diff --git a/playerbot/TravelNode.cpp b/playerbot/TravelNode.cpp index 2bccfe0a..214404a2 100644 --- a/playerbot/TravelNode.cpp +++ b/playerbot/TravelNode.cpp @@ -284,9 +284,6 @@ TravelNodePath* TravelNode::buildPath(TravelNode* endNode, Unit* bot, bool postP path = endPos.getPathFromPath(path, bot); bool canPath = endPos.isPathTo(path); - if (canPath && path.size() == 2 && this->getDistance(endNode) > 5.0f) //Very small path probably bad pathfinder or flying. Stop using it. - canPath = false; - //Cheat a little for walk -> portal/transport. if (!canPath && !isTransport() && !getAreaTriggerId() && (endNode->getAreaTriggerId() || endNode->isTransport())) { @@ -316,6 +313,32 @@ TravelNodePath* TravelNode::buildPath(TravelNode* endNode, Unit* bot, bool postP } } + if (canPath && path.size() == 2 && this->getDistance(endNode) > 5.0f) //Very small path probably bad pathfinder or flying. Stop using it. + canPath = false; + + if (canPath && path.size() > 2) //Do not allow the path to slope too much at the end (pathfinder cheating) + { + WorldPosition firstPos = path.front(); + WorldPosition secondPos = path[1]; + + float vDist = fabs(firstPos.getZ() - secondPos.getZ()); + float hDist = firstPos.fDist(secondPos); + + if (vDist > 10 && (hDist == 0 || vDist / hDist > 2)) + canPath = false; + else + { + WorldPosition firstPos = path.back(); + WorldPosition secondPos = path[path.size() - 2]; + + float vDist = fabs(firstPos.getZ() - secondPos.getZ()); + float hDist = firstPos.fDist(secondPos); + + if (vDist > 10 && (hDist == 0 || vDist / hDist > 2)) + canPath = false; + } + } + returnNodePath->setPath(path); returnNodePath->setComplete(canPath);