feat(Core/Player): Add 'OnPlayerCanLearnTalent' hook (#24826)
This commit is contained in:
@@ -13958,6 +13958,9 @@ void Player::LearnTalent(uint32 talentId, uint32 talentRank, bool command /*= fa
|
|||||||
if (!talentInfo)
|
if (!talentInfo)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (!sScriptMgr->OnPlayerCanLearnTalent(this, talentInfo, talentRank))
|
||||||
|
return;
|
||||||
|
|
||||||
TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
|
TalentTabEntry const* talentTabInfo = sTalentTabStore.LookupEntry(talentInfo->TalentTab);
|
||||||
if (!talentTabInfo)
|
if (!talentTabInfo)
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -109,6 +109,11 @@ void ScriptMgr::OnPlayerTalentsReset(Player* player, bool noCost)
|
|||||||
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_TALENTS_RESET, script->OnPlayerTalentsReset(player, noCost));
|
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_TALENTS_RESET, script->OnPlayerTalentsReset(player, noCost));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptMgr::OnPlayerCanLearnTalent(Player* player, TalentEntry const* talent, uint32 rank)
|
||||||
|
{
|
||||||
|
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_LEARN_TALENT, !script->OnPlayerCanLearnTalent(player, talent, rank));
|
||||||
|
}
|
||||||
|
|
||||||
void ScriptMgr::OnPlayerAfterSpecSlotChanged(Player* player, uint8 newSlot)
|
void ScriptMgr::OnPlayerAfterSpecSlotChanged(Player* player, uint8 newSlot)
|
||||||
{
|
{
|
||||||
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_SPEC_SLOT_CHANGED, script->OnPlayerAfterSpecSlotChanged(player, newSlot));
|
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_AFTER_SPEC_SLOT_CHANGED, script->OnPlayerAfterSpecSlotChanged(player, newSlot));
|
||||||
|
|||||||
@@ -43,6 +43,7 @@ enum PlayerHook
|
|||||||
PLAYERHOOK_ON_LEVEL_CHANGED,
|
PLAYERHOOK_ON_LEVEL_CHANGED,
|
||||||
PLAYERHOOK_ON_FREE_TALENT_POINTS_CHANGED,
|
PLAYERHOOK_ON_FREE_TALENT_POINTS_CHANGED,
|
||||||
PLAYERHOOK_ON_TALENTS_RESET,
|
PLAYERHOOK_ON_TALENTS_RESET,
|
||||||
|
PLAYERHOOK_CAN_LEARN_TALENT,
|
||||||
PLAYERHOOK_ON_AFTER_SPEC_SLOT_CHANGED,
|
PLAYERHOOK_ON_AFTER_SPEC_SLOT_CHANGED,
|
||||||
PLAYERHOOK_ON_BEFORE_UPDATE,
|
PLAYERHOOK_ON_BEFORE_UPDATE,
|
||||||
PLAYERHOOK_ON_UPDATE,
|
PLAYERHOOK_ON_UPDATE,
|
||||||
@@ -260,6 +261,9 @@ public:
|
|||||||
// Called when a player's talent points are reset (right before the reset is done)
|
// Called when a player's talent points are reset (right before the reset is done)
|
||||||
virtual void OnPlayerTalentsReset(Player* /*player*/, bool /*noCost*/) { }
|
virtual void OnPlayerTalentsReset(Player* /*player*/, bool /*noCost*/) { }
|
||||||
|
|
||||||
|
// Called when a player attempts to put a point in a talent.
|
||||||
|
virtual bool OnPlayerCanLearnTalent(Player* /*player*/, TalentEntry const* /*talent*/, uint32 /*rank*/) { return true; }
|
||||||
|
|
||||||
// Called after a player switches specs using the dual spec system
|
// Called after a player switches specs using the dual spec system
|
||||||
virtual void OnPlayerAfterSpecSlotChanged(Player* /*player*/, uint8 /*newSlot*/) { }
|
virtual void OnPlayerAfterSpecSlotChanged(Player* /*player*/, uint8 /*newSlot*/) { }
|
||||||
|
|
||||||
|
|||||||
@@ -308,6 +308,7 @@ public: /* PlayerScript */
|
|||||||
void OnPlayerLevelChanged(Player* player, uint8 oldLevel);
|
void OnPlayerLevelChanged(Player* player, uint8 oldLevel);
|
||||||
void OnPlayerFreeTalentPointsChanged(Player* player, uint32 newPoints);
|
void OnPlayerFreeTalentPointsChanged(Player* player, uint32 newPoints);
|
||||||
void OnPlayerTalentsReset(Player* player, bool noCost);
|
void OnPlayerTalentsReset(Player* player, bool noCost);
|
||||||
|
bool OnPlayerCanLearnTalent(Player* player, TalentEntry const* talent, uint32 rank);
|
||||||
void OnPlayerAfterSpecSlotChanged(Player* player, uint8 newSlot);
|
void OnPlayerAfterSpecSlotChanged(Player* player, uint8 newSlot);
|
||||||
void OnPlayerMoneyChanged(Player* player, int32& amount);
|
void OnPlayerMoneyChanged(Player* player, int32& amount);
|
||||||
void OnPlayerBeforeLootMoney(Player* player, Loot* loot);
|
void OnPlayerBeforeLootMoney(Player* player, Loot* loot);
|
||||||
|
|||||||
Reference in New Issue
Block a user