//==========================================================================================
//
//	supply_pro.gm
//
//	Who              	When			What
//------------------------------------------------------------------------------------------
//	native12		11 September 2010	Initial Script
//				26.09.2010		Final version
//==========================================================================================
//
//	supply_pro.way
//
//	Who              	When			What
//------------------------------------------------------------------------------------------
//	native12		26.09.2010		Final version
//==========================================================================================
//
//	supply_pro_goals.gm
//
//	Who              	When			What
//------------------------------------------------------------------------------------------
//	native12		26.09.2010		Final version
//==========================================================================================
//
//==========================================================================================
//	correction by crapshoot
//	added defuse goal priorities by BubbaG1 13 July 2012

global Map =
{
	talk = 1,
	Command_Post_Dyno = 0,
	Crane_Controls_Dyno = 0,
	Depot_Fence_Dyno = 0,
	Depot_Gate_Dyno = 0,
	East_Depot_Wall_Dyno = 0,
	Forward_Gate_Dyno = 0,
	Forward_Spawn_exit_Dyno = 0,
	West_Depot_Wall_Dyno = 0,
	depot_gate = 0,		//intact
	east_depod_wall = 0,	//intact
	west_depod_wall = 0,	//intact
	depot_fence = 0,	//not builded
	forward_gate = 0,	//intact
	forward_spawn_exit = 0,	//intact
	truck_at_forward_gate = 0,	//not at forward gate
	truck_at_depot_gate = 0,	//not at depot gate
	truck_at_position = 0,
	gold_on_truck = 0,
	truck_status = 1,	//not destroyed
	allies_CP = 0,		//not builded
	crane_controls = 0,	//not builded
	crane_pushed = 0,
	truck_infront_of_gate = 0,
	fbwindow_destroyed = false,

	Navigation =
	{
		// break the glass at forward bunker window. /bot draw_paththrough 1 to see the spots
		fbwindow =
		{
			gotowp = "start_11", // waypoint for the bot to go to before doing anything else
			EvalFunc = function() // if this function returns false, navigation will not run
			{
				return !Map.fbwindow_destroyed;
			},

			navigate = function(_this)
			{
				if ( Map.fbwindow_destroyed ) {
					yield();
					return;
				}

				_this.AddWeaponRequest(WEAPON.KNIFE);
				_this.AddAimRequest(Priority.High, "position", Vector3(-469.875,2373.727,150.217));

				while( !Map.fbwindow_destroyed ) {
					_this.Bot.HoldButton(BTN.ATTACK1, 1);
					yield();
				}

				_this.ReleaseAimRequest();
				_this.ReleaseWeaponRequest();
			},
		},
		//  	/bot waypoint_setproperty paththrough Navigation_PT:navigate11
		//navigate11 =
		//{
		//	navigate = function(_this)
		//	{
		//		wpTable = {};
		//		Wp.GetWaypointByName("navigate_11", wpTable);
		//		if ( _this.Goto(wpTable.position) == EVENT.PATH_SUCCESS )
		//		{
		//			Wp.SetWaypointFlag( "navigate_1", "closed", true);
		//			_this.AddAimRequest(Priority.Low, "facing", wpTable.facing);
		//			_this.Bot.HoldButton(BTN.FORWARD, 0.1);
		//
		//			sleep(1);
		//			Wp.SetWaypointFlag( "navigate_11", "closed", true);
		//		}
		//	},
		//},
	},

	Truck_Built = function()
	{
		if ( Map.truck_at_position == 1 )
		{
			if ( Map.gold_on_truck == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_truck" );
				Util.MapDebugPrint( "^3Truck_Built at position - not loaded" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );
				Util.MapDebugPrint( "^3Truck_Built at position - gold loaded" );
			}
		}
		else if ( Map.truck_at_depot_gate == 1 )
		{
			if ( Map.depot_gate == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_truck" );
				Util.MapDebugPrint( "^3Truck_Built at depot gate - gate not destroyed" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );
				Util.MapDebugPrint( "^3Truck_Built at depot gate - gate destroyed" );
			}
		}
		else if ( Map.truck_at_forward_gate == 1 )
		{
			if ( Map.forward_gate == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_truck" );
				Util.MapDebugPrint( "^3Truck_Built at forward gate - gate not destroyed" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );
				Util.MapDebugPrint( "^3Truck_Built at forward gate - gate destroyed" );
			}
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );

			Util.MapDebugPrint( "^3Truck_Built in map" );
		}


	},

	Truck_damaged = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_truck" );

		if ( Map.truck_at_position == 1 )
		{
			if ( Map.crane_pushed == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Truck" );
				Util.MapDebugPrint( "^3Truck_damaged at position - switch not pushed" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Truck" );
				Util.MapDebugPrint( "^3Truck_damaged at position - switch pushed" );
			}
		}
		else if ( Map.truck_at_depot_gate == 1 )
		{
			if ( Map.depot_gate == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Truck" );
				Util.MapDebugPrint( "^3Truck_damaged at depot gate - gate not destroyed" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Truck" );
				Util.MapDebugPrint( "^3Truck_damaged at depot gate - gate destroyed" );
			}
		}
		else if ( Map.truck_at_forward_gate == 1 )
		{
			if ( Map.forward_gate == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Truck" );
				Util.MapDebugPrint( "^3Truck_damaged at forward gate - gate not destroyed" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Truck" );
				Util.MapDebugPrint( "^3Truck_damaged at forward gate - gate destroyed" );
			}
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Truck" );

			Util.MapDebugPrint( "^3Truck_damaged in map" );
		}
	},

	forwardflag_Axis_Captured = function()
	{
		Util.MapDebugPrint( "^3forwardflag_Axis_Captured" );
	},

	forwardflag_Allies_Captured = function()
	{
		Util.MapDebugPrint( "^3forwardflag_Allies_Captured" );
	},

	TruckAtForwardGate =
 	{
 		Name="TruckAtForwardGate",
		TriggerOnEntity = GetGoal("MOVER_truck").GetEntity(),
 		OnEnter = function(ent)
 		{
 			Map.truck_at_forward_gate = 1;

			SetAvailableMapGoals( TEAM.AXIS, true, "AIRSTRIKE_TruckAtForwardGate" );

			SetGoalPriority( "AIRSTRIKE_TruckAtForwardGate", 0.81, TEAM.AXIS, CLASS.FIELDOPS );

			if ( Map.forward_gate == 0 )	//intact
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_truck" );

				SetGoalPriority( "BUILD_Truck", 0.70, TEAM.ALLIES, CLASS.ENGINEER );

				Util.MapDebugPrint(GetEntName(ent) + " TruckAtForwardGate - Gate not destroyed", true);
			}

			if ( Map.forward_gate == 1 )	//destroyed
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );

				Util.MapDebugPrint(GetEntName(ent) + " TruckAtForwardGate - Gate destroyed", true);
			}
 		},
 		OnExit = function(ent)
 		{
			Map.truck_at_forward_gate = 0;

			SetAvailableMapGoals( TEAM.AXIS, false, "AIRSTRIKE_TruckAtForwardGate" );

			Util.MapDebugPrint(GetEntName(ent) + " exited TruckAtForwardGate trigger", true);
 		},
	},

	Forward_Gate_Planted = function()
	{
		Map.Forward_Gate_Dyno += 1;
		Util.MapDebugPrint( "^3Forward_Gate_Planted" );
	},

	Forward_Gate_Defused = function()
	{
		Map.Forward_Gate_Dyno -= 1;
		Util.MapDebugPrint( "^3Forward_Gate_Defused" );
	},

	Forward_Gate_Destroyed = function()
	{
		Map.Forward_Gate_Dyno = 0;
		Map.forward_gate = 1;	//destroyed

		// spawn allies at forward bunker
		Util.ChangeSpawn( TEAM.ALLIES, 3 );

		truck1 = OnTriggerRegion(AABB(749.208,-10.566,1.125,887.500,194.537,75.125), Map.TruckAtDepotGate);

		SetGoalPriority( "BUILD_Truck", 0.90, TEAM.ALLIES, CLASS.ENGINEER );

		if ( Map.Forward_Spawn_exit_Dyno > 0)
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Forward_Spawn_exit_.*" );
		}
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_start_.*",
			"CHECKPOINT_forwardflag",
			"DEFUSE_Forward_Gate_.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"PLANTMINE_Cave_gate_exit_1",
			"PLANTMINE_Cave_gate_exit_2",
			"PLANTMINE_East_wall_out_.*",
			"PLANTMINE_West_wall_out_.*",
			"DEFEND_Depot_gate_.*",
			"BUILD_Depot_Fence",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_start.*",
			"CHECKPOINT_forwardflag",
			"PLANT_Forward_Gate",
			"MOUNTMG42_437",
			"SNIPE_start_9",
			"REPAIRMG42_437",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Truck" );

		if ( Map.truck_status == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );
		}

		if ( Map.forward_spawn_exit == 0 )
		{
			SetGoalPriority( "PLANT_Forward_Spawn_exit", 0.95, TEAM.ALLIES, CLASS.ENGINEER );

			sleep(1.5);

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"PLANT_Depot_Gate",
				"PLANT_East_Depot_Wall",
				"PLANT_West_Depot_Wall",
				"ATTACK_Depot_gate_.*",
				"ATTACK_East_wall_.*",
				"ATTACK_West_wall_.*",
				"SNIPE_Depot_gate_7",
			});

			SetGoalPriority( "PLANT_Depot_Gate", 0.82, TEAM.ALLIES, CLASS.ENGINEER );

			if ( Map.allies_CP == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_CP_.*" );

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"SNIPE_CP_3",
					"DEFEND_CP_.*",
				});
			}
		}

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"AIRSTRIKE_TruckAtForwardGate",
			"ARTILLERY_S_TruckAtForwardGate_.*",
			"CALLARTILLERY_TruckAtForwardGate_1",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ARTILLERY_S_TruckAtDepotGate_6",
			"CALLARTILLERY_TruckAtDepotGate_5",
			"ARTILLERY_S_TruckAtDepotGate_8",
			"ARTILLERY_S_TruckAtDepotGate_9",
			"ARTILLERY_S_TruckAtDepotGate_10",
			"CALLARTILLERY_TruckAtDepotGate_7",
		});

		Util.MapDebugPrint( "^3Forward_Gate_Destroyed" );
	},

	Forward_Spawn_exit_Planted = function()
	{
		Map.Forward_Spawn_exit_Dyno += 1;

		if ( Map.forward_gate == 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Forward_Spawn_exit_.*" );
		}

		Util.MapDebugPrint( "^3Forward_Spawn_exit_Planted" );
	},

	Forward_Spawn_exit_Defused = function()
	{
		Map.Forward_Spawn_exit_Dyno -= 1;
		Util.MapDebugPrint( "^3Forward_Spawn_exit_Defused" );
	},

	Forward_Spawn_exit_Destroyed = function()
	{
		Map.Forward_Spawn_exit_Dyno = 0;
		Map.forward_spawn_exit = 1;	//destroyed

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Forward_Spawn_exit" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_ForwardSpawn" );

		SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Forward_Spawn_exit_.*" );

		//SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_Cave_gate_exit_1" );
		//SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_Cave_gate_exit_2" );
		//SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_East_wall_out_.*" );
		//SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_West_wall_out_.*" );
		//SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Depot_gate_.*" );
		//SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Depot_Fence" );

		if ( Map.forward_gate == 0 )
		{
			SetGoalPriority( "PLANT_Depot_Gate", 0.82, TEAM.ALLIES, CLASS.ENGINEER );

			sleep(1.5);

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"BUILD_Command_Post",
				"PLANT_Command_Post",
				"PLANT_Depot_Gate",
				"PLANT_East_Depot_Wall",
				"PLANT_West_Depot_Wall",
				"ATTACK_Depot_gate_.*",
				"ATTACK_East_wall_.*",
				"ATTACK_West_wall_.*",
				"SNIPE_Depot_gate_7",
			});

			SetGoalPriority( "DEFEND_start_.*", 0.72, TEAM.AXIS, 0 );

			if ( Map.allies_CP == 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, {
					"SNIPE_CP_3",
					"DEFEND_CP_.*",
				});

				SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_CP_.*" );
			}
		}

		Util.MapDebugPrint( "^3Forward_Spawn_exit_Destroyed" );
	},

	Axis_Command_Post_Built = function()
	{
		Util.MapDebugPrint( "^3Axis_Command_Post_Built" );
	},

	Axis_Command_Post_Destroyed = function()
	{
		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "^3Axis_Command_Post_Destroyed" );
	},

	Allied_Command_Post_Built = function()
	{
		Map.allies_CP = 1;

		SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_CPSpawn_1" );

		if ( Map.truck_infront_of_gate == 1 )
		{
			// allies spawn at CP
			Util.ChangeSpawn( TEAM.ALLIES, 4 );
		}
		else
		{
			// randomly have some bots spawn at cp. the others will stay at the fb
			Util.RandomSpawn( TEAM.ALLIES, 4 );
		}

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"SNIPE_CP_3",
			"DEFEND_CP_.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ARTILLERY_S_TruckAtDepotGate_4",
			"CALLARTILLERY_TruckAtDepotGate_3",
			"PLANT_Command_Post",
			"AMMOCAB_ammocabinet2",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_CP_.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "AMMOCAB_ammocabinet2" );

		Util.MapDebugPrint( "^3Allied_Command_Post_Built" );
	},

	Allied_Command_Post_Destroyed = function()
	{
		Map.Command_Post_Dyno = 0;
		Map.allies_CP = 0;

		SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_CPSpawn_1" );

		// allies spawn back at the fb
		Util.ChangeSpawn( TEAM.ALLIES, 3 );

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANT_Command_Post",
			"AMMOCAB_ammocabinet2",
			"ARTILLERY_S_TruckAtDepotGate_4",
			"CALLARTILLERY_TruckAtDepotGate_3",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, "AMMOCAB_ammocabinet2" );

		if ( Map.forward_gate == 1 or Map.forward_spawn_exit == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_CP_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"SNIPE_CP_3",
				"DEFEND_CP_.*",
			});
		}
		Util.MapDebugPrint( "^3Allied_Command_Post_Destroyed" );
	},

	Command_Post_Planted = function()
	{
		Map.Command_Post_Dyno += 1;
		Util.MapDebugPrint( "^3Command_Post_Planted" );
	},

	Command_Post_Defused = function()
	{
		Map.Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "^3Command_Post_Defused" );
	},

	TruckAtDepotGate =
 	{
 		Name="TruckAtDepotGate",
		TriggerOnEntity = GetGoal("MOVER_truck").GetEntity(),
 		OnEnter = function(ent)
 		{
 			Map.truck_at_depot_gate = 1;

			SetAvailableMapGoals( TEAM.AXIS, true, "AIRSTRIKE_TruckAtDepotGate_.*" );

			SetGoalPriority( "AIRSTRIKE_TruckAtDepotGate_2", 0.81, TEAM.AXIS, CLASS.FIELDOPS );

			if ( Map.depot_gate == 0 )	//intact
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_truck" );

				SetGoalPriority( "BUILD_Truck", 0.70, TEAM.ALLIES, CLASS.ENGINEER );

				Util.MapDebugPrint(GetEntName(ent) + " TruckAtDepotGate - Gate not destroyed", true);
			}

			if ( Map.depot_gate == 1 )	//destroyed
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );

				Util.MapDebugPrint(GetEntName(ent) + " TruckAtDepotGate - Gate destroyed", true);
			}
 		},
 		OnExit = function(ent)
 		{
			Map.truck_at_depot_gate = 0;

			SetAvailableMapGoals( TEAM.AXIS, false, "AIRSTRIKE_TruckAtDepotGate_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, "AIRSTRIKE_TruckPastDepotGate" );
			SetGoalPriority( "AIRSTRIKE_TruckPastDepotGate", 0.81, TEAM.AXIS, CLASS.FIELDOPS );

			Util.MapDebugPrint(GetEntName(ent) + " exited TruckAtDepotGate trigger", true);
 		},
	},

	Depot_Gate_Planted = function()
	{
		Map.Depot_Gate_Dyno += 1;
		Util.MapDebugPrint( "^3Depot_Gate_Planted" );
	},

	Depot_Gate_Defused = function()
	{
		Map.Depot_Gate_Dyno -= 1;
		Util.MapDebugPrint( "^3Depot_Gate_Defused" );
	},

	Depot_Gate_Destroyed = function()
	{
		Map.Depot_Gate_Dyno = 0;
		Map.depot_gate = 1;	//destroyed

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_Depot_gate_.*",
			"SNIPE_Depot_gate_.*",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Truck" );

		SetGoalPriority( "BUILD_Truck", 0.90, TEAM.ALLIES, CLASS.ENGINEER );

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_Fence_.*",
			"DEFEND_Crane_controls_5",
			"DEFEND_Crane_controls_6",
		});

		SetGoalPriority( "DEFEND_Depot_gate_.*", 0.45, TEAM.AXIS, 0 );

		if ( Map.truck_status == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );
		}

		if ( Map.west_depod_wall == 0 && Map.east_depod_wall == 0 )	//both intact
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"AMMOCAB_ammocabinet",
				"HEALTHCAB_healthcabinet",
			});

			sleep(1.5);
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"AMMOCAB_ammocabinet",
				"HEALTHCAB_healthcabinet",
				"PLANT_Depot_Fence",
				"BUILD_Crane_Controls",
			});

			SetGoalPriority( "PLANT_Depot_Fence", 0.60, TEAM.ALLIES, CLASS.ENGINEER );
			SetGoalPriority( "BUILD_Crane_Controls", 0.80, TEAM.ALLIES, CLASS.ENGINEER );
		}

		if ( Map.west_depod_wall == 1 && Map.east_depod_wall == 1 && Map.depot_gate == 1 )
		{
			SetGoalPriority( "BUILD_Crane_Controls", 0.90, TEAM.ALLIES, CLASS.ENGINEER );
		}

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_Fence_.*",
			"ATTACK_Crane_controls_1",
			"ATTACK_Crane_controls_2",
		});

		Util.MapDebugPrint( "^3Depot_Gate_Destroyed" );
	},

	East_Depot_Wall_Planted = function()
	{
		Map.East_Depot_Wall_Dyno += 1;
		Util.MapDebugPrint( "^3East_Depot_Wall_Planted" );
	},

	East_Depot_Wall_Defused = function()
	{
		Map.East_Depot_Wall_Dyno -= 1;
		Util.MapDebugPrint( "^3East_Depot_Wall_Defused" );
	},

	East_Depot_Wall_Destroyed = function()
	{
		Map.East_Depot_Wall_Dyno = 0;
		Map.east_depod_wall = 1;	//destroyed

		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_East_wall_.*" );

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"ROUTE_AirstrikeTruckExit20_4",
			"ROUTE_AirstrikeTruckExit20_5",
		});

		if ( Map.west_depod_wall == 0 && Map.depot_gate == 0 )	//both intact
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"AMMOCAB_ammocabinet",
				"HEALTHCAB_healthcabinet",
			});

			sleep(1.5);
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"AMMOCAB_ammocabinet",
				"HEALTHCAB_healthcabinet",
				"PLANT_Depot_Fence",
			});

			SetGoalPriority( "PLANT_Depot_Fence", 0.60, TEAM.ALLIES, CLASS.ENGINEER );
			SetGoalPriority( "BUILD_Crane_Controls", 0.80, TEAM.ALLIES, CLASS.ENGINEER );
		}

		if ( Map.west_depod_wall == 1 && Map.east_depod_wall == 1 && Map.depot_gate == 1 )
		{
			SetGoalPriority( "BUILD_Crane_Controls", 0.90, TEAM.ALLIES, CLASS.ENGINEER );
		}

		Util.MapDebugPrint( "^3East_Depot_Wall_Destroyed" );
	},

	West_Depot_Wall_Planted = function()
	{
		Map.West_Depot_Wall_Dyno += 1;
		Util.MapDebugPrint( "^3West_Depot_Wall_Planted" );
	},

	West_Depot_Wall_Defused = function()
	{
		Map.West_Depot_Wall_Dyno -= 1;
		Util.MapDebugPrint( "^3West_Depot_Wall_Defused" );
	},

	West_Depot_Wall_Destroyed = function()
	{
		Map.West_Depot_Wall_Dyno = 0;
		Map.west_depod_wall = 1;	//destroyed

		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_West_wall_.*" );

		if ( Map.east_depod_wall == 0 && Map.depot_gate == 0 )	//both intact
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"AMMOCAB_ammocabinet",
				"HEALTHCAB_healthcabinet",
			});

			sleep(1.5);
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"AMMOCAB_ammocabinet",
				"HEALTHCAB_healthcabinet",
				"PLANT_Depot_Fence",
			});

			SetGoalPriority( "PLANT_Depot_Fence", 0.60, TEAM.ALLIES, CLASS.ENGINEER );
			SetGoalPriority( "BUILD_Crane_Controls", 0.80, TEAM.ALLIES, CLASS.ENGINEER );
		}

		if ( Map.west_depod_wall == 1 && Map.east_depod_wall == 1 && Map.depot_gate == 1 )
		{
			SetGoalPriority( "BUILD_Crane_Controls", 0.90, TEAM.ALLIES, CLASS.ENGINEER );
		}

		Util.MapDebugPrint( "^3West_Depot_Wall_Destroyed" );
	},

	Depot_Fence_Built = function()
	{
		Util.MapDebugPrint( "^3Depot_Fence_Built" );

		if ( Map.west_depod_wall == 0 && Map.east_depod_wall == 0 && Map.depot_gate == 0 )	//all intact
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Depot_Fence" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Depot_Fence" );
		}
	},

	Depot_Fence_Planted = function()
	{
		Map.Depot_Fence_Dyno += 1;
		Util.MapDebugPrint( "^3Depot_Fence_Planted" );
	},

	Depot_Fence_Defused = function()
	{
		Map.Depot_Fence_Dyno -= 1;
		Util.MapDebugPrint( "^3Depot_Fence_Defused" );
	},

	Depot_Fence_Destroyed = function()
	{
		Map.Depot_Fence_Dyno = 0;
		Map.depot_fence = 1;	//destroyed

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Depot_Fence" );

		Util.MapDebugPrint( "^3Depot_Fence_Destroyed" );
	},

	Crane_Controls_Built = function()
	{
		Map.crane_controls = 1;	//builded

		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Crane_Controls" );

		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Crane_Controls" );

		if ( Map.truck_at_position == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Crane_switch" );

			SetGoalPriority( "ATTACK_Crane_switch", 0.90, TEAM.ALLIES, 0 );

			SetGoalPriority( "PLANT_Crane_Controls", 0.99, TEAM.AXIS, CLASS.COVERTOPS );
			SetGoalPriority( "PLANT_Crane_Controls", 0.85, TEAM.AXIS, CLASS.ENGINEER );

			Util.SetMaxUsersInProgress( 3, "ATTACK_Crane_switch" );
		}

		Util.MapDebugPrint( "^3Crane_Controls_Built" );
	},

	Crane_Controls_Planted = function()
	{
		Map.Crane_Controls_Dyno += 1;
		Util.MapDebugPrint( "^3Crane_Controls_Planted" );
	},

	Crane_Controls_Defused = function()
	{
		Map.Crane_Controls_Dyno -= 1;
		Util.MapDebugPrint( "^3Crane_Controls_Defused" );
	},

	Crane_Controls_Destroyed = function()
	{
		Map.Crane_Controls_Dyno = 0;
		Map.crane_controls = 0;	//not builded

		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Crane_Controls" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Crane_Controls" );

		Util.MapDebugPrint( "^3Crane_Controls_Destroyed" );
	},

	truck_at_position = function()
	{
		Map.truck_at_position = 1;

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ESCORT_truck",
			"BUILD_Truck",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"ARTILLERY_S_TruckAtDepotGate_.*",
			"CALLARTILLERY_TruckAtDepotGate_.*",
			"AIRSTRIKE_TruckPastDepotGate",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_Crane_controls_.*",
			"BUILD_Crane_Controls",
		});

		SetGoalPriority( "ATTACK_Crane_controls_.*", 0.70, TEAM.ALLIES, 0 );
		SetGoalPriority( "BUILD_Crane_Controls", 0.91, TEAM.ALLIES, CLASS.ENGINEER );

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Crane_controls_.*" );

		SetGoalPriority( "DEFEND_Crane_controls_.*", 0.79, TEAM.AXIS, 0 );
		SetGoalPriority( "PLANT_Command_Post", 0.40, TEAM.AXIS, CLASS.ENGINEER );
		SetGoalPriority( "PLANT_Command_Post", 0.80, TEAM.AXIS, CLASS.COVERTOPS );

		if ( Map.crane_controls == 1 )	//builded
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Crane_switch" );

			SetGoalPriority( "ATTACK_Crane_switch", 0.55, TEAM.ALLIES, 0 );
			Util.SetMaxUsersInProgress( 3, "ATTACK_Crane_switch" );
		}

		DeleteTriggerRegion("TruckAtDepotGate");

		Util.MapDebugPrint( "^3truck_at_position" );
	},

	crane_activated = function()
	{
		Map.crane_pushed = 1;

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_Crane_controls_.*",
			"ATTACK_Crane_switch",
			"PLANT_Depot_Fence",
			"BUILD_Crane_Controls",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_Crane_controls_.*",
			"PLANT_Crane_Controls",
			"BUILD_Depot_Fence",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Inside_atposition_.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Truck" );

		SetGoalPriority( "DEFEND_Fence_.*", 0.80, TEAM.AXIS, 0 );

		SetGoalPriority( "ATTACK_Fence_.*", 0.55, TEAM.ALLIES, 0 );

		Util.MapDebugPrint( "^3crane_activated" );
	},

	gold_loaded = function()
	{
		Map.gold_on_truck = 1;

		//SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Truck" );

		SetGoalPriority( "DEFEND_Fence_.*", 0.55, TEAM.AXIS, 0 );
		SetGoalPriority( "DEFEND_Inside_atposition_.*", 0.80, TEAM.AXIS, 0 );

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_AtBackSpawnExit_.*" );

		SetGoalPriority( "DEFEND_AtBackSpawnExit_.*", 0.60, TEAM.AXIS, 0 );

		Util.SetMaxUsersInProgress( 2, "ATTACK_Fence_.*" );
		Util.SetMaxUsers( 2, "ATTACK_Fence_.*" );
		Util.SetMaxUsers( 5, "ESCORT_truck" );
		Util.SetMaxUsersInProgress( 5, "ESCORT_truck" );

		if ( Map.truck_status == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );
		}

		//truck2 = OnTriggerRegion(AABB(125.861,-2280.408,1.128,1178.685,-2093.029,75.128), Map.TruckAtBackSpawnExit);
		//truck2 = OnTriggerRegion(AABB(181.431,-2266.690,1.125,1195.414,-2098.716,75.125), Map.TruckAtBackSpawnExit);

		Util.MapDebugPrint( "^3gold_loaded" );
	},

	TruckAtBackSpawnExit =
 	{
 		Name="TruckAtBackSpawnExit",
		TriggerOnEntity = GetGoal("MOVER_truck").GetEntity(),
 		OnEnter = function(ent)
 		{
			Map.truck_at_position = 0;

			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Fence_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, "AIRSTRIKE_TruckEnterAtBack" );

			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Fence_.*" );

			//SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_AtBackSpawnExit_.*" );

			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_AtBackSpawnExit_.*" );

			SetGoalPriority( "DEFEND_Inside_atposition_.*", 0.50, TEAM.AXIS, 0 );
			SetGoalPriority( "DEFEND_AtBackSpawnExit_.*", 0.80, TEAM.AXIS, 0 );

			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_AtEastWall_.*" );

			SetGoalPriority( "DEFEND_AtEastWall_.*", 0.60, TEAM.AXIS, 0 );

			//truck3 = OnTriggerRegion(AABB(1286.917,-2108.882,1.128,1497.039,-963.501,75.128), Map.TruckAtEastWall);
			truck3 = OnTriggerRegion(AABB(979.073,-2298.571,1.125,1500.306,-1312.074,75.125), Map.TruckAtEastWall);

			Util.MapDebugPrint(GetEntName(ent) + " Truck entered TruckAtBackSpawnExit", true);
 		},
 		OnExit = function(ent)
 		{
			Util.MapDebugPrint(GetEntName(ent) + " Truck exited TruckAtBackSpawnExit", true);
 		},
	},

	TruckAtEastWall =
 	{
 		Name="TruckAtEastWall",
		TriggerOnEntity = GetGoal("MOVER_truck").GetEntity(),
 		OnEnter = function(ent)
 		{
 			SetAvailableMapGoals( TEAM.AXIS, false, {
 				"DEFEND_Inside_atposition_.*",
 				"AIRSTRIKE_TruckEnterAtBack",
 			});

			SetAvailableMapGoals( TEAM.AXIS, true, "AIRSTRIKE_TruckEnterEastWall" );

			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_AtBackSpawnExit_.*" );

			//truck4 = OnTriggerRegion(AABB(625.713,-802.717,1.128,1498.121,-241.426,75.128), Map.TruckInfrontOfSpawn);
			//truck4 = OnTriggerRegion(AABB(617.840,-795.335,1.125,1231.650,-499.278,75.125), Map.TruckInfrontOfSpawn);
			truck4 = OnTriggerRegion(AABB(585.107,-1366.928,1.125,1502.488,-657.662,75.125), Map.TruckInfrontOfSpawn);

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_AtBackSpawnExit_6",
				"DEFEND_AtBackSpawnExit_9",
			});

			SetGoalPriority( "DEFEND_AtBackSpawnExit_.*", 0.50, TEAM.AXIS, 0 );

			//SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_AtEastWall_.*" );

			SetGoalPriority( "DEFEND_AtEastWall_.*", 0.90, TEAM.AXIS, 0 );

			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_AtEastWall_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_InfrontOfSpawn_.*" );

			SetGoalPriority( "DEFEND_InfrontOfSpawn_.*", 0.60, TEAM.AXIS, 0 );

			Util.MapDebugPrint(GetEntName(ent) + " Truck entered TruckAtEastWall", true);
 		},
 		OnExit = function(ent)
 		{
			SetAvailableMapGoals( TEAM.AXIS, false, "AIRSTRIKE_TruckEnterEastWall" );

			Util.MapDebugPrint(GetEntName(ent) + " Truck exited TruckAtEastWall", true);
 		},
	},

	TruckInfrontOfSpawn =
 	{
 		Name="TruckInfrontOfSpawn",
		TriggerOnEntity = GetGoal("MOVER_truck").GetEntity(),
 		OnEnter = function(ent)
 		{
 			SetAvailableMapGoals( TEAM.AXIS, false, {
 				"DEFEND_AtBackSpawnExit_.*",
 				"DEFEND_AtEastWall_.*",
 			});

			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_AtEastWall_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_AtEastWall_8",
				"DEFEND_AtEastWall_9",
			});

			SetGoalPriority( "DEFEND_AtEastWall_.*", 0.50, TEAM.AXIS, 0 );

			//SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_InfrontOfSpawn_.*" );

			SetGoalPriority( "DEFEND_InfrontOfSpawn_.*", 0.99, TEAM.AXIS, 0 );

			SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_InfrontOfSpawn_.*" );

			truck5 = OnTriggerRegion(AABB(671.309,-95.816,1.125,1282.687,786.306,161.208), Map.TruckInfrontOfGate);

			Util.SetMaxUsersInProgress( 2, "ATTACK_InfrontOfGate_.*" );
			Util.SetMaxUsers( 2, "ATTACK_InfrontOfGate_.*" );

			Util.MapDebugPrint(GetEntName(ent) + " Truck entered TruckInfrontOfSpawn", true);
 		},
 		OnExit = function(ent)
 		{
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"DEFEND_AtEastWall_9",
				"DEFEND_InfrontOfSpawn_.*",
			});

			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_InfrontOfSpawn_.*" );

			Util.MapDebugPrint(GetEntName(ent) + " Truck exited TruckInfrontOfSpawn", true);
 		},
	},

	TruckInfrontOfGate =
 	{
 		Name="TruckInfrontOfGate",
		TriggerOnEntity = GetGoal("MOVER_truck").GetEntity(),
 		OnEnter = function(ent)
 		{
 			Map.truck_infront_of_gate = 1;

			if ( Map.allies_CP == 1 )
			{
				// allies spawn at the cp
				Util.ChangeSpawn( TEAM.ALLIES, 4 );
			}

			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_.*" );

			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"ATTACK_InfrontOfGate_.*",
				"ARTILLERY_S_TruckAtDepotGate_8",
				"ARTILLERY_S_TruckAtDepotGate_10",
			});
			//SetAvailableMapGoals( TEAM.AXIS, true, "ARTILLERY_S_TruckAtDepotGate_4" );
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"CALLARTILLERY_TruckAtDepotGate_7",
				"AIRSTRIKE_TruckExit_20",
			});

			SetGoalPriority( "ATTACK_InfrontOfGate_.*", 0.95, TEAM.AXIS, 0 );
			SetGoalPriority( "AIRSTRIKE_TruckExit_20", 0.97, TEAM.AXIS, 0 );
			SetGoalPriority( "CALLARTILLERY_TruckAtDepotGate_7", 0.96, TEAM.AXIS, 0 );
			SetGoalPriority( "ARTILLERY_S_TruckAtDepotGate_.*", 0.96, TEAM.AXIS, 0 );

			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_InfrontOfGate_.*" );

			Util.SetMaxUsersInProgress( 2, "ATTACK_TruckExit_.*" );
			Util.SetMaxUsers( 2, "ATTACK_TruckExit_.*" );

			Util.MapDebugPrint(GetEntName(ent) + " Truck entered TruckInfrontOfGate", true);
 		},
 		OnExit = function(ent)
 		{
			SetAvailableMapGoals( TEAM.AXIS, false, {
				"ATTACK_.*",
				"ARTILLERY_S_TruckAtDepotGate_.*",
			});

			SetAvailableMapGoals( TEAM.AXIS, true, {
				"ATTACK_TruckExit_.*",
				"ARTILLERY_S_TruckAtDepotGate_11",
				"AIRSTRIKE_TruckExit_21",
			});

			SetGoalPriority( "ATTACK_TruckExit_.*", 0.95, TEAM.AXIS, 0 );
			SetGoalPriority( "AIRSTRIKE_TruckExit_21", 0.97, TEAM.AXIS, 0 );

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"DEFEND_CP_4",
				"DEFEND_CP_5",
				"DEFEND_TruckExit_7",
			});

			Util.MapDebugPrint(GetEntName(ent) + " Truck exited TruckInfrontOfGate", true);
 		},
	},

	allies_win = function()
	{
		ETUtil.WinningChat( TEAM.ALLIES );
		ETUtil.LosingChat( TEAM.AXIS );
		Util.MapDebugPrint( "^3allies_win" );
	},

	fbwindow_exploded = function()
	{
		Map.fbwindow_destroyed = true;
		SetGoalPriority( "DEFEND_start_11", 0.5, TEAM.AXIS, 0 );
		Util.MapDebugPrint( "fbwindow_exploded", true );
	},
};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "The Crane Controls have been constructed.", Map.Crane_Controls_Built );
	OnTrigger( "The Depot Fence has been constructed.", Map.Depot_Fence_Built );
	OnTrigger( "The Truck has been repaired!", Map.Truck_Built );
	OnTrigger( "The Truck has been damaged!", Map.Truck_damaged );
	OnTrigger( "Planted at the Command Post.", Map.Command_Post_Planted );
	OnTrigger( "Planted at the Crane Controls.", Map.Crane_Controls_Planted );
	OnTrigger( "Planted at the Depot Fence.", Map.Depot_Fence_Planted );
	OnTrigger( "Planted at the Depot Gate.", Map.Depot_Gate_Planted );
	OnTrigger( "Planted at the East Depot Wall.", Map.East_Depot_Wall_Planted );
	OnTrigger( "Planted at the Forward Gate.", Map.Forward_Gate_Planted );
	OnTrigger( "Planted at the Forward Spawn exit.", Map.Forward_Spawn_exit_Planted );
	OnTrigger( "Planted at the West Depot Wall.", Map.West_Depot_Wall_Planted );
	OnTrigger( "Defused at the Command Post.", Map.Command_Post_Defused );
	OnTrigger( "Defused at the Crane Controls.", Map.Crane_Controls_Defused );
	OnTrigger( "Defused at the Depot Fence.", Map.Depot_Fence_Defused );
	OnTrigger( "Defused at the Depot Gate.", Map.Depot_Gate_Defused );
	OnTrigger( "Defused at the East Depot Wall.", Map.East_Depot_Wall_Defused );
	OnTrigger( "Defused at the Forward Gate.", Map.Forward_Gate_Defused );
	OnTrigger( "Defused at the Forward Spawn exit.", Map.Forward_Spawn_exit_Defused );
	OnTrigger( "Defused at the West Depot Wall.", Map.West_Depot_Wall_Defused );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "The Crane Controls have been destroyed.", Map.Crane_Controls_Destroyed );
	OnTrigger( "The Depot Fence has been destroyed.", Map.Depot_Fence_Destroyed );
	OnTrigger( "The Allies have breached the Depot Gate!", Map.Depot_Gate_Destroyed );
	OnTrigger( "The Allies have breached the Depot's east wall!", Map.East_Depot_Wall_Destroyed );
	OnTrigger( "The Allies have breached the Forward Bunker Gate!", Map.Forward_Gate_Destroyed );
	OnTrigger( "The Allies have opened up the Forward spawn rear exit!", Map.Forward_Spawn_exit_Destroyed );
	OnTrigger( "The Allies have breached the Depot's west wall!", Map.West_Depot_Wall_Destroyed );
	OnTrigger( "The Axis have captured the forward bunker!", Map.forwardflag_Axis_Captured );
	OnTrigger( "The Allies have captured the forward bunker!", Map.forwardflag_Allies_Captured );
	OnTrigger( "The Allies have activated the crane!", Map.crane_activated );
	OnTrigger( "The Allies have loaded the Gold Crate onto the Truck!", Map.gold_loaded );
	OnTrigger( "The Allied Truck is in position!", Map.truck_at_position );
	OnTrigger( "The Allies have escaped with the Gold Crate!", Map.allies_win );
	OnTrigger( "GRENADE_fbwindow Exploded.", Map.fbwindow_exploded );

	SetAvailableMapGoals( TEAM.ALLIES, false, ".*" );

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"BUILD_Truck",
		"ESCORT_truck",
		"ATTACK_start_.*",
		"CHECKPOINT_forwardflag",
		"PLANT_Forward_Gate",
		"PLANT_Forward_Spawn_exit",
		"MOUNTMG42_437",
		"REPAIRMG42_437",
		"SNIPE_start_9",
		"ROUTE_.*",
	});

	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"ROUTE_ForwardSpawn",
		"ROUTE_CPSpawn_1",
	});

	SetAvailableMapGoals( TEAM.AXIS, false, ".*" );

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"DEFEND_start_.*",
		"CHECKPOINT_forwardflag",
		"BUILD_Command_Post",
		"ARTILLERY_S_TruckAtForwardGate_.*",
		"CALLARTILLERY_TruckAtForwardGate_1",
	});

	// goal priorities
	SetGoalPriority( "PLANT_Forward_Gate", 0.85, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "MOUNTMG42_437", 0.50, TEAM.ALLIES, 0 );
	SetGoalPriority( "MOUNTMG42_437", 0.70, TEAM.ALLIES, CLASS.SOLDIER );
	SetGoalPriority( "DEFUSE_Crane_Controls_.*", 0.10, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Command_Post", 0.40, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "DEFEND_start_11", 0.7, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFUSE_Depot_Gate_.*", 1.20, TEAM.AXIS, CLASS.ENGINEER, true );
	SetGoalPriority( "DEFUSE_Forward_Gate_.*", 1.15, TEAM.AXIS, CLASS.ENGINEER, true );
	SetGoalPriority( "DEFUSE_Forward_Spawn_exit_.*", 1.10, TEAM.AXIS, CLASS.ENGINEER, true );

	// Max users per goal
	Util.SetMaxUsersInProgress( 2, "BUILD_.*" );
	Util.SetMaxUsersInProgress( 1, "DEFUSE_.*" );
	Util.SetMaxUsersInProgress( 5, "CHECKPOINT_.*" );

	// SetMaxUsers sets both In_Use and In_Progress
	Util.SetMaxUsers( 2, "PLANT_.*" );
	Util.SetMaxUsers( 2, "ESCORT_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "BUILD_Command_Post" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=10, MaxCampTime=60} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );

	Wp.SetWaypointFlag( "navigate_1", "closed", false);
	//Wp.SetWaypointFlag( "navigate_11", "closed", false);

	truck0 = OnTriggerRegion(AABB(-1099.941,2293.917,-92.200,-885.467,2469.620,25.918), Map.TruckAtForwardGate);
	//truck2 = OnTriggerRegion(AABB(181.431,-2266.690,1.125,1195.414,-2098.716,75.125), Map.TruckAtBackSpawnExit);
	truck2 = OnTriggerRegion(AABB(-8.712,-2253.196,1.125,922.303,-2079.949,113.079), Map.TruckAtBackSpawnExit);

	MapRoutes =
	{
		//DEFEND_start_10 =
		//{
		//	ROUTE_ForwardSpawn =
		//	{
		//		ROUTE_navigate_1 =
		//		{
		//
		//		},
		//	},
		//},
		CHECKPOINT_forwardflag =
		{
			ROUTE_AllySpawn =
			{
				ROUTE_Cave_right =
				{
					Weight = 2,
					ROUTE_Cave_exit =
					{
						ROUTE_Right_forward_stairs =
						{

						},
						ROUTE_Left_forward_stairs =
						{

						},
					},
				},
				ROUTE_Cave_left =
				{
					Weight = 2,
					ROUTE_Cave_exit =
					{
						ROUTE_Right_forward_stairs =
						{

						},
						ROUTE_Left_forward_stairs =
						{

						},
					},
				},
				ROUTE_Truck_route =
				{
					ROUTE_Truck_route_1 =
					{
						ROUTE_Right_forward_stairs =
						{

						},
						ROUTE_Left_forward_stairs =
						{

						},
					},
				},
				ROUTE_Left_hill_route =
				{
					ROUTE_Left_hill_route_1 =
					{
						ROUTE_Left_hill_route_2 =
						{
							ROUTE_Left_hill_route_3 =
							{

							},
						},
					},
				},
			},
		},
		PLANT_Depot_Gate =
		{
			ROUTE_ForwardSpawn =
			{
				ROUTE_ForwardSpawn_1 =
				{
					ROUTE_ForwardSpawn_2 =
					{
						ROUTE_Cave2_Enter =
						{
							Weight = 2,
							ROUTE_Cave2_Exit =
							{

							},
						},
						ROUTE_Outside_Cave2_1 =
						{
							ROUTE_Outside_Cave2_2 =
							{
								ROUTE_Outside_Cave2_3 =
								{

								},
							},
						},
					},
				},
			},
			ROUTE_CPSpawn_1 =
			{
				ROUTE_CPSpawn_2 =
				{
					ROUTE_CPGate =
					{

					},
					ROUTE_CPWall_1 =
					{
						ROUTE_CPWall_2 =
						{
							ROUTE_Outside_Cave2_2 =
							{
								ROUTE_Outside_Cave2_3 =
								{

								},
							},
						},
						ROUTE_CPLawn =
						{

						},
					},
				},
			},
		},
		DEFEND_Depot_gate_8 =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_AxisSpawnStairs =
				{
					ROUTE_AxisSpawnRightExit =
					{

					},
					ROUTE_AxisSpawnLeftExit =
					{

					},
				},
			},
		},
		DEFEND_Fence_9 =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_AxisSpawnStairs =
				{
					ROUTE_AxisSpawnHealth =
					{

					},
				},
			},
		},
		DEFEND_Fence_6 =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_AxisSpawnStairs =
				{
					ROUTE_AxisSpawnHealth =
					{

					},
					ROUTE_AxisSpawnUpperStairs =
					{

					},
				},
			},
		},
		DEFEND_Fence_5 =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_AxisSpawnStairs =
				{
					ROUTE_AxisSpawnHealth =
					{
						ROUTE_AxisSpawnHealthExit =
						{

						},
					},
				},
				ROUTE_AxisSpawnCave =
				{
					ROUTE_AxisSpawnCave_1 =
					{

					},
				},
			},
		},
		AIRSTRIKE_TruckExit_20 =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_AxisSpawnStairs =
				{
					ROUTE_AxisSpawnRightExit =
					{
						ROUTE_AirstrikeTruckExit20_4 =
						{
							Weight = 2,
							ROUTE_AirstrikeTruckExit20_5 =
							{
								ROUTE_AirstrikeTruckExit20_6 =
								{
									ROUTE_AirstrikeTruckExit20_7 =
									{
										ROUTE_AirstrikeTruckExit20_8 =
										{

										},
									},
								},
							},
						},
						ROUTE_AirstrikeTruckExit20_1 =
						{
							ROUTE_AirstrikeTruckExit20_2 =
							{
								ROUTE_AirstrikeTruckExit20_3 =
								{

								},
							},
						},
					},
				},
			},
		},
	};

	MapRoutes.ATTACK_start_1 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_start_2 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_start_3 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_start_4 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_start_5 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_start_6 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_start_7 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_start_8 = MapRoutes.CHECKPOINT_forwardflag;

	MapRoutes.PLANT_West_Depot_Wall = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.PLANT_East_Depot_Wall = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_Depot_gate_1 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_Depot_gate_2 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_Depot_gate_3 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_Depot_gate_4 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_Depot_gate_5 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_Depot_gate_6 = MapRoutes.PLANT_Depot_Gate;

	MapRoutes.DEFEND_Depot_gate_9 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_Depot_gate_10 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_Depot_gate_11 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_Depot_gate_12 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_Depot_gate_13 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_Depot_gate_14 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_Depot_gate_15 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_Depot_gate_16 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_Depot_gate_17 = MapRoutes.DEFEND_Depot_gate_8;

	MapRoutes.DEFEND_Fence_7 = MapRoutes.DEFEND_Fence_6;
	MapRoutes.DEFEND_Fence_8 = MapRoutes.DEFEND_Fence_6;

	MapRoutes.AIRSTRIKE_TruckPastDepotGate = MapRoutes.DEFEND_Fence_5;

	MapRoutes.DEFEND_Inside_atposition_3 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_Inside_atposition_4 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_Inside_atposition_1 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_Inside_atposition_5 = MapRoutes.DEFEND_Fence_9;
	MapRoutes.DEFEND_Inside_atposition_6 = MapRoutes.DEFEND_Fence_6;
	MapRoutes.DEFEND_Inside_atposition_7 = MapRoutes.DEFEND_Fence_6;
	MapRoutes.DEFEND_Inside_atposition_8 = MapRoutes.DEFEND_Fence_6;

	MapRoutes.DEFEND_AtBackSpawnExit_4 = MapRoutes.DEFEND_Fence_6;
	MapRoutes.DEFEND_AtBackSpawnExit_5 = MapRoutes.DEFEND_Fence_9;
	MapRoutes.DEFEND_AtBackSpawnExit_3 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_AtBackSpawnExit_7 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_AtBackSpawnExit_1 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_AtBackSpawnExit_2 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_AtBackSpawnExit_8 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_AtBackSpawnExit_6 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_AtBackSpawnExit_9 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.AIRSTRIKE_TruckEnterAtBack = MapRoutes.DEFEND_Fence_5;

	MapRoutes.DEFEND_AtEastWall_1 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_AtEastWall_2 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_AtEastWall_3 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.DEFEND_AtEastWall_4 = MapRoutes.DEFEND_Fence_5;
	MapRoutes.AIRSTRIKE_TruckEnterEastWall = MapRoutes.DEFEND_Fence_5;

	MapRoutes.DEFEND_InfrontOfSpawn_1 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_InfrontOfSpawn_2 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_InfrontOfSpawn_3 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_InfrontOfSpawn_4 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_InfrontOfSpawn_5 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_InfrontOfSpawn_6 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_InfrontOfSpawn_7 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.DEFEND_InfrontOfSpawn_8 = MapRoutes.DEFEND_Depot_gate_8;

	MapRoutes.AIRSTRIKE_TruckExit_21 = MapRoutes.AIRSTRIKE_TruckExit_20;

	MapRoutes.ATTACK_InfrontOfGate_1 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.ATTACK_InfrontOfGate_2 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.ATTACK_InfrontOfGate_3 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.ATTACK_InfrontOfGate_4 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.ATTACK_InfrontOfGate_5 = MapRoutes.DEFEND_Depot_gate_8;

	MapRoutes.ATTACK_TruckExit_1 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.ATTACK_TruckExit_2 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.ATTACK_TruckExit_3 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.ATTACK_TruckExit_4 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.ATTACK_TruckExit_5 = MapRoutes.DEFEND_Depot_gate_8;
	MapRoutes.ATTACK_TruckExit_6 = MapRoutes.DEFEND_Depot_gate_8;

	Util.Routes(MapRoutes);

	SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_.*" );

	SetAvailableMapGoals( TEAM.AXIS, true, "ROUTE_.*" );

	SetAvailableMapGoals( TEAM.AXIS, false, {
		"ROUTE_AirstrikeTruckExit20_4",
		"ROUTE_AirstrikeTruckExit20_5",
	});

	Util.MapDebugPrint( "Omni-bot map script for " + GetMapName() + " executed." );
};

