v0.9.1: fixed rare errors resulting from v0.9.0 AI changes
This commit is contained in:
parent
61372291ca
commit
22036628d3
|
@ -879,6 +879,9 @@ public abstract class Mob extends Char {
|
||||||
|
|
||||||
public static final String TAG = "HUNTING";
|
public static final String TAG = "HUNTING";
|
||||||
|
|
||||||
|
//prevents rare infinite loop cases
|
||||||
|
private boolean recursing = false;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
|
public boolean act( boolean enemyInFOV, boolean justAlerted ) {
|
||||||
enemySeen = enemyInFOV;
|
enemySeen = enemyInFOV;
|
||||||
|
@ -906,11 +909,16 @@ public abstract class Mob extends Char {
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
//if moving towards an enemy isn't possible, try to switch targets to another enemy that is closer
|
//if moving towards an enemy isn't possible, try to switch targets to another enemy that is closer
|
||||||
Char newEnemy = chooseEnemy();
|
//unless we have already done that and still can't move toward them, then move on.
|
||||||
if (newEnemy != null && enemy != newEnemy){
|
if (!recursing) {
|
||||||
enemy = newEnemy;
|
Char newEnemy = chooseEnemy();
|
||||||
spend( TICK );
|
if (newEnemy != null && enemy != newEnemy) {
|
||||||
return true;
|
enemy = newEnemy;
|
||||||
|
recursing = true;
|
||||||
|
boolean result = act(enemyInFOV, justAlerted);
|
||||||
|
recursing = false;
|
||||||
|
return result;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
spend( TICK );
|
spend( TICK );
|
||||||
|
|
Loading…
Reference in New Issue
Block a user