Skip to content

Commit 106a831

Browse files
committed
[Core] Make RPPM effects reset their lastProc and lastAttempt on encounter start
1 parent 3dd8c29 commit 106a831

8 files changed

Lines changed: 3058 additions & 3022 deletions

File tree

sim/core/character.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@ func (cbp CharacterBuildPhase) Matches(other CharacterBuildPhase) bool {
1818
return (cbp & other) != 0
1919
}
2020

21+
type OnEncounterStartEffect func()
22+
2123
const (
2224
CharacterBuildPhaseNone CharacterBuildPhase = 0
2325
CharacterBuildPhaseBase CharacterBuildPhase = 1 << iota
@@ -82,6 +84,8 @@ type Character struct {
8284
spellCategoryTimers map[int32]*Timer
8385

8486
Pets []*Pet // cached in AddPet, for advance()
87+
88+
OnEncounterStartEffects []OnEncounterStartEffect
8589
}
8690

8791
func NewCharacter(party *Party, partyIndex int, player *proto.Player) Character {
@@ -805,3 +809,11 @@ func (character *Character) ApplyArmorSpecializationEffect(primaryStat stats.Sta
805809
trackerAura.AttachStatDependency(armorSpecializationDependency)
806810
return trackerAura
807811
}
812+
813+
func (character *Character) RegisterOnEncounterStartEffect(onEncounterStartEffect OnEncounterStartEffect) {
814+
if onEncounterStartEffect == nil {
815+
return
816+
}
817+
818+
character.OnEncounterStartEffects = append(character.OnEncounterStartEffects, onEncounterStartEffect)
819+
}

sim/core/procs.go

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package core
22

33
import (
4+
"time"
5+
46
"github.com/wowsims/mop/sim/core/proto"
57
)
68

@@ -263,9 +265,16 @@ func (character *Character) NewRPPMProcManager(effectID int32, isEnchant bool, i
263265
dpm := builder()
264266

265267
// Keep track of the lastProc and lastCheck values when weapon swapping.
266-
lastProc := -RppmLastProcResetValue
267-
lastCheck := -RppmLastCheckCap
268-
isFirstProc := true
268+
var lastProc time.Duration
269+
var lastCheck time.Duration
270+
var isFirstProc bool
271+
272+
resetProc := func() {
273+
lastProc = -RppmLastProcResetValue
274+
lastCheck = -RppmLastCheckCap
275+
isFirstProc = true
276+
}
277+
resetProc()
269278

270279
character.RegisterItemSwapCallback(slotList, func(_ *Simulation, _ proto.ItemSlot) {
271280
for _, proc := range dpm.procChances {
@@ -286,9 +295,18 @@ func (character *Character) NewRPPMProcManager(effectID int32, isEnchant bool, i
286295
})
287296

288297
character.RegisterResetEffect(func(_ *Simulation) {
289-
lastProc = -RppmLastProcResetValue
290-
lastCheck = -RppmLastCheckCap
291-
isFirstProc = true
298+
resetProc()
299+
})
300+
301+
character.RegisterOnEncounterStartEffect(func() {
302+
resetProc()
303+
304+
for _, proc := range dpm.procChances {
305+
resolvedProc := proc.(*RPPMProc)
306+
resolvedProc.lastProc = lastProc
307+
resolvedProc.lastCheck = lastCheck
308+
resolvedProc.isFirstProc = isFirstProc
309+
}
292310
})
293311

294312
return &dpm

sim/core/unit.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -812,6 +812,12 @@ func (unit *Unit) reset(sim *Simulation, _ Agent) {
812812
func (unit *Unit) onEncounterStart(sim *Simulation) {
813813
if agent := unit.Env.GetAgentFromUnit(unit); agent != nil {
814814
agent.OnEncounterStart(sim)
815+
816+
if character := agent.GetCharacter(); character != nil {
817+
for i := range character.OnEncounterStartEffects {
818+
character.OnEncounterStartEffects[i]()
819+
}
820+
}
815821
}
816822

817823
// Reduce Haste fakepoints arising from overly precise swing timings relative to the GCD timer.

sim/druid/feral/TestFeral.results

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1266,7 +1266,7 @@ dps_results: {
12661266
key: "TestFeral-AllItems-Horridon'sLastGasp-96757"
12671267
value: {
12681268
dps: 223125.75057
1269-
tps: 329197.79855
1269+
tps: 329198.49284
12701270
hps: 15408.66764
12711271
}
12721272
}

0 commit comments

Comments
 (0)