@@ -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.
425426func (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.
430431func (unit * Unit ) HasTemporaryRangedSwingSpeedIncrease () bool {
431- return unit .RangedAttackSpeed != unit .initialRangedSwingSpeed
432+ return unit .rangedAttackSpeed != unit .initialRangedSwingSpeed
432433}
433434
434435func (unit * Unit ) InitialCastSpeed () float64 {
@@ -452,7 +453,6 @@ func (unit *Unit) updateCastSpeed() {
452453 unit .OnCastSpeedChanged [i ](oldCastSpeed , newCastSpeed )
453454 }
454455}
455-
456456func (unit * Unit ) MultiplyCastSpeed (amount float64 ) {
457457 unit .PseudoStats .CastSpeedMultiplier *= amount
458458
@@ -466,12 +466,11 @@ func (unit *Unit) MultiplyCastSpeed(amount float64) {
466466func (unit * Unit ) ApplyCastSpeed (dur time.Duration ) time.Duration {
467467 return time .Duration (float64 (dur ) * unit .CastSpeed )
468468}
469-
470469func (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.
502499func (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
523519func (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 )
0 commit comments