SRL Archive - First Scripts

[BareBones] Varrock iron ore miner and banker


Kaladin

2014-01-24 02:14:08

~~~~~~~~~~~Varrock Iron Miner and Banker!~~~~~~~~~~~

Features
100% Colour
SPS Pathing
Fast mining method
Random antibans
Banking
Progress Report

Please test and enjoy, report bugs back to me and I'll try my best to fix them!

program VarrockMiner;
{$DEFINE SMART}
{$I SRL-6/SRL.Simba}
{$i sps/lib/sps-rs3.simba}

//INSTRUCTIONS -------------------------------------------------------------------------------\\
//Enter your nick, file and amount of ore here, start in V-east bank or by the mine. Enjoy :)
const
nick:= 'Ago';
file:= 'default';
desiredOre:= 224;
//--------------------------------------------------------------------------------------------\\
var
ToBank: tpointarray;
ToMine: tpointarray;
location: string;
foundore: boolean;
xpPh, xP, oreXP, orePh, oresMined, oresBanked, total, rTemp, inv, invTemp: integer; //Declaring multiple vars of same type on same line


// Procedure that sets up SRL, SPS, the player and relevant vars etc.
procedure setup;

begin

total:= 0;
smartEnableDrawing := true;
setupSRL;
Players.Setup([nick], file);
CurrentPlayer := 0;
ToBank := [Point(330, 414), Point(330, 416), Point(335, 402), Point(340, 397), Point(347, 396), Point(350, 393), Point(354, 393), Point(358, 388), Point(360, 388), Point(362, 384), Point(363, 379), Point(365, 374), Point(365, 367), Point(365, 362), Point(364, 353), Point(364, 349), Point(362, 344), Point(360, 336), Point(359, 334), Point(357, 325), Point(358, 316), Point(358, 309), Point(360, 303), Point(363, 296), Point(361, 289), Point(361, 283), Point(361, 277), Point(359, 273), Point(357, 265), Point(356, 257), Point(352, 252), Point(350, 245), Point(348, 239), Point(344, 233), Point(338, 225), Point(336, 218), Point(336, 211), Point(338, 198), Point(331, 177), Point(321, 163), Point(317, 157), Point(308, 155), Point(300, 153), Point(288, 153), Point(266, 155), Point(258, 155), Point(246, 157), Point(234, 158), Point(223, 156), Point(216, 155), Point(210, 155), Point(200, 157), Point(200, 164), Point(200, 169), Point(202, 176), Point(197, 182), Point(194, 187), Point(200, 189), Point(200, 193)];
ToMine := [Point(195, 192), Point(196, 187), Point(196, 180), Point(196, 176), Point(198, 168), Point(198, 161), Point(203, 157), Point(213, 153), Point(221, 154), Point(231, 156), Point(237, 158), Point(247, 158), Point(255, 158), Point(267, 156), Point(273, 156), Point(280, 156), Point(286, 158), Point(294, 158), Point(299, 158), Point(305, 158), Point(311, 159), Point(316, 160), Point(323, 162), Point(326, 172), Point(332, 179), Point(337, 185), Point(343, 191), Point(344, 198), Point(341, 203), Point(338, 216), Point(344, 222), Point(346, 229), Point(349, 236), Point(351, 236), Point(353, 242), Point(355, 247), Point(357, 252), Point(360, 265), Point(360, 269), Point(361, 275), Point(360, 286), Point(359, 289), Point(356, 300), Point(356, 303), Point(357, 316), Point(357, 319), Point(358, 329), Point(360, 336), Point(365, 340), Point(366, 344), Point(366, 352), Point(367, 358), Point(369, 365), Point(363, 372), Point(359, 374), Point(352, 383), Point(352, 384), Point(352, 386), Point(349, 396), Point(347, 401), Point(344, 408), Point(344, 411), Point(339, 413), Point(333, 413), Point(332, 413)];
sps.setup('VarMine', RUNESCAPE_SURFACE, 4, 600.0, 0.40);
wait(1000 + random(2000));
players[currentPlayer].login();
mainscreen.setAngle(MS_ANGLE_HIGH);
inv:= tabBackpack.count();
oreXP:= 27;
end;

// Procedure courtesy of Coh3n, checks for spinticket etc
procedure Find_Randoms();
var
p: TPoint;
begin
if (findSpinTicket(p)) then
begin
mouse(p, MOUSE_LEFT);
end;

// in case the Task Tab is accidentally opened
if (getColor(100, 358) = 1010650) then
gameTabs.openTab(TAB_TASK);
closeAdWindow();
end;


// Also derived from coh3ns script, an anti ban that randomly trigges each time an ore is mined
procedure minorRandomAntiBan;
begin
case Random(40) of
1: RandomRClickItem();
2: SleepAndMoveMouse(200 + Random(50));
3: ;
4: PickUpMouse;
5: ;
6: ;
7: RandomCompass(0, 90 + random(90), false);
9: ;
10: PickUpMouse;
11:;
12:;
13:MouseOffClient(Random(5));
14:;
15:MouseMovingObject();
end;
end;


// The mayor is responsible for this, searches for TPAs then moves to each one individually
function findOre: boolean;

var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
invTemp:= inv
if not isLoggedIn then
exit;
// color // tol //CTS, hue, sat from ACA
if findColorsSpiralTolerance(x, y, TPA, 2504288, mainScreen.getBounds(), 10, colorSetting(2, 0.08, 0.20)) then

if (Length(TPA) < 1) then // if no matching TPoints are found, exit
exit;

ATPA := TPA.toATPA(30, 30); // split our TPA into boxes of 30 x 30 pixels and put into an ATPA
ATPA.sortFromMidPoint(mainscreen.playerPoint); // sort the array from player, so closest TPA to player is first in array

for i := 0 to high(ATPA) do
begin // move move to each TPA one at a time, until we get a match
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Mine Iron ore rocks'], 200) then
begin
GetMousePos(x, y);
Mouse(point(x, y).rand(1), MOUSE_LEFT, MOUSE_HUMAN);
wait(200 + random(600));
if tabBackpack.waitForShift(6000) = true then // Waitfor inv to inc by 1
oresMined := oresMined + 1; // Increase the oresmined variable by 1
writeln(oresMined);
minorRandomAntiBan; // Call antiban
exit(true);
end;
end;
end;


// Credit to Ashaman script for the basis of this prog report
Procedure Progress;
begin
XP:= oresMined*oreXP;
xpPh:= Round(XP * (3600.0 / (GetTimeRunning / 1000.0)));
orePh:= Round((OresMined * (3600.0 / (GetTimeRunning / 1000.0))));
Writeln('~~~~~~~~~~~~ Varrock Iron Mine and Bank - Version 1 Public Release ~~~~~~~~~~~~') ;
Writeln('Time Running: ' + ToStr(TimeRunning));
Writeln('Ore Mined: ' + ToStr(oresMined));
Writeln('Ores Banked: ' + ToStr(oresBanked));
Writeln('Ores Per Hour: ' + ToStr(orePh));
Writeln('Experience Earned: ' + IntToStr(xP));
Writeln('Experience Per Hour: ' + ToStr(xpPh));
Writeln('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~');
end;

procedure bank;
var
bp: TPoint;
begin
if tabBackpack.isFull then
if (bankscreen.open(BANK_BOOTH)) then
begin
Progress;
bankscreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
oresBanked := oresBanked+28;
bankscreen.close;
end else
if tabBackpack.isFull then
begin
if (bankscreen.open(BANK_NPC_BLUE)) then
begin
bankscreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
oresBanked := oresBanked+28;
Progress;
bankscreen.close;
end else
minimap.findSymbol(bp, MM_SYMBOL_BANK, minimap.getBounds);
mouse(bp, MOUSE_LEFT, MOUSE_HUMAN);
end else
Exit;

end;

procedure mainLoop;
var
bs, ms : TPoint;
begin
if not isLoggedIn then
exit;
if minimap.findSymbol(bs, MM_SYMBOL_BANK, minimap.getBounds()) then
begin
mouse(bs, MOUSE_LEFT, MOUSE_HUMAN);
bank;
if not tabBackpack.isFull then
begin
sps.walkPath(ToMine);
Writeln('Walking to Mine');
end else
if tabBackpack.isFull then
bank;
sps.walkPath(toMine);
if (minimap.isPlayerMoving()) then
begin
writeln('Player is walking to mine!');
end else;
minimap.setAngle(MM_DIRECTION_NORTH);
sps.walkPath(ToMine);
end else
if minimap.findSymbol(ms, MM_SYMBOL_MINING, minimap.getBounds()) then
if tabBackpack.isFull then
begin
sps.walkPath(ToBank);
find_Randoms();
sps.walkPath(ToBank);//Second time incase random pops during pathwalk
end else
if not findOre then
RandomCompass(0, 90 + random(90), false);
if not findOre then
mouse(ms, MOUSE_LEFT, MOUSE_HUMAN);
end;

begin
setup;
repeat
find_Randoms();
mainLoop;
until oresMined = desiredOre;
Progress;
TerminateScript;
end.

On the way;
Failsafes
Functionality improvements
Different ore types
Different locations

Instructions
Download both files
place the .png (VarMine.png) in /Includes/SPS/img/runescape_Surface
Change how many ores you want mined, add in your nickname and playerfile and hit play!
Post progress report if it actually prints! :D

Much thanks to anyone who has answered my noob questions and muchmuch thanks to TheMayor for his TPA/ATPA tutorial and function :)

Update: Updated to include basic antibans and anti-randoms, directly plagiarized from the legendary coh3n, if this is a problem let me know but I thought it a good idea temporarily at least and due credit to him.
Should work well please test and let me know of any major bugs <3

Updated 13:24 GMT - Should bank and mine smoothly and not fail at it! As well as reasonable antibans, got some redundant code in there that I will sort out, want to get proggies and breaking working before I sleep but will see xD

Updated 17:16 GMT - Added progress reports and some fail safes after I encountered a few bugs, should work fairly well now.


Here is a proggy, It's not the best and I can see some obvious repetitive issues that I'll fix tomorrow :)

~~~~~~~~~~~~ Varrock Iron Mine and Bank - Version 1 Public Release ~~~~~~~~~~~~
Time Running: 30 Minutes and 22 Seconds
Ore Mined: 222
Ores Banked: 196
Ores Per Hour: 439
Experience Earned: 5994
Experience Per Hour: 11841
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

The Mayor

2014-01-24 04:46:19

Added a few comments below. You should add some code which waits until it has finished mining each rock. You could wait for the inventory count to change, then you know its mined the rock. There is a couple of ways to do this:

You could use tabBackPack.waitCount(count, time) to wait for the count to increase by one, or an easier way is just to use tabBackpack.waitForShift(time). This will wait for up to 10 seconds for the inventory count to change:


if findOre then
tabBackpack.waitForShift(10000);






program VarrockMiner;
{$DEFINE SMART}
{$I SRL-6/SRL.Simba}
{$i sps/lib/sps-rs3.simba}


var
bs, ms : TPoint;
ToBank, ToMine: tpointarray; // I put these on same line since same var type
location: string;
foundore: boolean;
total: integer;

function findOre: boolean;
var
x, y, i: integer;
TPA: TPointArray;
ATPA: T2DPointArray;

begin
if not isLoggedIn then
exit;

if findColorsSpiralTolerance(x, y, TPA, 2504288, mainScreen.getBounds(), 10, colorSetting(2, 0.08, 0.20)) then

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

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

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Mine Iron ore rocks'], 300) then
begin
GetMousePos(x, y);
Mouse(point(x, y), MOUSE_LEFT);
wait(500 + random(500));
foundore := true ; // no need for this because
exit(true); // the whole function is a boolean already and results true here
end;
end;
end;

procedure setup;
begin
total:= 0;
smartEnableDrawing := true;
setupSRL;
ToBank := [Point(330, 414), Point(330, 416), Point(335, 402), Point(340, 397), Point(347, 396), Point(350, 393), Point(354, 393), Point(358, 388), Point(360, 388), Point(362, 384), Point(363, 379), Point(365, 374), Point(365, 367), Point(365, 362), Point(364, 353), Point(364, 349), Point(362, 344), Point(360, 336), Point(359, 334), Point(357, 325), Point(358, 316), Point(358, 309), Point(360, 303), Point(363, 296), Point(361, 289), Point(361, 283), Point(361, 277), Point(359, 273), Point(357, 265), Point(356, 257), Point(352, 252), Point(350, 245), Point(348, 239), Point(344, 233), Point(338, 225), Point(336, 218), Point(336, 211), Point(338, 198), Point(331, 177), Point(321, 163), Point(317, 157), Point(308, 155), Point(300, 153), Point(288, 153), Point(266, 155), Point(258, 155), Point(246, 157), Point(234, 158), Point(223, 156), Point(216, 155), Point(210, 155), Point(200, 157), Point(200, 164), Point(200, 169), Point(202, 176), Point(197, 182), Point(194, 187), Point(200, 189), Point(200, 193)];
ToMine := [Point(195, 192), Point(196, 187), Point(196, 180), Point(196, 176), Point(198, 168), Point(198, 161), Point(203, 157), Point(213, 153), Point(221, 154), Point(231, 156), Point(237, 158), Point(247, 158), Point(255, 158), Point(267, 156), Point(273, 156), Point(280, 156), Point(286, 158), Point(294, 158), Point(299, 158), Point(305, 158), Point(311, 159), Point(316, 160), Point(323, 162), Point(326, 172), Point(332, 179), Point(337, 185), Point(343, 191), Point(344, 198), Point(341, 203), Point(338, 216), Point(344, 222), Point(346, 229), Point(349, 236), Point(351, 236), Point(353, 242), Point(355, 247), Point(357, 252), Point(360, 265), Point(360, 269), Point(361, 275), Point(360, 286), Point(359, 289), Point(356, 300), Point(356, 303), Point(357, 316), Point(357, 319), Point(358, 329), Point(360, 336), Point(365, 340), Point(366, 344), Point(366, 352), Point(367, 358), Point(369, 365), Point(363, 372), Point(359, 374), Point(352, 383), Point(352, 384), Point(352, 386), Point(349, 396), Point(347, 401), Point(344, 408), Point(344, 411), Point(339, 413), Point(333, 413), Point(332, 413)];
sps.setup('VarMine', RUNESCAPE_SURFACE, 4, 600.0, 0.40);
end;

procedure bank;
begin
if tabBackpack.isFull then
begin
bankscreen.open(BANK_BOOTH);
bankscreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
total := total + 28;
end else
Exit; // no need for the exit as its the end of the procedure anyway
end;

procedure mainLoop;
begin
if minimap.findSymbol(bs, MM_SYMBOL_BANK, minimap.getBounds()) then // since bs and ms are only used here, they could be
begin // local variables within this procedure
bank;
sps.walkPath(ToMine);
end else
if minimap.findSymbol(ms, MM_SYMBOL_MINING, minimap.getBounds()) then
if tabBackpack.isFull then
begin
sps.walkPath(ToBank);
end else
findOre;
end;

begin
setup;
repeat
mainLoop;
until total = 1000;
end.

E: Just realised I looked at the old version :( Oh well

Kaladin

2014-01-24 12:20:25

Updated this considerably, hoping to release it publically, would be nice to get some testing/feedback from others before I do (and so I can :D)

Thanks.