SRL Archive - Reflection Tutorials

Client Hacking


n3ss3s

2008-11-08 03:02:41

Reflection seemed a bit bare as the title so… ffs I'm crap at writing tutorials, they never end up as mighty and huge as I thought :(



Hooks

"Hooks", are field paths, which bots use to get information from the client.

Example, SmartGetFieldInt(0, 'me.h'). That would get the h -integer of the me -class.

People use "Updaters" to get the hooks their want, if you want to know more about those you should try searching at mopar…



SMART Functions

SmartGetFieldInt(Parent, Path) returns either the integer in the client in the Parent class, something like SmartGetFieldInt(GetPlayer, HP) for example.

Or, the integer in the client in the Path.


SmartGetFieldBoolean(Parent, Path) is the same as above, except it returns a boolean.


SmartGetFieldObject(Parent, Path), this is nice. This can return umm… Entire classes? I don't know how to say it correctly…

Object finding, for example, uses this.

        obj := SmartGetFieldObject(Z, getObj[I]);
//WriteLn('Object is '+inttostr(obj)+' on getObject1 in '+inttostr(Q)+' ground layer');
If obj <> 0 Then
Begin
Result.UID.High := SmartGetFieldLongH(obj, getUIDs[I]);
Result.UID.Low := SmartGetFieldLongL(obj, getUIDs[I]);
Result.objType := GetObjectType(Result.UID);
SmartFreeObject(obj);
//SmartFreeObject(Z); // Causes scar to crash
Exit;
End;


There are all kinds of handy uses for these "Objects", for example, we can retrieve strings from them!

First, we do A := SmartGetFieldObject(Obj, StringBytes), and then StringFromBytes(A), we have just retrieved a string from the client :)



All of these functions have their 2D and 3D functions, some examples of their usages…

  BsX := SmartGetFieldInt(0, BaseX);
BsY := SmartGetFieldInt(0, BaseY);
Plane := SmartGetFieldInt(0, BaseLayer);
NodeList := SmartGetFieldArray3DObject(0, getNodeListArray, Plane, TileX - BsX, TileY - BsY);


And ofcourse my function for seeing if a tile is walkable ;)

Function IsWalkable(X, Y: Integer): Boolean;

Var
GroundData, BX, BY, Blocks, blx, bly: Integer;
Begin
Bx := SmartGetFieldInt(0, BaseX);
By := SmartGetFieldInt(0, BaseY);
GroundData := SmartGetFieldArrayObject(0, getGroundDataArray, SmartGetFieldInt(0, BaseLayer));
If (SmartGetFieldArray2DInt(GroundData, getBlocks, X - Bx, Y - By) And $1280108) = 0 Then
Result := True;
SmartFreeObject(GroundData);
End;



ffs I'm crap at writing tutorials, they never end up as mighty and huge as I thought :(

So let's do so that you ask, I answer, ok?

Method

2008-11-08 13:17:01

It looks like a good start. I'd just like to comment that the SmartGetFieldObject functions return actual objects (instances of classes) instead of the classes themelves. Other than that, it looks fine. :)

n3ss3s

2008-11-09 03:16:47

Yeah that's what I meant :p

0wn 4 skill

2008-11-25 15:18:16

How do people go about implementing reflection into a client? It confuses me no end…