//==========================================================================================
//
//	syphonfilter.gm
//
//	Who              	When		What
//------------------------------------------------------------------------------------------
//	^1W^4OLF ^1E^4NSTEIN	19 February 2019	Initial Script
//
//==========================================================================================
//

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

	Command_Post_Dyno = 0,

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

		Util.MapDebugPrint( "Command_Post_Built" );
	},

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

		Map.Command_Post_Dyno += 1;
		Util.MapDebugPrint( "Command_Post_Planted" );
	},

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

		Map.Command_Post_Dyno -= 1;
		Util.MapDebugPrint( "Command_Post_Defused" );
	},

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

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	docs_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.ALLIES, true, "CAPPOINT_truck" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_4" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_4" );

		Util.MapDebugPrint( "docs_Taken" );
	},

	key1_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.ALLIES, true, "SWITCH_Lab_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_2" );

		Util.MapDebugPrint( "key1_Taken" );
	},

	docs_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Rocket_4" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Rocket_4" );		
				

		Util.MapDebugPrint( "docs_Returned" );
	},

	key1_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
      SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_docs" );
      SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Key_1" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Key_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Lab_1" );

		Util.MapDebugPrint( "key1_Returned" );
	},

	docs_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_4" );		

		Util.MapDebugPrint( "docs_Secured" );
	},

	key1_Secured = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_2" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Rocket_4" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Rocket_4" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_docs" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Lab_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_key1" );
	
				

		Util.MapDebugPrint( "key1_Secured" );
	},
	
		Wood_Fence_Destroyed = function( trigger )
	{
	
	SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_key1" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_The_R9_Devytka" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Wooden_Fence" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Wooden_Gate_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Wooden_Gate_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Wooden_Gate_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Wooden_Gate_4" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Wooden_Gate_5" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Rocket_1" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Rocket_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Wooden_Gate_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Wooden_Gate_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Wooden_Gate_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Wooden_Gate_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Wooden_Gate_5" );
	SetAvailableMapGoals( TEAM.AXIS, true, "BUILD_Command_Post" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Command_Post_1" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Command_Post_2" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Key_1" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Key_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_2" );
	
	
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "Wood_Fence_Destroyed" );
	},
	
		The_R9_Devytka_Destroyed = function( trigger )
	{
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_The_R9_Devytka" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_4" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Key_3" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Key_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_4" );
	
		if ( TestMap )
			{ return; }

		Util.MapDebugPrint( "The_R9_Devytka_Destroyed" );
	},

};

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

	// Register callback functions
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Command_Post_Planted );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Command_Post_Defused );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Destroyed );
	OnTrigger( "^2The Agency picked up the syphonfilter virus documents!", Map.docs_Taken );
	OnTrigger( "^2The Agency picked up the Laboratory key", Map.key1_Taken );
	OnTrigger( "^2Terrorist returned the syphonfilter virus documents!", Map.docs_Returned );
	OnTrigger( "^2Terrorist returned the Armor key", Map.key1_Returned );
	OnTrigger( "^2The Agency have secured the syphonfilter virus documents!", Map.docs_Secured );
	OnTrigger( "^2Laboratory door has been opened", Map.key1_Secured );
	OnTrigger( "^2The Agency have destroyed the woodfence!", Map.Wood_Fence_Destroyed );
	OnTrigger( "^2The Agency have destroyed the R9 Devyatka!", Map.The_R9_Devytka_Destroyed );
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_docs" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_key1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_The_R9_Devytka" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Rocket_4" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "CAPPOINT_truck" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "SWITCH_Lab_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Key_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Command_Post" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Command_Post_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Command_Post_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Rocket_4" );
	
	SetGoalPriority("SWITCH_Lab_1", 0.81);
	SetGoalPriority("PLANT_The_R9_Devytka", 0.81);
	SetGoalPriority("BUILD_Command_Post", 0.81);

	//~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 )
{
	// Uncomment for shootable breakables
	//~bot.TargetBreakableDist = 90.0;
	// Only set MaxViewDistance on maps with limited sight (e.g. fog)
	//~bot.MaxViewDistance = 2400;
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		BUILD_Command_Post =
		{
		},
		PLANT_Command_Post =
		{
		},
		FLAG_key1 =
		{
		},
		FLAG_docs =
		{
		},
	};
	Util.Routes(MapRoutes);
};
