Allow for a kill threshold to be specified in epic missions (for use with unwinnable missions).

This commit is contained in:
Steve 2016-08-28 18:48:55 +01:00
parent b8dccb9882
commit e59af4bfbc
6 changed files with 41 additions and 3 deletions

View File

@ -364,6 +364,11 @@ void doFighter(void)
updateObjective(self->name, TT_DESTROY); updateObjective(self->name, TT_DESTROY);
updateObjective(self->groupName, TT_DESTROY); updateObjective(self->groupName, TT_DESTROY);
if (battle.isEpic && self->killedBy == player)
{
updateObjective("EPIC_PLAYER_KILLS", TT_DESTROY);
}
adjustObjectiveTargetValue(self->name, TT_ESCAPED, -1); adjustObjectiveTargetValue(self->name, TT_ESCAPED, -1);
updateCondition(self->name, TT_DESTROY); updateCondition(self->name, TT_DESTROY);

View File

@ -346,3 +346,23 @@ void addEpicLivesObjective(void)
o->active = 1; o->active = 1;
o->isCondition = 1; o->isCondition = 1;
} }
void addEpicKillsObjective(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, _("Destroy at least %d enemy fighters"), battle.epicKills);
STRNCPY(o->id, id, MAX_DESCRIPTION_LENGTH);
STRNCPY(o->description, id, MAX_DESCRIPTION_LENGTH);
STRNCPY(o->targetName, "EPIC_PLAYER_KILLS", MAX_NAME_LENGTH);
o->targetValue = battle.epicKills;
o->targetType = TT_DESTROY;
o->active = 1;
}

View File

@ -432,7 +432,7 @@ static void preFireMissile(void)
} }
} }
void initPlayerSelect(void) static void initPlayerSelect(void)
{ {
Entity *e; Entity *e;
@ -440,7 +440,7 @@ void initPlayerSelect(void)
selectedPlayerIndex = 0; selectedPlayerIndex = 0;
if (battle.epicLives > 0 && --battle.epicLives > 0) if (battle.epicLives == 0 || (battle.epicLives > 0 && --battle.epicLives > 0))
{ {
for (e = battle.entityHead.next ; e != NULL ; e = e->next) for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{ {
@ -461,6 +461,11 @@ void initPlayerSelect(void)
{ {
battle.isEpic = 0; battle.isEpic = 0;
if (battle.epicKills > 0 && battle.stats[STAT_ENEMIES_KILLED_PLAYER] < battle.epicKills)
{
battle.unwinnable = 0;
}
failMission(); failMission();
} }
} }

View File

@ -421,12 +421,18 @@ static void loadEpicData(cJSON *node)
battle.epicFighterLimit = cJSON_GetObjectItem(node, "fighterLimit")->valueint; battle.epicFighterLimit = cJSON_GetObjectItem(node, "fighterLimit")->valueint;
battle.unlimitedEnemies = getJSONValue(node, "unlimitedEnemies", 0); battle.unlimitedEnemies = getJSONValue(node, "unlimitedEnemies", 0);
battle.epicLives = getJSONValue(node, "lives", 0); battle.epicLives = getJSONValue(node, "lives", 0);
battle.epicKills = getJSONValue(node, "kills", 0);
if (battle.epicLives > 0) if (battle.epicLives > 0)
{ {
addEpicLivesObjective(); addEpicLivesObjective();
} }
if (battle.epicKills != 0)
{
addEpicKillsObjective();
}
for (e = battle.entityHead.next ; e != NULL ; e = e->next) for (e = battle.entityHead.next ; e != NULL ; e = e->next)
{ {
if (e->active && e->type == ET_FIGHTER && numFighters[e->side]++ >= battle.epicFighterLimit) if (e->active && e->type == ET_FIGHTER && numFighters[e->side]++ >= battle.epicFighterLimit)

View File

@ -65,6 +65,7 @@ extern void awardPostMissionTrophies(void);
extern void awardCraftTrophy(void); extern void awardCraftTrophy(void);
extern void setInitialPlayerAngle(void); extern void setInitialPlayerAngle(void);
extern void addEpicLivesObjective(void); extern void addEpicLivesObjective(void);
extern void addEpicKillsObjective(void);
extern Battle battle; extern Battle battle;
extern Dev dev; extern Dev dev;

View File

@ -345,6 +345,7 @@ typedef struct {
int unlimitedEnemies; int unlimitedEnemies;
int epicFighterLimit; int epicFighterLimit;
int epicLives; int epicLives;
int epicKills;
int playerSelect; int playerSelect;
int manualComplete; int manualComplete;
int unwinnable; int unwinnable;