From 6d8f9f575e294c5924433fde630634b55295cba9 Mon Sep 17 00:00:00 2001 From: Steve Date: Sun, 29 May 2016 09:36:10 +0100 Subject: [PATCH] Allow some missions have to unlimited enemies (unwinnable epics). --- .../clarke/06 - clarke defence #6.json | 9 +++++---- data/missions/iliad/05 - iliad defence #5.json | 9 +++++---- .../rothan/06 - rothan defence #5.json | 5 +++-- src/battle/entities.c | 16 ++++++++++++---- src/battle/entities.h | 1 + src/battle/fighters.c | 18 +++++++++++++++++- src/battle/hud.c | 2 +- src/galaxy/mission.c | 1 + src/structs.h | 1 + 9 files changed, 46 insertions(+), 16 deletions(-) diff --git a/data/missions/clarke/06 - clarke defence #6.json b/data/missions/clarke/06 - clarke defence #6.json index 4b1ef59..77afc9b 100644 --- a/data/missions/clarke/06 - clarke defence #6.json +++ b/data/missions/clarke/06 - clarke defence #6.json @@ -9,14 +9,15 @@ "objectives" : [ { "description" : "Destroy all enemy targets", - "targetName" : "Pandoran", - "targetValue" : 999, + "targetName" : "ENEMY", + "targetValue" : 1, "targetType" : "TT_DESTROY", - "hideNumbers" : 1 + "isEliminateAll" : 1 } ], "epic" : { - "fighterLimit" : 24 + "fighterLimit" : 24, + "unlimitedEnemies" : 1 }, "player" : { "type" : "Rook", diff --git a/data/missions/iliad/05 - iliad defence #5.json b/data/missions/iliad/05 - iliad defence #5.json index 91c1848..c9257ad 100644 --- a/data/missions/iliad/05 - iliad defence #5.json +++ b/data/missions/iliad/05 - iliad defence #5.json @@ -6,16 +6,17 @@ "planet" : "gfx/planets/bluePlanet.png", "music" : "music/battle/Tactical Pursuit.mp3", "epic" : { - "fighterLimit" : 12 + "fighterLimit" : 12, + "unlimitedEnemies" : 1 }, "unwinnable" : 1, "objectives" : [ { "description" : "Destroy all enemy targets", - "targetName" : "Pandoran", - "targetValue" : 999, + "targetName" : "ENEMY", + "targetValue" : 1, "targetType" : "TT_DESTROY", - "hideNumbers" : 1 + "isEliminateAll" : 1 } ], "player" : { diff --git a/data/missions/rothan/06 - rothan defence #5.json b/data/missions/rothan/06 - rothan defence #5.json index 483f979..980886b 100644 --- a/data/missions/rothan/06 - rothan defence #5.json +++ b/data/missions/rothan/06 - rothan defence #5.json @@ -8,7 +8,8 @@ "music" : "music/battle/Tactical Pursuit.mp3", "unwinnable" : 1, "epic" : { - "fighterLimit" : 18 + "fighterLimit" : 18, + "unlimitedEnemies" : 1 }, "objectives" : [ { @@ -53,7 +54,7 @@ "side" : "SIDE_PANDORAN", "x" : 25, "y" : 15, - "number" : 999, + "number" : 100, "scatter" : 5000, "flags" : "+EF_AI_TARGET" } diff --git a/src/battle/entities.c b/src/battle/entities.c index 2b3e1ab..30a7b64 100644 --- a/src/battle/entities.c +++ b/src/battle/entities.c @@ -189,11 +189,19 @@ void doEntities(void) cutRope(e); prev->next = e->next; - - /* move to dead list */ + e->next = NULL; - deadTail->next = e; - deadTail = e; + + /* Move to end of entity queue if unlimited epic enemies. Otherwise, in dead list */ + if (battle.isEpic && e->side != player->side && battle.unlimitedEnemies) + { + resetFighter(e); + } + else + { + deadTail->next = e; + deadTail = e; + } e = prev; } diff --git a/src/battle/entities.h b/src/battle/entities.h index 2cff27f..f3779d7 100644 --- a/src/battle/entities.h +++ b/src/battle/entities.h @@ -38,6 +38,7 @@ extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore); extern int isOnBattleScreen(int x, int y, int w, int h); extern long lookup(char *name); extern void awardTrophy(char *id); +extern void resetFighter(Entity *e); extern App app; extern Battle battle; diff --git a/src/battle/fighters.c b/src/battle/fighters.c index ce6be29..ba7a2ae 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -190,6 +190,22 @@ static void randomizeDartGuns(Entity *dart) } } +void resetFighter(Entity *e) +{ + e->active = 0; + e->health = e->maxHealth; + e->systemPower = MAX_SYSTEM_POWER; + e->alive = ALIVE_ALIVE; + e->action = doAI; + e->die = die; + + e->next = NULL; + + battle.entityTail->next = e; + + SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Resetting fighter '%s'", e->name); +} + void doFighter(void) { if (self->alive == ALIVE_ALIVE) @@ -584,7 +600,7 @@ static void die(void) incFighterStat(self->defName); } - if (battle.isEpic) + if (battle.isEpic && player->flags & EF_COMMON_FIGHTER) { battle.stats[STAT_EPIC_KILL_STREAK]++; } diff --git a/src/battle/hud.c b/src/battle/hud.c index 148bfb7..e781e9e 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -425,7 +425,7 @@ static void drawNumFighters(void) /* Enemies */ SDL_SetTextureColorMod(smallFighter, 255, 100, 100); blit(smallFighter, SCREEN_WIDTH - 410, 15, 0); - drawText(SCREEN_WIDTH - 420, 11, 14, TA_RIGHT, colors.white, battle.numEnemies < 1000 ? "(%d)" : "(999+)", battle.numEnemies); + drawText(SCREEN_WIDTH - 420, 11, 14, TA_RIGHT, colors.white, !battle.unlimitedEnemies ? "(%d)" : "(999+)", battle.numEnemies); } static void drawObjectives(void) diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index d5dd5e5..b39bab8 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -407,6 +407,7 @@ static void loadEpicData(cJSON *node) battle.isEpic = 1; battle.epicFighterLimit = cJSON_GetObjectItem(node, "fighterLimit")->valueint; + battle.unlimitedEnemies = getJSONValue(node, "unlimitedEnemies", 0); for (e = battle.entityHead.next ; e != NULL ; e = e->next) { diff --git a/src/structs.h b/src/structs.h index d36d624..e6b42d4 100644 --- a/src/structs.h +++ b/src/structs.h @@ -339,6 +339,7 @@ typedef struct { int numInitialEnemies; int status; int isEpic; + int unlimitedEnemies; int epicFighterLimit; int playerSelect; int manualComplete;