v3.0.1: standardized logic for shield buffs that don't detach at 0
This commit is contained in:
@@ -27,6 +27,8 @@ import com.watabou.utils.Bundle;
|
|||||||
public abstract class ShieldBuff extends Buff {
|
public abstract class ShieldBuff extends Buff {
|
||||||
|
|
||||||
private int shielding;
|
private int shielding;
|
||||||
|
|
||||||
|
protected boolean detachesAtZero = true;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean attachTo(Char target) {
|
public boolean attachTo(Char target) {
|
||||||
@@ -85,7 +87,7 @@ public abstract class ShieldBuff extends Buff {
|
|||||||
dmg -= shielding;
|
dmg -= shielding;
|
||||||
shielding = 0;
|
shielding = 0;
|
||||||
}
|
}
|
||||||
if (shielding == 0){
|
if (shielding <= 0 && detachesAtZero){
|
||||||
detach();
|
detach();
|
||||||
}
|
}
|
||||||
if (target != null) target.needsShieldUpdate = true;
|
if (target != null) target.needsShieldUpdate = true;
|
||||||
|
|||||||
@@ -75,6 +75,8 @@ public class AscendedForm extends ArmorAbility {
|
|||||||
|
|
||||||
{
|
{
|
||||||
type = buffType.POSITIVE;
|
type = buffType.POSITIVE;
|
||||||
|
|
||||||
|
detachesAtZero = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static float DURATION = 10f;
|
public static float DURATION = 10f;
|
||||||
@@ -114,21 +116,6 @@ public class AscendedForm extends ArmorAbility {
|
|||||||
left += amt;
|
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
|
@Override
|
||||||
public boolean act() {
|
public boolean act() {
|
||||||
left--;
|
left--;
|
||||||
|
|||||||
@@ -212,6 +212,10 @@ public class BrokenSeal extends Item {
|
|||||||
|
|
||||||
public static class WarriorShield extends ShieldBuff {
|
public static class WarriorShield extends ShieldBuff {
|
||||||
|
|
||||||
|
{
|
||||||
|
detachesAtZero = false;
|
||||||
|
}
|
||||||
|
|
||||||
private Armor armor;
|
private Armor armor;
|
||||||
private float partialShield;
|
private float partialShield;
|
||||||
|
|
||||||
@@ -256,20 +260,5 @@ public class BrokenSeal extends Item {
|
|||||||
return 0;
|
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;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user