From c57d97ac9f8dc901c64f8dce0ff5b9a8a156d85e Mon Sep 17 00:00:00 2001 From: Grimdhex <176165533+Grimdhex@users.noreply.github.com> Date: Sun, 15 Sep 2024 19:12:29 +0200 Subject: [PATCH] improve the dest selection --- .../Outland/BlackTemple/boss_mother_shahraz.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp index 6589034e95..4aac19e795 100644 --- a/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp +++ b/src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp @@ -212,14 +212,22 @@ class spell_mother_shahraz_fatal_attraction : public SpellScript void SetDest(SpellDestination& dest) { + float constexpr minDist = 30.0f; + float constexpr maxDist = 48.0f; + + // Randomize the teleportation distance from the caster + float const teleportDist = frand(minDist, maxDist); + // Initialize a first destination - Position teleportDest = GetCaster()->GetRandomNearPosition(50.0f); + Position teleportDest = GetCaster()->GetRandomNearPosition(teleportDist); // Ensure that the destination is not too close to the caster. - // @todo: Need maybe a LOS Check? - while (teleportDest.GetExactDist(GetCaster()->GetPosition()) < 50.0f) + // Add a check for LOS, to ensure to not be teleported under the map + while (teleportDest.GetExactDist(GetCaster()) < minDist || + !GetCaster()->IsWithinLOS(teleportDest.GetPositionX(), teleportDest.GetPositionY(), teleportDest.GetPositionZ())) { - teleportDest = GetCaster()->GetRandomNearPosition(50.0f); + // If the conditions are not met, find a new destination. + teleportDest = GetCaster()->GetRandomNearPosition(teleportDist); } // When a valid destination is found, relocate it.