//==========================================================================================
//
//	adlernest_2.gm
//
//	Who      		When			What
//------------------------------------------------------------------------------------------
//	Qiki			14 December 2010	Initial Script
//	Native12		4.1.2011		Final script
//	adlernest_2.way		4.1.2011		Size: 278 528 b
//	adlernest_2_goals.gm	4.1.2011		Size: 65 536 b
//==========================================================================================
//
//	Native12
//	adlernest_2.gm		11.1.2011		Cleaning script, correction
//	adlernest_2.way		11.1.2011		Size: 278 528 b
//	adlernest_2_goals.gm	11.1.2011		Size: 65 536 b
//==========================================================================================
//
//	adlernest_2.gm		13.1.2011		Correction in navigation table (Thx crapshoot)
//==========================================================================================
//

global Map =
{
	Talk = true,
	talk = 1,
	DefendingTeam = TEAM.AXIS,

	Allied_CP_Dyno = 0,
	Door_controls_Dyno = 0,

	BlastDoorOpen = 0,
	CP_build = 0,
	Docs_taken = 0,
	DoorControlDestroyed = 0,
	AlliesInTrigger1 = 0,
	EngInTrigger1 = 0,
	AlliesInTrigger2 = 0,
	EngInTrigger2 = 0,
	AlliesInTrigger3 = 0,
	EngInTrigger3 = 0,
	PipeBar1_Exploded = false,
	PipeBar2_Exploded = false,
	windowexploded = false,

	// region triggers
	iw1 = 0,
	iw2 = 0,
	iw3 = 0,
	iw4 = 0,

	Navigation =
	{
		//  	/bot waypoint_setproperty paththrough Navigation_PT:pipebar1
		pipebar1 =
		{
			gotowp = "pipe_bar1", // waypoint for the bot to go to before doing anything else
			EvalFunc = function(_this) // if this function returns false, navigation will not run
			{
				if ( _this.Bot.GetTeam() == TEAM.AXIS )
				{
					return false;
				}

				return !Map.PipeBar1_Exploded;
			},
			navigate = function(_this)
			{
				if ( Map.PipeBar1_Exploded )
				{
					yield();
					return;
				}

				_this.AddWeaponRequest(WEAPON.KNIFE);
				_this.AddAimRequest(Priority.High, "facing", Vector3(-1,0,0));

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

				_this.Bot.ReleaseButton(BTN.ATTACK1);
				_this.ReleaseAimRequest();
				_this.ReleaseWeaponRequest();
			},
		},
		//  	/bot waypoint_setproperty paththrough Navigation_PT:pipebar2
		pipebar2 =
		{
			gotowp = "pipe_bar2", // waypoint for the bot to go to before doing anything else
			EvalFunc = function(_this) // if this function returns false, navigation will not run
			{
				if ( _this.Bot.GetTeam() == TEAM.AXIS )
				{
					return false;
				}

				return !Map.PipeBar2_Exploded;
			},
			navigate = function(_this)
			{
				if ( Map.PipeBar2_Exploded )
				{
					yield();
					return;
				}

				_this.AddWeaponRequest(WEAPON.KNIFE);
				_this.AddAimRequest(Priority.High, "facing", Vector3(0,-1,0.1));

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

				_this.Bot.ReleaseButton(BTN.ATTACK1);
				_this.ReleaseAimRequest();
				_this.ReleaseWeaponRequest();
			},
		},
		//  	/bot waypoint_setproperty paththrough Navigation_PT:docswindow
		docswindow =
		{
			gotowp = "window", // waypoint for the bot to go to before doing anything else
			EvalFunc = function(_this) // if this function returns false, navigation will not run
			{
				if ( _this.Bot.GetTeam() == TEAM.AXIS )
				{
					return false;
				}

				return !Map.windowexploded;
			},
			navigate = function(_this)
			{
				if ( Map.windowexploded )
				{
					yield();
					return;
				}

				_this.AddWeaponRequest( WEAPON.COLT);
				_this.AddAimRequest(Priority.High, "facing", Vector3(0.4,1,0.1));

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

				_this.Bot.ReleaseButton(BTN.ATTACK1);
				_this.ReleaseAimRequest();
				_this.ReleaseWeaponRequest();
			},
		},
	},

	PipeBar_1_Exploded = function()
	{
		Map.PipeBar1_Exploded = true;

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

	PipeBar_2_Exploded = function()
	{
		Map.PipeBar2_Exploded = true;

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

	Window_Exploded = function()
	{
		Map.windowexploded = true;

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

	Door_controls_Planted = function()
	{
		Map.Door_controls_Dyno += 1;

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

	Door_controls_Defused = function()
	{
		Map.Door_controls_Dyno -= 1;

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

	Door_controls_Destroyed = function()
	{
		Map.Door_controls_Dyno = 0;
		Map.DoorControlDestroyed = 1;

		Map.AlliesInTrigger1 = 0;
		Map.AlliesInTrigger2 = 0;
		Map.AlliesInTrigger3 = 0;
		Map.EngInTrigger1 = 0;
		Map.EngInTrigger2 = 0;
		Map.EngInTrigger3 = 0;

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

		DeleteTriggerRegion( Map.iw1 );
		DeleteTriggerRegion( Map.iw2 );
		DeleteTriggerRegion( Map.iw3 );
		DeleteTriggerRegion("trigger_1");
		DeleteTriggerRegion("trigger_2");
		DeleteTriggerRegion("trigger_3");

		Map.iw4 = OnTriggerRegion(AABB(-2014.874,-972.384,-118.875,1152.874,1730.874,179.125), RegionTrigger.IntrusionWarning);
		trigger4 = OnTriggerRegion(AABB(-2014.874,-972.384,-118.875,1152.874,1730.874,179.125), Map.Trigger_4);

		SetGoalPriority( "SWITCH_.*", 0.5, TEAM.AXIS, CLASS.FIELDOPS );

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

		Util.SetMaxUsers( 20, "FLAG_documents" );

		SetAvailableMapGoals( TEAM.AXIS, false, {
			".*_Axis_DoorControls_.*",
			"DEFUSE_Door_controls_.*",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			".*_Allied_DoorControls_.*",
			"MOUNTMG42_359",
		});

		if ( Map.Docs_taken == 0 )
		{
			SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_AtDocs_.*" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_AtTransmitter_.*" );
		}

		sleep(2);

		if ( Map.BlastDoorOpen == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"SWITCH_BlastDoorSwitch1",
				"SWITCH_BlastDoorSwitch2",
			});
		}

		if ( Map.CP_build == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_CP" );
		}

		if ( Map.Docs_taken == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_documents" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"ATTACK_Allied_AtTransmitter_.*",
				"CAPPOINT_Transmitter",
			});
		}

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

	Allied_CP_Built = function()
	{

		Map.CP_build = 1;

		Util.ChangeSpawn( TEAM.ALLIES, 2 );

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

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

		Util.MapDebugPrint( "^5Allied_CP_Built" );

		if ( Map.DoorControlDestroyed == 0 )
		{
			Util.SetMaxUsers( 20, "FLAG_documents" );

			if ( Map.Docs_taken == 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

				SetAvailableMapGoals( TEAM.AXIS, true, {
					".*_Axis_AtDocs_.*",
					"DEFEND_Axis_DoorControls_5",
					"DEFEND_Axis_DoorControls_6",
					"DEFEND_Axis_DoorControls_8",
					"DEFEND_Axis_DoorControls_9",
				});

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

				Util.MapDebugPrint( "^5Allied_CP_Built, docs not taken" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

				SetAvailableMapGoals( TEAM.AXIS, true, {
					".*_Axis_AtTransmitter_.*",
					"DEFEND_Axis_DoorControls_5",
					"DEFEND_Axis_DoorControls_6",
					"DEFEND_Axis_DoorControls_8",
					"DEFEND_Axis_DoorControls_9",
				});

				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"ATTACK_Allied_AtTransmitter_.*",
					"CAPPOINT_Transmitter",
				});

				Util.MapDebugPrint( "^5Allied_CP_Built, docs taken" );
			}

			if ( Map.BlastDoorOpen == 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"SWITCH_BlastDoorSwitch1",
					"SWITCH_BlastDoorSwitch2",
				});

				Util.MapDebugPrint( "^5Allied_CP_Built, BlastDoor closed" );
			}
		}
	},

	Allied_CP_Destroyed = function()
	{
		Map.Allied_CP_Dyno = 0;
		Map.CP_build = 0;

		Util.ChangeSpawn( TEAM.ALLIES, 1 );

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

		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_CP_.*" );

		if ( Map.DoorControlDestroyed == 0 )
		{
			if ( Map.BlastDoorOpen == 0 )
			{
				if ( Map.AlliesInTrigger1 > 0 or Map.AlliesInTrigger2 > 0 or Map.AlliesInTrigger3 > 0 )
				{
					if ( Map.EngInTrigger1 > 0 or Map.EngInTrigger2 > 0 or Map.EngInTrigger3 > 0 )
					{
						SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_CP" );

						Util.MapDebugPrint( "^5Allied_CP_Destroyed, BlastDoor closed, Allies in Triggers, Eng in Triggers" );

						while ( Map.EngInTrigger1 > 0 or Map.EngInTrigger2 > 0 or Map.EngInTrigger3 > 0 and Map.Docs_taken == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
						{
							yield();
						}

						if ( Map.Docs_taken == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
						{
							SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_CP" );

							Util.MapDebugPrint( "^5Allied_CP_Destroyed, BlastDoor closed, Allies in Triggers, ^3Eng isn´t in Triggers" );
						}
					}
					else
					{
						SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_CP" );

						Util.MapDebugPrint( "^5Allied_CP_Destroyed, BlastDoor closed, Allies in Triggers, ^3Eng isn´t in Triggers" );
					}

					while( Map.AlliesInTrigger1 > 0 or Map.AlliesInTrigger2 > 0 or Map.AlliesInTrigger3 > 0 and Map.Docs_taken == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
					{
						yield();
					}

					if ( Map.Docs_taken == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
					{
						SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_AtDocs_.*" );

						SetAvailableMapGoals( TEAM.ALLIES, false, {
							"FLAG_documents",
							"SWITCH_BlastDoorSwitch1",
							"SWITCH_BlastDoorSwitch2",
						});

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

						Util.MapDebugPrint( "^5Allied_CP_Destroyed, BlastDoor closed, Allies aren´t in Triggers, Docs not taken" );
					}
				}
				else
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, {
						"FLAG_documents",
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
					});

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

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

					Util.MapDebugPrint( "^5Allied_CP_Destroyed, BlastDoor closed, Allies aren´t in Triggers, Docs not taken" );
				}
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_CP" );

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"SWITCH_BlastDoorSwitch1",
					"SWITCH_BlastDoorSwitch2",
				});

				Util.MapDebugPrint( "^5Allied_CP_Destroyed, BlastDoor opened" );
			}
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_CP" );

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

	Allied_CP_Planted = function()
	{
		Map.Allied_CP_Dyno += 1;

		if ( Map.DoorControlDestroyed == 0 )
		{
			if ( Map.BlastDoorOpen == 0 )
			{
				if ( Map.EngInTrigger1 > 0 or Map.EngInTrigger2 > 0 or Map.EngInTrigger3 > 0 )
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Allied_CP_.*" );

					Util.MapDebugPrint( "^5Allied_CP_Planted, BlastDoor closed, Allies in Triggers, Eng in Triggers" );

					while ( Map.EngInTrigger1 > 0 or Map.EngInTrigger2 > 0 or Map.EngInTrigger3 > 0 and Map.Docs_taken == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
					{
						yield();
					}

					if ( Map.Docs_taken == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
					{
						SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_CP_.*" );

						Util.MapDebugPrint( "^5Allied_CP_Planted, BlastDoor closed, Allies in Triggers, ^3Eng isn´t in Triggers" );
					}
				}
				else
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_CP_.*" );

					Util.MapDebugPrint( "^5Allied_CP_Planted, BlastDoor closed, Allies in Triggers, ^3Eng isn´t in Triggers" );
				}
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Allied_CP_.*" );

				Util.MapDebugPrint( "^5Allied_CP_Planted, BlastDoor opened" );
			}
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Allied_CP_.*" );

			Util.MapDebugPrint( "^5Allied_CP_Planted" );
		}

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

	Allied_CP_Defused = function()
	{
		Map.Allied_CP_Dyno -= 1;

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

	documents_Taken = function()
	{

		Map.Docs_taken = 1;

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

		if ( Map.DoorControlDestroyed == 0 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_Transmitter" );

			if ( Map.CP_build == 0 and Map.BlastDoorOpen == 0 )
			{
				if ( Map.AlliesInTrigger1 > 0 or Map.AlliesInTrigger2 > 0 or Map.AlliesInTrigger3 > 0 )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

					SetAvailableMapGoals( TEAM.AXIS, true, {
						"DEFEND_Axis_AtTransmitter_1",
						"DEFEND_Axis_AtTransmitter_2",
						"DEFEND_Axis_AtTransmitter_3",
						"DEFEND_Axis_AtTransmitter_4",
						"MOBILEMG42_Axis_AtTransmitter_18",
						"DEFEND_Axis_DoorControls_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, true, {
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
						"ATTACK_Allied_AtTransmitter_.*",
					});

					Util.MapDebugPrint( "^5documents_Taken, Doorcontrols intact, CP not builded, BlastDoor closed, Allies in Triggers" );

					while( Map.AlliesInTrigger1 > 0 or Map.AlliesInTrigger2 > 0 or Map.AlliesInTrigger3 > 0 and Map.CP_build == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.Docs_taken == 1 )
					{
						yield();
					}

					if ( Map.CP_build == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.Docs_taken == 1 )
					{
						SetAvailableMapGoals( TEAM.ALLIES, false, {
							"SWITCH_BlastDoorSwitch1",
							"SWITCH_BlastDoorSwitch2",
							"CAPPOINT_Transmitter",
							"ATTACK_Allied_AtTransmitter_.*",
						});

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

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

						Util.MapDebugPrint( "^5documents_Taken, Doorcontrols intact, CP not builded, BlastDoor closed, Allies aren´t in Triggers" );
					}
				}
				else
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, {
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
						"CAPPOINT_Transmitter",
						"ATTACK_Allied_AtTransmitter_.*",
					});

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

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

					Util.MapDebugPrint( "^5documents_Taken, Doorcontrols intact, CP not builded, BlastDoor closed, Allies aren´t in Triggers" );
				}
			}
			else
			{
				SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

				SetAvailableMapGoals( TEAM.AXIS, true, {
					".*_Axis_AtTransmitter_.*",
					"DEFEND_Axis_DoorControls_5",
					"DEFEND_Axis_DoorControls_6",
					"DEFEND_Axis_DoorControls_8",
					"DEFEND_Axis_DoorControls_9",
				});

				SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_Allied_AtTransmitter_.*" );

				if ( Map.BlastDoorOpen == 0 )
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, {
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
					});

					Util.MapDebugPrint( "^5documents_Taken, Doorcontrols intact, BlastDoor closed, CP builded" );
				}
				else
				{
					SetAvailableMapGoals( TEAM.AXIS, true, {
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
					});

					Util.MapDebugPrint( "^5documents_Taken, Doorcontrols intact, BlastDoor opened, CP builded" );
				}
			}
		}
		else
		{
			if ( Map.BlastDoorOpen == 1 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, {
					"SWITCH_BlastDoorSwitch1",
					"SWITCH_BlastDoorSwitch2",
				});
			}

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

			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"ATTACK_Allied_AtTransmitter_.*",
				"CAPPOINT_Transmitter",
			});

			Util.MapDebugPrint( "^5documents_Taken, Doorcontrols destroyed" );
		}
	},

	documents_Dropped = function()
	{
		Util.MapDebugPrint( "^5documents_Dropped" );
	},

	documents_Returned = function()
	{

		Map.Docs_taken = 0;

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

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

		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_Allied_AtTransmitter_.*" );

		if ( Map.DoorControlDestroyed == 0 )
		{
			if ( Map.BlastDoorOpen == 0 )
			{
				if ( Map.AlliesInTrigger1 > 0 or Map.AlliesInTrigger2 > 0 or Map.AlliesInTrigger3 > 0 )
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, {
						"FLAG_documents",
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
					});

					Util.MapDebugPrint( "^5documents_Returned, BlastDoor closed, Allies in Triggers" );

					if ( Map.CP_build == 0 )
					{
						SetAvailableMapGoals( TEAM.AXIS, true, {
							".*_Axis_DoorControls_.*",
							"DEFEND_Axis_AtDocs_10",
							"DEFEND_Axis_AtDocs_13",
							"DEFEND_Axis_AtDocs_14",
							"MOBILEMG42_Axis_AtDocs_19",
						});

						Util.MapDebugPrint( "^5documents_Returned, BlastDoor closed, Allies in Triggers, CP not builded" );
					}
					else
					{
						SetAvailableMapGoals( TEAM.AXIS, true, {
							".*_Axis_AtDocs_.*",
							"DEFEND_Axis_DoorControls_5",
							"DEFEND_Axis_DoorControls_6",
							"DEFEND_Axis_DoorControls_8",
							"DEFEND_Axis_DoorControls_9",
						});

						Util.MapDebugPrint( "^5documents_Returned, BlastDoor closed, Allies in Triggers, CP builded" );
					}

					while( Map.AlliesInTrigger1 > 0 or Map.AlliesInTrigger2 > 0 or Map.AlliesInTrigger3 > 0 and Map.CP_build == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.Docs_taken == 0 )
					{
						yield();
					}

					if ( Map.CP_build == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.Docs_taken == 0 )
					{
						SetAvailableMapGoals( TEAM.ALLIES, false, {
							"FLAG_documents",
							"SWITCH_BlastDoorSwitch1",
							"SWITCH_BlastDoorSwitch2",
						});

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

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

						Util.MapDebugPrint( "^5documents_Returned, BlastDoor closed, ^3Allies aren´t in Triggers" );
					}
				}
				else
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, {
						"FLAG_documents",
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
					});

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

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

					Util.MapDebugPrint( "^5documents_Returned, BlastDoor closed, ^3Allies aren´t in Triggers" );
				}
			}
			else
			{
				SetAvailableMapGoals( TEAM.AXIS, false, {
					"SWITCH_BlastDoorSwitch1",
					"SWITCH_BlastDoorSwitch2",
					".*_Axis_DoorControls_.*",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					".*_Axis_AtDocs_.*",
					"DEFEND_Axis_DoorControls_5",
					"DEFEND_Axis_DoorControls_6",
					"DEFEND_Axis_DoorControls_8",
					"DEFEND_Axis_DoorControls_9",
				});

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

				Util.MapDebugPrint( "^5documents_Returned, BlastDoor opened" );
			}
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, true, ".*_Axis_AtDocs_.*" );

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

			Util.MapDebugPrint( "^5documents_Returned, DoorControls destroyed" );

			if ( Map.BlastDoorOpen == 1 )
			{
				sleep(3);

				SetAvailableMapGoals( TEAM.AXIS, false, {
					"SWITCH_BlastDoorSwitch1",
					"SWITCH_BlastDoorSwitch2",
				});
			}
		}
	},

	documents_Secured = function()
	{

		ETUtil.WinningChat( TEAM.ALLIES );
		ETUtil.LosingChat( TEAM.AXIS );

		DeleteTriggerRegion("Map.iw4");
		DeleteTriggerRegion("trigger_4");

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

	Door_Open = function()
	{

		Map.BlastDoorOpen = 1;

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SWITCH_BlastDoorSwitch1",
			"SWITCH_BlastDoorSwitch2",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ROUTE_NearMG42",
			"ROUTE_Blast_Door",
		});

		if ( Map.DoorControlDestroyed == 0 )
		{
			if ( Map.CP_build == 0 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, {
					"SWITCH_BlastDoorSwitch1",
					"SWITCH_BlastDoorSwitch2",
				});

				if ( Map.Docs_taken == 1 )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

					SetAvailableMapGoals( TEAM.AXIS, true, {
						".*_Axis_AtTransmitter_.*",
						"DEFEND_Axis_DoorControls_5",
						"DEFEND_Axis_DoorControls_6",
						"DEFEND_Axis_DoorControls_8",
						"DEFEND_Axis_DoorControls_9",
					});

					sleep(2);

					SetAvailableMapGoals( TEAM.ALLIES, true, {
						"ATTACK_Allied_AtTransmitter_.*",
						"BUILD_Allied_CP",
						"CAPPOINT_Transmitter",
					});

					Util.MapDebugPrint( "^5Door_Open, DoorControls intact, CP not builded, Docs taken" );
				}
				else
				{
					SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

					SetAvailableMapGoals( TEAM.AXIS, true, {
						".*_Axis_AtDocs_.*",
						"DEFEND_Axis_DoorControls_5",
						"DEFEND_Axis_DoorControls_6",
						"DEFEND_Axis_DoorControls_8",
						"DEFEND_Axis_DoorControls_9",
					});

					Util.SetMaxUsers( 5, "FLAG_documents" );

					sleep(2);

					SetAvailableMapGoals( TEAM.ALLIES, true, {
						"FLAG_documents",
						"BUILD_Allied_CP",
					});

					Util.MapDebugPrint( "^5Door_Open, DoorControls intact, CP not builded, Docs not taken" );
				}
			}
			else
			{
				if ( Map.Docs_taken == 1 )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

					SetAvailableMapGoals( TEAM.AXIS, true, {
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
						".*_Axis_AtTransmitter_.*",
						"DEFEND_Axis_DoorControls_5",
						"DEFEND_Axis_DoorControls_6",
						"DEFEND_Axis_DoorControls_8",
						"DEFEND_Axis_DoorControls_9",
					});

					SetAvailableMapGoals( TEAM.ALLIES, true, {
						"ATTACK_Allied_AtTransmitter_.*",
						"CAPPOINT_Transmitter",
					});

					Util.MapDebugPrint( "^5Door_Open, DoorControls intact, CP builded, Docs taken" );
				}
				else
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
						".*_Axis_DoorControls_.*",
					});

					SetAvailableMapGoals( TEAM.AXIS, true, {
						".*_Axis_AtDocs_.*",
						"DEFEND_Axis_DoorControls_5",
						"DEFEND_Axis_DoorControls_6",
						"DEFEND_Axis_DoorControls_8",
						"DEFEND_Axis_DoorControls_9",
					});

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

					Util.MapDebugPrint( "^5Door_Open, DoorControls intact, CP builded, Docs not taken" );
				}
			}
		}
		else
		{
			if ( Map.Docs_taken == 1 )
			{
				SetAvailableMapGoals( TEAM.AXIS, true, {
					"SWITCH_BlastDoorSwitch1",
					"SWITCH_BlastDoorSwitch2",
				});

				Util.MapDebugPrint( "^5Door_Open, DoorControls destroyed, Docs taken" );
			}
			else
			{
				SetAvailableMapGoals( TEAM.AXIS, false, {
					"SWITCH_BlastDoorSwitch1",
					"SWITCH_BlastDoorSwitch2",
				});

				Util.MapDebugPrint( "^5Door_Open, DoorControls destroyed, Docs not taken" );
			}

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

	Door_Close = function()
	{

		Map.BlastDoorOpen = 0;

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"SWITCH_BlastDoorSwitch1",
			"SWITCH_BlastDoorSwitch2",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ROUTE_NearMG42",
			"ROUTE_Blast_Door",
		});

		if ( Map.DoorControlDestroyed == 0 )
		{
			if ( Map.CP_build == 0 )
			{
				if ( Map.AlliesInTrigger1 > 0 or Map.AlliesInTrigger2 > 0 or Map.AlliesInTrigger3 > 0 )
				{
					SetAvailableMapGoals( TEAM.ALLIES, true, {
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
					});

					Util.MapDebugPrint( "^5Door_Close, Allies in triggers" );

					if ( Map.AlliesInTrigger1 < 3 or Map.AlliesInTrigger2 < 3 or Map.AlliesInTrigger3 < 3 )
					{
						if ( Map.Docs_taken == 0 )
						{
							SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_AtDocs_.*" );

							SetAvailableMapGoals( TEAM.AXIS, true, {
								"DEFEND_Axis_AtDocs_10",
								"DEFEND_Axis_AtDocs_13",
								".*_Axis_DoorControls_.*",
							});

							Util.MapDebugPrint( "^5<3 Allies remain in Triggers" );
						}
					}

					if ( Map.EngInTrigger1 > 0 or Map.EngInTrigger2 > 0 or Map.EngInTrigger3 > 0 )
					{
						Util.MapDebugPrint( "^5Door_Close, Allies in triggers, Eng in triggers" );

						while ( Map.EngInTrigger1 > 0 or Map.EngInTrigger2 > 0 or Map.EngInTrigger3 > 0 and Map.CP_build == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.Docs_taken == 0 )
						{
							yield();
						}

						if ( Map.CP_build == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.Docs_taken == 0 )
						{
							SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_CP" );

							Util.MapDebugPrint( "^5Door_Close, ^3Eng isn´t in triggers" );
						}
					}
					else
					{
						SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_CP" );

						Util.MapDebugPrint( "^5Door_Close, Allies in triggers, ^3Eng isn´t in triggers" );
					}

					while( Map.AlliesInTrigger1 > 0 or Map.AlliesInTrigger2 > 0 or Map.AlliesInTrigger3 > 0 and Map.CP_build == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.Docs_taken == 0 )
					{
						yield();
					}

					if ( Map.CP_build == 0 and Map.DoorControlDestroyed == 0 and Map.BlastDoorOpen == 0 and Map.Docs_taken == 0 )
					{
						SetAvailableMapGoals( TEAM.ALLIES, false, {
							"CAPPOINT_Transmitter",
							"FLAG_documents",
							"SWITCH_BlastDoorSwitch1",
							"SWITCH_BlastDoorSwitch2",
						});

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

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

						Util.MapDebugPrint( "^5Door_Close, CP not builded, ^3Allies aren´t in triggers" );
					}
				}
				else
				{
					SetAvailableMapGoals( TEAM.ALLIES, false, {
						"CAPPOINT_Transmitter",
						"FLAG_documents",
						"SWITCH_BlastDoorSwitch1",
						"SWITCH_BlastDoorSwitch2",
						"BUILD_Allied_CP",
					});

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

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

					Util.MapDebugPrint( "^5Door_Close, CP not builded, ^3Allies aren´t in triggers" );
				}
			}
			else
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"SWITCH_BlastDoorSwitch1",
					"SWITCH_BlastDoorSwitch2",
				});

				Util.MapDebugPrint( "^5Door_Close, CP builded" );
			}
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, {
				"SWITCH_BlastDoorSwitch1",
				"SWITCH_BlastDoorSwitch2",
			});

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

	Trigger_1 =
	{
		Name = "trigger_1",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				if (Map.DoorControlDestroyed == 0 )
				{
					Map.AlliesInTrigger1 += 1;

					Util.MapDebugPrint( "^5Allies entered into Trigger 1" );

					if ( Map.Docs_taken == 0 )
					{
						SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_documents" );

						if ( Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
						{
							if ( Map.AlliesInTrigger1 < 3 or Map.AlliesInTrigger2 < 3 or Map.AlliesInTrigger3 < 3 )
							{
								SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

								SetAvailableMapGoals( TEAM.AXIS, true, {
									"DEFEND_Axis_AtDocs_10",
									"DEFEND_Axis_AtDocs_13",
									".*_Axis_DoorControls_.*",
								});

								Util.MapDebugPrint( "^5<3 Allies entered into Triggers" );
							}
							else
							{
								SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

								SetAvailableMapGoals( TEAM.AXIS, true, {
									"DEFEND_Axis_AtDocs_10",
									"DEFEND_Axis_AtDocs_13",
									"DEFEND_Axis_AtDocs_14",
									".*_Axis_DoorControls_.*",
								});

								Util.MapDebugPrint( "^5>2 Allies entered into Triggers" );
							}
						}
					}

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

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

						if ( Map.CP_build == 0 )
						{
							SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_CP" );
						}

						Util.MapDebugPrint( "^5Engineer entered into Trigger 1" );
					}
				}
			}
		},
		OnExit = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				if (Map.DoorControlDestroyed == 0 )
				{
					Map.AlliesInTrigger1 -= 1;

					Util.MapDebugPrint( "^5Allies exited from Trigger 1" );

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

						if ( Map.EngInTrigger1 == 0 and Map.EngInTrigger2 == 0 and Map.EngInTrigger3 == 0 )
						{
							if ( Map.BlastDoorOpen == 0 )
							{
								if ( Map.Allied_CP_Dyno > 0 )
								{
									SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_CP_.*" );
								}

								if ( Map.CP_build == 0 )
								{
									SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_CP" );
								}
							}
						}

						Util.MapDebugPrint( "^5Engineer exited from Trigger 1" );
					}

					if ( Map.AlliesInTrigger1 == 0 and Map.AlliesInTrigger2 == 0 and Map.AlliesInTrigger3 == 0 )
					{
						if ( Map.Docs_taken == 0 and Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
						{
							SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_documents" );

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

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

							Util.MapDebugPrint( "^5Bunker is clear !" );
						}
					}
				}
			}
		},
	},

	Trigger_2 =
	{
		Name = "trigger_2",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				if (Map.DoorControlDestroyed == 0 )
				{
					Map.AlliesInTrigger2 += 1;

					foreach ( id and bot in BotTable )
					{
						if ( bot.GetTeam() == TEAM.AXIS )
						{
							bot.SayTeam("Allies are coming for documents!");
							break;
						}
					}

					Util.MapDebugPrint( "^5Allies entered into Trigger 2" );

					if ( Map.Docs_taken == 0 )
					{
						SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_documents" );

						if ( Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
						{
							if ( Map.AlliesInTrigger1 < 3 or Map.AlliesInTrigger2 < 3 or Map.AlliesInTrigger3 < 3 )
							{
								SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

								SetAvailableMapGoals( TEAM.AXIS, true, {
									"DEFEND_Axis_AtDocs_10",
									"DEFEND_Axis_AtDocs_13",
									".*_Axis_DoorControls_.*",
								});

								Util.MapDebugPrint( "^5<3 Allies entered into Triggers" );
							}
							else
							{
								SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

								SetAvailableMapGoals( TEAM.AXIS, true, {
									"DEFEND_Axis_AtDocs_10",
									"DEFEND_Axis_AtDocs_13",
									"DEFEND_Axis_AtDocs_14",
									".*_Axis_DoorControls_.*",
								});

								Util.MapDebugPrint( "^5>2 Allies entered into Triggers" );
							}
						}
					}

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

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

						if ( Map.CP_build == 0 )
						{
							SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_CP" );
						}

						Util.MapDebugPrint( "^5Engineer entered into Trigger 2" );
					}
				}
			}
		},
		OnExit = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				if (Map.DoorControlDestroyed == 0 )
				{
					Map.AlliesInTrigger2 -= 1;

					Util.MapDebugPrint( "^5Allies exited from Trigger 2" );

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

						if ( Map.EngInTrigger1 == 0 and Map.EngInTrigger2 == 0 and Map.EngInTrigger3 == 0 )
						{
							if ( Map.BlastDoorOpen == 0 )
							{
								if ( Map.Allied_CP_Dyno > 0 )
								{
									SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_CP_.*" );
								}

								if ( Map.CP_build == 0 )
								{
									SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_CP" );
								}
							}
						}

						Util.MapDebugPrint( "^5Engineer exited from Trigger 2" );
					}

					if ( Map.AlliesInTrigger1 == 0 and Map.AlliesInTrigger2 == 0 and Map.AlliesInTrigger3 == 0 )
					{
						if ( Map.Docs_taken == 0 and Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
						{
							SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_documents" );

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

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

							Util.MapDebugPrint( "^5Bunker is clear !" );
						}
					}
				}
			}
		},
	},

	Trigger_3 =
	{
		Name = "trigger_3",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				if (Map.DoorControlDestroyed == 0 )
				{
					Map.AlliesInTrigger3 += 1;

					foreach ( id and bot in BotTable )
					{
						if ( bot.GetTeam() == TEAM.AXIS )
						{
							bot.SayTeam("Allies are coming for documents!");
							break;
						}
					}

					Util.MapDebugPrint( "^5Allies entered into Trigger 3" );

					if ( Map.Docs_taken == 0 )
					{
						SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_documents" );

						if ( Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
						{
							if ( Map.AlliesInTrigger1 < 3 or Map.AlliesInTrigger2 < 3 or Map.AlliesInTrigger3 < 3 )
							{
								SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

								SetAvailableMapGoals( TEAM.AXIS, true, {
									"DEFEND_Axis_AtDocs_10",
									"DEFEND_Axis_AtDocs_13",
									".*_Axis_DoorControls_.*",
								});

								Util.MapDebugPrint( "^5<3 Allies entered into Triggers" );
							}
							else
							{
								SetAvailableMapGoals( TEAM.AXIS, false, ".*_Axis_DoorControls_.*" );

								SetAvailableMapGoals( TEAM.AXIS, true, {
									"DEFEND_Axis_AtDocs_10",
									"DEFEND_Axis_AtDocs_13",
									"DEFEND_Axis_AtDocs_14",
									".*_Axis_DoorControls_.*",
								});

								Util.MapDebugPrint( "^5>2 Allies entered into Triggers" );
							}
						}
					}

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

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

						if ( Map.CP_build == 0 )
						{
							SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_CP" );
						}

						Util.MapDebugPrint( "^5Engineer entered into Trigger 3" );
					}
				}
			}
		},
		OnExit = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				if (Map.DoorControlDestroyed == 0 )
				{
					Map.AlliesInTrigger3 -= 1;

					Util.MapDebugPrint( "^5Allies exited from Trigger 3" );

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

						if ( Map.EngInTrigger1 == 0 and Map.EngInTrigger2 == 0 and Map.EngInTrigger3 == 0 )
						{
							if ( Map.BlastDoorOpen == 0 )
							{
								if ( Map.Allied_CP_Dyno > 0 )
								{
									SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Allied_CP_.*" );
								}

								if ( Map.CP_build == 0 )
								{
									SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_CP" );
								}
							}
						}

						Util.MapDebugPrint( "^5Engineer exited from Trigger 3" );
					}

					if ( Map.AlliesInTrigger1 == 0 and Map.AlliesInTrigger2 == 0 and Map.AlliesInTrigger3 == 0 )
					{
						if ( Map.Docs_taken == 0 and Map.BlastDoorOpen == 0 and Map.CP_build == 0 )
						{
							SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_documents" );

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

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

							Util.MapDebugPrint( "^5Bunker is clear !" );
						}
					}
				}
			}
		},
	},

	Trigger_4 =
	{
		Name = "trigger_4",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.ALLIES )
			{
				foreach ( id and bot in BotTable )
				{
					if ( bot.GetTeam() == TEAM.AXIS )
					{
						bot.SayTeam("Allies are coming for documents!");
						break;
					}
				}
			}
		},
	},
};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_CP_Built );
	OnTrigger( "Planted at the Allied CP.", Map.Allied_CP_Planted );
	OnTrigger( "Planted at the Door controls.", Map.Door_controls_Planted );
	OnTrigger( "Defused at the Allied CP.", Map.Allied_CP_Defused );
	OnTrigger( "Defused at the Door controls.", Map.Door_controls_Defused );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_CP_Destroyed );
	OnTrigger( "The Doors are opening!!", Map.Door_controls_Destroyed );
	OnTrigger( "Allies have stolen the documents!", Map.documents_Taken );
	OnTrigger( "the documents dropped.", Map.documents_Dropped );
	OnTrigger( "Flag returned documents!", Map.documents_Returned );
	OnTrigger( "Allied team has transmitted the documents!", Map.documents_Secured );
	OnTrigger( "Main blast door opening!", Map.Door_Open );
	OnTrigger( "Main blast door closing!", Map.Door_Close );
	OnTrigger( "GRENADE_PipeBar_1 Exploded.", Map.PipeBar_1_Exploded );
	OnTrigger( "GRENADE_PipeBar_2 Exploded.", Map.PipeBar_2_Exploded );
	OnTrigger( "GRENADE_window Exploded.", Map.Window_Exploded );

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

	WeaponTable.SetWeaponAvailability(CLASS.SOLDIER, { WEAPON.MP40, WEAPON.THOMPSON }, true);
	WeaponTable.SetWeaponAvailability(CLASS.SOLDIER, WEAPON.PANZERFAUST, false);
	WeaponTable.SetWeaponAvailability(CLASS.ENGINEER, { WEAPON.KAR98, WEAPON.CARBINE }, false);

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"DEFEND_Axis_DoorControls_.*",
		"CALLARTILLERY_Axis_DoorControls_2",
		"ARTILLERY_S_Axis_DoorControls_3",
		"MOBILEMG42_Axis_DoorControls_1",
		"ROUTE_.*",
		"SMOKEBOMB_Axis_DoorControls_18",
	});
	//SetAvailableMapGoals( TEAM.AXIS, true, "AMMOCAB_hutammocab" );
	//SetAvailableMapGoals( TEAM.AXIS, true, "HEALTHCAB_huthpcab" );

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"ROUTE_.*",
		"AMMOCAB_hutammocab",
		"HEALTHCAB_huthpcab",
		"PLANT_Door_controls",
		"ATTACK_Allied_DoorControls_.*",
		"MOUNTMG42_359",
		"REPAIRMG42_359",
		"SMOKEBOMB_Allied_DoorControls_14",
	});

	SetGoalPriority( "ATTACK_Allied_AtTransmitter_.*", 0.6, TEAM.ALLIES, 0 );
	SetGoalPriority( "SWITCH_.*", 0.81, TEAM.ALLIES, CLASS.SOLDIER );
	SetGoalPriority( "MOUNTMG42_359", 0.5, TEAM.ALLIES, 0 );
	SetGoalPriority( "MOUNTMG42_359", 0.7, TEAM.ALLIES, CLASS.SOLDIER );

	SetGoalPriority( "PLANT_Allied_CP", 0.3, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "DEFEND_Axis_DoorControls_.*", 0.55, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "DEFEND_Axis_AtDocs_.*", 0.55, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtDocs_10", 0.6, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtDocs_11", 0.6, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtDocs_12", 0.6, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtDocs_13", 0.6, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtDocs_14", 0.6, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtDocs_.*", 0.4, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "DEFEND_Axis_AtTransmitter_.*", 0.65, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtTransmitter_1", 0.7, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtTransmitter_2", 0.7, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtTransmitter_3", 0.7, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtTransmitter_4", 0.7, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtTransmitter_5", 0.7, TEAM.AXIS, 0 );
	SetGoalPriority( "DEFEND_Axis_AtTransmitter_.*", 0.45, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "SWITCH_.*", 0.5, TEAM.AXIS, 0 );
	SetGoalPriority( "SWITCH_.*", 0.81, TEAM.AXIS, CLASS.SOLDIER );
	SetGoalPriority( "SWITCH_.*", 0.81, TEAM.AXIS, CLASS.FIELDOPS );
	SetGoalPriority( "SWITCH_.*", 0.82, TEAM.AXIS, CLASS.COVERTOPS );
	//SetGoalPriority( "SWITCH_.*", 0.47, TEAM.AXIS, CLASS.ENGINEER );

	// Max users per goal
	Util.SetMaxUsers( 1, "BUILD_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "SWITCH_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=300, MaxCampTime=360} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=300, MaxCampTime=360} );

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

	//trigger1 = OnTriggerRegion(AABB(-568.236,-3568.875,-358.875,1022.955,-2450.693,123.125), Map.Trigger_1);
	trigger1 = OnTriggerRegion(AABB(-568.875,-3752.875,-358.875,1026.217,-2445.605,143.148), Map.Trigger_1);
	Map.iw1 = OnTriggerRegion(AABB(-568.875,-3752.875,-358.875,1026.217,-2445.605,143.148), RegionTrigger.IntrusionWarning);
	//trigger2 = OnTriggerRegion(AABB(-1974.897,-2972.875,75.125,1127.879,1717.982,155.125), Map.Trigger_2);
	trigger2 = OnTriggerRegion(AABB(-2014.874,-2479.063,37.125,1136.875,1748.874,179.126), Map.Trigger_2);
	Map.iw2 = OnTriggerRegion(AABB(-2014.874,-2479.063,37.125,1136.875,1748.874,179.126), RegionTrigger.IntrusionWarning);
	trigger3 = OnTriggerRegion(AABB(-192.875,-665.772,-118.875,1133.716,1724.260,95.125), Map.Trigger_3);
	Map.iw3 = OnTriggerRegion(AABB(-192.875,-665.772,-118.875,1133.716,1724.260,95.125), RegionTrigger.IntrusionWarning);

	BD1 = OnTriggerRegion(AABB(-5.987,944.463,49.125,186.244,1066.641,139.125), RegionTrigger.BreakableDistance);

	//Util.UpdateSwitchData();

	MapRoutes =
	{
		PLANT_Door_controls =
		{
			ROUTE_Allied_FirstSpawn =
			{
				ROUTE_Allied_FirstSpawn_Left =
				{
					ROUTE_Meadow =
					{
						ROUTE_MainAccess =
						{
							ROUTE_FrontPlant =
							{
								Weight = 2,
							},
							ROUTE_SideWallPlant =
							{

							},
						},
					},
				},
				ROUTE_Allied_FirstSpawn_Right =
				{
					Weight = 2,
					ROUTE_Pipe =
					{
						ROUTE_FrontPlant =
						{

						},
						ROUTE_SideWallPlant =
						{
							Weight = 2,
						},
					},
					ROUTE_Hatch =
					{
						Weight = 3,
						ROUTE_FrontPlant =
						{

						},
						ROUTE_SideWallPlant =
						{
							Weight = 2,
						},
					},
					ROUTE_BrokenWall =
					{
						Weight = 2,
						ROUTE_MainAccess =
						{
							ROUTE_FrontPlant =
							{
								Weight = 2,
							},
							ROUTE_SideWallPlant =
							{

							},
						},
					},
				},
			},
		},
		PLANT_Allied_CP =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_AxisControlsDoor =
				{
					ROUTE_StairsToCP =
					{
						ROUTE_DoorToCP =
						{

						},
					},
				},
			},
		},
		SWITCH_BlastDoorSwitch1 =
		{
			ROUTE_AxisSpawn =
			{
				ROUTE_AxisControlsDoor =
				{

				},
			},
		},
		FLAG_documents =
		{
			ROUTE_Allied_FirstSpawn =
			{
				ROUTE_SideGate =
				{
					ROUTE_SideGate_Right =
					{
						Weight = 2,
						ROUTE_LeftDocsStairs =
						{
							ROUTE_Docs =
							{

							},
						},
						ROUTE_RightDocsStairs =
						{
							ROUTE_Docs =
							{

							},
						},
					},
					ROUTE_SideGate_Left =
					{
						ROUTE_Bridge =
						{
							ROUTE_Docs =
							{

							},
						},
					},
				},
			},
			ROUTE_Allied_CPSpawn =
			{
				ROUTE_Bridge =
				{
					ROUTE_Docs =
					{

					},
				},
				ROUTE_NearSideGate =
				{
					ROUTE_SideGate_Right =
					{
						ROUTE_LeftDocsStairs =
						{
							ROUTE_Docs =
							{

							},
						},
						ROUTE_RightDocsStairs =
						{
							ROUTE_Docs =
							{

							},
						},
					},
				},
			},
		},
		CAPPOINT_Transmitter =
		{
			ROUTE_Flag_Docs =
			{
				ROUTE_Bridge =
				{
					Weight = 3,
					ROUTE_DoorToCP =
					{
						ROUTE_StairsToCP =
						{

						},
					},
				},
				ROUTE_LeftDocsStairs =
				{
					ROUTE_SideGate_Right =
					{
						ROUTE_BrokenWall =
						{
							Weight = 2,
							ROUTE_MainAccess =
							{
								ROUTE_MainGate =
								{

								},
							},
						},
						ROUTE_SideGate =
						{
							ROUTE_Allied_FirstSpawn_Left =
							{
								ROUTE_NearMG42 =
								{
									ROUTE_Blast_Door =
									{

									},
								},
							},
						},
						ROUTE_NearSideGate =
						{
							ROUTE_DoorToCP =
							{
								ROUTE_StairsToCP =
								{

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

	//copy some routes
	MapRoutes.ATTACK_Allied_DoorControls_1 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_2 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_3 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_4 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_5 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_6 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_7 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_8 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_9 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_10 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_11 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_12 = MapRoutes.PLANT_Door_controls;
	MapRoutes.ATTACK_Allied_DoorControls_13 = MapRoutes.PLANT_Door_controls;
	MapRoutes.SMOKEBOMB_Allied_DoorControls_14 = MapRoutes.PLANT_Door_controls;
	MapRoutes.SWITCH_BlastDoorSwitch2 = MapRoutes.SWITCH_BlastDoorSwitch1;

	Util.Routes(MapRoutes);

	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"ROUTE_NearMG42",
		"ROUTE_Blast_Door",
		"ROUTE_MainGate",
	});

	Util.MapDebugPrint( "^5Omni-bot map script for " + GetMapName() + " executed." );
};

global OnBotJoin = function( bot )
{
	if ( Map.CP_build == 1 )
	{
		Util.ChangeSpawn( TEAM.ALLIES, 2 );
	}
	else
	{
		Util.ChangeSpawn( TEAM.ALLIES, 1 );
	}

	bot.TargetBreakableDist = 250.0;
};
