From 9d3cd6a6e593adce7c5902f35115d5347d5ebb71 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 23 Jun 2021 15:59:06 -0400 Subject: [PATCH] Core/Spells: fix logic error causing near teleports to drop combat for players Port From (https://github.com/TrinityCore/TrinityCore/commit/f9b14ca795de932746ce404dfe56c5cded3bde2b) --- Source/Game/Spells/SpellEffects.cs | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/Source/Game/Spells/SpellEffects.cs b/Source/Game/Spells/SpellEffects.cs index ab5de827a..c54645b6c 100644 --- a/Source/Game/Spells/SpellEffects.cs +++ b/Source/Game/Spells/SpellEffects.cs @@ -584,27 +584,26 @@ namespace Game.Spells } // Init dest coordinates - uint mapid = destTarget.GetMapId(); - if (mapid == 0xFFFFFFFF) - mapid = unitTarget.GetMapId(); - float x, y, z, orientation; - destTarget.GetPosition(out x, out y, out z, out orientation); - if (orientation == 0 && m_targets.GetUnitTarget() != null) - orientation = m_targets.GetUnitTarget().GetOrientation(); - Log.outDebug(LogFilter.Spells, "Spell.EffectTeleportUnits - teleport unit to {0} {1} {2} {3} {4}\n", mapid, x, y, z, orientation); + WorldLocation targetDest = new(destTarget); + if (targetDest.GetMapId() == 0xFFFFFFFF) + targetDest.SetMapId(unitTarget.GetMapId()); + + if (targetDest.GetOrientation() == 0 && m_targets.GetUnitTarget()) + targetDest.SetOrientation(m_targets.GetUnitTarget().GetOrientation()); Player player = unitTarget.ToPlayer(); - if (player) + if (player != null) { // Custom loading screen uint customLoadingScreenId = (uint)effectInfo.MiscValue; if (customLoadingScreenId != 0) player.SendPacket(new CustomLoadScreen(m_spellInfo.Id, customLoadingScreenId)); - - player.TeleportTo(mapid, x, y, z, orientation, unitTarget == m_caster ? TeleportToOptions.Spell | TeleportToOptions.NotLeaveCombat : 0); } - else if (mapid == unitTarget.GetMapId()) - unitTarget.NearTeleportTo(x, y, z, orientation, unitTarget == m_caster); + + if (targetDest.GetMapId() == unitTarget.GetMapId()) + unitTarget.NearTeleportTo(targetDest, unitTarget == m_caster); + else if (player != null) + player.TeleportTo(targetDest, unitTarget == m_caster ? TeleportToOptions.Spell : 0); else { Log.outError(LogFilter.Spells, "Spell.EffectTeleportUnits - spellId {0} attempted to teleport creature to a different map.", m_spellInfo.Id);