View Single Post
06-04-18, 03:10 PM   #13
tehmoku
A Fallenroot Satyr
Join Date: May 2007
Posts: 27
So, here is the code for running on a throttled OnUpdate (just change the update interval to whatever you want).

Note: I only really care about raid frames being highly accurate, and I left the target frame how it was.

Fair warning, it's quite a bit more taxing on your CPU. It's a lot more reliable though, and probably what I will be using. This code is for legion, but just remove the underscore next to buffName on line 21 and it will work for BfA.

Lua Code:
  1. local ONUPDATE_INTERVAL = 0.5
  2. local lastUpdate = 0
  3.  
  4. --Compact Unit Frames
  5. hooksecurefunc("CompactUnitFrame_OnUpdate",function(frame, elapsed)
  6. lastUpdate = lastUpdate + elapsed
  7.  
  8.     if lastUpdate >= ONUPDATE_INTERVAL then
  9.         lastUpdate = 0
  10.  
  11.         local index = 1
  12.         local frameNum = 1
  13.         local filter = nil
  14.  
  15.         while ( frameNum <= frame.maxBuffs ) do
  16.             local buffNames = UnitBuff(frame.displayedUnit, index, filter)
  17.             if ( buffNames ) then
  18.                 if ( CompactUnitFrame_UtilShouldDisplayBuff(frame.displayedUnit, index, filter) and not CompactUnitFrame_UtilIsBossAura(frame.displayedUnit, index, filter, true) ) then
  19.                     local buffFrame = frame.buffFrames[frameNum]
  20.  
  21.                     local buffName, _, icon, count, debuffType, duration, expirationTime, caster, canStealOrPurge, nameplateShowPersonal,
  22.                     spellId, canApplyAura, isBossDebuff, casterIsPlayer, nameplateShowAll, timeMod, _ = UnitBuff(frame.displayedUnit, index, filter)
  23.  
  24.                     if spellId == 33763 and casterIsPlayer then
  25.                         local timeRemaining = (expirationTime - GetTime()) / timeMod
  26.                         local refreshTime = duration * 0.3
  27.  
  28.                         if not buffFrame.highlight then
  29.                             local highlight = buffFrame:CreateTexture(nil, "OVERLAY")
  30.                             highlight:SetTexture([[Interface\TargetingFrame\UI-TargetingFrame-Stealable]])
  31.                             highlight:SetPoint("TOPLEFT", -3, 3)
  32.                             highlight:SetPoint("BOTTOMRIGHT", 3, -3)
  33.                             highlight:SetBlendMode("ADD")
  34.                             buffFrame.highlight = highlight
  35.                         end
  36.  
  37.                         if timeRemaining <= refreshTime then
  38.                             buffFrame.highlight:Show()
  39.                         else
  40.                             buffFrame.highlight:Hide()
  41.                         end
  42.  
  43.                     elseif buffFrame.highlight then
  44.                         buffFrame.highlight:Hide()
  45.                     end
  46.  
  47.                     frameNum = frameNum + 1
  48.                 end
  49.             else
  50.                 break
  51.             end
  52.             index = index + 1
  53.         end
  54.     end
  55. end)

Last edited by tehmoku : 06-07-18 at 12:41 AM.
  Reply With Quote