diff --git a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java index 51c4dbea2..0c4923510 100644 --- a/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java +++ b/core/src/main/java/com/shatteredpixel/shatteredpixeldungeon/actors/mobs/Mob.java @@ -308,13 +308,16 @@ public abstract class Mob extends Char { } else { boolean newPath = false; - if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst())) + //scrap the current path if it's empty, no longer connects to the current location + //or if it's extremely inefficient and checking again may result in a much better path + if (path == null || path.isEmpty() + || !Dungeon.level.adjacent(pos, path.getFirst()) + || path.size() >= 2*Dungeon.level.distance(pos, target)) newPath = true; else if (path.getLast() != target) { //if the new target is adjacent to the end of the path, adjust for that - //rather than scrapping the whole path. Unless the path is too long, - //in which case re-checking will likely result in a better path - if (Dungeon.level.adjacent(target, path.getLast()) && path.size() < Dungeon.level.distance(pos, target)) { + //rather than scrapping the whole path. + if (Dungeon.level.adjacent(target, path.getLast())) { int last = path.removeLast(); if (path.isEmpty()) { @@ -355,7 +358,7 @@ public abstract class Mob extends Char { int lookAhead = (int)GameMath.gate(1, path.size()-1, 4); for (int i = 0; i < lookAhead; i++) { int cell = path.get(i); - if (!Level.passable[cell] || ( Dungeon.visible[cell] && Actor.findChar(cell) != null)) { + if (!Level.passable[cell] || ( Level.fieldOfView[cell] && Actor.findChar(cell) != null)) { newPath = true; break; }