SetNpcWeapon: Difference between revisions
Jump to navigation
Jump to search
Complete Lua function catalog |
Document new NPC/player-mode API and events available from 0.1.5 |
||
| (One intermediate revision by the same user not shown) | |||
| Line 37: | Line 37: | ||
[[Category:NPC Functions]] | [[Category:NPC Functions]] | ||
[[Category:Equipment Functions]] | [[Category:Equipment Functions]] | ||
<!-- npc015:start --> | |||
== Draw state since 0.1.5 == | |||
Equipping does not draw or start combat. A different item resets draw mode; repeating the same item preserves it. Use [[setNpcWeaponMode]]. Ranged state is also replayed for relevance entry/late join. See [[NPC scripting]]. | |||
<!-- npc015:end --> | |||
<!-- npc-appearance015:start --> | |||
== Appearance API since 0.1.5 == | |||
NPC appearance controls from 0.1.5 do not equip, remove or draw weapons. Use [[getPlayerRangedWeaponNames]] for ranged item keys and [[getPlayerWeaponNames]] for melee keys; see [[setNpcWeaponMode]] for drawn mode. | |||
<!-- npc-appearance015:end --> | |||
Latest revision as of 17:37, 25 September 2026
setNpcWeapon
Changes the authoritative weapon of a resource-owned scripted NPC.
Syntax
bool setNpcWeapon(int npcId, string itemKey)
Parameters
| Name | Type | Required | Description |
|---|---|---|---|
npcId |
int |
yes | The server-assigned NPC identifier returned by spawnNpc or getNpcs.
|
itemKey |
string |
yes | A validated key returned by getPlayerWeaponNames; armor and weapon accept none to clear the slot.
|
Returns
Returns true when the validated change is accepted and replicated; otherwise returns false.
Examples
Change an NPC's weapon:
setNpcWeapon(npcId, "none")
Notes
- Available only in server-side resource scripts.
- The state is sent reliably to current viewers and replayed on relevance entry and late join.
- Raw Unreal object paths are never accepted from Lua.
- Use
getPlayerWeaponNamesto enumerate supported keys.
Draw state since 0.1.5
Equipping does not draw or start combat. A different item resets draw mode; repeating the same item preserves it. Use setNpcWeaponMode. Ranged state is also replayed for relevance entry/late join. See NPC scripting.
Appearance API since 0.1.5
NPC appearance controls from 0.1.5 do not equip, remove or draw weapons. Use getPlayerRangedWeaponNames for ranged item keys and getPlayerWeaponNames for melee keys; see setNpcWeaponMode for drawn mode.