--/////////////////////////////////////////////////////////////////////////////////////////////////
--  (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/LandMode/TacticalMultiplayerBuildLandUnitsGeneric.LUA
--
-- Original Editor: Giovanni Galyana
--
--   Final Edit By: Giovanni Galyana
--
--            Date: 17 April, 2023
--
--       Revisions: 8
--
--/////////////////////////////////////////////////////////////////////////////////////////////////
-- Rebel_Infantry_Squad_ALT | Rebel_Rifle_Squad_ALT | Rebel_Tank_Buster_Squad_ALT | Rebel_Infiltrator_Team_ALT | Rebel_Combat_Medic_Squad_ALT
-- Empire_T1_FCU_Company | Empire_T2_FCU_Company | Empire_T3_FCU_Company | Empire_T4_FCU_Company
-- Rebel_T1_FCU_Company | Rebel_T2_FCU_Company | Rebel_T3_FCU_Company | Rebel_T4_FCU_Company
-- Underworld_T1_FCU_Company | Underworld_T2_FCU_Company | Underworld_T3_FCU_Company | Underworld_T4_FCU_Company
-- Hutt_T1_FCU_Company | Hutt_T2_FCU_Company | Hutt_T3_FCU_Company | Hutt_T4_FCU_Company

require("pgevents")

function Definitions()
	
	Category = "Tactical_Multiplayer_Build_Land_Units_Generic"
	IgnoreTarget = true
	TaskForce = {
	{
		"ReserveForce"
		,"DenySpecialWeaponAttach"
		,"DenyHeroAttach"
		,"RC_Level_Two_Tech_Upgrade | RC_Level_Three_Tech_Upgrade | RC_Level_Four_Tech_Upgrade = 0,1"
		,"EC_Level_Two_Tech_Upgrade | EC_Level_Three_Tech_Upgrade | EC_Level_Four_Tech_Upgrade = 0,1"
		,"UC_Level_Two_Tech_Upgrade | UC_Level_Three_Tech_Upgrade | UC_Level_Four_Tech_Upgrade = 0,1"
		,"HC_Level_Two_Tech_Upgrade | HC_Level_Three_Tech_Upgrade | HC_Level_Four_Tech_Upgrade = 0,1"
		,"PC_Level_Two_Tech_Upgrade | PC_Level_Three_Tech_Upgrade | PC_Level_Four_Tech_Upgrade = 0,1"
		,"Boba_Fett_Team_Land_MP | Darth_Team_Land_MP | General_Veers_Team | Emperor_Palpatine_Team | Mara_Jade_Team = 0,1"
		,"Han_Solo_Team_Land_MP | Obi_Wan_Team | Droids_Team | Katarn_Team | Yoda_Team | Luke_Skywalker_Jedi_Team | Garm_Bel_Iblis_Team = 0,1"
		,"Urai_Fen_Team | Bossk_Team | Silri_Team | Tyber_Zann_Team | IG88_Team_Land_MP = 0,1"
		,"Sykariius_Team | Nikomer_Team | Xizor_Team | Pestelous_Team | Cuarson_Team = 0,1"
		,"Pirate_Soldier_Squad_R | Rebel_Skiff_Team | Rebel_Heavy_Skiff_Team | Swamp_Speeder_Team_R | Pod_Walker_Company_R | Rebel_Infantry_Squad | Rebel_Tank_Buster_Squad | Rebel_Rifle_Squad | Rebel_Infiltrator_Team | Rebel_Combat_Medic_Squad | Rebel_Artillery_Brigade | Rebel_Scout_Tank_Brigade | Rebel_Light_Tank_Brigade | Rebel_Medium_Tank_Brigade | Rebel_Heavy_Tank_Brigade | Rebel_Experimental_Tank_Brigade = 0,3"
		,"Pirate_Soldier_Squad_E | Empire_Skiff_Team | Empire_Heavy_Skiff_Team | Swamp_Speeder_Team_E | Pod_Walker_Company_E | Imperial_Anti_Infantry_Brigade | Imperial_Armor_Group | Imperial_Heavy_Scout_Squad | Imperial_Heavy_Assault_Company | Imperial_Light_Scout_Squad | Imperial_Stormtrooper_Squad | DarkTrooper_P1_Company | DarkTrooper_P2_Company | DarkTrooper_P3_Company | Noghri_Assassin_Squad | Imperial_Sniper_Team | Darkside_Adept_Team | Imperial_AT_RT_Scout_Squad | Imperial_AT_PT_Scout_Squad | Imperial_AT_TE_Assault_Company = 0,3"
		,"Pirate_Soldier_Squad_U | Underworld_Skiff_Team | Underworld_Heavy_Skiff_Team | Swamp_Speeder_Team_U | Pod_Walker_Company_U | Canderous_Assault_Tank_Company | Destroyer_Droid_Company | Underworld_Disruptor_Merc_Squad | Mandalorian_Warrior_Company | MAL_Rocket_Vehicle_Company | Underworld_Merc_Squad | Night_Sister_Company | MZ8_Pulse_Cannon_Tank_Company | HAG_Company | B1_Battledroid_Company | B2_Battledroid_Company = 0,3"
		,"Pirate_Soldier_Squad_H | Hutt_Soldier_Squad | Hutt_Elite_Soldier_Squad | Hutt_Sniper_Squad | Hutt_PLEX_Soldier_Squad | Heavy_Beam_Tank_Company | Hutt_Modified_Pod_Walker_Team | Hutt_Modified_Skiff_Team | Hutt_Heavy_Skiff_Team | Hutt_Modified_Swamp_Speeder_Team | AALL6_Company | Medium_Tank_Company = 0,3"
		,"Rebel_MDU_Company | Rebel_Field_Mechanic_Squad | Rebel_Speeder_Wing | Rebel_AssaultSpeeder_Wing | Rebel_Atmospheric_XWing_Squad | Gallofree_HTT_Company | Valahari_Fighter_Company_R = 0,1"
		,"Empire_MDU_Company | HAV_Juggernaut_Company | Lancet_Air_Wing | Scimitar_Assault_Squad | TIE_Neutralizer_Squad | Imperial_Anti_Aircraft_Company | Valahari_Fighter_Company_E  = 0,1"
		,"Underworld_MDU_Company | Underworld_Saboteur_Team | Vornskr_Wolf_Pack | Underworld_Ewok_Handler_Company | MagnaGuard_Company | B1_Repairdroid_Company | F9TZ_Cloaking_Transport_Company | Fanblade_Fighter_Company | Nantex_Fighter_Company | Gauntlet_Heavy_Fighter_Company | Valahari_Fighter_Company_U = 0,1" 
		,"Hutt_MDU_Company | Hutt_Bounty_Hunter_Company | Hutt_SailBarge_Company | Field_Com_Hutts_Team | Twilek_Commando_Company | Scyk_Fighter_Company | Hutt_Valahari_Fighter_Company | Sandfire_Company | Vaksai_Gunship_Company = 0,1"
		,"Pirate_Soldier_Squad | Pirate_Scout_Squad | Pirate_PLEX_Squad | Pirate_Assassin_Company_P | Pirate_Diplomat_Company | Pirate_Swamp_Speeder_Team | Pirate_Skiff_Team | Pirate_Pod_Walker_Team | Heavy_Skiff_Team | Valahari_Fighter_Company = 0,3"
		}
	}
	RequiredCategories = {"Infantry | Vehicle | LandHero | Upgrade"}
	AllowFreeStoreUnits = false

end

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

	-- 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 = 3000
		max_sleep_seconds = 45
	elseif tech_level >= 3 then
		min_credits = 4000
		max_sleep_seconds = 60
	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