From b42ab1d1fab92124114559aeaa69bd92ebb0cb53 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Thu, 5 Dec 2013 08:19:27 +0000 Subject: [PATCH] Move all aura-related methods into OvaleAura and its state machine. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1239 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleAura.lua | 51 +++++++++++++++++++++++++++++++++-- OvaleData.lua | 84 --------------------------------------------------------- 2 files changed, 49 insertions(+), 86 deletions(-) diff --git a/OvaleAura.lua b/OvaleAura.lua index 2bdd753..eec5840 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -212,6 +212,24 @@ end local function IsWithinAuraLag(time1, time2) return (time1 - time2 < self_auraLag/1000) and (time2 - time1 < self_auraLag/1000) end + +local function GetTickLength(auraId, snapshot) + local tick = 3 + local si = OvaleData.spellInfo[auraId] + if si then + tick = si.tick or tick + local hasteMultiplier = 1 + if si.haste then + if si.haste == "spell" then + hasteMultiplier = OvalePaperDoll:GetSpellHasteMultiplier(snapshot) + elseif si.haste == "melee" then + hasteMultiplier = OvalePaperDoll:GetMeleeHasteMultiplier(snapshot) + end + tick = tick / hasteMultiplier + end + end + return tick +end -- -- @@ -274,7 +292,7 @@ function OvaleAura:COMBAT_LOG_EVENT_UNFILTERED(event, ...) -- This isn't a known periodic aura, but it's ticking so treat this as the first tick. local si = OvaleData.spellInfo[spellId] if si and si.tick then - tick = OvaleData:GetTickLength(spellId, aura.snapshot) + tick = GetTickLength(spellId, aura.snapshot) elseif bit_band(spellSchool, CLEU_SCHOOL_MASK_MAGIC) > 0 then tick = 3 / OvalePaperDoll:GetSpellHasteMultiplier(aura.snapshot) else @@ -426,7 +444,7 @@ function OvaleAura:GainedAuraOnGUID(guid, atTime, auraId, casterGUID, filter, ic -- Only set the initial tick information for new auras. if not auraIsActive then aura.ticksSeen = 0 - aura.tick = OvaleData:GetTickLength(auraId, aura.snapshot) + aura.tick = GetTickLength(auraId, aura.snapshot) end end end @@ -692,6 +710,35 @@ local function GetStateAuraOnGUID(state, guid, auraId, filter, mine) return auraFound end +-- Returns the raw duration, DoT duration, tick length, and number of ticks of an aura. +statePrototype.GetDuration = function(state, auraId, spellcast) + local snapshot, combo, holy + if spellcast then + snapshot, combo, holy = spellcast.snapshot, spellcast.combo, spellcast.holy + else + snapshot, combo, holy = state.snapshot, state.combo, state.holy + end + + local duration = math.huge + local tick = GetTickLength(auraId, snapshot) + + local si = OvaleData.spellInfo[auraId] + if si and si.duration then + duration = si.duration + if si.adddurationcp and combo then + duration = duration + si.adddurationcp * combo + end + if si.adddurationholy and holy then + duration = duration + si.adddurationholy * (holy - 1) + end + end + + local numTicks = floor(duration/tick + 0.5) + local dotDuration = tick * numTicks + + return duration, dotDuration, tick, numTicks +end + -- Print the auras matching the filter on the unit in alphabetical order. do local array = {} diff --git a/OvaleData.lua b/OvaleData.lua index 2c2ee4e..0874d3e 100644 --- a/OvaleData.lua +++ b/OvaleData.lua @@ -13,11 +13,6 @@ local OvaleData = Ovale:NewModule("OvaleData") Ovale.OvaleData = OvaleData -- --- Forward declarations for module dependencies. -local OvalePaperDoll = nil -local OvaleState = nil - -local floor = math.floor local API_GetSpellCooldown = GetSpellCooldown -- Auras that are refreshed by spells that don't trigger a new snapshot. @@ -248,20 +243,6 @@ OvaleData.buffSpellList.heroism = OvaleData.buffSpellList.burst_haste -- -- -function OvaleData:OnInitialize() - -- Resolve module dependencies. - OvalePaperDoll = Ovale.OvalePaperDoll - OvaleState = Ovale.OvaleState -end - -function OvaleData:OnEnable() - OvaleState:RegisterState(self, self.statePrototype) -end - -function OvaleData:OnDisable() - OvaleState:UnregisterState(self) -end - function OvaleData:ResetSpellInfo() self.spellInfo = {} end @@ -330,69 +311,4 @@ function OvaleData:GetDamage(spellId, attackpower, spellpower, mainHandWeaponDam end return damage end - -function OvaleData:GetTickLength(auraId, snapshot) - local tick = 3 - local si = self.spellInfo[auraId] - if si then - tick = si.tick or tick - local hasteMultiplier = 1 - if si.haste then - if si.haste == "spell" then - hasteMultiplier = OvalePaperDoll:GetSpellHasteMultiplier(snapshot) - elseif si.haste == "melee" then - hasteMultiplier = OvalePaperDoll:GetMeleeHasteMultiplier(snapshot) - end - tick = tick / hasteMultiplier - end - end - return tick -end -- - ---[[---------------------------------------------------------------------------- - State machine for simulator. ---]]---------------------------------------------------------------------------- - --- -OvaleData.statePrototype = {} --- - --- -local statePrototype = OvaleData.statePrototype --- - --- -statePrototype.GetTickLength = function(state, auraId, snapshot) - return OvaleData:GetTickLength(auraId, snapshot) -end - --- Returns the raw duration, DoT duration, tick length, and number of ticks of an aura. -statePrototype.GetDuration = function(state, auraId, spellcast) - local snapshot, combo, holy - if spellcast then - snapshot, combo, holy = spellcast.snapshot, spellcast.combo, spellcast.holy - else - snapshot, combo, holy = state.snapshot, state.combo, state.holy - end - - local duration = math.huge - local tick = state:GetTickLength(auraId, snapshot) - - local si = OvaleData.spellInfo[auraId] - if si and si.duration then - duration = si.duration - if si.adddurationcp and combo then - duration = duration + si.adddurationcp * combo - end - if si.adddurationholy and holy then - duration = duration + si.adddurationholy * (holy - 1) - end - end - - local numTicks = floor(duration/tick + 0.5) - local dotDuration = tick * numTicks - - return duration, dotDuration, tick, numTicks -end --- -- 1.7.9.5