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 — not in use, kept for compatibility. There is no longer a non-optimized code path: the parameter is read and discarded, and the value passed makes no difference. Use moveHeuristicMult and moveTurnCost to tune the pathfinder.

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 callback receives the last server-confirmed position, not the predicted one the method itself moves by. Up to 4 steps can sit in the queue unconfirmed, so these coordinates may lag the character’s real progress by up to 4 tiles. Two practical consequences: the callback is never invoked for the destination tile — the last call comes before the final step, and arrival is checked against predicted coordinates — and any comparison against a GetPathArray route or against the destination is off by that same lag. GetX / GetY return the same confirmed position, so comparing against those is consistent.

The callback fires once per movement iteration rather than strictly once per step: an iteration that ends in a path recomputation calls it without stepping.

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.

MoveXY is MoveXYZ with the destination Z fixed at 0 and the Z accuracy at 255, so the Z coordinate is effectively ignored.

The method fails early, returning False without any pathfinding, if Xdst or Ydst is 0 (an error is written to the system journal), or if the destination is farther than 1000 tiles along either axis.

While moving, it checks passability up to 7 points ahead and recomputes the route whenever a point turns out to be impassable or a step is rejected. If the character ends up more than 5 tiles away from the expected position, this is treated as a teleport and the method returns False — a recall, gate or teleporter mid-route ends the movement. On arrival it waits for all queued steps to be sent and re-verifies the final position before returning True.

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

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

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

Optimized — не используется, оставлен для совместимости. Неоптимального пути в коде больше нет: параметр читается и отбрасывается, передаваемое значение ни на что не влияет. Для настройки поиска пути используйте moveHeuristicMult и moveTurnCost.

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

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

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

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

Callback получает последнюю подтверждённую сервером позицию, а не расчётную, по которой движется сам метод. В очереди может находиться до 4 неподтверждённых шагов, поэтому эти координаты отстают от реального продвижения персонажа до 4 тайлов. Два практических следствия: для точки назначения callback не вызывается никогда — последний вызов происходит перед финальным шагом, а приход проверяется по расчётным координатам — и любое сравнение с маршрутом из GetPathArray или с целью промахивается на ту же величину. GetX / GetY возвращают ту же подтверждённую позицию, поэтому сверка с ними согласована.

Callback вызывается раз на итерацию движения, а не строго на каждый шаг: итерация, закончившаяся пересчётом пути, вызовет его без шага.

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

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

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

MoveXY — это MoveXYZ с фиксированными Z назначения 0 и точностью по Z 255, то есть координата Z фактически не учитывается.

Метод завершается сразу с False, не выполняя поиск пути, если Xdst или Ydst равны 0 (в системный журнал пишется ошибка) либо если цель дальше 1000 тайлов по любой из осей.

В движении проверяет проходимость на 7 точек вперёд и пересчитывает маршрут, если точка оказалась непроходимой или шаг отклонён. Если персонаж оказался более чем в 5 тайлах от ожидаемой позиции, это считается телепортом и метод возвращает False — recall, gate или телепортер посреди маршрута прерывают движение. При достижении цели дожидается отправки всех шагов из очереди и повторно проверяет финальную позицию перед возвратом True.

Возвращает 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 movement method implemented in py_astealth rather than in the Stealth core. Automatic path recalculation, disconnect handling and the step callback are not what sets it apart: the built-in MoveXY does all three itself.

В Python также доступен newMoveXYZ — метод перемещения, реализованный в py_astealth, а не в ядре Stealth. Автоматическая перестройка пути, обработка отключений и 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