From a251459413405968b995401c462024476e95619e Mon Sep 17 00:00:00 2001 From: Steve Date: Mon, 25 Jan 2016 14:58:07 +0000 Subject: [PATCH] Added "unwinnable" mission flag, to automatically continue the game when the player is defeated. --- src/battle/battle.c | 9 +++++++++ src/battle/missionInfo.c | 13 ++++++++----- src/galaxy/mission.c | 5 +++++ src/structs.h | 1 + 4 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/battle/battle.c b/src/battle/battle.c index b22a81a..9f44868 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -169,6 +169,15 @@ static void doBattle(void) } battle.stats[STAT_TIME]++; + + if (battle.unwinnable && battle.missionFinishedTimer <= -FPS * 6) + { + postBattle(); + + destroyBattle(); + + initGalacticMap(); + } } static void draw(void) diff --git a/src/battle/missionInfo.c b/src/battle/missionInfo.c index 6aae78b..bb9c399 100644 --- a/src/battle/missionInfo.c +++ b/src/battle/missionInfo.c @@ -52,13 +52,16 @@ void drawMissionInfo(void) case MS_COMPLETE: case MS_FAILED: - if (battle.missionFinishedTimer <= -FPS) + if (!battle.unwinnable) { - drawMissionSummary(battle.status == MS_COMPLETE ? missionCompleteTexture : missionFailedTexture); - - if (battle.missionFinishedTimer <= -(FPS * 2)) + if (battle.missionFinishedTimer <= -FPS) { - drawWidgets(battle.status == MS_COMPLETE ? "battleWon" : "battleLost"); + drawMissionSummary(battle.status == MS_COMPLETE ? missionCompleteTexture : missionFailedTexture); + + if (battle.missionFinishedTimer <= -(FPS * 2)) + { + drawWidgets(battle.status == MS_COMPLETE ? "battleWon" : "battleLost"); + } } } break; diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 0abf527..d0f5f12 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -72,6 +72,11 @@ void loadMission(char *filename) loadEpicData(cJSON_GetObjectItem(root, "epic")); } + if (cJSON_GetObjectItem(root, "unwinnable")) + { + battle.unwinnable = cJSON_GetObjectItem(root, "unwinnable")->valueint; + } + initScript(cJSON_GetObjectItem(root, "script")); free(text); diff --git a/src/structs.h b/src/structs.h index 89acfeb..c3896c2 100644 --- a/src/structs.h +++ b/src/structs.h @@ -278,6 +278,7 @@ typedef struct { int epic; int epicFighterLimit; int playerSelect; + int unwinnable; int missionFinishedTimer; int boostTimer; int ecmTimer;