From 89341597cad1bf14543d3a03d182ea8f1c5ecc07 Mon Sep 17 00:00:00 2001 From: mostlikely4r Date: Tue, 22 Oct 2024 15:34:55 +0200 Subject: [PATCH] -Nodegen improvement: Bots now prefer to move into an area trigger from a nearby exit teleport. --- playerbot/TravelNode.cpp | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) diff --git a/playerbot/TravelNode.cpp b/playerbot/TravelNode.cpp index 3da3d47e..10a6435f 100644 --- a/playerbot/TravelNode.cpp +++ b/playerbot/TravelNode.cpp @@ -403,6 +403,28 @@ bool TravelNode::isUselessLink(TravelNode* farNode) { farPath = getPathTo(farNode); farLength = farPath->getDistance(); + + if (uint32 areaTriggerId = getAreaTriggerId()) //If area triggers are linked to a nearby exit remove all other links. + { + bool farIsTarget = farNode->isAreaTriggerTarget(); + + for (auto& link : *getLinks()) + { + TravelNode* nearNode = link.first; + + if (farNode == nearNode) + continue; + + if (farNode->getMapId() != nearNode->getMapId()) + continue; + + WorldPosition nearPos = *nearNode->getPosition(); + float nearLength = link.second->getDistance(); + + if (!farIsTarget && nearNode->isAreaTriggerTarget() && nearLength < 20.0f) + return true; + } + } } else farLength = getDistance(farNode); @@ -419,6 +441,9 @@ bool TravelNode::isUselessLink(TravelNode* farNode) if (farNode->hasLinkTo(this) && !nearNode->hasLinkTo(this)) continue; + if (nearNode->getAreaTriggerId()) //This node might get removed later, can not use it as a faster route. + continue; + if (nearNode->hasLinkTo(farNode)) { //Is it quicker to go past second node to reach first node instead of going directly? @@ -435,6 +460,9 @@ bool TravelNode::isUselessLink(TravelNode* farNode) if (!nearNode->hasRouteTo(farNode, true)) continue; + if (nearNode->getAreaTriggerId()) //This node might get removed later, can not use it as a faster route. + continue; + TravelNodeRoute route = sTravelNodeMap.getRoute(nearNode, farNode, nullptr); if (route.isEmpty()) @@ -2390,6 +2418,9 @@ void TravelNodeMap::generateHelperNodes(uint32 mapId) if (node->isTransport()) continue; + if (node->getAreaTriggerId()) + continue; + places_to_reach.push_back(make_pair(GuidPosition(0, *node->getPosition()), node->getName())); } @@ -2430,6 +2461,9 @@ void TravelNodeMap::generateHelperNodes(uint32 mapId) if (node->isTransport()) continue; + if (node->getAreaTriggerId()) + continue; + if (node->getPosition()->canPathTo(pos.first, nullptr)) // continue;