Skip to content

Commit

Permalink
Rework WS and WF
Browse files Browse the repository at this point in the history
  • Loading branch information
Adamrch committed Sep 26, 2024
1 parent 88010bb commit 5eab673
Show file tree
Hide file tree
Showing 27 changed files with 2,362 additions and 1,110 deletions.
1 change: 1 addition & 0 deletions sim/core/apl.go
Original file line number Diff line number Diff line change
Expand Up @@ -202,6 +202,7 @@ func (apl *APLRotation) DoNextAction(sim *Simulation) {

if sim.Log != nil && i == 0 {
apl.unit.Log(sim, "No available actions!")
apl.unit.Log(sim, "GCD ready at : %f ", apl.unit.GCD.ReadyAt())
}

gcdReady := apl.unit.GCD.IsReady(sim)
Expand Down
31 changes: 28 additions & 3 deletions sim/core/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -458,8 +458,21 @@ func (unit *Unit) EnableAutoAttacks(agent Agent, options AutoAttackOptions) {
BonusCoefficient: TernaryFloat64(options.MainHand.GetSpellSchool() == SpellSchoolPhysical, 1, 0),

ApplyEffects: func(sim *Simulation, target *Unit, spell *Spell) {
baseDamage := spell.Unit.MHWeaponDamage(sim, spell.MeleeAttackPower())
spell.CalcAndDealDamage(sim, target, baseDamage, spell.OutcomeMeleeWhite)

autoInProgress := *spell

baseDamage := autoInProgress.Unit.MHWeaponDamage(sim, autoInProgress.MeleeAttackPower())
result := autoInProgress.CalcDamage(sim, target, baseDamage, autoInProgress.OutcomeMeleeWhite)

StartDelayedAction(sim, DelayedActionOptions{
DoAt: sim.CurrentTime + SpellBatchWindow,
OnAction: func(s *Simulation) {
autoInProgress.DealDamage(sim, result)
},
})

//baseDamage := spell.Unit.MHWeaponDamage(sim, spell.MeleeAttackPower()) */
//spell.CalcAndDealDamage(sim, target, baseDamage, spell.OutcomeMeleeWhite)
},
}

Expand All @@ -478,6 +491,17 @@ func (unit *Unit) EnableAutoAttacks(agent Agent, options AutoAttackOptions) {
BonusCoefficient: TernaryFloat64(options.OffHand.GetSpellSchool() == SpellSchoolPhysical, 1, 0),

ApplyEffects: func(sim *Simulation, target *Unit, spell *Spell) {

/* autoInProgress := *spell
baseDamage := autoInProgress.Unit.OHWeaponDamage(sim, autoInProgress.MeleeAttackPower())
result := autoInProgress.CalcDamage(sim, target, baseDamage, autoInProgress.OutcomeMeleeWhite)
StartDelayedAction(sim, DelayedActionOptions{
DoAt: sim.CurrentTime + SpellBatchWindow,
OnAction: func(s *Simulation) {
autoInProgress.DealDamage(sim, result)
},
}) */
baseDamage := spell.Unit.OHWeaponDamage(sim, spell.MeleeAttackPower())
spell.CalcAndDealDamage(sim, target, baseDamage, spell.OutcomeMeleeWhite)
},
Expand Down Expand Up @@ -728,7 +752,8 @@ func (aa *AutoAttacks) ExtraMHAttack(sim *Simulation, attacks int32, actionID Ac
attacksText := Ternary(attacks == 1, "attack", "attacks")
aa.mh.unit.Log(sim, "gained %d extra main-hand %s from %s triggered by %s", attacks, attacksText, actionID, triggerAction)
}
aa.mh.swingAt = sim.CurrentTime + SpellBatchWindow

aa.mh.swingAt = sim.CurrentTime
aa.mh.spell.SetMetricsSplit(1)
sim.rescheduleWeaponAttack(aa.mh.swingAt)
aa.mh.extraAttacksPending += attacks
Expand Down
111 changes: 38 additions & 73 deletions sim/core/buffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2175,18 +2175,16 @@ func BattleSquawkAura(character *Unit, stackcount int32) *Aura {
// })
// }

func ApplyWildStrikes(character *Character) *Aura {
buffActionID := ActionID{SpellID: 407975}

func CreateExtraAttackAuraCommon(character *Character, buffActionID ActionID, auraLabel string, rank int32, getBonusAP func(aura *Aura, rank int32) float64) *Aura {
var bonusAP float64

wsBuffAura := character.GetOrRegisterAura(Aura{
Label: "Wild Strikes Buff",
apBuffAura := character.GetOrRegisterAura(Aura{
Label: auraLabel + " Buff",
ActionID: buffActionID,
Duration: time.Millisecond * 1500,
MaxStacks: 2,
OnGain: func(aura *Aura, sim *Simulation) {
bonusAP = 0.2 * aura.Unit.GetStat(stats.AttackPower)
bonusAP = getBonusAP(aura, rank)
aura.Unit.AddStatsDynamic(sim, stats.Stats{stats.AttackPower: bonusAP})
},
OnExpire: func(aura *Aura, sim *Simulation) {
Expand All @@ -2199,37 +2197,48 @@ func ApplyWildStrikes(character *Character) *Aura {
Duration: time.Millisecond * 1500,
}

wsBuffAura.Icd = &icd
apBuffAura.Icd = &icd

MakePermanent(character.GetOrRegisterAura(Aura{
Label: "Wild Strikes",
Label: auraLabel,
OnSpellHitDealt: func(aura *Aura, sim *Simulation, spell *Spell, result *SpellResult) {
// charges are removed by every auto or next melee, whether it lands or not
// this directly contradicts https://github.com/magey/classic-warrior/wiki/Windfury-Totem#triggered-by-melee-spell-while-an-on-next-swing-attack-is-queued
// but can be seen in both "vanilla" and "sod" era logs
if apBuffAura.IsActive() && spell.ProcMask.Matches(ProcMaskMeleeWhiteHit) {
apBuffAura.RemoveStack(sim)
}

if !result.Landed() || !spell.ProcMask.Matches(ProcMaskMeleeMH) || spell.Flags.Matches(SpellFlagSuppressEquipProcs) {
return
}

// charges are removed by every auto or next melee, whether it lands or not
if wsBuffAura.IsActive() && spell.ProcMask.Matches(ProcMaskMeleeWhiteHit) {
if wsBuffAura.GetStacks() == 2 {
wsBuffAura.SetStacks(sim, 1)
wsBuffAura.Duration = time.Millisecond * 100 // 100 ms might be generous - could anywhere from 50-150 ms potentially
wsBuffAura.Refresh(sim) // Apply New Duration
if icd.IsReady(sim) && sim.RandomFloat(auraLabel) < 0.2 {
icd.Use(sim)
apBuffAura.Activate(sim)
// aura is up _before_ the triggering swing lands, so if triggered by an auto attack, the aura fades right after the extra attack lands.
if spell.ProcMask == ProcMaskMeleeMHAuto {
apBuffAura.SetStacks(sim, 1)
} else {
apBuffAura.SetStacks(sim, 2)
}
}

if icd.IsReady(sim) && sim.RandomFloat("Wild Strikes") < 0.2 {
icd.Use(sim)
wsBuffAura.Activate(sim)
// aura is up _after_ the triggering swing lands, the extra attack only has 1500ms for the AP bonus but the extra attack does not expire
wsBuffAura.SetStacks(sim, 2)
wsBuffAura.Duration = time.Millisecond * 1500
wsBuffAura.Refresh(sim) // Apply New Duration
aura.Unit.AutoAttacks.ExtraMHAttackProc(sim, 1, buffActionID, spell)
}
},
}))

return wsBuffAura
return apBuffAura
}

func GetWildStrikesAP(aura *Aura, rank int32) float64 {
return 0.2 * aura.Unit.GetStat(stats.AttackPower)
}

func ApplyWildStrikes(character *Character) *Aura {
buffActionID := ActionID{SpellID: 407975}

return CreateExtraAttackAuraCommon(character, buffActionID, "Wild Strikes", 1, GetWildStrikesAP)
}

const WindfuryRanks = 3
Expand All @@ -2239,6 +2248,10 @@ var (
WindfuryBuffBonusAP = [WindfuryRanks + 1]float64{0, 122, 229, 315}
)

func GetWindfuryAP(aura *Aura, rank int32) float64 {
return WindfuryBuffBonusAP[rank]
}

func ApplyWindfury(character *Character) *Aura {
level := character.Level
if level < 32 {
Expand All @@ -2247,58 +2260,10 @@ func ApplyWindfury(character *Character) *Aura {

rank := LevelToBuffRank[Windfury][level]
spellId := WindfuryBuffSpellId[rank]
bonusAP := WindfuryBuffBonusAP[rank]

windfuryBuffAura := character.GetOrRegisterAura(Aura{
Label: "Windfury Buff",
ActionID: ActionID{SpellID: spellId},
Duration: time.Millisecond * 1500,
MaxStacks: 2,
OnGain: func(aura *Aura, sim *Simulation) {
aura.Unit.AddStatsDynamic(sim, stats.Stats{stats.AttackPower: bonusAP})
},
OnExpire: func(aura *Aura, sim *Simulation) {
aura.Unit.AddStatsDynamic(sim, stats.Stats{stats.AttackPower: -bonusAP})
},
})

icd := Cooldown{
Timer: character.NewTimer(),
Duration: time.Millisecond * 1500,
}

windfuryBuffAura.Icd = &icd

MakePermanent(character.GetOrRegisterAura(Aura{
Label: "Windfury",
OnSpellHitDealt: func(aura *Aura, sim *Simulation, spell *Spell, result *SpellResult) {
// charges are removed by every auto or next melee, whether it lands or not
// this directly contradicts https://github.com/magey/classic-warrior/wiki/Windfury-Totem#triggered-by-melee-spell-while-an-on-next-swing-attack-is-queued
// but can be seen in both "vanilla" and "sod" era logs
if windfuryBuffAura.IsActive() && spell.ProcMask.Matches(ProcMaskMeleeWhiteHit) {
windfuryBuffAura.RemoveStack(sim)
}

if !result.Landed() || !spell.ProcMask.Matches(ProcMaskMeleeMH) || spell.Flags.Matches(SpellFlagSuppressEquipProcs) {
return
}
buffActionID := ActionID{SpellID: spellId}

if icd.IsReady(sim) && sim.RandomFloat("Windfury") < 0.2 {
icd.Use(sim)
windfuryBuffAura.Activate(sim)
// aura is up _before_ the triggering swing lands, so if triggered by an auto attack, the aura fades right after the extra attack lands.
if spell.ProcMask == ProcMaskMeleeMHAuto {
windfuryBuffAura.SetStacks(sim, 1)
} else {
windfuryBuffAura.SetStacks(sim, 2)
}

aura.Unit.AutoAttacks.ExtraMHAttackProc(sim, 1, ActionID{SpellID: spellId}, spell)
}
},
}))
return CreateExtraAttackAuraCommon(character, buffActionID, "Windfury", rank, GetWindfuryAP)

return windfuryBuffAura
}

///////////////////////////////////////////////////////////////////////////
Expand Down
Loading

0 comments on commit 5eab673

Please sign in to comment.