//==========================================================================================
//
//	Supply (Winter Edition) - supply_we.gm
//
//	Who            	When		What
//------------------------------------------------------------------------------------------
//  Mateos      10 March 2014   Minor update
//  Mateos      14 March 2013   Adapted to supply_we
//	crapshoot	29 April 2010	Initial Script (supply.gm)
//
//==========================================================================================

global Map =
{
	Debug = 0,

	// Dyno counters
	Crane_Controls_Dyno = 0,
	Depot_Fence_Dyno = 0,
	Depot_Gate_Dyno = 0,
	East_Depot_Wall_Dyno = 0,
	Forward_Bunker_Gate_Dyno = 0,
	Forward_spawn_rear_exit_Dyno = 0,
	West_Depot_Wall_Dyno = 0,

	// Objective status
	FlagStatus = 0, // Nobody owns it. 1 = axis, 2 = allied
	BunkerGateStatus = false, // Intact
	RearExitStatus = false, // Intact
	CPStatus = 0, // Nobody owns it. 1 = axis, 2 = allied
	DepotGateStatus = false, // Intact
	WestWallStatus = false, // Intact
	EastWallStatus = false, // Intact
	TruckInPosition = false, // Truck is not ready for gold loading
	ControlsBuilt = false, // Crane controls are not built
	CraneActivated = false, // Crane has not been activated

	// Shift status
	ShiftedToCraneControls = false, // Axis have not shifted to crane control defense

	// Delay dispense ammo a bit so they will use arty goals right away
	DispenseAmmoTime = 12,

	// Paththrough Navigation for special instructions at specific waypoints
	Navigation =
	{
		// Some quick jumping for rails and gaps
		quickjump =
		{
			navigate = function(_this)
			{
				_this.Bot.PressButton(BTN.JUMP);
				sleep(0.25);
			},
		},
	},

	// Region trigger for alerting the axis bots when enemies are getting close to the controls
	AxisFallback =
	{
		Name = "AxisFallback",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			// Son't do anything if the depot hasn't been breached
			if ( !Map.DepotBreached() ) {
				return;
			}

			// Only trigger it on the first allied player through
			if ( !Map.ShiftedToCraneControls && GetEntTeam(ent) == TEAM.ALLIES ) {
				// Mark it as triggered
				Map.ShiftedToCraneControls = true;

				// And shift the defense
				Util.DisableGroup( "rinnerdepot", TEAM.AXIS );
				SetAvailableMapGoals( TEAM.AXIS, false, "PLANTMINE_.*" );
				Util.EnableGroup( "rcranecontrols", TEAM.AXIS ); // defend, callartillery

				Util.MapDebugPrint("AxisFallback");
			}
		},
	},

	// Is the forward gate or door breached?
	BunkerBreached = function()
	{
		if ( Map.RearExitStatus || Map.BunkerGateStatus ) {
			return true;
		}

		return false;
	},

	Command_Post_Built_Allied = function( trigger )
	{
		// Mark the CP as owned by Allies
		Map.CPStatus = 2;

		// Don't shift if Bunker hasn't been breached ( humans snuck through and built )
		if ( !Map.BunkerBreached() ) {
			return;
		}

		// And shift everyone to the outer Depot goals
		Map.ShiftToOuterDepot();

		// Allies should get the Truck now
		SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );

		// And spawn at the CP
		Util.ChangeSpawn( TEAM.ALLIES, 4 );

		Util.MapDebugPrint( "Command_Post_Built" );
	},

	Command_Post_Built_Axis = function( trigger )
	{
		// Mark the CP as owned by Axis
		Map.CPStatus = 1;

		Util.MapDebugPrint( "Command_Post_Built" );
	},

	Command_Post_Destroyed_Allied = function( trigger )
	{
		// Nobody owns the CP when it's not constructed
		Map.CPStatus = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	Command_Post_Destroyed_Axis = function( trigger )
	{
		// Nobody owns the CP when it's not constructed
		Map.CPStatus = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	Crane_Activated = function( trigger )
	{
		// Mark the crane as activated
		Map.CraneActivated = true;

		// And shift focus to Truck
		Util.DisableGroup( "rcranecontrols", TEAM.AXIS );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANT_Crane_Controls",
			"BUILD_Depot_Fence",
		});
		Util.DisableGroup( "binnerdepot", TEAM.ALLIES );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SWITCH_crane",
			"PLANT_Depot_Fence",
			"DEFUSE_Crane_Controls.*",
		});
		SetGoalPriority( "DEFUSE_Crane_Controls.*", 0.0, TEAM.ALLIES, CLASS.ENGINEER, true );

		// Re-use some of the axis inner depot defense
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_rInnerDepot[123456]",
			"DEFEND_rCrateLoad.*",
			"CALLARTILLERY_rInnerDepot.*",
			"ARTILLERY_S_rInnerDepot.*",
			"PLANTMINE_rEastWall.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_bTruckAssist.*",
			"ATTACK_bEscape.*",
		});

		Util.MapDebugPrint( "Crane_Activated" );
	},

	Crane_Controls_Built = function( trigger )
	{
		// Mark the controls as built
		Map.ControlsBuilt = true;

		// Always enable the plant, no matter when it's built
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Crane_Controls" );

		// Enable the switch if truck is in postion
		if ( Map.TruckInPosition && !Map.CraneActivated ) {
			SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_crane" );
		}

		Util.MapDebugPrint( "Crane_Controls_Built" );
	},

	Crane_Controls_Defused = function( trigger )
	{
		// One less dyno at the crane controls
		Map.Crane_Controls_Dyno -= 1;

		Util.MapDebugPrint( "Crane_Controls_Defused" );
	},

	Crane_Controls_Destroyed = function( trigger )
	{
		// Reset the dyno counter
		Map.Crane_Controls_Dyno = 0;

		// Mark the controls as not built
		Map.ControlsBuilt = false;

		// Always disable the switch
		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_crane" );

		Util.MapDebugPrint( "Crane_Controls_Destroyed" );
	},

	Crane_Controls_Planted = function( trigger )
	{
		// One more dyno at the crane controls
		Map.Crane_Controls_Dyno += 1;

		Util.MapDebugPrint( "Crane_Controls_Planted" );
	},

	Crate_Loaded = function( trigger )
	{
		// Escort the truck
		SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );

		// And shift to rear depot
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_rCrateLoad.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_bTruckAssist.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_rRearDepot.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_bRearDepot.*" );

		Util.MapDebugPrint( "Crate_Loaded" );
	},

	// Is the depot breached?
	DepotBreached = function()
	{
		if ( Map.DepotGateStatus || Map.WestWallStatus || Map.EastWallStatus ) {
			return true;
		}

		return false;
	},

	Depot_Fence_Built = function( trigger )
	{
		Util.MapDebugPrint( "Depot_Fence_Built" );
	},

	Depot_Fence_Defused = function( trigger )
	{
		// One less dyno at the depot fence
		Map.Depot_Fence_Dyno -= 1;

		Util.MapDebugPrint( "Depot_Fence_Defused" );
	},

	Depot_Fence_Destroyed = function( trigger )
	{
		// Reset the dyno counter
		Map.Depot_Fence_Dyno = 0;

		Util.MapDebugPrint( "Depot_Fence_Destroyed" );
	},

	Depot_Fence_Planted = function( trigger )
	{
		// One more dyno at the depot fence
		Map.Depot_Fence_Dyno += 1;

		Util.MapDebugPrint( "Depot_Fence_Planted" );
	},

	Depot_Gate_Defused = function( trigger )
	{
		// One less dyno at the depot gate
		Map.Depot_Gate_Dyno -= 1;

		Util.MapDebugPrint( "Depot_Gate_Defused" );
	},

	Depot_Gate_Destroyed = function( trigger )
	{
		// Reset the dyno counter
		Map.Depot_Gate_Dyno = 0;

		// Mark the depot gate as destroyed
		Map.DepotGateStatus = true;

		// Shift everyone to inside the depot
		Map.ShiftToInnerDepot();

		Util.MapDebugPrint( "Depot_Gate_Destroyed" );
	},

	Depot_Gate_Planted = function( trigger )
	{
		// One more dyno at the depot gate
		Map.Depot_Gate_Dyno += 1;

		Util.MapDebugPrint( "Depot_Gate_Planted" );
	},

	East_Depot_Wall_Defused = function( trigger )
	{
		// One less dyno at the east depot wall
		Map.East_Depot_Wall_Dyno -= 1;

		Util.MapDebugPrint( "East_Depot_Wall_Defused" );
	},

	East_Depot_Wall_Destroyed = function( trigger )
	{
		// Reset the dyno counter
		Map.East_Depot_Wall_Dyno = 0;

		// Mark the east wall as destroyed
		Map.EastWallStatus = true;

		// And shift the defense a bit
		Map.ShiftToInnerDepot();

		Util.MapDebugPrint( "East_Depot_Wall_Destroyed" );
	},

	East_Depot_Wall_Planted = function( trigger )
	{
		// One more dyno at the east depot wall
		Map.East_Depot_Wall_Dyno += 1;

		// Only defuse sides if main isn't destroyed
		SetAvailableMapGoals( TEAM.AXIS, !Map.DepotGateStatus, "DEFUSE_East_Depot.*" );

		Util.MapDebugPrint( "East_Depot_Wall_Planted" );
	},

	Forward_Bunker_Gate_Defused = function( trigger )
	{
		// One less dyno at the forward bunker gate
		Map.Forward_Bunker_Gate_Dyno -= 1;

		Util.MapDebugPrint( "Forward_Bunker_Gate_Defused" );
	},

	Forward_Bunker_Gate_Destroyed = function( trigger )
	{
		// Reset the dyno counter
		Map.Forward_Bunker_Gate_Dyno = 0;

		// Mark the forward bunker gate as destroyed
		Map.BunkerGateStatus = true;

		// Axis goals
		Map.ShiftToCP();

		Util.MapDebugPrint( "Forward_Bunker_Gate_Destroyed" );
	},

	Forward_Bunker_Gate_Planted = function( trigger )
	{
		// One more dyno at the forward bunker gate
		Map.Forward_Bunker_Gate_Dyno += 1;

		// Axis should not try and defuse if they have already shifted
		if ( Map.BunkerBreached() ) {
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Forward_Bunker.*" );
		}

		Util.MapDebugPrint( "Forward_Bunker_Gate_Planted" );
	},

	Forward_spawn_rear_exit_Defused = function( trigger )
	{
		// One less dyno at the rear spawn exit
		Map.Forward_spawn_rear_exit_Dyno -= 1;

		Util.MapDebugPrint( "Forward_spawn_rear_exit_Defused" );
	},

	Forward_spawn_rear_exit_Destroyed = function( trigger )
	{
		// Reset the dyno counter
		Map.Forward_spawn_rear_exit_Dyno = 0;

		// Mark the rear spawn exit as destroyed
		Map.RearExitStatus = true;

		// Shift everyone to the command post
		Map.ShiftToCP();
		Util.MapDebugPrint( "Forward_spawn_rear_exit_Destroyed" );
	},

	Forward_spawn_rear_exit_Planted = function( trigger )
	{
		// One more dyno at the rear spawn exit
		Map.Forward_spawn_rear_exit_Dyno += 1;

		// Axis should not try and defuse if they have already shifted
		if ( Map.BunkerBreached() ) {
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Forward_spawn.*" );
		}

		Util.MapDebugPrint( "Forward_spawn_rear_exit_Planted" );
	},

	forwardflag_Allies_Captured = function( trigger )
	{
		// Mark the checkpoint as owned by allies
		Map.FlagStatus = 2;

		Util.MapDebugPrint( "forwardflag_Allies_Captured" );
	},

	forwardflag_Axis_Captured = function( trigger )
	{
		// Mark the checkpoint as owned by axis
		Map.FlagStatus = 1;

		Util.MapDebugPrint( "forwardflag_Axis_Captured" );
	},

	ShiftToCP = function()
	{
		// Clean up any phase 1 goals that may be active
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFUSE_Forward_spawn.*",
			"DEFUSE_Forward_Bunker.*",
		});
		Util.DisableGroup( "rbunker", TEAM.AXIS );
		Util.DisableGroup( "bbunker", TEAM.ALLIES );

		// Make sure allies destroy both bunker plants
		if ( !Map.BunkerGateStatus ) {
			SetGoalPriority( "PLANT_Forward_Bunker_Gate", 0.9 );
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Forward_Bunker_Gate" );
		}

		if ( !Map.RearExitStatus ) {
			SetGoalPriority( "PLANT_Forward_spawn_rear_exit", 0.9 );
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Forward_spawn_rear_exit" );
		}

		// Increase users for the Command Post
		Util.SetMaxUsers( 2, "BUILD_Command_Post" );

		// Remove the role so anyone can plant it now
		Util.ClearRoleForGoals( "PLANT_Command_Post", ROLE.INFILTRATOR );

		// Make sure the CP goals are always active for allies
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_Command_Post",
			"BUILD_Command_Post",
		});

		// If the CP is already built by Allies, shift to the depot
		if ( Map.CPStatus == 2 ) {
			Map.ShiftToOuterDepot();
			return;
		}

		// Enable the CP offense and defense
		Util.EnableGroup( "rcp", TEAM.AXIS ); // defend, artillery, plantmine
		Util.EnableGroup( "bcp", TEAM.ALLIES );	// attack, airstrike

		Util.MapDebugPrint( "ShiftToCP" );
	},

	ShiftToInnerDepot = function()
	{
		// If the truck is already in place, this function is useless.
		// So early return to avoid any conflicting logic
		if ( Map.TruckInPosition ) {
			return;
		}

		// Remove the role so anyone can plant it now
		Util.ClearRoleForGoals( "PLANT_Depot_Fence", ROLE.INFILTRATOR );

		// Make sure axis build the fence on any breach.
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Depot_Fence" );

		// Shift based on which walls are destroyed
		if ( Map.DepotGateStatus ) {
			// Full shift to inside the depot walls
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"ESCORT_truck",
				"ATTACK_bTruckAssist.*",
			});
			Util.DisableGroup( "routerdepot", TEAM.AXIS );
			SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );
			Util.DisableGroup( "bouterdepot", TEAM.ALLIES );
			Util.EnableGroup( "rinnerdepot", TEAM.AXIS ); // defend, callartillery
			Util.EnableGroup( "binnerdepot", TEAM.ALLIES ); // attack, build

			// Make sure the CP offense and defense is disabled in case
			// This happens before Allies build the CP
			Util.DisableGroup( "rcp", TEAM.AXIS );
			Util.DisableGroup( "bcp", TEAM.ALLIES );
		}

		if ( Map.WestWallStatus ) {
			// Bots should use these routes now
			Util.EnableGoal( "ROUTE_westwall.*" );

			// Axis will plant some mines at the west wall
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_rWestWall.*" );
		}

		if ( Map.EastWallStatus ) {
			// Bots should use these routes now
			Util.EnableGoal( "ROUTE_eastwall.*" );

			// Axis will plant some mines at the east wall
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANTMINE_rEastWall.*" );
		}

		Util.MapDebugPrint( "ShiftToInnerDepot" );
	},

	ShiftToOuterDepot = function()
	{
		// Disable the cp offense and defense
		Util.DisableGroup( "rcp", TEAM.AXIS );
		Util.DisableGroup( "bcp", TEAM.ALLIES );

		// Make sure the plant goals are active no matter what
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_Depot_Gate",
			"PLANT_West_Depot_Wall",
			"PLANT_East_Depot_Wall",
		});

		// If the depot gate is already breached, shift to inner depot
		if ( Map.DepotGateStatus ) {
			Map.ShiftToInnerDepot();
			return;
		}

		// Enable the outer depot offense and defense
		Util.EnableGroup( "routerdepot", TEAM.AXIS );
		Util.EnableGroup( "bouterdepot", TEAM.ALLIES );

		Util.MapDebugPrint( "ShiftToOuterDepot" );
	},

	Truck_In_Position = function( trigger )
	{
		// Mark the truck as in position
		Map.TruckInPosition = true;

		// Disable escort until gold is loaded
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ESCORT_truck",
			"ATTACK_bTruckAssist.*",
		});

		// Enable the switch if the controls are built
		if ( Map.ControlsBuilt ) {
			SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_crane" );
		}

		Util.MapDebugPrint( "Truck_In_Position" );
	},

	// This map does weird stuff to the truck after passing first gate
	// Adding sanity checks for all of them just in case. Could just delete
	// the region triggers as they are first triggered, but I'm going to leave
	// this as an example for other maps that may not have that as an option
	CurrentTriggerBounds = null,
	forwardGateBounds = AABB(-397.000,2155.000,-126.000,-175.000,2540.000,-52.000),
	depotGateBounds = AABB(953.000,244.000,1.000,991.000,282.000,75.000),
	backDepotBounds = AABB(687.000,-2274.000,1.000,725.000,-2236.000,75.000),
	eastDepotBounds = AABB(1482.000,-1576.000,1.000,1520.000,-1538.000,75.000),
	truckEscapeBounds = AABB(686.000,-273.000,1.000,724.000,-235.000,75.000),

	Truck_Location = function(trigger)
	{
		// We need to sanity check the location because the map script
		// appears to do some funky things with the truck entity which causes
		// multiple triggers at the same region
		entBounds = GetEntWorldAABB(trigger.Entity);

		if ( Map.CurrentTriggerBounds && entBounds.Intersects(Map.CurrentTriggerBounds) ) {
			if ( Map.Debug ) {
				DrawAABB(entBounds, COLOR.BLUE, 60);
				DrawAABB(Map.CurrentTriggerBounds, COLOR.RED, 60);
				Util.MapDebugPrint( "double TriggerRegion trigger detected!" );
			}

			// One was erroneously added, subtract it.
			Map.VehicleLocation -= 1;
			return;
		}

		// OK, valid trigger. proceed as normal.
		switch(Map.VehicleLocation)
		{
			case 1: // Truck at the first gate
			{
				Map.CurrentTriggerBounds = Map.forwardGateBounds;
				if ( !Map.BunkerGateStatus ) {
					SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_truck" );
				}
			}
			case 2: // Truck at depot gate
			{
				Map.CurrentTriggerBounds = Map.depotGateBounds;
				if ( !Map.DepotGateStatus ) {
					SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_truck" );
				}
			}
			case 3: // Truck at back depot
			{
				Map.CurrentTriggerBounds = Map.backDepotBounds;

				// Shift to east depot
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_rRearDepot.*" );
				SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_bRearDepot.*" );
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_rEastDepot.*" );
				SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_bEastDepot.*" );
			}
			case 4: // Truck at east depot
			{
				Map.CurrentTriggerBounds = Map.eastDepotBounds;

				// Shift to northeast depot
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_rEastDepot.*" );
				SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_bEastDepot.*" );
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_rNEDepot.*" );
				SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_bNEDepot.*" );

				// Add a region trigger for the gate. added dynamically since
				// We only want the truck to trigger it on the way out
				dg = OnTriggerRegion(Map.truckEscapeBounds,RegionTrigger.VehicleTrigger);
			}
			case 5: // Truck at gate
			{
				Map.CurrentTriggerBounds = Map.eastDepotBounds;

				// Increase number of users headed for the truck
				Util.SetMaxUsersInProgress( 2, "ESCORT_truck" );

				// Shift to the outside
				SetAvailableMapGoals( TEAM.AXIS, false, {
					"DEFEND_rNEDepot.*",
					"DEFEND_rInnerDepot[123456]",
					"PLANTMINE_rEastWall.*",
					"CALLARTILLERY_rInnerDepot.*",
					"ARTILLERY_S_rInnerDepot.*",
				});
				SetAvailableMapGoals( TEAM.ALLIES, false, {
					"ATTACK_bNEDepot.*",
					"ATTACK_bEscape.*",
				});
				Util.EnableGroup( "routerdepot", TEAM.AXIS );
				Util.EnableGroup( "bouterdepot", TEAM.ALLIES );
			}
			case 6: // Truck is outside the gate
			{
				Map.CurrentTriggerBounds = Map.depotGateBounds;

				// Shift to the deliver area
				Util.DisableGroup( "routerdepot", TEAM.AXIS );
				Util.DisableGroup( "bouterdepot", TEAM.ALLIES );
				SetAvailableMapGoals( TEAM.AXIS, true, {
					"DEFEND_rEscape.*",
					"PLANT_Command_Post",
					"BUILD_Command_Post",
				});
				Util.EnableGroup( "bcp", TEAM.ALLIES );
			}
		}

		Util.MapDebugPrint("truck at location " + Map.VehicleLocation, true);
	},

	West_Depot_Wall_Defused = function( trigger )
	{
		// One less dyno at the west depot wall
		Map.West_Depot_Wall_Dyno -= 1;

		Util.MapDebugPrint( "West_Depot_Wall_Defused" );
	},

	West_Depot_Wall_Destroyed = function( trigger )
	{
		// Reset the dyno counter
		Map.West_Depot_Wall_Dyno = 0;

		// Mark the west depot wall as destroyed
		Map.WestWallStatus = true;

		// And shift the defense a bit
		Map.ShiftToInnerDepot();

		Util.MapDebugPrint( "West_Depot_Wall_Destroyed" );
	},

	West_Depot_Wall_Planted = function( trigger )
	{
		// One more dyno at the west depot wall
		Map.West_Depot_Wall_Dyno += 1;

		// Only defuse sides if main isn't destroyed
		SetAvailableMapGoals( TEAM.AXIS, !Map.DepotGateStatus, "DEFUSE_West_Depot.*" );

		Util.MapDebugPrint( "West_Depot_Wall_Planted" );
	},
};

