Warcraft III resources & community, 2003–2006 · archived

MinRangeToEnemy

not rated
Submitted by AIAndyCalculations0 downloads
Returns the distance to the nearest start location of an enemy of p counted from l.

Source

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
endfunction

Comments

0

No comments.