SRL Archive - Jr. Member General Help and Discussion

[Dev Log] Advanced Gnome Agility RS3 (Barb eventually)


Brotein

2014-06-10 09:45:58

Kind of had a crash in motivation with runescape the past few months but once again I'm bored at work looking to make a new script. So I'm working on an advanced gnome course runner, and I'll add in barbarian afterwards since it will be easy to just add in the extra procedures. Got the logic all worked out with failsafes but I'm having just a few problems.

First problem:
Thinking of a reliable way to check if an obstacle has been done. Original thought was to use Ash's CheckXp function and compare the xp before and after the doObstacle function in my script. That has been unreliable in the past with misread xp so I don't want to use that. My new thought is to use a TPA search for the xp drop popup. That is, search for the color(inside a specific region) of the xp that appears in the center and scrolls up the screen(or is it down I forget hah). So in short minus the failsafes.

doObstacle;
repeat
wait;
until(xpDrop);
Thoughts on doing it this way?

Second Problem:
The colors can be a bit tricky to get to be unique on this course. My main issue is searching for the first and second branch with UNIQUE colors. The log balance is also a little bit tricky because of it's small click area. If anyone could help me get some reliable unique colors for those 3 obstacles(or all of them if you think they are good enough) I would really appreciate the help. I have working colors just those 3 will pick up other objects first before the correct uptext is found.

I'll post up the script progress as it comes along.

Ashaman88

2014-06-10 11:00:34

I stopped b/c I was bored awhile ago… but if you want any ideas here is one I had come up with and was like 90% done… from what i remember I was still tweaking positioning, but who knows if the colors have changed since then.

Program AshamanGnomeAgility;
{$IFDEF RAYMONDPOWNS}{wrappers} function FloodFillTPAWrap(const TPA: TPointArray): T2DPointArray; var tempATPA: T2DPointArray; begin tempATPA:= FloodFillTPA(TPA); Result:= tempATPA; SetLength(tempATPA, 0); end; function FindTPAEdges(const p: TPointArray): TPointArray; begin FindTPAEdgesWrap(p, result); end; Function RotatePoints(Const P: TPointArray; A, cx, cy: Extended): TPointArray; begin RotatePointsWrap(P, A, cx, cy, result); end; function TPAFromCircle(const CX, CY, Radius: Integer): TPointArray; begin TPAFromCircleWrap(CX, CY, Radius, result); end; function TPAFromEllipse(const CX, CY, XRadius, YRadius : Integer): TPointArray; begin TPAFromEllipseWrap(CX, CY, XRadius, YRadius, result); end; function TPAFromBox(const Box : TBox) : TPointArray; begin TPAFromBoxWrap(Box, result); end; Function ReturnPointsNotInTPA(Const TotalTPA: TPointArray; const Box: TBox): TPointArray; begin ReturnPointsNotInTPAWrap(TotalTPA, Box, result); end; function CombineIntArray(const Ar1, Ar2: TIntegerArray): TIntegerArray; begin CombineIntArrayWrap(Ar1, Ar2, result); end; function ReArrangeandShortenArray(const a: TPointArray; Dist: Integer): TPointArray; begin ReArrangeandShortenArrayWrap(a, Dist, result); end; function ReArrangeandShortenArrayEx(const a: TPointArray; w, h: Integer): TPointArray; begin ReArrangeandShortenArrayExWrap(a, w, h, result); end; function CombineTPA(const Ar1, Ar2: TPointArray): TPointArray; begin CombineTPAWrap(Ar1, Ar2, Result); end; function RemoveDistTPointArray(x, y, dist: Integer;const ThePoints: TPointArray; RemoveHigher: Boolean): TPointArray; begin RemoveDistTPointArrayWrap(x, y, dist, ThePoints, RemoveHigher, Result); end; function TPAFromText(const text, font: String; var w,h: Integer): TPointArray; begin TPAFromTextWrap(text, font, w, h, result); end; function GetColors(const Coords: TPointArray): TIntegerArray; begin GetColorsWrap(Coords, Result); end; function Explode(del, str: string): TStringArray; begin ExplodeWrap(del, str, Result); end; function MergeATPA(const ATPA : T2DPointArray): TPointArray; begin MergeATPAWrap(ATPA, Result); end; function SplitTPA(arr : TPointArray; dist : Integer) : T2DPointArray; begin SplitTPAWrap(arr, dist, result); end; function SplitTPAEx(arr : TPointArray; w, h : integer) : T2DPointArray; begin SplitTPAExWrap(Arr, w, h, result); end; function ClearTPAFromTPA(arP, ClearPoints : TPointArray) : TPointArray; begin ClearTPAFromTPAWrap(arP, ClearPoints, result); end; function TPAToATPAEx(arP : TPointArray; w, h : integer) : T2DPointArray; begin TPAtoATPAExWrap(arP, w, h, result); end; function TPAToATPA(arP : TPointArray; dist : Integer) : T2DPointArray; begin TPAtoATPAWrap(arP, dist, result); end; function FindGapsTPA(TPA : TPointArray; MinPixels : integer) : T2DPointArray; begin FindGapsTPAWrap(tpa, MinPixels, result); end; {$ENDIF}
{$Define SMART}
{$I SRL-6/SRL.Simba}
{$i srl-6/lib/misc/srlplayerform.simba}
{$I SPS/lib/SPS-RS3.Simba}

function TRSChatBox.getXP: Integer;
var
b: TBox;
s: String;
tpa : TPointArray;
atpa : T2DPointArray;
i,cts,p,p2: Integer;
begin
b := self.getBounds();
b.edit(+(b.x2-b.x1)-140, +10, -5, -94);

findColorsTolerance(tpa, 14013909, b, 4,colorSetting(2, 0.00, 0.00));

if length(tpa) < 2 then
begin
print('chatBox.getXP(): No XP found', TDebug.SUB);
Exit;
end;

atpa := tpa.cluster(10);
atpa.sortFromFirstPoint(point(b.x2,b.y2));

b:= atpa[low(atpa)].getbounds;
b.edit(-2,-2,+2,+3);

