Stats updates. Start of trophy code.

This commit is contained in:
Steve 2018-02-13 21:36:42 +00:00
parent 81910dadf4
commit ea323685c9
36 changed files with 122 additions and 88 deletions

View File

@ -48,7 +48,7 @@ _OBJS += particles.o player.o plasmaBlob.o plasmaDroid.o pistolBlob.o pistolDroi
_OBJS += quadtree.o
_OBJS += radar.o
_OBJS += shotgunBlob.o shotgunDroid.o sound.o spreadGunBlob.o spreadGunDroid.o sprites.o structures.o
_OBJS += tankCommander.o tankTrack.o teeka.o teleporter.o text.o textures.o title.o transition.o triggers.o
_OBJS += tankCommander.o tankTrack.o teeka.o teleporter.o text.o textures.o title.o transition.o triggers.o trophies.o
_OBJS += unit.o util.o
_OBJS += weapons.o weaponPickup.o widgets.o world.o worldLoader.o worldSaver.o

View File

@ -321,3 +321,25 @@ enum
WT_SPINNER,
WT_PLAIN_BUTTON
};
enum
{
STAT_KEYS_FOUND,
STAT_CELLS_FOUND,
STAT_HEARTS_FOUND,
STAT_DEATHS,
STAT_SHOTS_FIRED,
STAT_SHOTS_HIT,
STAT_EYE_DROID_EXPLOSION_KILLS,
STAT_FLY_TIME,
STAT_SWIM_TIME,
STAT_CHERRIES_PICKED_UP,
STAT_BATTERIES_PICKED_UP,
STAT_WEAPONS_PICKED_UP,
STAT_ENEMIES_KILLED,
STAT_TARGETS_DEFEATED,
STAT_MIAS_RESCUED,
STAT_MISSIONS_PLAYED,
STAT_TIME_PLAYED,
STAT_MAX
};

View File

@ -116,7 +116,6 @@ static void tick(void)
world.bob->health = world.bob->healthMax;
}
/*
if (world.isTrainingMission)
{
world.bob->power = MIN(world.bob->power + 0.01, world.bob->powerMax);
@ -125,7 +124,6 @@ static void tick(void)
{
world.bob->power = MIN(world.bob->power + 0.00065, world.bob->powerMax);
}
*/
if (dev.cheatPower)
{
@ -370,7 +368,7 @@ static void doDying(void)
playSound(SND_SPLAT, CH_BOB);
game.deaths++;
game.stats[STAT_DEATHS]++;
}
}
@ -497,6 +495,8 @@ static void bobSwim(void)
activate(1);
clearControl(CONTROL_JETPACK);
}
game.stats[STAT_SWIM_TIME]++;
}
static void bobFly(void)
@ -536,6 +536,8 @@ static void bobFly(void)
world.bob->dx = MIN(FLY_SPEED, MAX(world.bob->dx, -FLY_SPEED));
world.bob->dy = MIN(FLY_SPEED, MAX(world.bob->dy, -FLY_SPEED));
game.stats[STAT_FLY_TIME]++;
}
static void fireWeapon(void)
@ -550,7 +552,6 @@ static void fireWeapon(void)
break;
case WPN_SPREAD:
fireSpread((Entity*)world.bob, 3);
game.statShotsFired[WPN_SPREAD] += 2;
break;
case WPN_LASER:
fireLaser((Entity*)world.bob);
@ -562,7 +563,7 @@ static void fireWeapon(void)
break;
}
game.statShotsFired[world.bob->weaponType]++;
game.stats[STAT_SHOTS_FIRED]++;
}

View File

