diff --git a/src/battle/hud.c b/src/battle/hud.c index 19cf3a7..148bfb7 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -472,6 +472,10 @@ static void drawObjectives(void) { drawText(SCREEN_WIDTH / 2, 35, 14, TA_CENTER, colors.white, "%d / %d", battle.stats[STAT_ENEMIES_DISABLED], game.currentMission->challengeData.disableLimit); } + else if (game.currentMission->challengeData.surrenderLimit) + { + drawText(SCREEN_WIDTH / 2, 35, 14, TA_CENTER, colors.white, "%d / %d", battle.stats[STAT_ENEMIES_SURRENDERED], game.currentMission->challengeData.surrenderLimit); + } else if (player->flags & EF_MUST_DISABLE) { drawText(SCREEN_WIDTH / 2, 35, 14, TA_CENTER, colors.white, _("System Power : %d%%"), player->systemPower); diff --git a/src/challenges/challenges.c b/src/challenges/challenges.c index 114dbf9..f87f08c 100644 --- a/src/challenges/challenges.c +++ b/src/challenges/challenges.c @@ -28,6 +28,7 @@ static void updateLossesChallenge(Challenge *c); static void updatePlayerKillsChallenge(Challenge *c); static void updateDisabledChallenge(Challenge *c); static void updateItemsChallenge(Challenge *c); +static void updateSurrenderChallenge(Challenge *c); static void completeChallenge(void); static void failChallenge(void); static int updateChallenges(void); @@ -61,6 +62,7 @@ void initChallenges(void) challengeDescription[CHALLENGE_ITEMS] = _("Collect %d packages"); challengeDescription[CHALLENGE_PLAYER_ITEMS] = _("Collect %d packages"); challengeDescription[CHALLENGE_RESCUE] = _("Rescue %d civilians"); + challengeDescription[CHALLENGE_SURRENDER] = _("Cause %d enemies to surrender"); tail = &game.challengeMissionHead; @@ -100,6 +102,7 @@ void loadChallenge(Mission *mission, cJSON *node) mission->challengeData.playerItemLimit = getJSONValue(node, "playerItemLimit", 0); mission->challengeData.rescueLimit = getJSONValue(node, "rescueLimit", 0); mission->challengeData.disableLimit = getJSONValue(node, "disableLimit", 0); + mission->challengeData.surrenderLimit = getJSONValue(node, "surrenderLimit", 0); /* restrictions */ mission->challengeData.noMissiles = getJSONValue(node, "noMissiles", 0); @@ -208,6 +211,11 @@ static int challengeFinished(void) return 1; } + if (game.currentMission->challengeData.surrenderLimit > 0 && (battle.stats[STAT_ENEMIES_KILLED_PLAYER] + battle.stats[STAT_ENEMIES_SURRENDERED] + battle.stats[STAT_ENEMIES_DISABLED]) >= game.currentMission->challengeData.surrenderLimit) + { + return 1; + } + if (game.currentMission->challengeData.eliminateThreats && !battle.hasThreats) { return 1; @@ -271,6 +279,10 @@ static int updateChallenges(void) case CHALLENGE_PLAYER_ITEMS: updateItemsChallenge(c); break; + + case CHALLENGE_SURRENDER: + updateSurrenderChallenge(c); + break; } } @@ -407,6 +419,14 @@ static void updateItemsChallenge(Challenge *c) } } +static void updateSurrenderChallenge(Challenge *c) +{ + if (!c->passed) + { + c->passed = battle.stats[STAT_ENEMIES_SURRENDERED] >= c->value; + } +} + char *getChallengeDescription(Challenge *c) { if (c->type == CHALLENGE_TIME) diff --git a/src/defs.h b/src/defs.h index b540789..c35bd8f 100644 --- a/src/defs.h +++ b/src/defs.h @@ -338,6 +338,7 @@ enum CHALLENGE_PLAYER_ITEMS, CHALLENGE_RESCUE, CHALLENGE_SURVIVE, + CHALLENGE_SURRENDER, CHALLENGE_MAX }; diff --git a/src/structs.h b/src/structs.h index 09ba096..ebd948a 100644 --- a/src/structs.h +++ b/src/structs.h @@ -259,6 +259,7 @@ typedef struct { int waypointLimit; int rescueLimit; int disableLimit; + int surrenderLimit; int noMissiles; int noBoost; int noECM; diff --git a/src/system/lookup.c b/src/system/lookup.c index 5a27bbe..dd914e7 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -157,6 +157,7 @@ void initLookups(void) addLookup("CHALLENGE_ITEMS", CHALLENGE_ITEMS); addLookup("CHALLENGE_PLAYER_ITEMS", CHALLENGE_PLAYER_ITEMS); addLookup("CHALLENGE_RESCUE", CHALLENGE_RESCUE); + addLookup("CHALLENGE_SURRENDER", CHALLENGE_SURRENDER); addLookup("STAT_PERCENT_COMPLETE", STAT_PERCENT_COMPLETE); addLookup("STAT_MISSIONS_STARTED", STAT_MISSIONS_STARTED);