//==========================================================================================
//
//	uje_airport.gm
//
//	Who  	When				What
//------------------------------------------------------------------------------------------
//	|TP|kaos	11 November 2011	r2 script
//	MickyP	28 January 2014 	Fixes
//	palota	9 January 2025	converted to Omni-bot 0.9, Allies can build command post
//==========================================================================================
//

global Map =
{
	Debug = 0,

	Airfield_side_door_Dyno = 0,
	Axis_Controls_Dyno = 0,
	Axis_Main_Airfield_entrance_Dyno = 0,
	Axis_Main_Airfield_entrance_1_Dyno = 0,
	Cargo_plane_1_Dyno = 0,
	Second_Cargoplane_Dyno = 0,

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

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

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

	Airfield_side_door_Planted = function( trigger )
	{
		Map.Airfield_side_door_Dyno += 1;
		Util.MapDebugPrint( "Airfield_side_door_Planted" );
	},

	Axis_Controls_Planted = function( trigger )
	{
		Map.Axis_Controls_Dyno += 1;
		SetGoalPriority( "ATTACK_c.*", 0.95, TEAM.ALLIES );
		SetGoalPriority( "DEFEND_c.*", 0.95, TEAM.AXIS );
		Util.MapDebugPrint( "Axis_Controls_Planted" );
	},

	Axis_Main_Airfield_entrance_Planted = function( trigger )
	{
		Map.Axis_Main_Airfield_entrance_Dyno += 1;
		SetGoalPriority( "ATTACK_b0_4", 0.95, TEAM.ALLIES );
		SetGoalPriority( "ATTACK_b0_5", 0.95, TEAM.ALLIES );
		SetGoalPriority( "ATTACK_b0_6", 0.95, TEAM.ALLIES );
		SetGoalPriority( "ATTACK_b0_7", 0.95, TEAM.ALLIES );
		SetGoalPriority( "ATTACK_b0_8", 0.95, TEAM.ALLIES );
		SetGoalPriority( "DEFEND_r0_2", 0.95, TEAM.AXIS );
		SetGoalPriority( "DEFEND_r0_3", 0.95, TEAM.AXIS );
		SetGoalPriority( "DEFEND_r0_7", 0.95, TEAM.AXIS );
		SetGoalPriority( "DEFEND_r0_8", 0.95, TEAM.AXIS );
		Util.MapDebugPrint( "Axis_Main_Airfield_entrance_Planted" );
	},

	Cargo_plane_1_Planted = function( trigger )
	{
		Map.Cargo_plane_1_Dyno += 1;
		SetGoalPriority( "ATTACK_p1.*", 0.95, TEAM.ALLIES );
		SetGoalPriority( "DEFEND_p1.*", 0.95, TEAM.AXIS );
		Util.MapDebugPrint( "Cargo_plane_1_Planted" );
	},

	Second_Cargoplane_Planted = function( trigger )
	{
		Map.Second_Cargoplane_Dyno += 1;
		SetGoalPriority( "ATTACK_p2.*", 0.95, TEAM.ALLIES );
		SetGoalPriority( "DEFEND_p2.*", 0.95, TEAM.AXIS );
		Util.MapDebugPrint( "Second_Cargoplane_Planted" );
	},

	Airfield_side_door_Defused = function( trigger )
	{
		Map.Airfield_side_door_Dyno -= 1;
		Util.MapDebugPrint( "Airfield_side_door_Defused" );
	},

	Axis_Controls_Defused = function( trigger )
	{
		Map.Axis_Controls_Dyno -= 1;
		SetGoalPriority( "ATTACK_c.*", 0.5, TEAM.ALLIES );
		SetGoalPriority( "DEFEND_c.*", 0.5, TEAM.AXIS );
		Util.MapDebugPrint( "Axis_Controls_Defused" );
	},

	Axis_Main_Airfield_entrance_Defused = function( trigger )
	{
		Map.Axis_Main_Airfield_entrance_Dyno -= 1;
		SetGoalPriority( "ATTACK_b0_4", 0.5, TEAM.ALLIES );
		SetGoalPriority( "ATTACK_b0_5", 0.5, TEAM.ALLIES );
		SetGoalPriority( "ATTACK_b0_6", 0.5, TEAM.ALLIES );
		SetGoalPriority( "ATTACK_b0_7", 0.5, TEAM.ALLIES );
		SetGoalPriority( "ATTACK_b0_8", 0.5, TEAM.ALLIES );
		SetGoalPriority( "DEFEND_r0_2", 0.5, TEAM.AXIS );
		SetGoalPriority( "DEFEND_r0_3", 0.5, TEAM.AXIS );
		SetGoalPriority( "DEFEND_r0_7", 0.5, TEAM.AXIS );
		SetGoalPriority( "DEFEND_r0_8", 0.5, TEAM.AXIS );
		Util.MapDebugPrint( "Axis_Main_Airfield_entrance_Defused" );
	},

	Cargo_plane_1_Defused = function( trigger )
	{
		Map.Cargo_plane_1_Dyno -= 1;
		SetGoalPriority( "ATTACK_p1.*", 0.5, TEAM.ALLIES );
		SetGoalPriority( "DEFEND_p1.*", 0.5, TEAM.AXIS );
		Util.MapDebugPrint( "Cargo_plane_1_Defused" );
	},

	Second_Cargoplane_Defused = function( trigger )
	{
		Map.Second_Cargoplane_Dyno -= 1;
		SetGoalPriority( "ATTACK_p2.*", 0.5, TEAM.ALLIES );
		SetGoalPriority( "DEFEND_p2.*", 0.5, TEAM.AXIS);
		Util.MapDebugPrint( "Second_Cargoplane_Defused" );
	},

	Airfield_side_door_Destroyed = function( trigger )
	{
		Map.Airfield_side_door_Dyno = 0;

		Util.MapDebugPrint( "Airfield_side_door_Destroyed" );
	},

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

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

	Axis_Controls_Destroyed = function( trigger )
	{
		Map.Axis_Controls_Dyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_c.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_c.*" );

		Util.MapDebugPrint( "Axis_Controls_Destroyed" );
	},

	Axis_Main_Airfield_entrance_Destroyed = function( trigger )
	{
		Map.Axis_Main_Airfield_entrance_Dyno = 0;
		sleep(0.1);
		Wp.CheckBlockable();

		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_r0.*" );
		SetAvailableMapGoals( TEAM.AXIS, true, {
			"BUILD_Axis_Command_Post",
			"PLANT_Allied_Command_Post",
			"BUILD_Airfield_side_door",
			"DEFEND_ex.*",
			"DEFEND_p1.*",
			"DEFEND_p2.*",
			"DEFEND_c.*",
			"SNIPE_.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, false, {
			"ATTACK_b0.*",
		});
		SetAvailableMapGoals( TEAM.ALLIES, true, {
			"BUILD_Allied_Command_Post",
			"PLANT_Airfield_side_door",
			"PLANT_Axis_Command_Post",
			"PLANT_Axis_Controls",
			"PLANT_Cargo_plane_1",
			"PLANT_Second_Cargoplane",
			"ATTACK_p1.*",
			"ATTACK_p2.*",
			"ATTACK_c.*",
		});

		Util.MapDebugPrint( "Axis_Main_Airfield_entrance_Destroyed" );
	},

	Cargo_plane_1_Destroyed = function( trigger )
	{
		Map.Cargo_plane_1_Dyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_p1.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_p1.*" );

		Util.MapDebugPrint( "Cargo_plane_1_Destroyed" );
	},

	Second_Cargoplane_Destroyed = function( trigger )
	{
		Map.Second_Cargoplane_Dyno = 0;
		SetAvailableMapGoals( TEAM.ALLIES, false, "ATTACK_p2.*" );
		SetAvailableMapGoals( TEAM.AXIS, false, "DEFEND_p2.*" );

		Util.MapDebugPrint( "Second_Cargoplane_Destroyed" );
	},

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

	oldcityflag_Allies_Captured = function( trigger )
	{
		SetAvailableMapGoals( TEAM.ALLIES, true, "PLANT_Axis_Main_Airfield_entrance" );

		Util.MapDebugPrint( "oldcityflag_Allies_Captured" );
	},

};

