global Map =
{
	Command_Post_Built = function()
	{
		print( "Command_Post_Built" );
	},

	Door_bars_Built = function()
	{
//		SetGoalRole(Map.Plant_Door_bars, ROLE.INFILTRATOR);
		Util.MapDebugPrint( "Door_bars_Built" );
	},

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

	Rhine_Bridge_Built = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_db.*",
			"DEFEND_door.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "CHECKPOINT_forward_spawn" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"SNIPE_axis.*",
			"MOUNTMG42_283",
			"MOBILEMG42_mg1",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, true, "CALLARTILLERY_bridge1" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"ARTILLERY_D_bars2",
			"ARTILLERY_S_bars3",
			"CALLARTILLERY_bars1",
			"PLANT_Stairs",
			"MOBILEMORTAR_mrt1",
			"ATTACK_bunker.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_bridge.*" );
		Server.MinClassCount[TEAM.AXIS][CLASS.ENGINEER] = 3;
		Server.MinClassCount[TEAM.AXIS][CLASS.FIELDOPS] = 1;

		Util.MapDebugPrint( "Rhine_Bridge_Built" );
	},

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

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

	doorbars_blown = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Bunker_Door" );
//		ClearGoalRole(Map.Plant_Door_bars, ROLE.INFILTRATOR);

		Util.MapDebugPrint( "bars blown" );
	},

	Cave_Stone_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_as.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_bridge.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_db.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_ds.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"PLANTMINE_1",
			"PLANTMINE_2",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Rhine_Bridge" );
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_Rhine_Bridge" );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"BUILD_Command_Post",
			"PLANT_Command_Post",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"PLANT_Command_Post",
			"BUILD_Stairs",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_643" );

		Util.MapDebugPrint("Cave_Stone_Destroyed");
	},

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

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

	Rhine_Bridge_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_bunker.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_bridge.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_mg1" );

		Util.MapDebugPrint( "Rhine_Bridge_Destroyed" );
	},

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

	forward_spawn_Axis_Captured = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_135" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMORTAR_shit1" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMG42_hill" );

		Util.MapDebugPrint( "forward_spawn_Axis_Captured" );
	},

	forward_spawn_Allies_Captured = function()
	{
		Server.MinClassCount[TEAM.ALLIES][CLASS.COVERTOPS] = 2;
		Server.MinClassCount[TEAM.ALLIES][CLASS.FIELDOPS] = 1;
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOUNTMG42_135" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_486" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMORTAR_shit1" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOBILEMG42_hill" );

		Util.MapDebugPrint( "forward_spawn_Allies_Captured" );
	},

	bunker_planted = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_db4",
			"DEFEND_db3",
			"BUILD_Door_bars",
		});

		Util.MapDebugPrint("Bunker Planted" );
	},

	bunker_defused = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_db4",
			"DEFEND_db3",
			"BUILD_Door_bars",
		});
		Util.MapDebugPrint("Bunker defused" );
	},

	bridge_defused = function()
	{
		Util.MapDebugPrint("bridge defused" );
	},

	bridge_planted = function()
	{
		Util.MapDebugPrint("bridge planted" );
	},
};

