global Map =
{
	Talk = true, // set to false if you don't want the bots to use voice chat
	Debug = 0,
	HQ_is_cleared = false,
	StationIsSecured = false,
	DepotIsCleared = false,
	ElevatorDoorStatus = 0, // closed
	StationEntranceStatus = 1, // intact
	DefendingTeam = TEAM.AXIS,
	Focus = null,

	Depot_Side_Door_Dyno = 0,
	Neutral_Command_Post_Dyno = 0,
	Station_Entrance_Dyno = 0,
	Assault_Ramp_Dyno = 0,

	Ammo_Cabinet_first_ammocabinet = "AMMOCAB_first_ammocabinet",
	Health_Cabinet_first_healthcabinet = "HEALTHCAB_first_healthcabinet",
	Checkpoint_flag_axisHQ = "CHECKPOINT_flag_axisHQ",
	Checkpoint_flag_bank = "CHECKPOINT_flag_bank",
	Checkpoint_flag_depot = "CHECKPOINT_flag_depot",
	Checkpoint_flag_hotel = "CHECKPOINT_flag_hotel",
	Checkpoint_flag_library = "CHECKPOINT_flag_library",
	Checkpoint_flag_shop = "CHECKPOINT_flag_shop",
	Checkpoint_flag_station = "CHECKPOINT_flag_station",
	Build_Depot_Side_Door = "BUILD_Depot_Side_Door",
	Build_Neutral_Command_Post = "BUILD_Neutral_Command_Post",
	Build_Station_Barricade = "BUILD_Station_Barricade",
	Plant_Depot_Side_Door = "PLANT_Depot_Side_Door",
	Plant_Neutral_Command_Post = "PLANT_Neutral_Command_Post",
	Plant_Station_Entrance = "PLANT_Station_Entrance",
	Explode_Station_Barricade = "EXPLODE_Station_Barricade",
	Mount_Hotel_MG = "MOUNTMG42_181",
	Mount_Factory_MG = "MOUNTMG42_1316",
	Repair_Hotel_MG = "REPAIRMG42_181",
	Repair_Factory_MG = "REPAIRMG42_1316",

	/*** TRIGGER REGIONS ***/
	station_dyno_trigger =
	{
		Name = "station_dyno_trigger",
		TriggerOnClass = CLASS.ENGINEER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES && Map.StationEntranceStatus == 1 && !Map.StationIsSecured )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_dyno_station.*" );
			}

			Util.MapDebugPrint(GetEntName(ent) + " near station dyno", true);
		},
		OnExit = function(ent)
		{
			Util.MapDebugPrint(GetEntName(ent) + " leaves station dyno", true);
		},
	},

	factory_mg_trigger =
	{
		Name = "factory_mg_trigger",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.AXIS )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_anti_mg" );
			}

			Util.MapDebugPrint( "factory mg manned", true );
		},
		OnExit = function(ent)
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_anti_mg" );

			Util.MapDebugPrint( "factory mg unmanned", true );
		},
	},

	// disable bot pushing and combat movement in this region.
	disablepush =
	{
		Name = "disablepush",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			b = Util.IsBot(ent);
			if (b)
			{
				b.DisableBotPush(true);
				b.DisableCombatMovement = true;
			}
			Util.MapDebugPrint( "disablepush", true );
		},
		OnExit = function(ent)
		{
			b = Util.IsBot(ent);
			if (b)
			{
				b.DisableBotPush(false);
				b.DisableCombatMovement = false;
			}
		},
	},

	/*** SWITCHES ***/
	Switches =
	{
		//uses paththrough
		elevator_switch =
		{
			Enabled = true,
			Priority = 0.0,
			WaypointName = "elevator_switch",
			Timeout = 1500,
			AimPosition = Vector3(6193.875,6963.353,75.186),
			Wait = function()
			{
				if ( Map.ElevatorDoorStatus == 1 )
				{
					sleep(2);
					return true;
				}
				return false;
			},
		},

		elevator_switch2 =
		{
			Enabled = false,
			Priority = 0.6,
			WaypointName = "elevator_switch2",
			Timeout = 1500,
			LimitDistance = 1000,
			LimitBots = 1,
			LimitTeam = (1<<TEAM.ALLIES),
			AimPosition = Vector3(6214.125,6963.652,74.809),
		},
	},

	/*** PATHTHROUGH NAV TABLES ***/
	Navigation =
	{
		ladder2 =
		{
			navigate = function(_this)
			{
				Util.MapDebugPrint("ladder paththrough");
				//  *sigh* this sucks like heck ... óÒ ... but it works more or less -- d00d
				/*
				_this.AddAimRequest(Priority.High);  // leave off optional parameters, defaults to AimPosition, so set it
				_this.AimVector = Vec3(5686,4880,0); // this can be called at any time in the script goal
				_this.Bot.HoldButton(BTN.FORWARD, 5.0);
				*/
				sleep(5);
			},
		},

		ladder1 =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 2.5);
				sleep(2.5);
			},
		},

		ladder4 = // waypoint name ladder4
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 4);
				sleep(4);
			},
		},

		quickjump =
		{
			// better response time than nav flags
			navigate = function(_this)
			{
				_this.Bot.PressButton(BTN.JUMP);
				yield();
			},
		},
	},

	/*** TRIGGER CALLBACKS ***/
	Elevator_Door_Moving = function( trigger )
	{
		if ( trigger.Action == "opening" )
		{
			Map.ElevatorDoorStatus = 1; //open
			Map.Switches.elevator_switch.Enabled = false;
			Map.Switches.elevator_switch2.Enabled = false;
			Util.MapDebugPrint("door is opening");
		}
		else
		{
			Map.ElevatorDoorStatus = 0; //closed
			Map.Switches.elevator_switch.Enabled = true;
			if ( Map.Focus == "bank" )
			{
				Map.Switches.elevator_switch2.Enabled = true;
			}
		}
	},

	Depot_Side_Door_Built = function( trigger )
	{
		Map.Depot_Side_Door_Dyno = 0;

		Util.MapDebugPrint( "Depot_Side_Door_Built" );
	},

	// Shop spawn enabled for Allies, Axis fallen back to the bank, etc.
	// Focus on hotel and depot.
	Assault_Ramp_Enabled = function( trigger )
	{
		Util.DisableGoal( "DEFEND_shop.*", true );
		Util.DisableGoal( "ATTACK_shop.*", true );
		Util.DisableGoal( "ATTACK_station.*", true );
		Util.DisableGoal( "DEFEND_station.*", true );
		Util.DisableGoal( "SNIPE_station.*", true );
		Util.DisableGoal( "DEFEND_axis_start.*", true );
		Util.DisableGoal( "SNIPE_allies_start.*", true );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			Map.Checkpoint_flag_depot,
			Map.Checkpoint_flag_hotel,
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_.*",
			"CALLARTILLERY_.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_hotel.*",
			"ATTACK_depot.*",
			"BUILD_ramp",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOBILEMG42_1733",
			"CALLARTILLERY.*",
			"DEFEND_.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_hotel.*",
			"DEFEND_depot.*",
		});

		Util.MapDebugPrint( "Assault_Ramp_Enabled" );
	},

	Assault_Ramp_Built = function( trigger )
	{
		Wp.SetWaypointFlag( "ramp1", "closed", false );
		Wp.SetWaypointFlag( "ramp2", "closed", false );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_ramp1" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_ramp" );

		if ( Map.Talk && MAP_TALK )
		{
			rand = ETUtil.CountTeam(TEAM.AXIS);
			foreach ( gameId and bot in BotTable )
			{
				if (bot.GetTeam() == TEAM.AXIS && bot.GetClass() != CLASS.ENGINEER && RandInt(1,rand) < 2)
				{
					sleep(1.0);
					bot.SayVoice(VOICE.DESTROY_CONST);
					break;
				}
			}
		}

		Util.MapDebugPrint( "Assault_Ramp_Built" );
	},

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

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

	Assault_Ramp_Destroyed = function( trigger )
	{
		Wp.SetWaypointFlag( "ramp1", "closed", true );
		Wp.SetWaypointFlag( "ramp2", "closed", true );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_ramp1" );

		Util.MapDebugPrint( "Assault_Ramp_Destroyed" );
	},

	Allied_Command_Post_Built = function( trigger )
	{
		Map.Neutral_Command_Post_Dyno = 0;
		SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_Neutral_Command_Post );

		Util.MapDebugPrint( "Allied_Command_Post_Built" );
	},

	Axis_Command_Post_Built = function( trigger )
	{
		Map.Neutral_Command_Post_Dyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Neutral_Command_Post );

		Util.MapDebugPrint( "Axis_Command_Post_Built" );
	},

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

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

	Depot_Side_Door_Planted = function( trigger )
	{
		Map.Depot_Side_Door_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Depot_Side_Door );

		Util.MapDebugPrint( "Depot_Side_Door_Planted" );
	},

	Neutral_Command_Post_Planted = function( trigger )
	{
		Map.Neutral_Command_Post_Dyno += 1;
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Plant_Neutral_Command_Post );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Neutral_Command_Post );

		Util.MapDebugPrint( "Neutral_Command_Post_Planted" );
	},

	Station_Entrance_Planted = function( trigger )
	{
		Map.Station_Entrance_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Station_Entrance );
		if ( !Map.StationIsSecured )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_dyno_station.*" ); }

		Util.MapDebugPrint( "Station_Entrance_Planted" );
	},

	Depot_Side_Door_Defused = function( trigger )
	{
		Map.Depot_Side_Door_Dyno -= 1;
		if ( Map.Depot_Side_Door_Dyno < 1 && !Map.DepotIsCleared )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Depot_Side_Door ); }

		Util.MapDebugPrint( "Depot_Side_Door_Defused" );
	},

	Neutral_Command_Post_Defused = function( trigger )
	{
		Map.Neutral_Command_Post_Dyno -= 1;
		if ( Map.Neutral_Command_Post_Dyno < 1 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_Neutral_Command_Post );
			SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Neutral_Command_Post );
		}

		Util.MapDebugPrint( "Neutral_Command_Post_Defused" );
	},

	Station_Entrance_Defused = function( trigger )
	{
		Map.Station_Entrance_Dyno -= 1;
		if ( Map.Station_Entrance_Dyno < 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Station_Entrance );
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_dyno_station.*" );
		}

		Util.MapDebugPrint( "Station_Entrance_Defused" );
	},

	Depot_Side_Door_Destroyed = function( trigger )
	{
		Map.Depot_Side_Door_Dyno = 0;

		Util.MapDebugPrint( "Depot_Side_Door_Destroyed" );
	},

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

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

	Station_Entrance_Destroyed = function( trigger )
	{
		Map.Station_Entrance_Dyno = 0;
		Map.StationEntranceStatus = 0; //open

		if ( !Map.StationIsSecured )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"DEFEND_station.*",
				"TRIPMINE_station_entrance.*",
			});
		}
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_dyno_station.*",
			"SMOKEBOMB_allies.*",
		});

		Util.MapDebugPrint( "Station_Entrance_Destroyed" );
	},

	/*** FLAGS ***/

	flag_axisHQ_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Checkpoint_flag_axisHQ );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_axisHQ );

		Util.MapDebugPrint( "flag_axisHQ_Axis_Captured" );
	},

	flag_axisHQ_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_axisHQ );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.Checkpoint_flag_axisHQ );

		Util.MapDebugPrint( "flag_axisHQ_Allies_Captured" );
	},

	flag_axisHQ_Allies_Secured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"BUILD_ramp",
			Map.Checkpoint_flag_axisHQ,
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_hq.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_ramp" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_hq.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_axisHQ );

		Util.MapDebugPrint( "flag_axisHQ_Allies_Secured" );
	},

	axisHQ_Cleared = function( trigger )
	{
		Map.HQ_is_cleared = true;

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			Map.Checkpoint_flag_library,
			Map.Checkpoint_flag_bank,
			"SNIPE_bank.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_hq.*" );

		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_hq.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"SNIPE_bank.*",
			"DEFEND_bank.*",
			Map.Mount_Factory_MG,
			Map.Repair_Factory_MG,
		});

		Util.MapDebugPrint( "axisHQ_Cleared" );
	},

	flag_bank_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Checkpoint_flag_bank );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_bank );

		Util.MapDebugPrint( "flag_bank_Axis_Captured" );
	},

	flag_bank_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_bank );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.Checkpoint_flag_bank );
		Map.Focus = "bank";

		Util.MapDebugPrint( "flag_bank_Allies_Captured" );
	},

	flag_bank_Allies_Secured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_bank );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_hide_bank.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			Map.Checkpoint_flag_bank,
			"DEFEND_bank.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_hide_bank.*" );
		Map.Switches.elevator_switch2.Enabled = true;

		Util.MapDebugPrint( "flag_bank_Allies_Secured" );
	},

	bank_Cleared = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_hide_bank.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_hide_bank.*" );
		Map.Switches.elevator_switch2.Enabled = false;
		Map.Switches.elevator_switch2.LimitTeam = 0;
		Map.Focus = null;

		Util.MapDebugPrint( "bank_Cleared" );
	},

	flag_depot_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Checkpoint_flag_depot );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_depot );

		Util.MapDebugPrint( "flag_depot_Axis_Captured" );
	},

	flag_depot_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_depot );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.Checkpoint_flag_depot );

		Util.MapDebugPrint( "flag_depot_Allies_Captured" );
	},

	flag_depot_Allies_Secured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_depot );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_hide_depot.*",
			"ATTACK_depot.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_depot );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_hide_depot.*",
			"DEFEND_depot.*",
		});

		Util.MapDebugPrint( "flag_depot_Allies_Secured" );
	},

	depot_Cleared = function( trigger )
	{
		Map.DepotIsCleared = true;
		SetAvailableMapGoals( TEAM.ALLIES, true, "GRENADE_factory_mg.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_hide_depot.*",
			"ATTACK_depot.*",
			Map.Plant_Depot_Side_Door,
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			Map.Build_Depot_Side_Door,
			"ATTACK_depot.*",
			"DEFEND_hide_depot.*",
			"DEFEND_depot.*",
		});

		Util.MapDebugPrint( "depot_Cleared" );
	},

	flag_hotel_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Checkpoint_flag_hotel );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_hotel );

		Util.MapDebugPrint( "flag_hotel_Axis_Captured" );
	},

	flag_hotel_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_hotel_mg.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Mount_Hotel_MG );
		SetMapGoalProperties( Map.Mount_Hotel_MG, { AimVectors={} } );

		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_hotel );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.Checkpoint_flag_hotel );

		Util.MapDebugPrint( "flag_hotel_Allies_Captured" );
	},

	flag_hotel_Allies_Secured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_hotel );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_hotel );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_hotel.*",
			"ATTACK_hide_hotel.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_hide_hotel.*",
			"DEFEND_hotel.*",
		});

		Util.MapDebugPrint( "flag_hotel_Allies_Secured" );
	},

	hotel_Cleared = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_hotel.*",
			"ATTACK_hide_hotel.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_hide_hotel.*",
			"DEFEND_hotel.*",
		});

		Util.MapDebugPrint( "hotel_Cleared" );
	},

	flag_library_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Checkpoint_flag_library );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_library );

		Util.MapDebugPrint( "flag_library_Axis_Captured" );
	},

	flag_library_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_library );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.Checkpoint_flag_library );

		Util.MapDebugPrint( "flag_library_Allies_Captured" );
	},

	flag_library_Allies_Secured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_library );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_library );

		Util.MapDebugPrint( "flag_library_Allies_Secured" );
	},

	flag_shop_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_shop.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_shop.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Checkpoint_flag_shop );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_shop );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_shop.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_shop.*" );

		Util.MapDebugPrint( "flag_shop_Axis_Captured" );
	},

	flag_shop_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_shop.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_shop.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_shop );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.Checkpoint_flag_shop );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_shop.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_shop.*" );

		Util.MapDebugPrint( "flag_shop_Allies_Captured" );
	},

	flag_shop_Allies_Secured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_shop );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_shop.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_shop );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_shop.*",
			"ATTACK_shop.*",
		});

		DeleteTriggerRegion( Map.iw1 );
		DeleteTriggerRegion( Map.iw2 );

		Util.MapDebugPrint( "flag_shop_Allies_Secured" );
	},

	flag_station_Axis_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_station.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Checkpoint_flag_station );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_station );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_station.*" );

		Util.MapDebugPrint( "flag_station_Axis_Captured" );
	},

	flag_station_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_station.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_station );
		SetAvailableMapGoals( TEAM.AXIS, true, Map.Checkpoint_flag_station );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_station.*" );

		Util.MapDebugPrint( "flag_station_Allies_Captured" );
	},

	flag_station_Allies_Secured = function( trigger )
	{
		Map.StationIsSecured = true;

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SMOKEBOMB_allies.*",
			"GRENADE_barrier.*",
			"DEFEND_station.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_station.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Checkpoint_flag_station );

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_station.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Checkpoint_flag_station );

		Util.MapDebugPrint( "flag_station_Allies_Secured" );
	},

	station_Cleared = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Depot_Side_Door );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_station.*",
			"ATTACK_station.*",
			"SNIPE_station.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			Map.Build_Station_Barricade,
			"TRIPMINE_station_entrance.*",
			"DEFEND_station.*",
			"ATTACK_station.*",
			"SNIPE_station.*",
		});

		Wp.SetWaypointFlag( "station_teamdoor", "disguise", false );

		Util.MapDebugPrint( "station_Cleared" );
	},

	Axis_at_Factory = function( trigger )
	{
		Util.DisableGoal( "MOBILEMORTAR.*", true );
		SetAvailableMapGoals( TEAM.ALLIES, true, Map.Checkpoint_flag_axisHQ );

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

global OnMapLoad = function()
{
	/*** REGION TRIGGERS ***/
	sdt = OnTriggerRegion( AABB(4840,3717,15, 5180,4120,140), Map.station_dyno_trigger );
	fmg = OnTriggerRegion( AABB(5617,8700,190, 5736,8850,267), Map.factory_mg_trigger );
	Map.iw1 = OnTriggerRegion( AABB(5433,2987,5, 5525,3089,194), RegionTrigger.IntrusionWarning );
	Map.iw2 = OnTriggerRegion( AABB(4922,3764,9, 5076,4046,230), RegionTrigger.IntrusionWarning );

	// these region triggers disable bot pushing and combat movement at the barb-wire barrier and other places
	tmp = OnTriggerRegion( AABB(5668,2637,333, 6177,3306,613), Map.disablepush );
	dp = OnTriggerRegion( AABB(5585,4505,335, 5776,4882,641), Map.disablepush );
	bwb = OnTriggerRegion( AABB(5000,2900,0, 5600,4000,200), Map.disablepush );
	bwb1 = OnTriggerRegion( AABB(4623,2538,0, 4990,3100,250), Map.disablepush );
	hotel_mg = OnTriggerRegion( AABB(4347,5056,23, 4902,5992,170), Map.disablepush );
	factory_spawn1 = OnTriggerRegion( AABB(4313,8723,5, 5694,9521,608), Map.disablepush );
	factory_spawn2 = OnTriggerRegion( AABB(4411,7708,417, 4643,8741,620), Map.disablepush );
	ladder1 = OnTriggerRegion( AABB(6760,4236,0, 6896,4327,618), Map.disablepush );
	fireexit = OnTriggerRegion( AABB(6202,3449,-8, 6434,3962,570), Map.disablepush );

	/*** TRIGGER SETUP ***/
	OnTrigger( "Defused at the Station Entrance.", Map.Station_Entrance_Defused );
	OnTrigger( "Planted at the Station Entrance.", Map.Station_Entrance_Planted );
	OnTrigger( "^d*** ^7The Allies have destroyed the Station Main Entrance! ^d***", Map.Station_Entrance_Destroyed );
	OnTrigger( "^d*** ^7Allies have destroyed the Station Barricade! ^d***", Map.Station_Barricade_Destroyed );
	OnTrigger( "^1*** ^7Axis have rebuilt the Station Barricade! ^1***", Map.Station_Barricade_Built );
	OnTrigger( "^1*** ^7Axis have repaired the Depot Side Door! ^1***", Map.Depot_Side_Door_Built );
	OnTrigger( "Planted at the Depot Side Door.", Map.Depot_Side_Door_Planted );
	OnTrigger( "Defused at the Depot Side Door.", Map.Depot_Side_Door_Defused );
	OnTrigger( "^d*** ^7Allies have destroyed the Depot Side Door! ^d*** ", Map.Depot_Side_Door_Destroyed );
	OnTrigger( "^1*** ^7Axis have fallen back to the ^3Bank! ^1***", Map.Assault_Ramp_Enabled );
	OnTrigger( "^d*** ^7The Allies have built the Assault Ramp at the Axis HQ! ^d***", Map.Assault_Ramp_Built );
	OnTrigger( "Planted at the Assault Ramp.", Map.Assault_Ramp_Planted );
	OnTrigger( "Defused at the Assault Ramp.", Map.Assault_Ramp_Defused );
	OnTrigger( "^1*** ^7Axis have destroyed the Assault Ramp! ^1***", Map.Assault_Ramp_Destroyed );
	OnTrigger( "^1*** ^7Axis Command Post constructed. Charge speed increased! ^1***", Map.Axis_Command_Post_Built );
	OnTrigger( "^d*** ^7Allied Command Post constructed. Charge speed increased! ^d***", Map.Allied_Command_Post_Built );
	OnTrigger( "Planted at the Neutral Command Post.", Map.Neutral_Command_Post_Planted );
	OnTrigger( "Defused at the Neutral Command Post.", Map.Neutral_Command_Post_Defused );
	OnTrigger( "^3*** ^7Axis team has destroyed the Allied Command Post! ^3***", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "^3*** Allied team has destroyed the Axis Command Post! ^3***", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "banklift_Moving", Map.Elevator_Door_Moving );

	OnTrigger( "^1*** ^7Axis have recaptured the ^3Axis HQ! ^1***", Map.flag_axisHQ_Axis_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Axis HQ ^7and must hold it for a tot", Map.flag_axisHQ_Allies_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Axis HQ ^7- they must clear all defe", Map.flag_axisHQ_Allies_Secured );
	OnTrigger( "^d*** ^7All axis defenders have been cleared from the ^3Axis HQ! ^d***", Map.axisHQ_Cleared );
	OnTrigger( "^1*** ^7Axis have recaptured the ^3Bank! ^1***", Map.flag_bank_Axis_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Bank ^7and must hold it for a total ", Map.flag_bank_Allies_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Bank ^7- they must clear all defende", Map.flag_bank_Allies_Secured );
	OnTrigger( "^1*** ^7Axis have recaptured the ^3Depot! ^1***", Map.flag_depot_Axis_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Depot ^7and must hold it for a total", Map.flag_depot_Allies_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Depot ^7- they must clear all defend", Map.flag_depot_Allies_Secured );
	OnTrigger( "^d*** ^7All axis defenders have been cleared from the ^3Depot! ^d***", Map.depot_Cleared );
	OnTrigger( "^d*** ^7All axis defenders have been cleared from the ^3Bank! ^d***", Map.bank_Cleared );
	OnTrigger( "^1*** ^7Axis have recaptured the ^3Hotel! ^1***", Map.flag_hotel_Axis_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Hotel ^7and must hold it for a total", Map.flag_hotel_Allies_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Hotel ^7- they must clear all defend", Map.flag_hotel_Allies_Secured );
	OnTrigger( "^d*** ^7All axis defenders have been cleared from the ^3Hotel! ^d***", Map.hotel_Cleared );
	OnTrigger( "^1*** ^7Axis have recaptured the ^3Library! ^1***", Map.flag_library_Axis_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Library ^7and must hold it for a tot", Map.flag_library_Allies_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Library ^7- they must clear all defe", Map.flag_library_Allies_Secured );
	OnTrigger( "^1*** ^7Axis have recaptured the ^3Shop! ^1***", Map.flag_shop_Axis_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Shop ^7and must hold it for a total ", Map.flag_shop_Allies_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Shop ^7- they must clear all defende", Map.flag_shop_Allies_Secured );
	OnTrigger( "^1*** ^7Axis have recaptured the ^3Station! ^1***", Map.flag_station_Axis_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Station ^7and must hold it for a tot", Map.flag_station_Allies_Captured );
	OnTrigger( "^d*** ^7Allies have captured the ^3Station ^7- they must clear all defe", Map.flag_station_Allies_Secured );
	OnTrigger( "^d*** ^7All axis defenders have been cleared from the ^3Station! ^d***", Map.station_Cleared );

	OnTrigger( "^1*** ^7Axis have fallen back to the ^3Factory! ^1***", Map.Axis_at_Factory );

	// Goals, goals, gÔÔals!
	Util.RemoveGoal( "MOVER_tank" );
	Util.DisableGoal( "CHECKPOINT_.*", true );
	Util.DisableGoal( "MOUNT.*", true );

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		Map.Checkpoint_flag_shop,
		Map.Checkpoint_flag_station,
	});
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		Map.Repair_Factory_MG,
		Map.Repair_Hotel_MG,
		Map.Plant_Depot_Side_Door,
		"BUILD_ramp",
		"TRIPMINE_.*",
		"GRENADE_.*",
		"MOBILEMG.*",
		"MOBILEMORTAR.*",
		"ARTILLERY_.*",
		"CALLARTILLERY_.*",
		"ATTACK_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_shop.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"DEFEND_.*",
		"SNIPE_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"SNIPE_allies_start.*",
		"SNIPE_lib1",
		"SNIPE_lib2",
		"SNIPE_lib3",
		"SMOKEBOMB_allies.*",
		"GRENADE_barrier[123]",
		"GRENADE_hotel_mg.*",
		"CALLARTILLERY_allies_mg.*",
		"ARTILLERY_S_allies_mg.*",
	});

	SetAvailableMapGoals( TEAM.AXIS, false, {
		Map.Repair_Factory_MG,
		"ARTILLERY_S_allies_mg.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, Map.Mount_Hotel_MG );
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"TRIPMINE_.*",
		"GRENADE_.*",
		"ATTACK_.*",
		"DEFEND_.*",
		"SNIPE_allies_.*",
		"SNIPE_bank.*",
		"SNIPE_hq.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"DEFEND_axis_start.*",
		"DEFEND_shop.*",
	});

	// Priority
	SetGoalPriority( Map.Plant_Station_Entrance, 0.0 );
	SetGoalPriority( Map.Plant_Station_Entrance, 0.91, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "DEFEND_dyno_station.*", 0.6 );
	SetGoalPriority( "ATTACK_anti_mg", 0.6 );
	SetGoalPriority( "CHECKPOINT_.*", 0.71 );
	SetGoalPriority( "GRENADE_.*", 0.7 );
	SetGoalPriority( "GRENADE_barrier.*", 0.71 );
	SetGoalPriority( "GRENADE_factory_mg", 0.71 );
	SetGoalPriority( "SNIPE_allies_start.*", 0.71, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "SMOKEBOMB_.*", 0.8 );
	SetGoalPriority( "BUILD_Neutral_Command_Post", 0.7 );

	// Max users
	Util.SetMaxUsersInProgress( 3, "CHECKPOINT_.*" );
	Util.SetMaxUsersInUse( 2, "CHECKPOINT_.*" );
	Util.SetMaxUsers( 2, "PLANT_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "BUILD_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "SMOKEBOMB_.*" );
	Util.SetMaxUsers( 1, "MOUNT.*" );

	// Set Map Goal Properties
	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=0, MaxCampTime=3} );
	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=3, MaxCampTime=35} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=90} );
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=10, MaxCampTime=120} );
	SetMapGoalProperties( "SNIPE_.*", {MinCampTime=10, MaxCampTime=120} );
	SetMapGoalProperties( Map.Mount_Hotel_MG, { AimVectors={ [0]=Vec3(0.122,-0.986,0.112), [1]=Vec3(0.110,-0.994,-0.006), [10]=Vec3(0.330,-0.942,-0.056), [2]=Vec3(0.227,-0.970,-0.086), [3]=Vec3(0.225,-0.974,0.014), [4]=Vec3(0.280,-0.955,0.102), [5]=Vec3(0.304,-0.952,0.020), [6]=Vec3(0.394,-0.919,0.004), [7]=Vec3(0.980,-0.198,-0.007), [8]=Vec3(0.519,0.855,-0.009), [9]=Vec3(0.623,-0.782,0.026) } } );

	// Ramp not built initially, close path
	Wp.SetWaypointFlag( "ramp1", "closed", true );
	Wp.SetWaypointFlag( "ramp2", "closed", true );
	Wp.SetWaypointFlag( "station_teamdoor", "disguise", true );

	Util.AddUseWp( "PLANT_Depot_Side_Door", "door_inside" );
	Util.AddUseWp( "PLANT_Depot_Side_Door", "door_outside" );

	// Routes
	MapRoutes =
	{
		CHECKPOINT_flag_axisHQ =
		{
			ROUTE_shop_spawn =
			{
				ROUTE_ramp1 =
				{
					ROUTE_hq1 = {}
				}
			},
			ROUTE_bank_spawn =
			{
				ROUTE_bank_window = {},
				ROUTE_bank_stairs =
				{
					ROUTE_bank_maindoor = {}
				}
			},
			ROUTE_factory_spawn =
			{
				ROUTE_factory_crates = {},
				ROUTE_factory_mg =
				{
					ROUTE_factory_door1 = {},
					ROUTE_factory_door2 = {},
					ROUTE_factory_wall = {}
				}
			},
		},

		CHECKPOINT_flag_hotel =
		{
			ROUTE_shop_spawn =
			{
				ROUTE_hotel_backdoor1 =
				{
					ROUTE_hotel_backdoor2 = {}
				}
			},
			ROUTE_bank_spawn =
			{
				ROUTE_bank_window = {},
				ROUTE_bank_stairs =
				{
					ROUTE_bank_maindoor = {}
				}
			},
			ROUTE_factory_spawn =
			{
				ROUTE_factory_crates = {},
				ROUTE_factory_mg =
				{
					ROUTE_factory_door1 = {},
					ROUTE_factory_door2 = {},
					ROUTE_factory_wall = {}
				}
			},
		},

		CHECKPOINT_flag_library =
		{
			ROUTE_bank_spawn =
			{
				ROUTE_bank_window = {},
				ROUTE_bank_stairs =
				{
					ROUTE_bank_maindoor = {}
				}
			},
			ROUTE_factory_spawn =
			{
				ROUTE_factory_crates = {},
				ROUTE_factory_mg =
				{
					ROUTE_factory_door1 = {},
					ROUTE_factory_door2 = {},
					ROUTE_factory_wall = {}
				}
			},
		},

		CHECKPOINT_flag_bank =
		{
			ROUTE_factory_spawn =
			{
				ROUTE_factory_crates = {},
				ROUTE_factory_mg =
				{
					ROUTE_factory_door1 = {},
					ROUTE_factory_door2 = {},
					ROUTE_factory_wall = {}
				}
			},
		},

		CHECKPOINT_flag_station =
		{
			ROUTE_allied_spawn =
			{
				//ROUTE_shop_backdoor = {},
				//ROUTE_blue = { ROUTE_archway = {} },
				ROUTE_ruin_right = {},
				ROUTE_window_right = {},
				ROUTE_window_spawn_1 = {},
				ROUTE_as_left =
				{
					ROUTE_ruin_left = {},
					ROUTE_left_plank_left = {},
					ROUTE_left_plank_right = {},
					ROUTE_right_plank = {},
				},
				ROUTE_as_middle =
				{
					ROUTE_left_plank_left = {},
					ROUTE_left_plank_right = {},
					ROUTE_right_plank = {},
				},
				ROUTE_as_right =
				{
					ROUTE_left_plank_left = {},
					ROUTE_left_plank_right = {},
					ROUTE_right_plank = {},
				},
			},
		},

		CHECKPOINT_flag_shop =
		{
			ROUTE_allied_spawn =
			{
				ROUTE_ruin_right = {},
				ROUTE_window_right = {},
				ROUTE_window_spawn_1 = {},
				ROUTE_right_jump = { ROUTE_stairs_outside = {} },
				ROUTE_as_left =
				{
					ROUTE_ruin_left = {},
					ROUTE_shop_door = {},
					ROUTE_left_plank_left = { ROUTE_shop_door = {} },
					ROUTE_left_plank_right = { ROUTE_shop_door = {} },
					ROUTE_right_plank = { ROUTE_shop_door = {} },
				},
				ROUTE_as_middle =
				{
					ROUTE_left_plank_left = { ROUTE_shop_door = {} },
					ROUTE_left_plank_right = { ROUTE_shop_door = {} },
					ROUTE_right_plank = { ROUTE_shop_door = {} },
				},
				ROUTE_as_right =
				{
					ROUTE_shop_door = {},
					ROUTE_left_plank_left = { ROUTE_shop_door = {} },
					ROUTE_left_plank_right = { ROUTE_shop_door = {} },
					ROUTE_right_plank = { ROUTE_shop_door = {} },
				},
			},
			ROUTE_factory_spawn =
			{
				ROUTE_factory_crates = {},
				ROUTE_factory_mg =
				{
					ROUTE_factory_door1 = {},
					ROUTE_factory_door2 = {},
					ROUTE_factory_wall = {}
				}
			},
			ROUTE_shop1stfloor =
			{
				ROUTE_shop_backdoor = {}
			},
		},
	};
	MapRoutes.PLANT_Station_Entrance = MapRoutes.CHECKPOINT_flag_station;
	MapRoutes.BUILD_Neutral_Command_Post = MapRoutes.CHECKPOINT_flag_shop;
	MapRoutes.PLANT_Neutral_Command_Post = MapRoutes.CHECKPOINT_flag_shop;
	MapRoutes.CHECKPOINT_flag_depot = MapRoutes.CHECKPOINT_flag_library;
	Util.Routes(MapRoutes);
	SetAvailableMapGoals( TEAM.ALLIES, false, "ROUTE_ramp1" );

	Util.UpdateSwitchData();
	Util.MapDebugPrint( "Omni-bot map script for Berlin executed." );
};

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 110;
	bot.MaxViewDistance = 2400;
	rand = RandInt(0,10);
	if ( Map.Talk && MAP_TALK && rand > 5 )
	{
		if ( bot.GetTeam() == TEAM.AXIS )
		{
			sleep( 10 - rand );
			if ( bot.GetNearestAlly(CAT.PLAYER, CLASS.ENGINEER) && bot.GetClass() != CLASS.ENGINEER )
			{
				if ( rand == 7 )
					{ bot.ExecCommand("vsay_team FTDeployLandmines"); }
			}
			else if ( bot.GetNearestAlly(CAT.PLAYER, CLASS.SOLDIER) && bot.GetClass() != CLASS.SOLDIER )
			{
				if ( rand == 6 )
					{ bot.SayVoice(VOICE.DEFEND_OBJECTIVE); }
				else if ( rand == 7 )
					{ bot.ExecCommand("vsay_team FTMortar"); }
			}
			return;
		}
		else if ( bot.GetTeam() == TEAM.ALLIES )
		{
			sleep( 10 - rand );
			if ( bot.GetNearestAlly(CAT.PLAYER, CLASS.COVERTOPS) && bot.GetClass() != CLASS.COVERTOPS )
			{
				if ( rand == 6 )
					{ bot.SayVoice(VOICE.CLEAR_PATH); }
				else if ( rand == 7 )
					{ bot.ExecCommand("vsay_team FTProvideSniperCover"); }
				else if ( rand == 8 )
					{ bot.ExecCommand("vsay_team FTGoUndercover"); }
				else if ( rand == 9 )
					{ bot.ExecCommand("vsay_team FTExploreArea"); }
				else if ( rand == 10 )
					{ bot.ExecCommand("vsay_team FTInfiltrate "); }
			}
			else if ( bot.GetNearestAlly(CAT.PLAYER, CLASS.ENGINEER) && bot.GetClass() != CLASS.ENGINEER )
			{
				if ( rand == 6 )
					{ bot.SayVoice(VOICE.CLEAR_PATH); }
				else if ( rand == 7 )
					{ bot.ExecCommand("vsay_team FTDisarmLandmines"); }
				else if ( rand == 8 )
					{ bot.ExecCommand("vsay_team FTClearMines"); }
			}
			return;
		}
	}
};
