Searches for a path from start point to end point using the pathfinding algorithm as used by clonks and returns a map with its waypoints and length. Returns nil if no path was found. The returned map is structured like this:
Key |
Data type |
Description |
Length |
int |
Length of the found path, same as returned byGetPathLength
|
Waypoints |
array |
Array containing waypoints |
The waypoints are structured like this:
Key |
Data type |
Description |
X |
int |
X coordinate of the waypoint |
Y |
int |
Y coordinate of the waypoint |
TransferTarget |
object |
Transfer target. only set if present. |
This function can only be used with #strict 3 or above because of the map syntax. Use
GetPathLength in older versions.
var path = GetPath(GetX(), GetY(), GetX(FindBase(GetOwner())), GetY(FindBase(GetOwner())));
if (path)
{
Log("Anzahl der Wegpunkte: %d, Pfadlänge: %d", GetLength(path.Waypoints), path.Length);
}
else
{
Log("Kein Pfad gefunden!");
}
Logs the number of waypoints and the path length to the calling object's owner's first base, if a way has been found.