global OnMapLoad = function()
{
	// Adjust goal positions for reachablility
	Util.SetGoalPosition( 29.874, 2384.431, -103.875, "PLANT_Forward_Bunker_Gate" );

	// Ignore the 'dead' flag so the escort goal will work
	Util.AddInvVehicle("MOVER_truck");

	// If test map is on, call the function that starts the testmap sequence
	// Register callback functions
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Command_Post_Built_Allied );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Command_Post_Built_Axis );
	OnTrigger( "The Crane Controls have been constructed.", Map.Crane_Controls_Built );
	OnTrigger( "The Depot Fence has been constructed.", Map.Depot_Fence_Built );
	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 Bunker Gate.", Map.Forward_Bunker_Gate_Planted );
	OnTrigger( "Planted at the Forward spawn rear exit.", Map.Forward_spawn_rear_exit_Planted );
	OnTrigger( "Planted at the West Depot Wall.", Map.West_Depot_Wall_Planted );
	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 Bunker Gate.", Map.Forward_Bunker_Gate_Defused );
	OnTrigger( "Defused at the Forward spawn rear exit.", Map.Forward_spawn_rear_exit_Defused );
	OnTrigger( "Defused at the West Depot Wall.", Map.West_Depot_Wall_Defused );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Command_Post_Destroyed_Allied );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Command_Post_Destroyed_Axis );
	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 Forward Bunker Gate!", Map.Forward_Bunker_Gate_Destroyed );
	OnTrigger( "The Allies have breached the Depot's east wall!", Map.East_Depot_Wall_Destroyed );
	OnTrigger( "The Allies have breached the Depot Gate!", Map.Depot_Gate_Destroyed );
	OnTrigger( "The Allies have opened up the Forward spawn rear exit!", Map.Forward_spawn_rear_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 Allied Truck is in position!", Map.Truck_In_Position );
	OnTrigger( "The Allies have activated the crane!", Map.Crane_Activated );
	OnTrigger( "The Allies have loaded the Gold Crate onto the Truck!", Map.Crate_Loaded );
	OnTrigger( "truck at location", Map.Truck_Location );

	// Disable pushing in the cp spawn area
	cpspawn = OnTriggerRegion(AABB(2319.000,591.000,225.000,2800.000,944.000,336.000),RegionTrigger.DisableBotPush);

	// Vehicle location triggers
	forwardGate = OnTriggerRegion(Map.forwardGateBounds,RegionTrigger.VehicleTrigger);
	depotGate = OnTriggerRegion(Map.depotGateBounds,RegionTrigger.VehicleTrigger);
	backDepot = OnTriggerRegion(Map.backDepotBounds,RegionTrigger.VehicleTrigger);
	eastDepot = OnTriggerRegion(Map.eastDepotBounds,RegionTrigger.VehicleTrigger);

	// Have the axis fall back when enemies get close to crane controls
	mainstairs = OnTriggerRegion(AABB(847.000,-1968.000,161.000,940.000,-1686.000,235.000),Map.AxisFallback);
	topoframp = OnTriggerRegion(AABB(237.000,-1520.000,321.000,364.000,-1475.000,395.000),Map.AxisFallback);

	// Allied bots should prefer to escort from the back at this point
	ETUtil.SetStartIndex("ESCORT_truck", 1);

	// Disable all the goals at map start (except routes)
	Util.DisableGoal( ".*", true );

	// Disable routes to the command post for axis
	Util.DisableGroup( "p2routes", TEAM.AXIS );

	// Disable some routes that are dependant on wall status
	Util.DisableGoal( "ROUTE_westwall.*" );
	Util.DisableGoal( "ROUTE_eastwall.*" );

	// Allied covert ops in disguise can sneak through team doors to destroy these goals
	Util.SetRoleForGoals( "PLANT_Command_Post", ROLE.INFILTRATOR );
	Util.SetRoleForGoals( "PLANT_Depot_Fence", ROLE.INFILTRATOR );

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

	// Defuse these before others
	SetGoalPriority( "DEFUSE_Forward_Bunker_Gate.*", 1.1, TEAM.AXIS, CLASS.ENGINEER, true );
	SetGoalPriority( "DEFUSE_Depot_Gate.*", 1.1, TEAM.AXIS, CLASS.ENGINEER, true );

	// Only have Covert ops destroy the Fence
	SetGoalPriority( "PLANT_Depot_Fence", 0.0, TEAM.ALLIES, CLASS.ENGINEER );

	// Some slightly higher priority camp goals to focus the bots around the Truck
	SetGoalPriority( "ATTACK_bTruckAssist.*", 0.51, TEAM.ALLIES );
	SetGoalPriority( "DEFEND_rCrateLoad.*", 0.51, TEAM.AXIS );
	SetGoalPriority( "ATTACK_bRearDepot.*", 0.51, TEAM.ALLIES );
	SetGoalPriority( "DEFEND_rRearDepot.*", 0.51, TEAM.AXIS );

	// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "PLANT_.*" );
	Util.SetMaxUsers( 10, "SWITCH_.*" );
	Util.SetMaxUsersInUse( 1, "ESCORT_.*" );
	Util.SetMaxUsers( 1, "BUILD_Command_Post" ); // Only one Axis bot at start

	// Shared goals
	Util.EnableGoal( "CHECKPOINT_forwardflag" );

	// Axis goals
	Util.EnableGroup( "rbunker", TEAM.AXIS ); // defend, plantmine, artillery
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );

	// Allied goals
	Util.EnableGroup( "bbunker", TEAM.ALLIES ); // attack, plant
	SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_truck" );

	// Covert ops in disguise can reach these goals at any time
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"PLANT_Command_Post",
		"PLANT_Depot_Fence",
	});

	// Set up routing
	InitializeMapRoutes();

	Util.MapDebugPrint( "Omni-bot map script for Supply (Winter Edition) executed." );
};

global InitializeMapRoutes = function()
{
	// The route tables
	MapRoutes =
	{
		CHECKPOINT_forwardflag =
		{
			ROUTE_FirstAlliedSpawn =
			{
				ROUTE_UpperWest1 = { ROUTE_UpperWest2 = {}, },
				ROUTE_BunkerCentralWest1 = {
					ROUTE_BunkerCentralWest2 = {
						ROUTE_BunkerCentralWest3 = {
							ROUTE_BunkerCentralWest4 = {
							},
						},
					},
				},
				ROUTE_BunkerCentralEast1 = { ROUTE_BunkerCentralEast2 = {}, },
				ROUTE_BunkerTunnel1 = {},
				ROUTE_BunkerTunnel2 = {},
			},
			ROUTE_rDepotSpawn =
			{
				ROUTE_EastDepotStairs = {},
				ROUTE_DepotDoor = {},
			},
		},
		// 1, 2, 3, 9 and 10 sometimes get routed through cp
		DEFEND_rCp1 =
		{
			ROUTE_rDepotSpawn =
			{
				ROUTE_EastDepotStairs =
				{
					ROUTE_cpgate =
					{
						ROUTE_cprear = {},
						ROUTE_cpfront = {},
					},
				},
				ROUTE_DepotDoor =
				{
					ROUTE_cpgate =
					{
						ROUTE_cprear = {},
						ROUTE_cpfront = {},
					},
				},
			},
		},
		DEFEND_rCp4 =
		{
			ROUTE_rDepotSpawn =
			{
				ROUTE_EastDepotStairs = {},
				ROUTE_DepotDoor = {},
			},
		},
		PLANT_Command_Post =
		{
			ROUTE_FlagSpawn =
			{
				ROUTE_DepotTunnelEntrance =
				{
					ROUTE_NorthCpRoad = {},
					ROUTE_SouthCpRoad = {},
				},
				ROUTE_BunkerCliff =
				{
					ROUTE_NorthCpRoad = {},
					ROUTE_SouthCpRoad = {},
					ROUTE_EastBunkerRoad = { ROUTE_NorthCpRoad = {}, },
				},
			},
		},
		ATTACK_bCp1 =
		{
			ROUTE_FlagSpawn =
			{
				ROUTE_DepotTunnelEntrance =
				{
					ROUTE_NorthCpRoad = {},
					ROUTE_SouthCpRoad = {},
				},
				ROUTE_DepotTunnelMid = { ROUTE_DepotTunnelExit = {}, },
				ROUTE_BunkerCliff =
				{
					ROUTE_NorthCpRoad = {},
					ROUTE_SouthCpRoad = {},
					ROUTE_EastBunkerRoad = { ROUTE_NorthCpRoad = {}, },
				},
			},
			// For the truck assist when its close to the finish
			ROUTE_cpspawn =
			{
				ROUTE_cpfront =
				{
					ROUTE_cpgate = {},
					ROUTE_destroyedwall = {},
					ROUTE_SouthCpRoad = {},
				},
				ROUTE_cprear =
				{
					ROUTE_cpgate = {},
					ROUTE_destroyedwall = {},
					ROUTE_SouthCpRoad = {},
				},
			},
		},
		DEFEND_rDepotGate1 =
		{
			ROUTE_rDepotSpawn =
			{
				ROUTE_WestSpawnExit = {},
				ROUTE_EastSpawnExit = {},
			},
		},
		PLANT_Depot_Gate =
		{
			ROUTE_cpspawn =
			{
				ROUTE_cpfront =
				{
					ROUTE_cpgate = {},
					ROUTE_destroyedwall = {},
					ROUTE_SouthCpRoad = {},
				},
				ROUTE_cprear =
				{
					ROUTE_cpgate = {},
					ROUTE_destroyedwall = {},
					ROUTE_SouthCpRoad = {},
				},
			},
			ROUTE_FlagSpawn =
			{
				ROUTE_DepotTunnelEntrance =
				{
					ROUTE_NorthCpRoad = {},
					ROUTE_SouthCpRoad = {},
				},
				ROUTE_DepotTunnelMid = { ROUTE_DepotTunnelExit = {}, },
				ROUTE_BunkerCliff =
				{
					ROUTE_NorthCpRoad = {},
					ROUTE_SouthCpRoad = {},
					ROUTE_EastBunkerRoad = { ROUTE_NorthCpRoad = {}, },
				},
			},
		},
		DEFEND_rInnerDepot1 =
		{
			ROUTE_rDepotSpawn =
			{
				ROUTE_WestSpawnExit = {},
				ROUTE_EastSpawnExit = {},
			},
		},
		BUILD_Crane_Controls =
		{
			ROUTE_FlagSpawn =
			{
				ROUTE_DepotTunnelEntrance =
				{
					ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
					ROUTE_westdepotgate = {},
					ROUTE_eastdepotgate = {},
					ROUTE_eastwall2 = { ROUTE_eastwall1 = {}, },
				},
				ROUTE_DepotTunnelMid =
				{
					ROUTE_DepotTunnelExit =
					{
						ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
						ROUTE_westdepotgate = {},
					},
				},
				ROUTE_BunkerCliff =
				{
					ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
					ROUTE_westdepotgate = {},
					ROUTE_eastdepotgate = {},
					ROUTE_eastwall2 = { ROUTE_eastwall1 = {}, },
					ROUTE_EastBunkerRoad =
					{
						ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
						ROUTE_westdepotgate = {},
						ROUTE_eastdepotgate = {},
						ROUTE_eastwall2 = { ROUTE_eastwall1 = {}, },
					},
				},
			},
			ROUTE_cpspawn =
			{
				ROUTE_cpfront =
				{
					ROUTE_cpgate =
					{
						ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
						ROUTE_westdepotgate = {},
						ROUTE_eastdepotgate = {},
						ROUTE_eastwall2 = { ROUTE_eastwall1 = {}, },
					},
					ROUTE_destroyedwall =
					{
						ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
						ROUTE_westdepotgate = {},
						ROUTE_eastdepotgate = {},
						ROUTE_eastwall2 = { ROUTE_eastwall1 = {}, },
					},
					ROUTE_SouthCpRoad =
					{
						ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
						ROUTE_westdepotgate = {},
						ROUTE_eastdepotgate = {},
						ROUTE_eastwall2 = { ROUTE_eastwall1 = {}, },
					},
				},
				ROUTE_cprear =
				{
					ROUTE_cpgate =
					{
						ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
						ROUTE_westdepotgate = {},
						ROUTE_eastdepotgate = {},
						ROUTE_eastwall2 = { ROUTE_eastwall1 = {}, },
					},
					ROUTE_destroyedwall =
					{
						ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
						ROUTE_westdepotgate = {},
						ROUTE_eastdepotgate = {},
						ROUTE_eastwall2 = { ROUTE_eastwall1 = {}, },
					},
					ROUTE_SouthCpRoad =
					{
						ROUTE_westwall2 = { ROUTE_westwall1 = {}, },
						ROUTE_westdepotgate = {},
						ROUTE_eastdepotgate = {},
						ROUTE_eastwall2 = { ROUTE_eastwall1 = {}, },
					},
				},
			},
		},
		DEFEND_rCraneControls1 =
		{
			ROUTE_rDepotSpawn =
			{
				ROUTE_ccstairs = { Weight = 3, },
				ROUTE_SouthSpawnExit =
				{
					ROUTE_ccstairs = { Weight = 2, },
					ROUTE_ramp = {},
				},
			}
		},
		DEFEND_rCrateLoad1 =
		{
			ROUTE_rDepotSpawn =
			{
				ROUTE_SouthSpawnExit = {},
				ROUTE_bottomstairs = { ROUTE_backdoor = {}, },
				ROUTE_WestSpawnExit = {},
			},
		},
		DEFEND_rRearDepot1 =
		{
			ROUTE_rDepotSpawn =
			{
				ROUTE_SouthSpawnExit = {},
				ROUTE_bottomstairs = { ROUTE_backdoor = {}, },
			},
		},
		DEFEND_rEastDepot1 =
		{
			ROUTE_rDepotSpawn =
			{
				ROUTE_SouthSpawnExit = {},
				ROUTE_bottomstairs = { ROUTE_backdoor = {}, },
				ROUTE_EastSpawnExit = { Weight = 3, },
			},
		},
	};

	// Copy some routes
	MapRoutes.ATTACK_bBunker1 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_bBunker2 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_bBunker3 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_bBunker4 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_bBunker5 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_bBunker6 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_bBunker7 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_bBunker8 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_bBunker9 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.ATTACK_bBunker10 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rCp2 = MapRoutes.DEFEND_rCp1;
	MapRoutes.DEFEND_rCp3 = MapRoutes.DEFEND_rCp1;
	MapRoutes.DEFEND_rCp5 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rCp6 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rCp7 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rCp8 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rCp9 = MapRoutes.DEFEND_rCp1;
	MapRoutes.DEFEND_rCp10 = MapRoutes.DEFEND_rCp1;
	MapRoutes.CALLARTILLERY_rCp1 = MapRoutes.DEFEND_rCp1;
	MapRoutes.CALLARTILLERY_rCp2 = MapRoutes.DEFEND_rCp1;
	MapRoutes.DEFEND_rEscape1 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rEscape2 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rEscape3 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rEscape4 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rEscape5 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rEscape6 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rEscape7 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rEscape8 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rEscape9 = MapRoutes.DEFEND_rCp4;
	MapRoutes.DEFEND_rEscape10 = MapRoutes.DEFEND_rCp4;
	MapRoutes.BUILD_Command_Post = MapRoutes.PLANT_Command_Post;
	MapRoutes.AIRSTRIKE_bCp1 = MapRoutes.PLANT_Command_Post;
	MapRoutes.AIRSTRIKE_bCp2 = MapRoutes.PLANT_Command_Post;
	MapRoutes.ATTACK_bCp2 = MapRoutes.ATTACK_bCp1;
	MapRoutes.ATTACK_bCp3 = MapRoutes.ATTACK_bCp1;
	MapRoutes.ATTACK_bCp4 = MapRoutes.ATTACK_bCp1;
	MapRoutes.ATTACK_bCp5 = MapRoutes.ATTACK_bCp1;
	MapRoutes.ATTACK_bCp6 = MapRoutes.ATTACK_bCp1;
	MapRoutes.ATTACK_bCp7 = MapRoutes.ATTACK_bCp1;
	MapRoutes.ATTACK_bCp8 = MapRoutes.ATTACK_bCp1;
	MapRoutes.ATTACK_bCp9 = MapRoutes.ATTACK_bCp1;
	MapRoutes.ATTACK_bCp10 = MapRoutes.ATTACK_bCp1;
	MapRoutes.DEFEND_rDepotGate2 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.DEFEND_rDepotGate3 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.DEFEND_rDepotGate4 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.DEFEND_rDepotGate5 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.DEFEND_rDepotGate6 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.DEFEND_rDepotGate7 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.DEFEND_rDepotGate8 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.DEFEND_rDepotGate9 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.DEFEND_rDepotGate10 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.CALLARTILLERY_rDepotGate1 = MapRoutes.DEFEND_rDepotGate1;
	MapRoutes.PLANT_West_Depot_Wall = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.PLANT_East_Depot_Wall = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate1 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate2 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate3 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate4 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate5 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate6 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate7 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate8 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate9 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.ATTACK_bDepotGate10 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.AIRSTRIKE_bDepotGate1 = MapRoutes.PLANT_Depot_Gate;
	MapRoutes.DEFEND_rInnerDepot2 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rInnerDepot3 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rInnerDepot4 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rInnerDepot5 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rInnerDepot6 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rInnerDepot7 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rInnerDepot8 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rInnerDepot9 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rInnerDepot10 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rNEDepot1 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rNEDepot2 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rNEDepot3 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.DEFEND_rNEDepot4 = MapRoutes.DEFEND_rInnerDepot1;
	MapRoutes.ATTACK_bTruckAssist1 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bTruckAssist2 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bTruckAssist3 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bTruckAssist4 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot1 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot2 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot3 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot4 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot5 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot6 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot7 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot8 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot9 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bInnerDepot10 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEscape1 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEscape2 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEscape3 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEscape4 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEscape5 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEscape6 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bRearDepot1 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bRearDepot2 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bRearDepot3 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bRearDepot4 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEastDepot1 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEastDepot2 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEastDepot3 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bEastDepot4 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bNEDepot1 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bNEDepot2 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bNEDepot3 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.ATTACK_bNEDepot4 = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.SWITCH_crane = MapRoutes.BUILD_Crane_Controls;
	MapRoutes.DEFEND_rCraneControls2 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.DEFEND_rCraneControls3 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.DEFEND_rCraneControls4 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.DEFEND_rCraneControls5 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.DEFEND_rCraneControls6 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.DEFEND_rCraneControls7 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.DEFEND_rCraneControls8 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.DEFEND_rCraneControls9 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.DEFEND_rCraneControls10 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.CALLARTILLERY_rCraneControls1 = MapRoutes.DEFEND_rCraneControls1;
	MapRoutes.DEFEND_rCrateLoad2 = MapRoutes.DEFEND_rCrateLoad1;
	MapRoutes.DEFEND_rCrateLoad3 = MapRoutes.DEFEND_rCrateLoad1;
	MapRoutes.DEFEND_rCrateLoad4 = MapRoutes.DEFEND_rCrateLoad1;
	MapRoutes.DEFEND_rRearDepot2 = MapRoutes.DEFEND_rRearDepot1;
	MapRoutes.DEFEND_rRearDepot3 = MapRoutes.DEFEND_rRearDepot1;
	MapRoutes.DEFEND_rRearDepot4 = MapRoutes.DEFEND_rRearDepot1;
	MapRoutes.DEFEND_rEastDepot2 = MapRoutes.DEFEND_rEastDepot1;
	MapRoutes.DEFEND_rEastDepot3 = MapRoutes.DEFEND_rEastDepot1;
	MapRoutes.DEFEND_rEastDepot4 = MapRoutes.DEFEND_rEastDepot1;
	MapRoutes.DEFEND_rBunker1 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rBunker2 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rBunker3 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rBunker4 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rBunker5 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rBunker6 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rBunker7 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rBunker8 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rBunker9 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.DEFEND_rBunker10 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.CALLARTILLERY_rBunker1 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.PLANTMINE_rBunker1 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.PLANTMINE_rBunker2 = MapRoutes.CHECKPOINT_forwardflag;
	MapRoutes.PLANTMINE_rBunker3 = MapRoutes.CHECKPOINT_forwardflag;

	// Register the routes
	Util.Routes(MapRoutes);
};
