Added new stats.
This commit is contained in:
parent
5964162971
commit
a9dc374d40
|
@ -310,10 +310,12 @@ static void postBattle(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
/* we don't want to count the time when adding up stats */
|
||||
for (i = 0 ; i < STAT_TIME ; i++)
|
||||
for (i = 0 ; i < STAT_MAX ; i++)
|
||||
{
|
||||
game.stats[i] += battle.stats[i];
|
||||
if (i != STAT_TIME && i != STAT_EPIC_KILL_STREAK)
|
||||
{
|
||||
game.stats[i] += battle.stats[i];
|
||||
}
|
||||
}
|
||||
|
||||
if (game.currentMission && !game.currentMission->completed)
|
||||
|
|
|
@ -89,6 +89,12 @@ void doBullets(void)
|
|||
|
||||
if (--b->life <= 0)
|
||||
{
|
||||
|
||||
if (player != NULL && player->alive == ALIVE_ALIVE && b->type == BT_MISSILE && b->damage > 0 && b->target == player)
|
||||
{
|
||||
battle.stats[STAT_MISSILES_EVADED]++;
|
||||
}
|
||||
|
||||
if (b == battle.bulletTail)
|
||||
{
|
||||
battle.bulletTail = prev;
|
||||
|
@ -140,16 +146,23 @@ static void checkCollisions(Bullet *b)
|
|||
damageFighter(e, b->damage, b->flags);
|
||||
|
||||
b->life = 0;
|
||||
b->damage = 0;
|
||||
|
||||
if (b->flags & BF_EXPLODES)
|
||||
{
|
||||
addMissileExplosion(b);
|
||||
|
||||
if (e == player)
|
||||
{
|
||||
battle.stats[STAT_MISSILES_STRUCK]++;
|
||||
}
|
||||
}
|
||||
|
||||
/* assuming that health <= 0 will always mean killed */
|
||||
if (e->health <= 0 && b->owner == player)
|
||||
{
|
||||
battle.stats[STAT_ENEMIES_KILLED_PLAYER]++;
|
||||
battle.stats[STAT_EPIC_KILL_STREAK]++;
|
||||
}
|
||||
|
||||
if (b->owner == player && b->type == BT_MISSILE)
|
||||
|
|
|
@ -152,7 +152,7 @@ static void updateDisabledChallenge(Challenge *c)
|
|||
{
|
||||
if (!c->passed)
|
||||
{
|
||||
c->passed = battle.stats[STAT_DISABLED] >= c->targetValue;
|
||||
c->passed = battle.stats[STAT_ENEMIES_DISABLED] >= c->targetValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -211,7 +211,7 @@ void doFighter(void)
|
|||
{
|
||||
self->flags |= EF_DISABLED;
|
||||
updateObjective(self->name, TT_DISABLE);
|
||||
battle.stats[STAT_DISABLED]++;
|
||||
battle.stats[STAT_ENEMIES_DISABLED]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -223,9 +223,9 @@ void doFighter(void)
|
|||
addHudMessage(colors.red, "Mission target has escaped.");
|
||||
battle.stats[STAT_ENEMIES_ESCAPED]++;
|
||||
}
|
||||
else
|
||||
else if (self->flags & EF_CIVILIAN)
|
||||
{
|
||||
battle.stats[STAT_ALLIES_ESCAPED]++;
|
||||
battle.stats[STAT_CIVILIANS_RESCUED]++;
|
||||
}
|
||||
|
||||
updateObjective(self->name, TT_ESCAPED);
|
||||
|
@ -251,15 +251,18 @@ void doFighter(void)
|
|||
}
|
||||
else
|
||||
{
|
||||
battle.stats[STAT_ALLIES_KILLED]++;
|
||||
|
||||
if (!battle.epic)
|
||||
if (self->flags & EF_CIVILIAN)
|
||||
{
|
||||
if (self->flags & EF_CIVILIAN)
|
||||
battle.stats[STAT_CIVILIANS_KILLED]++;
|
||||
if (!battle.epic)
|
||||
{
|
||||
addHudMessage(colors.red, "Civilian has been killed");
|
||||
}
|
||||
else
|
||||
}
|
||||
else
|
||||
{
|
||||
battle.stats[STAT_ALLIES_KILLED]++;
|
||||
if (!battle.epic)
|
||||
{
|
||||
addHudMessage(colors.red, "Ally has been killed");
|
||||
}
|
||||
|
|
|
@ -107,12 +107,17 @@ static void action(void)
|
|||
if ((e->flags & EF_COLLECTS_ITEMS) && collision(self->x - (self->w / 2), self->y - (self->h / 2), self->w, self->h, e->x - (e->w / 2), e->y - (e->h / 2), e->w, e->h))
|
||||
{
|
||||
self->alive = ALIVE_DEAD;
|
||||
playSound(SND_GET_ITEM);
|
||||
addHudMessage(colors.white, "Picked up %s", self->name);
|
||||
playBattleSound(SND_GET_ITEM, self->x, self->y);
|
||||
|
||||
updateObjective(self->name, TT_ITEM);
|
||||
|
||||
checkTrigger(self->name, TRIGGER_ITEM);
|
||||
|
||||
if (e == player)
|
||||
{
|
||||
addHudMessage(colors.white, "Picked up %s", self->name);
|
||||
battle.stats[STAT_ITEMS_COLLECTED]++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,10 +31,12 @@ extern long flagsToLong(char *flags);
|
|||
extern Entity *spawnEntity(void);
|
||||
extern Entity **getAllEntsWithin(int x, int y, int w, int h, Entity *ignore);
|
||||
extern int collision(int x1, int y1, int w1, int h1, int x2, int y2, int w2, int h2);
|
||||
extern void playSound(int id);
|
||||
extern void playBattleSound(int id, int x, int y);
|
||||
extern void addHudMessage(SDL_Color c, char *format, ...);
|
||||
extern void updateObjective(char *name, int type);
|
||||
extern void checkTrigger(char *name, int type);
|
||||
|
||||
extern Battle battle;
|
||||
extern Entity *self;
|
||||
extern Entity *player;
|
||||
extern Colors colors;
|
||||
|
|
|
@ -62,6 +62,10 @@ void initPlayer(void)
|
|||
|
||||
battle.boostTimer = BOOST_RECHARGE_TIME;
|
||||
battle.ecmTimer = ECM_RECHARGE_TIME;
|
||||
|
||||
game.stats[STAT_EPIC_KILL_STREAK] = MAX(game.stats[STAT_EPIC_KILL_STREAK], battle.stats[STAT_EPIC_KILL_STREAK]);
|
||||
|
||||
battle.stats[STAT_EPIC_KILL_STREAK] = 0;
|
||||
}
|
||||
|
||||
void doPlayer(void)
|
||||
|
@ -246,6 +250,8 @@ static void activateBoost(void)
|
|||
self->thrust = sqrt((self->dx * self->dx) + (self->dy * self->dy));
|
||||
|
||||
battle.boostTimer = 0;
|
||||
|
||||
battle.stats[STAT_BOOST]++;
|
||||
}
|
||||
|
||||
static void deactivateBoost(void)
|
||||
|
@ -268,6 +274,8 @@ static void deactivateBoost(void)
|
|||
static void activateECM(void)
|
||||
{
|
||||
battle.ecmTimer = 0;
|
||||
|
||||
battle.stats[STAT_ECM]++;
|
||||
}
|
||||
|
||||
static void switchGuns(void)
|
||||
|
|
|
@ -40,3 +40,4 @@ extern Battle battle;
|
|||
extern Colors colors;
|
||||
extern Entity *player;
|
||||
extern Entity *self;
|
||||
extern Game game;
|
||||
|
|
|
@ -39,7 +39,12 @@ void attachRope(void)
|
|||
{
|
||||
self->towing = e;
|
||||
e->owner = self;
|
||||
addHudMessage(colors.white, "Tow rope attached");
|
||||
|
||||
if (self == player)
|
||||
{
|
||||
battle.stats[STAT_NUM_TOWED]++;
|
||||
addHudMessage(colors.white, "Tow rope attached");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,3 +34,4 @@ extern App app;
|
|||
extern Battle battle;
|
||||
extern Colors colors;
|
||||
extern Entity *self;
|
||||
extern Entity *player;
|
||||
|
|
16
src/defs.h
16
src/defs.h
|
@ -108,6 +108,7 @@ enum
|
|||
{
|
||||
SIDE_NONE,
|
||||
SIDE_ALLIES,
|
||||
SIDE_REBEL,
|
||||
SIDE_PANDORAN,
|
||||
SIDE_PIRATE,
|
||||
SIDE_CSN,
|
||||
|
@ -241,9 +242,20 @@ enum
|
|||
STAT_ENEMIES_KILLED_PLAYER,
|
||||
STAT_ALLIES_KILLED,
|
||||
STAT_PLAYER_KILLED,
|
||||
STAT_DISABLED,
|
||||
STAT_ENEMIES_DISABLED,
|
||||
STAT_ENEMIES_ESCAPED,
|
||||
STAT_ALLIES_ESCAPED,
|
||||
STAT_ECM,
|
||||
STAT_BOOST,
|
||||
STAT_MISSILES_EVADED,
|
||||
STAT_MISSILES_STRUCK,
|
||||
STAT_CIVILIANS_RESCUED,
|
||||
STAT_CIVILIANS_KILLED,
|
||||
STAT_TUG,
|
||||
STAT_SHUTTLE,
|
||||
STAT_NUM_TOWED,
|
||||
STAT_ITEMS_COLLECTED,
|
||||
STAT_EPIC_KILL_STREAK,
|
||||
/* add stats before here, so as not to mess up the stats screen */
|
||||
STAT_TIME,
|
||||
STAT_MAX
|
||||
};
|
||||
|
|
|
@ -422,8 +422,8 @@ static void drawInfoBars(void)
|
|||
SDL_RenderFillRect(app.renderer, &r);
|
||||
SDL_SetRenderDrawBlendMode(app.renderer, SDL_BLENDMODE_NONE);
|
||||
|
||||
drawText((SCREEN_WIDTH / 2) - 50, 5, 18, TA_RIGHT, colors.white, "Missions %d / %d", completedMissions, totalMissions);
|
||||
drawText((SCREEN_WIDTH / 2) + 50, 5, 18, TA_LEFT, colors.white, "Challenges %d / %d", completedChallenges, totalChallenges);
|
||||
drawText((SCREEN_WIDTH / 2) - 50, 5, 18, TA_RIGHT, colors.white, "Missions: %d / %d", completedMissions, totalMissions);
|
||||
drawText((SCREEN_WIDTH / 2) + 50, 5, 18, TA_LEFT, colors.white, "Challenges: %d / %d", completedChallenges, totalChallenges);
|
||||
}
|
||||
|
||||
static void selectStarSystem(void)
|
||||
|
|
|
@ -210,6 +210,16 @@ static void loadPlayer(cJSON *node)
|
|||
player = spawnFighter(type, 0, 0, side);
|
||||
player->x = (GRID_SIZE * GRID_CELL_WIDTH) / 2;
|
||||
player->y = (GRID_SIZE * GRID_CELL_HEIGHT) / 2;
|
||||
|
||||
if (strcmp(type, "Tug") == 0)
|
||||
{
|
||||
battle.stats[STAT_TUG]++;
|
||||
}
|
||||
|
||||
if (strcmp(type, "Shuttle") == 0)
|
||||
{
|
||||
battle.stats[STAT_SHUTTLE]++;
|
||||
}
|
||||
}
|
||||
|
||||
static void loadFighters(cJSON *node)
|
||||
|
|
|
@ -33,7 +33,17 @@ static char *statDescription[] = {
|
|||
"Times Killed",
|
||||
"Enemies Disabled",
|
||||
"Enemies Escaped",
|
||||
"Allies Escaped",
|
||||
"ECM Used",
|
||||
"Boost Used",
|
||||
"Missiles Evaded",
|
||||
"Missiles Struck Player",
|
||||
"Civilians Rescued",
|
||||
"Civilians Killed",
|
||||
"Times used Tug",
|
||||
"Times used Shuttle",
|
||||
"Craft Towed",
|
||||
"Items Collected",
|
||||
"Longest Epic Kill Streak",
|
||||
"STAT_TIME"
|
||||
};
|
||||
|
||||
|
|
|
@ -101,9 +101,19 @@ void initLookups(void)
|
|||
addLookup("STAT_ENEMIES_KILLED_PLAYER", STAT_ENEMIES_KILLED_PLAYER);
|
||||
addLookup("STAT_ALLIES_KILLED", STAT_ALLIES_KILLED);
|
||||
addLookup("STAT_PLAYER_KILLED", STAT_PLAYER_KILLED);
|
||||
addLookup("STAT_DISABLED", STAT_DISABLED);
|
||||
addLookup("STAT_ENEMIES_DISABLED", STAT_ENEMIES_DISABLED);
|
||||
addLookup("STAT_ENEMIES_ESCAPED", STAT_ENEMIES_ESCAPED);
|
||||
addLookup("STAT_ALLIES_ESCAPED", STAT_ALLIES_ESCAPED);
|
||||
addLookup("STAT_CIVILIANS_RESCUED", STAT_CIVILIANS_RESCUED);
|
||||
addLookup("STAT_ECM", STAT_ECM);
|
||||
addLookup("STAT_BOOST", STAT_BOOST);
|
||||
addLookup("STAT_MISSILES_EVADED", STAT_MISSILES_EVADED);
|
||||
addLookup("STAT_MISSILES_STRUCK", STAT_MISSILES_STRUCK);
|
||||
addLookup("STAT_CIVILIANS_KILLED", STAT_CIVILIANS_KILLED);
|
||||
addLookup("STAT_TUG", STAT_TUG);
|
||||
addLookup("STAT_SHUTTLE", STAT_SHUTTLE);
|
||||
addLookup("STAT_NUM_TOWED", STAT_NUM_TOWED);
|
||||
addLookup("STAT_ITEMS_COLLECTED", STAT_ITEMS_COLLECTED);
|
||||
addLookup("STAT_EPIC_KILL_STREAK", STAT_EPIC_KILL_STREAK);
|
||||
addLookup("STAT_TIME", STAT_TIME);
|
||||
|
||||
addLookup("TRIGGER_TIME", TRIGGER_TIME);
|
||||
|
|
Loading…
Reference in New Issue