SRL Archive - RS3 Help

Right Click Hover Banker


Gunner

2014-05-13 00:43:47

Hey dudez, me again. What is the easiest way to write a right click hover option for banking? I've successfully written in a hover for this before, but that's all it was. It just hovered the mouse over the banker then left clicked when it was supposed to, but sometimes it would jump from banker to banker before clicking. I would like to right click the banker and hover the "Bank Banker" option.

Here is the code from the original hover I "wrote"…err…stole from The Mayor's tut and deleted the fastClick bit…


procedure hoverBank();
begin
if bankScreen.isOpen then
exit;

findColorsSpiralTolerance(x, y, TPA, 5385548, mainScreen.getBounds(), 16, colorSetting(2, 0.59, 0.72));

if (Length(TPA) < 1) then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do

begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);

end;
end;
end;

And here is my current banking code:

procedure openBank();
begin
if not isLoggedIn() then
begin
writeln('We got logged out, logging back in!');
exit;
end;

bankScreen.open(BANK_NPC_BLUE); //Change this to the bank of your choice.

if (pinscreen.isOpen()) then
begin
writeln('Pinscreen is open!');
if (pinScreen.enter('1234')) then //Change the number to your bank pin.
writeln('Entered our bank pin!');
end;

if bankScreen.isOpen then
begin
inc(LoadsDone);
exit;
end;
end;

I'm assuming I would not be able to incorporate the bankScreen.open(WhicheverBanker), which is ok but I don't want to right click and hover one banker, then go off and left click another when it's time to actually bank. Which so far, is the only thing I've been able to do. I guess what I need is a hoverOption(); instead of chooseOption.select().

Is the best way to do this by using the ATPA above, then a right click, then a wait time, then a chooseOption.select? Or is there a more reliable, more logical way to do it?

Thanks in advance!

sdf

2014-05-13 01:25:49

The problem is that you don't have something to exit the 'for' loop once it's found the thing to hover over, so it will continue to hover over all found points.


function hoverBank(): Boolean;
begin
if bankScreen.isOpen then
exit;

findColorsSpiralTolerance(x, y, TPA, 5385548, mainScreen.getBounds(), 16, colorSetting(2, 0.59, 0.72));
if (Length(TPA) < 1) then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Bank'], 500) then exit(true);
end;
end;
Adding a simple check to see if the mouse is over a valid target will cause the procedure to stop once it's hovered over the banker (by validating the banker's uptext).

You would then incorporate it like this:

function openBank(): Boolean;
begin
if not isLoggedIn() then
begin
writeln('We got logged out, logging back in!');
exit;
end;

if hoverBank() then
begin
fastClick(MOUSE_RIGHT);
result := ChooseOption.select(['Bank'], 200); //bank screen should be open, if this returns true
end;

if (pinscreen.isOpen()) then
begin
writeln('Pinscreen is open!');
if (pinScreen.enter('1234')) then
writeln('Entered our bank pin!');
end;

if bankScreen.isOpen then
begin
inc(LoadsDone);
exit;
end;
end;
There are simpler ways to do this, but I can't be bothered typing it up.

EDIT: I noticed you want it to sometimes right click to bank and sometimes left click - you can simply set up a case structure using a random generated number e.g.:

r := random(99);
case r of
0..79: leftClickBank();
80..99: rightClickBank();
end;

Gunner

2014-05-13 01:51:59

From: sdf

EDIT: I noticed you want it to sometimes right click to bank and sometimes left click - you can simply set up a case structure using a random generated number e.g.:

r := random(99);
case r of
0..79: leftClickBank();
80..99: rightClickBank();
end;


I would only want it to left click if the antiban did a mouseoffclient. Otherwise I would always want it to right click immediately after productionscreen.clickStart; and then hover the "Bank Banker" option. Thanks for your reply though, it gave me a really good place to start.

The Mayor

2014-05-13 05:22:18

From: Gunner
I would only want it to left click if the antiban did a mouseoffclient. Otherwise I would always want it to right click immediately after productionscreen.clickStart; and then hover the "Bank Banker" option. Thanks for your reply though, it gave me a really good place to start.



Good idea. Although I don't think you should hover every single time. Sometimes you could even hover, but then move the mouse away even before you've finished what you're doing.

Here is an idea that you can use as a base. You can just use 1 procedure that takes a Boolean parameter.


