SRL Archive - SRL Archives

FindBankTPA


Sir R. M8gic1an

2008-06-06 18:48:05

well, the latest fashion is to turn all DTMs into TPAs so here it is ;)


//by Rasta Magician
//Note: missing -> lb, vwb, ge from f2p
//didn't include OpenBankFast, but who cares for now >.>
procedure FindBankTPA(name:string);
var
TPA:TPointArray;
ATPA: T2DPointArray;
TP: TPoint;
TempCTS, i, rx, ry, ExtraAngle:integer;
begin
TempCTS := GetColorToleranceSpeed;
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.00, 0.13);
try
if not (FindColorsTolerance(TPA, 125931, MMX1, MMY1, MMX2, MMY2, 7)) then
begin
Writeln('Failed to find the color, no result.');
Exit;
end;

ATPA:=TPAToATPA(TPA, 3);

if Length(ATPA) < 4 then
begin
writeln('could not find bankers');
exit;
end;

Setlength(TPA, Length(ATPA))
for i:=0 to High(ATPA) do
TPA[i] := MiddleTPA(ATPA[i]);

ATPA := SplitTPA(TPA, 8);

for i:=0 to High(ATPA) do
if Length(ATPA[i]) >=3 then
begin
writeln('found our bankers');
TP := MiddleTPA(ATPA[i]);

case lowercase(name) of
'eb' : begin rx := -11; ry := -3; ExtraAngle := 0; end;
'veb': begin rx := 3; ry := 11; ExtraAngle := -90; end;
'fwb': begin rx := 10; ry := 8; ExtraAngle := -90; end;
'feb': begin rx := 3; ry := 8; ExtraAngle := -90; end;
'akb': begin rx := 7; ry := 5; ExtraAngle := 0; end;
'db' : begin rx := 9; ry := 10; ExtraAngle := 0; end;
end;

IncEx(TP.x, Round(rx * Cos(rs_GetCompassAngleRadians + ExtraAngle)));
IncEx(TP.y, Round(ry * Sin(rs_GetCompassAngleRadians + ExtraAngle)));
Mouse(TP.x, TP.y, 0, 0, true);
break;

end;
finally
ColorToleranceSpeed(tempCTS);
SetColorSpeed2Modifiers(0.2, 0.2);
end;
end;

i can't do lumbridge bank cus there's only one banker
didn't do vwb yet cus there's two lines of bankers which means more work
didn't do ge cus didn't have time.

i'll probably do ge tomorrow, i'll see about vwb,

enjoy :D

~RM

Bobarkinator

2008-06-06 19:14:55

I'm thinking very soon that Wizzup and N3ss3s will slip in a rev that is all TPA's :p

MylesMadness

2008-06-06 19:19:06

I wouldn't be surprised if the entire srl is tpa…

markuska815

2008-06-06 19:42:33

Yea haha me neither… now that i have a good understanding of them im surprised they havent already… They're very useful.

Edit : Im going to use this as a base for a findBankers in My SVC w/ proper credit of course. :)

bullzeye95

2008-06-06 22:15:21

Pretty nice. 3 is probably too little in TPAtoATPA (Try SplitTPA with 1 to 3 [3 max]).

markuska815

2008-06-06 22:20:45

No I think hes right on with 3 cause the yellow of the banker dots has a max length of 3. Its been working perfect for me anyways and counts the right number of dots every time.

bullzeye95

2008-06-06 22:24:14

Oh, banker dots! I read the thread too fast, and thought it opened a bank. I take that back. W00t for 3.

Sir R. M8gic1an

2008-06-07 02:19:55

i'm glad you guys like it :)

markus, you'll most likely had to do the radius part yourself for seers bank, but one of the reasons i did this function is cus i find it's a very easy way to add all banks. i would've added p2p, but i don't have any account with membership :p

how about you post here when you get the stuff for seers bank and i'll add it in with credits? :)

~RM

markuska815

2008-06-07 02:32:45

Ok well Ill post my function here:

function MyFindBankers: boolean;
var
TPA:TPointArray;
ATPA: T2DPointArray;
TP: TPoint;
i, HighIndex :integer;
begin
FindColorsTolerance(TPA, 125931, MMX1, MMY1, MMX2, MMY2, 7);
ATPA := TPAtoATPA(TPA,3);
if (Length(ATPA) < 7) then
begin
WriteLn('Could not find bankers');
Result:=false;
Exit;
end;
Setlength(TPA, Length(ATPA))
HighIndex := High(ATPA);
for i := 0 to High(ATPA) do
TPA[i] := MiddleTPA(ATPA[i]);
ATPA := SplitTPA(TPA, 10);
HighIndex := High(ATPA);
for i:=0 to HighIndex do
if (Length(ATPA[i]) >= 5) then
begin
TP := MiddleTPA(ATPA[i]);
break;
end;
WriteLn('Found middle of bankers at ' + InttoStr(TP.x) + ', ' + InttoStr(TP.y));
BankPoint := TP;
Result := true;
end;

