Register for your free account! | Forgot your password?

Go Back   elitepvpers > Popular Games > Silkroad Online > SRO Coding Corner
You last visited: Today at 08:49

  • Please register to post and access all features, it's quick, easy and FREE!

Advertisement



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

Discussion on How to convert (x/y/z & Region ) to (X/Y) ? within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 135
Join Date: May 2015
Posts: 647
Received Thanks: 752
How to convert (x/y/z & Region ) to (X/Y) ?

........
$WeGs is offline  
Old 09/10/2015, 15:37   #2
 
elite*gold: 0
Join Date: Nov 2007
Posts: 959
Received Thanks: 602
Use the search function on the forum,or google,it's been posted at least 2 or 3 times on this forum alone...
vorosmihaly is offline  
Old 09/10/2015, 16:02   #3
 
elite*gold: 0
Join Date: Oct 2014
Posts: 34
Received Thanks: 16
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
	{
		...
	}
}
mxii is offline  
Thanks
1 User
Old 09/10/2015, 16:29   #4
 
elite*gold: 135
Join Date: May 2015
Posts: 647
Received Thanks: 752
.
$WeGs is offline  
Reply


Similar Threads Similar Threads
Kick to convert: easy and fast way to convert your item_proto/mob_proto to txt files!
09/07/2016 - Metin2 PServer Guides & Strategies - 21 Replies
Hi all, this is my first release :) This "kick converter" will allow you to generate txt files (item_names, item_proto, mob_proto, mob_names) for the rev-34k game. The script was written in python by me, so you need python 2.7 and MySQLDB (python extension) installed on your server. If you found any error, please report it to me and I'll fix it as soon as possibile. PS: If you get errors while converting the item_proto, please remove items that have type 29 or type 31.
first npc.bin convert
02/24/2014 - Rohan - 16 Replies
Hello everybody i wanna Trade my npc.php template For antihack+db (antihack in Dedicated) i have scripts (Guild Logo, Gms cpanel, Itemmall 3 scripts, weapon/armor stats adder) and there a lots scripts if u wanna trade for the antihack Btw That the Template npc.bin convert picture 1 http://infinity-rohan.com/uploads/npc1.png picture 2 http://infinity-rohan.com/uploads/npc.png
How i convert this to npc ??
01/07/2013 - CO2 Private Server - 2 Replies
i want to convert this 3dmax project to npc
In Global Region Region für alle Spieler
01/05/2013 - Minecraft - 2 Replies
Nur eine kurze Frage wie kann ich in einer mit worldguard gesetzen /region flag __global__ build deny eine gebiet setzen in dem alle spieler etwas abbauen können?



All times are GMT +1. The time now is 08:50.


Powered by vBulletin®
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.

Support | Contact Us | FAQ | Advertising | Privacy Policy | Terms of Service | Abuse
Copyright ©2025 elitepvpers All Rights Reserved.