global Map =
{
	Debug = false,

	Ammo_Cabinet_south_ammocabinet = "AMMOCAB_south_ammocabinet",
	Health_Cabinet_south_healthcabinet = "HEALTHCAB_south_healthcabinet",
	Checkpoint_bank_flag = "CHECKPOINT_bank_flag",
	Checkpoint_shack_flag = "CHECKPOINT_shack_flag",
	Build_Allied_Command_Post = "BUILD_Allied_Command_Post",
	Build_Axis_Command_Post = "BUILD_Axis_Command_Post",
	Build_Embankment_Assault_Ramp = "BUILD_Embankment_Assault_Ramp",
	Build_Tank_Barrier_1 = "BUILD_Tank_Barrier_1",
	Build_Tank_Barrier_2 = "BUILD_Tank_Barrier_2",
	Build_Tiger_Tank = "BUILD_Tiger_Tank",
	Build_Unexploded_Bomb = "BUILD_Unexploded_Bomb",
	Build_Unexploded_Bomb_1 = "BUILD_Unexploded_Bomb_1",
	Build_bunker_MG42 = "BUILD_bunker_MG42",
	Build_crypt_door = "BUILD_crypt_door",
	Build_tunnel_door = "BUILD_tunnel_door",
	Plant_Allied_Command_Post = "PLANT_Allied_Command_Post",
	Plant_Axis_Command_Post = "PLANT_Axis_Command_Post",
	Plant_Embankment_Assault_Ramp = "PLANT_Embankment_Assault_Ramp",
	Plant_Tank_Barrier_1 = "PLANT_Tank_Barrier_1",
	Plant_Tank_Barrier_2 = "PLANT_Tank_Barrier_2",
	Plant_Unexploded_Bomb = "PLANT_Unexploded_Bomb",
	Plant_bunker_MG42 = "PLANT_bunker_MG42",
	Plant_crypt_door = "PLANT_crypt_door",
	Plant_tunnel_door = "PLANT_tunnel_door",
	Explode_Unexploded_Bomb = "EXPLODE_Unexploded_Bomb",
	Mount_361 = "MOUNTMG42_361",
	Mount_432 = "MOUNTMG42_432",
	Mount_bunker_MG42 = "MOUNTMG42_bunker_MG42",
	Repair_361 = "REPAIRMG42_361",
	Repair_432 = "REPAIRMG42_432",
	Repair_bunker_MG42 = "REPAIRMG42_bunker_MG42",
	Mobile_MG42_78 = "MOBILEMG42_78",
	Snipe_338 = "SNIPE_338",
	Snipe_78 = "SNIPE_78",
	Snipe_98 = "SNIPE_98",
	Mover_tank = "MOVER_tank",

	BreakableAxisMGRoof_Destroyed = false,
	BreakableAxisMGRoof_Info = null,
	BreakableFence1_Destroyed = false,
	BreakableFence1_Info = null,
	BreakableFence2_Destroyed = false,
	BreakableFence2_Info = null,
	BreakableLadder1_Destroyed = false,
	BreakableLadder2_Destroyed = false,
	BreakableFlagDoor_Destroyed = false,
	BreakableFlagDoor_Info = null,
	BreakableFlagDoor_1_Info = null,
	BreakableWindow_Destroyed = false,
	BreakableWindow_Info = null,
	Breakable_Window_Back_Destroyed = false,
	Breakable_Window_Back_Info = null,
	Breakable_Side_Window_Back_Destroyed = false,
	Breakable_Side_Window_Back_Info = null,
	Breakable_Side_Window_Front_Destroyed = false,
	Breakable_Side_Window_Front_Info = null,
	Lift_Info = null,

	Defuse_Crypt = false,
	Defuse_Axis_CP = false,

	check_breakableFence1 = function()
	{
		Util.MapDebugPrint( "thread check_breakableFence1 started", true );
		wpOne = Util.WpNameInfo("fence_1");
		wpTwo = Util.WpNameInfo("fence_in");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( !Map.BreakableFence1_Destroyed )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }
				Map.BreakableFence1_Destroyed = true;

				Util.MapDebugPrint( "thread check_breakableFence1 ended", true );
			 }

			 sleep(3);
		}

		Util.MapDebugPrint( "breakableFence1_destroyed", true );
	},

	check_breakableFence2 = function()
	{
		Util.MapDebugPrint( "thread check_breakableFence2 started", true );
		wpOne = Util.WpNameInfo("fence_2");
		wpTwo = Util.WpNameInfo("fence_in");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( !Map.BreakableFence2_Destroyed )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }
				Map.BreakableFence2_Destroyed = true;

				Util.MapDebugPrint( "thread check_breakableFence2 ended", true );
			 }

			 sleep(3);
		}

		Util.MapDebugPrint( "breakableFence2_destroyed", true );
	},

	check_breakableLadder1 = function()
	{
		Util.MapDebugPrint( "thread check_breakableLadder1 started", true );
		wpOne = Util.WpNameInfo("to_axis_flag_1");
		wpTwo = Util.WpNameInfo("to_axis_flag_2");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( !Map.BreakableLadder1_Destroyed )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }
				Map.BreakableLadder1_Destroyed = true;
				Wp.SetWaypointFlag("breakable_ladder_1_top", "closed", true);

				Util.MapDebugPrint( "thread check_breakableLadder1 ended", true );
			 }

			 sleep(3);
		}

		Util.MapDebugPrint( "breakableLadder1_destroyed", true );
	},

	check_breakableLadder2 = function()
	{
		Util.MapDebugPrint( "thread check_breakableLadder2 started", true );
		wpOne = Util.WpNameInfo("to_axis_flag_3");
		wpTwo = Util.WpNameInfo("to_axis_flag_4");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( !Map.BreakableLadder2_Destroyed )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }
				Map.BreakableLadder2_Destroyed = true;
				Wp.SetWaypointFlag("breakable_ladder_2_top", "closed", true);

				Util.MapDebugPrint( "thread check_breakableLadder2 ended", true );
			 }

			 sleep(3);
		}

		Util.MapDebugPrint( "breakableLadder2_destroyed", true );
	},

	check_flagDoor = function()
	{
		Util.MapDebugPrint( "thread check_flagDoor started", true );
		wpOne = Util.WpNameInfo("fd_out");
		wpTwo = Util.WpNameInfo("fd_in");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( !Map.BreakableFlagDoor_Destroyed )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }
				Map.BreakableFlagDoor_Destroyed = true;

				Util.MapDebugPrint( "thread check_flagDoor ended", true );
			 }

			 sleep(2);
		}

		Util.MapDebugPrint( "flagDoor_destroyed", true );
	},

	check_lift = function()
	{
		Util.MapDebugPrint( "thread check_lift started", true );
		wpOne = Util.WpNameInfo("lift_left");
		wpTwo = Util.WpNameInfo("lift_right");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( 1 )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }

				Wp.SetWaypointFlag("liftpt", "closed", false);
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }

				Wp.SetWaypointFlag("liftpt", "closed", true);
			 }

			 sleep(1);
		}
	},

	check_breakableWindowBack = function()
	{
		Util.MapDebugPrint( "thread check_breakableWindowBack started", true );
		wpOne = Util.WpNameInfo("window_back_in");
		wpTwo = Util.WpNameInfo("window_back_out");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( !Map.Breakable_Window_Back_Destroyed )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }
				Map.Breakable_Window_Back_Destroyed = true;

				Util.MapDebugPrint( "thread check_breakableWindowBack ended", true );
			 }

			 sleep(1);
		}

		Util.MapDebugPrint( "breakableWindowBack_destroyed", true );
	},

	check_breakableSideWindowBack = function()
	{
		Util.MapDebugPrint( "thread check_breakableSideWindowBack started", true );
		wpOne = Util.WpNameInfo("side_window_back_in");
		wpTwo = Util.WpNameInfo("side_window_back_out");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( !Map.Breakable_Side_Window_Back_Destroyed )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }
				Map.Breakable_Side_Window_Back_Destroyed = true;

				Util.MapDebugPrint( "thread check_breakableSideWindowBack ended", true );
			 }

			 sleep(1);
		}

		Util.MapDebugPrint( "breakableSideWindowBack_destroyed", true );
	},

	check_breakableSideWindowFront = function()
	{
		Util.MapDebugPrint( "thread check_breakableSideWindowFront started", true );
		wpOne = Util.WpNameInfo("side_window_front_in");
		wpTwo = Util.WpNameInfo("side_window_front_out");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( !Map.Breakable_Side_Window_Front_Destroyed )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }
				Map.Breakable_Side_Window_Front_Destroyed = true;

				Util.MapDebugPrint( "thread check_breakableSideWindowFront ended", true );
			 }

			 sleep(1);
		}

		Util.MapDebugPrint( "breakableSideWindowFront_destroyed", true );
	},

	check_axis_mg_roof = function()
	{
		Util.MapDebugPrint( "thread check_axis_mg_roof started", true );
		wpOne = Util.WpNameInfo("enter_axis_mg");
		wpTwo = Util.WpNameInfo("axis_mg_roof_1");
		startoffset = Vector3(0,0,0);
		endoffset = Vector3(0,0,0);

		while( !Map.BreakableAxisMGRoof_Destroyed )
		{
			tr = TraceLine( wpOne.position + startoffset, wpTwo.position + endoffset, null, TRACE.SHOT, 0, false );

			 if ( tr.fraction < 1 )
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.RED, 0.25); }
			 }
			 else
			 {
				if ( Map.Debug )
					{ DrawDebugLine(wpOne.position + startoffset, wpTwo.position + endoffset, COLOR.GREEN, 0.25); }
				Map.BreakableAxisMGRoof_Destroyed = true;

				SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_a_Axis_Spawn_Back_1" );
				Wp.SetWaypointFlag("axis_mg_roof_1", "closed", true);
				Wp.SetWaypointFlag("axis_mg_roof_2", "closed", true);

				Util.MapDebugPrint( "thread check_axis_mg_roof ended", true );
			 }

			 sleep(4);
		}

		Util.MapDebugPrint( "axis_mg_roof_destroyed", true );
	},

	Navigation =
	{
		fence_short =
		{
			EvalFunc = function(_this)
			{
				return !Map.BreakableFence1_Destroyed;
			},
			navigate = function(_this)
			{
				// cache the info
				if ( !Map.BreakableFence1_Info ) {
					Map.BreakableFence1_Info = Util.WpNameInfo("fence_1");
				}

				if ( _this.Goto(Map.BreakableFence1_Info.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.High, "facing", Map.BreakableFence1_Info.facing);
					_this.AddWeaponRequest(Priority.High, WEAPON.KNIFE );
					_this.BlockForWeaponChange( WEAPON.KNIFE );

					while( !Map.BreakableFence1_Destroyed )
					{
						_this.Bot.HoldButton(BTN.ATTACK1, 1.0);
						yield();
					}
				}
			},
		},
		fence_long =
		{
			EvalFunc = function(_this)
			{
				return !Map.BreakableFence2_Destroyed;
			},
			navigate = function(_this)
			{
				// cache the info
				if ( !Map.BreakableFence2_Info ) {
					Map.BreakableFence2_Info = Util.WpNameInfo("fence_2");
				}

				if ( _this.Goto(Map.BreakableFence2_Info.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.High, "facing", Map.BreakableFence2_Info.facing);
					_this.AddWeaponRequest(Priority.High, WEAPON.KNIFE );
					_this.BlockForWeaponChange( WEAPON.KNIFE );

					while( !Map.BreakableFence2_Destroyed )
					{
						_this.Bot.HoldButton(BTN.ATTACK1, 1.0);
						yield();
					}
				}
			},
		},
		flag_door =
		{
			EvalFunc = function(_this)
			{
				return !Map.BreakableFlagDoor_Destroyed;
			},
			navigate = function(_this)
			{
				// cache the info
				if ( !Map.BreakableFlagDoor_Info ) {
					Map.BreakableFlagDoor_Info = Util.WpNameInfo("flag_door_out");
				}

				if ( _this.Goto(Map.BreakableFlagDoor_Info.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.High, "facing", Map.BreakableFlagDoor_Info.facing);
					_this.AddWeaponRequest(Priority.High, WEAPON.KNIFE );
					_this.BlockForWeaponChange( WEAPON.KNIFE );

					while( !Map.BreakableFlagDoor_Destroyed )
					{
						_this.Bot.HoldButton(BTN.ATTACK1, 0.5);
						yield();
					}
				}
			},
		},
		flag_door_1 =
		{
			EvalFunc = function(_this)
			{
				return !Map.BreakableFlagDoor_Destroyed;
			},
			navigate = function(_this)
			{
				// cache the info
				if ( !Map.BreakableFlagDoor_1_Info ) {
					Map.BreakableFlagDoor_1_Info = Util.WpNameInfo("flag_door_in");
				}

				if ( _this.Goto(Map.BreakableFlagDoor_1_Info.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.High, "facing", Map.BreakableFlagDoor_1_Info.facing);
					_this.AddWeaponRequest(Priority.High, WEAPON.KNIFE );
					_this.BlockForWeaponChange( WEAPON.KNIFE );

					while( !Map.BreakableFlagDoor_Destroyed )
					{
						_this.Bot.HoldButton(BTN.ATTACK1, 0.5);
						yield();
					}
				}
			},
		},
		lift =
		{
			navigate = function(_this) {
				if ( !Map.Lift_Info ) {
					Map.Lift_Info = Util.WpNameInfo("liftpt");
				}
				if ( _this.Goto(Map.Lift_Info.position) == EVENT.PATH_SUCCESS ) {
					_this.AddAimRequest(Priority.High, "facing", Map.Lift_Info.facing);
					_this.Bot.HoldButton(BTN.FORWARD, 0.5);
					sleep(4);
				}
			},
		},
		window_back_pt =
		{
			EvalFunc = function(_this)
			{
				return !Map.Breakable_Window_Back_Destroyed;
			},
			navigate = function(_this)
			{
				// cache the info
				if ( !Map.Breakable_Window_Back_Info ) {
					Map.Breakable_Window_Back_Info = Util.WpNameInfo("wb");
				}

				if ( _this.Goto(Map.Breakable_Window_Back_Info.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.High, "facing", Map.Breakable_Window_Back_Info.facing);
					_this.AddWeaponRequest(Priority.High, WEAPON.KNIFE );
					_this.BlockForWeaponChange( WEAPON.KNIFE );

					while( !Map.Breakable_Window_Back_Destroyed )
					{
						_this.Bot.HoldButton(BTN.ATTACK1, 0.5);
						yield();
					}
				}
			},
		},
		side_window_back_pt =
		{
			EvalFunc = function(_this)
			{
				return !Map.Breakable_Side_Window_Back_Destroyed;
			},
			navigate = function(_this)
			{
				// cache the info
				if ( !Map.Breakable_Side_Window_Back_Info ) {
					Map.Breakable_Side_Window_Back_Info = Util.WpNameInfo("swb");
				}

				if ( _this.Goto(Map.Breakable_Side_Window_Back_Info.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.High, "facing", Map.Breakable_Side_Window_Back_Info.facing);
					_this.AddWeaponRequest(Priority.High, WEAPON.KNIFE );
					_this.BlockForWeaponChange( WEAPON.KNIFE );

					while( !Map.Breakable_Side_Window_Back_Destroyed )
					{
						_this.Bot.HoldButton(BTN.ATTACK1, 0.5);
						yield();
					}
				}
			},
		},
		side_window_front_pt =
		{
			EvalFunc = function(_this)
			{
				return !Map.Breakable_Side_Window_Front_Destroyed;
			},
			navigate = function(_this)
			{
				// cache the info
				if ( !Map.Breakable_Side_Window_Front_Info ) {
					Map.Breakable_Side_Window_Front_Info = Util.WpNameInfo("swf");
				}

				if ( _this.Goto(Map.Breakable_Side_Window_Front_Info.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.High, "facing", Map.Breakable_Side_Window_Front_Info.facing);
					_this.AddWeaponRequest(Priority.High, WEAPON.KNIFE );
					_this.BlockForWeaponChange( WEAPON.KNIFE );

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

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

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

	Allies_Steal_Tank = function( trigger )
	{

		Util.MapDebugPrint( "Allies_Steal_Tank" );
	},

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

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

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

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

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

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

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

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

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

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

	Axis_Command_Post_Planted = function( trigger )
	{

		if ( Defuse_Axis_CP )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_Axis_Command_Post_.*" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Axis_Command_Post_.*" );
		}

		Util.MapDebugPrint( "Axis_Command_Post_Planted" );
	},

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

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

	Tank_Barrier_1_Planted = function( trigger )
	{

		//SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Tank_Barrier_2" );
		//SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_tunnel_door" );
		//SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Axis_Command_Post" );
		//SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_crypt_door" );

		Util.MapDebugPrint( "Tank_Barrier_1_Planted" );
	},

	Tank_Barrier_1_Defused = function( trigger )
	{

		//SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Tank_Barrier_2" );
		//SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_tunnel_door" );
		//SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Command_Post" );
		//SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_crypt_door" );

		Util.MapDebugPrint( "Tank_Barrier_1_Defused" );
	},

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

	Tank_Barrier_2_Planted = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"BUILD_tunnel_door",
			"BUILD_Axis_Command_Post",
			"BUILD_crypt_door",
		});

		Util.MapDebugPrint( "Tank_Barrier_2_Destroyed" );
	},

	Tank_Barrier_2_Defused = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"BUILD_tunnel_door",
			"BUILD_Axis_Command_Post",
			"BUILD_crypt_door",
		});

		Util.MapDebugPrint( "Tank_Barrier_2_Destroyed" );
	},

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

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

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

	crypt_door_Planted = function( trigger )
	{

		if ( Defuse_Crypt )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_crypt_door_.*");
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_crypt_door_.*");
		}

		Util.MapDebugPrint( "crypt_door_Planted" );
	},

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

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

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

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

	shack_flag_Axis_Captured = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_bank_flag" );
		SetAvailableMapGoals( TEAM.AXIS, false, "CHECKPOINT_bank_flag" );

		Util.MapDebugPrint( "shack_flag_Axis_Captured" );
	},

	shack_flag_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_bank_flag" );
		SetAvailableMapGoals( TEAM.AXIS, true, "CHECKPOINT_bank_flag" );

		Util.MapDebugPrint( "shack_flag_Allies_Captured" );
	},

	Tank_Passed_Barrier1 = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_a_tb1_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_a_Intersection_.*",
			"CHECKPOINT_shack_flag",
			"PLANT_Tank_Barrier_2",
			"PLANT_crypt_door",
			"BUILD_Embankment_Assault_Ramp",
			"BUILD_Allied_Command_Post",
			"CHECKPOINT_bank_flag",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_d_tb1_.*",
			"PLANTMINE_tb1_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"CALLARTILLERY_int_.*",
			"ARTILLERY_D_int_.*",
			"DEFEND_d_Intersection_.*",
			"PLANTMINE_int_.*",
			"AIRSTRIKE_int_.*",
		});

		Util.MapDebugPrint( "Tank_Passed_Barrier1" );
	},

	Tank_Passed_Barrier2 = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANTMINE_tb2_.*",
			"DEFEND_d_Crypt_to_TB2_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_d_end_.*" );

		Util.MapDebugPrint( "Tank_Passed_Barrier2" );
	},

	tank_at_location = function( trigger )
	{
		switch(Map.VehicleLocation)
		{
			case 1:
			{
				Map.tank_near_intersection();
			}
			case 2:
			{
				Map.tank_at_axis_spawn_back();
			}
			case 3:
			{
				Map.tank_near_axis_cp();
			}
			case 4:
			{
				Map.tank_near_bottom_tb2_hill();
			}
		}
		Util.MapDebugPrint("vehicle at location " + Map.VehicleLocation, true);
	},

	tank_near_intersection = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANTMINE_int_.*",
			"AIRSTRIKE_int_.*",
			"CALLARTILLERY_int_.*",
			"ARTILLERY_D_int_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"CALLARTILLERY_asb_.*",
			"ARTILLERY_D_asb_.*",
			"PLANTMINE_asb_.*",
		});

		Util.MapDebugPrint( "tank_near_intersection" );
	},

	tank_at_axis_spawn_back = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_a_Intersection_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_a_Axis_Spawn_Back_.*" );

		if ( Map.BreakableAxisMGRoof_Destroyed )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_a_Axis_Spawn_Back_1" );
		}

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_d_Intersection_.*",
			"PLANTMINE_asb_.*",
			"CALLARTILLERY_asb_.*",
			"ARTILLERY_D_asb_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"CALLARTILLERY_axis_lookout_.*",
			"ARTILLERY_D_cp_.*",
			"DEFEND_d_Axis_Spawn_Back_.*",
			"PLANTMINE_axis_cp_.*",
		});

		Util.MapDebugPrint( "tank_at_axis_spawn_back" );
	},

	tank_near_axis_cp = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_a_Axis_Spawn_Back_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_a_TB2_Hill_.*" );

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_d_Axis_Spawn_Back_.*",
			"PLANTMINE_axis_cp_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_d_Crypt_to_TB2_.*",
			"PLANTMINE_tb2_.*",
		});

		Util.MapDebugPrint( "tank_near_axis_cp" );
	},

	tank_near_bottom_tb2_hill = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_a_TB2_.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_a_TB2_Hill_.*" );

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"CALLARTILLERY_axis_lookout_.*",
			"ARTILLERY_D_cp_.*",
		});

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

