Quantcast

Fix buff conditions by checking that an aura is active.

Johnny C. Lam [04-25-14 - 20:56]
Fix buff conditions by checking that an aura is active.

Active auras have their properties returned with a time span of (0, inf)
and inactive auras fall through to the default value of zero.

This partly backs out r1252 and re-implements using broader time spans to
avoid problems with comparisons.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1321 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
conditions/BuffAmount.lua
conditions/BuffComboPoints.lua
conditions/BuffDamageMultiplier.lua
conditions/BuffDuration.lua
conditions/BuffRemains.lua
conditions/BuffSnapshot.lua
conditions/BuffStacks.lua
conditions/RuneOfPowerRemains.lua
conditions/TickTime.lua
conditions/TicksRemain.lua
diff --git a/conditions/BuffAmount.lua b/conditions/BuffAmount.lua
index 4a61f88..6ca4963 100644
--- a/conditions/BuffAmount.lua
+++ b/conditions/BuffAmount.lua
@@ -54,10 +54,10 @@ do
 			statName = "value3"
 		end
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura then
+		if state:IsActiveAura(aura) then
 			local start, ending = aura.start, aura.ending
 			local value = aura[statName] or 0
-			return TestValue(start, ending, value, start, 0, comparator, limit)
+			return TestValue(0, math.huge, value, start, 0, comparator, limit)
 		end
 		return Compare(0, comparator, limit)
 	end
diff --git a/conditions/BuffComboPoints.lua b/conditions/BuffComboPoints.lua
index 2d815e0..b888be9 100644
--- a/conditions/BuffComboPoints.lua
+++ b/conditions/BuffComboPoints.lua
@@ -37,10 +37,10 @@ do
 		local auraId, comparator, limit = condition[1], condition[2], condition[3]
 		local target, filter, mine = ParseCondition(condition)
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura then
+		if state:IsActiveAura(aura) then
 			local start, ending = aura.start, aura.ending
 			local value = aura and aura.combo or 0
-			return TestValue(start, ending, value, start, 0, comparator, limit)
+			return TestValue(0, math.huge, value, start, 0, comparator, limit)
 		end
 		return Compare(0, comparator, limit)
 	end
diff --git a/conditions/BuffDamageMultiplier.lua b/conditions/BuffDamageMultiplier.lua
index e7c27c8..e9c4af6 100644
--- a/conditions/BuffDamageMultiplier.lua
+++ b/conditions/BuffDamageMultiplier.lua
@@ -37,12 +37,12 @@ do
 		local auraId, comparator, limit = condition[1], condition[2], condition[3]
 		local target, filter, mine = ParseCondition(condition)
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura then
+		if state:IsActiveAura(aura) then
 			local start, ending = aura.start, aura.ending
 			local baseDamageMultiplier = aura.snapshot and aura.snapshot.baseDamageMultiplier or 1
 			local damageMultiplier = aura.damageMultiplier or 1
 			local value = baseDamageMultiplier * damageMultiplier
-			return TestValue(start, ending, value, start, 0, comparator, limit)
+			return TestValue(0, math.huge, value, start, 0, comparator, limit)
 		end
 		return Compare(1, comparator, limit)
 	end
diff --git a/conditions/BuffDuration.lua b/conditions/BuffDuration.lua
index 870ac5c..e867318 100644
--- a/conditions/BuffDuration.lua
+++ b/conditions/BuffDuration.lua
@@ -35,10 +35,10 @@ do
 		local auraId, comparator, limit = condition[1], condition[2], condition[3]
 		local target, filter, mine = ParseCondition(condition)
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura then
+		if state:IsActiveAura(aura) then
 			local start, ending = aura.start, aura.ending
 			local value = ending - start
-			return TestValue(start, ending, value, start, 0, comparator, limit)
+			return TestValue(0, math.huge, value, start, 0, comparator, limit)
 		end
 		return Compare(0, comparator, limit)
 	end
diff --git a/conditions/BuffRemains.lua b/conditions/BuffRemains.lua
index d6ae93e..048272d 100644
--- a/conditions/BuffRemains.lua
+++ b/conditions/BuffRemains.lua
@@ -41,9 +41,9 @@ do
 		local auraId, comparator, limit = condition[1], condition[2], condition[3]
 		local target, filter, mine = ParseCondition(condition)
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura then
+		if state:IsActiveAura(aura) then
 			local start, ending = aura.start, aura.ending
-			return TestValue(start, ending, ending - start, start, -1, comparator, limit)
+			return TestValue(0, math.huge, ending - start, start, -1, comparator, limit)
 		end
 		return Compare(0, comparator, limit)
 	end
