SRL Archive - SRL Snippets

Fairy Ring Usage


Kevin

2013-07-01 00:12:05

This is slightly long… But I can't seem to break it anymore and it seems to be fail-safed enough, so I'm submitting it now. (As a side note, I use my WaitUpTextAcc instead of WaitUpTextMulti for accuracy/simplicity reasons.

With this Simply calling FairyRingTele('CKS') will get you to morytania - or any of the other areas as you change the paramers.


function FindAndClickEdgevilleFairyRing: boolean;
var
tempCTS, x, y: integer;
ATPA : T2DPointArray;
TPA: TPointArray;
box: TBox;
begin
tempCTS := GetColorToleranceSpeed; //set CTS
ColorToleranceSpeed(2);
SetColorSpeed2Modifiers(0.03, 0.07);
FindColorsSpiralTolerance(MSCX, MSCY, TPA, 4544893, MSX1, MSY1, MSX2, MSY2, 10);
SetColorSpeed2Modifiers(0.2, 0.2);
ColorToleranceSpeed(tempCTS);
ATPA:= TPAtoATPAEx(TPA, 120, 90);
SortATPASize(ATPA, true);
if((length(atpa)=0) or (length(atpa[0]) < 10))then
Exit;
MiddleTPAEx(ATPA[0], x, y);
MMouse(x, y, 3, 3);
If (WaitUpTextAcc('Use Fairy ring', 0.7, 600)) Then
begin
Result := True;
clickMouse2(mouse_Left);
end;
end;

function FairyCodeMenuOpen: boolean;
begin
Result:= (CountColorTolerance(4212288, MSX1, MSY1, MSX2, MSY2, 5) > 20000);
end;

procedure SelectFairyLetter(letter: String);
begin
if(not FairyCodeMenuOpen)then
Exit;
case Lowercase(letter) of
'a':begin end; //nothing necessary
'b':begin Mouse(40, 170, 30, 30, mouse_left); end;
'c':begin
case Random(1) of
0:begin Mouse(40, 170, 30, 30, mouse_left); wait(randomRange(100,200)); ClickMouse2(mouse_left); end;
1:begin Mouse(140, 170, 30, 30, mouse_left); wait(randomRange(100,200)); ClickMouse2(mouse_left); end;
end;
end;
'd':begin Mouse(140, 170, 30, 30, mouse_left); end;
'i':begin
end; //nothing necessary
'j':begin Mouse(210, 170, 30, 30, mouse_left); end;
'k':begin
case Random(1) of
0:begin Mouse(210, 170, 30, 30, mouse_left); wait(randomRange(100,200)); ClickMouse2(mouse_left); end;
1:begin Mouse(310, 170, 30, 30, mouse_left); wait(randomRange(100,200)); ClickMouse2(mouse_left); end;
end;
end;
'l':begin Mouse(310, 170, 30, 30, mouse_left); end;
'p':begin end; //nothing necessary
'q':begin Mouse(380, 170, 30, 30, mouse_left); end;
'r':begin
case Random(1) of
0:begin Mouse(380, 170, 30, 30, mouse_left); wait(randomRange(100,200)); ClickMouse2(mouse_left); end;
1:begin Mouse(480, 170, 30, 30, mouse_left); wait(randomRange(100,200)); ClickMouse2(mouse_left); end;
end;
end;
's':begin Mouse(480, 170, 30, 30, mouse_left); end;
end;
wait(randomRange(100,200));
end;

function FindFairyRing: boolean;
var
timer, xPos: integer;
begin
if(FindAndClickEdgevilleFairyRing)then
Result:= True;
timer:= GetSystemTime+10000;
wait(600);
repeat
wait(randomRange(75,150));
xPos:= SPS_GetMyPos.x;
until((GetSystemTime > timer) or (xPos < 0));
if(GetSystemTime > timer)then
TerminateScript;//failure
ClickNorth(SRL_ANGLE_HIGH);
MMouse(262,188,5,5);
ClickMouse2(Mouse_Left);
timer:= GetSystemTime+10000;
repeat
wait(randomRange(75,150));
until((GetSystemTime > timer) or (FairyCodeMenuOpen));
if(not FairyCodeMenuOpen)then
TerminateScript;//Could not open fairy teleportation menu. failure
end;

function RotateCheck(check: function(): boolean; angleOfRotation: integer): boolean;
var
i: integer;
begin
i:= angleOfRotation-30;
while (i<=(angleOfRotation+30))do
begin
MakeCompass(i);
wait(randomRange(300,400));
if(Check())then
begin
Result:= True;
wait(randomRange(500,1000));
Exit;
end;
i:=i+30;
end;
end;

procedure GetToZanaris;
var
tries: integer;
begin
LodestoneTeleport('Edgeville');
wait(randomRange(16000, 17500));
repeat
ToggleActionBar(false);
until(not IsActionBarOpen);
SPS_Setup(RUNESCAPE_SURFACE, ['10_5', '10_6', '9_5', '9_6']);
SetAngle(SRL_ANGLE_HIGH);
for tries:= 0 to 3 do
begin
if(ObjDTM_WalkPath(['148:88:5:0:7:89:32:0:7:140:50:3:7:105:96:3:7:100:120:1:7:120:33', '147:78:7:0:7:132:50:0:7:77:41:1:7:76:20:1:7:56:24:1:7:135:85:3:7:36:111:3:7:41:87', '144:60:6:0:7:69:53:1:7:98:120:1:7:71:88:1:7:76:28:1:7:60:28:3:7:104:136', '131:121:8:1:7:74:115:1:7:82:96:1:7:98:111:1:7:102:88:1:7:106:69:1:7:91:65:1:7:82:126:5:7:113:76', '76:101:8:1:7:99:77:1:7:106:88:1:7:101:104:1:7:103:61:1:7:53:72:1:7:57:49:1:7:37:86:0:7:134:52'], 5, 200, 5, false, true))then
FFlag(0)
else if(SPS_WalkPath([Point(4063, 2588), Point(4071, 2588), Point(4079, 2588), Point(4090, 2586), Point(4099, 2585), Point(4110, 2585), Point(4123, 2585), Point(4136, 2584), Point(4145, 2583), Point(4156, 2582), Point(4171, 2582), Point(4185, 2583), Point(4200, 2580), Point(4216, 2575), Point(4228, 2571), Point(4237, 2569), Point(4248, 2563), Point(4255, 2554), Point(4263, 2546), Point(4271, 2541), Point(4285, 2533), Point(4295, 2533), Point(4303, 2533), Point(4315, 2533), Point(4326, 2533), Point(4334, 2533), Point(4335, 2540), Point(4329, 2548), Point(4323, 2555), Point(4319, 2564), Point(4321, 2568), Point(4322, 2571), Point(4321, 2581), Point(4318, 2594), Point(4308, 2603), Point(4300, 2614), Point(4299, 2622)]))then
FFlag(0);
if(RotateCheck(@FindFairyRing, 0))then
break;
ClickNorth(SRL_ANGLE_HIGH);
end;
if(tries=4)then
TerminateScript;//Some reason caused us to fail to reach the fairy ring.
end;

procedure FairyRingTele(address: String);
begin
if(length(address) <> 3)then
begin
Exit;//Fairy codes must be 3 letters.
end;
GetToZanaris;
SelectFairyLetter(address[1]);
SelectFairyLetter(address[2]);
SelectFairyLetter(address[3]);
Mouse(260, 285, 75, 20, mouse_left);
repeat
ToggleActionBar(true);
until(IsActionBarOpen);
end;

Silentcore

2013-07-01 09:31:38

Very nice Kevin, i barely ever script but i can read this and understand by the way it works.

Turpinator

2013-07-01 13:13:27

Hmm. Looks nice. my only suggestion would be be in SelectFairyRingLetter, to add the usage of FairyCodeMenuOpen, just to ensure it is still open, not that through some super rare lag/glitch it gets closed.

Kevin

2013-07-01 14:23:49

From: Silentcore
Very nice Kevin, i barely ever script but i can read this and understand by the way it works.

I hope that means it's not too simple ;)

From: Turpinator
Hmm. Looks nice. my only suggestion would be be in SelectFairyRingLetter, to add the usage of FairyCodeMenuOpen, just to ensure it is still open, not that through some super rare lag/glitch it gets closed.

That's a good idea just for a safety check, will do.

Silentcore

2013-07-01 14:32:12

From: Kevin
I hope that means it's not too simple ;)

No, I think it actually means i have a better understanding of scripting. I just haven't put my knowledge to a test…lol

Kevin

2013-07-01 14:36:27

From: Silentcore
No, I think it actually means i have a better understanding of scripting. I just haven't put my knowledge to a test…lol


I think you should work on a script and release it. You are quite the community member here! It'd be great to see even more from you ;)

Silentcore

2013-07-01 15:03:43

From: Kevin
I think you should work on a script and release it. You are quite the community member here! It'd be great to see even more from you ;)


Ill get working on a script right away on my spare time..

Edit: ill realease SilentDung, the script i use for fast dung training, lol.;)