Skip to content
Open
Show file tree
Hide file tree
Changes from all 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
1 change: 1 addition & 0 deletions changelog/snippets/fix.6863md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- (#6863) Fix `OnAdjacentTo` error caused by dummy units attached to external factories and UEF engineering drones.
1 change: 1 addition & 0 deletions engine/Core/Categories.lua
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ categories = {
CANNOTUSEAIRSTAGING = categoryValue,
CANTRANSPORTCOMMANDER = categoryValue,
CAPTURE = categoryValue,
--- Changes engine behavior of units attached to this unit: Hides units and makes them unselectable.
CARRIER = categoryValue,
--- Allows the unit to land on water. Is introduced by https://github.com/FAForever/FA-Binary-Patches/pull/20
CANLANDONWATER = categoryValue,
Expand Down
26 changes: 26 additions & 0 deletions lua/sim/units/components/DebugUnitComponent.lua
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,17 @@

local DebugComponent = import("/lua/shared/components/debugcomponent.lua").DebugComponent

---@type UnitState[]
UnitStates = { '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',
}

---@class DebugUnitComponent : DebugComponent
DebugUnitComponent = Class(DebugComponent) {

Expand Down Expand Up @@ -118,4 +129,19 @@ DebugUnitComponent = Class(DebugComponent) {
local blueprint = self.Blueprint
DrawCircle(self:GetPosition(), math.max(blueprint.SizeX, blueprint.SizeY, blueprint.SizeZ), color)
end,

DebugActiveStates = function(self)
if not self.EnabledLogging then
return
end

local activeStates = {}
for _, state in UnitStates do
if self:IsUnitState(state) then
table.insert(activeStates, state)
end
end

self:DebugLog('Active states: ' .. table.concat(activeStates, ', '))
end,
}
21 changes: 3 additions & 18 deletions lua/sim/units/uef/TConstructionPodUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,13 @@ local oldGetGuards = TConstructionUnit.GetGuards
---@field Pod string
---@field Parent? UEL0301 | UEL0001 # Only these two units set the parent properly
---@field guardCache table
---@field guardDummy Unit
---@field rebuildDrone boolean # If true, the parent should rebuild the pod. Caches script bit 1.
TConstructionPodUnit = ClassUnit(TConstructionUnit) {
Parent = nil,

---@param self TConstructionPodUnit
OnCreate = function(self)
TConstructionUnit.OnCreate(self)
self.guardDummy = CreateUnitHPR('ZXA0003', self:GetArmy(), 0,0,0,0,0,0)
self.guardDummy:AttachTo(self, -1)
self.Trash:Add(self.guardDummy)
end,

---@param self TConstructionPodUnit
Expand All @@ -40,22 +36,11 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) {
---@param transport Unit
---@param bone number
OnAttachedToTransport = function(self, transport, bone)
local guards = self:GetGuards()
IssueClearCommands(guards)
IssueGuard(guards, self.guardDummy)
-- Removing the state allows guards to keep assisting the drone
self:SetUnitState("Attached", false)
TConstructionUnit.OnAttachedToTransport(self, transport, bone)
end,

---@param self TConstructionPodUnit
---@param transport Unit
---@param bone number
OnDetachedFromTransport = function(self, transport, bone)
TConstructionUnit.OnDetachedFromTransport(self, transport, bone)
local guards = self.guardDummy:GetGuards()
IssueClearCommands(guards)
IssueGuard(guards, self)
end,

---@param self TConstructionPodUnit
---@param parent UEL0301 | UEL0001 # Only these two implement the function `NotifyOfPodDeath`
---@param podName string
Expand Down Expand Up @@ -95,7 +80,7 @@ TConstructionPodUnit = ClassUnit(TConstructionUnit) {
---@param target Unit|Prop
OnStopReclaim = function(self, target)
TConstructionUnit.OnStopReclaim(self, target)
-- Check if we finished our reclaim task and clear our cached commaand if so
-- Check if we finished our reclaim task and clear our cached command if so
if self.guardCache and table.empty(target) then
self.guardCache = nil
end
Expand Down
5 changes: 3 additions & 2 deletions units/ZXA0002/ZXA0002_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ UnitBlueprint {
'FACTORY',
'CONSTRUCTION',
'SELECTABLE',
'UNTARGETTABLE',
'UNTARGETABLE',
'RALLYPOINT',
'SORTCONSTRUCTION',
'DRAGBUILD',
'SHOWQUEUE',
'EXTERNALFACTORYUNIT'
'EXTERNALFACTORYUNIT',
'UNSPAWNABLE',
},
Defense = {
Health = 100000,
Expand Down
11 changes: 0 additions & 11 deletions units/ZXA0003/ZXA0003_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,6 @@ local DummyUnit = import('/lua/sim/unit.lua').DummyUnit

---@class ZXA0003 : DummyUnit
ZXA0003 = ClassUnit(DummyUnit) {

OnCreate = function (self)
self:HideBone(0, true)
-- do not allow the unit to be killed or to take damage
self.CanTakeDamage = false

-- do not allow the unit to be reclaimed or targeted by weapons
self:SetReclaimable(false)
self:SetDoNotTarget(true)
end,

DetachFrom = function(self)
end,
}
Expand Down
30 changes: 1 addition & 29 deletions units/ZXA0003/ZXA0003_unit.bp
Original file line number Diff line number Diff line change
Expand Up @@ -8,40 +8,12 @@ UnitBlueprint{
"UNTARGETABLE",
"CARRIER",
},
Defense = {
Health = 30,
MaxHealth = 30,
},
Display = {
Mesh = {
IconFadeInZoom = 2000,
LODs = {
{
ShaderName = 'Unit',
MeshName = '/Units/UEA0001/UEA0001_lod0.scm',
AlbedoName = '/Units/UEA0001/UEA0001_Albedo.dds',
NormalsName = '/Units/UEA0001/UEA0001_normalsTS.dds',
SpecularName = '/Units/UEA0001/UEA0001_SpecTeam.dds',
},
},
},
UniformScale = 0.12,
},
Economy = {
BuildCostEnergy = 0,
BuildCostMass = 0,
BuildTime = 0,
},
General = {
CapCost = 0,
Category = '',
SelectionPriority = 3,
},
Intel = { VisionRadius = 0 },
Physics = {
MotionType = "RULEUMT_None",
},
SizeX = 0,
SizeY = 0,
SizeZ = 0,
CollisionShape = "None"
}