public override bool PreAI() { projectile.ai[1] += 1f; bool chasing = false; if (projectile.ai[1] >= 30f) { chasing = true; projectile.friendly = true; NPC target = null; if (projectile.ai[0] == -1f) { target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false); } else { target = Main.npc[(int)projectile.ai[0]]; if (!target.active || !target.CanBeChasedBy()) { target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false); } } if (target == null) { chasing = false; projectile.ai[0] = -1f; } else { projectile.ai[0] = (float)target.whoAmI; ProjectileExtras.HomingAI(this, target, 10f, 5f); } } ProjectileExtras.LookAlongVelocity(this); if (!chasing) { Vector2 dir = projectile.velocity; float vel = projectile.velocity.Length(); if (vel != 0f) { if (vel < 4f) { dir *= 1 / vel; projectile.velocity += dir * 0.0625f; } } else { //Stops the projectiles from spazzing out projectile.velocity.X += Main.rand.Next(2) == 0 ? 0.1f : -0.1f; } } { int dust = Dust.NewDust(projectile.position + projectile.velocity, projectile.width, projectile.height, 75, projectile.velocity.X * 0.5f, projectile.velocity.Y * 0.5f); } return(false); }
public override void AI() { if (projectile.ai[1] == 0) { projectile.ai[0] = -1; } projectile.ai[1] += 1f; bool chasing = false; if (projectile.ai[1] >= 30f) { chasing = true; projectile.friendly = true; NPC target = null; if (projectile.ai[0] < 0 || projectile.ai[0] >= Main.maxNPCs) { target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false); } else { target = Main.npc[(int)projectile.ai[0]]; if (!target.active || !target.CanBeChasedBy()) { target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false); } } if (target == null) { chasing = false; projectile.ai[0] = -1f; } else { projectile.ai[0] = (float)target.whoAmI; ProjectileExtras.HomingAI(this, target, 10f, .5f); } } ProjectileExtras.LookAlongVelocity(this); if (!chasing) { Vector2 dir = projectile.velocity; float vel = projectile.velocity.Length(); if (vel != 0f) { if (vel < 8f) { dir *= 1 / vel; projectile.velocity += dir * 0.0625f; } } else { //Stops the projectile from spazzing out projectile.velocity.X += Main.rand.Next(2) == 0 ? 0.1f : -0.1f; } } for (int i = 0; i < 10; i++) { Vector2 pos = projectile.Center - projectile.velocity * ((float)i / 10f); int num = Dust.NewDust(pos, 2, 2, DustID.SilverCoin); Main.dust[num].alpha = projectile.alpha; //Main.dust[num].position = pos; Main.dust[num].velocity = Vector2.Zero; Main.dust[num].noGravity = true; } }
public override bool PreAI() { projectile.ai[1] += 1f; bool chasing = false; if (projectile.ai[1] >= 30f) { chasing = true; projectile.friendly = true; NPC target = null; if (projectile.ai[0] == -1f) { target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false); } else { target = Main.npc[(int)projectile.ai[0]]; if (!target.active || !target.CanBeChasedBy()) { target = ProjectileExtras.FindRandomNPC(projectile.Center, 960f, false); } } if (target == null) { chasing = false; projectile.ai[0] = -1f; } else { projectile.ai[0] = (float)target.whoAmI; ProjectileExtras.HomingAI(this, target, 10f, 5f); } } ProjectileExtras.LookAlongVelocity(this); if (!chasing) { Vector2 dir = projectile.velocity; float vel = projectile.velocity.Length(); if (vel != 0f) { if (vel < 4f) { dir *= 1 / vel; projectile.velocity += dir * 0.0625f; } } else { //Stops the projectiles from spazzing out projectile.velocity.X += Main.rand.Next(2) == 0 ? 0.1f : -0.1f; } } int num = 5; for (int k = 0; k < 3; k++) { int index2 = Dust.NewDust(projectile.position, 1, 1, DustID.DungeonWater, 0.0f, 0.0f, 0, new Color(), 1f); Main.dust[index2].position = projectile.Center - projectile.velocity / num * (float)k; Main.dust[index2].scale = .5f; Main.dust[index2].velocity *= 0f; Main.dust[index2].noGravity = true; Main.dust[index2].noLight = false; } return(false); }