From 0ca487094d44d9db04aad56c186920deb609e80f Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 19 Oct 2016 15:53:58 -0400 Subject: [PATCH] v0.4.3a: reworked glyph of brimstone --- .../actors/buffs/Burning.java | 12 +-- .../items/armor/glyphs/Brimstone.java | 81 +++++++++++++++++++ .../messages/items/items.properties | 2 +- 3 files changed, 88 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java index c6594a0c3..2f6467a64 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Burning.java @@ -87,12 +87,7 @@ public class Burning extends Buff implements Hero.Doom { if (hero.belongings.armor != null && hero.belongings.armor.hasGlyph(Brimstone.class)){ - float heal = hero.belongings.armor.level()/5f; - if (Random.Float() < heal % 1) heal++; - if (heal >= 1 && hero.HP < hero.HT) { - hero.sprite.emitter().burst(Speck.factory(Speck.HEALING), (int)heal); - hero.HP = Math.min(hero.HT, hero.HP + (int)heal); - } + Buff.affect(target, Brimstone.BrimstoneShield.class); } else { @@ -138,6 +133,11 @@ public class Burning extends Buff implements Hero.Doom { } } else { + + Brimstone.BrimstoneShield brimShield = target.buff(Brimstone.BrimstoneShield.class); + if (brimShield != null) + brimShield.startDecay(); + detach(); } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Brimstone.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Brimstone.java index cf16da1f6..6d84161cd 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Brimstone.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/armor/glyphs/Brimstone.java @@ -21,8 +21,12 @@ package com.shatteredpixel.shatteredpixeldungeon.items.armor.glyphs; import com.shatteredpixel.shatteredpixeldungeon.actors.Char; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Buff; +import com.shatteredpixel.shatteredpixeldungeon.actors.buffs.Burning; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.items.armor.Armor; import com.shatteredpixel.shatteredpixeldungeon.sprites.ItemSprite; +import com.watabou.utils.Bundle; public class Brimstone extends Armor.Glyph { @@ -39,4 +43,81 @@ public class Brimstone extends Armor.Glyph { return ORANGE; } + public static class BrimstoneShield extends Buff { + + private int shieldAdded; + private int lastShield = -1; + + @Override + public boolean act() { + Hero hero = (Hero)target; + + //make sure any shielding lost through combat is accounted for + if (lastShield != -1 && lastShield > hero.SHLD) + shieldAdded = Math.max(0, shieldAdded - (lastShield - hero.SHLD)); + + lastShield = hero.SHLD; + + if (hero.belongings.armor == null || !hero.belongings.armor.hasGlyph(Brimstone.class)) { + hero.SHLD -= shieldAdded; + detach(); + return true; + } + + int level = hero.belongings.armor.level(); + + if (hero.buff(Burning.class) != null){ + //max shielding equal to the armors level (this does mean no shield at lvl 0) + if (hero.SHLD < level) { + shieldAdded++; + hero.SHLD++; + lastShield++; + + //generates 0.2 + 0.1*lvl shield per turn + spend( 10f / (2f + level)); + } else { + + //if shield is maxed, don't wait longer than 1 turn to try again + spend( Math.min( TICK, 10f / (2f + level))); + } + + } else if (hero.buff(Burning.class) == null){ + if (shieldAdded > 0 && hero.SHLD > 0){ + shieldAdded--; + hero.SHLD--; + lastShield--; + + //shield decays at a rate of 1 per turn. + spend(TICK); + } else { + detach(); + } + } + + return true; + } + + public void startDecay(){ + //sets the buff to start acting next turn. Invoked by Burning when it expires. + spend(-cooldown()+2); + } + + private static String ADDED = "added"; + private static String LAST = "last"; + + @Override + public void storeInBundle(Bundle bundle) { + super.storeInBundle(bundle); + bundle.put( ADDED, shieldAdded ); + bundle.put( LAST, lastShield ); + } + + @Override + public void restoreFromBundle(Bundle bundle) { + super.restoreFromBundle(bundle); + shieldAdded = bundle.getInt( ADDED ); + lastShield = bundle.getInt( LAST ); + } + } + } diff --git a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties index 8935e3238..3a7b83dfc 100644 --- a/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties +++ b/core/src/main/resources/com/shatteredpixel/shatteredpixeldungeon/messages/items/items.properties @@ -26,7 +26,7 @@ items.armor.glyphs.antimagic.name=%s of anti-magic items.armor.glyphs.antimagic.desc=This powerful glyph allows armor to apply its defense to most magical attacks as well as physical ones. items.armor.glyphs.brimstone.name=%s of brimstone -items.armor.glyphs.brimstone.desc=This glyph protects the wearer and their belongings from fire, with upgrades it even converts the heat into health. +items.armor.glyphs.brimstone.desc=This glyph protects the wearer and their belongings from fire, with upgrades it even converts the heat into temporary shielding. items.armor.glyphs.camouflage.name=%s of camouflage items.armor.glyphs.camouflage.desc=This glyph allows the wearer to blend into tall grass, granting them temporary invisibility.