GetFastestToPointOfGroup
not ratedReturns the unit of a group that can get to a certain point in the shortest time (given that they all fly or all walk).
This function destroys the passed group.
This function destroys the passed group.
function GetFastestToPointOfGroup takes group g, location l returns unit
local real d = 0
local unit u = null
local unit nu = null
local real sd = 1000000
local real ms = 0
loop
set u = FirstOfGroup(g)
exitwhen u == null
set ms = GetUnitMoveSpeed(u)
if ms == 0 then
set ms = 0.01
endif
set d = DistanceBetweenPoints(GetUnitLoc(u), l) / ms
if d < sd then
set sd = d
set nu = u
endif
call GroupRemoveUnit(g, u )
endloop
call DestroyGroup(g)
return nu
endfunctionNo comments.