From 8fe920ff17e2954145cba3f66d32178f88da8b6c Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 21 Jun 2017 17:11:48 -0400 Subject: [PATCH] v0.6.1: reworked the HP mechanics on right of might --- .../actors/hero/Hero.java | 23 ++++++++++++-- .../items/potions/PotionOfMight.java | 4 +-- .../items/rings/RingOfMight.java | 31 +++++++++---------- .../items/scrolls/ScrollOfRemoveCurse.java | 1 + 4 files changed, 39 insertions(+), 20 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java index ea138f94a..f5d1ead56 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/hero/Hero.java @@ -161,6 +161,8 @@ public class Hero extends Char { public int lvl = 1; public int exp = 0; + public int HTBoost = 0; + private ArrayList visibleEnemies; //This list is maintained so that some logic checks can be skipped @@ -179,6 +181,19 @@ public class Hero extends Char { visibleEnemies = new ArrayList(); } + + public void updateHT( boolean boostHP ){ + int curHT = HT; + + HT = 20 + 5*(lvl-1) + HTBoost; + float multiplier = RingOfMight.HTMultiplier(this); + HT = Math.round(multiplier * HT); + + if (boostHP){ + HP += Math.max(HT - curHT, 0); + } + HP = Math.min(HP, HT); + } public int STR() { int STR = this.STR; @@ -193,6 +208,7 @@ public class Hero extends Char { private static final String STRENGTH = "STR"; private static final String LEVEL = "lvl"; private static final String EXPERIENCE = "exp"; + private static final String HTBOOST = "htboost"; @Override public void storeInBundle( Bundle bundle ) { @@ -209,6 +225,8 @@ public class Hero extends Char { bundle.put( LEVEL, lvl ); bundle.put( EXPERIENCE, exp ); + + bundle.put( HTBOOST, HTBoost ); belongings.storeInBundle( bundle ); } @@ -229,6 +247,8 @@ public class Hero extends Char { lvl = bundle.getInt( LEVEL ); exp = bundle.getInt( EXPERIENCE ); + HTBoost = bundle.getInt(HTBOOST); + belongings.restoreFromBundle( bundle ); } @@ -1191,8 +1211,7 @@ public class Hero extends Char { lvl++; levelUp = true; - HT += 5; - HP += 5; + updateHT( true ); attackSkill++; defenseSkill++; diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfMight.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfMight.java index 477bfb8ef..9c0a12324 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfMight.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/potions/PotionOfMight.java @@ -40,8 +40,8 @@ public class PotionOfMight extends Potion { setKnown(); hero.STR++; - hero.HT += 5; - hero.HP += 5; + hero.HTBoost += 5; + hero.updateHT( true ); hero.sprite.showStatus( CharSprite.POSITIVE, Messages.get(this, "msg_1") ); GLog.p( Messages.get(this, "msg_2") ); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java index a15dbd3b5..5f11dd193 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/rings/RingOfMight.java @@ -31,8 +31,7 @@ public class RingOfMight extends Ring { @Override public boolean doEquip(Hero hero) { if (super.doEquip(hero)){ - hero.HT += level()*5; - hero.HP = Math.min(hero.HP, hero.HT); + hero.updateHT( false ); return true; } else { return false; @@ -41,34 +40,30 @@ public class RingOfMight extends Ring { @Override public boolean doUnequip(Hero hero, boolean collect, boolean single) { - if (super.doUnequip(hero, collect, single)){ - hero.HT -= level()*5; - hero.HP = Math.min(hero.HP, hero.HT); + hero.updateHT( false ); return true; } else { return false; } - } @Override public Item upgrade() { - if (buff != null && buff.target != null){ - buff.target.HT += 5; - } - return super.upgrade(); + super.upgrade(); + updateTargetHT(); + return this; } @Override public void level(int value) { - if (buff != null && buff.target != null){ - buff.target.HT -= level()*5; - } super.level(value); - if (buff != null && buff.target != null){ - buff.target.HT += level()*5; - buff.target.HP = Math.min(buff.target.HP, buff.target.HT); + updateTargetHT(); + } + + private void updateTargetHT(){ + if (buff != null && buff.target instanceof Hero){ + ((Hero) buff.target).updateHT( false ); } } @@ -80,6 +75,10 @@ public class RingOfMight extends Ring { public static int strengthBonus( Char target ){ return getBonus( target, Might.class ); } + + public static float HTMultiplier( Char target ){ + return (float)Math.pow(1.035, getBonus(target, Might.class)); + } public class Might extends RingBuff { } diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRemoveCurse.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRemoveCurse.java index ab5b7aba9..1741202e5 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRemoveCurse.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/items/scrolls/ScrollOfRemoveCurse.java @@ -91,6 +91,7 @@ public class ScrollOfRemoveCurse extends InventoryScroll { if (procced) { hero.sprite.emitter().start( ShadowParticle.UP, 0.05f, 10 ); + hero.updateHT( false ); //for ring of might } return procced;