SCAR Code:
type tehpointfur = record
x,y,dist :integer;
active : boolean;
end;
type ybox = record
x1,y1,x2,y2,cx,cy:integer;
active:boolean;
end;
var gx,gy:integer;
procedure findreds (var fx, fy:integer; PointsToFind,width,basex,basey,endx,endy:integer);
var
box :array of ybox;
ypoint : array of tehpointfur;
x,d,e,f,i,g,rx,ry,tehcolor,lowest,lowestp,nob,{gx,gy,}currentpoint,row,prow,col,nor,noc:integer;//var
//x,d,nob,gx,gy,currentpoint,row,prow,col,nor,noc:integer;
begin
//---------------
// replace this section of code with setting rx and ry to the center of the minimap
{ repeat
if not(Loggedin) then break;
if(TimeFromMark(Mark)>600000) then begin Logout; Exit; end;
Until(FindSymbol(rx,ry,'furnace'));}
//---------------------------------------------
noc:=(( (endx-basex) - (width mod (endx-basex)))/width)+1;
nor:=(( (endy-basey) - (width mod (endy-basey)))/width)+1;
//noc:=round( (endx-basex)/width );
//nor:=round( (endy-basey)/width );
nob:=nor*noc;
setarraylength(box, ((nob)+2));
repeat
x:=x+1;
if ((x+noc) mod noc)>0 then
col:=((x+noc) mod noc);
if ((x+noc) mod noc) =0then
col:=noc;
prow:=0;
repeat
prow:=prow+1;
until ( x<=(noc*prow));
row:=prow;
box[x].x1:=(basex+ ((col-1)*width) );
box[x].x2:=(basex+(col*width));
box[x].y1:=(basey+ ((row-1)*width) );
box[x].y2:=(basey+(row*width));
box[x].cx:=round((box[x].x2+box[x].x1)/2);
box[x].cy:=round((box[x].y2+box[x].y1)/2);
box[x].active:=true;
{
movemouse(box[x].x1,box[x].y1);
holdmouse(box[x].x1,box[x].y1,true);
movemouse(box[x].x2,box[x].y2);
releasemouse(box[x].x2,box[x].y2,true);
}
until x>=nob;
currentpoint:=1;
d:=0;
setarraylength(ypoint, pointstofind+1);
repeat
d:=d+1;
if (box[d].active) then
begin
tehcolor:=210;
repeat
tehcolor:=tehcolor+1;
//if findcolor(gx,gy,tehcolor,box[d].x1,box[d].y1,box[d].x2,box[d].y2) then
until (findcolor(gx,gy,tehcolor,box[d].x1,box[d].y1,box[d].x2,box[d].y2) or (tehcolor>=260));
if (findcolor(gx,gy,tehcolor,box[d].x1,box[d].y1,box[d].x2,box[d].y2))then
begin
ypoint[currentpoint].x :=gx;
ypoint[currentpoint].y :=gy;
ypoint[currentpoint].dist:=Round(Sqrt(Sqr(ypoint[currentpoint].x - rx) + Sqr(ypoint[currentpoint].y- ry)))
currentpoint:=currentpoint+1;
box[d].active:=false;
end;
end;
until (( currentpoint= pointstofind)or (d=nob));
e:=0;
repeat
e:=e+1;
if (not(ypoint[e].x=0) and not(ypoint[e].y=0)) then
ypoint[e].active:=true;
//if ypoint[e].dist<5 then
//ypoint[e].active:=false;
until e=pointstofind;
e:=0;
lowest:=1000;
repeat
e:=e+1;
if ypoint[e].active then
begin
if ypoint[e].dist<lowest then
lowestp:=e;
lowest:=min(lowest, ypoint[e].dist);
end;
until e=pointstofind;
gx:=ypoint[lowestp].x;
gy:=ypoint[lowestp].y;
end;