From 05bae1c145f4b7dcb2f0d43edd28fcc93a67b26c Mon Sep 17 00:00:00 2001 From: mountaindrew10 Date: Sat, 14 Sep 2024 13:40:49 -0500 Subject: [PATCH] Added charge safety for the Ebonian Paladin. --- NPCs/SlimeGod/EbonianPaladin.cs | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/NPCs/SlimeGod/EbonianPaladin.cs b/NPCs/SlimeGod/EbonianPaladin.cs index 6559ad81cf..4096de5453 100644 --- a/NPCs/SlimeGod/EbonianPaladin.cs +++ b/NPCs/SlimeGod/EbonianPaladin.cs @@ -322,6 +322,9 @@ namespace CalamityMod.NPCs.SlimeGod // Charge by swooping down else if (NPC.ai[0] == 3f) { + // Distance required to charge + float minChargeSafeDistance = 400f; + // Charge variables float chargeVelocityMult = 0.125f; float maxChargeVelocity = (bossRush || enraged) ? 24f : death ? 21f : revenge ? 19.5f : expertMode ? 18f : 15f; @@ -339,18 +342,29 @@ namespace CalamityMod.NPCs.SlimeGod // Start charge if (NPC.ai[1] == 0f) { - // Set damage - NPC.damage = setDamage; - Vector2 velocity = (player.Center - NPC.Center).SafeNormalize(new Vector2(NPC.direction, 0f)) * maxChargeVelocity; NPC.velocity = velocity * chargeVelocityMult; - NPC.ai[1] = 1f; - NPC.netUpdate = true; + if (NPC.Distance(player.Center) > minChargeSafeDistance) + { + // Avoid cheap bullshit + NPC.damage = 0; - SoundEngine.PlaySound(SlimeGodCore.BigShotSound, NPC.Center); + // Move away if too close + NPC.velocity /= chargeVelocityMult * -1f; + } + else + { + // Set damage + NPC.damage = setDamage; - NPC.aiAction = 1; + NPC.ai[1] = 1f; + NPC.netUpdate = true; + + SoundEngine.PlaySound(SlimeGodCore.BigShotSound, NPC.Center); + + NPC.aiAction = 1; + } } else if (NPC.ai[1] == 1f) {