SRL Archive - OutDated Tutorials

The Master Reflection Tutorial - By Zasz


ZaSz

2009-06-16 11:29:17

The Master Reflection Tutorial - By Zasz

Key

Using Reflection. (This post)
NPC's
Your Player
Position Recognition/Walking
Objects + Ground Items


What is Reflection?
- Reflection is Scars way of Reading the clents Variables so we can do much more with scripting. Reflection is similar to RsBots way of reading the client. But unlike RsBot, Reflection Does not Modify the client, and is 100% safe.

Reflection Is used for things like Perfect Walking from City to City, and Perfect NPC and Object finding.

Reflection is indeed easier to use then color. But Goes down for about 6 hours until we can update the hooks required to run it.



Getting Reflection:
I suggest using this thread. As it allows you to get the latest Srl Dev Revision + Dev Reflection Revision, while starting scar. (Signup is Required)

Please Note:
The following sections below are for script devolopers. And do not Pertain to updating scripts (in most cases) for usage.

Setting Up Reflection For Use:
For Including (Taken from widgets "Some Reflection Stuff):
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl/srl/reflection/reflection.scar}


ZaSz

2009-06-16 11:30:19

NPC's
Lets Start Off with NPC variables.

{ type TNPC;
Description: Holds information related to an NPC. }
TNPC = record
Tile, MS, MM: TPoint;
Index, NPCType, Height, Animation, TurnDirection, Combat: Integer;
HPRatio: Integer;
Name: string;
InFight, IsMoving: Boolean;
end;
{ type TNPCEx;
Description: Holds information related to an NPC. }
TNPCEx = record
MS, MM: TPoint;
Tile: TTile;
Index, NPCType, Height, Animation, TurnDirection, Combat: Integer;
HPRatio: Integer;
Name: string;
InFight, IsMoving: Boolean;
end;

What each one holds:
Tile - Tile of the NPC. | Ms - The Converted point of an NPC to the main screen. | MM - The Converted point of an NPC to the MiniMap.
Index - Each individual NPC has a unique Index. (sometimes referred to as an i.d) | NPCType - Returns the NPC type.
Height - NPC's Height from the ground. | TurnDirection - Returns the Turn Direction. | Combat - Returns the NPC's Combat Level
HPRatio - Returns the number of Hitpoints left in the NPC | Name - Returns the NPC's Name. | InFight - Returns if the NPC is currently fighting.
IsMoving - Returns If the NPC is currently moving.

Testing it out:
After you have included reflection and setupsmart. You can test it out yourself.
Make sure you fill out the NPC's Name (doesn't have to full name) Correctly.

