using CalamityMod.Buffs.StatDebuffs; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { public class AcidShrapnel : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; public override string Texture => "CalamityMod/Projectiles/Rogue/BarrelShrapnel"; public bool HitTile = false; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 3; } public override void SetDefaults() { Projectile.width = 12; Projectile.height = 14; Projectile.friendly = true; Projectile.penetrate = 1; Projectile.timeLeft = 160; Projectile.tileCollide = true; Projectile.DamageType = RogueDamageClass.Instance; Projectile.ignoreWater = true; } public override void AI() { Projectile.ai[0] += 1f; if (HitTile) { Projectile.velocity.X = 0f; Projectile.rotation = MathHelper.Pi; } else Projectile.rotation = Projectile.velocity.ToRotation() + MathHelper.PiOver2; Projectile.velocity.Y += 0.2f; } public override bool OnTileCollide(Vector2 oldVelocity) { HitTile = true; return false; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 180); Projectile.Kill(); } public override void OnHitPlayer(Player target, Player.HurtInfo info) { target.AddBuff(ModContent.BuffType(), 180); Projectile.Kill(); } public override void Kill(int timeLeft) { for (int i = 0; i < 15; i++) { Dust dust = Dust.NewDustDirect(Projectile.position, Projectile.width, Projectile.height, (int)CalamityDusts.SulfurousSeaAcid); dust.velocity = Vector2.UnitY.RotatedBy(i / 15f * MathHelper.TwoPi) * 3f * (float)Math.Cos(i / 15f * MathHelper.TwoPi); dust.scale = 2.5f; dust.noGravity = true; } } } }