global OnMapLoad = function()
{
	OnTrigger( "Allied Command Post constructed. Charge speed increased!`", Map.Allied_Command_Post_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Allied team has stolen the Tank!", Map.Allies_Steal_Tank );
	OnTrigger( "^3Allies have built the Embankment Assault Ramp!", Map.Embankment_Assault_Ramp_Built );
	OnTrigger( "Tank Barrier #1 has been constructed.", Map.Tank_Barrier_1_Built );
	OnTrigger( "Tank Barrier #2 has been constructed.", Map.Tank_Barrier_2_Built );
	OnTrigger( "The Tiger has been repaired!", Map.Tiger_Tank_Built );
	OnTrigger( "^3Allies have built the bunker MG42!", Map.bunker_MG42_Built );
	OnTrigger( "^3Axis have built the crypt door!", Map.crypt_door_Built );
	OnTrigger( "^3Axis have built the foot tunnel door!", Map.tunnel_door_Built );
	OnTrigger( "Axis have destroyed the Allied Command Post! ^3Allied respawn time now 20 secs!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "Planted at the Axis Command Post.", Map.Axis_Command_Post_Planted );
	OnTrigger( "Allies have destroyed the Axis Command Post! ^3Axis respawn time now 25 secs!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "^3Axis have destroyed the Embankment Assault Ramp!", Map.Embankment_Assault_Ramp_Destroyed );
	OnTrigger( "Planted at Tank Barrier #1.", Map.Tank_Barrier_1_Planted );
	OnTrigger( "Defused at Tank Barrier #1.", Map.Tank_Barrier_1_Defused );
	OnTrigger( "Tank Barrier #1 has been destroyed.", Map.Tank_Barrier_1_Destroyed );
	OnTrigger( "Planted at Tank Barrier #2.", Map.Tank_Barrier_2_Planted );
	OnTrigger( "Defused at Tank Barrier #2.", Map.Tank_Barrier_2_Defused );
	OnTrigger( "Tank Barrier #2 has been destroyed.", Map.Tank_Barrier_2_Destroyed );
	OnTrigger( "^3Axis have destroyed the bunker MG42!", Map.bunker_MG42_Destroyed );
	OnTrigger( "Planted at the crypt door.", Map.crypt_door_Planted );
	OnTrigger( "^3Allies have destroyed the crypt door!", Map.crypt_door_Destroyed );
	OnTrigger( "^3Allies have destroyed the foot tunnel door!", Map.tunnel_door_Destroyed );
	OnTrigger( "^3Axis have captured the Bank!", Map.bank_flag_Axis_Captured );
	OnTrigger( "^3Allies have taken the Bank!", Map.bank_flag_Allies_Captured );
	OnTrigger( "^3Axis have taken the Shack!", Map.shack_flag_Axis_Captured );
	OnTrigger( "^3Allies have captured the Shack!", Map.shack_flag_Allies_Captured );
	OnTrigger( "goldrush_allies_tank_barrier1", Map.Tank_Passed_Barrier1 );
	OnTrigger( "goldrush_allies_tank_barrier2", Map.Tank_Passed_Barrier2 );
	OnTrigger( "tank at location", Map.tank_at_location );

	// tank positions
	at_intersection = OnTriggerRegion(AABB(2559,2685,64,2668,2355,64), RegionTrigger.VehicleTrigger);
	at_back_of_axis_spawn = OnTriggerRegion(AABB(2535,1452,64,2569,1078,64), RegionTrigger.VehicleTrigger);
	at_axis_cp = OnTriggerRegion(AABB(1338,1080,64,1046,1316,64), RegionTrigger.VehicleTrigger);
	at_bottom_tb2_hill = OnTriggerRegion(AABB(1299,2074,64,1135,2403,120), RegionTrigger.VehicleTrigger);

	Util.DisableGoal(".*");

	Util.AddUsePoint( "PLANT_Tank_Barrier_1", { Vec3(2452, 3762, 32), Vec3(2670, 3808, 31) } );

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"BUILD_Tiger_Tank",
		"PLANT_Tank_Barrier_1",
		"MOVER_tank",
		"MOUNT_tank",
		"ATTACK_a_tb1_.*",
	});

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"BUILD_Tank_Barrier_1",
		"BUILD_Tank_Barrier_2",
		"BUILD_tunnel_door",
		"BUILD_crypt_door",
		"PLANT_Embankment_Assault_Ramp",
		"BUILD_Axis_Command_Post",
		"CHECKPOINT_bank_flag",
		"DEFEND_d_tb1_.*",
		"PLANTMINE_tb1_.*",
	});

	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=5, MaxCampTime=20});
	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=5, MaxCampTime=20});

	SetGoalPriority( "BUILD_Allied_Command_Post", 0.89 );
	SetGoalPriority( "BUILD_Tank_Barrier_1", 0.90 );
	SetGoalPriority( "BUILD_Tank_Barrier_2", 0.89 );
	SetGoalPriority( "BUILD_tunnel_door", 0.88 );
	SetGoalPriority( "BUILD_Axis_Command_Post", 0.87 );
	SetGoalPriority( "BUILD_crypt_door", 0.86 );

	SetGoalPriority( "DEFUSE_Tank_Barrier_1", 1.5, TEAM.AXIS, CLASS.ENGINEER, true );
	SetGoalPriority( "DEFUSE_Tank_Barrier_2", 1.4, TEAM.AXIS, CLASS.ENGINEER, true );

	Wp.SetWaypointFlag("breakable_ladder_1_top", "closed", false);
	Wp.SetWaypointFlag("breakable_ladder_2_top", "closed", false);
	Wp.SetWaypointFlag("axis_mg_roof_1", "closed", false);
	Wp.SetWaypointFlag("axis_mg_roof_2", "closed", false);

	Util.SetMaxUsers( 1, "CHECKPOINT_bank_flag" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );

	Util.SetMaxUsers( 1, "BUILD.*" );
	Util.SetMaxUsers( 1, "CAMP.*" );

	Util.SetGoalPosition( 2620.5, 3606.6, 32.125, "PLANT_Tank_Barrier_1");
	Util.SetGoalPosition( 1175.2, 3437.9, 324.69, "PLANT_Tank_Barrier_2");

	thread(Map.check_breakableFence1);
	thread(Map.check_breakableFence2);
	thread(Map.check_breakableLadder1);
	thread(Map.check_breakableLadder2);
	thread(Map.check_flagDoor);
	thread(Map.check_lift);
	thread(Map.check_breakableWindowBack);
	thread(Map.check_breakableSideWindowBack);
	thread(Map.check_breakableSideWindowFront);
	thread(Map.check_axis_mg_roof);

	Util.EnableGoal("ROUTE_.*"); //enable routing for both teams

	Util.MapDebugPrint( "OnMapLoad" );
};

