Skip to content

Commit

Permalink
Keep Energy and Focus tick randomized during reset actions.
Browse files Browse the repository at this point in the history
 On branch feature/add-trinket-swapping
 Changes to be committed:
	modified:   sim/core/energy.go
	modified:   sim/core/focus.go
	modified:   sim/death_knight/unholy/TestUnholy.results
	modified:   sim/hunter/beast_mastery/TestBM.results
	modified:   sim/rogue/combat/TestCombat.results
	modified:   sim/rogue/subtlety/TestSubtlety.results
  • Loading branch information
NerdEgghead committed Jan 7, 2025
1 parent fb0d505 commit 09ba41c
Show file tree
Hide file tree
Showing 6 changed files with 1,709 additions and 1,680 deletions.
23 changes: 22 additions & 1 deletion sim/core/energy.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,20 @@ func (eb *energyBar) ComboPoints() int32 {
return eb.comboPoints
}

func (eb *energyBar) IsReset(sim *Simulation) bool {
return (eb.nextEnergyTick != 0) && (eb.nextEnergyTick - sim.CurrentTime <= eb.EnergyTickDuration)
}

func (eb *energyBar) IsTicking(sim *Simulation) bool {
return eb.IsReset(sim) && (sim.CurrentTime <= eb.nextEnergyTick)
}

// Gives an immediate partial energy tick and restarts the tick timer.
func (eb *energyBar) ResetEnergyTick(sim *Simulation) {
if !eb.IsTicking(sim) {
return
}

timeSinceLastTick := max(sim.CurrentTime-(eb.NextEnergyTickAt()-eb.EnergyTickDuration), 0)
partialTickAmount := (eb.EnergyPerTick * eb.hasteRatingMultiplier * eb.energyRegenMultiplier) * (float64(timeSinceLastTick) / float64(eb.EnergyTickDuration))
eb.AddEnergy(sim, partialTickAmount, eb.regenMetrics)
Expand All @@ -130,7 +142,16 @@ func (eb *energyBar) processDynamicHasteRatingChange(sim *Simulation) {

// Used for dynamic updates to maximum Energy, such as from the Druid Primal Madness talent
func (eb *energyBar) UpdateMaxEnergy(sim *Simulation, bonusEnergy float64, metrics *ResourceMetrics) {
// Reset tick timer first so that Energy is properly zeroed out when bonusEnergy < -currentEnergy
if !eb.IsReset(sim) {
eb.maxEnergy += bonusEnergy
} else {
eb.updateMaxEnergyInternal(sim, bonusEnergy, metrics)
}
}

func (eb *energyBar) updateMaxEnergyInternal(sim *Simulation, bonusEnergy float64, metrics *ResourceMetrics) {
// Reset tick timer first so that Energy is properly zeroed out when
// bonusEnergy < -currentEnergy.
eb.ResetEnergyTick(sim)

eb.maxEnergy += bonusEnergy
Expand Down
8 changes: 8 additions & 0 deletions sim/core/focus.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,16 @@ func (fb *focusBar) SpendFocus(sim *Simulation, amount float64, metrics *Resourc
fb.currentFocus = newFocus
}

func (fb *focusBar) IsTicking(sim *Simulation) bool {
return (fb.nextFocusTick != 0) && (sim.CurrentTime <= fb.nextFocusTick) && (fb.nextFocusTick - sim.CurrentTime <= fb.focusTickDuration)
}

// Gives an immediate partial Focus tick and restarts the tick timer.
func (fb *focusBar) ResetFocusTick(sim *Simulation) {
if !fb.IsTicking(sim) {
return
}

timeSinceLastTick := max(sim.CurrentTime-(fb.NextFocusTickAt()-fb.focusTickDuration), 0)
partialTickAmount := fb.FocusRegenPerSecond() * timeSinceLastTick.Seconds()
fb.AddFocus(sim, partialTickAmount, fb.regenMetrics)
Expand Down
8 changes: 4 additions & 4 deletions sim/death_knight/unholy/TestUnholy.results
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,7 @@ dps_results: {
value: {
dps: 43120.17978
tps: 32013.58168
hps: 601.25406
hps: 601.25407
}
}
dps_results: {
Expand Down Expand Up @@ -1302,9 +1302,9 @@ dps_results: {
dps_results: {
key: "TestUnholy-AllItems-PetrifiedPickledEgg-232014"
value: {
dps: 39594.5399
tps: 29368.10418
hps: 651.99472
dps: 39593.05402
tps: 29369.14359
hps: 652.77837
}
}
dps_results: {
Expand Down
24 changes: 12 additions & 12 deletions sim/hunter/beast_mastery/TestBM.results
Original file line number Diff line number Diff line change
Expand Up @@ -683,8 +683,8 @@ dps_results: {
dps_results: {
key: "TestBM-AllItems-GaleofShadows-56138"
value: {
dps: 24296.61326
tps: 15281.99504
dps: 24278.5094
tps: 15265.58579
}
}
dps_results: {
Expand All @@ -704,8 +704,8 @@ dps_results: {
dps_results: {
key: "TestBM-AllItems-Gladiator'sPursuit"
value: {
dps: 22537.04644
tps: 14217.96817
dps: 22547.92184
tps: 14213.6985
}
}
dps_results: {
Expand Down Expand Up @@ -795,8 +795,8 @@ dps_results: {
dps_results: {
key: "TestBM-AllItems-HeartofSolace-55868"
value: {
dps: 24296.61326
tps: 15281.99504
dps: 24278.5094
tps: 15265.58579
}
}
dps_results: {
Expand Down Expand Up @@ -1061,8 +1061,8 @@ dps_results: {
dps_results: {
key: "TestBM-AllItems-Lightning-ChargedBattlegear"
value: {
dps: 24565.79227
tps: 15458.02105
dps: 24566.93284
tps: 15458.194
}
}
dps_results: {
Expand Down Expand Up @@ -1864,8 +1864,8 @@ dps_results: {
dps_results: {
key: "TestBM-AllItems-Val'anyr,HammerofAncientKings-46017"
value: {
dps: 23762.51314
tps: 15020.37497
dps: 23776.34089
tps: 15027.1501
}
}
dps_results: {
Expand Down Expand Up @@ -2186,8 +2186,8 @@ dps_results: {
dps_results: {
key: "TestBM-Average-Default"
value: {
dps: 25502.56838
tps: 16070.8061
dps: 25502.44332
tps: 16070.84897
}
}
dps_results: {
Expand Down
Loading

0 comments on commit 09ba41c

Please sign in to comment.