Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prevent siloes from cancelling missiles when issued a hard-stop command #6557

Merged
merged 5 commits into from
Nov 26, 2024
Merged
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 23 additions & 9 deletions lua/ui/game/orders.lua
Original file line number Diff line number Diff line change
Expand Up @@ -298,14 +298,6 @@ local function MomentaryOrderBehavior(self, modifiers)
self:SetCheck(false)
end

function Stop(units)
local units = units or GetSelectedUnits()

if units[1] then
IssueUnitCommand(units, 'Stop')
end
end

function ClearCommands(units)
local cb = {Func = 'ClearCommands'}

Expand All @@ -326,8 +318,30 @@ function ClearCommands(units)
SimCallback(cb, true)
end

-- This command (hard stop) will filter out non-construction silo units to avoid wasting partially completed missiles
-- Those units will have their commands cleared, but will be paused instead of stopped
function Stop(units)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please annotate the parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In process of annotating the whole file, will put in separate pr

units = units or GetSelectedUnits()
local silos = EntityCategoryFilterDown(categories.SILO - categories.CONSTRUCTION, units)
if silos[1] then
ClearCommands(silos)
for _, silo in silos do
if not GetIsPausedOfUnit(silo) then
local missileInfo = silo:GetMissileInfo()
if missileInfo.nukeSiloBuildCount > 0 or missileInfo.tacticalSiloBuildCount > 0 then
IssueUnitCommand(silo, 'Pause')
end
end
end
end
units = EntityCategoryFilterOut(categories.SILO - categories.CONSTRUCTION, units)
if units[1] then
IssueUnitCommand(units, 'Stop')
end
end

function SoftStop(units)
local units = units or GetSelectedUnits()
units = units or GetSelectedUnits()
Construction.ResetOrderQueues(units)
ClearCommands(EntityCategoryFilterDown(categories.SILO, units))
Stop(EntityCategoryFilterOut((categories.SHOWQUEUE * categories.STRUCTURE) + categories.FACTORY + categories.SILO, units))
Expand Down
Loading