CreateTrapAtLocation(int, location, float, string, int, string, string)

From NWN Lexicon
Jump to navigationJump to search

Creates a square Trap object.

object CreateTrapAtLocation(
    int nTrapType,
    location lLocation,
    float fSize = 2.0f,
    string sTag = "",
    int nFaction = STANDARD_FACTION_HOSTILE,
    string sOnDisarmScript = "",
    string sOnTrapTriggeredScript = ""
);

Parameters

nTrapType
The base type of trap. TRAP_BASE_TYPE_* or line in traps.2da
lLocation
The location and orientation that the trap will be created at.
fSize
The size of the trap. Minimum size allowed is 1.0f. If no value set, defaults to 2.0f.
sTag
The tag of the trap being created. If no value set, defaults to an empty string.
nFaction
The faction of the trap. STANDARD_FACTION_*
sOnDisarmScript
The OnDisarm script that will fire when the trap is disarmed. If no value set, defaults to an empty string and no script will fire.
sOnTrapTriggeredScript
The OnTrapTriggered script that will fire when the trap is triggered. If no value set, defaults to an empty string and the default OnTrapTriggered script for the trap type specified will fire instead (as specified in the traps.2da).


Description

Creates a square Trap object.

The location provided is the centre of the trap, so a fSize of 2.0 is used then it will be 1.0M each direction. A fSize value of 10.0 for instance and a location point in the centre of a tile will mean it covers the entire tile.


Remarks

You cannot change the faction of the trap after creation to a non-standard faction since ChangeFaction only works with creatures. This does limit you somewhat to having traps only in the standard factions with this function.

For custom traps (different sizes, etc.) you can use JsonToObject with the trigger type, defining a trap addition to the trigger. While sorting a trap for a given faction is harder you might be able to sort the ID from doing ObjectToJson on an appropriate faction member (eg a PC, a custom faction NPC).


See Also

functions: 

CreateTrapOnObject

events: 

OnTrapTriggered Event , OnDisarm Event



author: Mistress