fleeWithinBattleArea bug fix.

This commit is contained in:
Steve 2016-06-02 11:20:18 +01:00
parent e348199358
commit db2c945cd6
1 changed files with 14 additions and 8 deletions

View File

@ -736,18 +736,24 @@ static void fleeWithinBattleArea(int x, int y, int numEnemies)
self->aiActionTime = FPS * 2;
/* at the limit of the battle area, try somewhere else */
if (self->targetLocation.x < SCREEN_WIDTH || self->targetLocation.x >= BATTLE_AREA_WIDTH - SCREEN_WIDTH)
if (self->targetLocation.x < SCREEN_WIDTH)
{
self->targetLocation.x = -self->targetLocation.x;
self->aiActionTime = FPS * 5;
self->targetLocation.x = -SCREEN_WIDTH;
}
/* at the limit of the battle area, try somewhere else */
if (self->targetLocation.y < SCREEN_HEIGHT || self->targetLocation.y >= BATTLE_AREA_HEIGHT - SCREEN_HEIGHT)
if (self->targetLocation.x >= BATTLE_AREA_WIDTH - SCREEN_WIDTH)
{
self->targetLocation.y = -self->targetLocation.y;
self->aiActionTime = FPS * 5;
self->targetLocation.x = BATTLE_AREA_WIDTH;
}
if (self->targetLocation.y < SCREEN_HEIGHT)
{
self->targetLocation.y = -SCREEN_HEIGHT;
}
if (self->targetLocation.y >= BATTLE_AREA_HEIGHT - SCREEN_HEIGHT)
{
self->targetLocation.y = BATTLE_AREA_HEIGHT;
}
self->action = fleeEnemies;