diff --git a/sim/core/energy.go b/sim/core/energy.go index 1582292958..3362d448e7 100644 --- a/sim/core/energy.go +++ b/sim/core/energy.go @@ -172,9 +172,10 @@ type EnergyCostOptions struct { RefundMetrics *ResourceMetrics // Optional, will default to unit.EnergyRefundMetrics if not supplied. } type EnergyCost struct { - Refund float64 - RefundMetrics *ResourceMetrics - ResourceMetrics *ResourceMetrics + Refund float64 + RefundMetrics *ResourceMetrics + ResourceMetrics *ResourceMetrics + ComboPointMetrics *ResourceMetrics } func newEnergyCost(spell *Spell, options EnergyCostOptions) *EnergyCost { @@ -184,9 +185,10 @@ func newEnergyCost(spell *Spell, options EnergyCostOptions) *EnergyCost { } return &EnergyCost{ - Refund: options.Refund, - RefundMetrics: options.RefundMetrics, - ResourceMetrics: spell.Unit.NewEnergyMetrics(spell.ActionID), + Refund: options.Refund, + RefundMetrics: options.RefundMetrics, + ResourceMetrics: spell.Unit.NewEnergyMetrics(spell.ActionID), + ComboPointMetrics: spell.Unit.NewComboPointMetrics(spell.ActionID), } } @@ -209,3 +211,11 @@ func (ec *EnergyCost) IssueRefund(sim *Simulation, spell *Spell) { spell.Unit.AddEnergy(sim, ec.Refund*spell.CurCast.Cost, ec.RefundMetrics) } } + +func (spell *Spell) EnergyMetrics() *ResourceMetrics { + return spell.Cost.(*EnergyCost).ComboPointMetrics +} + +func (spell *Spell) ComboPointMetrics() *ResourceMetrics { + return spell.Cost.(*EnergyCost).ComboPointMetrics +} diff --git a/sim/core/runic_power.go b/sim/core/runic_power.go index ea95316156..ed611f222f 100644 --- a/sim/core/runic_power.go +++ b/sim/core/runic_power.go @@ -1106,6 +1106,12 @@ type RuneCostImpl struct { RunicPowerCost float64 RunicPowerGain float64 Refundable bool + + runicPowerMetrics *ResourceMetrics + bloodRuneMetrics *ResourceMetrics + frostRuneMetrics *ResourceMetrics + unholyRuneMetrics *ResourceMetrics + deathRuneMetrics *ResourceMetrics } func newRuneCost(spell *Spell, options RuneCostOptions) *RuneCostImpl { @@ -1120,6 +1126,12 @@ func newRuneCost(spell *Spell, options RuneCostOptions) *RuneCostImpl { RunicPowerCost: options.RunicPowerCost, RunicPowerGain: options.RunicPowerGain, Refundable: options.Refundable, + + runicPowerMetrics: Ternary(options.RunicPowerCost > 0 || options.RunicPowerGain > 0, spell.Unit.NewRunicPowerMetrics(spell.ActionID), nil), + bloodRuneMetrics: Ternary(options.BloodRuneCost > 0, spell.Unit.NewBloodRuneMetrics(spell.ActionID), nil), + frostRuneMetrics: Ternary(options.FrostRuneCost > 0, spell.Unit.NewFrostRuneMetrics(spell.ActionID), nil), + unholyRuneMetrics: Ternary(options.UnholyRuneCost > 0, spell.Unit.NewUnholyRuneMetrics(spell.ActionID), nil), + deathRuneMetrics: spell.Unit.NewDeathRuneMetrics(spell.ActionID), } } @@ -1225,3 +1237,23 @@ func (rc *RuneCostImpl) IssueRefund(sim *Simulation, spell *Spell) { // Instead of issuing refunds we just don't charge the cost of spells which // miss; this is better for perf since we'd have to cancel the regen actions. } + +func (spell *Spell) RunicPowerMetrics() *ResourceMetrics { + return spell.Cost.(*RuneCostImpl).runicPowerMetrics +} + +func (spell *Spell) BloodRuneMetrics() *ResourceMetrics { + return spell.Cost.(*RuneCostImpl).bloodRuneMetrics +} + +func (spell *Spell) FrostRuneMetrics() *ResourceMetrics { + return spell.Cost.(*RuneCostImpl).frostRuneMetrics +} + +func (spell *Spell) UnholyRuneMetrics() *ResourceMetrics { + return spell.Cost.(*RuneCostImpl).unholyRuneMetrics +} + +func (spell *Spell) DeathRuneMetrics() *ResourceMetrics { + return spell.Cost.(*RuneCostImpl).deathRuneMetrics +} diff --git a/sim/core/spell.go b/sim/core/spell.go index a6a7ecf3f7..947f6e8faf 100644 --- a/sim/core/spell.go +++ b/sim/core/spell.go @@ -74,14 +74,8 @@ type Spell struct { // Example: https://wow.tools/dbc/?dbc=spellmisc&build=3.4.0.44996 MissileSpeed float64 - ResourceMetrics *ResourceMetrics - comboPointMetrics *ResourceMetrics - runicPowerMetrics *ResourceMetrics - bloodRuneMetrics *ResourceMetrics - frostRuneMetrics *ResourceMetrics - unholyRuneMetrics *ResourceMetrics - deathRuneMetrics *ResourceMetrics - healthMetrics []*ResourceMetrics + ResourceMetrics *ResourceMetrics + healthMetrics []*ResourceMetrics Cost SpellCost // Cost for the spell. DefaultCast Cast // Default cast parameters with all static effects applied. @@ -368,48 +362,6 @@ func (spell *Spell) doneIteration() { } } -func (spell *Spell) ComboPointMetrics() *ResourceMetrics { - if spell.comboPointMetrics == nil { - spell.comboPointMetrics = spell.Unit.NewComboPointMetrics(spell.ActionID) - } - return spell.comboPointMetrics -} - -func (spell *Spell) RunicPowerMetrics() *ResourceMetrics { - if spell.runicPowerMetrics == nil { - spell.runicPowerMetrics = spell.Unit.NewRunicPowerMetrics(spell.ActionID) - } - return spell.runicPowerMetrics -} - -func (spell *Spell) BloodRuneMetrics() *ResourceMetrics { - if spell.bloodRuneMetrics == nil { - spell.bloodRuneMetrics = spell.Unit.NewBloodRuneMetrics(spell.ActionID) - } - return spell.bloodRuneMetrics -} - -func (spell *Spell) FrostRuneMetrics() *ResourceMetrics { - if spell.frostRuneMetrics == nil { - spell.frostRuneMetrics = spell.Unit.NewFrostRuneMetrics(spell.ActionID) - } - return spell.frostRuneMetrics -} - -func (spell *Spell) UnholyRuneMetrics() *ResourceMetrics { - if spell.unholyRuneMetrics == nil { - spell.unholyRuneMetrics = spell.Unit.NewUnholyRuneMetrics(spell.ActionID) - } - return spell.unholyRuneMetrics -} - -func (spell *Spell) DeathRuneMetrics() *ResourceMetrics { - if spell.deathRuneMetrics == nil { - spell.deathRuneMetrics = spell.Unit.NewDeathRuneMetrics(spell.ActionID) - } - return spell.deathRuneMetrics -} - func (spell *Spell) HealthMetrics(target *Unit) *ResourceMetrics { if spell.healthMetrics == nil { spell.healthMetrics = make([]*ResourceMetrics, len(spell.Unit.AttackTables)) diff --git a/sim/deathknight/blood_tap.go b/sim/deathknight/blood_tap.go index 88548c8fdf..55285f7ab0 100644 --- a/sim/deathknight/blood_tap.go +++ b/sim/deathknight/blood_tap.go @@ -11,6 +11,7 @@ func (dk *Deathknight) registerBloodTapSpell() { cdTimer := dk.NewTimer() cd := time.Minute * 1 + rpMetrics := dk.NewRunicPowerMetrics(actionID) dk.BloodTapAura = dk.RegisterAura(core.Aura{ Label: "Blood Tap", ActionID: actionID, @@ -23,7 +24,7 @@ func (dk *Deathknight) registerBloodTapSpell() { // Gain at the end, to take into account previous effects for callback amountOfRunicPower := 10.0 - dk.AddRunicPower(sim, amountOfRunicPower, dk.BloodTap.RunicPowerMetrics()) + dk.AddRunicPower(sim, amountOfRunicPower, rpMetrics) }, OnExpire: func(aura *core.Aura, sim *core.Simulation) { dk.CancelBloodTap(sim) diff --git a/sim/deathknight/empower_rune_weapon.go b/sim/deathknight/empower_rune_weapon.go index 3b1d46ba70..9e2f28ff58 100644 --- a/sim/deathknight/empower_rune_weapon.go +++ b/sim/deathknight/empower_rune_weapon.go @@ -11,6 +11,7 @@ func (dk *Deathknight) registerEmpowerRuneWeaponSpell() { cdTimer := dk.NewTimer() cd := time.Minute * 5 + rpMetrics := dk.NewRunicPowerMetrics(actionID) dk.EmpowerRuneWeapon = dk.RegisterSpell(core.SpellConfig{ ActionID: actionID, Flags: core.SpellFlagNoOnCastComplete, @@ -22,7 +23,7 @@ func (dk *Deathknight) registerEmpowerRuneWeaponSpell() { }, ApplyEffects: func(sim *core.Simulation, target *core.Unit, spell *core.Spell) { dk.RegenAllRunes(sim) - dk.AddRunicPower(sim, 25, dk.EmpowerRuneWeapon.RunicPowerMetrics()) + dk.AddRunicPower(sim, 25, rpMetrics) }, }) } diff --git a/sim/deathknight/horn_of_winter.go b/sim/deathknight/horn_of_winter.go index cec51a34ff..b805936e3f 100644 --- a/sim/deathknight/horn_of_winter.go +++ b/sim/deathknight/horn_of_winter.go @@ -11,6 +11,7 @@ import ( func (dk *Deathknight) registerHornOfWinterSpell() { actionID := core.ActionID{SpellID: 57623} duration := time.Minute * time.Duration((2.0 + core.TernaryFloat64(dk.HasMinorGlyph(proto.DeathknightMinorGlyph_GlyphOfHornOfWinter), 1.0, 0.0))) + rpMetrics := dk.NewRunicPowerMetrics(actionID) bonusStats := stats.Stats{stats.Strength: 155.0, stats.Agility: 155.0} negativeStats := bonusStats.Multiply(-1) @@ -53,7 +54,7 @@ func (dk *Deathknight) registerHornOfWinterSpell() { if dk.Inputs.RefreshHornOfWinter { dk.HornOfWinterAura.Activate(sim) } - dk.AddRunicPower(sim, 10, dk.HornOfWinter.RunicPowerMetrics()) + dk.AddRunicPower(sim, 10, rpMetrics) }, }) }