Skip to content

Commit

Permalink
Fix auto timer update ordering so that it works intuitively with Time…
Browse files Browse the repository at this point in the history
…ToNextAuto APL value
  • Loading branch information
jimmyt857 committed Oct 13, 2023
1 parent d22cfd9 commit 5cb7121
Show file tree
Hide file tree
Showing 13 changed files with 1,078 additions and 1,069 deletions.
3 changes: 3 additions & 0 deletions sim/core/apl_values_auto_attacks.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,9 @@ func (value *APLValueAutoTimeToNext) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeDuration
}
func (value *APLValueAutoTimeToNext) GetDuration(sim *Simulation) time.Duration {
if sim.Log != nil {
sim.Log("TimeToNextAuto: %s", max(0, value.unit.AutoAttacks.NextAttackAt()-sim.CurrentTime))
}
return max(0, value.unit.AutoAttacks.NextAttackAt()-sim.CurrentTime)
}
func (value *APLValueAutoTimeToNext) String() string {
Expand Down
12 changes: 9 additions & 3 deletions sim/core/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,8 +508,10 @@ func (aa *AutoAttacks) TrySwingMH(sim *Simulation, target *Unit) {

attackSpell := aa.MaybeReplaceMHSwing(sim, aa.MHAuto)

attackSpell.Cast(sim, target)
// Update swing timer BEFORE the cast, so that APL checks for TimeToNextAuto behave correctly
// if the attack causes APL evaluations (e.g. from rage gain).
aa.MainhandSwingAt = sim.CurrentTime + aa.curMHSwingDuration
attackSpell.Cast(sim, target)

if !sim.Options.Interactive {
if aa.unit.IsUsingAPL {
Expand Down Expand Up @@ -537,8 +539,10 @@ func (aa *AutoAttacks) TrySwingOH(sim *Simulation, target *Unit) {
return
}

aa.OHAuto.Cast(sim, target)
// Update swing timer BEFORE the cast, so that APL checks for TimeToNextAuto behave correctly
// if the attack causes APL evaluations (e.g. from rage gain).
aa.OffhandSwingAt = sim.CurrentTime + aa.curOHSwingDuration
aa.OHAuto.Cast(sim, target)

if !sim.Options.Interactive {
if aa.unit.IsUsingAPL {
Expand All @@ -555,8 +559,10 @@ func (aa *AutoAttacks) TrySwingRanged(sim *Simulation, target *Unit) {
return
}

aa.RangedAuto.Cast(sim, target)
// Update swing timer BEFORE the cast, so that APL checks for TimeToNextAuto behave correctly
// if the attack causes APL evaluations.
aa.RangedSwingAt = sim.CurrentTime + aa.RangedSwingSpeed()
aa.RangedAuto.Cast(sim, target)

if !sim.Options.Interactive {
if aa.unit.IsUsingAPL {
Expand Down
4 changes: 2 additions & 2 deletions sim/deathknight/dps/TestUnholy.results
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,8 @@ dps_results: {
dps_results: {
key: "TestUnholy-AllItems-TheTwinBladesofAzzinoth"
value: {
dps: 10596.60128
tps: 6872.43752
dps: 10596.77085
tps: 6872.60709
hps: 304.79181
}
}
Expand Down
6 changes: 3 additions & 3 deletions sim/druid/tank/TestFeralTank.results
Original file line number Diff line number Diff line change
Expand Up @@ -1074,9 +1074,9 @@ dps_results: {
dps_results: {
key: "TestFeralTank-Average-Default"
value: {
dps: 2664.56255
tps: 5648.23342
dtps: 59.71589
dps: 2664.65503
tps: 5648.53713
dtps: 59.70577
}
}
dps_results: {
Expand Down
Loading

0 comments on commit 5cb7121

Please sign in to comment.