-
Notifications
You must be signed in to change notification settings - Fork 0
/
events.lua
109 lines (94 loc) · 4.19 KB
/
events.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
-- vim: set ts=3 sw=3 foldmethod=indent:
if select(2, UnitClass("player")) == "DEATHKNIGHT" then
local _, DKROT = ...
local function evtAddonLoaded(...)
local addonName = ...
if addonName == "DKRot" then
DKROT.MainFrame:UnregisterEvent("ADDON_LOADED")
if DKROT_Settings ~= nil and DKROT_Settings.UpdateWarning ~= true then
StaticPopup_Show("DKROT_UPDATE_WARNING")
DKROT_Settings.UpdateWarning = true
end
end
end
local function evtCombatLogEventUnfiltered(...)
local _, event, _, _, casterName, _, _,targetguid, targetName, _, _, _, spellName = ...
DKROT.curtime = GetTime()
if (event == "UNIT_DIED" or event == "UNIT_DESTROYED") and DKROT.DT.Unit[targetguid] ~= nil then
if DKROT.DT.Unit[targetguid].Frame ~= nil then
DKROT.DT.Unit[targetguid].Frame:SetAlpha(0)
DKROT.DT.Unit[targetguid].Frame = nil
end
DKROT.DT.Unit[targetguid] = nil
end
-- If we hit someone and its not a dot ticking, add / update time for the active
-- target tracking. Excluding spell_periodic_damage means we only track targets
-- actively being hit by our spells as dotted targets might be moved away
if casterName == DKROT.PLAYER_NAME and targetName ~= DKROT.PLAYER_NAME and (
(
event:endswith('_DAMAGE') or event:endswith('_AURA_APPLIED') or event:endswith('_AURA_REFRESH')
) and event ~= 'SPELL_PERIODIC_DAMAGE'
) then
DKROT.ActiveTargets.Targets[targetguid] = DKROT.curtime
end
if casterName == PLAYER_NAME and DKROT_Settings.DT.Dots[spellName] and targetName ~= PLAYER_NAME then
if (event == "SPELL_AURA_APPLIED" or event == "SPELL_AURA_REFRESH") then
if DKROT.DT.Unit[targetguid] == nil then
DKROT.DT.Unit[targetguid] = {}
DKROT.DT.Unit[targetguid].Spells = {}
DKROT.DT.Unit[targetguid].NumDots = 0
DKROT.DT.Unit[targetguid].Name = select(3, string.find(targetName, "(.-)-")) or targetName
end
if DKROT.DT.Unit[targetguid].Spells[spellName] == nil then
DKROT.DT.Unit[targetguid].NumDots = DKROT.DT.Unit[targetguid].NumDots + 1
end
if spellName == DKROT.spells["Death and Decay"] or spellName == DKROT.spells["Defile"] then
DKROT.DT.Unit[targetguid].Spells[spellName] = select(1, GetSpellCooldown(spellName)) + 10
else
DKROT.DT.Unit[targetguid].Spells[spellName] = select(7, UnitDebuff("TARGET", spellName))
end
elseif (event == "SPELL_AURA_REMOVED") then
if DKROT.DT.Unit[targetguid] ~= nil and DKROT.DT.Unit[targetguid][spellName] ~= nil then
DKROT.DT.Unit[targetguid].Spells[spellName] = nil
DKROT.DT.Unit[targetguid].NumDots = DKROT.DT.Unit[targetguid].NumDots - 1
end
end
end
end
local function evtPlayerEnterCombat(...)
DKROT.TimeToDie.Targets = {}
DKROT.TimeToDie.Sweep = DKROT.curtime
DKROT.ActiveTargets.Targets = { }
DKROT.ActiveTargets.Sweep = DKROT.curtime
end
local function evtPlayerTalentChanged(...)
DKROT:CheckSpec()
DKROT:OptionsRefresh()
if evt == "ACTIVE_TALENT_GROUP_CHANGED" then
DKROT:CheckRotationTalents()
end
end
local function evtChatMsgAddon(...)
local prefix, message, channel, sender = ...
if prefix == "D4" then
local handler, time, name = ("\t"):split(message)
if handler == "PT" then
DKROT.PullTimer = GetTime() + tonumber(time)
DKROT:Debug("Received a DBM pull timer")
end
end
end
local events = {
["ADDON_LOADED"] = evtAddonLoaded,
["COMBAT_LOG_EVENT_UNFILTERED"]= evtCombatLogEventUnfiltered,
["PLAYER_ENTER_COMBAT"] = evtPlayerEnterCombat,
["PLAYER_TALENT_UPDATE"] = evtPlayerTalentChanged,
["PLAYER_TALENT_GROUP_CHANGED"] = evtPlayerTalentChanged,
["CHAT_MSG_ADDON"] = evtChatMsgAddon
}
function DKROT.EventHandler(self, evt, ...)
if evt == 'ADDON_LOADED' or (DKROT.loaded and events[evt] ~= nil) then
events[evt](...)
end
end
end