s:=Replace(tesseractgettext(b.x1,b.y1,b.x2,b.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);

P := Pos('x', S);
P2 := Pos('X', S);
if (P > 0) Or (P2 > 0) then
Result := StrToIntDef(ExtractFromStr(Copy(s, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);

print('chatBox.getXP(): XP found: ' + tostr(result), TDebug.SUB);
end;

function waitXPChange(startingXP: integer; waitTime: Integer = 2000): boolean;
var
t: TTimeMarker;
begin
t.start;
repeat
wait(50 + random(100));

if startingXP <> chatBox.getXP then
begin
print('XP has changed');
exit(true);
end;
until t.getTime > waitTime;
end;

type
TObstacle = record
obstacleName: string;
obstacleNumber: integer;
obstacleCoords: TBox;
startAngle: integer;
customSearchBounds: boolean;
searchBounds: TColorData;
obstacleColor: TColorData;
cluster: boolean;
tpaWidth: Integer;
tpaHeight: Integer;
filterHigh: integer;
filterLow: integer;
sortBySize: boolean;
sortFrom: TPoint;
objectPart: string;
mouseOverText: TStringArray;
nextAction: TBox;
nextCamera: Integer;
end;

TObstacleArray = array of TObstacle;

Const
CROSS_LOG: TObstacle = ['Cross Log', 0, [140, 130, 179, 160], MM_DIRECTION_NORTH, true, [3620167, 7, [2, [0.10, 0.26, 0.00]]], [3692141, 15, [2, [0.03, 0.09, 0.00]]], +
false, 5, 20, 0, 10, false, [293, 219], 'Top', ['balance', 'alan', 'cross', 'Log'], [177, 308, 358, 317], MM_DIRECTION_NORTH];

CLIMB_NET: TObstacle = ['Climb Net', 1, [140, 175, 185, 205], MM_DIRECTION_NORTH, false, [3620167, 7, [2, [0.10, 0.26, 0.00]]], [6455450, 1, [2, [0.27, 0.62, 0.00]]], +
true, 5, 20, 0, 10, false, [273, 311], '', ['net', 'Climb', 'stacle', 'Obs'], + [275, 154, 279, 167], MM_DIRECTION_SOUTH];

CLIMB_BRANCH_1: TObstacle = ['Climb Branch 1', 2, [570, 470, 600, 490], MM_DIRECTION_SOUTH, false, [1584956, 4, [2, [0.44, 0.43, 0.00]]], [6385790, 8, [2, [0.06, 0.07, 0.00]]], +
true, 5, 20, 0, 10, false, [284, 141], 'Bottom', ['Tree', 'Climb', 'anch', 'bran'], [321, 157, 324, 171], MM_DIRECTION_SOUTH];

CLIMB_BRANCH_2: TObstacle = ['Climb Branch 2', 3, [160, 510, 190, 535], MM_DIRECTION_SOUTH, false, [1584956, 4, [2, [0.44, 0.43, 0.00]]], [1650492, 4, [2, [0.45, 0.35, 0.00]]], +
true, 5, 20, 0, 10, false, [291, 192], 'MidRight', ['Tree', 'Climb', 'anch', 'bran'], [114, 118, 118, 135], MM_DIRECTION_SOUTH];

RUN_SIGN: TObstacle = ['Run Signpost', 4, [580, 170, 610, 190], MM_DIRECTION_SOUTH, false, [1584956, 4, [2, [0.44, 0.43, 0.00]]], [3708616, 14, [2, [0.02, 1.11, 0.00]]], +
true, 5, 20, 0, 10, false, [118, 118], 'MidRight', ['Run', 'cross', 'post', 'ign'], [309, 17, 342, 19], MM_DIRECTION_NORTH];

SWING_POLE: TObstacle = ['Swing Pole', 5, [625, 165, 650, 190], MM_DIRECTION_NORTH, false, [1584956, 4, [2, [0.44, 0.43, 0.00]]], [4740702, 5, [2, [0.20, 0.09, 0.00]]], +
true, 5, 20, 0, 10, false, [330, 19], '', ['Swing', 'Pole', 'ole', 'wing'], [222, 153, 244, 163], MM_DIRECTION_NORTH];

DOWN_PIPE: TObstacle = ['Down Pipe', 6, [615, 110, 660, 135], MM_DIRECTION_NORTH, true, [1584956, 4, [2, [0.44, 0.43, 0.00]]], [7904959, 5, [2, [0.06, 1.44, 0.00]]], +
true, 5, 2, 0, 10, false, [233, 158], '', ['Jump', 'over', 'arr', 'rier'], [615, 63, 630, 78], MM_DIRECTION_NORTH];

TO_START: TObstacle = ['To Start', 7, [180, 130, 240, 160], MM_DIRECTION_NORTH, true, [1584956, 4, [2, [0.44, 0.43, 0.00]]], [7904959, 5, [2, [0.06, 1.44, 0.00]]], +
true, 5, 20, 0, 10, false, [233, 158], '', ['Jump', 'over', 'arr', 'rier'], [615, 63, 630, 78], MM_DIRECTION_NORTH];

OBSTACLE_ARRAY: TObstacleArray = [CROSS_LOG, CLIMB_NET, CLIMB_BRANCH_1, CLIMB_BRANCH_2, RUN_SIGN, SWING_POLE, DOWN_PIPE, TO_START];

var
map_upstairs, map_ground: TSPSArea;

function walkToStart: boolean;
begin
if not isLoggedIn then
exit;

{ CheckFirst:=True;

Case Random(10) Of
0..1: SRL_Events[EVENT_ANTIBAN] := nil;
Else
SRL_Events[EVENT_ANTIBAN] := @QuickStep;
End; }

Result:= SPS.walkToPOS(Point(166, 155));
End;

function setbounds(settings: TColorData): TBox;
var
tpa: TPointArray;
atpa: T2DPointArray;
begin
if not isLoggedIn then
exit;

print('Using custom bounds');

settings.gatherIn(tpa, mainscreen.getBounds);

atpa := tpa.cluster(20);
atpa.sortBySize;

result := atpa[0].getBounds;
result.setLimit(mainscreen.getBounds);

print('Custom bounds: ' + toStr(result));
smartimage.drawBox(result);
end;

function findObstacle(whichObject: Integer): boolean;
var
i, startXP: Integer;
b: TBox;
tpa: TPointArray;
atpa: T2DPointArray;
begin
if not isLoggedIn then
exit;

if whichObject = -1 then
exit;

if whichObject = 7 then
begin
result:= walkToStart;
exit;
end;

with OBSTACLE_ARRAY[whichObject] do
begin
print('Trying to find object: ' + obstacleName);

minimap.setAngle(startAngle);

if isMouseOverText(mouseOverText, 10) then
begin
print('found object text, clicking');
if didClick(true) then
begin
print('clicked successfully, waiting for xp change');
wait(randomRange(0,1000));
minimap.setAngle(nextCamera);
mouseBox(nextAction);
result:= waitXPChange(randomRange(5000,6000));
if result then
exit;
end;
end;

if customSearchBounds then
b := setbounds(searchBounds) else
b := mainscreen.getBounds;

obstacleColor.gatherIn(tpa, b);

if cluster then
atpa := tpa.cluster(tpaWidth, tpaHeight) else
atpa := tpa.toATPA(tpaWidth, tpaHeight);

atpa.filterBetween(filterHigh, filterLow);

if sortBySize then
atpa.sortBySize else
atpa.sortFromFirstPoint(sortFrom);

smartImage.debugATPA(atpa);

for i := 0 to min(high(atpa), 2) do
begin
case objectPart of
'Top':
begin
b := atpa[i].getBounds;
b := [b.x1 + 3, b.y1, b.x2 - 3, b.y1 + 5];
mouseBox(b);
end;

'Bottom':
begin
b := atpa[i].getBounds;
b := [b.x1 + 3, b.y2 - 3, b.x2, b.y2];
mouseBox(b);
end;

'MidRight':
begin
b := atpa[i].getBounds;
b := [b.x2 -6, b.y1 + 10, b.x2 - 4, b.y1 + 20];
mouseBox(b);
end;
else
mouseBox(atpa[i].getBounds);
end;

if isMouseOverText(mouseOverText) then
begin
print('found object text, clicking');
if didClick(true) then
begin
print('clicked successfully, waiting for xp change');
startXP := chatBox.getXP;
wait(randomRange(0,1000));
minimap.setAngle(nextCamera);
mouseBox(nextAction);
result:= waitXPChange(startXP, randomRange(10000,15000));
if result then
exit;
end;
end;
end;
end;
end;

Function whereAmI: Integer;
Var
I: Integer;
Location: TPoint;
Begin
SmartImage.Clear;

Result := -1;
Location := map_ground.GetPlayerPos;

if location.x := -1 then
location := map_upstairs.GetPlayerPos;

Print('SPS Point: '+ToStr(Location));

For I := 0 To High(OBSTACLE_ARRAY) Do
If PointInBox(Location, OBSTACLE_ARRAY[I].obstacleCoords) Then
Begin
Result := I;
Break;
End;



If (Result=-1) Then
begin
Print('WARNING DONT KNOW WHERE YOU ARE!');
exit;
end;

Print('We are at position: '+OBSTACLE_ARRAY[I].obstacleName);

End;

begin
SmartEnableDrawing := True;
smartPlugins := ['d3d9.dll','OpenGL32.dll'];
setupSRL;

spsAnyAngle:=True;
map_upstairs.setup('0_0GA2', 'Runescape_Surface\');
map_ground.setup('0_0GA', 'Runescape_Surface\');
MainScreen.SetAngle(MS_ANGLE_HIGH);
repeat
findObstacle(whereAmI);
until false;
end.

use what you like - just throwing it out there! (PS i like to use SPS to figure out positions and when obstacles are complete for agility course, but just my personal pref)

Brotein

2014-06-11 10:57:53

Thanks for look, I'll check it out once I actually test my script.

So, this is what I got so far. I still need to gather accurate colors for the obstacles and xp drop popup. Just need to use either DTM or SPS to get back to start, and have a progress report and it should be working. I'll go back into it to add more failsafes(didClick etc). Anyways, progress…
program BroteinAdvAgile;

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

var
X, Y, DTM, Obstacle, FailCount : Integer;

////////////////////////////////////////////////////////////////////////////////
// Change Constants Here //
////////////////////////////////////////////////////////////////////////////////
const
DEBUGSCRIPT = true; //Enable if you are having issues running script
DEBUGCOLORS = true; //Enable if you are having issues running script
TIMESTOFAIL = 10; //Maximum times the script is allowed to fail before logging out

//ACA Settings for Log Obstacle
LOGCOLOR = 3362404;
LOGTOL = 16;
LOGHUE = 0.04;
LOGSAT = 0.08;

//ACA Settings for Net Obstacle
NETCOLOR = 4217200;
NETTOL = 12;
NETHUE = 0.10;
NETSAT = 5.48;

//ACA Settings for Branch1 Obstacle
BRANCH1COLOR = 3164509;
BRANCH1TOL = 8;
BRANCH1HUE = 0.07;
BRANCH1SAT = 0.12;

//ACA Settings for Bracnh2 Obstacle
BRANCH2COLOR = 3032665;
BRANCH2TOL = 7;
BRANCH2HUE = 0.07;
BRANCH2SAT = 0.10;

//ACA Settings for Sign Obstacle
SIGNCOLOR = 6401217;
SIGNTOL = 7;
SIGNHUE = 0.32;
SIGNSAT = 4.33;

//ACA Settings for Pole Obstacle
POLECOLOR = 4016464;
POLETOL = 18;
POLEHUE = 0.06;
POLESAT = 0.06;

//ACA Settings for Barrier Obstacle
BARRIERCOLOR = 5342120;
BARRIERTOL = 15;
BARRIERHUE = 0.05;
BARRIERSAT = 5.56;

//ACA Setting for Xp Drop/Popup
XPCOLOR = 0;
XPTOL = 0;
XPHUE = 0.00;
XPSAT = 0.00;

////////////////////////////////////////////////////////////////////////////////
// Set up your Character info here!!! //
////////////////////////////////////////////////////////////////////////////////
procedure declarePlayers;
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; //Set username here
password := ''; //Set password here
bankPin := ''; //Set PIN here
world := 1; //Set world here
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

////////////////////////////////////////////////////////////////////////////////
// Script starts here, Setup Complete! //
////////////////////////////////////////////////////////////////////////////////
// @ Procedure printStatus
// * Used for debugging our script to a log by using print
// * Will draw progress report at all times, and only progress report if we
// are not using the DEBUGSCRIPT constant.
procedure printStatus(Jamc : String; PrintType : Integer);
begin
if DEBUGSCRIPT then
begin
if PrintType = 0 then
print(Jamc, TDebug.SUB);
if PrintType = 1 then
print(Jamc, TDebug.HEADER);
if PrintType = 2 then
print(Jamc, TDebug.SUB);
if PrintType = 3 then
print(Jamc, TDebug.FOOTER);
if PrintType = 4 then
print(Jamc, TDebug.ERROR);
if PrintType = 5 then
writeLn(Jamc);
end;
if not DEBUGSCRIPT then
begin
if PrintType = 0 then
writeLn(Jamc);
end;
end

// @ Procedure takeScreen by Olly
// * Saves a screenshot and blurs out info, safe for upload
procedure takeScreen(Reason : String);
procedure blur(Bmp, Xs, Ys, Xe, Ye: Integer);
var
BmpCopy, Tmp: Integer;
begin
BmpCopy := copyBitmap(Bmp);
cropBitmap(BmpCopy, Xs, Ys, Xe, Ye);
Tmp := convoluteBitmap(BmpCopy, gaussMatrix(6, 3.00));
fastDrawTransparent(Xs, Ys, Tmp, Bmp);
freeBitmaps([BmpCopy, Tmp]);
end;
var
BmpClient, W, H, I: Integer;
Areas: TBoxArray;
begin
getClientDimensions(W, H);
BmpClient := bitmapFromClient(0, 0, W-1, H-1);
Areas := [[actionBar.x1, actionbar.y1, chatBox.x2, chatBox.y2], mainScreen.playerBox,
[tabBackpack.x1-4, tabBackpack.y2 - 40, tabBackpack.x2, tabBackpack.y2],
[mainScreen.x2 - 130, mainScreen.y1, mainScreen.x2, mainScreen.y1 + 75]];

for I := 0 to high(Areas) do
blur(BmpClient, Areas[i].x1, Areas[i].y1, Areas[i].x2, Areas[i].y2);
getMufasaBitmap(BmpClient).drawClippedText('Reason: ' + Reason + 'Time:' + theTime, point(chatBox.x1 + 5, chatBox.y2 - 16), StatChars, true, clLime);
saveBitmap(BmpClient, appPath + 'BroteinAdvAgile' + '.png');
debugBitmap(BmpClient);
freeBitmap(BmpClient);
end;

// @ Function getXP by Ashaman88
// * Gets XP in current xp counter on chat box.
function TRSChatBox.getXP: Integer;
var
B : TBox;
S : String;
TPA : TPointArray;
ATPA : T2DPointArray;
P : Integer;
begin
printStatus('TRSChatBox.getXP: Starting...', 1);
B := self.getBounds();
B.edit( +(B.x2 - B.x1) - 140, +10, -5, -94);
findColorsTolerance(TPA, 14013909, B, 4, colorSetting(2, 0.00, 0.00));
if length(TPA) < 2 then
begin
printStatus('chatBox.getXP(): No XP found', 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
exit;
end;
ATPA := TPA.cluster(10);
ATPA.sortFromFirstPoint(point(B.x2, B.y2));
B := ATPA[low(ATPA)].getbounds;
B.edit(-2, -2, +2, +3);
S := Replace(tesseractgettext(B.x1, B.y1, B.x2, B.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);
P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(S, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);
printStatus('chatBox.getXP(): XP found: ' + tostr(result), 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
end;

// @ Procedure killScript
// * Kills our script
// # Reason used for Debug
procedure killScript(Reason : String);
begin
printStatus('killScript: Starting...', 0);
takeScreen(Reason);
if isLoggedIn then
players[currentPlayer].logout();
terminateScript;
printStatus('killScript: Finished! Script terminated at time: ' + theTime + ', Script ran for: ' + timeRunning + ', Stopped for reason: ' + Reason, 0);
end;

// @ Function findObstacle
// * TPA finding function for the obstacles in our course.
// # ObColor, ObTol, ObCTS, ObHue, ObSat: Fill in with ACA(Color, Tolerance, ColorToleranceSpeed, Hue, Saturation)
// # ATPAW, ATPAH: Width and Height of ATPA
// # ObSort: 0 for sort ATPA by size, 1 for sort ATPA from midpoint(player)
// # RanX, RanY : Used to set randomrange for point x,y randomness in ATPA
// # ObUpText : UpText for the object as a String Array
function findObstacle(ObColor, ObTol, ObCTS, ATPAW, ATPAH, ObSort, RanX, RanY : Integer; ObHue, ObSat : Extended; ObUpText : TStringArray) : Boolean;
var
p : TPoint;
px, py, i : Integer;
ObTPA : TPointArray;
ObATPA : T2DPointArray;
begin
if not isLoggedIn then
exit;
printStatus('findObstacle: Starting...', 1);
printStatus('Looking for obstacle', 2);
if findColorsSpiralTolerance(px, py, ObTPA, ObColor, mainScreen.getBounds(), ObTol, colorSetting(ObCTS, ObHue, ObSat)) then
begin
ObATPA := ObTPA.toATPA(ATPAW, ATPAH);
ObATPA.filterBetween(0, 50);
if ObSort = 0 then
ObATPA.sortBySize(true);
if ObSort = 1 then
ObATPA.sortFromMidPoint(mainscreen.playerPoint);
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(ObTPA, true);
smartImage.debugATPA(ObATPA);
end;
for i := 0 to high(ObATPA) do
begin
p := middleTPA(ObATPA[i]);
p.offset(point(randomRange(-RanX, RanX), randomRange(-RanY, RanY)));
mouse(p.x, p.y, MOUSE_MOVE, MOUSE_HUMAN);
printStatus('Point we click on: ' + intToStr(p.x) + ', ' + intToStr(p.y), 2);
wait(150 + random(25));
if isMouseOverText(ObUpText) then
begin
wait(150 + random(50));
fastClick(MOUSE_LEFT);
printStatus('Found Obstacle!', 2);
wait(500 + random(100));
if DEBUGCOLORS then
smartImage.clear();
wait(random(250));
printStatus('Done Waiting', 2);
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
Result := true;
exit;
end;
wait(randomRange(1, 50));
end;
end;
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
end;

// @ Function checkXpDrop
// * Returns true when xp popup is found on mainscreen, times out at 15 seconds
function checkXpDrop : Boolean;
var
XpTPA : TPointArray;
Timer : TTimeMarker;
begin
if not isLoggedIn then
exit;
printStatus('checkXpDrop: Starting...', 1);
Timer.start;
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result) + ', Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
wait(randomRange(125, 250));
until(findColorsTolerance(XpTPA, XPCOLOR, intToBox(1,1,2,2), XPTOL, colorSetting(2, XPHUE, XPSAT)));
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(XpTPA, true);
end;
Timer.reset;
Result := true;
wait(1000);
if DEBUGCOLORS then
smartImage.clear();
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result), 3);
end;

// @ Procedure doLog
// * Completes Log Obstacle
// # Sets camera to face south after clicking on obstacle
// # Increments Obstacle to 1
procedure doLog;
begin
if not isLoggedIn then
exit;
printStatus('doLog: Starting...', 1);
printStatus('Beginning Log Search', 2);
if findObstacle(LOGCOLOR, LOGTOL, 2, 30, 70, 1, 1, 1, LOGHUE, LOGSAT, ['og', 'ala', 'alance', 'Log']) then
begin
printStatus('Setting camera to face South', 2);;
minimap.setAngle(MM_DIRECTION_SOUTH);
mainscreen.setAngle(0);
mainscreen.setZoom(false);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Net Obstacle', 2);
Obstacle := 1;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doLog: Finished', 3);
end;

// @ Procedure doNet
// * Completes Net Obstacle
// # Increments Obstacle to 2
procedure doNet;
begin
if not isLoggedIn then
exit;
printStatus('doNet: Starting...', 1);
printStatus('Beginning Net Search', 2);
if findObstacle(NETCOLOR, NETTOL, 2, 160, 40, 0, 1, 1, NETHUE, NETSAT, ['bstacle', 'net', 'Obstacle', 'Ob']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch1 Obstacle', 2);
Obstacle := 2;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doNet: Finished', 3);
end;

// @ Procedure doBranch1
// * Completes First Branch Obstacle
// # Increments Obstacle to 3
procedure doBranch1;
begin
if not isLoggedIn then
exit;
printStatus('doBranch1: Starting...', 1);
printStatus('Beginning Branch1 Search', 2);
if findObstacle(BRANCH1COLOR, BRANCH1TOL, 2, 70, 70, 1, 1, 1, BRANCH1HUE, BRANCH1SAT, ['ree', 'branch', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch2 Obstacle', 2);
Obstacle := 3;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch1: Finished', 3);
end;

// @ Procedure doBranch2
// * Completes Second Branch Obstacle
// # Increments Obstacle to 4
procedure doBranch2;
begin
if not isLoggedIn then
exit;
printStatus('doBranch2: Starting...', 1);
printStatus('Beginning Branch2 Search', 2);
if findObstacle(BRANCH2COLOR, BRANCH2TOL, 2, 10, 40, 1, 1, 1, BRANCH2HUE, BRANCH2SAT, ['ree', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Sign Obstacle', 2);
Obstacle := 4;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch2: Finished', 3);
end;

// @ Procedure doSign
// * Completes Sign Obstacle
// # Sets camera to face east after clicking on obstacle
// # Increments Obstacle to 5
procedure doSign;
begin
if not isLoggedIn then
exit;
printStatus('doSign: Starting...', 1);
printStatus('Beginning Sign Search', 2);
if findObstacle(SIGNCOLOR, SIGNTOL, 2, 15, 40, 1, 1, 1, SIGNHUE, SIGNSAT, ['ign', 'post', 'Sign', 'Signpost']) then
begin
printStatus('Setting camera to face East', 2);
minimap.setAngle(MM_DIRECTION_EAST);
mainscreen.setAngle(0);
mainscreen.setZoom(false);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Pole Obstacle', 2);
Obstacle := 5;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doSign: Finished', 3);
end;

// @ Procedure doPole
// * Completes Pole Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 6
procedure doPole;
begin
if not isLoggedIn then
exit;
printStatus('doPole: Starting...', 1);
printStatus('Beginning Pole Search', 2);
if findObstacle(POLECOLOR, POLETOL, 2, 30, 200, 0, 1, 1, POLEHUE, POLESAT, ['ole', 'Pole', 'Pol']) then
begin
printStatus('Setting camera to face North', 2);
minimap.clickCompass();
mainscreen.setAngle(0);
mainscreen.setZoom(false);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Barrier Obstacle', 2);
Obstacle := 6;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doPole: Finished', 3);
end;

// @ Procedure doBarrier
// * Completes Barrier Obstacle
// # Sets camera to face north(high) after clicking on obstacle
// # Resets Obstacle to 0
procedure doBarrier;
begin
if not isLoggedIn then
exit;
printStatus('doBarrier: Starting...', 1);
printStatus('Beginning Barrier Search', 2);
if findObstacle(BARRIERCOLOR, BARRIERTOL, 2, 40, 40, 0, 1, 1, BARRIERHUE, BARRIERSAT, ['arr', 'arrier', 'Barrier', 'Bar']) then
begin
printStatus('Setting camera to face North High', 2);
mainscreen.setAngle(0);
mainscreen.setZoom(false);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Log Obstacle', 2);
Obstacle := 0;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBarrier: Finished', 3);
end;

// @ Procedure runToStart
// * Stuff
procedure runToStart;
begin
//DTM minimap to start of log maybe?
end;

// @ Procedure doTheCourse
// * Checks fail count to see if we should log out, otherwise will complete course
procedure doTheCourse;
begin
if not isLoggedIn then
exit;
printStatus('doTheCourse: Starting...', 1);
printStatus('FailCount: ' + intToStr(FailCount), 2);
if FailCount > TIMESTOFAIL then
begin
printStatus('We failed too many times, logging out!', 2);
printStatus('doTheCourse: Finished!', 3);
killScript('Failed ' + intToStr(FailCount) + ' times');
end;
if Obstacle = 0 then
doLog;
if Obstacle = 1 then
doNet;
if Obstacle = 2 then
doBranch1;
if Obstacle = 3 then
doBranch2;
if Obstacle = 4 then
doSign;
if Obstacle = 5 then
doPole;
if Obstacle = 6 then
doBarrier;
printStatus('doTheCourse: Finished!', 3);
end;

// @ Procedure progressReport
// * Xp stuff
procedure progressReport
begin
// Stuff
end;

// @ Procedure onScreenReport
// * Draws xp stuff on screen
procedure onScreenReport
begin
// Stuff
end;

// @ Main Loop
// * Loops through stuff
// Not yet, testing here
begin
clearDebug();
if not DEBUGSCRIPT then
disableSRLDebug := true;
smartEnableDrawing := true;
setupSRL;
declarePlayers;
//findObstacle(3362404, 16, 2, 30, 70, 1, 1, 1, 0.04, 0.08, ['og', 'ala', 'alance', 'Log']);
//findObstacle(4217200, 12, 2, 160, 40, 0, 1, 1, 0.10, 5.48, ['bstacle', 'net', 'Obstacle', 'Ob']);
//findObstacle(3164509, 8, 2, 70, 70, 1, 1, 1, 0.07, 0.12, ['ree', 'branch', 'Tree', 'Tre']);
//findObstacle(3032665, 7, 2, 10, 40, 1, 1, 1, 0.07, 0.10, ['ree', 'Tree', 'Tre']);
//findObstacle(6401217, 7, 2, 15, 40, 1, 1, 1, 0.32, 4.33, ['ign', 'post', 'Sign', 'Signpost']);
//findObstacle(4016464, 18, 2, 30, 200, 0, 1, 1, 0.06, 0.06, ['ole', 'Pole', 'Pol']);
//findObstacle(5342120, 15, 2, 40, 40, 0, 1, 1, 0.05, 5.56, ['arr', 'arrier', 'Barrier', 'Bar']);

//back to log test
DTM := DTMFromString('mQwAAAHicY2ZgYJBhZWAQA2IFID4I5J8E4tNAvHOCCkNdnBrD1WNVDJJAPhcUMyJhIAAAIWIHbg==');
if (minimap.findDTM(dtm, x, y)) then
writeln('found the dtm');
mouse(x, y, MOUSE_MOVE, MOUSE_HUMAN);
fastClick(MOUSE_LEFT);
freeDTM(dtm);
end.

Brotein

2014-06-12 11:25:40

Surprised everything worked on the first go! Still building it, but it will run through the course if anyone wants to check it out. If you are, just start it somewhere in the course area with the camera zoomed out facing north high angle.

program BroteinAdvAgile;

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

var
X, Y, MMDTM, Obstacle, FailCount : Integer;

////////////////////////////////////////////////////////////////////////////////
// Change Constants Here //
////////////////////////////////////////////////////////////////////////////////
const
DEBUGSCRIPT = true; //Enable if you are having issues running script
DEBUGCOLORS = true; //Enable if you are having issues running script
TIMESTOFAIL = 10; //Maximum times the script is allowed to fail before logging out

//ACA Settings for Log Obstacle
LOGCOLOR = 3362404;
LOGTOL = 16;
LOGHUE = 0.04;
LOGSAT = 0.08;

//ACA Settings for Net Obstacle
NETCOLOR = 4217200;
NETTOL = 12;
NETHUE = 0.10;
NETSAT = 5.48;

//ACA Settings for Branch1 Obstacle
BRANCH1COLOR = 4348010;
BRANCH1TOL = 18;
BRANCH1HUE = 0.04;
BRANCH1SAT = 0.57;

//ACA Settings for Bracnh2 Obstacle
BRANCH2COLOR = 3032665;
BRANCH2TOL = 7;
BRANCH2HUE = 0.07;
BRANCH2SAT = 0.10;

//ACA Settings for Sign Obstacle
SIGNCOLOR = 6401217;
SIGNTOL = 7;
SIGNHUE = 0.32;
SIGNSAT = 4.33;

//ACA Settings for Pole Obstacle
POLECOLOR = 4016464;
POLETOL = 18;
POLEHUE = 0.06;
POLESAT = 0.06;

//ACA Settings for Barrier Obstacle
BARRIERCOLOR = 5342120;
BARRIERTOL = 15;
BARRIERHUE = 0.05;
BARRIERSAT = 5.56;

//ACA Setting for Xp Drop/Popup
XPCOLOR = 4040932;
XPTOL = 2;
XPHUE = 0.13;
XPSAT = 2.79;

////////////////////////////////////////////////////////////////////////////////
// Set up your Character info here!!! //
////////////////////////////////////////////////////////////////////////////////
procedure declarePlayers;
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; //Set username here
password := ''; //Set password here
bankPin := ''; //Set PIN here
world := 1; //Set world here
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

////////////////////////////////////////////////////////////////////////////////
// Script starts here, Setup Complete! //
////////////////////////////////////////////////////////////////////////////////
// @ Procedure printStatus
// * Used for debugging our script to a log by using print
// * Will draw progress report at all times, and only progress report if we
// are not using the DEBUGSCRIPT constant.
procedure printStatus(Jamc : String; PrintType : Integer);
begin
if DEBUGSCRIPT then
begin
if PrintType = 0 then
print(Jamc, TDebug.SUB);
if PrintType = 1 then
print(Jamc, TDebug.HEADER);
if PrintType = 2 then
print(Jamc, TDebug.SUB);
if PrintType = 3 then
print(Jamc, TDebug.FOOTER);
if PrintType = 4 then
print(Jamc, TDebug.ERROR);
if PrintType = 5 then
writeLn(Jamc);
end;
if not DEBUGSCRIPT then
begin
if PrintType = 0 then
writeLn(Jamc);
end;
end

// @ Procedure takeScreen by Olly
// * Saves a screenshot and blurs out info, safe for upload
procedure takeScreen(Reason : String);
procedure blur(Bmp, Xs, Ys, Xe, Ye: Integer);
var
BmpCopy, Tmp: Integer;
begin
BmpCopy := copyBitmap(Bmp);
cropBitmap(BmpCopy, Xs, Ys, Xe, Ye);
Tmp := convoluteBitmap(BmpCopy, gaussMatrix(6, 3.00));
fastDrawTransparent(Xs, Ys, Tmp, Bmp);
freeBitmaps([BmpCopy, Tmp]);
end;
var
BmpClient, W, H, I: Integer;
Areas: TBoxArray;
begin
getClientDimensions(W, H);
BmpClient := bitmapFromClient(0, 0, W-1, H-1);
Areas := [[actionBar.x1, actionbar.y1, chatBox.x2, chatBox.y2], mainScreen.playerBox,
[tabBackpack.x1-4, tabBackpack.y2 - 40, tabBackpack.x2, tabBackpack.y2],
[mainScreen.x2 - 130, mainScreen.y1, mainScreen.x2, mainScreen.y1 + 75]];

for I := 0 to high(Areas) do
blur(BmpClient, Areas[i].x1, Areas[i].y1, Areas[i].x2, Areas[i].y2);
getMufasaBitmap(BmpClient).drawClippedText('Reason: ' + Reason + 'Time:' + theTime, point(chatBox.x1 + 5, chatBox.y2 - 16), StatChars, true, clLime);
saveBitmap(BmpClient, appPath + 'BroteinAdvAgile' + '.png');
debugBitmap(BmpClient);
freeBitmap(BmpClient);
end;

// @ Function getXP by Ashaman88
// * Gets XP in current xp counter on chat box.
function TRSChatBox.getXP: Integer;
var
B : TBox;
S : String;
TPA : TPointArray;
ATPA : T2DPointArray;
P : Integer;
begin
printStatus('TRSChatBox.getXP: Starting...', 1);
B := self.getBounds();
B.edit( +(B.x2 - B.x1) - 140, +10, -5, -94);
findColorsTolerance(TPA, 14013909, B, 4, colorSetting(2, 0.00, 0.00));
if length(TPA) < 2 then
begin
printStatus('chatBox.getXP(): No XP found', 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
exit;
end;
ATPA := TPA.cluster(10);
ATPA.sortFromFirstPoint(point(B.x2, B.y2));
B := ATPA[low(ATPA)].getbounds;
B.edit(-2, -2, +2, +3);
S := Replace(tesseractgettext(B.x1, B.y1, B.x2, B.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);
P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(S, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);
printStatus('chatBox.getXP(): XP found: ' + tostr(result), 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
end;

procedure setOurDTMs
begin
MMDTM := DTMFromString('mWAAAAHicY2FgYBBhZWDgAmJRIBYD4jhGBoZsIM4H4gAg3jZFi6EhSYvhzdM+hhmdiQwaQD3ImBENgwAArpkI8w==');
end;

// @ Procedure killScript
// * Kills our script
// # Reason used for Debug
procedure killScript(Reason : String);
begin
printStatus('killScript: Starting...', 0);
takeScreen(Reason);
if isLoggedIn then
players[currentPlayer].logout();
terminateScript;
printStatus('killScript: Finished! Script terminated at time: ' + theTime + ', Script ran for: ' + timeRunning + ', Stopped for reason: ' + Reason, 0);
end;

// @ Function findObstacle
// * TPA finding function for the obstacles in our course.
// # ObColor, ObTol, ObCTS, ObHue, ObSat: Fill in with ACA(Color, Tolerance, ColorToleranceSpeed, Hue, Saturation)
// # ATPAW, ATPAH: Width and Height of ATPA
// # ObSort: 0 for sort ATPA by size, 1 for sort ATPA from midpoint(player)
// # RanX, RanY : Used to set randomrange for point x,y randomness in ATPA
// # ObUpText : UpText for the object as a String Array
function findObstacle(ObColor, ObTol, ObCTS, ATPAW, ATPAH, ObSort, RanX, RanY, IndexStart : Integer; ObHue, ObSat : Extended; ObUpText : TStringArray) : Boolean;
var
p : TPoint;
px, py, i : Integer;
ObTPA : TPointArray;
ObATPA : T2DPointArray;
begin
if not isLoggedIn then
exit;
printStatus('findObstacle: Starting...', 1);
printStatus('Looking for obstacle', 2);
if findColorsSpiralTolerance(px, py, ObTPA, ObColor, mainScreen.getBounds(), ObTol, colorSetting(ObCTS, ObHue, ObSat)) then
begin
ObATPA := ObTPA.toATPA(ATPAW, ATPAH);
ObATPA.filterBetween(0, 50);
if ObSort = 0 then
ObATPA.sortBySize(true);
if ObSort = 1 then
ObATPA.sortFromMidPoint(mainscreen.playerPoint);
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(ObTPA, true);
smartImage.debugATPA(ObATPA);
end;
for i := IndexStart to high(ObATPA) do
begin
p := middleTPA(ObATPA[i]);
p.offset(point(randomRange(-RanX, RanX), randomRange(-RanY, RanY)));
mouse(p.x, p.y, MOUSE_MOVE, MOUSE_HUMAN);
printStatus('Point we click on: ' + intToStr(p.x) + ', ' + intToStr(p.y), 2);
wait(150 + random(25));
if isMouseOverText(ObUpText) then
begin
wait(150 + random(50));
fastClick(MOUSE_LEFT);
printStatus('Found Obstacle!', 2);
wait(500 + random(100));
if DEBUGCOLORS then
smartImage.clear();
wait(random(250));
printStatus('Done Waiting', 2);
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
Result := true;
exit;
end;
wait(randomRange(1, 50));
end;
end;
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
end;

// @ Function checkXpDrop
// * Returns true when xp popup is found on mainscreen, times out at 15 seconds
function checkXpDrop : Boolean;
var
XpTPA : TPointArray;
Timer : TTimeMarker;
begin
if not isLoggedIn then
exit;
printStatus('checkXpDrop: Starting...', 1);
Timer.start;
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result) + ', Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting...', 2);
wait(randomRange(125, 250));
until(findColorsTolerance(XpTPA, XPCOLOR, intToBox(266, 7, 500, 239), XPTOL, colorSetting(2, XPHUE, XPSAT)));
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(XpTPA, true);
end;
Timer.reset;
Result := true;
wait(1000);
if DEBUGCOLORS then
smartImage.clear();
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result), 3);
end;

// @ Procedure runToStart
// * Stuff
procedure runToStart;
begin
printStatus('runToStart: Starting...', 1);
printStatus('Looking for DTM...', 2);
if(findDTM(MMDTM, x, y, miniMap.getBounds())) then
begin
wait(randomRange(250, 500));
printStatus('Found DTM!', 2);
mouse(x, y, MOUSE_MOVE, MOUSE_HUMAN);
fastClick(MOUSE_LEFT);
repeat
wait(randomRange(250, 500));
until(not minimap.isPlayerMoving());
end;
printStatus('runToStart: Finished!', 3);
end;

// @ Procedure doLog
// * Completes Log Obstacle
// # Sets camera to face south after clicking on obstacle
// # Increments Obstacle to 1
procedure doLog;
begin
if not isLoggedIn then
exit;
printStatus('doLog: Starting...', 1);
runToStart;
printStatus('Beginning Log Search', 2);
if findObstacle(LOGCOLOR, LOGTOL, 2, 30, 70, 1, 1, 1, 1, LOGHUE, LOGSAT, ['og', 'ala', 'alance', 'Log']) then
begin
printStatus('Setting camera to face South', 2);;
minimap.setAngle(MM_DIRECTION_SOUTH);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Net Obstacle', 2);
Obstacle := 1;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doLog: Finished', 3);
end;

// @ Procedure doNet
// * Completes Net Obstacle
// # Increments Obstacle to 2
procedure doNet;
begin
if not isLoggedIn then
exit;
printStatus('doNet: Starting...', 1);
printStatus('Beginning Net Search', 2);
if findObstacle(NETCOLOR, NETTOL, 2, 160, 40, 0, 1, 1, 0, NETHUE, NETSAT, ['bstacle', 'net', 'Obstacle', 'Ob']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch1 Obstacle', 2);
Obstacle := 2;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doNet: Finished', 3);
end;

// @ Procedure doBranch1
// * Completes First Branch Obstacle
// # Increments Obstacle to 3
procedure doBranch1;
begin
if not isLoggedIn then
exit;
printStatus('doBranch1: Starting...', 1);
printStatus('Beginning Branch1 Search', 2);
if findObstacle(BRANCH1COLOR, BRANCH1TOL, 2, 70, 70, 1, 1, 1, 0, BRANCH1HUE, BRANCH1SAT, ['ree', 'branch', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch2 Obstacle', 2);
Obstacle := 3;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch1: Finished', 3);
end;

// @ Procedure doBranch2
// * Completes Second Branch Obstacle
// # Increments Obstacle to 4
procedure doBranch2;
begin
if not isLoggedIn then
exit;
printStatus('doBranch2: Starting...', 1);
printStatus('Beginning Branch2 Search', 2);
if findObstacle(BRANCH2COLOR, BRANCH2TOL, 2, 10, 40, 1, 1, 1, 2, BRANCH2HUE, BRANCH2SAT, ['ree', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Sign Obstacle', 2);
Obstacle := 4;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch2: Finished', 3);
end;

// @ Procedure doSign
// * Completes Sign Obstacle
// # Sets camera to face east after clicking on obstacle
// # Increments Obstacle to 5
procedure doSign;
begin
if not isLoggedIn then
exit;
printStatus('doSign: Starting...', 1);
printStatus('Beginning Sign Search', 2);
if findObstacle(SIGNCOLOR, SIGNTOL, 2, 15, 40, 1, 1, 1, 0, SIGNHUE, SIGNSAT, ['ign', 'post', 'Sign', 'Signpost']) then
begin
printStatus('Setting camera to face East', 2);
minimap.setAngle(MM_DIRECTION_WEST);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Pole Obstacle', 2);
Obstacle := 5;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doSign: Finished', 3);
end;

// @ Procedure doPole
// * Completes Pole Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 6
procedure doPole;
begin
if not isLoggedIn then
exit;
printStatus('doPole: Starting...', 1);
printStatus('Beginning Pole Search', 2);
if findObstacle(POLECOLOR, POLETOL, 2, 30, 200, 0, 1, 1, 0, POLEHUE, POLESAT, ['ole', 'Pole', 'Pol']) then
begin
printStatus('Setting camera to face North', 2);
minimap.clickCompass();
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Barrier Obstacle', 2);
Obstacle := 6;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doPole: Finished', 3);
end;

// @ Procedure doBarrier
// * Completes Barrier Obstacle
// # Sets camera to face north(high) after clicking on obstacle
// # Resets Obstacle to 0
procedure doBarrier;
begin
if not isLoggedIn then
exit;
printStatus('doBarrier: Starting...', 1);
printStatus('Beginning Barrier Search', 2);
if findObstacle(BARRIERCOLOR, BARRIERTOL, 2, 40, 40, 0, 1, 1, 0, BARRIERHUE, BARRIERSAT, ['arr', 'arrier', 'Barrier', 'Bar']) then
begin
printStatus('Setting camera to face North High', 2);
mainscreen.setAngle(0);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Log Obstacle', 2);
Obstacle := 0;
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBarrier: Finished', 3);
end;

// @ Procedure doTheCourse
// * Checks fail count to see if we should log out, otherwise will complete course
procedure doTheCourse;
begin
if not isLoggedIn then
exit;
printStatus('doTheCourse: Starting...', 1);
printStatus('FailCount: ' + intToStr(FailCount), 2);
if FailCount > TIMESTOFAIL then
begin
printStatus('We failed too many times, logging out!', 2);
printStatus('doTheCourse: Finished!', 3);
killScript('Failed ' + intToStr(FailCount) + ' times');
end;
if Obstacle = 0 then
doLog;
if Obstacle = 1 then
doNet;
if Obstacle = 2 then
doBranch1;
if Obstacle = 3 then
doBranch2;
if Obstacle = 4 then
doSign;
if Obstacle = 5 then
doPole;
if Obstacle = 6 then
doBarrier;
printStatus('doTheCourse: Finished!', 3);
end;

// @ Procedure progressReport
// * Xp stuff
procedure progressReport
begin
// Stuff
end;

// @ Procedure onScreenReport
// * Draws xp stuff on screen
procedure onScreenReport
begin
// Stuff
end;

// @ Main Loop
// * Loops through simple steps infinitley
// Not yet, testing here
begin
clearDebug();
if not DEBUGSCRIPT then
disableSRLDebug := true;
smartEnableDrawing := true;
setupSRL;
declarePlayers;
Obstacle := 0;
setOurDTMs;
//findObstacle(3362404, 16, 2, 30, 70, 1, 1, 1, 0.04, 0.08, ['og', 'ala', 'alance', 'Log']);
//findObstacle(4217200, 12, 2, 160, 40, 0, 1, 1, 0.10, 5.48, ['bstacle', 'net', 'Obstacle', 'Ob']);
//findObstacle(3164509, 8, 2, 70, 70, 1, 1, 1, 0.07, 0.12, ['ree', 'branch', 'Tree', 'Tre']);
//findObstacle(3032665, 7, 2, 10, 40, 1, 1, 1, 0.07, 0.10, ['ree', 'Tree', 'Tre']);
//findObstacle(6401217, 7, 2, 15, 40, 1, 1, 1, 0.32, 4.33, ['ign', 'post', 'Sign', 'Signpost']);
//findObstacle(4016464, 18, 2, 30, 200, 0, 1, 1, 0.06, 0.06, ['ole', 'Pole', 'Pol']);
//findObstacle(5342120, 15, 2, 40, 40, 0, 1, 1, 0.05, 5.56, ['arr', 'arrier', 'Barrier', 'Bar']);

//checkXpDrop;

//doLog;
//doNet;
//doBranch1;
//doBranch2;
//doSign;
//doPole;
//doBarrier;
repeat
doTheCourse;
until(false);
freeDTM(MMDTM);
end.

The REAL issue I am having right now is what I named obstacle Branch1, which is the first tree branch. It's click area is only the branch and not the trunk. Can anyone help me get something accurate for this branch. The colors I have work but when the camera rotates too far it splits the TPAs wrong.

Brotein

2014-06-12 16:52:01

More progress…

program BroteinAdvAgile;

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

var
X, Y, MMDTM, Obstacle, FailCount : Integer;
XpGained, XpHour, SecondS : Extended;

////////////////////////////////////////////////////////////////////////////////
// Change Constants Here //
////////////////////////////////////////////////////////////////////////////////
const
DEBUGSCRIPT = true; //Enable if you are having issues running script
DEBUGCOLORS = true; //Enable if you are having issues running script
TIMESTOFAIL = 10; //Maximum times the script is allowed to fail before logging out

//ACA Settings for Log Obstacle
LOGCOLOR = 3362404;
LOGTOL = 16;
LOGHUE = 0.04;
LOGSAT = 0.08;

//ACA Settings for Net Obstacle
NETCOLOR = 4348787;
NETTOL = 13;
NETHUE = 0.10;
NETSAT = 5.49;

//ACA Settings for Branch1 Obstacle
BRANCH1COLOR = 4348010;
BRANCH1TOL = 18;
BRANCH1HUE = 0.04;
BRANCH1SAT = 0.57;

//ACA Settings for Bracnh2 Obstacle
BRANCH2COLOR = 2835028;
BRANCH2TOL = 10;
BRANCH2HUE = 0.06;
BRANCH2SAT = 0.25;

//ACA Settings for Sign Obstacle
SIGNCOLOR = 6401217;
SIGNTOL = 7;
SIGNHUE = 0.32;
SIGNSAT = 4.33;

//ACA Settings for Pole Obstacle
POLECOLOR = 4016464;
POLETOL = 18;
POLEHUE = 0.06;
POLESAT = 0.06;

//ACA Settings for Barrier Obstacle
BARRIERCOLOR = 5277871;
BARRIERTOL = 16;
BARRIERHUE = 0.08;
BARRIERSAT = 5.56;

//ACA Setting for Xp Drop/Popup
XPCOLOR = 4040932;
XPTOL = 2;
XPHUE = 0.13;
XPSAT = 2.79;

////////////////////////////////////////////////////////////////////////////////
// Set up your Character info here!!! //
////////////////////////////////////////////////////////////////////////////////
procedure declarePlayers;
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; //Set username here
password := ''; //Set password here
bankPin := ''; //Set PIN here
world := 1; //Set world here
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

////////////////////////////////////////////////////////////////////////////////
// Script starts here, Setup Complete! //
////////////////////////////////////////////////////////////////////////////////
// @ Procedure printStatus
// * Used for debugging our script to a log by using print
// * Will draw progress report at all times, and only progress report if we
// are not using the DEBUGSCRIPT constant.
procedure printStatus(Jamc : String; PrintType : Integer);
begin
if DEBUGSCRIPT then
begin
if PrintType = 0 then
print(Jamc, TDebug.SUB);
if PrintType = 1 then
print(Jamc, TDebug.HEADER);
if PrintType = 2 then
print(Jamc, TDebug.SUB);
if PrintType = 3 then
print(Jamc, TDebug.FOOTER);
if PrintType = 4 then
print(Jamc, TDebug.ERROR);
if PrintType = 5 then
writeLn(Jamc);
end;
if not DEBUGSCRIPT then
begin
if PrintType = 0 then
writeLn(Jamc);
end;
end

// @ Procedure takeScreen by Olly
// * Saves a screenshot and blurs out info, safe for upload
procedure takeScreen(Reason : String);
procedure blur(Bmp, Xs, Ys, Xe, Ye: Integer);
var
BmpCopy, Tmp: Integer;
begin
BmpCopy := copyBitmap(Bmp);
cropBitmap(BmpCopy, Xs, Ys, Xe, Ye);
Tmp := convoluteBitmap(BmpCopy, gaussMatrix(6, 3.00));
fastDrawTransparent(Xs, Ys, Tmp, Bmp);
freeBitmaps([BmpCopy, Tmp]);
end;
var
BmpClient, W, H, I: Integer;
Areas: TBoxArray;
begin
getClientDimensions(W, H);
BmpClient := bitmapFromClient(0, 0, W-1, H-1);
Areas := [[actionBar.x1, actionbar.y1, chatBox.x2, chatBox.y2], mainScreen.playerBox,
[tabBackpack.x1-4, tabBackpack.y2 - 40, tabBackpack.x2, tabBackpack.y2],
[mainScreen.x2 - 130, mainScreen.y1, mainScreen.x2, mainScreen.y1 + 75]];

for I := 0 to high(Areas) do
blur(BmpClient, Areas[i].x1, Areas[i].y1, Areas[i].x2, Areas[i].y2);
getMufasaBitmap(BmpClient).drawClippedText('Reason: ' + Reason + 'Time:' + theTime, point(chatBox.x1 + 5, chatBox.y2 - 16), StatChars, true, clLime);
saveBitmap(BmpClient, appPath + 'BroteinAdvAgile' + '.png');
debugBitmap(BmpClient);
freeBitmap(BmpClient);
end;

// @ Function getXP by Ashaman88
// * Gets XP in current xp counter on chat box.
function TRSChatBox.getXP: Integer;
var
B : TBox;
S : String;
TPA : TPointArray;
ATPA : T2DPointArray;
P : Integer;
begin
printStatus('TRSChatBox.getXP: Starting...', 1);
B := self.getBounds();
B.edit( +(B.x2 - B.x1) - 140, +10, -5, -94);
findColorsTolerance(TPA, 14013909, B, 4, colorSetting(2, 0.00, 0.00));
if length(TPA) < 2 then
begin
printStatus('chatBox.getXP(): No XP found', 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
exit;
end;
ATPA := TPA.cluster(10);
ATPA.sortFromFirstPoint(point(B.x2, B.y2));
B := ATPA[low(ATPA)].getbounds;
B.edit(-2, -2, +2, +3);
S := Replace(tesseractgettext(B.x1, B.y1, B.x2, B.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);
P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(S, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);
printStatus('chatBox.getXP(): XP found: ' + tostr(result), 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
end;

// @ Procedure setDTMs
// * Sets our DTM
// # MMDTM
procedure setDTMs
begin
MMDTM := DTMFromString('mWAAAAHicY2FgYBBhZWDgAmJRIBYD4jhGBoZsIM4H4gAg3jZFi6EhSYvhzdM+hhmdiQwaQD3ImBENgwAArpkI8w==');
end;

// @ Procedure releaseDTMs
// * Frees our DTM from memory
// # [OreDTM]
procedure releaseDTMs;
begin
freeDTMs([MMDTM]);
end;

// @ Procedure killScript
// * Kills our script
// # Reason used for Debug
procedure killScript(Reason : String);
begin
printStatus('killScript: Starting...', 0);
takeScreen(Reason);
if isLoggedIn then
players[currentPlayer].logout();
terminateScript;
printStatus('killScript: Finished! Script terminated at time: ' + theTime + ', Script ran for: ' + timeRunning + ', Stopped for reason: ' + Reason, 0);
end;

// @ Procedure setUsUp
// * Does our intial setup stuff for script during startup
procedure setUsUp;
begin
printStatus('setUsUp: Starting...', 1);
clearDebug();
//autoUpdateMe;
if not DEBUGSCRIPT then
disableSRLDebug := true;
smartEnableDrawing := true;
setupSRL;
setDTMs;
addOnTerminate('releaseDTMs');
declarePlayers;
Obstacle := 0;
printStatus('setUsUp: Finished!', 3);
end;

// @ Procedure logUsIn
// * Logs in player when not logged in and closes Treasure popup
procedure logUsIn;
begin
printStatus('logUsIn: Starting...', 1);
if not isLoggedIn then
begin
players[currentPlayer].login();
exitTreasure();
if Obstacle = 0 then
begin
minimap.clickCompass();
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 1 or Obstacle = 2 or Obstacle = 3 or Obstacle = 4 then
begin
minimap.setAngle(MM_DIRECTION_SOUTH);
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 5 then
begin
minimap.setAngle(MM_DIRECTION_WEST);
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 6 then
begin
minimap.clickCompass();
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
end;
printStatus('logUsIn: Finished!', 3);
end;

// @ Proecure progressReport
// * Will display our progress, and increments XpGained by obstacle XP
// # XpGained, XpHour, timeRunning, FailCount
procedure progressReport(IncAmount : Extended);
begin
if not DEBUGSCRIPT then
clearDebug();
XpGained := XpGained + IncAmount;
SecondS := round((getTimeRunning/1000));
XpHour := round((3600 * XpGained) / (SecondS));
printStatus('*************Progress Report***************', 0);
printStatus('Time Running: ' + timeRunning, 0);
printStatus('XP Gained: ' + floatToStr(XpGained), 0);
printStatus('XP/Hour: ' + floatToStr(XpHour), 0);
printStatus('Times Failed: ' + intToStr(FailCount), 0);
printStatus('*******************************************', 0);
end;

// @ Procedure onScreenReport
// * Draws xp stuff on screen
procedure onScreenReport
begin
// Stuff
end;

// @ Function findObstacle
// * TPA finding function for the obstacles in our course.
// # ObColor, ObTol, ObCTS, ObHue, ObSat: Fill in with ACA(Color, Tolerance, ColorToleranceSpeed, Hue, Saturation)
// # ATPAW, ATPAH: Width and Height of ATPA
// # ObSort: 0 for sort ATPA by size, 1 for sort ATPA from midpoint(player)
// # RanX, RanY : Used to set randomrange for point x,y randomness in ATPA
// # ObUpText : UpText for the object as a String Array
function findObstacle(ObColor, ObTol, ObCTS, ATPAW, ATPAH, ObSort, RanX, RanY, IndexStart : Integer; ObHue, ObSat : Extended; ObUpText : TStringArray) : Boolean;
var
p : TPoint;
px, py, i : Integer;
ObTPA : TPointArray;
ObATPA : T2DPointArray;
begin
if not isLoggedIn then
exit;
printStatus('findObstacle: Starting...', 1);
printStatus('Looking for obstacle', 2);
if findColorsSpiralTolerance(px, py, ObTPA, ObColor, mainScreen.getBounds(), ObTol, colorSetting(ObCTS, ObHue, ObSat)) then
begin
ObATPA := ObTPA.toATPA(ATPAW, ATPAH);
ObATPA.filterBetween(0, 50);
if ObSort = 0 then
ObATPA.sortBySize(true);
if ObSort = 1 then
ObATPA.sortFromMidPoint(mainscreen.playerPoint);
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(ObTPA, true);
smartImage.debugATPA(ObATPA);
end;
for i := IndexStart to high(ObATPA) do
begin
p := middleTPA(ObATPA[i]);
p.offset(point(randomRange(-RanX, RanX), randomRange(-RanY, RanY)));
mouse(p.x, p.y, MOUSE_MOVE, MOUSE_HUMAN);
printStatus('Point we click on: ' + intToStr(p.x) + ', ' + intToStr(p.y), 2);
wait(150 + random(25));
if isMouseOverText(ObUpText) then
begin
wait(150 + random(50));
fastClick(MOUSE_LEFT);
printStatus('Found Obstacle!', 2);
wait(500 + random(100));
if DEBUGCOLORS then
smartImage.clear();
wait(random(250));
printStatus('Done Waiting', 2);
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
Result := true;
exit;
end;
wait(randomRange(1, 50));
end;
end;
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
end;

// @ Function checkXpDrop
// * Returns true when xp popup is found on mainscreen, times out at 15 seconds
function checkXpDrop : Boolean;
var
XpTPA : TPointArray;
Timer : TTimeMarker;
begin
if not isLoggedIn then
exit;
printStatus('checkXpDrop: Starting...', 1);
Timer.start;
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result) + ', Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting...', 2);
wait(randomRange(125, 250));
until(findColorsTolerance(XpTPA, XPCOLOR, intToBox(266, 7, 500, 239), XPTOL, colorSetting(2, XPHUE, XPSAT)));
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(XpTPA, true);
end;
Timer.reset;
Result := true;
wait(1000);
if DEBUGCOLORS then
smartImage.clear();
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result), 3);
end;

// @ Procedure runToStart
// * Stuff
procedure runToStart;
var
Timer : TTimeMarker;
begin
printStatus('runToStart: Starting...', 1);
printStatus('Looking for DTM...', 2);
if(findDTM(MMDTM, X, Y, miniMap.getBounds())) then
begin
Timer.start;
wait(randomRange(1000, 1500));
printStatus('Found DTM!', 2);
mouse(X, Y, MOUSE_MOVE, MOUSE_HUMAN);
fastClick(MOUSE_LEFT);
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('runToStart: Finished with, Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting until player stops running...', 2);
wait(randomRange(250, 500));
until(not minimap.isPlayerMoving());
end;
printStatus('runToStart: Finished!', 3);
end;

// @ Procedure doLog
// * Completes Log Obstacle
// # Sets camera to face south after clicking on obstacle
// # Increments Obstacle to 1
procedure doLog;
begin
if not isLoggedIn then
exit;
printStatus('doLog: Starting...', 1);
runToStart;
printStatus('Beginning Log Search', 2);
if findObstacle(LOGCOLOR, LOGTOL, 2, 30, 70, 1, 1, 1, 1, LOGHUE, LOGSAT, ['og', 'ala', 'alance', 'Log']) then
begin
printStatus('Setting camera to face South', 2);;
minimap.setAngle(MM_DIRECTION_SOUTH);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Net Obstacle', 2);
Obstacle := 1;
progressReport(7.5);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doLog: Finished', 3);
end;

// @ Procedure doNet
// * Completes Net Obstacle
// # Increments Obstacle to 2
procedure doNet;
begin
if not isLoggedIn then
exit;
printStatus('doNet: Starting...', 1);
printStatus('Beginning Net Search', 2);
if findObstacle(NETCOLOR, NETTOL, 2, 160, 40, 0, 1, 1, 0, NETHUE, NETSAT, ['bstacle', 'net', 'Obstacle', 'Ob']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch1 Obstacle', 2);
Obstacle := 2;
progressReport(7.5);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doNet: Finished', 3);
end;

// @ Procedure doBranch1
// * Completes First Branch Obstacle
// # Increments Obstacle to 3
procedure doBranch1;
begin
if not isLoggedIn then
exit;
printStatus('doBranch1: Starting...', 1);
printStatus('Beginning Branch1 Search', 2);
if findObstacle(BRANCH1COLOR, BRANCH1TOL, 2, 70, 70, 1, 1, 1, 0, BRANCH1HUE, BRANCH1SAT, ['ree', 'branch', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch2 Obstacle', 2);
Obstacle := 3;
progressReport(5.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch1: Finished', 3);
end;

// @ Procedure doBranch2
// * Completes Second Branch Obstacle
// # Increments Obstacle to 4
procedure doBranch2;
begin
if not isLoggedIn then
exit;
printStatus('doBranch2: Starting...', 1);
printStatus('Beginning Branch2 Search', 2);
if findObstacle(BRANCH2COLOR, BRANCH2TOL, 2, 10, 40, 1, 1, 1, 2, BRANCH2HUE, BRANCH2SAT, ['ree', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Sign Obstacle', 2);
Obstacle := 4;
progressReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch2: Finished', 3);
end;

// @ Procedure doSign
// * Completes Sign Obstacle
// # Sets camera to face east after clicking on obstacle
// # Increments Obstacle to 5
procedure doSign;
begin
if not isLoggedIn then
exit;
printStatus('doSign: Starting...', 1);
printStatus('Beginning Sign Search', 2);
if findObstacle(SIGNCOLOR, SIGNTOL, 2, 15, 40, 1, 1, 1, 0, SIGNHUE, SIGNSAT, ['ign', 'post', 'Sign', 'Signpost']) then
begin
printStatus('Setting camera to face East', 2);
minimap.setAngle(MM_DIRECTION_WEST);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Pole Obstacle', 2);
Obstacle := 5;
progressReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doSign: Finished', 3);
end;

// @ Procedure doPole
// * Completes Pole Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 6
procedure doPole;
begin
if not isLoggedIn then
exit;
printStatus('doPole: Starting...', 1);
printStatus('Beginning Pole Search', 2);
if findObstacle(POLECOLOR, POLETOL, 2, 30, 200, 0, 1, 1, 0, POLEHUE, POLESAT, ['ole', 'Pole', 'Pol']) then
begin
printStatus('Setting camera to face North', 2);
minimap.clickCompass();
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Barrier Obstacle', 2);
Obstacle := 6;
progressReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doPole: Finished', 3);
end;

// @ Procedure doBarrier
// * Completes Barrier Obstacle
// # Sets camera to face north(high) after clicking on obstacle
// # Resets Obstacle to 0
procedure doBarrier;
begin
if not isLoggedIn then
exit;
printStatus('doBarrier: Starting...', 1);
printStatus('Beginning Barrier Search', 2);
if findObstacle(BARRIERCOLOR, BARRIERTOL, 2, 40, 40, 0, 1, 1, 0, BARRIERHUE, BARRIERSAT, ['arr', 'arrier', 'Barrier', 'Bar']) then
begin
printStatus('Setting camera to face North High', 2);
mainscreen.setAngle(0);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Log Obstacle', 2);
Obstacle := 0;
progressReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBarrier: Finished', 3);
end;

// @ Procedure doTheCourse
// * Checks fail count to see if we should log out, otherwise will complete course
procedure doTheCourse;
begin
if not isLoggedIn then
exit;
printStatus('doTheCourse: Starting...', 1);
printStatus('FailCount: ' + intToStr(FailCount), 2);
if FailCount > TIMESTOFAIL then
begin
printStatus('We failed too many times, logging out!', 2);
printStatus('doTheCourse: Finished!', 3);
killScript('Failed ' + intToStr(FailCount) + ' times');
end;
if Obstacle = 0 then
doLog;
if Obstacle = 1 then
doNet;
if Obstacle = 2 then
doBranch1;
if Obstacle = 3 then
doBranch2;
if Obstacle = 4 then
doSign;
if Obstacle = 5 then
doPole;
if Obstacle = 6 then
doBarrier;
progressReport(605.0);
printStatus('doTheCourse: Finished!', 3);
end;

// @ Main Loop
// * Loops through simple steps infinitley
// Not yet, testing here
begin
// clearDebug();
// if not DEBUGSCRIPT then
// disableSRLDebug := true;
// smartEnableDrawing := true;
// setupSRL;
// declarePlayers;
// Obstacle := 0;
// setDTMs;
//findObstacle(3362404, 16, 2, 30, 70, 1, 1, 1, 0.04, 0.08, ['og', 'ala', 'alance', 'Log']);
//findObstacle(4217200, 12, 2, 160, 40, 0, 1, 1, 0.10, 5.48, ['bstacle', 'net', 'Obstacle', 'Ob']);
//findObstacle(3164509, 8, 2, 70, 70, 1, 1, 1, 0.07, 0.12, ['ree', 'branch', 'Tree', 'Tre']);
//findObstacle(3032665, 7, 2, 10, 40, 1, 1, 1, 0.07, 0.10, ['ree', 'Tree', 'Tre']);
//findObstacle(6401217, 7, 2, 15, 40, 1, 1, 1, 0.32, 4.33, ['ign', 'post', 'Sign', 'Signpost']);
//findObstacle(4016464, 18, 2, 30, 200, 0, 1, 1, 0.06, 0.06, ['ole', 'Pole', 'Pol']);
//findObstacle(5342120, 15, 2, 40, 40, 0, 1, 1, 0.05, 5.56, ['arr', 'arrier', 'Barrier', 'Bar']);

//checkXpDrop;

//doLog;
//doNet;
//doBranch1;
//doBranch2;
//doSign;
//doPole;
//doBarrier;
//repeat
// doTheCourse;
//until(false);
//freeDTM(MMDTM);
setUsUp;
repeat
logUsIn;
doTheCourse;
until(false);
releaseDTMs;
terminateScript;
end.

Progress Report:
-------- *************Progress Report***************
-------- Time Running: 28 Minutes and 51 Seconds
-------- XP Gained: 21995
-------- XP/Hour: 45744
-------- Times Failed: 5
-------- *******************************************

A little slow since each time if fails it wastes a minute searching. So some of those colors are still an issue, I need to sit down and do a bunch of world changes to gather better colors. I also am thinking about cheating some of the search ranges on TPAs.

What happens if I have it search for a higher index than something that actually exists in the ATPA. So say my ATPA is of size 5, and I search from 0 to 9, would it stop at 5 or would it crash the script for trying to access a higher index than what exists in the ATPA?

The Mayor

2014-06-12 17:04:44

Looking good! Olly made one a while back (before RS3) which I thing was ~55k - 60k/h, if you want a benchmark :)

KeepBotting

2014-06-12 18:24:44

as far as the first problem is concerned, the xp popups themselves are actually prime candidates for DTMs

pretty to easy to make a DTM of the image, I did it with the fishing xp popup a while back

e: dug through my old files and found it. use it as a reference on how to make DTMs of xp popups if you need.

https://www.dropbox.com/s/8kcukh3n4n3yujz/fishingXpPopup.dtm

Brotein

2014-06-13 08:17:59

From: KeepBotting
as far as the first problem is concerned, the xp popups themselves are actually prime candidates for DTMs

pretty to easy to make a DTM of the image, I did it with the fishing xp popup a while back

e: dug through my old files and found it. use it as a reference on how to make DTMs of xp popups if you need.

https://www.dropbox.com/s/8kcukh3n4n3yujz/fishingXpPopup.dtm


Thanks for the suggestion. This is actually nice to see how others would do it but I decided to use this for the search.

repeat
....
until(findColorsTolerance());

It hasn't failed once in detection and is almost instant, grabs the color very fast, sometimes as soon as the first pixel on the top of the text popups.

KeepBotting

2014-06-13 09:48:17

From: Brotein
Thanks for the suggestion. This is actually nice to see how others would do it but I decided to use this for the search.

repeat
....
until(findColorsTolerance());

It hasn't failed once in detection and is almost instant, grabs the color very fast, sometimes as soon as the first pixel on the top of the text popups.
that's certainly just as valid a method, but make sure to impose failsafes upon that function as well, in case of a misclick or other unforseen error so you don't get stuck in an infinite loop

Brotein

2014-06-15 15:43:53

Got the paint done! Just need to clean up the code and go back and get some as accurate as possible colors and this is ready to go.
Then I'll add in the barbarian course when I get the level to do it without failing.




The Mayor

2014-06-15 17:23:41

You always have nice paints

Brotein

2014-06-17 20:45:46

From: The Mayor
You always have nice paints


Thanks I try to make them blend in with the RS3 interface/style.

Anyways, updated it a bit more, sorry I am not posting code right now I left that version at work and didn't commit it. Sped up the waits and everything else, just need to fix the search area for some obstacles to prevent it from hovering over stuff that we know isn't the obstacle.


So I think I can get this running at a solid 55k/hr, which I think is good considering the highest you can get is 65k/hr with perfect clicks and preemptively aiming the mouse at obstacles.

KeepBotting

2014-06-17 20:50:38

Lookin' sexy! Can't wait to see the sauce!

Brotein

2014-06-19 11:50:45

Just around that 55k/hr mark.

Need to go through and re-log/switch worlds for better colors now, throw in the auto-updater and this is about done.
program BroteinAdvAgile;

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

var
X, Y, MMDTM, Obstacle, FailCount : Integer;
XpGained, XpHour, SecondS : Extended;

////////////////////////////////////////////////////////////////////////////////
// Change Constants Here //
////////////////////////////////////////////////////////////////////////////////
const
DEBUGSCRIPT = true; //Enable if you are having issues running script
DEBUGCOLORS = false; //Enable if you are having issues running script
USEONSCREEN = true; //Enable for onscreen progress report
TIMESTOFAIL = 1000; //Maximum times the script is allowed to fail before logging out
STARTOBSTACLE = 0; //0=log, 1=net, 2=branch1, 3=branch2, 4=sign, 5=post, 6=barrier

//ACA Settings for Log Obstacle
LOGCOLOR = 3362148;
LOGTOL = 16;
LOGHUE = 0.06;
LOGSAT = 0.12;

//ACA Settings for Net Obstacle
NETCOLOR = 4348787;
NETTOL = 13;
NETHUE = 0.10;
NETSAT = 5.49;

//ACA Settings for Branch1 Obstacle
BRANCH1COLOR = 4348010;
BRANCH1TOL = 18;
BRANCH1HUE = 0.04;
BRANCH1SAT = 0.57;

//ACA Settings for Bracnh2 Obstacle
BRANCH2COLOR = 2835028;
BRANCH2TOL = 10;
BRANCH2HUE = 0.06;
BRANCH2SAT = 0.25;

//ACA Settings for Sign Obstacle
SIGNCOLOR = 6401217;
SIGNTOL = 7;
SIGNHUE = 0.32;
SIGNSAT = 4.33;

//ACA Settings for Pole Obstacle
POLECOLOR = 4016464;
POLETOL = 18;
POLEHUE = 0.06;
POLESAT = 0.06;

//ACA Settings for Barrier Obstacle
BARRIERCOLOR = 5277871;
BARRIERTOL = 16;
BARRIERHUE = 0.08;
BARRIERSAT = 5.56;

//ACA Setting for Xp Drop/Popup
XPCOLOR = 4040932;
XPTOL = 2;
XPHUE = 0.13;
XPSAT = 2.79;

////////////////////////////////////////////////////////////////////////////////
// Set up your Character info here!!! //
////////////////////////////////////////////////////////////////////////////////
procedure declarePlayers;
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; //Set username here
password := ''; //Set password here
bankPin := ''; //Set PIN here
world := 1; //Set world here
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

////////////////////////////////////////////////////////////////////////////////
// Script starts here, Setup Complete! //
////////////////////////////////////////////////////////////////////////////////
// @ Procedure printStatus
// * Used for debugging our script to a log by using print
// * Will draw progress report at all times, and only progress report if we
// are not using the DEBUGSCRIPT constant.
procedure printStatus(Jamc : String; PrintType : Integer);
begin
if DEBUGSCRIPT then
begin
if PrintType = 0 then
print(Jamc, TDebug.SUB);
if PrintType = 1 then
print(Jamc, TDebug.HEADER);
if PrintType = 2 then
print(Jamc, TDebug.SUB);
if PrintType = 3 then
print(Jamc, TDebug.FOOTER);
if PrintType = 4 then
print(Jamc, TDebug.ERROR);
if PrintType = 5 then
writeLn(Jamc);
end;
if not DEBUGSCRIPT then
begin
if PrintType = 0 then
writeLn(Jamc);
end;
end

// @ Procedure takeScreen by Olly
// * Saves a screenshot and blurs out info, safe for upload
procedure takeScreen(Reason : String);
procedure blur(Bmp, Xs, Ys, Xe, Ye: Integer);
var
BmpCopy, Tmp: Integer;
begin
BmpCopy := copyBitmap(Bmp);
cropBitmap(BmpCopy, Xs, Ys, Xe, Ye);
Tmp := convoluteBitmap(BmpCopy, gaussMatrix(6, 3.00));
fastDrawTransparent(Xs, Ys, Tmp, Bmp);
freeBitmaps([BmpCopy, Tmp]);
end;
var
BmpClient, W, H, I: Integer;
Areas: TBoxArray;
begin
getClientDimensions(W, H);
BmpClient := bitmapFromClient(0, 0, W-1, H-1);
Areas := [[actionBar.x1, actionbar.y1, chatBox.x2, chatBox.y2], mainScreen.playerBox,
[tabBackpack.x1-4, tabBackpack.y2 - 40, tabBackpack.x2, tabBackpack.y2],
[mainScreen.x2 - 130, mainScreen.y1, mainScreen.x2, mainScreen.y1 + 75]];

for I := 0 to high(Areas) do
blur(BmpClient, Areas[i].x1, Areas[i].y1, Areas[i].x2, Areas[i].y2);
getMufasaBitmap(BmpClient).drawClippedText('Reason: ' + Reason + 'Time:' + theTime, point(chatBox.x1 + 5, chatBox.y2 - 16), StatChars, true, clLime);
saveBitmap(BmpClient, appPath + 'BroteinAdvAgile' + '.png');
debugBitmap(BmpClient);
freeBitmap(BmpClient);
end;

// @ Function getXP by Ashaman88
// * Gets XP in current xp counter on chat box.
function TRSChatBox.getXP: Integer;
var
B : TBox;
S : String;
TPA : TPointArray;
ATPA : T2DPointArray;
P : Integer;
begin
printStatus('TRSChatBox.getXP: Starting...', 1);
B := self.getBounds();
B.edit( +(B.x2 - B.x1) - 140, +10, -5, -94);
findColorsTolerance(TPA, 14013909, B, 4, colorSetting(2, 0.00, 0.00));
if length(TPA) < 2 then
begin
printStatus('chatBox.getXP(): No XP found', 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
exit;
end;
ATPA := TPA.cluster(10);
ATPA.sortFromFirstPoint(point(B.x2, B.y2));
B := ATPA[low(ATPA)].getbounds;
B.edit(-2, -2, +2, +3);
S := Replace(tesseractgettext(B.x1, B.y1, B.x2, B.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);
P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(S, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);
printStatus('chatBox.getXP(): XP found: ' + tostr(result), 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
end;

// @ Procedure setDTMs
// * Sets our DTM
// # MMDTM
procedure setDTMs
begin
MMDTM := DTMFromString('mWAAAAHicY2FgYBBhZWDgAmJRIBYD4jhGBoZsIM4H4gAg3jZFi6EhSYvhzdM+hhmdiQwaQD3ImBENgwAArpkI8w==');
end;

// @ Procedure releaseDTMs
// * Frees our DTM from memory
// # [OreDTM]
procedure releaseDTMs;
begin
freeDTMs([MMDTM]);
end;

// @ Procedure killScript
// * Kills our script
// # Reason used for Debug
procedure killScript(Reason : String);
begin
printStatus('killScript: Starting...', 0);
takeScreen(Reason);
if isLoggedIn then
players[currentPlayer].logout();
terminateScript;
printStatus('killScript: Finished! Script terminated at time: ' + theTime + ', Script ran for: ' + timeRunning + ', Stopped for reason: ' + Reason, 0);
end;


// @ Function timeRunningShort
// * Same as timeRunning, but uses TIME_SHORT constant
function timeRunningShort(TheType: Integer = TIME_SHORT): string;
begin
Result := msToTime(GetTimeRunning(), TheType);
end;

// @ Proecure progressReport
// * Will display our progress, and increments XpGained by obstacle XP
// # XpGained, XpHour, timeRunning, FailCount
procedure progressReport(IncAmount : Extended);
begin
if not DEBUGSCRIPT then
clearDebug();
XpGained := XpGained + IncAmount;
SecondS := round((getTimeRunning/1000));
XpHour := round((3600 * XpGained) / (SecondS));
printStatus('*************Progress Report***************', 0);
printStatus('Time Running: ' + timeRunningShort, 0);
printStatus('XP Gained: ' + floatToStr(XpGained), 0);
printStatus('XP/Hour: ' + floatToStr(XpHour), 0);
printStatus('Times Failed: ' + intToStr(FailCount), 0);
printStatus('*******************************************', 0);
end;

// @ Procedure onScreenReport
// * Same as progressReport expect will draw most of the information onscreen
procedure onScreenReport(IncAmount : Extended);
var
ScreenProggy : Integer;
InfoPoints : TPointArray;
begin
progressReport(IncAmount);
if USEONSCREEN then
begin
InfoPoints := [Point(245,509), Point(220,541), Point(442,541), Point(490,500), Point(4,447), Point(240 ,315)];
ScreenProggy := loadBitmap(appPath + '/AdvAgileProg.png');
smartImage.clear();
smartImage.drawBitmap(ScreenProggy, InfoPoints[4]);
smartImage.drawText(timeRunningShort, InfoPoints[0], UpChars, false, 1423591);
smartImage.drawText(floatToStr(XpGained), InfoPoints[1], BigChars, false, 1423591);
smartImage.drawText(floatToStr(XpHour), InfoPoints[2], BigChars, false, 1423591);
smartImage.drawText(intToStr(FailCount), InfoPoints[3], BigChars, false, 1423591);
freeBitmap(ScreenProggy);
end;
end;

// @ Procedure setUsUp
// * Does our intial setup stuff for script during startup
procedure setUsUp;
begin
printStatus('setUsUp: Starting...', 1);
clearDebug();
//autoUpdateMe;
if not DEBUGSCRIPT then
disableSRLDebug := true;
smartEnableDrawing := true;
setupSRL;
setDTMs;
addOnTerminate('releaseDTMs');
declarePlayers;
Obstacle := STARTOBSTACLE;
MouseSpeed := 50;
onScreenReport(0.0);
printStatus('setUsUp: Finished!', 3);
end;

// @ Procedure logUsIn
// * Logs in player when not logged in and closes Treasure popup
procedure logUsIn;
begin
printStatus('logUsIn: Starting...', 1);
if not isLoggedIn then
begin
players[currentPlayer].login();
exitTreasure();
if Obstacle = 0 then
begin
minimap.clickCompass();
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 1 or Obstacle = 2 or Obstacle = 3 or Obstacle = 4 then
begin
minimap.setAngle(MM_DIRECTION_SOUTH);
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 5 then
begin
minimap.setAngle(MM_DIRECTION_WEST);
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 6 then
begin
minimap.clickCompass();
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
end;
printStatus('logUsIn: Finished!', 3);
end;

// @ Function findObstacle
// * TPA finding function for the obstacles in our course.
// # ObColor, ObTol, ObCTS, ObHue, ObSat: Fill in with ACA(Color, Tolerance, ColorToleranceSpeed, Hue, Saturation)
// # ATPAW, ATPAH: Width and Height of ATPA
// # ObSort: 0 for sort ATPA by size, 1 for sort ATPA from midpoint(player)
// # RanX1, RanX2, RanY1, RanY2 : Used to set randomrange for point x,y randomness in ATPA
// # IndexLow, IndexHigh : Used for ATPA[i] search
// # SearchBox : Used to set search area
// # ObUpText : UpText for the object as a String Array
function findObstacle(ObColor, ObTol, ObCTS, ATPAW, ATPAH, ObSort, RanX1, RanX2, RanY1, RanY2, IndexLow, IndexHigh, EndWaitTime : Integer; ObHue, ObSat : Extended; SearchBox: TBox; ObUpText : TStringArray) : Boolean;
var
p : TPoint;
px, py, i : Integer;
ObTPA : TPointArray;
ObATPA : T2DPointArray;
begin
if not isLoggedIn then
exit;
printStatus('findObstacle: Starting...', 1);
printStatus('Looking for obstacle', 2);
if findColorsSpiralTolerance(px, py, ObTPA, ObColor, SearchBox, ObTol, colorSetting(ObCTS, ObHue, ObSat)) then
begin
ObATPA := ObTPA.toATPA(ATPAW, ATPAH);
ObATPA.filterBetween(0, 50);
if ObSort = 0 then
ObATPA.sortBySize(true);
if ObSort = 1 then
ObATPA.sortFromMidPoint(mainscreen.playerPoint);
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(ObTPA, true);
smartImage.debugATPA(ObATPA);
end;
for i := IndexLow to IndexHigh do
begin
p := middleTPA(ObATPA[i]);
p.offset(point(randomRange(RanX1, RanX1 + RanX2), randomRange(RanY1, RanY1 + RanY2)));
mouse(p.x, p.y, MOUSE_MOVE, MOUSE_HUMAN);
printStatus('Point we click on: ' + intToStr(p.x) + ', ' + intToStr(p.y), 2);
wait(randomRange(150, 175));
if isMouseOverText(ObUpText) then
begin
wait(150 + random(50));
fastClick(MOUSE_LEFT);
printStatus('Found Obstacle!', 2);
wait(randomRange(125, 250));
if DEBUGCOLORS then
smartImage.clear();
wait(random(250));
printStatus('Done Waiting', 2);
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
Result := true;
exit;
end;
end;
wait(EndWaitTime + random(50));
end;
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
end;

// @ Function checkXpDrop
// * Returns true when xp popup is found on mainscreen, times out at 15 seconds
function checkXpDrop : Boolean;
var
XpTPA : TPointArray;
Timer : TTimeMarker;
begin
if not isLoggedIn then
exit;
printStatus('checkXpDrop: Starting...', 1);
Timer.start;
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result) + ', Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting...', 2);
wait(randomRange(125, 250));
until(findColorsTolerance(XpTPA, XPCOLOR, intToBox(266, 7, 500, 239), XPTOL, colorSetting(2, XPHUE, XPSAT)));
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(XpTPA, true);
end;
Timer.reset;
Result := true;
wait(randomRange(150, 225));
if DEBUGCOLORS then
smartImage.clear();
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result), 3);
end;

// @ Procedure runToStart
// * Stuff
procedure runToStart;
var
Timer : TTimeMarker;
begin
printStatus('runToStart: Starting...', 1);
printStatus('Looking for DTM...', 2);
if(findDTM(MMDTM, X, Y, miniMap.getBounds())) then
begin
Timer.start;
printStatus('Found DTM!', 2);
mouse(X, Y, MOUSE_MOVE, MOUSE_HUMAN);
fastClick(MOUSE_LEFT);
wait(randomRange(500, 750));
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('runToStart: Finished with, Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting until player stops running...', 2);
wait(randomRange(1000, 1500));
until(not minimap.isPlayerMoving());
end;
printStatus('runToStart: Finished!', 3);
end;

// @ Procedure doLog
// * Completes Log Obstacle
// # Sets camera to face south after clicking on obstacle
// # Increments Obstacle to 1
procedure doLog;
begin
if not isLoggedIn then
exit;
printStatus('doLog: Starting...', 1);
runToStart;
printStatus('Beginning Log Search', 2);
if findObstacle(LOGCOLOR, LOGTOL, 2, 30, 70, 1, 1, 0, -10, 0, 1, 3, 750, LOGHUE, LOGSAT, mainScreen.getBounds(), ['og', 'ala', 'alance', 'Log']) then
begin
printStatus('Setting camera to face South', 2);;
minimap.setAngle(MM_DIRECTION_SOUTH);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Net Obstacle', 2);
Obstacle := 1;
onScreenReport(7.5);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doLog: Finished', 3);
end;

// @ Procedure doNet
// * Completes Net Obstacle
// # Increments Obstacle to 2
procedure doNet;
begin
if not isLoggedIn then
exit;
printStatus('doNet: Starting...', 1);
printStatus('Beginning Net Search', 2);
if findObstacle(NETCOLOR, NETTOL, 2, 160, 40, 0, 1, 0, 1, 0, 0, 2, 250, NETHUE, NETSAT, mainScreen.getBounds(), ['bstacle', 'net', 'Obstacle', 'Ob']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch1 Obstacle', 2);
Obstacle := 2;
onScreenReport(7.5);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doNet: Finished', 3);
end;

// @ Procedure doBranch1
// * Completes First Branch Obstacle
// # Increments Obstacle to 3
procedure doBranch1;
begin
if not isLoggedIn then
exit;
printStatus('doBranch1: Starting...', 1);
printStatus('Beginning Branch1 Search', 2);
if findObstacle(BRANCH1COLOR, BRANCH1TOL, 2, 70, 70, 1, 1, 0, 1, 0, 0, 2, 250, BRANCH1HUE, BRANCH1SAT, intToBox(162, 77 , 371, 222), ['ree', 'branch', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch2 Obstacle', 2);
Obstacle := 3;
onScreenReport(5.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch1: Finished', 3);
end;

// @ Procedure doBranch2
// * Completes Second Branch Obstacle
// # Increments Obstacle to 4
procedure doBranch2;
begin
if not isLoggedIn then
exit;
printStatus('doBranch2: Starting...', 1);
printStatus('Beginning Branch2 Search', 2);
if findObstacle(BRANCH2COLOR, BRANCH2TOL, 2, 10, 40, 1, 1, 0, 1, 0, 1, 3, 250, BRANCH2HUE, BRANCH2SAT, intToBox(189, 102, 333, 204), ['ree', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Sign Obstacle', 2);
Obstacle := 4;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch2: Finished', 3);
end;

// @ Procedure doSign
// * Completes Sign Obstacle
// # Sets camera to face east after clicking on obstacle
// # Increments Obstacle to 5
procedure doSign;
begin
if not isLoggedIn then
exit;
printStatus('doSign: Starting...', 1);
printStatus('Beginning Sign Search', 2);
if findObstacle(SIGNCOLOR, SIGNTOL, 2, 15, 40, 1, 1, 0, 1, 0, 0, 1, 250, SIGNHUE, SIGNSAT, mainScreen.getBounds(), ['ign', 'post', 'Sign', 'Signpost']) then
begin
printStatus('Setting camera to face East', 2);
minimap.setAngle(MM_DIRECTION_WEST);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Pole Obstacle', 2);
Obstacle := 5;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doSign: Finished', 3);
end;

// @ Procedure doPole
// * Completes Pole Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 6
procedure doPole;
begin
if not isLoggedIn then
exit;
printStatus('doPole: Starting...', 1);
printStatus('Beginning Pole Search', 2);
if findObstacle(POLECOLOR, POLETOL, 2, 30, 200, 0, 1, 0, 1, 0, 0, 1, 250, POLEHUE, POLESAT, mainScreen.getBounds(), ['ole', 'Pole', 'Pol']) then
begin
printStatus('Setting camera to face North', 2);
minimap.clickCompass();
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Barrier Obstacle', 2);
Obstacle := 6;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doPole: Finished', 3);
end;

// @ Procedure doBarrier
// * Completes Barrier Obstacle
// # Sets camera to face north(high) after clicking on obstacle
// # Resets Obstacle to 0
procedure doBarrier;
begin
if not isLoggedIn then
exit;
printStatus('doBarrier: Starting...', 1);
printStatus('Beginning Barrier Search', 2);
if findObstacle(BARRIERCOLOR, BARRIERTOL, 2, 40, 40, 0, 1, 0, 1, 0, 0, 2, 250, BARRIERHUE, BARRIERSAT, intToBox(206, 106, 330, 192) , ['arr', 'arrier', 'Barrier', 'Bar']) then
begin
printStatus('Setting camera to face North High', 2);
mainscreen.setAngle(0);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Log Obstacle', 2);
Obstacle := 0;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBarrier: Finished', 3);
end;

// @ Procedure doTheCourse
// * Checks fail count to see if we should log out, otherwise will complete course
procedure doTheCourse;
begin
if not isLoggedIn then
exit;
printStatus('doTheCourse: Starting...', 1);
printStatus('FailCount: ' + intToStr(FailCount), 2);
if FailCount > TIMESTOFAIL then
begin
printStatus('We failed too many times, logging out!', 2);
printStatus('doTheCourse: Finished!', 3);
killScript('Failed ' + intToStr(FailCount) + ' times');
end;
if Obstacle = 0 then
doLog;
if Obstacle = 1 then
doNet;
if Obstacle = 2 then
doBranch1;
if Obstacle = 3 then
doBranch2;
if Obstacle = 4 then
doSign;
if Obstacle = 5 then
doPole;
if Obstacle = 6 then
begin
doBarrier;
onScreenReport(605.0);
end;
printStatus('doTheCourse: Finished!', 3);
end;

// @ Main Loop
// * Runs the course
begin
setUsUp;
repeat
logUsIn;
doTheCourse;
until(false);
releaseDTMs;
terminateScript;
end.

Brotein

2014-07-05 18:07:39

This version is running pretty stable right now if you guys want to use it. Got above a 3 hour report, avg around 52k/hr. Caught it crashing by misreading someone's spotted cape for xp-gain during the log obstacle and froze the script. Going to rethink my failsafes on that one so it can correct from something like that. Once I hit 93 agility, I'll work on the barb course and release this one as a JR member script.

If you are going to use it, log in by the start of course, camera facing north-high zoomed out(Classic camera mode), and set rotate sensitivity to be low.

program BroteinAdvAgile;

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

var
X, Y, MMDTM, Obstacle, FailCount : Integer;
XpGained, XpHour, SecondS : Extended;

////////////////////////////////////////////////////////////////////////////////
// Change Constants Here //
////////////////////////////////////////////////////////////////////////////////
const
DEBUGSCRIPT = true; //Enable if you are having issues running script
DEBUGCOLORS = true; //Enable if you are having issues running script
USEONSCREEN = false; //Enable for onscreen progress report
TIMESTOFAIL = 1000; //Maximum times the script is allowed to fail before logging out
STARTOBSTACLE = 0; //0=log, 1=net, 2=branch1, 3=branch2, 4=sign, 5=post, 6=barrier

//ACA Settings for Log Obstacle
LOGCOLOR = 3164767;
LOGTOL = 17;
LOGHUE = 0.06;
LOGSAT = 0.13;

//ACA Settings for Net Obstacle
NETCOLOR = 4282995;
NETTOL = 13;
NETHUE = 0.11;
NETSAT = 5.49;

//ACA Settings for Branch1 Obstacle
BRANCH1COLOR = 3821149;
BRANCH1TOL = 22;
BRANCH1HUE = 0.04;
BRANCH1SAT = 0.47;

//ACA Settings for Bracnh2 Obstacle
BRANCH2COLOR = 2900821;
BRANCH2TOL = 11;
BRANCH2HUE = 0.05;
BRANCH2SAT = 0.19;

//ACA Settings for Sign Obstacle
SIGNCOLOR = 6401217;
SIGNTOL = 7;
SIGNHUE = 0.32;
SIGNSAT = 4.33;

//ACA Settings for Pole Obstacle
POLECOLOR = 4016464;
POLETOL = 18;
POLEHUE = 0.06;
POLESAT = 0.06;

//ACA Settings for Barrier Obstacle
BARRIERCOLOR = 5343664;
BARRIERTOL = 17;
BARRIERHUE = 0.07;
BARRIERSAT = 5.38;

//ACA Setting for Xp Drop/Popup
XPCOLOR = 4040932;
XPTOL = 2;
XPHUE = 0.13;
XPSAT = 2.79;

////////////////////////////////////////////////////////////////////////////////
// Set up your Character info here!!! //
////////////////////////////////////////////////////////////////////////////////
procedure declarePlayers;
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; //Set username here
password := ''; //Set password here
bankPin := ''; //Set PIN here
world := 1; //Set world here
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

////////////////////////////////////////////////////////////////////////////////
// Script starts here, Setup Complete! //
////////////////////////////////////////////////////////////////////////////////
// @ Procedure printStatus
// * Used for debugging our script to a log by using print
// * Will draw progress report at all times, and only progress report if we
// are not using the DEBUGSCRIPT constant.
procedure printStatus(Jamc : String; PrintType : Integer);
begin
if DEBUGSCRIPT then
begin
if PrintType = 0 then
print(Jamc, TDebug.SUB);
if PrintType = 1 then
print(Jamc, TDebug.HEADER);
if PrintType = 2 then
print(Jamc, TDebug.SUB);
if PrintType = 3 then
print(Jamc, TDebug.FOOTER);
if PrintType = 4 then
print(Jamc, TDebug.ERROR);
if PrintType = 5 then
writeLn(Jamc);
end;
if not DEBUGSCRIPT then
begin
if PrintType = 0 then
writeLn(Jamc);
end;
end

// @ Procedure takeScreen by Olly
// * Saves a screenshot and blurs out info, safe for upload
procedure takeScreen(Reason : String);
procedure blur(Bmp, Xs, Ys, Xe, Ye: Integer);
var
BmpCopy, Tmp: Integer;
begin
BmpCopy := copyBitmap(Bmp);
cropBitmap(BmpCopy, Xs, Ys, Xe, Ye);
Tmp := convoluteBitmap(BmpCopy, gaussMatrix(6, 3.00));
fastDrawTransparent(Xs, Ys, Tmp, Bmp);
freeBitmaps([BmpCopy, Tmp]);
end;
var
BmpClient, W, H, I: Integer;
Areas: TBoxArray;
begin
getClientDimensions(W, H);
BmpClient := bitmapFromClient(0, 0, W-1, H-1);
Areas := [[actionBar.x1, actionbar.y1, chatBox.x2, chatBox.y2], mainScreen.playerBox,
[tabBackpack.x1-4, tabBackpack.y2 - 40, tabBackpack.x2, tabBackpack.y2],
[mainScreen.x2 - 130, mainScreen.y1, mainScreen.x2, mainScreen.y1 + 75]];

for I := 0 to high(Areas) do
blur(BmpClient, Areas[i].x1, Areas[i].y1, Areas[i].x2, Areas[i].y2);
getMufasaBitmap(BmpClient).drawClippedText('Reason: ' + Reason + 'Time:' + theTime, point(chatBox.x1 + 5, chatBox.y2 - 16), StatChars, true, clLime);
saveBitmap(BmpClient, appPath + 'BroteinAdvAgile' + '.png');
debugBitmap(BmpClient);
freeBitmap(BmpClient);
end;

// @ Function getXP by Ashaman88
// * Gets XP in current xp counter on chat box.
function TRSChatBox.getXP: Integer;
var
B : TBox;
S : String;
TPA : TPointArray;
ATPA : T2DPointArray;
P : Integer;
begin
printStatus('TRSChatBox.getXP: Starting...', 1);
B := self.getBounds();
B.edit( +(B.x2 - B.x1) - 140, +10, -5, -94);
findColorsTolerance(TPA, 14013909, B, 4, colorSetting(2, 0.00, 0.00));
if length(TPA) < 2 then
begin
printStatus('chatBox.getXP(): No XP found', 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
exit;
end;
ATPA := TPA.cluster(10);
ATPA.sortFromFirstPoint(point(B.x2, B.y2));
B := ATPA[low(ATPA)].getbounds;
B.edit(-2, -2, +2, +3);
S := Replace(tesseractgettext(B.x1, B.y1, B.x2, B.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);
P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(S, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);
printStatus('chatBox.getXP(): XP found: ' + tostr(result), 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
end;

// @ Procedure setDTMs
// * Sets our DTM
// # MMDTM
procedure setDTMs
begin
MMDTM := DTMFromString('mWAAAAHicY2FgYBBhZWDgAmJRIBYD4jhGBoZsIM4H4gAg3jZFi6EhSYvhzdM+hhmdiQwaQD3ImBENgwAArpkI8w==');
end;

// @ Procedure releaseDTMs
// * Frees our DTM from memory
// # [OreDTM]
procedure releaseDTMs;
begin
freeDTMs([MMDTM]);
end;

// @ Procedure killScript
// * Kills our script
// # Reason used for Debug
procedure killScript(Reason : String);
begin
printStatus('killScript: Starting...', 0);
takeScreen(Reason);
if isLoggedIn then
players[currentPlayer].logout();
terminateScript;
printStatus('killScript: Finished! Script terminated at time: ' + theTime + ', Script ran for: ' + timeRunning + ', Stopped for reason: ' + Reason, 0);
end;


// @ Function timeRunningShort
// * Same as timeRunning, but uses TIME_SHORT constant
function timeRunningShort(TheType: Integer = TIME_SHORT): string;
begin
Result := msToTime(GetTimeRunning(), TheType);
end;

// @ Proecure progressReport
// * Will display our progress, and increments XpGained by obstacle XP
// # XpGained, XpHour, timeRunning, FailCount
procedure progressReport(IncAmount : Extended);
begin
if not DEBUGSCRIPT then
clearDebug();
XpGained := XpGained + IncAmount;
SecondS := round((getTimeRunning/1000));
XpHour := round((3600 * XpGained) / (SecondS));
printStatus('*************Progress Report***************', 0);
printStatus('Time Running: ' + timeRunningShort, 0);
printStatus('XP Gained: ' + floatToStr(XpGained), 0);
printStatus('XP/Hour: ' + floatToStr(XpHour), 0);
printStatus('Times Failed: ' + intToStr(FailCount), 0);
printStatus('*******************************************', 0);
end;

// @ Procedure onScreenReport
// * Same as progressReport expect will draw most of the information onscreen
procedure onScreenReport(IncAmount : Extended);
var
ScreenProggy : Integer;
InfoPoints : TPointArray;
begin
progressReport(IncAmount);
if USEONSCREEN then
begin
InfoPoints := [Point(245,509), Point(220,541), Point(442,541), Point(490,500), Point(4,447), Point(240 ,315)];
ScreenProggy := loadBitmap(appPath + 'AdvAgileProg.png');
smartImage.clear();
smartImage.drawBitmap(ScreenProggy, InfoPoints[4]);
smartImage.drawText(timeRunningShort, InfoPoints[0], UpChars, false, 1423591);
smartImage.drawText(floatToStr(XpGained), InfoPoints[1], BigChars, false, 1423591);
smartImage.drawText(floatToStr(XpHour), InfoPoints[2], BigChars, false, 1423591);
smartImage.drawText(intToStr(FailCount), InfoPoints[3], BigChars, false, 1423591);
freeBitmap(ScreenProggy);
end;
end;

// @ Procedure setUsUp
// * Does our intial setup stuff for script during startup
procedure setUsUp;
begin
printStatus('setUsUp: Starting...', 1);
clearDebug();
//autoUpdateMe;
if not DEBUGSCRIPT then
disableSRLDebug := true;
smartEnableDrawing := true;
setupSRL;
setDTMs;
addOnTerminate('releaseDTMs');
declarePlayers;
Obstacle := STARTOBSTACLE;
MouseSpeed := 50;
onScreenReport(0.0);
printStatus('setUsUp: Finished!', 3);
end;

// @ Procedure logUsIn
// * Logs in player when not logged in and closes Treasure popup
procedure logUsIn;
begin
printStatus('logUsIn: Starting...', 1);
if not isLoggedIn then
begin
players[currentPlayer].login();
exitTreasure();
if Obstacle = 0 then
begin
minimap.clickCompass();
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 1 or Obstacle = 2 or Obstacle = 3 or Obstacle = 4 then
begin
minimap.setAngle(MM_DIRECTION_SOUTH);
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 5 then
begin
minimap.setAngle(MM_DIRECTION_WEST);
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 6 then
begin
minimap.clickCompass();
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
end;
printStatus('logUsIn: Finished!', 3);
end;

// @ Function findObstacle
// * TPA finding function for the obstacles in our course.
// # ObColor, ObTol, ObCTS, ObHue, ObSat: Fill in with ACA(Color, Tolerance, ColorToleranceSpeed, Hue, Saturation)
// # ATPAW, ATPAH: Width and Height of ATPA
// # ObSort: 0 for sort ATPA by size, 1 for sort ATPA from midpoint(player)
// # RanX1, RanX2, RanY1, RanY2 : Used to set randomrange for point x,y randomness in ATPA
// # IndexLow, IndexHigh : Used for ATPA[i] search
// # SearchBox : Used to set search area
// # ObUpText : UpText for the object as a String Array
function findObstacle(ObColor, ObTol, ObCTS, ATPAW, ATPAH, ObSort, RanX1, RanX2, RanY1, RanY2, IndexLow, IndexHigh, EndWaitTime : Integer; ObHue, ObSat : Extended; SearchBox: TBox; ObUpText : TStringArray) : Boolean;
var
p : TPoint;
px, py, i : Integer;
ObTPA : TPointArray;
ObATPA : T2DPointArray;
begin
if not isLoggedIn then
exit;
printStatus('findObstacle: Starting...', 1);
printStatus('Looking for obstacle', 2);
if findColorsSpiralTolerance(px, py, ObTPA, ObColor, SearchBox, ObTol, colorSetting(ObCTS, ObHue, ObSat)) then
begin
ObATPA := ObTPA.toATPA(ATPAW, ATPAH);
ObATPA.filterBetween(0, 50);
if ObSort = 0 then
ObATPA.sortBySize(true);
if ObSort = 1 then
ObATPA.sortFromMidPoint(mainscreen.playerPoint);
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(ObTPA, true);
smartImage.debugATPA(ObATPA);
end;
for i := IndexLow to IndexHigh do
begin
p := middleTPA(ObATPA[i]);
p.offset(point(randomRange(RanX1, RanX1 + RanX2), randomRange(RanY1, RanY1 + RanY2)));
mouse(p.x, p.y, MOUSE_MOVE, MOUSE_HUMAN);
printStatus('Point we click on: ' + intToStr(p.x) + ', ' + intToStr(p.y), 2);
wait(randomRange(150, 175));
if isMouseOverText(ObUpText) then
begin
wait(150 + random(50));
fastClick(MOUSE_LEFT);
printStatus('Found Obstacle!', 2);
wait(randomRange(125, 250));
if DEBUGCOLORS then
smartImage.clear();
wait(random(250));
printStatus('Done Waiting', 2);
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
Result := true;
exit;
end;
end;
wait(EndWaitTime + random(50));
end;
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
end;

// @ Function checkXpDrop
// * Returns true when xp popup is found on mainscreen, times out at 15 seconds
function checkXpDrop : Boolean;
var
XpTPA : TPointArray;
Timer : TTimeMarker;
begin
if not isLoggedIn then
exit;
printStatus('checkXpDrop: Starting...', 1);
Timer.start;
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result) + ', Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting...', 2);
wait(randomRange(125, 250));
until(findColorsTolerance(XpTPA, XPCOLOR, intToBox(256, 0, 505, 303), XPTOL, colorSetting(2, XPHUE, XPSAT)));
if DEBUGCOLORS then
begin
smartImage.clear;
smartImage.debugTPA(XpTPA, true);
end;
Timer.reset;
Result := true;
wait(randomRange(150, 225));
if DEBUGCOLORS then
smartImage.clear();
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result), 3);
end;

// @ Function checkWaterMM
// * Returns true when water is found on minimap, times out at 15 seconds
function checkWaterMM : Boolean;
var
WaterTPA : TPointArray;
Timer : TTimeMarker;
begin
if not isLoggedIn then
exit;
printStatus('checkWaterMM: Starting...', 1);
Timer.start;
repeat
if Timer.getTime > 2500 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('checkWaterMM: Finished with Result: ' + boolToStr(Result) + ', Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting...', 2);
wait(randomRange(125, 250));
until(findColorsTolerance(WaterTPA, 8088158, intToBox(732, 14, 794, 151), 10, colorSetting(2, 1.64, 1.93)));
Timer.reset;
Result := true;
wait(randomRange(150, 225));
if DEBUGCOLORS then
smartImage.clear();
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result), 3);
end;

// @ Procedure runToStart
// * Stuff
procedure runToStart;
var
Timer : TTimeMarker;
begin
printStatus('runToStart: Starting...', 1);
printStatus('Looking for DTM...', 2);
if(findDTM(MMDTM, X, Y, miniMap.getBounds())) then
begin
Timer.start;
printStatus('Found DTM!', 2);
mouse(X, Y, MOUSE_MOVE, MOUSE_HUMAN);
fastClick(MOUSE_LEFT);
wait(randomRange(500, 750));
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('runToStart: Finished with, Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting until player stops running...', 2);
wait(randomRange(1000, 1500));
until(not minimap.isPlayerMoving());
end;
printStatus('runToStart: Finished!', 3);
end;

// @ Procedure doLog
// * Completes Log Obstacle
// # Sets camera to face south after clicking on obstacle
// # Increments Obstacle to 1
procedure doLog;
begin
if not isLoggedIn then
exit;
printStatus('doLog: Starting...', 1);
runToStart;
printStatus('Beginning Log Search', 2);
if findObstacle(LOGCOLOR, LOGTOL, 2, 30, 70, 1, 1, 0, -50, 0, 2, 3, 750, LOGHUE, LOGSAT, mainScreen.getBounds(), ['og', 'ala', 'alance', 'Log']) then
begin
printStatus('Setting camera to face South', 2);;
minimap.setAngle(MM_DIRECTION_SOUTH);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Net Obstacle', 2);
Obstacle := 1;
onScreenReport(7.5);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doLog: Finished', 3);
end;

// @ Procedure doNet
// * Completes Net Obstacle
// # Increments Obstacle to 2
procedure doNet;
begin
if not isLoggedIn then
exit;
printStatus('doNet: Starting...', 1);
printStatus('Beginning Net Search', 2);
if findObstacle(NETCOLOR, NETTOL, 2, 160, 40, 0, 1, 0, 1, 0, 0, 2, 250, NETHUE, NETSAT, mainScreen.getBounds(), ['bstacle', 'net', 'Obstacle', 'Ob']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch1 Obstacle', 2);
Obstacle := 2;
onScreenReport(7.5);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doNet: Finished', 3);
end;

// @ Procedure doBranch1
// * Completes First Branch Obstacle
// # Increments Obstacle to 3
procedure doBranch1;
begin
if not isLoggedIn then
exit;
printStatus('doBranch1: Starting...', 1);
printStatus('Beginning Branch1 Search', 2);
if findObstacle(BRANCH1COLOR, BRANCH1TOL, 2, 50, 70, 1, 0, 0, 0, 0, 0, 2, 250, BRANCH1HUE, BRANCH1SAT, intToBox(162, 77 , 371, 222), ['ree', 'branch', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch2 Obstacle', 2);
Obstacle := 3;
onScreenReport(5.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch1: Finished', 3);
end;

// @ Procedure doBranch2
// * Completes Second Branch Obstacle
// # Increments Obstacle to 4
procedure doBranch2;
begin
if not isLoggedIn then
exit;
printStatus('doBranch2: Starting...', 1);
printStatus('Beginning Branch2 Search', 2);
if findObstacle(BRANCH2COLOR, BRANCH2TOL, 2, 10, 40, 1, 0, 0, 0, 0, 1, 3, 250, BRANCH2HUE, BRANCH2SAT, intToBox(189, 102, 333, 190), ['ree', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Sign Obstacle', 2);
Obstacle := 4;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch2: Finished', 3);
end;

// @ Procedure doSign
// * Completes Sign Obstacle
// # Sets camera to face east after clicking on obstacle
// # Increments Obstacle to 5
procedure doSign;
begin
if not isLoggedIn then
exit;
printStatus('doSign: Starting...', 1);
printStatus('Beginning Sign Search', 2);
if findObstacle(SIGNCOLOR, SIGNTOL, 2, 15, 40, 1, 1, 0, 1, 0, 0, 1, 250, SIGNHUE, SIGNSAT, mainScreen.getBounds(), ['ign', 'post', 'Sign', 'Signpost']) then
begin
printStatus('Setting camera to face East', 2);
minimap.setAngle(MM_DIRECTION_WEST);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Pole Obstacle', 2);
Obstacle := 5;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doSign: Finished', 3);
end;

// @ Procedure doPole
// * Completes Pole Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 6
procedure doPole;
begin
if not isLoggedIn then
exit;
printStatus('doPole: Starting...', 1);
printStatus('Beginning Pole Search', 2);
if findObstacle(POLECOLOR, POLETOL, 2, 30, 200, 0, 1, 0, 1, 0, 0, 1, 250, POLEHUE, POLESAT, mainScreen.getBounds(), ['ole', 'Pole', 'Pol']) then
begin
printStatus('Setting camera to face North', 2);
minimap.clickCompass();
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Barrier Obstacle', 2);
Obstacle := 6;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doPole: Finished', 3);
end;

// @ Procedure doBarrier
// * Completes Barrier Obstacle
// # Sets camera to face north(high) after clicking on obstacle
// # Resets Obstacle to 0
procedure doBarrier;
begin
if not isLoggedIn then
exit;
printStatus('doBarrier: Starting...', 1);
printStatus('Beginning Barrier Search', 2);
if findObstacle(BARRIERCOLOR, BARRIERTOL, 2, 40, 40, 0, 1, 0, 1, 0, 0, 2, 250, BARRIERHUE, BARRIERSAT, intToBox(206, 106, 330, 192) , ['arr', 'arrier', 'Barrier', 'Bar']) then
begin
printStatus('Setting camera to face North High', 2);
mainscreen.setAngle(0);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Log Obstacle', 2);
Obstacle := 0;
onScreenReport(25.0);
end
else if checkWaterMM then
begin
printStatus('Water found on MiniMap, moving onto Log Obstacle', 2);
Obstacle := 0;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBarrier: Finished', 3);
end;

// @ Procedure doTheCourse
// * Checks fail count to see if we should log out, otherwise will complete course
procedure doTheCourse;
begin
if not isLoggedIn then
exit;
printStatus('doTheCourse: Starting...', 1);
printStatus('FailCount: ' + intToStr(FailCount), 2);
if FailCount > TIMESTOFAIL then
begin
printStatus('We failed too many times, logging out!', 2);
printStatus('doTheCourse: Finished!', 3);
killScript('Failed ' + intToStr(FailCount) + ' times');
end;
if Obstacle = 0 then
doLog;
if Obstacle = 1 then
doNet;
if Obstacle = 2 then
doBranch1;
if Obstacle = 3 then
doBranch2;
if Obstacle = 4 then
doSign;
if Obstacle = 5 then
doPole;
if Obstacle = 6 then
begin
doBarrier;
onScreenReport(605.0);
end;
printStatus('doTheCourse: Finished!', 3);
end;

// @ Main Loop
// * Runs the course
begin
setUsUp;
repeat
logUsIn;
doTheCourse;
until(false);
releaseDTMs;
terminateScript;
end.

Brotein

2014-07-05 20:46:28

Yes, it's working nice. This was at 6 hour time out(had to restart a little bit in)

------ *************Progress Report***************
------ Time Running: 04h 13m 32s
------ XP Gained: 211700
------ XP/Hour: 50097
------ Times Failed: 350
------ *******************************************

The Mayor

2014-07-09 05:50:54

From: Brotein
Yes, it's working nice. This was at 6 hour time out(had to restart a little bit in)

------ *************Progress Report***************
------ Time Running: 04h 13m 32s
------ XP Gained: 211700
------ XP/Hour: 50097
------ Times Failed: 350
------ *******************************************


Looking nice! It turns out you may have some competition!

Brotein

2014-07-09 16:18:45

From: The Mayor
Looking nice! It turns out you may have some competition!


Does that mean you are making one :confused::confused:

The Mayor

2014-07-09 17:03:29

From: Brotein
Does that mean you are making one :confused::confused:


Nope, not me :p

Brotein

2014-07-21 16:59:13

Ok got the barbarian course coded in. If you want to run it just start where you would of finished the course(bottom of slide), with camera facing south. 93+ agility only!!!

program BroteinAdvAgile;

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

var
X, Y, MMDTM, Obstacle, FailCount : Integer;
XpGained, XpHour, SecondS : Extended;

////////////////////////////////////////////////////////////////////////////////
// Change Constants Here //
////////////////////////////////////////////////////////////////////////////////
const
WHICH_COURSE = 1; //0 = Gnome, 1 = Barbarian
DEBUG_SCRIPT = true; //Enable if you are having issues running script
DEBUG_COLORS = true; //Enable if you are having issues running script
USE_ON_SCREEN = false; //Enable for onscreen progress report
TIMES_TO_FAIL = 1000; //Maximum times the script is allowed to fail before logging out
START_OBSTACLE = 0; //0=log, 1=net, 2=branch1, 3=branch2, 4=sign, 5=post, 6=barrier

//ACA Settings for Log Obstacle
LOG_COLOR = 3164767;
LOG_TOL = 17;
LOG_HUE = 0.06;
LOG_SAT = 0.13;

//ACA Settings for Net Obstacle
NET_COLOR = 4282995;
NET_TOL = 13;
NET_HUE = 0.11;
NET_SAT = 5.49;

//ACA Settings for Branch1 Obstacle
BRANCH1_COLOR = 3821149;
BRANCH1_TOL = 22;
BRANCH1_HUE = 0.04;
BRANCH1_SAT = 0.47;

//ACA Settings for Bracnh2 Obstacle
BRANCH2_COLOR = 2900821;
BRANCH2_TOL = 11;
BRANCH2_HUE = 0.05;
BRANCH2_SAT = 0.19;

//ACA Settings for Sign Obstacle
SIGN_COLOR = 6401217;
SIGN_TOL = 7;
SIGN_HUE = 0.32;
SIGN_SAT = 4.33;

//ACA Settings for Pole Obstacle
POLE_COLOR = 4016464;
POLE_TOL = 18;
POLE_HUE = 0.06;
POLE_SAT = 0.06;

//ACA Settings for Barrier Obstacle
BARRIER_COLOR = 5343664;
BARRIER_TOL = 17;
BARRIER_HUE = 0.07;
BARRIER_SAT = 5.38;

//ACA Settings for Rope Swing Obstacle
ROPE_SWING_COLOR = 207409;
ROPE_SWING_TOL = 5;
ROPE_SWING_HUE = 0.22;
ROPE_SWING_SAT = 1.37;

//ACA Settings for Log Blanace Obstacle
LOG_BALANCE_COLOR = 2239808;
LOG_BALANCE_TOL = 8;
LOG_BALANCE_HUE = 0.12;
LOG_BALANCE_SAT = 0.28;

//ACA Settings for Wall Run Obstacle
WALL_RUN_COLOR = 10149862;
WALL_RUN_TOL = 15;
WALL_RUN_HUE = 0.05;
WALL_RUN_SAT = 2.65;

//ACA Settings for Wall Climb Obstacle
WALL_CLIMB_COLOR = 3757934;
WALL_CLIMB_TOL = 11;
WALL_CLIMB_HUE = 0.06;
WALL_CLIMB_SAT = 0.10;

//ACA Settings for Spring Obstacle
SPRING_COLOR = 12247530;
SPRING_TOL = 18;
SPRING_HUE = 0.20;
SPRING_SAT = 2.60;

//ACA Settings for Balance Beam Obstacle
BALANCE_BEAM_COLOR = 8029064;
BALANCE_BEAM_TOL = 13;
BALANCE_BEAM_HUE = 0.21;
BALANCE_BEAM_SAT = 0.14;

//ACA Settings for Jump Obstacle
JUMP_COLOR = 2118252;
JUMP_TOL = 1;
JUMP_HUE = 0.15;
JUMP_SAT = 0.77;

//ACA Settings for Slide Obstacle
SLIDE_COLOR = 4875636;
SLIDE_TOL = 12;
SLIDE_HUE = 0.06;
SLIDE_SAT = 0.46;

//ACA Setting for Xp Drop/Popup
XP_COLOR = 4040932;
XP_TOL = 2;
XP_HUE = 0.13;
XP_SAT = 2.79;

////////////////////////////////////////////////////////////////////////////////
// Set up your Character info here!!! //
////////////////////////////////////////////////////////////////////////////////
procedure declarePlayers;
begin
setLength(players, 1);
with players[0] do
begin
loginName := ''; //Set username here
password := ''; //Set password here
bankPin := ''; //Set PIN here
world := 1; //Set world here
isActive := true;
isMember := true;
end
currentPlayer := 0;
end;

////////////////////////////////////////////////////////////////////////////////
// Script starts here, Setup Complete! //
////////////////////////////////////////////////////////////////////////////////
// @ Procedure printStatus
// * Used for debugging our script to a log by using print
// * Will draw progress report at all times, and only progress report if we
// are not using the DEBUG_SCRIPT constant.
procedure printStatus(Jamc : String; PrintType : Integer);
begin
if DEBUG_SCRIPT then
begin
if PrintType = 0 then
print(Jamc, TDebug.SUB);
if PrintType = 1 then
print(Jamc, TDebug.HEADER);
if PrintType = 2 then
print(Jamc, TDebug.SUB);
if PrintType = 3 then
print(Jamc, TDebug.FOOTER);
if PrintType = 4 then
print(Jamc, TDebug.ERROR);
if PrintType = 5 then
writeLn(Jamc);
end;
if not DEBUG_SCRIPT then
begin
if PrintType = 0 then
writeLn(Jamc);
end;
end

// @ Procedure takeScreen by Olly
// * Saves a screenshot and blurs out info, safe for upload
procedure takeScreen(Reason : String);
procedure blur(Bmp, Xs, Ys, Xe, Ye: Integer);
var
BmpCopy, Tmp: Integer;
begin
BmpCopy := copyBitmap(Bmp);
cropBitmap(BmpCopy, Xs, Ys, Xe, Ye);
Tmp := convoluteBitmap(BmpCopy, gaussMatrix(6, 3.00));
fastDrawTransparent(Xs, Ys, Tmp, Bmp);
freeBitmaps([BmpCopy, Tmp]);
end;
var
BmpClient, W, H, I: Integer;
Areas: TBoxArray;
begin
getClientDimensions(W, H);
BmpClient := bitmapFromClient(0, 0, W-1, H-1);
Areas := [[actionBar.x1, actionbar.y1, chatBox.x2, chatBox.y2], mainScreen.playerBox,
[tabBackpack.x1-4, tabBackpack.y2 - 40, tabBackpack.x2, tabBackpack.y2],
[mainScreen.x2 - 130, mainScreen.y1, mainScreen.x2, mainScreen.y1 + 75]];

for I := 0 to high(Areas) do
blur(BmpClient, Areas[i].x1, Areas[i].y1, Areas[i].x2, Areas[i].y2);
getMufasaBitmap(BmpClient).drawClippedText('Reason: ' + Reason + 'Time:' + theTime, point(chatBox.x1 + 5, chatBox.y2 - 16), StatChars, true, clLime);
saveBitmap(BmpClient, appPath + 'BroteinAdvAgile' + '.png');
debugBitmap(BmpClient);
freeBitmap(BmpClient);
end;

// @ Function getXP by Ashaman88
// * Gets XP in current xp counter on chat box.
function TRSChatBox.getXP: Integer;
var
B : TBox;
S : String;
TPA : TPointArray;
ATPA : T2DPointArray;
P : Integer;
begin
printStatus('TRSChatBox.getXP: Starting...', 1);
B := self.getBounds();
B.edit( +(B.x2 - B.x1) - 140, +10, -5, -94);
findColorsTolerance(TPA, 14013909, B, 4, colorSetting(2, 0.00, 0.00));
if length(TPA) < 2 then
begin
printStatus('chatBox.getXP(): No XP found', 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
exit;
end;
ATPA := TPA.cluster(10);
ATPA.sortFromFirstPoint(point(B.x2, B.y2));
B := ATPA[low(ATPA)].getbounds;
B.edit(-2, -2, +2, +3);
S := Replace(tesseractgettext(B.x1, B.y1, B.x2, B.y2, FILTER_SMALL_CHARS), ' ', '', [rfReplaceAll]);
P := Pos('x', S);
if P > 0 then
Result := StrToIntDef(ExtractFromStr(Copy(S, P, Length(S)), Numbers), 0)
else
Result := StrToIntDef(ExtractFromStr(S, Numbers), 0);
printStatus('chatBox.getXP(): XP found: ' + tostr(result), 2);
printStatus('TRSChatBox.getXP: Finished!', 3);
end;

// @ Procedure setDTMs
// * Sets our DTM
// # MMDTM
procedure setDTMs
begin
MMDTM := DTMFromString('mWAAAAHicY2FgYBBhZWDgAmJRIBYD4jhGBoZsIM4H4gAg3jZFi6EhSYvhzdM+hhmdiQwaQD3ImBENgwAArpkI8w==');
end;

// @ Procedure releaseDTMs
// * Frees our DTM from memory
// # [MMDTM]
procedure releaseDTMs;
begin
freeDTMs([MMDTM]);
end;

// @ Procedure killScript
// * Kills our script
// # Reason used for Debug
procedure killScript(Reason : String);
begin
printStatus('killScript: Starting...', 0);
takeScreen(Reason);
if isLoggedIn then
players[currentPlayer].logout();
terminateScript;
printStatus('killScript: Finished! Script terminated at time: ' + theTime + ', Script ran for: ' + timeRunning + ', Stopped for reason: ' + Reason, 0);
end;

// @ Function timeRunningShort
// * Same as timeRunning, but uses TIME_SHORT constant
function timeRunningShort(TheType: Integer = TIME_SHORT): string;
begin
Result := msToTime(GetTimeRunning(), TheType);
end;

// @ Proecure progressReport
// * Will display our progress, and increments XpGained by obstacle XP
// # XpGained, XpHour, timeRunning, FailCount
procedure progressReport(IncAmount : Extended);
begin
if not DEBUG_SCRIPT then
clearDebug();
XpGained := XpGained + IncAmount;
SecondS := round((getTimeRunning/1000));
XpHour := round((3600 * XpGained) / (SecondS));
printStatus('*************Progress Report***************', 0);
printStatus('Time Running: ' + timeRunningShort, 0);
printStatus('XP Gained: ' + floatToStr(XpGained), 0);
printStatus('XP/Hour: ' + floatToStr(XpHour), 0);
printStatus('Times Failed: ' + intToStr(FailCount), 0);
printStatus('*******************************************', 0);
end;

// @ Procedure onScreenReport
// * Same as progressReport expect will draw most of the information onscreen
procedure onScreenReport(IncAmount : Extended);
var
ScreenProggy : Integer;
InfoPoints : TPointArray;
begin
progressReport(IncAmount);
if USE_ON_SCREEN then
begin
InfoPoints := [Point(245,509), Point(220,541), Point(442,541), Point(490,500), Point(4,447), Point(240 ,315)];
ScreenProggy := loadBitmap(appPath + 'AdvAgileProg.png');
smartImage.clear();
smartImage.drawBitmap(ScreenProggy, InfoPoints[4]);
smartImage.drawText(timeRunningShort, InfoPoints[0], UpChars, false, 1423591);
smartImage.drawText(floatToStr(XpGained), InfoPoints[1], BigChars, false, 1423591);
smartImage.drawText(floatToStr(XpHour), InfoPoints[2], BigChars, false, 1423591);
smartImage.drawText(intToStr(FailCount), InfoPoints[3], BigChars, false, 1423591);
freeBitmap(ScreenProggy);
end;
end;

// @ Procedure setUsUp
// * Does our intial setup stuff for script during startup
procedure setUsUp;
begin
printStatus('setUsUp: Starting...', 1);
clearDebug();
//autoUpdateMe;
if not DEBUG_SCRIPT then
disableSRLDebug := true;
smartEnableDrawing := true;
setupSRL;
setDTMs;
addOnTerminate('releaseDTMs');
declarePlayers;
Obstacle := START_OBSTACLE;
MouseSpeed := 50;
onScreenReport(0.0);
printStatus('setUsUp: Finished!', 3);
end;

// @ Procedure logUsIn
// * Logs in player when not logged in and closes Treasure popup
procedure logUsIn;
begin
printStatus('logUsIn: Starting...', 1);
if not isLoggedIn then
begin
players[currentPlayer].login();
exitTreasure();
if Obstacle = 0 then
begin
minimap.clickCompass();
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 1 or Obstacle = 2 or Obstacle = 3 or Obstacle = 4 then
begin
minimap.setAngle(MM_DIRECTION_SOUTH);
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 5 then
begin
minimap.setAngle(MM_DIRECTION_WEST);
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
if Obstacle = 6 then
begin
minimap.clickCompass();
mainscreen.setAngle(0);
mainscreen.setZoom(true);
end;
end;
printStatus('logUsIn: Finished!', 3);
end;

// @ Function findObstacle
// * TPA finding function for the obstacles in our course.
// # ObColor, ObTol, ObCTS, ObHue, ObSat: Fill in with ACA(Color, Tolerance, ColorToleranceSpeed, Hue, Saturation)
// # ATPAW, ATPAH: Width and Height of ATPA
// # ObSort: 0 for sort ATPA by size, 1 for sort ATPA from midpoint(player)
// # RanX1, RanX2, RanY1, RanY2 : Used to set randomrange for point x,y randomness in ATPA
// # IndexLow, IndexHigh : Used for ATPA[i] search
// # SearchBox : Used to set search area
// # ObUpText : UpText for the object as a String Array
function findObstacle(ObColor, ObTol, ObCTS, ATPAW, ATPAH, ObSort, RanX1, RanX2, RanY1, RanY2, IndexLow, IndexHigh, EndWaitTime : Integer; ObHue, ObSat : Extended; SearchBox: TBox; ObUpText : TStringArray) : Boolean;
var
p : TPoint;
px, py, i : Integer;
ObTPA : TPointArray;
ObATPA : T2DPointArray;
begin
if not isLoggedIn then
exit;
printStatus('findObstacle: Starting...', 1);
printStatus('Looking for obstacle', 2);
if findColorsSpiralTolerance(px, py, ObTPA, ObColor, SearchBox, ObTol, colorSetting(ObCTS, ObHue, ObSat)) then
begin
ObATPA := ObTPA.toATPA(ATPAW, ATPAH);
ObATPA.filterBetween(0, 30);
if ObSort = 0 then
ObATPA.sortBySize(true);
if ObSort = 1 then
ObATPA.sortFromMidPoint(mainscreen.playerPoint);
if DEBUG_COLORS then
begin
smartImage.clear;
smartImage.debugTPA(ObTPA, true);
smartImage.debugATPA(ObATPA);
end;
for i := IndexLow to IndexHigh do
begin
p := middleTPA(ObATPA[i]);
p.offset(point(randomRange(RanX1, RanX1 + RanX2), randomRange(RanY1, RanY1 + RanY2)));
mouse(p.x, p.y, MOUSE_MOVE, MOUSE_HUMAN);
printStatus('Point we click on: ' + intToStr(p.x) + ', ' + intToStr(p.y), 2);
wait(randomRange(150, 175));
if isMouseOverText(ObUpText) then
begin
wait(150 + random(50));
fastClick(MOUSE_LEFT);
printStatus('Found Obstacle!', 2);
wait(randomRange(125, 250));
if DEBUG_COLORS then
smartImage.clear();
wait(random(250));
printStatus('Done Waiting', 2);
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
Result := true;
exit;
end;
end;
wait(EndWaitTime + random(50));
end;
printStatus('findObstacle: Finished with result: ' + boolToStr(Result), 3);
end;

// @ Function checkXpDrop
// * Returns true when xp popup is found on mainscreen, times out at 15 seconds
function checkXpDrop : Boolean;
var
XpTPA : TPointArray;
Timer : TTimeMarker;
begin
if not isLoggedIn then
exit;
printStatus('checkXpDrop: Starting...', 1);
Timer.start;
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result) + ', Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting...', 2);
wait(randomRange(125, 250));
until(findColorsTolerance(XpTPA, XP_COLOR, intToBox(256, 0, 505, 303), XP_TOL, colorSetting(2, XP_HUE, XP_SAT)));
if DEBUG_COLORS then
begin
smartImage.clear;
smartImage.debugTPA(XpTPA, true);
end;
Timer.reset;
Result := true;
wait(randomRange(150, 225));
if DEBUG_COLORS then
smartImage.clear();
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result), 3);
end;

// @ Function checkWaterMM
// * Returns true when water is found on minimap, times out at 5 seconds
function checkWaterMM : Boolean;
var
WaterTPA : TPointArray;
Timer : TTimeMarker;
begin
if not isLoggedIn then
exit;
printStatus('checkWaterMM: Starting...', 1);
Timer.start;
repeat
if Timer.getTime > 5000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('checkWaterMM: Finished with Result: ' + boolToStr(Result) + ', Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting...', 2);
wait(randomRange(125, 250));
until(findColorsTolerance(WaterTPA, 8088158, intToBox(732, 14, 794, 151), 10, colorSetting(2, 1.64, 1.93)));
Timer.reset;
Result := true;
wait(randomRange(150, 225));
if DEBUG_COLORS then
smartImage.clear();
printStatus('checkXpDrop: Finished with Result: ' + boolToStr(Result), 3);
end;

// @ Procedure runToStart
// * Stuff
procedure runToStart;
var
Timer : TTimeMarker;
begin
printStatus('runToStart: Starting...', 1);
printStatus('Looking for DTM...', 2);
if(findDTM(MMDTM, X, Y, miniMap.getBounds())) then
begin
Timer.start;
printStatus('Found DTM!', 2);
mouse(X, Y, MOUSE_MOVE, MOUSE_HUMAN);
fastClick(MOUSE_LEFT);
wait(randomRange(500, 750));
repeat
if Timer.getTime > 15000 then
begin
printStatus('Waiting too long, increasing fail count',2);
printStatus('runToStart: Finished with, Fail Count: ' + intToStr(FailCount), 3);
inc(FailCount);
Timer.reset;
exit;
end;
printStatus('Waiting until player stops running...', 2);
wait(randomRange(1000, 1500));
until(not minimap.isPlayerMoving());
end;
printStatus('runToStart: Finished!', 3);
end;

// @ Procedure doLog
// * Completes Log Obstacle
// # Sets camera to face south after clicking on obstacle
// # Increments Obstacle to 1
procedure doLog;
begin
if not isLoggedIn then
exit;
printStatus('doLog: Starting...', 1);
runToStart;
printStatus('Beginning Log Search', 2);
if findObstacle(LOG_COLOR, LOG_TOL, 2, 30, 70, 1, 1, 0, -50, 0, 2, 3, 750, LOG_HUE, LOG_SAT, mainScreen.getBounds(), ['og', 'ala', 'alance', 'Log']) then
begin
printStatus('Setting camera to face South', 2);;
minimap.setAngle(MM_DIRECTION_SOUTH);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Net Obstacle', 2);
Obstacle := 1;
onScreenReport(7.5);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doLog: Finished', 3);
end;

// @ Procedure doNet
// * Completes Net Obstacle
// # Increments Obstacle to 2
procedure doNet;
begin
if not isLoggedIn then
exit;
printStatus('doNet: Starting...', 1);
printStatus('Beginning Net Search', 2);
if findObstacle(NET_COLOR, NET_TOL, 2, 160, 40, 0, 1, 0, 1, 0, 0, 2, 250, NET_HUE, NET_SAT, mainScreen.getBounds(), ['bstacle', 'net', 'Obstacle', 'Ob']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch1 Obstacle', 2);
Obstacle := 2;
onScreenReport(7.5);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doNet: Finished', 3);
end;

// @ Procedure doBranch1
// * Completes First Branch Obstacle
// # Increments Obstacle to 3
procedure doBranch1;
begin
if not isLoggedIn then
exit;
printStatus('doBranch1: Starting...', 1);
printStatus('Beginning Branch1 Search', 2);
if findObstacle(BRANCH1_COLOR, BRANCH1_TOL, 2, 50, 70, 1, 0, 0, 0, 0, 0, 2, 250, BRANCH1_HUE, BRANCH1_SAT, intToBox(162, 77 , 371, 222), ['ree', 'branch', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Branch2 Obstacle', 2);
Obstacle := 3;
onScreenReport(5.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch1: Finished', 3);
end;

// @ Procedure doBranch2
// * Completes Second Branch Obstacle
// # Increments Obstacle to 4
procedure doBranch2;
begin
if not isLoggedIn then
exit;
printStatus('doBranch2: Starting...', 1);
printStatus('Beginning Branch2 Search', 2);
if findObstacle(BRANCH2_COLOR, BRANCH2_TOL, 2, 10, 40, 1, 0, 0, 0, 0, 1, 3, 250, BRANCH2_HUE, BRANCH2_SAT, intToBox(189, 102, 333, 190), ['ree', 'Tree', 'Tre']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Sign Obstacle', 2);
Obstacle := 4;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBranch2: Finished', 3);
end;

// @ Procedure doSign
// * Completes Sign Obstacle
// # Sets camera to face east after clicking on obstacle
// # Increments Obstacle to 5
procedure doSign;
begin
if not isLoggedIn then
exit;
printStatus('doSign: Starting...', 1);
printStatus('Beginning Sign Search', 2);
if findObstacle(SIGN_COLOR, SIGN_TOL, 2, 15, 40, 1, 1, 0, 1, 0, 0, 1, 250, SIGN_HUE, SIGN_SAT, mainScreen.getBounds(), ['ign', 'post', 'Sign', 'Signpost']) then
begin
printStatus('Setting camera to face East', 2);
minimap.setAngle(MM_DIRECTION_WEST);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Pole Obstacle', 2);
Obstacle := 5;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doSign: Finished', 3);
end;

// @ Procedure doPole
// * Completes Pole Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 6
procedure doPole;
begin
if not isLoggedIn then
exit;
printStatus('doPole: Starting...', 1);
printStatus('Beginning Pole Search', 2);
if findObstacle(POLE_COLOR, POLE_TOL, 2, 30, 200, 0, 1, 0, 1, 0, 0, 1, 250, POLE_HUE, POLE_SAT, mainScreen.getBounds(), ['ole', 'Pole', 'Pol']) then
begin
printStatus('Setting camera to face North', 2);
minimap.clickCompass();
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Barrier Obstacle', 2);
Obstacle := 6;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doPole: Finished', 3);
end;

// @ Procedure doBarrier
// * Completes Barrier Obstacle
// # Sets camera to face north(high) after clicking on obstacle
// # Resets Obstacle to 0
procedure doBarrier;
begin
if not isLoggedIn then
exit;
printStatus('doBarrier: Starting...', 1);
printStatus('Beginning Barrier Search', 2);
if findObstacle(BARRIER_COLOR, BARRIER_TOL, 2, 40, 40, 0, 1, 0, 1, 0, 0, 2, 250, BARRIER_HUE, BARRIER_SAT, intToBox(206, 106, 330, 192) , ['arr', 'arrier', 'Barrier', 'Bar']) then
begin
printStatus('Setting camera to face North High', 2);
mainscreen.setAngle(0);
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Log Obstacle', 2);
Obstacle := 0;
onScreenReport(25.0);
end
else if checkWaterMM then
begin
printStatus('Water found on MiniMap, moving onto Log Obstacle', 2);
Obstacle := 0;
onScreenReport(25.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBarrier: Finished', 3);
end;

// @ Procedure doRopeSwing
// * Completes Rope Swing Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 1
procedure doRopeSwing;
begin
if not isLoggedIn then
exit;
printStatus('doRopeSwing: Starting...', 1);
printStatus('Beginning Rope Swing Search', 2);
if findObstacle(ROPE_SWING_COLOR, ROPE_SWING_TOL, 2, 30, 200, 0, 1, 0, 1, 0, 1, 2, 250, ROPE_SWING_HUE, ROPE_SWING_SAT, mainScreen.getBounds(), ['wing', 'Swing', 'On']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Log Balance Obstacle', 2);
Obstacle := 1;
onScreenReport(22.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doRopeSwing: Finished', 3);
end;

// @ Procedure doRopeSwing
// * Completes Rope Swing Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 2
procedure doLogBalance;
begin
if not isLoggedIn then
exit;
printStatus('doLogBalance: Starting...', 1);
printStatus('Beginning Log Balance Search', 2);
if findObstacle(LOG_BALANCE_COLOR, LOG_BALANCE_TOL, 2, 20, 20, 1, 1, 0, 1, 0, 0, 1, 250, LOG_BALANCE_HUE, LOG_BALANCE_SAT, mainScreen.getBounds(), ['alk', 'across', 'Walk', 'Log', 'og', 'balance']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Wall Jump Obstacle', 2);
Obstacle := 2;
onScreenReport(13.7);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doLogBalance: Finished', 3);
end;

// @ Procedure doWallRun
// * Completes Wall Run Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 3
procedure doWallRun;
begin
if not isLoggedIn then
exit;
printStatus('doWallRun: Starting...', 1);
printStatus('Beginning Wall Run Search', 2);
if findObstacle(WALL_RUN_COLOR, WALL_RUN_TOL, 2, 30, 50, 0, 1, 0, 1, 0, 0, 1, 250, WALL_RUN_HUE, WALL_RUN_SAT, mainScreen.getBounds(), ['un', 'Run', 'up', 'Wall']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Wall Climb Obstacle', 2);
Obstacle := 3;
onScreenReport(13.7);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doWallRun: Finished', 3);
end;

// @ Procedure doWallClimb
// * Completes Wall Climb Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 4
procedure doWallClimb;
begin
if not isLoggedIn then
exit;
printStatus('doWallClimb: Starting...', 1);
printStatus('Beginning Wall Climb Search', 2);
if findObstacle(WALL_CLIMB_COLOR, WALL_CLIMB_TOL, 2, 30, 60, 1, 1, 0, 1, 0, 0, 1, 250, WALL_CLIMB_HUE, WALL_CLIMB_SAT, intToBox(311, 185, 342, 251), ['limb', 'Climb', 'up', 'Wall']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Spring Obstacle', 2);
Obstacle := 4;
onScreenReport(15.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doWallClimb: Finished', 3);
end;

// @ Procedure doSpring
// * Completes Spring Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 5
procedure doSpring;
begin
if not isLoggedIn then
exit;
printStatus('doSpring: Starting...', 1);
printStatus('Beginning Spring Search', 2);
if findObstacle(SPRING_COLOR, SPRING_TOL, 2, 80, 60, 0, 1, 0, 1, 0, 0, 0, 250, SPRING_HUE, SPRING_SAT, intToBox(324, 137, 424, 242), ['ire', 'Fire', 'Spring', 'Device']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Barrier Obstacle', 2);
Obstacle := 5;
onScreenReport(15.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doSpring: Finished', 3);
end;

// @ Procedure doBalanceBeam
// * Completes Balance Beam Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 6
procedure doBalanceBeam;
begin
if not isLoggedIn then
exit;
printStatus('doBalanceBeam: Starting...', 1);
printStatus('Beginning Balance Beam Search', 2);
if findObstacle(BALANCE_BEAM_COLOR, BALANCE_BEAM_TOL, 2, 15, 15, 1, 1, 0, 1, 0, 0, 1, 250, BALANCE_BEAM_HUE, BALANCE_BEAM_SAT, mainScreen.getBounds(), ['ross', 'Cross', 'Balance', 'beam']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Barrier Obstacle', 2);
Obstacle := 6;
onScreenReport(15.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doBalanceBeam: Finished', 3);
end;

// @ Procedure doJump
// * Completes Jump Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 7
procedure doJump;
begin
if not isLoggedIn then
exit;
printStatus('doJump: Starting...', 1);
printStatus('Beginning Jump Search', 2);
if findObstacle(JUMP_COLOR, JUMP_TOL, 2, 30, 30, 1, 1, 0, 1, 0, 0, 1, 250, JUMP_HUE, JUMP_SAT, mainScreen.getBounds(), ['ump', 'Jump', 'over', 'Gap']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Slide Obstacle', 2);
Obstacle := 7;
onScreenReport(15.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doJump: Finished', 3);
end;

// @ Procedure doSlide
// * Completes Slide Obstacle
// # Sets camera to face north after clicking on obstacle
// # Increments Obstacle to 0
procedure doSlide;
begin
if not isLoggedIn then
exit;
printStatus('doSlide: Starting...', 1);
printStatus('Beginning Slide Search', 2);
if findObstacle(SLIDE_COLOR, SLIDE_TOL, 2, 50, 100, 0, 1, 0, 1, 0, 0, 1, 250, SLIDE_HUE, SLIDE_SAT, intToBox(213, 165, 245, 242), ['lide', 'Slide', 'down', 'Roof']) then
begin
printStatus('Waiting for XP drop', 2);
if checkXpDrop then
begin
printStatus('XP drop found, moving onto Rope Swing Obstacle', 2);
Obstacle := 0;
onScreenReport(15.0);
end
else
begin
inc(FailCount);
printStatus('No XP drop found, Fail Count: ' + intToStr(FailCount), 2);
end;
end
else
begin
inc(FailCount);
printStatus('Never found obstacle, Fail Count: ' + intToStr(FailCount), 2);
end;
printStatus('doSlide: Finished', 3);
end;

// @ Procedure doGnomeCourse
// * Checks fail count to see if we should log out, otherwise will complete course
procedure doGnomeCourse;
begin
if not isLoggedIn then
exit;
printStatus('doTheCourse: Starting...', 1);
printStatus('FailCount: ' + intToStr(FailCount), 2);
if FailCount > TIMES_TO_FAIL then
begin
printStatus('We failed too many times, logging out!', 2);
printStatus('doTheCourse: Finished!', 3);
killScript('Failed ' + intToStr(FailCount) + ' times');
end;
if Obstacle = 0 then
doLog;
if Obstacle = 1 then
doNet;
if Obstacle = 2 then
doBranch1;
if Obstacle = 3 then
doBranch2;
if Obstacle = 4 then
doSign;
if Obstacle = 5 then
doPole;
if Obstacle = 6 then
begin
doBarrier;
onScreenReport(605.0);
end;
printStatus('doTheCourse: Finished!', 3);
end;

// @ Procedure doBarbCourse
// * Checks fail count to see if we should log out, otherwise will complete course
procedure doBarbCourse;
begin
if not isLoggedIn then
exit;
printStatus('doTheCourse: Starting...', 1);
printStatus('FailCount: ' + intToStr(FailCount), 2);
if FailCount > TIMES_TO_FAIL then
begin
printStatus('We failed too many times, logging out!', 2);
printStatus('doTheCourse: Finished!', 3);
killScript('Failed ' + intToStr(FailCount) + ' times');
end;
if Obstacle = 0 then
doRopeSwing;
if Obstacle = 1 then
doLogBalance;
if Obstacle = 2 then
doWallRun;
if Obstacle = 3 then
doWallClimb;
if Obstacle = 4 then
doSpring;
if Obstacle = 5 then
doBalanceBeam;
if Obstacle = 6 then
doJump;
if Obstacle = 7 then
begin
doSlide;
onScreenReport(615.0);
end;
printStatus('doTheCourse: Finished!', 3);
end;

// @ Procedure doTheCourse
// * Takes contstant WHICH_COURSE to determine which course to complete
procedure doTheCourse;
begin
if WHICH_COURSE = 0 then
doGnomeCourse;
if WHICH_COURSE = 1 then
doBarbCourse;
end;

// @ Main Loop
// * Runs the course
begin
setUsUp;
repeat
logUsIn;
doTheCourse;
until(false);
releaseDTMs;
terminateScript;
end.

Just gotta go through and add in some setup stuff, and fix some errors and it's good to go.

RlagkRud

2014-08-07 11:43:20

From: Brotein
Ok got the barbarian course coded in. If you want to run it just start where you would of finished the course(bottom of slide), with camera facing south. 93+ agility only!!!

Just gotta go through and add in some setup stuff, and fix some errors and it's good to go.


Is there going to be an official release in the JR section? I think a lot of people will find these scripts to be quite useful!

Brotein

2014-08-08 10:46:26

From: RlagkRud
Is there going to be an official release in the JR section? I think a lot of people will find these scripts to be quite useful!


I don't know, I feel like there's no activity for RS3 on these forums. I might just make a thread with all my scripts and if you want to use them you can but I won't update them when I have no use for them anymore.

Right now there is a big issue with the adv barb course being that everyone who has a comp cape has to have the SAME exact color I use for xp detection, so it's causing a lot of false positives.