global OnBotJoin = function( bot )
{
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		ATTACK_a_tb1_1 =
		{
			ROUTE_r_Allied_Spawn =
			{
				ROUTE_r_Allied_Spawn_Ladder = {},
				ROUTE_r_Allied_Side_Window_In =
				{
					ROUTE_r_Allied_Side_Window_Out = {},
				},
				ROUTE_r_Allied_End_Window =
				{
					ROUTE_r_Allied_Tunnel_Door =
					{
					},
					ROUTE_r_Allied_Tank_Barrier_1 =
					{
					},
				},
			},
			ROUTE_r_Allied_Spawn_Shack =
			{
				ROUTE_r_Allied_Spawn_Shack_Back =
				{
					Weight = 2,
				},
				ROUTE_r_Assault_Ramp_Bottom = {},
			},
		},
		BUILD_Allied_Command_Post =
		{
			ROUTE_r_Allied_Spawn =
			{
				ROUTE_r_Allied_Spawn_Ladder = {},
				ROUTE_r_Allied_Side_Window_In =
				{
					ROUTE_r_Allied_Side_Window_Out = {},
				},
				ROUTE_r_Allied_End_Window =
				{
					ROUTE_r_Allied_Tunnel_Door =
					{
						ROUTE_r_Alley_Begin =
						{
							ROUTE_r_Allied_CP_Window = {},
						},
					},
					ROUTE_r_Allied_Tank_Barrier_1 =
					{
					},
				},
			},
		},
		BUILD_Axis_Command_Post =
		{
			ROUTE_r_Axis_Spawn =
			{
				ROUTE_r_Axis_Spawn_Window_Back = {},
				ROUTE_r_Axis_Spawn_Side_Window_Back = {},
				ROUTE_r_Axis_Spawn_Side_Window_Front = {},
				ROUTE_r_Axis_Spawn_Front = {},
			},
		},
		BUILD_Tiger_Tank =
		{
			ROUTE_r_Allied_Spawn =
			{
				ROUTE_r_Allied_Spawn_Ladder = {},
				ROUTE_r_Allied_Side_Window_In =
				{
					ROUTE_r_Allied_Side_Window_Out = {},
				},
			},
		},
		BUILD_Tank_Barrier_1 =
		{
			ROUTE_r_Allied_Spawn =
			{
				ROUTE_r_Axis_Spawn_Front =
				{
					ROUTE_r_Ruins_Tank_Barrier_1 =
					{
					},
					ROUTE_r_Alley_Intersection =
					{
						ROUTE_r_Alley_Begin = {},
					},
				},
				ROUTE_r_Axis_Spawn_Side_Window_Back =
				{
					ROUTE_r_Ruins_Tank_Barrier_1 = {},
				},
				ROUTE_r_Axis_Spawn_Side_Window_Front =
				{
					ROUTE_r_Ruins_Tank_Barrier_1 = {},
				},
				ROUTE_r_Axis_Spawn_Window_Back =
				{
					ROUTE_r_Ruins_Tank_Barrier_1 =
					{
						ROUTE_r_Alley_Lift =
						{
							ROUTE_r_Alley_Begin = {},
						},
					},
				},
			},
		},
		BUILD_Tank_Barrier_2 =
		{
			ROUTE_r_Axis_Spawn =
			{
				ROUTE_r_Axis_Spawn_Side_Window_Front = {},
				ROUTE_r_Axis_Spawn_Window_Back = {},
				ROUTE_r_Axis_Spawn_Side_Window_Back =
				{
					ROUTE_r_Axis_CourtYard_Side = {},
					ROUTE_r_Alley_Lift =
					{
						ROUTE_r_Allied_CP_Roof = {},
					},
				},
				ROUTE_r_Axis_Spawn_Front =
				{
					ROUTE_r_Tank_Barrier_2 = {},
					ROUTE_r_Ruins_Roof = {},
				},
			},
			ROUTE_r_Axis_Flag_Spawn =
			{
				ROUTE_r_Tank_Path_Intersection =
				{
					ROUTE_r_Tank_Barrier_2 = {},
					ROUTE_r_Ruins_Roof = {},
				},
				ROUTE_r_Allied_CP_Roof = {},
				ROUTE_r_Tank_Path_Lift =
				{
					ROUTE_r_Axis_CourtYard_Back = {},
				},
			},
		},
		PLANT_Tank_Barrier_1 =
		{
			ROUTE_r_Allied_Spawn =
			{
				ROUTE_r_Allied_Spawn_Ladder = {},
				ROUTE_r_Allied_Side_Window_In =
				{
					ROUTE_r_Allied_Side_Window_Out = {},
				},
				ROUTE_r_Allied_End_Window =
				{
					ROUTE_r_Allied_Tunnel_Door = {},
					ROUTE_r_Allied_Tank_Barrier_1 = {},
				},
			},
		},
		CHECKPOINT_bank_flag =
		{
			ROUTE_r_Allied_Spawn =
			{
				ROUTE_r_Allied_Spawn_Ladder = {},
				ROUTE_r_Allied_Side_Window_In =
				{
					ROUTE_r_Allied_Side_Window_Out = {},
				},
				ROUTE_r_Allied_End_Window =
				{
					ROUTE_r_Allied_Tunnel_Door =
					{
						ROUTE_r_Alley_Begin =
						{
							Weight = 3,
							ROUTE_r_Allied_CP_Window = {},
							ROUTE_r_Alley_Lift =
							{
								ROUTE_r_Lift = {},
							},
						},
						ROUTE_r_Tank_Path_Alley =
						{
							ROUTE_r_Tank_Path_Intersection =
							{
								ROUTE_r_Alley_Intersection =
								{
									ROUTE_r_Alley_Lift =
									{
										ROUTE_r_Lift = {},
									},
								},
								ROUTE_r_Tank_Path_Lift =
								{
									ROUTE_r_Lift = {},
								},
							},
						},
					},
					ROUTE_r_Allied_Tank_Barrier_1 =
					{
					},
				},
				ROUTE_r_Allied_Spawn_Shack_Back =
				{
					ROUTE_r_Assault_Ramp_Bottom =
					{
						ROUTE_r_Assault_Ramp_Top =
						{
							ROUTE_r_Allied_CP_Roof = {},
						},
					},
				},
			},
			ROUTE_r_Allied_Spawn_Shack =
			{
				ROUTE_r_Assault_Ramp_Bottom =
				{
					ROUTE_r_Assault_Ramp_Top =
					{
						ROUTE_r_Allied_CP_Roof = {},
					},
				},
				ROUTE_r_Allied_Tank_Barrier_1 =
				{
					ROUTE_r_Alley_Begin =
					{
						Weight = 3,
						ROUTE_r_Allied_CP_Window = {},
						ROUTE_r_Alley_Lift =
						{
							ROUTE_r_Lift = {},
						},
					},
					ROUTE_r_Tank_Path_Alley =
					{
						ROUTE_r_Tank_Path_Intersection =
						{
							ROUTE_r_Alley_Intersection =
							{
								ROUTE_r_Alley_Lift =
								{
									ROUTE_r_Lift = {},
								},
							},
							ROUTE_r_Tank_Path_Lift =
							{
								ROUTE_r_Lift = {},
							},
						},
					},
				},

			},
			ROUTE_r_Axis_Spawn =
			{
				ROUTE_r_Axis_Spawn_Window_Back = {},
				ROUTE_r_Axis_Spawn_Side_Window_Back = {},
				ROUTE_r_Axis_Spawn_Side_Window_Front = {},
			},
		},
	};

	MapRoutes.ATTACK_a_tb1_2 = MapRoutes.ATTACK_a_tb1_1;
	MapRoutes.ATTACK_a_tb1_3 = MapRoutes.BUILD_Allied_Command_Post;
	MapRoutes.ATTACK_a_tb1_4 = MapRoutes.ATTACK_a_tb1_1;
	MapRoutes.BUILD_crypt_door = MapRoutes.BUILD_Axis_Command_Post;
	MapRoutes.DEFEND_d_tb1_1 = MapRoutes.BUILD_Tank_Barrier_1;
	MapRoutes.DEFEND_d_tb1_2 = MapRoutes.BUILD_Tank_Barrier_1;
	MapRoutes.PLANT_tunnel_door = MapRoutes.ATTACK_a_tb1_1;

	Util.Routes(MapRoutes);
};

global OnExit = function()
{
	threadKillAll();
};
