This is some quick&dirty way to get mobile factories.
The factory gets movectrl'd and thus follows the mobile unit.
The built units fly out of the factory because my factory already was like that:
So it is not that funny bug.
But I guess that is not even needed. (maybe tweak yardmap a bit)
When the factory dies, it is recreated. (could also just make it superstrong or block damage or w/e)
Put this into the script of the mobile unit:
Code: Select all
function script.Create()
newFactory ()
StartThread (moveFactory)
end
function newFactory ()
local x,y,z = Spring.GetUnitPosition (unitID)
teamID = Spring.GetUnitTeam (unitID)
factoryID = Spring.CreateUnit ("NAME_OF_FACTORY", x,y,z+100, 0, teamID)
Spring.MoveCtrl.Enable (factoryID)
end
function moveFactory ()
while (true) do
if (not Spring.ValidUnitID (factoryID)) then newFactory () end
local x,y,z = Spring.GetUnitPosition (unitID)
Spring.SetUnitPosition (factoryID, x, y, z+100)
Sleep (33)
end
end
Killing the factory along with the mobile unit like
Code: Select all
function script.Killed(recentDamage, maxHealth)
-- if (Spring.ValidUnitID (factoryID)) then
Spring.DestroyUnit (factoryID)
--end
end
So that might need a gadget or the factory has to kill itself.
Due to lazy SetUnitPosition (factoryID, x, y, z+100) the factory does not really turn with the mobile unit, use math for that.