Code:
program AdvanceBarbarianAgility;
{$DEFINE SMART}
{$i srl/srl.scar}
{$i sps/sps.simba}
{$I SRL/SRL/misc/paintsmart.scar}
// Author: Anyhow
// Version: 1.0 Beta
// Runs Advance Barbarian Agility Course
// Does not eat currently so only run if your are 93+ agility
// No antiban and no breaks yet, be cautious
// A hattip to [Nathan] for his skeleton of this script
//SETUP
const
SERVER = 86; //Replace with desired server number
Username = '';
Password = '';
Nickname = '';
ar = 0; //AntiRandom switch (0 = off, 1 = on)
mmdebug = 0; //mmBlack function debug switch (0 = off, 1 = on)
debugwfloor = 0; //Wfloor function debug switch (0 = off, 10~14 = on)
//Vars
var x,y:LongInt;
var startingExp,currentExp,laps:Integer;
var gainedExp:Extended;
var myPos: TPoint;
var reRunUpWall: Boolean;
function MSToHour(mstime :Extended): Extended;
begin
result := mstime/3600000;
end;
procedure AntiRandoms;
begin
if ((not LoggedIn) or (ar = 0)) then Exit;
FindNormalRandoms; // find random events
end;
function mmBlack:Boolean;
var blackSpot : array [0..7] of TPoint;
var color : array [0..7] of Integer;
var i,kk,res:Integer;
begin
result:= false;
blackSpot[0]:= Point(587,43);
blackSpot[1]:= Point(575,112);
blackSpot[2]:= Point(577,115);
blackSpot[3]:= Point(672,122);
blackSpot[4]:= Point(627,139);
blackSpot[5]:= Point(611,134);
blackSpot[6]:= Point(622,152);
blackSpot[7]:= Point(622,152);
color[0]:= 512;
color[1]:= 393990;
color[2]:= 198400;
color[3]:= 65537;
color[4]:= 131072;
color[5]:= 1797;
color[6]:= 459782;
color[7]:= 328705;
res := 0;
for i := 0 to 7 do
begin
for kk := 0 to 7 do
begin
if(FindColorTolerance(x,y,color[kk],blackSpot[i].x,blackSpot[i].y,blackSpot[i].x,blackSpot[i].y,7)) then
begin
res := res + 1;
//debug
if mmdebug = 1 then
writeln('i = ' + inttostr(i) + ' kk = ' + inttostr(kk));
end;
end;
end;
if(res > 7) then
result:= true;
end;
function Wfloor:Integer;
begin
result:= 99;
if((FindColorTolerance(x,y,2247007,633,56,633,56,15) or
FindColorTolerance(x,y,2247007,629,52,629,52,15) or
FindColorTolerance(x,y,2247007,628,60,628,60,15) or
FindColorTolerance(x,y,2247007,634,51,634,51,15) or
FindColorTolerance(x,y,2247007,633,60,633,60,15) or
FindColorTolerance(x,y,2247007,629,49,629,49,15)) and
FindColorTolerance(x,y,395009,634,84,634,84,15) and
(mmblack())) then
result:= 10;
if((FindColorTolerance(x,y,1655633,615,84,615,84,15) or
FindColorTolerance(x,y,1521998,621,57,621,57,15)) and
(mmblack())) then
result:= 11;
if((FindColorTolerance(x,y,1853268,630,113,630,113,15) or
FindColorTolerance(x,y,1853268,636,116,636,116,15)) and (mmblack())) then
result:= 12;
if(FindColorTolerance(x,y,4873321,530,184,530,184,15) and (mmblack())) then
result:= 13;
if((FindColorTolerance(x,y,2180188,621,113,621,113,15) or
FindColorTolerance(x,y,2180188,625,114,625,114,15) or
FindColorTolerance(x,y,2180188,627,112,627,112,15) or
FindColorTolerance(x,y,2180188,622,113,622,113,15)) and
FindColorTolerance(x,y,393218,643,114,643,114,15) and
FindColorTolerance(x,y,393218,632,114,632,114,15) and
not(FindColorTolerance(x,y,4873321,530,184,530,184,15))and
(mmblack())) then
result:= 14;
//Debug
if debugwfloor = 10 then
begin
writeln('Debug Start');
writeln(FindColorTolerance(x,y,2247007,633,56,633,56,15));
writeln(FindColorTolerance(x,y,2247007,629,52,629,52,15));
writeln(FindColorTolerance(x,y,2247007,628,60,628,60,15));
writeln(FindColorTolerance(x,y,2247007,634,51,634,51,15));
writeln(FindColorTolerance(x,y,2247007,633,60,633,60,15));
writeln('Debug End');
end;
if debugwfloor = 14 then
begin
writeln('Debug Start');
writeln(FindColorTolerance(x,y,2180188,621,113,621,113,15));
writeln(FindColorTolerance(x,y,2180188,625,114,625,114,15));
writeln(FindColorTolerance(x,y,2180188,627,112,627,112,15));
writeln(FindColorTolerance(x,y,393218,643,114,643,114,15));
writeln(FindColorTolerance(x,y,393218,632,114,632,114,15));
writeln(FindColorTolerance(x,y,4873321,530,184,530,184,15));
writeln('Debug End');
end;
end;
Procedure sleepWhileMMBlack();
var t:Integer;
begin
t := 0;
while((mmBlack) and (t < 25)) do
begin
sleep(250+random(5))
t:=t+1;
writeln('SLeeping while mm is blacked');
end;
end;
function distanceTo(var point:TPoint): Extended;
var myLoc:TPoint;
begin
myLoc:= SPS_GetMyPos();
Result:= Sqrt((Sqr((Abs((point.x - myLoc.x)))) + Sqr((Abs((point.y - myLoc.y))))))
end;
procedure FreeAll;
begin
ClearRSCanvas(SMART_Canvas.canvas);
//SMART_FreeDebug; <- contains a bug, don't use this.
writeln('free');
end;
procedure Paint;
begin
SMART_DrawBox(IntToBox(5,35,350,160));
SMART_DrawTextEx(False,80,40,'UpChars','Advance Barbarian Agility By: [Anyhow]', clBlue);
SMART_DrawTextEx(False,10,60,'UpChars','Time running: ' + TimeRunning, clBlue);
SMART_DrawTextEx(False,10,80,'UpChars','Laps run: ' + inttostr(laps), clBlue);
SMART_DrawTextEx(False,10,100,'UpChars','Experience gained: ' + inttostr( (currentExp-startingExp) ), clBlue);
SMART_DrawTextEx(False,10,120,'UpChars','Current Experience: ' + inttostr(currentExp), clBlue);
SMART_DrawTextEx(False,10,140,'UpChars','XP/hr: ' + inttostr(Round(gainedExp/MSToHour(gettimerunning))), clBlue);
end;
function checkAgility:Integer;
begin
currentExp:=GetXP(SKILL_AGILITY);
if(currentExp=-1) then
currentExp:=GetXP(SKILL_AGILITY);
if(currentExp=-1) then
currentExp:=GetXP(SKILL_AGILITY);
if(currentExp=-1) then
currentExp:=GetXP(SKILL_AGILITY);
if(currentExp=-1) then
currentExp:=GetXP(SKILL_AGILITY);
if(currentExp=-1) then
currentExp:=GetXP(SKILL_AGILITY);
if(currentExp=-1) then
currentExp:=GetXP(SKILL_AGILITY);
result:=currentExp;
end;
//Rewrite of FindObjEx to try a max of 12 times before giving up
//Useful in case we move and script doesn't detect it
function FindObjEx2(var cx, cy: Integer; Text: TStringArray; Color: TIntegerArray;
Tol, Step, xs, ys, xe, ye: Integer): Boolean;
var
CurX, CurY, a, b, c, i, zzz: Integer;
Start: Boolean;
begin
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorSpiralTolerance(cx, cy, color[b], xs, ys, xe, ye, Tol)) then
begin
zzz:= zzz+1;
Start := True;
Break;
end;
end;
if (Start) then
begin
CurX := Round((xs + xe) div 2);
CurY := Round((ys + ye) div 2) - Step;
i := 1;
repeat
for c := 1 to i do
begin
case a of
0: begin //To allow for beginning offset and loop
a := a + 1;
i := 0;
CurY := CurY + Step;
end;
1: CurX := CurX + Step;
2: CurY := CurY - Step;
3: CurX := CurX - Step;
4: CurY := CurY + Step;
end;
if (CurX >= xs) and (CurX <= xe) and (CurY >= ys) and (CurY <= ye) then
begin
try
for b := 0 to (GetArrayLength(Color)-1) do
begin
if (FindColorTolerance(cx, cy, Color[b], CurX-(Step div 2), CurY-(Step div 2), CurX+(Step div 2), CurY+(Step div 2), Tol)) then
begin
MMouse(cx, cy, 3, 3);
zzz:= zzz+1;
writeln('zzz:');
writeln(zzz);
If (WaitUptextMulti(Text, 300)) then
begin
GetMousePos(cx, cy);
Result := True;
Exit;
end;
end;
end;
except
end;
end;
end;
a := a + 1;
if a mod 5 = 0 then a := 1;
if (a = 1) or (a = 3) then i := i + 1;
until (zzz > 12) or (Result) or ((CurX > xe) and (CurY > ye))
end;
end;
procedure sleepWhileMoving();
var t:Integer;
begin
t := 0;
while((IsMoving) and (t < 12)) do
begin
sleep(250+random(5))
writeln('Sleeping while moving');
t:=t+1;
end;
end;
function getLocation(): integer;
var myPos, First, Second, Third, Fourth: TPoint;
begin
result := 0;
if (mmblack = true) then
result := Wfloor()
else
begin
First := Point(2045, 2430); //Beginning Point
Second := Point(2045, 2445); //After swinging the rope
Third := Point(2005, 2460); //After log balancing
Fourth := Point(1940, 2415); //Before running up the wall
myPos := SPS_GetMyPos();
if ((distanceTo(First) <= 5) and (myPos.y < 2435)) then
begin
result:=1;
end;
if (distanceTo(Second) <= 5) then
begin
result:=2;
end;
if (distanceTo(Third) <= 15) then
begin
reRunUpWall := True;
result:=3;
end;
if (reRunUpWall = True) then
result:=3;
if (myPos = Fourth) then
begin
result:=4;
end;
end;
end;
procedure handleObstacle(spot: integer);
begin
writeln(spot);
if (spot = 0) then
begin
AntiRandoms;
writeln('Walk to beginning Point(2045, 2430)');
SPS_WalkToPos(Point(2045, 2430));
sleepWhileMoving();
end;
if (spot = 1) then
begin
writeln('Swing on rope');
if FindObjEx2(x, y, ['wing', 'on'], [861482], 5, 50, MSX1, MSY1, MSX2, MSY2) then
begin
Mouse(x, y, 3, 3, True);
sleep(2200+random(175));
sleepWhileMoving();
end;
end;
if (spot = 2) then
begin
writeln('Walk across log balance');
if FindObjEx2(x, y, ['walk', 'cross'], [7830921], 5, 50, MSX1, MSY1, MSX2, MSY2) then
begin
MMouse(x,y,5,5);
Mouse(x, y, 3, 3, True);
sleep(1900+random(150));
sleepWhileMoving();
end;
end;
if (spot = 3) then
begin
writeln('Run up wall');
SPS_WalkToPos(Point(1996, 2478));
writeln(SPS_GetMyPos());
if FindObjEx(x, y, ['Run'], [4349815], 5, 30, MSX1, MSY1, MSX2, MSY2) then
begin
Mouse(x, y, 3, 3, True);
sleep(6400+random(150));
sleepWhileMoving();
end;
end;
if (spot = 10) then
begin
if (reRunUpwall = True) then
reRunUpwall := False;
AntiRandoms;
writeln('Climb up wall');
if FindObjEx(x, y, ['limb', 'up'], [3624802], 5, 40, 174, 78, 253, 247) then
begin
Mouse(x, y, 0, 0, True);
sleep(3300+random(150));
sleepWhileMoving();
end;
end;
if (spot = 11) then
begin
writeln('Fire Spring Device');
if FindObjEx(x, y, ['ire'], [7713234,7317446], 5, 40, 105, 110, 361, 272) then
begin
Mouse(x, y, 0, 0, True);
sleep(4300+random(150));
sleepWhileMoving();
end;
end;
if (spot = 12) then
begin
writeln('Cross Balance Beam');
if FindObjEx(x, y, ['ross'], [6580073, 5329748], 5, 30, MSX1, MSY1, MSX2, MSY2) then
begin
Mouse(x, y, 0, 0, True);
sleep(2000+random(150));
sleepWhileMoving();
end;
end;
if (spot = 13) then
begin
writeln('Jump over gap');
if FindObjEx(x, y, ['ump'], [3691876], 5, 40, MSX1, MSY1, MSX2, MSY2) then
begin
Mouse(x, y, 0, 0, True);
sleep(2000+random(150));
sleepWhileMoving();
end;
end;
if (spot = 14) then
begin
AntiRandoms;
writeln('Slide down roof');
if FindObjEx(x, y, ['lide', 'own'], [4674652], 5, 30, 276, 105, 373, 250) then
begin
Mouse(x, y, 0, 0, True);
sleep(1800+random(150));
if(Random(100) > 0) then
begin
checkAgility;
writeln('Current Exp : ' + inttostr(currentExp));
end;
sleepWhileMoving();
laps:=laps+1;
end;
end;
end;
procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
Players[0].Name := Username;
Players[0].Pass := Password;
Players[0].Nick := Nickname;
Players[0].Active := True;
end;
procedure LogMeIn;
begin
LoginPlayerToLob;
OpenWorldScreen;
SelectWorld(SERVER);
LoginPlayer;
end;
begin
Smart_Server := SERVER;
Smart_Members := True;
//Setup
SetupSRL;
DeclarePlayers;
SPS_Setup(RUNESCAPE_SURFACE, ['4_5','4_6']);
AddOnTerminate('FreeAll');
if not(LoggedIn) then
LogMeIn;
while not(LoggedIn) do
sleep(1000);
startingExp:= checkAgility();
Writeln('Starting exp: ' + inttostr(startingExp));
ClickNorth(True);
while(true) do //Main loop
begin
while not(LoggedIn) do
LoginPlayer;
handleObstacle(getLocation());
gainedExp:= (currentExp-startingExp);
Paint;
myPos := SPS_GetMyPos();
writeln(Wfloor());
writeln(myPos);
writeln(mmBlack);
end;
end.