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", "flags" : "EF_HAS_ROPE",
"aiFlags" : "AIF_AVOIDS_COMBAT" "aiFlags" : "AIF_AVOIDS_COMBAT+AIF_TOWS"
} }

View File

@ -68,9 +68,12 @@ void doAI(void)
return; return;
} }
if ((self->aiFlags & AIF_TOWS) && nearTowableCraft()) if (self->aiFlags & AIF_TOWS)
{ {
return; if (!self->towing && nearTowableCraft())
{
return;
}
} }
if ((self->aiFlags & AIF_RETREATS) && (battle.stats[STAT_TIME] % 60 == 0) && isRetreating()) 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]) 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); distance = getDistance(self->x, self->y, e->x, e->y);
@ -618,6 +621,8 @@ static void moveToTowableCraft(void)
faceTarget(self->target); faceTarget(self->target);
applyFighterThrust(); applyFighterThrust();
nextAction();
} }
static void lookForPlayer(void) static void lookForPlayer(void)

View File

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