Day and night areas
From NWNWiki
[edit] What it does
NPCs will randomly walk around in one area during the day, and at nightfall there is a 10% chance each heartbeat that they will move to their night area and randomly walk about there. At daybreak there is a 10% chance each heartbeat that they will move back to their day area.
[edit] The Script
Place this in the NPCs OnHeartbeat script and place two waypoints. One called "DayArea" and the other called "NightArea".
// Author: Kaylor (5/8/02)
if (IsInConversation(OBJECT_SELF) == FALSE){
int iDayNight = GetLocalInt(OBJECT_SELF, "TimeOfDay");
if (GetIsNight() == TRUE && iDayNight != 1 && d100(1) <= 10){
location lDestination = GetLocation(GetWaypointByTag("NightArea"));
object oArea = GetAreaFromLocation(lDestination);
object oCurrentArea = GetArea(OBJECT_SELF);
if (oArea != oCurrentArea){
SetLocalInt(OBJECT_SELF, "TimeOfDay", 3);
ClearAllActions();
ActionForceMoveToLocation(lDestination);}
else if (oArea == oCurrentArea){
SetLocalInt(OBJECT_SELF, "TimeOfDay", 1);}
}
else if (GetIsNight() == FALSE && iDayNight != 2 && d100(1) <= 10){
location lDestination = GetLocation(GetWaypointByTag("DayArea"));
object oArea = GetAreaFromLocation(lDestination);
object oCurrentArea = GetArea(OBJECT_SELF);
if (oArea != oCurrentArea){
SetLocalInt(OBJECT_SELF, "TimeOfDay", 3);
ClearAllActions();
ActionForceMoveToLocation(lDestination);}
else if (oArea == oCurrentArea){
SetLocalInt(OBJECT_SELF, "TimeOfDay", 2);}
}
if (iDayNight != 3){
ClearAllActions();
ActionRandomWalk();}
}
