Register for your free account! | Forgot your password?

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

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

Advertisement



[Help] Calculation of coordinates in dungeons

Discussion on [Help] Calculation of coordinates in dungeons within the SRO Coding Corner forum part of the Silkroad Online category.

Reply
 
Old   #1
 
elite*gold: 0
Join Date: Mar 2009
Posts: 48
Received Thanks: 75
Question [Help] Calculation of coordinates in dungeons

Hey guys,
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();
                }
Step 2: Calculating the absolute X,Y Position:

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);
            }
        }
Step 3: Failing
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
Attached Files
File Type: txt Position.cs.txt (5.8 KB, 11 views)
torstmn is offline  
Old 04/17/2018, 21:15   #2
 
elite*gold: 11
Join Date: May 2009
Posts: 617
Received Thanks: 589
there isnt any diference on calculating gameworld coordinates but only x y z coordinates are in double-word (just read it as 32bit dont do readshort() - readshort())

edit:
also my advices to you are:
1-Do not split region to x sector & y sector. Store them as Region.
2-Change your coordinate namings: Y is used for depth, X Z is for 2D coordinate projection. (in packet order X-Y-Z)
3-"public bool IsInDungeon => YSector == 0x80;" dungeons are not identified by ysector == 128. Its identified by MSB of region. So you must use "public bool IsInDungeon => Region & 0x8000 != 0"
4-Don't use "class" for Position, use struct instead. In .NET classes are allocated with gcnew but structs are not if you don't do it especially. This decreases your performance.
qoaway is offline  
Reply

Tags
calculation, position, silkroad


Similar Threads Similar Threads
[Help] Warp packet calculation (/wp)
11/23/2014 - SRO Coding Corner - 9 Replies
Hello epvp.. today am working on warp packet calculations it's kinda weird. however: here is a simple packet 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)
[INT] Z calculation in dungeons/emok/etc.
01/02/2011 - Kal Online - 3 Replies
Hi peeps, I've been trying to play a little with z coords. Bakabugs (:handsdown:) height thingy works like a charm except for when you are inside dungeons/emok/etc. Does anyone know if there is a simulair function for getting height in dungeons etc.?
[Help] CoEmu 2 TwoFolds Blade Calculation
06/14/2009 - CO2 Private Server - 8 Replies
Hi, Any one knows or guide me on how and what .cs for the TwoFolds Blade calculation damage, cause i tried having +12's and SDGs and it only damages "1" on players but works on mobs... Thanks



All times are GMT +1. The time now is 19:47.


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.