@ -125,8 +125,7 @@ static void preTeleport(void)
m = (MIA*)self;
m->teleportTimer--;
if (m->teleportTimer <= FPS)
if (--m->teleportTimer <= FPS)
{
m->action = teleport;
m->flags |= (EF_NO_CLIP | EF_WEIGHTLESS);
@ -140,11 +139,10 @@ static void teleport(void)
m = (MIA*)self;
m->teleportTimer--;
if (m->teleportTimer <= 0)
if (--m->teleportTimer <= 0)
{
addTeleportStars(self);
addRescuedMIA(m->name);
game.stats[STAT_MIAS_RESCUED]++;
updateObjective("MIA");
m->alive = ALIVE_DEAD;
}

View File

@ -27,8 +27,8 @@ extern void addTeleportStars(Entity *e);
extern void setGameplayMessage(int type, char *format, ...);
extern void playSound(int snd, int ch);
extern void updateObjective(char *targetName);
extern void addRescuedMIA(char *name);
extern void initEntity(Entity *e);
extern Entity *self;
extern Game game;
extern World world;

View File

@ -384,8 +384,8 @@ static void die2(void)
updateObjective(b->name);
addDefeatedTarget(b->name);
game.stats[STAT_TARGETS_DEFEATED]++;
game.enemiesKilled++;
game.stats[STAT_ENEMIES_KILLED]++;
}
}

View File

@ -34,7 +34,6 @@ extern int getDistance(int x1, int y1, int x2, int y2);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern int enemyCanSeePlayer(Entity *e);
extern void updateObjective(char *targetName);
extern void addDefeatedTarget(char *name);
extern Entity *self;
extern Game game;

View File

@ -376,9 +376,11 @@ static void die2()
updateObjective(b->name);
addDefeatedTarget(b->name);
game.stats[STAT_TARGETS_DEFEATED]++;
game.enemiesKilled++;
awardTrophy("");
game.stats[STAT_ENEMIES_KILLED]++;
}
}

View File

@ -29,13 +29,13 @@ extern void addSmokeParticles(float x, float y);
extern int rrnd(int low, int high);
extern int getDistance(int x1, int y1, int x2, int y2);
extern int enemyCanSeePlayer(Entity *e);
extern void addDefeatedTarget(char *name);
extern void updateObjective(char *targetName);
extern double randF(void);
extern void playSound(int snd, int ch);
extern Bullet *createBaseBullet(Unit *owner);
extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void awardTrophy(char *id);
extern Entity *self;
extern Game game;

View File

@ -330,9 +330,11 @@ static void die2(void)
updateObjective(b->name);
addDefeatedTarget(b->name);
game.stats[STAT_TARGETS_DEFEATED]++;
game.enemiesKilled++;
awardTrophy("");
game.stats[STAT_ENEMIES_KILLED]++;
}
}

View File

@ -28,7 +28,6 @@ extern float limit(float i, float a, float b);
extern int rrnd(int low, int high);
extern int getDistance(int x1, int y1, int x2, int y2);
extern int enemyCanSeePlayer(Entity *e);
extern void addDefeatedTarget(char *name);
extern void updateObjective(char *targetName);
extern void playSound(int snd, int ch);
extern Bullet *createBaseBullet(Unit *owner);
@ -36,6 +35,7 @@ extern void getSlope(int x1, int y1, int x2, int y2, float *dx, float *dy);
extern void addExplosion(float x, float y, int radius, Entity *owner);
extern void addScorchDecal(int x, int y);
extern void initTankTrack(Entity *e);
extern void awardTrophy(char *id);
extern Entity *self;
extern Game game;

View File

@ -118,7 +118,7 @@ static void touch(Entity *other)
if (b->owner->type == world.bob->type)
{
game.statShotsHit[b->weaponType]++;
game.stats[STAT_SHOTS_HIT]++;
}
}
}

View File

@ -82,7 +82,7 @@ static void touch(Entity *other)
if (b->owner->type == world.bob->type)
{
game.statShotsHit[WPN_GRENADES]++;
game.stats[STAT_SHOTS_HIT]++;
}
if (!(other->flags & EF_BOMB_SHIELD))

View File

@ -74,7 +74,7 @@ static void touch(Entity *other)
if (b->owner->type == world.bob->type)
{
game.statShotsHit[WPN_LASER]++;
game.stats[STAT_SHOTS_HIT]++;
}
if (other->type == ET_BOB && world.bob->stunTimer == 0)

View File

