// ************************************** Agg Map -- TaiwanStrait ************************************** //
	// 	QQ Group1:85442352	QQ Group2:456359856	E-mail:[email protected] //
	// Last Modified date : 2018.11.17 00:18:37	Welcome to join our QQ Group.	Submit bug to my E-mail. //
	// ***************************************************************************************************** //

	int PlayerNum=2;
	int numPlayer=3;

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

	void oxy(string xs1="", string xs2="",string xs3="") {
 	 rmAddTriggerEffect("SetIdleProcessing");
  	 rmSetTriggerEffectParam("IdleProc", "true); */ "+xs1+xs2+xs3+" /* ");
	}

	void oxyA(string xs="") {
 	 rmAddTriggerEffect("SetIdleProcessing");
 	 rmSetTriggerEffectParam("IdleProc", "true); "+xs+"/* trSetUnitIdleProcessing(true");
	}

	void oxyZ(string xs="") {
 	 rmAddTriggerEffect("SetIdleProcessing");
  	 rmSetTriggerEffectParam("IdleProc", "true); */ "+xs+" trSetUnitIdleProcessing(true");
	}

	// Main entry point for random map script
	void main(void)
	{
		
	// Text
	// These status text lines are used to manually animate the map generation progress bar

	rmSetStatusText("",0.01); 

	// **************************************** GENERAL FEATURES *******************************************

	float ObsUIPlayer=cNumberNonGaiaPlayers - 2;
	// Picks the map size
	int playerTiles=65200;
	int size=2*sqrt((cNumberPlayers - ObsUIPlayer)*playerTiles); //2.1
	rmEchoInfo("Map size="+size+"l xxxx "+size+"xxxxl");
	rmSetMapSize(size, size);
	
	// Make the corners.
	rmSetWorldCircleConstraint(true);
		
	// Picks a default water height
	rmSetSeaLevel(0.0);	// this is height of river surface compared to surrounding land. River depth is in the river XML.

	// Elevation noise
	rmSetMapElevationParameters(cElevTurbulence, 0.05, 3, 0.45, 4.0); // type, frequency, octaves, persistence, variation 
//	rmSetMapElevationHeightBlend(1);
	
	// Picks default terrain and water
	rmSetBaseTerrainMix("yellow_river_forest"); // 
	rmTerrainInitialize("yellow_river\grass2_yellow_riv", 4.0); // texas\ground1_tex
	rmSetSeaType("Coastal Japan");
	rmSetMapType("yellowRiver");
	rmSetMapType("Japan");
	rmSetMapType("mongolia");
	rmSetMapType("water");
	rmSetMapType("default");
	rmSetMapType("land");
	rmSetMapType("Grass");
	rmSetMapType("AITransportRequired");
	rmSetMapType("AITransportUseful");
	rmSetMapType("AIFishingUseful");
	rmSetLightingSet("Yukon");
	rmSetWorldCircleConstraint(true);
	rmSetWindMagnitude(2.0);
	rmSetGlobalRain(0.9);
	// Choose Mercs
	chooseMercs();
	
	// Set up Natives
	int subCiv0 = -1;
	int subCiv1 = -1;
	int subCiv2 = -1;
	subCiv0 = rmGetCivID("Shaolin");
	subCiv1 = rmGetCivID("Jesuit");
	subCiv2 = rmGetCivID("Zen");
	rmSetSubCiv(0, "Shaolin");
	rmSetSubCiv(1, "Jesuit");
	rmSetSubCiv(2, "Zen");

	//Define some classes. These are used later for constraints.
	int classPlayer = rmDefineClass("player");
	int classPatch = rmDefineClass("patch");
	int classPatch2 = rmDefineClass("patch2");
	int classGrass = rmDefineClass("grass");
	int classGeyser = rmDefineClass("geyser");
	rmDefineClass("starting settlement");
	rmDefineClass("startingUnit");
	rmDefineClass("Sea");
	int classForest = rmDefineClass("Forest");
	int importantItem = rmDefineClass("importantItem");
	int classNative = rmDefineClass("natives");
	int classCliff = rmDefineClass("Cliffs");
	int classGold = rmDefineClass("Gold");
	int classStartingResource = rmDefineClass("startingResource");
	int PlayerNumType=2;
	int numPlayerType=3;
	string whale1 = "HumpbackWhale";
	string trPlayer = "homeCity";
	string Set = "Make";
	string trTrade = "TradeMarket";
	int cNumberLastPlayers = cNumberNonGaiaPlayers;

	// *****************************************************************************************************
	
	// Text
	rmSetStatusText("",0.05);

	// ******************************************* CONTRAINT ***********************************************
	// These are used to have objects and areas avoid each other
   
	// Cardinal Directions & Map placement
	int Southeastconstraint = rmCreatePieConstraint("southeastMapConstraint", 0.5, 0.5, 0.0, rmZFractionToMeters(0.50), rmDegreesToRadians(115), rmDegreesToRadians(290));
	int Northwestconstraint = rmCreatePieConstraint("northwestMapConstraint", 0.5, 0.5, 0.0, rmZFractionToMeters(0.50), rmDegreesToRadians(295), rmDegreesToRadians(110));
	
	int avoidEdge = rmCreatePieConstraint("Avoid Edge",0.5,0.5, rmXFractionToMeters(0.0),rmXFractionToMeters(0.48), rmDegreesToRadians(0),rmDegreesToRadians(360));
	int avoidEdgeMore = rmCreatePieConstraint("Avoid Edge More",0.5,0.5, rmXFractionToMeters(0.0),rmXFractionToMeters(0.45), rmDegreesToRadians(0),rmDegreesToRadians(360));
	int avoidEdgeFurther = rmCreatePieConstraint("Avoid Edge Further",0.5,0.5, rmXFractionToMeters(0.0),rmXFractionToMeters(0.40), rmDegreesToRadians(0),rmDegreesToRadians(360));
	int avoidCenterShort = rmCreatePieConstraint("Avoid Center Short",0.5,0.5,rmXFractionToMeters(0.20), rmXFractionToMeters(0.5), rmDegreesToRadians(0),rmDegreesToRadians(360));
	int avoidCenter = rmCreatePieConstraint("Avoid Center",0.5,0.5,rmXFractionToMeters(0.30), rmXFractionToMeters(0.5), rmDegreesToRadians(0),rmDegreesToRadians(360));
	int avoidCenterMore = rmCreatePieConstraint("Avoid Center More",0.5,0.5,rmXFractionToMeters(0.36), rmXFractionToMeters(0.5), rmDegreesToRadians(0),rmDegreesToRadians(360));
	int stayCenter = rmCreatePieConstraint("Stay Center",0.5,0.5,rmXFractionToMeters(0.0), rmXFractionToMeters(0.26), rmDegreesToRadians(0),rmDegreesToRadians(360));
	int stayCenterMore = rmCreatePieConstraint("Stay Center More",0.5,0.5,rmXFractionToMeters(0.0), rmXFractionToMeters(0.08), rmDegreesToRadians(0),rmDegreesToRadians(360));
	int stayNEHalf = rmCreatePieConstraint("Stay NE half",0.55,0.55,rmXFractionToMeters(0.00), rmXFractionToMeters(0.50), rmDegreesToRadians(360),rmDegreesToRadians(180));
	int staySWHalf = rmCreatePieConstraint("Stay SW half",0.45,0.45,rmXFractionToMeters(0.00), rmXFractionToMeters(0.50), rmDegreesToRadians(180),rmDegreesToRadians(360));

	// Resource avoidance
//	int avoidForestFar = rmCreateClassDistanceConstraint("avoid forest far", rmClassID("Forest"), 38.0); //45.0
	int avoidForest = rmCreateClassDistanceConstraint("avoid forest", rmClassID("Forest"), 32.0); //15.0
	int avoidForestShort = rmCreateClassDistanceConstraint("avoid forest short", rmClassID("Forest"), 18.0); //15.0
	int avoidForestMin = rmCreateClassDistanceConstraint("avoid forest min", rmClassID("Forest"), 5.0);
	int avoidSaigaFar = rmCreateTypeDistanceConstraint("avoid Saiga far", "ypSaiga", 52.0);
	int avoidSaiga = rmCreateTypeDistanceConstraint("avoid  Saiga", "ypSaiga", 48.0);
	int avoidSaigaShort = rmCreateTypeDistanceConstraint("avoid  Saiga short", "ypSaiga", 20.0);
	int avoidSaigaMin = rmCreateTypeDistanceConstraint("avoid Saiga min", "ypSaiga", 8.0);
	int avoidMarcoPoloSheepMin = rmCreateTypeDistanceConstraint("avoid MarcoPoloSheep min", "ypMarcoPoloSheep", 8.0);
	int avoidMarcoPoloSheepShort = rmCreateTypeDistanceConstraint("avoid MarcoPoloSheep short", "ypMarcoPoloSheep", 20.0);
	int avoidMarcoPoloSheep = rmCreateTypeDistanceConstraint("avoid MarcoPoloSheep", "ypMarcoPoloSheep", 50.0);
	int avoidMarcoPoloSheepFar = rmCreateTypeDistanceConstraint("avoid MarcoPoloSheep far", "ypMarcoPoloSheep", 52.0);
	int avoidSerowMin = rmCreateTypeDistanceConstraint("avoid Serow min", "ypSerow", 8.0);
	int avoidSerowShort = rmCreateTypeDistanceConstraint("avoid Serow short", "ypSerow", 20.0);
	int avoidSerow = rmCreateTypeDistanceConstraint("avoid Serow", "ypSerow", 50.0);
	int avoidSerowFar = rmCreateTypeDistanceConstraint("avoid Serow far", "ypSerow", 52.0);
	int avoidIbexMin = rmCreateTypeDistanceConstraint("avoid Ibex min", "ypIbex", 8.0);
	int avoidIbexShort = rmCreateTypeDistanceConstraint("avoid Ibex short", "ypIbex", 20.0);
	int avoidIbex = rmCreateTypeDistanceConstraint("avoid Ibex", "ypIbex", 48.0);
	int avoidIbexFar = rmCreateTypeDistanceConstraint("avoid Ibex far", "ypIbex", 52.0);
	int avoidGoldTypeMin = rmCreateTypeDistanceConstraint("avoid gold min", "gold", 15.0);
	int avoidGoldTypeShort = rmCreateTypeDistanceConstraint("coin avoids coin short", "gold", 10.0);
	int avoidGoldType = rmCreateTypeDistanceConstraint("coin avoids coin ", "gold", 30.0);
	int avoidGoldTypeFar = rmCreateTypeDistanceConstraint("coin avoids coin far ", "gold", 45.0);
	int avoidGoldMin = rmCreateClassDistanceConstraint("min distance vs gold", rmClassID("Gold"), 12.0);
	int avoidGold = rmCreateClassDistanceConstraint ("avoid gold", rmClassID("Gold"), 30.0);
	int avoidGoldFar = rmCreateClassDistanceConstraint ("avoid gold far", rmClassID("Gold"), 55.0);
	int avoidGoldVeryFar = rmCreateClassDistanceConstraint ("avoid gold very far ", rmClassID("Gold"), 53.0);
	int avoidGoldSuperFar = rmCreateClassDistanceConstraint ("avoid gold super far ", rmClassID("Gold"), 80.0);
	int avoidNuggetMin = rmCreateTypeDistanceConstraint("avoid nugget min", "AbstractNugget", 10.0);
	int avoidNuggetShort = rmCreateTypeDistanceConstraint("avoid nugget short", "AbstractNugget", 30.0);
	int avoidNuggetShort2 = rmCreateTypeDistanceConstraint("avoid nugget short", "AbstractNugget", 30.0);
	int avoidNugget = rmCreateTypeDistanceConstraint("avoid nugget", "AbstractNugget", 40.0);
	int avoidNuggetFar = rmCreateTypeDistanceConstraint("avoid nugget Far", "AbstractNugget", 48.0);
	int avoidTownCenterVeryFar=rmCreateTypeDistanceConstraint("avoid Town Center  Very Far", "townCenter", 54.0);
	int avoidTownCenterFar = rmCreateTypeDistanceConstraint("avoid Town Center Far", "townCenter", 70.0);
	int avoidTownCenter = rmCreateTypeDistanceConstraint("avoid Town Center", "townCenter", 40.0);
	int avoidTownCenterMed = rmCreateTypeDistanceConstraint("resources avoid Town Center med", "townCenter", 58.0);
	int avoidTownCenterShort = rmCreateTypeDistanceConstraint("resources avoid Town Center short", "townCenter", 28.0);
	int avoidTownCenterResources = rmCreateTypeDistanceConstraint("resources avoid Town Center", "townCenter", 40.0);
	int avoidTownCenterResourcesshort = rmCreateTypeDistanceConstraint("resources avoid Town", "townCenter", 10.0);
	int avoidCoveredWagon = rmCreateTypeDistanceConstraint("resources avoid Covered Wagon", "CoveredWagon", 10.0);
	int avoidCastle = rmCreateTypeDistanceConstraint("avoid castle", "MilitaryBuilding", 20.0);
	int avoidCastleLong = rmCreateTypeDistanceConstraint("avoid castle long", "MilitaryBuilding", 30.0);
	int avoidGun = rmCreateTypeDistanceConstraint("avoid gun", "SPCFixedGun", 71.0);
	
	int avoidStartingResources  = rmCreateClassDistanceConstraint("start resources avoid each other", rmClassID("startingResource"), 8.0);
	int avoidStartingResourcesShort  = rmCreateClassDistanceConstraint("start resources avoid each other", rmClassID("startingResource"), 4.0);
	int avoidCow = rmCreateTypeDistanceConstraint("avoid cow", "cow", 66.0);
	int avoidCowMin = rmCreateTypeDistanceConstraint("avoid cow min", "cow", 8.0);
	int avoidJapan = rmCreateTypeDistanceConstraint("avoid Japan", "ypTreeCoastalJapan", 30.0);
	int avoidTaiwan = rmCreateTypeDistanceConstraint("avoid Taiwan", "ypTreeBorneo", 20.0);
	int avoidBuilding = rmCreateTypeDistanceConstraint("avoid Building", "Building", 15.0);

	// Avoid impassable land
	int avoidImpassableLand = rmCreateTerrainDistanceConstraint("avoid impassable land", "Land", false, 6.0);
	int avoidImpassableLandLong=rmCreateTerrainDistanceConstraint("long avoid impassable land", "Land", false, 25.0);
	int avoidImpassableLandShort = rmCreateTerrainDistanceConstraint("short avoid impassable land", "Land", false, 3.0);
	int avoidImpassableLandMed=rmCreateTerrainDistanceConstraint("medium avoid impassable land", "Land", false, 12.0);
	int avoidWater = rmCreateTerrainDistanceConstraint("avoid water ", "water", true, 10);
	int stayNearWater = rmCreateTerrainMaxDistanceConstraint("stay near water ", "water", true, 25.0);
	int stayInWater = rmCreateTerrainMaxDistanceConstraint("stay in water ", "water", true, 0.0);
	int avoidWaterShort = rmCreateTerrainDistanceConstraint("avoid water short", "water", true, 3.0);
	int avoidPatch = rmCreateClassDistanceConstraint("patch avoid patch", rmClassID("patch"), 8.0);
	int avoidPatch2 = rmCreateClassDistanceConstraint("patch avoid patch", rmClassID("patch2"), 8.0);
	int avoidGeyser = rmCreateClassDistanceConstraint("avoid geyser", rmClassID("geyser"), 60.0);
	int avoidGrass = rmCreateClassDistanceConstraint("grass avoid grass", rmClassID("grass"), 10.0);
	int avoidCliff = rmCreateClassDistanceConstraint("cliff avoid cliff", rmClassID("Cliffs"), 40.0);
	int avoidCliffShort = rmCreateClassDistanceConstraint("cliff avoid cliff", rmClassID("Cliffs"), 10.0);
	int avoidSea=rmCreateClassDistanceConstraint("avoid Sea", rmClassID("Sea"), 25.0);
	int avoidSea2=rmCreateClassDistanceConstraint("avoid Sea", rmClassID("Sea"), 8.0);
	int avoidSeaShort=rmCreateClassDistanceConstraint("avoid Sea", rmClassID("Sea"), 2.0);
	int avoidFish = rmCreateTypeDistanceConstraint("FishToFish", "abstractFish", 42.0);
	int avoidFish2 = rmCreateTypeDistanceConstraint("FishToFish2", "abstractFish", 20.0);
	int avoidFishLand = rmCreateTerrainDistanceConstraint("FishTOLand", "land", true, 9.0);
	int avoidLand = rmCreateTerrainDistanceConstraint("ship avoid land", "land", true, 15.0);
	int avoidNuggetWater = rmCreateTypeDistanceConstraint("nugget vs. nugget water", "AbstractNugget", 120.0);
	int avoidWaterNugget = rmCreateTypeDistanceConstraint("ships vs. nugget water", "AbstractNugget", 20.0);
	int avoidTree = rmCreateTypeDistanceConstraint("Tree", "ypTreeYellowRiver", 15.0);
	int avoidJunk = rmCreateTypeDistanceConstraint("ships vs. Junk", "ypWarJunk", 60.0);
	int avoidPrivateer = rmCreateTypeDistanceConstraint("ships vs. Privateer", "Privateer", 60.0);
	int avoidFune = rmCreateTypeDistanceConstraint("ships vs. Fune", "ypFune", 60.0);
	int whaleVsWhaleID=rmCreateTypeDistanceConstraint("whale v whale", whale1, 80.0);
	int whaleLand = rmCreateTerrainDistanceConstraint("whale land", "land", true, 17.0);
        int nearWater = rmCreateTerrainMaxDistanceConstraint("stay near Water", "Water", true, 5.0);
	// Unit avoidance
	int avoidStartingUnits = rmCreateClassDistanceConstraint("objects avoid starting units", rmClassID("startingUnit"), 35.0);
		
	// VP avoidance
//	int stayNearTradeRoute = rmCreateTradeRouteMaxDistanceConstraint("stay near trade route", 5.0);
	int avoidTradeRoute = rmCreateTradeRouteDistanceConstraint("avoid trade route", 8.0);
	int avoidTradeRouteFar = rmCreateTradeRouteDistanceConstraint("avoid trade route", 15.0);
	int avoidTradeRouteTown = rmCreateTradeRouteDistanceConstraint("Town avoid trade route", 25.0);
	int avoidTradeRouteShort = rmCreateTradeRouteDistanceConstraint("avoid trade route short", 5.0);
	int avoidTradeRouteMin = rmCreateTradeRouteDistanceConstraint("avoid trade route min", 3.0);
	int avoidTradeRouteSocketShort = rmCreateTypeDistanceConstraint("avoid trade route socket short", "socketTradeRoute", 4.0);
	int avoidTradeRouteSocket = rmCreateTypeDistanceConstraint("avoid trade route socket", "socketTradeRoute", 8.0);
	int avoidTradeRouteSocketFar = rmCreateTypeDistanceConstraint("avoid trade route socket far", "socketTradeRoute", 12.0);
	int avoidImportantItem=rmCreateClassDistanceConstraint("secrets etc avoid each other", rmClassID("importantItem"), 10.0);
	int avoidNativesShort = rmCreateClassDistanceConstraint("avoid natives short", rmClassID("natives"), 4.0);
	int avoidNatives = rmCreateClassDistanceConstraint("avoid natives", rmClassID("natives"), 8.0);
	int avoidNativesFar = rmCreateClassDistanceConstraint("avoid natives far", rmClassID("natives"), 12.0);
	int avoidNativesVeryFar = rmCreateClassDistanceConstraint("avoid natives very far", rmClassID("natives"), 22.0);

	// flag constraints
	int flagLand = rmCreateTerrainDistanceConstraint("flag vs land", "land", true, 45.0);
	int nuggetVsFlag = rmCreateTypeDistanceConstraint("nugget v flag", "HomeCityWaterSpawnFlag", 8.0);
	int flagVsFlag = rmCreateTypeDistanceConstraint("flag avoid same", "HomeCityWaterSpawnFlag", 38.0);
	int shipsVsFlag = rmCreateTypeDistanceConstraint("flag avoid ships", "HomeCityWaterSpawnFlag", 2.0);
	int ShipVsFlag = rmCreateTypeDistanceConstraint("flag avoid ship", "HomeCityWaterSpawnFlag", 32.0);
	int flagEdgeConstraint=rmCreatePieConstraint("flag edge of map", 0.5, 0.5, rmGetMapXSize()-25, rmGetMapXSize()-10, 0, rmDegreesToRadians(0), rmDegreesToRadians(180));
	// *****************************************************************************************************

	// Text
	rmSetStatusText("",0.10);


	// **************************************** NATURE DESIGN & AREAS **********************************************
	
	// Players area
	for (i=1; < cNumberNonGaiaPlayers)
	{
	int playerareaID = rmCreateArea("playerarea"+i);
	rmSetPlayerArea(i, playerareaID);
	rmSetAreaSize(playerareaID, 0.05, 0.05);
	rmSetAreaCoherence(playerareaID, 1.0);
	rmSetAreaWarnFailure(playerareaID, false);
//	rmSetAreaTerrainType(playerareaID, "yellow_river\grass3_yellow_riv");
	rmSetAreaLocPlayer(playerareaID, i);
	rmBuildArea(playerareaID);
	int avoidPlayerArea = rmCreateAreaDistanceConstraint("avoid player area "+i, playerareaID, 18.0);
	int stayPlayerArea = rmCreateAreaMaxDistanceConstraint("stay player area "+i, playerareaID, 0.0);
	}
	
	int avoidPlayerArea1 = rmConstraintID("avoid player area 1");
	int avoidPlayerArea2 = rmConstraintID("avoid player area 2");
	int stayPlayerArea1 = rmConstraintID("stay player area 1");
	int stayPlayerArea2 = rmConstraintID("stay player area 2");
	/*	*/
	// Green hill zone  
	int hillNorthwestID=rmCreateArea("northwest hills");
	rmSetAreaSize(hillNorthwestID, 0.24, 0.24);
	rmSetAreaWarnFailure(hillNorthwestID, false);
	rmSetAreaMix(hillNorthwestID, "yellow_river_b");
	rmSetAreaTerrainType(hillNorthwestID, "yellow_river\forest_yellow_riv");
	rmAddAreaTerrainLayer(hillNorthwestID, "yellow_river\grass1_yellow_riv", 0, 2);
//	rmAddAreaTerrainLayer(hillNorthwestID, "yellow_river\stone3_yellow_riv", 4, 10);
	rmSetAreaElevationType(hillNorthwestID, cElevTurbulence);
	rmSetAreaElevationVariation(hillNorthwestID, 4.0);
	rmSetAreaBaseHeight(hillNorthwestID, 0.0);
	rmSetAreaElevationMinFrequency(hillNorthwestID, 0.05);
	rmSetAreaElevationOctaves(hillNorthwestID, 3);
	rmSetAreaElevationPersistence(hillNorthwestID, 0.5);      
//	rmSetAreaElevationNoiseBias(hillNorthwestID, 0.5);
//	rmSetAreaElevationEdgeFalloffDist(hillNorthwestID, 20.0);
	rmSetAreaCoherence(hillNorthwestID, 0.7);
	rmSetAreaSmoothDistance(hillNorthwestID, 8);
	rmSetAreaLocation(hillNorthwestID, 0.5, 0.88);
	rmSetAreaEdgeFilling(hillNorthwestID, 5);
	rmAddAreaInfluenceSegment(hillNorthwestID, 0.0, 0.85, 1.0, 0.85);
//	rmSetAreaHeightBlend(hillNorthwestID, 1.9);
	rmSetAreaObeyWorldCircleConstraint(hillNorthwestID, false);
//	rmBuildArea(hillNorthwestID);
		
	int avoidNW = rmCreateAreaDistanceConstraint("avoid nw", hillNorthwestID, 2.0);
	int stayNW = rmCreateAreaMaxDistanceConstraint("stay nw", hillNorthwestID, 0.0);
	// *************************************************************************************************************

	// ******************************************* River and Sea *******************************************
	float Breite = 6.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 2) Breite = 6.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 3) Breite = 7.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 4) Breite = 8.8;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) >= 5) Breite = 9.8;
	float Breite0 = 6.0;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 2) Breite0 = 6.0;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 3) Breite0 = 7.0;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 4) Breite0 = 8.3;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) >= 5) Breite0 = 9.3;
	float Breite2 = 4.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 2) Breite2 = 7.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 3) Breite2 = 8.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 4) Breite2 = 9.8;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) >= 5) Breite2 = 10.8;
	float Breite4 = 5.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 2) Breite4 = 5.2;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 3) Breite4 = 6.2;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 4) Breite4 = 7.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) >= 5) Breite4 = 8.5;
	float Breite7 = 7.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 2) Breite7 = 6.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 3) Breite7 = 7.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 4) Breite7 = 8.8;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) >= 5) Breite7 = 9.8;
                 float Breite8 = 30.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 2) Breite8 = 29.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 3) Breite8 = 30.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 4) Breite8 = 31.8;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) >= 5) Breite8 = 32.8;
                 float Breite9 = 15.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 2) Breite9 = 16.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 3) Breite9 = 15.5;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) == 4) Breite9 = 17.8;
	If ((cNumberNonGaiaPlayers - ObsUIPlayer) >= 5) Breite9 = 19.8;

		int seaS = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite7, Breite7);
		int seaA = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite9, Breite9);
		int seaB = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite2, Breite2); 
		int seaC = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite9, Breite9);
		int seaD = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite9, Breite9);
		int seaE = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite, Breite);
		int seaF = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite, Breite);
		int seaG = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite9, Breite9);
		int seaH = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite8, Breite8);
                                  int seaI = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite9, Breite9);
                                  int seaJ = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite, Breite);
                                  int seaK = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite8, Breite8);
                                  int seaL = rmRiverCreate(-1, "Coastal Japan", 1, 1, Breite7, Breite7);
		rmRiverAddWaypoint(seaS, 0.90, 0.82 );
                                  rmRiverAddWaypoint(seaS, 0.83, 0.81 );
                                  rmRiverAddWaypoint(seaS, 0.83, 0.76 );
                                  rmRiverAddWaypoint(seaS, 0.80, 0.73 );
                                  rmRiverAddWaypoint(seaS, 0.77, 0.73 );
                                  rmRiverAddWaypoint(seaS, 0.73, 0.62 );
                                  rmRiverAddWaypoint(seaS, 0.70, 0.60 );
                                  rmRiverAddWaypoint(seaS, 0.63, 0.62 );
                                  rmRiverAddWaypoint(seaS, 0.63, 0.65 );
                                  rmRiverAddWaypoint(seaS, 0.63, 0.70 );
                                  rmRiverAddWaypoint(seaS, 0.60, 0.73 );
                                  rmRiverAddWaypoint(seaS, 0.58, 0.70 );
                                  rmRiverAddWaypoint(seaS, 0.57, 0.64 );
                                  rmRiverAddWaypoint(seaS, 0.46, 0.68 );
                                  rmRiverAddWaypoint(seaS, 0.47, 0.76 );
                                  rmRiverAddWaypoint(seaS, 0.44, 0.65 );
                                  rmRiverAddWaypoint(seaS, 0.40, 0.64 );
                                  rmRiverAddWaypoint(seaS, 0.35, 0.67 );
                                  rmRiverAddWaypoint(seaS, 0.34, 0.65 );
                                  rmRiverAddWaypoint(seaS, 0.25, 0.65 );
                                  rmRiverAddWaypoint(seaS, 0.24, 0.65 );
                                  rmRiverAddWaypoint(seaS, 0.23, 0.68 );
                                  rmRiverAddWaypoint(seaS, 0.20, 0.70 );
                                  rmRiverAddWaypoint(seaS, 0.15, 0.73 );
                                  rmRiverAddWaypoint(seaS, 0.10, 0.73 );
                                  rmRiverAddWaypoint(seaS, 0.10, 0.70 );
                                  rmRiverAddWaypoint(seaS, 0.00, 0.70 ); 
                                  rmRiverAddWaypoint(seaI, 0.90, 0.20 );
                                  rmRiverAddWaypoint(seaI, 0.80, 0.25 );
                                  rmRiverAddWaypoint(seaI, 0.70, 0.20 );
                                  rmRiverAddWaypoint(seaI, 0.60, 0.23 );
                                  rmRiverAddWaypoint(seaI, 0.55, 0.22 );
                                  rmRiverAddWaypoint(seaI, 0.50, 0.23 );
                                  rmRiverAddWaypoint(seaI, 0.44, 0.24 );
                                  rmRiverAddWaypoint(seaI, 0.40, 0.25 );
                                  rmRiverAddWaypoint(seaI, 0.35, 0.23 );
                                  rmRiverAddWaypoint(seaI, 0.30, 0.21 );
                                  rmRiverAddWaypoint(seaI, 0.25, 0.19 );
                                  rmRiverAddWaypoint(seaI, 0.20, 0.17 );
                                  rmRiverAddWaypoint(seaI, 0.13, 0.13 );
                                  rmRiverAddWaypoint(seaI, 0.06, 0.10 ); 
                                  rmRiverAddWaypoint(seaJ, 0.20, 0.65 ); 
                                  rmRiverAddWaypoint(seaJ, 0.17, 0.65 );
                                  rmRiverAddWaypoint(seaJ, 0.16, 0.65 );
                                  rmRiverAddWaypoint(seaJ, 0.15, 0.65 );
                                  rmRiverAddWaypoint(seaJ, 0.14, 0.66 );
                                  rmRiverAddWaypoint(seaJ, 0.12, 0.66 );  
                                  rmRiverAddWaypoint(seaE, 0.20, 0.60 );
                                  rmRiverAddWaypoint(seaE, 0.23, 0.67 ); 
                                  rmRiverAddWaypoint(seaE, 0.20, 0.70 );
                                  rmRiverAddWaypoint(seaE, 0.15, 0.72 );
                                  rmRiverAddWaypoint(seaE, 0.10, 0.73 );
                                  rmRiverAddWaypoint(seaE, 0.13, 0.70 );
                                  rmRiverAddWaypoint(seaF, 0.23, 0.52 );
                                  rmRiverAddWaypoint(seaF, 0.10, 0.53 );
                                  rmRiverAddWaypoint(seaF, 0.09, 0.50 );
                                  rmRiverAddWaypoint(seaF, 0.10, 0.45 );
                                  rmRiverAddWaypoint(seaF, 0.15, 0.43 );
                                  rmRiverAddWaypoint(seaF, 0.00, 0.40 );
                                  rmRiverAddWaypoint(seaF, 0.08, 0.35 );
                                  rmRiverAddWaypoint(seaF, 0.18, 0.43 );
                                  rmRiverAddWaypoint(seaF, 0.28, 0.41 ); 
                                  rmRiverAddWaypoint(seaG, 0.90, 0.75 );
                                  rmRiverAddWaypoint(seaG, 0.80, 0.68 );
                                  rmRiverAddWaypoint(seaG, 0.85, 0.72 ); 
                                  rmRiverAddWaypoint(seaG, 0.85, 0.70 );
                                  rmRiverAddWaypoint(seaG, 0.70, 0.58 );
                                  rmRiverAddWaypoint(seaG, 0.60, 0.58 );
                                  rmRiverAddWaypoint(seaG, 0.60, 0.57 ); 
                                  rmRiverAddWaypoint(seaG, 0.50, 0.58 );
                                  rmRiverAddWaypoint(seaG, 0.10, 0.60 );
                                  rmRiverAddWaypoint(seaG, 0.00, 0.60 );
                                  rmRiverAddWaypoint(seaB, 0.61, 0.74 );
                                  rmRiverAddWaypoint(seaB, 0.60, 0.70 );
                                  rmRiverAddWaypoint(seaB, 0.63, 0.70 );
                                  rmRiverAddWaypoint(seaB, 0.60, 0.60 );
                                  rmRiverAddWaypoint(seaC, 0.60, 0.62 );
                                  rmRiverAddWaypoint(seaC, 0.50, 0.62 );
                                  rmRiverAddWaypoint(seaC, 0.40, 0.62 );
                                  rmRiverAddWaypoint(seaC, 0.30, 0.60 );
                                  rmRiverAddWaypoint(seaK, 0.00, 0.65 );
                                  rmRiverAddWaypoint(seaK, 0.09, 0.64 );
                                  rmRiverAddWaypoint(seaH, 1.00, 0.50 );
                                  rmRiverAddWaypoint(seaH, 0.25, 0.50 ); 
                                  rmRiverAddWaypoint(seaH, 0.25, 0.40 );
                                  rmRiverAddWaypoint(seaH, 1.00, 0.40 ); 
                                  rmRiverAddWaypoint(seaD, 1.00, 0.70 );
                                  rmRiverAddWaypoint(seaD, 0.90, 0.70 );
                                  rmRiverAddWaypoint(seaD, 0.90, 0.65 );
                                  rmRiverAddWaypoint(seaD, 1.00, 0.25 );
                                  rmRiverAddWaypoint(seaD, 0.40, 0.25 );                                                                                                                  rmRiverAddWaypoint(seaD, 0.00, 0.20 );
                                  rmRiverAddWaypoint(seaD, 0.00, 0.26 );
                                  rmRiverAddWaypoint(seaD, 1.00, 0.26 );
                                  rmRiverAddWaypoint(seaD, 1.00, 0.27 );
                                  rmRiverAddWaypoint(seaD, 0.00, 0.27 );
                                  rmRiverAddWaypoint(seaD, 0.00, 0.28 );
                                  rmRiverAddWaypoint(seaD, 1.00, 0.28 ); 
                                  rmRiverAddWaypoint(seaD, 1.00, 0.29 );
                                  rmRiverAddWaypoint(seaD, 0.00, 0.29 );
                                  rmRiverAddWaypoint(seaD, 0.00, 0.30 );
                                  rmRiverAddWaypoint(seaD, 1.00, 0.30 ); 
                                  rmRiverAddWaypoint(seaD, 1.00, 0.33 );
                                  rmRiverAddWaypoint(seaD, 0.00, 0.33 );
                                  rmRiverAddWaypoint(seaA, 1.00, 0.65 );
                                  rmRiverAddWaypoint(seaA, 0.70, 0.55 );
                                  rmRiverAddWaypoint(seaA, 0.00, 0.55 );
                                  rmRiverAddWaypoint(seaA, 0.00, 0.20 );
                                  rmRiverAddWaypoint(seaL, 0.10, 0.70 );
                                  rmRiverAddWaypoint(seaL, 0.10, 0.78 );
                                  rmRiverAddWaypoint(seaL, 0.16, 0.78 );
                                  rmRiverAddWaypoint(seaL, 0.18, 0.70 );    
		rmRiverSetBankNoiseParams(seaS,0.00, 0, 0.0, 0.0, 0.0, 0.0);
		rmRiverSetBankNoiseParams(seaA,0.00, 0, 0.0, 0.0, 0.0, 0.0);
		rmRiverSetBankNoiseParams(seaB,0.00, 0, 0.0, 0.0, 0.0, 0.0);
		rmRiverSetBankNoiseParams(seaC,0.00, 0, 0.0, 0.0, 0.0, 0.0);
		rmRiverSetBankNoiseParams(seaD,0.00, 0, 0.0, 0.0, 0.0, 0.0);
		rmRiverSetBankNoiseParams(seaE,0.00, 0, 0.0, 0.0, 0.0, 0.0);
		rmRiverSetBankNoiseParams(seaF,0.00, 0, 0.0, 0.0, 0.0, 0.0);
		rmRiverSetBankNoiseParams(seaG,0.00, 0, 0.0, 0.0, 0.0, 0.0);
		rmRiverSetBankNoiseParams(seaH,0.00, 0, 0.0, 0.0, 0.0, 0.0);
                                  rmRiverSetBankNoiseParams(seaI,0.00, 0, 0.0, 0.0, 0.0, 0.0);
                                  rmRiverSetBankNoiseParams(seaJ,0.00, 0, 0.0, 0.0, 0.0, 0.0);
                                  rmRiverSetBankNoiseParams(seaK,0.00, 0, 0.0, 0.0, 0.0, 0.0);
                                  rmRiverSetBankNoiseParams(seaL,0.00, 0, 0.0, 0.0, 0.0, 0.0);
		rmRiverBuild(seaS);
		rmRiverBuild(seaA);
		rmRiverBuild(seaB);
		rmRiverBuild(seaC);
		rmRiverBuild(seaD);
		rmRiverBuild(seaE);
		rmRiverBuild(seaF);
		rmRiverBuild(seaG);
		rmRiverBuild(seaH);
                                  rmRiverBuild(seaI);
                                  rmRiverBuild(seaJ);
                                  rmRiverBuild(seaK);
                                  rmRiverBuild(seaL);
		rmAddAreaToClass(seaS,rmClassID("Sea"));
		rmAddAreaToClass(seaA,rmClassID("Sea"));
		rmAddAreaToClass(seaB,rmClassID("Sea"));
		rmAddAreaToClass(seaC,rmClassID("Sea"));
		rmAddAreaToClass(seaD,rmClassID("Sea"));
		rmAddAreaToClass(seaE,rmClassID("Sea"));
		rmAddAreaToClass(seaF,rmClassID("Sea"));
		rmAddAreaToClass(seaG,rmClassID("Sea"));
		rmAddAreaToClass(seaH,rmClassID("Sea"));
                                  rmAddAreaToClass(seaI,rmClassID("Sea"));
                                  rmAddAreaToClass(seaJ,rmClassID("Sea"));
                                  rmAddAreaToClass(seaK,rmClassID("Sea"));
                                  rmAddAreaToClass(seaL,rmClassID("Sea"));

	// *****************************************************************************************************

	// Text
	rmSetStatusText("",0.15);
	// ******************************************** Destroy ID *********************************************
	//AGG 3.0 Map	All start ID and count need <=9999.If you want to modify ,Please search up "9999".
	int InvisibleProjectileCount = rmRandFloat(200,300);
	int InvisibleProjectileDistance1 = 30;
	int InvisibleProjectileDistance2 = 45;
	int InvisibleProjectileDistance = rmRandFloat(InvisibleProjectileDistance1,InvisibleProjectileDistance2);
