diff options
author | ariel- <ariel-@users.noreply.github.com> | 2017-05-27 03:56:09 -0300 |
---|---|---|
committer | funjoker <funjoker109@gmail.com> | 2020-06-14 23:49:04 +0200 |
commit | 444754e65afa18e636349d9aebeb790128c98912 (patch) | |
tree | 0435a34b1b9be6310a9aaa48b997f510f97c398f | |
parent | 250aef5186699fb9d31c3ba94754ad926c4f96af (diff) |
Core/SmartAI: allow SMART_ACTION_SEND_GOSSIP_MENU to override default gossip
Closes #19769
(cherry picked from commit f2b0819e5368b2b8e8865b13555c140e4f9a59a7)
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.cpp | 15 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartAI.h | 12 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 8 |
3 files changed, 28 insertions, 7 deletions
diff --git a/src/server/game/AI/SmartScripts/SmartAI.cpp b/src/server/game/AI/SmartScripts/SmartAI.cpp index 2dd122de1ee..b33c6f5093a 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.cpp +++ b/src/server/game/AI/SmartScripts/SmartAI.cpp @@ -74,6 +74,8 @@ SmartAI::SmartAI(Creature* c) : CreatureAI(c) mJustReset = false; mConditionsTimer = 0; mHasConditions = sConditionMgr->HasConditionsForNotGroupedEntry(CONDITION_SOURCE_TYPE_CREATURE_TEMPLATE_VEHICLE, c->GetEntry()); + + _gossipReturn = false; } bool SmartAI::IsAIControlled() const @@ -810,14 +812,16 @@ void SmartAI::SetEvadeDisabled(bool disable) bool SmartAI::GossipHello(Player* player) { + _gossipReturn = false; GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player); - return false; + return _gossipReturn; } bool SmartAI::GossipSelect(Player* player, uint32 menuId, uint32 gossipListId) { + _gossipReturn = false; GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_SELECT, player, menuId, gossipListId); - return false; + return _gossipReturn; } bool SmartAI::GossipSelectCode(Player* /*player*/, uint32 /*menuId*/, uint32 /*gossipListId*/, const char* /*code*/) @@ -995,16 +999,17 @@ void SmartGameObjectAI::Reset() // Called when a player opens a gossip dialog with the gameobject. bool SmartGameObjectAI::GossipHello(Player* player, bool reportUse) { - TC_LOG_DEBUG("scripts.ai", "SmartGameObjectAI::GossipHello"); + _gossipReturn = false; GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player, uint32(reportUse), 0, false, nullptr, me); - return false; + return _gossipReturn; } // Called when a player selects a gossip item in the gameobject's gossip menu. bool SmartGameObjectAI::GossipSelect(Player* player, uint32 sender, uint32 action) { + _gossipReturn = false; GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_SELECT, player, sender, action, false, nullptr, me); - return false; + return _gossipReturn; } // Called when a player selects a gossip with a code in the gameobject's gossip menu. diff --git a/src/server/game/AI/SmartScripts/SmartAI.h b/src/server/game/AI/SmartScripts/SmartAI.h index 1c65c9633b9..788e41b9003 100644 --- a/src/server/game/AI/SmartScripts/SmartAI.h +++ b/src/server/game/AI/SmartScripts/SmartAI.h @@ -198,6 +198,8 @@ class TC_GAME_API SmartAI : public CreatureAI void SetWPPauseTimer(uint32 time) { mWPPauseTimer = time; } + void SetGossipReturn(bool val) { _gossipReturn = val; } + private: bool mIsCharmed; uint32 mFollowCreditType; @@ -241,12 +243,15 @@ class TC_GAME_API SmartAI : public CreatureAI void CheckConditions(uint32 diff); bool mHasConditions; uint32 mConditionsTimer; + + // Gossip + bool _gossipReturn; }; class TC_GAME_API SmartGameObjectAI : public GameObjectAI { public: - SmartGameObjectAI(GameObject* g) : GameObjectAI(g) { } + SmartGameObjectAI(GameObject* g) : GameObjectAI(g), _gossipReturn(false) { } ~SmartGameObjectAI() { } void UpdateAI(uint32 diff) override; @@ -268,8 +273,13 @@ class TC_GAME_API SmartGameObjectAI : public GameObjectAI void EventInform(uint32 eventId) override; void SpellHit(Unit* unit, const SpellInfo* spellInfo) override; + void SetGossipReturn(bool val) { _gossipReturn = val; } + private: SmartScript mScript; + + // Gossip + bool _gossipReturn; }; /// Registers scripts required by the SAI scripting system diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index ebf884133a4..a1c6d3af9b6 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -2411,7 +2411,7 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u } case SMART_ACTION_SEND_GOSSIP_MENU: { - if (!GetBaseObject()) + if (!GetBaseObject() || !IsSmart()) break; TC_LOG_DEBUG("scripts.ai", "SmartScript::ProcessAction:: SMART_ACTION_SEND_GOSSIP_MENU: gossipMenuId %d, gossipNpcTextId %d", @@ -2421,6 +2421,12 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u if (!targets) break; + // override default gossip + if (me) + ENSURE_AI(SmartAI, me->AI())->SetGossipReturn(true); + else if (go) + ENSURE_AI(SmartGameObjectAI, go->AI())->SetGossipReturn(true); + for (ObjectList::const_iterator itr = targets->begin(); itr != targets->end(); ++itr) { if (Player* player = (*itr)->ToPlayer()) |