using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using CalamityMod.Projectiles.Summon; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { public class CorrodedShell : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; public override void SetDefaults() { Projectile.width = 14; Projectile.height = 14; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.arrow = true; Projectile.ignoreWater = true; Projectile.penetrate = 6; Projectile.timeLeft = 600; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 12; Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { Projectile.velocity *= 0.9995f; Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; if (Projectile.timeLeft % 5 == 0) { if (Projectile.owner == Main.myPlayer) { int aura = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), (int)(Projectile.damage * 0.15), Projectile.knockBack, Projectile.owner); if (aura.WithinBounds(Main.maxProjectiles)) { Main.projectile[aura].DamageType = DamageClass.Ranged; Main.projectile[aura].timeLeft = 20; } } } } public override void OnKill(int timeLeft) { Projectile.position = Projectile.Center; Projectile.width = Projectile.height = 32; Projectile.position = Projectile.position - Projectile.Size / 2f; Projectile.maxPenetrate = -1; Projectile.penetrate = -1; Projectile.Damage(); SoundEngine.PlaySound(SoundID.Item92, Projectile.Center); int count = Main.rand.Next(6, 15); for (int i = 0; i < count; i++) { int idx = Dust.NewDust(Projectile.Center - Projectile.velocity / 2f, 0, 0, (int)CalamityDusts.SulfurousSeaAcid, 0f, 0f, 100, default, 2f); Main.dust[idx].velocity *= 2f; Main.dust[idx].noGravity = true; } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 480); } } }