From 773071fee37eb52935fa44d0a37aae6302cd119b Mon Sep 17 00:00:00 2001 From: Ivan Savenko Date: Sun, 3 Dec 2023 15:58:44 +0200 Subject: [PATCH] Fix AI movement through wandering monsters --- lib/pathfinder/CPathfinder.cpp | 16 ++++------------ 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/lib/pathfinder/CPathfinder.cpp b/lib/pathfinder/CPathfinder.cpp index a713b5bdc..46d4f564b 100644 --- a/lib/pathfinder/CPathfinder.cpp +++ b/lib/pathfinder/CPathfinder.cpp @@ -40,19 +40,11 @@ bool CPathfinderHelper::canMoveFromNode(const PathNodeInfo & source) const if (source.node->isTeleportAction()) return true; - // we can go through garrisons - if (source.nodeObject->ID == MapObjectID::GARRISON || source.nodeObject->ID == MapObjectID::GARRISON2) - return true; + // we can not go through teleporters since moving onto a teleport will teleport hero and may invalidate path (e.g. one-way teleport or enemy hero on other side) + if (dynamic_cast(source.nodeObject) != nullptr) + return false; - // or through border gate (if we stand on it then we already have the key) - if (source.nodeObject->ID == MapObjectID::BORDER_GATE) - return true; - - // or "through" boat, but only if this is embarking - if (source.nodeObject->ID == MapObjectID::BOAT && source.node->action == EPathNodeAction::EMBARK) - return true; - - return false; + return true; } std::vector CPathfinderHelper::getNeighbourTiles(const PathNodeInfo & source) const