Skip to content

Commit 13a36a3

Browse files
committed
Do not rely on AllowCommand to stop egg from moving, this is UI, not mechanics.
Removed unwanted egg commands properly. Eggs update their morph buttons when transferred. Morph buttons update _after_ a commander joins a new team, not _before_ they leave their old one. Left Egg with Move and Attack Move as these will be inherited by hatched commanders. Stopped move commands being removed from a "stuck" egg. Fixed egg collision and selection volumes. Reduced default impact location transport speed, to accommodate egg in Charon. Updated gadget information.
1 parent 99747e6 commit 13a36a3

4 files changed

Lines changed: 16 additions & 40 deletions

File tree

LuaRules/Gadgets/cmd_raw_move.lua

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ for i = 1, #UnitDefs do
106106
else
107107
turnPeriods[i] = 8
108108
end
109-
if ud.speed == 0 then -- Structures with move commands
109+
if ud.speed == 0 or ud.customParams.no_move_speed then -- Structures with move commands
110110
startMovingTime[i] = 10000000 -- Never cancel orders due to no progress
111111
elseif (ud.moveDef.maxSlope or 0) > 0.8 and ud.speed < 60 then
112112
-- Slow spiders need a lot of leeway when climing cliffs.

LuaRules/Gadgets/unit_commander_egg.lua

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,9 @@ function gadget:GetInfo()
77
return {
88
name = "Commander Egg",
99
desc = "Manages commander egg hatching limits and morph button state",
10-
author = "Orlicek, Licho",
10+
author = "Orlicek, Licho, GoogleFrog",
1111
license = "GNU GPL, v2 or later",
12+
date = "May, 2026",
1213
layer = -1,
1314
enabled = true,
1415
}
@@ -183,36 +184,17 @@ function GG.MorphCompleted(oldUnitID, newUnitID, teamID)
183184
return true
184185
end
185186

186-
--------------------------------------------------------------------------------
187-
-- Block move commands on eggs (egg has speed for blocking but should not move)
188-
--------------------------------------------------------------------------------
189-
190-
local blockedCmds = {
191-
[CMD.MOVE] = true,
192-
[CMD.FIGHT] = true,
193-
[CMD.PATROL] = true,
194-
[CMD.GUARD] = true,
195-
[SUC.RAW_MOVE] = true,
196-
}
197-
198-
function gadget:AllowCommand(unitID, unitDefID, teamID, cmdID, cmdParams, cmdOptions)
199-
if unitDefID == eggDefID and blockedCmds[cmdID] then
200-
return false
201-
end
202-
return true
203-
end
204-
205187
--------------------------------------------------------------------------------
206188
-- Event handlers for button greying
207189
--------------------------------------------------------------------------------
208190

209191
local pendingEggUpdate = false
210-
local cmdsToRemove = {CMD.MOVE, CMD.PATROL, CMD.FIGHT, CMD.GUARD, CMD.MOVE_STATE, CMD.FIRE_STATE, Spring.Utilities.CMD.RAW_MOVE}
211192

212193
function gadget:UnitCreated(unitID, unitDefID, teamID)
213194
if unitDefID == eggDefID then
214195
IterableMap.Add(eggs, unitID)
215196
pendingEggUpdate = true
197+
GG.Attributes.AddEffect(unitID, "no_move", {move = 0})
216198
end
217199
if Spring.Utilities.isComm(unitDefID) then
218200
IterableMap.Add(commanders, unitID)
@@ -225,14 +207,6 @@ end
225207

226208
function gadget:UnitFinished(unitID, unitDefID, teamID)
227209
if unitDefID == eggDefID then
228-
-- remove movement-related command buttons
229-
for _, cmdID in ipairs(cmdsToRemove) do
230-
local cmdDescID = Spring.FindUnitCmdDesc(unitID, cmdID)
231-
if cmdDescID then
232-
Spring.RemoveUnitCmdDesc(unitID, cmdDescID)
233-
end
234-
end
235-
Spring.GiveOrderToUnit(unitID, CMD.STOP, {}, 0)
236210
UpdateEggMorphButtons()
237211
end
238212
end
@@ -252,8 +226,8 @@ function gadget:UnitDestroyed(unitID, unitDefID, teamID)
252226
end
253227
end
254228

255-
function gadget:UnitTaken(unitID, unitDefID, oldTeamID, newTeamID)
256-
if Spring.Utilities.isComm(unitDefID) then
229+
function gadget:UnitGiven(unitID, unitDefID, oldTeamID, teamID)
230+
if Spring.Utilities.isComm(unitDefID) or unitDefID == eggDefID then
257231
UpdateEggMorphButtons()
258232
end
259233
end

LuaUI/Widgets/cmd_newton_firezone.lua

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,8 @@ options = {
174174
name = "Drop prediction speed threshold",
175175
desc = "Draw prediction for transports above this speed.",
176176
type = 'number',
177-
min = 0, max = 8, step = 0.2,
178-
value = 5,
177+
min = 0, max = 8, step = 0.1,
178+
value = 4,
179179
OnChange = function(self)
180180
transportPredictionSpeedSq = self.value^2
181181
end,

units/commander_egg.lua

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,24 @@ return { commander_egg = {
33
description = [[Morphs into a Commander. Disarm and slow explosion on death.]],
44
builder = false,
55
buildPic = [[commander_egg.png]],
6+
canGuard = false,
67
canMove = true,
8+
canPatrol = false,
79
cantBeTransported = false,
810
category = [[LAND UNARMED]],
911
collisionVolumeOffsets = [[0 0 0]],
10-
collisionVolumeScales = [[36 45 36]],
11-
collisionVolumeType = [[CylY]],
12+
collisionVolumeScales = [[32 48 32]],
13+
collisionVolumeType = [[ellipsoid]],
1214
selectionVolumeOffsets = [[0 0 0]],
13-
selectionVolumeScales = [[40 40 40]],
14-
selectionVolumeType = [[CylY]],
15+
selectionVolumeScales = [[44 55 44]],
16+
selectionVolumeType = [[ellipsoid]],
1517
corpse = [[DEAD]],
1618

1719
customParams = {
1820
instantselfd = [[1]],
19-
midposoffset = [[0 15 0]],
2021
modelradius = [[15]],
2122
stats_show_death_explosion = 1,
23+
no_move_speed = 1,
2224

2325
morphto_1 = [[dynstrike0]],
2426
morphtime_1 = 60,
@@ -52,7 +54,7 @@ return { commander_egg = {
5254
objectName = [[commander_egg.s3o]],
5355
script = [[commander_egg.lua]],
5456
selfDestructAs = [[COMMANDER_EGG_EMP]],
55-
sightDistance = 300,
57+
sightDistance = 300,
5658
speed = 40,
5759

5860
weaponDefs = {

0 commit comments

Comments
 (0)