SRL Archive - First Scripts

Spaceblow's redberries gatherer (my first script)


Spaceblow

2014-08-14 21:29:59

EDIT: I released a better version of this script with more features: Spaceblow's Redberries Gatherer



Hello everyone, I'm really new to this kind of stuff. I made a simple script that gathers redberries at Varrock East and banks them. I did this so I could get a little bit of experience because this is my first scripting language that I've ever learned. I have no idea how I could put an antiban in the 'getRedberries()' procedure (look below), I tried it for hours but I just don't have any clue. Learning how to make an antiban will probably be for my next script or maybe for an update on this one, but I don't think so because I think I've had it with the redberries. :p

Sooner or later you'll probably going to experience a bug when running my script, it would be nice if you would let me know so I could learn from my mistakes. If you try it out, start in the bank of Varrock East, next to the bushes or on the way from the bank to the redberries. A huge thank you for @The Mayor. I would never have even learned to type 'writeLn()' without him. And of course a very big thank you for everyone who helped me and for the people who have made guides and tutorials!

It actually took me way too long to make this but this was because of a lot trial and error. I guess it isn't flawless but I just couldn't hold it anymore to start this thread. I included the map with this thread. Just place it in Simba\Includes\SPS\img\runescape_other. Delete the Direct-X line at the end of the script if you don't use that plugin. I hope experienced and unexperienced scripters will reply on this thread to tell me whether I did good or bad. :)

[ATTACH=CONFIG]23799[/ATTACH]

program Spaceblows_redberries_gatherer;

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

var
loadsDone: integer;

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'username'; // Enter your username
password := 'password'; // Enter your password
isActive := true;
isMember := false; // Set it to true if you're a member
end
currentPlayer := 0;
end;

// STUFF //
procedure runToBank();
var
pathToBank: TPointArray;

begin
if not isLoggedIn() then
exit;

if not tabBackpack.isFull() then
exit;

writeLn('--------------------------------------------------------------------------- Running to bank.');
wait(randomRange(500, 750));
pathToBank:= [Point(274, 294), Point(273, 280), Point(274, 264), Point(274, 247), Point(271, 230), Point(266, 216), Point(258, 199), Point(253, 185), Point(248, 169), Point(245, 153), Point(240, 137), Point(224, 133), Point(211, 133), Point(187, 131), Point(173, 132), Point(157, 132), Point(137, 130), Point(120, 136), Point(118, 151), Point(117, 169)];
if SPS.walkPath(pathToBank) then
minimap.waitPlayerMoving()
else
writeLn('--------------------------------------------------------------------------- We failed to walk to the bank.');
end;


procedure bankRedberries();
var
bankTimer: TTimeMarker;
pathFail: TPointArray;

begin
if not isLoggedIn() then
exit;

if not tabBackpack.isFull() then
exit;

minimap.setAngle(MM_DIRECTION_SOUTH);
mainScreen.setAngle(MS_ANGLE_HIGH);

bankScreen.open(BANK_NPC_BLUE);
_waitBankOrPinscreen(5000);
wait(randomRange(750, 1250));

if bankScreen.isOpen() then
begin
bankTimer.start();
writeLn('--------------------------------------------------------------------------- Succesfully opened the bank');
repeat
begin
wait(randomRange(600, 900));
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
wait(randomRange(600, 900));
bankScreen.close();
writeLn('--------------------------------------------------------------------------- Succesfully closed the bank.');
end;
until(tabBackpack.isEmpty()) or (not isLoggedIn()) or (bankTimer.getTime() > 7000);
if tabBackpack.isEmpty() then
begin
writeLn('--------------------------------------------------------------------------- Succesfully banked Redberries.');
inc(loadsDone);
wait(randomRange(750, 1250));
writeLn('--------------------------------------------------------------------------- Running to redberries.');
end;
end else
begin
writeLn('--------------------------------------------------------------------------- Could not open bank, trying to find it.');
wait(randomRange(750, 1000));

pathFail:= [Point(118, 133), Point(118, 169)]; //in case the player somehow didn't got in the bank, but outside of it
if SPS.walkPath(pathFail) then
minimap.waitPlayerMoving();

wait(randomRange(750, 1000));
bankRedberries();
end;

if tabBackpack.isEmpty() then
begin
exit;
end else
bankRedberries();
end;

procedure runToDoor();
var
pathToDoor, pathFurther: TPointArray;
goToBankTimer: TTimeMarker;
dummySymbol, clothesSymbol: TPoint;

begin
if not isLoggedIn() then
exit;

if tabBackpack.isFull() then
begin
goToBankTimer.start();
repeat
bankRedberries();
if (goToBankTimer.getTime() > 15000) then
WriteLn('--------------------------------------------------------------------------- Could not bank, terminating the script.');
terminateScript();
until (tabBackpack.isEmpty());
end;

if not minimap.findSymbol(dummySymbol, MM_SYMBOL_TRAINING_DUMMY, minimap.getBounds()) then
exit;

writeLn('--------------------------------------------------------------------------- Running to door.');

minimap.setAngle(MM_DIRECTION_NORTH);

pathToDoor:= [Point(117, 162), Point(118, 145), Point(120, 136), Point(137, 128), Point(157, 132), Point(180, 132), Point(192, 132), Point(208, 131)];
if SPS.walkPath(pathToDoor) then
minimap.waitPlayerMoving()
else
writeLn('--------------------------------------------------------------------------- We failed to walk to the redberries.');

if conversationBox.isOpen() then
repeat
wait(randomRange(350, 750));
conversationBox.continue(true, true);
wait(randomRange(350, 750));
conversationBox.selectOption(1);
wait(1000);
until not conversationBox.isOpen();

wait(randomRange(2000, 2250)); //in case the player somehow didn't go through the door (I experienced it)

if conversationBox.isOpen() then
repeat
wait(randomRange(350, 750));
conversationBox.continue(true, true);
wait(randomRange(350, 750));
conversationBox.selectOption(1);
wait(1000);
until not conversationBox.isOpen();
writeLn('--------------------------------------------------------------------------- We continued our journey.');

// after door //
pathFurther := [Point(217, 131), Point(233, 147), Point(254, 178), Point(257, 190)];
if SPS.walkPath(pathFurther) then
minimap.waitPlayerMoving();

if not minimap.findSymbol(clothesSymbol, MM_SYMBOL_SHOP_CLOTHES, minimap.getBounds()) then
begin
writeLn('--------------------------------------------------------------------------- Not at the right location, terminating script.');
terminateScript;
end;

end;


procedure runToRedberries();
var
pathToRedberries: TPointArray;
altarSymbol, treeSymbol: TPoint;

begin
if not isLoggedIn() then
exit;

writeLn('--------------------------------------------------------------------------- Running to redberries.');
wait(randomRange(500, 750));
pathToRedberries:= [Point(215, 132), Point(222, 135), Point(241, 143), Point(250, 156), Point(259, 167), Point(260, 181), Point(262, 198), Point(265, 212), Point(268, 229), Point(272, 244), Point(274, 259), Point(273, 275), Point(274, 292), Point(280, 314), Point(281, 325), Point(280, 339), Point(271, 350), Point(256, 360), Point(239, 362), Point(222, 361), Point(208, 361)];
if SPS.walkPath(pathToRedberries) then
minimap.waitPlayerMoving()
else
writeLn('--------------------------------------------------------------------------- We failed to run to the redberries.');

if (minimap.findSymbol(altarSymbol, MM_SYMBOL_ALTAR, minimap.getBounds()) and minimap.findSymbol(treeSymbol, MM_SYMBOL_TREE, minimap.getBounds())) then
begin
writeLn('--------------------------------------------------------------------------- We found the redberry bushes.');
end else
begin
writeLn('--------------------------------------------------------------------------- We somehow didn''t find the redberry bushes, maybe you''re at the wrong location, terminating script.');
terminateScript;
end;
end;


procedure getRedberries();
var
x, y, i: integer;
bushTPA: TPointArray;
berryTPA: TPointArray;
ATPA: T2DPointArray;
redberriesTimer: TTimeMarker;

begin
if not isLoggedIn() then
exit;

redberriesTimer.start();
minimap.setAngle(320);
mainScreen.setAngle(MS_ANGLE_HIGH);

repeat

findColorsSpiralTolerance(x, y, bushTPA, 1714858, mainScreen.getBounds(), 5, colorSetting(2, 0.11, 0.31));
ATPA:= bushTPA.toATPA(30, 30);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(ATPA);

for i:= 0 to high(ATPA) do
if findColorsSpiralTolerance(x, y, berryTPA, 1714858, ATPA[i].getBounds(), 5, colorSetting(2, 0.11, 0.31)) then
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Redberry bush'], 2000) then
begin
fastClick(MOUSE_LEFT);
tabBackpack.waitForShift(1500 + random(1000));
writeLn('--------------------------------------------------------------------------- Succesfully got some redberries');
wait(randomRange(1250, 1500)); //waiting to refresh smartImage
smartImage.clear;
break;
end;
end;

until tabBackpack.isFull() or (redberriesTimer.getTime() > 900000);
end;

procedure runToBorderGuard();
var
pathToBG: TPointArray;
questSymbol: TPoint;

begin
if not isLoggedIn() then
exit;

if not tabBackpack.isFull() then
exit;

if minimap.findSymbol(questSymbol, MM_SYMBOL_QUEST, minimap.getBounds()) then
exit;

writeLn('--------------------------------------------------------------------------- Running to border guard.');

minimap.setAngle(MM_DIRECTION_NORTH);
pathToBG:= [Point(222, 362), Point(234, 362), Point(247, 360), Point(260, 356), Point(273, 347), Point(281, 334), Point(280, 320), Point(278, 296)];
if SPS.walkPath(pathToBG) then
minimap.waitPlayerMoving()
else
writeLn('--------------------------------------------------------------------------- We failed to walk to the border guard.');

if conversationBox.isOpen() then
repeat
wait(randomRange(350, 750));
conversationBox.continue(true, true);
wait(randomRange(350, 750));
conversationBox.selectOption(1);
wait(1000);
until not conversationBox.isOpen();

wait(randomRange(2000, 2250)); //in case the player somehow didn't go through the door (I experienced it)

if conversationBox.isOpen() then
repeat
wait(randomRange(350, 750));
conversationBox.continue(true, true);
wait(randomRange(350, 750));
conversationBox.selectOption(1);
wait(1000);
until not conversationBox.isOpen();
writeLn('--------------------------------------------------------------------------- We continued our journey.');
end;

procedure progressReport();
var
redberriesGot, profit, profitPerHour: integer;

begin
redberriesGot:= loadsDone * 28;
profit:= (redberriesGot * 870);
profitPerHour:= round((profit * 60) / (getTimeRunning() / 60000));

writeLn('#################################################');
writeLn('######## Spaceblow''s redberries gatherer ########');
writeLn('#################################################');
writeLn('Time run: ' + timeRunning);
writeLn('Redberries gathered: ' + intToStr(redberriesGot));
writeLn('Loads done: ' + intToStr(loadsDone));
writeLn('Profit made: ' + intToStr(profit));
writeLn('Profit per hour: ' + intToStr(profitPerHour));
writeLn('#################################################');
end;


// MAIN LOOP //
begin
clearDebug();
smartShowConsole := false;
smartEnableDrawing := true;
smartPlugins := ['d3d9.dll']; // DIRECT-X PLUGIN, DELETE THIS IF YOU DON'T HAVE THE PLUGIN
setupSRL();
declarePlayers();

SPS.setup ('BERRY_MAP', RUNESCAPE_OTHER);

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

runToBorderGuard();
runToBank();
bankRedberries();
progressReport();
runToDoor();
runToRedberries();
getRedberries();
until(false);
end.

Sin

2014-08-14 22:50:15

Very well written for a first script. Keep it up man.

Spaceblow

2014-08-15 06:42:40

From: Sin
Very well written for a first script. Keep it up man.
Thank you very much! I will try to keep it up but I don't know if that's possible because I don't have very much time, we'll see what the future brings.

For the declarePlayers() procedure, I actually copied it from The Mayor's AIO guide, all the credits go to him.

Ashaman88

2014-08-15 09:42:07

From: Spaceblow
Thank you very much! I will try to keep it up but I don't know if that's possible because I don't have very much time, we'll see what the future brings.

For the declarePlayers() procedure, I actually copied it from The Mayor's AIO guide, all the credits go to him.


Well @The Mayor; copied it from me.. and I copied it from someone else, who copied it from someone else, etc etc. The true question is who was the first???

The Mayor

2014-08-15 18:07:36

From: Ashaman88
Well @The Mayor; copied it from me.. and I copied it from someone else, who copied it from someone else, etc etc. The true question is who was the first???


The earliest declare players I could find was 15 Feb 2006, which was a few days after SRL went public. Mems link

Dr Clemsip

2014-08-16 13:41:26

Great first script, look forward to seeing more. :P

Spaceblow

2014-08-16 16:26:57

From: Dr Clemsip
Great first script, look forward to seeing more. :P
Thank you for your reply, it was nice to meet you by the way. :p

I met him when I was working on my script, he was a random player who said it was noticable that I was botting and he recommended me to use Simba, what a small world haha. :D

twirap

2014-08-17 00:43:37

Doesn't work for me…Keeps saying waiting for RS to load but I have tried both OpenGL and DirectX…The other scripts are working for me..I have it setup properly too..

Spaceblow

2014-08-17 06:52:54

From: twirap
Doesn't work for me…Keeps saying waiting for RS to load but I have tried both OpenGL and DirectX…The other scripts are working for me..I have it setup properly too..
It's working fine for me. Maybe it's because of your graphics settings? If you're using the Direct-X plugin, don't forget to change your graphics settings too… I adjusted the script a little bit so update your .simba file if you want to try out my script again. Don't expect it to be flawless but most of the time it's working fine. I would really appreciate it if you tell me how the script is after you've tried it out.

twirap

2014-08-17 07:56:58

The settings for direct x are different? I thought the only change for Directx was changing the graphics from Opengl to directx..

Spaceblow

2014-08-17 08:55:50

From: twirap
The settings for direct x are different? I thought the only change for Directx was changing the graphics from Opengl to directx..
You do have the Direct-X plugin, right?

twirap

2014-08-17 15:46:19

Ah no. I was using the noral Directx on my settings in game.

Spaceblow

2014-08-17 15:56:14

From: twirap
Ah no. I was using the noral Directx on my settings in game.
You have to set your graphics settings to Direct-X and download the plugin. Just place the plugin in C:\Simba\Plugins and run the script. If you prefer not to use the plugin set your graphics settings to OpenGL and manually delete that line in the script and start it. It should run without problems, I don't see why it wouldn't.

As I already said, don't expect the script to run flawless as it's my first try for anything related to scripting. I'll probably re-release the script in the near future with antiban and those stuff, so keep an eye out on the RS3 scripts section.