1. Script Name: - Open Sesame
2. What it does: This script will Unlock and open multiple doors,
using a lever or pull chain, then close and lock them with a second pull of
the lever or chain, with the added delight of locking and unlocking a
MainDoor in the process. Great for prison setups.
3. Notes: This script should be placed in the OnUsed and OnDeath
portions of the lever or chain being used to activate this script.
4. The Script itself
NWScript:
void main()
{
object oDoor ;
int nDoorLocked;
int nDoorOpen;
int count = 0;
string sDoorTag;
oDoor = GetObjectByTag ("Door1", count);
if ( GetLocalInt ( OBJECT_SELF, "m_bActivated" )==TRUE)
{
SetLocalInt (OBJECT_SELF,"m_bActivated",FALSE);
ActionPlayAnimation ( ANIMATION_PLACEABLE_ACTIVATE);
}
else if ( GetLocalInt (OBJECT_SELF,"m_bActivated") ==FALSE)
{
SetLocalInt (OBJECT_SELF,"m_bActivated",TRUE);
ActionPlayAnimation (ANIMATION_PLACEABLE_DEACTIVATE);
}
while (oDoor != OBJECT_INVALID)
if ( GetIsObjectValid (oDoor) == TRUE )
{
sDoorTag = GetTag (oDoor);
nDoorLocked = GetLocked (oDoor);
nDoorOpen = GetIsOpen (oDoor);
if ( nDoorLocked && nDoorOpen==FALSE)
{
SetLocked ( oDoor,FALSE );
ActionOpenDoor ( oDoor );
}
else if ( nDoorOpen && nDoorLocked==FALSE)
{
ActionCloseDoor (oDoor);
SetLocked (oDoor,TRUE);
}
else if ( nDoorOpen==FALSE && nDoorLocked==FALSE)
{
ActionOpenDoor (oDoor);
}
count++;
oDoor = GetObjectByTag ("Door1", count);
}
object oDoorMain;
int nDoorLockedMain;
int nDoorOpenMain;
string sDoorTagMain;
oDoorMain = GetObjectByTag ("MainDoor", 0);
if ( GetIsObjectValid (oDoorMain) == TRUE )
{
sDoorTagMain = GetTag (oDoorMain);
nDoorLockedMain = GetLocked (oDoorMain);
nDoorOpenMain = GetIsOpen (oDoorMain);
if ( nDoorLockedMain==FALSE && nDoorOpenMain==FALSE)
{
SetLocked ( oDoorMain,TRUE );
}
else if ( nDoorLockedMain==TRUE && nDoorOpenMain==FALSE)
{
SetLocked (oDoorMain,FALSE);
}
}
}
As a side note. This script will check the open/closed state of the MainDoor,
however it will not open or close the door for you. I am using the following
script in the OnOpen event slot for my MainDoor.
NWScript: void main()
{
DelayCommand(5.0, ActionCloseDoor(OBJECT_SELF));
}
that way I don't have to worry about closing the MainDoor before the lever
locks it.
Enjoy. Please PM me or post in
THIS THREAD for comments and bug reports. It is working great in one of
my modules right now. I have it working with 9 Door1's and 1 maindoor with
no problems.
_________________
-Pyldrvr
Go check out
www.gameslapper.com
|