Script:spawn npc: Difference between revisions

From Arx Libertatis Wiki
Jump to navigation Jump to search
mNo edit summary
mNo edit summary
Line 5: Line 5:
script path Script path (without file extension) of the entity to add, relative to <code>graph/obj3d/interactive/npc</code>
script path Script path (without file extension) of the entity to add, relative to <code>graph/obj3d/interactive/npc</code>
target entity Existing entity from which to copy the position and rotation for the new entity
target entity Existing entity from which to copy the position and rotation for the new entity
|intro=New entities will be assigned an '''unused''' instance number which means that it is not possible to create entities with instance scripts using this command (or any other script command).
|intro=The new entity will be placed in the world at the position of the given target entity with the same rotation.


The created entity will be sent the {{Event|load}}, {{Event|init}} and {{Event|initend}} events (in that order).
The created entity will be sent the {{Event|load}}, {{Event|init}} and {{Event|initend}} events (in that order).
Line 25: Line 25:


The ID of the created entity can be retrieved via the <code>^last_spawned</code> [[Script:Variables#System variables|system variable]]. It will be made up of the filename component of the script path (the entity class) followed by <code>_</code> 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.
The ID of the created entity can be retrieved via the <code>^last_spawned</code> [[Script:Variables#System variables|system variable]]. It will be made up of the filename component of the script path (the entity class) followed by <code>_</code> 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).


[[Category:Script commands creating entities]]
[[Category:Script commands creating entities]]

Revision as of 21:35, 22 June 2022

The spawn npc script command is used to create a new NPC entity. The new entity will be placed in the world at the position of the given target entity with the same rotation.

The created entity will be sent the load, init and initend events (in that order).

This command only creates NPC entities. To create items use spawn item, inventory add, inventory addmulti, inventory playeradd, inventory playeraddmulti or setweapon.

To replace an existing entity use replaceme instead.

⚠️
This command has no effect while re-loading an area that was already visited before, e.g. in the reload event.

Usage

spawn npc <script> <target>

Context: For self

Parameters:

ParameterTypeDescription
script path Script path (without file extension) of the entity to add, relative to graph/obj3d/interactive/npc
target entity Existing entity from which to copy the position and rotation for the new entity

Script path

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

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

Entity ID

The ID of the created entity can be retrieved via the ^last_spawned system variable. It 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).