What is the code you need to check if a unit("player") has a certain buff?
Woulldnt mind fitting that into my addon to check if the player has any of the following buffs:
Battle Shout,
Horn of Winter,
Kings,
Mark of the Wild,
Well Fed.
Am new to this lua stuff, so any assistance would be appreciated ....

Hmmmm ... I think I wasnt specific enough in the original question ...

The addon I have done is up and running on wow interface ( http://www.wowinterface.com/download...enseStats.html )
It is working fine, apart from the fact that it assumes you have no buffs currently when it does all the calculations to output your CTC.
If you get a buff that you can select from the dropdowns, then effectively the buff is added twice to the calculations (these are the only buffs available that will affect your Combat Table Coverage (well, apart from different ranks and the myriad of food buffs that give lower stat rating boosts, but that would need a list faaaaaaar too long to factor into the equations) ....

I need to check if the player has these buffs (it will need to be by spellId as the well fed buffs all return the name 'Well Fed' even though they give different stats .... (stupid way of blizzard doing this IMO)

I know WHAT I need to do, but cant, for the life of me incorporate it into the addon.....
Once getting the spellId of all buffs currently on the player (using spellId = UnitAura("player",i) ), the current values for BuffStrengthAdjust, BuffParryAdjust, BuffDodgeAdjust, BuffMasteryAdjust and BufMultiplierAdjust would need to be worked out in the following way:

I have no feckin idea how to get this lot into the lua to factor in the current buffs when working out the new stat values ( I actually DID get it working once, but the values didnt update if the buff disappeared (like Battle shout with its 2 minute cooldown), but much to my chagrin, this poxy village suffered a power cut at that time and I lost the file :( )

I may be going about this in totally the wrong way, as it may be simpler to factor in the Current buffs when you are selecting the raid buffs from the dropdown menu (though that would be complicated when choosing from the list of food buffs )

Andy

kaels

03-08-12 08:42 PM

Here's how you would modify Phanx's code to do what you want to do:

lua Code:

local buffs ={

-- setting the defaults to false so that you can start out assuming the player doesn't have the buff

["Battle Shout"]=false,

["Blessing of Kings"]=false,

["Horn of Winter"]=false,

["Mark of the Wild"]=false,

-- add the spell IDs for food buffs here - you can feed them into UnitBuff with the same syntax as spell names

87554=false,

87555=false,

87549=false,

87545=false,

}

local frame = CreateFrame("Frame")

frame:RegisterEvent("UNIT_AURA")

-- probably want to check for buffs on login as well, I'm not sure if Unit_Aura fires

frame:RegisterEvent("PLAYER_ENTERING_WORLD")

frame:SetScript("OnEvent", function(self, event, ...)

if(unit and unit ~="player")then

return

end

for buff inpairs(buffs)do

if UnitBuff("player", buff)then

-- If you have the buff, check to see if it's already been factored in

ifnot buffs[buff]then

-- If it hasn't been factored in, adjust accordingly

buffs[buff]=true

AddBuffAdjustment(buff)

end

else

-- If you don't have the buff, check to see if you're still adjusting for it

if buffs[buff]then

-- If you're still adjusting for it, remove the adjustment

buffs[buff]=false

RemoveBuffAdjustment(buff)

end

end

end

end)

localfunction AddBuffAdjustment(buff)

if buff =="Battle Shout"then

-- do whatever you need to do when Battle Shout is added

elseif buff =="Blessing of Kings"or buff ="Mark of the Wild"then

-- do whatever you need to do when BoK/Mark is added

elseif

-- and so forth

else

end

end

localfunction RemoveBuffAdjustment(buff)

if buff =="Battle Shout"then

-- do whatever you need to do when Battle Shout is removed

elseif buff =="Blessing of Kings"or buff =="Mark of the Wild"then

-- do whatever you need to do when BoK/Mark is removed

elseif

-- and so forth

else

end

end

You'll have to calculate a bit differently than you've been doing, but it should actually be simpler.