using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Dusts; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { public class BrimroseBeam : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() { Projectile.width = Projectile.height = 4; Projectile.alpha = 255; Projectile.friendly = true; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = -1; Projectile.extraUpdates = 100; Projectile.timeLeft = 30; Projectile.usesIDStaticNPCImmunity = true; Projectile.idStaticNPCHitCooldown = 10; } public override void Kill(int timeLeft) { int numProj = 2; float rotation = MathHelper.ToRadians(Projectile.ai[0] >= 3f ? 20 : 10); // Splits up to 4 times if (Projectile.owner == Main.myPlayer && Projectile.ai[0] < 4f) { for (int i = 0; i < numProj; i++) { Vector2 perturbedSpeed = Projectile.velocity.RotatedBy(MathHelper.Lerp(-rotation, rotation, i / (numProj - 1))); Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, perturbedSpeed, Projectile.type, Projectile.damage, Projectile.knockBack, Projectile.owner, Projectile.ai[0] + 1f); } } } public override void AI() { // Small buffer before dust spawns on the first projectile Projectile.ai[1]++; if (Projectile.ai[1] > 9f || Projectile.ai[0] > 0f) { int fire = Dust.NewDust(Projectile.Center, 1, 1, (int)CalamityDusts.Brimstone, 0f, 0f, 0, default, 1.5f); Main.dust[fire].velocity *= 0.1f; Main.dust[fire].noGravity = true; } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 120); // Pierce damage decay time if (Projectile.numHits > 0) Projectile.damage = (int)(Projectile.damage * 0.8); } } }