Quantcast

Fix ticket 302 noting inconsistent return value for SpellCooldown().

Johnny C. Lam [10-19-13 - 17:24]
Fix ticket 302 noting inconsistent return value for SpellCooldown().

Modify SpellCooldown to have constant value of 0 if the spell is off of
cooldown.  This matches natural expectations for how to use this script
condition.

Make similar changes to other cooldown conditions.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1084 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCondition.lua
diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index 4acb61a..31975d8 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -1224,7 +1224,7 @@ end

 OvaleCondition.conditions.charges = function(condition)
 	local spellId, comparator, limit = condition[1], condition[2], condition[3]
-	local currentCharges, maxCharges, timeLastCast, cooldownDuration = API_GetSpellCharges(spellId)
+	local currentCharges = API_GetSpellCharges(spellId)
 	return Compare(currentCharges, comparator, limit)
 end

@@ -2046,8 +2046,12 @@ end

 OvaleCondition.conditions.itemcooldown = function(condition)
 	local itemId, comparator, limit = condition[1], condition[2], condition[3]
-	local actionCooldownStart, actionCooldownDuration, actionEnable = API_GetItemCooldown(itemId)
-	return TestValue(comparator, limit, actionCooldownDuration, actionCooldownStart, -1)
+	local start, duration = API_GetItemCooldown(itemId)
+	if start + duration > OvaleState.currentTime then
+		return TestOvaleValue(start, start + duration, duration, start, -1, comparator, limit)
+	else
+		return Compare(0, comparator, limit)
+	end
 end

 --- Get the current number of the given item in the player's inventory.
@@ -3549,7 +3553,11 @@ OvaleCondition.conditions.spellcooldown = function(condition)
 	else
 		start, duration = OvaleState:GetComputedSpellCD(spellId)
 	end
-	return TestOvaleValue(start, start + duration, duration, start, -1, comparator, limit)
+	if start + duration > OvaleState.currentTime then
+		return TestOvaleValue(start, start + duration, duration, start, -1, comparator, limit)
+	else
+		return Compare(0, comparator, limit)
+	end
 end
 -- OvaleCondition.spellbookConditions.spellcooldown = true / may be a sharedcd