Skip to content

Instantly share code, notes, and snippets.

@psykzz
Created March 7, 2017 00:21
Show Gist options
  • Save psykzz/fcfa326a1186e3af8f3d5bc49b682dbb to your computer and use it in GitHub Desktop.
Save psykzz/fcfa326a1186e3af8f3d5bc49b682dbb to your computer and use it in GitHub Desktop.
Example parsing the evtc from arcdps gw2
import struct
class Parser(object):
def __init__(self, filepath):
with open(filepath, 'rb') as fh:
self.parse(fh)
def parse(self, fh):
fh.read(4) # skip random EVTC tag
version = fh.read(8)
fh.read(1) # skip
inst_id = struct.unpack("<h", fh.read(2))[0]
fh.read(1) # skip
player_count = struct.unpack("<i", fh.read(4))[0]
for i in range(player_count):
agent = struct.unpack("<q", fh.read(8))[0]
prof = struct.unpack("<i", fh.read(4))[0]
elite = struct.unpack("<i", fh.read(4))[0]
tough = struct.unpack("<i", fh.read(4))[0]
healing = struct.unpack("<i", fh.read(4))[0]
condi = struct.unpack("<i", fh.read(4))[0]
name = fh.read(68)
if elite != -1:
print("%s - %s :: %s %s %s" % (elite, name, tough, healing, condi))
print(version)
print(inst_id)
print(player_count)
if __name__ == '__main__':
p = Parser('./test.evtc')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment