Skip to content

Commit

Permalink
[dk] prevent "resetEffects" leak when using APL rotations (plus refac…
Browse files Browse the repository at this point in the history
…toring for a little less reset() work)
  • Loading branch information
vigo2 committed Sep 23, 2023
1 parent 6ed2bd8 commit 3f7fae1
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 50 deletions.
27 changes: 17 additions & 10 deletions sim/deathknight/dps/dps_deathknight.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ type DpsDeathknight struct {
CustomRotation *common.CustomRotation

Rotation *proto.Deathknight_Rotation

rotationSetup func()
}

func NewDpsDeathknight(character core.Character, player *proto.Player) *DpsDeathknight {
Expand Down Expand Up @@ -154,41 +156,43 @@ func (dk *DpsDeathknight) SetupRotations() {
if dk.CustomRotation == nil || dk.Rotation.FrostRotationType == proto.Deathknight_Rotation_SingleTarget {
dk.Rotation.FrostRotationType = proto.Deathknight_Rotation_SingleTarget
if fr > uh && fr > bl {
// AotD as major CD doesnt work well with frost
// AotD as major CD doesn't work well with frost
if dk.Inputs.ArmyOfTheDeadType == proto.Deathknight_Rotation_AsMajorCd {
dk.Inputs.ArmyOfTheDeadType = proto.Deathknight_Rotation_PreCast
dk.Rotation.HoldErwArmy = false
}
if bl > uh {
if dk.Rotation.DesyncRotation {
dk.setupFrostSubBloodDesyncOpener()
dk.rotationSetup = dk.setupFrostSubBloodDesyncOpener
} else if dk.Rotation.UseEmpowerRuneWeapon {
dk.setupFrostSubBloodERWOpener()
dk.rotationSetup = dk.setupFrostSubBloodERWOpener
} else {
dk.setupFrostSubBloodNoERWOpener()
dk.rotationSetup = dk.setupFrostSubBloodNoERWOpener
}
} else {
dk.Rotation.FrostRotationType = proto.Deathknight_Rotation_SingleTarget
if dk.Rotation.UseEmpowerRuneWeapon {
dk.setupFrostSubUnholyERWOpener()
dk.rotationSetup = dk.setupFrostSubUnholyERWOpener
} else {
// TODO you can't unh sub without ERW in the opener...yet
dk.Rotation.UseEmpowerRuneWeapon = true
dk.setupFrostSubUnholyERWOpener()
dk.rotationSetup = dk.setupFrostSubUnholyERWOpener
}
}
} else if uh > fr && uh > bl {
dk.setupUnholyRotations()
dk.rotationSetup = dk.setupUnholyRotations
} else if bl > fr && bl > uh {
if dk.Inputs.ArmyOfTheDeadType == proto.Deathknight_Rotation_AsMajorCd {
dk.Inputs.ArmyOfTheDeadType = proto.Deathknight_Rotation_PreCast
dk.Rotation.HoldErwArmy = false
}
dk.setupBloodRotations()
dk.rotationSetup = dk.setupBloodRotations
}
} else {
dk.setupCustomRotations()
dk.rotationSetup = dk.setupCustomRotations
}

dk.rotationSetup()
}

func (dk *DpsDeathknight) GetDeathknight() *deathknight.Deathknight {
Expand All @@ -202,6 +206,8 @@ func (dk *DpsDeathknight) Initialize() {
dk.br.Initialize(dk)
dk.fr.Initialize(dk)
dk.ur.Initialize(dk)

dk.SetupRotations()
}

func (dk *DpsDeathknight) setupGargProcTrackers() {
Expand Down Expand Up @@ -517,7 +523,8 @@ func (dk *DpsDeathknight) Reset(sim *core.Simulation) {
dk.fr.Reset(sim)
dk.ur.Reset(sim)

dk.SetupRotations()
dk.RotationSequence.Clear()
dk.rotationSetup()

dk.Presence = deathknight.UnsetPresence

Expand Down
9 changes: 2 additions & 7 deletions sim/deathknight/rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
"github.com/wowsims/wotlk/sim/core"
)

func (dk *Deathknight) OnAutoAttack(sim *core.Simulation, spell *core.Spell) {
func (dk *Deathknight) OnAutoAttack(_ *core.Simulation, _ *core.Spell) {
}

func (dk *Deathknight) OnGCDReady(sim *core.Simulation) {
Expand Down Expand Up @@ -218,12 +218,7 @@ func (dk *Deathknight) RotationActionCallback_RD(sim *core.Simulation, target *c
return -1
}

func (dk *Deathknight) RotationActionCallback_Reset(sim *core.Simulation, target *core.Unit, s *Sequence) time.Duration {
s.Reset()
return -1
}

func (s *Sequence) DoAction(sim *core.Simulation, target *core.Unit, dk *Deathknight) time.Duration {
func (s *Sequence) DoAction(sim *core.Simulation, target *core.Unit, _ *Deathknight) time.Duration {
action := s.actions[s.idx]
return action(sim, target, s)
}
Expand Down
40 changes: 7 additions & 33 deletions sim/deathknight/rotation_helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,32 +10,15 @@ import (
// return duration is an optional wait time
type RotationAction func(sim *core.Simulation, target *core.Unit, s *Sequence) time.Duration

func TernaryRotationAction(condition bool, t RotationAction, f RotationAction) RotationAction {
if condition {
return t
} else {
return f
}
}

// Add your UH rotation Actions here and then on the DoNext function

type Sequence struct {
idx int
numActions int
actions []RotationAction
idx int
actions []RotationAction
}

func (s *Sequence) IsOngoing() bool {
return s.idx < s.numActions
}

func (s *Sequence) RemainingActions() int {
return (s.numActions - 1) - s.idx
}

func (s *Sequence) Reset() {
s.idx = 0
return s.idx < len(s.actions)
}

func (s *Sequence) Advance() {
Expand All @@ -48,32 +31,23 @@ func (s *Sequence) ConditionalAdvance(condition bool) {
}
}

func (s *Sequence) GetNextAction() RotationAction {
if s.idx+1 < s.numActions {
return s.actions[s.idx+1]
} else {
return nil
}
}

func (s *Sequence) NewAction(action RotationAction) *Sequence {
s.actions = append(s.actions, action)
s.numActions += 1
return s
}

func (s *Sequence) Clear() *Sequence {
s.actions = s.actions[:0]
s.numActions = 0
s.idx = 0
return s
}

type RotationHelper struct {
RotationSequence *Sequence

LastOutcome core.HitOutcome
LastCast *core.Spell
NextCast *core.Spell
LastOutcome core.HitOutcome
LastCast *core.Spell
NextCast *core.Spell

AoESpellNumTargetsHit int32
}

0 comments on commit 3f7fae1

Please sign in to comment.