using System; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Enemy { public class PufferExplosion : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Enemy"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() { Projectile.width = 250; Projectile.height = 250; Projectile.friendly = true; Projectile.hostile = true; Projectile.ignoreWater = true; Projectile.tileCollide = false; Projectile.penetrate = -1; Projectile.timeLeft = 210; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 1; } public override void AI() { Lighting.AddLight(Projectile.Center, (255 - Projectile.alpha) * 0.75f / 255f, (255 - Projectile.alpha) * 0.5f / 255f, (255 - Projectile.alpha) * 0.01f / 255f); if (Projectile.localAI[0] == 0f) { SoundEngine.PlaySound(SoundID.Item20, Projectile.Center); Projectile.localAI[0] += 1f; } bool xflag = false; bool yflag = false; if (Projectile.velocity.X < 0f && Projectile.position.X < Projectile.ai[0]) { xflag = true; } if (Projectile.velocity.X > 0f && Projectile.position.X > Projectile.ai[0]) { xflag = true; } if (Projectile.velocity.Y < 0f && Projectile.position.Y < Projectile.ai[1]) { yflag = true; } if (Projectile.velocity.Y > 0f && Projectile.position.Y > Projectile.ai[1]) { yflag = true; } if (xflag && yflag) { Projectile.Kill(); } float projTimer = 25f; if (Projectile.ai[0] > 180f) { projTimer -= (Projectile.ai[0] - 180f) / 2f; } if (projTimer <= 0f) { projTimer = 0f; Projectile.Kill(); } projTimer *= 0.7f; Projectile.ai[0] += 4f; int timerCounter = 0; while ((float)timerCounter < projTimer) { float rando1 = (float)Main.rand.Next(-30, 35); float rando2 = (float)Main.rand.Next(-30, 35); float rando3 = (float)Main.rand.Next(13, 18); float randoAdjuster = (float)Math.Sqrt((double)(rando1 * rando1 + rando2 * rando2)); randoAdjuster = rando3 / randoAdjuster; rando1 *= randoAdjuster; rando2 *= randoAdjuster; int explodeBrimStyle = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.Brimstone, 0f, 0f, 100, default, 1.5f); Main.dust[explodeBrimStyle].noGravity = true; Main.dust[explodeBrimStyle].position.X = Projectile.Center.X; Main.dust[explodeBrimStyle].position.Y = Projectile.Center.Y; Dust expr_149DF_cp_0 = Main.dust[explodeBrimStyle]; expr_149DF_cp_0.position.X += (float)Main.rand.Next(-10, 11); Dust expr_14A09_cp_0 = Main.dust[explodeBrimStyle]; expr_14A09_cp_0.position.Y += (float)Main.rand.Next(-10, 11); Main.dust[explodeBrimStyle].velocity.X = rando1; Main.dust[explodeBrimStyle].velocity.Y = rando2; timerCounter++; } } } }