SRL Archive - Reflection Tutorials

How-To-Make a simple Reflection Walker - 0wn 4 skill


0wn 4 skill

2008-08-14 15:06:40

Reflection Walking!!



Ever wanted to make a easy and nearly flawless walker? Well, this is where you will find out how.

I have written this guide assuming that you have a basic knowledge of Scar, Srl and Reflection. I have made it fairly noob friendly.


What your going to need:
  • Srl Rev#20
  • Reflection Rev#72
  • Summilions PathMaker - which can be found > here <

Firstly you are going to need to include reflection into your script. You do this by writing below the program name. If you have made scripts previously using the include SRL then you will be very familiar with this process.
Once you have done that it should look like this:

Program SimpleReflectionWalkerEx;       // The Name of your program
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}
// The above shows how i included reflection

Begin// This is your Mainloop
SetupSRL;// This Sets up the SRL include in your script.
end.

And without the notes it looks like this:

program SimpleReflectionWalkerEx;
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}

Begin
SetupSRL;
end.


Okay, now that you have included it you can start using all those juicy procedures and functions that have been made by the creators of Reflection.

Now then, for reflection to work you need to use a procedure to open S.M.A.R.T . Reflection works by finding variables within smart and using them to do things.

Now to open smart you need to use a procedure which looks like this:

Procedure SetupSmart;
Begin
SmartSetup('world84', True, True, False);//Change the number in 'world84'
Wait(1000); //to whichever world you want.
SetTargetDC(SmartGetDC);
end;

So now your script should look something like this:

program SimpleReflectionWalkerEx;
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}

Procedure SetupSmart;
Begin
SmartSetup('world167', True, True, False);
Wait(1000);
SetTargetDC(SmartGetDC);
end;

Begin
SetupSRL;
SetupSmart; // Calls the SetupSmart procedure.
end.

Remember, if you want to call a procedure in the main loop you cant call it after the mainloop. The mainloop always stays at the end.

Next you will want to declare your player.

The easiest way to do this is by adding this. (Just copy and paste)

Procedure DeclarePlayers;
Begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :=''; //Your Username
Players[0].Pass :=''; // Your password
Players[0].Nick :=''; //3-4 letters of your username.
Players[0].Active:=True;

end;

So now your script is starting to get bigger! It doesnt get much harder than this.

program SimpleReflectionWalkerEx;
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}

Procedure SetupSmart;
Begin
SmartSetup('world167', True, True, False);
Wait(1000);
SetTargetDC(SmartGetDC);
end;

Procedure DeclarePlayers;
Begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;

end;

Begin
SetupSRL;
SetupSmart;
DeclarePlayers;//Calls the DeclarePlayers procedure
LoginPlayer;// This will log your player in.
end.


Now, open up your PathMaker - Reflection tool. (Link at top) Then make a Path, if you get any orange paths, it wont work. You should end up with something like this:

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

Result[0] := Point(3213, 3428);
Result[1] := Point(3200, 3428);
Result[2] := Point(3189, 3429);
Result[3] := Point(3175, 3427);
Result[4] := Point(3164, 3422);
Result[5] := Point(3153, 3416);
Result[6] := Point(3139, 3416);
Result[7] := Point(3126, 3414);
Result[8] := Point(3116, 3419);
Result[9] := Point(3105, 3420);
Result[10] := Point(3090, 3420);
Result[11] := Point(3082, 3422);
end;

Mine walks from Varrock centre to Barbarian Village.
Just copy this into your script. As long as its above the mainloop it will be fine. You are almost finished your simple walker.

So now your script will look like this:

program SimpleReflectionWalkerEx;
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}

Procedure SetupSmart;
Begin
SmartSetup('world167', True, True, False);
Wait(1000);
SetTargetDC(SmartGetDC);
end;

Procedure DeclarePlayers;
Begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;

end;

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

Result[0] := Point(3213, 3428);
Result[1] := Point(3200, 3428);
Result[2] := Point(3189, 3429);
Result[3] := Point(3175, 3427);
Result[4] := Point(3164, 3422);
Result[5] := Point(3153, 3416);
Result[6] := Point(3139, 3416);
Result[7] := Point(3126, 3414);
Result[8] := Point(3116, 3419);
Result[9] := Point(3105, 3420);
Result[10] := Point(3090, 3420);
Result[11] := Point(3082, 3422);
end;

Begin
SetupSRL;
SetupSmart;
DeclarePlayers;//Calls the DeclarePlayers procedure
LoginPlayer;// This will log your player in.
end.

Now, this is complicated bit (Due to Update of Rev and deletion of WalkPath)

Procedure WalkThePath;
Var
I: Integer;
Path: TPointArray;

Begin
Path := LoadPath;
for i := 0 to High(Path) do
Begin
WalkToTile(Path[i], 3, 0);
end;
Wait(500+Random(300));
end;