const
npcname = 'Chick';
procedure love;
var
NPCC: TNPC;
begin
If((FindNPC(npcname,NPCC))Then
begin
writeln('Tile:'+inttostr(NPCC.tile.x)+','+inttostr(NPCC.tile.y));
writeln('Ms:'+inttostr(NPCC.ms.x)+','+inttostr(NPCC.ms.y));
writeln('mm:'+inttostr(NPCC.mm.x)+','+inttostr(NPCC.mm.y));
writeln('index:'+inttostr(NPCC.index));
writeln('NPCType:'+inttostr(NPCC.NPCType));
writeln('Height:'+inttostr(NPCC.Height));
writeln('Animation:'+inttostr(NPCC.Animation));
writeln('TurnDirection:'+inttostr(NPCC.TurnDirection));
writeln('Combat:'+inttostr(NPCC.Combat));
writeln('HPRatio:'+inttostr(NPCC.HPRatio));
writeln('Name:'+NPCC.Name);
writeln('InFight:'+booltostr(NPCC.Infight));
writeln('IsMoving:'+booltostr(NPCC.IsMoving));
end;
end;

Clicking an NPC:
We want to find our NPC. And our example will be the lumbridge guide.
So lets use FindNPC.
procedure FindGuide;
var
NPCC: TNPC;
begin
If(FindNPC('Lumbridge',NPCC))then
writeln('Found the Guide! woot');
end;

If you remember about the variables above, you should see that it stores all those variables to the variable NPCC. And we want to use those to click on the NPC. So we will use NPCC.Tile to do this.

But we need to know about a little thing called TileToMS.
{*******************************************************************************
function TileToMS(Tile:TPoint; height: integer): TPoint;
By: BenLand100
Description: Converts the tile position tileX,tileY to a mainscreen location
Height is the distance (in px) above the ground
*******************************************************************************}
Which means we just have to put the tile in and a height that we want our point to be.

TileToMS will also assign that to a TPoint, so we need to create a variable to add the TPoint to.

So lets use that to click the NPC!

procedure FindGuide;
var
NPCC: TNPC;
OurPoint: TPoint
begin
If(FindNPC('Lumbridge',NPCC))then
begin
writeln('Found the Guide! woot');
OurPoint := TileToMS(NPCC.Tile, Random(5));
writeln('Attempting to click!');
mouse(OurPoint.x,OurPoint.y,2,2,true);
end;
end;

ZaSz

2009-06-16 11:31:19

Your Player:
Lets Start off with Player Variables.
{ type TMe;
Description: Holds information related to your character. }
TMe = record
Tile, MS: TPoint;
Animation, Speed, LoginIndex: Integer;
HPRatio, Height, Level, Combat: Integer;
Name: string;
InFight: boolean;
Experience, Levels: array[0..23] of Integer;
end;

What Each one holds:
Tile - Returns the Tile you are on. | Ms - Returns the MainScreen Position Point. | Animation - Returns the Animation id the characters doing.
Speed - Returns the Speed of your character | LoginIndex - Returns 10 if logged out, 25 if at loading screen, and 30 if logged in.
HPRatio - Returns the HitPoints you have left. | Height - Returns your height. | Level - Returns your total level. | Combat - Returns your Combat Level.
Name - Returns your Name | InFight - Returns if you are in a fight. | Experience - Returns the experience of a skill in the form of an array.
Levels - Returns the Levels of a skill in the form of an array.

Useful for Skill Index's
{*******************************************************************************
Index Skill Index Skill
0 - Attack 12 - Crafting
1 - Defence 13 - Smithing
2 - Strength 14 - Mining
3 - Hitpoints 15 - Herblore
4 - Range 16 - Agility
5 - Prayer 17 - Theiving
6 - Magic 18 - Slayer
7 - Cooking 19 - Farming
8 - Woodcutting 20 - Runecrafting
9 - Fletching 21 - Hunter
10 - Fishing 22 - Construction
11 - Firemaking 23 - Summoning
*******************************************************************************}

Useful Commands:
GetMe; - Usage would be to assign all the above variables for tme to your character.

We will use it to tell us each of our levels from attack to summoning.

procedure writelevels;
var
playervar : TMe;
I : integer;
begin
PlayerVar := GetMe;
for I := 0 to 23 do
writeln(PlayerVar.Levels[I]);
end;

Testing it out:
Lets see all things about your character TMe can hold.
Procedure WriteAboutMe;
var
me:tme;
begin
me := GetMe;
writeln('Name: '+me.name);
writeln('Tile: '+inttostr(Me.Tile.X)+','+inttostr(Me.Tile.Y));
writeln('Height: '+inttostr(Me.Height));
writeln('MS: '+inttostr(Me.MS.X)+','+inttostr(Me.MS.Y));
writeln('Animation: '+inttostr(me.animation));
writeln('Speed: '+inttostr(me.Speed));
writeln('HPRatio: '+inttostr(Me.HPRatio));
writeln('Level: '+inttostr(Me.Level));
writeln('LoginIndex: '+inttostr(Me.LoginIndex));
writeln('Combat: '+inttostr(Me.Combat));
writeln('InFight: '+booltostr(Me.InFight));
end;

Using Animations:
Animations are useful because they tell whether you are doing something, such as woodcutting or fishing.

When we do something with different objects (such as woodcutting with a rune axe then a steel axe) we are using different animations.

A good way we can find out animations for different things is to use a procedure like this.

//Lets say we just started to chop wood. Lets get the animation we are doing
procedure WriteOurAnimation;
var
Me : Tme;
begin
Me := getme;
writeln('Our animation is: '+inttostr(Me.Animation)); // Look familiar?
end;

Lets say the result from above is from woodcutting with a rune axe. Now we can use that to do antiban and such while we are woodcutting like this.


//Lets say woodcutting with a rune axes animation is 846.
function IsCutting:boolean;
Me : tme;
begin
me := GetMe;
if(Me.Animation=846)then
result := true;
end;

procedure cutwood;
begin
//The Finding Tree Procedure
//Now we want to do anti-ban until we are done cutting. So we will use the while statement.
while IsCutting do
begin
R_FindRandoms;
FindNormalRandoms;
wait(500);
end;
end;

ZaSz

2009-06-16 11:32:19

Position Recognition/Walking:
Now we are getting to the better stuff.

We need to know how to get tiles now right? Well the answer is GetMyPos, which assigns the tile you are on as a TPoint.
A good procedure to write your point to a debug box would be.

procedure writepos;
var
myposition: TPoint;
begin
MyPosition := GetMyPos;
writeln('Our tile is: '+inttostr(MyPosition.x)+','+inttostr(MyPosition.y));
end;

Ok. So lets say you are making a Catherby docks fisher, and you want to make sure you are near the docks, And you just got your point you want from above. Well we should use TileOnMM.

//Lets say the point of the position of where we want to be is 3032,3420
procedure checkposition;
var
atdocks : boolean
begin
if(TileOnMM(3032,3420))then
begin
atdocks := true;
end;
if(atdocks)then
begin
writeln('We are at the docks. We do not have to kill anyone for today');
end else
writeln('Not at docks. Time to let the mob do its thing.');
end;

Checking if in a perimeter:
Pretty much we want to start at the top left of the perimeter and mark the point, then the bottom right and mark the point.
Then we want to check if our point is in the perimeter. Usage:

// lets say 1010,2020 = top left and 3030,4040 = bottom right.
procedure WriteIfInBank;
PlayerPosition : Tpoint;
begin
PlayerPosition := GetMyPos;
if PointInBox(PlayerPosition , IntToBox(1010,2020, 3030,4040)) then
begin
writeln('You are in the bank!');
end;
end;

The Walking:
Walking is good for well, walking. We are going to make a fake death walker.
We should learn about WalkToTile.
WalkToTile will do what it says, walk to the specified tile. An example:

//Lets Say 5555,6666 is a tile in draynor bank.
Procedure WalkInBank;
var
banktile: TPoint;
begin
BankTile := Point(5555,6666)
WalkToTile(BankTile, 2, 1); //2 is the randomness of tiles, 1 is flagd. (I would suggest to keep at 1).
end;

Creating Paths:
Its best to declare them as a result of a function. An example.

function DeathWalkPath:TPointArray;
begin
setlength(result,4); // 4 = (scar counts from 0) (logic is 0, 1, 2, 3)
result[0] := point(0001,1000);
result[1] := point(0002,2000);
result[2] := point(0003,3000);
result[3] := point(0004,4000);
end;

Now Lets make it do a deathwalk.

//Lets say it checked if we were in a perimeter like we did earlier. (and that procedure made a variable called InLumbyCastle.
Procedure DeathWalk;
begin
If(Not(InLumbyCastle))then
exit;
For I := 0 to High(DeathWalkPath) do
Begin
If(WalkToTile(DeathWalkPath[I], 2, 1))Then
R_Flag;
Flag;
R_FindRandoms;
FindNormalRandoms;
Wait(550+Random(300));
end;
end;

Objects:
UID's
UID = Record
objType: Integer;
UID: Long;
End;
Breaking it down:
OBJType - The I.D of an object. Mostly used for Identifying things on screen.
UId - Not sure really.

Useful Functions

GetObjectAt(TileX, TileY: Integer)
Procedure TellObjectAtTile(Tileof:Tpoint);
MyObject: UID;
begin
MyObject := GetObjectAt(Tileof.x,Tileof.y);
writeln('The Objects I.D is: '+inttostr(MyObject.objType));
end;
FindObject(Var Tile: TPoint; objType: Integer) - Declares the tile objects on to a tpoint;

Clicking an Object.


Procedure ClickABankBooth;
Var
BoothTile :TPoint;
begin // Lets pretend the bank booths I.D = 666.
If(FindObject(BoothTile, 666))then
begin
Writeln('Found a Booth, Clicking!');
BoothTile := TileToMS(BoothTile, Random(5));
mouse(BoothTile.x,BoothTile.y,2,2,True);
end;
end;

Ground Objects:
Type
TGroundItem = Record
MS, Tile: TPoint;
ID, StackSize: Integer;
End;

Breaking it Down:
Ms - MainScreen Point. Tile - The tile of the item. Id - The I.D of the Item. StackSize - The StackSize of the item.

Picking Up A Ground Object:

If you don't know a Items Position:

Procedure PickupBones;
var
I : integer;
Items : TGroundItemArray;
ItemPos : TPoint;
begin // Lets say Reg Bones is 536
FindGroundItems(Items,[536],10);
//Your If your position is a certain length away, walk to tile stuff.
//^
for I := 0 to High(Items) do
begin
ItemPos := TileToMs(Items[I].Tile, Random(5));
Mouse(ItemPos.x, ItemPos.y,2,2,false);
wait(500+random(500));
R_ChooseOption('ake Bon');
end;
end;

If you do know a Items Position:

Procedure PickupRespawningRunes;
Var
Items : TPointArray;
TempPoint : TPoint;
PP : Integer;
begin
//Lets say the position of a respawning air rune is 3030,3021.
//Also, lets say 320 is an air rune id.
Items := GetGroundItems(3030,3021);

//Since Its a Tpoint. X = The I.D. Y = The Stack Size

for PP := 0 to High(ItemTempPoint) do
begin
If(Items[PP].x=320)then
begin
writeln('There are: ' +inttostr(Items[PP].y+' Air Runes at point'); // .y = Stack Size Remember?
//Your If certain length away, then walk stuff'
// ^^
TempPoint := TileToMs(Point(3030,3021),random(4));
Mouse(TempPoint.x,TempPoint.y,2,2,false);
wait(500+random(500));
R_ChooseOption('Take Air');
flag;
wait(2000+random(600));
end;
end;
end;


Interfaces:
I like to use them for chat options.

Here's an example of……………………..


More will come later.

Post all suggestions



cycrosism

2009-06-16 11:35:13

Wow, that's a big tut. I'll have to read it all when I get home

ZaSz

2009-06-16 18:55:41

Thank you. I will be adding object finding as well, but not right now.

caused

2009-06-16 19:03:56

Excellent! All the stuff i've been struggling with during the last days ;).

Thank you. I will be adding object finding as well, but not right now.

Yay, i find object finding to be the toughest part.. :).

Da 0wner

2009-06-16 19:08:05

If only vBulletin did not make links open with _blank.

Da 0wner

2009-06-16 19:15:21

I was trying to wikify this, but I phailed. Can you do it yourself :D?

ShowerThoughts

2009-06-16 19:17:59

First one? Niace! :)

Colluci

2009-06-16 19:52:20

Thanks a lot from this. Rep+++

Dynamite

2009-06-16 20:13:00

Im putting on now. (wiki)

T~M

Dynamite

2009-06-16 20:25:34

Ok its up, gonna try and fix the tags
here the link http://www.villavu.com/wiki/index.php/Master_Reflection_Tutorial

T~M

marpis

2009-06-16 20:46:38

i think you should explain the differences between NPC and Object finding.
also tell how to get IDs of things with RSBot.

you should also highlight that reflection is easier to use than colors, and it is a lot better in many ways. the only disadvantage of reflection is it's uptime.

edit: make an example script of a draynor willowcutter and banker, and add a lot of explanations there. it'll be under 200 lines of code

ZaSz

2009-06-16 21:07:22

From: marpis
i think you should explain the differences between NPC and Object finding.
also tell how to get IDs of things with RSBot.

you should also highlight that reflection is easier to use than colors, and it is a lot better in many ways. the only disadvantage of reflection is it's uptime.

edit: make an example script of a draynor willowcutter and banker, and add a lot of explanations there. it'll be under 200 lines of code


Thank you for your suggestions, i we do a few of those things. Dunno about the draynor cutter though.

I just added using animations to the Player section.

davidwang

2009-06-17 21:38:26

