SRL Archive - SRL Archives

findBankerTPA


munk

2008-06-09 13:30:20

Ok, so I was talkin to Rasta Magician and he asked me about his findBankTPA, and it gave me an idea, and I got waayyyy to into it, and so I ended up with this function.

It will find most f2p bank's bankers on the minimap and click them. It can work at any compass angle, and will always put the player right near the bank booths. It works 99% and the only problem I've had is at Draynor, it will ocassionally find the pig pen.


findBankerTPA took 0ms

:rolleyes:



{*******************************************************************************
function findBankerTPA(name:string): boolean;
By: munk, inspired by Rasta Magician
Description: Finds and clicks specified bank on the minimap.
(Name is subject to change :) )
*******************************************************************************}
function findBankerTPA(name:string):boolean;
var
i,i2,i3,i4,t,cA,Ang,Dist,
mx,my,rx,ry,xm,ym:integer;
maxDists:TintegerArray;
TPA,bankTPA:TpointArray;
found:boolean;
begin
if not(loggedIn) then exit;
marktime(t);
try
case lowercase(name) of
'eb' :
begin
bankTPA:=[point(4,4),point(0,-8),point(0,-15)];
maxDists:=[7,7,7];
xm:=-5;
ym:=0;
end;
'veb':
begin
bankTPA:=[point(4,0),point(8,0),point(12,0)];
maxDists:=[5,5,5];
xm:=4;
ym:=9;
end;
'vwb':
begin
bankTPA:=[point(0,-9),point(45,4),point(45,-4)];
maxDists:=[4,12,12];
xm:=4;
ym:=0;
end;
'feb','fwb':
begin
bankTPA:=[point(4,0),point(8,0),point(12,0)];
maxDists:=[8,8,8];
xm:=3;
ym:=9;
end;
'akb':
begin
bankTPA:=[point(0,4),point(0,-4),point(0,-12)];
maxDists:=[5,5,9];
xm:=5;
ym:=0;
end;
'db' :
begin
bankTPA:=[point(0,8),point(0,-5),point(-9,-5)];
maxDists:=[6,5,8];
xm:=8;
ym:=-1;
end;
'ge' :
begin
bankTPA:=[point(4,0),point(-5,4),point(4,13),point(8,4)];
maxDists:=[4,9,10,7];
xm:=0;
ym:=-2;
end;
else
begin
writeln('ERROR: Invalid Bank!');
exit;
end;
end;
cA:=round(rs_GetCompassAngleDegrees);
FindColorsTolerance(TPA,60909,mmx1,mmy1,mmx2,mmy2,0);
for i:=0 to high(bankTPA) do
begin
Ang:=round(degrees(arcTan2(bankTPA[i].x,bankTPA[i].y)))+cA;
Dist:=distance(0,0,bankTPA[i].x,bankTPA[i].y);
bankTPA[i].x:=round(Dist*sine(Ang));
bankTPA[i].y:=round(-Dist*cose(Ang));
end;
Ang:=round(degrees(arcTan2(xm,ym)))+cA;
Dist:=distance(0,0,xm,ym);
xm:=round(Dist*sine(Ang));
ym:=round(-Dist*cose(Ang));
for i:=0 to high(TPA) do
for i2:=0 to high(bankTPA) do
begin
found:=false;
for i3:=0 to high(TPA) do
if not((TPA[i].x=TPA[i3].x)and(TPA[i].y=TPA[i3].y)) then
if iabs(TPA[i3].x-(TPA[i].x+bankTPA[i2].x))<maxDists[i2] then
if iabs(TPA[i3].y-(TPA[i].y+bankTPA[i2].y))<maxDists[i2] then
found:=true;
if not(found) then break;
if i2 = high(bankTPA) then
begin
writeln('findBankerTPA took '+inttostr(timefrommark(t))+'ms');
rx:=TPA[i].x+xm;
ry:=TPA[i].y+ym;
if distance(rx,ry,mmcx,mmcy)>4 then
begin
for i4:=0 to 3 do
begin
mouse(rx,ry,3,3,true);
wait(700+random(300));
if findColor(mx,my,255,rx-20,ry-20,rx+5,ry+5) then
begin
fflag(0);
result:=true;
break;
end;
rx:=rx+(xm div 2);
ry:=ry+(ym div 2);
end;
end else result:=true;
exit;
end;
end;
except end;
end;

test it ;)

markuska815

2008-06-09 14:02:27

From: Munk
I got waayyyy to into it

I'd have to agree haha. But its brilliant. Nice work. Ill test it out if I make any F2P scripts.

JuKKa

2008-06-09 14:08:33

{.Include SRL/SRL.Scar}

Function FindYellowDots(Var X, Y: Integer; AmountOfDots, Tolerance: Integer): Boolean;
Var
I: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;
Begin
FindColorsTolerance(TPA, 195836, MMX1, MMY1, MMX2, MMY2, 0);
aTPA := SplitTPA(TPA, 3 + Tolerance);
For I:= 0 To GetArrayLength( aTPA ) - 1 Do
If( GetArrayLength(aTPA[I]) / 3 = AmountOfDots )Then
Begin
Result := True;
MiddleTPAEx(aTPA[I], X, Y);
Break;
End;
End;

Function FindBankers(Var X, Y: Integer; Name: String): Boolean;
Begin
case lowercase(name) of

'feb':
begin
Result := FindYellowDots(X, Y, 6, 2);
Y := Y - 10;
end;
//etc more banks.....
end

End;

Var
X, Y: Integer;

Begin
SetupSRL;

FindBankers(X, Y, 'feb');
End.

Way shorter!

munk

2008-06-09 16:05:32

From: JuKKa
{.Include SRL/SRL.Scar}

Function FindYellowDots(Var X, Y: Integer; AmountOfDots, Tolerance: Integer): Boolean;
Var
I: Integer;
TPA: TPointArray;
ATPA: T2DPointArray;
Begin
FindColorsTolerance(TPA, 195836, MMX1, MMY1, MMX2, MMY2, 0);
aTPA := SplitTPA(TPA, 3 + Tolerance);
For I:= 0 To GetArrayLength( aTPA ) - 1 Do
If( GetArrayLength(aTPA[I]) / 3 = AmountOfDots )Then
Begin
Result := True;
MiddleTPAEx(aTPA[I], X, Y);
Break;
End;
End;

Function FindBankers(Var X, Y: Integer; Name: String): Boolean;
Begin
case lowercase(name) of

'feb':
begin
Result := FindYellowDots(X, Y, 6, 2);
Y := Y - 10;
end;
//etc more banks.....
end

End;

Var
X, Y: Integer;

Begin
SetupSRL;

FindBankers(X, Y, 'feb');
End.

Way shorter!


shorter != better
;)

its meant for accuracy:D

EDIT: if you're bored, test and see which ones faster :)