/*
	If (cNumberNonGaiaPlayers == 2) InvisibleProjectileCount = rmRandFloat(cNumberNonGaiaPlayers * 800,cNumberPlayers * 650);
	If (cNumberNonGaiaPlayers == 3) InvisibleProjectileCount = rmRandFloat(cNumberNonGaiaPlayers * 350,cNumberPlayers * 350);
	If (cNumberNonGaiaPlayers == 4) InvisibleProjectileCount = rmRandFloat(cNumberNonGaiaPlayers * 320,cNumberPlayers * 250);
	If (cNumberNonGaiaPlayers == 5) InvisibleProjectileCount = rmRandFloat(cNumberNonGaiaPlayers * 280,cNumberPlayers * 230);
	If (cNumberNonGaiaPlayers == 6) InvisibleProjectileCount = rmRandFloat(cNumberNonGaiaPlayers * 270,cNumberPlayers * 200);
	If (cNumberNonGaiaPlayers == 7) InvisibleProjectileCount = rmRandFloat(cNumberNonGaiaPlayers * 250,cNumberPlayers * 180);
	If (cNumberNonGaiaPlayers == 8) InvisibleProjectileCount = rmRandFloat(cNumberNonGaiaPlayers * 130,cNumberPlayers * 100);
*/

	int InvisibleProjectileID = 0;

	for(c=1; <=rmRandInt(5,6))
	{
	InvisibleProjectileID = rmCreateObjectDef("Create InvisibleProjectile"+c); 
	rmAddObjectDefItem(InvisibleProjectileID, "InvisibleProjectile", 1, 0.0);
	rmSetObjectDefMinDistance(InvisibleProjectileID, 0.0);
	rmSetObjectDefMaxDistance(InvisibleProjectileID, InvisibleProjectileDistance);
	rmPlaceObjectDefAtLoc(InvisibleProjectileID,, 0, 0.15, 0.15, InvisibleProjectileCount);
	}

	// *****************************************************************************************************

	// ******************************************** ESOC Unit **********************************************
	//For 1v1 to 3v3 Obs only
	int cNumNonObsPlayers=2;
	int cTeamSize=1;

	//Logic for type of obs, on assumption of tvb.
	if(rmGetPlayerTeam(1)!=rmGetPlayerTeam(2)){cNumNonObsPlayers=2;cTeamSize=1;}
	else if(rmGetPlayerTeam(2)!=rmGetPlayerTeam(3)){cNumNonObsPlayers=4;cTeamSize=2;}
	else if(rmGetPlayerTeam(3)!=rmGetPlayerTeam(4)){cNumNonObsPlayers=6;cTeamSize=3;}

	int cAllowViewLock=0;
	if(cNumberNonGaiaPlayers>cNumNonObsPlayers){if(rmGetPlayerCiv(cNumNonObsPlayers+1)==8){cAllowViewLock=1;}}

	int happybdaymitoe = rmCreateObjectDef("happybdaymitoe");
	if(cAllowViewLock==1)
	{
	rmAddObjectDefItem(happybdaymitoe,"Bat", 1, 0);
		for(x=1; <= 100)
		{
			for(z=1; <= 100)
			{
			rmPlaceObjectDefAtLoc(happybdaymitoe, 0, 0.01*z, 0.01*x, 1);
			}
		}
	}

	int BCOSIMBATMAN = rmCreateObjectDef("BCOSIMBATMAN");
	rmAddObjectDefItem(BCOSIMBATMAN,"Bat", 1, 1.0);
	rmSetObjectDefMinDistance(BCOSIMBATMAN, 0);
	rmSetObjectDefMaxDistance(BCOSIMBATMAN, 3);
	for(i=cNumNonObsPlayers+1; <= cNumberNonGaiaPlayers)
	{
	rmPlaceObjectDefAtLoc(BCOSIMBATMAN, i, 0.985, 0.45+0.01*i, 1);
	}


	// *****************************************************************************************************

	// Text
	rmSetStatusText("",0.20);

	// ******************************************* PLACE PLAYERS *******************************************

	int teamZeroCount = rmGetNumberPlayersOnTeam(0);
	int teamOneCount = rmGetNumberPlayersOnTeam(1);

	// 2 team and FFA support
	float OneVOnePlacement=rmRandFloat(0, 1);
	int randomplayer = rmRandInt(1, 2);
	if(rmGetPlayerName(1)=="Debug1")
	{	randomplayer=1;}
	if(rmGetPlayerName(1)=="Debug2")
	{	randomplayer=2;}
	if(randomplayer ==1)
		{
		rmPlacePlayer(1,0.52,0.82);
		rmPlacePlayer(2,0.50,0.1);
		}
	else
		{
		rmPlacePlayer(2,0.52,0.82);
		rmPlacePlayer(1,0.50,0.1);
		}
	// *****************************************************************************************************

	// Text
	rmSetStatusText("",0.25);

	// ****************************************** TRADE ROUTE **********************************************

int tradeRouteID = rmCreateTradeRoute();
            int socket2ID=rmCreateObjectDef("middle trade route");
    rmSetObjectDefTradeRouteID(socket2ID, tradeRouteID);
        rmAddObjectDefItem(socket2ID, "SocketTradeRoute", 1, 0.0);
    rmSetObjectDefAllowOverlap(socket2ID, true);
        rmSetObjectDefMinDistance(socket2ID, 0.0);
        rmSetObjectDefMaxDistance(socket2ID, 10.0);
    
rmAddTradeRouteWaypoint(tradeRouteID, 0.70,0.95); 
rmAddTradeRouteWaypoint(tradeRouteID, 0.50,0.95); 
rmAddTradeRouteWaypoint(tradeRouteID, 0.30,0.95); 

/*------------------------------------------------------------------------------------------------------------------------------------------------*/

bool placedTradeRoute = rmBuildTradeRoute(tradeRouteID, "water");
    if(placedTradeRoute == false)
rmEchoError("Failed to place trade route #1");

/*------------------------------------------------------------------------------------------------------------------------------------------------*/
vector socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.10);
        rmPlaceObjectDefAtPoint(socket2ID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.50);
        rmPlaceObjectDefAtPoint(socket2ID, 0, socketLoc);

socketLoc = rmGetTradeRouteWayPoint(tradeRouteID, 0.90);
        rmPlaceObjectDefAtPoint(socket2ID, 0, socketLoc);
	// *************************************************************************************************************

	// Text
	rmSetStatusText("",0.30);


	// ********************************************* NATIVE ************************************************
	int randomnative = rmRandInt(50,51);
	int shaolinID = rmCreateGrouping("shaolin A", "native shaolin temple mongol 04");
	rmSetGroupingMinDistance(shaolinID, 0.0);
	rmSetGroupingMaxDistance(shaolinID, rmXFractionToMeters(0.05));
	rmAddAreaToClass(shaolinID,rmClassID("natives"));
	rmAddGroupingConstraint(shaolinID, avoidImpassableLandMed);
	rmAddGroupingConstraint(shaolinID, avoidTradeRouteShort);
	rmAddGroupingConstraint(shaolinID, avoidTradeRouteSocket);
	rmPlaceGroupingAtLoc(shaolinID, 0,0.60,0.13);

	int ZenID = rmCreateGrouping("Zen A", "native zen temple ceylon 04");
	rmSetGroupingMinDistance(ZenID, 0.0);
	rmSetGroupingMaxDistance(ZenID,rmXFractionToMeters(0.05));
	rmAddAreaToClass(ZenID,rmClassID("natives"));
	rmAddGroupingConstraint(ZenID, avoidImpassableLandMed);
	rmAddGroupingConstraint(ZenID, avoidTradeRouteShort);
	rmAddGroupingConstraint(ZenID, avoidTradeRouteSocket);
	rmPlaceGroupingAtLoc(ZenID, 0,0.50,0.03);

	int JesuitID = rmCreateGrouping("Jesuit A", "native jesuit mission borneo 03");
	rmSetGroupingMinDistance(JesuitID, 0.0);
	rmSetGroupingMaxDistance(JesuitID, rmXFractionToMeters(0.05));
	rmAddAreaToClass(JesuitID,rmClassID("natives"));
	rmAddGroupingConstraint(JesuitID, avoidImpassableLandMed);
	rmAddGroupingConstraint(JesuitID, avoidTradeRouteShort);
	rmAddGroupingConstraint(JesuitID, avoidTradeRouteSocket);
	rmPlaceGroupingAtLoc(JesuitID, 0,0.40,0.13);

	
	// *********************************** PLAYER STARTING RESOURCES ***************************************

	// *********************************************** Grass ***********************************************
	// Grass
	for (i=0; < 50)
	{
		int GrassID = rmCreateObjectDef("drygrass"+i);
		rmAddObjectDefItem(GrassID, "UnderbrushYellowRiver", rmRandInt(1,1), 4.0); 
		rmSetObjectDefMinDistance(GrassID, 0);
		rmSetObjectDefMaxDistance(GrassID, rmXFractionToMeters(0.6));
		rmAddObjectDefToClass(GrassID, rmClassID("grass"));
		rmAddObjectDefConstraint(GrassID, avoidGrass);
		rmAddObjectDefConstraint(GrassID, avoidImpassableLandShort);
		rmAddObjectDefConstraint(GrassID, avoidTownCenterShort);
		rmAddObjectDefConstraint (GrassID, avoidNW);
		rmPlaceObjectDefAtLoc(GrassID, 0, 0.50, 0.50);
	}
	
	// *****************************************************************************************************

	// ********************************************** Define ***********************************************

	// Town center & units
	int TCID = rmCreateObjectDef("player TC");
	int startingUnits = rmCreateStartingUnitsObjectDef(5.0);
	int Chi3 = rmRandInt(rmRandInt(1,rmRandInt(2,3)),rmRandInt(4,5));
	if (rmGetNomadStart())
	{
	rmAddObjectDefItem(TCID, "CoveredWagon", 1, 0.0);
	rmAddObjectDefItem(TCID, "ypDockWagon", 1, 6.0);
	}
	else
	{
	rmAddObjectDefItem(TCID, "TownCenter", 1, 0.0);
	rmAddObjectDefItem(TCID, "ypDockWagon", 1, 10.0);
	}
	rmAddObjectDefToClass(TCID, classStartingResource);
