using CalamityMod.Buffs.DamageOverTime; using CalamityMod.Projectiles.Typeless; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Magic { public class HolyLaser : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Magic"; public override string Texture => "CalamityMod/Projectiles/InvisibleProj"; public override void SetDefaults() { Projectile.width = 4; Projectile.height = 4; Projectile.friendly = true; Projectile.DamageType = DamageClass.Magic; Projectile.penetrate = 2; Projectile.extraUpdates = 100; Projectile.timeLeft = 180; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 30; } public override void AI() { Projectile.localAI[0] += 1f; if (Projectile.localAI[0] > 9f) { int dustType = Main.rand.Next(2); if (dustType == 0) { dustType = 244; } else { dustType = 246; } Vector2 projPos = Projectile.position; projPos -= Projectile.velocity * 0.25f; int holyDust = Dust.NewDust(projPos, 1, 1, dustType, 0f, 0f, 0, default, 0.25f); Main.dust[holyDust].position = projPos; Main.dust[holyDust].scale = (float)Main.rand.Next(70, 110) * 0.013f; Main.dust[holyDust].velocity *= 0.1f; } } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { target.AddBuff(ModContent.BuffType(), 180); if (Projectile.owner == Main.myPlayer) { int proj = Projectile.NewProjectile(Projectile.GetSource_FromThis(), Projectile.Center, Vector2.Zero, ModContent.ProjectileType(), Projectile.damage, Projectile.knockBack, Projectile.owner, 0f, 0.85f + Main.rand.NextFloat() * 1.15f); if (proj.WithinBounds(Main.maxProjectiles)) Main.projectile[proj].DamageType = DamageClass.Magic; } } } }