SRL Archive - Test corner

working on bankfinder


Bramble

2007-03-01 01:57:50

program new;
{.include srl/srl.scar}

const
banker=195836;

Function FindDaBankers(var x,y:integer;Direction:String):boolean;
var n,imin,imax,i,xx,yy,bx1,by1,bx2,by2,cbanker,tol:integer;
Colors:Array[0..1890] of integer;Coords:array[0..1890] of Tpoint;
count:array[0..182] of integer;results:array[0..59] of integer;
Coordsc:array[0..182] of Tpoint;
begin
wait(250+random(+100));
MakeCompass(Direction);
if FindSymbol(x,y,'bank') = false then
repeat
SymbolAccuracy:=SymbolAccuracy-10;
until (FindSymbol(x,y,'bank')=true) or (SymbolAccuracy=0);
if (x<=0) and (y<=0) then
begin
Result:=False;
exit;
end;
bx1:=x-30; by1:=y-15; bx2:=x+30; by2:=y+15;
Tol:=10;
X:=0;
Y:=0;
if cbanker = 0 then
begin
if FindColorTolerance(x,y,Banker,bx1,by1,bx2,by2,10) = false then
repeat
Tol:=Tol+5;
until (FindColorTolerance(x,y,Banker,bx1,by1,bx2,by2,tol)=true) or (tol=50);
if (x<=0) and (y<=0) then
begin
Result:=False;
exit;
end;
CBanker:=GetColor(x,y);
end;
for YY := by1 to by2 do
for xx:= bx1 to bx2 do
begin
colors[i]:=GetColor(xx,yy);
Coords[i].x:=xx;
Coords[i].y:=yy;
I:=i+1
end;
I:= 0;
yy:=0;
xx:=0;
imax:=60
repeat
for xx := imin to imax do
begin
if cbanker = colors[i] then
n:=n+1;
i:=i+1;
end;
count[yy]:=n;
yy:=YY+1;
n:=0;
imin:=imin+61;
imax:=imax+61;
until (imax>1890);
I:=0;
for i := 0 to 28 do
results[i]:=count[i]+count[i+1]+count[i+2];
I:=0;
n:=0;
for i :=0 to 27 do
if Results[n] > Results[i+1] then
n:=i
else n:=i+1;
imin:=(n*61)-1;
imax:=imin+182;


xx:=0;
yy:=0;
for xx := imin to imax do
begin
Coordsc[yy].x := coords[xx].x;
Coordsc[yy].y := coords[xx].y;
yy:=yy+1;
end;
xx:=0;
yy:=0;
i:=0;
bx1:=coordsc[0].x;
bx2:=coordsc[182].x;
by1:=coordsc[0].y;
by2:=coordsc[182].y;
for xx := bx1 to bx2 do
for yy:= by1 to by2 do
begin
colors[i]:=getcolor(xx,yy);
coords[i].x:=xx;
coords[i].y:=yy;
I:=i+1;
end;

imin:=0;
imax:=2;
yy:=0;
xx:=0;
repeat
for xx := imin to imax do
begin
if cbanker = colors[xx] then
n:=n+1;
i:=i+1;
end;
count[yy]:=n;
yy:=YY+1;
n:=0;
imin:=imin+3;
imax:=imax+3;
until (imax>180);
I:=0;
for i := 0 to 57 do
results[i]:=count[i]+count[i+1]+count[i+2];
I:=0;
n:=0;
for i := 0 to 56 do
if Results[n] > Results[i+1] then
n:=i
else n:=i+1;
imin:=(n*3)-1;
imax:=imin+8;
xx:=coords[imin].x + round((coords[imax].x-coords[imin].x)/2);
yy:=coords[imin].y + round((coords[imax].y-coords[imin].x)/y);
x:=xx;
y:=yy;
result:=true;
exit;
end;

begin
setupsrl;
wait(500);
activateclient;
wait(500);
if FindDaBankers(x,y,'s') then
mmouse(x,y,0,0);

newline:=newline;
end.

need testers, wont work in lumby bank, it looks for banker dots pretty much

Lorax

2007-03-01 08:20:40

Could you explain what it does?

JuKKa

2007-03-01 13:04:06

User specified a new RS window
Successfully compiled
SRL Compiled in 203msec.
[Runtime Error] : Out Of Range in line 84 in script

thats what i get.. odd… dont have time to fix it .. (tested in draynor)

Bramble

2007-03-01 13:21:25

well what it does is, it finds the bank symbol, adds 30 to each side of x, and 15 to each side of y, to get an area, then i chop that area up, and search it along the y axis, and store to an array, then i compare 3 x' axis at a time, to find out which one has the most of the banker color, then i divide it by 6 and get sections out of the 3 lines, and whichever 7*3 area has the most yellow, it returns x and y of it, that out of range error is one of my arrays is small

and Direction in the parameters is to point the compass, so that the banker dots are north of the bank booth, at this point u could reverse that, but later i will make it so it clicks right beside the bank booth

Killerdou

2007-03-01 13:25:43

maybe use a dtm for it? i suppose it works just aswell:) and what happens when it cant find the banksymbol(if its covered with white dots)

