/////////////////////////////////////////////
//
// created by _Knightmare_
// 12.??.2010
//
// door_all
// Altered by: Greyfort
// 12.18.2010
//
// place script in onFailToOpen of door
//
// set variables on door from the advanced tab variables button
// set door plot, set door locked, door set relockable
//door int "sClose"
//------------------ SET CLOSE DOOR DELAY -------------------
// Set a local int of the door called "sClose"
// Set it to the value you want for delay
// Default 15 second delay
//door string "LOCKED",
//------------------ SET LOCK BASED ON DAY/NIGHT SETTING -------------------
// Set local string on door named "LOCKED" to decide when it is locked
// Applicable entries are "DAY"=locked day time and "NIGHT"=locked night time
//door string "ALIGN GE" , "ALIGN LC", "NEUTRAL" ,
//------------------ SET LOCK BASED ON ALIGNMENT -------------------
// Set local string on door called "ALIGN GE" (Alignment Good/Evil)
// Set local string on door called "ALIGN LC" (Alignment Law/Chaos)
// Applicable entries are "GOOD" and "EVIL" for the first string
// Applicable entries are "LAW" and "CHAOS" for the second string
// Optional setting for allowing True Neutral PCs through
// Set Local Int on Door called "NEUTRAL"
// Set to 1 for allowing True Neutrals through
// To restrict True Neutrals and not allow through set to 0 or don't have the int at all
//door int "class"
//------------------ SET LOCK BASED ON class -------------------
// Set a local int of the door called "class"
// Set it to the (constant) value of the class you want to be let through
// You can find class (constant) in lexicon
//door string"KEY"
//------------------ KEY UNLOCKED -------------------
// Set a local string of the door called "KEY"
// Set string value Tag of key item ie "castlekey"
////////////////////////////////////////////////////////////////////////////////
// Here's an all inclusive example for you.
// If nothing else it can serve to steer you in a direction:
////////////////////////////////////////////////////////////////////////////////
void main()
{
object oDoor = OBJECT_SELF;
object oPC = GetClickingObject(); // Get the player object that clicked on the door
//------------------ SET CLOSE DOOR DELAY -------------------
// Set a local int of the door called "sClose"
// Set it to the value you want for delay
// Default 15 second delay
float fClose;
string sClose = GetLocalString(OBJECT_SELF, "sClose");
if(sClose == "")
{
fClose = 15.0;
}
else if(sClose == "-1") return;
else
{
fClose = StringToFloat( sClose );
}
DelayCommand(fClose, ActionCloseDoor(oDoor));
if (GetLockLockable(oDoor))
{
SetLocked(oDoor, TRUE);
}
//------------------ SET LOCK BASED ON DAY/NIGHT SETTING -------------------
// Set local string on door named "LOCKED" to decide when it is locked
// Applicable entries are "DAY" and "NIGHT"
string sLocked = GetLocalString(oDoor, "LOCKED");
if(sLocked == "DAY")
{
if(GetIsDay()) // Daytime, close and lock door
{
if(GetIsOpen(OBJECT_SELF))
{
ActionCloseDoor(OBJECT_SELF);
}
ActionDoCommand(SetLocked(OBJECT_SELF,TRUE));
}
else if(GetIsNight()) // Night time, unlock door
{
if(GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
}
}
}
if(sLocked == "NIGHT")
{
if(GetIsNight()) // Night time, close and lock door
{
if(GetIsOpen(OBJECT_SELF))
{
ActionCloseDoor(OBJECT_SELF);
}
ActionDoCommand(SetLocked(OBJECT_SELF,TRUE));
}
else if(GetIsDay()) // Day time, unlock door
{
if(GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
}
}
}
//------------------ SET LOCK BASED ON ALIGNMENT -------------------
// Set local string on door called "ALIGN GE" (Alignment Good/Evil)
// Set local string on door called "ALIGN LC" (Alignment Law/Chaos)
// Applicable entries are "GOOD" and "EVIL" for the first string
// Applicable entries are "LAW" and "CHAOS" for the second string
// Optional setting for allowing True Neutral PCs through
// Set Local Int on Door called "NEUTRAL"
// Set to 1 for allowing True Neutrals through
// To restrict True Neutrals and not allow through set to 0 or don't have the int at all
int nDoorGE;
int nDoorLC;
string sDoorGE = GetLocalString(oDoor, "ALIGN GE");
if(sDoorGE == "GOOD")
{
nDoorGE == 4;
}
else if(sDoorGE == "EVIL")
{
nDoorGE == 5;
}
string sDoorLC = GetLocalString(oDoor, "ALIGN LC");
if(sDoorLC == "LAW")
{
nDoorLC == 2;
}
else if(sDoorLC == "CHAOS")
{
nDoorLC == 3;
}
// If door has an entry for "ALIGN GE" and/or "ALIGN LC" string variables
// Check to see if the PC's alignment matches the entry
// Unlock door if matched, else lock the door if no match
int nPCGE = GetAlignmentGoodEvil(oPC);
int nPCLC = GetAlignmentLawChaos(oPC);
// Good/Evil check
if(sDoorGE != "" && nPCGE == nDoorGE)
{
SendMessageToPC (oPC,"Good/Evil check door script fired");
if(GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
ActionOpenDoor(OBJECT_SELF);
}
else
{
SetLocked(OBJECT_SELF,TRUE);
}
}
// Law/Chaos check
if(sDoorLC != "" && nPCLC == nDoorLC)
{
SendMessageToPC (oPC,"Law/Chaos check door script fired");
if(GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
ActionOpenDoor(OBJECT_SELF);
}
else
{
SetLocked(OBJECT_SELF,TRUE);
}
}
// Optional - allow True Neutrals through
if(GetLocalInt(oDoor, "NEUTRAL") == 1)
{
if(GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
ActionOpenDoor(OBJECT_SELF);
//DEBUG MESSAGING
SendMessageToPC (oPC,"NEUTRAL check door script fired");
}
}
//------------------ SET LOCK BASED ON class -------------------
// Set a local int of the door called "class"
// Set it to the (constant) value of the class you want to be let through
// Get the PC's various classes
int nclass1 = GetclassByPosition(1, oPC);
int nclass2 = GetclassByPosition(2, oPC);
int nclass3 = GetclassByPosition(3, oPC);
//int nclass4 = GetclassByPosition(4, oPC);
// Compare PC's classes to door int variable
// If matched, unlock door, else lock door
int nDoorclass = GetLocalInt(oDoor, "class");
if((nclass1 == nDoorclass) || (nclass2 == nDoorclass) || (nclass3 == nDoorclass) )//|| (nclass4 == nDoorclass))
{
if(GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
ActionOpenDoor(OBJECT_SELF);
//DEBUG MESSAGING
SendMessageToPC (oPC,"class door script fired");
}
}
else
{
SetLocked(OBJECT_SELF,TRUE);
}
/*
If you leave either the "LAW/CHAOS" or the "GOOD/EVIL" strings blank (no entry value),
it will not check those of the player. So, you can let in all good or all evil,
all lawful or all chaotic (or all True Neutrals as an optional).
Or you can set both values and let in only LAWFUL GOOD, only CHAOTIC EVIL,
only CHAOTIC GOOD, etc.
You will need to look up the class constant number value.
It might keep locking/unlocking the door as different variables return true
throughout the script. Hopefully it will end up correct at the end.
*/
//------------------ KEY UNLOCKED -------------------
// Set a local string of the door called "KEY"
// Set string value Tag of key item ie "castlekey"
object oKey=GetObjectByTag(GetLocalString(OBJECT_SELF,"KEY"));
if(GetItemPossessor(oKey)==oPC)
{
SetLocked(OBJECT_SELF,FALSE);
ActionOpenDoor(OBJECT_SELF);
//DEBUG MESSAGING
SendMessageToPC (oPC,"KEY check door script fired");
}
/*
Greyfort Notes:
*/
//end of script
}
WORKING NWN1 SCRIPT: Based on what _Knightmare_ gave as a start.
Ive tested script in toolset works great. If you have any questions just ask we are here to help. Great script Idea _Knightmare_ I enjoyed getting it to work for nwn1.
Modifié par Greyfort, 19 décembre 2010 - 06:57 .