vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 -------------------------------------------------------------------------------
2 -- Quu Spell Alert
3 -- A mod that alerts about spell effects. Written by Quu
4 -- Original "Spell Alert" written by Awen
5 -------------------------------------------------------------------------------
6  
7 -------------------------------------------------------------------------------
8 -- Contants
9 -- The things that make this tick
10 -------------------------------------------------------------------------------
11 BINDING_HEADER_QSATITLE = "Quu Spell Alert";
12 QSA_VERSION = "2.5.1";
13 local QSA_SLASH_COMMAND = "/qsa";
14 -- how long alerts should be displayed
15 local QSA_NON_CRIT_TIME = 2;
16 local QSA_CRIT_TIME = 5;
17  
18 -------------------------------------------------------------------------------
19 -- controll variables
20 -- these are the variables that are saved between sessions, and variables
21 -- that enable the "controll" logic
22 -------------------------------------------------------------------------------
23  
24 -- the basics (there are stored in the savedvariables.lua
25 QSA_SavedVars_DEFAULT = {
26 Enabled = true;
27  
28 CombatOnly = true;
29 TargetOnly = false;
30  
31 ShortDisplay = true;
32  
33 EmoteMode = true;
34 GainMode = true;
35 FadeMode = false;
36 Afflictions = true;
37  
38 QSA_Hide = false;
39 };
40  
41 QSA_SavedVars = {
42 };
43 QSA_RED = 1.0;
44 QSA_GREEN = 0.2;
45 QSA_BLUE = 0.2;
46 QSA_ALPHA = 1.0;
47  
48 function getVar( varName)
49 local playerName = UnitName( "player");
50 if (not QSA_SavedVars[playerName]) then
51 QSA_SavedVars[playerName] = QSA_SavedVars_DEFAULT;
52 end
53  
54 return QSA_SavedVars[playerName][varName];
55 end
56  
57 function setVar( varName, value)
58 local playerName = UnitName( "player");
59 if (not QSA_SavedVars[playerName]) then
60 QSA_SavedVars[playerName] = QSA_SavedVars_DEFAULT;
61 end
62  
63 QSA_SavedVars[playerName][varName] = value;
64 end
65  
66 function toggleVar( varName)
67 local playerName = UnitName( "player");
68 if (not QSA_SavedVars[playerName]) then
69 QSA_SavedVars[playerName] = QSA_SavedVars_DEFAULT;
70 end
71  
72 QSA_SavedVars[playerName][varName] = not QSA_SavedVars[playerName][varName];
73 end
74  
75  
76 -- this is the last caster that was captured
77 -- used for the key binding
78 local QSA_LastTarget;
79  
80 -------------------------------------------------------------------------------
81 -- Alert functions
82 -------------------------------------------------------------------------------
83 -- print simple messages
84 function QSA_println( Message)
85 DEFAULT_CHAT_FRAME:AddMessage(Message, 1.0, 1.0, 1.0);
86 end
87  
88 -- normal alerts
89 function QSA_Banner(msg)
90 QuuSpellAlertNormalFrame:AddMessage(msg, QSA_RED, QSA_GREEN, QSA_BLUE, QSA_ALPHA, QSA_NON_CRIT_TIME);
91 end
92  
93 -- critical alerts
94 function QSA_Critical(msg)
95 QuuSpellAlertCriticalFrame:AddMessage(msg, QSA_RED, QSA_GREEN, QSA_BLUE, QSA_ALPHA, QSA_CRIT_TIME);
96 end
97  
98 -------------------------------------------------------------------------------
99 -- the colour picking stuff (and alpha)
100 -------------------------------------------------------------------------------
101 -- initial loading of the color chooser
102 function QSA_ChooseColor()
103 ColorPickerFrame.func = QSA_SetColor;
104 ColorPickerFrame.hasOpacity = true;
105 ColorPickerFrame.opacityFunc = QSA_SetOpacity;
106 ColorPickerFrame.opacity = 1.0 - QSA_ALPHA;
107 ColorPickerFrame:SetColorRGB(QSA_RED, QSA_GREEN, QSA_BLUE);
108 ColorPickerFrame.previousValues = {r = QSA_RED, g = QSA_GREEN, b = QSA_BLUE, opacity = (1.0 - QSA_ALPHA)};
109 ColorPickerFrame.cancelFunc = QSA_CancelColor;
110 ShowUIPanel(ColorPickerFrame);
111 end
112  
113 -- this is the values as they are set
114 function QSA_SetColor()
115 QSA_RED, QSA_GREEN, QSA_BLUE = ColorPickerFrame:GetColorRGB();
116 end
117  
118 -- this si the opacity as they are set
119 function QSA_SetOpacity()
120 QSA_ALPHA = 1.0 - OpacitySliderFrame:GetValue();
121 end
122  
123 -- they changed thier minds
124 function QSA_CancelColor()
125 QSA_RED = ColorPickerFrame.previousValues.r;
126 QSA_GREEN = ColorPickerFrame.previousValues.g;
127 QSA_BLUE = ColorPickerFrame.previousValues.b;
128 QSA_ALPHA = 1.0 - ColorPickerFrame.previousValues.opacity;
129 end
130  
131 -------------------------------------------------------------------------------
132 -- Options box... the functions for the options dialog box
133 -------------------------------------------------------------------------------
134 function QSA_OptionsOpen()
135 if ( not QuuSpellAlertOptions:IsVisible() ) then
136 QuuSpellAlertOptionsEnable:SetChecked(getVar("Enabled"));
137 QuuSpellAlertOptionsCombat:SetChecked(getVar("CombatOnly"));
138 QuuSpellAlertOptionsTarget:SetChecked(getVar("TargetOnly"));
139 QuuSpellAlertOptionsShort:SetChecked(getVar("ShortDisplay"));
140 QuuSpellAlertOptionsEmote:SetChecked(getVar("EmoteMode"));
141 QuuSpellAlertOptionsGain:SetChecked(getVar("GainMode"));
142 QuuSpellAlertOptionsFade:SetChecked(getVar("FadeMode"));
143 QuuSpellAlertOptionsAffliction:SetChecked(getVar("Afflictions"));
144  
145 QuuSpellAlertOptions:Show();
146 else
147 QSA_OptionsClose();
148 end
149 end
150  
151 function QSA_OptionsClose()
152  
153 setVar( "Enabled", QuuSpellAlertOptionsEnable:GetChecked());
154 setVar( "CombatOnly", QuuSpellAlertOptionsCombat:GetChecked());
155 setVar( "TargetOnly", QuuSpellAlertOptionsTarget:GetChecked());
156 setVar( "ShortDisplay", QuuSpellAlertOptionsShort:GetChecked());
157 setVar( "EmoteMode", QuuSpellAlertOptionsEmote:GetChecked());
158 setVar( "GainMode", QuuSpellAlertOptionsGain:GetChecked());
159 setVar( "FadeMode", QuuSpellAlertOptionsFade:GetChecked());
160 setVar( "Afflictions", QuuSpellAlertOptionsAffliction:GetChecked());
161  
162 QuuSpellAlertOptions:Hide();
163 end
164  
165 -------------------------------------------------------------------------------
166 -- the init and configuration
167 -------------------------------------------------------------------------------
168 function QSA_Init()
169 QSA_Status();
170  
171 -- Register our slash command
172 SLASH_QSA1 = QSA_SLASH_COMMAND;
173 SlashCmdList["QSA"] = function(msg)
174 QSA_Command(msg);
175 end
176  
177 if (getVar( "QSA_Hide")) then
178 QuuSpellAlertAnchor:Hide();
179 end
180  
181 QSA_LastTarget = nil;
182 end
183  
184 function QSA_Command(msg)
185 if( msg ) then
186 local command = string.lower(msg);
187 if( command == "" ) then
188 QSA_println(QSA_SLASH_COMMAND.." ["..QSA_MACRO_STATUS.."|"..QSA_MACRO_TOGGLE.."|...]");
189 QSA_println(" "..QSA_MACRO_STATUS.." "..QSA_MACRO_STATUS_DESC);
190 QSA_println(" "..QSA_MACRO_TOGGLE.." "..QSA_MACRO_TOGGLE_DESC);
191 QSA_println(" "..QSA_MACRO_REPORT.." "..QSA_MACRO_REPORT_DESC);
192 QSA_println(" "..QSA_MACRO_TARGET.." "..QSA_MACRO_TARGET_DESC);
193 QSA_println(" "..QSA_MACRO_SHOW.." "..QSA_MACRO_SHOW_DESC);
194 QSA_println(" "..QSA_MACRO_EMOTE.." "..QSA_MACRO_EMOTE_DESC);
195 QSA_println(" "..QSA_MACRO_GAIN.." "..QSA_MACRO_GAIN_DESC);
196 QSA_println(" "..QSA_MACRO_FADE.." "..QSA_MACRO_FADE_DESC);
197 QSA_println(" "..QSA_MACRO_COMBAT.." "..QSA_MACRO_COMBAT_DESC);
198 QSA_println(" "..QSA_MACRO_TRGNLY.." "..QSA_MACRO_TRGNLY_DESC);
199 QSA_println(" "..QSA_MACRO_SHORT.." "..QSA_MACRO_SHORT_DESC);
200 QSA_println(" "..QSA_MACRO_AFFL.." "..QSA_MACRO_AFFL_DESC);
201 QSA_println(" "..QSA_MACRO_TEST.." "..QSA_MACRO_TEST_DESC);
202 elseif (command == QSA_MACRO_STATUS ) then
203 QSA_Status();
204 elseif (command == QSA_MACRO_TOGGLE ) then
205 toggleVar( "Enabled");
206 QSA_Status();
207 elseif (command == QSA_MACRO_REPORT ) then
208 toggleVar( "QSA_Report");
209 QSA_Status();
210 elseif (command == QSA_MACRO_TARGET ) then
211 QSA_TargetLast();
212 elseif (command == QSA_MACRO_SHOW ) then
213 setVar( "QSA_Hide", false)
214 QuuSpellAlertAnchor:Show();
215 QuuSpellAlertTimerFrame:Show();
216 elseif (command == QSA_MACRO_EMOTE ) then
217 toggleVar( "EmoteMode");
218 QSA_Status();
219 elseif (command == QSA_MACRO_GAIN ) then
220 toggleVar( "GainMode");
221 QSA_Status();
222 elseif (command == QSA_MACRO_FADE ) then
223 toggleVar( "FadeMode");
224 QSA_Status();
225 elseif (command == QSA_MACRO_COMBAT ) then
226 toggleVar( "CombatOnly");
227 QSA_Status();
228 elseif (command == QSA_MACRO_TRGNLY ) then
229 toggleVar( "TargetOnly");
230 QSA_Status();
231 elseif (command == QSA_MACRO_SHORT ) then
232 toggleVar( "ShortDisplay");
233 QSA_Status();
234 elseif (command == QSA_MACRO_AFFL ) then
235 toggleVar( "Afflictions");
236 QSA_Status();
237 elseif (command == QSA_MACRO_TEST ) then
238 QSA_Test();
239 else
240 QSA_println( QSA_MACRO_ERROR);
241 end
242 end
243 end
244  
245 function QSA_Test()
246 local enabled_temp = getVar("Enabled");
247 local combat_temp = getVar("CombatOnly");
248 local target_only = getVar("TargetOnly");
249  
250 setVar( "Enabled",true);
251 setVar( "CombatOnly",false);
252 setVar( "TargetOnly",false);
253  
254 -- I am not going to localize the test strings
255  
256  
257 --Running through the events
258 local creature = "Beta Death Shaman";
259  
260 local emote = " is dacing to the beat!";
261 QSA_Event( "CHAT_MSG_MONSTER_EMOTE", emote, creature);
262  
263 local casting = "Uber Flame Strike";
264 local buffer = string.format(SPELLCASTOTHERSTART, creature, casting);
265 QSA_Event( "CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE", buffer, nil);
266  
267 local performing = "Death Coil Onion";
268 buffer = string.format(SPELLPERFORMOTHERSTART, creature, performing);
269 QSA_Event( "CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE", buffer, nil);
270  
271 local totem = "Uber "..QSA_TOTEM;
272 buffer = string.format(SPELLCASTGOOTHER, creature, totem);
273 QSA_Event( "CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE", buffer, nil);
274  
275  
276 local aura = "Uberness";
277 buffer = string.format(AURAADDEDOTHERHELPFUL, creature, aura);
278 QSA_Event( "CHAT_MSG_SPELL_CREATURE_VS_PARTY_DAMAGE", buffer, nil);
279  
280 -- and displaying some information
281 QSA_Critical("This is the Critical Alert area");
282 QSA_Critical("More important stuff is here");
283  
284 setVar( "TargetOnly",target_only);
285 setVar( "CombatOnly",combat_temp);
286 setVar( "Enabled",enabled_temp);
287 end
288  
289 function QSA_TargetLast()
290 if (QSA_LastTarget ~= nil) then
291 TargetByName(QSA_LastTarget);
292 end
293 end
294  
295 function QSA_Status()
296 --[[
297 QSA_println( "Quu Spell Alert "..QSA_VERSION);
298 if (getVar("Enabled")) then
299 QSA_println( QSA_STATUS_ENABLED);
300 if (QSA_Report) then
301 QSA_println( QSA_REPORT_ENABLED);
302 end
303 if (getVar("EmoteMode")) then
304 QSA_println( QSA_EMOTE_ENABLED);
305 end
306 if (getVar("GainMode")) then
307 QSA_println( QSA_GAIN_ENABLED);
308 end
309 if (getVar("FadeMode")) then
310 QSA_println( QSA_FADE_ENABLED);
311 end
312 if (getVar("CombatOnly")) then
313 QSA_println( QSA_COMBAT_ENABLED);
314 end
315 if (getVar("TargetOnly")) then
316 QSA_println( QSA_TRGONLY_ENABLED)
317 end
318 if (getVar("ShortDisplay")) then
319 QSA_println( QSA_SHORT_ENABLED)
320 end
321 if (getVar("Afflictions")) then
322 QSA_println( QSA_AFFL_ENABLED)
323 end
324 else
325 QSA_println( QSA_STATUS_DISBALED);
326 end
327 ]]--
328 end
329  
330  
331 -------------------------------------------------------------------------------
332 -- the display logic
333 -- this takes the spell and caster... and determains if we alert on it
334 -------------------------------------------------------------------------------
335  
336 function QSA_ReplaceTokens( originalString, caster, effect)
337 return string.gsub( string.gsub( originalString, "$c", caster), "$e", effect);
338 end
339  
340 -- name check function
341 function QSA_IsInParty( Name)
342 if (Name == UnitName("player")) then
343 return true;
344 elseif (Name == UnitName("pet")) then
345 return true;
346 elseif (Name == UnitName("party1")) then
347 return true;
348 elseif (Name == UnitName("party2")) then
349 return true;
350 elseif (Name == UnitName("party3")) then
351 return true;
352 elseif (Name == UnitName("party4")) then
353 return true;
354 elseif (Name == UnitName("partypet1")) then
355 return true;
356 elseif (Name == UnitName("partypet2")) then
357 return true;
358 elseif (Name == UnitName("partypet3")) then
359 return true;
360 elseif (Name == UnitName("partypet4")) then
361 return true;
362 else
363 local numRaidMembers = GetNumRaidMembers();
364 if (numRaidMembers > 0) then
365 -- we are in a raid
366 for i=1, numRaidMembers do
367 RaidName = GetRaidRosterInfo(i);
368 if ( Name == RaidName) then
369 return true;
370 end
371 if ( Name == UnitName("raidpet"..i)) then
372 return true;
373 end
374 end
375 end
376 end
377 return false;
378 end
379  
380 -- this displays the information
381 function QSA_Display( Creature, Effect, Msg, type, bannner)
382 if (not getVar(type)) then
383 return;
384 end;
385  
386 -- first... do we ignore it?
387 if (QSA_IgnoreSpells[Effect]) then
388 return;
389 end
390  
391 -- then if they are in our party... ignore it
392 if (QSA_IsInParty(Creature)) then
393 return;
394 end
395  
396 if (getVar("TargetOnly") and (UnitExists("target"))) then
397 if (UnitName("target") ~= Creature) then
398 return;
399 end
400 end
401  
402 -- save the name for a targetbyname possability
403 QSA_LastTarget = Creature;
404  
405 if (QSA_ImportantSpells[Effect]) then
406 -- its important... flag it
407 if (getVar("ShortDisplay")) then
408 QSA_Critical( QSA_ReplaceTokens(bannner, Creature, Effect));
409 else
410 QSA_Critical( Msg);
411 end
412  
413 else
414 -- its not important... put a normal display
415 if (getVar("ShortDisplay")) then
416 QSA_Banner( QSA_ReplaceTokens(bannner, Creature, Effect));
417 else
418 QSA_Banner( Msg);
419 end
420 end
421  
422 end
423  
424 -------------------------------------------------------------------------------
425 -- event block... this listens and deals with all those pesky events
426 -------------------------------------------------------------------------------
427  
428 -- this is all the events that might trip up ones we care about
429 -- all these doe is remove potential "pitfall" alerts... spam
430 QSA_PreConsumerStrings = {
431 AURAADDEDSELFHELPFUL,
432 AURADISPELSELF,
433 AURAREMOVEDSELF,
434 GENERICPOWERGAIN_OTHER,
435 GENERICPOWERGAIN_SELF,
436 PERIODICAURAHEALOTHEROTHER,
437 PERIODICAURAHEALOTHERSELF,
438 PERIODICAURAHEALSELFOTHER,
439 PERIODICAURAHEALSELFSELF,
440 POWERGAIN_OTHER,
441 POWERGAIN_SELF,
442 SPELLCASTGOSELF,
443 SPELLCASTSELFSTART,
444 SPELLEXTRAATTACKSOTHER,
445 SPELLEXTRAATTACKSOTHER_SINGULAR,
446 SPELLEXTRAATTACKSSELF,
447 SPELLEXTRAATTACKSSELF_SINGULAR,
448 SPELLPERFORMSELFSTART,
449 SPELLPOWERDRAINOTHEROTHER,
450 SPELLPOWERDRAINOTHERSELF,
451 SPELLPOWERLEECHOTHEROTHER,
452 SPELLPOWERLEECHOTHERSELF,
453 SPELLPOWERLEECHSELFOTHER,
454 }
455  
456 -- this function converts one of the globals into a search string
457 -- this is important so we don't have to localize them
458 function QSA_FormatGlobalStrings( globalString)
459 local res = globalString;
460  
461 -- first reformat the "global" so it can be gsubed
462 local i;
463 for i = 1, string.len(res) do
464 if (string.sub(res, i, i) == "%") then
465 if (i == 1) then
466 res = "$"..string.sub(res, 2);
467 else
468 res = string.sub(res, 1, i -1).."$"..string.sub(res, i + 1);
469 end
470 end
471 end
472 res = string.gsub(res, "$s", "(.+)");
473 res = string.gsub(res, "$d", "(%d)");
474 return res;
475 end
476  
477 -- this is the "big" function
478 function QSA_Event(event, arg1, arg2)
479 -- are we enabled
480 if (not getVar("Enabled")) then
481 return;
482 end
483  
484 -- are we in combat
485 if ((not UnitAffectingCombat("player")) and getVar("CombatOnly")) then
486 return;
487 end
488  
489 -- first lets check for emotes
490 if (
491 (event == "CHAT_MSG_EMOTE") or
492 -- (event == "CHAT_MSG_TEXT_EMOTE") or
493 (event == "CHAT_MSG_MONSTER_EMOTE")
494 ) then
495 -- got one... process it for display
496 QSA_Display( arg2, arg1, arg2.." "..arg1, "EmoteMode", QSA_EMOTE_BANNER);
497 return;
498 elseif (
499 (event == "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE") or
500 (event == "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE") or
501 (event == "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE")
502 ) then
503 -- looks like we have somethign effecting the party
504  
505 if (getVar("Afflictions")) then
506 for effect in string.gfind(arg1,QSA_FormatGlobalStrings(AURAADDEDSELFHARMFUL)) do
507 if (getVar("Afflictions")) then
508 if (QSA_Alert_Afflictions[effect]) then
509 QSA_Critical(arg1);
510 end
511 end
512  
513 return;
514 end
515  
516 -- now we look to see if a team member is afflicted with somethign we care about
517 for player, effect in string.gfind(arg1,QSA_FormatGlobalStrings(AURAADDEDOTHERHARMFUL)) do
518 --AURAADDEDOTHERHARMFUL = "%s is afflicted by %s."; -- Combat log text for aura events
519 if (QSA_Alert_Afflictions[effect]) then
520 QSA_Critical(arg1);
521 end
522 return;
523 end
524 end
525 else
526  
527 -- first remove any troublesome strings that might trip up the real ones
528 for key, value in QSA_PreConsumerStrings do
529 for _ in string.gfind(arg1,QSA_FormatGlobalStrings(value)) do
530 if (QSA_Debug) then
531 if ( not QSA_DebugArray.preConsumed) then
532 QSA_DebugArray.preConsumed = { };
533 end
534 QSA_DebugArray.preConsumed[arg1] = event;
535 end
536 return;
537 end
538 end
539  
540  
541 -- now parse the different spells we listen to
542 local mob = "<ERROR>";
543 local effect = "<ERROR>";
544  
545  
546 for mob, effect in string.gfind(arg1,QSA_FormatGlobalStrings(SPELLCASTOTHERSTART)) do
547 QSA_Display( mob, effect, arg1, "Enabled", QSA_CASTING_BANNER);
548 return;
549 end
550  
551 for mob, effect in string.gfind(arg1,QSA_FormatGlobalStrings(SPELLPERFORMOTHERSTART)) do
552 QSA_Display( mob, effect, arg1, "Enabled", QSA_CASTING_BANNER);
553 return;
554 end
555  
556 for mob, effect in string.gfind(arg1,QSA_FormatGlobalStrings(SPELLCASTGOOTHER)) do
557 if (string.find(effect, QSA_TOTEM)) then
558 QSA_Display( mob, effect, arg1, "Enabled", QSA_CASTING_BANNER);
559 end
560  
561  
562 return;
563 end
564  
565 for effect, mob in string.gfind(arg1,QSA_FormatGlobalStrings(AURAREMOVEDOTHER)) do
566 QSA_Display( mob, effect, arg1, "FadeMode", QSA_FADE_BANNER);
567 return;
568 end
569  
570 for mob, effect in string.gfind(arg1,QSA_FormatGlobalStrings(AURADISPELOTHER)) do
571 QSA_Display( mob, effect, arg1, "FadeMode", QSA_FADE_BANNER);
572 return;
573 end
574  
575 for mob, effect in string.gfind(arg1,QSA_FormatGlobalStrings(AURAADDEDOTHERHELPFUL)) do
576 QSA_Display( mob, effect, arg1, "GainMode", QSA_GAIN_BANNER);
577 return;
578 end
579  
580 -- GAIN2 is for when a mob gets a bad status ailment...
581 -- we don't normally care about that... so only do it
582 -- if it is an important event.
583 for mob, effect in string.gfind(arg1,QSA_FormatGlobalStrings(AURAADDEDOTHERHARMFUL)) do
584 if (QSA_ImportantSpells[effect]) then
585 QSA_Display( mob, effect, arg1, "GainMode", QSA_GAIN_BANNER);
586 end
587 return;
588 end
589  
590 end
591 end
592