SRL Archive - Bugs

R_OpenBankBooth


Yago

2011-04-08 21:58:46

There is a problem when Reflection tries to open the bank booth, but the menu is tabbed. Here's a screen-shot of the problem:



Problem: Current Function Does Not Support Tabbed Menus.

Here's my proposed code to solve the problem:

function R_OpenBankBooth(Bank : String) : Boolean;
var
Tiles: TPointArray;
P: TPoint;
Tries: Integer;
begin
Result := R_BankScreen or R_PinScreen;
if Result then Exit;

case LowerCase(Bank) of
'veb', 'varrock east':
Tiles := [Point(3251,3419), Point(3252,3419), Point(3253,3419),
Point(3254,3419), Point(3255,3419), Point(3256,3419)];
'vwb', 'varrock west':
Tiles := [Point(3190,3435), Point(3190,3437), Point(3190,3439),
Point(3190,3441), Point(3190,3443), Point(3181,3444),
Point(3181,3442), Point(3181,3440), Point(3181,3438),
Point(3181,3436)];
'falador west', 'fwb':
Tiles := [Point(2945,3367), Point(2946,3367), Point(2947,3367),
Point(2948,3367)];
'falador east', 'feb':
Tiles := [Point(3010,3354), Point(3011,3354), Point(3012,3354),
Point(3013,3354), Point(3014,3354), Point(3015,3354)];
'lumbridge', 'lb':
Tiles := [Point(3208,3221)];
'draynor', 'db':
Tiles := [Point(3091,3245), Point(3091,3243), Point(3091,3242)];
'al kharid', 'akb':
Tiles := [Point(3268,3168), Point(3268,3167), Point(3268,3166),
Point(3268,3169), Point(3268,3164)];
'seb', 'seers':
Tiles := [Point(2729,3494), Point(2728,3494), Point(2727,3494),
Point(2724,3494), Point(2722,3494), Point(2721,3494)];

'ctb', 'catherby':
Tiles := [Point(2807,3442), Point(2809,3442), Point(2810,3442),
Point(2811,3442)];

'eb', 'edgeville':
Tiles := [Point(3095,3489), Point(3095,3491), Point(3095,3493),
Point(3097,3495)];
'fgb', 'fishing guild':
Tiles := [Point(2584, 3423), Point(2584, 3422)];
'mc', 'moonclan':
Tiles := [Point(2098, 3920), Point(2097, 3920), Point(2098, 3920)];
'yb', 'yanille':
Tiles := [Point(2614, 3094), Point(2614, 3092), Point(2614, 3091)];
'da', 'duel arena': Tiles := [Point(3381, 3269), Point(3382, 3270)];
'anb', 'ardougne north': Tiles := [Point(2618, 3331), Point(2619, 3331), Point(2614, 3331)];
'asb', 'ardougne south': Tiles := [Point(2656, 3286), Point(2656, 3283), Point(2656, 3280)];
'pc', 'pest control':
Tiles := [Point(2667, 2652), Point(2666, 2652), Point(2665, 2652),
Point(2668, 2652)];
'cw', 'castle wars': Tiles := [Point(2445, 3083)];
else
begin
SRL_Warn('R_OpenBankBooth', 'Unsupported bank name.', -1);
Exit;
end;
end;
SortTPAFrom(Tiles, GetMyPos);
if (DistanceFrom(Tiles[0]) > 3) or not TileOnMS(Tiles[0], 10) then
begin
if not(TileOnMM(Tiles[0])) then
begin
SRL_Warn('R_OpenBankBooth', 'Could not find Bank Booth.', Warn_AllVersions);
Exit;
end;
WalkToTile(Tiles[0], 0, 0);
Wait(50);
R_Flag;
Wait(RandomRange(100, 200));
end;
if not(TileOnMS(Tiles[0], 10)) then
begin
SetAngle(True);
MakeCompass('n');
Wait(RandomRange(200, 400));
if not(TileOnMS(Tiles[0], 10)) then
begin
SRL_Warn('R_OpenBankBooth', 'Could get MS Point.', Warn_AllVersions);
Exit;
end;
end;

if (Bank = 'veb') or (Bank = 'varrock east') then
begin
if (GetMyPos = Tile(3250, 3419)) or (GetMyPos = Tile(3257, 3419)) then
begin
WalkToTile(Tile(3253, 3421), 1, 0);
end;
end;

P := TileToMS(Tiles[0], 10);
MMouse(p.x - 5, p.y - 5, 11, 11);
Wait(RandomRange(200, 300));
if WaitUpTextMulti(['ank', 'ooth'], 2000) then
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, false);
Wait(RandomRange(80, 110));
if IsMenuOpen then
if IsMenuTabbed then
begin
if ClickSubMenu(['se-quickly', 'ank', 'ooth'], 0, 1) then
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
if (Length(Players) > 0) then
if Players[CurrentPlayer].Pin <> '' then
Result := InPin(Players[CurrentPlayer].Pin);
Result := R_BankScreen or R_PinScreen;
until (Result) or (Tries > 20);
end else if R_ChooseOptionMulti(['Use-quickly']) then
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
if (Length(Players) > 0) then
if Players[CurrentPlayer].Pin <> '' then
Result := InPin(Players[CurrentPlayer].Pin);
Result := R_BankScreen or R_PinScreen;
until Result or (Tries > 20);
end else if IsUpTextMultiCustom(['ank', 'hest']) then //one-click bank chests
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, true);
Wait(RandomRange(80, 110));
P.x := 0;
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
if (Length(Players) > 0) then
if Players[CurrentPlayer].Pin <> '' then
Result := InPin(Players[CurrentPlayer].Pin);
Result := R_BankScreen or R_PinScreen;
until Result or (Tries > 40);
end;
end;

Here is what I changed:

  P := TileToMS(Tiles[0], 10);
MMouse(p.x - 5, p.y - 5, 11, 11);
Wait(RandomRange(200, 300));
if WaitUpTextMulti(['ank', 'ooth'], 2000) then
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, false);
Wait(RandomRange(80, 110));
if IsMenuOpen then
if IsMenuTabbed then
begin
if ClickSubMenu(['se-quickly', 'ank', 'ooth'], 0, 1) then
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
if (Length(Players) > 0) then
if Players[CurrentPlayer].Pin <> '' then
Result := InPin(Players[CurrentPlayer].Pin);
Result := R_BankScreen or R_PinScreen;
until (Result) or (Tries > 20);
end else if R_ChooseOptionMulti(['Use-quickly']) then
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
if (Length(Players) > 0) then
if Players[CurrentPlayer].Pin <> '' then
Result := InPin(Players[CurrentPlayer].Pin);
Result := R_BankScreen or R_PinScreen;
until Result or (Tries > 20);
end else if IsUpTextMultiCustom(['ank', 'hest']) then //one-click bank chests
begin
GetMousePos(P.x, P.y);
Mouse(P.x, P.y, 0, 0, true);
Wait(RandomRange(80, 110));
P.x := 0;
repeat
R_Flag;
Wait(RandomRange(50, 90));
Inc(Tries);
if (Length(Players) > 0) then
if Players[CurrentPlayer].Pin <> '' then
Result := InPin(Players[CurrentPlayer].Pin);
Result := R_BankScreen or R_PinScreen;
until Result or (Tries > 40);
end;
end;

I am currently using this code as I have encountered no errors… It works great!!!

Bixby Sayz

2011-04-08 22:11:39

F**k me! I have been beating my head against the wall trying to figure out why sometimes my cooker will fail to click on the range after running flawlessly for hours.

It's the same problem.

Yago

2011-04-08 22:14:05

Off-topic: Make sure them menu is back on track…

On-topic: Has anyone else encountered this problem when banking? To me it almost always 99% of the time happens when using R_OpenBankBooth at Lumby Bank since everyone piles up in front of the booth.

Bixby Sayz

2011-04-08 22:23:48

[QUOTE=Yago;797294Has anyone else encountered this problem when banking?

I have without realizing it until I read this post, as it always seems to occur when I am not watching. A char will fail to bank seemingly at random. Logging into the char shows them standing right in front of the bank booth.

Flight

2011-04-08 22:31:28

I don't use reflection for banking, infact I think SRL's is superior. "OpenBankFast" will rotate your camera to North and zoom all the way, thus making your initial right-click on the bank booth accurate, not bringing up the player/npc list as well. I would recommend that. :)

Yago

2011-04-08 22:34:01

Thanks… anyways it still is a problem that must be fixed. The code I posted above is working great … Hopefully it gets implemented cause its driving me crazy.

Bixby Sayz

2011-04-08 22:35:40

Would you mind if I incorporated this into my scripts (with credit of course)?

Sex

2011-04-08 22:41:59

It should be incorporated into SRL Reflection..

Yago

2011-04-08 23:17:28

Sure no problem. Im actually hoping this is pushed into reflection … As soon as a dev approves as Sex said

Harry

2011-04-09 00:27:02

You should just fix R_ChooseOptionMulti so it properly handles sub-menus…

Yago

2011-04-09 15:56:43

I agree with that. Ill try to think of something for that … As for now should we get this in?

Bixby Sayz

2011-04-09 21:42:50

From: Harry
You should just fix R_ChooseOptionMulti so it properly handles sub-menus…


This would be a lot easier if the Reflection devs didn't treat comments as some form of STDs: Something to be avoided at all costs.

Just kidding, but couldn't resist the dig after spending a couple weeks digging through the Reflection includes.

Harry

2011-04-10 01:49:49

From: Bixby Sayz
This would be a lot easier if the Reflection devs didn't treat comments as some form of STDs: Something to be avoided at all costs.

Just kidding, but couldn't resist the dig after spending a couple weeks digging through the Reflection includes.

Lol what? Most stuff gets added as long as it's well done, and a proper patch…

Bixby Sayz

2011-04-10 09:23:34

My ongoing beef with all the includes is that trying to wade through the includes to learn what something is doing and why is made much difficult than it needs to be due to a dearth of comments.

One of the things drilled into you when taking formal training is to comment your blasted code. No exceptions. If someone has to ask what it is doing and why you have failed to do the job properly. At the time I thought it was BS. Now, having had to rework peoples code many times over the years I realize there is no such thing as too many comments. 90% comments and 10% code? Fine by me if I can understand it.

One of my instructors once showed me a piece of Fortran code (yeah this was a few years ago) from a missile guidance system that was incredibly fast, accurate, and a complete mystery to everyone how it worked, including the author of the code who had written it years before. Everyone was scared to touch it for fear of breaking what they didn't understand.

All of which is off-topic. Didn't mean to derail this thread.

Yago

2011-04-10 15:43:34

Its ok.

What do the devs think about this?

Coh3n

2011-04-10 18:00:34

I didn't look at the code, but shouldn't something be added to ChooseOption to support the different menus? So it works when clicking any object?

Yago

2011-04-10 18:57:56

Yes it should. Ill see what I can pull up for it.

Coh3n

2011-04-10 22:13:57

From: Yago
Yes it should. Ill see what I can pull up for it.

If you figure it out, check out SRL's ChooseOption as well. May be able to kill two birds with one stone here.

Yago

2011-04-10 22:17:31

Doesn't SRL want to be independent from Reflection though? The stuff i changed to find sub-menus was all reflection :)

Edit: I really dont know how static_blahblah works annd about hooks and stuff. I tried playing around with something with no success. Is there a tut on stuff like this : static_subxblah

If i could only understand that then i could probably fix this.

Yago

2011-04-14 21:37:17

Bump. Soooo … can we implement this?

Echo_

2011-04-14 22:31:38

From: Yago
Bump. Soooo … can we implement this?


Send a pull request over Git with your changes, whether or not it will be implemented will be discussed there.

Yago

2011-04-14 22:57:57

I don't know how to use git… And the code is in the first post :)

Coh3n

2011-04-15 10:56:31

The devs are more likely to see the pull request then a thread, though.

pyroryan

2011-04-15 11:40:41

Its better to fix R_ChooseOption/Multi/etc. than make things more complicated by adding code to a function that should already be handled elsewhere. Thats my own opinion though. Doing it this way will eventually result in redundant code.

Home

2011-04-15 12:21:49

From: Harry
You should just fix R_ChooseOptionMulti so it properly handles sub-menus…


Yep. I agree or just modify ChooseOptionEx. You can look in my guild ranger for Temp Fix. :)


~Home

Troll

2011-04-15 13:36:21

All should handle sub menus i think.

Also has anyone seen the title

R_OpenBanBooth

pyroryan

2011-04-15 16:03:29

From: Troll
Also has anyone seen the title

R_OpenBanBooth


I don't see anything wrong.

Yago

2011-04-15 16:42:07

From: pyroryan
Its better to fix R_ChooseOption/Multi/etc. than make things more complicated by adding code to a function that should already be handled elsewhere. Thats my own opinion though. Doing it this way will eventually result in redundant code.


Can someone do this cause I have no idea how to do this. Pyro, Ill message you so you can teach me a bit this week because I'm free :)

From: Troll
All should handle sub menus i think.

Also has anyone seen the title

R_OpenBanBooth


Yeah I noticed that a week ago. :)

Troll

2011-04-15 17:22:36

From: pyroryan
I don't see anything wrong.


Its changed now but it missed the k of bank