vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 --[[
2 Hunter Timers, by Sorren of Bleeding Hollow (versions up to 1.2)
3 Version 1.6.11 (by Kharthus of Deathwing)
4  
5 v1.6.11
6 -Added Spanish translation (thanks Geran)
7 -Fixed issues with bar/frame fading and transparency
8 -Added oCB support
9 v1.6.10
10 -Fixed French trap messages
11 -Fixed traptimemult nil issues
12 -Cleanup code for freezing/immolation trap resists
13 v1.6.9
14 -Fixed French flare translation
15 -Allowed eCastingBar/otravi to be used with all other HUDs
16 v1.6.8
17 -Fixed another German typo
18 -Allowed ArcHUD2 and eCastingBar to work at the same time
19 v1.6.7
20 -Fixed German trap messages
21 v1.6.6
22 -Added MetaHud support
23 v1.6.5
24 -Better fix for Clever Traps
25 -Added otravi_CastingBar support
26 v1.6.4
27 -Fixed Clever Traps talent detection
28 v1.6.3
29 -Added ArcHUD2 support (thanks to Mapelli0)
30 -Added Nurfed support
31 -Added Bongos support
32 -Added Perl Arcane Bar support
33 -Cleaned up CastTime and eCastingBar support
34 -Localization updates for all languages
35 v1.6.2
36 -GUI cleanup
37 -Added checkbox for bar growth up/down
38 v1.6.1
39 -Fixes for ZHM and Devilsaur Eye
40 -Reset function correctly resets any active spells
41 -Cleaned up lua tables for future lua versions (5.1)
42 v1.6.0
43 -Added Berserking (thanks to AxelRod for the equation)
44 -Added Devilsaur Eye
45 -Added Zandalarian Hero Medallion
46 -Added Earthstrike
47 -Added Badge of the Swarmguard
48 -Added Kiss of the Spider
49 v1.5.7
50 -Added Jom Gabbar
51 v1.5.6
52 -Updated toc for patch 1.12
53 v1.5.5
54 -Added Simple and Traditional Chinese translations
55 -Escape key will now close the options screen
56 -Added command line option to clear settings
57 v1.5.4
58 -Fixed bug with Aimed Shot timer when Rapid Fire/Quick Shots bars were disabled
59 -Fixed Rapid Fire length when 2-piece CS bonus is active
60 -Added Gluth to Frenzy list
61 v1.5.3
62 -Default localization is now enUS (previously only loaded if actually in enUS)
63 -Fixed spell misses
64 v1.5.2
65 -Added French translation for Hunter's Mark
66 -Fixed mob name parsing
67 v1.5.1
68 -Restricted loading to only hunters
69 -Fixed Aimed Shot cast timer
70 v1.5
71 -Added auto shot timer (thanks to Sorren for the hard part)
72 -Added Apply button to options screen
73 -Cleaned up button XML for 1.11 patch
74 -Major GUI/code cleanup
75 v1.4.2
76 -Fixed Feign Death/Trap macros
77 -Fixed Aimed Shot timer resetting
78 v1.4.1
79 -Added a few German translations
80 v1.4
81 -Added Hunter's Mark
82 -Added Primal Blessing
83 -Added Entrapment
84 -Fixed Clever Traps being incorrectly applied to all traps
85 -Fixed target name with Concussive Shot
86 v1.3.3
87 -Fixed Intimidation (really)
88 v1.3.2
89 -Fixed Intimidation
90 v1.3.1
91 -Fixed German death message translation
92 -Optimized UNIT_AURA event handling
93 v1.3
94 -Fixes for 1.10 tooltips
95 -Increased duration on Quick Shots
96 -Added Expose Weakness
97 -Added Princess Huhuran to frenzy list
98 -Quick Shots will now properly refresh when you regain it during the buff
99 -Fixed bug with Imp Wing Clip expiring that was clearing Wing Clip
100 -Fixed Imp Concussive Shot
101 v1.2
102 -Added icons
103 -Added a switch to append the name
104 -Dynamic resizing to account for the name space
105 -Added opacities
106 -Added the ability to change the border opacity/color
107 -Added the ability to change text colors
108 -Added even more options, look for yourself
109 -Moved some of the variables I had in localization to globals. These are mostly arrays that contain localised variables, so don't worry about them.
110 -Should properly auto-cascade now.
111 v1.1a
112 -Fixed a trap error, thanks Malathis
113 -Added an option to reset the position of the bars to the center of the screen
114 v1.1
115 -Thank you Flimflam for helping me out.
116 -Added per target debuffs! Stings etc. will now be added per target, mouseover a bar to see the target
117 -Added support for fear beast
118 -Fixed a bug with scatter shot
119 -Quick shots will now properly refresh when you regain it during the buff
120 v1.0d
121 -The survival tree continues to mock me.
122 v1.0c
123 -Broke improved wingclip while trying to make it localisable, fixed
124 -Broke improved concussive while trying to make it localisable, fixed
125 v1.0b
126 -Deterrence is 10 seconds. weee.
127 -I broke the slash commands by accident. Fixed.
128 v1.0a
129 -Fixed Scorpid Sting
130 -ALL macros should now work!
131 -Fixed an issue with CT_mods casting bar
132 v1.0
133 -New Shiny gui configuration!
134 -Fixed a crapton of bugs
135 -Should now detect macros and casts from the spellbook
136 -Should no longer explode during frenzy
137 -You can now turn stuff on and off
138 -You can now specify the precision of the time
139 -You can now change the spacing between the bars
140 -Fixed conflict with nurfed casting bar(hopefully discord too)
141 v0.3
142 -Diminshing returns theoretically works!
143 -Fixed an issue with scaling
144 -Wyvern sting works in theory, couldn't find anyone to test
145 v0.2a
146 -Fixed some action bar issues
147 v0.2
148 -Fixed more bugs
149 -Added color changing
150 -Added flashing when the timer is about to expire
151 -updated the slash commands
152 v0.1g
153 -Fixed a bunch of bugs
154 -Can now have it grow up or down
155 -Can now lock/unlock
156 v0.1f
157 -Scaling through /sht scale 0-100 (100 being 100%)
158 -Detect trap resists
159 -can now set an extra delay on the aimed shot casting(for those of us who lag a bit) via /sht delay ## where # is miliseconds.
160 -Fix some minor bugs
161 v0.1d
162 -Imp. Wing Clip
163 -Imp. Conc shot
164 -Counterattack
165 -various bugs
166 -minor fade detection
167 v0.1c fixed Bestial wrath, fixed conflict with CastingTimeBar
168 -Added quick shots
169 -added rapid fire
170 -made both affect aimed shot cast time
171 v0.1b fixed an conflict with CT_RaidTracker
172 v0.1a fixed an error with concussive shot
173 v0.1 initial release
174  
175 --]]
176  
177 local checkForTargetDeath = 0;
178 local checkForTarget = nil;
179 local checkForSpell = 0;
180 local targetDebuffs = {};
181 local playerBuffs = {};
182 local checkForSpellFail = nil;
183 local checkForSpellName = nil;
184 local trapTimer = nil;
185 local dimin = {};
186 local shtautoshot = false;
187 local shttimeleft = nil;
188 local shtcasting = false;
189 local shtautotime = 0;
190 local autodelta = 0;
191 local shtdebug = false;
192 local currentHealth = nil;
193 local maxHealth = nil;
194 local percentHealth = nil;
195 local berserkValue = nil;
196  
197 function SHunterTimers_OnLoad()
198 local playerClass, englishClass = UnitClass("player");
199 if(englishClass ~= "HUNTER") then
200 return;
201 end
202 this:RegisterEvent("VARIABLES_LOADED");
203 this:RegisterEvent("SPELLS_CHANGED");
204 this:RegisterEvent("CHARACTER_POINTS_CHANGED");
205 this:RegisterEvent("PLAYER_ALIVE");
206 this:RegisterEvent("UNIT_AURA");
207 this:RegisterEvent("PLAYER_TARGET_CHANGED");
208 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE");
209 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE");
210 this:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_OTHER");
211 this:RegisterEvent("CHAT_MSG_SPELL_AURA_GONE_SELF");
212 this:RegisterEvent("CHAT_MSG_SPELL_SELF_DAMAGE");
213 this:RegisterEvent("CHAT_MSG_COMBAT_HOSTILE_DEATH");
214 this:RegisterEvent("CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS");
215 this:RegisterEvent("CHAT_MSG_SPELL_PET_DAMAGE");
216 this:RegisterEvent("CHAT_MSG_MONSTER_EMOTE");
217 this:RegisterEvent("START_AUTOREPEAT_SPELL");
218 this:RegisterEvent("STOP_AUTOREPEAT_SPELL");
219 this:RegisterEvent("SPELLCAST_START");
220 this:RegisterEvent("SPELLCAST_STOP");
221 this:RegisterEvent("SPELLCAST_FAILED");
222 --this:RegisterEvent("SPELLCAST_INTERRUPTED");
223 --this:RegisterAllEvents();
224  
225 tinsert(UISpecialFrames,"SHunterTimersOptions");
226  
227 if(DEFAULT_CHAT_FRAME) then
228 DEFAULT_CHAT_FRAME:AddMessage("Sorren's Hunter Timers "..SHT_VERSION.." Loaded", 1, 0, 0 );
229 end
230  
231 SlashCmdList["SHUNTERTIMERS"] = function (msg)
232 SHunterTimers_SlashCmd(msg);
233 end
234 SLASH_SHUNTERTIMERS1 = "/shuntertimers";
235 SLASH_SHUNTERTIMERS2 = "/sht";
236  
237 targetDebuffs["numDebuffs"] = 0;
238 playerBuffs["numBuffs"] = 0;
239  
240 end
241  
242 function SHunterTimers_SlashCmd(msg)
243 if( msg == "showvars" ) then
244 if( SHTvars["exposeweak"] ) then
245 DEFAULT_CHAT_FRAME:AddMessage("exposeweak", 1, 0, 0 );
246 else
247 DEFAULT_CHAT_FRAME:AddMessage("exposeweak "..SHT_OFF, 1, 0, 0 );
248 end
249 return;
250 elseif( msg == "menu" ) then
251 SHunterTimers_ShowOptions();
252 return;
253 elseif( msg == "reset" ) then
254 for num = 1, 11, 1 do
255 frame = getglobal("SHunterTimersStatus"..num);
256 frame.endTime = 0;
257 end
258 SHunterTimers_ClearActiveSpells();
259 return;
260 elseif( msg == "clear all" ) then
261 SHunterTimers_ResetOptions();
262 DEFAULT_CHAT_FRAME:AddMessage("SHT options reset to defaults.", 1, 0, 0);
263 return;
264 elseif( msg == "debug" ) then
265 if ( shtdebug ) then
266 shtdebug = false;
267 DEFAULT_CHAT_FRAME:AddMessage("SHT debugging mode disabled.", 1, 0, 0);
268 else
269 shtdebug = true;
270 DEFAULT_CHAT_FRAME:AddMessage("SHT debugging mode enabled.", 1, 0, 0);
271 end
272 return;
273 elseif( msg == SHT_ON ) then
274 if( SHTvars[SHT_ON] ) then
275 DEFAULT_CHAT_FRAME:AddMessage("SHT already "..SHT_ON, 1, 0, 0);
276 return;
277 else
278 UseAction = SHunterTimers_OnUseAction;
279 CastSpellByName = SHunterTimers_OnCastSpellByName;
280 CastSpell = SHunterTimers_OnCastSpell;
281 SHTvars[SHT_ON] = true;
282 DEFAULT_CHAT_FRAME:AddMessage("SHT "..SHT_ON, 1, 0, 0);
283 return;
284 end
285 elseif( msg == SHT_OFF ) then
286 if( SHTvars[SHT_ON] ) then
287 UseAction = SHunterTimers_Real_UseAction;
288 CastSpellByName = SHunterTimers_Real_CastSpellByName;
289 CastSpell = SHunterTimers_Real_CastSpell;
290 SHTvars[SHT_ON] = false;
291 DEFAULT_CHAT_FRAME:AddMessage("SHT "..SHT_OFF, 1, 0, 0);
292 return;
293 else
294 DEFAULT_CHAT_FRAME:AddMessage("SHT not "..SHT_ON, 1, 0, 0);
295 return;
296 end
297 elseif( string.find( msg, "setbgcolor" ) ) then
298 for r, g, b, a in string.gfind( msg, "setcolor (%d+) (%d+) (%d+) (%d+)" ) do
299 SHTvars["bg"].r = r/10;
300 SHTvars["bg"].g = g/10;
301 SHTvars["bg"].b = b/10;
302 SHTvars["bg"].a = a/10;
303 SHunterTimersFrame:SetBackdropColor( r/10, g/10, b/10, a/10 );
304 end
305 return;
306 elseif( string.find( msg, "aimed" ) )then
307 if( string.find(msg, SHT_ON ) )then
308 SHTvars["skills"][SHT_AIMED_SHOT] = true;
309 DEFAULT_CHAT_FRAME:AddMessage("SHT: Aimed Shot Casting Bar "..SHT_ON);
310 elseif( string.find( msg, SHT_OFF ) ) then
311 SHTvars["skills"][SHT_AIMED_SHOT] = false;
312 DEFAULT_CHAT_FRAME:AddMessage("SHT: Aimed Shot Casting Bar "..SHT_OFF);
313 else
314 if( SHTvars["skills"][SHT_AIMED_SHOT] ) then
315 SHTvars["skills"][SHT_AIMED_SHOT] = false;
316 DEFAULT_CHAT_FRAME:AddMessage("SHT: Aimed Shot Casting Bar "..SHT_OFF);
317 else
318 SHTvars["skills"][SHT_AIMED_SHOT] = true;
319 DEFAULT_CHAT_FRAME:AddMessage("SHT: Aimed Shot Casting Bar "..SHT_ON);
320 end
321 end
322 elseif( string.find(msg, "aimeddelay" ) ) then
323 for ms in string.gfind(msg, "aimeddelay (%d+)") do
324 SHTvars["aimeddelay"] = ms;
325 DEFAULT_CHAT_FRAME:AddMessage("Aimed delay set to "..ms.."ms");
326 end
327 elseif( string.find(msg, "delay" ) ) then
328 for ms in string.gfind(msg, "delay (%d+)") do
329 SHTvars["shotdelay"] = ms;
330 DEFAULT_CHAT_FRAME:AddMessage("Shot delay set to "..ms.."ms");
331 end
332 elseif( string.find(msg, "scale" ) ) then
333 for scale in string.gfind( msg, "scale (%d+)" ) do
334 if( (scale/100) < 0.1 ) then
335 scale = 10;
336 end
337 scale = scale * UIParent:GetScale();
338 SHTvars["scale"] = scale/100;
339 end
340 SHunterTimersFrame:SetScale( SHTvars["scale"] );
341 for i=1, 11 do
342 getglobal("SHunterTimersStatus"..i):SetScale( SHTvars["scale"] );
343 end
344 elseif( string.find(msg, "down") ) then
345 SHTvars["down"] = true;
346 SHunterTimersFrame:ClearAllPoints();
347 SHunterTimersFrame:SetPoint( "TOPLEFT", "SHunterTimersAnchor", "BOTTOMRIGHT" );
348 DEFAULT_CHAT_FRAME:AddMessage("SHT: Growing down");
349 elseif( string.find(msg, "up" ) ) then
350 SHTvars["down"] = false;
351 SHunterTimersFrame:ClearAllPoints();
352 SHunterTimersFrame:SetPoint( "BOTTOMLEFT", "SHunterTimersAnchor", "TOPRIGHT" );
353 DEFAULT_CHAT_FRAME:AddMessage("SHT: Growing up");
354 elseif( msg == "unlock" ) then
355 SHTvars["locked"] = false;
356 SHunterTimersAnchor:Show();
357 elseif( msg == "lock" ) then
358 SHTvars["locked"] = true;
359 SHunterTimersAnchor:Hide();
360 elseif( string.find(msg, "colorchange" ) ) then
361 for on in string.gfind(msg, "colorchange (%a+)") do
362 if( on == SHT_ON ) then
363 SHTvars["colorchange"] = true;
364 elseif( on == SHT_OFF ) then
365 SHTvars["colorchange"] = false;
366 end
367 if( on == SHT_ON) or ( on == SHT_OFF ) then
368 DEFAULT_CHAT_FRAME:AddMessage( "SHT: Colorchange is: "..on);
369 end
370 end
371 elseif( string.find( msg, "barcolor" ) ) then
372 for r, g, b in string.gfind(msg, "barcolor ([%d.]+) ([%d.]+) ([%d.]+)") do
373 local red, green, blue = unpack( SHTvars["barstartcolor"] );
374 SHTvars["barstartcolor"][1] = r;
375 SHTvars["barstartcolor"][2] = g;
376 SHTvars["barstartcolor"][3] = b;
377  
378 local rd, gd, bd = unpack( SHTvars["bardelta"] );
379 red = rd + red;
380 blue = bd + blue;
381 green = gd + green;
382  
383 red = red - r;
384 green = green - g;
385 blue = blue - b;
386  
387 SHTvars["bardelta"][1] = red;
388 SHTvars["bardelta"][2] = green;
389 SHTvars["bardelta"][3] = blue;
390 DEFAULT_CHAT_FRAME:AddMessage( "SHT: Barcolor set to: "..SHTColor(r, g, b)..r..", "..g..", "..b.."|r");
391 end
392 elseif( string.find( msg, "barendcolor" ) ) then
393 for red, green, blue in string.gfind(msg, "barendcolor ([%d.]+) ([%d.]+) ([%d.]+)") do
394 local r, g, b = unpack( SHTvars["barstartcolor"] );
395  
396 r = red - r;
397 g = green - g;
398 b = blue - b;
399  
400 SHTvars["bardelta"][1] = r;
401 SHTvars["bardelta"][2] = g;
402 SHTvars["bardelta"][3] = b;
403 DEFAULT_CHAT_FRAME:AddMessage( "SHT: Barendcolor set to: "..SHTColor(red, green, blue)..red..", "..green..", "..blue.."|r");
404 end
405 elseif( string.find( msg, "flash" ) ) then
406 for flash in string.gfind( msg, "flash (%d+)" ) do
407 flash = flash * 1;
408 SHTvars["flash"] = flash;
409 if( flash == 0 ) then
410 DEFAULT_CHAT_FRAME:AddMessage("SHT: Bar flash "..SHT_OFF);
411 else
412 DEFAULT_CHAT_FRAME:AddMessage("SHT: Bar flash set to: "..flash.." seconds");
413 end
414 end
415 elseif( string.find( msg, "step" ) ) then
416 for step in string.gfind( msg, "step ([%d.]+)" ) do
417 SHTvars["step"] = step
418 DEFAULT_CHAT_FRAME:AddMessage("SHT: Step set to: "..step);
419 end
420 elseif( msg == "resetpos" ) then
421 SHunterTimersAnchor:ClearAllPoints();
422 SHunterTimersAnchor:SetPoint("CENTER", "UIParent", "CENTER", 0, 0 );
423 elseif( string.find( msg, "(%a+) (%d+)" ) ) then
424 for cmd1, cmd2 in string.gfind( msg, "(%a+) (%d+)" ) do
425 --DEFAULT_CHAT_FRAME:AddMessage(cmd1.."-"..cmd2, 1, 0, 0);
426 SHunterTimersFrame_add( cmd2, cmd1 );
427 end
428 elseif( msg == "status" ) then
429  
430 local statusstring = "";
431 local statusstring1 = "";
432 local statusstring2 = "";
433  
434 if( SHTvars[SHT_ON] ) then
435 statusstring1 = SHT_ON;
436 else
437 statusstring1 = SHT_OFF;
438 end
439 if( SHTvars["skills"][SHT_AIMED_SHOT] ) then
440 statusstring2 = SHT_ON;
441 else
442 statusstring2 = SHT_OFF;
443 end
444 DEFAULT_CHAT_FRAME:AddMessage(SHT_STATUS_STRINGS[1]);
445 DEFAULT_CHAT_FRAME:AddMessage(format(SHT_STATUS_STRINGS[2], statusstring1, statusstring2));
446 DEFAULT_CHAT_FRAME:AddMessage(format(SHT_STATUS_STRINGS[3], SHTvars["shotdelay"], SHTvars["aimeddelay"]));
447 DEFAULT_CHAT_FRAME:AddMessage(format(SHT_STATUS_STRINGS[4], SHTvars["flash"], SHTvars["step"]));
448  
449 local r, g, b = unpack( SHTvars["barstartcolor"] );
450 local rd, gd, bd = unpack( SHTvars["bardelta"] );
451 statusstring1 = SHTColor(r,g,b)..r..", "..g..", "..b.."|r";
452 statusstring2 = SHTColor(r+rd, g+gd, b+bd)..(r+rd)..", "..(b+bd)..", "..(g+gd).."|r";
453 DEFAULT_CHAT_FRAME:AddMessage(format(SHT_STATUS_STRINGS[5], statusstring1, statusstring2));
454  
455 if( SHTvars["colorchange"] ) then
456 statusstring1 = SHT_ON;
457 else
458 statusstring1 = SHT_OFF;
459 end
460 if( SHTvars["down"] ) then
461 statusstring2 = "down";
462 else
463 statusstring2 = "up";
464 end
465 DEFAULT_CHAT_FRAME:AddMessage(format(SHT_STATUS_STRINGS[6], statusstring1, statusstring2));
466 DEFAULT_CHAT_FRAME:AddMessage(format(SHT_STATUS_STRINGS[7], (SHTvars["scale"]/UIParent:GetScale()*100) ) );
467 else
468 for key,val in pairs(SHT_SLASH_HELP) do
469 DEFAULT_CHAT_FRAME:AddMessage(val, 1, 1, 0);
470 end
471 end
472  
473 end
474  
475 function SHunterTimersFrame_add( spellDuration, spellName, target )
476 if( SHTvars["numBars"] < 0 ) then
477 SHTvars["numBars"] = 0;
478 end
479  
480 local allReadyActive = false;
481 local bar;
482  
483 if( SHT_sfind( spellName, SHT_STING ) or string.find( spellName, SHT_CONC_SHOT ) ) then
484 spellDuration = spellDuration + SHTvars["shotdelay"];
485 end
486  
487 if( spellName == SHT_INTIM ) then
488 --DEFAULT_CHAT_FRAME:AddMessage("Intim", 1, 1, 0 );
489 if( SHTvars["petIntim"] ) then
490 --DEFAULT_CHAT_FRAME:AddMessage("Pet Intim", 1, 1, 0 );
491 for num = 1, SHTvars["numBars"], 1 do
492 local barframe = getglobal("SHunterTimersStatus"..num);
493 local textBar = getglobal("SHunterTimersStatus"..num.."BarLeftText"):GetText();
494 --DEFAULT_CHAT_FRAME:AddMessage("Intim: "..textBar, 1, 1, 0 );
495 if( string.find( textBar, SHT_PET_INTIM ) ) then
496 --barframe.endTime = 0;
497 allReadyActive = true;
498 bar = num;
499 break;
500 end
501 end
502 end
503 elseif( string.find( spellName, SHT_PRIMED ) ) then
504 if( trapTimer ) then
505 for num = 1, SHTvars["numBars"], 1 do
506 local textBar = getglobal("SHunterTimersStatus"..num.."BarLeftText"):GetText();
507 --DEFAULT_CHAT_FRAME:AddMessage("Intim: "..textBar, 1, 1, 0 );
508 if( string.find(textBar, SHT_PRIMED ) ) then
509 allReadyActive = true;
510 bar = num;
511 break;
512 end
513 end
514 end
515 elseif( SHT_sfind( spellName, SHT_STING ) ) then
516 for num = 1, SHTvars["numBars"] do
517 local barframe = getglobal("SHunterTimersStatus"..num);
518 if( SHT_sfind( barframe.spell, SHT_STING ) and ( barframe.target == target ) ) then
519 allReadyActive = true;
520 bar = num;
521 break;
522 end
523 end
524 elseif( SHT_sfind( spellName, SHT_HUNTERS_MARK ) ) then
525 for num = 1, SHTvars["numBars"] do
526 local barframe = getglobal("SHunterTimersStatus"..num);
527 if( SHT_sfind( barframe.spell, SHT_HUNTERS_MARK ) ) then
528 allReadyActive = true;
529 bar = num;
530 break;
531 end
532 end
533 elseif( spellName == SHT_AUTO_SHOT ) and SHTvars["sticky"] then
534 if( SHunterTimersStatus1.spell == SHT_AUTO_SHOT ) then
535 allReadyActive = true;
536 bar = 1;
537 else
538 SHunterTimers_shift(1);
539 allReadyActive = true;
540 SHTvars["numBars"] = SHTvars["numBars"] + 1;
541 bar = 1;
542 end
543 elseif( not string.find( spellName, SHT_FLARE ) ) then
544 for num = 1, SHTvars["numBars"], 1 do
545 local barframe = getglobal("SHunterTimersStatus"..num);
546 if( barframe.spell == spellName ) and (barframe.target == target)then
547 allReadyActive = true;
548 bar = num;
549 break;
550 end
551 end
552 end
553  
554 local num = bar;
555 if( allReadyActive ) then
556 if( SHTvars["numBars"] == 0 ) then
557 SHTvars["numBars"] = 1;
558 end
559 else
560 if( SHTvars["numBars"] == 11 ) then
561 return;
562 end
563 SHTvars["numBars"] = SHTvars["numBars"] + 1;
564 num = SHTvars["numBars"];
565 end
566  
567 local icon = getglobal("SHunterTimersStatus"..num.."Icon");
568 local barframe = getglobal("SHunterTimersStatus"..num);
569 local bar = getglobal("SHunterTimersStatus"..num.."Bar");
570 local leftText = getglobal("SHunterTimersStatus"..num.."BarLeftText");
571 local rightText = getglobal("SHunterTimersStatus"..num.."BarRightText");
572  
573 if( not barframe ) then
574 --DEFAULT_CHAT_FRAME:AddMessage("WTFBBQ line 214");
575 return;
576 end
577 local texture;
578 if( spellName == SHT_IMP_CONC_SHORT ) then
579 texture = SHTvars["textures"][SHT_CONC_SHOT];
580 elseif( spellName == SHT_IMP_WC_SHORT ) then
581 texture = SHTvars["textures"][SHT_WING_CLIP];
582 elseif( string.find( spellName, SHT_TRAP ) ) then
583 if( string.find( spellName, SHT_FREEZING_TRAP ) )then
584 texture = SHTvars["textures"][SHT_FREEZING_TRAP]
585 elseif( string.find( spellName, SHT_IMMO_TRAP ) ) then
586 texture = SHTvars["textures"][SHT_IMMO_TRAP]
587 elseif( string.find( spellName, SHT_FROST_TRAP ) ) then
588 texture = SHTvars["textures"][SHT_FROST_TRAP]
589 elseif( string.find( spellName, SHT_EXPL_TRAP ) ) then
590 texture = SHTvars["textures"][SHT_EXPL_TRAP]
591 end
592 elseif( string.find( spellName, SHT_PET_INTIM ) ) then
593 texture = SHTvars["textures"][SHT_INTIM];
594 elseif( spellName == SHT_AUTO_SHOT ) then
595 texture = GetInventoryItemTexture("player", 18);
596 else
597 texture = SHTvars["textures"][spellName];
598 end
599 icon:SetTexture(texture);
600 barframe.spell = spellName;
601 barframe.texture = texture;
602 barframe.target = target;
603 barframe.startTime = GetTime();
604 barframe.duration = spellDuration / 1000;
605 barframe.endTime = barframe.startTime + barframe.duration;
606 bar:SetMinMaxValues(barframe.startTime, barframe.endTime);
607 bar:SetValue( barframe.endTime );
608 local spellText = SHTColor(unpack(SHTvars["skillcolor"]))..spellName;
609 if( SHTvars["append"] ) and (barframe.target) then
610 spellText = spellText.."|r - "..SHTColor(unpack(SHTvars["targetcolor"]))..barframe.target;
611 end
612 leftText:SetText( spellText );
613 local text;
614 if( SHTvars["mili"] == 0 ) then
615 text = string.format( SHTColor(unpack(SHTvars["timecolor"])).."%ds", barframe.duration );
616 else
617 text = string.format( SHTColor(unpack(SHTvars["timecolor"])).."%."..SHTvars["mili"].."f", barframe.duration );
618 end
619 rightText:SetText( text );
620 barframe.channeling = true;
621 barframe.fadeOut = false;
622 SHunterTimersFrame:SetAlpha(SHTvars["overallalpha"]);
623 SHT_SetHeight();
624 if( not SHunterTimersFrame:IsVisible() ) then
625 SHunterTimersFrame:Show();
626 end
627 local r, g, b, a = unpack( SHTvars["barstartcolor"] );
628 bar:SetStatusBarColor(r, g, b, a );
629 getglobal("SHunterTimersStatus"..num.."BGBar"):SetStatusBarColor(r, g, b, 0.25*a);
630 barframe:SetAlpha(SHTvars["overallalpha"]);
631 SHunterTimers_SetWidths();
632 barframe:Show();
633 end
634  
635 function SHunterTimers_SetWidths()
636 local largestwidth = 180;
637 if( SHTvars["showtex"] ) then
638 if( SHTvars["largetex"] ) and (SHTvars["barheight"] < 16 ) then
639 largestwidth = largestwidth - 16;
640 else
641 largestwidth = largestwidth - SHTvars["barheight"];
642 end
643 if( SHTvars["gap"] ) then
644 largestwidth = largestwidth - 5;
645 end
646 end
647 local tarwidth = largestwidth;
648 local extrawidth = 0;
649 for i=1, SHTvars["numBars"] do
650 local width = getglobal("SHunterTimersStatus"..i.."BarLeftText"):GetWidth() + getglobal("SHunterTimersStatus"..i.."BarRightText"):GetWidth();
651 if( width > largestwidth ) then
652 largestwidth = width;
653 end
654 end
655 if( largestwidth > tarwidth ) and (not SHTvars["hidetext"]) then
656 largestwidth = largestwidth + 40;
657 if( SHTvars["showtex"] ) then
658 extrawidth = SHTvars["barheight"];
659 if( SHTvars["largetex"] ) and ( SHTvars["barheight"] < 16 ) then
660 extrawidth = 16;
661 end
662 if( SHTvars["gap"] ) then
663 extrawidth = extrawidth + 5;
664 end
665 end
666 for i=1, SHTvars["numBars"] do
667 getglobal("SHunterTimersStatus"..i):SetWidth(largestwidth + extrawidth);
668 getglobal("SHunterTimersStatus"..i.."Bar"):SetWidth(largestwidth);
669 getglobal("SHunterTimersStatus"..i.."BGBar"):SetWidth(largestwidth);
670 end
671 if( SHTvars["padding"] ) then
672 SHunterTimersFrame:SetWidth(largestwidth + extrawidth + 20);
673 else
674 SHunterTimersFrame:SetWidth(largestwidth + extrawidth + 10);
675 end
676 else
677 if( SHTvars["padding"] ) then
678 SHunterTimersFrame:SetWidth( 240 );
679 else
680 SHunterTimersFrame:SetWidth( 230 );
681 end
682 local width = 220;
683 if( SHTvars["showtex"] ) then
684 if( SHTvars["largetex"] ) and ( SHTvars["barheight"] < 16) then
685 width = width - 16;
686 else
687 width = width - SHTvars["barheight"];
688 end
689 if( SHTvars["gap"] ) then
690 width = width - 5;
691 end
692 end
693 for i=1, SHTvars["numBars"] do
694 getglobal("SHunterTimersStatus"..i):SetWidth(220);
695 getglobal("SHunterTimersStatus"..i.."Bar"):SetWidth(width);
696 getglobal("SHunterTimersStatus"..i.."BGBar"):SetWidth(width);
697 end
698 end
699 end
700  
701  
702  
703 function SHunterTimers_OnUpdateBar( id )
704 if( not SHunterTimersFrame:IsVisible() ) then
705 SHunterTimersFrame:Show();
706 end
707 local barframe = getglobal("SHunterTimersStatus"..id);
708 if( barframe.channeling ) then
709 local time = GetTime();
710 local bartext = getglobal( "SHunterTimersStatus"..id.."BarRightText");
711 local text = barframe.spell;
712  
713 if( barframe.spell == SHT_AUTO_SHOT ) then
714 if(( not shtautoshot ) or ( shtcasting )) and ( not barframe.movetime ) and ( (barframe.endTime - time) <= 0.7 ) then
715 barframe.movetime = time;
716 --DEFAULT_CHAT_FRAME:AddMessage("1 d");
717 elseif( barframe.movetime ) and (( shtautoshot ) and ( not shtcasting )) then
718 local deltaTime = time - barframe.movetime;
719 --DEFAULT_CHAT_FRAME:AddMessage("2 d");
720 --DEFAULT_CHAT_FRAME:AddMessage(barframe.endTime.." "..deltaTime.." "..barframe.movetime);
721 barframe.startTime = barframe.startTime + deltaTime;
722 barframe.endTime = barframe.endTime + deltaTime;
723 getglobal("SHunterTimersStatus"..id.."Bar"):SetMinMaxValues(barframe.startTime, barframe.endTime);
724 barframe:SetAlpha(SHTvars["overallalpha"]);
725 barframe.movetime = nil;
726 elseif(( not shtautoshot ) or ( shtcasting )) and ( barframe.movetime ) then
727 if( time - barframe.movetime) > 7 then
728 barframe.channeling = false;
729 barframe.fadeOut = true;
730 barframe.movetime = nil;
731 elseif( time - barframe.movetime ) > 4 then
732 local alpha = barframe:GetAlpha() - SHTvars["step"];
733 if( alpha > (0.3*SHTvars["overallalpha"]) ) then
734 barframe:SetAlpha(alpha);
735 end
736 end
737 return;
738 end
739 end
740  
741 if( time >= barframe.endTime ) then
742 if( barframe.spell == SHT_AUTO_SHOT ) then
743 return;
744 end
745 barframe.channeling = false;
746 barframe.fadeOut = true;
747 barframe.step = 0;
748 barframe.target = nil;
749 bartext:SetText( SHT_DONE );
750 if( SHTvars["concuss"] ) and ( text == SHT_CONC_SHOT ) then
751 SHTvars["concuss"] = false;
752 elseif( SHTvars["impconc"] ) and ( text == SHT_IMP_CONC_SHORT ) then
753 SHTvars["impconc"] = false;
754 elseif( SHTvars["rapid"] ) and ( text == SHT_RAPID_FIRE ) then
755 SHTvars["rapid"] = false;
756 elseif( SHTvars["quick"] ) and ( text == SHT_QUICK_SHOTS ) then
757 SHTvars["quick"] = false;
758 elseif( SHTvars["petIntim"] ) and ( text == SHT_PET_INTIM ) then
759 SHTvars["petIntim"] = false;
760 elseif( SHTvars["intimidate"] ) and ( text == SHT_INTIM ) then
761 SHTvars["intimidate"] = false;
762 elseif( SHTvars["deterrence"] ) and ( text == SHT_DETERRENCE ) then
763 SHTvars["deterrence"] = false;
764 elseif( trapTimer ) and string.find( text, SHT_PRIMED ) then
765 trapTimer = false;
766 elseif( SHTvars["wingclip"] ) and ( text == SHT_WING_CLIP ) then
767 SHTvars["wingclip"] = false;
768 elseif( SHTvars["impwing"] ) and ( text == SHT_IMP_WC_SHORT ) then
769 SHTvars["impwing"] = false;
770 elseif( SHTvars["freezing"] ) and ( text == SHT_FREEZING_TRAP ) then
771 SHTvars["freezing"] = false;
772 elseif( SHTvars["scatter"] ) and ( text == SHT_SCATTER ) then
773 SHTvars["scatter"] = false;
774 elseif( SHTvars["wyvern"] ) and ( text == SHT_WYVERN_TEXT ) then
775 SHTvars["wyvern"] = false;
776 elseif( SHTvars["fearbeast"] ) and ( text == SHT_FEAR_BEAST ) then
777 SHTvars["fearbeast"] = false;
778 elseif( SHTvars["exposeweak"] ) and ( text == SHT_EXPOSE_WEAKNESS ) then
779 SHTvars["exposeweak"] = false;
780 elseif( SHTvars["huntersmark"] ) and ( text == SHT_HUNTERS_MARK ) then
781 SHTvars["huntersmark"] = false;
782 elseif( SHTvars["primalblessing"] ) and ( text == SHT_PRIMAL_BLESSING ) then
783 SHTvars["primalblessing"] = false;
784 elseif( SHTvars["entrapment"] ) and ( text == SHT_ENTRAPMENT ) then
785 SHTvars["entrapment"] = false;
786 elseif( SHTvars["berserking"] ) and ( text == SHT_BERSERKING ) then
787 SHTvars["berserking"] = false;
788 elseif( SHTvars["devilsaur"] ) and ( text == SHT_DEVILSAUR ) then
789 SHTvars["devilsaur"] = false;
790 elseif( SHTvars["zhm"] ) and ( text == SHT_ZHM ) then
791 SHTvars["zhm"] = false;
792 elseif( SHTvars["earthstrike"] ) and ( text == SHT_EARTHSTRIKE ) then
793 SHTvars["earthstrike"] = false;
794 elseif( SHTvars["swarmguard"] ) and ( text == SHT_SWARMGUARD ) then
795 SHTvars["swarmguard"] = false;
796 elseif( SHTvars["jomgabbar"] ) and ( text == SHT_JOM_GABBAR ) then
797 SHTvars["jomgabbar"] = false;
798 elseif( SHTvars["spider"] ) and ( text == SHT_KISS_SPIDER ) then
799 SHTvars["spider"] = false;
800 end
801 return;
802 elseif ( SHTvars["quick"] and text == SHT_QUICK_SHOTS and SHTvars["skills"][SHT_QUICK_SHOTS] ) then
803 local i = 1;
804 while( UnitBuff("player", i ) ) do
805 local time = GetTime();
806 local duration = GetPlayerBuffTimeLeft( GetPlayerBuff( i-1 ) );
807 SHuntersTooltip:ClearLines();
808 SHuntersTooltip:SetPlayerBuff( i-1 );
809 playerBuffs[i] = SHuntersTooltipTextLeft1:GetText();
810 if ( string.find( playerBuffs[i], SHT_QUICK_SHOTS ) ) then
811 if ( duration > 11 ) then
812 --DEFAULT_CHAT_FRAME:AddMessage(i.." "..playerBuffs[i].." "..duration, 1, 0, 0 );
813 SHunterTimersFrame_add( duration*1000, SHT_QUICK_SHOTS );
814 end
815 break;
816 end
817 i = i + 1;
818 end
819 elseif ( SHTvars["rapid"] and text == SHT_RAPID_FIRE and SHTvars["skills"][SHT_RAPID_FIRE] ) then
820 local i = 1;
821 while( UnitBuff("player", i ) ) do
822 local time = GetTime();
823 local duration = GetPlayerBuffTimeLeft( GetPlayerBuff( i-1 ) );
824 SHuntersTooltip:ClearLines();
825 SHuntersTooltip:SetPlayerBuff( i-1 );
826 playerBuffs[i] = SHuntersTooltipTextLeft1:GetText();
827 if ( string.find( playerBuffs[i], SHT_RAPID_FIRE ) ) then
828 if ( duration > 18 ) then
829 --DEFAULT_CHAT_FRAME:AddMessage(i.." "..playerBuffs[i].." "..duration, 1, 0, 0 );
830 SHunterTimersFrame_add( duration*1000, SHT_RAPID_FIRE );
831 end
832 break;
833 end
834 i = i + 1;
835 end
836 elseif ( SHTvars["primalblessing"] and text == SHT_PRIMAL_BLESSING and SHTvars["skills"][SHT_PRIMAL_BLESSING] ) then
837 local i = 1;
838 while( UnitBuff("player", i ) ) do
839 local time = GetTime();
840 local duration = GetPlayerBuffTimeLeft( GetPlayerBuff( i-1 ) );
841 SHuntersTooltip:ClearLines();
842 SHuntersTooltip:SetPlayerBuff( i-1 );
843 playerBuffs[i] = SHuntersTooltipTextLeft1:GetText();
844 if ( string.find( playerBuffs[i], SHT_PRIMAL_BLESSING ) ) then
845 if ( duration > 11 ) then
846 --DEFAULT_CHAT_FRAME:AddMessage(i.." "..playerBuffs[i].." "..duration, 1, 0, 0 );
847 SHunterTimersFrame_add( duration*1000, SHT_PRIMAL_BLESSING );
848 end
849 break;
850 end
851 i = i + 1;
852 end
853 end
854  
855 local bar = getglobal("SHunterTimersStatus"..id.."Bar");
856 local value = barframe.startTime + barframe.endTime - time;
857 bar:SetValue( value );
858 local timeleft = barframe.duration - (time - barframe.startTime);
859 local timeleftstring;
860 if( SHTvars["mili"] == 0 ) then
861 timeleftstring = string.format( SHTColor(unpack(SHTvars["timecolor"])).."%ds", timeleft );
862 else
863 timeleftstring = string.format( SHTColor(unpack(SHTvars["timecolor"])).."%."..SHTvars["mili"].."f", timeleft );
864 end
865 getglobal("SHunterTimersStatus"..id.."BarRightText"):SetText(timeleftstring);
866 if( SHTvars["colorchange"] ) then
867 local percent = (time - barframe.startTime)/(barframe.endTime - barframe.startTime);
868 local r, g, b, a = unpack( SHTvars["barstartcolor"] );
869 local redd, greend, blued, alphad = unpack( SHTvars["bardelta"] );
870 redd = r + redd*percent;
871 greend = g + greend*percent;
872 blued = b + blued*percent;
873 alphad = a + alphad*percent;
874 bar:SetStatusBarColor( redd, greend, blued, alphad );
875 getglobal("SHunterTimersStatus"..id.."BGBar"):SetStatusBarColor( redd, greend, blued, 0.25*alphad );
876 end
877  
878 if( timeleft < SHTvars["flash"] ) and ( barframe.spell ~= SHT_AUTO_SHOT ) then
879 if( barframe.step == 0 ) then
880 barframe.step = -SHTvars["step"];
881 end
882  
883 local alpha = barframe:GetAlpha() + barframe.step;
884 if( alpha < 0.2 ) then
885 barframe.step = SHTvars["step"];
886 elseif( alpha > SHTvars["overallalpha"] ) then
887 barframe.step = -SHTvars["step"];
888 end
889 barframe:SetAlpha(alpha);
890 end
891  
892  
893 elseif( barframe.fadeOut ) then
894 if( trapTimer ) then
895 local textBar = getglobal("SHunterTimersStatus"..id.."BarLeftText"):GetText();
896 if( string.find( textBar, "primed" ) ) then
897 trapTimer = false;
898 end
899 end
900  
901 local alpha = barframe:GetAlpha() - 0.05;
902 if( alpha > 0 ) then
903 barframe:SetAlpha(alpha);
904 else
905 barframe.fadeOut = false;
906 barframe:Hide();
907 SHTvars["numBars"] = SHTvars["numBars"] - 1;
908 SHunterTimers_AutoCascade( 1, false );
909 end
910 end
911 end
912  
913 function SHunterTimersFrame_OnUpdate(elapsed)
914 if( (elapsed - this.updateTime) > 1 ) then
915 this.updateTime = elapsed;
916  
917 SHunterTimersFrame:SetScale( SHTvars["scale"] );
918 for i=1, SHT_NUM_BARS do
919 getglobal("SHunterTimersStatus"..i):SetScale( SHTvars["scale"] );
920 end
921 for key, val in pairs(dimin) do
922 if( (elapsed - dimin[key]["time"]) > 20 ) then
923 dimin[key] = nil;
924 end
925 end
926 SHT_SetHeight();
927 end
928  
929 if ( SHTvars["numBars"] > 0 ) then
930 SHunterTimersFrame:Show();
931 SHunterTimersFrame:SetAlpha( SHTvars["overallalpha"] );
932 else
933 local alpha = SHunterTimersFrame:GetAlpha() - 0.05;
934 if( alpha > 0 ) then
935 SHunterTimersFrame:SetAlpha(alpha);
936 else
937 SHunterTimersFrame:Hide();
938 end
939 end
940 end
941 function SHT_init()
942 if( not SHTvars ) then
943 SHTvars = {};
944 SHTvars["bg"] = { r=0, g=0, b=0, a=7 };
945 end
946 if( SHTvars[SHT_ON] == nil ) then
947 SHTvars[SHT_ON] = true;
948 end
949 if( not SHTvars["borderalpha"] ) then
950 SHTvars["borderalpha"] = {
951 [1] = 1;
952 [2] = 1;
953 [3] = 1;
954 [4] = 1;
955 };
956 end
957 SHunterTimersFrame:SetBackdropColor( SHTvars["bg"].r, SHTvars["bg"].g, SHTvars["bg"].b, SHTvars["bg"].a );
958 SHunterTimersFrame:SetBackdropBorderColor( unpack(SHTvars["borderalpha"]) );
959 SHTvars["numBars"] = 0;
960 SHunterTimers_Real_UseAction = UseAction;
961 SHunterTimers_Real_CastSpellByName = CastSpellByName;
962 SHunterTimers_Real_CastSpell = CastSpell;
963 if( not SHTvars["skills"] ) then
964 SHTvars["skills"] = {};
965 end
966  
967 for i=1, SHT_NUM_TIMERS do
968 if( SHTvars["skills"][SHT_OPTIONS_TIMERS[i]] == nil ) then
969 SHTvars["skills"][SHT_OPTIONS_TIMERS[i]] = true;
970 end
971 end
972  
973 if( not SHTvars["shotdelay"] ) then
974 SHTvars["shotdelay"] = 200;
975 end
976 if( not SHTvars["aimeddelay"] ) then
977 SHTvars["aimeddelay"] = 200;
978 end
979  
980 if( not SHTvars["scale"] ) then
981 SHTvars["scale"] = UIParent:GetScale();
982 end
983  
984 if( SHTvars["locked"] == nil ) then
985 SHTvars["locked"] = false;
986 end
987  
988 if( not SHTvars["locked"] ) then
989 SHunterTimersAnchor:Show();
990 else
991 SHunterTimersAnchor:Hide();
992 end
993  
994 if( not SHTvars["mili"] ) then
995 SHTvars["mili"] = 2;
996 end
997  
998 if( SHTvars["flash"] == nil ) then
999 SHTvars["flash"] = 5;
1000 end
1001  
1002 if( not SHTvars["skillcolor"] ) then
1003 local r, g, b = SHunterTimersStatus1BarLeftText:GetTextColor();
1004 --local a = SHunterTimersStatus1BarLeftText:GetAlpha();
1005 SHTvars["skillcolor"] = {
1006 [1] = r,
1007 [2] = g,
1008 [3] = b,
1009 [4] = 1
1010 };
1011 end
1012  
1013 if( not SHTvars["timecolor"] ) then
1014 local r, g, b = SHunterTimersStatus1BarRightText:GetTextColor();
1015 --local a = SHunterTimersStatus1BarRightText:GetAlpha();
1016 SHTvars["timecolor"] = {
1017 [1] = r,
1018 [2] = g,
1019 [3] = b,
1020 [4] = 1
1021 };
1022 end
1023  
1024 if( not SHTvars["targetcolor"] ) then
1025 local r, g, b = SHunterTimersStatus1BarLeftText:GetTextColor();
1026 --local a = SHunterTimersStatus1BarRightText:GetAlpha();
1027 SHTvars["targetcolor"] = {
1028 [1] = r,
1029 [2] = g,
1030 [3] = b,
1031 [4] = 1
1032 };
1033 end
1034  
1035 if( not SHTvars["barstartcolor"] ) then
1036 SHTvars["barstartcolor"] = {
1037 [1] = 0,
1038 [2] = 0.8,
1039 [3] = 0,
1040 [4] = 1 };
1041 end
1042 if( not SHTvars["barstartcolor"][4] ) then
1043 SHTvars["barstartcolor"][4] = 1;
1044 end
1045 if( not SHTvars["bardelta"] ) then
1046 SHTvars["bardelta"] = {
1047 [1] = 0.8,
1048 [2] = -0.8,
1049 [3] = 0,
1050 [4] = 0};
1051 end
1052 if( not SHTvars["bardelta"][4] ) then
1053 SHTvars["bardelta"][4] = 0;
1054 end
1055 if( SHTvars["step"] == nil ) then
1056 SHTvars["step"] = 0.015;
1057 end
1058 if( SHTvars["colorchange"] == nil ) then
1059 SHTvars["colorchange"] = false;
1060 end
1061 if( not SHTvars["bardistance"] ) then
1062 SHTvars["bardistance"] = 10;
1063 end
1064  
1065 if( SHTvars["down"] == nil ) then
1066 SHTvars["down"] = true;
1067 end
1068  
1069 if( SHTvars["down"] ) then
1070 SHunterTimersFrame:ClearAllPoints();
1071 SHunterTimersFrame:SetPoint( "TOPLEFT", "SHunterTimersAnchor", "BOTTOMRIGHT" );
1072 else
1073 SHunterTimersFrame:ClearAllPoints();
1074 SHunterTimersFrame:SetPoint( "BOTTOMLEFT", "SHunterTimersAnchor", "TOPRIGHT" );
1075 end
1076  
1077 if( SHTvars["append"] == nil ) then
1078 SHTvars["append"] = false;
1079 end
1080  
1081 if( not SHTvars["overallalpha"] ) then
1082 SHTvars["overallalpha"] = 1;
1083 end
1084  
1085 SHunterTimers_ClearActiveSpells();
1086  
1087 for i=1, SHT_NUM_TIMERS do --Check boxes
1088 getglobal("SHunterTimersOptionsTimersCheckButton"..i.."Text"):SetText(SHT_OPTIONS_TIMERS[i]);
1089 end
1090  
1091 for i=1, SHT_NUM_OPTIONS do --Check boxes
1092 getglobal("SHunterTimersOptionsBarsCheckButton"..i.."Text"):SetText(SHT_OPTIONS_BARS[i]);
1093 end
1094  
1095 for i=1, SHT_NUM_SLIDERS do --Sliders
1096 getglobal("SHunterTimersOptionsBarsSlider"..i.."SliderTitle"):SetText(SHT_OPTIONS_SLIDER[i]);
1097 getglobal("SHunterTimersOptionsBarsSlider"..i.."SliderLow"):SetText(SHT_OPTIONS_SLIDER_ENDS[i][1])
1098 getglobal("SHunterTimersOptionsBarsSlider"..i.."SliderHigh"):SetText(SHT_OPTIONS_SLIDER_ENDS[i][2]);
1099 end
1100  
1101 if( not SHTvars["textures"] ) then
1102 SHTvars["textures"] = {};
1103 end
1104  
1105 if( SHTvars["showtex"] == nil ) then
1106 SHTvars["showtex"] = true;
1107 end
1108 if( SHTvars["largetex"] == nil ) then
1109 SHTvars["largetex"] = false;
1110 end
1111  
1112 if( SHTvars["hidetext"] == nil ) then
1113 SHTvars["hidetext"] = false;
1114 end
1115  
1116 if( SHTvars["hidetime"] == nil ) then
1117 SHTvars["hidetime"] = false;
1118 end
1119  
1120 if( SHTvars["gap"] == nil ) then
1121 SHTvars["gap"] = true;
1122 end
1123  
1124 if( SHTvars["padding"] == nil ) then
1125 SHTvars["padding"] = true;
1126 end
1127  
1128 if( not SHTvars["barheight"] ) then
1129 SHTvars["barheight"] = 10;
1130 end
1131  
1132 if( SHTvars["sticky"] == nil ) then
1133 SHTvars["sticky"] = true;
1134 end
1135  
1136 if( SHTvars["traptimemult"] == nil ) then
1137 SHTvars["traptimemult"] = 1;
1138 end
1139  
1140 getglobal("SHunterTimersOptionsTimersLabel1Label"):SetText(SHT_OPTIONS_TIMERS_TEXT);
1141  
1142 for i=1, SHT_NUM_LABELS do
1143 getglobal("SHunterTimersOptionsBarsLabel"..i.."Label"):SetText(SHT_OPTIONS_LABELS[i]);
1144 end
1145  
1146 getglobal("SHunterTimersOptionsTitleString"):SetText("Sorren's Hunter Timers "..SHT_VERSION);
1147  
1148 SHunterTimers_SetSettings();
1149  
1150 SHunterTimersOptions:SetScale(UIParent:GetScale()*0.8);
1151 end
1152  
1153 function SHunterTimersFrame_OnEvent()
1154 if ( shtdebug ) then
1155 if ( arg1 ) then
1156 DEFAULT_CHAT_FRAME:AddMessage(event.." "..arg1, 1, 0, 0 );
1157 else
1158 DEFAULT_CHAT_FRAME:AddMessage(event, 1, 0, 0 );
1159 end
1160 end
1161  
1162 if( event == "VARIABLES_LOADED" ) then
1163 SHT_init();
1164 return;
1165 end
1166 if( event == "SPELLS_CHANGED" ) then
1167 SHunterTimers_UpdateSpells();
1168 return;
1169 end
1170 if( event == "CHARACTER_POINTS_CHANGED" or event == "PLAYER_ALIVE" ) then
1171 local _, _, _, _, rank = GetTalentInfo( 3, 7 ); --Clever traps
1172 SHTvars["traptimemult"] = 1 + (rank * 0.15);
1173 return;
1174 end
1175 if( not SHTvars[SHT_ON] ) then
1176 return;
1177 end
1178 if( event == "CHAT_MSG_SPELL_PERIODIC_CREATURE_DAMAGE" ) or ( event == "CHAT_MSG_SPELL_PERIODIC_HOSTILEPLAYER_DAMAGE" ) then
1179 if( string.find( arg1, SHT_TRAP ) ) then
1180 if( trapTimer ) then
1181 for mob, effect in string.gfind( arg1, SHT_TRAP_AFFLICT_STRING ) do
1182 --DEFAULT_CHAT_FRAME:AddMessage(effect.." "..mob);
1183 SHunterTimers_addDebuff( effect, mob );
1184 end
1185 end
1186 elseif( string.find( arg1, SHT_FEAR_BEAST ) ) then
1187 for mob, effect in string.gfind( arg1, SHT_AFFLICT_STRING ) do
1188 --DEFAULT_CHAT_FRAME:AddMessage(effect.." "..mob);
1189 if( string.find(effect, SHT_FEAR_BEAST) ) and ( mob == UnitName("target") ) then
1190 SHTvars["fearbeast"] = true;
1191 SHunterTimers_addDebuff( SHT_FEAR_BEAST, mob );
1192 end
1193 end
1194 elseif( string.find( arg1, SHT_EXPOSE_WEAKNESS ) ) then
1195 for mob, effect in string.gfind( arg1, SHT_AFFLICT_STRING ) do
1196 --DEFAULT_CHAT_FRAME:AddMessage(effect.." "..mob);
1197 if( string.find(effect, SHT_EXPOSE_WEAKNESS) ) and ( mob == UnitName("target") ) then
1198 SHTvars["exposeweak"] = true;
1199 SHunterTimers_addDebuff( SHT_EXPOSE_WEAKNESS, mob );
1200 end
1201 end
1202 elseif( string.find( arg1, SHT_ENTRAPMENT ) ) then
1203 for mob, effect in string.gfind( arg1, SHT_AFFLICT_STRING ) do
1204 --DEFAULT_CHAT_FRAME:AddMessage(effect.." "..mob);
1205 if( string.find(effect, SHT_ENTRAPMENT) ) and ( mob == UnitName("target") ) then
1206 SHTvars["entrapment"] = true;
1207 SHunterTimers_addDebuff( SHT_ENTRAPMENT, mob );
1208 end
1209 end
1210 end
1211 elseif( event == "CHAT_MSG_SPELL_PERIODIC_SELF_BUFFS" ) then
1212 --DEFAULT_CHAT_FRAME:AddMessage(event.." "..arg1, 1, 0, 0 );
1213 if( string.find( arg1, SHT_QUICK_SHOTS ) ) then
1214 SHTvars["quick"] = true;
1215 SHTvars["quicktime"] = GetTime();
1216 if(SHTvars["skills"][SHT_QUICK_SHOTS]) then
1217 SHunterTimersFrame_add( 12000, SHT_QUICK_SHOTS );
1218 end
1219 elseif( string.find( arg1, SHT_RAPID_FIRE ) ) then
1220 SHTvars["rapid"] = true;
1221 SHTvars["rapidtime"] = GetTime();
1222 if (SHTvars["skills"][SHT_RAPID_FIRE]) then
1223 SHunterTimersFrame_add( 15000, SHT_RAPID_FIRE );
1224 end
1225 elseif( string.find( arg1, SHT_PRIMAL_BLESSING ) ) then
1226 SHTvars["primalblessing"] = true;
1227 if (SHTvars["skills"][SHT_PRIMAL_BLESSING]) then
1228 SHunterTimersFrame_add( 12000, SHT_PRIMAL_BLESSING );
1229 end
1230 elseif( string.find( arg1, SHT_DETERRENCE ) and SHTvars["skills"][SHT_DETERRENCE] ) then
1231 SHTvars["deterrence"] = true;
1232 SHunterTimersFrame_add( 10000, SHT_DETERRENCE );
1233 elseif( string.find( arg1, SHT_BERSERKING ) ) then
1234 SHTvars["berserking"] = true;
1235 currentHealth = UnitHealth("player");
1236 maxHealth = UnitHealthMax("player");
1237 percentHealth = currentHealth / maxHealth;
1238 if(percentHealth >= 0.40) then
1239 berserkValue = (1.30 - percentHealth)/3;
1240 else
1241 berserkValue = 0.30;
1242 end
1243 if (SHTvars["skills"][SHT_BERSERKING]) then
1244 SHunterTimersFrame_add( 10000, SHT_BERSERKING );
1245 end
1246 elseif( string.find( arg1, SHT_DEVILSAUR_PROC ) ) then
1247 if ( SHTvars["skills"][SHT_DEVILSAUR] ) then
1248 SHunterTimersFrame_add( 20000, SHT_DEVILSAUR );
1249 SHTvars["devilsaur"] = true;
1250 end
1251 elseif( string.find( arg1, SHT_ZHM_PROC ) ) then
1252 if ( SHTvars["skills"][SHT_ZHM] ) then
1253 SHunterTimersFrame_add( 20000, SHT_ZHM );
1254 SHTvars["zhm"] = true;
1255 end
1256 elseif( string.find( arg1, SHT_EARTHSTRIKE ) ) then
1257 if ( SHTvars["skills"][SHT_EARTHSTRIKE] ) then
1258 SHunterTimersFrame_add( 20000, SHT_EARTHSTRIKE );
1259 SHTvars["earthstrike"] = true;
1260 end
1261 elseif( string.find( arg1, SHT_SWARMGUARD ) ) then
1262 if ( SHTvars["skills"][SHT_SWARMGUARD] ) then
1263 SHunterTimersFrame_add( 30000, SHT_SWARMGUARD );
1264 SHTvars["swarmguard"] = true;
1265 end
1266 elseif( string.find( arg1, SHT_JOM_GABBAR ) ) then
1267 if ( SHTvars["skills"][SHT_JOM_GABBAR] and not SHTvars["jomgabbar"] ) then
1268 SHunterTimersFrame_add( 20000, SHT_JOM_GABBAR );
1269 SHTvars["jomgabbar"] = true;
1270 end
1271 elseif( string.find( arg1, SHT_KISS_SPIDER ) ) then
1272 SHTvars["spider"] = true;
1273 if (SHTvars["skills"][SHT_KISS_SPIDER]) then
1274 SHunterTimersFrame_add( 15000, SHT_KISS_SPIDER );
1275 end
1276 end
1277 elseif( event == "CHAT_MSG_SPELL_PET_DAMAGE" ) then
1278 if( string.find( arg1, SHT_RESIST ) or string.find( arg1, SHT_IMMUNE) ) then
1279 if( string.find( arg1, SHT_INTIM ) ) then
1280 for i=1, SHTvars["numBars"] do
1281 local text = getglobal("SHunterTimersStatus"..i).spell;
1282 if( string.find( text, SHT_PET_INTIM ) ) then
1283 getglobal("SHunterTimersStatus"..i).endTime = 0;
1284 end
1285 end
1286 else
1287 for trap in string.gfind( arg1, SHT_FIND_TRAP_FAILED ) do
1288 if( trapTimer ) and ( string.find( trap, SHT_FREEZING_TRAP ) or string.find( trap, SHT_IMMO_TRAP ) )then
1289 for i=1, SHTvars["numBars"] do
1290 local text = getglobal("SHunterTimersStatus"..i.."BarLeftText"):GetText();
1291 if( string.find( text, trap.." "..SHT_PRIMED ) ) then
1292 getglobal("SHunterTimersStatus"..i).endTime = 0;
1293 end
1294 end
1295 end
1296 end
1297 end
1298 end
1299 elseif( event == "CHAT_MSG_SPELL_SELF_DAMAGE" ) then
1300 if(SHTvars["skills"][SHT_WING_CLIP]) and ( string.find( arg1, SHT_YOUR..SHT_WING_CLIP ) ) and ( string.find( arg1, SHT_HITS ) or string.find(arg1, SHT_CRITS ) ) then
1301 SHTvars["wingclip"] = true;
1302 local name = UnitName("target");
1303 SHunterTimersFrame_add( 10000, SHT_WING_CLIP, name );
1304 elseif( string.find( arg1, SHT_FAILED ) ) then
1305 local name = UnitName("target");
1306 for spell in string.gfind( arg1, SHT_FAILED_STRING) do
1307 --DEFAULT_CHAT_FRAME:AddMessage(spell);
1308 for i=1, SHTvars["numBars"] do
1309 local barframe = getglobal("SHunterTimersStatus"..i);
1310 --local text = getglobal("SHunterTimersStatus"..i.."BarLeftText"):GetText();
1311 if( barframe.spell == spell ) and ( barframe.target == name )then
1312 getglobal("SHunterTimersStatus"..i).endTime = 0;
1313 end
1314 end
1315 end
1316 elseif( string.find(arg1, SHT_MISSES ) ) then
1317 local name = UnitName("target");
1318 for spell in string.gfind( arg1, SHT_MISSES_STRING ) do
1319 for i=1, SHTvars["numBars"] do
1320 local barframe = getglobal("SHunterTimersStatus"..i);
1321 --local text = getglobal("SHunterTimersStatus"..i.."BarLeftText"):GetText();
1322 if( barframe.spell == spell ) and ( barframe.target == name )then
1323 getglobal("SHunterTimersStatus"..i).endTime = 0;
1324 end
1325 end
1326 end
1327 elseif(SHTvars["skills"][SHT_COUNTER]) and ( string.find( arg1, SHT_YOUR..SHT_COUNTER ) and (string.find( arg1, SHT_HITS ) or string.find( arg1, SHT_CRITS )) )then
1328 SHunterTimersFrame_add( 5000, SHT_COUNTER, UnitName("target") );
1329 end
1330 elseif( event == "CHAT_MSG_COMBAT_HOSTILE_DEATH" ) then
1331 if( SHTvars["numBars"] > 0 ) then
1332 for target in string.gfind( arg1, SHT_DIES ) do
1333 checkForTarget = target;
1334 end
1335 checkForTargetDeath = GetTime();
1336 end
1337 elseif( event == "CHAT_MSG_MONSTER_EMOTE" ) then
1338 if( SHTvars["skills"][SHT_FRENZY] and (string.find(arg1, SHT_FRENZY_EMOTE ) or string.find(arg1, SHT_FRENZY_FLAMEGOR ) )) then
1339 if( arg2 == SHT_CHROMAGGUS ) then
1340 SHunterTimersFrame_add( 15000, SHT_FRENZY, SHT_CHROMAGGUS );
1341 elseif( arg2 == SHT_FLAMEGOR ) then
1342 SHunterTimersFrame_add( 10000, SHT_FRENZY, SHT_FLAMEGOR );
1343 elseif( arg2 == SHT_MAGMADAR ) then
1344 SHunterTimersFrame_add( 15000, SHT_FRENZY, SHT_MAGMADAR );
1345 elseif( arg2 == SHT_HUHURAN ) then
1346 SHunterTimersFrame_add( 10000, SHT_FRENZY, SHT_HUHURAN );
1347 elseif( arg2 == SHT_GLUTH ) then
1348 SHunterTimersFrame_add( 10000, SHT_FRENZY, SHT_GLUTH );
1349 end
1350 end
1351 elseif( event == "PLAYER_TARGET_CHANGED" ) then
1352 if(SHTvars["numBars"]== 0 ) then
1353 return;
1354 end
1355 local time = GetTime();
1356 if( time - checkForTargetDeath < 1 ) then
1357 for num = 1, SHTvars["numBars"], 1 do
1358 --local text = getglobal("SHunterTimersStatus"..num.."BarLeftText"):GetText();
1359 local barframe = getglobal("SHunterTimersStatus"..num);
1360 if( barframe.target == checkForTarget ) then
1361 barframe.endTime = 0;
1362 end
1363 end
1364 end
1365 elseif( event == "SPELLCAST_START" ) then
1366 --DEFAULT_CHAT_FRAME:AddMessage(event.." "..arg1, 1, 0, 0 );
1367 checkForSpellFail = true;
1368 checkForTarget = UnitName("target");
1369 checkForSpellName = arg1;
1370 elseif( event == "SPELLCAST_FAILED" ) then
1371 if( checkForSpellFail ) then
1372 if( SHTvars["skills"][SHT_AIMED_SHOT] and ( checkForSpellName == SHT_AIMED_SHOT ) ) then
1373 SHTvars["aimed"] = false;
1374 end
1375 checkForSpellFail = false;
1376 checkForSpellName = nil;
1377 end
1378 elseif( event == "SPELLCAST_STOP" ) then
1379 --DEFAULT_CHAT_FRAME:AddMessage(event, 1, 0, 0 );
1380 --DEFAULT_CHAT_FRAME:AddMessage(checkForSpellName, 1, 0, 0 );
1381 if( checkForSpellFail ) then
1382 checkForSpellFail = false;
1383 local name = UnitName("target");
1384 if( SHT_sfind( checkForSpellName, SHT_STING ) ) then
1385 SHunterTimers_addDebuff( checkForSpellName, name );
1386 elseif( SHTvars["skills"][SHT_INTIM]) and ( string.find( checkForSpellName, SHT_INTIM ) ) then
1387 SHTvars["petIntim"] = true;
1388 SHunterTimersFrame_add( 15000, SHT_PET_INTIM );
1389 elseif( SHTvars["skills"][SHT_BW]) and ( string.find( checkForSpellName, SHT_BW ) ) then
1390 SHunterTimersFrame_add( 15000, checkForSpellName );
1391 elseif( SHTvars["skills"][SHT_FLARE]) and ( string.find( checkForSpellName, SHT_FLARE ) ) then
1392 SHunterTimersFrame_add( 30000, checkForSpellName );
1393 elseif( SHTvars["skills"][SHT_HUNTERS_MARK]) and ( string.find( checkForSpellName, SHT_HUNTERS_MARK ) ) then
1394 if ( name ~= nil ) then
1395 SHTvars["huntersmark"] = true;
1396 SHunterTimers_addDebuff( SHT_HUNTERS_MARK, name );
1397 end
1398 elseif( string.find( checkForSpellName, SHT_TRAP ) ) then
1399 if( SHTvars["skills"][checkForSpellName]) then
1400 trapTimer = true;
1401 SHunterTimersFrame_add( 60000, checkForSpellName.." "..SHT_PRIMED );
1402 end
1403 elseif( SHTvars["skills"][SHT_SCATTER]) and ( string.find( checkForSpellName, SHT_SCATTER ) ) then
1404 local duration = 4000;
1405 if(name) and ( dimin[name] ) and ((GetTime() - dimin[name]["time"]) < 20) then
1406 for i=1, dimin[name]["times"] do
1407 duration = duration/2;
1408 end
1409 end
1410 SHTvars["scatter"] = true;
1411 SHunterTimersFrame_add( duration, checkForSpellName, name );
1412 elseif( SHTvars["skills"][SHT_FEAR_BEAST]) and ( checkForSpellName == SHT_FEAR_BEAST ) then
1413 SHTvars["fearbeast"] = true;
1414 elseif( SHTvars["skills"][SHT_CONC_SHOT]) and ( checkForSpellName == SHT_CONC_SHOT ) then
1415 SHTvars["concuss"] = true;
1416 SHunterTimers_addDebuff( checkForSpellName, name );
1417 elseif( SHTvars["skills"][SHT_AIMED_SHOT] and ( checkForSpellName == SHT_AIMED_SHOT ) ) then
1418 SHTvars["aimed"] = false;
1419 else
1420 SHunterTimers_addDebuff( checkForSpellName, name );
1421 end
1422 checkForSpellName = nil;
1423 elseif( shtautoshot ) and ( not shtcasting ) then
1424 SHT_AddAutoShot();
1425 end
1426 if( shtcasting ) then
1427 shtcasting = false;
1428 end
1429 --[[DEFAULT_CHAT_FRAME:AddMessage(GetTime() - autodelta );
1430 DEFAULT_CHAT_FRAME:AddMessage("auto: "..GetTime() - shtautotime );
1431 autodelta = GetTime();
1432 shtautotime = GetTime();--]]
1433 --DEFAULT_CHAT_FRAME:AddMessage(checkForSpell, 1, 0, 0 );
1434  
1435 elseif( event == "UNIT_AURA" ) then
1436 if( arg1 == "target" ) then
1437 --DEFAULT_CHAT_FRAME:AddMessage(event.." "..arg1, 1, 0, 0 );
1438 local time = GetTime();
1439 local name = UnitName("target");
1440 --DEFAULT_CHAT_FRAME:AddMessage(time, 1, 0, 0 );
1441 local i = 1;
1442 while( UnitDebuff("target", i ) ) do
1443 SHuntersTooltip:ClearLines();
1444 SHuntersTooltip:SetUnitDebuff("target", i );
1445 targetDebuffs[i] = SHuntersTooltipTextLeft1:GetText();
1446 --DEFAULT_CHAT_FRAME:AddMessage(i.." "..targetDebuffs[i], 1, 0, 0 );
1447  
1448 if( string.find( targetDebuffs[i], SHT_INTIM ) ) and ( not SHTvars["intimidate"] ) then
1449 SHTvars["intimidate"] = true;
1450 SHunterTimers_addDebuff( SHT_INTIM, name );
1451 break;
1452 elseif( string.find( targetDebuffs[i], SHT_IMP_CONC ) ) and ( not SHTvars["impconc"] ) then
1453 SHTvars["impconc"] = true;
1454 SHunterTimers_addDebuff( SHT_IMP_CONC_SHORT, name );
1455 break;
1456 elseif( string.find( targetDebuffs[i], SHT_IMP_WC ) ) and ( not SHTvars["impwing"] ) then
1457 SHTvars["impwing"] = true;
1458 SHunterTimersFrame_add( 5000, SHT_IMP_WC_SHORT, name );
1459 break;
1460 elseif( string.find( targetDebuffs[i], SHT_EXPOSE_WEAKNESS ) ) and ( not SHTvars["exposeweak"] ) then
1461 SHTvars["exposeweak"] = true;
1462 SHunterTimers_addDebuff( SHT_EXPOSE_WEAKNESS, name );
1463 break;
1464 end
1465 i = i + 1;
1466 end
1467 end
1468 elseif( event == "CHAT_MSG_SPELL_AURA_GONE_OTHER" ) then
1469 for effect, target in string.gfind(arg1, SHT_FADE_STRING ) do
1470  
1471 if( SHTvars["freezing"] ) and string.find(effect, SHT_FREEZING_TRAP ) then
1472 for i=1, SHTvars["numBars"] do
1473 local barframe = getglobal( "SHunterTimersStatus"..i);
1474 --local text = getglobal( "SHunterTimersStatus"..i.."BarLeftText"):GetText();
1475 if( barframe.spell == SHT_FREEZING_TRAP ) and ( barframe.target == target ) then
1476 --SHunterTimersFrame_add( 20000, "Diminishing Returns" );
1477 getglobal("SHunterTimersStatus"..i).endTime = 0;
1478 end
1479 end
1480 if( not dimin[target] ) then
1481 dimin[target] = {};
1482 end
1483 dimin[target]["time"] = GetTime();
1484 if( dimin[target]["times"] == nil ) then
1485 dimin[target]["times"] = 1;
1486 else
1487 dimin[target]["times"] = dimin[target]["times"] + 1;
1488 end
1489 elseif( SHTvars["scatter"] ) and string.find( effect, SHT_SCATTER ) then
1490 for i=1, SHTvars["numBars"] do
1491 local barframe = getglobal( "SHunterTimersStatus"..i)
1492 --local text = getglobal("SHunterTimersStatus"..i.."BarLeftText"):GetText();
1493 if( barframe.spell == SHT_SCATTER ) and ( barframe.target == target ) then
1494 getglobal("SHunterTimersStatus"..i).endTime = 0;
1495  
1496 end
1497 end
1498 if( not dimin[target] ) then
1499 dimin[target] = {};
1500 end
1501 dimin[target]["time"] = GetTime();
1502 if( dimin[target]["times"] == nil ) then
1503 dimin[target]["times"] = 1;
1504 else
1505 dimin[target]["times"] = dimin[target]["times"] + 1;
1506 end
1507 elseif( SHTvars["fearbeast"] ) and string.find( effect, SHT_FEAR_BEAST ) then
1508 for i=1, SHTvars["numBars"] do
1509 local barframe = getglobal( "SHunterTimersStatus"..i);
1510 --local text = getglobal("SHunterTimersStatus"..i.."BarLeftText"):GetText();
1511 if( barframe.spell == SHT_FEAR_BEAST ) and (barframe.target == target ) then
1512 getglobal("SHunterTimersStatus"..i).endTime = 0;
1513 end
1514 end
1515 elseif( SHTvars["wyvern"] ) and string.find( effect, SHT_WYVERN ) then
1516 for i=1, SHTvars["numBars"] do
1517 local barframe = getglobal( "SHunterTimersStatus"..i);
1518 local text = getglobal("SHunterTimersStatus"..i.."BarLeftText"):GetText();
1519 if( text == SHT_WYVERN_TEXT ) and (barframe.target == target ) then
1520 getglobal("SHunterTimersStatus"..i).endTime = 0;
1521 end
1522 end
1523 if( not dimin[target] ) then
1524 dimin[target] = {};
1525 end
1526 dimin[target]["time"] = GetTime();
1527 if( dimin[target]["times"] == nil ) then
1528 dimin[target]["times"] = 1;
1529 else
1530 dimin[target]["times"] = dimin[target]["times"] + 1;
1531 end
1532 elseif( SHTvars["wingclip"] ) and string.find( effect, SHT_WING_CLIP ) and not ( string.find( effect, SHT_IMP_WC ) ) then
1533 for i=1, SHTvars["numBars"] do
1534 --local text = getglobal( "SHunterTimersStatus"..i.."BarLeftText"):GetText();
1535 local barframe = getglobal( "SHunterTimersStatus"..i);
1536 if( barframe.spell == SHT_WING_CLIP ) and ( barframe.target == target ) then
1537 getglobal("SHunterTimersStatus"..i).endTime = 0;
1538 end
1539 end
1540 elseif( SHTvars["exposeweak"] ) and string.find( effect, SHT_EXPOSE_WEAKNESS ) then
1541 for i=1, SHTvars["numBars"] do
1542 local barframe = getglobal( "SHunterTimersStatus"..i);
1543 if( barframe.spell == SHT_EXPOSE_WEAKNESS ) and ( barframe.target == target ) then
1544 getglobal("SHunterTimersStatus"..i).endTime = 0;
1545 end
1546 end
1547 elseif( SHTvars["entrapment"] ) and string.find( effect, SHT_ENTRAPMENT ) then
1548 for i=1, SHTvars["numBars"] do
1549 local barframe = getglobal( "SHunterTimersStatus"..i);
1550 if( barframe.spell == SHT_ENTRAPMENT ) and ( barframe.target == target ) then
1551 getglobal("SHunterTimersStatus"..i).endTime = 0;
1552 end
1553 end
1554 elseif( SHTvars["huntersmark"] ) and string.find( effect, SHT_HUNTERS_MARK ) then
1555 for i=1, SHTvars["numBars"] do
1556 local barframe = getglobal( "SHunterTimersStatus"..i);
1557 if( barframe.spell == SHT_HUNTERS_MARK ) and ( barframe.target == target ) then
1558 getglobal("SHunterTimersStatus"..i).endTime = 0;
1559 end
1560 end
1561 end
1562 end
1563 elseif( event == "CHAT_MSG_SPELL_AURA_GONE_SELF" ) then
1564 --DEFAULT_CHAT_FRAME:AddMessage(event.." "..arg1, 1, 0, 0);
1565 for effect, target in string.gfind(arg1, SHT_FADE_STRING ) do
1566 if( SHTvars["quick"] ) and string.find( effect, SHT_QUICK_SHOTS ) then
1567 SHTvars["quick"] = false;
1568 for i=1, SHTvars["numBars"] do
1569 local barframe = getglobal( "SHunterTimersStatus"..i);
1570 if( barframe.spell == SHT_QUICK_SHOTS ) then
1571 getglobal("SHunterTimersStatus"..i).endTime = 0;
1572 end
1573 end
1574 elseif( SHTvars["rapid"] ) and string.find( effect, SHT_RAPID_FIRE ) then
1575 SHTvars["rapid"] = false;
1576 for i=1, SHTvars["numBars"] do
1577 local barframe = getglobal( "SHunterTimersStatus"..i);
1578 if( barframe.spell == SHT_RAPID_FIRE ) then
1579 getglobal("SHunterTimersStatus"..i).endTime = 0;
1580 end
1581 end
1582 elseif( SHTvars["primalblessing"] ) and string.find( effect, SHT_PRIMAL_BLESSING ) then
1583 for i=1, SHTvars["numBars"] do
1584 local barframe = getglobal( "SHunterTimersStatus"..i);
1585 if( barframe.spell == SHT_PRIMAL_BLESSING ) then
1586 getglobal("SHunterTimersStatus"..i).endTime = 0;
1587 end
1588 end
1589 elseif( SHTvars["berserking"] ) and string.find( effect, SHT_BERSERKING ) then
1590 SHTvars["berserking"] = false;
1591 for i=1, SHTvars["numBars"] do
1592 local barframe = getglobal( "SHunterTimersStatus"..i);
1593 if( barframe.spell == SHT_BERSERKING ) then
1594 getglobal("SHunterTimersStatus"..i).endTime = 0;
1595 end
1596 end
1597 elseif( SHTvars["spider"] ) and string.find( effect, SHT_KISS_SPIDER ) then
1598 SHTvars["spider"] = false;
1599 for i=1, SHTvars["numBars"] do
1600 local barframe = getglobal( "SHunterTimersStatus"..i);
1601 if( barframe.spell == SHT_KISS_SPIDER ) then
1602 getglobal("SHunterTimersStatus"..i).endTime = 0;
1603 end
1604 end
1605 end
1606 end
1607 elseif( event == "START_AUTOREPEAT_SPELL" ) then
1608 shtautotime = GetTime();
1609 shtautoshot = true;
1610 --SHT_AddAutoShot();
1611 elseif( event == "STOP_AUTOREPEAT_SPELL" ) then
1612 shtautoshot = false;
1613 end
1614  
1615 end
1616  
1617 function SHunterTimers_addDebuff( debuff, mob )
1618 if (SHTvars["skills"][SHT_SERPENT]) and ( debuff == SHT_SERPENT ) then
1619 SHunterTimersFrame_add( 15000, SHT_SERPENT, mob );
1620 --currentSting = "Serpent Sting";
1621 elseif(SHTvars["skills"][SHT_SCORPID]) and ( debuff == SHT_SCORPID ) then
1622 SHunterTimersFrame_add( 20000, SHT_SCORPID, mob );
1623 --currentSting = "Scorpid Sting";
1624 elseif(SHTvars["skills"][SHT_VIPER]) and ( debuff == SHT_VIPER ) then
1625 SHunterTimersFrame_add( 8000, SHT_VIPER, mob );
1626 --currentSting = "Viper Sting";
1627 elseif(SHTvars["skills"][SHT_WYVERN]) and ( debuff == SHT_WYVERN ) then
1628 local duration = 12000;
1629 local name = UnitName("target");
1630 if( dimin[name] ) and ( ( GetTime() - dimin[name]["time"]) < 20 )then
1631 for i=1, dimin[name]["times"] do
1632 duration = duration / 2;
1633 end
1634 end
1635 SHTvars["wyvern"] = true;
1636 SHunterTimersFrame_add( duration, SHT_WYVERN_TEXT, name );
1637 elseif(SHTvars["skills"][SHT_CONC_SHOT]) and ( debuff == SHT_IMP_CONC_SHORT ) then
1638 SHunterTimersFrame_add( 3000, SHT_IMP_CONC_SHORT, mob );
1639 elseif(SHTvars["skills"][SHT_FEAR_BEAST] ) and ( debuff == SHT_FEAR_BEAST ) then
1640 SHunterTimersFrame_add( 20000, SHT_FEAR_BEAST, mob );
1641 elseif(SHTvars["skills"][SHT_CONC_SHOT]) and ( debuff == SHT_CONC_SHOT ) then
1642 SHunterTimersFrame_add( 4000, SHT_CONC_SHOT, mob );
1643 elseif(SHTvars["skills"][SHT_HUNTERS_MARK]) and ( debuff == SHT_HUNTERS_MARK ) then
1644 SHunterTimersFrame_add( 120000, SHT_HUNTERS_MARK, mob );
1645 elseif(SHTvars["skills"][SHT_INTIM]) and ( debuff == SHT_INTIM ) then
1646 SHunterTimersFrame_add( 3000, SHT_INTIM, mob );
1647 elseif(SHTvars["skills"][SHT_EXPOSE_WEAKNESS]) and ( debuff == SHT_EXPOSE_WEAKNESS ) then
1648 SHunterTimersFrame_add( 7000, SHT_EXPOSE_WEAKNESS, mob );
1649 elseif(SHTvars["skills"][SHT_ENTRAPMENT]) and ( debuff == SHT_ENTRAPMENT ) then
1650 SHunterTimersFrame_add( 5000, SHT_ENTRAPMENT, mob );
1651 elseif( string.find( debuff, SHT_TRAP ) ) then
1652 if( trapTimer ) then
1653 trapTimer = false;
1654 for num = 1, SHTvars["numBars"] do
1655 local barframe = getglobal( "SHunterTimersStatus"..num);
1656 local text = getglobal("SHunterTimersStatus"..num.."BarLeftText"):GetText();
1657 if( string.find( text, SHT_PRIMED ) ) then
1658 barframe.endTime = 0;
1659 end
1660 end
1661 if(SHTvars["skills"][SHT_FREEZING_TRAP]) and ( string.find( debuff, SHT_FREEZING_TRAP ) ) then
1662 SHTvars["freezing"] = true;
1663 local duration = 20000*SHTvars["traptimemult"];
1664 if(mob) and ( dimin[mob] ) and ( ( GetTime() - dimin[mob]["time"]) < 20 )then
1665 for i=1, dimin[mob]["times"] do
1666 duration = duration / 2;
1667 end
1668 end
1669 SHunterTimersFrame_add( duration, SHT_FREEZING_TRAP, mob );
1670 elseif(SHTvars["skills"][SHT_FROST_TRAP]) and ( string.find( debuff, SHT_FROST_TRAP ) ) then
1671 SHunterTimersFrame_add( 30000*SHTvars["traptimemult"], SHT_FROST_TRAP.." "..SHT_AURA );
1672 elseif(SHTvars["skills"][SHT_IMMO_TRAP]) and ( string.find( debuff, SHT_IMMO_TRAP ) ) then
1673 SHunterTimersFrame_add( 15000, SHT_IMMO_TRAP, mob );
1674 elseif(SHTvars["skills"][SHT_EXPL_TRAP]) and ( string.find( debuff, SHT_EXPL_TRAP ) ) then
1675 SHunterTimersFrame_add( 20000, SHT_EXPL_TRAP.." "..SHT_AURA );
1676 end
1677 end
1678 end
1679 end
1680 function SHunterTimers_cascadeBar( id )
1681 local barframefrom = getglobal("SHunterTimersStatus"..(id+1));
1682 if( not barframefrom ) or not ( barframefrom:IsVisible() and (barframefrom.channeling or barframefrom.fadeOut) )then
1683 getglobal("SHunterTimersStatus"..id):Hide();
1684 SHunterTimers_SetWidths();
1685 SHT_SetHeight();
1686 return;
1687 end
1688  
1689 local barframeto = getglobal("SHunterTimersStatus"..id);
1690 local barto = getglobal("SHunterTimersStatus"..id.."Bar");
1691 local textLeftto = getglobal("SHunterTimersStatus"..id.."BarLeftText");
1692 local textRightto = getglobal("SHunterTimersStatus"..id.."BarRightText");
1693 local iconto = getglobal("SHunterTimersStatus"..id.."Icon");
1694  
1695 id = id + 1;
1696  
1697 local barfrom = getglobal("SHunterTimersStatus"..id.."Bar");
1698 local textLeftfrom = getglobal("SHunterTimersStatus"..id.."BarLeftText");
1699 local textRightfrom = getglobal("SHunterTimersStatus"..id.."BarRightText");
1700  
1701 barframeto.texture = barframefrom.texture;
1702 iconto:SetTexture(barframeto.texture);
1703  
1704 barframeto.startTime = barframefrom.startTime;
1705 barframeto.endTime = barframefrom.endTime;
1706 barframeto.duration = barframefrom.duration;
1707 barframeto.channeling = barframefrom.channeling;
1708 barframeto.fadeOut = barframefrom.fadeOut;
1709 barframeto.target = barframefrom.target;
1710 barframeto.spell = barframefrom.spell;
1711 barto:SetMinMaxValues(barframeto.startTime, barframeto.endTime);
1712 barto:SetValue(barfrom:GetValue());
1713 textLeftto:SetText(textLeftfrom:GetText());
1714 textRightto:SetText(textRightfrom:GetText());
1715 barframeto:SetAlpha(barframefrom:GetAlpha());
1716 barframeto:Show();
1717 SHunterTimers_cascadeBar( id );
1718 end
1719  
1720 function SHunterTimers_shift( id, curr )
1721  
1722 if( id > SHTvars["numBars"] ) or ( SHTvars["numBars"] == 11 ) then
1723 return;
1724 end
1725  
1726 if( not curr ) then
1727 curr = SHTvars["numBars"] + 1;
1728 end
1729  
1730 if( curr == id ) then
1731 --DEFAULT_CHAT_FRAME:AddMessage("shiftend");
1732 return;
1733 end
1734  
1735 SHunterTimers_CopyBar( curr, curr-1 );
1736 SHunterTimers_shift( id, curr-1 );
1737  
1738 end
1739  
1740 function SHunterTimers_CopyBar(to, from)
1741 local barframeto = getglobal("SHunterTimersStatus"..to);
1742 local barto = getglobal("SHunterTimersStatus"..to.."Bar");
1743 local textLeftto = getglobal("SHunterTimersStatus"..to.."BarLeftText");
1744 local textRightto = getglobal("SHunterTimersStatus"..to.."BarRightText");
1745 local iconto = getglobal("SHunterTimersStatus"..to.."Icon");
1746  
1747 local barframefrom = getglobal("SHunterTimersStatus"..from);
1748 local barfrom = getglobal("SHunterTimersStatus"..from.."Bar");
1749 local textLeftfrom = getglobal("SHunterTimersStatus"..from.."BarLeftText");
1750 local textRightfrom = getglobal("SHunterTimersStatus"..from.."BarRightText");
1751  
1752 barframeto.texture = barframefrom.texture;
1753 iconto:SetTexture(barframeto.texture);
1754  
1755 barframeto.startTime = barframefrom.startTime;
1756 barframeto.endTime = barframefrom.endTime;
1757 barframeto.duration = barframefrom.duration;
1758 barframeto.channeling = barframefrom.channeling;
1759 barframeto.fadeOut = barframefrom.fadeOut;
1760 barframeto.target = barframefrom.target;
1761 barframeto.spell = barframefrom.spell;
1762 barto:SetMinMaxValues(barframeto.startTime, barframeto.endTime);
1763 barto:SetValue(barfrom:GetValue());
1764 textLeftto:SetText(textLeftfrom:GetText());
1765 textRightto:SetText(textRightfrom:GetText());
1766 barframeto:SetAlpha(barframefrom:GetAlpha());
1767 barframeto:Show();
1768 end
1769  
1770 function SHunterTimers_AutoCascade(id, last)
1771 if( id == SHT_NUM_BARS ) then
1772 return;
1773 end
1774 if( id == 0 ) then
1775 id = 1;
1776 end
1777 local barframe = getglobal("SHunterTimersStatus"..id);
1778 if( barframe:IsVisible() ) then
1779 SHunterTimers_AutoCascade(id+1, false);
1780 else
1781 local barframenext = getglobal("SHunterTimersStatus"..id+1);
1782 if( barframenext:IsVisible() ) then
1783 SHunterTimers_cascadeBar(id);
1784 if( last ) then
1785 SHunterTimers_AutoCascade( id-1, true );
1786 else
1787 SHunterTimers_AutoCascade( id+1, false );
1788 end
1789 else
1790 SHunterTimers_AutoCascade(id+1, true);
1791 end
1792 end
1793 end
1794  
1795  
1796  
1797 function SHunterTimers_OnUseAction( slot, checkFlags, checkSelf )
1798 SHuntersTooltip:ClearLines();
1799 SHuntersTooltip:SetAction(slot);
1800 local text = SHuntersTooltipTextLeft1:GetText();
1801 SHunterTimers_SetStates(text);
1802 SHunterTimers_Real_UseAction( slot, checkFlags, checkSelf );
1803 end
1804  
1805 function SHunterTimers_OnCastSpell(spellID, spellTab)
1806 SHuntersTooltip:ClearLines();
1807 SHuntersTooltip:SetSpell(spellID, spellTab);
1808 local text = SHuntersTooltipTextLeft1:GetText();
1809 SHunterTimers_SetStates(text);
1810 SHunterTimers_Real_CastSpell(spellID, spellTab);
1811 end
1812  
1813 function SHunterTimers_OnCastSpellByName(spellName)
1814 SHunterTimers_SetStates(spellName);
1815 SHunterTimers_Real_CastSpellByName(spellName);
1816 end
1817  
1818 function SHunterTimers_SetStates(text)
1819 if( text ) then
1820 --DEFAULT_CHAT_FRAME:AddMessage(text);
1821 for spell in string.gfind( text, SHT_SPELL_RANK_STRIP ) do --strip the (Rank #) portion
1822 --DEFAULT_CHAT_FRAME:AddMessage(text.." "..spell);
1823 text = spell;
1824 end
1825 if( string.find( text, SHT_AIMED_SHOT ) ) then
1826 if( SHTvars["skills"][SHT_AIMED_SHOT] and not SHTvars["aimed"]) then
1827 SHTvars["aimed"] = true;
1828 local duration = 3;
1829 if( SHTvars["rapid"] ) then
1830 duration = duration / 1.4;
1831 end
1832 if( SHTvars["quick"] ) then
1833 duration = duration / 1.3;
1834 end
1835 if ( SHTvars["berserking"] ) then
1836 duration = duration / (1 + berserkValue);
1837 end
1838 if( SHTvars["spider"] ) then
1839 duration = duration / 1.2;
1840 end
1841  
1842 shtcasting = true;
1843 local name = UnitName("player");
1844 local arg1 = SHT_AIMED_SHOT;
1845 local arg2 = duration * 1000 + SHTvars["aimeddelay"];
1846  
1847 if( IsAddOnLoaded("MetaHud") and MetaHudOptions["castingbar"] == 1 ) then
1848 MetaHud.spellname = arg1;
1849 MetaHud_EventFrame.startTime = GetTime();
1850 MetaHud_EventFrame.maxValue = MetaHud_EventFrame.startTime + (arg2 / 1000);
1851 MetaHud_EventFrame.holdTime = 0;
1852 MetaHud_EventFrame.casting = 1;
1853 MetaHud_EventFrame.delay = 0;
1854 MetaHud_EventFrame.channeling = nil;
1855 MetaHud_EventFrame.fadeOut = nil;
1856 MetaHud_EventFrame.flash = nil;
1857 MetaHud_EventFrame.duration = floor(arg2 / 100) / 10;
1858 MetaHud.Casting = true;
1859 MetaHud:updateAlpha();
1860 MetaHud_Casttime_Text:SetAlpha(1);
1861 MetaHud_Castdelay_Text:SetAlpha(1);
1862 MetaHud_Casting_Bar:Show();
1863 MetaHud_Flash_Bar:Hide();
1864  
1865 elseif( IsAddOnLoaded("Perl_ArcaneBar") and Perl_ArcaneBar_Config[name]["Enabled"] == 1 ) then
1866 Perl_ArcaneBar:SetStatusBarColor(1.0, 0.7, 0.0, Perl_ArcaneBar_Config[name]["Transparency"]);
1867 Perl_ArcaneBarSpark:Show();
1868 Perl_ArcaneBarFrame.startTime = GetTime();
1869 Perl_ArcaneBarFrame.maxValue = Perl_ArcaneBarFrame.startTime + (arg2 / 1000);
1870 Perl_ArcaneBar:SetMinMaxValues(Perl_ArcaneBarFrame.startTime, Perl_ArcaneBarFrame.maxValue);
1871 Perl_ArcaneBar:SetValue(Perl_ArcaneBarFrame.startTime);
1872 Perl_ArcaneBarFrame:SetAlpha(0.8);
1873 Perl_ArcaneBarFrame.holdTime = 0;
1874 Perl_ArcaneBarFrame.casting = 1;
1875 Perl_ArcaneBarFrame.fadeOut = nil;
1876 Perl_ArcaneBarFrame:Show();
1877 Perl_ArcaneBarFrame.delaySum = 0;
1878 if (Perl_ArcaneBar_Config[name]["ShowTimer"] == 1) then
1879 Perl_ArcaneBar_CastTime:Show();
1880 else
1881 Perl_ArcaneBar_CastTime:Hide();
1882 end
1883 Perl_ArcaneBarFrame.mode = "casting";
1884 end
1885  
1886 if( IsAddOnLoaded("eCastingBar") and eCastingBar_Saved[eCastingBar_Player].Enabled == 1 ) then
1887 eCastingBar_SpellcastStart( "", arg1, arg2 );
1888 elseif ( IsAddOnLoaded("otravi_CastingBar") ) then
1889 otravi_CastingBar:SpellStart(arg1,arg2);
1890 elseif ( IsAddOnLoaded("oCB") ) then
1891 oCB:SpellStart(arg1,arg2);
1892 end
1893  
1894 if( IsAddOnLoaded("ArcHUD2") and ArcHUD:HasModule("Casting") and ArcHUD:IsModuleActive("Casting") ) then
1895 ArcHUD:GetModule("Casting").f:UpdateColor({["r"] = 1.0, ["g"] = 0.7, ["b"] = 0});
1896 ArcHUD:GetModule("Casting").Text:SetText(arg1);
1897 ArcHUD:GetModule("Casting").startValue = 0;
1898 ArcHUD:GetModule("Casting").f:SetMax(arg2);
1899 ArcHUD:GetModule("Casting").channeling = 0;
1900 ArcHUD:GetModule("Casting").f.casting = 1;
1901 ArcHUD:GetModule("Casting").spellstart = GetTime();
1902 ArcHUD:GetModule("Casting").stopSet = false;
1903 if(ArcHUD.db.profile.FadeIC > ArcHUD.db.profile.FadeOOC) then
1904 ArcHUD:GetModule("Casting").f:SetRingAlpha(ArcHUD.db.profile.FadeIC);
1905 else
1906 ArcHUD:GetModule("Casting").f:SetRingAlpha(ArcHUD.db.profile.FadeOOC);
1907 end
1908  
1909 elseif ( IsAddOnLoaded("Bongos_CastBar") ) then
1910 BCastBarCastBar:SetStatusBarColor(1.0, 0.7, 0.0);
1911 BCastBarCastBarSpark:Show();
1912 BCastBarCastBar.startTime = GetTime();
1913 BCastBarCastBar.maxValue = BCastBarCastBar.startTime + (arg2 / 1000);
1914 BCastBarCastBar:SetMinMaxValues(BCastBarCastBar.startTime, BCastBarCastBar.maxValue);
1915 BCastBarCastBar:SetValue(BCastBarCastBar.startTime);
1916 BCastBarCastBarText:SetText(arg1);
1917 BCastBarCastBar:SetAlpha( BCastBarCastBar:GetParent():GetAlpha() );
1918 BCastBarCastBar.holdTime = 0;
1919 BCastBarCastBar.casting = 1;
1920 BCastBarCastBar.fadeOut = nil;
1921 BCastBarCastBar:Show();
1922 BCastBarCastBar.mode = "casting";
1923  
1924 elseif ( IsAddOnLoaded("Nurfed_Hud") ) then
1925 Nurfed_Hudcastingbar:SetVertexColor(1.0, 1.0, 0.0);
1926 Nurfed_Hudcastingspell:SetText(arg1);
1927 Nurfed_Hudcasting.startTime = GetTime();
1928 Nurfed_Hudcasting.maxValue = Nurfed_Hudcasting.startTime + (arg2 / 1000);
1929 Nurfed_Hudcasting:SetAlpha(1.0);
1930 Nurfed_Hudcasting.holdTime = 0;
1931 Nurfed_Hudcasting.casting = 1;
1932 Nurfed_Hudcasting.fadeOut = nil;
1933 Nurfed_Hudcasting:Show();
1934 Nurfed_Hudcasting.mode = "casting";
1935  
1936 else
1937 if( IsAddOnLoaded("CastTime") ) then
1938 CastTime.delaySum = 0;
1939 CastTime.spellname = arg1;
1940 CastTime.startTime = GetTime();
1941 CastTime.maxValue = CastTime.startTime + (arg2 / 1000);
1942 CastTimeFrame:Show();
1943 end
1944  
1945 if( IsAddOnLoaded("CT_MasterMod") ) then
1946 CT_CastBarFrame.spellName = arg1;
1947 end
1948  
1949 if ( IsAddOnLoaded("MetaHud") and MetaHudOptions["bcastingbar"] == 0 ) then
1950  
1951 elseif ( IsAddOnLoaded("Perl_ArcaneBar") and Perl_ArcaneBar_Config[name]["HideOriginal"] == 1 ) then
1952  
1953 elseif ( IsAddOnLoaded("eCastingBar") and eCastingBar_Saved[eCastingBar_Player].Enabled == 1 ) then
1954  
1955 elseif ( IsAddOnLoaded("otravi_CastingBar") ) then
1956  
1957 elseif ( IsAddOnLoaded("oCB") ) then
1958  
1959 else
1960 CastingBarFrameStatusBar:SetStatusBarColor(1.0, 0.7, 0.0);
1961 CastingBarSpark:Show();
1962 CastingBarFrame.startTime = GetTime();
1963 CastingBarFrame.maxValue = CastingBarFrame.startTime + (arg2 / 1000);
1964 CastingBarFrameStatusBar:SetMinMaxValues(CastingBarFrame.startTime, CastingBarFrame.maxValue);
1965 CastingBarFrameStatusBar:SetValue(CastingBarFrame.startTime);
1966 CastingBarText:SetText(arg1);
1967 CastingBarFrame:SetAlpha(1.0);
1968 CastingBarFrame.holdTime = 0;
1969 CastingBarFrame.casting = 1;
1970 CastingBarFrame.fadeOut = nil;
1971 CastingBarFrame:Show();
1972 CastingBarFrame.mode = "casting";
1973 end
1974 end
1975 end
1976 end
1977 if( SHT_sfind( text, SHT_STING )
1978 or string.find( text, SHT_TRAP )
1979 or string.find( text, SHT_INTIM )
1980 or string.find( text, SHT_BW )
1981 or string.find( text, SHT_FLARE )
1982 or string.find( text, SHT_HUNTERS_MARK )
1983 or string.find( text, SHT_CONC_SHOT )
1984 or string.find( text, SHT_SCATTER )
1985 or string.find( text, SHT_AIMED_SHOT ) ) then
1986 checkForSpellFail = true;
1987 checkForSpellName = text;
1988 elseif ( string.find( text, SHT_FEIGN_DEATH ) ) then
1989 -- Do nothing or FD/trap macros break
1990 elseif( not string.find( text, SHT_AUTO_SHOT ) ) then
1991 checkForSpellFail = true;
1992 checkForSpellName = "dummy for autoshot";
1993 --DEFAULT_CHAT_FRAME:AddMessage("Button pressed: "..text, 1, 1, 0 );
1994 end
1995 end
1996 end
1997  
1998 function SHunterTimers_ShowOptions()
1999 for i=1, SHT_NUM_TIMERS do
2000 if( SHTvars["skills"][SHT_OPTIONS_TIMERS[i]] ) then
2001 getglobal("SHunterTimersOptionsTimersCheckButton"..i):SetChecked(1);
2002 else
2003 getglobal("SHunterTimersOptionsTimersCheckButton"..i):SetChecked(0);
2004 end
2005 end
2006  
2007 if( SHTvars[SHT_ON] ) then
2008 SHunterTimersOptionsBarsCheckButtonOn:SetChecked(1);
2009 else
2010 SHunterTimersOptionsBarsCheckButtonOn:SetChecked(0);
2011 end
2012  
2013 if( SHTvars["locked"] ) then
2014 SHunterTimersOptionsBarsCheckButton1:SetChecked(1);
2015 else
2016 SHunterTimersOptionsBarsCheckButton1:SetChecked(0);
2017 end
2018  
2019 if( SHTvars["colorchange"] ) then
2020 SHunterTimersOptionsBarsCheckButton2:SetChecked(1);
2021 else
2022 SHunterTimersOptionsBarsCheckButton2:SetChecked(0);
2023 end
2024  
2025 if( SHTvars["showtex"] ) then
2026 SHunterTimersOptionsBarsCheckButton3:SetChecked(1);
2027 else
2028 SHunterTimersOptionsBarsCheckButton3:SetChecked(0);
2029 end
2030  
2031 if( SHTvars["largetex"] ) then
2032 SHunterTimersOptionsBarsCheckButton4:SetChecked(1);
2033 else
2034 SHunterTimersOptionsBarsCheckButton4:SetChecked(0);
2035 end
2036  
2037 if( SHTvars["gap"] ) then
2038 SHunterTimersOptionsBarsCheckButton5:SetChecked(0);
2039 else
2040 SHunterTimersOptionsBarsCheckButton5:SetChecked(1);
2041 end
2042  
2043 if( SHTvars["append"] ) then
2044 SHunterTimersOptionsBarsCheckButton6:SetChecked(1);
2045 else
2046 SHunterTimersOptionsBarsCheckButton6:SetChecked(0);
2047 end
2048  
2049 if( SHTvars["padding"] ) then
2050 SHunterTimersOptionsBarsCheckButton7:SetChecked(0);
2051 else
2052 SHunterTimersOptionsBarsCheckButton7:SetChecked(1);
2053 end
2054  
2055 if( SHTvars["hidetext"] ) then
2056 SHunterTimersOptionsBarsCheckButton8:SetChecked(1);
2057 else
2058 SHunterTimersOptionsBarsCheckButton8:SetChecked(0);
2059 end
2060  
2061 if( SHTvars["hidetime"] ) then
2062 SHunterTimersOptionsBarsCheckButton9:SetChecked(1);
2063 else
2064 SHunterTimersOptionsBarsCheckButton9:SetChecked(0);
2065 end
2066  
2067 if( SHTvars["sticky"] ) then
2068 SHunterTimersOptionsBarsCheckButton10:SetChecked(1);
2069 else
2070 SHunterTimersOptionsBarsCheckButton10:SetChecked(0);
2071 end
2072  
2073 if( SHTvars["down"] ) then
2074 SHunterTimersOptionsBarsCheckButton11:SetChecked(1);
2075 else
2076 SHunterTimersOptionsBarsCheckButton11:SetChecked(0);
2077 end
2078  
2079 SHunterTimersOptionsBarsEditBox1:SetText(SHTvars["aimeddelay"]);
2080 SHunterTimersOptionsBarsEditBox2:SetText(SHTvars["shotdelay"]);
2081  
2082 local r, g, b, a = unpack(SHTvars["barstartcolor"]);
2083 local rd, gd, bd, ad = unpack( SHTvars["bardelta"] );
2084 rd = rd + r;
2085 gd = gd + g;
2086 bd = bd + b;
2087 ad = ad + a;
2088 SHunterTimersOptionsBarsColor1Swatch:SetVertexColor(r, g, b);
2089 SHunterTimersOptionsBarsColor1Swatch.r = r;
2090 SHunterTimersOptionsBarsColor1Swatch.g = g;
2091 SHunterTimersOptionsBarsColor1Swatch.b = b;
2092 SHunterTimersOptionsBarsColor1Swatch.a = a;
2093 SHunterTimersOptionsBarsColor2Swatch:SetVertexColor(rd, gd, bd);
2094 SHunterTimersOptionsBarsColor2Swatch.r = rd;
2095 SHunterTimersOptionsBarsColor2Swatch.g = gd;
2096 SHunterTimersOptionsBarsColor2Swatch.b = bd;
2097 SHunterTimersOptionsBarsColor2Swatch.a = ad;
2098 SHunterTimersOptionsBarsColor3Swatch:SetVertexColor(SHTvars["bg"].r, SHTvars["bg"].g, SHTvars["bg"].b, SHTvars["bg"].a);
2099 SHunterTimersOptionsBarsColor3Swatch.r = SHTvars["bg"].r;
2100 SHunterTimersOptionsBarsColor3Swatch.g = SHTvars["bg"].g;
2101 SHunterTimersOptionsBarsColor3Swatch.b = SHTvars["bg"].b;
2102 SHunterTimersOptionsBarsColor3Swatch.a = SHTvars["bg"].a;
2103 SHunterTimersOptionsBarsColor4Swatch:SetVertexColor( unpack( SHTvars["borderalpha"]) );
2104 SHunterTimersOptionsBarsColor4Swatch.r, SHunterTimersOptionsBarsColor4Swatch.g, SHunterTimersOptionsBarsColor4Swatch.b, SHunterTimersOptionsBarsColor4Swatch.a = unpack( SHTvars["borderalpha"] );
2105 SHunterTimersOptionsBarsColor5Swatch:SetVertexColor(unpack(SHTvars["skillcolor"]));
2106 SHunterTimersOptionsBarsColor5Swatch.r, SHunterTimersOptionsBarsColor5Swatch.g, SHunterTimersOptionsBarsColor5Swatch.b, SHunterTimersOptionsBarsColor5Swatch.a = unpack( SHTvars["skillcolor"] );
2107 SHunterTimersOptionsBarsColor6Swatch:SetVertexColor(unpack(SHTvars["timecolor"]));
2108 SHunterTimersOptionsBarsColor6Swatch.r, SHunterTimersOptionsBarsColor6Swatch.g, SHunterTimersOptionsBarsColor6Swatch.b, SHunterTimersOptionsBarsColor6Swatch.a = unpack( SHTvars["timecolor"] );
2109 SHunterTimersOptionsBarsColor7Swatch:SetVertexColor(unpack(SHTvars["targetcolor"]));
2110 SHunterTimersOptionsBarsColor7Swatch.r, SHunterTimersOptionsBarsColor7Swatch.g, SHunterTimersOptionsBarsColor7Swatch.b, SHunterTimersOptionsBarsColor7Swatch.a = unpack( SHTvars["targetcolor"] );
2111  
2112 SHunterTimersOptionsBarsSlider1Slider:SetValue(SHTvars["bardistance"]);
2113 SHunterTimersOptionsBarsSlider2Slider:SetValue(SHTvars["scale"]/UIParent:GetScale());
2114 SHunterTimersOptionsBarsSlider3Slider:SetValue(SHTvars["mili"]);
2115 SHunterTimersOptionsBarsSlider4Slider:SetValue(SHTvars["flash"]);
2116 SHunterTimersOptionsBarsSlider5Slider:SetValue(SHTvars["step"]);
2117 SHunterTimersOptionsBarsSlider6Slider:SetValue(SHTvars["overallalpha"]);
2118 SHunterTimersOptionsBarsSlider7Slider:SetValue(SHTvars["barheight"]);
2119  
2120 SHunterTimersOptions:Show();
2121 end
2122  
2123 function SHunterTimers_SaveOptions()
2124  
2125 for i=1, SHT_NUM_TIMERS do
2126 if( getglobal("SHunterTimersOptionsTimersCheckButton"..i):GetChecked() == 1 ) then
2127 SHTvars["skills"][SHT_OPTIONS_TIMERS[i]] = true;
2128 else
2129 SHTvars["skills"][SHT_OPTIONS_TIMERS[i]] = false;
2130 end
2131 end
2132  
2133 if( SHunterTimersOptionsBarsCheckButtonOn:GetChecked() == 1 ) then
2134 SHTvars[SHT_ON] = true;
2135 else
2136 SHTvars[SHT_ON] = false;
2137 end
2138  
2139 if( SHunterTimersOptionsBarsCheckButton1:GetChecked() == 1 ) then
2140 SHTvars["locked"] = true;
2141 SHunterTimersAnchor:Hide();
2142 else
2143 SHTvars["locked"] = false;
2144 SHunterTimersAnchor:Show();
2145 end
2146  
2147 if( SHunterTimersOptionsBarsCheckButton2:GetChecked() == 1 ) then
2148 SHTvars["colorchange"] = true;
2149 else
2150 SHTvars["colorchange"] = false;
2151 end
2152  
2153 if( SHunterTimersOptionsBarsCheckButton3:GetChecked() == 1 ) then
2154 SHTvars["showtex"] = true;
2155 else
2156 SHTvars["showtex"] = false;
2157 end
2158  
2159 if( SHunterTimersOptionsBarsCheckButton4:GetChecked() == 1 ) then
2160 SHTvars["largetex"] = true;
2161 else
2162 SHTvars["largetex"] = false;
2163 end
2164  
2165 if( SHunterTimersOptionsBarsCheckButton5:GetChecked() == 1 ) then
2166 SHTvars["gap"] = false;
2167 else
2168 SHTvars["gap"] = true;
2169 end
2170  
2171 if( SHunterTimersOptionsBarsCheckButton6:GetChecked() == 1 ) then
2172 SHTvars["append"] = true;
2173 else
2174 SHTvars["append"] = false;
2175 end
2176  
2177 if( SHunterTimersOptionsBarsCheckButton7:GetChecked() == 1 ) then
2178 SHTvars["padding"] = false;
2179 else
2180 SHTvars["padding"] = true;
2181 end
2182  
2183 if( SHunterTimersOptionsBarsCheckButton8:GetChecked() == 1 ) then
2184 SHTvars["hidetext"] = true;
2185 else
2186 SHTvars["hidetext"] = false;
2187 end
2188  
2189 if( SHunterTimersOptionsBarsCheckButton9:GetChecked() == 1 ) then
2190 SHTvars["hidetime"] = true;
2191 else
2192 SHTvars["hidetime"] = false;
2193 end
2194  
2195 if( SHunterTimersOptionsBarsCheckButton10:GetChecked() == 1 ) then
2196 SHTvars["sticky"] = true;
2197 else
2198 SHTvars["sticky"] = false;
2199 end
2200  
2201 if( SHunterTimersOptionsBarsCheckButton11:GetChecked() == 1 ) then
2202 SHTvars["down"] = true;
2203 else
2204 SHTvars["down"] = false;
2205 end
2206  
2207 SHTvars["aimeddelay"] = 1*SHunterTimersOptionsBarsEditBox1:GetText();
2208 SHTvars["shotdelay"] = 1*SHunterTimersOptionsBarsEditBox2:GetText();
2209  
2210 SHTvars["barstartcolor"][1] = SHunterTimersOptionsBarsColor1Swatch.r;
2211 SHTvars["barstartcolor"][2] = SHunterTimersOptionsBarsColor1Swatch.g;
2212 SHTvars["barstartcolor"][3] = SHunterTimersOptionsBarsColor1Swatch.b;
2213 SHTvars["barstartcolor"][4] = SHunterTimersOptionsBarsColor1Swatch.a;
2214 SHTvars["bardelta"][1] = SHunterTimersOptionsBarsColor2Swatch.r - SHunterTimersOptionsBarsColor1Swatch.r;
2215 SHTvars["bardelta"][2] = SHunterTimersOptionsBarsColor2Swatch.g - SHunterTimersOptionsBarsColor1Swatch.g;
2216 SHTvars["bardelta"][3] = SHunterTimersOptionsBarsColor2Swatch.b - SHunterTimersOptionsBarsColor1Swatch.b;
2217 SHTvars["bardelta"][4] = SHunterTimersOptionsBarsColor2Swatch.a - SHunterTimersOptionsBarsColor1Swatch.a;
2218 SHTvars["borderalpha"][1] = SHunterTimersOptionsBarsColor4Swatch.r;
2219 SHTvars["borderalpha"][2] = SHunterTimersOptionsBarsColor4Swatch.g;
2220 SHTvars["borderalpha"][3] = SHunterTimersOptionsBarsColor4Swatch.b;
2221 SHTvars["borderalpha"][4] = SHunterTimersOptionsBarsColor4Swatch.a;
2222 SHTvars["skillcolor"][1] = SHunterTimersOptionsBarsColor5Swatch.r;
2223 SHTvars["skillcolor"][2] = SHunterTimersOptionsBarsColor5Swatch.g;
2224 SHTvars["skillcolor"][3] = SHunterTimersOptionsBarsColor5Swatch.b;
2225 SHTvars["skillcolor"][4] = SHunterTimersOptionsBarsColor5Swatch.a;
2226 SHTvars["timecolor"][1] = SHunterTimersOptionsBarsColor6Swatch.r;
2227 SHTvars["timecolor"][2] = SHunterTimersOptionsBarsColor6Swatch.g;
2228 SHTvars["timecolor"][3] = SHunterTimersOptionsBarsColor6Swatch.b;
2229 SHTvars["timecolor"][4] = SHunterTimersOptionsBarsColor6Swatch.a;
2230 SHTvars["targetcolor"][1] = SHunterTimersOptionsBarsColor7Swatch.r;
2231 SHTvars["targetcolor"][2] = SHunterTimersOptionsBarsColor7Swatch.g;
2232 SHTvars["targetcolor"][3] = SHunterTimersOptionsBarsColor7Swatch.b;
2233 SHTvars["targetcolor"][4] = SHunterTimersOptionsBarsColor7Swatch.a;
2234  
2235 SHTvars["bg"].r = SHunterTimersOptionsBarsColor3Swatch.r;
2236 SHTvars["bg"].g = SHunterTimersOptionsBarsColor3Swatch.g;
2237 SHTvars["bg"].b = SHunterTimersOptionsBarsColor3Swatch.b;
2238 SHTvars["bg"].a = SHunterTimersOptionsBarsColor3Swatch.a;
2239  
2240 SHTvars["bardistance"] = SHunterTimersOptionsBarsSlider1Slider:GetValue();
2241 SHTvars["scale"] = SHunterTimersOptionsBarsSlider2Slider:GetValue()*UIParent:GetScale();
2242 SHTvars["mili"] = SHunterTimersOptionsBarsSlider3Slider:GetValue();
2243 SHTvars["flash"] = SHunterTimersOptionsBarsSlider4Slider:GetValue();
2244 SHTvars["step"] = SHunterTimersOptionsBarsSlider5Slider:GetValue();
2245 SHTvars["overallalpha"] = SHunterTimersOptionsBarsSlider6Slider:GetValue();
2246 SHTvars["barheight"] = SHunterTimersOptionsBarsSlider7Slider:GetValue();
2247  
2248 SHunterTimers_SetSettings();
2249  
2250 end
2251  
2252 function SHunterTimers_SaveCloseOptions()
2253  
2254 SHunterTimers_SaveOptions();
2255 SHunterTimersOptions:Hide();
2256  
2257 end
2258  
2259 function SHunterTimers_ResetOptions()
2260  
2261 SHTvars = {};
2262  
2263 SHTvars["bg"] = { r=0, g=0, b=0, a=7 };
2264  
2265 SHTvars[SHT_ON] = true;
2266  
2267 SHTvars["borderalpha"] = {
2268 [1] = 1;
2269 [2] = 1;
2270 [3] = 1;
2271 [4] = 1;
2272 };
2273  
2274 SHunterTimersFrame:SetBackdropColor( SHTvars["bg"].r, SHTvars["bg"].g, SHTvars["bg"].b, SHTvars["bg"].a );
2275 SHunterTimersFrame:SetBackdropBorderColor( unpack(SHTvars["borderalpha"]) );
2276 SHTvars["numBars"] = 0;
2277  
2278 SHTvars["skills"] = {};
2279  
2280 for i=1, SHT_NUM_TIMERS do
2281 if( SHTvars["skills"][SHT_OPTIONS_TIMERS[i]] == nil ) then
2282 SHTvars["skills"][SHT_OPTIONS_TIMERS[i]] = true;
2283 end
2284 end
2285  
2286 SHTvars["shotdelay"] = 200;
2287  
2288 SHTvars["aimeddelay"] = 200;
2289  
2290 SHTvars["scale"] = UIParent:GetScale();
2291  
2292 SHTvars["locked"] = false;
2293 SHunterTimersAnchor:Show();
2294  
2295 SHTvars["down"] = true;
2296 SHunterTimersFrame:ClearAllPoints();
2297 SHunterTimersFrame:SetPoint( "TOPLEFT", "SHunterTimersAnchor", "BOTTOMRIGHT" );
2298  
2299 SHTvars["mili"] = 2;
2300  
2301 SHTvars["flash"] = 5;
2302  
2303 local r, g, b = SHunterTimersStatus1BarLeftText:GetTextColor();
2304 SHTvars["skillcolor"] = {
2305 [1] = r,
2306 [2] = g,
2307 [3] = b,
2308 [4] = 1
2309 };
2310  
2311 local r, g, b = SHunterTimersStatus1BarRightText:GetTextColor();
2312 SHTvars["timecolor"] = {
2313 [1] = r,
2314 [2] = g,
2315 [3] = b,
2316 [4] = 1
2317 };
2318  
2319 local r, g, b = SHunterTimersStatus1BarLeftText:GetTextColor();
2320 SHTvars["targetcolor"] = {
2321 [1] = r,
2322 [2] = g,
2323 [3] = b,
2324 [4] = 1
2325 };
2326  
2327 SHTvars["barstartcolor"] = {
2328 [1] = 0,
2329 [2] = 0.8,
2330 [3] = 0,
2331 [4] = 1
2332 };
2333  
2334 SHTvars["bardelta"] = {
2335 [1] = 0.8,
2336 [2] = -0.8,
2337 [3] = 0,
2338 [4] = 0};
2339  
2340 SHTvars["step"] = 0.015;
2341  
2342 SHTvars["colorchange"] = false;
2343  
2344 SHTvars["bardistance"] = 10;
2345  
2346 SHTvars["append"] = false;
2347  
2348 SHTvars["overallalpha"] = 1;
2349  
2350 SHunterTimers_ClearActiveSpells();
2351  
2352 for i=1, SHT_NUM_TIMERS do --Check boxes
2353 getglobal("SHunterTimersOptionsTimersCheckButton"..i.."Text"):SetText(SHT_OPTIONS_TIMERS[i]);
2354 end
2355  
2356 for i=1, SHT_NUM_OPTIONS do --Check boxes
2357 getglobal("SHunterTimersOptionsBarsCheckButton"..i.."Text"):SetText(SHT_OPTIONS_BARS[i]);
2358 end
2359  
2360 for i=1, SHT_NUM_SLIDERS do --Sliders
2361 getglobal("SHunterTimersOptionsBarsSlider"..i.."SliderTitle"):SetText(SHT_OPTIONS_SLIDER[i]);
2362 getglobal("SHunterTimersOptionsBarsSlider"..i.."SliderLow"):SetText(SHT_OPTIONS_SLIDER_ENDS[i][1])
2363 getglobal("SHunterTimersOptionsBarsSlider"..i.."SliderHigh"):SetText(SHT_OPTIONS_SLIDER_ENDS[i][2]);
2364 end
2365  
2366 SHTvars["textures"] = {};
2367 SHunterTimers_UpdateSpells();
2368  
2369 SHTvars["showtex"] = true;
2370  
2371 SHTvars["largetex"] = false;
2372  
2373 SHTvars["hidetext"] = false;
2374  
2375 SHTvars["hidetime"] = false;
2376  
2377 SHTvars["gap"] = true;
2378  
2379 SHTvars["padding"] = true;
2380  
2381 SHTvars["barheight"] = 10;
2382  
2383 SHTvars["sticky"] = true;
2384  
2385 local _, _, _, _, rank = GetTalentInfo( 3, 7 ); --Clever traps
2386 SHTvars["traptimemult"] = 1 + (rank * 0.15);
2387  
2388 getglobal("SHunterTimersOptionsTimersLabel1Label"):SetText(SHT_OPTIONS_TIMERS_TEXT);
2389  
2390 for i=1, SHT_NUM_LABELS do
2391 getglobal("SHunterTimersOptionsBarsLabel"..i.."Label"):SetText(SHT_OPTIONS_LABELS[i]);
2392 end
2393  
2394 getglobal("SHunterTimersOptionsTitleString"):SetText("Sorren's Hunter Timers "..SHT_VERSION);
2395  
2396 SHunterTimers_SetSettings();
2397  
2398 end
2399  
2400 function SHunterTimers_SetSettings()
2401  
2402 if( SHTvars[SHT_ON] ) then
2403 UseAction = SHunterTimers_OnUseAction;
2404 CastSpellByName = SHunterTimers_OnCastSpellByName;
2405 CastSpell = SHunterTimers_OnCastSpell;
2406 else
2407 UseAction = SHunterTimers_Real_UseAction;
2408 CastSpellByName = SHunterTimers_Real_CastSpellByName;
2409 CastSpell = SHunterTimers_Real_CastSpell;
2410 end
2411  
2412 SHunterTimersFrame:SetBackdropColor(SHTvars["bg"].r, SHTvars["bg"].g, SHTvars["bg"].b, SHTvars["bg"].a);
2413 SHunterTimersFrame:SetBackdropBorderColor(unpack(SHTvars["borderalpha"] ) );
2414  
2415 if( SHTvars["down"] ) then
2416 SHunterTimersFrame:ClearAllPoints();
2417 SHunterTimersFrame:SetPoint( "TOPLEFT", "SHunterTimersAnchor", "BOTTOMRIGHT" );
2418 else
2419 SHunterTimersFrame:ClearAllPoints();
2420 SHunterTimersFrame:SetPoint( "BOTTOMLEFT", "SHunterTimersAnchor", "TOPRIGHT" );
2421 end
2422  
2423 for i=1, SHT_NUM_BARS do
2424 local barframe = getglobal("SHunterTimersStatus"..i);
2425 local bar = getglobal( "SHunterTimersStatus"..i.."Bar");
2426 local bg = getglobal( "SHunterTimersStatus"..i.."BGBar");
2427 local barwidth = 220;
2428  
2429 barframe:SetHeight( SHTvars["barheight"] );
2430 bar:SetHeight( SHTvars["barheight"] );
2431 bg:SetHeight( SHTvars["barheight"] );
2432 local icon = getglobal("SHunterTimersStatus"..i.."Icon");
2433 if( SHTvars["showtex"] ) then
2434  
2435 icon:Show();
2436 if( SHTvars["gap"] ) then
2437 barwidth = barwidth - 5;
2438 end
2439 if( SHTvars["largetex"] ) and ( SHTvars["barheight"] < 16) then
2440 barframe:SetHeight(16);
2441 icon:SetHeight(16);
2442 icon:SetWidth(16);
2443 barwidth = barwidth - 16;
2444 else
2445 icon:SetHeight( SHTvars["barheight"] );
2446 icon:SetWidth( SHTvars["barheight"] );
2447 barwidth = barwidth - SHTvars["barheight"];
2448 end
2449  
2450 bar:ClearAllPoints();
2451 if( SHTvars["gap"] ) then
2452 bar:SetPoint("LEFT", "SHunterTimersStatus"..i.."Icon", "RIGHT", 5, 0 );
2453 else
2454 bar:SetPoint("LEFT", "SHunterTimersStatus"..i.."Icon", "RIGHT", 0, 0 );
2455 end
2456 bg:ClearAllPoints();
2457 if( SHTvars["gap"] ) then
2458 bg:SetPoint("LEFT", "SHunterTimersStatus"..i.."Icon", "RIGHT", 5, 0 );
2459 else
2460 bg:SetPoint("LEFT", "SHunterTimersStatus"..i.."Icon", "RIGHT", 0, 0 );
2461 end
2462 else
2463 icon:Hide();
2464 bar:SetPoint("LEFT", "SHunterTimersStatus"..i, "LEFT", 0, 0 );
2465 bg:SetPoint("LEFT", "SHunterTimersStatus"..i, "LEFT", 0, 0 );
2466 end
2467 barframe:SetWidth(220);
2468 bar:SetWidth(barwidth);
2469 bg:SetWidth(barwidth);
2470 if( SHTvars["hidetext"] ) then
2471 getglobal("SHunterTimersStatus"..i.."BarLeftText"):Hide();
2472 else
2473 getglobal("SHunterTimersStatus"..i.."BarLeftText"):Show();
2474 end
2475 if( SHTvars["hidetime"] ) then
2476 getglobal("SHunterTimersStatus"..i.."BarRightText"):Hide();
2477 else
2478 getglobal("SHunterTimersStatus"..i.."BarRightText"):Show();
2479 end
2480 end
2481  
2482  
2483 local height;
2484 if( not SHTvars["largetex"] ) or ( SHTvars["barheight"] >= 16 ) then
2485 height = SHTvars["numBars"] * (SHTvars["barheight"] + SHTvars["bardistance"]) - SHTvars["bardistance"] + 10;
2486 else
2487 height = SHTvars["numBars"] * (16 + SHTvars["bardistance"]) - SHTvars["bardistance"] + 10;
2488 end
2489  
2490 if( SHTvars["padding"] ) then
2491 SHunterTimersFrame:SetWidth( 240 );
2492 SHunterTimersStatus1:SetPoint( "TOPLEFT", "SHunterTimersFrame", "TOPLEFT", 10, -10 );
2493 height = height + 10;
2494  
2495 else
2496 SHunterTimersFrame:SetWidth( 230 );
2497 SHunterTimersStatus1:SetPoint( "TOPLEFT", "SHunterTimersFrame", "TOPLEFT", 5, -5 );
2498 end
2499  
2500 SHunterTimersFrame:SetHeight(height);
2501  
2502 for i=2, SHT_NUM_BARS do
2503 getglobal("SHunterTimersStatus"..i):ClearAllPoints();
2504 getglobal("SHunterTimersStatus"..i):SetPoint("TOP", "SHunterTimersStatus"..(i-1), "BOTTOM", 0, -SHTvars["bardistance"]);
2505  
2506 end
2507  
2508 SHunterTimersFrame:SetScale( SHTvars["scale"] );
2509 SHunterTimersFrame:SetAlpha( SHTvars["overallalpha"] );
2510 for i=1, SHT_NUM_BARS do
2511 getglobal("SHunterTimersStatus"..i):SetScale( SHTvars["scale"] );
2512 getglobal("SHunterTimersStatus"..i):SetAlpha( SHTvars["overallalpha"] );
2513 end
2514  
2515 end
2516  
2517 function SHT_SetHeight()
2518 local height;
2519 if( not SHTvars["largetex"] ) or ( SHTvars["barheight"] >= 16 ) then
2520 height = SHTvars["numBars"] * (SHTvars["barheight"] + SHTvars["bardistance"]) - SHTvars["bardistance"] + 10;
2521 else
2522 height = SHTvars["numBars"] * (16 + SHTvars["bardistance"]) - SHTvars["bardistance"] + 10;
2523 end
2524  
2525 if( SHTvars["padding"] ) then
2526 height = height + 10;
2527 end
2528  
2529 SHunterTimersFrame:SetHeight(height);
2530 SHunterTimers_SetWidths();
2531 end
2532  
2533 function SHunterTimers_UpdateSpells()
2534  
2535 for key,val in pairs(SHTvars["skills"]) do
2536 local i = 1;
2537 while( GetSpellTexture(i, BOOKTYPE_SPELL) ) do
2538 local spellName = GetSpellName(i, BOOKTYPE_SPELL);
2539 if( spellName == key ) then
2540 SHTvars["textures"][key] = GetSpellTexture(i, BOOKTYPE_SPELL);
2541 break;
2542 end
2543 i = i + 1;
2544 end
2545 end
2546  
2547 SHTvars["textures"][SHT_QUICK_SHOTS] = "Interface\\Icons\\Ability_Warrior_InnerRage";
2548 SHTvars["textures"][SHT_FRENZY] = "Interface\\Icons\\Ability_Druid_ChallangingRoar";
2549 SHTvars["textures"][SHT_EXPOSE_WEAKNESS] = "Interface\\Icons\\Ability_Hunter_SniperShot";
2550 SHTvars["textures"][SHT_PRIMAL_BLESSING] = "Interface\\Icons\\Ability_Hunter_Harass";
2551 SHTvars["textures"][SHT_ENTRAPMENT] = "Interface\\Icons\\Spell_Nature_StrangleVines";
2552 SHTvars["textures"][SHT_DEVILSAUR] = "Interface\\Icons\\Ability_Hunter_Pet_Raptor";
2553 SHTvars["textures"][SHT_ZHM] = "Interface\\Icons\\INV_Jewelry_Necklace_13";
2554 SHTvars["textures"][SHT_EARTHSTRIKE] = "Interface\\Icons\\Spell_Nature_AbolishMagic";
2555 SHTvars["textures"][SHT_SWARMGUARD] = "INV_Misc_AhnQirajTrinket_04";
2556 SHTvars["textures"][SHT_JOM_GABBAR] = "Interface\\Icons\\Ability_Poisons";
2557 SHTvars["textures"][SHT_KISS_SPIDER] = "Interface\\Icons\\INV_Trinket_Naxxramas04";
2558 end
2559  
2560 function SHunterTimers_ClearActiveSpells()
2561  
2562 SHTvars["concuss"] = false;
2563 SHTvars["impconc"] = false;
2564 SHTvars["rapid"] = false;
2565 SHTvars["quick"] = false;
2566 SHTvars["petIntim"] = false;
2567 SHTvars["intimidate"] = false;
2568 SHTvars["deterrence"] = false;
2569 SHTvars["wingclip"] = false;
2570 SHTvars["impwing"] = false;
2571 SHTvars["freezing"] = false;
2572 SHTvars["scatter"] = false;
2573 SHTvars["wyvern"] = false;
2574 SHTvars["fearbeast"] = false;
2575 SHTvars["exposeweak"] = false;
2576 SHTvars["huntersmark"] = false;
2577 SHTvars["primalblessing"] = false;
2578 SHTvars["entrapment"] = false;
2579 SHTvars["aimed"] = false;
2580 SHTvars["berserking"] = false;
2581 SHTvars["devilsaur"] = false;
2582 SHTvars["zhm"] = false;
2583 SHTvars["earthstrike"] = false;
2584 SHTvars["swarmguard"] = false;
2585 SHTvars["jomgabbar"] = false;
2586 SHTvars["spider"] = false;
2587  
2588 end
2589  
2590 local SHTSetColorFunc = {
2591 [1] = function() SHTSetColor(1) end,
2592 [2] = function() SHTSetColor(2) end,
2593 [3] = function() SHTSetColor(3) end,
2594 [4] = function() SHTSetColor(4) end,
2595 [5] = function() SHTSetColor(5) end,
2596 [6] = function() SHTSetColor(6) end,
2597 [7] = function() SHTSetColor(7) end
2598 };
2599  
2600 local SHTSetOpacityFunc = {
2601 [1] = function() SHTSetOpacity(1) end,
2602 [2] = function() SHTSetOpacity(2) end,
2603 [3] = function() SHTSetOpacity(3) end,
2604 [4] = function() SHTSetOpacity(4) end,
2605 [5] = function() SHTSetOpacity(5) end,
2606 [6] = function() SHTSetOpacity(6) end,
2607 [7] = function() SHTSetOpacity(7) end
2608 };
2609  
2610 local SHTCancelFunc = {
2611 [1] = function(x) SHTCancelColor(1, x) end,
2612 [2] = function(x) SHTCancelColor(2, x) end,
2613 [3] = function(x) SHTCancelColor(3, x) end,
2614 [4] = function(x) SHTCancelColor(4, x) end,
2615 [5] = function(x) SHTCancelColor(5, x) end,
2616 [6] = function(x) SHTCancelColor(6, x) end,
2617 [7] = function(x) SHTCancelColor(7, x) end
2618 };
2619  
2620 function SHT_ColorPicker(id)
2621 CloseMenus();
2622 local texture = getglobal("SHunterTimersOptionsBarsColor"..id.."Swatch");
2623 ColorPickerFrame.func = SHTSetColorFunc[id];
2624 ColorPickerFrame:SetColorRGB(texture.r, texture.g, texture.b);
2625 ColorPickerFrame.previousValues = {r = texture.r, g = texture.g, b = texture.b, opacity =texture.a};
2626 ColorPickerFrame.cancelFunc = SHTCancelFunc[id];
2627 if( id < 5 ) then
2628 ColorPickerFrame.hasOpacity = true;
2629 ColorPickerFrame.opacity = 1 - texture.a;
2630 ColorPickerFrame.opacityFunc = SHTSetOpacityFunc[id];
2631 else
2632 ColorPickerFrame.hasOpacity = false;
2633 end
2634  
2635  
2636 --OpacityFrame.opacityFunc = SHTSetOpacityFunc[id];
2637  
2638 ColorPickerFrame:Show();
2639 end
2640  
2641 function SHTSetOpacity(id)
2642 local a = 1 - OpacitySliderFrame:GetValue();
2643 local texture = getglobal("SHunterTimersOptionsBarsColor"..id.."Swatch");
2644 --DEFAULT_CHAT_FRAME:AddMessage(id);
2645 texture:SetAlpha(a);
2646 texture.a = a;
2647 end
2648  
2649 function SHTSetColor(id)
2650 local r, g, b = ColorPickerFrame:GetColorRGB();
2651 local texture = getglobal("SHunterTimersOptionsBarsColor"..id.."Swatch");
2652 --SHTSetOpacity(id);
2653 texture:SetVertexColor(r, g, b);
2654 texture.r = r;
2655 texture.g = g;
2656 texture.b = b;
2657 end
2658  
2659 function SHTCancelColor(id, prev)
2660 local texture = getglobal("SHunterTimersOptionsBarsColor"..id.."Swatch");
2661 local r = prev.r;
2662 local g = prev.g;
2663 local b = prev.b;
2664 local a = prev.opacity;
2665 texture:SetVertexColor(r, g, b);
2666 texture:SetAlpha( a );
2667 texture.r = r;
2668 texture.g = g;
2669 texture.b = b;
2670 texture.a = a;
2671 end
2672  
2673 function SHTColor(r, g, b, a)
2674 if( not a ) then
2675 a = 1;
2676 end
2677 return string.format("|c%02x%02x%02x%02x", (a*255), (r*255), (g*255), (b*255));
2678 end
2679  
2680 function SHunterTimers_Tooltip(barframe)
2681 --DEFAULT_CHAT_FRAME:AddMessage(barframe:GetName());
2682 if( barframe.target ) then
2683 GameTooltip_SetDefaultAnchor(GameTooltip, barframe);
2684 GameTooltip:ClearLines();
2685 GameTooltip:AddLine( barframe.target );
2686 GameTooltip:Show();
2687 end
2688 end
2689  
2690 function SHT_sfind( s, pattern )
2691 for p in string.gfind( pattern, "([^|]+)" ) do
2692 if( string.find( s, p ) )then
2693 return string.find( s, p );
2694 end
2695 end
2696 return false;
2697 end
2698  
2699 function SHT_AddAutoShot()
2700 if( not SHTvars["skills"][SHT_AUTO_SHOT] ) then
2701 return;
2702 end
2703 shttimeleft = UnitRangedDamage("player");
2704 SHunterTimersFrame_add( shttimeleft*1000, SHT_AUTO_SHOT );
2705 end