diff --git a/engine/Sim.lua b/engine/Sim.lua index 83308adff3..ff675a17e9 100644 --- a/engine/Sim.lua +++ b/engine/Sim.lua @@ -7,7 +7,8 @@ ---@alias Bone string | number ---@alias Language "cn" | "cz" | "de" | "es" | "fr" | "it" | "pl" | "ru" | "tw" | "tzm" | "us" - +---@alias Object Blip | CollisionBeam | Entity | Prop | Projectile | Unit +---@alias ReclaimableObject Prop | Unit ---@alias BoneObject Projectile | Prop | Unit --- Restricts the army from building the unit category @@ -498,9 +499,9 @@ end function DrawLinePop() end ---- Check if the economy event is finished. --- @param event Economy event created by CreateEconomyEvent function. --- @return true/false. +--- Checks if the economy event is finished +---@param event moho.EconomyEvent +---@return boolean function EconomyEventIsDone(event) end @@ -704,8 +705,9 @@ end function IsCollisionBeam(entity) end ---- Returns true if given command is finished. --- @param cmd Unit's command crated for example by IssueMove(). +--- Returns if the given command is finished +---@param cmd SimCommand +---@return boolean function IsCommandDone(cmd) end @@ -738,289 +740,291 @@ end function IsUnit(entity) end ---- Order a group of units to attack move to target position. ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to attack move to ----@return SimCommand # Command that has been issued -function IssueAggressiveMove(tblUnits, position) +--- Orders a group of units to attack-move to a position +---@param units Unit[] +---@param position Vector +---@return SimCommand +function IssueAggressiveMove(units, position) end ---- Order a group of units to attack a target ----@param tblUnits Unit[] # Units to issue the command to ----@param target Unit # Unit to attack ----@return SimCommand # Command that has been issued -function IssueAttack(tblUnits, target) +--- Orders a group of units to attack a target +---@param units Unit[] +---@param target Unit +---@return SimCommand +function IssueAttack(units, target) end ---- Order a group of units to build a unit ----@param tblUnits Unit[] # Units to issue the command to, usually factories ----@param blueprintID string # BlueprintId of the unit to build ----@param count number # Number of units to build ----@return SimCommand # Command that has been issued -function IssueBuildFactory(tblUnits, blueprintID, count) +--- Orders a group of units to build a unit +---@param units Unit[] +---@param blueprintID string +---@param count number +---@return SimCommand +function IssueBuildFactory(units, blueprintID, count) end ---- Order a group of units to build a unit, each unit is assigned the closest building ----@param tblUnits Unit[] # Units to issue the command to, usually engineers ----@param position Point # Position to build at ----@param blueprintID string # BlueprintId of the unit to build ----@param table number # A list of alternative build locations, similar to AiBrain.BuildStructure. Doesn't appear to function properly ----@return SimCommand # Command that has been issued -function IssueBuildMobile(tblUnits, position, blueprintID, table) +--- Orders a group of units to build a unit, each unit is assigned the closest building. +--- Takes some time to process (at least 3 ticks). +---@param units Unit[] +---@param position Vector +---@param blueprintID string +---@param table number[] # A list of alternative build locations, similar to AiBrain.BuildStructure. Doesn't appear to function properly +---@return SimCommand +function IssueBuildMobile(units, position, blueprintID, table) end ---- Order a group of units to capture a target, usually engineers ----@param tblUnits Unit[] # Units to issue the command to ----@param target Unit # Unit to capture ----@return SimCommand # Command that has been issued -function IssueCapture(tblUnits, target) +--- Orders a group of units to capture a target, usually engineers +---@param units Unit[] +---@param target Unit +---@return SimCommand +function IssueCapture(units, target) end --- Clears out all commands issued on the group of units, this happens immediately ----@param tblUnits Unit[] # Units to issue the command to ----@return SimCommand # Command that has been issued -function IssueClearCommands(tblUnits) +---@param units Unit[] +---@return SimCommand +function IssueClearCommands(units) end ---- Clears out all commands issued on the group of factories without affecting the build queue, allows you to change the rally point ----@param tblUnits Unit[] # Units to issue the command to ----@return SimCommand # Command that has been issued -function IssueClearFactoryCommands(tblUnits) +--- Clears out all commands issued on the group of factories without affecting +--- the build queue, allows you to change the rally point +---@param factories Unit[] +---@return SimCommand +function IssueClearFactoryCommands(factories) end ---- Order a group of units to destroy themselves, doesn't leave a wreckage ----@see # The global `IssueKillSelf` is for an alternative that does leave a wreckage ----@param tblUnits Unit[] # Units to issue the command to ----@return SimCommand # Command that has been issued -function IssueDestroySelf(tblUnits) +--- Orders a group of units to destroy themselves, doesn't leave a wreckage +---@see IssueKillSelf() # an alternative that does leave a wreckage +---@param units Unit[] +---@return SimCommand +function IssueDestroySelf(units) end ---- Order a group of units to dive ----@param tblUnits Unit[] # Units to issue the command to ----@return SimCommand # Command that has been issued -function IssueDive(tblUnits) +--- Orders a group of units to dive +---@param units Unit[] +---@return SimCommand +function IssueDive(units) end ---- Order a group of factories to assist another factory ----@param tblUnits Unit[] # Units to issue the command to ----@param target Unit # Factory to assist ----@return SimCommand # Command that has been issued -function IssueFactoryAssist(tblUnits, target) +--- Orders a group of factories to assist another factory +---@param units Unit[] +---@param target Unit +---@return SimCommand +function IssueFactoryAssist(units, target) end ---- Order a group of factories to set their rally point ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to set the rally point ----@return SimCommand # Command that has been issued -function IssueFactoryRallyPoint(tblUnits, position) +--- Orders a group of factories to set their rally point +---@param units Unit[] +---@param position Vector +---@return SimCommand +function IssueFactoryRallyPoint(units, position) end ---- Order a group of units to setup a ferry ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to add to the ferry route ----@return SimCommand # Command that has been issued -function IssueFerry(tblUnits, position) +--- Orders a group of units to setup a ferry +---@param units Unit[] +---@param position Vector +---@return SimCommand +function IssueFerry(units, position) end ---- Order a group of units to attack move to a position in formation ---- @param tblUnits Unit[] # Units to issue the command to ---- @param position Point # Position to attack move to +--- Orders a group of units to attack move to a position in formation +--- @param units Unit[] +--- @param position Vector --- @param formation UnitFormations # Unit formation to use as defined in `formations.lua` --- @param degrees number # Orientation the platoon takes when it reaches the position. South is 0 degrees, east is 90 degrees, etc. ---- @return SimCommand # Command that has been issued -function IssueFormAggressiveMove(tblUnits, position, formation, degrees) +--- @return SimCommand +function IssueFormAggressiveMove(units, position, formation, degrees) end ---- Order a group of units to attack a target in formation ---- @param tblUnits Unit[] # Units to issue the command to ---- @param target Unit # Unit to attack +--- Orders a group of units to attack a target in formation +--- @param units Unit[] +--- @param target Unit --- @param formation UnitFormations # Unit formation to use as defined in `formations.lua` --- @param degrees number # Orientation the platoon takes when it reaches the position. South is 0 degrees, east is 90 degrees, etc. ---- @return SimCommand # Command that has been issued -function IssueFormAttack(tblUnits, target, formation, degrees) +--- @return SimCommand +function IssueFormAttack(units, target, formation, degrees) end ---- Order a group of units to move to a position in formation ---- @param tblUnits Unit[] # Units to issue the command to ---- @param position Point # Position to move to +--- Orders a group of units to move to a position in formation +--- @param units Unit[] +--- @param position Vector --- @param formation UnitFormations # Unit formation to use as defined in `formations.lua` --- @param degrees number # Orientation the platoon takes when it reaches the position. South is 0 degrees, east is 90 degrees, etc. ---- @return SimCommand # Command that has been issued -function IssueFormMove(tblUnits, position, formation, degrees) +--- @return SimCommand +function IssueFormMove(units, position, formation, degrees) end ---- Order a group of units to patrol to a position in formation, ---- @param tblUnits Unit[] # Units to issue the command to ---- @param position Point # Position to add to the patrol +--- Orders a group of units to patrol to a position in formation +--- @param units Unit[] +--- @param position Vector --- @param formation UnitFormations # Unit formation to use as defined in `formations.lua` --- @param degrees number # Orientation the platoon takes when it reaches the position. South is 0 degrees, east is 90 degrees, etc. ---- @return SimCommand # Command that has been issued -function IssueFormPatrol(tblUnits, position, formation, degrees) +--- @return SimCommand +function IssueFormPatrol(units, position, formation, degrees) end ---- Order a group of units to guard a target ----@param tblUnits Unit[] # Units to issue the command to ----@param target Unit # Unit to guard ----@return SimCommand # Command that has been issued -function IssueGuard(tblUnits, target) +--- Orders a group of units to guard a target +---@param units Unit[] +---@param target Unit +---@return SimCommand +function IssueGuard(units, target) end ---- Order a group of units to kill themselves ----@see # The global `IssueDestroySelf` is an alternative that does not leave a wreckage ----@param tblUnits Unit[] # Units to issue the command to ----@return SimCommand # Command that has been issued -function IssueKillSelf(tblUnits) +--- Orders a group of units to kill themselves +---@see IssueDestroySelf() # an alternative that does not leave a wreckage +---@param units Unit[] +---@return SimCommand +function IssueKillSelf(units) end ---- Order a group of units to move to a position ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to move to ----@return SimCommand # Command that has been issued -function IssueMove(tblUnits, position) +--- Orders a group of units to move to a position +---@param units Unit[] +---@param position Vector +---@return SimCommand +function IssueMove(units, position) end ---- Order a group of units to move off a factory build site ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to move to ----@return SimCommand # Command that has been issued -function IssueMoveOffFactory(tblUnits, position) +--- Orders a group of units to move off a factory build site +---@param units Unit[] +---@param position Vector +---@return SimCommand +function IssueMoveOffFactory(units, position) end ---- Order a group of units to launch a strategic missile at a position ----@see # the function `IssueTactical` for tactical missiles ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to launch to ----@return SimCommand # Command that has been issued -function IssueNuke(tblUnits, position) +--- Orders a group of units to launch a strategic missile at a position +---@see IssueTactical() # for tactical missiles +---@param units Unit[] +---@param position Vector +---@return SimCommand +function IssueNuke(units, position) end ---- Order a group of units to use Overcharge at a target ----@param tblUnits Unit[] # Units to issue the command to ----@param target Unit # Unit to overcharge ----@return SimCommand # Command that has been issued -function IssueOverCharge(tblUnits, target) +--- Orders a group of units to use Overcharge at a target +---@param units Unit[] +---@param target Unit +---@return SimCommand +function IssueOverCharge(units, target) end ---- Order a group of units to patrol to a position ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to add to the patrol ----@return SimCommand # Command that has been issued -function IssuePatrol(tblUnits, position) +--- Orders a group of units to patrol to a position +---@param units Unit[] +---@param position Vector +---@return SimCommand +function IssuePatrol(units, position) end ---- Order a unit to pause, this happens immediately ----@param unit Unit # Units to pause +--- Orders a unit to pause, this happens immediately +---@param unit Unit function IssuePause(unit) end ---- Order a group of units to reclaim a target ----@param tblUnits Unit[] # Units to issue the command to ----@param target Unit | Prop # Prop or unit to reclaim ----@return SimCommand # Command that has been issued -function IssueReclaim(tblUnits, target) +--- Orders a group of units to reclaim a target +---@param units Unit[] +---@param target ReclaimableObject +---@return SimCommand +function IssueReclaim(units, target) end ---- Order a group of units to repair a target ----@param tblUnits Unit[] # Units to issue the command to ----@param target Unit # Unit to repair ----@return SimCommand # Command that has been issued -function IssueRepair(tblUnits, target) +--- Orders a group of units to repair a target +---@param units Unit[] +---@param target Unit +---@return SimCommand +function IssueRepair(units, target) end ---- Order a group of units to sacrifice, sharing their resources to a target ----@param tblUnits Unit[] # Units to issue the command to ----@param target Unit # Unit to share the resources with ----@return SimCommand # Command that has been issued +--- Orders a group of units to sacrifice, yielding part of their build cost to a target +---@param tblUnits Unit[] +---@param target Unit +---@return SimCommand function IssueSacrifice(tblUnits, target) end ---- Order a group of units to run a script sequence, as an example: { TaskName = "EnhanceTask", Enhancement = "AdvancedEngineering" } ----@param tblUnits Unit[] # Units to issue the command to ----@param order table # Task / order to apply ----@return SimCommand # Command that has been issued +--- Orders a group of units to run a script sequence, as an example: { TaskName = "EnhanceTask", Enhancement = "AdvancedEngineering" } +---@param tblUnits Unit[] +---@param order table +---@return moho.ScriptTask_Methods function IssueScript(tblUnits, order) end ---- Order a group of units to build a nuke ----@param tblUnits Unit[] # Units to issue the command to, usually strategic missile launchers / defense ----@return SimCommand # Command that has been issued -function IssueSiloBuildNuke(tblUnits) +--- Orders a group of units (SML or SMD) to build a nuke +---@param units Unit[] +---@return SimCommand +function IssueSiloBuildNuke(units) end ---- Order a group of units to build a tactical missile ----@param tblUnits Unit[] # Units to issue the command to, usually tactical missile launchers ----@return SimCommand # Command that has been issued -function IssueSiloBuildTactical() +--- Orders a group of units to build a tactical missile +---@param units Unit[] +---@return SimCommand +function IssueSiloBuildTactical(units) end ---- Order a group of units to stop, this happens immediately ----@param tblUnits Unit[] # Units to issue the command to -function IssueStop(tblUnits) +--- Orders a group of units to stop, this happens immediately +---@param units Unit[] +function IssueStop(units) end ---- Order a group of units to launch a tactical missile ----@see # the function `IssueNuke` for strategical missiles ----@param tblUnits Unit[] # Units to issue the command to ----@param target Unit | Point # Unit or point to launch at ----@return SimCommand # Command that has been issued -function IssueTactical(tblUnits, target) +--- Orders a group of units to launch a tactical missile +---@see IssueNuke() # for strategic missiles +---@param units Unit[] +---@param target Unit | Vector +---@return SimCommand +function IssueTactical(units, target) end ---- Order a group of units to teleport to a position ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to teleport to ----@return SimCommand # Command that has been issued -function IssueTeleport(tblUnits, position) +--- Orders a group of units to teleport to a position +---@param units Unit[] +---@param position Vector +---@return SimCommand +function IssueTeleport(units, position) end ---- TODO. -function IssueTeleportToBeacon() +--- +---@param units Unit[] +---@param beacon unknown +---@return SimCommand +function IssueTeleportToBeacon(units, beacon) end ---- Order a group of units to attach themselves to a transport ----@param tblUnits Unit[] # Units to issue the command to ----@param transport Unit # Transport to be loaded ----@return SimCommand # Command that has been issued -function IssueTransportLoad(tblUnits, transport) +--- Orders a group of units to attach themselves to a transport +---@param units Unit[] +---@param transport Unit +---@return SimCommand +function IssueTransportLoad(units, transport) end ---- Order a group of transports to unload their cargo at a position ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to unload ----@return SimCommand # Command that has been issued -function IssueTransportUnload(tblUnits, position) +--- Orders a group of transports to unload their cargo at a position +---@param units Unit[] +---@param position Vector +---@return SimCommand +function IssueTransportUnload(units, position) end ---- Orders group of transports (carriers) to drop specific units at target position. --- This seems to work only with carriers and not with air transports. --- @param tblUnits Table containing transports (carriers). --- @param category Unit category (categories.BOMBER). --- @param position Table with position {x, y, z}. --- @return Returns the issued command. - ---- Order a group of transports or carriers to unload specific units, appears to work only for carriers ----@param tblUnits Unit[] # Units to issue the command to ----@param position Point # Position to unload ----@param category Categories # Unit types to unload ----@return SimCommand # Command that has been issued -function IssueTransportUnloadSpecific(tblUnits, category, position) +--- Orders a group of ~~transports~~ or carriers to unload specific units, +--- appears to work only for carriers +---@param units Unit[] +---@param position Vector +---@param category EntityCategory +---@return SimCommand +function IssueTransportUnloadSpecific(units, category, position) end ---- Order a group of units to upgrade ----@param tblUnits Unit[] # Units to issue the command to ----@param blueprintID string # BlueprintId of unit to upgrade to ----@return SimCommand # Command that has been issued -function IssueUpgrade(tblUnits, blueprintID) +--- Orders a group of units to upgrade +---@param units Unit[] +---@param blueprintID string +---@return SimCommand +function IssueUpgrade(units, blueprintID) end ---- TODO. --- INFO: ScriptTask.LUnitMove(self, target) -function LUnitMove(self, target) +--- Latent unit move +---@param unit Unit +---@param target Vector +function LUnitMove(unit, target) end ---- TODO. --- INFO: ScriptTask.LUnitMoveNear(self,target,range) -function LUnitMoveNear(self, target, range) +--- Latent unit move near +---@param unit Unit +---@param target Vector +---@param range number +function LUnitMoveNear(unit, target, range) end --- Lists all armies in the game @@ -1244,11 +1248,11 @@ end function TryCopyPose(unitFrom, entityTo, bCopyWorldTransform) end ---- Instanly moves entity to target location. --- @param entity Entity to teleport. --- @param location Table with position {x, y, z}. --- @param orientation Target orientation, optimal parameter. -function Warp(entity, location, orientation) +--- Instantly moves an entity to a location +---@param object Entity | Projectile | Unit +---@param location Vector +---@param orientation? Vector +function Warp(object, location, orientation) end --- diff --git a/engine/Sim/Unit.lua b/engine/Sim/Unit.lua index 139785f976..b4d920176e 100644 --- a/engine/Sim/Unit.lua +++ b/engine/Sim/Unit.lua @@ -4,61 +4,111 @@ local Unit = {} ---@class UnitId: string ----@alias LayerName "Air" | "Land" | "Orbital" | "Seabed" | "Sub" | "Water" +---@alias CommandCap +---| "RULEUCC_Move" +---| "RULEUCC_Stop" +---| "RULEUCC_Attack" +---| "RULEUCC_Guard" +---| "RULEUCC_Patrol" +---| "RULEUCC_RetaliateToggle" +---| "RULEUCC_Repair" +---| "RULEUCC_Capture" +---| "RULEUCC_Transport" +---| "RULEUCC_CallTransport" +---| "RULEUCC_Nuke" +---| "RULEUCC_Tactical" +---| "RULEUCC_Teleport" +---| "RULEUCC_Ferry" +---| "RULEUCC_SiloBuildTactical" +---| "RULEUCC_SiloBuildNuke" +---| "RULEUCC_Sacrifice" +---| "RULEUCC_Pause" +---| "RULEUCC_Overcharge" +---| "RULEUCC_Dive" +---| "RULEUCC_Reclaim" +---| "RULEUCC_SpecialAction" +---| "RULEUCC_Dock" +---| "RULEUCC_Script" +---| "RULEUCC_Invalid" + +---@alias ToggleCap +---| "RULEUTC_ShieldToggle" +---| "RULEUTC_WeaponToggle" +---| "RULEUTC_JammingToggle" +---| "RULEUTC_IntelToggle" +---| "RULEUTC_ProductionToggle" +---| "RULEUTC_StealthToggle" +---| "RULEUTC_GenericToggle" +---| "RULEUTC_SpecialToggle" +---| "RULEUTC_CloakToggle" + +---@alias UnitState +---| "Immobile" +---| "Moving" +---| "Attacking" +---| "Guarding" +---| "Building" +---| "Upgrading" +---| "WaitingForTransport" +---| "TransportLoading" +---| "TransportUnloading" +---| "MovingDown" +---| "MovingUp" +---| "Patrolling" +---| "Busy" +---| "Attached" +---| "BeingReclaimed" +---| "Repairing" +---| "Diving" +---| "Surfacing" +---| "Teleporting" +---| "Ferrying" +---| "WaitForFerry" +---| "AssistMoving" +---| "PathFinding" +---| "ProblemGettingToGoal" +---| "NeedToTerminateTask" +---| "Capturing" +---| "BeingCaptured" +---| "Reclaiming" +---| "AssistingCommander" +---| "Refueling" +---| "GuardBusy" +---| "ForceSpeedThrough" +---| "UnSelectable" +---| "DoNotTarget" +---| "LandingOnPlatform" +---| "CannotFindPlaceToLand" +---| "BeingUpgraded" +---| "Enhancing" +---| "BeingBuilt" +---| "NoReclaim" +---| "NoCost" +---| "BlockCommandQueue" +---| "MakingAttackRun" +---| "HoldingPattern" +---| "SiloBuildingAmmo" +---@alias LayerName "Air" | "Land" | "Orbital" | "Seabed" | "Sub" | "Water" --- ---@param category moho.EntityCategory function Unit:AddBuildRestriction(category) end ---- Add a command cap to a unit. --- Also adds a button to the UI, or enables it, for the unit to use the new command. ----@param capName "RULEUCC_Move" ---- |"RULEUCC_Stop" ---- |"RULEUCC_Attack" ---- |"RULEUCC_Guard" ---- |"RULEUCC_Patrol" ---- |"RULEUCC_RetaliateToggle" ---- |"RULEUCC_Repair" ---- |"RULEUCC_Capture" ---- |"RULEUCC_Transport" ---- |"RULEUCC_CallTransport" ---- |"RULEUCC_Nuke" ---- |"RULEUCC_Tactical" ---- |"RULEUCC_Teleport" ---- |"RULEUCC_Ferry" ---- |"RULEUCC_SiloBuildTactical" ---- |"RULEUCC_SiloBuildNuke" ---- |"RULEUCC_Sacrifice" ---- |"RULEUCC_Pause" ---- |"RULEUCC_Overcharge" ---- |"RULEUCC_Dive" ---- |"RULEUCC_Reclaim" ---- |"RULEUCC_SpecialAction" ---- |"RULEUCC_Dock" ---- |"RULEUCC_Script" ---- |"RULEUCC_Invalid" +---@param capName CommandCap function Unit:AddCommandCap(capName) end ---- Add a toggle cap to a unit. +--- Adds a toggle cap to the unit. --- Also adds a button to the UI, or enables it, for the unit to use the new command. ----@param capName string Available: --- RULEUTC_ShieldToggle --- RULEUTC_WeaponToggle --- RULEUTC_JammingToggle --- RULEUTC_IntelToggle --- RULEUTC_ProductionToggle --- RULEUTC_StealthToggle --- RULEUTC_GenericToggle --- RULEUTC_SpecialToggle --- RULEUTC_CloakToggle +---@param capName ToggleCap function Unit:AddToggleCap(capName) end ---- Adds unit to the storage of the carrier. --- @param unit Target unit to load. +--- Adds unit to the storage of the carrier +---@param unit Unit function Unit:AddUnitToStorage(unit) end @@ -80,16 +130,17 @@ end function Unit:CanBuild(bpID) end ---- See if the unit can path to the goal. --- @param position Table with position {x, y, z}. --- @return result, bestGoal true/false, if falses, returns the closest position, else the original position. +--- See if the unit can path to the goal +---@param position Position +---@return boolean result if false, returns the closest position, else the original position +---@return Position bestGoal function Unit:CanPathTo(position) end ---- See if the unit can path to the goal rectangle. --- TODO: find out if it returns position as well --- @param rectangle Map area created by function Rect(x0, z0, x1, z1). --- @return true/false +--- See if the unit can path to the goal rectangle +--- TODO: find out if it returns position as well +---@param rectangle Rectangle +---@return boolean function Unit:CanPathToRect(rectangle) end @@ -125,6 +176,10 @@ end function Unit:GetBlueprint() end +---@return UnitBlueprint +function Unit:GetBlueprint() +end + --- Returns the build rate of a unit. -- What fraction of target unit it builds per second. -- @return rate @@ -136,8 +191,8 @@ end function Unit:GetCargo() end ---- Return table of commands queued up for this unit. --- @return table +--- Returns table of commands queued up for this unit +---@return OrderInfo[] function Unit:GetCommandQueue() end @@ -183,13 +238,13 @@ end function Unit:GetFuelUseTime() end ---- Returns the unit that is being guarded. --- @return unit Guarded unit or nil. +--- Returns the unit that is being guarded +---@return Unit | nil function Unit:GetGuardedUnit() end ---- Find out units that are guarding this unit. --- @return table Table of units that are guarding this uni. +--- Find out units that are guarding this unit +---@return Unit[] function Unit:GetGuards() end @@ -207,8 +262,8 @@ end function Unit:GetNukeSiloAmmoCount() end ---- Get number of factory/engineer build orders that fit in the specified category. --- @param category Unit's category, example: categories.ALLUNITS. +--- Get number of factory/engineer build orders that fit in the specified category +---@param category EntityCategory function Unit:GetNumBuildOrders(category) end @@ -232,9 +287,10 @@ end function Unit:GetResourceConsumed() end ---- Get the current toggle state of the script bit that matches the string. --- TODO. -function Unit:GetScriptBit() +--- Get the current toggle state of the script bit that matches the number +---@param bit number +---@return boolean +function Unit:GetScriptBit(bit) end --- Get the shield ratio, `0.0` - `1.0` @@ -311,7 +367,8 @@ end function Unit:HasMeleeSpaceAroundTarget(target) end ---- TODO. +--- +---@return boolean function Unit:HasValidTeleportDest() end @@ -321,55 +378,55 @@ end function Unit:HideBone(bone, affectChildren) end ---- See if unit is under construction. --- @return bool true/false. +--- Returns if the unit is under construction +---@return boolean function Unit:IsBeingBuilt() end ---- Returns if this unit can be captured or not. --- @return bool true/false. +--- Returns if the unit can be captured +---@return boolean function Unit:IsCapturable() end ---- See if the eunit is in Idle state or not. --- @return bool true/false. +--- Returns if the unit is in an Idle state +---@return boolean function Unit:IsIdleState() end ---- See if it's a mobile unit. --- @return bool true/false. +--- Returns if it's a mobile unit +---@return boolean function Unit:IsMobile() end ---- See if the unit is moving or not. --- @return bool true/false. +--- Returns if the unit is moving +---@return boolean function Unit:IsMoving() end ---- See if the unit has paused overcharge. --- @return bool true/false. +--- Returns if the unit has paused overcharge +---@return boolean function Unit:IsOverchargePaused() end ---- See if the unit is paused. --- @return bool true/false. +--- Returns if the unit is paused +---@return boolean function Unit:IsPaused() end ---- See if the unit is stunned. --- @return bool true/false. +--- Returns if the unit is stunned +---@return boolean function Unit:IsStunned() end ---- See if the unit is in given state. --- @param stateName String, see SetUnitState function for available states. --- @return bool true/false. +--- Returns if the unit is in given state +---@param stateName UnitState +---@return boolean function Unit:IsUnitState(stateName) end ---- TODO. --- @return bool true/false. -function Unit:IsValidTarget(self) +--- +---@return boolean +function Unit:IsValidTarget() end --- Kill a specific manipulator held by a script object. @@ -403,9 +460,9 @@ end function Unit:RemoveBuildRestriction(category) end ---- Remove a command cap to a unit. --- Also removes the command button, or disables it, from the UI, see AddCommandCap for available options. --- @param capName String. +--- Removes a command cap from the unit. +--- Also removes the command button, or disables it, from the UI. +---@param capName CommandCap function Unit:RemoveCommandCap(capName) end @@ -419,9 +476,9 @@ end function Unit:RemoveTacticalSiloAmmo(amount) end ---- Remove a toggle cap to a unit. --- Also removes the command button, or disables it, from the UI, see AddToggleCap for available options. --- @param capName String. +--- Removes a toggle cap from the unit. +--- Also removes the command button, or disables it, from the UI. +---@param capName ToggleCap function Unit:RemoveToggleCap(capName) end @@ -433,7 +490,7 @@ end function Unit:RestoreCommandCaps() end ---- Restore the toggle caps of the unit back to blueprint spec. +--- Restore the toggle caps of the unit back to blueprint spec function Unit:RestoreToggleCaps() end @@ -459,14 +516,14 @@ end function Unit:SetAccMult(float) end ---- Set auto silo build mode to on/off. --- @param bool true/false -function Unit:SetAutoMode(bool) +--- Set auto silo build mode to on/off +---@param mode boolean +function Unit:SetAutoMode(mode) end ---- TODO. --- @param flag true/false. -function Unit:SetBlockCommandQueue(flag) +--- +---@param block boolean +function Unit:SetBlockCommandQueue(block) end --- Set the break off distance multiplier of the unit. @@ -489,9 +546,9 @@ end function Unit:SetBusy(flag) end ---- Set if this unit can be captured or not. --- @param flag true/false. -function Unit:SetCapturable(flag) +--- Sets if this unit can be captured +---@param capturable boolean +function Unit:SetCapturable(capturable) end --- TODO. @@ -520,10 +577,10 @@ end function Unit:SetCustomName(name) end ---- If set true, enemy units won't target this unit. --- Accidental hits can still damage it but it enemy units won't lock on it. --- @param flag true/false. -function Unit:SetDoNotTarget(flag) +--- If set to true, enemy units won't target this unit. +--- Accidental hits can still damage it but it enemy units won't lock onto it. +---@param dontTarget boolean +function Unit:SetDoNotTarget(dontTarget) end --- Set the elevation of the unit @@ -551,24 +608,24 @@ end function Unit:SetFuelUseTime(seconds) end ---- Sets if the unit is able to move. --- @param flag true/false. -function Unit:SetImmobile(flag) +--- Sets if the unit is able to move +---@param immobile boolean +function Unit:SetImmobile(immobile) end --- --- SetIsValidTarget(self,bool) -function Unit:SetIsValidTarget(self, bool) +---@param valid boolean +function Unit:SetIsValidTarget(valid) end ---- Set if this unit has an overcharge pasued. --- @param flag true/false. -function Unit:SetOverchargePaused(flag) +--- Set if this unit has an overcharge paused +---@param paused boolean +function Unit:SetOverchargePaused(paused) end ---- Pauses building, upgrading and other tasks of the unit. --- @param flag true/false. -function Unit:SetPaused(flag) +--- Pauses building, upgrading, and other tasks +---@param paused boolean +function Unit:SetPaused(paused) end --- Enable, disable production of resources on the unit. @@ -597,10 +654,10 @@ end function Unit:SetRegenRate(rate) end ---- Set the script bit that matches the string to the desired state. --- @param string TODO. --- @param state true/false. -function Unit:SetScriptBit(string, state) +--- Set the script bit to the desired state +---@param bit number +---@param state boolean +function Unit:SetScriptBit(bit, state) end --- Set the shield ratio, `0.0` - `1.0` @@ -635,66 +692,20 @@ end function Unit:SetTurnMult(float) end ---- Set if the unit can be selected. --- @param flag true/false. +--- Sets if the unit can be selected +---@param flag boolean function Unit:SetUnSelectable(flag) end ---- Set unit's state. --- @param stateName String, name of the state to set. --- 'Immobile' --- 'Moving' --- 'Attacking' --- 'Guarding' --- 'Building' --- 'Upgrading' --- 'WaitingForTransport' --- 'TransportLoading' --- 'TransportUnloading' --- 'MovingDown' --- 'MovingUp' --- 'Patrolling' --- 'Busy' --- 'Attached' --- 'BeingReclaimed' --- 'Repairing' --- 'Diving' --- 'Surfacing' --- 'Teleporting' --- 'Ferrying' --- 'WaitForFerry' --- 'AssistMoving' --- 'PathFinding' --- 'ProblemGettingToGoal' --- 'NeedToTerminateTask' --- 'Capturing' --- 'BeingCaptured' --- 'Reclaiming' --- 'AssistingCommander' --- 'Refueling' --- 'GuardBusy' --- 'ForceSpeedThrough' --- 'UnSelectable' --- 'DoNotTarget' --- 'LandingOnPlatform' --- 'CannotFindPlaceToLand' --- 'BeingUpgraded' --- 'Enhancing' --- 'BeingBuilt' --- 'NoReclaim' --- 'NoCost' --- 'BlockCommandQueue' --- 'MakingAttackRun' --- 'HoldingPattern' --- 'SiloBuildingAmmo' --- @param bool true/false. +--- Sets the unit's state +---@param stateName UnitState +---@param bool boolean function Unit:SetUnitState(stateName, bool) end ---- Set the work progress on the unit. --- Used for ACU upgrades, missile construction? TODO. --- @param float Range 0 - 1, where 1 is completed. -function Unit:SetWorkProgress(float) +--- Sets the work progress on the unit, `0.0` - `1.0` +---@param progress number +function Unit:SetWorkProgress(progress) end --- Makes unit's bone visible. @@ -707,13 +718,13 @@ end function Unit:StopSiloBuild() end ---- Test if a unit has this specified set to true in the blueprint spec. --- @param capName String. +--- Test if the unit has this specified set to true in the blueprint spec +---@param capName CommandCap function Unit:TestCommandCaps(capName) end ---- Test if a unit has this specified set to true in the blueprint spec. --- @param capName String. +--- Test if the unit has this specified set to true in the blueprint spec +---@param capName ToggleCap function Unit:TestToggleCaps(capName) end @@ -721,24 +732,25 @@ end function Unit:ToggleFireState() end ---- Toggle the script bit that matches the string. --- TODO. -function Unit:ToggleScriptBit() + +--- Toggles the script bit that matches the number +---@param bit number +function Unit:ToggleScriptBit(bit) end ---- Detach all units from a transport. --- @param destroySomeUnits TODO. +--- Detaches all units from a transport +---@param destroySomeUnits unknown function Unit:TransportDetachAllUnits(destroySomeUnits) end ---- Find out if carrier is full or not. --- @return true/false. +--- Finds out if carrier is full or not +---@return boolean function Unit:TransportHasAvailableStorage() end ---- Find out if the target unit can fit into the carrier. --- @param target Unit to test. --- @return true/false. +--- Finds out if the target unit can fit into the carrier +---@param target Unit +---@return boolean function Unit:TransportHasSpaceFor(target) end