View Single Post
12-05-13, 08:53 AM   #4
ckaotik
A Fallenroot Satyr
 
ckaotik's Avatar
AddOn Author - Click to view addons
Join Date: Nov 2008
Posts: 29
I have something along these lines in a custom addon ... here are the parts that you would probably need. However, I have not tested this code (as standalone). It assumes that any CC effect is on a diminishing return and only shows those.

P.S. Please tell me if this worked for you

Requirements:

1) a place to put the code: If you don't happen to have a dummy addon to stuff code into already, you can create one here: http://addon.bool.no
2) DRData-1.0 library, which can be found here: http://www.wowace.com/addons/drdata-1-0/
3) put this in your lua file (or the lua input box on addon.bool.no)
Lua Code:
  1. local DRData = LibStub('DRData-1.0')
  2. local hideDRType = {
  3.     ["ctrlroot"] = true,
  4.     ["shortroot"] = true,
  5.     ["disarm"] = true,
  6.     ["taunt"] = true,
  7.     ["knockback"] = true,
  8. }
  9.  
  10. local isDisabled = nil
  11. local _FRAMES = {}
  12.  
  13. local function UpdateOverlay(self)
  14.     if not self.Overlay then return end
  15.     local display, drType = nil, nil
  16.     for i = 1, 40 do
  17.         local _, _, icon, count, dispelType, _, expires, caster, _, _, spellID, canApplyAura, isBoss = UnitDebuff(self.displayedUnit or self.unit, i)
  18.         local drType = DRData:GetSpellCategory(spellID)
  19.         if drType and not hideDRType[drType] then
  20.             display = true
  21.             break
  22.         end
  23.     end
  24.  
  25.     if display then
  26.         self.Overlay.icon:SetTexture(icon)
  27.         self.Overlay.icon:SetDesaturated( caster == "player" )
  28.         self.Overlay.count:SetText(count == 1 and '' or count)
  29.         local now = GetTime()
  30.         self.Overlay.cooldown:SetCooldown(now, expires - now)
  31.  
  32.         self.Overlay:Show()
  33.     else
  34.         self.Overlay:Hide()
  35.     end
  36. end
  37.  
  38. local isHooked = nil
  39. local Disable = function(self)
  40.     local overlay = self.Overlay
  41.     if overlay then
  42.         for k, frame in ipairs(_FRAMES) do
  43.             if frame == self then
  44.                 tremove(_FRAMES, k)
  45.                 overlay:Hide()
  46.                 break
  47.             end
  48.         end
  49.  
  50.         if #_FRAMES == 0 and isHooked then
  51.             isDisabled = true
  52.         end
  53.     end
  54. end
  55.  
  56. local Enable = function(self)
  57.     local overlay = self.Overlay
  58.     if overlay then
  59.         tinsert(_FRAMES, self)
  60.         isDisabled = nil
  61.         if not isHooked then
  62.             hooksecurefunc("CompactUnitFrame_UpdateDebuffs", UpdateOverlay)
  63.             isHooked = true
  64.         end
  65.     end
  66. end
  67.  
  68. hooksecurefunc("CompactUnitFrame_UpdateVisible", function(frame)
  69.     if not frame.Overlay and frame.unit and not frame.unit:find('pet') then
  70.         local overlay = CreateFrame("Button", "$parentCUFOverlay", frame, "CompactAuraTemplate")
  71.               overlay:SetPoint('CENTER', 0, 0)
  72.               overlay:SetSize(20, 20)
  73.               overlay:EnableMouse(false)
  74.               overlay:EnableMouseWheel(false)
  75.               overlay:Hide()
  76.         frame.Overlay = overlay
  77.         Enable(frame)
  78.     end
  79. end)
4) put this in your toc file (or click 'Show advanced (TOC) options' and add this line to the toc box):
Code:
## Dependencies: DRData-1.0
__________________
It all starts to make a creepy kind of sense. Avatar

Last edited by ckaotik : 12-11-13 at 01:58 PM. Reason: Fixed declaration of variables + _ taint, fixed missing argument 'frame'
  Reply With Quote