vanilla-wow-addons – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | --[[ |
2 | Spell Alert |
||
3 | Author: Awen |
||
4 | Modified by: Mithryn |
||
5 | Thanks: Quu (Code contribution) |
||
6 | Cyron (German Translation) |
||
7 | Awen (Original Code) |
||
8 | |||
9 | ]] |
||
10 | |||
11 | |||
12 | SAConfig = { }; |
||
13 | SAConfig.color = { }; |
||
14 | SAConfig.on = 1; |
||
15 | SAConfig.emote_on = 1; |
||
16 | SAConfig.retarget_on = 1; |
||
17 | SAConfig.targetonly = 1; |
||
18 | SAConfig.heals = 1; |
||
19 | SAConfig.cc = 1; |
||
20 | SAConfig.dispelable = 1; |
||
21 | SAConfig.damage = 1; |
||
22 | SAConfig.misc = 1; |
||
23 | SAConfig.pos = 20; |
||
24 | SAConfig.shadow = 0; |
||
25 | SAConfig.zoom = 37; |
||
26 | SAConfig.color.at = {r=1,g=0,b=0}; |
||
27 | SAConfig.color.he = {r=1,g=1,b=0}; |
||
28 | SAConfig.color.bu = {r=0,g=1,b=0}; |
||
29 | SAConfig.color.em = {r=1,g=0.6,b=0}; |
||
30 | SAConfig.color.to = {r=0.5,g=0.5,b=0.5}; |
||
31 | SAConfig.radio = 1; |
||
32 | SAConfig.drag = 5; |
||
33 | SAConfig.holdTime = 1; |
||
34 | SAConfig.livingBomb = 1; |
||
35 | |||
36 | local kind = 0; |
||
37 | local sa_gains = { }; |
||
38 | local sa_color_prev = {r=1,g=1,b=1}; |
||
39 | local fadeInTime = 0.1; |
||
40 | local fadeOutTime = 0.4; |
||
41 | local startTime = 0; |
||
42 | local cType = 0; -- 0 = damage, 1 = heal, 2 = buff, 3 = emote, 4 = totem |
||
43 | local shadow; |
||
44 | local getX, getY; |
||
45 | local change = 0; |
||
46 | local changed = false; |
||
47 | |||
48 | local sa_options = 0; |
||
49 | |||
50 | function SpellAlert_OnLoad() |
||
51 | |||
52 | this:RegisterEvent("VARIABLES_LOADED"); |
||
53 | this:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE"); |
||
54 | this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS"); |
||
55 | this:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF"); |
||
56 | this:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE"); |
||
57 | this:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF"); |
||
58 | this:RegisterEvent("CHAT_MSG_MONSTER_EMOTE"); |
||
59 | this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE"); |
||
60 | this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS"); |
||
61 | this:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_OTHER"); |
||
62 | |||
63 | SlashCmdList["SpellAlertCOMMAND"] = SpellAlertHandler; |
||
64 | SLASH_SpellAlertCOMMAND1 = "/spellalert"; |
||
65 | DEFAULT_CHAT_FRAME:AddMessage("SpellAlert by Awen. Type /spellalert for options."); |
||
66 | DEFAULT_CHAT_FRAME:AddMessage("SpellAlert was modified by Mithryn."); |
||
67 | |||
68 | end |
||
69 | |||
70 | function SpellAlert_OnEvent() |
||
71 | if (SAConfig.on == 0) then |
||
72 | return; |
||
73 | end |
||
74 | |||
75 | if (event == "VARIABLES_LOADED") then |
||
76 | |||
77 | if (not SAConfig) then |
||
78 | SAConfig = {}; |
||
79 | |||
80 | SAConfig.on = 1; |
||
81 | SAConfig.emote_on = 1; |
||
82 | SAConfig.retarget_on = 1; |
||
83 | SAConfig.targetonly = 1; |
||
84 | SAConfig.heals = 1; |
||
85 | SAConfig.cc = 1; |
||
86 | SAConfig.dispelable = 1; |
||
87 | SAConfig.damage = 1; |
||
88 | SAConfig.misc = 1; |
||
89 | SAConfig.pos = 20; |
||
90 | SAConfig.shadow = 0; |
||
91 | SAConfig.zoom = 37; |
||
92 | SAConfig.radio = 1; |
||
93 | SAConfig.version = 1.5; |
||
94 | SAConfig.shadow = 0; |
||
95 | SAConfig.drag = 5; |
||
96 | SAConfig.version = 1.6; |
||
97 | SAConfig.holdTime = 1; |
||
98 | SAConfig.livingBomb = 1; |
||
99 | |||
100 | SAConfig.color = {}; |
||
101 | SAConfig.color.at = {r=1,g=0,b=0}; |
||
102 | SAConfig.color.he = {r=1,g=1,b=0}; |
||
103 | SAConfig.color.bu = {r=0,g=1,b=0}; |
||
104 | SAConfig.color.em = {r=1,g=0.6,b=0}; |
||
105 | SAConfig.color.to = {r=0.5,g=0.5,b=0.5}; |
||
106 | DEFAULT_CHAT_FRAME:AddMessage("SpellAlert: Setting Options to Default"); |
||
107 | |||
108 | elseif (not SAConfig.color) then |
||
109 | SAConfig.color = {}; |
||
110 | SAConfig.color.at = {r=1,g=0,b=0}; |
||
111 | SAConfig.color.he = {r=1,g=1,b=0}; |
||
112 | SAConfig.color.bu = {r=0,g=1,b=0}; |
||
113 | SAConfig.color.em = {r=1,g=0.6,b=0}; |
||
114 | SAConfig.color.to = {r=0.5,g=0.5,b=0.5}; |
||
115 | DEFAULT_CHAT_FRAME:AddMessage("SpellAlert: Setting Options to Default"); |
||
116 | |||
117 | elseif (not SAConfig.radio) then |
||
118 | SAConfig.radio = 1; |
||
119 | DEFAULT_CHAT_FRAME:AddMessage("SpellAlert: Setting Options to Default"); |
||
120 | |||
121 | elseif (not SAConfig.version or not SAConfig.version == 1.5) then |
||
122 | SAConfig.version = 1.5; |
||
123 | SAConfig.shadow = 0; |
||
124 | SAConfig.drag = 5; |
||
125 | DEFAULT_CHAT_FRAME:AddMessage("Updated SpellAlert to 1.5"); |
||
126 | |||
127 | elseif (not SAConfig.version or not SAConfig.version == 1.6) then |
||
128 | SAConfig.version = 1.6; |
||
129 | SAConfig.holdTime = 1; |
||
130 | SAConfig.livingBomb = 1; |
||
131 | DEFAULT_CHAT_FRAME:AddMessage("Updated SpellAlert to 1.6"); |
||
132 | |||
133 | end |
||
134 | |||
135 | if(SAConfig.shadow == 0) then |
||
136 | shadow = ""; |
||
137 | elseif (SAConfig.shadow == 1) then |
||
138 | shadow = "OUTLINE"; |
||
139 | elseif (SAConfig.shadow == 2) then |
||
140 | shadow = "THICKOUTLINE"; |
||
141 | end |
||
142 | |||
143 | AlertFrameText:SetTextColor(1, 1, 1); |
||
144 | SpellAlert_Toggle(); |
||
145 | AlertFrameText:SetFont("Fonts\\FRIZQT__.TTF", SAConfig.zoom, shadow); |
||
146 | AlertFrameText:SetText("SpellAlert Loaded!"); |
||
147 | if(not SAConfig.holdTime) then |
||
148 | SAConfig.holdTime = 1; |
||
149 | end |
||
150 | AlertFrame_Show() |
||
151 | |||
152 | end |
||
153 | |||
154 | local mob, spell; |
||
155 | if (event == "CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE") then |
||
156 | for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_CAST) do |
||
157 | if (not SpellAlert_isParty(mob)) then |
||
158 | cType = 0; |
||
159 | if (SAConfig.radio == 1) then |
||
160 | SpellAlert_alert(mob, spell, arg1); |
||
161 | elseif (SAConfig.radio == 2) then |
||
162 | SpellAlert_alert(mob, spell, mob.." begins to cast |cffffffff"..spell.."|r."); |
||
163 | else |
||
164 | SpellAlert_alert(mob, spell, "|cffffffff"..mob.." beings to cast |r"..spell.."."); |
||
165 | end |
||
166 | end |
||
167 | return; |
||
168 | end |
||
169 | elseif (event == "CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF") then |
||
170 | for mob, spell, k in string.gfind(arg1, SA_PTN_SPELL_GAINS_X) do |
||
171 | return; |
||
172 | end |
||
173 | for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_CAST) do |
||
174 | if (not SpellAlert_isParty(mob)) then |
||
175 | cType = 1; |
||
176 | if (SAConfig.radio == 1) then |
||
177 | SpellAlert_alert(mob, spell, arg1); |
||
178 | elseif (SAConfig.radio == 2) then |
||
179 | SpellAlert_alert(mob, spell, mob.." begins to cast |cffffffff"..spell.."|r."); |
||
180 | else |
||
181 | SpellAlert_alert(mob, spell, "|cffffffff"..mob.." beings to cast |r"..spell.."."); |
||
182 | end |
||
183 | end |
||
184 | return; |
||
185 | end |
||
186 | for mob, spell in string.gfind(arg1, SA_PTN_SPELL_TOTEM) do |
||
187 | if (not SpellAlert_isParty(mob)) then |
||
188 | cType = 4; |
||
189 | if (SAConfig.radio == 1) then |
||
190 | SpellAlert_alert(mob, spell, arg1); |
||
191 | elseif (SAConfig.radio == 2) then |
||
192 | SpellAlert_alert(mob, spell, mob.." casts |cffffffff"..spell.."|r Totem."); |
||
193 | else |
||
194 | SpellAlert_alert(mob, spell, "|cffffffff"..mob.." casts |r"..spell.." Totem."); |
||
195 | end |
||
196 | end |
||
197 | return; |
||
198 | end |
||
199 | for mob, spell in string.gfind(arg1, SA_PTN_SPELL_GAINS) do |
||
200 | cType = 2; |
||
201 | if (SAConfig.radio == 1) then |
||
202 | SpellAlert_alert(mob, spell, arg1); |
||
203 | elseif (SAConfig.radio == 2) then |
||
204 | SpellAlert_alert(mob, spell, mob.." gains |cffffffff"..spell.."|r."); |
||
205 | else |
||
206 | SpellAlert_alert(mob, spell, "|cffffffff"..mob.." gains |r"..spell.."."); |
||
207 | end |
||
208 | return; |
||
209 | end |
||
210 | elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF") then |
||
211 | for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_CAST) do |
||
212 | cType = 1; |
||
213 | if (SAConfig.radio == 1) then |
||
214 | SpellAlert_alert(mob, spell, arg1); |
||
215 | elseif (SAConfig.radio == 2) then |
||
216 | SpellAlert_alert(mob, spell, mob.." begins to cast |cffffffff"..spell.."|r."); |
||
217 | else |
||
218 | SpellAlert_alert(mob, spell, "|cffffffff"..mob.." begins to cast |r"..spell.."."); |
||
219 | end |
||
220 | return; |
||
221 | end |
||
222 | elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS") then |
||
223 | for mob, spell, k in string.gfind(arg1, SA_PTN_SPELL_GAINS_X) do |
||
224 | return; |
||
225 | end |
||
226 | for mob, spell in string.gfind(arg1, SA_PTN_SPELL_GAINS) do |
||
227 | cType = 2; |
||
228 | if (SAConfig.radio == 1) then |
||
229 | SpellAlert_alert(mob, spell, arg1); |
||
230 | elseif (SAConfig.radio == 2) then |
||
231 | SpellAlert_alert(mob, spell, mob.." gains |cffffffff"..spell.."|r."); |
||
232 | else |
||
233 | SpellAlert_alert(mob, spell, "|cffffffff"..mob.." gains |r"..spell.."."); |
||
234 | end |
||
235 | return; |
||
236 | end |
||
237 | elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE") then |
||
238 | for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_CAST) do |
||
239 | cType = 0; |
||
240 | if (SAConfig.radio == 1) then |
||
241 | SpellAlert_alert(mob, spell, arg1); |
||
242 | elseif (SAConfig.radio == 2) then |
||
243 | SpellAlert_alert(mob, spell, mob.." begins to cast |cffffffff"..spell.."|r."); |
||
244 | else |
||
245 | SpellAlert_alert(mob, spell, "|cffffffff"..mob.." begins to cast |r"..spell.."."); |
||
246 | end |
||
247 | return; |
||
248 | end |
||
249 | elseif (event == "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS") then |
||
250 | for mob, spell, temp in string.gfind(arg1, SA_PTN_SPELL_GAINS_X) do |
||
251 | return; |
||
252 | end |
||
253 | for mob, spell in string.gfind(arg1, SA_PTN_SPELL_GAINS) do |
||
254 | if ( (spell == SA_WOTF) or |
||
255 | (spell == SA_BERSERKER_RAGE) ) then |
||
256 | sa_gains[mob] = {}; |
||
257 | sa_gains[mob].spell = spell; |
||
258 | sa_gains[mob].time = GetTime(); |
||
259 | end |
||
260 | cType = 2; |
||
261 | if (SAConfig.radio == 1) then |
||
262 | SpellAlert_alert(mob, spell, arg1); |
||
263 | elseif (SAConfig.radio == 2) then |
||
264 | SpellAlert_alert(mob, spell, mob.." gains |cffffffff"..spell.."|r."); |
||
265 | else |
||
266 | SpellAlert_alert(mob, spell, "|cffffffff"..mob.." gains |r"..spell.."."); |
||
267 | end |
||
268 | return; |
||
269 | end |
||
270 | elseif (event == "CHAT_MSG_SPELL_AURA_GONE_OTHER") then |
||
271 | for spell, mob in string.gfind(arg1, SA_PTN_SPELL_FADE) do |
||
272 | if ( (spell == SA_WOTF) or |
||
273 | (spell == SA_BERSERKER_RAGE) ) then |
||
274 | local tt = sa_gains[mob]; |
||
275 | if (tt) then |
||
276 | if (tt.spell == spell) then |
||
277 | if (GetTime() - tt.time <= 30) then |
||
278 | cType = 2; |
||
279 | if (SAConfig.radio == 1) then |
||
280 | SpellAlert_alert(mob, spell, arg1); |
||
281 | elseif (SAConfig.radio == 2) then |
||
282 | SpellAlert_alert(mob, spell, "|cffffffff"..spell.."|r gains "..mob.."."); |
||
283 | else |
||
284 | SpellAlert_alert(mob, spell, spell.."|cffffffff fades from "..mob.."."); |
||
285 | end |
||
286 | end |
||
287 | end |
||
288 | tt[mob] = nil; |
||
289 | return; |
||
290 | end |
||
291 | end |
||
292 | end |
||
293 | elseif (event == "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE") then |
||
294 | if (arg1 == SA_AFFLICT_LIVINGBOMB) then |
||
295 | if (SAConfig.livingBomb == 1) then |
||
296 | AlertFrameText:SetText("YOU ARE THE LIVING BOMB!"); |
||
297 | AlertFrameText:SetTextColor(SAConfig.color.at.r,SAConfig.color.at.g,SAConfig.color.at.b); |
||
298 | AlertFrame_Show(); |
||
299 | end |
||
300 | end |
||
301 | if (arg1 == SA_AFFLICT_SCATTERSHOT) then |
||
302 | SpellAlert_retarget(SA_SCATTERSHOT); |
||
303 | elseif (arg1 == SA_AFFLICT_FEAR) then |
||
304 | SpellAlert_retarget(SA_FEAR); |
||
305 | elseif (arg1 == SA_AFFLICT_INTIMIDATING_SHOUT) then |
||
306 | SpellAlert_retarget(SA_INTIMIDATING_SHOUT); |
||
307 | elseif (arg1 == SA_AFFLICT_PSYCHIC_SCREAM) then |
||
308 | SpellAlert_retarget(SA_PSYCHIC_SCREAM); |
||
309 | elseif (arg1 == SA_AFFLICT_PANIC) then |
||
310 | SpellAlert_retarget(SA_PANIC); |
||
311 | elseif (arg1 == SA_AFFLICT_BELLOWING_ROAR) then |
||
312 | SpellAlert_retarget(SA_BELLOWING_ROAR); |
||
313 | elseif (arg1 == SA_AFFLICT_ANCIENT_DESPAIR) then |
||
314 | SpellAlert_retarget(SA_ANCIENT_DESPAIR); |
||
315 | elseif (arg1 == SA_AFFLICT_ANCIENT_SCREECH) then |
||
316 | SpellAlert_retarget(SA_SCREECH); |
||
317 | elseif (arg1 == SA_AFFLICT_POLYMORPH) then |
||
318 | SpellAlert_retarget(SA_POLYMORPH); |
||
319 | elseif (arg1 == SA_AFFLICT_DEATHCOIL) then |
||
320 | SpellAlert_retarget(SA_DEATHCOIL); |
||
321 | end |
||
322 | elseif (event == "CHAT_MSG_EMOTE") then |
||
323 | if (arg1) then |
||
324 | if (SAConfig.emote_on == 1) then |
||
325 | cType = 3; |
||
326 | SpellAlert_alert("", "", arg1); |
||
327 | end |
||
328 | end |
||
329 | elseif (event == "CHAT_MSG_MONSTER_EMOTE") then |
||
330 | local name = arg2; |
||
331 | if (not name) then |
||
332 | name = "nil"; |
||
333 | end |
||
334 | if (arg1) then |
||
335 | if (SAConfig.emote_on == 1) then |
||
336 | cType = 3; |
||
337 | -- AlertFrameText:SetTextColor(1,0.6,0); |
||
338 | SpellAlert_alert(name, arg1, name .. " " .. arg1); |
||
339 | end |
||
340 | end |
||
341 | end |
||
342 | end |
||
343 | |||
344 | function SpellAlert_setOptions() |
||
345 | |||
346 | SAConfig.on = 1; |
||
347 | SAConfig.emote_on = 1; |
||
348 | SAConfig.retarget_on = 1; |
||
349 | SAConfig.targetonly = 1; |
||
350 | SAConfig.heals = 1; |
||
351 | SAConfig.cc = 1; |
||
352 | SAConfig.dispelable = 1; |
||
353 | SAConfig.damage = 1; |
||
354 | SAConfig.misc = 1; |
||
355 | SAConfig.pos = 20; |
||
356 | SAConfig.shadow = 0; |
||
357 | SAConfig.zoom = 37; |
||
358 | SAConfig.color.at = {r=1,g=0,b=0}; |
||
359 | SAConfig.color.he = {r=1,g=1,b=0}; |
||
360 | SAConfig.color.bu = {r=0,g=1,b=0}; |
||
361 | SAConfig.color.em = {r=1,g=0.6,b=0}; |
||
362 | SAConfig.color.to = {r=0.5,g=0.5,b=0.5}; |
||
363 | SAConfig.radio = 1; |
||
364 | SAConfig.drag = 5; |
||
365 | SAConfig.livingBomb = 1; |
||
366 | SAConfig.holdTime = 1; |
||
367 | |||
368 | SAOptionsEnable:SetChecked(SpellAlert_Int2Bool(SAConfig.on)); |
||
369 | SAOptionsEmote:SetChecked(SpellAlert_Int2Bool(SAConfig.emote_on)); |
||
370 | SAOptionsRetarget:SetChecked(SpellAlert_Int2Bool(SAConfig.retarget_on)); |
||
371 | SAOptionsTargetOnly:SetChecked(SpellAlert_Int2Bool(SAConfig.targetonly)); |
||
372 | SAOptionsHeals:SetChecked(SpellAlert_Int2Bool(SAConfig.heals)); |
||
373 | SAOptionsCC:SetChecked(SpellAlert_Int2Bool(SAConfig.cc)); |
||
374 | SAOptionsDispelable:SetChecked(SpellAlert_Int2Bool(SAConfig.dispelable)); |
||
375 | SAOptionsMisc:SetChecked(SpellAlert_Int2Bool(SAConfig.misc)); |
||
376 | SAOptionsDamage:SetChecked(SpellAlert_Int2Bool(SAConfig.damage)); |
||
377 | SASizeSlider:SetValue(SAConfig.zoom); |
||
378 | SAPosSlider:SetValue(SAConfig.pos); |
||
379 | SAShadowSlider:SetValue(SAConfig.shadow); |
||
380 | boxColor = getglobal("SAat_NormalTexture"); |
||
381 | boxColor:SetVertexColor(SAConfig.color.at.r,SAConfig.color.at.g,SAConfig.color.at.b); |
||
382 | boxColor = getglobal("SAhe_NormalTexture"); |
||
383 | boxColor:SetVertexColor(SAConfig.color.he.r,SAConfig.color.he.g,SAConfig.color.he.b); |
||
384 | boxColor = getglobal("SAbu_NormalTexture"); |
||
385 | boxColor:SetVertexColor(SAConfig.color.bu.r,SAConfig.color.bu.g,SAConfig.color.bu.b); |
||
386 | boxColor = getglobal("SAem_NormalTexture"); |
||
387 | boxColor:SetVertexColor(SAConfig.color.em.r,SAConfig.color.em.g,SAConfig.color.em.b); |
||
388 | boxColor = getglobal("SAto_NormalTexture"); |
||
389 | boxColor:SetVertexColor(SAConfig.color.to.r,SAConfig.color.to.g,SAConfig.color.to.b); |
||
390 | |||
391 | SAOptionsRadio1:SetChecked(0); |
||
392 | SAOptionsRadio2:SetChecked(0); |
||
393 | SAOptionsRadio3:SetChecked(0); |
||
394 | SAOptionsRadioA:SetChecked(0); |
||
395 | SAOptionsRadioB:SetChecked(0); |
||
396 | |||
397 | SAOptionsRadioA:SetChecked(1); |
||
398 | SADrag:SetMovable(false); |
||
399 | SADrag:ClearAllPoints(); |
||
400 | SADrag:SetPoint("CENTER", "UIParent", "CENTER"); |
||
401 | SADrag:Hide(); |
||
402 | AlertFrame:ClearAllPoints(); |
||
403 | AlertFrame:SetPoint("TOP", 0, SAConfig.pos); |
||
404 | |||
405 | sa_options = 1; |
||
406 | AlertFrameText:SetAlpha(1); |
||
407 | AlertFrameText:Show(); |
||
408 | AlertFrameText:SetTextColor(0.3,0.3,0.3); |
||
409 | |||
410 | SAOptionsRadio1:SetChecked(1); |
||
411 | AlertFrameText:SetText("<Enemy Name> begins casting <Spell>!"); |
||
412 | |||
413 | end |
||
414 | |||
415 | |||
416 | function SpellAlertHandler(msg) |
||
417 | |||
418 | SpellAlert_OptionsLoad(); |
||
419 | SAOptions:Show(); |
||
420 | |||
421 | end |
||
422 | |||
423 | function SpellAlert_alert(mob, spell, msg) |
||
424 | if (GetLocale()=="enUS") then |
||
425 | if (SA_SPELLS_IGNORE[spell]) then |
||
426 | return; |
||
427 | end |
||
428 | |||
429 | if (SAConfig.heals == 0) then |
||
430 | if (SA_SPELLS_HEALS[spell] == 1) then |
||
431 | return; |
||
432 | end |
||
433 | end |
||
434 | |||
435 | if (SAConfig.cc == 0) then |
||
436 | if (SA_SPELLS_CC[spell] == 1) then |
||
437 | return; |
||
438 | end |
||
439 | end |
||
440 | |||
441 | if (SAConfig.dispelable == 0) then |
||
442 | if (SA_SPELLS_DISPELABLE[spell] == 1) then |
||
443 | return; |
||
444 | end |
||
445 | end |
||
446 | |||
447 | if (SAConfig.damage == 0) then |
||
448 | if (SA_SPELLS_DAMAGE[spell] == 1) then |
||
449 | return; |
||
450 | end |
||
451 | end |
||
452 | |||
453 | end |
||
454 | |||
455 | SpellAlert_banner(msg, mob); |
||
456 | end |
||
457 | |||
458 | function AlertFrame_Color() |
||
459 | |||
460 | if (SA_SPELLS_HEALS[spell] == 1) then |
||
461 | cType = 1; |
||
462 | -- AlertFrameText:SetTextColor(1,1,0); |
||
463 | end |
||
464 | |||
465 | if (SA_SPELLS_CC[spell] == 1) then |
||
466 | cType = 0; |
||
467 | -- AlertFrameText:SetTextColor(1,0,1); |
||
468 | end |
||
469 | |||
470 | if (SA_SPELLS_DISPELABLE[spell] == 1) then |
||
471 | cType = 2; |
||
472 | -- AlertFrameText:SetTextColor(0,1,0); |
||
473 | end |
||
474 | |||
475 | if (SA_SPELLS_DAMAGE[spell] == 1) then |
||
476 | cType = 0; |
||
477 | -- AlertFrameText:SetTextColor(1,0,0); |
||
478 | end |
||
479 | |||
480 | if (cType == 0) then |
||
481 | AlertFrameText:SetTextColor(SAConfig.color.at.r,SAConfig.color.at.g,SAConfig.color.at.b); |
||
482 | elseif (cType == 1) then |
||
483 | AlertFrameText:SetTextColor(SAConfig.color.he.r,SAConfig.color.he.g,SAConfig.color.he.b); |
||
484 | elseif (cType == 2) then |
||
485 | AlertFrameText:SetTextColor(SAConfig.color.bu.r,SAConfig.color.bu.g,SAConfig.color.bu.b); |
||
486 | elseif (cType == 3) then |
||
487 | AlertFrameText:SetTextColor(SAConfig.color.em.r,SAConfig.color.em.g,SAConfig.color.em.b); |
||
488 | elseif (cType == 4) then |
||
489 | AlertFrameText:SetTextColor(SAConfig.color.to.r,SAConfig.color.to.g,SAConfig.color.to.b); |
||
490 | end |
||
491 | |||
492 | end |
||
493 | |||
494 | function SpellAlert_banner(msg, mob) |
||
495 | if (SAConfig.targetonly == 0) then |
||
496 | AlertFrameText:SetText(msg); |
||
497 | AlertFrame_Color(); |
||
498 | AlertFrame_Show(); |
||
499 | else |
||
500 | local targetname = UnitName("target"); |
||
501 | if (mob == targetname) then |
||
502 | AlertFrameText:SetText(msg); |
||
503 | AlertFrame_Color(); |
||
504 | AlertFrame_Show(); |
||
505 | end |
||
506 | end |
||
507 | end |
||
508 | |||
509 | function SpellAlert_isParty(name) |
||
510 | for i = 1, 4, 1 do |
||
511 | local partyname = UnitName("party" .. i); |
||
512 | if (name == partyname) then |
||
513 | return 1; |
||
514 | end |
||
515 | end |
||
516 | return nil; |
||
517 | end |
||
518 | |||
519 | function SpellAlert_retarget(spell) |
||
520 | if (SAConfig.retarget_on == 0) then |
||
521 | return; |
||
522 | end |
||
523 | if (not UnitName("target")) then |
||
524 | if (sa_targetName) then |
||
525 | if (sa_targetHostile) then |
||
526 | DEFAULT_CHAT_FRAME:AddMessage("SpellAlert is trying to retarget after " .. spell .. " : " .. sa_targetName); |
||
527 | TargetLastEnemy(); |
||
528 | else |
||
529 | DEFAULT_CHAT_FRAME:AddMessage("SpellAlert is trying to retarget after " .. spell .. " : " .. sa_targetName); |
||
530 | TargetByName(sa_targetName); |
||
531 | end |
||
532 | end |
||
533 | end |
||
534 | end |
||
535 | |||
536 | function SpellAlert_retargetHunter() |
||
537 | if (SAConfig.retarget_on == 0) then |
||
538 | return; |
||
539 | end |
||
540 | if (not UnitName("target")) then |
||
541 | if (sa_targetName) then |
||
542 | if (sa_targetHostile) then |
||
543 | TargetByName(sa_targetName); |
||
544 | if (UnitIsDeadOrGhost("target") and UnitCanAttack("player", "target")) then |
||
545 | DEFAULT_CHAT_FRAME:AddMessage("SpellAlert is trying to retarget after Feign Death : " .. sa_targetName); |
||
546 | TargetByName(sa_targetName); |
||
547 | else |
||
548 | ClearTarget(); |
||
549 | sa_targetHostile = nil; |
||
550 | sa_targetName = nil; |
||
551 | end |
||
552 | end |
||
553 | end |
||
554 | end |
||
555 | end |
||
556 | |||
557 | function SpellAlert_OpenColorPicker(button, kinda) |
||
558 | |||
559 | kind = kinda; |
||
560 | |||
561 | if ( not button ) then |
||
562 | button = this; |
||
563 | end |
||
564 | ColorPickerFrame.func = SpellAlert_SetColor; |
||
565 | |||
566 | if (kind == 0) then |
||
567 | sa_color_prev.r = SAConfig.color.at.r; |
||
568 | sa_color_prev.g = SAConfig.color.at.g; |
||
569 | sa_color_prev.b = SAConfig.color.at.b; |
||
570 | elseif (kind == 1) then |
||
571 | sa_color_prev.r = SAConfig.color.he.r; |
||
572 | sa_color_prev.g = SAConfig.color.he.g; |
||
573 | sa_color_prev.b = SAConfig.color.he.b; |
||
574 | elseif (kind == 2) then |
||
575 | sa_color_prev.r = SAConfig.color.bu.r; |
||
576 | sa_color_prev.g = SAConfig.color.bu.g; |
||
577 | sa_color_prev.b = SAConfig.color.bu.b; |
||
578 | elseif (kind == 3) then |
||
579 | sa_color_prev.r = SAConfig.color.em.r; |
||
580 | sa_color_prev.g = SAConfig.color.em.g; |
||
581 | sa_color_prev.b = SAConfig.color.em.b; |
||
582 | elseif (kind == 4) then |
||
583 | sa_color_prev.r = SAConfig.color.to.r; |
||
584 | sa_color_prev.g = SAConfig.color.to.g; |
||
585 | sa_color_prev.b = SAConfig.color.to.b; |
||
586 | end |
||
587 | |||
588 | ColorPickerFrame.cancelFunc = SpellAlert_CancelColor; |
||
589 | if (kind == 0) then |
||
590 | ColorPickerFrame:SetColorRGB(SAConfig.color.at.r, SAConfig.color.at.g, SAConfig.color.at.b); |
||
591 | elseif (kind == 1) then |
||
592 | ColorPickerFrame:SetColorRGB(SAConfig.color.he.r, SAConfig.color.he.g, SAConfig.color.he.b); |
||
593 | elseif (kind == 2) then |
||
594 | ColorPickerFrame:SetColorRGB(SAConfig.color.bu.r, SAConfig.color.bu.g, SAConfig.color.bu.b); |
||
595 | elseif (kind == 3) then |
||
596 | ColorPickerFrame:SetColorRGB(SAConfig.color.em.r, SAConfig.color.em.g, SAConfig.color.em.b); |
||
597 | elseif (kind == 4) then |
||
598 | ColorPickerFrame:SetColorRGB(SAConfig.color.to.r, SAConfig.color.to.g, SAConfig.color.to.b); |
||
599 | end |
||
600 | ColorPickerFrame:Show(); |
||
601 | end |
||
602 | |||
603 | function SpellAlert_SetColor() |
||
604 | local r,g,b = ColorPickerFrame:GetColorRGB(); |
||
605 | local swatch,frame; |
||
606 | if (kind == 0) then |
||
607 | swatch = getglobal("SAat_NormalTexture"); |
||
608 | swatch:SetVertexColor(r,g,b); |
||
609 | SAConfig.color.at.r = r; |
||
610 | SAConfig.color.at.g = g; |
||
611 | SAConfig.color.at.b = b; |
||
612 | AlertFrameText:SetTextColor(SAConfig.color.at.r,SAConfig.color.at.g,SAConfig.color.at.b); |
||
613 | elseif (kind == 1) then |
||
614 | swatch = getglobal("SAhe_NormalTexture"); |
||
615 | swatch:SetVertexColor(r,g,b); |
||
616 | SAConfig.color.he.r = r; |
||
617 | SAConfig.color.he.g = g; |
||
618 | SAConfig.color.he.b = b; |
||
619 | AlertFrameText:SetTextColor(SAConfig.color.he.r,SAConfig.color.he.g,SAConfig.color.he.b); |
||
620 | elseif (kind == 2) then |
||
621 | swatch = getglobal("SAbu_NormalTexture"); |
||
622 | swatch:SetVertexColor(r,g,b); |
||
623 | SAConfig.color.bu.r = r; |
||
624 | SAConfig.color.bu.g = g; |
||
625 | SAConfig.color.bu.b = b; |
||
626 | AlertFrameText:SetTextColor(SAConfig.color.bu.r,SAConfig.color.bu.g,SAConfig.color.bu.b); |
||
627 | elseif (kind == 3) then |
||
628 | swatch = getglobal("SAem_NormalTexture"); |
||
629 | swatch:SetVertexColor(r,g,b); |
||
630 | SAConfig.color.em.r = r; |
||
631 | SAConfig.color.em.g = g; |
||
632 | SAConfig.color.em.b = b; |
||
633 | AlertFrameText:SetTextColor(SAConfig.color.em.r,SAConfig.color.em.g,SAConfig.color.em.b); |
||
634 | elseif (kind == 4) then |
||
635 | swatch = getglobal("SAto_NormalTexture"); |
||
636 | swatch:SetVertexColor(r,g,b); |
||
637 | SAConfig.color.to.r = r; |
||
638 | SAConfig.color.to.g = g; |
||
639 | SAConfig.color.to.b = b; |
||
640 | AlertFrameText:SetTextColor(SAConfig.color.to.r,SAConfig.color.to.g,SAConfig.color.to.b); |
||
641 | end |
||
642 | |||
643 | end |
||
644 | |||
645 | function SpellAlert_CancelColor() |
||
646 | if (kind == 0) then |
||
647 | swatch = getglobal("SAat_NormalTexture"); |
||
648 | SAConfig.color.at.r = sa_color_prev.r; |
||
649 | SAConfig.color.at.g = sa_color_prev.g; |
||
650 | SAConfig.color.at.b = sa_color_prev.b; |
||
651 | swatch:SetVertexColor(sa_color_prev.r, sa_color_prev.g, sa_color_prev.b); |
||
652 | elseif (kind == 1) then |
||
653 | swatch = getglobal("SAhe_NormalTexture"); |
||
654 | SAConfig.color.he.r = sa_color_prev.r; |
||
655 | SAConfig.color.he.g = sa_color_prev.g; |
||
656 | SAConfig.color.he.b = sa_color_prev.b; |
||
657 | swatch:SetVertexColor(sa_color_prev.r, sa_color_prev.g, sa_color_prev.b); |
||
658 | elseif (kind == 2) then |
||
659 | swatch = getglobal("SAbu_NormalTexture"); |
||
660 | SAConfig.color.bu.r = sa_color_prev.r; |
||
661 | SAConfig.color.bu.g = sa_color_prev.g; |
||
662 | SAConfig.color.bu.b = sa_color_prev.b; |
||
663 | swatch:SetVertexColor(sa_color_prev.r, sa_color_prev.g, sa_color_prev.b); |
||
664 | elseif (kind == 3) then |
||
665 | swatch = getglobal("SAem_NormalTexture"); |
||
666 | SAConfig.color.em.r = sa_color_prev.r; |
||
667 | SAConfig.color.em.g = sa_color_prev.g; |
||
668 | SAConfig.color.em.b = sa_color_prev.b; |
||
669 | swatch:SetVertexColor(sa_color_prev.r, sa_color_prev.g, sa_color_prev.b); |
||
670 | elseif (kind == 4) then |
||
671 | swatch = getglobal("SAto_NormalTexture"); |
||
672 | SAConfig.color.to.r = sa_color_prev.r; |
||
673 | SAConfig.color.to.g = sa_color_prev.g; |
||
674 | SAConfig.color.to.b = sa_color_prev.b; |
||
675 | swatch:SetVertexColor(sa_color_prev.r, sa_color_prev.g, sa_color_prev.b); |
||
676 | end |
||
677 | AlertFrameText:SetTextColor(0.3,0.3,0.3); |
||
678 | end |
||
679 | |||
680 | function SpellAlert_OptionsClose() |
||
681 | SAConfig.on = SpellAlert_Bool2Int(SAOptionsEnable:GetChecked()); |
||
682 | SAConfig.emote_on = SpellAlert_Bool2Int(SAOptionsEmote:GetChecked()); |
||
683 | SAConfig.retarget_on = SpellAlert_Bool2Int(SAOptionsRetarget:GetChecked()); |
||
684 | SAConfig.targetonly = SpellAlert_Bool2Int(SAOptionsTargetOnly:GetChecked()); |
||
685 | SAConfig.heals = SpellAlert_Bool2Int(SAOptionsHeals:GetChecked()); |
||
686 | SAConfig.cc = SpellAlert_Bool2Int(SAOptionsCC:GetChecked()); |
||
687 | SAConfig.dispelable = SpellAlert_Bool2Int(SAOptionsDispelable:GetChecked()); |
||
688 | SAConfig.misc = SpellAlert_Bool2Int(SAOptionsMisc:GetChecked()); |
||
689 | SAConfig.damage = SpellAlert_Bool2Int(SAOptionsDamage:GetChecked()); |
||
690 | SAConfig.livingBomb = SpellAlert_Bool2Int(SAOptionsBomb:GetChecked()); |
||
691 | AlertFrameText:SetText(" "); |
||
692 | sa_options = 0; |
||
693 | SAOptions:Hide(); |
||
694 | AlertFrame:ClearAllPoints(); |
||
695 | getX = AlertFrame:GetLeft(); |
||
696 | getY = AlertFrame:GetTop(); |
||
697 | SADrag:Hide(); |
||
698 | end |
||
699 | |||
700 | function SpellAlert_OptionsLoad() |
||
701 | local boxColor; |
||
702 | SAOptionsEnable:SetChecked(SpellAlert_Int2Bool(SAConfig.on)); |
||
703 | SAOptionsEmote:SetChecked(SpellAlert_Int2Bool(SAConfig.emote_on)); |
||
704 | SAOptionsRetarget:SetChecked(SpellAlert_Int2Bool(SAConfig.retarget_on)); |
||
705 | SAOptionsTargetOnly:SetChecked(SpellAlert_Int2Bool(SAConfig.targetonly)); |
||
706 | SAOptionsHeals:SetChecked(SpellAlert_Int2Bool(SAConfig.heals)); |
||
707 | SAOptionsCC:SetChecked(SpellAlert_Int2Bool(SAConfig.cc)); |
||
708 | SAOptionsDispelable:SetChecked(SpellAlert_Int2Bool(SAConfig.dispelable)); |
||
709 | SAOptionsMisc:SetChecked(SpellAlert_Int2Bool(SAConfig.misc)); |
||
710 | SAOptionsDamage:SetChecked(SpellAlert_Int2Bool(SAConfig.damage)); |
||
711 | SAOptionsBomb:SetChecked(SpellAlert_Int2Bool(SAConfig.livingBomb)); |
||
712 | SASizeSlider:SetValue(SAConfig.zoom); |
||
713 | SAPosSlider:SetValue(SAConfig.pos); |
||
714 | SAShadowSlider:SetValue(SAConfig.shadow); |
||
715 | SADelaySlider:SetValue(SAConfig.holdTime); |
||
716 | boxColor = getglobal("SAat_NormalTexture"); |
||
717 | boxColor:SetVertexColor(SAConfig.color.at.r,SAConfig.color.at.g,SAConfig.color.at.b); |
||
718 | boxColor = getglobal("SAhe_NormalTexture"); |
||
719 | boxColor:SetVertexColor(SAConfig.color.he.r,SAConfig.color.he.g,SAConfig.color.he.b); |
||
720 | boxColor = getglobal("SAbu_NormalTexture"); |
||
721 | boxColor:SetVertexColor(SAConfig.color.bu.r,SAConfig.color.bu.g,SAConfig.color.bu.b); |
||
722 | boxColor = getglobal("SAem_NormalTexture"); |
||
723 | boxColor:SetVertexColor(SAConfig.color.em.r,SAConfig.color.em.g,SAConfig.color.em.b); |
||
724 | boxColor = getglobal("SAto_NormalTexture"); |
||
725 | boxColor:SetVertexColor(SAConfig.color.to.r,SAConfig.color.to.g,SAConfig.color.to.b); |
||
726 | |||
727 | SAOptionsRadio1:SetChecked(0); |
||
728 | SAOptionsRadio2:SetChecked(0); |
||
729 | SAOptionsRadio3:SetChecked(0); |
||
730 | SAOptionsRadioA:SetChecked(0); |
||
731 | SAOptionsRadioB:SetChecked(0); |
||
732 | |||
733 | sa_options = 1; |
||
734 | AlertFrameText:SetAlpha(1); |
||
735 | AlertFrameText:Show(); |
||
736 | AlertFrameText:SetTextColor(0.3,0.3,0.3); |
||
737 | if (SAConfig.radio == 1) then |
||
738 | SAOptionsRadio1:SetChecked(1); |
||
739 | AlertFrameText:SetText("<Enemy Name> begins casting <Spell>!"); |
||
740 | elseif (SAConfig.radio == 2) then |
||
741 | SAOptionsRadio2:SetChecked(1); |
||
742 | AlertFrameText:SetText("<Enemy Name> begins casting |cffffffff<Spell>!|r"); |
||
743 | else |
||
744 | SAOptionsRadio3:SetChecked(1); |
||
745 | AlertFrameText:SetText("|cffffffff<Enemy Name> begins casting |r<Spell>!"); |
||
746 | end |
||
747 | |||
748 | if (SAConfig.drag == 5) then |
||
749 | SAOptionsRadioA:SetChecked(1); |
||
750 | else |
||
751 | SAOptionsRadioB:SetChecked(1); |
||
752 | end |
||
753 | |||
754 | SpellAlert_Toggle(); |
||
755 | |||
756 | end |
||
757 | |||
758 | function SA_Radio_OnClick() |
||
759 | local radioId = this:GetID(); |
||
760 | if(radioId <= 3) then |
||
761 | SAConfig.radio = radioId; |
||
762 | else |
||
763 | SAConfig.drag = radioId; |
||
764 | end |
||
765 | SA_Radio_Update(); |
||
766 | end |
||
767 | |||
768 | function SA_Radio_Update() |
||
769 | SAOptionsRadio1:SetChecked(0); |
||
770 | SAOptionsRadio2:SetChecked(0); |
||
771 | SAOptionsRadio3:SetChecked(0); |
||
772 | SAOptionsRadioA:SetChecked(0); |
||
773 | SAOptionsRadioB:SetChecked(0); |
||
774 | |||
775 | if (SAConfig.radio == 1) then |
||
776 | SAOptionsRadio1:SetChecked(1); |
||
777 | AlertFrameText:SetText("<Enemy Name> begins casting <Spell>!"); |
||
778 | elseif (SAConfig.radio == 2) then |
||
779 | SAOptionsRadio2:SetChecked(1); |
||
780 | AlertFrameText:SetText("<Enemy Name> begins casting |cffffffff<Spell>!|r"); |
||
781 | else |
||
782 | SAOptionsRadio3:SetChecked(1); |
||
783 | AlertFrameText:SetText("|cffffffff<Enemy Name> begins casting |r<Spell>!"); |
||
784 | end |
||
785 | |||
786 | if (SAConfig.drag == 5) then |
||
787 | SAOptionsRadioA:SetChecked(1); |
||
788 | else |
||
789 | SAOptionsRadioB:SetChecked(1); |
||
790 | end |
||
791 | |||
792 | SpellAlert_Toggle() |
||
793 | |||
794 | end |
||
795 | |||
796 | function SpellAlert_Toggle() |
||
797 | |||
798 | if (SAConfig.drag == 5) then |
||
799 | SADrag:SetMovable(false); |
||
800 | AlertFrame:ClearAllPoints(); |
||
801 | AlertFrame:SetPoint("TOP", 0, SAConfig.pos); |
||
802 | AlertFrameText:ClearAllPoints(); |
||
803 | AlertFrameText:SetPoint("CENTER", "AlertFrame", "CENTER"); |
||
804 | AlertFrameText:SetJustifyH("CENTER"); |
||
805 | SADrag:Hide(); |
||
806 | else |
||
807 | |||
808 | if (sa_options == 1) then |
||
809 | SADrag:Show(); |
||
810 | end |
||
811 | |||
812 | AlertFrame:ClearAllPoints(); |
||
813 | |||
814 | if ((SADrag:GetLeft()+32) < (GetScreenWidth()/2)) then |
||
815 | AlertFrame:SetPoint("LEFT", "SADrag", "LEFT", 0, -30); |
||
816 | AlertFrameText:ClearAllPoints(); |
||
817 | AlertFrameText:SetPoint("LEFT", "AlertFrame", "LEFT"); |
||
818 | AlertFrameText:SetJustifyH("LEFT"); |
||
819 | else |
||
820 | AlertFrame:SetPoint("RIGHT", "SADrag", "RIGHT", 0, -30); |
||
821 | AlertFrameText:ClearAllPoints(); |
||
822 | AlertFrameText:SetPoint("RIGHT", "AlertFrame", "RIGHT"); |
||
823 | AlertFrameText:SetJustifyH("RIGHT"); |
||
824 | end |
||
825 | |||
826 | SADrag:SetMovable(true); |
||
827 | end |
||
828 | |||
829 | end |
||
830 | |||
831 | function AlertFrame_Adjust() |
||
832 | |||
833 | if (SADrag:IsVisible()) then |
||
834 | if ((SADrag:GetLeft()+32) < (GetScreenWidth()/2)) then |
||
835 | if (change == 0 and not changed) then |
||
836 | AlertFrame:ClearAllPoints(); |
||
837 | AlertFrame:SetPoint("LEFT", "SADrag", "LEFT", 0, -30); |
||
838 | AlertFrameText:ClearAllPoints(); |
||
839 | AlertFrameText:SetPoint("LEFT", "AlertFrame", "LEFT"); |
||
840 | AlertFrameText:SetJustifyH("LEFT"); |
||
841 | changed = true; |
||
842 | elseif (change == 1 and changed) then |
||
843 | change = 0; |
||
844 | changed = false; |
||
845 | end |
||
846 | |||
847 | AlertFrameText:SetWidth(GetScreenWidth() - AlertFrame:GetLeft()); |
||
848 | |||
849 | else |
||
850 | if (change == 1 and not changed) then |
||
851 | AlertFrame:ClearAllPoints(); |
||
852 | AlertFrame:SetPoint("RIGHT", "SADrag", "RIGHT", 0, -30); |
||
853 | AlertFrameText:ClearAllPoints(); |
||
854 | AlertFrameText:SetPoint("RIGHT", "AlertFrame", "RIGHT"); |
||
855 | AlertFrameText:SetJustifyH("RIGHT"); |
||
856 | changed = true; |
||
857 | elseif (change == 0 and changed) then |
||
858 | change = 1; |
||
859 | changed = false; |
||
860 | end |
||
861 | |||
862 | AlertFrameText:SetWidth(GetScreenWidth() - (GetScreenWidth() - AlertFrame:GetRight())); |
||
863 | |||
864 | end |
||
865 | |||
866 | end |
||
867 | |||
868 | end |
||
869 | |||
870 | |||
871 | function SpellAlert_UpdateLook() |
||
872 | |||
873 | if(SAConfig.shadow == 0) then |
||
874 | shadow = ""; |
||
875 | elseif (SAConfig.shadow == 1) then |
||
876 | shadow = "OUTLINE"; |
||
877 | elseif (SAConfig.shadow == 2) then |
||
878 | shadow = "THICKOUTLINE"; |
||
879 | end |
||
880 | |||
881 | AlertFrameText:SetFont("Fonts\\FRIZQT__.TTF", SAConfig.zoom, shadow); |
||
882 | |||
883 | end |
||
884 | |||
885 | |||
886 | function SpellAlert_UpdatePosition() |
||
887 | |||
888 | AlertFrame:ClearAllPoints(); |
||
889 | AlertFrame:SetPoint("TOP", 0, SAConfig.pos); |
||
890 | |||
891 | end |
||
892 | |||
893 | function SpellAlert_Bool2Int(val) |
||
894 | if (val) then |
||
895 | return 1; |
||
896 | else |
||
897 | return 0; |
||
898 | end |
||
899 | end |
||
900 | |||
901 | function SpellAlert_Int2Bool(val) |
||
902 | if (val == 0) then |
||
903 | return nil; |
||
904 | else |
||
905 | return 1; |
||
906 | end |
||
907 | end |
||
908 | |||
909 | function AlertFrame_Show() |
||
910 | startTime = GetTime(); |
||
911 | AlertFrameText:Show(); |
||
912 | end |
||
913 | |||
914 | function SpellAlert_OnUpdate() |
||
915 | local targetName = UnitName("target"); |
||
916 | if (targetName) then |
||
917 | sa_targetClass = UnitClass("target"); |
||
918 | sa_targetHostile = UnitIsEnemy("player", "target"); |
||
919 | sa_targetName = targetName; |
||
920 | else |
||
921 | if (sa_targetName and (sa_targetClass == "Hunter") and sa_targetHostile) then |
||
922 | SpellAlert_retargetHunter(); |
||
923 | end |
||
924 | end |
||
925 | |||
926 | if(sa_options == 0) then |
||
927 | local elapsed = GetTime() - startTime; |
||
928 | if ( elapsed < fadeInTime ) then |
||
929 | local alpha = (elapsed / fadeInTime); |
||
930 | AlertFrameText:SetAlpha(alpha); |
||
931 | return; |
||
932 | end |
||
933 | if ( elapsed < (fadeInTime + SAConfig.holdTime) ) then |
||
934 | AlertFrameText:SetAlpha(1.0); |
||
935 | return; |
||
936 | end |
||
937 | if ( elapsed < (fadeInTime + SAConfig.holdTime + fadeOutTime) ) then |
||
938 | local alpha = 1.0 - ((elapsed - SAConfig.holdTime - fadeInTime) / fadeOutTime); |
||
939 | AlertFrameText:SetAlpha(alpha); |
||
940 | return; |
||
941 | end |
||
942 | AlertFrameText:Hide(); |
||
943 | end |
||
944 | end |