diff --git a/data/fighters/tug.json b/data/fighters/tug.json index 9d752c5..f961124 100644 --- a/data/fighters/tug.json +++ b/data/fighters/tug.json @@ -14,5 +14,5 @@ } ], "flags" : "EF_HAS_ROPE", - "aiFlags" : "AIF_AVOIDS_COMBAT" + "aiFlags" : "AIF_AVOIDS_COMBAT+AIF_TOWS" } diff --git a/src/battle/ai.c b/src/battle/ai.c index 5080f6e..adff9c3 100644 --- a/src/battle/ai.c +++ b/src/battle/ai.c @@ -68,9 +68,12 @@ void doAI(void) 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()) @@ -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) diff --git a/src/battle/rope.c b/src/battle/rope.c index f3ae743..1fd33be 100644 --- a/src/battle/rope.c +++ b/src/battle/rope.c @@ -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; } }