//	rmAddObjectDefConstraint(TCID, avoidTradeRouteFar);
//	rmAddObjectDefConstraint(TCID, avoidTownCenterMed);
	rmSetObjectDefMinDistance(TCID, 0.0);
	rmSetObjectDefMaxDistance(TCID, 0.0);
	
	
	int playerWAID = rmCreateObjectDef("player WA");
   	if ( rmGetPlayerCiv(1) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(1) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(1) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(playerWAID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(1) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(playerWAID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(1) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(playerWAID, "YPBarracksIndian", 1, 2.0);
	}
	else if(rmGetPlayerCiv(1) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(playerWAID, "ypBarracksJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(1) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(playerWAID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(playerWAID, "Barracks", 1, 2.0);
	}
	rmSetObjectDefMinDistance(playerWAID, 16.0);
	rmSetObjectDefMaxDistance(playerWAID, 23.0);
	rmAddObjectDefToClass(playerWAID, classStartingResource);
	rmAddObjectDefConstraint(playerWAID, avoidTradeRoute);
	rmAddObjectDefConstraint(playerWAID, avoidImpassableLand);
	rmAddObjectDefConstraint(playerWAID, avoidNatives);
	rmAddObjectDefConstraint(playerWAID, avoidStartingResources);

	
	int playerWA2ID = rmCreateObjectDef("player WA 2");
   	if (rmGetPlayerCiv(1) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(playerWA2ID, "NoblesHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(1) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(playerWA2ID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(1) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(playerWA2ID, "ypCaravanserai", 1, 2.0);
	}
	else if(rmGetPlayerCiv(1) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(playerWA2ID, "ypStableJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(1) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(1) ==  rmGetCivID("XPSioux"))
	{
		rmAddObjectDefItem(playerWA2ID, "Corral", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(playerWA2ID, "Stable", 1, 2.0);
	}
	rmSetObjectDefMinDistance(playerWA2ID, 16.0);
	rmSetObjectDefMaxDistance(playerWA2ID, 23.0);
	rmAddObjectDefToClass(playerWA2ID, classStartingResource);
	rmAddObjectDefConstraint(playerWA2ID, avoidTradeRoute);
	rmAddObjectDefConstraint(playerWA2ID, avoidImpassableLand);
	rmAddObjectDefConstraint(playerWA2ID, avoidNatives);
	rmAddObjectDefConstraint(playerWA2ID, avoidStartingResources);
	
	int player2WAID = rmCreateObjectDef("player2 WA");
   	if ( rmGetPlayerCiv(2) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(2) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(2) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(player2WAID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(2) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(player2WAID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(2) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(player2WAID, "YPBarracksIndian", 1, 2.0);
	}
	else if(rmGetPlayerCiv(2) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(player2WAID, "ypBarracksJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(2) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(player2WAID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(player2WAID, "Barracks", 1, 2.0);
	}
	rmSetObjectDefMinDistance(player2WAID, 16.0);
	rmSetObjectDefMaxDistance(player2WAID, 23.0);
	rmAddObjectDefToClass(player2WAID, classStartingResource);
	rmAddObjectDefConstraint(player2WAID, avoidTradeRoute);
	rmAddObjectDefConstraint(player2WAID, avoidImpassableLand);
	rmAddObjectDefConstraint(player2WAID, avoidNatives);
	rmAddObjectDefConstraint(player2WAID, avoidStartingResources);

	
	int player2WA2ID = rmCreateObjectDef("player2 WA 2");
   	if (rmGetPlayerCiv(2) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(player2WA2ID, "NoblesHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(2) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(player2WA2ID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(2) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(player2WA2ID, "ypCaravanserai", 1, 2.0);
	}
	else if(rmGetPlayerCiv(2) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(player2WA2ID, "ypStableJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(2) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(2) ==  rmGetCivID("XPSioux"))
	{
		rmAddObjectDefItem(player2WA2ID, "Corral", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(player2WA2ID, "Stable", 1, 2.0);
	}
	rmSetObjectDefMinDistance(player2WA2ID, 16.0);
	rmSetObjectDefMaxDistance(player2WA2ID, 23.0);
	rmAddObjectDefToClass(player2WA2ID, classStartingResource);
	rmAddObjectDefConstraint(player2WA2ID, avoidTradeRoute);
	rmAddObjectDefConstraint(player2WA2ID, avoidImpassableLand);
	rmAddObjectDefConstraint(player2WA2ID, avoidNatives);
	rmAddObjectDefConstraint(player2WA2ID, avoidStartingResources);
	
	// Starting mines
	int playergoldID = rmCreateObjectDef("player mine");
	rmAddObjectDefItem(playergoldID, "minegold", 1, 0);
	rmSetObjectDefMinDistance(playergoldID, 16.0);
	rmSetObjectDefMaxDistance(playergoldID, 18.0);
	rmAddObjectDefToClass(playergoldID, classStartingResource);
	rmAddObjectDefToClass(playergoldID, classGold);
	rmAddObjectDefConstraint(playergoldID, avoidGoldType);
	rmAddObjectDefConstraint(playergoldID, avoidTradeRoute);
	rmAddObjectDefConstraint(playergoldID, avoidImpassableLand);
	rmAddObjectDefConstraint(playergoldID, avoidNatives);
	rmAddObjectDefConstraint(playergoldID, avoidStartingResources);
	
	// 2nd mine
	int playergold2ID = rmCreateObjectDef("player second mine");
	rmAddObjectDefItem(playergold2ID, "mine", 1, 0);
	rmSetObjectDefMinDistance(playergold2ID, 18.0); //58
	rmSetObjectDefMaxDistance(playergold2ID, 20.0); //62
	rmAddObjectDefToClass(playergold2ID, classStartingResource);
	rmAddObjectDefToClass(playergold2ID, classGold);
	rmAddObjectDefConstraint(playergold2ID, avoidTradeRoute);
	rmAddObjectDefConstraint(playergold2ID, avoidImpassableLand);
	rmAddObjectDefConstraint(playergold2ID, avoidNatives);
	rmAddObjectDefConstraint(playergold2ID, avoidGoldType);
	rmAddObjectDefConstraint(playergold2ID, avoidStartingResources);
	
	// 3nd mine
	int playergold3ID = rmCreateObjectDef("player third mine");
	rmAddObjectDefItem(playergold3ID, "mine", 1, 0);
	rmSetObjectDefMinDistance(playergold3ID, 68.0); //58
	rmSetObjectDefMaxDistance(playergold3ID, 70.0); //62
	rmAddObjectDefToClass(playergold3ID, classStartingResource);
	rmAddObjectDefToClass(playergold3ID, classGold);
	rmAddObjectDefConstraint(playergold3ID, avoidTradeRouteShort);
	rmAddObjectDefConstraint(playergold3ID, avoidTradeRouteSocket);
	rmAddObjectDefConstraint(playergold3ID, avoidImpassableLand);
	rmAddObjectDefConstraint(playergold3ID, avoidNatives);
	rmAddObjectDefConstraint(playergold3ID, avoidGoldTypeFar);
	rmAddObjectDefConstraint(playergold3ID, avoidStartingResources);
	rmAddObjectDefConstraint(playergold3ID, avoidEdgeMore);
	rmAddObjectDefConstraint(playergold3ID, avoidCenterMore);
	
	// 4th mine
	int playergold4ID = rmCreateObjectDef("player forth mine");
	rmAddObjectDefItem(playergold4ID, "minegold", 1, 0);
	rmSetObjectDefMinDistance(playergold4ID, 18.0); //58
	rmSetObjectDefMaxDistance(playergold4ID, 20.0); //62
	rmAddObjectDefToClass(playergold4ID, classStartingResource);
	rmAddObjectDefToClass(playergold4ID, classGold);
	rmAddObjectDefConstraint(playergold4ID, avoidTradeRoute);
	rmAddObjectDefConstraint(playergold4ID, avoidImpassableLand);
	rmAddObjectDefConstraint(playergold4ID, avoidNatives);
	rmAddObjectDefConstraint(playergold4ID, avoidGoldType);
	rmAddObjectDefConstraint(playergold4ID, avoidStartingResources);

	// Starting trees1
	int playerTree1ID = rmCreateObjectDef("player trees");
	rmAddObjectDefItem(playerTree1ID, "ypTreeYellowRiver", 7, 1.0);
	rmSetObjectDefMinDistance(playerTree1ID, 6);
	rmSetObjectDefMaxDistance(playerTree1ID, 12);
	rmAddObjectDefToClass(playerTree1ID, classStartingResource);
//	rmAddObjectDefToClass(playerTree1ID, classForest);
//	rmAddObjectDefConstraint(playerTree1ID, avoidForestMin);
	rmAddObjectDefConstraint(playerTree1ID, avoidTradeRoute);
	rmAddObjectDefConstraint(playerTree1ID, avoidImpassableLand);
//	rmAddObjectDefConstraint(playerTree1ID, avoidStartingResources);
	
	// Starting trees2
	int playerTree2ID = rmCreateObjectDef("player trees2");
	rmAddObjectDefItem(playerTree2ID, "ypTreeYellowRiver", 7, 2.0);
	rmSetObjectDefMinDistance(playerTree2ID, 8);
	rmSetObjectDefMaxDistance(playerTree2ID, 14);
	rmAddObjectDefToClass(playerTree2ID, classStartingResource);
//	rmAddObjectDefToClass(playerTree2ID, classForest);
//	rmAddObjectDefConstraint(playerTree2ID, avoidForestMin);
	rmAddObjectDefConstraint(playerTree2ID, avoidTradeRoute);
	rmAddObjectDefConstraint(playerTree2ID, avoidImpassableLand);
//	rmAddObjectDefConstraint(playerTree2ID, avoidStartingResources);
	
	// Starting herd
	int playerherdID = rmCreateObjectDef("starting herd");
	rmAddObjectDefItem(playerherdID, "ypGiantSalamander", 12, 4.0);
	rmSetObjectDefMinDistance(playerherdID, 8.0);
	rmSetObjectDefMaxDistance(playerherdID, 12.0);
	rmSetObjectDefCreateHerd(playerherdID, true);
	rmAddObjectDefToClass(playerherdID, classStartingResource);
	rmAddObjectDefConstraint(playerherdID, avoidTradeRoute);
	rmAddObjectDefConstraint(playerherdID, avoidImpassableLand);
	rmAddObjectDefConstraint(playerherdID, avoidNatives);
	rmAddObjectDefConstraint(playerherdID, avoidStartingResourcesShort);
	
	// Starting Berry
	int playerBerryID=rmCreateObjectDef("player berries");
	rmAddObjectDefItem(playerBerryID, "BerryBush", 6, 3.0);
	rmSetObjectDefMinDistance(playerBerryID, 12);
	rmSetObjectDefMaxDistance(playerBerryID, 14);
	rmAddObjectDefToClass(playerBerryID, classStartingResource);
	rmAddObjectDefConstraint(playerBerryID, avoidTradeRoute);
	rmAddObjectDefConstraint(playerBerryID, avoidImpassableLand);

	// (Chinese) Starting Crate 
	int ChineseCrateID=rmCreateObjectDef("Chinese Crate");
		if ( Chi3 == 1 )
			{
			rmAddObjectDefItem(ChineseCrateID, "CrateofWood", 1, 5.0);
			}
		if ( Chi3 == 2 )
			{
			rmAddObjectDefItem(ChineseCrateID, "CrateofFood", 1, 5.0);
			}
		if ( Chi3 == 3 )
			{
			rmAddObjectDefItem(ChineseCrateID, "CrateofCoin", 1, 5.0);
			}
		if ( Chi3 == 4 )
			{
			rmAddObjectDefItem(ChineseCrateID, "Crateofwood", 1, 5.0);
			rmAddObjectDefItem(ChineseCrateID, "CrateofCoin", 1, 5.0);
			}
		if ( Chi3 == 5 )
			{
			rmAddObjectDefItem(ChineseCrateID, "Crateoffood", 1, 5.0);
			rmAddObjectDefItem(ChineseCrateID, "CrateofCoin", 1, 5.0);
			}
	rmSetObjectDefMinDistance(ChineseCrateID, 4);
	rmSetObjectDefMaxDistance(ChineseCrateID, 6);
	rmAddObjectDefToClass(ChineseCrateID, classStartingResource);
	rmAddObjectDefConstraint(ChineseCrateID, avoidTradeRoute);
	rmAddObjectDefConstraint(ChineseCrateID, avoidImpassableLand);

	// (SPCAct3) Starting Hero
	int SPCAct3ID=rmCreateObjectDef("SPCACT3");
	rmAddObjectDefItem(SPCAct3ID, "SPCAmelia", 1, 5.0);
	rmAddObjectDefItem(SPCAct3ID, "SPCCooper", 1, 5.0);
	rmSetObjectDefMinDistance(SPCAct3ID, 18);
	rmSetObjectDefMaxDistance(SPCAct3ID, 22);
	rmAddObjectDefToClass(SPCAct3ID, classStartingResource);
	rmAddObjectDefConstraint(SPCAct3ID, avoidTradeRoute);
	rmAddObjectDefConstraint(SPCAct3ID, avoidImpassableLand);
	
	// (SPCAct3) Starting Crate
	int SPCAct3CrateID=rmCreateObjectDef("SPC Crate");
	rmAddObjectDefItem(SPCAct3CrateID, "Crateoffood", 2, 4.0);
	rmAddObjectDefItem(SPCAct3CrateID, "Crateofwood", 2, 4.0);
	rmSetObjectDefMinDistance(SPCAct3CrateID, 4);
	rmSetObjectDefMaxDistance(SPCAct3CrateID, 6);
	rmAddObjectDefToClass(SPCAct3CrateID, classStartingResource);
	rmAddObjectDefConstraint(SPCAct3CrateID, avoidTradeRoute);
	rmAddObjectDefConstraint(SPCAct3CrateID, avoidImpassableLand);

	// (XPSPC) Starting Crate
	int XPSPCID=rmCreateObjectDef("SPC Country");
	rmAddObjectDefItem(XPSPCID, "SPCXPNathaniel", 1, 5.0);
	rmAddObjectDefItem(XPSPCID, "SPCXPWashington", 1, 5.0);
	rmSetObjectDefMinDistance(XPSPCID, 18);
	rmSetObjectDefMaxDistance(XPSPCID, 22);
	rmAddObjectDefToClass(XPSPCID, classStartingResource);
	rmAddObjectDefConstraint(XPSPCID, avoidTradeRoute);
	rmAddObjectDefConstraint(XPSPCID, avoidImpassableLand);
	rmAddObjectDefConstraint(XPSPCID, avoidStartingResources);
	rmAddObjectDefConstraint(XPSPCID, avoidNatives);
	rmAddObjectDefConstraint(XPSPCID, avoidEdge);
	rmAddObjectDefConstraint(XPSPCID, avoidNugget);

	// 2nd herd
	int playerSaigaID = rmCreateObjectDef("player Saiga");
	rmAddObjectDefItem(playerSaigaID, "ypSaiga", rmRandInt(11,11), 10.0);
	rmSetObjectDefMinDistance(playerSaigaID, 38);
	rmSetObjectDefMaxDistance(playerSaigaID, 40);
	rmSetObjectDefCreateHerd(playerSaigaID, true);
	rmAddObjectDefConstraint(playerSaigaID, avoidTradeRouteSocket);
	rmAddObjectDefConstraint(playerSaigaID, avoidImpassableLandShort);
	rmAddObjectDefConstraint(playerSaigaID, avoidNativesShort);
//	rmAddObjectDefConstraint(playerSaigaID, avoidStartingResources);
	rmAddObjectDefConstraint(playerSaigaID, avoidSaigaShort);
	rmAddObjectDefConstraint(playerSaigaID, avoidIbexShort);
	rmAddObjectDefConstraint(playerSaigaID, avoidCenterMore);
	
	// 3rd herd
	int playerMarcoPoloSheepID = rmCreateObjectDef("player MarcoPoloSheep");
	rmAddObjectDefItem(playerMarcoPoloSheepID, "ypMarcoPoloSheep", rmRandInt(8,8), 8.0);
	rmSetObjectDefMinDistance(playerMarcoPoloSheepID, 48);
	rmSetObjectDefMaxDistance(playerMarcoPoloSheepID, 50);
	rmSetObjectDefCreateHerd(playerMarcoPoloSheepID, true);
	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidMarcoPoloSheepFar); 
//	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidSaigaShort);
//	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidIbexShort);
	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidSerowFar);
	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidTradeRouteShort);
	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidImpassableLandShort);
	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidNativesShort);
//	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidCenterShort);
//	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidStartingResources);
	rmAddObjectDefConstraint(playerMarcoPoloSheepID, avoidEdgeMore);
	
	// Starting treasures
	int playerNuggetID = rmCreateObjectDef("player nugget"); 
	rmAddObjectDefItem(playerNuggetID, "Nugget", 1, 0.0);
	rmSetNuggetDifficulty(1, 1);
	rmSetObjectDefMinDistance(playerNuggetID, 20.0);
	rmSetObjectDefMaxDistance(playerNuggetID, 30.0);
	rmAddObjectDefToClass(playerNuggetID, classStartingResource);
	rmAddObjectDefConstraint(playerNuggetID, avoidTradeRoute);
	rmAddObjectDefConstraint(playerNuggetID, avoidImpassableLand);
	rmAddObjectDefConstraint(playerNuggetID, avoidNatives);
	rmAddObjectDefConstraint(playerNuggetID, avoidStartingResources);
	rmAddObjectDefConstraint(playerNuggetID, avoidNugget);
	rmAddObjectDefConstraint(playerNuggetID, avoidEdge);
	int nugget0count = rmRandInt (2,2);

	int OBSUIID = rmCreateObjectDef("ESOC OBSUI Unit");
	rmAddObjectDefItem(OBSUIID, "Minuteman", 1, 20.0);
	rmSetObjectDefMinDistance(OBSUIID, 0);
	rmSetObjectDefMaxDistance(OBSUIID, 40);

	// Text
	rmSetStatusText("",0.35);

	// ************************************************ Place ************************************************
	
	for(i=1; <=cNumberNonGaiaPlayers - ObsUIPlayer)
	{
		rmPlaceObjectDefAtLoc(TCID, i, rmPlayerLocXFraction(i), rmPlayerLocZFraction(i));

		vector TCLoc = rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, i));
			rmPlaceObjectDefAtLoc(startingUnits, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playergoldID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playergold2ID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playergold3ID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playergold4ID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playerherdID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playerTree1ID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playerTree1ID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playerTree1ID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playerTree2ID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playerTree2ID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playerBerryID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
//			rmPlaceObjectDefAtLoc(playerSaigaID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playerMarcoPoloSheepID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
			rmPlaceObjectDefAtLoc(playerNuggetID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
/*
			if (rmGetPlayerCiv(i) == 20 || rmGetPlayerCiv(i) ==rmGetCivID("SPCChinese"))
				{
				rmPlaceObjectDefAtLoc(ChineseCrateID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
				}
*/
			if (rmGetPlayerCiv(i) == rmGetCivID("SPCAct3"))
				{
				rmPlaceObjectDefAtLoc(SPCAct3CrateID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
				rmPlaceObjectDefAtLoc(SPCAct3ID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
				}
			if (rmGetPlayerCiv(i) == rmGetCivID("XPSPC"))
				{
				rmPlaceObjectDefAtLoc(SPCAct3CrateID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
				rmPlaceObjectDefAtLoc(XPSPCID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
				}
			if (nugget0count == 2)
			rmPlaceObjectDefAtLoc(playerNuggetID, i, rmXMetersToFraction(xsVectorGetX(TCLoc)), rmZMetersToFraction(xsVectorGetZ(TCLoc)));
	}
			rmPlaceObjectDefAtLoc(playerWAID, 1, rmXMetersToFraction(xsVectorGetX(rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, 1)))), rmZMetersToFraction(xsVectorGetZ(rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, 1)))));
			rmPlaceObjectDefAtLoc(playerWA2ID, 1, rmXMetersToFraction(xsVectorGetX(rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, 1)))), rmZMetersToFraction(xsVectorGetZ(rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, 1)))));

			rmPlaceObjectDefAtLoc(player2WAID, 2, rmXMetersToFraction(xsVectorGetX(rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, 2)))), rmZMetersToFraction(xsVectorGetZ(rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, 2)))));
			rmPlaceObjectDefAtLoc(player2WA2ID, 2, rmXMetersToFraction(xsVectorGetX(rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, 2)))), rmZMetersToFraction(xsVectorGetZ(rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, 2)))));

	// *******************************************************************************************************
	

	// *******************************************************************************************************
	
   int GunID = rmCreateObjectDef("Gun 1");
   rmAddObjectDefItem(GunID, "SPCFixedGun", 1, 2.0);
   rmSetObjectDefMinDistance(GunID, 0.0);
   rmSetObjectDefMaxDistance(GunID, 0.0);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(GunID, 2, 0.19, 0.67);
   else
   rmPlaceObjectDefAtLoc(GunID, 1, 0.19, 0.67);
   int GunSelect1 = rmGetUnitPlaced(GunID, 0);

	
   int Gun2ID = rmCreateObjectDef("Gun 2");
   rmAddObjectDefItem(Gun2ID, "SPCFixedGun", 1, 2.0);
   rmSetObjectDefMinDistance(Gun2ID, 0.0);
   rmSetObjectDefMaxDistance(Gun2ID, 10);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Gun2ID, 2, 0.84, 0.79);
   else
   rmPlaceObjectDefAtLoc(Gun2ID, 1, 0.84, 0.79);
   int GunSelect2 = rmGetUnitPlaced(Gun2ID, 0);

	
   int CacheID = rmCreateObjectDef("Cache 1");
   rmAddObjectDefItem(CacheID, "SPCXPBarn", 1, 2.0);
   rmSetObjectDefMinDistance(CacheID, 0.0);
   rmSetObjectDefMaxDistance(CacheID, rmXFractionToMeters(0.05));
   rmAddObjectDefConstraint(CacheID, avoidTradeRouteShort);
   rmAddObjectDefConstraint(CacheID, avoidTradeRouteSocket);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(CacheID, 1, 0.42, 0.92);
   else
   rmPlaceObjectDefAtLoc(CacheID, 2, 0.42, 0.92);
   int CacheSelect = rmGetUnitPlaced(CacheID, 0);

	
   int WAID = rmCreateObjectDef("WA 1");
   	if ( rmGetPlayerCiv(randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(WAID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(WAID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(WAID, "YPBarracksIndian", 1, 2.0);
	}
	else if(rmGetPlayerCiv(randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(WAID, "ypBarracksJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(WAID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(WAID, "Barracks", 1, 2.0);
	}
   rmSetObjectDefMinDistance(WAID, 0.0);
   rmSetObjectDefMaxDistance(WAID, 0.0);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(WAID, 1, 0.125, 0.755);
   else
   rmPlaceObjectDefAtLoc(WAID, 2, 0.125, 0.755);

   int CastleID = rmCreateObjectDef("Castle 1");
   	if ( rmGetPlayerCiv(randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(CastleID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(CastleID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(CastleID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(CastleID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(CastleID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(CastleID, "Outpost", 1, 2.0);
	}
   rmSetObjectDefMinDistance(CastleID, 0.0);
   rmSetObjectDefMaxDistance(CastleID, 0.0);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(CastleID, 1, 0.14, 0.751);
   else
   rmPlaceObjectDefAtLoc(CastleID, 2, 0.14, 0.751);
	
   int WA2ID = rmCreateObjectDef("WA 2");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(WA2ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(WA2ID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(WA2ID, "YPBarracksIndian", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(WA2ID, "ypBarracksJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(WA2ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(WA2ID, "Barracks", 1, 2.0);
	}
   rmSetObjectDefMinDistance(WA2ID, 0.0);
   rmSetObjectDefMaxDistance(WA2ID, 0.0);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(WA2ID, 2, 0.172, 0.672);
   else
   rmPlaceObjectDefAtLoc(WA2ID, 1, 0.172, 0.672);

   int Castle2ID = rmCreateObjectDef("Castle 2");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(Castle2ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(Castle2ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(Castle2ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(Castle2ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(Castle2ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(Castle2ID, "Outpost", 1, 2.0);
	}
   rmSetObjectDefMinDistance(Castle2ID, 0.0);
   rmSetObjectDefMaxDistance(Castle2ID, 0.0);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Castle2ID, 2, 0.147, 0.687);
   else
   rmPlaceObjectDefAtLoc(Castle2ID, 1, 0.147, 0.687);
	
   int Dock4ID = rmCreateObjectDef("Dock 4");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("Chinese") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("Indians") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(Dock4ID, "YPDockAsian", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(Dock4ID, "Dock", 1, 2.0);
	}
   rmSetObjectDefMinDistance(Dock4ID, 0.0);
   rmSetObjectDefMaxDistance(Dock4ID, rmXFractionToMeters(0.05));
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Dock4ID, 2, 0.15, 0.50);
   else
   rmPlaceObjectDefAtLoc(Dock4ID, 1, 0.15, 0.50);
   int DockSelect = rmGetUnitPlaced(Dock4ID, 0);

   int Castle3ID = rmCreateObjectDef("Castle 3");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(Castle3ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(Castle3ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(Castle3ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(Castle3ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(Castle3ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(Castle3ID, "Outpost", 1, 2.0);
	}
   rmSetObjectDefMinDistance(Castle3ID, 0.0);
   rmSetObjectDefMaxDistance(Castle3ID, rmXFractionToMeters(0.12));
   rmAddObjectDefConstraint(Castle3ID, avoidCastle);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Castle3ID, 2, 0.15, 0.50);
   else
   rmPlaceObjectDefAtLoc(Castle3ID, 1, 0.15, 0.50);
	

   int Castle4ID = rmCreateObjectDef("Castle 4");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(Castle4ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(Castle4ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(Castle4ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(Castle4ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(Castle4ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(Castle4ID, "Outpost", 1, 2.0);
	}
   rmSetObjectDefMinDistance(Castle4ID, 0.0);
   rmSetObjectDefMaxDistance(Castle4ID, rmXFractionToMeters(0.12));
   rmAddObjectDefConstraint(Castle4ID, avoidCastle);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Castle4ID, 2, 0.15, 0.50);
   else
   rmPlaceObjectDefAtLoc(Castle4ID, 1, 0.15, 0.50);
	
   int WA3ID = rmCreateObjectDef("WA 3");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(WA3ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(WA3ID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(WA3ID, "YPBarracksIndian", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(WA3ID, "ypBarracksJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(WA3ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(WA3ID, "Barracks", 1, 2.0);
	}
   rmSetObjectDefMinDistance(WA3ID, 0.0);
   rmSetObjectDefMaxDistance(WA3ID, rmXFractionToMeters(0.12));
   rmAddObjectDefConstraint(WA3ID, avoidCastle);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(WA3ID, 2, 0.15, 0.50);
   else
   rmPlaceObjectDefAtLoc(WA3ID, 1, 0.15, 0.50);


   int Castle5ID = rmCreateObjectDef("Castle 5");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(Castle5ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(Castle5ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(Castle5ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(Castle5ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(Castle5ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(Castle5ID, "Outpost", 1, 2.0);
	}
   rmSetObjectDefMinDistance(Castle5ID, 0.0);
   rmSetObjectDefMaxDistance(Castle5ID, rmXFractionToMeters(0.12));
   rmAddObjectDefConstraint(Castle5ID, avoidCastle);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Castle5ID, 2, 0.15, 0.50);
   else
   rmPlaceObjectDefAtLoc(Castle5ID, 1, 0.15, 0.50);
	

   int Castle6ID = rmCreateObjectDef("Castle 6");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(Castle6ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(Castle6ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(Castle6ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(Castle6ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(Castle6ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(Castle6ID, "Outpost", 1, 2.0);
	}
   rmSetObjectDefMinDistance(Castle6ID, 0.0);
   rmSetObjectDefMaxDistance(Castle6ID, rmXFractionToMeters(0.12));
   rmAddObjectDefConstraint(Castle6ID, avoidCastle);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Castle6ID, 2, 0.15, 0.50);
   else
   rmPlaceObjectDefAtLoc(Castle6ID, 1, 0.15, 0.50);
	
   int WA4ID = rmCreateObjectDef("WA 4");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(WA4ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(WA4ID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(WA4ID, "YPBarracksIndian", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(WA4ID, "ypBarracksJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(WA4ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(WA4ID, "Barracks", 1, 2.0);
	}
   rmSetObjectDefMinDistance(WA4ID, 0.0);
   rmSetObjectDefMaxDistance(WA4ID, rmXFractionToMeters(0.12));
   rmAddObjectDefConstraint(WA4ID, avoidCastle);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(WA4ID, 2, 0.15, 0.50);
   else
   rmPlaceObjectDefAtLoc(WA4ID, 1, 0.15, 0.50);


   int Castle7ID = rmCreateObjectDef("Castle 7");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(Castle7ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(Castle7ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(Castle7ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(Castle7ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(Castle7ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(Castle7ID, "Outpost", 1, 2.0);
	}
   rmSetObjectDefMinDistance(Castle7ID, 0.0);
   rmSetObjectDefMaxDistance(Castle7ID, rmXFractionToMeters(0.12));
   rmAddObjectDefConstraint(Castle7ID, avoidCastle);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Castle7ID, 2, 0.1, 0.40);
   else
   rmPlaceObjectDefAtLoc(Castle7ID, 1, 0.1, 0.40);
	

   int Castle8ID = rmCreateObjectDef("Castle 8");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(Castle8ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(Castle8ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(Castle8ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(Castle8ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(Castle8ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(Castle8ID, "Outpost", 1, 2.0);
	}
   rmSetObjectDefMinDistance(Castle8ID, 0.0);
   rmSetObjectDefMaxDistance(Castle8ID, rmXFractionToMeters(0.12));
   rmAddObjectDefConstraint(Castle8ID, avoidCastle);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Castle8ID, 2, 0.1, 0.40);
   else
   rmPlaceObjectDefAtLoc(Castle8ID, 1, 0.1, 0.40);
	
   int WA5ID = rmCreateObjectDef("WA 5");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(WA5ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(WA5ID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(WA5ID, "YPBarracksIndian", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(WA5ID, "ypBarracksJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(WA5ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(WA5ID, "Barracks", 1, 2.0);
	}
   rmSetObjectDefMinDistance(WA5ID, 0.0);
   rmSetObjectDefMaxDistance(WA5ID, rmXFractionToMeters(0.12));
   rmAddObjectDefConstraint(WA5ID, avoidCastle);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(WA5ID, 2, 0.1, 0.40);
   else
   rmPlaceObjectDefAtLoc(WA5ID, 1, 0.1, 0.40);

	
   int WA6ID = rmCreateObjectDef("WA 6");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(WA6ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(WA6ID, "ypWarAcademy", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(WA6ID, "YPBarracksIndian", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(WA6ID, "ypBarracksJapanese", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(WA6ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(WA6ID, "Barracks", 1, 2.0);
	}
   rmSetObjectDefMinDistance(WA6ID, 0.0);
   rmSetObjectDefMaxDistance(WA6ID, 10.0);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(WA6ID, 2, 0.88, 0.79);
   else
   rmPlaceObjectDefAtLoc(WA6ID, 1, 0.88, 0.79);

   int Castle9ID = rmCreateObjectDef("Castle 9");
   	if ( rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPIroquois") || rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPSioux") ||	rmGetPlayerCiv(3-randomplayer) ==  rmGetCivID("XPAztec"))
	{
		rmAddObjectDefItem(Castle9ID, "WarHut", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Chinese"))
	{
		rmAddObjectDefItem(Castle9ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Indians"))
	{
		rmAddObjectDefItem(Castle9ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Japanese"))
	{
		rmAddObjectDefItem(Castle9ID, "ypCastle", 1, 2.0);
	}
	else if(rmGetPlayerCiv(3-randomplayer) == rmGetCivID("Russians"))
	{
		rmAddObjectDefItem(Castle9ID, "Blockhouse", 1, 2.0);
	}
	else
	{
		rmAddObjectDefItem(Castle9ID, "Outpost", 1, 2.0);
	}
   rmSetObjectDefMinDistance(Castle9ID, 0.0);
   rmSetObjectDefMaxDistance(Castle9ID, 10.0);
   if(randomplayer ==1)
   rmPlaceObjectDefAtLoc(Castle9ID, 2, 0.85, 0.77);
   else
   rmPlaceObjectDefAtLoc(Castle9ID, 1, 0.85, 0.77);

   int TowerID = rmCreateObjectDef("Tower 1");
   rmAddObjectDefItem(TowerID, "YPOutpostAsian", 1, 2.0);
   rmSetObjectDefMinDistance(TowerID, 0.0);
   rmSetObjectDefMaxDistance(TowerID, rmXFractionToMeters(0.3));
   rmAddObjectDefConstraint(TowerID, nearWater);
   rmAddObjectDefConstraint(TowerID, avoidCastleLong);
   rmAddObjectDefConstraint(TowerID, avoidGun);
   if(randomplayer ==1)
   {
   rmPlaceObjectDefAtLoc(TowerID, 1, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 1, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 1, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 1, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 1, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 1, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 1, 0.52,0.82);
   }
   else
   {
   rmPlaceObjectDefAtLoc(TowerID, 2, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 2, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 2, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 2, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 2, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 2, 0.52,0.82);
   rmPlaceObjectDefAtLoc(TowerID, 2, 0.52,0.82);
   }

   int Tower2ID = rmCreateObjectDef("Tower 2");
   rmAddObjectDefItem(Tower2ID, "YPOutpostAsian", 1, 2.0);
   rmSetObjectDefMinDistance(Tower2ID, 0.0);
   rmSetObjectDefMaxDistance(Tower2ID, rmXFractionToMeters(0.3));
   rmAddObjectDefConstraint(Tower2ID, nearWater);
   rmAddObjectDefConstraint(Tower2ID, avoidCastleLong);
   if(randomplayer ==1)
   {
   rmPlaceObjectDefAtLoc(Tower2ID, 2, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 2, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 2, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 2, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 2, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 2, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 2, 0.50,0.1);
   }
   else
   {
   rmPlaceObjectDefAtLoc(Tower2ID, 1, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 1, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 1, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 1, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 1, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 1, 0.50,0.1);
   rmPlaceObjectDefAtLoc(Tower2ID, 1, 0.50,0.1);
   }

	// Text
	rmSetStatusText("",0.40);

	// *******************************************************************************************************	

	// ********************************************** Mines **************************************************
	
	int goldCount = rmRandInt(8 * (cNumberNonGaiaPlayers - ObsUIPlayer), 7 * (cNumberNonGaiaPlayers - ObsUIPlayer));
		
	//Mines
	for(i=0; < goldCount)
	{
		int goldID = rmCreateObjectDef("gold"+i);
		rmAddObjectDefItem(goldID, "Mine", 1, 0.0);
		rmSetObjectDefMinDistance(goldID, 0);
		rmSetObjectDefMaxDistance(goldID, rmXFractionToMeters(0.5));
		rmAddObjectDefToClass(goldID, classGold);
		rmAddObjectDefConstraint(goldID, avoidTradeRouteSocketFar);
		rmAddObjectDefConstraint(goldID, avoidTradeRoute);
		rmAddObjectDefConstraint(goldID, avoidNatives);
		rmAddObjectDefConstraint(goldID, avoidImpassableLand);
		rmAddObjectDefConstraint(goldID, avoidGoldVeryFar);
//		rmAddObjectDefConstraint(goldID, Northwestconstraint);
		rmAddObjectDefConstraint(goldID, avoidTownCenterVeryFar);
		rmAddObjectDefConstraint(goldID, avoidEdgeMore);
		rmPlaceObjectDefAtLoc(goldID, 0, 0.50, 0.9);
	}
	for(i=0; < goldCount)
	{
		rmPlaceObjectDefAtLoc(goldID, 0, 0.50, 0.1);
	}
	
	// *******************************************************************************************************
	
	// ***************************************** Island Resources ********************************************
/*
	int TreeCount2 = rmRandInt(15,20);//((cNumberNonGaiaPlayers - ObsUIPlayer) * 8)

	int NuggetJapanID = rmCreateObjectDef("NuggetJapan ");
	rmAddObjectDefItem(NuggetJapanID, "nugget", 1, 0.0);
	rmSetNuggetDifficulty(4, 4);
	rmSetObjectDefMinDistance(NuggetJapanID, 0.0);
	rmSetObjectDefMaxDistance(NuggetJapanID, rmXFractionToMeters(0.05));
	rmAddGroupingConstraint(NuggetJapanID, avoidSeaShort);
	rmPlaceObjectDefAtLoc(NuggetJapanID, 0, 0.61, 0.05, 1);

	int TreeJapanID = rmCreateObjectDef("TreeJapan ");
	rmAddObjectDefItem(TreeJapanID, "ypTreeCoastalJapan", TreeCount2, 15.0);
	rmSetObjectDefMinDistance(TreeJapanID, 0.0);
	rmSetObjectDefMaxDistance(TreeJapanID, rmXFractionToMeters(0.10));
	rmAddGroupingConstraint(TreeJapanID, avoidSeaShort);
	rmPlaceObjectDefAtLoc(TreeJapanID, 0, 0.13, 0.48, 1);

	int HerdJapanID = rmCreateObjectDef("HerdJapan ");
	rmAddObjectDefItem(HerdJapanID, "ypGiantSalamander", 6, 8.0);
	rmSetObjectDefMinDistance(HerdJapanID, 0.0);
	rmSetObjectDefMaxDistance(HerdJapanID, rmXFractionToMeters(0.08));
	rmAddGroupingConstraint(HerdJapanID, avoidSeaShort);
	rmPlaceObjectDefAtLoc(HerdJapanID, 0, 0.13, 0.48, 1);

	int Tree2JapanID = rmCreateObjectDef("Tree2Japan");
	rmAddObjectDefItem(Tree2JapanID, "ypTreeCoastalJapan", TreeCount2, 15.0);
	rmSetObjectDefMinDistance(Tree2JapanID, 0.0);
	rmSetObjectDefMaxDistance(Tree2JapanID, rmXFractionToMeters(0.15));
	rmAddGroupingConstraint(Tree2JapanID, avoidSeaShort);
	rmPlaceObjectDefAtLoc(Tree2JapanID, 0, 0.86, 0.69, 1);

	int Herd2JapanID = rmCreateObjectDef("Herd2Japan");
	rmAddObjectDefItem(Herd2JapanID, "ypGiantSalamander", 6, 8.0);
	rmSetObjectDefMinDistance(Herd2JapanID, 0.0);
	rmSetObjectDefMaxDistance(Herd2JapanID, rmXFractionToMeters(0.15));
	rmAddGroupingConstraint(Herd2JapanID, avoidSeaShort);
	rmPlaceObjectDefAtLoc(Herd2JapanID, 0, 0.86, 0.69, 1);
*/
	// *******************************************************************************************************

	// *********************************************** Forest ************************************************

	int dirtforestcount = ((cNumberNonGaiaPlayers - ObsUIPlayer) * 8);
	int greenforestcount = ((cNumberNonGaiaPlayers - ObsUIPlayer) * 12);
	int dirtforesttreecount = rmRandInt(5,6);
	
	// Green forests big

	
	// Green forests small
	for (i=1; < greenforestcount)
	{


			int greenforesttreeID = rmCreateObjectDef("dirt forest trees"+i);
			rmAddObjectDefItem(greenforesttreeID, "ypTreeYellowRiver", 9, 6.0);
			rmSetObjectDefMinDistance(greenforesttreeID,  rmXFractionToMeters(0.0));
			rmSetObjectDefMaxDistance(greenforesttreeID,  rmXFractionToMeters(0.5));
			rmAddObjectDefToClass(greenforesttreeID, classForest);
		//	rmAddObjectDefConstraint(greenforesttreeID, avoidForestShort);
			rmAddObjectDefConstraint(greenforesttreeID, avoidImpassableLandShort);
			rmAddAreaConstraint(greenforesttreeID, avoidJapan);
			rmAddAreaConstraint(greenforesttreeID, avoidTree);
			rmAddAreaConstraint(greenforesttreeID, avoidBuilding);
			rmAddAreaConstraint(greenforesttreeID, avoidTownCenterResourcesshort);
			rmAddAreaConstraint(greenforesttreeID, avoidCoveredWagon);
			rmPlaceObjectDefAtLoc(greenforesttreeID, 0, 0.50, 0.50,7);
	}
			

	for (i=1; < greenforestcount)
	{
			int dirtforesttreeID = rmCreateObjectDef("dirt forest trees"+i);
			rmAddObjectDefItem(dirtforesttreeID, "ypTreeBamboo", 14, 2.0);
			rmSetObjectDefMinDistance(dirtforesttreeID,  rmXFractionToMeters(0.0));
			rmSetObjectDefMaxDistance(dirtforesttreeID,  rmXFractionToMeters(0.5));
			rmAddObjectDefToClass(dirtforesttreeID, classForest);
		//	rmAddObjectDefConstraint(dirtforesttreeID, avoidForestShort);
			rmAddObjectDefConstraint(dirtforesttreeID, avoidImpassableLandShort);
			rmAddAreaConstraint(dirtforesttreeID, avoidJapan);
			rmAddAreaConstraint(dirtforesttreeID, avoidTree);
			rmAddAreaConstraint(dirtforesttreeID, avoidBuilding);
			rmAddAreaConstraint(dirtforesttreeID, avoidTownCenterResourcesshort);
			rmAddAreaConstraint(dirtforesttreeID, avoidCoveredWagon);
			rmPlaceObjectDefAtLoc(dirtforesttreeID, 0, 0.50, 0.50,5);
	}

	// *******************************************************************************************************

	// Text
	rmSetStatusText("",0.45);

	// ************************************************ Herd *************************************************

	int herdcount = ((cNumberPlayers*2) - ObsUIPlayer);
	
	for(i=0; < herdcount)
	{
	
		//Ibex
		int IbexID = rmCreateObjectDef("Ibex"+i);
		rmAddObjectDefItem(IbexID, "ypIbex", rmRandInt(11,11), 10.0);
		rmSetObjectDefMinDistance(IbexID, rmXFractionToMeters(0.0));
		rmSetObjectDefMaxDistance(IbexID, rmXFractionToMeters(0.5));
		rmSetObjectDefCreateHerd(IbexID, true);
		rmAddObjectDefConstraint(IbexID, avoidImpassableLandShort);
		rmAddObjectDefConstraint(IbexID, avoidNativesShort);
		rmAddObjectDefConstraint(IbexID, avoidTradeRouteSocket);
		rmAddObjectDefConstraint(IbexID, avoidGoldMin);
		rmAddObjectDefConstraint(IbexID, avoidForestMin); 
		rmAddObjectDefConstraint(IbexID, avoidTownCenterFar);
		rmAddObjectDefConstraint(IbexID, avoidSaigaFar); 
		rmAddObjectDefConstraint(IbexID, avoidMarcoPoloSheepFar); 
		rmAddObjectDefConstraint(IbexID, avoidIbexFar); 
		rmAddObjectDefConstraint(IbexID, avoidSerowFar); 
		rmAddObjectDefConstraint(IbexID, avoidJapan); 
		rmAddObjectDefConstraint(IbexID, avoidTaiwan); 
	//	rmAddObjectDefConstraint(IbexID, avoidEdge);
		
		//Serow
		int SerowID = rmCreateObjectDef("Serow"+i);
		rmAddObjectDefItem(SerowID, "ypSerow", rmRandInt(8,8), 8.0);
		rmSetObjectDefMinDistance(SerowID, rmXFractionToMeters(0.0));
		rmSetObjectDefMaxDistance(SerowID, rmXFractionToMeters(0.5));
		rmSetObjectDefCreateHerd(SerowID, true);
		rmAddObjectDefConstraint(SerowID, avoidImpassableLandShort);
		rmAddObjectDefConstraint(SerowID, avoidNativesShort);
		rmAddObjectDefConstraint(SerowID, avoidTradeRouteSocket);
		rmAddObjectDefConstraint(SerowID, avoidGoldMin);
		rmAddObjectDefConstraint(SerowID, avoidForestMin);
		rmAddObjectDefConstraint(SerowID, avoidTownCenterFar);
		rmAddObjectDefConstraint(SerowID, avoidSaigaFar); 
		rmAddObjectDefConstraint(SerowID, avoidMarcoPoloSheepFar); 
		rmAddObjectDefConstraint(SerowID, avoidIbexFar); 
		rmAddObjectDefConstraint(SerowID, avoidSerowFar); 
		rmAddObjectDefConstraint(SerowID, avoidJapan); 
		rmAddObjectDefConstraint(SerowID, avoidTaiwan); 
	//	rmAddObjectDefConstraint(SerowID, avoidEdge);

		if (i == 0 )
		{
			rmAddObjectDefConstraint(IbexID, staySWHalf);
			rmAddObjectDefConstraint(SerowID, staySWHalf);
		}
		else if (i == 1)
		{
			rmAddObjectDefConstraint(IbexID, stayNEHalf);
			rmAddObjectDefConstraint(SerowID, stayNEHalf);
		}
		if (i < 2)
			rmPlaceObjectDefAtLoc(IbexID, 0, 0.50, 0.50);
		rmPlaceObjectDefAtLoc(IbexID, 0, 0.50, 0.50);
		rmPlaceObjectDefAtLoc(SerowID, 0, 0.50, 0.50);
	}
	
	// *******************************************************************************************************
	
	// Text
	rmSetStatusText("",0.46);

	// ********************************************** Treasure ***********************************************
	
	int nuggetLV4count = ((cNumberPlayers-ObsUIPlayer)*3);
	int nuggetLV3count = ((cNumberNonGaiaPlayers-ObsUIPlayer) * 4);
	int nuggetLV2count = ((cNumberNonGaiaPlayers-ObsUIPlayer) * 7);
	
	// Treasures center	

	int Nugget4ID = rmCreateObjectDef("nugget4"); 
	rmAddObjectDefItem(Nugget4ID, "Nugget", 1, 0.0);
	rmSetObjectDefMinDistance(Nugget4ID, 0);
	rmSetObjectDefMaxDistance(Nugget4ID, rmXFractionToMeters(0.6));
	rmAddObjectDefConstraint(Nugget4ID, avoidNuggetFar);
	rmAddObjectDefConstraint(Nugget4ID, avoidNatives);
	rmAddObjectDefConstraint(Nugget4ID, avoidTradeRouteShort);
	rmAddObjectDefConstraint(Nugget4ID, avoidTradeRouteSocket);
	rmAddObjectDefConstraint(Nugget4ID, avoidImpassableLand);
	rmAddObjectDefConstraint(Nugget4ID, avoidGoldTypeMin);
	rmAddObjectDefConstraint(Nugget4ID, avoidTownCenterFar);
	rmAddObjectDefConstraint(Nugget4ID, avoidSaigaMin); 
	rmAddObjectDefConstraint(Nugget4ID, avoidMarcoPoloSheepMin);
	rmAddObjectDefConstraint(Nugget4ID, avoidIbexMin); 
	rmAddObjectDefConstraint(Nugget4ID, avoidSerowMin);
	rmAddObjectDefConstraint(Nugget4ID, avoidForestMin);	
	rmAddObjectDefConstraint(Nugget4ID, avoidEdgeMore);
		
	for (i=0; <= nuggetLV4count)
	{
	rmSetNuggetDifficulty(4,4);
	rmPlaceObjectDefAtLoc(Nugget4ID, 0, 0.50, 0.50);
	}

	int HardID = rmCreateObjectDef("nugget3"); 
	rmAddObjectDefItem(HardID, "Nugget", 1, 0.0);
	rmSetObjectDefMinDistance(HardID, 0);
	rmSetObjectDefMaxDistance(HardID, rmXFractionToMeters(0.6));
	rmAddObjectDefConstraint(HardID, avoidNuggetShort);
	rmAddObjectDefConstraint(HardID, avoidNatives);
	rmAddObjectDefConstraint(HardID, avoidTradeRouteShort);
	rmAddObjectDefConstraint(HardID, avoidTradeRouteSocket);
	rmAddObjectDefConstraint(HardID, avoidImpassableLand);
	rmAddObjectDefConstraint(HardID, avoidGoldTypeMin);
	rmAddObjectDefConstraint(HardID, avoidTownCenterFar);
	rmAddObjectDefConstraint(HardID, avoidSaigaMin); 
	rmAddObjectDefConstraint(HardID, avoidMarcoPoloSheepMin);
	rmAddObjectDefConstraint(HardID, avoidIbexMin); 
	rmAddObjectDefConstraint(HardID, avoidSerowMin);
	rmAddObjectDefConstraint(HardID, avoidForestMin);	
	rmAddObjectDefConstraint(HardID, avoidEdgeMore);
		
	for (i=0; <= nuggetLV3count)
	{
	rmSetNuggetDifficulty(3,3);
	rmPlaceObjectDefAtLoc(HardID, 0, 0.50, 0.50);
	}

	int NuggetID = rmCreateObjectDef("nugget2"); 
	rmAddObjectDefItem(NuggetID, "Nugget", 1, 0.0);
	rmSetObjectDefMinDistance(NuggetID, 0);
	rmSetObjectDefMaxDistance(NuggetID, rmXFractionToMeters(0.6));
	rmAddObjectDefConstraint(NuggetID, avoidNugget);
	rmAddObjectDefConstraint(NuggetID, avoidNatives);
	rmAddObjectDefConstraint(NuggetID, avoidTradeRouteShort);
	rmAddObjectDefConstraint(NuggetID, avoidTradeRouteSocket);
	rmAddObjectDefConstraint(NuggetID, avoidImpassableLand);
	rmAddObjectDefConstraint(NuggetID, avoidGoldTypeMin);
	rmAddObjectDefConstraint(NuggetID, avoidTownCenterFar);
	rmAddObjectDefConstraint(NuggetID, avoidSaigaMin); 
	rmAddObjectDefConstraint(NuggetID, avoidMarcoPoloSheepMin);
	rmAddObjectDefConstraint(NuggetID, avoidIbexMin); 
	rmAddObjectDefConstraint(NuggetID, avoidSerowMin);
	rmAddObjectDefConstraint(NuggetID, avoidForestMin);	
	rmAddObjectDefConstraint(NuggetID, avoidEdgeMore);
		
	for (i=0; <= nuggetLV2count)
	{
	rmSetNuggetDifficulty(2,2);
	rmPlaceObjectDefAtLoc(NuggetID, 0, 0.50, 0.50);
	}

	// *******************************************************************************************************
	

	// Text
	rmSetStatusText("",0.48);
	// ******************************************* Sea Resource ********************************************
	int FishSalmoncount = (cNumberPlayers - ObsUIPlayer) * 10;
	int FishSardinecount = (cNumberPlayers - ObsUIPlayer) * 10;
	int waternuggetcount = (cNumberNonGaiaPlayers - ObsUIPlayer) * 8;
	int whalecount = (((cNumberNonGaiaPlayers - ObsUIPlayer) * 7) + rmRandInt(8,9));
	int Junkcount = (cNumberNonGaiaPlayers - ObsUIPlayer);
	if (cNumberNonGaiaPlayers ==3) Junkcount = (cNumberNonGaiaPlayers - ObsUIPlayer +1);
	if (cNumberNonGaiaPlayers ==4) Junkcount = (cNumberPlayers - ObsUIPlayer);
	if (cNumberNonGaiaPlayers >=5) Junkcount = (cNumberNonGaiaPlayers - ObsUIPlayer -1);
	int RandomJunk = rmRandInt(0,1);

	int waterSpawnPointID = rmCreateObjectDef("Flag");
	rmAddObjectDefItem(waterSpawnPointID, "HomeCityWaterSpawnFlag", 1, 0.0);
	rmAddClosestPointConstraint(flagVsFlag);
	rmAddClosestPointConstraint(flagLand);
//	rmAddClosestPointConstraint(flagEdgeConstraint);

	// Text
	rmSetStatusText("",0.50);

	for(i=1; <cNumberPlayers - ObsUIPlayer)
	{
/*
	int ShipsID = rmCreateObjectDef("Ships"+i);
	if (rmGetPlayerCiv(i) <= 13 && rmGetPlayerCiv(i) != 8)
		{
		rmAddObjectDefItem(ShipsID,"Caravel", 1, 0.0);
		}
	else if (rmGetPlayerCiv(i) == 8)
		{
		rmAddObjectDefItem(ShipsID,"Galley", 1, 0.0);
		}
	else if (rmGetPlayerCiv(i) >= 14 && rmGetPlayerCiv(i) <= 17)
		{
		rmAddObjectDefItem(ShipsID,"xpWarCanoe", 1, 0.0);
		rmAddObjectDefItem(ShipsID,"Canoe", 1, 10.0);
		}
	else if (rmGetPlayerCiv(i) == 19 || rmGetPlayerCiv(i) == 22 || rmGetPlayerCiv(i) == 26)
		{
		rmAddObjectDefItem(ShipsID,"ypFune", 1, 0.0);
		}
	else if (rmGetPlayerCiv(i) == 20 || rmGetPlayerCiv(i) == 23)
		{
		rmAddObjectDefItem(ShipsID,"ypWarJunk", 1, 0.0);
		}
	else
		{
		rmAddObjectDefItem(ShipsID, "Caravel", 1, 0.0);
		}
	rmAddClosestPointConstraint(shipsVsFlag);
	rmAddClosestPointConstraint(flagLand);
*/
	vector TCLocation = rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, i));
	vector closestPoint = rmFindClosestPointVector(TCLocation, rmXFractionToMeters(1.0));
	rmPlaceObjectDefAtLoc(waterSpawnPointID, i, rmXMetersToFraction(xsVectorGetX(closestPoint)), rmZMetersToFraction(xsVectorGetZ(closestPoint)));
//	rmPlaceObjectDefAtLoc(ShipsID, i, rmXMetersToFraction(xsVectorGetX(closestPoint)), rmZMetersToFraction(xsVectorGetZ(closestPoint)));

	}
		rmClearClosestPointConstraints();

	int Fisch1=rmCreateObjectDef("Fish 1");
	rmAddObjectDefItem(Fisch1, "FishSalmon", 1, 0.0);
	rmSetObjectDefMinDistance(Fisch1, 0.3);
	rmSetObjectDefMaxDistance(Fisch1, rmXFractionToMeters(0.5));
	rmAddObjectDefConstraint(Fisch1, avoidFish);
	rmAddObjectDefConstraint(Fisch1, avoidFishLand);
	rmPlaceObjectDefAtLoc(Fisch1, 0, 0.5, 0.5, FishSalmoncount);

	int Fisch2=rmCreateObjectDef("Fish 2");
	rmAddObjectDefItem(Fisch2, "FishSardine", 1, 0.0);
	rmSetObjectDefMinDistance(Fisch2, 0.3);
	rmSetObjectDefMaxDistance(Fisch2, rmXFractionToMeters(0.5));
	rmAddObjectDefConstraint(Fisch2, avoidFish);
	rmAddObjectDefConstraint(Fisch2, avoidFishLand);
	rmPlaceObjectDefAtLoc(Fisch2, 0, 0.5, 0.5, FishSardinecount);

	int nuggetW= rmCreateObjectDef("nugget water"); 
	rmAddObjectDefItem(nuggetW, "ypNuggetBoat", 1, 0.0);
	rmSetNuggetDifficulty(5, 5);
	rmSetObjectDefMinDistance(nuggetW, rmXFractionToMeters(0.0));
	rmSetObjectDefMaxDistance(nuggetW, rmXFractionToMeters(0.5));
	rmAddObjectDefConstraint(nuggetW, nuggetVsFlag);
	rmAddObjectDefConstraint(nuggetW, avoidLand);
	rmAddObjectDefConstraint(nuggetW, avoidNuggetWater);
	rmPlaceObjectDefAtLoc(nuggetW, 0, 0.5, 0.5, waternuggetcount);

	int whaleID=rmCreateObjectDef("whale");
	rmAddObjectDefItem(whaleID, "HumpbackWhale", 1, 0.0);
	rmSetObjectDefMinDistance(whaleID, 0.0);
	rmSetObjectDefMaxDistance(whaleID, rmXFractionToMeters(0.5));
	rmAddObjectDefConstraint(whaleID, whaleVsWhaleID);
	rmAddObjectDefConstraint(whaleID, whaleLand);
	rmPlaceObjectDefAtLoc(whaleID, 0, 0.5, 0.5, whalecount);

	if (RandomJunk == 1)
	{
	}
	int PrivateerID=rmCreateObjectDef("PrivateerShip");
	rmAddObjectDefItem(PrivateerID, "Privateer", 1, 0.0);
	rmSetObjectDefMinDistance(PrivateerID, 0.0);
	rmSetObjectDefMaxDistance(PrivateerID, rmXFractionToMeters(0.5));
	rmAddObjectDefConstraint(PrivateerID, ShipVsFlag);
	rmAddObjectDefConstraint(PrivateerID, avoidLand);
	rmAddObjectDefConstraint(PrivateerID, avoidJunk);
	rmAddObjectDefConstraint(PrivateerID, avoidPrivateer);
	rmAddObjectDefConstraint(PrivateerID, avoidFune);
//	rmAddObjectDefConstraint(PrivateerID, avoidWaterNugget);
	rmPlaceObjectDefAtLoc(PrivateerID, 0, 0.5, 0.5, Junkcount);

	int JunkID=rmCreateObjectDef("Junk");
	rmAddObjectDefItem(JunkID, "ypWarJunk", 1, 0.0);
	rmSetObjectDefMinDistance(JunkID, 0.0);
	rmSetObjectDefMaxDistance(JunkID, rmXFractionToMeters(0.5));
	rmAddObjectDefConstraint(JunkID, ShipVsFlag);
	rmAddObjectDefConstraint(JunkID, avoidLand);
	rmAddObjectDefConstraint(JunkID, avoidJunk);
	rmAddObjectDefConstraint(JunkID, avoidPrivateer);
	rmAddObjectDefConstraint(JunkID, avoidFune);
//	rmAddObjectDefConstraint(JunkID, avoidWaterNugget);
	rmPlaceObjectDefAtLoc(JunkID, 0, 0.5, 0.5, Junkcount);

	int FuneID=rmCreateObjectDef("Fune");
	rmAddObjectDefItem(FuneID, "ypFune", 1, 0.0);
	rmSetObjectDefMinDistance(FuneID, 0.0);
	rmSetObjectDefMaxDistance(FuneID, rmXFractionToMeters(0.5));
	rmAddObjectDefConstraint(FuneID, ShipVsFlag);
	rmAddObjectDefConstraint(FuneID, avoidLand);
	rmAddObjectDefConstraint(FuneID, avoidJunk);
	rmAddObjectDefConstraint(FuneID, avoidPrivateer);
	rmAddObjectDefConstraint(FuneID, avoidFune);
//	rmAddObjectDefConstraint(FuneID, avoidWaterNugget);
	rmPlaceObjectDefAtLoc(FuneID, 0, 0.5, 0.5, Junkcount);

	// *****************************************************************************************************

	// Text
	rmSetStatusText("",0.60);


	// ****************************************** Additional Trigger ******************************************
	// SunBaili:QQ1191982435                                                 E-mail:[email protected]


   rmCreateTrigger("BuildLimit");
   rmSwitchToTrigger(rmTriggerID("BuildLimit"));
   rmSetTriggerPriority(3); 
   rmSetTriggerActive(true);
   rmSetTriggerRunImmediately(false);
   rmSetTriggerLoop(false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypCastle", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Outpost", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Blockhouse", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "WarHut", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "YPOutpostAsian", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypCastle", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Outpost", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Blockhouse", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "WarHut", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "YPOutpostAsian", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Caravel", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "30", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galley", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "30", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Canoe", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "60", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFune", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "30", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypWarJunk", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "30", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Caravel", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "30", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galley", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "30", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Canoe", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "60", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFune", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "30", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypWarJunk", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "30", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Monitor", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "5", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galleon", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "5", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Fluyt", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "5", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Frigate", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "5", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFuchuan", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "5", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypAtakabune", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "5", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypTekkousen", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "5", false);
   
   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Fluyt", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Monitor", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galleon", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Frigate", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFuchuan", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypAtakabune", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypTekkousen", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "20", false);

   rmCreateTrigger("Cost Coin 1");
   rmSwitchToTrigger(rmTriggerID("Cost Coin 1"));
   rmSetTriggerPriority(3); 
   rmSetTriggerActive(true);
   rmSetTriggerRunImmediately(false);
   rmSetTriggerLoop(false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Caravel", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galley", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Canoe", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-60", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFune", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypWarJunk", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Fluyt", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Monitor", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galleon", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-400", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Frigate", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-350", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFuchuan", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypAtakabune", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypTekkousen", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-350", false);

   rmCreateTrigger("Cost Wood 1");
   rmSwitchToTrigger(rmTriggerID("Cost Wood 1"));
   rmSetTriggerPriority(3); 
   rmSetTriggerActive(true);
   rmSetTriggerRunImmediately(false);
   rmSetTriggerLoop(false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Caravel", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-250", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galley", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-250", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFune", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-250", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypWarJunk", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-250", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Fluyt", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Monitor", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-650", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galleon", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "Frigate", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-350", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFuchuan", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-650", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypAtakabune", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 1, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypTekkousen", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-350", false);

   rmCreateTrigger("Cost Coin");
   rmSwitchToTrigger(rmTriggerID("Cost Coin"));
   rmSetTriggerPriority(3); 
   rmSetTriggerActive(true);
   rmSetTriggerRunImmediately(false);
   rmSetTriggerLoop(false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Caravel", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galley", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Canoe", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-60", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFune", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypWarJunk", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Fluyt", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Monitor", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galleon", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-400", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Frigate", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-350", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFuchuan", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-50", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypAtakabune", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypTekkousen", false);
   rmSetTriggerEffectParam("Field", "15", false);
   rmSetTriggerEffectParam("Delta", "-350", false);

   rmCreateTrigger("Cost Wood");
   rmSwitchToTrigger(rmTriggerID("Cost Wood"));
   rmSetTriggerPriority(3); 
   rmSetTriggerActive(true);
   rmSetTriggerRunImmediately(false);
   rmSetTriggerLoop(false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Caravel", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-250", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galley", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-250", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFune", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-250", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypWarJunk", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-250", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Fluyt", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Monitor", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-650", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galleon", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "Frigate", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-350", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFuchuan", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-650", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypAtakabune", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-200", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", 2, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypTekkousen", false);
   rmSetTriggerEffectParam("Field", "16", false);
   rmSetTriggerEffectParam("Delta", "-350", false);
/*  
    rmCreateTrigger("Gun1");
    rmSwitchToTrigger(rmTriggerID("Gun1"));
    rmSetTriggerPriority(3); 
    rmSetTriggerActive(true);
    rmSetTriggerRunImmediately(true);
    rmSetTriggerLoop(false);
      
    rmAddTriggerCondition("Units Owned");
    rmSetTriggerConditionParamInt("SrcObject", GunSelect1, false);
    rmSetTriggerConditionParamInt("Player", randomplayer, false);
    
    rmAddTriggerEffect("Grant Resources");
    rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
    rmSetTriggerEffectParam("ResName", "Gold", false);
    rmSetTriggerEffectParam("Amount", "1000", false);

    rmCreateTrigger("Gun2");
    rmSwitchToTrigger(rmTriggerID("Gun2"));
    rmSetTriggerPriority(3); 
    rmSetTriggerActive(true);
    rmSetTriggerRunImmediately(true);
    rmSetTriggerLoop(false);
      
    rmAddTriggerCondition("Units Owned");
    rmSetTriggerConditionParamInt("SrcObject", GunSelect2, false);
    rmSetTriggerConditionParamInt("Player", randomplayer, false);
    
    rmAddTriggerEffect("Grant Resources");
    rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
    rmSetTriggerEffectParam("ResName", "Gold", false);
    rmSetTriggerEffectParam("Amount", "1000", false);
//    rmAddTriggerEffect("Fire Event");		//Test
//    rmSetTriggerEffectParamInt("EventID",rmTriggerID("AIStartAttackII"));	//Test, The RM Trigger can't open C++ Trigger.
//    xsEnableRule("_AIStartAttackII");	//Test
*/
    rmCreateTrigger("Dock");
    rmSwitchToTrigger(rmTriggerID("Dock"));
    rmSetTriggerPriority(3); 
    rmSetTriggerActive(true);
    rmSetTriggerRunImmediately(true);
    rmSetTriggerLoop(false);
      
    rmAddTriggerCondition("Is Dead");
    rmSetTriggerConditionParamInt("SrcObject", DockSelect, false);
    
   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Monitor", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "15", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Galleon", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "15", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Fluyt", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "15", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "Frigate", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "15", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypFuchuan", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "15", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypAtakabune", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "15", false);

   rmAddTriggerEffect("Modify Protounit");
   rmSetTriggerEffectParamInt("PlayerID", randomplayer, false);
   rmSetTriggerEffectParam("ProtoUnit", "ypTekkousen", false);
   rmSetTriggerEffectParam("Field", "10", false);
   rmSetTriggerEffectParam("Delta", "15", false);

    rmCreateTrigger("Cache");
    rmSwitchToTrigger(rmTriggerID("Cache"));
    rmSetTriggerPriority(3); 
    rmSetTriggerActive(true);
    rmSetTriggerRunImmediately(true);
    rmSetTriggerLoop(false);
      
    rmAddTriggerCondition("Is Dead");
    rmSetTriggerConditionParamInt("SrcObject", CacheSelect, false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);
    
   rmAddTriggerEffect("Tribute");
   rmSetTriggerEffectParamInt("FromPlayerID", randomplayer, false);
   rmSetTriggerEffectParamInt("ToPlayerID", 3-randomplayer, false);
   rmSetTriggerEffectParam("ResName", "food", false);
   rmSetTriggerEffectParam("Amount", "200", false);

    rmCreateTrigger("Resource");
    rmSwitchToTrigger(rmTriggerID("Resource"));
    rmSetTriggerPriority(3); 
    rmSetTriggerActive(true);
    rmSetTriggerRunImmediately(true);
    rmSetTriggerLoop(false);
          
	for(i=1;<=cNumberNonGaiaPlayers)
	{
    rmAddTriggerEffect("Grant Resources");
    rmSetTriggerEffectParamInt("PlayerID", i, false);
    rmSetTriggerEffectParam("ResName", "Gold", false);
    rmSetTriggerEffectParam("Amount", "1000", false);
    rmAddTriggerEffect("Grant Resources");
    rmSetTriggerEffectParamInt("PlayerID", i, false);
    rmSetTriggerEffectParam("ResName", "Wood", false);
    rmSetTriggerEffectParam("Amount", "1000", false);
    rmAddTriggerEffect("Grant Resources");
    rmSetTriggerEffectParamInt("PlayerID", i, false);
    rmSetTriggerEffectParam("ResName", "Food", false);
    rmSetTriggerEffectParam("Amount", "1000", false);
	}
	// ****************************************** Advance Trigger ******************************************
	// 	QQ Group1:85442352	QQ Group2:456359856	E-mail:[email protected]

	int PlayerType = rmRandInt(1,2);
	int Chi2 = rmRandInt(3,4);

	// ***************************************** Installation Path *****************************************

	rmCreateTrigger("GameStart");
	rmSetTriggerRunImmediately(true);
	rmSetTriggerPriority(5);
	rmSetTriggerEffectParam("IdleProc","true);trQuestVarSet(\"Path\",1);xsDisableSelf();}}/*");
	rmCreateTrigger("Path	active	runImmediately{if(trQuestVarGet(\"Path\")!=1){"+"showSPCNote(\"Error!\",\"<color=0,255,255>Use-the-English-path-to-install-the-Age-of-Empires-III,please.\");"+"uiMessageBox2(20948);trEndGame();trYouWin(true);xsDisableRule(\"_Path\");}}/*");
	rmSetTriggerActive(false);
	rmSetTriggerPriority(5);

	rmCreateTrigger("GamestartInit");
	rmSwitchToTrigger(rmTriggerID("GamestartInit"));
	rmSetTriggerRunImmediately(true);
	oxyA("}}");

	// ********************************************** Trigger **********************************************

	// Text
	rmSetStatusText("",0.70);

	oxy("rule _0start active runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 1.00000000){");
	oxy("trSetLighting(\"spcCC5b\", 420.00000000);");
	oxy("xsDisableRule(\"_0start\");");
	oxy("xsEnableRule(\"_revolutionLighting\");");
	oxyZ("}} /*");

	oxy("rule _revolutionLighting inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 419.00000000){");
	oxy("trSetLighting(\"hc_revolution\", 250.00000000);");
	oxy("xsDisableRule(\"_revolutionLighting\");");
	oxy("xsEnableRule(\"_6lISBOM\");");
	oxyZ("}} /*");

	oxy("rule _6lISBOM inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 250.00000000){");
	oxy("trSetLighting(\"Lisbon Storm\", 50.00000000);");
	oxy("xsDisableRule(\"_6lISBOM\");");
	oxy("xsEnableRule(\"_7spcJC4aflashback\");");
	oxyZ("}} /*");

	oxy("rule _7spcJC4aflashback inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 50.00000000){");
	oxy("trSetLighting(\"spcJC4aflashback\", 120.00000000);");
	oxy("xsDisableRule(\"_7spcJC4aflashback\");");
	oxy("xsEnableRule(\"_8minescent\");");
	oxyZ("}} /*");

	oxy("rule _8minescent inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 420.00000000){");
	oxy("trSetLighting(\"minescene\", 300.00000000);");
	oxy("xsDisableRule(\"_8minescent\");");
	oxy("xsEnableRule(\"_1start\");");
	oxyZ("}} /*");

	oxy("rule _1start inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 300.00000000){");
	oxy("trSetLighting(\"New England Start\", 130.00000000);");
	oxy("xsDisableRule(\"_1start\");");
	oxy("xsEnableRule(\"_2start\");");
	oxyZ("}} /*");

	oxy("rule _2start inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 130.00000000){");
		If ( PlayerType == 1 )
			{
			oxy("trSetLighting(\"yellow_river\", 140.00000000);");
			}
		If ( PlayerType == 2 )
			{
			oxy("trSetLighting(\"yukon\", 140.00000000);");
			}
	oxy("xsDisableRule(\"_2start\");");
	oxy("xsEnableRule(\"_3patagonia\");");
	oxyZ("}} /*");

	oxy("rule _3patagonia inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 140.00000000){");
	oxy("trSetLighting(\"spcCC5b\", 150.00000000);");
	oxy("xsDisableRule(\"_3patagonia\");");
	oxy("xsEnableRule(\"_4hcrevolution4\");");
	oxyZ("}} /*");

	oxy("rule _4hcrevolution4 inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 150.00000000){");
	oxy("trSetLighting(\"hc_revolution\", 250.00000000);");
	oxy("xsDisableRule(\"_4hcrevolution4\");");
	oxy("xsEnableRule(\"_6lISBOM\");");
	oxyZ("}} /*");

	// Text
	rmSetStatusText("",0.80);

	//This Map Trigger
	oxy("rule _StartTech active runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 1.00000000){");
	oxy("trModifyProtounit(\"IGCTownCenter\", 0, 2, -34);");
	oxy("trModifyProtounit(\"Privateer\", 0, 0, -500);");
	oxy("trModifyProtounit(\"ypWarJunk\", 0, 0, -400);");
	oxy("trModifyProtounit(\"ypFune\", 0, 0, -400);");
	oxy("trModifyProtounit(\"Privateer\", 0, 2, -13);");
	oxy("trModifyProtounit(\"ypJunk\", 0, 2, -6);");
	oxy("trModifyProtounit(\"ypWarJunk\", 0, 2, -7);");
	oxy("trModifyProtounit(\"ypFune\", 0, 2, -7);");
	oxy("trModifyProtounit(\"ypCatamaran\", 0, 2, -2);");
	oxy("trModifyProtounit(\"Explorer\", 0, 0, -400);");
	oxy("trModifyProtounit(\"Explorer\", 0, 0, 400);");
	//Explorer Nugget
		for(p=1;<=cNumberNonGaiaPlayers)
		{
		oxy("trTechSetStatus("+p+", 351, 0);");
		oxy("trTechSetStatus("+p+", 864, 0);");
		oxy("trTechSetStatus("+p+", 446, 0);");
		oxy("trTechSetStatus("+p+", 1539, 0);");
			if ( Chi2 == 4 )
				{
				oxy("trUnforbidProtounit("+p+",\"MercManchu\");");
				oxy("trUnforbidProtounit("+p+",\"ypRepentantManchu\");");
				oxy("trUnforbidProtounit("+p+",\"ypWokouBlindMonk\");");
				oxy("trUnforbidProtounit("+p+",\"ypRepentantBlindMonk\");");
				}
			if ( Chi2 == 3 )
				{
				oxy("trUnforbidProtounit("+p+",\"MercNinja\");");
				oxy("trUnforbidProtounit("+p+",\"ypRepentantNinja\");");
				oxy("trUnforbidProtounit("+p+",\"ypWokouPirate\");");
				oxy("trUnforbidProtounit("+p+",\"ypRepentantSmuggler\");");
				}
			if (rmGetPlayerCiv(p) == 11)
				{
				oxy("trUnforbidProtounit("+p+",\"xpColonialMilitia\");");
				oxy("trUnforbidProtounit("+p+",\"xpGatlingGun\");");
				oxy("trModifyProtounit(\"SPCAmelia\", "+p+", 0, -650);");
				oxy("trModifyProtounit(\"SPCCooper\", "+p+", 0, -700);");
				}
			if (rmGetPlayerCiv(p) == 18)
				{
				oxy("trPlayerOverrideArtCulture("+p+",\"WesternEurope\");");
				oxy("trTechSetStatus("+p+", 72, 2);");
				oxy("trTechSetStatus("+p+", 1572, 2);");
				oxy("trTechSetStatus("+p+", 1384, 0);");
				oxy("trTechSetStatus("+p+", 1385, 0);");
				oxy("trTechSetStatus("+p+", 1386, 0);");
				oxy("trTechSetStatus("+p+", 1520, 1);");
				oxy("trTechSetStatus("+p+", 409, 1);");
				oxy("trTechSetStatus("+p+", 449, 1);");
				oxy("trTechSetStatus("+p+", 260, 1);");
				oxy("trTechSetStatus("+p+", 264, 1);");
				oxy("trTechSetStatus("+p+", 450, 1);");
				oxy("trTechSetStatus("+p+", 269, 1);");
				oxy("trTechSetStatus("+p+", 270, 1);");
				oxy("trTechSetStatus("+p+", 275, 1);");
				oxy("trTechSetStatus("+p+", 300, 1);");
				oxy("trTechSetStatus("+p+", 461, 1);");
				oxy("trTechSetStatus("+p+", 464, 1);");
				oxy("trTechSetStatus("+p+", 522, 1);");
				oxy("trTechSetStatus("+p+", 523, 1);");
				oxy("trTechSetStatus("+p+", 537, 1);");
				oxy("trTechSetStatus("+p+", 579, 1);");
				oxy("trTechSetStatus("+p+", 665, 1);");
				oxy("trTechSetStatus("+p+", 1098, 1);");
				oxy("trTechSetStatus("+p+", 1099, 1);");
				oxy("trTechSetStatus("+p+", 525, 1);");
				oxy("trTechSetStatus("+p+", 527, 1);");
				oxy("trTechSetStatus("+p+", 1426, 1);");
				oxy("trTechSetStatus("+p+", 1427, 1);");
				oxy("trTechSetStatus("+p+", 1108, 1);");
				oxy("trTechSetStatus("+p+", 1116, 1);");
				//oxy("trTechSetStatus("+p+", 1125, 1);");
				oxy("trTechSetStatus("+p+", 1126, 1);");
				oxy("trTechSetStatus("+p+", 1127, 1);");
				oxy("trTechSetStatus("+p+", 278, 1);");
				oxy("trTechSetStatus("+p+", 279, 1);");
				oxy("trTechSetStatus("+p+", 280, 1);");
				oxy("trTechSetStatus("+p+", 281, 1);");
				//oxy("trTechSetStatus("+p+", 282, 1);");
				oxy("trTechSetStatus("+p+", 283, 1);");
				oxy("trTechSetStatus("+p+", 284, 1);");
				//oxy("trTechSetStatus("+p+", 285, 1);");
				//oxy("trTechSetStatus("+p+", 286, 1);");
				oxy("trTechSetStatus("+p+", 287, 1);");
				oxy("trTechSetStatus("+p+", 288, 1);");
				oxy("trTechSetStatus("+p+", 1069, 1);");
				oxy("trTechSetStatus("+p+", 1664, 1);");
				oxy("trTechSetStatus("+p+", 292, 1);");
				oxy("trTechSetStatus("+p+", 341, 1);");
				oxy("trTechSetStatus("+p+", 389, 1);");
				oxy("trTechSetStatus("+p+", 1662, 1);");
				oxy("trTechSetStatus("+p+", 272, 1);");
				oxy("trTechSetStatus("+p+", 407, 1);");
				oxy("trTechSetStatus("+p+", 462, 1);");
				oxy("trTechSetStatus("+p+", 416, 1);");
				oxy("trTechSetStatus("+p+", 417, 1);");
				oxy("trTechSetStatus("+p+", 418, 1);");
				oxy("trTechSetStatus("+p+", 289, 1);");
				oxy("trTechSetStatus("+p+", 290, 1);");
				oxy("trTechSetStatus("+p+", 479, 1);");
				oxy("trTechSetStatus("+p+", 480, 1);");
				oxy("trTechSetStatus("+p+", 428, 1);");
				oxy("trTechSetStatus("+p+", 429, 1);");
				oxy("trTechSetStatus("+p+", 1110, 1);");
				oxy("trTechSetStatus("+p+", 1122, 1);");
				oxy("trTechSetStatus("+p+", 451, 1);");
				oxy("trTechSetStatus("+p+", 505, 1);");
				oxy("trTechSetStatus("+p+", 504, 1);");
				oxy("trTechSetStatus("+p+", 507, 1);");
				oxy("trTechSetStatus("+p+", 506, 1);");
				oxy("trTechSetStatus("+p+", 509, 1);");
				oxy("trTechSetStatus("+p+", 519, 1);");
				oxy("trTechSetStatus("+p+", 520, 1);");
				oxy("trTechSetStatus("+p+", 399, 1);");
				oxy("trTechSetStatus("+p+", 397, 1);");
				oxy("trTechSetStatus("+p+", 398, 1);");
				oxy("trTechSetStatus("+p+", 485, 1);");
				oxy("trTechSetStatus("+p+", 495, 1);");
				oxy("trTechSetStatus("+p+", 400, 1);");
				oxy("trTechSetStatus("+p+", 142, 1);");
				oxy("trTechSetStatus("+p+", 1140, 1);");
				oxy("trTechSetStatus("+p+", 1557, 1);");
				oxy("trTechSetStatus("+p+", 1519, 1);");
				oxy("trTechSetStatus("+p+", 1128, 1);");
				oxy("trTechSetStatus("+p+", 1129, 1);");
				oxy("trTechSetStatus("+p+", 1522, 1);");
				oxy("trTechSetStatus("+p+", 1523, 1);");
				oxy("trForbidProtounit("+p+",\"SettlerNative\");");
				oxy("trForbidProtounit("+p+",\"Corral\");");
				oxy("trUnforbidProtounit("+p+",\"xpColonialMilitia\");");
				oxy("trUnforbidProtounit("+p+",\"xpGatlingGun\");");
				oxy("trUnforbidProtounit("+p+",\"xpSPCColonialMilitia\");");
				oxy("trUnforbidProtounit("+p+",\"Settler\");");
				oxy("trUnforbidProtounit("+p+",\"Factory\");");
				oxy("trUnforbidProtounit("+p+",\"FortFrontier\");");
				oxy("trUnforbidProtounit("+p+",\"SPCXPFortWagon\");");
				oxy("trUnforbidProtounit("+p+",\"Church\");");
				oxy("trUnforbidProtounit("+p+",\"Arsenal\");");
				oxy("trUnforbidProtounit("+p+",\"Sheep\");");
				oxy("trUnforbidProtounit("+p+",\"Stable\");");
				oxy("trUnforbidProtounit("+p+",\"FieldHospital\");");
				oxy("trUnforbidProtounit("+p+",\"Hussar\");");
				oxy("trUnforbidProtounit("+p+",\"WallStraight5\");");
				oxy("trUnforbidProtounit("+p+",\"WallStraight2\");");
				oxy("trUnforbidProtounit("+p+",\"WallConnector\");");
				oxy("trUnforbidProtounit("+p+",\"House\");");
				oxy("trUnforbidProtounit("+p+",\"WallConnector\");");
				oxy("trUnforbidProtounit("+p+",\"Dragoon\");");
				oxy("trUnforbidProtounit("+p+",\"xpTomahawk\");");
				oxy("trUnforbidProtounit("+p+",\"Saloon\");");
				oxy("trUnforbidProtounit("+p+",\"Outpost\");");
				oxy("trUnforbidProtounit("+p+",\"Caravel\");");
				oxy("trUnforbidProtounit("+p+",\"Frigate\");");
				oxy("trUnforbidProtounit("+p+",\"Monitor\");");
				oxy("trUnforbidProtounit("+p+",\"Capitol\");");
				oxy("trUnforbidProtounit("+p+",\"Priest\");");
				oxy("trUnforbidProtounit("+p+",\"Surgeon\");");
				oxy("trUnforbidProtounit("+p+",\"Grenadier\");");
				oxy("trUnforbidProtounit("+p+",\"Falconet\");");
				oxy("trUnforbidProtounit("+p+",\"Culverin\");");
				oxy("trUnforbidProtounit("+p+",\"Mortar\");");
				oxy("trUnforbidProtounit("+p+",\"xpMantlet\");");
				oxy("trUnforbidProtounit("+p+",\"ArtilleryDepot\");");
				oxy("trUnforbidProtounit("+p+",\"xpPetard\");");
				oxy("trModifyProtounit(\"SPCXPWashington\", "+p+", 0, -1050);");
				oxy("trModifyProtounit(\"SPCXPNathaniel\", "+p+", 0, -850);");
				}
		}
	oxy("xsDisableRule(\"_StartTech\");");
	oxyZ("}} /*");

	// Text
	rmSetStatusText("",0.90);

	// *****************************************************************************************************

	// *********************************************** TEST ************************************************

	float Debug1 = rmGetHomeCityLevel(cNumberNonGaiaPlayers);
	oxy("rule _Debug active runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 1.00000000){");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>Debug Mode\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>ObsUIPlayer:<color=0,255,0>"+ObsUIPlayer+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>Breite:<color=0,255,0>"+Breite+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>Breite0:<color=0,255,0>"+Breite2+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>Breite4:<color=0,255,0>"+Breite4+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>Breite7:<color=0,255,0>"+Breite7+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>Chi3:<color=0,255,0>"+Chi3+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>playerTiles:<color=0,255,0>"+playerTiles+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>size=2*sqrt(cNumberNonGaiaPlayers*playerTiles):<color=0,255,0>"+size+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>InvisibleProjectileCount:<color=0,255,0>"+InvisibleProjectileCount+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>InvisibleProjectileDistance:<color=0,255,0>"+InvisibleProjectileDistance+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>PlayerNumType:<color=0,255,0>"+PlayerNumType+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>OneVOnePlacement:<color=0,255,0>"+OneVOnePlacement+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>RandomJunk:<color=0,255,0>"+RandomJunk+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>rmGetHomeCityLevel(Last Player):<color=0,255,0>"+Debug1+"\");");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>Unittype1463:<color=0,255,0>\"+kbGetUnitTypeName(1463));");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>Unittype1480:<color=0,255,0>\"+kbGetUnitTypeName(1480));");
	oxy("trChatSendSpoofed(0,\"<color=0,255,255>Unittype1666:<color=0,255,0>\"+kbGetUnitTypeName(1666));");
	oxy("trChatSendSpoofed(0,\"<color=0,254,0>AGG Map: <color=0,255,0>TaiwanStrait\");");
	oxy("trChatSendSpoofed(0,\"<color=0,254,0>Last modified date : 2018.11.17 00:18:37\n\");");
	oxy("trChatSendSpoofed(0,\"<color=0,254,0>Welcome to our QQ Group.\n        QQ Group1 : 85442352\");");
	if (rmGetNomadStart()!=true)
		{
		for(p=1;<=cNumberNonGaiaPlayers)
			{
			if (rmGetPlayerCiv(p) >= 14 && rmGetPlayerCiv(p) <= 18 )
				{
				oxy("trChatSendToPlayer(0,"+p+",\"{63974}\");");
				}
			else if (rmGetPlayerCiv(p) >= 19 && rmGetPlayerCiv(p) <= 26 )
				{
				oxy("trChatSendToPlayer(0,"+p+",\"{63973}\");");
				}
			else
				{
				oxy("trChatSendToPlayer(0,"+p+",\"{31536}\");");
				}
			}
		}
	oxy("xsDisableRule(\"_Debug\");");
	oxyZ("}} /*");



	oxy("rule _Spy active runImmediately { ");
	oxy("if((trTime()-cActivationTime) == 0.00000000){");
	for(p=1;<=cNumberNonGaiaPlayers)
	{
	oxy("if(kbIsPlayerHuman("+p+") != true){");
	oxy("trTechSetStatus("+p+", 446, 2);");
	oxy("}");
	}
	oxy("xsDisableRule(\"_Spy\");");
	oxyZ("}} /*");

	oxy("rule _SetUnitID active runImmediately { ");
	oxy("for(WarShipsID=3000;>-1){if(kbGetUnitTypeName(WarShipsID) ==\"AbstractWarShip\") Break;}");
	oxy("if((trTime()-cActivationTime) == 0.00000000){");
	oxy("trQuestVarSet(\"cUnittypeAbstractWarShip\",WarShipsID);");
	oxy("xsDisableRule(\"_SetUnitID\");");
	oxyZ("}} /*");

	oxy("rule _Gun1 active runImmediately { ");
	oxy("trUnitSelectClear();");
	oxy("trUnitSelectByID("+rmGetUnitPlaced(GunID, 0)+");");
	oxy("if(trUnitIsOwnedBy("+randomplayer+")){");
	oxy("trPlayerGrantResources("+randomplayer+", \"Gold\", 1000);");
	oxy("xsEnableRule(\"_AIStartAttackII\");");
	oxy("xsDisableRule(\"_Gun1\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _Gun2 active runImmediately { ");
	oxy("trUnitSelectClear();");
	oxy("trUnitSelectByID("+rmGetUnitPlaced(Gun2ID, 0)+");");
	oxy("if(trUnitIsOwnedBy("+randomplayer+")){");
	oxy("trPlayerGrantResources("+randomplayer+", \"Gold\", 1000);");
	oxy("xsEnableRule(\"_AIStartAttack\");");
	oxy("xsDisableRule(\"_Gun2\");");
	oxy("}");
	oxyZ("} /*");

	vector LocFlag2 = rmGetUnitPosition(rmGetUnitPlacedOfPlayer(waterSpawnPointID, 2));
	float LOCXFlag2 = xsVectorGetX(LocFlag2);
	float LOCYFlag2 = xsVectorGetY(LocFlag2);
	float LOCZFlag2 = xsVectorGetZ(LocFlag2);


	vector LocGun1ID = rmGetUnitPosition(rmGetUnitPlaced(GunID, 0));
	vector LocGun2ID = rmGetUnitPosition(rmGetUnitPlaced(Gun2ID, 0));
	vector LocDockID = rmGetUnitPosition(rmGetUnitPlaced(Dock4ID, 0));
	vector LocCacheID = rmGetUnitPosition(rmGetUnitPlaced(CacheID, 0));
	vector LocFlag1 = rmGetUnitPosition(rmGetUnitPlacedOfPlayer(waterSpawnPointID, 1));
	vector LocTown1ID = rmGetUnitPosition(rmGetUnitPlacedOfPlayer(TCID, 1));


	float SpawnLoc = 60;
	float ShipLoc = 40;
	float RandomTime10min = rmRandFloat(540,720);
	float RandomTimeGun0 = rmRandInt(120,120);
	float RandomTimeGun1 = rmRandFloat(780,900);
//	float RandomTimeGun1 = rmRandFloat(0,0);
	float RandomTimeGun2 = RandomTimeGun1+RandomTimeGun0;

	if (randomplayer ==1)
		{
		SpawnLoc = 60;
		ShipLoc = -40;
		}
	else
		{
		SpawnLoc = -60;
		ShipLoc = 40;
		}


	oxy("rule _Sent1Ships active runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 120.00000000){");
	for(p=1;<=cNumberNonGaiaPlayers)
	{
	oxy("if(kbIsPlayerHuman("+p+") != true){");
	oxy("xsEnableRule(\"_AIShips"+p+"\");");
	oxy("}");
	}
	oxy("xsEnableRule(\"_Sent2Ships\");");
	oxy("xsDisableRule(\"_Sent1Ships\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _Sent2Ships inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 120.00000000){");
	for(p=1;<=cNumberNonGaiaPlayers)
	{
	oxy("if(kbIsPlayerHuman("+p+") != true){");
	oxy("xsEnableRule(\"_AIShips"+p+"\");");
	oxy("}");
	}
	oxy("xsEnableRule(\"_Sent1Ships\");");
	oxy("xsDisableRule(\"_Sent2Ships\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _Sent3Ships active runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 180.00000000){");
	for(p=1;<=cNumberNonGaiaPlayers)
	{
	oxy("if(kbIsPlayerHuman("+p+") != true){");
	oxy("xsEnableRule(\"_AI2Ships"+p+"\");");
	oxy("}");
	}
	oxy("xsEnableRule(\"_Sent4Ships\");");
	oxy("xsDisableRule(\"_Sent3Ships\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _Sent4Ships inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 180.00000000){");
	for(p=1;<=cNumberNonGaiaPlayers)
	{
	oxy("if(kbIsPlayerHuman("+p+") != true){");
	oxy("xsEnableRule(\"_AI2Ships"+p+"\");");
	oxy("}");
	}
	oxy("xsEnableRule(\"_Sent3Ships\");");
	oxy("xsDisableRule(\"_Sent4Ships\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _Sent5Ships active runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 240.00000000){");
	for(p=1;<=cNumberNonGaiaPlayers)
	{
	oxy("if(kbIsPlayerHuman("+p+") != true){");
	oxy("xsEnableRule(\"_AI3Ships"+p+"\");");
	oxy("}");
	}
	oxy("xsEnableRule(\"_Sent6Ships\");");
	oxy("xsDisableRule(\"_Sent5Ships\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _Sent6Ships inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 240.00000000){");
	for(p=1;<=cNumberNonGaiaPlayers)
	{
	oxy("if(kbIsPlayerHuman("+p+") != true){");
	oxy("xsEnableRule(\"_AI3Ships"+p+"\");");
	oxy("}");
	}
	oxy("xsEnableRule(\"_Sent5Ships\");");
	oxy("xsDisableRule(\"_Sent6Ships\");");
	oxy("}");
	oxyZ("} /*");


	for(i=1;<=cNumberNonGaiaPlayers)
	{

	oxy("rule _AIShips"+i+" inactive runImmediately { ");
	oxy("xsSetContextPlayer("+i+");");
	oxy("if((trTime()-cActivationTime) >= 0.00000000){");
	oxy("if(trPlayerActive("+i+")){");
	oxy("if(kbGetAgeForPlayer("+i+") >= 1){");
	oxy("if(kbUnitCount("+i+",trQuestVarGet(\"cUnittypeAbstractWarShip\"),cUnitStateAlive) <= 80){");
	if(i==2)
	{
		if (rmGetPlayerCiv(i) <= 13 && rmGetPlayerCiv(i) != 8)
		{
		oxy("trUnitCreate(\"Caravel\",\"AIShips"+i+"A\"+trTime(),"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"Caravel\",\"AIShips"+i+"E\"+trTime(),"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else if (rmGetPlayerCiv(i) == 8)
		{
		oxy("trUnitCreate(\"Galley\",\"AIShips"+i+"A\"+trTime(),"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"Galley\",\"AIShips"+i+"E\"+trTime(),"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else if (rmGetPlayerCiv(i) >= 14 && rmGetPlayerCiv(i) <= 17)
		{
		oxy("trUnitCreate(\"xpWarCanoe\",\"AIShips"+i+"A\"+trTime(),"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"Canoe\",\"AIShips"+i+"B\"+trTime(),"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"xpWarCanoe\",\"AIShips"+i+"E\"+trTime(),"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"Canoe\",\"AIShips"+i+"F\"+trTime(),"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else if (rmGetPlayerCiv(i) == 19 || rmGetPlayerCiv(i) == 22 || rmGetPlayerCiv(i) == 26)
		{
		oxy("trUnitCreate(\"ypFune\",\"AIShips"+i+"A\"+trTime(),"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"ypFune\",\"AIShips"+i+"E\"+trTime(),"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else if (rmGetPlayerCiv(i) == 20 || rmGetPlayerCiv(i) == 23)
		{
		oxy("trUnitCreate(\"ypWarJunk\",\"AIShips"+i+"A\"+trTime(),"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"ypWarJunk\",\"AIShips"+i+"E\"+trTime(),"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else
		{
		oxy("trUnitCreate(\"Caravel\",\"AIShips"+i+"A\"+trTime(),"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"Caravel\",\"AIShips"+i+"E\"+trTime(),"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
	}
	oxy("}}}");
	oxy("xsDisableRule(\"_AIShips"+i+"\");");
	oxyZ("}} /*");


	oxy("rule _AI2Ships"+i+" inactive runImmediately { ");
	oxy("xsSetContextPlayer("+i+");");
	oxy("if((trTime()-cActivationTime) >= 0.00000000){");
	oxy("if(trPlayerActive("+i+")){");
	oxy("if(kbGetAgeForPlayer("+i+") >= 2){");
	oxy("if(kbUnitCount("+i+",trQuestVarGet(\"cUnittypeAbstractWarShip\"),cUnitStateAlive) <= 40){");
	if(i==2)
	{
		if (rmGetPlayerCiv(i) <= 13 && rmGetPlayerCiv(i) != 7)
		{
		oxy("trUnitCreate(\"Galleon\",\"AIShips"+i+"W\"+trTime(),"+xsVectorGetX(LocFlag2)+"+250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"Galleon\",\"AIShips"+i+"G\"+trTime(),"+xsVectorGetX(LocFlag2)+"-250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else if (rmGetPlayerCiv(i) == 7)
		{
		oxy("trUnitCreate(\"Fluyt\",\"AIShips"+i+"W\"+trTime(),"+xsVectorGetX(LocFlag2)+"+250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"Fluyt\",\"AIShips"+i+"G\"+trTime(),"+xsVectorGetX(LocFlag2)+"-250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else if (rmGetPlayerCiv(i) >= 14 && rmGetPlayerCiv(i) <= 17)
		{
		oxy("trUnitCreate(\"xpWarCanoe\",\"AIShips"+i+"W\"+trTime(),"+xsVectorGetX(LocFlag2)+"+250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"xpWarCanoe\",\"AIShips"+i+"G\"+trTime(),"+xsVectorGetX(LocFlag2)+"-250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else if (rmGetPlayerCiv(i) == 19 || rmGetPlayerCiv(i) == 22 || rmGetPlayerCiv(i) == 26)
		{
		oxy("trUnitCreate(\"ypAtakabune\",\"AIShips"+i+"W\"+trTime(),"+xsVectorGetX(LocFlag2)+"+250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"ypAtakabune\",\"AIShips"+i+"G\"+trTime(),"+xsVectorGetX(LocFlag2)+"-250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else if (rmGetPlayerCiv(i) == 20 || rmGetPlayerCiv(i) == 23)
		{
		oxy("trUnitCreate(\"ypFuchuan\",\"AIShips"+i+"W\"+trTime(),"+xsVectorGetX(LocFlag2)+"+250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"ypFuchuan\",\"AIShips"+i+"G\"+trTime(),"+xsVectorGetX(LocFlag2)+"-250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
		else
		{
		oxy("trUnitCreate(\"Galleon\",\"AIShips"+i+"W\"+trTime(),"+xsVectorGetX(LocFlag2)+"+250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"Galleon\",\"AIShips"+i+"G\"+trTime(),"+xsVectorGetX(LocFlag2)+"-250,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
	}
	oxy("}}}");
	oxy("xsDisableRule(\"_AI2Ships"+i+"\");");
	oxyZ("}} /*");

	oxy("rule _AI3Ships"+i+" inactive runImmediately { ");
	oxy("xsSetContextPlayer("+i+");");
	oxy("if((trTime()-cActivationTime) >= 0.00000000){");
	oxy("if(trPlayerActive("+i+")){");
	oxy("if(kbGetAgeForPlayer("+i+") >= 3){");
	oxy("if(kbUnitCount("+i+",trQuestVarGet(\"cUnittypeAbstractWarShip\"),cUnitStateAlive) <= 26){");
	if(i==2)
	{
		if (rmGetPlayerCiv(i) != 15 && rmGetPlayerCiv(i) != 16 && rmGetPlayerCiv(i) != 17)
		{
		oxy("trUnitCreate(\"Monitor\",\"AIShips"+i+"C\"+trTime(),"+xsVectorGetX(LocFlag2)+"+25,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
			if (rmGetPlayerCiv(i) != 19 && rmGetPlayerCiv(i) != 20)
			{
			oxy("trUnitCreate(\"Frigate\",\"AIShips"+i+"U\"+trTime(),"+xsVectorGetX(LocFlag2)+"-25,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
			}
			else if (rmGetPlayerCiv(i) == 19)
			{
			oxy("trUnitCreate(\"ypTekkousen\",\"AIShips"+i+"U\"+trTime(),"+xsVectorGetX(LocFlag2)+"-25,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
			}
			else
			{
			oxy("trUnitCreate(\"ypFuchuan\",\"AIShips"+i+"U\"+trTime(),"+xsVectorGetX(LocFlag2)+"-25,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
			}
		}
		else
		{
		oxy("trUnitCreate(\"xpWarCanoe\",\"AIShips"+i+"H\"+trTime(),"+xsVectorGetX(LocFlag2)+"-25,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		oxy("trUnitCreate(\"xpTlalocCanoe\",\"AIShips"+i+"Q\"+trTime(),"+xsVectorGetX(LocFlag2)+"+25,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,"+i+");");
		}
	}
	oxy("}}}");
	oxy("xsDisableRule(\"_AI3Ships"+i+"\");");
	oxyZ("}} /*");


	oxy("rule _AIAttack"+i+" inactive runImmediately { ");
	oxy("xsSetContextPlayer("+i+");");
	oxy("if((trTime()-cActivationTime) >= 0.00000000){");
	oxy("if(trPlayerActive("+i+")){");
	oxy("if(kbUnitCount("+i+",trQuestVarGet(\"cUnittypeAbstractWarShip\"),cUnitStateAlive) <= 90){");
	if(i==2)
	{
		if (rmGetPlayerCiv(i) != 15 && rmGetPlayerCiv(i) != 16 && rmGetPlayerCiv(i) != 17)
		{
			if (rmGetPlayerCiv(i) != 19 && rmGetPlayerCiv(i) != 20)
			{
		oxy("trArmyDispatch(\""+i+",0\",\"Frigate\",2,"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
			else if (rmGetPlayerCiv(i) == 19)
			{
		oxy("trArmyDispatch(\""+i+",0\",\"ypTekkousen\",2,"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
			else
			{
		oxy("trArmyDispatch(\""+i+",0\",\"ypFuchuan\",2,"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
		}
		else
		{
		oxy("trArmyDispatch(\""+i+",0\",\"xpTlalocCanoe\",3,"+xsVectorGetX(LocFlag2)+"+150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
		}
		oxy("trArmySelect(\""+i+",0\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",-1,true,true,1.0);");
	oxy("xsEnableRule(\"_AIMoveToGun2\");");
	oxy("xsEnableRule(\"_AIAttackGun2\");");
	}
	oxy("}}");
	oxy("xsDisableRule(\"_AIAttack"+i+"\");");
	oxyZ("}} /*");

	oxy("rule _AIAttackII"+i+" inactive runImmediately { ");
	oxy("xsSetContextPlayer("+i+");");
	oxy("if((trTime()-cActivationTime) >= 0.00000000){");
	oxy("if(trPlayerActive("+i+")){");
	oxy("if(kbUnitCount("+i+",trQuestVarGet(\"cUnittypeAbstractWarShip\"),cUnitStateAlive) <= 90){");
	if(i==2)
	{
		if (rmGetPlayerCiv(i) != 15 && rmGetPlayerCiv(i) != 16 && rmGetPlayerCiv(i) != 17)
		{
			if (rmGetPlayerCiv(i) != 19 && rmGetPlayerCiv(i) != 20)
			{
		oxy("trArmyDispatch(\""+i+",2\",\"Frigate\",2,"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
			else if (rmGetPlayerCiv(i) == 19)
			{
		oxy("trArmyDispatch(\""+i+",2\",\"ypTekkousen\",2,"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
			else
			{
		oxy("trArmyDispatch(\""+i+",2\",\"ypFuchuan\",2,"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
		}
		else
		{
		oxy("trArmyDispatch(\""+i+",2\",\"xpTlalocCanoe\",3,"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
		}
		oxy("trArmySelect(\""+i+",2\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",-1,true,true,1.0);");
	oxy("xsEnableRule(\"_AIMoveToGun1\");");
	oxy("xsEnableRule(\"_AIAttackGun1\");");
	}
	oxy("}}");
	oxy("xsDisableRule(\"_AIAttackII"+i+"\");");
	oxyZ("}} /*");
 
	}//FOR I END.

	oxy("rule _AIDefineAttack active runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 0){");
	oxy("if(kbIsPlayerHuman(2) != true){");
	oxy("xsEnableRule(\"_AIAttackland10min01\");");
	if (randomplayer ==1)
		{
		oxy("xsEnableRule(\"_AIAttackCache\");");
		}
	else
		{
		oxy("xsEnableRule(\"_AIStartAttack\");");
		oxy("xsEnableRule(\"_AIStartAttackII\");");
		}
	oxy("}");
	oxy("xsDisableRule(\"_AIDefineAttack\");");
	oxyZ("}} /*");

	oxy("rule _AIAttackCache inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= "+RandomTimeGun1+"){");
	oxy("xsEnableRule(\"_AIAttackCacheSpawn\");");
	oxy("xsEnableRule(\"_AIAttackCacheStart\");");
	oxy("xsDisableRule(\"_AIAttackCache\");");
	oxyZ("}} /*");

	oxy("rule _AIAttackCacheSpawn inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 0.00000000){");
	oxy("if(trPlayerActive(2)){");
		if (rmGetPlayerCiv(2) != 15 && rmGetPlayerCiv(2) != 16 && rmGetPlayerCiv(2) != 17)
		{
			if (rmGetPlayerCiv(2) != 19 && rmGetPlayerCiv(2) != 20)
			{
		oxy("trArmyDispatch(\"2,0\",\"Frigate\",2,"+xsVectorGetX(LocFlag2)+"-100,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
			else if (rmGetPlayerCiv(2) == 19)
			{
		oxy("trArmyDispatch(\"2,0\",\"ypTekkousen\",2,"+xsVectorGetX(LocFlag2)+"-100,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
			else
			{
		oxy("trArmyDispatch(\"2,0\",\"ypFuchuan\",2,"+xsVectorGetX(LocFlag2)+"-100,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
		}
		else
		{
		oxy("trArmyDispatch(\"2,0\",\"xpTlalocCanoe\",3,"+xsVectorGetX(LocFlag2)+"-100,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
		}
		oxy("trArmySelect(\"2,0\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-100,-1,false,true,1.0);");
		oxy("trArmySelect(\"2,1\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocCacheID)+","+xsVectorGetY(LocCacheID)+","+xsVectorGetZ(LocCacheID)+",-1,false,true,1.0);");
	oxy("xsEnableRule(\"_AIMoveToCache\");");
	oxy("}");
	oxy("xsDisableRule(\"_AIAttackCacheSpawn\");");
	oxyZ("}} /*");

	oxy("rule _AIMoveToCache inactive runImmediately { ");
	//This is a Loop Trigger
		oxy("if((trTime()-cActivationTime) >= 5.00000000 && (trTime()-cActivationTime) < 60.00000000){");
		oxy("trArmySelect(\"2,0\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",-1,false,false,1.0);");
		oxy("}");
		oxy("if((trTime()-cActivationTime) > 60.00000000){");
		oxy("trArmySelect(\"2,0\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",-1,true,false,1.0);");
		oxy("xsDisableRule(\"_AIMoveToCache\");");
		oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackCacheStart inactive runImmediately { ");
	oxy("trArmySelect(\"2,0\");");
	oxy("if(trUnitDistanceToPoint("+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+") <=24){");
	oxy("xsDisableRule(\"_AIAttackCacheStart\");");
	oxy("xsEnableRule(\"_AIAttackCacheSpawnArmy\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackCacheSpawnArmy inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 5.00000000){");
		if (rmGetPlayerCiv(2) <= 7 && rmGetPlayerCiv(2) != 7)
		{
		oxy("trArmyDispatch(\"2,1\",\"Pikeman\",22,"+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 7)
		{
		oxy("trArmyDispatch(\"2,1\",\"Dopplesoldner\",15,"+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 8)
		{
		oxy("trArmyDispatch(\"2,1\",\"Grenadier\",15,"+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 15)
		{
		oxy("trArmyDispatch(\"2,1\",\"xpRam\",12,"+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 16)
		{
		oxy("trArmyDispatch(\"2,1\",\"xpWarClub\",18,"+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 17)
		{
		oxy("trArmyDispatch(\"2,1\",\"xpPumaMan\","+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 19)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypKensei\",14,"+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 20)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypQiangPikeman\",24,"+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 21)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypUrumi\",30,"+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else
		{
		oxy("trArmyDispatch(\"2,1\",\"SPCBuccaneer\",21,"+xsVectorGetX(LocFlag1)+"-100,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		oxy("trArmySelect(\"2,1\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocCacheID)+","+xsVectorGetY(LocCacheID)+","+xsVectorGetZ(LocCacheID)+",-1,false,true,1.0);");
	oxy("xsEnableRule(\"_AIAttackCacheMoveToTC\");");
	oxy("xsDisableRule(\"_AIAttackCacheSpawnArmy\");");
	oxyZ("}} /*");

	oxy("rule _AIAttackCacheMoveToTC inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 120.00000000){");
	oxy("trArmySelect(\"2,1\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-1,true,true,1.0);");
	oxy("xsDisableRule(\"_AIAttackCacheMoveToTC\");");
	oxyZ("}} /*");

	oxy("rule _AIStartAttackII inactive runImmediately { ");
	//GunID
	oxy("if(kbIsPlayerHuman(2) != true){");
	oxy("if((trTime()-cActivationTime) >= "+RandomTimeGun2+"){");
	oxy("xsEnableRule(\"_AIAttackII2\");");
	oxy("xsDisableRule(\"_AIStartAttackII\");");
	oxy("}}");
	oxy("else");
	oxy("{xsDisableRule(\"_AIStartAttackII\");}");
	oxyZ("} /*");

	oxy("rule _AIStartAttack inactive runImmediately { ");
	//Gun2ID
	oxy("if(kbIsPlayerHuman(2) != true){");
	oxy("if((trTime()-cActivationTime) >= "+RandomTimeGun1+"){");
	oxy("xsEnableRule(\"_AIAttack2\");");
	oxy("xsDisableRule(\"_AIStartAttack\");");
	oxy("}}");
	oxy("else");
	oxy("{xsDisableRule(\"_AIStartAttack\");}");
	oxyZ("} /*");

	oxy("rule _AIMoveToGun2 inactive runImmediately { ");
	//This is a Loop Trigger
		oxy("if((trTime()-cActivationTime) >= 1.00000000 && (trTime()-cActivationTime) < 80.00000000){");
		oxy("trArmySelect(\"2,0\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun2ID)+"-5,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-5,-1,false,true,1.0);");
		oxy("}");
		oxy("if((trTime()-cActivationTime) >= 80.00000000){");
		oxy("trArmySelect(\"2,0\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun2ID)+"-5,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-5,-1,true,true,1.0);");
		oxy("trArmySelect(\"2,1\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun2ID)+"+20,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-5,-1,true,true,1.0);");
		oxy("xsDisableRule(\"_AIMoveToGun2\");");
		oxy("xsEnableRule(\"_AIDeleteArmy2\");");
		oxy("}");
	oxyZ("} /*");

	oxy("rule _AIDeleteArmy2 inactive runImmediately { ");
		oxy("if((trTime()-cActivationTime) >= 60.00000000){");
		oxy("trArmySelect(\"2,1\");");
		oxy("trUnitDelete();");
		oxy("if((trTime()-cActivationTime) >= 61.00000000){");
		if (rmGetPlayerCiv(2) <= 7 && rmGetPlayerCiv(2) != 5 && rmGetPlayerCiv(2) != 7)
		{
		oxy("trArmyDispatch(\"2,1\",\"Musketeer\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 5)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypConsulateStadhouders\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 7)
		{
		oxy("trArmyDispatch(\"2,1\",\"Dopplesoldner\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 8)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypConsulateTufanciCorps\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 15)
		{
		oxy("trArmyDispatch(\"2,1\",\"xpTomahawk\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 16)
		{
		oxy("trArmyDispatch(\"2,1\",\"xpWarClub\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 17)
		{
		oxy("trArmyDispatch(\"2,1\",\"xpPumaMan\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 19)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypAshigaru\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 20)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypQiangPikeman\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 21)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypSepoy\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		else
		{
		oxy("trArmyDispatch(\"2,1\",\"SPCBuccaneer\",2,"+xsVectorGetX(LocGun2ID)+","+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,true);");
		}
		oxy("trUnitCreate(\"ypSPCJapaneseOutpost\",\"SPCJapaneseOutpost2\"+trTime(),"+xsVectorGetX(LocGun2ID)+"+15,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+",0,2);");
		oxy("xsDisableRule(\"_AIDeleteArmy2\");");
		oxy("trArmySelect(\"2,0\");");
		oxy("trUnitDelete(false);");
		oxy("trUnitSelectClear();");
		oxy("}");
		oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackGun2 inactive runImmediately { ");
	oxy("trArmySelect(\"2,0\");");
	oxy("if(trUnitDistanceToPoint("+xsVectorGetX(LocGun2ID)+"-5,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-5) <=24){");
	oxy("xsEnableRule(\"_AIAttackGun2Spawn\");");
	oxy("xsDisableRule(\"_AIAttackGun2\");");
	oxyZ("}} /*");

	oxy("rule _AIAttackGun2Spawn inactive runImmediately { ");
	oxy("trArmySelect(\"2,0\");");
		oxy("if((trTime()-cActivationTime) >= 5.00000000){");
		if (rmGetPlayerCiv(2) <= 7 && rmGetPlayerCiv(2) != 7)
		{
		oxy("trArmyDispatch(\"2,1\",\"Pikeman\",22,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 7)
		{
		oxy("trArmyDispatch(\"2,1\",\"Dopplesoldner\",15,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 8)
		{
		oxy("trArmyDispatch(\"2,1\",\"Grenadier\",15,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 15)
		{
		oxy("trArmyDispatch(\"2,1\",\"xpRam\",12,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 16)
		{
		oxy("trArmyDispatch(\"2,1\",\"xpWarClub\",18,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 17)
		{
		oxy("trArmyDispatch(\"2,1\",\"xpPumaMan\",18,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 19)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypKensei\",14,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 20)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypQiangPikeman\",24,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 21)
		{
		oxy("trArmyDispatch(\"2,1\",\"ypUrumi\",30,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		else
		{
		oxy("trArmyDispatch(\"2,1\",\"SPCBuccaneer\",21,"+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-8,0,true);");
		}
		oxy("trArmySelect(\"2,1\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun2ID)+"-3,"+xsVectorGetY(LocGun2ID)+","+xsVectorGetZ(LocGun2ID)+"-10,-1,false,true,1.0);");
	oxy("xsDisableRule(\"_AIAttackGun2Spawn\");");
	oxyZ("}} /*");

	oxy("rule _AIMoveToGun1 inactive runImmediately { ");
	//This is a Loop Trigger
		oxy("if((trTime()-cActivationTime) >= 1.00000000 && (trTime()-cActivationTime) < 80.00000000){");
		oxy("trArmySelect(\"2,2\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun1ID)+"-15,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",-1,false,true,1.0);");
		oxy("}");
		oxy("if((trTime()-cActivationTime) >= 80.00000000){");
		oxy("trArmySelect(\"2,2\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun1ID)+"-15,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",-1,true,true,1.0);");
		oxy("trArmySelect(\"2,3\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun1ID)+"-30,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",-1,true,true,1.0);");
		oxy("xsDisableRule(\"_AIMoveToGun1\");");
		oxy("xsEnableRule(\"_AIDeleteArmy3\");");
		oxy("}");
	oxyZ("} /*");

	oxy("rule _AIDeleteArmy3 inactive runImmediately { ");
		oxy("if((trTime()-cActivationTime) >= 60.00000000){");
		oxy("trArmySelect(\"2,3\");");
		oxy("trUnitDelete();");
		oxy("trArmySelect(\"2,3\");");
		oxy("trUnitDelete(true);");
		oxy("if((trTime()-cActivationTime) >= 61.00000000){");
		if (rmGetPlayerCiv(2) <= 7 && rmGetPlayerCiv(2) != 5 && rmGetPlayerCiv(2) != 7)
		{
		oxy("trArmyDispatch(\"2,3\",\"Musketeer\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 5)
		{
		oxy("trArmyDispatch(\"2,3\",\"ypConsulateStadhouders\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 7)
		{
		oxy("trArmyDispatch(\"2,3\",\"Dopplesoldner\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 8)
		{
		oxy("trArmyDispatch(\"2,3\",\"ypConsulateTufanciCorps\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 15)
		{
		oxy("trArmyDispatch(\"2,3\",\"xpTomahawk\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 16)
		{
		oxy("trArmyDispatch(\"2,3\",\"xpWarClub\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 17)
		{
		oxy("trArmyDispatch(\"2,3\",\"xpPumaMan\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 19)
		{
		oxy("trArmyDispatch(\"2,3\",\"ypAshigaru\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 20)
		{
		oxy("trArmyDispatch(\"2,3\",\"ypQiangPikeman\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 21)
		{
		oxy("trArmyDispatch(\"2,3\",\"ypSepoy\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		else
		{
		oxy("trArmyDispatch(\"2,3\",\"SPCBuccaneer\",2,"+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,true);");
		}
		oxy("trUnitCreate(\"ypSPCJapaneseOutpost\",\"SPCJapaneseOutpost2\"+trTime(),"+xsVectorGetX(LocGun1ID)+"-15,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",0,2);");
		oxy("xsDisableRule(\"_AIDeleteArmy3\");");
		oxy("trArmySelect(\"2,2\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocDockID)+","+xsVectorGetY(LocDockID)+","+xsVectorGetZ(LocDockID)+",-1,true,true,1.0);");
		oxy("trArmySelect(\"2,2\");");
		oxy("trUnitDelete(false);");
		oxy("xsDisableRule(\"_AIAttackGun2\");");
		oxy("xsDisableRule(\"_AIAttackGun1\");");
		oxy("}");
		oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackGun1 inactive runImmediately { ");
	oxy("trArmySelect(\"2,2\");");
	oxy("if(trUnitDistanceToPoint("+xsVectorGetX(LocGun1ID)+"-15,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+") <=18){");
	oxy("xsEnableRule(\"_AIAttackGun1Spawn\");");
	oxy("xsDisableRule(\"_AIAttackGun1\");");
	oxyZ("}} /*");

	oxy("rule _AIAttackGun1Spawn inactive runImmediately { ");
	oxy("trArmySelect(\"2,2\");");
	oxy("if((trTime()-cActivationTime) >= 5.00000000){");
		if (rmGetPlayerCiv(2) <= 7 && rmGetPlayerCiv(2) != 7)
		{
		oxy("trArmyDispatch(\"2,3\",\"Pikeman\",22,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 7)
		{
		oxy("trArmyDispatch(\"2,3\",\"Dopplesoldner\",15,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 8)
		{
		oxy("trArmyDispatch(\"2,3\",\"Grenadier\",15,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 15)
		{
		oxy("trArmyDispatch(\"2,3\",\"xpRam\",12,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 16)
		{
		oxy("trArmyDispatch(\"2,3\",\"xpWarClub\",18,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 17)
		{
		oxy("trArmyDispatch(\"2,3\",\"xpPumaMan\",18,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 19)
		{
		oxy("trArmyDispatch(\"2,3\",\"ypKensei\",14,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 20)
		{
		oxy("trArmyDispatch(\"2,3\",\"ypQiangPikeman\",24,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		else if (rmGetPlayerCiv(2) == 21)
		{
		oxy("trArmyDispatch(\"2,3\",\"ypUrumi\",30,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		else
		{
		oxy("trArmyDispatch(\"2,3\",\"SPCBuccaneer\",21,"+xsVectorGetX(LocGun1ID)+"-10,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+"-5,0,true);");
		}
		oxy("trArmySelect(\"2,3\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun1ID)+"-30,"+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",-1,true,true,1.0);");
	oxy("xsDisableRule(\"_AIAttackGun1Spawn\");");
	oxyZ("}} /*");

	oxy("rule _AIAttackland10min01 inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= "+RandomTime10min+"){");
	oxy("xsEnableRule(\"_AIAttackland\");");
	oxy("xsEnableRule(\"_AIAttack01\");");
	oxy("xsEnableRule(\"_AIAttackland10min02\");");
	oxy("xsDisableRule(\"_AIAttackland10min01\");");
	oxyZ("}} /*");

	oxy("rule _AIAttackland inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 0.00000000){");
	oxy("if(trPlayerActive(2)){");
		if (rmGetPlayerCiv(2) != 15 && rmGetPlayerCiv(2) != 16 && rmGetPlayerCiv(2) != 17)
		{
			if (rmGetPlayerCiv(2) != 19 && rmGetPlayerCiv(2) != 20)
			{
		oxy("trArmyDispatch(\"2,4\",\"Frigate\",2,"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
			else if (rmGetPlayerCiv(2) == 19)
			{
		oxy("trArmyDispatch(\"2,4\",\"ypTekkousen\",2,"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
			else
			{
		oxy("trArmyDispatch(\"2,4\",\"ypFuchuan\",2,"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
			}
		}
		else
		{
		oxy("trArmyDispatch(\"2,4\",\"xpTlalocCanoe\",3,"+xsVectorGetX(LocFlag2)+"-150,"+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+"+"+ShipLoc+",0,true);");
		}
		oxy("trArmySelect(\"2,4\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-100,-1,false,true,1.0);");
		oxy("trArmySelect(\"2,5\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocGun1ID)+","+xsVectorGetY(LocGun1ID)+","+xsVectorGetZ(LocGun1ID)+",-1,true,true,1.0);");
	oxy("xsEnableRule(\"_AIMoveToTC\");");
	oxy("}");
	oxy("xsDisableRule(\"_AIAttackland\");");
	oxyZ("}} /*");

	oxy("rule _AIAttack01 inactive runImmediately { ");
	oxy("trArmySelect(\"2,4\");");
	oxy("if(trUnitDistanceToPoint("+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+") <=24){");
	oxy("xsDisableRule(\"_AIAttack01\");");
	oxy("xsEnableRule(\"_AIAttackTC01\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackTC01 inactive runImmediately { ");
	oxy("trArmySelect(\"2,4\");");
	oxy("if((trTime()-cActivationTime) >= 5.00000000){");
		if (rmGetPlayerCiv(2) <= 7 && rmGetPlayerCiv(2) != 5 && rmGetPlayerCiv(2) != 7)
		{
		oxy("trArmyDispatch(\"2,5\",\"Pikeman\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Musketeer\",10,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Hussar\",8,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Crossbowman\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 5)
		{
		oxy("trArmyDispatch(\"2,5\",\"Pikeman\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Skirmisher\",10,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Hussar\",8,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Skirmisher\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 7)
		{
		oxy("trArmyDispatch(\"2,5\",\"Pikeman\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Dopplesoldner\",7,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Uhlan\",8,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Crossbowman\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 8)
		{
		oxy("trArmyDispatch(\"2,5\",\"Grenadier\",5,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Janissary\",10,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Hussar\",8,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"AbusGun\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 15)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpRam\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpTomahawk\",10,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpHorseman\",8,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpAenna\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 16)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpWarClub\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpBowRider\",8,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpAxeRider\",8,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpWarBow\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 17)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpPumaMan\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpCoyoteMan\",6,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpCoyoteMan\",8,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpMacehualtin\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 19)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypKensei\",6,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypAshigaru\",10,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypNaginataRider\",8,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypYumi\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 20)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypQiangPikeman\",12,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypKeshik\",9,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypSteppeRider\",14,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypChuKoNu\",15,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 21)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypRajput\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-60,0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypSepoy\",10,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypSowar\",8,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypNatMercGurkha\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-63,0,true);");
		}
		else
		{
		oxy("trArmyDispatch(\"2,5\",\"SPCBuccaneer\",21,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-60,0,true);");
		oxy("trArmyDispatch(\"2,6\",\"WhiteWolf\",10,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypNatMercSohei\",8,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,8\",\"SPCRailroadWorker\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-63,0,true);");
		}
	oxy("trArmySelect(\"2,5\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-1,true,true,1.0);");
	oxy("trArmySelect(\"2,6\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"+8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,7\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,8\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("xsEnableRule(\"_AIMove01\");");
	oxy("xsDisableRule(\"_AIAttackTC01\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _AIMoveToTC inactive runImmediately { ");
	//This is a Loop Trigger
		oxy("if((trTime()-cActivationTime) >= 5.00000000 && (trTime()-cActivationTime) < 60.00000000){");
		oxy("trArmySelect(\"2,4\");");
		oxy("trUnitMoveToPoint("+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",-1,false,false,1.0);");
		oxy("}");
		oxy("if((trTime()-cActivationTime) > 60.00000000){");
		oxy("xsDisableRule(\"_AIMoveToTC\");");
		oxy("}");
	oxyZ("} /*");

	oxy("rule _AIMove01 inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 30.00000000){");
	oxy("trArmySelect(\"2,4\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-100,-1,false,false,1.0);");
	oxy("trArmySelect(\"2,5\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-1,true,true,1.0);");
	oxy("trArmySelect(\"2,6\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"+8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,7\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-10,true,true,1.0);");
	oxy("trArmySelect(\"2,8\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,9\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("xsEnableRule(\"_AIMove02\");");
	oxy("xsDisableRule(\"_AIMove01\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _AIMove02 inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 180.00000000){");
	oxy("trArmySelect(\"2,4\");");
	oxy("trUnitDelete(false);");
	oxy("trArmySelect(\"2,5\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"+250,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-30,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,6\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-250,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-30,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,7\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"+250,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"+30,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,8\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-250,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"+30,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,9\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"+300,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"+30,-1,true,true,1.0);");
	oxy("xsDisableRule(\"_AIMove02\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackland10min02 inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= ("+RandomTime10min+"+600)/2){");
	oxy("xsEnableRule(\"_AIAttackland\");");
	oxy("xsEnableRule(\"_AIAttack02\");");
	oxy("xsEnableRule(\"_AIAttackland5min03\");");
	oxy("xsDisableRule(\"_AIAttackland10min02\");");
	oxyZ("}} /*");

	oxy("rule _AIAttack02 inactive runImmediately { ");
	oxy("trArmySelect(\"2,4\");");
	oxy("if(trUnitDistanceToPoint("+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+") <=24){");
	oxy("xsDisableRule(\"_AIAttack02\");");
	oxy("xsEnableRule(\"_AIAttackTC02\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackTC02 inactive runImmediately { ");
	oxy("trArmySelect(\"2,4\");");
	oxy("if((trTime()-cActivationTime) >= 5.00000000){");
		if (rmGetPlayerCiv(2) <= 7 && rmGetPlayerCiv(2) != 5 && rmGetPlayerCiv(2) != 7)
		{
		oxy("trArmyDispatch(\"2,5\",\"Dragoon\",16,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Musketeer\",18,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Hussar\",12,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Skirmisher\",18,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Falconet\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 5)
		{
		oxy("trArmyDispatch(\"2,5\",\"Ruyter\",16,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Skirmisher\",11,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Hussar\",12,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Skirmisher\",11,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Falconet\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 7)
		{
		oxy("trArmyDispatch(\"2,5\",\"WarWagon\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Dopplesoldner\",14,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Uhlan\",15,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Skirmisher\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Falconet\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 8)
		{
		oxy("trArmyDispatch(\"2,5\",\"Grenadier\",5,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Janissary\",18,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Spahi\",6,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"AbusGun\",16,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Falconet\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 15)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpRam\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpTomahawk\",10,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpHorseman\",12,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpAenna\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"xpLightCannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 16)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpCoupRider\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpBowRider\",8,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpAxeRider\",12,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpWarRifle\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"xpRifleRider\",8,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 17)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpPumaMan\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpCoyoteMan\",8,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpMusketWarrior\",10,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpMacehualtin\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"xpArrowKnight\",12,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 19)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypKensei\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypAshigaru\",12,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypNaginataRider\",10,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypYumi\",16,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"ypFlamingArrow\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 20)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypArquebusier\",21,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypIronFlail\",16,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypMeteorHammer\",12,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypChangdao\",12,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"ypFlameThrower\",12,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 21)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypUrumi\",8,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-60,0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypSepoy\",12,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypHowdah\",4,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypNatMercGurkha\",12,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-63,0,true);");
		oxy("trArmyDispatch(\"2,9\",\"ypSiegeElephant\",3,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else
		{
		oxy("trArmyDispatch(\"2,5\",\"SPCBuccaneer\",21,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-60,0,true);");
		oxy("trArmyDispatch(\"2,6\",\"WhiteWolf\",10,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypNatMercSohei\",8,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,8\",\"SPCRailroadWorker\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-63,0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Falconet\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
	oxy("trArmySelect(\"2,5\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-1,true,true,1.0);");
	oxy("trArmySelect(\"2,6\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"+8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,7\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,8\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,9\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-1,true,true,1.0);");
	oxy("xsEnableRule(\"_AIMove01\");");
	oxy("xsDisableRule(\"_AIAttackTC02\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackland5min03 inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= (("+RandomTime10min+"+600)/2)-300){");
	oxy("xsEnableRule(\"_AIAttackland\");");
	oxy("xsEnableRule(\"_AIAttack03\");");
	oxy("xsDisableRule(\"_AIAttack02\");");
	oxy("xsDisableRule(\"_AIAttack04\");");
	oxy("trArmySelect(\"2,5\");");
	oxy("trUnitDelete();");
	oxy("trArmySelect(\"2,6\");");
	oxy("trUnitDelete();");
	oxy("trArmySelect(\"2,7\");");
	oxy("trUnitDelete();");
	oxy("trArmySelect(\"2,8\");");
	oxy("trUnitDelete();");
	oxy("trArmySelect(\"2,9\");");
	oxy("trUnitDelete();");
	oxy("xsEnableRule(\"_AIAttackland5min04\");");
	oxy("xsDisableRule(\"_AIAttackland5min03\");");
	oxyZ("}} /*");

	oxy("rule _AIAttack03 inactive runImmediately { ");
	oxy("trArmySelect(\"2,4\");");
	oxy("if(trUnitDistanceToPoint("+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+") <=24){");
	oxy("xsDisableRule(\"_AIAttack03\");");
	oxy("xsEnableRule(\"_AIAttackTC03\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackTC03 inactive runImmediately { ");
	oxy("trArmySelect(\"2,4\");");
	oxy("if((trTime()-cActivationTime) >= 5.00000000){");
		if (rmGetPlayerCiv(2) <= 14 && rmGetPlayerCiv(2) >= 22)
		{
		oxy("trArmyDispatch(\"2,5\",\"MercRonin\",12,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"MercElmeti\",10,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"MercFusilier\",12,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"MercJaeger\",12,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"MercGreatCannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 15)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpMusketRider\",14,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpTomahawk\",14,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpHorseman\",14,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpAenna\",12,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"xpLightCannon\",8,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 16)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpCoupRider\",17,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpBowRider\",14,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpDogSoldier\",14,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpWarRifle\",14,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"xpRifleRider\",14,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 17)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpSkullKnight\",14,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpCoyoteMan\",14,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpMusketWarrior\",14,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpMacehualtin\",14,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"xpArrowKnight\",17,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 19)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypConsulateRonin\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypMercYojimbo\",14,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypConsulateNinja\",14,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypConsulateShinobi\",18,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"ypConsulateYamabushi\",14,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 20)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypMercIronTroop\",14,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"MercManchu\",14,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypRepentantFusilier\",12,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypRepentantElmeti\",10,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"ypRepentantGreatCannon\",3,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 21)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypUrumi\",17,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-60,0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypRepentantFusilier\",14,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypMercJatLancer\",14,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypMercArsonist\",14,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-63,0,true);");
		oxy("trArmyDispatch(\"2,9\",\"ypRepentantGreatCannon\",3,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else
		{
		oxy("trArmyDispatch(\"2,5\",\"MercRonin\",12,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"MercElmeti\",10,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"MercFusilier\",12,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"MercJaeger\",12,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"MercGreatCannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
	oxy("trArmySelect(\"2,5\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-1,true,true,1.0);");
	oxy("trArmySelect(\"2,6\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"+8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,7\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,8\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,9\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-1,true,true,1.0);");
	oxy("xsEnableRule(\"_AIMove01\");");
	oxy("xsDisableRule(\"_AIAttackTC03\");");
	oxy("}");
	oxyZ("} /*");

	oxy("rule _AIAttackland5min04 inactive runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= (("+RandomTime10min+"+600)/2)-300){");
	oxy("xsEnableRule(\"_AIAttackland\");");
	oxy("xsEnableRule(\"_AIAttack04\");");
	oxy("xsDisableRule(\"_AIAttack03\");");
	oxy("trArmySelect(\"2,5\");");
	oxy("trUnitDelete();");
	oxy("trArmySelect(\"2,6\");");
	oxy("trUnitDelete();");
	oxy("trArmySelect(\"2,7\");");
	oxy("trUnitDelete();");
	oxy("trArmySelect(\"2,8\");");
	oxy("trUnitDelete();");
	oxy("trArmySelect(\"2,9\");");
	oxy("trUnitDelete();");
	oxy("xsEnableRule(\"_AIAttackland5min03\");");
	oxy("xsDisableRule(\"_AIAttackland5min04\");");
	oxyZ("}} /*");

	oxy("rule _AIAttack04 inactive runImmediately { ");
	oxy("trArmySelect(\"2,4\");");
	oxy("if(trUnitDistanceToPoint("+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+") <=24){");
	oxy("xsDisableRule(\"_AIAttack04\");");
	oxy("xsEnableRule(\"_AIAttackTC04\");");
	oxy("}");
	oxyZ("} /*");

	// Text
	rmSetStatusText("",0.95);

	oxy("rule _AIAttackTC04 inactive runImmediately { ");
	oxy("trArmySelect(\"2,4\");");
	oxy("if((trTime()-cActivationTime) >= 5.00000000){");
		if (rmGetPlayerCiv(2) == 1)
		{
		oxy("trArmyDispatch(\"2,5\",\"Musketeer\",40,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Rodelero\",32,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Lancer\",32,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Dragoon\",28,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Cannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 2)
		{
		oxy("trArmyDispatch(\"2,5\",\"Longbowman\",40,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypConsulateRedcoat\",32,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Hussar\",32,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Dragoon\",28,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Rocket\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 3)
		{
		oxy("trArmyDispatch(\"2,5\",\"Dragoon\",30,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Musketeer\",30,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Cuirassier\",30,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Skirmisher\",28,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Cannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 4)
		{
		oxy("trArmyDispatch(\"2,5\",\"Dragoon\",30,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Cacadore\",28,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Hussar\",28,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"OrganGun\",15,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Cannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 5)
		{
		oxy("trArmyDispatch(\"2,5\",\"Ruyter\",30,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypConsulateStadhouders\",16,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Hussar\",28,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"Skirmisher\",28,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Cannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 6)
		{
		oxy("trArmyDispatch(\"2,5\",\"Strelet\",45,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Musketeer\",28,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Oprichnik\",28,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypConsulateSiberianCossack\",30,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"RussianCannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 7)
		{
		oxy("trArmyDispatch(\"2,5\",\"WarWagon\",25,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"MercLandsknecht\",20,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Uhlan\",32,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"MercJaeger\",20,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"Cannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 8)
		{
		oxy("trArmyDispatch(\"2,5\",\"CavalryArcher\",25,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"Janissary\",28,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"Spahi\",18,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"AbusGun\",28,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"GreatBombard\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 15)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpMusketRider\",18,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpTomahawk\",22,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpHorseman\",22,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpAenna\",20,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"xpLightCannon\",8,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 16)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpCoupRider\",25,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpBowRider\",22,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpDogSoldier\",22,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpWarRifle\",22,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"xpRifleRider\",22,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 17)
		{
		oxy("trArmyDispatch(\"2,5\",\"xpSkullKnight\",22,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"xpCoyoteMan\",22,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"xpMusketWarrior\",22,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"xpMacehualtin\",22,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"xpArrowKnight\",25,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 19)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypConsulateRonin\",18,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypMercYojimbo\",22,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypConsulateNinja\",22,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypConsulateShinobi\",26,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"ypFlamingArrow\",8,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 20)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypMercIronTroop\",20,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"MercManchu\",20,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypArquebusier\",28,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypIronFlail\",26,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"ypFlyingCrow\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else if (rmGetPlayerCiv(2) == 21)
		{
		oxy("trArmyDispatch(\"2,5\",\"ypUrumi\",26,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-60,0,true);");
		oxy("trArmyDispatch(\"2,6\",\"ypSepoy\",28,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,7\",\"ypMercJatLancer\",20,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-61,0,true);");
		oxy("trArmyDispatch(\"2,8\",\"ypMercArsonist\",22,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"-63,0,true);");
		oxy("trArmyDispatch(\"2,9\",\"ypSiegeElephant\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
		else
		{
		oxy("trArmyDispatch(\"2,5\",\"MercRonin\",20,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,6\",\"MercElmeti\",18,"+xsVectorGetX(LocFlag1)+"+5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,7\",\"MercFusilier\",20,"+xsVectorGetX(LocFlag1)+"-5,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,8\",\"MercJaeger\",20,"+xsVectorGetX(LocFlag1)+","+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		oxy("trArmyDispatch(\"2,9\",\"MercGreatCannon\",5,"+xsVectorGetX(LocFlag1)+"+7,"+xsVectorGetY(LocFlag1)+","+xsVectorGetZ(LocFlag1)+"+"+SpawnLoc+",0,true);");
		}
	oxy("trArmySelect(\"2,5\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-1,true,true,1.0);");
	oxy("trArmySelect(\"2,6\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"+8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,7\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+"-8,"+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,8\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+"-10,-1,true,true,1.0);");
	oxy("trArmySelect(\"2,9\");");
	oxy("trUnitMoveToPoint("+xsVectorGetX(LocTown1ID)+","+xsVectorGetY(LocTown1ID)+","+xsVectorGetZ(LocTown1ID)+",-1,true,true,1.0);");
	oxy("xsEnableRule(\"_AIMove01\");");
	oxy("xsDisableRule(\"_AIAttackTC04\");");
	oxy("}");
	oxyZ("} /*");



	// ******************************************** Trigger End ********************************************
	oxy("rule _Temp inactive { if(true){");
	oxyZ("xsDisableSelf();");
	// *****************************************************************************************************


/* //----------------------------------------------------------------------------------------------------------- //
						// ---------Test--------- //
	for(i=1;<=cNumberNonGaiaPlayers)
	{
	rmCreateTrigger("AIAttack"+i);
	rmSwitchToTrigger(rmTriggerID("AIAttack"+i));
	rmSetTriggerPriority(3); 
	rmSetTriggerActive(true);
	rmSetTriggerRunImmediately(true);
	rmSetTriggerLoop(false);
	rmAddTriggerEffect("Army Deploy");
//	rmSetTriggerEffectParam("SrcArmy","AIShipsAttack", false);
	rmSetTriggerEffectParamArmy("SrcArmy",i,0,false);
	rmSetTriggerEffectParam("ProtoName","Frigate", false);
	rmSetTriggerEffectParam("Location",""+xsVectorGetX(LocFlag2)+","+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2), false);
	rmSetTriggerEffectParamInt("Count",3, false);
	rmSetTriggerEffectParamInt("Heading",0, false);
	rmSetTriggerEffectParam("Clear","true", false);



	}

	oxy("rule _AIAttack"+i+" active runImmediately { ");
	oxy("if((trTime()-cActivationTime) >= 0.00000000){");
	oxy("trArmyDispatch(\""+i+",0\",\"Frigate\",3,"+xsVectorGetX(LocFlag2)+","+xsVectorGetY(LocFlag2)+","+xsVectorGetZ(LocFlag2)+",0,true);");
	oxy("xsDisableRule(\"_AIAttack"+i+"\");");
	oxyZ("}} /*");
*/ //----------------------------------------------------------------------------------------------------------- //

	// Text
	rmSetStatusText("",1.00);


	} //END
	
	
	
/* */