Skip to content

Commit

Permalink
Merge pull request #3321 from wowsims/apl_icd
Browse files Browse the repository at this point in the history
Add Icd tracking for player auras in APL
  • Loading branch information
rosenrusinov authored Jul 15, 2023
2 parents 97142d5 + 88d7d56 commit c52b3ba
Show file tree
Hide file tree
Showing 26 changed files with 124 additions and 13 deletions.
1 change: 1 addition & 0 deletions proto/api.proto
Original file line number Diff line number Diff line change
Expand Up @@ -297,6 +297,7 @@ message ComputeStatsRequest {
message AuraStats {
ActionID id = 1;
int32 max_stacks = 2;
bool has_icd = 3;
}
message SpellStats {
ActionID id = 1;
Expand Down
4 changes: 4 additions & 0 deletions proto/apl.proto
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,7 @@ message APLValue {
APLValueAuraIsActive aura_is_active = 22;
APLValueAuraRemainingTime aura_remaining_time = 23;
APLValueAuraNumStacks aura_num_stacks = 24;
APLValueAuraInternalCooldown aura_internal_cooldown = 39;

// Dot values
APLValueDotIsActive dot_is_active = 6;
Expand Down Expand Up @@ -272,6 +273,9 @@ message APLValueAuraRemainingTime {
message APLValueAuraNumStacks {
ActionID aura_id = 1;
}
message APLValueAuraInternalCooldown {
ActionID aura_id = 1;
}

message APLValueDotIsActive {
ActionID spell_id = 1;
Expand Down
4 changes: 4 additions & 0 deletions sim/common/wotlk/enchant_effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ func init() {
Timer: character.NewTimer(),
Duration: time.Second * 35,
}
procAura.Icd = &icd

aura := character.GetOrRegisterAura(core.Aura{
Label: "Black Magic",
Expand Down Expand Up @@ -352,6 +353,7 @@ func init() {
Timer: character.NewTimer(),
Duration: time.Second * 60,
}
procAura.Icd = &icd

callback := func(_ *core.Aura, sim *core.Simulation, _ *core.Spell, result *core.SpellResult) {
if !result.Landed() {
Expand Down Expand Up @@ -389,6 +391,7 @@ func init() {
}

character.GetOrRegisterAura(core.Aura{
Icd: &icd,
Label: "Darkglow Embroidery",
Duration: core.NeverExpires,
OnReset: func(aura *core.Aura, sim *core.Simulation) {
Expand All @@ -411,6 +414,7 @@ func init() {
Timer: character.NewTimer(),
Duration: time.Second * 55,
}
procAura.Icd = &icd

character.GetOrRegisterAura(core.Aura{
Label: "Swordguard Embroidery",
Expand Down
6 changes: 4 additions & 2 deletions sim/common/wotlk/highest_stat_effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ func init() {
})

hsa.Init(character)
core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
triggerAura := core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: "DMC Greatness",
Callback: core.CallbackOnSpellHitDealt | core.CallbackOnPeriodicDamageDealt | core.CallbackOnHealDealt | core.CallbackOnPeriodicHealDealt,
ProcMask: core.ProcMaskDirect | core.ProcMaskSpellHealing | core.ProcMaskProc,
Expand All @@ -78,6 +78,7 @@ func init() {
hsa.Get(character).Activate(sim)
},
})
hsa.Get(character).Icd = triggerAura.Icd
})
}
core.AddEffectsToTest = false
Expand All @@ -103,7 +104,7 @@ func init() {
})

hsa.Init(character)
core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
triggerAura := core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: name,
Callback: core.CallbackOnSpellHitDealt | core.CallbackOnPeriodicDamageDealt,
ProcMask: core.ProcMaskDirect | core.ProcMaskProc,
Expand All @@ -115,6 +116,7 @@ func init() {
hsa.Get(character).Activate(sim)
},
})
hsa.Get(character).Icd = triggerAura.Icd
})
}
core.AddEffectsToTest = false
Expand Down
3 changes: 2 additions & 1 deletion sim/common/wotlk/metagems.go
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ func init() {
character := agent.GetCharacter()
procAura := character.NewTemporaryStatsAura("Thundering Skyflare Diamond Proc", core.ActionID{SpellID: 55379}, stats.Stats{stats.MeleeHaste: 480}, time.Second*6)

core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
triggerAura := core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: "Thundering Skyflare Diamond",
Callback: core.CallbackOnSpellHitDealt,
// Mask 68, melee or ranged auto attacks.
Expand All @@ -93,6 +93,7 @@ func init() {
procAura.Activate(sim)
},
})
procAura.Icd = triggerAura.Icd
})

core.NewItemEffect(41401, func(agent core.Agent) {
Expand Down
17 changes: 13 additions & 4 deletions sim/common/wotlk/other_effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ func init() {
}
})

core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
triggerAura := core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: "Essence of Gossamer Trigger",
Callback: core.CallbackOnSpellHitTaken,
ProcMask: core.ProcMaskMelee,
Expand All @@ -38,6 +38,7 @@ func init() {
procAura.Activate(sim)
},
})
procAura.Icd = triggerAura.Icd
})
core.NewItemEffect(45507, func(agent core.Agent) {
character := agent.GetCharacter()
Expand All @@ -55,7 +56,7 @@ func init() {
}
})

