Register for your free account! | Forgot your password?

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

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

Advertisement



[Help] Warp packet calculation (/wp)

Discussion on [Help] Warp packet calculation (/wp) within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
Muhab*'s Avatar
 
elite*gold: 0
Join Date: Feb 2014
Posts: 885
Received Thanks: 1,419
[Help] Warp packet calculation (/wp)

Hello epvp.. today am working on warp packet calculations it's kinda weird.
however: here is a simple packet
PHP Code:
[-> S][7010]
10 00                                             ................
A8 60                                             .`..............
00 E0 82 44 75 AD 57 C1 00 80 95 44               ...Du.W....D....
01 00                                             ................ 
A8 60 = RegionID(24744)
00 E0 82 44 = PosX(1047)
75 AD 57 C1 = PosY(-13.4798479)
00 80 95 44 = PosZ(1196)

also here is some calculations i have written so far but i can't understand it since there is a big difference between X=1000 and X=1047 than normal.

PHP Code:
x=0    00 00 00 00    X:6144    Y:851    --    
x=1    00 00 80 3F    X:6144    Y:851    --    16256    +    128
x
=2    00 00 00 40    X:6144    Y:851    --    16384    +    64
x
=3    00 00 40 40    X:6144    Y:851    --    16448    +    64
x
=4    00 00 80 40    X:6144    Y:851    --    16512    +    32
x
=5    00 00 A0 40    X:6144    Y:851    --    16544    +    128
x
=10   00 00 20 41    X:6145    Y:851    --    16672    +    128
x
=20   00 00 A0 41    X:6146    Y:851    --    16800    +    168
x
=50   00 00 48 42    X:6149    Y:851    --    16968    +    128
x
=100  00 00 C8 42    X:6154    Y:851    --    17096    +    128
x
=200  00 00 48 43    X:6164    Y:851    --    17224    +    178
x
=500  00 00 FA 43    X:6194    Y:851    --    17402    +    128
x
=1000 00 00 7A 44    X:6244    Y:851    --    17530
x
=1047 00 E0 82 44    X:6440    Y:887
x
=1083 00 60 87 44    X:6444    Y:851 
any ideas would be great, Thanks in advance.
Muhab* is offline  
Old 09/21/2014, 01:05   #2
dotCom
 
Devsome's Avatar
 
elite*gold: 9842
The Black Market: 107/0/0
Join Date: Mar 2009
Posts: 16,841
Received Thanks: 4,675
Maybe it helps, because I don't know what you realy want.

Code:
public static void parseWalk(object opacket)
{
	ErrorHandler.AddHandler();

	Packet packet = (Packet)opacket;

	currentWalk result = new currentWalk();
	result.playerId = packet.data.ReadDWORD();
	if (packet.data.ReadBYTE() == 1)
	{
		result.xSector = packet.data.ReadBYTE();
		result.ySector = packet.data.ReadBYTE();

		if (result.ySector == 0x80)
		{
			int x = packet.data.ReadSignedDWORD();
			int z = packet.data.ReadSignedDWORD();
			int y = packet.data.ReadSignedDWORD();

			result.zPos = z;
			result.xCoord = Functions.GetXCoord((int)x, result.xSector);
			result.yCoord = Functions.GetYCoord((int)y, result.ySector);
		}
		else
		{
			short x = packet.data.ReadSignedWORD();
			short z = packet.data.ReadSignedWORD();
			short y = packet.data.ReadSignedWORD();

			result.zPos = (int)z;
			result.xCoord = Functions.GetXCoord((int)x, result.xSector);
			result.yCoord = Functions.GetYCoord((int)y, result.ySector);
		}

		result.distance = Functions.CalcDistance(result.xCoord, result.yCoord);
	}

	Main.UpdateWalk(result);
}

public static int GetXCoord(int posX, int regionX)
{
	return (int)Math.Round((double)((regionX - 135) * 192 + posX / 10));
}

public static int GetYCoord(int posY, int regionY)
{
	return (int)Math.Round((double)((regionY - 92) * 192 + posY / 10));
}

public static int CalcDistance(int XCoord, int YCoord)
	{
	return (int)System.Math.Round(System.Math.Sqrt(Math.Pow((Main.charData.XCoord - XCoord), 2) + Math.Pow((Main.charData.YCoord - YCoord), 2)));
}
Devsome is offline  
Old 09/22/2014, 23:24   #3
 
Muhab*'s Avatar
 
elite*gold: 0
Join Date: Feb 2014
Posts: 885
Received Thanks: 1,419
Quote:
Originally Posted by Devsome View Post
Maybe it helps, because I don't know what you realy want.

Code:
public static void parseWalk(object opacket)
{
	ErrorHandler.AddHandler();

	Packet packet = (Packet)opacket;

	currentWalk result = new currentWalk();
	result.playerId = packet.data.ReadDWORD();
	if (packet.data.ReadBYTE() == 1)
	{
		result.xSector = packet.data.ReadBYTE();
		result.ySector = packet.data.ReadBYTE();

		if (result.ySector == 0x80)
		{
			int x = packet.data.ReadSignedDWORD();
			int z = packet.data.ReadSignedDWORD();
			int y = packet.data.ReadSignedDWORD();

			result.zPos = z;
			result.xCoord = Functions.GetXCoord((int)x, result.xSector);
			result.yCoord = Functions.GetYCoord((int)y, result.ySector);
		}
		else
		{
			short x = packet.data.ReadSignedWORD();
			short z = packet.data.ReadSignedWORD();
			short y = packet.data.ReadSignedWORD();

			result.zPos = (int)z;
			result.xCoord = Functions.GetXCoord((int)x, result.xSector);
			result.yCoord = Functions.GetYCoord((int)y, result.ySector);
		}

		result.distance = Functions.CalcDistance(result.xCoord, result.yCoord);
	}

	Main.UpdateWalk(result);
}

public static int GetXCoord(int posX, int regionX)
{
	return (int)Math.Round((double)((regionX - 135) * 192 + posX / 10));
}

public static int GetYCoord(int posY, int regionY)
{
	return (int)Math.Round((double)((regionY - 92) * 192 + posY / 10));
}

public static int CalcDistance(int XCoord, int YCoord)
	{
	return (int)System.Math.Round(System.Math.Sqrt(Math.Pow((Main.charData.XCoord - XCoord), 2) + Math.Pow((Main.charData.YCoord - YCoord), 2)));
}
That don't really help me since it's for walk packet even it's server side packet, /wp packet is kinda different packet.
/wp packet is somehow encrypted..
however i can't find out how warps encrypted inside gmwpfort.dat maybe it has the solution!
i have mentioned in the first post how /wp packet is and what is the poses for this example and region id.
Thanks for trying to help.
Muhab* is offline  
Old 09/23/2014, 09:12   #4
 
elite*gold: 0
Join Date: Feb 2008
Posts: 962
Received Thanks: 650
Because the X,Y,Z are Floats. If you want to parse/use a packet, there is no need to use float, just send Int32 for each

PHP Code:
Packet.WriteUInt8(0x10);    //static
Packet.WriteUInt8(0);        //static
Packet.WriteUInt16(24744);    //regionID
Packet.WriteInt32(1047);        //x
Packet.WriteInt32(-13);    //y 
Packet.WriteInt32(1196);        //z 
Packet.WriteUInt8(0x01);        //worldID
Packet.WriteUInt8(0);        //static
Agent.Send(Packet); 
Refer to this website for conversions :
magicanoo is offline  
Thanks
1 User
Old 09/23/2014, 15:30   #5
 
Muhab*'s Avatar
 
elite*gold: 0
Join Date: Feb 2014
Posts: 885
Received Thanks: 1,419
Quote:
Originally Posted by magicanoo View Post
Because the X,Y,Z are Floats. If you want to parse/use a packet, there is no need to use float, just send Int32 for each

PHP Code:
Packet.WriteUInt8(0x10);    //static
Packet.WriteUInt8(0);        //static
Packet.WriteUInt16(24744);    //regionID
Packet.WriteInt32(1047);        //x
Packet.WriteInt32(-13);    //y 
Packet.WriteInt32(1196);        //z 
Packet.WriteUInt8(0x01);        //worldID
Packet.WriteUInt8(0);        //static
Agent.Send(Packet); 
Refer to this website for conversions :
Thanks alot dude for pointing that it's a float value.

p.s.WriteInt32 isn't working , i have just added WriteFloat with float value into SilkroadSecurityApi 1.4 source.
Muhab* is offline  
Old 09/26/2014, 16:53   #6
 
Muhab*'s Avatar
 
elite*gold: 0
Join Date: Feb 2014
Posts: 885
Received Thanks: 1,419
Quote:
Originally Posted by xExorcist View Post
I am trying to find out how it works too
but seems like i am recalling my self i teleport [yes] but not to the given cords just to my cords.
you have to confirm your spawn after teleporting.
Muhab* is offline  
Old 09/28/2014, 14:32   #7
dotCom
 
Devsome's Avatar
 
elite*gold: 9842
The Black Market: 107/0/0
Join Date: Mar 2009
Posts: 16,841
Received Thanks: 4,675
Oh /wp command, sorry my fault
I can check it later if you need help.
Devsome is offline  
Old 10/17/2014, 11:15   #8
 
elite*gold: 0
Join Date: Jun 2007
Posts: 79
Received Thanks: 19
pff i got a old php script about this section not sure if its still needed but i post it here for ppl that are looking for it


Code:
        (int) $xCoord = 0;//Cords here
        (int) $yCoord = 0;// Cords here.
 
        (int) $xSector = floor(($xCoord + 0x6540) / 0xC0);
        (int) $ySector = floor(($yCoord + 0x44EC) / 0xC0);
 
        (int) $xPos = ($xCoord - (($xSector - 0x87) * 0xC0)) * 0x0A;
        (int) $yPos = ($yCoord - (($ySector - 0x5C) * 0xC0)) * 0x0A;
 
        (int) $vSector = ((($ySector << 16) | ($xSector & 0xFFFF)) >> 8) + ((($ySector << 16) | ($xSector & 0xFFFF)) & 0xFF);
cyberninjah is offline  
Thanks
1 User
Old 11/19/2014, 01:24   #9
 
elite*gold: 0
Join Date: Feb 2008
Posts: 962
Received Thanks: 650
For the record, the sequence of the coords in the packet is like that :

PHP Code:
                            p13.WriteUInt8(0x10); //static
                            
p13.WriteUInt8(0); //static
                            
p13.WriteInt16(24744); //regionID
                            
p13.WriteSingle(1365); //x
                            
p13.WriteSingle(1334); //Y
                            
p13.WriteSingle(0); //Z
                            
p13.WriteInt8(1); //worldid
                            
p13.WriteUInt8(0); //static 
Also, you can use WriteSingle, no need to implement a new WriteFloat function.
magicanoo is offline  
Old 11/23/2014, 18:44   #10


 
​Exo's Avatar
 
elite*gold: 28
Join Date: Aug 2014
Posts: 4,096
Received Thanks: 2,653
Quote:
Originally Posted by magicanoo View Post
For the record, the sequence of the coords in the packet is like that :

PHP Code:
                            p13.WriteUInt8(0x10); //static
                            
p13.WriteUInt8(0); //static
                            
p13.WriteInt16(24744); //regionID
                            
p13.WriteSingle(1365); //x
                            
p13.WriteSingle(1334); //Y
                            
p13.WriteSingle(0); //Z
                            
p13.WriteInt8(1); //worldid
                            
p13.WriteUInt8(0); //static 
Also, you can use WriteSingle, no need to implement a new WriteFloat function.
Looks like you got that too, was planning to share it later xD
​Exo is offline  
Reply


Similar Threads Similar Threads
new damage calculation
05/16/2014 - Seafight - 17 Replies
Damage calculation bug fix | Seafight this is the latest post from seafight in simple terms what this means is pay 2900 crystals for extra cannons on decks just to cause the same damage as before but using more ammunition, 10% more ammo to be exact. bigpoint have gave us an update to increase damage but took it off us with a fake bug fix. i must say im not very happy with that. would love to hear what everyone else thinks on this.
Exp Calculation
08/21/2011 - CO2 Private Server - 4 Replies
I know this is not real exp calculation and it's custom. Just wondering, if it would be a good way to do it custom. static ulong GetExerience(ulong GainExperience, byte attLevel, byte oppLevel, byte Rate, uint Damage, byte Reborns, byte TeamMembers) { ulong Experience = (attLevel <= oppLevel) ? (GainExperience * Rate) : ((GainExperience / attLevel) * Rate); Experience += (ulong)(Damage ^ (Reborns + oppLevel)) / TeamMembers; return...
Exp calculation?
01/09/2011 - CO2 Programming - 3 Replies
Hey, Does anyone has a decent exp calculation, or show me atleast how it is calculated? I really have no idea when it comes to conquer. Thanks in advance, ImmuneOne.
Damage Calculation
08/02/2010 - CO2 PServer Guides & Releases - 12 Replies
Okay. I haven't found any physical damage calculations out there that involves BP. Maybe nobody wants it or what but Ive been lurking these forums for a while looking for ideas for my server. Anyway, here's my ROUGH (+- 1.5k) damage compared to the real co. If anyone got any ideas on how to improve my equation by all means please post. I use 5165 but the gist of it should be the same as other servers. also, thanks to CoEmu v2, I used some of the damage calculation from there namely the...
Repair Calculation
06/04/2010 - CO2 Private Server - 0 Replies
Here is the correct gold calculation for repairing an item: int nRecoverDurability = Math.Max(0, Item.Stats.Durability - Item.CurDurability); if (nRecoverDurability == 0) return; byte Quality = ItemManipulation.GetQuality((int)Item.Stats.ID); double QualityMultipier = 0;



All times are GMT +1. The time now is 21:32.


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.