From cc96f5b3ef974ed9d50bb232f5be5c48abb1ec93 Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Wed, 21 Feb 2024 04:03:19 -0600 Subject: [PATCH] Vanilla Destroyer contact damage fairness that I forgot to push last time. --- .../VanillaNPCOverrides/Bosses/DestroyerAI.cs | 29 +++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs index 62396664c3..fba399341c 100644 --- a/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs +++ b/NPCs/VanillaNPCOverrides/Bosses/DestroyerAI.cs @@ -729,6 +729,35 @@ namespace CalamityMod.NPCs.VanillaNPCOverrides.Bosses if (npc.ai[3] > 0f) npc.realLife = (int)npc.ai[3]; + // Calculate contact damage based on velocity + float minimalContactDamageVelocity = 4f; + float minimalDamageVelocity = 8f; + if (npc.type == NPCID.TheDestroyer) + { + if (npc.velocity.Length() <= minimalContactDamageVelocity) + { + npc.damage = (int)(npc.defDamage * 0.5f); + } + else + { + float velocityDamageScalar = MathHelper.Clamp((npc.velocity.Length() - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); + npc.damage = (int)MathHelper.Lerp(npc.defDamage * 0.5f, npc.defDamage, velocityDamageScalar); + } + } + else + { + float bodyAndTailVelocity = (npc.position - npc.oldPosition).Length(); + if (bodyAndTailVelocity <= minimalContactDamageVelocity) + { + npc.damage = 0; + } + else + { + float velocityDamageScalar = MathHelper.Clamp((bodyAndTailVelocity - minimalContactDamageVelocity) / minimalDamageVelocity, 0f, 1f); + npc.damage = (int)MathHelper.Lerp(0f, npc.defDamage, velocityDamageScalar); + } + } + if (npc.target < 0 || npc.target == Main.maxPlayers || Main.player[npc.target].dead) npc.TargetClosest();