Here is the code
Code:
local dispellableDebuffTypes = { Magic = true, Curse = true, Disease = true, Poison = true};
function CompactUnitFrame_UpdateDispellableDebuffs(frame)
if ( not frame.dispelDebuffFrames or not frame.optionTable.displayDispelDebuffs ) then
CompactUnitFrame_HideAllDispelDebuffs(frame);
return;
end
--Clear what we currently have.
for debuffType, display in pairs(dispellableDebuffTypes) do
if ( display ) then
frame["hasDispel"..debuffType] = false;
end
end
local index = 1;
local frameNum = 1;
local filter = "RAID"; --Only dispellable debuffs.
while ( frameNum <= frame.maxDispelDebuffs ) do
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, canStealOrPurge, _, spellId = UnitDebuff(frame.displayedUnit, index, filter);
if ( dispellableDebuffTypes[debuffType] and not frame["hasDispel"..debuffType] ) then
frame["hasDispel"..debuffType] = true;
local dispellDebuffFrame = frame.dispelDebuffFrames[frameNum];
CompactUnitFrame_UtilSetDispelDebuff(dispellDebuffFrame, debuffType, index)
frameNum = frameNum + 1;
elseif ( not name ) then
break;
end
index = index + 1;
end
for i=frameNum, frame.maxDispelDebuffs do
local dispellDebuffFrame = frame.dispelDebuffFrames[i];
dispellDebuffFrame:Hide();
end
end
Thank you all for suggestions. Last I checked, RAID did not work at all.
As I mentioned earlier, it is too hard to check for debuffs, I had asked another Druid to cast Roots on me - how else can I check it ? Of course I could also do it with two accounts and two copies of WoW client - but my second account is unpaid currently...
It seems it uses the return from UnitAura / debuffType to check whether it should display the debuff or not on the raid frames. If the debuf is one of Curse, Poison, Magic or Disease then it gets shown.
This would further imply that the RAID flag of UnitAura filters out debuffs that the player cannot dispell for example a Resto Shaman cannot dispell Disease. The code however would happily accept disease as a valid debuff ? The only logical explanation is that the RAID filter has already filtered those kind of debuffs out. Fair enough. But then why bother even checking? Weird. Could someone please explain?
My Lua knowledge is not great and I am wondering:
local dispellableDebuffTypes = { Magic = true, Curse = true, Disease = true, Poison = true};
I cannot understand what Magic / Curse / Disease / Poison types are. They seem to be booleans but on the other hand are not declared anywhere (did a quick search). In addition the code then indexes dispellableDebuffTypes with the return from UnitAura() debuffType which is a string. Very weird and confusing and it works, obviously, so I am going to try it, but it would make more sense if it were like this
local dispellableDebuffTypes = { "Magic" = true, "Curse" = true, "Disease" = true, "Poison" = true};
If it were like this then we have a table indexed by strings and the UnitAura/debuffType is also a string.
Could someone please explain this to me too ?