using CalamityMod.Buffs.DamageOverTime; using Microsoft.Xna.Framework; using Terraria; using Terraria.ModLoader; namespace CalamityMod.Projectiles.Melee { public class FallenBlast : ModProjectile, ILocalizedModType { public new string LocalizationCategory => "Projectiles.Melee"; public override void SetStaticDefaults() => Main.projFrames[Type] = 8; private static float ExplosionRadius = 236f; public override void SetDefaults() { Projectile.width = 472; Projectile.height = 472; Projectile.friendly = true; Projectile.DamageType = DamageClass.MeleeNoSpeed; Projectile.penetrate = -1; Projectile.tileCollide = false; Projectile.ignoreWater = true; Projectile.usesLocalNPCImmunity = true; Projectile.localNPCHitCooldown = 600; Projectile.timeLeft = 24; } public override void AI() { Projectile.frameCounter++; if (Projectile.frameCounter % 3 == 0) Projectile.frame = (Projectile.frame + 1) % Main.projFrames[Type]; if (Projectile.frame >= 8) Projectile.Kill(); Projectile.rotation = Projectile.velocity.ToRotation() - MathHelper.PiOver2 * 1.5f; } public override void ModifyHitNPC(NPC target, ref NPC.HitModifiers modifiers) { target.AddBuff(ModContent.BuffType(), 60); float minMult = 0.15f; int hitsToMinMult = 12; float damageMult = Utils.Remap(Projectile.numHits, 0, hitsToMinMult, 1, minMult, true); modifiers.SourceDamage *= damageMult; } public override void OnHitNPC(NPC target, NPC.HitInfo hit, int damageDone) { // If you are hitting an armored target or kill a target, don't reduce damage based on enemy hits if ((damageDone <= 2 || (target.life <= 0 && target.realLife == -1)) && Projectile.numHits > 0) { Projectile.numHits -= 1; } } public override bool? Colliding(Rectangle projHitbox, Rectangle targetHitbox) => CalamityUtils.CircularHitboxCollision(Projectile.Center, ExplosionRadius, targetHitbox); } }