From b5d7f03a201d12a570f712d85ead85f3d591c012 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Sun, 28 Oct 2012 22:02:05 +0000 Subject: [PATCH] Cache aura values if available when updating auras on units. Use the cached values in TickValue() script condition. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@630 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleAura.lua | 12 ++++++---- OvaleCondition.lua | 67 +++++++++++++++++++++++++++++----------------------- 2 files changed, 45 insertions(+), 34 deletions(-) diff --git a/OvaleAura.lua b/OvaleAura.lua index 141f8b3..b5b96ad 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -108,7 +108,7 @@ function OvaleAura:UPDATE_SHAPESHIFT_FORMS(event) self:ShapeshiftEventHandler() end -function OvaleAura:AddAura(unitGUID, spellId, unitCaster, icon, count, debuffType, duration, expirationTime, isStealable, name) +function OvaleAura:AddAura(unitGUID, spellId, unitCaster, icon, count, debuffType, duration, expirationTime, isStealable, name, value) local auraList = self.aura[unitGUID] if not auraList[spellId] then @@ -151,6 +151,7 @@ function OvaleAura:AddAura(unitGUID, spellId, unitCaster, icon, count, debuffTyp aura.mine = mine aura.source = unitCaster aura.name = name + aura.value = value end end @@ -200,8 +201,11 @@ function OvaleAura:UpdateAuras(unitId, unitGUID) local i = 1 local mode = "HELPFUL" + local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId + local canApplyAura, isBossDebuff, value1, value2, value3 while (true) do - local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(unitId, i, mode) + name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId, + canApplyAura, isBossDebuff, value1, value2, value3 = UnitAura(unitId, i, mode) if not name then if mode == "HELPFUL" then mode = "HARMFUL" @@ -211,11 +215,11 @@ function OvaleAura:UpdateAuras(unitId, unitGUID) end else if (unitCaster == "player" and OvaleData.spellFilter.mine[spellId]) or OvaleData.spellFilter.any[spellId] then - self:AddAura(unitGUID, spellId, unitCaster, icon, count, debuffType, duration, expirationTime, isStealable, name) + self:AddAura(unitGUID, spellId, unitCaster, icon, count, debuffType, duration, expirationTime, isStealable, name, value1) if debuffType then -- TODO: not very clean -- should be computed by OvaleState:GetAura - self:AddAura(unitGUID, debuffType, unitCaster, icon, count, debuffType, duration, expirationTime, isStealable, name) + self:AddAura(unitGUID, debuffType, unitCaster, icon, count, debuffType, duration, expirationTime, isStealable, name, value1) end end diff --git a/OvaleCondition.lua b/OvaleCondition.lua index fa994ec..3109512 100644 --- a/OvaleCondition.lua +++ b/OvaleCondition.lua @@ -299,6 +299,36 @@ local function testValue(comparator, limit, value, atTime, rate) end end +local function getAura(target, spellId, mine) + local aura + if type(spellId) == "number" then + aura = OvaleState:GetAura(target, spellId, mine) + elseif OvaleData.buffSpellList[spellId] then + local newAura + for k,v in pairs(OvaleData.buffSpellList[spellId]) do + newAura = OvaleState:GetAura(target, v, mine) + if newAura and (not aura or newAura.stacks > aura.stacks) then + aura = newAura + end + end + elseif spellId == "Magic" or spellId == "Disease" or spellId == "Curse" or spellId == "Poison" then + aura = OvaleState:GetAura(target, spellId, mine) + end + return aura +end + +local function getMine(condition) + local mine = true + if condition.any then + if condition.any == 0 then + mine = true + else + mine = false + end + end + return mine +end + -- Recherche un aura sur la cible et récupère sa durée et le nombre de stacks -- return start, ending, stacks, spellHaste local function GetTargetAura(condition, target) @@ -313,34 +343,13 @@ local function GetTargetAura(condition, target) stacks = 1 end local spellId = condition[1] + local mine = getMine(condition) - local mine = true - if condition.any then - mine = false - end - - local aura - if type(spellId) == "number" then - aura = OvaleState:GetAura(target, spellId, mine) - elseif OvaleData.buffSpellList[spellId] then - for k,v in pairs(OvaleData.buffSpellList[spellId]) do - local newAura = OvaleState:GetAura(target, v, mine) - if newAura and (not aura or newAura.stacks>aura.stacks) then - aura = newAura - end - end - elseif spellId == "Magic" or spellId == "Disease" or spellId=="Curse" or spellId=="Poison" then - aura = OvaleState:GetAura(target, spellId, mine) - else - Ovale:Error("unknown buff "..spellId) - return 0,0,0,0 - end - + local aura = getAura(target, spellId, mine) if not aura then Ovale:Log("Aura "..spellId.." not found") return 0,0,0,0 - end - + end if Ovale.trace then Ovale:Print("GetTargetAura = start=".. tostring(aura.start) .. " end="..tostring(aura.ending).." stacks=" ..tostring(aura.stacks).."/"..stacks) end @@ -2445,13 +2454,11 @@ end -- Spell(purifying_brew) OvaleCondition.conditions.tickvalue = function(condition) - local target = getTarget(condition.target) - local name = GetSpellInfo(condition[1]) - local value = select(14, UnitAura(target, name, "", "HARMFUL")) - if not value then - value = select(14, UnitAura(target, name, "", "HELPFUL")) + local value = 0 + local aura = getAura(getTarget(condition.target), condition[1], getMine(condition)) + if aura then + value = aura.value or 0 end - value = value or 0 return compare(value, condition[2], condition[3]) end OvaleCondition.auraConditions.tickvalue = true -- 1.7.9.5