SRL Archive - Help and Support

[R]Alternate object hooks?


Flight

2011-05-11 06:17:04

I don't really know how to go about wording this, but is there a way to tell if a, let's called it 'Object mask', changes? Or if there's a more specific name for it, when an object visually changes, but ID/Tile/and Orientation remain the same.

Maybe a more specific question is; using reflection to get an object's interactable menu, for example: "Mine,Examine".

I'm sure sorry if I'm unclear, but I don't know the correct name for these object properties. Any info or pointers would be great. :)

Shuttleu

2011-05-11 06:20:39

yes you can, look at reflections text.simba and there is a function called something like GetMenuText

~shut

Flight

2011-05-11 06:26:43

Without having to right-click the object to bring up the menu?

Shuttleu

2011-05-11 06:29:51

correct

~shut

EDIT: im not at home at the mo, so i cant check, but its called something like r_GetMenuText

Home

2011-05-11 06:38:43

OptionExists(Option : string)


~Home

Iamadam

2011-05-11 06:40:01

But your mouse still needs to be over the object.
Can I ask what object this is? Most objects change ID when they are doing a different animation.

Flight

2011-05-11 06:49:51

Yeah, I think it was a new shot at bots from our dear friends, Jagex.

Anywho, if any of you have played the Livid Farm activity, it's the Livid plants and the Soil that change animation, appearance, and even interactable menus… but remain the same in ID.

Home, I looked into that and anything else that get the options available in a menu, but I don't see how I could apply any of those to an object itself.

I'm terribly sorry for the dumb questions, but my knowledge is still very limited with Reflection.

Edit:
Do you guys think it might be "hook_interactiveobject_GetModel"? If so, how would I go about debuging an object's Model ID?

Shuttleu

2011-05-11 07:27:37

SmartGetFieldInt({index, no idea where to get it from}, hook_interactiveobject_GetModel)

~shut

EDIT:
procedure Debug
var
TheIndex, id: integer;
begin
try
TheIndex := SmartGetFieldArrayInt(0{might be wrong}, {index hook}, 0{might be wrong});

id:= SmartGetFieldInt(TheIndex, hook_interactiveobject_GetModel);

finally
SmartFreeObject(TheIndex);
end;
end;

Flight

2011-05-11 07:44:28

What is the "index hook", is that for the Object ID we're debugging?

Shuttleu

2011-05-11 07:49:50

to be honest, i have no idea

sorry

~shut

Flight

2011-05-11 08:04:24

I was hoping this would work:

Procedure Test;
Var
Rock: TRSObject;
ModelID: Integer;
begin
Rock := NULL_RSOBJECT;
Rock := GetObjectByID(2096,OBJECT_TYPE_INTERACTABLE,7);

if(Not Rock = NULL_RSOBJECT)then
ModelID := SmartGetFieldInt(Rock, hook_InteractiveObject_GetModel);

Writeln('Object model ID: '+IntToStr(ModelID));
SmartFreeObject(Rock);
end;

But I have a type mismatch with this line: "ModelID := SmartGetFieldInt(Rock, hook_InteractiveObject_GetModel);". I even tried using "SmartGetFieldShort" instead, same dilemma.

Echo_

2011-05-11 08:59:33

I don't think SmartGetFieldInt will work with GetModel because it's not an integer. I don't know what GetModel is, all I know is that it is associated with another class :p


You cannot currently find an object's animation, so that isn't an option. Looks like you will have to rely upon the option menu changes.

mormonman

2011-05-11 10:27:56

You need to use SmartGetObject, but with interactables you have to go through the soft and hard reference classes and get the right one.

Flight

2011-05-11 12:21:10

From: mormonman
You need to use SmartGetObject, but with interactables you have to go through the soft and hard reference classes and get the right one.


Beyond my ability.

@Echo_, I've looked at reflection's Text, for example, 'GetMenuText'. How would you use that for a single object to get it's menu's text without moving the mouse to and clicking the object? Is there an example someone might show me how to do this?

Echo_

2011-05-11 13:43:30

Like Home said, you can always use OptionExists if there is a unique option for the object's state. Something like this:

