SetNpcMoveGoal

From Wiki G1R-MP G1 Remake Multiplayer
Jump to navigation Jump to search

setNpcMoveGoal

AVAILABLE FROM UPDATE 0.1.2
This function is available in G1R:MP 0.1.2 and later. The contract below includes the compatibility guarantees introduced in that update.

Assigns one direct, collision-checked movement goal to a resource-owned NPC in scripted navigation mode.

Syntax

bool setNpcMoveGoal(int npcId, number x, number y, number z [, table options])

Parameters

Name Type Required Description
npcId int yes The server-assigned NPC identifier returned by spawnNpc or getNpcs.
x number yes Goal X coordinate in metres.
y number yes Goal Y coordinate in metres.
z number yes Ground-location Z reference in metres.
options table no Optional { speed = number, arrivalRadius = number }. speed is measured in metres per second, must be 0.1-12, and defaults to 1. arrivalRadius is measured in metres, must be 0.01-5, and defaults to 0.2.

Returns

Returns true when the complete goal is accepted; otherwise returns false.

Examples

Move an NPC directly toward a work point:

setNpcNavigationMode(npcId, "scripted")
setNpcMoveGoal(npcId, 20.0, -7.5, 2.0, {
    speed = 1.5,
    arrivalRadius = 0.25,
})

Notes

  • Available only in server-side resource scripts.
  • Only the owning resource may set a goal, and the NPC must already be in "scripted" mode.
  • The goal is a direct segment. Scripted mode does not run route path finding, wait/avoid behavior or automatic detours.
  • Static world blockers and authoritative player, NPC and monster capsules remain hard constraints. A blocked goal remains active and resumes only after a valid direct step becomes available.
  • The owning resource receives one onNpcMoveBlocked edge when continuous blockage begins and one onNpcMoveComplete event when the arrival radius is reached.
  • Movement is ground-only. The Z value must describe a plausible nearby ground location; this API does not control vertical velocity or moving platforms.