Waypoint challenge updates.

This commit is contained in:
Steve 2016-03-04 22:59:16 +00:00
parent 599c4fc338
commit 7979b175a2
9 changed files with 76 additions and 71 deletions

View File

@ -14,18 +14,19 @@
},
"challenge" : {
"waypointLimit" : 5,
"timeLimit" : 120,
"challenges" : [
{
"type" : "CHALLENGE_TIME",
"value" : 60
},
{
"type" : "CHALLENGE_TIME",
"value" : 90
"value" : 80
},
{
"type" : "CHALLENGE_TIME",
"value" : 120
},
{
"type" : "CHALLENGE_ARMOUR",
"value" : 100
}
]
},
@ -33,34 +34,46 @@
{
"groupName" : "RT1",
"types" : "Rocket Turret",
"x" : 35,
"y" : 15,
"x" : 30,
"y" : 30,
"side" : "SIDE_REBEL",
"active" : 0
"scatter" : 1000,
"number" : 2
},
{
"groupName" : "RT1",
"types" : "Rocket Turret",
"x" : 30,
"y" : 20,
"side" : "SIDE_REBEL",
"scatter" : 1000,
"number" : 2
},
{
"groupName" : "RT2",
"types" : "Rocket Turret",
"x" : 15,
"y" : 15,
"x" : 20,
"y" : 20,
"side" : "SIDE_REBEL",
"active" : 0
"scatter" : 1000,
"number" : 2
},
{
"groupName" : "RT3",
"types" : "Rocket Turret",
"x" : 15,
"y" : 35,
"x" : 20,
"y" : 30,
"side" : "SIDE_REBEL",
"active" : 0
}
"scatter" : 1000,
"number" : 2
},
{
"groupName" : "RT4",
"types" : "Rocket Turret",
"x" : 25,
"y" : 25,
"side" : "SIDE_REBEL",
"scatter" : 500,
"scatter" : 1000,
"number" : 2,
"active" : 0
}
@ -68,26 +81,26 @@
"entities" : [
{
"type" : "ET_WAYPOINT",
"x" : 35,
"y" : 35,
"x" : 30,
"y" : 30,
"active" : 0
},
{
"type" : "ET_WAYPOINT",
"x" : 35,
"y" : 15,
"x" : 30,
"y" : 20,
"active" : 0
},
{
"type" : "ET_WAYPOINT",
"x" : 15,
"y" : 15,
"x" : 20,
"y" : 20,
"active" : 0
},
{
"type" : "ET_WAYPOINT",
"x" : 15,
"y" : 35,
"x" : 20,
"y" : 30,
"active" : 0
},
{
@ -98,24 +111,6 @@
}
],
"script" : [
{
"function" : "Waypoint #1",
"lines" : [
"ACTIVATE_ENTITY_GROUPS RT1"
]
},
{
"function" : "Waypoint #2",
"lines" : [
"ACTIVATE_ENTITY_GROUPS RT2"
]
},
{
"function" : "Waypoint #3",
"lines" : [
"ACTIVATE_ENTITY_GROUPS RT3"
]
},
{
"function" : "Waypoint #4",
"lines" : [

View File

@ -67,6 +67,8 @@ static void think(void)
runScriptFunction(self->name);
activateNextWaypoint(self->id);
battle.stats[STAT_WAYPOINTS_VISITED]++;
}
}

View File

@ -32,6 +32,7 @@ static void updateChallenges(void);
static char *getFormattedChallengeDescription(const char *format, ...);
char *getChallengeDescription(Challenge *c);
static int hasFailedAllChallenges(void);
static int challengeFinished(void);
static void printStats(void);
static char descriptionBuffer[MAX_DESCRIPTION_LENGTH];
@ -54,7 +55,6 @@ void initChallenges(void)
challengeDescription[CHALLENGE_LOSSES] = _("Do not lose more than %d team mates");
challengeDescription[CHALLENGE_PLAYER_KILLS] = _("Take down %d enemy targets");
challengeDescription[CHALLENGE_DISABLE] = _("Disable %d or more enemy fighters");
challengeDescription[CHALLENGE_TIME_MINS] = _("Complete challenge in %d minutes or less");
tail = &game.challengeMissionHead;
@ -78,7 +78,7 @@ void doChallenges(void)
{
if (game.currentMission->challengeData.isChallenge && battle.status == MS_IN_PROGRESS)
{
if (game.currentMission->challengeData.timeLimit > 0 && battle.stats[STAT_TIME] >= game.currentMission->challengeData.timeLimit)
if (challengeFinished())
{
updateChallenges();
@ -91,17 +91,35 @@ void doChallenges(void)
completeChallenge();
}
}
/* disabled enemies count as killed during challenges - not player exclusive, but no need to worry about AI contributions here */
if (game.currentMission->challengeData.killLimit > 0 && (battle.stats[STAT_ENEMIES_KILLED_PLAYER] + battle.stats[STAT_ENEMIES_DISABLED]) >= game.currentMission->challengeData.killLimit)
{
updateChallenges();
completeChallenge();
}
}
}
static int challengeFinished(void)
{
if (game.currentMission->challengeData.timeLimit > 0 && battle.stats[STAT_TIME] >= game.currentMission->challengeData.timeLimit)
{
return 1;
}
/* disabled enemies count as killed during challenges - not player exclusive, but no need to worry about AI contributions here */
if (game.currentMission->challengeData.killLimit > 0 && (battle.stats[STAT_ENEMIES_KILLED_PLAYER] + battle.stats[STAT_ENEMIES_DISABLED]) >= game.currentMission->challengeData.killLimit)
{
return 1;
}
if (game.currentMission->challengeData.waypointLimit > 0 && battle.stats[STAT_WAYPOINTS_VISITED] >= game.currentMission->challengeData.waypointLimit)
{
return 1;
}
if (game.currentMission->challengeData.itemLimit > 0 && battle.stats[STAT_ITEMS_COLLECTED] >= game.currentMission->challengeData.itemLimit)
{
return 1;
}
return 0;
}
static int hasFailedAllChallenges(void)
{
int i;
@ -136,7 +154,6 @@ static void updateChallenges(void)
switch (c->type)
{
case CHALLENGE_TIME:
case CHALLENGE_TIME_MINS:
updateTimeChallenge(c);
break;
@ -195,21 +212,9 @@ static void printStats(void)
static void updateTimeChallenge(Challenge *c)
{
switch (c->type)
if (battle.stats[STAT_TIME] / FPS < c->value)
{
case CHALLENGE_TIME:
if (battle.stats[STAT_TIME] / FPS < c->value)
{
c->passed = 1;
}
break;
case CHALLENGE_TIME_MINS:
if ((battle.stats[STAT_TIME] / FPS) / 60 < c->value)
{
c->passed = 1;
}
break;
c->passed = 1;
}
}

View File

@ -30,6 +30,7 @@ extern char *getLookupName(char *prefix, long num);
extern char *timeToString(long millis, int showHours);
extern int getPercent(float current, float total);
extern void updateAccuracyStats(unsigned int *stats);
extern char *timeToString(long millis, int showHours);
extern Dev dev;
extern Battle battle;

View File

@ -287,7 +287,6 @@ enum
CHALLENGE_LOSSES,
CHALLENGE_PLAYER_KILLS,
CHALLENGE_DISABLE,
CHALLENGE_TIME_MINS,
CHALLENGE_MAX
};
@ -323,6 +322,7 @@ enum
STAT_SHUTTLE,
STAT_NUM_TOWED,
STAT_ITEMS_COLLECTED,
STAT_WAYPOINTS_VISITED,
STAT_EPIC_KILL_STREAK,
STAT_CAPITAL_SHIPS_DESTROYED,
STAT_CAPITAL_SHIPS_LOST,

View File

@ -76,8 +76,8 @@ Mission *loadMissionMeta(char *filename)
if (node)
{
mission->challengeData.isChallenge = 1;
mission->challengeData.timeLimit = getJSONValue(node, "timeLimit", 0);
mission->challengeData.timeLimit = getJSONValue(node, "timeLimit", 0) * FPS;
mission->challengeData.killLimit = getJSONValue(node, "killLimit", 0);
mission->challengeData.waypointLimit = getJSONValue(node, "waypointLimit", 0);
mission->challengeData.noMissiles = getJSONValue(node, "noMissiles", 0);

View File

@ -64,6 +64,7 @@ void initStats(void)
statDescription[STAT_NUM_TOWED] = _("Craft Towed");
statDescription[STAT_ITEMS_COLLECTED] = _("Items Collected");
statDescription[STAT_EPIC_KILL_STREAK] = _("Longest Epic Kill Streak");
statDescription[STAT_WAYPOINTS_VISITED] = _("Waypoints Visited");
statDescription[STAT_CAPITAL_SHIPS_DESTROYED] = _("Capital Ships Destroyed");
statDescription[STAT_CAPITAL_SHIPS_LOST] = _("Capital Ships Lost");
statDescription[STAT_TIME] = _("Time Played");

View File

@ -247,6 +247,7 @@ typedef struct {
int killLimit;
int lossLimit;
int itemLimit;
int waypointLimit;
int noMissiles;
int noBoost;
int noECM;

View File

@ -130,7 +130,6 @@ void initLookups(void)
addLookup("CHALLENGE_LOSSES", CHALLENGE_LOSSES);
addLookup("CHALLENGE_PLAYER_KILLS", CHALLENGE_PLAYER_KILLS);
addLookup("CHALLENGE_DISABLE", CHALLENGE_DISABLE);
addLookup("CHALLENGE_TIME_MINS", CHALLENGE_TIME_MINS);
addLookup("STAT_PERCENT_COMPLETE", STAT_PERCENT_COMPLETE);
addLookup("STAT_MISSIONS_STARTED", STAT_MISSIONS_STARTED);
@ -162,6 +161,7 @@ void initLookups(void)
addLookup("STAT_SHUTTLE", STAT_SHUTTLE);
addLookup("STAT_NUM_TOWED", STAT_NUM_TOWED);
addLookup("STAT_ITEMS_COLLECTED", STAT_ITEMS_COLLECTED);
addLookup("STAT_WAYPOINTS_VISITED", STAT_WAYPOINTS_VISITED);
addLookup("STAT_EPIC_KILL_STREAK", STAT_EPIC_KILL_STREAK);
addLookup("STAT_CAPITAL_SHIPS_DESTROYED", STAT_CAPITAL_SHIPS_DESTROYED);
addLookup("STAT_CAPITAL_SHIPS_LOST", STAT_CAPITAL_SHIPS_LOST);