diff options
-rw-r--r-- | src/server/game/AI/CreatureAI.cpp | 6 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScript.cpp | 3 | ||||
-rw-r--r-- | src/server/game/AI/SmartScripts/SmartScriptMgr.h | 1 |
3 files changed, 7 insertions, 3 deletions
diff --git a/src/server/game/AI/CreatureAI.cpp b/src/server/game/AI/CreatureAI.cpp index d246171e28..95e9b042ce 100644 --- a/src/server/game/AI/CreatureAI.cpp +++ b/src/server/game/AI/CreatureAI.cpp @@ -53,9 +53,11 @@ void CreatureAI::Talk(uint8 id, WorldObject const* target /*= nullptr*/, Millise { if (delay > Seconds::zero()) { - me->m_Events.AddEventAtOffset([this, id, target]() + ObjectGuid targetGuid = target->GetGUID(); + me->m_Events.AddEventAtOffset([this, id, targetGuid]() { - sCreatureTextMgr->SendChat(me, id, target); + if (Unit* textTarget = ObjectAccessor::GetUnit(*me, targetGuid)) + sCreatureTextMgr->SendChat(me, id, textTarget); }, delay); } else diff --git a/src/server/game/AI/SmartScripts/SmartScript.cpp b/src/server/game/AI/SmartScripts/SmartScript.cpp index c980f4f709..377910258f 100644 --- a/src/server/game/AI/SmartScripts/SmartScript.cpp +++ b/src/server/game/AI/SmartScripts/SmartScript.cpp @@ -238,7 +238,8 @@ void SmartScript::ProcessAction(SmartScriptHolder& e, Unit* unit, uint32 var0, u mLastTextID = e.action.talk.textGroupID; mTextTimer = e.action.talk.duration; mUseTextTimer = true; - sCreatureTextMgr->SendChat(talker, uint8(e.action.talk.textGroupID), talkTarget); + + talker->AI()->Talk(e.action.talk.textGroupID, talkTarget, Milliseconds(e.action.talk.delay)); LOG_DEBUG("sql.sql", "SmartScript::ProcessAction: SMART_ACTION_TALK: talker: {} ({}), textId: {}", talker->GetName(), talker->GetGUID().ToString(), mLastTextID); break; } diff --git a/src/server/game/AI/SmartScripts/SmartScriptMgr.h b/src/server/game/AI/SmartScripts/SmartScriptMgr.h index 4f29d9c517..9260b9ab46 100644 --- a/src/server/game/AI/SmartScripts/SmartScriptMgr.h +++ b/src/server/game/AI/SmartScripts/SmartScriptMgr.h @@ -765,6 +765,7 @@ struct SmartAction uint32 textGroupID; uint32 duration; SAIBool useTalkTarget; + uint32 delay; } talk; struct |