Quantcast

Added CritChance and LastSpellCritChance conditions, needed by new SimulationCraft imports

Sidoine De Wispelaere [06-02-13 - 14:44]
Added CritChance and LastSpellCritChance conditions, needed by new SimulationCraft imports

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@929 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleCondition.lua
OvaleFuture.lua
diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index 2a21bd6..803dde5 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -1042,6 +1042,19 @@ OvaleCondition.conditions.creaturetype = function(condition)
 	return nil
 end

+--- Get the current critical strike chance of the player.
+-- @name CritChance
+-- @paramsig number or boolean
+-- @param operator Optional. Comparison operator: equal, less, more.
+-- @param number Optional. The number to compare against.
+-- @return The current critical strike chance (in percent).
+-- @return A boolean value for the result of the comparison.
+-- @usage
+-- if CritChance() >30 Spell(immolate)
+OvaleCondition.conditions.critchance = function(condition)
+	return Compare(OvalePaperDoll.spellCrit, condition[1], condition[2])
+end
+
 --- Get the current estimated damage of a spell if it is a critical strike.
 -- @name CritDamage
 -- @paramsig number
@@ -1833,6 +1846,23 @@ OvaleCondition.conditions.lastspellcombopoints = function(condition)
 	return Compare(OvaleFuture:GetLastComboPoints(condition[1]), condition[2], condition[3])
 end

+--- Get the critical strike chance of the player during the most recent cast of a spell.
+-- @name LastSpellCritChance
+-- @paramsig number or boolean
+-- @param id The spell ID.
+-- @param operator Optional. Comparison operator: equal, less, more.
+-- @param number Optional. The number to compare against.
+-- @return The previous mastery effect.
+-- @return A boolean value for the result of the comparison.
+-- @see Mastery
+-- @usage
+-- if {CritChance(shadow_bolt) - LastSpellCritChance(shadow_bolt)} > 1000
+--     Spell(metamorphosis)
+
+OvaleCondition.conditions.lastspellcritchance = function(condition)
+	return Compare(OvaleFuture:GetLastCritChance(condition[1]), condition[2], condition[3])
+end
+
 --- Get the mastery effect of the player during the most recent cast of a spell.
 -- Mastery effect is the effect of the player's mastery, typically a percent-increase to damage
 -- or a percent-increase to chance to trigger some effect.
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index 2bacd79..f6d7a79 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -51,6 +51,7 @@ local self_lastComboPoints = {}
 local self_lastDamageMultiplier = {}
 local self_lastMasteryEffect = {}
 local self_lastSpellpower = {}
+local self_lastCritChance = {}

 -- These CLEU events are eventually received after a successful spellcast.
 local OVALE_CLEU_SPELLCAST_RESULTS = {
@@ -118,6 +119,7 @@ local function AddSpellToQueue(spellId, lineId, startTime, endTime, channeled, a
 	self.lastSpellId = spellId
 	self_lastAttackPower[spellId] = OvalePaperDoll.attackPower
 	self_lastSpellpower[spellId] = OvalePaperDoll.spellBonusDamage
+	self_lastCritChance[spellId] = OvalePaperDoll.spellCrit
 	self_lastDamageMultiplier[spellId] = OvaleAura:GetDamageMultiplier(spellId)
 	self_lastMasteryEffect[spellId] = OvalePaperDoll.masteryEffect
 	tinsert(self_activeSpellcast, spellcast)
@@ -405,6 +407,10 @@ function OvaleFuture:GetLastSpellpower(spellId)
 	return self_lastSpellpower[spellId] or 0
 end

+function OvaleFuture:GetLastCritChance(spellId)
+	return self_lastCritChance[spellId] or 0
+end
+
 function OvaleFuture:InFlight(spellId)
 	for _, spellcast in ipairs(self_activeSpellcast) do
 		if spellcast.spellId == spellId then