using CalamityMod.World; using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Boss { public class ScavengerNuke : ModProjectile { public override void SetStaticDefaults() { DisplayName.SetDefault("Homing Nuke"); Main.projFrames[projectile.type] = 5; } public override void SetDefaults() { projectile.width = 44; projectile.height = 44; projectile.hostile = true; projectile.ignoreWater = true; projectile.tileCollide = false; projectile.penetrate = 1; projectile.alpha = 255; projectile.timeLeft = 720; } public override void AI() { bool revenge = CalamityWorld.revenge || CalamityWorld.bossRushActive; projectile.ai[1] += 1f; if (projectile.ai[1] > 480) { projectile.tileCollide = true; } projectile.frameCounter++; if (projectile.frameCounter > 18) { projectile.frame++; projectile.frameCounter = 0; } if (projectile.frame > 4) { projectile.frame = 0; } projectile.rotation = (float)Math.Atan2((double)projectile.velocity.Y, (double)projectile.velocity.X) + 1.57f; float num953 = revenge ? 75f : 60f; float scaleFactor12 = revenge ? 15f : 12f; float num954 = 40f; if (projectile.alpha > 0) { projectile.alpha -= 10; } if (projectile.alpha < 0) { projectile.alpha = 0; } projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; projectile.frameCounter = 0; } if (projectile.frame > 3) { projectile.frame = 0; } Lighting.AddLight(projectile.Center, 1f, 0.7f, 0f); int num959 = (int)projectile.ai[0]; if (num959 >= 0 && Main.player[num959].active && !Main.player[num959].dead) { if (projectile.Distance(Main.player[num959].Center) > num954) { Vector2 vector102 = projectile.DirectionTo(Main.player[num959].Center); if (vector102.HasNaNs()) { vector102 = Vector2.UnitY; } projectile.velocity = (projectile.velocity * (num953 - 1f) + vector102 * scaleFactor12) / num953; } } else { if (projectile.timeLeft > 30) { projectile.timeLeft = 30; } if (projectile.ai[0] != -1f) { projectile.ai[0] = -1f; projectile.netUpdate = true; } } } public override void Kill(int timeLeft) { Main.PlaySound(2, (int)projectile.position.X, (int)projectile.position.Y, 14); projectile.position = projectile.Center; projectile.width = projectile.height = 160; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); projectile.Damage(); for (int num621 = 0; num621 < 30; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 40; num623++) { int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } for (int num625 = 0; num625 < 3; num625++) { float scaleFactor10 = 0.33f; if (num625 == 1) { scaleFactor10 = 0.66f; } if (num625 == 2) { scaleFactor10 = 1f; } int num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f); Main.gore[num626].velocity *= scaleFactor10; Gore expr_13AB6_cp_0 = Main.gore[num626]; expr_13AB6_cp_0.velocity.X += 1f; Gore expr_13AD6_cp_0 = Main.gore[num626]; expr_13AD6_cp_0.velocity.Y += 1f; num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f); Main.gore[num626].velocity *= scaleFactor10; Gore expr_13B79_cp_0 = Main.gore[num626]; expr_13B79_cp_0.velocity.X -= 1f; Gore expr_13B99_cp_0 = Main.gore[num626]; expr_13B99_cp_0.velocity.Y += 1f; num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f); Main.gore[num626].velocity *= scaleFactor10; Gore expr_13C3C_cp_0 = Main.gore[num626]; expr_13C3C_cp_0.velocity.X += 1f; Gore expr_13C5C_cp_0 = Main.gore[num626]; expr_13C5C_cp_0.velocity.Y -= 1f; num626 = Gore.NewGore(new Vector2(projectile.position.X + (float)(projectile.width / 2) - 24f, projectile.position.Y + (float)(projectile.height / 2) - 24f), default, Main.rand.Next(61, 64), 1f); Main.gore[num626].velocity *= scaleFactor10; Gore expr_13CFF_cp_0 = Main.gore[num626]; expr_13CFF_cp_0.velocity.X -= 1f; Gore expr_13D1F_cp_0 = Main.gore[num626]; expr_13D1F_cp_0.velocity.Y -= 1f; } } } }