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