fix(Core/SmartAI): despawn follow if player goes out of range / offline (#24450)
This commit is contained in:
@@ -109,6 +109,45 @@ void SmartAI::UpdateDespawn(const uint32 diff)
|
|||||||
mDespawnTime -= 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()
|
WaypointData const* SmartAI::GetNextWayPoint()
|
||||||
{
|
{
|
||||||
if (!mWayPoints || mWayPoints->empty())
|
if (!mWayPoints || mWayPoints->empty())
|
||||||
@@ -536,23 +575,7 @@ void SmartAI::UpdateAI(uint32 diff)
|
|||||||
GetScript()->OnUpdate(diff);
|
GetScript()->OnUpdate(diff);
|
||||||
UpdatePath(diff);
|
UpdatePath(diff);
|
||||||
UpdateDespawn(diff);
|
UpdateDespawn(diff);
|
||||||
|
UpdateFollow(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;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (!IsAIControlled())
|
if (!IsAIControlled())
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -222,6 +222,7 @@ private:
|
|||||||
bool mIsCharmed;
|
bool mIsCharmed;
|
||||||
uint32 mFollowCreditType;
|
uint32 mFollowCreditType;
|
||||||
uint32 mFollowArrivedTimer;
|
uint32 mFollowArrivedTimer;
|
||||||
|
uint32 _followCheckTimer;
|
||||||
uint32 mFollowCredit;
|
uint32 mFollowCredit;
|
||||||
uint32 mFollowArrivedEntry;
|
uint32 mFollowArrivedEntry;
|
||||||
bool mFollowArrivedAlive;
|
bool mFollowArrivedAlive;
|
||||||
@@ -253,6 +254,7 @@ private:
|
|||||||
uint32 mDespawnTime;
|
uint32 mDespawnTime;
|
||||||
uint32 mDespawnState;
|
uint32 mDespawnState;
|
||||||
void UpdateDespawn(const uint32 diff);
|
void UpdateDespawn(const uint32 diff);
|
||||||
|
void UpdateFollow(const uint32 diff);
|
||||||
uint32 mEscortInvokerCheckTimer;
|
uint32 mEscortInvokerCheckTimer;
|
||||||
bool mJustReset;
|
bool mJustReset;
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user