From 7b229482225c5a12b2dfe0fae2161d8b39d117a9 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Sat, 23 Mar 2013 21:39:03 +0000 Subject: [PATCH] Enhance GetAura methods to accept the name of a spell list. This allows for doing things like: OvaleAura:GetAura("player", "melee_haste", "HELPFUL") OvaleState:GetAura("player", "melee_haste", "HELPFUL") to get the first buff from the melee_haste spell list that is found on the player. As a side-effect of this change, the SpellInfo parameters that take a buff spell ID, e.g., buffnocd, buff_combo, etc., can now take a spell list name instead. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@822 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleAura.lua | 21 ++++++++++++++++++++- OvaleState.lua | 27 +++++++++++++++++++++++---- 2 files changed, 43 insertions(+), 5 deletions(-) diff --git a/OvaleAura.lua b/OvaleAura.lua index 8ef0443..40338de 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -317,7 +317,26 @@ function OvaleAura:GetAuraByGUID(guid, spellId, filter, mine, unitId) end function OvaleAura:GetAura(unitId, spellId, filter, mine) - return self:GetAuraByGUID(OvaleGUID:GetGUID(unitId), spellId, filter, mine, unitId) + local guid = OvaleGUID:GetGUID(unitId) + if type(spellId) == "number" then + return self:GetAuraByGUID(guid, spellId, filter, mine, unitId) + elseif OvaleData.buffSpellList[spellId] then + local newStart, newEnding, newStacks, newSpellHasteMultiplier, newValue, newGain + for _, v in pairs(OvaleData.buffSpellList[spellId]) do + local start, ending, stacks, spellHasteMultiplier, value, gain = self:GetAuraByGUID(guid, v, filter, mine, unitId) + if start and (not newStart or stacks > newStacks) then + newStart = start + newEnding = ending + newStacks = stacks + newSpellHasteMultiplier = spellHasteMultiplier + newValue = value + newGain = gain + end + end + return newStart, newEnding, newStacks, newSpellHasteMultiplier, newValue, newGain + elseif spellId == "Magic" or spellId == "Disease" or spellId == "Curse" or spellId == "Poison" then + return self:GetAuraByGUID(guid, spellId, filter, mine, unitId) + end end function OvaleAura:GetStealable(unitId) diff --git a/OvaleState.lua b/OvaleState.lua index efbd5fd..013e8fd 100644 --- a/OvaleState.lua +++ b/OvaleState.lua @@ -531,7 +531,7 @@ function OvaleState:AddEclipse(endCast, spellId) newAura.ending = nil end -function OvaleState:GetAuraByGUID(guid, spellId, filter, mine, target) +function OvaleState:GetAuraByGUID(guid, spellId, filter, mine, unitId) local aura if mine then local auraTable = self.aura[guid] @@ -559,12 +559,31 @@ function OvaleState:GetAuraByGUID(guid, spellId, filter, mine, target) return aura.start, aura.ending, aura.stacks, aura.spellHasteMultiplier, aura.value, aura.gain else Ovale:Log("Aura " .. spellId .. " not found in state for " .. tostring(guid)) - return OvaleAura:GetAuraByGUID(guid, spellId, filter, mine, target) + return OvaleAura:GetAuraByGUID(guid, spellId, filter, mine, unitId) end end -function OvaleState:GetAura(target, spellId, filter, mine) - return self:GetAuraByGUID(OvaleGUID:GetGUID(target), spellId, filter, mine, target) +function OvaleState:GetAura(unitId, spellId, filter, mine) + local guid = OvaleGUID:GetGUID(unitId) + if type(spellId) == "number" then + return self:GetAuraByGUID(guid, spellId, filter, mine, unitId) + elseif OvaleData.buffSpellList[spellId] then + local newStart, newEnding, newStacks, newSpellHasteMultiplier, newValue, newGain + for _, v in pairs(OvaleData.buffSpellList[spellId]) do + local start, ending, stacks, spellHasteMultiplier, value, gain = self:GetAuraByGUID(guid, v, filter, mine, unitId) + if start and (not newStart or stacks > newStacks) then + newStart = start + newEnding = ending + newStacks = stacks + newSpellHasteMultiplier = spellHasteMultiplier + newValue = value + newGain = gain + end + end + return newStart, newEnding, newStacks, newSpellHasteMultiplier, newValue, newGain + elseif spellId == "Magic" or spellId == "Disease" or spellId == "Curse" or spellId == "Poison" then + return self:GetAuraByGUID(guid, spellId, filter, mine, unitId) + end end -- Look for my aura on any target. -- 1.7.9.5