Skip to content

Commit

Permalink
Merge pull request #1661 from wowsims/fixes
Browse files Browse the repository at this point in the history
Refactor enchant IDs
  • Loading branch information
jimmyt857 authored Nov 10, 2022
2 parents 6d29407 + 1e0b8ff commit eb859fa
Show file tree
Hide file tree
Showing 66 changed files with 7,746 additions and 8,376 deletions.
14 changes: 8 additions & 6 deletions proto/common.proto
Original file line number Diff line number Diff line change
Expand Up @@ -683,13 +683,15 @@ enum EnchantType {
}

message Enchant {
int32 id = 1; // ID of the enchant "item".
int32 effect_id = 2; // ID of the effect (for the item tooltip UI)
string name = 3;
// All enchants have an effect ID. Some also have an item ID, others have a spell ID,
// and yet others have both item and spell IDs. No single ID alone is not enough
// to uniquely identify an enchant. Uniqueness requires either effect ID + slot, or
// effect ID + item/spell ID.
int32 effect_id = 2; // ID of the effect.
int32 item_id = 1; // ID of the enchant "item". Might be 0 if not available.
int32 spell_id = 10; // ID of the enchant "spell". Might be 0 if not available.

// If true, then id is the ID of the enchant spell instead of the formula item.
// This is used by enchants for which a formula doesn't exist (its taught by a trainer).
bool is_spell_id = 10;
string name = 3;

ItemType type = 4; // Which type of item this enchant can be applied to.
EnchantType enchant_type = 9;
Expand Down
44 changes: 22 additions & 22 deletions sim/common/tbc/enchant_effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func init() {
// Keep these in order by item ID.

// TODO: Crusader, Mongoose, and Executioner could also be modelled as AddWeaponEffect instead
core.AddWeaponEffect(16250, func(agent core.Agent, slot proto.ItemSlot) {
core.AddWeaponEffect(1897, func(agent core.Agent, slot proto.ItemSlot) {
w := &agent.GetCharacter().AutoAttacks.MH
if slot == proto.ItemSlot_ItemSlotOffHand {
w = &agent.GetCharacter().AutoAttacks.OH
Expand All @@ -22,22 +22,22 @@ func init() {
w.BaseDamageMax += 5
})

core.NewEnchantEffect(18283, func(agent core.Agent) {
core.NewEnchantEffect(2523, func(agent core.Agent) {
agent.GetCharacter().AddBonusRangedHitRating(30)
})
core.NewEnchantEffect(23766, func(agent core.Agent) {
core.NewEnchantEffect(2724, func(agent core.Agent) {
agent.GetCharacter().AddBonusRangedCritRating(28)
})

core.NewEnchantEffect(22560, func(agent core.Agent) {
core.NewEnchantEffect(2671, func(agent core.Agent) {
// Sunfire
agent.GetCharacter().OnSpellRegistered(func(spell *core.Spell) {
if spell.SpellSchool.Matches(core.SpellSchoolArcane | core.SpellSchoolFire) {
spell.BonusSpellPower += 50
}
})
})
core.NewEnchantEffect(22561, func(agent core.Agent) {
core.NewEnchantEffect(2672, func(agent core.Agent) {
// Soulfrost
agent.GetCharacter().OnSpellRegistered(func(spell *core.Spell) {
if spell.SpellSchool.Matches(core.SpellSchoolFrost | core.SpellSchoolShadow) {
Expand All @@ -46,7 +46,7 @@ func init() {
})
})

core.AddWeaponEffect(22552, func(agent core.Agent, slot proto.ItemSlot) {
core.AddWeaponEffect(963, func(agent core.Agent, slot proto.ItemSlot) {
w := &agent.GetCharacter().AutoAttacks.MH
if slot == proto.ItemSlot_ItemSlotOffHand {
w = &agent.GetCharacter().AutoAttacks.OH
Expand All @@ -58,10 +58,10 @@ func init() {
// ApplyCrusaderEffect will be applied twice if there is two weapons with this enchant.
// However it will automatically overwrite one of them so it should be ok.
// A single application of the aura will handle both mh and oh procs.
core.NewEnchantEffect(16252, func(agent core.Agent) {
core.NewEnchantEffect(1900, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 16252
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 16252
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 1900
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 1900
if !mh && !oh {
return
}
Expand Down Expand Up @@ -95,17 +95,17 @@ func init() {
})
})

core.NewEnchantEffect(22535, func(agent core.Agent) {
core.NewEnchantEffect(2929, func(agent core.Agent) {
agent.GetCharacter().PseudoStats.BonusDamage += 2
})

// ApplyMongooseEffect will be applied twice if there is two weapons with this enchant.
// However it will automatically overwrite one of them so it should be ok.
// A single application of the aura will handle both mh and oh procs.
core.NewEnchantEffect(22559, func(agent core.Agent) {
core.NewEnchantEffect(2673, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 22559
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 22559
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 2673
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 2673
if !mh && !oh {
return
}
Expand Down Expand Up @@ -137,25 +137,25 @@ func init() {
})
})

core.AddWeaponEffect(23765, func(agent core.Agent, _ proto.ItemSlot) {
core.AddWeaponEffect(2723, func(agent core.Agent, _ proto.ItemSlot) {
w := &agent.GetCharacter().AutoAttacks.Ranged
w.BaseDamageMin += 12
w.BaseDamageMax += 12
})

core.NewEnchantEffect(33150, func(agent core.Agent) {
core.NewEnchantEffect(2621, func(agent core.Agent) {
character := agent.GetCharacter()
character.PseudoStats.ThreatMultiplier *= 0.98
})
core.NewEnchantEffect(33153, func(agent core.Agent) {
core.NewEnchantEffect(2613, func(agent core.Agent) {
character := agent.GetCharacter()
character.PseudoStats.ThreatMultiplier *= 1.02
})

core.NewEnchantEffect(33307, func(agent core.Agent) {
core.NewEnchantEffect(3225, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 33307
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 33307
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3225
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3225
if !mh && !oh {
return
}
Expand Down Expand Up @@ -223,10 +223,10 @@ func init() {
},
})
}
core.NewEnchantEffect(35498, func(agent core.Agent) {
core.NewEnchantEffect(3273, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 35498
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 35498
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3273
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3273
if !mh && !oh {
return
}
Expand Down
84 changes: 38 additions & 46 deletions sim/common/wotlk/enchant_effects.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@ import (
func init() {
// Keep these in order by item ID.

core.NewEnchantEffect(37339, func(agent core.Agent) {
core.NewEnchantEffect(3251, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 37339
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 37339
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3251
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3251
if !mh && !oh {
return
}
Expand Down Expand Up @@ -57,10 +57,10 @@ func init() {
})
})

core.NewEnchantEffect(37344, func(agent core.Agent) {
core.NewEnchantEffect(3239, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 37344
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 37344
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3239
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3239
if !mh && !oh {
return
}
Expand Down Expand Up @@ -99,19 +99,19 @@ func init() {
})
})

core.NewEnchantEffect(41146, func(agent core.Agent) {
core.NewEnchantEffect(3607, func(agent core.Agent) {
character := agent.GetCharacter()
// TODO: This should be ranged-only haste. For now just make it hunter-only.
if character.Class == proto.Class_ClassHunter {
character.AddStats(stats.Stats{stats.MeleeHaste: 40, stats.SpellHaste: 40})
}
})

core.NewEnchantEffect(41167, func(agent core.Agent) {
core.NewEnchantEffect(3608, func(agent core.Agent) {
agent.GetCharacter().AddBonusRangedCritRating(40)
})

core.NewEnchantEffect(42500, func(agent core.Agent) {
core.NewEnchantEffect(3748, func(agent core.Agent) {
character := agent.GetCharacter()
actionID := core.ActionID{ItemID: 42500}

Expand Down Expand Up @@ -145,35 +145,27 @@ func init() {
})
})

core.NewEnchantEffect(44473, func(agent core.Agent) {
core.NewEnchantEffect(3247, func(agent core.Agent) {
character := agent.GetCharacter()
if character.CurrentTarget.MobType == proto.MobType_MobTypeUndead {
character.PseudoStats.MobTypeAttackPower += 140
}
})

core.NewEnchantEffect(44485, func(agent core.Agent) {
core.NewEnchantEffect(3253, func(agent core.Agent) {
character := agent.GetCharacter()
character.PseudoStats.ThreatMultiplier *= 1.02
})

// Apply for Wisdom to Cloak (itemid) but NOT for Enchant Gloves Precision (spellid)
core.NewEnchantEffect(44488, func(agent core.Agent) {
core.NewEnchantEffect(3296, func(agent core.Agent) {
character := agent.GetCharacter()
if character.Equip[proto.ItemSlot_ItemSlotBack].Enchant.ID == 44488 {
if character.Equip[proto.ItemSlot_ItemSlotHands].Enchant.ID == 44488 {
// If someone has both of these enchants for some reason, this will get called twice.
character.PseudoStats.ThreatMultiplier *= 0.98995
} else {
character.PseudoStats.ThreatMultiplier *= 0.98
}
}
character.PseudoStats.ThreatMultiplier *= 0.98
})

core.NewEnchantEffect(44492, func(agent core.Agent) {
core.NewEnchantEffect(3789, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 44492
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 44492
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3789
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3789
if !mh && !oh {
return
}
Expand Down Expand Up @@ -208,10 +200,10 @@ func init() {
})

// TODO: These are stand-in values without any real reference.
core.NewEnchantEffect(44494, func(agent core.Agent) {
core.NewEnchantEffect(3241, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 44494
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 44494
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3241
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3241
if !mh && !oh {
return
}
Expand All @@ -238,7 +230,7 @@ func init() {
})
})

core.NewEnchantEffect(44495, func(agent core.Agent) {
core.NewEnchantEffect(3790, func(agent core.Agent) {
character := agent.GetCharacter()

procAura := character.NewTemporaryStatsAura("Black Magic Proc", core.ActionID{SpellID: 59626}, stats.Stats{stats.MeleeHaste: 250, stats.SpellHaste: 250}, time.Second*10)
Expand Down Expand Up @@ -266,13 +258,13 @@ func init() {
})
})

core.AddWeaponEffect(44739, func(agent core.Agent, _ proto.ItemSlot) {
core.AddWeaponEffect(3843, func(agent core.Agent, _ proto.ItemSlot) {
w := &agent.GetCharacter().AutoAttacks.Ranged
w.BaseDamageMin += 15
w.BaseDamageMax += 15
})

core.NewEnchantEffect(54998, func(agent core.Agent) {
core.NewEnchantEffect(3603, func(agent core.Agent) {
character := agent.GetCharacter()
actionID := core.ActionID{SpellID: 54757}

Expand Down Expand Up @@ -309,7 +301,7 @@ func init() {
})
})

core.NewEnchantEffect(54999, func(agent core.Agent) {
core.NewEnchantEffect(3604, func(agent core.Agent) {
character := agent.GetCharacter()
actionID := core.ActionID{SpellID: 54758}

Expand Down Expand Up @@ -372,10 +364,10 @@ func init() {
})
}

core.NewEnchantEffect(53343, func(agent core.Agent) {
core.NewEnchantEffect(3370, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 53343
oh := character.HasOHWeapon() && character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 53343
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3370
oh := character.HasOHWeapon() && character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3370
if !mh && !oh {
return
}
Expand Down Expand Up @@ -457,10 +449,10 @@ func init() {
// ApplyRuneOfTheFallenCrusader will be applied twice if there is two weapons with this enchant.
// However it will automatically overwrite one of them so it should be ok.
// A single application of the aura will handle both mh and oh procs.
core.NewEnchantEffect(53344, func(agent core.Agent) {
core.NewEnchantEffect(3368, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 53344
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 53344
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3368
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3368
if !mh && !oh {
return
}
Expand Down Expand Up @@ -502,10 +494,10 @@ func init() {
})
})

core.NewEnchantEffect(70164, func(agent core.Agent) {
core.NewEnchantEffect(3883, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 70164
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 70164
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3883
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3883
if !mh && !oh {
return
}
Expand All @@ -514,10 +506,10 @@ func init() {
character.MultiplyStat(stats.Stamina, 1.01)
})

core.NewEnchantEffect(62158, func(agent core.Agent) {
core.NewEnchantEffect(3847, func(agent core.Agent) {
character := agent.GetCharacter()
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.ID == 62158
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.ID == 62158
mh := character.Equip[proto.ItemSlot_ItemSlotMainHand].Enchant.EffectID == 3847
oh := character.Equip[proto.ItemSlot_ItemSlotOffHand].Enchant.EffectID == 3847
if !mh {
return
}
Expand All @@ -530,7 +522,7 @@ func init() {
character.MultiplyStat(stats.Stamina, 1.02)
})

core.NewEnchantEffect(55642, func(agent core.Agent) {
core.NewEnchantEffect(3722, func(agent core.Agent) {
character := agent.GetCharacter()

procAura := character.NewTemporaryStatsAura("Lightweave Embroidery Proc", core.ActionID{SpellID: 55637}, stats.Stats{stats.SpellPower: 295}, time.Second*15)
Expand All @@ -554,7 +546,7 @@ func init() {
})
})

core.NewEnchantEffect(55769, func(agent core.Agent) {
core.NewEnchantEffect(3728, func(agent core.Agent) {
character := agent.GetCharacter()
if !character.HasManaBar() {
return
Expand All @@ -581,7 +573,7 @@ func init() {
})
})

core.NewEnchantEffect(55777, func(agent core.Agent) {
core.NewEnchantEffect(3730, func(agent core.Agent) {
character := agent.GetCharacter()

procAura := character.NewTemporaryStatsAura("Swordguard Embroidery Proc", core.ActionID{SpellID: 55775}, stats.Stats{stats.AttackPower: 400, stats.RangedAttackPower: 400}, time.Second*15)
Expand Down
4 changes: 2 additions & 2 deletions sim/core/character.go
Original file line number Diff line number Diff line change
Expand Up @@ -178,11 +178,11 @@ func (character *Character) applyItemEffects(agent Agent) {
}

// TODO: should we use eq.Enchant.EffectID because some enchants use a spellID instead of itemID?
if applyEnchantEffect, ok := enchantEffects[eq.Enchant.ID]; ok {
if applyEnchantEffect, ok := enchantEffects[eq.Enchant.EffectID]; ok {
applyEnchantEffect(agent)
}

if applyWeaponEffect, ok := weaponEffects[eq.Enchant.ID]; ok {
if applyWeaponEffect, ok := weaponEffects[eq.Enchant.EffectID]; ok {
applyWeaponEffect(agent, proto.ItemSlot(slot))
}
}
Expand Down
Loading

0 comments on commit eb859fa

Please sign in to comment.