How to convert (x/y/z & Region ) to (X/Y) ?

09/10/2015 15:08 $WeGs#1
........
09/10/2015 15:37 vorosmihaly#2
Use the search function on the forum,or google,it's been posted at least 2 or 3 times on this forum alone...
09/10/2015 16:02 mxii#3
Its not PHP, but should help u!

Code:
public static int CalculatePositionX(ushort xSector, float X)
{
	return (int)((xSector - 135) * 192 + X / 10);
}
public static int CalculatePositionY(ushort ySector, float Y)
{
	return (int)((ySector - 92) * 192 + Y / 10);
}

public static void ParseMovePacket(Packet packet)
{
	uint id = packet.ReadUInt32();
	if (id == CharData.CharId)
	{
		if (packet.ReadUInt8() == 1)
		{
			byte xsec = packet.ReadUInt8();
			byte ysec = packet.ReadUInt8();
			float xcoord = 0;
			float zcoord = 0;
			float ycoord = 0;
			if (ysec == 0x80)
			{
				xcoord = packet.ReadUInt16() - packet.ReadUInt16();
				zcoord = packet.ReadUInt16() - packet.ReadUInt16();
				ycoord = packet.ReadUInt16() - packet.ReadUInt16();
			}
			else
			{
				xcoord = packet.ReadUInt16();
				zcoord = packet.ReadUInt16();
				ycoord = packet.ReadUInt16();
			}
			int real_xcoord = 0;
			int real_ycoord = 0;
			if (xcoord > 32768)
			{
				real_xcoord = (int)(65536 - xcoord);
			}
			else
			{
				real_xcoord = (int)xcoord;
			}
			if (ycoord > 32768)
			{
				real_ycoord = (int)(65536 - ycoord);
			}
			else
			{
				real_ycoord = (int)ycoord;
			}
			
			int x = CalculatePositionX(xsec, real_xcoord);
			int y = CalculatePositionY(ysec, real_ycoord);

			CharData.X = x;
			CharData.XSector = xsec;
			CharData.Y = y;
			CharData.YSector = ysec;
			
			BotData.RecalculateDistances();
		}
	}
	else if (id == CharData.HorseId)
	{
		...
	}
	else
	{
		...
	}
}
09/10/2015 16:29 $WeGs#4
.