Skip to content

Commit

Permalink
fix weird tricks + MCD interaction (#3851)
Browse files Browse the repository at this point in the history
  • Loading branch information
lime-green committed Oct 8, 2023
1 parent 5c14fe9 commit 20f14c5
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
8 changes: 0 additions & 8 deletions sim/core/major_cooldown.go
Original file line number Diff line number Diff line change
Expand Up @@ -183,8 +183,6 @@ type majorCooldownManager struct {
// the course of the sim.
majorCooldowns []*MajorCooldown
minReady time.Duration

tryUsing bool
}

func newMajorCooldownManager(cooldowns *proto.Cooldowns) majorCooldownManager {
Expand Down Expand Up @@ -463,7 +461,6 @@ func (mcdm *majorCooldownManager) TryUseCooldowns(sim *Simulation) {
return
}

mcdm.tryUsing = true
restart:
for _, mcd := range mcdm.majorCooldowns {
if !mcd.IsReady(sim) {
Expand All @@ -486,17 +483,12 @@ restart:
goto restart
}
}
mcdm.tryUsing = false

mcdm.minReady = mcdm.majorCooldowns[0].ReadyAt()
}

// This function should be called if the CD for a major cooldown changes outside
// of the TryActivate() call.
func (mcdm *majorCooldownManager) UpdateMajorCooldowns() {
if mcdm.tryUsing {
panic("Do not call UpdateMajorCooldowns while iterating cooldowns in TryUseCooldowns")
}
if len(mcdm.majorCooldowns) == 0 {
mcdm.minReady = NeverExpires
return
Expand Down
1 change: 1 addition & 0 deletions sim/rogue/rogue.go
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,7 @@ func (rogue *Rogue) Initialize() {
if !rogue.IsUsingAPL && rogue.Rotation.TricksOfTheTradeFrequency != proto.Rogue_Rotation_Never && !rogue.HasSetBonus(Tier10, 2) {
rogue.RegisterPrepullAction(-10*time.Second, func(sim *core.Simulation) {
rogue.TricksOfTheTrade.Cast(sim, nil)
rogue.UpdateMajorCooldowns()
})
}
}
Expand Down
5 changes: 3 additions & 2 deletions sim/rogue/tricks_of_the_trade.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,11 @@ func (rogue *Rogue) registerTricksOfTheTradeSpell() {
},
OnGain: func(aura *core.Aura, sim *core.Simulation) {
rogue.TricksOfTheTrade.CD.Set(core.NeverExpires)
rogue.UpdateMajorCooldowns()
},
OnExpire: func(aura *core.Aura, sim *core.Simulation) {
rogue.TricksOfTheTrade.CD.Set(sim.CurrentTime + time.Second*time.Duration(30-5*rogue.Talents.FilthyTricks))
rogue.UpdateMajorCooldowns()
},
})

Expand Down Expand Up @@ -73,9 +75,8 @@ func (rogue *Rogue) registerTricksOfTheTradeSpell() {

if rogue.Rotation.TricksOfTheTradeFrequency != proto.Rogue_Rotation_Never {
// TODO: Support Rogue_Rotation_Once
tricksSpell := rogue.TricksOfTheTrade
rogue.AddMajorCooldown(core.MajorCooldown{
Spell: tricksSpell,
Spell: rogue.TricksOfTheTrade,
Priority: core.CooldownPriorityBloodlust,
Type: core.CooldownTypeDPS,
ShouldActivate: func(sim *core.Simulation, character *core.Character) bool {
Expand Down

0 comments on commit 20f14c5

Please sign in to comment.