fix(Core/Creature): ensure target is valid when acquiring GUID (#22937)
This commit is contained in:
parent
1aa5788f72
commit
9e0b6ff7a6
1 changed files with 7 additions and 5 deletions
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue