using System; using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.Audio; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Rogue { public class DeepSeaDumbbellWeight : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Rogue"; public override void SetDefaults() { Projectile.width = 14; Projectile.height = 14; Projectile.friendly = true; Projectile.DamageType = RogueDamageClass.Instance; Projectile.ignoreWater = true; Projectile.penetrate = 1; } public override void AI() { Projectile.rotation += Math.Abs(Projectile.velocity.X) * 0.04f * (float)Projectile.direction; Projectile.velocity.Y = Projectile.velocity.Y + 0.4f; Projectile.velocity.X = Projectile.velocity.X * 0.99f; if (Projectile.velocity.Y > 16f) { Projectile.velocity.Y = 16f; } } public override void OnKill(int timeLeft) { SoundEngine.PlaySound(SoundID.NPCDeath43 with { Volume = SoundID.NPCDeath43.Volume * 0.35f }, Projectile.position); Projectile.position = Projectile.Center; Projectile.width = Projectile.height = 36; Projectile.position.X = Projectile.position.X - (float)(Projectile.width / 2); Projectile.position.Y = Projectile.position.Y - (float)(Projectile.height / 2); int constant = 36; for (int i = 0; i < constant; i++) { Vector2 weightVel = Vector2.Normalize(Projectile.velocity) * new Vector2((float)Projectile.width / 2f, (float)Projectile.height) * 0.25f; weightVel = weightVel.RotatedBy((double)((float)(i - (constant / 2 - 1)) * 6.28318548f / (float)constant), default) + Projectile.Center; Vector2 dustVel = weightVel - Projectile.Center; int dusty = Dust.NewDust(weightVel + dustVel, 0, 0, DustID.Water, dustVel.X, dustVel.Y, 100, default, 1f); Main.dust[dusty].noGravity = true; Main.dust[dusty].velocity = dustVel; } Projectile.Damage(); } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 120); } public override void OnHitPlayer(Player target, Player.HurtInfo info) { target.AddBuff(ModContent.BuffType(), 120); } } }