SRL Archive - OSR Help

Walking Help


Bad Boy JH

2010-06-01 23:09:52

Right, This walking procedure Keeps stuffing up…


function LoadPath: TPointArray;
begin
SetLength(Result, 8);

Result[0] := Point(2845, 3140);
Result[1] := Point(2856, 3147);
Result[2] := Point(2867, 3153);
Result[3] := Point(2877, 3159);
Result[4] := Point(2889, 3164);
Result[5] := Point(2899, 3169);
Result[6] := Point(2911, 3172);
Result[7] := Point(2921, 3177);
end;

Function WalkTo(ToStiles:Boolean):Boolean;
var
I, Mark:integer;
TPA:TPointArray;
begin
TPA := LoadPath;
if ToStiles then
InvertTPA(TPA);
for i := 1 to high(TPA) do
begin
MarkTime(Mark);
while (TimeFromMark(Mark) <= 10000) do
begin
if TileOnMM(PointToTile(TPA[i])) then Break;
Wait(250);
end;
Wait(RandomRange(500, 1000));
if not WalkToTile(PointToTile(TPA[i]), 2, 2) then Exit;
end;
Result := True;
end;

This is in Karamja, if the WalkTo Variable (ToStiles) is True, It walks from the fishing Dock to Stiles, if false, it walks from stiles, back to the dock. However, it keeps stuffing up and stopping half way.

bbri06

2010-06-01 23:31:23

First off, you should use R_FFlag(); or FFlag();. Second, you should put a loop inside your loop that will check if the tile is on the map a few times; if the tile is not there make it wait a little before the next loop through.
For instance:

for i:= 0 to High(Tiles) do
begin
for z := 0 to 10 do
begin
if(TileOnMM(Tile[i]))then
Break
else
Wait(500 + random(250));
if(z = 10)then
begin
Writeln('Couldnt find path tile');//
Result := False;// These parts can be replaced with something that tries to fix the problem then tries to pathwalk again.
Exit;//
end;
end;
ThePoint := TileToMM(Tiles[i]);
Mouse(ThePoint.x, ThePoint.y, 3, 3, true);
R_FFlag(10);

Something like that should help. I'll probably add some more to this post in a bit.

Bad Boy JH

2010-06-02 05:51:54

Is there A Statement Like Break, that doesn't break out of the loop, but goes to the begining again, IE.


begin
for I := 1 to 20 do
begin
if I := 10 then *Something*;
Writeln(IntToStr(I));
end;
end.

And It would output
1
2
3
4
5
6
7
8
9
11
12
13
14
15
16
17
18
19
20

Coh3n

2010-06-02 06:11:41

From: Bad Boy JH
Is there A Statement Like Break, that doesn't break out of the loop, but goes to the begining again, IE.

Continue;


var
i: Integer;
begin
for I := 1 to 20 do
begin
if (i = 10) then
Continue;
Writeln(IntToStr(I));
end;
end.

Bad Boy JH

2010-06-02 06:33:19

I was shortening (by a lot) the disance in the steps, and I was going to add a
If TileOnMM(PointToTile(TPA[i+1])) then 
Continue;

good idea?

Coh3n

2010-06-02 17:34:10

Yeah good idea, but it would be more efficient by doing something like this:

var
i: Integer;
begin
repeat
for i := High(TPA) downto 0 do
if (TileOnMM(PointToTile(TPA[i]))) then
begin
//move and click mouse + whatever else you want to do
end;
until(GetMyPos = InBox()); //not sure if GetMyPos is the right function or not, and you'd have to gets the tiles for a box around the end location
end.
That way it will start with the last point in the path and walk to it if it's on the minimap.

Bad Boy JH

2010-06-03 02:10:10

you know, thats brilliant, that way It can start at any point on that route…

Coh3n

2010-06-03 06:09:36

From: Bad Boy JH
you know, thats brilliant, that way It can start at any point on that route…

Exactly. ;)