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())
|
if (delay > Seconds::zero())
|
||||||
{
|
{
|
||||||
ObjectGuid targetGuid = target->GetGUID();
|
ObjectGuid targetGuid;
|
||||||
|
|
||||||
|
if (target)
|
||||||
|
targetGuid = target->GetGUID();
|
||||||
|
|
||||||
me->m_Events.AddEventAtOffset([this, id, targetGuid]()
|
me->m_Events.AddEventAtOffset([this, id, targetGuid]()
|
||||||
{
|
{
|
||||||
if (Unit* textTarget = ObjectAccessor::GetUnit(*me, targetGuid))
|
// Target can be nullptr here, it will be handled inside the function.
|
||||||
sCreatureTextMgr->SendChat(me, id, textTarget);
|
sCreatureTextMgr->SendChat(me, id, ObjectAccessor::GetUnit(*me, targetGuid));
|
||||||
}, delay);
|
}, delay);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
|
||||||
sCreatureTextMgr->SendChat(me, id, target);
|
sCreatureTextMgr->SendChat(me, id, target);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user