diff --git a/src/battle/hud.c b/src/battle/hud.c index 8f2cb9e..a926948 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -392,12 +392,12 @@ static void drawNumFighters(void) /* Allies */ SDL_SetTextureColorMod(smallFighter, 150, 200, 255); blit(smallFighter, 400, 15, 0); - drawText(425, 11, 14, TA_LEFT, colors.white, "(%d)", battle.numAllies); + drawText(425, 11, 14, TA_LEFT, colors.white, battle.numAllies < 1000 ? "(%d)" : "(999+)", battle.numAllies); /* Enemies */ SDL_SetTextureColorMod(smallFighter, 255, 100, 100); blit(smallFighter, SCREEN_WIDTH - 410, 15, 0); - drawText(SCREEN_WIDTH - 420, 11, 14, TA_RIGHT, colors.white, "(%d)", battle.numEnemies); + drawText(SCREEN_WIDTH - 420, 11, 14, TA_RIGHT, colors.white, battle.numEnemies < 1000 ? "(%d)" : "(999+)", battle.numEnemies); } static void drawObjectives(void) @@ -411,6 +411,11 @@ static void drawObjectives(void) if (game.currentMission->challengeData.timeLimit) { drawText(SCREEN_WIDTH / 2, 10, 16, TA_CENTER, colors.white, timeToString(game.currentMission->challengeData.timeLimit - battle.stats[STAT_TIME], 0)); + + if (game.currentMission->challengeData.itemLimit) + { + drawText(SCREEN_WIDTH / 2, 35, 14, TA_CENTER, colors.white, "%d / %d", battle.stats[STAT_ITEMS_COLLECTED] + battle.stats[STAT_ITEMS_COLLECTED_PLAYER], game.currentMission->challengeData.itemLimit); + } } else { diff --git a/src/battle/items.c b/src/battle/items.c index 404134c..a2acb0b 100644 --- a/src/battle/items.c +++ b/src/battle/items.c @@ -114,6 +114,10 @@ static void action(void) if (e == player) { addHudMessage(colors.white, _("Picked up %s"), self->name); + battle.stats[STAT_ITEMS_COLLECTED_PLAYER]++; + } + else + { battle.stats[STAT_ITEMS_COLLECTED]++; } diff --git a/src/challenges/challenges.c b/src/challenges/challenges.c index 6c4063a..790656f 100644 --- a/src/challenges/challenges.c +++ b/src/challenges/challenges.c @@ -26,6 +26,7 @@ static void updateArmourChallenge(Challenge *c); static void updateLossesChallenge(Challenge *c); static void updatePlayerKillsChallenge(Challenge *c); static void updateDisabledChallenge(Challenge *c); +static void updateItemsChallenge(Challenge *c); static void completeChallenge(void); static void failChallenge(void); static void updateChallenges(void); @@ -55,6 +56,7 @@ void initChallenges(void) challengeDescription[CHALLENGE_LOSSES] = _("Do not lose more than %d team mates"); challengeDescription[CHALLENGE_PLAYER_KILLS] = _("Take down %d enemy targets"); challengeDescription[CHALLENGE_DISABLE] = _("Disable %d or more enemy fighters"); + challengeDescription[CHALLENGE_ITEMS] = _("Collect %d packages"); tail = &game.challengeMissionHead; @@ -117,7 +119,12 @@ static int challengeFinished(void) return 1; } - if (game.currentMission->challengeData.itemLimit > 0 && battle.stats[STAT_ITEMS_COLLECTED] >= game.currentMission->challengeData.itemLimit) + if (game.currentMission->challengeData.itemLimit > 0 && battle.stats[STAT_ITEMS_COLLECTED] + battle.stats[STAT_ITEMS_COLLECTED_PLAYER] >= game.currentMission->challengeData.itemLimit) + { + return 1; + } + + if (game.currentMission->challengeData.scriptedEnd) { return 1; } @@ -167,6 +174,10 @@ static void updateChallenges(void) case CHALLENGE_DISABLE: updateDisabledChallenge(c); break; + + case CHALLENGE_ITEMS: + updateItemsChallenge(c); + break; } } } @@ -272,6 +283,14 @@ static void updateDisabledChallenge(Challenge *c) } } +static void updateItemsChallenge(Challenge *c) +{ + if (!c->passed) + { + c->passed = battle.stats[STAT_ITEMS_COLLECTED] + battle.stats[STAT_ITEMS_COLLECTED_PLAYER] >= c->value; + } +} + char *getChallengeDescription(Challenge *c) { return getFormattedChallengeDescription(challengeDescription[c->type], c->value); diff --git a/src/defs.h b/src/defs.h index c80f810..1046787 100644 --- a/src/defs.h +++ b/src/defs.h @@ -288,6 +288,7 @@ enum CHALLENGE_LOSSES, CHALLENGE_PLAYER_KILLS, CHALLENGE_DISABLE, + CHALLENGE_ITEMS, CHALLENGE_MAX }; @@ -323,6 +324,7 @@ enum STAT_SHUTTLE, STAT_NUM_TOWED, STAT_ITEMS_COLLECTED, + STAT_ITEMS_COLLECTED_PLAYER, STAT_WAYPOINTS_VISITED, STAT_EPIC_KILL_STREAK, STAT_CAPITAL_SHIPS_DESTROYED, diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 1a9502e..769a770 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -77,10 +77,14 @@ Mission *loadMissionMeta(char *filename) { mission->challengeData.isChallenge = 1; + /* limits */ mission->challengeData.timeLimit = getJSONValue(node, "timeLimit", 0) * FPS; mission->challengeData.killLimit = getJSONValue(node, "killLimit", 0); mission->challengeData.escapeLimit = getJSONValue(node, "escapeLimit", 0); mission->challengeData.waypointLimit = getJSONValue(node, "waypointLimit", 0); + mission->challengeData.itemLimit = getJSONValue(node, "itemLimit", 0); + + /* restrictions */ mission->challengeData.noMissiles = getJSONValue(node, "noMissiles", 0); mission->challengeData.noECM = getJSONValue(node, "noECM", 0); mission->challengeData.noBoost = getJSONValue(node, "noBoost", 0); diff --git a/src/galaxy/stats.c b/src/galaxy/stats.c index 490f4df..9f99a4e 100644 --- a/src/galaxy/stats.c +++ b/src/galaxy/stats.c @@ -63,6 +63,7 @@ void initStats(void) statDescription[STAT_SHUTTLE] = _("Times used Shuttle"); statDescription[STAT_NUM_TOWED] = _("Craft Towed"); statDescription[STAT_ITEMS_COLLECTED] = _("Items Collected"); + statDescription[STAT_ITEMS_COLLECTED_PLAYER] = _("Items Collected (Player)"); statDescription[STAT_EPIC_KILL_STREAK] = _("Longest Epic Kill Streak"); statDescription[STAT_WAYPOINTS_VISITED] = _("Waypoints Visited"); statDescription[STAT_CAPITAL_SHIPS_DESTROYED] = _("Capital Ships Destroyed"); diff --git a/src/system/lookup.c b/src/system/lookup.c index 4a74bf3..db2779b 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -130,6 +130,7 @@ void initLookups(void) addLookup("CHALLENGE_LOSSES", CHALLENGE_LOSSES); addLookup("CHALLENGE_PLAYER_KILLS", CHALLENGE_PLAYER_KILLS); addLookup("CHALLENGE_DISABLE", CHALLENGE_DISABLE); + addLookup("CHALLENGE_ITEMS", CHALLENGE_ITEMS); addLookup("STAT_PERCENT_COMPLETE", STAT_PERCENT_COMPLETE); addLookup("STAT_MISSIONS_STARTED", STAT_MISSIONS_STARTED); @@ -161,6 +162,7 @@ void initLookups(void) addLookup("STAT_SHUTTLE", STAT_SHUTTLE); addLookup("STAT_NUM_TOWED", STAT_NUM_TOWED); addLookup("STAT_ITEMS_COLLECTED", STAT_ITEMS_COLLECTED); + addLookup("STAT_ITEMS_COLLECTED_PLAYER", STAT_ITEMS_COLLECTED_PLAYER); addLookup("STAT_WAYPOINTS_VISITED", STAT_WAYPOINTS_VISITED); addLookup("STAT_EPIC_KILL_STREAK", STAT_EPIC_KILL_STREAK); addLookup("STAT_CAPITAL_SHIPS_DESTROYED", STAT_CAPITAL_SHIPS_DESTROYED);