-
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMain.lua
145 lines (121 loc) · 3.86 KB
/
Main.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
--[[
* Copyright (c) 2012 by Adam Hellberg <[email protected]> and Bjørn Tore Håvie <[email protected]>
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to use,
* copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR
* A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
--]]
local Name, T = ...
T.Name = Name
T.Version = GetAddOnMetadata(Name, "Version")
local Dan = nil
function T:OnLoad()
self:LoadSavedVars()
self.Loaded = true
if self.Settings.Debug then
DungeonDanDebug = self
end
end
function T:LoadSavedVars()
if type(_G.DUNGEONDAN) ~= "table" then
_G.DUNGEONDAN = {}
end
self.Global = _G.DUNGEONDAN
if type(self.Global.Settings) ~= "table" then
self.Global.Settings = {}
end
self.Settings = self.Global.Settings
if type(self.Settings.Debug) ~= "boolean" then
self.Settings.Debug = false
end
end
function T.Events.ADDON_LOADED(self, event, ...)
if (select(1, ...)) == Name then
self:OnLoad()
end
end
function T.Events.PLAYER_ENTERING_WORLD(self, event, ...)
if Dan then return end
self:CreateDan()
Dan = self.Dan
local f = CreateFrame("Frame")
f.t = 0
f:SetScript("OnUpdate", function(s,e)
s.t = s.t + e
if s.t >= 2 then
s:SetScript("OnUpdate", nil)
Dan:ResetModelSettings()
Dan:DoAction(Dan.Actions.Welcome, true)
end
end)
-- Register callbacks on boss mod, if any
local function bossKill()
Dan:DoAction(Dan.Actions.BossKill)
end
local function bossWipe()
Dan:DoAction(Dan.Actions.BossWipe)
end
if DBM then
DBM:RegisterCallback("kill", bossKill)
DBM:RegisterCallback("wipe", bossWipe)
elseif DXE then
DXE.RegisterCallback(T, "DXECallback", bossKill)
elseif BigWigs then
T.Events.CHAT_MSG_ADDON = function(s, e, prefix, message, type, sender)
if prefix ~= "BigWigs" then return end
local sync, rest = select(3, message:find("(%S+)%s*(.*)$"))
if sync ~= "Death" then return end
bossKill()
end
else -- LibBossIDs
local lib = LibStub:GetLibrary("LibBossIDs-1.0", true)
T.Events.COMBAT_LOG_EVENT_UNFILTERED = function(s, e, ...)
local _, event = ...
if event ~= "PARTY_KILL" then return end
local id = tonumber((select(8, ...)):sub(6, 10), 16)
if lib.BossIDs[id] then bossKill() end
end
end
end
function T.Events.LFG_PROPOSAL_SHOW(self, event, ...)
Dan:DoAction(Dan.Actions.DungeonReady, true)
end
function T.Events.LFG_PROPOSAL_FAILED(self, event, ...)
Dan:StopAction()
end
function T.Events.LFG_PROPOSAL_SUCCEEDED(self, event, ...)
Dan:StopAction()
end
local validEvents = {
"SPELL_DAMAGE",
"SPELL_PERIODIC_DAMAGE",
"SPELL_BUILDING_DAMAGE",
"RANGE_DAMAGE"
}
local function IsValidEvent(event)
for _,v in pairs(validEvents) do
if event == v then return true end
end
return false
end
function T.Events.COMBAT_LOG_EVENT_UNFILTERED(self, event, ...)
local _, event, _, _, _, _, _, _, destName = ...
if destName ~= UnitName("player") then return end
if IsValidEvent(event) then
local id = (select(12, ...))
if self.AoeSpells[tostring(id)] then Dan:DoAction(Dan.Actions.AoeDamage) end
end
end