Skip to content

Commit

Permalink
fix APL wait (#3465)
Browse files Browse the repository at this point in the history
* fix APL wait

* fix

* address comments
  • Loading branch information
lime-green authored Aug 16, 2023
1 parent d61f350 commit f715904
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 2 deletions.
4 changes: 4 additions & 0 deletions sim/core/apl.go
Original file line number Diff line number Diff line change
Expand Up @@ -181,6 +181,10 @@ func (apl *APLRotation) DoNextAction(sim *Simulation) {
}

func (apl *APLRotation) getNextAction(sim *Simulation) *APLAction {
if sim.CurrentTime < apl.unit.waitUntilTime {
return nil
}

if apl.strictSequence != nil {
ss := apl.strictSequence.impl.(*APLActionStrictSequence)
if ss.actions[ss.curIdx].IsReady(sim) {
Expand Down
1 change: 0 additions & 1 deletion sim/core/apl_action.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package core

import (
"fmt"

"github.com/wowsims/wotlk/sim/core/proto"
)

Expand Down
16 changes: 15 additions & 1 deletion sim/core/apl_actions_core.go
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,23 @@ func (rot *APLRotation) newActionWait(config *proto.APLActionWait) APLActionImpl
func (action *APLActionWait) IsReady(sim *Simulation) bool {
return action.duration != nil
}

func (action *APLActionWait) Execute(sim *Simulation) {
action.unit.WaitUntil(sim, sim.CurrentTime+action.duration.GetDuration(sim))
waitUntilTime := sim.CurrentTime + action.duration.GetDuration(sim)
action.unit.waitUntilTime = waitUntilTime

if waitUntilTime > action.unit.GCD.ReadyAt() {
action.unit.WaitUntil(sim, waitUntilTime)
return
}
pa := &PendingAction{
Priority: ActionPriorityLow,
OnAction: action.unit.gcdAction.OnAction,
NextActionAt: waitUntilTime,
}
sim.AddPendingAction(pa)
}

func (action *APLActionWait) String() string {
return fmt.Sprintf("Wait(%s)", action.duration)
}
3 changes: 3 additions & 0 deletions sim/core/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ type Unit struct {
waitingForEnergy float64
waitingForMana float64
waitStartTime time.Duration
waitUntilTime time.Duration

// Cached mana return values per tick.
manaTickWhileCasting float64
Expand Down Expand Up @@ -451,6 +452,8 @@ func (unit *Unit) reset(sim *Simulation, agent Agent) {
if unit.Rotation != nil {
unit.Rotation.reset(sim)
}

unit.waitUntilTime = 0
}

func (unit *Unit) startPull(sim *Simulation) {
Expand Down

0 comments on commit f715904

Please sign in to comment.