From 0decdddf35d1abb5a6a9f69815d3b05f62a0d806 Mon Sep 17 00:00:00 2001 From: "Johnny C. Lam" Date: Tue, 27 May 2014 18:27:43 +0000 Subject: [PATCH] Enhance OvaleEclipse to update the damage multiplier properly for spells. The damage multiplier stored in auras now includes the bonus from both Moonkin Form and Eclipse plus the mastery bonus. git-svn-id: svn://svn.curseforge.net/wow/ovale/mainline/trunk@1500 d5049fe3-3747-40f7-a4b5-f36d6801af5f --- OvaleEclipse.lua | 73 +++++++++++++++++++++++++++++++++++++++- OvaleFuture.lua | 17 +++++++--- scripts/ovale_druid_spells.lua | 26 ++++++++------ 3 files changed, 100 insertions(+), 16 deletions(-) diff --git a/OvaleEclipse.lua b/OvaleEclipse.lua index 5ddc25b..6d3db1d 100644 --- a/OvaleEclipse.lua +++ b/OvaleEclipse.lua @@ -17,10 +17,13 @@ Ovale.OvaleEclipse = OvaleEclipse -- -- Forward declarations for module dependencies. +local OvaleAura = nil local OvaleData = nil +local OvaleFuture = nil local OvaleSpellBook = nil local OvaleState = nil +local floor = math.floor local API_GetEclipseDirection = GetEclipseDirection local API_UnitClass = UnitClass local API_UnitGUID = UnitGUID @@ -33,13 +36,18 @@ local OVALE_ECLIPSE_DEBUG = "eclipse" local self_guid = nil -- Player's class. local _, self_class = API_UnitClass("player") +-- Table of functions to update spellcast information to register with OvaleFuture. +local self_updateSpellcastInfo = {} local LUNAR_ECLIPSE = ECLIPSE_BAR_LUNAR_BUFF_ID local SOLAR_ECLIPSE = ECLIPSE_BAR_SOLAR_BUFF_ID -- Nature's Grace: You gain 15% spell haste for 15 seconds each time you trigger an Eclipse. local NATURES_GRACE = 16886 local CELESTIAL_ALIGNMENT = 112071 +local DREAM_OF_CENARIUS = 145151 +local DREAM_OF_CENARIUS_TALENT = 17 local EUPHORIA = 81062 +local MOONKIN_FORM = 24858 local STARFALL = 48505 -- @@ -49,10 +57,52 @@ OvaleEclipse.eclipse = 0 OvaleEclipse.eclipseDirection = 0 -- +-- +-- Manage Eclipsed damage multiplier information. +local function GetDamageMultiplier(spellId, snapshot, auraObject) + auraObject = auraObject or OvaleAura + local damageMultiplier = 1 + local si = OvaleData.spellInfo[spellId] + + if si and (si.arcane == 1 or si.nature == 1) then + -- Update the damage multiplier for Moonkin Form 10% bonus to Arcane and Nature damage. + local moonkinForm = auraObject:GetAura("player", MOONKIN_FORM, "HELPFUL", true) + if auraObject:IsActiveAura(moonkinForm) then + damageMultiplier = damageMultiplier * 1.1 + end + + -- Update the damage multiplier for Eclipse bonus to Arcane and Nature damage. + local aura + if si.arcane == 1 then + aura = auraObject:GetAura("player", LUNAR_ECLIPSE, "HELPFUL", true) + end + if not auraObject:IsActiveAura(aura) and si.nature == 1 then + aura = auraObject:GetAura("player", SOLAR_ECLIPSE, "HELPFUL", true) + end + if not auraObject:IsActiveAura(aura) then + aura = auraObject:GetAura("player", CELESTIAL_ALIGNMENT, "HELPFUL", true) + end + if auraObject:IsActiveAura(aura) then + local eclipseEffect = aura.value1 + local masteryEffect = snapshot.masteryEffect or 0 + eclipseEffect = eclipseEffect - floor(masteryEffect) + masteryEffect + damageMultiplier = damageMultiplier * (1 + eclipseEffect / 100) + end + end + return damageMultiplier +end + +do + self_updateSpellcastInfo.GetDamageMultiplier = GetDamageMultiplier +end +-- + -- function OvaleEclipse:OnInitialize() -- Resolve module dependencies. + OvaleAura = Ovale.OvaleAura OvaleData = Ovale.OvaleData + OvaleFuture = Ovale.OvaleFuture OvaleSpellBook = Ovale.OvaleSpellBook OvaleState = Ovale.OvaleState end @@ -79,8 +129,10 @@ function OvaleEclipse:Ovale_SpecializationChanged(event, specialization, previou self:RegisterMessage("Ovale_StanceChanged", "Update") self:RegisterMessage("Ovale_AuraAdded") OvaleState:RegisterState(self, self.statePrototype) + OvaleFuture:RegisterSpellcastInfo(self_updateSpellcastInfo) else OvaleState:UnregisterState(self) + OvaleFuture:UnregisterSpellcastInfo(self_updateSpellcastInfo) self:UnregisterEvent("ECLIPSE_DIRECTION_CHANGE") self:UnregisterEvent("UNIT_POWER") self:UnregisterEvent("UNIT_POWER_FREQUENT") @@ -181,6 +233,8 @@ end -- Update the state of the simulator for the eclipse energy gained by casting the given spell. statePrototype.ApplyEclipseEnergy = function(state, spellId, atTime, snapshot) if spellId == CELESTIAL_ALIGNMENT then + local aura = state:AddAuraToGUID(self_guid, spellId, self_guid, "HELPFUL", atTime, atTime + 15, snapshot) + aura.value1 = state:EclipseBonusDamage(atTime, snapshot) -- Celestial Alignment grants the spell effects of both Lunar and Solar Eclipse and -- also resets the total Eclipse energy to zero. state:AddEclipse(LUNAR_ECLIPSE, atTime, snapshot) @@ -267,11 +321,28 @@ statePrototype.EclipseEnergy = function(state, spellId) return eclipseEnergy end +statePrototype.EclipseBonusDamage = function(state, atTime, snapshot) + -- Base Eclipse bonus (percent) to damage. + local bonus = 15 + -- Add in mastery bonus to Eclipse damage. + bonus = bonus + snapshot.masteryEffect + -- Add in bonus from Dream of Cenarius. + if OvaleSpellBook:GetTalentPoints(DREAM_OF_CENARIUS_TALENT) > 0 then + local aura = state:GetAura("player", DREAM_OF_CENARIUS, "HELPFUL", true) + if state:IsActiveAura(aura, atTime) then + bonus = bonus + 25 + end + end + return bonus +end + statePrototype.AddEclipse = function(state, eclipseId, atTime, snapshot) if eclipseId == LUNAR_ECLIPSE or eclipseId == SOLAR_ECLIPSE then local eclipseName = (eclipseId == LUNAR_ECLIPSE) and "Lunar" or "Solar" Ovale:Logf("[%s] Adding %s Eclipse (%d) at %f", OVALE_ECLIPSE_DEBUG, eclipseName, eclipseId, atTime) - state:AddAuraToGUID(self_guid, eclipseId, self_guid, "HELPFUL", atTime, math.huge, snapshot) + local aura = state:AddAuraToGUID(self_guid, eclipseId, self_guid, "HELPFUL", atTime, math.huge, snapshot) + -- Set the value of the Eclipse aura to the Eclipse's bonus damage. + aura.value1 = state:EclipseBonusDamage(atTime, snapshot) -- Reaching Eclipse state grants Nature's Grace. state:AddAuraToGUID(self_guid, NATURES_GRACE, self_guid, "HELPFUL", atTime, atTime + 15, snapshot) -- Reaching Lunar Eclipse resets the cooldown of Starfall. diff --git a/OvaleFuture.lua b/OvaleFuture.lua index da901ec..141a183 100644 --- a/OvaleFuture.lua +++ b/OvaleFuture.lua @@ -131,7 +131,7 @@ end GetAura(unitId, auraId, filter, mine) IsActiveAura(aura, atTime) --]] -local function GetDamageMultiplier(spellId, auraObject) +local function GetDamageMultiplier(spellId, snapshot, auraObject) auraObject = auraObject or OvaleAura local damageMultiplier = 1 local si = OvaleData.spellInfo[spellId] @@ -150,6 +150,13 @@ local function GetDamageMultiplier(spellId, auraObject) end end end + -- Factor in additional damage multipliers that are registered with this module. + for tbl in pairs(self_updateSpellcastInfo) do + if tbl.GetDamageMultiplier then + local multiplier = tbl.GetDamageMultiplier(spellId, snapshot, auraObject) + damageMultiplier = damageMultiplier * multiplier + end + end return damageMultiplier end @@ -175,7 +182,7 @@ local function AddSpellToQueue(spellId, lineId, startTime, endTime, channeled, a -- Snapshot the current stats for the spellcast. spellcast.snapshot = OvalePaperDoll:GetSnapshot() - spellcast.damageMultiplier = GetDamageMultiplier(spellId) + spellcast.damageMultiplier = GetDamageMultiplier(spellId, spellcast.snapshot) local si = OvaleData.spellInfo[spellId] if si then @@ -288,7 +295,7 @@ local function UpdateLastSpellcast(spellcast) if self_timeAuraAdded then if self_timeAuraAdded >= spellcast.start and self_timeAuraAdded - spellcast.stop < 1 then OvalePaperDoll:UpdateSnapshot(spellcast.snapshot) - spellcast.damageMultiplier = GetDamageMultiplier(spellId) + spellcast.damageMultiplier = GetDamageMultiplier(spellId, spellcast.snapshot) TracePrintf(spellId, " Updated spell info for %s (%d) to snapshot from %f.", OvaleSpellBook:GetSpellName(spellId), spellId, spellcast.snapshot.snapshotTime) end @@ -450,7 +457,7 @@ function OvaleFuture:UNIT_SPELLCAST_SUCCEEDED(event, unit, name, rank, lineId, s OvalePaperDoll:ReleaseSnapshot(spellcast.snapshot) end spellcast.snapshot = OvalePaperDoll:GetSnapshot() - spellcast.damageMultiplier = GetDamageMultiplier(spellId) + spellcast.damageMultiplier = GetDamageMultiplier(spellId, spellcast.snapshot) return end end @@ -713,7 +720,7 @@ statePrototype.GetCounterValue = function(state, id) end statePrototype.GetDamageMultiplier = function(state, spellId) - return GetDamageMultiplier(spellId, state) + return GetDamageMultiplier(spellId, state.snapshot, state) end --[[ diff --git a/scripts/ovale_druid_spells.lua b/scripts/ovale_druid_spells.lua index 426e98c..049a1d0 100644 --- a/scripts/ovale_druid_spells.lua +++ b/scripts/ovale_druid_spells.lua @@ -7,6 +7,8 @@ do local code = [[ # Druid spells and functions. +Define(astral_storm 106996) + SpellInfo(astral_storm arcane=1 channel=10 haste=spell) Define(barkskin 22812) SpellInfo(barkskin cd=60) SpellInfo(barkskin buff_cdr=cooldown_reduction_agility_buff mastery=feral) @@ -54,11 +56,13 @@ Define(dream_of_cenarius_talent 17) Define(enrage 5229) SpellInfo(enrage cd=60 rage=-20) Define(faerie_fire 770) + SpellInfo(faerie_fire nature=1) SpellInfo(faerie_fire cd=6 if_stance=druid_bear_form) SpellInfo(faerie_fire cd=6 if_stance=druid_cat_form) SpellInfo(faerie_fire cd=15 glyph=glyph_of_fae_silence if_stance=druid_bear_form) SpellAddTargetDebuff(faerie_fire weakened_armor_debuff=3) Define(faerie_swarm 102355) + SpellInfo(faerie_swarm nature=1) SpellInfo(faerie_swarm cd=6 if_stance=druid_bear_form) SpellInfo(faerie_swarm cd=6 if_stance=druid_cat_form) SpellInfo(faerie_swarm cd=15 glyph=glyph_of_fae_silence if_stance=druid_bear_form) @@ -75,7 +79,7 @@ Define(ferocious_bite 22568) SpellInfo(ferocious_bite damage=FeralFerociousBiteDamage mastery=feral) SpellAddBuff(ferocious_bite omen_of_clarity_melee_buff=0 if_spell=omen_of_clarity_melee) Define(force_of_nature_caster 33831) - SpellInfo(force_of_nature_caster gcd=0) + SpellInfo(force_of_nature_caster gcd=0 nature=1) Define(force_of_nature_heal 102693) SpellInfo(force_of_nature_heal gcd=0) Define(force_of_nature_melee 102703) @@ -120,7 +124,7 @@ Define(heart_of_the_wild_melee 108292) SpellInfo(heart_of_the_wild_melee cd=360) Define(heart_of_the_wild_talent 16) Define(hurricane 16914) - SpellInfo(hurricane channel=10 haste=spell) + SpellInfo(hurricane channel=10 haste=spell nature=1) Define(incarnation 106731) SpellInfo(incarnation cd=180) Define(incarnation_talent 11) @@ -173,9 +177,10 @@ Define(mighty_bash 5211) SpellInfo(mighty_bash cd=50) Define(mighty_bash_talent 15) Define(moonfire 8921) + SpellInfo(moonfire arcane=1) SpellAddTargetDebuff(moonfire moonfire_debuff=1) Define(moonfire_debuff 8921) - SpellInfo(moonfire_debuff duration=14 haste=spell tick=2) + SpellInfo(moonfire_debuff arcane=1 duration=14 haste=spell tick=2) SpellInfo(moonfire_debuff addduration=2 itemset=T14_caster itemcount=4) Define(moonkin_form 24858) Define(natures_grace_buff 16886) @@ -299,19 +304,20 @@ Define(son_of_ursoc_buff 102558) SpellInfo(son_of_ursoc_buff duration=30) Define(soul_of_the_forest_talent 10) Define(starfall 48505) - SpellInfo(starfall cd=90) + SpellInfo(starfall arcane=1 cd=90) SpellAddBuff(starfall starfall_buff=1) Define(starfall_buff 48505) SpellInfo(starfall_buff duration=10) Define(starfire 2912) - SpellInfo(starfire eclipse=20) + SpellInfo(starfire arcane=1 eclipse=20) Define(starsurge 78674) - SpellInfo(starsurge cd=15 eclipse=20 eclipsedir=1) + SpellInfo(starsurge arcane=1 cd=15 eclipse=20 eclipsedir=1 nature=1) SpellAddBuff(starsurge shooting_stars_buff=0) Define(sunfire 93402) + SpellInfo(sunfire nature=1) SpellAddTargetDebuff(sunfire sunfire_debuff=1) Define(sunfire_debuff 93402) - SpellInfo(sunfire_debuff duration=14 haste=spell tick=2) + SpellInfo(sunfire_debuff duration=14 haste=spell nature=1 tick=2) SpellInfo(sunfire addduration=2 itemset=T14_caster itemcount=4) Define(survival_instincts 61336) SpellInfo(survival_instincts cd=180) @@ -362,7 +368,7 @@ Define(tranquility 740) Define(tree_of_life_buff 33891) SpellInfo(tree_of_life_buff duration=30) Define(typhoon 132469) - SpellInfo(typhoon cd=30) + SpellInfo(typhoon cd=30 nature=1) Define(typhoon_talent 9) Define(weakened_armor_debuff 113746) SpellInfo(weakened_armor_debuff duration=30 maxstacks=3) @@ -387,11 +393,11 @@ Define(wild_mushroom_bloom 102791) Define(wild_mushroom_caster 88747) SpellInfo(wild_mushroom_caster gcd=1) Define(wild_mushroom_detonate 88751) - SpellInfo(wild_mushroom_detonate cd=10 gcd=0) + SpellInfo(wild_mushroom_detonate cd=10 gcd=0 nature=1) Define(wild_mushroom_heal 145205) SpellInfo(wild_mushroom_heal cd=3 sharedcd=mushroom) Define(wrath 5176) - SpellInfo(wrath eclipse=-15) + SpellInfo(wrath eclipse=-15 nature=1) AddFunction FaerieFire { -- 1.7.9.5