global Map =
{
	// Conditionals/customization
	TankRampDyno = 0,
	BunkerDyno = 0,
	TankIsPastBunker = false,
	TankIsPastBarrier = false,
	StationSpawnIsPermanent = false,
	StationSpawnAllied = false,
	BarricadeIsBuilt = true,
	Talk = true,
	// Store some goal name strings
	Build_Allied_Command_Post = "BUILD_Allied_Command_Post",
	Build_Axis_Command_Post = "BUILD_Axis_Command_Post",
	Build_Barricade = "BUILD_Barricade",
	Build_Roadblock = "BUILD_Roadblock",
	Build_Tank_Barrier = "BUILD_Tank_Barrier",
	Build_Tiger_Tank = "BUILD_Tiger_Tank",

	Plant_Allied_Command_Post = "PLANT_Allied_Command_Post",
	Plant_Axis_Command_Post = "PLANT_Axis_Command_Post",
	Plant_Bunker_Debris = "PLANT_Bunker_Debris",
	Plant_Collapsed_Tunnel = "PLANT_Collapsed_Tunnel",
	Plant_Footbridge = "PLANT_Footbridge",
	Plant_Railway_Tunnel = "PLANT_Railway_Tunnel",
	Plant_Roadblock = "PLANT_Roadblock",
	Plant_Tank_Barrier = "PLANT_Tank_Barrier",
	Plant_Wrecked_Footbridge = "PLANT_Wrecked_Footbridge",

	Explode_Barricade = "EXPLODE_Barricade",
	Checkpoint_station_flag = "CHECKPOINT_station_flag",

	Mount_bunker_MG = "MOUNTMG42_727",
	Repair_bunker_MG = "REPAIRMG42_727",
	Mount_train_mg42 = "MOUNTMG42_train_mg42",
	Repair_train_mg42 = "REPAIRMG42_train_mg42",

	Mover_tank = "MOVER_tank",
	Bird1 = "MOVER_bird1",
	Bird2 = "MOVER_bird2",
	Bird3 = "MOVER_bird3",
	Bird4 = "MOVER_bird4",

	// Keep these movers
	Movers =
	{
		"MOVER_tank",
		"MOVER_bird1",
		"MOVER_bird2",
		"MOVER_bird3",
		"MOVER_bird4",
	},

	Switches =
	{
		cargo_door =
		{
			Enabled = false,
			Priority = 0.9,
			WaypointName = "cargo_door",
			LimitBots = 1,
			LimitDistance = 2000,
			LimitTeam = Util.AllTeams,
			LimitClass = Util.AllClasses,
			Timeout = 1000,
		},
	},

	// *** TRIGGER CALLBACKS ***

	Barricade_Built = function( trigger )
	{
		Map.BarricadeIsBuilt = true;
		SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_barricade" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ROUTE_barricade" );
		Util.MapDebugPrint( "Barricade_Built" );
	},

	Barricade_Destroyed = function( trigger )
	{
		Map.BarricadeIsBuilt = false;
		SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_barricade" );
		SetAvailableMapGoals( TEAM.AXIS, true, "ROUTE_barricade" );
		Util.MapDebugPrint( "Barricade_Destroyed" );
	},

	station_flag_Axis_Captured = function( trigger )
	{
		Map.StationSpawnAllied = false;
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_checkpoint.*",
			"SNIPE_checkpoint.*",
			"MOBILEMG42_start.*",
			"DEFEND_start.*",
			"SNIPE_start.*",
			Map.Build_Roadblock,
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"GRENADE_barrier1",
			"GRENADE_barrier2",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_checkpoint.*",
			"SNIPE_checkpoint.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Roadblock );
		Util.MapDebugPrint( "station_flag_Axis_Captured" );
	},

	station_flag_Allies_Captured = function( trigger )
	{
		Map.StationSpawnAllied = true;
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_start.*",
			"SNIPE_start.*",
			"MOBILEMG42_start.*",
			"DEFEND_checkpoint.*",
			"SNIPE_checkpoint.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_barrier1" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_barrier2" );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Roadblock );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Build_Roadblock );
		Util.MapDebugPrint( "station_flag_Allies_Captured" );
	},

	StationPermanent = function( trigger )
	{
		Map.StationSpawnAllied = true;
		Map.StationSpawnIsPermanent = true;
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"GRENADE_barrier1",
			"GRENADE_barrier2",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_checkpoint.*",
			"SNIPE_checkpoint.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SNIPE_checkpoint.*",
			"DEFEND_checkpoint.*",
			Map.Plant_Roadblock,
			Map.Checkpoint_station_flag,
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			Map.Checkpoint_station_flag,
			Map.Build_Roadblock,
			Map.Build_Barricade,
		});
		Util.MapDebugPrint( "StationPermanent" );
	},

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

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

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

	Tiger_Tank_Damaged = function( trigger )
	{
		Util.SetPositionGoal( "BUILD_Tiger_Tank", "MOVER_tank" );
		Util.MapDebugPrint( "Tiger_Tank_Damaged", true );
	},

	Tank_In_First_Tunnel = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"SNIPE_footbridge.*",
			"DEFEND_footbridge.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_start.*",
			"SNIPE_start.*",
		});
		Util.MapDebugPrint( "Tank_In_First_Tunnel" );
	},

	Footbridge_Destroyed = function( trigger )
	{
		Wp.SetWaypointFlag("footbridge18", "closed", false);
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Wrecked_Footbridge );
		Util.MapDebugPrint( "Footbridge_Destroyed" );
	},

	Wrecked_Footbridge_Destroyed = function( trigger )
	{
		Wp.SetWaypointFlag("footbridge18", "closed", true);
		Util.MapDebugPrint( "Wrecked_Footbridge_Destroyed" );
	},

	Tank_Past_Footbridge = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_start.*",
			"SNIPE_start.*",
			"DEFEND_footbridge.*",
			"SNIPE_footbridge.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"SNIPE_tb.*",
			"DEFEND_tb.*",
			Map.Build_Tank_Barrier,
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Tank_Barrier );
		SetGoalPriority("DEFEND_start.*", 0.5);
		Util.MapDebugPrint( "Tank_Past_Footbridge" );
	},

	Build_Tank_Ramp = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_tank_ramp.*",
			"SNIPE_tank_ramp.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_ramp" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_ramp" );
		Util.MapDebugPrint( "Build_Tank_Ramp" );
	},

	Tank_Ramp_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_tank_ramp.*",
			"SNIPE_tank_ramp.*",
		});
		SetGoalPriority("DEFEND_start.*", 0.45);
		Util.MapDebugPrint( "Tank_Ramp_Built" );
	},

	Tank_Ramp_Planted = function( trigger )
	{
		Map.TankRampDyno += 1;
		Util.MapDebugPrint( "Tank_Ramp_Planted" );
	},

	Tank_Ramp_Defused = function( trigger )
	{
		Map.TankRampDyno -= 1;
		Util.MapDebugPrint( "Tank_Ramp_Defused" );
	},

	Tank_Ramp_Destroyed = function( trigger )
	{
		Map.TankRampDyno = 0;
		Util.MapDebugPrint( "Tank_Ramp_Destroyed" );
	},

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

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

	Tank_past_Barrier = function( trigger )
	{
		Map.TankIsPastBarrier = true;
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_tunnel.*",
			"SNIPE_tunnel.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOBILEMG42_start.*",
			"DEFEND_tb.*",
			"SNIPE_tb.*",
			"DEFEND_tank_ramp.*",
			"SNIPE_tank_ramp.*",
		});
		Util.MapDebugPrint( "Tank_past_Barrier" );
	},

	Tank_at_Corner = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_2ndTankPath.*",
			"SNIPE_2ndTankPath.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Build_Tank_Barrier );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Tank_Barrier );
		SetGoalPriority("DEFEND_start.*", 0.4);
		SetGoalPriority("DEFEND_2ndTankPath.*", 0.55);
		Util.MapDebugPrint( "Tank_at_Corner" );
	},

	Tunnel_Dyno_Enabled = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_after_tunnel6",
			"DEFEND_after_tunnel7",
			"SNIPE_after_tunnel6",
			"SNIPE_after_tunnel7",
		});
		Util.SetGoalPosition( 1800,-767,32, Map.Plant_Railway_Tunnel );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_Railway_Tunnel );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_ramp" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_ramp" );
		Map.doorthreadid = thread( Map.testTraceLineThread );
		Map.Switches.cargo_door.Enabled = true;
		Util.MapDebugPrint( "Tunnel_Dyno_Enabled" );
	},

	Railway_Tunnel_Destroyed = function( trigger )
	{
		// Path across tunnel rubble is open now
		Wp.SetWaypointFlag("tunnel_debris1", "closed", false);
		Wp.SetWaypointFlag("tunnel_debris2", "closed", false);
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Collapsed_Tunnel );
		Util.MapDebugPrint( "Railway_Tunnel_Destroyed" );
	},

	Railway_Tunnel_Cleared = function( trigger )
	{
		// Path across tunnel rubble is closed again
		Wp.SetWaypointFlag("tunnel_debris1", "closed", true);
		Wp.SetWaypointFlag("tunnel_debris2", "closed", true);
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_after_tunnel.*",
			"SNIPE_after_tunnel.*",
		});
		Util.MapDebugPrint( "Railway_Tunnel_Cleared" );
	},

	Tank_at_Tunnel = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"SNIPE_tb.*",
			"DEFEND_tb.*",
			"DEFEND_2ndTankPath.*",
			"SNIPE_2ndTankPath.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_tunnel.*",
			"SNIPE_tunnel.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Build_Tank_Barrier );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Tank_Barrier );
		Util.MapDebugPrint( "Tank_at_Tunnel" );
	},

	Tank_past_Tunnel = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"SNIPE_tunnel.*",
			"DEFEND_tunnel.*",
			"DEFEND_2ndTankPath.*",
			"SNIPE_2ndTankPath.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_after_tunnel.*",
			"SNIPE_after_tunnel.*",
		});
		Util.MapDebugPrint( "Tank_past_Tunnel" );
	},

	Bunker_Dyno_Enabled = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			Map.Mount_bunker_MG,
			Map.Repair_bunker_MG,
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"SNIPE_tunnel.*",
			"DEFEND_tunnel.*",
			"DEFEND_2ndTankPath.*",
			"SNIPE_2ndTankPath.*",
			"DEFEND_after_tunnel.*",
			"SNIPE_after_tunnel.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"SNIPE_bunker.*",
			"DEFEND_bunker.*",
			"MOBILEMG42_bunker.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_station_flag );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			Map.Plant_Tank_Barrier,
			Map.Checkpoint_station_flag,
		});
		Util.MapDebugPrint( "Bunker_Dyno_Enabled" );

		threadKill( Map.doorthreadid );
		Map.Switches.cargo_door.Enabled = false;
		sleep(1);
		SetAvailableMapGoals( TEAM.AXIS, false, {
			Map.Mount_train_mg42,
			Map.Repair_train_mg42,
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			Map.Mount_train_mg42,
			Map.Repair_train_mg42,
		});

		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Bunker_Control_Room" );
	},

	Bunker_Planted = function( trigger )
	{
		Map.BunkerDyno += 1;
		Util.MapDebugPrint( "Bunker_Planted" );
	},

	Bunker_Defused = function( trigger )
	{
		Map.BunkerDyno -= 1;
		Util.MapDebugPrint( "Bunker_Defused" );
	},

	Bunker_Destroyed = function( trigger )
	{
		Map.BunkerDyno = 0;
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Build_Axis_Command_Post );
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Bunker_Debris );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Bunker_Control_Room" );
		Util.MapDebugPrint( "Bunker_Destroyed" );
	},

	Tank_past_Bunker = function( trigger )
	{
		Map.TankIsPastBunker = true;
		SetAvailableMapGoals( TEAM.AXIS, false, {
			Map.Repair_bunker_MG,
			Map.Mount_bunker_MG,
			"DEFEND.*",
			"SNIPE.*",
			"MOBILEMG42.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"SNIPE_past_bunker.*",
			"DEFEND_past_bunker.*",
		});
		Util.MapDebugPrint( "Tank_past_Bunker" );
	},

	train_cargo_door_Moving = function( trigger )
	{
		// Util.MapDebugPrint(trigger.Action);
		//Util.MapDebugPrint(trigger.Entity);
		// Util.MapDebugPrint( "train_cargo_door_Moving" );
	},

	testTraceLineThread = function()
	{
		start = Vector3(2035,12,100);
		end = Vector3(1950,12,100);
		interval = 0.8;
		while (1)
		{
			tr = TraceLine(start, end, null, TRACE.SHOT, 0, false);
			if(tr.fraction < 1)
			{
				//Util.MapDebugPrint("closed");
				//DrawDebugLine(start, end, COLOR.RED, interval);
				SetAvailableMapGoals( TEAM.AXIS, false, {
					Map.Mount_train_mg42,
					Map.Repair_train_mg42,
				});
				SetAvailableMapGoals( TEAM.ALLIES, false, {
					Map.Mount_train_mg42,
					Map.Repair_train_mg42,
				});
			}
			else
			{
				//Util.MapDebugPrint("open");
				//DrawDebugLine(start, end, COLOR.GREEN, interval);
				Map.Switches.cargo_door.Enabled = false;
				SetAvailableMapGoals( TEAM.AXIS, true, {
					Map.Mount_train_mg42,
					Map.Repair_train_mg42,
				});
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					Map.Mount_train_mg42,
					Map.Repair_train_mg42,
				});
			}
			sleep(interval);
		}
	},

	Tank_Health = function()
	{
		tankEnt = Util.GetGoalEnt("MOVER_tank");

		if (tankEnt)
		{
			tankName = GetEntName(tankEnt);
			triggerInfo =
			{
				Entity = tankEnt,
				Activator = null,
				TagName = "",
				Action = "",
			};

			status = GetEntFlags(tankEnt, ENTFLAG.DEAD);
			while(1)
			{
				newStatus = GetEntFlags(tankEnt, ENTFLAG.DEAD);
				if ( newStatus != status )
				{
					if ( newStatus == true ) {
						triggerInfo.TagName = tankName + " damaged!";
						triggerInfo.Action = "damaged";
						SendTrigger(triggerInfo);
					}
					else {
						triggerInfo.TagName = tankName + " built!";
						triggerInfo.Action = "built";
						SendTrigger(triggerInfo);
					}

					status = newStatus;
				}

				sleep(0.5);
			}
		}
	},

	tank_at_location = function( trigger )
	{
		switch(Map.VehicleLocation)
		{
			case 1:
			{
				// random positions now
				ETUtil.SetStartIndex("BUILD_Tiger_Tank", -1);
				ETUtil.SetStartIndex("ESCORT_tank", -1);
				ETUtil.SetStartIndex("MOUNT_tank", -1);
			}
			case 2: // Tank_In_First_Tunnel
			{
				Map.Tank_In_First_Tunnel();
			}
			case 3: // Tank_at_Corner
			{
				Map.Tank_at_Corner();
			}
			case 4: // Tank_at_tunnel
			{
				Map.Tank_at_Tunnel();
			}
		}
		Util.MapDebugPrint("tank at location " + Map.VehicleLocation, true);
	},
};

