//==========================================================================================
//
//	adlernest_roof_b4.gm
//
//	Who                    	When		What
//------------------------------------------------------------------------------------------
//	^1{WeB}^7*^4GA^1NG$^4TA^7*	02 September 2015	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 1, // please set to zero before distributing your script
	ShowMovers = false,

	Allied_CP_Dyno = 0,
	Axis_CP_Dyno = 0,
	Door_controls_Dyno = 0,
	Tunnel_Barrier_Dyno = 0,

	Allied_CP_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Allied_CP_Built" );
	},

	Axis_CP_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Axis_CP_Built" );
	},

	Tunnel_Barrier_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Tunnel_Barrier_Built" );
	},

	Allied_CP_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Allied_CP_Dyno += 1;
		Util.MapDebugPrint( "Allied_CP_Planted" );
	},

	Axis_CP_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Axis_CP_Dyno += 1;
		Util.MapDebugPrint( "Axis_CP_Planted" );
	},

	Door_controls_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Door_controls_Dyno += 1;
		Util.MapDebugPrint( "Door_controls_Planted" );
	},

	Tunnel_Barrier_Planted = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Tunnel_Barrier_Dyno += 1;
		Util.MapDebugPrint( "Tunnel_Barrier_Planted" );
	},

	Allied_CP_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Allied_CP_Dyno -= 1;
		Util.MapDebugPrint( "Allied_CP_Defused" );
	},

	Axis_CP_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Axis_CP_Dyno -= 1;
		Util.MapDebugPrint( "Axis_CP_Defused" );
	},

	Door_controls_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Door_controls_Dyno -= 1;
		Util.MapDebugPrint( "Door_controls_Defused" );
	},

	Tunnel_Barrier_Defused = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Tunnel_Barrier_Dyno -= 1;
		Util.MapDebugPrint( "Tunnel_Barrier_Defused" );
	},

	Allied_CP_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Allied_CP_Dyno = 0;

		Util.MapDebugPrint( "Allied_CP_Destroyed" );
	},

	Axis_CP_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Axis_CP_Dyno = 0;

		Util.MapDebugPrint( "Axis_CP_Destroyed" );
	},

	Door_controls_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_transmitter" );
	    SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_documents" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_CP" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Allied_CP" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Tunnel_Barrier" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Door_controls_1" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Door_controls_2" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Door_controls_3" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Door_controls_4" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Door_controls_5" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Door_controls_6" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Door_controls_7" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Door_controls_8" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Door_controls_9" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Door_controls_10" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Axis_CP" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_1" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_2" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_3" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_4" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_5" );
		

		Map.Door_controls_Dyno = 0;

		Util.MapDebugPrint( "Door_controls_Destroyed" );
	},

	Tunnel_Barrier_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }

		Map.Tunnel_Barrier_Dyno = 0;

		Util.MapDebugPrint( "Tunnel_Barrier_Destroyed" );
	},

	documents_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_main_blast_door" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_1" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_2" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_3" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_4" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_5" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Transmitter_1" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Transmitter_2" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Transmitter_3" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Transmitter_5" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Transmitter_1" );
	    SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Transmitter_2" );
	    SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Transmitter_3" );
	    SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Transmitter_5" );

		Util.MapDebugPrint( "documents_Taken" );
	},

	documents_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_1" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_2" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_3" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_5" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_1" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_2" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_3" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_4" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Docs_5" );

		Util.MapDebugPrint( "documents_Returned" );
	},

	documents_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_main_blast_door" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Allied_CP" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_CP" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_CP" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_main_blast_door" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_transmitter" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_documents" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Transmitter_1" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Transmitter_2" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Transmitter_3" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Transmitter_5" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_Launch_Missile" );
	    SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_Activate_Radar" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_radar_1" );
	    SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_radar_2" );
	    SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_radar_3" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_radar_1" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_radar_2" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_radar_3" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_radar_4" );
	    SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_radar_5" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_1" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_2" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_3" );
	    SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_5" );
		ETUtil.SuicideSpawn( TEAM.AXIS, 0 );
		ETUtil.SuicideSpawn( TEAM.ALLIES, 0 );

		Util.MapDebugPrint( "documents_Secured" );
	},
	
		Door_Open = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_main_blast_door" );
		SetAvailableMapGoals( TEAM.AXIS, true, "SWITCH_main_blast_door" );

		Util.MapDebugPrint( "Door_Open" );
	},
	
			Door_Close = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_main_blast_door" );
		SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_main_blast_door" );

		Util.MapDebugPrint( "Door_Close" );
	},
	
			missile_Launched = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Launch_Missile" );

		Util.MapDebugPrint( "missile_Launched" );
	},
	
			Transmission_Active = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Activate_Radar" );
		SetAvailableMapGoals( TEAM.AXIS, true, "SWITCH_Activate_Radar" );

		Util.MapDebugPrint( "Transmission_Active" );
	},
	
			Transmission_Inactive = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_Activate_Radar" );
		SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_Activate_Radar" );

		Util.MapDebugPrint( "Transmission_Inactive" );
	},

};

