SRL Archive - Help and Support

help walking with reflection


Bonfield

2009-06-02 17:36:27

im trying to help senrath with his telegrabber script with the walking, i made a script and was wondering why when the tile is not found the writeln doesnt work, that isnt the actual reason for this thread, i was wondering how i can start the account anywhere on the path and the script will be able to walk th where it needs ie log in halfway to the temple and pickup from where it left off, atm if it gets lost it stays lost

anyways here is what i have so far


program WineTelegrabber;
{.include SRL\SRL\Misc\Smart.scar}
{.include SRL\SRL.scar}
{.include SRL\SRL\Reflection\Reflection.scar}

procedure DeclarePlayers;
begin
HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name := 'name'; //Character Name
Players[0].Pass := 'pass'; //Character Pass
Players[0].Nick := 'nick'; //Nickname 3 - 4 Letter's of char name
Players[0].Integers[0] := 1; //0: to temple 1: to bank
Players[0].Active := True;

end;

function LoadPaths: TPointArray;
begin
case Random(3) of
0: Result := [Point(2945, 3371), Point(2951, 3377), Point(2956, 3381),
Point(2962, 3383), Point(2965, 3390), Point(2965, 3397),
Point(2964, 3404), Point(2961, 3411), Point(2957, 3417),
Point(2952, 3421), Point(2948, 3427), Point(2948, 3434),
Point(2947, 3442), Point(2947, 3450), Point(2944, 3456),
Point(2944, 3465), Point(2944, 3475), Point(2942, 3485),
Point(2943, 3492), Point(2941, 3500), Point(2941, 3507),
Point(2941, 3514), Point(2935, 3516)];

1: Result := [Point(2946, 3371), Point(2953, 3379), Point(2962, 3382),
Point(2966, 3391), Point(2966, 3404), Point(2966, 3411),
Point(2958, 3417), Point(2950, 3423), Point(2948, 3432),
Point(2948, 3440), Point(2947, 3449), Point(2944, 3460),
Point(2944, 3472), Point(2943, 3485), Point(2943, 3493),
Point(2941, 3502), Point(2941, 3512), Point(2935, 3516)];

2: Result := [Point(2944, 3371), Point(2949, 3375), Point(2961, 3380),
Point(2966, 3389), Point(2966, 3403), Point(2965, 3412),
Point(2954, 3419), Point(2949, 3425), Point(2947, 3433),
Point(2947, 3440), Point(2945, 3452), Point(2944, 3464),
Point(2943, 3476), Point(2943, 3487), Point(2942, 3496),
Point(2942, 3505), Point(2940, 3511), Point(2935, 3516)];
end;
end;

function WalkToPathTile(Tile: TPoint; Randomness: Integer): boolean;
var
wTile: TPoint;
t: Integer;
begin
if not LoggedIn then Exit;
Tile.X := RandomRange(Tile.X - Randomness, Tile.X + Randomness);
Tile.Y := RandomRange(Tile.Y - Randomness, Tile.Y + Randomness);
wTile := TileToMM(Tile);
while not TileOnMM(Tile) do
Wait(100 + Random(200));
if not TileOnMM(Tile) then
begin
Result := False;
Writeln('Tile not on MM!');
Exit;
end;
Result := True;
Mouse(wTile.x, wTile.y, 0, 0, true);
t := getsystemtime;
Result := (GetSystemTime - t) < 60000;
end;

function WalkPath(Path: TPointArray; FlagDist: Integer; Reverse:Boolean): boolean;
var
i: integer;
begin
if not LoggedIn then Exit;
if Reverse then InvertTPA(Path);
if not WalkToPathTile(Path[i], 2) then
Exit;
for i := 0 to High(Path) do
begin
if i < High(Path) then
begin
while not TileOnMM(Point(Path[i + 1].x, Path[i + 1].y)) do
Wait(100 + Random(100));
Wait(200 + Random(700));
WalkToPathTile(Path[i + 1], 1);
end
else
FFlag(FlagDist);
Wait(400 + Random(200));
end;
result := true;
end;

function ToTemple: boolean;
begin
if not LoggedIn then Exit;
Result := WalkPath(LoadPaths, 10, False);
if Result then
Writeln('Walked to Temple!');
end;

function ToBank: boolean;
begin
if not LoggedIn then Exit;
Result := WalkPath(LoadPaths, 10, True);
if Result then
Writeln('Walked to Bank!');
end;

procedure SetupSmart;
begin
SmartSetupEx(81, False, True, false);
wait(5000);
SetTargetDC(SmartGetDC);
repeat
wait(100);
until (SmartGetColor(253, 233) <> 1118604);
end;

begin
SetupSmart;
SetupSRL;
DeclarePlayers;
LoginPlayer;
repeat
ToTemple;
//ToBank;
until true;
end.

Richard

2009-06-02 17:45:26

There's been an RS update, you'll need to wait for the new hooks.

Bonfield

2009-06-02 17:47:51

but wouldnt that mean the script wouldnt walk at all?

if i start at the bank it will walk to the and make it walk to the temple it works and its the samr for temple to bank

i want it to be able to start anywhere on the path

Method

2009-06-02 17:50:05

From: Richard
There's been an RS update, you'll need to wait for the new hooks.


My updater just spat out "RuneScape Build #548", so I don't think the game has updated builds.

Metagen

2009-06-02 17:52:41

Clearly you just need to use rsbot

Bonfield

2009-06-02 17:55:07

why would you tell me to use rsbot….. i want to fix this

any actual ideas?

Metagen

2009-06-02 17:57:19

I'm thinking really hard, but my mind keeps coming back to your mom last night…

…

…

Oh!! i have an idea… use rsbot.


Nah im just bored and being a dick, sorry.

Bonfield

2009-06-02 18:02:06

wtf is with the spam…. pretty mature

wow SRL members really has changed alot since i was here last

EDIT: how does using rsbot help me in any remote way if you really have nothing of any benifit to anyone leave

Metagen

2009-06-02 18:16:08

I wrote a function that does what you want… but im not at home..

basically just make a function that returns the closest tile in the array, and then check if that is on mm.

So basically


Tile ClosestTile = tiles[0];
foreach tile t in tiles
if (t is closer than ClosestTile) ClosestTile = t;



Use basic distance formula… i think scar has it built in

Bonfield

2009-06-03 10:44:58

couldnt i just cycle through the tiles in the array and see if any are on the mm then continue walking?

thats what i thought of but have no idea on how to go about doing that

NiCbaZ

2009-06-03 11:25:00

Here il show you mine

[PHP]function WalkToPath(Path: TPointArray): Boolean;
var
I: integer;
Last, II, Dist: Integer;
P: TPoint;
DoTile: Integer;
begin
case random(3) of
1: SetRun(true);
end;
P := GetMyPos;
Last := 1 shl 20;
for II := 0 to High(Path) do
begin
Dist := Distance(P.x, P.y, Path[II].x, Path[II].y);
if (Dist > Last) then Continue;
Last := Dist;
DoTile := II;
end;
if (not(WalkToTile(Path[DoTile], 1, 10))) then
begin
FNR;
WriteLn('Too far from Path to start walking…');
Result:= False;
Exit;
end else
for I := DoTile + 1 to High(Path) do
begin
if not (WalkToTile(Path,1 , 10)) then
begin
Exit;
Result:= False;
end else
begin
Flag;
end;
end;
Result := True;
FNR;
End[/PHP]

based of Zephs :)

Bonfield

2009-06-03 12:08:24

thats what i have i im just not to sure how to have the result be the tile the script starts walking from, i wrote most of that before i read your post

i really confused myself and now im not sure how to use it in my walking procedure

function GetMyPosOnPath(Path: TPointArray): Boolean;
var
ThePath: TPointArray;
I: Integer;
CharPos: TPoint;
begin
CharPos:= GetMyPos;
ThePath:= LoadPaths;
SortTPAFrom(ThePath, Point(CharPos.x, CharPos.y));
for I:= 0 to High(Path) do
if(Path[i].X = ThePath[0].X)and(Path[i].Y = ThePath[0].Y)then
begin
Result:= True;
Exit;
end;
end;

function WalkToPathTile(Tile: TPoint; Randomness: Integer): boolean;
var
wTile: TPoint;
t: Integer;
begin
if not LoggedIn then Exit;
Tile.X := RandomRange(Tile.X - Randomness, Tile.X + Randomness);
Tile.Y := RandomRange(Tile.Y - Randomness, Tile.Y + Randomness);
wTile := TileToMM(Tile);
while not TileOnMM(Tile) do
Wait(100 + Random(200));
if not TileOnMM(Tile) then
begin
Result := False;
Writeln('Tile not on MM!');
Exit;
end;
Result := True;
Mouse(wTile.x, wTile.y, 0, 0, true);
t := getsystemtime;
Result := (GetSystemTime - t) < 60000;
end;

function WalkPath(Path: TPointArray; FlagDist: Integer; Reverse:Boolean): boolean;
var
i: integer;
begin
if not LoggedIn then Exit;
if Reverse then InvertTPA(Path);
if not WalkToPathTile(Path[i], 2) then
Exit;
for i := 0 to High(Path) do
begin
if i < High(Path) then
begin
while not TileOnMM(Point(Path[i + 1].x, Path[i + 1].y)) do
Wait(100 + Random(100));
Wait(200 + Random(700));
WalkToPathTile(Path[i + 1], 1);
end
else
FFlag(FlagDist);
Wait(400 + Random(200));
end;
result := true;
end;

ZephyrsFury

2009-06-03 14:26:24

Here is what I use in all my reflection scripts:


{------------------------------------------------------------------------------]
[ function ClosestTile(Path: TPointArray): Integer; ]
[ by: ZephyrsFury ]
[ Description: Returns the array index of the Point in the TPA closest to us. ]
{------------------------------------------------------------------------------}
function ClosestTile(Path: TPointArray): Integer;
var
Last, II, Dist: Integer;
P: TPoint;
begin
P := GetMyPos;
Last := 1 shl 20;
for II := 0 to High(Path) do
begin
Dist := Distance(P.x, P.y, Path[II].x, Path[II].y);
if (Dist > Last) then Continue;
Last := Dist;
Result := II;
end;
end;

{------------------------------------------------------------------------------]
[ function WalkMyPath(Path: TPointArray; Start, Finish: Integer): Boolean; ]
[ by: ZephyrsFury ]
[ Description: Walks a path using reflection. ]
{------------------------------------------------------------------------------}
function WalkMyPath(Path: TPointArray; Start, Finish: Integer): Boolean;
var
Closest, Nxt, Incr, Att: Integer;
begin
Incr := (Finish - Start)/iAbs(Finish - Start);
Closest := ClosestTile(Path);
if (DistanceFrom(Path[Closest]) > 3) then
if (not(WalkToTile(Path[Closest], 1, 10))) then
begin
WriteLn('Too far from Path to start walking...');
Exit;
end else
FindNormalRandoms;
Att := 0;
while (ClosestTile(Path) <> Finish) do
begin
Nxt := ClosestTile(Path) + Incr;
WriteLn('Walking to Path Index: ' + IntToStr(Nxt) + ' (' + IntToStr(Path[Nxt].x) +', ' + IntToStr(Path[Nxt].y) + ').');
if (not(WalkToTile(Path[Nxt], 1, 10))) then
begin
if (Att > 3) then Break;
Inc(Att);
while (CharacterMoving) do
Wait(100);
FindNormalRandoms;
end else Att := 0;
FindNormalRandoms;
end;
Result := ClosestTile(Path) = Finish;
end;


ClosestTile is similar to what I think you're trying to do with your GetMyPosOnPath function. What my function does is it returns the index of TPoint in the TPointArray thats closest to your current position.

WalkMyPath walks the path from Start to Finish where Start and Finish are the indices of the array. It will also detect the closest tile to the path (using ClosestTile) and start walking from there as long as the path is reachable.

Bonfield

2009-06-03 17:28:27

thank you for actually explaining it a little bit to me, i will have a good look through it and hopefully see where i was going wrong…. how does what i have made so far look? its been ages since i have scripted

also shl, is just shift left isnt it? is it the same as multiplying by 2, but just quicker?

EDIT: i used shl and i couldnt really figure out what it does, like 1 shl 20 is 1048576 i couldnt figure out any mathematical relationship unless it has to do with log or exponentials but i dont really have time to figure it out as im going to bed… i think i remember wizzup saying something about it ages ago but i cant seem to find anything on it