From 5a62d6c5701aaa2d93fbaa912b9f493da0bc69c4 Mon Sep 17 00:00:00 2001 From: Ovahlord Date: Thu, 24 Aug 2023 21:35:05 +0200 Subject: [PATCH] Core/Movement: fixed edge cases in which hovering units were considered far from poly during path generation, resulting in incomplete paths getting returned --- .../MovementGenerators/ChaseMovementGenerator.cpp | 8 ++------ src/server/game/Movement/PathGenerator.cpp | 9 +++++++-- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp index dcf96fbc8e..2a8eed13ec 100644 --- a/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/ChaseMovementGenerator.cpp @@ -173,8 +173,6 @@ bool ChaseMovementGenerator::Update(Unit* owner, uint32 diff) target->MovePositionToFirstCollision(destination, GetHitboxSum(owner, target), angle); } - owner->UpdateAllowedPositionZ(destination.GetPositionX(), destination.GetPositionY(), destination.m_positionZ); - // Destination set and ready. Now the usual checks result |= checkPosition(ChasePositionCheckOptions(CHASE_POSITION_CHECK_DISTANCE | CHASE_POSITION_CHECK_LOS), owner, target, &destination); @@ -241,10 +239,8 @@ ChaseMovementPositionCheckResult ChaseMovementGenerator::checkPosition(ChasePosi void ChaseMovementGenerator::launchSpline(Unit* owner, Unit* target, Position& destination) { - bool success = _pathGenerator->CalculatePath(destination.GetPositionX(), destination.GetPositionY(), destination.GetPositionZ(), owner->IsFlying()); - uint32 deniedPathResultTypes = PATHFIND_NOPATH; - if (!owner->IsHovering()) - deniedPathResultTypes |= PATHFIND_INCOMPLETE; + bool success = _pathGenerator->CalculatePath(destination, owner->IsFlying()); + uint32 deniedPathResultTypes = PATHFIND_NOPATH | PATHFIND_INCOMPLETE; if (!owner->IsFlying() || (target->IsInWater() && !owner->CanEnterWater())) // only flying and swimming units may use shortcuts deniedPathResultTypes |= PATHFIND_SHORTCUT; diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index b340a731e7..e60ede3538 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -222,8 +222,13 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con } // we may need a better number here - bool startFarFromPoly = distToStartPoly > 7.0f; - bool endFarFromPoly = distToEndPoly > 7.0f; + float allowedPolyDist = 7.0f; + if (Unit const* unit = _source->ToUnit()) + if (unit->IsHovering()) // some hovering units hover above the original 7.0f threshold so we have to take their hover offset into consideration + allowedPolyDist = std::max(allowedPolyDist, unit->GetHoverOffset()); + + bool startFarFromPoly = distToStartPoly > allowedPolyDist; + bool endFarFromPoly = distToEndPoly > allowedPolyDist; if (startFarFromPoly || endFarFromPoly) { TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: farFromPoly distToStartPoly=%.3f distToEndPoly=%.3f", distToStartPoly, distToEndPoly);