CreateTrapOnObject(int, object, int, string, string)

From NWN Lexicon
Jump to navigationJump to search

Creates a Trap on the object specified.

void CreateTrapOnObject(
    int nTrapType,
    object oObject,
    int nFaction = STANDARD_FACTION_HOSTILE,
    string  sOnDisarmScript = "",
    string  sOnTrapTriggeredScript = ""
);

Parameters

nTrapType
The base type of trap. TRAP_BASE_TYPE_*
oObject
The object that the trap will be created on. Works only on Doors and Placeables.
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 Trap on the object (doors and placeables only!) specified.


Remarks

After creating a trap on an object, you can change the trap's properties using the various SetTrap* scripting commands by passing in the object that the trap was created on (i.e. oObject) to any subsequent SetTrap* commands.


Known Bugs

The nFaction parameter may be buggy. The engine does store it but uses it in odd ways and the door/placeables faction might be used in certain circumstances. Once the Trap Script fires the use of GetIsReactionTypeFriendly, for instance, will generally be based on the object oObject not this faction ID.


See Also

functions: 

CreateTrapAtLocation SetTrapRecoverable

events: 

OnTrapTriggered Event


author: Mistress