global OnBotJoin = function( bot )
{
	// cs: removed all looping of bot tables for the spawns. we get the bot object passed into this function
	if ( Map.forward_gate == 0 )
	{
		bot.ChangeSpawnPoint( 1 ); // Farmhouse spawn
	}
	//else if ( Map.forward_gate == 1 && Map.allies_CP == 0 && Map.truck_infront_of_gate == 0 )
	if ( Map.forward_gate == 1 && Map.allies_CP == 0 && Map.truck_infront_of_gate == 0 )
	{
		bot.ChangeSpawnPoint( 3 ); // Forwardbunker spawn
	}
	//else if ( Map.forward_gate == 1 && Map.allies_CP == 1 && Map.truck_infront_of_gate == 0 )
	if ( Map.forward_gate == 1 && Map.allies_CP == 1 && Map.truck_infront_of_gate == 0 )
	{
		if ( RandInt(0,1) < 1)
		{
			bot.ChangeSpawnPoint( 4 ); // CP
		}
		else
		{
			bot.ChangeSpawnPoint( 3 ); // Forwardbunker spawn
		}
	}
	//else if ( Map.forward_gate == 1 && Map.allies_CP == 0 && Map.truck_infront_of_gate == 1 )
	if ( Map.forward_gate == 1 && Map.allies_CP == 0 && Map.truck_infront_of_gate == 1 )
	{

		bot.ChangeSpawnPoint( 3 ); // Forwardbunker spawn
	}
	//else //if ( Map.forward_gate == 1 && Map.allies_CP == 1 && Map.truck_infront_of_gate == 1 )
	if ( Map.forward_gate == 1 && Map.allies_CP == 1 && Map.truck_infront_of_gate == 1 )
	{
		bot.ChangeSpawnPoint( 4 ); // CP
	}

	bot.TargetBreakableDist = 50.0;
	//	/setspawnpt <number>
	//Axis Spawns:
	//		3 - Axis Forwardbunker spawn (only at start before destroing Forward gate)
	//		2 - Axis Depot spawn

	//Allies Spawns:
	//		1 - Allies Farmhouse spawn
	//		3 - Allies Forwardbunker spawn (after destroing Forward gate)
	//		4 - Allies CP spawn
};
