From 61988ddd12714e8a6fbfb75bd19f09e6797fa6eb Mon Sep 17 00:00:00 2001 From: James Tanner Date: Mon, 4 Sep 2023 14:48:26 -0700 Subject: [PATCH] Fix APL issue with Fan of Knives and different types in math operations --- sim/core/apl_values_operators.go | 3 +++ sim/core/energy.go | 2 -- sim/core/environment.go | 12 ++++++++++++ sim/core/sim.go | 2 +- sim/rogue/fan_of_knives.go | 5 ++++- 5 files changed, 20 insertions(+), 4 deletions(-) diff --git a/sim/core/apl_values_operators.go b/sim/core/apl_values_operators.go index dbbfee0c47..a98d8d2e96 100644 --- a/sim/core/apl_values_operators.go +++ b/sim/core/apl_values_operators.go @@ -353,6 +353,9 @@ type APLValueMath struct { func (rot *APLRotation) newValueMath(config *proto.APLValueMath) APLValue { lhs, rhs := rot.newAPLValue(config.Lhs), rot.newAPLValue(config.Rhs) + if config.Op == proto.APLValueMath_OpAdd || config.Op == proto.APLValueMath_OpSub { + lhs, rhs = rot.coerceToSameType(lhs, rhs) + } if lhs == nil || rhs == nil { return nil } diff --git a/sim/core/energy.go b/sim/core/energy.go index 05262b05f8..a50e79fa65 100644 --- a/sim/core/energy.go +++ b/sim/core/energy.go @@ -8,8 +8,6 @@ import ( // Time between energy ticks. const EnergyTickDuration = time.Millisecond * 100 - -// Extra 0.2 because Blizzard const EnergyPerTick = 1.0 // OnEnergyGain is called any time energy is increased. diff --git a/sim/core/environment.go b/sim/core/environment.go index b18578421c..b90b0eaf80 100644 --- a/sim/core/environment.go +++ b/sim/core/environment.go @@ -331,3 +331,15 @@ func (unit *Unit) RegisterPrepullAction(doAt time.Duration, action func(*Simulat Action: action, }) } + +func (env *Environment) PrepullStartTime() time.Duration { + if !env.IsFinalized() { + panic("Env not yet finalized") + } + + if len(env.prepullActions) == 0 { + return 0 + } else { + return env.prepullActions[0].DoAt + } +} diff --git a/sim/core/sim.go b/sim/core/sim.go index 2dc24f4e5f..5de0f551f5 100644 --- a/sim/core/sim.go +++ b/sim/core/sim.go @@ -336,7 +336,7 @@ func (sim *Simulation) runPendingActions(max time.Duration) { func (sim *Simulation) PrePull() { if len(sim.Environment.prepullActions) > 0 { - sim.CurrentTime = sim.Environment.prepullActions[0].DoAt + sim.CurrentTime = sim.Environment.PrepullStartTime() for _, prepullAction := range sim.Environment.prepullActions { if prepullAction.DoAt > sim.CurrentTime { diff --git a/sim/rogue/fan_of_knives.go b/sim/rogue/fan_of_knives.go index 64385633a3..fee8ff763e 100644 --- a/sim/rogue/fan_of_knives.go +++ b/sim/rogue/fan_of_knives.go @@ -12,17 +12,20 @@ const FanOfKnivesSpellID int32 = 51723 func (rogue *Rogue) makeFanOfKnivesWeaponHitSpell(isMH bool) *core.Spell { var procMask core.ProcMask var weaponMultiplier float64 + var actionID core.ActionID if isMH { + actionID = core.ActionID{SpellID: FanOfKnivesSpellID}.WithTag(1) weaponMultiplier = core.TernaryFloat64(rogue.HasDagger(core.MainHand), 1.05, 0.7) procMask = core.ProcMaskMeleeMHSpecial } else { + actionID = core.ActionID{SpellID: FanOfKnivesSpellID}.WithTag(2) weaponMultiplier = core.TernaryFloat64(rogue.HasDagger(core.OffHand), 1.05, 0.7) weaponMultiplier *= rogue.dwsMultiplier() procMask = core.ProcMaskMeleeOHSpecial } return rogue.RegisterSpell(core.SpellConfig{ - ActionID: core.ActionID{SpellID: FanOfKnivesSpellID}, + ActionID: actionID, SpellSchool: core.SpellSchoolPhysical, ProcMask: procMask, Flags: core.SpellFlagMeleeMetrics | SpellFlagColdBlooded,