Added Waypoint challenge type.

This commit is contained in:
Steve 2016-06-01 09:32:10 +01:00
parent f88c8dd156
commit 0cd73db62e
4 changed files with 25 additions and 0 deletions

View File

@ -476,6 +476,10 @@ static void drawObjectives(void)
{
drawText(SCREEN_WIDTH / 2, 35, 14, TA_CENTER, colors.white, "%d / %d", battle.stats[STAT_ENEMIES_SURRENDERED], game.currentMission->challengeData.surrenderLimit);
}
else if (game.currentMission->challengeData.waypointLimit)
{
drawText(SCREEN_WIDTH / 2, 35, 14, TA_CENTER, colors.white, "%d / %d", battle.stats[STAT_WAYPOINTS_VISITED], game.currentMission->challengeData.waypointLimit);
}
else if (player->flags & EF_MUST_DISABLE)
{
drawText(SCREEN_WIDTH / 2, 35, 14, TA_CENTER, colors.white, _("System Power : %d%%"), player->systemPower);

View File

@ -29,6 +29,7 @@ static void updatePlayerKillsChallenge(Challenge *c);
static void updateDisabledChallenge(Challenge *c);
static void updateItemsChallenge(Challenge *c);
static void updateSurrenderChallenge(Challenge *c);
static void updateWaypointChallenge(Challenge *c);
static void completeChallenge(void);
static void failChallenge(void);
static int updateChallenges(void);
@ -63,6 +64,7 @@ void initChallenges(void)
challengeDescription[CHALLENGE_PLAYER_ITEMS] = _("Collect %d packages");
challengeDescription[CHALLENGE_RESCUE] = _("Rescue %d civilians");
challengeDescription[CHALLENGE_SURRENDER] = _("Cause %d enemies to surrender");
challengeDescription[CHALLENGE_WAYPOINTS] = _("Reach %d waypoints");
tail = &game.challengeMissionHead;
@ -216,6 +218,11 @@ static int challengeFinished(void)
return 1;
}
if (game.currentMission->challengeData.waypointLimit > 0 && (battle.stats[STAT_WAYPOINTS_VISITED]) >= game.currentMission->challengeData.waypointLimit)
{
return 1;
}
if (game.currentMission->challengeData.eliminateThreats && !battle.hasThreats)
{
return 1;
@ -283,6 +290,10 @@ static int updateChallenges(void)
case CHALLENGE_SURRENDER:
updateSurrenderChallenge(c);
break;
case CHALLENGE_WAYPOINTS:
updateWaypointChallenge(c);
break;
}
}
@ -427,6 +438,14 @@ static void updateSurrenderChallenge(Challenge *c)
}
}
static void updateWaypointChallenge(Challenge *c)
{
if (!c->passed)
{
c->passed = battle.stats[STAT_WAYPOINTS_VISITED] >= c->value;
}
}
char *getChallengeDescription(Challenge *c)
{
if (c->type == CHALLENGE_TIME)

View File

@ -338,6 +338,7 @@ enum
CHALLENGE_RESCUE,
CHALLENGE_SURVIVE,
CHALLENGE_SURRENDER,
CHALLENGE_WAYPOINTS,
CHALLENGE_MAX
};

View File

@ -158,6 +158,7 @@ void initLookups(void)
addLookup("CHALLENGE_PLAYER_ITEMS", CHALLENGE_PLAYER_ITEMS);
addLookup("CHALLENGE_RESCUE", CHALLENGE_RESCUE);
addLookup("CHALLENGE_SURRENDER", CHALLENGE_SURRENDER);
addLookup("CHALLENGE_WAYPOINTS", CHALLENGE_WAYPOINTS);
addLookup("STAT_PERCENT_COMPLETE", STAT_PERCENT_COMPLETE);
addLookup("STAT_MISSIONS_STARTED", STAT_MISSIONS_STARTED);