Start of lives restriction for epic battles.

This commit is contained in:
Steve 2016-08-20 11:42:10 +01:00
parent b08006aea2
commit 27427a8637
7 changed files with 50 additions and 5 deletions

View File

@ -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
{

View File

@ -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;
}

View File

@ -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;
}
}
}

View File

@ -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;

View File

@ -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)
{

View File

@ -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;

View File

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