mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
feat(Core/Scripting): Implement OnAllowedToLootContainerCheck() hook (#17209)
* chore(Core/Loot): Move OnAllowedForPlayerLootCheck() hook call up * Revert "chore(Core/Loot): Move OnAllowedForPlayerLootCheck() hook call up" This reverts commit f841ef9da313976179fb788d9573ff8ced05ecb9. * feat(Core/Scripting): Implement OnAllowedToLootContainerCheck() hook * Update GlobalScript.cpp
This commit is contained in:
@@ -8041,6 +8041,12 @@ void Player::SendLoot(ObjectGuid guid, LootType loot_type)
|
|||||||
// need know merged fishing/corpse loot type for achievements
|
// need know merged fishing/corpse loot type for achievements
|
||||||
loot->loot_type = loot_type;
|
loot->loot_type = loot_type;
|
||||||
|
|
||||||
|
if (!sScriptMgr->OnAllowedToLootContainerCheck(this, guid))
|
||||||
|
{
|
||||||
|
SendLootError(guid, LOOT_ERROR_DIDNT_KILL);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (permission != NONE_PERMISSION)
|
if (permission != NONE_PERMISSION)
|
||||||
{
|
{
|
||||||
SetLootGUID(guid);
|
SetLootGUID(guid);
|
||||||
|
|||||||
@@ -178,6 +178,21 @@ bool ScriptMgr::OnAllowedForPlayerLootCheck(Player const* player, ObjectGuid sou
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool ScriptMgr::OnAllowedToLootContainerCheck(Player const* player, ObjectGuid source)
|
||||||
|
{
|
||||||
|
auto ret = IsValidBoolScript<GlobalScript>([&](GlobalScript* script)
|
||||||
|
{
|
||||||
|
return script->OnAllowedToLootContainerCheck(player, source);
|
||||||
|
});
|
||||||
|
|
||||||
|
if (ret && *ret)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Called when an instance Id is deleted, usually because it expired or no players are bound to it anymore.
|
* @brief Called when an instance Id is deleted, usually because it expired or no players are bound to it anymore.
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1646,9 +1646,12 @@ public:
|
|||||||
// Called after loading spell dbc corrections
|
// Called after loading spell dbc corrections
|
||||||
virtual void OnLoadSpellCustomAttr(SpellInfo* /*spell*/) { }
|
virtual void OnLoadSpellCustomAttr(SpellInfo* /*spell*/) { }
|
||||||
|
|
||||||
// Called when checking if a player can see the creature loot
|
// Called when checking if a player can see the creature loot item
|
||||||
virtual bool OnAllowedForPlayerLootCheck(Player const* /*player*/, ObjectGuid /*source*/) { return false; };
|
virtual bool OnAllowedForPlayerLootCheck(Player const* /*player*/, ObjectGuid /*source*/) { return false; };
|
||||||
|
|
||||||
|
// Called when checking if a player can see the creature loot (if it can click the corpse f.e)
|
||||||
|
virtual bool OnAllowedToLootContainerCheck(Player const* /*player*/, ObjectGuid /*source*/) { return false; };
|
||||||
|
|
||||||
// Called when instance id is removed from database (e.g. instance reset)
|
// Called when instance id is removed from database (e.g. instance reset)
|
||||||
virtual void OnInstanceIdRemoved(uint32 /*instanceId*/) { }
|
virtual void OnInstanceIdRemoved(uint32 /*instanceId*/) { }
|
||||||
|
|
||||||
@@ -2494,6 +2497,7 @@ public: /* GlobalScript */
|
|||||||
bool OnSpellHealingBonusTakenNegativeModifiers(Unit const* target, Unit const* caster, SpellInfo const* spellInfo, float& val);
|
bool OnSpellHealingBonusTakenNegativeModifiers(Unit const* target, Unit const* caster, SpellInfo const* spellInfo, float& val);
|
||||||
void OnLoadSpellCustomAttr(SpellInfo* spell);
|
void OnLoadSpellCustomAttr(SpellInfo* spell);
|
||||||
bool OnAllowedForPlayerLootCheck(Player const* player, ObjectGuid source);
|
bool OnAllowedForPlayerLootCheck(Player const* player, ObjectGuid source);
|
||||||
|
bool OnAllowedToLootContainerCheck(Player const* player, ObjectGuid source);
|
||||||
void OnInstanceIdRemoved(uint32 instanceId);
|
void OnInstanceIdRemoved(uint32 instanceId);
|
||||||
void OnBeforeSetBossState(uint32 id, EncounterState newState, EncounterState oldState, Map* instance);
|
void OnBeforeSetBossState(uint32 id, EncounterState newState, EncounterState oldState, Map* instance);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user