Infantry001
2009-07-14 23:26:33
Well, the current one doesn't work. I fixed it.
{*******************************************************************************
function NearestTile(Path: TPointArray; MinDist: integer): TPoint;
By: lordsaturn
Description: Gets the closest tile in the array.
*******************************************************************************}
function NearestTile(Path: TPointArray; MinDist: integer): TPoint;
var
i, Hi, dist, mn, index: integer;
begin
mn := 99999; //Added
Hi := High(Path);
if Hi < 0 then Exit;
index := -1;
for i := 0 to Hi do
begin
dist := DistanceFrom(Path[i]);
if (dist < mn) and (dist >= MinDist) then
begin
mn := dist;
index := i;
end;
end;
if index > -1 then
Result := Path[i];
end;