//==========================================================================================
//
//	2hide.gm
//
//	Who			When		What
//------------------------------------------------------------------------------------------
//  MickyP
//
//==========================================================================================
//

global Map =
{
	Ammo_Cabinet_north_ammocabinet = "AMMOCAB_north_ammocabinet",
	Ammo_Cabinet_south_ammocabinet = "AMMOCAB_south_ammocabinet",
	Health_Cabinet_north_healthcabinet = "HEALTHCAB_north_healthcabinet",
	Health_Cabinet_south_healthcabinet = "HEALTHCAB_south_healthcabinet",
	Checkpoint_roadbunker = "CHECKPOINT_roadbunker",
	Flag_radarbox1 = "FLAG_radarbox1",
	Flag_secretdocs = "FLAG_secretdocs",
	Cappoint_detbatcap = "CAPPOINT_detbatcap",
	Cappoint_doccap = "CAPPOINT_doccap",
	Build_Big_Gun_MG = "BUILD_Big_Gun_MG",
	Build_Command_Post = "BUILD_Command_Post",
	Build_Door_Lock = "BUILD_Door_Lock",
	Build_High_Guardhouse = "BUILD_High_Guardhouse",
	Build_Schutzschild = "BUILD_Schutzschild",
	Plant_Big_Gun = "PLANT_Big_Gun",
	Plant_Big_Gun_MG = "PLANT_Big_Gun_MG",
	Plant_Command_Post = "PLANT_Command_Post",
	Plant_Door_Lock = "PLANT_Door_Lock",
	Plant_High_Guardhouse = "PLANT_High_Guardhouse",
	Plant_Schutzschild = "PLANT_Schutzschild",
	Plant_Side_Gate = "PLANT_Side_Gate",
	Plant_Wall = "PLANT_Wall",
	Mount_Big_Gun_MG = "MOUNTMG42_Big_Gun_MG",
	Mount_High_Guardhouse = "MOUNTMG42_High_Guardhouse",
	Mount_HillTop_1 = "MOUNTMG42_HillTop_1",
	Mount_HillTop_2 = "MOUNTMG42_HillTop_2",
	Mount_Rear_Facing = "MOUNTMG42_Rear_Facing",
	Mount_Schutzschild = "MOUNTMG42_Schutzschild",
	Mount_Truck = "MOUNTMG42_Truck",
	Mount_bunker_G2 = "MOUNTMG42_bunker_G2",
	Mount_gun_G2 = "MOUNTMG42_gun_G2",
	Repair_Big_Gun_MG = "REPAIRMG42_Big_Gun_MG",
	Repair_High_Guardhouse = "REPAIRMG42_High_Guardhouse",
	Repair_HillTop_1 = "REPAIRMG42_HillTop_1",
	Repair_HillTop_2 = "REPAIRMG42_HillTop_2",
	Repair_Rear_Facing = "REPAIRMG42_Rear_Facing",
	Repair_Schutzschild = "REPAIRMG42_Schutzschild",
	Repair_Truck = "REPAIRMG42_Truck",
	Repair_bunker_G2 = "REPAIRMG42_bunker_G2",
	Repair_gun_G2 = "REPAIRMG42_gun_G2",

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

	lock_box_Built = function()
	{

		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Door_Lock" );
//		Wp.SetWaypointFlag( "lockdoor1", "axis", true );
//		Wp.SetWaypointFlag( "lockdoor2", "axis", true );
//		Removed due to Map error - repairing lock does not fix anything

		Util.MapDebugPrint( "lock_box_Built" );
	},

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

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

	gun_build_Built = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"BUILD_Big_Gun_MG",
			"DEFEND_gun_G1",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"MOUNTMG42_Big_Gun_MG",
			"REPAIRMG42_Big_Gun_MG",
		});

		Util.MapDebugPrint( "gun_build_Built" );
	},

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

	lock_box_Destroyed = function()
	{
		Wp.SetWaypointFlag( "lockdoor1", "axis", false );
		Wp.SetWaypointFlag( "lockdoor2", "axis", false );

		Util.MapDebugPrint( "lock_box_Destroyed" );
	},

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

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

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

	side_gate_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANT_Side_Gate",
			"ATTACK_side.*",
		});
		Util.MapDebugPrint( "side_gate_Destroyed" );
	},

	wall_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANT_Wall",
			"ATTACK_wall.*",
		});

		Util.MapDebugPrint( "wall_Destroyed" );
	},

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

	gun_build_Destroyed = function()
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_Big_Gun_MG",
			"REPAIRMG42_Big_Gun_MG",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_gun_G1",
			"BUILD_Big_Gun_MG",
		});
		Util.MapDebugPrint( "gun_build_Destroyed" );
	},

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

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

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

	detonator_charged = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_detbatcap" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_doccap" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_detwait.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_dynowall" );

		Util.MapDebugPrint( "detonator_charged" );
	},

	biggun_open = function()
	{
		Wp.SetWaypointFlag( "gundoor1", "axis", false );
		Wp.SetWaypointFlag( "gundoor2", "axis", false );

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

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"CAPPOINT_doccap",
			"FLAG_secretdocs",
		});
		Util.MapDebugPrint( "biggun_open" );
	},

	keycode_taken = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_gun.*" );
		Util.MapDebugPrint( "keycode_taken" );
	},

	keycode_returned = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_gun.*" );
		Util.MapDebugPrint( "keycode_returned" );
	},

	battery_taken = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_town.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"DEFEND_Flag.*",
			"MOUNTMG42_Rear_Facing",
			"REPAIRMG42_Rear_Facing",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_gate.*",
			"DEFEND_lock.*",
			"DEFEND_wall.*",
			"MOUNTMG42_bunker_G2",
			"REPAIRMG42_bunker_G2",
			"BUILD_High_Guardhouse",
			"CHECKPOINT_roadbunker",
			"MOUNTMG42_High_Guardhouse",
			"REPAIRMG42_High_Guardhouse",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_town.*",
			"BUILD_Schutzschild",
			"MOUNTMG42_Schutzschild",
			"REPAIRMG42_Schutzschild",
		});
		Util.MapDebugPrint( "battery_taken" );
	},

	battery_returned = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"DEFEND_Flag.*",
			"MOUNTMG42_Rear_Facing",
			"REPAIRMG42_Rear_Facing",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_gate.*",
			"DEFEND_lock.*",
			"DEFEND_wall.*",
			"MOUNTMG42_bunker_G2",
			"REPAIRMG42_bunker_G2",
			"BUILD_High_Guardhouse",
			"CHECKPOINT_roadbunker",
			"MOUNTMG42_High_Guardhouse",
			"REPAIRMG42_High_Guardhouse",
		});
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_town.*",
			"MOUNTMG42_Schutzschild",
		});
		Util.MapDebugPrint( "battery_returned" );
	},

	battery_armed = function()
	{

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_gate.*",
			"DEFEND_lock.*",
			"DEFEND_wall.*",
			"MOUNTMG42_bunker_G2",
			"REPAIRMG42_bunker_G2",
			"BUILD_High_Guardhouse",
			"CHECKPOINT_roadbunker",
			"MOUNTMG42_High_Guardhouse",
			"REPAIRMG42_High_Guardhouse",
			"MOUNTMG42_Schutzschild",
			"BUILD_Schutzschild",
			"DEFEND_town.*",
			"AMMOCAB_south_ammocabinet.*",
			"HEALTHCAB_south_healthcabinet",
			"DEFEND_bunker.*",
			"MOUNTMG42_Schutzschild",
			"REPAIRMG42_Schutzschild",
			"BUILD_Schutzschild",
			"PLANT_Command_Post",
			"BUILD_Command_Post",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_gun.*",
			"MOUNTMG42_gun_G2",
			"REPAIRMG42_gun_G2",
			"BUILD_Big_Gun_MG",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"PLANT_Door_Lock",
			"PLANT_Wall",
			"PLANT_Side_Gate",
			"AMMOCAB_north_ammocabinet.*",
			"HEALTHCAB_north_healthcabinet",
			"FLAG_radarbox1",
			"GRENADE_Obj_box.*",
			"DEFEND_Flag.*",
			"MOUNTMG42_Rear_Facing",
			"REPAIRMG42_Rear_Facing",
		});

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"AMMOCAB_south_ammocabinet.*",
			"HEALTHCAB_south_healthcabinet",
			"PLANT_Command_Post",
			"BUILD_Command_Post",
			"DEFEND_detwait.*",
			"AMMOCAB_south_ammocabinet.*",
			"HEALTHCAB_south_healthcabinet",
		});

		Util.MapDebugPrint( "battery_armed" );
	},

 	Allies_Capture_Flag = function()
 	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"GRENADE_Obj_box.*",
			"DEFEND_Flag.*",
			"MOUNTMG42_Rear_Facing",
			"REPAIRMG42_Rear_Facing",
		});

		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"AMMOCAB_north_ammocabinet.*",
			"HEALTHCAB_north_healthcabinet",
			"ATTACK_wall.*",
			"ATTACK_side.*",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"CHECKPOINT_roadbunker",
			"PLANT_Command_Post",
			"BUILD_Command_Post",
		});

		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_gate.*",
			"DEFEND_lock.*",
			"DEFEND_wall.*",
			"MOUNTMG42_bunker_G2",
			"REPAIRMG42_bunker_G2",
			"BUILD_High_Guardhouse",
			"MOUNTMG42_High_Guardhouse",
			"REPAIRMG42_High_Guardhouse",
		});

 		Util.MapDebugPrint( "Allies_Capture_Flag" );
 	},

 	Axis_Capture_Flag = function()
 	{
		SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_Obj_box.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"AMMOCAB_north_ammocabinet.*",
			"HEALTHCAB_north_healthcabinet",
		});

		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_gate.*",
			"DEFEND_lock.*",
			"DEFEND_wall.*",
			"MOUNTMG42_bunker_G2",
			"REPAIRMG42_bunker_G2",
			"BUILD_High_Guardhouse",
			"CHECKPOINT_roadbunker",
			"MOUNTMG42_High_Guardhouse",
			"REPAIRMG42_High_Guardhouse",
		});

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

 		Util.MapDebugPrint( "Axis_Capture_Flag" );
 	},

	Crate_Exploded = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_radarbox1" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_Obj_box.*" );
		Util.MapDebugPrint( "Crate_Exploded" );
	},

	Detonator_Used = function()
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_secretdocs" );
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"SWITCH_dynowall",
			"ATTACK_town.*",
			"DEFEND_detwait.*",
		});

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

