Skip to content

Commit

Permalink
Merge branch 'master' into feature/generic-auto-gemming
Browse files Browse the repository at this point in the history
  • Loading branch information
1337LutZ committed Oct 11, 2023
2 parents 360ecd5 + a056c67 commit d00ed0d
Show file tree
Hide file tree
Showing 37 changed files with 2,577 additions and 2,514 deletions.
5 changes: 3 additions & 2 deletions proto/druid.proto
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ message BalanceDruid {
bool use_smart_cooldowns = 9;
bool maintain_faerie_fire = 10;
int32 player_latency = 11;
float okf_ppm = 14;
float okf_ppm = 14 [deprecated = true];

enum EclipsePrio {
Lunar = 0;
Expand All @@ -207,7 +207,8 @@ message BalanceDruid {

message Options {
UnitReference innervate_target = 1;
}
float okf_uptime = 2;
}
Options options = 3;
}

Expand Down
2 changes: 1 addition & 1 deletion sim/common/wotlk/other_effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -360,7 +360,7 @@ func init() {

core.ApplyProcTriggerCallback(&character.Unit, activeAura, core.ProcTrigger{
Callback: core.CallbackOnSpellHitDealt,
ProcMask: core.ProcMaskSpellDamage,
ProcMask: core.ProcMaskSpellOrProc | core.ProcMaskWeaponProc | core.ProcMaskSuppressedProc,
Outcome: core.OutcomeCrit,
Handler: func(sim *core.Simulation, _ *core.Spell, _ *core.SpellResult) {
activeAura.RemoveStack(sim)
Expand Down
12 changes: 6 additions & 6 deletions sim/core/apl_values_spell.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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 {
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand All @@ -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
Expand Down
18 changes: 6 additions & 12 deletions sim/core/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down Expand Up @@ -65,19 +65,17 @@ func (cast *Cast) EffectiveTime() time.Duration {
type CastFunc func(*Simulation, *Unit)
type CastSuccessFunc func(*Simulation, *Unit) bool

func (spell *Spell) castFailureHelper(sim *Simulation, gracefulFailure bool, message string, vals ...interface{}) bool {
reason := fmt.Sprintf(spell.ActionID.String()+" failed to cast: "+message, vals...)
func (spell *Spell) castFailureHelper(sim *Simulation, gracefulFailure bool, message string, vals ...any) bool {
if sim.CurrentTime < 0 && spell.Unit.IsUsingAPL {
spell.Unit.Rotation.ValidationWarning(reason)
return false
spell.Unit.Rotation.ValidationWarning(fmt.Sprintf(spell.ActionID.String()+" failed to cast: "+message, vals...))
} else if gracefulFailure {
if sim.Log != nil && !spell.Flags.Matches(SpellFlagNoLogs) {
spell.Unit.Log(sim, reason)
spell.Unit.Log(sim, fmt.Sprintf(spell.ActionID.String()+" failed to cast: "+message, vals...))
}
return false
} else {
panic(reason)
panic(fmt.Sprintf(spell.ActionID.String()+" failed to cast: "+message, vals...))
}
return false
}

func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
Expand Down Expand Up @@ -112,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) {
Expand Down
15 changes: 11 additions & 4 deletions sim/core/spell.go
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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,
Expand All @@ -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,
Expand All @@ -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 {
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions sim/core/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}

Expand Down
Loading

0 comments on commit d00ed0d

Please sign in to comment.