Check surrender chance earlier in ai call.

This commit is contained in:
Steve 2016-05-25 12:26:25 +01:00
parent 4c224fdabb
commit 4e36f0731f
1 changed files with 6 additions and 6 deletions

View File

@ -65,6 +65,11 @@ void doAI(void)
deployMine(); deployMine();
} }
if ((self->aiFlags & AIF_SURRENDERS) && (battle.stats[STAT_TIME] % 6 == 0) && isSurrendering())
{
return;
}
if ((self->aiFlags & (AIF_AVOIDS_COMBAT | AIF_EVADE)) && nearEnemies()) if ((self->aiFlags & (AIF_AVOIDS_COMBAT | AIF_EVADE)) && nearEnemies())
{ {
return; return;
@ -107,11 +112,6 @@ void doAI(void)
return; return;
} }
if ((self->aiFlags & AIF_SURRENDERS) && (battle.stats[STAT_TIME] % 6 == 0) && isSurrendering())
{
return;
}
if (!(self->aiFlags & AIF_AVOIDS_COMBAT)) if (!(self->aiFlags & AIF_AVOIDS_COMBAT))
{ {
if (self->speed) if (self->speed)
@ -605,7 +605,7 @@ static int isSurrendering(void)
{ {
chance = self->health; chance = self->health;
chance /= self->maxHealth; chance /= self->maxHealth;
chance *= 75; chance *= 100;
if (rand() % 100 > chance) if (rand() % 100 > chance)
{ {