-
Notifications
You must be signed in to change notification settings - Fork 5
/
HealBarsClassic.lua
810 lines (689 loc) · 26.5 KB
/
HealBarsClassic.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
local libCHC = LibStub("LibHealComm-4.0-Custom", true)
HealBarsClassic = LibStub("AceAddon-3.0"):NewAddon("HealBarsClassic")
local AceConfigDialog = LibStub("AceConfigDialog-3.0")
local AceConsole = LibStub("AceConsole-3.0")
local healBarTable = {}
local shieldBarTable = {}
local masterFrameTable = {}
local statusGUIDs = {}
local shieldGUIDs = {}
local barTypes = {['flat']={}, ['hot']={}, ['ownFlat']={}, ['ownHot']={}, ['afterOwnFlat']={}}
local currentHeals = {}
local playerGUID = UnitGUID('player')
local HBCdb = {}
local partyGUIDs = {
[UnitGUID("player")] = "player",
}
local globalFrameList = {
["player"] = _G["PlayerFrame"] ,
["pet"] = _G["PetFrame"],
["target"] = _G["TargetFrame"],
["focus"] = _G["FocusFrame"],
["party1"] = _G["PartyMemberFrame1"],
["partypet1"] = _G["PartyMemberFrame1PetFrame"],
["party2"] = _G["PartyMemberFrame2"],
["partypet2"] = _G["PartyMemberFrame2PetFrame"],
["party3"] = _G["PartyMemberFrame3"],
["partypet3"] = _G["PartyMemberFrame3PetFrame"],
["party4"] = _G["PartyMemberFrame4"],
["partypet4"] = _G["PartyMemberFrame4PetFrame"],
}
HBCDefaultColors = {
['flat'] = {130/255, 1, 0, 1.0},
['hot'] = {110/255, 230/255, 55/255, 0.7},
['ownFlat'] = {255/255, 0/255, 135/255, 1},
['ownHot'] = {230/255, 76/255, 105/255, 0.7},
}
HealBarsClassic.invulStatusTextConfigList = {
['DIVSHLD'] = 'Divine Shield - DIVSHLD',
['DIVPROT'] = 'Divine Protection - DIVPROT',
['BLSPROT'] = 'Blessing of Protection - BLSPROT',
['ICEBLCK'] = 'Ice Block - ICEBLCK',
['DIVINTR'] = 'Divine Intervention - DIVINTR',
}
HealBarsClassic.strongMitStatusTextConfigList = {
['EVASION'] = 'Evasion - EVASION',
['SHDWALL'] = 'Shield Wall - SHDWALL',
['CHEATDTH'] = 'Cheat Death - CHEATDTH'
}
HealBarsClassic.softMitStatusTextConfigList = {
['BARKSKIN'] = 'Barkskin - BARKSKIN',
['PAINSPR'] = 'Pain Supression - PAINSPR',
['SHMRAGE'] = 'Shamanistic Rage - SHMRAGE'
}
HealBarsClassic.miscStatusTextConfigList = {
-- ['INERVTE'] = 'Innervate - INERVTE',
-- ['SPIRIT'] = 'Spirit of Redemption - SPIRIT'
}
local defensiveSpells = {
[642] = {name = 'DIVSHLD',duration = 12, priority = 2} -- Divine Shield Rank 1
, [1020] = {name = 'DIVSHLD',duration = 12, priority = 2} -- Divine Shield Rank 2
, [1022] = {name = 'BLSPROT',duration = 6, priority = 10} -- Blessing of Protection Rank 1
, [5599] = {name = 'BLSPROT',duration = 6, priority = 10} -- Blessing of Protection Rank 2
, [10278] = {name = 'BLSPROT',duration = 6, priority = 10} -- Blessing of Protection Rank 3
, [498] = {name = 'DIVPROT',duration = 6, priority = 2} -- Divine Protection Rank 1
, [5573] = {name = 'DIVPROT',duration = 6, priority = 2} -- Divine Protection Rank 2
, [45438] = {name = 'ICEBLCK',duration = 10, priority = 2} -- Ice Block
, [19753] = {name = 'DIVINTR',duration = 45, priority = 1} -- Divine Intervention
-- (Rarely held for full duration & frequently breaks from release->res)
, [26669] = {name = 'EVASION', duration = 15, priority = 20} -- Evasion Rank 2
, [5277] = {name = 'EVASION', duration = 15, priority = 20} -- Evasion Rank 1
, [871] = {name = 'SHDWALL', duration = 10, priority = 5} -- Shield Wall
, [45182] = {name = 'CHEATDTH', duration = 3, priority = 5} -- Cheat Death
, [22812] = {name = 'BARKSKIN', duration = 12, priority = 30} -- Bark Skin
, [30823] = {name = 'SHMRGE', duration = 15, priority = 30} -- Shamanistic Rage
, [33206] = {name = 'PAINSPR', duration = 8, priority = 25} -- Pain Suppression
--, [20711] = {name = 'SPIRIT', duration = 15, priority = 1} -- Spirit of Redemption
--, [29166] = {name = 'INERVTE', duration = 20, priority = 40} -- Innervate
}
local shieldSpells = {
[17] = {} -- Power Word: Shield Rank 1
, [592] = {} -- Power Word: Shield Rank 2
, [600] = {} -- Power Word: Shield Rank 3
, [3747] = {} -- Power Word: Shield Rank 4
, [6065] = {} -- Power Word: Shield Rank 5
, [6066] = {} -- Power Word: Shield Rank 6
, [10898] = {} -- Power Word: Shield Rank 7
, [10899] = {} -- Power Word: Shield Rank 8
, [10900] = {} -- Power Word: Shield Rank 9
, [10901] = {} -- Power Word: Shield Rank 10
, [25217] = {} -- Power Word: Shield Rank 11
, [25218] = {} -- Power Word: Shield Rank 12
, [1463] = {} -- Mana Shield Rank 1
, [8494] = {} -- Mana Shield Rank 2
, [8495] = {} -- Mana Shield Rank 3
, [10191] = {} -- Mana Shield Rank 4
, [10192] = {} -- Mana Shield Rank 5
, [10193] = {} -- Mana Shield Rank 6
, [27131] = {} -- Mana Shield Rank 6
, [11426] = {} -- Ice Barrier Rank 1
, [13031] = {} -- Ice Barrier Rank 2
, [13032] = {} -- Ice Barrier Rank 3
, [13033] = {} -- Ice Barrier Rank 4
, [27134] = {} -- Ice Barrier Rank 5
, [33405] = {} -- Ice Barrier Rank 6
, [7812] = {} -- Sacrifice Rank 1
, [19438] = {} -- Sacrifice Rank 2
, [19440] = {} -- Sacrifice Rank 3
, [19441] = {} -- Sacrifice Rank 4
, [19442] = {} -- Sacrifice Rank 5
, [19443] = {} -- Sacrifice Rank 6
, [27273] = {} -- Sacrifice Rank 7
--, [22812] = {} -- Barkskin (debug only)
}
local HBCdefault = {
global = {
overhealPercent = 20,
timeframe = 3,
healTimeframe = 8,
channelTimeframe = 3,
showHots = true,
seperateHots = true,
seperateOwnHeals = false,
healColor = HBCDefaultColors.flat,
hotColor = HBCDefaultColors.hot,
ownHealColor = HBCDefaultColors.ownFlat,
ownHotColor = HBCDefaultColors.ownHot,
defensiveIndicator = true,
shieldGlow = false,
enabledStatusTexts = {
['*'] = false,
['DIVSHLD'] = true,
['DIVPROT'] = true,
['BLSPROT'] = true,
['DIVINTR'] = true,
['ICEBLCK'] = true,
['SHDWALL'] = true,
['EVASION'] = true,
['CHEATDTH'] = true,
--['SPIRIT'] = true,
},
predictiveHealthLost = false,
alternativeTexture = true,
fastUpdate = false,
fastUpdateDuration = 0.03, --~30 updates per second
}
}
function HealBarsClassic:ClearAllShields()
local guidsToWipe = {}
for guid, value in pairs(shieldGUIDs) do
if value then
table.insert(guidsToWipe,guid)
end
end
wipe(shieldGUIDs)
for _, guid in ipairs(guidsToWipe) do
HealBarsClassic:UpdateGUIDHeals(guid)
end
end
function HealBarsClassic:ColorTest(case)
if not currentHeals[playerGUID] then
currentHeals[playerGUID] = {}
end
local playerHeals = currentHeals[playerGUID]
if not case or case == 1 then
table.insert(playerHeals,{healType = 'ownFlat',amount = 700})
table.insert(playerHeals,{healType = 'flat',amount = 800})
table.insert(playerHeals,{healType = 'ownHot',amount = 500})
table.insert(playerHeals,{healType = 'hot',amount = 500})
elseif case == 2 then
table.insert(playerHeals,{healType = 'ownFlat',amount = 500})
table.insert(playerHeals,{healType = 'flat',amount = 500})
elseif case == 3 then
table.insert(playerHeals,{healType = 'flat',amount = 500})
table.insert(playerHeals,{healType = 'ownFlat',amount = 500})
end
HealBarsClassic:UpdateGUIDHeals(playerGUID)
end
function HealBarsClassic:getHealColor(healType)
local colorVarName, colorTable
if healType == 'flat' or healType == 'afterOwnFlat' then
colorTable = HBCdb.global.healColor
elseif healType == 'hot' then
colorTable = HBCdb.global.hotColor
elseif healType == 'ownFlat' then
colorTable = HBCdb.global.ownHealColor
else
colorTable = HBCdb.global.ownHotColor
end
if colorTable then
return unpack(colorTable)
end
end
function HealBarsClassic:CreateDefaultHealBars()
for name,unitFrame in pairs(globalFrameList) do
HealBarsClassic:createHealBars(unitFrame)
end
end
function HealBarsClassic:createHealBars(unitFrame, textureType)
if not unitFrame or unitFrame:IsForbidden() or not unitFrame:GetName() then return end
if masterFrameTable[unitFrame:GetName()] then return end
masterFrameTable[unitFrame:GetName()]=unitFrame
if not healBarTable[unitFrame] then
healBarTable[unitFrame] = {}
end
local currentBarList = healBarTable[unitFrame]
for healType, properties in pairs(barTypes) do
if not currentBarList[healType] then
local healFrame = CreateFrame("StatusBar"
, "HBCIncHealBar"..unitFrame:GetName()..healType, unitFrame)
healFrame:SetFrameStrata("LOW")
if(unitFrame:GetName() == 'FocusFrame') then
healFrame:SetFrameLevel(healFrame:GetFrameLevel())
end
healFrame:SetFrameLevel(healFrame:GetFrameLevel()-1)
if textureType == 'raid' or HBCdb.global.alternativeTexture then
healFrame:SetStatusBarTexture("Interface\\RaidFrame\\Raid-Bar-Hp-Fill")
else
healFrame:SetStatusBarTexture("Interface\\TargetingFrame\\UI-StatusBar")
end
healFrame:SetMinMaxValues(0, 1)
healFrame:SetValue(1)
healFrame:SetStatusBarColor(HealBarsClassic:getHealColor(healType))
healFrame:Hide()
currentBarList[healType] = healFrame
end
end
local _, healthBar = HealBarsClassic:GetFrameInfo(unitFrame)
local shieldFrame = healthBar:CreateTexture("HBCShieldBar"..unitFrame:GetName(),'ARTWORK',healthBar,2)
shieldFrame:SetTexture("Interface\\RaidFrame\\Shield-Overshield")
shieldFrame:SetBlendMode("ADD")
shieldFrame:SetWidth(16)
shieldFrame:Hide()
shieldBarTable[unitFrame] = shieldFrame
local eventFrame = CreateFrame("Frame","HealBarsClassicEventFrame"..unitFrame:GetName(), unitFrame)
eventFrame:SetScript("OnEvent",function(self) HealBarsClassic:UpdateHealBars(self:GetParent()) end)
local shieldEventFrame = CreateFrame("Frame","HealBarsClassicAuraEventFrame"..unitFrame:GetName(), unitFrame)
shieldEventFrame:SetScript("OnEvent",function(self) HealBarsClassic:UpdateAuras(self:GetParent()) end)
shieldEventFrame:RegisterUnitEvent('UNIT_AURA',(HealBarsClassic:GetFrameInfo(unitFrame)))
shieldEventFrame:RegisterUnitEvent('UNIT_HEALTH',(HealBarsClassic:GetFrameInfo(unitFrame)))
shieldEventFrame:RegisterUnitEvent('UNIT_MAXHEALTH',(HealBarsClassic:GetFrameInfo(unitFrame)))
end
function HealBarsClassic:UpdateGUIDHeals(GUID)
if partyGUIDs[targetGUID] then
if globalFrameList[partyGUIDs[targetGUID]] then
HealBarsClassic:UpdateHealBars(globalFrameList[partyGUIDs[targetGUID]])
end
end
for frameName, unitFrame in pairs(masterFrameTable) do
local displayedUnit = HealBarsClassic:GetFrameInfo(unitFrame)
if displayedUnit and UnitGUID(displayedUnit) == GUID then
HealBarsClassic:UpdateHealBars(unitFrame)
if unitFrame.statusText then
CompactUnitFrame_UpdateStatusText(unitFrame)
end
HealBarsClassic:UpdateShieldGlow(unitFrame)
end
end
end
function HealBarsClassic:GetFrameInfo(unitFrame)
local displayedUnit, healthBar
if not unitFrame then return end
if unitFrame.displayedUnit ~= nil then
displayedUnit = unitFrame.displayedUnit
else
displayedUnit = unitFrame.unit
end
if unitFrame.healthBar ~= nil then
healthBar = unitFrame.healthBar
else
healthBar = unitFrame.healthbar
end
return displayedUnit,healthBar
end
function HealBarsClassic:UpdateHealBars(unitFrame)
if not unitFrame then return end
local displayedUnit, healthBar = HealBarsClassic:GetFrameInfo(unitFrame)
if not displayedUnit or not UnitExists(displayedUnit) or not healBarTable[unitFrame] then return end
local eventFrame = _G['HealBarsClassicEventFrame'..unitFrame:GetName()]
eventFrame:RegisterUnitEvent("UNIT_HEALTH",(HealBarsClassic:GetFrameInfo(unitFrame)))
eventFrame:RegisterUnitEvent("UNIT_MAXHEALTH",(HealBarsClassic:GetFrameInfo(unitFrame)))
local unit = displayedUnit
local maxHealth= UnitHealthMax(unit)
local health= UnitHealth(unit)
local healthWidth=healthBar:GetWidth() * (health / maxHealth)
local maxWidth = healthBar:GetWidth() * ( 1 + (HBCdb.global.overhealPercent/100))
local healWidthTotal = 0
local currentHealsForGUID = currentHeals[UnitGUID(displayedUnit)]
if not currentHealsForGUID then
HealBarsClassic:ClearHealBar(unitFrame)
return
end
for index,healInfo in ipairs(currentHealsForGUID) do
local healType = healInfo.healType
local barFrame = healBarTable[unitFrame][healType]
local amount = healInfo.amount
if amount and amount > 0 and (health < maxHealth or HBCdb.global.overhealPercent > 0 )
and healthBar:IsVisible()
then
barFrame:Show()
local healWidth = healthBar:GetWidth() * (amount / maxHealth)
if healthWidth + healWidthTotal + healWidth >= maxWidth then
healWidth = maxWidth - healthWidth - healWidthTotal
if healWidth <= 0 then
barFrame:Hide()
end
end
barFrame:SetSize(healWidth,healthBar:GetHeight())
barFrame:ClearAllPoints()
barFrame:SetPoint("TOPLEFT", healthBar, "TOPLEFT", healthWidth + healWidthTotal, 0)
healWidthTotal = healWidthTotal + healWidth
else
barFrame:Hide()
end
end
end
function HealBarsClassic:UpdateShieldGlow(unitFrame)
local displayedUnit,healthBar = HealBarsClassic:GetFrameInfo(unitFrame)
local shieldFrame = _G['HBCShieldBar'..unitFrame:GetName()]
if HBCdb.global.shieldGlow and displayedUnit and shieldGUIDs[UnitGUID(displayedUnit)] then
local maxHealth= UnitHealthMax(displayedUnit)
local health= UnitHealth(displayedUnit)
local healthWidth=healthBar:GetWidth() * (health / maxHealth)
shieldFrame:SetPoint('TOPLEFT',healthBar,'TOPLEFT',healthWidth - 7,0)
shieldFrame:SetHeight(healthBar:GetHeight())
shieldFrame:Show()
else
shieldFrame:Hide()
end
end
local function UnitFrame_SetUnitHook(unitFrame)
HealBarsClassic:UnRegisterAllInactiveFrames()
HealBarsClassic:UpdateHealBars(unitFrame)
end
hooksecurefunc("UnitFrame_SetUnit", UnitFrame_SetUnitHook) -- This needs early hooking
local function CompactUnitFrame_SetUnitHook(unitFrame)
HealBarsClassic:createHealBars(unitFrame,'raid')
end
hooksecurefunc("CompactUnitFrame_SetUnit", CompactUnitFrame_SetUnitHook) -- This needs early hooking
function HealBarsClassic:UpdateAuras(unitFrame)
local index = 1
local statusUpdate = false
local unitId = HealBarsClassic:GetFrameInfo(unitFrame)
if not unitId then return end
local targetGUID = UnitGUID(unitId)
if not targetGUID then return end
--wipe current data
if not statusGUIDs[targetGUID] then
statusGUIDs[targetGUID] = {}
end
wipe(statusGUIDs[targetGUID])
shieldGUIDs[targetGUID] = false
repeat
local name, icon, count, debuffType, duration, expirationTime, source, isStealable, nameplateShowPersonal, spellId
= UnitBuff(unitId,index)
if spellId then
-- check defensive auras
if HBCdb.global.defensiveIndicator then
local spell = defensiveSpells[spellId]
if spell and HBCdb.global.enabledStatusTexts[spell.name] then
statusGUIDs[targetGUID][spell] = true
statusUpdate = true
end
end
-- check shield auras
if HBCdb.global.shieldGlow then
local spell = shieldSpells[spellId]
if spell then
shieldGUIDs[targetGUID] = true
statusUpdate = true
end
end
index = index + 1
end
until(not spellId)
HealBarsClassic:UpdateGUIDHeals(targetGUID)
end
function HealBarsClassic:GROUP_ROSTER_UPDATE()
HealBarsClassic:UnRegisterAllInactiveFrames()
end
function HealBarsClassic:UnRegisterAllInactiveFrames()
for frameName, unitFrame in pairs(masterFrameTable) do
local eventFrame = _G['HealBarsClassicEventFrame'..frameName]
if eventFrame then
local displayedUnit = HealBarsClassic:GetFrameInfo(unitFrame)
if frameName ~= 'target' and frameName ~= 'player' and frameName ~= 'focus' then
eventFrame:UnregisterAllEvents()
end
end
end
end
function CompactUnitFrame_UpdateStatusTextHBCHook(unitFrame)
if not unitFrame.statusText or not unitFrame.optionTable.displayStatusText
or not UnitIsConnected(unitFrame.displayedUnit) or UnitIsDeadOrGhost(unitFrame.displayedUnit) then return end
local healthLost = UnitHealthMax(unitFrame.displayedUnit) - UnitHealth(unitFrame.displayedUnit)
if HBCdb.global.defensiveIndicator then
local guid = UnitGUID(unitFrame.displayedUnit)
local statusEffects = statusGUIDs[guid] or {}
local priorityEffect = {}
for effect, _ in pairs(statusEffects) do
if not priorityEffect.priority or (priorityEffect.priority > effect.priority) then
priorityEffect.name = effect.name
priorityEffect.priority = effect.priority
end
end
if priorityEffect.name then
unitFrame.statusText:SetFormattedText("%s", priorityEffect.name)
unitFrame.statusText:Show()
return
end
end
--predictive health lost feature
if unitFrame.optionTable.healthText == "losthealth" and HBCdb.global.predictiveHealthLost and currentHeals then
local currentHeals = currentHeals[UnitGUID(unitFrame.displayedUnit)] or {}
local totalHeals = 0
for index, healInfo in ipairs(currentHeals) do
totalHeals = totalHeals + healInfo.amount
end
local healthDelta = totalHeals - healthLost
if healthDelta >= 0 then
unitFrame.statusText:Hide()
else
unitFrame.statusText:SetFormattedText("%d", healthDelta)
unitFrame.statusText:Show()
end
end
end
function HealBarsClassic:OnInitialize()
HBCdb = LibStub("AceDB-3.0"):New("HealBarSettings", HBCdefault)
HBCdb.RegisterCallback(HealBarsClassic, "OnProfileChanged", "UpdateColors")
HealBarsClassic.HBCdb = HBCdb
HealBarsClassic:CreateDefaultHealBars()
HealBarsClassic:CreateConfigs()
hooksecurefunc("CompactUnitFrame_UpdateStatusText", CompactUnitFrame_UpdateStatusTextHBCHook)
libCHC.RegisterCallback(HealBarsClassic, "HealComm_HealStarted", "HealComm_HealUpdated")
libCHC.RegisterCallback(HealBarsClassic, "HealComm_HealStopped")
libCHC.RegisterCallback(HealBarsClassic, "HealComm_HealDelayed", "HealComm_HealUpdated")
libCHC.RegisterCallback(HealBarsClassic, "HealComm_HealUpdated")
libCHC.RegisterCallback(HealBarsClassic, "HealComm_ModifierChanged")
libCHC.RegisterCallback(HealBarsClassic, "HealComm_GUIDDisappeared")
AceConsole:RegisterChatCommand(
'hbc'
,function(args) HealBarsClassic:ChatCommand(args) end)
AceConsole:RegisterChatCommand(
'HealBarsClassic'
,function(args) HealBarsClassic:ChatCommand(args) end)
C_Timer.After(HBCdb.global.fastUpdateDuration,HealBarsClassic.UpdateHealthValuesLoop)
end
function HealBarsClassic:ChatCommand(args)
if args ~= nil then
arg = AceConsole:GetArgs(args,1)
end
if arg == nil then
AceConfigDialog:Open('HBCOptions')
elseif arg == 'rc' then
AceConsole:Print('|c42f581FFHealBarsClassic|r - These players have casted a heal while using a compatible healing addon:\n')
local nameSet = {}
for frameName, unitFrame in pairs(masterFrameTable) do
displayedUnit = HealBarsClassic:GetFrameInfo(unitFrame)
if displayedUnit and UnitGUID(displayedUnit)
and libCHC:GUIDHasHealed(UnitGUID(displayedUnit)) then
nameSet[(UnitName(displayedUnit))] = true
end
end
for name,_ in pairs(nameSet) do
AceConsole:Print(name)
end
else
AceConsole:Print('|c42f581FFHealBarsClassic|r\n'..
'|c42f5daFF/hbc|r - Open settings menu.\n'..
'|c42f5daFF/hbc rc|r - Raid Check. Players only show if you\'ve seen them cast'..
' a heal since they\'ve joined the raid. Cross-addon compatible.')
end
end
function HealBarsClassic:UpdateColors()
for unitFrame, unitFrameBars in pairs(healBarTable) do
for barType, barFrame in pairs(unitFrameBars) do
barFrame:SetStatusBarColor(HealBarsClassic:getHealColor(barType))
end
end
end
function HealBarsClassic:UpdateHealthValuesLoop()
if HBCdb.global.fastUpdate and (UnitInParty("player") or UnitInRaid("player")) then
local unitFrame = _G["CompactRaidFrame1"]
local num = 1
while unitFrame do
if unitFrame.displayedUnit and UnitExists(unitFrame.displayedUnit) then
CompactUnitFrame_UpdateMaxHealth(unitFrame.healthBar:GetParent())
CompactUnitFrame_UpdateHealth(unitFrame.healthBar:GetParent())
end
num = num + 1
unitFrame = _G["CompactRaidFrame"..num]
end
--[[
for k=1, NUM_RAID_PULLOUT_FRAMES do
frame = getglobal("RaidPullout"..k)
for z=1, frame.numPulloutButtons do
unitFrame = getglobal(frame:GetName().."Button"..z)
if unitFrame.unit and UnitExists(unitFrame.unit) then
CompactUnitFrame_UpdateMaxHealth(unitFrame.healthBar:GetParent())
CompactUnitFrame_UpdateHealth(unitFrame.healthBar:GetParent())
end
end
end--]]
for i=1, 8 do
local grpHeader = "CompactRaidGroup"..i
if _G[grpHeader] then
for k=1, 5 do
unitFrame = _G[grpHeader.."Member"..k]
if unitFrame and unitFrame.displayedUnit and UnitExists(unitFrame.displayedUnit) then
CompactUnitFrame_UpdateMaxHealth(unitFrame.healthBar:GetParent())
CompactUnitFrame_UpdateHealth(unitFrame.healthBar:GetParent())
end
end
end
end
C_Timer.After(HBCdb.global.fastUpdateDuration,HealBarsClassic.UpdateHealthValuesLoop)
else
C_Timer.After(1,HealBarsClassic.UpdateHealthValuesLoop)
end
end
function HealBarsClassic:PLAYER_TARGET_CHANGED(frame)
HealBarsClassic:UpdateHealBars(_G['TargetFrame'])
HealBarsClassic:UpdateAuras(_G['TargetFrame'])
end
function HealBarsClassic:PLAYER_ROLES_ASSIGNED()
local frame, unitFrame, num
for guid,unit in pairs(partyGUIDs) do
if strsub(unit,1,5) == "party" then
partyGUIDs[guid] = nil
end
end
if UnitInParty("player") then
for i=1, MAX_PARTY_MEMBERS do
local p = "party"..i
if UnitExists(p) then
partyGUIDs[UnitGUID(p)] = p
else
break
end
end
unitFrame = _G["CompactPartyFrameMember1"]
num = 1
while unitFrame do
HealBarsClassic:UpdateHealBars(unitFrame)
num = num + 1
unitFrame = _G["CompactPartyFrameMember"..num]
end
unitFrame = _G["CompactRaidFrame1"]
num = 1
while unitFrame do
HealBarsClassic:UpdateHealBars(unitFrame)
num = num + 1
unitFrame = _G["CompactRaidFrame"..num]
end
end
if UnitInRaid("player") then
for k=1, NUM_RAID_PULLOUT_FRAMES do
frame = _G["RaidPullout"..k]
for z=1, frame.numPulloutButtons do
unitFrame = _G[frame:GetName().."Button"..z]
HealBarsClassic:UpdateHealBars(unitFrame)
end
end
for i=1, 8 do
local grpHeader = "CompactRaidGroup"..i
if _G[grpHeader] then
for k=1, 5 do
unitFrame = _G[grpHeader.."Member"..k]
HealBarsClassic:UpdateHealBars(unitFrame)
end
end
end
end
end
function HealBarsClassic:HealComm_HealUpdated(event, casterGUID, spellID, healType, endTime, ...)
if (bit.band(healType,libCHC.DIRECT_HEALS) > 0 or healType == libCHC.BOMB_HEALS)
and (endTime - GetTime()) > HBCdb.global.healTimeframe then
self:UpdateIncoming(endTime - GetTime() - HBCdb.global.healTimeframe , ...)
--[[
elseif HBCdb.global.timeframe < 4 and healType == libCHC.HOT_HEALS then
self:UpdateIncoming(0.5, ...)
--]]
else
self:UpdateIncoming(nil, ...)
end
end
function HealBarsClassic:HealComm_HealStopped(event, casterGUID, spellID, healType, interrupted, ...)
self:UpdateIncoming(nil, ...)
end
function HealBarsClassic:HealComm_ModifierChanged(event, guid)
self:UpdateIncoming(nil, guid)
end
function HealBarsClassic:HealComm_GUIDDisappeared(event, guid)
self:UpdateIncoming(nil,guid)
end
function HealBarsClassic:ResetHealBars()
wipe(currentHeals)
for unitFrame, _ in pairs(healBarTable) do
HealBarsClassic:ClearHealBar(unitFrame)
end
end
function HealBarsClassic:ClearHealBar(unitFrame)
for _,barFrame in pairs(healBarTable[unitFrame]) do
barFrame:SetWidth(0)
barFrame:Hide()
end
end
function HealBarsClassic:UpdateIncoming(callbackTime, ...)
local targetGUID, healType
local guidTable = {}
local currentTime =GetTime()
local hotType= bit.bor(libCHC.HOT_HEALS,libCHC.BOMB_HEALS)
local channelType = libCHC.CHANNEL_HEALS
if HBCdb.global.showHots and not HBCdb.global.seperateHots then
healType = bit.bor(hotType,libCHC.DIRECT_HEALS)
else
healType = libCHC.DIRECT_HEALS
end
for i=1, select("#", ...) do
local amountTable = {}
targetGUID = select(i, ...)
local targetHealMod = (libCHC:GetHealModifier(targetGUID) or 1)
if not currentHeals[targetGUID] then
currentHeals[targetGUID] = {}
else
wipe(currentHeals[targetGUID])
end
if not HBCdb.global.seperateOwnColor then
local flatAmount = (libCHC:GetHealAmount(targetGUID, healType, currentTime + HBCdb.global.healTimeframe) or 0) +
(libCHC:GetHealAmount(targetGUID, channelType, currentTime + HBCdb.global.channelTimeframe) or 0)
--calc flat/all heals
table.insert(currentHeals[targetGUID],{healType = 'flat'
, amount = flatAmount * targetHealMod})
--calc hot heals
if HBCdb.global.showHots and HBCdb.global.seperateHots then
table.insert(currentHeals[targetGUID],{healType = 'hot'
, amount = (libCHC:GetHealAmount(targetGUID, hotType, currentTime + HBCdb.global.timeframe) or 0) * targetHealMod})
end
else
local ownHealAmount,_,ownHealTime = libCHC:GetTimeframeHealAmount(targetGUID,
healType,currentTime,currentTime + HBCdb.global.healTimeframe,nil,playerGUID)
ownHealAmount = ownHealAmount + (libCHC:GetTimeframeHealAmount(targetGUID,
channelType,currentTime,currentTime + HBCdb.global.channelTimeframe,nil,playerGUID) or 0)
ownHealAmount = ownHealAmount * targetHealMod
local beforeHealAmount = 0
if ownHealTime then
beforeHealAmount = (libCHC:GetTimeframeHealAmount(targetGUID,
healType,currentTime, ownHealTime - 0.001, playerGUID) or 0)
+ (libCHC:GetTimeframeHealAmount(targetGUID,
channelType,currentTime, ownHealTime - 0.001, playerGUID) or 0)
beforeHealAmount = beforeHealAmount * targetHealMod
else
ownHealTime = 0
end
local afterHealAmount = (libCHC:GetTimeframeHealAmount(targetGUID,
healType,ownHealTime,currentTime + HBCdb.global.healTimeframe, playerGUID) or 0)
afterHealAmount = afterHealAmount + (libCHC:GetTimeframeHealAmount(targetGUID,
channelType,ownHealTime,currentTime + HBCdb.global.channelTimeframe, playerGUID) or 0)
afterHealAmount = afterHealAmount * targetHealMod
table.insert(currentHeals[targetGUID],{healType = 'flat', amount = beforeHealAmount})
table.insert(currentHeals[targetGUID],{healType = 'ownFlat', amount = ownHealAmount})
table.insert(currentHeals[targetGUID],{healType = 'afterOwnFlat', amount = afterHealAmount})
if HBCdb.global.showHots then
if HBCdb.global.seperateHots then
table.insert(currentHeals[targetGUID],{healType = 'ownHot'
, amount = (libCHC:GetHealAmount(targetGUID, hotType, GetTime() + HBCdb.global.timeframe, playerGUID) or 0) * targetHealMod})
table.insert(currentHeals[targetGUID],{healType = 'hot'
, amount = (libCHC:GetOthersHealAmount(targetGUID, hotType, GetTime() + HBCdb.global.timeframe) or 0) * targetHealMod})
else
table.insert(currentHeals[targetGUID],{healType = 'hot'
, amount = (libCHC:GetHealAmount(targetGUID, hotType, currentTime + HBCdb.global.timeframe) or 0) * targetHealMod})
end
end
end
HealBarsClassic:UpdateGUIDHeals(targetGUID)
end
if callbackTime then
local args = {...}
C_Timer.After(callbackTime, function()
HealBarsClassic:UpdateIncoming(nil, unpack(args))
end)
end
end
local eventFrame = CreateFrame("Frame")
eventFrame:RegisterEvent("PLAYER_TARGET_CHANGED")
eventFrame:RegisterEvent("PLAYER_ROLES_ASSIGNED")
eventFrame:SetScript("OnEvent", function(self, event, ...)
HealBarsClassic[event](self, ...) end)
--[[ End of "Event Registration" code section ]]--