GetPathLength

Category: Landscape
Since engine version: 1.0 OC

Description

Searches for a path from start point to end point using the pathfinding algorithm as used by clonks and returns the length of the found path. Returns nil if no path was found.

Syntax

int GetPathLength(int startx, int starty, int endx, int endy, int depth);

Parameters

startx:
X coordinate of starting position. Always global coordinate.
starty:
Y coordinate of starting position. Always global coordinate.
endx:
X coordinate of end position. Always global coordinate.
endy:
Y coordinate of end position. Always global coordinate.
depth:
Determines search depth of the pathfinder algorithm (range from 1 - 10 with default 1). Warning: higher values may slow down the game. See also the PathFinder entry in the DefCore.

Example

var dist = GetPathLength(GetX(), GetY(), GetX(FindBase(GetOwner())), GetY(FindBase(GetOwner())));
Determines the distance from an object to its closest friendly base.
PeterW, 2002-04