v2.0.0: improved self-step logic to work with plants

This commit is contained in:
Evan Debenham
2022-11-10 15:57:25 -05:00
parent 0c915726fe
commit b1215bc6c6
2 changed files with 14 additions and 5 deletions

View File

@@ -744,6 +744,7 @@ public class Hero extends Char {
damageInterrupt = true;
waitOrPickup = false;
ready = true;
canSelfTrample = true;
AttackIndicator.updateState();
@@ -767,18 +768,26 @@ public class Hero extends Char {
next();
}
public boolean isStandingOnTrampleableGrass(){
return !rooted && !flying &&
(Dungeon.level.map[pos] == Terrain.HIGH_GRASS || (heroClass != HeroClass.HUNTRESS && Dungeon.level.map[pos] == Terrain.FURROWED_GRASS));
private boolean canSelfTrample = false;
public boolean canSelfTrample(){
return canSelfTrample && !rooted && !flying &&
//standing in high grass
(Dungeon.level.map[pos] == Terrain.HIGH_GRASS ||
//standing in furrowed grass and not huntress
(heroClass != HeroClass.HUNTRESS && Dungeon.level.map[pos] == Terrain.FURROWED_GRASS) ||
//standing on a plant
Dungeon.level.plants.get(pos) != null);
}
private boolean actMove( HeroAction.Move action ) {
if (getCloser( action.dst )) {
canSelfTrample = false;
return true;
//Hero moves in place if there is grass to trample
} else if (isStandingOnTrampleableGrass()){
} else if (canSelfTrample()){
canSelfTrample = false;
Dungeon.level.pressCell(pos);
spendAndNext( 1 / speed() );
return false;

View File

@@ -252,7 +252,7 @@ public class Toolbar extends Component {
protected void onClick() {
if (Dungeon.hero.ready && !GameScene.cancel()) {
Dungeon.hero.waitOrPickup = true;
if ((Dungeon.level.heaps.get(Dungeon.hero.pos) != null || Dungeon.hero.isStandingOnTrampleableGrass())
if ((Dungeon.level.heaps.get(Dungeon.hero.pos) != null || Dungeon.hero.canSelfTrample())
&& 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)){