PDA

View Full Version : [Results] The two Fastest Bot Competitions



Kevin
01-28-2015, 07:03 AM
The Fastest Bot Scripting Competitions RESULTS

http://puu.sh/canQ4/498c922997.jpg




Summary:


The Fastest Bot Competitions have drawn to a close. One competition for the member's and above, and a separate one for all those below. In the end, we had 3 members, 3 juniors, and 1 registered user apply. We got people who weren't familiar with scripts to work on them in the lower ranks by not requiring quality, and we got some old-timers to prove their skill in an efficiency contest for the members, and in both respects I was thoroughly impressed. I actually saw results from the winners better than i thought the best legit player could accomplish!

Each script has been graded relative to the competition. For Juniors and Registered Users, they merely needed the most logs banked within an hour. For Members, the speed was based on the fastest level 40 in mining, with additional grading metrics as quality of the scripts were analyzed. The competition marks were very, very close, however in efficiency respects, there was a very solid leader in both competitions. All of the scoring results are presented below, with Juniors' scripts included, Members are left the option to let them be public or not. Read them, learn from them, and maybe one day you will also attain the SRL Competition Cup, and the many other goodies in the hidden sections of these forums.

At the end of the day, this competition has proved 3 things:

You don’t have to write 1000 lines of code to make an amazing script (for real, only one script hit 1024 and the rest were significantly less, with the smallest at a meager 253).
Anybody can learn to code with the resources available to them, if they put their mind to it - Our Registered Member did very well!
400m is mere pocket change to Kevin :garfield: (jk I'm in debt now)







The final results:

Juniors:



1st: cosmasjdz; with 506 logs!
2nd: HKbotz; with 277.5 logs!
3rd: serajin; with 260.5 logs!
4th: Lipcot; (undorak7) with 15.5 logs!
.


Members(These are listed ALPHABETICALLY and not by score as with my scoring 2 of them are tied so I need a second judge to grade them for final results):



Foundry[/MENTION]; (undorak7): ....
riwu[/MENTION];: ....
The Mayor[/MENTION];: ....
.




Prizes:

Juniors:




Cosmasjdz: https://villavu.com/forum/images/ranks/competition.png + 120m RS3
HKbotz: 60m RS3
Serajin: 40m RS3


Members:
[INDENT]


[SIZE=3]?: https://villavu.com/forum/images/ranks/competition.png + $100 and 130m RS3
??: 60m RS3
???: 40m RS3


A big thanks to our donators: NKN (50m), Bonsai ($100), and myself (400m). And a special thanks to 3Garrett3; for not being an official judge from the beginning but helping out in the juniors comp when another judge failed to be able to help.

Please PM me, or send me a skype message to collect your prize (skype on my profile). Cup Daniel






Entries (in no particular order):



program Comp_script;

{$DEFINE SMART}
{$I SRL-6/SRL.simba}
{$I SPS/lib/SPS-RS3.Simba}

var
{Break vars}
Sbreaks, Breaks, Sleeptime, TimeOnBreak, BreakTime: integer;
breakTimer, TimeOnBreakTimer, SleepTimer: TTimeMarker;
{Proggy vars}
ItemAcquired, Profit, ProfitPerHour, LoadsDone, PriceInteger, chicken: Integer;
ItemPrice, CurrentStatus: string;

Dagger, readytochop, treetargeted, atedgeville: boolean;
p:Tpoint;
const
Debug = true;
DrawOnSmart = true;

// Script By Undorak7(Lipcot)

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'chopcompetition@hotmail.com';
password := 'bubbie';
isActive := true;
isMember := true;
World := 34;
end;
currentPlayer := 0;
end;
{------------------------------------------------------------------------------}
procedure progressReport();
begin
profit := (ItemAcquired * (PriceInteger));
profitPerHour := round((profit * 60) / (getTimeRunning() / 60000));
TimeOnBreak := round(TimeOnBreakTimer.getTime() / 60000);
if not debug then
clearDebug();
{This will appear on the Debug each time we call it}
{--------------Report----------------------------------------------------------}
writeLn('========================================= ===============');
writeLn('Progress Report');
writeLn('Time Run: ' + timeRunning);
writeLn('Items Acquired: ' + intToStr(ItemAcquired) + ' Profit Made: ' + intToStr(profit));
writeLn('Money P/H: ' + intToStr(profitPerHour));
writeLn('Time on Break: ' + intToStr(TimeOnBreak) + ' minutes ');
writeLn('Normal Breaks Taken: ' + intToStr(breaks) + ' Long Breaks Taken:' + intToStr(sbreaks));
writeLn('========================================= ===============');
{------------------------------------------------------------------------------}
end;
{------------------------------------------------------------------------------}
procedure paintOnSmart();
var
doingString, moneyphString, timeString, progressString: string;
begin

if not isLoggedIn() then
exit;
{These will be printed always we call this procedure. It will only change when the Var's change.}
TimeString:= ('Time Run: ' + timeRunning);
DoingString := 'Activity we are doing';
progressString:= ('Items Picked/Made/Acquired: ' + intToStr(ItemAcquired));
MoneyphString:= ('Gp Per Hour: ' + intToStr(profitPerHour));

smartImage.clear;
//smartImage.drawBitmap({BMP name goes here}, point(0, 327)); //if we loaded a ProggyBMP erase "//" at the beggining of line
smartImage.drawText(DoingString, point(2, 0), upChars, false, 16777215); //Top left corner, white letters
smartImage.drawText(TimeString, point(2, 13), upChars, false, 16777215);
smartImage.drawText(progressString, point(2, 26), upChars, false, 16777215);
smartImage.drawText(MoneyphString, point(2, 39), upChars, false, 16777215);
smartImage.drawText(CurrentStatus, point(2, 52), upChars, false, 16777215);
//'Current Status' is to be changed at each procedure so we know what we are doing
end;
{------------------------------------------------------------------------------}
// To be called as: antiban(400); that means 10% chance
procedure antiban(rand: integer);
begin
mousespeed := 20 + random(5);
case random(rand) of
0..12: smallRandomMouse(500 + random(150));
13..25: sleepAndMoveMouse(randomRange(600, 5500));
26..28: wait(randomRange(5000, 7000));
29..40: pickUpMouse();
end;
end;
{------------------------------------------------------------------------------}
// To be called as: longAntiban(1000); that means 10% chance.
procedure longAntiban(rand: integer);
begin
case random(rand) of
1..40: begin
writeLn('Simulating Checking Social Networks');
mouseOffClient(OFF_CLIENT_RANDOM);
wait(randomRange(30000, 40000));
pickUpMouse();
end;
41..61: begin
writeLn('Simulating Bored Human');
mouseOffClient(OFF_CLIENT_RANDOM);
wait(randomRange(6000, 8000));
pickUpMouse();
mousespeed:= 19 + random(3);
smallRandomMouse(1000 + random(500));
end;
62..100: begin
writeLn('Simulating Small afk');
sleepAndMoveMouse(750 + random(500));
wait(randomRange(5000, 8000));
pickUpMouse();
end;
end;
end;

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

wait(500);
minimap.waitPlayerMoving;
wait(500);

mousespeed:= 80;

if not (findColorsSpiralTolerance(x, y, TPA, 6658660, mainscreen.getbounds(), 25, colorSetting(2, 0.55, 0.52))) then
exit(false);

result := false;

mousespeed:= 35;

ATPA := TPA.cluster(20);
ATPA.sortFromMidPoint(mainscreen.playerPoint);

smartimage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Shopkeeper','hopkeeper'], 500) then
begin
fastclick(MOUSE_RIGHT);
if chooseoption.isOpen(1000) then
chooseoption.select(['Trade','rade'], 500);
wait(750);
minimap.waitPlayerMoving;
wait(1500);
exit(true);
end;
end;

smartimage.clearArea(mainscreen.getBounds());

end;

function buyDagger: boolean;
begin

result := false;

MOUSE(inttoBox(371, 98, 476, 127).getRandomPoint, MOUSE_LEFT);
wait(2000);
MOUSE(inttoBox(487, 319, 516, 328).getRandomPoint, MOUSE_LEFT);
wait(3000);
MOUSE(inttoBox(521, 40, 529, 48).getRandomPoint, MOUSE_LEFT);
wait(3000);

if tabbackpack.count >= 1 then
begin
result:= true;
dagger := true;
end;

MOUSE(point(600, 345), MOUSE_LEFT);
wait(3000);

end;

function handleDoor: boolean;
var
x, y, i, x2, y2: integer;
TPA, WallTPA: TPointArray;
ATPA: T2DPointArray;
begin

findColorsSpiralTolerance(x2, y2, WallTPA, 6916752, mainscreen.getbounds(), 17, colorSetting(2, 0.20, 0.29));

if not (findColorsSpiralTolerance(x, y, TPA, 4151412, GetTPAbounds(WallTPA), 11, colorSetting(2, 0.10, 0.34))) then
exit(false);

result := false;

mousespeed:= 35;

ATPA := TPA.cluster(20);
ATPA.filterBetween(0,200);
ATPA.filterBetween(800,2000);
ATPA.sortFromMidPoint(mainscreen.playerPoint);

smartimage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['pen','Open'], 200) then
begin
fastclick(MOUSE_LEFT);
wait(750);
minimap.waitPlayerMoving;
smartimage.clear;
result:= true;
break;
end;
end;

smartimage.clearArea(mainscreen.getBounds());
end;

function killchicken: boolean;
var
x, y, i, x2, y2: integer;
TPA, WallTPA: TPointArray;
ATPA: T2DPointArray;
begin

mousespeed:= 50;
result := false;

findColorsSpiralTolerance(x2, y2, WallTPA, 4874861, mainscreen.getbounds(), 9, colorSetting(2, 0.08, 0.42));
smartimage.debugTPA(wallTPA);

if not (findColorsSpiralTolerance(x, y, TPA, 3032457, GetTPAbounds(WallTPA), 27, colorSetting(2, 0.11, 0.94))) then
exit(false);

ATPA := TPA.cluster(5);
ATPA.filterBetween(0,4);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartimage.debugATPA(ATPA);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['ttack','Attack'], 200) then
begin
fastclick(MOUSE_LEFT);
wait(1550);
minimap.isPlayerMoving;
wait(randomrange(5550, 7000));
smartimage.clear;
if chatbox.findTextOnLines(['reach'], [0..0]) then
begin
typesend('0', true);
typesend('.', true);
exit(false);
end;
result := true;
exit;
end;
end;

smartimage.clear;

end;

function pickupChicken: boolean;
var
x, y, i, x2, y2, count1, count2: integer;
TPA, WallTPA, BonesTPA: TPointArray;
ATPA, ATPA2: T2DPointArray;
begin

mousespeed:= 80;
result := false;

minimap.waitPlayerMoving;

count1:= tabbackpack.count;

findColorsSpiralTolerance(x2, y2, WallTPA, 6916752, mainscreen.getbounds(), 17, colorSetting(2, 0.20, 0.29));

