Quantcast

Use Blizzard API to get the damage multiplier.

Johnny C. Lam [07-12-13 - 07:44]
Use Blizzard API to get the damage multiplier.

The damage multiplier numbers aren't accurate from just scanning buffs
because the tooltips aren't accurate.  For example, Savage Roar's tooltip
says 30% increase but it's actually 40% increase, and the Fluidity buff in
the Jin'Rohk encounter says 40% increase but in LFR it's actually 96%
increase.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@961 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleAura.lua
OvaleData.lua
OvalePaperDoll.lua
OvaleState.lua
diff --git a/OvaleAura.lua b/OvaleAura.lua
index 7e310ad..32aea8f 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -565,15 +565,7 @@ end

 function OvaleAura:GetDamageMultiplier(spellId)
 	-- Calculate the base damage multiplier for all spells.
-	local damageMultiplier = 1
-	for auraSpellId, multiplier in pairs(OvaleData.selfDamageBuff) do
-		local count = select(3, self:GetAuraByGUID(self_player_guid, auraSpellId, filter, nil, "player"))
-		if count and count > 0 then
-			-- Try to account for a stacking aura.
-			-- multiplier = 1 + (multiplier - 1) * count
-			damageMultiplier = damageMultiplier * multiplier
-		end
-	end
+	local damageMultiplier = OvalePaperDoll.stat.damageMultiplier

 	-- Factor in the spell-specific multipliers from SpellDamage{Buff,Debuff} declarations.
 	if spellId then
diff --git a/OvaleData.lua b/OvaleData.lua
index 0b0e76c..6aa2898 100644
--- a/OvaleData.lua
+++ b/OvaleData.lua
@@ -85,22 +85,6 @@ OvaleData.power =
 OvaleData.secondaryPower = {"rage", "focus", "shards", "holy", "chi", "shadoworbs", "burningembers", "demonicfury"}
 OvaleData.powerType = {}

--- List temporary damage multiplier
-OvaleData.selfDamageBuff =
-{
-	[5217] = 1.15, -- Tiger's Fury (druid)
-	[31665] = 1.1, -- Master of Subtlety (rogue)
-	[52610] = 1.4, -- Savage Roar, glyphed (druid)
-	[57933] = 1.15, -- Tricks of the Trade (rogue)
-	[84745] = 1.1, -- Shallow Insight (rogue)
-	[84746] = 1.2, -- Moderate Insight (rogue)
-	[84747] = 1.3, -- Deep Insight (rogue)
-	[124974] = 1.1, -- Nature's Vigil (druid)
-	[127538] = 1.4, -- Savage Roar (druid)
-	[138002] = 1.4, -- Fluidity (Throne of Thunder, Jin'rokh encounter)
-	[140741] = 2.0, -- Primal Nutriment (Throne of Thunder, Ji-Kun encounter)
-}
-
 OvaleData.buffSpellList =
 {
 	-- Debuffs
diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua
index 0b4903e..dc0cbe9 100644
--- a/OvalePaperDoll.lua
+++ b/OvalePaperDoll.lua
@@ -100,6 +100,8 @@ OvalePaperDoll.stat = {
 	-- average weapon damage of mainhand and offhand weapons
 	mainHandWeaponDamage = 0,
 	offHandWeaponDamage = 0,
+	-- damage multiplier
+	damageMultiplier = 1,
 }
 --</public-static-properties>

@@ -115,12 +117,14 @@ function OvalePaperDoll:OnEnable()
 	self:RegisterEvent("PLAYER_TALENT_UPDATE", "UpdateStats")
 	self:RegisterEvent("SPELL_POWER_CHANGED")
 	self:RegisterEvent("UNIT_ATTACK_POWER")
+	self:RegisterEvent("UNIT_AURA", "UpdateDamageMultiplier")
 	self:RegisterEvent("UNIT_LEVEL")
 	self:RegisterEvent("UNIT_RANGEDDAMAGE")
 	self:RegisterEvent("UNIT_RANGED_ATTACK_POWER")
 	self:RegisterEvent("UNIT_SPELL_HASTE")
 	self:RegisterEvent("UNIT_STATS")
 	self:RegisterMessage("Ovale_EquipmentChanged")
+	self:RegisterMessage("Ovale_StanceChanged", "UpdateDamageMultiplier")
 end

 function OvalePaperDoll:OnDisable()
@@ -134,12 +138,14 @@ function OvalePaperDoll:OnDisable()
 	self:UnregisterEvent("PLAYER_TALENT_UPDATE")
 	self:UnregisterEvent("SPELL_POWER_CHANGED")
 	self:UnregisterEvent("UNIT_ATTACK_POWER")
+	self:UnregisterEvent("UNIT_AURA")
 	self:UnregisterEvent("UNIT_LEVEL")
 	self:UnregisterEvent("UNIT_RANGEDDAMAGE")
 	self:UnregisterEvent("UNIT_RANGED_ATTACK_POWER")
 	self:UnregisterEvent("UNIT_SPELL_HASTE")
 	self:UnregisterEvent("UNIT_STATS")
 	self:UnregisterMessage("Ovale_EquipmentChanged")
+	self:UnregisterMessage("Ovale_StanceChanged")
 end

 function OvalePaperDoll:COMBAT_RATING_UPDATE(event)
@@ -225,6 +231,11 @@ function OvalePaperDoll:Ovale_EquipmentChanged(event)
 	end
 end

+function OvalePaperDoll:UpdateDamageMultiplier(event)
+	self.stat.damageMultiplier = select(7, API_UnitDamage("player"))
+	self.stat.snapshotTime = Ovale.now
+end
+
 function OvalePaperDoll:UpdateStats(event)
 	self.specialization = API_GetSpecialization()
 	self:COMBAT_RATING_UPDATE(event)
@@ -236,6 +247,7 @@ function OvalePaperDoll:UpdateStats(event)
 	self:UNIT_RANGED_ATTACK_POWER(event, "player")
 	self:UNIT_SPELL_HASTE(event, "player")
 	self:UNIT_STATS(event, "player")
+	self:UpdateDamageMultiplier(event)
 	self:Ovale_EquipmentChanged(event)
 end

@@ -289,6 +301,7 @@ function OvalePaperDoll:Debug()
 	Ovale:FormatPrint("Ranged critical strike effect: %f%%", self.stat.rangedCrit)
 	Ovale:FormatPrint("Ranged haste effect: %f%%", self.stat.rangedHaste)
 	Ovale:FormatPrint("Mastery effect: %f%%", self.stat.masteryEffect)
+	Ovale:FormatPrint("Damage multiplier: %f", self.stat.damageMultiplier)
 	Ovale:FormatPrint("Weapon damage (mainhand): %f", self.stat.mainHandWeaponDamage)
 	Ovale:FormatPrint("Weapon damage (offhand): %f", self.stat.offHandWeaponDamage)
 end
diff --git a/OvaleState.lua b/OvaleState.lua
index 1a1f1f3..c79e2d6 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -38,7 +38,6 @@ local API_UnitPower = UnitPower
 local API_UnitPowerMax = UnitPowerMax
 local MAX_COMBO_POINTS = MAX_COMBO_POINTS

-local self_damageMultiplier = 1
 local self_runes = {}
 local self_runesCD = {}

@@ -191,19 +190,6 @@ function OvaleState:Reset()
 	for k,v in pairs(self.state.counter) do
 		self.state.counter[k] = OvaleFuture.counter[k]
 	end
-
-	-- Calculate the base damage multiplier for all spells.
-	self_damageMultiplier = 1
-	local playerGUID = OvaleGUID:GetGUID("player")
-	local count
-	for auraSpellId, multiplier in pairs(OvaleData.selfDamageBuff) do
-		count = select(3, self:GetAuraByGUID(playerGUID, auraSpellId, filter, nil, "player"))
-		if count and count > 0 then
-			-- Try to account for a stacking aura.
-			multiplier = 1 + (multiplier - 1) * count
-			self_damageMultiplier = self_damageMultiplier * multiplier
-		end
-	end
 end

 -- Apply the effects of spells that are being cast or are in flight, allowing us to
@@ -669,7 +655,7 @@ function OvaleState:NewAura(guid, spellId, filter)
 end

 function OvaleState:GetDamageMultiplier(spellId)
-	local damageMultiplier = self_damageMultiplier
+	local damageMultiplier = OvalePaperDoll.stat.damageMultiplier
 	if spellId then
 		local si = OvaleData.spellInfo[spellId]
 		if si and si.damageAura then