diff --git a/src/defs.h b/src/defs.h index f00f2a7..72f041a 100644 --- a/src/defs.h +++ b/src/defs.h @@ -337,6 +337,7 @@ enum STAT_PERCENT_COMPLETE, STAT_MISSIONS_STARTED, STAT_MISSIONS_COMPLETED, + STAT_OPTIONAL_COMPLETED, STAT_CHALLENGES_STARTED, STAT_CHALLENGES_COMPLETED, STAT_SHOTS_FIRED, diff --git a/src/galaxy/galacticMap.c b/src/galaxy/galacticMap.c index c086eee..88469b3 100644 --- a/src/galaxy/galacticMap.c +++ b/src/galaxy/galacticMap.c @@ -606,7 +606,7 @@ static void drawStarSystemDetail(void) { drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.yellow, _("Note: this is an epic mission.")); } - else if (selectedStarSystem->side == SIDE_PANDORAN) + else if (game.currentMission->isOptional) { drawText(525, SCREEN_HEIGHT - 95, 18, TA_LEFT, colors.cyan, _("Note: this is an optional mission.")); } diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 6ebb636..8d22092 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -51,7 +51,10 @@ Mission *loadMissionMeta(char *filename) STRNCPY(mission->filename, filename, MAX_DESCRIPTION_LENGTH); mission->requires = getJSONValue(root, "requires", 0); - + + mission->isOptional = getJSONValue(root, "isOptional", 0); + mission->requiresOptional = getJSONValue(root, "requiresOptional", 0); + if (cJSON_GetObjectItem(root, "epic")) { mission->epic = 1; @@ -256,6 +259,11 @@ void completeMission(void) selectWidget("continue", "battleWon"); game.stats[STAT_MISSIONS_COMPLETED]++; + + if (game.currentMission->isOptional) + { + game.stats[STAT_OPTIONAL_COMPLETED]++; + } completeConditions(); @@ -448,7 +456,7 @@ void updateAllMissions(void) int isMissionAvailable(Mission *mission, Mission *prev) { - return (prev->completed && mission->requires <= game.completedMissions) || dev.debug; + return (prev->completed && mission->requires <= game.completedMissions && game.stats[STAT_OPTIONAL_COMPLETED] >= mission->requiresOptional) || dev.debug; } static unsigned long hashcode(const char *str) diff --git a/src/game/stats.c b/src/game/stats.c index 930e4e9..671162d 100644 --- a/src/game/stats.c +++ b/src/game/stats.c @@ -36,6 +36,7 @@ void initStats(void) statDescription[STAT_PERCENT_COMPLETE] = _("Percent Complete"); statDescription[STAT_MISSIONS_STARTED] = _("Missions Started"); statDescription[STAT_MISSIONS_COMPLETED] = _("Missons Completed"); + statDescription[STAT_OPTIONAL_COMPLETED] = _("Optional Missions Completed"); statDescription[STAT_CHALLENGES_STARTED] = _("Challenges Started"); statDescription[STAT_CHALLENGES_COMPLETED] = _("Challenges Completed"); statDescription[STAT_SHOTS_FIRED] = _("Shots Fired"); diff --git a/src/structs.h b/src/structs.h index 52e10f1..70cbcf1 100644 --- a/src/structs.h +++ b/src/structs.h @@ -274,6 +274,7 @@ struct Mission { char description[MAX_DESCRIPTION_LENGTH]; char filename[MAX_DESCRIPTION_LENGTH]; int requires; + int requiresOptional; char pilot[MAX_NAME_LENGTH]; char squadron[MAX_NAME_LENGTH]; char craft[MAX_NAME_LENGTH]; @@ -282,6 +283,7 @@ struct Mission { int completedChallenges; int totalChallenges; int epic; + int isOptional; ChallengeData challengeData; SDL_Rect rect; Mission *next; diff --git a/src/system/lookup.c b/src/system/lookup.c index da8210b..5c94fad 100644 --- a/src/system/lookup.c +++ b/src/system/lookup.c @@ -103,6 +103,7 @@ void initLookups(void) addLookup("TT_PLAYER_ESCAPED", TT_PLAYER_ESCAPED); addLookup("TT_ITEM", TT_ITEM); addLookup("TT_STOLEN", TT_STOLEN); + addLookup("TT_MISC", TT_MISC); addLookup("WT_BUTTON", WT_BUTTON); addLookup("WT_SELECT", WT_SELECT); @@ -155,6 +156,7 @@ void initLookups(void) addLookup("STAT_PERCENT_COMPLETE", STAT_PERCENT_COMPLETE); addLookup("STAT_MISSIONS_STARTED", STAT_MISSIONS_STARTED); addLookup("STAT_MISSIONS_COMPLETED", STAT_MISSIONS_COMPLETED); + addLookup("STAT_OPTIONAL_COMPLETED", STAT_OPTIONAL_COMPLETED); addLookup("STAT_CHALLENGES_STARTED", STAT_CHALLENGES_STARTED); addLookup("STAT_CHALLENGES_COMPLETED", STAT_CHALLENGES_COMPLETED); addLookup("STAT_SHOTS_FIRED", STAT_SHOTS_FIRED);