Author Sticky: Post Working Scripts Here
Haelix Posted: Monday, 22 July 12:38PM
Name: Locked Trapdoor

By: Bioware Modified By: Haelix 7/20/02

What It Does: Simply a modified version of the animated teleporting trapdoor orig. by bio. Requires a specific key to open, and not having the key will get you a message stating that the trapdoor is locked and requires a key. Very simple script to use.

Place in the onused slot of a TrapDoor(marked usable and plot)
NWScript:
//::////////////////////////////////////////////////////

//::               Locked Trap Door

//::  A modified version of the orig. Bioware TD script.

//::  This one requires a key to open the trapdoor, it

//::  also states that it requires a key to open if

//::  someone tries to open it without the key.

//::  By: Bioware, Modified By: Haelix 7/20/02

//::////////////////////////////////////////////////////

void main()

{

    //Get PC

    object oPC = GetLastUsedBy();

    //Get Trapdoor tag and open/closed state

    object oDoor = GetObjectByTag("trapdoor_tag_here");

    int nDoorState = GetLocalInt(oDoor, "Opened");

    //get the target waypoint destination

    object oDrop = GetWaypointByTag("wp_destination_tag_here");

      if (nDoorState == FALSE) //the door is closed, so try to open it

        {

        if (GetIsObjectValid(GetItemPossessedBy(oPC, "key_tag_here")))  //if the pc has the key open the door

          {

           //have the PC kneel down and act as if opening the trapdoor

           AssignCommand(oPC, ActionPlayAnimation(ANIMATION_LOOPING_GET_LOW, 0.7f));

           //swing the door to open after a slight delay to allow for the PC's animation

           DelayCommand(1.0f, ActionPlayAnimation(ANIMATION_PLACEABLE_OPEN));

           //change status of door to open

           SetLocalInt(oDoor, "Opened", 1);

          }

        else // door is closed and pc lacks the key

          {

           AssignCommand(oDoor, SpeakString("This trapdoor is locked and requires a key."));

          }

        }

      else  //the door is open, so jump the player

      {

      //jump the PC to the destination

      AssignCommand (oPC,JumpToObject(oDrop));

      //closing the door would be optional, you could

      //just leave it open for the next player

      //close the trapdoor

      PlayAnimation (ANIMATION_PLACEABLE_CLOSE);

      //change status of door to closed

      SetLocalInt(oDoor, "Opened", 0);

      }

}



_________________
The Preceding Has Been A Paid Advertisement For The Get A Life Haelix Foundation