Skip to content

Commit

Permalink
Refactor Armor Spec application
Browse files Browse the repository at this point in the history
  • Loading branch information
1337LutZ committed Jan 10, 2025
1 parent e5a4d8c commit fce2792
Show file tree
Hide file tree
Showing 20 changed files with 72 additions and 85 deletions.
12 changes: 12 additions & 0 deletions sim/core/aura_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,18 @@ func (parentAura *Aura) AttachSpellMod(spellModConfig SpellModConfig) {
})
}

// Attaches a StatDependency to a parent Aura
func (parentAura *Aura) AttachStatDependency(statDep *stats.StatDependency) {

parentAura.ApplyOnGain(func(_ *Aura, sim *Simulation) {
parentAura.Unit.EnableBuildPhaseStatDep(sim, statDep)
})

parentAura.ApplyOnExpire(func(_ *Aura, sim *Simulation) {
parentAura.Unit.DisableBuildPhaseStatDep(sim, statDep)
})
}

// Adds Stats to a parent Aura
func (parentAura *Aura) AttachStatsBuff(stats stats.Stats) {
parentAura.ApplyOnGain(func(aura *Aura, sim *Simulation) {
Expand Down
89 changes: 33 additions & 56 deletions sim/core/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -775,63 +775,40 @@ func (character *Character) MeetsArmorSpecializationRequirement(armorType proto.
return true
}

func (character *Character) ApplyArmorSpecializationEffect(primaryStat stats.Stat, armorType proto.ArmorType) {
armorSpecializationDepdency := character.NewDynamicMultiplyStat(primaryStat, 1.05)
var isEnabled bool
func (character *Character) ApplyArmorSpecializationEffect(primaryStat stats.Stat, armorType proto.ArmorType, spellID int32) {
armorSpecializationDependency := character.NewDynamicMultiplyStat(primaryStat, 1.05)
isEnabled := character.MeetsArmorSpecializationRequirement(armorType)

enableArmorSpecialization := func(sim *Simulation) {
character.EnableBuildPhaseStatDep(sim, armorSpecializationDepdency)

if isEnabled {
return
}
isEnabled = true
if sim.Log != nil {
sim.Log("Armor Specialization: Active")
}
}
disableArmorSpecialization := func(sim *Simulation) {
character.DisableBuildPhaseStatDep(sim, armorSpecializationDepdency)

if !isEnabled {
return
}
isEnabled = false
if sim.Log != nil {
sim.Log("Armor Specialization: Inactive")
}
}

processArmorSpecialization := func(sim *Simulation) {
hasBonus := character.MeetsArmorSpecializationRequirement(armorType)
if hasBonus {
enableArmorSpecialization(sim)
} else {
disableArmorSpecialization(sim)
}
}

MakePermanent(character.RegisterAura(Aura{
aura := character.RegisterAura(Aura{
Label: "Armor Specialization",
BuildPhase: CharacterBuildPhaseTalents,
OnGain: func(aura *Aura, sim *Simulation) {
processArmorSpecialization(sim)
},
}))
ActionID: ActionID{SpellID: spellID},
BuildPhase: Ternary(isEnabled, CharacterBuildPhaseTalents, CharacterBuildPhaseNone),
Duration: NeverExpires,
})

if character.ItemSwap.IsEnabled() {
character.RegisterItemSwapCallback([]proto.ItemSlot{
proto.ItemSlot_ItemSlotHead,
proto.ItemSlot_ItemSlotShoulder,
proto.ItemSlot_ItemSlotChest,
proto.ItemSlot_ItemSlotWrist,
proto.ItemSlot_ItemSlotHands,
proto.ItemSlot_ItemSlotWaist,
proto.ItemSlot_ItemSlotLegs,
proto.ItemSlot_ItemSlotFeet,
},
func(sim *Simulation, _ proto.ItemSlot) {
processArmorSpecialization(sim)
})
}
aura.AttachStatDependency(armorSpecializationDependency)

if isEnabled {
aura = MakePermanent(aura)
}

character.RegisterItemSwapCallback([]proto.ItemSlot{
proto.ItemSlot_ItemSlotHead,
proto.ItemSlot_ItemSlotShoulder,
proto.ItemSlot_ItemSlotChest,
proto.ItemSlot_ItemSlotWrist,
proto.ItemSlot_ItemSlotHands,
proto.ItemSlot_ItemSlotWaist,
proto.ItemSlot_ItemSlotLegs,
proto.ItemSlot_ItemSlotFeet,
},
func(sim *Simulation, _ proto.ItemSlot) {
if character.MeetsArmorSpecializationRequirement(armorType) {
if !aura.IsActive() {
aura.Activate(sim)
}
} else {
aura.Deactivate(sim)
}
})
}
22 changes: 10 additions & 12 deletions sim/core/item_sets.go
Original file line number Diff line number Diff line change
Expand Up @@ -236,15 +236,15 @@ func (character *Character) makeSetBonusStatusAura(setName string, numPieces int
statusAura = MakePermanent(statusAura)
}

if character.ItemSwap.IsEnabled() {
character.RegisterItemSwapCallback(slots, func(sim *Simulation, _ proto.ItemSlot) {
if character.hasActiveSetBonus(setName, numPieces) {
character.RegisterItemSwapCallback(slots, func(sim *Simulation, _ proto.ItemSlot) {
if character.hasActiveSetBonus(setName, numPieces) {
if !statusAura.IsActive() {
statusAura.Activate(sim)
} else {
statusAura.Deactivate(sim)
}
})
}
} else {
statusAura.Deactivate(sim)
}
})

return statusAura
}
Expand Down Expand Up @@ -279,9 +279,7 @@ func (character *Character) RegisterPvPGloveMod(itemIDs []int32, config SpellMod

checkGloves()

if character.ItemSwap.IsEnabled() {
character.RegisterItemSwapCallback([]proto.ItemSlot{proto.ItemSlot_ItemSlotHands}, func(_ *Simulation, _ proto.ItemSlot) {
checkGloves()
})
}
character.RegisterItemSwapCallback([]proto.ItemSlot{proto.ItemSlot_ItemSlotHands}, func(_ *Simulation, _ proto.ItemSlot) {
checkGloves()
})
}
2 changes: 1 addition & 1 deletion sim/death_knight/blood/blood.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ func (bdk BloodDeathKnight) getBloodShieldMasteryBonus() float64 {

func (bdk *BloodDeathKnight) ApplyTalents() {
bdk.DeathKnight.ApplyTalents()
bdk.ApplyArmorSpecializationEffect(stats.Stamina, proto.ArmorType_ArmorTypePlate)
bdk.ApplyArmorSpecializationEffect(stats.Stamina, proto.ArmorType_ArmorTypePlate, 86524)

// Veteran of the Third War
bdk.AddStaticMod(core.SpellModConfig{
Expand Down
2 changes: 1 addition & 1 deletion sim/death_knight/frost/frost.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ func (fdk *FrostDeathKnight) Initialize() {

func (fdk *FrostDeathKnight) ApplyTalents() {
fdk.DeathKnight.ApplyTalents()
fdk.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate)
fdk.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate, 86524)

masteryMod := fdk.AddDynamicMod(core.SpellModConfig{
Kind: core.SpellMod_DamageDone_Pct,
Expand Down
2 changes: 1 addition & 1 deletion sim/death_knight/unholy/unholy.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (uhdk *UnholyDeathKnight) Initialize() {

func (uhdk *UnholyDeathKnight) ApplyTalents() {
uhdk.DeathKnight.ApplyTalents()
uhdk.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate)
uhdk.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate, 86524)

// Mastery: Dreadblade
masteryMod := uhdk.AddDynamicMod(core.SpellModConfig{
Expand Down
2 changes: 1 addition & 1 deletion sim/hunter/talents.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import (
)

func (hunter *Hunter) ApplyTalents() {
hunter.ApplyArmorSpecializationEffect(stats.Agility, proto.ArmorType_ArmorTypeMail)
hunter.ApplyArmorSpecializationEffect(stats.Agility, proto.ArmorType_ArmorTypeMail, 86529)

if hunter.Pet != nil {
hunter.applyFrenzy()
Expand Down
2 changes: 1 addition & 1 deletion sim/mage/mage.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (mage *Mage) AddPartyBuffs(partyBuffs *proto.PartyBuffs) {
}

func (mage *Mage) ApplyTalents() {
mage.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeCloth)
mage.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeCloth, 89744)

mage.ApplyArcaneTalents()
mage.ApplyFireTalents()
Expand Down
2 changes: 1 addition & 1 deletion sim/paladin/holy/holy.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ func (holy *HolyPaladin) GetPaladin() *paladin.Paladin {

func (holy *HolyPaladin) ApplyTalents() {
holy.Paladin.ApplyTalents()
holy.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypePlate)
holy.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypePlate, 86525)
}

func (holy *HolyPaladin) Initialize() {
Expand Down
2 changes: 1 addition & 1 deletion sim/paladin/protection/protection.go
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ func (prot *ProtectionPaladin) Initialize() {

func (prot *ProtectionPaladin) ApplyTalents() {
prot.Paladin.ApplyTalents()
prot.ApplyArmorSpecializationEffect(stats.Stamina, proto.ArmorType_ArmorTypePlate)
prot.ApplyArmorSpecializationEffect(stats.Stamina, proto.ArmorType_ArmorTypePlate, 86525)
}

func (prot *ProtectionPaladin) Reset(sim *core.Simulation) {
Expand Down
2 changes: 1 addition & 1 deletion sim/paladin/retribution/retribution.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func (ret *RetributionPaladin) Initialize() {

func (ret *RetributionPaladin) ApplyTalents() {
ret.Paladin.ApplyTalents()
ret.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate)
ret.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate, 86525)
}

func (ret *RetributionPaladin) Reset(sim *core.Simulation) {
Expand Down
2 changes: 1 addition & 1 deletion sim/priest/talents.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func (priest *Priest) ApplyTalents() {
priest.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeCloth)
priest.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeCloth, 89745)
// TODO:
// Reflective Shield
// Improved Flash Heal
Expand Down
2 changes: 1 addition & 1 deletion sim/rogue/talents.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import (
)

func (rogue *Rogue) ApplyTalents() {
rogue.ApplyArmorSpecializationEffect(stats.Agility, proto.ArmorType_ArmorTypeLeather)
rogue.ApplyArmorSpecializationEffect(stats.Agility, proto.ArmorType_ArmorTypeLeather, 87504)
rogue.PseudoStats.MeleeSpeedMultiplier *= []float64{1, 1.02, 1.04, 1.06}[rogue.Talents.LightningReflexes]
rogue.AddStat(stats.PhysicalHitPercent, 2*float64(rogue.Talents.Precision))
rogue.AddStat(stats.SpellHitPercent, 2*float64(rogue.Talents.Precision))
Expand Down
2 changes: 1 addition & 1 deletion sim/shaman/elemental/elemental.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ func (eleShaman *ElementalShaman) Initialize() {

func (ele *ElementalShaman) ApplyTalents() {
ele.Shaman.ApplyTalents()
ele.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeMail)
ele.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeMail, 86529)
}

type ElementalShaman struct {
Expand Down
2 changes: 1 addition & 1 deletion sim/shaman/enhancement/enhancement.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ func (enh *EnhancementShaman) GetShaman() *shaman.Shaman {

func (enh *EnhancementShaman) ApplyTalents() {
enh.Shaman.ApplyTalents()
enh.ApplyArmorSpecializationEffect(stats.Agility, proto.ArmorType_ArmorTypeMail)
enh.ApplyArmorSpecializationEffect(stats.Agility, proto.ArmorType_ArmorTypeMail, 86529)
}

func (enh *EnhancementShaman) Initialize() {
Expand Down
2 changes: 1 addition & 1 deletion sim/shaman/restoration/restoration.go
Original file line number Diff line number Diff line change
Expand Up @@ -87,5 +87,5 @@ func (resto *RestorationShaman) Initialize() {

func (resto *RestorationShaman) ApplyTalents() {
resto.Shaman.ApplyTalents()
resto.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeMail)
resto.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeMail, 86529)
}
2 changes: 1 addition & 1 deletion sim/warlock/warlock.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (warlock *Warlock) GetWarlock() *Warlock {
}

func (warlock *Warlock) ApplyTalents() {
warlock.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeCloth)
warlock.ApplyArmorSpecializationEffect(stats.Intellect, proto.ArmorType_ArmorTypeCloth, 86091)

warlock.ApplyAfflictionTalents()
warlock.ApplyDemonologyTalents()
Expand Down
2 changes: 1 addition & 1 deletion sim/warrior/arms/talents.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func (war *ArmsWarrior) ApplyTalents() {
war.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate)
war.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate, 86526)
war.Warrior.ApplyCommonTalents()

war.RegisterBladestorm()
Expand Down
2 changes: 1 addition & 1 deletion sim/warrior/fury/talents.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func (war *FuryWarrior) ApplyTalents() {
war.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate)
war.ApplyArmorSpecializationEffect(stats.Strength, proto.ArmorType_ArmorTypePlate, 86526)
war.Warrior.ApplyCommonTalents()

war.RegisterDeathWish()
Expand Down
2 changes: 1 addition & 1 deletion sim/warrior/protection/talents.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import (
)

func (war *ProtectionWarrior) ApplyTalents() {
war.ApplyArmorSpecializationEffect(stats.Stamina, proto.ArmorType_ArmorTypePlate)
war.ApplyArmorSpecializationEffect(stats.Stamina, proto.ArmorType_ArmorTypePlate, 86526)

// Vigilance is not implemented as it requires a second friendly target
// We can probably fake it or make it configurable or something, but I expect it wouldn't
Expand Down

0 comments on commit fce2792

Please sign in to comment.