03-05-12, 08:53 PM | #1 |
code to check player for buff
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 .... Last edited by Seerah : 03-06-12 at 10:07 AM. Reason: (moved from a thread in the tutorials section) |
|
03-06-12, 10:50 AM | #2 |
__________________
The cataclysm broke the world ... and the pandas could not fix it! |
|
03-06-12, 11:02 PM | #3 |
Something like this:
lua Code:
|
|
03-08-12, 07:49 PM | #4 |
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) .... Heres a pastebin of the lua as it stands: http://pastebin.com/0prqsJwk the issue I am running into is the UpdateBuffStats() from line 336 to line 349 I want to check the player to see if he has any of the buffs you can select in the addon to see your raid buffed stats currently applied, and if so, to change the output of the UpdateBuffStats() As it stands, the lines in question are : Code:
local food, strength, stat local function UpdateBuffStats() BuffStrengthAdjust = strength.StrengthValue + food.StrengthValue BuffParryAdjust = food.ParryValue BuffDodgeAdjust = food.DodgeValue BuffMasteryAdjust = food.MasteryValue BuffMultiplierAdjust = stat.BuffValue PAPERDOLL_STATINFO["TOTALAVOIDANCE"].updateFunc(Frame1, "player") PAPERDOLL_STATINFO["COMBATTABLE"].updateFunc(Frame2, "player") end Code:
"Mark of the Wild" = 79061 "Blessing of Kings" = 79063 "Horn of Winter" = 57330 "Battle Shout" = 6673 "Well Fed" = 87554 --Dodge food Buff "Well Fed" = 87555 --Parry Food Buff "Well Fed" = 87549 --Mastery Food Buff "Well Fed" = 87545 --Strength Food Buff 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: Code:
if (spellId ~= 79061 and spellId ~= 79063) then BuffMultiplierAdjust = stat.BuffValue else BuffMultiplierAdjust = 1 if spellId ~= 87549 then BuffMasteryAdjust = food.MasteryValue else BuffMasteryAdjust = 0 if spellId ~= 87554 then BuffDodgeAdjust = food.DodgeValue else BuffDodgeAdjust = 0 if spellId ~= 87555 then BuffParryAdjust = food.ParryValue else BuffParryAdjust = 0 --this next formula is a bit more complex as there are 3 combinations :( if (spellId ~= 57330 and spellId ~= 6673 and spellId ~= 87545) then BuffStrengthAdjust = strength.StrengthValue + food.StrengthValue else if (spellId = 57330 or spellId = 6673) and spellId ~= 87545 then BuffStrengthAdjust = food.StrengthValue else if (spellId ~= 57330 and spellId ~= 6637) and spellId = 87545 then BuffStrengthAdjust = strength.StrengthValue 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 |
|
03-08-12, 08:42 PM | #5 |
Here's how you would modify Phanx's code to do what you want to do:
lua Code:
You'll have to calculate a bit differently than you've been doing, but it should actually be simpler. |
|
WoWInterface » Developer Discussions » Lua/XML Help » code to check player for buff |
«
Previous Thread
|
Next Thread
»
|
Thread Tools | |
Display Modes | |
|
|