findColorsSpiralTolerance(x2, y2, BonesTPA, 13158847, mainscreen.getbounds(), 8, colorSetting(2, 8.38, 0.61));
ATPA2:= BonesTPA.toATPA(20);
atpa2.filterBetween(50, 5000);
smartimage.debugATPA(atpa2);


ATPA2.sortFromMidPoint(mainscreen.playerPoint);
if not (findColorsSpiralTolerance(x, y, TPA, 12303760, GetATPABounds(ATPA2), 5, colorSetting(2, 9.93, 1.67))) then
exit(false);

ATPA := TPA.cluster(10);
ATPA.filterBetween(0,5);
ATPA.filterBetween(80,1000);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartimage.debugATPA(ATPA);


for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['aw','chicken'], 200) then
begin
fastclick(MOUSE_LEFT);
wait(1550);
minimap.isPlayerMoving;
tabbackpack.waitForShift(1000);
inc(chicken);
smartimage.clear;
if count1 = count2 then
exit(false);
result := true;
exit;
end;
if isMouseOverText(['eather','Feather'], 200) then
begin
fastclick(MOUSE_LEFT);
wait(1550);
minimap.isPlayerMoving;
tabbackpack.waitForShift(1000);
MOUSE(mainscreen.playerPoint, MOUSE_LEFT);
tabbackpack.waitForShift(3000);
inc(chicken);
smartimage.clear;
count2:= tabbackpack.count;
if count1 = count2 then
exit(false);
result := true;
exit;
end;
end;

smartimage.clear;

end;
function sellStuff: boolean;
var
sold:integer;
begin


mouse(point(220, 74), MOUSE_LEFT, MOUSE_ACCURATE);
wait(1000);
repeat
mouse(point(132, 118), MOUSE_LEFT, MOUSE_ACCURATE);
wait(1000);
mouse(point(520, 278), MOUSE_LEFT, MOUSE_ACCURATE);
wait(1000);
mouse(point(497, 324), MOUSE_LEFT, MOUSE_ACCURATE);
wait(1000);
inc(sold);
result:= true;
until sold = 4;

mouse(point(526, 45), MOUSE_LEFT, MOUSE_ACCURATE);

end;

function goToShopkeeper: boolean;
var
path: TpointArray;
p: tpoint;
begin

result:= false;

repeat
lodestoneScreen.teleportTo(LOCATION_LUMBRIDGE);
wait(randomRange(16500, 17000));
until (not isLoggedIn()) or minimap.findSymbol(p, MM_SYMBOL_LODESTONE, minimap.getBounds());

{ path := [Point(282, 392), Point(268, 376), Point(257, 361), Point(244, 345), Point(215, 330)];

if sps.walkPath(path) then
begin
sps.blindWalk(point(202, 334));
result:= true;
end;}

wait(4000);

MOUSE(point(618, 25), MOUSE_LEFT);

wait(5000);
minimap.waitPlayerMoving;
result:=true;

end;
function goToAxeShop: boolean;
var
path: TpointArray;
p: tpoint;
begin

result:= false;

repeat
lodestoneScreen.teleportTo(LOCATION_LUMBRIDGE);
wait(randomRange(16500, 17000));
until (not isLoggedIn()) or minimap.findSymbol(p, MM_SYMBOL_LODESTONE, minimap.getBounds());


{path := [Point(284, 409), Point(286, 426), Point(289, 451), Point(286, 472), Point(274, 476)];

if sps.walkPath(path) then
begin
sps.blindWalk(point(265, 487));
result:= true;
end; }

wait(4000);

MOUSE(point(676, 175), MOUSE_LEFT);
wait(5000);
minimap.waitPlayerMoving;
result:=true;

end;

function targetAxeSeller: boolean;
var
TPA: TpointArray;
ATPA: T2dPointarray;
x, y, i: integer;
begin

wait(3000);

findColorsSpiralTolerance(x, y, TPA, 9606804, mainscreen.getbounds(), 6, colorSetting(2, 2.32, 0.17));

ATPA := tpa.cluster(20);
ATPA.sortFromFirstPoint(mainscreen.playerPoint);
smartimage.debugATPA(ATPA);
for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if ismouseovertext(['ob','Bob'], 500) then
begin
fastclick(MOUSE_RIGHT);
if chooseoption.select(['Trade','rade'], 500) then
begin
result:=true;
smartimage.clear;
break;
end;
break;
end;
end;
end;

function buyaxe: boolean;
begin

wait(2000);
MOUSE(point(125, 237), MOUSE_LEFT);
wait(1000);
MOUSE(point(502, 326), MOUSE_LEFT);
wait(1000);
MOUSE(point(526, 44), MOUSE_LEFT);
wait(500);

end;

function equipAxe: boolean;
var
TPA:TpointArray;
ATPA:T2dPOintARRAY;
x, y, i: integer;
begin

result:= false;

findColorsSpiralTolerance(x, y, TPA, 6249819, tabbackpack.getBounds(), 13, colorSetting(2, 0.22, 0.04));

ATPA:= TPA.cluster(7);

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if ismouseovertext(['Steel','teel','hatchet','atchet'], 500) then
begin
fastclick(mouse_right);
if chooseoption.select(['tool','ool','belt'], 500) then
begin
result:= true;
ReadyToChop := true;
dagger := true;

writeln('we are ready to go chop!');
end;
end;
end;
end;
procedure MyRandomCompass();
begin

if not isLoggedIn() then
exit;

case randomRange(1,3) of
1..1: begin
minimap.setAngle(MM_DIRECTION_WEST);
mainscreen.setAngle(MS_ANGLE_LOW);
writeLn('We Are now Facing WEST');
end;
2..2: begin
minimap.setAngle(MM_DIRECTION_SOUTH);
mainscreen.setAngle(MS_ANGLE_Low);
writeLn('We Are now Facing SOUTH');
end;
3..3: begin
minimap.setAngle(MM_DIRECTION_EAST);
if random(2) then
mainscreen.setAngle(MS_ANGLE_Low);
writeLn('We Are now Facing EAST');
end;
end;
end;
function targetTree: boolean;
var
TPA: TpointArray;
ATPA: T2dpointarray;
x,y,i,count1,count2, attempts: integer;
label
retry;
begin
retry:
mousespeed:= 100;

writeln('targeting tree');

if isMouseOverText(['Evergreen', 'vergreen'], 100) then
begin
result:= true;
treetargeted:= true;
exit;
end;

if not findColorsSpiralTolerance(x, y, TPA, 2181948, mainscreen.getbounds(), 11, colorSetting(2, 0.13, 0.44)) then
begin
myrandomcompass();
goto retry;
end;

ATPA:= Tpa.cluster(5);
ATPA.filterBetween(0,4);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartimage.debugATPA(ATPA);

for i := 1 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Evergreen', 'vergreen'], 100) then
begin
writeln('mouse is over evergreen');
result:= true;
treetargeted:= true;
smartimage.clear;
break;
end;
end;
if not treetargeted then
begin
myrandomcompass();
writeln('looking for tree again!');
inc(attempts);
if attempts <= 5 then
goto retry
else
begin
if attempts <= 7 then
sps.blindWalk(Point(239, 441));
if attempts >= 7 then
exit;
end;
end;
end;

function Chop: boolean;
var
TPA: TpointArray;
ATPA: T2dpointarray;
x,y,i,count1,count2: integer;
label
retry;
begin
repeat
mainscreen.setAngle(MS_ANGLE_HIGH);
retry:
writeln('going to chop');
if targettree then
begin
if treetargeted then
begin
wait(100);
fastClick(MOUSE_left);
treetargeted := false;
wait(500);
minimap.waitPlayerMoving();
repeat
writeln('in loop');
if not treetargeted then
targetTree;
count1:= tabbackpack.count;
wait(500);
count2:= tabbackpack.count;
if not mainscreen.isPlayerAnimating(100) then
break;
until count2>count1;
claimSpinTicket();
closeAdWindow();
end else goto retry;
end else goto retry;

until tabbackpack.isFull;

writeln('loop ended');

result := true;

end;

function gotobank: boolean;
var
p: tpoint;
begin

result:= false;

repeat
lodestoneScreen.teleportTo(LOCATION_EDGEVILLE);
wait(randomRange(16500, 17000));
until (not isLoggedIn()) or minimap.findSymbol(p, MM_SYMBOL_LODESTONE, minimap.getBounds());

sps.blindWalk(point(395, 256));
result:= true;

end;

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

begin
if not isLoggedIn() then
exit;

mousespeed:= 80;

result:= false;

findColorsSpiralTolerance(x, y, TPA, 6500939, mainScreen.getBounds(), 10, colorSetting(2, 0.40, 0.60));

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

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

for i := 0 to high(ATPA) do
begin
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['anker'], 500) then
begin
fastClick(MOUSE_LEFT);
wait(randomRange(500, 1000));
smartImage.clear;
break;
end;
end;

if bankscreen.isOpen(2000) then
begin
MOUSE(point(413, 576), MOUSE_LEFT, MOUSE_ACCURATE);
wait(200);
bankscreen.close;
if not bankscreen.isOpen(1000) then
result:= true;
end;

end;

function goToTrees: boolean;
var
path: TpointArray;
p: tpoint;
begin

writeln('going to trees');

result:= false;

path := [Point(400, 259), Point(366, 267), Point(351, 272), Point(302, 280), Point(302, 280), Point(281, 336), Point(263, 397), Point(236, 411)];

if sps.walkPath(path) then
begin
result:= true;
end;


end;
{------------------------------------------------------------------------------}
procedure doBreak();
begin

TimeOnBreakTimer.start();

if not isLoggedIn() then
exit;

CurrentStatus := ('Status: Breaking'); //Draws on smart
progressreport;
paintonsmart;

case randomRange(1,50) of
1..50: begin
clearDebug();
writeLn('Taking 10-12 minutes break');
progressreport;
paintonsmart;
players[currentPlayer].exitToLobby();
mouseOffClient(OFF_CLIENT_RANDOM);
wait(randomRange(600000, 720000));
end;
51..100: begin
clearDebug();
writeLn('Taking (12-18 minutes break');
progressreport;
paintonsmart;
players[currentPlayer].exitToLobby();
mouseOffClient(OFF_CLIENT_RANDOM);
wait(randomRange(480000, 1080000));
end;
end;

inc(breaks);
TimeOnBreakTimer.pause();
end;
{------------------------------------------------------------------------------}
procedure SleepBreak();
begin
CurrentStatus := ('Status: Sleeping Break');
progressreport;
paintonsmart;
TimeOnBreakTimer.start();
writeLn('Taking 7-8 hours "sleep" break');
players[currentPlayer].logout;
wait(randomRange(25200000, 28800000)); //7-8 hours
inc(Sbreaks);
TimeOnBreakTimer.pause();
end;
{------------------------------------------------------------------------------}
procedure GetPrice();
var
p : string;
begin
writeln('Recieving GE Prices');
p := getPage('Web Page where Price is goes here (GE page preferably)');
ItemPrice := between('Current Guide Price <span>', '</span>', p); //Place were Price is.
writeln('[ITEM NAME HERE]: ' +toStr(ItemPrice));
ItemPrice := replace(ItemPrice, ',', '', [rfReplaceAll]);
PriceInteger := strToInt(ItemPrice);
end;
{------------------------------------------------------------------------------}
procedure Setup();
begin
smartPlugins := ['d3d9.dll'];
clearDebug();
if drawonsmart then
smartEnableDrawing := true;
smartShowConsole := false;
setupSRL();
declarePlayers();
If Not Debug Then
DisableSRLDebug := True;
SPS.setup('EDGEVILLE2', RUNESCAPE_OTHER);
// SPS.setup('LUMBY_MAP', RUNESCAPE_OTHER); // If Using SPS MAP erase "//" at the beggining of the line
breaktime := randomrange(4600000, 5800000); //Time to break
sleeptime := randomrange(46800000, 54000000); // Time to do sleep break
//scriptPaintBMP := loadBitmap(appPath + '/Scripts/ImageName.png'); // If Using PAINT erase "//" at the beggining of the line
//Getprice(); //If We need to get the price of the GE erase "//" at the beggining of the line
breakTimer.start();
sleeptimer.start();
Dagger := false;
mousespeed:= 100;
{------------Colors---------------} // if using global vars for colors load them here.
{------------End-Colors-----------}
end;
{------------------------------------------------------------------------------}
procedure customLogIn();
begin
players[currentPlayer].login();
writeln('Waiting for lag to go away');
wait(randomrange(4000, 5000));
exitTreasure();
minimap.clickCompass();
mainScreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
end;
{------------------------------------------------------------------------------}
procedure mainLoop();
begin
repeat
if breakTimer.getTime() >= breaktime then
begin
doBreak();
breakTimer.reset();
breakTimer.start();
if not isLoggedIn() then
customlogin;
end;

if sleeptimer.getTime() >= sleeptime then
begin
SleepBreak;
sleeptimer.reset();
sleeptimer.start();
if not isLoggedIn() then
customlogin;
end;

if not isLoggedIn() then
customlogin;

if not Dagger then
begin
repeat
pickupchicken;
until chicken >= 15;
if gotoShopkeeper then
begin
if targetshopkeeper then
begin
sellstuff;
if goToAxeShop then
begin
repeat
targetAxeSeller;
buyaxe;
equipaxe;
until readytochop;
end;
end;
end;
end;

if not atEdgeville then
begin
repeat
lodestoneScreen.teleportTo(LOCATION_EDGEVILLE);
wait(randomRange(16500, 17000));
until (not isLoggedIn()) or minimap.findSymbol(p, MM_SYMBOL_LODESTONE, minimap.getBounds());
atedgeville:=true;
end;



if AtEdgeville then
begin
if gotoTrees then
begin
chop;
gotobank;
bankstuff;
end;
end;

until (false);
end;
{------MainLoop-------}
begin

Setup;
MainLoop;

end.
{-------The End-------}





program Woodchoppery;

{$DEFINE SMART}
{$i SRL-6/srl.simba}
{$i sps/lib/SPS-RS3.simba}

const
Debug = true;

userLogin := 'YOUR USERNAME HERE';
userPassword := 'YOUR PASSWORD HERE';

TREE_TOP_COL = 2776650;
TREE_TOP_TOL = 15;
TREE_TOP_HUE = 0.22;
TREE_TOP_SAT = 0.45;

TREE_BOT_COL = 1124383;
TREE_BOT_TOL = 6;
TREE_BOT_HUE = 0.35;
TREE_BOT_SAT = 1.00;

TREE_COL = 1387304;
TREE_TOL = 5;
TREE_HUE = 0.95;
TREE_SAT = 1.57;

TREE_INSIDE_COL = 5733553;
TREE_INSIDE_TOL = 10;
TREE_INSIDE_HUE = 0.19;
TREE_INSIDE_SAT = 1.07;

EDGEVILLE_BANKER_COLOR:= 5451333;
EDGEVILLE_BANKER_TOLERANCE:= 12;
EDGEVILLE_BANKER_HUE:= 0.53;
EDGEVILLE_BANKER_SAT:= 0.83;

var
ATPA: T2DPointArray;
LOCATION_BOX:TBox;
WALK_BOX:TBox;

bmps: Integer;

gameTime: TTimeMarker;

procedure randomMouse(chance: Integer; sleep: Boolean = false; min, max: Integer = 0);
begin
if (random(chance) = 1) then
if sleep then
begin
sleepAndMoveMouse(randomRange(min, max))
end else
begin
smallRandomMouse();
end;
end;

{----------------------------------------------------------------}
{Procedure blindWalkOne() - Walks the furthest on screen step of a blindly generated path to the point}
{Credit: Taken from SPS and modified by Garrett}
{----------------------------------------------------------------}

function blindWalkOne(pos: TPoint): boolean;
var
tries, i: integer;
ctrlPoints: TPointArray;
p: TPoint;
begin
result := false;
writeLn('', 'BlindWalkOne activating');
repeat
if (not isLoggedIn()) then
exit();
writeLn('trying p');
p := SPS.getPlayerPos();
writeLn(p);
inc(tries);

if ((tries) > 10) then
break();
until (not p.equals([-1, -1]));

if (tries <= 10) then
begin
ctrlPoints := TPABetweenPoints(p, pos, 20 + random(20), 15);
for i := high(ctrlPoints) downto 0 do
begin
result := SPS.walkToPos(ctrlPoints[i]);
if result then Exit;
end;
end;
end;

{----------------------------------------------------------------}
{Procedure stayPut() - Ensures the player does not wander too much while chopping}
{Credit: Idea by Incurable, code based on Ross's ShaftShaver, modified by Garrett}
{----------------------------------------------------------------}

procedure stayPut();
var
p: tPoint;
begin
writeLn('trying stay put');
p := SPS.getPlayerPos();
writeLn(p);
if pointInBox(p, LOCATION_BOX) then
begin
writeln('in box');
exit;
end else
begin
WriteLn('Outside of designated area, relocating');
//paintStatus('Relocating Closer to Trees');
blindWalkOne(Walk_Box.getGaussPoint());
minimap.waitPlayerMoving()
end;
end;

function isBackpackShifting(minShift, waitPerLoop, maxTime: Integer): Boolean;
var
shift: Integer;
begin
shift := getPixelShiftAverage(tabBackpack.getBounds(), waitPerLoop, maxTime);
result := shift > minShift;
writeLn('Backpack pixel shift: ' + toStr(shift));
end;

function isPlayerMoving(minShift, waitPerLoop, maxTime: Integer): Boolean;
var
shift: Integer;
begin
shift := getPixelShiftAverage(mainscreen.playerBox, waitPerLoop, maxTime);
result := shift > minShift;
writeLn('Player pixel shift: ' + toStr(shift));
end;

function GetMSPoints(x, y, color, width, height, tolerance: Integer; huem,
satm: Extended; searchArea: Tbox): TpointArray;
var
TPA: TpointArray; ATPA: T2DpointArray;
l, i, p, CTS: Integer;
begin
CTS:= GetToleranceSpeed;
SetColorToleranceSpeed(2);

SetToleranceSpeed2Modifiers(huem, satm);
SetLength(TPA, 1000);
FindColorsSpiralTolerance(x, y, TPA, color, searchArea.x1, searchArea.y1, searchArea.x2, searchArea.y2, tolerance);
SetColorToleranceSpeed(2);


ATPA:= TPAtoATPAEx(TPA, width, height);
for i:= 0 to High(ATPA) do
if Length(ATPA) > 5 then
begin
l:= getarraylength(Result);
SetArrayLength(Result, l + 1);
Result[l]:= MiddleTpa(ATPA[i]);
end;

if Length(result) = 0 then Exit;

writeLn('Found: ' + IntToStr(l) + ' Result(s)');
end;

procedure FilterTPADistTPA(var TPA1: TPointArray; const MinDist,
MaxDist: Extended; TPA2 : TPointArray);
var
c,i,j,h,hh : integer;
d : extended;
mind ,maxd :extended;
begin
h := high(TPA1);
hh := high(TPA2);
c := 0;
mind := sqr(MinDist);
maxd := sqr(MaxDist);
for i := 0 to h do
begin
for j := 0 to hh do
begin
d := sqr(TPA1[i].x - TPA2[j].x) + sqr(TPA1[i].y - TPA2[j].y);
if (d >= mind) and (d <= maxd) then
begin
TPA1[c] := TPA1[i];
inc(c);
break;
end;
end;
end;
setlength(TPA1,c);
end;


{----------------------------------------------------------------}
{Procedure openBank() - Custom bank finder because SRL banker was broken at the time}
{Credit: Garrett}
{----------------------------------------------------------------}

function OpenBank(): boolean;
var
x, y: integer;
match: extended;
TPA: TPointArray;
ATPA: T2DPointArray;
begin

if DEBUG then
writeln('trying to open bank');
//paintStatus('trying to open bank');
findColorsSpiralTolerance(x, y, TPA, EDGEVILLE_BANKER_COLOR, mainScreen.getBounds(), EDGEVILLE_BANKER_TOLERANCE, colorSetting(2, EDGEVILLE_BANKER_HUE, EDGEVILLE_BANKER_SAT));
ATPA:= SplitTPA(TPA, 15);
FilterTPAsBetween(atpa, 0, 75);
SortATPAFromMidPoint(ATPA, mainScreen.getCenterPoint);
if DEBUG then
begin
smartImage.debugATPA(ATPA);
end;
if(length(atpa) = 0) then
Exit;
if(length(atpa[0]) = 0) then
Exit;
mouse(ATPA[0].getBounds().getGaussPoint(), MOUSE_MOVE);
for x:=0 to 5 do
begin
match:= StringMatch('Bank Banker', GetMouseOverText(true));
if(match >= 0.75)then
begin
break;
end;
wait(51);
end;
if(match > 0.75)then
begin
fastClick(mouse_Left);
end else begin
//Get yo ass to the bank and restart
end;
if(BankScreen.isOpen(2500))then
begin
Result:= true;
Exit;
end;
end;


{----------------------------------------------------------------}
{Procedure toBank() - Walks to the bank and opens it}
{Credit: Mayor's SPS tutorial + heavy modification for failsafes and bank logic by Garrett}
{----------------------------------------------------------------}

function ToBank() : Boolean;
var
pathToBank: TPointArray;
p : TPoint;
begin
if not isLoggedIn() then
exit;

//paintStatus('Walking to Bank');
writeln('walking to bank');

pathToBank := [Point(114, 448), Point(145, 432), Point(156, 402), Point(160, 365), Point(163, 325), Point(174, 298), Point(183, 277), Point(190, 260), Point(197, 238), Point(224, 228), Point(243, 214), Point(272, 211)];

if not (SPS.WalkPath(pathToBank)) then
begin
writeLn('trying bank walk again');
if not (SPS.WalkPath(pathToBank)) then //Tries again (sometimes it misclicks)
begin
writeLn('trying blindWalk');
if not (SPS.blindWalk(pathToBank[high(pathToBank)])) then //Blind walk
begin
writeLn('trying to find symbol');
if minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds) then //Minimap last resort
begin
mouse(p.x, p.y, 3, 3, MOUSE_LEFT);
wait(randomRange(500,1000));
minimap.waitPlayerMoving();
wait(randomRange(500, 1000));
end;
end;
end;
end;

wait(gaussRangeInt(100,250));
minimap.waitPlayerMoving();
wait(gaussRangeInt(100,250));
writeln('at bank');
if not openBank() then //if the bank can't be opened but the walks returned true then try walking the symbol again
begin
writeln('couldn''t open bank');
if minimap.findSymbol(p, MM_SYMBOL_BANK, minimap.getBounds) then
begin
mouse(p.x, p.y, 3, 3, MOUSE_LEFT);
wait(randomRange(500,1000));
minimap.waitPlayerMoving();
end;
Result := openBank();
if not Result then
begin
//FailMe('Opening Bank');
Exit;
end;
end;
Result := True;

end;
{----------------------------------------------------------------}
{Procedure doBank() - Does the depositing and bank closing}
{Credit: Garrett}
{----------------------------------------------------------------}

function doBank() : Boolean;
begin
if not isLoggedIn() then
Exit;

if bankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY) then
begin
wait(randomRange(1000, 2000));
if not bankscreen.close() then
begin
wait(randomRange(1000, 2000));
if bankScreen.isOpen() then
if not bankScreen.close() then
begin
wait(randomRange(1000, 2000));
if bankScreen.isOpen() then
begin
//FailMe('Bank Closing');
Exit;
end;
end;
end;
//inc(LoadsDone);
//inc(Players[currentPlayer].integers[P_LOADS]);
Result := True;
end else
//FailMe('Depositing Items');
writeLn('failed');
end;

