Skip to content

Commit

Permalink
add coherence bounces
Browse files Browse the repository at this point in the history
  • Loading branch information
kayla-glick committed Jun 19, 2024
1 parent f817b77 commit 0d284ed
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 84 deletions.
19 changes: 13 additions & 6 deletions sim/shaman/chain_heal.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const ChainHealRanks = 3
const ChainHealTargetCount = 3
const ChainHealTargetCount = int32(3)

var ChainHealSpellId = [ChainHealRanks + 1]int32{0, 1064, 10622, 10623}
var ChainHealBaseHealing = [ChainHealRanks + 1][]float64{{0}, {332, 381}, {416, 477}, {567, 646}}
Expand Down Expand Up @@ -40,6 +40,9 @@ func (shaman *Shaman) registerChainHealSpell() {
}

func (shaman *Shaman) newChainHealSpellConfig(rank int, isOverload bool) core.SpellConfig {
hasOverloadRune := shaman.HasRune(proto.ShamanRune_RuneChestOverload)
hasCoherenceRune := shaman.HasRune(proto.ShamanRune_RuneCloakCoherence)

spellId := ChainHealSpellId[rank]
baseHealingLow := ChainHealBaseHealing[rank][0] * (1 + shaman.purificationHealingModifier())
baseHealingHigh := ChainHealBaseHealing[rank][1] * (1 + shaman.purificationHealingModifier())
Expand All @@ -53,10 +56,14 @@ func (shaman *Shaman) newChainHealSpellConfig(rank int, isOverload bool) core.Sp
flags |= core.SpellFlagAPL
}

// 50% reduction per bounce or 35% with Coherence
ChainHealBounceCoeff := core.TernaryFloat64(shaman.HasRune(proto.ShamanRune_RuneCloakCoherence), .65, .5)
bounceCoef := .5 // 50% reduction per bounce
targetCount := ChainHealTargetCount
if hasCoherenceRune {
bounceCoef = .65 // 35% reduction per bounce
targetCount += 2
}

canOverload := !isOverload && shaman.HasRune(proto.ShamanRune_RuneChestOverload)
canOverload := !isOverload && hasOverloadRune

spell := core.SpellConfig{
ActionID: core.ActionID{SpellID: spellId},
Expand Down Expand Up @@ -93,7 +100,7 @@ func (shaman *Shaman) newChainHealSpellConfig(rank int, isOverload bool) core.Sp
BonusCoefficient: spellCoeff,

ApplyEffects: func(sim *core.Simulation, target *core.Unit, spell *core.Spell) {
targets := sim.Environment.Raid.GetFirstNPlayersOrPets(ChainHealTargetCount)
targets := sim.Environment.Raid.GetFirstNPlayersOrPets(targetCount)
curTarget := targets[0]
origMult := spell.DamageMultiplier
// TODO: This bounces to most hurt friendly...
Expand All @@ -106,7 +113,7 @@ func (shaman *Shaman) newChainHealSpellConfig(rank int, isOverload bool) core.Sp
shaman.ChainHealOverload[rank].Cast(sim, target)
}

spell.DamageMultiplier *= ChainHealBounceCoeff
spell.DamageMultiplier *= bounceCoef
curTarget = targets[hitIndex]
}
spell.DamageMultiplier = origMult
Expand Down
24 changes: 15 additions & 9 deletions sim/shaman/chain_lightning.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import (
)

const ChainLightningRanks = 4
const ChainLightningTargetCount = 3
const ChainLightningTargetCount = int32(3)

var ChainLightningSpellId = [ChainLightningRanks + 1]int32{0, 421, 930, 2860, 10605}
var ChainLightningBaseDamage = [ChainLightningRanks + 1][]float64{{0}, {200, 227}, {288, 323}, {383, 430}, {505, 564}}
Expand Down Expand Up @@ -42,6 +42,11 @@ func (shaman *Shaman) registerChainLightningSpell() {
}

func (shaman *Shaman) newChainLightningSpellConfig(rank int, cdTimer *core.Timer, isOverload bool) core.SpellConfig {
hasOverloadRune := shaman.HasRune(proto.ShamanRune_RuneChestOverload)
hasRollingThunderRune := shaman.HasRune(proto.ShamanRune_RuneBracersRollingThunder)
hasCoherenceRune := shaman.HasRune(proto.ShamanRune_RuneCloakCoherence)
hasStormEarthAndFireRune := shaman.HasRune(proto.ShamanRune_RuneCloakStormEarthAndFire)

spellId := ChainLightningSpellId[rank]
baseDamageLow := ChainLightningBaseDamage[rank][0]
baseDamageHigh := ChainLightningBaseDamage[rank][1]
Expand All @@ -52,15 +57,16 @@ func (shaman *Shaman) newChainLightningSpellConfig(rank int, cdTimer *core.Timer
cooldown := time.Second * 6
castTime := time.Millisecond * 2500

// 30% reduction per bounce or 20% with Coherence
ChainLightningBounceCoeff := core.TernaryFloat64(shaman.HasRune(proto.ShamanRune_RuneCloakCoherence), .8, .7)
bounceCoef := .7 // 30% reduction per bounce
targetCount := ChainLightningTargetCount
if hasCoherenceRune {
bounceCoef = .8 // 20% reduction per bounce
targetCount += 2
}

canOverload := !isOverload && shaman.HasRune(proto.ShamanRune_RuneChestOverload)
canOverload := !isOverload && hasOverloadRune
overloadChance := .1667

hasRollingThunderRune := shaman.HasRune(proto.ShamanRune_RuneBracersRollingThunder)
hasStormEarthAndFireRune := shaman.HasRune(proto.ShamanRune_RuneCloakStormEarthAndFire)

spell := shaman.newElectricSpellConfig(
core.ActionID{SpellID: spellId},
manaCost,
Expand All @@ -80,15 +86,15 @@ func (shaman *Shaman) newChainLightningSpellConfig(rank int, cdTimer *core.Timer
}
}

results := make([]*core.SpellResult, min(ChainLightningTargetCount, shaman.Env.GetNumTargets()))
results := make([]*core.SpellResult, min(targetCount, shaman.Env.GetNumTargets()))

spell.ApplyEffects = func(sim *core.Simulation, target *core.Unit, spell *core.Spell) {
origMult := spell.DamageMultiplier
for hitIndex := range results {
baseDamage := sim.Roll(baseDamageLow, baseDamageHigh)
results[hitIndex] = spell.CalcDamage(sim, target, baseDamage, spell.OutcomeMagicHitAndCrit)
target = sim.Environment.NextTargetUnit(target)
spell.DamageMultiplier *= ChainLightningBounceCoeff
spell.DamageMultiplier *= bounceCoef
}

for _, result := range results {
Expand Down
Loading

0 comments on commit 0d284ed

Please sign in to comment.