SetNpcObstacleBehavior
setNpcObstacleBehavior
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.
Changes how a resource-owned NPC responds to dynamic characters blocking its route.
Syntax
bool setNpcObstacleBehavior(int npcId, string behavior)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
npcId |
int |
yes | The server-assigned NPC identifier returned by spawnNpc or getNpcs.
|
behavior |
string |
yes | Either "wait" or "avoid". Values are case-sensitive.
|
Returns
Returns true when the validated behavior is accepted; otherwise returns false.
Examples
Make an NPC try to walk around a dynamic blocker:
setNpcObstacleBehavior(npcId, "avoid")
Notes
- Available only in server-side resource scripts.
- This function is available since update 0.1.2.
- Only the resource that created the NPC may change this setting.
- The change applies immediately to the active route and remains in effect for later routes; route points do not need to be rebuilt.
- In
"wait"mode the NPC stops until the blocking player, NPC or monster clears. In"avoid"mode it attempts a safe collision-checked detour and falls back to waiting when no valid detour exists. - Neither mode bypasses static navigation blockers or character collision. The current value is returned as
getNpcData(npcId).obstacleBehavior.