diff --git a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp index fa4ae7efe0..5c34687c87 100644 --- a/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp +++ b/src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp @@ -174,19 +174,20 @@ void EscortAI::UpdateAI(uint32 diff) if (_despawnAtEnd) { TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: reached end of waypoints, despawning at end ({})", me->GetGUID().ToString()); - if (_returnToStart) - { - Position respawnPosition = me->GetRespawnPosition(); - me->GetMotionMaster()->MovePoint(POINT_HOME, respawnPosition); - TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: returning to spawn location: {} ({})", respawnPosition, me->GetGUID().ToString()); - } - else if (_instantRespawn) + if (_instantRespawn) me->Respawn(true); else me->DespawnOrUnsummon(); } + else if (_returnToStart) + { + Position respawnPosition = me->GetRespawnPosition(); + me->GetMotionMaster()->MovePoint(POINT_HOME, respawnPosition); + TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: returning to spawn location: {} ({})", respawnPosition, me->GetGUID().ToString()); + } + else + RemoveEscortState(STATE_ESCORT_ESCORTING); TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: reached end of waypoints ({})", me->GetGUID().ToString()); - RemoveEscortState(STATE_ESCORT_ESCORTING); return; }