JuKKa

2007-03-01 13:35:43

From: bramble
well what it does is, it finds the bank symbol, adds 30 to each side of x, and 15 to each side of y, to get an area, then i chop that area up, and search it along the y axis, and store to an array, then i compare 3 x' axis at a time, to find out which one has the most of the banker color, then i divide it by 6 and get sections out of the 3 lines, and whichever 7*3 area has the most yellow, it returns x and y of it, that out of range error is one of my arrays is small

and Direction in the parameters is to point the compass, so that the banker dots are north of the bank booth, at this point u could reverse that, but later i will make it so it clicks right beside the bank booth


sounds so… mathematical? i kinda.. didnt understand a word :D hopefully nothing i need.. that..badly.. :rolleyes:

tarajunky

2007-03-01 13:37:58

I use a DTM to find the bankers in varrock east bank and it works VERY well.

Here the bankers dots' look something like this

….X..X……X…..

so I just make a DTM of a horizontal line with a yellow point on each of those spots, and added a LOT of color tolerance, and a little area tolerance.

I DON'T use this for bankfinding. I find the bank first and move near/into it. Then I look for this DTM to get my char right next to the bank booth. Then I use a variant of Fakawi's SimpleBank procedure where is just moves the mouse in an arc toward where the bank booth should be until it finds the right uptext.

Making a 'universal' bankfinder is fine for helping out noobs, but how many scripts use 3 or 4 different banks? I think it's best to just write your own custom code for the bank you need.

Bramble

2007-03-01 14:04:35

well, u dont have to do any math as its all done for you allready lol, just check out my script make sure it looks right, cause as of right now i run it and scar errors and closes

and when this gets working properly, it shouldnt take anytime at all really to find the bank, and click there

program new;
{.include srl/srl.scar}

const
banker=195836;

Function FindDaBankers(var x,y:integer;Direction:String):boolean;
var n,imin,imax,i,xx,yy,bx1,by1,bx2,by2,cbanker,tol:integer;
Colors:Array[0..1890] of integer;Coords:array[0..1890] of Tpoint;
count:array[0..182] of integer;results:array[0..59] of integer;
Coordsc:array[0..182] of Tpoint;
begin
wait(250+random(+100));
MakeCompass(Direction);
if FindSymbol(x,y,'bank') = false then
repeat
SymbolAccuracy:=SymbolAccuracy-10;
until (FindSymbol(x,y,'bank')=true) or (SymbolAccuracy=0);
if (x<=0) and (y<=0) then
begin
Result:=False;
exit;
end;
bx1:=x-30; by1:=y-15; bx2:=x+30; by2:=y+15;
Tol:=10;
X:=0;
Y:=0;
if cbanker = 0 then
begin
if FindColorTolerance(x,y,Banker,bx1,by1,bx2,by2,10) = false then
repeat
Tol:=Tol+5;
until (FindColorTolerance(x,y,Banker,bx1,by1,bx2,by2,tol)=true) or (tol=50);
if (x<=0) and (y<=0) then
begin
Result:=False;
exit;
end;
CBanker:=GetColor(x,y);
end;
for YY := by1 to by2 do
for xx:= bx1 to bx2 do
begin
colors[i]:=GetColor(xx,yy);
Coords[i].x:=xx;
Coords[i].y:=yy;
I:=i+1
end;
I:= 0;
yy:=0;
xx:=0;
imax:=60
repeat
for xx := imin to imax do
begin
if cbanker = colors[i] then
n:=n+1;
i:=i+1;
end;
count[yy]:=n;
yy:=YY+1;
n:=0;
imin:=imin+61;
imax:=imax+61;
until (imax>1890);
I:=0;
for i := 0 to 28 do
results[i]:=count[i]+count[i+1]+count[i+2];
I:=0;
n:=0;
for i :=0 to 27 do
if Results[n] > Results[i+1] then
n:=i
else n:=i+1;
imin:=(n*61)-1;
imax:=imin+182;


xx:=0;
yy:=0;
for xx := imin to imax do
begin
Coordsc[yy].x := coords[xx].x;
Coordsc[yy].y := coords[xx].y;
yy:=yy+1;
end;
xx:=0;
yy:=0;
i:=0;
bx1:=coordsc[0].x;
bx2:=coordsc[182].x;
by1:=coordsc[0].y;
by2:=coordsc[182].y;
for xx := bx1 to bx2 do
for yy:= by1 to by2 do
begin
colors[i]:=getcolor(xx,yy);
coords[i].x:=xx;
coords[i].y:=yy;
I:=i+1;
end;

imin:=0;
imax:=2;
yy:=0;
xx:=0;
repeat
for xx := imin to imax do
begin
if cbanker = colors[xx] then
n:=n+1;
i:=i+1;
end;
count[yy]:=n;
yy:=YY+1;
n:=0;
imin:=imin+3;
imax:=imax+3;
until (imax>180);
I:=0;
for i := 0 to 57 do
results[i]:=count[i]+count[i+1]+count[i+2];
I:=0;
n:=0;
for i := 0 to 56 do
if Results[n] > Results[i+1] then
n:=i
else n:=i+1;
imin:=(n*3)-1;
imax:=imin+8;
xx:=coords[imin].x + round((coords[imax].x-coords[imin].x)/2);
yy:=coords[imin].y + round((coords[imax].y-coords[imin].x)/y);
x:=xx;
y:=yy;
result:=true;
exit;
end;

