global Map =
{
	Debug = 0,

	Command_Post_Dyno = 0,
	anti_ship_gun_Dyno = 0,
	comms_bunker_Dyno = 0,
	compound_gate_Dyno = 0,
	compound_wall_Dyno = 0,
	light_Dyno = 0,
	main_entrance_Dyno = 0,
	ropes_Dyno = 0,
	tower_climbing_ropes_Dyno = 0,
	Quiet = true,

	Ammo_Cabinet_sawmill_ammocabinet = "AMMOCAB_sawmill_ammocabinet",
	Ammo_Cabinet_sawmill_ammocabinet_1 = "AMMOCAB_sawmill_ammocabinet_1",
	Health_Cabinet_sawmill_health_cabinet = "HEALTHCAB_sawmill_health_cabinet",
	Health_Cabinet_sawmill_health_cabinet_1 = "HEALTHCAB_sawmill_health_cabinet_1",
	Call_Artillery_122 = "CALLARTILLERY_122",
	Call_Artillery_345 = "CALLARTILLERY_345",
	Call_Artillery_355 = "CALLARTILLERY_355",
	Call_Artillery_476 = "CALLARTILLERY_476",
	Call_Artillery_91 = "CALLARTILLERY_91",
	Call_Artillery_94 = "CALLARTILLERY_94",
	Artillery_D_134 = "ARTILLERY_D_134",
	Artillery_D_377 = "ARTILLERY_D_377",
	Artillery_D_378 = "ARTILLERY_D_378",
	Artillery_D_528 = "ARTILLERY_D_528",
	Artillery_S_134 = "ARTILLERY_S_134",
	Artillery_S_318 = "ARTILLERY_S_318",
	Artillery_S_377 = "ARTILLERY_S_377",
	Artillery_S_378 = "ARTILLERY_S_378",
	Artillery_S_528 = "ARTILLERY_S_528",
	Checkpoint_forwardspawn = "CHECKPOINT_forwardspawn",
	Build_Command_Post = "BUILD_Command_Post",
	Build_ropes = "BUILD_ropes",
	Build_tower_climbing_ropes = "BUILD_tower_climbing_ropes",
	Plant_Command_Post = "PLANT_Command_Post",
	Plant_anti_ship_gun = "PLANT_anti_ship_gun",
	Plant_comms_bunker = "PLANT_comms_bunker",
	Plant_compound_gate = "PLANT_compound_gate",
	Plant_compound_wall = "PLANT_compound_wall",
	Plant_light = "PLANT_light",
	Plant_main_entrance = "PLANT_main_entrance",
	Plant_ropes = "PLANT_ropes",
	Plant_tower_climbing_ropes = "PLANT_tower_climbing_ropes",
	Mobile_MG42_346 = "MOBILEMG42_346",
	Mobile_MG42_347 = "MOBILEMG42_347",
	Snipe_391 = "SNIPE_391",
	Snipe_69 = "SNIPE_69",
	Snipe_70 = "SNIPE_70",
	Snipe_91 = "SNIPE_91",
	Snipe_94 = "SNIPE_94",
	Plant_Mine_314 = "PLANTMINE_314",
	Plant_Mine_345 = "PLANTMINE_345",

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

	ropes_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_compound_wall" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_ropes" );
		Wp.SetWaypointFlag( "rps1", "closed", false );

		Util.MapDebugPrint( "ropes_Built" );
	},

	tower_climbing_ropes_Built = function( trigger )
	{
		Wp.SetWaypointFlag( "rope1", "closed", false );
		Wp.SetWaypointFlag( "rope2", "closed", false );

		Wp.SetWaypointFlag( "rope3", "closed", false );
		Util.MapDebugPrint( "tower_climbing_ropes_Built" );
	},

	Command_Post_Planted = function( trigger )
	{
		Map.Command_Post_Dyno += 1;
		SetAvailableMapGoals( TEAM.AXIS, false, Map.Plant_Command_Post );

		// CHECK! Is this a valid goal for both teams?
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_Command_Post );

		Util.MapDebugPrint( "Command_Post_Planted" );
	},

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

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

	compound_gate_Planted = function( trigger )
	{
		Map.compound_gate_Dyno += 1;

		Util.MapDebugPrint( "compound_gate_Planted" );
	},

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

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

	main_entrance_Planted = function( trigger )
	{
		Map.main_entrance_Dyno += 1;

		Util.MapDebugPrint( "main_entrance_Planted" );
	},

	ropes_Planted = function( trigger )
	{
		Map.ropes_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_ropes );

		Util.MapDebugPrint( "ropes_Planted" );
	},

	tower_climbing_ropes_Planted = function( trigger )
	{
		Map.tower_climbing_ropes_Dyno += 1;
		SetAvailableMapGoals( TEAM.ALLIES, false, Map.Plant_tower_climbing_ropes );

		Util.MapDebugPrint( "tower_climbing_ropes_Planted" );
	},

	Command_Post_Defused = function( trigger )
	{
		Map.Command_Post_Dyno -= 1;
		if ( Map.Command_Post_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_Command_Post ); }

		// CHECK! Is this a valid goal for both teams?
		if ( Map.Command_Post_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_Command_Post ); }

		Util.MapDebugPrint( "Command_Post_Defused" );
	},

	anti_ship_gun_Defused = function( trigger )
	{
		Map.anti_ship_gun_Dyno -= 1;

		Util.MapDebugPrint( "anti_ship_gun_Defused" );
	},

	comms_bunker_Defused = function( trigger )
	{
		Map.comms_bunker_Dyno -= 1;

		Util.MapDebugPrint( "comms_bunker_Defused" );
	},

	compound_gate_Defused = function( trigger )
	{
		Map.compound_gate_Dyno -= 1;

		Util.MapDebugPrint( "compound_gate_Defused" );
	},

	compound_wall_Defused = function( trigger )
	{
		Map.compound_wall_Dyno -= 1;
		if ( Map.compound_wall_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_compound_wall ); }

		Util.MapDebugPrint( "compound_wall_Defused" );
	},

	light_Defused = function( trigger )
	{
		Map.light_Dyno -= 1;
		if ( Map.light_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.AXIS, true, Map.Plant_light ); }

		Util.MapDebugPrint( "light_Defused" );
	},

	main_entrance_Defused = function( trigger )
	{
		Map.main_entrance_Dyno -= 1;

		Util.MapDebugPrint( "main_entrance_Defused" );
	},

	ropes_Defused = function( trigger )
	{
		Map.ropes_Dyno -= 1;
		if ( Map.ropes_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_ropes ); }

		Util.MapDebugPrint( "ropes_Defused" );
	},

	tower_climbing_ropes_Defused = function( trigger )
	{
		Map.tower_climbing_ropes_Dyno -= 1;
		if ( Map.tower_climbing_ropes_Dyno < 1 )
			{ SetAvailableMapGoals( TEAM.ALLIES, true, Map.Plant_tower_climbing_ropes ); }

		Util.MapDebugPrint( "tower_climbing_ropes_Defused" );
	},

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

	anti_ship_gun_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_sg*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_antiship.*" );
		Util.DisableGoal("PLANT_Command_Post");

		Util.MapDebugPrint( "anti_ship_gun_Destroyed" );
	},

	comms_bunker_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_cm.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_comms.*" );

		Util.MapDebugPrint( "comms_bunker_Destroyed" );
	},

	compound_gate_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"PLANT_anti_ship_gun",
			"PLANT_light",
			"PLANT_comms_bunker",
			"ATTACK_lh.*",
		});

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

	compound_wall_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_r.*",
			"DEFEND_s.*",
		});
