Skip to content

Commit

Permalink
-Nodegen improvement: Bots now prefer to move into an area trigger fr…
Browse files Browse the repository at this point in the history
…om a nearby exit teleport.
  • Loading branch information
mostlikely4r committed Oct 22, 2024
1 parent 9dae093 commit 8934159
Showing 1 changed file with 34 additions and 0 deletions.
34 changes: 34 additions & 0 deletions playerbot/TravelNode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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?
Expand All @@ -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())
Expand Down Expand Up @@ -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()));
}

Expand Down Expand Up @@ -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;

Expand Down

0 comments on commit 8934159

Please sign in to comment.