From 4db432f845512648c7accdd2e8345a019107625d Mon Sep 17 00:00:00 2001 From: Steve Date: Fri, 20 Nov 2015 22:51:44 +0000 Subject: [PATCH] Allow player to retreat from missions. --- src/battle/triggers.c | 9 +++++++++ src/battle/triggers.h | 1 + src/defs.h | 6 +++++- src/system/lookup.c | 4 ++++ 4 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/battle/triggers.c b/src/battle/triggers.c index a46763a..1e54d0a 100644 --- a/src/battle/triggers.c +++ b/src/battle/triggers.c @@ -46,6 +46,9 @@ static int conditionMet(Trigger *trigger) case TRIGGER_KILLS: return trigger->targetValue == battle.stats[STAT_ENEMIES_KILLED]; + case TRIGGER_LOSSES: + return trigger->targetValue == battle.stats[STAT_ALLIES_KILLED]; + case TRIGGER_WAYPOINT: return 1; @@ -81,5 +84,11 @@ static void fireTrigger(Trigger *trigger) case TA_ACTIVE_OBJECTIVE: activateObjective(atoi(trigger->actionValue)); break; + + case TA_RETREAT_ALLIES: + battle.epic = 0; + addHudMessage(colors.red, "Mission Aborted! Retreat!"); + retreatAllies(); + break; } } diff --git a/src/battle/triggers.h b/src/battle/triggers.h index b25fbdb..f16d908 100644 --- a/src/battle/triggers.h +++ b/src/battle/triggers.h @@ -29,6 +29,7 @@ extern void addHudMessage(SDL_Color c, char *format, ...); extern void activateEntities(char *name); extern void activateObjective(int num); extern void activateEntityGroup(char *groupName); +extern void retreatAllies(void); extern Battle battle; extern Colors colors; diff --git a/src/defs.h b/src/defs.h index 9390205..4b28c0a 100644 --- a/src/defs.h +++ b/src/defs.h @@ -73,6 +73,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #define EF_COLLECTS_ITEMS (2 << 6) #define EF_MUST_DISABLE (2 << 7) #define EF_FLEEING (2 << 8) +#define EF_NO_EPIC (2 << 9) #define AIF_NONE 0 #define AIF_FOLLOWS_PLAYER (2 << 0) @@ -190,6 +191,7 @@ enum TT_DISABLE, TT_WAYPOINT, TT_ESCAPED, + TT_PLAYER_ESCAPED, TT_ITEM }; @@ -197,6 +199,7 @@ enum { TRIGGER_TIME, TRIGGER_KILLS, + TRIGGER_LOSSES, TRIGGER_WAYPOINT, TRIGGER_ESCAPES, TRIGGER_ITEM @@ -208,7 +211,8 @@ enum TA_FAIL_MISSION, TA_ACTIVE_ENTITY, TA_ACTIVE_ENTITY_GROUP, - TA_ACTIVE_OBJECTIVE + TA_ACTIVE_OBJECTIVE, + TA_RETREAT_ALLIES }; enum diff --git a/src/system/lookup.c b/src/system/lookup.c index ece324f..a6a3db6 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -41,6 +41,7 @@ void initLookups(void) addLookup("EF_FLEEING", EF_FLEEING); addLookup("EF_HAS_ROPE", EF_HAS_ROPE); addLookup("EF_COLLECTS_ITEMS", EF_COLLECTS_ITEMS); + addLookup("EF_NO_EPIC", EF_NO_EPIC); addLookup("AIF_NONE", AIF_NONE); addLookup("AIF_FOLLOWS_PLAYER", AIF_FOLLOWS_PLAYER); @@ -55,6 +56,7 @@ void initLookups(void) addLookup("TT_DISABLE", TT_DISABLE); addLookup("TT_WAYPOINT", TT_WAYPOINT); addLookup("TT_ESCAPED", TT_ESCAPED); + addLookup("TT_PLAYER_ESCAPED", TT_PLAYER_ESCAPED); addLookup("TT_ITEM", TT_ITEM); addLookup("WT_BUTTON", WT_BUTTON); @@ -127,6 +129,7 @@ void initLookups(void) addLookup("TRIGGER_TIME", TRIGGER_TIME); addLookup("TRIGGER_KILLS", TRIGGER_KILLS); + addLookup("TRIGGER_LOSSES", TRIGGER_LOSSES); addLookup("TRIGGER_WAYPOINT", TRIGGER_WAYPOINT); addLookup("TA_COMPLETE_MISSION", TA_COMPLETE_MISSION); @@ -134,6 +137,7 @@ void initLookups(void) addLookup("TA_ACTIVE_ENTITY", TA_ACTIVE_ENTITY); addLookup("TA_ACTIVE_OBJECTIVE", TA_ACTIVE_OBJECTIVE); addLookup("TA_ACTIVE_ENTITY_GROUP", TA_ACTIVE_ENTITY_GROUP); + addLookup("TA_RETREAT_ALLIES", TA_RETREAT_ALLIES); } static void addLookup(char *name, long value)