void main()
{
object oDoor = OBJECT_SELF;
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 );
}
}
Door Script Modification
#1
Posté 11 décembre 2010 - 03:08
#2
Posté 11 décembre 2010 - 05:56
#3
Posté 11 décembre 2010 - 06:15
#4
Posté 11 décembre 2010 - 08:11
void main()
{
object oDoor = OBJECT_SELF;
//added this line
int nNightLocked = GetLocalInt(oDoor, "NIGHT_LOCKED");
//
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 );
}
// Added Code
if(nNightLocked == 1)
{
if (GetIsNight()&&GetIsOpen(OBJECT_SELF))
{
ActionCloseDoor(OBJECT_SELF);
ActionDoCommand(SetLocked(OBJECT_SELF,TRUE));
}
else if(GetIsDawn()&&GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
}
}
}
#5
Posté 12 décembre 2010 - 01:48
#6
Posté 12 décembre 2010 - 04:14
void main()
{
object oDoor = OBJECT_SELF;
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 == "NIGHT")
{
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 == "DAY")
{
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
object oPC = GetClickingObject(); // Get the player object that clicked on the door
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)
{
if(GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
}
else
{
SetLocked(OBJECT_SELF,TRUE);
}
}
// Law/Chaos check
if(sDoorLC != "" && nPCLC == nDoorLC)
{
if(GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
}
else
{
SetLocked(OBJECT_SELF,TRUE);
}
}
// Optional - allow True Neutrals through
if(GetLocalInt(oDoor, "NEUTRAL") == 1)
{
if(GetLocked(OBJECT_SELF))
{
SetLocked(OBJECT_SELF,FALSE);
}
}
//------------------ 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);
}
}
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.
Script should go in the OnClicked event of the door. It might keep locking/unlocking the door as different variables return true throughout the script. Hopefully it will end up correct at the end.
Script untested in game but should compile with no problems.
Also, note the forums here (for whatever reason) makes the letter "C" in the word "class" lower case. You will need to change them all to an upper case "C" if you do any sort of copy/paste.
Modifié par _Knightmare_, 17 décembre 2010 - 03:06 .
#7
Posté 14 décembre 2010 - 01:20
#8
Posté 14 décembre 2010 - 01:30
#9
Posté 14 décembre 2010 - 02:38
#10
Posté 15 décembre 2010 - 05:52
TR
Modifié par Tarot Redhand, 15 décembre 2010 - 05:53 .
#11
Posté 15 décembre 2010 - 11:37
_Knightmare_ wrote...
Also, note the forums here (for whatever reason) makes the letter "C" in the word "class" lower case. You will need to change them all to an upper case "C" if you do any sort of copy/paste.
Been a bit busy with other things haven't had a chance to test it just yet sorry.
Modifié par Birdman076, 15 décembre 2010 - 11:38 .
#12
Posté 17 décembre 2010 - 12:06
TR
#13
Posté 17 décembre 2010 - 12:39
Tarot Redhand wrote...
@_Knightmare_ There is no OnClick event for doors - see here.
TR
Hmmm, well that really stinks. I use NWN2 for everything and we have a full allotment of script slots for doors there (including all you listed in that linked post, plus OnClick, OnConversation, OnTrapTriggered, and OnDisarm). The scripting for both games is so similar I just try to also help people here.
The script should work if you can find an appropriate script slot for it to fire from... sorry about that.
#14
Posté 17 décembre 2010 - 01:13
TR
#15
Posté 18 décembre 2010 - 05:28
onAreaTransclick
onClose
onDamaged
onDeath
onFailToOpen
onHeartbeat
onLock
onPhysicalAttacked
onOpen
onSpellCastAt
onUnlock
onUserDefined
also for classes:
// Get the PC's various classes
int nclass1 = GetclassByPosition(1, oPC);
int nclass2 = GetclassByPosition(2, oPC);
int nclass3 = GetclassByPosition(3, oPC);
only those lines are valid there are not 4 class positions
in regaurds to :
Script should go in the OnClicked event of the door.
place in onFailToOpen script it calls the object oPC = GetClickingObject();
also you may have to divide the script up according to what you want. if you give a little more detail I can help you set up a nwn1 door useing script _Knightmare_ made it wont work as it is onFailToOpen we will have to break it up.
Edit add: I forgot to ask did you want variables on the door or only created after door is interacted with?
Modifié par Greyfort, 18 décembre 2010 - 05:33 .
#16
Posté 19 décembre 2010 - 06:55
//
// 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 .
#17
Posté 19 décembre 2010 - 01:19
Thanks.
#18
Posté 19 décembre 2010 - 02:33
//-------------------------------- class Type Constants ------------------------ //:: //:: Base classes //:: //:: class_TYPE_BARBARIAN - 0 class_TYPE_PALADIN - 6 //:: class_TYPE_BARD - 1 class_TYPE_RANGER - 7 //:: class_TYPE_CLERIC - 2 class_TYPE_ROGUE - 8 //:: class_TYPE_DRUID - 3 class_TYPE_SORCERER - 9 //:: class_TYPE_FIGHTER - 4 class_TYPE_WIZARD - 10 //:: class_TYPE_MONK - 5 //:: //:: Prestige classes //:: //:: class_TYPE_SHADOWDANCER - 27 //:: class_TYPE_HARPER - 28 //:: class_TYPE_ARCANE_ARCHER - 29 //:: class_TYPE_ASSASSIN - 30 //:: class_TYPE_BLACKGUARD - 31 //:: class_TYPE_DIVINECHAMPION - 32 (Champion of Torm) //:: class_TYPE_WEAPON_MASTER - 33 //:: class_TYPE_PALE_MASTER - 34 //:: class_TYPE_SHIFTER - 35 //:: class_TYPE_DWARVENDEFENDER - 36 //:: class_TYPE_DRAGONDISCIPLE - 37 //:: //------------------------------------------------------------------------------
Here are the class constants per the lexicon. Thank you for working on this and getting it to work it will come in very handy and help me eliminate a couple of handfuls of scripts from the PW I am working on.
Modifié par Birdman076, 19 décembre 2010 - 02:34 .
#19
Posté 19 décembre 2010 - 05:24
//----------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------
//::///////////////////////////////////////////////
//:: Name Special Key
//:: FileName scr_special_key
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
*/
//:://////////////////////////////////////////////
//:: Created By: Tarot Redhand
//:: Created On: 18th December 2010
//:://////////////////////////////////////////////
//#include needed for HasItem
#include "nw_i0_plot"
void SpecialKey(object oDoor, object oPC, string sKeyTag, string sFailMessage = "", int iDestroyItemOnSuccess = FALSE)
//simple routine to unlock a door oDoor if a specific item sKeyTag (tag of item) is carried by oPC
//if the item is not in oPC's inventory, oDoor "speaks" sFailMessage
//Note - oDoor is opened at the same time as it is unlocked
//Start with oDoor locked and call this from oDoor's OnFailToOpen event
{
if(HasItem(oPC, sKeyTag))
{
SetLocked(oDoor, FALSE);
if(iDestroyItemOnSuccess)
DestroyObject(GetObjectByTag(sKeyTag));
AssignCommand(oDoor, ActionOpenDoor(oDoor));
}
else
{
if(sFailMessage != "")
SpeakString(sFailMessage);
}
}
//----------------------------------------------------------------------------------------------------------------
void main()
{
//put call to SpecialKey here
}
//----------------------------------------------------------------------------------------------------------------
//next script
//----------------------------------------------------------------------------------------------------------------
/*
//:://////////////////////////////////////////////
//:: Name Unlocked By Spell
//:: FileName scr_unlok_by_spl
//:: Copyright © 2001 Bioware Corp.
//:://////////////////////////////////////////////
/*
*/
//:://////////////////////////////////////////////
//:: Created By: Tarot Redhand
//:: Created On: 18th September 2010
//:://////////////////////////////////////////////
void UnlockedBySpell(object oDoor, int iTargetSpell = SPELL_DISPEL_MAGIC)
//very simple routine to unlock lockable object oDoor when a specific spell intTargetSpell
//is cast at it otherwise oDoor will be locked
//call this function from the void main() part of the script that services an OnSpellCastAt event
{
if(GetLastSpell() == iTargetSpell)
SetLocked(oDoor, FALSE);
else
SetLocked(oDoor, TRUE);
}
//----------------------------------------------------------------------------------------------------------------
void main()
{
//call UnlockedBySpell from here uncomment the next line to try
//UnlockedBySpell(OBJECT_SELF, SPELL_LIGHT);
}
//----------------------------------------------------------------------------------------------------------------
//----------------------------------------------------------------------------------------------------------------
TR
Modifié par Tarot Redhand, 19 décembre 2010 - 05:27 .





Retour en haut







