SAIL - Nejbližší jednotka k oblasti

Vše ohledně SAILu a tvorby modifikací do OW.
Post Reply
User avatar
Morphid
Site Administrator
Site Administrator
Czech Republic
Posts: 86
Joined: Sat Dec 25, 2010 12:48 am
Location: Czech Republic
Contact:

SAIL - Nejbližší jednotka k oblasti

Post by Morphid »

Následující funkce vrací jednotku ze seznamu (pole) jednotek, která je nejblíže k zadané oblasti.

Použití: NearestUnitToArea(list:plist, area:integer)
Autor: Radzio

Code: Select all

export function NearestUnitToArea(list, area);
var un, n;
begin
       n:= 999999;
       for un in list do
       begin
              if GetDistUnitArea(un, area) < n then
              begin
                     n:= GetDistUnitArea(un, area);
                     result:= un;
              end;
              if (n = 0) then exit;
       end;
end;
Post Reply