I still don't get how to add it to a script =(

Torrent of Flame

2009-06-18 00:23:05

The Man, I have updated said Wiki Article with proper formatting. Welcome your Tutorial to the Wiki Zasz :)

ZaSz

2009-06-23 05:23:14

Thank you! I just added All Object Finding procedures. Someone can add to wiki if wanted.

spicynachos2

2009-06-26 09:24:27

Working with this atm.

The Little

2009-06-26 09:37:46

Hey Zasz,

I love the tutorial, my script is basically based on it :), one thing you might want to add is FindObjectEx(ObjectTile, ObjectID, MaxLength), that will be faster than FindObject if you set the MaxLength as low as possible :).

Naike

2009-06-26 16:06:45

Good going, Add Interfaces(How to obtain them and use them)..
And you could do more advanced stuff ;P

+Rep.

Awkwardsaw

2009-06-30 03:53:59

=o. nice Tut.


but, when i try out finding a NPC, i get a type mismatch

type TQNPC = record
DukeId : integer;
DT : TPoint;
SedridorId : integer;
SedTile : TPoint;
end;

procedure FindDuke;
var
Duke: TQNPC;
DukePoint: TPoint;
begin
If(FindNPC('Duke',Duke))then//error on this line
begin
DukePoint := TileToMS(Duke.DT, Random(5));
mouse(DukePoint.x,DukePoint.y,2,2,true);
flag;
end;
end;

