Skip to content

Commit

Permalink
Merge pull request #1007 from wowsims/feral
Browse files Browse the repository at this point in the history
Generalized Feral bleed snapshotting algorithm
  • Loading branch information
NerdEgghead authored Sep 13, 2024
2 parents 824480d + da98e50 commit 603dec6
Show file tree
Hide file tree
Showing 9 changed files with 898 additions and 551 deletions.
8 changes: 8 additions & 0 deletions sim/core/aura_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,10 @@ func (character *Character) NewTemporaryStatsAuraWrapped(auraLabel string, actio
if includesHealthBuff {
character.UpdateMaxHealth(sim, amountHealed, healthMetrics)
}

for i := range character.OnTemporaryStatsChanges {
character.OnTemporaryStatsChanges[i](sim, aura, buffs)
}
},
OnExpire: func(aura *Aura, sim *Simulation) {
if sim.Log != nil {
Expand All @@ -277,6 +281,10 @@ func (character *Character) NewTemporaryStatsAuraWrapped(auraLabel string, actio
if includesHealthBuff {
character.UpdateMaxHealth(sim, -amountHealed, healthMetrics)
}

for i := range character.OnTemporaryStatsChanges {
character.OnTemporaryStatsChanges[i](sim, aura, buffs.Invert())
}
},
}

Expand Down
11 changes: 11 additions & 0 deletions sim/core/unit.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ type UnitType int
type SpellRegisteredHandler func(spell *Spell)
type OnMasteryStatChanged func(sim *Simulation, oldMasteryRating float64, newMasteryRating float64)
type OnCastSpeedChanged func(oldSpeed float64, newSpeed float64)
type OnTemporaryStatsChange func(sim *Simulation, buffAura *Aura, statsChangeWithoutDeps stats.Stats)

const (
PlayerUnit UnitType = iota
Expand Down Expand Up @@ -181,6 +182,9 @@ type Unit struct {
// Used for reacting to cast speed changes if a spec needs it (e.g. for cds reduced by haste)
OnCastSpeedChanged []OnCastSpeedChanged

// Used for reacting to transient stat changes if a spec needs if (e.g. for caching snapshotting calculations)
OnTemporaryStatsChanges []OnTemporaryStatsChange

GetSpellPowerValue GetSpellpowerValue
}

Expand Down Expand Up @@ -274,6 +278,13 @@ func (unit *Unit) AddOnCastSpeedChanged(ocsc OnCastSpeedChanged) {
unit.OnCastSpeedChanged = append(unit.OnCastSpeedChanged, ocsc)
}

func (unit *Unit) AddOnTemporaryStatsChange(otsc OnTemporaryStatsChange) {
if unit.Env != nil && unit.Env.IsFinalized() {
panic("Already finalized, cannot add on temporary stats change callback!")
}
unit.OnTemporaryStatsChanges = append(unit.OnTemporaryStatsChanges, otsc)
}

func (unit *Unit) AddStatsDynamic(sim *Simulation, bonus stats.Stats) {
if unit.Env == nil {
panic("Environment not constructed.")
Expand Down
31 changes: 30 additions & 1 deletion sim/druid/druid.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ type Druid struct {
AssumeBleedActive bool
LeatherSpecActive bool
Feral4pT12Active bool
RipTfSnapshot bool

MHAutoSpell *core.Spell
ReplaceBearMHFunc core.ReplaceMHSwing
Expand Down Expand Up @@ -387,6 +386,11 @@ func New(char *core.Character, form DruidForm, selfBuffs SelfBuffs, talents stri
type DruidSpell struct {
*core.Spell
FormMask DruidForm

// Optional fields used in snapshotting calculations
CurrentSnapshotPower float64
NewSnapshotPower float64
ShortName string
}

func (ds *DruidSpell) IsReady(sim *core.Simulation) bool {
Expand All @@ -410,6 +414,31 @@ func (ds *DruidSpell) IsEqual(s *core.Spell) bool {
return ds.Spell == s
}

func (druid *Druid) UpdateBleedPower(bleedSpell *DruidSpell, sim *core.Simulation, target *core.Unit, updateCurrent bool, updateNew bool) {
snapshotPower := bleedSpell.ExpectedTickDamage(sim, target)

// Assume that Mangle will be up soon if not currently active.
if !druid.BleedCategories.Get(target).AnyActive() {
snapshotPower *= 1.3
}

if updateCurrent {
bleedSpell.CurrentSnapshotPower = snapshotPower

if sim.Log != nil {
druid.Log(sim, "%s Snapshot Power: %.1f", bleedSpell.ShortName, snapshotPower)
}
}

if updateNew {
bleedSpell.NewSnapshotPower = snapshotPower

if (sim.Log != nil) && !updateCurrent {
druid.Log(sim, "%s Projected Power: %.1f", bleedSpell.ShortName, snapshotPower)
}
}
}

// Agent is a generic way to access underlying druid on any of the agents (for example balance druid.)
type DruidAgent interface {
GetDruid() *Druid
Expand Down
Loading

0 comments on commit 603dec6

Please sign in to comment.