From 855a11caed2e82f558b9a86329f18b1bf3feda16 Mon Sep 17 00:00:00 2001 From: ccrs Date: Mon, 27 Apr 2026 17:24:37 +0200 Subject: [PATCH] Core/AI: fix _returnToStart handling in ScriptedEscortAI (cherry picked from commit 84b0222bdcce8e6a0fe0589e334d1ff476ccfb2d) --- .../game/AI/ScriptedAI/ScriptedEscortAI.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) 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; }