-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathBuffLib.lua
659 lines (576 loc) · 21.6 KB
/
BuffLib.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
local BuffLibabilityIDs = {
-- MISC & Racials ---------------------
[11196] = 60, -- Recently Bandaged
[44055] = 15, -- Battlemaster (1750 HP)
[19305] = 15, -- Starshards
[2651] = 15, -- Elune's Grace
[25467] = 24, -- Devouring Plague
[20600] = 20, -- Perception
[33697] = 15, -- Blood Fury
[20594] = 8, -- Stoneform
[28880] = 15, -- Gift of the Naaru
[26296] = 10, -- Berserking
[43716] = 20, -- Call of the Berserker ( Berserker's Call buff )
[7744] = 5, -- Will of the Forsaken
-- Rogue ------------------------------
-- Defensive
[45182] = 3, -- Cheat Death
[31224] = 5, -- Cloak of Shadows
[26669] = 15, -- Evasion
[11305] = 15, -- Sprint
-- Offensive
[13750] = 15, -- Adrenaline Rush
[14278] = 7, -- Ghostly Strike dodge buff
[13877] = 15, -- Blade Flurry
[8647] = 30, -- Expose Armor
[26679] = 6, -- Deadly Throw
[703] = 18, -- Garrote bleed
[1330] = 3, -- Garrote - Silence
-- CC
[1833] = 4, -- Cheap Shot
[8643] = 6, -- Kidney Shot
[1776] = 4, -- Gouge
[2094] = 10, -- Blind
[6770] = 10, -- Sap
-- Poisons
[13220] = 15, -- Wound Poison
[11400] = 10, -- Mind-Numbing Poison III
[3420] = 12, -- Crippling Poison
[2835] = 12, -- Deadly Poison
-- Druid -------------------------------
-- Defensive
[22812] = 12, -- Barkskin
[29166] = 20, -- Innervate
[16689] = 45, -- Nature's Grasp
[22842] = 10, -- Frenzied Regeneration
-- Healing
[33763] = 7, -- Lifebloom
[26980] = 21, -- Regrowth
[26982] = 12, -- Rejuvenation
[14253] = 8, -- Abolish Poison
-- Offensive
[26993] = 40, -- Fairie Fire
[27011] = 40, -- Fairie Fire (Feral)
[5570] = 12, -- Insect Swarm
[8921] = 12, -- Moonfire
[33745] = 15, -- Lacerate
[9007] = 18, -- Pounce Bleed
-- CC
[33786] = 6, -- Cyclone
[26989] = 10, -- Roots
[2637] = 10, -- Hibernate
[5211] = 5, -- Bash
[22570] = 5, -- Maim (4p 5s)
[9005] = 3, -- Pounce stun
-- Warrior ------------------------------
-- Offensive
[12292] = 30, -- Death Wish
[11597] = 30, -- Sunder Armor
[18499] = 10, -- Berserker Rage
[12294] = 10, -- Mortal Strike
[1715] = 10, -- Hamstring
[772] = 21, -- Rend
[20230] = 15, -- Retaliation
[1719] = 15, -- Recklessness
[871] = 10, -- Shield Wall
[12323] = 6, -- Piercing Howl
[25274] = 3, -- Intercept Stun
[5530] = 3, -- Mace Stun Effect
[34510] = 5, -- Stormherald Stun
-- Defensive
[3411] = 10, -- Intervene
[23920] = 5, -- Spell Reflection
[676] = 10, -- Disarm
[12975] = 20, -- Last Stand
-- CC
[5246] = 8, -- Intimidating Shout
[12809] = 5, -- Concussion Blow
-- Shaman -------------------------------
-- Offensive
[32182] = 40, -- Heroism
[2825] = 40, -- Bloodlust
[8050] = 12, -- Flame Shock
[8056] = 6, -- Frost Shock
-- Defensive
[30823] = 15, -- Shamanistic Rage
-- Priest -------------------------------
-- Offensive
[10060] = 15, -- Power Infusion
[25368] = 18, -- Shadow Word: Pain
[8122] = 8, -- Psychic Scream
[15487] = 5, -- Silence
[34917] = 15, -- Vampiric Touch
[44047] = 2, -- Chastise
[15334] = 15, -- Shadow Weaving
-- Defensive
[27607] = 30, -- Power Word: Shield
[6788] = 13, -- Weakened Soul
[33206] = 8, -- Pain Suppression
[6346] = 180, -- Fear Ward
[27828] = 10, -- Focused Casting
[33146] = 6, -- Blessed Resilience
[27818] = 10, -- Blessed Recovery
[45244] = 8, -- Focused Will
-- Healing
[33076] = 30, -- Prayer of Mending (needs a hack because duration is 10 after first jump)
[139] = 15, -- Renew
-- Paladin -------------------------------
-- Offensive
[31884] = 20, -- Avenging Wrath
[853] = 6, -- Hammer of Justice
[20066] = 6, -- Repentance
[25771] = 60, -- Forbearance
-- Defensive
[1044] = 14, -- Blessing of Freedom
[1020] = 12, -- Divine Shield
[27148] = 30, -- Blessing of Sacrifice
[10278] = 10, -- Blessing of Protection
[31842] = 15, -- Divine Illumination
-- Mage ----------------------------------
-- Offensive
[133] = 8, -- Fireball debuff
[120] = 8, -- Cone of Cold
[12472] = 20, -- Icy Veins
[116] = 9, -- Frostbolt debuff
[2139] = 4, --Counterspell
[12042] = 15, -- Arcane Power
[31589] = 15, -- Slow
[18469] = 4, -- Counterspell - Silenced
[33043] = 4, -- Dragon's Breath
[33395] = 8, -- Freeze (Watelemental)
[12579] = 15, -- Winter's Chill
-- Defensive
[45438] = 10, -- Ice Block
[12051] = 8, -- Evocation
[66] = 5, -- Invisibilty fade
[41425] = 30, -- Hypothermia
[11426] = 60, -- Ice Barriers
-- CC
[118] = 10, -- Poly
[28272] = 10, -- Poly Pig
[28271] = 10, -- Poly Turtle
[27088] = 8, -- Frostnova
[12494] = 5, -- Frostbite
-- Warlock --------------------------------
-- Offensive
[172] = 18, -- Corruption
[980] = 24, -- Curse of Agony
[27243] = 18, -- Seed of Corruption
[348] = 15, -- Immolate
[18265] = 30, -- Siphon Life
[27223] = 3, -- Death Coil
[24259] = 3, -- Spell Lock
-- Defensive
[18708] = 15, -- Fel Domination
-- CC
[1714] = 6, -- Curse of Tongues
[5782] = 10, -- Fear
[5484] = 8, -- Howl of Terror
[710] = 10, -- Banish
-- Hunter ---------------------------------
-- Offensive
[27065] = 10, -- Aimed Shot
[19574] = 18, -- Bestial Wrath
[38373] = 18, -- The Beast Within
[27018] = 8, -- Viper Sting
[1978] = 15, -- Serpent Sting
[3045] = 15, -- Rapid Fire
[13813] = 20, -- Explosive Trap
[13795] = 15, -- Immolation Trap
[19577] = 3, -- Intimidation
-- Defensive
[19263] = 10, -- Deterrence
-- CC
[14309] = 10, -- Freezing Trap Effect
[13810] = 30, -- Frost Trap Aura
[14326] = 10, -- Scare Beast
[2974] = 10, -- Wing Clip
[19386] = 12, -- Wyvern Sting
[19503] = 4, -- Scatter Shot
[34490] = 3, -- Silencing Shot
[19229] = 5, -- Improved Wing Clip
[19410] = 3, -- Improved Concussive Shot
[5116] = 4, -- Concussive Shot
[19185] = 4, -- Entrapment
};
BuffLibDebug = 0
BuffLibDB = BuffLibDB or { sync = true}
local function log(msg)
if BuffLibDebug == 1 then
DEFAULT_CHAT_FRAME:AddMessage(msg)
elseif BuffLibDebug == 0 then
return
end
end -- alias for convenience
local DR_RESET_TIME = 15
local DRLib
local logDelay = 0.05
local applyEvents = {
"SPELL_AURA_APPLIED",
"SPELL_AURA_REFRESH",
"SPELL_AURA_APPLIED_DOSE",
"SPELL_CAST_SUCCESS",
}
local removeEvents = {
"SPELL_AURA_REMOVE",
"SPELL_AURA_DISPEL",
"SPELL_AURA_STOLEN",
}
local _UnitBuff = UnitBuff
local _UnitDebuff = UnitDebuff
local function firstToUpper(str)
if (str~=nil) then
return (str:gsub("^%l", string.upper));
else
return nil;
end
end
local function wipe(t)
for k,v in pairs(t) do
t[k]=nil
end
end
local BuffLib = CreateFrame("Frame", nil, UIParent);
function BuffLib:OnEvent(event, ...) -- functions created in "object:method"-style have an implicit first parameter of "self", which points to object
self[event](self, ...) -- route event parameters to LoseControl:event methods
end
BuffLib:SetScript("OnEvent", BuffLib.OnEvent)
BuffLib:RegisterEvent("PLAYER_ENTERING_WORLD")
BuffLib:RegisterEvent("PLAYER_LOGIN")
function BuffLib:InitDR(destGUID, spellID, event)
if type(self.guids[destGUID]) ~= "table" then
self.guids[destGUID] = { }
end
local drCat = DRLib:GetSpellCategory(spellID)
if drCat then
local tracked = self.guids[destGUID][drCat]
--first AURA_APPLIED - initialize DR
if not self.guids[destGUID][drCat] then
self.guids[destGUID][drCat] = { reset = 99999999, diminished = 1.0, lastDR = 0 }
--another AURA_APPLIED - reset DR if run out of time
elseif tracked and tracked.reset <= GetTime() then -- reset DR because timer ran out
tracked.diminished = 1.0
tracked.reset = 99999999
tracked.lastDR = 0
log(DR_RESET_TIME.." seconds DR timer ran out, resetting "..drCat)
--AURA_REMOVE - start timer and DR duration (maybe also on AURA_REFRESH?)
elseif event == "SPELL_AURA_REMOVED" then
tracked.reset = GetTime() + DR_RESET_TIME
tracked.lastDR = 0
log("start "..DR_RESET_TIME.." seconds DR timer "..GetSpellInfo(spellID))
end
end
end
function BuffLib:NextDR(destGUID, spellID, event)
local tracked
local drCat
if self.guids[destGUID] then
drCat = DRLib:GetSpellCategory(spellID)
tracked = self.guids[destGUID][drCat]
end
if tracked and tracked.lastDR+0.5 <= GetTime() then
tracked.diminished = DRLib:NextDR(tracked.diminished)
tracked.lastDR = GetTime()
log("next DR: "..GetSpellInfo(spellID).. " "..drCat)
end
end
function BuffLib:CreateFrames(destGUID, spellName, spellID)
-- don't create any more frames than necessary to avoid memory overload
if self.guids[destGUID] and self.guids[destGUID][spellName] then
self:UpdateFrames(destGUID, spellName, spellID)
else
local diminished = 1.0
local tracked
if( self.guids[destGUID] ) then
local drCat = DRLib:GetSpellCategory(spellID)
tracked = self.guids[destGUID][drCat]
if (tracked) then
diminished = tracked.diminished
--log(spellName.." "..self.abilities[spellName]*diminished)
end
end
if type(self.guids[destGUID]) ~= "table" then
self.guids[destGUID] = { }
end
--self.guids[destGUID][spellName] = CreateFrame("Frame", spellName .. "_" .. destGUID)
self.guids[destGUID][spellName] = {}
-- create information other addons can read using getglobal(spellName_GUIDTarget)
self.guids[destGUID][spellName].startTime = GetTime()
self.guids[destGUID][spellName].endTime = self.abilities[spellName]*diminished
--log(spellName.." "..self.abilities[spellName]*diminished.." CreateFrames")
end
end
function BuffLib:UpdateFrames(destGUID, spellName, spellID)
if self.guids[destGUID] and self.guids[destGUID][spellName] and self.abilities[spellName] then
local diminished = 1.0
local tracked
if( self.guids[destGUID] ) then
local drCat = DRLib:GetSpellCategory(spellID)
tracked = self.guids[destGUID][drCat]
if (tracked) then
diminished = tracked.diminished
--log(spellName.." "..self.abilities[spellName]*diminished)
end
end
-- update "library"
self.guids[destGUID][spellName].startTime = GetTime()
self.guids[destGUID][spellName].endTime = self.abilities[spellName]*diminished
--log(spellName.." "..self.abilities[spellName]*diminished.." UpdateFrames")
end
end
function BuffLib:HideFrames(destGUID, spellName, spellID)
if self.guids[destGUID] and self.guids[destGUID][spellName] and self.abilities[spellName] then
-- combatLog
self.guids[destGUID][spellName].startTime = 0
self.guids[destGUID][spellName].endTime = 0
-- sync
self.guids[destGUID][spellName].timeLeft = 0
self.guids[destGUID][spellName].getTime = 0
end
end
function BuffLib:PLAYER_LOGIN(...)
self:CreateOptions()
end
function BuffLib:PLAYER_ENTERING_WORLD(...)
-- clear frames, just to be sure
if type(self.guids) == "table" then
for k,v in pairs(self.guids) do
for ke,va in pairs(self.abilities) do
local frame = getglobal(ke.."_"..k)
if frame then
frame = nil
end
end
self.guids[k]=nil
end
end
self.guids = {}
self.abilities = {}
for k,v in pairs(BuffLibabilityIDs) do
self.abilities[GetSpellInfo(k)]=v;
end
DRLib = LibStub("DRData-1.0")
self:RegisterEvent("COMBAT_LOG_EVENT_UNFILTERED")
self:RegisterEvent("CHAT_MSG_ADDON")
if BuffLibDB.sync == true then
self:RegisterEvent("UNIT_AURA")
end
end
--[[
first: initialize DR with 1.0 (full duration), if timestamp older than 15 seconds, reset to 1.0
next: AFTER calculating spell duration, divide DR by 2 (0.5, 0.25, ...) IF a CC is applied
next: on REMOVE, set a timestamp as "DR timer"
--]]
function BuffLib:COMBAT_LOG_EVENT_UNFILTERED(...)
local timestamp, eventType, sourceGUID,sourceName,sourceFlags,destGUID,destName,destFlags,spellID,spellName,spellSchool,auraType = select ( 1 , ... );
-- DR can be applied by all spells, therefore outside of self.abilities[name]
if eventType == "SPELL_AURA_APPLIED" or eventType == "SPELL_AURA_REFRESH" or eventType == "SPELL_AURA_REMOVED" or (eventType == "SPELL_CAST_SUCCESS" and spellSchool == "0x1") then
self:InitDR(destGUID, spellID, eventType)
end
if self.abilities[spellName] and (eventType == "SPELL_AURA_APPLIED") then -- check if spell just used is in list
-- filter multiple incorrect combatlog events || don't want to trigger spell timer twice if SUCCESS+REFRESH or SUCCESS+APPLIED
if self.guids[destGUID] and self.guids[destGUID][spellName] and self.guids[destGUID][spellName].lastTime and self.guids[destGUID][spellName].lastTime+logDelay <= GetTime() then
self:CreateFrames(destGUID, spellName, spellID)
elseif not self.guids[destGUID] or not self.guids[destGUID][spellName] or not self.guids[destGUID][spellName].lastTime then
self:CreateFrames(destGUID, spellName, spellID)
end
-- have to also take CAST_SUCCESS because it's the only way to get refreshed spells like MS, Harmstring etc
elseif self.abilities[spellName] and (eventType == "SPELL_AURA_REFRESH" or eventType == "SPELL_AURA_APPLIED_DOSE" or eventType == "SPELL_CAST_SUCCESS") then
if self.guids[destGUID] and self.guids[destGUID][spellName] and self.guids[destGUID][spellName].lastTime and self.guids[destGUID][spellName].lastTime+logDelay <= GetTime() then
self:CreateFrames(destGUID, spellName, spellID)
elseif not self.guids[destGUID] or not self.guids[destGUID][spellName] or not self.guids[destGUID][spellName].lastTime then
self:CreateFrames(destGUID, spellName, spellID)
end
elseif self.abilities[spellName] and removeEvents[eventType] then
self:HideFrames(destGUID, spellName, spellID)
end
-- some spells do not have AURA_REFRESH because they are physical, CAST_SUCCESS works though
-- could technically catch even more by just using CAST_SUCCESS without spellSchool
if eventType == "SPELL_AURA_APPLIED" or eventType == "SPELL_AURA_REFRESH" or (eventType == "SPELL_CAST_SUCCESS" and spellSchool == "0x1") then
self:NextDR(destGUID, spellID, eventType)
end
-- hack for Wound Poison
if spellName == GetSpellInfo(13220) and eventType == "SPELL_DAMAGE" then
self:CreateFrames(destGUID, spellName, spellID)
end
-- call UNIT_AURA on any units where the player COULD see buff/debuff durations
-- UNIT_AURA does not fire automatically when a spell is refreshed :(
-- the self:UNIT_AURA() sends sync messages
if eventType == "SPELL_AURA_REFRESH" and BuffLibDB.sync == true then
if destGUID == UnitGUID("player") then
self:UNIT_AURA("player")
end
end
--[[
timer of last update on this spell, this is to ensure that multiple combatlog events will not overwrite the current timer
for example CAST_SUCCESS and AURA_APPLIED fire at the SAME time (or virtually same time)
only do this for spells which can actually DR - anything else doesn't matter
--]]
if self.abilities[spellName] and DRLib:GetSpellCategory(spellID) then
if self.guids[destGUID] and self.guids[destGUID][spellName] and eventType ~= "SPELL_AURA_REMOVE" then
self.guids[destGUID][spellName].lastTime = GetTime()
--log("setting lastTime")
end
end
end
function BuffLib:CHAT_MSG_ADDON(prefix, message, channel, sender)
if prefix == "BuffLib" and sender ~= UnitName("player") then
local guid, name, duration, timeLeft = strsplit(",", message)
if guid == UnitGUID("player") then return end
--local EBFrame = getglobal(name.."_"..guid)
local EBFrame
if self.guids[guid] then
EBFrame = self.guids[guid][name]
end
if EBFrame ~= nil then
EBFrame.timeLeft = tonumber(timeLeft)
EBFrame.duration = tonumber(duration)
EBFrame.getTime = GetTime()
--[[delete combatlog data
EBFrame.startTime = nil
EBFrame.endTime = nil]]
else
--self.guids[guid][name] = CreateFrame("Frame", name.."_"..guid, UIParent)
if not self.guids[guid] then return end
self.guids[guid][name] = {}
self.guids[guid][name].timeLeft = tonumber(timeLeft)
self.guids[guid][name].duration = tonumber(duration)
self.guids[guid][name].getTime = GetTime()
end
local units = {
["target"] = true,
["focus"] = true,
["pet"] = true,
["party1"] = true,
["party2"] = true,
["party3"] = true,
["party4"] = true,
}
for unit,v in pairs(units) do
if(UnitGUID(unit) == guid) then
local aura = ArenaLiveCore:GetHandler("Aura");
local indicator = ArenaLiveCore:GetHandler("CCIndicator");
aura:OnEvent("UNIT_AURA", unit);
indicator:OnEvent("UNIT_AURA", unit);
end
end
end
end
function BuffLib:UNIT_AURA(unitID, eventType)
if unitID == "player" or unitID == "target" or unitID == "focus" then
for i=1, 40 do
local name, rank, icon, count, duration, timeLeft = _UnitBuff(unitID, i, castable)
if timeLeft ~= nil then -- can see timer, perfect
self:SendSync(UnitGUID(unitID)..","..name..","..duration..","..timeLeft)
end
local name, rank, icon, count, debuffType, duration, timeLeft = _UnitDebuff(unitID, i, castable)
if timeLeft ~= nil then
self:SendSync(UnitGUID(unitID)..","..name..","..duration..","..timeLeft)
end
end
end
end
function BuffLib:SendSync(message)
local inInstance, instanceType = IsInInstance()
if instanceType == "pvp" then
SendAddonMessage("BuffLib", message, "BATTLEGROUND")
elseif instanceType == "raid" then
SendAddonMessage("BuffLib", message, "RAID")
elseif instanceType == "arena" or instanceType == "party" then
SendAddonMessage("BuffLib", message, "PARTY")
elseif instanceType == "none" then
if UnitGUID("party1") then
SendAddonMessage("BuffLib", message, "PARTY")
elseif UnitGUID("raid1") then
SendAddonMessage("BuffLib", message, "RAID")
end
end
end
local SO = LibStub("LibSimpleOptions-1.0")
function BuffLib:CreateOptions()
local panel = SO.AddOptionsPanel("BuffLib", function() end)
self.panel = panel
SO.AddSlashCommand("BuffLib","/bufflib")
SO.AddSlashCommand("BuffLib","/bl")
local title, subText = panel:MakeTitleTextAndSubText("Buff Library Addon", "General settings")
local sync = panel:MakeToggle(
'name', 'Synchronize timers',
'description', 'Turns off synchronizing timers with your teammates. Could prevent lags.',
'default', false,
'getFunc', function() return BuffLibDB.sync end,
'setFunc', function(value) BuffLibDB.sync = value BuffLib:PLAYER_ENTERING_WORLD() end)
sync:SetPoint("TOPLEFT",subText,"TOPLEFT",16,-32)
end
-------- HOOKING FUNCTIONS -------
-- endTime is equal to duration
-- startTime is GetTime() when the spell was found in CombatLog
-- endTime-(GetTime()-startTime) is therefore timeLeft
function UnitBuff(unitID, index, castable)
local name, rank, icon, count, duration, timeLeft, isMine = _UnitBuff(unitID, index, castable)
if not name then return name, rank, icon, count, duration, timeLeft, isMine end
--local EBFrame = getglobal(name.."_"..UnitGUID(unitID))
local EBFrame
if BuffLib.guids and BuffLib.guids[UnitGUID(unitID)] then
EBFrame = BuffLib.guids[UnitGUID(unitID)][name]
end
-- if duration can be seen by the player (provided by the server) return original duration and end function here
if timeLeft ~= nil or duration ~=nil then -- can see timer, perfect
if unitID ~= "player" then
isMine = true
else
isMine = false
end
return name, rank, icon, count, duration, timeLeft, isMine
end
if timeLeft == nil and EBFrame ~=nil and EBFrame.timeLeft ~= nil and EBFrame.timeLeft-(GetTime()-EBFrame.getTime) > 0 then -- can't see timer but someone in party/raid/bg can
--log(name.. " reading from snyc")
duration = EBFrame.duration
timeLeft = EBFrame.timeLeft-(GetTime()-EBFrame.getTime)
isMine = false
elseif timeLeft == nil and EBFrame ~=nil and EBFrame.timeLeft == nil then -- have to load timer from combatlog :(
--log(name.. " reading from combatlog")
duration = EBFrame.endTime
timeLeft = EBFrame.endTime-(GetTime()-EBFrame.startTime)
isMine = false
end
if timeLeft and timeLeft <= 0 then
timeLeft = nil
duration = nil
--log(name.." resetting timeLeft "..unitID)
end
return name, rank, icon, count, duration, timeLeft, isMine
end
function UnitDebuff(unitID, index, castable)
local name, rank, icon, count, debuffType, duration, timeLeft, isMine = _UnitDebuff(unitID, index, castable)
if not name then return name, rank, icon, count, debuffType, duration, timeLeft, isMine end
--local EBFrame = getglobal(name.."_"..UnitGUID(unitID))
local EBFrame
if BuffLib.guids and BuffLib.guids[UnitGUID(unitID)] then
EBFrame = BuffLib.guids[UnitGUID(unitID)][name]
end
if timeLeft ~= nil or duration ~= nil then
if unitID ~= "player" then
isMine = true
else
isMine = false
end
return name, rank, icon, count, debuffType, duration, timeLeft, isMine
end
if timeLeft == nil and EBFrame ~=nil and EBFrame.timeLeft ~= nil and EBFrame.timeLeft-(GetTime()-EBFrame.getTime) > 0 then
--log(name.. " reading from snyc")
duration = EBFrame.duration
timeLeft = EBFrame.timeLeft-(GetTime()-EBFrame.getTime)
isMine = false
elseif timeLeft == nil and EBFrame ~=nil and EBFrame.timeLeft == nil then
--log(name.. " reading from combatlog")
duration = EBFrame.endTime
timeLeft = EBFrame.endTime-(GetTime()-EBFrame.startTime)
isMine = false
end
if timeLeft and timeLeft <= 0 then
timeLeft = nil
duration = nil
--log(name.." resetting timeLeft "..unitID)
end
return name, rank, icon, count, debuffType, duration, timeLeft, isMine
end