198 lines
8.2 KiB
C#
198 lines
8.2 KiB
C#
using CalamityMod.CalPlayer;
|
|
using Microsoft.Xna.Framework;
|
|
using System;
|
|
using Terraria;
|
|
using Terraria.ID;
|
|
using Terraria.ModLoader;
|
|
|
|
namespace CalamityMod.Projectiles.Summon
|
|
{
|
|
public class WaterElementalMinion : ModProjectile
|
|
{
|
|
public int dust = 3;
|
|
|
|
public override void SetStaticDefaults()
|
|
{
|
|
DisplayName.SetDefault("Anahita");
|
|
Main.projFrames[projectile.type] = 6;
|
|
ProjectileID.Sets.MinionSacrificable[projectile.type] = true;
|
|
ProjectileID.Sets.MinionTargettingFeature[projectile.type] = true;
|
|
}
|
|
|
|
public override void SetDefaults()
|
|
{
|
|
projectile.width = 100;
|
|
projectile.height = 190;
|
|
projectile.netImportant = true;
|
|
projectile.friendly = true;
|
|
projectile.ignoreWater = true;
|
|
projectile.minion = true;
|
|
projectile.minionSlots = 0f;
|
|
projectile.timeLeft = 18000;
|
|
projectile.penetrate = -1;
|
|
projectile.tileCollide = false;
|
|
projectile.timeLeft *= 5;
|
|
}
|
|
|
|
public override void AI()
|
|
{
|
|
bool flag64 = projectile.type == ModContent.ProjectileType<WaterElementalMinion>();
|
|
Player player = Main.player[projectile.owner];
|
|
CalamityPlayer modPlayer = player.Calamity();
|
|
if (!modPlayer.sirenWaifu && !modPlayer.allWaifus)
|
|
{
|
|
projectile.active = false;
|
|
return;
|
|
}
|
|
if (flag64)
|
|
{
|
|
if (player.dead)
|
|
{
|
|
modPlayer.slWaifu = false;
|
|
}
|
|
if (modPlayer.slWaifu)
|
|
{
|
|
projectile.timeLeft = 2;
|
|
}
|
|
}
|
|
if (dust > 0)
|
|
{
|
|
projectile.Calamity().spawnedPlayerMinionDamageValue = player.MinionDamage();
|
|
projectile.Calamity().spawnedPlayerMinionProjectileDamageValue = projectile.damage;
|
|
int num501 = 50;
|
|
for (int num502 = 0; num502 < num501; num502++)
|
|
{
|
|
int num503 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y + 16f), projectile.width, projectile.height - 16, 33, 0f, 0f, 0, default, 1f);
|
|
Main.dust[num503].velocity *= 2f;
|
|
Main.dust[num503].scale *= 1.15f;
|
|
}
|
|
dust--;
|
|
}
|
|
if (player.MinionDamage() != projectile.Calamity().spawnedPlayerMinionDamageValue)
|
|
{
|
|
int damage2 = (int)((float)projectile.Calamity().spawnedPlayerMinionProjectileDamageValue /
|
|
projectile.Calamity().spawnedPlayerMinionDamageValue * player.MinionDamage());
|
|
projectile.damage = damage2;
|
|
}
|
|
Lighting.AddLight(projectile.Center, 0f, 0.25f, 1.5f);
|
|
projectile.frameCounter++;
|
|
if (projectile.frameCounter > 8)
|
|
{
|
|
projectile.frame++;
|
|
projectile.frameCounter = 0;
|
|
}
|
|
if (projectile.frame >= 6)
|
|
{
|
|
projectile.frame = 0;
|
|
}
|
|
projectile.Center = player.Center + Vector2.UnitY * (player.gfxOffY - 180f);
|
|
if (player.gravDir == -1f)
|
|
{
|
|
projectile.position.Y += 360f;
|
|
projectile.rotation = MathHelper.Pi;
|
|
}
|
|
else
|
|
{
|
|
projectile.rotation = 0f;
|
|
}
|
|
projectile.position.X = (int)projectile.position.X;
|
|
projectile.position.Y = (int)projectile.position.Y;
|
|
if (projectile.owner == Main.myPlayer)
|
|
{
|
|
// Prevent firing immediately
|
|
if (projectile.localAI[0] < 120f)
|
|
projectile.localAI[0] += 1f;
|
|
|
|
if (projectile.ai[0] != 0f)
|
|
{
|
|
projectile.ai[0] -= 1f;
|
|
return;
|
|
}
|
|
bool flag18 = false;
|
|
float num506 = projectile.Center.X;
|
|
float num507 = projectile.Center.Y;
|
|
float num508 = 1000f;
|
|
if (player.HasMinionAttackTargetNPC)
|
|
{
|
|
NPC npc = Main.npc[player.MinionAttackTargetNPC];
|
|
if (npc.CanBeChasedBy(projectile, false))
|
|
{
|
|
float num539 = npc.position.X + (float)(npc.width / 2);
|
|
float num540 = npc.position.Y + (float)(npc.height / 2);
|
|
float num541 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num539) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num540);
|
|
if (num541 < num508 && Collision.CanHit(projectile.position, projectile.width, projectile.height, npc.position, npc.width, npc.height))
|
|
{
|
|
num506 = num539;
|
|
num507 = num540;
|
|
flag18 = true;
|
|
}
|
|
}
|
|
}
|
|
if (!flag18)
|
|
{
|
|
for (int num512 = 0; num512 < Main.maxNPCs; num512++)
|
|
{
|
|
if (Main.npc[num512].CanBeChasedBy(projectile, false))
|
|
{
|
|
float num513 = Main.npc[num512].position.X + (float)(Main.npc[num512].width / 2);
|
|
float num514 = Main.npc[num512].position.Y + (float)(Main.npc[num512].height / 2);
|
|
float num515 = Math.Abs(projectile.position.X + (float)(projectile.width / 2) - num513) + Math.Abs(projectile.position.Y + (float)(projectile.height / 2) - num514);
|
|
if (num515 < num508 && Collision.CanHit(projectile.position, projectile.width, projectile.height, Main.npc[num512].position, Main.npc[num512].width, Main.npc[num512].height))
|
|
{
|
|
num508 = num515;
|
|
num506 = num513;
|
|
num507 = num514;
|
|
flag18 = true;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
if (flag18 && projectile.localAI[0] >= 120f)
|
|
{
|
|
float num516 = num506;
|
|
float num517 = num507;
|
|
num506 -= projectile.Center.X;
|
|
num507 -= projectile.Center.Y;
|
|
if (num506 < 0f)
|
|
{
|
|
projectile.spriteDirection = 1;
|
|
}
|
|
else
|
|
{
|
|
projectile.spriteDirection = -1;
|
|
}
|
|
int projectileType = ModContent.ProjectileType<WaterSpearFriendly>();
|
|
if (Main.rand.NextBool(9))
|
|
{
|
|
projectileType = ModContent.ProjectileType<FrostMistFriendly>();
|
|
}
|
|
else if (Main.rand.NextBool(9))
|
|
{
|
|
projectileType = ModContent.ProjectileType<SirenSongFriendly>();
|
|
}
|
|
float num403 = Main.rand.Next(12, 20);
|
|
Vector2 vector29 = new Vector2(projectile.position.X + (float)projectile.width * 0.5f, projectile.position.Y + (float)projectile.height * 0.5f);
|
|
float num404 = num516 - vector29.X;
|
|
float num405 = num517 - vector29.Y;
|
|
float num406 = (float)Math.Sqrt((double)(num404 * num404 + num405 * num405));
|
|
num406 = num403 / num406;
|
|
num404 *= num406;
|
|
num405 *= num406;
|
|
Projectile.NewProjectile(projectile.Center.X - 4f, projectile.Center.Y, num404, num405, projectileType, projectile.damage, projectile.knockBack, projectile.owner, 0f, 0f);
|
|
projectile.ai[0] = 12f;
|
|
}
|
|
}
|
|
}
|
|
|
|
public override Color? GetAlpha(Color lightColor)
|
|
{
|
|
return new Color(200, 200, 200, 200);
|
|
}
|
|
|
|
public override bool CanDamage()
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
}
|