diff --git a/conditions/BuffSnapshot.lua b/conditions/BuffSnapshot.lua
index 0322d39..83b9254 100644
--- a/conditions/BuffSnapshot.lua
+++ b/conditions/BuffSnapshot.lua
@@ -23,10 +23,10 @@ do
 		local auraId, comparator, limit = condition[1], condition[2], condition[3]
 		local target, filter, mine = ParseCondition(condition)
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura then
-			local start, ending = aura.start, aura.ending
+		if state:IsActiveAura(aura) then
+			local start = aura.start
 			local value = aura.snapshot and aura.snapshot[statName] or defaultValue
-			return TestValue(start, ending, value, start, 0, comparator, limit)
+			return TestValue(0, math.huge, value, start, 0, comparator, limit)
 		end
 		return Compare(defaultValue, comparator, limit)
 	end
@@ -36,13 +36,13 @@ do
 		local auraId, comparator, limit = condition[1], condition[2], condition[3]
 		local target, filter, mine = ParseCondition(condition)
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura then
+		if state:IsActiveAura(aura) then
 			local start, ending = aura.start, aura.ending
 			local value = aura.snapshot and aura.snapshot[statName] or defaultValue
 			if condition.unlimited ~= 1 and value > 100 then
 				value = 100
 			end
-			return TestValue(start, ending, value, start, 0, comparator, limit)
+			return TestValue(0, math.huge, value, start, 0, comparator, limit)
 		end
 		return Compare(defaultValue, comparator, limit)
 	end
diff --git a/conditions/BuffStacks.lua b/conditions/BuffStacks.lua
index e813d92..2449351 100644
--- a/conditions/BuffStacks.lua
+++ b/conditions/BuffStacks.lua
@@ -43,10 +43,10 @@ do
 		local auraId, comparator, limit = condition[1], condition[2], condition[3]
 		local target, filter, mine = ParseCondition(condition)
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura then
+		if state:IsActiveAura(aura) then
 			local start, ending = aura.start, aura.ending
 			local value = aura.stacks or 0
-			return TestValue(start, ending, value, start, 0, comparator, limit)
+			return TestValue(0, math.huge, value, start, 0, comparator, limit)
 		end
 		return Compare(0, comparator, limit)
 	end
diff --git a/conditions/RuneOfPowerRemains.lua b/conditions/RuneOfPowerRemains.lua
index ffb078d..abc9f1c 100644
--- a/conditions/RuneOfPowerRemains.lua
+++ b/conditions/RuneOfPowerRemains.lua
@@ -35,7 +35,7 @@ do
 	local function RuneOfPowerRemains(condition)
 		local comparator, limit = condition[1], condition[2]
 		local aura = state:GetAura("player", RUNE_OF_POWER_BUFF, "HELPFUL")
-		if aura then
+		if state:IsActiveAura(aura) then
 			local start, ending
 			for totemSlot = 1, 2 do
 				local haveTotem, name, startTime, duration = API_GetTotemInfo(totemSlot)
@@ -45,7 +45,7 @@ do
 				end
 			end
 			if start then
-				return TestValue(start, ending, ending - start, start, -1, comparator, limit)
+				return TestValue(0, math.huge, ending - start, start, -1, comparator, limit)
 			end
 		end
 		return Compare(0, comparator, limit)
diff --git a/conditions/TickTime.lua b/conditions/TickTime.lua
index 5b09fe5..5bfd6be 100644
--- a/conditions/TickTime.lua
+++ b/conditions/TickTime.lua
@@ -38,7 +38,7 @@ do
 		local auraId, comparator, limit = condition[1], condition[2], condition[3]
 		local target, filter, mine = ParseCondition(condition)
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura and aura.tick then
+		if state:IsActiveAura(aura) and aura.tick then
 			local value = aura.tick
 			return Compare(value, comparator, limit)
 		end
diff --git a/conditions/TicksRemain.lua b/conditions/TicksRemain.lua
index d5e024c..e8750f3 100644
--- a/conditions/TicksRemain.lua
+++ b/conditions/TicksRemain.lua
@@ -42,10 +42,10 @@ do
 		local auraId, comparator, limit = condition[1], condition[2], condition[3]
 		local target, filter, mine = ParseCondition(condition)
 		local aura = state:GetAura(target, auraId, filter, mine)
-		if aura then
+		if state:IsActiveAura(aura) then
 			local start, ending, tick = aura.start, aura.ending, aura.tick
 			if tick and tick > 0 then
-				return TestValue(start, ending, 1, ending, -1/tick, comparator, limit)
+				return TestValue(0, math.huge, 1, ending, -1/tick, comparator, limit)
 			end
 		end
 		return Compare(0, comparator, limit)