////////////////////////////////////////////////////////////////////////////////
//
//  Map Exploration by Map
//  opw_map_exp_map
//  By Don Anderson
//  dandersonru@msn.com
//
//  Place this in the Area OnEnter Event
//
////////////////////////////////////////////////////////////////////////////////

void main()
{
    object oPC = GetEnteringObject();
    object oArea = GetArea(oPC);
    string sArea = GetTag(oArea);

    string sMExplore = "RegionMap";
    string sWPExplore = "REGION_MAP";

    //Use these to save CPU Cycles
    if(GetIsDM(oPC) == TRUE) return;
    if(GetIsDMPossessed(oPC) == TRUE) return;
    if(GetIsPC(oPC) == FALSE) return;

    object oMap = GetFirstItemInInventory(oPC);
    object oWPExplore = GetNearestObjectByTag("REGION_MAP",oPC,1);
    string sName = GetName(oWPExplore);

    string sMap;
    string sTag;
    string sResRef;

    //Now Loop Through Inventory and search for Maps
    while(oMap != OBJECT_INVALID)
    {
      sResRef = GetResRef(oMap);
      sMap = GetStringLeft(sTag,4);

      //Found a Map
      if(sMap == "map_")
      {
        sTag = GetTag(oMap);

        //Found our Area Map
        if(sTag == sName)
        {
          ExploreAreaForPlayer(oArea,GetEnteringObject());
          return;
        }
      }
      oMap = GetNextItemInInventory(oPC);
    }
}