SRL Archive - First Scripts

VWBSmitherBETA


Theron

2015-01-15 22:54:53

Have your preset_1 set up with the bars you will be smithing.
By default, it makes the last thing you selected or your highest item at the anvil (will include option to change item later on)

Start with a full inventory of bars in the Varrock West Bank.
It should change the angle to west and view to highest possible, if this doesn't occur on log-in, you will need to do this manually or it cannot find the banker.

program VWBSmither;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'UN';
password := 'PW';
isActive := true;
isMember := false;
end
currentPlayer := 0;
end;

procedure walkToTheAnvil();
var
myPoint: TPoint;
begin
minimap.findSymbol(myPoint, MM_SYMBOL_ANVIL, minimap.getBounds());

mouse(myPoint, MOUSE_LEFT);

minimap.waitPlayerMoving();
end;

procedure clickAnvil();
var
x, y: integer;
begin
if mainscreen.findObject(x, y, 4737619, 3, ['nvil'], MOUSE_RIGHT) then
begin
writeLn('We right clicked an avil!');
chooseOption.select(['Smith Anvil']);
end;
end;

procedure makePlatebodies();
begin
if productionScreen.isOpen(5000) then // If productionScreen is open within 5 seconds
begin
productionScreen.clickStart(); // Click the start button

if progressScreen.isOpen(5000) then // if progressScreen is open within 5 seconds
begin
writeLn('The progressScreen is open!');

repeat
wait(1000);
until (not progressScreen.isOpen()); // Repeat waiting 1 second until it's not open anymore

end;

end;

end;

procedure clickTheBank();
var
myPoint: TPoint;
begin
minimap.findSymbol(myPoint, MM_SYMBOL_BANK, minimap.getBounds());

mouse(myPoint, MOUSE_LEFT);

minimap.waitPlayerMoving();
end;

procedure findColorz();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
if not isLoggedIn() then
exit;

findColorsSpiralTolerance(x, y, TPA, 5845056, mainScreen.getBounds(), 7, colorSetting(2, 0.25, 1.03));
smartImage.debugTPA(TPA);
writeLn('TPA length is ' + toStr(length(TPA)));
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 mainscreen.findObject(x, y, 5845056, 7, ['ank'], MOUSE_RIGHT) then
smartImage.clear;
chooseOption.select(['Bank Banker'])
end else
writeLn('Couldn''t find the bank for some reason!');
end;

procedure usePreset();
begin
if bankScreen.isOpen() then
bankScreen.clickButton(BANK_BUTTON_PRESET_1)
end;

{Main Loop}
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitTreasure();
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_WEST);
end;

walkToTheAnvil();
clickAnvil();
makePlatebodies();
clickTheBank();
findColorz();
usePreset();

until (false);

end.

Having some banking issues, any advice would be helpful.

edit 1: Replaced bank colors. Colors are working better, however when it opens the bank, the debug says bank not found, even though the bank is open. It doesn't carry on to using presets.

edit 2: Replaced how it clicked the bank, it's sloppy, but functional. Seems very botlike at the moment, would appreciate any help on getting it to run more smoothly.

Thanks to @The Mayor for his tutorials and @KeepBotting for talking me through things on Skype, regardless of how stupid or simple of a question. xD

NKN

2015-01-16 06:42:52

What exactly?

Accuracy, depositing?

Theron

2015-01-16 07:10:45

From: NKN
What exactly?

Accuracy, depositing?


accuracy with my colors, I was orginally using BANK_NPC_BLUE, but that wasn't picking the closest banker, so I tried making a TPA that would. Now it may find the bank 1/4 of the time and now I can't get it to use presets after it opens the bank. Not sure if I have it setup correctly.

NKN

2015-01-16 07:22:29

From: Theron
accuracy with my colors, I was orginally using BANK_NPC_BLUE, but that wasn't picking the closest banker, so I tried making a TPA that would. Now it may find the bank 1/4 of the time and now I can't get it to use presets after it opens the bank. Not sure if I have it setup correctly.


Redo ACA colors.


Only withdraw preset if the bank was successfully opened (Bankscreen.isOpen)

Theron

2015-01-16 08:36:00

From: NKN
Redo ACA colors.


Only withdraw preset if the bank was successfully opened (Bankscreen.isOpen)


replaced colors. It will open the bank now, but it says that the bank isn't open, even though it is. It doesn't carry on with using presets.

Should I consider changing how it clicks the banker, add a wait, and add a procedure that'll check if the bank is open, and if so, use preset_1. It changes angles but not height. Any idea why?

Baba

2015-01-16 15:45:26

From: Theron
replaced colors. It will open the bank now, but it says that the bank isn't open, even though it is. It doesn't carry on with using presets.

Should I consider changing how it clicks the banker, add a wait, and add a procedure that'll check if the bank is open, and if so, use preset_1. It changes angles but not height. Any idea why?


Been getting same bug https://villavu.com/forum/showthread.php?t=111610
To fix move mouse to random location when it clicks the bank.

Theron

2015-01-16 15:58:07

From: Baba
Been getting same bug https://villavu.com/forum/showthread.php?t=111610
To fix move mouse to random location when it clicks the bank.


elaborate a little on that please.

NKN

2015-01-16 16:08:17

From: Theron
elaborate a little on that please.


Something is covering the top of the bank interface.

Remove it.

Theron

2015-01-16 16:15:19

From: NKN
Something is covering the top of the bank interface.

Remove it.


random mouse movement after bank opens. Like so?

http://gyazo.com/cc4a04b1252e8643f9e68e3a096e88b4

Baba

2015-01-16 17:00:41

From: Theron
random mouse movement after bank opens. Like so?

http://gyazo.com/cc4a04b1252e8643f9e68e3a096e88b4


I would use: mouse(MOUSE_MOVE, 400 + randomRange(1, 69), 385 + randomRange(1, 69));
Put it before choose.Option

KeepBotting

2015-01-16 17:04:32

From: Baba
I would use: mouse(MOUSE_MOVE, 400 + randomRange(1, 69), 385 + randomRange(1, 69));
Put it before choose.Option


The best way would be to set some bounds for where the top of the bank interface usually is (they can be static, won't matter hugely in this case), then get SMART's mouse's position. If the mouse position is inside those bounds, move the mouse to the inverse of those bounds (e.g. anywhere else on the screen).

E: come to think of it, mouseOffClient(OFF_CLIENT_RANDOM); might be a simpler way

Theron

2015-01-16 17:20:15

From: KeepBotting
The best way would be to set some bounds for where the top of the bank interface usually is (they can be static, won't matter hugely in this case), then get SMART's mouse's position. If the mouse position is inside those bounds, move the mouse to the inverse of those bounds (e.g. anywhere else on the screen).

E: come to think of it, mouseOffClient(OFF_CLIENT_RANDOM); might be a simpler way


I put this in front of my choose.Option and now it doesn't click a banker, I moved it to after the choose.Option and it doesn't compile.

KeepBotting

2015-01-16 23:58:17

From: Theron
I put this in front of my choose.Option and now it doesn't click a banker, I moved it to after the choose.Option and it doesn't compile.


Post code please, adding a mouseOffClient() shouldn't affect clicking (aside from the time it takes for the mouse to get back) or compiling

bonsai

2015-01-17 00:09:38

We should add a secondary check to SRL that uses a different portion of the bankscreen.

Moving the mouse around isn't a great solution, there's plenty of visible bank window to identify.

KeepBotting

2015-01-17 00:18:58

From: bonsai
We should add a secondary check to SRL that uses a different portion of the bankscreen.

Moving the mouse around isn't a great solution, there's plenty of visible bank window to identify.


That's a good idea. A DTM of the "infinity" symbol on the first bank tab might work? Still kinda near the top though

Theron

2015-01-17 00:30:00

From: KeepBotting
Post code please, adding a mouseOffClient() shouldn't affect clicking (aside from the time it takes for the mouse to get back) or compiling


if mainscreen.findObject(x, y, 5845056, 7, ['ank'], MOUSE_RIGHT) then
smartImage.clear;
mouseOffClient(OFF_CLIENT_RANDOM);
chooseOption.select(['Bank Banker'])
if bankScreen.isOpen() then
end else
writeLn('Couldn''t find the bank for some reason!');
end;

procedure usePreset();
begin
if bankScreen.isOpen() then
bankScreen.clickButton(BANK_BUTTON_PRESET_1)
end;

also included how I use my preset_1 function, it opens the bank if i leave out the mouseOffClient(OFF_CLIENT_RANDOM);, but it doesn't detect the bank is open initially so it has to rerun my full loop before it finds the bank open.

The Mayor

2015-01-17 02:05:19

@Theron;

Bank was most likely failing because you didn't give it enough time to open. You were clicking it, and then straight away calling the preset. What I modified:

https://www.diffchecker.com/7tkj5jsy


program VWBSmither;
{$DEFINE SMART}
{$i srl-6/srl.simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'UN';
password := 'PW';
isActive := true;
isMember := false;
end
currentPlayer := 0;
end;

procedure walkToTheAnvil();
var
myPoint: TPoint;
begin
if minimap.findSymbol(myPoint, MM_SYMBOL_ANVIL, minimap.getBounds()) then
begin
mouse(myPoint, MOUSE_LEFT); // I put this inside a begin..end
minimap.waitPlayerMoving(); // don't want to try and click if you didn't find symbol
end;
end;

procedure clickAnvil();
var
x, y: integer;
begin
if mainscreen.findObject(x, y, 4737619, 3, ['nvil'], MOUSE_RIGHT) then
begin
writeLn('We right clicked an avil!');
chooseOption.select(['Smith Anvil']);
end;
end;

procedure makePlatebodies();
begin
if productionScreen.isOpen(5000) then
begin
productionScreen.clickStart();
if progressScreen.isOpen(5000) then
begin
writeLn('The progressScreen is open!');
repeat
wait(1000);
until (not progressScreen.isOpen());
end;
end;
end;

procedure clickTheBank();
var
myPoint: TPoint;
begin
if minimap.findSymbol(myPoint, MM_SYMBOL_BANK, minimap.getBounds()) then
begin
mouse(myPoint, MOUSE_LEFT); // Same again here
minimap.waitPlayerMoving();
end;
end;

procedure findColorz();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if not isLoggedIn() then
exit();

findColorsSpiralTolerance(x, y, TPA, 5845056, mainScreen.getBounds(), 7, colorSetting(2, 0.25, 1.03));

if (length(TPA) < 1) then
begin
writeLn('Found no bank colours');
exit();
end;

smartImage.debugTPA(TPA);
writeLn('TPA length is ' + toStr(length(TPA)));

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(['ank']) then
begin
fastClick(MOUSE_RIGHT); // I cleaned up this
chooseOption.select(['Bank']);
break();
end;
end

end;

procedure usePreset();
begin
if bankScreen.isOpen(5000) then // added a wait, as that's why it was failing
bankScreen.clickButton(BANK_BUTTON_PRESET_1)
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitTreasure();
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_WEST);
end;

walkToTheAnvil();
clickAnvil();
makePlatebodies();
clickTheBank();
findColorz();
usePreset();
until (false);
end.


Theron

2015-01-17 09:47:34

From: The Mayor
@Theron;

Bank was most likely failing because you didn't give it enough time to open. You were clicking it, and then straight away calling the preset. What I modified:

https://www.diffchecker.com/7tkj5jsy


program VWBSmither;
{$DEFINE SMART}
{$i srl-6/srl.simba}

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'UN';
password := 'PW';
isActive := true;
isMember := false;
end
currentPlayer := 0;
end;

procedure walkToTheAnvil();
var
myPoint: TPoint;
begin
if minimap.findSymbol(myPoint, MM_SYMBOL_ANVIL, minimap.getBounds()) then
begin
mouse(myPoint, MOUSE_LEFT); // I put this inside a begin..end
minimap.waitPlayerMoving(); // don't want to try and click if you didn't find symbol
end;
end;

procedure clickAnvil();
var
x, y: integer;
begin
if mainscreen.findObject(x, y, 4737619, 3, ['nvil'], MOUSE_RIGHT) then
begin
writeLn('We right clicked an avil!');
chooseOption.select(['Smith Anvil']);
end;
end;

procedure makePlatebodies();
begin
if productionScreen.isOpen(5000) then
begin
productionScreen.clickStart();
if progressScreen.isOpen(5000) then
begin
writeLn('The progressScreen is open!');
repeat
wait(1000);
until (not progressScreen.isOpen());
end;
end;
end;

procedure clickTheBank();
var
myPoint: TPoint;
begin
if minimap.findSymbol(myPoint, MM_SYMBOL_BANK, minimap.getBounds()) then
begin
mouse(myPoint, MOUSE_LEFT); // Same again here
minimap.waitPlayerMoving();
end;
end;

procedure findColorz();
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if not isLoggedIn() then
exit();

findColorsSpiralTolerance(x, y, TPA, 5845056, mainScreen.getBounds(), 7, colorSetting(2, 0.25, 1.03));

if (length(TPA) < 1) then
begin
writeLn('Found no bank colours');
exit();
end;

smartImage.debugTPA(TPA);
writeLn('TPA length is ' + toStr(length(TPA)));

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(['ank']) then
begin
fastClick(MOUSE_RIGHT); // I cleaned up this
chooseOption.select(['Bank']);
break();
end;
end

end;

procedure usePreset();
begin
if bankScreen.isOpen(5000) then // added a wait, as that's why it was failing
bankScreen.clickButton(BANK_BUTTON_PRESET_1)
end;

begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
declarePlayers();

repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
exitTreasure();
mainScreen.setAngle(MS_ANGLE_HIGH);
minimap.setAngle(MM_DIRECTION_WEST);
end;

walkToTheAnvil();
clickAnvil();
makePlatebodies();
clickTheBank();
findColorz();
usePreset();
until (false);
end.



Thank you, any thoughts on the easiest way to incorporate antiban into this?

GRIM

2015-01-17 13:13:09

@Theron


procedure antiBan(); //ez n00b shit antibanm8
begin
case random(3) of
0: pickUpMouse();
1: mouseOffClient(OFF_CLIENT_RANDOM);
2: hoverSkill(SKILL_SMITHING);
3: hoverRandomSkill();
end
end;

Now i'll add the antiban procedure we just created in the script after the code where your progress screen is open.
That way when the progress screen is open you're checking your xp :D


antiBan();

my fix


procedure makePlatebodies();
begin
if productionScreen.isOpen(5000) then
begin
productionScreen.clickStart();
if progressScreen.isOpen(5000) then
begin
writeLn('The progressScreen is open!');
repeat
antiBan();
until (not progressScreen.isOpen());
end;
end;
end;

I want to note that your banking method is stupid as hell and extremely unstable right now.
Begin fixing that is my suggestion for further development..

Theron

2015-01-17 13:39:51

From: GRIM
@Theron


procedure antiBan(); //ez n00b shit antibanm8
begin
case random(3) of
0: pickUpMouse();
1: mouseOffClient(OFF_CLIENT_RANDOM);
2: hoverSkill(SKILL_SMITHING);
3: hoverRandomSkill();
end
end;

Now i'll add the antiban procedure we just created in the script after the code where your progress screen is open.
That way when the progress screen is open you're checking your xp :D


antiBan();

my fix


procedure makePlatebodies();
begin
if productionScreen.isOpen(5000) then
begin
productionScreen.clickStart();
if progressScreen.isOpen(5000) then
begin
writeLn('The progressScreen is open!');
repeat
antiBan();
until (not progressScreen.isOpen());
end;
end;
end;

I want to note that your banking method is stupid as hell and extremely unstable right now.
Begin fixing that is my suggestion for further development..

Could you elaborate on what's wrong with the banking method?
I specifically took it from The Mayor's tutorial. How can I improve it or change it to something more stable? I'm open to constructive criticism.

GRIM

2015-01-20 13:18:49

my banking method is stupid af but it works for my script

i do

procedure bank();
begin
if bankScreen.open(BANK_NPC_BLUE) then
bankScreen.clickButton(BANK_BUTTON_PRESET_1)
end;

you could make your script walk to the point in the back next to the npc and then use that for banking
your script trys to talk to the bankers that are behind the closed doors like it's tryna get laid or something
hahahah