Quantcast

Snapshot a DoT's damage multiplier when it is applied or refreshed.

Johnny C. Lam [07-07-13 - 04:43]
Snapshot a DoT's damage multiplier when it is applied or refreshed.

git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@944 d5049fe3-3747-40f7-a4b5-f36d6801af5f
Filename
OvaleAura.lua
OvaleCondition.lua
OvaleFuture.lua
OvalePaperDoll.lua
OvaleState.lua
diff --git a/OvaleAura.lua b/OvaleAura.lua
index 0b5f421..7e310ad 100644
--- a/OvaleAura.lua
+++ b/OvaleAura.lua
@@ -101,6 +101,7 @@ local OVALE_CLEU_TICK_EVENTS = {

 --<private-static-methods>
 local function UnitGainedAura(event, guid, spellId, filter, casterGUID, icon, count, debuffType, duration, expirationTime, isStealable, name, value)
+	local self = OvaleAura
 	if not self_aura[guid][filter] then
 		self_aura[guid][filter] = {}
 	end
@@ -164,6 +165,7 @@ local function UnitGainedAura(event, guid, spellId, filter, casterGUID, icon, co
 				aura.ticksSeen = 0
 				aura.tick = OvaleData:GetTickLength(spellId)
 				OvalePaperDoll:SnapshotStats(aura.gain, aura)
+				aura.damageMultiplier = self:GetDamageMultiplier(spellId)
 			end
 		end
 	end
diff --git a/OvaleCondition.lua b/OvaleCondition.lua
index 13dd3da..795f49f 100644
--- a/OvaleCondition.lua
+++ b/OvaleCondition.lua
@@ -602,6 +602,29 @@ OvaleCondition.conditions.buffrangedattackpower = function(condition)
 end
 OvaleCondition.conditions.debuffrangedattackpower = OvaleCondition.conditions.buffrangedattackpower

+--- Get the player's damage multiplier for the given aura at the time the aura was applied on the target.
+-- @name BuffDamageMultiplier
+-- @paramsig number
+-- @param id The aura spell ID.
+-- @param target Optional. Sets the target to check. The target may also be given as a prefix to the condition.
+--     Defaults to target=player.
+--     Valid values: player, target, focus, pet.
+-- @return The damage multiplier.
+-- @usage
+-- if target.DebuffDamageMultiplier(rake) <1 Spell(rake)
+
+OvaleCondition.conditions.buffdamagemultiplier = function(condition)
+	self_auraFound.damageMultiplier = nil
+	local start, ending = GetAura(condition, self_auraFound)
+	local damageMultiplier = self_auraFound.damageMultiplier
+	if start and ending and start <= ending then
+		return start, ending, damageMultiplier, start, 0
+	else
+		return 0, nil, 0, 0, 0
+	end
+end
+OvaleCondition.conditions.debuffdamagemultiplier = OvaleCondition.conditions.buffdamagemultiplier
+
 --- Get the player's melee critical strike chance at the time the given aura was applied on the target.
 -- @name BuffMeleeCritChance
 -- @paramsig number
diff --git a/OvaleFuture.lua b/OvaleFuture.lua
index 8e47957..a325ad1 100644
--- a/OvaleFuture.lua
+++ b/OvaleFuture.lua
@@ -295,6 +295,7 @@ function OvaleFuture:UNIT_SPELLCAST_SENT(event, unit, spell, rank, target, lineI
 				spellcast.target = targetGUID
 				-- Update spellcast stats to the latest snapshot of the player's stats.
 				OvalePaperDoll:SnapshotStats(Ovale.now, spellcast)
+				spellcast.damageMultiplier = OvaleAura:GetDamageMultiplier(spellId)
 			end
 		end
 		self_sentSpellcast[lineId] = Ovale.now
diff --git a/OvalePaperDoll.lua b/OvalePaperDoll.lua
index 4871a96..6acb516 100644
--- a/OvalePaperDoll.lua
+++ b/OvalePaperDoll.lua
@@ -243,6 +243,8 @@ function OvalePaperDoll:SnapshotStats(timestamp, t, source)
 		for k in pairs(self.stat) do
 			t[k] = source[k]
 		end
+		-- Also snapshot damageMultiplier if it's present (added by OvaleFuture and OvaleAura).
+		t.damageMultiplier = source.damageMultiplier
 	end
 end

diff --git a/OvaleState.lua b/OvaleState.lua
index ac472e4..1a1f1f3 100644
--- a/OvaleState.lua
+++ b/OvaleState.lua
@@ -461,6 +461,7 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ
 										newAura.tick = OvaleData:GetTickLength(auraSpellId)
 										-- Re-snapshot stats for the DoT.
 										OvalePaperDoll:SnapshotStats(newAura.start, newAura, stats)
+										newAura.damageMultiplier = self:GetDamageMultiplier(auraSpellId)
 									else
 										newAura.ending = endCast + duration
 									end
@@ -485,6 +486,7 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ
 								if isDoT then
 									newAura.tick = OvaleData:GetTickLength(auraSpellId)
 									OvalePaperDoll:SnapshotStats(newAura.start, newAura, stats)
+									newAura.damageMultiplier = self:GetDamageMultiplier(auraSpellId)
 								end
 							end
 						end