// Germania
// Made by Lord Duck for the Acient Age Mod

include "mercenaries.xs";
include "ypAsianInclude.xs";
include "ypKOTHInclude.xs";

void main(void)
{
  
   rmSetStatusText("",0.10);
   // ************************************** Choose Natives **************************************
	
	//CelticSet -> Celtic settlement
	//Chatti -> Chatti
        //Suebi -> Suebi
	//RomanSet -> Roman settlement
	
   int subCiv0=-1;
   int subCiv1=-1;
   int subCiv2=-1;
   int subCiv3=-1;
   int subCiv4=-1;
   int subCiv5=-1;
   
  //Romans and celtic settlements, and 2 Suebi and 2 Chatti villages all the time
  if (rmAllocateSubCivs(6) == true)
  {
		subCiv0=rmGetCivID("RomanSet");
                rmEchoInfo("subCiv0 is RomanSet "+subCiv0);		
      if (subCiv0 >= 0)
         rmSetSubCiv(0, "RomanSet");

		subCiv1=rmGetCivID("CelticSet");
		rmEchoInfo("subCiv1 is CelticSet "+subCiv1);		
      if (subCiv1 >= 0)
         rmSetSubCiv(1, "CelticSet");
         
                subCiv2=rmGetCivID("Chatti");
		rmEchoInfo("subCiv2 is Chatti "+subCiv2);		
      if (subCiv2 >= 0)
         rmSetSubCiv(2, "Chatti"); 
       
                subCiv3=rmGetCivID("Chatti");
		rmEchoInfo("subCiv3 is Chatti "+subCiv3);		
      if (subCiv3 >= 0)
         rmSetSubCiv(3, "Chatti");

		subCiv4=rmGetCivID("Suebi");
		rmEchoInfo("subCiv4 is Suebi "+subCiv4);
      if (subCiv4 >= 0)
         rmSetSubCiv(4, "Suebi");

		subCiv5=rmGetCivID("Suebi");
		rmEchoInfo("subCiv5 is Suebi "+subCiv5);
      if (subCiv5 >= 0)
         rmSetSubCiv(5, "Suebi");
  }

   rmSetStatusText("",0.20);
   // ************************************** Map Parameters **************************************

//Map Size   
   int playerTiles=10000;
	if (cNumberNonGaiaPlayers >4)
	    playerTiles = 9000;
   int size=2.0*sqrt(cNumberNonGaiaPlayers*playerTiles);
   rmEchoInfo("Map size="+size+"m x "+size+"m");
   rmSetMapSize(size, size);
   rmSetMapType("grass");
   rmSetMapType("land");
   
//Other Parameters
int foodcount=rmRandInt(10,11);
int lowgoldcount=rmRandInt(2,3);
int failCount = 0;
int rivercount = 0; 
int huntcount = 0;
int berrycount = 0;
int weather=rmRandInt(0,1);
int time=rmRandInt(1,5);
int terrainvariation=rmRandInt(1,2);
	
string rivertype = " ";
string foresttype = " ";
string hunttype = " ";

//Terrain Variation: 1-> Hilly 2-> Swampy   
if (terrainvariation == 1)
{
 rmTerrainInitialize("yukon\ground10_yuk", 0.0);
 rivertype = "Pampas River";
 rivercount=1;
 rmSetMapElevationParameters(cElevTurbulence, 10, 10, 10, 10.0);
 rmSetMapElevationHeightBlend(0);
 huntcount=foodcount-2;
 berrycount=foodcount-5;
}
else if (terrainvariation == 2)
{
 rmTerrainInitialize("pampas\ground5_pam", 0.0);
 rivertype = "Andes River";
 rivercount=rmRandInt(2,3);
 rmSetMapElevationParameters(cElevTurbulence,  0.4, 6, 0.7, 5.0);
 rmSetMapElevationHeightBlend(0);
 huntcount=foodcount-4;
 berrycount=foodcount-3;
}

//Weather: 1-> Rain 2-> Clear
if (weather == 0)
{
 rmSetGlobalRain( 0.99 );
 rmSetWindMagnitude(2.5);
}
else 
{
 rmSetWindMagnitude(1.5);
}

//Time: 1-> Day 2-> Night 3-> Foggy (Needs very high shadow settings!)
if (time <= 1)
{
 rmSetLightingSet("texas");
}
else if (time <= 3)
{
 rmSetLightingSet("st_petersburg_night");
}
else if (time <= 5)
{
 rmSetLightingSet("Yellow River");
}


   rmSetStatusText("",0.30);
   // ************************************** Define Classes **************************************
   int classPlayer=rmDefineClass("player");
   int guardedGoldClass = rmDefineClass("GuardedGold");
   int nativeClass = rmDefineClass("natives");
   int importantItem = rmDefineClass("importantItem");
   
   rmSetStatusText("",0.40);
   // ************************************ Define Constraints ************************************
   int forestObjConstraint=rmCreateTypeDistanceConstraint("forest obj", "all", 8.0);
   int StartingObjects = rmCreateClassDistanceConstraint("avoids starting objects", classPlayer, 6.0);
   int StartingObjectsTree = rmCreateClassDistanceConstraint("avoids starting objects tree", classPlayer, 14.0);
   int StartingObjectsMid = rmCreateClassDistanceConstraint("avoids starting objects medium", classPlayer, 40.0);
   int avoidGuardedGold = rmCreateClassDistanceConstraint("avoids guarded gold", guardedGoldClass, 40.0);
   int avoidGuardedGoldShort = rmCreateClassDistanceConstraint("avoids guarded gold short", guardedGoldClass, 8.0);
   int avoidWaterShort = rmCreateTerrainDistanceConstraint("avoids water short", "Land", false, 4.0);
   int avoidWater = rmCreateTerrainDistanceConstraint("avoids water", "Land", false, 10.0);
   int avoidAll=rmCreateTypeDistanceConstraint("avoids all", "all", 4.0);
   int avoidDeer=rmCreateTypeDistanceConstraint("avoids deer", "deer", 40.0);
   int avoidDeerMid=rmCreateTypeDistanceConstraint("avoids deer medium", "deer", 15.0);
   int avoidDeerShort=rmCreateTypeDistanceConstraint("avoids deer short", "deer", 5.0);
   int avoidBerry=rmCreateTypeDistanceConstraint("avoids berries", "berryBush", 80.0);
   int avoidBerryMid=rmCreateTypeDistanceConstraint("avoids berries medium", "berryBush", 20.0);
   int avoidBerryShort=rmCreateTypeDistanceConstraint("avoids  berries short", "berryBush", 5.0);
   int avoidGold=rmCreateTypeDistanceConstraint("avoids silver mines", "mine", 35.0);
   int avoidGoldMid=rmCreateTypeDistanceConstraint("avoids silver mines medium", "mine", 15.0);
   int avoidWolves=rmCreateTypeDistanceConstraint("avoids wolves", "wolf", 40.0);
   int avoidWolvesShort=rmCreateTypeDistanceConstraint("avoids wolves short", "wolf", 5.0);
   int avoidImportantItem=rmCreateClassDistanceConstraint("secrets etc avoid each other", importantItem, 12.0);
   int avoidImportantItemShort=rmCreateClassDistanceConstraint("secrets etc avoid each other short", importantItem, 4.0);
   int avoidNugget=rmCreateTypeDistanceConstraint("nugget avoid nugget", "AbstractNugget", 20.0);
   int avoidNatives=rmCreateClassDistanceConstraint("avoids natives", nativeClass, 20.0);
   int avoidNativesShort=rmCreateClassDistanceConstraint("avoids natives short", nativeClass, 4.0);
   int avoidRomanSocketsTC=rmCreateTypeDistanceConstraint("avoid Roman Socket from TC", "SocketRomans", 40);
   int avoidCelticSocketsTC=rmCreateTypeDistanceConstraint("avoid Celtic Socket from TC", "SocketCeltics", 40);
   int avoidSuebiSocketsTC=rmCreateTypeDistanceConstraint("avoid Suebi Socket from TC", "SocketSuebi", 85);
   int avoidChattiSocketsTC=rmCreateTypeDistanceConstraint("avoid Chatti Socket from TC", "SocketChatti", 85);
   
   
   rmSetStatusText("",0.50);
   // ************************************** Define Objects **************************************
   

   
   rmSetStatusText("",0.60);
   //************************************** Build Terrrain **************************************

//Rivers
   // rmRiverCreate(? Must be <0, Style, Ammount of "things" in the river, straigtness, width, regularity)
   
   //North - South river
   int river1 = rmRiverCreate(-1, rivertype, 5, 5, 5, 8); 
   rmRiverAddWaypoint(river1, 1.0, 1.0);
   rmRiverAddWaypoint(river1, 0.0, 0.0);
   rmRiverSetBankNoiseParams(river1, 0.07, 2, 15.0, 15.0, 0.667, 1.8);
   rmRiverSetShallowRadius(river1, size);
   rmRiverAddShallow(river1, 1);
   rmRiverAddShallow(river1, 0.1);
   rmRiverBuild(river1);
   
  if (rivercount == 2)
  {
   //West - East River
   int river3 = rmRiverCreate(-1, rivertype, 6, 3, 5, 5);
   rmRiverAddWaypoint(river3, 1.0, 0.0);
   rmRiverAddWaypoint(river3, 0.0, 1.0);
   rmRiverSetBankNoiseParams(river3, 0.07, 2, 15.0, 15.0, 0.667, 1.8);
   rmRiverSetShallowRadius(river3, size);
   rmRiverAddShallow(river3, 1);
   rmRiverAddShallow(river3, 0.1);
   rmRiverBuild(river3);
  }
 
  if (rivercount == 3 )
  {
   //NorthEast - NorthWest River
   int river2 = rmRiverCreate(-1, rivertype, 6, 3, 5, 5);
   rmRiverAddWaypoint(river2, 0.5, 1.0);
   rmRiverAddWaypoint(river2, .45, .9);
   rmRiverAddWaypoint(river2, .45, .8);
   rmRiverAddWaypoint(river2, .45, .7);
   rmRiverAddWaypoint(river2, .4, .6);
   rmRiverAddWaypoint(river2, .3, .55);
   rmRiverAddWaypoint(river2, .2, .55);
   rmRiverAddWaypoint(river2, .1, .55);
   rmRiverAddWaypoint(river2, 0.0, 0.5);
   rmRiverSetBankNoiseParams(river2, 0.07, 2, 15.0, 15.0, 0.667, 1.8);
   rmRiverSetShallowRadius(river2, size);
   rmRiverAddShallow(river2, 1);
   rmRiverAddShallow(river2, 0.1);
   rmRiverBuild(river2);
   
   //SouthEast - SouthWest River
   int river4 = rmRiverCreate(-1, rivertype, 5, 5, 5, 8);
   rmRiverAddWaypoint(river4, 1.0, 0.5);
   rmRiverAddWaypoint(river4, .9, .45);
   rmRiverAddWaypoint(river4, .8, .45);
   rmRiverAddWaypoint(river4, .7, .45);
   rmRiverAddWaypoint(river4, .6, .4);
   rmRiverAddWaypoint(river4, .55, .3);
   rmRiverAddWaypoint(river4, .55, .2);
   rmRiverAddWaypoint(river4, .55, .1);
   rmRiverAddWaypoint(river4, 0.5, 0.0);
   rmRiverSetBankNoiseParams(river4, 0.07, 2, 15.0, 15.0, 0.667, 1.8);
   rmRiverSetShallowRadius(river4, size);
   rmRiverAddShallow(river4, 1);
   rmRiverAddShallow(river4, 0.1);
   rmRiverBuild(river4);
  }
   
   
   
   rmSetStatusText("",0.70);
   // *************************************	Place Players ***************************************


   
 if (cNumberTeams == 2){
      if (rivercount == 1 || rivercount == 3){
	  rmSetPlacementTeam(0);
      rmSetPlacementSection(0.84, 0.91);
      rmPlacePlayersCircular(.40, .40, 0);
      rmSetPlacementTeam(1);
      rmSetPlacementSection(.34, .41);  
      rmPlacePlayersCircular(.40, .40, 0);
	  }
	  if (rivercount == 2){
	  rmSetPlacementTeam(0);
      rmSetPlacementSection(0.215, 0.285);
      rmPlacePlayersCircular(.40, .40, 0);
      rmSetPlacementTeam(1);
      rmSetPlacementSection(.715, .785);  
      rmPlacePlayersCircular(.40, .40, 0);
	  }
    }
    
 else {
    rmPlacePlayersCircular(0.400, 0.400, 0.0);
  }

   // Set up player areas.
   float playerFraction=rmAreaTilesToFraction(100);
   for(i=1; <cNumberPlayers)
   {
    int id=rmCreateArea("Player"+i);
    rmSetPlayerArea(i, id);
	rmAddAreaToClass(id, classPlayer);
    rmSetAreaSize(id, playerFraction, playerFraction);
	rmSetAreaCoherence(id, 1.0);
	rmSetAreaLocPlayer(id, i);
    rmSetAreaWarnFailure(id, false);
    rmBuildArea(id);
   }
   
	//Define Starting Units and Towncenter (or TCWagon)
	int startingUnits = rmCreateStartingUnitsObjectDef(5.0);
	rmSetObjectDefMinDistance(startingUnits, 7.0);
	rmSetObjectDefMaxDistance(startingUnits, 12.0);

	int startingTCID = rmCreateObjectDef("startingTC");
	if ( rmGetNomadStart())	{
	rmAddObjectDefItem(startingTCID, "CoveredWagon", 1, 0.0);}
	else{
	rmAddObjectDefItem(startingTCID, "TownCenter", 1, 0.0);	}
	rmSetObjectDefMinDistance(startingTCID, 0.0);
	rmSetObjectDefMaxDistance(startingTCID, 9.0);
	rmAddObjectDefConstraint(startingTCID, avoidWater);
	rmAddObjectDefToClass(startingTCID, classPlayer);
	
	//Define Starting Resources
	int playerSilverID = rmCreateObjectDef("player mine");
	rmAddObjectDefItem(playerSilverID, "minecopper", 1, 0);
	rmSetObjectDefMinDistance(playerSilverID, 12.0);
	rmSetObjectDefMaxDistance(playerSilverID, 16.0);
	rmAddObjectDefToClass(playerSilverID, classPlayer);
    rmAddObjectDefConstraint(playerSilverID ,StartingObjects);
	
	int playerFoodID=rmCreateObjectDef("player nilgai");
    rmAddObjectDefItem(playerFoodID, "ypNilgai", huntcount, 5.0);
    rmSetObjectDefCreateHerd(playerFoodID, true);
    rmSetObjectDefMinDistance(playerFoodID, 8);
    rmSetObjectDefMaxDistance(playerFoodID, 14);
	rmAddObjectDefToClass(playerFoodID, classPlayer);
    rmAddObjectDefConstraint(playerFoodID ,StartingObjects);

	int playerTreeID=rmCreateObjectDef("player trees");
    rmAddObjectDefItem(playerTreeID, "ypTreeDeccan", 7, 10);
    rmSetObjectDefMinDistance(playerTreeID, 8);
    rmSetObjectDefMaxDistance(playerTreeID, 12);
	rmAddObjectDefToClass(playerTreeID, classPlayer);
    rmAddObjectDefConstraint(playerTreeID ,StartingObjects);

    int playerNuggetID=rmCreateObjectDef("player nugget");
    rmAddObjectDefItem(playerNuggetID, "nugget", 1, 0.0);
    rmSetObjectDefMinDistance(playerNuggetID, 15);
    rmSetObjectDefMaxDistance(playerNuggetID, 20);
	rmAddObjectDefToClass(playerNuggetID, classPlayer);
    rmAddObjectDefConstraint(playerNuggetID ,StartingObjects);

    int playerBerryID=rmCreateObjectDef("player berries");
    rmAddObjectDefItem(playerBerryID, "berryBush", berrycount, 5.0);
    rmSetObjectDefMinDistance(playerBerryID, 10);
    rmSetObjectDefMaxDistance(playerBerryID, 15);
	rmAddObjectDefToClass(playerBerryID, classPlayer);
    rmAddObjectDefConstraint(playerBerryID ,StartingObjects);
	
	//Place starting resources, town center and units for each player
	for(i=1; <cNumberPlayers) {
	  rmPlaceObjectDefAtLoc(startingTCID, i, rmPlayerLocXFraction(i), rmPlayerLocZFraction(i));
	  rmPlaceObjectDefAtLoc(startingUnits, i, rmPlayerLocXFraction(i), rmPlayerLocZFraction(i));
	    vector TCLoc = rmGetUnitPosition(rmGetUnitPlacedOfPlayer(startingTCID, i));
	  rmPlaceObjectDefAtLoc(playerSilverID, 0, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
	  rmPlaceObjectDefAtLoc(playerFoodID, 0, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
      rmPlaceObjectDefAtLoc(playerTreeID, 0, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
      rmPlaceObjectDefAtLoc(playerBerryID, 0, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
        rmSetNuggetDifficulty(1, 1);
      rmPlaceObjectDefAtLoc(playerNuggetID, 0, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
	}
	
	
   rmSetStatusText("",0.80);
   // *************************************	Place Natives ***************************************

if (subCiv0 == rmGetCivID("RomanSet"))
{
    int nativeVillage1 = -1;
    nativeVillage1 = rmCreateGrouping("Roman settlement in S", "native roman settlement 1");
    rmSetGroupingMinDistance(nativeVillage1, 0.0);
    rmSetGroupingMaxDistance(nativeVillage1, 14.0);
    rmAddGroupingToClass(nativeVillage1, nativeClass);
    rmAddGroupingToClass(nativeVillage1, rmClassID("importantItem"));
    rmAddGroupingConstraint(nativeVillage1, avoidWaterShort);
    rmAddGroupingConstraint(nativeVillage1, avoidNativesShort);
    rmPlaceGroupingAtLoc(nativeVillage1, 0, 0.12, 0.31);	
    
}

if (subCiv1 == rmGetCivID("CelticSet"))	
{
    int nativeVillage2 = -1;
    nativeVillage2 = rmCreateGrouping("Celtic settlement in N", "native celtic settlement 1");
    rmSetGroupingMinDistance(nativeVillage2, 0.0);
    rmSetGroupingMaxDistance(nativeVillage2, 14.0);
    rmAddGroupingToClass(nativeVillage2, nativeClass);
    rmAddGroupingToClass(nativeVillage2, rmClassID("importantItem"));
    rmAddGroupingConstraint(nativeVillage2, avoidWaterShort);
    rmAddGroupingConstraint(nativeVillage2, avoidNativesShort);
    rmPlaceGroupingAtLoc(nativeVillage2, 0, 0.88, 0.70);	
  
}

if (subCiv2 == rmGetCivID("Chatti"))
{
    int nativeVillage3 = -1;
    nativeVillage3 = rmCreateGrouping("Chatti village 1", "native chatti village 1");
    rmSetGroupingMinDistance(nativeVillage3, 0.0);
    rmSetGroupingMaxDistance(nativeVillage3, 14.0);
    rmAddGroupingToClass(nativeVillage3, nativeClass);
    rmAddGroupingToClass(nativeVillage3, rmClassID("importantItem"));
    rmAddGroupingConstraint(nativeVillage3, avoidWaterShort);
    rmAddGroupingConstraint(nativeVillage3, avoidNativesShort);

    if ((rivercount == 1) || (rivercount == 3)) 
    {	
 	rmPlaceGroupingAtLoc(nativeVillage3, 0, 0.62, 0.82);	
    }
    else
    {
 	rmPlaceGroupingAtLoc(nativeVillage3, 0, 0.58, 0.89);	
    }
}
	
if (subCiv3 == rmGetCivID("Chatti"))
{
    int nativeVillage4 = -1;
    nativeVillage4 = rmCreateGrouping("Chatti village 2", "native chatti village 2");
    rmSetGroupingMinDistance(nativeVillage4, 0.0);
    rmSetGroupingMaxDistance(nativeVillage4, 14.0);
    rmAddGroupingToClass(nativeVillage4, nativeClass);
    rmAddGroupingToClass(nativeVillage4, rmClassID("importantItem"));
    rmAddGroupingConstraint(nativeVillage4, avoidWaterShort);
    rmAddGroupingConstraint(nativeVillage4, avoidNativesShort);
    rmPlaceGroupingAtLoc(nativeVillage4, 0, 0.67, 0.88);
    
}

if (subCiv4 == rmGetCivID("Suebi"))
{
    int nativeVillage5 = -1;
    nativeVillage5 = rmCreateGrouping("Suebi village 1", "native suebi village 1");
    rmSetGroupingMinDistance(nativeVillage5, 0.0);
    rmSetGroupingMaxDistance(nativeVillage5, 14.0);
    rmAddGroupingToClass(nativeVillage5, nativeClass);
    rmAddGroupingToClass(nativeVillage5, rmClassID("importantItem"));
    rmAddGroupingConstraint(nativeVillage5, avoidWaterShort);
    rmAddGroupingConstraint(nativeVillage5, avoidNativesShort);

    if ((rivercount == 1) || (rivercount == 3)) 
    {
	rmPlaceGroupingAtLoc(nativeVillage5, 0, 0.45, 0.28);
    }
    else
    {	
	rmPlaceGroupingAtLoc(nativeVillage5, 0, 0.34, 0.19);
    }
}

if (subCiv5 == rmGetCivID("Suebi"))
{
    int nativeVillage6 = -1;
    nativeVillage6 = rmCreateGrouping("Suebi village 2", "native suebi village 2");
    rmSetGroupingMinDistance(nativeVillage6, 0.0);
    rmSetGroupingMaxDistance(nativeVillage6, 14.0);
    rmAddGroupingToClass(nativeVillage6, nativeClass);
    rmAddGroupingToClass(nativeVillage6, rmClassID("importantItem"));
    rmAddGroupingConstraint(nativeVillage6, avoidWaterShort);
    rmAddGroupingConstraint(nativeVillage6, avoidNativesShort);
    rmPlaceGroupingAtLoc(nativeVillage6, 0, 0.40, 0.22);
    
}

   rmSetStatusText("",0.90);
   // *************************************	Place Objects ***************************************
   
   int TCID = rmCreateObjectDef("player TC");
   rmAddObjectDefConstraint(TCID, avoidRomanSocketsTC);
   rmAddObjectDefConstraint(TCID, avoidCelticSocketsTC);
   rmAddObjectDefConstraint(TCID, avoidSuebiSocketsTC);
   rmAddObjectDefConstraint(TCID, avoidChattiSocketsTC);

   //Guarded Gold
    int guardedGold= rmCreateObjectDef("guardedGold");
    rmAddObjectDefItem(guardedGold, "Nugget", 1, 0.0);
    rmSetNuggetDifficulty(66, 66);
    rmSetObjectDefMinDistance(guardedGold, 40.0);
    rmSetObjectDefMaxDistance(guardedGold, 100.0);
    rmAddObjectDefToClass(guardedGold, guardedGoldClass);
    rmAddObjectDefConstraint(guardedGold, StartingObjectsMid);
    rmAddObjectDefConstraint(guardedGold, avoidGuardedGold);
    rmAddObjectDefConstraint(guardedGold, avoidWaterShort);
    rmAddObjectDefConstraint(guardedGold, avoidImportantItem);
    for (i=0; <cNumberNonGaiaPlayers){
	rmPlaceObjectDefAtLoc(guardedGold, 0, 0.5, 0.5);	
    }

   //Unguarded Gold
    int Gold=rmCreateObjectDef("silvermines");
    rmAddObjectDefItem(Gold, "mine", 1, 0.0);
	rmSetObjectDefMinDistance(Gold, 0.0);
	rmSetObjectDefMaxDistance(Gold, size);	
	rmAddObjectDefConstraint(Gold, StartingObjectsMid);
	rmAddObjectDefConstraint(Gold, avoidGold);
	rmAddObjectDefConstraint(Gold, avoidGuardedGold);
	rmAddObjectDefConstraint(Gold, avoidWaterShort);
        rmAddObjectDefConstraint(Gold, avoidImportantItem);
	rmPlaceObjectDefAtLoc(Gold, 0, 0.5, 0.5, lowgoldcount*cNumberNonGaiaPlayers);

   //deers
   	int Deer=rmCreateObjectDef("deer");
    rmAddObjectDefItem(Deer, "deer", huntcount, 5.0);
    rmSetObjectDefCreateHerd(Deer, true);
	rmSetObjectDefMinDistance(Deer, 0.0);
	rmSetObjectDefMaxDistance(Deer, size);	
	rmAddObjectDefConstraint(Deer, StartingObjectsMid);
	rmAddObjectDefConstraint(Deer, avoidGuardedGoldShort);
	rmAddObjectDefConstraint(Deer, avoidDeer);
	rmAddObjectDefConstraint(Deer, avoidNatives);
        rmAddObjectDefConstraint(Deer, avoidImportantItem);
	rmPlaceObjectDefAtLoc(Deer, 0, 0.5, 0.5, huntcount*cNumberNonGaiaPlayers);   
	
	
   //Berries
    int Berries=rmCreateObjectDef("berrybush");
    rmAddObjectDefItem(Berries, "berrybush", berrycount, 5.0);
	rmSetObjectDefMinDistance(Berries, 0.0);
	rmSetObjectDefMaxDistance(Berries, size);	
	rmAddObjectDefConstraint(Berries, StartingObjectsMid);
	rmAddObjectDefConstraint(Berries, avoidGuardedGoldShort);
	rmAddObjectDefConstraint(Berries, avoidDeerMid);
	rmAddObjectDefConstraint(Berries, avoidBerry);
  	rmAddObjectDefConstraint(Berries, avoidWaterShort);
	rmAddObjectDefConstraint(Berries, avoidNatives);
        rmAddObjectDefConstraint(Berries, avoidImportantItemShort);
	rmPlaceObjectDefAtLoc(Berries, 0, 0.5, 0.5, berrycount*cNumberNonGaiaPlayers);      
   
   //Nuggets
	int nuggetEasy= rmCreateObjectDef("nugget easy"); 
	rmAddObjectDefItem(nuggetEasy, "Nugget", 1, 0.0);
	rmSetNuggetDifficulty(1, 1);
	rmAddObjectDefConstraint(nuggetEasy, avoidImportantItemShort);
	rmAddObjectDefConstraint(nuggetEasy, avoidNugget);
	rmAddObjectDefConstraint(nuggetEasy, avoidAll);
	rmSetObjectDefMinDistance(nuggetEasy, 40.0);
	rmSetObjectDefMaxDistance(nuggetEasy, 60.0);
	rmPlaceObjectDefAtLoc(nuggetEasy, 0, 0.4, 0.4, rmRandInt(2,3));
        rmPlaceObjectDefAtLoc(nuggetEasy, 0, 0.4, 0.6, rmRandInt(2,3));
	rmPlaceObjectDefAtLoc(nuggetEasy, 0, 0.6, 0.4, rmRandInt(2,3));
        rmPlaceObjectDefAtLoc(nuggetEasy, 0, 0.6, 0.6, rmRandInt(2,3));
   
   //Wolves
    int Wolves=rmCreateObjectDef("wolves");
    rmAddObjectDefItem(Wolves, "wolf", 1, 0.0);
	rmSetObjectDefMinDistance(Wolves, 50.0);
	rmSetObjectDefMaxDistance(Wolves, size);	
	rmAddObjectDefConstraint(Wolves, StartingObjectsMid);
	rmAddObjectDefConstraint(Wolves, avoidDeerMid);
	rmAddObjectDefConstraint(Wolves, avoidBerryMid);
	rmAddObjectDefConstraint(Wolves, avoidGoldMid);
	rmAddObjectDefConstraint(Wolves, avoidGuardedGold);
	rmAddObjectDefConstraint(Wolves, avoidWaterShort);
	rmAddObjectDefConstraint(Wolves, avoidWolves);
	rmAddObjectDefConstraint(Wolves, avoidNatives);
        rmAddObjectDefConstraint(Wolves, avoidImportantItem);
	rmPlaceObjectDefAtLoc(Wolves, 0, 0.5, 0.5, 2*cNumberNonGaiaPlayers);   
   
   
   //Forest - Last
    int numTries = 16*cNumberNonGaiaPlayers;
   
    for (i=0; <numTries) 
    {   
       int forest=rmCreateArea("forest"+i);
       rmSetAreaWarnFailure(forest, false);
       rmSetAreaSize(forest, 0.03, 0.03);
       rmSetAreaForestType(forest, "Deccan Forest");
       rmSetAreaForestDensity(forest, 1.0);
       rmSetAreaForestClumpiness(forest, 1.0);
       rmSetAreaForestUnderbrush(forest, 0.0);
       rmSetAreaCoherence(forest, 0.8);
       rmAddAreaConstraint(forest, StartingObjectsTree);
       rmAddAreaConstraint(forest, avoidDeerShort);
       rmAddAreaConstraint(forest, avoidBerryShort);
       rmAddAreaConstraint(forest, avoidAll);
       rmAddAreaConstraint(forest, avoidGuardedGoldShort);
       rmAddAreaConstraint(forest, avoidWolvesShort);
       rmAddAreaConstraint(forest, avoidNativesShort);
       rmAddAreaConstraint(forest, avoidImportantItemShort);
       if(rmBuildArea(forest)==false)
       {
           // Stop trying once we fail 3 times in a row.
           failCount++;
           if(failCount==3)
           {
              break;
           }
       }
       else
       {
           failCount=0; 
       }
    }
 
   // *************************************** Triggers ******************************************
   //None for this map
   
   rmSetStatusText("",0.99);
   }