Created
March 12, 2021 17:59
-
-
Save hexparrot/5bc36913f377a35be14fb9d12d7a1fb3 to your computer and use it in GitHub Desktop.
Valheim Coord Finder
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
from collections import namedtuple, defaultdict | |
Coord = namedtuple('Coord', 'x y z') | |
def byte_to_coord(bytestr, start_pos): | |
x = slice(start_pos+0, start_pos+4) | |
z = slice(start_pos+4, start_pos+8) | |
y = slice(start_pos+8, start_pos+12) | |
import struct | |
return Coord(struct.unpack('f', bytestr[x]), | |
struct.unpack('f', bytestr[y]), | |
struct.unpack('f', bytestr[z])) | |
def return_offsets(bytestr, search_string): | |
ss = bytes(search_string, 'utf-8') | |
offset = 0 | |
while True: | |
try: | |
pos = buf.index(ss, offset) | |
offset = pos + len(ss) | |
yield offset | |
except ValueError: | |
break | |
SPAWNS = { | |
'bosses': ['Eikthyrnir', 'GoblinKing', 'GDKing', 'Bonemass', 'Dragonqueen'], | |
'poi': ['Vendor_BlackForest'], | |
'crypts': ['SunkenCrypt4', 'Crypt2', 'Ruin1', 'Ruin2', 'Ruin3'], | |
} | |
RETURN_LOCS = SPAWNS['poi'] #change me to any of the entries in SPAWNS | |
buf = open('Dedicated.db', 'rb').read() #change me to your world name file | |
locations = defaultdict(Coord) | |
for p in RETURN_LOCS: | |
locations[p] = [byte_to_coord(buf, f) for f in return_offsets(buf, p)] | |
for k,v in locations.items(): | |
print(k) | |
for each in v: | |
print(each) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment