it has been long since I was active for the last time but now I try to continue developing my bot (RSBot). During development I had the following issue:
I have a class "Postion" that tries to accomplish the task of calculating wether offsets or "real" coordinates. It does that very well but as soon as I enter a dungeon the calculation fu**ed up a little. This is not caused by missinterpreted packetsbut I think it's the calculation of the XCoordinate (absolute position).
Is there a different formular for dungeon coordinates I don't know about maybe?
Since im no genius in math, it would be great if you guys could help me a little.
I will attach the Position.cs class to this post.
In addition to that, I want to give you a little code example:
Step 1: Reading the packet
Code:
result.Destination = new Position
{
XSector = packet.ReadByte(),
YSector = packet.ReadByte(),
};
if (result.Destination.RegionID < short.MaxValue)
{
result.Destination.XOffset = packet.ReadShort();
result.Destination.YOffset = packet.ReadShort();
result.Destination.ZOffset = packet.ReadShort();
}
else
{
//The player is in a dungeon
result.Destination.XOffset = packet.ReadShort() - packet.ReadShort();
result.Destination.YOffset = packet.ReadShort() - packet.ReadShort();
result.Destination.ZOffset = packet.ReadShort() - packet.ReadShort();
}
Code:
/// <summary>
/// Gets or sets the x coordinate.
/// </summary>
/// <value>
/// The x coordinate.
/// </value>
public float XCoordinate
{
get
{
return (XSector - 135) * 192 + (XOffset / 10);
}
set
{
XSector = XSectorFromX(value);
XOffset = XOffsetFromX(value);
}
}
/// <summary>
/// Gets or sets the y coordinate.
/// </summary>
/// <value>
/// The y coordinate.
/// </value>
public float YCoordinate
{
get
{
return (YSector - 92) * 192 + (ZOffset / 10);
}
set
{
YSector = YSectorFromY(value);
ZOffset = YOffsetFromY(value);
}
}
I actually have checked up the absolute positions inside a cave with phBot. Result are the following:
Pos-X: -24196.2
Pos-Y: 641.2
While my positions look like this:
Pos-X: -25540
Pos-Y: 7553
Here is the paste of the complete Position.cs file:

So yeah, I realy could need your help here...
Thanks in advance







