From 0a4b8949fa5ce6b58e941c9dfc9901bee3a4ce5c Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Mon, 5 Dec 2022 15:26:39 -0500 Subject: [PATCH] v2.0.0: fixed hold fast and earthroot working after moving with high spd --- .../shatteredpixeldungeon/actors/buffs/HoldFast.java | 12 +++++++++++- .../shatteredpixeldungeon/actors/hero/Hero.java | 4 ++-- .../shatteredpixeldungeon/plants/Earthroot.java | 10 ++++------ .../shatteredpixeldungeon/ui/Toolbar.java | 2 +- 4 files changed, 18 insertions(+), 10 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/HoldFast.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/HoldFast.java index 72a5bc767..71f46a117 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/HoldFast.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/HoldFast.java @@ -22,10 +22,12 @@ package com.shatteredpixel.shatteredpixeldungeon.actors.buffs; import com.shatteredpixel.shatteredpixeldungeon.Dungeon; +import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Hero; import com.shatteredpixel.shatteredpixeldungeon.actors.hero.Talent; import com.shatteredpixel.shatteredpixeldungeon.messages.Messages; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.watabou.noosa.Image; +import com.watabou.utils.Random; public class HoldFast extends Buff { @@ -37,7 +39,6 @@ public class HoldFast extends Buff { @Override public boolean act() { - if (pos == -1) pos = target.pos; if (pos != target.pos) { detach(); } else { @@ -46,6 +47,15 @@ public class HoldFast extends Buff { return true; } + public int armorBonus(){ + if (pos == target.pos && target instanceof Hero){ + return Random.NormalIntRange(0, 2* ((Hero) target).pointsInTalent(Talent.HOLD_FAST)); + } else { + detach(); + return 0; + } + } + @Override public int icon() { return BuffIndicator.ARMOR; 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 8ffec099f..02dae14fa 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 @@ -538,7 +538,7 @@ public class Hero extends Char { } if (buff(HoldFast.class) != null){ - dr += Random.NormalIntRange(0, 2*pointsInTalent(Talent.HOLD_FAST)); + dr += buff(HoldFast.class).armorBonus(); } return dr; @@ -1170,7 +1170,7 @@ public class Hero extends Char { public void rest( boolean fullRest ) { spendAndNextConstant( TIME_TO_REST ); if (hasTalent(Talent.HOLD_FAST)){ - Buff.affect(this, HoldFast.class); + Buff.affect(this, HoldFast.class).pos = pos; } if (!fullRest) { if (sprite != null) { diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java index 93caf5dfd..3ee608d80 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/plants/Earthroot.java @@ -81,12 +81,6 @@ public class Earthroot extends Plant { announced = true; } - @Override - public boolean attachTo( Char target ) { - pos = target.pos; - return super.attachTo( target ); - } - @Override public boolean act() { if (target.pos != pos) { @@ -101,6 +95,10 @@ public class Earthroot extends Plant { } public int absorb( int damage ) { + if (pos != target.pos){ + detach(); + return damage; + } int block = Math.min( damage, blocking()); if (level <= block) { detach(); diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java index e15b84876..a499fb012 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/ui/Toolbar.java @@ -256,7 +256,7 @@ public class Toolbar extends Component { && Dungeon.hero.handle(Dungeon.hero.pos)){ //trigger hold fast here, even if the hero didn't specifically wait if (Dungeon.hero.hasTalent(Talent.HOLD_FAST)){ - Buff.affect(Dungeon.hero, HoldFast.class); + Buff.affect(Dungeon.hero, HoldFast.class).pos = Dungeon.hero.pos; } Dungeon.hero.next(); } else {