i think in any case you need to check against all the enemies.
something like this:
Code:indexOfClosest:=-1; closest:=Infinity; for i:=0 to length(enemies)-1 do begin d:=distance(player,enemies[i]); if (d<closest) and (d<=inRange) then begin indexOfClosest:=i; closest:=d; end; end;
Bookmarks