mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-02-16 16:56:07 +00:00
feat(Scripting/Hooks): Add OnBeforeOpenItem Hook (#12576)
This commit is contained in:
@@ -598,6 +598,21 @@ void ScriptMgr::OnGroupRollRewardItem(Player* player, Item* item, uint32 count,
|
||||
});
|
||||
}
|
||||
|
||||
bool ScriptMgr::OnBeforeOpenItem(Player* player, Item* item)
|
||||
{
|
||||
auto ret = IsValidBoolScript<PlayerScript>([&](PlayerScript* script)
|
||||
{
|
||||
return !script->OnBeforeOpenItem(player, item);
|
||||
});
|
||||
|
||||
if (ret && *ret)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void ScriptMgr::OnFirstLogin(Player* player)
|
||||
{
|
||||
ExecuteScript<PlayerScript>([&](PlayerScript* script)
|
||||
|
||||
@@ -1176,6 +1176,9 @@ public:
|
||||
// After receiving item as a group roll reward
|
||||
virtual void OnGroupRollRewardItem(Player* /*player*/, Item* /*item*/, uint32 /*count*/, RollVote /*voteType*/, Roll* /*roll*/) { }
|
||||
|
||||
//Before opening an item
|
||||
[[nodiscard]] virtual bool OnBeforeOpenItem(Player* /*player*/, Item* /*item*/) { return true; }
|
||||
|
||||
// After completed a quest
|
||||
[[nodiscard]] virtual bool OnBeforeQuestComplete(Player* /*player*/, uint32 /*quest_id*/) { return true; }
|
||||
|
||||
@@ -2252,6 +2255,7 @@ public: /* PlayerScript */
|
||||
void OnCreateItem(Player* player, Item* item, uint32 count);
|
||||
void OnQuestRewardItem(Player* player, Item* item, uint32 count);
|
||||
void OnGroupRollRewardItem(Player* player, Item* item, uint32 count, RollVote voteType, Roll* roll);
|
||||
bool OnBeforeOpenItem(Player* player, Item* item);
|
||||
bool OnBeforePlayerQuestComplete(Player* player, uint32 quest_id);
|
||||
void OnQuestComputeXP(Player* player, Quest const* quest, uint32& xpValue);
|
||||
void OnBeforePlayerDurabilityRepair(Player* player, ObjectGuid npcGUID, ObjectGuid itemGUID, float& discountMod, uint8 guildBank);
|
||||
|
||||
Reference in New Issue
Block a user