//==========================================================================================
//
//	et_mor2.gm
//
//	Who      	When			What
//------------------------------------------------------------------------------------------
//	Qiki		11 March 2013	Initial Script
//	Native12	01.05.2013		Ready to test
//	Native12	04.05.2013		Minor bugs fixed, added triggers for N!tmod
//	Native12	11.05.2013		Added Coversplits (thx Palota)
//==========================================================================================
//

global Map =
{
	Allied_Command_Post_Dyno = 0,
	Axis_Command_Post_Dyno = 0,
	Laboratory_Entrance_Dyno = 0,
	MG2_Dyno = 0,
	North_market_MG_nest_Dyno = 0,
	Tank_defences_bridge_Dyno = 0,
	back_door_Dyno = 0,
	barricade_materials_Dyno = 0,
	lab_barricade_materials_Dyno = 0,
	villa_courtyard_gate_Dyno = 0,
	Axis_Wire_Swing_Dyno = 0,
	Allied_Wire_Swing_Dyno = 0,

	Axis_Wire_Swing = false,
	Allied_Wire_Swing = false,
	Allied_Command_Post = false,
	Axis_Command_Post = false,
	MG2 = false,
	North_market_MG_nest = false,
	Tank_defences_bridge = false,
	barricade_materials = false,
	lab_barricade_materials = false,
	villa_courtyard_gate = false,
	Laboratory_Entrance = true,
	back_door = true,
	case1Taken = false,
	Main_Town_Gate = true,
	TankIsDestroyed = true,
	Tank_At_Bridge = false,
	TankPassBridge = false,
	Somebody_With_Case_In_Lab = false,
	Tank_NearlyGate = false,
	Allies_Win = false,
	Allies_Are_Inside = 0,
	Labor = 0,
	AllyInside = 0,
	CovertInside = 0,
	EngInside = 0,

	Roles =
	{
		ALLIES =
		{
			AllBots = true,
			ATTACKER =
			{
				numbots = 8,
			},
		},
	},

	Navigation =
	{
		//  	/bot waypoint_setproperty paththrough Navigation_PT:fall_down
		fall_down =
		{
			navigate = function(_this)
			{
				wpTable = {};
				Wp.GetWaypointByName("Fall_Down", wpTable);
				if ( _this.Goto(wpTable.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.VeryHigh, "facing", wpTable.facing);
					sleep(0.4);
					_this.Bot.HoldButton(BTN.FORWARD, 1.4);
					sleep(1.4);
				}
			},
		},

		//  	/bot waypoint_setproperty paththrough Navigation_PT:ladder
		ladder =
		{
			navigate = function(_this)
			{
				wpTable = {};
				Wp.GetWaypointByName("Ladder", wpTable);
				if ( _this.Goto(wpTable.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.VeryHigh, "facing", wpTable.facing);
					sleep(0.5);
					_this.Bot.HoldButton(BTN.FORWARD, 1.6);
					sleep(1.6);
				}
			},
		},

		//  	/bot waypoint_setproperty paththrough Navigation_PT:facing
		facing =
		{
			navigate = function(_this)
			{
				_this.AddAimRequest(Priority.VeryHigh, "facing", Vector3(-0.096152,-0.086528,0.991598));
				sleep(1);
				_this.Bot.HoldButton(BTN.FORWARD, 3);
				sleep(3);
			},
		},

		//  	/bot waypoint_setproperty paththrough Navigation_PT:jump
		jump =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.JUMP, 0.55);
			},
		},

		//  	/bot waypoint_setproperty paththrough Navigation_PT:roof_jump
		roof_jump =
		{
			navigate = function(_this)
			{
				wpTable = {};
				Wp.GetWaypointByName("Roof_Jump", wpTable);
				if ( _this.Goto(wpTable.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.VeryHigh, "facing", wpTable.facing);
					sleep(0.75);
					_this.Bot.HoldButton(BTN.FORWARD, 0.55);
					_this.Bot.HoldButton(BTN.JUMP, 0.55);
					sleep(0.55);
				}
			},
		},

		//  	/bot waypoint_setproperty paththrough Navigation_PT:box
		box =
		{
			navigate = function(_this)
			{
				wpTable = {};
				Wp.GetWaypointByName("Box", wpTable);
				if ( _this.Goto(wpTable.position) == EVENT.PATH_SUCCESS )
				{
					_this.AddAimRequest(Priority.VeryHigh, "facing", wpTable.facing);
					sleep(0.75);
					_this.Bot.HoldButton(BTN.FORWARD, 0.55);
					yield();
					_this.Bot.HoldButton(BTN.JUMP, 0.55);
					sleep(0.55);
				}
			},
		},
	},

	MG2_Built = function()
	{

		Map.MG2 = true;

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_MG2" );

		if ( Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"MOUNTMG42_MG2",
				"REPAIRMG42_MG2",
			});

			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_MG2" );
		}

		Util.MapDebugPrint( "^5MG2_Built" );
	},

	MG2_Planted = function()
	{

		Map.MG2_Dyno += 1;

		SetGoalPriority( "DEFUSE_MG2_.*", 0.91, TEAM.AXIS, CLASS.ENGINEER );

		if ( !Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_MG2_.*" );
		}

		Util.MapDebugPrint( "^5MG2_Planted" );
	},

	MG2_Defused = function()
	{

		Map.MG2_Dyno -= 1;

		Util.MapDebugPrint( "^5MG2_Defused" );
	},

	MG2_Destroyed = function()
	{

		if ( Map.MG2_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_MG2_.*" );
		}

		Map.MG2_Dyno = 0;
		Map.MG2 = false;

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_MG2",
			"REPAIRMG42_MG2",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_MG2" );

		if ( Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_MG2" );
		}

		Util.MapDebugPrint( "^5MG2_Destroyed" );
	},

	Tank_Near_Viaduct =
	{
		Name = "Tank_Near_Viaduct",
		TriggerOnEntity = GetGoal("MOVER_tank").GetEntity(),
		OnEnter = function(ent)
		{

		},
		OnExit = function(ent)
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMORTAR_Axis_Start" );

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

			Util.MapDebugPrint( "^5Tank_Near_Viaduct" );
		}
	},

	Tank_defences_bridge_Built = function()
	{

		Map.Tank_defences_bridge = true;

		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank_defences_bridge" );

		if ( !Map.TankPassBridge )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Tank_defences_bridge" );
		}

		Util.MapDebugPrint( "^5Tank_defences_bridge_Built" );
	},

	Tank_defences_bridge_Planted = function()
	{

		Map.Tank_defences_bridge_Dyno += 1;

		if ( Map.TankPassBridge )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Tank_defences_bridge_.*" );
		}

		Util.MapDebugPrint( "^5Tank_defences_bridge_Planted" );
	},

	Tank_defences_bridge_Defused = function()
	{

		Map.Tank_defences_bridge_Dyno -= 1;

		Util.MapDebugPrint( "^5Tank_defences_bridge_Defused" );
	},

	Tank_defences_bridge_Destroyed = function()
	{

		if ( Map.Tank_defences_bridge_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Tank_defences_bridge_.*" );
		}

		Map.Tank_defences_bridge_Dyno = 0;
		Map.Tank_defences_bridge = false;

		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Tank_defences_bridge" );

		if ( !Map.TankPassBridge )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank_defences_bridge" );
		}

		Util.MapDebugPrint( "^5Tank_defences_bridge_Destroyed" );
	},

	TankAtBridge =
	{
		Name = "TankAtBridge",
		TriggerOnEntity = GetGoal("MOVER_tank").GetEntity(),
		OnEnter = function(ent)
		{
			Map.Tank_At_Bridge = true;

			ETUtil.SetExcludeIndexes( "BUILD_Tank", { 2, 3 } );

			SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMORTAR_Axis_Viaduct" );

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

			if ( !Map.Tank_defences_bridge )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_Tank" );
			}

			Util.MapDebugPrint( "^5Tank_At_Bridge" );
		},
		OnExit = function(ent)
		{
			Map.Tank_At_Bridge = false;
			Map.TankPassBridge = true;

			ETUtil.SetExcludeIndexes( "BUILD_Tank", { 2, 3, 4 } );

			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"BUILD_Tank_defences_bridge",
				"SMOKEBOMB_Allies_Barrier_01",
			});

			SetAvailableMapGoals( TEAM.AXIS, false, {
				"PLANT_Tank_defences_bridge",
				"MOBILEMORTAR_Axis_Bridge",
			});

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

			SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_Barrier_02" );

			Util.MapDebugPrint( "^5Tank_Pass_Bridge" );
		}
	},

	Snipe_Tower_Destroyed = function()
	{

		if ( !Map.Tank_NearlyGate )
		{
			Util.MapDebugPrint( "^5Snipe_Tower_Destroyed" );
		}
	},

	Tank_Near_Tower =
	{
		Name = "Tank_Near_Tower",
		TriggerOnEntity = GetGoal("MOVER_tank").GetEntity(),
		OnEnter = function(ent)
		{
			ETUtil.SetExcludeIndexes( "BUILD_Tank", { 0, 1, 2, 3 } );

			SetAvailableMapGoals( TEAM.AXIS, false, {
				"MOBILEMORTAR_Axis_PastBridge",
				"PLANTMINE_.*",
			});

			SetAvailableMapGoals( TEAM.ALLIES, false, "SMOKEBOMB_Allies_Barrier_02" );

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

			SetAvailableMapGoals( TEAM.ALLIES, true, "SMOKEBOMB_Allies_MainGate_15" );

			Util.MapDebugPrint( "^5Tank_Near_Tower" );
		},
		OnExit = function(ent)
		{
			ETUtil.SetExcludeIndexes( "BUILD_Tank", { 2, 3, 4 } );
		}
	},

	Tank_Nearly_Gate = function()
	{

		Map.Tank_NearlyGate = true;

		SetAvailableMapGoals( TEAM.AXIS, false, {
			".*_Axis_Tower_.*",
			".*_Axis_Barrier_.*",
			".*_Axis_TunnelExit_.*",
			"MOBILEMORTAR_Axis_.*",
			"BUILD_MG2",
			"MOUNTMG42_MG2",
			"REPAIRMG42_MG2",
			"PLANT_Tank_defences_bridge",
		});

		if ( ETUtil.CountClass( TEAM.AXIS, CLASS.SOLDIER ) < 2 )
		{
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.FLAMETHROWER, false );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MORTAR, false );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.PANZERFAUST, false );

			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MOBILE_MG42, true );

			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.AXIS )
				{
					if ( bot.GetClass() == CLASS.SOLDIER )
					{
						if ( bot.HasWeapon(WEAPON.FLAMETHROWER) or bot.HasWeapon(WEAPON.MORTAR) or bot.HasWeapon(WEAPON.PANZERFAUST) )
						{
							bot.ExecCommand( "kill" );

							Util.MapDebugPrint( "^5I have wrong weapon" );
						}
					}
				}
			}
		}
		else
		{
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.FLAMETHROWER, false );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MORTAR, false );

			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MOBILE_MG42, true );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.PANZERFAUST, true );

			foreach ( id and bot in BotTable )
			{
				if ( bot.GetTeam() == TEAM.AXIS )
				{
					if ( bot.GetClass() == CLASS.SOLDIER )
					{
						if ( bot.HasWeapon(WEAPON.FLAMETHROWER) or bot.HasWeapon(WEAPON.MORTAR) )
						{
							bot.ExecCommand( "kill" );

							Util.MapDebugPrint( "^5I have wrong weapon" );
						}
					}
				}
			}
		}

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"AMMOCAB_.*",
			"HEALTHCAB_.*",
			".*_Axis_OutsideLaboratory_.*",
		});

		if ( !Map.Axis_Command_Post )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Command_Post" );
		}

		if ( !Map.North_market_MG_nest )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_North_market_MG_nest" );
		}

		if ( Map.Allied_Wire_Swing )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Wire_Swing_Gate_neutral" );
		}

		if ( !Map.Allied_Wire_Swing and !Map.Axis_Wire_Swing )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Wire_Swing_Gate_neutral" );
		}

		if ( !Map.villa_courtyard_gate )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_villa_courtyard_gate" );
		}

		if ( Map.Allied_Command_Post )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Allied_Command_Post" );
		}

		if ( Map.Axis_Command_Post_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_Axis_Command_Post_.*" );
		}

		if ( Map.MG2_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_MG2_.*" );
		}

		if ( Map.North_market_MG_nest_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_North_market_MG_nest_.*" );
		}

		if ( Map.barricade_materials_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_barricade_materials_.*" );
		}

		if ( Map.villa_courtyard_gate_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_villa_courtyard_gate_.*" );
		}

		if ( Map.Axis_Wire_Swing_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_Wire_Swing_Gate_neutral_.*" );
		}

		if ( !Map.Laboratory_Entrance )
		{
			if ( !Map.lab_barricade_materials )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_lab_barricade_materials" );

				if ( Map.case1Taken )
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Truck" );
				}
				else
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_case1" );
				}
			}
		}

		if ( !Map.back_door )
		{
			if ( !Map.barricade_materials )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_barricade_materials" );
			}
		}

		Util.MapDebugPrint( "^5Tank_Nearly_Gate" );
	},

	Main_Town_Gate_Destroyed = function()
	{

		Map.Main_Town_Gate = false;

		if ( Map.North_market_MG_nest )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"REPAIRMG42_North_market_MG_nest",
				"MOUNTMG42_North_market_MG_nest",
			});
		}

		Util.MapDebugPrint( "^5Main_Town_Gate_Destroyed" );

		sleep(1.5);

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"BUILD_Tank",
			"ESCORT_Tank",
			"MOUNT_Tank",
			"BUILD_Tank_defences_bridge",
			"PLANT_MG2",
			".*_MainGate_.*",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"AMMOCAB_.*",
			"HEALTHCAB_.*",
			".*_Allies_OutsideLaboratory_.*",
		});

		if ( Map.Axis_Command_Post )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_Command_Post" );
		}

		if ( Map.North_market_MG_nest )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_North_market_MG_nest" );
		}

		if ( Map.Axis_Wire_Swing )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Wire_Swing_Gate_neutral" );
		}

		if ( !Map.Allied_Wire_Swing and !Map.Axis_Wire_Swing )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Wire_Swing_Gate_neutral" );
		}

		if ( Map.villa_courtyard_gate )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_villa_courtyard_gate" );
		}

		if ( !Map.Allied_Command_Post )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_Command_Post" );
		}

		if ( Map.Laboratory_Entrance )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Laboratory_Entrance" );
		}
		else
		{
			if ( Map.lab_barricade_materials )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"PLANT_lab_barricade_materials",
					"PLANT_lab_barricade_materials_1",
				});
			}
			else
			{
				if ( Map.case1Taken )
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Truck" );
				}
				else
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_case1" );
				}
			}
		}

		if ( Map.back_door )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_back_door" );
		}
		else
		{
			if ( Map.barricade_materials )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_barricade_materials" );
			}
		}

		if ( Map.Allied_Command_Post_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Allied_Command_Post_.*" );
		}

		if ( Map.Allied_Wire_Swing_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Wire_Swing_Gate_neutral_.*" );
		}
	},

	Allied_Command_Post_Built = function()
	{

		Map.Allied_Command_Post = true;

		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_Command_Post" );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Allied_Command_Post" );
		}

		Util.MapDebugPrint( "^5Allied_Command_Post_Built" );
	},

	Allied_Command_Post_Planted = function()
	{

		Map.Allied_Command_Post_Dyno += 1;

		if ( Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_Command_Post_.*" );
		}
		else
		{
			if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_Command_Post_.*" );
			}
		}

		SetGoalPriority( "DEFUSE_Allied_Command_Post_.*", 0.8, TEAM.ALLIES, CLASS.ENGINEER );

		Util.MapDebugPrint( "^5Allied_Command_Post_Planted" );
	},

	Allied_Command_Post_Defused = function()
	{

		Map.Allied_Command_Post_Dyno -= 1;

		Util.MapDebugPrint( "^5Allied_Command_Post_Defused" );
	},

	Allied_Command_Post_Destroyed = function()
	{

		if ( Map.Allied_Command_Post_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_Command_Post_.*" );
		}

		Map.Allied_Command_Post_Dyno = 0;
		Map.Allied_Command_Post = false;

		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Allied_Command_Post" );

		if ( !Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_Command_Post" );
		}

		Util.MapDebugPrint( "^5Allied_Command_Post_Destroyed" );
	},

	Axis_Command_Post_Built = function()
	{

		Map.Axis_Command_Post = true;

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Axis_Command_Post" );

		if ( !Map.Main_Town_Gate and !Map.case1Taken )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_Command_Post" );
		}

		Util.MapDebugPrint( "^5Axis_Command_Post_Built" );
	},

	Axis_Command_Post_Planted = function()
	{

		Map.Axis_Command_Post_Dyno += 1;

		if ( Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Axis_Command_Post_.*" );
		}
		else
		{
			if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Axis_Command_Post_.*" );
			}
		}

		SetGoalPriority( "DEFUSE_Axis_Command_Post_.*", 0.8, TEAM.AXIS, CLASS.ENGINEER );

		Util.MapDebugPrint( "^5Axis_Command_Post_Planted" );
	},

	Axis_Command_Post_Defused = function()
	{

		Map.Axis_Command_Post_Dyno -= 1;

		Util.MapDebugPrint( "^5Axis_Command_Post_Defused" );
	},

	Axis_Command_Post_Destroyed = function()
	{

		if ( Map.Axis_Command_Post_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_Command_Post_.*" );
		}

		Map.Axis_Command_Post_Dyno = 0;
		Map.Axis_Command_Post = false;

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_Command_Post" );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Command_Post" );
		}

		Util.MapDebugPrint( "^5Axis_Command_Post_Destroyed" );
	},

	North_market_MG_nest_Built = function()
	{

		Map.North_market_MG_nest = true;

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_North_market_MG_nest" );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, {
				"MOUNTMG42_North_market_MG_nest",
				"REPAIRMG42_North_market_MG_nest",
			});
		}

		if ( !Map.Main_Town_Gate and !Map.case1Taken )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_North_market_MG_nest" );
		}

		Util.MapDebugPrint( "^5North_market_MG_nest_Built" );
	},

	North_market_MG_nest_Planted = function()
	{

		Map.North_market_MG_nest_Dyno += 1;

		SetGoalPriority( "DEFUSE_North_market_MG_nest_.*", 0.90, TEAM.AXIS, CLASS.ENGINEER );

		if ( Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_North_market_MG_nest_.*" );
		}
		else
		{
			if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_North_market_MG_nest_.*" );
			}
		}

		Util.MapDebugPrint( "^5North_market_MG_nest_Planted" );
	},

	North_market_MG_nest_Defused = function()
	{

		Map.North_market_MG_nest_Dyno -= 1;

		Util.MapDebugPrint( "^5North_market_MG_nest_Defused" );
	},

	North_market_MG_nest_Destroyed = function()
	{

		if ( Map.North_market_MG_nest_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_North_market_MG_nest_.*" );
		}

		Map.North_market_MG_nest_Dyno = 0;
		Map.North_market_MG_nest = false;

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_North_market_MG_nest" );

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_North_market_MG_nest",
			"REPAIRMG42_North_market_MG_nest",
		});

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_North_market_MG_nest" );
		}

		Util.MapDebugPrint( "^5North_market_MG_nest_Destroyed" );
	},

	back_door_Planted = function()
	{

		Map.back_door_Dyno += 1;

		SetGoalPriority( "DEFUSE_back_door_.*", 0.91, TEAM.AXIS, CLASS.ENGINEER );

		if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_back_door_.*" );
		}

		Util.MapDebugPrint( "^5back_door_Planted" );
	},

	back_door_Defused = function()
	{

		Map.back_door_Dyno -= 1;

		Util.MapDebugPrint( "^5back_door_Defused" );
	},

	back_door_Destroyed = function()
	{

		if ( Map.back_door_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_back_door_.*" );
		}

		Map.back_door_Dyno = 0;
		Map.back_door = false;

		Util.EnableGoal ("ROUTE_Around_Cabinets_1");
		Util.EnableGoal ("ROUTE_ToBackDoor_1");
		Util.EnableGoal ("ROUTE_ToBackDoor_2");

		Wp.SetWaypointFlag( "back_door_1", "axis", false );
		Wp.SetWaypointFlag( "back_door_2", "axis", false );
		Wp.SetWaypointFlag( "back_door_1", "door", false );
		Wp.SetWaypointFlag( "back_door_2", "door", false );
		Wp.SetWaypointFlag( "barricade_materials_1", "closed", false );
		Wp.SetWaypointFlag( "barricade_materials_2", "closed", false );
		Wp.SetWaypointFlag( "back_door_1", "blockwall", true );
		Wp.SetWaypointFlag( "back_door_2", "blockwall", true );

		Util.MapDebugPrint( "^5back_door_Destroyed" );

		sleep(1);

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_barricade_materials" );
		}
	},

	barricade_materials_Built = function()
	{

		Map.barricade_materials = true;

		Util.DisableGoal ("ROUTE_Around_Cabinets_1");
		Util.DisableGoal ("ROUTE_ToBackDoor_1");
		Util.DisableGoal ("ROUTE_ToBackDoor_2");

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_barricade_materials" );

		if ( !Map.Main_Town_Gate and !Map.case1Taken )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_barricade_materials" );
		}

		Util.MapDebugPrint( "^5barricade_materials_Built" );
	},

	barricade_materials_Planted = function()
	{

		Map.barricade_materials_Dyno += 1;

		SetGoalPriority( "DEFUSE_barricade_materials_.*", 0.91, TEAM.AXIS, CLASS.ENGINEER );

		if ( Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_barricade_materials_.*" );
		}
		else
		{
			if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_barricade_materials_.*" );
			}
		}

		Util.MapDebugPrint( "^5barricade_materials_Planted" );
	},

	barricade_materials_Defused = function()
	{

		Map.barricade_materials_Dyno -= 1;

		Util.MapDebugPrint( "^5barricade_materials_Defused" );
	},

	barricade_materials_Destroyed = function()
	{

		if ( Map.barricade_materials_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_barricade_materials_.*" );
		}

		Map.barricade_materials_Dyno = 0;
		Map.barricade_materials = false;

		Util.EnableGoal ("ROUTE_Around_Cabinets_1");
		Util.EnableGoal ("ROUTE_ToBackDoor_1");
		Util.EnableGoal ("ROUTE_ToBackDoor_2");

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_barricade_materials" );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_barricade_materials" );
		}

		Util.MapDebugPrint( "^5barricade_materials_Destroyed" );
	},

	villa_courtyard_gate_Built = function()
	{

		Map.villa_courtyard_gate = true;

		Util.DisableGoal ("ROUTE_Around_AlliedCP_1");
		Util.DisableGoal ("ROUTE_Tunnel_Straight");
		Util.DisableGoal ("ROUTE_CourtyardGate");
		Util.DisableGoal ("ROUTE_Around_Wall");
		Util.DisableGoal ("ROUTE_Under_Bridge");

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_villa_courtyard_gate" );

		if ( !Map.Main_Town_Gate and !Map.case1Taken )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_villa_courtyard_gate" );
		}

		Util.MapDebugPrint( "^5villa_courtyard_gate_Built" );
	},

	villa_courtyard_gate_Planted = function()
	{

		Map.villa_courtyard_gate_Dyno += 1;

		SetGoalPriority( "DEFUSE_villa_courtyard_gate_.*", 0.91, TEAM.AXIS, CLASS.ENGINEER );

		if ( Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_villa_courtyard_gate_.*" );
		}
		else
		{
			if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_villa_courtyard_gate_.*" );
			}
		}

		Util.MapDebugPrint( "^5villa_courtyard_gate_Planted" );
	},

	villa_courtyard_gate_Defused = function()
	{

		Map.villa_courtyard_gate_Dyno -= 1;

		Util.MapDebugPrint( "^5villa_courtyard_gate_Defused" );
	},

	villa_courtyard_gate_Destroyed = function()
	{

		Map.villa_courtyard_gate_Dyno = 0;
		Map.villa_courtyard_gate = false;

		Util.EnableGoal ("ROUTE_Around_AlliedCP_1");
		Util.EnableGoal ("ROUTE_Tunnel_Straight");
		Util.EnableGoal ("ROUTE_CourtyardGate");
		Util.EnableGoal ("ROUTE_Around_Wall");
		Util.EnableGoal ("ROUTE_Under_Bridge");

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_villa_courtyard_gate" );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_villa_courtyard_gate" );
		}

		Util.MapDebugPrint( "^5villa_courtyard_gate_Destroyed" );
	},

	Laboratory_Entrance_Planted = function()
	{

		Map.Laboratory_Entrance_Dyno += 1;

		if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Laboratory_Entrance_.*" );
		}

		Util.MapDebugPrint( "^5Laboratory_Entrance_Planted" );
	},

	Laboratory_Entrance_Defused = function()
	{

		Map.Laboratory_Entrance_Dyno -= 1;

		Util.MapDebugPrint( "^5Laboratory_Entrance_Defused" );
	},

	Laboratory_Entrance_Destroyed = function()
	{

		Map.Laboratory_Entrance_Dyno = 0;
		Map.Laboratory_Entrance = false;

		Wp.SetWaypointFlag( "lab_door_1", "closed", true );
		Wp.SetWaypointFlag( "lab_door_2", "closed", true );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab) )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_OutsideLaboratory_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_InsideLaboratory_.*" );
			yield();
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_OutsideLaboratory_.*" );
		}

		if ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab)
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_lab_barricade_materials" );
		}

		Util.MapDebugPrint( "^5Laboratory_Entrance_Destroyed" );

		sleep(1);

		if ( !Map.Main_Town_Gate )
		{
			if ( !Map.case1Taken )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_case1" );
			}
		}
	},

	lab_barricade_materials_Built = function()
	{

		Map.lab_barricade_materials = true;

		Wp.SetWaypointFlag( "lab_door_3", "closed", false );
		Wp.SetWaypointFlag( "lab_door_4", "closed", false );
		Wp.SetWaypointFlag( "lab_door_3", "door", true );
		Wp.SetWaypointFlag( "lab_door_4", "door", true );
		Wp.SetWaypointFlag( "lab_door_3", "axis", true );
		Wp.SetWaypointFlag( "lab_door_4", "axis", true );

		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_lab_barricade_materials" );

		SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_case1" );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"PLANT_lab_barricade_materials",
				"PLANT_lab_barricade_materials_1",
			});
		}

		Util.MapDebugPrint( "^5lab_barricade_materials_Built" );

		if ( Map.AllyInside > 0 )
		{
			if ( !Map.case1Taken )
			{
				SetGoalRole("FLAG_case1", ROLE.ATTACKER);

				SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_case1" );
			}

			if ( Map.EngInside > 0 or Map.CovertInside > 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_lab_barricade_materials_inside" );
			}
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_case1" );
		}

		if ( !Map.Somebody_With_Case_In_Lab )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_InsideLaboratory_.*" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Wait" );
		}

		while ( Map.Somebody_With_Case_In_Lab and Map.lab_barricade_materials )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Truck" );
			sleep(0.5);
		}

		if ( Map.case1Taken )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Wait" );

			SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Truck" );
		}
	},

	lab_barricade_materials_Planted = function()
	{

		Map.lab_barricade_materials_Dyno += 1;

		if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_lab_barricade_materials_.*" );
		}

		Util.MapDebugPrint( "^5lab_barricade_materials_Planted" );
	},

	lab_barricade_materials_Defused = function()
	{

		Map.lab_barricade_materials_Dyno -= 1;

		Util.MapDebugPrint( "^5lab_barricade_materials_Defused" );
	},

	lab_barricade_materials_Destroyed = function()
	{

		Map.lab_barricade_materials_Dyno = 0;
		Map.lab_barricade_materials = false;

		Wp.SetWaypointFlag( "lab_door_3", "closed", true );
		Wp.SetWaypointFlag( "lab_door_4", "closed", true );

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANT_lab_barricade_materials",
			"PLANT_lab_barricade_materials_1",
		});

		ClearGoalRole("FLAG_case1", ROLE.ATTACKER);

		Util.MapDebugPrint( "^5lab_barricade_materials_Destroyed" );

		sleep(1.5);

		if ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab)
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_lab_barricade_materials" );
		}

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab) )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_OutsideLaboratory_.*" );

			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_InsideLaboratory_.*" );
			yield();
			SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_OutsideLaboratory_.*" );
		}

		if ( Map.AllyInside > 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_Inside_.*" );
		}

		if ( !Map.Main_Town_Gate )
		{
			if ( !Map.case1Taken )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_case1" );
			}
			else
			{
				if ( Map.Somebody_With_Case_In_Lab )
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Wait" );

					SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Truck" );
				}
			}
		}
	},

	Axis_Wire_Swing_Built = function()
	{

		Map.Axis_Wire_Swing = true;

		Util.SetGoalPosition(-926.861755, -273.925537, 21.280886, "PLANT_Wire_Swing_Gate_neutral");

		Wp.SetWaypointFlag( "Axis_Wire_swing", "closed", false );

		Util.DisableGoal( "BUILD_Wire_Swing_Gate_neutral" );

		if ( !Map.Main_Town_Gate and !Map.case1Taken )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Wire_Swing_Gate_neutral" );
		}

		Util.MapDebugPrint( "^5Axis_Wire_Swing_Built" );
	},

	Allied_Wire_Swing_Built = function()
	{

		Map.Allied_Wire_Swing = true;

		Util.SetGoalPosition(-1178.983765, 68.782532, 24.125000, "PLANT_Wire_Swing_Gate_neutral");

		Wp.SetWaypointFlag( "Allied_Wire_swing", "closed", false );

		Util.DisableGoal( "BUILD_Wire_Swing_Gate_neutral" );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Wire_Swing_Gate_neutral" );
		}

		Util.MapDebugPrint( "^5Allied_Wire_Swing_Built" );
	},

	Wire_Swing_Planted = function()
	{

		if ( Map.Axis_Wire_Swing )
		{
			Map.Axis_Wire_Swing_Dyno += 1;

			SetGoalPriority( "DEFUSE_Wire_Swing_Gate_neutral_.*", 0.91, TEAM.AXIS, CLASS.ENGINEER );

			if ( Map.Main_Town_Gate )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Wire_Swing_Gate_neutral_.*" );
			}
			else
			{
				if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Wire_Swing_Gate_neutral_.*" );
				}
			}

			Util.MapDebugPrint( "^5Axis_Wire_Swing_Planted" );
		}
		else
		{
			Map.Allied_Wire_Swing_Dyno += 1;

			SetGoalPriority( "DEFUSE_Wire_Swing_Gate_neutral_.*", 0.91, TEAM.ALLIES, CLASS.ENGINEER );

			if ( Map.Main_Town_Gate )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Wire_Swing_Gate_neutral_.*" );
			}
			else
			{
				if ( Map.case1Taken and !Map.Somebody_With_Case_In_Lab )
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Wire_Swing_Gate_neutral_.*" );
				}
			}

			Util.MapDebugPrint( "^5Allied_Wire_Swing_Planted" );
		}
	},

	Wire_Swing_Defused = function()
	{

		if ( Map.Axis_Wire_Swing )
		{
			Map.Axis_Wire_Swing_Dyno -= 1;

			Util.MapDebugPrint( "^5Axis_Wire_Swing_Defused" );
		}
		else
		{
			Map.Allied_Wire_Swing_Dyno -= 1;

			Util.MapDebugPrint( "^5Allied_Wire_Swing_Defused" );
		}
	},

	Axis_Wire_Swing_Destroyed = function()
	{

		if ( Map.Axis_Wire_Swing_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Wire_Swing_Gate_neutral_.*" );
		}

		Map.Axis_Wire_Swing_Dyno = 0;
		Map.Axis_Wire_Swing = false;

		Wp.SetWaypointFlag( "Axis_Wire_swing", "closed", true );

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Wire_Swing_Gate_neutral" );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			Util.EnableGoal( "BUILD_Wire_Swing_Gate_neutral" );
		}

		Util.MapDebugPrint( "^5Axis_Wire_Swing_Destroyed" );
	},

	Allied_Wire_Swing_Destroyed = function()
	{

		if ( Map.Allied_Wire_Swing_Dyno > 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Wire_Swing_Gate_neutral_.*" );
		}

		Map.Allied_Wire_Swing_Dyno = 0;
		Map.Allied_Wire_Swing = false;

		Wp.SetWaypointFlag( "Allied_Wire_swing", "closed", true );

		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Wire_Swing_Gate_neutral" );

		if ( !Map.Main_Town_Gate and ( !Map.case1Taken or Map.Somebody_With_Case_In_Lab ) )
		{
			Util.EnableGoal( "BUILD_Wire_Swing_Gate_neutral" );
		}

		Util.MapDebugPrint( "^5Allied_Wire_Swing_Destroyed" );
	},

	case1_Taken = function()
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_case1" );

		if ( !Map.Main_Town_Gate )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Truck" );
		}

		if ( !Map.case1Taken )
		{
			Map.Labor = OnTriggerRegion( AABB(-2432.875,-1792.854,17.125,-1831.125,-1151.125,164.028), Map.Laboratory );
		}

		Map.case1Taken = true;

		Util.MapDebugPrint( "^5case1_Taken" );
	},

	case1_Returned = function()
	{

		Map.case1Taken = false;

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"CAPPOINT_Truck",
			"CAPPOINT_Wait",
		});

		DeleteTriggerRegion(Map.Labor);

		if ( !Map.Main_Town_Gate )
		{
			if ( !Map.Somebody_With_Case_In_Lab )
			{
				Util.DisableGoal( ".*", true );

				Util.EnableGoal( {
					"AMMOCAB_.*",
					"HEALTHCAB_.*",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_OutsideLaboratory_.*" );

				SetAvailableMapGoals( TEAM.ALLIES, true, ".*_Allies_OutsideLaboratory_.*" );
			}

			if ( !Map.Laboratory_Entrance and !Map.lab_barricade_materials )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, {
					"DEFEND_Axis_InsideLaboratory_.*",
					"BUILD_lab_barricade_materials",
				});

				SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_case1" );
			}

			if ( Map.Laboratory_Entrance )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_InsideLaboratory_.*" );

				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Laboratory_Entrance" );
			}

			if ( Map.lab_barricade_materials )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_InsideLaboratory_.*" );

				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"PLANT_lab_barricade_materials",
					"PLANT_lab_barricade_materials_1",
				});
			}

			if ( !Map.Axis_Command_Post )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Axis_Command_Post" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_Command_Post" );
			}

			if ( !Map.North_market_MG_nest )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_North_market_MG_nest" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.AXIS, true, {
					"MOUNTMG42_North_market_MG_nest",
					"REPAIRMG42_North_market_MG_nest",
				});

				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_North_market_MG_nest" );
			}

			if ( Map.Allied_Wire_Swing )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Wire_Swing_Gate_neutral" );
			}

			if ( Map.Axis_Wire_Swing )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Wire_Swing_Gate_neutral" );
			}

			if ( !Map.Allied_Wire_Swing and !Map.Axis_Wire_Swing )
			{
				Util.EnableGoal( "BUILD_Wire_Swing_Gate_neutral" );
			}

			if ( !Map.villa_courtyard_gate )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_villa_courtyard_gate" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_villa_courtyard_gate" );
			}

			if ( Map.Allied_Command_Post )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Allied_Command_Post" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_Command_Post" );
			}

			if ( Map.Axis_Command_Post_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_Axis_Command_Post_.*" );
			}

			if ( Map.MG2_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_MG2_.*" );
			}

			if ( Map.North_market_MG_nest_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_North_market_MG_nest_.*" );
			}

			if ( Map.barricade_materials_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_barricade_materials_.*" );
			}

			if ( Map.villa_courtyard_gate_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_villa_courtyard_gate_.*" );
			}

			if ( Map.Axis_Wire_Swing_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, "DEFUSE_Wire_Swing_Gate_neutral_.*" );
			}

			if ( !Map.back_door )
			{
				if ( !Map.barricade_materials )
				{
					SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_barricade_materials" );
				}
				else
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_barricade_materials" );
				}
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_back_door" );
			}
		}

		Map.Somebody_With_Case_In_Lab = false;

		Util.MapDebugPrint( "^5case1_Returned" );
	},

	case1_Secured = function()
	{

		Map.case1Taken = false;

		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Truck" );

		Util.MapDebugPrint( "^5Allies_Win" );

		Map.Allies_Win = true;
		sleep(1);
		ETUtil.WinningChat( TEAM.ALLIES );
		sleep(1.5);
		ETUtil.LosingChat( TEAM.AXIS );

		Util.MapDebugPrint( "^5case1_Secured" );
	},

	Thirty_second = function()
	{

		Util.MapDebugPrint( "^5Thirty_second" );

		sleep(30);

		if ( !Map.Allies_Win )
		{
			Util.MapDebugPrint( "^5Axis_Win" );

			sleep(1);
			ETUtil.WinningChat( TEAM.AXIS );
			sleep(1.5);
			ETUtil.LosingChat( TEAM.ALLIES );
		}
	},

	Allies_Inside =
	{
		Name = "Allies_Inside",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				if ( Map.Main_Town_Gate )
				{
					Map.Allies_Are_Inside += 1;

					SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Axis_Barrier_.*" );

					if ( Map.Allies_Are_Inside == 1 )
					{
						Util.BotChat( TEAM.AXIS, "sayteam", "^1Allies are inside the city! Defend the laboratory!", 2 );
					}

					if ( !Map.Laboratory_Entrance and !Map.lab_barricade_materials )
					{
						if ( Map.Allies_Are_Inside < 2 )
						{
							SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_InsideLaboratory_01" );
						}
						else
						{
							SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_InsideLaboratory_.*" );
						}
					}
					else
					{
						if ( Map.Allies_Are_Inside < 2 )
						{
							SetAvailableMapGoals( TEAM.AXIS, true, {
								"DEFEND_Axis_OutsideLaboratory_01",
								"DEFEND_Axis_OutsideLaboratory_06",
							});
						}
						else
						{
							SetAvailableMapGoals( TEAM.AXIS, true, {
								"DEFEND_Axis_OutsideLaboratory_05",
								"DEFEND_Axis_OutsideLaboratory_06",
								"DEFEND_Axis_OutsideLaboratory_09",
							});
						}
					}

					Util.MapDebugPrint( "^5Allies are inside the city" );

					yield();

					SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Axis_Barrier_.*" );
				}
			}
		},
		OnExit = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				if ( Map.Main_Town_Gate )
				{
					Map.Allies_Are_Inside -= 1;

					if ( Map.Allies_Are_Inside == 0 )
					{
						SetAvailableMapGoals( TEAM.AXIS, false, {
							"DEFEND_Axis_InsideLaboratory_.*",
							"DEFEND_Axis_OutsideLaboratory_.*",
						});

						Util.BotChat( TEAM.AXIS, "sayteam", "^2Allies are not inside the city. The city is safe!", 2 );

						Util.MapDebugPrint( "^5Allies are not inside the city" );
					}
				}
			}
		}
	},

	Laboratory =
	{
		Name = "Laboratory",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				bot = Util.IsBot(ent);
				if ( bot )
				{
					bot.SetRoles(ROLE.ATTACKER);
				}
			}

			if ( GetEntFlags(ent,ENTFLAG.CARRYINGGOAL) )
			{
				if ( !Map.Somebody_With_Case_In_Lab )
				{
					Util.DisableGoal( "ATTACK_Truck_.*" );

					SetAvailableMapGoals( TEAM.AXIS, true, {
						"DEFEND_Axis_InsideLaboratory_.*",
						".*_Axis_OutsideLaboratory_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, true, ".*_Allies_OutsideLaboratory_.*" );
				}

				Map.Somebody_With_Case_In_Lab = true;

				Util.MapDebugPrint( "^5Allies are inside the laboratory and have taken documents" );

				while ( ( Map.Laboratory_Entrance or Map.lab_barricade_materials ) and Map.Somebody_With_Case_In_Lab )
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Wait" );

					SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Truck" );
					sleep(0.5);
				}

				if ( Map.case1Taken )
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_Wait" );

					SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Truck" );
				}
			}
		},
		OnExit = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				bot = Util.IsBot(ent);
				if ( bot )
				{
					bot.ClearRoles(ROLE.ATTACKER);
				}
			}

			if ( GetEntFlags(ent,ENTFLAG.CARRYINGGOAL) )
			{
				Map.Somebody_With_Case_In_Lab = false;

				Util.DisableGoal( ".*", true );

				Util.EnableGoal( {
					"AMMOCAB_.*",
					"HEALTHCAB_.*",
				});

				if ( Map.case1Taken )
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Truck" );
				}

				Util.EnableGoal( "ATTACK_Truck_.*" );

				Util.MapDebugPrint( "^5Allies escaped from laboratory with documents" );
			}
		}
	},

	Ally_inside =
	{
		Name = "Ally_inside",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				bot = Util.IsBot(ent);
				if ( bot )
				{
					Map.AllyInside += 1;

					bot.SetRoles(ROLE.ATTACKER);

					Util.MapDebugPrint( "^5set role ATTACKER" );

					SetAvailableMapGoals( TEAM.ALLIES, true, "CAMP_Inside_.*" );
				}

				if( GetEntClass(ent) == CLASS.ENGINEER )
				{
					Map.EngInside += 1;

					if ( Map.lab_barricade_materials )
					{
						SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_lab_barricade_materials_inside" );
					}
				}

				if( GetEntClass(ent) == CLASS.COVERTOPS )
				{
					Map.CovertInside += 1;

					if ( Map.lab_barricade_materials )
					{
						SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_lab_barricade_materials_inside" );
					}
				}
			}
		},
		OnExit = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				bot = Util.IsBot(ent);
				if ( bot )
				{
					Map.AllyInside -= 1;

					bot.ClearRoles(ROLE.ATTACKER);

					Util.MapDebugPrint( "^5clear role ATTACKER" );
				}

				if( GetEntClass(ent) == CLASS.ENGINEER )
				{
					Map.EngInside -= 1;
				}

				if( GetEntClass(ent) == CLASS.COVERTOPS )
				{
					Map.CovertInside -= 1;
				}

				if ( Map.lab_barricade_materials and Map.EngInside == 0 and Map.CovertInside == 0 )
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_lab_barricade_materials_inside" );
				}

				if ( Map.AllyInside == 0 )
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, "CAMP_Inside_.*" );
				}
			}
		}
	},

};