procedure openBank(hover: boolean);
var
TPA: TPointArray;
ATPA: Array of TPointArray;
i, x, y: Integer;
t: TTimeMarker;
begin
if not isLoggedIn() then
begin
writeln('We got logged out, logging back in!');
exit;
end;

if bankScreen.isOpen() then
exit;

findColorsSpiralTolerance(x, y, TPA, 5385548, mainScreen.getBounds(), 16, colorSetting(2, 0.59, 0.72));

if (length(TPA) < 1) then
exit;

ATPA := TPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Bank'], 500) then
begin
if hover then // if hovering
begin
fastClick(MOUSE_RIGHT);
//using internal _select with MOUSE_MOVE
if chooseOption._select(['Bank Banker'], MOUSE_MOVE, false, 1.00, 250) then
begin
t.start();

repeat
wait(100);
until (not productionScreen.isOpen()) or (t.getTime() > 30000);

if chooseOption.select(['Bank Banker']) then
exit;
end;
end else
begin // if not hover just left click
fastClick(MOUSE_LEFT);
exit;
end;
end;
end;
end;

procedure depositStuff();
begin
if not isLoggedIn() then
begin
writeln('We got logged out, logging back in!');
exit;
end;

if (pinscreen.isOpen()) then
begin
writeln('Pinscreen is open!');
if (pinScreen.enter('1234')) then
writeln('Entered our bank pin!');
end;

//deposit stuff

end;

begin
setupSRL();
openBank(true);
depositStuff();
end.

Gunner

2014-05-13 12:10:20

From: The Mayor
Good idea. Although I don't think you should hover every single time. Sometimes you could even hover, but then move the mouse away even before you've finished what you're doing.

Here is an idea that you can use as a base. You can just use 1 procedure that takes a Boolean parameter.


If I understand correctly,

chooseOption._select(['Bank Banker'], MOUSE_MOVE, false, 1.00, 250)

is telling it to hover the Bank Banker option, and NOT to click yet, correct? I think I'm missing something though. To me it looks like it will always move the mouse over the banker, so "hover" will always return true? And hence, will always hover the Bank Banker option? I know that's what I asked for, but then what is the point of


end else
begin // if not hover just left click
fastClick(MOUSE_LEFT);
exit;
end;

In a separate question for that particular bit of code, if it's not hovering, shouldn't it be


end else
begin // if not hover just left click
bankScreen.open(BANK_NPC_BLUE);
exit;
end;

since if it's not hovering, fastClick will cause my toon to take off running wherever the mouse happens to be right? Sorry, I know these are probably first grade questions, but I'm just now getting into the color aspects and getting away from coords and SRL functions.

The Mayor

2014-05-13 16:01:32

From: Gunner
If I understand correctly,

chooseOption._select(['Bank Banker'], MOUSE_MOVE, false, 1.00, 250)

is telling it to hover the Bank Banker option, and NOT to click yet, correct? I think I'm missing something though. To me it looks like it will always move the mouse over the banker, so "hover" will always return true?


Yes, you can see before that line it right clicks, and this line tells it to move the mouse over the 'BankBanker' option in the chooseOptions menu, but not click. You can see the "hover" boolean is a parameter that you input:


procedure openBank(hover: boolean);
So if you wanted to hover you would go:

openBank(true);
and if you wanted to just left click the closest banker you would go:

openBank(false);

Lets take a closer look at that chunk of code:

mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Bank'], 500) then //right now mouse is on top of closest banker NPC
begin
if hover then
begin // if you set hover to true then this will begin
fastClick(MOUSE_RIGHT); // right click
//move mouse to 'Bank Banker' in chooseOptions popup
if chooseOption._select(['Bank Banker'], MOUSE_MOVE, false, 1.00, 250) then
begin
t.start();

repeat //repeat waiting until the production screen closes (or what ever)
wait(100);
until (not productionScreen.isOpen()) or (t.getTime() > 30000);

if chooseOption.select(['Bank Banker']) then //since production screen is closed
exit; // we click the 'Bank Banker' option we were hovering over
end;
end else // if you didn't set hover to true, this will begin instead
begin // it will just left click the banker (which the mouse is already on top of)
fastClick(MOUSE_LEFT);
exit;
end;


From: Gunner

In a separate question for that particular bit of code, if it's not hovering, shouldn't it be


end else
begin // if not hover just left click
bankScreen.open(BANK_NPC_BLUE);
exit;
end;

since if it's not hovering, fastClick will cause my toon to take off running wherever the mouse happens to be right? Sorry, I know these are probably first grade questions, but I'm just now getting into the color aspects and getting away from coords and SRL functions.


