Accuracy for rockets and missiles, not just shots.
This commit is contained in:
parent
2f168c2559
commit
d5d5169078
|
@ -25,7 +25,7 @@
|
|||
"value" : 120
|
||||
},
|
||||
{
|
||||
"type" : "CHALLENGE_ACCURACY",
|
||||
"type" : "CHALLENGE_SHOT_ACCURACY",
|
||||
"value" : 80
|
||||
}
|
||||
]
|
||||
|
|
|
@ -368,6 +368,8 @@ static void postBattle(void)
|
|||
}
|
||||
}
|
||||
|
||||
updateAccuracyStats(game.stats);
|
||||
|
||||
if (!game.currentMission->challengeData.isChallenge)
|
||||
{
|
||||
if (game.currentMission && !game.currentMission->completed)
|
||||
|
|
|
@ -82,6 +82,7 @@ extern void destroyDebris(void);
|
|||
extern void destroyBullets(void);
|
||||
extern void destroyEffects(void);
|
||||
extern void initChallengeHome(void);
|
||||
extern void updateAccuracyStats(unsigned int *stats);
|
||||
|
||||
extern App app;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -169,6 +169,8 @@ static void drawChallenges(void)
|
|||
{
|
||||
c = game.currentMission->challengeData.challenges[i];
|
||||
|
||||
if (c)
|
||||
{
|
||||
y += 50;
|
||||
|
||||
color = colors.white;
|
||||
|
@ -191,5 +193,6 @@ static void drawChallenges(void)
|
|||
drawText(SCREEN_WIDTH / 2 - 50, y, 22, TA_RIGHT, colors.white, "%s", getChallengeDescription(c));
|
||||
drawText(SCREEN_WIDTH / 2 + 50, y, 22, TA_LEFT, color, challengeStatus);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -45,7 +45,9 @@ void initChallenges(void)
|
|||
|
||||
challengeDescription[CHALLENGE_ARMOUR] = _("Retain at least %d%% armour");
|
||||
challengeDescription[CHALLENGE_TIME] = _("Complete challenge in %d seconds or less");
|
||||
challengeDescription[CHALLENGE_ACCURACY] = _("Attain a %d%% hit accuracy");
|
||||
challengeDescription[CHALLENGE_SHOT_ACCURACY] = _("Attain a %d%% shot hit accuracy");
|
||||
challengeDescription[CHALLENGE_ROCKET_ACCURACY] = _("Attain a %d%% rocket hit accuracy");
|
||||
challengeDescription[CHALLENGE_MISSILE_ACCURACY] = _("Attain a %d%% missile hit accuracy");
|
||||
challengeDescription[CHALLENGE_NO_LOSSES] = _("Do not lose any team mates");
|
||||
challengeDescription[CHALLENGE_1_LOSS] = _("Do not lose more than 1 team mate");
|
||||
challengeDescription[CHALLENGE_LOSSES] = _("Do not lose more than %d team mates");
|
||||
|
@ -97,11 +99,13 @@ static void updateChallenges(void)
|
|||
int i;
|
||||
Challenge *c;
|
||||
|
||||
updateAccuracyStats(battle.stats);
|
||||
|
||||
for (i = 0 ; i < MAX_CHALLENGES ; i++)
|
||||
{
|
||||
c = game.currentMission->challengeData.challenges[i];
|
||||
|
||||
if (!c->passed)
|
||||
if (c && !c->passed)
|
||||
{
|
||||
switch (c->type)
|
||||
{
|
||||
|
@ -110,7 +114,9 @@ static void updateChallenges(void)
|
|||
updateTimeChallenge(c);
|
||||
break;
|
||||
|
||||
case CHALLENGE_ACCURACY:
|
||||
case CHALLENGE_SHOT_ACCURACY:
|
||||
case CHALLENGE_ROCKET_ACCURACY:
|
||||
case CHALLENGE_MISSILE_ACCURACY:
|
||||
updateAccuracyChallenge(c);
|
||||
break;
|
||||
|
||||
|
@ -159,8 +165,6 @@ static void printStats(void)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
printf("DEBUG: Accuracy=%d\n", getPercent(battle.stats[STAT_SHOTS_FIRED], battle.stats[STAT_SHOTS_HIT]));
|
||||
}
|
||||
|
||||
static void updateTimeChallenge(Challenge *c)
|
||||
|
@ -187,9 +191,24 @@ static void updateAccuracyChallenge(Challenge *c)
|
|||
{
|
||||
float percent;
|
||||
|
||||
percent = battle.stats[STAT_SHOTS_HIT];
|
||||
percent /= battle.stats[STAT_SHOTS_FIRED];
|
||||
percent *= 100;
|
||||
switch (c->type)
|
||||
{
|
||||
case CHALLENGE_SHOT_ACCURACY:
|
||||
percent = battle.stats[STAT_SHOT_ACCURACY];
|
||||
break;
|
||||
|
||||
case CHALLENGE_ROCKET_ACCURACY:
|
||||
percent = battle.stats[STAT_ROCKET_ACCURACY];
|
||||
break;
|
||||
|
||||
case CHALLENGE_MISSILE_ACCURACY:
|
||||
percent = battle.stats[STAT_MISSILE_ACCURACY];
|
||||
break;
|
||||
|
||||
default:
|
||||
percent = 0;
|
||||
break;
|
||||
}
|
||||
|
||||
if (percent >= c->value)
|
||||
{
|
||||
|
|
|
@ -30,6 +30,7 @@ extern char *getFileLocation(char *filename);
|
|||
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 Dev dev;
|
||||
extern Battle battle;
|
||||
|
|
|
@ -257,7 +257,9 @@ enum
|
|||
{
|
||||
CHALLENGE_ARMOUR,
|
||||
CHALLENGE_TIME,
|
||||
CHALLENGE_ACCURACY,
|
||||
CHALLENGE_SHOT_ACCURACY,
|
||||
CHALLENGE_ROCKET_ACCURACY,
|
||||
CHALLENGE_MISSILE_ACCURACY,
|
||||
CHALLENGE_NO_LOSSES,
|
||||
CHALLENGE_1_LOSS,
|
||||
CHALLENGE_LOSSES,
|
||||
|
@ -276,10 +278,13 @@ enum
|
|||
STAT_CHALLENGES_COMPLETED,
|
||||
STAT_SHOTS_FIRED,
|
||||
STAT_SHOTS_HIT,
|
||||
STAT_SHOT_ACCURACY,
|
||||
STAT_ROCKETS_FIRED,
|
||||
STAT_ROCKETS_HIT,
|
||||
STAT_ROCKET_ACCURACY,
|
||||
STAT_MISSILES_FIRED,
|
||||
STAT_MISSILES_HIT,
|
||||
STAT_MISSILE_ACCURACY,
|
||||
STAT_ENEMIES_KILLED,
|
||||
STAT_ENEMIES_KILLED_PLAYER,
|
||||
STAT_ALLIES_KILLED,
|
||||
|
|
|
@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
static void prevPage(void);
|
||||
static void nextPage(void);
|
||||
static void calculatePercentComplete(void);
|
||||
void updateAccuracyStats(unsigned int *stats);
|
||||
|
||||
static char *statDescription[STAT_MAX];
|
||||
|
||||
static int page;
|
||||
static float maxPages;
|
||||
static Widget *prev;
|
||||
|
@ -40,10 +40,13 @@ void initStats(void)
|
|||
statDescription[STAT_CHALLENGES_COMPLETED] = _("Challenges Completed");
|
||||
statDescription[STAT_SHOTS_FIRED] = _("Shots Fired");
|
||||
statDescription[STAT_SHOTS_HIT] = _("Shots Hit");
|
||||
statDescription[STAT_SHOT_ACCURACY] = _("Accuracy");
|
||||
statDescription[STAT_ROCKETS_FIRED] = _("Rockets Fired");
|
||||
statDescription[STAT_ROCKETS_HIT] = _("Rockets Hit");
|
||||
statDescription[STAT_ROCKET_ACCURACY] = _("Accuracy");
|
||||
statDescription[STAT_MISSILES_FIRED] = _("Missiles Fired");
|
||||
statDescription[STAT_MISSILES_HIT] = _("Missiles Hit");
|
||||
statDescription[STAT_MISSILE_ACCURACY] = _("Accuracy");
|
||||
statDescription[STAT_ENEMIES_KILLED] = _("Enemies Killed");
|
||||
statDescription[STAT_ENEMIES_KILLED_PLAYER] = _("Enemies Killed (Player)");
|
||||
statDescription[STAT_ALLIES_KILLED] = _("Allies Killed");
|
||||
|
@ -82,6 +85,8 @@ void initStatsDisplay(void)
|
|||
next->action = nextPage;
|
||||
|
||||
calculatePercentComplete();
|
||||
|
||||
updateAccuracyStats(game.stats);
|
||||
}
|
||||
|
||||
static void calculatePercentComplete(void)
|
||||
|
@ -144,13 +149,18 @@ void drawStats(void)
|
|||
{
|
||||
drawText(r.x + 20, y, 18, TA_LEFT, colors.white, statDescription[i]);
|
||||
|
||||
if (i == STAT_PERCENT_COMPLETE)
|
||||
switch (i)
|
||||
{
|
||||
case STAT_PERCENT_COMPLETE:
|
||||
case STAT_SHOT_ACCURACY:
|
||||
case STAT_ROCKET_ACCURACY:
|
||||
case STAT_MISSILE_ACCURACY:
|
||||
drawText(r.x + r.w - 20, y, 18, TA_RIGHT, colors.white, "%d%%", game.stats[i]);
|
||||
}
|
||||
else
|
||||
{
|
||||
break;
|
||||
|
||||
default:
|
||||
drawText(r.x + r.w - 20, y, 18, TA_RIGHT, colors.white, "%d", game.stats[i]);
|
||||
break;
|
||||
}
|
||||
|
||||
y += 40;
|
||||
|
@ -178,3 +188,10 @@ static void prevPage(void)
|
|||
next->visible = 1;
|
||||
prev->visible = page > 0;
|
||||
}
|
||||
|
||||
void updateAccuracyStats(unsigned int *stats)
|
||||
{
|
||||
stats[STAT_SHOT_ACCURACY] = getPercent(stats[STAT_SHOTS_HIT], stats[STAT_SHOTS_FIRED]);
|
||||
stats[STAT_ROCKET_ACCURACY] = getPercent(stats[STAT_ROCKETS_HIT], stats[STAT_ROCKETS_FIRED]);
|
||||
stats[STAT_MISSILE_ACCURACY] = getPercent(stats[STAT_MISSILES_HIT], stats[STAT_MISSILES_FIRED]);
|
||||
}
|
||||
|
|
|
@ -108,7 +108,9 @@ void initLookups(void)
|
|||
|
||||
addLookup("CHALLENGE_ARMOUR", CHALLENGE_ARMOUR);
|
||||
addLookup("CHALLENGE_TIME", CHALLENGE_TIME);
|
||||
addLookup("CHALLENGE_ACCURACY", CHALLENGE_ACCURACY);
|
||||
addLookup("CHALLENGE_SHOT_ACCURACY", CHALLENGE_SHOT_ACCURACY);
|
||||
addLookup("CHALLENGE_ROCKET_ACCURACY", CHALLENGE_ROCKET_ACCURACY);
|
||||
addLookup("CHALLENGE_MISSILE_ACCURACY", CHALLENGE_MISSILE_ACCURACY);
|
||||
addLookup("CHALLENGE_NO_LOSSES", CHALLENGE_NO_LOSSES);
|
||||
addLookup("CHALLENGE_1_LOSS", CHALLENGE_1_LOSS);
|
||||
addLookup("CHALLENGE_LOSSES", CHALLENGE_LOSSES);
|
||||
|
@ -123,10 +125,13 @@ void initLookups(void)
|
|||
addLookup("STAT_CHALLENGES_COMPLETED", STAT_CHALLENGES_COMPLETED);
|
||||
addLookup("STAT_SHOTS_FIRED", STAT_SHOTS_FIRED);
|
||||
addLookup("STAT_SHOTS_HIT", STAT_SHOTS_HIT);
|
||||
addLookup("STAT_SHOT_ACCURACY", STAT_SHOT_ACCURACY);
|
||||
addLookup("STAT_ROCKETS_FIRED", STAT_ROCKETS_FIRED);
|
||||
addLookup("STAT_ROCKETS_HIT", STAT_ROCKETS_HIT);
|
||||
addLookup("STAT_ROCKET_ACCURACY", STAT_ROCKET_ACCURACY);
|
||||
addLookup("STAT_MISSILES_FIRED", STAT_MISSILES_FIRED);
|
||||
addLookup("STAT_MISSILES_HIT", STAT_MISSILES_HIT);
|
||||
addLookup("STAT_MISSILE_ACCURACY", STAT_MISSILE_ACCURACY);
|
||||
addLookup("STAT_ENEMIES_KILLED", STAT_ENEMIES_KILLED);
|
||||
addLookup("STAT_ENEMIES_KILLED_PLAYER", STAT_ENEMIES_KILLED_PLAYER);
|
||||
addLookup("STAT_ALLIES_KILLED", STAT_ALLIES_KILLED);
|
||||
|
|
Loading…
Reference in New Issue