forked from ACEmulator/ACE
-
Notifications
You must be signed in to change notification settings - Fork 1
Landblocks and Cartesian Coordinates
aquafir edited this page Dec 28, 2021
·
3 revisions
Outdoor positions in ACE involve a landblock (0-255 for X and Y, further divided into squares/cells) and a position offset (float X, Y, and Z).
Using the /loc
command you get the landblock and cell in a DWORD, followed by the position, followed by a quaternion for the rotation:
13.3N, 34.9E-->
0xAB900001 [10.000000 10.000000 44.005001] ...
AB 90 0001 [10.000000 10.000000 44.005001]
lbX lbY cell positionX positionY positionZ
Cartesian coordinates fall within -102 and +102, starting from the bottom-left (SW) and ending at the top-right (NE). The conversion between units is:
- 1 landblock = 192 meters
- 1 landblock = 0.8 map units
- 1 map unit = 1.25 landblocks
- 1 map unit = 240 meters
To convert from an outdoor landblock and position to a cartesian location you could use this:
void ConvertToCartesian(uint rawLandblock, float positionX, float positionY, out float coordX, out float coordY) {
uint landblockX = ((rawLandblock>> 24) & 0xFF);
uint landblockY = ((rawLandblock >> 16) & 0xFF);
coordX = (landblockX * 192 + positionX) / 240 - 102;
coordY = (landblockY * 192 + positionY) / 240 - 102;
}
To check if a landblock and cell are indoors you mask out the landblock and check if the cell is above 0x0100: bool indoors = (rawLandblock & 0x0000FFFF) >= 0x100;