@ -85,10 +85,10 @@ static void die2(void)
if (u->isMissionTarget)
{
addDefeatedTarget(u->name);
game.stats[STAT_TARGETS_DEFEATED]++;
}
game.enemiesKilled++;
game.stats[STAT_ENEMIES_KILLED]++;
mx = (int) ((u->x + (u->w / 2)) / MAP_TILE_SIZE);
my = (int) (u->y / MAP_TILE_SIZE) + 1;

View File

@ -30,7 +30,6 @@ extern void playSound(int snd, int ch);
extern void addBloodDecal(int x, int y);
extern void updateObjective(char *targetName);
extern int enemyCanSeePlayer(Entity *e);
extern void addDefeatedTarget(char *name);
extern void fireTriggers(char *name);
extern void addRandomItems(float x, float y);
extern int rrnd(int low, int high);

View File

@ -93,10 +93,10 @@ static void touch(Entity *other)
if (u->isMissionTarget)
{
addDefeatedTarget(u->name);
game.stats[STAT_TARGETS_DEFEATED]++;
}
game.enemiesKilled++;
game.stats[STAT_ENEMIES_KILLED]++;
mx = (int) ((u->x + (u->w / 2)) / MAP_TILE_SIZE);
my = (int) ((u->y + u->h) / MAP_TILE_SIZE) + 1;

View File

@ -28,7 +28,6 @@ extern float limit(float i, float a, float b);
extern void playSound(int snd, int ch);
extern void updateObjective(char *targetName);
extern int enemyCanSeePlayer(Entity *e);
extern void addDefeatedTarget(char *name);
extern void fireTriggers(char *name);
extern void addRandomItems(float x, float y);
extern int rrnd(int low, int high);

View File

@ -51,5 +51,7 @@ static void touch(Entity *other)
pickupItem();
playSound(SND_ITEM, CH_ITEM);
game.stats[STAT_BATTERIES_PICKED_UP]++;
}
}

View File

@ -27,4 +27,5 @@ extern void setGameplayMessage(int type, char *format, ...);
extern int touchedPlayer(Entity *e);
extern Entity *self;
extern Game game;
extern World world;

View File

@ -50,6 +50,8 @@ static void touch(Entity *other)
{
game.cells++;
game.stats[STAT_CELLS_FOUND]++;
world.bob->power = world.bob->powerMax = game.cells;
setGameplayMessage(MSG_OBJECTIVE, _("Found a battery cell - Max power increased!"));

View File

@ -48,5 +48,7 @@ static void touch(Entity *other)
pickupItem();
playSound(SND_CHERRY, CH_BOB);
game.stats[STAT_CHERRIES_PICKED_UP]++;
}
}

View File

@ -28,4 +28,5 @@ extern void pickupItem(void);
extern float limit(float i, float a, float b);
extern Entity *self;
extern Game game;
extern World world;

View File

@ -62,6 +62,8 @@ static void touch(Entity *other)
{
game.hearts++;
game.stats[STAT_HEARTS_FOUND]++;
world.bob->health = world.bob->healthMax = game.hearts;
setGameplayMessage(MSG_OBJECTIVE, _("Found a heart - Max health increased!"));

View File

@ -135,7 +135,7 @@ static void bobPickupItem(void)
if (i->thinkTime == 0)
{
addItem(i);
game.keysFound++;
game.stats[STAT_KEYS_FOUND]++;
updateObjective("KEY");
setGameplayMessage(MSG_STANDARD, _("Picked up a %s"), i->name);

View File

@ -106,5 +106,7 @@ static void touchWhiteKeycard(Entity *other)
updateObjective("White Keycard");
teekaExitMission();
awardTrophy("");
}
}

View File

@ -23,5 +23,6 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
extern Entity *createItem(void);
extern void updateObjective(char *targetName);
extern void teekaExitMission(void);
extern void awardTrophy(char *id);
extern World world;

View File

@ -96,5 +96,7 @@ static void touch(Entity *other)
pickupItem();
playSound(SND_WEAPON, CH_ITEM);
game.stats[STAT_WEAPONS_PICKED_UP]++;
}
}

