-
Notifications
You must be signed in to change notification settings - Fork 9
/
logs_damage_specific.py
303 lines (261 loc) · 9.03 KB
/
logs_damage_specific.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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
from collections import defaultdict
from typing import TypedDict
from h_debug import running_time
FESTER_SPAMMERS = {
0, # Death Knight
1, # Blood
2, # Frost
3, # Unholy
4, # Druid
5, # Balance
6, # Feral Combat
7, # Restoration
8, # Hunter
9, # Beast Mastery
10, # Marksmanship
11, # Survival
15, # Frost
16, # Paladin
17, # Holy
# 18, # Protection
19, # Retribution
22, # Holy
31, # Restoration
36, # Warrior
37, # Arms
38, # Fury
# 39, # Protection
}
class ValksDamage(TypedDict):
overkill: defaultdict[str, int]
useful: defaultdict[str, int]
class FesterPlayerDamage:
__slots__ = "stacks", "increased_by", "useful", "total"
def __init__(self) -> None:
self.stacks = 0
self.increased_by = 1.0
self.useful = 0
self.total = 0
def change_stacks(self, flag: str):
if flag == "SPELL_AURA_APPLIED_DOSE":
self.stacks += 1
elif flag == "SPELL_AURA_APPLIED":
self.stacks = 1
elif flag == "SPELL_AURA_REMOVED":
self.stacks = 0
else:
return
self.increased_by = 1 + self.stacks / 10
def add_damage(self, damage: int, overkill: int):
self.total += damage
self.useful += int(damage / self.increased_by) - overkill
@running_time
def _fester_useful(logs_slice: list[str]):
players: defaultdict[str, FesterPlayerDamage] = defaultdict(FesterPlayerDamage)
for line in logs_slice:
if ",72553," in line:
_, flag, _, _, target_guid, _ = line.split(',', 5)
players[target_guid].change_stacks(flag)
continue
if "DAMAGE" not in line:
continue
_line = line.split(',', 11)
if _line[4][6:12] != "008F12":
continue
try:
dmg = int(_line[9])
overkill = int(_line[10])
players[_line[2]].add_damage(dmg, overkill)
except ValueError:
pass
return players
@running_time
def fester_useful(logs_slice: list[str], specs: dict[str, int]):
players_damage = _fester_useful(logs_slice)
d = {}
for guid, player in players_damage.items():
spec = specs.get(guid)
if spec == 1 and player.useful < 2_000_000:
d[guid] = player.total
elif spec in FESTER_SPAMMERS:
d[guid] = player.useful
else:
d[guid] = player.total
return d
def _is_valk(guid: str):
return guid[6:-6] == '008F01'
def dmg_gen_valk(logs: list[str]):
casted_life_siphon = {}
for line in logs:
if '8F01' not in line:
continue
if "_DAMAGE" not in line:
continue
_, _, source_guid, _, target_guid, _, _, _, _, damage, _ = line.split(',', 10)
if target_guid in casted_life_siphon:
pass
elif _is_valk(target_guid):
yield source_guid, target_guid, int(damage)
elif _is_valk(source_guid):
casted_life_siphon[source_guid] = True
@running_time
def get_valks_dmg(logs: list[str], half_hp=2992500 // 2) -> ValksDamage:
valks_useful = defaultdict(int)
valks_overkill = defaultdict(int)
valks_dmg_taken = defaultdict(int)
for sGUID, tGUID, amount in dmg_gen_valk(logs):
_dmg_taken = valks_dmg_taken[tGUID]
if _dmg_taken == -1:
valks_overkill[sGUID] += amount
continue
current_dmg_taken = _dmg_taken + amount
if current_dmg_taken < half_hp:
valks_dmg_taken[tGUID] = current_dmg_taken
else:
valks_dmg_taken[tGUID] = -1
overkill = current_dmg_taken - half_hp
amount -= overkill
valks_overkill[sGUID] += overkill
valks_useful[sGUID] += amount
return {
'overkill': valks_overkill,
'useful': valks_useful,
}
# 8/31 20:12:36.834 SPELL_PERIODIC_HEAL,00808A000A6D,"Freya",0x10a48,00808A000A6D,"Freya",0x10a48,62528,"Touch of Eonar",0x1,42000,14075,0,nil
# 9/ 1 20:26:43.762 SPELL_PERIODIC_HEAL,00808A000CC3,"Freya",0x10a48,00808A000CC3,"Freya",0x10a48,62892,"Touch of Eonar",0x1,218400,143919,0,nil
def freya_useful(logs_slice: list[str]):
FREYA = "00808A"
DAMAGE: defaultdict[str, int] = defaultdict(int)
healing = True
for line in logs_slice:
if FREYA not in line:
continue
if healing:
if "SPELL_PERIODIC_HEAL" in line and line.split(',', 11)[10] == '0':
healing = False
continue
if "DAMAGE" not in line:
continue
try:
_, _, sGUID, _, tGUID, _, _, _, _, dmg, _ = line.split(',', 10)
if tGUID[6:-6] == FREYA:
DAMAGE[sGUID] += int(dmg)
except ValueError:
pass
return DAMAGE
@running_time
def iron_useful(logs_slice: list[str]):
DAMAGE = {
"008059": defaultdict(int), # Stormcaller Brundir
"00809F": defaultdict(int), # Runemaster Molgeim
"008063": defaultdict(int), # Steelbreaker
}
dead = {
guid: False
for guid in DAMAGE
}
def died_reset_not_dead(target_guid_id: str):
dead[target_guid_id] = True
for guid_id, v in dead.items():
if not v:
DAMAGE[guid_id].clear()
for line in logs_slice:
if "0080" not in line:
continue
if "UNIT_DIED" in line:
tGUID = line.split(',', 5)[4]
target_guid_id = tGUID[6:-6]
died_reset_not_dead(target_guid_id)
continue
if "DAMAGE" not in line:
continue
try:
_, _, sGUID, _, tGUID, _, _, _, _, dmg, ok, _ = line.split(',', 11)
target_guid_id = tGUID[6:-6]
if target_guid_id not in DAMAGE:
continue
DAMAGE[target_guid_id][sGUID] += int(dmg)
if ok != "0":
died_reset_not_dead(target_guid_id)
except ValueError:
pass
return DAMAGE
def kologarn_hands_absorb(logs_slice: list[str]):
RIGHT_ARM = "0080A6"
DAMAGE: defaultdict[str, int] = defaultdict(int)
for line in logs_slice:
if "ABSORB" not in line:
continue
try:
_line = line.split(',', 10)
if _line[4][6:-6] != RIGHT_ARM:
continue
DAMAGE[_line[2]] += int(_line[-1])
except ValueError:
pass
return DAMAGE
def valks_shield(logs_slice: list[str]):
VALKS = {"0086C0", "0086C1"}
DAMAGE: defaultdict[str, int] = defaultdict(int)
for line in logs_slice:
if "ABSORB" not in line:
continue
try:
_line = line.split(',', 10)
if _line[4][6:-6] not in VALKS:
continue
DAMAGE[_line[2]] += int(_line[-1])
except ValueError:
pass
return DAMAGE
def specific_useful(logs_slice, boss_name, specs):
data: dict[str, defaultdict[str, int]] = {}
if boss_name == "The Lich King":
valks_dmg = get_valks_dmg(logs_slice)
data['008F01'] = valks_dmg['useful']
elif boss_name == "Freya":
data['00808A'] = freya_useful(logs_slice)
elif boss_name == "Festergut":
data['008F12'] = fester_useful(logs_slice, specs)
elif boss_name == "Twin Val'kyr":
data['0086C2'] = valks_shield(logs_slice)
elif boss_name == "Kologarn":
data['0080A6'] = kologarn_hands_absorb(logs_slice)
elif boss_name == "Assembly of Iron":
data |= iron_useful(logs_slice)
return data
def test1():
import logs_base
report = logs_base.THE_LOGS("24-05-10--21-04--Jengo--Lordaeron")
s, f = report.ENCOUNTER_DATA["Festergut"][-1]
logs_slice = report.LOGS[s:f]
players_damage = fester_useful(logs_slice)
d = sorted(players_damage.items(), key=lambda x: x[1], reverse=True)
for guid, value in d:
print(f"{report.guid_to_name(guid):12} | {value:>10.0f}")
def test2():
import logs_base
report = logs_base.THE_LOGS("24-11-12--17-27--Zazatree--Whitemane-Frostmourne")
boss = "Assembly of Iron"
s, f = report.ENCOUNTER_DATA[boss][-1]
logs_slice = report.LOGS[s:f+1000]
_damage = iron_useful(logs_slice)
for boss, players_damage in _damage.items():
print()
print(boss)
d = report.combine_pets(players_damage, trim_non_players=True)
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
for guid, value in d:
print(f"{report.guid_to_name(guid):12} | {value:>10.0f}")
def test3():
import logs_base
report = logs_base.THE_LOGS("24-11-12--17-27--Zazatree--Whitemane-Frostmourne")
s, f = report.ENCOUNTER_DATA["Kologarn"][-1]
logs_slice = report.LOGS[s:f]
players_damage = kologarn_hands_absorb(logs_slice)
d = report.combine_pets(players_damage, trim_non_players=True)
d = sorted(d.items(), key=lambda x: x[1], reverse=True)
# for guid, value in d:
# print(f"{report.guid_to_name(guid):12} | {value:>10.0f}")
if __name__ == "__main__":
test3()