From 6b583089f35f04fd51b9c47ac56daa87944e03f1 Mon Sep 17 00:00:00 2001 From: Synful-Syn Date: Fri, 25 Aug 2023 08:14:27 -0400 Subject: [PATCH] fix(Core/Spell): Stop `Blink` from the falling player to move upward by 1y and stop moving backward when facing a wall (#16657) * blink-bad-warps * Change formatting of an if --- src/common/Collision/Maps/MapTree.cpp | 8 +------- src/server/game/Spells/Spell.cpp | 21 +++++++++++++++------ 2 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/common/Collision/Maps/MapTree.cpp b/src/common/Collision/Maps/MapTree.cpp index 2223c58d3..27c4c1ded 100644 --- a/src/common/Collision/Maps/MapTree.cpp +++ b/src/common/Collision/Maps/MapTree.cpp @@ -176,13 +176,7 @@ namespace VMAP // direction with length of 1 G3D::Ray ray = G3D::Ray::fromOriginAndDirection(pos1, (pos2 - pos1) / maxDist); - if (GetIntersectionTime(ray, maxDist, true, ignoreFlags)) - { - - return false; - } - - return true; + return !GetIntersectionTime(ray, maxDist, true, ignoreFlags); } //========================================================= /** diff --git a/src/server/game/Spells/Spell.cpp b/src/server/game/Spells/Spell.cpp index 06fa659d2..e239466c7 100644 --- a/src/server/game/Spells/Spell.cpp +++ b/src/server/game/Spells/Spell.cpp @@ -1412,16 +1412,16 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici uint32 mapid = m_caster->GetMapId(); uint32 phasemask = m_caster->GetPhaseMask(); float collisionHeight = m_caster->GetCollisionHeight(); - float destx = 0.0f, desty = 0.0f, destz = 0.0f, ground = 0.0f, startx = 0.0f, starty = 0.0f, startz = 0.0f, starto = 0.0f; + float destz = 0.0f, startx = 0.0f, starty = 0.0f, startz = 0.0f, starto = 0.0f; Position pos; Position lastpos; m_caster->GetPosition(startx, starty, startz, starto); pos.Relocate(startx, starty, startz, starto); - destx = pos.GetPositionX() + distance * cos(pos.GetOrientation()); - desty = pos.GetPositionY() + distance * sin(pos.GetOrientation()); + float destx = pos.GetPositionX() + distance * cos(pos.GetOrientation()); + float desty = pos.GetPositionY() + distance * sin(pos.GetOrientation()); - ground = map->GetHeight(phasemask, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); + float ground = map->GetHeight(phasemask, pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); bool isCasterInWater = m_caster->IsInWater(); if (!m_caster->HasUnitMovementFlag(MOVEMENTFLAG_FALLING) || (pos.GetPositionZ() - ground < distance)) @@ -1586,6 +1586,15 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici destz = prevZ; //LOG_ERROR("spells", "(collision) destZ rewrited in prevZ"); + // Don't make the player move backward from the xy adjustments by collisions. + if ((DELTA_X > 0 && startx > destx) || (DELTA_X < 0 && startx < destx) || + (DELTA_Y > 0 && starty > desty) || (DELTA_Y < 0 && starty < desty)) + { + destx = startx; + desty = starty; + destz = startz; + } + break; } // we have correct destz now @@ -1597,9 +1606,9 @@ void Spell::SelectImplicitCasterDestTargets(SpellEffIndex effIndex, SpellImplici else { float z = pos.GetPositionZ(); - bool col = VMAP::VMapFactory::createOrGetVMapMgr()->GetObjectHitPos(mapid, pos.GetPositionX(), pos.GetPositionY(), z + 0.5f, destx, desty, z + 0.5f, destx, desty, z, -0.5f); + bool col = VMAP::VMapFactory::createOrGetVMapMgr()->GetObjectHitPos(mapid, pos.GetPositionX(), pos.GetPositionY(), z, destx, desty, z, destx, desty, z, -0.5f); // check dynamic collision - bool dcol = m_caster->GetMap()->GetObjectHitPos(phasemask, pos.GetPositionX(), pos.GetPositionY(), z + 0.5f, destx, desty, z + 0.5f, destx, desty, z, -0.5f); + bool dcol = m_caster->GetMap()->GetObjectHitPos(phasemask, pos.GetPositionX(), pos.GetPositionY(), z, destx, desty, z, destx, desty, z, -0.5f); // collision occured if (col || dcol)