Allow challenges to be completed even if the player is killed.

This commit is contained in:
Steve 2016-04-02 09:37:39 +01:00
parent 422901632f
commit a64b41f851
5 changed files with 21 additions and 7 deletions

View File

@ -276,11 +276,7 @@ void doFighter(void)
if (self->alive == ALIVE_DEAD)
{
if (self == player)
{
battle.stats[STAT_PLAYER_KILLED]++;
}
else if (player != NULL)
if (player != NULL && self == player)
{
if (player->alive == ALIVE_ALIVE)
{

View File

@ -119,7 +119,16 @@ void doPlayer(void)
if (player->health <= 0 && battle.status == MS_IN_PROGRESS)
{
if (!battle.isEpic)
battle.stats[STAT_PLAYER_KILLED]++;
if (game.currentMission->challengeData.isChallenge)
{
if (!game.currentMission->challengeData.allowPlayerDeath)
{
failMission();
}
}
else if (!battle.isEpic)
{
failMission();
}

View File

@ -87,7 +87,7 @@ void doChallenges(void)
{
if (challengeFinished())
{
if (battle.stats[STAT_TIME] >= game.currentMission->challengeData.timeLimit)
if (game.currentMission->challengeData.timeLimit && battle.stats[STAT_TIME] >= game.currentMission->challengeData.timeLimit)
{
failChallenge();
}
@ -139,6 +139,11 @@ static int challengeFinished(void)
return 1;
}
if (player->health <= 0)
{
return 1;
}
return 0;
}

View File

@ -87,6 +87,9 @@ Mission *loadMissionMeta(char *filename)
mission->challengeData.noECM = getJSONValue(node, "noECM", 0);
mission->challengeData.noBoost = getJSONValue(node, "noBoost", 0);
mission->challengeData.noGuns = getJSONValue(node, "noGuns", 0);
/* misc */
mission->challengeData.allowPlayerDeath = getJSONValue(node, "allowPlayerDeath", 0);
node = cJSON_GetObjectItem(node, "challenges");

View File

@ -261,6 +261,7 @@ typedef struct {
int noECM;
int noGuns;
int scriptedEnd;
int allowPlayerDeath;
Challenge *challenges[MAX_CHALLENGES];
} ChallengeData;