//==========================================================================================
//
//	duplex_towers.gm
//
//	Who      	When		What
//------------------------------------------------------------------------------------------
//	Qiki		27 May 2012	Initial Script
//	Native12	23.09.2012	Ready to test
//	Native12	25.10.2012	Finished
//
//	Associated files:	duplex_towers.way	20.09.2012	183 kB (188 019 b)
//				duplex_towers_goals.gm	20.9.2012	54,2 kB (55 578 b)
//==========================================================================================
//	ToDo:	Maybe routes - but not necessary

global Map =
{
	Debug = 0, // please set to zero before distributing your script

	Centre_Buildings_Dyno = 0,
	Command_Post_Dyno = 0,
	East_Fortifications_Dyno = 0,
	East_Ramp_Dyno = 0,
	East_Tower_Dyno = 0,
	Main_Gate_Dyno = 0,
	North_East_Sniper_Tower_Dyno = 0,
	South_East_Defence_Dyno = 0,
	South_Ramp_Dyno = 0,
	South_West_Sniper_Tower_Dyno = 0,
	Tunnel_Roof_Dyno = 0,
	West_Defence_Dyno = 0,
	West_Ramp_Dyno = 0,
	West_Tower_Dyno = 0,

	door_closed = true,
	EastTowerDestroyed = false,
	WestTowerDestroyed = false,
	Ally_CP = false,
	Axis_Eng_Inside = 0,
	EastRamp_built = false,
	MainGate_built = true,
	SouthRamp_Built = false,
	TunnelRoof_Built = true,
	WestRamp_Built = false,
	RouteEnabled = false,
	Axis_Eng_Inside_ET = 0,
	Axis_Eng_Inside_WT = 0,

	e_a = 0,
	e_b = 0,
	w_a = 0,
	w_b = 0,

	Roles =
	{
		ALLIES =
		{
			AllBots = true, // each bot is considered for a role
			DEFENDER =	//DEFEND south ramp
			{
				spawnpt = 3,
				numbots = 4,
				crucialClass = CLASS.ENGINEER,
			},
			DEFENDER1 =	//DEFEND east ramp
			{
				spawnpt = 3,
				numbots = 4,
				crucialClass = CLASS.COVERTOPS,
			},
			DEFENDER2 =	//DEFEND west ramp
			{
				spawnpt = 4,
				numbots = 4,
				crucialClass = CLASS.COVERTOPS,
			},
			DEFENDER3 =	//DEFEND tunnel roof & main gate
			{
				spawnpt = 4,
				numbots = 4,
				crucialClass = CLASS.ENGINEER,
			},
		},
		AXIS =
		{
			AllBots = true, // each bot is considered for a role
			ATTACKER =
			{
				spawnpt = 1,
				numbots = 4,
				crucialClass = CLASS.ENGINEER,
			},
			ATTACKER1 =
			{
				spawnpt = 1,
				numbots = 4,
				crucialClass = CLASS.COVERTOPS,
			},
			ATTACKER2 =
			{
				spawnpt = 2,
				numbots = 4,
				crucialClass = CLASS.ENGINEER,
			},
			ATTACKER3 =
			{
				spawnpt = 2,
				numbots = 4,
				crucialClass = CLASS.ENGINEER,
			},
		},
	},

	Navigation =
	{
		//	/bot waypoint_setproperty paththrough Navigation_PT:allied_door
		allied_door =
		{
			navigate = function(_this)
			{
				wpTable = {};
				Wp.GetWaypointByName("Allied_door", wpTable);
				if ( _this.Goto(wpTable.position) == EVENT.PATH_SUCCESS )
				{
					if ( !Map.door_closed )
					{
						Util.MapDebugPrint( "^5Door is open => do nothing" );
						_this.AddAimRequest(Priority.High, "facing", wpTable.facing);
						sleep(0.8);
						_this.Bot.HoldButton( BTN.WALK, 1.5 );
						_this.Bot.HoldButton( BTN.FORWARD, 1.5 );
						sleep(1.5);
						_this.Bot.ReleaseButton(BTN.WALK);
						_this.Bot.ReleaseButton(BTN.FORWARD);
						_this.ReleaseAimRequest();
					}
					else
					{
						Util.MapDebugPrint( "^5Door is closed => open it" );
						sleep(1);
						_this.AddAimRequest(Priority.High, "facing", wpTable.facing);
						sleep(0.4);
						Map.door_closed = false;
						_this.Bot.HoldButton( BTN.USE, 0.5 );
						sleep(1);
						_this.Bot.HoldButton( BTN.WALK, 1.5 );
						_this.Bot.HoldButton( BTN.FORWARD, 1.5 );
						sleep(1.2);
						Map.door_closed = true;
						Util.MapDebugPrint( "^5Door is closing => wait" );
						sleep(0.3);
						_this.Bot.ReleaseButton(BTN.WALK);
						_this.Bot.ReleaseButton(BTN.FORWARD);
						_this.ReleaseAimRequest();
					}
				}
			},
		},
	},

	Centre_Buildings_Built = function( trigger )
	{

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

	Centre_Buildings_Planted = function( trigger )
	{

		Map.Centre_Buildings_Dyno += 1;

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

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

	Centre_Buildings_Defused = function( trigger )
	{

		Map.Centre_Buildings_Dyno -= 1;

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

	Centre_Buildings_Destroyed = function( trigger )
	{

		Map.Centre_Buildings_Dyno = 0;

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

	Allied_Command_Post_Built = function( trigger )
	{

		Map.Ally_CP = true;

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

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

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

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

	Axis_Command_Post_Built = function( trigger )
	{

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

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

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

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

	Command_Post_Planted = function( trigger )
	{

		Map.Command_Post_Dyno += 1;

		if ( Map.Ally_CP )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFUSE_Command_Post_.*" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Command_Post_.*" );
		}

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

	Command_Post_Defused = function( trigger )
	{

		Map.Command_Post_Dyno -= 1;

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

	Allied_Command_Post_Destroyed = function( trigger )
	{

		Map.Command_Post_Dyno = 0;

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

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

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

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

	Axis_Command_Post_Destroyed = function( trigger )
	{

		Map.Command_Post_Dyno = 0;

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

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

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

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

	East_Fortifications_Built = function( trigger )
	{

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

	East_Fortifications_Planted = function( trigger )
	{

		Map.East_Fortifications_Dyno += 1;

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

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

	East_Fortifications_Defused = function( trigger )
	{

		Map.East_Fortifications_Dyno -= 1;

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

	East_Fortifications_Destroyed = function( trigger )
	{

		Map.East_Fortifications_Dyno = 0;

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

	East_Ramp_Built = function( trigger )
	{

		Map.EastRamp_built = true;

		Map.RouteEnabled = true;
		//enable route

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

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

		if ( Map.Axis_Eng_Inside == 0 )
		{
			if ( !Map.WestTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_West_tower_1",
					"DEFEND_Allied_West_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_West_Tower",
					"ATTACK_Axis_West_tower_1",
					"ATTACK_Axis_West_tower_4",
				});
			}
			if ( !Map.EastTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_East_tower_1",
					"DEFEND_Allied_East_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_East_Tower",
					"ATTACK_Axis_East_tower_1",
					"ATTACK_Axis_East_tower_4",
				});
			}
		}

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

	East_Ramp_Planted = function( trigger )
	{

		Map.East_Ramp_Dyno += 1;

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

	East_Ramp_Defused = function( trigger )
	{

		Map.East_Ramp_Dyno -= 1;

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

	East_Ramp_Destroyed = function( trigger )
	{

		Map.EastRamp_built = false;
		//disable route

		if ( Map.MainGate_built and !Map.SouthRamp_Built and Map.TunnelRoof_Built and !Map.WestRamp_Built )
		{
			Map.RouteEnabled = false;

			if ( Map.Axis_Eng_Inside == 0 )
			{
				if ( !Map.WestTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_West_Tower",
						"ATTACK_Axis_West_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_West_tower_.*" );
				}
				if ( !Map.EastTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_East_Tower",
						"ATTACK_Axis_East_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_East_tower_.*" );
				}
			}
		}

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

		Map.East_Ramp_Dyno = 0;

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

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

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

	Main_Gate_Built = function( trigger )
	{

		Map.MainGate_built = true;
		//disable route

		if ( !Map.EastRamp_built and !Map.SouthRamp_Built and Map.TunnelRoof_Built and !Map.WestRamp_Built )
		{
			Map.RouteEnabled = false;

			if ( Map.Axis_Eng_Inside == 0 )
			{
				if ( !Map.WestTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_West_Tower",
						"ATTACK_Axis_West_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_West_tower_.*" );
				}
				if ( !Map.EastTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_East_Tower",
						"ATTACK_Axis_East_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_East_tower_.*" );
				}
			}
		}

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

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

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

	Main_Gate_Planted = function( trigger )
	{

		Map.Main_Gate_Dyno += 1;

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

	Main_Gate_Defused = function( trigger )
	{

		Map.Main_Gate_Dyno -= 1;

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

	Main_Gate_Destroyed = function( trigger )
	{

		Map.MainGate_built = false;

		Map.RouteEnabled = true;
		//enable route

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

		Map.Main_Gate_Dyno = 0;

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

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

		if ( Map.Axis_Eng_Inside == 0 )
		{
			if ( !Map.WestTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_West_tower_1",
					"DEFEND_Allied_West_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_West_Tower",
					"ATTACK_Axis_West_tower_1",
					"ATTACK_Axis_West_tower_4",
				});
			}
			if ( !Map.EastTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_East_tower_1",
					"DEFEND_Allied_East_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_East_Tower",
					"ATTACK_Axis_East_tower_1",
					"ATTACK_Axis_East_tower_4",
				});
			}
		}

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

	North_East_Sniper_Tower_Built = function( trigger )
	{

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

	North_East_Sniper_Tower_Planted = function( trigger )
	{

		Map.North_East_Sniper_Tower_Dyno += 1;

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

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

	North_East_Sniper_Tower_Defused = function( trigger )
	{

		Map.North_East_Sniper_Tower_Dyno -= 1;

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

	North_East_Sniper_Tower_Destroyed = function( trigger )
	{

		Map.North_East_Sniper_Tower_Dyno = 0;

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

	South_East_Defence_Built = function( trigger )
	{

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

	South_East_Defence_Planted = function( trigger )
	{

		Map.South_East_Defence_Dyno += 1;

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

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

	South_East_Defence_Defused = function( trigger )
	{

		Map.South_East_Defence_Dyno -= 1;

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

	South_East_Defence_Destroyed = function( trigger )
	{

		Map.South_East_Defence_Dyno = 0;

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

	South_Ramp_Built = function( trigger )
	{

		Map.SouthRamp_Built = true;

		Map.RouteEnabled = true;
		//enable route

		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_South_ramp_4" );
		SetGoalPriority( "DEFEND_Allied_South_ramp_4", 0.519, TEAM.ALLIES, 0 );

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

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"SMOKEBOMB_Allied_SouthRampBuilt",
			"PLANT_South_Ramp",
		});

		if  ( !Map.WestTowerDestroyed )
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Allied_WestTower_SouthRampBuilt" );
		}
		else
		{
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Allied_EastTower_SouthRampBuilt" );
		}

		if ( Map.Axis_Eng_Inside == 0 )
		{
			if ( !Map.WestTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_West_tower_1",
					"DEFEND_Allied_West_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_West_Tower",
					"ATTACK_Axis_West_tower_1",
					"ATTACK_Axis_West_tower_4",
				});
			}
			if ( !Map.EastTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_East_tower_1",
					"DEFEND_Allied_East_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_East_Tower",
					"ATTACK_Axis_East_tower_1",
					"ATTACK_Axis_East_tower_4",
				});
			}
		}
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Allied_South_ramp_4" );

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

	South_Ramp_Planted = function( trigger )
	{

		Map.South_Ramp_Dyno += 1;

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

	South_Ramp_Defused = function( trigger )
	{

		Map.South_Ramp_Dyno -= 1;

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

	South_Ramp_Destroyed = function( trigger )
	{

		Map.SouthRamp_Built = false;
		//disable route

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SMOKEBOMB_Allied_SouthRampBuilt",
			"DEFEND_Allied_South_ramp_4",
		});
		SetGoalPriority( "DEFEND_Allied_South_ramp_4", 0.5, TEAM.ALLIES, 0 );

		if ( Map.MainGate_built and !Map.EastRamp_built and Map.TunnelRoof_Built and !Map.WestRamp_Built )
		{
			Map.RouteEnabled = false;

			if ( Map.Axis_Eng_Inside == 0 )
			{
				if ( !Map.WestTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_West_Tower",
						"ATTACK_Axis_West_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_West_tower_.*" );
				}
				if ( !Map.EastTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_East_Tower",
						"ATTACK_Axis_East_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_East_tower_.*" );
				}
			}
		}

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

		Map.South_Ramp_Dyno = 0;

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANT_South_Ramp",
			"DEFEND_Allied_WestTower_SouthRampBuilt",
			"DEFEND_Allied_EastTower_SouthRampBuilt",
		});

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

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

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

	South_West_Sniper_Tower_Built = function( trigger )
	{

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

	South_West_Sniper_Tower_Planted = function( trigger )
	{

		Map.South_West_Sniper_Tower_Dyno += 1;

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

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

	South_West_Sniper_Tower_Defused = function( trigger )
	{

		Map.South_West_Sniper_Tower_Dyno -= 1;

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

	South_West_Sniper_Tower_Destroyed = function( trigger )
	{

		Map.South_West_Sniper_Tower_Dyno = 0;

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

	Tunnel_Roof_Built = function( trigger )
	{

		Map.TunnelRoof_Built = true;
		//disable route

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

		if ( !Map.EastRamp_built and !Map.SouthRamp_Built and Map.MainGate_built and !Map.WestRamp_Built )
		{
			Map.RouteEnabled = false;

			if ( Map.Axis_Eng_Inside == 0 )
			{
				if ( !Map.WestTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_West_Tower",
						"ATTACK_Axis_West_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_West_tower_.*" );
				}
				if ( !Map.EastTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_East_Tower",
						"ATTACK_Axis_East_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_East_tower_.*" );
				}
			}
		}

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

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

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

	Tunnel_Roof_Planted = function( trigger )
	{

		Map.Tunnel_Roof_Dyno += 1;

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

	Tunnel_Roof_Defused = function( trigger )
	{

		Map.Tunnel_Roof_Dyno -= 1;

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

	Tunnel_Roof_Destroyed = function( trigger )
	{

		Map.TunnelRoof_Built = false;

		Map.RouteEnabled = true;
		//enable route

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

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

		Map.Tunnel_Roof_Dyno = 0;

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

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

		if ( Map.Axis_Eng_Inside == 0 )
		{
			if ( !Map.WestTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_West_tower_1",
					"DEFEND_Allied_West_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_West_Tower",
					"ATTACK_Axis_West_tower_1",
					"ATTACK_Axis_West_tower_4",
				});
			}
			if ( !Map.EastTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_East_tower_1",
					"DEFEND_Allied_East_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_East_Tower",
					"ATTACK_Axis_East_tower_1",
					"ATTACK_Axis_East_tower_4",
				});
			}
		}

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

	West_Defence_Built = function( trigger )
	{

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

	West_Defence_Planted = function( trigger )
	{

		Map.West_Defence_Dyno += 1;

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

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

	West_Defence_Defused = function( trigger )
	{

		Map.West_Defence_Dyno -= 1;

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

	West_Defence_Destroyed = function( trigger )
	{

		Map.West_Defence_Dyno = 0;

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

	West_Ramp_Built = function( trigger )
	{

		Map.WestRamp_Built = true;

		Map.RouteEnabled = true;
		//enable route

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

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

		if ( Map.Axis_Eng_Inside == 0 )
		{
			if ( !Map.WestTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_West_tower_1",
					"DEFEND_Allied_West_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_West_Tower",
					"ATTACK_Axis_West_tower_1",
					"ATTACK_Axis_West_tower_4",
				});
			}
			if ( !Map.EastTowerDestroyed )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, {
					"DEFEND_Allied_East_tower_1",
					"DEFEND_Allied_East_tower_2",
				});

				SetAvailableMapGoals( TEAM.AXIS, true, {
					"PLANT_East_Tower",
					"ATTACK_Axis_East_tower_1",
					"ATTACK_Axis_East_tower_4",
				});
			}
		}

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

	West_Ramp_Planted = function( trigger )
	{

		Map.West_Ramp_Dyno += 1;

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

	West_Ramp_Defused = function( trigger )
	{

		Map.West_Ramp_Dyno -= 1;

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

	West_Ramp_Destroyed = function( trigger )
	{

		Map.WestRamp_Built = false;
		//disable route

		if ( Map.MainGate_built and !Map.EastRamp_built and Map.TunnelRoof_Built and !Map.SouthRamp_Built )
		{
			Map.RouteEnabled = false;

			if ( Map.Axis_Eng_Inside == 0 )
			{
				if ( !Map.WestTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_West_Tower",
						"ATTACK_Axis_West_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_West_tower_.*" );
				}
				if ( !Map.EastTowerDestroyed )
				{
					SetAvailableMapGoals( TEAM.AXIS, false, {
						"PLANT_East_Tower",
						"ATTACK_Axis_East_tower_.*",
					});

					SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_East_tower_.*" );
				}
			}
		}

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

		Map.West_Ramp_Dyno = 0;

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

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

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

	East_Tower_Planted = function( trigger )
	{

		Map.East_Tower_Dyno += 1;

		Util.MapDebugPrint( "^5East_Tower_Planted" );

		Map.e_a += 1;
		Map.e_b = "DEFUSE_East_Tower_"+Map.e_a;

		if ( Map.East_Tower_Dyno == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_EastTowerPlanted_1" );
			Util.SetPositionGoal( "DEFEND_EastTowerPlanted_1", Map.e_b );
			Util.SetGoalOffset( -30, -30, 0, "DEFEND_EastTowerPlanted_1" );
			yield();
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_EastTowerPlanted_1" );
			sleep(27);
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_EastTowerPlanted_1" );
		}
		if ( Map.East_Tower_Dyno == 2 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_EastTowerPlanted_2" );
			Util.SetPositionGoal( "DEFEND_EastTowerPlanted_2", Map.e_b );
			Util.SetGoalOffset( -30, -30, 0, "DEFEND_EastTowerPlanted_2" );
			yield();
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_EastTowerPlanted_2" );
			sleep(27);
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_EastTowerPlanted_2" );
		}

		SetGoalRole( "DEFUSE_East_Tower_.*", { ROLE.DEFENDER, ROLE.DEFENDER1, ROLE.DEFENDER2, ROLE.DEFENDER3 } );

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

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

	East_Tower_Defused = function( trigger )
	{

		Map.East_Tower_Dyno -= 1;

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

		if ( Map.West_Tower_Dyno == 0 and Map.East_Tower_Dyno == 0 )
		{
			if ( Map.Main_Gate_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Main_Gate_.*" );
			}

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

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

	East_Tower_Destroyed = function( trigger )
	{

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

		Map.East_Tower_Dyno = 0;

		Map.EastTowerDestroyed = true;

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

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

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_Allied_East_tower_.*",
			"PLANTMINE_East_tower_.*",
			"DEFEND_EastTowerPlanted_.*",
		});

		if ( Map.West_Tower_Dyno == 0 )
		{
			if ( Map.Main_Gate_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Main_Gate_.*" );
			}

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

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

			sleep(1);

			ETUtil.WinningChat( TEAM.AXIS );
			sleep(1.5);
			ETUtil.LosingChat( TEAM.ALLIES );
		}
		else
		{
			ClearGoalRole( "DEFEND_Allied_East_tower_.*", { ROLE.DEFENDER, ROLE.DEFENDER1 } );
			ClearGoalRole( "DEFEND_EastTowerPlanted_.*", { ROLE.DEFENDER, ROLE.DEFENDER1 } );
			yield();
			SetGoalRole( "DEFEND_Allied_West_tower_.*", { ROLE.DEFENDER, ROLE.DEFENDER1, ROLE.DEFENDER2, ROLE.DEFENDER3 } );
			SetGoalRole( "DEFEND_WestTowerPlanted_.*", { ROLE.DEFENDER, ROLE.DEFENDER1, ROLE.DEFENDER2, ROLE.DEFENDER3 } );
		}

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

	West_Tower_Planted = function( trigger )
	{

		Map.West_Tower_Dyno += 1;

		Util.MapDebugPrint( "^5West_Tower_Planted" );

		Map.w_a += 1;
		Map.w_b = "DEFUSE_West_Tower_"+Map.w_a;

		if ( Map.West_Tower_Dyno == 1 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_WestTowerPlanted_1" );
			Util.SetPositionGoal( "DEFEND_WestTowerPlanted_1", Map.w_b );
			Util.SetGoalOffset( -30, -30, 0, "DEFEND_WestTowerPlanted_1" );
			yield();
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_WestTowerPlanted_1" );
			sleep(27);
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_WestTowerPlanted_1" );
		}
		if ( Map.West_Tower_Dyno == 2 )
		{
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_WestTowerPlanted_2" );
			Util.SetPositionGoal( "DEFEND_WestTowerPlanted_2", Map.w_b );
			Util.SetGoalOffset( -30, -30, 0, "DEFEND_WestTowerPlanted_2" );
			yield();
			SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_WestTowerPlanted_2" );
			sleep(27);
			SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_WestTowerPlanted_2" );
		}

		SetGoalRole( "DEFUSE_West_Tower_.*", { ROLE.DEFENDER, ROLE.DEFENDER1, ROLE.DEFENDER2, ROLE.DEFENDER3 } );

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

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

	West_Tower_Defused = function( trigger )
	{

		Map.West_Tower_Dyno -= 1;

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

		if ( Map.West_Tower_Dyno == 0 and Map.East_Tower_Dyno == 0 )
		{
			if ( Map.Main_Gate_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Main_Gate_.*" );
			}

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

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

	West_Tower_Destroyed = function( trigger )
	{

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

		Map.West_Tower_Dyno = 0;

		Map.WestTowerDestroyed = true;

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

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

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_Allied_West_tower_.*",
			"PLANTMINE_West_tower_.*",
			"DEFEND_Allied_WestTower_SouthRampBuilt",
			"DEFEND_WestTowerPlanted_.*",
		});

		if ( Map.East_Tower_Dyno == 0 )
		{
			if ( Map.Main_Gate_Dyno > 0 )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "DEFUSE_Main_Gate_.*" );
			}

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

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

			sleep(1);

			ETUtil.WinningChat( TEAM.AXIS );
			sleep(1.5);
			ETUtil.LosingChat( TEAM.ALLIES );
		}
		else
		{
			ClearGoalRole( "DEFEND_Allied_West_tower_.*", { ROLE.DEFENDER2, ROLE.DEFENDER3 } );
			ClearGoalRole( "DEFEND_WestTowerPlanted_.*", { ROLE.DEFENDER2, ROLE.DEFENDER3 } );
			yield();
			SetGoalRole( "DEFEND_Allied_East_tower_.*", { ROLE.DEFENDER, ROLE.DEFENDER1, ROLE.DEFENDER2, ROLE.DEFENDER3 } );
			SetGoalRole( "DEFEND_EastTowerPlanted_.*", { ROLE.DEFENDER, ROLE.DEFENDER1, ROLE.DEFENDER2, ROLE.DEFENDER3 } );

			if ( Map.SouthRamp_Built )
			{
				SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Allied_EastTower_SouthRampBuilt" );
			}
		}

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

	Thirty_second = function( trigger )
	{

		Util.MapDebugPrint( "^5Thirty_second" );

		sleep(30);

		if ( !Map.EastTowerDestroyed or !Map.WestTowerDestroyed )
		{
			Util.MapDebugPrint( "^5Allies_Win" );

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

	Axis_Inside =
 	{
 		Name="Axis_Inside",
		TriggerOnClass = CLASS.ANYPLAYER,
		OnEnter = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.AXIS )
			{
				if ( GetEntClass(ent) == CLASS.ENGINEER )
				{
					Map.Axis_Eng_Inside += 1;

					if ( Map.Axis_Eng_Inside == 1 )
					{
						SetAvailableMapGoals( TEAM.ALLIES, false, {
							"DEFEND_Allied_.*_ramp_2",
							"DEFEND_Allied_.*_ramp_3",
							"DEFEND_Allied_.*_ramp_4",
							"DEFEND_Allied_Tunnel_roof_2",
							"DEFEND_Allied_Main_gate_2",
							"DEFEND_Allied_Main_gate_3",
							"DEFEND_Allied_Main_gate_4",
						});

						if ( !Map.WestTowerDestroyed )
						{
							SetAvailableMapGoals( TEAM.ALLIES, true, {
								"DEFEND_WestTowerPlanted_1",
								"DEFEND_WestTowerPlanted_2",
								"DEFEND_Allied_West_tower_.*",
							});

							SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_Axis_West_tower_.*" );
						}
						if ( !Map.EastTowerDestroyed )
						{
							SetAvailableMapGoals( TEAM.ALLIES, true, {
								"DEFEND_EastTowerPlanted_1",
								"DEFEND_EastTowerPlanted_2",
								"DEFEND_Allied_East_tower_.*",
							});

							SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_Axis_East_tower_.*" );
						}

						Util.BotChat( TEAM.ALLIES, "sayteam", "^1Axis engineers are in our base! Defend the towers!", 2 );

						Util.MapDebugPrint( "^5Axis Engs are in base" );
					}
				}
			}
		},
		OnExit = function(ent)
		{
			if( GetEntTeam(ent) == TEAM.AXIS )
			{
				if ( GetEntClass(ent) == CLASS.ENGINEER )
				{
					Map.Axis_Eng_Inside -= 1;

					if ( Map.Axis_Eng_Inside == 0 )
					{
						if ( Map.RouteEnabled )
						{
							if ( !Map.WestTowerDestroyed )
							{
								SetAvailableMapGoals( TEAM.ALLIES, false, {
									"DEFEND_WestTowerPlanted_1",
									"DEFEND_WestTowerPlanted_2",
									"DEFEND_Allied_West_tower_3",
									"DEFEND_Allied_West_tower_4",
									"DEFEND_Allied_West_tower_5",
									"DEFEND_Allied_West_tower_6",
									"DEFEND_Allied_West_tower_7",
								});

								SetAvailableMapGoals( TEAM.AXIS, false, {
									"ATTACK_Axis_West_tower_2",
									"ATTACK_Axis_West_tower_3",
									"ATTACK_Axis_West_tower_5",
									"ATTACK_Axis_West_tower_6",
									"ATTACK_Axis_West_tower_7",
								});
							}
							if ( !Map.EastTowerDestroyed )
							{
								SetAvailableMapGoals( TEAM.ALLIES, false, {
									"DEFEND_EastTowerPlanted_1",
									"DEFEND_EastTowerPlanted_2",
									"DEFEND_Allied_East_tower_3",
									"DEFEND_Allied_East_tower_4",
									"DEFEND_Allied_East_tower_5",
									"DEFEND_Allied_East_tower_6",
									"DEFEND_Allied_East_tower_7",
								});

								SetAvailableMapGoals( TEAM.AXIS, false, {
									"ATTACK_Axis_East_tower_2",
									"ATTACK_Axis_East_tower_3",
									"ATTACK_Axis_East_tower_5",
									"ATTACK_Axis_East_tower_6",
									"ATTACK_Axis_East_tower_7",
								});
							}

							SetAvailableMapGoals( TEAM.ALLIES, true, {
								"DEFEND_Allied_.*_ramp_.*",
								"DEFEND_Allied_Tunnel_roof_.*",
								"DEFEND_Allied_Main_gate_.*",
							});

							Util.MapDebugPrint( "^5Axis Engs are not in base, route enabled" );
						}
						else
						{
							Util.BotChat( TEAM.ALLIES, "sayteam", "^1Axis engineers are not in our base! Base is safe.", 2 );

							if ( !Map.WestTowerDestroyed )
							{
								SetAvailableMapGoals( TEAM.ALLIES, false, {
									"DEFEND_WestTowerPlanted_1",
									"DEFEND_WestTowerPlanted_2",
								});

								SetAvailableMapGoals( TEAM.AXIS, false, {
									"PLANT_West_Tower",
									"ATTACK_Axis_West_tower_.*",
								});

								SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_West_tower_.*" );
							}
							if ( !Map.EastTowerDestroyed )
							{
								SetAvailableMapGoals( TEAM.ALLIES, false, {
									"DEFEND_EastTowerPlanted_1",
									"DEFEND_EastTowerPlanted_2",
								});

								SetAvailableMapGoals( TEAM.AXIS, false, {
									"PLANT_East_Tower",
									"ATTACK_Axis_East_tower_.*",
								});

								SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Allied_East_tower_.*" );
							}

							SetAvailableMapGoals( TEAM.ALLIES, true, {
								"DEFEND_Allied_.*_ramp_.*",
								"DEFEND_Allied_Tunnel_roof_.*",
								"DEFEND_Allied_Main_gate_.*",
							});

							Util.MapDebugPrint( "^5Axis Engs are not in base, route disabled" );
						}
					}
				}
			}
		},
	},
};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "^8The Allies have constructed the Centre Buildings! (It takes a dynamit", Map.Centre_Buildings_Built );
	OnTrigger( "Planted at The Centre Buildings.", Map.Centre_Buildings_Planted );
	OnTrigger( "Defused at The Centre Buildings.", Map.Centre_Buildings_Defused );
	OnTrigger( "^8The Axis have destroyed the Centre Buildings! (It can be rebuilt by t", Map.Centre_Buildings_Destroyed );

	OnTrigger( "^8Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "^8Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Planted at the Command Post.", Map.Command_Post_Planted );
	OnTrigger( "Defused at the Command Post.", Map.Command_Post_Defused );
	OnTrigger( "^8Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "^8Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );

	OnTrigger( "^8The Axis have constructed the East Fortifications! (A dynamite will d", Map.East_Fortifications_Built );
	OnTrigger( "Planted at the East Fortifications.", Map.East_Fortifications_Planted );
	OnTrigger( "Defused at the East Fortifications.", Map.East_Fortifications_Defused );
	OnTrigger( "^8The Allies have destroyed the East Fortifications! (Axis can rebuild ", Map.East_Fortifications_Destroyed );

	OnTrigger( "^8The Axis have constructed the East Ramp! (A satchel will destroy it.)", Map.East_Ramp_Built );
	OnTrigger( "Planted at the East Ramp.", Map.East_Ramp_Planted );
	OnTrigger( "Defused at the East Ramp.", Map.East_Ramp_Defused );
	OnTrigger( "^8The Allies have destroyed the East Ramp! (Axis can rebuild it.)", Map.East_Ramp_Destroyed );

	OnTrigger( "^8The Allies have constructed the Main Gate! (It takes a satchel to des", Map.Main_Gate_Built );
	OnTrigger( "Planted at Main Gate.", Map.Main_Gate_Planted );
	OnTrigger( "Defused at Main Gate.", Map.Main_Gate_Defused );
	OnTrigger( "^8The Axis have destroyed the Main Gate! (It can be rebuilt by the Alli", Map.Main_Gate_Destroyed );

	OnTrigger( "^8The Axis have constructed the North-East Sniper Tower! (A satchel wil", Map.North_East_Sniper_Tower_Built );
	OnTrigger( "Planted at the North-East Sniper Tower.", Map.North_East_Sniper_Tower_Planted );
	OnTrigger( "Defused at the North-East Sniper Tower.", Map.North_East_Sniper_Tower_Defused );
	OnTrigger( "^8The Allies have destroyed the North-East Sniper Tower! (Axis can rebu", Map.North_East_Sniper_Tower_Destroyed );

	OnTrigger( "^8The Allies have constructed the South East Defence! (It takes a dynam", Map.South_East_Defence_Built );
	OnTrigger( "Planted at the South East Defence.", Map.South_East_Defence_Planted );
	OnTrigger( "Defused at the South East Defence.", Map.South_East_Defence_Defused );
	OnTrigger( "^8The Axis have destroyed the South East Defence! (It can be rebuilt by", Map.South_East_Defence_Destroyed );

	OnTrigger( "^8The Axis have constructed the South Ramp! (It takes a dynamite to des", Map.South_Ramp_Built );
	OnTrigger( "Planted at the South Ramp.", Map.South_Ramp_Planted );
	OnTrigger( "Defused at the South Ramp.", Map.South_Ramp_Defused );
	OnTrigger( "^8The Allies have destroyed the South Ramp! (Axis can rebuild it.)", Map.South_Ramp_Destroyed );

	OnTrigger( "^8The Axis have constructed the South-West Sniper Tower! (A satchel wil", Map.South_West_Sniper_Tower_Built );
	OnTrigger( "Planted at the South-West Sniper Tower.", Map.South_West_Sniper_Tower_Planted );
	OnTrigger( "Defused at the South-West Sniper Tower.", Map.South_West_Sniper_Tower_Defused );
	OnTrigger( "^8The Allies have destroyed the South-East Sniper Tower! (Axis can rebu", Map.South_West_Sniper_Tower_Destroyed );

	OnTrigger( "^8The Allies have fixed the Tunnel Roof! (It takes a satchel to destroy", Map.Tunnel_Roof_Built );
	OnTrigger( "Planted at the Tunnel Roof.", Map.Tunnel_Roof_Planted );
	OnTrigger( "Defused at the Tunnel Roof.", Map.Tunnel_Roof_Defused );
	OnTrigger( "^8The Axis have destroyed the Tunnel Roof! (It can be rebuilt by the Al", Map.Tunnel_Roof_Destroyed );

	OnTrigger( "^8The Allies have constructed the West Defence! (It takes a dynamite to", Map.West_Defence_Built );
	OnTrigger( "Planted at the West Defence.", Map.West_Defence_Planted );
	OnTrigger( "Defused at the West Defence.", Map.West_Defence_Defused );
	OnTrigger( "^8The Axis have destroyed the West Defence! (It can be rebuilt by the A", Map.West_Defence_Destroyed );

	OnTrigger( "^8The Axis have constructed the West Ramp! (A satchel will destroy it.)", Map.West_Ramp_Built );
	OnTrigger( "Planted at the West Ramp.", Map.West_Ramp_Planted );
	OnTrigger( "Defused at the West Ramp.", Map.West_Ramp_Defused );
	OnTrigger( "^8The Allies have destroyed the West Ramp! (Axis can rebuild it.)", Map.West_Ramp_Destroyed );

	OnTrigger( "Planted at the East Tower.", Map.East_Tower_Planted );
	OnTrigger( "Defused at the East Tower.", Map.East_Tower_Defused );
	OnTrigger( "^8The Axis have destroyed the East Tower.", Map.East_Tower_Destroyed );

	OnTrigger( "Planted at the West Tower.", Map.West_Tower_Planted );
	OnTrigger( "Defused at the West Tower.", Map.West_Tower_Defused );
	OnTrigger( "^8The Axis have destroyed the West Tower.", Map.West_Tower_Destroyed );

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

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

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"PLANTMINE_.*",
		"BUILD_South_East_Defence",
		"BUILD_Centre_Buildings",
		"BUILD_West_Defence",
		"BUILD_Command_Post",
		".*_Allied_.*_ramp_.*",
		".*_Allied_Tunnel_roof_.*",
		".*_Allied_Main_gate_.*",
	});

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"AMMOCAB_cabinet_supply",
		"HEALTHCAB_cabinet_health",
		"BUILD_.*_Tower",
		"BUILD_East_Fortifications",
		"BUILD_Command_Post",
		"PLANT_Main_Gate",
		"PLANT_Tunnel_Roof",
		"BUILD_.*_Ramp",
		"ATTACK_Axis_.*_ramp_.*",
		"ATTACK_Axis_Main_gate_.*",
		"ATTACK_Axis_Tunnel_roof_.*",
	});

	//Priorities
	SetGoalPriority( "PLANT_North_East_Sniper_Tower", 0.4, TEAM.ALLIES, 0 );
	SetGoalPriority( "PLANT_South_West_Sniper_Tower", 0.4, TEAM.ALLIES, 0 );
	SetGoalPriority( "PLANT_Command_Post", 0.45, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_.*_ramp_1", 0.51, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_.*_ramp_2", 0.505, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_Tunnel_roof_1", 0.51, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_Main_gate_1", 0.51, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_Main_gate_2", 0.505, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_Main_gate_4", 0.505, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_West_tower_4", 0.515, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_West_tower_5", 0.515, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_West_tower_6", 0.515, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_West_tower_7", 0.515, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_West_tower_1", 0.517, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_West_tower_2", 0.517, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_West_tower_3", 0.52, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_WestTower_SouthRampBuilt", 0.525, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_EastTower_SouthRampBuilt", 0.525, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_East_tower_4", 0.515, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_East_tower_5", 0.515, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_East_tower_6", 0.515, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_East_tower_7", 0.515, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_East_tower_1", 0.517, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_East_tower_2", 0.517, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_Allied_East_tower_3", 0.52, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_WestTowerPlanted_.*", 0.805, TEAM.ALLIES, 0 );
	SetGoalPriority( "DEFEND_EastTowerPlanted_.*", 0.805, TEAM.ALLIES, 0 );
	SetGoalPriority( "BUILD_Command_Post", 0.6, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_South_East_Defence", 0.75, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Centre_Buildings", 0.75, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_West_Defence", 0.75, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_East_Ramp", 0.78, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_East_Ramp", 0.82, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_West_Ramp", 0.78, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_West_Ramp", 0.82, TEAM.ALLIES, CLASS.COVERTOPS );

	SetGoalPriority( "PLANT_Centre_Buildings", 0.4, TEAM.AXIS, 0 );
	SetGoalPriority( "PLANT_South_East_Defence", 0.4, TEAM.AXIS, 0 );
	SetGoalPriority( "PLANT_West_Defence", 0.4, TEAM.AXIS, 0 );
	SetGoalPriority( "PLANT_Command_Post", 0.45, TEAM.AXIS, 0 );
	SetGoalPriority( "ATTACK_Axis_East_tower_.*", 0.55, TEAM.AXIS, 0 );
	SetGoalPriority( "ATTACK_Axis_West_tower_.*", 0.55, TEAM.AXIS, 0 );
	SetGoalPriority( "BUILD_Command_Post", 0.6, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_.*_Tower", 0.78, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_East_Fortifications", 0.78, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Command_Post", 0.785, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Main_Gate", 0.8, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Tunnel_Roof", 0.8, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_West_Tower", 0.9, TEAM.AXIS, CLASS.ENGINEER );	//as well as build ramps - or increase?
	SetGoalPriority( "PLANT_East_Tower", 0.9, TEAM.AXIS, CLASS.ENGINEER );	//as well as build ramps - or increase?

	//Allied roles
	SetGoalRole( "PLANTMINE_.*", { ROLE.DEFENDER, ROLE.DEFENDER1, ROLE.DEFENDER2, ROLE.DEFENDER3 } );

	SetGoalRole( "DEFEND_Allied_WestTower_SouthRampBuilt", { ROLE.DEFENDER, ROLE.DEFENDER1, ROLE.DEFENDER2 } );
	SetGoalRole( "DEFEND_Allied_EastTower_SouthRampBuilt", { ROLE.DEFENDER, ROLE.DEFENDER1, ROLE.DEFENDER2 } );

	SetGoalRole( "DEFEND_Allied_East_tower_.*", { ROLE.DEFENDER, ROLE.DEFENDER1 } );
	SetGoalRole( "DEFEND_Allied_West_tower_.*", { ROLE.DEFENDER2, ROLE.DEFENDER3 } );

	SetGoalRole( ".*_Allied_South_ramp_.*", ROLE.DEFENDER );
	SetGoalRole( "BUILD_South_East_Defence", ROLE.DEFENDER );
	SetGoalRole( "BUILD_Centre_Buildings", ROLE.DEFENDER );
	SetGoalRole( "SMOKEBOMB_Allied_SouthRampBuilt", ROLE.DEFENDER );
	SetGoalRole( "PLANT_South_Ramp", ROLE.DEFENDER );
	SetGoalRole( "PLANT_East_Ramp", ROLE.DEFENDER );
	SetGoalRole( "CALLARTILLERY_Allied_South_ramp_.*", ROLE.DEFENDER );

	SetGoalRole( "CALLARTILLERY_Allied_South_ramp_.*", ROLE.DEFENDER1 );
	SetGoalRole( "ARTILLERY_S_Allied_South_ramp_.*", ROLE.DEFENDER1 );
	SetGoalRole( ".*_Allied_East_ramp_.*", ROLE.DEFENDER1 );
	SetGoalRole( "BUILD_South_East_Defence", ROLE.DEFENDER1 );
	SetGoalRole( "BUILD_Centre_Buildings", ROLE.DEFENDER1 );
	SetGoalRole( "SMOKEBOMB_Allied_SouthRampBuilt", ROLE.DEFENDER1 );
	SetGoalRole( "PLANT_South_Ramp", ROLE.DEFENDER1 );
	SetGoalRole( "PLANT_East_Ramp", ROLE.DEFENDER1 );

	SetGoalRole( "CALLARTILLERY_Allied_South_ramp_.*", ROLE.DEFENDER2 );
	SetGoalRole( "ARTILLERY_S_Allied_South_ramp_.*", ROLE.DEFENDER2 );
	SetGoalRole( ".*_Allied_West_ramp_.*", ROLE.DEFENDER2 );
	SetGoalRole( "BUILD_West_Defence", ROLE.DEFENDER2 );
	SetGoalRole( "PLANT_West_Ramp", ROLE.DEFENDER2 );
	SetGoalRole( "SMOKEBOMB_Allied_SouthRampBuilt", ROLE.DEFENDER2 );

	SetGoalRole( ".*_Allied_Tunnel_roof_.*", ROLE.DEFENDER3 );
	SetGoalRole( ".*_Allied_Main_gate_.*", ROLE.DEFENDER3 );
	SetGoalRole( "BUILD_West_Defence", ROLE.DEFENDER3 );
	SetGoalRole( "PLANT_West_Ramp", ROLE.DEFENDER3 );

	//Axis roles
	SetGoalRole( ".*_Axis_East_ramp_.*", ROLE.ATTACKER );
	SetGoalRole( "BUILD_East_Ramp", ROLE.ATTACKER );
	SetGoalRole( "BUILD_East_Fortifications", ROLE.ATTACKER );
	SetGoalRole( "BUILD_North_East_Sniper_Tower", ROLE.ATTACKER );

	SetGoalRole( ".*_Axis_Tunnel_roof_.*", ROLE.ATTACKER1 );
	SetGoalRole( ".*_Axis_Main_gate_.*", ROLE.ATTACKER1 );
	SetGoalRole( "PLANT_Main_Gate", ROLE.ATTACKER1 );
	SetGoalRole( "PLANT_Tunnel_Roof", ROLE.ATTACKER1 );

	SetGoalRole( ".*_Axis_South_ramp_.*", ROLE.ATTACKER2 );
	SetGoalRole( "BUILD_South_Ramp", ROLE.ATTACKER2 );
	SetGoalRole( "BUILD_South_West_Sniper_Tower", ROLE.ATTACKER2 );

	SetGoalRole( ".*_Axis_West_ramp_.*", ROLE.ATTACKER3 );
	SetGoalRole( "BUILD_West_Ramp", ROLE.ATTACKER3 );
	SetGoalRole( "BUILD_Command_Post", ROLE.ATTACKER3 );

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

	Util.AddUseWp( "PLANT_East_Ramp", "plant_east_ramp" );
	Util.AddUseWp( "PLANT_South_Ramp", "plant_south_ramp" );
	Util.AddUseWp( "PLANT_West_Ramp", "plant_west_ramp" );
	Util.AddUseWp( "PLANT_Tunnel_Roof", "plant_tunnel_roof" );
	Util.AddUseWp( "PLANT_East_Tower", "plant_EastTower" );
	Util.AddUseWp( "PLANT_West_Tower", "plant_WestTower" );

	Wp.SetWaypointFlag("west_tower_waypoint", "closed", false);
	Wp.SetWaypointFlag("east_tower_waypoint", "closed", false);
	Wp.SetWaypointFlag("plant_tunnel_roof", "closed", false);

	NP1 = OnTriggerRegion(AABB(-1641.427,735.562,1339.237,-1487.125,944.874,1451.125), RegionTrigger.DisableBotPush);	//Allied door
	DCM1 = OnTriggerRegion(AABB(-1641.427,735.562,1339.237,-1487.125,944.874,1451.125), RegionTrigger.DisableCombatMovement);
	NP2 = OnTriggerRegion(AABB(1118.574,-662.139,1013.973,1760.874,-458.569,1476.477), RegionTrigger.DisableBotPush);	//East ramp
	DCM2 = OnTriggerRegion(AABB(1118.574,-662.139,1013.973,1760.874,-458.569,1476.477), RegionTrigger.DisableCombatMovement);
	NP3 = OnTriggerRegion(AABB(-520.834,-1161.788,1294.016,-327.708,-933.840,1503.917), RegionTrigger.DisableBotPush);	//South ramp
	DCM3 = OnTriggerRegion(AABB(-520.834,-1161.788,1294.016,-327.708,-933.840,1503.917), RegionTrigger.DisableCombatMovement);
	NP4 = OnTriggerRegion(AABB(-1861.869,-149.821,910.715,-1283.399,19.662,1343.722), RegionTrigger.DisableBotPush);	//West ramp
	DCM4 = OnTriggerRegion(AABB(-1861.869,-149.821,910.715,-1283.399,19.662,1343.722), RegionTrigger.DisableCombatMovement);
	NP5 = OnTriggerRegion(AABB(-960.875,-443.727,1725.125,-795.496,-165.816,1843.125), RegionTrigger.DisableBotPush);	//Around defend goal: DEFEND_Allied_WestTower_SouthRampBuilt
	DCM5 = OnTriggerRegion(AABB(-960.875,-443.727,1725.125,-795.496,-165.816,1843.125), RegionTrigger.DisableCombatMovement);
	NP6 = OnTriggerRegion(AABB(597.515,-700.680,2081.125,691.772,-604.344,2163.125), RegionTrigger.DisableBotPush);	//Around defend goal: DEFEND_Allied_EastTower_SouthRampBuilt
	DCM6 = OnTriggerRegion(AABB(597.515,-700.680,2081.125,691.772,-604.344,2163.125), RegionTrigger.DisableCombatMovement);

	axisInside_1 = OnTriggerRegion(AABB(-1591.389,-845.478,1305.125,1220.160,-76.257,2472.508), Map.Axis_Inside);
	axisInside_2 = OnTriggerRegion(AABB(-1346.182,-193.484,1145.937,560.875,824.875,1989.219), Map.Axis_Inside);
	axisInside_3 = OnTriggerRegion(AABB(-1456.871,544.523,1125.753,170.529,1093.282,1786.913), Map.Axis_Inside);
	axisInside_4 = OnTriggerRegion(AABB(-1467.044,-938.472,1345.125,1197.364,-682.870,1773.261), Map.Axis_Inside);
	axisInside_5 = OnTriggerRegion(AABB(379.276,-201.316,1365.300,827.386,73.621,1905.029), Map.Axis_Inside);
	axisInside_6 = OnTriggerRegion(AABB(420.715,-15.930,1359.565,690.140,179.229,1888.196), Map.Axis_Inside);
	axisInside_7 = OnTriggerRegion(AABB(-1968.640,959.333,1122.989,59.915,1348.740,1883.840), Map.Axis_Inside);
	axisInside_8 = OnTriggerRegion(AABB(-1464.190,185.145,1268.425,-1275.278,1072.875,1745.389), Map.Axis_Inside);
	axisInside_9 = OnTriggerRegion(AABB(-1968.875,1207.978,1214.326,-1087.125,1456.875,1760.128), Map.Axis_Inside);
	axisInside_10 = OnTriggerRegion(AABB(-324.745,-1099.642,1323.746,1251.875,-872.260,1806.827), Map.Axis_Inside);
	axisInside_11 = OnTriggerRegion(AABB(63.125,-1215.972,1315.339,1256.744,-995.722,1794.492), Map.Axis_Inside);
	axisInside_12 = OnTriggerRegion(AABB(457.180,-1460.602,1270.263,1328.875,-1121.453,1742.851), Map.Axis_Inside);
	axisInside_13 = OnTriggerRegion(AABB(703.126,-1716.987,1204.203,1328.875,-1311.538,1750.512), Map.Axis_Inside);
	axisInside_14 = OnTriggerRegion(AABB(1093.187,-1856.877,1273.114,1584.855,-1359.125,1772.399), Map.Axis_Inside);
	axisInside_15 = OnTriggerRegion(AABB(1200.413,-1996.389,1329.134,1584.875,-1598.418,1820.791), Map.Axis_Inside);
	axisInside_16 = OnTriggerRegion(AABB(1359.125,-2108.630,1303.610,1584.874,-1890.545,1856.854), Map.Axis_Inside);
	axisInside_17 = OnTriggerRegion(AABB(1137.299,-356.990,1305.125,1340.875,-60.811,1789.530), Map.Axis_Inside);
	axisInside_18 = OnTriggerRegion(AABB(51.584,-511.237,465.380,331.991,-201.214,1582.817), Map.Axis_Inside);

	Util.MapDebugPrint( "^3Omni-bot map script by ^1n^2a^4t^8i^3v^5e12 ^3for " + GetMapName() + " executed." );
};

global OnBotJoin = function( bot )
{
	Server.MinClassCount[TEAM.ALLIES][CLASS.SOLDIER] = 0;
	Server.MinClassCount[TEAM.AXIS][CLASS.SOLDIER] = 0;
};
