IsNpcSeeingPlayer

From Wiki G1R-MP G1 Remake Multiplayer
Revision as of 17:14, 25 September 2026 by QCherry (talk | contribs) (Document new NPC/player-mode API and events available from 0.1.5)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

isNpcSeeingPlayer

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

Tests distance/cone perception against server sight blockers.

Syntax

isNpcSeeingPlayer(npcId, playerId, maxDist=15, fov=120)

Parameters

Name Type Required Description
npcId int yes Server-assigned NPC ID returned by spawnNpc; not a player ID.
playerId int yes Connected player ID.
maxDist number no Optional distance in metres, greater than 0 and at most 1000; default 15.
fov number no Optional full horizontal field of view in degrees, greater than 0 and at most 360; default 120.

Returns

Returns true if distance, cone and server blocker checks pass; otherwise false.

Examples

local visible = isNpcSeeingPlayer(npcId, playerId, 20, 120)

Notes

  • Server-side only. Mutations require the NPC to belong to the calling resource; getters do not grant control.
  • Since 0.1.5. This documents the next release; public 0.1.4 does not include these additions.
  • Use matching updated client and server. See NPC scripting for lifecycle, defaults, combat examples and collision limitations.
  • Not full native-world raycasting. Uncovered terrain/buildings/doors/editor meshes do not automatically occlude this query. See NPC scripting#Visibility and collision.