global OnMapLoad = function()
{
	if ( TestMapOn )
		{ Util.AutoTestMap(); }

	// Register callback functions
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_CP_Built );
	OnTrigger( "^3Axis must interrupt the transmission!", Map.Transmission_Active );
	OnTrigger( "^3Axis have interrupted the transmission!", Map.Transmission_Inactive );
	OnTrigger( "MISSING_STRING", Map.Axis_CP_Built );
	OnTrigger( "MISSING_STRING", Map.Tunnel_Barrier_Built );
	OnTrigger( "^1THE MISSILE HAS BEEN LAUNCHED!", Map.missile_Launched );
	OnTrigger( "Planted at the Allied CP.", Map.Allied_CP_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Axis_CP_Planted );
	OnTrigger( "Planted at the Door controls.", Map.Door_controls_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Tunnel_Barrier_Planted );
	OnTrigger( "Defused at the Allied CP.", Map.Allied_CP_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Axis_CP_Defused );
	OnTrigger( "Defused at the Door controls.", Map.Door_controls_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Tunnel_Barrier_Defused );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_CP_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Axis_CP_Destroyed );
	OnTrigger( "The Doors are opening!!", Map.Door_controls_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Tunnel_Barrier_Destroyed );
	OnTrigger( "Main blast door opening!", Map.Door_Open );
	OnTrigger( "Main blast door closing!", Map.Door_Close );
	OnTrigger( "Allies have stolen the documents!", Map.documents_Taken );
	OnTrigger( "Flag returned documents!", Map.documents_Returned );
	OnTrigger( "The documents have been delivered!", Map.documents_Secured );
	
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Door_controls" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tunnel_Barrier" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Door_controls_1" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Door_controls_2" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Door_controls_3" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Door_controls_4" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Door_controls_5" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Door_controls_6" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Door_controls_7" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Door_controls_8" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Door_controls_9" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Door_controls_10" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Allied_CP" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_main_blast_door" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_transmitter" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_documents" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_123" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_799" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_CP" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Launch_Missile" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Activate_Radar" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Transmitter_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Transmitter_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Transmitter_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Transmitter_5" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_radar_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_radar_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_radar_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_Activate_Radar" );
	SetAvailableMapGoals( TEAM.AXIS, false, "SWITCH_main_blast_door" );
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Tunnel_Barrier" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Docs_5" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Transmitter_5" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_radar_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_radar_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_radar_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_radar_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_radar_5" );
	
	SetGoalPriority( "PLANT_Door_controls", 0.91 );
	SetGoalPriority( "SWITCH_Activate_Radar", 0.91 );
	SetGoalPriority( "SWITCH_Launch_Missile", 0.91 );
	
	
	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );

	// Max users per goal
	//Util.SetMaxUsers( 1, "DEFEND_.*" );
	//Util.SetMaxUsers( 1, "GRENADE_.*" );
	//Util.SetMaxUsers( 1, "MOUNTMG42_.*" );

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


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

global OnBotJoin = function( bot )
{
	   bot.TargetBreakableDist = 60;
	
	// Only set MaxViewDistance on maps with limited sight (e.g. fog)
	//~bot.MaxViewDistance = 2400;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Axis_CP =
		{
		},
		BUILD_Allied_CP =
		{
		},
		BUILD_Tunnel_Barrier =
		{
		},
		PLANT_Door_controls =
		{
		},
		PLANT_Axis_CP =
		{
		},
		PLANT_Allied_CP =
		{
		},
		PLANT_Tunnel_Barrier =
		{
		},
		FLAG_documents =
		{
		},
	};
	Util.Routes(MapRoutes);
};
