From e51c067e419bf1ec6186153ff0cc65dd63a5e562 Mon Sep 17 00:00:00 2001 From: WALL OF JUSTICE <-> Date: Fri, 25 Oct 2024 15:35:15 +1100 Subject: [PATCH] * stat update with player --- src/actboulder.cpp | 2 +- src/actladder.cpp | 4 ++-- src/entity.cpp | 14 +++++++------- src/menu.cpp | 2 +- src/mod_tools.hpp | 2 +- src/playfab.cpp | 14 ++++++++++++-- src/playfab.hpp | 2 +- src/scores.cpp | 6 +++--- src/scores.hpp | 2 +- src/steam.cpp | 2 +- 10 files changed, 30 insertions(+), 20 deletions(-) diff --git a/src/actboulder.cpp b/src/actboulder.cpp index e497f584e..36b4e2b1b 100644 --- a/src/actboulder.cpp +++ b/src/actboulder.cpp @@ -390,7 +390,7 @@ int boulderCheckAgainstEntity(Entity* my, Entity* entity, bool ignoreInsideEntit { Compendium_t::Events_t::eventUpdateWorld(entity->skill[2], Compendium_t::CPDM_TRAP_KILLED_BY, "boulder trap", 1); } - achievementObserver.updateGlobalStat(STEAM_GSTAT_BOULDER_DEATHS); + achievementObserver.updateGlobalStat(STEAM_GSTAT_BOULDER_DEATHS, entity->skill[2]); } } if ( BOULDER_PLAYERPUSHED >= 0 && oldHP > 0 && stats->HP <= 0 ) diff --git a/src/actladder.cpp b/src/actladder.cpp index 4e773a75b..3ef41da0f 100644 --- a/src/actladder.cpp +++ b/src/actladder.cpp @@ -1466,9 +1466,9 @@ void actCustomPortal(Entity* my) tutorialLevels.at(number).completionTime = std::min(tutorialLevels.at(number).completionTime, completionTime); } achievementObserver.updateGlobalStat( - std::min(STEAM_GSTAT_TUTORIAL1_COMPLETED - 1 + number, static_cast(STEAM_GSTAT_TUTORIAL10_COMPLETED))); + std::min(STEAM_GSTAT_TUTORIAL1_COMPLETED - 1 + number, static_cast(STEAM_GSTAT_TUTORIAL10_COMPLETED)), -1); achievementObserver.updateGlobalStat( - std::min(STEAM_GSTAT_TUTORIAL1_ATTEMPTS - 1 + number, static_cast(STEAM_GSTAT_TUTORIAL10_ATTEMPTS))); + std::min(STEAM_GSTAT_TUTORIAL1_ATTEMPTS - 1 + number, static_cast(STEAM_GSTAT_TUTORIAL10_ATTEMPTS)), -1); } completionTime = 0; gameModeManager.Tutorial.writeToDocument(); diff --git a/src/entity.cpp b/src/entity.cpp index 470aca21b..44845456a 100644 --- a/src/entity.cpp +++ b/src/entity.cpp @@ -13070,7 +13070,7 @@ void Entity::awardXP(Entity* src, bool share, bool root) { if ( src->behavior == &actPlayer && this->behavior == &actMonster ) { - achievementObserver.updateGlobalStat(getIndexForDeathType(destStats->type)); + achievementObserver.updateGlobalStat(getIndexForDeathType(destStats->type), src->skill[2]); if ( destStats->type == MIMIC ) { steamAchievementClient(src->skill[2], "BARONY_ACH_ETERNAL_REWARD"); @@ -13080,27 +13080,27 @@ void Entity::awardXP(Entity* src, bool share, bool root) { if ( srcStats->type == LICH ) { - achievementObserver.updateGlobalStat(STEAM_GSTAT_HERX_SLAIN); + achievementObserver.updateGlobalStat(STEAM_GSTAT_HERX_SLAIN, this->skill[2]); } else if ( srcStats->type == LICH_FIRE ) { - achievementObserver.updateGlobalStat(STEAM_GSTAT_TWINSFIRE_SLAIN); + achievementObserver.updateGlobalStat(STEAM_GSTAT_TWINSFIRE_SLAIN, this->skill[2]); } else if ( srcStats->type == LICH_ICE ) { - achievementObserver.updateGlobalStat(STEAM_GSTAT_TWINSICE_SLAIN); + achievementObserver.updateGlobalStat(STEAM_GSTAT_TWINSICE_SLAIN, this->skill[2]); } else if ( srcStats->type == DEVIL ) { - achievementObserver.updateGlobalStat(STEAM_GSTAT_BAPHOMET_SLAIN); + achievementObserver.updateGlobalStat(STEAM_GSTAT_BAPHOMET_SLAIN, this->skill[2]); } else if ( srcStats->type == MINOTAUR ) { - achievementObserver.updateGlobalStat(STEAM_GSTAT_MINOTAURS_SLAIN); + achievementObserver.updateGlobalStat(STEAM_GSTAT_MINOTAURS_SLAIN, this->skill[2]); } else if ( srcStats->type == SHOPKEEPER ) { - achievementObserver.updateGlobalStat(STEAM_GSTAT_SHOPKEEPERS_SLAIN); + achievementObserver.updateGlobalStat(STEAM_GSTAT_SHOPKEEPERS_SLAIN, this->skill[2]); } } } diff --git a/src/menu.cpp b/src/menu.cpp index c83e80bdb..a51a402a5 100644 --- a/src/menu.cpp +++ b/src/menu.cpp @@ -9637,7 +9637,7 @@ void doEndgame(bool saveHighscore, bool onServerDisconnect) { { conductGameChallenges[CONDUCT_BOOTS_SPEED] = 1; } - achievementObserver.updateGlobalStat(STEAM_GSTAT_GAMES_WON); + achievementObserver.updateGlobalStat(STEAM_GSTAT_GAMES_WON, clientnum); for ( int c = 0; c < MAXPLAYERS; ++c ) { diff --git a/src/mod_tools.hpp b/src/mod_tools.hpp index 77766b5a2..befb01c56 100644 --- a/src/mod_tools.hpp +++ b/src/mod_tools.hpp @@ -2619,7 +2619,7 @@ class GameModeManager_t { #ifndef EDITOR achievementObserver.updateGlobalStat( - std::min(STEAM_GSTAT_TUTORIAL1_ATTEMPTS - 1 + levelNum, static_cast(STEAM_GSTAT_TUTORIAL10_ATTEMPTS))); + std::min(STEAM_GSTAT_TUTORIAL1_ATTEMPTS - 1 + levelNum, static_cast(STEAM_GSTAT_TUTORIAL10_ATTEMPTS)), -1); #endif // !EDITOR } diff --git a/src/playfab.cpp b/src/playfab.cpp index 07e7c6175..5a9da898e 100644 --- a/src/playfab.cpp +++ b/src/playfab.cpp @@ -66,14 +66,14 @@ void PlayfabUser_t::gameBegin() PlayFab::PlayFabEventsAPI::WriteTelemetryEvents(eventRequest, OnEventsWrite, OnCloudScriptFailure); } -void PlayfabUser_t::globalStat(int index, int value) +void PlayfabUser_t::globalStat(int index, int player) { if ( !bLoggedIn ) { return; } - if ( index < 0 || index >= STEAM_GSTAT_MAX || value < 0 ) + if ( index < 0 || index >= STEAM_GSTAT_MAX ) { return; } @@ -90,6 +90,16 @@ void PlayfabUser_t::globalStat(int index, int value) eventContent.Payload["stat"] = SteamGlobalStatStr[index].c_str(); eventContent.Payload["level"] = currentlevel; eventContent.Payload["secret"] = secretlevel; + if ( player >= 0 && player < MAXPLAYERS && !client_disconnected[player] ) + { + eventContent.Payload["class"] = client_classes[player]; + eventContent.Payload["race"] = stats[player]->playerRace; + } + else + { + eventContent.Payload["class"] = -1; + eventContent.Payload["race"] = -1; + } eventRequest.Events.push_back(eventContent); PlayFab::PlayFabEventsAPI::WriteTelemetryEvents(eventRequest, OnEventsWrite, OnCloudScriptFailure); } diff --git a/src/playfab.hpp b/src/playfab.hpp index 48712f5ad..6c233e2ff 100644 --- a/src/playfab.hpp +++ b/src/playfab.hpp @@ -48,7 +48,7 @@ class PlayfabUser_t void getLeaderboardAroundMe(std::string lid); void getLeaderboardTop100Alternate(std::string lid); void gameBegin(); - void globalStat(int index, int value); + void globalStat(int index, int player); struct PlayerCheckLeaderboardData_t { diff --git a/src/scores.cpp b/src/scores.cpp index 82db7568e..4abdfafc9 100644 --- a/src/scores.cpp +++ b/src/scores.cpp @@ -6193,7 +6193,7 @@ bool AchievementObserver::PlayerAchievements::checkTraditionKill(Entity* player, return true; } -void AchievementObserver::updateGlobalStat(int index, int value) +void AchievementObserver::updateGlobalStat(int index, int player) { if ( multiplayer == CLIENT ) { @@ -6208,10 +6208,10 @@ void AchievementObserver::updateGlobalStat(int index, int value) } #endif #ifdef USE_PLAYFAB - playfabUser.globalStat(index, value); + playfabUser.globalStat(index, player); #endif #if defined USE_EOS - EOS.queueGlobalStatUpdate(index, value); + EOS.queueGlobalStatUpdate(index, 1); #endif } diff --git a/src/scores.hpp b/src/scores.hpp index 4af0f26c8..187e2b838 100644 --- a/src/scores.hpp +++ b/src/scores.hpp @@ -923,7 +923,7 @@ class AchievementObserver void updateClientBounties(bool firstSend); void clearPlayerAchievementData(); void checkMapScriptsOnVariableSet(); - void updateGlobalStat(int index, int value = 1); + void updateGlobalStat(int index, int player); }; extern AchievementObserver achievementObserver; #endif diff --git a/src/steam.cpp b/src/steam.cpp index 713845f56..b11282f14 100644 --- a/src/steam.cpp +++ b/src/steam.cpp @@ -1212,7 +1212,7 @@ void steamStatisticUpdate(int statisticNum, ESteamStatTypes type, int value) std::min(g_SteamStats[statisticNum].m_iValue, steamStatAchStringsAndMaxVals[statisticNum].second); if ( oldValue == 0 ) { - achievementObserver.updateGlobalStat(STEAM_GSTAT_TUTORIAL_ENTERED); + achievementObserver.updateGlobalStat(STEAM_GSTAT_TUTORIAL_ENTERED, -1); } indicateProgress = false; break;