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.
8 changes: 6 additions & 2 deletions lua/sim/units/StructureUnit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,9 @@ StructureUnit = ClassUnit(Unit, BlinkingLightsUnitComponent) {
OnAdjacentTo = function(self, adjacentUnit, triggerUnit)

-- make sure we're both finished building
if self:IsBeingBuilt() or adjacentUnit:IsBeingBuilt() then
if self:IsBeingBuilt() or adjacentUnit:IsBeingBuilt()
or adjacentUnit.Blueprint.CategoriesHash["DUMMYUNIT"]
Copy link
Member

Choose a reason for hiding this comment

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

By the suggested logic the dummy unit should not have adjacency.

Whats the reason to put this check into Structure?

Why not to add OnAdjacentTo OnNotAdjacentTo to the Dummy class that would return?

Copy link
Contributor

Choose a reason for hiding this comment

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

^Second this suggestion. Keeping things modular means that any future changes/removals don't leave lingering logic in the base class. Additionally, as the original implementer of zxa0003 I'll say that I knew enough to get it working, but not enough to know all the details exhaustively. Somebody with more experience in the unit blueprints could remove the structure-ness of it and address the problem at the source (add a movement type, maybe?).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Why not to add OnAdjacentTo OnNotAdjacentTo to the Dummy class that would return?

The error pops up in the script of the structure that is adjacent. Returning in the dummy class does nothing to prevent the adjacent structure unit script from running.

don't leave lingering logic in the base class

I agree, I'll try to find a different solution.

remove the structure-ness of it and address the problem at the source (add a movement type, maybe?).

I tried other motion types but the engine removes the assist order once the drone is attached to the SACU (and the dummy unit is finally attached indirectly to the SACU).
Fortunately, upon some investigation, it seems related to the "Attached" state of the unit, so we can do self:SetUnitState("Attached", false) in OnAttachedToTransport and then remove all the guard re-assignment behavior, since assist orders no longer get removed.

I haven't yet figured out how to deal with fatboy detaching its external factory when you give the dummy unit a motion type.

then
return
end

Expand Down Expand Up @@ -832,7 +834,9 @@ StructureUnit = ClassUnit(Unit, BlinkingLightsUnitComponent) {
OnNotAdjacentTo = function(self, adjacentUnit)

-- make sure we're both finished building
if self:IsBeingBuilt() or adjacentUnit:IsBeingBuilt() then
if self:IsBeingBuilt() or adjacentUnit:IsBeingBuilt()
or adjacentUnit.Blueprint.CategoriesHash["DUMMYUNIT"]
then
return
end

Expand Down
2 changes: 2 additions & 0 deletions units/ZXA0003/ZXA0003_script.lua
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ local DummyUnit = import('/lua/sim/unit.lua').DummyUnit
ZXA0003 = ClassUnit(DummyUnit) {

OnCreate = function (self)
DummyUnit.OnCreate(self)

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