v0.4.2: fixed bugs and corrected logic to pathfinder
This commit is contained in:
parent
7ff72dee27
commit
7e3c7f44cd
|
@ -1045,7 +1045,7 @@ public class Hero extends Char {
|
|||
} else {
|
||||
|
||||
boolean newPath = false;
|
||||
if (path == null || path.isEmpty())
|
||||
if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst()))
|
||||
newPath = true;
|
||||
else if (path.getLast() != target)
|
||||
newPath = true;
|
||||
|
|
|
@ -307,12 +307,13 @@ public abstract class Mob extends Char {
|
|||
} else {
|
||||
|
||||
boolean newPath = false;
|
||||
if (path == null || path.isEmpty())
|
||||
if (path == null || path.isEmpty() || !Dungeon.level.adjacent(pos, path.getFirst()))
|
||||
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
|
||||
if (Dungeon.level.adjacent(target, path.getLast())) {
|
||||
//rather than scrapping the whole path. Unless the path is very long,
|
||||
//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();
|
||||
|
||||
if (path.isEmpty()) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user