From Arx Libertatis Wiki
Jump to navigation Jump to search

The setweapon script command is used to create and equip a weapon for an NPC. If the NPC already has a weapon equipped then that weapon will be destroyed.

Unlike other spawn commands, this command will work re-loading an area that was already visited before, e.g. in the reload event.


setweapon [-h] <class>

Context: NPCs


 -h: Don't show the weapon on the character's back while sheathed


class path Script class of the weapon to use, relative to graph/obj3d/interactive/items/weapons

Script path

The entity class script is loaded from graph/obj3d/interactive/items/weapons/<class>/<class>.asl.

If the filename component of the script path starts with gold_coin gold coin then the item will be treated as a gold coin which means that it will be added to the player's purse when the player interacts with it or when it would be added to the player inventory. Gold coins also somewhat act like stacks but use the price in place of the count and have the icon automatically selected based on the price.

If the script path contains the string movable then the item cannot be added to inventories and is dropped in front of the player instead whenever it would be.

The initial mesh of the item will be graph/obj3d/interactive/items/weapons/<class>/<class>.teo with the cooked mesh loaded from game/graph/obj3d/interactive/items/weapons/<class>/<class>.ftl. Either the raw mesh, cooked mesh or entity class script file must exist or the item will not be created.

The initial icon of the item will be graph/obj3d/interactive/itemsweapons/<class>/<class>[icon] if it exists or graph/interface/misc/default[icon] otherwise. The icon size determines how many slots the item takes up in inventories except for movable items (which have no icon) and gold coins (where the icon depends on the price).

ℹ️  In version before Arx Libertatis 1.3 the icon file at the default path must also exist or the item will not be created, even for gold coins, movable items or items that change the icon in the load event.

Entity ID

The ID of the created entity will be made up of the filename component of the script path (the entity class) followed by _ and a previously unused four-digit instance number - meaning one that does not have an instance directory in the game resources under the script path and does not have an existing entity in the current area or save file.

This also means that it is not possible to create entities with instance scripts using this command (or any other script command).

IDs of entities created with this command are not available via the ^last_spawned system variable

Entity initialization

The created item will be sent the load, init and initend events (in that order) before being equipped.