//==========================================================================================
//
//	powcamp_b5.gm
//
//	Who                  	When		What
//------------------------------------------------------------------------------------------
//	maker@bigsighstudios.com	03 March 2018	Initial Script
//	palota	9 July 2025
//==========================================================================================
//

global Map =
{
	SaveGroups = 0,

	Navigation =
	{
		jump = //cappoint
		{
			navigate = function()
			{
				this.AddAimRequest(Priority.High, "facing", Vec3(-0.906, -0.002, 0.424));
				sleep(0.1);
				this.Bot.HoldButton(BTN.JUMP, BTN.FORWARD, 1);
				sleep(1);
			},
		},
	},

	tank_at_location = function()
	{
		SetGoalPriority("PLANT_Tank_Barrier", 0.92);
		SetAvailableMapGoals(TEAM.ALLIES, 1, "SMOKEBOMB_barrier");
		ETUtil.SetStartIndex("BUILD_Tank", 2);
		Util.MapDebugPrint("tank at barrier");
	},

	//Tank blows garrison door
	Garrison_Door_Destroyed  = function()
	{
		ETUtil.KillTeam(TEAM.ALLIES);
		ETUtil.KillTeam(TEAM.AXIS, 8);
		sleep(0.1);
		Wp.CheckBlockable();
		Util.DisableGroup("al1");
		Util.DisableGroup("ax1");

		SetAvailableMapGoals(TEAM.ALLIES, 1, ".*Command_Post");
		SetAvailableMapGoals(TEAM.ALLIES, 0, "SMOKEBOMB.*");
		Util.SetGoalRange("BUILD_Neutral_Command_Post", 6000);

		SetGoalGroup({
			"FLAG_allied_gold",
			"CAPPOINT_GateControls",
			".*MG42_569",
			".*MG42_45",
		}, "al2");
		Util.EnableGroup("al2", TEAM.ALLIES);

		SetGoalGroup({
			"DEFEND_key.*",
			"DEFEND_2_.*",
			"SNIPE_DEFEND_A1",
			"PLANTMINE_g.*",
			".*MG42_357",
			".*MG42_362",
			".*MG42_472",
		}, "ax2");
		Util.EnableGroup("ax2", TEAM.AXIS);

		Util.MapDebugPrint("Garrison_Door_Destroyed");
	},

	// main gate key
	allied_gold_Taken = function()
	{
		SetAvailableMapGoals(TEAM.AXIS, 0, "DEFEND_key.*");
		SetAvailableMapGoals(TEAM.AXIS, 1, "DEFEND_control.*");
		Util.MapDebugPrint("allied_gold_Taken");
	},
	allied_gold_Returned = function()
	{
		SetAvailableMapGoals(TEAM.AXIS, 0, "DEFEND_control.*");
		SetAvailableMapGoals(TEAM.AXIS, 1, "DEFEND_key.*");
		Util.MapDebugPrint("allied_gold_Returned");
	},

	//Major Event: Phase 2
	Main_Gate_Open = function()
	{
		sleep(2);
		Wp.CheckBlockable();
		Util.DisableGroup("al2");
		Util.DisableGroup("ax2");

		SetGoalGroup({
			"CHECKPOINT_superflag",
			"BUILD_Assault_Ramp",
			"PLANT_execution_wall",
			"ATTACK_wall.*",
		}, "al3");
		Util.EnableGroup("al3", TEAM.ALLIES);

		SetAvailableMapGoals(TEAM.AXIS, 0, "DEFEND_control.*");
		SetGoalGroup({
			"CHECKPOINT_superflag",
			"PLANT_Assault_Ramp",
			"DEFEND_wall.*",
			"PLANTMINE_w.*",
			"MOBILEMG42_wall.*",
			".*MG42_1072",
		}, "ax3");
		Util.EnableGroup("ax3", TEAM.AXIS);

		Util.MapDebugPrint("Main_Gate_Open");
	},

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

	execution_wall_Destroyed = function()
	{
		sleep(0.1);
		Wp.CheckBlockable();
		Util.DisableGroup("al3");
		Util.DisableGroup("ax3");
		SetAvailableMapGoals(TEAM.ALLIES, 1, {
			"PLANT_Invasion_Barrier",
			"BUILD_scaffolding",
			"PLANT_Gas_Control",
			"FLAG_zyklon",
			"CAPPOINT_zyklon",
		});
		SetAvailableMapGoals(TEAM.AXIS, 1, {
			"DEFEND_end.*",
			"BUILD_Gas_Control",
			"BUILD_Invasion_Barrier",
			"PLANT_scaffolding",
			"MOBILEMG42_end.*",
		});

		Util.MapDebugPrint("execution_wall_Destroyed");
	},

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

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

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

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

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

	zyklon_Taken = function()
	{
		Util.MapDebugPrint("zyklon_Taken");
	},
	zyklon_Returned = function()
	{
		Util.MapDebugPrint("zyklon_Returned");
	},
	zyklon_Secured = function()
	{
		Util.MapDebugPrint("zyklon_Secured");
	},

};

