//==========================================================================================
//
//	erdenberg_b2.gm
//
//	Who  	When		What
//------------------------------------------------------------------------------------------
//	^4Tardis	30 April 2011	Initial Script
//
//==========================================================================================
//

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

	East_Flak88_Dyno = 0,
	Main_Entrance_Dyno = 0,
	West_Flak88_Dyno = 0,
	Command_Post_Dyno = 0,

//Command Post
	Allied_Command_Post_Built = function( trigger )
	{

		Util.MapDebugPrint( "Allied_Command_Post_Built" );
	},

	Allied_Command_Post_Planted = function( trigger )
	{
		Map.Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Command_Post_Planted" );
	},

	Allied_Command_Post_Defused = function( trigger )
	{
		Map.Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Command_Post_Defused" );
	},

	Allied_Command_Post_Destroyed = function( trigger )
	{
		Map.Command_Post_Dyno = 0;
		Util.MapDebugPrint( "Allied_Command_Post_Destroyed" );
	},

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

	Axis_Command_Post_Planted = function( trigger )
	{
		Map.Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Command_Post_Planted" );
	},

	Axis_Command_Post_Defused = function( trigger )
	{
		Map.Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Command_Post_Defused" );
	},

	Axis_Command_Post_Destroyed = function( trigger )
	{
			Map.Command_Post_Dyno = 0;
		Util.MapDebugPrint( "Axis_Command_Post_Destroyed" );
	},

	East_Flak88_Planted = function( trigger )
	{
		Map.East_Flak88_Dyno += 1;
		Util.MapDebugPrint( "East_Flak88_Planted" );
	},

	East_Flak88_Defused = function( trigger )
	{
		Map.East_Flak88_Dyno -= 1;
		Util.MapDebugPrint( "East_Flak88_Defused" );
	},

	East_Flak88_Destroyed = function( trigger )
	{
		Map.East_Flak88_Dyno = 0;

		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_east.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_east.*" );

		Util.MapDebugPrint( "East_Flak88_Destroyed" );
	},

	West_Flak88_Planted = function( trigger )
	{
		Map.West_Flak88_Dyno += 1;
		Util.MapDebugPrint( "West_Flak88_Planted" );
	},

	West_Flak88_Defused = function( trigger )
	{
		Map.West_Flak88_Dyno -= 1;
		Util.MapDebugPrint( "West_Flak88_Defused" );
	},

	West_Flak88_Destroyed = function( trigger )
	{
		Map.West_Flak88_Dyno = 0;

		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_west.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_west.*" );

		Util.MapDebugPrint( "West_Flak88_Destroyed" );
	},


	Main_Entrance_Planted = function( trigger )
	{
		Map.Main_Entrance_Dyno += 1;
		Util.MapDebugPrint( "Main_Entrance_Planted" );
	},

	Main_Entrance_Defused = function( trigger )
	{
		Map.Main_Entrance_Dyno -= 1;
		Util.MapDebugPrint( "Main_Entrance_Defused" );
	},

	Main_Entrance_Destroyed = function( trigger )
	{
		Map.Main_Entrance_Dyno = 0;

		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_main.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_main.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "CHECKPOINT_forward_flag" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_forward_flag" );
		Util.EnableGoal( ".*Command_Post" );
		//east
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_east.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_east.*",
			"PLANT_East_Flak88",
		});
		//west
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_west.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ATTACK_west.*",
			"PLANT_West_Flak88",
		});

		Util.MapDebugPrint( "Main_Entrance_Destroyed" );
	},

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

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

};