if OptionExists('option string') then
begin
DoActivity;
end else
begin
repeat
YourAntiban;
R_FindRandoms;
until(OptionExists('option string');
end;

Shuttleu

2011-05-11 13:57:22

From: Echo_
Like Home said, you can always use OptionExists if there is a unique option for the object's state. Something like this:

if OptionExists('option string') then
begin
DoActivity;
end else
begin
repeat
YourAntiban;
R_FindRandoms;
until(OptionExists('option string');
end;


i think he wants to check the menu text without hovering over it

~shut

Echo_

2011-05-11 14:27:14

From: Shuttleu
i think he wants to check the menu text without hovering over it

~shut


{*******************************************************************************
function OptionExists(option: string): Boolean;
By: Drags111
Description: Returns true if an option exists in the choose option menu. Choose
option menu does NOT have to be open.
*******************************************************************************}

Shuttleu

2011-05-11 14:30:03

From: Echo_
{*******************************************************************************
function OptionExists(option: string): Boolean;
By: Drags111
Description: Returns true if an option exists in the choose option menu. Choose
option menu does NOT have to be open.
*******************************************************************************}

the menu does not have to be open
the mouse does have to be hovering over the object

~shut

Flight

2011-05-11 22:00:07

Well it seems that shoots down my idea… I appreciate all the help guys, but I don't know what other options I have. Maybe I'll work for a different script instead.

pyroryan

2011-05-11 22:27:34

From: Flight
Maybe a more specific question is; using reflection to get an object's interactable menu, for example: "Mine,Examine".


Yes thats possible. ObjectDef does contain the actions for a specific object. Same thing for NPCDef.
Sorry I wasn't on the past few days. Try MSN :)

Iamadam

2011-05-11 22:35:11

Maybe use color to determine the animation?

Flight

2011-05-11 23:08:02

From: pyroryan
Yes thats possible. ObjectDef does contain the actions for a specific object. Same thing for NPCDef.
Sorry I wasn't on the past few days. Try MSN :)


I'll get on MSN now.

@Iamadam:
Believe me, color was my second option and I went over it many times, but like I mentioned before the colors are well-blended in this whole area. Although I did notice the leaves on the dead plants having a unique color so that might be a possibility, but unfertilized soil patches don't differ much in color from fertilized patches.

mormonman

2011-05-12 00:02:50

From: pyroryan
Yes thats possible. ObjectDef does contain the actions for a specific object. Same thing for NPCDef.
Sorry I wasn't on the past few days. Try MSN :)


But odds are that the objects aren't loaded in the cache, and the only way to load them is to mouse over. That ruins the purpose.

pyroryan

2011-05-12 00:21:25

From: mormonman
But odds are that the objects aren't loaded in the cache, and the only way to load them is to mouse over. That ruins the purpose.


If I recall, all objects are refreshed anytime the mouse moves any object. Someone who remembers should help out :)

n3ss3s

2011-05-12 20:43:54

I'm pretty sure you need to have the right click menu open, but there isn't anything you'd need to right click menu for that you couldn't determine from the object ID. A mined rock has a different ID than a fresh rock.

Flight

2011-05-12 21:14:33

From: n3ss3s
I'm pretty sure you need to have the right click menu open, but there isn't anything you'd need to right click menu for that you couldn't determine from the object ID. A mined rock has a different ID than a fresh rock.


Or if there's a more specific name for it, when an object visually changes, but ID/Tile/and Orientation remain the same.


Object id remains the same, object animation/appearance changes. From what I've heard there is a way to grab the object's animation, but it's just not in SRL-Ref yet. ;)

footballjds

2011-05-13 17:57:33

From: Flight
Object id remains the same, object animation/appearance changes. From what I've heard there is a way to grab the object's animation, but it's just not in SRL-Ref yet. ;)


and it won't be for a while unless you haggle the right people.

Can you get me a pic of it and i'll try to find some unique colors and create you a function so you can keep working on the script?

n3ss3s

2011-05-15 18:35:52

Object id remains the same, object animation/appearance changes. From what I've heard there is a way to grab the object's animation, but it's just not in SRL-Ref yet.


Wrong. A mined and a fresh rock are different objects.



I have no idea what train of thought gave birth to this thread, we've been making reflection miners etc for years, and now someone thinks we have to track the animation?

footballjds

2011-05-15 19:37:05

From: n3ss3s
Wrong. A mined and a fresh rock are different objects.



I have no idea what train of thought gave birth to this thread, we've been making reflection miners etc for years, and now someone thinks we have to track the animation?


Okay, n3ss3s, you and him are on different tracks. Your talking about rocks.
He is talking about farming.

He is correct, the ID for his specific thing DOES NOT CHANGE.
Rocks are nice, when mining they change ID. But the plants/soil do not change ID when they are bad.

I understand he didn't do the best with wording his question and his original post was a bit hard to follow… :p
Also he used something hypothetical
"Mine,Examine"
which would make one think he is talking about rocks… But he really wants to use this for farming in a specific location that is relevant to a recent update on Lunar isle :D

understand? :)

Gu3st...

2011-05-15 19:43:56

From: footballjds
Okay, n3ss3s, you and him are on different tracks. Your talking about rocks and i have no fucking clue why…?
He is talking about farming.

He is correct, the ID for his specific thing DOES NOT CHANGE.
Rocks are nice, when mining they change ID. But the plants/soil do not change ID when they are bad.

