-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathclagger.py
More file actions
55 lines (51 loc) · 1.68 KB
/
clagger.py
File metadata and controls
55 lines (51 loc) · 1.68 KB
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
# -*- coding: utf-8 -*-
"""
Created on Mon Feb 10 19:09:06 2020
@author: AsteriskAmpersand
"""
from Cstruct import PyCStruct
from collections import OrderedDict
from Chunk import chunkPath
from pathlib import Path
from FileLike import FileLike
class Header(PyCStruct):
fields = OrderedDict([
("IB" , "byte[4]"),
("unkn0" , "int32"),
("cnt" , "int32"),])
class Clagger(PyCStruct):
fields = OrderedDict([
("unkn0" , "int32"),
("normal" , "float"),
("enrage" , "float"),
("fatigue" , "float"),
("hpRangeMod" ,"float[10]"),
("lowr" , "float"),
("highr" , "float"),
("masterr" , "float"),])
def __repr__(self):
return ','.join([str(getattr(self,f)) for f in self.fields if "unkn" not in f])
def header(self):
return ','.join([f for f in self.fields.keys() if "unkn" not in f])
class Trail(PyCStruct):
fields = OrderedDict([
("unkn" , "int32[3]")])
class ClaggerCommon():
defaultPath = Path(chunkPath).joinpath(r"common\em\em_clawgrab_common.dtt_clawc")
def __init__(self):
self.Header = Header()
self.ClaggerTables = []
def marshall(self,data):
self.Header.marshall(data)
self.ClaggerTables = [Clagger().marshall(data) for i in range(self.Header.cnt)]
self.Trail = Trail().marshall(data)
@staticmethod
def open(filepath = None):
if filepath is None:
filepath=ClaggerCommon.defaultPath
clag = ClaggerCommon()
with open(filepath,"rb") as inf:
clag.marshall(FileLike(inf.read()))
return clag
def __getitem__(self,ix):
return self.ClaggerTables[ix]