vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 CT_AddMovable("CT_BuffMod_Drag", CT_BUFFMOD_MOVABLE_BUFFBAR, "BOTTOMLEFT", "BOTTOMLEFT", "MinimapCluster", 10, -20, function(status)
2 if ( status ) then
3 CT_BuffMod_Drag:Show()
4 else
5 CT_BuffMod_Drag:Hide();
6 end
7 end, BuffModResetFunction);
8  
9 CT_ExpireBuffs = { };
10 CT_BuffNames = { };
11 CT_LastExpiredBuffs = { };
12 CT_PlaySound = 0;
13 local CT_UsingTooltip = 0;
14  
15 CT_BuffMod_BuffSides = "RIGHT";
16  
17 CT_ShowDuration = 1;
18 CT_ShowExpire = 1;
19 CT_ShowRed = 0;
20  
21 -- Buffs not to recast
22 CT_BuffMod_NoRecastBuffs = {
23 ["Mind Control"] = 1
24 };
25  
26 function CT_BuffFrame_OnLoad()
27 MinBuffDurationExpireMessage = 51; -- Never display an expire message if the buff duration is less than this.
28 ExpireMessageTime = 15; -- How long before the buff expires to display the expire message.
29 ExpireMessageColors = { };
30 ExpireMessageColors["r"] = 1.0;
31 ExpireMessageColors["g"] = 0.0;
32 ExpireMessageColors["b"] = 0.0;
33 ExpireMessageFrame = DEFAULT_CHAT_FRAME; -- The frame in which to display the expire message.
34  
35 BuffStartFlashTime = 16; -- How long before the buff expires to start flashing.
36 BuffFlashOn = 0.50; -- How long to flash.
37 BuffFlashOff = 0.50; -- How long between each flash.
38 BuffMinOpacity = 0.30; -- Minimum level of opacity.
39  
40 BuffFlashState = 0;
41 BuffFlashTime = 0;
42 BuffFlashUpdateTime = 0;
43 BuffFrame:Hide();
44 CT_BuffFrame:Show();
45 end
46  
47 function CT_BuffFrame_OnUpdate(elapsed)
48  
49 if ( BuffFlashUpdateTime > 0 ) then
50 BuffFlashUpdateTime = BuffFlashUpdateTime - elapsed;
51 else
52 BuffFlashUpdateTime = BuffFlashUpdateTime + TOOLTIP_UPDATE_TIME;
53 end
54  
55 BuffFlashTime = BuffFlashTime - elapsed;
56  
57 if ( BuffFlashTime < 0 ) then
58 local overtime = -BuffFlashTime;
59 if ( BuffFlashState == 1 ) then
60 BuffFlashState = 0;
61 BuffFlashTime = BuffFlashOff;
62 else
63 BuffFlashState = 1;
64 BuffFlashTime = BuffFlashOn;
65 end
66 if ( overtime < BuffFlashTime ) then
67 BuffFlashTime = BuffFlashTime - overtime;
68 end
69 end
70 end
71  
72 function CT_BuffIsDebuff(id)
73 for z=0, 23, 1 do
74 local dbIndex, dbTemp = GetPlayerBuff(z, "HARMFUL");
75 if ( dbIndex == -1 ) then return 0; end
76  
77 if ( dbIndex == id ) then
78 return 1;
79 end
80 end
81 return 0;
82 end
83  
84 function CT_GetBuffName(unit, i, filt)
85 CT_UsingTooltip = 1;
86 local filter;
87 if ( not filt ) then
88 filter = "HELPFUL|HARMFUL";
89 else
90 filter = filt;
91 end
92 local buffIndex, untilCancelled = GetPlayerBuff(i, filter);
93 local buff;
94  
95 if ( buffIndex < 24 ) then
96 buff = buffIndex;
97 if (buff == -1) then
98 buff = nil;
99 end
100 end
101  
102 if (buff) then
103 local tooltip = BTooltip;
104 if (unit == "player" and tooltip ) then
105 tooltip:SetPlayerBuff(buffIndex);
106 end
107 local tooltiptext = getglobal("BTooltipTextLeft1");
108 if ( tooltiptext ) then
109 local name = tooltiptext:GetText();
110 if ( name ~= nil ) then
111 CT_UsingTooltip = 0;
112 return name;
113 end
114 end
115 end
116 CT_UsingTooltip = 0;
117 return nil;
118 end
119  
120  
121 function CT_BuffButton_Update()
122 local buffIndex, untilCancelled = GetPlayerBuff(this:GetID(), "HELPFUL|HARMFUL");
123 this.buffIndex = buffIndex;
124 this.untilCancelled = untilCancelled;
125  
126 if ( buffIndex < 0 ) then
127 this:Hide();
128 return;
129 else
130 this:SetAlpha(1.0);
131 this:Show();
132 end
133  
134 local icon = getglobal(this:GetName().."Icon");
135 icon:SetTexture(GetPlayerBuffTexture(buffIndex, "HELPFUL|HARMFUL"));
136  
137 if ( GameTooltip:IsOwned(this) ) then
138 GameTooltip:SetPlayerBuff(buffIndex, "HELPFUL|HARMFUL");
139 end
140 local name = CT_GetBuffName("player", this:GetID(), "HELPFUL|HARMFUL");
141 if ( name ) then
142 getglobal(this:GetName() .. "DescribeText"):SetText( name );
143 end
144 CT_BuffNames[this:GetID()] = nil;
145  
146 end
147  
148 function CT_BuffButton_OnLoad()
149 getglobal(this:GetName() .. "DurationText"):SetTextColor(1, 1, 0);
150 local bIndex, untilCancelled = GetPlayerBuff(this:GetID(), "HELPFUL|HARMFUL");
151 if ( CT_BuffIsDebuff( temp ) == 1 ) then
152 if ( CT_ShowRed == 1 ) then
153 getglobal(this:GetName() .. "DescribeText"):SetTextColor(1, 0, 0);
154 else
155 getglobal(this:GetName() .. "DescribeText"):SetTextColor(1, 1, 0);
156 end
157 getglobal(this:GetName() .. "Debuff"):Show();
158 else
159 getglobal(this:GetName() .. "DescribeText"):SetTextColor(1, 1, 0);
160 getglobal(this:GetName() .. "Debuff"):Hide();
161 end
162 if ( untilCancelled == 1 or CT_ShowDuration == 0 ) then
163 getglobal(this:GetName() .. "DurationText"):SetText("");
164 end
165  
166 CT_BuffButton_Update();
167 this:RegisterForClicks("RightButtonUp");
168 this:RegisterEvent("PLAYER_AURAS_CHANGED");
169  
170 local descript = getglobal(this:GetName() .. "DescribeText");
171 if ( descript ) then descript:Show(); end
172 end
173  
174 function CT_BuffButton_OnEvent(event)
175 CT_BuffButton_Update();
176 end
177  
178 function CT_GetStringTime(seconds)
179 local str = "";
180 if ( seconds >= 60 ) then
181 local minutes = ceil(seconds / 60);
182 str = minutes .. " " .. CT_BUFFMOD_MINUTE;
183 if ( minutes > 1 ) then
184 str = minutes .. " " .. CT_BUFFMOD_MINUTES;
185 else
186 str = minutes .. " " .. CT_BUFFMOD_MINUTE;
187 end
188 else
189 if ( seconds > 1 ) then
190 str = floor(seconds) .. " " .. CT_BUFFMOD_SECONDS;
191 else
192 str = floor(seconds) .. " " .. CT_BUFFMOD_SECOND;
193 end
194 end
195 return str;
196 end
197  
198 function CT_BuffButton_OnUpdate(elapsed)
199 local buffname;
200 local bIndex, untilCancelled = GetPlayerBuff( this:GetID(), "HELPFUL|HARMFUL" );
201 local isDebuff = CT_BuffIsDebuff(bIndex);
202 local buffnum = GetPlayerBuffApplications(bIndex)
203 if ( buffnum > 1 ) then
204 getglobal(this:GetName() .. "Count"):SetText(buffnum);
205 else
206 getglobal(this:GetName() .. "Count"):SetText("");
207 end
208 if ( isDebuff == 1 ) then
209 if ( CT_ShowRed == 1 ) then
210 getglobal(this:GetName() .. "DescribeText"):SetTextColor(1, 0, 0);
211 else
212 getglobal(this:GetName() .. "DescribeText"):SetTextColor(1, 1, 0);
213 end
214 getglobal(this:GetName() .. "Debuff"):Show();
215 else
216 getglobal(this:GetName() .. "DescribeText"):SetTextColor(1, 1, 0);
217 getglobal(this:GetName() .. "Debuff"):Hide();
218 end
219 if ( untilCancelled == 1 ) then
220 getglobal(this:GetName() .. "DurationText"):SetText("");
221 return;
222 end
223 if ( not CT_BuffNames[this:GetID()] ) then
224 buffname = CT_GetBuffName( "player", this:GetID() );
225 CT_BuffNames[this:GetID()] = buffname;
226 else
227 buffname = CT_BuffNames[this:GetID()];
228 end
229 local timeLeft = GetPlayerBuffTimeLeft(bIndex);
230 local buffAlphaValue;
231 if ( timeLeft >= 1 and CT_ShowDuration == 1 ) then
232 getglobal(this:GetName() .. "DurationText"):SetText(CT_GetStringTime(timeLeft));
233 else
234 getglobal(this:GetName() .. "DurationText"):SetText("");
235 end
236  
237 if ( floor(timeLeft) == MinBuffDurationExpireMessage and not CT_ExpireBuffs[buffname] ) then
238 CT_ExpireBuffs[buffname] = 1;
239 end
240  
241 if ( ceil(timeLeft) == ExpireMessageTime and CT_ExpireBuffs[buffname] and CT_BuffIsDebuff(bIndex) == 0 ) then
242 if ( CT_ShowExpire == 1 and not CT_BuffMod_NoRecastBuffs[buffname]) then
243 if ( CT_PlaySound == 1 ) then
244 PlaySound("TellMessage");
245 end
246 CT_BuffMod_AddToQueue(buffname);
247 local message;
248 if ( CT_PlayerSpells[buffname] and GetBindingKey("CT_RECASTBUFF") ) then
249 message = format(ExpireMessageRecastString, buffname, GetBindingText(GetBindingKey("CT_RECASTBUFF"), "KEY_"));
250 else
251 message = format(ExpireMessageString, buffname);
252 end
253 ExpireMessageFrame:AddMessage(message, ExpireMessageColors["r"], ExpireMessageColors["g"], ExpireMessageColors["b"]);
254 end
255 CT_ExpireBuffs[buffname] = nil;
256 CT_BuffNames[this:GetID()] = nil;
257 end
258 if ( timeLeft < BuffStartFlashTime ) then
259 if ( BuffFlashState == 1 ) then
260 buffAlphaValue = (BuffFlashOn - BuffFlashTime) / BuffFlashOn;
261 buffAlphaValue = buffAlphaValue * (1 - BuffMinOpacity) + BuffMinOpacity;
262 else
263 buffAlphaValue = BuffFlashTime / BuffFlashOn;
264 buffAlphaValue = (buffAlphaValue * (1 - BuffMinOpacity)) + BuffMinOpacity;
265 this:SetAlpha(BuffFlashTime / BuffFlashOn);
266 end
267 this:SetAlpha(buffAlphaValue);
268 else
269 this:SetAlpha(1.0);
270 end
271  
272 if ( BuffFlashUpdateTime > 0 ) then
273 return;
274 end
275 if ( GameTooltip:IsOwned(this) ) then
276 GameTooltip:SetPlayerBuff(bIndex);
277 end
278 end
279  
280 function CT_BuffButton_OnClick()
281 CancelPlayerBuff(this.buffIndex);
282 end
283  
284 function CT_Buffs_SwapSides(onLoad)
285 local i;
286 for i = 0, 23, 1 do
287 getglobal("CT_BuffButton" .. i .. "DescribeText"):ClearAllPoints();
288 getglobal("CT_BuffButton" .. i .. "DurationText"):ClearAllPoints();
289 if ( CT_BuffMod_BuffSides == "RIGHT" or onLoad ) then
290 getglobal("CT_BuffButton" .. i .. "DescribeText"):SetPoint("RIGHT", "CT_BuffButton" .. i, "LEFT", -8, 7);
291 getglobal("CT_BuffButton" .. i .. "DurationText"):SetPoint("RIGHT", "CT_BuffButton" .. i, "LEFT", -8, -7);
292 elseif ( CT_BuffMod_BuffSides == "LEFT" ) then
293 getglobal("CT_BuffButton" .. i .. "DescribeText"):SetPoint("LEFT", "CT_BuffButton" .. i, "LEFT", 40, 7);
294 getglobal("CT_BuffButton" .. i .. "DurationText"):SetPoint("LEFT", "CT_BuffButton" .. i, "LEFT", 40, -7);
295 end
296 end
297 if ( onLoad ) then return; end
298 if ( CT_BuffMod_BuffSides == "LEFT" ) then
299 CT_BuffMod_BuffSides = "RIGHT";
300 else
301 CT_BuffMod_BuffSides = "LEFT";
302 end
303 end
304  
305 expirefunction = function(modId, count)
306 local val = CT_Mods[modId]["modValue"];
307 if ( val == "1min" ) then
308 CT_Mods[modId]["modValue"] = "Off";
309 if ( count ) then count:SetText("Off"); end
310 CT_ShowExpire = 0;
311 CT_Print(CT_BUFFMOD_ON_EXPIRE, 1.0, 1.0, 0.0);
312 else
313 CT_ShowExpire = 1;
314 if ( val == "15sec" ) then
315 CT_Mods[modId]["modValue"] = "1min";
316 if ( count ) then count:SetText("1min"); end
317 CT_Print(CT_BUFFMOD_MIN_EXPIRE, 1.0, 1.0, 0.0);
318 ExpireMessageTime = 60;
319 MinBuffDurationExpireMessage = 120;
320 elseif ( val == "Off" ) then
321 CT_Mods[modId]["modValue"] = "15sec";
322 if ( count ) then count:SetText("15sec"); end
323 CT_Print(CT_BUFFMOD_SEC_EXPIRE, 1.0, 1.0, 0.0);
324 ExpireMessageTime = 15;
325 MinBuffDuratioonExpireMessage = 51;
326 end
327 end
328 end
329  
330 durationfunction = function(modId)
331 if ( CT_ShowDuration == 1 ) then
332 CT_ShowDuration = 0;
333 CT_SetModStatus(modId, "off");
334 CT_Print(CT_BUFFMOD_OFF_DURATION, 1.0, 1.0, 0.0);
335 else
336 CT_ShowDuration = 1;
337 CT_SetModStatus(modId, "on");
338 CT_Print(CT_BUFFMOD_ON_DURATION, 1.0, 1.0, 0.0);
339 end
340 end
341  
342 expireinitfunction = function(modId)
343 local val = CT_Mods[modId]["modValue"];
344 if ( val == "Off" ) then
345 CT_ShowExpire = 0;
346 else
347 CT_ShowExpire = 1;
348 if ( val == "1min" ) then
349 ExpireMessageTime = 60;
350 MinBuffDurationExpireMessage = 120;
351 elseif ( val == "15sec" ) then
352 ExpireMessageTime = 15;
353 MinBuffDurationExpireMessage = 51;
354 end
355 end
356 end
357 durationinitfunction = function(modId)
358 local val = CT_Mods[modId]["modStatus"];
359 if ( val == "on" ) then
360 CT_ShowDuration = 1;
361 else
362 CT_ShowDuration = 0;
363 end
364 end
365  
366 debuffnamesfunction = function(modId)
367 local val = CT_Mods[modId]["modStatus"];
368 if ( val == "on" ) then
369 CT_ShowRed = 1;
370 CT_Print(CT_BUFFMOD_ON_DEBUFF, 1.0, 1.0, 0.0);
371 else
372 CT_ShowRed = 0;
373 CT_Print(CT_BUFFMOD_OFF_DEBUFF, 1.0, 1.0, 0.0);
374 end
375 end
376  
377 debuffnamesinitfunction = function(modId)
378 local val = CT_Mods[modId]["modStatus"];
379 if ( val == "on" ) then
380 CT_ShowRed = 1;
381 else
382 CT_ShowRed = 0;
383 end
384 end
385  
386 lockframefunction = function(modId)
387 local val = CT_Mods[modId]["modStatus"];
388 if ( val == "off" ) then
389 CT_Print(CT_BUFFMOD_OFF_LOCK, 1, 1, 0);
390 CT_BuffMod_Drag:Hide();
391 else
392 CT_Print(CT_BUFFMOD_ON_LOCK, 1, 1, 0);
393 CT_BuffMod_Drag:Show();
394 end
395 end
396  
397 lockframeinitfunction = function(modId)
398 local val = CT_Mods[modId]["modStatus"];
399 if ( val == "off" ) then
400 CT_BuffMod_Drag:Hide();
401 else
402 CT_BuffMod_Drag:Show();
403 end
404 end
405  
406 buffmodfunction = function(modId)
407 local val = CT_Mods[modId]["modStatus"];
408 if ( val == "off" ) then
409 CT_Print(CT_BUFFMOD_OFF_TOGGLE, 1, 1, 0);
410 CT_BuffFrame:Hide();
411 BuffFrame:Show();
412 if ( TemporaryEnchantFrame ) then
413 TemporaryEnchantFrame:Show();
414 end
415 else
416 CT_Print(CT_BUFFMOD_ON_TOGGLE, 1, 1, 0);
417 CT_BuffFrame:Show();
418 BuffFrame:Hide();
419 if ( TemporaryEnchantFrame and CT_ItemBuffFrame ) then
420 TemporaryEnchantFrame:Hide();
421 elseif ( TemporaryEnchantFrame ) then
422 TemporaryEnchantFrame:Show();
423 end
424 end
425 end
426  
427 buffmodinitfunction = function(modId)
428 local val = CT_Mods[modId]["modStatus"];
429 if ( val == "off" ) then
430 CT_BuffFrame:Hide();
431 BuffFrame:Show();
432 if ( TemporaryEnchantFrame ) then
433 TemporaryEnchantFrame:Show();
434 end
435 else
436 CT_BuffFrame:Show();
437 BuffFrame:Hide();
438 if ( TemporaryEnchantFrame and CT_ItemBuffFrame ) then
439 TemporaryEnchantFrame:Hide();
440 elseif ( TemporaryEnchantFrame ) then
441 TemporaryEnchantFrame:Show();
442 end
443 end
444 end
445  
446 CT_RegisterMod(CT_BUFFMOD_MODNAME_TOGGLE, CT_BUFFMOD_MODNAME_SUB_TOGGLE, 4, "Interface\\Icons\\Spell_Holy_Renew", CT_BUFFMOD_MODNAME_TOOLTIP_TOGGLE, "on", nil, buffmodfunction, buffmodinitfunction);
447 CT_RegisterMod(CT_BUFFMOD_MODNAME_EXPIRE, CT_BUFFMOD_MODNAME_SUB_EXPIRE, 4, "Interface\\Icons\\INV_Misc_Note_03", CT_BUFFMOD_MODNAME_TOOLTIP_EXPIRE, "switch", "15sec", expirefunction, expireinitfunction);
448 CT_RegisterMod(CT_BUFFMOD_MODNAME_DURATION, CT_BUFFMOD_MODNAME_SUB_DURATION, 4, "Interface\\Icons\\INV_Misc_PocketWatch_01", CT_BUFFMOD_MODNAME_TOOLTIP_DURATION, "on", nil, durationfunction, durationinitfunction);
449 CT_RegisterMod(CT_BUFFMOD_MODNAME_DEBUFF, CT_BUFFMOD_MODNAME_SUB_DEBUFF, 4, "Interface\\Icons\\Spell_Holy_SealOfSacrifice", CT_BUFFMOD_MODNAME_TOOLTIP_DEBUFF, "off", nil, debuffnamesfunction, debuffnamesinitfunction);
450  
451 function CT_BuffMod_RecastLastBuff()
452 local buff = CT_BuffMod_GetExpiredBuff();
453 if ( buff and CT_PlayerSpells[buff] ) then
454 if ( CT_PlayerSpells[buff] ) then
455 CT_BuffMod_LastCastSpell = buff;
456 CT_BuffMod_LastCast = GetTime();
457 if ( UnitExists("target") and UnitIsFriend("player", "target") ) then
458 TargetUnit("player");
459 end
460 CastSpell(CT_PlayerSpells[buff]["spell"], CT_PlayerSpells[buff]["tab"]+1);
461 if ( SpellIsTargeting() and SpellCanTargetUnit("player") ) then
462 SpellTargetUnit("player");
463 end
464 end
465 end
466 end
467  
468 function CT_BuffButton_OnEnter()
469 if ( this:GetCenter() < UIParent:GetCenter() ) then
470 GameTooltip:SetOwner(this, "ANCHOR_RIGHT");
471 else
472 GameTooltip:SetOwner(this, "ANCHOR_LEFT");
473 end
474 GameTooltip:SetPlayerBuff(this.buffIndex);
475 end
476  
477 function CT_BuffMod_AddToQueue(name)
478 local hKey = 0;
479 local hVal = 0;
480 for key, val in CT_LastExpiredBuffs do
481 if ( val > hVal ) then
482 hKey = key; hVal = val;
483 end
484 end
485 if ( hKey == name ) then return; end
486  
487 CT_LastExpiredBuffs[name] = hVal+1;
488 end
489  
490 function CT_BuffMod_GetExpiredBuff()
491 local hKey = 0;
492 local hVal = 0;
493 for key, val in CT_LastExpiredBuffs do
494 if ( val > hVal ) then
495 hKey = key; hVal = val;
496 end
497 end
498 if ( hKey ~= 0 and hVal ~= 0 ) then
499 CT_LastExpiredBuffs[hKey] = nil;
500 return hKey;
501 else
502 return nil;
503 end
504 end
505  
506 function CT_BuffMod_OnEvent(event)
507 if ( CT_BuffMod_LastCast and (GetTime()-CT_BuffMod_LastCast) <= 0.1 ) then
508 CT_BuffMod_AddToQueue(CT_BuffMod_LastCastSpell);
509 CT_BuffMod_LastCast = nil;
510 CT_BuffMod_LastCastSpell = nil;
511 end
512 end
513  
514 function BuffModResetFunction()
515 if ( CT_BuffMod_BuffSides == "LEFT" ) then
516 CT_Buffs_SwapSides();
517 end
518 end
519  
520 ChirpFunction = function(modId)
521 local val = CT_Mods[modId]["modStatus"];
522 if ( val == "off" ) then
523 CT_Print(CT_BUFFMOD_OFF_CHIRP, 1, 1, 0);
524 CT_PlaySound = 0;
525 else
526 CT_Print(CT_BUFFMOD_ON_CHIRP, 1, 1, 0);
527 CT_PlaySound = 1;
528 end
529 end
530  
531 ChirpInitFunction = function(modId)
532 local val = CT_Mods[modId]["modStatus"];
533 if ( val == "off" ) then
534 CT_PlaySound = 0;
535 else
536 CT_PlaySound = 1;
537 end
538 end
539  
540 CT_RegisterMod(CT_BUFFMOD_MODNAME_SOUND, CT_BUFFMOD_SUB_SOUND, 4, "Interface\\Icons\\INV_Misc_Bell_01", CT_BUFFMOD_TOOLTIP_SOUND, "off", nil, ChirpFunction, ChirpInitFunction);