#include "inc_misc_tools"
void main()
    {
    int i;
    int iDoors,iTraps,iSecretDoors,iFalls,iMon,iObjType,iHiddenTreasure;
    object oArea,oObject;
    string sTag;
    for (i = 1; i <= NUMBER_OF_AREAS; i+=1)
        {
        oArea = GetObjectByTag("Area"+Convert(i));
        // Sadly Traps can not be dynamically spawned. It is because of this fact that module resets are required.
        SetUpTraps(oArea);
        object oObject = GetFirstObjectInArea(oArea);
        while (GetIsObjectValid(oObject))
            {
            iObjType = GetObjectType(oObject);
            sTag = GetTag(oObject);
            switch (iObjType)
                {
                case OBJECT_TYPE_DOOR:
                    {
                    // ---------------------- TRANSITION DOORS ----------------
                    if (GetTag(GetTransitionTarget(oObject)) == "None")
                        SetLocalObject(GetModule(),"Door"+IntToString(iDoors+=1),oObject);
                    break;
                    }
                case OBJECT_TYPE_WAYPOINT:
                    {
                    // -----------------------SECRET DOORS---------------------
                    if (sTag == "SecretDoor")
                        {
                        if (d100() <= ROOM_SECRET_DOOR)
                            SetLocalInt(oObject,"Active",TRUE);
                        SetLocalObject(GetModule(),"SecretDoor"+IntToString(iSecretDoors+=1),oObject);
                        }
                    //----------------------- FALL POINTS ---------------------
                    else if (sTag == "Fall")
                        SetLocalObject(GetModule(),"Fall"+IntToString(iFalls+=1),oObject);
                    //------------------ ROOM MONSTER SPAWNS-------------------
                    else if (sTag == "MON_")
                        SetLocalObject(GetModule(),"MonsterWP"+IntToString(iMon+=1),oObject);
                    //------------------ HIDDEN TREASURE POINTS ---------------
                    else if (sTag == "HiddenChest")
                        {
                        if (d100() <= ROOM_HIDDEN_TREASURE)
                            SetLocalInt(oObject,"Active",TRUE);
                        SetLocalObject(GetModule(),"HiddenTreasure"+IntToString(iHiddenTreasure+=1),oObject);
                        }
                    break;
                    }
                };
            oObject = GetNextObjectInArea(oArea);
            }
        }
    // Save all counters.
    SetLocalInt(GetModule(),"Doors",iDoors);
    SetLocalInt(GetModule(),"SecretDoorWPs",iSecretDoors);
    SetLocalInt(GetModule(),"Falls",iFalls);
    SetLocalInt(GetModule(),"RoomMonsterWPs",iMon);
    SetLocalInt(GetModule(),"HiddenTreasureWPs",iHiddenTreasure);
    }