//~		SetAvailableMapGoals( TEAM.AXIS, true, "PLANT_anti_ship_gun" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"PLANT_light",
			"ATTACK_comms.*",
			"ATTACK_lh.*",
			"PLANT_comms_bunker",
			"PLANT_compound_gate",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"DEFEND_cm.*",
			"DEFEND_sg*",
			"DEFEND_light.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, "CALLARTILLERY_ca.*" );
//~		SetAvailableMapGoals( TEAM.AXIS, false, "ATTACK_a.*" );
		Util.DisableGroup( "group1", TEAM.AXIS);
		Util.SetGoalPosition( -178.489, 326.976, 1052.125, "PLANT_compound_gate" ) ;
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"CALLARTILLERY_ca.*",
			"ARTILLERY_D_ropesarty.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_tower_climbing_ropes" );

		Util.MapDebugPrint( "compound_wall_Destroyed" );
	},

	light_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_light.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"BUILD_tower_climbing_ropes",
			"ATTACK_lh.*",
		});

		Util.MapDebugPrint( "light_Destroyed" );
	},

	main_entrance_Destroyed = function( trigger )
	{
//~		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_s.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_r.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"CHECKPOINT_forwardspawn",
			"PLANT_compound_gate",
			"PLANT_anti_ship_gun",
			"ATTACK_antiship.*",
		});

		Util.DisableGroup( "attack1", TEAM.AXIS);
		Util.DisableGroup( "defend1", TEAM.ALLIES);
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"DEFEND_cm.*",
			"DEFEND_sg.*",
			"DEFEND_light.*",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"CALLARTILLERY_ca.*",
			"ARTILLERY_S_marty1",
			"ARTILLERY_D_ropesarty.*",
			"CALLARTILLERY_earty1",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMORTAR_.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"PLANT_Command_Post",
			"BUILD_Command_Post",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" );

		SetAvailableMapGoals( TEAM.AXIS, false, "ARTILLERY_S_searty1" );
		Util.MapDebugPrint( "main destroyed" );
	},

	ropes_Destroyed = function( trigger )
	{
		Wp.SetWaypointFlag( "rps1", "closed", true );

		Util.MapDebugPrint( "ropes_Destroyed" );
	},

	tower_climbing_ropes_Destroyed = function( trigger )
	{

		Wp.SetWaypointFlag( "rope1", "closed", true );
		Wp.SetWaypointFlag( "rope2", "closed", true );
		Wp.SetWaypointFlag( "rope3", "closed", true );
		Util.MapDebugPrint( "tower_climbing_ropes_Destroyed" );
	},

	forwardspawn_Axis_Captured = function( trigger )
	{
		DynamicPathsUpdated();
		SetAvailableMapGoals( TEAM.ALLIES, true, "MOBILEMG42_ally1" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOBILEMG42_axis1" );

		Util.MapDebugPrint( "forwardspawn_Axis_Captured" );
	},

	forwardspawn_Allies_Captured = function( trigger )
	{
		DynamicPathsUpdated();
		SetAvailableMapGoals( TEAM.ALLIES, false, "MOBILEMG42_ally1" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_axis1" );

   		// half the allies should spawn at the cp
		foreach ( id and bot in BotTable )
		{
			if ( bot.GetTeam() == TEAM.ALLIES )
			{
				if ( RandInt(0,10) < 5)
				{
					bot.ChangeSpawnPoint( 3 ); // cp
				}
				else
				{
					bot.ChangeSpawnPoint( 0 ); //flag
				}
			}
		}

		Util.MapDebugPrint( "forwardspawn_Allies_Captured" );
	},
};

global OnMapLoad = function()
{
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );
	OnTrigger( "Axis team has built the cliff assault ropes!", Map.ropes_Built );
	OnTrigger( "Axis team has built the lighthouse tower assault ropes!", Map.tower_climbing_ropes_Built );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Command_Post_Planted );
	OnTrigger( "Planted at the anti ship gun.", Map.anti_ship_gun_Planted );
	OnTrigger( "Planted at the comms bunker.", Map.comms_bunker_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.compound_gate_Planted );
	OnTrigger( "Planted at the compound wall.", Map.compound_wall_Planted );
	OnTrigger( "Planted at the light.", Map.light_Planted );
	OnTrigger( "Planted at the main entrance.", Map.main_entrance_Planted );
	OnTrigger( "Planted at the ropes.", Map.ropes_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.tower_climbing_ropes_Planted );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Command_Post_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.anti_ship_gun_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.comms_bunker_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.compound_gate_Defused );
	OnTrigger( "Defused at the compound wall.", Map.compound_wall_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.light_Defused );
	OnTrigger( "Defused at the main entrance.", Map.main_entrance_Defused );
	OnTrigger( "Defused at the ropes.", Map.ropes_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.tower_climbing_ropes_Defused );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Destroyed );
	OnTrigger( "Axis have destroyed MAIN OBJECTIVE 2 the Anti-Ship Gun!", Map.anti_ship_gun_Destroyed );
	OnTrigger( "Axis have destroyed MAIN OBJECTIVE 3 the Command Bunker!", Map.comms_bunker_Destroyed );
	OnTrigger( "Axis team has breached the compound gate", Map.compound_gate_Destroyed );
	OnTrigger( "Axis team has breached the compound wall", Map.compound_wall_Destroyed );
	OnTrigger( "Axis have destroyed MAIN OBJECTIVE 1 the Light!", Map.light_Destroyed );
	OnTrigger( "Axis team has breached the main entrance", Map.main_entrance_Destroyed );
	OnTrigger( "Allied team has destroyed the assault ropes!", Map.ropes_Destroyed );
	OnTrigger( "Allied team has destroyed the lighthouse tower assault ropes!", Map.tower_climbing_ropes_Destroyed );
	OnTrigger( "Axis capture forward bunker - ammo bunker door open!", Map.forwardspawn_Axis_Captured );
	OnTrigger( "Allies capture forward bunker - ammo bunker door closed!", Map.forwardspawn_Allies_Captured );

	SetAvailableMapGoals( TEAM.AXIS, false, ".*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, ".*" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "ROUTE_.*" );

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

	Util.EnableGroup( "attack1", TEAM.AXIS);
	Util.EnableGroup( "defend1", TEAM.ALLIES);
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"CALLARTILLERY_ca3",
		"CALLARTILLERY_earty1",
		"ARTILLERY_S_marty1",
		"ARTILLERY_S_searty1",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"MOBILEMORTAR_.*",
		"BUILD_Command_Post",
		"DEFEND_r.*",
		"CHECKPOINT_forwardspawn",
	});

	Wp.SetWaypointFlag( "rope1", "closed", true );
	Wp.SetWaypointFlag( "rope2", "closed", true );
	Wp.SetWaypointFlag( "rope3", "closed", true );
	Wp.SetWaypointFlag( "rps1", "closed", true );


	Util.SetGoalOffset( -10, 10, 0, "BUILD_tower_climbing_ropes" );
	Util.SetGoalOffset( 0, -20, -12, "PLANT_compound_wall" );
	Util.SetGoalPosition( -1210.569, -221.527, 2608.244, "PLANT_light" ) ;
	Util.SetGoalPosition( -466.3, -766.04, 1034.125, "PLANT_ropes" ) ;
	Util.SetGoalPosition( 603.5, 968.4, 650.125, "PLANT_main_entrance" ) ;
	Util.SetGoalPosition( 686.339, -564.2, 648.125, "PLANT_anti_ship_gun" ) ;
	Util.SetGoalPosition( -101.975, 311.6, 1048.125, "PLANT_compound_gate" ) ;

	Util.EnableGoal("AMMOCAB_.*");
	Util.EnableGoal("HEALTHCAB_.*");
	Util.EnableGoal("ROUTE_.*");

	SetMapGoalProperties( "DEFEND_.*", {MinCampTime=30, MaxCampTime=90} );
	SetMapGoalProperties( "DEFEND_start.*", {MinCampTime=60, MaxCampTime=90} );
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=30, MaxCampTime=90} );
//~	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=60, MaxCampTime=90} );
	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=25, MaxCampTime=60} );
	SetMapGoalProperties( "SNIPE_.*", {MinCampTime=40, MaxCampTime=60} );
	SetGoalPriority( "PLANT_compound_wall", 0.93, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_main_entrance", 0.92, TEAM.AXIS, CLASS.ENGINEER );

	Util.SetMaxUsers( 2, "CHECKPOINT_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "BUILD_.*" );
	Util.SetMaxUsers( 1, "PLANT_.*" );

	MapRoutes =
	{
		DEFEND_s1 =
		{
			ROUTE_ally1  =
			{
				ROUTE_ally2  =
				{
					ROUTE_ally3  =
					{
						ROUTE_ally4  =
						{
						},
						ROUTE_ally5  =
						{
							ROUTE_ally6  =
							{
								ROUTE_ally7  =
								{
								},
							},
						},
					},
				},
			},
		},
	};

	MapRoutes.DEFEND_s2 = MapRoutes.DEFEND_s1;
	MapRoutes.DEFEND_s3 = MapRoutes.DEFEND_s1;
	MapRoutes.DEFEND_s4 = MapRoutes.DEFEND_s1;
	MapRoutes.BUILD_Command_Post = MapRoutes.DEFEND_s1;
	MapRoutes.CHECKPOINT_forwardspawn = MapRoutes.DEFEND_s1;
	MapRoutes.DEFEND_r1 = MapRoutes.DEFEND_s1;
	Util.Routes(MapRoutes);

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

global OnBotJoin = function( bot )
{
	bot.TargetBreakableDist = 60.0;
	bot.MaxViewDistance = 2400;
	w = bot.GetWeapon(WEAPON.KNIFE);
	w.PrimaryFire.SetDesirabilityRange(0, 48, 0.2);
};
