Skip to content

Commit

Permalink
flag cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
kayla-glick committed Dec 23, 2024
1 parent cf1e859 commit d2390a6
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 52 deletions.
4 changes: 0 additions & 4 deletions sim/core/apl.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package core

import (
"fmt"
"slices"
"time"

"github.com/wowsims/classic/sim/core/proto"
Expand Down Expand Up @@ -170,9 +169,6 @@ func (rot *APLRotation) reset(sim *Simulation) {
rot.inLoop = false
rot.interruptChannelIf = nil
rot.allowChannelRecastOnInterrupt = false
rot.allowCastWhileChanneling = slices.ContainsFunc(rot.unit.Spellbook, func(spell *Spell) bool {
return spell.Flags.Matches(SpellFlagCastWhileChanneling)
})
for _, action := range rot.allAPLActions() {
action.impl.Reset(sim)
}
Expand Down
42 changes: 1 addition & 41 deletions sim/core/cast.go
Original file line number Diff line number Diff line change
Expand Up @@ -194,20 +194,10 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
}

if hc := spell.Unit.Hardcast; spell.Unit.IsCasting(sim) {
// Attempt to use a queued cast-while-casting spell mid-hard cast
if cwc := spell.Unit.castWhileCastingAction; cwc != nil {
cwc.OnAction(sim)
}

return spell.castFailureHelper(sim, "casting/channeling %v for %s, curTime = %s", hc.ActionID, hc.Expires-sim.CurrentTime, sim.CurrentTime)
}

if dot := spell.Unit.ChanneledDot; spell.Unit.IsChanneling(sim) && !spell.Flags.Matches(SpellFlagCastWhileChanneling) {
// Attempt to use a queued cast-while-casting spell mid-hard cast
if cwc := spell.Unit.castWhileCastingAction; cwc != nil {
cwc.OnAction(sim)
}

if dot := spell.Unit.ChanneledDot; spell.Unit.IsChanneling(sim) {
return spell.castFailureHelper(sim, "channeling %v for %s, curTime = %s", dot.ActionID, dot.expires-sim.CurrentTime, sim.CurrentTime)
}

Expand All @@ -233,36 +223,6 @@ func (spell *Spell) makeCastFunc(config CastConfig) CastSuccessFunc {
spell.Unit.AutoAttacks.StopMeleeUntil(sim, restartMeleeAt, false)
}

// Castable-while-casting spells
if spell.Flags.Matches(SpellFlagCastWhileCasting) {
// Queue cast-while-casting spells to cast 750 ms into the next hard-cast
pa := &PendingAction{
NextActionAt: sim.CurrentTime + GCDDefault/2,
OnAction: func(sim *Simulation) {
spell.LastCastAt = sim.CurrentTime

if sim.Log != nil && !spell.Flags.Matches(SpellFlagNoLogs) {
spell.Unit.Log(sim, "Casting %s (Cost = %0.03f, Cast Time = %s, Effective Time = %s)",
spell.ActionID, max(0, spell.CurCast.Cost), spell.CurCast.CastTime, spell.CurCast.EffectiveTime())
spell.Unit.Log(sim, "Completed cast %s", spell.ActionID)
}

if spell.Cost != nil {
spell.Cost.SpendCost(sim, spell)
}

spell.applyEffects(sim, target)

if !spell.Flags.Matches(SpellFlagNoOnCastComplete) {
spell.Unit.OnCastComplete(sim, spell)
}
},
}
spell.Unit.castWhileCastingAction = pa
sim.AddPendingAction(pa)
return true
}

// Hardcasts
if spell.CurCast.CastTime > 0 {
if sim.Log != nil && !spell.Flags.Matches(SpellFlagNoLogs) {
Expand Down
2 changes: 0 additions & 2 deletions sim/core/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -186,8 +186,6 @@ const (
SpellFlagDefensiveEquipment // Indicates this spell a defensive equippable item activation spell
SpellFlagResetAttackSwing // Indicates this spell resets the melee swing timer.
SpellFlagCastTimeNoGCD // Indicates this spell is off the GCD (e.g. hunter's Auto Shot)
SpellFlagCastWhileCasting // Indicates this spell can be cast while another spell is being cast (e.g. mage's Fire Blast with Overheat rune)
SpellFlagCastWhileChanneling // Indicates this spell can be cast while another spell is being channeled (e.g. spriest's T2.5 4pc set bonus)
SpellFlagPureDot // Indicates this spell is a dot with no initial damage component
SpellFlagPassiveSpell // Indicates this spell is applied/cast as a result of another spell
SpellFlagSuppressWeaponProcs // Indicates this spell cannot proc weapon chance on hits or enchants
Expand Down
4 changes: 2 additions & 2 deletions sim/core/spell.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,15 +521,15 @@ func (spell *Spell) CanCast(sim *Simulation, target *Unit) bool {
}

// While casting no other action is possible except rare cast-while-casting spells
if spell.Unit.IsCasting(sim) && !spell.Flags.Matches(SpellFlagCastWhileCasting) {
if spell.Unit.IsCasting(sim) {
//if sim.Log != nil {
// sim.Log("Cant cast because already casting")
//}
return false
}

// While channeling no other action is possible except rare cast-while-channeling spells
if spell.Unit.IsChanneling(sim) && !spell.Flags.Matches(SpellFlagCastWhileChanneling) {
if spell.Unit.IsChanneling(sim) {
//if sim.Log != nil {
// sim.Log("Cant cast because already channeling")
//}
Expand Down
5 changes: 2 additions & 3 deletions sim/core/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,9 +140,8 @@ type Unit struct {
Hardcast Hardcast

// GCD-related PendingActions.
gcdAction *PendingAction
hardcastAction *PendingAction
castWhileCastingAction *PendingAction
gcdAction *PendingAction
hardcastAction *PendingAction

// Cached mana return values per tick.
manaTickWhileCasting float64
Expand Down

0 comments on commit d2390a6

Please sign in to comment.