Don't chase your target forever - reevaluate if they go out of range.
This commit is contained in:
parent
0246600d9c
commit
090eab162d
|
@ -115,9 +115,12 @@ void doAI(void)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Don't chase your target forever
|
||||||
|
*/
|
||||||
static int targetOutOfRange(void)
|
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)
|
static void huntTarget(void)
|
||||||
|
@ -156,8 +159,9 @@ static void huntAndAttackTarget(void)
|
||||||
static void findTarget(void)
|
static void findTarget(void)
|
||||||
{
|
{
|
||||||
Entity *f;
|
Entity *f;
|
||||||
int closest = 2000;
|
unsigned int dist, closest;
|
||||||
int dist = 2000;
|
|
||||||
|
dist = closest = (!battle.epic) ? 2000 : MAX_TARGET_RANGE;
|
||||||
|
|
||||||
self->target = NULL;
|
self->target = NULL;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue