Server Totals
M'Chek - (1)
Wilderness - (0)
Ferrell - (0)
Elysia - (0)
Le'Or - (0)
Deglos - (0)
Visimontium - (0)
Underdark - (0)
Mikona - (0)
Total players: 1
Gallery
  • Winter Ball 2015
    Album name: DM Events
    Uploaded by: Ronan
    Uploaded: Sat Jan 03, 2015 4:15 pm

Links Menu

open a door with a lever (keyed and unkeyed)

Moderators: Nighthawk4, Dungeon Masters

open a door with a lever (keyed and unkeyed)

PostAuthor: Psyco » Thu Mar 18, 2004 3:22 am

This is something we were discussing last night in IRC.

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);
        }
    }
}
User avatar
Psyco
Elder Sage
 
Posts: 3297
Joined: Mon Jun 30, 2003 10:05 pm
Location: New Zealand (NZDT, +12 GMT)

PostAuthor: Mistcaller » Thu Mar 18, 2004 9:51 am

Well done Psyco! :)


-Mistcaller,
fan of generic scripts
User avatar
Mistcaller
Team Member; Retired with Honors
 
Posts: 5481
Joined: Sun Feb 09, 2003 3:42 pm
Location: Athens, Greece (GMT +2)

PostAuthor: Psyco » Thu Mar 18, 2004 11:00 am

Considering that is the first time i have ever written a NWN script, i think i did fairly well :-)
User avatar
Psyco
Elder Sage
 
Posts: 3297
Joined: Mon Jun 30, 2003 10:05 pm
Location: New Zealand (NZDT, +12 GMT)


Return to NWN Scripting

Who is online

Registered users: Bing [Bot], Google [Bot]