mirror of
https://github.com/liyunfan1223/azerothcore-wotlk.git
synced 2026-08-08 15:58:04 +00:00
Gossip script for items
This commit is contained in:
@@ -9080,6 +9080,12 @@ GameObjectTemplate const* ObjectMgr::GetGameObjectTemplate(uint32 entry)
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Player* ObjectMgr::GetPlayerByLowGUID(uint32 lowguid) const
|
||||||
|
{
|
||||||
|
uint64 guid = MAKE_NEW_GUID(lowguid, 0, HIGHGUID_PLAYER);
|
||||||
|
return ObjectAccessor::FindPlayer(guid);
|
||||||
|
}
|
||||||
|
|
||||||
bool ObjectMgr::IsGameObjectStaticTransport(uint32 entry)
|
bool ObjectMgr::IsGameObjectStaticTransport(uint32 entry)
|
||||||
{
|
{
|
||||||
GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
|
GameObjectTemplate const* goinfo = GetGameObjectTemplate(entry);
|
||||||
|
|||||||
@@ -666,6 +666,8 @@ class ObjectMgr
|
|||||||
|
|
||||||
typedef std::map<uint32, uint32> CharacterConversionMap;
|
typedef std::map<uint32, uint32> CharacterConversionMap;
|
||||||
|
|
||||||
|
Player* GetPlayerByLowGUID(uint32 lowguid) const;
|
||||||
|
|
||||||
GameObjectTemplate const* GetGameObjectTemplate(uint32 entry);
|
GameObjectTemplate const* GetGameObjectTemplate(uint32 entry);
|
||||||
bool IsGameObjectStaticTransport(uint32 entry);
|
bool IsGameObjectStaticTransport(uint32 entry);
|
||||||
GameObjectTemplateContainer const* GetGameObjectTemplates() const { return &_gameObjectTemplateStore; }
|
GameObjectTemplateContainer const* GetGameObjectTemplates() const { return &_gameObjectTemplateStore; }
|
||||||
@@ -687,6 +689,18 @@ class ObjectMgr
|
|||||||
ItemTemplate const* GetItemTemplate(uint32 entry);
|
ItemTemplate const* GetItemTemplate(uint32 entry);
|
||||||
ItemTemplateContainer const* GetItemTemplateStore() const { return &_itemTemplateStore; }
|
ItemTemplateContainer const* GetItemTemplateStore() const { return &_itemTemplateStore; }
|
||||||
|
|
||||||
|
ItemLocale const* GetItemLocale(uint32 entry) const
|
||||||
|
{
|
||||||
|
ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry);
|
||||||
|
if (itr == _itemLocaleStore.end()) return NULL;
|
||||||
|
return &itr->second;
|
||||||
|
}
|
||||||
|
ItemSetNameLocale const* GetItemSetNameLocale(uint32 entry) const
|
||||||
|
{
|
||||||
|
ItemSetNameLocaleContainer::const_iterator itr = _itemSetNameLocaleStore.find(entry);
|
||||||
|
if (itr == _itemSetNameLocaleStore.end())return NULL;
|
||||||
|
return &itr->second;
|
||||||
|
}
|
||||||
ItemSetNameEntry const* GetItemSetNameEntry(uint32 itemId)
|
ItemSetNameEntry const* GetItemSetNameEntry(uint32 itemId)
|
||||||
{
|
{
|
||||||
ItemSetNameContainer::iterator itr = _itemSetNameStore.find(itemId);
|
ItemSetNameContainer::iterator itr = _itemSetNameStore.find(itemId);
|
||||||
@@ -1164,6 +1178,11 @@ class ObjectMgr
|
|||||||
GraveyardContainer GraveyardStore;
|
GraveyardContainer GraveyardStore;
|
||||||
|
|
||||||
static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data);
|
static void AddLocaleString(std::string const& s, LocaleConstant locale, StringVector& data);
|
||||||
|
static inline void GetLocaleString(const StringVector& data, int loc_idx, std::string& value)
|
||||||
|
{
|
||||||
|
if (data.size() > size_t(loc_idx) && !data[loc_idx].empty())
|
||||||
|
value = data[loc_idx];
|
||||||
|
}
|
||||||
|
|
||||||
CharacterConversionMap FactionChangeAchievements;
|
CharacterConversionMap FactionChangeAchievements;
|
||||||
CharacterConversionMap FactionChangeItems;
|
CharacterConversionMap FactionChangeItems;
|
||||||
|
|||||||
@@ -101,6 +101,7 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
|
|||||||
|
|
||||||
Creature* unit = NULL;
|
Creature* unit = NULL;
|
||||||
GameObject* go = NULL;
|
GameObject* go = NULL;
|
||||||
|
Item* item = NULL;
|
||||||
if (IS_CRE_OR_VEH_GUID(guid))
|
if (IS_CRE_OR_VEH_GUID(guid))
|
||||||
{
|
{
|
||||||
unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
|
unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_NONE);
|
||||||
@@ -119,6 +120,23 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (IS_ITEM_GUID(guid))
|
||||||
|
{
|
||||||
|
item = _player->GetItemByGuid(guid);
|
||||||
|
if (!item || _player->IsBankPos(item->GetPos()))
|
||||||
|
{
|
||||||
|
//TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - %s not found.", guid.ToString().c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else if (IS_PLAYER_GUID(guid))
|
||||||
|
{
|
||||||
|
if (guid != _player->GetGUID() || menuId != _player->PlayerTalkClass->GetGossipMenu().GetMenuId())
|
||||||
|
{
|
||||||
|
//TC_LOG_DEBUG("network", "WORLD: HandleGossipSelectOptionOpcode - %s not found.", guid.ToString().c_str());
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u.", uint32(GUID_HIPART(guid)), uint32(GUID_LOPART(guid)));
|
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleGossipSelectOptionOpcode - unsupported GUID type for highguid %u. lowpart %u.", uint32(GUID_HIPART(guid)), uint32(GUID_LOPART(guid)));
|
||||||
@@ -147,11 +165,19 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
|
|||||||
if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str()))
|
if (!sScriptMgr->OnGossipSelectCode(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId), code.c_str()))
|
||||||
_player->OnGossipSelect(unit, gossipListId, menuId);
|
_player->OnGossipSelect(unit, gossipListId, menuId);
|
||||||
}
|
}
|
||||||
else
|
else if (go)
|
||||||
{
|
{
|
||||||
go->AI()->GossipSelectCode(_player, menuId, gossipListId, code.c_str());
|
go->AI()->GossipSelectCode(_player, menuId, gossipListId, code.c_str());
|
||||||
sScriptMgr->OnGossipSelectCode(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(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
|
else
|
||||||
{
|
{
|
||||||
@@ -161,12 +187,20 @@ void WorldSession::HandleGossipSelectOptionOpcode(WorldPacket & recv_data)
|
|||||||
if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
|
if (!sScriptMgr->OnGossipSelect(_player, unit, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
|
||||||
_player->OnGossipSelect(unit, gossipListId, menuId);
|
_player->OnGossipSelect(unit, gossipListId, menuId);
|
||||||
}
|
}
|
||||||
else
|
else if (go)
|
||||||
{
|
{
|
||||||
go->AI()->GossipSelect(_player, menuId, gossipListId);
|
go->AI()->GossipSelect(_player, menuId, gossipListId);
|
||||||
if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
|
if (!sScriptMgr->OnGossipSelect(_player, go, _player->PlayerTalkClass->GetGossipOptionSender(gossipListId), _player->PlayerTalkClass->GetGossipOptionAction(gossipListId)))
|
||||||
_player->OnGossipSelect(go, gossipListId, menuId);
|
_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));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user