Adds hooks for all achievements

This commit is contained in:
Linus Probert 2018-08-29 14:26:07 +02:00
parent 412a30da0d
commit 3697e9b0b6
3 changed files with 24 additions and 8 deletions

View File

@ -866,6 +866,9 @@ run_game(void)
gui_log("Your break is over!"); gui_log("Your break is over!");
gui_event_message("Well done!"); gui_event_message("Well done!");
end_game_details(); end_game_details();
#ifdef STEAM_BUILD
steam_set_achievement(BACK_TO_WORK);
#endif // STEAM_BUILD
} }
} }

View File

@ -36,6 +36,10 @@
#include "animation.h" #include "animation.h"
#include "trap.h" #include "trap.h"
#ifdef STEAM_BUILD
#include "steam/steamworks_api_wrapper.h"
#endif // STEAM_BUILD
#define ENGINEER_STATS { 12, 12, 5, 7, 2, 2, 1, false, false } #define ENGINEER_STATS { 12, 12, 5, 7, 2, 2, 1, false, false }
#define MAGE_STATS { 12, 12, 5, 7, 1, 2, 1, false, false } #define MAGE_STATS { 12, 12, 5, 7, 1, 2, 1, false, false }
#define PALADIN_STATS { 12, 12, 8, 9, 3, 1, 1, false, false } #define PALADIN_STATS { 12, 12, 8, 9, 3, 1, 1, false, false }
@ -514,6 +518,17 @@ player_monster_kill_check(Player *player, Monster *monster)
if (!monster) if (!monster)
return; return;
#ifdef STEAM_BUILD
if (strcmp("The Shadow", monster->label) == 0)
steam_set_achievement(LIGHTS_ON);
else if (strcmp("The Hell Hound", monster->label) == 0)
steam_set_achievement(BAD_DOG);
else if (strcmp("Platino", monster->label) == 0)
steam_set_achievement(DRAGON_SLAYER);
else if (strcmp("The Cleric", monster->label) == 0)
steam_set_achievement(THE_DOCTOR_IS_OUT);
#endif // STEAM_BUILD
if (monster->stats.hp <= 0) { if (monster->stats.hp <= 0) {
unsigned int gained_xp = 5 * monster->stats.lvl; unsigned int gained_xp = 5 * monster->stats.lvl;
player->stat_data.kills += 1; player->stat_data.kills += 1;

View File

@ -28,18 +28,13 @@ steam_request_stats()
static void static void
stats_received(void) stats_received(void)
{ {
debug("Stats received"); debug("Steam stats received");
for (Uint8 i = 0; i < numAchievements; ++i) {
Achievement *a = &g_Achievements[i];
c_SteamUserStats_GetAchievement(a->m_pchAchievementID, &a->m_bAchieved);
gui_log("You just earned the \"%s\" achievement", c_SteamUserStats_GetAchievementDisplayAttribute(a->m_pchAchievementID, "name"));
}
} }
static void static void
stats_stored(void) stats_stored(void)
{ {
debug("Stats stored"); debug("Steam stats stored");
} }
void void
@ -67,7 +62,10 @@ void steam_run_callbacks(void)
void steam_set_achievement(EAchievement eAch) void steam_set_achievement(EAchievement eAch)
{ {
for (Uint8 i = 0; i < numAchievements; ++i) { for (Uint8 i = 0; i < numAchievements; ++i) {
if (g_Achievements[i].m_eAchievementID == eAch) Achievement *a = &g_Achievements[i];
if (a->m_eAchievementID == eAch && !a->m_bAchieved) {
c_SteamUserStats_SetAchievement(g_Achievements[i].m_pchAchievementID); c_SteamUserStats_SetAchievement(g_Achievements[i].m_pchAchievementID);
gui_log("You just earned the \"%s\" achievement", a->m_rgchName);
}
} }
} }