global Map =
{

	Navigation = // should not be needed but no harm to leave it in
	{
		ladder_pt =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.FORWARD, 2);
				sleep(3.5);
			},
		},

		strafe_l_point =
		{
			navigate = function(_this)
			{
				_this.Bot.HoldButton(BTN.STRAFE_L, 2);
				sleep(2);
			},
		},


	},

	Axis_Command_Post_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );

		Util.MapDebugPrint( "Command_Post_Built" );
	},

	Allies_Command_Post_Built = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"BUILD_Command_Post",
			"PLANT_Command_Post",
		});

		Util.MapDebugPrint( "Command_Post_Built" );
	},

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

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

	Main_door_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_maindoor.*",
			"BUILD_Command_Post.*",
			"ARTILLERY_S_main",
			"CALLARTILLERY_main",
			"DEFUSE_Main_door.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_depot.*",
			"CALLARTILLERY_depot.*",
			"ARTILLERY_S_depot.*",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_maindoor.*",
			"PLANT_Main_door.*",
			"AMMOCAB_south_ammocabinet",
			"HEALTHCAB_south_healthcabinet",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_depot.*",
			"PLANT_Side_door",
			"PLANT_depot_door_1",
			"PLANT_depot_door_2",
			"BUILD_Command_Post",
			"PLANT_Command_Post",
		});

		Util.ChangeSpawn(TEAM.ALLIES, 4); // just to make sure bots change to new spawn

		Util.MapDebugPrint( "Main_door_Destroyed" );
	},

	Side_door_Destroyed = function( trigger )
	{

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_side_depot.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_Side_door.*" );

		Util.MapDebugPrint( "Side_door_Destroyed" );
	},

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

	depot_door_1_Destroyed = function( trigger )
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_depot_door_1" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_V2_gun_control",
			"ATTACK_V2.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_V2_gun_1" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_depot_door_1.*" );

		Util.EnableGoal("ROUTE_depot_door_1");

		Util.MapDebugPrint( "depot_door_1_Destroyed" );
	},

	depot_door_2_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_depot_door_2" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_V2_gun_control",
			"ATTACK_V2.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_V2_gun_2" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFUSE_depot_door_2.*" );

		Util.EnableGoal("ROUTE_depot_door_2");
		Util.EnableGoal("ROUTE_depot_side");

		Util.MapDebugPrint( "depot_door_2_Destroyed" );
	},

};

global OnMapLoad = function()
{
	OnTrigger( "^3**^1Allied Command Post constructed. Charge speed increased!^3**", Map.Allies_Command_Post_Built );
	OnTrigger( "^3**^1Axis Command Post constructed. Charge speed increased!^3**", Map.Axis_Command_Post_Built );
	OnTrigger( "^3**^1Axis team has destroyed the Allied Command Post!^3**", Map.Allies_Command_Post_Destroyed );
	OnTrigger( "^3**^1Allied team has destroyed the Axis Command Post!^3**", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "^3**^1Allies team have destroyed  the main door !!^3**", Map.Main_door_Destroyed );
	OnTrigger( "^3**^1Allies team have destroyed  the side door !!^3**", Map.Side_door_Destroyed );
	OnTrigger( "^3**^1Allies team have destroyed  the gun control!!^3**", Map.V2_gun_control_Destroyed );
	OnTrigger( "^3**^1Allies team have destroyed  the depot door #1!!^3**", Map.depot_door_1_Destroyed );
	OnTrigger( "^3**^1Allies team have destroyed  the depot door #2!!^3**", Map.depot_door_2_Destroyed );

	Util.SetGoalOffset( 0, 30, 0, "PLANT_depot_door_1" );
	Util.SetGoalOffset( -20, 0, 0, "PLANT_depot_door_2" );

	Util.DisableGoal(".*");
	Util.DisableGoal("ROUTE_depot_door_1");
	Util.DisableGoal("ROUTE_depot_door_2");
	Util.DisableGoal("ROUTE_depot_side");

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"DEFEND_maindoor.*",
		"BUILD_Command_Post.*",
		"ARTILLERY_S_main",
		"CALLARTILLERY_main",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"ATTACK_maindoor.*",
		"PLANT_Main_door",
		"AMMOCAB_south_ammocabinet",
		"HEALTHCAB_south_healthcabinet",
		"ROUTE.*",
	});

	SetGoalPriority( "ATTACK_V2.*", 0.51, TEAM.ALLIES );
	SetGoalPriority( "DEFEND_V2.*", 0.51, TEAM.AXIS );

	Util.SetMaxUsersInProgress( 1, "BUILD_Command_Post" );




	MapRoutes =
	{
		PLANT_Main_door =
		{
			ROUTE_alliesspawn1 =
			{
				ROUTE_alliess1north = {},
				ROUTE_alliess1west = {},
			},
		},

		PLANT_depot_door_1 =
		{
			ROUTE_alliesspawn2 =
			{
				ROUTE_depotpath = {Weight = 2},
				ROUTE_depottunnel = {},
			},
		},

		ATTACK_V2_1 =
		{
			ROUTE_alliesspawn2  =
			{
				Weight = 2,
				ROUTE_depotpath  =
				{
					ROUTE_depot_door_1  =
					{
					},
					ROUTE_depot_side  =
					{
						ROUTE_depot_door_2  =
						{
						},
					},
				},
				ROUTE_depottunnel  =
				{
					ROUTE_depot_door_1  =
					{
					},
					ROUTE_depot_side  =
					{
						ROUTE_depot_door_2  =
						{
						},
					},
				},
			},
		},


	};
	MapRoutes.ATTACK_maindoor_1 = MapRoutes.PLANT_Main_door;
	MapRoutes.ATTACK_maindoor_2 = MapRoutes.PLANT_Main_door;
	MapRoutes.ATTACK_maindoor_3 = MapRoutes.PLANT_Main_door;
	MapRoutes.ATTACK_maindoor_4 = MapRoutes.PLANT_Main_door;
	MapRoutes.ATTACK_maindoor_5 = MapRoutes.PLANT_Main_door;
	MapRoutes.ATTACK_maindoor_6 = MapRoutes.PLANT_Main_door;

	MapRoutes.PLANT_depot_door_2 = MapRoutes.PLANT_depot_door_1;
	MapRoutes.ATTACK_depot_1 = MapRoutes.PLANT_depot_door_1;
	MapRoutes.ATTACK_depot_2 = MapRoutes.PLANT_depot_door_1;
	MapRoutes.ATTACK_depot_3 = MapRoutes.PLANT_depot_door_1;
	MapRoutes.ATTACK_depot_4 = MapRoutes.PLANT_depot_door_1;
	MapRoutes.ATTACK_depot_5 = MapRoutes.PLANT_depot_door_1;
	MapRoutes.ATTACK_depot_6 = MapRoutes.PLANT_depot_door_1;
	MapRoutes.ATTACK_depot_7 = MapRoutes.PLANT_depot_door_1;
	MapRoutes.ATTACK_V2_2 = MapRoutes.ATTACK_V2_1;
	MapRoutes.ATTACK_V2_3 = MapRoutes.ATTACK_V2_1;

	Util.Routes(MapRoutes);

	Util.MapDebugPrint( "OnMapLoad" );
};