{----------------------------------------------------------------}
{Procedure toTrees() - Goes to the trees from the Bank}
{Credit: Based on The Mayor's tutorial, modified to use failsafes}
{----------------------------------------------------------------}

function toTrees() : Boolean;
var
pathToTrees: TPointArray;
begin
if not isLoggedIn() then
exit;

//pathToTrees := [Point(272, 211), Point(243, 214), Point(224, 228), Point(197, 238), Point(190, 260), Point(183, 277), Point(174, 298), Point(163, 325), Point(135, 325)];
pathtoTrees:= [Point(276, 204), Point(249, 214), Point(234, 222), Point(220, 231), Point(211, 233), Point(192, 242), Point(180, 248), Point(166, 260), Point(156, 267), Point(145, 275), Point(138, 281), Point(132, 290), Point(129, 304), Point(129, 311), Point(129, 318)];
//pathToTrees := [Point(272, 211), Point(243, 214), Point(224, 228), Point(197, 238), Point(190, 260), Point(183, 277), Point(174, 298), Point(163, 325), Point(160, 365), Point(156, 402), Point(145, 432), Point(114, 448)];

//paintStatus('Walking to Trees');
writeLn('trying to walk to trees');

Result := True;
if not (SPS.walkPath(pathToTrees)) then
if not (SPS.walkPath(pathToTrees)) then //Tries again (sometimes it misclicks)
if not (SPS.blindWalk(pathtoTrees[high(pathToTrees)])) then //Blind walk last resort
begin
Result := False;
Exit;
end;

minimap.waitPlayerMoving()
end;


function cleanTreeATPA(ATPA : T2DPointArray) : T2DPointArray;
var
TPA : TPointArray;
i, h, x, y: Integer;
begin
h := high(ATPA);
for i := 0 to h do
begin

if length(ATPA[i]) < 400 then
begin
ATPA.deleteIndex(i);
i:= i-1;
h:= h-1;
continue;
end;

findColorsSpiralTolerance(x, y, TPA, TREE_INSIDE_COL, ATPA[i].getBounds(), TREE_INSIDE_TOL, colorSetting(2, TREE_INSIDE_HUE, TREE_INSIDE_SAT));

if (length(TPA) > 20) then
begin
ATPA.deleteIndex(i);
i:= i-1;
h:= h-1;
end;
end;

Result := ATPA;
end;

function findTree() : T2DPointArray;
var
i, h, j, x, y: Integer;
TPA: TPointArray;
ATPA, ATPA2: T2DPointArray;
//Test new finding method
TPA2: TPointArray;
ATPA3, APTA4: T2DPointArray;

myBox: TBox;
begin
TPA := getMSPoints(x, y, TREE_TOP_COL, 3, 3, TREE_TOP_TOL, TREE_TOP_HUE, TREE_TOP_SAT, mainscreen.getBounds());
//findColorsSpiralTolerance(x, y, TPA, TREE_TOP_COL , mainScreen.getBounds(), TREE_TOP_TOL, colorSetting(2, TREE_TOP_HUE, TREE_TOP_SAT));
//smartImage.DrawTPA(TPA, clWhite);
TPA2 := getMSPoints(x, y, TREE_BOT_COL, 3, 3, TREE_BOT_TOL, TREE_BOT_HUE, TREE_BOT_SAT, mainscreen.getBounds());
//findColorsSpiralTolerance(x, y, TPA2, TREE_BOT_COL , mainScreen.getBounds(), TREE_BOT_TOL, colorSetting(2, TREE_BOT_HUE, TREE_BOT_SAT));
//smartImage.DrawTPA(TPA2, clBlue);

writeLn('filtering');
FilterTPADistTPA(TPA, 0, 10, TPA2);
writeLn('drawing tpa');
smartImage.DrawTPA(TPA, clGreen);
SplitTPAWrap(TPA, 5, ATPA3);
FilterTPAsBetween(atpa3, 0, 50);
SortATPAFromMidPoint(ATPA3, mainScreen.getCenterPoint);
smartImage.debugATPA(ATPA3);

//findColorsSpiralTolerance(x, y, TPA, TREE_COL , mainScreen.getBounds(), TREE_TOL, colorSetting(2, TREE_HUE, TREE_SAT));

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

//ATPA := TPA.toATPA(25);

//smartImage.debugATPA(ATPA);

//wait(5000);
//ATPA2 := cleanTreeATPA(ATPA);
//ATPA2.sortFromMidPoint(mainScreen.getCenterPoint() );

smartImage.clear();
//if Debug then smartImage.debugATPA(ATPA2);

result := ATPA3;
end;

function clickTree():boolean;
var
i, count: Integer;
ATPA: T2DPointArray;
t: TTimeMarker;
mouseText: string;
match: Extended;

begin
mouseText := getMouseOverText(true);
match:= StringMatch('Chop down Evergreen', mouseText);
if match < 0.8 then
begin
ATPA := findTree;
smartImage.debugATPA(ATPA);

if (not length(ATPA) > 0) then
begin
stayPut;
end;

if Length(ATPA) > 0 then
mouse(middleTPA(ATPA[0]), mouse_move);
mouseText := getMouseOverText(true);
match:= StringMatch('Chop down Evergreen', mouseText);
if match < 0.8 then
begin
//resolve issue about not finding tree here
blindWalkOne(Walk_Box.getGaussPoint());
minimap.waitPlayerMoving();
exit;
end;
end;

mouseText := getMouseOverText(true);
match:= StringMatch('Chop down Evergreen', mouseText);
writeLn(match);
//if Length(ATPA) > 0 then
//begin

wait(random(100));
if match >= 0.8 then
fastClick(mouse_left);
while minimap.isPlayerMoving() do
begin
wait(10);
end;
ATPA := findTree;
if inRange(1, 0, high(ATPA)) then
mouse(middleTPA(ATPA[1]), mouse_move);
wait(random(100));
//if getMouseOverText(true) = 'Chop down Evergreen' then
//begin
count := tabBackpack.count;
t.start;

//if

while tabBackpack.count = count do
begin
mouseText := getMouseOverText(true);
match:= StringMatch('Chop down Evergreen', mouseText);
if match < 0.8 then
begin
ATPA := findTree;
smartImage.debugATPA(ATPA);
if inRange(1, 0, high(ATPA)) then
mouse(middleTPA(ATPA[1]), mouse_move);
wait(25);
end;
//wait(10);
if tabBackpack.count <> count then
break;
if isPlayerMoving(20, 10, 250) = false then
break;
end;
//end;
//until isBackpackShifting(1, 10, 100) or t.getTime > 6000;
//end;
end;
//DebugPrint - If Debug is true, writes a line.
procedure DebugPrint(message: String);
begin
if(debug)then
begin
writeln(message);
end;
end;

//Logs a player in, and does standard login things.
procedure LogPlayerIn();
begin
players[currentPlayer].login();
wait(randomRange(1500, 3000));
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
mainscreen.setZoom(true);
sleepAndMoveMouse(randomRange(750, 1200));
exitTreasure;
claimTicket;
closePollWindow();
end;

//From 3Garrett3's script, antipattern
procedure Antipattern;
var
i: integer;
begin
i := random(3000);
if i < 60 then
begin
DebugPrint('Doing antiban');
case i of
1..4: begin
writeLn('Taking Mini-break');
wait(gaussRangeInt(300000,420000));
if not isLoggedIn() then
begin
LogPlayerIn();
end;
end;
5..18: begin
hoverSkill(SKILL_FARMING);
wait(gaussRangeInt(1500,5000));
gameTabs.openTab(TAB_BACKPACK);
end;
19..21: mouseMovingObject();
22..34: sleepAndMoveMouse(randomRange(100,6000));
35..45: begin
mouseOffClient(Random(4));
Wait(gaussRangeInt(10000,15000));
end;
46..53: Wait(gaussRangeInt(1000,1500));
54..60: pickUpMouse();
end;
DebugPrint('Antiban done');
end;
if(i > 2600) then
begin
mouseSpeed := gaussRangeInt(18,29);
DebugPrint('Changing mouse speed');
end;
end;

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := userLogin;
password := userPassword;
isActive := true;
isMember := false;
//secureLogin := true;
World := 0;
end;
currentPlayer := 0;
end;

//Setup program
procedure SetupProgram;
begin

//WALK_BOX := intToBox(80, 400, 140, 460);

//WALK_BOX := intToBox(100, 340, 145, 380);
//LOCATION_BOX := intToBox(80, 300, 150, 430);

LOCATION_BOX := intToBox(35, 285, 165, 374);
//WALK_BOX := intToBox( 93, 323, 116, 342);
WALK_BOX := intToBox(75, 310, 165, 350);
SetupSRL;
SPS.setup('EVERGREEN_MAP_2', RUNESCAPE_OTHER, 5, 500, 0.5);
SPSAnyAngle := False;
smartSetupDrawing;
smartEnableDrawing := true;
smartUserAgent:= 'Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.65 Safari/537.36';
mouseSpeed := gaussRangeInt(18,29);

declarePlayers();

if not isLoggedIn then
LogPlayerIn();

end;


(*
closeAdWindow
~~~~~~~~~~~~~

.. code-block:: pascal

function closeAdWindow(): boolean;

Finds and exits the wicked hood and dwarven army axe pop up ads.

.. note::

- by litoris
- Last Updated: 17 August 2013 by Coh3n

Example:

.. code-block:: pascal

closeAdWindow();
*)
function closeAdWindow(): boolean; override;
var
x, y, wid, hei, i: integer;
bmps: array [0..2] of integer;
begin
getClientDimensions(wid, hei);

// red cross color
if (not findColorTolerance(x, y, 725899, 0, 0, wid - 1, hei - 1, 25)) then
exit(false);

bmps[0] := BitmapFromString(15, 15, 'meJxjYMACuIW7sQljATyik/kk5w' +
'BJIlXySy4gqB5oO1ABj/BsoEpB6UVAEpd7ZFSmBM+57dRyBqJFTG4' +
'ekB04+xqXYDOmmRqG8wMnXcu69A+iHkgC2fZNp4BsZPOBeoFc GeXZ' +
'ptYL3fuuhh7/67b8OZA0qT0FsQVIQszn4M2GKAapV5kCVG81/6X9r' +
'r+mc55yCVTBpYAMoEqgek7eUoigiFS3Yv4pjbW/Vac8A5LSWYc5eC' +
'u5+JvBKivhLgGqB6qUzTklsvCXcPJRedV+xaKzQDZ/wl6gFBCh+VF' +
'RtUm07Bp3LMg0Eck2I9Mp4hknOLPPsXFmYw09adlaoEp2HhCS lG4C' +
'aoe4ExcAmsPOVQRBuMxEBqxsyUBlQJKgSghgZgnGKg4Aa3dqT g==');

bmps[1] := BitmapFromString(8, 8, 'meJzj5Ing4K9FR9zhQDLl6i+runMQ' +
'ESADyEVmA0k4A64RyLY++heIkAWBSDzrOEQcyEAWlFz/B0jCGUBBH' +
'vMlcDZcDVCQS6AYSCKbCRLkLwQApS1D+w==');

bmps[2] := BitmapFromString(13, 13, 'meJx9kD1LQmEYhjOlk+doiYkePw' +
'ZD1EGiSSVwcggDscFNxMFNcBQbmoKWIAR1kKLFSRLabAr8AY3 +DXE' +
'QHIRUvOyJlybh5uE5132dj/dojpruvtsf7dc5DXYjNwPzouf0dJze' +
'/l88HV+iB6cVmb06WZe+5sHEK1AcdgicVrR4pn/7OVem4+xZOUza3' +
'XvNOvDy+gOz9L1hcrva4bQ4fJ7cLmZuvJYohxZndwrXIzvxZ9 8Rkq' +
'MVk10gLc6RXraf3BMj0o69zXAk7BCpcAiycf4Ajw5/mKnKSO1wedS' +
'hraiFmu6nqfmyIJwrlm4x5RJOi0OMVPu4tYQgBEJNjs9kh8Bp cXSj' +
'EI42+AniyKGImHBanAPLFVNiseb/R3GcLSjFpv0=');

for i := 0 to high(bmps) do
if (findBitmapToleranceIn(bmps[i], x, y, 0, 0, wid - 1, hei - 1, 5)) then
begin
mouse(point(x, y).rand(3), MOUSE_LEFT);
result := true;
end;

freeBitmaps(bmps);
end;


begin

SetupProgram;


gameTime.start();

repeat
if gameTime.getTime() > 3600000 then
break;
writeLn(gameTime.getTime());
if tabBackpack.count = 28 then
begin
if ToBank then
if DoBank then
ToTrees;
end;

//findTree;
clickTree();
stayPut;
//isPlayerMoving(10, 10, 250);
closeAdWindow;
claimTicket();

until gameTime.getTime() > 3600000;
//findTree;
writeLn('done');

end.





program new; (*
\/================================================== ==========================\/
|| ||
|| program ||
|| ||
|| Description: ||
|| ||
|| ||
|| ||
|| Features: ||
|| ||
|| ||
|| ||
|| +not yet implemented ||
|| *work in progress ||
|| -complete ||
|| ||
/\================================================= ===========================/\
*)
{$DEFINE SMART}
{$i srl-6/srl.simba}
{$i SPS/lib/SPS-RS3.simba}


const (*
\/================================================== ==========================\/
|| ||
|| BEGIN SETUP ||
|| ||
/\================================================= ===========================/\
*)

//tree text
TREE_TEXT = ['Evergreen', 'vergreen', 'rgreen', 'Dead', 'ead', 'tree'];
BANK_TEXT = ['Bank', 'ank', 'ooth'];
//set debugs
SRL_DEBUG = true;
SMART_DEBUG = true;

//squeal
EXIT_SOF = true;

(*
\/================================================== ==========================\/
|| ||
|| END SETUP ||
|| ||
/\================================================= ===========================/\
*)
const
//Log levels
LOG_OFF = -1;
LOG_FATAL = 0;
LOG_ERROR = 1;
LOG_WARNING = 2;
LOG_HINT = 3;
LOG_DEBUG = 4;


var
Logs: integer = 0;
LogLvl: integer;
DTMs, BMPs: TIntegerArray;
theTimer: TTimeMarker;
ClosedAd: boolean = false;
AxBMP: integer;
LSideBoundsDTM, RSideBoundsDTM, TopBoundsDTM, OkDTM: integer;


procedure log(text: string; lvl: integer = LOG_DEBUG);
begin
if ((LogLvl < -1) or (LogLvl > 4)) then
begin
writeln('!!! Improper log settings, changing to lvl 4!!!');
LogLvl := 4;
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('!!!!!! lvl is not -1 - 4 !!!!!!'); //should be impossible to get here
end;
end;


//free dtms, bmps, log time script ran, etc.
procedure cleanup();
begin
freeBitmaps([AxBMP]);
freeDTMs([LSideBoundsDTM, RSideBoundsDTM, TopBoundsDTM, OkDTM]);
log('Logs: ' + intToStr(Logs));
log('Closed ad: ' + boolToStr(ClosedAd));
log('Time running: ' + timeRunning(TIME_SHORT));
end;


//abort script
procedure abort(reason: string);
begin
log(reason, LOG_FATAL);
cleanup();
terminateScript();
end;


procedure T2DPointArray.combine(const arr: T2DPointArray);
var
i, n: integer;
begin
for (i := 0) to (high(arr)) do
begin
n := high(self) + 1;
setLength(self, n + 1);
self[n] := arr[i];
end;
end;


//overload for mainscreen.isPlayerAnimating(), has waitTime(in ms) parameter
function TRSMainscreen.isPlayerAnimating(maxShift: integer = 300; waitTime: integer): boolean; overload;
begin
result := (getPixelShiftAverage(self.playerBox, 50, waitTime) >= maxShift);
end;


//waits waitTime(in ms) for minimap flag to go away
function TRSMinimap.waitForFlag(waitTime: integer): boolean;
var
p: TPoint;
timer: TTimeMarker;
begin
result := false;
timer.start();
repeat
if (not minimap.isFlagPresent(p)) then
exit(true);
until (timer.getTime() >= waitTime);
end;


function closeAxAd(): boolean;
var
p: TPoint;
begin
result := false;
repeat
if (findBitmapTolerance(AxBMP, p.x, p.y, 10)) then
begin
result := true;
ClosedAd := true;
mouse(p, MOUSE_LEFT);
wait(100);
end;
until (not findBitmapTolerance(AxBMP, p.x, p.y, 10));
end;


function clickOk(): boolean;
var
p: TPoint;
begin
if (findDTM(OkDTM, p.x, p.y, getClientBounds())) then
begin
mouse(p, MOUSE_LEFT);
end;
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;


procedure runToTrees();
var
treePath: TPointArray;
begin
treePath := [Point(275, 112), Point(253, 135), Point(234, 182), Point(215, 215)];
SPS.walkPath(treePath);
minimap.waitFlag();
end;


procedure runToBank();
var
bankPath: TPointArray;
begin
bankPath := [Point(206, 241), Point(234, 182), Point(253, 135), Point(275, 112)];
SPS.walkPath(bankPath);
minimap.waitFlag();
end;


function filterTrees(atpa: T2DPointArray): T2DPointArray;
var
i, c: integer;
tmpATPA: T2DPointArray;
mp, sp, tp: TPoint;
found := false;
begin
c := 0;
findDTM(LSideBoundsDTM, sp.x, sp.y, mainscreen.getBounds());
findDTM(TopBoundsDTM, tp.x, tp.y, mainscreen.getBounds());
for (i := 0) to (high(atpa)) do
begin
mp := atpa[i].getBounds().getMiddle();
if ((mp.x < sp.x) or ((mp.y < tp.y))) then
begin
log('Tree outside area we want, ignoring...');
end else
begin
setLength(tmpATPA, c + 1);
tmpATPA[c] := atpa[i];
inc(c);
end;
end;
smartImage.clear();
smartImage.debugATPA(tmpATPA);
//wait(3000);
setLength(result, length(tmpATPA));
tmpATPA.sortFromMidPoint(mainscreen.playerPoint);
result := tmpATPA;
//wait(1000);
smartImage.clear();
smartImage.debugATPA(result);
end;


function findTrees(var theATPA: T2DPointArray): boolean;
var
i, c: integer;
p: TPoint;
evergreenTPA, deadTPA: TPointArray;
tmpATPA, deadATPA, trunkATPA: T2DPointArray;
begin
result := false;
checkIfInGame();
//if (findColorsTolerance(evergreenTPA, 2176284, mainscreen.getBounds(), 6, colorSetting(2, 1.12, 1.04))) then
if (findColorsTolerance(evergreenTPA, 1911318, mainscreen.getBounds(), 3, colorSetting(2, 1.46, 2.20))) then
begin
tmpATPA := evergreenTPA.toATPA(60, 30);
tmpATPA.filterbetween(0, 200);
//theATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(tmpATPA);
//tmpEATPA := evergreenATPA;
end;
if (findColorsTolerance(deadTPA, 1978939, mainscreen.getBounds(), 6, colorSetting(2, 1.49, 4.20)))then
begin
deadATPA := deadTPA.toATPA(15, 30);
deadATPA.filterBetween(0, 75);
//deadATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(deadATPA);
end;

smartImage.clear();
tmpATPA.combine(deadATPA);
tmpATPA.sortFromMidPoint(mainscreen.playerPoint);
smartImage.debugATPA(tmpATPA);
//wait(3000);
theATPA := filterTrees(tmpATPA);
end;


function cutLogs(): boolean;
var
atpa, eATPA, dATPA: T2DPointArray;
i, c: integer;
didCut: boolean;
falsePositive := false;
timer: TTimeMarker;
begin
result := false;
while (not tabBackpack.isFull()) do
begin
if (theTimer.getTime() >= (60000 * 60)) then
abort('hour limit reached!');
findTrees(atpa);
for (i := 0) to (high(atpa)) do
begin
if (tabBackpack.isFull()) then
begin
log('Backpack is full so exiting function.');
exit(true);
end;
if (closeAxAd()) then
begin
log('Closed the stupid ad.');
break;
end;
mouse(atpa[i].getMiddle(), MOUSE_MOVE);
wait(50);
if (isMouseOverText(TREE_TEXT)) then
begin
c := tabBackpack.count();
fastClick(MOUSE_LEFT);
minimap.waitForFlag(500);
minimap.waitPlayerMoving();
timer.start();
repeat
while (mainscreen.isPlayerAnimating(100, 500)) do
begin
log('Waiting to cut log...');
if (tabBackpack.count() > c) then
begin
inc(Logs);
didCut := true;
break;
end;
end;
if (didCut) then
begin
log('Cut the tree down.');
timer.reset();
break;
end;
if (tabBackpack.count() > c) then
begin
inc(Logs);
didCut := true;
end;
if (didCut) then
begin
log('Cut the tree down.');
timer.reset();
break;
end;
until (timer.getTime() > 1000);
end;
if (didCut) then
begin
didCut := false;
break;
end else
begin
timer.reset();
end;
if (i = high(atpa)) then
begin
log('Need to reset location.');
runToTrees();
break;
end;
end;
end;
end;


function bank(): boolean;
var
woodTPA, paperTPA: TPointArray;
tmpATPA, ATPA: T2DPointArray;
i: integer;
begin
result := false;
if (not bankscreen.isOpen()) then
if (findColorsTolerance(woodTPA, 5930638, mainscreen.getBounds(), 9, colorSetting(2, 0.15, 0.49))) then
begin
tmpATPA := woodTPA.toATPA(30, 30);
atpa.filterBetween(0, 30);
smartImage.debugATPA(tmpATPA);
//wait(1000);
for (i := 0) to (high(tmpATPA)) do
begin
if (findColorsTolerance(paperTPA, 13558491, tmpATPA[i].getBounds(), 10, colorSetting(2, 0.59, 0.73))) then
begin
atpa := paperTPA.toATPA(5, 5);
atpa.filterBetween(0, 10);
atpa.sortFromMidPoint(mainscreen.playerPoint);
smartImage.clear();
smartImage.debugATPA(atpa);
if (length(atpa) > 1) then
break;
//wait(1000);
end;
end;
end;
for (i := 0) to (high(atpa)) do
begin
mouse(atpa[i].getMiddle(), MOUSE_MOVE)
if (isMouseOverText(BANK_TEXT)) then
begin
log('Found bank. Opening...');
fastClick(MOUSE_LEFT);
minimap.waitFlag();
if (bankscreen.isOpen(7000)) then
begin
log('Depositing logs...');
bankscreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
wait(random(50, 100));
bankscreen.close();
tabBackpack.waitWhileLocked();
exit(true);
end;
end;
end;
end;

//setup everything we need
procedure setup();
begin
clearDebug();
smartEnableDrawing := true;
setupSRL();
SPS.setup('burthPath', RUNESCAPE_OTHER);
mouseSpeed := 70;
LSideBoundsDTM := DTMFromString('mlwAAAHicY2dgYIhlZGBoAuJNQFwHxN1AvB qI1wGxKhCrA7EWEDsCMRsQuwGxFBDfevORobevhOHam/cMnV1FDH39pQxvv/xkuPP+E4MI0FxcmBEPhgIAbjcVXg==');
RSideBoundsDTM := DTMFromString('mlwAAAHicY2dgYNBnYmAQAOJvjAwMCkBaBI hZgZgbiMuBYp+Baj4B8SsguwCIE4F4ARDn19sxpGZFMaRlRzFU Tw1jKGkLZKjsCWZoXxbHIAJUjwsz4sFQAACyaw/x');
TopBoundsDTM := DTMFromString('mwQAAAHic42RgYMhihGBbIDYH4l4gng3EfU AcAsT5QCwCxG5ALAXEXkDsBMSKQMwKxGxA/ANoTlNPHkNNXRZD97QShtq6bCDOYmjpz2Moa0hlqO3IZcgqiWc QAaojhBmJwHAAAOcQE4g=');
OkDTM := DTMFromString('mrAAAAHic42BgYGhmYmCIA+JlQLwUiJOAuA GI9wGxNxAfB+KdQLwHiI8A8VEgXgnE+6FqDlfxMfw65czwa58F w6VuMYbTPUIMfCKSDEKScmAsArQDH2YkgGEAAM0BE74=');

AxBMP := BitmapFromString(9, 9, 'meJxLuvQ3avdHae1Z/NKTecUW8opM' +
'ArKBIkmX/vpvBZEQWR7hHrg4kNR3WwuUjTr1D0gqey6Hs4HiQGUQW' +
'Y99fyEILg40BIgknVYCBU23/AGSQDZEkJOvmlt5otqct0BxCAKygS' +
'IgccVGIFt11W8gaRa3Bc4Gigt1vpaY+QWI1G0Wqpn3AUkIFyj O0fc' +
'DSAIFpWTKuITKgSSQDREHANTuclk=');
end;


//fancy main function
procedure main();
var
atpa, atpa2: T2DPointArray;
timer: TTimeMarker;
begin
setup();
clickOk();
TheTimer.start();
checkIfInGame();
//mainscreen.setZoom(true);
minimap.clickCompass();
mainscreen.setAngle(MS_ANGLE_HIGH);
repeat
checkIfInGame();
runToTrees();
cutLogs();
repeat
runToBank();
bank();
until (not tabBackpack.isFull());
log('Time elapsed: ' + intToStr(theTimer.getTime()));
until (TheTimer.getTime() >= (60000 * 60));
cleanup();
end;




//runs script
begin
main();
end.





program WC;
{$DEFINE SMART}
{$i srl-6/srl.simba}
//{$i srl-6/lib/misc/srlplayerform.simba}
{$I SPS/lib/SPS-RS3.Simba}
var
Tripas: procedure();
x,y,sk,wt,trd: integer;
tpadtm: tpointarray;
ttt: ttimemarker;
p: tpoint;
Ge:=true;
medziuvietos: array [1..32] of tbox;
Medziucentrai: array [1..32] of tpoint;
BmpX := BitmapFromString(8, 8, 'meJzLvPE9cMNXh4i7cATkZoIFg098' +
'ApJGvieACJkLZyMLqpjuAyLLRY8d9n8FIiADIiKqshqIlOZ91 dj4A' +
'YiADIgIEAm1PgNygSScgSzIpjoFiOBc/rlvgCQTbx8cQQQBR8FgHQ==');
GeIconas := BitmapFromString(14, 8, 'meJx7tm2Oj6OtrKa+UkSualq9lJy' +
'Sgn8iEEnLKwO5QEEZDX0/F4enW2c/2jDd3cZSKyZPL79Nr6xfJSRV' +
'KSARiDTD0gzL+nXy29Wicj3tbB5umH5/7RQ3a0s1t1Cj1oUGTfMVb' +
'T2U3ENByNbTqHm+YctCFbcQD1vre2sm31nZ72ZlISunJKOiJa emo2' +
'Rm59g43ap+hoKpLZALFARKedha3V7ed2Nxl6ulmaysooK2sUX ddNe' +
'1Fz233gYiIAPIBQoCpYDOu76o89rCDohKGRkFSUkZSQlpcXFJ IAIy' +
'gFygIFAK6LyrC9qvzm+fX5k5qSh1UlFaXXKEoqIyUAqIgIy65 MhJx' +
'WlAtKg299Kc5mMTKk9MrDo+oeLkpKozU2un5CUoKCgD0bSS9L MzGk' +
'5NrjkxqRoou7+7FAD8eHgf');
Bankas:= BitmapFromString(12, 6, 'meJyzMvXi4DfiFDDmU/XSnnHMaOc' +
'n030/9NfdFzaL4RQyBUpZGntYmnhyCpqAkIAxh5ChZNsm5dZNJpve' +
'6867zK8VABQHKrAwhqrhVXDhFDFSbVkjbB2r0bLTaO0LMadso DhQg' +
'ZWpD7eIJY+so0bjFrXadbzpEwXdsw3mXTeYe13YLA4oBVRgae LNI2' +
'olpB2k1bTdcP5N42UPjJc9NJx7XTV3Hq+4DVAKqMACrAaI+OV dpH3' +
'KVRs3KxcskPGp4JWyg4gDFQAAvog8ug==');
Muzika := BitmapFromString(12, 7, 'meJyzMtDi5uaCoIMHD66GgS1btnh' +
'4uHNxcdoZ61rpa8LVrFixggMGTExMXFxcgGpsjHUt9TQE+fmA iI+X' +
'Z9myZZycHDw83Ly8PJaWlt7eXkCNNkba1gZawkJCELRgwQIeb i5BA' +
'QEg28ba2svLk5eH295Ez85IByhibm5eX18/efJkoAlioqJJSUm9vb' +
'1Au4DqncwNgWpkZaQzMzNmzJhRWlrKx8traGCwaNGirq4uMzN TIUF' +
'BB1ODtEA3TRVla0vLmOhoLS1NAX5+oJbY2FhfX19JSQkFWemM UG8A' +
'tLA6QQ==');
LogDTM := DTMFromString('mggAAAHicY2NgYHBmYmAwA+IAJgjbF4gtgL gYKFcIxRlAnALEaUAc66bJ0JhhyRBir8oQ7aIBFGECYyY4CxUz 4sAQAACgoweu');
lvl10 := DTMFromString('mrAAAAHic42BgYBBlYmCQBmJ+KJZhgog9Bs o9AuJkII4F4lQonQ7EuUAszcjA8ARI/9liypDJw84Qw8UGprn4hYCijAw/zvYyfD7ZzcAF5OHDjAQwDAAAt28OFQ==');
W:=[20,29,38,41,43,61,80,81,135,141];

procedure declarePlayers();
begin
setLength(players, 1);
with players[0] do
begin
loginName := 'woodcutercos@gmail.com';
password := 'baravykas';
isActive := true;
isMember := true;
world :=43;
end
currentPlayer := 0;
end;

procedure prisijungus();
begin
mainscreen.setZoom(true);
minimap.clickCompass();
exitTreasure();
claimSpinTicket();
closeAdWindow();
if minimap.isRunEnabled()=false then minimap.toggleRun(30);
end;

procedure dw();
var
x,y:integer;
begin
if finddtm(lvl10,x,y,mainscreen.getbounds() )then
begin
mouse(x,y,mouse_move);
fastclick(mouse_left);
end;
end;

function uzdarytiX():boolean;
var
x,y : integer;
begin
result:=false;
if findBitmapToleranceIn(bmpX, x, y,mainscreen.getbounds(), 15) then
begin
writeln('judam');
mouse(x+random(0,3),y+random(0,3),mouse_move);
writeln('judam1');
fastclick(mouse_left);
writeln('judam2');
result:=true;
end;
end;

function Pasisneleti():boolean;
begin
result:=false;
Mouse(289+random(0,2), 165+random(0,2),mouse_move);
fastclick(Mouse_right);
chooseoption.isOpen(1000);
Chooseoption.select(['Grand Exchange Tutor','Grand','Tutor','Exchange']);
ConversationBox.isOpen(1000);
repeat
conversationBox.continue(true, true);
until length(conversationBox.getOptions())>2;
ConversationBox.selectOption(['I want the basics from you.','want the basics','the basics from you.','Can you teach me about the Grand']);
repeat
conversationBox.continue(true, true);
until not ConversationBox.isOpen(1000);
writeln('Pasisnekejom :D');
result:=true;
end;

function NueitiGe():boolean;
var
x,y,i :integer;
ba:=[GeIconas,Bankas,Muzika];
begin
result:=false;
minimap.clickCompass();
if tabbackpack.count()>=21 then sps.blindWalk(point(214,110));
wait(1000);
for i:=0 to 2 do
begin
if findBitmapToleranceIn(ba[i],x,y,inttobox(581, 16,795,105),6) then
begin
mouse(x,y,mouse_move);
fastclick(mouse_left);
result:=true;
wait(1000);
Minimap.waitplayermoving();
exit;
end ;
end;
mouse(693, 29,mouse_move);
fastclick(mouse_left);
result:=true;
writeln('Ge failsafexxxxxxxxxxxxxxxxxxxx');
end;

function SurastiKlerka():boolean;
var
x,y,i,iz:integer;
tpa,tpadtm: TPointArray;
atpa: T2DPointArray;
begin
result:=false;
If tabbackpack.islocked() then
begin
result:=true;
exit;
end;
findColorsSpiralTolerance(x, y, TPA, 3283753, mainScreen.getBounds(), 10, colorSetting(2,0.60,0.98));
if length(TPA) < 1 then minimap.setangle(random(trunc(minimap.getangledegr ees())+20));
ATPA := TPA.toATPA(20,20);
ATPA.filterBetween(0, 6);
ATPA.sortFromMidPoint(mainscreen.playerPoint);
smartimage.debugtpa(tpa);
smartImage.debugATPA(ATPA);
if (length(ATPA) < 1) then exit
else
begin
for i := 0 to high(ATPA) do
begin
if bankscreen.isOpen() then exit;
mouse(middleTPA(ATPA[i]), MOUSE_MOVE);
if isMouseOverText(['Grand','Exchange','Grand Exchange clerk','Exchange Grand Exchange clerk','Exchange','Exchanqe'], 500) then
begin
fastclick(MOUSE_right);
if chooseoption.isOpen(1000) then ChooseOption.select(['Exchange Grand','Exchanqe Grand']) else exit;
for iz:=0 to 6 do
begin
wait(750);
if tabbackpack.islocked() then
begin
Result:=true;
Writeln('Ge screen Open');
exit;
end

end;
end;
end;
end;
minimap.setangle(random(trunc(minimap.getangledegr ees())+35));
end;

Procedure Gescreen();
var
t: ttimemarker;
begin
t.start();
repeat
wait(250);
if t.gettime()>40000 then exit;
until SurastiKlerka();
end;

Procedure pasiimti();
var
x,y: integer;
begin
mouse(145, 155,mouse_move);
fastclick(mouse_left);
wait(2000);
mouse(452, 326,mouse_move);
fastclick(mouse_left);
mouse(503, 324,mouse_move);
fastclick(mouse_left);
wait(2500);
end;
function ParduotiLogs():boolean;
var
x,y,i: integer;
tpa: tpointarray;
atpa: t2dpointarray;
begin
result:=false;
Mouse(570+random(0,2), 87+random(0,2),mouse_move);
fastclick(Mouse_left);
wait(1000);
if findcolortolerance(x,y,3455994 ,inttobox(144, 296,436, 341),10) then
begin
mouse(144, 243,mouse_move);
fastclick(mouse_left);
wait(1000);
for i:=0 to 2 do
begin
mouse(320, 243,mouse_move);
fastclick(mouse_left);
wait(500);
end;
mouse(287, 328,mouse_move);
fastclick(mouse_left);
wait(3000);
If findcolortolerance(x,y,1999423 ,inttobox(123, 182,205, 198),10) then Pasiimti();
end;
end;

Procedure Nusipirkti(axe: integer);
var
x,y: integer;
begin

mouse(90, 152,mouse_move);
fastclick(mouse_left);
wait(3500);
if axe=0 then SendKeys('steel hat',100,50) else SendKeys('mithril hat',100,50);
wait(5000);
mouse(139, 444,mouse_move);
fastclick(mouse_left);
wait(2000);
mouse(101, 243,mouse_move);
fastclick(mouse_left);
wait(500);
mouse(417, 245,mouse_move);
fastclick(mouse_left);
wait(2000);
if axe=0 then typeSend('1k') else typesend('2k');
wait(2000);
mouse(287, 328,mouse_move);
fastclick(mouse_left);
wait(2500);
end;

function pasiimtif():boolean;
var
x,y: integer;
t: ttimemarker;
begin
result:=false;
t.start();
repeat
wait(100);
if t.gettime()>5000 then exit;
until findcolortolerance(x,y,1999423,inttobox(65, 176,202, 199),15);
result:=false;
mouse(145, 155,mouse_move);
fastclick(mouse_left);
t.start();
repeat
wait(100);
if t.gettime()>5000 then exit;
until findcolortolerance(x,y,1999423,inttobox(96, 308,409, 346),15);
mouse(452, 326,mouse_move);
fastclick(mouse_left);
mouse(503, 324,mouse_move);
fastclick(mouse_left);
result:=true;
end;

function ParduotiLogsf():boolean;
var
x,y,i: integer;
tpa: tpointarray;
atpa: t2dpointarray;
t: ttimemarker;
begin
result:=false;
Mouse(570+random(0,2), 87+random(0,2),mouse_move);
fastclick(Mouse_left);
t.start();
repeat
wait(100);
if t.gettime()>5000 then exit;
until findcolortolerance(x,y,3718906, inttobox(190, 299,384, 343),15);
mouse(226, 243,mouse_move);
fastclick(mouse_left);
t.start();
repeat
wait(100);
if t.gettime()>5000 then exit;
until findcolortolerance(x,y,16777215, inttobox(248, 269,266, 281),15);
for i:=0 to 2 do
begin
mouse(320, 243,mouse_move);
fastclick(mouse_left);
wait(250);
end;
mouse(287, 328,mouse_move);
fastclick(mouse_left);
t.start();
repeat
wait(100);
if t.gettime()>5000 then exit;
until findcolortolerance(x,y,1999423 ,inttobox(123, 182,205, 198),10);
Pasiimtif();
end;

Procedure Nusipirktif(axe: integer);
var
x,y: integer;
t: ttimemarker;
begin
mouse(90, 152,mouse_move);
fastclick(mouse_left);
t.start();
repeat
wait(100);
if t.gettime()>5000 then exit;
until findcolortolerance(x,y,3718906, inttobox(190, 299,384, 343),15);
wait(250);
if axe=3 then SendKeys('adamant hat',100,50);
//if axe=0 then SendKeys('steel hat',100,50) else SendKeys('mithril hat',100,50);
wait(5000);
mouse(139, 444,mouse_move);
fastclick(mouse_left);
wait(2000);
mouse(101, 243,mouse_move);
fastclick(mouse_left);
wait(500);
mouse(417, 245,mouse_move);
fastclick(mouse_left);
wait(2000);
//if axe=0 then typeSend('1k') else
typesend('4k');
wait(2000);
mouse(287, 328,mouse_move);
fastclick(mouse_left);
end;

function idetiitoolbelta(): boolean;
var
t: ttimemarker;
begin
t.start();
repeat
wait(350);
if t.gettime()>5000 then exit;
until tabbackpack.isLocked()=false;
wait(575);
mousebox(tabbackpack.getSlotBox(1));
fastclick(Mouse_right);
chooseoption.isOpen(1000);
if chooseoption.optionsExist(['Add to tool belt','Add','dd'])=false then
begin
exit;
end;
chooseoption.select(['Add to tool belt','Add','dd']);
result:=true;
end;

function Apsiprekinti():boolean;
begin
result:=false;
Gescreen();
ParduotiLogsf();
Nusipirktif(3);
// pasiimtif();
// wait(750);
// Nusipirktif(1);
pasiimtif();
wait(1000);
multiType(VK_ESCAPE, 200, 1);
wait(2500);
if tabbackpack.islocked() then multiType(VK_ESCAPE, 200,1);
if idetiitoolbelta()=false then
begin
exit;
end;
result:=true;
end;
procedure ApsiprekintiFailsafe();
var
t:ttimemarker;
begin
NueitiGe();
t.start();
repeat
if t.getTime()>180000 then break;
until Apsiprekinti();
minimap.clickCompass();
mouse(667, 183,mouse_move);
fastclick(Mouse_left);
wait(1500);
minimap.waitPlayerMoving();
sps.getPlayerPos();
wait(5000);
sps.blindwalk(point(268,142));
ge:=false;
end;
procedure Bank(); //Banking procedure
var
x, y, i : integer;
TPA: TPointArray;
ATPA: T2DPointArray;
btm: ttimemarker;
begin
if not Isloggedin() then exit;
begin
FindColorsSpiralTolerance(x, y, TPA, 10673123, mainScreen.getBounds(), 2, colorSetting(2, 0.26, 2.06));
ATPA:= TPA.toATPA(20, 20);
ATPA.filterBetween(0, 3);
smartimage.debugtpa(tpa);
smartImage.debugATPA(ATPA);
if length(atpa)<1 then exit;
for i:= 0 to high(ATPA) do
begin
Mouse(middleTPA(ATPA[i]), Mouse_move);
if isMouseOverText(['Donate', 'odwill', 'ell'], 500) then
begin
Fastclick(Mouse_right);
Chooseoption.isOpen(1000);
ChooseOption.select(['Bank', 'Open Bank']);
if Bankscreen.isopen(5000)= true then exit else
begin
writeln('Neisejo bank pagrindinis');
exit;
end;
end;
end;
minimap.setangle(random(trunc(minimap.getangledegr ees())-45));
end;
end;

procedure Apsibankinti();
var
t,tf: ttimemarker;
begin
mouse(410, 574,3,3,mouse_move);
t.start();
repeat
wait(50);
until ((t.getTime()>8500) or (tabbackpack.islocked()));

//if not tabbackpack.islocked() then
//begin
// repeat
// Bank();
// until tabbackpack.islocked();
// end
// BankScreen.quickDeposit(QUICK_DEPOSIT_INVENTORY);
if t.getTime()>8500 then exit;
fastclick(mouse_left);
//BankScreen.close();
multiType(VK_ESCAPE, 200, 1);
tf.start();
repeat
wait(50);
if tabbackpack.isLocked()=false then exit;
until tf.getTime()>=750;
writeln('LOCKEEEEEEEEEEEEEEEEEEEEEEEEEEEEEEED');
wait(250);
if tabbackpack.isLocked() then multiType(VK_ESCAPE, 200, 1);
end;
//cleanup credits to keepbotting, althrough i modified it abit
function cleanUp(theATPA : T2DPointArray) : T2DPointArray;
var
Taskas : TPoint;
TTPA : TPointArray;
rBoundary : TBox;
cleanTime : TTimeMarker;
i, h : Integer;
begin
cleanTime.start();
h := high(theATPA);
for i := 0 to h do
begin
if length(theATPA[i]) < 250 then
begin
theATPA.deleteIndex(i);
i:= i-1;
h:= h-1;
continue;
end;
rBoundary := theATPA[i].getBounds();
findColorsSpiralTolerance(Taskas.x, Taskas.y, TTPA, 5069149, rBoundary, 12, colorSetting(2, 0.38, 0.42));
if (length(TTPA) > 20) then
begin
theATPA.deleteIndex(i);
i:= i-1;
h:= h-1;
end;
end;
Result := theATPA;
writeln(cleantime.gettime());
end;

function RastiKamiena(kur: tbox):tpoint;
var
x, y, i : integer;
TPA: TPointArray;
ATPA,cleanatpa: T2DPointArray;
b:=point(1,1);
begin
result:= b; // pirmi 3 2705243, mainScreen.getBounds(), 5, colorSetting(2, 0.31, 0.47
FindColorsSpiralTolerance(x, y, TPA, 2574432, kur, 15, colorSetting(2, 0.31, 0.47));
ATPA := TPA.toATPA(70);
cleanATPA := cleanUp(ATPA); //4
cleanatpa.sortFromMidPoint(mainscreen.playerPoint) ;
if length(cleanatpa)<1 then exit;
smartImage.debugATPA(cleanATPA);
result:=middletpa(cleanatpa[0]);
end;

function RastiKamienaT(kur,kur1,kur2,kur3: integer):tpoint;
var
x, y, i : integer;
TPA: TPointArray;
ATPA,cleanatpa: T2DPointArray;
b:=point(1,1);
begin
result:= b; // pirmi 3 2705243, mainScreen.getBounds(), 5, colorSetting(2, 0.31, 0.47
FindColorsSpiralTolerance(x, y, TPA, 3815973, inttobox(kur,kur1,kur2,kur3), 7, colorSetting(2, 9.67, 2.15));
ATPA := TPA.toATPA(35);
cleanATPA := cleanUp(ATPA); //4
cleanatpa.sortFromMidPoint(mainscreen.playerPoint) ;
//smartimage.debugtpa(tpa);
smartImage.debugATPA(cleanATPA);
result:=middletpa(cleanatpa[0]);
end;

function prehover(Medi :integer):boolean;
begin
result:=false;
if medi=4 then //Jei reikia spaust minimape
begin
Mouse(629, 121,mouse_move);
result:=true;
exit;
end;
mouse(MedziuCentrai[medi],mouse_move);
end;

function krc(medis:integer):boolean;
var
i: integer;
begin
result:=false;
mouse(MedziuCentrai[medis],mouse_move);
if ismouseovertext(['Chop down Tree','Tree','ree','Chop down','Chop'])
then
begin
fastclick(Mouse_left);
result:=true;
exit;
end else
begin
mouse(RastiKamiena(inttobox(20,20,200,200)),mouse_ move);
if ismouseovertext(['Chop down Tree','Tree','ree','Chop down','Chop']) then fastclick(mouse_right);
wait(1200);
chooseoption.select(['Chop']);
result:=true;
end;
end;

Function PerfectTrip(): boolean;
var
i: integer;
lt, t5,t6,t10,tmtm: ttimemarker;
begin
writeln('Slow');
if not isloggedin() then players[0].login();
if not krc(1) then
begin
result:=false;
exit;
end;

for i:=1 to 28 do
begin
writeln(tostring(i));
prehover(i+1);
tabbackpack.waitForShift(wt);
if uzdarytiX() then prehover(i+1);
if trd<2 then
begin
dw();
prehover(i+1);
end;
if i=3 then
begin
fastclick(mouse_left);
wait(3000);
minimap.waitPlayerMoving();
wait(750);
mouse(rastikamiena(inttobox(185, 191,322, 258)),mouse_move);
end;
If i=28 then
begin
if ismouseovertext(['Donate','odwill','ell']) then fastclick(Mouse_right) else
begin
tmtm.start();
repeat
wait(100);
if tmtm.gettime()>3500 then break;
until ismouseovertext(['Donate','odwill','ell']);
fastclick(mouse_right);
end;
if chooseoption.isOpen(1200) then
begin
if chooseoption.optionsExist(['Open Bank','Bank','Open']) then chooseoption.select(['Open Bank','Bank','Open']) else
begin
wait(1250);
prehover(i+1);
fastclick(mouse_right);
if chooseoption.isOpen(1200) then chooseoption.select(['Open Bank','Bank','Open']);
end;
end;
break;
end;
if ((tabbackpack.count()>=21) and (ge=true)) then
begin
ApsiprekintiFailsafe();
bank();
break;
end;
if tabbackpack.isFull() then
begin
sps.blindwalk(point(268,142));
bank();
break;
end;
if ismouseovertext(['Chop down Tree','Tree','ree','Chop down','Chop']) then
begin
fastclick(Mouse_left);
end
else
begin
writeln('laukiam');
lt.start();
repeat
wait(50);
if ismouseovertext(['Chop down Tree','Tree','ree','Chop down','Chop']) then
begin
fastclick(Mouse_left);
break();
end
until lt.getTime()>=3800;
if lt.getTime()>=3800 then
begin
result:=false;
exit;
end;
end;
end;

Apsibankinti();
minimap.clickCompass();
claimspinticket();
result:=true;
inc(trd);
end;
function nusitaiko():tpoint;
var
x, y,i : integer;
TPA: TPointArray;
ATPA: T2DPointArray;
t: tpoint;
k,m: extended;
xv,yv,ml: integer;
begin
result:=point(-1,-1);
findColorsSpiralTolerance(x, y, TPA, 518375, minimap.getbounds(), 8, colorSetting(2,0.23, 0.74));
if length(TPA) < 1 then
ATPA := TPA.toATPA(2, 2);
ATPA.sortFromMidPoint(minimap.getCenterPoint());
t:=minimap.getCenterPoint();
if high(tpa)=-1 then
begin
writeln('No such type dots found on the minimap, quiting procedure');

exit;
end;
SortTPAFrom(TPA, t);
result:=tpa[0];
smartimage.drawCross(tpa[0],5,255);
end;
function elis():tbox;
begin
result:=inttobox(0,0,400,300);
if pointinbox((minimap.pointtomainscreen(nusitaiko()) ),mainscreen.getbounds()) then begin
smartimage.drawbox(inttobox(minimap.pointtomainscr een(nusitaiko()).x-35,minimap.pointtomainscreen(nusitaiko()).y-35,minimap.pointtomainscreen(nusitaiko()).x+35,min imap.pointtomainscreen(nusitaiko()).y+35),255);
result:=inttobox(minimap.pointtomainscreen(nusitai ko()).x-35,minimap.pointtomainscreen(nusitaiko()).y-35,minimap.pointtomainscreen(nusitaiko()).x+35,min imap.pointtomainscreen(nusitaiko()).y+35);
end;
end;
function surastigalva():boolean;
var
x,y:integer;
TPA: TPointArray;
ATPA: T2DPointArray;
i: integer;
begin
result:=false;
for i:=0 to 15 do
begin
wait(350);
findcolorsspiraltolerance(x,y,tpa,3622482,elis(),8 ,colorSetting(2,0.63, 1.45));
if length(TPA) < 1 then continue;
atpa:= clustertpa(tpa, 4);
atpa.filterBetween(0, 15);
if length(atpa)<1 then continue;
smartImage.debugTPA(TPA,true);
SmartImage.debugATPA(atpa);
mouse(middleTPA(ATPA[0]).x,middleTPA(ATPA[0]).y,mouse_move);
if (isMouseOverText(['Talk','Ellis','llis'], 500))then fastclick(mouse_right);
if chooseoption.optionsexist(['Tan hide','hide']) then
begin
chooseoption.select(['Tan hide','hide']);
result:=true;
exit;
end;
end;
writeln('failed to find tanner');
end;
begin
{$IFDEF SMART}
//smartPlugins := ['d3d9.dll'];
clearDebug();
smartShowConsole := false;
smartEnableDrawing := True;
{$ENDIF}

clearDebug();
declareplayers();

setupSRL();

ttt.start();
case isloggedin() of
false: begin
players[0].logintolobby();
players[0].switchToworld(43);
end;
true: players[0].switchToworld(43);
end;


sps.setup('wood',runescape_other,3,150,0.45);

MedziuVietos[1]:=[98,76,200,183];
MedziuVietos[2]:=[1,1,90,107];
MedziuCentrai[1]:=[148,141];
MedziuCentrai[2]:=[141, 112];
MedziuCentrai[3]:=[123, 218];
MedziuCentrai[5]:=[126, 226];
MedziuCentrai[6]:=[97, 245];
MedziuCentrai[7]:=[232, 260];
MedziuCentrai[8]:=[178, 223];
MedziuCentrai[9]:=[247, 164];
MedziuCentrai[10]:=[119, 248];
MedziuCentrai[11]:=[183, 292]; ///////
MedziuCentrai[12]:=[170, 208];
MedziuCentrai[13]:=[223, 136];
MedziuCentrai[14]:=[335, 191];
MedziuCentrai[15]:=[209, 125];
//MedziuCentrai[16]:=[402, 213]; /// Jei Yra kelmas tada tik kertam sita nes kiti uzstoja
MedziuCentrai[16]:=[346, 143]; //smulkus sitas butinai failsafe 287,121
MedziuCentrai[17]:=[241, 116];
MedziuCentrai[18]:=[341, 148];//smulkus
MedziuCentrai[19]:=[351, 205]; //smulkus
MedziuCentrai[20]:=[503, 165]; //smulkus
MedziuCentrai[21]:=[398, 283]; //gana smulkus
MedziuCentrai[22]:=[395, 352]; //gali but dar nespawnines
MedziuCentrai[23]:=[559, 220];
MedziuCentrai[24]:=[543, 351];
MedziuCentrai[25]:=[408, 276];
MedziuCentrai[26]:=[470, 193];
MedziuCentrai[27]:=[552, 145];
MedziuCentrai[29]:=[502, 143]; //Bankas
MedziuCentrai[28]:=[319, 93];
MedziuCentrai[31]:=[346, 143 ]; //praleidzia 16 medi 319, 93
sk:=0;




prisijungus();
Pasisneleti();
mouse(668, 193,mouse_move);
fastclick(Mouse_left);
uzdarytiX(); //veikia su steel hatchet
sps.blindwalk(point(268,142));
tabbackpack.open();
BANK();
Apsibankinti();
wait(2000);
wt:=35000;
trd:=0;
repeat
if PerfectTrip()=false then
begin
players[0].switchtoworld(W[sk]);
if not isloggedin() then players[0].login();
prisijungus();
sps.blindwalk(point(268,142));
BANK();
Apsibankinti();
minimap.clickCompass();
inc(sk);
if sk>=10 then sk:=0;
end;
if trd>=1 then
begin
case trd of
1..4: wt:=21500;
5..9: wt:=13000;
10..14: wt:=10500;
15..18: wt:=7500;
19..80: wt:=5500;
end;
end;
writeln(tostr(trd));
smartimage.clear();
until ttt.gettime()>=3600000;

end.