Use battle.hasThreats to determine if all enemies have been defeated.

This commit is contained in:
Steve 2016-05-10 14:56:10 +01:00
parent 6dcbd265d9
commit 025e72822b
5 changed files with 18 additions and 7 deletions

View File

@ -67,7 +67,7 @@ void doEntities(void)
prev = &battle.entityHead;
numAllies = numEnemies = numActiveAllies = numActiveEnemies = numSpawnedEnemies = 0;
battle.hasThreats = numAllies = numEnemies = numActiveAllies = numActiveEnemies = numSpawnedEnemies = 0;
if (dev.playerImmortal)
{
@ -218,6 +218,11 @@ void doEntities(void)
numSpawnedEnemies++;
}
}
if (e->health > 0 && !(e->flags & EF_DISABLED))
{
battle.hasThreats = 1;
}
}
}

View File

@ -120,7 +120,7 @@ void updateObjective(char *name, int type)
}
}
if (o->isEliminateAll && o->status != OS_COMPLETE && (battle.stats[STAT_ENEMIES_KILLED] + battle.stats[STAT_CAPITAL_SHIPS_DESTROYED]) == battle.numInitialEnemies)
if (o->isEliminateAll && o->status != OS_COMPLETE && !battle.hasThreats)
{
addHudMessage(colors.green, _("%s - Objective Complete!"), o->description);

View File

@ -262,7 +262,7 @@ static void executeNextLine(ScriptRunner *runner)
}
else if (strcmp(command, "END_CHALLENGE") == 0)
{
game.currentMission->challengeData.scriptedEnd = 1;
battle.scriptedEnd = 1;
}
else if (strcmp(command, "RETREAT_ALLIES") == 0)
{

View File

@ -89,8 +89,6 @@ void loadChallenge(Mission *mission, cJSON *node)
int i;
Challenge *challenge;
memset(&mission->challengeData, 0, sizeof(ChallengeData));
mission->challengeData.isChallenge = 1;
/* limits */
@ -117,6 +115,7 @@ void loadChallenge(Mission *mission, cJSON *node)
/* misc */
mission->challengeData.allowPlayerDeath = getJSONValue(node, "allowPlayerDeath", 0);
mission->challengeData.clearWaypointEnemies = getJSONValue(node, "clearWaypointEnemies", 0);
mission->challengeData.eliminateThreats = getJSONValue(node, "eliminateThreats", 0);
node = cJSON_GetObjectItem(node, "challenges");
@ -208,7 +207,12 @@ static int challengeFinished(void)
return 1;
}
return (player->health <= 0 || player->alive == ALIVE_ESCAPED || game.currentMission->challengeData.scriptedEnd);
if (game.currentMission->challengeData.eliminateThreats && !battle.hasThreats)
{
return 1;
}
return (player->health <= 0 || player->alive == ALIVE_ESCAPED || battle.scriptedEnd);
}
static int updateChallenges(void)

View File

@ -262,9 +262,9 @@ typedef struct {
int noBoost;
int noECM;
int noGuns;
int scriptedEnd;
int allowPlayerDeath;
int clearWaypointEnemies;
int eliminateThreats;
Challenge *challenges[MAX_CHALLENGES];
} ChallengeData;
@ -345,6 +345,8 @@ typedef struct {
int radarRange;
int numPlayerGuns;
int numObjectivesComplete, numObjectivesTotal, numConditions;
int scriptedEnd;
int hasThreats;
Entity *missionTarget;
Entity *jumpgate;
Entity *messageSpeaker;