Skip to content

Commit

Permalink
Merge pull request #2686 from wowsims/cleanups
Browse files Browse the repository at this point in the history
Remove mana tracker and bonus mana fields
  • Loading branch information
jimmyt857 authored Feb 19, 2023
2 parents 9afab99 + 834f86e commit 7801f81
Show file tree
Hide file tree
Showing 45 changed files with 81 additions and 275 deletions.
148 changes: 0 additions & 148 deletions sim/common/mana_spending_rate_tracker.go

This file was deleted.

2 changes: 1 addition & 1 deletion sim/common/tbc/metagems.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func init() {
return
}
icd.Use(sim)
character.AddMana(sim, 300, manaMetrics, false)
character.AddMana(sim, 300, manaMetrics)
},
})
})
Expand Down
2 changes: 1 addition & 1 deletion sim/common/wotlk/enchant_effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -387,7 +387,7 @@ func init() {
OnCastComplete: func(aura *core.Aura, sim *core.Simulation, spell *core.Spell) {
if icd.IsReady(sim) && sim.RandomFloat("Darkglow") < 0.35 {
icd.Use(sim)
character.AddMana(sim, 400, manaMetrics, false)
character.AddMana(sim, 400, manaMetrics)
}
},
})
Expand Down
2 changes: 1 addition & 1 deletion sim/common/wotlk/metagems.go
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ func init() {
ProcChance: 0.05,
ICD: time.Second * 15,
Handler: func(sim *core.Simulation, _ *core.Spell, _ *core.SpellResult) {
character.AddMana(sim, 600, manaMetrics, false)
character.AddMana(sim, 600, manaMetrics)
},
})
})
Expand Down
12 changes: 6 additions & 6 deletions sim/common/wotlk/other_effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func init() {
ProcChance: 0.25,
ICD: time.Second * 45,
Handler: func(sim *core.Simulation, _ *core.Spell, _ *core.SpellResult) {
character.AddMana(sim, 900, manaMetrics, false)
character.AddMana(sim, 900, manaMetrics)
},
})
})
Expand Down Expand Up @@ -410,7 +410,7 @@ func init() {
},
},
ApplyEffects: func(sim *core.Simulation, _ *core.Unit, _ *core.Spell) {
character.AddMana(sim, amount, manaMetrics, false)
character.AddMana(sim, amount, manaMetrics)
},
})
character.AddMajorCooldown(core.MajorCooldown{
Expand Down Expand Up @@ -524,7 +524,7 @@ func init() {
NumTicks: 12,
Period: time.Second * 1,
OnAction: func(sim *core.Simulation) {
character.AddMana(sim, 195, manaMetrics, false)
character.AddMana(sim, 195, manaMetrics)
},
})
},
Expand All @@ -547,7 +547,7 @@ func init() {
ProcChance: 0.25,
ICD: time.Second * 45,
Handler: func(sim *core.Simulation, _ *core.Spell, _ *core.SpellResult) {
character.AddMana(sim, 500, manaMetrics, false)
character.AddMana(sim, 500, manaMetrics)
},
})
})
Expand Down Expand Up @@ -591,7 +591,7 @@ func init() {
OnAction: func(sim *core.Simulation) {
cpb := character.GetCurrentPowerBar()
if cpb == core.ManaBar {
character.AddMana(sim, 120, resourceMetricsMana, false)
character.AddMana(sim, 120, resourceMetricsMana)
} else if cpb == core.RageBar {
character.AddRage(sim, 2, resourceMetricsRage)
} else if cpb == core.EnergyBar {
Expand Down Expand Up @@ -629,7 +629,7 @@ func init() {
Callback: core.CallbackOnHealDealt | core.CallbackOnPeriodicHealDealt,
ICD: time.Millisecond * 250,
Handler: func(sim *core.Simulation, _ *core.Spell, _ *core.SpellResult) {
character.AddMana(sim, 11, manaMetrics, false)
character.AddMana(sim, 11, manaMetrics)
},
})
})
Expand Down
38 changes: 7 additions & 31 deletions sim/core/buffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ func BlessingOfSanctuaryAura(character *Character) {
},
OnSpellHitTaken: func(aura *Aura, sim *Simulation, spell *Spell, result *SpellResult) {
if result.Outcome.Matches(OutcomeBlock | OutcomeDodge | OutcomeParry) {
character.AddMana(sim, 0.02*character.MaxMana(), manaMetrics, false)
character.AddMana(sim, 0.02*character.MaxMana(), manaMetrics)
}
},
})
Expand Down Expand Up @@ -883,7 +883,7 @@ func registerRevitalizeHotCD(agent Agent, label string, hotID ActionID, ticks in
if s.RandomFloat("Revitalize Proc") < 0.15 {
cpb := aura.Unit.GetCurrentPowerBar()
if cpb == ManaBar {
aura.Unit.AddMana(s, aura.Unit.MaxMana()*0.01, manaMetrics, true)
aura.Unit.AddMana(s, 0.01*aura.Unit.MaxMana(), manaMetrics)
} else if cpb == EnergyBar {
aura.Unit.AddEnergy(s, 8, energyMetrics)
} else if cpb == RageBar {
Expand Down Expand Up @@ -948,17 +948,12 @@ func registerInnervateCD(agent Agent, numInnervates int32) {
}

innervateThreshold := 0.0
expectedManaPerInnervate := 0.0
remainingInnervateUsages := 0
var innervateAura *Aura

character := agent.GetCharacter()
character.Env.RegisterPostFinalizeEffect(func() {
innervateThreshold = InnervateManaThreshold(character)
expectedManaPerInnervate = 3496 * 2.25 // WotLK druid's base mana
remainingInnervateUsages = int(1 + (MaxDuration(0, character.Env.BaseDuration))/InnervateCD)
character.ExpectedBonusMana += expectedManaPerInnervate * float64(remainingInnervateUsages)
innervateAura = InnervateAura(character, expectedManaPerInnervate, -1)
innervateAura = InnervateAura(character, -1)
})

registerExternalConsecutiveCDApproximation(
Expand All @@ -976,17 +971,12 @@ func registerInnervateCD(agent Agent, numInnervates int32) {
},
AddAura: func(sim *Simulation, character *Character) {
innervateAura.Activate(sim)

newRemainingUsages := int(sim.GetRemainingDuration() / InnervateCD)
// AddInnervateAura already accounts for 1 usage, which is why we subtract 1 less.
character.ExpectedBonusMana -= expectedManaPerInnervate * MaxFloat(0, float64(remainingInnervateUsages-newRemainingUsages-1))
remainingInnervateUsages = newRemainingUsages
},
},
numInnervates)
}

func InnervateAura(character *Character, expectedBonusManaReduction float64, actionTag int32) *Aura {
func InnervateAura(character *Character, actionTag int32) *Aura {
actionID := ActionID{SpellID: 29166, Tag: actionTag}
manaMetrics := character.NewManaMetrics(actionID)
return character.GetOrRegisterAura(Aura{
Expand All @@ -995,13 +985,12 @@ func InnervateAura(character *Character, expectedBonusManaReduction float64, act
ActionID: actionID,
Duration: InnervateDuration,
OnGain: func(aura *Aura, sim *Simulation) {
expectedBonusManaPerTick := expectedBonusManaReduction / 10
const manaPerTick = 3496 * 2.25 / 10 // WotLK druid's base mana
StartPeriodicAction(sim, PeriodicActionOptions{
Period: InnervateDuration / 10,
NumTicks: 10,
OnAction: func(sim *Simulation) {
character.ExpectedBonusMana -= expectedBonusManaPerTick
character.AddMana(sim, expectedBonusManaPerTick, manaMetrics, true)
character.AddMana(sim, manaPerTick, manaMetrics)
},
})
},
Expand All @@ -1019,19 +1008,13 @@ func registerManaTideTotemCD(agent Agent, numManaTideTotems int32) {
return
}

expectedManaPerManaTideTotem := 0.0
remainingManaTideTotemUsages := 0
initialDelay := time.Duration(0)
var mttAura *Aura

character := agent.GetCharacter()
character.Env.RegisterPostFinalizeEffect(func() {
// Use first MTT at 60s, or halfway through the fight, whichever comes first.
initialDelay = MinDuration(character.Env.BaseDuration/2, time.Second*60)

expectedManaPerManaTideTotem = 0.24 * character.MaxMana()
remainingManaTideTotemUsages = int(1 + MaxDuration(0, character.Env.BaseDuration-initialDelay)/ManaTideTotemCD)
character.ExpectedBonusMana += expectedManaPerManaTideTotem * float64(remainingManaTideTotemUsages)
mttAura = ManaTideTotemAura(character, -1)
})

Expand All @@ -1050,11 +1033,6 @@ func registerManaTideTotemCD(agent Agent, numManaTideTotems int32) {
},
AddAura: func(sim *Simulation, character *Character) {
mttAura.Activate(sim)

newRemainingUsages := int(sim.GetRemainingDuration() / ManaTideTotemCD)
// AddManaTideTotemAura already accounts for 1 usage, which is why we subtract 1 less.
character.ExpectedBonusMana -= expectedManaPerManaTideTotem * MaxFloat(0, float64(remainingManaTideTotemUsages-newRemainingUsages-1))
remainingManaTideTotemUsages = newRemainingUsages
},
},
numManaTideTotems)
Expand Down Expand Up @@ -1084,9 +1062,7 @@ func ManaTideTotemAura(character *Character, actionTag int32) *Aura {
for i, player := range character.Party.Players {
if metrics[i] != nil {
char := player.GetCharacter()
manaGain := 0.06 * char.MaxMana()
char.AddMana(sim, manaGain, metrics[i], true)
char.ExpectedBonusMana -= manaGain
char.AddMana(sim, 0.06*char.MaxMana(), metrics[i])
}
}
},
Expand Down
6 changes: 0 additions & 6 deletions sim/core/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,11 +64,6 @@ type Character struct {
// This character's index within its party [0-4].
PartyIndex int

// Total amount of remaining additional mana expected for the current sim iteration,
// beyond this Character's mana pool. This should include mana potions / runes /
// innervates / etc.
ExpectedBonusMana float64

defensiveTrinketCD *Timer
offensiveTrinketCD *Timer
conjuredCD *Timer
Expand Down Expand Up @@ -426,7 +421,6 @@ func (character *Character) init(sim *Simulation, agent Agent) {
}

func (character *Character) reset(sim *Simulation, agent Agent) {
character.ExpectedBonusMana = 0
character.Unit.reset(sim, agent)
character.majorCooldownManager.reset(sim)
character.ItemSwap.reset(sim)
Expand Down
6 changes: 3 additions & 3 deletions sim/core/consumes.go
Original file line number Diff line number Diff line change
Expand Up @@ -550,7 +550,7 @@ func makePotionActivation(potionType proto.Potions, character *Character, potion
} else if hasEngi && potionType == proto.Potions_RunicManaInjector {
manaGain *= 1.25
}
character.AddMana(sim, manaGain, manaMetrics, true)
character.AddMana(sim, manaGain, manaMetrics)
},
}),
}
Expand Down Expand Up @@ -631,7 +631,7 @@ func makePotionActivation(potionType proto.Potions, character *Character, potion
if alchStoneEquipped {
manaGain *= 1.4
}
character.AddMana(sim, manaGain, manaMetrics, true)
character.AddMana(sim, manaGain, manaMetrics)
},
}),
}
Expand Down Expand Up @@ -775,7 +775,7 @@ func registerConjuredCD(agent Agent, consumes *proto.Consumes) {
ApplyEffects: func(sim *Simulation, _ *Unit, _ *Spell) {
// Restores 900 to 1500 mana. (2 Min Cooldown)
manaGain := sim.RollWithLabel(900, 1500, "dark rune")
character.AddMana(sim, manaGain, manaMetrics, true)
character.AddMana(sim, manaGain, manaMetrics)

// if character.Class == proto.Class_ClassPaladin {
// // Paladins gain extra mana from self-inflicted damage
Expand Down
Loading

0 comments on commit 7801f81

Please sign in to comment.