v0.7.0a: significant code improvements to shield-granting buffs
This commit is contained in:
parent
679797a7a0
commit
a49eab8ed1
|
@ -37,7 +37,7 @@ public class Barrier extends ShieldBuff {
|
|||
|
||||
absorbDamage(1);
|
||||
|
||||
if (shielding <= 0){
|
||||
if (shielding() <= 0){
|
||||
detach();
|
||||
}
|
||||
|
||||
|
@ -46,12 +46,6 @@ public class Barrier extends ShieldBuff {
|
|||
return true;
|
||||
}
|
||||
|
||||
public void set( int s ){
|
||||
if (shielding < s){
|
||||
shielding = s;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void fx(boolean on) {
|
||||
if (on) target.sprite.add(CharSprite.State.SHIELDED);
|
||||
|
@ -75,6 +69,6 @@ public class Barrier extends ShieldBuff {
|
|||
|
||||
@Override
|
||||
public String desc() {
|
||||
return Messages.get(this, "desc", shielding);
|
||||
return Messages.get(this, "desc", shielding());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ import com.watabou.utils.Bundle;
|
|||
|
||||
public abstract class ShieldBuff extends Buff {
|
||||
|
||||
protected int shielding;
|
||||
private int shielding;
|
||||
|
||||
@Override
|
||||
public boolean attachTo(Char target) {
|
||||
|
@ -48,6 +48,29 @@ public abstract class ShieldBuff extends Buff {
|
|||
return shielding;
|
||||
}
|
||||
|
||||
public void setShield( int shield ) {
|
||||
this.shielding = shield;
|
||||
target.needsShieldUpdate = true;
|
||||
}
|
||||
|
||||
public void incShield(){
|
||||
incShield(1);
|
||||
}
|
||||
|
||||
public void incShield( int amt ){
|
||||
shielding += amt;
|
||||
target.needsShieldUpdate = true;
|
||||
}
|
||||
|
||||
public void decShield(){
|
||||
decShield(1);
|
||||
}
|
||||
|
||||
public void decShield( int amt ){
|
||||
shielding -= amt;
|
||||
target.needsShieldUpdate = true;
|
||||
}
|
||||
|
||||
//returns the amount of damage leftover
|
||||
public int absorbDamage( int dmg ){
|
||||
if (shielding >= dmg){
|
||||
|
|
|
@ -76,7 +76,7 @@ public class Succubus extends Mob {
|
|||
int shield = (HP - HT) + (5 + damage);
|
||||
if (shield > 0){
|
||||
HP = HT;
|
||||
Buff.affect(this, Barrier.class).set(shield);
|
||||
Buff.affect(this, Barrier.class).setShield(shield);
|
||||
} else {
|
||||
HP += 5 + damage;
|
||||
}
|
||||
|
|
|
@ -106,17 +106,16 @@ public class BrokenSeal extends Item {
|
|||
|
||||
@Override
|
||||
public synchronized boolean act() {
|
||||
if (shielding < maxShield()) {
|
||||
partialShield += 1/(35*Math.pow(0.885f, (maxShield() - shielding - 1)));
|
||||
if (shielding() < maxShield()) {
|
||||
partialShield += 1/(35*Math.pow(0.885f, (maxShield() - shielding() - 1)));
|
||||
}
|
||||
|
||||
while (partialShield >= 1){
|
||||
shielding++;
|
||||
incShield();
|
||||
partialShield--;
|
||||
target.needsShieldUpdate = true;
|
||||
}
|
||||
|
||||
if (shielding <= 0 && maxShield() <= 0){
|
||||
if (shielding() <= 0 && maxShield() <= 0){
|
||||
detach();
|
||||
}
|
||||
|
||||
|
@ -125,9 +124,8 @@ public class BrokenSeal extends Item {
|
|||
}
|
||||
|
||||
public synchronized void supercharge(int maxShield){
|
||||
if (maxShield > shielding){
|
||||
shielding = maxShield;
|
||||
target.needsShieldUpdate = true;
|
||||
if (maxShield > shielding()){
|
||||
setShield(maxShield);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -146,14 +144,13 @@ public class BrokenSeal extends Item {
|
|||
@Override
|
||||
//logic edited slightly as buff should not detach
|
||||
public int absorbDamage(int dmg) {
|
||||
if (shielding >= dmg){
|
||||
shielding -= dmg;
|
||||
if (shielding() >= dmg){
|
||||
decShield(dmg);
|
||||
dmg = 0;
|
||||
} else {
|
||||
dmg -= shielding;
|
||||
shielding = 0;
|
||||
dmg -= shielding();
|
||||
setShield(0);
|
||||
}
|
||||
target.needsShieldUpdate = true;
|
||||
return dmg;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -64,8 +64,8 @@ public class Brimstone extends Armor.Glyph {
|
|||
|
||||
if (hero.buff(Burning.class) != null){
|
||||
//max shielding equal to the armors level (this does mean no shield at lvl 0)
|
||||
if (shielding < level) {
|
||||
shielding++;
|
||||
if (shielding() < level) {
|
||||
incShield();
|
||||
|
||||
//generates 0.2 + 0.1*lvl shield per turn
|
||||
spend( 10f / (2f + level));
|
||||
|
@ -76,8 +76,8 @@ public class Brimstone extends Armor.Glyph {
|
|||
}
|
||||
|
||||
} else if (hero.buff(Burning.class) == null){
|
||||
if (shielding > 0){
|
||||
shielding--;
|
||||
if (shielding() > 0){
|
||||
decShield();
|
||||
|
||||
//shield decays at a rate of 1 per turn.
|
||||
spend(TICK);
|
||||
|
@ -85,7 +85,6 @@ public class Brimstone extends Armor.Glyph {
|
|||
detach();
|
||||
}
|
||||
}
|
||||
target.needsShieldUpdate = true;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -100,7 +99,7 @@ public class Brimstone extends Armor.Glyph {
|
|||
super.restoreFromBundle(bundle);
|
||||
//pre-0.7.0
|
||||
if (bundle.contains("added")){
|
||||
shielding = bundle.getInt("added");
|
||||
setShield(bundle.getInt("added"));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -39,7 +39,7 @@ public class ElixirOfVitality extends Elixir {
|
|||
public void apply(Hero hero) {
|
||||
Buff.affect( hero, Healing.class ).setHeal((int)(0.8f*hero.HT + 14), 0.25f, 0);
|
||||
PotionOfHealing.cure(hero);
|
||||
Buff.affect(hero, Barrier.class).set((int)(0.6f*hero.HT + 10));
|
||||
Buff.affect(hero, Barrier.class).setShield((int)(0.6f*hero.HT + 10));
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -36,6 +36,6 @@ public class PotionOfShielding extends ExoticPotion {
|
|||
setKnown();
|
||||
|
||||
//~75% of a potion of healing
|
||||
Buff.affect(hero, Barrier.class).set((int)(0.6f*hero.HT + 10));
|
||||
Buff.affect(hero, Barrier.class).setShield((int)(0.6f*hero.HT + 10));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -83,7 +83,7 @@ public class WandOfTransfusion extends Wand {
|
|||
int shielding = (ch.HP + healing) - ch.HT;
|
||||
if (shielding > 0){
|
||||
healing -= shielding;
|
||||
Buff.affect(ch, Barrier.class).set(shielding);
|
||||
Buff.affect(ch, Barrier.class).setShield(shielding);
|
||||
} else {
|
||||
shielding = 0;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user