global OnMapLoad = function()
{
	OnTrigger( "the side door has been contructed", Map.Airfield_side_door_Built );
	OnTrigger( "Allied Command Post constructed. Charge speed increased!", Map.Allied_Command_Post_Built );
	OnTrigger( "Axis Command Post constructed. Charge speed increased!", Map.Axis_Command_Post_Built );
	OnTrigger( "Planted at the Airfield ide door.", Map.Airfield_side_door_Planted );
	OnTrigger( "Planted at The Axis Controls.", Map.Axis_Controls_Planted );
	OnTrigger( "Planted at the Axis Main Airfield entrance.", Map.Axis_Main_Airfield_entrance_Planted );
	OnTrigger( "Planted at Cargo plane 1.", Map.Cargo_plane_1_Planted );
	OnTrigger( "Planted at The Second Cargoplane.", Map.Second_Cargoplane_Planted );
	OnTrigger( "Defused at the Airfield side door.", Map.Airfield_side_door_Defused );
	OnTrigger( "Defused at The Axis Controls.", Map.Axis_Controls_Defused );
	OnTrigger( "Defused at the Axis Main Airfield entrance.", Map.Axis_Main_Airfield_entrance_Defused );
	OnTrigger( "Defused at Cargo plane 1.", Map.Cargo_plane_1_Defused );
	OnTrigger( "Defused at The Second Cargoplane.", Map.Second_Cargoplane_Defused );
	OnTrigger( "the side door has been destroyed", Map.Airfield_side_door_Destroyed );
	OnTrigger( "Axis team has destroyed the Allied Command Post!", Map.Allied_Command_Post_Destroyed );
	OnTrigger( "Allied team has destroyed the Axis Command Post!", Map.Axis_Command_Post_Destroyed );
	OnTrigger( "Allies have destroyed the Airfield Controls", Map.Axis_Controls_Destroyed );
	OnTrigger( "Allies have gained access to the Airport", Map.Axis_Main_Airfield_entrance_Destroyed );
	OnTrigger( "Allies have destroyed Cargoplane 1!", Map.Cargo_plane_1_Destroyed );
	OnTrigger( "Allies have destroyed Cargoplane 2!", Map.Second_Cargoplane_Destroyed );
	OnTrigger( "Axis reclaim the Garage!", Map.oldcityflag_Axis_Captured );
	OnTrigger( "Allies capture the garage!", Map.oldcityflag_Allies_Captured );

	//INITIAL
	SetAvailableMapGoals( TEAM.AXIS, false, {
		"BUILD_Axis_Command_Post",
		"PLANT_Allied_Command_Post",
		"BUILD_Airfield_side_door",
		"ATTACK_.*",
		"DEFEND_ex.*",
		"DEFEND_p[12].*",
		"DEFEND_c.*",
		"SNIPE_.*",
	});
	SetAvailableMapGoals( TEAM.AXIS, true, "DEFEND_r0.*" );
	SetAvailableMapGoals( TEAM.ALLIES, false, {
		"BUILD_Allied_Command_Post",
		"PLANT_Airfield_side_door",
		"PLANT_Axis_Command_Post",
		"PLANT_Axis_Controls",
		"PLANT_Cargo_plane_1",
		"PLANT_Second_Cargoplane",
		"DEFEND_.*",
		"ATTACK_c.*",
		"ATTACK_p[12].*",
		"SNIPE_.*",
	});
	SetAvailableMapGoals( TEAM.ALLIES, true, {
		"PLANT_Axis_Main_Airfield_entrance",
		"ATTACK_b0.*",
	});

	SetGoalPriority( "PLANT_Allied_Command_Post", 0.0, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "PLANT_Allied_Command_Post", 0.7, TEAM.AXIS, CLASS.COVERTOPS );
	SetGoalPriority( "PLANT_Axis_Command_Post", 0.0, TEAM.ALLIES, CLASS.ENGINEER );
	SetGoalPriority( "BUILD_Axis_Command_Post", 0.51, TEAM.AXIS, CLASS.ENGINEER );
	SetGoalPriority( "ATTACK_.*", 0.5, TEAM.ALLIES );
	SetGoalPriority( "DEFEND_.*", 0.5, TEAM.AXIS );

	// Max users per goal
	Util.SetMaxUsers( 1, "DEFEND_.*" );
	Util.SetMaxUsers( 1, "PLANT_.*" );

	// Camp times
	SetMapGoalProperties( "ATTACK_.*", {MinCampTime=30, MaxCampTime=60} );
	SetMapGoalProperties( "DEFEND_ex.*", {MinCampTime=5, MaxCampTime=15} );
	SetMapGoalProperties( "SNIPE_.*", {MinCampTime=30, MaxCampTime=60} );

	//PLANES DYNAMITE
	Util.SetGoalPosition( 1645.471, 1083.700, -713.220, "PLANT_Cargo_plane_1" );
	Util.SetGoalPosition( 3080.022, 2004.712, -701.955, "PLANT_Second_Cargoplane" );
	Util.SetGoalPosition( -117,-314,-871, "PLANT_Axis_Main_Airfield_entrance" );
	Util.SetGoalPosition( 120,-306,-871, "PLANT_Axis_Main_Airfield_entrance" );

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