Skip to content

Commit

Permalink
fix steadyshot cast time (wowsims#3820)
Browse files Browse the repository at this point in the history
  • Loading branch information
lime-green authored Oct 5, 2023
1 parent ed0c98d commit 37f1301
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 7 deletions.
6 changes: 6 additions & 0 deletions sim/core/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@ type CastConfig struct {

CD Cooldown
SharedCD Cooldown

GetCastTime func(spell *Spell) time.Duration
}

type Cast struct {
Expand Down Expand Up @@ -101,6 +103,10 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
spell.CurCast.ChannelTime = spell.Unit.ApplyCastSpeedForSpell(spell.CurCast.ChannelTime, spell)
}

if spell.GetCastTime != nil {
spell.CurCast.CastTime = spell.GetCastTime(spell)
}

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) {
Expand Down
3 changes: 3 additions & 0 deletions sim/core/spell.go
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ type Spell struct {

// Per-target auras that are related to this spell, usually buffs or debuffs applied by the spell.
RelatedAuras []AuraArray

GetCastTime func(spell *Spell) time.Duration
}

func (unit *Unit) OnSpellRegistered(handler SpellRegisteredHandler) {
Expand Down Expand Up @@ -218,6 +220,7 @@ func (unit *Unit) RegisterSpell(config SpellConfig) *Spell {
splitSpellMetrics: make([][]SpellMetrics, max(1, config.MetricSplits)),

RelatedAuras: config.RelatedAuras,
GetCastTime: config.Cast.GetCastTime,
}

switch {
Expand Down
3 changes: 3 additions & 0 deletions sim/core/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,9 @@ func (unit *Unit) ApplyCastSpeed(dur time.Duration) time.Duration {
return time.Duration(float64(dur) * unit.CastSpeed)
}
func (unit *Unit) ApplyCastSpeedForSpell(dur time.Duration, spell *Spell) time.Duration {
if spell.GetCastTime != nil {
return spell.GetCastTime(spell)
}
return time.Duration(float64(dur) * unit.CastSpeed * spell.CastTimeMultiplier)
}

Expand Down
10 changes: 3 additions & 7 deletions sim/hunter/steady_shot.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,10 @@ func (hunter *Hunter) registerSteadyShotSpell() {
GCD: core.GCDDefault,
CastTime: time.Millisecond * 2000,
},
ModifyCast: func(_ *core.Simulation, _ *core.Spell, cast *core.Cast) {
cast.CastTime = hunter.SteadyShotCastTime()
},
IgnoreHaste: true, // Hunter GCD is locked at 1.5s
GetCastTime: func(spell *core.Spell) time.Duration {
return time.Duration(float64(spell.DefaultCast.CastTime) / hunter.RangedSwingSpeed())
},
},

BonusCritRating: 0 +
Expand All @@ -92,7 +92,3 @@ func (hunter *Hunter) registerSteadyShotSpell() {
},
})
}

func (hunter *Hunter) SteadyShotCastTime() time.Duration {
return time.Duration(float64(time.Millisecond*2000) / hunter.RangedSwingSpeed())
}

0 comments on commit 37f1301

Please sign in to comment.