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]
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.