It allows a door to only be opened when a placeable is used. this can be used with or without a key, and best of all it is 100% generic.
Code: Select all
//::///////////////////////////////////////////////
//:: Name remote_door_open
//:: FileName remote_door_open.nss
//:: Copyright (c) 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
When a PC uses the placeable, it opens a door with
tag: DOOR_<tag of placeable>
*/
//:://////////////////////////////////////////////
//:: Created By: Psyco
//:: Created On: March 18, 2004
//:://////////////////////////////////////////////
// It gets the keytag from the keytag field of the target door.
// The keytag on the door must have the form NOKEY_<keytag>
// If there is a blank keytag on the door, no key will be required.
#include "nw_i0_plot"
void main()
{
string sTempTag = GetTag(OBJECT_SELF);
object oDoor = GetObjectByTag("DOOR_"+ sTempTag);
if (GetIsObjectValid(oDoor))
{
string sTempKeyTag = GetLockKeyTag(oDoor);
int nLength = GetStringLength(sTempKeyTag);
int nKeyTagLength = nLength - GetStringLength("NOKEY_");
if (nKeyTagLength > 0)
{
string sKeyTag = GetStringRight(sTempKeyTag, nKeyTagLength);
object oPC=GetLastUsedBy();
if (HasItem(oPC, sKeyTag))
{
ActionOpenDoor(oDoor);
}
}
else
{
ActionOpenDoor(oDoor);
}
}
}