core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
triggerAura := core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: "The General's Heart Trigger",
Callback: core.CallbackOnSpellHitTaken,
ProcMask: core.ProcMaskMelee,
Expand All @@ -67,6 +68,7 @@ func init() {
procAura.Activate(sim)
},
})
procAura.Icd = triggerAura.Icd
})

core.NewItemEffect(37734, func(agent core.Agent) {
Expand Down Expand Up @@ -175,7 +177,7 @@ func init() {
return
}

core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
triggerAura := core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: name,
Callback: core.CallbackOnSpellHitDealt,
ProcMask: core.ProcMaskMeleeOrRanged | core.ProcMaskProc,
Expand All @@ -194,6 +196,10 @@ func init() {
}
},
})

for _, aura := range auras {
aura.Icd = triggerAura.Icd
}
})
})

Expand Down Expand Up @@ -446,6 +452,7 @@ func init() {
Timer: character.NewTimer(),
Duration: time.Second * 30,
}
procAura.Icd = &icd

core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: name + " Trigger",
Expand Down Expand Up @@ -487,7 +494,7 @@ func init() {
BonusPerStack: stats.Stats{stats.SpellPower: amount},
})

core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
triggerAura := core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: name + " Trigger",
Callback: core.CallbackOnSpellHitDealt,
ProcMask: core.ProcMaskSpellOrProc,
Expand All @@ -509,6 +516,7 @@ func init() {
})
},
})
procAura.Icd = triggerAura.Icd
})
})

Expand Down Expand Up @@ -869,6 +877,7 @@ func init() {
Timer: character.NewTimer(),
Duration: time.Second * 45,
}
procAura.Icd = &icd

core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: name + " Trigger",
Expand Down
3 changes: 2 additions & 1 deletion sim/common/wotlk/stat_bonus_procs.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ func newProcStatBonusEffect(config ProcStatBonusEffect) {
}
}

core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
triggerAura := core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
ActionID: core.ActionID{ItemID: config.ID},
Name: config.Name,
Callback: config.Callback,
Expand All @@ -53,6 +53,7 @@ func newProcStatBonusEffect(config ProcStatBonusEffect) {
ICD: config.ICD,
Handler: handler,
})
procAura.Icd = triggerAura.Icd
})
}

Expand Down
3 changes: 2 additions & 1 deletion sim/common/wotlk/stat_bonus_stacking.go
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ func init() {
BonusPerStack: stats.Stats{stats.MeleeCrit: 15, stats.SpellCrit: 15},
})

core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
triggerAura := core.MakeProcTriggerAura(&character.Unit, core.ProcTrigger{
Name: "Death Knight's Anguish",
Callback: core.CallbackOnSpellHitDealt,
ProcMask: core.ProcMaskMeleeOrRanged,
Expand All @@ -160,6 +160,7 @@ func init() {
procAura.Activate(sim)
},
})
procAura.Icd = triggerAura.Icd
})

