v2.0.0: fixed hold fast and earthroot working after moving with high spd

This commit is contained in:
Evan Debenham
2022-12-05 15:26:39 -05:00
parent fba407c933
commit 0a4b8949fa
4 changed files with 18 additions and 10 deletions

View File

@@ -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;

View File

@@ -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) {

View File

@@ -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();

View File

@@ -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 {