diff options
author | Ovahlord <dreadkiller@gmx.de> | 2020-05-16 17:40:08 +0200 |
---|---|---|
committer | Ovahlord <dreadkiller@gmx.de> | 2020-05-16 17:40:08 +0200 |
commit | fdcb7388a64bf61a691535933a9fbae0504b80cc (patch) | |
tree | 319620ba4f74ee98b358262dc305843f0c3749fe /src | |
parent | 75ab3619bdec058dcc848ad134c6d5e838e8f6fb (diff) |
Core/Objects: fixed destination calculation for destination based spells casted by flying units
* Additionally he PathGenerator will now check for realtime movement flags instead of creature based template data only so scripted flying movement and players will now correctly get their path calculated
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Entities/Object/Object.cpp | 38 | ||||
-rw-r--r-- | src/server/game/Movement/PathGenerator.cpp | 4 |
2 files changed, 23 insertions, 19 deletions
diff --git a/src/server/game/Entities/Object/Object.cpp b/src/server/game/Entities/Object/Object.cpp index 3d132c31679..16dbefdfce7 100644 --- a/src/server/game/Entities/Object/Object.cpp +++ b/src/server/game/Entities/Object/Object.cpp @@ -3275,9 +3275,10 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float path.SetUseRaycast(true); path.CalculatePath(destx, desty, destz, false); - // We have a invalid path result. Skip further processing. - if (path.GetPathType() & ~(PATHFIND_NORMAL | PATHFIND_SHORTCUT | PATHFIND_INCOMPLETE | PATHFIND_FARFROMPOLY_END | PATHFIND_NOT_USING_PATH)) - return; + // Check for valid path types before we proceed + if (!(path.GetPathType() & PATHFIND_NOT_USING_PATH)) + if (path.GetPathType() & ~(PATHFIND_NORMAL | PATHFIND_SHORTCUT | PATHFIND_INCOMPLETE | PATHFIND_FARFROMPOLY_END)) + return; G3D::Vector3 result = path.GetPath().back(); destx = result.x; @@ -3286,23 +3287,26 @@ void WorldObject::MovePositionToFirstCollision(Position &pos, float dist, float // check static LOS float halfHeight = GetCollisionHeight() * 0.5f; - bool col; - /* - col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), - pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight, - destx, desty, destz + halfHeight, - destx, desty, destz, -0.5f); - - destz -= halfHeight; + bool col = false; - // Collided with static LOS object, move back to collision point - if (col) + // Unit is flying, check for potential collision via vmaps + if (path.GetPathType() & PATHFIND_NOT_USING_PATH) { - destx -= CONTACT_DISTANCE * std::cos(angle); - desty -= CONTACT_DISTANCE * std::sin(angle); - dist = std::sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty)); + col = VMAP::VMapFactory::createOrGetVMapManager()->getObjectHitPos(GetMapId(), + pos.m_positionX, pos.m_positionY, pos.m_positionZ + halfHeight, + destx, desty, destz + halfHeight, + destx, desty, destz, -0.5f); + + destz -= halfHeight; + + // Collided with static LOS object, move back to collision point + if (col) + { + destx -= CONTACT_DISTANCE * std::cos(angle); + desty -= CONTACT_DISTANCE * std::sin(angle); + dist = std::sqrt((pos.m_positionX - destx) * (pos.m_positionX - destx) + (pos.m_positionY - desty) * (pos.m_positionY - desty)); + } } - */ // check dynamic collision col = GetMap()->getObjectHitPos(GetPhaseMask(), diff --git a/src/server/game/Movement/PathGenerator.cpp b/src/server/game/Movement/PathGenerator.cpp index af6b8b0b30c..39ee09731a3 100644 --- a/src/server/game/Movement/PathGenerator.cpp +++ b/src/server/game/Movement/PathGenerator.cpp @@ -178,7 +178,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con { TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: (startPoly == 0 || endPoly == 0)"); BuildShortcut(); - bool path = _source->GetTypeId() == TYPEID_UNIT && _source->ToCreature()->CanFly(); + bool path = _source->GetTypeId() == TYPEID_UNIT && _source->ToCreature()->IsFlying(); bool waterPath = _source->GetTypeId() == TYPEID_UNIT && _source->ToCreature()->CanSwim(); if (waterPath) @@ -232,7 +232,7 @@ void PathGenerator::BuildPolyPath(G3D::Vector3 const& startPos, G3D::Vector3 con TC_LOG_DEBUG("maps.mmaps", "++ BuildPolyPath :: flying case"); if (Unit const* _sourceUnit = _source->ToUnit()) { - if (_sourceUnit->CanFly()) + if (_sourceUnit->IsFlying()) buildShotrcut = true; // Allow to build a shortcut if the unit is falling and it's trying to move downwards towards a target (i.e. charging) else if (_sourceUnit->IsFalling() && endPos.z < startPos.z) |