From b44f208f6cce9eaef7f0834d294ab50b43422903 Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 20 Nov 2015 22:52:35 +0000 Subject: [PATCH] Complete mission if player escapes. --- src/battle/fighters.c | 35 +++++++++++++++++++++++++++++++++++ src/battle/fighters.h | 1 + 2 files changed, 36 insertions(+) diff --git a/src/battle/fighters.c b/src/battle/fighters.c index 647b9cb..05171de 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -227,10 +227,25 @@ void doFighter(void) battle.stats[STAT_ENEMIES_DISABLED]++; } } + + if (self->target != NULL && self->target->alive != ALIVE_ALIVE) + { + self->target = NULL; + + if (self != player) + { + self->action = doAI; + } + } } if (self->alive == ALIVE_ESCAPED) { + if (self == player) + { + completeMission(); + } + if (self->side != SIDE_ALLIES) { addHudMessage(colors.red, "Mission target has escaped."); @@ -279,6 +294,8 @@ void doFighter(void) { addHudMessage(colors.red, "Ally has been killed"); } + + checkTrigger("ALLIES_KILLED", TRIGGER_LOSSES); } } } @@ -534,6 +551,24 @@ void fleeAllEnemies(void) } } +void retreatAllies(void) +{ + Entity *e; + + for (e = battle.entityHead.next ; e != NULL ; e = e->next) + { + if (e->type == ET_FIGHTER && e->side == SIDE_ALLIES) + { + e->flags |= EF_FLEEING; + + e->aiFlags |= AIF_AVOIDS_COMBAT; + e->aiFlags |= AIF_UNLIMITED_RANGE; + e->aiFlags |= AIF_GOAL_EXTRACTION; + e->aiFlags &= ~AIF_FOLLOWS_PLAYER; + } + } +} + Entity *getFighterDef(char *name) { Entity *f; diff --git a/src/battle/fighters.h b/src/battle/fighters.h index c67d170..c53fd65 100644 --- a/src/battle/fighters.h +++ b/src/battle/fighters.h @@ -47,6 +47,7 @@ extern char *readFile(char *filename); extern long lookup(char *name); extern long flagsToLong(char *flags); extern void addShieldSplinterEffect(Entity *ent); +extern void completeMission(void); extern App app; extern Battle battle;