Map.WatchTankStatus = function()
{
	goal = GetGoal( "MOVER_tank" );
	entity = goal.GetEntity();
	Util.MapDebugPrint("^5Tank thread started", true);

	while ( Map.Main_Town_Gate )
	{
		if(GetEntFlags(GetGoal("MOVER_tank").GetEntity(), ENTFLAG.DEAD))
		{
			Map.TankIsDestroyed = true;

			SetAvailableMapGoals( TEAM.ALLIES, false, {
				"MOUNT_Tank",
				"ESCORT_Tank",
			});

			if ( Map.Tank_At_Bridge and Map.Tank_defences_bridge )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank" );
			}

			if ( !Map.Tank_At_Bridge )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank" );
			}
		}
		else
		{
			Map.TankIsDestroyed = false;

			SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNT_Tank" );

			SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Tank" );

			if ( Map.Tank_At_Bridge and Map.Tank_defences_bridge )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_Tank" );
			}
			else if ( Map.Tank_At_Bridge and !Map.Tank_defences_bridge )
			{
				SetAvailableMapGoals( TEAM.ALLIES, false, "ESCORT_Tank" );
			}

			if ( !Map.Tank_At_Bridge )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "ESCORT_Tank" );
			}
		}
		sleep(0.5);
	}
};

