From f5b3933a8796aebd68aeae0f602ae6079a7df5de Mon Sep 17 00:00:00 2001 From: Steve Date: Sat, 12 Mar 2016 18:28:43 +0000 Subject: [PATCH] Merge branch 'develop' into trophies Conflicts: src/battle/battle.c --- data/trophies/trophies.json | 73 +++++++++++++++++++++++++++++----- src/battle/battle.c | 5 +++ src/battle/battle.h | 1 + src/battle/bullets.c | 7 +++- src/battle/fighters.c | 8 +++- src/challenges/challengeHome.c | 12 +++--- src/challenges/challengeHome.h | 1 + src/game/trophies.c | 43 ++++++++++++++++++-- src/structs.h | 2 + 9 files changed, 130 insertions(+), 22 deletions(-) diff --git a/data/trophies/trophies.json b/data/trophies/trophies.json index 20bbd46..c3b3034 100644 --- a/data/trophies/trophies.json +++ b/data/trophies/trophies.json @@ -27,7 +27,7 @@ "id" : "CAMPAIGN_40", "title" : "Commander", "description" : "Complete 40% of all missions", - "value" : "TROPHY_SILVER" + "value" : "TROPHY_BRONZE" }, { "id" : "CAMPAIGN_50", @@ -51,13 +51,13 @@ "id" : "CAMPAIGN_90", "title" : "Admiral", "description" : "Complete 90% of all missions", - "value" : "TROPHY_SILVER" + "value" : "TROPHY_GOLD" }, { "id" : "CAMPAIGN_100", "title" : "Fleet Admiral", "description" : "Complete all campaign missions", - "value" : "TROPHY_SILVER" + "value" : "TROPHY_GOLD" }, { "id" : "CAMPAIGN_SOL", @@ -83,7 +83,7 @@ "id" : "CAMPAIGN_ILIAD", "title" : "The shape of things to come", "description" : "Complete all missions at Iliad", - "value" : "TROPHY_BRONZE", + "value" : "TROPHY_SILVER", "hidden" : 1 }, { @@ -108,17 +108,29 @@ "statValue" : 1 }, { - "id" : "PANDORAN_FIRST", - "title" : "Plenty more where that came from", - "description" : "Engage the Pandorans in battle", + "id" : "PANDORAN", + "title" : "Plenty more where that came from, unfortunately", + "description" : "Destroy a Pandoran-controlled craft", "value" : "TROPHY_BRONZE" }, { - "id" : "ATAF_FIRST", + "id" : "ATAF", "title" : "Man, I gotta get me one of these!", "description" : "Pilot an ATAF during the campaign", "value" : "TROPHY_BRONZE" }, + { + "id" : "TUG", + "title" : "The 4th emergency service", + "description" : "Complete a mission using a Tug", + "value" : "TROPHY_BRONZE" + }, + { + "id" : "SHUTTLE", + "title" : "Room for one more on top", + "description" : "Complete a mission using a Shuttle", + "value" : "TROPHY_BRONZE" + }, { "id" : "CHALLENGE_25", "title" : "", @@ -141,7 +153,7 @@ "id" : "FIRE_100000", "title" : "Your name's on one of these!", "description" : "Fire 100,000 shots", - "value" : "TROPHY_SILVER", + "value" : "TROPHY_BRONZE", "stat" : "STAT_SHOTS_FIRED", "statValue" : 10000 }, @@ -149,10 +161,51 @@ "id" : "MISSILE_1000", "title" : "Dodge this!", "description" : "Launch 1,000 missiles", - "value" : "TROPHY_SILVER", + "value" : "TROPHY_BRONZE", "stat" : "STAT_MISSILES_FIRED", "statValue" : 1000 }, + { + "id" : "ECM_100", + "title" : "Isn't technology wonderful?", + "description" : "Use the ECM 100 times", + "value" : "TROPHY_BRONZE", + "stat" : "STAT_ECM", + "statValue" : 100 + }, + { + "id" : "BOOST_100", + "title" : "Runaway!", + "description" : "Boost 100 times", + "value" : "TROPHY_BRONZE", + "stat" : "STAT_BOOST", + "statValue" : 100 + }, + { + "id" : "EVADE_50", + "title" : "Missed, you f**kers!", + "description" : "Evade 50 missiles", + "value" : "TROPHY_BRONZE", + "stat" : "STAT_MISSILES_EVADED", + "statValue" : 50, + "hidden" : 1 + }, + { + "id" : "WAYPOINT_100", + "title" : "Sightseer", + "description" : "Visit 100 waypoints", + "value" : "TROPHY_BRONZE", + "stat" : "STAT_WAYPOINTS_VISITED", + "statValue" : 100 + }, + { + "id" : "EPIC_KILL_13", + "title" : "Yippie-ki-yay", + "description" : "Destroy 13 or more enemies in an epic battle without being killed", + "value" : "TROPHY_SILVER", + "stat" : "STAT_EPIC_KILL_STREAK", + "statValue" : 13 + }, { "id" : "ATAF_DESTROYED", "title" : "Almost indestructable. Almost.", diff --git a/src/battle/battle.c b/src/battle/battle.c index bc393e2..71c2cc8 100644 --- a/src/battle/battle.c +++ b/src/battle/battle.c @@ -371,6 +371,11 @@ static void postBattle(void) if (game.currentMission && !game.currentMission->completed) { game.currentMission->completed = (battle.status == MS_COMPLETE || !battle.numObjectivesTotal); + + if (game.currentMission->completed) + { + awardPostMissionTrophies(); + } } } } diff --git a/src/battle/battle.h b/src/battle/battle.h index 0662b49..e37db3a 100644 --- a/src/battle/battle.h +++ b/src/battle/battle.h @@ -85,6 +85,7 @@ extern void initChallengeHome(void); extern void updateAccuracyStats(unsigned int *stats); extern void clearInput(void); extern void runScriptTimeFunctions(void); +extern void awardPostMissionTrophies(void); extern App app; extern Battle battle; diff --git a/src/battle/bullets.c b/src/battle/bullets.c index d7e233f..6c3648b 100644 --- a/src/battle/bullets.c +++ b/src/battle/bullets.c @@ -145,7 +145,7 @@ static void resizeDrawList(void) SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_DEBUG, "Resizing bullet draw capacity: %d -> %d\n", drawCapacity, n); bulletsToDraw = resize(bulletsToDraw, sizeof(Bullet*) * drawCapacity, sizeof(Bullet*) * n); - + drawCapacity = n; } @@ -207,6 +207,11 @@ static void checkCollisions(Bullet *b) { battle.stats[STAT_ENEMIES_KILLED_PLAYER]++; battle.stats[STAT_EPIC_KILL_STREAK]++; + + if (e->side == SIDE_PANDORAN) + { + awardTrophy("PANDORAN"); + } } if (b->owner == player && b->type == BT_MISSILE) diff --git a/src/battle/fighters.c b/src/battle/fighters.c index 7c8ec45..9d91703 100644 --- a/src/battle/fighters.c +++ b/src/battle/fighters.c @@ -290,7 +290,7 @@ void doFighter(void) addHudMessage(colors.red, _("Mission target has escaped.")); battle.stats[STAT_ENEMIES_ESCAPED]++; } - + if (strcmp(self->defName, "Civilian") == 0) { battle.stats[STAT_CIVILIANS_RESCUED]++; @@ -314,6 +314,12 @@ void doFighter(void) if (self == player) { battle.stats[STAT_PLAYER_KILLED]++; + + /* the player is known as "Player", so we need to check the craft they were assigned to */ + if (strcmp(game.currentMission->craft, "ATAF") == 0) + { + awardTrophy("ATAF_DESTROYED"); + } } else if (player != NULL) { diff --git a/src/challenges/challengeHome.c b/src/challenges/challengeHome.c index 5f43774..a27971a 100644 --- a/src/challenges/challengeHome.c +++ b/src/challenges/challengeHome.c @@ -40,10 +40,8 @@ static char *listRestrictions(void); static SDL_Texture *background; static int startIndex; static Widget *start; -static int completedChallenges; static SDL_Texture *planetTexture; static PointF planet; -static int totalChallenges; static int show; static char timeLimit[MAX_DESCRIPTION_LENGTH]; static char restrictions[MAX_DESCRIPTION_LENGTH]; @@ -59,6 +57,8 @@ void initChallengeHome(void) unlockChallenges(); + awardChallengeTrophies(); + awardStatsTrophies(); saveGame(); @@ -109,7 +109,7 @@ static void unlockChallenges(void) int i, prevCompleted; - i = completedChallenges = totalChallenges = 0; + i = game.completedChallenges = game.totalChallenges = 0; prevCompleted = 1; @@ -117,8 +117,8 @@ static void unlockChallenges(void) { m->available = (prevCompleted > 0 || dev.debug); - completedChallenges += m->completedChallenges; - totalChallenges += m->totalChallenges; + game.completedChallenges += m->completedChallenges; + game.totalChallenges += m->totalChallenges; prevCompleted = m->completedChallenges; i++; @@ -232,7 +232,7 @@ static void draw(void) drawText(SCREEN_WIDTH / 2, 50, 30, TA_CENTER, colors.white, _("Challenges")); - drawText(SCREEN_WIDTH / 2, 100, 24, TA_CENTER, colors.white, "%d / %d", completedChallenges, totalChallenges); + drawText(SCREEN_WIDTH / 2, 100, 24, TA_CENTER, colors.white, "%d / %d", game.completedChallenges, game.totalChallenges); drawChallenges(); diff --git a/src/challenges/challengeHome.h b/src/challenges/challengeHome.h index dfeadcd..94e752a 100644 --- a/src/challenges/challengeHome.h +++ b/src/challenges/challengeHome.h @@ -63,6 +63,7 @@ extern void clearInput(void); extern void doTrophies(void); extern void drawTrophyAlert(void); extern void awardStatsTrophies(void); +extern void awardChallengeTrophies(void); extern App app; extern Battle battle; diff --git a/src/game/trophies.c b/src/game/trophies.c index 9abdae7..43befcd 100644 --- a/src/game/trophies.c +++ b/src/game/trophies.c @@ -22,6 +22,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. static void loadTrophyData(char *filename); static void resetAlert(void); +static void awardCraftTrophy(void); static Trophy *alertTrophy; static SDL_Texture *trophyIcons[TROPHY_MAX]; @@ -74,7 +75,7 @@ void doTrophies(void) if (alertRect.x > -50) { - alertDX *= 0.95; + alertDX *= 0.9; } if (--alertTimer <= 0) @@ -193,12 +194,12 @@ void awardCampaignTrophies(void) { char trophyId[MAX_NAME_LENGTH]; char name[MAX_NAME_LENGTH]; - int completedMissions, i, len; + int completed, i, len; StarSystem *starSystem; /* check % of missions completed */ - completedMissions = getPercent(game.completedMissions, game.totalMissions); - sprintf(trophyId, "CAMPAIGN_%d", completedMissions); + completed = getPercent(game.completedMissions, game.totalMissions); + sprintf(trophyId, "CAMPAIGN_%d", completed); awardTrophy(trophyId); /* check if all star system missions are completed */ @@ -220,7 +221,41 @@ void awardCampaignTrophies(void) } } +void awardChallengeTrophies(void) +{ + char trophyId[MAX_NAME_LENGTH]; + int completed; + + /* check % of challenges completed */ + completed = getPercent(game.completedChallenges, game.totalChallenges); + sprintf(trophyId, "CHALLENGE_%d", completed); + awardTrophy(trophyId); +} + void awardPostMissionTrophies(void) { + awardCraftTrophy(); + if (game.currentMission->epic) + { + awardTrophy("EPIC"); + } +} + +/* the player is known as "Player", so we need to check the craft they were assigned to */ +static void awardCraftTrophy(void) +{ + char trophyId[MAX_NAME_LENGTH]; + int len; + + memset(trophyId, '\0', MAX_NAME_LENGTH); + + len = strlen(game.currentMission->craft); + + for (i = 0 ; i < len ; i++) + { + trophyId[i] = toupper(game.currentMission->craft[i]); + } + + awardTrophy(trophyId); } diff --git a/src/structs.h b/src/structs.h index 34c0587..bf62ed5 100644 --- a/src/structs.h +++ b/src/structs.h @@ -365,6 +365,8 @@ typedef struct { int completedMissions; int availableMissions; int totalMissions; + int completedChallenges; + int totalChallenges; unsigned int stats[STAT_MAX]; Trophy trophyHead; } Game;