From 74870a939b16b15de40449fc7306012cceee719f Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Fri, 15 Nov 2013 19:58:39 +0000 Subject: [PATCH] Pass an extra argument to ApplySpell that denotes a channeled spell. A channeled spell may cause different decisions on how the spell is applied in the state machine. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1179 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleAura.lua | 11 ++++++----- OvaleComboPoints.lua | 2 +- OvaleCooldown.lua | 2 +- OvaleEclipse.lua | 2 +- OvaleFrame.lua | 2 +- OvaleFuture.lua | 4 ++-- OvalePower.lua | 2 +- OvaleRunes.lua | 2 +- OvaleState.lua | 19 ++++++++++++------- 9 files changed, 26 insertions(+), 20 deletions(-) diff --git a/OvaleAura.lua b/OvaleAura.lua index 6574d77..26e3764 100644 --- a/OvaleAura.lua +++ b/OvaleAura.lua @@ -643,20 +643,20 @@ function OvaleAura:ResetState(state) end -- Apply the effects of the spell on the player's state, assuming the spellcast completes. -function OvaleAura:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) +function OvaleAura:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, isChanneled, nocd, targetGUID, spellcast) local si = OvaleData.spellInfo[spellId] -- Apply the auras on the player. if si and si.aura and si.aura.player then - state:ApplySpellAuras(spellId, startCast, endCast, OvaleGUID:GetGUID("player"), si.aura.player, spellcast) + state:ApplySpellAuras(spellId, startCast, endCast, isChanneled, OvaleGUID:GetGUID("player"), si.aura.player, spellcast) end end -- Apply the effects of the spell on the target's state when it lands on the target. -function OvaleAura:ApplySpellOnHit(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) +function OvaleAura:ApplySpellOnHit(state, spellId, startCast, endCast, nextCast, isChanneled, nocd, targetGUID, spellcast) local si = OvaleData.spellInfo[spellId] -- Apply the auras on the target. if si and si.aura and si.aura.target then - state:ApplySpellAuras(spellId, startCast, endCast, targetGUID, si.aura.target, spellcast) + state:ApplySpellAuras(spellId, startCast, endCast, isChanneled, targetGUID, si.aura.target, spellcast) end end -- @@ -666,8 +666,9 @@ do local statePrototype = OvaleAura.statePrototype -- Apply the auras caused by the given spell in the simulator. - function statePrototype:ApplySpellAuras(spellId, startCast, endCast, guid, auraList, spellcast) + function statePrototype:ApplySpellAuras(spellId, startCast, endCast, isChanneled, guid, auraList, spellcast) local state = self + local target = OvaleGUID:GetUnitId(guid) for filter, filterInfo in pairs(auraList) do for auraId, spellData in pairs(filterInfo) do local si = OvaleData.spellInfo[auraId] diff --git a/OvaleComboPoints.lua b/OvaleComboPoints.lua index 05f37fb..1076b5d 100644 --- a/OvaleComboPoints.lua +++ b/OvaleComboPoints.lua @@ -121,7 +121,7 @@ function OvaleComboPoints:ResetState(state) end -- Apply the effects of the spell on the player's state, assuming the spellcast completes. -function OvaleComboPoints:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) +function OvaleComboPoints:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, isChanneled, nocd, targetGUID, spellcast) local si = OvaleData.spellInfo[spellId] if si and si.combo then local cost = si.combo diff --git a/OvaleCooldown.lua b/OvaleCooldown.lua index 7dd4d8a..30e9815 100644 --- a/OvaleCooldown.lua +++ b/OvaleCooldown.lua @@ -103,7 +103,7 @@ function OvaleCooldown:ResetState(state) end -- Apply the effects of the spell on the player's state, assuming the spellcast completes. -function OvaleCooldown:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) +function OvaleCooldown:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, isChanneled, nocd, targetGUID, spellcast) local si = OvaleData.spellInfo[spellId] if si then local cd = state:GetCD(spellId) diff --git a/OvaleEclipse.lua b/OvaleEclipse.lua index 633d23c..aefc983 100644 --- a/OvaleEclipse.lua +++ b/OvaleEclipse.lua @@ -136,7 +136,7 @@ function OvaleEclipse:ResetState(state) end -- Apply the effects of the spell on the player's state, assuming the spellcast completes. -function OvaleEclipse:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) +function OvaleEclipse:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, isChanneled, nocd, targetGUID, spellcast) local si = OvaleData.spellInfo[spellId] if si and si.eclipse then local eclipse = state.eclipse diff --git a/OvaleFrame.lua b/OvaleFrame.lua index 2fc6ec8..a6974a0 100644 --- a/OvaleFrame.lua +++ b/OvaleFrame.lua @@ -278,7 +278,7 @@ do if spellTarget == "target" or not spellTarget then spellTarget = target end - OvaleState:ApplySpell(spellId, start, start + castTime, nextCast, false, OvaleGUID:GetGUID(spellTarget)) + OvaleState:ApplySpell(spellId, start, start + castTime, nextCast, false, false, OvaleGUID:GetGUID(spellTarget)) timeSpan, _, element = OvaleBestAction:Compute(node) start = NextTime(timeSpan, state.currentTime) icons[2]:Update(element, start, OvaleBestAction:GetActionInfo(element)) diff --git a/OvaleFuture.lua b/OvaleFuture.lua index 742fa8f..3e22902 100644 --- a/OvaleFuture.lua +++ b/OvaleFuture.lua @@ -461,7 +461,7 @@ function OvaleFuture:ApplyInFlightSpells() local spellcast = self_activeSpellcast[index] Ovale:Logf("now = %f, spellId = %d, endCast = %f", now, spellcast.spellId, spellcast.stop) if now - spellcast.stop < 5 then - OvaleState:ApplySpell(spellcast.spellId, spellcast.start, spellcast.stop, spellcast.stop, spellcast.nocd, spellcast.target, spellcast) + OvaleState:ApplySpell(spellcast.spellId, spellcast.start, spellcast.stop, spellcast.stop, spellcast.channeled, spellcast.nocd, spellcast.target, spellcast) else tremove(self_activeSpellcast, index) self_pool:Release(spellcast) @@ -522,7 +522,7 @@ function OvaleFuture:ResetState(state) end -- Apply the effects of the spell at the start of the spellcast. -function OvaleFuture:ApplySpellStartCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) +function OvaleFuture:ApplySpellStartCast(state, spellId, startCast, endCast, nextCast, isChanneled, nocd, targetGUID, spellcast) local si = OvaleData.spellInfo[spellId] if si then -- Increment and reset spell counters. diff --git a/OvalePower.lua b/OvalePower.lua index 7f953e2..0cbc34a 100644 --- a/OvalePower.lua +++ b/OvalePower.lua @@ -232,7 +232,7 @@ function OvalePower:ResetState(state) end -- Apply the effects of the spell on the player's state, assuming the spellcast completes. -function OvalePower:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) +function OvalePower:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, isChanneled, nocd, targetGUID, spellcast) local si = OvaleData.spellInfo[spellId] -- Update power using information from GetSpellInfo() if there is no SpellInfo() for the spell's cost. diff --git a/OvaleRunes.lua b/OvaleRunes.lua index cfbacde..3bd1ef1 100644 --- a/OvaleRunes.lua +++ b/OvaleRunes.lua @@ -195,7 +195,7 @@ function OvaleRunes:ResetState(state) end -- Apply the effects of the spell on the player's state, assuming the spellcast completes. -function OvaleRunes:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) +function OvaleRunes:ApplySpellAfterCast(state, spellId, startCast, endCast, nextCast, isChanneled, nocd, targetGUID, spellcast) local si = OvaleData.spellInfo[spellId] if si then for i, name in ipairs(RUNE_NAME) do diff --git a/OvaleState.lua b/OvaleState.lua index 184409b..e199c27 100644 --- a/OvaleState.lua +++ b/OvaleState.lua @@ -37,6 +37,7 @@ OvaleState.now = nil OvaleState.nextCast = nil OvaleState.startCast = nil OvaleState.endCast = nil +OvaleState.isChanneling = nil OvaleState.lastSpellId = nil -- The state for the simulator. @@ -80,7 +81,7 @@ end function OvaleState:InvokeMethod(methodName, ...) for _, addon in self_stateModules:Iterator() do if addon[methodName] then - addon[methodName](addon, self.state, ...) + addon[methodName](addon, ...) end end end @@ -93,7 +94,7 @@ function OvaleState:StartNewFrame() end function OvaleState:InitializeState() - self:InvokeMethod("InitializeState") + self:InvokeMethod("InitializeState", self.state) self_stateIsInitialized = true end @@ -104,9 +105,10 @@ function OvaleState:Reset() self.lastSpellId = Ovale.lastSpellcast and Ovale.lastSpellcast.spellId self.currentSpellId = nil + self.isChanneling = false self.nextCast = self.now - self:InvokeMethod("ResetState") + self:InvokeMethod("ResetState", self.state) end --[[ @@ -117,11 +119,13 @@ end startCast The time at the start of the spellcast. endCast The time at the end of the spellcast. nextCast The earliest time at which the next spell can be cast (nextCast >= endCast). + isChanneled The spell is a channeled spell. nocd The spell's cooldown is not triggered. targetGUID The GUID of the target of the spellcast. spellcast (optional) Table of spellcast information, including a snapshot of player's stats. --]] -function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) +function OvaleState:ApplySpell(...) + local spellId, startCast, endCast, nextCast, isChanneled, nocd, targetGUID, spellcast = ... if not spellId or not targetGUID then return end @@ -132,6 +136,7 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ self.currentSpellId = spellId self.startCast = startCast self.endCast = endCast + self.isChanneling = isChanneled self.lastSpellId = spellId -- Set the current time in the simulator to a little after the start of the current cast, @@ -152,12 +157,12 @@ function OvaleState:ApplySpell(spellId, startCast, endCast, nextCast, nocd, targ --]] -- If the spellcast has already started, then the effects have already occurred. if startCast >= OvaleState.now then - self:InvokeMethod("ApplySpellStartCast", spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) + self:InvokeMethod("ApplySpellStartCast", self.state, ...) end -- If the spellcast has already ended, then the effects have already occurred. if endCast > OvaleState.now then - self:InvokeMethod("ApplySpellAfterCast", spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) + self:InvokeMethod("ApplySpellAfterCast", self.state, ...) end - self:InvokeMethod("ApplySpellOnHit", spellId, startCast, endCast, nextCast, nocd, targetGUID, spellcast) + self:InvokeMethod("ApplySpellOnHit", self.state, ...) end -- -- 1.7.9.5