global Map =
{

	Debug = 0,

	DoorStatus = 0, //closed

	Switches =
	{
		outside =
		{
			Enabled = true,
			Priority = 0,
			WaypointName = "Outside",
			Timeout = 2000,
			AimPosition = Vec3(-1408.125, 1759.859, 45.984),
			LimitBots = 1,
		},
		inside =
		{
			Enabled = false,
			Priority = 0,
			WaypointName = "Inside",
			Timeout = 2000,
			AimPosition = Vec3(-1151.875, 1792.344, 46.182),
			LimitBots = 1,
		},
	},



	BUILD__Allied_Quick_Access_Bridge_Built = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"PLANT_Radar_1_door",
			"BUILD_Allied_Command_Post",
			"PLANT_Allied_door",
			"PLANT_Radar_2_door",
			"PLANT_Axis_tunnel_gate",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_.*" );

		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"FLAG_docscaptured",
			"CAPPOINT_.*",
		});


		Util.MapDebugPrint( "BUILD_2_Allied_Quick_Access_Bridge_Built" );
	},

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

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

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

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

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

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

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

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

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

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

	North_Radar_1_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_radar_1.*",
			"MOBILEMG42_roof1",
			"MOBILEMG42_radar1mg2",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_aux2",
			"DEFEND_aux2a",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_r1.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"MOUNTMG42_680",
			"ARTILLERY_D_rdr",
			"ARTILLERY_S_rdr",
			"CALLARTILLERY_rdr",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ARTILLERY_D_rdr",
			"ARTILLERY_S_rdr",
			"CALLARTILLERY_rdr1",
			"ATTACK_mg.*",
		});

		Util.MapDebugPrint( "North_Radar_1_Destroyed" );
	},

	Radar_1_door_Destroyed = function( trigger )
	{

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


		Util.MapDebugPrint( "Radar_1_door_Destroyed" );
	},

	Radar_2_door_Destroyed = function( trigger )
	{

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


		Util.MapDebugPrint( "Radar_2_door_Destroyed" );
	},

	South_Radar_2_Destroyed = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_radar_2.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"DEFEND_aux1",
			"DEFEND_aux1a",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_r2.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "MOBILEMG42_radar2mg" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ARTILLERY_S_radar" );
		SetAvailableMapGoals( TEAM.AXIS, false, "ARTILLERY_S_radar" );

		Util.MapDebugPrint( "South_Radar_2_Destroyed" );
	},

	docscaptured_Taken = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_alien.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_cap.*" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_cap.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANT__Allied_Quick_Access_Bridge",
			"MOUNTMG42_818",
		});

		Util.MapDebugPrint( "docscaptured_Taken" );
	},

	docscaptured_returned = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_alien.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_cap.*" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_cap.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_818" );

		Util.MapDebugPrint( "docscaptured returned" );
	},

/*

	CAPPOINT_812_Captured = function( trigger )
	{
		Util.MapDebugPrint( "CAPPOINT_812_Captured" );
	},
*/
	CAPPOINT_835_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_cap.*",
			"DEFEND_alien.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_cap.*",
			"SNIPE_spawnsnipe",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_680" );
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"PLANT__Allied_Quick_Access_Bridge",
			"PLANT_Allied_Command_Post",
			"SNIPE_spawn1",
			"MOUNTMG42_818",
			"PLANTMINE_al.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_mg.*" );



		Util.MapDebugPrint( "CAPPOINT_835_Captured" );
	},

	CAPPOINT_843_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.AXIS, false, {
			"DEFEND_cap.*",
			"DEFEND_alien.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_cap.*",
			"SNIPE_spawnsnipe",
		});
		SetAvailableMapGoals( TEAM.AXIS, true, "MOUNTMG42_680" );
		Util.MapDebugPrint( "CAPPOINT_843_Captured" );
	},

	door_open = function(trigger)
	{

		vel = ToVector(trigger.Action);

		if ( vel.z > 0 )
		{



				Map.Switches.inside.Enabled = false;
				Map.Switches.outside.Enabled = false;
				sleep(1.5);  //wait 1.5 seconds while the door is opening
				SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_tunnel_gate" );
				Map.DoorStatus = 1;
				Util.MapDebugPrint( "Open" );
		}

		else if ( vel.z < 0 )
		{
				Map.Switches.inside.Enabled = true;
				Map.Switches.outside.Enabled = true;
				Map.DoorStatus = 0;
				Util.MapDebugPrint("^1Closed");
		}


	},





};

