Skip to content

Commit 84b0222

Browse files
committed
Core/AI: fix _returnToStart handling in ScriptedEscortAI
1 parent 7ebf804 commit 84b0222

1 file changed

Lines changed: 12 additions & 11 deletions

File tree

src/server/game/AI/ScriptedAI/ScriptedEscortAI.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -176,22 +176,23 @@ void EscortAI::UpdateAI(uint32 diff)
176176
if (_despawnAtEnd)
177177
{
178178
TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: reached end of waypoints, despawning at end ({})", me->GetGUID().ToString());
179-
if (_returnToStart)
180-
{
181-
Position respawnPosition;
182-
float orientation = 0.f;
183-
me->GetRespawnPosition(respawnPosition.m_positionX, respawnPosition.m_positionY, respawnPosition.m_positionZ, &orientation);
184-
respawnPosition.SetOrientation(orientation);
185-
me->GetMotionMaster()->MovePoint(POINT_HOME, respawnPosition);
186-
TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: returning to spawn location: {} ({})", respawnPosition.ToString(), me->GetGUID().ToString());
187-
}
188-
else if (_instantRespawn)
179+
if (_instantRespawn)
189180
me->Respawn(true);
190181
else
191182
me->DespawnOrUnsummon();
192183
}
184+
else if (_returnToStart)
185+
{
186+
Position respawnPosition;
187+
float orientation = 0.f;
188+
me->GetRespawnPosition(respawnPosition.m_positionX, respawnPosition.m_positionY, respawnPosition.m_positionZ, &orientation);
189+
respawnPosition.SetOrientation(orientation);
190+
me->GetMotionMaster()->MovePoint(POINT_HOME, respawnPosition);
191+
TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: returning to spawn location: {} ({})", respawnPosition.ToString(), me->GetGUID().ToString());
192+
}
193+
else
194+
RemoveEscortState(STATE_ESCORT_ESCORTING);
193195
TC_LOG_DEBUG("scripts.ai.escortai", "EscortAI::UpdateAI: reached end of waypoints ({})", me->GetGUID().ToString());
194-
RemoveEscortState(STATE_ESCORT_ESCORTING);
195196
return;
196197
}
197198

0 commit comments

Comments
 (0)