vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2  
3 Natur EnemyCastBar
4  
5 Revision History:
6 -----------------
7 .
8 . Deleted the original History to achive some less scrolling! Sorry Limited ;-)
9 . This mod was mainly coded by "Limited" - I (Naturfreund) added all codes after Limited's version Carnical Enemy Cast Bar 1.5c
10 .
11  
12 =================================
13 Read Changelog.txt for more info!
14 =================================
15 ]]--
16  
17 CECB_status_version_txt = "4.4.0";
18  
19 menuesizex = 500;
20 mshrinksizex = 260;
21 menuesizey = 480;
22 mshrinksizey = 140;
23  
24 carniactive = true;
25 mobname = "Mob";
26 mob = "Mob";
27 spell = "Cast Bar";
28  
29 function CEnemyCastBar_DefaultVars()
30  
31 CEnemyCastBar = { };
32 CEnemyCastBar.bStatus = true;
33 CEnemyCastBar.bPvP = true;
34 CEnemyCastBar.bPvE = true;
35 CEnemyCastBar.bLocked = true;
36 CEnemyCastBar.bTimer = true;
37 CEnemyCastBar.bScale = 1;
38 CEnemyCastBar.bAlpha = 1;
39 CEnemyCastBar.bShowafflict = true;
40 CEnemyCastBar.bTargetM = true;
41 CEnemyCastBar.bCDown = false;
42 CEnemyCastBar.bAfflictuni = false;
43 CEnemyCastBar.bNumBars = 15;
44 -- new variables for new versions (check onload variables!)
45 CEnemyCastBar.bParseC = true;
46 CEnemyCastBar.bGains = true;
47 CEnemyCastBar.bFlipB = false;
48 CEnemyCastBar.bSmallTSize = false;
49 CEnemyCastBar.bFlashit = true;
50 CEnemyCastBar.bGlobalFrag = true;
51 CEnemyCastBar.bCDownShort = false;
52 CEnemyCastBar.bCT_RA_chan = CECB_menue_CTRAnoBC;
53 CEnemyCastBar.bBCaster = false;
54 CEnemyCastBar.bSoloD = false;
55 CEnemyCastBar.bSpace = 20;
56 CEnemyCastBar.bDRTimer = false;
57 CEnemyCastBar.bMageC = false;
58 CEnemyCastBar.bMiniMap = 356;
59 CEnemyCastBar.bClassDR = false;
60 CEnemyCastBar.bShowIcon = true;
61 CEnemyCastBar.bSDoTs = false;
62 CEnemyCastBar.tDisabledSpells = { };
63  
64 end
65  
66 function CEnemyCastBar_RegisterEvents(unregister)
67  
68 local eventpacket = { "CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE", "CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF", "CHAT_MSG_SPELL_FRIENDLYPLAYER_DAMAGE",
69 "CHAT_MSG_SPELL_FRIENDLYPLAYER_BUFF", "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS", "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_BUFFS",
70 "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE", "CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE", "CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE",
71 "CHAT_MSG_SPELL_PARTY_DAMAGE", "CHAT_MSG_SPELL_PARTY_BUFF", "CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE",
72 "CHAT_MSG_SPELL_PERIODIC_PARTY_BUFFS", "CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE", "CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS",
73 "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE", "CHAT_MSG_SPELL_CREATURE_VS_CREATURE_BUFF",
74 "CHAT_MSG_SPELL_BREAK_AURA", "CHAT_MSG_SPELL_AURA_GONE_OTHER", "CHAT_MSG_SPELL_AURA_GONE_SELF",
75 "CHAT_MSG_MONSTER_YELL", "CHAT_MSG_MONSTER_EMOTE",
76 "CHAT_MSG_RAID", "CHAT_MSG_PARTY", "CHAT_MSG_CHANNEL", "CHAT_MSG_CHANNEL_NOTICE",
77 "CHAT_MSG_COMBAT_HOSTILE_DEATH", "CHAT_MSG_COMBAT_FRIENDLY_DEATH", "CHAT_MSG_COMBAT_XP_GAIN",
78 "PLAYER_REGEN_DISABLED", "CHAT_MSG_SPELL_SELF_DAMAGE", "PLAYER_COMBO_POINTS"};
79 -- "CHAT_MSG_SPELL_SELF_BUFF", "CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS", "CHAT_MSG_COMBAT_SELF_HITS" -- for testing only
80  
81 local i = 1;
82  
83 while (eventpacket[i]) do
84  
85 if (unregister) then
86 this:UnregisterEvent(eventpacket[i]);
87 else
88 this:RegisterEvent(eventpacket[i]);
89 end
90  
91 i = i + 1;
92 end
93  
94 if (CEnemyCastBar.bStatus and CEnemyCastBar.bDebug) then
95 i = i - 1;
96 if (unregister) then
97 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Debug, |cffff0000"..i.." GameEvents UNRegistered!");
98 else
99 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Debug, |cff00ff00"..i.." GameEvents Registered!");
100 end
101 end
102  
103 -- unregister ComboPoint detection for all but rogues
104 local _, playersclass = UnitClass("player");
105 if (playersclass ~= "ROGUE") then
106 this:UnregisterEvent("PLAYER_COMBO_POINTS");
107 end
108 end
109  
110 function CEnemyCastBar_OnLoad()
111  
112 this:RegisterEvent("PLAYER_LEAVING_WORLD");
113 this:RegisterEvent("PLAYER_ENTERING_WORLD");
114 this:RegisterEvent("VARIABLES_LOADED");
115  
116 SLASH_CARNIVALENEMYCASTBAR1 = "/necb";
117 SlashCmdList["CARNIVALENEMYCASTBAR"] = function(msg)
118 CEnemyCastBar_Handler(msg);
119 end
120  
121 for i=1, 20 do
122  
123 local button = getglobal("Carni_ECB_"..i);
124 local fauxbutton = getglobal("FauxTargetBtn"..i);
125 button:Hide();
126 fauxbutton:Hide();
127  
128 end
129  
130 if ( not CEnemyCastBar ) then
131  
132 CEnemyCastBar_DefaultVars();
133  
134 for i=1, 20 do
135  
136 local frame = getglobal("Carni_ECB_"..i);
137 frame:StopMovingOrSizing();
138 frame:EnableMouse(0);
139  
140 end
141  
142 end
143  
144 end
145  
146 function CEnemyCastBar_OnEvent(event) --onevent
147  
148 if (event == "PLAYER_COMBO_POINTS") then
149  
150 if(CECBownCPsLast and GetComboPoints() < CECBownCPsLast) then
151  
152 CECBownCPsHit = CECBownCPsLast;
153 CECBownCPsHitTime = GetTime();
154  
155 -- check if there was a finishing move right before you lost all CPs (the server might create a difference up to 500ms between those two events!)
156 --CECBownCPsHitBuffer = {mob, spell, GetTime(), DRTimer }; -- just to understand what 1,2,3,4 stands for; defined in 'control' function (affliction)^
157 if (CECBownCPsHitBuffer and (CECBownCPsHitTime - CECBownCPsHitBuffer[3]) < 1) then
158  
159 local CPSpell = CECBownCPsHitBuffer[2];
160 castime = CEnemyCastBar_Afflictions[CPSpell].t - (CEnemyCastBar_Afflictions[CPSpell].cpinterval * (5 - CECBownCPsHit));
161  
162 local CPDRTimer = CECBownCPsHitBuffer[4];
163 if (CPDRTimer == 4 or CPDRTimer == 6) then
164 castime = castime / (CPDRTimer - 2);
165 end
166  
167 CEnemyCastBar_UniqueCheck(CPSpell, castime - (CECBownCPsHitTime - CECBownCPsHitBuffer[3]), CECBownCPsHitBuffer[1], "trueupdate"); --update bar duration
168 CECBownCPsHitTime = nil; -- spell already updated no need to wait 3 secs for new afflictions
169 end
170 end
171 CECBownCPsLast = GetComboPoints();
172 CECBownCPsHitBuffer = nil;
173  
174 elseif (event == "CHAT_MSG_MONSTER_YELL") then
175  
176 CEnemyCastBar_Yells(arg1, arg2);
177  
178 elseif (event == "CHAT_MSG_MONSTER_EMOTE") then
179  
180 CEnemyCastBar_Emotes(arg1, arg2);
181  
182 elseif (event == "PLAYER_LEAVING_WORLD" and CEnemyCastBar.bStatus) then
183  
184 CEnemyCastBar_RegisterEvents("unregister");
185  
186 elseif (event == "PLAYER_ENTERING_WORLD" and CEnemyCastBar.bStatus) then
187  
188 CEnemyCastBar_RegisterEvents();
189 if ( not necbdisabledyell and CEnemyCastBar.tDisabledSpells and table.getn(CEnemyCastBar.tDisabledSpells) > 0 ) then
190 CEnemyCastBar_Handler("disabled");
191 necbdisabledyell = true;
192 end
193  
194 elseif (event == "PLAYER_REGEN_DISABLED") then
195  
196 CEnemyCastBar_Player_Enter_Combat();
197  
198 elseif (event == "CHAT_MSG_RAID") then
199  
200 CEnemyCastBar_Parse_RaidChat(arg1, arg2, "Raid");
201  
202 elseif (event == "CHAT_MSG_PARTY") then
203  
204 CEnemyCastBar_Parse_RaidChat(arg1, arg2, "Party");
205  
206 elseif (event == "CHAT_MSG_CHANNEL") then --channelparser
207 --CEnemyCastBar_Gfind(arg1); --!
208 if (arg9 == CEnemyCastBar.bCT_RA_chan and type(arg1) == "string") then
209  
210 -- converter for 'drunken protection'
211 local msg = string.gsub(arg1, "%$", "s");
212 msg = string.gsub(msg, "§", "S");
213  
214 if ( strsub(msg, strlen(msg)-7) == " ...hic!") then
215 msg = strsub(msg, 1, strlen(msg)-8);
216 end
217 -- converter finished
218  
219 -- cecb network infos + calls the parse function: CEnemyCastBar_Parse_RaidChat(arg1, arg2, "CT_RA");
220 if (CEnemyCastBar_Parse_RaidChat(msg, arg2, "CT_RA")) then
221  
222 if ( ParserCollect[100] ) then
223 table.remove (ParserCollect, 1);
224 end
225  
226 local startpos;
227 if (string.sub (msg, 1, 11) == ".cecbspell ") then
228 startpos = 12;
229 if (numspellcast == 99) then
230 numspellcast = 0;
231 numsender = " (|cffffffffS|cffffaaaa):";
232 elseif (wrongclient) then
233 numsender = " (|cffccccccC|cffffaaaa):";
234 elseif (numspellcast > 0 and arg2 ~= UnitName("player")) then
235 numsender = " (|cffffff00"..numspellcast.."|cffffaaaa):";
236 else
237 numsender = ":";
238 end
239  
240 elseif (string.sub (msg, 1, 7) == "<CECB> ") then
241 startpos = 8;
242 numsender = ":";
243  
244 else
245 startpos = 1;
246 numsender = ":";
247 end
248  
249 -- reduce length of line
250 local i, cropped = 0, "";
251 CECBParserFauxText:SetText("|cffffaaaa"..arg2..numsender.." |cffcccccc"..string.sub (msg, startpos, string.len (msg)));
252 while (CECBParserFauxText:GetStringWidth() > 410) do
253 i = i + 1;
254 CECBParserFauxText:SetText("|cffffaaaa"..arg2..numsender.." |cffcccccc"..string.sub (msg, startpos, string.len (msg) -i));
255 end
256  
257 if (i ~= 0) then
258 cropped = "|cffffaaaa...";
259 else
260 cropped = "";
261 end
262  
263 table.insert (ParserCollect, "|cffffaaaa"..arg2..numsender.." |cffcccccc"..string.sub (msg, startpos, string.len (msg) -i)..cropped);
264  
265 if (CECBParser) then
266 if (parserline == 0) then
267 CEnemyCastBar_ParserOnClick();
268 else
269 CECBCTRAParserFrameBOTTOMArrowFlash:Show();
270 CEnemyCastBar_ParserOnClick("up");
271 end
272 end
273  
274 end
275 end
276  
277 elseif (event == "CHAT_MSG_CHANNEL_NOTICE") then
278  
279 if (arg1 == "YOU_LEFT" and arg9 == CEnemyCastBar.bCT_RA_chan) then
280 CEnemyCastBar.bCT_RA_chan = CECB_menue_CTRAnoBC;
281 if (CECBOptionsFrame:IsVisible()) then
282 CECB_ReloadOptionsUI();
283 end
284 end
285  
286  
287 elseif ( event == "VARIABLES_LOADED" ) then
288  
289 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Natur EnemyCastBar |cffcccc00("..CECB_status_version_txt..")|cffffff00:|cffffffff AddOn loaded. Use |cff00ff00/necb|cffffffff to configure.");
290  
291 if ( not MobTargetName ) then
292 MobTargetName = { };
293 end
294  
295 if ( not VersionDB ) then
296 VersionDB = { };
297 VersionNames = { };
298 end
299  
300 if ( not ParserCollect ) then
301 ParserCollect = { };
302 end
303  
304 DisabledSpells = { };
305  
306 -- new variables for new versions
307 if (CEnemyCastBar.bParseC == nil) then
308 CEnemyCastBar.bParseC = true;
309 end
310 if (CEnemyCastBar.bGains == nil) then
311 CEnemyCastBar.bGains = true;
312 end
313 if (CEnemyCastBar.bFlashit == nil) then
314 CEnemyCastBar.bFlashit = true;
315 end
316 if (CEnemyCastBar.bGlobalFrag == nil) then
317 CEnemyCastBar.bGlobalFrag = true;
318 end
319 if (CEnemyCastBar.bCT_RA_chan == nil) then
320 CEnemyCastBar.bCT_RA_chan = CECB_menue_CTRAnoBC;
321 end
322 if (CEnemyCastBar.bSpace == nil) then
323 CEnemyCastBar.bSpace = 20;
324 end
325 if (CEnemyCastBar.bMiniMap == nil) then
326 CEnemyCastBar.bMiniMap = 360;
327 end
328 if (CEnemyCastBar.bShowIcon == nil) then
329 CEnemyCastBar.bShowIcon = true;
330 end
331  
332 if ( CEnemyCastBar.tDisabledSpells and table.getn(CEnemyCastBar.tDisabledSpells) > 0 ) then
333 CEnemyCastBar_LoadDisabledSpells("mute");
334 else
335 CEnemyCastBar.tDisabledSpells = { };
336 end
337  
338 CECBOptionsFrame:SetHeight(menuesizey); -- set optionframe size, not needed atm
339 CECBOptionsFrame:SetWidth(menuesizex);
340  
341 CEnemyCastBar.bLocked = true; -- remove if lock-option is inserted again
342 CEnemyCastBar.bDebug = false; -- same here
343 CEnemyCastBar_FlipBars();
344 CEnemyCastBar_SetTextSize();
345 CECBownCPsHit = 5; -- Set Combopoints to max for all classes, RogueClass will fire an event to change this dynamically
346  
347 -- setpos of Minimap button
348 if (CEnemyCastBar.bMiniMap == 0) then
349 CECBMiniMapButton:Hide();
350 else
351 CECBMiniMapButton:SetPoint("TOPLEFT", "Minimap", "TOPLEFT", 52 - (80 * cos(CEnemyCastBar.bMiniMap)), (80 * sin(CEnemyCastBar.bMiniMap)) - 52);
352 CECBMiniMapButton:Show();
353 end
354  
355 -- variables for the ctra channel parser
356 numspellcast = 0; parserline = 0;
357 for i=1, 86 do
358 table.insert (ParserCollect, "|cffcccccc- |cff666666"..i.."|cffcccccc -");
359 end
360 table.insert (ParserCollect, " ");
361 table.insert (ParserCollect, "|r==================================");
362 table.insert (ParserCollect, "|cffffff00Welcome to the NECB CTRA Channel Parser!");
363 table.insert (ParserCollect, "This parser displays all NECB commands/broadcasts received by your client.");
364 table.insert (ParserCollect, " ");
365 table.insert (ParserCollect, "It follows this pattern:");
366 table.insert (ParserCollect, "|cffffaaaaBroadcaster: |cffccccccDetected CTRA Message [, ClientLanguage, Latency]|cffffff00");
367 table.insert (ParserCollect, "|cffffaaaa(|cffffffffS|cffffaaaa)|cffffff00 = Sender who triggered a castbar for you. |cffffaaaa(|cffccccccC|cffffaaaa)|cffffff00 = Wrong client!");
368 table.insert (ParserCollect, "|cffffaaaa(|cffffff00n|cffffaaaa)|cffffff00 = n useless broadcasts of this spell event.|cffffff00");
369 table.insert (ParserCollect, " ");
370 table.insert (ParserCollect, "100 lines are buffered. Use up/down at topright to scroll the lines.");
371 table.insert (ParserCollect, "I tried to make it work like the default chatframe :D");
372 table.insert (ParserCollect, "|r==================================");
373 table.insert (ParserCollect, " ");
374 -- ctra parser finished
375  
376 -- set frames to be hidden if addon disabled
377 OptionFrameNames = { CECBOptionsFrameCECB_pvp_check, CECBOptionsFrameCECB_cdown_check, CECBOptionsFrameCECB_cdownshort_check,
378 CECBOptionsFrameCECB_gains_check, CECBOptionsFrameCECB_pve_check, CECBOptionsFrameCECB_afflict_check,
379 CECBOptionsFrameCECB_globalfrag_check, CECBOptionsFrameCECB_magecold_check, CECBOptionsFrameCECB_solod_check,
380 CECBOptionsFrameCECB_drtimer_check, CECBOptionsFrameCECB_classdr_check, CECBOptionsFrameCECB_sdots_check,
381 CECBOptionsFrameCECB_affuni_check,
382 CECBOptionsFrameCECB_timer_check, CECBOptionsFrameCECB_targetM_check, CECBOptionsFrameCECB_parseC_check,
383 CECBOptionsFrameCECB_broadcast_check, CECBOptionsFrameBGFrameNet, CECBOptionsFrameCTRAChan,
384 CECBOptionsFrameCECB_flipb_check, CECBOptionsFrameCECB_tsize_check, CECBOptionsFrameCECB_flashit_check,
385 CECBOptionsFrameCECB_showicon_check,
386 CECBOptionsFrameCECB_scale_Slider, CECBOptionsFrameCECB_alpha_Slider, CECBOptionsFrameCECB_numbars_Slider,
387 CECBOptionsFrameCECB_space_Slider, CECBOptionsFrameCECB_MiniMap_Slider,
388 CECBOptionsFrameBGFrame2, CECBOptionsFrameBGFrame3,
389 CECBOptionsFrameMoveBar, CECBOptionsFrameBGFrameFPSBar, CECBOptionsFrameBGFrameFPSBar_check };
390  
391 else
392  
393 CEnemyCastBar_Gfind(arg1, event);
394  
395 end
396  
397 end
398  
399 function CEnemyCastBar_ParserOnClick(msg)
400  
401 if (msg) then
402 if ((msg == "down" or msg == -1) and parserline < 0) then
403 parserline = parserline + 1;
404  
405 elseif ((msg == "up" or msg == 1) and parserline > -80) then
406 parserline = parserline - 1;
407  
408 elseif (msg == 0) then
409 parserline = 0;
410 CECBCTRAParserFrameUPArrow:Enable();
411 end
412  
413 if (parserline == -80) then
414 CECBCTRAParserFrameUPArrow:Disable();
415 elseif (parserline == 0) then
416 CECBCTRAParserFrameDOWNArrow:Disable();
417 CECBCTRAParserFrameBOTTOMArrow:Disable();
418 CECBCTRAParserFrameBOTTOMArrowFlash:Hide();
419 else
420 CECBCTRAParserFrameUPArrow:Enable();
421 CECBCTRAParserFrameDOWNArrow:Enable();
422 CECBCTRAParserFrameBOTTOMArrow:Enable();
423 end
424 end
425  
426 CECBCTRAParserFrameLineText:SetText(parserline);
427 local parserstring = table.concat (ParserCollect, "\n", 81 + parserline, 100 + parserline);
428 CECBCTRAParserFrameBGText:SetText(parserstring);
429  
430 end
431  
432 function CEnemyCastBar_ParserButton_OnUpdate(elapsed)
433 if (this:GetButtonState() == "PUSHED") then
434 this.clickDelay = this.clickDelay - elapsed;
435 if ( this.clickDelay < 0 ) then
436 local name = this:GetName();
437 if ( name == this:GetParent():GetName().."DOWNArrow" ) then
438 CEnemyCastBar_ParserOnClick("down");
439 elseif ( name == this:GetParent():GetName().."UPArrow" ) then
440 CEnemyCastBar_ParserOnClick("up");
441 end
442 this.clickDelay = MESSAGE_SCROLLBUTTON_SCROLL_DELAY;
443 end
444 end
445 end
446  
447 function CEnemyCastBar_TargetPlayer(txt)
448  
449 if (CEnemyCastBar.bTargetM == true) then
450  
451 TargetByName(MobTargetName[tonumber(txt)]);
452 --DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Targetting \""..MobTargetName[tonumber(txt)].."\"");
453  
454 end
455  
456 end
457  
458 function CEnemyCastBar_HideBar(num, shiftright) --hide
459  
460 local button = getglobal("Carni_ECB_"..num);
461 local fauxbutton = getglobal("FauxTargetBtn"..num);
462  
463 if (shiftright) then
464 local spell = button.spell;
465 local disabled = false;
466  
467 if (spell ~= "Stun DR" and not string.find(spell, "DR:") ) then
468  
469 if (CEnemyCastBar_Raids[spell]) then
470 CEnemyCastBar_Raids[spell].disabled = true;
471 disabled = true;
472 end
473  
474 if (CEnemyCastBar_Spells[spell]) then
475 CEnemyCastBar_Spells[spell].disabled = true;
476 disabled = true;
477 end
478  
479 if (CEnemyCastBar_Afflictions[spell]) then
480 CEnemyCastBar_Afflictions[spell].disabled = true;
481 disabled = true;
482 end
483 end
484  
485 if (disabled) then
486 table.insert (DisabledSpells, spell);
487 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Disabled \"|cffffff00"..spell.."|r\" (|cffffff00"..table.getn (DisabledSpells).."|r total) for this session.");
488 else
489 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|cffffaaaa Spell not found! |rMaybe it was a CD/DR of some spell?");
490 end
491  
492 end
493  
494 fauxbutton:Hide();
495 button:Hide();
496 --DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Deleted \""..button.label.."\"");
497 button.spell = nil;
498 button.label = nil;
499 MobTargetName[num] = "";
500 mobname = "";
501  
502 end
503  
504 function CEnemyCastBar_LockPos() --lockpos
505  
506 CEnemyCastBar.bLocked = not CEnemyCastBar.bLocked;
507  
508 if (CEnemyCastBar.bLocked) then
509  
510 for i=1, 20 do
511  
512 local frame = getglobal("Carni_ECB_"..i);
513 local fauxframe = getglobal("FauxTargetBtn"..i);
514 frame:StopMovingOrSizing();
515 frame:EnableMouse(0);
516 fauxframe:EnableMouse(1);
517  
518 end
519  
520 else
521  
522 for i=1, 20 do
523  
524 local frame = getglobal("Carni_ECB_"..i);
525 local fauxframe = getglobal("FauxTargetBtn"..i);
526 frame:EnableMouse(1);
527 fauxframe:EnableMouse(0);
528  
529 end
530  
531 end
532  
533 end
534  
535 function CEnemyCastBar_ResetPos() --resetpos
536  
537 local frame = getglobal("Carni_ECB_1");
538 local fauxframe = getglobal("FauxTargetBtn1");
539 frame:Hide();
540 fauxframe:Hide();
541 frame:ClearAllPoints();
542 frame:SetPoint("TOPLEFT", "UIParent", 50, -500);
543  
544 CEnemyCastBar_FlipBars();
545 end
546  
547 function CEnemyCastBar_FlipBars() --flipbars; sets the SPACE and ICONSIZE, too!
548  
549 for i=2, 21 do
550  
551 local o = i - 1;
552 if (i <= 20) then
553 local frame = getglobal("Carni_ECB_"..i);
554 local fauxframe = getglobal("FauxTargetBtn"..i);
555  
556 if (CEnemyCastBar.bFlipB) then
557 frame:SetPoint("TOPLEFT", "Carni_ECB_"..o, "TOPLEFT", 0, -CEnemyCastBar.bSpace);
558 else
559 frame:SetPoint("TOPLEFT", "Carni_ECB_"..o, "TOPLEFT", 0, CEnemyCastBar.bSpace);
560 end
561 end
562 local buttonicon = getglobal("Carni_ECB_"..o.."_Icon");
563 buttonicon:SetHeight(CEnemyCastBar.bSpace);
564 buttonicon:SetWidth(CEnemyCastBar.bSpace);
565 buttonicon:SetPoint("LEFT", "Carni_ECB_"..o, "LEFT", -CEnemyCastBar.bSpace + 4, 5);
566  
567 end
568  
569 end
570  
571 function CEnemyCastBar_SetTextSize() --settextsize and ICONSIZE
572  
573 for i=1, 20 do
574  
575 local buttontext = getglobal("Carni_ECB_"..i.."_Text");
576 local buttonttext = getglobal("Carni_ECB_"..i.."_CastTimeText");
577  
578 if (CEnemyCastBar.bSmallTSize) then
579 buttontext:SetFontObject(GameFontHighlightSmall);
580 buttonttext:SetFontObject(GameFontHighlightSmall);
581 else
582 buttontext:SetFontObject(GameFontHighlight);
583 buttonttext:SetFontObject(GameFontHighlight);
584 end
585 end
586 end
587  
588 function CEnemyCastBar_Boolean(var)
589  
590 if (var) then
591  
592 return "on";
593  
594 else
595  
596 return "off";
597  
598 end
599  
600 end
601  
602 function CEnemyCastBar_Handler(msg) --Handler
603 if (msg == "help") then
604  
605 DEFAULT_CHAT_FRAME:AddMessage(" ")
606 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Natur EnemyCastBar |cffcccc00("..CECB_status_version_txt..")|cffffff00:|cffff0000 /necb help")
607 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb |cffffffff- Toggles the options window.")
608 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb clear |cffffffff- Removes all castbars from screen")
609 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb gcinfo |cffffffffDisplay memory usage of all addons")
610 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb countsec sss label |cffffffff- Starts a countdown of sss seconds")
611 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb countmin mmm label |cffffffff- Starts a countdown of mmm minutes")
612 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb repeat sss label |cffffffff- Repeated countdown of sss seconds")
613 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb stopcount label |cffffffff- Stops all grey CastBars which inherit 'label'")
614 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cffffffffYou may also try |cff00ff00.countsec|cffffffff (s. Options -> Raid/PartyChat!)")
615 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb versions |cffffffff- Displays RaidUsers NECB versions.")
616 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb parser |cffffffff- Opens the NECB - CTRA Channel parser.")
617 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00SHIFT + LeftClick |cffffffffdeletes the bar, |cff00ff00ALT + click |cffffffffdeletes all bars")
618 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00SHIFT + RightClick |cffffffffdisables the spell for the rest of your session!")
619 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb disabled |cfffffffflists disabled spells, |cff00ff00/necb restore |cffffffffrestores spells!")
620 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb load |cffffffffloads disabled spells, |cff00ff00/necb save |cffffffffsaves disabled spells!")
621 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |cff00ff00/necb remove xyz |cffffffff removes xyz from the list of disabled spells!")
622  
623 elseif (msg == "" or msg == nil) then
624  
625 if (CECBOptionsFrame:IsVisible()) then
626 fademenue = 1;
627 else
628 fademenue = 2;
629 CECBOptionsFrame:SetAlpha(0);
630 CECB_ShowHideOptionsUI();
631 end
632  
633 elseif (msg == "gcinfo") then
634  
635 if (CECBGCFrame:IsVisible()) then
636 CECBGCFrame:Hide();
637 cecbgc_last = nil;
638 else
639 CECBGCFrame:Show();
640 end
641  
642 elseif (msg == "versions") then
643  
644 DEFAULT_CHAT_FRAME:AddMessage(" ")
645 DEFAULT_CHAT_FRAME:AddMessage("|cffffff00Natur EnemyCastBar |cffcccc00("..CECB_status_version_txt..")|cffffff00:|cffff0000 /necb versions")
646  
647 local VersionDBTemp = { };
648  
649 if (VersionDB and VersionDB[1]) then
650 for i=1, table.getn (VersionDB) do
651 VersionDB[i] = string.gsub (VersionDB[i], "Natur ", "");
652 table.insert (VersionDBTemp, "|cffaaaaaaNECB: |rVersion |cff00ff00"..VersionDB[i].."|r is used by |cffcccc00"..VersionNames[i].."|r.");
653 end
654  
655 table.sort (VersionDBTemp);
656 local vcounter = 1;
657  
658 for i=1, table.getn (VersionDBTemp) do
659 local o = i + 1;
660 if (VersionDBTemp[o]) then
661 local _,_,nextversion = string.find (VersionDBTemp[o], "Version (.+) is used")
662 local _,_,thisversion = string.find (VersionDBTemp[i], "Version (.+) is used")
663  
664 if (nextversion and thisversion and nextversion == thisversion) then
665 local _,_,nextname = string.find (VersionDBTemp[o], "is used by (.+).")
666 table.remove (VersionDBTemp, o);
667 VersionDBTemp[i] = string.sub (VersionDBTemp[i], 1, string.len( VersionDBTemp[i] ) - 1 ) .. ", " ..nextname ..".";
668 i = i - 1;
669 vcounter = vcounter + 1;
670 else
671 if (vcounter > 1) then
672 VersionDBTemp[i] = VersionDBTemp[i] .. " (|cff00ff00" ..vcounter.. "|r Users)";
673 end
674 vcounter = 1;
675 end
676  
677 else
678  
679 if (vcounter > 1 and VersionDBTemp[i]) then
680 VersionDBTemp[i] = VersionDBTemp[i] .. " (|cff00ff00" ..vcounter.. "|r Users)";
681 end
682  
683 end
684  
685 end
686  
687 for i=table.getn (VersionDBTemp), 1, -1 do
688 DEFAULT_CHAT_FRAME:AddMessage(VersionDBTemp[i]);
689 end
690  
691 else
692 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB: |rIt seems there was |cffff0000no CT_RA Broadcast|r, yet!\n|cffaaaaaaNECB: |rChannelparsing has to be enabled to detect versions.")
693 end
694  
695 elseif (msg == "parser") then
696  
697 if (CECBParser) then
698  
699 CECBParser = false;
700 CECBCTRAParserFrame:Hide();
701 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Broadcast Parser |cffff9999disabled")
702  
703 else
704  
705 CECBParser = true;
706 CEnemyCastBar_ParserOnClick(0);
707 CECBCTRAParserFrame:Show();
708 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Broadcast Parser |cff99ff99temporary enabled")
709  
710 end
711  
712 elseif (msg == "clear") then
713  
714 lockshow = 0;
715  
716 if (not CEnemyCastBar.bLocked) then
717  
718 CEnemyCastBar_LockPos();
719  
720 end
721  
722 for i=1, 20 do
723  
724 CEnemyCastBar_HideBar(i);
725  
726 end
727  
728 elseif (msg == "restore") then
729  
730 local i = 1;
731 while (i <= table.getn (DisabledSpells)) do
732 local spell = DisabledSpells[i];
733  
734 if (CEnemyCastBar_Raids[spell]) then
735 CEnemyCastBar_Raids[spell].disabled = nil;
736 end
737  
738 if (CEnemyCastBar_Spells[spell]) then
739 CEnemyCastBar_Spells[spell].disabled = nil;
740 end
741  
742 if (CEnemyCastBar_Afflictions[spell]) then
743 CEnemyCastBar_Afflictions[spell].disabled = nil;
744 end
745  
746 i = i + 1;
747 end
748  
749 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Restored (|cffffff00"..table.getn (DisabledSpells).."|r) spells which were disabled by Shift + RightClick");
750 DisabledSpells = { };
751  
752 elseif (msg == "disabled") then
753  
754 local DSpells = table.concat (DisabledSpells, "|cffff0000 | |r");
755 if (table.getn (DisabledSpells) == 0) then
756 DSpells = " -.-";
757 end
758 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|cffffffff Disabled Spells: |r"..DSpells, 1, 1, 0);
759  
760 elseif (msg == "save") then
761  
762 CEnemyCastBar.tDisabledSpells = { };
763  
764 local i = 1;
765 while (DisabledSpells[i]) do
766 table.insert (CEnemyCastBar.tDisabledSpells, DisabledSpells[i]);
767 i = i + 1;
768 end
769  
770 if (table.getn (DisabledSpells) == 0) then
771 DSpells = "Nothing disabled! |rEmpty table saved.";
772 else
773 i = i - 1;
774 DSpells = i.." |rDisabled Spells saved.";
775 end
776 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|cffffff00 "..DSpells);
777  
778 elseif (msg == "load") then
779  
780 CEnemyCastBar_LoadDisabledSpells();
781  
782 elseif (string.sub (msg, 1, 7) == "remove " and CEnemyCastBar.bStatus) then
783  
784 local msg1 = string.sub (msg, 8, string.len(msg) );
785 local spellfound = false;
786  
787 local i = 1;
788 while (DisabledSpells[i]) do
789  
790 if (string.lower(DisabledSpells[i]) == string.lower(msg1)) then
791 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|cffffffff Restored Spell: |r".. table.concat (DisabledSpells, "", i, i), 1, 1, 0);
792  
793 local spell = DisabledSpells[i];
794 if (CEnemyCastBar_Raids[spell]) then
795 CEnemyCastBar_Raids[spell].disabled = nil;
796 end
797  
798 if (CEnemyCastBar_Spells[spell]) then
799 CEnemyCastBar_Spells[spell].disabled = nil;
800 end
801  
802 if (CEnemyCastBar_Afflictions[spell]) then
803 CEnemyCastBar_Afflictions[spell].disabled = nil;
804 end
805  
806 table.remove (DisabledSpells, i);
807 spellfound = true;
808 break;
809 end
810 i = i + 1;
811 end
812  
813 if (not spellfound) then
814 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|cffffaaaa Spell not found!");
815 end
816  
817 elseif (string.sub (msg, 1, 9) == "countsec " and CEnemyCastBar.bStatus) then
818  
819 local msg1 = tonumber (string.sub (msg, 10, 12));
820  
821 local textlen = string.len (msg);
822 local textinput = string.sub (msg, 10, textlen);
823 local firstspace = string.find (textinput, " ");
824 local msg2;
825 if (firstspace and textlen >= (firstspace + 10)) then
826 msg2 = string.sub (msg, firstspace + 10, textlen);
827 if ((firstspace +8) <= 12) then
828 msg1 = tonumber (string.sub (msg, 10, firstspace + 8));
829 end
830 end
831  
832 if (msg1) then
833  
834 if (msg1 < 0) then
835  
836 DEFAULT_CHAT_FRAME:AddMessage("NECB: |cffff9999Invalid value to start the countdown!")
837  
838 else
839  
840 if (msg2 == nil) then msg2 = "Countdown";
841 end
842  
843 if ( CEnemyCastBar_UniqueCheck(msg2, msg1, "("..msg1.." Seconds)") == 0 ) then
844 CEnemyCastBar_Show("("..msg1.." Seconds)", msg2, msg1, "grey", nil, "INV_Misc_Bomb_03.blp");
845 end
846  
847 end
848  
849 end
850  
851 elseif (string.sub (msg, 1, 9) == "countmin " and CEnemyCastBar.bStatus) then
852  
853 local msg1 = tonumber (string.sub (msg, 10, 12));
854  
855 local textlen = string.len (msg);
856 local textinput = string.sub (msg, 10, textlen);
857 local firstspace = string.find (textinput, " ");
858 local msg2;
859 if (firstspace and textlen >= (firstspace + 10)) then
860 msg2 = string.sub (msg, firstspace + 10, textlen);
861 if ((firstspace +8) <= 12) then
862 msg1 = tonumber (string.sub (msg, 10, firstspace + 8));
863 end
864 end
865  
866 if (msg1) then
867  
868 if (msg1 * 60 < 0) then
869  
870 DEFAULT_CHAT_FRAME:AddMessage("NECB: |cffff9999Invalid value to start the countdown!")
871  
872 else
873  
874 if (msg2 == nil) then msg2 = "Countdown";
875 end
876  
877 if ( CEnemyCastBar_UniqueCheck(msg2, msg1 * 60, "("..msg1.." Minutes)") == 0 ) then
878 CEnemyCastBar_Show("("..msg1.." Minutes)", msg2, msg1 * 60, "grey", nil, "INV_Misc_Bomb_03.blp");
879 end
880  
881  
882 end
883  
884 end
885  
886 elseif (string.sub (msg, 1, 7) == "repeat " and CEnemyCastBar.bStatus) then
887  
888 local msg1 = tonumber (string.sub (msg, 8, 10));
889  
890 local textlen = string.len (msg);
891 local textinput = string.sub (msg, 8, textlen);
892 local firstspace = string.find (textinput, " ");
893 local msg2;
894 if (firstspace and textlen >= (firstspace + 8)) then
895 msg2 = string.sub (msg, firstspace + 8, textlen);
896 if ((firstspace +6) <= 10) then
897 msg1 = tonumber (string.sub (msg, 8, firstspace + 6));
898 end
899 end
900  
901 if (msg1) then
902  
903 if (msg1 < 0) then
904  
905 DEFAULT_CHAT_FRAME:AddMessage("NECB: |cffff9999Invalid value to start the repeater!")
906  
907 else
908  
909 if (msg2 == nil) then msg2 = "Repeater";
910 else msg2 = "Repeater: "..msg2;
911 end
912 if ( CEnemyCastBar_UniqueCheck(msg2, msg1, "("..msg1.." Seconds)") == 0 ) then
913 CEnemyCastBar_Show("("..msg1.." Seconds)", msg2, msg1, "grey", nil, "INV_Misc_Bomb_04.blp");
914 end
915  
916 end
917  
918 end
919  
920 elseif (string.sub (msg, 1, 10) == "stopcount " and CEnemyCastBar.bStatus) then
921  
922 local msg1;
923 local textlen = string.len (msg);
924 if (textlen >= 11) then
925 msg1 = string.sub (msg, 11, textlen);
926 end
927  
928 if (msg1) then
929  
930 if (msg1 == "all") then msg1 = " ";
931 end
932  
933 for i=1, CEnemyCastBar.bNumBars do
934  
935 local label = getglobal("Carni_ECB_"..i).label;
936 local r,g,b = getglobal("Carni_ECB_"..i.."_StatusBar"):GetStatusBarColor();
937  
938 if (label) then
939 if (string.find (label, msg1) and ceil(b*10) == 8) then
940 CEnemyCastBar_HideBar(i);
941 end
942 end
943 end
944 end
945  
946 elseif (msg == "debug") then
947  
948 if (CEnemyCastBar.bDebug) then
949  
950 CEnemyCastBar.bDebug = false;
951 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r DebugMode |cffffff99disabled")
952  
953 else
954  
955 CEnemyCastBar.bDebug = true;
956 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r DebugMode |cffffff99enabled")
957  
958 end
959 end
960 end
961  
962  
963 -- Options Handler -----------------------
964 function CEnemyCastBar_Options(msg) --Options
965  
966 if (msg == "enable") then
967  
968 CEnemyCastBar.bStatus = true;
969 CEnemyCastBar_RegisterEvents();
970 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r AddOn |cff99ff99enabled|cffffffff. (Events |cff99ff99registered|cffffffff.)")
971  
972 elseif (msg == "disable") then
973  
974  
975 CEnemyCastBar_Handler("clear");
976 CEnemyCastBar.bStatus = false;
977 CEnemyCastBar_RegisterEvents("unregister");
978 TempFPSBar = false; CECB_FPSBarFree:Hide(); CECB_ReloadOptionsUI();
979  
980 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r AddOn |cffff9999disabled|cffffffff. (Events |cffff9999unregistered|cffffffff.)")
981  
982 elseif (msg == "lock") then
983  
984 CEnemyCastBar_LockPos()
985  
986 elseif (msg == "show") then
987  
988 CEnemyCastBar_Handler("clear");
989  
990 if (CEnemyCastBar.bLocked) then
991  
992 CEnemyCastBar_LockPos();
993  
994 end
995  
996 CEnemyCastBar_Show("(unlocked)", "Move this bar!", 15.0, "friendly");
997  
998 lockshow = 1;
999  
1000 elseif (msg == "reset") then
1001  
1002 CEnemyCastBar_Handler("clear");
1003 local lockcheck = CEnemyCastBar.bLocked; -- check if there is a difference after restoring (because of unlocking through "show")
1004 CEnemyCastBar_DefaultVars();
1005 CEnemyCastBar_ResetPos();
1006 CEnemyCastBar_SetTextSize();
1007 CECBOptionsFrameCECB_scale_Slider:SetValue(CEnemyCastBar.bScale); -- set sliders to default
1008 CECBOptionsFrameCECB_alpha_Slider:SetValue(CEnemyCastBar.bAlpha);
1009  
1010 if (not lockcheck == CEnemyCastBar.bLocked) then
1011 CEnemyCastBar.bLocked = lockcheck;
1012 CEnemyCastBar_LockPos();
1013 end
1014  
1015 if (TempFPSBar) then CEnemyCastBar_Handler("fpsbar");
1016 end
1017  
1018 CECB_ReloadOptionsUI();
1019 CECB_FPSBarFree:SetPoint("TOPLEFT", "UIParent", 50, -550);
1020 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r AddOn is now |cff99ff99restored")
1021  
1022 elseif (msg == "pvp") then
1023  
1024 if (CEnemyCastBar.bPvP) then
1025  
1026 CEnemyCastBar.bPvP = false;
1027 CECB_ReloadOptionsUI();
1028 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r CastBars for PvP spells |cffff9999completely disabled")
1029  
1030 else
1031  
1032 CEnemyCastBar.bPvP = true;
1033 CECB_ReloadOptionsUI();
1034 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r CastBars for PvP spells |cff99ff99enabled")
1035  
1036 end
1037  
1038 elseif (msg == "cdown") then
1039  
1040 if (CEnemyCastBar.bCDown) then
1041  
1042 CEnemyCastBar.bCDown = false;
1043 CECB_ReloadOptionsUI();
1044 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show some CoolDowns |cffff9999disabled")
1045  
1046 else
1047  
1048 CEnemyCastBar.bCDown = true;
1049 CECB_ReloadOptionsUI();
1050 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show some CoolDowns |cff99ff99enabled")
1051  
1052 end
1053  
1054 elseif (msg == "cdownshort") then
1055  
1056 if (CEnemyCastBar.bCDownShort) then
1057  
1058 CEnemyCastBar.bCDownShort = false;
1059 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Only show short cooldowns |cffff9999disabled")
1060  
1061 else
1062  
1063 CEnemyCastBar.bCDownShort = true;
1064 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Only show short cooldowns |cff99ff99enabled")
1065  
1066 end
1067  
1068 elseif (msg == "gains") then
1069  
1070 if (CEnemyCastBar.bGains) then
1071  
1072 CEnemyCastBar.bGains = false;
1073 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show 'gains' (and their cooldown) |cffff9999disabled")
1074  
1075 else
1076  
1077 CEnemyCastBar.bGains = true;
1078 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show 'gain type spells' |cff99ff99enabled")
1079  
1080 end
1081  
1082 elseif (msg == "pve") then
1083  
1084 if (CEnemyCastBar.bPvE) then
1085  
1086 CEnemyCastBar.bPvE = false;
1087 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r CastBars for PvE spells |cffff9999disabled")
1088  
1089 else
1090  
1091 CEnemyCastBar.bPvE = true;
1092 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r CastBars for PvE spells |cff99ff99enabled")
1093  
1094 end
1095  
1096 elseif (msg == "afflict") then
1097  
1098 if (CEnemyCastBar.bShowafflict) then
1099  
1100 CEnemyCastBar.bShowafflict = false;
1101 CECB_ReloadOptionsUI();
1102 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show Debuffs |cffff9999completely disabled")
1103  
1104 else
1105  
1106 CEnemyCastBar.bShowafflict = true;
1107 CECB_ReloadOptionsUI();
1108 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show Debuffs |cff99ff99enabled")
1109  
1110 end
1111  
1112 elseif (msg == "globalfrag") then
1113  
1114 if (CEnemyCastBar.bGlobalFrag) then
1115  
1116 CEnemyCastBar.bGlobalFrag = false;
1117 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show 'Mob Outs' even w/o target |cffff9999disabled")
1118  
1119 else
1120  
1121 CEnemyCastBar.bGlobalFrag = true;
1122 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show 'Mob Outs' even w/o target |cff99ff99enabled")
1123  
1124 end
1125  
1126 elseif (msg == "solod") then
1127  
1128 if (CEnemyCastBar.bSoloD) then
1129  
1130 CEnemyCastBar.bSoloD = false;
1131 CECB_ReloadOptionsUI();
1132 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show 'Solo Debuffs' (e.g. most stuns) |cffff9999disabled")
1133  
1134 else
1135  
1136 CEnemyCastBar.bSoloD = true;
1137 CECB_ReloadOptionsUI();
1138 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show 'Solo Debuffs' (e.g. most stuns) |cff99ff99enabled")
1139  
1140 end
1141  
1142 elseif (msg == "magecold") then
1143  
1144 if (CEnemyCastBar.bMageC) then
1145  
1146 CEnemyCastBar.bMageC = false;
1147 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show 'Mages Cold Effects' (DeBuffs) |cffff9999disabled")
1148  
1149 else
1150  
1151 CEnemyCastBar.bMageC = true;
1152 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Show 'Mages Cold Effects' (DeBuffs) |cff99ff99enabled")
1153  
1154 end
1155  
1156 elseif (msg == "drtimer") then
1157  
1158 if (CEnemyCastBar.bDRTimer) then
1159  
1160 CEnemyCastBar.bDRTimer = false;
1161 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Consider 'Diminishing Return' for biggest stun-family |cffff9999disabled")
1162  
1163 else
1164  
1165 CEnemyCastBar.bDRTimer = true;
1166 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Consider 'Diminishing Return' for biggest stun-family |cff99ff99enabled")
1167  
1168 end
1169  
1170 elseif (msg == "classdr") then
1171  
1172 if (CEnemyCastBar.bClassDR) then
1173  
1174 CEnemyCastBar.bClassDR = false;
1175 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Consider Class specific 'Diminishing Return' |cffff9999disabled")
1176  
1177 else
1178  
1179 CEnemyCastBar.bClassDR = true;
1180 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Consider Class specific 'Diminishing Return' |cff99ff99enabled")
1181  
1182 end
1183  
1184 elseif (msg == "sdots") then
1185  
1186 if (CEnemyCastBar.bSDoTs) then
1187  
1188 CEnemyCastBar.bSDoTs = false;
1189 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r CastBars to watch your DoT duration |cffff9999disabled")
1190  
1191 else
1192  
1193 CEnemyCastBar.bSDoTs = true;
1194 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r CastBars to watch your DoT duration |cff99ff99enabled")
1195  
1196 end
1197  
1198 elseif (msg == "affuni") then
1199  
1200 if (CEnemyCastBar.bAfflictuni) then
1201  
1202 CEnemyCastBar.bAfflictuni = false;
1203 CECB_ReloadOptionsUI();
1204 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Only show RaidDebuffs |cffff9999disabled")
1205  
1206 else
1207  
1208 CEnemyCastBar.bAfflictuni = true;
1209 CECB_ReloadOptionsUI();
1210 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Only show RaidDebuffs |cff99ff99enabled")
1211  
1212 end
1213  
1214 elseif (msg == "parsec") then
1215  
1216 if (CEnemyCastBar.bParseC) then
1217  
1218 CEnemyCastBar.bParseC = false;
1219 CECB_ReloadOptionsUI();
1220 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Parse Raid/PartyChannel for commands |cffff9999disabled")
1221  
1222 else
1223  
1224 CEnemyCastBar.bParseC = true;
1225 CECB_ReloadOptionsUI();
1226 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Parse Raid/PartyChannel for commands |cff99ff99enabled")
1227  
1228 end
1229  
1230 elseif (msg == "broadcast") then
1231  
1232 if (CEnemyCastBar.bBCaster) then
1233  
1234 CEnemyCastBar.bBCaster = false;
1235 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Broadcast Spells through CT_RA channel |cffff9999disabled")
1236  
1237 else
1238  
1239 CEnemyCastBar.bBCaster = true;
1240 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Broadcast Spells through CT_RA channel |cff99ff99enabled")
1241  
1242 end
1243  
1244 elseif (msg == "fpsbar") then
1245  
1246 if (TempFPSBar) then
1247  
1248 TempFPSBar = false;
1249 CECB_FPSBarFree:Hide();
1250 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Standalone FPS-Bar |cffff9999disabled")
1251  
1252 else
1253  
1254 TempFPSBar = true;
1255 CECB_FPSBarFree:Show();
1256 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Standalone FPS-Bar |cff99ff99enabled")
1257  
1258 end
1259  
1260 elseif (msg == "timer") then
1261  
1262 if (CEnemyCastBar.bTimer) then
1263  
1264 for i=1, 20 do
1265  
1266 getglobal("Carni_ECB_"..i.."_CastTimeText"):SetText( );
1267  
1268 end
1269  
1270 CEnemyCastBar.bTimer = false;
1271 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r CastBar time display |cffff9999disabled")
1272  
1273 else
1274  
1275 CEnemyCastBar.bTimer = true;
1276 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r CastBar time display |cff99ff99enabled")
1277  
1278 end
1279  
1280 elseif (msg == "targetm") then
1281  
1282 if (CEnemyCastBar.bTargetM) then
1283  
1284 CEnemyCastBar.bTargetM = false;
1285 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Target on BarLeftClick |cffff9999disabled")
1286  
1287 else
1288  
1289 CEnemyCastBar.bTargetM = true;
1290 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Target on BarLeftClick |cff99ff99enabled")
1291  
1292 end
1293  
1294 elseif (msg == "tsize") then
1295  
1296 if (CEnemyCastBar.bSmallTSize) then
1297  
1298 CEnemyCastBar.bSmallTSize = false;
1299 CEnemyCastBar_SetTextSize();
1300 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Small textsize of CastBars |cffff9999disabled")
1301  
1302 else
1303  
1304 CEnemyCastBar.bSmallTSize = true;
1305 CEnemyCastBar_SetTextSize();
1306 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Small textsize of CastBars |cff99ff99enabled")
1307  
1308 end
1309  
1310 elseif (msg == "flipb") then
1311  
1312 if (CEnemyCastBar.bFlipB) then
1313  
1314 CEnemyCastBar.bFlipB = false;
1315 CEnemyCastBar_FlipBars();
1316 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Bars now appear from first bar upwards. 'FlipOver' |cffff9999disabled")
1317  
1318 else
1319  
1320 CEnemyCastBar.bFlipB = true;
1321 CEnemyCastBar_FlipBars();
1322 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Bars now appear from first bar downwards. 'FlipOver' |cff99ff99enabled")
1323  
1324 end
1325  
1326 elseif (msg == "flashit") then
1327  
1328 if (CEnemyCastBar.bFlashit) then
1329  
1330 CEnemyCastBar.bFlashit = false;
1331 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r 'Flash' CastBars at their end |cffff9999disabled")
1332  
1333 else
1334  
1335 CEnemyCastBar.bFlashit = true;
1336 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r 'Flash' CastBars at their end |cff99ff99enabled")
1337  
1338 end
1339  
1340 elseif (msg == "showicon") then
1341  
1342 if (CEnemyCastBar.bShowIcon) then
1343  
1344 CEnemyCastBar.bShowIcon = false;
1345 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Display a Spell Icon next to the CastBar |cffff9999disabled")
1346  
1347 else
1348  
1349 CEnemyCastBar.bShowIcon = true;
1350 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Display a Spell Icon next to the CastBar |cff99ff99enabled")
1351  
1352 end
1353 end
1354 end
1355  
1356  
1357 function CEnemyCastBar_Show(mob, spell, castime, ctype, turnlabel, icontexture) --Show
1358  
1359 if (lockshow ~= 1) then
1360  
1361 local showing = false;
1362 local i = 1;
1363 local o = CEnemyCastBar.bNumBars;
1364  
1365 while (i <= o) do
1366  
1367 local button = getglobal("Carni_ECB_"..i);
1368 local fauxbutton = getglobal("FauxTargetBtn"..i);
1369  
1370 if (not button:IsVisible()) then
1371  
1372 if (showing == false) then
1373  
1374 if (ctype == "hostile") then
1375  
1376 red = 1.0;
1377 green = 0.0;
1378 blue = 0.0;
1379  
1380 elseif (ctype == "friendly") then
1381  
1382 red = 0.0;
1383 green = 1.0;
1384 blue = 0.0;
1385  
1386 elseif (ctype == "cooldown") then
1387  
1388 red = 0.0;
1389 green = 0.0;
1390 blue = 1.0;
1391  
1392 elseif (ctype == "gains") then
1393  
1394 red = 1.0;
1395 green = 0.0;
1396 blue = 1.0;
1397  
1398 elseif (ctype == "grey") then
1399 -- be carefull, those values are checked later to remove those bars - search for "GetStatusBarColor"
1400 red = 0.8;
1401 green = 0.8;
1402 blue = 0.8;
1403  
1404 elseif (ctype == "afflict") then
1405  
1406 red = 0.8;
1407 green = 0.8;
1408 blue = 0.0;
1409  
1410 elseif (ctype == "cursetype") then
1411  
1412 red = 0.0;
1413 green = 0.8;
1414 blue = 0.8;
1415  
1416 end
1417  
1418 getglobal("Carni_ECB_"..i).startTime = GetTime();
1419  
1420 if (turnlabel) then
1421 getglobal("Carni_ECB_"..i).label = mob .." - ".. spell;
1422 else
1423 getglobal("Carni_ECB_"..i).label = spell .." - ".. mob;
1424 end
1425  
1426 if (mob == UnitName("player")) then
1427 getglobal("Carni_ECB_"..i.."_Text"):SetShadowColor(1,0,0);
1428 else
1429 getglobal("Carni_ECB_"..i.."_Text"):SetShadowColor(0,0,0);
1430 end
1431  
1432 if (CEnemyCastBar.bShowIcon and icontexture) then
1433 getglobal("Carni_ECB_"..i.."_Icon"):SetTexture("Interface\\Icons\\"..icontexture);
1434 getglobal("Carni_ECB_"..i.."_Icon"):Show();
1435 else
1436 getglobal("Carni_ECB_"..i.."_Icon"):Hide();
1437 end
1438  
1439 getglobal("Carni_ECB_"..i).spell = spell;
1440 getglobal("Carni_ECB_"..i).endTime = getglobal("Carni_ECB_"..i).startTime + castime;
1441 getglobal("Carni_ECB_"..i.."_StatusBar"):SetMinMaxValues(button.startTime,button.endTime);
1442 getglobal("Carni_ECB_"..i.."_StatusBar"):SetValue(button.startTime);
1443 getglobal("Carni_ECB_"..i.."_StatusBar"):SetStatusBarColor(red, green, blue);
1444 fauxbutton:SetScale(CEnemyCastBar.bScale);
1445 fauxbutton:Show();
1446 button:SetAlpha(0);
1447 button:SetScale(CEnemyCastBar.bScale);
1448 button:Show();
1449 MobTargetName[i] = mob;
1450 showing = true;
1451  
1452 end
1453  
1454 end
1455  
1456 i = i + 1;
1457  
1458 end
1459  
1460 showing = false;
1461  
1462 end
1463  
1464 end
1465  
1466  
1467  
1468 function CEnemyCastBar_Gfind(arg1, event) --Gfind
1469  
1470 if (CEnemyCastBar.bStatus) then
1471  
1472 if (arg1) then
1473  
1474 for mob, spell in string.gfind(arg1, CEnemyCastBar_SPELL_CAST) do
1475  
1476 CEnemyCastBar_Control(mob, spell, "casts", nil, event);
1477 return;
1478 end
1479  
1480 for mob, spell in string.gfind(arg1, CEnemyCastBar_SPELL_PERFORM) do
1481  
1482 CEnemyCastBar_Control(mob, spell, "performs");
1483 return;
1484 end
1485  
1486 for mob in string.gfind(arg1, CEnemyCastBar_MOB_DIES) do
1487  
1488 if (mob == CEnemyCastBar_CTHUN_NAME1) then
1489 --CEnemyCastBar_UniqueCheck("Dark Glare (Repeater)", 0, "clears castbar");
1490 CEnemyCastBar_UniqueCheck("Eye Tentacle (Repeater)", 0, "clears castbar");
1491 CEnemyCastBar_Control("C'Thun", "Phase2 Eye Tentacle", "pve");
1492 end
1493  
1494 CEnemyCastBar_Control(mob, mob, "died");
1495 return;
1496 end
1497  
1498 for mob, spell in string.gfind(arg1, CEnemyCastBar_SPELL_GAINS) do
1499  
1500 CEnemyCastBar_Control(mob, spell, "gains", nil, event);
1501 return;
1502 end
1503  
1504 -- return if Spell damage from other players/mobs is detected -> german client problem (without it DoTs from everyone will be displayed, see next clause)
1505 if (string.find(arg1, CEnemyCastBar_SPELL_DAMAGE) ) then
1506  
1507 return;
1508 end
1509  
1510 if ( GetLocale() == "frFR" ) then
1511  
1512 for spell, damage, mob in string.gfind(arg1, CEnemyCastBar_SPELL_DAMAGE_SELFOTHER) do
1513  
1514 CEnemyCastBar_Control(mob, spell, "periodicdmg");
1515 return;
1516 end
1517  
1518 else
1519 -- periodic debuff damage routine for enUS and deDE pattern, No.1
1520 for mob, damage, spell in string.gfind(arg1, CEnemyCastBar_SPELL_DAMAGE_SELFOTHER) do
1521  
1522 CEnemyCastBar_Control(mob, spell, "periodicdmg");
1523 return;
1524 end
1525  
1526 end
1527  
1528 -- periodic debuff damage routine for frFR, enUS and deDE pattern, No.2 - crit! has to be checked first!
1529 for spell, mob, damage in string.gfind(arg1, CEnemyCastBar_SPELL_CRITS_SELFOTHER) do
1530  
1531 CEnemyCastBar_Control(mob, spell, "periodichitdmg");
1532 return;
1533 end
1534  
1535 -- periodic debuff damage routine for frFR, enUS and deDE pattern, No.3 - noncrit! has to be checked after crit!
1536 for spell, mob, damage in string.gfind(arg1, CEnemyCastBar_SPELL_HITS_SELFOTHER) do
1537  
1538 CEnemyCastBar_Control(mob, spell, "periodichitdmg");
1539 return;
1540 end
1541  
1542 if ( GetLocale() == "deDE" ) then
1543  
1544 for mob, spell in string.gfind(arg1, CEnemyCastBar_SPELL_AFFLICTED) do
1545  
1546 CEnemyCastBar_Control(mob, spell, "afflicted", nil, event);
1547 return;
1548 end
1549  
1550 for mob, spell in string.gfind(arg1, CEnemyCastBar_SPELL_AFFLICTED2) do
1551  
1552 CEnemyCastBar_Control(mob, spell, "afflicted", nil, event);
1553 return;
1554 end
1555  
1556 for spell, mob in string.gfind(arg1, CEnemyCastBar_SPELL_REMOVED) do
1557  
1558 CEnemyCastBar_Control(mob, spell, "fades");
1559 return;
1560 end
1561  
1562 else
1563  
1564 for mob, crap, spell in string.gfind(arg1, CEnemyCastBar_SPELL_AFFLICTED) do
1565  
1566 CEnemyCastBar_Control(mob, spell, "afflicted", nil, event);
1567 return;
1568 end
1569  
1570 for mob, spell in string.gfind(arg1, CEnemyCastBar_SPELL_REMOVED) do
1571  
1572 CEnemyCastBar_Control(mob, spell, "fades");
1573 return;
1574 end
1575 end
1576  
1577 for spell, mob in string.gfind(arg1, CEnemyCastBar_SPELL_FADE) do
1578  
1579 CEnemyCastBar_Control(mob, spell, "fades");
1580 return;
1581 end
1582  
1583 for mob, spell in string.gfind(arg1, CEnemyCastBar_SPELL_CASTS) do
1584  
1585 CEnemyCastBar_Control(mob, spell, "instcast", nil, event);
1586 return;
1587 end
1588 end
1589 end
1590 end
1591  
1592 function CEnemyCastBar_UniqueCheck(spellname, castime, mob, gspell, DRText) --Unique
1593  
1594 local ashowing, drstate, labeladd = 0;
1595  
1596 if (gspell == "true") then
1597  
1598 for i=1, CEnemyCastBar.bNumBars do
1599  
1600 local spell = getglobal("Carni_ECB_"..i).spell;
1601  
1602 if (spell == spellname and mob == MobTargetName[i]) then
1603  
1604 ashowing = 1;
1605  
1606 local button = getglobal("Carni_ECB_"..i); --START unique updater
1607 if (mob == UnitName("player")) then
1608 getglobal("Carni_ECB_"..i.."_Text"):SetShadowColor(1,0,0);
1609 else
1610 getglobal("Carni_ECB_"..i.."_Text"):SetShadowColor(0,0,0);
1611 end
1612  
1613 break; -- there can be only one :D
1614 end
1615 end
1616  
1617 elseif (gspell == "trueupdate") then
1618  
1619 for i=1, CEnemyCastBar.bNumBars do
1620  
1621 local spell = getglobal("Carni_ECB_"..i).spell;
1622  
1623 if (spell == spellname and mob == MobTargetName[i]) then
1624  
1625 ashowing = 1;
1626  
1627 local button = getglobal("Carni_ECB_"..i); --START unique updater
1628 if (mob == UnitName("player")) then
1629 getglobal("Carni_ECB_"..i.."_Text"):SetShadowColor(1,0,0);
1630 else
1631 getglobal("Carni_ECB_"..i.."_Text"):SetShadowColor(0,0,0);
1632 end
1633 getglobal("Carni_ECB_"..i).startTime = GetTime();
1634 getglobal("Carni_ECB_"..i).endTime = getglobal("Carni_ECB_"..i).startTime + castime;
1635 getglobal("Carni_ECB_"..i.."_StatusBar"):SetMinMaxValues(button.startTime,button.endTime);
1636 getglobal("Carni_ECB_"..i.."_StatusBar"):SetValue(button.startTime);
1637  
1638 break; -- there can be only one :D
1639 end
1640 end
1641  
1642 else
1643  
1644 for i=1, CEnemyCastBar.bNumBars do
1645  
1646 local spell = getglobal("Carni_ECB_"..i).spell;
1647  
1648 if (spell == spellname) then
1649  
1650 ashowing = 1;
1651  
1652 local button = getglobal("Carni_ECB_"..i); --START unique updater
1653  
1654 if (mob == UnitName("player")) then
1655 getglobal("Carni_ECB_"..i.."_Text"):SetShadowColor(1,0,0);
1656 else
1657 getglobal("Carni_ECB_"..i.."_Text"):SetShadowColor(0,0,0);
1658 end
1659  
1660 if (DRText) then
1661 if (string.find(button.label, "1/2")) then
1662 drstate = 4; DRText = "(|cffff00001/4|r)"; castime = castime/2 + 15;
1663 elseif (string.find(button.label, "1/4")) then
1664 drstate = 6; DRText = "(|cffff0000immune|r)"; castime = castime/4 + 15;
1665 elseif (string.find(button.label, "immune")) then
1666 drstate = 2; DRText = "(|cffff00001/2|r)"; castime = castime + 15;
1667 end
1668  
1669 getglobal("Carni_ECB_"..i).label = spell .." "..DRText.." - "..mob;
1670 else
1671 getglobal("Carni_ECB_"..i).label = spell .." - ".. mob;
1672 end
1673  
1674 getglobal("Carni_ECB_"..i).startTime = GetTime();
1675 getglobal("Carni_ECB_"..i).endTime = getglobal("Carni_ECB_"..i).startTime + castime;
1676 getglobal("Carni_ECB_"..i.."_StatusBar"):SetMinMaxValues(button.startTime,button.endTime);
1677 getglobal("Carni_ECB_"..i.."_StatusBar"):SetValue(button.startTime);
1678  
1679 MobTargetName[i] = mob; --END unique updater
1680  
1681 break; -- there can be only one :D
1682 end
1683 end
1684 end
1685  
1686 return ashowing, drstate;
1687 end
1688  
1689 function CEnemyCastBar_BCast_Control(bcasted, channum) --BCast Control
1690  
1691 local down, up, latency = GetNetStats();
1692  
1693 if (not bcasted and channum ~= 0 and latency < 500 and CEnemyCastBar.bBCaster and CEnemyCastBar.bParseC and GetNumRaidMembers() ~= 0) then
1694 if (LastSentBCPacket) then
1695 if (BCPacket[1] == LastSentBCPacket[1] and BCPacket[2] == LastSentBCPacket[2] and BCPacket[3] == LastSentBCPacket[3] and (GetTime() - LastSentBCPacket[4]) < 5) then
1696 return false, latency;
1697 end
1698 end
1699 return true, latency;
1700 end
1701 return false, latency;
1702 end
1703  
1704 function CEnemyCastBar_Control(mob, spell, special, bcasted, event) --Control
1705  
1706 if (CEnemyCastBar.bStatus and CEnemyCastBar.bDebug) then
1707  
1708 if (event) then
1709 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Debug, Con: "..mob.." (event: "..event..")");
1710 end
1711 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Debug, Con: "..mob.." ("..spell.." "..special..")");
1712  
1713 end
1714  
1715 -- Convert "You" into Playername, important for broadcasts
1716 if (mob == CECB_SELF1 or mob == CECB_SELF2) then
1717 mob = UnitName("player");
1718 end
1719  
1720 local spelllength = string.len (spell);
1721 -- crop the german aposthrophes from some spells (')
1722 local spell_de = string.sub(spell, 2, spelllength - 1);
1723 if (CEnemyCastBar_Raids[spell_de]) then spell = spell_de;
1724 end
1725  
1726 -- Network BC TempBCaster
1727 local channum = GetChannelName(CEnemyCastBar.bCT_RA_chan);
1728 local clientlang = GetLocale();
1729  
1730  
1731 if (special ~= "fades" and CEnemyCastBar_Raids[spell]) then
1732  
1733 if (CEnemyCastBar.bPvE) then
1734  
1735 -- stop Boss CDs from beeing updated by fault when player enters combat
1736 if (special == "engage") then
1737 if (engagecd and (GetTime() - engagecd) < 180) then
1738 engagecd = GetTime();
1739 return;
1740 end
1741 engagerunning = true;
1742 engagecd = GetTime();
1743 else
1744 if (engagerunning and (GetTime() - engagecd) < 180) then
1745 engagecd = GetTime();
1746  
1747 elseif (engagerunning or engagecd) then
1748 engagerunning, engagecd = nil;
1749 end
1750 end
1751  
1752 -- only allow instant casts with a flag pass to avoid spell mirroring
1753 if (special == "instcast" and not CEnemyCastBar_Raids[spell].icasted) then
1754 return;
1755 end
1756  
1757 -- check if previously disabled with shift + leftclick; +more
1758 if (
1759 (CEnemyCastBar_Raids[spell].disabled)
1760 or (CEnemyCastBar_Raids[spell].checktarget and UnitName("target") ~= mob)
1761 or (CEnemyCastBar_Raids[spell].aZone and GetRealZoneText() ~= CEnemyCastBar_Raids[spell].aZone)
1762 or (CEnemyCastBar_Raids[spell].checkevent and (not event or not string.find(CEnemyCastBar_Raids[spell].checkevent, event) ) )
1763  
1764 ) then
1765 return;
1766 end
1767  
1768 local icontex = CEnemyCastBar_Raids[spell].icontex; -- > get icon texture
1769 local globalspell = CEnemyCastBar_Raids[spell].global; -- > This castbar won't be updated if already active!
1770 castime = CEnemyCastBar_Raids[spell].t;
1771 ctype = CEnemyCastBar_Raids[spell].c;
1772  
1773 -- Spell might have the same name but a different cast time on another mob, ie. Onyxia/Nefarian on Bellowing Roar
1774 if (CEnemyCastBar_Raids[spell].r) then
1775  
1776 if (mob == CEnemyCastBar_Raids[spell].r) then
1777  
1778 castime = CEnemyCastBar_Raids[spell].a;
1779  
1780 end
1781  
1782 end
1783  
1784  
1785 if (CEnemyCastBar_Raids[spell].m) then
1786  
1787 mobbuffer = mob;
1788 mob = CEnemyCastBar_Raids[spell].m;
1789  
1790 end
1791  
1792  
1793 -- stop mirroring spells! only this mob produces castbars
1794 if (CEnemyCastBar_Raids[spell].mcheck) then
1795  
1796 mobcheck = CEnemyCastBar_Raids[spell].mcheck;
1797 else
1798 mobcheck = nil;
1799  
1800 end
1801  
1802 -- stop mirroring spells! only active casts are allowed
1803 if (CEnemyCastBar_Raids[spell].active and special ~= "casts") then
1804  
1805 mobcheck = "xyzdontshowspell";
1806  
1807 end
1808  
1809 if (mobcheck == nil or mobcheck == mob) then
1810  
1811 alreadyshowing = CEnemyCastBar_UniqueCheck(spell,castime,mob,globalspell);
1812  
1813 else
1814  
1815 alreadyshowing = 1;
1816  
1817 end
1818  
1819 if (alreadyshowing == 0) then
1820  
1821 CEnemyCastBar_Show(mob, spell, castime, ctype, nil, icontex);
1822  
1823 end
1824  
1825 if (CEnemyCastBar_Raids[spell].i) then
1826  
1827 castime = CEnemyCastBar_Raids[spell].i;
1828  
1829 --
1830 if (mobcheck == nil or mobcheck == mob) then
1831  
1832 alreadyshowing = CEnemyCastBar_UniqueCheck(spell.." (D)",castime,mob,globalspell);
1833  
1834 else
1835  
1836 alreadyshowing = 1;
1837  
1838 end
1839 --
1840  
1841 if (alreadyshowing == 0) then
1842  
1843 CEnemyCastBar_Show(mob, spell.." (D)", castime, "hostile", nil, icontex);
1844  
1845 end
1846  
1847 end
1848  
1849  
1850 -- Network BCasting
1851 if (mobcheck == nil or mobcheck == mob) then
1852 if (special == "afflicted" and mob ~= mobcheck) then
1853 mob = "CECBName"; -- so no channel spam appears after the raid got feared etc.
1854 end
1855  
1856 BCPacket = {mob, spell, special};
1857 local freetosend, latency = CEnemyCastBar_BCast_Control(bcasted, channum);
1858 if ( freetosend ) then
1859 CEnemyCastBar_SendMessage(".cecbspell "..mob..", "..spell..", "..special..", "..clientlang..", "..latency);
1860 LastSentBCPacket = {mob, spell, special, GetTime()};
1861 LastGotBCPacket = {mob, spell, special, GetTime()};
1862 numspellcast = 0;
1863 end
1864 end
1865  
1866 -- recall control function for mobs dying (Obsidian Destroyer) to clear all bars
1867 if (special == "died") then
1868 if (mobbuffer) then
1869 CEnemyCastBar_Control(mobbuffer, "dummy_xyz", "died");
1870 mobbuffer = nil;
1871 else
1872 CEnemyCastBar_Control(mob, "dummy_xyz", "died");
1873 end
1874 end
1875 end
1876  
1877 else
1878  
1879 if (CEnemyCastBar.bPvP) then
1880  
1881 if (UnitName("target") == mob) then
1882  
1883 if (special == "casts" or special == "gains" or special == "performs") then
1884  
1885 -- crop the german aposthrophes from some spells (')
1886 local spell_de = string.sub(spell, 2, spelllength - 1);
1887 if (CEnemyCastBar_Spells[spell_de]) then spell = spell_de;
1888 end
1889  
1890 if (CEnemyCastBar_Spells[spell]) then
1891  
1892 -- check if previously disabled with shift + leftclick
1893 if (CEnemyCastBar_Spells[spell].disabled) then
1894 return;
1895 end
1896  
1897 local icontex = CEnemyCastBar_Spells[spell].icontex; -- > get icon texture
1898  
1899 if (UnitIsEnemy("player", "target")) then
1900 ctype = "hostile";
1901 else
1902 ctype = "friendly";
1903 end
1904  
1905 if (CEnemyCastBar_Spells[spell].i) then
1906  
1907 castime = CEnemyCastBar_Spells[spell].i;
1908 CEnemyCastBar_Show(mob, spell, castime, ctype, nil, icontex);
1909  
1910 end
1911  
1912 if (CEnemyCastBar_Spells[spell].d and CEnemyCastBar.bCDown) then
1913  
1914 if (not (special == "gains" and not CEnemyCastBar.bGains)) then
1915  
1916 castime = CEnemyCastBar_Spells[spell].d;
1917 if (not (castime > 60 and CEnemyCastBar.bCDownShort) ) then
1918 if (CEnemyCastBar_UniqueCheck(spell.." (CD)", castime, mob, "trueupdate") == 0) then
1919 CEnemyCastBar_Show(mob, spell.." (CD)", castime, "cooldown", nil, icontex);
1920 end
1921 end
1922 end
1923 end
1924  
1925 castime = CEnemyCastBar_Spells[spell].t; -- but if only "d=" is applied then "t=nil", so check at end of this block
1926  
1927 -- Spell might have the same name but a different cast time on another mob, ie. Death Talon Hatchers/Players on Bellowing Roar
1928 if (CEnemyCastBar_Spells[spell].r) then
1929  
1930 if (mob == CEnemyCastBar_Spells[spell].r) then
1931  
1932 castime = CEnemyCastBar_Spells[spell].a;
1933  
1934 end
1935  
1936 end
1937  
1938 if (special == "gains") then
1939  
1940 if (CEnemyCastBar.bGains) then
1941  
1942 ctype = "gains";
1943 if (CEnemyCastBar_Spells[spell].g) then
1944  
1945 castime = CEnemyCastBar_Spells[spell].g;
1946  
1947 end
1948 else
1949  
1950 castime = nil;
1951  
1952 end
1953 end
1954  
1955 if (CEnemyCastBar_Spells[spell].c) then
1956  
1957 ctype = CEnemyCastBar_Spells[spell].c;
1958  
1959 end
1960  
1961 if (castime) then
1962 CEnemyCastBar_Show(mob, spell, castime, ctype, nil, icontex);
1963 end
1964  
1965 end
1966  
1967 end
1968  
1969 end
1970  
1971 end
1972 -- new block
1973 -- other than PvE, independent of PvP
1974 -- now check everytime, since some gains shall be removed, too (see REMOVALS in afflictions section of localization.lua)
1975 if (special == "fades") then -- spells fading earlier than bar, not very important since most spells can't end earlier and aren't listed in c-log after recast and still afflicted
1976  
1977 -- crop the german aposthrophes from some spells (')
1978 local spell_de = string.sub(spell, 2, spelllength - 1);
1979 if (CEnemyCastBar_Afflictions[spell_de]) then spell = spell_de;
1980 end
1981  
1982 if (CEnemyCastBar_Afflictions[spell]) then
1983  
1984 if (CEnemyCastBar_Afflictions[spell].periodicdmg) then
1985 return; -- don't hide dmg debuffs, can be other player's fade!
1986 end
1987  
1988 -- correct DR if a DR Spell fades earlier
1989 if (CEnemyCastBar.bClassDR and CEnemyCastBar_Afflictions[spell].spellDR) then
1990 local drshare = CEnemyCastBar_Afflictions[spell].drshare;
1991 if (drshare) then
1992 CEnemyCastBar_UniqueCheck("DR: "..drshare, 15, mob, "trueupdate", "");
1993 else
1994 CEnemyCastBar_UniqueCheck("DR: "..spell, 15, mob, "trueupdate", "");
1995 end
1996 end
1997  
1998 for i=1, CEnemyCastBar.bNumBars do
1999  
2000 local spellrunning = getglobal("Carni_ECB_"..i).spell;
2001 if (spellrunning) then
2002  
2003 local mobrunning = MobTargetName[i];
2004 if (mob == mobrunning and spell == spellrunning and not CEnemyCastBar_Afflictions[spell].multi) then
2005  
2006 CEnemyCastBar_HideBar(i);
2007  
2008 if (CEnemyCastBar_Afflictions[spell].global or CEnemyCastBar_Afflictions[spell].fragile) then
2009 -- Network BCasting
2010 BCPacket = {mob, spell, special};
2011 local freetosend, latency = CEnemyCastBar_BCast_Control(bcasted, channum);
2012 if ( freetosend ) then
2013 CEnemyCastBar_SendMessage(".cecbspell "..mob..", "..spell..", "..special..", "..clientlang..", "..latency);
2014 LastSentBCPacket = {mob, spell, special, GetTime()};
2015 LastGotBCPacket = {mob, spell, special, GetTime()};
2016 numspellcast = 0;
2017 end
2018 end
2019  
2020 break; -- there can be only one :D
2021  
2022 end
2023 end
2024 end
2025 end
2026  
2027 -- clear on mob died; to save some CPU time breackit it out
2028 elseif (special == "died") then
2029  
2030 for i=1, CEnemyCastBar.bNumBars do
2031  
2032 local spellrunning = getglobal("Carni_ECB_"..i).spell;
2033 if (spellrunning) then
2034  
2035 -- remove DR Timers upon death
2036 if (string.find(spellrunning, "DR:")) then
2037 spellrunning = "Stun DR";
2038 end
2039  
2040 local mobrunning = MobTargetName[i];
2041 if (CEnemyCastBar_Afflictions[spellrunning]) then
2042  
2043 -- "if" mob can't die without removing the debuff, so this wasn't the 'afflicted' mob
2044 -- "death" negates the above
2045 local fragile = CEnemyCastBar_Afflictions[spellrunning].fragile;
2046 local death = CEnemyCastBar_Afflictions[spellrunning].death;
2047  
2048 if (mob == mobrunning and (not fragile or death)) then
2049  
2050 CEnemyCastBar_HideBar(i);
2051  
2052 if (CEnemyCastBar_Afflictions[spellrunning].global or CEnemyCastBar_Afflictions[spellrunning].fragile) then
2053 -- Network BCasting
2054 BCPacket = {mob, spell, special};
2055 local freetosend, latency = CEnemyCastBar_BCast_Control(bcasted, channum);
2056 if ( freetosend ) then
2057 CEnemyCastBar_SendMessage(".cecbspell "..mob..", "..spell..", "..special..", "..clientlang..", "..latency);
2058 LastSentBCPacket = {mob, spell, special, GetTime()};
2059 LastGotBCPacket = {mob, spell, special, GetTime()};
2060 numspellcast = 0;
2061 end
2062 end
2063  
2064 end
2065  
2066 -- to clear all but CD bars if mob dies
2067 elseif (CEnemyCastBar_Spells[spellrunning]) then
2068  
2069 if (mob == mobrunning and (CEnemyCastBar.bCDownShort or not string.find(getglobal("Carni_ECB_"..i).label, "(CD)") ) ) then
2070 CEnemyCastBar_HideBar(i);
2071 end --
2072 end
2073 end
2074 end
2075  
2076 -- other than faded/died
2077 elseif (CEnemyCastBar.bShowafflict) then
2078  
2079 -- only 'afflicted', DoTs allowed!
2080 if (special == "afflicted" or (CEnemyCastBar.bSDoTs and (special == "periodicdmg" or special == "periodichitdmg") ) ) then
2081  
2082 -- crop the german aposthrophes from some spells (')
2083 local spell_de = string.sub(spell, 2, spelllength - 1);
2084 if (CEnemyCastBar_Afflictions[spell_de]) then spell = spell_de;
2085 end
2086  
2087 -- check if spell stacks
2088 local fbracket,_,spellstacks = string.find(spell, "(%(%d+%))" );
2089 if (fbracket) then
2090 spell = string.sub(spell, 1, fbracket - 2);
2091 else
2092 spellstacks = false;
2093 end
2094  
2095 -- database check
2096 if (CEnemyCastBar_Afflictions[spell]) then
2097  
2098 if (
2099 -- check if previously disabled with shift + leftclick
2100 (CEnemyCastBar_Afflictions[spell].disabled)
2101 -- break if 'mage cold debuff' but disabled
2102 or (CEnemyCastBar_Afflictions[spell].magecold and not CEnemyCastBar.bMageC)
2103 -- periodic dmg spells shall only be triggered if they do damage, otherwise the affliction might be from another player!
2104 or ( (special == "afflicted" and CEnemyCastBar_Afflictions[spell].periodicdmg) or ((special == "periodicdmg" or special == "periodichitdmg") and not CEnemyCastBar_Afflictions[spell].periodicdmg) )
2105  
2106 ) then
2107 return;
2108 end
2109  
2110 alreadyshowing = 0;
2111 local icontex = CEnemyCastBar_Afflictions[spell].icontex; -- > get icon texture
2112 local globalspell = CEnemyCastBar_Afflictions[spell].global; -- > castbars without a target check (Raidencounter)!
2113 local fragile = CEnemyCastBar_Afflictions[spell].fragile; -- > for option to show "fragiles" without a target!
2114  
2115 if (UnitName("target") == mob or globalspell or (fragile and CEnemyCastBar.bGlobalFrag) or special == "periodicdmg" or special == "periodichitdmg") then
2116  
2117 castime = CEnemyCastBar_Afflictions[spell].t;
2118  
2119 -- Consider Combo points for duration; wait 3 secs for 'Rupture's first DoT damage!
2120 if (CEnemyCastBar_Afflictions[spell].cpinterval and CECBownCPsHitTime and (GetTime() - CECBownCPsHitTime) < 3) then
2121 castime = castime - (CEnemyCastBar_Afflictions[spell].cpinterval * (5 - CECBownCPsHit));
2122 --DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Debug, castime="..castime.." -CECBownCPsHit="..CECBownCPsHit.." -cpinterval="..CEnemyCastBar_Afflictions[spell].cpinterval.." -timediff="..GetTime() - CECBownCPsHitTime) --!
2123 end
2124  
2125 if (special == "periodicdmg" or special == "periodichitdmg") then
2126 ctype = "cursetype";
2127 else
2128 ctype = "afflict";
2129 end
2130  
2131 -- DR START
2132 local DRTimer = 0;
2133 -- subfunction for DR Timer; CASTIME will be modified in Uni function (if DRText transmitted to funcion = last flag and label found -> after ELSE)
2134 local function CEnemyCastBar_DRBar(msg)
2135 if (CEnemyCastBar_UniqueCheck(msg, castime, mob, "true") == 0) then
2136 if (CEnemyCastBar_UniqueCheck(msg, castime, mob) == 0) then
2137 if (msg == "Stun DR") then
2138 CEnemyCastBar_Show(mob, msg, castime, "cooldown", nil, "Spell_Frost_Stun");
2139 else
2140 CEnemyCastBar_Show(mob, msg, castime, "cooldown", nil, icontex);
2141 end
2142 end
2143 CEnemyCastBar_UniqueCheck(msg, 15 + castime, mob, nil, "(|cffff00001/2|r)");
2144 else
2145 _, DRTimer = CEnemyCastBar_UniqueCheck(msg, castime, mob, nil, "trigger label check in uni function");
2146 end
2147 end
2148  
2149 -- stun diminishing returns bar
2150 if (not CEnemyCastBar.bAfflictuni and CEnemyCastBar.bDRTimer and mob ~= UnitName("player") and CEnemyCastBar_Afflictions[spell].stun) then
2151  
2152 CEnemyCastBar_DRBar("Stun DR");
2153 end
2154  
2155 -- pvp diminishing returns bar, CEnemyCastBar.bPvPDR
2156 local _, playersclass = UnitClass("player");
2157 if (CEnemyCastBar.bClassDR and not CEnemyCastBar.bAfflictuni and CEnemyCastBar_Afflictions[spell].spellDR and playersclass == CEnemyCastBar_Afflictions[spell].sclass and (UnitIsPlayer("target") or CEnemyCastBar_Afflictions[spell].affmob) and mob ~= UnitName("player")) then
2158 local drshare = CEnemyCastBar_Afflictions[spell].drshare;
2159 if (drshare) then
2160 CEnemyCastBar_DRBar("DR: "..drshare);
2161 else
2162 CEnemyCastBar_DRBar("DR: "..spell);
2163 end
2164 end
2165  
2166 if (DRTimer == 4 or DRTimer == 6) then
2167 castime = castime / (DRTimer - 2);
2168 end
2169 -- DR END
2170  
2171 -- break if 'solo spell' but disabled
2172 if (CEnemyCastBar_Afflictions[spell].solo and not CEnemyCastBar.bSoloD) then
2173 return;
2174 end
2175  
2176 if (CEnemyCastBar_Afflictions[spell].m) then
2177  
2178 mob = CEnemyCastBar_Afflictions[spell].m
2179  
2180 end
2181  
2182 -- unique check; Raidspells (globalspell) won't be updated; Fragiles will be updated and multiple bars allowed
2183 if (fragile) then
2184 alreadyshowing = CEnemyCastBar_UniqueCheck(spell,castime,mob,"trueupdate");
2185 elseif (spellstacks) then
2186 alreadyshowing = CEnemyCastBar_UniqueCheck(spell,castime,mob,nil,spellstacks);
2187 elseif (special == "periodicdmg" or special == "periodichitdmg") then
2188 if (special == "periodichitdmg" and CEnemyCastBar_Afflictions[spell].directhit) then
2189 alreadyshowing = CEnemyCastBar_UniqueCheck(spell,castime,mob);
2190 castime = castime + 1.0;
2191 else
2192 castime = castime - 1.5;
2193 alreadyshowing = CEnemyCastBar_UniqueCheck(spell,castime,mob,"true");
2194 end
2195 else
2196 alreadyshowing = CEnemyCastBar_UniqueCheck(spell,castime,mob,globalspell);
2197 end
2198  
2199 -- to detect if CPs are cleared AFTER a skill has been used, to update with correct duration afterwards if event "PLAYER_COMBO_POINTS" is fired
2200 if (playersclass == "ROGUE" and CEnemyCastBar_Afflictions[spell].cpinterval and not CEnemyCastBar_Afflictions[spell].periodicdmg) then
2201 CECBownCPsHitBuffer = {mob, spell, GetTime(), DRTimer };
2202 end
2203  
2204 if (globalspell or fragile) then
2205 -- Network BCasting
2206 BCPacket = {mob, spell, special};
2207 local freetosend, latency = CEnemyCastBar_BCast_Control(bcasted, channum);
2208 if ( freetosend ) then
2209 CEnemyCastBar_SendMessage(".cecbspell "..mob..", "..spell..", "..special..", "..clientlang..", "..latency);
2210 LastSentBCPacket = {mob, spell, special, GetTime()};
2211 LastGotBCPacket = {mob, spell, special, GetTime()};
2212 numspellcast = 0;
2213 end
2214 end
2215  
2216 if (alreadyshowing == 0) then
2217  
2218 -- Check for non-Raiddebuff and if they are switched off
2219 -- turnaroundlabel through "globalspell" (turnlabel), because the name is more important then
2220 if (not (globalspell ~= "true" and CEnemyCastBar.bAfflictuni) ) then
2221  
2222 CEnemyCastBar_Show(mob, spell, castime, ctype, globalspell, icontex);
2223 if (spellstacks) then
2224 CEnemyCastBar_UniqueCheck(spell,castime,mob,nil,spellstacks);
2225 end
2226 end
2227 end
2228 end
2229  
2230 end -- is spell in database?
2231 end -- check for afflicted/ DoTs option + periodicdmg
2232  
2233 end -- clear on mob fades/dies, elseif check option, afflictions set on?
2234 ------ block end (afflictions+)
2235  
2236 end -- finishes pve 'else' pvp, died if afflictions/fades
2237  
2238 end
2239  
2240 function CEnemyCastBar_Yells(arg1, arg2) --Yell
2241  
2242 if (CEnemyCastBar.bStatus and CEnemyCastBar.bDebug) then
2243  
2244 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Debug, YELL: "..arg1.."\nMOB="..arg2)
2245  
2246 end
2247  
2248 if (CEnemyCastBar.bStatus) then
2249  
2250 if (arg2 == "Nefarian") then
2251  
2252 if (string.find(arg1, CEnemyCastBar_NEFARIAN_SHAMAN_CALL)) then
2253 CEnemyCastBar_Control("Shamans", "Nefarian calls", "pve");
2254 return;
2255  
2256 elseif (string.find(arg1, CEnemyCastBar_NEFARIAN_DRUID_CALL)) then
2257 CEnemyCastBar_Control("Druids", "Nefarian calls", "pve");
2258 return;
2259  
2260 elseif (string.find(arg1, CEnemyCastBar_NEFARIAN_WARLOCK_CALL)) then
2261 CEnemyCastBar_Control("Warlocks", "Nefarian calls", "pve");
2262 return;
2263  
2264 elseif (string.find(arg1, CEnemyCastBar_NEFARIAN_PRIEST_CALL)) then
2265 CEnemyCastBar_Control("Priests", "Nefarian calls", "pve");
2266 return;
2267  
2268 elseif (string.find(arg1, CEnemyCastBar_NEFARIAN_HUNTER_CALL)) then
2269 CEnemyCastBar_Control("Hunters", "Nefarian calls", "pve");
2270 return;
2271  
2272 elseif (string.find(arg1, CEnemyCastBar_NEFARIAN_WARRIOR_CALL)) then
2273 CEnemyCastBar_Control("Warriors", "Nefarian calls", "pve");
2274 return;
2275  
2276 elseif (string.find(arg1, CEnemyCastBar_NEFARIAN_ROGUE_CALL)) then
2277 CEnemyCastBar_Control("Rogues", "Nefarian calls", "pve");
2278 return;
2279  
2280 elseif (string.find(arg1, CEnemyCastBar_NEFARIAN_PALADIN_CALL)) then
2281 CEnemyCastBar_Control("Paladins", "Nefarian calls", "pve");
2282 return;
2283  
2284 elseif (string.find(arg1, CEnemyCastBar_NEFARIAN_MAGE_CALL)) then
2285 CEnemyCastBar_Control("Mages", "Nefarian calls", "pve");
2286 return;
2287  
2288 elseif (string.find(arg1, CEnemyCastBar_NEFARIAN_LAND)) then
2289  
2290 CEnemyCastBar_Control("Nefarian", "Landing", "pve");
2291 return;
2292  
2293 end
2294  
2295 elseif (arg2 == "Lord Victor Nefarius") then
2296  
2297 if (string.find(arg1, CEnemyCastBar_NEFARIAN_STARTING)) then
2298  
2299 CEnemyCastBar_Control("Nefarian", "Mob Spawn", "pve");
2300 return;
2301  
2302 end
2303  
2304 elseif (arg2 == "Ragnaros") then
2305  
2306 if (string.find(arg1, CEnemyCastBar_RAGNAROS_STARTING)) then
2307  
2308 CEnemyCastBar_Control("Ragnaros", "Submerge", "pve");
2309 return;
2310  
2311 elseif (string.find(arg1, CEnemyCastBar_RAGNAROS_KICKER)) then
2312  
2313 CEnemyCastBar_Control("Ragnaros", "Knockback", "pve");
2314 return;
2315  
2316 elseif (string.find(arg1, CEnemyCastBar_RAGNAROS_SONS)) then
2317  
2318 CEnemyCastBar_Control("Ragnaros", "Sons of Flame", "pve");
2319 return;
2320  
2321 end
2322  
2323 elseif (arg2 == CEnemyCastBar_RAZORGORE_CALLER) then
2324  
2325 if (string.find(arg1, CEnemyCastBar_RAZORGORE_CALL)) then
2326  
2327 CEnemyCastBar_Control("Razorgore", "Mob Spawn (45sec)", "pve");
2328 return;
2329  
2330 end
2331  
2332 elseif (arg2 == CEnemyCastBar_SARTURA_NAME) then
2333  
2334 if (string.find(arg1, CEnemyCastBar_SARTURA_CALL)) then
2335  
2336 CEnemyCastBar_Control("Sartura", "Enraged mode", "pve");
2337 return;
2338  
2339 end
2340  
2341 elseif (arg2 == "Hakkar") then
2342  
2343 if (string.find(arg1, CEnemyCastBar_HAKKAR_YELL)) then
2344  
2345 CEnemyCastBar_Control("Hakkar", "LIFE DRAIN", "pve");
2346 return;
2347  
2348 end
2349  
2350 end
2351  
2352 end
2353  
2354 end
2355  
2356 function CEnemyCastBar_Emotes(arg1, arg2) --Emote
2357  
2358 if (CEnemyCastBar.bStatus) then
2359  
2360 if (CEnemyCastBar.bStatus and CEnemyCastBar.bDebug) then
2361  
2362 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r Debug, EMOTE: "..arg1.."\nMOB="..arg2)
2363  
2364 end
2365  
2366 if (arg2 == CEnemyCastBar_FLAMEGOR_NAME) then
2367  
2368 if (string.find(arg1, CEnemyCastBar_FLAMEGOR_FRENZY)) then
2369  
2370 CEnemyCastBar_Control("Flamegor", "Frenzy (CD)", "pve");
2371 return;
2372  
2373 end
2374  
2375 elseif (arg2 == "Chromaggus") then
2376  
2377 if (string.find(arg1, CEnemyCastBar_CHROMAGGUS_FRENZY)) then
2378  
2379 CEnemyCastBar_Control("Chromaggus", "Killing Frenzy", "pve");
2380 return;
2381  
2382 end
2383  
2384 elseif (arg2 == "Moam") then
2385  
2386 if (string.find(arg1, CEnemyCastBar_MOAM_STARTING)) then
2387  
2388 CEnemyCastBar_Control("Moam", "Until Stoneform", "pve");
2389 return;
2390  
2391 end
2392  
2393 elseif (arg2 == CEnemyCastBar_SARTURA_NAME) then
2394  
2395 if (string.find(arg1, CEnemyCastBar_SARTURA_CRAZY)) then
2396  
2397 CEnemyCastBar_Control("Sartura", "Enraged mode", "fades");
2398 CEnemyCastBar_Control("Sartura", "Enters Enraged mode", "pve");
2399 return;
2400  
2401 end
2402  
2403 elseif (arg2 == CEnemyCastBar_HUHURAN_NAME) then
2404  
2405 if (string.find(arg1, CEnemyCastBar_HUHURAN_FRENZY)) then
2406  
2407 CEnemyCastBar_Control("Huhuran", "Frenzy (CD)", "pve");
2408 return;
2409  
2410 elseif (string.find(arg1, CEnemyCastBar_HUHURAN_CRAZY)) then
2411  
2412 CEnemyCastBar_Control("Huhuran", "Berserk mode", "fades");
2413 CEnemyCastBar_Control("Huhuran", "Enters Berserk mode", "pve");
2414 return;
2415  
2416 end
2417  
2418 elseif (string.find(CEnemyCastBar_CTHUN_NAME1, arg2) ) then
2419  
2420 if (string.find(arg1, CEnemyCastBar_CTHUN_WEAKENED)) then
2421  
2422 CEnemyCastBar_UniqueCheck("Eye Tentacle (Repeater)", 0, "clears castbar");
2423 CEnemyCastBar_Control("C'Thun", "Weakened!!!", "pve", "true");
2424 CEnemyCastBar_Control("C'Thun", "Next Eye Tentacle", "pve", "true");
2425 return;
2426  
2427 end
2428  
2429 end
2430  
2431 end
2432  
2433 end
2434  
2435 function CEnemyCastBar_Player_Enter_Combat() --enter combat (Aggro etc., not only melee autoattack -> "regen. disabled" event)
2436  
2437 if (CEnemyCastBar.bStatus) then
2438  
2439 if (UnitName("target") == CEnemyCastBar_FIREMAW_NAME or UnitName("target") == CEnemyCastBar_FLAMEGOR_NAME or UnitName("target") == CEnemyCastBar_EBONROC_NAME) then
2440  
2441 CEnemyCastBar_Control("Presumed", "First Wingbuffet", "pve");
2442 return;
2443  
2444 elseif (UnitName("target") and (string.find (UnitName("target"), "Vek'lor") or string.find (UnitName("target"), "Vek'nilash"))) then
2445  
2446 CEnemyCastBar_Control("Twins", "Enraged mode", "engage");
2447 return;
2448  
2449 elseif (UnitName("target") and string.find (UnitName("target"), "Huhuran") ) then
2450  
2451 CEnemyCastBar_Control("Huhuran", "Berserk mode", "engage");
2452 return;
2453  
2454 elseif (UnitName("target") and string.find (UnitName("target"), CEnemyCastBar_CTHUN_NAME1) ) then
2455  
2456 CEnemyCastBar_Control("C'Thun", "Eye Tentacle (Repeater)", "engage");
2457 CEnemyCastBar_Control("C'Thun", "First Dark Glare", "engage");
2458 return;
2459  
2460 end
2461  
2462 end
2463  
2464 end
2465  
2466 function CEnemyCastBar_Parse_RaidChat(msg, author, origin) --parse Raid/PartyChat for commands
2467  
2468 if (CEnemyCastBar.bParseC) then
2469  
2470 if (string.sub (msg, 1, 10) == ".countsec " or string.sub (msg, 1, 10) == ".countmin " or string.sub (msg, 1, 8) == ".repeat " or string.sub (msg, 1, 11) == ".stopcount " or string.sub (msg, 1, 11) == ".cecbspell " or string.sub (msg, 1, 30) == "<CECB> CT_RA Channel detected.") then
2471  
2472 local detectedCECBcommand = true;
2473  
2474 if (origin == "CT_RA") then
2475  
2476 -- check if author is in your raidgroup
2477 local name, rank, inraid;
2478 for i = 1, GetNumRaidMembers() do
2479 name, rank = GetRaidRosterInfo(i);
2480 if ( name == author ) then
2481 inraid = true;
2482 break;
2483 end
2484 end
2485  
2486 if (not inraid) then return detectedCECBcommand; --!
2487 end --!
2488 end
2489  
2490 --Network BC
2491 if (string.sub (msg, 1, 11) == ".cecbspell ") then
2492  
2493 wrongclient = false;
2494 if (UnitName("player") == author) then return detectedCECBcommand; --!
2495 end --!
2496  
2497 for bcmob, bcspell, bcspecial, bcclientlang, bclatency in string.gfind (msg, ".cecbspell (.+), (.+), (.+), (.+), (.+)") do
2498  
2499 if (bcclientlang ~= GetLocale()) then
2500 wrongclient = true;
2501 return detectedCECBcommand;
2502 end
2503  
2504 -- Check if last receive was the same packet within 5 seconds -> then break!
2505 if (LastGotBCPacket) then
2506 if (bcmob == LastGotBCPacket[1] and bcspell == LastGotBCPacket[2] and bcspecial == LastGotBCPacket[3] and (GetTime() - LastGotBCPacket[4]) < 5) then
2507 numspellcast = numspellcast + 1;
2508 return detectedCECBcommand;
2509 end
2510 end
2511  
2512 --DEFAULT_CHAT_FRAME:AddMessage("m:"..bcmob.." s:"..bcspell.." t:"..bcspecial) --!
2513 numspellcast = 99;
2514 LastGotBCPacket = {bcmob, bcspell, bcspecial, GetTime()};
2515 CEnemyCastBar_Control(bcmob, bcspell, bcspecial, "true");
2516 return detectedCECBcommand; --unnecessary but gives a good feeling :D
2517 end
2518  
2519 else
2520 -- version harvester
2521 for version in string.gfind(msg, "<CECB> CT_RA Channel detected. (.+)") do
2522 version = string.sub(version, 2, string.len (version) - 1); -- remove brackets
2523 table.insert (VersionDB, version);
2524 table.insert (VersionNames, author);
2525 end
2526  
2527 local msg1 = string.sub (msg, 2, string.len(msg));
2528 CEnemyCastBar_Handler(msg1);
2529 return detectedCECBcommand; --unnecessary but gives a good feeling :D
2530 end
2531  
2532 return detectedCECBcommand;
2533  
2534 -- check for CT_RaidAssist broadcast
2535 elseif (origin == "Raid") then
2536  
2537 for chan in string.gfind(msg, "<CTMod> This is an automatic message sent by CT_RaidAssist. Channel changed to: (.+)") do
2538 CEnemyCastBar.bCT_RA_chan = chan;
2539 if (CECBOptionsFrame:IsVisible()) then
2540 CECB_ReloadOptionsUI();
2541 end
2542 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|r CT_RA Broadcast detected. Channel adopted!", 1, 0.5, 0);
2543 VersionDB = { };
2544 CEnemyCastBar_SendMessage("<CECB> CT_RA Channel detected. ("..CECB_status_version_txt..", "..GetLocale()..")");
2545 end
2546 end
2547 end
2548 end
2549  
2550 function CEnemyCastBar_SendMessage(msgs) --send
2551  
2552 -- converter for 'drunken protection'
2553 msgs = string.gsub(msgs, "s", "$");
2554 msgs = string.gsub(msgs, "S", "§");
2555 SendChatMessage(msgs, "CHANNEL", nil, GetChannelName(CEnemyCastBar.bCT_RA_chan));
2556  
2557 end
2558  
2559 function CEnemyCastBar_OnUpdate() --Update
2560  
2561 local CECname=this:GetName();
2562 local CECno=this:GetID();
2563 local fauxbtn=getglobal("FauxTargetBtn"..CECno);
2564  
2565 if (not carniactive) then
2566  
2567 -- Fade the bar out
2568 local alpha = this:GetAlpha() - 0.05;
2569 if (alpha > 0) then
2570 this:SetAlpha(alpha);
2571 end
2572 CEnemyCastBar_HideBar(CECno);
2573  
2574 else
2575  
2576 if (this.endTime) then
2577  
2578 local label = mobname;
2579 local now = GetTime();
2580 -- Update the spark, status bar and label
2581 local remains = this.endTime - now;
2582 --label = label .. CEnemyCastBar_NiceTime(remains);
2583 local sparkPos = ((now - this.startTime) / (this.endTime - this.startTime)) * 195;
2584  
2585 getglobal(this:GetName() .. "_StatusBar"):SetValue(now);
2586 getglobal(this:GetName() .. "_Text"):SetText( this.label );
2587 getglobal(this:GetName() .. "_StatusBar_Spark"):SetPoint("CENTER", getglobal(this:GetName() .. "_StatusBar"), "LEFT", sparkPos, 0);
2588  
2589 if (CEnemyCastBar.bTimer) then
2590  
2591 getglobal(this:GetName() .. "_CastTimeText"):SetText( CEnemyCastBar_NiceTime(remains) );
2592  
2593 end
2594  
2595  
2596 -- fantastic fading routine + flashing, fps independent :D
2597 local framerate = GetFramerate();
2598 local stepping = 2/framerate;
2599  
2600 if (stepping > 0.4 ) then stepping = 0.4; -- security for very low fps (< 5fps)
2601 end
2602  
2603 local baralpha = this:GetAlpha();
2604 local totalTime = this.endTime - this.startTime;
2605 if (CEnemyCastBar.bFlashit and (remains/totalTime) < 0.20 and remains < 10 and totalTime >= 20) then
2606  
2607 stepping2 = stepping/1.2 -- manipulate flashing-speed
2608 if ((baralpha - stepping2) >= 0.1) then
2609 baralpha = baralpha - stepping2;
2610 this:SetAlpha(baralpha);
2611 else
2612 this:SetAlpha(1);
2613 end
2614  
2615 else
2616  
2617 if (baralpha + stepping <= CEnemyCastBar.bAlpha) then
2618 baralpha = baralpha + stepping;
2619 this:SetAlpha(baralpha);
2620 else
2621 if (baralpha ~= CEnemyCastBar.bAlpha) then
2622 this:SetAlpha(CEnemyCastBar.bAlpha);
2623 end
2624 end
2625 end
2626 -- fading routine finished
2627  
2628 if (remains < 0) then
2629  
2630 if (string.find (getglobal(this:GetName()).label, "Repeater") ) then
2631  
2632 local castime = getglobal(this:GetName()).endTime - getglobal(this:GetName()).startTime;
2633 getglobal(this:GetName()).startTime = GetTime();
2634 getglobal(this:GetName()).endTime = getglobal(this:GetName()).startTime + castime;
2635 getglobal(this:GetName().."_StatusBar"):SetMinMaxValues(getglobal(this:GetName()).startTime,getglobal(this:GetName()).endTime);
2636 getglobal(this:GetName().."_StatusBar"):SetValue(getglobal(this:GetName()).startTime);
2637  
2638 if (castime == 0) then
2639 getglobal(this:GetName()).label = "delete me!";
2640 end
2641  
2642 else
2643  
2644 if (getglobal(this:GetName()).spell == "Move this bar!" and lockshow == 1) then
2645 lockshow = 0;
2646 if (CEnemyCastBar.bLocked == false) then
2647 CEnemyCastBar_LockPos();
2648 end
2649  
2650 -- damn C'Thun crazy timers
2651 -- elseif (string.find (getglobal(this:GetName()).label, "First Dark Glare") ) then
2652 -- CEnemyCastBar_Control("C'Thun", "Dark Glare (Repeater)", "pve", "true");
2653  
2654 elseif (string.find (getglobal(this:GetName()).label, "Next Eye Tentacle") or string.find (getglobal(this:GetName()).label, "Phase2 Eye Tentacle") ) then
2655 CEnemyCastBar_Control("C'Thun", "Eye Tentacle (Repeater)", "pve", "true");
2656 CEnemyCastBar_UniqueCheck("Eye Tentacle (Repeater)", 30, "C'Thun");
2657  
2658 end
2659  
2660 CEnemyCastBar_HideBar(CECno);
2661  
2662 end
2663  
2664 elseif (remains >= 5 ) then
2665  
2666 -- pull the bars together
2667 local CECpre = CECno - 1;
2668 local cecbuttonpre = getglobal("Carni_ECB_"..CECpre);
2669  
2670 if (CECpre > 0 and not cecbuttonpre:IsShown()) then
2671  
2672 cecbuttonpre.startTime = this.startTime
2673 cecbuttonpre.label = this.label;
2674  
2675 local r,g,b = getglobal("Carni_ECB_"..CECno.."_Text"):GetShadowColor();
2676 getglobal("Carni_ECB_"..CECpre.."_Text"):SetShadowColor(r,g,b);
2677  
2678 if (getglobal("Carni_ECB_"..CECno.."_Icon"):IsShown()) then
2679 getglobal("Carni_ECB_"..CECpre.."_Icon"):SetTexture(getglobal("Carni_ECB_"..CECno.."_Icon"):GetTexture());
2680 getglobal("Carni_ECB_"..CECpre.."_Icon"):Show();
2681 end
2682  
2683 cecbuttonpre.spell = this.spell;
2684 cecbuttonpre.endTime = this.endTime;
2685 getglobal("Carni_ECB_"..CECpre.."_StatusBar"):SetMinMaxValues(getglobal("Carni_ECB_"..CECno.."_StatusBar"):GetMinMaxValues());
2686 getglobal("Carni_ECB_"..CECpre.."_StatusBar"):SetValue(getglobal("Carni_ECB_"..CECno.."_StatusBar"):GetValue());
2687 getglobal("Carni_ECB_"..CECpre.."_StatusBar"):SetStatusBarColor(getglobal("Carni_ECB_"..CECno.."_StatusBar"):GetStatusBarColor());
2688 getglobal("FauxTargetBtn"..CECpre):Show();
2689 MobTargetName[CECpre] = MobTargetName[CECno];
2690 cecbuttonpre:SetAlpha(CEnemyCastBar.bAlpha);
2691 cecbuttonpre:Show();
2692  
2693 CEnemyCastBar_HideBar(CECno);
2694 end
2695 end
2696  
2697 end
2698 end
2699 end
2700  
2701 -- Movable window
2702 function CEnemyCastBar_OnDragStart()
2703 CarniEnemyCastBarFrame:StartMoving();
2704 end
2705  
2706 function CEnemyCastBar_OnDragStop()
2707 CarniEnemyCastBarFrame:StopMovingOrSizing();
2708 end
2709  
2710 -- Format seconds into m:ss
2711 function CEnemyCastBar_NiceTime(secs)
2712 if (secs > 60) then
2713 return string.format("%d:%02d", secs / 60, math.mod(secs, 60));
2714 else
2715 return string.format("%.1f", secs);
2716 end
2717 end
2718  
2719 -- Show/hide Options
2720 function CECB_ShowHideOptionsUI()
2721 if (CECBOptionsFrame:IsVisible()) then
2722 CECBOptionsFrame:Hide();
2723 else
2724 CECBOptionsFrame:Show();
2725  
2726 if (CEnemyCastBar.bPvP) then
2727 CECB_Checkbox_toggle("cdown", "enable");
2728 CECB_Checkbox_toggle("gains", "enable");
2729 if (CEnemyCastBar.bCDown) then
2730 CECB_Checkbox_toggle("cdownshort", "enable");
2731 else
2732 CECB_Checkbox_toggle("cdownshort", "disable");
2733 end
2734 else
2735 CECB_Checkbox_toggle("cdown", "disable");
2736 CECB_Checkbox_toggle("gains", "disable");
2737 CECB_Checkbox_toggle("cdownshort", "disable");
2738 end
2739  
2740 if (CEnemyCastBar.bShowafflict) then
2741 -- + 'solo debuffs' + all DR Checkboxes under 'globalfrag'
2742 CECB_Checkbox_toggle("affuni", "enable");
2743 if (CEnemyCastBar.bAfflictuni) then
2744 CECB_Checkbox_toggle("globalfrag", "disable");
2745 else
2746 CECB_Checkbox_toggle("globalfrag", "enable");
2747 end
2748 else
2749 CECB_Checkbox_toggle("affuni", "disable");
2750 CECB_Checkbox_toggle("globalfrag", "disable");
2751 end
2752  
2753 if (CEnemyCastBar.bParseC) then
2754 if (GetChannelName(CEnemyCastBar.bCT_RA_chan) == 0) then
2755 CECB_Checkbox_toggle("broadcast", "disable");
2756 CECBOptionsFrameCTRAChanText:SetText("|cffffcc00"..CECB_menue_CTRAChan.."|cffaaaaaa"..CECB_menue_CTRAnoBC);
2757 else
2758 CECB_Checkbox_toggle("broadcast", "enable");
2759 CECBOptionsFrameCTRAChanText:SetText("|cffffcc00"..CECB_menue_CTRAChan.."|cffffaa00/"..GetChannelName(CEnemyCastBar.bCT_RA_chan).." "..CEnemyCastBar.bCT_RA_chan);
2760 end
2761 else
2762 CECB_Checkbox_toggle("broadcast", "disable");
2763 if (GetChannelName(CEnemyCastBar.bCT_RA_chan) == 0) then
2764 CECBOptionsFrameCTRAChanText:SetText("|cffaaaaaa"..CECB_menue_CTRAChan..CECB_menue_CTRAnoBC);
2765 else
2766 CECBOptionsFrameCTRAChanText:SetText("|cffaaaaaa"..CECB_menue_CTRAChan.."/"..GetChannelName(CEnemyCastBar.bCT_RA_chan).." "..CEnemyCastBar.bCT_RA_chan);
2767 end
2768 end
2769 end
2770 end
2771  
2772 function CECB_ReloadOptionsUI()
2773 CECB_ShowHideOptionsUI();
2774 CECB_ShowHideOptionsUI();
2775 end
2776  
2777 function CECB_Checkbox_toggle(which, todo) --toggle
2778  
2779 if (which == "status") then
2780  
2781 if (todo == "enable") then
2782 CECBOptionsFrameCECB_status_check:Enable();
2783 CECBOptionsFrameCECB_status_checkText:SetText(CECB_status_txt);
2784  
2785 elseif (CECBOptionsFrameCECB_status_check:IsEnabled() ) then
2786 CECBOptionsFrameCECB_status_check:Disable();
2787 CECBOptionsFrameCECB_status_checkText:SetText("|cffaaaaaa"..CECB_status_txt);
2788 end
2789  
2790 elseif (which == "cdown") then
2791  
2792 if (todo == "enable") then
2793 CECBOptionsFrameCECB_cdown_check:Enable();
2794 CECBOptionsFrameCECB_cdown_checkText:SetText(CECB_cdown_txt);
2795 else
2796 CECBOptionsFrameCECB_cdown_check:Disable();
2797 CECBOptionsFrameCECB_cdown_checkText:SetText("|cffaaaaaa"..CECB_cdown_txt);
2798 end
2799  
2800 elseif (which == "gains") then
2801  
2802 if (todo == "enable") then
2803 CECBOptionsFrameCECB_gains_check:Enable();
2804 CECBOptionsFrameCECB_gains_checkText:SetText(CECB_gains_txt);
2805 else
2806 CECBOptionsFrameCECB_gains_check:Disable();
2807 CECBOptionsFrameCECB_gains_checkText:SetText("|cffaaaaaa"..CECB_gains_txt);
2808 end
2809  
2810 elseif (which == "affuni") then
2811  
2812 if (todo == "enable") then
2813 CECBOptionsFrameCECB_affuni_check:Enable();
2814 CECBOptionsFrameCECB_affuni_checkText:SetText(CECB_affuni_txt);
2815  
2816 else
2817 CECBOptionsFrameCECB_affuni_check:Disable();
2818 CECBOptionsFrameCECB_affuni_checkText:SetText("|cffaaaaaa"..CECB_affuni_txt);
2819  
2820 end
2821  
2822 -- plus 'solo debuffs', plus 'mages cold effects'
2823 elseif (which == "globalfrag") then
2824  
2825 if (todo == "enable") then
2826 CECBOptionsFrameCECB_magecold_check:Enable();
2827 CECBOptionsFrameCECB_magecold_checkText:SetText(CECB_magecold_txt);
2828 CECBOptionsFrameCECB_solod_check:Enable();
2829 CECBOptionsFrameCECB_solod_checkText:SetText(CECB_solod_txt);
2830 CECBOptionsFrameCECB_globalfrag_check:Enable();
2831 CECBOptionsFrameCECB_globalfrag_checkText:SetText(CECB_globalfrag_txt);
2832 CECBOptionsFrameCECB_drtimer_check:Enable();
2833 CECBOptionsFrameCECB_drtimer_checkText:SetText(CECB_drtimer_txt);
2834 CECBOptionsFrameCECB_classdr_check:Enable();
2835 CECBOptionsFrameCECB_classdr_checkText:SetText(CECB_classdr_txt);
2836 CECBOptionsFrameCECB_sdots_check:Enable();
2837 CECBOptionsFrameCECB_sdots_checkText:SetText(CECB_sdots_txt);
2838 else
2839 CECBOptionsFrameCECB_magecold_check:Disable();
2840 CECBOptionsFrameCECB_magecold_checkText:SetText("|cffaaaaaa"..CECB_magecold_txt);
2841 CECBOptionsFrameCECB_solod_check:Disable();
2842 CECBOptionsFrameCECB_solod_checkText:SetText("|cffaaaaaa"..CECB_solod_txt);
2843 CECBOptionsFrameCECB_globalfrag_check:Disable();
2844 CECBOptionsFrameCECB_globalfrag_checkText:SetText("|cffaaaaaa"..CECB_globalfrag_txt);
2845 CECBOptionsFrameCECB_drtimer_check:Disable();
2846 CECBOptionsFrameCECB_drtimer_checkText:SetText("|cffaaaaaa"..CECB_drtimer_txt);
2847 CECBOptionsFrameCECB_classdr_check:Disable();
2848 CECBOptionsFrameCECB_classdr_checkText:SetText("|cffaaaaaa"..CECB_classdr_txt);
2849 CECBOptionsFrameCECB_sdots_check:Disable();
2850 CECBOptionsFrameCECB_sdots_checkText:SetText("|cffaaaaaa"..CECB_sdots_txt);
2851 end
2852  
2853 elseif (which == "cdownshort") then
2854  
2855 if (todo == "enable") then
2856 CECBOptionsFrameCECB_cdownshort_check:Enable();
2857 CECBOptionsFrameCECB_cdownshort_checkText:SetText(CECB_cdownshort_txt);
2858 else
2859 CECBOptionsFrameCECB_cdownshort_check:Disable();
2860 CECBOptionsFrameCECB_cdownshort_checkText:SetText("|cffaaaaaa"..CECB_cdownshort_txt);
2861 end
2862  
2863 elseif (which == "broadcast") then
2864  
2865 if (todo == "enable") then
2866 CECBOptionsFrameCECB_broadcast_check:Enable();
2867 CECBOptionsFrameCECB_broadcast_checkText:SetText(CECB_broadcast_txt);
2868 else
2869 CECBOptionsFrameCECB_broadcast_check:Disable();
2870 CECBOptionsFrameCECB_broadcast_checkText:SetText("|cffaaaaaa"..CECB_broadcast_txt);
2871 end
2872 end
2873 end
2874  
2875 -- Show/hide ApplyReset
2876 function CECB_ApplyResetFrame()
2877 if (CECBApplyResetFrame:IsVisible()) then
2878 CECBApplyResetFrame:Hide();
2879  
2880 else
2881 CECBApplyResetFrame:Show();
2882 end
2883 end
2884  
2885 function CECB_Options_Sub(todo, value) --options sub
2886  
2887 local i = 1;
2888 while (OptionFrameNames[i]) do
2889  
2890 if (todo == "alpha") then OptionFrameNames[i]:SetAlpha(value);
2891 elseif (todo == "hide") then OptionFrameNames[i]:Hide();
2892 elseif (todo == "show") then OptionFrameNames[i]:Show();
2893 end
2894  
2895 i = i + 1;
2896 end
2897 end
2898  
2899 function CEnemyCastBar_Options_OnUpdate() --Menue on update
2900  
2901 if (not cecbmaxsize and CECBOptionsFrame:GetHeight() > (menuesizey - 1)) then
2902 bgalpha = 1; CECB_Options_Sub("show");
2903 cecbmaxsize = true; cecbminsize = false;
2904 CECB_Checkbox_toggle("status", "enable");
2905 elseif (not cecbminsize and CECBOptionsFrame:GetHeight() < (mshrinksizey + 1)) then
2906 bgalpha = 0; CECB_Options_Sub("hide");
2907 cecbminsize = true; cecbmaxsize = false;
2908 CECB_Checkbox_toggle("status", "enable");
2909 end
2910  
2911 local framerate = GetFramerate();
2912 local stepping = 2/framerate;
2913 if (stepping > 0.4 ) then stepping = 0.4; -- security for very low fps (< 5fps)
2914 end
2915  
2916 -- add fps-meter
2917 local g = framerate/30;
2918 local r = 30/framerate;
2919  
2920 if (g > 1) then g = 1; end
2921 if (r > 1) then r = 1; end
2922  
2923 if (framerate > 100) then frameratesafe = 100;
2924 else frameratesafe = framerate;
2925 end
2926  
2927 CECBOptionsFrameBGFrameFPSBar_StatusBar:SetMinMaxValues(1,100);
2928 CECBOptionsFrameBGFrameFPSBar_StatusBar:SetValue(frameratesafe);
2929 CECBOptionsFrameBGFrameFPSBar_StatusBar_Spark:SetPoint("CENTER", "CECBOptionsFrameBGFrameFPSBar_StatusBar", "LEFT", frameratesafe*1.95, 0);
2930 CECBOptionsFrameBGFrameFPSBar_Text:SetText("|cffffffaaFPS: |cffffcc00"..ceil(framerate));
2931 CECBOptionsFrameBGFrameFPSBar_StatusBar:SetStatusBarColor(r,g,0);
2932 -- fps-meter finished
2933  
2934 -- now we start
2935 if (fademenue == 1) then
2936 local malpha = CECBOptionsFrame:GetAlpha() - stepping*2;
2937 if (malpha > 0) then
2938 CECBOptionsFrame:SetAlpha(malpha);
2939 else
2940 CECBOptionsFrame:Hide();
2941 fademenue = false;
2942 end
2943  
2944 elseif (fademenue == 2) then
2945 local malpha = CECBOptionsFrame:GetAlpha() + stepping*2;
2946 if (malpha < 1) then
2947 CECBOptionsFrame:SetAlpha(malpha);
2948 else
2949 CECBOptionsFrame:SetAlpha(1);
2950 fademenue = false;
2951 end
2952 end
2953  
2954 if (not CEnemyCastBar.bStatus) then
2955  
2956 if (not cecbminsize) then
2957  
2958 local optionsheight = CECBOptionsFrame:GetHeight();
2959 local optionswidth = CECBOptionsFrame:GetWidth();
2960 if ((optionsheight - stepping*150) > (mshrinksizey +1)) then
2961 CECB_Checkbox_toggle("status", "disable");
2962 optionsheight = optionsheight - stepping*150;
2963 CECBOptionsFrame:SetHeight(optionsheight);
2964  
2965 if ((optionswidth - stepping*200) > (mshrinksizex +1)) then
2966 optionswidth = optionswidth - stepping*200;
2967 CECBOptionsFrame:SetWidth(optionswidth);
2968 else
2969 CECBOptionsFrame:SetWidth(mshrinksizex);
2970 end
2971  
2972 if ((bgalpha - stepping) >= 0) then bgalpha = bgalpha - stepping;
2973 CECB_Options_Sub("alpha", bgalpha);
2974 CECBOptionsFrameBGFrame1:SetBackdropBorderColor(1 - bgalpha, 0, 0);
2975 else
2976 CECB_Options_Sub("alpha", 0);
2977 end
2978  
2979 else
2980 CECB_Options_Sub("hide");
2981 CECBOptionsFrame:SetHeight(mshrinksizey);
2982 end
2983 end
2984  
2985 elseif (not cecbmaxsize) then
2986  
2987 local optionsheight = CECBOptionsFrame:GetHeight();
2988 local optionswidth = CECBOptionsFrame:GetWidth();
2989 CECBOptionsFrameBGFrame1:SetBackdropBorderColor(0.4, 0.4, 0.4);
2990  
2991 CECB_Options_Sub("show");
2992  
2993 if ((optionsheight + stepping*150) < (menuesizey -1)) then
2994 CECB_Checkbox_toggle("status", "disable");
2995 optionsheight = optionsheight + stepping*150;
2996 CECBOptionsFrame:SetHeight(optionsheight);
2997  
2998 if ((optionswidth + stepping*200) < (menuesizex -1)) then
2999 optionswidth = optionswidth + stepping*200;
3000 CECBOptionsFrame:SetWidth(optionswidth);
3001 else
3002 CECBOptionsFrame:SetWidth(menuesizex);
3003 end
3004  
3005 if ((bgalpha + stepping) <= 1) then bgalpha = bgalpha + stepping;
3006 CECB_Options_Sub("alpha", bgalpha);
3007 else
3008 CECB_Options_Sub("alpha", 1);
3009 end
3010 else
3011 CECBOptionsFrame:SetHeight(menuesizey);
3012 CECB_Options_Sub("alpha", 1);
3013 end
3014 end
3015 end
3016  
3017 function CEnemyCastBar_FPSBar_OnUpdate() --FPSBar
3018  
3019 local framerate = GetFramerate();
3020 local g = framerate/30;
3021 local r = 30/framerate;
3022  
3023 if (g > 1) then g = 1; end
3024 if (r > 1) then r = 1; end
3025  
3026 if (framerate > 100) then frameratesafe = 100;
3027 else frameratesafe = framerate;
3028 end
3029  
3030 CECB_FPSBarFree_StatusBar:SetMinMaxValues(1,100);
3031 CECB_FPSBarFree_StatusBar:SetValue(frameratesafe);
3032 CECB_FPSBarFree_StatusBar_Spark:SetPoint("CENTER", "CECB_FPSBarFree_StatusBar", "LEFT", frameratesafe*1.95, 0);
3033 CECB_FPSBarFree_Text:SetText("|cffffffaaFPS: |cffffcc00"..ceil(framerate));
3034 CECB_FPSBarFree_StatusBar:SetStatusBarColor(r,g,0);
3035  
3036 end
3037  
3038 function CECB_MiniMap_Slider_OnShow()
3039 getglobal(this:GetName().."High"):SetText("360\194\176");
3040 getglobal(this:GetName().."Low"):SetText(CECB_minimapoff_txt);
3041  
3042 if (CEnemyCastBar.bMiniMap == 0) then
3043 getglobal(this:GetName() .. "Text"):SetText(CECB_minimap_txt .. CECB_minimapoff_txt);
3044 else
3045 getglobal(this:GetName() .. "Text"):SetText(CECB_minimap_txt .. CEnemyCastBar.bMiniMap .."\194\176");
3046 end
3047  
3048 this:SetMinMaxValues(0, 360);
3049 this:SetValueStep(2);
3050 this:SetValue(CEnemyCastBar.bMiniMap);
3051 end
3052  
3053 function CECB_MiniMap_Slider_OnValueChanged()
3054  
3055 CEnemyCastBar.bMiniMap = this:GetValue();
3056  
3057 if (CEnemyCastBar.bMiniMap == 0) then
3058 CECBMiniMapButton:Hide();
3059 getglobal(this:GetName() .. "Text"):SetText(CECB_minimap_txt .. CECB_minimapoff_txt);
3060 else
3061 CECBMiniMapButton:SetPoint("TOPLEFT", "Minimap", "TOPLEFT", 52 - (80 * cos(this:GetValue())), (80 * sin(this:GetValue())) - 52);
3062 CECBMiniMapButton:Show();
3063 getglobal(this:GetName() .. "Text"):SetText(CECB_minimap_txt .. CEnemyCastBar.bMiniMap .."\194\176");
3064 end
3065 end
3066  
3067 function CECB_scale_Slider_OnShow()
3068 getglobal(this:GetName().."High"):SetText("130%");
3069 getglobal(this:GetName().."Low"):SetText("30%");
3070  
3071 getglobal(this:GetName() .. "Text"):SetText(CECB_scale_txt .. CEnemyCastBar.bScale * 100 .. "%");
3072  
3073 this:SetMinMaxValues(0.3, 1.3);
3074 this:SetValueStep(0.1);
3075 this:SetValue(CEnemyCastBar.bScale);
3076 end
3077  
3078 function CECB_scale_Slider_OnValueChanged()
3079  
3080 local delta = abs(CEnemyCastBar.bScale - this:GetValue()) * 100;
3081 local BarScaleOld = CEnemyCastBar.bScale;
3082 -- DEFAULT_CHAT_FRAME:AddMessage("old: " .. CEnemyCastBar.bScale .. " | new: " .. this:GetValue() .." | delta "..delta)
3083  
3084 CEnemyCastBar.bScale = this:GetValue() * 10;
3085  
3086 if (CEnemyCastBar.bScale < 0) then
3087 CEnemyCastBar.bScale = ceil(CEnemyCastBar.bScale - 0.5)
3088 else
3089 CEnemyCastBar.bScale = floor(CEnemyCastBar.bScale + 0.5)
3090 end
3091  
3092 CEnemyCastBar.bScale = CEnemyCastBar.bScale / 10;
3093  
3094 getglobal(this:GetName() .. "Text"):SetText(CECB_scale_txt .. CEnemyCastBar.bScale * 100 .. "%");
3095  
3096 if (delta >= 1) then
3097  
3098 CEnemyCastBar_Handler("clear");
3099  
3100 local BarScaleFactor = BarScaleOld / CEnemyCastBar.bScale;
3101  
3102 local frame = getglobal("Carni_ECB_1");
3103 local p, rf, rp, x, y = frame:GetPoint();
3104  
3105 --DEFAULT_CHAT_FRAME:AddMessage("p="..p..", rp="..rp..", x="..x..", y="..y);
3106 x = (x + 102.5 - 102.5 * 1/BarScaleFactor)* BarScaleFactor;
3107 y = (y - 10 + 10 * 1/BarScaleFactor) * BarScaleFactor;
3108 frame:SetPoint("TOPLEFT", "UIParent", x, y);
3109  
3110 CEnemyCastBar_Show("Info", "New CastBarStyle!", 10.0, "friendly");
3111  
3112 end
3113  
3114 end
3115  
3116  
3117 function CECB_alpha_Slider_OnShow()
3118 getglobal(this:GetName().."High"):SetText("1");
3119 getglobal(this:GetName().."Low"):SetText("0.1");
3120  
3121 getglobal(this:GetName() .. "Text"):SetText(CECB_alpha_txt .. CEnemyCastBar.bAlpha);
3122  
3123 this:SetMinMaxValues(0.1, 1.0);
3124 this:SetValueStep(0.1);
3125 this:SetValue(CEnemyCastBar.bAlpha);
3126 end
3127  
3128 function CECB_alpha_Slider_OnValueChanged()
3129  
3130 local delta = abs(CEnemyCastBar.bAlpha - this:GetValue()) * 100;
3131  
3132 CEnemyCastBar.bAlpha = this:GetValue() * 10;
3133 if (CEnemyCastBar.bAlpha < 0) then
3134 CEnemyCastBar.bAlpha = ceil(CEnemyCastBar.bAlpha - 0.5)
3135 else
3136 CEnemyCastBar.bAlpha = floor(CEnemyCastBar.bAlpha + 0.5)
3137 end
3138 CEnemyCastBar.bAlpha = CEnemyCastBar.bAlpha / 10;
3139  
3140 getglobal(this:GetName() .. "Text"):SetText(CECB_alpha_txt .. CEnemyCastBar.bAlpha);
3141  
3142 CECB_PrintBar_OnMove(delta);
3143  
3144 end
3145  
3146 function CECB_numbars_Slider_OnShow()
3147 getglobal(this:GetName().."High"):SetText("20");
3148 getglobal(this:GetName().."Low"):SetText("5");
3149  
3150 getglobal(this:GetName() .. "Text"):SetText(CECB_numbars_txt .. CEnemyCastBar.bNumBars);
3151  
3152 this:SetMinMaxValues(5, 20);
3153 this:SetValueStep(1);
3154 this:SetValue(CEnemyCastBar.bNumBars);
3155 end
3156  
3157 function CECB_numbars_Slider_OnValueChanged()
3158  
3159 local delta = abs(CEnemyCastBar.bNumBars - this:GetValue()) * 10;
3160 --DEFAULT_CHAT_FRAME:AddMessage("old: " .. CEnemyCastBar.bNumBars .. " | new: " .. this:GetValue() .." | delta "..delta)
3161  
3162 if (delta >= 1) then
3163  
3164 CEnemyCastBar_Handler("clear");
3165  
3166 CEnemyCastBar.bNumBars = this:GetValue();
3167  
3168 getglobal(this:GetName() .. "Text"):SetText(CECB_numbars_txt .. CEnemyCastBar.bNumBars);
3169  
3170 for i=1, CEnemyCastBar.bNumBars do
3171 CEnemyCastBar_Show("Info", "CastBarNumbers", 5.0, "friendly");
3172 end
3173  
3174 end
3175  
3176 end
3177  
3178 function CECB_space_Slider_OnShow()
3179 getglobal(this:GetName().."High"):SetText("50");
3180 getglobal(this:GetName().."Low"):SetText("10");
3181  
3182 getglobal(this:GetName() .. "Text"):SetText(CECB_space_txt .. CEnemyCastBar.bSpace);
3183  
3184 this:SetMinMaxValues(10, 50);
3185 this:SetValueStep(1);
3186 this:SetValue(CEnemyCastBar.bSpace);
3187 end
3188  
3189 function CECB_space_Slider_OnValueChanged()
3190  
3191 local delta = abs(CEnemyCastBar.bSpace - this:GetValue()) * 10;
3192  
3193 if (delta >= 1) then
3194  
3195 CEnemyCastBar_Handler("clear");
3196  
3197 CEnemyCastBar.bSpace = this:GetValue();
3198  
3199 getglobal(this:GetName() .. "Text"):SetText(CECB_space_txt .. CEnemyCastBar.bSpace);
3200  
3201 CEnemyCastBar_FlipBars(); -- sets the space, too!
3202 for i=1, CEnemyCastBar.bNumBars do
3203 CEnemyCastBar_Show("Info", "Space between CastBars!", 5.0, "friendly", nil, "Spell_Holy_Renew");
3204 end
3205  
3206 end
3207  
3208 end
3209  
3210 function CECB_PrintBar_OnMove(delta)
3211  
3212 if (delta >= 1) then
3213  
3214 CEnemyCastBar_Handler("clear");
3215  
3216 CEnemyCastBar_Show("Info", "New CastBarStyle!", 10.0, "friendly");
3217  
3218  
3219 end
3220 end
3221  
3222 function CECB_GCInfo_OnUpdate()
3223  
3224 local GCTime = GetTime();
3225  
3226 if (not lastgcupdate or GCTime - lastgcupdate > 0.5) then
3227 lastgcupdate = GCTime;
3228  
3229 local cecbgc_now, cecbgc_max = gcinfo();
3230  
3231 if (not cecbgc_last or cecbgc_last > cecbgc_now) then
3232 cecbgc_last = cecbgc_now;
3233 cecbgc_min = cecbgc_now;
3234 cecbgc_minupdate = GCTime;
3235 lastgcdiffupdate = nil;
3236 cecbgc_purge30 = 0;
3237 end
3238  
3239 if (not lastgcdiffupdate or GCTime - lastgcdiffupdate > 5) then
3240 lastgcdiffupdate = GCTime;
3241  
3242 cecbgcdiff = (cecbgc_now - cecbgc_last) / 5;
3243 cecbgc_last = cecbgc_now;
3244  
3245 local GCPurgeCalcLength = 30;
3246 if ((GCTime - cecbgc_minupdate) > GCPurgeCalcLength) then
3247 if (cecbgc_min == cecbgc_now) then
3248 cecbgc_purge30 = 0;
3249 else
3250 cecbgc_purge30 = (cecbgc_max - cecbgc_now) * (GCTime - cecbgc_minupdate) / (cecbgc_now - cecbgc_min);
3251 end
3252 cecbgc_min = cecbgc_now;
3253 cecbgc_minupdate = GCTime;
3254 end
3255  
3256 if (cecbgc_min == cecbgc_now and cecbgc_purge30 == 0) then
3257 cecbgcpurge = "waiting...";
3258 else
3259 if (cecbgc_min == cecbgc_now) then
3260 cecbgcpurge = cecbgc_purge30;
3261 else
3262 if (GCTime - cecbgc_minupdate > GCPurgeCalcLength or cecbgc_purge30 == 0) then
3263 cecbgcpurge = (cecbgc_max - cecbgc_now) * (GCTime - cecbgc_minupdate) / (cecbgc_now - cecbgc_min);
3264 else
3265 cecbgcpurge = (cecbgc_purge30 * (GCPurgeCalcLength - (GCTime - cecbgc_minupdate)) / GCPurgeCalcLength) + (cecbgc_max - cecbgc_now) * (GCTime - cecbgc_minupdate) / (cecbgc_now - cecbgc_min) * (GCTime - cecbgc_minupdate) / GCPurgeCalcLength;
3266 end
3267 end
3268  
3269 if (cecbgcpurge >= 3600) then
3270 cecbgcpurge = string.format("%d:%02d (|cffffccccHour|r:|cffccffccMin|r)", cecbgcpurge / 3600, math.mod(cecbgcpurge / 60, 60));
3271 elseif (cecbgcpurge >= 60) then
3272 cecbgcpurge = string.format("%d:%02d (|cffccffccMin|r:|cffccccffSec|r)", cecbgcpurge / 60, math.mod(cecbgcpurge, 60));
3273 else
3274 cecbgcpurge = string.format("%d (|cffccccffSeconds|r)", cecbgcpurge);
3275 end
3276 end
3277  
3278 end
3279  
3280 local gctext1 = "|cffffff00This is a simple tool to observe the memory usage of all your addons!\n\n";
3281 local gctext2 = "|cffcccc00Estimated time until purge: |r"..cecbgcpurge.."\n\n";
3282 local gctext3 = "|cffccccffUsed Memory |r- |cffffccccGainRate |r- |cffccffccMaximum\n";
3283 local gctext4 = "|cff9999ff"..cecbgc_now.."|rkb - |cffff9999"..cecbgcdiff.."|rkb/s - |cff99ff99"..cecbgc_max.."|rkb";
3284 CECBGCFrameBGText:SetText(gctext1..gctext2..gctext3..gctext4, 0.8, 0.8, 0.8);
3285  
3286 end
3287  
3288 end
3289  
3290 function CEnemyCastBar_Validchar(msg) --validchar
3291  
3292 value = true;
3293  
3294 for i = 1, string.len(msg) do
3295  
3296 local ctable = string.byte(string.sub(msg,i,i));
3297 if ( not ( (ctable >= 48 and ctable <= 57) or (ctable >= 65 and ctable <= 90) or (ctable >= 97 and ctable <= 122) ) ) then
3298 value = false;
3299 end
3300 end
3301  
3302 return value;
3303 end
3304  
3305 function CEnemyCastBar_LoadDisabledSpells(msg) --loaddisabled
3306  
3307 DisabledSpells = { };
3308  
3309 local i = 1;
3310 while (CEnemyCastBar.tDisabledSpells[i]) do
3311  
3312 local spell = CEnemyCastBar.tDisabledSpells[i];
3313 if (CEnemyCastBar_Raids[spell]) then
3314 CEnemyCastBar_Raids[spell].disabled = true;
3315 end
3316  
3317 if (CEnemyCastBar_Spells[spell]) then
3318 CEnemyCastBar_Spells[spell].disabled = true;
3319 end
3320  
3321 if (CEnemyCastBar_Afflictions[spell]) then
3322 CEnemyCastBar_Afflictions[spell].disabled = true;
3323 end
3324  
3325 table.insert (DisabledSpells, CEnemyCastBar.tDisabledSpells[i]);
3326 i = i + 1;
3327 end
3328  
3329 if (not msg) then
3330 if (table.getn (DisabledSpells) == 0) then
3331 DSpells = "Nothing disabled found! |rEmpty table loaded.";
3332 else
3333 i = i - 1;
3334 DSpells = i.." |rDisabled Spells loaded. (see |cff00ff00/necb disabled|r)";
3335 end
3336 DEFAULT_CHAT_FRAME:AddMessage("|cffaaaaaaNECB:|cffffff00 "..DSpells);
3337 end
3338  
3339 end