Allow AI controlled tug to collect disabled fighters, and take them to the extraction point.

This commit is contained in:
Steve 2015-11-26 22:48:22 +00:00
parent d8783cc557
commit 3ef305686f
3 changed files with 14 additions and 4 deletions

View File

@ -14,5 +14,5 @@
}
],
"flags" : "EF_HAS_ROPE",
"aiFlags" : "AIF_AVOIDS_COMBAT"
"aiFlags" : "AIF_AVOIDS_COMBAT+AIF_TOWS"
}

View File

@ -68,10 +68,13 @@ void doAI(void)
return;
}
if ((self->aiFlags & AIF_TOWS) && nearTowableCraft())
if (self->aiFlags & AIF_TOWS)
{
if (!self->towing && nearTowableCraft())
{
return;
}
}
if ((self->aiFlags & AIF_RETREATS) && (battle.stats[STAT_TIME] % 60 == 0) && isRetreating())
{
@ -592,7 +595,7 @@ static int nearTowableCraft(void)
for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i])
{
if (e->type == ET_FIGHTER && (e->flags & EF_DISABLED))
if (e->type == ET_FIGHTER && (e->flags & (EF_DISABLED|EF_MISSION_TARGET)) == (EF_DISABLED|EF_MISSION_TARGET))
{
distance = getDistance(self->x, self->y, e->x, e->y);
@ -618,6 +621,8 @@ static void moveToTowableCraft(void)
faceTarget(self->target);
applyFighterThrust();
nextAction();
}
static void lookForPlayer(void)

View File

@ -40,6 +40,10 @@ void attachRope(void)
self->towing = e;
e->owner = self;
self->aiFlags |= AIF_GOAL_EXTRACTION;
e->flags |= EF_RETREATING;
if (self == player)
{
battle.stats[STAT_NUM_TOWED]++;
@ -92,6 +96,7 @@ void cutRope(Entity *e)
if (e->owner && e->owner->towing == e)
{
e->owner->towing = NULL;
e->owner->aiFlags &= ~AIF_GOAL_EXTRACTION;
e->owner = NULL;
}
}