Morrowind Mod:XSetTrap

The UESPWiki – Your source for The Elder Scrolls since 1995
Jump to: navigation, search

A function from MWSE update by Merzasphor.

Sets a trap. Returns 1 if successful, 0 if not (no trap/lock installed or invalid spellId). Pass 0 to remove an installed trap. There must be a lock installed to set a trap. To set a trap on an object with no lock installed, call Lock 0 and Unlock on the object first.

Traps that are set this way do not persist through saving and loading. If a trap is removed its removal persists only if the object is activated or its lock is manipulated before saving.

If you want to set a trap on a door/container, first check for an existing lock (xGetLockLevel). If no lock is already installed, use Lock 0, Unlock to create the lock/trap record. Set the trap. To make sure the trap is persistent, manipulate the lock, but then put it back to its original state. In other words, if the lock is currently unlocked, lock it (use xGetLockLevel to determine the correct lock level) then unlock it. Do the reverse if it's currently unlocked.

Syntax[edit]

success (short): ref->xSetTrap spellId (string | string ref)

Example[edit]

; Sets a trap on the player's target.
long target

setx target to xGetPCTarget
target->xSetTrap "trap_fire00"

See Also[edit]

xGetTrap