To come back to this, this is the code in question:
Callbacks.CapMex = function(data, units)
local units = EntityCategoryFilterDown(categories.ENGINEER, SecureUnits(units))
if not units[1] then return end
local mex = GetEntityById(data.target)
if not mex or not EntityCategoryContains(categories.MASSEXTRACTION * categories.STRUCTURE, mex) then return end
if mex.Layer == 'Seabed' then return end
local pos = mex:GetPosition()
local msid
local builder
for _, unit in units do
msid = LetterArray[unit:GetBlueprint().General.FactionName]..'b1106' -- The identity of the storage we'll build
if unit:CanBuild(msid) then
builder = unit
break
end
end
if not builder then return end
local locations = {
up = Vector(pos.x, pos.y, pos.z - 2),
down = Vector(pos.x, pos.y, pos.z + 2),
left = Vector(pos.x - 2, pos.y, pos.z),
right = Vector(pos.x + 2, pos.y, pos.z),
}
for key, location in locations do
if CanBuildInSpot(mex, msid, location) then
IssueBuildMobile({builder}, location, msid, {})
end
end
IssueGuard(units, builder)
end
The reason one is assisted is because there could be a unit that can not build the storage (e.g., the commander) - but I agree that typically it would be better to just issue the build order for all the units in question, and only let those that can't build it assist one that can. Or perhaps exclude that one all together - we'll have to discuss that.