forked from victorvde/dota2_nohats
-
Notifications
You must be signed in to change notification settings - Fork 0
/
mdl_kv.py
49 lines (38 loc) · 1.03 KB
/
mdl_kv.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
37
38
39
40
41
42
43
44
45
46
47
48
49
from mdl import MDL
from argparse import ArgumentParser, FileType
from io import SEEK_END
def model_set_kv(s, kv):
m = MDL()
m.unpack(s)
s.seek(0, SEEK_END)
b = kv.encode("ascii") + b"\0"
print(kv)
print(s.tell())
print(len(b))
m["keyvalueindex"].data = s.tell()
m["keyvaluesize"].data = len(b)
s.write(b)
s.seek(0)
m.pack(s)
def model_attach_effect(s, effect, attachment):
new_kv = """mdlkeyvalue
{{
particles {{
effect {{
"name" "{}"
"attachment_type" "follow_attachment"
"attachment_point" "{}"
}}
}}
}}
""".format(effect, attachment)
model_set_kv(s, new_kv)
def main():
parser = ArgumentParser(description="Add an effect to a model")
parser.add_argument("model_file", type=FileType("r+b"))
parser.add_argument("effect_name")
parser.add_argument("attachment")
args = parser.parse_args()
model_attach_effect(args.model_file, args.effect_name, args.attachment)
if __name__ == "__main__":
main()