This walks the path in the array which you made in LoadPath procedure.

Path:=  LoadPath;
Declares LoadPath as a TPointArray.

  for i := 0 to High(Path) do
Begin
WalkToTile(Path[i], 3, 0);
end;
Wait(500+Random(300));

Repeats until all the arrays are used.



Now your script should be complete and look something like this:

program SimpleReflectionWalkerEx;
{.Include SRL\SRL\Misc\Smart.Scar}
{.Include SRL\SRL.Scar}
{.Include SRL\SRL\Reflection\Reflection.Scar}

Procedure SetupSmart;
Begin
SmartSetup('world167', True, True, False);
Wait(1000);
SetTargetDC(SmartGetDC);
end;

Procedure DeclarePlayers;
Begin

HowManyPlayers := 1;
NumberOfPlayers(HowManyPlayers);
CurrentPlayer := 0;

Players[0].Name :='';
Players[0].Pass :='';
Players[0].Nick :='';
Players[0].Active:=True;

end;

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

Result[0] := Point(3213, 3428);
Result[1] := Point(3200, 3428);
Result[2] := Point(3189, 3429);
Result[3] := Point(3175, 3427);
Result[4] := Point(3164, 3422);
Result[5] := Point(3153, 3416);
Result[6] := Point(3139, 3416);
Result[7] := Point(3126, 3414);
Result[8] := Point(3116, 3419);
Result[9] := Point(3105, 3420);
Result[10] := Point(3090, 3420);
Result[11] := Point(3082, 3422);
end;

Procedure WalkThePath;
Var
I: Integer;
Path: TPointArray;

Begin
Path := LoadPath;
for i := 0 to High(Path) do
Begin
WalkToTile(Path[i], 3, 0);
end;
Wait(500+Random(300));
end;

Begin
SetupSRL;
SetupSmart;
DeclarePlayers;//Calls the DeclarePlayers procedure
LoginPlayer;// This will log your player in.
WalkThePath;
Logout; //This will log your player out!
end.

The End.

Any questions? Add me on msn [email]Bonf@live.co.uk[/email]

Enjoy!! :D

dallas574

2008-08-14 15:17:23

nice tut thanks

Timer

2008-08-14 15:17:38

Meh… Wheres the PathWalk Function?! :p

Whos pathwalk function is it..?

0wn 4 skill

2008-08-14 15:19:38

@Dallas574 - Thankyou for the reply. It means alot.

@Timer -Dowload Rev#71 Reflection. All shall become clear.

Keep the comments coming!!

Timer

2008-08-14 15:26:57

I know… I was kidding because I removed them in a new reversion… Reversion 72 please… Im a SRL Reflection Developer if you didn't know… :rolleyes:

:p

0wn 4 skill

2008-08-14 15:27:55

You removed?! But that was a good update.

Please alaborate why you removed?

Timer

2008-08-14 15:29:11

So..? Were not going to have pathwalk functions in Walking.scar… xD

People can make there own…

0wn 4 skill

2008-08-14 15:31:27

