Currently, when a miner is filled up and wants to return to a drop-off unit, it will go to the nearest one. It seems it checks for that location as soon as it is "ready".
If when the miner gets there, the drop-off unit has moved (by morphing or because it's simply another mobile unit), the miner will then return to a rock to mine, mine it for a split second before realizing it is indeed still full, do the search again, and go to the next nearest drop-off unit. If the travel between the rock and the drop-off is long enough, it's not that hard to have a miner perpetually search for the drop-off and never find it.
The most obvious remedy to me is to make the miner redo the search when it reaches the drop-off coordinates, if it still has the "cargo" of course, and then proceed to the nearest drop-off location again, instead of heading back to the rock.
Of course, the mobile-drop off unit would be slow so it's easy to catch up
I think this is the piece controlling the "return to drop-off" AI for units (line 319):
Code: Select all
function return_to_dropoff (unitID)
local x, y, z = Spring.GetUnitPosition(unitID)
local tx, ty, tz = nearest_dropoff_position_from_miner (unitID)
if (tx ~= nil) then
-- Spring.GiveOrderToUnit(unitID, CMD.FIRE_STATE , { 0 }, {})
-- Spring.GiveOrderToUnit(unitID, CMD.MOVE_STATE, { 0 }, {})
Spring.GiveOrderToUnit(unitID, CMD.MOVE , {tx, ty, tz }, {})
miners[unitID].status = "to_hq"
if (debug) then Spring.Echo ("returning to base with cargo:" .. miners[unitID].cargo) end
end
end
Code: Select all
function nearest_dropoff_position_from_miner (minerID)
local minerteam = Spring.GetUnitTeam (minerID)
local nearest_distance = 9999999999
local nearest_dropoffID = nil
for i in pairs (dropoffs) do
local dropoffteam = Spring.GetUnitTeam (i)
if (minerteam == dropoffteam) then
local d = Spring.GetUnitSeparation (minerID, i)
if (d < nearest_distance) then
nearest_distance = d
nearest_dropoffID = i
end
end
end
if (nearest_dropoffID ~= nil) then
return Spring.GetUnitPosition (nearest_dropoffID)
else
return nil
end
end
Link to the whole gadget:
tp_mining