mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-17 02:50:29 +00:00
feat(Core/Entities): add OnPlayerCanGiveLevel script hook (#21666)
This commit is contained in:
@@ -2476,6 +2476,9 @@ void Player::GiveLevel(uint8 level)
|
||||
if (level == oldLevel)
|
||||
return;
|
||||
|
||||
if (!sScriptMgr->OnPlayerCanGiveLevel(this, level))
|
||||
return;
|
||||
|
||||
if (Guild* guild = GetGuild())
|
||||
guild->UpdateMemberData(this, GUILD_MEMBER_DATA_LEVEL, level);
|
||||
|
||||
|
||||
@@ -915,6 +915,11 @@ bool ScriptMgr::OnPlayerCanResurrect(Player* player)
|
||||
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_RESURRECT, !script->OnPlayerCanResurrect(player));
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnPlayerCanGiveLevel(Player* player, uint8 newLevel)
|
||||
{
|
||||
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_ON_CAN_GIVE_LEVEL, !script->OnPlayerCanGiveLevel(player, newLevel));
|
||||
}
|
||||
|
||||
PlayerScript::PlayerScript(const char* name, std::vector<uint16> enabledHooks)
|
||||
: ScriptObject(name, PLAYERHOOK_END)
|
||||
{
|
||||
|
||||
@@ -208,6 +208,7 @@ enum PlayerHook
|
||||
PLAYERHOOK_ON_BEFORE_UPDATE_SKILL,
|
||||
PLAYERHOOK_ON_UPDATE_SKILL,
|
||||
PLAYERHOOK_CAN_RESURRECT,
|
||||
PLAYERHOOK_ON_CAN_GIVE_LEVEL,
|
||||
PLAYERHOOK_END
|
||||
};
|
||||
|
||||
@@ -782,6 +783,16 @@ public:
|
||||
* @return true if player is authorized to resurect
|
||||
*/
|
||||
virtual bool OnPlayerCanResurrect(Player* /*player*/) { return true; }
|
||||
|
||||
/**
|
||||
* @brief This hook is called, to cancel the normal level up flow
|
||||
*
|
||||
* @param player Contains information about the Player
|
||||
* @param newLevel The new level the player is about to be given
|
||||
*
|
||||
* @return true if player is allowed to gain the new level
|
||||
*/
|
||||
virtual bool OnPlayerCanGiveLevel(Player* /*player*/, uint8 /*newLevel*/) { return true; }
|
||||
};
|
||||
|
||||
#endif
|
||||
|
||||
@@ -463,6 +463,7 @@ public: /* PlayerScript */
|
||||
void OnPlayerBeforeUpdateSkill(Player* player, uint32 skill_id, uint32& value, uint32 max, uint32 step);
|
||||
void OnPlayerUpdateSkill(Player* player, uint32 skillId, uint32 value, uint32 max, uint32 step, uint32 newValue);
|
||||
bool OnPlayerCanResurrect(Player* player);
|
||||
bool OnPlayerCanGiveLevel(Player* player, uint8 newLevel);
|
||||
|
||||
// Anti cheat
|
||||
void AnticheatSetCanFlybyServer(Player* player, bool apply);
|
||||
|
||||
Reference in New Issue
Block a user