[SOLVED] Just Cause 2: Convert world_pos vector to map coordinates

Programming related discussions related to game research
Pickle
Posts: 9
Joined: Thu Jul 14, 2022 6:24 pm

[SOLVED] Just Cause 2: Convert world_pos vector to map coordinates

Post by Pickle »

I've used Rick Gibbed's tools to extract the files from pc0.arc and convert the BIN files to XML. I'm looking at \settings\icons_global.xml and I see lines like this.

Code: Select all

<value name="world_pos" type="vec">-9019.082,486.125,2830.436</value>

This line is the location of a military base named "Kem Komander Sutherland".

My problem is that I have no idea how to take these values and turn them into map coordinates like the ones used in-game. I've looked into vector algebra, but it doesn't appear that these values represent a Euclidean vector. I am certain that the first value is X and the last is Y. The middle value is unknown, but probably Z (altitude).

For reference, the above village is roughly located at (7360,19200) in-game. It's important to note that in-game coordinates do not have pinpoint accuracy due to the way the world map works. The game uses a 2048x2048 pixel image for the world map and the coordinates run from (0,0) in the top-left to (32768,32768) in the bottom-right. This means that each pixel on the map represents 16 meters.

Does anyone have any idea how this world_pos becomes the map coordinates?
Last edited by Pickle on Sun Aug 28, 2022 4:10 pm, edited 1 time in total.
grandshot
Posts: 42
Joined: Mon Jun 07, 2021 8:20 pm

Re: Just Cause 2: Convert world_pos vector to map coordinates

Post by grandshot »

I think it can be not ingame world coords, but its position of icon on 3d map model from PDA. Try to rip this map with 3d Ripper DX, for save forms, and check getted geometry. Maybe it push the mind to the right solution ;)
Pickle
Posts: 9
Joined: Thu Jul 14, 2022 6:24 pm

Re: [SOLVED] Just Cause 2: Convert world_pos vector to map coordinates

Post by Pickle »

Thanks for the reply, grandshot. I forgot the PDA map is 3D; however, 3D Ripper DX won't work because JC2 is a DX10 game. Fortunately, I have found the solution a different way.

I used a memory scanner to find the player position in RAM. The player position uses the exact same coordinates as the world_pos vector. I was then able to determine the following info.

Code: Select all

world_pos vector = (x,z,y)
(0,0,0) is center of map, this is (16384,16384) in map coordinates
North is -Y
South is +Y
East is +X
West is -X

Now converting world_pos to map coordinates is simple.

Code: Select all

Kem Komander Sutherland world_pos = (-9019.082,486.125,2830.436)
X = 16384 + -9019.082 = 7364.918
Y = 16384 + 2830.436 = 19214.436
Kem Komander Sutherland map coordinates = (7364.918,19214.436)

These map coordinates are an exact match to the ones found in JC2MapViewer.