global OnMapLoad = function()
{
	OnTrigger( "The Schutzschild have been built.", Map.town_shoot_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.allied_compost_built_Built );
	OnTrigger( "The side gate door lock has been repaired.", Map.lock_box_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.axis_compost_built_Built );
	OnTrigger( "The Big Gun MG have been built.", Map.gun_build_Built );
	OnTrigger( "The Schutzschild have been destroyed!", Map.town_shoot_Destroyed );
	OnTrigger( "Allies have destroyed the side gate!", Map.side_gate_Destroyed );
	OnTrigger( "The side gate door lock has been destroyed.", Map.lock_box_Destroyed );
	OnTrigger( "The Big Gun MG have been destroyed!", Map.gun_build_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.allied_compost_built_Destroyed );
	OnTrigger( "Allies have destroyed the the Wall!", Map.wall_Destroyed );
	OnTrigger( "Allies have destroyed the Big Gun!", Map.gun_Destroyed );
 	OnTrigger( "Allies capture the Forward Bunker!", Map.Allies_Capture_Flag );
 	OnTrigger( "Axis reclaim the Forward Bunker!", Map.Axis_Capture_Flag );
	OnTrigger( "The high Guardtower have been built.", Map.Guardtower_Built );
	OnTrigger( "The high Guardtower have been destroyed!", Map.Guardtower_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.axis_compost_built_Destroyed );
	OnTrigger( "The detonator is now charged!", Map.detonator_charged );
	OnTrigger( "The Big Gun is now unsecured and can be destroyed!", Map.biggun_open );
	OnTrigger( "Allies has taken the Key-Code Documents!", Map.keycode_taken );
	OnTrigger( "Axis has secured the Key-Code Documents!", Map.keycode_returned );
	OnTrigger( "Allies has taken the Detonator Battery!", Map.battery_taken );
	OnTrigger( "Allies have armed the Train Dynamite Detonator!", Map.battery_armed );
	OnTrigger( "Axis has secured the Detonator Battery!", Map.battery_returned );
	OnTrigger( "GRENADE_Obj_box_1 Exploded.", Map.Crate_Exploded );
	OnTrigger( "GRENADE_Obj_box_2 Exploded.", Map.Crate_Exploded );
	OnTrigger( "dyna_lever_Moving", Map.Detonator_Used );

	Util.DisableGoal(".*");

	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"PLANT_Wall",
		"PLANT_Side_Gate",
		"CHECKPOINT_roadbunker",
		"PLANT_Door_Lock.*",
		"CAPPOINT_detbatcap",
		"ROUTE.*",
		"AMMOCAB_north_ammocabinet.*",
		"HEALTHCAB_north_healthcabinet",
		"ATTACK_wall.*",
		"ATTACK_side.*",
	});

	SetAvailableMapGoals( TEAM.AXIS, true, {
		"DEFEND_gate.*",
		"DEFEND_lock.*",
		"DEFEND_wall.*",
		"MOUNTMG42_bunker_G2",
		"REPAIRMG42_bunker_G2",
		"BUILD_High_Guardhouse",
		"CHECKPOINT_roadbunker",
		"MOUNTMG42_High_Guardhouse",
		"REPAIRMG42_High_Guardhouse",
		"ROUTE.*",
	});

	Wp.SetWaypointFlag( "gundoor1", "axis", true );
	Wp.SetWaypointFlag( "gundoor2", "axis", true );
	Wp.SetWaypointFlag( "lockdoor1", "axis", true );
	Wp.SetWaypointFlag( "lockdoor2", "axis", true );

	Util.SetMaxUsersInProgress( 1, "MOUNTMG42.*" );
	Util.SetMaxUsersInProgress( 1, "DEFEND_gate_1" );
	Util.SetMaxUsersInProgress( 1, "DEFEND_lock_1" );
	Util.SetMaxUsersInProgress( 1, "DEFEND_wall_1" );
	Util.SetMaxUsersInProgress( 1, "DEFEND_wall_2" );
	Util.SetMaxUsersInProgress( 1, "DEFEND_town.*" );
	Util.SetMaxUsersInProgress( 1, "PLANT.*" );
	Util.SetMaxUsersInProgress( 2, "ATTACK.*" );


	MapRoutes =
	{
		CHECKPOINT_roadbunker =
		{
			ROUTE_alliesspawn =
			{
				ROUTE_sidegate = {},
				ROUTE_mainwall = {},
			},
			ROUTE_town_spawn =
			{
				ROUTE_railtrack = {},
				ROUTE_churchpath = {},
			}
		},

		CAPPOINT_detbatcap =
		{
			ROUTE_bunker_spawn =
			{
				ROUTE_railtrack = {},
				ROUTE_churchpath = {},
			},
		},

		ATTACK_gun_1 =
		{
			ROUTE_town_spawn =
			{
				ROUTE_side_tunnel = {},
				ROUTE_pond_side = {},
				ROUTE_farmhouse_front = {},
			},
		},

		CAPPOINT_doccap =
		{
			ROUTE_docs =
			{
				ROUTE_side_tunnel = {},
				ROUTE_pond_side = {},
				ROUTE_farmhouse_front = {},
			},
		},
	};
	MapRoutes.ATTACK_town_1 = MapRoutes.CAPPOINT_detbatcap;
	MapRoutes.ATTACK_town_2 = MapRoutes.CAPPOINT_detbatcap;
	MapRoutes.ATTACK_town_3 = MapRoutes.CAPPOINT_detbatcap;
	MapRoutes.ATTACK_town_4 = MapRoutes.CAPPOINT_detbatcap;
	MapRoutes.ATTACK_town_5 = MapRoutes.CAPPOINT_detbatcap;
	MapRoutes.ATTACK_gun_2 = MapRoutes.ATTACK_gun_1;
	MapRoutes.ATTACK_gun_3 = MapRoutes.ATTACK_gun_1;
	MapRoutes.ATTACK_gun_4 = MapRoutes.ATTACK_gun_1;
	MapRoutes.ATTACK_gun_5 = MapRoutes.ATTACK_gun_1;
	MapRoutes.ATTACK_gun_out_1 = MapRoutes.ATTACK_gun_1;
	MapRoutes.ATTACK_gun_out_2 = MapRoutes.ATTACK_gun_1;
	MapRoutes.PLANT_Big_Gun = MapRoutes.ATTACK_gun_1;

	Util.Routes(MapRoutes);


	Util.MapDebugPrint( "OnMapLoad" );
};
global OnBotJoin = function( bot )
{

	 bot.TargetBreakableDist = 150.0;
};
