How do you restrict player resting to a specific location on the map?
Hi, I know how to click the "no rest" checkbox in area properties (which disables resting in that entire area). But I've also seen modules where resting is only prohibited in certain areas of the map. (Such as modules that only allow resting inside of bedrooms). Can anyone show me how to do this? Thanks.
0
Comments
if (GetLastRestEventType() == REST_EVENTTYPE_REST_STARTED) { if (GetLocalInt(oPC, "NoRest") == 1) { SendMessageToPC(oPC, "You may not rest at this time."); AssignCommand(oPC, ClearAllActions()); // Cancel rest return; } }You might, for example, use the area OnEnter and OnExit scripts to set and clear NoRest. The bedroom area might contain a trigger that does the opposite (or clicking a bed might clear the flag temporarily).There is a snag with area and trigger OnEnter scripts - they fire again when a saved game is loaded. You can detect this, though. In the OnClientEnter script
if (GetLocalInt(oPC, "ModuleEnteredBefore")) { SetLocalInt(oPC, "Reload", TRUE); // This tells area and trigger OnEnter scripts that we are loading a saved game return; } SetLocalInt(oPC, "ModuleEnteredBefore", TRUE);then in the area or trigger OnEnter scriptif (GetLocalInt(oPC, "Reload") && (GetTag(oArea) == GetLocalString(oPC, "AreaEntered"))) { SetLocalInt(oPC, "Reload", FALSE); return; }This might seem complicated, but as long as you use generic scripts, you only have to write this code once to cover every eventuality. Of course, there might be cases where you need to code to fire when loading a saved game, but these are rare, at least for single player.