//==========================================================================================
//
//	sub_base_final.gm
//
//	Who                    	When		What
//------------------------------------------------------------------------------------------
//	^1{WeB}^7*^4GA^1NG$^4TA^7*	21 July 2015	Initial Script
//
//==========================================================================================
//

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

	Allied_Bunker_Defenses_Dyno = 0,
	Command_Post_Dyno = 0,
	Rear_Entrance_Dyno = 0,

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

		Util.MapDebugPrint( "Allied_Bunker_Defenses_Built" );
	},

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

		Util.MapDebugPrint( "Command_Post_Built" );
	},

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

		Map.Allied_Bunker_Defenses_Dyno += 1;
		Util.MapDebugPrint( "Allied_Bunker_Defenses_Planted" );
	},

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

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

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

		Map.Rear_Entrance_Dyno += 1;
		Util.MapDebugPrint( "Rear_Entrance_Planted" );
	},

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

		Map.Allied_Bunker_Defenses_Dyno -= 1;
		Util.MapDebugPrint( "Allied_Bunker_Defenses_Defused" );
	},

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

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

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

		Map.Rear_Entrance_Dyno -= 1;
		Util.MapDebugPrint( "Rear_Entrance_Defused" );
	},

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

		Map.Allied_Bunker_Defenses_Dyno = 0;

		Util.MapDebugPrint( "Allied_Bunker_Defenses_Destroyed" );
	},

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

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

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

		Map.Rear_Entrance_Dyno = 0;

		Util.MapDebugPrint( "Rear_Entrance_Destroyed" );
	},

	radarbox1_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_enigma_1" );
	    SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_enigma_2" );	

		Util.MapDebugPrint( "radarbox1_Taken" );
	},

	radarbox1_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_enigma_1" );
	    SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_enigma_2" );	

		Util.MapDebugPrint( "radarbox1_Returned" );
	},

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

		Util.MapDebugPrint( "radarbox1_Secured" );
	},

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

		Util.MapDebugPrint( "roadbunker_Axis_Captured" );
	},

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

		Util.MapDebugPrint( "roadbunker_Allies_Captured" );
	},

};

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

	// Register callback functions
	OnTrigger( "The Allies have fortified the Bunker", Map.Allied_Bunker_Defenses_Built );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Allied_Bunker_Defenses_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Command_Post_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Rear_Entrance_Planted );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Allied_Bunker_Defenses_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Command_Post_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Rear_Entrance_Defused );
	OnTrigger( "Axis have breached the Bunker Entrance", Map.Allied_Bunker_Defenses_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Destroyed );
	OnTrigger( "Axis have destroyed the Rear Door", Map.Rear_Entrance_Destroyed );
	OnTrigger( "Axis have stolen the Enigma Machine!", Map.radarbox1_Taken );
	OnTrigger( "Allies have returned the Enigma Machine!", Map.radarbox1_Returned );
	OnTrigger( "MISSING_STRING", Map.radarbox1_Secured );
	OnTrigger( "MISSING_STRING", Map.roadbunker_Axis_Captured );
	OnTrigger( "MISSING_STRING", Map.roadbunker_Allies_Captured );
	
	SetGoalPriority("PLANT_Road_Entrance", 0.91);
	SetGoalPriority("PLANT_Rear_Entrance", 0.81);
	SetGoalPriority("PLANT_Allied_Bunker_Defenses", 0.80);
	SetGoalPriority("PLANT_Command_Post", 0.80);
	SetGoalPriority("BUILD_Command_Post", 0.80);
	SetGoalPriority("BUILD_Allied_Bunker_Defenses", 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_Allied_Bunker_Defenses =
		{
		},
		BUILD_Command_Post =
		{
		},
		PLANT_Allied_Bunker_Defenses =
		{
		},
		PLANT_Command_Post =
		{
		},
		PLANT_Rear_Entrance =
		{
		},
		FLAG_radarbox1 =
		{
		},
		CHECKPOINT_roadbunker =
		{
		},
	};
	Util.Routes(MapRoutes);
};
