v0.4.2: fixed bugs and corrected logic to pathfinder

This commit is contained in:
Evan Debenham 2016-09-02 01:07:26 -04:00
parent 7ff72dee27
commit 7e3c7f44cd
2 changed files with 5 additions and 4 deletions

View File

@ -1045,7 +1045,7 @@ public class Hero extends Char {
} else { } else {
boolean newPath = false; boolean newPath = false;
if (path == null || path.isEmpty()) if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst()))
newPath = true; newPath = true;
else if (path.getLast() != target) else if (path.getLast() != target)
newPath = true; newPath = true;

View File

@ -307,12 +307,13 @@ public abstract class Mob extends Char {
} else { } else {
boolean newPath = false; boolean newPath = false;
if (path == null || path.isEmpty()) if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst()))
newPath = true; newPath = true;
else if (path.getLast() != target) { else if (path.getLast() != target) {
//if the new target is adjacent to the end of the path, adjust for that //if the new target is adjacent to the end of the path, adjust for that
//rather than scrapping the whole path //rather than scrapping the whole path. Unless the path is very long,
if (Dungeon.level.adjacent(target, path.getLast())) { //in which case re-checking will likely result in a much better path
if (Dungeon.level.adjacent(target, path.getLast()) && path.size() < viewDistance) {
int last = path.removeLast(); int last = path.removeLast();
if (path.isEmpty()) { if (path.isEmpty()) {