global OnMapLoad = function()
{
	// Register callback functions
	OnTrigger( "Planted at the East Flak88", Map.East_Flak88_Planted );
	OnTrigger( "Planted at the Main Entrance.", Map.Main_Entrance_Planted );
	OnTrigger( "Planted at the West Flak88", Map.West_Flak88_Planted );
	OnTrigger( "Planted at the Allied Command Post", Map.Allied_Command_Post_Planted );
	OnTrigger( "Planted at the Axis Command Post", Map.Axis_Command_Post_Planted );
	OnTrigger( "Defused at the Allied Command Post", Map.Allied_Command_Post_Defused );
	OnTrigger( "Defused at the Axis Command Post", Map.Axis_Command_Post_Defused );
	OnTrigger( "Defused at the East Flak88", Map.East_Flak88_Defused );
	OnTrigger( "Defused at the Main Entrance", Map.Main_Entrance_Defused );
	OnTrigger( "Defused at the West Flak88", Map.West_Flak88_Defused );
	OnTrigger( "The East Flak88 has been destroyed!", Map.East_Flak88_Destroyed );
	OnTrigger( "Main Gate has been destroyed!", Map.Main_Entrance_Destroyed );
	OnTrigger( "The West Flak88 has been destroyed!", Map.West_Flak88_Destroyed );
	OnTrigger( "The Axis have reclaimed the forward bunker!", Map.forward_flag_Axis_Captured );
	OnTrigger( "The Allies have captured the forward bunker!", Map.forward_flag_Allies_Captured );

	Util.DisableGoal( ".*", true ); // all but routes
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_main.*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"ATTACK_main.*",
		"PLANT_Main_Entrance",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, "CHECKPOINT_forward_flag" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_forward_flag" );
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );

	SetGoalPriority( "PLANT_Command_Post.*", 0.49, 0, CLASS.ENGINEER );

	// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 2, "CHECKPOINT.*" );
	Util.SetMaxUsers( 1, "PLANT.*" );
	Util.SetMaxUsers( 1, "BUILD.*" );
	Util.SetMaxUsers( 1, "PLANT_Command_Post" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=90} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );
	//Routes

	MapRoutes =
	{
		CHECKPOINT_forward_flag =
		{
			ROUTE_alliedSP  =
			{
				ROUTE_tunnel  =
				{
					ROUTE_tunnelsp  =
					{
						ROUTE_tunnelB  =
						{
							ROUTE_main_2  =
							{
								ROUTE_main_3  =
								{
									ROUTE_main_4  =
									{
										ROUTE_SPFlag  =
										{
										},
									},
								},
							},
						},
						ROUTE_tunnelA  =
						{
							ROUTE_SPFlag  =
							{
							},
						},
					},
				},
				ROUTE_main  =
				{
					ROUTE_main_1  =
					{
						ROUTE_main_2  =
						{
							ROUTE_main_3  =
							{
								ROUTE_main_4  =
								{
									ROUTE_SPFlag  =
									{
									},
								},
							},
						},
					},
				},
				ROUTE_ramp  =
				{
					ROUTE_ramp_1  =
					{
						ROUTE_ramp_2  =
						{
							ROUTE_ramp_3  =
							{
								ROUTE_ramp_4  =
								{
									ROUTE_SPFlag  =
									{
									},
								},
							},
						},
					},
				},
			},
		},
		PLANT_Main_Entrance =
		{
			ROUTE_alliedSP  =
			{
				ROUTE_tunnel  =
				{
					ROUTE_tunnelsp  =
					{
						ROUTE_tunnelB  =
						{
							ROUTE_main_2  =
							{
								ROUTE_main_3  =
								{
									ROUTE_main_4  =
									{
									},
								},
							},
						},
						ROUTE_tunnelA  =
						{
							ROUTE_main_4  =
							{
							},
						},
					},
				},
				ROUTE_ramp  =
				{
					ROUTE_ramp_1  =
					{
						ROUTE_ramp_2  =
						{
							ROUTE_ramp_3  =
							{
								ROUTE_ramp_4  =
								{
									ROUTE_main_4  =
									{
									},
								},
							},
						},
					},
				},
				ROUTE_main  =
				{
					ROUTE_main_1  =
					{
						ROUTE_main_2  =
						{
							ROUTE_main_3  =
							{
								ROUTE_main_4  =
								{
								},
							},
						},
					},
				},
			},
		},
		PLANT_East_Flak88 =
		{
			ROUTE_SPFlag  =
			{
				ROUTE_east  =
				{
					ROUTE_east_1  =
					{
						ROUTE_east_2  =
						{
							ROUTE_east_3  =
							{
								ROUTE_east_4  =
								{
									ROUTE_east_5  =
									{
										ROUTE_east_6  =
										{
											ROUTE_east_7  =
											{
												ROUTE_eastgun  =
												{
												},
											},
										},
										ROUTE_westST  =
										{
											ROUTE_westST_1  =
											{
												ROUTE_westST_2  =
												{
													ROUTE_eastST_2  =
													{
														ROUTE_eastST_3  =
														{
															ROUTE_eastgun  =
															{
															},
														},
													},
												},
											},
										},
									},
								},
							},
						},
					},
				},
				ROUTE_west  =
				{
					ROUTE_west_1  =
					{
						ROUTE_west_2  =
						{
							ROUTE_west_3  =
							{
								ROUTE_west_4  =
								{
									ROUTE_west_5  =
									{
										ROUTE_westeast  =
										{
											ROUTE_eastST  =
											{
												ROUTE_eastST_1  =
												{
													ROUTE_eastST_2  =
													{
														ROUTE_eastST_3  =
														{
															ROUTE_eastgun  =
															{
															},
														},
													},
												},
											},
											ROUTE_westeast_1  =
											{
												ROUTE_westeast_2  =
												{
													ROUTE_eastgun  =
													{
													},
												},
												ROUTE_eastgun  =
												{
												},
											},
										},
									},
								},
							},
						},
					},
				},
			},
		},
		PLANT_West_Flak88 =
		{
			ROUTE_SPFlag  =
			{
				ROUTE_east  =
				{
					ROUTE_eastHO  =
					{
						ROUTE_eastHO_1  =
						{
							ROUTE_eastHO_2  =
							{
								ROUTE_eastHO_3  =
								{
									ROUTE_westgun  =
									{
									},
								},
							},
						},
					},
				},
				ROUTE_west  =
				{
					ROUTE_west_1  =
					{
						ROUTE_west_2  =
						{
							ROUTE_west_3  =
							{
								ROUTE_west_4  =
								{
									ROUTE_westgun  =
									{
									},
									ROUTE_west_5  =
									{
										ROUTE_eastHO_3  =
										{
											ROUTE_westgun  =
											{
											},
										},
									},
								},
							},
						},
					},
				},
			},
		},

		PLANT_East_Flak88 =
		{
			ROUTE_AxisSP  =
			{
				ROUTE_AxisA  =
				{
					ROUTE_westgun  =
					{
					},
				},
				ROUTE_AxisB  =
				{
					ROUTE_westgun  =
					{
					},
				},
				ROUTE_AxisC  =
				{
					ROUTE_westgun  =
					{
					},
				},
			},
		},
		PLANT_West_Flak88 =
		{
			ROUTE_AxisSP  =
			{
				ROUTE_AxisA  =
				{
					ROUTE_westgun  =
					{
					},
				},
				ROUTE_AxisB  =
				{
					ROUTE_westgun  =
					{
					},
				},
				ROUTE_AxisC  =
				{
					ROUTE_westgun  =
					{
					},
				},
			},
		},
	};

	//copy some routes
	MapRoutes.DEFEND_main = MapRoutes.CHECKPOINT_forward_flag;
	MapRoutes.DEFEND_main_1 = MapRoutes.CHECKPOINT_forward_flag;
	MapRoutes.DEFEND_main_2 = MapRoutes.CHECKPOINT_forward_flag;
	MapRoutes.DEFEND_main_3 = MapRoutes.CHECKPOINT_forward_flag;
	MapRoutes.DEFEND_main_4 = MapRoutes.CHECKPOINT_forward_flag;
	MapRoutes.DEFEND_main_5 = MapRoutes.CHECKPOINT_forward_flag;

	MapRoutes.DEFEND_west = MapRoutes.PLANT_West_Flak88;
	MapRoutes.DEFEND_west_1 = MapRoutes.PLANT_West_Flak88;
	MapRoutes.DEFEND_west_2 = MapRoutes.PLANT_West_Flak88;
	MapRoutes.DEFEND_west_3 = MapRoutes.PLANT_West_Flak88;
	MapRoutes.DEFEND_west_4 = MapRoutes.PLANT_West_Flak88;
	MapRoutes.DEFEND_west_5 = MapRoutes.PLANT_West_Flak88;
	MapRoutes.DEFEND_west_6 = MapRoutes.PLANT_West_Flak88;

	MapRoutes.DEFEND_east = MapRoutes.PLANT_East_Flak88;
	MapRoutes.DEFEND_east_1 = MapRoutes.PLANT_East_Flak88;
	MapRoutes.DEFEND_east_2 = MapRoutes.PLANT_East_Flak88;
	MapRoutes.DEFEND_east_3 = MapRoutes.PLANT_East_Flak88;
	MapRoutes.DEFEND_east_4 = MapRoutes.PLANT_East_Flak88;

	MapRoutes.ATTACK_main = MapRoutes.CHECKPOINT_forward_flag;
	MapRoutes.ATTACK_main_1 = MapRoutes.CHECKPOINT_forward_flag;
	MapRoutes.ATTACK_main_2 = MapRoutes.CHECKPOINT_forward_flag;
	MapRoutes.ATTACK_main_3 = MapRoutes.CHECKPOINT_forward_flag;
	MapRoutes.ATTACK_main_4 = MapRoutes.CHECKPOINT_forward_flag;

	MapRoutes.ATTACK_west = MapRoutes.PLANT_West_Flak88;
	MapRoutes.ATTACK_west_1 = MapRoutes.PLANT_West_Flak88;
	MapRoutes.ATTACK_west_2 = MapRoutes.PLANT_West_Flak88;
	MapRoutes.ATTACK_west_3 = MapRoutes.PLANT_West_Flak88;
	MapRoutes.ATTACK_west_4 = MapRoutes.PLANT_West_Flak88;
	MapRoutes.ATTACK_west_5 = MapRoutes.PLANT_West_Flak88;

	MapRoutes.ATTACK_east = MapRoutes.PLANT_East_Flak88;
	MapRoutes.ATTACK_east_1 = MapRoutes.PLANT_East_Flak88;
	MapRoutes.ATTACK_east_2 = MapRoutes.PLANT_East_Flak88;
	MapRoutes.ATTACK_east_3 = MapRoutes.PLANT_East_Flak88;
	MapRoutes.ATTACK_east_4 = MapRoutes.PLANT_East_Flak88;
	MapRoutes.ATTACK_east_5 = MapRoutes.PLANT_East_Flak88;


	Util.Routes(MapRoutes);


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

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