Skip to content

Commit

Permalink
fix druid errors
Browse files Browse the repository at this point in the history
  • Loading branch information
kayla-glick committed Dec 23, 2024
1 parent afaa298 commit 61a66a3
Show file tree
Hide file tree
Showing 9 changed files with 14 additions and 136 deletions.
3 changes: 0 additions & 3 deletions proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,6 @@ message APLValue {
APLValueTotemRemainingTime totem_remaining_time = 49;
// Druid
APLValueCatExcessEnergy cat_excess_energy = 52;
APLValueCatNewSavageRoarDuration cat_new_savage_roar_duration = 61;
// Warlock
APLValueWarlockShouldRecastDrainSoul warlock_should_recast_drain_soul = 59;
APLValueWarlockShouldRefreshCorruption warlock_should_refresh_corruption = 60;
Expand Down Expand Up @@ -518,8 +517,6 @@ message APLValueTotemRemainingTime {
}
message APLValueCatExcessEnergy {
}
message APLValueCatNewSavageRoarDuration {
}
message APLValueWarlockShouldRecastDrainSoul {
}
message APLValueWarlockShouldRefreshCorruption {
Expand Down
4 changes: 1 addition & 3 deletions sim/druid/druid.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package druid

import (
"time"

"github.com/wowsims/classic/sim/common/guardians"
"github.com/wowsims/classic/sim/core"
"github.com/wowsims/classic/sim/core/proto"
Expand Down Expand Up @@ -92,7 +90,7 @@ type Druid struct {
PredatoryInstinctsAura *core.Aura
TigersFuryAura *core.Aura

BleedCategories core.ExclusiveCategoryArray
BleedCategories core.ExclusiveCategoryArray

form DruidForm
disabledMCDs []*core.MajorCooldown
Expand Down
25 changes: 1 addition & 24 deletions sim/druid/feral/apl_values.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ func (cat *FeralDruid) NewAPLValue(rot *core.APLRotation, config *proto.APLValue
switch config.Value.(type) {
case *proto.APLValue_CatExcessEnergy:
return cat.newValueCatExcessEnergy(rot, config.GetCatExcessEnergy())
case *proto.APLValue_CatNewSavageRoarDuration:
return cat.newValueCatNewSavageRoarDuration(rot, config.GetCatNewSavageRoarDuration())
default:
return nil
}
Expand Down Expand Up @@ -72,27 +70,6 @@ func (value *APLValueCatExcessEnergy) String() string {
return "Cat Excess Energy()"
}

type APLValueCatNewSavageRoarDuration struct {
core.DefaultAPLValueImpl
cat *FeralDruid
}

func (cat *FeralDruid) newValueCatNewSavageRoarDuration(rot *core.APLRotation, config *proto.APLValueCatNewSavageRoarDuration) core.APLValue {
return &APLValueCatNewSavageRoarDuration{
cat: cat,
}
}
func (value *APLValueCatNewSavageRoarDuration) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeDuration
}
func (value *APLValueCatNewSavageRoarDuration) GetDuration(sim *core.Simulation) time.Duration {
cat := value.cat
return cat.SavageRoarDurationTable[cat.ComboPoints()]
}
func (value *APLValueCatNewSavageRoarDuration) String() string {
return "New Savage Roar Duration()"
}

func (cat *FeralDruid) NewAPLAction(rot *core.APLRotation, config *proto.APLAction) core.APLActionImpl {
switch config.Action.(type) {
case *proto.APLAction_CatOptimalRotationAction:
Expand Down Expand Up @@ -131,7 +108,7 @@ func (action *APLActionCatOptimalRotationAction) Execute(sim *core.Simulation) {

// If a melee swing resulted in an Omen or Wild Strikes proc, then schedule the
// next player decision based on latency.
if (cat.Talents.OmenOfClarity && cat.ClearcastingAura.RemainingDuration(sim) == cat.ClearcastingAura.Duration) || (cat.WildStrikesBuffAura != nil && cat.WildStrikesBuffAura.RemainingDuration(sim) == cat.WildStrikesBuffAura.Duration) {
if cat.Talents.OmenOfClarity && cat.ClearcastingAura.RemainingDuration(sim) == cat.ClearcastingAura.Duration {
// Kick gcd loop, also need to account for any gcd 'left'
// otherwise it breaks gcd logic
kickTime := max(cat.NextGCDAt(), sim.CurrentTime+cat.latency)
Expand Down
101 changes: 7 additions & 94 deletions sim/druid/feral/rotation.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@ type FeralDruidRotation struct {
MinCombosForRip int32
MaxWaitTime time.Duration
MaintainFaerieFire bool
UseSavageRoar bool
UseShredTrick bool
UseRipTrick bool
}
Expand Down Expand Up @@ -94,34 +93,12 @@ func (cat *FeralDruid) timeToCast(numSpecials int32) time.Duration {
return core.DurationFromSeconds(numPowershiftedSpecials*2.0 + numOomSpecials*4.0)
}

func (cat *FeralDruid) canRip(sim *core.Simulation, isTrick bool, usingRoar bool) bool {
func (cat *FeralDruid) canRip(sim *core.Simulation, isTrick bool) bool {
if cat.Rip.CurDot().IsActive() {
return false
}
// Allow Rip if conservative napkin math estimate says that we can cast the Rip and then build 5 Combo Points in time before the current Savage Roar expires.
var roarDur time.Duration

if usingRoar {
roarDur = cat.SavageRoarAura.RemainingDuration(sim)
} else {
roarDur = core.NeverExpires
}

fightDur := sim.GetRemainingDuration()
remainingFightTimeAfterRoar := fightDur - roarDur

// solve "remainingFightTimeAfterRoar = 5*roarCP+9" for roarCP
// add 1 to round up instead of down
roarCp := int32((remainingFightTimeAfterRoar-time.Second*9)/(time.Second*5)) + 1
minRoarCp := min(roarCp, 5)

// Actions to generate minRoarCp, plus cast Roar itself.
actionsToCastRoar := minRoarCp + 1

// Don't let roar expire.
if cat.timeToCast(actionsToCastRoar) >= roarDur {
return false
}

if cat.ComboPoints() == 5 {
// 5CP rip is worth it with 4 ticks
Expand All @@ -137,12 +114,6 @@ func (cat *FeralDruid) canRip(sim *core.Simulation, isTrick bool, usingRoar bool
}
}

// If we can't get any more combo points before roar expires, then we should rip now.
// If we can generate another CP and then rip without letting roar expire, then wait.
if cat.timeToCast(actionsToCastRoar+1) >= roarDur {
return true
}

// Caller decided that we should "rip trick".
if isTrick {
return true
Expand All @@ -153,8 +124,7 @@ func (cat *FeralDruid) canRip(sim *core.Simulation, isTrick bool, usingRoar bool

/*
func (cat *FeralDruid) canBite(sim *core.Simulation) bool {
return cat.Rip.CurDot().RemainingDuration(sim) >= cat.Rotation.BiteTime &&
cat.SavageRoarAura.RemainingDuration(sim) >= cat.Rotation.BiteTime
return cat.Rip.CurDot().RemainingDuration(sim) >= cat.Rotation.BiteTime
}
func (cat *FeralDruid) berserkExpectedAt(sim *core.Simulation, futureTime time.Duration) bool {
Expand All @@ -181,35 +151,6 @@ func (cat *FeralDruid) calcBuilderDpe(sim *core.Simulation) (float64, float64) {
}
*/

func (cat *FeralDruid) clipRoar(sim *core.Simulation) bool {
// If existing Roar already covers us to end of fight, then don't clip it
roarDur := cat.SavageRoarAura.RemainingDuration(sim)
fightDur := sim.GetRemainingDuration()

if roarDur >= fightDur {
return false
}

// If a fresh Roar cast now at the current number of Combo Points *would* cover us to end of fight, then clip now for maximum CP efficiency
newRoarDur := cat.SavageRoarDurationTable[cat.ComboPoints()]

if newRoarDur >= fightDur {
return true
}

// Roar clips that don't cover us to end of fight should only be done at 5 CP
if cat.ComboPoints() < 5 {
return false
}

// Calculate the minimum number of Roar casts that will cover us to end of fight if we (a) let the current one expire naturally vs. (b) clip it now.
minRoarsPossible := (fightDur - roarDur) / newRoarDur
projectedRoarCasts := fightDur / newRoarDur

// Allow a clip at the earliest time that doesn't result in an extra Roar cast
return projectedRoarCasts == minRoarsPossible
}

func (cat *FeralDruid) preRotationCleanup(sim *core.Simulation) bool {
// If we previously decided to shift, then execute the shift now once
// the input delay is over.
Expand Down Expand Up @@ -264,7 +205,6 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) {
nextTick := cat.NextEnergyTickAt()
timeToNextTick := nextTick - sim.CurrentTime
isClearcast := cat.ClearcastingAura.IsActive()
hasRoar := cat.SavageRoarAura.IsActive()
numShiftsToOom := cat.numShiftsRemaining()
fightDur := sim.GetRemainingDuration()
shredCost := cat.Shred.DefaultCast.Cost
Expand All @@ -278,23 +218,18 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) {

var nextAbility *druid.DruidSpell

if rotation.UseSavageRoar && curCp >= 1 && !hasRoar {
nextAbility = cat.SavageRoar
} else if isClearcast {
if isClearcast {
nextAbility = cat.Shred
} else if (curCp >= rotation.MinCombosForRip || canRipTrick) && cat.canRip(sim, canRipTrick, rotation.UseSavageRoar) {
} else if (curCp >= rotation.MinCombosForRip || canRipTrick) && cat.canRip(sim, canRipTrick) {
nextAbility = cat.Rip
} else if rotation.UseSavageRoar && curCp >= 1 && cat.clipRoar(sim) {
nextAbility = cat.SavageRoar
} else if canShredTrick {
nextAbility = cat.Shred
} else {
nextAbility = rotation.PrimaryBuilder
}

// Then determine whether to cast vs. wait vs. shift
waitForWildStrikesProc := (cat.WildStrikesBuffAura != nil) && !cat.WildStrikesBuffAura.IsActive()
poolEnergy := poolMana && ((curCp == 5) || waitForWildStrikesProc) && (nextEnergy < 100) && (nextAbility == rotation.PrimaryBuilder)
poolEnergy := poolMana && curCp == 5 && (nextEnergy < 100) && (nextAbility == rotation.PrimaryBuilder)
nextAction := sim.CurrentTime

if nextAbility.CanCast(sim, cat.CurrentTarget) && !poolEnergy {
Expand Down Expand Up @@ -367,7 +302,7 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) {
mangleNow := !ripNow && cat.MangleCat != nil && (mangleRefreshNow || clipMangle)
biteBeforeRip := (curCp >= rotation.MinCombosForBite) && ripDot.IsActive() && cat.SavageRoarAura.IsActive() && rotation.UseBite && cat.canBite(sim)
biteBeforeRip := (curCp >= rotation.MinCombosForBite) && ripDot.IsActive() && rotation.UseBite && cat.canBite(sim)
biteNow := (biteBeforeRip || biteAtEnd) && !isClearcast && curEnergy < 67
// During Berserk, we additionally add an Energy constraint on Bite
Expand Down Expand Up @@ -416,8 +351,6 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) {
berserkNow = simTimeRemain < cat.BerserkAura.Duration+(3*time.Second)
}
roarNow := curCp >= 1 && (!cat.SavageRoarAura.IsActive() || cat.clipRoar(sim))
// Faerie Fire on cooldown for Omen procs. Each second of FF delay is
// worth ~7 Energy, so it is okay to waste up to 7 Energy to cap when
// determining whether to cast it vs. dump Energy first. That puts the
Expand Down Expand Up @@ -464,10 +397,6 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) {
mangleCost := core.Ternary(cat.berserkExpectedAt(sim, cat.bleedAura.ExpiresAt()), cat.MangleCat.DefaultCast.Cost*0.5, cat.MangleCat.DefaultCast.Cost)
pendingPool.addAction(cat.bleedAura.ExpiresAt(), mangleCost)
}
if cat.SavageRoarAura.IsActive() {
roarCost := core.Ternary(cat.berserkExpectedAt(sim, cat.SavageRoarAura.ExpiresAt()), cat.SavageRoar.DefaultCast.Cost*0.5, cat.SavageRoar.DefaultCast.Cost)
pendingPool.addAction(cat.SavageRoarAura.ExpiresAt(), roarCost)
}
pendingPool.sort()
Expand Down Expand Up @@ -637,12 +566,6 @@ func (cat *FeralDruid) doRotation(sim *core.Simulation) (bool, time.Duration) {
cat.Berserk.Cast(sim, nil)
cat.UpdateMajorCooldowns()
return false, 0
} else if roarNow {
if cat.SavageRoar.CanCast(sim, cat.CurrentTarget) {
cat.SavageRoar.Cast(sim, nil)
return false, 0
}
timeToNextAction = time.Duration((cat.CurrentSavageRoarCost() - curEnergy) * float64(core.EnergyTickDuration))
} else if ripNow {
if cat.Rip.CanCast(sim, cat.CurrentTarget) {
cat.Rip.Cast(sim, cat.CurrentTarget)
Expand Down Expand Up @@ -740,7 +663,6 @@ type FeralDruidRotation struct {
BerserkBiteThresh float64
BerserkFfThresh float64
Powerbear bool
MinRoarOffset time.Duration
RipLeeway time.Duration
MaxFfDelay time.Duration
RevitFreq float64
Expand All @@ -755,22 +677,13 @@ type FeralDruidRotation struct {
*/

func (cat *FeralDruid) setupRotation(config *proto.APLActionCatOptimalRotationAction) {
var primaryBuilder *druid.DruidSpell

if cat.MangleCat != nil {
primaryBuilder = cat.MangleCat
} else {
primaryBuilder = cat.Shred
}

knowsRoar := cat.SavageRoar != nil
primaryBuilder := cat.Shred

cat.Rotation = FeralDruidRotation{
PrimaryBuilder: primaryBuilder,
MinCombosForRip: config.MinCombosForRip,
MaxWaitTime: core.DurationFromSeconds(float64(config.MaxWaitTime)),
MaintainFaerieFire: config.MaintainFaerieFire,
UseSavageRoar: knowsRoar,
UseShredTrick: config.UseShredTrick,
UseRipTrick: false,
}
Expand Down
3 changes: 1 addition & 2 deletions sim/druid/hurricane.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import (
"time"

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

func (druid *Druid) registerHurricaneSpell() {
Expand Down Expand Up @@ -38,7 +37,7 @@ func (druid *Druid) registerHurricaneSpell() {
Rank: i + 1,

ManaCost: core.ManaCostOptions{
FlatCost: rank.manaCost,
FlatCost: rank.manaCost,
},
Cast: core.CastConfig{
DefaultCast: core.Cast{
Expand Down
2 changes: 0 additions & 2 deletions sim/druid/items.go
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package druid

import (
"slices"

"github.com/wowsims/classic/sim/core"
)

Expand Down
5 changes: 3 additions & 2 deletions sim/druid/rip.go
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,9 @@ func (druid *Druid) newRipSpellConfig(ripRank RipRankInfo) core.SpellConfig {
TickLength: time.Second * 2,

OnSnapshot: func(sim *core.Simulation, target *core.Unit, dot *core.Dot, isRollover bool) {
cpScaling := core.TernaryFloat64(cp == 5, 4, float64(druid.ComboPoints()))
baseDamage := ripRank.dmgTickBase + ripRank.dmgTickPerCombo*cp
cp := float64(druid.ComboPoints())
cpScaling := core.TernaryFloat64(cp == 5, 4, cp)
baseDamage := ripRank.dmgTickBase + ripRank.dmgTickPerCombo*cpScaling
dot.Snapshot(target, baseDamage, isRollover)
},
OnTick: func(sim *core.Simulation, target *core.Unit, dot *core.Dot) {
Expand Down
1 change: 0 additions & 1 deletion sim/druid/shred.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"time"

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

func (druid *Druid) registerShredSpell() {
Expand Down
6 changes: 1 addition & 5 deletions sim/druid/swipe.go
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
package druid

import (
"time"

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

const SwipeRanks = 5
Expand All @@ -30,8 +27,7 @@ func (druid *Druid) registerSwipeBearSpell() {
baseDamage := SwipeBaseDamage[rank]

rageCost := 20 - float64(druid.Talents.Ferocity)
targetCount := 3
numHits := min(targetCount, druid.Env.GetNumTargets())
numHits := min(3, druid.Env.GetNumTargets())
results := make([]*core.SpellResult, numHits)

switch druid.Ranged().ID {
Expand Down

0 comments on commit 61a66a3

Please sign in to comment.