SRL Archive - Reflection Discussion

object returning tile


**BANNED The Man

2011-01-12 19:40:29

Hai guys,
So basically i want to check for an object by id, and if it is there i want to click it.
I know there is a hook for it, cause powerbot/rsbot can do it.
I was wondering if this is already possible or do i have to work on an algorithm for the hook?

-Boom

silor

2011-01-12 19:46:53

From: Dynamite
Hai guys,
So basically i want to check for an object by id, and if it is there i want to click it.
I know there is a hook for it, cause powerbot/rsbot can do it.
I was wondering if this is already possible or do i have to work on an algorithm for the hook?

-Boom


Erm, there are already tutorials about this.. I think..

Call GetObjectById, it takes 3 params ID, objType, maxDistance (?) and returns a TRSObject, then call TileToMS it takes 2 params, a tile and a height, it returns a TPoint (X,Y) which you can then click on.

This is what I use in my scripts, I suppose could be done better.
procedure FindAndClickObject(ID: Integer; UpText: string; Hover: boolean);
var
CurrentObject: TRSObject;
MP: TPoint;
objType: integer;
Success: Boolean;
TimeOut: integer;
begin
TimeOut := GetSystemTime;

while (Success = False) and (GetSystemTime - TimeOut < 7000) do
begin
CurrentObject := GetObjectById(ID, objType, 3);
if (TileOnMs(CurrentObject.Tile, 0) = False) then Break;
MP := TileToMS(CurrentObject.Tile, 0);

if (IsUpText(UpText) = False) then
MMouse(MP.x + RandomRange(-2, 2), MP.y + RandomRange(-3, 1), 0, 0);

if (Hover = False) then
begin
if (WaitUpText(UpText, 100 + Random(50))) then
begin
Wait(5 + Random(20));
ClickMouse2(True);
Success := True;
end else
begin
ClickMouse2(False);
Wait(3 + Random(20));
if R_ChooseOption(UpText) then Success := True;
end;
end else Success := True;
end;
Wait(20 + Random(50));
end;

Nava2

2011-01-12 19:47:20

From: Dynamite
Hai guys,
So basically i want to check for an object by id, and if it is there i want to click it.
I know there is a hook for it, cause powerbot/rsbot can do it.
I was wondering if this is already possible or do i have to work on an algorithm for the hook?

-Boom


Used to be in objects.simba, not really sure though. I know you can get the tile of an object based on UID's. Buuut, I have been out of the reflection include for awhile so I dunno.