Dam :( I really liked that one.

Harry

2008-08-14 15:31:55

From: Timer
I know… I was kidding because I removed them in a new reversion… Reversion 72 please… Im a SRL Developer and Manager if you didn't know… :rolleyes:

:p


You aren't a Dev..

From: Timer
So..? Were not going to have pathwalk functions in Walking.scar… xD

People can make there own…


So you want to make reflection coding harder..? Why? The whole idea behind reflection is to make it easier for newbies, and easier to make bigger projects. By removing it, you are just making Reflection harder to use, and more and more obsolete.

0wn 4 skill

2008-08-14 15:41:45

Updated to Rev#72 Reflection.

From: Hy71194

So you want to make reflection coding harder..? Why? The whole idea behind reflection is to make it easier for newbies, and easier to make bigger projects. By removing it, you are just making Reflection harder to use, and more and more obsolete.


I agree Hy. Put it back!! Plz :D

Wizzup?

2008-08-14 15:49:45

From: Hy71194
So you want to make reflection coding harder..? Why? The whole idea behind reflection is to make it easier for newbies, and easier to make bigger projects. By removing it, you are just making Reflection harder to use, and more and more obsolete.


The idea was never to make it easier for noobies, the idea was to make bigger projects, but it should still require skill.

Widget

2008-08-14 15:50:04

From: Timer
I know… I was kidding because I removed them in a new reversion… Reversion 72 please… Im a SRL Developer and Manager if you didn't know… :rolleyes:

:p

Just because you created the subversion account doesn't mean you're a manger, and you sure as hell aren't an SRL Developer.


From: Hy71194
You aren't a Dev..



So you want to make reflection coding harder..? Why? The whole idea behind reflection is to make it easier for newbies, and easier to make bigger projects. By removing it, you are just making Reflection harder to use, and more and more obsolete.

I actually was flamed by Wizzup? regarding this. Our (SRL's) view on reflection is that it's supposed to make scripts more efficient and reliable, not easier or 4 lines long like RSBot/Nexus scripts. Ideally, every reflection function used in a script will have full color backup (DDTMs, RadialWalking, TPAs, etc).

Here we are:
[BANANA](2:48:48 PM) Wizzup: OwnForSkill
(2:48:52 PM) Wizzup: Reflection should not be simple
(2:49:00 PM) OwnForSkill: Why?
(2:49:16 PM) Wizzup: For the same reasons we actually did not want to release it[/BANANA]


(Nice tut btw ;))

0wn 4 skill

2008-08-14 15:58:31

Well, that settles that then.
@Widget, Wizzup? - Thanx for explaining.

Rubix

2008-08-14 17:36:25

:O no more walkpath function :S and of course, i just updated my reflection so i lost it :S :S

0wn 4 skill

2008-08-14 17:51:24

If u want it then just put this near the top of ure script:
Function PathWalk(Path : array of TPoint; Tol, FlagD : integer): Boolean;
var
Count : integer;
begin
Count := 0;
repeat
Result := WalkToTile(Path[Count], Tol, FlagD);
if not(Result) then
begin
WriteLn('Path walk failed');
Exit;
end;
Count := Count + 1;
until (not(Result)) or (Count = GetArrayLength(Path))
end;

Just forget about the boolean from before.

Timer

2008-08-14 17:57:08

From: Hy71194
You aren't a Dev..



So you want to make reflection coding harder..? Why? The whole idea behind reflection is to make it easier for newbies, and easier to make bigger projects. By removing it, you are just making Reflection harder to use, and more and more obsolete.


Opps mis type… Fixz0red… xDDD

0wn 4 skill

2008-08-15 17:27:22

Updated. Fixed a little error.

Timer

2008-08-15 18:29:41

You can use my walking functions in your tut if you want! :p

{-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
function WalkToTile2(TileX, TileY: Integer): Boolean;
By: Timer
Description: Walks to the tile using minimap.
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-}
function WalkToTile2(TileX, TileY, Rx, Ry: Integer): Boolean;
var
Tw: TPoint;
begin
Tw:= TiletoMM(Point(Tilex, Tiley));
if(not InCircle(Tw.x, Tw.y, MMCX, MMCY, 74))then
begin
Writeln('Tile off minimap!');
Result:= False;
Exit;
end;
Mouse(Tw.x, Tw.y, Rx, Rx, True);
Result:= True;
end;

{-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
function GetMyPosOnPath(aVar: Integer; Path: TPointArray): Boolean;
By: Timer
Description: Finds your character on a specified path. Results True if Sucsess.
aVar is the tile in array;
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-}
function GetMyPosOnPath(aVar: Integer; Path: TPointArray): Boolean;
var
aPath: TPointArray;
I: Integer;
PosG: TPoint;
begin
PosG:= GetMyPos;
aPath:= Path;
SortTPAFrom(aPath, Point(PosG.x, PosG.y));
if(not TileOnMM(Point(aPath[0].X, aPath[0].Y)))then
Exit;
for I:= 0 to High(Path) do
if(Path[i].X = aPath[0].X)and(Path[i].Y = aPath[0].Y)then
begin
aVar:= I;
Result:= True;
Exit;
end;
end;

{-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-
function PathWalk(Path: TPointArray): Boolean;
By: Timer
Description: Walks The Path, if Lost, Finds Character, and Reverts to A
R_FFlag(0); Instead of R_FFlag(8); RandomizesTiles.
-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-~-}
function PathWalk(Path: TPointArray): Boolean;
var
I, I2: Integer;
begin
for I:= 0 to High(Path) do
if(not WalkToTile2(Path[i].X + (Random(3) - Random(3)), Path[i].Y + (Random(3) - Random(3)), (Random(3) - Random(3)), (Random(3) - Random(3))))then
begin
Result:= False;
Break;
end else
begin
R_FFlag(8);
FindNormalRandoms;
Result:= True;
end;
if(Result)then
Exit;
if(GetMyPosOnPath(I2, Path))then
begin
for I:= I2 to High(Path) do
if(not WalkToTile2(Path[i].X + (Random(3) - Random(3)), Path[i].Y + (Random(3) - Random(3)), 3, 3))then
begin
Result:= False;
Exit;
end else
begin
R_FFlag(0);
FindNormalRandoms;
Result:= True;
end;
end;
end;

0wn 4 skill

2008-08-15 18:58:41

@ Timer, This is a tut for people only beggining setting out on their reflection carrer. However i love these functions, may i use these in my script?

Timer

2008-08-15 20:11:49

Sure! :)

Smarter Child

2008-08-22 17:54:14

how did you get the walking points?

Function LoadPath: TPointArray;
begin
SetLength(Result, 12);

Result[0] := Point(3213, 3428);
Result[1] := Point(3200, 3428);
Result[2] := Point(3189, 3429);
Result[3] := Point(3175, 3427);
Result[4] := Point(3164, 3422);
Result[5] := Point(3153, 3416);
Result[6] := Point(3139, 3416);
Result[7] := Point(3126, 3414);
Result[8] := Point(3116, 3419);
Result[9] := Point(3105, 3420);
Result[10] := Point(3090, 3420);
Result[11] := Point(3082, 3422);
end;

0wn 4 skill

2008-08-23 18:05:34

Using summilions pathmaker. Check the top of the 1st post.

Smarter Child

2008-08-26 09:41:13

From: 0wn 4 skill
Using summilions pathmaker. Check the top of the 1st post.


Oh yeah and all how the hell do u do webwalk lol i don't get webwalk and all that isn't Scar only based with color,dtm,bitmaps?

Heavenzeyez1

2008-08-26 09:59:17

This is really good , thanks , things are getting easier than i thought , but i will still make tons of failsaves , just to make sure i'm not losing some skills .. :)
~Eerik~

0wn 4 skill

2008-08-29 05:06:55

Lol. People are starting to move on. Reflection is really good! Thanx for the comment.

Heavenzeyez1

2008-08-29 05:40:20

Yeah , i just finished my first reflection script , it really helped a lot . :)
~Eerik~

Seroko

2008-08-29 16:23:00

Nice tut, set me straight on starting to add in Reflection to my scripts

0wn 4 skill

2008-09-01 19:44:33

Wooot :D Im gonna make something without reflection now… Hmmmmmmz

leather sock

2008-09-03 21:26:31

Your Script doesn't compile with latest rev. of reflection

SubiN

2008-09-12 04:53:12

great tut thanx.

0wn 4 skill

2008-11-02 14:16:19

Glad to see everyone getting stuck in! :D

Goodluck ppl! :D:D

Melon

2008-12-13 10:31:05

why i get this whn i compile

Line 85: [Error] (87:187): Invalid number of parameters in script C:\Program Files\SCAR 3.15\includes\SRL\SRL\Misc\Smart.Scar

edit : soz didnt update

?

pk ownage94

2008-12-27 12:12:21

Thanks for the tutorial you helped me make my first decent script!!!

YAY!

randy marsh

2009-01-08 20:34:54

Line 8: [Error] (19786:42): Invalid number of parameters in script

chitin

2009-01-11 22:52:51

wait so does or doesnt this work? i read a few post and i though i saw somthing about removing "wallkthepath" function becuase it made it "too" easy….which is pretty lame because wdf…that was the idea?

NCDS

2009-01-13 02:48:09

From: chitin
… i read a few post and i though i saw somthing about removing "wallkthepath" function becuase it made it "too" easy….which is pretty lame because wdf…that was the idea?


Read the first page, it covers all that better.

Nice TUT Own 4 Skill, you have inspired me to try Reflection lol

leuquim

2009-04-10 14:44:13

So, if i want to use the old Function you were using in tut, where do i need to put the PathWalk function, in script or in reflection's walk file?
I've tried both and none worked :/.

Great tut btw, nice nd easy to follow ^^.

leuquim

2009-04-19 00:04:44

Damn theese forums are inactive -.-.

Awkwardsaw

2009-05-26 03:02:34

thanks dude :D i made a simple lumby-draynor walker, works like a charm :)

nice tut

Cartmann

2009-09-14 22:43:22

Is this still the prefered metode for walking in Reflection?

Smarter Child

2009-09-15 01:59:51

From: Cartmann
Is this still the prefered metode for walking in Reflection?


You can use this method of walking, although I think Reflection's getflag is broken. So you'll probably have to edit it, and do some other stuff with it. I don't know if your smart enough to make a really good reflection walking function, well I know I ain't :p, unless I like really tried lol.

rogeruk

2009-09-15 02:43:54

Yes you can still use it for walking (once reflection is updated)




Function PathToTan: TPointArray;
Begin
SetLength(Result, 3);

Result[0] := Point(3277, 3175);
Result[1] := Point(3282, 3185);
Result[2] := Point(3274, 3193);
End;

Procedure ToTan;
Var
I: Integer;
Path: TPointArray;
Begin
If Not LoggedIn Then Exit;
Path := PathToTan;
For i := 0 To High(Path) Do
Begin
If Not LoggedIn Then Exit;
RunEnergy(30);
WalkToTile(Path[i], 0, 3);
Wait(RandomRange(100, 200));
R_FFlag(3);
If (i = High(Path)) Then Break;
End;
End;

Then you just call ToTan;