mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-21 12:47:07 +00:00
fix(Core/Creature): ensure target is valid when acquiring GUID (#22937)
This commit is contained in:
@@ -53,17 +53,19 @@ void CreatureAI::Talk(uint8 id, WorldObject const* target /*= nullptr*/, Millise
|
||||
{
|
||||
if (delay > Seconds::zero())
|
||||
{
|
||||
ObjectGuid targetGuid = target->GetGUID();
|
||||
ObjectGuid targetGuid;
|
||||
|
||||
if (target)
|
||||
targetGuid = target->GetGUID();
|
||||
|
||||
me->m_Events.AddEventAtOffset([this, id, targetGuid]()
|
||||
{
|
||||
if (Unit* textTarget = ObjectAccessor::GetUnit(*me, targetGuid))
|
||||
sCreatureTextMgr->SendChat(me, id, textTarget);
|
||||
// Target can be nullptr here, it will be handled inside the function.
|
||||
sCreatureTextMgr->SendChat(me, id, ObjectAccessor::GetUnit(*me, targetGuid));
|
||||
}, delay);
|
||||
}
|
||||
else
|
||||
{
|
||||
sCreatureTextMgr->SendChat(me, id, target);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user