NpcAttack
Jump to navigation
Jump to search
npcAttack
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.
Requests one ranged/magic attack against a player.
Syntax
npcAttack(npcId, playerId)
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. |
Returns
Returns true when accepted, false for a rejected request. Acceptance is not proof of a rendered animation, projectile release or hit.
Examples
npcAttack(npcId, playerId)
Notes
- Server-side only. Mutations require the NPC to belong to the calling resource; getters do not grant control.
- Since 0.1.5. Use the matching 0.1.5 client and server (Protocol 37).
- Use matching updated client and server. See NPC scripting for lifecycle, defaults, combat examples and collision limitations.
- For bow, crossbow or magic only. Requires drawn mode and resources. May wait/chase until an attempt is possible; stops after release or rejected attempt. Melee uses setNpcCombatTarget. Acceptance does not guarantee hit. Already released projectiles can survive stopping combat.