From 491e810a93ccfd3bc64529b65a6b8cc5f18ac879 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Thu, 8 May 2014 17:27:17 +0000 Subject: [PATCH] Add BuffStacksOnAny() condition for total stacks across all units. This can be used to track the number of stacks on an aura that can only be placed on a single target at a time. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1406 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleAura.lua | 14 ++++++++---- conditions/BuffCountOnAny.lua | 2 +- conditions/BuffRemainsOnAny.lua | 2 +- conditions/BuffStacksOnAny.lua | 48 +++++++++++++++++++++++++++++++++++++++ conditions/files.xml | 1 + 5 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 conditions/BuffStacksOnAny.lua diff --git a/OvaleAura.lua b/OvaleAura.lua index 74ad0c6..15077ce 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -1153,6 +1153,8 @@ end do -- The total count of the matched aura. local count + -- The total number of stacks of the matched aura. + local stacks -- The start and ending times of the first aura to expire that will change the total count. local startChangeCount, endingChangeCount -- The time interval over which count > 0. @@ -1160,6 +1162,7 @@ do local function CountMatchingActiveAura(aura) count = count + 1 + stacks = stacks + aura.stacks if aura.ending < endingChangeCount then startChangeCount, endingChangeCount = aura.gain, aura.ending end @@ -1172,14 +1175,15 @@ do end --[[ - Return the total count of the given aura across all units, the start/end times of - the first aura to expire that will change the total count, and the time interval - over which the count is more than 0. + Return the total count and stacks of the given aura across all units, the start/end times of + the first aura to expire that will change the total count, and the time interval over which + the count is more than 0. --]] statePrototype.AuraCount = function(state, auraId, filter, mine, minStacks) -- Initialize. minStacks = minStacks or 0 count = 0 + stacks = 0 startChangeCount, endingChangeCount = math.huge, math.huge startFirst, endingLast = math.huge, 0 @@ -1221,8 +1225,8 @@ do end end - Ovale:Logf("AuraCount(%d) is %s, %s, %s, %s, %s", auraId, count, startChangeCount, endingChangeCount, startFirst, endingLast) - return count, startChangeCount, endingChangeCount, startFirst, endingLast + Ovale:Logf("AuraCount(%d) is %s, %s, %s, %s, %s, %s", auraId, count, stacks, startChangeCount, endingChangeCount, startFirst, endingLast) + return count, stacks, startChangeCount, endingChangeCount, startFirst, endingLast end end -- diff --git a/conditions/BuffCountOnAny.lua b/conditions/BuffCountOnAny.lua index bee5e35..ec58267 100644 --- a/conditions/BuffCountOnAny.lua +++ b/conditions/BuffCountOnAny.lua @@ -38,7 +38,7 @@ do local auraId, comparator, limit = condition[1], condition[2], condition[3] local _, filter, mine = ParseCondition(condition) - local count, startChangeCount, endingChangeCount, startFirst, endingLast = state:AuraCount(auraId, filter, mine, condition.stacks) + local count, stacks, startChangeCount, endingChangeCount, startFirst, endingLast = state:AuraCount(auraId, filter, mine, condition.stacks) if count > 0 and startChangeCount < math.huge then local origin = startChangeCount local rate = -1 / (endingChangeCount - startChangeCount) diff --git a/conditions/BuffRemainsOnAny.lua b/conditions/BuffRemainsOnAny.lua index 6de1b6b..d50d5dc 100644 --- a/conditions/BuffRemainsOnAny.lua +++ b/conditions/BuffRemainsOnAny.lua @@ -38,7 +38,7 @@ do local auraId, comparator, limit = condition[1], condition[2], condition[3] local _, filter, mine = ParseCondition(condition) - local count, startChangeCount, endingChangeCount, startFirst, endingLast = state:AuraCount(auraId, filter, mine, condition.stacks) + local count, stacks, startChangeCount, endingChangeCount, startFirst, endingLast = state:AuraCount(auraId, filter, mine, condition.stacks) if count > 0 then local start, ending = startFirst, endingLast return TestValue(start, math.huge, 0, ending, -1, comparator, limit) diff --git a/conditions/BuffStacksOnAny.lua b/conditions/BuffStacksOnAny.lua new file mode 100644 index 0000000..b6da3ae --- /dev/null +++ b/conditions/BuffStacksOnAny.lua @@ -0,0 +1,48 @@ +--[[-------------------------------------------------------------------- + Ovale Spell Priority + Copyright (C) 2013, 2014 Johnny C. Lam + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License in the LICENSE + file accompanying this program. +--]]-------------------------------------------------------------------- + +local _, Ovale = ... + +do + local OvaleCondition = Ovale.OvaleCondition + local OvaleState = Ovale.OvaleState + + local Compare = OvaleCondition.Compare + local ParseCondition = OvaleCondition.ParseCondition + local TestValue = OvaleCondition.TestValue + local state = OvaleState.state + + --- Get the total number of stacks of the given aura across all targets. + -- @name BuffStacksOnAny + -- @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 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. + -- @return The total number of stacks. + -- @return A boolean value for the result of the comparison. + -- @see DebuffStacksOnAny + + local function BuffStacksOnAny(condition) + local auraId, comparator, limit = condition[1], condition[2], condition[3] + local _, filter, mine = ParseCondition(condition) + + local count, stacks, startChangeCount, endingChangeCount, startFirst, endingLast = state:AuraCount(auraId, filter, mine) + if count > 0 then + local start, ending = startFirst, endingChangeCount + return TestValue(start, ending, stacks, start, 0, comparator, limit) + end + return Compare(count, comparator, limit) + end + + OvaleCondition:RegisterCondition("buffstacksonany", false, BuffStacksOnAny) + OvaleCondition:RegisterCondition("debuffstacksonany", false, BuffStacksOnAny) +end diff --git a/conditions/files.xml b/conditions/files.xml index b6aadcb..59d627c 100644 --- a/conditions/files.xml +++ b/conditions/files.xml @@ -13,6 +13,7 @@