//==========================================================================================
//
//	armada_b2.gm
//
//	Who                    	When		What
//------------------------------------------------------------------------------------------
//	^1{WeB}^7*^4GA^1NG$^4TA^7*	05 June 2017	Initial Script
//
//==========================================================================================
//

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

	Assault_Ramp_Dyno = 0,
	Axis_MG_Dyno = 0,
	Command_Post_Dyno = 0,
	Hotel_Doors_Dyno = 0,
	South_East_Panzers_Dyno = 0,
	South_West_Panzer_Dyno = 0,

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

		Util.MapDebugPrint( "Assault_Ramp_Built" );
	},

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

		Util.MapDebugPrint( "Axis_MG_Built" );
	},

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

		Util.MapDebugPrint( "Command_Post_Built" );
	},

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

		Map.Assault_Ramp_Dyno += 1;
		Util.MapDebugPrint( "Assault_Ramp_Planted" );
	},

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

		Map.Axis_MG_Dyno += 1;
		Util.MapDebugPrint( "Axis_MG_Planted" );
	},

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

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

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

		Map.Hotel_Doors_Dyno += 1;
		Util.MapDebugPrint( "Hotel_Doors_Planted" );
	},

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

		Map.South_East_Panzers_Dyno += 1;
		Util.MapDebugPrint( "South_East_Panzers_Planted" );
	},

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

		Map.South_West_Panzer_Dyno += 1;
		Util.MapDebugPrint( "South_West_Panzer_Planted" );
	},

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

		Map.Assault_Ramp_Dyno -= 1;
		Util.MapDebugPrint( "Assault_Ramp_Defused" );
	},

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

		Map.Axis_MG_Dyno -= 1;
		Util.MapDebugPrint( "Axis_MG_Defused" );
	},

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

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

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

		Map.Hotel_Doors_Dyno -= 1;
		Util.MapDebugPrint( "Hotel_Doors_Defused" );
	},

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

		Map.South_East_Panzers_Dyno -= 1;
		Util.MapDebugPrint( "South_East_Panzers_Defused" );
	},

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

		Map.South_West_Panzer_Dyno -= 1;
		Util.MapDebugPrint( "South_West_Panzer_Defused" );
	},

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

		Map.Assault_Ramp_Dyno = 0;

		Util.MapDebugPrint( "Assault_Ramp_Destroyed" );
	},

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

		Map.Axis_MG_Dyno = 0;

		Util.MapDebugPrint( "Axis_MG_Destroyed" );
	},

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

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	Hotel_Doors_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Hotel_1" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Hotel_2" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Hotel_3" );	
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Ramp_1" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Ramp_2" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Ramp_3" );
		SetAvailableMapGoals( TEAM.AXIS, false, "BUILD_Axis_MG" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_SE_Panzers_1" );
	      SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_SE_Panzers_2" );
	      SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_SE_Panzers_3" );
	      SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_SE_Panzers_4" );
	      SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_SW_Panzer_1" );
	      SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_SW_Panzer_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_South_East_Panzers" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_South_West_Panzer" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_Assault_Ramp" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_SE_Panzers_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_SE_Panzers_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_SE_Panzers_3" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_SW_Panzer_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_SW_Panzer_2" );

		Map.Hotel_Doors_Dyno = 0;

		Util.MapDebugPrint( "Hotel_Doors_Destroyed" );
	},

	South_East_Panzers_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SE_Panzers_1" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SE_Panzers_2" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SE_Panzers_3" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SE_Panzers_4" );	
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SE_Panzers_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SE_Panzers_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SE_Panzers_3" );

		Map.South_East_Panzers_Dyno = 0;

		Util.MapDebugPrint( "South_East_Panzers_Destroyed" );
	},

	South_West_Panzer_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SW_Panzer_1" );
	      SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SW_Panzer_2" );	
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SW_Panzer_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SW_Panzer_2" );

		Map.South_West_Panzer_Dyno = 0;

		Util.MapDebugPrint( "South_West_Panzer_Destroyed" );
	},

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

		Util.MapDebugPrint( "oldcityflag_Axis_Captured" );
	},

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

		Util.MapDebugPrint( "oldcityflag_Allies_Captured" );
	},

};

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

	// Register callback functions
	OnTrigger( "The Allies have built an Assault Ramp!", Map.Assault_Ramp_Built );
	OnTrigger( "Axis MG nest constructed!", Map.Axis_MG_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Command_Post_Built );
	OnTrigger( "The Axis have destroyed the Allied assault ramp!", Map.Assault_Ramp_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis MG nest!", Map.Axis_MG_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Command_Post_Destroyed );
	OnTrigger( "Allies have breached the Hotel Doors and secured the Old City", Map.Hotel_Doors_Destroyed );
	OnTrigger( "Allies have destroyed the South-East Panzers!", Map.South_East_Panzers_Destroyed );
	OnTrigger( "Allies have destroyed the Sout-West Panzer!", Map.South_West_Panzer_Destroyed );
	OnTrigger( "Axis capture the forward spawn!", Map.oldcityflag_Axis_Captured );
	OnTrigger( "Allies capture the forward spawn!", Map.oldcityflag_Allies_Captured );
	
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Hotel_1" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Hotel_2" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Hotel_3" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Ramp_1" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Ramp_2" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Ramp_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SE_Panzers_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SE_Panzers_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SE_Panzers_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SE_Panzers_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SW_Panzer_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_SW_Panzer_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Assault_Ramp" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_South_East_Panzers" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_South_West_Panzer" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SE_Panzers_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SE_Panzers_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SE_Panzers_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SW_Panzer_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_SW_Panzer_2" );
	

	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );
	
	SetGoalPriority("PLANT_South_East_Panzers", 0.91);
	SetGoalPriority("PLANT_South_West_Panzer", 0.91);
	SetGoalPriority("BUILD_Assault_Ramp", 0.81);

	// 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_Assault_Ramp =
		{
		},
		BUILD_Axis_MG =
		{
		},
		PLANT_Hotel_Doors =
		{
		},
		PLANT_South_West_Panzer =
		{
		},
		PLANT_Command_Post =
		{
		},
		PLANT_Assault_Ramp =
		{
		},
		PLANT_Axis_MG =
		{
		},
		PLANT_South_East_Panzers =
		{
		},
		CHECKPOINT_oldcityflag =
		{
		},
	};
	Util.Routes(MapRoutes);
};
