Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(Script/BlackTemple): teleport position with fatal attraction #19971

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 20 additions & 1 deletion src/server/scripts/Outland/BlackTemple/boss_mother_shahraz.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,7 +212,26 @@ class spell_mother_shahraz_fatal_attraction : public SpellScript

void SetDest(SpellDestination& dest)
{
dest.Relocate(GetCaster()->GetRandomNearPosition(50.0f));
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(teleportDist);

// Ensure that the destination is not too close to the caster.
// Add a check for LOS, to ensure to not be teleported under the map
while (teleportDest.GetExactDist(GetCaster()) < minDist ||
Grimdhex marked this conversation as resolved.
Show resolved Hide resolved
!GetCaster()->IsWithinLOS(teleportDest.GetPositionX(), teleportDest.GetPositionY(), teleportDest.GetPositionZ()))
{
// If the conditions are not met, find a new destination.
teleportDest = GetCaster()->GetRandomNearPosition(teleportDist);
}

// When a valid destination is found, relocate it.
dest.Relocate(teleportDest);
}

void HandleTeleportUnits(SpellEffIndex /*effIndex*/)
Expand Down