DMH-Online

Dungeon Masters Helper · Est. 2005

Areas Scripts

NWN Script: keyed_transitions.htm

Author Sticky: Post Working Scripts Here
Milamber-POL Posted: Thursday, 25 July 12:01AM
This script prevents a PC from using an area transition unless they have one of the seven keys that open rooms on the other side of the area transition. I don't allow resting except at the Inn in my module, and for that you need to buy a key from the barkeeper. To prevent cheap PCs from just going upstairs and resting in the hall I needed a script that would allow multiple keys to use a single door.


NWScript:
///////////////////////////////////////////////////////
// at_1doormanykey
// By:  Milamber-POL
// July 20, 2002
// OnAreaTransition
///////////////////////////////////////////////////////
//
// This prevents a PC from using an area transition
// Unless they have an appropriate key.   In this
// case the area transition leads to the second floor
// of an Inn Named the Rainbow Parrot.   There are
// a number of rooms on the second floor for resting
// but to get through the Area tranition the PC needs
// a key which has "ParrotKey" as the first part
// of the tag.
// NOTE the key is taken from the PC when they go back
// downstairs.
//
///////////////////////////////////////////////////////
void main()
{
  object oClicker = GetClickingObject();
  object oTarget = GetTransitionTarget(OBJECT_SELF);
  location lLoc = GetLocation(oTarget);
  string sKey = "ParrotKey";
  object firstItemInInv;
  object currentItemInInv;
    firstItemInInv = GetFirstItemInInventory(oClicker);
    currentItemInInv = firstItemInInv;
    SetLocalInt(OBJECT_SELF, "KEY_CHECK", FALSE);
    // Insure they have at least one object
    if(currentItemInInv != OBJECT_INVALID)
    {
        do
        {
          string sItem = GetTag(currentItemInInv);            // get the tag of the Item
          string s1 = GetStringLeft(sItem, 9);                // get the first 9 chartacters
            if(s1 == sKey)
            {
                SetLocalInt(OBJECT_SELF, "KEY_CHECK", TRUE);  // Set Local Int to True
            }
            // get next item
            currentItemInInv = GetNextItemInInventory(oClicker);
        // loop while we have a new item to check
        }while(currentItemInInv != OBJECT_INVALID &&
               currentItemInInv != firstItemInInv);
     }
    if (GetLocalInt(OBJECT_SELF, "KEY_CHECK") == 1)
    {
        AssignCommand(oClicker,JumpToLocation(lLoc));
    }
    else
    {
        SpeakString( "You need to have a room key to access this area.");
    }
}




Milamber-POL
Paladins of Light
www.pofl.org

⌂ All Scripts ← PreviousNext → 👁 Category List

All Areas Scripts

📄 ambient_npc_ani 📄 area_spawner 📄 change_lighting 📄 clean_trash_001 📄 clean_trash_002 📄 clean_trash_003 📄 despawn_mobs 📄 despawn_mobs_002 📄 disable_sound 📄 full_edge_transition_001 📄 full_edge_transition_002 📄 full_edge_transition_003 📄 full_edge_transition_004 📄 full_edge_transition_004a 📄 get_pcs 📄 guard_patrols 📄 keyed_transitions 📄 random_enc_001 📄 random_enc_002 📄 random_enc_003 📄 random_enc_004 📄 random_enc_006 📄 random_enc_009 📄 random_encounter_005 📄 random_interiors 📄 random_interiors_001a 📄 restrict_access 📄 sitting_area