mirror of
https://github.com/KAMKEEL/CustomNPC-Plus.git
synced 2026-11-12 21:17:32 +00:00
Attempt at damage reduction
This commit is contained in:
1 parent
4f629c5679
commit
8fc0155df8
1 file changed
+11
-3
@@ -20,6 +20,7 @@ import kamkeel.npcs.controllers.data.ability.gui.AbilityFieldDefs;
|
||||
|
||||
import cpw.mods.fml.relauncher.Side;
|
||||
import cpw.mods.fml.relauncher.SideOnly;
|
||||
import noppes.npcs.util.ValueUtil;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
@@ -117,12 +118,19 @@ public class AbilityGuard extends Ability implements IAbilityGuard {
|
||||
}
|
||||
|
||||
public void onDamageTaken(EntityLivingBase caster, EntityLivingBase attacker, DamageSource source, float damage) {
|
||||
if (!isGuarding()) return;
|
||||
if (!canCounter || attacker == null || !counterEligible) return;
|
||||
if (!isDirectHit(source)) return;
|
||||
if (!isGuarding() || attacker == null) return;
|
||||
|
||||
lastAttacker = attacker;
|
||||
lastDamageTaken = damage;
|
||||
|
||||
float reduction = ValueUtil.clamp(getDamageReductionFactor(), 0, damage);
|
||||
float newHealth = ValueUtil.clamp(caster.getHealth() + reduction, 0, caster.getMaxHealth());
|
||||
|
||||
caster.setHealth(newHealth);
|
||||
|
||||
if (!canCounter || !counterEligible || counterTriggered) return;
|
||||
if (!isDirectHit(source)) return;
|
||||
|
||||
counterTriggered = true;
|
||||
// Counter will be performed in onActiveTick - don't self-interrupt
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user