this is my first time playing with reflection :o so bear with me :p

Method

2009-06-30 04:12:11

FindNPC doesn't take a "TQNPC" in its parameters. Use a variable of type TNPC.

mormonman

2009-06-30 05:06:47

Add tile arrays for static object finding. It is the fastest object finding known to reflection.

Awkwardsaw

2009-06-30 06:18:41

From: Method
FindNPC doesn't take a "TQNPC" in its parameters. Use a variable of type TNPC.


and that results in a different error, something to do with DukePoint := TileToMS(Duke.DT, Random(5));

id find out, but i have a script going atm :p

Method

2009-06-30 07:31:03

From: akwardsaw
and that results in a different error, something to do with DukePoint := TileToMS(Duke.DT, Random(5));

id find out, but i have a script going atm :p


Perhaps because there is no "DT" variable in the TNPC record.

Awkwardsaw

2009-06-30 07:32:12

oh, good point :P

The Little

2009-06-30 15:20:29

0.o mess up post? never noticed there was a second page <.<

Coh3n

2009-07-03 05:44:37

<3 it!

This made learning Reflection really easy, can't wait to release our super uber script, eh ian.? ;)

ZaSz

2009-07-25 22:16:22

Anyone wanting some updates?

D1zl3

2009-07-26 01:10:37

From: ZaSz
Anyone wanting some updates?


i decided i was going to make another script, and was going to try reflection, but haven't learned anything about it yet. Good time to update it, if your up to it:D +rep

edit: preferably on walking and failsafes

3Garrett3

2009-07-27 01:25:52

you should make a part on interfaces and such.

Laimonas171

2009-08-03 19:01:31

Ok i am learning reflection .

i trying to know how to use it.


Program x;
{.include srl/srl/misc/smart.scar}
{.include srl/srl.scar}
{.include srl/srl/reflection/reflection.scar}

procedure writelevels;
var
playervar : TMe;
I : integer;
begin
PlayerVar := GetMe;
for I := 0 to 23 do
writeln(PlayerVar.Levels[i]);
end;
begin
writelevels;
end.


I get this output:


-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
-1
Successfully executed


Can anyone explain me what i'm doing wrong.

Sabzi

2009-08-03 19:16:15

Maybe SetupReflection before writelevels?

EDIT: lol I forgot what Method didn't \/. But that's just too common for me. I couldn't help :(

Method

2009-08-03 20:10:38

Laimonas171, you don't even load SMART or log into the game. There's no way that code can get your levels as it currently is.

Laimonas171

2009-08-08 20:37:44

From: Method
Laimonas171, you don't even load SMART or log into the game. There's no way that code can get your levels as it currently is.

oh ty!

3Garrett3

2009-08-26 06:17:49

Update with inventory explination please?

Smarter Child

2009-08-27 05:57:59

From: 3Garrett3
Update with inventory explination please?

Inventory is fairly simple, if you want help that is, pm me.

3Garrett3

2009-08-27 06:19:56

From: Smarter Child
Inventory is fairly simple, if you want help that is, pm me.


I figured it out. Took longer than if there was a tut though.

