Post by Stingray888 on Sept 4, 2013 2:24:46 GMT
nwvault.ign.com/View.php?view=Scripts.Detail&id=3871
A few scripts I wrote many years ago for use in The Vast PW to lock doors at night without using a heartbeat event.
Works in NWN, but I have no idea if it works in NWN2.
Three scripts:
tg_door_nightloc - goes in the OnEnter of a trigger you paint in front of the door. This just gets the nearest door when a player enters the trigger, and locks it if it's night time.
door_close15 - Closes the door in 15 seconds; place in the door's OnOpened event.
door_fto_nc - Use in the door's OnFailedToOpen event to notify players the door is locked at night.
Instructions:
Paint a generic trigger directly in front of the door. Make it a little wider than the door on each side, and about as deep too.
Be sure the trigger extends far enough away from the door that it will be entered before the PC can open the door.
Place tg_door_nightloc in the OnEnter of a trigger you paint in front of the door.
Place the other scripts as noted above.
Instructions are also in the comments in the scripts.
//tg_door_nightloc
//Created by Algernon's Ghost for The Vast, a NWN Persistent Role-Playing World.
//Paint a small generic trigger in front of any door you want
//to be locked at night. Be sure the trigger extends far enough
//away from the door that it will be entered before the PC can
//open the door.
//Place this script in the trigger's OnEntered event handler.
//Use the script, door_close, in the OnOpened event of the door.
//Set the door to PLOT if you don't want players bashing it down
//to gain entry.
//Use the script door_fto_nc if you want to notify players that the
//door is locked at night.
void main()
{
object oPC = GetEnteringObject();
//Only player possessed avatars will trigger this.
if (GetIsPC(oPC))
{
object oDoor = GetNearestObject(OBJECT_TYPE_DOOR);
if (GetIsNight())
{
SetLocked(oDoor, TRUE);
return;
}
else
{
SetLocked(oDoor, FALSE);
}
}
}
//door_fto_nc
//Notification that the door is locked at night.
//Use in OnFailedToOpen event, in conjunction with the night
//locking trigger (see tg_door_nightloc).
void main()
{
object oPC = GetClickingObject();
if (GetLocked(OBJECT_SELF) == TRUE)
{
FloatingTextStringOnCreature("This door is locked at night.", oPC);
}
}
//door_close15
//for OnOpened event of door
void main()
{
DelayCommand( 15.0f, ActionCloseDoor( OBJECT_SELF ));
}
A few scripts I wrote many years ago for use in The Vast PW to lock doors at night without using a heartbeat event.
Works in NWN, but I have no idea if it works in NWN2.
Three scripts:
tg_door_nightloc - goes in the OnEnter of a trigger you paint in front of the door. This just gets the nearest door when a player enters the trigger, and locks it if it's night time.
door_close15 - Closes the door in 15 seconds; place in the door's OnOpened event.
door_fto_nc - Use in the door's OnFailedToOpen event to notify players the door is locked at night.
Instructions:
Paint a generic trigger directly in front of the door. Make it a little wider than the door on each side, and about as deep too.
Be sure the trigger extends far enough away from the door that it will be entered before the PC can open the door.
Place tg_door_nightloc in the OnEnter of a trigger you paint in front of the door.
Place the other scripts as noted above.
Instructions are also in the comments in the scripts.
//tg_door_nightloc
//Created by Algernon's Ghost for The Vast, a NWN Persistent Role-Playing World.
//Paint a small generic trigger in front of any door you want
//to be locked at night. Be sure the trigger extends far enough
//away from the door that it will be entered before the PC can
//open the door.
//Place this script in the trigger's OnEntered event handler.
//Use the script, door_close, in the OnOpened event of the door.
//Set the door to PLOT if you don't want players bashing it down
//to gain entry.
//Use the script door_fto_nc if you want to notify players that the
//door is locked at night.
void main()
{
object oPC = GetEnteringObject();
//Only player possessed avatars will trigger this.
if (GetIsPC(oPC))
{
object oDoor = GetNearestObject(OBJECT_TYPE_DOOR);
if (GetIsNight())
{
SetLocked(oDoor, TRUE);
return;
}
else
{
SetLocked(oDoor, FALSE);
}
}
}
//door_fto_nc
//Notification that the door is locked at night.
//Use in OnFailedToOpen event, in conjunction with the night
//locking trigger (see tg_door_nightloc).
void main()
{
object oPC = GetClickingObject();
if (GetLocked(OBJECT_SELF) == TRUE)
{
FloatingTextStringOnCreature("This door is locked at night.", oPC);
}
}
//door_close15
//for OnOpened event of door
void main()
{
DelayCommand( 15.0f, ActionCloseDoor( OBJECT_SELF ));
}