Quantcast

Be more accurate when computing CritDamage().

Johnny C. Lam [04-30-14 - 18:35]
Be more accurate when computing CritDamage().

Factor in the increased crit effect from any meta gems and also the effect
of the MoP amplification trinkets.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1346 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
conditions/Damage.lua
diff --git a/conditions/Damage.lua b/conditions/Damage.lua
index fe8fc01..56c2a54 100644
--- a/conditions/Damage.lua
+++ b/conditions/Damage.lua
@@ -12,6 +12,7 @@ local _, Ovale = ...
 do
 	local OvaleCondition = Ovale.OvaleCondition
 	local OvaleData = Ovale.OvaleData
+	local OvaleEquipement = Ovale.OvaleEquipement
 	local OvaleState = Ovale.OvaleState

 	local Compare = OvaleCondition.Compare
@@ -62,6 +63,59 @@ do
 	-- @return A boolean value for the result of the comparison.
 	-- @see Damage, LastDamage, LastEstimatedDamage

+	local INCREASED_CRIT_META_GEM = {
+		[52291] = 1.03,
+		[52297] = 1.03,
+		[68778] = 1.03,
+		[68779] = 1.03,
+		[68780] = 1.03,
+		[76884] = 1.03,
+		[76885] = 1.03,
+		[76886] = 1.03,
+		[76888] = 1.03,
+	}
+	local AMPLIFICATION_TRINKET = {
+		[102293] = true,
+		[102299] = true,
+		[102305] = true,
+		[104426] = true,
+		[104478] = true,
+		[104613] = true,
+		[104675] = true,
+		[104727] = true,
+		[104862] = true,
+		[104924] = true,
+		[104976] = true,
+		[105111] = true,
+		[105173] = true,
+		[105225] = true,
+		[105360] = true,
+		[105422] = true,
+		[105474] = true,
+		[105609] = true,
+	}
+	local AMPLIFICATION_TRINKET_EFFECT = {
+		[528] = 0.0555,
+		[532] = 0.0576,
+		[536] = 0.0598,
+		[540] = 0.062,
+		[544] = 0.0644,
+		[548] = 0.0668,
+		[553] = 0.07,
+		[557] = 0.0727,
+		[559] = 0.074,
+		[561] = 0.0754,
+		[563] = 0.0769,
+		[566] = 0.079,
+		[567] = 0.0798,
+		[570] = 0.082,
+		[572] = 0.0836,
+		[574] = 0.0852,
+		[576] = 0.0867,
+		[580] = 0.09,
+	}
+	local TRINKET_SLOTS = { INVSLOT_TRINKET1, INVSLOT_TRINKET2 }
+
 	local function CritDamage(condition)
 		local spellId, comparator, limit = condition[1], condition[2], condition[3]
 		local target = ParseCondition(condition, "target")
@@ -74,9 +128,25 @@ do
 		if si and si.physical then
 			value = value * (1 - BossArmorDamageReduction(target))
 		end
-		-- TODO: Need to account for increased crit effect from meta-gems.
-		local critFactor = 2
-		local value = critFactor * value
+
+		-- Default crit damage is 2 times normal damage.
+		local critMultiplier = 2
+		-- Add additional critical strike damage from MoP amplification trinkets.
+		for _, slotId in pairs(TRINKET_SLOTS) do
+			local trinket = OvaleEquipement:GetEquippedItem(slotId)
+			local trinketItemLevel = OvaleEquipement:GetEquippedItemLevel(slotId)
+			local amplificationEffect = 0
+			if AMPLIFICATION_TRINKET[trinket] then
+				amplificationEffect = AMPLIFICATION_TRINKET_EFFECT[trinketItemLevel] or 0
+			end
+			critMultiplier = critMultiplier + amplificationEffect
+		end
+		-- Multiply by increased crit effect from the meta gem.
+		local metaGem = OvaleEquipement.metaGem
+		local increasedMetaGemCritEffect = metaGem and INCREASED_CRIT_META_GEM[metaGem] or 1
+		critMultiplier = critMultiplier * increasedMetaGemCritEffect
+
+		local value = critMultiplier * value
 		return Compare(value, comparator, limit)
 	end