Simba Code:
program TheMayorsVEBMiner;
{$DEFINE SMART}
{$I SRL-6/SRL.Simba}
{$I SPS/LIB/SPS-RS3.simba}
const
REVISION = '1';
(* .
.---. .-. .-..----. .-. .-. .--..-. .-..----. .----.|\.----.
{_ _}| {_} || {_ | `.' | / {} \\ \/ // {} \| {} }{ {__
| | | { } || {__ | |\ /| |/ /\ \} { \ /| .-. \.-._} }
`-' `-' `-'`----' `-' ` `-'`-' `-'`--' `----' `-' `-'`----'
.-. .-..----..----. .-. .-..-..-. .-..----..----.
| | | || {_ | {} } | `.' || || `| || {_ | {} }
\ \_/ /| {__ | {} } | |\ /| || || |\ || {__ | .-. \
`---' `----'`----' `-' ` `-'`-'`-' `-'`----'`-' `-'
Completed: 24th April 2014 for the LOLs
Updated:
*)
NICKNAME = ':spot::spot::spot:'; { Nickname of player entered into the Rafiki player manager }
PLAYER_FILE = 'default'; { The name of your player file that you made in Rafiki }
LOADS_TO_DO = 6000; { Stop after how namy loads }
MINE_TIMER = 5000; { Max time to wait for ore after clicking a rock.
You would want to increase this if using a
low level pickaxe (5000 = 5 seconds) }
PAINT_ON_SMART = True; { Paint status in chatbox? }
STATUS_COLOUR = 255; { What colour do you want the paint to be (you can choose with color picker) }
ENABLE_DEBUG = False; { Show debug output in debug box? }
(* -------------------------------------------------------------------------- *)
{* EASY UPDATE - Update colours yourself! *}
(* -------------------------------------------------------------------------- *)
{ If future RS updates change the colours, then you can easily update them
yourself by changing the values below. See my AIO tutorial if you don't know
how to pick colours using ACA. }
{ Iron Ore }
ROCK_COLOUR = 2242428;
ROCK_TOL = 8;
ROCK_HUE = 0.09;
ROCK_SAT = 0.33;
{ Bank booth in VEB }
BOOTH_COLOUR = 1394024;
BOOTH_TOL = 3;
BOOTH_HUE = 0.13;
BOOTH_SAT = 2.11;
{ Banker NPC in VEB (purple ones) }
BANKER_COLOUR = 5517369;
BANKER_TOL = 12;
BANKER_HUE = 0.20;
BANKER_SAT = 0.48;
(* -------------------------------------------------------------------------- *)
{* DON'T TOUCH ANYTHING BELOW *}
(* -------------------------------------------------------------------------- *)
{ Global Variables }
var
PathToBank, PathToMine: TPointArray;
LoadsDone, OresMined, BankSymbol, MineSymbol, IronOrePrice: integer;
procedure findRandoms();
begin
exitTreasure();
claimTicket();
end;
procedure paintStatus(status: string);
begin
if PAINT_ON_SMART then
begin
smartImage.clear();
smartImage.drawText('Status: ' + status, point(chatbox.X2-320,chatbox.Y2-19), SmallChars, false, STATUS_COLOUR);
end;
end;
function getGEPrice(itemString: string): integer;
var
wikiaPage, priceString: string;
begin
wikiaPage := getPage('http://runescape.wikia.com/wiki/Exchange:' + itemString);
priceString := between('GEPrice">', '</span>', wikiaPage);
result := strToIntDef(priceString, -1);
writeLn('-- ' + itemString + ' price: '+ toStr(result) + ' gp');
end;
procedure checkForImages(path, link, item: string);
var
progFile: longInt;
picName: string;
begin
picName := AppPath + path;
try
if not fileExists(picName) then
begin
writeLn('NOTIFICATION: ' + item + ' does not exist - Downloading it now!');
progFile := createFile(picName);
end else
begin
writeLn('NOTIFICATION: ' + item + ' already exists!');
exit;
end;
closeFile(progFile);
progFile := rewriteFile(picName, false);
writeFileString(progFile, getPage(link));
writeLn('NOTIFICATION: ' + item + ' has been download to Simba folder!');
writeLn('');
finally
if (progFile > 0) then
closeFile(progFile);
end;
end;
function antiBan(): boolean;
var
i: integer;
begin
i := random(1500);
if i < 66 then
begin
paintStatus('Engaging in antiban');
case i of
1..4: boredHuman(false);
5..10: begin
hoverSkill(SKILL_MINING);
wait(gaussRangeInt(1500,5000));
end;
11..13: mouseMovingObject();
14..25: sleepAndMoveMouse(randomRange(100,6000));
26..40: begin
mouseOffClient(Random(4));
wait(randomRange(2000, 15000));
end;
41..50: wait(RandomRange(1000, 2000));
51..60: randomCameraAngle(MS_ANGLE_HIGH);
61..65: pickUpMouse();
end;
end;
end;
procedure progressReport();
var
xpGained, xpPerHour, oresPerHour, profit, profitPerHour, PAD: integer;
begin
xpGained := OresMined * 27;
xpPerHour := round(xpGained * (3600.0 / (GetTimeRunning / 1000.0)));
oresPerHour := round(OresMined * (3600.0 / (GetTimeRunning / 1000.0)));
profit := OresMined * IronOrePrice;
profitPerHour := round(profit * (3600.0 / (GetTimeRunning / 1000.0)));
PAD := 39;
clearDebug();
writeLn('||-------------------------------------||');
writeLn(padR('|| The Mayor''s VEB Miner (Rev. ' + REVISION + ')', PAD) + '||') ;
writeLn(padR('||', PAD) + '||');
writeLn(padR('|| Time Running: ' + msToTime(getTimeRunning(), TIME_SHORT), PAD) + '||') ;
writeLn(padR('|| Ores Mined: ' + toStr(oresMined) + ' (' + toStr(oresPerHour) + ' PH)', PAD) + '||');
writeLn(padR('|| Loads Done: ' + toStr(loadsDone) + ' of ' + toStr(LOADS_TO_DO), PAD) + '||');
writeLn(padR('|| Experience Earned: ' + toStr(xpGained) + ' (' + toStr(xpPerHour) + ' PH)', PAD) + '||');
writeLn(padR('|| Profit Made: ' + toStr(profit) + ' (' + toStr(profitPerHour) + ' PH)', PAD) + '||');
writeLn('||-------------------------------------||');
end;
procedure endScript(reason: string);
begin
wait(randomRange(4000, 3000));
players[currentPlayer].exitToLobby();
progressReport();
writeLn('Terminated because: ' + reason);
writeln('Thank you for using Varrock Bank and Miner, all credits to the SRL community');
freeDTM(MineSymbol);
freeDTM(BankSymbol);
terminateScript();
end;
function mayorObjectFinder(excludeSmall: boolean; hue, sat: extended; W, H, colour, tolerance, clickType: Integer; mouseOverText, chooseOptions: array of string): boolean;
var
i, x, y: integer;
p: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if not isLoggedIn() then
exit;
findColorsSpiralTolerance(x, y, TPA, colour, mainScreen.getBounds(), tolerance, colorSetting(2, hue, sat));
if (Length(TPA) < 1) then exit;
ATPA := TPA.toATPA(W, H);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
if PAINT_ON_SMART then
smartImage.debugATPA(ATPA);
for i := 0 to high(ATPA) do
begin
if excludeSmall then
if length(ATPA[i]) < W then
continue;
mouse(MiddleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(mouseOverText, 500) then
begin
fastClick(ClickType);
if clickType = MOUSE_LEFT then
begin
if PAINT_ON_SMART then
smartImage.clearArea(mainscreen.getBounds());
exit(true);
end;
if chooseOption.select(chooseOptions) then
begin
if PAINT_ON_SMART then
smartImage.clearArea(mainscreen.getBounds());
exit(true);
end else
begin
gaussBox(p, mainscreen.getBounds());
mouse(p, MOUSE_MOVE);
end;
end;
end;
end;
function findBankerNPCDots(var bank: TPoint): boolean;
var
i: integer;
B, gB: TPointArray;
aTPA: T2DPointArray;
begin
result := false;
B := minimap.getDots(MM_DOT_NPC, minimap.getBounds());
aTPA := splitTPA(B, 10);
sortATPASize(aTPA, true);
if length(aTPA) = 0 then
exit;
B := aTPA[0];
for i := 0 to high(B) - 1 do
begin
if (Abs(B[i].Y - B[i + 1].Y) < 15) and (Abs(B[i].X - B[i + 1].X) < 60) then
begin
setLength(gB, length(gB) + 1);
gB[high(gB)] := B[i];
if high(gB) > 3 then
begin
bank := middleTPA(gB);
bank.Y := bank.Y - 5;
exit(true);
end;
end else
setLength(gB, 0);
end;
end;
procedure walkToBank();
var
p: TPoint;
walkTimer: TTimeMarker;
x, y: integer;
begin
walkTimer.start();
paintStatus('Walking to Varrock East Bank');
repeat
if not isLoggedIn() then
exit;
minimap.setAngle(MM_DIRECTION_NORTH);
SPS.walkPath(PathToBank);
if findBankerNPCDots(p) then
begin
mouse(p, MOUSE_LEFT);
exit;
end;
if findDTM(BankSymbol, x, y, minimap.getBounds()) then
begin
mouse(x , y, 5, 5, MOUSE_LEFT);
exit;
end;
until walkTimer.getTime() > 120000;
endScript('failed to walk to the bank within 2 minutes');
end;
procedure openBank();
var
bankTimer: TTimeMarker;
p: TPoint;
angle: extended;
begin
bankTimer.start();
paintStatus('Opening Varrock East Bank');
repeat
if (not isLoggedIn) or bankScreen.isOpen() or pinScreen.isOpen() then
exit;
minimap.waitFlag(5);
minimap.waitPlayerMoving(350);
if mayorObjectFinder(true, BOOTH_HUE, BOOTH_SAT, 45, 33, BOOTH_COLOUR, BOOTH_TOL, MOUSE_LEFT, ['ooth', 'ank boo'], ['ank Bank']) then
if (bankScreen.isOpen(5000)) or (pinScreen.isOpen(5000)) then
exit;
if mayorObjectFinder(true, BANKER_HUE, BANKER_SAT, 20, 20, BANKER_COLOUR, BANKER_TOL, MOUSE_RIGHT, ['anker', 'ank Ban'], ['ank Bank']) then
if bankScreen.isOpen(5000) or pinScreen.isOpen(5000) then
exit;
if findBankerNPCDots(p) then
mouse(p, MOUSE_LEFT)
else
minimap.setAngle(randomRange(35, 50));
until (bankTimer.getTime() > 120000) or (not isLoggedIn());
endScript('we failed to open the bank within 2 minutes');
end;
procedure depositOre();
var
bankTimer: TTimeMarker;
begin
if bankScreen.isOpen(3000) or pinScreen.isOpen(3000) then
begin
paintStatus('Depositing Iron Ore');
if pinScreen.isOpen() then
pinScreen.enter(Players[currentPlayer].bankPin);
bankTimer.start();
repeat
if (bankscreen.getPackCount() > 0) then
begin
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
wait(gaussRangeInt(1100, 1750));
end;
if bankscreen.getPackCount() = 0 then
begin
bankscreen.close();
wait(gaussRangeInt(1100, 1750));
inc(LoadsDone);
exit;
end;
until (bankTImer.getTime() > 45000);
endScript('something went wrong when depositing ore');
end;
end;
procedure walkToMine();
var
p: TPoint;
walkTimer: TTimeMarker;
x, y: integer;
begin
walkTimer.start();
paintStatus('Walking to Varrock East Mine');
repeat
if not isLoggedIn() then
exit;
minimap.setAngle(MM_DIRECTION_NORTH);
SPS.walkPath(PathToMine);
if findDTM(MineSymbol, x, y, minimap.getBounds()) then
begin
mouse(x , y, 5, 5, MOUSE_LEFT);
wait(randomRange(1000, 1500));
exit;
end;
exit; //as DTM is buggy
until walkTimer.getTime() > 120000;
endScript('failed to walk to the mine within 2 minutes');
end;
procedure mineRocks();
var
mineTimer: TTimeMarker;
begin
mineTimer.start();
mainscreen.setAngle(MS_ANGLE_HIGH);
repeat
paintStatus('Mining Iron Ore');
if mayorObjectFinder(false, ROCK_HUE, ROCK_SAT, 15, 15, ROCK_COLOUR, ROCK_TOL, MOUSE_LEFT, ['ron ore roc'], ['']) then
if tabBackpack.waitForShift(MINE_TIMER) then
inc(OresMined);
findRandoms();
antiBan();
if random(14) = 5 then
randomCompass(10, 300, false);
until tabBackpack.isFull() or (mineTimer.getTime() > 300000);
end;
procedure mainLoop();
begin
if not isLoggedIn() then
exit;
findRandoms();
if tabBackpack.count >= 28 then
begin
walkToBank();
openBank();
depositOre();
end else
begin
walkToMine();
mineRocks();
end;
progressReport();
end;
procedure setup();
begin
clearDebug();
smartEnableDrawing := true;
disableSRLDebug := not ENABLE_DEBUG;
setupSRL();
players.Setup([NICKNAME], PLAYER_FILE);
currentPlayer := 0;
checkForImages('Includes/SPS/img/runescape_other/VEB_01.png', 'http://i.imgur.com/8cEO9N3.png', 'SPS map');
PathToBank := [Point(317, 346), Point(338, 312), Point(339, 278), Point(337, 222), Point(330, 180), Point(310, 136), Point(286, 100), Point(234, 99), Point(188, 99), Point(176, 111)];
PathToMine := [Point(177, 131), Point(176, 100), Point(221, 101), Point(269, 99), Point(310, 124), Point(318, 170), Point(338, 222), Point(340, 266), Point(347, 299), Point(329, 325), Point(311, 344)];
sps.setup('VEB_01', RUNESCAPE_OTHER);
BankSymbol := DTMFromString('mbQAAAHicY2VgYJBkZmCQgGJBIFYE4n1A8cNAvAuIDwDxfiD+eL6EodRJiuHCgiSGiavvMiza85pBBCiOjhmxYDAAAGPyDew=');
MineSymbol := DTMFromString('mWAAAAHicY2FgYNjOxMCwE4h3APFeIE4AikUDcQoQxwHx21OiDD/vcDCYmpgwvL0kxCAHFINhEGBEwyAAAGSsCuQ=');
IronOrePrice := getGEPrice('Iron_ore');
progressReport();
end;
begin
setup;
repeat
if not isLoggedIn() then
begin
players[currentPlayer].login();
mainscreen.setAngle(MS_ANGLE_HIGH);
findRandoms();
end;
mainLoop();
until LoadsDone >= LOADS_TO_DO;
endScript('your player has finished your desired loads');
end.