using Microsoft.Xna.Framework; using Terraria; using Terraria.ID; using Terraria.ModLoader; using Terraria.Audio; using CalamityMod.Buffs.DamageOverTime; namespace CalamityMod.Projectiles.Melee { public class BurningMeteor : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; private int noTileHitCounter = 120; public override void SetStaticDefaults() { ProjectileID.Sets.TrailCacheLength[Projectile.type] = 5; ProjectileID.Sets.TrailingMode[Projectile.type] = 0; } public override void SetDefaults() { Projectile.width = 46; Projectile.height = 46; Projectile.alpha = 150; Projectile.friendly = true; Projectile.DamageType = DamageClass.Melee; Projectile.tileCollide = false; Projectile.penetrate = 1; Projectile.extraUpdates = 2; Projectile.timeLeft = 180; Projectile.ignoreWater = true; } public override void AI() { int randomToSubtract = Main.rand.Next(1, 4); noTileHitCounter -= randomToSubtract; if (noTileHitCounter == 0) { Projectile.tileCollide = true; } if (Projectile.soundDelay == 0) { Projectile.soundDelay = 20 + Main.rand.Next(40); if (Main.rand.NextBool(5)) { SoundEngine.PlaySound(SoundID.Item20, Projectile.position); } } Projectile.localAI[0] += 1f; if (Projectile.localAI[0] == 30f) { Projectile.localAI[0] = 0f; for (int l = 0; l < 12; l++) { Vector2 vector3 = Vector2.UnitX * (float)-(float)Projectile.width / 2f; vector3 += -Vector2.UnitY.RotatedBy((double)((float)l * 3.14159274f / 6f), default) * new Vector2(8f, 16f); vector3 = vector3.RotatedBy((double)(Projectile.rotation - 1.57079637f), default); int num9 = Dust.NewDust(Projectile.Center, 0, 0, 244, 0f, 0f, 160, default, 1f); Main.dust[num9].scale = 1.1f; Main.dust[num9].noGravity = true; Main.dust[num9].position = Projectile.Center + vector3; Main.dust[num9].velocity = Projectile.velocity * 0.1f; Main.dust[num9].velocity = Vector2.Normalize(Projectile.Center - Projectile.velocity * 3f - Main.dust[num9].position) * 1.25f; } } Projectile.alpha -= 15; int num58 = 150; if (Projectile.Center.Y >= Projectile.ai[1]) { num58 = 0; } if (Projectile.alpha < num58) { Projectile.alpha = num58; } Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2; } public override void Kill(int timeLeft) { for (int k = 0; k < 5; k++) { Dust.NewDust(Projectile.position + Projectile.velocity, Projectile.width, Projectile.height, 244, 0f, 0f); } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 180); } public override bool PreDraw(ref Color lightColor) { if (Projectile.timeLeft > 175) return false; CalamityUtils.DrawAfterimagesCentered(Projectile, ProjectileID.Sets.TrailingMode[Projectile.type], lightColor, 1); return false; } } }