However it doesn't click on the bank but here is the mouse range i use when i do click on the bank:

Mouse(BankPoint.x, BankPoint.y + randomRange(9, 13), 5, 0, true);

So as you can see I modified it specifically for the Seers bank and changed it up a bit but im sure you can figure out how to add it to yours in conjunction. And I realize adding the HighIndex thing to save time is stupid i just havent changed it back. :duh: The small checks i did change prolly work just fine with yours. I just changed them for fun i guess haha

Edit : If you want me to make it like yours i for sure can. I just thought you might want to since its your function. Just let me know. I just did it for my own script so thats why its just personalized.

Sir R. M8gic1an

2008-06-07 03:03:37

no you don't have to make it like mine, in the credits just do something like

//Based of Rasta Magicians FindBankTPA

i'll see if i can add it, but i don't think so. does your function work well with different compass angles?

~RM

EvilChicken!

2008-06-07 03:23:25

Is this for finding banker dots?

This is what I use:

if FindColor(X, Y, 195836, MMX1, MMY1, MMX2, MMY2) then
MouseFlag(X, Y, 4, 4);

It works for Lumbridge atleast.


Sooo, yeah. Banker dots colors are constant. (Yes, teste for hours.)

markuska815

2008-06-07 03:29:20

Yea it works for different compass angles, it does the same thing as yours, the change in numbers is just cause there's so many bankers at SV. It prolly works with your numbers i just didnt test them with em. And Ill change it to your way tomorrow. I don't have time tonight.

And of course i credited i just didnt include the function comments:
////////////////////////////////////////////////////////////////////////////////
//---> MyFindBankers - Finds bankers and returns the middle of them at x and y
// Credit to RastaMagician for the his FindBankTPA fucntion which was the
// base of this function
////////////////////////////////////////////////////////////////////////////////
:)

ZephyrsFury

2008-06-07 03:31:00

From: EvilChicken!
Is this for finding banker dots?

This is what I use:

if FindColor(X, Y, 195836, MMX1, MMY1, MMX2, MMY2) then
MouseFlag(X, Y, 4, 4);

It works for Lumbridge atleast.


Sooo, yeah. Banker dots colors are constant. (Yes, teste for hours.)


Banker dots are the same as any other NPC dot. It works in Lummy cos I don't think you can get any other NPCs on the top level of Lummy Castle.

PvH

2008-06-07 03:42:31

From: ZephyrsFury
Banker dots are the same as any other NPC dot. It works in Lummy cos I don't think you can get any other NPCs on the top level of Lummy Castle.


What about random events than:rolleyes:?

ZephyrsFury

2008-06-07 03:45:44

From: pvh
What about random events than:rolleyes:?


Yes randoms occasionally but not very often from my experience.

Anyway nice function RM. After you've finished updating etc. and after some more tests I'm sure we could add it to SRL. :)

EvilChicken!

2008-06-07 06:50:42

From: ZephyrsFury
Banker dots are the same as any other NPC dot. It works in Lummy cos I don't think you can get any other NPCs on the top level of Lummy Castle.


It is possible, and even may screw up the script for all I know.
Like, Old Man or Niles or something like that quest goblin that follows you..
Anyway, that's why we do MMCX, MMCY instead of X, Y, and have failsafes like "if not OpenBank then go to banksymbol and try again..

JuKKa

2008-06-07 18:40:19

Just enter the amount of bankers (yellow dots) you want to find and it returns the position (middle point) works really well..

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

edit: added minimum tolerance is 3 maximum probably something like 15, simply enter how many yellow dots there should be in one place, and returns the point.

markuska815

2008-06-07 21:00:58

But Jukka if you have other yellow dots (a random event or just other random NPCs wouldn't that function add those into determining the middle point. Thats why RM added the ATPA := SplitTPA(TPA, 8); so thats the banker group would all be in one TPA and would ignore the other dots. In the one I made for SV there is usually another npcs, the real estate agent or someone else, so i don't want that to be included in determining the middle point of the array. So i believe RM has it right.

Edit: Oh wow i read your post way too fast and didnt realize the tolerance and amount of dots paramaters account for this. So they acheive the same thing.

Sir R. M8gic1an

2008-06-08 07:01:31

actually jukka, there is just one more thing my function does. you know when sometimes you click on the banker and the flag goes outside the bank? that's what the whole second part is about, it finds the bankers and clicks inside of the bank, using the compass angle, for every bank.

anyway, i posted the finished thing on SRL Development, to make sure Zeph would notice the finished version, and you guys can have a look at the extra lil bit there if you want ;)

I'm gonna ask a mod to close this.

~RM

nielsie95

2008-06-08 09:49:12

Closed on request.