-
Notifications
You must be signed in to change notification settings - Fork 0
/
__init__.py
36 lines (28 loc) · 960 Bytes
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
from collections import namedtuple
# Where did these numbers come from? See https://github.com/palworldlol/palworld-coord/blob/main/DEV.md
__transl_x = 123888
__transl_y = 158000
__scale = 459
Point = namedtuple('Point', ['x', 'y'])
def sav_to_map(x: float, y: float) -> Point:
"""
Convert coordinates from the system in .sav files to in-game
coordinate system in Paldex
"""
# Translate
newX = x + __transl_x
newY = y - __transl_y
# NOTE: The X and Y coordinates are flipped on purpose
# Scale down
return Point(x=round(newY/__scale), y=round(newX/__scale))
def map_to_sav(x: int, y: int) -> Point:
"""
Convert coordinates from the in-game coordinates system in
Paldex to the system in .sav files
"""
# Scale up
newX = x * __scale
newY = y * __scale
# NOTE: The X and Y coordinates are flipped on purpose
# Translate
return Point(x=newY - __transl_x, y=newX + __transl_y)