From 630bc0291d09e522b4970fb7375cbbdb40643ae3 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Tue, 2 Aug 2022 13:13:28 -0400 Subject: [PATCH] v1.4.0: waiting now always takes exactly 1 turn, regardless of speed mod --- .../shatteredpixeldungeon/actors/Actor.java | 10 ++++++++-- .../shatteredpixeldungeon/actors/hero/Hero.java | 15 ++++++++++----- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java index 5b1d8861e..3a5328315 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/Actor.java @@ -54,8 +54,9 @@ public abstract class Actor implements Bundlable { protected int actPriority = DEFAULT; protected abstract boolean act(); - - protected void spend( float time ) { + + //Always spends exactly one tick, regardless of time-influencing factors + protected final void spendConstant( float time ){ this.time += time; //if time is very close to a whole number, round to a whole number to fix errors float ex = Math.abs(this.time % 1f); @@ -64,6 +65,11 @@ public abstract class Actor implements Bundlable { } } + //can be overridden for time to be affected by various factors + protected void spend( float time ) { + spendConstant( time ); + } + public void spendToWhole(){ time = (float)Math.ceil(time); } 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 e401f7d1a..9825ee6b4 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 @@ -641,7 +641,13 @@ public class Hero extends Char { super.spend(time); } - + + public void spendAndNextConstant( float time ) { + busy(); + spendConstant( time ); + next(); + } + public void spendAndNext( float time ) { busy(); spend( time ); @@ -683,7 +689,7 @@ public class Hero extends Char { if (curAction == null) { if (resting) { - spend( TIME_TO_REST ); + spendConstant( TIME_TO_REST ); next(); } else { ready(); @@ -893,9 +899,8 @@ public class Hero extends Char { curAction = null; } else { - // if (waitOrPickup) { - spendAndNext(TIME_TO_REST); + spendAndNextConstant(TIME_TO_REST); //allow the hero to move between levels even if they can't collect the item } else if (Dungeon.level.getTransition(pos) != null){ @@ -1140,7 +1145,7 @@ public class Hero extends Char { } public void rest( boolean fullRest ) { - spendAndNext( TIME_TO_REST ); + spendAndNextConstant( TIME_TO_REST ); if (!fullRest) { if (hasTalent(Talent.HOLD_FAST)){ Buff.affect(this, HoldFast.class);