global Map =
{
	Debug = 0,

	Switches =
	{
		TrackSwitch =
		{
			Enabled = false,
			Priority = 0, // leave for paththrough
			WaypointName = "TrackSwitch",
			LimitTeam = 0, // disabled initially.
		},

		RailgunControls =
		{
			Enabled = false,
			Priority = 0, // leave for paththrough
			WaypointName = "Railgun Controls",
			LimitTeam = 0, // disabled initially.
		},
	},

	// a few bots on each team will focus on the flag area while the rest will ignore it
	Roles =
	{
		AXIS =
		{
			DEFENDER3 =
			{
				numbots = 3,
			},
		},

		ALLIES =
		{
			DEFENDER3 =
			{
				numbots = 3,
			},
		},
	},

	Navigation =
	{
		// some quick jumping for rails and gaps
		quickjump =
		{
			navigate = function()
			{
				this.Bot.PressButton(BTN.JUMP);
				sleep(0.25);
			},
		},
	},

	//flag status
	FlagStatus = 0, //1 axis, 2 allies

	DispenseHealthTime = 15.0,
	DispenseAmmoTime = 15.0,

	// some flags to help with tug position logic
	southcrane = 0,
	southofswitch = 0,
	northofswitch = 0,
	depotyard = 0,
	panel3 = true,
	Railgun_Loaded = false,
	Switch_Raised = false,
	AmmoCrane = false,
	AmmoLoaded = false,

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

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

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

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

	Rail_Gun_Firing_Controls_Built = function()
	{
		Map.panel3 = true;

		if ( Map.Railgun_Loaded )
		{
			Map.Switches.RailgunControls.LimitTeam = (1<<TEAM.AXIS);
			Util.LimitToTeam( TEAM.AXIS, "SWITCH_controls" );
		}

		Util.MapDebugPrint( "Rail_Gun_Firing_Controls_Built" );
	},

	Rail_Gun_Firing_Controls_Destroyed = function()
	{
		Map.panel3 = false;

		if ( Map.Railgun_Loaded )
		{
			Map.Switches.RailgunControls.LimitTeam = 0;
			Util.DisableGoal( "SWITCH_controls" );
		}

		Util.MapDebugPrint( "Rail_Gun_Firing_Controls_Destroyed" );
	},

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

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

	depotflag_Axis_Captured = function()
	{
		Map.FlagStatus = 1;

		Util.MapDebugPrint( "depotflag_Axis_Captured" );
	},

	depotflag_Allies_Captured = function()
	{
		Map.FlagStatus = 2;

		Util.MapDebugPrint( "depotflag_Allies_Captured" );
	},

	Track_Switch_Raised = function()
	{
		Map.Switch_Raised = true;

		if ( Map.Switches.TrackSwitch.LimitTeam == (1<<TEAM.AXIS) )
			{ Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES); }
		else
			{ Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS); }

		// TODO: need to redo this stuff
		mg = GetGoal("SWITCH_trackswitch");
		if( mg.IsAvailable(TEAM.AXIS) )
		{
			Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
		}
		else
		{
			Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
		}

		if ( !Map.AmmoCrane )
		{
			// cs: don't toggle these now that both teams will chase
			/*if ( !Map.depotyard )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "RIDE_rtug1" );
				SetAvailableMapGoals( TEAM.ALLIES, true, "RIDE_btug1" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "RIDE_rtug1" );
				SetAvailableMapGoals( TEAM.ALLIES, false, "RIDE_btug1" );
			}*/

			if ( !Map.AmmoLoaded )
			{
				if ( Map.southofswitch || Map.southcrane )
				{
					Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
				}
			}
			else
			{
				if ( Map.southofswitch || Map.southcrane )
				{
					Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
				}
			}
		}

		Util.MapDebugPrint( "Track_Switch_Raised" );
	},

	Track_Switch_Lowered = function()
	{
		Map.Switch_Raised = false;

		if ( Map.Switches.TrackSwitch.LimitTeam == (1<<TEAM.ALLIES) )
			{ Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS); }
		else
			{ Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES); }

		// TODO: need to redo this stuff
		mg = GetGoal("SWITCH_trackswitch");
		if( mg.IsAvailable(TEAM.ALLIES) )
		{
			Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
		}
		else
		{
			Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
		}

		if ( !Map.AmmoCrane )
		{
			if ( !Map.AmmoLoaded )
			{
				if ( Map.southofswitch || Map.southcrane )
				{
					Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
				}
			}
			else
			{
				if ( Map.southofswitch || Map.southcrane )
				{
					Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
				}
			}
		}

		Util.MapDebugPrint( "Track_Switch_Lowered" );
	},

	Axis_Ammo_Tug1 = function()
	{
		Map.AmmoLoaded = true;

		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_Depot_Yard.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Depot_Yard.*" );

		Util.MapDebugPrint( "Axis_Ammo_Tug1" );
	},

	Axis_Ammo_Crane = function()
	{
		Map.AmmoCrane = true;

		Map.Switches.TrackSwitch.LimitTeam = null;
		Util.DisableGoal("SWITCH_trackswitch");

		// Allied goals
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"RIDE_btug1",
			"DEFEND_Track_Switch_North_.*",
			"PLANTMINE_bTrackswitch.*",
			"MOUNTMG42_Track_Switch_MG_Nest",
			"BUILD_Track_Switch_MG_Nest",
			"REPAIRMG42_Track_Switch_MG_Nest",
			"REPAIRMG42_Depot_Yard_MG_Nest",
			"MOUNTMG42_mg42_3",
			"REPAIRMG42_mg42_3",
			"PLANT_Command_Post",
			"BUILD_Command_Post",
			"HEALTHCAB_t1171",
			"AMMOCAB_t1170",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Railgun.*" ); //just to make sure
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Crane_Area_.*" );

		// Axis goals
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"RIDE_rtug1",
			"ATTACK_Track_Switch_North_.*",
			"MOUNTMG42_Track_Switch_MG_Nest",
			"PLANT_Track_Switch_MG_Nest",
			"REPAIRMG42_Track_Switch_MG_Nest",
			"REPAIRMG42_Depot_Yard_MG_Nest",
			"REPAIRMG42_mg42_3",
			"PLANT_Depot_Yard_MG_Nest",
			"PLANT_Command_Post",
			"MOUNTMG42_mg42_3",
			"BUILD_Command_Post",
			"HEALTHCAB_t1171",
			"AMMOCAB_t1170",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"RIDE_rtug2",
			"ATTACK_Railgun.*",
		});

		Util.MapDebugPrint( "Axis_Ammo_Crane" );
	},

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

	Axis_Loaded_Railgun = function()
	{
		Map.Railgun_Loaded = true;

		if ( Map.panel3 )
		{
			Map.Switches.RailgunControls.LimitTeam = (1<<TEAM.AXIS);
			Util.LimitToTeam( TEAM.AXIS, "SWITCH_controls" );
		}

		SetAvailableMapGoals( TEAM.AXIS, false, "RIDE_rtug2" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "RIDE_btug2" );

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

		Util.MapDebugPrint( "Axis_Loaded_Railgun" );
	},

	Axis_Fired_Railgun = function()
	{
		Map.Switches.RailgunControls.LimitTeam = 0;
		Util.DisableGoal( "SWITCH_controls" );

		Util.MapDebugPrint( "Axis_Fired_Railgun" );
	},

	tug_depotyard =
	{
		Name = "tug_depotyard",
		TriggerOnEntity = GetGoal("MOVER_train1").GetEntity(),
		OnEnter = function(ent)
		{
			if ( Map.depotyard != 0 )
			{
				//SetAvailableMapGoals( TEAM.ALLIES, false, "RIDE_btug1");
				Map.depotyard = 0;
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "RIDE_btug1");
				Map.depotyard = 1;
			}

			//reset the northofswitch flag
			Map.northofswitch = 0;

			//run the logic tests
			Map.tug_logics(1);

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

	tug_northofswitch =
	{
		Name = "tug_northofswitch",
		TriggerOnEntity = GetGoal("MOVER_train1").GetEntity(),
		OnEnter = function(ent)
		{
			Map.northofswitch = 1;
			Map.southofswitch = 0;
			Map.depotyard = 0;

			//run the logic tests
			Map.tug_logics(2);

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

	tug_southofswitch =
	{
		Name = "tug_southofswitch",
		TriggerOnEntity = GetGoal("MOVER_train1").GetEntity(),
		OnEnter = function(ent)
		{
			Map.northofswitch = 0;
			Map.southofswitch = 1;
			Map.southcrane = 0;

			//run the logic tests
			Map.tug_logics(3);

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

	tug_southcrane =
	{
		Name = "tug_southcrane",
		TriggerOnEntity = GetGoal("MOVER_train1").GetEntity(),
		OnEnter = function(ent)
		{
			if ( Map.southcrane != 0 )
			{
				Map.southcrane = 0;
			}
			else
			{
				Map.southcrane = 1;
			}

			//reset the southofswitch flag
			Map.southofswitch = 0;

			//run the logic tests
			Map.tug_logics(4);

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

	tug_logics = function (position)
	{
		Util.MapDebugPrint("tug_logics", true);
		if ( !Map.AmmoLoaded )
		{
			if( position == 1 ) //depotyard
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, {
					"DEFEND_Track_Switch_North_.*",
					"PLANTMINE_bTrackswitch.*",
					"DEFEND_Depot_Yard_.*",
				});
				SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_mg42_3" );
				SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Crane_Area_.*" );
			}
			else if( position == 2 ) //northofswitch
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Depot_Yard_.*",
					"DEFEND_Track_Switch_North_.*",
					"PLANTMINE_bTrackswitch.*",
				});
				SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_mg42_3" );


				if ( !Map.Switch_Raised )
				{
					if ( Map.southofswitch != 0 )
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
						Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
					}
					else
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
						Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
					}
				}
				else
				{
					if ( Map.southofswitch != 0 )
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
						Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
					}
					else
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
						Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
					}
				}
			}
			else if( position == 3 ) //southofswitch
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Crane_Area_.*" );

				if ( !Map.Switch_Raised )
				{
					if ( Map.norththofswitch != 0 )
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
						Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
					}
					else
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
						Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
					}
				}
				else
				{
					if ( Map.northofswitch != 0 )
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
						Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
					}
					else
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
						Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
					}
				}
			}
			else if( position == 4 ) //southcrane
			{
				if ( Map.Switch_Raised )
				{
					Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
					Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
				}
				else
				{
					Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
					Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
				}
			}
		}
		else
		{
			if( position == 1 )
			{
				//will never get here
			}
			else if( position == 2 )
			{
				if ( !Map.Switch_Raised )
				{
					if ( Map.southofswitch != 0 )
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
						Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
					}
					else
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
						Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
					}
				}
				else
				{
					if ( Map.southofswitch != 0 )
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
						Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
					}
					else
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
						Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
					}
				}

				//some allies should start cheating over to railgun here
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Railgun_.*",
					"DEFEND_Crane_Area_.*",
				});

				SetAvailableMapGoals( TEAM.ALLIES, false, {
					"CHECKPOINT_depotflag",
					"BUILD_Depot_Yard_MG_Nest",
					"MOUNTMG42_Depot_Yard_MG_Nest",
					"REPAIRMG42_Depot_Yard_MG_Nest",
				});

				SetAvailableMapGoals( TEAM.AXIS, false, {
					"CHECKPOINT_depotflag",
					"BUILD_Depot_Yard_MG_Nest",
					"MOUNTMG42_Depot_Yard_MG_Nest",
					"REPAIRMG42_Depot_Yard_MG_Nest",
				});
			}
			else if( position == 3 )
			{
				if ( !Map.Switch_Raised )
				{
					if ( Map.norththofswitch != 0 )
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
						Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
					}
					else
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
						Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
					}
				}
				else
				{
					if ( Map.northofswitch != 0 )
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
						Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
					}
					else
					{
						Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
						Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
					}
				}

				SetAvailableMapGoals( TEAM.ALLIES, false, {
					"DEFEND_Railgun_.*",
					"DEFEND_Crane_Area_.*",
				});

				//SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_depotflag" );
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"BUILD_Depot_Yard_MG_Nest",
					"MOUNTMG42_Depot_Yard_MG_Nest",
					"REPAIRMG42_Depot_Yard_MG_Nest",
				});

				//SetAvailableMapGoals( TEAM.AXIS, true, "CHECKPOINT_depotflag" );
				SetAvailableMapGoals( TEAM.AXIS, true, {
					"BUILD_Depot_Yard_MG_Nest",
					"MOUNTMG42_Depot_Yard_MG_Nest",
					"REPAIRMG42_Depot_Yard_MG_Nest",
				});
			}
			else if( position == 4 )
			{
				if ( Map.Switch_Raised )
				{
					Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.ALLIES);
					Util.LimitToTeam( TEAM.ALLIES, "SWITCH_trackswitch" );
				}
				else
				{
					Map.Switches.TrackSwitch.LimitTeam = (1<<TEAM.AXIS);
					Util.LimitToTeam( TEAM.AXIS, "SWITCH_trackswitch" );
				}
			}
		}

		return;
	},
};

