feat(Core/Scripting): Add OnPlayerBeforeGetLevelForXPGain hook (#25295)
This commit is contained in:
@@ -18,6 +18,9 @@
|
||||
#include "PlayerScript.h"
|
||||
#include "ScriptMgr.h"
|
||||
#include "ScriptMgrMacros.h"
|
||||
#include "World.h"
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
void ScriptMgr::OnPlayerBeforeDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank)
|
||||
{
|
||||
@@ -930,6 +933,12 @@ void ScriptMgr::OnPlayerLearnTaxiNode(Player const* player, uint32 nodeId)
|
||||
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_LEARN_TAXI_NODE, script->OnPlayerLearnTaxiNode(player, nodeId));
|
||||
}
|
||||
|
||||
void ScriptMgr::OnPlayerBeforeGetLevelForXPGain(Player const* player, uint8& level)
|
||||
{
|
||||
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_BEFORE_GET_LEVEL_FOR_XP_GAIN, script->OnPlayerBeforeGetLevelForXPGain(player, level));
|
||||
level = std::clamp(level, uint8(1), uint8(sWorld->getIntConfig(CONFIG_MAX_PLAYER_LEVEL)));
|
||||
}
|
||||
|
||||
PlayerScript::PlayerScript(const char* name, std::vector<uint16> enabledHooks)
|
||||
: ScriptObject(name, PLAYERHOOK_END)
|
||||
{
|
||||
|
||||
@@ -211,6 +211,7 @@ enum PlayerHook
|
||||
PLAYERHOOK_ON_GIVE_REPUTATION,
|
||||
PLAYERHOOK_ON_GET_REPUTATION_PRICE_DISCOUNT,
|
||||
PLAYERHOOK_ON_LEARN_TAXI_NODE,
|
||||
PLAYERHOOK_ON_BEFORE_GET_LEVEL_FOR_XP_GAIN,
|
||||
PLAYERHOOK_END
|
||||
};
|
||||
|
||||
@@ -829,6 +830,14 @@ public:
|
||||
* @param nodeId The id of the learned taxi node
|
||||
*/
|
||||
virtual void OnPlayerLearnTaxiNode(Player const* /*player*/, uint32 /*nodeId*/) {}
|
||||
|
||||
/**
|
||||
* @brief This hook is called when XP is calculated for the player, and is used to modify the player level used in the XP formulas.
|
||||
*
|
||||
* @param player Contains information about the Player
|
||||
* @param level The level that should be used for XP gain calculations
|
||||
*/
|
||||
virtual void OnPlayerBeforeGetLevelForXPGain(Player const* /*player*/, uint8& /*level*/) {}
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user