From 4db385b165d524a7d28192121f104954957a38b2 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Tue, 15 Oct 2013 01:26:32 +0000 Subject: [PATCH] Fix ticket 299 - BuffAmount() Add a new condition BuffAmount that returns one of the three values associated with a unit aura (see UnitAura documentation for more details). Make existing TickValue into an alias for BuffAmount as they are basically identical. Implementation from @ShmooDude. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1061 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleAura.lua | 6 ++-- OvaleCondition.lua | 88 ++++++++++++++++++++++++++++++++++++---------------- 2 files changed, 64 insertions(+), 30 deletions(-) diff --git a/OvaleAura.lua b/OvaleAura.lua index 6cfb176..ed3b4bd 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -74,7 +74,7 @@ local OVALE_CLEU_TICK_EVENTS = { -- -- -local function UnitGainedAura(guid, spellId, filter, casterGUID, icon, count, debuffType, duration, expirationTime, isStealable, name, value) +local function UnitGainedAura(guid, spellId, filter, casterGUID, icon, count, debuffType, duration, expirationTime, isStealable, name, value1, value2, value3) local self = OvaleAura if not self_aura[guid][filter] then self_aura[guid][filter] = {} @@ -130,7 +130,7 @@ local function UnitGainedAura(guid, spellId, filter, casterGUID, icon, count, de aura.mine = mine aura.source = casterGUID aura.name = name - aura.value = value + aura.value1, aura.value2, aura.value3 = value1, value2, value3 -- Snapshot stats for DoTs. if mine then @@ -263,7 +263,7 @@ local function ScanUnitAuras(unitId, guid) end else local casterGUID = OvaleGUID:GetGUID(unitCaster) - local added = UnitGainedAura(guid, spellId, filter, casterGUID, icon, count, debuffType, duration, expirationTime, isStealable, name, value1) + local added = UnitGainedAura(guid, spellId, filter, casterGUID, icon, count, debuffType, duration, expirationTime, isStealable, name, value1, value2, value3) if added then Ovale.refreshNeeded[unitId] = true end diff --git a/OvaleCondition.lua b/OvaleCondition.lua index 4822348..c127805 100644 --- a/OvaleCondition.lua +++ b/OvaleCondition.lua @@ -518,6 +518,67 @@ OvaleCondition.conditions.armorsetparts = function(condition) return Compare(OvaleEquipement:GetArmorSetCount(condition[1]), comparator, limit) end +--- Get the current tick value of a periodic aura on the target. +-- @name TickValue +-- @paramsig number or boolean +-- @param id The spell ID of the aura or the name of a spell list. +-- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more. +-- @param number Optional. The number to compare against. +-- @param filter Optional. The type of aura to check. +-- Default is any. +-- Valid values: any, buff, debuff +-- @param target Optional. Sets the target to check. The target may also be given as a prefix to the condition. +-- Defaults to target=player. +-- Valid values: player, target, focus, pet. +-- @return The tick value. +-- @return A boolean value for the result of the comparison. +-- @see TicksRemain +-- @usage +-- if DebuffRemains(light_stagger) >0 and TickValue(light_stagger) >10000 +-- Spell(purifying_brew) + +--- Get the value of a buff as a number. Not all buffs return an amount. +-- @name BuffAmount +-- @paramsig number +-- @param id The spell ID of the aura or the name of a spell list. +-- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more. +-- @param number Optional. The number to compare against. +-- @param target Optional. Sets the target to check. The target may also be given as a prefix to the condition. +-- Defaults to target=player. +-- Valid values: player, target, focus, pet. +-- @param any Optional. Sets by whom the aura was applied. If the aura can be applied by anyone, then set any=1. +-- Defaults to any=0. +-- Valid values: 0, 1. +-- @param value Optional. Sets which aura value to return from UnitAura(). +-- Defaults to value=1. +-- Valid values: 1, 2, 3. +-- @return The value of the buff as a number. +-- @see DebuffAmount +-- @see TickValue +-- @usage +-- if DebuffAmount(stagger) >10000 Spell(purifying_brew) +-- if DebuffAmount(stagger more 10000) Spell(purifying_brew) + +OvaleCondition.conditions.buffamount = function(condition) + self_auraFound.value1, self_auraFound.value2, self_auraFound.value3 = nil, nil, nil + local comparator, limit = condition[2], condition[3] + local start, ending = GetAura(condition, self_auraFound) + local value = condition.value or 1 + local amount + if value == 1 then + amount = self_auraFound.value1 or 0 + elseif value == 2 then + amount = self_auraFound.value2 or 0 + elseif value == 3 then + amount = self_auraFound.value3 or 0 + else + amount = 0 + end + return Compare(amount, comparator, limit) +end +OvaleCondition.conditions.debuffamount = OvaleCondition.conditions.buffamount +OvaleCondition.conditions.tickvalue = OvaleCondition.conditions.buffamount + --- Get the current attack power of the player. -- @name AttackPower -- @paramsig number or boolean @@ -3613,33 +3674,6 @@ OvaleCondition.conditions.threat = function(condition) return Compare(threatpct, comparator, limit) end ---- Get the current tick value of a periodic aura on the target. --- @name TickValue --- @paramsig number or boolean --- @param id The spell ID of the aura or the name of a spell list. --- @param operator Optional. Comparison operator: less, atMost, equal, atLeast, more. --- @param filter Optional. The type of aura to check. --- Default is any. --- Valid values: any, buff, debuff --- @param number Optional. The number to compare against. --- @param target Optional. Sets the target to check. The target may also be given as a prefix to the condition. --- Defaults to target=player. --- Valid values: player, target, focus, pet. --- @return The tick value. --- @return A boolean value for the result of the comparison. --- @see TicksRemain --- @usage --- if DebuffRemains(light_stagger) >0 and TickValue(light_stagger) >10000 --- Spell(purifying_brew) - -OvaleCondition.conditions.tickvalue = function(condition) - self_auraFound.value = nil - local comparator, limit = condition[2], condition[3] - local start, ending = GetAura(condition, self_auraFound) - local value = self_auraFound.value or 0 - return Compare(value, comparator, limit) -end - --- Get the total number of ticks of a periodic aura. -- @name Ticks -- @paramsig number or boolean -- 1.7.9.5