newStackingStatBonusEffect(StackingStatBonusEffect{
Expand Down
2 changes: 2 additions & 0 deletions sim/core/apl_value.go
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,8 @@ func (rot *APLRotation) newAPLValue(config *proto.APLValue) APLValue {
return rot.newValueAuraRemainingTime(config.GetAuraRemainingTime())
case *proto.APLValue_AuraNumStacks:
return rot.newValueAuraNumStacks(config.GetAuraNumStacks())
case *proto.APLValue_AuraInternalCooldown:
return rot.newValueAuraInternalCooldown(config.GetAuraInternalCooldown())

// Dots
case *proto.APLValue_DotIsActive:
Expand Down
29 changes: 29 additions & 0 deletions sim/core/apl_values_aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,14 @@ func (rot *APLRotation) aplGetAura(auraId *proto.ActionID) *Aura {
return aura
}

func (rot *APLRotation) aplGetProcAura(auraId *proto.ActionID) *Aura {
aura := rot.unit.GetIcdAuraByID(ProtoToActionID(auraId))
if aura == nil {
rot.validationWarning("No aura found for: %s", ProtoToActionID(auraId))
}
return aura
}

type APLValueAuraIsActive struct {
defaultAPLValueImpl
aura *Aura
Expand Down Expand Up @@ -80,3 +88,24 @@ func (value *APLValueAuraNumStacks) Type() proto.APLValueType {
func (value *APLValueAuraNumStacks) GetInt(sim *Simulation) int32 {
return value.aura.GetStacks()
}

type APLValueAuraInternalCooldown struct {
defaultAPLValueImpl
aura *Aura
}

func (rot *APLRotation) newValueAuraInternalCooldown(config *proto.APLValueAuraInternalCooldown) APLValue {
aura := rot.aplGetProcAura(config.AuraId)
if aura == nil {
return nil
}
return &APLValueAuraInternalCooldown{
aura: aura,
}
}
func (value *APLValueAuraInternalCooldown) Type() proto.APLValueType {
return proto.APLValueType_ValueTypeDuration
}
func (value *APLValueAuraInternalCooldown) GetDuration(sim *Simulation) time.Duration {
return value.aura.Icd.TimeToReady(sim)
}
12 changes: 12 additions & 0 deletions sim/core/aura.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ type Aura struct {
ActionID ActionID // If set, metrics will be tracked for this aura.
ActionIDForProc ActionID // If set, indicates that this aura is a trigger aura for the specified proc.

Icd *Cooldown // The internal cooldown if any

Duration time.Duration // Duration of aura, upon being applied.

startTime time.Duration // Time at which the aura was applied.
Expand Down Expand Up @@ -331,6 +333,14 @@ func (at *auraTracker) GetAuraByID(actionID ActionID) *Aura {
}
return nil
}
func (at *auraTracker) GetIcdAuraByID(actionID ActionID) *Aura {
for _, aura := range at.auras {
if (aura.ActionID.SameAction(actionID) || aura.ActionIDForProc.SameAction(actionID)) && aura.Icd != nil {
return aura
}
}
return nil
}
func (at *auraTracker) HasAura(label string) bool {
aura := at.GetAura(label)
return aura != nil
Expand All @@ -357,6 +367,7 @@ func (at *auraTracker) registerAura(unit *Unit, aura Aura) *Aura {
newAura := &Aura{}
*newAura = aura
newAura.Unit = unit
newAura.Icd = aura.Icd
newAura.metrics.ID = aura.ActionID
newAura.activeIndex = Inactive
newAura.onCastCompleteIndex = Inactive
Expand Down Expand Up @@ -385,6 +396,7 @@ func (unit *Unit) GetOrRegisterAura(aura Aura) *Aura {
if curAura == nil {
return unit.RegisterAura(aura)
} else {
curAura.Icd = aura.Icd
curAura.OnCastComplete = aura.OnCastComplete
curAura.OnSpellHitDealt = aura.OnSpellHitDealt
curAura.OnSpellHitTaken = aura.OnSpellHitTaken
Expand Down
1 change: 1 addition & 0 deletions sim/core/aura_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ func ApplyProcTriggerCallback(unit *Unit, aura *Aura, config ProcTrigger) {
Timer: unit.NewTimer(),
Duration: config.ICD,
}
aura.Icd = &icd
}

var ppmm PPMManager
Expand Down
1 change: 1 addition & 0 deletions sim/core/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ func (character *Character) FillPlayerStats(playerStats *proto.PlayerStats) {
return &proto.AuraStats{
Id: aura.ActionID.ToProto(),
MaxStacks: aura.MaxStacks,
HasIcd: aura.Icd != nil,
}
})

Expand Down
4 changes: 4 additions & 0 deletions sim/deathknight/items.go
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,7 @@ func (dk *Deathknight) registerThassariansBattlegearProc() {
Timer: dk.NewTimer(),
Duration: time.Second * 45.0,
}
procAura.Icd = &icd

core.MakePermanent(dk.GetOrRegisterAura(core.Aura{
Label: "Unholy Might",
Expand Down Expand Up @@ -642,6 +643,7 @@ func init() {
Timer: dk.NewTimer(),
Duration: time.Second * 45.0,
}
procAura.Icd = &icd

core.MakePermanent(dk.GetOrRegisterAura(core.Aura{
Label: "Sigil of Haunted Dreams",
Expand Down Expand Up @@ -682,6 +684,7 @@ func init() {
Timer: dk.NewTimer(),
Duration: time.Second * 10.0,
}
procAura.Icd = &icd

core.MakePermanent(dk.GetOrRegisterAura(core.Aura{
Label: "Sigil of Insolence",
Expand All @@ -706,6 +709,7 @@ func init() {
Timer: dk.NewTimer(),
Duration: time.Second * 10.0,
}
procAura.Icd = &icd

core.MakePermanent(dk.GetOrRegisterAura(core.Aura{
Label: "Sigil of Virulence",
Expand Down
4 changes: 4 additions & 0 deletions sim/druid/items.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,6 +222,7 @@ var ItemSetNightsongBattlegear = core.NewItemSet(core.ItemSet{
OnReset: func(aura *core.Aura, sim *core.Simulation) {
aura.Activate(sim)
cca = druid.GetAura("Clearcasting")
cca.Icd = &icd
if cca == nil {
panic("no valid clearcasting aura")
}
Expand Down Expand Up @@ -450,6 +451,8 @@ func init() {
Timer: druid.NewTimer(),
Duration: time.Second * 8,
}
bearAura.Icd = &icd
catAura.Icd = &icd
procChance := 0.7

core.MakePermanent(druid.RegisterAura(core.Aura{
Expand Down Expand Up @@ -599,6 +602,7 @@ func init() {
Timer: druid.NewTimer(),
Duration: time.Second * 6,
}
procAura.Icd = &icd

core.MakePermanent(druid.RegisterAura(core.Aura{
Label: "Idol of Lunar Fury",
Expand Down
Loading

0 comments on commit c52b3ba

Please sign in to comment.