AI evasion updates.

This commit is contained in:
Steve 2015-12-20 16:13:49 +00:00
parent 9be0cdab6c
commit 05b42f21ce
2 changed files with 10 additions and 5 deletions

View File

@ -56,7 +56,7 @@ void doAI(void)
return;
}
if ((self->aiFlags & AIF_DEFENSIVE) && rand() % 50 && nearEnemies())
if ((self->aiFlags & AIF_DEFENSIVE) && rand() % 25 && nearEnemies())
{
return;
}
@ -555,8 +555,13 @@ static int nearEnemies(void)
{
self->targetLocation.x /= numEnemies;
self->targetLocation.y /= numEnemies;
/* dodge slightly */
self->targetLocation.x += (rand() % 100 - rand() % 100);
self->targetLocation.y += (rand() % 100 - rand() % 100);
self->action = fleeEnemies;
self->aiActionTime = FPS / 2;
self->aiActionTime = FPS * 2;
return 1;
}

View File

@ -445,13 +445,13 @@ void damageFighter(Entity *e, int amount, long flags)
/*
* Sometimes run away if you take too much damage in a short space of time
*/
if (e->type == ET_FIGHTER && e != player && e->aiDamagePerSec >= (e->maxHealth + e->maxShield) * 0.1 && (!(e->aiFlags & AIF_EVADE)))
if (e->type == ET_FIGHTER && (!(e->aiFlags & AIF_EVADE)) && e != player && e->aiDamagePerSec >= (e->maxHealth + e->maxShield) * 0.1)
{
if (rand() % 3)
if ((rand() % 10) > 6)
{
e->action = doAI;
e->aiFlags |= AIF_EVADE;
e->aiActionTime = e->aiEvadeTimer = FPS * 3;
e->aiActionTime = e->aiEvadeTimer = FPS * (1 + (rand() % 3));
}
else
{