v0.4.2: fixed bugs with mob pathfinding
This commit is contained in:
parent
01aad4196c
commit
67f435319f
|
@ -294,6 +294,18 @@ public abstract class Mob extends Char {
|
|||
return false;
|
||||
}
|
||||
|
||||
int step = -1;
|
||||
|
||||
if (Dungeon.level.adjacent( pos, target )) {
|
||||
|
||||
path = null;
|
||||
|
||||
if (Actor.findChar( target ) == null && Level.passable[target]) {
|
||||
step = target;
|
||||
}
|
||||
|
||||
} else {
|
||||
|
||||
boolean newPath = false;
|
||||
if (path == null || path.isEmpty())
|
||||
newPath = true;
|
||||
|
@ -335,6 +347,7 @@ public abstract class Mob extends Char {
|
|||
|
||||
}
|
||||
|
||||
|
||||
if (!newPath) {
|
||||
//checks the next 4 cells in the path for validity
|
||||
for (int i = 0; i < Math.min(path.size(), 4); i++) {
|
||||
|
@ -355,7 +368,8 @@ public abstract class Mob extends Char {
|
|||
if (path == null)
|
||||
return false;
|
||||
|
||||
int step = path.removeFirst();
|
||||
step = path.removeFirst();
|
||||
}
|
||||
if (step != -1) {
|
||||
move( step );
|
||||
return true;
|
||||
|
|
Loading…
Reference in New Issue
Block a user