using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { public class PrinceFlameSmall : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; public ref float Time => ref Projectile.ai[0]; public const int AttackDelay = 12; public override void SetStaticDefaults() { Main.projFrames[Projectile.type] = 4; ProjectileID.Sets.TrailingMode[Projectile.type] = 2; ProjectileID.Sets.TrailCacheLength[Projectile.type] = 3; } public override void SetDefaults() { Projectile.width = Projectile.height = 16; Projectile.friendly = true; Projectile.ignoreWater = true; Projectile.timeLeft = 240; Projectile.penetrate = 1; Projectile.DamageType = DamageClass.Magic; Projectile.extraUpdates = 2; } public override void AI() { Time++; Projectile.frameCounter++; Projectile.frame = Projectile.frameCounter / 5 % Main.projFrames[Projectile.type]; Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; Projectile.Opacity = Utils.GetLerpValue(0f, 15f, Projectile.timeLeft, true); if (Time > AttackDelay) CalamityUtils.HomeInOnNPC(Projectile, false, 600f, 14f, 32f); } public override bool PreDraw(ref Color lightColor) { lightColor = Color.Lerp(lightColor, Color.White, 0.8f); lightColor.A /= 3; CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); return false; } public override bool? CanHitNPC(NPC target) { if (Time > AttackDelay) return null; return false; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 60); } } }