Jump to content

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

 //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>($@"
                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 

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...