SRL Archive - Help

TileToMS, TGroundItem


blackfire553

2011-07-01 15:19:21

My problem is that when i convert a tile of a TGroundItem to mainscreen coordinates, it is never accurate. When i do not use offsets, it is typically a little bit to the lower right of the item. Using offsets in the x and y for the Mouse function makes it more accurate, but i feel this is a temporary solution for a larger problem.

The code i use is this:
ItemsOnGround := GetItemsNear(Players[CurrentPlayer].Integers[0]);
For j := 0 to high(ItemsOnGround) do
begin
ItemPoints[j] := TileToMS(ItemsOnGround[j].Tile,0)
end;
SortTPAFrom(ItemPoints,GetMyPos);
Mouse(ItemPoints[i].x, ItemPoints[i].y, 0, 0, false);


I want to be able to convert the MS point back into a tile to get the item again and check the ID, but it doesnt work because i cant get the proper coordinates anyways.

Another thing i noticed is that the ItemsOnGround[j].height is usually between -800 and -900.

Capricorn

2011-07-01 18:08:02

Just use the middle of the tile? That way you won't have to use negative height lol

blackfire553

2011-07-02 01:51:35

From: Capricorn
Just use the middle of the tile? That way you won't have to use negative height lol


how?

Smarter Child

2011-07-02 03:48:54

From: blackfire553
how?


MiddleTPA?

Although, you don't even sort the ground objects, GetItemsNear with 1-2 will only search in the squares very near to you.
Not to mention you can verify it via ID checking.

blackfire553

2011-07-02 14:29:43

From: Smarter Child
MiddleTPA?

Although, you don't even sort the ground objects, GetItemsNear with 1-2 will only search in the squares very near to you.
Not to mention you can verify it via ID checking.


Im using GetItemsNear to find the tiles with items, i dont use TPAs except for the location to click the items.

Edit: So middleTPA wont work because the points are random dots all over the screen where items are located. (one dot per item)

I changed my code to where i dont need to convert the point back into a tile, but i still would like to have the exact coordinates without using offsets.

Awkwardsaw

2011-07-02 14:37:13

From: blackfire553
Im using GetItemsNear to find the tiles with items, i dont use TPAs except for the location to click the items.

Edit: So middleTPA wont work because the points are random dots all over the screen where items are located. (one dot per item)

I changed my code to where i dont need to convert the point back into a tile, but i still would like to have the exact coordinates without using offsets.


You can try to make a box around the tile of ground item, then find the middle of the tile. you shouldnt be picking up items that are more than 2-3 tiles away from your character anyways :p

Smarter Child

2011-07-02 15:32:00

From: blackfire553
Im using GetItemsNear to find the tiles with items, i dont use TPAs except for the location to click the items.

Edit: So middleTPA wont work because the points are random dots all over the screen where items are located. (one dot per item)

I changed my code to where i dont need to convert the point back into a tile, but i still would like to have the exact coordinates without using offsets.


The exact coordinate of ground items can be retrieved, and there is no need for any off-sets..