global OnMapLoad = function()
{
	Util.SetGoalOffset( 0, 25, -10, "BUILD_Rail_Gun_Firing_Controls" );
	//~ Util.SetGoalOffset( 50, 0, 0, "BUILD_Depot_Yard_MG_Nest" );

	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Command_Post_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Command_Post_Built );
	OnTrigger( "The Depot Yard MG Nest has been constructed.", Map.Depot_Yard_MG_Nest_Built );
	OnTrigger( "The Depot Yard MG has been constructed.", Map.Depot_Yard_MG_Nest_Built );
	OnTrigger( "Rail Gun Firing Controls rebuilt!", Map.Rail_Gun_Firing_Controls_Built );
	OnTrigger( "The Track Switch MG Nest has been constructed.", Map.Track_Switch_MG_Nest_Built );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Command_Post_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Command_Post_Destroyed );
	OnTrigger( "The Depot Yard MG has been destroyed.", Map.Depot_Yard_MG_Nest_Destroyed );
	OnTrigger( "Rail Gun Firing Controls destroyed!", Map.Rail_Gun_Firing_Controls_Destroyed );
	OnTrigger( "The Track Switch MG Nest has been destroyed.", Map.Track_Switch_MG_Nest_Destroyed );
	OnTrigger( "Axis captures the Depot Yard!", Map.depotflag_Axis_Captured );
	OnTrigger( "Allies capture the Depot Yard!", Map.depotflag_Allies_Captured );
	OnTrigger( "Track Switch raised!", Map.Track_Switch_Raised );
	OnTrigger( "Track Switch lowered!", Map.Track_Switch_Lowered );
	OnTrigger( "Axis loaded the Rail Gun Ammo onto the First Tug!", Map.Axis_Ammo_Tug1 );
	OnTrigger( "Axis transported the Ammo to the North Crane!", Map.Axis_Ammo_Crane );
	OnTrigger( "Axis transferred the Ammo to the Second Tug!", Map.Axis_Ammo_Tug2 );
	OnTrigger( "Axis team have loaded the Rail Gun!", Map.Axis_Loaded_Railgun );
	OnTrigger( "Axis fired the Rail Gun!", Map.Axis_Fired_Railgun );

	OnTriggerRegion(AABB(589.290,4722.105,266.537,668.859,4976.230,347.125), Map.tug_depotyard);
	OnTriggerRegion(AABB(3759.637,4301.975,264.942,4051.185,4411.987,365.170), Map.tug_northofswitch);
	OnTriggerRegion(AABB(3705.093,2385.649,269.221,4299.063,2610.763,393.125), Map.tug_southofswitch);
	OnTriggerRegion(AABB(1094.028,955.041,263.132,1464.842,1297.302,345.125), Map.tug_southcrane);

	// disable combat movement and bot pushing in axis spawns
	OnTriggerRegion(AABB(-1526.600,4775.126,289.125,-1119.990,5261.116,424.964),RegionTrigger.DisableBotPush);
	OnTriggerRegion(AABB(1832.000,4915.000,561.000,2263.000,5339.000,714.000),RegionTrigger.DisableBotPush);

	// Max users per goal
	Util.SetMaxUsers( 1, {"DEFEND.*", "ATTACK_Depot_Yard.*", "SWITCH.*"} );
	Util.SetMaxUsers( 2, "CHECKPOINT_depotflag" );
	Util.SetMaxUsersInProgress( 3, "RIDE.*" );

	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=10, MaxCampTime=30});
	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=15, MaxCampTime=30});
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=45, MaxCampTime=90});


	Util.ExcludeClass( "MOUNTMG42_.*", 0,  CLASS.MEDIC, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Command_Post", 0, 0, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Depot_Yard_MG_Nest", 0, 0, CLASS.ENGINEER );
	SetGoalPriority( "SWITCH.*", 0.8 );

	// these goals in the flag area are limited by role. we want some bots to focus on them
	// so increase priority
	SetGoalPriority( ".*Depot_Yard.*", 0.81 ); // camps and all mg42 related goals
	SetGoalPriority( "CHECKPOINT_.*", 0.82 );

	// Allied goals
	SetGoalPriority( "PLANT_Depot_Yard_MG_Nest", 0.81, TEAM.ALLIES, CLASS.COVERTOPS );

	// Axis goals
	SetGoalPriority( "PLANT_Track_Switch_MG_Nest", 0, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Depot_Yard_MG_Nest", 0.81, TEAM.AXIS, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_Track_Switch_MG_Nest", 0.82, TEAM.AXIS, CLASS.COVERTOPS );

	Util.DisableGoal( ".*", true ); // all but routes

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"REPAIRMG42_Track_Switch_MG_Nest",
		"HEALTHCAB_t1171",
		"AMMOCAB_t1170",
		"BUILD_Command_Post",
		"BUILD_Track_Switch_MG_Nest",
		"PLANT_Rail_Gun_Firing_Controls",
		"PLANT_Command_Post",
		"PLANT_Depot_Yard_MG_Nest",
		"MOUNTMG42_Track_Switch_MG_Nest",
		"CHECKPOINT_depotflag",
		"DEFEND_Crane_Area_.*",
		"DEFEND_Depot_Yard_.*",
		"PLANTMINE_bTrackswitch.*",
	});

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"REPAIRMG42_mg42_3",
		"REPAIRMG42_Track_Switch_MG_Nest",
		"HEALTHCAB_t1171",
		"AMMOCAB_t1170",
		"BUILD_Command_Post",
		"PLANT_Track_Switch_MG_Nest",
		"RIDE_rtug1",
		"PLANT_Command_Post",
		"PLANT_Depot_Yard_MG_Nest",
		"MOUNTMG42_Track_Switch_MG_Nest",
		"CHECKPOINT_depotflag",
		"ATTACK_Depot_Yard_.*",
		"ATTACK_Track_Switch_North_.*",
	});
	Util.EnableGroup( "tsarty", TEAM.AXIS );

	Util.UpdateSwitchData();

	Util.FixMoverPos("train1", Vec3(-455.633, 4864.594, 356.922), Vec3(-316.094, 4864.000, 296.000), Vec3(1,-1,1));
	Util.FixMoverPos("train2", Vec3(1016.461, 5472.594, 348.922), Vec3(1156.000, 5472.000, 288.000));

	Util.MapDebugPrint( "OnMapLoad" );
};

global OnBotJoin = function( bot )
{
	bot.MaxViewDistance = 2500;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		PLANT_Rail_Gun_Firing_Controls =
		{
			ROUTE_AllySpawn =
			{
				ROUTE_as_mid = {},
				ROUTE_as_right = {},
			},
			ROUTE_FlagSpawn =
			{
				ROUTE_east_hill = { Weight = 3 },
				ROUTE_west_hill = {},
			},
		},
		BUILD_Rail_Gun_Firing_Controls =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_track1 = {},
				ROUTE_track2 = {},
			},
			ROUTE_FlagSpawn =
			{
				ROUTE_east_hill = { Weight = 3 },
				ROUTE_west_hill = {},
			},
		},
		CHECKPOINT_depotflag =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_east_hill = {},
				ROUTE_west_hill = {},
			},
			ROUTE_AllySpawn =
			{
				ROUTE_tsStairsJump = {},
				ROUTE_as_left = { Weight = 3, },
			},
		},
		SWITCH_trackswitch =
		{
			ROUTE_FlagSpawn =
			{
				ROUTE_west_hill = { ROUTE_bunker_north = {}, },
				ROUTE_bunker_sw =
				{
					Weight = 2,
					ROUTE_bunker_mid = {},
					ROUTE_bunker_east = {},
				},
			},
			ROUTE_AxisSpawn =
			{
				ROUTE_track1 =
				{
					Weight = 3,
					ROUTE_bunker_north = { Weight = 2, },
					ROUTE_bunker_mid = { ROUTE_bunker_east = {}, },
				},
				ROUTE_track2 =
				{
					ROUTE_bunker_north = { Weight = 2, },
					ROUTE_bunker_mid = { ROUTE_bunker_east = {}, },
				},
			},
		},
	};
	MapRoutes["DEFEND_Depot_Yard.*"] =
	{
		ROUTE_AllySpawn =
		{
			ROUTE_tsStairsJump = {},
			ROUTE_as_left = { Weight = 3, },
		},
	};
	MapRoutes["DEFEND_Track_Switch_North.*"] =
	{
		ROUTE_AllySpawn =
		{
			ROUTE_tsStairs = { Weight = 4, },
			ROUTE_as_mid = { Weight = 2, },
			ROUTE_as_right = {},
		},
		ROUTE_FlagSpawn =
		{
			ROUTE_west_hill = { ROUTE_bunker_north = {}, },
			ROUTE_bunker_sw =
			{
				Weight = 2,
				ROUTE_bunker_mid = {},
				ROUTE_bunker_east = {},
			},
		},
	};
	MapRoutes["ATTACK_Depot_Yard.*"] =
	{
		ROUTE_AxisSpawn =
		{
			ROUTE_east_hill = {},
			ROUTE_west_hill = {},
		},
	};

	//copy some routes
	MapRoutes["DEFEND_Railgun.*"] = MapRoutes.PLANT_Rail_Gun_Firing_Controls;
	MapRoutes["PLANTMINE_bTrackswitch.*"] = MapRoutes["DEFEND_Track_Switch_North.*"];
	MapRoutes["ATTACK_Railgun.*"] = MapRoutes.BUILD_Rail_Gun_Firing_Controls;
	MapRoutes["ATTACK_Track_Switch_North.*"] = MapRoutes.SWITCH_trackswitch;

	Util.Routes(MapRoutes);
};
