diff --git a/sim/core/apl_values_spell.go b/sim/core/apl_values_spell.go index 9ff83a1e67..aca1e8cb85 100644 --- a/sim/core/apl_values_spell.go +++ b/sim/core/apl_values_spell.go @@ -96,8 +96,8 @@ func (rot *APLRotation) newValueSpellCastTime(config *proto.APLValueSpellCastTim func (value *APLValueSpellCastTime) Type() proto.APLValueType { return proto.APLValueType_ValueTypeDuration } -func (value *APLValueSpellCastTime) GetDuration(sim *Simulation) time.Duration { - return value.spell.Unit.ApplyCastSpeedForSpell(value.spell.DefaultCast.CastTime, value.spell) +func (value *APLValueSpellCastTime) GetDuration(_ *Simulation) time.Duration { + return value.spell.CastTime() } func (value *APLValueSpellCastTime) String() string { return fmt.Sprintf("Cast Time(%s)", value.spell.ActionID) @@ -120,7 +120,7 @@ func (rot *APLRotation) newValueSpellChannelTime(config *proto.APLValueSpellChan func (value *APLValueSpellChannelTime) Type() proto.APLValueType { return proto.APLValueType_ValueTypeDuration } -func (value *APLValueSpellChannelTime) GetDuration(sim *Simulation) time.Duration { +func (value *APLValueSpellChannelTime) GetDuration(_ *Simulation) time.Duration { return value.spell.Unit.ApplyCastSpeedForSpell(value.spell.DefaultCast.ChannelTime, value.spell) } func (value *APLValueSpellChannelTime) String() string { @@ -144,7 +144,7 @@ func (rot *APLRotation) newValueSpellTravelTime(config *proto.APLValueSpellTrave func (value *APLValueSpellTravelTime) Type() proto.APLValueType { return proto.APLValueType_ValueTypeDuration } -func (value *APLValueSpellTravelTime) GetDuration(sim *Simulation) time.Duration { +func (value *APLValueSpellTravelTime) GetDuration(_ *Simulation) time.Duration { return value.spell.TravelTime() } func (value *APLValueSpellTravelTime) String() string { @@ -192,7 +192,7 @@ func (rot *APLRotation) newValueSpellIsChanneling(config *proto.APLValueSpellIsC func (value *APLValueSpellIsChanneling) Type() proto.APLValueType { return proto.APLValueType_ValueTypeBool } -func (value *APLValueSpellIsChanneling) GetBool(sim *Simulation) bool { +func (value *APLValueSpellIsChanneling) GetBool(_ *Simulation) bool { return value.spell.Unit.ChanneledDot != nil && value.spell.Unit.ChanneledDot.Spell == value.spell } func (value *APLValueSpellIsChanneling) String() string { @@ -216,7 +216,7 @@ func (rot *APLRotation) newValueSpellChanneledTicks(config *proto.APLValueSpellC func (value *APLValueSpellChanneledTicks) Type() proto.APLValueType { return proto.APLValueType_ValueTypeInt } -func (value *APLValueSpellChanneledTicks) GetInt(sim *Simulation) int32 { +func (value *APLValueSpellChanneledTicks) GetInt(_ *Simulation) int32 { channeledDot := value.spell.Unit.ChanneledDot if channeledDot == nil { return 0 diff --git a/sim/core/cast.go b/sim/core/cast.go index 60714b904b..62e8398829 100644 --- a/sim/core/cast.go +++ b/sim/core/cast.go @@ -34,7 +34,7 @@ type CastConfig struct { CD Cooldown SharedCD Cooldown - GetCastTime func(spell *Spell) time.Duration + CastTime func(spell *Spell) time.Duration } type Cast struct { @@ -110,10 +110,6 @@ 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) { diff --git a/sim/core/spell.go b/sim/core/spell.go index dc0408b849..c3bb6ffc42 100644 --- a/sim/core/spell.go +++ b/sim/core/spell.go @@ -88,6 +88,8 @@ type Spell struct { SharedCD Cooldown ExtraCastCondition CanCastCondition + castTimeFn func(spell *Spell) time.Duration // allows to override CastTime() + // Performs a cast of this spell. castFn CastSuccessFunc @@ -141,8 +143,6 @@ 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) { @@ -185,6 +185,12 @@ func (unit *Unit) RegisterSpell(config SpellConfig) *Spell { panic("Cast.SharedCD w/o Duration specified for spell " + config.ActionID.String()) } + if config.Cast.CastTime == nil { + config.Cast.CastTime = func(spell *Spell) time.Duration { + return spell.Unit.ApplyCastSpeedForSpell(spell.DefaultCast.CastTime, spell) + } + } + spell := &Spell{ ActionID: config.ActionID, Unit: unit, @@ -198,6 +204,8 @@ func (unit *Unit) RegisterSpell(config SpellConfig) *Spell { SharedCD: config.Cast.SharedCD, ExtraCastCondition: config.ExtraCastCondition, + castTimeFn: config.Cast.CastTime, + ApplyEffects: config.ApplyEffects, expectedInitialDamageInternal: config.ExpectedInitialDamage, @@ -220,7 +228,6 @@ func (unit *Unit) RegisterSpell(config SpellConfig) *Spell { splitSpellMetrics: make([][]SpellMetrics, max(1, config.MetricSplits)), RelatedAuras: config.RelatedAuras, - GetCastTime: config.Cast.GetCastTime, } switch { @@ -573,7 +580,7 @@ func (spell *Spell) EffectiveCastTime() time.Duration { // Time until the cast is finished (ignoring GCD) func (spell *Spell) CastTime() time.Duration { - return spell.Unit.ApplyCastSpeedForSpell(spell.DefaultCast.CastTime, spell) + return spell.castTimeFn(spell) } func (spell *Spell) TravelTime() time.Duration { diff --git a/sim/core/unit.go b/sim/core/unit.go index a0775ac226..278769585a 100644 --- a/sim/core/unit.go +++ b/sim/core/unit.go @@ -335,9 +335,6 @@ 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) } diff --git a/sim/hunter/multi_shot.go b/sim/hunter/multi_shot.go index bba28896ad..e0115c6668 100644 --- a/sim/hunter/multi_shot.go +++ b/sim/hunter/multi_shot.go @@ -23,16 +23,19 @@ func (hunter *Hunter) registerMultiShotSpell(timer *core.Timer) { Cast: core.CastConfig{ DefaultCast: core.Cast{ GCD: core.GCDDefault, - CastTime: 1, // Dummy value so core doesn't optimize the cast away + CastTime: time.Millisecond * 500, }, - ModifyCast: func(_ *core.Simulation, _ *core.Spell, cast *core.Cast) { - cast.CastTime = hunter.MultiShotCastTime() + ModifyCast: func(_ *core.Simulation, spell *core.Spell, cast *core.Cast) { + cast.CastTime = spell.CastTime() }, IgnoreHaste: true, // Hunter GCD is locked at 1.5s CD: core.Cooldown{ Timer: timer, Duration: time.Second*10 - core.TernaryDuration(hunter.HasMajorGlyph(proto.HunterMajorGlyph_GlyphOfMultiShot), time.Second*1, 0), }, + CastTime: func(spell *core.Spell) time.Duration { + return time.Duration(float64(spell.DefaultCast.CastTime) / hunter.RangedSwingSpeed()) + }, }, BonusCritRating: 0 + @@ -60,7 +63,3 @@ func (hunter *Hunter) registerMultiShotSpell(timer *core.Timer) { }, }) } - -func (hunter *Hunter) MultiShotCastTime() time.Duration { - return time.Duration(float64(time.Millisecond*500) / hunter.RangedSwingSpeed()) -} diff --git a/sim/hunter/steady_shot.go b/sim/hunter/steady_shot.go index 93ed0bde2f..abcaf4a188 100644 --- a/sim/hunter/steady_shot.go +++ b/sim/hunter/steady_shot.go @@ -60,10 +60,14 @@ func (hunter *Hunter) registerSteadyShotSpell() { Cast: core.CastConfig{ DefaultCast: core.Cast{ GCD: core.GCDDefault, - CastTime: time.Millisecond * 2000, + CastTime: time.Second * 2, }, IgnoreHaste: true, // Hunter GCD is locked at 1.5s - GetCastTime: func(spell *core.Spell) time.Duration { + ModifyCast: func(_ *core.Simulation, spell *core.Spell, cast *core.Cast) { + cast.CastTime = spell.CastTime() + }, + + CastTime: func(spell *core.Spell) time.Duration { return time.Duration(float64(spell.DefaultCast.CastTime) / hunter.RangedSwingSpeed()) }, },