Skip to content

Commit a20126f

Browse files
committed
Revert some of the attack speed changes to not change too much
1 parent 253efb9 commit a20126f

8 files changed

Lines changed: 51 additions & 56 deletions

File tree

sim/core/attack.go

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -496,7 +496,7 @@ func (aa *AutoAttacks) reset(sim *Simulation) {
496496
aa.oh.swingAt = NeverExpires
497497

498498
if aa.AutoSwingMelee {
499-
aa.mh.updateSwingDuration(aa.mh.unit.MeleeAttackSpeed)
499+
aa.mh.updateSwingDuration(aa.mh.unit.SwingSpeed())
500500
aa.mh.swingAt = 0
501501

502502
if aa.IsDualWielding {
@@ -520,7 +520,7 @@ func (aa *AutoAttacks) reset(sim *Simulation) {
520520
aa.ranged.swingAt = NeverExpires
521521

522522
if aa.AutoSwingRanged {
523-
aa.ranged.updateSwingDuration(aa.ranged.unit.RangedAttackSpeed)
523+
aa.ranged.updateSwingDuration(aa.ranged.unit.RangedSwingSpeed())
524524
aa.ranged.swingAt = 0
525525
}
526526
}
@@ -567,7 +567,7 @@ func (aa *AutoAttacks) startPull(sim *Simulation) {
567567

568568
if aa.mh.IsInRange() {
569569
aa.mh.enabled = true
570-
aa.mh.addWeaponAttack(sim, aa.mh.unit.MeleeAttackSpeed)
570+
aa.mh.addWeaponAttack(sim, aa.mh.unit.SwingSpeed())
571571
}
572572
}
573573

@@ -577,7 +577,7 @@ func (aa *AutoAttacks) startPull(sim *Simulation) {
577577
}
578578
if aa.ranged.IsInRange() {
579579
aa.ranged.enabled = true
580-
aa.ranged.addWeaponAttack(sim, aa.ranged.unit.RangedAttackSpeed)
580+
aa.ranged.addWeaponAttack(sim, aa.ranged.unit.RangedSwingSpeed())
581581
}
582582

583583
}
@@ -612,14 +612,14 @@ func (aa *AutoAttacks) EnableMeleeSwing(sim *Simulation) {
612612
aa.mh.swingAt = max(aa.mh.swingAt, sim.CurrentTime, 0)
613613
if aa.mh.IsInRange() && !aa.mh.enabled {
614614
aa.mh.enabled = true
615-
aa.mh.addWeaponAttack(sim, aa.mh.unit.MeleeAttackSpeed)
615+
aa.mh.addWeaponAttack(sim, aa.mh.unit.SwingSpeed())
616616
}
617617

618618
if aa.IsDualWielding && !aa.oh.enabled {
619619
aa.oh.swingAt = max(aa.oh.swingAt, sim.CurrentTime, 0)
620620
if aa.oh.IsInRange() {
621621
aa.oh.enabled = true
622-
aa.oh.addWeaponAttack(sim, aa.mh.unit.MeleeAttackSpeed)
622+
aa.oh.addWeaponAttack(sim, aa.mh.unit.SwingSpeed())
623623
}
624624
}
625625

@@ -641,7 +641,7 @@ func (aa *AutoAttacks) EnableRangedSwing(sim *Simulation) {
641641
aa.ranged.swingAt = max(aa.ranged.swingAt, sim.CurrentTime, 0)
642642
if aa.ranged.IsInRange() {
643643
aa.ranged.enabled = true
644-
aa.ranged.addWeaponAttack(sim, aa.ranged.unit.RangedAttackSpeed)
644+
aa.ranged.addWeaponAttack(sim, aa.ranged.unit.RangedSwingSpeed())
645645
}
646646
}
647647

@@ -697,13 +697,13 @@ func (aa *AutoAttacks) UpdateSwingTimers(sim *Simulation) {
697697
}
698698

699699
if aa.AutoSwingRanged && aa.ranged.enabled {
700-
aa.ranged.updateSwingDuration(aa.ranged.unit.RangedAttackSpeed)
700+
aa.ranged.updateSwingDuration(aa.ranged.unit.RangedSwingSpeed())
701701
// ranged attack speed changes aren't applied mid-"swing"
702702
}
703703

704704
if aa.AutoSwingMelee && aa.mh.enabled {
705705
oldSwingSpeed := aa.mh.curSwingSpeed
706-
aa.mh.updateSwingDuration(aa.mh.unit.MeleeAttackSpeed)
706+
aa.mh.updateSwingDuration(aa.mh.unit.SwingSpeed())
707707
f := oldSwingSpeed / aa.mh.curSwingSpeed
708708

709709
if remainingSwingTime := aa.mh.swingAt - sim.CurrentTime; remainingSwingTime > 0 {

sim/core/character.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -624,8 +624,8 @@ func (character *Character) GetPseudoStatsProto() []float64 {
624624
proto.PseudoStat_PseudoStatRangedSpeedMultiplier: character.PseudoStats.RangedSpeedMultiplier,
625625
proto.PseudoStat_PseudoStatMeleeSpeedMultiplier: character.PseudoStats.MeleeSpeedMultiplier,
626626
proto.PseudoStat_PseudoStatCastSpeedMultiplier: character.PseudoStats.CastSpeedMultiplier,
627-
proto.PseudoStat_PseudoStatMeleeHastePercent: (character.MeleeAttackSpeed - 1) * 100,
628-
proto.PseudoStat_PseudoStatRangedHastePercent: (character.RangedAttackSpeed - 1) * 100,
627+
proto.PseudoStat_PseudoStatMeleeHastePercent: (character.SwingSpeed() - 1) * 100,
628+
proto.PseudoStat_PseudoStatRangedHastePercent: (character.RangedSwingSpeed() - 1) * 100,
629629
proto.PseudoStat_PseudoStatSpellHastePercent: (character.TotalSpellHasteMultiplier() - 1) * 100,
630630

631631
// School-specific fully buffed Hit/Crit are represented as proper Stats in the back-end so

sim/core/unit.go

Lines changed: 34 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -167,8 +167,8 @@ type Unit struct {
167167
manaTickWhileNotCombat float64
168168

169169
CastSpeed float64
170-
MeleeAttackSpeed float64
171-
RangedAttackSpeed float64
170+
meleeAttackSpeed float64
171+
rangedAttackSpeed float64
172172

173173
CurrentTarget *Unit
174174
defaultTarget *Unit
@@ -337,11 +337,12 @@ func (unit *Unit) processDynamicBonus(sim *Simulation, bonus stats.Stats) {
337337
}
338338
}
339339
if bonus[stats.HasteRating] != 0 {
340+
unit.updateAttackSpeed()
341+
unit.AutoAttacks.UpdateSwingTimers(sim)
340342
unit.runicPowerBar.updateRegenTimes(sim)
341343
unit.energyBar.processDynamicHasteRatingChange(sim)
342344
unit.focusBar.processDynamicHasteRatingChange(sim)
343345
unit.updateCastSpeed()
344-
unit.updateAttackSpeed(sim)
345346
}
346347
if bonus[stats.MasteryRating] != 0 {
347348
newMasteryRating := unit.stats[stats.MasteryRating]
@@ -423,12 +424,12 @@ func (unit *Unit) HasTemporarySpellCastSpeedIncrease() bool {
423424

424425
// Returns if melee swings have any temporary increases active.
425426
func (unit *Unit) HasTemporaryMeleeSwingSpeedIncrease() bool {
426-
return unit.MeleeAttackSpeed != unit.initialMeleeSwingSpeed
427+
return unit.meleeAttackSpeed != unit.initialMeleeSwingSpeed
427428
}
428429

429430
// Returns if ranged swings have any temporary increases active.
430431
func (unit *Unit) HasTemporaryRangedSwingSpeedIncrease() bool {
431-
return unit.RangedAttackSpeed != unit.initialRangedSwingSpeed
432+
return unit.rangedAttackSpeed != unit.initialRangedSwingSpeed
432433
}
433434

434435
func (unit *Unit) InitialCastSpeed() float64 {
@@ -452,7 +453,6 @@ func (unit *Unit) updateCastSpeed() {
452453
unit.OnCastSpeedChanged[i](oldCastSpeed, newCastSpeed)
453454
}
454455
}
455-
456456
func (unit *Unit) MultiplyCastSpeed(amount float64) {
457457
unit.PseudoStats.CastSpeedMultiplier *= amount
458458

@@ -466,12 +466,11 @@ func (unit *Unit) MultiplyCastSpeed(amount float64) {
466466
func (unit *Unit) ApplyCastSpeed(dur time.Duration) time.Duration {
467467
return time.Duration(float64(dur) * unit.CastSpeed)
468468
}
469-
470469
func (unit *Unit) ApplyCastSpeedForSpell(dur time.Duration, spell *Spell) time.Duration {
471470
return time.Duration(float64(dur) * unit.CastSpeed * max(0, spell.CastTimeMultiplier))
472471
}
473472

474-
func (unit *Unit) TotalMeleeHasteMultiplier() float64 {
473+
func (unit *Unit) SwingSpeed() float64 {
475474
return unit.PseudoStats.MeleeSpeedMultiplier * (1 + (unit.stats[stats.HasteRating] / (HasteRatingPerHastePercent * 100)))
476475
}
477476

@@ -483,65 +482,59 @@ func (unit *Unit) BlockDamageReduction() float64 {
483482
return unit.PseudoStats.BlockDamageReduction
484483
}
485484

486-
func (unit *Unit) TotalRangedHasteMultiplier() float64 {
485+
func (unit *Unit) RangedSwingSpeed() float64 {
487486
return unit.PseudoStats.RangedSpeedMultiplier * (1 + (unit.stats[stats.HasteRating] / (HasteRatingPerHastePercent * 100)))
488487
}
489488

490-
func (unit *Unit) updateMeleeAttackSpeed(sim *Simulation) {
491-
oldMeleeAttackSpeed := unit.MeleeAttackSpeed
492-
unit.MeleeAttackSpeed = unit.TotalMeleeHasteMultiplier()
493-
494-
unit.AutoAttacks.UpdateSwingTimers(sim)
489+
func (unit *Unit) updateMeleeAttackSpeed() {
490+
oldMeleeAttackSpeed := unit.meleeAttackSpeed
491+
unit.meleeAttackSpeed = unit.SwingSpeed()
495492

496493
for i := range unit.OnMeleeAttackSpeedChanged {
497-
unit.OnMeleeAttackSpeedChanged[i](oldMeleeAttackSpeed, unit.MeleeAttackSpeed)
494+
unit.OnMeleeAttackSpeedChanged[i](oldMeleeAttackSpeed, unit.meleeAttackSpeed)
498495
}
499496
}
500497

501498
// MultiplyMeleeSpeed will alter the attack speed multiplier and change swing speed of all autoattack swings in progress.
502499
func (unit *Unit) MultiplyMeleeSpeed(sim *Simulation, amount float64) {
503500
unit.PseudoStats.MeleeSpeedMultiplier *= amount
504501

502+
unit.updateMeleeAttackSpeed()
503+
505504
for _, pet := range unit.DynamicMeleeSpeedPets {
506505
pet.dynamicMeleeSpeedInheritance(amount)
507506
}
508-
509-
unit.updateMeleeAttackSpeed(sim)
507+
unit.AutoAttacks.UpdateSwingTimers(sim)
510508
}
511509

512-
func (unit *Unit) updateRangedAttackSpeed(sim *Simulation) {
513-
oldRangedAttackSpeed := unit.RangedAttackSpeed
514-
unit.RangedAttackSpeed = unit.TotalRangedHasteMultiplier()
515-
516-
unit.AutoAttacks.UpdateSwingTimers(sim)
510+
func (unit *Unit) updateRangedAttackSpeed() {
511+
oldRangedAttackSpeed := unit.rangedAttackSpeed
512+
unit.rangedAttackSpeed = unit.RangedSwingSpeed()
517513

518514
for i := range unit.OnRangedAttackSpeedChanged {
519-
unit.OnRangedAttackSpeedChanged[i](oldRangedAttackSpeed, unit.RangedAttackSpeed)
515+
unit.OnRangedAttackSpeedChanged[i](oldRangedAttackSpeed, unit.rangedAttackSpeed)
520516
}
521517
}
522518

523519
func (unit *Unit) MultiplyRangedSpeed(sim *Simulation, amount float64) {
524520
unit.PseudoStats.RangedSpeedMultiplier *= amount
525-
unit.updateRangedAttackSpeed(sim)
521+
unit.updateRangedAttackSpeed()
522+
unit.AutoAttacks.UpdateSwingTimers(sim)
526523
}
527524

528-
func (unit *Unit) updateAttackSpeed(sim *Simulation) {
529-
oldMeleeAttackSpeed := unit.MeleeAttackSpeed
530-
oldRangedAttackSpeed := unit.RangedAttackSpeed
525+
func (unit *Unit) updateAttackSpeed() {
526+
oldMeleeAttackSpeed := unit.meleeAttackSpeed
527+
oldRangedAttackSpeed := unit.rangedAttackSpeed
531528

532-
unit.MeleeAttackSpeed = unit.TotalMeleeHasteMultiplier()
533-
unit.RangedAttackSpeed = unit.TotalRangedHasteMultiplier()
534-
535-
if sim != nil {
536-
unit.AutoAttacks.UpdateSwingTimers(sim)
537-
}
529+
unit.meleeAttackSpeed = unit.SwingSpeed()
530+
unit.rangedAttackSpeed = unit.RangedSwingSpeed()
538531

539532
for i := range unit.OnMeleeAttackSpeedChanged {
540-
unit.OnMeleeAttackSpeedChanged[i](oldMeleeAttackSpeed, unit.MeleeAttackSpeed)
533+
unit.OnMeleeAttackSpeedChanged[i](oldMeleeAttackSpeed, unit.meleeAttackSpeed)
541534
}
542535

543536
for i := range unit.OnRangedAttackSpeedChanged {
544-
unit.OnRangedAttackSpeedChanged[i](oldRangedAttackSpeed, unit.RangedAttackSpeed)
537+
unit.OnRangedAttackSpeedChanged[i](oldRangedAttackSpeed, unit.rangedAttackSpeed)
545538
}
546539
}
547540

@@ -550,11 +543,12 @@ func (unit *Unit) MultiplyAttackSpeed(sim *Simulation, amount float64) {
550543
unit.PseudoStats.MeleeSpeedMultiplier *= amount
551544
unit.PseudoStats.RangedSpeedMultiplier *= amount
552545

546+
unit.updateAttackSpeed()
547+
553548
for _, pet := range unit.DynamicMeleeSpeedPets {
554549
pet.dynamicMeleeSpeedInheritance(amount)
555550
}
556-
557-
unit.updateAttackSpeed(sim)
551+
unit.AutoAttacks.UpdateSwingTimers(sim)
558552
}
559553

560554
// Helper for multiplying resource generation speed
@@ -618,15 +612,15 @@ func (unit *Unit) finalize() {
618612
unit.defaultTarget = unit.CurrentTarget
619613
unit.applyParryHaste()
620614
unit.updateCastSpeed()
621-
unit.updateAttackSpeed(nil)
615+
unit.updateAttackSpeed()
622616
unit.initMovement()
623617

624618
// All stats added up to this point are part of the 'initial' stats.
625619
unit.initialStatsWithoutDeps = unit.stats
626620
unit.initialPseudoStats = unit.PseudoStats
627621
unit.initialCastSpeed = unit.CastSpeed
628-
unit.initialMeleeSwingSpeed = unit.MeleeAttackSpeed
629-
unit.initialRangedSwingSpeed = unit.RangedAttackSpeed
622+
unit.initialMeleeSwingSpeed = unit.SwingSpeed()
623+
unit.initialRangedSwingSpeed = unit.RangedSwingSpeed()
630624

631625
unit.StatDependencyManager.FinalizeStatDeps()
632626
unit.initialStats = unit.ApplyStatDependencies(unit.initialStatsWithoutDeps)

sim/hunter/cobra_shot.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,8 @@ func (hunter *Hunter) registerCobraShotSpell() {
3131
cast.CastTime = spell.CastTime()
3232
},
3333
CastTime: func(spell *core.Spell) time.Duration {
34-
return time.Duration(float64(spell.DefaultCast.CastTime) / hunter.RangedAttackSpeed)
34+
ss := hunter.RangedSwingSpeed()
35+
return time.Duration(float64(spell.DefaultCast.CastTime) / ss)
3536
},
3637
},
3738
DamageMultiplier: 0.77,

sim/hunter/marksmanship/aimed_shot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (mmHunter *MarksmanshipHunter) registerAimedShotSpell() {
3434
},
3535

3636
CastTime: func(spell *core.Spell) time.Duration {
37-
return time.Duration(float64(spell.DefaultCast.CastTime) / mmHunter.RangedAttackSpeed)
37+
return time.Duration(float64(spell.DefaultCast.CastTime) / mmHunter.RangedSwingSpeed())
3838
},
3939
},
4040
DamageMultiplier: 4.5,

sim/hunter/powershot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ func (hunter *Hunter) registerPowerShotSpell() {
3535
},
3636

3737
CastTime: func(spell *core.Spell) time.Duration {
38-
return time.Duration(float64(spell.DefaultCast.CastTime) / hunter.RangedAttackSpeed)
38+
return time.Duration(float64(spell.DefaultCast.CastTime) / hunter.RangedSwingSpeed())
3939
},
4040
CD: core.Cooldown{
4141
Timer: hunter.NewTimer(),

sim/hunter/steady_shot.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (hunter *Hunter) registerSteadyShotSpell() {
3434
},
3535

3636
CastTime: func(spell *core.Spell) time.Duration {
37-
return time.Duration(float64(spell.DefaultCast.CastTime) / hunter.RangedAttackSpeed)
37+
return time.Duration(float64(spell.DefaultCast.CastTime) / hunter.RangedSwingSpeed())
3838
},
3939
},
4040
BonusCritPercent: 0,

sim/paladin/sanctity_of_battle.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (paladin *Paladin) registerSanctityOfBattle() {
5252
ActionID: core.ActionID{SpellID: 25956},
5353

5454
OnGain: func(aura *core.Aura, sim *core.Simulation) {
55-
updateFloatValue(paladin.MeleeAttackSpeed)
55+
updateFloatValue(paladin.SwingSpeed())
5656
cooldownMod.Activate()
5757
},
5858
OnExpire: func(aura *core.Aura, sim *core.Simulation) {

0 commit comments

Comments
 (0)