v0.9.0: adjusted prep blink behaviour

This commit is contained in:
Evan Debenham
2020-09-30 22:36:48 -04:00
parent 04365a2cbd
commit 3746cd2fdb
@@ -35,6 +35,7 @@ import com.shatteredpixel.shatteredpixeldungeon.scenes.CellSelector;
import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene; import com.shatteredpixel.shatteredpixeldungeon.scenes.GameScene;
import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.ActionIndicator;
import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator; import com.shatteredpixel.shatteredpixeldungeon.ui.BuffIndicator;
import com.shatteredpixel.shatteredpixeldungeon.utils.BArray;
import com.shatteredpixel.shatteredpixeldungeon.utils.GLog; import com.shatteredpixel.shatteredpixeldungeon.utils.GLog;
import com.watabou.noosa.Image; import com.watabou.noosa.Image;
import com.watabou.noosa.audio.Sample; import com.watabou.noosa.audio.Sample;
@@ -234,7 +235,7 @@ public class Preparation extends Buff implements ActionIndicator.Action {
public void onSelect(Integer cell) { public void onSelect(Integer cell) {
if (cell == null) return; if (cell == null) return;
final Char enemy = Actor.findChar( cell ); 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")); GLog.w(Messages.get(Preparation.class, "no_target"));
} else { } else {
@@ -247,22 +248,15 @@ public class Preparation extends Buff implements ActionIndicator.Action {
AttackLevel lvl = AttackLevel.getLvl(turnsInvis); AttackLevel lvl = AttackLevel.getLvl(turnsInvis);
boolean[] passable = Dungeon.level.passable.clone(); boolean[] blinkable = BArray.not(Dungeon.level.solid, null);
//need to consider enemy cell as passable in case they are on a trap or chasm
passable[cell] = true; //we consider passable and cell occupancy for adjacent cells to target
PathFinder.buildDistanceMap(Dungeon.hero.pos, passable, lvl.blinkDistance+1); for (int i : PathFinder.NEIGHBOURS9){
if (PathFinder.distance[cell] == Integer.MAX_VALUE){ if (Actor.findChar(cell+i) != null) blinkable[cell+i] = false;
GLog.w(Messages.get(Preparation.class, "out_of_reach")); if (!Dungeon.level.passable[cell+i]) blinkable[cell+i] = false;
return;
} }
//we can move through enemies when determining blink distance, PathFinder.Path path = PathFinder.find(Dungeon.hero.pos, cell, blinkable);
// 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);
int attackPos = path == null ? -1 : path.get(path.size()-2); int attackPos = path == null ? -1 : path.get(path.size()-2);
if (attackPos == -1 || if (attackPos == -1 ||