Script Name: Restricted Rest
What it does: Prevents PC's from resting anywhere they choose.
Instead, the module designer can flag areas as restable (either an entire
NWN Area, or a smaller area, such as a roadside campsite, defined by a
trigger.
Notes: Integration with some sort of wandering monster script should
probably also be added. Basically, an area can have a flag, SAFE_REST,
indicating the option of the rest being interrupted by a wandering monster.
But for my initial run, this is good enough.
First, place this script in your Module's OnResting event:
NWScript:
void main()
{
int iRestEvent = GetLastRestEventType();
if (iRestEvent == REST_EVENTTYPE_REST_STARTED) {
object oRestingPC = GetLastPCRested();
int iAllowedToRest = GetLocalInt(oRestingPC, "ALLOWED_TO_REST");
if (iAllowedToRest == 0) {
AssignCommand(oRestingPC, ClearAllActions());
FloatingTextStringOnCreature("You are not allowed to rest here.", oRestingPC, FALSE);
}
}
}
This basically disallows rest everywhere in your module. Now, two scripts
will allow a player to rest. One goes in the OnEnter of a Trigger (around a
campsite for example) or Area (on the entire second floor of an Inn
containing rooms or a secluded glade for example) and the other goes in the
OnExit of the same Trigger/Area.
OnEnter:
NWScript: void main()
{
object oPC = GetEnteringObject();
if (GetIsPC(oPC)) {
SetLocalInt(oPC, "ALLOWED_TO_REST", 1);
}
}
OnExit:
NWScript: void main()
{
object oPC = GetExitingObject();
if (GetIsPC(oPC)) {
DeleteLocalInt(oPC, "ALLOWED_TO_REST");
}
}
Voila
|