I understand he didn't do the best with wording his question and his original post was a bit hard to follow… :p
Also he used something hypothetical which would make one think he is talking about rocks… But he really wants to use this for farming in a specific location that is relevant to a recent update on Lunar isle :D

understand? :)
Woah, calm down man…

footballjds

2011-05-15 19:47:22

From: Zyt3x
Woah, calm down man…


bro, i'm calm :D

this is t3h internet and my l33t personality appears rather harsh :'(

EDIT: fix0red so people will not hate me :p

Flight

2011-05-15 20:45:40

From: n3ss3s

I have no idea what train of thought gave birth to this thread, we've been making reflection miners etc for years, and now someone thinks we have to track the animation?


Yes, I'm sorry for being unclear but it's pretty difficult to explain an objects animation/model/mask/whatever. I used the text example "Mine/Examine" purely as an example because I figured if I use "Cure/Examine" no one would know what I was talking about.

I've tried directly hooking an Object's model ID from a specific Object, didn't work. I tried directly hooking an Object's interface text from a specific Object, also failed. I'm afraid I've run short on options. But, I did set a record for most Simbas/Smarts crashed within an hour. :cool:

n3ss3s

2011-05-15 22:01:30

But, I did set a record for most Simbas/Smarts crashed within an hour.


Free ur objects..

I've tried directly hooking an Object's model ID from a specific Object, didn't work.


Could you specify on what you tried and what doesn't work, because this should work fine…

Flight

2011-05-15 22:29:04

Yeah I probably didn't free it correctly. I'll post here what I have.


Function GetObjectModelID(RSObject: TRSObject): Integer;
Var
Obj: Integer;
begin
if RSObject = NULL_RSOBJECT then Exit;
Obj := SmartGetFieldShort(RSObject.ID, hook_interactiveobject_GetModel); //Should we include "and $FFFF"?
Result := Obj;
SmartFreeObject(Obj);
end;

Procedure DisplayModel;
Var
Plant: TRSObject;
begin
Plant := NULL_RSOBJECT;
//Plant := GetObjectByID(40462,OBJECT_TYPE_INTERACTABLE,7);
Plant := GetInteractableAt(Tile(GetMyPos.x,GetMyPos.y+1));

Wait(500);
ClearDebug;
Writeln('Model ID: '+IntToStr(GetObjectModelID(Plant)));
end;

I sure hope you see something I don't because I'm sure running short on options.

n3ss3s

2011-05-18 15:02:49

But what doesn't work? Does it always return 0 or what?

Echo_

2011-05-18 15:24:44

Remember that GetModel isn't a short type, it's an object.

Flight

2011-05-18 20:11:39

From: Echo_
Remember that GetModel isn't a short type, it's an object.


Yes I've tried "Obj := SmartGetFieldObject" as well, same result.

@n3ss3s:
I've tried an array of options but all came to two outcomes, so I can't remember which gives what, but I think with correctly freeing my objects I'll get either '65535' or '-1', which are both a null object.

trojan

2011-05-21 06:21:17

Would you be able to post pictures of the plant in its different states so everyone can get a better understanding of what you mean?

I really don't understand all this stuff about SMARTFieldObjects atm so I'm not going to try that approach, however have you tried;
1. Looking for a certain colour in the plant tile
2. Counting a colour in the plant tile, e.g. a plant may have more of a colour when it needs curing??

Sorry if this is no help :hypocrite:

Flight

2011-05-21 06:55:54

I appreciate the suggestion, but somewhere in this thread I've already gone over the color blending in this area. It is possible with color, but even if the plant/soil objects differed a drastic amount, it would still be difficult to really keep track of which plants need curing, and which soil needs fertilizing. The area of just the plants/soil patches themselves take up almost all of the screen, zoomed out at it's highest angle.

mormonman

2011-05-21 15:56:14

Model loading has to be done without freeing the Object. If these weren't interactables I would post code that loads them.

Flight

2011-05-21 20:54:33

Client-side they're declared as Private Short. So obviously my first try was this:

if RSObject = NULL_RSOBJECT then Exit;
Obj := SmartGetFieldShort(RSObject.ID, hook_interactiveobject_GetModel); //Should we include "and $FFFF"?
Result := Obj;

Results in a complete crash.

Edit:
Would either of these two have something to do with models?
SmartGetFieldArray3DObject
SmartGetFieldArray3DShort

mormonman

2011-05-22 01:21:26

Flight, did you not read my post? I'll show you where model loading must be done.

