//==========================================================================================
//
//	monte_cassino.gm
//
//	Who                    	When		What
//------------------------------------------------------------------------------------------
//	^1{WeB}^7*^4GA^1NG$^4TA^7*	16 September 2016	Initial Script
//
//==========================================================================================
//

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

	Axis_Tower_Dyno = 0,
	Command_Post_Dyno = 0,
	East_Fueltank_Dyno = 0,
	East_Ramp_Dyno = 0,
	Main_Entrance_Dyno = 0,
	Tunneldoor_Dyno = 0,
	Water_Pump_Dyno = 0,
	West_Ramp_Dyno = 0,

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

		Util.MapDebugPrint( "Axis_Tower_Built" );
	},

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

		Util.MapDebugPrint( "Command_Post_Built" );
	},

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

		Util.MapDebugPrint( "East_Fueltank_Built" );
	},

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

		Util.MapDebugPrint( "East_Ramp_Built" );
	},

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

		Util.MapDebugPrint( "Water_Pump_Built" );
	},

	West_Ramp_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "BUILD_East_Ramp" );	
		SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_dyna_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_dyna_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_dyna_3" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_dyna_4" );

		Util.MapDebugPrint( "West_Ramp_Built" );
	},

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

		Map.Axis_Tower_Dyno += 1;
		Util.MapDebugPrint( "Axis_Tower_Planted" );
	},

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

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

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

		Map.East_Fueltank_Dyno += 1;
		Util.MapDebugPrint( "East_Fueltank_Planted" );
	},

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

		Map.East_Ramp_Dyno += 1;
		Util.MapDebugPrint( "East_Ramp_Planted" );
	},

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

		Map.Main_Entrance_Dyno += 1;
		Util.MapDebugPrint( "Main_Entrance_Planted" );
	},

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

		Map.Tunneldoor_Dyno += 1;
		Util.MapDebugPrint( "Tunneldoor_Planted" );
	},

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

		Map.Water_Pump_Dyno += 1;
		Util.MapDebugPrint( "Water_Pump_Planted" );
	},

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

		Map.West_Ramp_Dyno += 1;
		Util.MapDebugPrint( "West_Ramp_Planted" );
	},

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

		Map.Axis_Tower_Dyno -= 1;
		Util.MapDebugPrint( "Axis_Tower_Defused" );
	},

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

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

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

		Map.East_Fueltank_Dyno -= 1;
		Util.MapDebugPrint( "East_Fueltank_Defused" );
	},

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

		Map.East_Ramp_Dyno -= 1;
		Util.MapDebugPrint( "East_Ramp_Defused" );
	},

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

		Map.Main_Entrance_Dyno -= 1;
		Util.MapDebugPrint( "Main_Entrance_Defused" );
	},

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

		Map.Tunneldoor_Dyno -= 1;
		Util.MapDebugPrint( "Tunneldoor_Defused" );
	},

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

		Map.Water_Pump_Dyno -= 1;
		Util.MapDebugPrint( "Water_Pump_Defused" );
	},

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

		Map.West_Ramp_Dyno -= 1;
		Util.MapDebugPrint( "West_Ramp_Defused" );
	},

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

		Map.Axis_Tower_Dyno = 0;

		Util.MapDebugPrint( "Axis_Tower_Destroyed" );
	},

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

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

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

		Map.East_Fueltank_Dyno = 0;

		Util.MapDebugPrint( "East_Fueltank_Destroyed" );
	},

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

		Map.East_Ramp_Dyno = 0;

		Util.MapDebugPrint( "East_Ramp_Destroyed" );
	},

	Main_Entrance_Destroyed = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_depot_flag" );	
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Tunneldoor" );
		SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_dyna_1" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_dyna_2" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_dyna_3" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_dyna_4" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_wall_1" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_wall_2" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_wall_3" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_wall_4" );
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Command_Post" );
		SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_gold_1" );
	     SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_gold_2" );
	     SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_gold_3" );
	     SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_gold_4" );

		Map.Main_Entrance_Dyno = 0;

		Util.MapDebugPrint( "Main_Entrance_Destroyed" );
	},

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

		Map.Tunneldoor_Dyno = 0;

		Util.MapDebugPrint( "Tunneldoor_Destroyed" );
	},

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

		Map.Water_Pump_Dyno = 0;

		Util.MapDebugPrint( "Water_Pump_Destroyed" );
	},

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

		Map.West_Ramp_Dyno = 0;

		Util.MapDebugPrint( "West_Ramp_Destroyed" );
	},

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

		Util.MapDebugPrint( "Gold_Bars1_Taken" );
	},

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

		Util.MapDebugPrint( "Gold_Bars2_Taken" );
	},

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

		Util.MapDebugPrint( "Gold_Bars1_Returned" );
	},

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

		Util.MapDebugPrint( "Gold_Bars2_Returned" );
	},

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

		Util.MapDebugPrint( "radarbox1_Secured" );
	},

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

		Util.MapDebugPrint( "radarbox2_Secured" );
	},

	depot_flag_Axis_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_radarbox1" );
	      SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_radarbox2" );

		Util.MapDebugPrint( "depot_flag_Axis_Captured" );
	},

	depot_flag_Allies_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_radarbox1" );
	      SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_radarbox2" );	

		Util.MapDebugPrint( "depot_flag_Allies_Captured" );
	},

};

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

	// Register callback functions
	OnTrigger( "Axis have the Tower constructed.", Map.Axis_Tower_Built );
	OnTrigger( "Allies have the East Fueltank constructed.", Map.East_Fueltank_Built );
	OnTrigger( "Allies have the East Ramp constructed.", Map.East_Ramp_Built );
	OnTrigger( "Allies have built the Water Pump!", Map.Water_Pump_Built );
	OnTrigger( "Allies have the West Ramp constructed.", Map.West_Ramp_Built );
	OnTrigger( "Allies have destroyed the Axis Tower.", Map.Axis_Tower_Destroyed );
	OnTrigger( "Axis have destroyed the East Fueltank.", Map.East_Fueltank_Destroyed );
	OnTrigger( "Axis have destroyed the East Ramp.", Map.East_Ramp_Destroyed );
	OnTrigger( "The Main Entrance has been breached!", Map.Main_Entrance_Destroyed );
	OnTrigger( "The Side Entrance has been breached!", Map.Tunneldoor_Destroyed );
	OnTrigger( "Axis have damaged the Water Pump!", Map.Water_Pump_Destroyed );
	OnTrigger( "Axis have destroyed the West Ramp.", Map.West_Ramp_Destroyed );
	OnTrigger( "Allies have stolen the Gold Bars 1!", Map.Gold_Bars1_Taken );
	OnTrigger( "Allies have stolen the Gold Bars 2!", Map.Gold_Bars2_Taken );
	OnTrigger( "Axis have returned the Gold Bars 1!", Map.Gold_Bars1_Returned );
	OnTrigger( "Axis have returned the Gold Bars 2!", Map.Gold_Bars2_Returned );
	OnTrigger( "MISSING_STRING", Map.radarbox1_Secured );
	OnTrigger( "MISSING_STRING", Map.radarbox2_Secured );
	OnTrigger( "Axis reclaim the Forward Bunker!", Map.depot_flag_Axis_Captured );
	OnTrigger( "Allies capture the Forward Bunker!", Map.depot_flag_Allies_Captured );
	
	SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_652" );
	SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_687" );
	SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_237" );
	SetAvailableMapGoals( TEAM.AXIS, false, "MOUNTMG42_246" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_gold_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_gold_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_gold_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_gold_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_East_Fueltank" );
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_East_Ramp" );
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_West_Ramp" );
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_West_Ramp" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_652" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_687" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_237" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "MOUNTMG42_246" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_depot_flag" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_East_Fueltank" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_East_Ramp" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "BUILD_Water_Pump" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_Tower" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Tunneldoor" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_radarbox1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_radarbox2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Axis_Tower" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "PLANT_Command_Post" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_dyna_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_dyna_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_dyna_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_dyna_4" );
	

	//~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_East_Ramp =
		{
		},
		BUILD_East_Fueltank =
		{
		},
		BUILD_Axis_Tower =
		{
		},
		BUILD_West_Ramp =
		{
		},
		BUILD_Command_Post =
		{
		},
		BUILD_Water_Pump =
		{
		},
		PLANT_Command_Post =
		{
		},
		PLANT_West_Ramp =
		{
		},
		PLANT_Tunneldoor =
		{
		},
		PLANT_East_Ramp =
		{
		},
		PLANT_Main_Entrance =
		{
		},
		PLANT_East_Fueltank =
		{
		},
		PLANT_Water_Pump =
		{
		},
		PLANT_Axis_Tower =
		{
		},
		FLAG_radarbox2 =
		{
		},
		FLAG_radarbox1 =
		{
		},
		CHECKPOINT_depot_flag =
		{
		},
	};
	Util.Routes(MapRoutes);
};
