SetNpcRoute

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 09:55, 15 August 2026 by QCherry (talk | contribs) (Complete Lua function catalog)
Jump to navigation Jump to search

setNpcRoute

Assigns an ordered, optionally looping movement route to a resource-owned NPC.

Syntax

bool setNpcRoute(int npcId, table points [, table options])

Parameters

Name Type Required Description
npcId int yes The server-assigned NPC identifier returned by spawnNpc or getNpcs.
points table yes A one-based array of 1-256 points. Every point has x, y and z in metres and may have yaw in degrees and waitMs from 0 to 3600000.
options table no Optional { loop = bool, speed = number }; speed is 0.1-12 metres per second and defaults to 1.

Returns

Returns true when the complete route is validated and started; otherwise returns false.

Examples

Patrol between two guard posts:

setNpcRoute(npcId, {
    { x = 10, y = 5, z = 2, yaw = 90, waitMs = 1500 },
    { x = 18, y = 5, z = 2, yaw = 270, waitMs = 1500 },
}, { loop = true, speed = 1.8 })

Notes

  • Available only in server-side resource scripts.
  • Movement is simulated by the server and replicated as normal smoothed remote snapshots.
  • Route progress emits onNpcRoutePoint and non-looping completion emits onNpcRouteComplete.