global OnMapLoad = function()
{
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );
	OnTrigger( "The Bunker door has been caged.", Map.Door_bars_Built );
	OnTrigger( "The Ladder have been built.", Map.Ladder_Built );
	OnTrigger( "The Rhine Bridge has been repaired.", Map.Rhine_Bridge_Built );
	OnTrigger( "MISSING_STRING", Map.Stairs_Built );
	OnTrigger( "MISSING_STRING", Map.Bunker_Door_Destroyed );
	OnTrigger( "Allies have breached the cave!", Map.Cave_Stone_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Ladder_Destroyed );
	OnTrigger( "The Rhine Bridge is destroyed.", Map.Rhine_Bridge_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Stairs_Destroyed );
	OnTrigger( "Axis capture the forward bunker!", Map.forward_spawn_Axis_Captured );
	OnTrigger( "Allies capture the forward bunker!", Map.forward_spawn_Allies_Captured );
	OnTrigger( "The Bunker door has been destroyed.", Map.doorbars_blown );
	OnTrigger( "Planted at Bunker Door.", Map.bunker_planted );
	OnTrigger( "Planted at Rhine Bridge.", Map.bridge_planted );
	OnTrigger( "Defused at Rhine Bridge.", Map.bridge_defused );
	OnTrigger( "Defused at Bunker Door.", Map.bunker_defused);

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

	Util.EnableGoal("AMMOCAB_.*"); //enables for both teams
	Util.EnableGoal("HEALTHCAB_.*"); //enables for both teams
	Util.EnableGoal("GRENADE_.*"); //enables for both teams

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"ATTACK_as.*",
		"PLANT_Cave_Stone",
		"BUILD_Ladder",
		"CHECKPOINT_forward_spawn",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"BUILD_Door_bars",
		"CHECKPOINT_forward_spawn",
		"BUILD_Command_Post",
		"MOUNTMG42_643",
		"DEFEND_ds.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Door_bars" );
	Util.AddUseWp( "PLANT_Door_bars", "bars" );

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

	// max users
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "BUILD_.*" );
	Util.SetMaxUsers( 2, "CHECKPOINT_forward_spawn" );
	Util.SetMaxUsers( 2, "PLANT_Door_bars" );
	Util.SetMaxUsers( 1, "BUILD_Stairs" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "PLANT_Cave_Stone" );
	Util.SetMaxUsers( 1, "PLANT_Rhine_Bridge" );
	Util.SetMaxUsers( 1, "PLANT_Command_Post" );

	// Camptimes
	SetMapGoalProperties( "DEFEND_.*", {mincamptime=25, maxcamptime=90} );
	SetMapGoalProperties( "ATTACK_.*", {mincamptime=15, maxcamptime=80} );
	SetMapGoalProperties( "MOBILEMG42_.*", {mincamptime=60, maxcamptime=120} );
	SetMapGoalProperties( "MOUNTMG42_.*", {mincamptime=60, maxcamptime=120} );
	SetMapGoalProperties( "MOBILEMORTAR_.*", {mincamptime=45, maxcamptime=140} );

	//Priorities
	SetGoalPriority( "PLANT_Stairs", 0.2, TEAM.ALLIES, 0 );
	SetGoalPriority( "PLANT_Door_bars", 0.0, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Door_bars", 0.93, TEAM.ALLIES, CLASS.COVERTOPS );
//	SetGoalRole(Map.Plant_Door_bars, ROLE.INFILTRATOR);

	//Goal positions
	Util.SetGoalOffset( 0,55,0, "PLANT_Cave_Stone" );
	Util.SetGoalOffset( 0,30,-20, "PLANT_Bunker_Door" );
	Util.SetGoalOffset( 0,30,0, "BUILD_Ladder" );
	Util.SetGoalPosition( -167.3, 162.13, 536.125, "BUILD_Rhine_Bridge") ;
	Util.SetGoalPosition( 21.478, -207.9, 536.125, "PLANT_Rhine_Bridge") ;
	Util.SetGoalPosition( 535.97, -1992.137, 536.125, "PLANT_Bunker_Door") ;

	MapRoutes =
	{
		CHECKPOINT_forward_spawn =
		{
			ROUTE_s0  =
			{
				ROUTE_s1  =
				{
					ROUTE_s2  =
					{
						ROUTE_s3  =
						{
							ROUTE_s4  =
							{
								ROUTE_bridge11  =
								{
									ROUTE_s6  =
									{
									},
								},
							},
						},
					},
					ROUTE_s13  =
					{
						ROUTE_s14  =
						{
							ROUTE_s11  =
							{
								ROUTE_s12  =
								{
									ROUTE_bridge11  =
									{
									},
								},
							},
						},
					},
					ROUTE_s7  = {Weight = 4,},
						ROUTE_s8  =
						{
							ROUTE_s9  =
							{
								ROUTE_s10  =
								{
									ROUTE_s11  =
									{
										ROUTE_bridge11  =
										{
										},
									},
								},
							},
						},

				},
			},
		},

		BUILD_Rhine_Bridge =
		{
			ROUTE_fs  =
			{
				ROUTE_bridge1  =
				{
					ROUTE_bridge2  =
					{
						ROUTE_bridge3  =
						{
							ROUTE_bridge4  =
							{
								ROUTE_bridge4a  =
								{
									ROUTE_bridge5  =
									{
									},
								},
								ROUTE_bridge4b  =
								{
									ROUTE_bridge5  =
									{
									},
								},
							},
						},
						ROUTE_bridge6  =
						{
							ROUTE_bridge7  =
							{
								ROUTE_bridge8  =
								{
									ROUTE_bridge9  =
									{
										ROUTE_bridge10  =
										{
											ROUTE_bridge4b  =
											{
												ROUTE_bridge5  =
												{
												},
											},
										},
									},
								},
							},
						},
					},
				},
				ROUTE_bridge11  =
				{
					ROUTE_s12  =
					{
						ROUTE_bridge12  =
						{
							ROUTE_bridge13  =
							{
								ROUTE_bridge14  =
								{
									ROUTE_bridge8  =
									{
										ROUTE_bridge9  =
										{
											ROUTE_bridge4b  = {},
										},
									},
								},
							},
						},
					},
				},
			},
		},
	};

	MapRoutes.ATTACK_as1 = MapRoutes.CHECKPOINT_forward_spawn;
	MapRoutes.ATTACK_as2 = MapRoutes.CHECKPOINT_forward_spawn;
	MapRoutes.ATTACK_as3 = MapRoutes.CHECKPOINT_forward_spawn;
	MapRoutes.ATTACK_as4 = MapRoutes.CHECKPOINT_forward_spawn;
	MapRoutes.MOUNTMG42_486 = MapRoutes.CHECKPOINT_forward_spawn;
	MapRoutes.PLANT_Cave_Stone = MapRoutes.CHECKPOINT_forward_spawn;
	MapRoutes.PLANT_Bunker_Door = MapRoutes.BUILD_Rhine_Bridge;
	MapRoutes.ATTACK_bunker1 = MapRoutes.BUILD_Rhine_Bridge;
	MapRoutes.ATTACK_bunker2 = MapRoutes.BUILD_Rhine_Bridge;
	MapRoutes.ATTACK_bunker3 = MapRoutes.BUILD_Rhine_Bridge;

	MapRoutes.ATTACK_bridge1 = MapRoutes.BUILD_Rhine_Bridge;
	MapRoutes.ATTACK_bridge2 = MapRoutes.BUILD_Rhine_Bridge;
	MapRoutes.PLANT_Ladder = MapRoutes.BUILD_Rhine_Bridge;
	Util.Routes(MapRoutes);

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

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