begin
setupsrl;
wait(500);
activateclient;
wait(500);
if FindDaBankers(x,y,'s') then
mmouse(x,y,0,0);

newline:=newline;
end.

Boreas

2007-03-01 18:14:54

Port phasmatys -great draynor-ok
type ybox = record
x1,y1,x2,y2,cx,cy:integer;
active:boolean;
end;


type tehpoint = record
x,y :integer;
active : boolean;
end;

type combo = record
point1,point2,x1,y1,x2,y2,dist:integer;
active:boolean;
end;



var hx,hy,gx,gy,bankfindtries:integer;
findyellowdone,foundbooth:boolean;



procedure findyellows (var fx, fy:integer; PointsToFind,width,basex,basey,endx,endy:integer);
var
box :array of ybox;
ypoint : array of tehpoint;
com:array [1..300] of combo;
x,d,e,f,i,g,nob,fyx,fyy,currentpoint,row,prow,col,nor,noc:integer;

begin
noc:=(( (endx-basex) - (width mod (endx-basex)))/width)+1;
nor:=(( (endy-basey) - (width mod (endy-basey)))/width)+1;

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;

{
//draws the boxes on paint
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
if findcolor(fyx,fyy,195836,box[d].x1,box[d].y1,box[d].x2,box[d].y2) then
begin
ypoint[currentpoint].x :=fyx;
ypoint[currentpoint].y :=fyy;
currentpoint:=currentpoint+1;
box[d].active:=false;
end;
end;
until (( currentpoint= pointstofind)or (d=nob));
{
e:=0;
repeat
e:=e+1;
writeln(inttostr(ypoint[e].x)+' '+inttostr(ypoint[e].y));
if not((ypoint[e].x = 0) and (ypoint[e].y = 0)) then ypoint[e].active:=true;
until e=16;

writeln(' all points');}

e:=0;
repeat
f:=f+1;
g:=0;
repeat
g:=g+1;
e:=e+1;
//writeln(inttostr(f)+' '+inttostr(g)+' '+inttostr(e));
com[e].point1:=f;
com[e].point2:=g;
com[e].x1:=ypoint[f].x;
com[e].y1:=ypoint[f].y;
com[e].x2:=ypoint[g].x;
com[e].y2:=ypoint[g].y;
if not((com[e].x1=0) or (com[e].y1=0) or (com[e].x2=0) or (com[e].y2=0)) then com[e].active:=true;
until( (g=16) or (e=256));
until ((f=16) or (e=256));

/////////--------------------analysis------------------------------
{ port phasmatys/draynor banker configuration

port phasmatys:
x-random people outside bank

x...x......x...x - bankers
pair 1 pair 2

first eliminates dots more than 20 away (random people outside)
then finds 2 dots close (6) together, (pair 1 or 2)
then finds a dot more than 7 away (a banker in the other pair)

the last step is so that 2 people outside walking close together
won't be mistaken for a pair of bankers

draynor is the same except that the one pair is a single and
its vertical, but that doesn't matter
}

e:=0;
repeat
e:=e+1;
com[e].dist:=Round(Sqrt(Sqr(com[e].x1 - com[e].x2) + Sqr(com[e].y1 - com[e].y2)))
if ((com[e].dist=0) or (com[e].dist>20)) then com[e].active:=false;
i:=0;
repeat
i:=i+1;
if ((com[e].active) and (com[i].active))then
begin
if ((com[e].point1=com[i].point2)and (com[e].point2=com[i].point1)) then com[i].active:=false;
end;
until i=256;
if com[e].dist=1 then com[e].active:=false;
//if com[e].active then writeln(inttostr(com[e].point1)+' '+inttostr(com[e].point2)+' '+inttostr(com[e].dist));
until e=256;
e:=0;
repeat
e:=e+1;
if com[e].active then
begin
if (com[e].dist <5 ) then
begin
i:=0;
repeat
i:=i+1;
if ((com[i].point1=com[e].point1) or (com[i].point1=com[e].point2) or (com[i].point2=com[e].point1) or (com[i].point2=com[e].point2))then
begin
if com[i].dist>6 then
begin
if (((com[e].x1=com[i].x1) and (com[e].y1=com[i].y1)) or ((com[e].x1=com[i].x2) and (com[e].y1=com[i].y2))) then
begin
fx:=com[e].x1;
fy:=com[e].y1;
findyellowdone:=true;
end;
if (((com[e].x2=com[i].x1) and (com[e].y2=com[i].y1)) or ((com[e].x2=com[i].x2) and (com[e].y2=com[i].y2))) then
begin
fx:=com[e].x2;
fy:=com[e].y2;
findyellowdone:=true;
end;
end;
end;
until i=256;
end;
end;
until e=256;
/////////--------------------analysis end--------------------------
end;