//==========================================================================================
//
//	unit_cache_final.gm
//
//	Who  	When		What
//------------------------------------------------------------------------------------------
//	d-luX	30 January 2021	Initial Script
//	palota	5 August 2025
//==========================================================================================
//

global Map =
{
	Safe_Destroyed = function()
	{
		SetAvailableMapGoals(TEAM.AXIS, true, {
			"DEFEND_keycardcapture.*",
			"BUILD_House_MG42",
		});
		SetAvailableMapGoals(TEAM.ALLIES, true, {
			"FLAG.*",
			"CAPPOINT.*",
		});
		Util.MapDebugPrint("Safe_Destroyed");
	},

	Keycard_Taken = function()
	{
		SetAvailableMapGoals(TEAM.AXIS, false, {
			"DEFEND_flag.*",
			"DEFEND_safe.*",
		});
		Util.MapDebugPrint("Keycard_Taken");
	},

	Keycard_Returned = function()
	{
		SetAvailableMapGoals(TEAM.AXIS, true, {
			"DEFEND_flag.*",
			"DEFEND_safe.*",
		});
		Util.MapDebugPrint("Keycard_Returned");
	},

	Keycard_Secured = function()
	{
		Util.DisableGoal("CHECKPOINT.*");
		SetAvailableMapGoals(TEAM.ALLIES, false, "ATTACK_safe.*");
		SetAvailableMapGoals(TEAM.AXIS, false, {
			"DEFEND.*",
			"CALLARTILLERY.*",
		});

		SetAvailableMapGoals(TEAM.AXIS, true, {
			"DEFEND_longway.*",
			"DEFEND_generator.*",
			"BUILD_Storage_Barrier",
			"BUILD_Backyard_Barrier",
			"MOUNTMG42.*",
			"REPAIRMG42.*",
			"CALLARTILLERY_longway.*",
			"AIRSTRIKE.*",
			"PLANTMINE.*",
		});

		sleep(3);
		SetAvailableMapGoals(TEAM.ALLIES, true, {
			"ATTACK_generator.*",
			"BUILD_Neutral_Command_Post",
			"PLANT_.*",
			"SNIPE_.*",
		});

		Util.MapDebugPrint("Keycard_Secured");
	},

	Backyard_Barrier_Built = function()
	{
		Util.MapDebugPrint("Backyard_Barrier_Built");
	},

	Backyard_Barrier_Destroyed = function()
	{
		Util.MapDebugPrint("Backyard_Barrier_Destroyed");
	},

	Storage_Barrier_Built = function()
	{
		Util.MapDebugPrint("Storage_Barrier_Built");
	},

	Storage_Barrier_Destroyed = function()
	{
		Util.MapDebugPrint("Storage_Barrier_Destroyed");
	},

	westbunker_flag_Axis_Captured = function()
	{
		Util.SetMaxUsersInProgress(2, "CHECKPOINT.*");
		Util.MapDebugPrint("westbunker_flag_Axis_Captured");
	},

	westbunker_flag_Allies_Captured = function()
	{
		Util.SetMaxUsersInProgress(4, "CHECKPOINT.*");
		Util.MapDebugPrint("westbunker_flag_Allies_Captured");
	},

};

global OnMapLoad = function()
{
	//OnTrigger("MISSING_STRING", Map.Backyard_Barrier_Built);
	//OnTrigger("MISSING_STRING", Map.Storage_Barrier_Built);
	//OnTrigger("MISSING_STRING", Map.Backyard_Barrier_Destroyed);
	//OnTrigger("MISSING_STRING", Map.Storage_Barrier_Destroyed);
	OnTrigger("Allies have blown the Tresor", Map.Safe_Destroyed);
	OnTrigger("Allies have stolen the Keycard!", Map.Keycard_Taken);
	OnTrigger("Flag returned Keycard!", Map.Keycard_Returned);
	OnTrigger("Allies have open the gates!", Map.Keycard_Secured);
	OnTrigger("Axis captured the Bunker!", Map.westbunker_flag_Axis_Captured);
	OnTrigger("Allies captured the Bunker!", Map.westbunker_flag_Allies_Captured);

	Util.DisableGoal(".*", true);
	Util.EnableGoal({
		"AMMOCAB.*",
		"HEALTHCAB.*",
		"CHECKPOINT.*",
		"PLANT_Neutral_Command_Post",
	});
	SetAvailableMapGoals(TEAM.AXIS, true, {
		"BUILD_Neutral_Command_Post",
		"CALLARTILLERY_.",
		"ARTILLERY.*",
		"DEFEND_flag.*",
		"DEFEND_safe.*",
	});
	SetAvailableMapGoals(TEAM.ALLIES, true, {
		"ATTACK_safe.*",
		"PLANT_Safe",
		"PLANT_Long_way_gate",
	});

	SetGoalPriority("PLANT_Neutral_Command_Post", 0.75);
	SetGoalPriority("PLANT_House_MG42", 0.79);
	SetGoalPriority("CALLARTILLERY_.", 0.6);
	SetGoalPriority("DEFUSE_Generator.*", 1.2, 0, 0, true);
	SetGoalPriority("DEFUSE_Long_way.*", 0.95, 0, 0, true);

	Util.SetMaxUsersInProgress(2, "CHECKPOINT.*");
	Util.SetMaxUsers(1, {"ATTACK.*", "DEFEND.*", "BUILD.*", "PLANT_Long_way_gate"});

	SetMapGoalProperties("DEFEND.*", {MinCampTime=20, MaxCampTime=40});
};

global OnBotJoin = function(bot)
{
	bot.TargetBreakableDist = 90;
};
