Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(Core/Entities): Add OnPlayerSendListInventory script hook #21676

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/server/game/Handlers/ItemHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1036,6 +1036,8 @@ void WorldSession::SendListInventory(ObjectGuid vendorGuid, uint32 vendorEntry)
{
LOG_DEBUG("network", "WORLD: Sent SMSG_LIST_INVENTORY");

sScriptMgr->OnPlayerSendInventoryList(GetPlayer(), vendorGuid, vendorEntry);

Creature* vendor = GetPlayer()->GetNPCIfCanInteractWith(vendorGuid, UNIT_NPC_FLAG_VENDOR);
if (!vendor)
{
Expand Down
5 changes: 5 additions & 0 deletions src/server/game/Scripting/ScriptDefines/PlayerScript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -915,6 +915,11 @@ bool ScriptMgr::OnPlayerCanResurrect(Player* player)
CALL_ENABLED_BOOLEAN_HOOKS(PlayerScript, PLAYERHOOK_CAN_RESURRECT, !script->OnPlayerCanResurrect(player));
}

void ScriptMgr::OnPlayerSendInventoryList(Player* player, ObjectGuid vendorGuid, uint32 vendorEntry)
{
CALL_ENABLED_HOOKS(PlayerScript, PLAYERHOOK_ON_SEND_INVENTORY_LIST, script->OnPlayerSendInventoryList(player, vendorGuid, vendorEntry));
}

PlayerScript::PlayerScript(const char* name, std::vector<uint16> enabledHooks)
: ScriptObject(name, PLAYERHOOK_END)
{
Expand Down
10 changes: 10 additions & 0 deletions src/server/game/Scripting/ScriptDefines/PlayerScript.h
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,7 @@ enum PlayerHook
PLAYERHOOK_ON_BEFORE_UPDATE_SKILL,
PLAYERHOOK_ON_UPDATE_SKILL,
PLAYERHOOK_CAN_RESURRECT,
PLAYERHOOK_ON_SEND_INVENTORY_LIST,
PLAYERHOOK_END
};

Expand Down Expand Up @@ -782,6 +783,15 @@ class PlayerScript : public ScriptObject
* @return true if player is authorized to resurect
*/
virtual bool OnPlayerCanResurrect(Player* /*player*/) { return true; }

/**
* @brief This hook is called whenever a player interacts with a vendor, and is then shown the vendor list
*
* @param player Contains information about the Player
* @param vendorGuid Guid of the vendor player is interacting with
* @param vendorEntry Entry of the vendor player is interacting with
*/
virtual void OnPlayerSendInventoryList(Player* /*player*/, ObjectGuid /*vendorGuid*/, uint32 /*vendorEntry*/) {}
};

#endif
1 change: 1 addition & 0 deletions src/server/game/Scripting/ScriptMgr.h
Original file line number Diff line number Diff line change
Expand Up @@ -463,6 +463,7 @@ class ScriptMgr
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);
void OnPlayerSendInventoryList(Player* player, ObjectGuid vendorGuid, uint32 vendorEntry);

// Anti cheat
void AnticheatSetCanFlybyServer(Player* player, bool apply);
Expand Down