Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(SoloCraft): Limit XP modification to instances only #49

Merged
merged 1 commit into from
Aug 21, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 19 additions & 2 deletions src/Solocraft.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "Chat.h"
#include <math.h>
#include <unordered_map>
#include "ObjectGuid.h"

bool SoloCraftEnable = 1;
bool SoloCraftAnnounceModule = 1;
Expand Down Expand Up @@ -309,6 +310,9 @@ class SolocraftConfig : public WorldScript

class SolocraftAnnounce : public PlayerScript
{
private:
std::map<ObjectGuid, bool> playerInInstanceMap;

public:
SolocraftAnnounce() : PlayerScript("SolocraftAnnounce") {}

Expand All @@ -328,11 +332,24 @@ class SolocraftAnnounce : public PlayerScript
//Remove database entry as the player has logged out
CharacterDatabase.Execute("DELETE FROM `custom_solocraft_character_stats` WHERE `GUID`={}", player->GetGUID().GetCounter());
}
playerInInstanceMap.erase(player->GetGUID());
}

void OnMapChanged(Player* player) override
{
if (player->GetMap()->IsDungeon() || player->GetMap()->IsRaid())
{
playerInInstanceMap[player->GetGUID()] = true;
}
else
{
playerInInstanceMap[player->GetGUID()] = false;
}
}

void OnGiveXP(Player* /*player*/, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
void OnGiveXP(Player* player, uint32& amount, Unit* /*victim*/, uint8 /*xpSource*/) override
{
if (SolocraftXPBalEnabled)
if (SolocraftXPBalEnabled && playerInInstanceMap[player->GetGUID()])
{
// Decrease Experience based on number of players and difficulty of instance (0 to 100%)
amount = uint32(amount * SoloCraftXPMod);
Expand Down