Created
May 24, 2020 10:55
-
-
Save YaLTeR/ff55de15334163fd32daa71af334129b to your computer and use it in GitHub Desktop.
BXT TAS log to HLKZ replay converter
This file contains hidden or 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/python | |
from itertools import chain | |
from os import fdopen | |
from sys import stdin, stdout | |
import json | |
import struct | |
def main(): | |
log = json.load(stdin) | |
it = iter(log['pf']) | |
for frame in it: | |
if 'bxt_timer_start' in frame['cbuf']: | |
break | |
game_time = 0 | |
replay = bytearray() | |
for frame in chain((frame,), it): | |
f = frame['cf'][0] | |
replay.extend(struct.pack( | |
'7fH', | |
game_time, | |
f['postpm']['pos'][0], | |
f['postpm']['pos'][1], | |
f['postpm']['pos'][2], | |
f['view'][1] / -3, | |
f['view'][0], | |
f['view'][2], | |
f['btns'], | |
)) | |
if 'bxt_timer_stop' in frame['cbuf']: | |
break | |
game_time += frame['ft'] | |
with fdopen(stdout.fileno(), 'wb') as f: | |
f.write(replay) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment