Skip to content

Commit

Permalink
[core] drive-by: make RageBar's OnSpellHit() slightly more efficient
Browse files Browse the repository at this point in the history
[core] GracefulCastCDFailures pseudostat removed...
[dk] ... rotations changed to check CDs before casting
[dk/core] replace CopyRunicPowerBar() with a light-weight Predictor class, so there's no more gating on "isACopy" in RunicPowerBar
[dk/core] remove RuneMeta.lastSpendTime
[dk/core] more RunicPowerBar cleanup
[dk/core] replace OnRuneSpend and the various OnXXXRuneGain callbacks by OnRuneChange
[dk/core] fix: spending death rune wasn't counting towards OnRuneSpend effects
[dk/core] add RuneChangeType flags to OnRuneChange event, and have the Cast & Refund type methods call OnRuneChange only once
  • Loading branch information
vigo2 committed Sep 27, 2023
1 parent 28f44a0 commit 8f045b9
Show file tree
Hide file tree
Showing 19 changed files with 416 additions and 453 deletions.
24 changes: 0 additions & 24 deletions sim/core/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -108,12 +108,6 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
if config.CD.Timer != nil {
// By panicking if spell is on CD, we force each sim to properly check for their own CDs.
if !spell.CD.IsReady(sim) {
if spell.Unit.PseudoStats.GracefulCastCDFailures {
if sim.Log != nil {
sim.Log("Failed cast because of CD")
}
return false
}
panic(fmt.Sprintf("Trying to cast %s but is still on cooldown for %s, curTime = %s", spell.ActionID, spell.CD.TimeToReady(sim), sim.CurrentTime))
}
spell.CD.Set(sim.CurrentTime + spell.CurCast.CastTime + spell.CD.Duration)
Expand All @@ -122,12 +116,6 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
if config.SharedCD.Timer != nil {
// By panicking if spell is on CD, we force each sim to properly check for their own CDs.
if !spell.SharedCD.IsReady(sim) {
if spell.Unit.PseudoStats.GracefulCastCDFailures {
if sim.Log != nil {
sim.Log("Failed cast because of SharedCD")
}
return false
}
panic(fmt.Sprintf("Trying to cast %s but is still on shared cooldown for %s, curTime = %s", spell.ActionID, spell.SharedCD.TimeToReady(sim), sim.CurrentTime))
}
spell.SharedCD.Set(sim.CurrentTime + spell.CurCast.CastTime + spell.SharedCD.Duration)
Expand Down Expand Up @@ -221,12 +209,6 @@ func (spell *Spell) makeCastFuncSimple() CastSuccessFunc {
if spell.CD.Timer != nil {
// By panicking if spell is on CD, we force each sim to properly check for their own CDs.
if !spell.CD.IsReady(sim) {
if spell.Unit.PseudoStats.GracefulCastCDFailures {
if sim.Log != nil {
sim.Log("Failed cast because of CD")
}
return false
}
panic(fmt.Sprintf("Trying to cast %s but is still on cooldown for %s, curTime = %s", spell.ActionID, spell.CD.TimeToReady(sim), sim.CurrentTime))
}

Expand All @@ -236,12 +218,6 @@ func (spell *Spell) makeCastFuncSimple() CastSuccessFunc {
if spell.SharedCD.Timer != nil {
// By panicking if spell is on CD, we force each sim to properly check for their own CDs.
if !spell.SharedCD.IsReady(sim) {
if spell.Unit.PseudoStats.GracefulCastCDFailures {
if sim.Log != nil {
sim.Log("Failed cast because of SharedCD")
}
return false
}
panic(fmt.Sprintf("Trying to cast %s but is still on shared cooldown for %s, curTime = %s", spell.ActionID, spell.SharedCD.TimeToReady(sim), sim.CurrentTime))
}

Expand Down
19 changes: 5 additions & 14 deletions sim/core/rage.go
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,17 @@ func (unit *Unit) EnableRageBar(options RageBarOptions, onRageGain OnRageGain) {
if result.Outcome.Matches(OutcomeMiss) {
return
}
if !spell.ProcMask.Matches(ProcMaskMelee) {
return
}
if !spell.ProcMask.Matches(ProcMaskWhiteHit) {
return
}

// Need separate check to exclude auto replacers (e.g. Heroic Strike and Cleave).
if spell.ProcMask.Matches(ProcMaskMeleeMHSpecial) {
return
}

var hitFactor float64
var speed float64
if spell.IsMH() {
if spell.ProcMask == ProcMaskMeleeMHAuto {
hitFactor = 3.5
speed = options.MHSwingSpeed
} else {
} else if spell.ProcMask == ProcMaskMeleeOHAuto {
hitFactor = 1.75
speed = options.OHSwingSpeed
} else {
return
}

if result.Outcome.Matches(OutcomeCrit) {
Expand Down Expand Up @@ -162,7 +153,7 @@ func (rb *rageBar) SpendRage(sim *Simulation, amount float64, metrics *ResourceM
rb.currentRage = newRage
}

func (rb *rageBar) reset(sim *Simulation) {
func (rb *rageBar) reset(_ *Simulation) {
if rb.unit == nil {
return
}
Expand Down
Loading

0 comments on commit 8f045b9

Please sign in to comment.