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

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

	Allied_Assault_Ladders_Dyno = 0,
	Allied_Assault_Ramp_Dyno = 0,
	Axis_Church_Door_Dyno = 0,
	Command_Post_Dyno = 0,

	Allied_Assault_Ladders_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ladders_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ladders_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ladders_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ladders_4" );	
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Church_1" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Church_2" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "CHECKPOINT_courtyard_flag" );

		Util.MapDebugPrint( "Allied_Assault_Ladders_Built" );
	},

	Allied_Assault_Ramp_Built = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ramp_1" );		
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ramp_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ramp_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ramp_4" );

		Util.MapDebugPrint( "Allied_Assault_Ramp_Built" );
	},

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

		Util.MapDebugPrint( "Axis_Church_Door_Built" );
	},

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

		Util.MapDebugPrint( "Command_Post_Built" );
	},

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

		Map.Allied_Assault_Ladders_Dyno += 1;
		Util.MapDebugPrint( "Allied_Assault_Ladders_Planted" );
	},

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

		Map.Allied_Assault_Ramp_Dyno += 1;
		Util.MapDebugPrint( "Allied_Assault_Ramp_Planted" );
	},

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

		Map.Axis_Church_Door_Dyno += 1;
		Util.MapDebugPrint( "Axis_Church_Door_Planted" );
	},

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

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

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

		Map.Allied_Assault_Ladders_Dyno -= 1;
		Util.MapDebugPrint( "Allied_Assault_Ladders_Defused" );
	},

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

		Map.Allied_Assault_Ramp_Dyno -= 1;
		Util.MapDebugPrint( "Allied_Assault_Ramp_Defused" );
	},

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

		Map.Axis_Church_Door_Dyno -= 1;
		Util.MapDebugPrint( "Axis_Church_Door_Defused" );
	},

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

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

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

		Map.Allied_Assault_Ladders_Dyno = 0;

		Util.MapDebugPrint( "Allied_Assault_Ladders_Destroyed" );
	},

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

		Map.Allied_Assault_Ramp_Dyno = 0;

		Util.MapDebugPrint( "Allied_Assault_Ramp_Destroyed" );
	},

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

		Map.Axis_Church_Door_Dyno = 0;

		Util.MapDebugPrint( "Axis_Church_Door_Destroyed" );
	},

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

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

	secret_Map_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Route_1" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Route_2" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Route_3" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Route_4" );
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_Route_5" );

		Util.MapDebugPrint( "secret_Map_Taken" );
	},

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

		Util.MapDebugPrint( "secret_Map_Returned" );
	},

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

		Util.MapDebugPrint( "secret_Map_Secured" );
	},

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

		Util.MapDebugPrint( "courtyard_flag_Axis_Captured" );
	},

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

		Util.MapDebugPrint( "courtyard_flag_Allies_Captured" );
	},

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

		Util.MapDebugPrint( "meadow_flag_Axis_Captured" );
	},

	meadow_flag_Allies_Captured = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Assault_Ladders_1" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Assault_Ladders_2" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Assault_Ladders_3" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Assault_Ladders_4" );
      SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Allied_Assault_Ramp" );	

		Util.MapDebugPrint( "meadow_flag_Allies_Captured" );
	},
	
	Find_Secret_Map = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Church_1" );
	SetAvailableMapGoals( TEAM.ALLIES, true, "DEFEND_Church_2" );	
	SetAvailableMapGoals( TEAM.ALLIES, true, "FLAG_secret_Map" );
	SetAvailableMapGoals( TEAM.AXIS, false, "CHECKPOINT_meadow_flag" );
	SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Allied_Assault_Ladders" );

		Util.MapDebugPrint( "Find_Secret_Map" );
	},

};

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

	// Register callback functions
	OnTrigger( "The Allied Assault Ladders has been constructed.", Map.Allied_Assault_Ladders_Built );
	OnTrigger( "The Allied Assault Ramp has been constructed.", Map.Allied_Assault_Ramp_Built );
	OnTrigger( "The Axis Church Door has been constructed.", Map.Axis_Church_Door_Built );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Built );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Allied_Assault_Ladders_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Allied_Assault_Ramp_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Axis_Church_Door_Planted );
	OnTrigger( "Planted at the MISSING_STRING.", Map.Command_Post_Planted );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Allied_Assault_Ladders_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Allied_Assault_Ramp_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Axis_Church_Door_Defused );
	OnTrigger( "Defused at the MISSING_STRING.", Map.Command_Post_Defused );
	OnTrigger( "MISSING_STRING", Map.Allied_Assault_Ladders_Destroyed );
	OnTrigger( "The Allied Assault Ramp has been DESTROYED!", Map.Allied_Assault_Ramp_Destroyed );
	OnTrigger( "The Axis Church Door has been DESTROYED!", Map.Axis_Church_Door_Destroyed );
	OnTrigger( "MISSING_STRING", Map.Command_Post_Destroyed );
	OnTrigger( "Allies have stolen secret Map!", Map.secret_Map_Taken );
	OnTrigger( "Axis have returned secret Map!", Map.secret_Map_Returned );
	OnTrigger( "Allies has secured the Secret Map", Map.secret_Map_Secured );
	OnTrigger( "MISSING_STRING", Map.courtyard_flag_Axis_Captured );
	OnTrigger( "MISSING_STRING", Map.courtyard_flag_Allies_Captured );
	OnTrigger( "The Axis have captured the Meadow !!!!!", Map.meadow_flag_Axis_Captured );
	OnTrigger( "The Allies have captured the Meadow !!!!!", Map.meadow_flag_Allies_Captured );
	OnTrigger( "^4Allies:^5Find the secret Map ^1!!!!", Map.Find_Secret_Map );
	
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ladders_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ladders_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ladders_3" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Assault_Ladders_4" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Church_1" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "DEFEND_Church_2" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "FLAG_secret_Map" );
	SetAvailableMapGoals( TEAM.ALLIES, false, "CHECKPOINT_courtyard_flag" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Church_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Church_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Route_1" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Route_2" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Route_3" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Route_4" );
	SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_Route_5" );

	//~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_Axis_Church_Door =
		{
		},
		BUILD_Allied_Assault_Ladders =
		{
		},
		BUILD_Command_Post =
		{
		},
		BUILD_Allied_Assault_Ramp =
		{
		},
		PLANT_Axis_Church_Door =
		{
		},
		PLANT_Allied_Assault_Ladders =
		{
		},
		PLANT_Command_Post =
		{
		},
		PLANT_Allied_Assault_Ramp =
		{
		},
		FLAG_secret_Map =
		{
		},
		CHECKPOINT_meadow_flag =
		{
		},
		CHECKPOINT_courtyard_flag =
		{
		},
	};
	Util.Routes(MapRoutes);
};
