From 3746cd2fdb58447f2a6ca61f5c27be402eb1a696 Mon Sep 17 00:00:00 2001 From: Evan Debenham Date: Wed, 30 Sep 2020 22:36:48 -0400 Subject: [PATCH] v0.9.0: adjusted prep blink behaviour --- .../actors/buffs/Preparation.java | 24 +++++++------------ 1 file changed, 9 insertions(+), 15 deletions(-) diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Preparation.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Preparation.java index 8f42d33d2..146d9224a 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Preparation.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/buffs/Preparation.java @@ -35,6 +35,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; +import com.shatteredpixel.shatteredpixeldungeon.utils.BArray; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.watabou.noosa.Image; import com.watabou.noosa.audio.Sample; @@ -234,7 +235,7 @@ public class Preparation extends Buff implements ActionIndicator.Action { public void onSelect(Integer cell) { if (cell == null) return; final Char enemy = Actor.findChar( cell ); - if (enemy == null || Dungeon.hero.isCharmedBy(enemy) || enemy instanceof NPC){ + if (enemy == null || Dungeon.hero.isCharmedBy(enemy) || enemy instanceof NPC || !Dungeon.level.heroFOV[cell]){ GLog.w(Messages.get(Preparation.class, "no_target")); } else { @@ -247,22 +248,15 @@ public class Preparation extends Buff implements ActionIndicator.Action { AttackLevel lvl = AttackLevel.getLvl(turnsInvis); - boolean[] passable = Dungeon.level.passable.clone(); - //need to consider enemy cell as passable in case they are on a trap or chasm - passable[cell] = true; - PathFinder.buildDistanceMap(Dungeon.hero.pos, passable, lvl.blinkDistance+1); - if (PathFinder.distance[cell] == Integer.MAX_VALUE){ - GLog.w(Messages.get(Preparation.class, "out_of_reach")); - return; + boolean[] blinkable = BArray.not(Dungeon.level.solid, null); + + //we consider passable and cell occupancy for adjacent cells to target + for (int i : PathFinder.NEIGHBOURS9){ + if (Actor.findChar(cell+i) != null) blinkable[cell+i] = false; + if (!Dungeon.level.passable[cell+i]) blinkable[cell+i] = false; } - //we can move through enemies when determining blink distance, - // but not when actually jumping to a location - for (Char ch : Actor.chars()){ - if (ch != Dungeon.hero) passable[ch.pos] = false; - } - - PathFinder.Path path = PathFinder.find(Dungeon.hero.pos, cell, passable); + PathFinder.Path path = PathFinder.find(Dungeon.hero.pos, cell, blinkable); int attackPos = path == null ? -1 : path.get(path.size()-2); if (attackPos == -1 ||