I think you're missing the fact that the mouse has already moved to the closest banker NPC

mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Bank'], 500) then
begin

So if hover is set to true, it will right click and wait, else it will left click straight away. I didn't use bankScreen.open(BANK_NPC_BLUE) because that is just searching for the banker colors all over again, which we have already done.

Gunner

2014-05-14 10:31:11

From: The Mayor
Yes, you can see before that line it right clicks, and this line tells it to move the mouse over the 'BankBanker' option in the chooseOptions menu, but not click. You can see the "hover" boolean is a parameter that you input:


procedure openBank(hover: boolean);
So if you wanted to hover you would go:

openBank(true);
and if you wanted to just left click the closest banker you would go:

openBank(false);

So if hover is set to true, it will right click and wait, else it will left click straight away. I didn't use bankScreen.open(BANK_NPC_BLUE) because that is just searching for the banker colors all over again, which we have already done.


Ok, that all makes sense now. Thanks a lot for clarifying.

So In my case, as you suggested, I don't want to hover every single time, just most of the time. So could I add in a case/of "1..80: openBank(true);" and case/of "81..99" openBank(false);?

Something like this?:


procedure hoverYorN();

begin
case Random(60) of
1..80: begin
openBank(true);
end;
81..99: begin
openBank(false);
end;
end;

And then call it here?:


for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Bank'], 500) then
begin
if openBank(hover: true); then // if hovering
begin
fastClick(MOUSE_RIGHT);
//using internal _select with MOUSE_MOVE
if chooseOption._select(['Bank Banker'], MOUSE_MOVE, false, 1.00, 250) then
begin
t.start();

repeat
wait(100);
until (not productionScreen.isOpen()) or (t.getTime() > 30000);

if chooseOption.select(['Bank Banker']) then
exit;
end;
end else
begin
openBank(hover: false); // if not hover just left click
fastClick(MOUSE_LEFT);
exit;
end;
end;
end;
end;

Otherwise, hover is just an option I set before running the script, correct? And it will always execute whatever I set? Or does your code offer some kind of case/of that I missed, again? Thanks a lot man.

The Mayor

2014-05-14 16:45:35

From: Gunner
Ok, that all makes sense now. Thanks a lot for clarifying.

So In my case, as you suggested, I don't want to hover every single time, just most of the time. So could I add in a case/of "1..80: openBank(true);" and case/of "81..99" openBank(false);?

Something like this?:


procedure hoverYorN();

begin
case Random(60) of
1..80: begin
openBank(true);
end;
81..99: begin
openBank(false);
end;
end;



Yes like so. Although in the case when you're not hovering make sure you wait until the inventory is compete with potions or whatever (e.g.add it above openbank(false) in the second case)


And then call it here?:


for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Bank'], 500) then
begin
if openBank(hover: true); then // if hovering
begin
fastClick(MOUSE_RIGHT);
//using internal _select with MOUSE_MOVE
if chooseOption._select(['Bank Banker'], MOUSE_MOVE, false, 1.00, 250) then
begin
t.start();

repeat
wait(100);
until (not productionScreen.isOpen()) or (t.getTime() > 30000);

if chooseOption.select(['Bank Banker']) then
exit;
end;
end else
begin
openBank(hover: false); // if not hover just left click
fastClick(MOUSE_LEFT);
exit;
end;
end;
end;
end;

Otherwise, hover is just an option I set before running the script, correct? And it will always execute whatever I set? Or does your code offer some kind of case/of that I missed, again? Thanks a lot man.


No don't call it there :p just leave it as it is. After you start making pots just call that hoverYorN procedure. I'm on phone so can't really elaborate

Gunner

2014-05-14 23:00:35

From: The Mayor

No don't call it there :p just leave it as it is. After you start making pots just call that hoverYorN procedure. I'm on phone so can't really elaborate


Ok gotcha. My current banking procedure only does one thing, opens the bank. Inside the bank is handled by another procedure, so I should just be able to replace openBank(); with hoverYorN();? Pretty sure that's an obvious yes, but I've asked dumber shit LOL. Thanks again for your help, and your patience!

The Mayor

2014-05-15 00:16:38

From: Gunner
Ok gotcha. My current banking procedure only does one thing, opens the bank. Inside the bank is handled by another procedure, so I should just be able to replace openBank(); with hoverYorN();? Pretty sure that's an obvious yes, but I've asked dumber shit LOL. Thanks again for your help, and your patience!


