GetPathArray
Calculates a 2D path from the character’s current position to (Xdst, Ydst) and returns the path as an array of points.
Optimized — not in use, kept for compatibility. Use moveHeuristicMult instead.
Accuracy — approaching accuracy: 0 = exactly to the destination point, 1 = within 1 tile, etc.
For 3D pathfinding with Z-level support, use GetPathArray3D.
Рассчитывает 2D-путь от текущей позиции персонажа до (Xdst, Ydst) и возвращает путь в виде массива точек.
Optimized — не используется, оставлен для совместимости. Используйте moveHeuristicMult.
Accuracy — точность приближения: 0 = точно в точку назначения, 1 = в радиусе 1 тайла и т. д.
Для 3D-поиска пути с поддержкой уровней Z используйте GetPathArray3D.
function GetPathArray(Xdst: Word; Ydst: Word; Optimized: Boolean; Accuracy: Integer): TPathArray;
DWS overload (legacy, returns count):
function GetPathArray(Xdst: Word; Ydst: Word; Optimized: Boolean; Accuracy: Integer;
var PathArray: TPathArray): Integer;
function GetPathArray(Xdst: Word; Ydst: Word; Optimized: Boolean; Accuracy: Integer;
var PathArray: TPathArray): Integer;
Type definitions:
TMyPoint = packed record
X: Word;
Y: Word;
Z: ShortInt;
end;
// Pascal Script
TPathArray = array[0..999] of TMyPoint;
// DWS
TPathArray = TArray<TMyPoint>;
Notes:
- In Pascal Script,
TPathArrayis a fixed-size array of 1000 elements. - In DWS,
TPathArrayis a dynamic array (TArray<TMyPoint>).
def GetPathArray(Xdst: int, Ydst: int, Optimized: bool, Accuracy: int) -> list[WorldPoint]: ...
var
Path: TPathArray;
i, Count: Integer;
begin
Count := GetPathArray(1000, 1000, False, 0, Path);
AddToSystemJournal('Path length: ' + IntToStr(Count));
for i := 0 to Count - 1 do
AddToSystemJournal(
'Step ' + IntToStr(i) + ': X=' + IntToStr(Path[i].X) +
' Y=' + IntToStr(Path[i].Y) +
' Z=' + IntToStr(Path[i].Z)
);
end.
path = GetPathArray(1000, 1000, False, 0)
AddToSystemJournal(f'Path length: {len(path)}')
for i, p in enumerate(path):
AddToSystemJournal(f'Step {i}: X={p.X} Y={p.Y} Z={p.Z}')