MinRangeToEnemy
not ratedReturns the distance to the nearest start location of an enemy of p counted from l.
function MinRangeToEnemy takes player p, location l returns real
local integer i = 0
local real d = 0
local real min_d = 1000000
loop
exitwhen i >= 12
if GetPlayerSlotState(Player(i)) == PLAYER_SLOT_STATE_PLAYING and IsPlayerEnemy(Player(i), p) then
set d = DistanceBetweenPoints(l, GetPlayerStartLocationLoc(Player(i)))
if d < min_d then
set min_d = d
endif
endif
set i = i + 1
endloop
return min_d
endfunctionNo comments.