RISK
2012-02-24 16:08:36
Version: 1.0.4
Last updated: 2/26/2012
Intro:
This is my take on a range guilding script. I originally had one planned to be released much earlier but I 'Lost' the passion I have for scripting. But I have recently found it again. So I decided to start the script up again and finish it. After a few days of testing and creating the script, here it is.
Please keep in mind that pre-nuke, this area was a 'Ban spot'. Even though there is a person every one out of five worlds now, you should still be careful.
I have also not added a break system yet. But it is planned for future releases. This does about 90 competitions an hour, so you can do the math and set the competitions to do in DeclarePlayers as you desire.
There is also no multiplayer support yet, so please also keep that in mind!
If you have any errors to report, you can post them here or PM them to me.
I hope you all enjoy using my script and get many levels with it!
Special thanks to:
Flight,
Kyle Undefined
Download:
View the bottom of the post or just copy and paste the following code in to your Simba and save.
(*
R_RangeGuilder
ver 1.0.4
Created by RISK
*)
program R_RangeGuilder;
{$i SRL/SRL/MISC/SMART.simba}
{$i SRL/SRL.simba}
{$i SRL/SRL/MISC/PAINTSMART.simba}
{$i SRL/SRL/MISC/DEBUG.simba}
{$i SPS/SPS.simba}
var
breakRounds, totalBreaks, competitionsDone, startingTickets,
expLastReport, comInc, compsLastReport, compsDone, startTickets,
curTickets, gained, expGained, expThisReport, comExp, comComps,
compsThisReport: Integer;
const
WORLD = 40; // What world do you wish to auto on? 0 = random
STATS_USER = ''; // What is your SRL stats username? Leave blank if you have none
STATS_PASS = ''; // What is your SRL stats password? Leave blank if you have none
ENABLE_BREAKS = True; // Do you want to enable taking breaks?
(* Ignore these settings if you aren't taking breaks *)
BREAK_IN = 35; // Break in how many minutes?
BREAK_FOR = 10; // Break for how many minutes?
RAND_IN = 5; // How many minutes in randomness on BREAK_IN?
RAND_FOR = 5; // How many minutes in randomness on BREAK_FOR?
(* *)
AUTO_RETALIATE = True; // True = On, False = Off
ENABLE_MOUSE_PAINT = True; // Do you want to have a paint trail behind the mouse?
ENABLE_DEBUG_MODE = False; // Do you want to enable debugging?
// This will disable debug clearing when making a progress report
(* Do not edit this segment *)
MIN_CLICK_WAIT = 0;
MAX_CLICK_WAIT = 1;
MIN_TARGET_WAIT = 2;
MAX_TARGET_WAIT = 3;
HOW_MANY_COMPS = 4;
CHECK_FOR_ARROWS = 0;
SCRIPT_VERSION = '1.0.4';
(* *)
procedure DeclarePlayers();
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := ''; // What is your character's username?
Pass := ''; // What is your character's password?
LampSkill := SKILL_RANGE;
BoxRewards := ['xp', 'exp', 'emote', 'clothes', 'charms'];
Integers[HOW_MANY_COMPS] := 500; // How many competitions do you wish to do?
Booleans[CHECK_FOR_ARROWS] := False; // Disable this if you want to use your
// own arrows. Remember they must be bronze!
(* These settings are best to leave default, but you can edit them if you desire *)
// If you are experiencing a lot of misclicks, you can raise 'MIN_TARGET_WAIT'
// and 'MAX_TARGET_WAIT' to be customized to your lag and computer
// The same goes for MIN_CLICK_WAIT and MAX_CLICK_WAIT.
Integers[MIN_CLICK_WAIT] := 85;
Integers[MAX_CLICK_WAIT] := 125;
Integers[MIN_TARGET_WAIT] := 800;
Integers[MAX_TARGET_WAIT] := 1200;
(* Each of these settings I have adjusted to work well, in what I think, will be
good for everyone's purposes. But everyone has different computers and desire,
so if you truly wish to make the script faster in clicking and wait times or slower,
then you can modify the settings. Here is a short little 'Tutorial' on each
setting:
Remember, each of these options are in milliseconds. So 1000 is one second
and so on.
MIN_CLICK_WAIT = Minimum amount of time to wait before it clicks the target
again.
MAX_CLICK_WAIT = Maximum amount of time to wait before it clicks the target
again.
MIN_TARGET_WAIT = The minimum amount of time that the target screen is up before
it attempts to close it. This is to make sure it closes the target screen if it's
open for too long.
MAX_TARGET_WAIT = The maximum amount of time that the target screen is up before
it attempts to close it. This is to make sure it closes the target screen if it's
open for too long.
(* *)
Active := True;
end;
end;
(*
You do not need to and should not edit beyond this point.
*)
procedure Write(T: string);
begin
WriteLn(TheTime + ': ' + T);
end;
(*
BenLand's function, modified by Flight(?) to have a paint trail, re-modified
by RISK to disable the paint option completely if the user is not using SMART
*)
procedure WindMouse2(xs, ys, xe, ye, gravity, wind, minWait, maxWait, maxStep, targetArea: extended);
var
veloX, veloY, windX, windY, veloMag, dist, randomDist, lastDist, step: extended;
lastX, lastY: integer;
sqrt2, sqrt3, sqrt5: extended;
begin
sqrt2:= sqrt(2);
sqrt3:= sqrt(3);
sqrt5:= sqrt(5);
while hypot(xs - xe, ys - ye) > 1 do
begin
dist:= hypot(xs - xe, ys - ye);
wind:= minE(wind, dist);
if dist >= targetArea then
begin
windX:= windX / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
windY:= windY / sqrt3 + (random(round(wind) * 2 + 1) - wind) / sqrt5;
end else
begin
windX:= windX / sqrt2;
windY:= windY / sqrt2;
if (maxStep < 3) then
begin
maxStep:= random(3) + 3.0;
end else
begin
maxStep:= maxStep / sqrt5;
end;
end;
veloX:= veloX + windX;
veloY:= veloY + windY;
veloX:= veloX + gravity * (xe - xs) / dist;
veloY:= veloY + gravity * (ye - ys) / dist;
if hypot(veloX, veloY) > maxStep then
begin
randomDist:= maxStep / 2.0 + random(round(maxStep) div 2);
veloMag:= sqrt(veloX * veloX + veloY * veloY);
veloX:= (veloX / veloMag) * randomDist;
veloY:= (veloY / veloMag) * randomDist;
end;
lastX:= Round(xs);
lastY:= Round(ys);
xs:= xs + veloX;
ys:= ys + veloY;
if (lastX <> Round(xs)) or (lastY <> Round(ys)) then
MoveMouse(Round(xs), Round(ys));
step:= hypot(xs - lastX, ys - lastY);
wait(round((maxWait - minWait) * (step / maxStep) + minWait));
lastdist:= dist;
{$IFDEF SMART}
if (ENABLE_MOUSE_PAINT) then
SMART_DrawDotsEx(False, [Point(lastX, lastY)], clWhite);
{$ENDIF}
end;
if (Round(xe) <> Round(xs)) or (Round(ye) <> Round(ys)) then
MoveMouse(Round(xe), Round(ye));
end;
(*
Credits to Flight
*)
procedure HumanMMouse(eX, eY, ranX, ranY: Integer);
var
randSpeed: extended;
X,Y,X2,Y2,A,Dist,MP: integer;
begin
SMART_ClearCanvas;
A := MouseSpeed;
GetMousePos(X, Y);
Dist := Distance(X, Y, eX, eY);
MP := Round(Dist/150);
if MP < 0 then
MP := 1;
randSpeed := (random(MouseSpeed) / 2.0 + MouseSpeed) / 10.0;
X2 := RandomRange(eX-(A*MP), eX+(A*MP));
Y2 := RandomRange(eY-(A*MP), eY+(A*MP));
WindMouse2(X, Y, X2, Y2, 11, 8, 10.0 / randSpeed, 12.0 / randSpeed, 10.0 * randSpeed, 10.0 * randSpeed);
GetMousePos(X, Y);
MMouse(eX, eY, ranX, ranY);
MouseSpeed := A;
end;
procedure SetCTS(Hue, Saturation: Extended);
begin
SetColorToleranceSpeed(2);
SetColorSpeed2Modifiers(Hue, Saturation);
end;
procedure RevertCTS();
begin
SetColorSpeed2Modifiers(0.2, 0.2);
SetColorToleranceSpeed(1);
end;
procedure ExitPlayer(Message: string);
begin
Write(Message);
Players[CurrentPlayer].Active := False;
Logout;
end;
procedure RClickMM;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
// Mouses to the minimap and right clicks
MouseBox(MMX1, MMY1, MMX2, MMY2, MOUSE_RIGHT);
Wait(RandomRange(300, 400));
MouseBox(MSX1, MSY1, MSX2, MSY2, MOUSE_MOVE);
end;
procedure RClickChat;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (FindNPCChatText('.', Nothing)) then
Exit;
// Moves the mouse to the chat and right clicks
MouseBox(MCX1, MCY1, MCX2, MCY2, MOUSE_RIGHT);
Wait(RandomRange(200, 300)); // A random wait
MouseBox(MSX1, MSY1, MSX2, MSY2, MOUSE_MOVE);
end;
procedure RandomSpacebar;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (FindNPCChatText('.', Nothing)) then
Exit;
// Presses the spacebar
KeyDown(1);
Wait(RandomRange(75, 100));
KeyUp(1);
// Waits before backspacing
Wait(RandomRange(750, 1150));
// Backspaces to remove the space we have just typed
KeyDown(1);
Wait(RandomRange(300, 400));
KeyUp(1);
end;
(*
Credits to Kyle Undefined
*)
function RandomRangeEx(rFrom, rTo : Variant) : Variant;
var
r : Variant;
begin
r := RandomRange(Floor(rFrom), Ceil(rTo));
r := r + RandomE;
repeat
begin
if r <= rFrom then
r := r + RandomE
else if r >= rTo then
r := r - RandomE;
end;
until ((r >= rFrom) and (r <= rTo))
r := (Trunc(r * 100) / 100.00)
Result := r;
end;
// 33.0 ~ 46.7
procedure FixCompass();
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
MakeCompass(RandomRangeEx(33.0, 46.7));
end;
procedure AntiBan();
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
case (Random(375)) of
0 : RandomRClick;
1 :
begin
BoredHuman;
SetAngle(SRL_ANGLE_LOW);
end;
2 : ExamineInv;
3 :
begin
HoverSkill('Ranged', False);
Wait(RandomRange(4000, 7000)); // Random wait to 'View' the skill information
end;
4 : RClickChat;
5 : RClickMM;
6 .. 13 : RandomSpaceBar;
14 .. 39 : Wait(RandomRange(1000, 8000));
39 .. 70 : MouseSpeed := (RandomRange(10, 14));
end;
end;
function GetATPA(Col, Tol, W, H: Integer; Hue, Sat: Extended): T2DPointArray;
var
X, Y: Integer;
TPA: TPointArray;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
SetCTS(Hue, Sat);
FindColorsSpiralTolerance(X, Y, TPA, Col, MSX1, MSY1, MSX2, MSY2, Tol);
RevertCTS;
Result := (SplitTPAEx(TPA, W, H));
end;
// Updated 2/26/2012 - Added a maximum pixel limit along side the already in
// place minimum pixel limit to help with mousing over the judge instead of the
// guards
function R_MouseTPA(Text: string; Col, Tol, W, H: Integer; Hue, Sat: Extended): Boolean;
var
R, I, T, maxT, TT, maxTT: Integer;
P: TPoint;
ATPA: T2DPointArray;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
I := 0;
T := 0;
TT := 0;
maxT := (RandomRange(15000, 25000));
maxTT := (RandomRange(6500, 7500));
Result := False;
repeat
MarkTime(T);
repeat
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (TimeFromMark(T) >= maxT) then
begin
Result := False;
Exit;
end;
ATPA := (GetATPA(Col, Tol, W, H, Hue, Sat));
if (Length(ATPA) > 0) then
Break;
Write('Object was not detected. Waiting.');
AntiBan;
Wait(RandomRange(500, 1500));
until(False);
MarkTime(TT);
// What to do if the length of ATPA is greater than 0
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if (ENABLE_DEBUG_MODE) then
DebugATPABounds(ATPA);
for I := 0 to High(ATPA) do
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if ((Length(ATPA[I]) < 15) and (Length(ATPA[I]) > 40)) then
Continue;
P := (MiddleTPA(ATPA[I]));
HumanMMouse(P.X, P.Y, 5, 5);
Result := (WaitUpText(Text, RandomRange(750, 1500)));
if (Result) then
Break;
if (TimeFromMark(TT) >= maxTT) then
begin
Write('Max time passed. Let''s wait and try to find the object again.');
AntiBan;
Wait(RandomRange(500, 1500));
Break;
end;
Wait(RandomRange(450, 750));
end;
Inc(R);
until((Result) or (R >= (RandomRange(4, 6))) or (not(LoggedIn)));
end;
// Non CTS 2 version of R_MouseTPA
function R_MouseObj(Text: string; Col, Tol, W, H: Integer): Boolean;
var
X, Y, I, T, maxT: Integer;
P: TPoint;
TPA: TPointArray;
ATPA: T2DPointArray;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
I := 0;
T := 0;
maxT := (RandomRange(15000, 25000));
MarkTime(T);
repeat
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (TimeFromMark(T) >= maxT) then
begin
Write('We were unable to find the object.');
Result := False;
Exit;
end;
FindColorsSpiralTolerance(X, Y, TPA, Col, MSX1, MSY1, MSX2, MSY2, Tol);
if (Length(TPA) > 0) then
Break;
Write('The object is not on the screen. Waiting.');
AntiBan;
Wait(RandomRange(500, 1500));
until(False);
// What to do if the length of TPA is greater than 0
ATPA := (TPAToATPAEx(TPA, W, H));
SortATPAFromFirstPoint(ATPA, Point(MSCX, MSCY));
if (ENABLE_DEBUG_MODE) then
DebugATPABounds(ATPA);
for I := 0 to High(ATPA) do
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
P := (MiddleTPA(ATPA[I]));
HumanMMouse(P.X, P.Y, 5, 5);
Result := (WaitUpText(Text, RandomRange(850, 1500)));
if (Result) then
Break;
AntiBan;
Wait(RandomRange(250, 500));
end;
if (not(Result)) then
Write('We were unable to mouse the object.');
end;
// Point(2525, 2945), Point(2520, 2979)
// Updated 2/26/2012 thanks to Nebula's tip.
procedure SPS_FixPosition;
var
Path: TPointArray;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
Path := [Point(2525, 2945), Point(2520, 2979)];
if (SPS_WalkPath(Path)) then
begin
FixCompass;
SetAngle(SRL_ANGLE_LOW);
end else
ExitPlayer('SPS repositioning failed. Logging out.');
end;
// Created as the main method of fixing our position instead of SPS
procedure DTM_FixPosition;
var
X, Y, DTM, T, maxT: Integer;
E: Extended;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
T := 0;
maxT := (RandomRange(3000, 5000));
DTM := DTMFromString('mggAAAHicY2NgYLAAYi8gFgdiHgYIAPHVgVgAiLWgYiJALAXE1TU6DAnV2gypiaoM2SGODB1VgQx5fYYM/EA5bJgJiBmxYAgAAG0ICHo=');
MarkTime(T);
repeat
if (not(LoggedIn)) then
Exit;
FindNormalRandoms;
if (TimeFromMark(T) >= maxT) then
begin
Write('DTM repositioning failed. Let''s try SPS.');
FreeDTM(DTM);
SPS_FixPosition;
end;
Wait(RandomRange(75, 200));
until(FindDTMRotated(DTM, X, Y, MMX1, MMY1, MMX2, MMY2, - Pi / 4, Pi / 4, Pi / 60, E));
FreeDTM(DTM);
HumanMMouse(X, Y, 5, 5);
ClickMouse2(MOUSE_LEFT);
FFlag(5);
FixCompass;
end;
// Fixes the chats so that we can detect if we have a new competition or not
procedure FixChats;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
SetAllChats('All', 'Off', 'Off', 'Off', 'Off', 'Off', '');
end;
procedure HandleNoArrows;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (not(FindNPCChatText('standard', Nothing))) then
Exit;
ExitPlayer('We have run out of arrows to use.');
Exit;
end;
function TargetScreen(): Boolean;
begin
Result := (CountColorTolerance(4500223, MSX1, MSY1, MSX2, MSY2, 10) > 100);
end;
procedure CloseTargetScreen();
var
X, Y, DTM, I, T, maxT: Integer;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (not(TargetScreen)) then
Exit;
T := 0;
maxT := (RandomRange(150000, 250000));
DTM := DTMFromString('mbQAAAHicY2VgYHjKyMDwFojvQ+l7QKwJFDeEYmUoVpQRZeDk5IRj' +
'A01FBi6gODpmxILBAAA7xwas');
MarkTime(T);
while (TargetScreen) do
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (TimeFromMark(T) >= maxT) then
begin
FreeDTM(DTM);
ExitPlayer('We were unable to close the target screen.');
Exit;
end;
if (FindDTM(DTM, X, Y, MSX1, MSY1, MSX2, MSY2)) then
begin
HumanMMouse(X, Y, 3, 3);
if (not(WaitUpText('Close', RandomRange(500, 800)))) then
begin
FreeDTM(DTM);
Exit;
end;
ClickMouse2(MOUSE_LEFT);
for I := 0 to 5 do
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (not(TargetScreen)) then
begin
FreeDTM(DTM);
Exit;
end;
Wait(RandomRange(500, 600));
end;
end;
end;
FreeDTM(DTM);
end;
procedure FireAtTargets();
var
minW, maxW, minC, maxC, I, maxI, T, TT, maxT, TTT, maxTTT, TTTT, maxTTTT: Integer;
startP, curP: TPoint;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
minW := (Players[CURRENTPLAYER].Integers[MIN_TARGET_WAIT]);
maxW := (Players[CURRENTPLAYER].Integers[MAX_TARGET_WAIT]);
minC := (Players[CURRENTPLAYER].Integers[MIN_CLICK_WAIT]);
maxC := (Players[CURRENTPLAYER].Integers[MAX_CLICK_WAIT]);
I := 0;
T := 0;
maxT := (RandomRange(150000, 250000));
TT := 0;
TTT := 0;
TTTT := 0;
maxTTTT := (RandomRange(4000, 6000));
maxTTT := (RandomRange(10000, 20000));
MarkTime(T);
MarkTime(TTTT);
repeat
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
HandleNoArrows;
if (TargetScreen) then
CloseTargetScreen;
if (TimeFromMark(T) >= maxT) then
begin
ExitPlayer('We were unable to fire at the targets.');
Exit;
end;
if (R_MouseObj('Fire-a', 5041405, 10, 10, 10)) then
Break;
if (TimeFromMark(TTTT) >= maxTTTT) then
begin
Write('We were unable to find any targets. We might be out of the area.');
DTM_FixPosition;
TTTT := 0;
maxTTTT := (RandomRange(4000, 6000));
MarkTime(TTTT);
AntiBan;
Wait(RandomRange(550, 850));
end;
Write('Unable to mouse over a target. Let''s wait.');
//if (not(CheckCompass))) then
// FixCompass;
AntiBan;
Wait(RandomRange(500, 1500));
until(False);
GetMousePos(startP.X, startP.Y);
MarkTime(TT);
repeat
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
GetMousePos(curP.X, curP.Y);
HandleNoArrows;
if (TimeFromMark(TT) >= maxT) then
begin
ExitPlayer('We were unable to fire at the targets.');
Exit;
end;
case (Random(30)) of
1 :
begin
GetMousePos(curP.X, curP.Y);
curP.X := (curP.X + Random(2));
curP.Y := (curP.Y + Random(2));
HumanMMouse(curP.X, curP.Y, 0, 0);
end;
2 :
begin
GetMousePos(curP.X, curP.Y);
curP.X := (curP.X - Random(2));
curP.Y := (curP.Y - Random(2));
HumanMMouse(curP.X, curP.Y, 0, 0);
end;
3 :
begin
GetMousePos(curP.X, curP.Y);
curP.X := (curP.X - Random(2));
curP.Y := (curP.Y + Random(2));
HumanMMouse(curP.X, curP.Y, 0, 0);
end;
4 :
begin
GetMousePos(curP.X, curP.Y);
curP.X := (curP.X + Random(2));
curP.Y := (curP.Y - Random(2));
HumanMMouse(curP.X, curP.Y, 0, 0);
end;
end;
// Checking to see if we have clicked to a different position
if (FindNPCChatText('meant', Nothing)) then
begin
Write('We have moved out of the shooting range. Repositioning.');
DTM_FixPosition;
end;
// Misclick handling
if (not(IsUpText('Fire-a')) and (not(TargetScreen))) then
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
HandleNoArrows;
Wait(RandomRange(500, 1500));
if (not(IsUpText('Fire-a')) and (not(TargetScreen))) then
if (not(R_MouseObj('Fire-a', 5041405, 10, 10, 10))) then
begin
DTM_FixPosition;
if (not(R_MouseObj('Fire-a', 5041405, 10, 10, 10))) then
begin
ExitPlayer('We have misclicked and we were unable to fix our position.');
Exit;
end;
end else
begin
GetMousePos(startP.X, startP.Y);
GetMousePos(curP.X, curP.Y);
end;
end;
// Target screen handling
if (TargetScreen) then
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
HandleNoArrows;
// We have this here to make sure the while .. do loop works properly
I := 0;
maxI := (RandomRange(minW, maxW));
MarkTime(TTT);
while (not(I >= maxI)) do
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
// Randomizes the waiting time per 'loop-thru' of the fail-safe
maxI := (RandomRange(minW, maxW));
if (TimeFromMark(TTT) >= maxTTT) then
begin
ExitPlayer('Error in detecting the target screen.');
Exit;
end;
if (not(TargetScreen)) then
Break;
Wait(100);
IncEx(I, 100);
end;
if ((I >= maxI) and ((TargetScreen))) then
begin
Write('The target screen has been up for ' + ToStr(maxI) + ' second(s). Closing it.');
CloseTargetScreen;
HumanMMouse(startP.X, startP.Y, 5, 5);
end;
end;
// Over the maximum amount of distance from center of target handling
if (Distance(curP.X, curP.Y, startP.X, startP.Y) >= 10) then
begin
Write('Mouse is too far from the center of the target. Fixing it.');
HumanMMouse(startP.X, startP.Y, 5, 5);
end;
// Clicking handling
ClickMouse2(MOUSE_LEFT);
Wait(RandomRange(minC, maxC));
until(FindNPCChatText('Sorry', Nothing) or (not(LoggedIn)));
end;
function ArrowsEquipped: Boolean;
var
X, Y, DTM: Integer;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
DTM := DTMFromString('mbQAAAHicY2VgYJjIxMAwG4j7gbgTiGcC8Sug+AsgfgLEb4H4HRAbKCgwuKpzAllMYDpOmJeBH8hDx4xYMBgAAO7dCag=');
GameTab(26);
Result := (FindDTM(DTM, X, Y, MIX1, MIY1, MIX2, MIY2));
FreeDTM(DTM);
end;
procedure EquipArrows();
var
DTM, I, T, maxT: Integer;
P: TPoint;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
I := 0;
T := 0;
maxT := (RandomRange(15000, 25000));
DTM := DTMFromString('mbQAAAHicY2VgYJjIxMAwG4j7gbgTiGcC8Sug+AsgfgLEb4H4HRAbKCgwuKpzAllMYDpOmJeBH8hDx4xYMBgAAO7dCag=');
MarkTime(T);
repeat
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (TimeFromMark(T) >= maxT) then
begin
FreeDTM(DTM);
ExitPlayer('There are no arrows in our inventory and none are equipped. - Perhaps a DTM failure.');
Exit;
end;
if (FindDTM(DTM, P.X, P.Y, MIX1, MIY1, MIX2, MIY2)) then
begin
HumanMMouse(P.X, P.Y, 3, 3);
if (WaitUpText('ze ar', RandomRange(750, 1500))) then
begin
ClickMouse2(MOUSE_LEFT);
for I := 1 to 5 do
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (not(FindDTM(DTM, P.X, P.Y, MIX1, MIY1, MIX2, MIY2))) then
begin
Write('We have equipped the arrows.');
FreeDTM(DTM);
Exit;
end;
Wait(RandomRange(100, 400));
end;
end;
end;
Write('There are no arrows in our inventory.');
AntiBan;
Wait(RandomRange(750, 1500));
if (ArrowsEquipped) then
begin
Write('We already have arrows equipped.');
Break;
end;
until(False);
FreeDTM(DTM);
end;
// Remade 2/24/2012 to make it less 'One shot'
// Modified 2/26/2012 - Removed some of the getting a new competition checks
// due to my new obtained knowledge that you don't need to click the green
// button or do anything after that to start a new competition. I'm sorry for
// including it in the first place, I was unaware of this.
procedure GetCompetition();
var
T, TT, TTT, maxT, maxTT, maxTTT, X, Y, iTR, cTR: Integer;
B, BB: Boolean;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
maxT := (RandomRange(60000, 65000));
maxTT := (RandomRange(4000, 5000));
T := 0;
TT := 0;
TTT := 0;
iTR := 0;
cTR := 0;
B := False;
BB := False;
MarkTime(T);
MarkTime(TT);
repeat
repeat // Attempts to mouse and interact with the judge
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (TargetScreen) then
CloseTargetScreen;
// Exits the character if we are unable to get a new competition
if (TimeFromMark(T) >= maxT) then
begin
ExitPlayer('We were unable to get a new competition.');
Exit;
end;
// Fixes the position of our character if we are unable to see the judge
if (TimeFromMark(TT) >= maxTT) then
begin
Write('We might be unable to see the judge. Let''s fix our location.');
DTM_FixPosition;
TT := 0;
maxTT := (RandomRange(4000, 5000));
AntiBan;
Wait(RandomRange(500, 850));
end;
if (R_MouseTPA('Judge', 6906979, 9, 15, 15, 0.31, 0.08)) then
begin
ClickMouse2(MOUSE_RIGHT);
maxTTT := (RandomRange(1500, 2000));
MarkTime(TTT);
// Waits for the option that the judge always has upon right click to show
while (not(OptionsExist(['k-to Comp'], False))) do
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
if (TimeFromMark(TTT) >= maxTTT) then
Break;
Write('Judge options not detected. Waiting.');
Wait(100);
end;
if ((TimeFromMark(TTT) >= maxTTT) and (not(OptionsExist(['k-to Comp'], False)))) then
begin
Write('We might have moused over the wrong object. Trying again.');
Continue;
end;
if (not(WaitOption('ete Comp', RandomRange(850, 1250)))) then
begin
Write('We have a competition already.');
Exit;
end;
Break; // Breaks out of the first repeat .. until to complete the procedure
end;
Write('Waiting for the object to be on the screen.');
AntiBan;
Wait(RandomRange(500, 1500));
until(False);
// Handles waiting for the pay confirmation dialogue to appear
for iTR := 1 to 5 do
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
B := (FindText(X, Y, '1', StatChars, MCX1, MCY1, MCX2, MCY2));
if (B) then
Break;
Write('Waiting for the pay confirmation dialogue to show.');
Wait(RandomRange(750, 1250));
end;
// Continues if we have timed out after waiting for the pay confirmation dialogue
if ((iTR >= 5) and (not(B))) then
Continue;
// Handles clicking 'Yes' for the pay confirmation dialogue
// We use MMouse here instead of HumanMMouse as HumanMMouse does not look
// like a human would when choosing a dialoge option.
MMouse(X, Y, 25, 7);
ClickMouse2(MOUSE_LEFT);
if (B) then
begin
Write('We have started a new competition!');
Exit;
end;
until(False);
end;
procedure StartGame();
var
Checking: Boolean;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
Checking := (Players[CURRENTPLAYER].Booleans[CHECK_FOR_ARROWS]);
GetCompetition;
if (Checking) then
EquipArrows;
end;
function TicketAmount: Integer;
var
DTM: Integer;
begin
if (not(LoggedIn)) then
Exit;
if (FindNormalRandoms) then
SetAngle(SRL_ANGLE_LOW);
DTM := DTMFromString('mbQAAAHicY2VgYMhlYmAoBeJ8IE4E4mQglmZkYJABYnUgVgZicSDOa4sEqmZCwfxAEh0zYsFgAABgUwRn');
GameTab(25);
Result := (ItemAmount('inv', 'dtm', DTM, []));
FreeDTM(DTM);
end;
// Five minute report
procedure ProgressReport;
var
XPH, CPH: Integer;
timeRan: string;
begin
if (not(ENABLE_DEBUG_MODE)) then
ClearDebug;
compsDone := (competitionsDone);
timeRan := (MSToTime(GetTimeRunning, Time_Bare));
startTickets := (startingTickets);
curTickets := (TicketAmount);
gained := (curTickets - startTickets);
expGained := (Gained * 5);
// Borrowed from Nebula's Range Guilder
CPH := (Round((competitionsDone) * 3600) / ((GetTimeRunning) / 1000));
XPH := (Round(gained * 5 * 3600) / ((GetTimeRunning) / 1000));
WriteLn('__________________________');
WriteLn('');
WriteLn(' RISK''s Range Guilder');
WriteLn(' Script version: ' + SCRIPT_VERSION);
WriteLn(' Time ran: ' + timeRan);
WriteLn(' Competitions done: ' + ToStr(compsDone));
WriteLn(' Competitions/h: ' + ToStr(CPH));
WriteLn(' Tickets gained: ' + ToStr(gained));
WriteLn(' EXP gained: ' + ToStr(expGained));
WriteLn(' EXP/h: ' + ToStr(XPH));
WriteLn('__________________________');
end;
// Created by Echo_, modified by Flight
function BreakHandler(BreakIn, BreakFor, randBreakIn, randBreakFor: Integer): Boolean;
var
realTime, w, x, y, z: Integer;
begin
if not LoggedIn then
Exit;
w := (BreakIn * 60000);
x := (BreakFor * 60000);
y := RandomRange(-randBreakIn * 60000, randBreakIn * 60000);
z := RandomRange(-randBreakFor * 60000, randBreakFor * 60000);
realTime := ((x + z) / 60000);
if (HowManyPlayers = 1) then
begin
if (GetTimeRunning < ((w) + (y) + BreakRounds)) then Exit
else
if (GetTimeRunning > ((w) + (y) + BreakRounds)) then
begin
Writeln('Taking a break for about ' + IntToStr(realTime) + ' minutes.');
Logout;
Wait((x) + (z));
Writeln('Logging in.');
LoginPlayer;
Result := LoggedIn;
FindNormalRandoms;
IncEx(BreakRounds, (w) + (x));
IncEx(TotalBreaks, 1);
Writeln('The next break will occur in about ' + IntToStr(realTime) + ' minutes.');
end;
end;
if (HowManyPlayers > 1) then
begin
if (GetTimeRunning < ((w) + (y) + BreakRounds)) then Exit
else
if (GetTimeRunning > ((w) + (y) + BreakRounds)) then
begin
Writeln('Taking a break for about ' + IntToStr(BreakFor) + ' minutes.');
Logout;
IncEx(BreakRounds, (w));
IncEx(TotalBreaks, 1);
NextPlayer(True);
Exit;
while (LoggedIn) do
Wait((x) + (z));
NextPlayer(True);
end;
end;
end;
procedure MainLoop();
var
T, TT, maxComps: Integer;
begin
repeat
maxComps := (Players[CURRENTPLAYER].Integers[HOW_MANY_COMPS]);
competitionsDone := 0;
comInc := 0;
startingTickets := (TicketAmount);
MarkTime(T);
MarkTime(TT);
FixChats;
Retaliate(AUTO_RETALIATE);
repeat
Inc(competitionsDone);
StartGame;
Wait(RandomRange(300, 500));
FireAtTargets;
Wait(RandomRange(300, 500));
AntiBan;
// Stat reporting & 5 minute debug report
if (TimeFromMark(T) >= 300000) then
begin
ProgressReport;
compsDone := (competitionsDone);
startTickets := (startingTickets);
curTickets := (TicketAmount);
gained := (curTickets - startTickets);
expGained := (Gained * 5);
// Stat committing is now in the main loop as 1.0.4 to test if it works
expThisReport := (expGained);
compsThisReport := (compsDone);
if (not(comInc = 0)) then
begin
comExp := (expThisReport - expLastReport);
comComps := (compsThisReport - compsLastReport);
end else
begin
comExp := (expThisReport);
comComps := (compsThisReport);
end;
expLastReport := (expThisReport);
compsLastReport := (compsThisReport);
stats_IncVariable('Ranged EXP (Gained)', comExp);
stats_IncVariable('Total EXP Gained', comExp);
stats_IncVariable('Competitions Done', comComps);
if (stats_Commit) then
Write('We have committed stats to SRL stats!');
Inc(comInc);
T := 0;
end;
// Breaking
if (ENABLE_BREAKS) then
if (BreakHandler(BREAK_IN, BREAK_FOR, RAND_IN, RAND_FOR)) then
begin
FixCompass;
SetAngle(SRL_ANGLE_LOW);
end;
until((competitionsDone >= maxComps) or (not(LoggedIn)));
ExitPlayer('');
Write('If you have encountered an error, please enable debug mode in the script setup and rerun the script.');
Write('Thank you!');
until((AllPlayersInactive));
end;
procedure Setup();
begin
SMART_Server := WORLD;
SMART_Members := True;
AddOnTerminate('ProgressReport');
SetupSRL;
SetupSRLStats(836, STATS_USER, STATS_PASS);
SPS_Setup(RUNESCAPE_SURFACE, ['6_7']);
MouseSpeed := (RandomRange(10, 12));
DeclarePlayers;
LoginPlayer;
SetAngle(SRL_ANGLE_LOW);
ClearDebug;
FixCompass;
MainLoop;
end;
begin
Setup;
end.Change log:
1.0.4:
* I've [i]possibly[/i] increased the speed of the script by removing some
of the procedure that gets a new competition. I originally had it go thru
all of the dialogue because I did not know that you only had to press the
payment confirmation button. So I removed the click to continue button
and chat-box confirmation parts of the procedure.
* I have added the break system. The user options for it can be found
below where you enter your stats username and password.
Instructions for the options can be found in the main post of this thread
under the setup section.
* I have changed the default clicking speeds to be a 'bit slower so that
it will not have to close the target screen so much. As always, if
you would like it to be faster or slower, you can adjust the options in
DeclarePlayers.
* I have fixed the distance from the target center and the mouse
checker. I had the amount at 20 when it should have been at 10.
I made it 20 when I was still testing it before I
released it due to a bug I could not figure out. I fixed the bug,
but I forgot to revert the distance checker maximum
distance back to 10 from 20. It should [i]hopefully[/i]
misclick a lot less now with the distance checker
actually working now.
* I have removed a segment from my TPA mousing
function that relies on CTS 2/Hue/Saturation that was
useless code that I never really used for some reason.
I forgot to remove it, but I have now removed it.
* I have added a maximum pixel check to my TPA mousing
function that relies on CTS 2/Hue/Saturation. This will work alongside
the minimum pixel check I already had in place. I'd like some feedback
on the guard finding now that I have added that, please.
* I have changed the way mousing the confirmation button works. I've
changed from HumanMMouse (Flight's amazing function) to the regular
MMouse when clicking the confirmation button in the dialogue as it looks
a 'bit un-humanlike in my opinion when using HumanMMouse for that.
* In regards to the mousing the confirmation button update, I have also made
the range of clicking the button itself a 'bit larger to make it more human-like.
It would previously only click on the '1' and a 'bit away from it. It looked very
bot-like in my opinion, so I have updated it.
* I've fixed the antiban procedure again. Two of the errors that I thought
I had fixed in the previous update were not fixed as I made a mistake. It
should be fixed now and when it does antiban, it shouldn't stop the script
due to the angle of the screen being at the highest point.
* I've fixed a bug in the random finding. When it would find and solve a
random, it would leave the angle of the screen at the highest point, thus
causing the script to eventually log out. But I believe I have fixed this now.
* I've made the mouse speed a random speed instead of it being just one
'Preset' speed. In regards to the mouse speed, I have also increased the
chance of the random mouse speed increase in the anti-ban by a 'bit.
I have also decreased the chance of antiban happening, but not by a lot.
* I have implemented Nebula's kind suggestion to my SPS backup position
fixing method. This should help fix some of the reposition errors that some
people may have, hopefully resulting in much longer runs for some people
that have had trouble with the script recently.
- Thanks, Nebula!
* I have removed the checking if we are in combat and escaping from it
procedure for now. Until I am able to create my own combat checking and
running from combat procedures, it will stay removed. As I noticed when
another person would be in combat by misclicking on a guard, the script
will attempt to run away. But it would not as I also had a bug in the running
away part of the procedure. But since I have removed it, this bug has been
solved, of course.
* I have added a user option in the settings that will allow them to choose if
they want to have the script enable auto retaliation from the start or not. This
is to 'Cater' to the people who might have characters they do not want HP levels
on and they would rather have their character die than them to gain an HP level.
* I have changed stat reporting to be in the main loop. Even if the variables
are not being sent at this time, it will be good to have them just in case. The
progress report in the debug will still show every five minutes though.
* I have added competitions per hour and experience per hour in to the
progress report. I borrowed the code to do it from Nebula's range guilder,
I have credited them where I use it. I borrowed it because I had no idea
how to create that type of stuff. But thanks to him, I have learned how.
- Thanks again, Nebula!
* I have added a target screen checker and closer early in most repeats, just
to make sure the script will not get stuck because of the target screen being up
while the script is trying to get a new competition or a target. So that could have
been considered a bug, but I have hopefully fixed it.
* I have added a lamp reward option and box reward options
in to DeclarePlayers.Setup:
Start next to the Competition judge with a bow equipped and enough gold to last you the amount of trips you want. Each competition requires 200 gold to start, so keep that in mind.
If you are using your own arrows and do not wish to spend time equipping the arrows you receive from the judge each new competition, then please disable "CHECK_FOR_ARROWS" in DeclarePlayers. To disable it you have to change 'True' to 'False', without the ''s, of course.
Also please make sure you have a free inventory to avoid any confusion with any other items in the inventory for the arrows or tickets to prevent 'Miscounting'. Thanks! :)
To enable breaks, look in the script options below where you insert your stats username and password. Set "ENABLE_BREAKS" to "True", without the quotation marks, of course. Then change the values under it.
BREAK_IN is how many minutes until you take a break,
BREAK_FOR is how many minutes you will take the break for,
RAND_IN is how many minutes in randomness you would like BREAK_IN to be,
RAND_FOR is the same as RAND_IN but for BREAK_FOR.
Remember, the options are in minutes. So don't enter them in milliseconds. :) 1 = 1 minute and so on.
Important:
Please make sure you have XP popup and display turned off. You can do this by right clicking the XP button next to the minimap and clicking both 'Toggle XP Popup' and 'Toggle XP Display'.
The only settings you will want to alter are these:
const
WORLD = 40; // What world do you wish to auto on? 0 = random
STATS_USER = ''; // What is your SRL stats username? Leave blank if you have none
STATS_PASS = ''; // What is your SRL stats password? Leave blank if you have none
ENABLE_BREAKS = True; // Do you want to enable taking breaks?
(* Ignore these settings if you aren't taking breaks *)
BREAK_IN = 35; // Break in how many minutes?
BREAK_FOR = 10; // Break for how many minutes?
RAND_IN = 5; // How many minutes in randomness on BREAK_IN?
RAND_FOR = 5; // How many minutes in randomness on BREAK_FOR?
(* *)
AUTO_RETALIATE = True; // True = On, False = Off
ENABLE_MOUSE_PAINT = True; // Do you want to have a paint trail behind the mouse?
procedure DeclarePlayers();
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;
with Players[0] do
begin
Name := ''; // What is your character's username?
Pass := ''; // What is your character's password?
Integers[HOW_MANY_COMPS] := 500; // How many competitions do you wish to do?
Booleans[CHECK_FOR_ARROWS] := False; // Disable this if you want to use your
// own arrows. Remember they must be bronze!
Active := True;
end;
end; Top Reports:
RISK:
__________________________
RISK's Range Guilder
Script version: 1.0.0a
Time ran: 04:19:54
Competitions done: 372
Tickets gained: -3578
EXP gained: -17890
__________________________
Eltardo:
RISK's Range Guilder
Script version: 1.0.3a
Time ran: 02:04:42
Competitions done: 170
Tickets gained: 11641
EXP gained: 58205kuiper:
__________________________
RISK's Range Guilder
Script version: 1.0.3a
Time ran: 02:01:24
Competitions done: 128
Tickets gained: -5617
EXP gained: -28085
__________________________ Donations:

If you have enjoyed my script and feel I deserve a donation of any amount, please click that button. You may also donate RSGP by PMing me.
Thank you very much! It would mean a lot to me if you did donate.
