SRL Archive - Reflection Help

TileToMS and FindNPC


Smarter Child

2011-06-27 15:04:47

So i have a script that looks kinda like..

FindNPC(NPCID, TNPC);
TP := TileToMS(TNPC.tile, TNPC.height);
MMouse(TP.x, TP.y, 0, 0);
Mouse(TP.x, TP.y, 0, 0);

When I run the script it never clicks accurately, and the NPC is not moving.

Am i doing something wrong?

Harry

2011-06-27 15:10:52

TNPC.Height is never usually proper. Also try .RealTile instead of .Tile if the NPC is more than one tile large.

Smarter Child

2011-06-27 15:17:19

From: Harry
TNPC.Height is never usually proper. Also try .RealTile instead of .Tile if the NPC is more than one tile large.


ok, how would I get around TNPC.Height never being proper, because what I am doing is kind of general and the NPC height may vary

Rich

2011-06-27 15:26:26

From: Smarter Child
ok, how would I get around TNPC.Height never being proper, because what I am doing is kind of general and the NPC height may vary
I use 0 (trying to find GE bankers) and it works fine.

Smarter Child

2011-06-27 15:47:11

From: Rich
I use 0 (trying to find GE bankers) and it works fine.


Doesn't always work for me, however is there any other work around to this?

TomTuff

2011-06-27 15:56:23

what I do often times for height is

Height := (RandomRange(1, 2) / 3)* NPC.Height;

Home

2011-06-27 17:30:30

What I usually do is:

[PHP]TP := TileToMS(TNPC.tile, TNPC.height / 2);[/PHP]
Then some Random X and Y Offsets.
~Home

i luffs yeww

2011-06-27 18:27:40

I find it quite sad and really inappropriate that the advice is to use random ranges or offets to try to use a piece of reflection. :/ I really hope that's changed soon.

Flight

2011-06-27 21:06:37

From: i luffs yeww
I find it quite sad and really inappropriate that the advice is to use random ranges or offets to try to use a piece of reflection. :/ I really hope that's changed soon.


Iamadam's model clicking looks promising in this field.

TomTuff

2011-06-27 21:17:22

From: i luffs yeww
I find it quite sad and really inappropriate that the advice is to use random ranges or offets to try to use a piece of reflection. :/ I really hope that's changed soon.


it's like adding random mouse offsets.

Drakan

2011-06-27 23:04:03

From: i luffs yeww
I find it quite sad and really inappropriate that the advice is to use random ranges or offets to try to use a piece of reflection. :/ I really hope that's changed soon.


Maybe you should learn what things are before criticizing them? The height property of an NPC is the game's pixel height off the ground when calculating the MS position. The reason why it isn't accurately clicking is because it's trying to hit the very top of the NPC, and could miss if the NPC isn't right in the center. A good rule of thumb for NPC's is to use (Tile.height*2/3).

@Harry: RealTile is the EXACT same thing as the Tile. Idk who added it and why, but it serves no purpose whatsoever. Stick with tile.

Flight

2011-06-27 23:29:27

From: drags111
@Harry: RealTile is the EXACT same thing as the Tile. Idk who added it and why, but it serves no purpose whatsoever. Stick with tile.


:garfield:

Smarter Child

2011-06-27 23:29:30

From: drags111
Maybe you should learn what things are before criticizing them? The height property of an NPC is the game's pixel height off the ground when calculating the MS position. The reason why it isn't accurately clicking is because it's trying to hit the very top of the NPC, and could miss if the NPC isn't right in the center. A good rule of thumb for NPC's is to use (Tile.height*2/3).

@Harry: RealTile is the EXACT same thing as the Tile. Idk who added it and why, but it serves no purpose whatsoever. Stick with tile.


Thanks for the help :D

Jakkle

2011-06-28 11:07:18

From: drags111
@Harry: RealTile is the EXACT same thing as the Tile. Idk who added it and why, but it serves no purpose whatsoever. Stick with tile.


Well when using .RealTile in my oak chopper script it finds the tree no problem. So I went to use it on my runecrafting script and it would not click on the rock or alter. So I had to use .Tile :S confused me tbh. I thought tho RealTile was the centre tile of the object.

mormonman

2011-06-28 13:19:47

From: whacko999
Well when using .RealTile in my oak chopper script it finds the tree no problem. So I went to use it on my runecrafting script and it would not click on the rock or alter. So I had to use .Tile :S confused me tbh. I thought tho RealTile was the centre tile of the object.


It's the bottom-left tile.

Home

2011-06-28 13:21:39

RealTile Vs Tile is NOT Same thing ;)
RealTile and Tile gives SOMETIMES different Pos / Tile.

EDIT: Not so sure anymore :P
Waiting for Pyro to answer me :)

Answer:

pyroryan says:
In theory they should be the same
i.e.
Tile is used as the location of the object. This location is then used to search for the object.
Once the object is found, its location is generated and stored in RealTile.

RealTile=SW corner of object area iirc

I believe you can search any of the 4 tiles a tree is on (Tile = one of the 4 tiles). But RealTile will only return 1 of them (the SW corner)

~Home

Gu3st...

2011-06-28 14:30:42

From the reflection include:
    Result[c].Tile.X := (Base.X + (SmartGetFieldInt(TheNPC, hook_animable_PixelX) / 512));
Result[c].Tile.Y := (Base.Y + (SmartGetFieldInt(TheNPC, hook_animable_PixelY) / 512));
Result[c].RealTile.X := (Base.X + (SmartGetFieldInt(TheNPC, hook_animable_PixelX) / 512));
Result[c].RealTile.Y := (Base.Y + (SmartGetFieldInt(TheNPC, hook_animable_PixelY) / 512));

So they're identical.

pyroryan

2011-06-28 15:24:29

From: Zyt3x
From the reflection include:
    Result[c].Tile.X := (Base.X + (SmartGetFieldInt(TheNPC, hook_animable_PixelX) / 512));
Result[c].Tile.Y := (Base.Y + (SmartGetFieldInt(TheNPC, hook_animable_PixelY) / 512));
Result[c].RealTile.X := (Base.X + (SmartGetFieldInt(TheNPC, hook_animable_PixelX) / 512));
Result[c].RealTile.Y := (Base.Y + (SmartGetFieldInt(TheNPC, hook_animable_PixelY) / 512));

So they're identical.


Oh you guys are talking about NPCs. I was talking about objects.


In theory they should be the same
i.e.
Tile is used as the location of the [B]object[/B]. This location is then used to search for the [B]object[/B].
Once the [B]object[/B] is found, its location is generated and stored in RealTile.

RealTile=SW corner of [B]object[/B] area iirc

I believe you can search any of the 4 tiles a [B]tree[/B] is on (Tile = one of the 4 tiles). But RealTile will only return 1 of them (the SW corner)

mormonman

2011-06-28 16:06:40

RealTile is an animable field, it works for both NPCs and objects but we don't search for npcs on a tile-by-tile basis, so RealTile and Tile will always be the same for NPCs.
I originally added RealTile for this: