using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Melee { public class Earth3 : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; private int noTileHitCounter = 120; public override void SetDefaults() { Projectile.width = 34; Projectile.height = 34; Projectile.alpha = 100; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.tileCollide = false; Projectile.penetrate = 1; Projectile.timeLeft = 300; Projectile.ignoreWater = true; } public override void AI() { int randomToSubtract = Main.rand.Next(1, 4); noTileHitCounter -= randomToSubtract; if (noTileHitCounter == 0) { Projectile.tileCollide = true; } if (Projectile.soundDelay == 0) { Projectile.soundDelay = 20 + Main.rand.Next(40); if (Main.rand.NextBool(5)) { SoundEngine.PlaySound(SoundID.Item9, Projectile.position); } } Projectile.alpha -= 15; int num58 = 150; if (Projectile.Center.Y >= Projectile.ai[1]) { num58 = 0; } if (Projectile.alpha < num58) { Projectile.alpha = num58; } Projectile.localAI[0] += (Math.Abs(Projectile.velocity.X) + Math.Abs(Projectile.velocity.Y)) * 0.01f * (float)Projectile.direction; Projectile.rotation = Projectile.velocity.ToRotation() - 1.57079637f; if (Main.rand.NextBool(16)) { Vector2 value3 = Vector2.UnitX.RotatedByRandom(1.5707963705062866).RotatedBy((double)Projectile.velocity.ToRotation(), default); int num59 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); Main.dust[num59].velocity = value3 * 0.66f; Main.dust[num59].position = Projectile.Center + value3 * 12f; } if (Main.rand.NextBool(48) && Main.netMode != NetmodeID.Server) { int num60 = Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.Center, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), 16, 1f); Main.gore[num60].velocity *= 0.66f; Main.gore[num60].velocity += Projectile.velocity * 0.3f; } if (Projectile.ai[1] == 1f) { Projectile.light = 0.9f; if (Main.rand.NextBool(10)) { Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f, 150, default, 1.2f); } if (Main.rand.NextBool(20) && Main.netMode != NetmodeID.Server) { Gore.NewGore(Projectile.GetSource_FromAI(), Projectile.position, new Vector2(Projectile.velocity.X * 0.2f, Projectile.velocity.Y * 0.2f), Main.rand.Next(16, 18), 1f); } } Lighting.AddLight(Projectile.Center, 1.5f, 0f, 0f); } public override void Kill(int timeLeft) { SoundEngine.PlaySound(SoundID.Item14, Projectile.position); Projectile.position.X = Projectile.position.X + (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y + (float)(Projectile.height / 2); Projectile.width = 30; Projectile.height = 30; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); for (int num621 = 0; num621 < 20; num621++) { int num622 = Dust.NewDust(Projectile.position, 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 < 35; num623++) { int num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; num624 = Dust.NewDust(Projectile.position, Projectile.width, Projectile.height, 244, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } if (Main.netMode != NetmodeID.Server) { Vector2 goreSource = Projectile.Center; int goreAmt = 3; Vector2 source = new Vector2(goreSource.X - 24f, goreSource.Y - 24f); for (int goreIndex = 0; goreIndex < goreAmt; goreIndex++) { float velocityMult = 0.33f; if (goreIndex < (goreAmt / 3)) { velocityMult = 0.66f; } if (goreIndex >= (2 * goreAmt / 3)) { velocityMult = 1f; } Mod mod = ModContent.GetInstance(); int type = Main.rand.Next(61, 64); int smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); Gore gore = Main.gore[smoke]; gore.velocity *= velocityMult; gore.velocity.X += 1f; gore.velocity.Y += 1f; type = Main.rand.Next(61, 64); smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); gore = Main.gore[smoke]; gore.velocity *= velocityMult; gore.velocity.X -= 1f; gore.velocity.Y += 1f; type = Main.rand.Next(61, 64); smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); gore = Main.gore[smoke]; gore.velocity *= velocityMult; gore.velocity.X += 1f; gore.velocity.Y -= 1f; type = Main.rand.Next(61, 64); smoke = Gore.NewGore(Projectile.GetSource_Death(), source, default, type, 1f); gore = Main.gore[smoke]; gore.velocity *= velocityMult; gore.velocity.X -= 1f; gore.velocity.Y -= 1f; } } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 240); } } }