-
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEavesDrop.lua
1765 lines (1650 loc) · 55.7 KB
/
EavesDrop.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
--[==[ ****************************************************************
EavesDrop
Author: Grayhoof. Original idea by Bant. Coding help/samples
from Andalia`s SideCombatLog and CombatChat.
Notes: Code comments coming at a later time.
****************************************************************]==]
--
EavesDrop = LibStub("AceAddon-3.0"):NewAddon("EavesDrop", "AceEvent-3.0", "AceConsole-3.0", "AceTimer-3.0")
local EavesDrop = EavesDrop
local db
local L = LibStub("AceLocale-3.0"):GetLocale("EavesDrop", true)
local media = LibStub("LibSharedMedia-3.0")
local OUTGOING = 1
local INCOMING = -1
local MISC = 3
local critchar = "*"
local deathchar = "†"
local crushchar = "^"
local glancechar = "~"
local newhigh = "|cffffff00!|r"
local arrEventData = {}
local arrEventFrames = {}
local frameSize = 21
local arrSize = 10
local arrDisplaySize = 20
local arrMaxSize = 128
local scroll = 0
local allShown = false
local totDamageIn = 0
local totDamageOut = 0
local totHealingIn = 0
local totHealingOut = 0
local timeStart = 0
local curTime = 0
local lastTime = 0
EavesDrop.BLACKLIST_DB_VERSION = "v2"
-- LUA calls
local _G = _G
local tonumber = tonumber
local strsub = strsub
local string_format = string.format
local string_match = string.match
local gsub = gsub
local tremove = tremove
local tinsert = tinsert
local function string_nil(val)
if val then
return val
else
return UNKNOWN
end
end
-- API calls
local UnitName = UnitName
local UnitXP = UnitXP
local GetSpellTexture = C_Spell.GetSpellTexture and C_Spell.GetSpellTexture or GetSpellTexture
local GetTime = GetTime
local InCombatLockdown = InCombatLockdown
EavesDrop.showPrints = true
local print = function(...)
if EavesDrop.showPrints == false then return end
local flag = select(1, ...)
if type(flag) == "boolean" then
if flag == true then
print(select(2, ...))
else
return
end
else
print(...)
end
end
--- Returns true if s is either nil or an empty string
---
---@param s string
---@return boolean
local function isEmptyString(s) --luacheck: ignore
return s == nil or s == ""
end
-- Combat log locals
local maxXP = UnitXPMax("player")
local pxp = UnitXP("player")
local PLAYER_MAX_LEVEL
local PLAYER_CURRENT_LEVEL
local skillmsg = gsub(gsub(gsub(SKILL_RANK_UP, "%d%$", ""), "%%s", "(.+)"), "%%d", "(%%d+)")
local CombatLog_Object_IsA = CombatLog_Object_IsA
local Blizzard_CombatLog_CurrentSettings
local COMBATLOG_OBJECT_NONE = COMBATLOG_OBJECT_NONE
local COMBATLOG_FILTER_MINE = COMBATLOG_FILTER_MINE
local COMBATLOG_FILTER_MY_PET = COMBATLOG_FILTER_MY_PET
local COMBATLOG_FILTER_HOSTILE = bit.bor(COMBATLOG_FILTER_HOSTILE_PLAYERS, COMBATLOG_FILTER_HOSTILE_UNITS)
local COMBAT_EVENTS = {
["SWING_DAMAGE"] = "DAMAGE",
["RANGE_DAMAGE"] = "DAMAGE",
["SPELL_DAMAGE"] = "DAMAGE",
["SPELL_PERIODIC_DAMAGE"] = "DAMAGE",
["ENVIRONMENTAL_DAMAGE"] = "DAMAGE",
["DAMAGE_SHIELD"] = "DAMAGE",
["DAMAGE_SPLIT"] = "DAMAGE",
["SPELL_HEAL"] = "HEAL",
["SPELL_PERIODIC_HEAL"] = "HEAL",
["SPELL_HEAL_ABSORBED"] = "HEALABSORB",
["SWING_MISSED"] = "MISS",
["RANGE_MISSED"] = "MISS",
["SPELL_MISSED"] = "MISS",
["SPELL_PERIODIC_MISSED"] = "MISS",
["DAMAGE_SHIELD_MISSED"] = "MISS",
["SPELL_DRAIN"] = "DRAIN",
["SPELL_LEECH"] = "DRAIN",
["SPELL_PERIODIC_DRAIN"] = "DRAIN",
["SPELL_PERIODIC_LEECH"] = "DRAIN",
["SPELL_ENERGIZE"] = "POWER",
["SPELL_PERIODIC_ENERGIZE"] = "POWER",
["PARTY_KILL"] = "DEATH",
["UNIT_DIED"] = "DEATH",
["UNIT_DESTROYED"] = "DEATH",
["SPELL_INSTAKILL"] = "DEATH",
}
-- LoadAddOn("Blizzard_DebugTools")
local SCHOOL_STRINGS = {}
for index, value in ipairs(_G["SCHOOL_STRINGS"]) do
SCHOOL_STRINGS[bit.lshift(1, index - 1)] = value
end
local SCHOOL_MASK_PHYSICAL = 1
-- DevTools_Dump(SCHOOL_STRINGS)
--[[ local SCHOOL_STRINGS = {
[SCHOOL_MASK_PHYSICAL] = SPELL_SCHOOL0_CAP,
[SCHOOL_MASK_HOLY] = SPELL_SCHOOL1_CAP,
[SCHOOL_MASK_FIRE] = SPELL_SCHOOL2_CAP,
[SCHOOL_MASK_NATURE] = SPELL_SCHOOL3_CAP,
[SCHOOL_MASK_FROST] = SPELL_SCHOOL4_CAP,
[SCHOOL_MASK_SHADOW] = SPELL_SCHOOL5_CAP,
[SCHOOL_MASK_ARCANE] = SPELL_SCHOOL6_CAP,
} ]]
local POWER_STRINGS = {
[Enum.PowerType.Mana] = MANA,
[Enum.PowerType.Rage] = RAGE,
[Enum.PowerType.Focus] = FOCUS,
[Enum.PowerType.Energy] = ENERGY,
[Enum.PowerType.ComboPoints] = COMBO_POINTS,
[Enum.PowerType.Runes] = RUNES,
[Enum.PowerType.RunicPower] = RUNIC_POWER,
[Enum.PowerType.SoulShards] = SHARDS,
[Enum.PowerType.LunarPower] = LUNAR_POWER,
[Enum.PowerType.HolyPower] = HOLY_POWER,
[Enum.PowerType.Alternate] = ALTERNATE_RESOURCE_TEXT,
[Enum.PowerType.Maelstrom] = MAELSTROM_POWER,
[Enum.PowerType.Chi] = CHI_POWER,
[Enum.PowerType.Insanity] = INSANITY_POWER,
-- [Enum.PowerType.Obsolete] = 14;
-- [Enum.PowerType.Obsolete2] = 15;
[Enum.PowerType.ArcaneCharges] = ARCANE_CHARGES_POWER,
[Enum.PowerType.Fury] = FURY,
[Enum.PowerType.Pain] = PAIN,
[Enum.PowerType.Essence] = L["Essence"],
[Enum.PowerType.AlternateMount] = L["Vigor"],
}
-- set table default size sense table.insert no longer does
for i = 1, arrMaxSize do
arrEventData[i] = {}
end
--- Returns the core school type of a multi-school type `a`.
---
--- If `a` is one of the core schools, return value will be the same as `a`
---
--- Example: Chaos school type consists of types Arcane, Shadow, Nature and Holy.
--- Since its bitmask is 106 (01101010), then its core school is (01000000) which
--- is the same as Arcane. Thus getSpellSchoolCoreType(106) will return 64.
---@param a number
---@return number
local function getSpellSchoolCoreType(a)
local count = 0
while true do
a = bit.rshift(a, 1)
if a == 0 then break end
count = count + 1
end
local stype = bit.lshift(1, count)
return stype
end
EavesDrop.blacklist = {}
-- Checks if `spell` is in the Blacklist DB
--
-- Returns true if any of input `spell`s is blacklisted
--
---@param spell string|number
---@return boolen
local function isBlacklisted(spell, ...)
local blacklist = EavesDrop.blacklist
if blacklist[spell] then return true end
local args = { ... }
for i = 1, #args do
if blacklist[args[i]] then return true end
end
return false
end
--@debug@
EavesDrop.DEBUG = false
function EavesDrop:AddToInspector(data, strName)
local l, f = select(2, C_AddOns.IsAddOnLoaded("DevTool"))
if l and f and self.DEBUG then DevTool:AddData(data, strName) end
end
--@end-debug@
function EavesDrop:IsClassic()
return (_G.WOW_PROJECT_ID == _G.WOW_PROJECT_CLASSIC)
or (_G.WOW_PROJECT_ID == _G.WOW_PROJECT_BURNING_CRUSADE_CLASSIC)
or (_G.WOW_PROJECT_ID == _G.WOW_PROJECT_WRATH_CLASSIC)
or (_G.WOW_PROJECT_ID == _G.WOW_PROJECT_CATACLYSM_CLASSIC)
end
function EavesDrop:IsRetail()
return (_G.WOW_PROJECT_ID == _G.WOW_PROJECT_MAINLINE)
end
local function convertRGBtoHEXString(color, text)
return string_format("|cFF%02x%02x%02x%s|r", ceil(color.r * 255), ceil(color.g * 255), ceil(color.b * 255), text)
end
local function shortenValue(value)
if value >= 10000000 then
value = string_format("%.1fm", value / 1000000)
elseif value >= 1000000 then
value = string_format("%.2fm", value / 1000000)
elseif value >= 100000 then
value = string_format("%.0fk", value / 1000)
elseif value >= 10000 then
value = string_format("%.1fk", value / 1000)
end
return tostring(value)
end
EavesDrop.shortenValue = shortenValue
local function round(num, idp)
return tonumber(string_format("%." .. (idp or 0) .. "f", num))
end
-- 05:13:54, |Hunit:Player-4384-047F64F1:Yadeek|hYadeek's|h |Hspell:45462:0:SPELL_MISSED|hPlague Strike|h was parried by |Hunit:Creature-0-4412-609-151-28611-0000468525:Scarlet Captain|hScarlet Captain|h.
local function cleanstring(s)
s = gsub(s, "|r", "")
s = gsub(s, "|c........", "")
s = gsub(s, "|Hunit:([%w%s*%-*:%']*)|h", "")
s = gsub(s, "|Haction:([%w_*]*)|h", "")
s = gsub(s, "|Hitem:(%d+)|h", "")
s = gsub(s, "|Hicon:%d+:dest|h", "")
s = gsub(s, "|Hicon:%d+:source|h", "")
s = gsub(s, "|Hspell:%d+:%d+:([%w_*]*)|h", "")
s = gsub(s, "|TInterface.TargetingFrame.UI.RaidTargetingIcon.%d.blp:0|t", "")
s = gsub(s, "|h", "")
s = gsub(s, "\n", ", ")
s = gsub(s, "\124", "\124\124")
return s
end
local function clearSummary()
totDamageIn = 0
totDamageOut = 0
totHealingIn = 0
totHealingOut = 0
end
-- Main Functions
function EavesDrop:OnInitialize()
-- setup table for display frame objects
for i = 1, arrDisplaySize do
arrEventFrames[i] = {}
arrEventFrames[i].frame = _G[string_format("EavesDropEvent%d", i)]
arrEventFrames[i].text = _G[string_format("EavesDropEvent%dEventText", i)]
arrEventFrames[i].intexture = _G[string_format("EavesDropEvent%dIncomingTexture", i)]
arrEventFrames[i].intextureframe = _G[string_format("EavesDropEvent%dIncoming", i)]
arrEventFrames[i].outtexture = _G[string_format("EavesDropEvent%dOutgoingTexture", i)]
arrEventFrames[i].outtextureframe = _G[string_format("EavesDropEvent%dOutgoing", i)]
end
self.db = LibStub("AceDB-3.0"):New("EavesDropDB", self:GetDefaultConfig())
self.chardb = LibStub("AceDB-3.0"):New("EavesDropStatsDB", { profile = { [OUTGOING] = {}, [INCOMING] = {} } })
self:SetupOptions()
-- callbacks for profile changes
self.db.RegisterCallback(self, "OnProfileChanged", "UpdateFrame")
self.db.RegisterCallback(self, "OnProfileCopied", "UpdateFrame")
self.db.RegisterCallback(self, "OnProfileReset", "UpdateFrame")
-- local the profile table
db = self.db.profile
self:PerformDisplayOptions()
if _G.WOW_PROJECT_ID == _G.WOW_PROJECT_CLASSIC then
PLAYER_MAX_LEVEL = 60
else
PLAYER_MAX_LEVEL = GetMaxLevelForExpansionLevel(GetExpansionLevel())
end
-- local tww = select(4, GetBuildInfo()) -- REMOVE this on release of TWW, it's just a hack to test the addon on Beta server
-- if tww >= 110000 then
-- PLAYER_MAX_LEVEL = 80
-- elseif self.IsRetail() then
-- PLAYER_MAX_LEVEL = 70
-- elseif _G.WOW_PROJECT_ID == _G.WOW_PROJECT_CATACLYSM_CLASSIC then
-- PLAYER_MAX_LEVEL = 85
-- elseif _G.WOW_PROJECT_ID == _G.WOW_PROJECT_WRATH_CLASSIC then
-- PLAYER_MAX_LEVEL = 80
-- elseif _G.WOW_PROJECT_ID == _G.WOW_PROJECT_BURNING_CRUSADE_CLASSIC then
-- PLAYER_MAX_LEVEL = 70
-- elseif _G.WOW_PROJECT_ID == _G.WOW_PROJECT_CLASSIC then
-- PLAYER_MAX_LEVEL = 60
-- end
PLAYER_CURRENT_LEVEL = UnitLevel("player")
maxXP = UnitXPMax("player")
pxp = UnitXP("player")
--@debug@
print("OnInitialize, maxXP:", maxXP)
print("OnInitialize, pxp:", pxp)
--@end-debug@
if PLAYER_CURRENT_LEVEL ~= PLAYER_MAX_LEVEL then
--@debug@
print("Not max level, checking XP numbers")
--@end-debug@
if maxXP == 0 then
--@debug@
print("Getting player's maxXP in 3 seconds!")
--@end-debug@
C_Timer.NewTimer(3, function()
maxXP = UnitXPMax("player")
--@debug@
print(string_format("After 3 seconds: maxXP: %d, pxp: %d", maxXP, pxp))
-- stylua: ignore
--@end-debug@
if maxXP == 0 then
print(WrapTextInColorCode("EavesDrop", "fff48cba") .. ": Couldn't get player's MAX EXP!")
end
end)
end
if pxp == 0 then
--@debug@
print("Getting player's pxp in 4 seconds!")
--@end-debug@
C_Timer.NewTimer(4, function()
pxp = UnitXP("player")
--@debug@
print(string_format("After 4 seconds: maxXP: %d, pxp: %d", maxXP, pxp))
-- stylua: ignore
--@end-debug@
if pxp == 0 then
print(WrapTextInColorCode("EavesDrop", "fff48cba") .. ": Couldn't get player's EXP!")
end
end)
end
else
--@debug@
print("At max level, NOT checking XP numbers")
--@end-debug@
end
self:RegisterEvent("ADDON_LOADED", self.SetFonts)
if EavesDrop.db.profile["BLACKLIST"]["version"] == EavesDrop.BLACKLIST_DB_VERSION then -- latest version
EavesDrop.blacklist = EavesDrop.db.profile["BLACKLIST"]["spells"]
--@debug@
print("Loading new db")
DevTools_Dump(EavesDrop.blacklist)
--@end-debug@
elseif next(EavesDrop.db.profile["BLACKLIST"]) == nil then -- empty blacklist
EavesDrop.blacklist = {}
EavesDrop.db.profile["BLACKLIST"] = { version = EavesDrop.BLACKLIST_DB_VERSION, spells = {} }
--@debug@
print("Empty blacklist. Updating format")
DevTools_Dump(EavesDrop.db.profile.BLACKLIST)
--@end-debug@
elseif EavesDrop.db.profile["BLACKLIST"]["version"] == nil then -- old/first version
EavesDrop.blacklist = EavesDrop.db.profile["BLACKLIST"]
--@debug@
print("Loading old db")
DevTools_Dump(EavesDrop.blacklist)
--@end-debug@
C_Timer.NewTimer(5, function()
print(
string.format(
"|cffF48CBAEavesDrop|r: Options file format has changed!\n"
.. "Open EavesDrop options and refresh the blacklisted spells under |cffFFF468Misc.|r tab "
.. "by insering a blank new line and then clicking |cffffff00Accept|r button!\n"
)
)
end)
else
C_Timer.NewTimer(5, function()
print(
string.format(
"|cffF48CBAEavesDrop|r: Saved profile DB seems to be corrupted!\nExit the game and delete EavesDrop.lua under |cffFFF468Saved Variables|r folder."
)
)
end)
end
end
function EavesDrop:OnEnable()
self:RegisterEvent("PLAYER_DEAD")
self:UpdateExpEvents()
self:UpdateRepHonorEvents()
self:UpdateCombatEvents()
self:UpdateBuffEvents()
self:UpdateBuffFadeEvents()
self:UpdateSkillEvents()
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED", "CombatEvent")
-- show frame
EavesDropFrame:Show()
if db["FADEFRAME"] then self:HideFrame() end
end
function EavesDrop:OnDisable()
self:UnregisterAllEvents()
EavesDropFrame:Hide()
end
function EavesDrop:UpdateCombatEvents()
if db["COMBAT"] == true then
self:RegisterEvent("PLAYER_REGEN_DISABLED")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
else
self:UnregisterEvent("PLAYER_REGEN_DISABLED")
self:UnregisterEvent("PLAYER_REGEN_ENABLED")
end
end
function EavesDrop:UpdateExpEvents()
if db["EXP"] == true then
self:RegisterEvent("PLAYER_XP_UPDATE")
else
self:UnregisterEvent("PLAYER_XP_UPDATE")
end
end
function EavesDrop:UpdateRepHonorEvents()
if db["REP"] or db["HONOR"] then
self:RegisterEvent("COMBAT_TEXT_UPDATE")
else
self:UnregisterEvent("COMBAT_TEXT_UPDATE")
end
end
function EavesDrop:UpdateBuffEvents()
if db["DEBUFF"] == true or db["BUFF"] == true then
COMBAT_EVENTS["SPELL_AURA_APPLIED"] = "BUFF"
COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED"] = "BUFF"
COMBAT_EVENTS["SPELL_AURA_APPLIED_DOSE"] = "BUFF"
COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED_DOSE"] = "BUFF"
COMBAT_EVENTS["ENCHANT_APPLIED"] = "ENCHANT_APPLIED"
else
COMBAT_EVENTS["SPELL_AURA_APPLIED"] = nil
COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED"] = nil
COMBAT_EVENTS["SPELL_AURA_APPLIED_DOSE"] = nil
COMBAT_EVENTS["SPELL_PERIODIC_AURA_APPLIED_DOSE"] = nil
COMBAT_EVENTS["ENCHANT_APPLIED"] = nil
end
end
function EavesDrop:UpdateBuffFadeEvents()
if db["DEBUFFFADE"] == true or db["BUFFFADE"] == true then
COMBAT_EVENTS["SPELL_AURA_REMOVED"] = "FADE"
COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED"] = "FADE"
COMBAT_EVENTS["SPELL_AURA_REMOVED_DOSE"] = "FADE"
COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED_DOSE"] = "FADE"
COMBAT_EVENTS["ENCHANT_REMOVED"] = "ENCHANT_REMOVED"
else
COMBAT_EVENTS["SPELL_AURA_REMOVED"] = nil
COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED"] = nil
COMBAT_EVENTS["SPELL_AURA_REMOVED_DOSE"] = nil
COMBAT_EVENTS["SPELL_PERIODIC_AURA_REMOVED_DOSE"] = nil
COMBAT_EVENTS["ENCHANT_REMOVED"] = nil
end
end
function EavesDrop:UpdateSkillEvents()
if db["SKILL"] == true then
self:RegisterEvent("CHAT_MSG_SKILL")
else
self:UnregisterEvent("CHAT_MSG_SKILL")
end
end
----------------------
-- Reset everything to default
function EavesDrop:UpdateFrame()
-- local the profile table
db = self.db.profile
self:UpdateExpEvents()
self:UpdateRepHonorEvents()
self:UpdateCombatEvents()
self:UpdateBuffEvents()
self:UpdateBuffFadeEvents()
self:UpdateSkillEvents()
self:PerformDisplayOptions()
self:UpdateEvents()
end
function EavesDrop:PerformDisplayOptions()
-- set size
arrSize = db["NUMLINES"]
frameSize = db["LINEHEIGHT"] + 1
local totalh = (frameSize * arrSize) + 50
local totalw = (db["LINEHEIGHT"] * 2) + db["LINEWIDTH"]
EavesDropFrame:SetHeight(totalh)
EavesDropFrame:SetWidth(totalw)
-- update look of frame
local r, g, b, a = db["FRAME"].r, db["FRAME"].g, db["FRAME"].b, db["FRAME"].a
-- main frame
EavesDropFrame:SetBackdropColor(r, g, b, a)
EavesDropTopBar:SetGradient(
"VERTICAL",
{ r = r * 0.1, g = g * 0.1, b = b * 0.1, a = 0 },
{ r = r * 0.2, g = g * 0.2, b = b * 0.2, a = a }
)
EavesDropBottomBar:SetGradient(
"VERTICAL",
{ r = r * 0.2, g = g * 0.2, b = b * 0.2, a = a },
{ r = r * 0.1, g = g * 0.1, b = b * 0.1, a = 0 }
)
EavesDropTopBar:SetWidth(totalw - 10)
EavesDropBottomBar:SetWidth(totalw - 10)
r, g, b, a = db["BORDER"].r, db["BORDER"].g, db["BORDER"].b, db["BORDER"].a
EavesDropFrame:SetBackdropBorderColor(r, g, b, a)
EavesDropFrame:EnableMouse(not db["LOCKED"])
-- tooltips
EavesDropTab.tooltipText = L["TabTip"]
if db["SCROLLBUTTON"] then
EavesDropFrameDownButton:Hide()
EavesDropFrameUpButton:Hide()
else
EavesDropFrameDownButton.tooltipText = L["DownTip"]
EavesDropFrameUpButton.tooltipText = L["UpTip"]
self:UpdateScrollButtons()
end
self.ToolTipAnchor = "ANCHOR_" .. strupper(db["TOOLTIPSANCHOR"])
-- labels
r, g, b, a = db["LABELC"].r, db["LABELC"].g, db["LABELC"].b, db["LABELC"].a
if db["FLIP"] == true then
EavesDropFramePlayerText:SetText(L["TargetLabel"])
EavesDropFrameTargetText:SetText(L["PlayerLabel"])
else
EavesDropFramePlayerText:SetText(L["PlayerLabel"])
EavesDropFrameTargetText:SetText(L["TargetLabel"])
end
EavesDropFramePlayerText:SetTextColor(r, g, b, a)
EavesDropFrameTargetText:SetTextColor(r, g, b, a)
-- fonts
self:SetFonts()
-- tab
if db["HIDETAB"] == true then
EavesDropTab:Hide()
else
EavesDropTab:Show()
end
-- position frame (have to schedule cause UI scale is still 1 for some reason during init)
self:ScheduleTimer("PlaceFrame", 0.1, self)
self:ResetEvents()
self:SetupHistory()
if db["FADEFRAME"] then
self:HideFrame()
else
self:ShowFrame()
end
end
function EavesDrop:SetFonts()
local flag = db["FONTOUTLINE"] == "None" and "" or strupper(db["FONTOUTLINE"])
EavesDropFontNormal:SetFont(media:Fetch("font", db["FONT"]), db["TEXTSIZE"], flag)
EavesDropFontNormalSmall:SetFont(media:Fetch("font", db["FONT"]), db["TEXTSIZE"], flag)
end
function EavesDrop:PlaceFrame()
local frame, x, y = EavesDropFrame, db.x, db.y
frame:ClearAllPoints()
if x == 0 and y == 0 then
frame:SetPoint("CENTER", UIParent, "CENTER")
else
local es = frame:GetEffectiveScale()
frame:SetPoint("TOPLEFT", UIParent, "CENTER", x / es, y / es)
end
end
function EavesDrop:HideFrame()
EavesDropFrame:SetAlpha(0)
end
function EavesDrop:ShowFrame()
EavesDropFrame:SetAlpha(1)
EavesDropTab:SetAlpha(0)
end
-- function EavesDrop:CombatEvent(larg1, ...)
function EavesDrop:CombatEvent(_, _)
-- local timestamp, event, hideCaster, sourceGUID, sourceName, sourceFlags, sourceFlags2, destGUID, destName, destFlags,
local _, event, _, _, sourceName, sourceFlags, _, _, destName, destFlags, _ = CombatLogGetCurrentEventInfo()
-- Ensure the event is related to player and his pet
local toPlayer, fromPlayer, toPet, fromPet
if sourceName and not CombatLog_Object_IsA(sourceFlags, COMBATLOG_OBJECT_NONE) then
fromPlayer = CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MINE)
fromPet = CombatLog_Object_IsA(sourceFlags, COMBATLOG_FILTER_MY_PET)
end
if destName and not CombatLog_Object_IsA(destFlags, COMBATLOG_OBJECT_NONE) then
toPlayer = CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_MINE)
toPet = CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_MY_PET)
end
if not fromPlayer and not toPlayer and not fromPet and not toPet then return end
if (not fromPlayer and not toPlayer) and (toPet or fromPet) and not db["PET"] then return end
local etype = COMBAT_EVENTS[event]
if not etype then return end
if not Blizzard_CombatLog_CurrentSettings then
Blizzard_CombatLog_CurrentSettings = Blizzard_CombatLog_Filters.filters[Blizzard_CombatLog_Filters.currentFilter]
end
-- check for reflect damage
if
event == "SPELL_DAMAGE"
and sourceName == destName
and CombatLog_Object_IsA(destFlags, COMBATLOG_FILTER_HOSTILE)
then
self:ParseReflect(CombatLogGetCurrentEventInfo())
return
end
local amount, school, resisted, blocked, absorbed, critical, glancing, crushing
local spellId, spellName, spellSchool, missType, powerType, extraAmount, overHeal
local text, texture, message, inout, color, auraType
local playerRelated, petRelated, whiteDMG
-- defaults
if toPet or fromPet then
texture = "pet"
petRelated = true
end
if toPlayer or fromPlayer then playerRelated = true end
if toPlayer or toPet then inout = INCOMING end
if fromPlayer or fromPet then inout = OUTGOING end
if toPet then color = db["PETI"] end
if fromPet then color = db["PETO"] end
local swordTexture = "Interface\\Icons\\INV_SWORD_04"
local bowTexture = "Interface\\Icons\\INV_WEAPON_BOW_07"
-- get combat log message (for tooltip)
message = CombatLog_OnEvent(Blizzard_CombatLog_CurrentSettings, CombatLogGetCurrentEventInfo())
------------damage----------------
if etype == "DAMAGE" then
local intype, outtype
if event == "SWING_DAMAGE" then
amount, _, school, resisted, blocked, absorbed, critical, glancing, crushing =
select(12, CombatLogGetCurrentEventInfo())
if school == SCHOOL_MASK_PHYSICAL then
outtype, intype = "TMELEE", "PHIT"
else
outtype, intype = "TSPELL", "PSPELL"
end
if playerRelated then texture = swordTexture end
whiteDMG = true
elseif event == "RANGE_DAMAGE" then
_, spellName, _, amount, _, school, resisted, blocked, absorbed, critical, glancing, crushing =
select(12, CombatLogGetCurrentEventInfo())
if school == SCHOOL_MASK_PHYSICAL then
outtype, intype = "TMELEE", "PHIT"
else
outtype, intype = "TSPELL", "PSPELL"
end
if toPlayer then texture = swordTexture end
if fromPlayer then texture = bowTexture end
whiteDMG = true
elseif event == "ENVIRONMENTAL_DAMAGE" then
_, amount, _, school, resisted, blocked, absorbed, critical, glancing, crushing =
select(12, CombatLogGetCurrentEventInfo())
outtype, intype = "TSPELL", "PSPELL"
whiteDMG = false
else
spellId, spellName, _, amount, _, school, resisted, blocked, absorbed, critical, glancing, crushing =
select(12, CombatLogGetCurrentEventInfo())
texture = GetSpellTexture(spellId)
outtype, intype = "TSPELL", "PSPELL"
whiteDMG = false
end
-- local a, o = false, false
local realDamage_All, netDamage = amount
if blocked and blocked > 0 then realDamage_All = realDamage_All + blocked end
if resisted and resisted > 0 then realDamage_All = realDamage_All + resisted end
if absorbed and absorbed > 0 then realDamage_All = realDamage_All + absorbed end
netDamage = realDamage_All
text = tostring(shortenValue(amount))
if critical then text = critchar .. text .. critchar end
if crushing then text = crushchar .. text .. crushchar end
if glancing then text = glancechar .. text .. glancechar end
if resisted then text = string_format("%s (%s)", text, shortenValue(resisted)) end
if blocked then text = string_format("%s (%s)", text, shortenValue(blocked)) end
if absorbed then text = string_format("%s (%s)", text, shortenValue(absorbed)) end
-- print(
-- string_format(
-- "|cff000099ABSORB in DAMAGE|r event!\n absorbed: %s, fromPlayer:%s fromPet: %s toPlayer: %s toPet: %s",
-- tostring(absorbed),
-- tostring(fromPlayer),
-- tostring(fromPet),
-- tostring(toPlayer),
-- tostring(toPet)
-- )
-- )
local school_new = getSpellSchoolCoreType(school or 1)
school = school_new
local trackIcon = texture
if event == "SWING_DAMAGE" or event == "RANGE_DAMAGE" then trackIcon = swordTexture end
if fromPlayer or fromPet then
if fromPet then
outtype = "PETI"
color = self:SpellColor(db[outtype], SCHOOL_STRINGS[school])
elseif whiteDMG then
color = db["TMELEE"]
else
color = self:SpellColor(db[outtype], SCHOOL_STRINGS[school])
end
if not toPlayer and not toPet then -- Don't count self damage in total
totDamageOut = totDamageOut + netDamage
else
inout = -inout -- Show self damage under player column
totDamageIn = totDamageIn + netDamage
if absorbed then totHealingOut = totHealingOut + absorbed end
end
if self:TrackStat(inout, "hit", spellName, trackIcon, SCHOOL_STRINGS[school], netDamage, critical, message) then
text = newhigh .. text .. newhigh
end
elseif toPlayer or toPet then
if absorbed then totHealingOut = totHealingOut + absorbed end
if self:TrackStat(inout, "hit", spellName, trackIcon, SCHOOL_STRINGS[school], netDamage, critical, message) then
text = newhigh .. text .. newhigh
end
if toPet and not whiteDMG then
intype = "PSPELL"
color = self:SpellColor(db[intype], SCHOOL_STRINGS[school])
elseif whiteDMG then
color = db["PHIT"]
else
color = self:SpellColor(db[intype], SCHOOL_STRINGS[school])
end
text = "-" .. text
totDamageIn = totDamageIn + netDamage
elseif toPet then
text = "-" .. text
end
-- If spell is blacklisted or too small, don't show it
if isBlacklisted(spellName, spellId) or netDamage < db["DFILTER"] then return end
self:DisplayEvent(inout, text, texture, color, message, spellName)
------------buff/debuff gain----------------
elseif etype == "BUFF" then
spellId, spellName, _, auraType, _ = select(12, CombatLogGetCurrentEventInfo())
-- If spell is blacklisted, don't show it
if isBlacklisted(spellName, spellId) then return end
texture = GetSpellTexture(spellId)
if toPlayer and db[auraType] then
self:DisplayEvent(
INCOMING,
self:ShortenString(spellName) .. " " .. L["Gained"],
texture,
db["P" .. auraType],
message,
spellName
)
else
return
end
------------buff/debuff lose----------------
elseif etype == "FADE" then
spellId, spellName, _, auraType, _ = select(12, CombatLogGetCurrentEventInfo())
-- If spell is blacklisted, don't show it
if isBlacklisted(spellName, spellId) then return end
texture = GetSpellTexture(spellId)
if toPlayer and db[auraType .. "FADE"] then
self:DisplayEvent(
INCOMING,
self:ShortenString(spellName) .. " " .. L["Fades"],
texture,
db["P" .. auraType],
message,
spellName
)
else
return
end
------------heals----------------
elseif etype == "HEAL" then
local absorbed --luacheck: ignore
spellId, spellName, spellSchool, amount, overHeal, absorbed, critical = select(12, CombatLogGetCurrentEventInfo())
local original_overheal = overHeal
texture = GetSpellTexture(spellId)
local _dshow = true
local a, o = false, false
local realHeal_All, netHeal
if absorbed and absorbed > 0 then
realHeal_All = amount + absorbed
else
realHeal_All = amount
end
netHeal = realHeal_All
if db["OVERHEAL"] and overHeal and overHeal > 0 then
o = true
netHeal = realHeal_All - overHeal
end
if db["HEALABSORB"] and absorbed and absorbed > 0 then
a = true
netHeal = netHeal - absorbed
end
-- Is this a bug in game?!!!
if realHeal_All < 0 or netHeal < 0 then
--@debug@
print(_dshow, string_format("|cffff0000Found An Issue|r"))
print(
_dshow,
string_format("ORIGINAL: Amount: %d, absorbed: %d, overHeal: %d", amount, absorbed, original_overheal)
)
print(_dshow, string_format("ADJUSTED: realHeal_All: %d, netHeal: %d", realHeal_All, netHeal))
--@end-debug@
-- Until we figure this out, we will just show what game reported to us.
netHeal = amount
end
if a and o then
text = string_format("%s (%s) {%s}", shortenValue(netHeal), shortenValue(absorbed), shortenValue(overHeal))
elseif a then
text = string_format("%s (%s)", shortenValue(netHeal), shortenValue(absorbed))
elseif o then
text = string_format("%s {%s}", shortenValue(netHeal), shortenValue(overHeal))
else
text = shortenValue(netHeal)
end
if critical then text = critchar .. text .. critchar end
if toPlayer or toPet then
if
self:TrackStat(inout, "heal", spellName, texture, SCHOOL_STRINGS[spellSchool], realHeal_All, critical, message)
then
text = newhigh .. text .. newhigh
end
if db["HEALERID"] == true and not fromPlayer and not fromPet then
text = text .. " (" .. (sourceName or "Unknown") .. ")"
end
color = db["PHEAL"]
if fromPlayer and not toPet then -- Show self healing under player column & with correct color.
color = db["THEAL"]
inout = -inout
end
-- Add healing to total healing received (incoming) if it is from others
if not fromPlayer and not fromPet then
totHealingIn = totHealingIn + realHeal_All
else -- otherwise add self healing (from player or his pet) to total healing done (outgoing)
totHealingOut = totHealingOut + realHeal_All
end
text = "+" .. text
elseif fromPlayer or fromPet then
color = db["THEAL"]
if
self:TrackStat(inout, "heal", spellName, texture, SCHOOL_STRINGS[spellSchool], realHeal_All, critical, message)
then
text = newhigh .. text .. newhigh
end
text = "+" .. text
if db["HEALERID"] == true then text = (destName or "Unknown") .. ": " .. text end
totHealingOut = totHealingOut + realHeal_All
end
-- If spell is blacklisted or too small, don't show it
if isBlacklisted(spellName, spellId) or realHeal_All < db["HFILTER"] then return end
self:DisplayEvent(inout, text, texture, color, message, spellName)
------------misses----------------
elseif etype == "MISS" then
local tcolor
if event == "SWING_MISSED" then
missType, _, amount = select(12, CombatLogGetCurrentEventInfo())
tcolor = "TMELEE"
else
spellId, spellName, _, missType, _, amount = select(12, CombatLogGetCurrentEventInfo())
texture = GetSpellTexture(spellId)
tcolor = "TSPELL"
end
text = _G[missType]
if missType == "ABSORB" and amount then
if fromPlayer or fromPet then
totHealingIn = totHealingIn + amount
else
totHealingOut = totHealingOut + amount
end
--@debug@
print(
false,
string_format(
"Heal in |cffffff00ABSORB|r is: |cff00aa00%s|r (%d)\n fromPlayer %s, fromPet %s, toPlayer %s, toPet: %s\n event: %s",
spellName or "SWING_MISSED",
amount,
tostring(fromPlayer),
tostring(fromPet),
tostring(toPlayer),
tostring(toPet),
event
)
)
print(false, string_format(" missType: %s, _G[missType]: %s", tostring(missType), tostring(_G[missType])))
--@end-debug@
end
--@debug@
if missType == "DEFLECT" or missType == "BLOCK" then
EavesDrop:AddToInspector({ CombatLogGetCurrentEventInfo() }, "deflectCLEU")
print(" ")
print(
string_format(
"spellID: %s, spellName: |cffff1000%s|r\namount: %s event: %s",
tostring(spellId),
tostring(spellName),
tostring(amount),
tostring(event)
)
)
print("-->", message)
print(" ")
end
--@end-debug@
if toPet then
inout = INCOMING
color = db["PETO"]
elseif fromPet then
inout = OUTGOING
color = db["PETI"]
elseif fromPlayer then
color = db[tcolor]
elseif toPlayer then
if missType == "REFLECT" then self:SetReflect(sourceName, spellName) end
color = db["PMISS"]
end
-- If spell is blacklisted, don't show it
if isBlacklisted(spellName, spellId) then return end
self:DisplayEvent(inout, text, texture, color, message, spellName)
------------leech and drains----------------
elseif etype == "DRAIN" then
if db["GAINS"] then
spellId, spellName, _, amount, powerType, extraAmount = select(12, CombatLogGetCurrentEventInfo())
texture = GetSpellTexture(spellId)
--@debug@
print(string_format("|cffff0000DRAIN!|r"))
print(
string_format(
"INC: %s, OUT: %s, amount: %s, extraAmount: %s",
tostring(inout == INCOMING),
tostring(inout == OUTGOING),
tostring(amount),
tostring(extraAmount)
)
)
print(string_format("powerType: %s, STRING: %s", tostring(powerType), tostring(POWER_STRINGS[powerType])))
--@end-debug@
if toPlayer then
if not fromPlayer and not fromPet then
totHealingIn = totHealingIn + amount
else
totHealingOut = totHealingOut + amount
end
text = string_format("-%d %s", amount, string_nil(POWER_STRINGS[powerType]))
color = db["PGAIN"]