Yep should be sweet.

Thomas

2015-03-04 03:29:36

I would love to see this included into SRL.

Thomas

2015-03-20 08:37:00

procedure antiban;
var
i: integer;
begin
i := random(600);
case i of
1: boredHuman(false);
2..7:
begin
hoverSkill(Skill_Herblore);
wait(gaussRangeInt(600, 900));
end;
8..50: mouseMovingObject;
51..280: sleepAndMoveMouse(randomRange(100, mouseB));
291..310:
begin
mouseOffClient(4);
wait(randomRange(400, mouseB));
end;
311..600: wait(randomRange(300, 700));
end;
wait(gaussRangeInt(80, antiB));
end;


function banking: boolean;
var
t: TTimeMarker;
time: integer;
begin
if not isLoggedIn then
exit;
t.start;
SRL_Events[EVENT_ANTIBAN] := nil;
time := gaussRangeInt(10000, 14000);
repeat
wait(gaussRangeInt(100, 400));
if bankscreen.open(BANK_GE) then
break
else
minimap.setAngle(MM_DIRECTION_NORTH);
if (t.getTime > time) or (not isLoggedIn) then
exit;
until (bankScreen.isOpen or pinscreen.isOpen);
SRL_Events[EVENT_ANTIBAN] := @ antiban;
pinScreen.Enter(players[currentPlayer].bankPin);
begin
t.start;
time := gaussRangeInt(8000, 10000);
repeat
if bankScreen.clickButton(BANK_BUTTON_PRESET_1) then
break;
if (t.getTime > time) or (not isLoggedIn) then
exit;
wait(gaussRangeInt(0, 500));
until false;
end;
begin
t.start;
time := gaussRangeInt(4000, 8000);
repeat
if not bankScreen.__find() then
break;
if (t.getTime > time) or (not isLoggedIn) then
exit;
wait(gaussRangeInt(0, 200));
until false;
end;
begin
case random(10) of
0..7: slot := 11;
8..9: slot := 12;
end;
tabBackpack.mouseSlot(slot, MOUSE_MOVE);
end;
wait(gaussRangeInt(30, 160));
t.start;
repeat
if (tabBackpack.isItemInSlot(28)) then
break;
wait(gaussRangeInt(20, 140));
if (t.getTime > 20000) then
begin
writeln('Failed withdrawing, shutting down');
players[currentPlayer].logout;
end;
if not isLoggedIn then
exit;
until (tabBackpack.isItemInSlot(28));
if chatbox.findTextOnLines(['could not be'], [0]) then
if countColorTolerance(66033, chatbox.lineBoxes[0], 10) > 100 then
begin
writeln('Failed withdrawing, shutting down');
players[currentPlayer].logout;
terminateScript;
end;
result := true;
end;


function makeItems: boolean;
var
time, X, Y, i: integer;
T: TTimeMarker;
begin
if not isLoggedIn then
exit;
tabBackpack.Open;
begin
t.start;
time := gaussRangeInt(5000, 8000);
antiB := 1500;
mouseB := 1800;
getMousePOS(x, y);
if slot = 0 then
slot := 1;
if not pointInBox(point(x, y), tabBackpack.getSlotBox(11)) and not pointInBox(point(x, y), tabBackpack.getSlotBox(12)) then
begin
case random(10) of
0..7: slot := 11;
8..9: slot := 12;
end;
end;
tabBackpack.mouseSlot(slot, MOUSE_LEFT);
wait(gaussRangeInt(90, 250));
case random(10) of
0..7: slot := 16;
8..9: slot := 17;
end;
tabBackpack.mouseSlot(slot, MOUSE_LEFT);
wait(gaussRangeInt(110, 230));


repeat
if productionScreen.isOpen then
break;
wait(gaussRangeInt(50, 200));
if (not isLoggedIn) or (t.getTime > time) then
begin
minimap.clickCompass;
exit;
end;
until productionScreen.IsOpen;
wait(gaussRangeInt(50, 200));
if itemType = '' then
// begin
itemType := productionScreen.getSelectedBoxText;
// end;
productionScreen.clickStart;
if not tabBackpack.waitForShift(randomRange(3000, 3500)) then
exit;
wait(gaussRangeInt(50, 200));
timeout.start;
t.start;
time := gaussRangeInt(25000, 40000);
repeat
wait(gaussRangeInt(50, 200));
antiBan;
if (not isLoggedIn) or (t.getTime > time) then
exit;
until not (tabBackpack.IsItemInSlot(27));
itemCount := itemCount + 14;
end;
result := true;
end;


