using CalamityMod.Buffs.StatDebuffs; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Ranged { public class MistArrow : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 3; } public override void SetDefaults() { Projectile.width = 14; Projectile.height = 14; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.alpha = 255; Projectile.penetrate = 1; Projectile.aiStyle = ProjAIStyleID.Arrow; Projectile.timeLeft = 300; AIType = ProjectileID.WoodenArrowFriendly; Projectile.arrow = true; Projectile.coldDamage = true; Projectile.Calamity().pointBlankShotDuration = CalamityGlobalProjectile.DefaultPointBlankDuration; } public override void AI() { //Animation Projectile.frameCounter++; if (Projectile.frameCounter > 9) { Projectile.frame++; Projectile.frameCounter = 0; } if (Projectile.frame > 2) { Projectile.frame = 0; } //Fade in if (Projectile.alpha > 5) Projectile.alpha -= 15; if (Projectile.alpha < 5) Projectile.alpha = 5; //Rotation Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? 0f : MathHelper.Pi) + MathHelper.ToRadians(90) * Projectile.direction; Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 4f) { Vector2 dspeed = -Projectile.velocity * Main.rand.NextFloat(0.3f, 0.6f); int num469 = Dust.NewDust(new Vector2(Projectile.position.X, Projectile.position.Y), Projectile.width, Projectile.height, 31, 0f, 0f, 100, new Color(237, 242, 242, 200), 1.2f); Main.dust[num469].noGravity = true; Main.dust[num469].velocity = dspeed; } } public override void Kill(int timeLeft) { for (int k = 0; k < 5; k++) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 31, Projectile.oldVelocity.X * 0.5f, Projectile.oldVelocity.Y * 0.5f, 100, new Color(237, 242, 242, 200), 1f); } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(BuffID.Frostburn2, 180); target.AddBuff(ModContent.BuffType(), 30); } } }