#include "inc_misc_tools"
#include "inc_room_content"
void main()
    {
    object oPC = GetEnteringObject();
    if (!GetIsPC(oPC))
        return;
    if (GetIsObjectValid(GetItemPossessedBy(oPC,"DeathToken")))
        AssignCommand(oPC,JumpToLocation(GetLocation(GetObjectByTag("DeathCheater"))));
    //---------------------------- TOWN FUNCTIONS ----------------------------//
    if (GetLocalInt(OBJECT_SELF,"Town"))
        {
        if (AllPCsInTown())
            {
            if (GetLocalInt(GetModule(),"AreasExplored") >= RESET_AFTER_X_ROOMS)
                {
                oPC = GetFirstPC();
                while (GetIsObjectValid(oPC))
                    {
                    FloatingTextStringOnCreature("In order to replace traps module will be reset in 30 seconds please halt activity.",oPC,FALSE);
                    DelayCommand(10.0,FloatingTextStringOnCreature("In order to replace traps module will be reset in 20 seconds please halt activity.",oPC,FALSE));
                    DelayCommand(20.0,FloatingTextStringOnCreature("In order to replace traps module will be reset in 10 seconds please halt activity.",oPC,FALSE));
                    AssignCommand(oPC,PlaySound("as_cv_brickscrp1"));
                    DelayCommand(10.0,AssignCommand(oPC,PlaySound("as_cv_brickscrp1")));
                    DelayCommand(20.0,AssignCommand(oPC,PlaySound("as_cv_brickscrp1")));
                    oPC = GetNextPC();
                    }
                DelayCommand(30.0,ExecuteScript("restartmodule",GetModule()));
                return;
                }
            ClearAllTransitions();
            ResetMonsterSpawns();
            ResetHiddenWaypoints();
            }
        if (!GetXP(oPC))
            {
            DelayCommand(1.0,StartingGold(oPC));
            }
        SetLocalInt(oPC,"Rest",TRUE);
        }
    else
    //--------------------------- DUNGEON FUNCTIONS --------------------------//
        {
        if (!GetIsDM(oPC) && GetIsPC(oPC))
            {
            if (!GetLocalInt(OBJECT_SELF,"DoOnce"))
                {
                NotifyPartyAverageLevel(oPC);
                SetLocalInt(OBJECT_SELF,"DoOnce",TRUE);
                int iPartyLevel = PartyLevel(oPC);
                SetUpEncounters(iPartyLevel);
                SetUpContents(oPC,iPartyLevel);
                SetLocalInt(GetModule(),"AreasExplored",GetLocalInt(GetModule(),"AreasExplored")+1);
                }
            if (EXPORT_CHARACTERS)
                ExportSingleCharacter(oPC);
            }
        }
    }
