vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 SpellAlertSCTVersion = "v11100-1";
2 SpellAlertDEBUG = false;
3  
4 --[[
5 SpellAlertSCT
6 Author: BarryJ (Eugorym of Perenolde) based on code from Awen
7 Version: 11100-1
8  
9 Description :
10 This is a modified version of SpellAlert that instead of putting the notification up in it's own frame will send a message to ScrollingCombatText.
11 There are several command line options to set how the text is displayed.
12  
13 /sasct crit [on/off] -- Whether or not the message should be a crit; does nothing if style is set to Message. [Default is Off]
14 /sasct status -- Displays the current configuration options.
15 /sasct style [message/vertical/rainbow/horizontal/angled down] -- Animation Style to use. [Default is Vertical]
16 /sasct targetonly [on/off] -- Whether or not to display messages from the selected target only. [Default is Off]
17 /sasct test -- Send a test message to see how it looks. (Also done automatically after a settings change)
18 /sasct emotes [on/off] -- Whether or not to display emotes along with spells. [Default is On]
19 /sasct targetindicator [string] -- Text to be put before and after the message, if the spell is being cast by your target. [Default is ' *** ']
20 /sasct retarget [on/off] -- Retarget after feign death like old SpellAlert. [Default is On]
21 /sasct bosswarnings [on/off] -- Deep Breath and Living Bomb Warning like old SpellAlert. [Default is On]
22 /sasct toggle [on/off] -- Toggles alerting of spell casting on and off. [Default is On]
23 /sasct color [default/target/warn/emote] [red/green/blue] [0.0 - 1.0] -- Sets the color component of the specified color.
24 /sasct compact [on/off] -- Toggles compacting of messages. [Default is Off]
25 /sasct repeat [number] -- How long in seconds to refrain from repeating the same message [Default is 2]
26  
27 Changes :
28 11100-1:
29 French compatibilty
30 /sasct repeat command added
31 Default message repeat delay time is now 2 seconds
32  
33 11000-11:
34 Bug Fix: Correctly displays the status of the BossWarnings Option
35 11000-10:
36 Added emote color options
37 Added compact option
38 Will no longer print the same message more than once every second
39 11000-9:
40 Now three different colors, one for regular (default), one for your target (target), and one for boss warnings (warn)
41 Added toggle option
42 Code fixes/optimizations
43 11000-8:
44 Clean up.
45 Added color to usage/help
46 Added /sasct retarget [on/off]
47 Added /sasct bosswarnings [on/off]
48 11000-7:
49 Incorporated changes by gygabyte
50 11000-6:
51 Default style is now Vertical, default Crit state is now Off
52 Added TargetIndicator option
53 Code cleanup (Yippie!)
54 Possible German support
55 Possible Korean support (Note: on curse-gaming there is a Korean Only version of 11000-5.2, more of that translation to come in 11000-7)
56 Less possible, but still possible French support
57 11000-5.2:
58 Back to one slash command
59 11000-5.1:
60 Fixed a bug with the /sasct reset from version 11000-5
61 11000-5:
62 Added the default settings to the help
63 Added a reset configuration command /sasct reset
64 Added emote toggle
65 11000-4:
66 Message Color is now changeable
67 Added TargetOnly option
68 11000-3:
69 Cleaned up code some more.
70 Added /sasct command and options for display.
71 Made file a .zip per request.
72 11000-2:
73 Cleaned up code a bit.
74 11000-1:
75 Initial Release
76 ]]
77  
78 sasct_color = {r = 1.0, g = 1.00, b = 1.00};
79 sasct_targetcolor = {r = 1.0, g = 1.00, b = 1.00};
80 sasct_warncolor = {r = 1.0, g = 0.00, b = 1.00};
81 sasct_emotecolor = {r = 0.70, g = 0.70, b = 1.00};
82  
83 -- variables option
84 --[[sasct_heals = 1;
85 sasct_cc = 1;
86 sasct_dispelable = 1;
87 sasct_damage = 1;]]
88  
89 -- Local variables
90 local playerName = nil;
91 local sa_targetName = nil;
92 local sa_targetClass = nil;
93 local sa_targetHostile = nil;
94 local sa_gains = {};
95 local partyNum = 0;
96 local raidNum = 0;
97 local raidList = {};
98 local listMessages = {};
99  
100 function SpellAlertSCT_ShowUsage()
101 local yellow = "|cffffff00";
102 local white = "|cffffffff";
103 SpellAlertSCT_print(SASCT_USAGE_HEADER_1..yellow..SpellAlertSCTVersion..white..SASCT_USAGE_HEADER_2);
104 SpellAlertSCT_print(yellow.."/sasct crit [on/off]"..white.." -- "..SASCT_USAGE_CRIT);
105 SpellAlertSCT_print(yellow.."/sasct status"..white.." -- "..SASCT_USAGE_STATUS);
106 SpellAlertSCT_print(yellow.."/sasct style [message/vertical/rainbow/horizontal/angled down]"..white.." -- "..SASCT_USAGE_STYLE);
107 SpellAlertSCT_print(yellow.."/sasct targetonly [on/off]"..white.." -- "..SASCT_USAGE_TARGETONLY);
108 SpellAlertSCT_print(yellow.."/sasct test"..white.." -- "..SASCT_USAGE_TEST);
109 -- SpellAlertSCT_print(yellow.."/sasct red [0.0 - 1.0]"..white.." -- "..SASCT_USAGE_RED);
110 -- SpellAlertSCT_print(yellow.."/sasct green [0.0 - 1.0]"..white.." -- "..SASCT_USAGE_GREEN);
111 -- SpellAlertSCT_print(yellow.."/sasct blue [0.0 - 1.0]"..white.." -- "..SASCT_USAGE_BLUE);
112 SpellAlertSCT_print(yellow.."/sasct emotes [on/off]"..white.." -- "..SASCT_USAGE_EMOTES);
113 SpellAlertSCT_print(yellow.."/sasct color [default/target/warn/emote] [red/green/blue] [0.0 - 1.0] "..white.." -- "..SASCT_USAGE_COLOR);
114 SpellAlertSCT_print(yellow.."/sasct targetindicator [string]"..white.." -- "..SASCT_USAGE_TARGETINDICATOR);
115 SpellAlertSCT_print(yellow.."/sasct retarget [on/off]"..white.." -- "..SASCT_USAGE_RETARGET);
116 SpellAlertSCT_print(yellow.."/sasct bosswarnings [on/off]"..white.." -- "..SASCT_USAGE_BOSSWARNINGS);
117 SpellAlertSCT_print(yellow.."/sasct toggle [on/off]"..white.." -- "..SASCT_USAGE_TOGGLE);
118 SpellAlertSCT_print(yellow.."/sasct compact [on/off]"..white.." -- "..SASCT_USAGE_COMPACT);
119 SpellAlertSCT_print(yellow.."/sasct repeat [number]"..white.." -- "..SASCT_USAGE_REPEAT);
120 end
121  
122 function SpellAlertSCT_alert(mob, spell, msg, msgtype)
123 if (SA_SPELLS_IGNORE[spell]) then
124 return;
125 end
126  
127 msgtodisplay = strsub(msg, 0, strlen(msg) - 1);
128  
129 if (SpellAlertDEBUG and msgtype == "?") then
130 local yellow = "|cffffff00";
131 local white = "|cffffffff";
132 SpellAlertSCT_print("Type: "..msgtype.." - Should print '"..yellow..msgtodisplay..white.."'");
133 end
134  
135 if (SpellAlertSCTDB[playerName].Compact) then
136 if (msgtype == "cast") then
137 msgtodisplay = mob.." > "..spell;
138 elseif (msgtype == "gain") then
139 msgtodisplay = mob.." + "..spell;
140 end
141 end
142  
143 local targetname = UnitName("target");
144 if (mob == targetname) then
145 SpellAlertSCT_SCTDisplay(msgtodisplay, true, msgtype);
146 else
147 if (not SpellAlertSCTDB[playerName].TargetOnly) then
148 SpellAlertSCT_SCTDisplay(msgtodisplay, false, msgtype);
149 end
150 end
151 end
152  
153 function SpellAlertSCT_SCTDisplay(msg, target, msgtype)
154 if (SpellAlertSCTDB[playerName].Toggle == false) then
155 return;
156 end
157  
158 if (not listMessages[msg]) then
159 listMessages[msg] = GetTime();
160 SpellAlertSCT_debug("Message: '"..msg.."' was printed for the first time at '"..listMessages[msg].."'");
161 elseif (GetTime() - listMessages[msg] < SpellAlertSCTDB[playerName].MessageRepeatTime) then
162 SpellAlertSCT_debug("Blocking message '"..msg.."' from repeating. Time difference = "..GetTime() - listMessages[msg]);
163 return;
164 else
165 listMessages[msg] = GetTime();
166 end
167  
168 local color = sasct_color;
169  
170 if (target) then
171 msg = SpellAlertSCTDB[playerName].TargetIndicator..msg..SpellAlertSCTDB[playerName].TargetIndicator;
172 color = sasct_targetcolor;
173 end
174  
175 if (msgtype == "emote") then
176 color = sasct_emotecolor;
177 end
178  
179 if (SpellAlertSCTDB[playerName].Style == "message") then
180 SCT_Display_Message(msg, color);
181 elseif (SpellAlertSCTDB[playerName].Style == "vertical") then
182 SCT_Display(msg, color, SpellAlertSCTDB[playerName].Crit, "event", 1 )
183 elseif (SpellAlertSCTDB[playerName].Style == "rainbow") then
184 SCT_Display(msg, color, SpellAlertSCTDB[playerName].Crit, "event", 2 )
185 elseif (SpellAlertSCTDB[playerName].Style == "horizontal") then
186 SCT_Display(msg, color, SpellAlertSCTDB[playerName].Crit, "event", 3 )
187 elseif (SpellAlertSCTDB[playerName].Style == "angled down") then
188 SCT_Display(msg, color, SpellAlertSCTDB[playerName].Crit, "event", 4 )
189 else
190 SCT_Display_Message(msg, color);
191 SpellAlertSCT_print(SASCT_ERRNOSTYLE);
192 end
193 end
194  
195 function SpellAlertSCT_ShowStatus()
196 if ( SpellAlertSCTDB[playerName].Crit ) then
197 SpellAlertSCT_print(SASCT_STATUS_CRIT..SpellAlertSCTDB[playerName].Style..SASCT_STATUS_CRIT_2);
198 else
199 SpellAlertSCT_print(SASCT_STATUS_NONCRIT..SpellAlertSCTDB[playerName].Style..SASCT_STATUS_CRIT_2);
200 end
201 if ( SpellAlertSCTDB[playerName].TargetOnly ) then
202 SpellAlertSCT_print(SASCT_STATUS_TARGETONLY_ON);
203 else
204 SpellAlertSCT_print(SASCT_STATUS_TARGETONLY_OFF);
205 end
206 if ( SpellAlertSCTDB[playerName].Emotes ) then
207 SpellAlertSCT_print(SASCT_STATUS_EMOTES_ON);
208 else
209 SpellAlertSCT_print(SASCT_STATUS_EMOTES_OFF);
210 end
211 if ( SpellAlertSCTDB[playerName].BossWarnings ) then
212 SpellAlertSCT_print(SASCT_STATUS_BOSSWARN_ON);
213 else
214 SpellAlertSCT_print(SASCT_STATUS_BOSSWARN_OFF);
215 end
216 if ( SpellAlertSCTDB[playerName].Compact ) then
217 SpellAlertSCT_print(SASCT_STATUS_COMPACT_ON);
218 else
219 SpellAlertSCT_print(SASCT_STATUS_COMPACT_OFF);
220 end
221 SpellAlertSCT_print(SASCT_STATUS_COLOR..SpellAlertSCTDB[playerName].defaultcolor.red.."/"..SpellAlertSCTDB[playerName].defaultcolor.green.."/"..SpellAlertSCTDB[playerName].defaultcolor.blue..SASCT_STATUS_COLOR_DEFAULT);
222 SpellAlertSCT_print(SASCT_STATUS_COLOR..SpellAlertSCTDB[playerName].targetcolor.red.."/"..SpellAlertSCTDB[playerName].targetcolor.green.."/"..SpellAlertSCTDB[playerName].targetcolor.blue..SASCT_STATUS_COLOR_TARGET);
223 SpellAlertSCT_print(SASCT_STATUS_COLOR..SpellAlertSCTDB[playerName].warncolor.red.."/"..SpellAlertSCTDB[playerName].warncolor.green.."/"..SpellAlertSCTDB[playerName].warncolor.blue..SASCT_STATUS_COLOR_WARN);
224 SpellAlertSCT_print(SASCT_STATUS_COLOR..SpellAlertSCTDB[playerName].emotecolor.red.."/"..SpellAlertSCTDB[playerName].emotecolor.green.."/"..SpellAlertSCTDB[playerName].emotecolor.blue..SASCT_STATUS_COLOR_EMOTE);
225  
226 SpellAlertSCT_print(SASCT_STATUS_REPEAT..SpellAlertSCTDB[playerName].MessageRepeatTime);
227  
228 local ti = SpellAlertSCTDB[playerName].TargetIndicator;
229 if (ti == "") then ti = "(blank)"; end
230 SpellAlertSCT_print(SASCT_STATUS_TARGETINDICATOR..ti);
231  
232 if ( SpellAlertSCTDB[playerName].Toggle ) then
233 SpellAlertSCT_print(SASCT_STATUS_TOGGLE_ON);
234 else
235 SpellAlertSCT_print(SASCT_STATUS_TOGGLE_OFF);
236 end
237 end
238  
239 function SpellAlertSCT_SlashHandler(msg)
240 if ( not msg or strlen(msg) <= 0 ) then
241 SpellAlertSCT_ShowUsage();
242 return;
243 end
244  
245 local command, params = SpellAlertSCT_NextParameter(string.lower(msg));
246  
247 if ( command == "crit" ) then
248 if ( not params ) then
249 if (SpellAlertSCTDB[playerName].Crit == true) then
250 SpellAlertSCTDB[playerName].Crit = false;
251 SpellAlertSCT_print(SASCT_OPT_CRIT_OFF);
252 else
253 SpellAlertSCTDB[playerName].Crit = true;
254 SpellAlertSCT_print(SASCT_OPT_CRIT_ON);
255 end
256 else
257 if (params == "on") then
258 SpellAlertSCTDB[playerName].Crit = true;
259 SpellAlertSCT_print(SASCT_OPT_CRIT_ON);
260 else
261 SpellAlertSCTDB[playerName].Crit = false;
262 SpellAlertSCT_print(SASCT_OPT_CRIT_OFF);
263 end
264 end
265 SpellAlertSCT_test();
266 elseif ( command == "style" ) then
267 if ( not params ) then
268 SpellAlertSCT_print(SASCT_OPT_STYLE_NOSTYLE);
269 else
270 if (params == "message") then
271 SpellAlertSCTDB[playerName].Style = "message";
272 SpellAlertSCT_print(SASCT_OPT_STYLE_MESSAGE);
273 elseif (params == "vertical") then
274 SpellAlertSCTDB[playerName].Style = "vertical";
275 SpellAlertSCT_print(SASCT_OPT_STYLE_VERTICAL);
276 elseif (params == "rainbow") then
277 SpellAlertSCTDB[playerName].Style = "rainbow";
278 SpellAlertSCT_print(SASCT_OPT_STYLE_RAINBOW);
279 elseif (params == "horizontal") then
280 SpellAlertSCTDB[playerName].Style = "horizontal";
281 SpellAlertSCT_print(SASCT_OPT_STYLE_HORIZONTAL);
282 elseif (params == "angled down") then
283 SpellAlertSCTDB[playerName].Style = "angled down";
284 SpellAlertSCT_print(SASCT_OPT_STYLE_ANGLEDDOWN);
285 else
286 SpellAlertSCT_print(SASCT_OPT_STYLE_CHOICES);
287 end
288 SpellAlertSCT_test();
289 end
290 elseif ( command == "targetonly" ) then
291 if ( not params ) then
292 if (SpellAlertSCTDB[playerName].TargetOnly == true) then
293 SpellAlertSCTDB[playerName].TargetOnly = false;
294 SpellAlertSCT_print(SASCT_OPT_TARGETONLY_OFF);
295 else
296 SpellAlertSCTDB[playerName].TargetOnly = true;
297 SpellAlertSCT_print(SASCT_OPT_TARGETONLY_ON);
298 end
299 else
300 if (params == "on") then
301 SpellAlertSCTDB[playerName].TargetOnly = true;
302 SpellAlertSCT_print(SASCT_OPT_TARGETONLY_ON);
303 else
304 SpellAlertSCTDB[playerName].TargetOnly = false;
305 SpellAlertSCT_print(SASCT_OPT_TARGETONLY_OFF);
306 end
307 end
308 elseif ( command == "emotes" ) then
309 if ( not params ) then
310 if (SpellAlertSCTDB[playerName].Emotes == true) then
311 SpellAlertSCTDB[playerName].Emotes = false;
312 SpellAlertSCT_print(SASCT_OPT_EMOTES_OFF);
313 else
314 SpellAlertSCTDB[playerName].Emotes = true;
315 SpellAlertSCT_print(SASCT_OPT_EMOTES_ON);
316 end
317 else
318 if (params == "on") then
319 SpellAlertSCTDB[playerName].Emotes = true;
320 SpellAlertSCT_print(SASCT_OPT_EMOTES_ON);
321 else
322 SpellAlertSCTDB[playerName].Emotes = false;
323 SpellAlertSCT_print(SASCT_OPT_EMOTES_OFF);
324 end
325 end
326 --[[ elseif ( command == "red" ) then
327 if ( not params ) then
328 SpellAlertSCT_print(SASCT_OPT_COLOR_COICES);
329 else
330 if ( tonumber(params) and tonumber(params) <= 1 and tonumber(params) >= 0) then
331 SpellAlertSCTDB[playerName].red = tonumber(params);
332 sasct_color.r = SpellAlertSCTDB[playerName].red;
333 SpellAlertSCT_print(SASCT_OPT_RED_SET..SpellAlertSCTDB[playerName].red..SASCT_OPT_RED_END);
334 SpellAlertSCT_test()
335 else
336 SpellAlertSCT_print(SASCT_OPT_COLOR_COICES);
337 end
338 end
339 elseif ( command == "green" ) then
340 if ( not params ) then
341 SpellAlertSCT_print(SASCT_OPT_COLOR_COICES);
342 else
343 if ( tonumber(params) and tonumber(params) <= 1 and tonumber(params) >= 0) then
344 SpellAlertSCTDB[playerName].green = tonumber(params);
345 sasct_color.g = SpellAlertSCTDB[playerName].green;
346 SpellAlertSCT_print(SASCT_OPT_GREEN_SET..SpellAlertSCTDB[playerName].green..SASCT_OPT_GREEN_END);
347 SpellAlertSCT_test()
348 else
349 SpellAlertSCT_print(SASCT_OPT_COLOR_COICES);
350 end
351 end
352 elseif ( command == "blue" ) then
353 if ( not params ) then
354 SpellAlertSCT_print(SASCT_OPT_COLOR_COICES);
355 else
356 if ( tonumber(params) and tonumber(params) <= 1 and tonumber(params) >= 0) then
357 SpellAlertSCTDB[playerName].blue = tonumber(params);
358 sasct_color.b = SpellAlertSCTDB[playerName].blue;
359 SpellAlertSCT_print(SASCT_OPT_BLUE_SET..SpellAlertSCTDB[playerName].blue..SASCT_OPT_BLUE_END);
360 SpellAlertSCT_test()
361 else
362 SpellAlertSCT_print(SASCT_OPT_COLOR_COICES);
363 end
364 end
365 ]] elseif ( command == "targetindicator" ) then
366 if ( not params ) then
367 SpellAlertSCTDB[playerName].TargetIndicator = "";
368 SpellAlertSCT_print(SASCT_OPT_TARGETINDICATOR_BLANK);
369 else
370 SpellAlertSCTDB[playerName].TargetIndicator = params;
371 SpellAlertSCT_print(SASCT_OPT_TARGETINDICATOR_SET..SpellAlertSCTDB[playerName].TargetIndicator);
372 end
373 elseif ( command == "retarget" ) then
374 if ( not params ) then
375 if (SpellAlertSCTDB[playerName].Retarget == true) then
376 SpellAlertSCTDB[playerName].Retarget = false;
377 SpellAlertSCT_print(SASCT_OPT_RETARGET_OFF);
378 else
379 SpellAlertSCTDB[playerName].Retarget = true;
380 SpellAlertSCT_print(SASCT_OPT_RETARGET_ON);
381 end
382 else
383 if (params == "on") then
384 SpellAlertSCTDB[playerName].Retarget = true;
385 SpellAlertSCT_print(SASCT_OPT_RETARGET_ON);
386 else
387 SpellAlertSCTDB[playerName].Retarget = false;
388 SpellAlertSCT_print(SASCT_OPT_RETARGET_OFF);
389 end
390 end
391 elseif ( command == "bosswarnings" ) then
392 if ( not params ) then
393 if (SpellAlertSCTDB[playerName].BossWarnings == true) then
394 SpellAlertSCTDB[playerName].BossWarnings = false;
395 SpellAlertSCT_print(SASCT_OPT_BOSSWARNINGS_OFF);
396 else
397 SpellAlertSCTDB[playerName].BossWarnings = true;
398 SpellAlertSCT_print(SASCT_OPT_BOSSWARNINGS_ON);
399 end
400 else
401 if (params == "on") then
402 SpellAlertSCTDB[playerName].BossWarnings = true;
403 SpellAlertSCT_print(SASCT_OPT_BOSSWARNINGS_ON);
404 else
405 SpellAlertSCTDB[playerName].BossWarnings = false;
406 SpellAlertSCT_print(SASCT_OPT_BOSSWARNINGS_OFF);
407 end
408 end
409 elseif ( command == "toggle" ) then
410 if ( not params ) then
411 if (SpellAlertSCTDB[playerName].Toggle == true) then
412 SpellAlertSCTDB[playerName].Toggle = false;
413 SpellAlertSCT_print(SASCT_OPT_TOGGLE_OFF);
414 else
415 SpellAlertSCTDB[playerName].Toggle = true;
416 SpellAlertSCT_print(SASCT_OPT_TOGGLE_ON);
417 end
418 else
419 if (params == "on") then
420 SpellAlertSCTDB[playerName].Toggle = true;
421 SpellAlertSCT_print(SASCT_OPT_TOGGLE_ON);
422 else
423 SpellAlertSCTDB[playerName].Toggle = false;
424 SpellAlertSCT_print(SASCT_OPT_TOGGLE_OFF);
425 end
426 end
427 elseif ( command == "color" ) then
428 if ( not params ) then
429 SpellAlertSCT_print(SASCT_OPT_COLOR_TYPES);
430 else
431 local whichtype;
432 whichtype, params = SpellAlertSCT_NextParameter(params);
433 if (not (whichtype == "default" or whichtype == "target" or whichtype == "warn" or whichtype == "emote")) then
434 SpellAlertSCT_print(SASCT_OPT_COLOR_TYPES);
435 SpellAlertSCT_print("You put: "..whichtype);
436 return;
437 end
438  
439 if ( not params ) then
440 SpellAlertSCT_print(SASCT_OPT_COLOR_COLORS);
441 else
442 local whichcolor;
443 whichcolor, params = SpellAlertSCT_NextParameter(params);
444 if ( tonumber(params) and tonumber(params) <= 1 and tonumber(params) >= 0) then
445 if (not (whichcolor == "red" or whichcolor == "green" or whichcolor == "blue")) then
446 SpellAlertSCT_print(SASCT_OPT_COLOR_COLORS);
447 return;
448 end
449  
450 SpellAlertSCTDB[playerName][whichtype.."color"][whichcolor] = tonumber(params);
451 SpellAlertSCT_print(whichtype.." "..whichcolor.." = "..SpellAlertSCTDB[playerName][whichtype.."color"][whichcolor]);
452 SpellAlertSCT_UpdateColors();
453 else
454 SpellAlertSCT_print(SASCT_OPT_COLOR_COICES);
455 end
456 end
457 end
458 elseif ( command == "compact" ) then
459 if ( not params ) then
460 if (SpellAlertSCTDB[playerName].Compact == true) then
461 SpellAlertSCTDB[playerName].Compact = false;
462 SpellAlertSCT_print(SASCT_OPT_COMPACT_OFF);
463 else
464 SpellAlertSCTDB[playerName].Compact = true;
465 SpellAlertSCT_print(SASCT_OPT_COMPACT_ON);
466 end
467 else
468 if (params == "on") then
469 SpellAlertSCTDB[playerName].Compact = true;
470 SpellAlertSCT_print(SASCT_OPT_COMPACT_ON);
471 else
472 SpellAlertSCTDB[playerName].Compact = false;
473 SpellAlertSCT_print(SASCT_OPT_COMPACT_OFF);
474 end
475 end
476 elseif ( command == "repeat" ) then
477 if ( not params ) then
478 SpellAlertSCT_print(SASCT_OPT_REPEAT_ERROR);
479 else
480 if ( tonumber(params)) then
481 SpellAlertSCTDB[playerName].MessageRepeatTime = tonumber(params);
482 SpellAlertSCT_print(SASCT_OPT_REPEAT_SET..SpellAlertSCTDB[playerName].MessageRepeatTime);
483 else
484 SpellAlertSCT_print(SASCT_OPT_REPEAT_ERROR);
485 end
486 end elseif ( command == "status" ) then
487 SpellAlertSCT_ShowStatus();
488 elseif ( command == "reset" ) then
489 SpellAlertSCT_ResetOptions();
490 SpellAlertSCT_print(SASCT_OPT_RESET);
491 SpellAlertSCT_test();
492 elseif ( command == "test" ) then
493 SpellAlertSCT_test();
494 elseif ( command == "resetmessagelist" ) then
495 listMessages = {};
496 elseif (command == "rl") then
497 ReloadUI();
498 else
499 SpellAlertSCT_ShowUsage();
500 end
501 end
502  
503 function SpellAlertSCT_ResetOptions()
504 SpellAlertSCTDB[playerName] = {
505 ["Crit"] = false,
506 ["Style"] = "vertical",
507 ["TargetOnly"] = false,
508 ["TargetIndicator"] = " *** ",
509 -- ["red"] = 1.0,
510 -- ["green"] = 1.0,
511 -- ["blue"] = 1.0,
512 ["Emotes"] = true,
513 ["Retarget"] = true,
514 ["BossWarnings"] = true,
515 ["Toggle"] = true,
516 ["Compact"] = false,
517 ["MessageRepeatTime"] = 2,
518  
519 ["defaultcolor"] = {
520 ["red"] = 1.0,
521 ["green"] = 1.0,
522 ["blue"] = 1.0,
523 },
524 ["targetcolor"] = {
525 ["red"] = 1.0,
526 ["green"] = 1.0,
527 ["blue"] = 1.0,
528 },
529 ["warncolor"] = {
530 ["red"] = 1.0,
531 ["green"] = 0.0,
532 ["blue"] = 1.0,
533 },
534 ["emotecolor"] = {
535 ["red"] = 1.0,
536 ["green"] = 0.0,
537 ["blue"] = 1.0,
538 },
539 };
540  
541 SpellAlertSCT_UpdateColors()
542 end
543  
544 function SpellAlertSCT_OnEvent()
545 local mob, spell;
546 if ( event == "VARIABLES_LOADED" ) then
547 this:RegisterEvent("RAID_ROSTER_UPDATE");
548 this:RegisterEvent("PARTY_MEMBERS_CHANGED");
549  
550 this:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE");
551 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS");
552 this:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF");
553 this:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE");
554 this:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF");
555 this:RegisterEvent("CHAT_MSG_MONSTER_EMOTE");
556 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE");
557 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS");
558 this:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_OTHER");
559  
560 this:RegisterEvent("PLAYER_LEAVE_COMBAT");
561  
562 if ( not SpellAlertSCTDB ) then
563 SpellAlertSCTDB = {};
564 SpellAlertSCT_print("first use!")
565 end
566  
567 if (GetLocale()=="koKR") then
568 playerName = GetCVar("realmName").." 서버의 "..UnitName("player");
569 else
570 playerName = UnitName("player").." of "..GetCVar("realmName");
571 end
572  
573 if ( not SpellAlertSCTDB[playerName] ) then
574 SpellAlertSCT_ResetOptions();
575 if (GetLocale()=="koKR") then
576 SpellAlertSCT_print(playerName.."님의 프로필이 생성되었습니다");
577 else
578 SpellAlertSCT_print("profile "..playerName.." created!");
579 end
580 else
581 if ( SpellAlertSCTDB[playerName].Style == nil ) then SpellAlertSCTDB[playerName].Style = "vertical"; end
582 if ( SpellAlertSCTDB[playerName].Crit == nil ) then SpellAlertSCTDB[playerName].Crit = false; end
583 if ( SpellAlertSCTDB[playerName].TargetOnly == nil ) then SpellAlertSCTDB[playerName].TargetOnly = false; end
584 if ( SpellAlertSCTDB[playerName].Emotes == nil ) then SpellAlertSCTDB[playerName].Emotes = true; end
585 if ( SpellAlertSCTDB[playerName].Retarget == nil ) then SpellAlertSCTDB[playerName].Retarget = true; end
586 if ( SpellAlertSCTDB[playerName].BossWarnings == nil ) then SpellAlertSCTDB[playerName].BossWarnings = true; end
587 if ( SpellAlertSCTDB[playerName].TargetIndicator == nil ) then SpellAlertSCTDB[playerName].TargetIndicator = " *** "; end
588 if ( SpellAlertSCTDB[playerName].Toggle == nil ) then SpellAlertSCTDB[playerName].Toggle = true; end
589 if ( SpellAlertSCTDB[playerName].Compact == nil ) then SpellAlertSCTDB[playerName].Compact = false; end
590 if ( SpellAlertSCTDB[playerName].MessageRepeatTime == nil ) then SpellAlertSCTDB[playerName].MessageRepeatTime = 2; end
591  
592  
593 if ( not SpellAlertSCTDB[playerName].defaultcolor) then
594 SpellAlertSCTDB[playerName].defaultcolor = {
595 ["red"] = 1.0,
596 ["green"] = 1.0,
597 ["blue"] = 1.0,
598 };
599 end
600 if ( not SpellAlertSCTDB[playerName].targetcolor) then
601 SpellAlertSCTDB[playerName].targetcolor = {
602 ["red"] = 1.0,
603 ["green"] = 1.0,
604 ["blue"] = 1.0,
605 };
606 end
607 if ( not SpellAlertSCTDB[playerName].warncolor) then
608 SpellAlertSCTDB[playerName].warncolor ={
609 ["red"] = 1.0,
610 ["green"] = 0.0,
611 ["blue"] = 1.0,
612 };
613 end
614 if ( not SpellAlertSCTDB[playerName].emotecolor) then
615 SpellAlertSCTDB[playerName].emotecolor ={
616 ["red"] = 0.70,
617 ["green"] = 0.70,
618 ["blue"] = 0.0,
619 };
620 end
621  
622 SpellAlertSCT_print(playerName..SASCT_PROFILELOADED);
623 end
624  
625 if ( SpellAlertSCTDB[playerName].red) then
626 SpellAlertSCTDB[playerName].defaultcolor.red = SpellAlertSCTDB[playerName].red;
627 SpellAlertSCTDB[playerName].red = nil;
628 end
629 if ( SpellAlertSCTDB[playerName].green) then
630 SpellAlertSCTDB[playerName].defaultcolor.green = SpellAlertSCTDB[playerName].green;
631 SpellAlertSCTDB[playerName].green = nil;
632 end
633 if ( SpellAlertSCTDB[playerName].blue) then
634 SpellAlertSCTDB[playerName].defaultcolor.blue = SpellAlertSCTDB[playerName].blue;
635 SpellAlertSCTDB[playerName].blue = nil;
636 end
637  
638 SpellAlertSCT_UpdateColors();
639  
640 local yellow = "|cffffff00"
641 local white = "|cffffffff"
642 SpellAlertSCT_print("SpellAlert SCT "..yellow..SpellAlertSCTVersion..white..SASCT_LOADPRINT);
643 elseif (event == "PARTY_MEMBERS_CHANGED") then
644 local num = GetNumPartyMembers();
645 if ((num ~= partyNum) and (GetNumRaidMembers() == 0)) then
646 partyNum = num;
647 SpellAlertSCT_BuildRaidList(false);
648 end
649  
650 elseif (event == "RAID_ROSTER_UPDATE") then
651 local num = GetNumRaidMembers();
652 if (num ~= raidNum) then
653 raidNum = num;
654 SpellAlertSCT_BuildRaidList(true);
655 end
656 elseif (event == "CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE") then
657 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_CAST) do
658 if (not SpellAlertSCT_isParty(mob)) then
659 SpellAlertSCT_alert(mob, spell, arg1, "cast");
660 end
661 return;
662 end
663 -- "(.+) begins to perform (.+)."
664 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_PERFORM) do
665 if (not SpellAlertSCT_isParty(mob)) then
666 SpellAlertSCT_alert(mob, spell, arg1, "cast");
667 end
668 return;
669 end
670 elseif (event == "CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF") then
671 for mob, spell, k in string.gfind(arg1, SA_PTN_SPELL_GAINS_X) do
672 return;
673 end
674 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_CAST) do
675 if (not SpellAlertSCT_isParty(mob)) then
676 SpellAlertSCT_alert(mob, spell, arg1, "cast");
677 end
678 return;
679 end
680 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_TOTEM) do
681 if (not SpellAlertSCT_isParty(mob)) then
682 SpellAlertSCT_alert(mob, spell, arg1, "cast");
683 end
684 return;
685 end
686 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_GAINS) do
687 SpellAlertSCT_alert(mob, spell, arg1, "cast");
688 return;
689 end
690 elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF") then
691 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_CAST) do
692 SpellAlertSCT_alert(mob, spell, arg1, "cast");
693 return;
694 end
695 elseif (event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS") then
696 for mob, spell, k in string.gfind(arg1, SA_PTN_SPELL_GAINS_X) do
697 return;
698 end
699 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_GAINS) do
700 SpellAlertSCT_alert(mob, spell, arg1, "gain");
701 return;
702 end
703 elseif (event == "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE") then
704 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_CAST) do
705 SpellAlertSCT_alert(mob, spell, arg1, "cast");
706 return;
707 end
708 -- "(.+) begins to perform (.+)."
709 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_BEGIN_PERFORM) do
710 SpellAlertSCT_alert(mob, spell, arg1, "cast");
711 return;
712 end
713 elseif (event == "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS") then
714 for mob, spell, temp in string.gfind(arg1, SA_PTN_SPELL_GAINS_X) do
715 return;
716 end
717 for mob, spell in string.gfind(arg1, SA_PTN_SPELL_GAINS) do
718 if ( (spell == SA_WOTF) or
719 (spell == SA_BERSERKER_RAGE) ) then
720 sa_gains[mob] = {};
721 sa_gains[mob].spell = spell;
722 sa_gains[mob].time = GetTime();
723 end
724 SpellAlertSCT_alert(mob, spell, arg1, "gain");
725 return;
726 end
727 elseif (event == "CHAT_MSG_SPELL_AURA_GONE_OTHER") then
728 for spell, mob in string.gfind(arg1, SA_PTN_SPELL_FADE) do
729 if ( (spell == SA_WOTF) or
730 (spell == SA_BERSERKER_RAGE) ) then
731 local tt = sa_gains[mob];
732 if (tt) then
733 if (tt.spell == spell) then
734 if (GetTime() - tt.time <= 30) then
735 SpellAlertSCT_alert(mob, spell, arg1, "?");
736 end
737 end
738 tt[mob] = nil;
739 return;
740 end
741 end
742 end
743 elseif (event == "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE") then
744 if ((arg1 == SA_AFFLICT_LIVINGBOMB) and (SpellAlertSCTDB[playerName].BossWarnings)) then
745 SpellAlertSCT_warn(arg1);
746 end
747 elseif (event == "CHAT_MSG_EMOTE") then
748 if (arg1) then
749 if (SpellAlertSCTDB[playerName].Emotes) then
750 SpellAlertSCT_alert("", "", arg1, "emote");
751 end
752 end
753 elseif (event == "CHAT_MSG_MONSTER_EMOTE") then
754 local name = arg2;
755 if (not name) then
756 name = "nil";
757 end
758 if (arg1) then
759 -- Onyxia Deep Breath and emotes
760 if (SpellAlertSCTDB[playerName].BossWarnings and (name == SASCT_ONY) and (arg1 == SA_EMOTE_DEEPBREATH) ) then
761 SpellAlertSCT_warn(name .. SASCT_EMOTESPACE .. arg1);
762 elseif (SpellAlertSCTDB[playerName].Emotes) then
763 SpellAlertSCT_alert(name, arg1, name .. SASCT_EMOTESPACE .. arg1, "emote");
764 end
765 end
766 elseif (event == "PLAYER_LEAVE_COMBAT") then
767 --listMessages = {};
768 end
769 end
770  
771 function SpellAlertSCT_OnLoad()
772 if ( not SCT_OnLoad ) then
773 SpellAlertSCT_print(SASCT_NOSCT);
774 return;
775 end
776  
777 this:RegisterEvent("VARIABLES_LOADED");
778  
779 SlashCmdList["SpellAlertSCTCOMMAND"] = SpellAlertSCT_SlashHandler;
780 SLASH_SpellAlertSCTCOMMAND1 = "/sasct";
781 SLASH_SpellAlertSCTCOMMAND2 = "/ss";
782 end
783  
784  
785 function SpellAlertSCT_print(msg)
786 if (DEFAULT_CHAT_FRAME) then
787 DEFAULT_CHAT_FRAME:AddMessage("|cff68ccefSpellAlertSCT:|cffffffff "..msg);
788 end
789 end
790  
791 function SpellAlertSCT_debug(msg)
792 if (SpellAlertDEBUG) then
793 SpellAlertSCT_print(msg);
794 end
795 end
796  
797  
798 function SpellAlertSCT_warn(msg)
799 -- Trying to rely only on SCT
800 -- WarningFrame:AddMessage(msg, sasct_color.r, sasct_color.g, sasct_color.b, 1, 5);
801 if (SpellAlertSCTDB[playerName].Toggle == false) then
802 return;
803 end
804  
805 msg = SpellAlertSCTDB[playerName].TargetIndicator..msg..SpellAlertSCTDB[playerName].TargetIndicator;
806 SCT_Display_Message(msg, sasct_warncolor);
807 end
808  
809 function SpellAlertSCT_isParty(name)
810 --[[ for i = 1, 4, 1 do
811 local partyname = UnitName("party" .. i);
812 if (name == partyname) then
813 return 1;
814 end
815 end
816 return nil;]]
817 return raidList[name];
818 end
819  
820 function SpellAlertSCT_retarget(spell)
821 if (SpellAlertSCTDB[playerName].Retarget == false) then
822 return;
823 end
824 if (not UnitName("target")) then
825 if (sa_targetName) then
826 if (sa_targetHostile) then
827 SpellAlertSCT_print(SASCT_RETARGET_1..spell..SASCT_RETARGET_2..sa_targetName);
828 TargetLastEnemy();
829 else
830 SpellAlertSCT_print(SASCT_RETARGET_1..spell..SASCT_RETARGET_2..sa_targetName);
831 TargetByName(sa_targetName);
832 end
833 end
834 end
835 end
836  
837 function SpellAlertSCT_OnUpdate()
838 local targetName = UnitName("target");
839 if (targetName) then
840 sa_targetClass = UnitClass("target");
841 sa_targetHostile = UnitIsEnemy("player", "target");
842 else
843 if (SpellAlertSCTDB[playerName].Retarget == true and sa_targetName and (sa_targetClass == SASCT_HUNTER) and sa_targetHostile ) then
844 TargetLastTarget();
845 if( UnitHealth("target") == 0 and UnitCanAttack("player", "target") ) then
846 ClearTarget();
847 SpellAlertSCT_retarget(SASCT_FEIGNDEATH);
848 else
849 ClearTarget();
850 end
851 end
852 end
853 sa_targetName = targetName;
854 end
855  
856 function SpellAlertSCT_NextParameter(msg)
857 local params = nil;
858 local command = nil;
859 local index = strfind(msg, " ");
860  
861 if ( index ) then
862 command = strsub(msg, 1, index - 1);
863 params = strsub(msg, index + 1);
864 else
865 command = msg;
866 end
867 return command, params;
868 end
869  
870 function SpellAlertSCT_UpdateColors()
871 sasct_color.r = SpellAlertSCTDB[playerName].defaultcolor.red;
872 sasct_color.g = SpellAlertSCTDB[playerName].defaultcolor.green;
873 sasct_color.b = SpellAlertSCTDB[playerName].defaultcolor.blue;
874  
875 sasct_targetcolor.r = SpellAlertSCTDB[playerName].targetcolor.red;
876 sasct_targetcolor.g = SpellAlertSCTDB[playerName].targetcolor.green;
877 sasct_targetcolor.b = SpellAlertSCTDB[playerName].targetcolor.blue;
878  
879 sasct_warncolor.r = SpellAlertSCTDB[playerName].warncolor.red;
880 sasct_warncolor.g = SpellAlertSCTDB[playerName].warncolor.green;
881 sasct_warncolor.b = SpellAlertSCTDB[playerName].warncolor.blue;
882  
883 sasct_emotecolor.r = SpellAlertSCTDB[playerName].emotecolor.red;
884 sasct_emotecolor.g = SpellAlertSCTDB[playerName].emotecolor.green;
885 sasct_emotecolor.b = SpellAlertSCTDB[playerName].emotecolor.blue;
886 end
887  
888 function SpellAlertSCT_BuildRaidList(isRaid)
889 raidList = { };
890 local max, g, name;
891 if (isRaid) then
892 max = 40;
893 g = "raid";
894 else
895 max = 4;
896 g = "party";
897 end
898 for i = 1, max do
899 name = UnitName(g..i);
900 if (name) then
901 raidList[name] = true;
902 end
903 name = UnitName(g.."pet"..i);
904 if (name) then
905 raidList[name] = true;
906 end
907 end
908 end
909  
910 function SpellAlertSCT_test()
911 SpellAlertSCT_alert("Player", "test", playerName..SASCT_ADDONTEST);
912 end