Language:
Lua     Change language:
Pastebin: 88543
Author: xbiggs // zork
Subject: rFilter2
Created: 2008-05-28 01:09:04
Download and save
Toggle line numbers
1--[[------------------------------------------------------------------------- 
2  Copyright (c) 2008, zork 
3  All rights reserved. 
4 
5  Redistribution and use in source and binary forms, with or without 
6  modification, are permitted provided that the following conditions are 
7  met: 
8 
9      * Redistributions of source code must retain the above copyright 
10        notice, this list of conditions and the following disclaimer. 
11      * Redistributions in binary form must reproduce the above 
12        copyright notice, this list of conditions and the following 
13        disclaimer in the documentation and/or other materials provided 
14        with the distribution. 
15      * Neither the name of rFilter nor the names of its contributors may 
16        be used to endorse or promote products derived from this 
17        software without specific prior written permission. 
18 
19  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
20  "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
21  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 
22  A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 
23  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 
24  SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 
25  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES LOSS OF USE, 
26  DATA, OR PROFITS OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 
27  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 
28  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 
29  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
30---------------------------------------------------------------------------]] 
31 
32  local addon = CreateFrame"Frame" 
33  local _G = getfenv(0
34  local rf2_player_name, _ = UnitName("player"
35  local _, rf2_player_class = UnitClass("player"
36 
37  ----------------------------------------------------- 
38  -- EDIT YOUR BUFFS/DEBUFFS IN HERE 
39  -- IMPORTANT, TAGS HAVE TO BE UNIQUE!!! 
40  ----------------------------------------------------- 
41 
42  -- to enable the icons OOC, put this to 1 while moving the icons and to 0 when ready 
43  -- 0 = off // 1 = on 
44  local testmode = 0 
45 
46  --DEFAULT_CHAT_FRAME:AddMessage("found "..rf2_player_name.." : "..rf2_player_class) 
47 
48  if rf2_player_class == "HUNTER" then 
49    rf2_spell_list = { 
50      buffs = { 
51        [1] = { tag = "battle", spellid = 2048, size = 32, fontsize = 24, posx = 0, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}
52        [2] = { tag = "commanding", spellid = 469, size = 32, fontsize = 24, posx = 40, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}
53      }
54      debuffs = { 
55        [1] = { tag = "demo", spellid = 25203, size = 32, fontsize = 24, posx = 0, posy = 40, framestrata = "BACKGROUND", anchor = "UIParent"}
56        [2] = { tag = "sunder", spellid = 25225, size = 32, fontsize = 24, posx = 40, posy = 40, framestrata = "BACKGROUND", anchor = "UIParent"}
57        [3] = { tag = "clap", spellid = 25264, size = 32, fontsize = 24, posx = 80, posy = 40, framestrata = "BACKGROUND", anchor = "UIParent"}
58        [4] = { tag = "scorpid", spellid = 3043, size = 32, fontsize = 24, posx = 120, posy = 40, framestrata = "BACKGROUND", anchor = "UIParent"}
59      }
60      cooldowns = { 
61        [1] = { tag = "wrath", spellid = 19574, size = 32, fontsize = 24, posx = 0, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}
62        [2] = { tag = "rapid", spellid = 3045, size = 32, fontsize = 24, posx = 40, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}
63        [3] = { tag = "arcane", spellid = 27019, size = 32, fontsize = 24, posx = 80, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}
64      }
65    } 
66  elseif rf2_player_class == "WARRIOR" then 
67    rf2_spell_list = { 
68      buffs = { 
69        [1] = { tag = "battle", spellid = 2048, size = 18, fontsize = 16, posx = -25, posy = -230, framestrata = "BACKGROUND", anchor = "UIParent"}
70        [2] = { tag = "commanding", spellid = 469, size = 18, fontsize = 16, posx = 0, posy = -230, framestrata = "BACKGROUND", anchor = "UIParent"}
71        [3] = { tag = "rampage", spellid = 30033, size = 18, fontsize = 16, posx = 25, posy = -230, framestrata = "BACKGROUND", anchor = "UIParent"}
72        --[3] = { tag = "berserker", spellid = 18499, size = 32, fontsize = 24, posx = 160, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}, 
73        --[5] = { tag = "block", spellid = 2565, size = 32, fontsize = 24, posx = 80, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}, 
74      }
75      debuffs = { 
76        [1] = { tag = "sunder", spellid = 25225, size = 18, fontsize = 16, posx = -75, posy = -200, framestrata = "BACKGROUND", anchor = "UIParent"}
77        [2] = { tag = "demo", spellid = 25203, size = 18, fontsize = 16, posx = -50, posy = -200, framestrata = "BACKGROUND", anchor = "UIParent"}
78        [3] = { tag = "clap", spellid = 25264, size = 18, fontsize = 16, posx = -25, posy = -200, framestrata = "BACKGROUND", anchor = "UIParent"}
79        [4] = { tag = "scorpid", spellid = 3043, size = 18, fontsize = 16, posx = 0, posy = -200, framestrata = "BACKGROUND", anchor = "UIParent"}
80        [5] = { tag = "fearie", spellid = 26993, size = 18, fontsize = 16, posx = 25, posy = -200, framestrata = "BACKGROUND", anchor = "UIParent"}
81        [6] = { tag = "fearieferal", spellid = 27011, size = 18, fontsize = 16, posx = 25, posy = -200, framestrata = "BACKGROUND", anchor = "UIParent"}
82        [7] = { tag = "curseofreck", spellid = 27226, size = 18, fontsize = 16, posx = 50, posy = -200, framestrata = "BACKGROUND", anchor = "UIParent"}
83        [8] = { tag = "curseoftong", spellid = 11719, size = 18, fontsize = 16, posx = 75, posy = -200, framestrata = "BACKGROUND", anchor = "UIParent"}
84      }
85      cooldowns = { 
86        [1] = { tag = "bloodrage", spellid = 2687, size = 32, fontsize = 24, posx = -140, posy = -215, framestrata = "BACKGROUND", anchor = "UIParent"}
87        [2] = { tag = "berserkercool", spellid = 18499, size = 32, fontsize = 24, posx = -180, posy = -215, framestrata = "BACKGROUND", anchor = "UIParent"}
88        --[1] = { tag = "revenge", spellid = 30357, size = 32, fontsize = 24, posx = 0, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}, 
89        --[2] = { tag = "shieldslam", spellid = 30356, size = 32, fontsize = 24, posx = 40, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}, 
90      }
91    } 
92    elseif rf2_player_class == "ROGUE" then 
93    rf2_spell_list = { 
94      buffs = { 
95        [1] = { tag = "slice", spellid = 6774, size = 18, fontsize = 12, posx = -225, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
96        [2] = { tag = "blade", spellid = 13877, size = 18, fontsize = 12, posx = -200, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
97        [3] = { tag = "adrenalin", spellid = 13750, size = 18, fontsize = 12, posx = -175, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
98        [4] = { tag = "cloak", spellid = 31224, size = 18, fontsize = 12, posx = -150, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
99        [5] = { tag = "ghostly", spellid = 14278, size = 18, fontsize = 12, posx = -125, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
100        --[3] = { tag = "berserker", spellid = 18499, size = 32, fontsize = 24, posx = 160, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}, 
101        --[5] = { tag = "block", spellid = 2565, size = 32, fontsize = 24, posx = 80, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}, 
102      }
103      debuffs = { 
104        [1] = { tag = "rupture", spellid = 26867, size = 18, fontsize = 12, posx = 50, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
105        [2] = { tag = "deadly", spellid = 27187, size = 18, fontsize = 12, posx = 75, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
106        [3] = { tag = "wound", spellid = 27189, size = 18, fontsize = 12, posx = 100, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
107        [4] = { tag = "mind", spellid = 11399, size = 18, fontsize = 12, posx = 125, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
108        [5] = { tag = "kidney", spellid = 8643, size = 18, fontsize = 12, posx = 150, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
109        [6] = { tag = "cheap", spellid = 1833, size = 18, fontsize = 12, posx = 175, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
110        [7] = { tag = "sap", spellid = 11297, size = 18, fontsize = 12, posx = 200, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
111        [8] = { tag = "exposearmor", spellid = 26866, size = 18, fontsize = 12, posx = 225, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
112        [9] = { tag = "gouge", spellid = 38764, size = 18, fontsize = 12, posx = 250, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
113      }
114      cooldowns = { 
115        [1] = { tag = "kick", spellid = 38768, size = 24, fontsize = 18, posx = 0, posy = -300, framestrata = "BACKGROUND", anchor = "UIParent"}
116        [2] = { tag = "cloakshadow", spellid = 31224, size = 24, fontsize = 18, posx = 0, posy = -270, framestrata = "BACKGROUND", anchor = "UIParent"}
117        [3] = { tag = "shadowstep", spellid = 36554, size = 24, fontsize = 18, posx = 0, posy = -240, framestrata = "BACKGROUND", anchor = "UIParent"}
118        [4] = { tag = "vanish", spellid = 26889, size = 24, fontsize = 18, posx = 0, posy = -210, framestrata = "BACKGROUND", anchor = "UIParent"}
119        [5] = { tag = "ghostlystrike", spellid = 14278, size = 24, fontsize = 18, posx = 0, posy = -180, framestrata = "BACKGROUND", anchor = "UIParent"}
120        --[1] = { tag = "revenge", spellid = 30357, size = 32, fontsize = 24, posx = 0, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}, 
121        --[2] = { tag = "shieldslam", spellid = 30356, size = 32, fontsize = 24, posx = 40, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}, 
122      }
123    } 
124      elseif rf2_player_class == "PRIEST" then 
125    rf2_spell_list = { 
126      buffs = { 
127        [1] = { tag = "Renew", spellid = 25222, size = 18, fontsize = 12, posx = -225, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
128        [2] = { tag = "pwshield", spellid = 25218, size = 18, fontsize = 12, posx = -200, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
129        [3] = { tag = "pwmend", spellid = 33076, size = 18, fontsize = 12, posx = -175, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
130        [4] = { tag = "innerfire", spellid = 25431, size = 18, fontsize = 12, posx = -150, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
131        [5] = { tag = "powerinf", spellid = 10060, size = 18, fontsize = 12, posx = -125, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
132        [6] = { tag = "painsupress", spellid = 33206, size = 18, fontsize = 12, posx = -100, posy = -275, framestrata = "BACKGROUND", anchor = "UIParent"}
133        --[3] = { tag = "berserker", spellid = 18499, size = 32, fontsize = 24, posx = 160, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}, 
134        --[5] = { tag = "block", spellid = 2565, size = 32, fontsize = 24, posx = 80, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}, 
135      }
136      debuffs = { 
137        [1] = { tag = "swpain", spellid = 25368, size = 18, fontsize = 12, posx = 50, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
138        [2] = { tag = "weakendsoul", spellid = 6788, size = 18, fontsize = 12, posx = 75, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
139        [3] = { tag = "fear", spellid = 10890, size = 18, fontsize = 12, posx = 100, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
140        [4] = { tag = "vtouch", spellid = 34917, size = 18, fontsize = 12, posx = 125, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
141        [5] = { tag = "vembrace", spellid = 15286, size = 18, fontsize = 12, posx = 150, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
142        [6] = { tag = "silence", spellid = 15487, size = 18, fontsize = 12, posx = 175, posy = -220, framestrata = "BACKGROUND", anchor = "UIParent"}
143      }
144      cooldowns = { 
145        [1] = { tag = "painsup", spellid = 33206, size = 24, fontsize = 18, posx = 0, posy = -300, framestrata = "BACKGROUND", anchor = "UIParent"}
146        [2] = { tag = "powerinfusion", spellid = 10060, size = 24, fontsize = 18, posx = 0, posy = -270, framestrata = "BACKGROUND", anchor = "UIParent"}
147        [3] = { tag = "pom", spellid = 33076, size = 24, fontsize = 18, posx = 0, posy = -240, framestrata = "BACKGROUND", anchor = "UIParent"}
148        [4] = { tag = "fearward", spellid = 6346, size = 24, fontsize = 18, posx = 0, posy = -210, framestrata = "BACKGROUND", anchor = "UIParent"}
149        [5] = { tag = "physicscream", spellid = 10890, size = 24, fontsize = 18, posx = 0, posy = -180, framestrata = "BACKGROUND", anchor = "UIParent"}
150        [6] = { tag = "innerfocus", spellid = 14751, size = 24, fontsize = 18, posx = 0, posy = -150, framestrata = "BACKGROUND", anchor = "UIParent"}
151 
152        --[1] = { tag = "revenge", spellid = 30357, size = 32, fontsize = 24, posx = 0, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}, 
153        --[2] = { tag = "shieldslam", spellid = 30356, size = 32, fontsize = 24, posx = 40, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}, 
154      }
155    } 
156  else 
157    rf2_spell_list = { 
158      buffs = { 
159        [1] = { tag = "battle", spellid = 2048, size = 32, fontsize = 24, posx = 0, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}
160        --[2] = { tag = "commanding", spellid = 469, size = 32, fontsize = 24, posx = 40, posy = 0, framestrata = "BACKGROUND", anchor = "UIParent"}, 
161      }
162      debuffs = { 
163        [1] = { tag = "demo", spellid = 25203, size = 32, fontsize = 24, posx = 0, posy = 40, framestrata = "BACKGROUND", anchor = "UIParent"}
164        [2] = { tag = "sunder", spellid = 25225, size = 32, fontsize = 24, posx = 40, posy = 40, framestrata = "BACKGROUND", anchor = "UIParent"}
165        --[3] = { tag = "clap", spellid = 25264, size = 32, fontsize = 24, posx = 80, posy = 40, framestrata = "BACKGROUND", anchor = "UIParent"}, 
166        --[4] = { tag = "scorpid", spellid = 3043, size = 32, fontsize = 24, posx = 120, posy = 40, framestrata = "BACKGROUND", anchor = "UIParent"}, 
167      }
168      cooldowns = { 
169        [1] = { tag = "revenge", spellid = 30357, size = 32, fontsize = 24, posx = 0, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}
170        --[2] = { tag = "shieldslam", spellid = 30356, size = 32, fontsize = 24, posx = 40, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}, 
171        --[3] = { tag = "bloodrage", spellid = 2687, size = 32, fontsize = 24, posx = 80, posy = 80, framestrata = "BACKGROUND", anchor = "UIParent"}, 
172      }
173    } 
174  end 
175 
176  ----------------------------------------------------- 
177  -- DO NOT TOUCH ANYTHING BELOW THIS LINE !!! 
178  ----------------------------------------------------- 
179 
180  addon:SetScript("OnEvent", function() 
181 
182    if(event=="PLAYER_LOGIN") then 
183      --DEFAULT_CHAT_FRAME:AddMessage("hallo welt") 
184      for index,value in ipairs(rf2_spell_list.buffs) do 
185        local string = rf2_spell_list.buffs[index] 
186        --DEFAULT_CHAT_FRAME:AddMessage(tostring(index).." : "..string.tag.." : "..string.spellid.." : "..string.posx.." : "..string.posy.." : "..string.framestrata.." : "..string.anchor) 
187        --create the frames 
188        addon:rf2_create_icon(string.spellid,"rf2_"..string.tag,string.size,string.fontsize,string.posx,string.posy,string.framestrata,string.anchor) 
189      end 
190      for index,value in ipairs(rf2_spell_list.debuffs) do 
191        local string = rf2_spell_list.debuffs[index] 
192        --DEFAULT_CHAT_FRAME:AddMessage(tostring(index).." : "..string.tag.." : "..string.spellid.." : "..string.posx.." : "..string.posy.." : "..string.framestrata.." : "..string.anchor) 
193        --create the frames 
194        addon:rf2_create_icon(string.spellid,"rf2_"..string.tag,string.size,string.fontsize,string.posx,string.posy,string.framestrata,string.anchor) 
195      end 
196      for index,value in ipairs(rf2_spell_list.cooldowns) do 
197        local string = rf2_spell_list.cooldowns[index] 
198        --DEFAULT_CHAT_FRAME:AddMessage(tostring(index).." : "..string.tag.." : "..string.spellid.." : "..string.posx.." : "..string.posy.." : "..string.framestrata.." : "..string.anchor) 
199        --create the frames 
200        addon:rf2_create_icon(string.spellid,"rf2_"..string.tag,string.size,string.fontsize,string.posx,string.posy,string.framestrata,string.anchor) 
201      end 
202      --create the OnUpdate timer frame 
203      addon:rf2_onUpdate() 
204    end 
205 
206    --stop timer when out of combat 
207    if(event=="PLAYER_REGEN_ENABLED") then 
208      addon:rf2_hide_timeframe("rf2_OnUpdateFrame"
209      for index,value in ipairs(rf2_spell_list.buffs) do 
210        local string = rf2_spell_list.buffs[index] 
211        local f = _G["rf2_"..string.tag] 
212        f:Hide() 
213      end 
214      for index,value in ipairs(rf2_spell_list.debuffs) do 
215        local string = rf2_spell_list.debuffs[index] 
216        local f = _G["rf2_"..string.tag] 
217        f:Hide() 
218      end 
219      for index,value in ipairs(rf2_spell_list.cooldowns) do 
220        local string = rf2_spell_list.cooldowns[index] 
221        local f = _G["rf2_"..string.tag] 
222        f:Hide() 
223      end 
224    end 
225 
226    --start the timer when in combat 
227    if(event=="PLAYER_REGEN_DISABLED") then 
228      addon:rf2_show_timeframe("rf2_OnUpdateFrame"
229    end 
230 
231 
232  end
233 
234  function addon:rf2_create_icon(spellId,frameName,size,fontsize,posX,posY,framestrata,anchor) 
235    --get spell infos 
236    local spellName, spellRank, SpellIcon, SpellCost, spellIsFunnel, spellPowerType, spellCastTime, spellMinRange, spellMaxRange = GetSpellInfo(spellId) 
237    --create the basic frame 
238    local f = CreateFrame("Frame",frameName,UIParent) 
239    f:SetFrameStrata(framestrata) 
240    f:SetWidth(size) 
241    f:SetHeight(size) 
242    --create icon texture 
243    local t = f:CreateTexture(frameName.."_icon","BACKGROUND"
244    t:SetTexture(SpellIcon) 
245    t:SetTexCoord(0.1,0.9,0.1,0.9
246    t:SetAllPoints(f) 
247    f.texture = t 
248    --create gloss texture 
249    local t2 = f:CreateTexture(nil,"LOW"
250    t2:SetTexture("Interface\\AddOns\\rTextures\\square"
251    t2:SetPoint("TOPLEFT", f, "TOPLEFT", -2, 2
252    t2:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 2, -2
253    f.texture = t2 
254 
255 
256 
257    local time = f:CreateFontString(frameName.."_time", "ARTWORK"
258    time:SetPoint("CENTER", f, "CENTER", 0, 0
259    --time:SetFontObject(GameFontHighlight) 
260    time:SetFont(NAMEPLATE_FONT,fontsize,"OUTLINE"
261    time:SetTextColor(1, 1, 0
262    time:SetText(""
263    time:Show() 
264    local num = f:CreateFontString(frameName.."_num", "OVERLAY"
265    num:SetPoint("BOTTOMRIGHT", f, "BOTTOMRIGHT", 4, -4
266    --time:SetFontObject(GameFontHighlight) 
267    num:SetFont(NAMEPLATE_FONT,floor(fontsize*0.8),"OUTLINE"
268    num:SetTextColor(0.8, 0.8, 0.8
269    num:SetText(""
270    num:Show() 
271    --position the frame 
272    f:SetPoint("CENTER",posX,posY) 
273    if testmode == 1 then 
274      f:Show() 
275      num:SetText("9"
276      time:SetText("99"
277    else 
278      f:Hide() 
279    end 
280  end 
281 
282 
283  function addon:rf2_onUpdate() 
284    --create the timer frame that will "contain" the timer 
285    --timer can be switched on/off when showing/hiding the frame 
286    local f = CreateFrame("Frame", "rf2_OnUpdateFrame"
287    local totalElapsed = 0 
288    --hacked timer function from Iriel 
289    local function rf2_OnUpdateFunc(self, elapsed) 
290      totalElapsed = totalElapsed + elapsed 
291      --determines how often the function is called 
292      local rf2_update_timer = 1 
293      if (totalElapsed < rf2_update_timer) then 
294        --do nothing 
295        --THIS ONE IS IMPORTANT 
296        --you need this or the onUpdate function will kill your CPU 
297        return 
298      else 
299        --ChatFrame1:AddMessage("tick"..totalElapsed) 
300        totalElapsed = totalElapsed - floor(totalElapsed) 
301        --totalElapsed = totalElapsed - rf2_update_timer 
302        --do sth 
303        for index,value in ipairs(rf2_spell_list.buffs) do 
304          local string = rf2_spell_list.buffs[index] 
305          --call check buff 
306          --DEFAULT_CHAT_FRAME:AddMessage("check buff") 
307          addon:rf2_check_buff(string.tag,string.spellid) 
308        end 
309        for index,value in ipairs(rf2_spell_list.debuffs) do 
310          local string = rf2_spell_list.debuffs[index] 
311          --call check debuff 
312          --DEFAULT_CHAT_FRAME:AddMessage("check debuff") 
313          addon:rf2_check_debuff(string.tag,string.spellid) 
314        end 
315        for index,value in ipairs(rf2_spell_list.cooldowns) do 
316          local string = rf2_spell_list.cooldowns[index] 
317          --call check cooldowns 
318          --DEFAULT_CHAT_FRAME:AddMessage("check cooldowns") 
319          addon:rf2_check_cooldown(string.tag,string.spellid) 
320        end 
321      end 
322    end 
323    --set a script on the frame that activates itself on each onupdate (every frame generation!) 
324    f:SetScript("OnUpdate", rf2_OnUpdateFunc) 
325    --Hide (STOP) the timer out of combat, otherwise Show (START) it 
326    if UnitAffectingCombat("player") == 1 then 
327      f:Show() 
328    else 
329      f:Hide() 
330    end 
331  end 
332 
333  --starts the onupdate timer 
334  function addon:rf2_show_timeframe(frameName) 
335    local f = _G[frameName] 
336    f:Show() 
337  end 
338 
339  --stops the onupdate timer 
340  function addon:rf2_hide_timeframe(frameName) 
341    local f = _G[frameName] 
342    f:Hide() 
343  end 
344 
345  function addon:rf2_check_buff(frameTag,spellId) 
346    local spellName, spellRank, SpellIcon, SpellCost, spellIsFunnel, spellPowerType, spellCastTime, spellMinRange, spellMaxRange = GetSpellInfo(spellId) 
347    local f = _G["rf2_"..frameTag] 
348    f:Hide() 
349    local f2 = _G["rf2_"..frameTag.."_time"
350    local f3 = _G["rf2_"..frameTag.."_num"
351    for i = 1, 40 do 
352      local name, rank, texture, applications, duration, timeleft = UnitBuff("player", i) 
353      if name == spellName then 
354        local floortime = "" 
355        if timeleft ~= nil then 
356          floortime = floor(timeleft) 
357        end 
358        local floornum = "" 
359        if applications ~= nil then 
360          floornum = floor(applications) 
361          if floornum == 0 then 
362            floornum = "" 
363          end 
364        end 
365        --DEFAULT_CHAT_FRAME:AddMessage("found "..name.." : "..floortime) 
366        f:Show() 
367        f2:SetText(floortime) 
368        f3:SetText(floornum) 
369      end 
370    end 
371  end 
372 
373  function addon:rf2_check_debuff(frameTag,spellId) 
374    local spellName, spellRank, SpellIcon, SpellCost, spellIsFunnel, spellPowerType, spellCastTime, spellMinRange, spellMaxRange = GetSpellInfo(spellId) 
375    local f = _G["rf2_"..frameTag] 
376    f:Hide() 
377    local f2 = _G["rf2_"..frameTag.."_time"
378    local f3 = _G["rf2_"..frameTag.."_num"
379    for i = 1, 40 do 
380      local name, _, texture, applications, debufftype, duration, timeleft = UnitDebuff("target", i) 
381      if name == spellName then 
382        local floortime = "" 
383        if timeleft ~= nil then 
384          floortime = floor(timeleft) 
385        end 
386        local floornum = "" 
387        if applications ~= nil then 
388          floornum = floor(applications) 
389          if floornum == 0 then 
390            floornum = "" 
391          end 
392        end 
393        --DEFAULT_CHAT_FRAME:AddMessage("found "..spellName.." : "..floortime) 
394       if duration ~= nil then 
395        f:Show() 
396            f2:SetText(floortime) 
397            f3:SetText(floornum) 
398      end 
399      end 
400    end 
401  end 
402 
403 
404  function addon:rf2_check_cooldown(frameTag,spellId) 
405    local spellName, spellRank, SpellIcon, SpellCost, spellIsFunnel, spellPowerType, spellCastTime, spellMinRange, spellMaxRange = GetSpellInfo(spellId) 
406    local f = _G["rf2_"..frameTag] 
407    f:Hide() 
408    local f2 = _G["rf2_"..frameTag.."_time"
409    local f3 = _G["rf2_"..frameTag.."_num"
410    local spellCooldownStartTime, spellCooldownDuration, spellEnabled = GetSpellCooldown(spellName); 
411 
412    local localstartime = 0 
413    if spellCooldownStartTime ~= nil then 
414      localstartime = floor(spellCooldownStartTime) 
415    end 
416 
417    local floortime = 0 
418    if spellCooldownDuration ~= nil then 
419      floortime = floor(spellCooldownDuration) 
420    end 
421    local floornum = "" 
422    if spellEnabled ~= nil then 
423      floornum = floor(spellEnabled) 
424      if floornum == 0 then 
425        floornum = "1" 
426      else 
427        floornum = "" 
428      end 
429    end 
430    local now = floor(GetTime()) 
431    --DEFAULT_CHAT_FRAME:AddMessage("found "..frameTag.." : "..floortime.." : "..localstartime.." : "..now) 
432    local cooldown = (localstartime+floortime-now) 
433    --if cooldown == 2 then 
434    --  DEFAULT_CHAT_FRAME:AddMessage(spellName.." READY IN 2 SECONDS !!!") 
435    --end 
436    if cooldown > 1 then 
437      f:Show() 
438    end 
439    f2:SetText(cooldown) 
440    f3:SetText(floornum) 
441 
442  end 
443 
444 
445  addon:RegisterEvent"PLAYER_LOGIN" 
446  addon:RegisterEvent"PLAYER_REGEN_DISABLED" 
447  addon:RegisterEvent"PLAYER_REGEN_ENABLED" 
Download and save
Toggle line numbers
Thread:
[88543] rFilter2 by xbiggs // zork at 2008-05-28 01:09:04
  [106444] jacks1@link.net by Tzvi at 2009-01-16 06:29:45 (diff)
Tip: Click the line numbers to toggle highliting on that line.

Paste followup:

Language:
Author:
Subject:


    Tabstop:     bigger biggest
Note: You can prefix a line with "@@@" to highlight it.