diff --git a/src/battle/hud.c b/src/battle/hud.c index 818db05..e68434c 100644 --- a/src/battle/hud.c +++ b/src/battle/hud.c @@ -60,6 +60,7 @@ static char *OBJECTIVE_DIST_TEXT; static char *JUMPGATE_DIST_TEXT; static char *NEW_FIGHTER_TEXT; static char *SUSPICION_TEXT; +static char *REMAINING_PILOTS_TEXT; void initHud(void) { @@ -85,6 +86,7 @@ void initHud(void) JUMPGATE_DIST_TEXT = _("Jumpgate: %.2fkm"); NEW_FIGHTER_TEXT = _("SELECT NEW FIGHTER"); SUSPICION_TEXT = _("Suspicion"); + REMAINING_PILOTS_TEXT = _("Remaining Pilots: %d"); targetPointer = getTexture("gfx/hud/targetPointer.png"); targetCircle = getTexture("gfx/hud/targetCircle.png"); @@ -459,6 +461,11 @@ static void drawObjectives(void) { blit(objectives, (SCREEN_WIDTH / 2) - 50, 14, 0); drawText(SCREEN_WIDTH / 2, 10, 16, TA_CENTER, colors.white, "%d / %d", battle.numObjectivesComplete, (battle.numObjectivesTotal + battle.numConditions)); + + if (battle.isEpic && battle.epicLives > 0) + { + drawText(SCREEN_WIDTH / 2, 35, 14, TA_CENTER, colors.white, REMAINING_PILOTS_TEXT, battle.epicLives); + } } else { diff --git a/src/battle/objectives.c b/src/battle/objectives.c index 791dde5..9b04662 100644 --- a/src/battle/objectives.c +++ b/src/battle/objectives.c @@ -325,3 +325,24 @@ void loadObjectives(cJSON *node) fireObjectivesComplete = 1; } + +void addEpicLivesObjective(void) +{ + Objective *o; + char id[MAX_DESCRIPTION_LENGTH]; + + o = malloc(sizeof(Objective)); + memset(o, 0, sizeof(Objective)); + battle.objectiveTail->next = o; + battle.objectiveTail = o; + + sprintf(id, _("Do not lose more than %d pilots"), battle.epicLives); + + STRNCPY(o->id, id, MAX_DESCRIPTION_LENGTH); + STRNCPY(o->description, id, MAX_DESCRIPTION_LENGTH); + STRNCPY(o->targetName, "PLAYER", MAX_NAME_LENGTH); + o->targetValue = battle.epicLives; + o->targetType = TT_DESTROY; + o->active = 1; + o->isCondition = 1; +} diff --git a/src/battle/player.c b/src/battle/player.c index 89344f1..6771c32 100644 --- a/src/battle/player.c +++ b/src/battle/player.c @@ -166,7 +166,12 @@ void doPlayer(void) { updateDeathStats(); - initPlayerSelect(); + updateCondition("PLAYER", TT_DESTROY); + + if (battle.status == MS_IN_PROGRESS) + { + initPlayerSelect(); + } } } @@ -430,16 +435,19 @@ static void preFireMissile(void) void initPlayerSelect(void) { Entity *e; - + memset(&availablePlayerUnits, 0, sizeof(Entity*) * MAX_SELECTABLE_PLAYERS); selectedPlayerIndex = 0; - for (e = battle.entityHead.next ; e != NULL ; e = e->next) + if (battle.epicLives > 0 && --battle.epicLives > 0) { - if (e->active && e->type == ET_FIGHTER && e->health > 0 && e->side == SIDE_ALLIES && selectedPlayerIndex < MAX_SELECTABLE_PLAYERS) + for (e = battle.entityHead.next ; e != NULL ; e = e->next) { - availablePlayerUnits[selectedPlayerIndex++] = e; + if (e->active && e->type == ET_FIGHTER && e->health > 0 && e->side == SIDE_ALLIES && selectedPlayerIndex < MAX_SELECTABLE_PLAYERS) + { + availablePlayerUnits[selectedPlayerIndex++] = e; + } } } diff --git a/src/battle/player.h b/src/battle/player.h index 071ff89..c048241 100644 --- a/src/battle/player.h +++ b/src/battle/player.h @@ -46,6 +46,7 @@ extern int isAcceptControl(void); extern void resetAcceptControls(void); extern void awardTrophy(char *id); extern long flagsToLong(char *flags, int *add); +extern void updateCondition(char *name, int type); extern App app; extern Battle battle; diff --git a/src/galaxy/mission.c b/src/galaxy/mission.c index 9979170..6b4a67d 100644 --- a/src/galaxy/mission.c +++ b/src/galaxy/mission.c @@ -420,6 +420,12 @@ static void loadEpicData(cJSON *node) battle.epicFighterLimit = cJSON_GetObjectItem(node, "fighterLimit")->valueint; battle.unlimitedEnemies = getJSONValue(node, "unlimitedEnemies", 0); + battle.epicLives = getJSONValue(node, "lives", 0); + + if (battle.epicLives > 0) + { + addEpicLivesObjective(); + } for (e = battle.entityHead.next ; e != NULL ; e = e->next) { diff --git a/src/galaxy/mission.h b/src/galaxy/mission.h index 6daa8d1..47b0df4 100644 --- a/src/galaxy/mission.h +++ b/src/galaxy/mission.h @@ -64,6 +64,7 @@ extern void awardStatsTrophies(void); extern void awardPostMissionTrophies(void); extern void awardCraftTrophy(void); extern void setInitialPlayerAngle(void); +extern void addEpicLivesObjective(void); extern Battle battle; extern Dev dev; diff --git a/src/structs.h b/src/structs.h index ab44107..b31ca53 100644 --- a/src/structs.h +++ b/src/structs.h @@ -344,6 +344,7 @@ typedef struct { int isEpic; int unlimitedEnemies; int epicFighterLimit; + int epicLives; int playerSelect; int manualComplete; int unwinnable;