Через базу я не знаю как, но в ядре это делается очень легко. Требуется патч в ядро.
diff -r 1851f28ea31f -r e33b6a1e67eb src/server/game/Handlers/MiscHandler.cpp --- a/src/server/game/Handlers/MiscHandler.cpp Sun Mar 01 12:58:05 2015 +0400 +++ b/src/server/game/Handlers/MiscHandler.cpp Sun Mar 01 12:58:18 2015 +0400 @@ -96,6 +96,7 @@ if (_player->PlayerTalkClass->IsGossipOptionCoded(gossipListId)) recv_data >> code; + Item* item = NULL; Creature* unit = NULL; GameObject* go = NULL; if (IS_CRE_OR_VEH_GUID(guid)) @@ -116,6 +117,23 @@ return; } } + else if (IS_ITEM_GUID(guid)) + { + item = _player->GetItemByGuid(guid); + if (!item || _player->IsBankPos(item->GetPos())) + { + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - Item (GUID: %u) not found.", uint32(GUID_LOPART(guid))); + return; + } + } + else if (IS_PLAYER_GUID(guid)) + { + if (guid != _player->GetGUID() || menuId != _player->PlayerTalkClass->GetGossipMenu().GetMenuId()) + { + sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - Player (GUID: %u) invalid.", uint32(GUID_LOPART(guid))); + return; + } + } else { sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u.", uint32(GUID_HIPART(guid)), uint32(GUID_LOPART(guid))); @@ -145,11 +163,19 @@ if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str())) _player->OnGossipSelect(unit, gossipListId, menuId); } - else + else if (go) { go->AI()->GossipSelectCode(_player, menuId, gossipListId, code.c_str()); sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str()); } + else if (item) + { + sScriptMgr->OnGossipSelectCode(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str()); + } + else + { + sScriptMgr->OnGossipSelectCode(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str()); + } } else { @@ -159,12 +185,20 @@ if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId))) _player->OnGossipSelect(unit, gossipListId, menuId); } - else + else if (go) { go->AI()->GossipSelect(_player, menuId, gossipListId); if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId))) _player->OnGossipSelect(go, gossipListId, menuId); } + else if (item) + { + sScriptMgr->OnGossipSelect(_player, item, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)); + } + else + { + sScriptMgr->OnGossipSelect(_player, menuId, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)); + } } } diff -r 1851f28ea31f -r e33b6a1e67eb src/server/game/Scripting/ScriptMgr.cpp --- a/src/server/game/Scripting/ScriptMgr.cpp Sun Mar 01 12:58:05 2015 +0400 +++ b/src/server/game/Scripting/ScriptMgr.cpp Sun Mar 01 12:58:18 2015 +0400 @@ -751,6 +751,24 @@ return tmpscript->OnExpire(player, proto); } +void ScriptMgr::OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action) +{ + ASSERT(player); + ASSERT(item); + + GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript); + tmpscript->OnGossipSelect(player, item, sender, action); +} + +void ScriptMgr::OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code) +{ + ASSERT(player); + ASSERT(item); + + GET_SCRIPT(ItemScript, item->GetScriptId(), tmpscript); + tmpscript->OnGossipSelectCode(player, item, sender, action, code); +} + bool ScriptMgr::OnDummyEffect(Unit* caster, uint32 spellId, SpellEffIndex effIndex, Creature* target) { ASSERT(caster); @@ -1355,6 +1373,16 @@ FOREACH_SCRIPT(PlayerScript)->OnUpdateZone(player, newZone, newArea); } +void ScriptMgr::OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action) +{ + FOREACH_SCRIPT(PlayerScript)->OnGossipSelect(player, menu_id, sender, action); +} + +void ScriptMgr::OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code) +{ + FOREACH_SCRIPT(PlayerScript)->OnGossipSelectCode(player, menu_id, sender, action, code); +} + void ScriptMgr::OnPlayerJoinedBattleground(Player* player, Battleground* bg) { FOREACH_SCRIPT(PlayerScript)->OnPlayerJoinedBattleground(player, bg); diff -r 1851f28ea31f -r e33b6a1e67eb src/server/game/Scripting/ScriptMgr.h --- a/src/server/game/Scripting/ScriptMgr.h Sun Mar 01 12:58:05 2015 +0400 +++ b/src/server/game/Scripting/ScriptMgr.h Sun Mar 01 12:58:18 2015 +0400 @@ -393,6 +393,12 @@ // Called when the item expires (is destroyed). virtual bool OnExpire(Player* /*player*/, ItemTemplate const* /*proto*/) { return false; } + + // Called when a player selects an option in an item gossip window + virtual void OnGossipSelect(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/) { } + + // Called when a player selects an option in an item gossip window + virtual void OnGossipSelectCode(Player* /*player*/, Item* /*item*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { } }; class CreatureScript : public ScriptObject, public UpdatableScript<Creature> @@ -761,6 +767,12 @@ // Called when a player switches to a new zone virtual void OnUpdateZone(Player* /*player*/, uint32 /*newZone*/, uint32 /*newArea*/) { } + // Called when a player selects an option in a player gossip window + virtual void OnGossipSelect(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/) { } + + // Called when a player selects an option in a player gossip window + virtual void OnGossipSelectCode(Player* /*player*/, uint32 /*menu_id*/, uint32 /*sender*/, uint32 /*action*/, const char* /*code*/) { } + // Called when a player joined the battle virtual void OnPlayerJoinedBattleground(Player* /*player*/, Battleground* /*bg*/) { } @@ -922,6 +934,8 @@ bool OnQuestAccept(Player* player, Item* item, Quest const* quest); bool OnItemUse(Player* player, Item* item, SpellCastTargets const& targets); bool OnItemExpire(Player* player, ItemTemplate const* proto); + void OnGossipSelect(Player* player, Item* item, uint32 sender, uint32 action); + void OnGossipSelectCode(Player* player, Item* item, uint32 sender, uint32 action, const char* code); public: /* CreatureScript */ @@ -1049,6 +1063,8 @@ void OnPlayerFirstKillBattleground(Player* player, Battleground* bg); void OnPlayerBindToInstance(Player* player, Difficulty difficulty, uint32 mapid, bool permanent); void OnPlayerUpdateZone(Player* player, uint32 newZone, uint32 newArea); + void OnGossipSelect(Player* player, uint32 menu_id, uint32 sender, uint32 action); + void OnGossipSelectCode(Player* player, uint32 menu_id, uint32 sender, uint32 action, const char* code); public: /* GuildScript */
Сообщение #
5 отредактировано
_xXx_ -
Четверг, 05.03.2015, 20:30