{*******************************************************************************
function GetInteractableAt(T: TTile): TRSObject;
By: Drags111 modified/fixed by pyroryan
Description: Returns the objType Interactable ID at the given tile. Interactable
objects include anything clickable that isnt a WallObject.
*******************************************************************************}
function GetInteractableAt(T: TTile): TRSObject;
var
Plane, Ground, Node, Obj, ObjTemp, ID: integer;
TempBox: TBox;
TempTile, L, Base: TTile;
begin
Result := NULL_RSOBJECT;
try
Base.X := SmartGetFieldInt(0, hook_static_BaseX);
Base.Y := SmartGetFieldInt(0, hook_static_BaseY);
L.X := T.X - Base.X;
L.Y := T.Y - Base.Y;
Plane := SmartGetFieldInt(0, hook_static_LoadedPlane);
Ground := SmartGetFieldArray3DObject(0, hook_static_GroundTiles, Plane, L.X, L.Y);
Node := SmartGetFieldObject(Ground, hook_ground_AnimableList);
while(Node <> 0)do
begin
TempBox := NULL_BOX;
Obj := SmartGetFieldObject(Node, hook_AnimableNode_GetAnimable);
if(Obj <> 0)then
begin
ID := SmartGetFieldShort(Obj, hook_InteractiveObject_GetID) and $FFFF;
if((ID = -1) or ((ID) = 65535))then //65535 is an unsigned -1....
begin
ObjTemp := SmartGetFieldObject(Obj, hook_interactiveobject2_GetObjectData);
if(ObjTemp <> 0) then
begin
ID := SmartGetFieldInt(ObjTemp, hook_secondlevelobject_GetID);
if((ID = -1) or ((ID and $FFFF) = 65535))then
begin
SmartFreeObject(ObjTemp);
Break;
end;
//<<<<<<<<<<<<<<<<<<<<<<<<<<RIGHT HERE OR>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
TempBox.X1 := (Base.X + SmartGetFieldShort(ObjTemp, hook_animableentity_getAreaX1));
TempBox.Y1 := (Base.Y + SmartGetFieldShort(ObjTemp, hook_animableentity_getAreaY1));
TempBox.X2 := (Base.X + SmartGetFieldShort(ObjTemp, hook_animableentity_getAreaX2));
TempBox.Y2 := (Base.Y + SmartGetFieldShort(ObjTemp, hook_animableentity_getAreaY2));
TempTile.X := (Base.X + (SmartGetFieldInt(ObjTemp, hook_animable_PixelX) / 512));
TempTile.Y := (Base.Y + (SmartGetFieldInt(ObjTemp, hook_animable_PixelY) / 512));
SmartFreeObject(ObjTemp);
end;
end else //ID is valid, so we can use Obj
begin
//<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<RIGHT HERE>>>>>>>>>>>>>>>>>>>>>>
TempBox.X1 := (Base.X + SmartGetFieldShort(Obj, hook_animableentity_getAreaX1));
TempBox.Y1 := (Base.Y + SmartGetFieldShort(Obj, hook_animableentity_getAreaY1));
TempBox.X2 := (Base.X + SmartGetFieldShort(Obj, hook_animableentity_getAreaX2));
TempBox.Y2 := (Base.Y + SmartGetFieldShort(Obj, hook_animableentity_getAreaY2));
TempTile.X := (Base.X + (SmartGetFieldInt(Obj, hook_animable_PixelX) / 512));
TempTile.Y := (Base.Y + (SmartGetFieldInt(Obj, hook_animable_PixelY) / 512));
end;

Result := NewObject(ID, OBJECT_TYPE_INTERACTABLE, T, TempTile, TempBox);
SmartFreeObject(Obj);
Break;
end;
SmartFreeObject(Node);
Node := SmartGetFieldObject(Node, hook_AnimableNode_GetNext);
end;
finally
try
SmartFreeObject(Ground);
except
end;
try
SmartFreeObject(Obj);
except
end;
try
SmartFreeObject(ObjTemp);
except
end;
try
SmartFreeObject(Node);
except
end;
end;
end;

Method

2011-05-22 01:50:00

From: Flight
Client-side they're declared as Private Short. So obviously my first try was this:

if RSObject = NULL_RSOBJECT then Exit;
Obj := SmartGetFieldShort(RSObject.ID, hook_interactiveobject_GetModel); //Should we include "and $FFFF"?
Result := Obj;

Results in a complete crash.

Edit:
Would either of these two have something to do with models?
SmartGetFieldArray3DObject
SmartGetFieldArray3DShort


Unless RSObject.ID is a reference to some object in the client, you're incorrectly using it as the first argument to the function.

Flight

2011-05-22 06:02:32

From: mormonman
Flight, did you not read my post? I'll show you where model loading must be done.


Ah I apologize, I misunderstood your previous post. So shall I try to hook the Object Model at those indicated lines you posted in 'GetInteractableAt'?

mormonman

2011-05-22 11:46:38

From: Flight
Ah I apologize, I misunderstood your previous post. So shall I try to hook the Object Model at those indicated lines you posted in 'GetInteractableAt'?


You have to compare hard and soft references, which pyro is working on. For other things, like wall decor, that isn't required.