Vanilla Destroyer contact damage fairness that I forgot to push last time.
This commit is contained in:
1 parent
4400050e70
commit
cc96f5b3ef
1 file changed
+29
@@ -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();
|
||||
|
||||
|
||||
Reference in new issue
Block a user