From db2c945cd6c6596abad9465abda9ebc0b71f8149 Mon Sep 17 00:00:00 2001 From: Steve Date: Thu, 2 Jun 2016 11:20:18 +0100 Subject: [PATCH] fleeWithinBattleArea bug fix. --- src/battle/ai.c | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/src/battle/ai.c b/src/battle/ai.c index 3f86e1f..819a887 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -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;