fix(Core/SmartAI): despawn follow if player goes out of range / offline (#24450)
This commit is contained in:
parent
795e59dbcf
commit
9c05983b2a
2 changed files with 42 additions and 17 deletions
|
|
@ -109,6 +109,45 @@ void SmartAI::UpdateDespawn(const uint32 diff)
|
|||
mDespawnTime -= diff;
|
||||
}
|
||||
|
||||
void SmartAI::UpdateFollow(const uint32 diff)
|
||||
{
|
||||
if (!mFollowGuid)
|
||||
return;
|
||||
|
||||
if (mFollowArrivedTimer < diff)
|
||||
{
|
||||
if (me->FindNearestCreature(mFollowArrivedEntry, INTERACTION_DISTANCE, mFollowArrivedAlive))
|
||||
StopFollow(true);
|
||||
else
|
||||
mFollowArrivedTimer = 1000;
|
||||
}
|
||||
else
|
||||
mFollowArrivedTimer -= diff;
|
||||
|
||||
if (mFollowGuid.IsPlayer())
|
||||
{
|
||||
if (_followCheckTimer < diff)
|
||||
{
|
||||
bool shouldDespawn = false;
|
||||
if (Player* player = ObjectAccessor::FindPlayer(mFollowGuid))
|
||||
{
|
||||
float checkDist = me->GetInstanceScript() ? SMART_ESCORT_MAX_PLAYER_DIST * 2 : SMART_ESCORT_MAX_PLAYER_DIST;
|
||||
if (!me->IsWithinDistInMap(player, checkDist))
|
||||
shouldDespawn = true;
|
||||
}
|
||||
else
|
||||
shouldDespawn = true;
|
||||
|
||||
if (shouldDespawn)
|
||||
me->DespawnOrUnsummon();
|
||||
|
||||
_followCheckTimer = 1000;
|
||||
}
|
||||
else
|
||||
_followCheckTimer -= diff;
|
||||
}
|
||||
}
|
||||
|
||||
WaypointData const* SmartAI::GetNextWayPoint()
|
||||
{
|
||||
if (!mWayPoints || mWayPoints->empty())
|
||||
|
|
@ -536,23 +575,7 @@ void SmartAI::UpdateAI(uint32 diff)
|
|||
GetScript()->OnUpdate(diff);
|
||||
UpdatePath(diff);
|
||||
UpdateDespawn(diff);
|
||||
|
||||
//TODO move to void
|
||||
if (mFollowGuid)
|
||||
{
|
||||
if (mFollowArrivedTimer < diff)
|
||||
{
|
||||
if (me->FindNearestCreature(mFollowArrivedEntry, INTERACTION_DISTANCE, mFollowArrivedAlive))
|
||||
{
|
||||
StopFollow(true);
|
||||
return;
|
||||
}
|
||||
|
||||
mFollowArrivedTimer = 1000;
|
||||
}
|
||||
else
|
||||
mFollowArrivedTimer -= diff;
|
||||
}
|
||||
UpdateFollow(diff);
|
||||
|
||||
if (!IsAIControlled())
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue