Simba Code:
program theIrony; (*
\/============================================================================\/
|| ||
|| [T]he [H]ighly [E]nduring [I]ron [R]ock [O]bliterator [N]ear [Y]anille ||
|| ||
|| Description: ||
|| Mines the iron ore just north of the Yanille bank. ||
|| ||
|| Setup: ||
|| Start with empty inv in either Yanille bank or at Yanille mine, make ||
|| sure to have whatever pickaxe you want to use in toolbelt since it uses ||
|| that one. ||
|| Click play and fill out player form(you must use the Player Manager) ||
|| ||
|| If you want to power mine instead of bank, make sure to put iron ore ||
|| in first slot of action bar, otherwise it will just bank anyway. ||
|| Use in DirectX mode!! ||
|| ||
|| Features: ||
|| -banking ||
|| -dropping ||
|| -banks gems if dropping ores ||
|| -can either mine the spot with 3 rocks next to each other ||
|| or spot with 4 rocks next to each other ||
|| +breaking ||
|| +multiplayer ||
|| +antiban ||
|| +SMART proggy ||
|| +log file ||
|| ||
|| Known bugs: ||
|| *Sometimes finds depleted rocks as rocks with iron ||
|| *Ore finding in general is a bit rough ||
|| *banking function is rough, but seems to always find bank eventually ||
|| ||
|| ||
|| Credits: ||
|| All the awesome people who wrote tuts on the SRL forums. ||
|| I used pretty much all of them ;) ||
|| ||
|| Me(HKbotz)!! ||
|| ||
|| ||
|| +not yet implemented ||
|| -complete ||
|| ||
/\============================================================================/\
*)
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$i SPS/lib/SPS-RS3.simba}
{$i srl-6/lib/misc/srlplayerform.simba}
const (*
\/============================================================================\/
|| ||
|| ADVANCED SETUP ||
|| (Don't mess with this unless you know what you're doing) ||
|| ||
/\============================================================================/\
*)
//text to use when finding iron rocks and bank booth
IRON_ROCK_TEXT = ['Iron ore', 'ron ore', 'Iron', 'ron'];
BANK_BOOTH_TEXT = ['Bank booth', 'ank booth', 'Bank', 'ank', 'Booth'];
//defaults used when running script for first time, if you change these make
//sure to leave ALL of them in single quotes!!
RUNS = '20'; //runs to do
MINE_ROCK_WAIT = '7000'; //max time to wait to mine a rock
FIND_ROCK_WAIT = '10000'; //max time to wait to find a valid rock
BANK_WAIT = '10000'; //max time to wait to find the bank
DROP_WAIT = '10000'; //max time to wait to drop all ores
BANK_TRIES = '5'; //# of times to try and find bank
MINE_ROCK_TRIES = '5'; //# of times to try to mine a rock
MAX_DIST = '115'; //max distance to look for rocks from player
GEM_COUNT = '14'; //# of gems to get before banking if dropping ore
SHOULD_BANK = 'true'; //should we bank or drop, false means drop
LOCATION = '3 rocks'; //loc to use to mine rocks(3 rocks or 4 rocks)
SRL_DEBUG = 'false'; //Enable the SRL debug
SMART_DEBUG = 'true'; //Enable SMART debug
EXIT_SOF = 'true'; //exit treasure hunter spam if in corner
PAINT_PROGGY = 'true';
(*
\/============================================================================\/
|| ||
|| END SETUP ||
|| ||
/\============================================================================/\
*)
//----------------------------------------------------------------------------\\
// \\
// Everything below here should be left alone unless you really \\
// know what you're doing \\
// \\
//----------------------------------------------------------------------------\\
const
LOG_OFF = -1;
LOG_FATAL = 0;
LOG_ERROR = 1;
LOG_WARNING = 2;
LOG_HINT = 3;
LOG_DEBUG = 4;
VERSION = '1.2';
type
alignType = (left, right, center);
var
Loads, OreCount, GemCount: integer = 0;
LogLvl: integer = 4;
AtMine: boolean;
OreDTM: integer;
//formats string so I can make pretty proggy
function fstring(str: string; len: integer; align: alignType = left; fill: char = ' '): string;
var
i, c, n, strLen: integer;
begin
setLength(result, len);
strLen := length(str);
if (align = left) then
begin
for (i := 1) to (len) do
begin
if (i <= strLen) then
result[i] := str[i]
else
result[i] := fill;
end;
end else if (align = right) then
begin
n := len - strLen;
c := 1;
for (i := 1) to (len) do
begin
if (i <= n) then
result[i] := fill
else
begin
result[i] := str[c];
inc(c);
end;
end;
end else if (align = center) then
begin
n := round((len - strLen) / 2);
c := 1;
for (i := 1) to (len) do
begin
if (i <= n) then
result[i] := fill
else if (c <= strLen) then
begin
result[i] := str[c];
inc(c);
end else
result[i] := fill;
end;
end else
begin
writeln('Passed incorrect align param. Use right, left, or center.');
writeln('Returning your original string...');
setLength(result, strLen);
result := str;
end;
end;
//personal debug function
procedure log(text: string; lvl: integer = LOG_DEBUG);
begin
if ((LogLvl < LOG_OFF) or (LogLvl > LOG_DEBUG)) then
begin
writeln('!!! Improper log settings, changing to lvl 4!!!');
LogLvl := LOG_DEBUG;
end;
case (lvl) of
LOG_OFF:
exit;
LOG_FATAL:
writeln('FATAL: ' + text);
LOG_ERROR:
if (not (LogLvl < lvl)) then
writeln('ERROR: ' + text);
LOG_WARNING:
if (not (LogLvl < lvl)) then
writeln('WARNING: ' + text);
LOG_HINT:
if (not (LogLvl < lvl)) then
writeln('HINT: ' + text);
LOG_DEBUG:
if (not (LogLvl < lvl)) then
writeln('DEBUG: ' + text);
else
writeln('Didn''t enter proper log lvl, no info for you.');
end;
end;
//log player into lobby
procedure login();
begin
if (not isLoggedIn()) then
players[currentPlayer].loginToLobby();
end;
//overload for mouseBox, will click a different point in box if mouse is already in box.
procedure mouseBox(b: TBox; button: integer = MOUSE_MOVE; moveIfInBox: boolean); overload;
var
p: TPoint;
x, y: integer;
begin
if (not moveIfInBox) then
begin
mouseBox(b, button);
exit();
end;
gaussBox(p, b);
mouse(p, button);
end;
//free dtms, bmps, log time script ran, etc.
procedure cleanup();
begin
freeDTMs([oreDTM]);
log('Loads: ' + intToStr(Loads));
log('Time running: ' + timeRunning(TIME_SHORT));
end;
//abort script
procedure abort(reason: string);
begin
log(reason, LOG_FATAL);
cleanup();
terminateScript();
end;
//checks to see if player is logged into game
procedure checkIfIngame();
begin
if (lobby.isOpen()) then
abort('Player is in lobby.')
else if (not isLoggedIn()) then
abort('Player logged out');
end;
//setup the player form
procedure initPlayerForm();
begin
with playerForm do
begin
name := 'T.H.E. I.R.O.N.Y. v' + VERSION;
scriptHelpThread := '';
scriptSettingsPath := '';
editBoxLabels := ['Runs:', 'Max distance:', 'Bank tries:', 'Mine rock tries:',
'Bank wait:', 'Mine rock wait:', 'Drop wait:', 'Find rock wait:', 'Gem Count:'];
editBoxDefaults := [RUNS, MAX_DIST, BANK_TRIES, MINE_ROCK_TRIES,
BANK_WAIT, MINE_ROCK_WAIT, DROP_WAIT, FIND_ROCK_WAIT, GEM_COUNT];
editBoxHints := ['Runs to do', 'Max distance to look for rocks',
'Number of tries to bank', 'Number of tries to mine rock',
'Amount of time to wait to bank(in ms)', 'Amount of time' +
' to wait to mine a rock', 'Amount of time to wait to ' +
'drop ore', 'Amount of time to wait to find rocks',
'Number of gems to get before banking'];
checkBoxLabels := ['Bank', 'Exit SOF', 'SRL debug', 'SMART debug',
'Paint Proggy'];
checkBoxDefaults := [SHOULD_BANK, EXIT_SOF, SRL_DEBUG, SMART_DEBUG,
PAINT_PROGGY];
checkBoxHints := ['Should we bank? If not we drop', 'Exit SOF(treasure ' +
'hunter) when script starts?', 'Enable SRL debug?',
'Enable SMART debug?', 'Enable Paint Proggy?'];
comboBoxLabels := ['Rocks to use:'];
comboBoxDefaults := [LOCATION];
comboBoxHints := ['Use the spot with 3 rocks or spot with 4 rocks (don''t' +
' set max distance past 115 if using 3 rock spot or it' +
'detects 4 rock spot rocks too)'];
setLength(comboBoxItems, length(comboBoxLabels));
comboBoxItems[0] := ['3 rocks', '4 rocks'];
end;
end;
//declare our players
procedure declarePlayers(); overload;
var
i: integer;
begin
players.setup(playerForm.players);
currentPlayer := 0;
for (i := 0) to (high(players)) do
with players[i] do
begin
integers[0] := strToInt(playerForm.players[i].settings[0]); //RUNS
integers[1] := strToInt(playerForm.players[i].settings[1]); //MAX_DIST
integers[2] := strToInt(playerForm.players[i].settings[2]); //BANK_TRIES
integers[3] := strToInt(playerForm.players[i].settings[3]); //MINE_ROCK_TRIES
integers[4] := strToInt(playerForm.players[i].settings[4]); //BANK_WAIT
integers[5] := strToInt(playerForm.players[i].settings[5]); //MINE_ROCK_WAIT
integers[6] := strToInt(playerForm.players[i].settings[6]); //DROP_WAIT
integers[7] := strToInt(playerForm.players[i].settings[7]); //FIND_ROCK_WAIT
integers[8] := strToInt(playerForm.players[i].settings[8]); //GEM_COUNT
booleans[0] := strToBool(playerForm.players[i].settings[9]); //SHOULD_BANK
booleans[1] := strToBool(playerForm.players[i].settings[10]); //EXIT_SOF
booleans[2] := strToBool(playerForm.players[i].settings[11]); //SRL_DEBUG
booleans[3] := strToBool(playerForm.players[i].settings[12]); //SMART_DEBUG
booleans[4] := strToBool(playerForm.players[i].settings[13]); //PAINT_PROGGY
strings[0] := playerForm.players[i].settings[14]; //LOCATION
end;
end;
//debug the player form settings, only used for testing
procedure debugSPFSettings();
var
i: integer;
begin
writeln('');
for (i := 0) to (high(players)) do
begin
writeln('Runs: ', players[i].integers[0]);
writeln('Max distance: ', players[i].integers[1]);
writeln('Bank tries: ', players[i].integers[2]);
writeln('Mine rock tries: ', players[i].integers[3]);
writeln('Bank wait: ', players[i].integers[4]);
writeln('Mine rock wait: ', players[i].integers[5]);
writeln('Drop wait: ', players[i].integers[6]);
writeln('Find rock wait: ', players[i].integers[7]);
writeln('Gem count: ', players[i].integers[8]);
writeln('Bank: ', players[i].booleans[0]);
writeln('Exit squeal: ', players[i].booleans[1]);
writeln('SRL debug: ', players[i].booleans[2]);
writeln('SMART debug: ', players[i].booleans[3]);
writeln('rock location: ', players[i].strings[0]);
writeln('');
end;
end;
procedure proggy();
begin
writeln('\/' + fstring('', 50, , '=') + '\/');
writeln('||' + fstring('', 50) + '||');
writeln('||' + fstring('T.H.E. I.R.O.N.Y. v' + VERSION, 50, center) + '||');
writeln('||' + fstring('', 50) + '||');
writeln('||' + fstring(' Loads done: ' + intToStr(Loads), 50) + '||');
writeln('||' + fstring(' Ores collected: ' + intToStr(OreCount), 50) + '||');
writeln('||' + fstring(' Gems collected: ' + intToStr(GemCount), 50) + '||');
writeln('||' + fstring(' Time running: ' + timeRunning(TIME_SHORT), 50) + '||');
writeln('||' + fstring('', 50) + '||');
writeln('/\' + fstring('', 50, , '=') + '/\');
end;
//runs us to mine depending on location we want
function runToMine(): boolean;
var
minePath: TPointArray;
begin
result := false;
checkIfInGame();
//use proper path depending on which location you want to mine at
if (players[currentPlayer].strings[0] = '4 rocks') then
begin
log('Using path to 4 rocks.');
minePath := [Point(215, 387), Point(231, 335), Point(255, 278), Point(270, 238), Point(269, 189), Point(270, 149)];
end else
begin
log('Using path to 3 rocks.');
minePath := [Point(213, 388), Point(220, 346), Point(245, 307), Point(254, 265), Point(259, 222), Point(275, 191)];
end;
if (SPS.walkPath(minePath)) then
begin
log('Walked mine path.');
minimap.waitPlayerMoving();
AtMine := true;
exit(true);
end;
log('Didn''t walk path to mine.', LOG_ERROR);
end;
//run to the bank
function runToBank(): boolean;
var
bankPath: TPointArray;
begin
result := false;
checkIfInGame();
bankPath := [Point(276, 192), Point(264, 246), Point(243, 306), Point(216, 344), Point(212, 388)];
if (SPS.walkPath(bankPath)) then
begin
log('Walked bank path.');
minimap.waitPlayerMoving();
AtMine := false;
exit(true);
end;
log('Didn''t walk path to bank.', LOG_ERROR);
end;
//checks to see if we got ore
function didGetOre(): boolean;
var
p: TPoint;
begin
result := false;
if (findDTM(OreDTM, p.x, p.y, tabBackpack.getSlotBox(tabBackpack.count()))) then
begin
log('We got some iron ore.');
exit(true);
end;
log('We didn''t get any iron ore yet.');
end;
//finds all iron rocks on screen and returns the ATPA of them
function findRocks(var theATPA: T2DPointArray): boolean;
var
i, c: integer;
p: TPoint;
rockTPA, ironTPA: TPointArray;
tmpATPA, ATPA: T2DPointArray;
begin
result := false;
checkIfInGame();
//main color of rocks
if (not findColorsTolerance(rockTPA, 4683658, mainscreen.getBounds(), 10, colorSetting(2, 0.03, 0.13))) then
begin
log('Couldn''t find any colors for rocks.', LOG_ERROR);
exit(false);
end;
tmpATPA := rockTPA.toATPA(20, 20);
tmpATPA.filterBetween(0, 20);
tmpATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(tmpATPA);
c := 0;
for (i := 0) to (high(tmpATPA)) do
begin
//the brown part specific to iron rocks
if (findColorTolerance(p.x, p.y, 2306391, tmpATPA[i].getBounds(), 8, colorSetting(2, 0.07, 0.22))) then
begin
setLength(ATPA, c + 1);
ATPA[c] := tmpATPA[i];
inc(c);
end;
end;
smartImage.clear();
smartImage.debugATPA(ATPA);
theATPA := ATPA;
if (length(atpa) >= 1) then
exit(true);
end;
//mines iron if player isn't too far away from the rock
function mineRocks(rockTries, findRockWait: integer): boolean;
var
i, c, tries, dist: integer;
rocksATPA: T2DPointArray;
p1, p2: TPoint;
timer: TTimeMarker;
begin
result := false;
checkIfInGame();
while (not tabBackpack.isFull()) do
begin
checkIfInGame();
c := tabBackpack.count();
if (findRocks(rocksATPA)) then
begin
if (timer.__prevMark = 0) then //start the timer if it hasn't been started
timer.start();
log('rocks: ' + intToStr(length(rocksATPA)));
for (i := 0) to (high(rocksATPA)) do
begin
p1 := mainscreen.playerPoint;
p2 := rocksATPA[i].getMiddle();
dist := round(sqrt(pow((p2.x - p1.x), 2) + pow((p2.y - p1.y), 2))); //determine distance from player
if (dist > players[currentPlayer].integers[1]) then //if too far away, ignore it
begin
log('Rocks too far away to be ours.', LOG_HINT);
log('Rock: ' + intToStr(i) + ' Distance: ' + intToStr(dist));
if (timer.getTime() >= findRockWait) then
begin
log('Timed out trying to find rock.', LOG_ERROR);
log('find rock time: ' + intToStr(timer.getTime()));
exit(false);
end;
break;
end;
log('Rock: ' + intToStr(i) + ' Distance: ' + intToStr(dist));
mouseBox(rocksATPA[i].getBounds(), MOUSE_MOVE, true);
if (isMouseOverText(IRON_ROCK_TEXT)) then
begin
log('Clicking rock.');
if (not didClick(true, 500)) then
begin
log('Shit we miss clicked.');
minimap.waitPlayerMoving();
break;
end;
minimap.waitPlayerMoving();
//tabBackpack.waitForShift(players[currentPlayer].integers[5]);
//wait(250);
repeat
log('Waiting for player to finish animating...');
if (tabBackpack.count() > c) then
if (not didGetOre()) then
begin
log('Yay we got a gem!');
GemCount := GemCount + (tabBackpack.count() - c);
c := tabBackpack.count();
end;
until (not mainscreen.isPlayerAnimating(150));
if (tabBackpack.count() > c) then
if (didGetOre()) then
inc(OreCount);
timer.reset();
break;
end;
end;
end else
begin
log('Didn''t find any rocks :/', LOG_WARNING);
inc(tries);
end;
if (tries >= rockTries) then
break;
end;
if (tabBackpack.isFull()) then
exit(true);
log('Didn''t seem to mine rocks');
end;
//bank our ores/gems/whatever else is in inv.
function bank(bankTries, bankWait: integer): boolean;
var
boothTPA: TPointArray;
tmpATPA, ATPA: T2DPointArray;
p: TPoint;
i, c, tries: integer;
opened: boolean = false;
begin
result := false;
checkIfInGame();
if (bankscreen.isOpen()) then
begin
log('Bankscreen is already opened.');
exit(true);
end;
tries := 0;
repeat
if (bankscreen.isOpen()) then
begin
log('Bankscreen is already opened.');
break;
end;
if (not findColorsTolerance(boothTPA, 541791, mainscreen.getBounds(), 3, colorSetting(2, 0.09, 0.61))) then
begin
log('No primary colors found for bank booth.', LOG_ERROR);
exit(false);
end;
tmpATPA := boothTPA.toATPA(25, 25);
tmpATPA.filterBetween(0, 30);
tmpATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(tmpATPA);
//wait(1000);
c := 0;
for (i := 0) to (high(tmpATPA)) do
begin
if (findColorTolerance(p.x, p.y, 3552827, tmpATPA[i].getBounds(), 2, colorSetting(2, 1.67, 0.57))) then
begin
setLength(ATPA, c + 1);
ATPA[c] := tmpATPA[i];
inc(c);
end;
end;
smartImage.clear();
smartImage.debugATPA(ATPA);
if (length(ATPA) < 1) then
begin
log('No bank booths found.');
exit(false);
end;
for (i := 0) to (high(ATPA)) do
begin
mouseBox(ATPA[i].getBounds(), MOUSE_MOVE);
if (isMouseOverText(BANK_BOOTH_TEXT)) then
begin
log('Found bank, opening...');
fastClick(MOUSE_LEFT);
minimap.waitFlag();
if (bankscreen.isOpen(bankWait)) then
begin
log('Successfully opened bank.');
opened := true;
break;
end else
begin
log('Clicked but didn''t open.', LOG_WARNING);
break;
end;
end;
end;
if (opened) then
begin
bankscreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
bankscreen.close();
exit(true);
end;
inc(tries);
log('Bank tries: ' + intToStr(tries));
until (tries >= bankTries);
if (opened) then
begin
bankscreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
bankscreen.close();
exit(true);
end;
log('Wasn''t able to open bank', LOG_ERROR);
end;
//drop ores
function drop(waitTime: integer): boolean;
var
p: TPoint;
timer: TTimeMarker;
begin
result := false;
checkIfInGame();
timer.start();
repeat
if (findDTM(oreDTM, p.x, p.y, actionbar.getSlotBox(1))) then
begin
log('Dropping ores...');
if (not isKeyDown(VK_1)) then
keyDown(VK_1);
end else
begin
log('Looks like we dropped all ore in inv.');
if (isKeyDown(VK_1)) then
keyUp(VK_1);
exit(true);
end;
until (timer.getTime() >= waitTime);
if (isKeyDown(VK_1)) then
keyUp(VK_1);
end;
//setup everything we need
procedure setup();
begin
clearDebug();
initPlayerForm();
runPlayerForm();
AtMine := false;
OreDTM := DTMFromString('mlwAAAHicY2dgYKhjYWBoAOJOIC4B4mogboPSnxkZGN4A8Qcg/grE/4H4NxC/BGILRUkwzg23Y0jytwBjK2UphjgfUwZ+oLm4MCMeDAUAThgPxw==');
if (not playerForm.isScriptReady) then //end script if player clicks x on player form
abort('Script isn''t ready');
//smartPlugins := ['d3d9.dll']; //no longer needed with new SMART
smartEnableDrawing := true;
declarePlayers();
debugSPFSettings();
setupSRL();
if (players[currentPlayer].booleans[3]) then
smartSetDebug(true)
else
smartSetDebug(false);
if (not players[currentPlayer].booleans[2]) then
disableSRLDebug := true;
if (players[currentPlayer].booleans[1]) then
exitSquealOfFortune();
login();
SPS.setup('yanilleMine', RUNESCAPE_OTHER);
end;
//fancy main function
procedure main();
begin
setup();
checkIfInGame();
if (minimap.getAngleDegrees() <> 0 ) then
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
//(*
repeat
checkIfInGame();
if (not AtMine) then
if (not runToMine()) then
abort('Couldn''t run to mine.');
if (not mineRocks(players[currentPlayer].integers[3], players[currentPlayer].integers[7])) then
abort('Couldn''t mine any rocks.');
if (players[currentPlayer].booleans[0]) then
begin
if (not runToBank()) then
abort('Couldn''t run to bank.');
if (not bank(players[currentPlayer].integers[2], players[currentPlayer].integers[4])) then
abort('Couldn''t bank.');
end else
begin
if (not drop(players[currentPlayer].integers[6])) then
abort('Couldn''t drop ores.');
end;
if (tabBackpack.count() >= players[currentPlayer].integers[8])then
begin
if (not runToBank()) then
abort('Couldn''t run to bank.');
if (not bank(players[currentPlayer].integers[2], players[currentPlayer].integers[4])) then
abort('Couldn''t bank.');
end;
inc(Loads);
proggy();
until ((Loads >= players[currentPlayer].integers[0]) and (players[currentPlayer].integers[0] <> 0));
//*)
cleanup();
end;
//runs script
begin
main();
end.