--/////////////////////////////////////////////////////////////////////////////////////////////////
--  (c) Galyana's Ultimate Empire at War Modifications
--  
--     ******    ***        *** ************           ***         ***
--    *      *    *          *   *         *            *           *
--   *        *   *          *   *                      *           *
--  *         *   *          *   *                      *           *
--  *             *          *   *    *         **** *  *           *
--  *             *          *   ******        *    *   *           *
--  *      ****   *          *   *    *       *     *   *    ***    *
--  *         *   *          *   *           *      *   *     *     *
--   *        *    *        *    *           *      *    *    *    *
--    *      *      *      *     *         *  *    **     *   *   *
--     ******        ******     ************   **** **     *******
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- C O N F I D E N T I A L   S O U R C E   C O D E -- D O   N O T   D I S T R I B U T E
--/////////////////////////////////////////////////////////////////////////////////////////////////
--
--            File: GUEaW/Data/Scripts/AI/SpaceMode/TacticalMultiplayerBuildSpaceUnitsGeneric.LUA
--
-- Original Editor: Giovanni Galyana
--
--   Final Edit By: Giovanni Galyana
--
--            Date: 28 January, 2026
--
--       Revisions: 20
--
--/////////////////////////////////////////////////////////////////////////////////////////////////

-- Replaced Unit Teams
-- Sykariius_Team_Space_MP | Nikomer_Team_Space_MP | Xizor_Team_Space_MP | Cuarson_Team_Space_MP | Pestelous_Team_Space_MP
-- Bossk_Team_Space_MP | IG88_Team_Space_MP 
-- Han_Solo_Team_Space_MP | Red_Squadron
-- Boba_Fett_Team_Space_MP | Darth_Team_Space_MP

require("pgevents")


function Definitions()

	Category = "Tactical_Multiplayer_Build_Space_Units_Generic"
	IgnoreTarget = true
	TaskForce = {
		{
		"ReserveForce"
		,"RS_Level_Two_Starbase_Upgrade | RS_Level_Three_Starbase_Upgrade | RS_Level_Four_Starbase_Upgrade | RS_Level_Five_Starbase_Upgrade | RS_Level_Two_Drydock_Upgrade | RS_Level_Three_Drydock_Upgrade | RS_Level_Four_Drydock_Upgrade | RS_Level_Five_Drydock_Upgrade = 0,1"
		,"ES_Level_Two_Starbase_Upgrade | ES_Level_Three_Starbase_Upgrade | ES_Level_Four_Starbase_Upgrade | ES_Level_Five_Starbase_Upgrade | ES_Flak_Defenses | ES_Level_Two_Drydock_Upgrade | ES_Level_Three_Drydock_Upgrade | ES_Level_Four_Drydock_Upgrade | ES_Level_Five_Drydock_Upgrade = 0,1"
		,"US_Level_Two_Starbase_Upgrade | US_Level_Three_Starbase_Upgrade | US_Level_Four_Starbase_Upgrade | US_Level_Five_Starbase_Upgrade | US_Level_Two_Drydock_Upgrade | US_Level_Three_Drydock_Upgrade | US_Level_Four_Drydock_Upgrade | US_Level_Five_Drydock_Upgrade = 0,1"
		,"HS_Level_Two_Starbase_Upgrade | HS_Level_Three_Starbase_Upgrade | HS_Level_Four_Starbase_Upgrade | HS_Level_Five_Starbase_Upgrade | HS_Level_Two_Drydock_Upgrade | HS_Level_Three_Drydock_Upgrade | HS_Level_Four_Drydock_Upgrade | HS_Level_Five_Drydock_Upgrade = 0,1"
		,"RST_Level_Two_Starbase_Upgrade | RST_Level_Three_Starbase_Upgrade | RST_Level_Four_Starbase_Upgrade | RST_Level_Five_Starbase_Upgrade | RST_Level_Two_Drydock_Upgrade | RST_Level_Three_Drydock_Upgrade | RST_Level_Four_Drydock_Upgrade | RST_Level_Five_Drydock_Upgrade = 0,1"
		,"EST_Level_Two_Starbase_Upgrade | EST_Level_Three_Starbase_Upgrade | EST_Level_Four_Starbase_Upgrade | EST_Level_Five_Starbase_Upgrade | EST_Flak_Defenses | EST_Level_Two_Drydock_Upgrade | EST_Level_Three_Drydock_Upgrade | EST_Level_Four_Drydock_Upgrade | EST_Level_Five_Drydock_Upgrade = 0,1"
		,"UST_Level_Two_Starbase_Upgrade | UST_Level_Three_Starbase_Upgrade | UST_Level_Four_Starbase_Upgrade | UST_Level_Five_Starbase_Upgrade | UST_Level_Two_Drydock_Upgrade | UST_Level_Three_Drydock_Upgrade | UST_Level_Four_Drydock_Upgrade | UST_Level_Five_Drydock_Upgrade = 0,1"
		,"HST_Level_Two_Starbase_Upgrade | HST_Level_Three_Starbase_Upgrade | HST_Level_Four_Starbase_Upgrade | HST_Level_Five_Starbase_Upgrade | HST_Level_Two_Drydock_Upgrade | HST_Level_Three_Drydock_Upgrade | HST_Level_Four_Drydock_Upgrade | HST_Level_Five_Drydock_Upgrade = 0,1"
		,"PS_Level_Two_Starbase_Upgrade = 0,1"
		,"Rebel_Pirate_Fighter_Squadron | Rebel_Cobra_Squadron | Rebel_Prowler-A_Squadron | Rebel_Pirate_IPV | Rebel_Vonosmas_Corvette | Rebel_Pirate_Frigate | Rebel_Guardian_Star_Defender | Rebel_Hammer_SA | Rebel_Providence_SA | Rebel_Zylon_Destroyer | Rebel_Mandator_SSD = 0,2"
		,"Empire_Pirate_Fighter_Squadron | Empire_Cobra_Squadron | Empire_Prowler-A_Squadron | Empire_Pirate_IPV | Empire_Vonosmas_Corvette | Empire_Pirate_Frigate | Empire_Guardian_Star_Defender | Empire_Hammer_SA | Empire_Providence_SA | Empire_Zylon_Destroyer | Empire_Mandator_SSD = 0,2"
		,"Underworld_Pirate_Fighter_Squadron | Underworld_Cobra_Squadron | Underworld_Prowler-A_Squadron | Underworld_Pirate_IPV | Underworld_Vonosmas_Corvette | Underworld_Guardian_Star_Defender | Underworld_Hammer_SA | Underworld_Providence_SA | Underworld_Zylon_Destroyer | Underworld_Mandator_SSD = 0,2"
		,"Hutt_Cobra_Squadron | Hutt_Prowler-A_Squadron | Hutt_Vonosmas_Corvette | Hutt_Guardian_Star_Defender | Hutt_Hammer_SA | Hutt_Providence_SA | Hutt_Zylon_Destroyer | Hutt_Mandator_SSD = 0,2"
		,"Z95_Headhunter_Rebel_Squadron | Rebel_X-Wing_Squadron | UEAW_EWing_Squadron | Y-Wing_Squadron | A_Wing_Squadron | B-Wing_Squadron | Corellian_Corvette | Corellian_Gunboat | Venator_Cruiser | Marauder_Missile_Cruiser | Nebulon_B_Frigate | Nebulon_B2_Frigate | Alliance_Assault_Frigate | MC30_Frigate | Nebulon_C_Frigate | UEAW_Nebula_SD | MC80_LibertyType | MC80_HomeOneType | MC99_Star_Dreadnaught | Viscount_Calamari_Cruiser = 0,3"
		,"Tie_Fighter_Squadron | TIE_Scout_Squadron | Tie_Bomber_Squadron | UEAW_TIE_Advanced_Squadron | UEAW_Tie_Droid_Squadron | UEAW_Assault_Gunboat_Squadron | TIE_Defender_Squadron | TIE_Interceptor_Squadron | TIE_Bomb_Squadron | TIE_Phantom_Squadron | Tartan_Patrol_Cruiser | Dreadnaught_Heavy_Cruiser | Broadside_Class_Cruiser | Acclamator_Assault_Ship | Acclamator_Assault_Ship_Class_II | Victory_Destroyer | Interdictor_Cruiser | Vinterdictor_Cruiser | Escort_Carrier | Star_Destroyer | Star_Destroyer_Class_II | Star_Destroyer_Class_III | Executor_Super_Star_Destroyer | UEAW_Eclipse  = 0,3"
		,"Skipray_Squadron | StarViper_Squadron | UEAW_Aggressor_Squadron | Prowler-B_Squadron | Crusader_Gunship | Pinance_Heavy_Corvette | Interceptor4_Frigate | Recusant_Destroyer | Venator_Underworld | Munificent_Frigate | Orion_Dreadnaught | Kedalbe_Battleship | Krayt_Class_Destroyer | Pelleaon_Star_Destroyer | Lucrehulk_Battleship | Vengeance_Frigate | Super_Carrier | Malevolence = 0,3"
		,"Hutt_VWing_Squadron | Hutt_Pirate_Fighter_Squadron | Viper_Squadron | Mirage_Squadron | Z95_Headhunter_Hutts_Squadron | Aqulamator_Bomber_Squadron | Gallofree_Corvette | Illuminator_Frigate | Hutt_Pirate_IPV | ShadowClaw_Corvette | Kavadonia_Corvette | Ultor_Beam_Cruiser | Kavadonian_Interceptor_Frigate | Hutt_Pirate_Frigate | Hutt_Dreadnaught | Gladiator_Cruiser | MC30_ION_Frigate | Executor_Frigate | Hutt_Eclipse | Centurion_Destroyer | Venator_SD | SternenKreuzer | Chronoscepter = 0,3"
		,"Rogue_Squadron_Space | Red_Squadron_Spawner | Moldy_Crow | Sundered_Heart | Millennium_Falcon | Moff_Falast_Star_Destroyer | Home_One = 0,1"
		,"Slave_I | Pellaeon_Acclamator | Arc_Hammer | Mara_Jade_Ship | TIE_Prototype_Spawner | Accuser_Star_Destroyer | Admonitor_Star_Destroyer | ISD_Gorgon = 0,1"
		,"Houndstooth | Errant_Venture | IG-2000 | The_Peacebringer = 0,1"
		,"Xizor_Virago | Chrysaetos | Qatil | Acklay | Pestelous_ISD | Galyana_SSD = 0,1"
		,"Pirate_Fighter_Squadron | Cobra_Squadron | Prowler-A_Squadron | IPV1_System_Patrol_Craft | Vonosmas_Corvette | Pirate_Frigate | Guardian_Star_Defender | Hammer_SA | Providence_SA | Zylon_Destroyer = 0,3"
		}
	}
	RequiredCategories = {"Fighter | Bomber | Corvette | Frigate | Capital | SpaceHero"}
	AllowFreeStoreUnits = false

end

function ReserveForce_Thread()

	BlockOnCommand(ReserveForce.Produce_Force())
	ReserveForce.Set_Plan_Result(true)
	ReserveForce.Set_As_Goal_System_Removable(false)

	-- Give some time to accumulate money.
	tech_level = PlayerObject.Get_Tech_Level()
	min_credits = 2000
	max_sleep_seconds = 30
	if tech_level == 2 then
		min_credits = 4000
		max_sleep_seconds = 50
	elseif tech_level >= 3 then
		min_credits = 6000
		max_sleep_seconds = 80
	end

	current_sleep_seconds = 0
	while (PlayerObject.Get_Credits() < min_credits) and (current_sleep_seconds < max_sleep_seconds) do
		current_sleep_seconds = current_sleep_seconds + 1
		Sleep(1)
	end

	ScriptExit()
end