Deprecated: The behavior of unparenthesized expressions containing both '.' and '+'/'-' will change in PHP 8: '+'/'-' will take a higher precedence in /home/iano/public_html/tpforums-vb5/forum/includes/class_core.php on line 5842

PHP Warning: Use of undefined constant MYSQL_NUM - assumed 'MYSQL_NUM' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_ASSOC - assumed 'MYSQL_ASSOC' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: Use of undefined constant MYSQL_BOTH - assumed 'MYSQL_BOTH' (this will throw an Error in a future version of PHP) in ..../includes/init.php on line 165

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 588

PHP Warning: "continue" targeting switch is equivalent to "break". Did you mean to use "continue 2"? in ..../includes/functions_navigation.php on line 612

PHP Warning: Use of undefined constant archive_postsperpage - assumed 'archive_postsperpage' (this will throw an Error in a future version of PHP) in ..../archive/index.php on line 456
Find XYZ of tile [Archive] - Forums

PDA

View Full Version : Find XYZ of tile



bolek
07-20-2007, 04:47 PM
Hello

I tried to write my own fisher but i got one problem, i dont know how to get XYZ of tile ;/

So can anyone tell me how to do it?

bolek
07-20-2007, 05:29 PM
Sorry for double post but i need to give Ya example:

I'm skipping in function 'for' by STEP_MAP_TILE so i found that tile which is fish on it so i need to get the XYZ of that tile to fish there.

i found something in delphi:


var
MapPointer, Tile : longint;
ID : Word;
I,z,x,y : Byte;
begin
MapPointer := Memory_ReadLong(Adr_MapPointer,4);
for Tile:=0 to 2015 do
begin
ID := Memory_ReadWord((Tile*Map_DistTiles) + (MapPointer+Map_DistTileID));
begin
if (ID = CheckID) then
begin
z := trunc(tile/(14 * 18));
Y := trunc((tile - z * 14 * 18) / 18);
X := trunc((tile - z * 14 * 18 - y * 18));
end;
end;
end;
end;

So wtf mean trunc? and i think when we receive that x,y,z i need add PlayerX + MapX....(then we will get global XYZ of that tile).

EDIT2:
AAA trunc: http://delphi.about.com/library/rtl/blrtlTrunc.htm


EDIT3:

My function:


void tryFish()
{
int mapBegin = getMapPointer();

for(int i = mapBegin; i < mapBegin + (STEP_MAP_TILE * MAX_MAP_TILES); i += STEP_MAP_TILE)
{

int tileId = ReadINT( i + 4, 2);

for (int IsFish = fish_begin; IsFish < (fish_end + 1); IsFish++)
{
if (tileId == IsFish)
{
//bleble sending packet
}
}

}
}

Can anyone help me translate first function to mine?

bolek
07-21-2007, 12:16 PM
I see... awesome programmers here... or noone want help me, please.

zionz
07-21-2007, 12:41 PM
The first function, converted to C, will look something like this:



nt i;
int MapPointer, Tile;
short int ID;
unsigned char l,z,x,y;

MapPointer = ReadLong(adr_MapPointer,4);

for(i=0; i<2016; i++){
ID = ReadWord(Tile*Map_DistTiles) + (MapPointer+Map_DistTileID));
if(ID == CheckID){
x = tile / (14*18);
y = (tile - z * 14 * 18) / 18;
z = (tile - z * 17 * 18 - y*18);
}
}


The truc function is not needed becouse C truncates by default.

Want do you want to do exactly, convert a certain tile number in the map array to real XYZ? or get the position of a given XYZ tile in the tiles array?

bolek
07-21-2007, 03:01 PM
I need the global XYZ of that tile ( i sent You a private message with my function, read it)

EDIT#up:

Variable 'Tile' isnt update.
Map_DistTiles = 172 ?
Map_DistTileID = 176?

zionz
07-21-2007, 04:11 PM
i sent you a pm

BlackDemon
07-29-2007, 11:36 PM
Yeah it would be nice if someone will send me the same (getting XYZ of tile in the map), I got already map reading etc. but I don't know how to read the item pos in the map. Please help me anyone!

zionz
07-30-2007, 12:20 AM
You want to convert a tile number in the map array (from 0 to 2015) into a global position (x, y ,z) ?

BlackDemon
07-30-2007, 12:24 AM
Yes :) <tooshort>

zionz
07-30-2007, 12:54 AM
I have a function that converts a global xyz into a tile number, but not the another way, if you didnt , read this:
http://tibiaauto.net/articles/ta_art_mapread.html

you have to convert the tile number (0-2015) in a map array position (map[8][14][18]) then convert this to global positions.
Also if im not wrong ExpertMace have posted some code to do this in this post:
http://www.xcreations.net/~tpforums/forum/showthread.php?t=700

ExpertMace
07-30-2007, 06:47 PM
Yep I did, the full source code in delphi of my map reader is in my board area, the addresses arn't updated but the code works.

Mace.

BlackDemon
07-30-2007, 09:33 PM
I've updated addresses and i've converted it to C++. Whats wrong? In delphi it gives me correct XYZ(I converted addresses in delphi too) etc but not in C++. There's my code!

int Abs_Z(int TileNum)
{
int playertilenum;
int playerRz;
int playerabs;
int tileRz;
int value;
playertilenum = MapRead_GetPlayerTileNum();
playerRz = Rel_Z(playertilenum);
tileRz = Rel_Z(TileNum);
value = tileRz-playerRz;
ReadProcessMemory(processHandle, reinterpret_cast<void*>(0x006198F0), &playerabs, 4, 0);
return playerabs+value;
}

int Abs_Y(int TileNum)
{
int playertilenum;
int playerRy;
int playerabs;
int tileRy;
int value;
playertilenum = MapRead_GetPlayerTileNum();
playerRy = Rel_Y(playertilenum);
tileRy = Rel_Y(TileNum);
value = tileRy-playerRy;
ReadProcessMemory(processHandle, reinterpret_cast<void*>(0x006198F4), &playerabs, 4, 0);
return playerabs+value;
}

int Abs_X(int TileNum)
{
int playertilenum;
int playerRx;
int playerabs;
int tileRx;
int value;
playertilenum = MapRead_GetPlayerTileNum();
playerRx = Rel_X(playertilenum);
tileRx = Rel_X(TileNum);
value = tileRx-playerRx;
ReadProcessMemory(processHandle, reinterpret_cast<void*>(0x006198F8), &playerabs, 4, 0);
return playerabs+value;
}

int Rel_Z(int TileNum)
{
long value;
value = TileNum/(14*18);
return value;
}

int Rel_Y(int TileNum)
{
long value;
value = (TileNum-Rel_Z(TileNum)*14*18)/18;
return value;
}

int Rel_X(int TileNum)
{
long value;
value = (TileNum-Rel_Z(TileNum)*14*18-Rel_Y(TileNum)*18);
return value;
}

int MapRead_GetPlayerTileNum()
{
int polyadr;
int tilenum;
int x;
int costam;
int costam2;
int costam3;
int Player_ID;

for(tilenum = 0; tilenum <= 2015; tilenum++)
{
polyadr = getMapPointer() + (tilenum*172);
ReadProcessMemory(processHandle, reinterpret_cast<void*>(polyadr + 0), &costam, 4, 0);
if (costam > 1)
{
polyadr = polyadr + 4;
for(x = 0; x <= 10; x++)
{
ReadProcessMemory(processHandle, reinterpret_cast<void*>(0x0060EAD0), &Player_ID, 4, 0);
polyadr = polyadr + (12 * x);
ReadProcessMemory(processHandle, reinterpret_cast<void*>(polyadr + 0), &costam2, 4, 0);
ReadProcessMemory(processHandle, reinterpret_cast<void*>(polyadr + 4), &costam3, 4, 0);
if (costam2 == 99 && costam3 == Player_ID)
{
cout << tilenum;
return tilenum;
}
}
}
}
}

ExpertMace
07-30-2007, 09:41 PM
Could it be that the Rel_ functions need to be declared before the Abs_ ones?

Mace.

BlackDemon
07-30-2007, 09:44 PM
I did but it didn't nothing ;d

In c++ the same tile:

Z:4255798
Y:4255803
X:4255797

In delphi:


X: 32679
Y: 31689
Z: 7

Strange:/

BlackDemon
07-31-2007, 05:00 PM
Please help me anyone:(

zionz
07-31-2007, 05:39 PM
I just converted expertmace code to C, i tested it with known values and it seem to work, if MapRead_GetPlayerTileNum() its working, this should work, this will only get the Z position.




int MapRead_GetPlayerTileNum();
int Rel_Z(int tilenum);
int Rel_Y(int tilenum);
int Rel_X(int tilenum);
int Abs_X(int tilenum);

int MapRead_GetPlayerTileNum()
{
int polyadr;
int base_adr;
int tilenum;
int x;
int costam;
int costam2;
int costam3;
int Player_ID;

base_adr = getMapPointer();

for(tilenum = 0; tilenum <= 2015; tilenum++)
{
polyadr = base_adr + (tilenum*172);
ReadProcessMemory(processHandle, (void*)(polyadr + 0), &costam, 4, 0);
if (costam > 1)
{
polyadr = polyadr + 4;
for(x = 0; x <= 10; x++)
{
ReadProcessMemory(processHandle, (void*)(0x0060EAD0), &Player_ID, 4, 0);
polyadr = polyadr + (12 * x);
ReadProcessMemory(processHandle, (void*)(polyadr + 0), &costam2, 4, 0);
ReadProcessMemory(processHandle, (void*)(polyadr + 4), &costam3, 4, 0);
if (costam2 == 99 && costam3 == Player_ID)
{
cout << tilenum;
return tilenum;
}
}
}
}
}

int Rel_Z(int tilenum)
{
return (tilenum / (14*18));
}

int Rel_Y(int tilenum)
{
return ((tilenum - Rel_Z(tilenum)*14*18)/18);
}

int Rel_X(int tilenum)
{
return (tilenum - Rel_Z(tilenum)*14*18 - Rel_Y(tilenum)*18);
}

int Abs_Z(int tilenum)
{
int playerabs;

int playertilenum = MapRead_GetPlayerTileNum();
int playerRz = Rel_Z(playertilenum);
int tileRz = Rel_Z(tilenum);
int value = tileRz - playerRz;

ReadProcessMemory(processHandle, (void*)(0x006198F0), &playerabs, 4, 0);
return (playerabs+value);
}

int main()
{
printf("%i\n",Abs_Z(100));
}