-
Member
[QUESTION] Extracting player coordinates
Hello guys! Currently I try to create a world of warcraft retail(10.5) bot for movement.
I already created a Navemsh for every map, but the world coordinates are not the same as in world of warcraft.
Is there any way I can get the real World coordinates of the player instead of the shitty "map coordinate" what the game provides for me?
Do I need Memory reading to extract this information or can I get it in some other way?
-
Member
Honestly, idk how map coordinates work on retail, but I was using formula to convert map coords to 3d space coords (only X and Y) on 3.3.5
I'm not sure if it will work for botting (it's not very precise because of floating point), but it's still some kind of way to not use memory reading
X1, X2, Y1, Y2 are location borders. I was obtaining mine from Data/Content/WorldMapAreaData.json
Code:
3D SPACE TO MAP:
Get Y1(LocTop), Y2(LocBottom), X1(LocLeft), X2(LocRight):
Y1 = LocTop
Y2 = LocBottom
X1 = LocLeft
X2 = LocRight
Calculate Xdifference and Ydifference:
Xdifference = X2 - X1
Ydifference = Y2 - Y1
Calculate Xspace and Yspace:
Xspace = CharacterX - X1
Yspace = CharacterY - Y1
Calculate Xpercentage and Ypercentage:
Xpercentage = (abs(Xspace) / Xdifference) * 100
Ypercentage = (abs(Yspace) / Ydifference) * 100
Calculate map coordinates:
map_x = Xpercentage
map_y = Ypercentage
________________________________________
MAP TO 3D SPACE:
Get Y1(LocTop), Y2(LocBottom), X1(LocLeft), X2(LocRight):
Y1 = LocTop
Y2 = LocBottom
X1 = LocLeft
X2 = LocRight
Calculate Xdifference and Ydifference:
Xdifference = X2 - X1
Ydifference = Y2 - Y1
Calculate Xpercentage and Ypercentage:
Xpercentage = map_x
Ypercentage = map_y
Calculate Xspace and Yspace:
Xspace = (Xpercentage / 100) * Xdifference
Yspace = (Ypercentage / 100) * Ydifference
Calculate 3D space coordinates:
x_3d = X1 + Xspace
y_3d = Y1 + Yspace
Credits to radarlove (Zones and coordinates --> World to Zone coordinates), tyvm
-
Post Thanks / Like - 1 Thanks
nazmox (1 members gave Thanks to Jirno for this useful post)
-
Member
-
Member
The best way is of course to do as the Unit_GetPosition function does, or calling it diretctly. You can get a player's position like this (for retail):
Code:
Vector3 GetPosition(uintptr_t* unitptr)
{
if (unitptr == nullptr)
{
return Vector3();
}
auto movement_globals = *reinterpret_cast<uintptr_t*>((uintptr_t)unitptr + 176);
return *reinterpret_cast<Vector3*>(movement_globals + 32);
}
Last edited by Mathex; 09-05-2023 at 06:03 AM.
-
Post Thanks / Like - 2 Thanks
-
Member
I'm not really into memory editing in world of warcraft. How can I get the player's unitpointer?
-
Active Member
Odd, because this is the WoW Memory Editing subforum. I suggest that you search for the keywords you're looking for using the search feature, or posting your question in the general Bots + Programs section.
You basically have two options:
1. Do the math yourself and correlate map coordinates to your own coordinate system. This isn't hard, it's just time consuming.
When my bot was pixel based, I started by just extracting map coordinates and plotting them on a scatter plot with the zone map in the background. Actually works pretty well on a zone by zone basis. Math tweaks obviously required.
The problem with this method is that the correlation between zone coords and world coords is fucking random as shit, and changes quite drastically depending on where you are located in game. There isn't a universal algo that I'm aware of that does it for you.
2. Get into memory editing, write about 15 lines of code, and retrieve the values that way. Same as above.
Both options require reading on your part, and all of the information you need is on the forum. Alternatively, you could launch cheat engine and use it to find the values yourself. Which is also not hard, and doesn't require much in the way of effort. Scan for unknown float first scan. Move, scan for changed floats. Scan for unchanged float. Move again. Scan for changed float. Scan for unchanged float. Move. Scan for changed. Scan for unchanged. Repeat repeat repeat. Boom.
Last edited by wardrive; 09-05-2023 at 01:35 PM.
-
Member
Honestly I tried both options. The problem was with the first option was exactly what you said. there is no good conversion between map coordinates and world coordinates. in older versions of wow there was a data file where you can extract the starting and ending coordinates of each map, but now in retail there is no such thing.
I'm currently trying to learn memory editing to get the coordinates from there, but there is no reliable offsets for the object manager in game version 10.1.5 sadly, and I'm not skilled at reverse engineering at all so I cant dump the offsets for myself.
I also tried to extract pointers for coordinates in cheat engine, but I can only extract temporary values what are not even valid if I restart the game because they are not Pointers.
I think I'm pretty much lost now and don't really know how to move forward.
-
Post Thanks / Like - 1 Thanks
Hazzbazzy (1 members gave Thanks to nazmox for this useful post)
-
Active Member
You could try generating a pointermap for the coordinates addresses you find, using Cheat Engine. Then you have to filter out the pointers you found until you find one that doesn't change between client resets. That's a process all by itself.
Or, you could use the offset posts to throw something together that simply returns the current players x,y,z world coordinates. Pretty sure that can be done in less than 15 lines of code in any language.
Which is honestly the answer to your question to begin with.
Last edited by wardrive; 09-06-2023 at 04:07 AM.
-
Member
Yeah the code part is not a problem for me. finding pointers is hard to me. World of warcraft retail is crashing if I attach the debugger of CE to it, so I don't know how to find the pointers. I'm not really familiar with reverse engineering.
Also if I would have the offsets I could write the code, but there is no offset dump for world of warcraft 10.1.7 version ring now.
-
Member
Currently I'm giving up on memory reading version because I don't have the offsets to do this and not skilled enaugh for reverse engineering retail so probably this would a waste of time for me.
My workaround is that I found a dbc file for older versions of world of warcraft.
WoW.tools | Database browser
Credits to wowtools!
I can use this to extract map coordinate borders and I can use the Jirno provided before to convert map coordinates to world coordinates.
This solution is way worst that the memory reading because this file just contains the maps until legion (sadly no shadowlandland dragonflight) but would be a good enaugh solution for everyone for a simle movement system.