procedure mainloop;
var
i: integer;
begin
if not isLoggedIn then
begin
wait(7000);
writeln('Attempting to log back in');
repeat
try
players[currentPlayer].login;
inc(i);
except
end;
if (i = 7) then
begin
i := 0;
players.next(false);
end;
until isLoggedIn;
minimap.clickCompass;
timeout.start;
end;
if banking and (tabBackpack.isFull) then
begin
findNormalrandoms;
if makeItems then
begin
progressReport;
findNormalrandoms;
end;
end;
if timeout.getTime > 200000 then
begin
writeln('nothing has happened for too long, shutting down');
players[currentPlayer].logout;
terminateScript;
end;
if players[currentPlayer].Booleans[0] then
breakHandler(players[currentPlayer].integers[0], players[currentPlayer].integers[1], bir, bfr);
end;


begin
setup;
while (players.getActive() > 0) do
mainloop;
end.

How would I go into adding this in ashamans herblore script? I kind of wanted to include it in the antiban like this:
case i =1-200 then Hover NPC (no right click) until no item in slot 27 or 28. That seemed the most easy solution. But wouldn't allow for right click hover the way the mainloop etc is structured.

I don't know how I should add it the right click hover though, as the script currently repeats the antiban untill no items in 27/28. And then starts the loop again, starting with banking, making items and antiban untill no items.






function TRSBankScreen.__hoverGE(): Boolean;

function findBankerAreas(): TBoxArray;
var
TPA: TPointArray;
ATPA: T2DPointArray;
i: Integer;
b: TBox;
begin
FindColorsTolerance(TPA, 6580588, MainScreen.GetBounds(), 5, ColorSetting(2, 2.09, 0.55));
ATPA := ClusterTPAEx(TPA, 5, 5);

for i := 0 to High(ATPA) do
begin
if (Length(ATPA[i]) < 100) then
Continue;

b := GetTPABounds(ATPA[i]);

if (b.getWidth() < 15) or (b.getHeight() < 15) or
(b.getWidth() > 220) or (b.getHeight() > 220) or
(ATPA[i].getDensity() < 0.10) then
Continue;

b.Expand(10);
b.setLimit(MainScreen.getBounds());

Result := Result + b;
end;
end;

function findBanker(const Area: TBox): Boolean;
var
tFace, TPA: TPointArray;
aFace, ATPA: T2DPointArray;
i, j: Integer;
b: TBox;
p: TPoint;
begin
if (not FindColorsTolerance(tFace, 5408694, Area, 15, ColorSetting(2, 0.18, 0.67))) then
Exit(False);

aFace := ClusterTPAEx(tFace, 3, 3);
SortATPAFromMidPoint(aFace, MiddleBox(Area));

for i := 0 to High(aFace) do
if (Length(aFace[i]) > 4) and (Length(aFace[i]) < 50) then
begin
p := MiddleTPA(aFace[i]);
b := intToBox(p.x - 12, p.y, p.x + 12, p.y + 30);

if (not FindColorsTolerance(TPA, 11382432, b, 9, ColorSetting(2, 5.57, 0.48))) then
Continue();

ATPA := ClusterTPAEx(TPA, 4, 4);
SortATPASize(ATPA, True);

for j := 0 to High(ATPA) do
begin
if (Length(ATPA[j]) < 15) then
Continue();

mouse(ATPA[j].getMiddle().randRange(-4, 5));

if (isMouseOverText(['Bank Banker', 'ank Bank'])) then
begin

if (minimap.isFlagPresent(Random(300, 600))) then
minimap.waitFlag(10);
if (tabBackpack.isItemInSlot(28)) then
Exit(True);
end;
end;
end;
end;


var
i: Integer;
Boxes: TBoxArray;
begin
Result := False;
Boxes := findBankerAreas();

if (Length(Boxes) = 0) then
Exit(print('bankScreen.__openGE(): Found no possible area''s for a banker to be in', False));

SortBoxesFromMidPoint(Boxes, MainScreen.playerPoint);

for i := 0 to High(Boxes) do
if (FindBanker(Boxes[i])) then
Exit(print('bankScreen.__openGE(): Succesfully opened the GE bank', True, '', TDebug.DEBUG));
end;

I added this, how do I prevent the mouse from moving as much as it currently does while it hovers over the bank?
I rather not add a wait for it.