using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; namespace CalamityMod.Projectiles.Ranged { public class MiniatureFolly : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Ranged"; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 2; } public override void SetDefaults() { Projectile.width = 24; Projectile.height = 8; Projectile.friendly = true; Projectile.DamageType = DamageClass.Ranged; Projectile.penetrate = 1; Projectile.timeLeft = 600; Projectile.light = 0.25f; Projectile.extraUpdates = 1; } public override bool OnTileCollide(Vector2 oldVelocity) { Collision.HitTiles(Projectile.position, Projectile.velocity, Projectile.width, Projectile.height); SoundEngine.PlaySound(SoundID.NPCHit51, Projectile.Center); return true; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { SoundEngine.PlaySound(SoundID.NPCHit51, Projectile.Center); } public override void AI() { Projectile.frameCounter++; if (Projectile.frameCounter > 4) { Projectile.frame++; Projectile.frameCounter = 0; } if (Projectile.frame > 1) { Projectile.frame = 0; } if (Main.rand.Next(5) == 0) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 244, Projectile.velocity.X * 0.5f, Projectile.velocity.Y * 0.5f); } Projectile.spriteDirection = Projectile.direction = (Projectile.velocity.X > 0).ToDirectionInt(); Projectile.rotation = Projectile.velocity.ToRotation() + (Projectile.spriteDirection == 1 ? MathHelper.Pi : 0f); CalamityUtils.HomeInOnNPC(Projectile, !Projectile.tileCollide, 300f, 10f, 20f); } } }