View File

@ -29,4 +29,5 @@ extern const char *getWeaponName(int i);
extern Entity *initConsumable(void);
extern Entity *self;
extern Game game;
extern World world;

View File

@ -32,39 +32,11 @@ void initGame(void)
game.cells = 5;
game.hearts = 10;
game.timePlayed = 0;
game.stats[STAT_TIME_PLAYED] = 0;
loadMetaInfo();
}
void addRescuedMIA(char *name)
{
int i;
for (i = 0 ; i < game.totalMIAs ; i++)
{
if (strcmp(game.mias[i], "") == 0)
{
STRNCPY(game.mias[i], name, MAX_NAME_LENGTH);
return;
}
}
}
void addDefeatedTarget(char *name)
{
int i;
for (i = 0 ; i < game.totalTargets ; i++)
{
if (strcmp(game.targets[i], "") == 0)
{
STRNCPY(game.targets[i], name, MAX_NAME_LENGTH);
return;
}
}
}
int getNumItemsCarried(void)
{
int rtn, i;
@ -265,7 +237,6 @@ static void loadMetaInfo(void)
{
cJSON *root;
char *text;
int i;
text = readFile("data/meta/meta.json");
@ -279,18 +250,6 @@ static void loadMetaInfo(void)
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Meta [keys=%d, targets=%d, mias=%d, hearts=%d, cells=%d]", game.totalKeys, game.totalTargets, game.totalMIAs, game.totalHearts, game.totalCells);
game.mias = malloc(sizeof(char*) * game.totalMIAs);
for (i = 0 ; i < game.totalMIAs ; i++)
{
game.mias[i] = malloc(MAX_NAME_LENGTH);
}
game.targets = malloc(sizeof(char*) * game.totalTargets);
for (i = 0 ; i < game.totalTargets ; i++)
{
game.targets[i] = malloc(MAX_NAME_LENGTH);
}
cJSON_Delete(root);
free(text);

25
src/game/trophies.c Normal file
View File

@ -0,0 +1,25 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "trophies.h"
void awardTrophy(char *id)
{
}

21
src/game/trophies.h Normal file
View File

@ -0,0 +1,21 @@
/*
Copyright (C) 2018 Parallel Realities
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
See the GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "../common.h"

View File

@ -71,7 +71,7 @@ int main(int argc, char *argv[])
frames = 0;
game.timePlayed++;
game.stats[STAT_TIME_PLAYED]++;
nextSecond = SDL_GetTicks() + 1000;
}

View File

@ -345,25 +345,16 @@ typedef struct {
typedef struct {
int cells;
int hearts;
int keysFound;
int totalMIAs;
int totalTargets;
int totalCells;
int totalHearts;
int totalKeys;
int deaths;
int statShotsFired[WPN_ANY];
int statShotsHit[WPN_ANY];
int enemiesKilled;
int missionsPlayed;
long timePlayed;
unsigned int stats[STAT_MAX];
char worldId[MAX_NAME_LENGTH];
int isResumingMission;
int isComplete;
char **mias;
char **targets;
Tuple keys[MAX_KEY_TYPES];
Tuple originalKeys[MAX_KEY_TYPES];
Tuple missionStatusHead, *missionStatusTail;
} Game;

View File

@ -23,9 +23,9 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
void initAtlasTest(void)
{
dev.cheatStatic = 0;
dev.cheatBlind = 0;
dev.cheatBlind = 1;
dev.cheatNoEnemies = 0;
dev.cheatKeys = 1;
dev.cheatKeys = 0;
dev.cheatPower = 1;
dev.cheatHealth = 1;
@ -33,7 +33,7 @@ void initAtlasTest(void)
initHub();
loadWorld("greenlands1");
loadWorld("greenlands2");
initWorld();

View File

@ -80,7 +80,7 @@ void initWorld(void)
if (!game.isResumingMission)
{
game.missionsPlayed++;
game.stats[STAT_MISSIONS_PLAYED]++;
}
world.bob->flags |= EF_GONE;