From e343f1d64e611fb260febecdc1abfa6dbb54c494 Mon Sep 17 00:00:00 2001 From: Josh Date: Wed, 25 Oct 2023 20:19:15 -0400 Subject: [PATCH] fix sindragosa ai crash (#3944) --- sim/encounters/icc/sindragosa25h_ai.go | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/sim/encounters/icc/sindragosa25h_ai.go b/sim/encounters/icc/sindragosa25h_ai.go index b2a9c304ee..01f9ac8f5b 100644 --- a/sim/encounters/icc/sindragosa25h_ai.go +++ b/sim/encounters/icc/sindragosa25h_ai.go @@ -162,9 +162,12 @@ func (ai *Sindragosa25HAI) registerMysticBuffetAuras() { } ai.MysticBuffetAuras = make([]*core.Aura, 0) + pendingActions := make([]*core.PendingAction, 50) + i := 0 for _, party := range ai.Target.Env.Raid.Parties { for _, player := range party.PlayersAndPets { + i += 1 character := player.GetCharacter() aura := character.GetOrRegisterAura(core.Aura{ Label: "Mystic Buffet", @@ -178,7 +181,12 @@ func (ai *Sindragosa25HAI) registerMysticBuffetAuras() { OnGain: func(aura *core.Aura, sim *core.Simulation) { period := time.Second * 6 numTicks := int(sim.GetRemainingDuration() / period) - core.StartPeriodicAction(sim, core.PeriodicActionOptions{ + + if pendingActions[i-1] != nil { + pendingActions[i-1].Cancel(sim) + } + + pendingActions[i-1] = core.StartPeriodicAction(sim, core.PeriodicActionOptions{ NumTicks: numTicks, Period: period, OnAction: func(sim *core.Simulation) { @@ -187,6 +195,14 @@ func (ai *Sindragosa25HAI) registerMysticBuffetAuras() { }, }) }, + OnExpire: func(aura *core.Aura, sim *core.Simulation) { + pendingActions[i-1].Cancel(sim) + }, + OnReset: func(aura *core.Aura, sim *core.Simulation) { + if pendingActions[i-1] != nil { + pendingActions[i-1].Cancel(sim) + } + }, }) ai.MysticBuffetAuras = append(ai.MysticBuffetAuras, aura) }