Skip to content

Commit

Permalink
-Nodegen improvement: Disallow paths that have a big jump up or down …
Browse files Browse the repository at this point in the history
…at the beginning or end of the path indicating pathfinding cheating.
  • Loading branch information
mostlikely4r committed Oct 23, 2024
1 parent 0e97571 commit 28a7133
Showing 1 changed file with 26 additions and 3 deletions.
29 changes: 26 additions & 3 deletions playerbot/TravelNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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()))
{
Expand Down Expand Up @@ -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);

Expand Down

0 comments on commit 28a7133

Please sign in to comment.