Spartan 117
2014-01-21 01:21:56
8 Year(s)
Are you affilated in anyway with Jagex LTD?
No
Were you Referred to SRL?
What is your general programming knowledge?
I know pascal, C, Java, and some Objective-C
Are you a member of any other communities?
I am a member at powerbot, and tribot, however I am not active in either due to high ban rates
Tell us about yourself…
From: Spartan 117
I came to SRL when the bot nuke happened (yeah, I was one of those guys). And at first I was only a leecher. But after some time of reading through comments and using scripts I began to feel the sense of community and decided I wanted to belong here. I attempted scripting, sucked at it, and gave up. I quit runescape for a long time. However, my interest in programming increased. I began developing apps for the iPhone (that I never published). And became the teacher of our school computer science team for competitions (None of our teachers knew how to program). Now I am at Texas Tech and am majoring in computer engineering. My hobbies are sports, video games and programming. I have had the same girlfriend for 5 years now (had to keep the one that didn't mind me being a nerd). SRL really sparked my interest in what I am planning on doing for the rest of my life.
Please show us one (or multiple) of your scripts.
program WaterfiendKiller;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}
//Type taken from Sg5
type TLoot = record
name: TStringArray;
color, tol: Integer;
sat, hue: extended;
end;
//Used to detect items on the ground
//Taken from Sg5
function SetupLoot : array of TLoot;
begin
Setlength(result, 4);
//Green Charm
Result[0].name := ['reen', 'en ch'];
Result[0].color := 10209713;
Result[0].tol := 10;
//Mithril Arrow
Result[1].name := ['ithr', 'il ar'];
Result[1].color := 1595007;
Result[1].tol := 10;
//Crimson Charm
Result[2].name := ['rim', 'on ch'];
Result[2].color := 3760527;
Result[2].tol := 5;
//Water Rune
Result[3].name := ['ater', 'er ru'];
Result[3].color := 12699859;
Result[3].tol := 15;
end;
const
// COLORS THAT MAY NEED FIXING
FIEND_COLOR = 7756849;
var
closeDTM, combatDTM, monkDTM, pot1DTM, pot2DTM, pot3DTM, pot4DTM, prayDTM, pray2DTM: Integer;
eatPercent, drinkPercent, cycles, fails: Integer;
basic, threshold, ultimate: array of Integer;
useUltimate, usePrayerPot, usePrayer, loot, onLoot: boolean;
pathtobank, leave, pathtotele, pathFromNorth, pathFromMessUp, pathFromEast: TPointArray;
p2: tpoint;
procedure declarePlayers;
begin
{*************************************************************************************}
{********************* FILL OUT THESE OPTIONS ***********************************}
eatPercent := 70; //at what health percent do you want to eat at?
drinkPercent := 40; //what prayer percent do you want to drink a pot at?
basic := [1,2,3,4,5]; //Which actionbar slots do you have a basic ability in?
threshold := [6,7]; //Which actionbar slots do you have a threshold ability in?
ultimate := [8]; //Which actionbar slots do you have an ultimate ability in?
useUltimate := false; //Do you want to use your ultimate abiliies?
usePrayer := true; //Do you want to Pray? **ONLY SUPPORTS PROTECT FROM MISSLE**
usePrayerPot := true; //Do you want to drink prayer pots?
loot := true; //Do you want to loots? **SIGNIFICANTLY DECREASES XP/HR
{********************* END OF OPTIONS ***********************************}
{********************* FILL IN USE DATA ***********************************}
setLength(players, 1);
with players[0] do
begin
loginName := ''; //User name here
password := ''; //Password here
isActive := true;
isMember := true;
world := 84;
end;
currentPlayer := 0;
end;
procedure loadDTMs;
begin
combatDTM := DTMFromString('mbQAAAHicY2VgYFBkZWBQB2I5IJYEYiUgPgoUPwDEJ4H4MBCfBeLuiniGQg8VhuYAC4YwezWGUAcNBi6gODpmxILBAACLhwmX');
monkDTM := DTMFromString('mggAAAHicY2NgYNjHxsBwEogPAPFmIN4PxLuAWIWJgUEViPWhtDyU7etqDdTFhIG5gCQ2zIgDQwAAu/cGrg==');
pot1DTM := DTMFromString('mbQAAAHicY2VgYDjAxsCwC4iPAPEJIN4OxLOZGBgmAfEEIJ4LxNOBuGD1LKBqJhTMBSTRMSMWDAYA1E8I0A==');
pot2DTM := DTMFromString('mbQAAAHicY2VgYHBmY2BwB2JbILYCYg8g3sfEwLANiLcA8W4gPgTEJusbgaqZUDAXkETHjFgwGAAAB/AGvw==');
pot3DTM := DTMFromString('mbQAAAHicY2VgYHjNxsDwFIjfAvEHIH4AxDOZGBgmAnEPEM8D4tlAbLqxBaiaCQVzAUl0zIgFgwEAD5MJUw==');
pot4DTM := DTMFromString('mbQAAAHicY2VgYHBiY2BwA2JbILYAYi8gZmMCSkAxJxDzArHZllaEIBRzAUl0zIgFgwEA+V0DPw==');
prayDTM := DTMFromString('mbQAAAHicY2VgYJBlZWDQAGJJIFYFYjEgdmBkYPABYlsgtgRidyBe5K/G8PPHD4bn778wHAvXBGMuoH50zIgFgwEAw+sLkw==');
pray2DTM := DTMFromString('mQwAAAHicY2ZgYNBlYWBQBmJNIL7EyMBwAojPAfHhdhOGTTv2MSwuNmHgAqqDYUYkDAQAPe0IBQ==');
closeDTM := DTMFromString('mggAAAHicY2NgYKhmZWAoAeI6IC5HojcwQPBmIF4DxSD2z53ODMFszAyfZnAx/DufBcYgNlALVsyIA0MAAG7mESc=');
end;
procedure freeTheDTMs;
begin
freeDTM(combatDTM);
freeDTM(monkDTM);
freeDTM(pot1DTM);
freeDTM(pot2DTM);
freeDTM(pot3DTM);
freeDTM(pot4DTM);
freeDTM(prayDTM);
freeDTM(pray2DTM);
freeDTM(closeDTM);
end;
{Finds an objext with color of objColor and mouseText.
Return 0 if it left clicks
Returns 1 if it simply moves to the object
Returns 2 if it fails to find object}
function objectFinder(objColor: Integer; mouseText: array of string; needClosest, leftClick: boolean) : integer;
var
x, y, CTS, i: integer;
TPA: TPointArray;
obj: Array of TPointArray;
begin
if (not isLoggedIn) then Exit;
result := 2;
findColorsTolerance(TPA, objColor, mainscreen.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
if length(obj) > 0 then
begin
if needClosest then
sortATPAfromMidPoint(obj, mainscreen.playerPoint); //finds the closest obj
for i := 0 to high(obj) do
begin
mouse(MiddleTPA(obj[0]).x + randomrange(-1,1), MiddleTPA(obj[i]).y + randomrange(-1,1), MOUSE_MOVE);
if leftClick then
begin
if isMouseOverText(mouseText, randomrange(160,185)) then
begin
fastclick(MOUSE_LEFT);
result := 0;
break;
end;
end else
begin
fastclick(MOUSE_RIGHT);
chooseOption.select(mouseText);
break;
end;
end;
Writeln('ObjectFinder result: ' + toString(result));
end;
end;
//Returns true if not moving
function notMoving : boolean;
begin
if not isLoggedIn then Exit;
result := false;
if not minimap.isPlayerMoving() then
result := true;
end;
//Returns an ATPA of all loot stacks on the ground
//Based looslely off of Sg5's looter
function findLoot(lootitems:Array of TLoot) : Array of TPointArray;
var
i, a, h,r, dist: integer;
TPA: TPointArray;
atpa, loots: Array of TPointArray;
begin
if not isLoggedIn then Exit;
for i := 3 to high(lootitems) do
begin
findColorsTolerance(TPA, lootitems[i].color, mainScreen.getBounds(), lootitems[i].tol);
atpa := TPAtoATPA(TPA, 10);
for a := 0 to high(atpa) do
begin
dist := round(sqrt(((atpa[a][0].x - 286)*(atpa[a][0].x - 286)) + ((atpa[a][0].y - 195)*(atpa[a][0].y - 195))));
writeln(dist);
if dist > 35 then
begin
h := length(loots);
setlength(loots, length(loots) + length(atpa));
loots[h] := atpa[a];
end;
end;
end;
result:= loots;
if length(loots) > 0 then
begin
smartImage.drawCircle(middleTPA(loots[0]), 10, false, 472);
end;
wait(randomrange(500,750));
writeln('There are ' + tostring(length(result)) + ' loot stacks');
end;
//Returns true if lootstacks are found on ground
function lootVisible : boolean;
begin
if not isLoggedIn then Exit;
result := false;
if length(findLoot(setuploot)) > 0 then
result := true;
end;
//Takes loot in a prioritized manner
procedure takeLoot;
var
i: Integer;
atpa: array of TPointArray;
begin
if not isLoggedIn then Exit;
atpa := findloot(setuploot);
for i := 0 to high(atpa) do
begin
smartImage.clear();
Mouse(middleTPA(atpa[0]), MOUSE_MOVE);
wait(randomrange(50, 100));
fastclick(MOUSE_RIGHT);
writeln('grabbing loot');
wait(randomrange(150, 250));
if chooseOption.optionsExist(['Take Crimson']) then
begin
chooseOption.select(['Take Crimson']);
wait(randomrange(1500, 2000));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['row']) then
begin
chooseOption.select(['Take Mithril a']);
wait(randomrange(1500, 2000));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['reen']) then
begin
chooseOption.select(['Take Green']);
wait(randomrange(1500, 2000));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['lue']) then
begin
chooseOption.select(['Take Blu']);
wait(randomrange(1500, 2000));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['old']) then
begin
chooseOption.select(['Take Gold']);
wait(randomrange(1500, 2000));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['orb']) then
begin
chooseOption.select(['Take Water o']);
wait(randomrange(1500, 2000));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['lood']) then
begin
chooseOption.select(['lood', 'une']);
wait(randomrange(1500, 2000));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['ithril', 'ore']) then
begin
chooseOption.select(['ithr', 'l or', 'ore']);
wait(randomrange(350, 500));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['key']) then
begin
chooseOption.select(['key']);
wait(randomrange(350, 500));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['ivy']) then
begin
chooseOption.select(['ivy']);
wait(randomrange(350, 500));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['ater ru']) then
begin
chooseOption.select(['Take Water rune']);
wait(randomrange(1500, 2000));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['ru', 'rune']) then
begin
chooseOption.select(['ru', 'rune']);
wait(randomrange(350, 500));
onLoot := true;
Exit;
end else
if chooseOption.optionsExist(['ancel']) then
begin
chooseOption.select(['ancel']);
wait(randomrange(350, 500));
Exit;
end else
Exit;
end;
end;
//Returns true in the inv is full
function invFull : boolean;
begin
if not isLoggedIn then Exit;
result := false;
if tabBackpack.isFull then
result := true;
end;
//Takes the rest of the loot in a stack once the player is on a stack
procedure keepTaking;
var
p: TPoint;
allItems: TStringArray;
begin
p.x := 288 + randomrange(-1,1);
p.y := 199 + randomrange(-1,1);
setLength(allItems, 12);
allItems := ['rimson', 'row', 'reen', 'lue', 'old', 'orb', 'lood', 'ater ru', 'ru', 'rune', 'ithril o', 'ore'];
repeat
Mouse(p, MOUSE_MOVE);
wait(randomrange(150, 250));
fastClick(MOUSE_RIGHT);
wait(randomrange(160, 180));
if chooseOption.optionsExist(['rimson']) then
begin
chooseOption.select(['rimson', 'arm']);
wait(randomrange(1500, 2000));
end else
if chooseOption.optionsExist(['row']) then
begin
chooseOption.select(['ithril r', 'row']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['reen']) then
begin
chooseOption.select(['reen', 'arm']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['lue']) then
begin
chooseOption.select(['lue', 'arm']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['old']) then
begin
chooseOption.select(['old', 'arm']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['orb']) then
begin
chooseOption.select(['orb']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['lood']) then
begin
chooseOption.select(['lood', 'une']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['ithril o', 'ore']) then
begin
chooseOption.select(['ithr', 'l or', 'ore']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['key']) then
begin
chooseOption.select(['key']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['ivy']) then
begin
chooseOption.select(['ivy']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['ater ru']) then
begin
chooseOption.select(['r ru', 'rune']);
wait(randomrange(350, 500));
end else
if chooseOption.optionsExist(['ru', 'rune']) then
begin
chooseOption.select(['ru', 'rune']);
wait(randomrange(350, 500));
end else
if not chooseOption.optionsExist(allItems) then
begin
chooseOption.select(['ancel']);
wait(randomrange(350, 500));
Break;
end;
until(false);
onLoot := false;
end;
{Attacks a waterfiend then waits for a random time in the specified time range}
function attackFiend(waitMin, waitMax: Integer) : boolean;
begin
if not isLoggedIn then Exit;
result := false;
if (objectFinder(7756849, ['attack', 'fiend'], true, false) = 1) then
begin
wait(randomrange(waitMin, waitMax));
result := true;
end;
end;
function isInCombat : boolean;
var
x, y: Integer;
begin
if not isLoggedIn then Exit;
result := false;
if findDTM(combatDTM, x, y, mainScreen.getBounds()) then
result := true;
if findDTM(combatDTM, x, y, ActionBar.getBounds()) then
result := true;
if findDTM(combatDTM, x, y, chatBox.getBounds()) then
result := true;
if result = true then
writeln('We are fighting');
if result = false then
writeln('Not currently in combat');
end;
//Returns true if monkFish are in the inventory
function haveFood : boolean;
begin
if not isLoggedIn then Exit;
result := false;
if tabBackPack.countDTM(monkDTM) > 0 then
result := true;
end;
//Returns true if any PPots are found in inventory
function havePots : boolean;
begin
if not isLoggedIn then Exit;
result := false;
if ((tabBackPack.countDTM(pot1DTM) > 0) or
(tabBackPack.countDTM(pot2DTM) > 0) or
(tabBackPack.countDTM(pot3DTM) > 0) or
(tabBackPack.countDTM(pot4DTM) > 0)) then
result := true;
end;
//Returns true if health is below specified eating percent
function lowHealth : boolean;
begin
if not isLoggedIn then Exit;
result := false;
if (actionBar.getHPPercent() < eatPercent) then
result := true;
end;
//Eats a monkfish!
procedure eatFood;
begin
if not isLoggedIn then Exit;
tabBackpack.clickDTM(monkDTM, MOUSE_LEFT, '', randomrange(300, 350), false);
end;
//Drinks a PPot in a priortized manner of emptiest first
procedure drinkPot;
var
x, y: integer;
begin
if not isLoggedIn then Exit;
if findDTM(pot1DTM, x, y, tabBackpack.getBounds()) then
begin
tabBackpack.clickDTM(pot1DTM, MOUSE_LEFT, '', randomrange(300, 350), false);
writeln('Drinking dose of potion');
Exit;
end;
if findDTM(pot2DTM, x, y, tabBackpack.getBounds()) then
begin
tabBackpack.clickDTM(pot2DTM, MOUSE_LEFT, '', randomrange(300, 350), false);
writeln('Drinking dose of potion');
Exit;
end;
if findDTM(pot3DTM, x, y, tabBackpack.getBounds()) then
begin
tabBackpack.clickDTM(pot3DTM, MOUSE_LEFT, '', randomrange(300, 350), false);
writeln('Drinking dose of potion');
Exit;
end;
if findDTM(pot4DTM, x, y, tabBackpack.getBounds()) then
begin
tabBackpack.clickDTM(pot4DTM, MOUSE_LEFT, '', randomrange(300, 350), false);
writeln('Drinking dose of potion');
Exit;
end;
end;
//Checks if a certain slot's ability is ready (easier than typing out every time)
function abilityReady(slot: integer): boolean;
begin
if not isLoggedIn then Exit;
result := false;
if actionBar.getAbilityCooldown(slot) = 1 then
result := true;
end;
//Returns the actionbar slot that is best to use
function chooseAbility : integer;
var
i: Integer;
begin
if not isLoggedIn then Exit;
if ((actionBar.getAdrenalinePercent() < 50) or (not (abilityready(threshold[0]) or abilityready(threshold[1])))) then
begin
for i := 0 to high(basic) do
begin
if abilityready(basic[i]) then
begin
result := basic[i];
wait(randomrange(50, 75));
break;
end;
end;
Exit;
end;
if (actionBar.getAdrenalinePercent() >= 50) then
begin
for i := 0 to high(threshold) do
begin
if abilityready(threshold[i]) then
begin
result := threshold[i];
wait(randomrange(50, 75));
break;
end;
end;
Exit;
end;
if useUltimate then
begin
if (actionBar.getAdrenalinePercent() = 100) then
begin
for i := 0 to high(ultimate) do
begin
if abilityready(ultimate[i]) then
begin
result := ultimate[i];
wait(randomrange(50, 75));
break;
end;
end;
Exit;
end;
end;
end;
//Uses the ability given by chooseAbility
procedure useAbility;
var
slott: Integer;
begin
if not isLoggedIn then Exit;
slott := chooseAbility;
actionbar.clickSlot(slott);
wait(randomrange(200, 250));
writeln('Used ability in slot: ' + toString(slott));
end;
//Uses DTM on mainScreen to see if Protect from Missles is active
function isPraying : boolean;
var
x, y: Integer;
begin
if not isLoggedIn then Exit;
result := false;
if findDTM(prayDTM, x, y, mainScreen.getBounds()) then
result := true;
if findDTM(pray2DTM, x, y, mainScreen.getBounds()) then
result := true;
writeln(result);
end;
//Clicks slot 10 (where protect from Missles is)
procedure clickPrayer;
begin
if not isLoggedIn then Exit;
actionBar.clickSlot(10);
end;
//Returns true if player needs to drink PPot
function lowPrayer : boolean;
begin
if not isLoggedIn then Exit;
result := false;
if (actionBar.getPrayerPercent() < drinkPercent) then
result := true;
end;
//Returns true if the player has the ability to turn on prayer
function havePrayer : boolean;
begin
if not isLoggedIn then Exit;
result := false;
if usePrayerPot and havePots then
result := true;
if (actionbar.getPrayerPercent > 0) then
result := true;
end;
//Finds the bank and clicks on it using custom object finder
procedure clickBank;
begin
if not isLoggedIn then Exit;
objectfinder(10158079, ['ank', 'ooth'], true, true);
wait(randomrange(100, 150));
end;
//Quick way to write deposit all
procedure depositAll;
begin
if not isLoggedIn then Exit;
bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
end;
//Withdraws items needed
procedure withDrawItems;
begin
bankScreen.withdraw(10, 3, ['rayer', 'potion']);
wait(randomrange(250, 350));
bankScreen.withdraw(9, 10, ['onk', 'fish']);
wait(randomrange(250, 350));
bankScreen.withdraw(9, 10, ['onk', 'fish']);
end;
//walks to a fiary ring
function caveWalkOut : boolean;
var
x, y, i: integer;
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 1600233, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
begin
mouse(MiddleTPA(obj[0]).x + randomrange(-5,5), MiddleTPA(obj[0]).y + randomrange(-5,5), MOUSE_MOVE);
wait(randomrange(160, 180));
fastclick(MOUSE_LEFT);
result :=true;
end;
end;
//walks to obleisk on minimap
function walkToObelisk : boolean;
var
x, y, i: integer;
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 1068133, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
begin
smartImage.drawCircle(MiddleTPA(obj[0]), 8, true, 1777498);
mouse(MiddleTPA(obj[0]).x + randomrange(-1,1), MiddleTPA(obj[0]).y + randomrange(-1,1), MOUSE_MOVE);
wait(randomrange(160, 180));
fastclick(MOUSE_LEFT);
result :=true;
smartImage.clear();
end;
end;
//walks in between bank and obelisk with some randomness
function walkCloseToBank : boolean;
var
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 472, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
begin
smartImage.drawCircle(point(MiddleTPA(obj[0]).x - randomrange(33,35), MiddleTPA(obj[0]).y + randomrange(13,15)), 8, true, 1777498);
mouse(MiddleTPA(obj[0]).x - randomrange(25,35), MiddleTPA(obj[0]).y + randomrange(7,15), MOUSE_MOVE);
wait(randomrange(160, 180));
fastclick(MOUSE_LEFT);
result :=true;
smartImage.clear();
end;
end;
//Walks to random bank booth using minimap
function walkToBank : boolean;
var
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 2740983, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
begin
smartImage.drawCircle(MiddleTPA(obj[0]), 8, true, 1777498);
mouse(MiddleTPA(obj[0]).x - randomrange(10,13), MiddleTPA(obj[0]).y + randomrange(15,10), MOUSE_MOVE);
wait(randomrange(160, 180));
fastclick(MOUSE_LEFT);
result :=true;
smartImage.clear();
end;
end;
//Returns true if you are near a fairy ring
function nearRing : boolean;
var
dist: Integer;
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
dist := 100;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 1600233, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
dist := round(sqrt((p.x - MiddleTPA(obj[0]).x)*(p.x - MiddleTPA(obj[0]).x) + (p.y - MiddleTPA(obj[0]).y)*(p.y - MiddleTPA(obj[0]).y)));
if dist < 20 then
result := true;
end;
//Returns true if the fairy ring is not on minimap while in the cave
//Used as a failsafe for exiting when low health
function inBadCave : boolean;
var
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if not isLoggedIn then Exit;
result := true;
findColorsTolerance(TPA, 1600233, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
if length(obj) > 0 then
result := false;
end;
//Returns true if player is near obelisk on minimap
function nearObelisk : boolean;
var
dist: Integer;
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
dist := 100;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 1068133, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
dist := round(sqrt((p.x - MiddleTPA(obj[0]).x)*(p.x - MiddleTPA(obj[0]).x) + (p.y - MiddleTPA(obj[0]).y)*(p.y - MiddleTPA(obj[0]).y)));
if dist < 20 then
result := true;
end;
//Walks to where the fairy ring is visible on minimap in cave
procedure walkGoodCave;
var
clickBox: TBox;
pt: TPoint;
x, y, i: Integer;
TPA: tpointArray;
obj: array of tpointarray;
begin
if (not isLoggedIn) then Exit;
clickbox := intToBox(582, 67, 612, 135);
pt := clickbox.getMiddle();
Mouse(point(pt.x + randomrange(-8, 8), pt.y + randomrange(-8,8)), MOUSE_MOVE);
wait(randomrange(50, 100));
fastclick(MOUSE_LEFT);
end;
//Returns true if you are in the bank
function nearBank : boolean;
var
dist: Integer;
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
dist := 100;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 2740983, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
dist := round(sqrt((p.x - MiddleTPA(obj[0]).x)*(p.x - MiddleTPA(obj[0]).x) + (p.y - MiddleTPA(obj[0]).y)*(p.y - MiddleTPA(obj[0]).y)));
if dist < 15 then
result := true;
end;
//Walks in between obelisk and bank
function walkCloseObelisk : boolean;
var
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 1244922, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
begin
smartImage.drawCircle(middleTPA(obj[0]), 5, true, 472);
smartImage.drawCircle(point(MiddleTPA(obj[0]).x - randomrange(13,17),MiddleTPA(obj[0]).y + randomrange(22,27)), 5, true, 472);
mouse(MiddleTPA(obj[0]).x - randomrange(13,17), MiddleTPA(obj[0]).y + randomrange(22,27), MOUSE_MOVE);
wait(randomrange(160, 180));
fastclick(MOUSE_LEFT);
result :=true;
smartImage.clear();
end;
end;
//Returns true if you are in a certain area between teh obelisk and bank
function nearCloseToObelisk : boolean;
var
dist: Integer;
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
dist := 100;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 1244922, minimap.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
dist := round(sqrt((p.x - (MiddleTPA(obj[0]).x-14))*(p.x - (MiddleTPA(obj[0]).x-14)) + (p.y - (MiddleTPA(obj[0]).y+24))*(p.y - (MiddleTPA(obj[0]).y+24))));
if dist < 15 then
result := true;
end;
//Returns true if you are close to the bank
function nearCloseToBank : boolean;
var
dist: Integer;
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
dist := 100;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 265197, minimap.getBounds(), 15);
obj := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(obj, p);
if length(obj) > 0 then
dist := round(sqrt((p.x - (MiddleTPA(obj[0]).x - 34))*(p.x - (MiddleTPA(obj[0]).x - 34)) + (p.y - (MiddleTPA(obj[0]).y + 14))*(p.y - (MiddleTPA(obj[0]).y + 14))));
if dist < 15 then
result := true;
end;
//Returns true if there are waterfiends visible
//Method of checking to see if your are in cave
function fiendsVisible : boolean;
var
TPA: TPointArray;
obj: Array of TPointArray;
p: TPoint;
begin
if (not isLoggedIn) then Exit;
result := False;
p.x := 687;
p.y := 103;
findColorsTolerance(TPA, 7756849, mainScreen.getBounds(), 5);
obj := TPAToATPA(TPA, 50);
if length(obj) > 0 then
begin
wait(randomrange(160, 180));
result :=true;
smartImage.clear();
end;
end;
//Enters Zanaris
procedure clickRingCave;
begin
if not isLoggedIn then Exit;
if objectFinder(16777163, ['airy', 'ring'], true, false) = 2 then
objectFinder(11071999, ['airy', 'ring'], true, false);
end;
procedure clickRingZanaris;
var
i: Integer;
TPA: TPointArray;
obj: Array of TPointArray;
begin
if (not isLoggedIn) then Exit;
findColorsTolerance(TPA, 16777163, mainscreen.getBounds(), 5);
obj := TPAToATPA(TPA, 250);
sortATPAfromMidPoint(obj, mainscreen.playerPoint);
if length(obj) > 0 then
begin
mouse(MiddleTPA(obj[0]).x + randomrange(-1,1), MiddleTPA(obj[i]).y + randomrange(-1,1), MOUSE_MOVE);
if isMouseOverText(['airy', 'ring'], randomrange(530,695)) then
begin
fastclick(MOUSE_RIGHT);
wait(randomrange(160, 180));
chooseOption.select(['airy', 'ring']);
end;
end;
end;
//Sees if the fairy ring interface is up
function interfaceUp : boolean;
var
p: tpoint;
begin
if not IsLoggedIn then Exit;
result := false;
if findText(p, ['BJQ', 'ungeons'], [smallChars], intToBox(543, 63, 740, 328)) then
result := true;
end;
//Puts in teh proper fairy code NOTE: Must have been used before
procedure enterCave;
var
p: tpoint;
begin
if not isLoggedIn then Exit;
if findText(p, ['BJQ', 'ungeons'], [smallChars], intToBox(543, 63, 740, 328)) then
begin
Mouse(p, MOUSE_MOVE);
wait(randomrange(150, 250));
fastclick(MOUSE_LEFT);
end;
wait(randomrange(1200, 1700));
if findText(p, ['Teleport', 'to this', 'location'], [CharsNPC], intToBox(201, 281, 375, 335)) then
begin
Mouse(p, MOUSE_MOVE);
wait(randomrange(150, 250));
fastclick(MOUSE_LEFT);
end;
end;
//Returns true if the bank is open
//ignore this function
function bankOpen : boolean;
var
x, y: Integer;
begin
if not IsLoggedIn then Exit;
result := false;
if findDTM(closeDTM, x, y, mainScreen.getBounds()) then
result := true;
end;
//Does a reasonable amount of antiban for a combat script
procedure antiban;
var
i: integer;
begin
if not isLoggedIn then
exit;
i := random(1000);
case i of
1..3: randomRClickItem();
20..22: sleepAndMoveMouse(randomrange(1000, 1500));
60..62:
begin
randomCompass(0, 360, true);
minimap.clickCompass();
wait(randomrange(75,100));
randomCameraAngle(MS_ANGLE_HIGH);
end;
120..122: wait(randomrange(3000, 6000));
340..372: smallRandomMouse();
430..432: mouseOffClient(OFF_CLIENT_TOP);
450..452: mouseOffClient(OFF_CLIENT_RANDOM);
660..662: wait(randomrange(800, 2000));
860..870: minimap.setAngle(MM_DIRECTION_NORTH);
end;
end;
//Checks a state using the custom boolean functions
// and performs the logical task it needs to
procedure mainLoop;
begin
cycles := 0;
onLoot := false;
fails := 0;
repeat
if not isLoggedIn then
players[currentplayer].login();
loadDTMs;
antiban;
if fiendsVisible and inBadCave then
begin
walkGoodCave;
fails := 0;
wait(randomrange(6000, 7000));
end
if lowHealth and haveFood and fiendsVisible and not bankScreen.isOpen() then
begin
eatFood;
fails := 0;
wait(randomrange(250, 350));
end
if lowHealth and not haveFood and fiendsVisible and not bankScreen.isOpen() then /////////////////
begin
caveWalkOut;
fails := 0;
wait(randomrange(6000, 7000));
end
if isInCombat and not lowHealth then
begin
useAbility;
fails := 0;
wait(randomrange(250, 350));
end
if invFull then
eatFood;
if lowPrayer and usePrayerPot and havePots then
begin
drinkPot;
fails := 0;
wait(randomrange(350, 550));
end
if not isPraying and usePrayer and havePrayer and fiendsVisible and not bankScreen.isOpen() then //and inDungeon
begin
clickPrayer;
fails := 0;
wait(randomrange(250, 350));
end
if not lowHealth and not isInCombat and not lootVisible and fiendsVisible and not bankScreen.isOpen() then
begin
attackFiend(650, 750);
fails := 0;
wait(randomrange(2000, 2500));
end
if not lowHealth and not isInCombat and fiendsVisible and not bankScreen.isOpen() and lootVisible and loot and (not onLoot) then
begin
takeLoot;
fails := 0;
wait(randomrange(2000, 2750));
end
if onLoot and not isInCombat then
begin
keepTaking;
fails := 0;
wait(randomrange(130,200));
end
if nearBank and haveFood then
begin
walkCloseObelisk;
writeln('walking close to obelisk');
wait(randomrange(6000, 7000));
end
if nearCloseToObelisk and haveFood then
begin
caveWalkOut;
writeln('Walking to ring');
wait(randomrange(6000, 7000));
end
if nearRing and not fiendsVisible and haveFood then
begin
clickRingZanaris;
fails := 0;
wait(randomrange(1500, 1700));
end
if nearRing and not fiendsVisible and not haveFood then
begin
walkToObelisk;
writeln('walking to obelisk');
wait(randomrange(6000, 7000));
end
if nearObelisk and not haveFood then
begin
walkCloseObelisk;
writeln('Walking close to bank');
wait(randomrange(6000, 7000));
end
if nearCloseToObelisk and not haveFood then
begin
walkToBank;
writeln('walking in bank');
wait(randomrange(10000, 12000));
end
if nearBank and not haveFood then
begin
clickBank;
wait(randomrange(2200, 2700));
depositAll;
wait(randomrange(600, 800));
withdrawItems;
wait(randomrange(600, 800));
bankScreen.close();
wait(randomrange(2000, 2200));
end
if interfaceup then
begin
enterCave;
fails := 0;
wait(randomrange(10000, 12000));
end
if lowHealth and not haveFood and fiendsVisible and not bankScreen.isOpen() and nearRing then
begin
clickRingCave;
wait(randomrange(10000, 12000));
end
if fails = 5 then
Break;
cycles := cycles + 1;
writeln('We have been throu the main loop ' + toString(cycles) + ' times.');
freetheDTMs;
until(false);
end;
begin
clearDebug();
smartEnableDrawing := true;
setupSRL;
declarePlayers;
addonterminate('freetheDTMS');
wait(1000);
mainloop;
wait(1000);
end.
//Please keep in mind I had to use some lengthy methods due to colors in Zanaris and in the cave all being so
//similar to each other
//New script
//NOTE: I wrote AutoPlankMake before WaterFiendKiller
program AutoPlankMake;
{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}
var //globals
plankDTM, logDTM, planksmade, closeDTM, fails, bankerColor, spellSlot, direction: integer;
clicknext: string;
procedure declarePlayers;
begin
//Fill in these three. The bankerColor might be fine if you are in front of a purple banker.
bankerColor := 4005931; //Take the color of the banker in front of you.
spellSlot := 1; //This number needs to be the slot number plankmake is in on the action bar
direction := MM_DIRECTION_WEST; //Direction your character needs to face
setLength(players, 1);
with players[0] do
begin
loginName := '';
password := '';
isActive := true;
isMember := true;
world := 84;
end;
currentPlayer := 0;
end;
procedure loadDTMs
begin
logDTM := DTMFromString('mbQAAAHicY2VgYEhkZWDwB+J0IA4B4lQg/srIwPALiD8A8Xsoe3lPLFA1ExgH6HGDaS4giY4ZsWAwAAC2hAkS');
plankDTM := DTMFromString('mlwAAAHicY2dgYFjPxMCwAYjXAPEOKHsFEC8D4nBGBoY4IE4BYj8g9gLiKCBOAmIHQxWgbiasmBVI4sKMeDAUAADUsQgW');
closeDTM := DTMFromString('mggAAAHicY2NgYKhmZWAoAeI6IC5HojcwQPBmIF4DxSD2z53ODMFszAyfZnAx/DufBcYgNlALVsyIA0MAAG7mESc=');
end;
procedure freetheDTMS;
begin
freeDTM(plankDTM);
freeDTM(logDTM);
freeDTM(closeDTM);
end;
//failsafe to logout after inactivity/unsolvable screwups
procedure failExit;
begin
if (not isLoggedIn) then Exit;
wait(randomrange(1500,3000));
players[currentPlayer].exitToLobby();
wait(randomrange(500, 1000));
terminateScript;
end;
procedure antiban;
var
i: integer;
begin
if not isLoggedIn then
exit;
i := random(2000);
case i of
1..3: randomRClickItem();
20..22: sleepAndMoveMouse(randomrange(1000, 1500));
60..62: randomCompass(0, 360, true);
120..122: randomCameraAngle(MS_ANGLE_HIGH);
340..342: smallRandomMouse();
430..432: mouseOffClient(OFF_CLIENT_TOP);
450..452: mouseOffClient(OFF_CLIENT_RANDOM);
660..662: boredHuman();
860..870: minimap.setAngle(direction);
end;
end;
//finds the dtm in the bank pack and deposits it
function depositPlanks : boolean;
var
x, y: integer;
begin
if (not isLoggedIn) then Exit;
if (findDTM(plankDTM, x, y, 550, 75, 735, 350)) then
begin
Mouse(x + randomrange(-2,2), y + randomrange(-2,2), MOUSE_MOVE);
wait(randomrange(200, 250));
fastclick(MOUSE_RIGHT);
wait(randomrange(50, 75));
chooseoption.select(['All']);
result := true;
planksmade := planksmade + 26;
fails := 0;
end else
result := false;
end;
//calculates magic xp/hr
function xpperhour() : extended;
var
time, xpgained, timeinhour: extended;
begin
time := getTimeRunning;
xpgained := planksmade * 90;
timeinhour := time/1000/60/60;
result := xpgained/timeinhour;
end;
//ignore this procedure (its for testing purposes)
procedure loadPaint;
begin
smartImage.clearArea(IntToBox(4, 448, 569, 597));
smartImage.drawBitmap('C:\Simba\Scripts\AutoPlankMake\plankmakebmp.bmp', point(4,448));
end;
//simply paints the proggy
procedure paintProgress
begin
smartImage.clearArea(IntToBox(4, 448, 569, 597));
smartImage.drawBitmap('C:\Simba\Scripts\AutoPlankMake\plankmakebmp.bmp', point(4,448));
smartImage.DrawText('Run Time: ' + msToTime(GetTimeRunning, TIME_SHORT), Point(280, 500), upchars07, false, 9456471);
smartImage.DrawText('Total XP: ' + toString(planksmade * 90), Point(280, 515), upchars07, false, 9456471);
smartImage.DrawText('XP/HR: ' + toString(round(xpperhour())), Point(280, 530), upchars07, false, 9456471);
smartImage.DrawText('Planks Made: ' + toString(planksmade), Point(280, 545), upchars07, false, 9456471);
smartImage.DrawText('Planks/HR: '+ toString(round(round(xpperhour())/90)), Point(280, 560), upchars07, false, 9456471);
end;
//searches for the color of the banker, breaks into groups, and clicks closest group
function openBank : boolean;
var
x, y, CTS, i: integer;
TPA: TPointArray;
booth: Array of TPointArray;
begin
if (not isLoggedIn) then Exit;
if bankscreen.isOpen() then
begin
Writeln('Bank already open. Cant open again');
exit;
end;
findColorsTolerance(TPA, bankerColor, mainscreen.getBounds(), 5);
booth := TPAToATPA(TPA, 50);
sortATPAfromMidPoint(booth, mainscreen.playerPoint);
if (not bankscreen.isOpen()) then
begin
mouse(MiddleTPA(booth[0]).x + randomrange(-1,1), MiddleTPA(booth[i]).y + randomrange(-1,1), MOUSE_MOVE);
if isMouseOverText(['ank', 'nker'], randomrange(400,550)) then
begin
writeln('Opening Bank');
fastclick(MOUSE_LEFT);
result := true;
wait(randomrange(1650, 1800));
end
end else
begin
writeln('Bank Open');
end;
end;
//withdraws the logs from bankscreen
function withdrawLogs: boolean;
var
x, y: integer;
begin
if (not isLoggedIn) then Exit;
if findDTM(logDTM, x, y, 62,81, 543, 591) then
begin
Mouse(x,y, MOUSE_MOVE);
if isMouseOverText(['aho', 'gany', 'y log'], randomrange(400, 550)) then
begin
writeln('withdrawing logs');
fastclick(MOUSE_RIGHT);
wait(randomrange(200, 250));
chooseOption.select(['All']);
result := true;
fails := 0;
end;
end else
begin
fails := fails +1;
wait(randomrange(2500, 3000));
end;
end;
//clicks on the designated actionbar slot
procedure selectSpell;
var
x, y: integer;
begin
if (not isLoggedIn) then Exit;
if (clicknext = 'spell') then
begin
if (actionBar.clickSlot(spellSlot)) then
clicknext := 'log';
end;
end;
//clicks on the log in the inventory
procedure clickLog;
var
x, y: integer;
begin
if (not isLoggedIn) then Exit;
if (clicknext = 'log') then
begin
if (findDTM(logDTM, x, y, 575, 292, 796, 563)) then
begin
Mouse(x + randomrange(-2,2), y + randomrange(-2,2), MOUSE_MOVE);
wait(randomrange(150,250));
fastclick(MOUSE_LEFT);
clicknext := 'spell';
wait(randomrange(350, 450));
antiban;
end else
begin
exit;
clicknext := 'spell';
end;
end;
end;
//clicks on spell then logs repeatedly. some added code to make more humanlike
function makePlanks : boolean;
var
x, y : integer;
begin
clicknext := 'spell';
repeat
if (clicknext = 'spell') then
selectSpell;
wait(randomrange(50,100));
if (clicknext = 'log') then
begin
if findDTM(logDTM, x, y, 580, 320, 799, 560) then
begin
clickLog;
end else
break;
end;
paintProgress;
until(tabBackpack.countDTM(logDTM) = 0 or findDTM(plankDTM,x,y,624,500,665,540));
wait(randomrange(700, 900));
if (tabBackpack.countDTM(logDTM) = 1) then
begin
if (clicknext = 'spell') then
selectSpell;
wait(randomrange(50,100));
if (clicknext = 'log') then
begin
if findDTM(logDTM, x, y, 580, 320, 799, 560) then
begin
clickLog;
end;
end;
wait(randomrange(700,900));
end else
exit;
writeln('Made dem logs');
result := true;
if (tabBackpack.countDTM(logDTM) > 0) then result := false;
end;
//closes bank (only made this when I thought bankscreen.close() was broken but it wasnt
function bankClose : boolean;
var
x, y: integer;
begin
result := false;
if findDTM(closeDTM, x, y, 0, 0, 799, 599) then
begin
Mouse(x, y, MOUSE_MOVE);
wait(randomrange(150,250));
fastclick(MOUSE_LEFT);
wait(randomrange(150,250));
result := true;
end;
end;
//returns true if the minimap is north
function minimapisnorth : boolean;
var
ang: extended;
begin
result := false;
ang := minimap.getAngleDegrees();
wait(randomrange(150, 250));
if (ang > 330) then result := true;
if (ang < 25) then result := true;
end;
//checks what needs to happen and does it
procedure mainloop;
var
x, y: integer;
begin
planksmade := 0;
repeat
if (not isLoggedIn) then break;
if minimapisnorth then
begin
minimap.setAngle(direction);
wait(randomrange(300, 550));
randomCameraAngle(MS_ANGLE_HIGH);
wait(randomrange(500, 750));
end;
if (bankscreen.isOpen() and (bankScreen.getPackCountDTM(plankDTM) > 0)) then
begin
depositPlanks;
wait(randomrange(700, 900));
end;
if (bankscreen.isOpen() and (not bankScreen.isPackFull)) then
begin
withdrawLogs;
wait(randomrange(1300, 1500));
end;
if (bankScreen.isOpen and (bankScreen.getPackCountDTM(logDTM) <> 26) and (bankScreen.getPackCountDTM(plankDTM) > 0)) then
begin
withdrawLogs;
wait(randomrange(1300, 1500));
end;
if ((not bankscreen.isOpen()) and (tabBackpack.count() <3)) then
begin
openBank;
wait(randomrange(700, 900));
end;
if ((not bankScreen.isOpen()) and (tabBackpack.countDTM(logDTM) > 1)) then
begin
makePlanks;
end;
if ((not bankScreen.isOpen()) and (tabBackpack.countDTM(logDTM) < 2)) then
begin
openBank;
wait(randomrange(900, 1100));
end;
if ((bankScreen.isOpen()) and (bankScreen.getPackCountDTM(logDTM) > 1)) then
begin
bankClose;
wait(randomrange(1500, 1750));
end;
if ((bankScreen.isOpen()) and (not findDTM(plankDTM, x, y, 62, 82, 543, 590))) then
begin
bankScreen.close();
wait(randomrange(1500, 1750));
end;
if((bankScreen.isOpen()) and findDTM(plankDTM, x, y, 62, 82, 543, 590) and (not findDTM(logDTM, x, y, 62, 82, 543, 590))) then
begin
wait(randomrange(6000, 8000));
if (not findDTM(logDTM, x, y, 62, 82, 543, 590)) then
begin
bankScreen.close();
wait(randomrange(2000,3000));
openBank;
wait(randomrange(2000,3000));
if (not findDTM(logDTM, x, y, 62, 82, 543, 590)) then
begin
writeln('No logs in bank');
failExit;
end else
writeln('Your Internet is slow, try increasing wait times');
end else
writeln('Your Internet is slow, try increasing wait times');
end;
if((bankScreen.isOpen()) and (bankScreen.getPackCount = 2)) then
begin
withdrawLogs;
wait(randomrange(1300, 1500));
end;
//this section is a second failsafe where the script gets stuck in bankscreen
if (fails = 5) then
begin
if withdrawLogs then
begin
fails = 0;
end else
begin
if bankScreen.isOpen() then
begin
bankScreen.close();
failExit;
end else
failExit;
end;
end;
until(false);
end;
begin
smartEnableDrawing := true;
clearDebug();
setupSRL;
declarePlayers;
addonterminate('freetheDTMS');
loadDTMs;
loadPaint;
if not isLoggedIn then
players[currentplayer].login();
wait(1000);
mainloop;
wait(5000);
freethedtms;
end.
???$