void awardCampaignTrophies(void) { char trophyId[MAX_NAME_LENGTH]; char name[MAX_NAME_LENGTH]; int i, len; StarSystem *starSystem; if (game.completedMissions) { awardTrophy("CAMPAIGN_1"); } /* check if all star system missions are completed */ for (starSystem = game.starSystemHead.next ; starSystem != NULL ; starSystem = starSystem->next) { if (starSystem->totalMissions && starSystem->completedMissions == starSystem->totalMissions) { memset(name, '\0', MAX_NAME_LENGTH); len = strlen(starSystem->name); for (i = 0 ; i < len ; i++) { name[i] = toupper(starSystem->name[i]); } sprintf(trophyId, "CAMPAIGN_%s", name); awardTrophy(trophyId); } } }
void awardTrophy(char *id) { Trophy *t; int numRemaining; numRemaining = 0; for (t = game.trophyHead.next ; t != NULL ; t = t->next) { if (!t->awarded && strcmp(t->id, id) == 0) { t->awarded = 1; t->awardDate = time(NULL); t->notify = SDL_GetTicks(); /* prevent race condition */ SDL_Delay(1); SDL_LogMessage(SDL_LOG_CATEGORY_APPLICATION, SDL_LOG_PRIORITY_INFO, "Awarding trophy '%s'", t->id); app.saveGame = 1; } if (!t->awarded) { numRemaining++; } } /* the Platinum will always be the last trophy to unlock */ if (numRemaining == 1) { awardTrophy("PLATINUM"); } }
static void updateDeathStats(void) { 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"); } }
void awardChallengeTrophies(void) { char trophyId[MAX_NAME_LENGTH]; int completed; /* check % of challenges completed - 25% increments*/ completed = (getPercent(game.completedChallenges, game.totalChallenges) / 25) * 25; sprintf(trophyId, "CHALLENGE_%d", completed); awardTrophy(trophyId); }
void awardPostMissionTrophies(void) { if (game.currentMission->epic) { awardTrophy("EPIC"); if (battle.stats[STAT_PLAYER_KILLED] == 0 && player->flags & EF_COMMON_FIGHTER) { awardTrophy("SURVIVOR"); } } /* * Must be a non-challenge mission, a common fighter, must not be Sol, and must not have fired any shots or missiles (and there should have been some enemies present) */ if (player->flags & EF_COMMON_FIGHTER && player->missiles && strcmp(game.selectedStarSystem, "Sol") && !battle.stats[STAT_SHOTS_FIRED] && !battle.stats[STAT_MISSILES_FIRED] && battle.numInitialEnemies > 0) { awardTrophy("PACIFIST"); } }
static void doSplashDamage(void) { Entity *e, **candidates; int i, dist, kills; float damage, percent; candidates = getAllEntsInRadius(self->x, self->y, DAMAGE_RANGE, self); kills = 0; for (i = 0, e = candidates[i] ; e != NULL ; e = candidates[++i]) { if (e->health > 0 && (e->type == ET_FIGHTER || e->type == ET_MINE) && !(e->flags & EF_IMMORTAL)) { dist = getDistance(self->x, self->y, e->x, e->y); if (dist <= DAMAGE_RANGE) { percent = dist; percent /= DAMAGE_RANGE; percent = 1 - percent; damage = DAMAGE_RANGE; damage *= percent; if (e->type == ET_FIGHTER) { damageFighter(e, damage, 0); if (self->killedBy == player && e != player && e->health <= 0) { kills++; } } else if (e->type == ET_MINE) { e->dx = e->x - self->x; e->dy = e->y - self->y; e->dx *= 0.01; e->dy *= 0.01; } } } } if (kills >= 2) { awardTrophy("2_BIRDS"); } }
void awardCraftTrophy(void) { if (!game.currentMission->challengeData.isChallenge) { if (strcmp(game.currentMission->craft, "ATAF") == 0) { awardTrophy("ATAF"); } else if (strcmp(game.currentMission->craft, "Tug") == 0) { awardTrophy("TUG"); } } else { if (strcmp(game.currentMission->craft, "Shuttle") == 0 && battle.stats[STAT_ITEMS_COLLECTED_PLAYER] > 0) { awardTrophy("SHUTTLE"); } } awardPandoranCraftTrophy(); }
void awardStatsTrophies(void) { Trophy *t; Tuple *tp; for (t = game.trophyHead.next ; t != NULL ; t = t->next) { if (t->stat != -1 && !t->awarded && (game.stats[t->stat] + battle.stats[t->stat]) >= t->statValue) { awardTrophy(t->id); } } /* 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"); }