SCAR 3.21

2009-09-26 20:57:16

ive bookmarked this, and im going to read the rest of it later. from what ive read, its reallly good!

Mofared

2009-12-23 10:38:13

Hi ZaSz,

The link you provided for reflection is not available.I tried some other post that widget provided but failed to install it (it needs a permission to overwrite folder and i can select the accept it as the command over-lopping very fast).

This is very cool man, what is reflection current status? Where can i get the index of places,items, fishing spot, etc… this would make finding thing easier right?

Hope a good reply. Cant wait to write a script in scar again XD

Bionicle

2009-12-23 10:50:45

From: Mofared
Hi ZaSz,

The link you provided for reflection is not available.I tried some other post that widget provided but failed to install it (it needs a permission to overwrite folder and i can select the accept it as the command over-lopping very fast).

This is very cool man, what is reflection current status? Where can i get the index of places,items, fishing spot, etc… this would make finding thing easier right?

Hope a good reply. Cant wait to write a script in scar again XD


Reflection currently is broken, and I think ZaSz quit :( I haven't seen him active in a while.

Mofared

2009-12-23 11:19:28

By broke do you mean its totally useless or just some part of it?
Or is it still possible to use some of the function? Can you kindly help me give the latest file for reflection. Its an include right? thanks again.

Mr. Doctor

2009-12-23 11:23:29

From: Mofared
By broke do you mean its totally useless or just some part of it?
Or is it still possible to use some of the function? Can you kindly help me give the latest file for reflection. Its an include right? thanks again.


It's totally useless. To install reflection, it's in here.

Bionicle

2009-12-23 11:28:13

From: Mofared
By broke do you mean its totally useless or just some part of it?
Or is it still possible to use some of the function? Can you kindly help me give the latest file for reflection. Its an include right? thanks again.


Completely useless. There are those trying to fix it atm, the closest to finished is 75% fixed.

Mofared

2009-12-23 12:34:18

guess ill just have to start with smart then.

rya

2009-12-23 12:47:33

From: Junkj
It's totally useless. To install reflection, it's in here.


If its useless why would anyone want to install it?

Bionicle

2009-12-23 12:48:39

From: rya
If its useless why would anyone want to install it?


'cause they're silly :p

rya

2009-12-23 13:38:45

From: bionicle1800
'cause they're silly :p


:duh:

Diddy Kong

2010-04-10 01:16:20

Reflection is killing my SMART. It closes once it finished loading RuneScape and pops open a new one.

i luffs yeww

2010-04-10 03:40:52

Does it even work? :p

n3ss3s

2010-04-10 06:47:51

From: Diddy Kong
Reflection is killing my SMART. It closes once it finished loading RuneScape and pops open a new one.


I'd say your reflection loads SMART too, even SRL already does it…

trecool999

2010-04-10 07:01:04

Reflection's not even working at the moment… is it?

Bionicle

2010-04-10 11:48:59

From: trecool999
Reflection's not even working at the moment… is it?


Only walking AFAIK
E: Redownload the Place in plugins folder for SRL Rev Dev and replace the Embedded_SMART.dll with the reflection one in the plugins folder. Reflection is broken and the reflection Embedded_SMART.dll will not work afaik.

Timer

2010-04-10 14:22:45

Everything is working. You just need the right svn. :)

Bionicle

2010-04-10 16:31:28

From: Timer
Everything is working. You just need the right svn. :)


Orly?
Can you link me or is it your private reflection >.<

BraK

2010-06-21 10:56:12

This is a very handy tutorial for my first time trying out reflection. Thanks for posting it. But I seemed to come out of it with more questions than before I read it and not an explaination around. The UID bit for object's doesn't work.

sylvawarrior

2010-06-21 12:57:43

Great guide! Currently my computer is in a box 20 hours away. But everyone should be expecting a script from me soon. :)

Drakan

2010-06-22 19:55:54

From: BraK
This is a very handy tutorial for my first time trying out reflection. Thanks for posting it. But I seemed to come out of it with more questions than before I read it and not an explaination around. The UID bit for object's doesn't work.


Maybe because this tutorial is over a year old and has no correlation with the new reflection? I really need to lock some of these threads. Grave digging them will only confuse more people.