Core/SmartAI: allow SMART_ACTION_SEND_GOSSIP_MENU to override default gossip

This commit is contained in:
Aokromes committed 2018-01-06 06:46:43 +01:00
1 parent 208533840d
commit 1f95d87e92
3 files changed
+28 -7

No files matched your search

+10 -5
View File
@@ -73,6 +73,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
@@ -797,14 +799,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*/)
@@ -975,9 +979,9 @@ void SmartGameObjectAI::Reset()
// Called when a player opens a gossip dialog with the gameobject.
bool SmartGameObjectAI::GossipHello(Player* player)
{
TC_LOG_DEBUG("scripts.ai", "SmartGameObjectAI::GossipHello");
_gossipReturn = false;
GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_HELLO, player, 0, 0, false, nullptr, me);
return false;
return _gossipReturn;
}
bool SmartGameObjectAI::OnReportUse(Player* player)
@@ -990,8 +994,9 @@ bool SmartGameObjectAI::OnReportUse(Player* player)
// Called when a player selects a gossip item in the gameobject's gossip menu.
bool SmartGameObjectAI::GossipSelect(Player* player, uint32 menuId, uint32 gossipListId)
{
_gossipReturn = false;
GetScript()->ProcessEventsFor(SMART_EVENT_GOSSIP_SELECT, player, menuId, gossipListId, false, nullptr, me);
return false;
return _gossipReturn;
}
// Called when a player selects a gossip with a code in the gameobject's gossip menu.
+11 -1
View File
@@ -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;
@@ -240,12 +242,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
@@ -2215,7 +2215,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",
@@ -2225,6 +2225,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())