Skip to content

Conversation

@K1CE
Copy link
Contributor

@K1CE K1CE commented Jan 15, 2025

##what
This fixes the orbital unit's inability to be destroyed.
Currently, Deadline is indestructible upon being built. This is in contrast to how the other satellite artillery from UEF functions where it can be taken down by destroying the central command building.

##why
It makes it impossible for games started in 'Annihilation' gamemode (which requires every enemy unit to be destroyed) to end.

##how
All Deadlines are destroyed in the OnKilled event of Countdown as long as there are no other Countdowns.

K1CE added 2 commits January 7, 2025 15:51
Destroy all Deadlines with the death of the last Countdown
local NUtils = import('/lua/nomadsutils.lua')

--- Tech 3 Stationary Artillery
---@class XNB2302 : NStructureUnit
Copy link
Contributor

Choose a reason for hiding this comment

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

Please re-add the annotations.

Comment on lines +19 to +34
--Destroy all orbital on Countdown's death
local units = self:GetAIBrain():GetListOfUnits(categories.EXPERIMENTAL, false, false)
local toRemove = {}
for i, unit in ipairs(units) do
local name = unit:GetBlueprint().General.UnitName

--abort if another Countdown still exists
if unit:GetUnitId() == "xnb2302" and unit:GetEntityId() ~= self:GetEntityId() then return end
if unit:GetUnitId() == "xno2302" then
toRemove[i] = unit
end
end

for _, unit in pairs(toRemove) do
unit:Kill()
end
Copy link
Contributor

Choose a reason for hiding this comment

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

  • You can use the unit's blueprint id (which is lowercase) as a category
  • FAF adds Unit.Brain as a quicker replacement for Unit:GetAIBrain()
  • FAF adds Unit.Dead to check death status. For this station, it will be set to true in the OnKilled you called earlier. For other stations, we have to check it just in case multiple stations die at the same time and a different station exists as a unit but is in its death animation (the entity ID check doesn't work for that case).
Suggested change
--Destroy all orbital on Countdown's death
local units = self:GetAIBrain():GetListOfUnits(categories.EXPERIMENTAL, false, false)
local toRemove = {}
for i, unit in ipairs(units) do
local name = unit:GetBlueprint().General.UnitName
--abort if another Countdown still exists
if unit:GetUnitId() == "xnb2302" and unit:GetEntityId() ~= self:GetEntityId() then return end
if unit:GetUnitId() == "xno2302" then
toRemove[i] = unit
end
end
for _, unit in pairs(toRemove) do
unit:Kill()
end
-- If no other Countdowns exist, kill all Deadline satellites
local brain = self.Brain
local stations = brain:GetListOfUnits(categories.xnb2302, false, true)
for _, station in stations do
if not station.Dead then
return
end
end
local satellites = brain:GetListOfUnits(categories.xno2302, false, true)
for _, satellite in satellites do
satellite:Kill()
end

Copy link
Contributor

Choose a reason for hiding this comment

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

The satellites cost a lot, so maybe it can be more fun to disable their weapons, movement, and selectability once all stations are dead. You would also have to handle re-enabling all satellites once a station is rebuilt.

satellite:SetAllWeaponsEnabled(false)
satellite:SetUnSelectable(true)
satellite:SetImmobile(true)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants