SRL Archive - Help and Support

Reflection walking path problem...


Coh3n

2009-07-06 23:19:51

So I've got this walk path, and it executes the script after it walks to the 3rd point, sometimes the 4th.

Also, since I posted, the function Dray_AreWeHere; doesn't work either, and I don't know why. And yes, I've checked 100x that the boxes are correct.

I've tried:
  • Redoing the path… multiple times.
  • Commenting out parts, to see if that was the problem.

Here's the script:
program Script;
{.include SRL\SRL\misc\SMART.SCAR}
{.include SRL\SRL.scar}
{.include SRL\SRL\Reflection\Reflection.Scar}

const
SMARTWorld = 152;
Members = False;//I'm using this for some testing, I left the user/pass of your acc at home. XD

procedure S_Signature;
begin
end;

function Dray_AreWeThere: Boolean;//Doesn't work.
var
MPos : TPoint;
begin
MPos := GetMyPos;
if PointInBox(MPos, IntToBox(3103, 3250, 3105, 3248)) then//Tele loc using Glory.
begin
Writeln('We are in Draynor!');
Result := True;
end else
if PointInBox(MPos, IntToBox(3049, 3298, 3061, 3285)) then//Tele loc to cabbage patch.
begin
Writeln('We are in cabbage patch!');
Result := True;
end else
begin
Writeln('We are neither in cabbage patch nor Draynor.');
Result := False;
end;
end;

function Dray_WalkPath: TPointArray;//This is the problem path.
begin
SetArrayLength(Result, 7);
Result := [Point(3094, 3248), Point(3080, 3251), Point(3072, 3262),
Point(3072, 3275), Point(3063, 3279), {Climb Stile here}
Point(3053, 3295), {Open Gate here} Point(3056, 3308)];
end;

procedure Dray_ClimbStile;
var
Stile : TPoint;
begin
if not LoggedIn then Exit;
MakeCompass('N');
if FindObject(Stile, 7527) then
begin
Writeln('Found stile, attempting to climb...');
Stile := TileToMS(Stile, Random(5));
MMouse(Stile.x, Stile.y - 20, 4, 4);
if WaitUpTextMulti(['Stile', 'Climb', 'Over', 'Climb-over'], Random(500)) then
case Random(2) of
0: begin
Wait(80 + Random(500));
Mouse(Stile.x, Stile.y - 20, 4, 4, True);
Writeln('Climed over stile!');
end;
1: begin
Wait(80 + Random(500));
Mouse(Stile.x, Stile.y - 20, 4, 4, False);
R_ChooseActionMulti(['Climb-over']);
Writeln('Climed over stile!');
end;
else
Writeln('Couldn''t climb over stile.');
end;
end else Exit;
end;

procedure Dray_OpenGate;
var
Gate : TPoint;
begin
if not LoggedIn then Exit;
MakeCompass('N');
if FindObject(Gate, 7050) then
begin
Writeln('Found gate, attempting to open...');
Gate := TileToMS(Gate, Random(5));
MMouse(Gate.x, Gate.y - 20, 4, 4);
if WaitUpTextMulti(['pen', 'ate'], Random(500)) then
case Random(2) of
0: begin
Wait(80 + Random(500));
Mouse(Gate.x, Gate.y - 20, 4, 4, True);
Writeln('Opened gate!');
end;
1: begin
Wait(80 + Random(500));
Mouse(Gate.x, Gate.y - 20, 4, 4, False);
R_ChooseActionMulti(['Open']);
Writeln('Opened gate!');
end;
else
Writeln('Couldn''t open gate.');
end;
end else Exit;
end;

procedure Dray_ToPatch;//Here is the walking procedure.
var
Tries, i, p : Integer;
Path : TPointArray;
begin
if not LoggedIn then Exit;
Path := Dray_WalkPath;
RunEnergy(50);
Writeln('Heading to Draynor patch.');
for i := 0 to High(Path) do
begin
if WalkToTile(Path[i], 2, 1) then
begin
case i of
4: begin
R_FFlag(0);
Inc(Tries);
repeat
Dray_ClimbStile;
until((i = 5)or(Tries >= 20));
end;
5: begin
R_FFlag(0);
Inc(Tries);
repeat
Dray_OpenGate;
until((i = 6)or(Tries >= 20));
end;
end;
R_FFlag(5);
R_FindRandoms;
end;
end;
end;
{ I still think this procedure can be simplified, and it stops half way through
the walk path. :confused: Can't figure it out. }

procedure Prg_ProgReport;
begin
end;

procedure F_ScriptSetup;
begin
ClearDebug;
S_Signature;
Smart_Server := SMARTWorld;
Smart_Members := Members;
Smart_Signed := True;
Smart_SuperDetail := False;
Writeln('Loading, please wait...');
SetupSRL;
end;

procedure F_MainLoop;
begin
F_ScriptSetup;
Dray_ToPatch;
end;

procedure ScriptTerminate;
begin
Prg_ProgReport;
end;

begin
F_Mainloop;
end.

I'm sure it's something small and obvious, like most of my problems, but I just can't see it.

Thanks. :D

Home

2009-07-06 23:30:03

Are your Tiles correct ( In Path And in Other Function ) ?

~Home

Coh3n

2009-07-06 23:32:07

From: Home
Are your Tiles correct ( In Path And in Other Function ) ?

~Home


Yes, I've checked/redone them close to 10 times.

Nava2

2009-07-07 00:26:08

The boxes are wrong.

y2 > y1.

Found it.

You never increase the Tries variable in your loops. Also, no point having the until i=? because I wont increase in there.

E: you never break your loop, because even if it opens the stile, it still wont break. It will just keep trying.

Coh3n

2009-07-07 02:28:15

From: Nava2
The boxes are wrong.

y2 > y1. You mean x2 > x1? And I made the boxes from Top Left to Bottom Right, is that wrong?

Found it.

You never increase the Tries variable in your loops. Also, no point having the until i=? because I wont increase in there. The idea there was to try to climb the stile until you could walk to the other point, but you're right, I didn't think about that.

E: you never break your loop, because even if it opens the stile, it still wont break. It will just keep trying. Yes, thanks. :)


Comments in Red, thanks Nava. :D

EDIT: I don't think the Tries thing will fix the walking, because even if I take that whole loop out, it still stops after it reaches the 3rd or 4th point.