From 1a46ae3af2715463728b3ae825094c288c584c8a Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Fri, 7 Mar 2025 14:08:26 -0500 Subject: [PATCH] v3.0.1: standardized logic for shield buffs that don't detach at 0 --- .../actors/buffs/ShieldBuff.java | 4 +++- .../hero/abilities/cleric/AscendedForm.java | 17 ++--------------- .../items/BrokenSeal.java | 19 ++++--------------- 3 files changed, 9 insertions(+), 31 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/ShieldBuff.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/ShieldBuff.java index d19c8ccc2..3a5f65a47 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/ShieldBuff.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/ShieldBuff.java @@ -27,6 +27,8 @@ import com.watabou.utils.Bundle; public abstract class ShieldBuff extends Buff { private int shielding; + + protected boolean detachesAtZero = true; @Override public boolean attachTo(Char target) { @@ -85,7 +87,7 @@ public abstract class ShieldBuff extends Buff { dmg -= shielding; shielding = 0; } - if (shielding == 0){ + if (shielding <= 0 && detachesAtZero){ detach(); } if (target != null) target.needsShieldUpdate = true; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/cleric/AscendedForm.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/cleric/AscendedForm.java index e867da183..cc7803964 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/cleric/AscendedForm.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/abilities/cleric/AscendedForm.java @@ -75,6 +75,8 @@ public class AscendedForm extends ArmorAbility { { type = buffType.POSITIVE; + + detachesAtZero = true; } public static float DURATION = 10f; @@ -114,21 +116,6 @@ public class AscendedForm extends ArmorAbility { left += amt; } - @Override - //logic edited slightly as buff should not detach - public int absorbDamage(int dmg) { - if (shielding() <= 0) return dmg; - - if (shielding() >= dmg){ - decShield(dmg); - dmg = 0; - } else { - dmg -= shielding(); - decShield(shielding()); - } - return dmg; - } - @Override public boolean act() { left--; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java index 70af82b54..b1431c4c8 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/BrokenSeal.java @@ -212,6 +212,10 @@ public class BrokenSeal extends Item { public static class WarriorShield extends ShieldBuff { + { + detachesAtZero = false; + } + private Armor armor; private float partialShield; @@ -256,20 +260,5 @@ public class BrokenSeal extends Item { return 0; } } - - @Override - //logic edited slightly as buff should not detach - public int absorbDamage(int dmg) { - if (shielding() <= 0) return dmg; - - if (shielding() >= dmg){ - decShield(dmg); - dmg = 0; - } else { - dmg -= shielding(); - decShield(shielding()); - } - return dmg; - } } }