Jump to content
This site uses cookies! Learn More

This site uses cookies!

By continuing to use this site, you agree to allow us to store cookies on your computer. :)

Sorato

[WOTLK] Get World Coordinates From Map Coords

Recommended Posts

Hello guys,

i wanted to ask how i can get World Coords from Map Coords + Zone?
i just found the Lua Function: GetWorldLocFromMapPos but it was introduced with patch 5.0.4 or so, so does not work with 3.3.5a.

Do someone have any idea?

Thanks

Share this post


Link to post
Share on other sites
 //https://www.ownedcore.com/forums/world-of-warcraft/world-of-warcraft-bots-programs/wow-memory-editing/382790-zones-coordinates-world-zone-coordinates.html
        //somehow (ObjectManager.Me.Position.Y - x1) / (x2 - x1) is the character's on-map X position (notice the Y)
        //reversing that formula, you can get playerX (world position) based on all y values, it's utterly confusing and makes no sense to me
        private Vector3 CalculateMapCoords(string luaUnit)
        {
            float mapX = Lua.LuaDoString<float>([email protected]"
                local x, y = GetPlayerMapPosition('{luaUnit}');
                return x;
            ");
            float mapY = Lua.LuaDoString<float>(@"
                local x, y = GetPlayerMapPosition('{luaUnit}');
                return y;
            ");

            return CalculateFromMapPosition(mapX, mapY);
        }

        private Vector3 CalculateFromMapPosition(float mapX, float mapY)
        {
            var x1 = 2041.67f;
            var x2 = 895.833f;
            var y1 = 1627.08f;
            var y2 = 862.5f;

            var playerX = -mapY * y1 + mapY * y2 + y1;
            var playerY = -mapX * x1 + mapX * x2 + x1;
            
            return new Vector3(playerX, playerY, PathFinder.GetZPosition(new Vector3(playerX, playerY, 100)));
        }

Coordinates in there are hardcoded for warsong gulch. It's up to you to adjust this 

Share this post


Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


×
×
  • Create New...