global OnMapLoad = function()
{
	// the wm_announce is oddly unreliable, no idea why. so lets create our own triggers
	thread(Map.Tank_Health);

	// *** TRIGGERS ***
	OnTrigger( "^3*** ^7Axis have built the mine tunnel barricade! ^3***", Map.Barricade_Built );
	OnTrigger( "^3*** ^7Allies have destroyed the mine tunnel barricade! ^3***", Map.Barricade_Destroyed );
	OnTrigger( "^3*** ^7Axis have damaged the railway footbridge! ^3***", Map.Footbridge_Destroyed );
	OnTrigger( "^3*** ^7Allies have destroyed the footbridge, the rail tracks are clear", Map.Wrecked_Footbridge_Destroyed );
	OnTrigger( "^3*** ^7The Tank has passed the footbridge and will try to leave the tr", Map.Tank_Past_Footbridge );
	OnTrigger( "allies_ramp_constructed", Map.Tank_Ramp_Built );
	OnTrigger( "allies_build_ramp", Map.Build_Tank_Ramp );
	OnTrigger( "Planted at the Assault Ramp.", Map.Tank_Ramp_Planted );
	OnTrigger( "Defused at the Assault Ramp.", Map.Tank_Ramp_Defused );
	OnTrigger( "axis_ramp_destroyed", Map.Tank_Ramp_Destroyed );
	OnTrigger( "axis_dynamite_tunnel", Map.Tunnel_Dyno_Enabled );
	OnTrigger( "^3*** ^7Axis have collapsed the tunnel and blocked the road! ^3***", Map.Railway_Tunnel_Destroyed );
	OnTrigger( "^3*** ^7Allies have cleared a path through the tunnel rubble! ^3***", Map.Railway_Tunnel_Cleared );
	OnTrigger( "axis_dynamite_bunker", Map.Bunker_Dyno_Enabled );
	OnTrigger( "Planted at the Bunker Control Room.", Map.Bunker_Planted );
	OnTrigger( "Defused at the Bunker Control Room.", Map.Bunker_Defused );
	OnTrigger( "allies_bunker_damaged", Map.Bunker_Destroyed );
	OnTrigger( "allies_tank_past_bunker", Map.Tank_past_Bunker );
	OnTrigger( "allies_tank_past_barrier", Map.Tank_past_Barrier );
	// OnTrigger( "axis_tank_in_tunnel", Map.Tank_in_Tunnel );
	OnTrigger( "allies_tank_past_tunnel", Map.Tank_past_Tunnel );
	OnTrigger( "^3*** ^7Allies have ^3permanently ^7claimed the station courtyard! ^3**", Map.StationPermanent );
	OnTrigger( "axis_station_captured", Map.station_flag_Axis_Captured );
	OnTrigger( "allies_station_captured", Map.station_flag_Allies_Captured );
	OnTrigger( "train_cargo_door_Moving", Map.train_cargo_door_Moving );
	OnTrigger( "MISSING_STRING", Map.Tank_Barrier_Built );
	OnTrigger( "MISSING_STRING", Map.Tank_Barrier_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Roadblock_Built );
	OnTrigger( "MISSING_STRING", Map.Roadblock_Destroyed );
	OnTrigger( "tank damaged!", Map.Tiger_Tank_Damaged );
	OnTrigger( "tank at location", Map.tank_at_location );

	// *** INITIAL AVAILABILITY OF MAP GOALS ***
	SetAvailableMapGoals( TEAM.AXIS, false, ".*" );
	SetAvailableMapGoals( TEAM.AXIS, true, {
		Map.Plant_Footbridge,
		Map.Build_Axis_Command_Post,
		Map.Build_Barricade,
		Map.Build_Roadblock,
		Map.Plant_Allied_Command_Post,
		Map.Checkpoint_station_flag,
		"MOBILEMG42_start.*",
		"DEFEND_start.*",
		"SNIPE_start.*",
		"DEFEND_checkpoint.*",
		"SNIPE_checkpoint.*",
	});

	SetAvailableMapGoals( TEAM.ALLIES, false, ".*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"EXPLODE_Barricade",
		"GRENADE_barrier1",
		"GRENADE_barrier2",
		"ESCORT_tank",
		"MOUNT_tank",
		Map.Build_Tiger_Tank,
		Map.Plant_Axis_Command_Post,
		Map.Build_Allied_Command_Post,
		Map.Plant_Tank_Barrier,
		Map.Plant_Roadblock,
		Map.Checkpoint_station_flag,
	});
	//SetAvailableMapGoals( TEAM.ALLIES, true, "SNIPE_.*" );

	// *** PRIORITY ***
	SetGoalPriority(Map.Build_Axis_Command_Post, 0.85);
	SetGoalPriority(Map.Build_Allied_Command_Post, 0.85);
	SetGoalPriority(Map.Build_Roadblock, 0.92);
	SetGoalPriority(Map.Plant_Footbridge, 0.93);
	SetGoalPriority(Map.Plant_Wrecked_Footbridge, 0.9);
	SetGoalPriority(Map.Plant_Collapsed_Tunnel, 0.9);
	SetGoalPriority(Map.Plant_Railway_Tunnel, 0.93);
	SetGoalPriority(Map.Plant_Bunker_Debris, 0.85);
	SetGoalPriority("ESCORT_tank", 0.5); // same as the old goal was. make it higher? might increase focus
	SetGoalPriority("PLANT_Bunker_Control_Room", 0.91);
	SetGoalPriority("PLANT_ramp", 0.9);
	SetGoalPriority("GRENADE_barrier1", 0.7);
	SetGoalPriority("GRENADE_barrier2", 0.6);
	SetGoalPriority("ATTACK_.*", 0.5);
	SetGoalPriority("DEFEND_tank_ramp.*", 0.55);
	SetGoalPriority("DEFEND_start.*", 0.55);

	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=3, MaxCampTime=35} );
	SetMapGoalProperties( "SNIPE_.*", {MinCampTime=5, MaxCampTime=35} );
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=5, MaxCampTime=35} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=35} );

	Util.SetMaxUsersInProgress( 2, "CHECKPOINT_.*" );
	Util.SetMaxUsersInProgress( 1, "BUILD_.*" );
	Util.SetMaxUsersInProgress( 1, "PLANT_.*" );
	Util.SetMaxUsersInProgress( 2, "ATTACK_.*" );
	Util.SetMaxUsersInProgress( 1, "DEFEND_.*" );
	Util.SetMaxUsersInProgress( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsersInProgress( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "MOUNT_tank" );
	Util.SetMaxUsers( 2, "ESCORT_tank" ); // old goal had Limitbots 1 and 2 offsets

	// Path across tunnel rubble is closed initially
	Wp.SetWaypointFlag("tunnel_debris1", "closed", true);
	Wp.SetWaypointFlag("tunnel_debris2", "closed", true);
	Wp.SetWaypointFlag("footbridge18", "closed", true);

	location1 = OnTriggerRegion(AABB(5464.072,7354.821,95.125,5575.968,7631.087,209.281),RegionTrigger.VehicleTrigger);
	location2 = OnTriggerRegion(AABB(1561.534,6736.362,15.125,2058.672,6972.789,89.125),RegionTrigger.VehicleTrigger);
	location3 = OnTriggerRegion(AABB(2986.661,1088.029,47.642,3339.877,1535.174,162.996),RegionTrigger.VehicleTrigger);
	location4 = OnTriggerRegion(AABB(2591.196,-898.719,-304.875,2955.682,-510.030,-185.702),RegionTrigger.VehicleTrigger);

	Util.SetGoalOffset( 0,40,0, Map.Plant_Roadblock );
	Util.SetGoalOffset( 0,0,-100, Map.Plant_Wrecked_Footbridge );

	// start from the front until it moves out a bit
	ETUtil.SetStartIndex("BUILD_Tiger_Tank", 5);
	ETUtil.SetStartIndex("ESCORT_tank", 5);
	ETUtil.SetStartIndex("MOUNT_tank", 5);

	Util.UpdateSwitchData();

	/*** ROUTES ***/
	MapRoutes =
	{
		BUILD_Allied_Command_Post =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_left = {},
				ROUTE_right = {},
				ROUTE_barricade = {},
			},
			ROUTE_station_spawn =
			{
				ROUTE_station_spawn_a = {},
				ROUTE_station_spawn_b = {},
			},
		},
		DEFEND_start1 =
		{
			ROUTE_axis_spawn =
			{
				ROUTE_frontdoor = {},
				ROUTE_backdoor = {},
			},
			ROUTE_station_spawn =
			{
				ROUTE_station_spawn_a = {},
				ROUTE_station_spawn_b = {},
			},
		},
		DEFEND_after_tunnel1 =
		{
			ROUTE_bunker_spawn =
			{
				ROUTE_door = {},
				ROUTE_door2 = {},
			},
		},
		PLANT_Axis_Command_Post =
		{
			ROUTE_station_spawn =
			{
				ROUTE_station_spawn_a =
				{
					ROUTE_gate = {},
					ROUTE_ladder1 = {},
				},
				ROUTE_station_spawn_b = {},
				ROUTE_gate = {},
				ROUTE_ladder1 = {},
			},
		},
	};

	MapRoutes.DEFEND_start2 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_start3 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_start4 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_start5 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_start6 = MapRoutes.DEFEND_start1;
	MapRoutes.MOBILEMG42_start7 = MapRoutes.DEFEND_start1;
	MapRoutes.MOBILEMG42_start8 = MapRoutes.DEFEND_start1;
	MapRoutes.MOBILEMG42_start9 = MapRoutes.DEFEND_start1;
	MapRoutes.MOBILEMG42_start10 = MapRoutes.DEFEND_start1;
	MapRoutes.MOBILEMG42_start12 = MapRoutes.DEFEND_start1;
	MapRoutes.MOBILEMG42_start13 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_after_tunnel2 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_after_tunnel3 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_after_tunnel4 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_after_tunnel5 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_after_tunnel6 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_after_tunnel8 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_after_tunnel9 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_bunker1 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_bunker2 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_bunker3 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_bunker8 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_bunker9 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.DEFEND_bunker16 = MapRoutes.DEFEND_after_tunnel1;
	MapRoutes.BUILD_ramp = MapRoutes.BUILD_Allied_Command_Post;
	MapRoutes.CHECKPOINT_station_flag = MapRoutes.BUILD_Allied_Command_Post;
	MapRoutes.ATTACK_2ndTankPath8 = MapRoutes.BUILD_Allied_Command_Post;
	MapRoutes.ATTACK_2ndTankPath7 = MapRoutes.BUILD_Allied_Command_Post;
	MapRoutes.DEFEND_checkpoint2 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_checkpoint4 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_checkpoint7 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_footbridge2 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_footbridge3 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_footbridge4 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_footbridge5 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_footbridge6 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_footbridge7 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_footbridge8 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_tb1 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_tb2 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_tb3 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_tb4 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_tb5 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_tb6 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_tb7 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_tb8 = MapRoutes.DEFEND_start1;
	MapRoutes.DEFEND_tb9 = MapRoutes.DEFEND_start1;

	Util.Routes(MapRoutes);

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

	Util.MapDebugPrint( "Omni-bot map script for Breakout 2 executed." );
};

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 90.0;
	// Four birds to ignore as targets:
	bot.IgnoreTarget( GetGoal(Map.Bird1).GetEntity(), 9999 );
	bot.IgnoreTarget( GetGoal(Map.Bird2).GetEntity(), 9999 );
	bot.IgnoreTarget( GetGoal(Map.Bird3).GetEntity(), 9999 );
	bot.IgnoreTarget( GetGoal(Map.Bird4).GetEntity(), 9999 );
};
