//==========================================================================================
//
//	snipertram.gm - snipertram_beta1.pk3
//
//	Who                  	When		What
//------------------------------------------------------------------------------------------
//	maker@bigsighstudios.com	31 January 2018	Initial Script
//	palota	15 July 2025
//==========================================================================================
//

global Map =
{
	SaveGroups = 0,

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

	Axis_Wall_and_MG42_Built = function()
	{
		if(Map.bank){
			SetAvailableMapGoals(TEAM.ALLIES, true, "ATTACK_wall.*");
		}
		Util.MapDebugPrint("Axis_Wall_and_MG42_Built");
	},
	Axis_Wall_and_MG42_Destroyed = function()
	{
		sleep(0.1);
		Wp.CheckBlockable();
		SetAvailableMapGoals(TEAM.ALLIES, false, "ATTACK_wall.*");
		Util.MapDebugPrint("Axis_Wall_and_MG42_Destroyed");
	},

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

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

	Bank_Door_Destroyed = function() //"axis_hq_objective_destroyed"
	{
		Map.bank = 1;
		Wp.CheckBlockable();
		Util.DisableGroup("al1");
		SetAvailableMapGoals(TEAM.ALLIES, true, {
			"FLAG.*",
			"CAPPOINT.*",
			"ATTACK_wall.*",
			"ATTACK_cap.*",
			"PLANT_Generator",
			"PLANT_Axis_Wall_and_MG42",
		});
		SetAvailableMapGoals(TEAM.AXIS, false, {
			"DEFEND_tram.*",
			"PLANTMINE_bank.*",
			".*Command_Post",
		});
		SetAvailableMapGoals(TEAM.AXIS, true, {
			"DEFEND_wall.*",
			"SNIPE_wall.*",
			".*MG42_98",
			".*MG42_300",
			".*MG42_157",
			".*MG42_construction_track",
		});
		SetGoalPriority("BUILD_Axis_Wall_and_MG42", 0.9);
		Util.MapDebugPrint("Bank_Door_Destroyed");
	},

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

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

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

global OnMapLoad = function()
{
	OnTrigger("Axis Wall (and MG42) constructed!", Map.Axis_Wall_and_MG42_Built);
	OnTrigger("Allied Wall and MG42 destroyed!", Map.Axis_Wall_and_MG42_Destroyed);

	//"The Allied Forces have constructed the lower Tram system!"
	//"The lower Tram system is destroyed!"
	OnTrigger("The Axis Forces have constructed the upper Tram system!", Map.Tram_1_Built);

	OnTrigger("the Bank Door Destroyed.", Map.Bank_Door_Destroyed);

	OnTrigger("Allies have destroyed the Generator!", Map.Generator_Destroyed);

	OnTrigger("Allies have stolen The Gold!", Map.loffy_gold_crateinbank_Taken);
	OnTrigger("Axis have returned the Gold!", Map.loffy_gold_crateinbank_Returned);

	OnTrigger("Axis reclaim the Flag!", Map.the_flag_Axis_Captured);
	OnTrigger("Allies capture the Flag!", Map.the_flag_Allies_Captured);


	Util.DisableGoal(".*", true);
	Util.EnableGoal({
		".*CAB.*",
		".*Command_Post",
	});

	Util.ExcludeClass("PLANT_Command_Post", 0, CLASS.ENGINEER);

	Util.AddUsePoint("PLANT_Axis_Wall_and_MG42", Vec3(-6742, -2498, 456));
	Util.AddUsePoint("PLANT_Generator", Vec3(-5940, -3926, 724));

	//Allies
	SetGoalGroup({
		"BUILD_Allied_constructible",
		"BUILD_Tram_.*",
		"BUILD_Neutral_.*",
		"PLANT_Bank_Door",
		"ATTACK_bank.*",
	}, "al1");
	Util.EnableGroup("al1", TEAM.ALLIES);
	SetGoalPriority("ATTACK_cap.*", 0.4);
	SetGoalPriority("BUILD_Command_Post", 0.81, TEAM.ALLIES);

	//Axis
	SetAvailableMapGoals(TEAM.AXIS, 1, {
		"DEFEND_tram.*",
		"PLANTMINE_bank.*",
		"CHECKPOINT_the_flag",
	});
	SetGoalPriority("SNIPE.*", 0.8);
	SetGoalPriority("BUILD_Axis_Wall_and_MG42", 0.79);

	SetMapGoalProperties({"MOUNTMG42.*", "DEFEND.*", "SNIPE.*"}, {MinCampTime=30, MaxCampTime=200});

	Util.SetMaxUsers(1, {
		"MOUNTMG42.*",
		".*Command_Post",
		"DEFEND.*",
	});

	Util.MapDebugPrint("Omni-bot map script for " + GetMapName() + " executed.");

	sleep(5);
	SetAvailableMapGoals(TEAM.ALLIES, 1, "CHECKPOINT_the_flag");
	SetAvailableMapGoals(TEAM.AXIS, 1, "BUILD_Axis_Wall_and_MG42");
};

global InitializeRoutes = function()
{
	MapRoutes =
	{
		CHECKPOINT_the_flag = {
			ROUTE_allied_spawn = {
				ROUTE_a1 = {},
			}
		},
		CAPPOINT_gold = {
			ROUTE_bank_spawn = {
				ROUTE_x1 = {},
				ROUTE_x2 = {},
			},
			ROUTE_wall = {
				ROUTE_x1 = {},
				ROUTE_x2 = {},
			}
		},
	};
	MapRoutes.PLANT_Bank_Door = MapRoutes.CHECKPOINT_the_flag;
	MapRoutes["ATTACK_cap.*"] = MapRoutes.CAPPOINT_gold;
	Util.Routes(MapRoutes);
};