global OnMapLoad = function()
{

	OnTrigger( "Axis team have constructed the MG2 nest", Map.MG2_Built );
	OnTrigger( "Planted at MG2.", Map.MG2_Planted );
	OnTrigger( "Defused at MG2.", Map.MG2_Defused );
	OnTrigger( "Allied team has destroyed the MG2 nest", Map.MG2_Destroyed );

	OnTrigger( "Allied team have constructed the Tank defences bridge", Map.Tank_defences_bridge_Built );
	OnTrigger( "Planted at the Tank defences bridge.", Map.Tank_defences_bridge_Planted );
	OnTrigger( "Planted at Tank defences bridge.", Map.Tank_defences_bridge_Planted );	//Nitmod
	OnTrigger( "Defused at the Tank defences bridge.", Map.Tank_defences_bridge_Defused );
	OnTrigger( "Defused at Tank defences bridge.", Map.Tank_defences_bridge_Defused );	//Nitmod
	OnTrigger( "Axis team have destroyed the Tank defences bridge", Map.Tank_defences_bridge_Destroyed );

	OnTrigger( "tank_flash_stop", Map.Snipe_Tower_Destroyed );

	OnTrigger( "The Allied Tank is nearly at the town gate!!!", Map.Tank_Nearly_Gate );

	OnTrigger( "Allies have destroyed the Main town gate!!", Map.Main_Town_Gate_Destroyed );

	OnTrigger( "Allied team have constructed a command post.  Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "Planted at the Allied Command Post.", Map.Allied_Command_Post_Planted );
	OnTrigger( "Planted at Allied Command Post.", Map.Allied_Command_Post_Planted );	//Nitmod
	OnTrigger( "Defused at the Allied Command Post.", Map.Allied_Command_Post_Defused );
	OnTrigger( "Defused at Allied Command Post.", Map.Allied_Command_Post_Defused );	//Nitmod
	OnTrigger( "Axis team have destroyed the Allied Commmand Post", Map.Allied_Command_Post_Destroyed );

	OnTrigger( "Axis team have constructed a command post.  Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Planted at the Axis Command Post.", Map.Axis_Command_Post_Planted );
	OnTrigger( "Planted at Axis Command Post.", Map.Axis_Command_Post_Planted );	//Nitmod
	OnTrigger( "Defused at the Axis Command Post.", Map.Axis_Command_Post_Defused );
	OnTrigger( "Defused at Axis Command Post.", Map.Axis_Command_Post_Defused );	//Nitmod
	OnTrigger( "Allied team have destroyed the Axis Commmand Post", Map.Axis_Command_Post_Destroyed );

	OnTrigger( "Axis team have constructed the North market MG nest", Map.North_market_MG_nest_Built );
	OnTrigger( "Planted at the North market MG nest.", Map.North_market_MG_nest_Planted );
	OnTrigger( "Planted at North market MG nest.", Map.North_market_MG_nest_Planted );	//Nitmod
	OnTrigger( "Defused at the North market MG nest.", Map.North_market_MG_nest_Defused );
	OnTrigger( "Defused at North market MG nest.", Map.North_market_MG_nest_Defused );	//Nitmod
	OnTrigger( "Allied team has destroyed the North market MG nest", Map.North_market_MG_nest_Destroyed );

	OnTrigger( "Axis team have constructed the villa courtyard gate", Map.villa_courtyard_gate_Built );
	OnTrigger( "Planted at the villa courtyard gate.", Map.villa_courtyard_gate_Planted );
	OnTrigger( "Planted at villa courtyard gate.", Map.villa_courtyard_gate_Planted );	//Nitmod
	OnTrigger( "Defused at the villa courtyard gate.", Map.villa_courtyard_gate_Defused );
	OnTrigger( "Defused at villa courtyard gate.", Map.villa_courtyard_gate_Defused );	//Nitmod
	OnTrigger( "Allied team have destroyed the villa courtyard gate", Map.villa_courtyard_gate_Destroyed );

	OnTrigger( "Planted at the Laboratory Entrance.", Map.Laboratory_Entrance_Planted );
	OnTrigger( "Planted at Laboratory Entrance.", Map.Laboratory_Entrance_Planted );	//Nitmod
	OnTrigger( "Defused at the Laboratory Entrance.", Map.Laboratory_Entrance_Defused );
	OnTrigger( "Defused at Laboratory Entrance.", Map.Laboratory_Entrance_Defused );	//Nitmod
	OnTrigger( "Allies have destroyed the Laboratory Entrance", Map.Laboratory_Entrance_Destroyed );

	OnTrigger( "Planted at the back door.", Map.back_door_Planted );
	OnTrigger( "Planted at back door.", Map.back_door_Planted );	//Nitmod
	OnTrigger( "Defused at the back door.", Map.back_door_Defused );
	OnTrigger( "Defused at back door.", Map.back_door_Defused );	//Nitmod
	OnTrigger( "Allies have destroyed the back door", Map.back_door_Destroyed );

	OnTrigger( "Axis have built the backdoor barricade", Map.barricade_materials_Built );
	OnTrigger( "Planted at barricade materials.", Map.barricade_materials_Planted );
	OnTrigger( "Defused at barricade materials.", Map.barricade_materials_Defused );
	OnTrigger( "Allies have destroyed the backdoor barricade", Map.barricade_materials_Destroyed );

	OnTrigger( "Axis have built the Laboratory barricade", Map.lab_barricade_materials_Built );
	OnTrigger( "Planted at lab barricade materials.", Map.lab_barricade_materials_Planted );
	OnTrigger( "Defused at lab barricade materials.", Map.lab_barricade_materials_Defused );
	OnTrigger( "Allies have destroyed the Laboratory barricade", Map.lab_barricade_materials_Destroyed );

	OnTrigger( "Axis team have constructed the Wire swing gate", Map.Axis_Wire_Swing_Built );
	OnTrigger( "Allied team have constructed the Wire swing gate", Map.Allied_Wire_Swing_Built );
	OnTrigger( "Planted at the Wire Swing Gate (neutral).", Map.Wire_Swing_Planted );
	OnTrigger( "Planted at Wire Swing Gate (neutral).", Map.Wire_Swing_Planted );	//Nitmod
	OnTrigger( "Defused at the Wire Swing Gate (neutral).", Map.Wire_Swing_Defused );
	OnTrigger( "Defused at Wire Swing Gate (neutral).", Map.Wire_Swing_Defused );	//Nitmod
	OnTrigger( "Allied team have destroyed the Wire swing gate", Map.Axis_Wire_Swing_Destroyed );
	OnTrigger( "Axis team have destroyed the Wire swing gate", Map.Allied_Wire_Swing_Destroyed );

	OnTrigger( "Allies have stolen the Document Case!", Map.case1_Taken );
	OnTrigger( "Flag returned case1!", Map.case1_Returned );
	OnTrigger( "Allies have secured the Documents Case!", Map.case1_Secured );

	OnTrigger( "thirty second warning.", Map.Thirty_second );

	TankNearViaduct = OnTriggerRegion( Vec3(7518.051270, 1310.610596, -159.350937), 60, Map.Tank_Near_Viaduct );
	TankNearTower = OnTriggerRegion( Vec3(4594.034180, -247.902695, -25.987873), 60, Map.Tank_Near_Tower );
	Tankatbridge = OnTriggerRegion( AABB(6261.390,-655.990,-114.394,6299.390,-617.990,-40.394), Map.TankAtBridge );
	Inside = OnTriggerRegion( AABB(-2432.875,-1792.854,17.125,-1831.125,-1151.125,164.028), Map.Ally_inside );
	AlliesInside = OnTriggerRegion( AABB(-2432.871,-2112.694,-250.875,3054.439,1923.367,698.564), Map.Allies_Inside );

	RegionTrigger.Create(AABB(3591.126,-632.875,281.348,3704.875,-519.125,355.348), "DisableCombatMovement", "Snipe_from_tower" );
	RegionTrigger.Create(AABB(3591.126,-632.875,281.348,3704.875,-519.125,355.348), "DisableBotPush", "Snipe_from_tower" );
	RegionTrigger.Create(AABB(-1480.875,-1536.875,1.125,-1368.526,-1467.606,75.125), "DisableBotPush", "MOBILEMG42_lab_door" );
	RegionTrigger.Create(AABB(5703.472,-384.875,-39.401,5812.544,-301.173,74.820), "DisableBotPush", "Axis_Barrier_02" );
	RegionTrigger.Create(AABB(4208.652,-1029.316,114.252,4306.979,-926.615,224.124), "DisableBotPush", "Axis_Barrier_05" );
	RegionTrigger.Create(AABB(4510.859,-834.196,38.728,4604.925,-730.411,119.549), "DisableBotPush", "Axis_Barrier_06" );
	RegionTrigger.Create(AABB(4264.468,1874.895,233.334,4353.276,1970.290,349.276), "DisableBotPush", "Axis_TunnelExit_01" );
	RegionTrigger.Create(AABB(4066.330,1841.811,173.125,4133.819,1910.802,247.125), "DisableBotPush", "Axis_TunnelExit_03" );
	RegionTrigger.Create(AABB(-1173.400,-970.494,-20.818,-1023.125,-469.046,303.971), "DisableBotPush", "Balcony_above_gate_materials" );
	RegionTrigger.Create(AABB(-1173.400,-970.494,-20.818,-1023.125,-469.046,303.971), "DisableCombatMovement", "Balcony_above_gate_materials" );
	RegionTrigger.Create(AABB(-1125.186,-1115.531,97.125,-1011.846,-903.785,235.125), "DisableBotPush", "Above_gate" );
	RegionTrigger.Create(AABB(-1125.186,-1115.531,97.125,-1011.846,-903.785,235.125), "DisableCombatMovement", "Above_gate" );
	RegionTrigger.Create(AABB(-1262.458,-1600.873,183.125,-1080.358,-1342.732,410.374), "DisableBotPush", "Roof_opposite_the_laboratory" );
	RegionTrigger.Create(AABB(-1262.458,-1600.873,183.125,-1080.358,-1342.732,410.374), "DisableCombatMovement", "Roof_opposite_the_laboratory" );
	RegionTrigger.Create(AABB(-1405.613,-1585.799,129.125,-1212.124,-1519.336,259.125), "DisableBotPush", "Balcony_nex_to_the_laboratory_entrance" );
	RegionTrigger.Create(AABB(-1405.613,-1585.799,129.125,-1212.124,-1519.336,259.125), "DisableCombatMovement", "Balcony_nex_to_the_laboratory_entrance" );
	RegionTrigger.Create(AABB(-1147.730,-844.937,-22.875,-1087.125,-775.125,51.125), "DisableBotPush", "Axis_OutsideLaboratory_06" );
	RegionTrigger.Create(AABB(-1147.730,-844.937,-22.875,-1087.125,-775.125,51.125), "DisableCombatMovement", "Axis_OutsideLaboratory_06" );
	RegionTrigger.Create(AABB(-2042.362,-1573.379,49.125,-1983.125,-1519.125,123.125), "DisableBotPush", "Axis_InsideLaboratory_01" );
	RegionTrigger.Create(AABB(2118.692,-174.424,1.398,2213.911,-66.299,78.194), "DisableBotPush", "Around_Mobilemortar" );
	RegionTrigger.Create(AABB(-1124.842,-448.875,-0.956,-894.275,-384.491,131.126), "DisableBotPush", "Axis_wire_swing" );
	RegionTrigger.Create(AABB(-1124.842,-448.875,-0.956,-894.275,-384.491,131.126), "DisableCombatMovement", "Axis_wire_swing" );
	RegionTrigger.Create(AABB(-1344.875,-107.230,1.171,-1288.014,128.053,75.974), "DisableBotPush", "Allies_wire_swing" );
	RegionTrigger.Create(AABB(-1344.875,-107.230,1.171,-1288.014,128.053,75.974), "DisableCombatMovement", "Allies_wire_swing" );
	RegionTrigger.Create(AABB(-1350.549,-1340.112,-47.296,-1250.079,-1266.125,27.266), "DisableCombatMovement", "AIRSTRIKE_OutsideLaboratory_24" );
	RegionTrigger.Create(AABB(-1427.372,-1824.874,130.125,-1327.257,-1697.100,204.125), "DisableCombatMovement", "Allies_OutsideLaboratory_13" );
	RegionTrigger.Create(AABB(6056.849,-415.579,-146.792,6455.802,-279.813,-58.718), "DisableCombatMovement", "Near_Barrier" );
	RegionTrigger.Create(AABB(-322.853,-1834.898,265.544,141.547,-1428.204,419.125), "DisableCombatMovement", "Roof" );
	RegionTrigger.Create(AABB(-322.853,-1834.898,265.544,141.547,-1428.204,419.125), "DisableBotPush", "Roof" );
	RegionTrigger.Create(AABB(-544.875,-1541.390,129.125,-351.125,-981.426,241.995), "DisableCombatMovement", "Bridge" );
	RegionTrigger.Create(AABB(-288.874,-1097.072,-129.431,-17.892,-853.243,117.930), "DisableCombatMovement", "BoXes" );

	Util.LimitToClass("PLANT_Allied_Command_Post", TEAM.AXIS, CLASS.COVERTOPS);
	Util.LimitToClass("PLANT_Wire_Swing_Gate_neutral", TEAM.AXIS, CLASS.COVERTOPS);

	Util.LimitToClass("PLANT_Axis_Command_Post", TEAM.ALLIES, CLASS.COVERTOPS);
	Util.LimitToClass("PLANT_MG2", TEAM.ALLIES, CLASS.COVERTOPS);
	Util.LimitToClass("PLANT_North_market_MG_nest", TEAM.ALLIES, CLASS.COVERTOPS);
	Util.LimitToClass("PLANT_Wire_Swing_Gate_neutral", TEAM.ALLIES, CLASS.COVERTOPS);

	SetGoalRole("CAMP_Inside_.*", ROLE.ATTACKER);
	SetGoalRole("PLANT_lab_barricade_materials_inside", ROLE.ATTACKER);
	ClearGoalRole("FLAG_case1", ROLE.ATTACKER);

	SetGoalPriority( "BUILD_Tank_defences_bridge", 0.89, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_villa_courtyard_gate", 0.79, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_back_door", 0.82, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Wire_Swing_Gate_neutral", 0.79, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "SMOKEBOMB_Allies_OutsideLaboratory_14", 0.8, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_North_market_MG_nest", 0.8, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_barricade_materials", 0.8, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_barricade_materials", 0.83, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_lab_barricade_materials_1", 0.83, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_lab_barricade_materials_inside", 0.9, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_lab_barricade_materials_inside", 0.9, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_North_market_MG_nest", 0.82, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "SMOKEBOMB_Allies_MainGate_15", 0.82, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "SMOKEBOMB_Allies_Barrier_.*", 0.81, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "CAPPOINT_Wait", 0.6, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "CAPPOINT_Wait", 0.6, TEAM.ALLIES, CLASS.ENGINEER );

	SetGoalPriority( "BUILD_lab_barricade_materials", 0.92, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "DEFEND_Axis_Barrier_01", 0.52, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_Barrier_02", 0.51, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_TunnelExit_01", 0.52, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_TunnelExit_02", 0.51, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_OutsideLaboratory_.*", 0.53, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_InsideLaboratory_.*", 0.55, TEAM.AXIS, 0 );

	Util.DisableGoal( ".*", true );

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"BUILD_MG2",
		"MOBILEMORTAR_Axis_Start",
		"AMMOCAB_ammo1",
		"HEALTHCAB_health1",
		".*_Axis_Tower_.*",
		".*_Axis_Barrier_.*",
		".*_Axis_TunnelExit_.*",
	});

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"ATTACK_Allies_MainGate_.*",
		"AIRSTRIKE_Allies_MainGate_16",
		"SMOKEBOMB_Allies_Barrier_01",
	});

	Wp.SetWaypointFlag( "Door_1", "axis", true );
	Wp.SetWaypointFlag( "Door_2", "axis", true );
	Wp.SetWaypointFlag( "Door_1", "door", true );
	Wp.SetWaypointFlag( "Door_2", "door", true );
	Wp.SetWaypointFlag( "back_door_1", "axis", true );
	Wp.SetWaypointFlag( "back_door_2", "axis", true );
	Wp.SetWaypointFlag( "back_door_1", "door", true );
	Wp.SetWaypointFlag( "back_door_2", "door", true );
	Wp.SetWaypointFlag( "back_door_2", "blockwall", false );
	Wp.SetWaypointFlag( "back_door_1", "blockwall", false );
	Wp.SetWaypointFlag( "barricade_materials_1", "closed", true );
	Wp.SetWaypointFlag( "barricade_materials_2", "closed", true );
	Wp.SetWaypointFlag( "Axis_Wire_swing", "closed", true );
	Wp.SetWaypointFlag( "Allied_Wire_swing", "closed", true );
	Wp.SetWaypointFlag( "lab_door_1", "axis", true );
	Wp.SetWaypointFlag( "lab_door_2", "axis", true );
	Wp.SetWaypointFlag( "lab_door_1", "door", true );
	Wp.SetWaypointFlag( "lab_door_2", "door", true );
	Wp.SetWaypointFlag( "lab_door_1", "closed", false );
	Wp.SetWaypointFlag( "lab_door_2", "closed", false );
	Wp.SetWaypointFlag( "lab_door_3", "closed", true );
	Wp.SetWaypointFlag( "lab_door_4", "closed", true );

	Util.SetGoalPosition(-345.725037, -1951.412231, 72.125, "PLANT_back_door");

	Util.AddUseWp( "PLANT_Tank_defences_bridge", "Tank_defences_bridge_Plant_WP" );
	Util.AddUseWp( "BUILD_MG2", "MG2_Build_WP" );
	Util.AddUseWp( "PLANT_villa_courtyard_gate", "villa_courtyard_gate_Plant_WP_1" );
	Util.AddUseWp( "PLANT_villa_courtyard_gate", "villa_courtyard_gate_Plant_WP_2" );
	Util.AddUseWp( "PLANT_back_door", "Plant_WP_1" );
	Util.AddUseWp( "PLANT_back_door", "Plant_WP_2" );
	Util.AddUseWp( "PLANT_barricade_materials", "Plant_WP_1" );
	Util.AddUseWp( "PLANT_barricade_materials", "Plant_WP_2" );

	Util.AddUseWp( "PLANT_Laboratory_Entrance", "Lab" );
	Util.AddUseWp( "PLANT_lab_barricade_materials", "Lab" );
	Util.AddUseWp( "PLANT_lab_barricade_materials_1", "gt" );
	Util.AddUseWp( "PLANT_lab_barricade_materials", "X" );
	Util.AddUseWp( "PLANT_Laboratory_Entrance", "X" );
	Util.AddUseWp( "BUILD_North_market_MG_nest", "Y" );

	Util.SetMaxUsers( 1, "ATTACK_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "MOUNT.*" );
	Util.SetMaxUsers( 2, "ESCORT_.*" );

	Util.DisableGoal ("ROUTE_Around_Cabinets_1");
	Util.DisableGoal ("ROUTE_ToBackDoor_1");
	Util.DisableGoal ("ROUTE_ToBackDoor_2");

	thread(Map.WatchTankStatus);

	print( "^3Omni-bot map script for ^1" + GetMapName() + " ^3by ^1Q^2i^3k^4i ^3and ^1n^2a^4t^8i^3v^5e12^3." );

	sleep(1);

	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Tank_defences_bridge" );
};

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 90.0;

	WeaponTable.SetWeaponAvailability( CLASS.SOLDIER, WEAPON.FLAMETHROWER, false );

	WeaponTable.SetWeaponTeamAvailability( TEAM.ALLIES, CLASS.SOLDIER, WEAPON.MOBILE_MG42, false );
	WeaponTable.SetWeaponTeamAvailability( TEAM.ALLIES, CLASS.SOLDIER, WEAPON.MORTAR, false );

	if ( ETUtil.CountClass( TEAM.AXIS, CLASS.SOLDIER ) < 2 )
	{
		if ( Map.Main_Town_Gate )
		{
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.FLAMETHROWER, false );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MOBILE_MG42, false );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.PANZERFAUST, false );

			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MORTAR, true );

			if ( bot.GetTeam() == TEAM.AXIS )
			{
				if ( bot.HasWeapon(WEAPON.FLAMETHROWER) or bot.HasWeapon(WEAPON.MOBILE_MG42) or bot.HasWeapon(WEAPON.PANZERFAUST) )
				{
					bot.ExecCommand("kill");
					Util.MapDebugPrint( "^5I have wrong weapon" );
				}
			}
		}
		else
		{
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.FLAMETHROWER, false );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MORTAR, false );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.PANZERFAUST, false );

			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MOBILE_MG42, true );

			if ( bot.GetTeam() == TEAM.AXIS )
			{
				if ( bot.HasWeapon(WEAPON.FLAMETHROWER) or bot.HasWeapon(WEAPON.MORTAR) or bot.HasWeapon(WEAPON.PANZERFAUST) )
				{
					bot.ExecCommand("kill");
					Util.MapDebugPrint( "^5I have wrong weapon" );
				}
			}
		}
	}
	else
	{
		if ( Map.Main_Town_Gate )
		{
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.FLAMETHROWER, false );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MOBILE_MG42, false );

			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MORTAR, true );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.PANZERFAUST, true );

			if ( bot.GetTeam() == TEAM.AXIS )
			{
				if ( bot.HasWeapon(WEAPON.FLAMETHROWER) or bot.HasWeapon(WEAPON.MOBILE_MG42) )
				{
					bot.ExecCommand("kill");
					Util.MapDebugPrint( "^5I have wrong weapon" );
				}
			}
		}
		else
		{
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.FLAMETHROWER, false );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MORTAR, false );

			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.MOBILE_MG42, true );
			WeaponTable.SetWeaponTeamAvailability( TEAM.AXIS, CLASS.SOLDIER, WEAPON.PANZERFAUST, true );

			if ( bot.GetTeam() == TEAM.AXIS )
			{
				if ( bot.HasWeapon(WEAPON.FLAMETHROWER) or bot.HasWeapon(WEAPON.MORTAR) )
				{
					bot.ExecCommand("kill");
					Util.MapDebugPrint( "^5I have wrong weapon" );
				}
			}
		}
	}
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		PLANT_North_market_MG_nest =
		{
			ROUTE_Allied_CitySpawn_1 =
			{
				ROUTE_Around_AlliedCP =
				{
					ROUTE_TunnelEntrance =
					{
						ROUTE_RightTunnel_1 =
						{
							ROUTE_RightTunnel_2 =
							{

							},
						},
					},
				},
			},
			ROUTE_Allied_CitySpawn_2 =
			{
				ROUTE_Around_AlliedCP =
				{
					ROUTE_TunnelEntrance =
					{
						ROUTE_RightTunnel_1 =
						{
							ROUTE_RightTunnel_2 =
							{

							},
						},
					},
				},
			},
			ROUTE_Allied_CitySpawn_3 =
			{
				ROUTE_Around_AlliedCP =
				{
					ROUTE_TunnelEntrance =
					{
						ROUTE_RightTunnel_1 =
						{
							ROUTE_RightTunnel_2 =
							{

							},
						},
					},
				},
			},
		},
		PLANT_MG2 =
		{
			ROUTE_Allied_Spawn =
			{
				ROUTE_CaveTunnel_1 =
				{
					ROUTE_CaveTunnel_2 =
					{

					},
				},
			},
		},
		ATTACK_Allies_MainGate_03 =
		{
			ROUTE_Allied_Spawn =
			{
				ROUTE_CaveTunnel_1 =
				{
					Weight = 2,
					ROUTE_CaveTunnel_2 =
					{

					},
				},
				ROUTE_Bridge =
				{

				},
			},
		},
	};

	MapRoutes["ATTACK_Allies_OutsideLaboratory_.*"] =
	{
		ROUTE_Allied_CitySpawn_1 =
		{
			ROUTE_Around_AlliedCP =
			{
				Weight = 3,
				ROUTE_TunnelEntrance =
				{
					Weight = 3,
					ROUTE_RightTunnel_1 =
					{
						ROUTE_RightTunnel_2 =
						{
							ROUTE_Around_AxisSpawn =
							{
								ROUTE_Inside_1 =
								{
									ROUTE_Inside_2 =
									{

									},
								},
							},
							ROUTE_Under_NorthMGnest =
							{
								Weight = 2,
								ROUTE_Between_Buildings =
								{
									ROUTE_WireSwing =
									{

									},
									ROUTE_Stairs_WireSwing =
									{
										ROUTE_BackDoorInside =
										{

										},
									},
								},
							},
						},
					},
				},
				ROUTE_Around_Cabinets =
				{
					Weight = 2,
					ROUTE_StairsToBalcony =
					{
						ROUTE_Balcony =
						{
							ROUTE_Roof =
							{
								ROUTE_BackDoorInside =
								{

								},
							},
						},
					},
				},
			},
			ROUTE_Around_AlliedCP_1 =
			{
				Weight = 4,
				ROUTE_Tunnel_Straight =
				{
					Weight = 3,
					ROUTE_CourtyardGate =
					{

					},
				},
				ROUTE_Around_Cabinets_1 =
				{
					Weight = 3,
					ROUTE_ToBackDoor_1 =
					{
						Weight = 3,
						ROUTE_ToBackDoor_2 =
						{

						},
					},
					ROUTE_Around_Wall =
					{
						Weight = 2,
						ROUTE_Under_Bridge =
						{
							ROUTE_CourtyardGate =
							{

							},
						},
					},
				},
			},
		},
		ROUTE_Allied_CitySpawn_2 =
		{
			ROUTE_Around_AlliedCP =
			{
				Weight = 3,
				ROUTE_TunnelEntrance =
				{
					Weight = 3,
					ROUTE_RightTunnel_1 =
					{
						ROUTE_RightTunnel_2 =
						{
							ROUTE_Around_AxisSpawn =
							{
								ROUTE_Inside_1 =
								{
									ROUTE_Inside_2 =
									{

									},
								},
							},
							ROUTE_Under_NorthMGnest =
							{
								Weight = 2,
								ROUTE_Between_Buildings =
								{
									ROUTE_WireSwing =
									{

									},
									ROUTE_Stairs_WireSwing =
									{
										ROUTE_BackDoorInside =
										{

										},
									},
								},
							},
						},
					},
				},
				ROUTE_Around_Cabinets =
				{
					Weight = 2,
					ROUTE_StairsToBalcony =
					{
						ROUTE_Balcony =
						{
							ROUTE_Roof =
							{
								ROUTE_BackDoorInside =
								{

								},
							},
						},
					},
				},
			},
			ROUTE_Around_AlliedCP_1 =
			{
				Weight = 4,
				ROUTE_Tunnel_Straight =
				{
					Weight = 3,
					ROUTE_CourtyardGate =
					{

					},
				},
				ROUTE_Around_Cabinets_1 =
				{
					Weight = 3,
					ROUTE_ToBackDoor_1 =
					{
						Weight = 3,
						ROUTE_ToBackDoor_2 =
						{

						},
					},
					ROUTE_Around_Wall =
					{
						Weight = 2,
						ROUTE_Under_Bridge =
						{
							ROUTE_CourtyardGate =
							{

							},
						},
					},
				},
			},
		},
		ROUTE_Allied_CitySpawn_3 =
		{
			ROUTE_Around_AlliedCP =
			{
				Weight = 3,
				ROUTE_TunnelEntrance =
				{
					Weight = 3,
					ROUTE_RightTunnel_1 =
					{
						ROUTE_RightTunnel_2 =
						{
							ROUTE_Around_AxisSpawn =
							{
								ROUTE_Inside_1 =
								{
									ROUTE_Inside_2 =
									{

									},
								},
							},
							ROUTE_Under_NorthMGnest =
							{
								Weight = 2,
								ROUTE_Between_Buildings =
								{
									ROUTE_WireSwing =
									{

									},
									ROUTE_Stairs_WireSwing =
									{
										ROUTE_BackDoorInside =
										{

										},
									},
								},
							},
						},
					},
				},
				ROUTE_Around_Cabinets =
				{
					Weight = 2,
					ROUTE_StairsToBalcony =
					{
						ROUTE_Balcony =
						{
							ROUTE_Roof =
							{
								ROUTE_BackDoorInside =
								{

								},
							},
						},
					},
				},
			},
			ROUTE_Around_AlliedCP_1 =
			{
				Weight = 4,
				ROUTE_Tunnel_Straight =
				{
					Weight = 3,
					ROUTE_CourtyardGate =
					{

					},
				},
				ROUTE_Around_Cabinets_1 =
				{
					Weight = 3,
					ROUTE_ToBackDoor_1 =
					{
						Weight = 3,
						ROUTE_ToBackDoor_2 =
						{

						},
					},
					ROUTE_Around_Wall =
					{
						Weight = 2,
						ROUTE_Under_Bridge =
						{
							ROUTE_CourtyardGate =
							{

							},
						},
					},
				},
			},
		},
	};

	MapRoutes.ATTACK_Allies_MainGate_04 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_05 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_06 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_07 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_08 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_09 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_10 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_11 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_12 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_13 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.ATTACK_Allies_MainGate_14 = MapRoutes.ATTACK_Allies_MainGate_03;
	MapRoutes.PLANT_lab_barricade_materials = MapRoutes["ATTACK_Allies_OutsideLaboratory_.*"];
	MapRoutes.PLANT_lab_barricade_materials_1 = MapRoutes["ATTACK_Allies_OutsideLaboratory_.*"];
	MapRoutes.PLANT_Laboratory_Entrance = MapRoutes["ATTACK_Allies_OutsideLaboratory_.*"];

	Util.Routes(MapRoutes);
};
