This repository has been archived by the owner on Jun 6, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathevtc-remove-reward.py
executable file
·80 lines (65 loc) · 2.2 KB
/
evtc-remove-reward.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
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#!/usr/bin/python3
# Removes reward events from EVTC files. Has to be used on non-compressed
# logs, can be used to batch-process
# This can be useful for testing success detection when reward events
# are not present, for example because this is not the first weekly clear
# Example usage:
# ./evtc-remove-reward.py 20190412-210528.evtc 20190420-204619.evtc
# Will create two files:
# 20190412-210528.evtc-mod
# 20190420-204619.evtc-mod
from sys import argv
import struct
def skip_bytes(f, result, n):
for x in range(n):
byte = f.read(1)
if byte == b"":
return False
result.write(byte)
return True
def read_byte(f, result):
byte = f.read(1)
result.write(byte)
return byte
def read_int(f, result):
b = f.read(4)
result.write(b)
agent_count, = struct.unpack('i', b)
return agent_count
def remove_reward(filename):
print(f"Removing reward from {filename}")
with open(filename, "rb") as f:
with open(filename + "-mod", "wb") as result:
# Header
skip_bytes(f, result, 12)
revision = read_byte(f, result)
assert revision == b"\x01", "Can only handle revision 1"
print(f"Revision {revision}")
skip_bytes(f, result, 3)
# Agents
agent_count = read_int(f, result)
print(f"Agent count: {agent_count}")
for _ in range(agent_count):
skip_bytes(f, result, 96)
# Skills
skill_count = read_int(f, result)
print(f"Skill count: {skill_count}")
for _ in range(skill_count):
skip_bytes(f, result, 68)
combatitem_count = 0
while True:
b = f.read(64)
if (b == b""):
break
activation = b[56]
if (int(activation) == 17):
print(f"Reward on item {combatitem_count}, removing")
else:
result.write(b)
combatitem_count += 1
print(f"Combat item count: {combatitem_count}")
for filename in argv[1:]:
try:
remove_reward(filename)
except Exception as e:
print(e)