Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ws wf rework #1101

Merged
merged 2 commits into from
Oct 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 44 additions & 15 deletions sim/core/attack.go
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,10 @@ func (aa *AutoAttacks) MH() *Weapon {

func (aa *AutoAttacks) SetMH(weapon Weapon) {
aa.mh.setWeapon(weapon)

if aa.mh.extraAttacksAura == nil {
aa.mh.extraAttacksAura = aa.mh.unit.GetAuraByID(ActionID{SpellID: 21919})
}
}

func (aa *AutoAttacks) OH() *Weapon {
Expand Down Expand Up @@ -269,12 +273,14 @@ func (wa *WeaponAttack) trySwing(sim *Simulation) time.Duration {
}

func (wa *WeaponAttack) castExtraAttacksStored(sim *Simulation) {
wa.castExtraAttacks(sim, wa.extraAttacksStored, 0)
wa.extraAttacksStored = 0

if wa.extraAttacksAura != nil {
wa.extraAttacksStored = wa.extraAttacksAura.GetStacks()
wa.extraAttacksAura.SetStacks(sim, 0)
}

wa.castExtraAttacks(sim, wa.extraAttacksStored, 0)
wa.extraAttacksStored = 0

}

func (wa *WeaponAttack) castExtraAttacksTriggered(sim *Simulation, moreAttacks bool) {
Expand Down Expand Up @@ -458,8 +464,18 @@ 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)
},
})
},
}

Expand All @@ -478,8 +494,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) {
baseDamage := spell.Unit.OHWeaponDamage(sim, spell.MeleeAttackPower())
spell.CalcAndDealDamage(sim, target, baseDamage, spell.OutcomeMeleeWhite)

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)
},
})
},
}

Expand Down Expand Up @@ -589,6 +614,7 @@ func (aa *AutoAttacks) reset(sim *Simulation) {
}

func (aa *AutoAttacks) startPull(sim *Simulation) {

if !aa.AutoSwingMelee && !aa.AutoSwingRanged {
return
}
Expand Down Expand Up @@ -728,7 +754,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 All @@ -740,21 +767,23 @@ func (aa *AutoAttacks) StoreExtraMHAttack(sim *Simulation, attacks int32, action
}

if aa.mh.extraAttacksAura == nil {
aa.mh.extraAttacksAura = aa.mh.unit.GetOrRegisterAura(Aura{
Label: "Extra Attacks", // Tracks Stored Extra Attacks from all sources
ActionID: ActionID{SpellID: 21919}, // Thrash ID
aa.mh.extraAttacksAura = aa.mh.unit.GetAuraByID(ActionID{SpellID: 21919})
}

if aa.mh.extraAttacksAura == nil {
aa.mh.extraAttacksAura = MakePermanent(aa.mh.unit.GetOrRegisterAura(Aura{
Label: "Extra Attacks (Main Hand)", // Tracks Stored Extra Attacks from all sources
ActionID: ActionID{SpellID: 21919}, // Thrash ID
Duration: NeverExpires,
MaxStacks: 4, // Max is 4 extra attacks stored - more can proc after
})
}))
}

if !aa.mh.extraAttacksAura.IsActive() {
aa.mh.extraAttacksAura.Activate(sim)
}

aa.mh.extraAttacksStored = min(aa.mh.extraAttacksStored+attacks, 4) // Max is 4 stored extra attacks

aa.mh.extraAttacksAura.SetStacks(sim, aa.mh.extraAttacksStored)
aa.mh.extraAttacksAura.AddStacks(sim, attacks)

if sim.Log != nil {
aa.mh.unit.Log(sim, "stored %d extra main-hand attacks from %s triggered by %s, total is %d", attacks, actionID, triggerAction, aa.mh.extraAttacksStored)
Expand Down
121 changes: 48 additions & 73 deletions sim/core/buffs.go
Original file line number Diff line number Diff line change
Expand Up @@ -2191,61 +2191,80 @@ 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) {
aura.Unit.AddStatsDynamic(sim, stats.Stats{stats.AttackPower: -bonusAP})
},
})

MakePermanent(character.GetOrRegisterAura(Aura{
Label: "Extra Attacks (Main Hand)", // Tracks Stored Extra Attacks from all sources
ActionID: ActionID{SpellID: 21919}, // Thrash ID
Duration: NeverExpires,
MaxStacks: 4, // Max is 4 extra attacks stored - more can proc after
OnInit: func(aura *Aura, sim *Simulation) {
aura.Unit.AutoAttacks.mh.extraAttacksAura = aura
},
}))

icd := Cooldown{
Timer: character.NewTimer(),
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 @@ -2255,6 +2274,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 @@ -2263,58 +2286,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
}

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)
}
buffActionID := ActionID{SpellID: spellId}

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

return windfuryBuffAura
}

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