Start of Frequent Flyer trophy.
This commit is contained in:
parent
8bbe9f69e2
commit
b55574a9e6
|
@ -35,5 +35,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 5,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -17,5 +17,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 2,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -25,5 +25,5 @@
|
|||
],
|
||||
"combinedGuns" : 1,
|
||||
"missiles" : 3,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 6,
|
||||
"flags" : "EF_TAKES_DAMAGE",
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER",
|
||||
"aiFlags" : "AIF_MISSILE_BOAT+AIF_DEFENSIVE"
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 4,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 4,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 3,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -29,6 +29,6 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 8,
|
||||
"flags" : "EF_TAKES_DAMAGE",
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER",
|
||||
"aiFlags" : "AIF_MISSILE_BOAT+AIF_DEFENSIVE"
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 4,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -24,5 +24,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 3,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 6,
|
||||
"flags" : "EF_TAKES_DAMAGE",
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER",
|
||||
"aiFlags" : "AIF_MISSILE_BOAT+AIF_DEFENSIVE"
|
||||
}
|
||||
|
|
|
@ -30,5 +30,5 @@
|
|||
],
|
||||
"combinedGuns" : 1,
|
||||
"missiles" : 6,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 3,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 4,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -25,5 +25,5 @@
|
|||
],
|
||||
"combinedGuns" : 1,
|
||||
"missiles" : 4,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -34,5 +34,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 4,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -24,6 +24,6 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 8,
|
||||
"flags" : "EF_TAKES_DAMAGE",
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER",
|
||||
"aiFlags" : "AIF_MISSILE_BOAT+AIF_AGGRESSIVE+AIF_LONG_RANGE_FIRE"
|
||||
}
|
||||
|
|
|
@ -24,5 +24,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 3,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 5,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 6,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -29,5 +29,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 2,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -19,5 +19,5 @@
|
|||
}
|
||||
],
|
||||
"missiles" : 4,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -35,5 +35,5 @@
|
|||
],
|
||||
"combinedGuns" : 1,
|
||||
"missiles" : 4,
|
||||
"flags" : "EF_TAKES_DAMAGE"
|
||||
"flags" : "EF_TAKES_DAMAGE+EF_COMMON_FIGHTER"
|
||||
}
|
||||
|
|
|
@ -286,5 +286,11 @@
|
|||
"description" : "Destroy two or more fighters by shooting one mine",
|
||||
"value" : "TROPHY_BRONZE",
|
||||
"hidden" : 1
|
||||
},
|
||||
{
|
||||
"id" : "FREQUENT_FLYER",
|
||||
"title" : "Frequent flyer",
|
||||
"description" : "Destroy one of each common type of starfighter",
|
||||
"value" : "TROPHY_SILVER"
|
||||
}
|
||||
]
|
||||
|
|
|
@ -31,6 +31,8 @@ static void randomizeDartGuns(Entity *dart);
|
|||
static void loadFighterDef(char *filename);
|
||||
static void loadFighterDefList(char *filename);
|
||||
static Entity *getFighterDef(char *name);
|
||||
static void addFighterStat(char *name);
|
||||
static void incFighterStat(char *key);
|
||||
|
||||
static Entity defHead, *defTail;
|
||||
|
||||
|
@ -562,6 +564,11 @@ static void die(void)
|
|||
{
|
||||
battle.stats[STAT_ENEMIES_KILLED_PLAYER]++;
|
||||
|
||||
if (self->flags & EF_COMMON_FIGHTER)
|
||||
{
|
||||
incFighterStat(self->defName);
|
||||
}
|
||||
|
||||
if (battle.hasSuspicionLevel)
|
||||
{
|
||||
battle.suspicionLevel = MAX(0, battle.suspicionLevel - (MAX_SUSPICION_LEVEL * 0.1));
|
||||
|
@ -817,6 +824,11 @@ static void loadFighterDef(char *filename)
|
|||
{
|
||||
e->deathType = lookup(cJSON_GetObjectItem(root, "deathType")->valuestring);
|
||||
}
|
||||
|
||||
if (e->flags & EF_COMMON_FIGHTER)
|
||||
{
|
||||
addFighterStat(e->name);
|
||||
}
|
||||
|
||||
e->separationRadius = MAX(e->w, e->h) * 3;
|
||||
|
||||
|
@ -832,6 +844,47 @@ static void loadFighterDef(char *filename)
|
|||
free(text);
|
||||
}
|
||||
|
||||
static void addFighterStat(char *key)
|
||||
{
|
||||
Tuple *t, *tail;
|
||||
|
||||
tail = &game.fighterStatHead;
|
||||
|
||||
for (t = game.fighterStatHead.next ; t != NULL ; t = t->next)
|
||||
{
|
||||
if (strcmp(t->key, key) == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
tail = t;
|
||||
}
|
||||
|
||||
t = malloc(sizeof(Tuple));
|
||||
memset(t, 0, sizeof(Tuple));
|
||||
|
||||
STRNCPY(t->key, key, MAX_NAME_LENGTH);
|
||||
t->value = 0;
|
||||
|
||||
tail->next = t;
|
||||
|
||||
SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Added '%s' to fighter stats", key);
|
||||
}
|
||||
|
||||
static void incFighterStat(char *key)
|
||||
{
|
||||
Tuple *t;
|
||||
|
||||
for (t = game.fighterStatHead.next ; t != NULL ; t = t->next)
|
||||
{
|
||||
if (strcmp(t->key, key) == 0)
|
||||
{
|
||||
t->value++;
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void loadFighters(cJSON *node)
|
||||
{
|
||||
Entity *e;
|
||||
|
|
|
@ -108,6 +108,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
|||
#define EF_FRIENDLY_HEALTH_BAR (2 << 22)
|
||||
#define EF_NO_THREAT (2 << 23)
|
||||
#define EF_DROPS_ITEMS (2 << 24)
|
||||
#define EF_COMMON_FIGHTER (2 << 25)
|
||||
|
||||
#define AIF_NONE 0
|
||||
#define AIF_FOLLOWS_PLAYER (2 << 0)
|
||||
|
|
|
@ -385,6 +385,7 @@ static void loadTrophyData(char *filename)
|
|||
void awardStatsTrophies(void)
|
||||
{
|
||||
Trophy *t;
|
||||
Tuple *tp;
|
||||
|
||||
for (t = game.trophyHead.next ; t != NULL ; t = t->next)
|
||||
{
|
||||
|
@ -399,6 +400,17 @@ void awardStatsTrophies(void)
|
|||
app.saveGame = 1;
|
||||
}
|
||||
}
|
||||
|
||||
/* check to see if we've destroyed one of each common starfighter */
|
||||
for (tp = game.fighterStatHead.next ; tp != NULL ; tp = tp->next)
|
||||
{
|
||||
if (tp->value == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
awardTrophy("FREQUENT_FLYER");
|
||||
}
|
||||
|
||||
void awardCampaignTrophies(void)
|
||||
|
|
|
@ -39,6 +39,7 @@ typedef struct ScriptRunner ScriptRunner;
|
|||
typedef struct Location Location;
|
||||
typedef struct Bucket Bucket;
|
||||
typedef struct Trophy Trophy;
|
||||
typedef struct Tuple Tuple;
|
||||
|
||||
typedef struct {
|
||||
int debug;
|
||||
|
@ -400,6 +401,12 @@ typedef struct {
|
|||
int healthBars;
|
||||
} Gameplay;
|
||||
|
||||
struct Tuple {
|
||||
char key[MAX_NAME_LENGTH];
|
||||
int value;
|
||||
Tuple *next;
|
||||
};
|
||||
|
||||
typedef struct {
|
||||
StarSystem starSystemHead;
|
||||
Mission challengeMissionHead;
|
||||
|
@ -412,6 +419,7 @@ typedef struct {
|
|||
int totalChallenges;
|
||||
unsigned int stats[STAT_MAX];
|
||||
Trophy trophyHead;
|
||||
Tuple fighterStatHead;
|
||||
} Game;
|
||||
|
||||
struct Widget {
|
||||
|
|
|
@ -25,6 +25,7 @@ static void loadStarSystems(cJSON *starSystemsJSON);
|
|||
static void loadMissions(cJSON *missionsCJSON);
|
||||
static void loadChallenges(cJSON *challengesCJSON);
|
||||
static void loadTrophies(cJSON *trophiesJSON);
|
||||
static void loadFighterStats(cJSON *fighterStatsJSON);
|
||||
|
||||
void loadGame(void)
|
||||
{
|
||||
|
@ -45,6 +46,8 @@ void loadGame(void)
|
|||
loadStats(cJSON_GetObjectItem(gameJSON, "stats"));
|
||||
|
||||
loadTrophies(cJSON_GetObjectItem(gameJSON, "trophies"));
|
||||
|
||||
loadFighterStats(cJSON_GetObjectItem(gameJSON, "fighterStats"));
|
||||
|
||||
cJSON_Delete(root);
|
||||
free(text);
|
||||
|
@ -145,3 +148,26 @@ static void loadTrophies(cJSON *trophiesJSON)
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void loadFighterStats(cJSON *fighterStatsJSON)
|
||||
{
|
||||
Tuple *t, *tail;
|
||||
cJSON *fighterStatJSON;
|
||||
|
||||
tail = &game.fighterStatHead;
|
||||
|
||||
if (fighterStatsJSON)
|
||||
{
|
||||
for (fighterStatJSON = fighterStatsJSON->child ; fighterStatJSON != NULL ; fighterStatJSON = fighterStatJSON->next)
|
||||
{
|
||||
t = malloc(sizeof(Tuple));
|
||||
memset(t, 0, sizeof(Tuple));
|
||||
|
||||
STRNCPY(t->key, cJSON_GetObjectItem(fighterStatJSON, "key")->valuestring, MAX_NAME_LENGTH);
|
||||
t->value = cJSON_GetObjectItem(fighterStatJSON, "value")->valueint;
|
||||
|
||||
tail->next = t;
|
||||
tail = t;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -70,6 +70,7 @@ void initLookups(void)
|
|||
addLookup("EF_NO_THREAT", EF_NO_THREAT);
|
||||
addLookup("EF_NO_HEALTH_BAR", EF_NO_HEALTH_BAR);
|
||||
addLookup("EF_DROPS_ITEMS", EF_DROPS_ITEMS);
|
||||
addLookup("EF_COMMON_FIGHTER", EF_COMMON_FIGHTER);
|
||||
|
||||
addLookup("AIF_NONE", AIF_NONE);
|
||||
addLookup("AIF_MOVES_TO_PLAYER", AIF_MOVES_TO_PLAYER);
|
||||
|
|
|
@ -25,6 +25,7 @@ static void saveChallenges(cJSON *gameJSON);
|
|||
static cJSON *getMissionsJSON(StarSystem *starSystem);
|
||||
static void saveStats(cJSON *gameJSON);
|
||||
static void saveTrophies(cJSON *gameJSON);
|
||||
static void saveFighterStats(cJSON *gameJSON);
|
||||
|
||||
void saveGame(void)
|
||||
{
|
||||
|
@ -46,6 +47,8 @@ void saveGame(void)
|
|||
saveStats(gameJSON);
|
||||
|
||||
saveTrophies(gameJSON);
|
||||
|
||||
saveFighterStats(gameJSON);
|
||||
|
||||
out = cJSON_Print(root);
|
||||
|
||||
|
@ -175,3 +178,23 @@ static void saveTrophies(cJSON *gameJSON)
|
|||
|
||||
cJSON_AddItemToObject(gameJSON, "trophies", trophiesJSON);
|
||||
}
|
||||
|
||||
static void saveFighterStats(cJSON *gameJSON)
|
||||
{
|
||||
Tuple *t;
|
||||
cJSON *fighterStatsJSON, *fighterStatJSON;
|
||||
|
||||
fighterStatsJSON = cJSON_CreateArray();
|
||||
|
||||
for (t = game.fighterStatHead.next ; t != NULL ; t = t->next)
|
||||
{
|
||||
fighterStatJSON = cJSON_CreateObject();
|
||||
|
||||
cJSON_AddStringToObject(fighterStatJSON, "key", t->key);
|
||||
cJSON_AddNumberToObject(fighterStatJSON, "value", t->value);
|
||||
|
||||
cJSON_AddItemToArray(fighterStatsJSON, fighterStatJSON);
|
||||
}
|
||||
|
||||
cJSON_AddItemToObject(gameJSON, "fighterStats", fighterStatsJSON);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue