jK has already done mobile mexes with a gadget years go.PicassoCT wrote:so that a unit standing automorphs into a mex, and retour?
Did not test it but looks nice and customizeable.
But is also somewhat complicated (for new bees)
So this is a really simple version via a unit script:
When the unit stops moving, a mex is created at the position of the unit.
When the unit starts moving again, the mex is destroyed.
You need 2 units:
1) the mobile unit (like a mining vehicle or whatever, i chose flash.)
2) a mex unit (pro tip: unlike me, use an invisible model, this is just for better demonstration)
Code: Select all
local mexID = -666 function script.Create() Spring.Echo ("mobile mex here!") end function script.Killed(recentDamage, maxHealth) killMex() end function script.StartMoving() killMex() end function script.StopMoving() makeMex() end function makeMex () local x,y,z=Spring.GetUnitPosition (unitID) local teamID = Spring.GetUnitTeam (unitID) mexID = Spring.CreateUnit("armmex", x, y, z, 0, teamID) --replace with your mex name if (Spring.ValidUnitID (mexID)) then Spring.SetUnitNoSelect (mexID, true) else Spring.Echo ("error! CreateUnit failed for the mobile mex") end end function killMex() if (Spring.ValidUnitID (mexID)) then Spring.DestroyUnit (mexID, false,true) --leave no wreck end end
pro tip: some mods (ba, xta) do not have a unit_script.lua so it will not work there. Just copy it in to get lua unit scripts working.