SRL Archive - Reflection Help

Learning to use Reflection


Claymore

2008-12-09 20:27:02

Ok i got lots of questions about reflection.


type
TTile = record
x, y: extended;
end;
TTileArray = Array of TTile;

function PointToTile(Tile: TPoint): TTile;
begin
Result.x := Tile.x + 0.0;
Result.y := Tile.y + 0.0;
end;

So if i get a TPoint from the RS screen (E.g. Point(461, 131)) and all it does is add 0.0… I just don't understand this at all.

How do we really get the tile from the MS? I know how to get the on in the MM.


procedure FindMMTile;
var
P0, P: TPoint;
begin
GetMousePos(P.x, P.y);
P0 := MMToTile(P);
WriteLn('MM Tile.x: ' + IntToStr(P0.x));
WriteLn('MM Tile.y: ' + IntToStr(P0.y));
WriteLn('Is in Minimap: ' + BoolToStr(TileOnMM(P0)));
end;

I made a tool for Reflection, i'm to release it later once it has been tested by me.

Here is the rest of my functions.


program ReflectionTool;
{.include SRL/SRL/Misc/Smart.scar}
{.include SRL/SRL.scar}
{.include SRL/SRL/Reflection/Reflection.scar}

const
// Smart set up.
Members = True; // Members world?
World = 107; // What world?
Signed = True; // Use signed? Leave true if confused.
High_Detail = False; // Use high detail?

// Set up controls. It supports FKeys only (E.g. F1, F12).
NPC_Control = 8; // Which FKey to use for NPC's?
Me_Control = 9; // Which FKey to use for your player?
MMTile_Control = 10; // Which FKey to use for MM tiles?
Object_Control = 11; // Which FKey to use for finding UID objects?
Quit_Control = 12; // Which FKey to use for stopping the reflection tool?

