ActionUnlockObject(object)

From NWN Lexicon
Jump to navigationJump to search

Causes a creature to unlock a door or other locked object.

void ActionUnlockObject(
    object oTarget
);

Parameters

oTarget
Door or placeable object that will be the target of the unlock attempt.


Description

The action subject will unlock oTarget, which can be a door or a placeable object.

ActionUnlockObject performed by creatures will use either the correct key, or the Open Lock skill to get the lock open.

If performed by a door or placeable on themselves it will unlock them, but it is much easier and more reliable to use SetLocked in all cases since it fails if the door has a key and also the objects have delayed action queues so it may not trigger in a reliable amount of time.


Remarks

Used in the script of a creature (or assigned to a creature), it will move that creature to the door and use its Open Lock skill to attempt to unlock the door (or placeable) or key if they possess it.

If a PC fails to open a lock (eg low skill, or no key and no skill) then associates will be told about this in a special shout obtainable via. the OnConversation event.


Example

// In this example OnBlocked script, the NPC will unlock the door he ran into.
void main()
{
    object oDoor = GetBlockingDoor();

    // The blocking door can be a creature, too!
    if (GetObjectType(oDoor) == OBJECT_TYPE_DOOR)
        ActionUnlockObject(oDoor);
}

See Also

functions:  ActionLockObject, SetLocked



author: Tom Cassiotis, editor: Lilac Soul, additional contributor(s): Lilac Soul