SRL Archive - First Scripts

[RS3/SRL6/SPS] Inc's Onion Collector


Incurable

2014-08-17 09:29:09

STATUS: I have no plans to release an updated version. If enough people REALLY want it, I will, but this is an onion collector, lol… that won't happen. ;)

G'day,

This is a very simple script that will collect a pack of onions at the Draynor onion patch, bank them, and then repeat the process until the desired number of onions has been banked. It was written in a total of around 6 hours, and as such features no anti-ban and a (very) dodgy progress report. I got the idea from The Mayor/Solaire and used the invaluable tutorials created by C0h3n and The Mayor to create it.

Any feedback is welcome, though I'm unsure whether to continue to learn by improving this script, or whether I should use what I know to create a more valuable script with a higher gold/hr rate and then make that one worth using.

Known issues:
  • PickOnions(): If an onion can't be found then the mouse will be randomly moved around in a completely inhuman fashion.
  • ProgRep(): It works, but it's totally crap. Doesn't update once a second, instead updates each time an onion is picked or a load is deposited. I would love to make it update once per second.
  • LoginSteps(): Sometimes this won't actually run if the player is already logged in when the script is started, I have no idea why though.
  • Anti-ban: There's almost none.
  • Anti-randoms: Still yet to see a random? Not even sure what's going on there… o.O Turns out there are none in RS3… WHY?! XD

On the plus side, the script can run for several hours without interruption and is able to be started in the onion patch, close to it, or in the bank. It can also be started whether logged in or out, though logged out is much preferred.

Here's a proggy, I'm unsure why it stopped short of its goal, but it did run for 3.5 hours. :D


Inc's Onion Collector
Onions/hr: 769
Profit/hr: 48468 <--- Ignore that, had a bug.
Total collected: 2658/2800
Total profit: 13290gp
Time running: 3 Hours, 27 Minutes and 17 Seconds

Make sure to place the DRAYNOR_BANK_MAP.png file in the C:\Simba\Includes\SPS\img\runescape_other folder before running.

Cheers!

-Inc.


program OnionCollector;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

{ ******************** BEGIN USER SCRIPT SETUP ********************

Instructions:
1. Make sure that DRAYNOR_BANK_MAP.png is correctly placed in
"C:\Simba\Includes\SPS\img\runescape_other" before running
2. Check that Simba is using Lape (Script > Interpreter > Lape)
3. Setup the script by changing the values below
}

var
numToPick := 1000; // Number of onions to pick?
onionPrice := 5; // Current price of onions?
numPicked: integer; // Ignore
numBanked: integer; // Ignore

procedure DeclarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'username';
password := 'password';
isActive := true;
end
currentPlayer := 0;
end;

{ ******************** END USER SCRIPT SETUP ******************** }

// Steps to be completed at login
procedure LoginSteps();
begin
wait(randomRange(1000, 3000));
if not isLoggedIn() then
exit;

mainscreen.setZoom(true);
wait(randomRange(200, 500));
minimap.setAngle(MM_DIRECTION_NORTH);
wait(randomRange(200, 500));
mainScreen.setAngle(MS_ANGLE_HIGH);
wait(randomRange(200, 500));
exitTreasure();
wait(randomRange(1000, 3000));
end;

procedure ProgRep();
var
onionPh, profit, profitPh: integer;
x := 0;
y := 295;

begin
profit := numPicked * onionPrice;
onionPh := round((numPicked * 3600) / (getTimeRunning() / 1000));
profitPh := round((numPicked * onionPrice) * 3600 / (getTimeRunning() / 1000));

clearDebug();
writeLn('Inc''s Onion Collector');
writeLn('Onions/hr: ' + intToStr(onionPh));
writeLn('Profit/hr: ' + intToStr(profitPh));
writeLn('Total collected: ' + intToStr(numPicked) + '/' + intToStr(numToPick));
writeLn('Total profit: ' + intToStr(profit) + 'gp');
writeLn('Time running: ' + TimeRunning);
writeLn('============================================');

smartImage.clear();
smartImage.drawText('Inc''s Onion Collector', point(10, 290), upchars, true, clWhite);
smartImage.drawText('Onions/hr: ' + intToStr(onionPh), point(10, 305), upchars, true, clWhite);
smartImage.drawText('Profit/hr: ' + intToStr(profitPh), point(10, 320), upchars, true, clWhite);
smartImage.drawText('Total profit: ' + intToStr(profit) + 'gp', point(10, 335), upchars, true, clWhite);
smartImage.drawText('Total collected: ' + intToStr(numPicked) + '/' + intToStr(numToPick), point(10, 350), upchars, true, clWhite);
smartImage.drawText('Time running: ' + TimeRunning, point(10, 365), upchars, true, clWhite);
end;

// Pick a full inventory of onions
procedure PickOnions();
var
x, y, bpCountBeforeWait: integer;
begin
if not isLoggedIn() then
exit;

if mainscreen.findObject(x, y, 5142619, 10, ['ick'], MOUSE_LEFT) then
begin
bpCountBeforeWait := tabBackpack.count();
tabBackPack.waitForShift(5000);
if tabBackpack.count() > bpCountBeforeWait then
numPicked := numPicked + 1;
ProgRep();
wait(randomRange(200, 500));
end else
wait(randomRange(2000, 4000));
end;

// Walk to the bank from the onion patch
// Is this even needed???
procedure WalkToBank();
begin
end;

// Deposits the onions at a bank NPC
procedure DepositOnions();
var
quickDepInvBox: TBox;

begin
quickDepInvBox := intToBox(392, 564, 421, 587);
if not isLoggedIn() then
exit;

bankScreen.open(BANK_NPC_DRAYNOR);
if (minimap.isPlayerMoving()) then
minimap.waitPlayerMoving();

mouseBox(quickDepInvBox, MOUSE_LEFT);
numBanked := numBanked + 28;
ProgRep();
wait(randomRange(500, 1500));
bankScreen.close();;
end;

// Walk to the onion patch from the bank
procedure WalkToPatch();
var
pathToPatch: TPointArray;
begin
if not isLoggedIn() then
exit;

pathToPatch := [Point(208, 207), Point(225, 188), Point(241, 216), Point(231, 236)];
if SPS.walkPath(pathToPatch) then
minimap.waitPlayerMoving()
else
writeLn('ERROR: Failed to walk to the onion patch');
end;

// main loop
begin
clearDebug();
smartEnableDrawing := true;
SmartShowConsole := false;
SetupSRL();
DeclarePlayers();
SPS.setup('DRAYNOR_BANK_MAP', RUNESCAPE_OTHER);
wait(1000);
if not isLoggedIn() then
begin
players[currentPlayer].login();
LoginSteps();
ProgRep();
end;

if isLoggedIn() and tabBackpack.isFull() then
begin
LoginSteps();
ProgRep();
DepositOnions();
end else
ProgRep();
WalkToPatch();

repeat
repeat
PickOnions();
until tabBackPack.isFull();
//WalkToBank();
DepositOnions();
if numBanked < numToPick then
WalkToPatch();
until numBanked >= numToPick;

wait(randomRange(2000, 3000));
players[currentPlayer].logout();
smartImage.clear();
end.

Spaceblow

2014-08-18 05:29:06

I'm a beginner myself and I can tell you this is great for a first script, well done. For your WalkToBank() procedure, I don't think it's necessary if the script already does what you want. And for the randoms: "Random events were removed from RuneScape after an update.", nice huh? And I suggest you try to adjust your script with antiban and everything and when it's pretty flawless, move on to your next thing. I'm actually doing that right now, so I could get some more experience before I move on to something bigger. Keep up the good work!

Incurable

2014-08-18 05:48:48

From: Spaceblow
I'm a beginner myself and I can tell you this is great for a first script, well done. For your WalkToBank() procedure, I don't think it's necessary if the script already does what you want. And for the randoms: "Random events were removed from RuneScape after an update.", nice huh? And I suggest you try to adjust your script with antiban and everything and when it's pretty flawless, move on to your next thing. I'm actually doing that right now, so I could get some more experience before I move on to something bigger. Keep up the good work!


Why on Earth did they remove randoms? That just makes botting in RS3 a billion times easier, lol. I think I'll do as you suggested and add some anti-ban when I have the time. The reason I'm unsure about WalkToBank() is that I think it'll become necessary when I have some anti-ban and the screen is rotated in a random way. At the moment, the script relies purely on the fact that a few bank booths are always in sight when it is time to deposit the load. Thank you for the feedback, it's much appreciated. :D

On another note, I just ran the script for 6 straight hours before it stopped thanks to SMART, so I'm pretty confident that, barring that issue with SMART, this script could run for days at a time. :p


The Mayor

2014-08-18 05:59:57

Yes, nice first script :) I actually requested that Solaire write the onion collector as I wanted to start another collection.

Anyway, instead of using custom buttons like:

quickDepInvBox := intToBox(392, 564, 421, 587);

You should use the SRL functions as they are most probably more stable.

bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);


Also, you should watch out for these infinite loops:

repeat
PickOnions();
until tabBackPack.isFull();

What happens if you lagged out, or no onions were actually on screen?

You should probably put your login code insude your repeat loop so you can pass the 6h fix:


repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
LoginSteps();
ProgRep();
end;

WalkToPatch();

repeat // It's probably better to put the repeat..until inside the PickOnions() procedure with a timer
PickOnions();
until tabBackPack.isFull();

DepositOnions();
until numBanked >= numToPick;

Incurable

2014-08-18 07:36:24

From: The Mayor
Yes, nice first script :) I actually requested that Solaire write the onion collector as I wanted to start another collection.


Thank you, and thank you for the idea! ;)

Anyway, instead of using custom buttons like:

quickDepInvBox := intToBox(392, 564, 421, 587);

You should use the SRL functions as they are most probably more stable.

bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);


I actually did use that SRL procedure at first, but it would frequently fail to click it, believe that it had been clicked, and then try and run back to the patch with the bank screen still open. Changing it to a TBox actually solved that problem.

Also, you should watch out for these infinite loops:

repeat
PickOnions();
until tabBackPack.isFull();

What happens if you lagged out, or no onions were actually on screen?


I didn't think of that, thank you.

You should probably put your login code insude your repeat loop so you can pass the 6h fix:


repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
LoginSteps();
ProgRep();
end;

WalkToPatch();

repeat // It's probably better to put the repeat..until inside the PickOnions() procedure with a timer
PickOnions();
until tabBackPack.isFull();

DepositOnions();
until numBanked >= numToPick;


So if I'm understanding you correctly, you're suggesting that I start a timer before PickOnions() is called, and use that as a failsafe for if tabBackPack.isFull() is never true?

Thanks again!

The Mayor

2014-08-18 08:09:10

From: Incurable
Thank you, and thank you for the idea! ;)



I actually did use that SRL procedure at first, but it would frequently fail to click it, believe that it had been clicked, and then try and run back to the patch with the bank screen still open. Changing it to a TBox actually solved that problem.



I didn't think of that, thank you.



So if I'm understanding you correctly, you're suggesting that I start a timer before PickOnions() is called, and use that as a failsafe for if tabBackPack.isFull() is never true?

Thanks again!


Exactly. Look at my tutorial to see how to use ttimemarkers.

bonsai

2014-08-18 08:15:02

From: Incurable
I actually did use that SRL procedure at first, but it would frequently fail to click it, believe that it had been clicked, and then try and run back to the patch with the bank screen still open. Changing it to a TBox actually solved that problem.


I was running asha's herb script yesterday and saw this, the srl function is probably having a problem.

Incurable

2014-08-18 09:24:09

From: bonsai
I was running asha's herb script yesterday and saw this, the srl function is probably having a problem.


Running the script just now and bankScreen.close() failed three times in a row, so I had to change that to a TBox too. I guess both of them are down at the moment?

Dr Clemsip

2014-08-21 00:46:20

took me a few mins to realise theres no find Npc procedure, did you remove it.
I added one and a few other things and the script is flawless. keep up the good work.:thumbsup:

Edit: Removed your email and password, lol

program OnionCollector;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

{ ******************** BEGIN USER SCRIPT SETUP ********************

Instructions:
1. Setup the script by changing the values below.
2. Make sure that DRAYNOR_BANK_MAP.png is correctly placed in
"C:\Simba\Includes\SPS\img\runescape_other" before running.
}

var
numToPick := 28; // Number of onions to pick?
numPicked: integer; // Ignore
numBanked: integer; // Ignore

procedure DeclarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'email'; // Log in username/e-mail
password := 'Pass'; // Password
isActive := true;
end
currentPlayer := 0;
end;

{ ******************** END USER SCRIPT SETUP ******************** }

// Steps to be completed at login
procedure LoginSteps();
begin
wait(randomRange(1000, 3000));
if not isLoggedIn() then
exit;

mainscreen.setZoom(true);
wait(randomRange(200, 500));
minimap.setAngle(MM_DIRECTION_NORTH);
wait(randomRange(200, 500));
mainScreen.setAngle(MS_ANGLE_HIGH);
wait(randomRange(200, 500));
exitTreasure();
wait(randomRange(1000, 3000));
end;

procedure ProgRep();
var
onionPh, profit, profitPh: integer;
x := 0;
y := 295;

begin
profit := numPicked * 5; // Onion price in gp
onionPh := round((numPicked * 3600) / (getTimeRunning() / 1000));
profitPh := round((numPicked * 63) * 3600 / (getTimeRunning() / 1000));

clearDebug();
writeLn('Inc''s Onion Collector');
writeLn('Onions/hr: ' + intToStr(onionPh));
writeLn('Profit/hr: ' + intToStr(profitPh));
writeLn('Total collected: ' + intToStr(numPicked) + '/' + intToStr(numToPick));
writeLn('Total profit: ' + intToStr(profit) + 'gp');
writeLn('Time running: ' + TimeRunning);
writeLn('============================================');

smartImage.clear();
smartImage.drawBox(intToBox(x, y, (x + 250), (y + 92)), true, 1);
smartImage.drawText('Inc''s Onion Collector', point(10, 300), upchars, true, clYellow);
smartImage.drawText('Onions/hr: ' + intToStr(onionPh), point(10, 315), upchars, true, clYellow);
smartImage.drawText('Profit/hr: ' + intToStr(profitPh), point(10, 345), upchars, true, clYellow);
smartImage.drawText('Total profit: ' + intToStr(profit) + 'gp', point(10, 360), upchars, true, clYellow);
smartImage.drawText('Total collected: ' + intToStr(numPicked) + '/' + intToStr(numToPick), point(10, 330), upchars, true, clYellow);
smartImage.drawText('Time running: ' + TimeRunning, point(10, 375), upchars, true, clYellow);
end;

// Pick a full inventory of onions
procedure PickOnions();
var
x, y, bpCountBeforeWait: integer;
begin
if not isLoggedIn() then
exit;

bpCountBeforeWait := tabBackpack.count();

if mainscreen.findObject(x, y, 5142619, 10, ['ick'], MOUSE_LEFT) then
begin
tabBackPack.waitForShift(5000);
if tabBackpack.count() > bpCountBeforeWait then
numPicked := numPicked + 1;
ProgRep();
wait(randomRange(200, 500));
end else
wait(randomRange(2000, 4000));
end;

// Walk to the bank from the onion patch
// Is this even needed???
procedure runToBank();
var
pathToDepositBox: TPointArray;

begin
if not isLoggedIn() then
exit;

pathToDepositBox := [Point(229, 226), Point(226, 225)];

if SPS.walkPath(pathToDepositBox) then
minimap.waitPlayerMoving()
else
writeLn('Failed to walk to deposit box');
end;

procedure findDepositBox();
var
x, y, i: integer;
begin
if not isLoggedIn() then
exit;

repeat
mainscreen.findObject(x, y, 11835540, 5, colorSetting(2, 0.21, 0.37), mainscreen.playerPoint, 30, 50, 50, ['eposit', 'box'], MOUSE_LEFT);
wait(randomRange(1000, 2000));
inc(i);
until depositBox.isOpen() or (i >= 15);
end;

// Deposits the onions at a bank NPC
procedure depositOnions();
var
bankTimer: TTimeMarker;

begin
if not isLoggedIn() then
exit;

if depositBox.isOpen() then
begin

bankTimer.start();

repeat
if (depositBox.count > 0) then
begin
depositBox.quickDeposit(QUICK_DEPOSITBOX_INVENTORY);
wait(gaussRangeInt(500, 750));
end;
until(depositBox.isEmpty()) or (not isLoggedIn()) or (bankTimer.getTime() > 10000);


end;

depositBox.close();

end;

// Walk to the onion patch from the bank
procedure WalkToPatch();
var
pathToPatch: TPointArray;
begin
if not isLoggedIn() then
exit;

pathToPatch := [Point(208, 207), Point(225, 188), Point(241, 216), Point(231, 236)];
if SPS.walkPath(pathToPatch) then
minimap.waitPlayerMoving()
else
writeLn('ERROR: Failed to walk to the onion patch');
end;

// main loop
begin
clearDebug();
smartEnableDrawing := true;
SmartShowConsole := false;
SetupSRL();
DeclarePlayers();
SPS.setup('DRAYNOR_BANK_MAP', RUNESCAPE_OTHER);
wait(1000);
if not isLoggedIn() then
begin
players[currentPlayer].login();
LoginSteps();
ProgRep();
end;

if isLoggedIn() and tabBackpack.isFull() then
begin
LoginSteps();
ProgRep();
depositOnions();
end else
ProgRep();
WalkToPatch();

repeat
repeat
PickOnions();
until tabBackPack.isFull();
runToBank();
findDepositBox();
depositOnions();
if numBanked < numToPick then
WalkToPatch();
until numBanked >= numToPick;

wait(randomRange(2000, 3000));
players[currentPlayer].logout();
smartImage.clear();
end.

Incurable

2014-08-21 01:26:06

From: Dr Clemsip
took me a few mins to realise theres no find Npc procedure, did you remove it.
I added one and a few other things and the script is flawless. keep up the good work.:thumbsup:

Edit: Removed your email and password, lol

-snip-


I never had a find NPC procedure? It's unnecessary. :p And I didn't have my e-mail and password in there either as far as I know. o.O Oh, lol… fixed, thanks. :D

Anyway, thanks for the code additions, I'll be considering them for the next version. :)

EDIT: Just did a bit of testing and your version is actually 130 onions/hr (give or take) slower than mine in addition to appearing less human. :p