procedure FindNPCTool;
var
NPCs: array of TNPC;
h, i: Integer;
begin
NPCs := SortNPCs(GetNPCs);
h := High(NPCs);
for i := 0 to h do
begin
WriteLn('NPC'#39's name: ' + NPCs[i].Name);
WriteLn('Tile.y: ' + IntToStr(NPCs[i].Tile.x));
WriteLn('Tile.x: ' + IntToStr(NPCs[i].Tile.y));
WriteLn('NPC'#39's type: ' + IntToStr(NPCs[i].NPCType));
WriteLn('NPC'#39's height: ' + IntToStr(NPCs[i].Height));
WriteLn('NPC'#39's HP ratio: ' + IntToStr(NPCs[i].HPRatio));
WriteLn('In fight? ' + BoolToStr(NPCs[i].InFight));
WriteLn('Is moving? ' + BoolToStr(NPCs[i].IsMoving));
WriteLn('NPC'#39's animation ID: ' + IntToStr(NPCs[i].Animation));
WriteLn('NPC'#39's turn direction: ' + IntToStr(NPCs[i].TurnDirection));
WriteLn('');
Wait(100);
end;
end;

procedure FindMeTool;
var
PMe: TMe;
begin
PMe := GetMe;
WriteLn('Tile.x: ' + IntToStr(PMe.Tile.y));
WriteLn('Tile.y: ' + IntToStr(PMe.Tile.y));
WriteLn('My height: ' + IntToStr(PMe.Height));
WriteLn('My MS.x: ' + IntToStr(PMe.MS.x));
WriteLn('My MS.y: ' + IntToStr(PMe.MS.y));
WriteLn('My animation ID: ' + IntToStr(PMe.Animation));
WriteLn('My speed: ' + IntToStr(PMe.Speed));
WriteLn('My HP ratio: ' + IntToStr(PMe.HPRatio));
WriteLn('My level: ' + IntToStr(PMe.Level));
WriteLn('My login index: ' + IntToStr(PMe.LoginIndex));
WriteLn('My combat id: ' + IntToStr(PMe.Combat));
WriteLn('My HP ratio: ' + BoolToStr(PMe.InFight));
end;

procedure FindMMTile;
var
P0, P: TPoint;
begin
GetMousePos(P.x, P.y);
P0 := MMToTile(P);
WriteLn('MM Tile.x: ' + IntToStr(P0.x));
WriteLn('MM Tile.y: ' + IntToStr(P0.y));
WriteLn('Is in Minimap: ' + BoolToStr(TileOnMM(P0)));
end;

procedure FindObjectTool;
var
P0, P: TPoint;
IUD: UID;
begin
GetMousePos(P.x, P.y);
P0 := MMToTile(P);
IUD := GetObjectAt(P0.x, P0.y);
WriteLn('objType: ' + IntToStr(IUD.objType));
WriteLn('High: ' + IntToStr(IUD.UID.High));
WriteLn('Low: ' + IntToStr(IUD.UID.Low));
end;

begin
SMARTSetupEx(World, Members, Signed, High_Detail);
SetTargetDC(SmartGetDC);
repeat
wait(150);
until (SmartGetColor(253, 233) <> 1118604);
while not IsFKeyDown(Quit_Control) do
begin
if IsFKeyDown(NPC_Control) then
FindNPCTool;
Wait(100);
if IsFKeyDown(Me_Control) then
FindMeTool;
Wait(100);
if IsFKeyDown(MMTile_Control) then
FindMMTile;
Wait(100);
if IsFKeyDown(Object_Control) then
FindObjectTool;
Wait(100);
end;
WriteLn('Thank you for using Reflection Tool! Good luck on your script.');
end.

Well comment me for any mistakes and things to add. Curretly working on a Catherby Fisher. So i would be glad if you could please HELP me, reflection is so strange.

NiCbaZ

2008-12-09 20:43:05

So if i get a TPoint from the RS screen (E.g. Point(461, 131)) and all it does is add 0.0… I just don't understand this at all.

How do we really get the tile from the MS? I know how to get the on in the MM


Huh??

A Tile is a TPoint, here ill show you

program Moo;
{.include SRL\SRL\Misc\Smart.scar}
{.include SRl/SRl.scar}
{.include srl/srl/reflection/reflection.scar}


var
Tp: Tpoint; // The Tile...

begin
SetupSRL;
Tp:= GetMyPos; // GetMyPos returns a Tpoint;
Writeln('I am at tile '+ IntToStr(Tp.x) ','+ IntToStr(Tp.y)); // Get where you are on the MM.

//Now how about we will make it walk 5 Tiles Farward from where we are??

WalkToTile(Point(Tp.x + 5,Tp.Y,2,2);
end.




Claymore

2008-12-09 20:45:30

Oh, so if does it get the tile from the MM or from the MS?

Method

2008-12-09 21:06:43

From: Deathscytex
Oh, so if does it get the tile from the MM or from the MS?


Tiles are global - not just on the main screen or minimap. If you want to walk to a tile, the tile will be converted to minimap coordinates for you to walk to. If you want to click an object on the main screen, the tile will be converted into main screen coordinates so you can click on them.

Claymore

2008-12-09 21:23:36

Oh so functions alredy convert the TPoint to a MM Point or a MS Point. E.g. Clicking on Bank booths, WalkToTile.

NiCbaZ

2008-12-09 22:27:39

P:= Point(234,342);

TileToMS(p);

That what you would use to convert a tile to a MainScreen.

Claymore

2008-12-09 22:54:05

cool thanks nicbaz.

Btw, when i ran my script and ttested the functions, it gave me this.


objType: 0
High: 0
Low: 0
MM Tile.x: 33554430
MM Tile.y: 33554430
objType: 0
High: 0
Low: 0
MM Tile.x: 33554430
MM Tile.y: 33554430
Tile.x: 33554430
Tile.y: 33554430
My height: 1
My MS.x: 0
My MS.y: 0
My animation ID: -1
My speed: -1
My HP ratio: 0
My level: -1
My login index: -1
My combat id: -1
Is in fight? False

All the time. Smart isn't working properly =(

Method

2008-12-09 22:55:12

Make sure your hooks are updated also (though yes, SMART doesn't like working very much either).

Claymore

2008-12-09 23:14:01

How do i updated Hooks? Through Sub or SRL's?

Method

2008-12-10 00:15:23

The SRL repository doesn't have reflection in it. You can either use an SVN client like TortoiseSVN or you could use something like Widget's reflection downloader to get the latest files.