SRL Archive - Research & Development Lounge

BankNearestBankerVWB


Bixby Sayz

2009-09-16 06:20:19

Something I've been playing around with. Only works with varrock west bank.

Finds the banker npcs on the minimap, figures out which one is the closest, translates that to onscreen and banks at that bankbooth.

Works pretty well for me, but curious to see if it falls down when "released to the wild".

{*******************************************************************************
function C_BankNearestBankerVWB(): Boolean;
By: Bixby Sayz
Description: Attempts to bank at the nearest bank booth in varrock west bank.
Returns true on success.
Note: There is enough uncertainty/randomness in the conversions that randomness
in the mouse clicking isn't really required.
*******************************************************************************}
function C_BankNearestBankerVWB(): Boolean;
var
Npc : TPointArray; // Location of npcs on minimap.
ScreenPt: TPoint; // Screen point.
Sx, Sy : Integer; // Screen (x,y) coords.
begin
Result := False;
if not LoggedIn then
Exit;

// We need proper rotation/camera angle for this to work.
SetAngle(True);
MakeCompass('n');

// Figure out nearest npc on minimap.
Npc := GetMiniMapDots('npc');
if (High(Npc) = 0) then
Exit;
SortTPAFrom(Npc, Point(MMCX, MMCY));
if (Npc[0].x = 0) then
Exit;

// Convert minimap point to main screen point. Conversion isn't 100% accurate
// so some tweaking is needed, plus we want the bank booth not the banker
// itself.
ScreenPt := MMToMS(Npc[0]);
Sx := ScreenPt.x;
Sy := ScreenPt.y;

IncEx(Sx, (MMCX - Npc[0].x));
if (Npc[0].x > MMCX) then
DecEx(Sx, 25)
else
IncEx(Sx, 70);
DecEx(Sy, 15);

// Move mouse over to where we think bank booth is and look for bank booth
// color in a box centered on that point.
MMouse(Sx, Sy, 0, 0);
if not WaitFindColor(Sx, Sy, BankBoothColor, (Sx - 20), (Sy - 20), (Sy + 20), (Sy + 20), 5, 500) then
Exit;

// Move mouse to where we now know the bank booth is and double check the
// the uptext to be sure. If we have a match, right-click and select
// "Use-quickly bank booth".
MMouse(Sx, Sy, 0, 0);
if not WaitUpText('booth', 500) then
Exit;
Mouse(Sx, Sy, 0, 0, False);
Wait(RandomRange(100, 250));
if not WaitOption('quickly', 500) then
Exit;

// We should have an open bankscreen at this point.
Result := BankScreen;
end;

Also attached a script that tests it. Requires latest srl dev and smart 4.5. Place yourself anywhere in varrock west bank and run.

Edit: Broken since the Sep 17 update. Only works accurately if standing in middle of bank now. Won't have time to fix it for a while.

noidea

2009-09-16 06:40:30

Lol, all that commenting on your code. I have to do that in my Java class :p
Nevertheless, nice job :)

Bixby Sayz

2009-09-16 15:28:49

From: noidea
Lol, all that commenting on your code. I have to do that in my Java class :p
Nevertheless, nice job :)


I used to work for someone who had trouble understanding any code unless you basically commented every single line and put a summary of each logic block above in comments and a summary of the rountine in comments at the top.

After while I got in the habit of just writing comments first then filling in a lot of the time. Plus it is handy when things go wrong and you go back 1 yr later and try to figure out what the hell you where thinking when you wrote it.

caused

2009-09-18 01:21:33

hah. I did such function as well =). Only that i'm scanning the mainscreen for the closest bank booth.

Good Job on yours. I just wonder how accurate it is, since it seems to convert the minimap to the mainscreen, does that work well ?.

~caused

Bixby Sayz

2009-09-18 03:25:35

From: caused
I just wonder how accurate it is, since it seems to convert the minimap to the mainscreen, does that work well ?.


Found the conversion function when browsing through the srl includes, which got me to wondering the exact same thing. Soo I came up with these.

It gets you sort of close. I had to tweak the results, and how much to tweak differs according to whether you closest to the east or west row of bankers. Enough that I just couldn't get consistent results aiming for the bankers themselves.

But looking for the bank booth has enough leeway that it works. Have not tried it since the latest update, so god knows if it still works. Won't be able to script/test for a few days.

Neehosoft

2009-09-19 23:52:01

Mind if i use? Im scripting a VWB FireMaker right now

Bixby Sayz

2009-09-20 04:23:20

You are welcome to use it, but may want to wait until I fix it. The new round of updates seems to have broken it.

Now seems to work fine if standing in the middle of the bank, but way off if standing close to a banker.

danishkahn

2009-09-20 10:37:09

Do you rekon you could add a vial filler loop onto this script please :D

Neehosoft

2009-09-20 11:18:23

From: Bixby Sayz
You are welcome to use it, but may want to wait until I fix it. The new round of updates seems to have broken it.

Now seems to work fine if standing in the middle of the bank, but way off if standing close to a banker.


I will fix myself thanks

Neehosoft

2009-09-20 11:19:38

From: danishkahn
Do you rekon you could add a vial filler loop onto this script please :D


I could make a vial filler i guess it takes like 5 mins or you could learn to script and make it yourself

marpis

2009-09-24 12:05:57

Wow dude, it's incredibly accurate!
Mind if I use this?

E: I took this

{MMouse(Sx, Sy, 0, 0);
if not WaitFindColor(Sx, Sy, BankBoothColor, (Sx - 20), (Sy - 20), (Sy + 20), (Sy + 20), 5, 500) then
Exit;}
Away because it caused weird problems, now it works :)

Bixby Sayz

2009-09-24 18:04:04

From: marpis
Wow dude, it's incredibly accurate!
Mind if I use this?


You are welcome to use this if it is useful. It works for you ???

I've had no luck with it since the last update, so have completely rewritten it.

Haven't released that version since it includes a rewrite of MMToMS in Banking.scar that is only about 90% complete. (The x coords are bang on, but have to collect some more sample data and correct the y calculations) Just have not have had time lately, hoping this weekend.

Anyway if it works for you, go for it, just give credit.