Home API Manuals About Forum
Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Toggle Dark/Light/Auto mode Back to homepage

MoveXY

Moves the character to the specified XY coordinates using the pathfinding engine.

Xdst, Ydst — destination coordinates.

Optimized — if True, the pathfinder uses an optimized algorithm. If False, uses standard A* pathfinding.

Accuracy — how close the character needs to get to the destination (in tiles). Clamped to 0–20; values outside this range default to 1.

Running — if True, the character runs; if False, walks.

DWScript additionally supports an optional StepCallback parameter — a callback function invoked at each movement step. If the callback returns False, movement stops immediately.

TMoverStepCallBack = function(X, Y: Word; Z: ShortInt): Boolean;

The method blocks until the destination is reached (within accuracy), the path is blocked, the callback returns False, movement is cancelled by MoverStop, or the script is stopped.

If the character disconnects during movement, the behavior depends on the moveExitOnDisconnect setting: if enabled, the method returns False immediately; otherwise, it waits for reconnection.

The following movement variables affect this method’s behavior: moveOpenDoor, moveThroughNPC, moveThroughCorner, moveBetweenTwoCorners, moveCheckStamina, moveHeuristicMult, moveTurnCost, moveExitOnDisconnect.

Returns True if the destination was reached within the specified accuracy, False otherwise.

Перемещает персонажа к указанным координатам XY с использованием движка поиска пути.

Xdst, Ydst — координаты назначения.

Optimized — если True, используется оптимизированный алгоритм. Если False — стандартный A*.

Accuracy — на сколько тайлов можно не дойти до цели. Ограничивается 0–20; значения вне диапазона заменяются на 1.

RunningTrue — бег, False — ходьба.

В DWScript дополнительно поддерживается необязательный параметр StepCallback — функция обратного вызова на каждом шаге. Если callback возвращает False, движение немедленно прекращается.

TMoverStepCallBack = function(X, Y: Word; Z: ShortInt): Boolean;

Метод блокирует выполнение до достижения цели (в пределах accuracy), блокировки пути, возврата False из callback, отмены через MoverStop или остановки скрипта.

При отключении персонажа во время движения поведение зависит от настройки moveExitOnDisconnect: если включена, метод сразу возвращает False; иначе ожидает переподключения.

На поведение метода влияют следующие переменные движения: moveOpenDoor, moveThroughNPC, moveThroughCorner, moveBetweenTwoCorners, moveCheckStamina, moveHeuristicMult, moveTurnCost, moveExitOnDisconnect.

Возвращает True, если цель достигнута в пределах указанной точности, False — в противном случае.

DWS

function MoveXY(Xdst: Word; Ydst: Word; Optimized: Boolean;
  Accuracy: Integer; Running: Boolean;
  StepCallback: TMoverStepCallBack = nil): Boolean;

Pascal Script

function MoveXY(Xdst: Word; Ydst: Word; Optimized: Boolean;
  Accuracy: Integer; Running: Boolean): Boolean;

Python

def MoveXY(Xdst: int, Ydst: int, Optimized: bool,
           Accuracy: int, Running: bool) -> bool: ...

In Python, newMoveXYZ is also available — a Python-only advanced movement method with automatic path recalculation, disconnect handling, and optional step callback. Unlike the built-in MoveXY, it recalculates the path on the fly when steps fail or cells become impassable.

В Python также доступен newMoveXYZ — продвинутый Python-метод перемещения с автоматической перестройкой пути, обработкой отключений и опциональным callback на каждом шаге. В отличие от встроенного MoveXY, пересчитывает путь на лету при неудачных шагах или непроходимых клетках.

Pascal Example

Simple movement:

begin
  if MoveXY(1500, 1200, True, 1, True) then
    AddToSystemJournal('Arrived at destination')
  else
    AddToSystemJournal('Could not reach destination');
end.

With StepCallback (DWS):

function StepCallBack(X, Y: Word; Z: ShortInt): Boolean;
begin
  Result := True;
  if InJournal('Paralyzed') >= 0 then
    Exit(False);
end;

begin
  MoveXY(1500, 1200, True, 1, True, @StepCallBack);
end.

Python Example

if MoveXY(1500, 1200, True, 1, True):
    AddToSystemJournal('Arrived at destination')
else:
    AddToSystemJournal('Could not reach destination')

See Also

MoveXYZ, newMoveXY, newMoveXYZ, Step, StepQ, GetPathArray, MoverStop, moveOpenDoor, moveThroughNPC, moveThroughCorner, moveBetweenTwoCorners, moveCheckStamina, moveHeuristicMult, moveTurnCost, moveExitOnDisconnect