Don't chase your target forever - reevaluate if they go out of range.

This commit is contained in:
Steve 2015-11-01 10:46:49 +00:00
parent 0246600d9c
commit 090eab162d
1 changed files with 7 additions and 3 deletions

View File

@ -115,9 +115,12 @@ void doAI(void)
}
}
/*
* Don't chase your target forever
*/
static int targetOutOfRange(void)
{
return getDistance(self->x, self->y, self->target->x, self->target->y) > 2000;
return getDistance(self->x, self->y, self->target->x, self->target->y) > SCREEN_HEIGHT;
}
static void huntTarget(void)
@ -156,8 +159,9 @@ static void huntAndAttackTarget(void)
static void findTarget(void)
{
Entity *f;
int closest = 2000;
int dist = 2000;
unsigned int dist, closest;
dist = closest = (!battle.epic) ? 2000 : MAX_TARGET_RANGE;
self->target = NULL;