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

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

	Command_Post_Dyno = 0,
	Woodfence_Dyno = 0,

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

		Util.MapDebugPrint( "Command_Post_Built" );
	},

	Woodfence_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Woodfence" );		

		Util.MapDebugPrint( "Woodfence_Built" );
	},

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

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

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

		Map.Woodfence_Dyno += 1;
		Util.MapDebugPrint( "Woodfence_Planted" );
	},

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

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

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

		Map.Woodfence_Dyno -= 1;
		Util.MapDebugPrint( "Woodfence_Defused" );
	},

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

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	Woodfence_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Woodfence" );	

		Map.Woodfence_Dyno = 0;

		Util.MapDebugPrint( "Woodfence_Destroyed" );
	},
	
		Axis_Safe_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_docs" );	
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_Safe" );	

		Map.Axis_Safe_Dyno = 0;

		Util.MapDebugPrint( "Axis_Safe_Destroyed" );
	},
	
		V2_Launch_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_V2_Launch" );	

		Map.V2_Launch_Dyno = 0;

		Util.MapDebugPrint( "V2_Launch_Destroyed" );
	},
	
		V2_Production_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_V2_Production" );	

		Map.V2_Production_Dyno = 0;

		Util.MapDebugPrint( "V2_Production_Destroyed" );
	},

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

		Util.MapDebugPrint( "docs_Taken" );
	},

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

		Util.MapDebugPrint( "docs_Returned" );
	},

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

		Util.MapDebugPrint( "docs_Secured" );
	},

};

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

	// Register callback functions
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );
	OnTrigger( "^2Axis team has constructed the Wood Fence!", Map.Woodfence_Built );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Command_Post_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Woodfence_Planted );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Command_Post_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Woodfence_Defused );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Destroyed );
	OnTrigger( "^2The Wood Fence have been destroyed!", Map.Woodfence_Destroyed );
	OnTrigger( "^2Allies have destroyed the Safe!", Map.Axis_Safe_Destroyed );
	OnTrigger( "^2Allies have destroyed the A4b/A10 missile!", Map.V2_Launch_Destroyed );
	OnTrigger( "^2Allies have destroyed the V2 A4b/A10 A9/A10 missiles!", Map.V2_Production_Destroyed );
	OnTrigger( "^2Allies picked up the V1-V2 A4b/A10 A9/A10 Blueprints", Map.docs_Taken );
	OnTrigger( "^2Axis returned the V1-V2 A4b/A10 A9/A10 Blueprints", Map.docs_Returned );
	OnTrigger( "^2Allies secured the V1-V2 A4b/A10 A9/A10 Blueprints", Map.docs_Secured );
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_docs" );
	
	SetGoalPriority("PLANT_Axis_Safe", 0.91);
	SetGoalPriority("PLANT_Command_Post", 0.91);
	SetGoalPriority("PLANT_Generator", 0.91);
	SetGoalPriority("PLANT_V2_Launch", 0.91);
	SetGoalPriority("PLANT_V2_Production", 0.91);
	SetGoalPriority("PLANT_Woodfence", 0.81);
	SetGoalPriority("BUILD_Command_Post", 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 )
{
	// 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 =
		{
		},
		BUILD_Woodfence =
		{
		},
		PLANT_Command_Post =
		{
		},
		PLANT_Woodfence =
		{
		},
		FLAG_docs =
		{
		},
	};
	Util.Routes(MapRoutes);
};
