Code: Select all
travelUnits = {unitDefID,timeTraveling,destination,team}
function gadget:GameFrame(f)
if f + 4 % 5 < 0.01 then
for i,k in ipairs(travelUnits) do
if k.timeTraveling - f <= 0 then
Spring.CreateUnit(k.unitDefID,k.destination XYZ,0,k.team)
else
k.timeTraveling = k.timeTraveling - 4
end
end
end
Then you just need to define the destinations, and then write some equally-simple code to store Units if they enter certain places on the map, and set their destination. Obviously, this gets more complicated if you want tunnels you can "steer", but you were referring to static ones, so there you go.
To avoid logic problems, I'd also give them a "just been transported" tag that is wiped with time, or only let them actually be transported if their current Move / Fight / Patrol order takes them to a valid transport point (i.e., Units that have just been Transported will just sit there, they'll only go "down the tunnel" if they have appropriate orders).
The only tricky part of that might be getting the orders. This might work:
Code: Select all
local queue = Spring.GetCommandQueue(targetID);
if (queue ~= nil) then
if queue[1].id == CMD.MOVE or CMD.FIGHT or CMD.PATROL then
local params = queue[1].params
local x,y,z = params[1],params[2],params[3]
-- do some search logic here, based on the position of the tunnel, if x,y,z are close to the tunnel, then go ahead and remove the Unit
end
end