Skip to content

Commit

Permalink
Apply Channel Clip Delay to all post-GCD interrupts
Browse files Browse the repository at this point in the history
  • Loading branch information
jimmyt857 committed Sep 23, 2023
1 parent 885bbf7 commit c6203e3
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 33 deletions.
60 changes: 31 additions & 29 deletions sim/core/apl.go
Original file line number Diff line number Diff line change
Expand Up @@ -162,37 +162,11 @@ func (apl *APLRotation) DoNextAction(sim *Simulation) {
return
}

i := 0

channeledDot := apl.unit.ChanneledDot
if channeledDot != nil {
if channeledDot.MaxTicksRemaining() == 0 {
// Channel has ended, but apl.unit.ChanneledDot hasn't been cleared yet meaning the aura is still active.
return
}
if apl.unit.ChanneledDot.lastTickTime != sim.CurrentTime {
// Don't allow interupts between ticks, just continue channeling until next tick.
return
}
if !apl.unit.GCD.IsReady(sim) || apl.interruptChannelIf == nil || !apl.interruptChannelIf.GetBool(sim) {
// Continue the channel.
return
}

// Allow next action to interrupt the channel, but if the action is the same action then it still needs to continue.
nextAction := apl.getNextAction(sim)
if nextAction == nil {
return
}
if channelAction, ok := nextAction.impl.(*APLActionChannelSpell); ok && channelAction.spell == channeledDot.Spell {
// Newly selected action is channeling the same spell, so continue the channel.
return
}
channeledDot.Cancel(sim)
nextAction.Execute(sim)
i++
if apl.unit.ChanneledDot != nil {
return
}

i := 0
apl.inLoop = true
for nextAction := apl.getNextAction(sim); nextAction != nil; i, nextAction = i+1, apl.getNextAction(sim) {
if i > 1000 {
Expand Down Expand Up @@ -228,6 +202,34 @@ func (apl *APLRotation) getNextAction(sim *Simulation) *APLAction {
return nil
}

func (apl *APLRotation) shouldInterruptChannel(sim *Simulation) bool {
channeledDot := apl.unit.ChanneledDot
if channeledDot.MaxTicksRemaining() == 0 {
// Channel has ended, but apl.unit.ChanneledDot hasn't been cleared yet meaning the aura is still active.
return false
}
if apl.unit.ChanneledDot.lastTickTime != sim.CurrentTime {
// Don't allow interupts between ticks, just continue channeling until next tick.
return false
}
if !apl.unit.GCD.IsReady(sim) || apl.interruptChannelIf == nil || !apl.interruptChannelIf.GetBool(sim) {
// Continue the channel.
return false
}

// Allow next action to interrupt the channel, but if the action is the same action then it still needs to continue.
nextAction := apl.getNextAction(sim)
if nextAction == nil {
return false
}
if channelAction, ok := nextAction.impl.(*APLActionChannelSpell); ok && channelAction.spell == channeledDot.Spell {
// Newly selected action is channeling the same spell, so continue the channel.
return false
}

return true
}

func APLRotationFromJsonString(jsonString string) *proto.APLRotation {
apl := &proto.APLRotation{}
data := []byte(jsonString)
Expand Down
6 changes: 3 additions & 3 deletions sim/core/dot.go
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,9 @@ func (dot *Dot) TickOnce(sim *Simulation) {
if dot.MaxTicksRemaining() == 0 {
// If this was the last tick, wait 0ms to call the APL after the channel aura fully fades.
dot.Spell.Unit.WaitUntil(sim, sim.CurrentTime+dot.Spell.Unit.ChannelClipDelay)
} else {
// Give the APL settings a chance to interrupt the channel.
dot.Spell.Unit.Rotation.DoNextAction(sim)
} else if dot.Spell.Unit.Rotation.shouldInterruptChannel(sim) {
dot.Cancel(sim)
dot.Spell.Unit.WaitUntil(sim, sim.CurrentTime+dot.Spell.Unit.ChannelClipDelay)
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion sim/priest/mind_sear.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ func (priest *Priest) newMindSearSpell(numTicksIdx int32) *core.Spell {
numTicks := numTicksIdx
flags := core.SpellFlagChanneled
if numTicksIdx == 0 {
numTicks = 3
numTicks = 5
flags |= core.SpellFlagAPL
}

Expand Down

0 comments on commit c6203e3

Please sign in to comment.