mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-24 06:06:23 +00:00
feat(Core/Hooks): Add parameter to detect XP origin for OnGiveXP hook. (#16109)
Added enum parameter to detect where XP originated from.
This commit is contained in:
@@ -166,6 +166,7 @@ void KillRewarder::_RewardXP(Player* player, float rate)
|
||||
AddPct(xp, (*i)->GetAmount());
|
||||
|
||||
// 4.2.3. Give XP to player.
|
||||
sScriptMgr->OnGivePlayerXP(player, xp, _victim, PlayerXPSource::XPSOURCE_KILL);
|
||||
player->GiveXP(xp, _victim, _groupRate);
|
||||
if (Pet* pet = player->GetPet())
|
||||
// 4.2.4. If player has pet, reward pet with XP (100% for single player, 50% for group case).
|
||||
|
||||
@@ -2372,8 +2372,6 @@ void Player::GiveXP(uint32 xp, Unit* victim, float group_rate, bool isLFGReward)
|
||||
|
||||
uint8 level = GetLevel();
|
||||
|
||||
sScriptMgr->OnGivePlayerXP(this, xp, victim);
|
||||
|
||||
// Favored experience increase START
|
||||
uint32 zone = GetZoneId();
|
||||
float favored_exp_mult = 0;
|
||||
@@ -5730,6 +5728,7 @@ void Player::CheckAreaExploreAndOutdoor()
|
||||
XP = uint32(sObjectMgr->GetBaseXP(areaEntry->area_level) * sWorld->getRate(RATE_XP_EXPLORE));
|
||||
}
|
||||
|
||||
sScriptMgr->OnGivePlayerXP(this, XP, nullptr, PlayerXPSource::XPSOURCE_EXPLORE);
|
||||
GiveXP(XP, nullptr);
|
||||
SendExplorationExperience(areaId, XP);
|
||||
}
|
||||
@@ -6119,7 +6118,11 @@ bool Player::RewardHonor(Unit* uVictim, uint32 groupsize, int32 honor, bool awar
|
||||
bg->UpdatePlayerScore(this, SCORE_BONUS_HONOR, honor, false); //false: prevent looping
|
||||
// Xinef: Only for BG activities
|
||||
if (!uVictim)
|
||||
GiveXP(uint32(honor * (3 + GetLevel() * 0.30f)), nullptr);
|
||||
{
|
||||
uint32 xp = uint32(honor * (3 + GetLevel() * 0.30f));
|
||||
sScriptMgr->OnGivePlayerXP(this, xp, nullptr, PlayerXPSource::XPSOURCE_BATTLEGROUND);
|
||||
GiveXP(xp, nullptr);
|
||||
}
|
||||
}
|
||||
|
||||
if (sWorld->getBoolConfig(CONFIG_PVP_TOKEN_ENABLE))
|
||||
|
||||
@@ -995,6 +995,16 @@ enum PlayerCommandStates
|
||||
CHEAT_WATERWALK = 0x10
|
||||
};
|
||||
|
||||
// Used for OnGiveXP PlayerScript hook
|
||||
enum PlayerXPSource
|
||||
{
|
||||
XPSOURCE_KILL = 0,
|
||||
XPSOURCE_QUEST = 1,
|
||||
XPSOURCE_QUEST_DF = 2,
|
||||
XPSOURCE_EXPLORE = 3,
|
||||
XPSOURCE_BATTLEGROUND = 4
|
||||
};
|
||||
|
||||
enum InstantFlightGossipAction
|
||||
{
|
||||
GOSSIP_ACTION_TOGGLE_INSTANT_FLIGHT = 500
|
||||
|
||||
@@ -756,6 +756,7 @@ void Player::RewardQuest(Quest const* quest, uint32 reward, Object* questGiver,
|
||||
}
|
||||
else
|
||||
{
|
||||
sScriptMgr->OnGivePlayerXP(this, XP, nullptr, isLFGReward ? PlayerXPSource::XPSOURCE_QUEST_DF : PlayerXPSource::XPSOURCE_QUEST);
|
||||
GiveXP(XP, nullptr, isLFGReward);
|
||||
}
|
||||
|
||||
|
||||
@@ -154,11 +154,11 @@ void ScriptMgr::OnBeforeLootMoney(Player* player, Loot* loot)
|
||||
});
|
||||
}
|
||||
|
||||
void ScriptMgr::OnGivePlayerXP(Player* player, uint32& amount, Unit* victim)
|
||||
void ScriptMgr::OnGivePlayerXP(Player* player, uint32& amount, Unit* victim, uint8 xpSource)
|
||||
{
|
||||
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
||||
{
|
||||
script->OnGiveXP(player, amount, victim);
|
||||
script->OnGiveXP(player, amount, victim, xpSource);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -1035,7 +1035,7 @@ public:
|
||||
virtual void OnBeforeLootMoney(Player* /*player*/, Loot* /*loot*/) {}
|
||||
|
||||
// Called when a player gains XP (before anything is given)
|
||||
virtual void OnGiveXP(Player* /*player*/, uint32& /*amount*/, Unit* /*victim*/) { }
|
||||
virtual void OnGiveXP(Player* /*player*/, uint32& /*amount*/, Unit* /*victim*/, uint8 /*xpSource*/) { }
|
||||
|
||||
// Called when a player's reputation changes (before it is actually changed)
|
||||
virtual bool OnReputationChange(Player* /*player*/, uint32 /*factionID*/, int32& /*standing*/, bool /*incremental*/) { return true; }
|
||||
@@ -2240,7 +2240,7 @@ public: /* PlayerScript */
|
||||
void OnPlayerTalentsReset(Player* player, bool noCost);
|
||||
void OnPlayerMoneyChanged(Player* player, int32& amount);
|
||||
void OnBeforeLootMoney(Player* player, Loot* loot);
|
||||
void OnGivePlayerXP(Player* player, uint32& amount, Unit* victim);
|
||||
void OnGivePlayerXP(Player* player, uint32& amount, Unit* victim, uint8 xpSource);
|
||||
bool OnPlayerReputationChange(Player* player, uint32 factionID, int32& standing, bool incremental);
|
||||
void OnPlayerReputationRankChange(Player* player, uint32 factionID, ReputationRank newRank, ReputationRank oldRank, bool increased);
|
||||
void OnPlayerLearnSpell(Player* player, uint32 spellID);
|
||||
|
||||
Reference in New Issue
Block a user