global OnMapLoad = function()
{
	OnTrigger( "Allied have built the Allied Spawn Bridge!", Map.BUILD__Allied_Quick_Access_Bridge_Built );
	OnTrigger( "MISSING_STRING", Map.Allied_Command_Post_Built );
	OnTrigger( "MISSING_STRING", Map.Allied_MG42_Construction_Built );
	OnTrigger( "MISSING_STRING", Map.Axis_MG42_Construction_Built );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );
	OnTrigger( "MISSING_STRING", Map.PLANT__Allied_Quick_Access_Bridge_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Allied_MG42_Construction_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Axis_MG42_Construction_Destroyed );
	OnTrigger( "The Allies have destroyed the Axis tunnel gate!", Map.Axis_tunnel_gate_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Destroyed );
	OnTrigger( "Allied team has disabled the North Radar 1!", Map.North_Radar_1_Destroyed );
	OnTrigger( "^1Allied have blown Radar 1 door!!", Map.Radar_1_door_Destroyed );
	OnTrigger( "^1Allied have blown Radar 2 door!!", Map.Radar_2_door_Destroyed );
	OnTrigger( "Allied team has disabled the South Radar!", Map.South_Radar_2_Destroyed );
	OnTrigger( "Allies have stolen the Baby Alien!", Map.docscaptured_Taken );
	OnTrigger( "Flag returned docscaptured!", Map.docscaptured_returned );
	OnTrigger( "Allies have transmitted the documents!", Map.CAPPOINT_835_Captured );
	OnTrigger( "base_lever1_goto", Map.door_open );

	SetAvailableMapGoals( TEAM.AXIS, false, ".*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, ".*" );
	SetAvailableMapGoals( TEAM.AXIS, true, "SNIPE_spawn1" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD__Allied_Quick_Access_Bridge" );
	SetAvailableMapGoals( TEAM.AXIS, true, {
		"DEFEND_radar.*",
		"MOBILEMG42_roof1",
		"MOBILEMG42_radar1mg2",
		"DEFEND_alien.*",
		"HEALTHCAB_.*",
		"ARTILLERY_D_rdr",
		"ARTILLERY_S_rdr",
		"CALLARTILLERY_rdr",
		"ARTILLERY_S_radar",
		"CALLARTILLERY_axis1",
		"AMMOCAB_.*",
		"PLANT__Allied_Quick_Access_Bridge",
		"MOBILEMG42_radar2mg",
		"MOUNTMG42_818",
		"PLANTMINE_al.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"HEALTHCAB_.*",
		"AMMOCAB_.*",
		"ATTACK_r1.*",
		"ATTACK_r2.*",
		"ARTILLERY_D_rdr",
		"ARTILLERY_S_rdr",
		"ARTILLERY_S_radar",
		"CALLARTILLERY_rdr1",
		"CALLARTILLERY_allied1",
	});


	Util.SetMaxUsersInProgress( 1, "DEFEND_.*" );
	Util.SetMaxUsersInProgress( 1, "PLANT_.*" );
	Util.SetMaxUsersInProgress( 1, "BUILD_.*" );
	Util.SetMaxUsersInProgress( 1, "MOUNT_.*" );
	Util.SetMaxUsersInProgress( 1, "ATTACK_.*" );
	Util.SetMaxUsersInProgress( 1, "MOUNTMG42_.*" );

	Util.SetGoalPosition( -598,2035,32.1, "PLANT_Axis_tunnel_gate" );
	Util.SetGoalPosition( 1093,1831,404, "MOBILEMG42_radar1mg2" );
	Util.SetGoalPosition( -3100,1529,-168, "DEFEND_cap4" );
	Util.SetGoalPosition( -3037,940,-168, "DEFEND_cap2" );
	Util.SetGoalPosition( -3655,744,-168, "DEFEND_cap1" );
	Util.SetGoalPosition( 1434.5,269,344, "ATTACK_r2a" );
	SetMapGoalProperties( "DEFEND_.*", {mincamptime=25, maxcamptime=90} );
	SetMapGoalProperties( "MOUNT_.*", {mincamptime=15, maxcamptime=40} );
	SetMapGoalProperties( "MOBILEMG42_.*", {mincamptime=25, maxcamptime=90} );
	SetMapGoalProperties( "ATTACK_.*", {mincamptime=25, maxcamptime=90} );
	SetMapGoalProperties( "CAMP_.*", {mincamptime=35, maxcamptime=90} );

//~	SetGoalPriority( "DEFEND_cap.*", 0.99 );
//~	SetGoalPriority( "DEFEND_alien.*", 0.99 );
	SetGoalPriority( "PLANT_Axis_tunnel_gate", 0.95 );
    SetGoalPriority( "PLANT_Allied_door", 0.93 );

	Map.Switches.outside.Enabled = true;
	Map.Switches.inside.Enabled = false;
	Util.UpdateSwitchData();

	Util.MapDebugPrint( "OnMapLoad" );
};


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