-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSVT.lua
More file actions
275 lines (238 loc) · 7.54 KB
/
SVT.lua
File metadata and controls
275 lines (238 loc) · 7.54 KB
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
--[[
Addon created by Dorann
SVT - Shadow Vulnerability Tracker
--]]
-----------------------------------------------------------------------
-- Addon Declaration
-----------------------------------------------------------------------
local _, class = UnitClass("player")
if class ~= "PRIEST" then
return
end
local L = AceLibrary("AceLocale-2.2"):new("SVT")
SVT = AceLibrary("AceAddon-2.0"):new("AceEvent-2.0", "AceConsole-2.0", "AceModuleCore-2.0", "AceDB-2.0", "AceDebug-2.0", "FuBarPlugin-2.0")
SVT:SetModuleMixins("AceDebug-2.0", "AceEvent-2.0", "CandyBar-2.1")
SVT.revision = 1
SVT:RegisterDB("SVTDB")
SVT.cmdtable = {
type = "group",
handler = SVT,
args = {
enable = {
type = "toggle",
name = L["Enable"],
desc = L["Enable timers."],
order = 1,
get = function() return SVT.db.profile.enable end,
set = function(v) SVT.db.profile.enable = v end,
},
currentonly = {
type = "toggle",
name = L["Target only"],
desc = L["Show timer only for the current target."],
order = 2,
get = function() return SVT.db.profile.currentonly end,
set = function(v) SVT.db.profile.currentonly = v end,
},
spacer = {
type = "header",
name = " ",
order = 4,
},
mindflay = {
type = "execute",
name = L["Mind Flay"],
desc = L["Start Channeling Mind Flay if you are not already channeling."],
order = 5,
func = function() SVT:SpamMindFlay() end,
},
}
}
SVT:RegisterChatCommand({"/svt"}, SVT.cmdtable)
SVT.defaultDB = {
posx = nil,
posy = nil,
visible = nil,
enable = true,
currentonly = true,
}
-----------------------------------------------------------------------
-- Initialization
-----------------------------------------------------------------------
function SVT:OnInitialize()
-- Called when the addon is loaded
end
function SVT:OnEnable()
AceLibrary("PaintChips-2.0"):RegisterColor("purple", "9041FF")
-- Called when the addon is enabled
self:RegisterEvent("SpellStatus_SpellCastInstant")
self:RegisterEvent("SpellStatus_SpellCastChannelingStart")
self:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE", "PlayerDamageEvents")
self:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE", "PlayerDamageEvents")
self:RegisterEvent("CHAT_MSG_SPELL_DAMAGESHIELDS_ON_SELF", "PlayerDamageEvents")
self:RegisterEvent("PLAYER_REGEN_ENABLED")
self:RegisterEvent("PLAYER_TARGET_CHANGED")
self:RegisterEvent("SVT_Test", "TestBar")
end
function SVT:OnDisable()
-- Called when the addon is disabled
end
------------------------------
-- FuBar --
------------------------------
local tablet = AceLibrary("Tablet-2.0")
function SVT:OnTooltipUpdate()
tablet:SetHint(L["|cffeda55fRight click|r to show the options menu."])
end
function SVT:OnClick()
--self:ToggleFrame()
end
SVT.hasIcon = "Interface\\Icons\\Spell_Shadow_BlackPlague"
SVT.defaultMinimapPosition = 170
SVT.OnMenuRequest = SVT.cmdtable
------------------------------
-- Variables --
------------------------------
local BS = AceLibrary("Babble-Spell-2.2")
local SS = AceLibrary("SpellStatus-1.0")
SVT.target = nil
SVT.lastResist = GetTime()
SVT.lastVictim = nil
SVT.debuffs = {}
----------------------
-- Event Handlers --
----------------------
function SVT:SpellStatus_SpellCastChannelingStart(sId, sName, sRank, sFullName, sCastTime)
if self.db.profile.enable then
if sName == BS["Mind Flay"] then
local tmpTime = GetTime() - self.lastResist
if tmpTime > 0.1 then
self.lastVictim = UnitName("target");
self:ScheduleEvent("ShadowVulneDelayedBar", self.DelayedBar, 0.2, self)
--self:DebugMessage("Mind Flay - ".. self.lastVictim.." "..GetTime())
end
end
end
SVT.channeling = true
end
function SVT:SpellStatus_SpellCastInstant(sId, sName, sRank, sFullName, sCastTime)
if self.db.profile.enable then
if sName == BS["Shadow Word: Pain"] then
local tmpTime = GetTime()-self.lastResist
if tmpTime > 0.1 then
self.lastVictim = UnitName("target");
self:ScheduleEvent("ShadowVulneDelayedBar", self.DelayedBar, 0.2, self)
--self:DebugMessage("Mind Flay - ".. self.lastVictim.." "..GetTime())
end
end
end
end
function SVT:SpamMindFlay()
if not SS:IsChanneling() then
CastSpellByName(BS["Mind Flay"])
end
end
function SVT:PlayerDamageEvents(msg)
if self.db.profile.enable then
local start, ending, victim = string.find(msg, L["mindblast_test"])
if victim then
--self:Print("MindBlast - ".. victim)
self.lastVictim = victim
self:ScheduleEvent("ShadowVulneDelayedBar", self.DelayedBar, 0.2, self)
end
local start, ending, victim = string.find(msg, L["mindblastCrit_test"])
if victim then
--self:Print("MindBlast - ".. victim)
self.lastVictim = victim
self:ScheduleEvent("ShadowVulneDelayedBar", self.DelayedBar, 0.2, self)
end
local start, ending, victim = string.find(msg, L["vulneResist_test"])
if victim then
--self:DebugMessage("Shadow vulne resist - ".. victim.." "..GetTime())
self.lastResist = GetTime()
self:CancelScheduledEvent("ShadowVulneDelayedBar")
end
local start, ending, victim = string.find(msg, L["swpResist_test"])
if victim then
--self:DebugMessage("swp resist - ".. victim.." "..GetTime())
self.lastResist = GetTime()
self:CancelScheduledEvent("ShadowVulneDelayedBar")
end
local start, ending, victim = string.find(msg, L["mindflay_test"])
if victim then
--self:DebugMessage("mindflay resist - ".. victim.." "..GetTime())
self.lastResist = GetTime()
self:CancelScheduledEvent("ShadowVulneDelayedBar")
end
end
end
function SVT:DelayedBar()
self.debuffs[self.lastVictim] = GetTime() - 0.2
SVT:GetModule("Bar"):Start(self.lastVictim, 15 - 0.2, "Interface\\Icons\\Spell_Shadow_BlackPlague")
self:ScheduleEvent("ShadowVulneReckeckTargetChange" .. self.lastVictim, self.Warning, 15 - 5 - 0.2, self, self.lastVictim)
end
function SVT:PLAYER_REGEN_ENABLED()
self.target = nil
SVT:GetModule("Bar"):Stop()
self:CancelAllScheduledEvents()
self.debuffs = {}
end
function SVT:RecheckTargetChange()
local target = UnitName("target")
if target ~= self.target then
if self.db.profile.currentonly then
SVT:GetModule("Bar"):Stop()
end
self.target = target
local victim, timeleft = self:GetTargetInfo()
if victim and timeleft and self.db.profile.enable then
SVT:GetModule("Bar"):Start(victim, timeleft, "Interface\\Icons\\Spell_Shadow_BlackPlague")
if timeleft - 5 > 0 then
self:ScheduleEvent("ShadowVulneReckeckTargetChange" .. victim, self.Warning, timeleft - 5, self, victim)
self:Print(victim)
end
end
end
end
-- reset data if you change your target
function SVT:PLAYER_TARGET_CHANGED(msg)
if not self:IsEventScheduled("ShadowVulneReckeckTargetChange") then
self:ScheduleEvent("ShadowVulneReckeckTargetChange", self.RecheckTargetChange, 0.1, self)
end
end
-----------------------
-- Utility Functions --
-----------------------
function SVT:Warning(victim)
if victim then
SVT:GetModule("Bar"):ChangeColor(victim, "red")
PlaySoundFile("Interface\\AddOns\\SVT\\Sounds\\AlertSound16.mp3")
--PlaySound("RaidWarning")
end
end
function SVT:GetTargetInfo()
for k, v in pairs(self.debuffs) do
if k == self.target then
local timeleft = 15 - (GetTime() - v)
if timeleft > 0 then
return k, timeleft
end
end
end
return false
end
function SVT:HasDebuff(iconPath)
for i = 1, 16 do
local debuff = UnitDebuff("target", i)
if debuff and debuff == iconPath then
return true
end
end
return false
end
function SVT:HasShadowVulnerability()
return SVT:HasDebuff("Interface\\Icons\\Spell_Shadow_BlackPlague")
end
function SVT:TestBar()
SVT:GetModule("Bar"):Start("Test", 15, "Interface\\Icons\\Spell_Shadow_BlackPlague")
end