Skip to content

Movement & Teleport

gObjMoveGate(aIndex, gate)

Teleports the player to a predefined move gate.

gObjMoveGate(aIndex, 27) -- Move to gate 27 (e.g., Lorencia)

gObjTeleport(aIndex, map, x, y)

Teleports the player to exact coordinates on a map.

gObjTeleport(aIndex, 0, 130, 130) -- Teleport to Lorencia (130,130)

MoveObjectTo(lpObj, map, x, y, autoStartHelper)

Moves a player to coordinates on a map, using the gate system for cross-map moves. Optionally starts the helper (auto-move) system.

MoveObjectTo(player, 0, 130, 130, false)

gObjTeleportMagicUse(aIndex, map, x, y)

Uses teleport magic to move the player (with teleport animation).

gObjTeleportMagicUse(aIndex, 0, 130, 130)

gObjGetRandomFreeLocation(map, ox, oy, tx, ty, count)

Finds a random free location on the map near the given coordinates.

  • Returns: boolean (modifies ox, oy by reference)
local ok = gObjGetRandomFreeLocation(0, player.X, player.Y, player.X, player.Y, 10)

gObjGetTargetPos(lpObj, sx, sy)

Calculates a target position offset from the object.

  • Returns: boolean, tx, ty (tuple)
local ok, tx, ty = gObjGetTargetPos(player, 3, 3)
if ok then
    LogAdd(LOG_BLUE, "Target pos: " .. tx .. "," .. ty)
end

gObjGetPositionTarget(lpObj)

Gets the current movement target position of the object.

gObjGetPositionTarget(monster)

gObjSetPosition(aIndex, x, y)

Directly sets the object's position (no teleport animation).

gObjSetPosition(aIndex, 130, 130)

PathFindMoveMsgSend(lpObj, x, y)

Sends a pathfinding move message to make the object walk to the position.

PathFindMoveMsgSend(monster, 130, 140)

gObjConbertTimeGetTIckCount(secondsBlock)

Converts seconds into days, hours, minutes, seconds.

  • Returns: days, hours, minutes, seconds (tuple)
local d, h, m, s = gObjConbertTimeGetTIckCount(90061)
LogAdd(LOG_BLUE, d .. "d " .. h .. "h " .. m .. "m " .. s .. "s")
-- Output: "1d 1h 1m 1s"