Skip to content

Commit

Permalink
Merge pull request #746 from wowsims/revert-745-revert/pr-723
Browse files Browse the repository at this point in the history
[Core] Cooldown, Rounding for Cast Time and GCD
  • Loading branch information
NerdEgghead authored Jul 19, 2024
2 parents 302a772 + d729539 commit ee209e1
Show file tree
Hide file tree
Showing 15 changed files with 5,389 additions and 5,351 deletions.
22 changes: 18 additions & 4 deletions sim/core/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,24 +110,22 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
}

if !config.IgnoreHaste {
spell.CurCast.GCD = max(0, spell.Unit.ApplyCastSpeed(spell.CurCast.GCD))
spell.CurCast.CastTime = spell.Unit.ApplyCastSpeedForSpell(spell.CurCast.CastTime, spell)
spell.CurCast.GCD = max(0, spell.Unit.ApplyCastSpeed(spell.CurCast.GCD)).Round(time.Millisecond)
spell.CurCast.CastTime = spell.Unit.ApplyCastSpeedForSpell(spell.CurCast.CastTime, spell).Round(time.Millisecond)
}

if config.CD.Timer != nil {
// By panicking if spell is on CD, we force each sim to properly check for their own CDs.
if !spell.CD.IsReady(sim) {
return spell.castFailureHelper(sim, "still on cooldown for %s, curTime = %s", spell.CD.TimeToReady(sim), sim.CurrentTime)
}
spell.CD.Set(sim.CurrentTime + spell.CurCast.CastTime + time.Duration(float64(spell.CD.Duration)*spell.CdMultiplier))
}

if config.SharedCD.Timer != nil {
// By panicking if spell is on CD, we force each sim to properly check for their own CDs.
if !spell.SharedCD.IsReady(sim) {
return spell.castFailureHelper(sim, "still on shared cooldown for %s, curTime = %s", spell.SharedCD.TimeToReady(sim), sim.CurrentTime)
}
spell.SharedCD.Set(sim.CurrentTime + spell.CurCast.CastTime + time.Duration(float64(spell.SharedCD.Duration)*spell.CdMultiplier))
}

// By panicking if spell is on CD, we force each sim to properly check for their own CDs.
Expand Down Expand Up @@ -167,6 +165,14 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
spell.Cost.SpendCost(sim, spell)
}

if config.CD.Timer != nil {
spell.CD.Set(sim.CurrentTime + time.Duration(float64(spell.CD.Duration)*spell.CdMultiplier))
}

if config.SharedCD.Timer != nil {
spell.SharedCD.Set(sim.CurrentTime + time.Duration(float64(spell.SharedCD.Duration)*spell.CdMultiplier))
}

spell.applyEffects(sim, target)

if !spell.Flags.Matches(SpellFlagNoOnCastComplete) {
Expand All @@ -191,6 +197,14 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
spell.Cost.SpendCost(sim, spell)
}

if config.CD.Timer != nil {
spell.CD.Set(sim.CurrentTime + time.Duration(float64(spell.CD.Duration)*spell.CdMultiplier))
}

if config.SharedCD.Timer != nil {
spell.SharedCD.Set(sim.CurrentTime + time.Duration(float64(spell.SharedCD.Duration)*spell.CdMultiplier))
}

spell.applyEffects(sim, target)

if !spell.Flags.Matches(SpellFlagNoOnCastComplete) {
Expand Down
1 change: 1 addition & 0 deletions sim/core/gcd.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ func (unit *Unit) newHardcastAction(sim *Simulation) {
if unit.hardcastAction == nil {
pa := &PendingAction{
NextActionAt: unit.Hardcast.Expires,
Priority: ActionPriorityGCD,
OnAction: func(sim *Simulation) {
if hc := &unit.Hardcast; hc.Expires != startingCDTime && hc.Expires <= sim.CurrentTime {
hc.Expires = startingCDTime
Expand Down
Loading

0 comments on commit ee209e1

Please sign in to comment.