Core/Creature: Add support for multiple gossip menu IDs (#472)
* Core/Creature: Add support for multiple gossip menu IDs Adds support for assigning multiple gossip menu IDs to creatures and controlling them through conditions. Cherry-picked and adapted from: https://github.com/TrinityCore/TrinityCore/commit/36044a9470e9c39a71916e908ab6cf4f95677793 Also disables StormLib automatic static linking. StormLib fix suggested by @brian8544 on Discord. * merge prep --------- Co-authored-by: Ovahlord <18347559+Ovahlord@users.noreply.github.com>
This commit is contained in:
1 parent
30aab19ce5
commit
9da95e6cc9
15 files changed
+199
-96
No files matched your search
@@ -13385,7 +13385,7 @@ void Player::PrepareGossipMenu(WorldObject* source, uint32 menuId /*= 0*/, bool
|
||||
GossipMenuItemsMapBounds menuItemBounds = sObjectMgr->GetGossipMenuItemsMapBounds(menuId);
|
||||
|
||||
// if default menuId and no menu options exist for this, use options from default options
|
||||
if (menuItemBounds.first == menuItemBounds.second && menuId == GetDefaultGossipMenuForSource(source))
|
||||
if (menuItemBounds.first == menuItemBounds.second && menuId == GetGossipMenuForSource(source))
|
||||
menuItemBounds = sObjectMgr->GetGossipMenuItemsMapBounds(0);
|
||||
|
||||
uint32 npcflags = 0;
|
||||
@@ -13701,7 +13701,7 @@ uint32 Player::GetGossipTextId(WorldObject* source)
|
||||
if (!source)
|
||||
return DEFAULT_GOSSIP_MESSAGE;
|
||||
|
||||
return GetGossipTextId(GetDefaultGossipMenuForSource(source), source);
|
||||
return GetGossipTextId(GetGossipMenuForSource(source), source);
|
||||
}
|
||||
|
||||
uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* source)
|
||||
@@ -13715,6 +13715,10 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* source)
|
||||
|
||||
for (GossipMenusContainer::const_iterator itr = menuBounds.first; itr != menuBounds.second; ++itr)
|
||||
{
|
||||
// continue if only checks menuid instead of text
|
||||
if (!itr->second.TextID)
|
||||
continue;
|
||||
|
||||
if (sConditionMgr->IsObjectMeetToConditions(this, source, itr->second.Conditions))
|
||||
textId = itr->second.TextID;
|
||||
}
|
||||
@@ -13722,12 +13726,33 @@ uint32 Player::GetGossipTextId(uint32 menuId, WorldObject* source)
|
||||
return textId;
|
||||
}
|
||||
|
||||
uint32 Player::GetDefaultGossipMenuForSource(WorldObject* source)
|
||||
uint32 Player::GetGossipMenuForSource(WorldObject* source)
|
||||
{
|
||||
switch (source->GetTypeId())
|
||||
{
|
||||
case TYPEID_UNIT:
|
||||
return source->ToCreature()->GetCreatureTemplate()->GossipMenuId;
|
||||
{
|
||||
uint32 menuIdToShow = source->ToCreature()->GetGossipMenuId();
|
||||
|
||||
// if menu id is set by script
|
||||
if (menuIdToShow)
|
||||
return menuIdToShow;
|
||||
|
||||
// otherwise pick from db based on conditions
|
||||
for (uint32 menuId : source->ToCreature()->GetCreatureTemplate()->GossipMenuIds)
|
||||
{
|
||||
GossipMenusMapBounds menuBounds = sObjectMgr->GetGossipMenusMapBounds(menuId);
|
||||
|
||||
for (GossipMenusContainer::const_iterator itr = menuBounds.first; itr != menuBounds.second; ++itr)
|
||||
{
|
||||
if (!sConditionMgr->IsObjectMeetToConditions(this, source, itr->second.Conditions))
|
||||
continue;
|
||||
|
||||
menuIdToShow = menuId;
|
||||
}
|
||||
}
|
||||
return menuIdToShow;
|
||||
}
|
||||
case TYPEID_GAMEOBJECT:
|
||||
return source->ToGameObject()->GetGOInfo()->GetGossipMenuId();
|
||||
default:
|
||||
|
||||
Reference in new issue
Block a user