//==========================================================================================
//
//	grotli_b3.gm
//
//	Who	When		What
//------------------------------------------------------------------------------------------
//	^2o-0._.0-o	24 April 2023	Initial Script
//
//==========================================================================================
//

global Map =
{
	Debug = 0, // please set to zero before distributing your script
	ShowMovers = false,
    Quiet = true,
    Talk = true, // Set Talk to false if you don't want the bots talking ingame	

	Command_Post_Dyno = 0,
	Main_Gate_Dyno = 0,
	Tank_Barrier_Dyno = 0,
	Tank_Gate_Dyno = 0,
	Tank_Gate_1_Dyno = 0,
	Vault_room_door_Dyno = 0,

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

		Util.MapDebugPrint( "Command_Post_Built" );
	},

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

		Util.MapDebugPrint( "Tank_Built" );
	},

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

		Util.MapDebugPrint( "Tank_Barrier_Built" );
	},

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

		Util.MapDebugPrint( "Vault_room_door_Built" );
	},

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

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

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

		Map.Main_Gate_Dyno += 1;
		Util.MapDebugPrint( "Main_Gate_Planted" );
        SetAvailableMapGoals( TEAM.AXIS, false, "GRENADE_balk" );
        SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_balk" );				
	},

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

		Map.Tank_Barrier_Dyno += 1;
		Util.MapDebugPrint( "Tank_Barrier_Planted" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Command_Post" );																	 
	},

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

		Map.Tank_Gate_Dyno += 1;
		Util.MapDebugPrint( "Tank_Gate_Planted" );
	},

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

		Map.Tank_Gate_1_Dyno += 1;
		Util.MapDebugPrint( "Tank_Gate_1_Planted" );
	},

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

		Map.Vault_room_door_Dyno += 1;
		Util.MapDebugPrint( "Vault_room_door_Planted" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Command_Post" );	
        SetAvailableMapGoals( TEAM.AXIS, true, "GRENADE_balk" );
        SetAvailableMapGoals( TEAM.ALLIES, false, "GRENADE_balk" );		
		SetAvailableMapGoals( TEAM.ALLIES, false, "Map.BUILD_Tank" );
	},

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

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

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

		Map.Main_Gate_Dyno -= 1;
		Util.MapDebugPrint( "Main_Gate_Defused" );
	},

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

		Map.Tank_Barrier_Dyno -= 1;
		Util.MapDebugPrint( "Tank_Barrier_Defused" );
	},

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

		Map.Tank_Gate_Dyno -= 1;
		Util.MapDebugPrint( "Tank_Gate_Defused" );
	},

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

		Map.Tank_Gate_1_Dyno -= 1;
		Util.MapDebugPrint( "Tank_Gate_1_Defused" );
	},

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

		Map.Vault_room_door_Dyno -= 1;
		Util.MapDebugPrint( "Vault_room_door_Defused" );
	},

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

		Map.Command_Post_Dyno = 0;

		Util.MapDebugPrint( "Command_Post_Destroyed" );
	},

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

		Map.Main_Gate_Dyno = 0;

		Util.MapDebugPrint( "Main_Gate_Destroyed" );
		SetAvailableMapGoals( TEAM.AXIS, false, "PLANT_Command_Post" );
	},

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

		Map.Tank_Barrier_Dyno = 0;

		Util.MapDebugPrint( "Tank_Barrier_Destroyed" );
	},

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

		Map.Tank_Gate_Dyno = 0;

		Util.MapDebugPrint( "Tank_Gate_Destroyed" );
	},

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

		Map.Tank_Gate_1_Dyno = 0;

		Util.MapDebugPrint( "Tank_Gate_1_Destroyed" );
	},

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

		Map.Vault_room_door_Dyno = 0;

		Util.MapDebugPrint( "Vault_room_door_Destroyed" );
	},

	axis_gold1_Taken = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
		Util.EnableGoal( "ROUTE_allies_spawn_1" ); 	
		Util.MapDebugPrint( "axis_gold1_Taken" );
	},

	axis_gold1_Returned = function( trigger )
	{
		if ( TestMap )
			{ return; }
			
        SetAvailableMapGoals( TEAM.AXIS, false, "GRENADE_balk" );
		
		Util.MapDebugPrint( "axis_gold1_Returned" );
	},

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

		Util.MapDebugPrint( "axis_gold1_Secured" );
	},

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

		Util.MapDebugPrint( "forwardbunkerflag_Axis_Captured" );
	},

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

		Util.MapDebugPrint( "forwardbunkerflag_Allies_Captured" );
	},

};

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

	// Register callback functions
	OnTrigger( "^oCommand Post constructed.", Map.Command_Post_Built );
	OnTrigger( "^oThe Tank has been repaired", Map.Tank_Built );
	OnTrigger( "^oThe Tank Barrier has been constructed.", Map.Tank_Barrier_Built );
	OnTrigger( "^oThe Vault room door has been built", Map.Vault_room_door_Built );
	OnTrigger( "Planted at the Command Post.", Map.Command_Post_Planted );
	OnTrigger( "Planted at the Main Gate.", Map.Main_Gate_Planted );
	OnTrigger( "Planted at the Tank Barrier.", Map.Tank_Barrier_Planted );
	OnTrigger( "Planted at the Tank Gate.", Map.Tank_Gate_Planted );
	OnTrigger( "Planted at the Tank Gate..", Map.Tank_Gate_1_Planted );
	OnTrigger( "Planted at the Vault room door.", Map.Vault_room_door_Planted );
	OnTrigger( "Defused at the Command Post.", Map.Command_Post_Defused );
	OnTrigger( "Defused at the Main Gate.", Map.Main_Gate_Defused );
	OnTrigger( "Defused at the Tank Barrier.", Map.Tank_Barrier_Defused );
	OnTrigger( "Defused at the Tank Gate.", Map.Tank_Gate_Defused );
	OnTrigger( "Defused at the Tank Gate..", Map.Tank_Gate_1_Defused );
	OnTrigger( "Defused at the Vault room door.", Map.Vault_room_door_Defused );
	OnTrigger( "^oCommand Post destroyed", Map.Command_Post_Destroyed );
	OnTrigger( "^oThe Allies have destroyed the Main Gate!", Map.Main_Gate_Destroyed );
	OnTrigger( "^oThe Allies have destroyed the Tank Barrier", Map.Tank_Barrier_Destroyed );
	OnTrigger( "^oThe Allies have destroyed the Tank Gate", Map.Tank_Gate_Destroyed );
	OnTrigger( "Tank Gate..", Map.Tank_Gate_1_Destroyed );
	OnTrigger( "^oThe Vault room door has been destroyed", Map.Vault_room_door_Destroyed );
	OnTrigger( "^oThe Allies have stolen a Gold Crate!", Map.axis_gold1_Taken );
	OnTrigger( "^oThe Axis have intercepted the stolen Gold Crate!", Map.axis_gold1_Returned );
	OnTrigger( "^oAllies have escaped with the Gold!", Map.axis_gold1_Secured );
	OnTrigger( "^oAxis reclaim the Forward Bunker!", Map.forwardbunkerflag_Axis_Captured );
	OnTrigger( "^oAllies capture the Forward Bunker!", Map.forwardbunkerflag_Allies_Captured );	

	//~Util.DisableGoal( ".*", true ); // all but routes
	//~SetAvailableMapGoals( TEAM.AXIS, true, "ATTACK_.*" );
	//~SetAvailableMapGoals( TEAM.ALLIES, true, "ATTACK_.*" );

	// Max users per goal
	Util.SetMaxUsers( 1, "ATTACK_.*" );
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "GRENADE_.*" );
	Util.SetMaxUsers( 1, "SNIPE_.*" );
	Util.SetMaxUsers( 1, "MOUNTMG42_.*" );
	Util.SetMaxUsers( 1, "MOBILEMG42_.*" );
	Util.SetMaxUsers( 1, "MOBILEMORTAR_.*" );
	Util.SetMaxUsers( 1, "AIRSTRIKE_.*" );
	Util.SetMaxUsers( 1, "CALLARTILLERY_.*" );

	// Camp times
	SetMapGoalProperties( "MOUNTMG42_.*", {MinCampTime=15, MaxCampTime=90} );
	SetMapGoalProperties( "MOBILEMG42_.*", {MinCampTime=10, MaxCampTime=60} );

	// Allies goals
	SetGoalPriority( "CHECKPOINT_forwardbunkerflag", 0.95, TEAM.ALLIES );
	SetGoalPriority( "DEFEND_hill_3", 0.72, TEAM.ALLIES, CLASS.COVERTOPS );
	SetGoalPriority( "DEFEND_hill_2", 0.68, TEAM.ALLIES, CLASS.COVERTOPS );	
	SetGoalPriority( "FLAG_axis_gold1", 0.90, TEAM.ALLIES );	
	SetGoalPriority( "PLANT_Tank_Gate", 0.94, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Tank_Gate_1", 0.93, TEAM.ALLIES, CLASS.ENGINEER );	
	SetGoalPriority( "ESCORT_tank", 0.92, TEAM.ALLIES, CLASS.SOLDIER );
	
	// Axis goals
	SetGoalPriority( "PLANT_Command_Post", 0.10, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Tank_Barrier", 0.99, TEAM.AXIS );
	SetGoalPriority( "DEFEND_barrier_1", 0.93, TEAM.AXIS, CLASS.MEDIC );	
	SetGoalPriority( "BUILD_Vault_room_door", 0.98, TEAM.AXIS );
	SetGoalPriority( "DEFEND_gold_1", 0.82, TEAM.AXIS, CLASS.COVERTOPS );
	SetGoalPriority( "DEFEND_gold_2", 0.71, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "DEFEND_gold_2", 0.70, TEAM.AXIS, CLASS.MEDIC );	
	SetGoalPriority( "DEFEND_axistunnel_5", 0.80, TEAM.AXIS, CLASS.SOLDIER );	
	SetGoalPriority( "DEFEND_axistunnel_4", 0.79, TEAM.AXIS, CLASS.SOLDIER );	
	SetGoalPriority( "DEFEND_maingatetruck_1", 0.75, TEAM.AXIS, CLASS.SOLDIER );
	SetGoalPriority( "DEFEND_maingate_1", 0.74, TEAM.AXIS, CLASS.MEDIC );	
	SetGoalPriority( "DEFEND_maingate_2", 0.73, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "DEFEND_hill_1", 0.68, TEAM.AXIS, CLASS.COVERTOPS );	
	SetGoalPriority( "GRENADE_balk", 0.81, TEAM.AXIS );	

	// All
	SetGoalPriority( "DEFEND_chair_1", 0.70, CLASS.SOLDIER );
	SetGoalPriority( "DEFEND_fire_1", 0.66, CLASS.SOLDIER );
	SetGoalPriority( "DEFEND_fire_2", 0.65, CLASS.COVERTOPS );

	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_Vault_room_door =
		{
		},
		BUILD_Tank =
		{
		},
		BUILD_Command_Post =
		{
		},
		BUILD_Tank_Barrier =
		{
		},
		PLANT_Tank_Gate_1 =
		{
		},
		PLANT_Tank_Barrier =
		{
		},
		PLANT_Command_Post =
		{
		},
		PLANT_Main_Gate =
		{
			ROUTE_allies_spawn_1 = 
						{	
						ROUTE_fronttunnel = {},
						ROUTE_sidetunnel = {},	
	                    },					
		},
		PLANT_Vault_room_door =
		{
		},
		PLANT_Tank_Gate =
		{
		},
		FLAG_axis_gold1 =
		{
			ROUTE_axis_spawn_2 = 
						{	
						ROUTE_sidetunnel = {},
						ROUTE_allies_spawn_1 = {},
	                    },			
		},
		GRENADE_balk =
		{
		},		
		CHECKPOINT_forwardbunkerflag =
		{
		},
	};
	Util.Routes(MapRoutes);
};