global OnMapLoad = function()
{
	//OnTrigger("^dThe tank has been repaired!", Map.Tank_Built);
	//OnTrigger("^1The tank has been damaged!", Map.Tank_Damaged);
	//OnTrigger("^1The Tank Barrier has been constructed.", Map.Tank_Barrier_Built);
	//OnTrigger("^dThe Tank Barrier has been destroyed.", Map.Tank_Barrier_Destroyed);
	//OnTrigger("^dAllies ^3have built the Sola River Bridge!", Map.Sola_River_Bridge_Built);
	//OnTrigger("^1Axis ^3has destroyed the Sola River Bridge!", Map.Sola_River_Bridge_Destroyed);

	OnTrigger("^dAllies ^3have destroyed the Garrison Door!", Map.Garrison_Door_Destroyed);

	OnTrigger("^dAllies ^3have built the assault ramp!", Map.Assault_Ramp_Built);
	OnTrigger("^1Axis ^3has damaged the assault ramp!", Map.Assault_Ramp_Destroyed);

	OnTrigger("^1Axis ^3has repaired the gas control!", Map.Gas_Control_Built);
	OnTrigger("al_gc_destroyed", Map.Gas_Control_Destroyed);

	OnTrigger("^1Axis ^3has built the infantry barrier!", Map.Invasion_Barrier_Built);
	OnTrigger("^dAllies ^3have destroyed the infantry barrier!", Map.Invasion_Barrier_Destroyed);

	OnTrigger("^dAllies ^3have built the scaffold!", Map.scaffolding_Built);
	OnTrigger("^1Axis ^3has damaged the scaffold!", Map.scaffolding_Destroyed);

	OnTrigger("^dAllies ^3have destroyed the execution wall!", Map.execution_wall_Destroyed);

	OnTrigger("^dAllies ^3have taken the Main Gate key!", Map.allied_gold_Taken);
	OnTrigger("^1Axis ^3has returned the Main Gate key!", Map.allied_gold_Returned);
	OnTrigger("^dAllied team ^3has opened the camp's main gate!", Map.Main_Gate_Open);

	OnTrigger("^dAllies ^3have taken the Artillery Shell!", Map.zyklon_Taken);
	OnTrigger("^1Axis ^3have returned the Artillery Shell!", Map.zyklon_Returned);
	OnTrigger("^dAllies ^3have delivered the Artillery Shell", Map.zyklon_Secured);

	OnTrigger("^1Axis ^3have captured the Main Camp!", Map.superflag_Axis_Captured);
	OnTrigger("^dAllies ^3have captured the Main Camp!", Map.superflag_Allies_Captured);

	OnTriggerRegion(Vec3(3196, 5424, 695), 100, RegionTrigger.VehicleTrigger);
	OnTrigger("tank at location", Map.tank_at_location);

	Util.DisableGoal(".*", true);

	Util.LimitToClass("PLANT_scaffolding", 1, 5);
	Util.LimitToClass("PLANT_Assault_Ramp", 1, 5);
	Util.LimitToClass("PLANT_Neutral_Command_Post", 0, 5);

	Util.AddUsePoint("PLANT_Invasion_Barrier", Vec3(8787, 5752, 672));
	Util.AddUsePoint("PLANT_Assault_Ramp", Vec3(5015, 7961, 722));

	SetGoalGroup({
		"BUILD_Tank",
		"MOUNT_Tank",
		"ESCORT_Tank",
		"BUILD_Sola_River_Bridge",
		"PLANT_Tank_Barrier",
		"SNIPE_ATTACK_.*",
	}, "al1");
	Util.EnableGroup("al1", TEAM.ALLIES);

	SetGoalGroup({
		"BUILD_Tank_Barrier",
		"PLANT_Sola_River_Bridge",
		".*Command_Post",
		"DEFEND_1_.*",
		"SNIPE_DEFEND_[BC].*",
		"MOUNTMG42_244",
		"MOUNTMG42_488",
	}, "ax1");
	Util.EnableGroup("ax1", TEAM.AXIS);

	SetGoalPriority("DEFEND_control.*", 0.51);
	SetGoalPriority("BUILD_Assault_Ramp", 0.81);
	SetGoalPriority("PLANT_Invasion_Barrier", 0.9);
	SetGoalPriority("SNIPE.*", 0.8);
	SetGoalPriority("CHECKPOINT.*", 0.5);

	Util.SetGoalRange("BUILD_Neutral_Command_Post", 3100);

	SetMapGoalProperties("DEFEND.*", {MinCampTime=10, MaxCampTime=70});
	SetMapGoalProperties("SNIPE.*", {MinCampTime=300, MaxCampTime=400});

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

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

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

global InitializeRoutes = function()
{
	MapRoutes =
	{
		FLAG_allied_gold =
		{
			ROUTE_garrison_spawn =
			{
				ROUTE_k1 ={},
				ROUTE_k2 ={},
				ROUTE_k3 ={},
			},
		},
		CAPPOINT_GateControls =
		{
			ROUTE_key =
			{
				ROUTE_train1 ={},
				ROUTE_train2 ={},
				ROUTE_train3 ={},
				ROUTE_train4 ={},
			},
		},
		CAPPOINT_zyklon =
		{
			ROUTE_zyklon =
			{
				ROUTE_zyklon1 ={},
				ROUTE_zyklon2 ={},
				ROUTE_zyklon3 = { ROUTE_zyklon4 ={}},
			},
		},
	};
	Util.Routes(MapRoutes);
};
