diff options
author | Subv <s.v.h21@hotmail.com> | 2012-08-22 18:03:01 -0500 |
---|---|---|
committer | Subv <s.v.h21@hotmail.com> | 2012-08-22 18:03:01 -0500 |
commit | 45fc80736dbb733628537612b478d9a5415aeb9e (patch) | |
tree | 3b5fb58c826c5c7ffdef99e3a79030d2fa1ac945 /src | |
parent | 4c765aad3ddb0e8a890ee163cf3162d14c396d7e (diff) |
Core/Mmaps: Allow swimming creatures to move underwater when there is a hole in the mesh
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.cpp | 24 |
1 files changed, 21 insertions, 3 deletions
diff --git a/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.cpp b/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.cpp index 3172deb210e..82dcbc07648 100644 --- a/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.cpp +++ b/src/server/game/Movement/MovementGenerators/PathFinderMovementGenerator.cpp @@ -180,14 +180,32 @@ void PathFinderMovementGenerator::BuildPolyPath(const Vector3 &startPos, const V dtPolyRef endPoly = getPolyByLocation(endPoint, &distToEndPoly); // we have a hole in our mesh - // make shortcut path and mark it as NOPATH ( with flying exception ) + // make shortcut path and mark it as NOPATH ( with flying and swimming exception ) // its up to caller how he will use this info if (startPoly == INVALID_POLYREF || endPoly == INVALID_POLYREF) { sLog->outDebug(LOG_FILTER_MAPS, "++ BuildPolyPath :: (startPoly == 0 || endPoly == 0)\n"); BuildShortcut(); - m_type = (m_sourceUnit->GetTypeId() == TYPEID_UNIT && ((Creature*)m_sourceUnit)->CanFly()) - ? PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH) : PATHFIND_NOPATH; + bool path = m_sourceUnit->GetTypeId() == TYPEID_UNIT && m_sourceUnit->ToCreature()->CanFly(); + + bool waterPath = m_sourceUnit->GetTypeId() == TYPEID_UNIT && m_sourceUnit->ToCreature()->canSwim(); + if (waterPath) + { + // Check both start and end points, if they're both in water, then we can *safely* let the creature move + for (int i = 0; i < m_pathPoints.size(); ++i) + { + LiquidData data; + m_sourceUnit->GetBaseMap()->getLiquidStatus(m_pathPoints[i].x, m_pathPoints[i].y, m_pathPoints[i].z, MAP_ALL_LIQUIDS, &data); + // One of the points is not in the water, cancel movement. + if (data.type_flags == MAP_LIQUID_TYPE_NO_WATER) + { + waterPath = false; + break; + } + } + } + + m_type = (path || waterPath) ? PathType(PATHFIND_NORMAL | PATHFIND_NOT_USING_PATH) : PATHFIND_NOPATH; return; } |