-
Notifications
You must be signed in to change notification settings - Fork 0
/
parse.lua
1738 lines (1571 loc) · 48.9 KB
/
parse.lua
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
-- A pure combat meter for the Sophisticated, the High Class, the Extraordinairy.
CombatLog_LoadUI()
local time = time
local date = date
local bit = bit
local CombatLogGetCurrentEventInfo = CombatLogGetCurrentEventInfo
local GetPlayerInfoByGUID = GetPlayerInfoByGUID
local C_ClassColor = C_ClassColor
local COMBATLOG_DEFAULT_COLORS = COMBATLOG_DEFAULT_COLORS
local COMBATLOG_OBJECT_AFFILIATION_MASK = COMBATLOG_OBJECT_AFFILIATION_MASK
local UnitGUID = UnitGUID
local COMBATLOG_OBJECT_AFFILIATION_RAID = COMBATLOG_OBJECT_AFFILIATION_RAID
local COMBATLOG_OBJECT_SPECIAL_MASK = COMBATLOG_OBJECT_SPECIAL_MASK
local COMBATLOG_OBJECT_NONE = COMBATLOG_OBJECT_NONE
local COMBATLOG_OBJECT_TYPE_GUARDIAN = COMBATLOG_OBJECT_TYPE_GUARDIAN
local COMBATLOG_OBJECT_TYPE_PET = COMBATLOG_OBJECT_TYPE_PET
local MAX_BARS = 14
local BAR_HEIGHT = 22
local WINDOW_WIDTH = 450
local UPDATE_INTERVAL = 1
local COMBAT_END_TIMER = 5
local LEVEL_HISTORY = "history"
local LEVEL_METRIC = "metric"
local LEVEL_ACTOR = "actor"
local LEVEL_SUMMARY = "summary"
local LEVEL_DETAILS = "details"
local capturing = false
local replay = 1
local pretty_time = function(ugly_time)
if not ugly_time then return "" end
if (ugly_time > 60) then
return ("%dm %ds"):format(math.floor(ugly_time / 60), ugly_time % 60)
else
return ("%ds"):format(ugly_time)
end
end
local pretty_number = function(ugly_number)
if not ugly_number then return "" end
if (ugly_number >= 1e9) then
return ("%.2fb"):format(ugly_number / 1e9)
elseif (ugly_number >= 1e6) then
return ("%.2fm"):format(ugly_number / 1e6)
elseif (ugly_number >= 1e3) then
return ("%.2fk"):format(ugly_number / 1e3)
else
return ("%d"):format(ugly_number)
end
end
local backdrop = {
bgFile = [[Interface\Buttons\WHITE8x8]],
edgeFile = [[Interface\Buttons\WHITE8x8]],
tile = false,
tileSize = 0,
edgeSize = 1,
insets = {
left = 0,
right = 0,
top = 0,
bottom = 0
},
}
local gen_backdrop = function(frame, ...)
if not frame.SetBackdrop then
Mixin(frame, BackdropTemplateMixin)
end
if ... == nil then
frame:SetBackdrop(nil)
return
end
frame:SetBackdrop(backdrop)
frame:SetBackdropBorderColor(0, 0, 0, 1)
if (...) then
frame:SetBackdropColor(...)
else
frame:SetBackdropColor(.15, .15, .15, 1)
end
end
local gen_string = function(parent, size, flags, font, h_justify, v_justify, name)
local string = parent:CreateFontString(name, "OVERLAY")
string:SetFont(font or [[Interface\Addons\Parse\Media\gotham_ultra.ttf]], size or 15, flags or "THINOUTLINE")
if h_justify then
if h_justify == "MIDDLE" then h_justify = "CENTER" end
string:SetJustifyH(h_justify)
end
if v_justify then
if v_justify == "CENTER" then v_justify = "MIDDLE" end
string:SetJustifyV(v_justify)
end
return string
end
local gen_statusbar = function(parent, w, h, fg_color, bg_color)
local bar = CreateFrame("StatusBar", nil, parent, BackdropTemplateMixin and "BackdropTemplate")
bar:SetSize(w, h)
bar:SetStatusBarTexture([[Interface\Buttons\WHITE8x8]])
bar:SetBackdrop(backdrop)
bar:GetStatusBarTexture():SetDrawLayer("BORDER", -1);
bar:SetBackdropBorderColor(0, 0, 0, 1)
if fg_color then
bar:SetStatusBarColor(unpack(fg_color))
end
if bg_color then
bar:SetBackdropColor(unpack(bg_color))
else
bar:SetBackdropColor(.15, .15, .15, 1)
end
return bar
end
local color_actor = function(actor)
if actor.guid and string.len(actor.guid) > 0 then
local _, class = GetPlayerInfoByGUID(actor.guid)
if class then
return C_ClassColor.GetClassColor(class)
else
return {r = .5, g = .5, b = .5}
end
else
return {r = .5, g = .5, b = .5}
end
end
local update_action_details = function(current, state, parse)
local action = state[LEVEL_SUMMARY].context
-- TODO metrics without detail level
if not action.hits then
return
end
local i = 1
if action.hits[false][false].count + action.hits[false][true].count > 0 then
parse.bars[i].name_text:SetText((action.hits[false][false].count + action.hits[false][true].count).." hits")
parse.bars[i].description:SetText(pretty_number(action.hits[false][false].total + action.hits[false][true].total))
parse.bars[i]:SetValue(1)
parse.bars[i]:SetStatusBarColor(.75, .75, .75)
parse.bars[i]:Show()
i = i + 1
parse.bars[i].name_text:SetText(string.format(" %d normal", action.hits[false][false].count))
parse.bars[i].description:SetText(string.format("%s / %s / %s", pretty_number(action.hits[false][false].lowest), pretty_number(action.hits[false][false].average), pretty_number(action.hits[false][false].highest)))
parse.bars[i]:SetValue(1)
parse.bars[i]:SetStatusBarColor(.5, .5, .5)
parse.bars[i]:Show()
i = i + 1
parse.bars[i].name_text:SetText(string.format(" %d crit", action.hits[false][true].count))
parse.bars[i].description:SetText(string.format("%s / %s / %s", pretty_number(action.hits[false][true].lowest), pretty_number(action.hits[false][true].average), pretty_number(action.hits[false][true].highest)))
parse.bars[i]:SetValue(1)
parse.bars[i]:SetStatusBarColor(.5, .5, .5)
parse.bars[i]:Show()
i = i + 1
end
if action.hits[true][false].count + action.hits[true][true].count > 0 then
parse.bars[i].name_text:SetText((action.hits[true][false].count + action.hits[true][true].count).." ticks")
parse.bars[i].description:SetText(pretty_number(action.hits[true][false].total + action.hits[true][true].total))
parse.bars[i]:SetValue(1)
parse.bars[i]:SetStatusBarColor(.75, .75, .75)
parse.bars[i]:Show()
i = i + 1
parse.bars[i].name_text:SetText(string.format(" %d normal", action.hits[true][false].count))
parse.bars[i].description:SetText(string.format("%s / %s / %s", pretty_number(action.hits[true][false].lowest), pretty_number(action.hits[true][false].average), pretty_number(action.hits[true][false].highest)))
parse.bars[i]:SetValue(1)
parse.bars[i]:SetStatusBarColor(.5, .5, .5)
parse.bars[i]:Show()
i = i + 1
parse.bars[i].name_text:SetText(string.format(" %d crit", action.hits[true][true].count))
parse.bars[i].description:SetText(string.format("%s / %s / %s", pretty_number(action.hits[true][true].lowest), pretty_number(action.hits[true][true].average), pretty_number(action.hits[true][true].highest)))
parse.bars[i]:SetValue(1)
parse.bars[i]:SetStatusBarColor(.5, .5, .5)
parse.bars[i]:Show()
i = i + 1
end
for b = i, MAX_BARS do
parse.bars[b]:Hide()
end
end
--[[ metric handler
local METRIC_NAME = {
-- string that represents the metric on the metric list
label = "Display Name",
-- array of combat log event strings mapped to true that this metric handles
filter = {
["EVENT"] = true,
},
-- return a new actor level data object for the metric, include member 'total' as a value to sort by
new_actor = function()
return {
total = 0,
}
end,
-- return the actors of the history segment to rank for this metric (group vs outside)
actor_list = function(segment)
return segment.group
end,
-- return the summary entries for the actors (like spells for damage, sources for damage done to)
summary_list = function(actors)
return actors[1].actions
end,
-- return a color for the summary entry
summary_color = function(summary)
return {r = .5, g = .5, b = .5}
end,
-- draw the details level view
draw_details = function(
current, -- the currently active display state level
state, -- the display state
parse) -- the window, to access the parse.bars with
end,
-- return true if the event would start a new combat segment
handle_combatlog_event = function(
self,
event,
source, -- event's source actor
target, -- event's target actor
params) -- event params from the combat log event
return true
end
}
]]
local METRIC_DMG_DONE = {
new_action = function(self, id, name, school)
return {
id = id,
name = name,
school = school,
owner = nil,
total = 0,
higher = nil,
lower = nil,
hits = {
-- tick
[true] = {
-- crit
[true] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
},
-- hit
[false] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
}
},
-- direct
[false] = {
-- crit
[true] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
},
-- hit
[false] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
}
},
},
}
end,
label = "Damage",
filter = {
["SWING_DAMAGE"] = true,
["RANGE_DAMAGE"] = true,
["SPELL_DAMAGE"] = true,
["SPELL_PERIODIC_DAMAGE"] = true,
["SPELL_PERIODIC_MISSED"] = true,
["SWING_MISSED"] = true,
["RANGE_MISSED"] = true,
["SPELL_MISSED"] = true,
},
new_actor = function()
return {
total = 0,
actions = {},
}
end,
actor_list = function(segment)
return segment.group
end,
summary_list = function(actors)
local actions = {}
for _, actor in ipairs(actors) do
for _, action in pairs(actor.actions) do
table.insert(actions, action)
end
end
return actions
end,
draw_details = update_action_details,
summary_color = function(summary)
return COMBATLOG_DEFAULT_COLORS.schoolColoring[summary.school]
end,
handle_combatlog_event = function(self, event, source, target, params)
-- only show damage for existing friendly group members, and exclude damage dealt to self
if not params[4] or params[4] == "" or bit.band(params[6], COMBATLOG_OBJECT_AFFILIATION_MASK) > COMBATLOG_OBJECT_AFFILIATION_RAID or params[4] == params[8] then
return false
end
local source_metric = source.metrics[self.label]
local target_metric = target.metrics[self.label]
local tick, spell_id, spell_name, spell_school, amount, overkill, critical, absorbed
if string.find(event, "SWING") then
if string.find(event, "MISSED") then
if params[12] == "ABSORB" then
amount, critical = params[14], params[15]
else
return true
end
else
amount, overkill, absorbed, critical = params[12], params[13], params[17], params[18]
end
spell_id, spell_name, spell_school = 0, MELEE, 1
else
if string.find(event, "MISSED") then
if params[15] == "ABSORB" then
amount, critical = params[17], params[18]
else
return true
end
else
amount, overkill, absorbed, critical = params[15], params[16], params[20], params[21]
end
spell_id, spell_name, spell_school = params[12], params[13], params[14]
end
if absorbed then
amount = amount + absorbed
end
if overkill and overkill > 0 then
amount = amount - overkill
end
if string.find(event, "PERIODIC") then
tick = true
else
tick = false
end
local action = source_metric.actions[spell_id]
if not action then
if source.owner then
spell_name = spell_name.." ("..source.name..")"
end
action = self:new_action(spell_id, spell_name, spell_school)
source_metric.actions[spell_id] = action
end
local instance = action.hits[tick][critical]
instance.count = instance.count + 1
instance.total = instance.total + amount
instance.average = instance.total / instance.count
if instance.highest == nil or instance.highest < amount then
instance.highest = amount
end
if instance.lowest == nil or instance.lowest > amount then
instance.lowest = amount
end
action.total = action.total + amount
source_metric.total = (source_metric.total or 0) + amount
return true
end
}
local METRIC_DMG_DONE_TO = {
new_source = function(self, guid, name)
return {
guid = guid,
name = name,
total = 0,
}
end,
label = "Damage Done To",
filter = {
["SWING_DAMAGE"] = true,
["RANGE_DAMAGE"] = true,
["SPELL_DAMAGE"] = true,
["SPELL_PERIODIC_DAMAGE"] = true,
["SPELL_PERIODIC_MISSED"] = true,
["SWING_MISSED"] = true,
["RANGE_MISSED"] = true,
["SPELL_MISSED"] = true,
},
new_actor = function()
return {
total = 0,
dmg_sources = {},
}
end,
actor_list = function(segment)
return segment.outside
end,
summary_list = function(actors)
return actors[1].dmg_sources
end,
draw_details = nil,
summary_color = color_actor,
handle_combatlog_event = function(self, event, source, target, params)
-- only show damage to existing enemies out of or in group (such as charmed players) from existing friendly group members
if not params[8] or not params[4] or not source.guid or bit.band(params[6], COMBATLOG_OBJECT_AFFILIATION_MASK) > COMBATLOG_OBJECT_AFFILIATION_RAID then
return false
end
local source_metric = source.metrics[self.label]
local target_metric = target.metrics[self.label]
local amount, overkill, absorbed
if string.find(event, "SWING") then
if string.find(event, "MISSED") then
if params[12] == "ABSORB" then
amount = params[14]
else
return true
end
else
amount, overkill, absorbed = params[12], params[13], params[17]
end
else
if string.find(event, "MISSED") then
if params[15] == "ABSORB" then
amount = params[17]
else
return true
end
else
amount, overkill, absorbed = params[15], params[16], params[20]
end
end
if absorbed then
amount = amount + absorbed
end
if overkill and overkill > 0 then
amount = amount - overkill
end
-- attribute pet dmg dealt to the owner
local source = source.owner or source
local dmg_source = target_metric.dmg_sources[source.guid]
if not dmg_source then
dmg_source = self:new_source(source.guid, source.name)
target_metric.dmg_sources[source.guid] = dmg_source
end
dmg_source.total = dmg_source.total + amount
target_metric.total = target_metric.total + amount
return true
end
}
local METRIC_DMG_TAKEN = {
new_action = function(self, id, name, school)
return {
id = id,
name = name,
school = school,
owner = nil,
total = 0,
higher = nil,
lower = nil,
hits = {
-- tick
[true] = {
-- crit
[true] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
},
-- hit
[false] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
}
},
-- direct
[false] = {
-- crit
[true] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
},
-- hit
[false] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
}
},
},
}
end,
label = "Damage Taken",
filter = {
["ENVIRONMENTAL_DAMAGE"] = true,
["SWING_DAMAGE"] = true,
["RANGE_DAMAGE"] = true,
["SPELL_DAMAGE"] = true,
["SPELL_PERIODIC_DAMAGE"] = true,
["SPELL_PERIODIC_MISSED"] = true,
["SWING_MISSED"] = true,
["RANGE_MISSED"] = true,
["SPELL_MISSED"] = true,
},
new_actor = function()
return {
total = 0,
actions = {},
}
end,
actor_list = function(segment)
return segment.group
end,
summary_list = function(actors)
return actors[1].actions
end,
draw_details = update_action_details,
summary_color = function(summary)
return COMBATLOG_DEFAULT_COLORS.schoolColoring[summary.school]
end,
handle_combatlog_event = function(self, event, source, target, params)
-- only show damage to existing friendly group members from enemies in or out of group
-- source guid can be null for some non-environment effects (Fiery Ground from Blazing Pyreclaw outside Garrison)
if not params[8] or bit.band(params[10], COMBATLOG_OBJECT_AFFILIATION_MASK) > COMBATLOG_OBJECT_AFFILIATION_RAID then
return false
end
local source_metric = source.metrics[self.label]
local target_metric = target.metrics[self.label]
local tick, environmental_type, spell_id, spell_name, spell_school, amount, overkill, absorbed, critical
if string.find(event, "SWING") then
if string.find(event, "MISSED") then
if params[12] == "ABSORB" then
amount, critical = params[14], params[15]
else
return true
end
else
amount, overkill, absorbed, critical = params[12], params[13], params[17], params[18]
end
spell_id, spell_name, spell_school = 0, MELEE, 1
elseif string.find(event, "ENVIRONMENTAL") then
spell_id, spell_name, amount, overkill, spell_school, critical = "ENVIRONMENTAL-"..params[12], params[12], params[13], params[14], params[15], params[19]
else
if string.find(event, "MISSED") then
if params[15] == "ABSORB" then
amount, critical = params[17], params[18]
else
return true
end
else
amount, overkill, absorbed, critical = params[15], params[16], params[20], params[21]
end
spell_id, spell_name, spell_school = params[12], params[13], params[14]
end
if absorbed then
amount = amount + absorbed
end
if overkill and overkill > 0 then
amount = amount - overkill
end
if string.find(event, "SPELL_PERIODIC") then
tick = true
else
tick = false
end
local action = target_metric.actions[spell_id]
if not action then
action = self:new_action(spell_id, spell_name, spell_school)
target_metric.actions[spell_id] = action
end
local instance = action.hits[tick][critical]
instance.count = instance.count + 1
instance.total = instance.total + amount
instance.average = instance.total / instance.count
if instance.highest == nil or instance.highest < amount then
instance.highest = amount
end
if instance.lowest == nil or instance.lowest > amount then
instance.lowest = amount
end
action.total = action.total + amount
target_metric.total = (target_metric.total or 0) + amount
return params[4]
end
}
local METRIC_HEAL_DONE = {
new_action = function(self, id, name, school)
return {
id = id,
name = name,
school = school,
owner = nil,
total = 0,
higher = nil,
lower = nil,
hits = {
-- tick
[true] = {
-- crit
[true] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
},
-- hit
[false] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
}
},
-- direct
[false] = {
-- crit
[true] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
},
-- hit
[false] = {
count = 0,
highest = nil,
lowest = nil,
average = 0,
total = 0,
}
},
},
}
end,
init = function(self, parse)
-- absorb caster needs to be substituted into the event source so it gets added to the correct actor as healing done
parse.event_custom_params[self.label] = {
["SPELL_ABSORBED"] = function(params)
if type(params[12]) == "number" then
--spell
params[4], params[5], params[6], params[7] = params[15], params[16], params[17], params[18]
else
--swing
params[4], params[5], params[6], params[7] = params[12], params[13], params[14], params[15]
end
end
}
end,
label = "Healing",
filter = {
["SPELL_ABSORBED"] = true,
["SPELL_HEAL"] = true,
["SPELL_PERIODIC_HEAL"] = true,
},
new_actor = function()
return {
total = 0,
actions = {},
}
end,
actor_list = function(segment)
return segment.group
end,
summary_list = function(actors)
local actions = {}
for _, actor in ipairs(actors) do
for _, action in pairs(actor.actions) do
table.insert(actions, action)
end
end
return actions
end,
draw_details = update_action_details,
summary_color = function(summary)
return COMBATLOG_DEFAULT_COLORS.schoolColoring[summary.school]
end,
handle_combatlog_event = function(self, event, source, target, params)
-- only show healing from existing friendly group members
if not params[4] or bit.band(params[6], COMBATLOG_OBJECT_AFFILIATION_MASK) > COMBATLOG_OBJECT_AFFILIATION_RAID then
return false
end
local source_metric = source.metrics[self.label]
local target_metric = target.metrics[self.label]
local spell_id, spell_name, spell_school, overhealing, tick, amount, absorbed, critical
if string.find(event, "ABSORBED") then
if type(params[12]) == "number" then
-- source damage is from spell
spell_id, spell_name, spell_school, amount = params[19], params[20], params[21], params[22]
else
-- source damage is from swing
spell_id, spell_name, spell_school, amount = params[16], params[17], params[18], params[19]
end
critical = false
overhealing = 0
else
spell_id, spell_name, spell_school, amount, overhealing, absorbed, critical = params[12], params[13], params[14], params[15], params[16], params[17], params[18]
end
if string.find(event, "PERIODIC") then
tick = true
else
tick = false
end
local action = source_metric.actions[spell_id]
if not action then
if source.owner then
spell_name = spell_name.." ("..source.name..")"
end
action = self:new_action(spell_id, spell_name, spell_school)
source_metric.actions[spell_id] = action
end
-- TODO overhealing display
amount = amount - overhealing
local instance = action.hits[tick][critical]
instance.count = instance.count + 1
instance.total = instance.total + amount
instance.average = instance.total / instance.count
if instance.highest == nil or instance.highest < amount then
instance.highest = amount
end
if instance.lowest == nil or instance.lowest > amount then
instance.lowest = amount
end
action.total = action.total + amount
source_metric.total = (source_metric.total or 0) + amount
return false
end
}
local draw_history_level = function(current, state, parse)
local count = parse.data_history.count
for i = 1, MAX_BARS do
local first_entry = 1
if count > MAX_BARS then
first_entry = math.max(math.min(count - MAX_BARS + 1, parse.scroll), 1)
parse.scroll = first_entry
parse.count:SetText(string.format("%d / %d", first_entry, count))
else
parse.count:SetText("")
end
local bar = parse.bars[i]
local segment = parse.data_history.segments[i + first_entry - 1]
if segment then
bar.name_text:SetText(segment.timestamp)
local desc = ""
if segment.name then
desc = segment.name.." "
end
if segment.combat_end then
desc = desc..pretty_time(segment.combat_end - segment.combat_start)
end
bar.description:SetText(desc)
bar.context = segment
bar:SetValue(1)
bar:SetStatusBarColor(.5, .5, .5)
bar:Show()
else
bar:Hide()
end
end
end
local draw_metric_level = function(current, state, parse)
local count = #parse.metrics
for i = 1, MAX_BARS do
local first_entry = 1
if count > MAX_BARS then
first_entry = math.max(math.min(count - MAX_BARS + 1, parse.scroll), 1)
parse.scroll = first_entry
parse.count:SetText(string.format("%d / %d", first_entry, count))
else
parse.count:SetText("")
end
local bar = parse.bars[i]
local metric = parse.metrics[i + first_entry - 1]
if metric then
bar.name_text:SetText(metric.label)
bar.description:SetText("")
bar.context = metric
bar:SetValue(1)
bar:SetStatusBarColor(.5, .5, .5)
bar:Show()
else
bar:Hide()
end
end
end
local draw_sorted = function(parse, entries, get_value, segment_start, segment_end, get_color)
local highest_entry, highest_metric = nil, 0
local count = 0
for key, entry in pairs(entries) do
entry.higher = nil
entry.lower = nil
if entry.owner then
entry = nil
else
if get_value(entry) > 0 then
count = count + 1
else
entry = nil
end
end
if entry then
if not highest_entry then
highest_entry = entry
else
local current = highest_entry
while get_value(current) > get_value(entry) and current.lower do
current = current.lower
end
if get_value(current) > get_value(entry) then
entry.upper = current
entry.lower = current.lower
current.lower = entry
else
if current == highest_entry then
highest_entry = entry
entry.upper = nil
else
entry.upper = current.upper
current.upper.lower = entry
end
current.upper = entry
entry.lower = current
end
end
end
end
local first_entry = 1
if count > MAX_BARS then
first_entry = math.max(math.min(count - MAX_BARS + 1, parse.scroll), 1)
parse.scroll = first_entry
parse.count:SetText(string.format("%d / %d", first_entry, count))
else
parse.count:SetText("")
end
if highest_entry then
highest_metric = get_value(highest_entry)
end
local current_entry, current_metric = highest_entry, highest_metric
if current_entry then
local i = 1
while i < first_entry do
current_entry = current_entry.lower
i = i + 1
end
current_metric = get_value(current_entry)
end
local segment_length = (segment_end or time()) - segment_start
if segment_length < 1 then segment_length = 1 end
for i = 1, MAX_BARS do
local bar = parse.bars[i]
if not current_entry or current_metric == 0 then
bar:Hide()
else
bar:Show()
bar:SetValue(current_metric / highest_metric)
local metric_per_second
metric_per_second = current_metric / segment_length
bar.name_text:SetText(current_entry.name)
bar.description:SetText(pretty_number(current_metric).." - "..pretty_number(metric_per_second))
local color = get_color(current_entry)
if not color then
color = {r = .5, g = .5, b = .5}
end
bar:SetStatusBarColor(color.r * .75, color.g * .75, color.b * .75)
bar.context = current_entry
current_entry = current_entry.lower
if current_entry then
current_metric = get_value(current_entry)
end
end
end
end
local parse = CreateFrame("Frame", "ParseFrame", UIParent, BackdropTemplateMixin and "BackdropTemplate")
parse:SetSize(WINDOW_WIDTH, BAR_HEIGHT * 2)
parse:SetPoint("RIGHT", UIParent, "RIGHT", -5, 0)
parse:SetClampedToScreen(true)
parse:SetMovable(true)
parse:SetResizable(true)
parse:SetScript("OnMouseDown", function(self, click)
if click == "RightButton" then
self:StartSizing("RIGHT")
elseif click == "LeftButton" then
self:StartMoving()
elseif click == "MiddleButton" then
self:exit_combat(time())
self.data_history:clear()
self.display_state:clear()
self.scroll = 1
self:update_label()
self.display_state:draw_current_level(self)
end
end)
parse:SetScript("OnMouseUp", function(self)
self:StopMovingOrSizing()
self:SetHeight(BAR_HEIGHT * 2)
end)
parse.bg = CreateFrame("Frame", nil, UIParent, BackdropTemplateMixin and "BackdropTemplate")
parse.bg:SetPoint("TOPLEFT", parse, "BOTTOMLEFT", 0, 1)
parse.bg:SetPoint("TOPRIGHT", parse, "BOTTOMRIGHT", 0, 1)