Added AIF_SURRENDERING, to better handle surrendering targets and prevent race conditions.
This commit is contained in:
parent
c9536ae938
commit
0088dfdee3
|
@ -595,7 +595,7 @@ static int isSurrendering(void)
|
||||||
{
|
{
|
||||||
float chance;
|
float chance;
|
||||||
|
|
||||||
if (!(self->flags & EF_SURRENDERED))
|
if (!(self->aiFlags & AIF_SURRENDERED))
|
||||||
{
|
{
|
||||||
if (self->health < self->maxHealth)
|
if (self->health < self->maxHealth)
|
||||||
{
|
{
|
||||||
|
@ -605,9 +605,10 @@ static int isSurrendering(void)
|
||||||
|
|
||||||
if (rand() % 100 > chance)
|
if (rand() % 100 > chance)
|
||||||
{
|
{
|
||||||
self->aiActionTime = FPS * 3;
|
self->aiActionTime = FPS * 2;
|
||||||
|
|
||||||
self->aiFlags |= AIF_AVOIDS_COMBAT;
|
self->aiFlags |= AIF_AVOIDS_COMBAT;
|
||||||
|
self->aiFlags |= AIF_SURRENDERING;
|
||||||
self->aiFlags &= ~AIF_SURRENDERS;
|
self->aiFlags &= ~AIF_SURRENDERS;
|
||||||
|
|
||||||
self->flags |= EF_MUST_DISABLE;
|
self->flags |= EF_MUST_DISABLE;
|
||||||
|
@ -633,7 +634,8 @@ static void doSurrender(void)
|
||||||
{
|
{
|
||||||
if (--self->aiActionTime <= 0)
|
if (--self->aiActionTime <= 0)
|
||||||
{
|
{
|
||||||
self->flags |= EF_SURRENDERED;
|
self->aiFlags &= ~AIF_SURRENDERING;
|
||||||
|
self->aiFlags |= AIF_SURRENDERED;
|
||||||
|
|
||||||
nextAction();
|
nextAction();
|
||||||
}
|
}
|
||||||
|
|
|
@ -235,6 +235,12 @@ void doFighter(void)
|
||||||
self->flags |= EF_DISABLED;
|
self->flags |= EF_DISABLED;
|
||||||
self->flags |= EF_SECONDARY_TARGET;
|
self->flags |= EF_SECONDARY_TARGET;
|
||||||
|
|
||||||
|
if (self->aiFlags & AIF_SURRENDERING)
|
||||||
|
{
|
||||||
|
self->aiFlags |= AIF_SURRENDERED;
|
||||||
|
self->aiFlags &= ~AIF_SURRENDERING;
|
||||||
|
}
|
||||||
|
|
||||||
battle.stats[STAT_ENEMIES_DISABLED]++;
|
battle.stats[STAT_ENEMIES_DISABLED]++;
|
||||||
|
|
||||||
updateObjective(self->name, TT_DISABLE);
|
updateObjective(self->name, TT_DISABLE);
|
||||||
|
@ -347,7 +353,7 @@ void doFighter(void)
|
||||||
updateCondition(self->groupName, TT_DESTROY);
|
updateCondition(self->groupName, TT_DESTROY);
|
||||||
|
|
||||||
/* don't fire if the opposing side is responsible */
|
/* don't fire if the opposing side is responsible */
|
||||||
if (self->flags & EF_SURRENDERED && self->killedBy->side == player->side)
|
if (self->aiFlags & AIF_SURRENDERED && self->killedBy->side == player->side)
|
||||||
{
|
{
|
||||||
updateCondition("SURRENDERED", TT_DESTROY);
|
updateCondition("SURRENDERED", TT_DESTROY);
|
||||||
}
|
}
|
||||||
|
|
|
@ -109,8 +109,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define EF_NO_THREAT (2 << 23)
|
#define EF_NO_THREAT (2 << 23)
|
||||||
#define EF_DROPS_ITEMS (2 << 24)
|
#define EF_DROPS_ITEMS (2 << 24)
|
||||||
#define EF_COMMON_FIGHTER (2 << 25)
|
#define EF_COMMON_FIGHTER (2 << 25)
|
||||||
#define EF_SURRENDERED (2 << 26)
|
#define EF_KILLED_PLAYER (2 << 26)
|
||||||
#define EF_KILLED_PLAYER (2 << 27)
|
|
||||||
|
|
||||||
#define AIF_NONE 0
|
#define AIF_NONE 0
|
||||||
#define AIF_FOLLOWS_PLAYER (2 << 0)
|
#define AIF_FOLLOWS_PLAYER (2 << 0)
|
||||||
|
@ -135,6 +134,8 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
||||||
#define AIF_SUSPICIOUS (2 << 19)
|
#define AIF_SUSPICIOUS (2 << 19)
|
||||||
#define AIF_ZAK_SUSPICIOUS (2 << 20)
|
#define AIF_ZAK_SUSPICIOUS (2 << 20)
|
||||||
#define AIF_SURRENDERS (2 << 21)
|
#define AIF_SURRENDERS (2 << 21)
|
||||||
|
#define AIF_SURRENDERING (2 << 22)
|
||||||
|
#define AIF_SURRENDERED (2 << 23)
|
||||||
|
|
||||||
/* player abilities */
|
/* player abilities */
|
||||||
#define BOOST_RECHARGE_TIME (FPS * 7)
|
#define BOOST_RECHARGE_TIME (FPS * 7)
|
||||||
|
|
Loading…
Reference in New Issue