Door Guard
From NWNWiki
I realize it is easy to automatically close a door. However, most of the scripts already made just close it. It gets you wondering why, when no-one is around, all of a sudden the door closes behind you.
This script actually has someone close the door: The nearest person with the tag "DoorGuard". This script is placed on the door's OnOpen slot.
- Note that the script does not re-lock doors, or even check if the door has already been closed.
[edit] The Script
// This script, usually set to OnOpen, will command the nearest guard
// with the tag "DoorGuard" to wait 5 seconds, close the door, then
// return to where he was.
// Script created 8/14/2002 by Bokombur
void main()
{
object oGuard = GetNearestObjectByTag("DoorGuard", OBJECT_SELF, 1);
SetLocalLocation(oGuard, "BeforeDoorAction", GetLocation(oGuard));
AssignCommand(oGuard, ActionWait(5.0));
AssignCommand(oGuard, ActionCloseDoor(GetNearestObject(OBJECT_TYPE_DOOR,OBJECT_SELF,1)));
AssignCommand(oGuard, ActionMoveToLocation(
GetLocalLocation(oGuard, "BeforeDoorAction"),FALSE));
}
