Skip to content

Commit

Permalink
* stat update with player
Browse files Browse the repository at this point in the history
  • Loading branch information
WALL OF JUSTICE committed Oct 25, 2024
1 parent dd560ae commit e51c067
Show file tree
Hide file tree
Showing 10 changed files with 30 additions and 20 deletions.
2 changes: 1 addition & 1 deletion src/actboulder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
Expand Down
4 changes: 2 additions & 2 deletions src/actladder.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<int>(STEAM_GSTAT_TUTORIAL10_COMPLETED)));
std::min(STEAM_GSTAT_TUTORIAL1_COMPLETED - 1 + number, static_cast<int>(STEAM_GSTAT_TUTORIAL10_COMPLETED)), -1);
achievementObserver.updateGlobalStat(
std::min(STEAM_GSTAT_TUTORIAL1_ATTEMPTS - 1 + number, static_cast<int>(STEAM_GSTAT_TUTORIAL10_ATTEMPTS)));
std::min(STEAM_GSTAT_TUTORIAL1_ATTEMPTS - 1 + number, static_cast<int>(STEAM_GSTAT_TUTORIAL10_ATTEMPTS)), -1);
}
completionTime = 0;
gameModeManager.Tutorial.writeToDocument();
Expand Down
14 changes: 7 additions & 7 deletions src/entity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand All @@ -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]);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand Down
2 changes: 1 addition & 1 deletion src/mod_tools.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2619,7 +2619,7 @@ class GameModeManager_t
{
#ifndef EDITOR
achievementObserver.updateGlobalStat(
std::min(STEAM_GSTAT_TUTORIAL1_ATTEMPTS - 1 + levelNum, static_cast<int>(STEAM_GSTAT_TUTORIAL10_ATTEMPTS)));
std::min(STEAM_GSTAT_TUTORIAL1_ATTEMPTS - 1 + levelNum, static_cast<int>(STEAM_GSTAT_TUTORIAL10_ATTEMPTS)), -1);
#endif // !EDITOR
}

Expand Down
14 changes: 12 additions & 2 deletions src/playfab.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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);
}
Expand Down
2 changes: 1 addition & 1 deletion src/playfab.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down
6 changes: 3 additions & 3 deletions src/scores.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 )
{
Expand All @@ -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
}

Expand Down
2 changes: 1 addition & 1 deletion src/scores.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion src/steam.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit e51c067

Please sign in to comment.