using Microsoft.Xna.Framework; using System; using Terraria; using Terraria.ID; using Terraria.ModLoader; using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Summon { public class LanternFlame : ModProjectile { private bool playSound = true; public override void SetStaticDefaults() { DisplayName.SetDefault("Flame"); Main.projFrames[projectile.type] = 4; ProjectileID.Sets.SentryShot[projectile.type] = true; } public override void SetDefaults() { projectile.width = 20; projectile.height = 20; projectile.friendly = true; projectile.minion = true; projectile.penetrate = 1; projectile.timeLeft = 600; projectile.alpha = 255; projectile.tileCollide = false; } public override void AI() { Lighting.AddLight(projectile.Center, (255 - projectile.alpha) * 1f / 255f, 0f, 0f); projectile.frameCounter++; if (projectile.frameCounter > 4) { projectile.frame++; projectile.frameCounter = 0; } if (projectile.frame >= 4) { projectile.frame = 0; } if (projectile.alpha > 0) { projectile.alpha -= 10; } if (projectile.alpha <= 25) { NPC potentialTarget = projectile.Center.MinionHoming(700f, Main.player[projectile.owner]); if (potentialTarget != null) projectile.velocity = (projectile.velocity * 20f + projectile.SafeDirectionTo(potentialTarget.Center) * 16f) / 21f; } } public override void Kill(int timeLeft) { projectile.position = projectile.Center; projectile.width = projectile.height = 48; projectile.position.X = projectile.position.X - (float)(projectile.width / 2); projectile.position.Y = projectile.position.Y - (float)(projectile.height / 2); projectile.maxPenetrate = -1; projectile.penetrate = -1; projectile.usesLocalNPCImmunity = true; projectile.localNPCHitCooldown = 10; projectile.Damage(); for (int num621 = 0; num621 < 10; num621++) { int num622 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f); Main.dust[num622].velocity *= 3f; if (Main.rand.NextBool(2)) { Main.dust[num622].scale = 0.5f; Main.dust[num622].fadeIn = 1f + (float)Main.rand.Next(10) * 0.1f; } } for (int num623 = 0; num623 < 15; num623++) { int num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, 3f); Main.dust[num624].noGravity = true; Main.dust[num624].velocity *= 5f; num624 = Dust.NewDust(new Vector2(projectile.position.X, projectile.position.Y), projectile.width, projectile.height, 127, 0f, 0f, 100, default, 2f); Main.dust[num624].velocity *= 2f; } } public override void OnHitNPC(NPC target, int damage, float knockback, bool crit) { target.AddBuff(ModContent.BuffType(), 180); if (playSound) { Main.PlaySound(SoundID.Item74, projectile.position); } playSound = false; } } }