#include "inc_room_content"
object GetRestingPartyMember(object oPC);

void main()
    {
    object oLeader = OBJECT_SELF;
    object oPC = GetRestingPartyMember(oLeader);
    int iRest;
    if (GetIsObjectValid(oPC))
        iRest = TRUE;
    else
        oPC = oLeader;
    if (GetLocalInt(GetArea(oPC),"Town"))
        return;
    int iTimer = GetLocalInt(oLeader,"WanderingMonster") + 6;
    if (iTimer >= WANDER_MONSTER_TIMER
     || iRest == TRUE)
        {
        if (d100() <= WANDER_MONSTER_CHANCE)
            SetUpWanderingEncounter(oPC);
        SetLocalInt(oLeader,"WanderingMonster",0);
        }
    else
        SetLocalInt(oLeader,"WanderingMonster",iTimer);
    }

object GetRestingPartyMember(object oPC)
    {
    object oParty = GetFirstFactionMember(oPC);
    while (GetIsObjectValid(oParty))
        {
        if (GetIsResting(oParty))
            return oParty;
        oParty = GetNextFactionMember(oPC);
        }
    return OBJECT_INVALID;
    }
