vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2  
3 Carnival_EnemyCastBar
4  
5 Description:
6 ------------
7 Displays a replication of your targets spell casting bar on your UI, which can be moved around.
8 Spell casting time is not something that is available to your WoW client, so I have provided cast times for most (if not all spells).
9 As talents can be a factor on the cast time of some spells, the lowest cast time possible is used
10 ie. all Shadow Bolt cast times will display at 2.5 seconds even though the player you have targetted doesnt have those specific talents.
11 Interruptions on your target, ie. they get hit, will not adjust the display on your cast bar, as again, its impossible to know if it affected the cast.
12 This currently works for both Alliance and Horde, but has only been really tested playing against alliance characters.
13 Will display either a green cast bar for friendly targets, or a red for a hostile target.
14  
15 To move the bars, simply target someone and wait for them to do something, when they do, simply click and drag the FIRST bar that appears.
16 This might take a few tries, just get a friend to cast their Hearthstone while you have them targetted and this becomes a whole lot easier :)
17  
18 I do intend to develop this further, just a lot of people who I told about this are extremly interested in getting their grubby little paws on it.
19 So this is only an alpha release, as it currently doesnt do everything I want it to.
20  
21 Expect a new version soon!
22  
23  
24 Support:
25 --------
26 Either reply on the website you downloaded this from (www.curse-gaming.com or http://ui.worldofwar.net) or on my guilds forums (http://www.carnivalguild.co.uk)
27  
28  
29 Author:
30 -------
31 Miranda on Al'Akir (EU)
32 But please, don't ask me for support while im in game!
33 If you want to thank me however, feel free :)
34  
35  
36 Revision History:
37 -----------------
38 18/01/06 v1.0 ALPHA
39 * Initial Alpha Release
40  
41 24/01/06 v1.1 BETA
42 * Adjusted bars so that they "grow" from the bottom up
43 * Adjusted cast time on several spells,
44 * Added timers for warlock pet spells,
45 * Added timers for most trinkets, talisman of power, zandalarian hero charm, to show remaining time
46 * Added timers for gained abilities, arcane power, sprint, to show remaining time,
47 * Added timers for racial talents, perception, war stomp, will of the forsaken, to show cast time or remaining time depending on the talent,
48 * Added timers for various PvE events,
49 - Molten Core
50 - Lucifron (Impending Doom, Lucifron's Curse)
51 - Magmadar (Fear)
52 - Gehennas (Gehennas' Curse)
53 - Majordomo (Magic Reflection, Damage Shield)
54 - Ragnaros (Submerge, Knockback and Sons of the Flame)
55 - Blackwing Lair
56 - Firemaw (Wing Buffet, Shadow Flame)
57 - Ebonroc (Wing Buffet, Shadow Flame)
58 - Flamegor (Wing Buffet, Shadow Flame)
59 - Chromaggus (Frost Burn, Time Lapse, Ignite Flesh, Corrosive Acid, Incinerate)
60 - Neferian (Event Start, Bellowing Roar, Class Calls)
61 * Fixed some possibly laggy code
62  
63 24/01/06 v1.2 BETA
64 * Fixed a major problem with the XML frame
65  
66 27/01/06 v1.3 BETA
67 * Added Slash Commands
68 - /cenemycast enable/disable
69 - /cenemycast show
70 - /cenemycast pvp
71 - /cenemycast pve
72 * Fixed issue with "X gains Y" events
73 * Added Stoneform,
74 * Added Shadowguard,
75 * Added Priest - Mana Burn,
76 * Added Priest - Holy Fire,
77 * Added Priest - Mind Soothe,
78 * Added Priest - Prayer of Healing,
79 * Added Priest - Shackle Undead,
80 * Added Druid - Hibernate,
81 * Added Druid - Soothe Animal,
82 * Added Druid - Bark Skin,
83 * Added Druid - Innervate,
84 * Added Mage - Conjure Mana Ruby,
85 * Added Mage - Conjure Mana Citrine,
86 * Added Mage - Conjure Mana Jade,
87 * Added Mage - Conjure Mana Agate,
88 * Added Mage - Slow Fall,
89 * Added Warrior - Bloodrage,
90 * Added Warrior - Shield Wall,
91 * Added Warrior - Recklessness,
92 * Added Warrior - Berserker Rage,
93  
94 31/01/06 v1.4 BETA
95 * Fixed an error about FADESTEP,
96 * Fixed problem with Bellowing Roar on Nefarian/Onyxia, Onyxia's is 1.5sconds, Nefarain's is 2.0seconds
97 * Fixed debug output saying "ECB Control - Running i"
98 * Added cooldown data to the spell database, however the data is not in use yet
99 * Added timer for Hakkar in Zul'Gurrub
100 * Added German localization!
101 * Added /ecb lock - Locks or Unlocks the Casting Bars
102 * Added /ecb reset - Resets the bar position
103 * Adjusted Mage - Fireball,
104 * Adjusted Driud - Bark Skin,
105 * Adjusted Driud - Innervate,
106 * Adjusted Druid - Healing Touch,
107 * Adjusted Druid - Regrowth,
108 * Adjusted Hunter - Scare Beast,
109 * Adjusted Mage - Conjure Water,
110 * Adjusted Mage - Conjure Food,
111 * Adjusted Paladin - Howl of Terror,
112 * Adjusted Paladin - Summon Charger,
113 * Adjusted Paladin - Summon Warhorse
114 * Adjusted Warlock - Summon Felsteed,
115 * Adjusted Warlock - Summon Dreadsteed,
116 * Adjusted Warlock - Imp - Firebolt,
117 * Adjusted Warrior - Slam,
118 * Added Paladin - Divine Protection,
119 * Added Paladin - Divine Shield,
120 * Added Hunter - Dismiss Pet,
121 * Added Hunter - Revive Pet,
122 * Added Hunter - Eyes of the Beast,
123 * Added Hunter - Rapid Fire,
124 * Added Mage - Fire Ward,
125 * Added Mage - Frost Ward,
126 * Added Mage - Teleport: Darnassus,
127 * Added Mage - Teleport: Thunder Bluff,
128 * Added Mage - Teleport: Ironforge,
129 * Added Mage - Teleport: Orgrimmar,
130 * Added Mage - Teleport: Stormwind,
131 * Added Mage - Teleport: Undercity,
132 * Added Mage - Portal: Darnassus,
133 * Added Mage - Portal: Thunder Bluff,
134 * Added Mage - Portal: Ironforge,
135 * Added Mage - Portal: Orgrimmar,
136 * Added Mage - Portal: Stormwind,
137 * Added Mage - Portal: Undercity,
138 * Added Druid - Teleport: Moonglade,
139 * Added Druid - Tiger's Fury,
140 * Added Druid - Frenzied Regeneration,
141 * Added Druid - Rejuvenation
142 * Added Druid - Abolish Poison
143 * Added Priest - Fade,
144 * Added Priest - Renew,
145 * Added Priest - Abolish Disease,
146 * Added Rogue - Evasion,
147 * Added Rogue - Mind-numbing Poison,
148 * Added Rogue - Mind-numbing Poison II,
149 * Added Rogue - Mind-numbing Poison III,
150 * Added Rogue - Pick Lock,
151 * Added Shaman - Far Sight,
152 * Added Shaman - Fire Nova Totem,
153 * Added Shaman - Mana Tide Totem,
154 * Added Shaman - Stoneclaw Totem,
155 * Added Warrior - Slam,
156 * Added Warrior - Retaliation,
157 * Added Warlock - Ritual of Doom,
158 * Added Warlock - Enslave Demon,
159 * Added Warlock - Inferno,
160 * Added Warlock - Shadow Ward,
161 * Added Warlock - Create Spellstone,
162 * Added Warlock - Create Healthstone,
163 * Added Warlock - Create Soulstone,
164 * Added Warlock - Create Firestone,
165 * Added Warlock - Voidwalker - Consume Shadows,
166  
167 20/02/06 v1.5
168 * Added French Localization
169 * Added "/cenemycast timer" to toggle the timer text
170 * Fixed the time issue with Flamestrike and BWL mobs
171 * Fixed Nefarian/Ragnaros Timers so that they actually work
172 * Fixed (maybe) the issue with the bars not locking
173 * Fixed (maybe) the issue with multiple bars for the same mob (BWL Drakes)
174 * Fixed most (if not all) the issues with some PvE bars not appearing on MC bosses
175 * Removed the /ecb alias so that it doesnt clash with eCastingBar
176 * Guessed at a fix for the clash with WarriorAlert
177 * Added PvE - BWL - Flamegor - Frenzy
178 * Added PvE - BWL - Chromaggus - Frenzy
179 * Added PvE - BWL - Nefarian - Landing Warning
180 * Added PvE - Outdoor - Azuregos - Manastorm
181 * Added PvE - AQ40 - Obsidian Eradicator Respawn - 15minutes
182 * Added PvE - AQ20 - Anubisath - Explode - 5 seconds?
183 * Added General - First Aid - 8 seconds
184 * Added Engineering - Frost Reflector
185 * Added Engineering - Shadow Reflector
186 * Added Engineering - Fire Reflector
187 * (Reflectors *should* work, however have had NO testing)
188 * Added Mage - Ice Block - 10 seconds
189 * Added Paladin - Blessing of Freedom - 16 seconds
190 * Added Paladin - Blessing of Protection - 10 seconds
191 * Added Paladin - Blessing of Sacrifice - 10 seconds
192 * Adjusted - Hakkar - Blood Siphon - 90 seconds
193 * Adjusted - Warlock - Summon Imp - 6 seconds
194 * Adjusted - Warlock - Summon Succubus - 6 seconds
195 * Adjusted - Warlock - Summon Voidwalker - 6 seconds
196 * Adjusted - Warlock - Summon Felhunter - 6 seconds
197  
198 21/02/06 v1.6
199 * Fixed problem with French localization
200 * Fixed problem with German localization
201 * Adjusted PvE - AQ20 - Anubisath - Explode - 6 seconds
202  
203 ]]--
204  
205 carniactive = true;
206 mobname = "Mob";
207 mob = "Mob";
208 spell = "Cast Bar";
209  
210 function ECB_RegisterUltimateUI()
211 UltimateUI_RegisterConfiguration(
212 "UUI_ECB",
213 "SECTION",
214 "Enemy Cast Bar",
215 "Options to show castbars of other players / npcs."
216 );
217 UltimateUI_RegisterConfiguration(
218 "UUI_ECB_SEPARATOR",
219 "SEPARATOR",
220 "Enemy Cast Bar",
221 "Options to show castbars of other players / npcs."
222 );
223 UltimateUI_RegisterConfiguration(
224 "UUI_ECB_ENABLE",
225 "CHECKBOX",
226 "Enable / Disable ECB",
227 "Check or uncheck this box to enable or disable Enemy Cast Bar.",
228 ECB_Enable,
229 1
230 );
231 UltimateUI_RegisterConfiguration(
232 "UUI_ECB_LOCK",
233 "CHECKBOX",
234 "Lock",
235 "Check or uncheck this box to lock ECB to it's current position.",
236 Carnival_EnemyCastBar_LockPos,
237  
238 );
239 UltimateUI_RegisterConfiguration(
240 "UUI_ECB_RESET_POSITION",
241 "BUTTON",
242 "",
243 "",
244 Carnival_EnemyCastBar_ResetPos,
245 0,
246 0,
247 0,
248 0,
249 "Reset Position"
250 );
251 UltimateUI_RegisterConfiguration(
252 "UUI_ECB_TEST",
253 "BUTTON",
254 "",
255 "",
256 ECB_Test,
257 0,
258 0,
259 0,
260 0,
261 "Show"
262 );
263 UltimateUI_RegisterConfiguration(
264 "UUI_ECB_TIMER",
265 "CHECKBOX",
266 "Show Time on ECB",
267 "Show or hide Cast Bar time.",
268 ECB_Timer,
269 1
270 );
271 UltimateUI_RegisterConfiguration(
272 "UUI_ECB_PVE",
273 "CHECKBOX",
274 "Show PvE Spells",
275 "Enables or disables ECB from showing PvE only spells.",
276 ECB_PVE,
277 1
278 );
279 UltimateUI_RegisterConfiguration(
280 "UUI_ECB_PVP",
281 "CHECKBOX",
282 "Show PvP Spells",
283 "Enables or disables ECB from showing PvP only spells.",
284 ECB_PVP,
285 1
286 );
287 end
288  
289 function Carnival_EnemyCastBar_OnLoad()
290  
291 this:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_DAMAGE");
292 this:RegisterEvent("CHAT_MSG_SPELL_HOSTILEPLAYER_BUFF");
293  
294 this:RegisterEvent("CHAT_MSG_SPELL_FRIENDLYPLAYER_DAMAGE");
295 this:RegisterEvent("CHAT_MSG_SPELL_FRIENDLYPLAYER_BUFF");
296  
297 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_BUFFS");
298 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_BUFFS");
299  
300 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE");
301 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_FRIENDLYPLAYER_DAMAGE");
302 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_DAMAGE");
303  
304 this:RegisterEvent("CHAT_MSG_SPELL_PARTY_DAMAGE");
305 this:RegisterEvent("CHAT_MSG_SPELL_PARTY_BUFF");
306  
307 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_PARTY_DAMAGE");
308 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_PARTY_BUFFS");
309  
310 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE");
311 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_BUFFS");
312 this:RegisterEvent("CHAT_MSG_SPELL_CREATURE_VS_CREATURE_DAMAGE");
313  
314 this:RegisterEvent("CHAT_MSG_MONSTER_YELL");
315 this:RegisterEvent("CHAT_MSG_MONSTER_EMOTE");
316  
317 this:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH");
318  
319 this:RegisterEvent("VARIABLES_LOADED");
320  
321  
322 SLASH_CARNIVALENEMYCASTBAR1 = "/cenemycast";
323 SLASH_CARNIVALENEMYCASTBAR2 = "/cecb";
324 SlashCmdList["CARNIVALENEMYCASTBAR"] = function(msg)
325 Carnival_EnemyCastBar_Handler(msg);
326 end
327  
328 for i=1, 20 do
329  
330 local button = getglobal("Carni_ECB_"..i);
331 button:Hide();
332  
333 end
334  
335 if ( not Carnival_EnemyCastBar ) then
336  
337 Carnival_EnemyCastBar = { };
338 Carnival_EnemyCastBar.bStatus = true;
339 Carnival_EnemyCastBar.bPvP = true;
340 Carnival_EnemyCastBar.bPvE = true;
341 Carnival_EnemyCastBar.bLocked = true;
342 Carnival_EnemyCastBar.bDebug = true;
343 Carnival_EnemyCastBar.bTimer = true;
344  
345 for i=1, 20 do
346  
347 local frame = getglobal("Carni_ECB_"..i);
348 frame:StopMovingOrSizing();
349 frame:EnableMouse(0);
350 Carnival_EnemyCastBar.bLocked = true;
351  
352 end
353  
354 end
355 end
356  
357 function Carnival_EnemyCastBar_OnClick()
358  
359 if ( arg1 == "LeftButton" ) then
360  
361 DEFAULT_CHAT_FRAME:AddMessage("ECB - LeftButton");
362  
363 elseif ( arg1 == "RightButton" ) then
364  
365 DEFAULT_CHAT_FRAME:AddMessage("ECB - RightButton");
366  
367 end
368  
369 end
370  
371 function Carnival_EnemyCastBar_LockPos()
372  
373 Carnival_EnemyCastBar.bLocked = not Carnival_EnemyCastBar.bLocked;
374  
375 if (Carnival_EnemyCastBar.bLocked) then
376  
377 for i=1, 20 do
378  
379 local frame = getglobal("Carni_ECB_"..i);
380 frame:StopMovingOrSizing();
381 frame:EnableMouse(0);
382  
383 end
384  
385 --DEFAULT_CHAT_FRAME:AddMessage("Carnival_EnemyCastBar - Bars Locked");
386  
387 else
388  
389 for i=1, 20 do
390  
391 local frame = getglobal("Carni_ECB_"..i);
392 frame:EnableMouse(1);
393  
394 end
395  
396 -- DEFAULT_CHAT_FRAME:AddMessage("Carnival_EnemyCastBar - Bars Unlocked");
397  
398 end
399  
400 end
401  
402 function Carnival_EnemyCastBar_ResetPos()
403  
404 local frame = getglobal("Carni_ECB_1");
405 frame:Hide();
406 frame:ClearAllPoints();
407 frame:SetPoint("BOTTOMLEFT", "UIParent", "CENTER", 0, 0);
408  
409 for i=2, 20 do
410  
411 o = i - 1;
412 local frame = getglobal("Carni_ECB_"..i);
413 frame:Hide();
414 frame:ClearAllPoints();
415 frame:SetPoint("TOPLEFT", "Carni_ECB_"..o, "TOPLEFT", 0, 20);
416  
417 end
418  
419 end
420  
421 function Carnival_EnemyCastBar_Options(var)
422  
423 if (var) then
424  
425 return "on";
426  
427 else
428  
429 return "off";
430  
431 end
432  
433 end
434  
435 function ECB_Enable(arg)
436 if( arg == 1 ) then
437 Carnival_EnemyCastBar.bStatus = true;
438 --DEFAULT_CHAT_FRAME:AddMessage("ECB Addon is now enabled")
439 elseif( arg == 0) then
440 Carnival_EnemyCastBar.bStatus = false;
441 --DEFAULT_CHAT_FRAME:AddMessage("ECB Addon is now disabled")
442 else
443 DEFAULT_CHAT_FRAME:AddMessage("ECB_Enable(arg) returned invalid arg.");
444 end
445 end
446  
447 function ECB_Test()
448 Carnival_EnemyCastBar_Show("Mob", "Spell Name", 10.0, "friendly");
449 end
450  
451 function ECB_Timer(arg)
452 if( arg == 1 ) then
453 Carnival_EnemyCastBar.bTimer = true;
454 --DEFAULT_CHAT_FRAME:AddMessage("Cast Bars time display enabled")
455 elseif( arg == 0) then
456 Carnival_EnemyCastBar.bTimer = false;
457 --DEFAULT_CHAT_FRAME:AddMessage("Cast Bar time display disabled")
458 else
459 DEFAULT_CHAT_FRAME:AddMessage("ECB_Timer(arg) returned invalid arg.");
460 end
461 end
462  
463 function ECB_PVE(arg)
464 if( arg == 1 ) then
465 Carnival_EnemyCastBar.bPvE = true;
466 --DEFAULT_CHAT_FRAME:AddMessage("Cast Bars for PvE spells are now enabled")
467 elseif( arg == 0) then
468 Carnival_EnemyCastBar.bPvE = false;
469 --DEFAULT_CHAT_FRAME:AddMessage("Cast Bars for PvE spells are now disabled")
470 else
471 DEFAULT_CHAT_FRAME:AddMessage("ECB_PVE(arg) returned invalid arg.");
472 end
473 end
474  
475 function ECB_PVP(arg)
476 if( arg == 1 ) then
477 Carnival_EnemyCastBar.bPvP = true;
478 --DEFAULT_CHAT_FRAME:AddMessage("Cast Bars for PvP spells are now enabled")
479 elseif( arg == 0) then
480 Carnival_EnemyCastBar.bPvP = false;
481 --DEFAULT_CHAT_FRAME:AddMessage("Cast Bars for PvP spells are now disabled")
482 else
483 DEFAULT_CHAT_FRAME:AddMessage("ECB_PVP(arg) returned invalid arg.");
484 end
485 end
486  
487 function Carnival_EnemyCastBar_Handler(msg)
488  
489 if (msg == "") then
490  
491 DEFAULT_CHAT_FRAME:AddMessage("<Carnival> PvE/PvP Enemy Cast Bar")
492 DEFAULT_CHAT_FRAME:AddMessage("/cenemycast enable/disable ("..Carnival_EnemyCastBar_Options(Carnival_EnemyCastBar.bStatus)..") - Enables or Disables the Addon")
493 DEFAULT_CHAT_FRAME:AddMessage("/cenemycast show - Shows the bar, this will allow you to move it around")
494 DEFAULT_CHAT_FRAME:AddMessage("/cenemycast reset - Resets the bars to their original position")
495 DEFAULT_CHAT_FRAME:AddMessage("/cenemycast lock - Toggle - Will lock and unlock the bars into position")
496 DEFAULT_CHAT_FRAME:AddMessage("/cenemycast pvp ("..Carnival_EnemyCastBar_Options(Carnival_EnemyCastBar.bPvP)..") - Toggles the cast bar for PvP spells on and off")
497 DEFAULT_CHAT_FRAME:AddMessage("/cenemycast pve ("..Carnival_EnemyCastBar_Options(Carnival_EnemyCastBar.bPvE)..") - Toggles the cast bar for PvE spells on and off")
498 DEFAULT_CHAT_FRAME:AddMessage("/cenemycast timer ("..Carnival_EnemyCastBar_Options(Carnival_EnemyCastBar.bTimer)..") - Toggles the cast bar timer text on and off")
499  
500 elseif (msg == "enable") then
501  
502 Carnival_EnemyCastBar.bStatus = true;
503 DEFAULT_CHAT_FRAME:AddMessage("Addon is now enabled")
504  
505 elseif (msg == "disable") then
506  
507 Carnival_EnemyCastBar.bStatus = false;
508 DEFAULT_CHAT_FRAME:AddMessage("Addon is now disabled")
509  
510 elseif (msg == "lock") then
511  
512 Carnival_EnemyCastBar_LockPos()
513  
514 elseif (msg == "reset") then
515  
516 Carnival_EnemyCastBar_ResetPos()
517 DEFAULT_CHAT_FRAME:AddMessage("Bars are now reset")
518  
519 elseif (msg == "show") then
520  
521 Carnival_EnemyCastBar_Show("Mob", "Spell Name", 10.0, "friendly");
522  
523 elseif (msg == "timer") then
524  
525 if (Carnival_EnemyCastBar.bTimer) then
526  
527 Carnival_EnemyCastBar.bTimer = false;
528 DEFAULT_CHAT_FRAME:AddMessage("Cast Bar time display disabled")
529  
530 else
531  
532 Carnival_EnemyCastBar.bTimer = true;
533 DEFAULT_CHAT_FRAME:AddMessage("Cast Bars time display enabled")
534  
535 end
536  
537 elseif (msg == "pvp") then
538  
539 if (Carnival_EnemyCastBar.bPvP) then
540  
541 Carnival_EnemyCastBar.bPvP = false;
542 DEFAULT_CHAT_FRAME:AddMessage("Cast Bars for PvP spells are now disabled")
543  
544 else
545  
546 Carnival_EnemyCastBar.bPvP = true;
547 DEFAULT_CHAT_FRAME:AddMessage("Cast Bars for PvP spells are now enabled")
548  
549 end
550  
551 elseif (msg == "pve") then
552  
553 if (Carnival_EnemyCastBar.bPvE) then
554  
555 Carnival_EnemyCastBar.bPvE = false;
556 DEFAULT_CHAT_FRAME:AddMessage("Cast Bars for PvE spells are now disabled")
557  
558 else
559  
560 Carnival_EnemyCastBar.bPvE = true;
561 DEFAULT_CHAT_FRAME:AddMessage("Cast Bars for PvE spells are now enabled")
562  
563 end
564  
565 end
566  
567 end
568  
569 function Carnival_EnemyCastBar_Show(mob, spell, castime, ctype)
570  
571 local showing = false;
572 local i = 1;
573 local o = 20;
574  
575 while (i < o) do
576  
577 local button = getglobal("Carni_ECB_"..i);
578  
579 if (not button:IsVisible()) then
580  
581 if (showing == false) then
582  
583 if (ctype == "hostile") then
584  
585 red = 1.0;
586 green = 0.0;
587 blue = 0.0;
588  
589 elseif (ctype == "friendly") then
590  
591 red = 0.0;
592 green = 1.0;
593 blue = 0.0;
594  
595 elseif (ctype == "cooldown") then
596  
597 red = 0.0;
598 green = 0.0;
599 blue = 1.0;
600  
601 elseif (ctype == "gains") then
602  
603 red = 1.0;
604 green = 0.0;
605 blue = 1.0;
606  
607 end
608  
609 getglobal("Carni_ECB_"..i).startTime = GetTime();
610 getglobal("Carni_ECB_"..i).active = true;
611 getglobal("Carni_ECB_"..i).label = mob .." - ".. spell;
612 getglobal("Carni_ECB_"..i).spell = spell;
613 getglobal("Carni_ECB_"..i).endTime = getglobal("Carni_ECB_"..i).startTime + castime;
614 getglobal("Carni_ECB_"..i.."_StatusBar"):SetMinMaxValues(button.startTime,button.endTime);
615 getglobal("Carni_ECB_"..i.."_StatusBar"):SetValue(button.startTime);
616 getglobal("Carni_ECB_"..i.."_StatusBar"):SetStatusBarColor(red, green, blue);
617 button:Show();
618 showing = true;
619  
620 end
621  
622 end
623  
624 i = i + 1;
625  
626 end
627  
628 showing = false;
629  
630 end
631  
632 function Carnival_EnemyCastBar_OnEvent(event)
633  
634 if (event == "VARIABLES_LOADED") then
635 if (UltimateUI_RegisterConfiguration) then
636 ECB_RegisterUltimateUI();
637 end
638 end
639  
640 if (event == "CHAT_MSG_MONSTER_YELL") then
641  
642 if (Carnival_EnemyCastBar.bDebug) then
643  
644 DEFAULT_CHAT_FRAME:AddMessage("EVENT: "..event)
645  
646 end
647  
648 Carnival_EnemyCastBar_Yells(arg1, arg2);
649  
650 elseif (event == "CHAT_MSG_MONSTER_EMOTE") then
651  
652 Carnival_EnemyCastBar_Emotes(arg1, arg2);
653  
654 else
655  
656 Carnival_EnemyCastBar_Gfind(arg1);
657  
658 end
659  
660 end
661  
662  
663  
664 function Carnival_EnemyCastBar_Gfind(arg1)
665  
666 if (Carnival_EnemyCastBar.bStatus) then
667  
668 if (arg1 ~= nil) then
669  
670 for mob, spell in string.gfind(arg1, Carnival_EnemyCastBar_SPELL_CAST) do
671  
672 Carnival_EnemyCastBar_Control(mob, spell, "casts");
673 return;
674  
675 end
676  
677 for mob, spell in string.gfind(arg1, Carnival_EnemyCastBar_SPELL_PERFORM) do
678  
679 Carnival_EnemyCastBar_Control(mob, spell, "performs");
680 return;
681  
682 end
683  
684 for mob, spell in string.gfind(arg1, Carnival_EnemyCastBar_SPELL_GAINS) do
685  
686 Carnival_EnemyCastBar_Control(mob, spell, "gains");
687 return;
688  
689 end
690  
691 for mob in string.gfind(arg1, Carnival_EnemyCastBar_MOB_DIES) do
692  
693 Carnival_EnemyCastBar_Control(mob, mob, "cooldown");
694 return;
695  
696 end
697  
698 for mob, crap, spell in string.gfind(arg1, Carnival_EnemyCastBar_SPELL_AFFLICTED) do
699  
700 Carnival_EnemyCastBar_Control(mob, spell, "afflicted");
701 return;
702  
703 end
704  
705 for mob, damage, from, spell in string.gfind(arg1, Carnival_EnemyCastBar_SPELL_DAMAGE) do
706  
707 if (mob == "Hakkar") then
708  
709 Carnival_EnemyCastBar_Control(mob, spell, "yells");
710 return;
711  
712 end
713  
714 end
715  
716 end
717  
718 end
719  
720 end
721  
722 function Carnival_EnemyCastBar_UniqueCheck(spellname)
723  
724 alreadyshowing = 0;
725  
726 for i=1, 20 do
727  
728 local spell = getglobal("Carni_ECB_"..i).spell;
729  
730 if (spell == spellname) then
731  
732 alreadyshowing = 1;
733  
734 end
735  
736 end
737  
738 return alreadyshowing;
739  
740 end
741  
742 function Carnival_EnemyCastBar_Control(mob, spell, special)
743  
744 --DEFAULT_CHAT_FRAME:AddMessage("ECB Control - "..mob.." ("..spell..")");
745  
746 if (Carnival_EnemyCastBar_Raids[spell] ~= nil) then
747  
748 if (Carnival_EnemyCastBar.bPvE) then
749  
750 castime = Carnival_EnemyCastBar_Raids[spell].t;
751 ctype = Carnival_EnemyCastBar_Raids[spell].c;
752  
753 -- Spell might have the same name but a different cast time on another mob, ie. Onyxia/Nefarian on Bellowing Roar
754 if (Carnival_EnemyCastBar_Raids[spell].r) then
755  
756 if (mob == Carnival_EnemyCastBar_Raids[spell].r) then
757  
758 castime = Carnival_EnemyCastBar_Raids[spell].a;
759  
760 end
761  
762 end
763  
764 if (Carnival_EnemyCastBar_Raids[spell].m) then
765  
766 mob = Carnival_EnemyCastBar_Raids[spell].m
767  
768 end
769  
770 alreadyshowing = 0;
771  
772 if (Carnival_EnemyCastBar_Raids[spell].u) then
773  
774 unique = Carnival_EnemyCastBar_Raids[spell].u
775  
776 if (unique == "true") then
777  
778 alreadyshowing = Carnival_EnemyCastBar_UniqueCheck(spell)
779  
780 end
781  
782 end
783  
784 if (alreadyshowing == 0) then
785  
786 Carnival_EnemyCastBar_Show(mob, spell, castime, ctype);
787  
788 end
789  
790 if (Carnival_EnemyCastBar_Raids[spell].i ~= nil) then
791  
792 if (alreadyshowing == 0) then
793  
794 --DEFAULT_CHAT_FRAME:AddMessage("ECB Control - Running i");
795 castime = Carnival_EnemyCastBar_Raids[spell].i;
796 Carnival_EnemyCastBar_Show(mob, spell, castime, "hostile");
797  
798 end
799  
800 end
801  
802 end
803  
804 else
805  
806 if (Carnival_EnemyCastBar.bPvP) then
807  
808 if (UnitName("target") == mob) then
809  
810 if (Carnival_EnemyCastBar_Spells[spell] ~= nil) then
811  
812 if (UnitIsEnemy("player", "target")) then
813 ctype = "hostile";
814 else
815 ctype = "friendly";
816 end
817  
818 if (Carnival_EnemyCastBar_Spells[spell].i ~= nil) then
819  
820 castime = Carnival_EnemyCastBar_Spells[spell].i;
821 Carnival_EnemyCastBar_Show(mob, spell, castime, ctype);
822  
823 end
824  
825 castime = Carnival_EnemyCastBar_Spells[spell].t;
826  
827 if (special == "gains") then
828  
829 if (Carnival_EnemyCastBar_Spells[spell].g) then
830  
831 castime = Carnival_EnemyCastBar_Spells[spell].g;
832  
833 end
834  
835 end
836  
837 -- Spell might have the same name but a different cast time on another mob, ie. Death Talon Hatchers/Players on Bellowing Roar
838 if (Carnival_EnemyCastBar_Spells[spell].r) then
839  
840 if (mob == Carnival_EnemyCastBar_Spells[spell].r) then
841  
842 castime = Carnival_EnemyCastBar_Spells[spell].a;
843  
844 end
845  
846 end
847  
848 if (Carnival_EnemyCastBar_Spells[spell].c ~= nil) then
849  
850 ctype = Carnival_EnemyCastBar_Spells[spell].c;
851  
852 end
853  
854 Carnival_EnemyCastBar_Show(mob, spell, castime, ctype);
855  
856 end
857  
858 end
859  
860 end
861  
862 end
863  
864 end
865  
866 function Carnival_EnemyCastBar_Yells(arg1, arg2)
867  
868 if (Carnival_EnemyCastBar.bStatus) then
869  
870 if (Carnival_EnemyCastBar.bDebug) then
871  
872 DEFAULT_CHAT_FRAME:AddMessage("YELL: "..arg2)
873  
874 end
875  
876 if (arg2 == "Nefarian") then
877  
878 if (Carnival_EnemyCastBar.bDebug) then
879  
880 DEFAULT_CHAT_FRAME:AddMessage("NEFARIAN YELL: "..arg1)
881  
882 end
883  
884 if (
885  
886 string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_SHAMAN_CALL) or
887 string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_DRUID_CALL) or
888 string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_WARLOCK_CALL) or
889 string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_PRIEST_CALL) or
890 string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_HUNTER_CALL) or
891 string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_WARRIOR_CALL) or
892 string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_ROGUE_CALL) or
893 string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_PALADIN_CALL) or
894 string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_MAGE_CALL)
895  
896 ) then
897  
898 Carnival_EnemyCastBar_Control("Nefarian", "Class Call", "pve");
899 return;
900  
901 end
902  
903 elseif (arg2 == "Lord Victor Nefarius") then
904  
905 if (Carnival_EnemyCastBar.bDebug) then
906  
907 DEFAULT_CHAT_FRAME:AddMessage("LORD VICTOR YELL: "..arg1)
908  
909 end
910  
911 if (string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_STARTING)) then
912  
913 Carnival_EnemyCastBar_Control("Nefarian", "Mob Spawn", "pve");
914 return;
915  
916 elseif (string.find(arg1, Carnival_EnemyCastBar_NEFARIAN_LAND)) then
917  
918 Carnival_EnemyCastBar_Control("Nefarian", "Landing", "pve");
919 return;
920  
921 end
922  
923 elseif (arg2 == "Ragnaros") then
924  
925 if (string.find(arg1, Carnival_EnemyCastBar_RAGNAROS_STARTING)) then
926  
927 Carnival_EnemyCastBar_Control("Ragnaros", "Submerge", "pve");
928 return;
929  
930 elseif (string.find(arg1, Carnival_EnemyCastBar_RAGNAROS_KICKER)) then
931  
932 Carnival_EnemyCastBar_Control("Ragnaros", "Knockback", "pve");
933 return;
934  
935 elseif (string.find(arg1, Carnival_EnemyCastBar_RAGNAROS_SONS)) then
936  
937 Carnival_EnemyCastBar_Control("Ragnaros", "Sons of Flame", "pve");
938 return;
939  
940 end
941  
942 end
943  
944 end
945  
946 end
947  
948 function Carnival_EnemyCastBar_Emotes(arg1, arg2)
949  
950 if (Carnival_EnemyCastBar.bStatus) then
951  
952 if (arg2 == "Flamegor") then
953  
954 if (string.find(arg1, Carnival_EnemyCastBar_FLAMEGOR_FRENZY)) then
955  
956 Carnival_EnemyCastBar_Control("Flamegor", "Frenzy", "pve");
957 return;
958  
959 end
960  
961 elseif (arg2 == "Chromaggus") then
962  
963 if (string.find(arg1, Carnival_EnemyCastBar_CHROMAGGUS_FRENZY)) then
964  
965 Carnival_EnemyCastBar_Control("Chromaggus", "Killing Frenzy", "pve");
966 return;
967  
968 end
969  
970 end
971  
972 end
973  
974 end
975  
976 --[[function Carnival_EnemyCastBar_PartyChecker(spellcaster, target)
977  
978 if (target) then
979  
980 local unit, player;
981 local max = 0;
982 local groupstr = "";
983  
984 if (UnitInRaid("player")) then
985 max = 40;
986 groupstr = "raid";
987 else
988 max = 4;
989 groupstr = "party";
990 end
991  
992 ChatFrame5:AddMessage(spellcaster.." is casting a spell, are they targetting "..target.."?");
993  
994 for i=0, max do
995  
996 unit = groupstr..i;
997 player = UnitName(unit);
998  
999 if (player) then
1000  
1001 ChatFrame5:AddMessage("Checking "..unit.." ("..player..")");
1002  
1003 if (player == spellcaster) then
1004  
1005 mob = UnitName(unit.."target");
1006 if (mob) then
1007  
1008 ChatFrame5:AddMessage(""..unit.." ("..player..") target is "..mob);
1009  
1010 end
1011  
1012 if (mob == target) then
1013  
1014 ChatFrame5:AddMessage(spellcaster.." IS TARGETTING "..target.." - SHOW THE BAR!!!");
1015 return true;
1016  
1017 end
1018  
1019 end
1020  
1021 end
1022  
1023 end
1024  
1025 end
1026  
1027 end--]]
1028  
1029 function Carnival_EnemyCastBar_Target()
1030  
1031 TargetByName(mobname);
1032  
1033 end
1034  
1035 function Carnival_EnemyCastBar_OnUpdate()
1036  
1037 if (not carniactive) then
1038  
1039 -- Fade the bar out
1040 local alpha = this:GetAlpha() - 0.05;
1041 if (alpha > 0) then
1042 this:SetAlpha(alpha);
1043 else
1044 -- Hide up, reset alpha
1045 this:Hide();
1046 this:SetAlpha(1.0);
1047 end
1048 this.active = false;
1049 mobname = "";
1050  
1051 else
1052  
1053 if (this.endTime ~= nil) then
1054  
1055 local label = mobname;
1056 local now = GetTime();
1057  
1058 -- Update the spark, status bar and label
1059 local remains = this.endTime - now;
1060 --label = label .. Carnival_EnemyCastBar_NiceTime(remains);
1061 local sparkPos = ((now - this.startTime) / (this.endTime - this.startTime)) * 195;
1062  
1063 getglobal(this:GetName() .. "_StatusBar"):SetValue(now);
1064 getglobal(this:GetName() .. "_Text"):SetText( this.label );
1065 getglobal(this:GetName() .. "_StatusBar_Spark"):SetPoint("CENTER", getglobal(this:GetName() .. "_StatusBar"), "LEFT", sparkPos, 0);
1066  
1067 if (Carnival_EnemyCastBar.bTimer) then
1068  
1069 getglobal(this:GetName() .. "_CastTimeText"):SetText( format("%.1f", remains) );
1070  
1071 end
1072  
1073 if (0 > remains) then
1074  
1075 getglobal(this:GetName()):Hide();
1076 getglobal(this:GetName()).spell = nil;
1077 this.active = false;
1078 mobname = "";
1079  
1080 end
1081  
1082 end
1083 end
1084 end
1085  
1086 -- Movable window
1087 function Carnival_EnemyCastBar_OnDragStart()
1088 CarniEnemyCastBarFrame:StartMoving();
1089 end
1090  
1091 function Carnival_EnemyCastBar_OnDragStop()
1092 CarniEnemyCastBarFrame:StopMovingOrSizing();
1093 end
1094  
1095 -- Format seconds into m:ss
1096 function Carnival_EnemyCastBar_NiceTime(secs)
1097 return string.format("%d:%02d", secs / 60, math.mod(secs, 60));
1098 end
1099