From 3052b1dc23d5c13d62f0dd6dd383fb270a5a8478 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 13 Sep 2023 20:33:47 -0400 Subject: [PATCH] Core/Misc: Turn ChrSpecialization into enum Port From (https://github.com/TrinityCore/TrinityCore/commit/98007f859b7318570c0c923a00aa32fc485c8ec8) --- Source/Framework/Constants/CliDBConst.cs | 4 ++- Source/Game/AI/PlayerAI/PlayerAI.cs | 12 ++++----- Source/Game/Achievements/CriteriaHandler.cs | 4 +-- Source/Game/BattleGrounds/BattleGround.cs | 2 -- Source/Game/Chat/Commands/LearnCommands.cs | 2 +- Source/Game/Conditions/ConditionManager.cs | 10 +++---- Source/Game/DataStorage/DB2Manager.cs | 6 ++--- Source/Game/Entities/Item/AzeriteItem.cs | 4 +-- Source/Game/Entities/Item/Item.cs | 2 +- Source/Game/Entities/Item/ItemTemplate.cs | 2 +- Source/Game/Entities/Player/Player.DB.cs | 8 +++--- Source/Game/Entities/Player/Player.Items.cs | 6 ++--- Source/Game/Entities/Player/Player.Spells.cs | 6 ++--- Source/Game/Entities/Player/Player.Talents.cs | 27 ++++++++++++++----- Source/Game/Entities/StatSystem.cs | 4 +-- Source/Game/Handlers/AzeriteHandler.cs | 2 +- Source/Game/Handlers/TraitHandler.cs | 4 +-- .../Game/Networking/Packets/InspectPackets.cs | 2 +- Source/Game/Spells/Spell.cs | 4 +-- Source/Game/Spells/SpellInfo.cs | 4 +-- Source/Game/Spells/TraitManager.cs | 2 +- Source/Scripts/Spells/Items.cs | 2 +- Source/Scripts/Spells/Paladin.cs | 2 +- Source/Scripts/Spells/Shaman.cs | 2 +- Source/Scripts/Spells/Warrior.cs | 2 +- 25 files changed, 69 insertions(+), 56 deletions(-) diff --git a/Source/Framework/Constants/CliDBConst.cs b/Source/Framework/Constants/CliDBConst.cs index 64a959bb5..fb2f6a07b 100644 --- a/Source/Framework/Constants/CliDBConst.cs +++ b/Source/Framework/Constants/CliDBConst.cs @@ -1128,6 +1128,7 @@ namespace Framework.Constants public enum ChrSpecialization { + None = 0, MageArcane = 62, MageFire = 63, MageFrost = 64, @@ -1165,7 +1166,8 @@ namespace Framework.Constants DemonHunterHavoc = 577, DemonHunterVengeance = 581, EvokerDevastation = 1467, - EvokerPreservation = 1468 + EvokerPreservation = 1468, + EvokerAugmentation = 1473 } public enum ContentTuningCalcType diff --git a/Source/Game/AI/PlayerAI/PlayerAI.cs b/Source/Game/AI/PlayerAI/PlayerAI.cs index 018bfe9df..234cbc8ea 100644 --- a/Source/Game/AI/PlayerAI/PlayerAI.cs +++ b/Source/Game/AI/PlayerAI/PlayerAI.cs @@ -377,7 +377,7 @@ namespace Game.AI public class PlayerAI : UnitAI { protected new Player me; - uint _selfSpec; + ChrSpecialization _selfSpec; bool _isSelfHealer; bool _isSelfRangedAttacker; @@ -394,8 +394,8 @@ namespace Game.AI if (!who) return false; - return who.GetPrimarySpecialization() != 0 - && CliDB.ChrSpecializationStorage.LookupByKey(who.GetPrimarySpecialization()).GetRole() == ChrSpecializationRole.Healer; + var chrSpec = who.GetPrimarySpecializationEntry(); + return chrSpec != null && chrSpec.GetRole() == ChrSpecializationRole.Healer; } bool IsPlayerRangedAttacker(Player who) @@ -403,8 +403,8 @@ namespace Game.AI if (!who) return false; - return who.GetPrimarySpecialization() != 0 - && CliDB.ChrSpecializationStorage.LookupByKey(who.GetPrimarySpecialization()).GetFlags() == ChrSpecializationFlag.Ranged; + var chrSpec = who.GetPrimarySpecializationEntry(); + return chrSpec != null && chrSpec.GetFlags().HasFlag(ChrSpecializationFlag.Ranged); } Tuple VerifySpellCast(uint spellId, Unit target) @@ -613,7 +613,7 @@ namespace Game.AI return (!who || who == me) ? _isSelfHealer : IsPlayerHealer(who); } public bool IsRangedAttacker(Player who = null) { return (!who || who == me) ? _isSelfRangedAttacker : IsPlayerRangedAttacker(who); } - public uint GetSpec(Player who = null) { return (!who || who == me) ? _selfSpec : who.GetPrimarySpecialization(); } + public ChrSpecialization GetSpec(Player who = null) { return (!who || who == me) ? _selfSpec : who.GetPrimarySpecialization(); } public void SetIsRangedAttacker(bool state) { _isSelfRangedAttacker = state; } // this allows overriding of the default ranged attacker detection public virtual Unit SelectAttackTarget() { return me.GetCharmer() ? me.GetCharmer().GetVictim() : null; } diff --git a/Source/Game/Achievements/CriteriaHandler.cs b/Source/Game/Achievements/CriteriaHandler.cs index 836cfc274..2550af549 100644 --- a/Source/Game/Achievements/CriteriaHandler.cs +++ b/Source/Game/Achievements/CriteriaHandler.cs @@ -3112,7 +3112,7 @@ namespace Game.Achievements break; case ModifierTreeType.PlayerLootSpecializationMatchesRole: // 263 { - ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey(referencePlayer.GetPrimarySpecialization()); + ChrSpecializationRecord spec = referencePlayer.GetPrimarySpecializationEntry(); if (spec == null || spec.Role != reqValue) return false; break; @@ -3256,7 +3256,7 @@ namespace Game.Achievements return false; } case ModifierTreeType.PlayerSpecialization: // 279 - if (referencePlayer.GetPrimarySpecialization() != reqValue) + if (referencePlayer.GetPrimarySpecialization() != (ChrSpecialization)reqValue) return false; break; case ModifierTreeType.PlayerMapOrCosmeticChildMap: // 280 diff --git a/Source/Game/BattleGrounds/BattleGround.cs b/Source/Game/BattleGrounds/BattleGround.cs index 99924419a..42f33e509 100644 --- a/Source/Game/BattleGrounds/BattleGround.cs +++ b/Source/Game/BattleGrounds/BattleGround.cs @@ -936,7 +936,6 @@ namespace Game.BattleGrounds BattlegroundPlayer bp = new(); bp.OfflineRemoveTime = 0; bp.Team = team; - bp.ActiveSpec = (int)player.GetPrimarySpecialization(); bp.Mercenary = player.IsMercenaryForBattlegroundQueueType(GetQueueId()); bool isInBattleground = IsPlayerInBattleground(player.GetGUID()); @@ -1993,7 +1992,6 @@ namespace Game.BattleGrounds { public long OfflineRemoveTime; // for tracking and removing offline players from queue after 5 Time.Minutes public Team Team; // Player's team - public int ActiveSpec; // Player's active spec public bool Mercenary; } } diff --git a/Source/Game/Chat/Commands/LearnCommands.cs b/Source/Game/Chat/Commands/LearnCommands.cs index 606976c05..89cad6f92 100644 --- a/Source/Game/Chat/Commands/LearnCommands.cs +++ b/Source/Game/Chat/Commands/LearnCommands.cs @@ -207,7 +207,7 @@ namespace Game.Chat.Commands if (playerClass != talentInfo.ClassID) continue; - if (talentInfo.SpecID != 0 && player.GetPrimarySpecialization() != talentInfo.SpecID) + if (talentInfo.SpecID != 0 && player.GetPrimarySpecialization() != (ChrSpecialization)talentInfo.SpecID) continue; SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(talentInfo.SpellID, Difficulty.None); diff --git a/Source/Game/Conditions/ConditionManager.cs b/Source/Game/Conditions/ConditionManager.cs index 6486dab40..15f7fca0e 100644 --- a/Source/Game/Conditions/ConditionManager.cs +++ b/Source/Game/Conditions/ConditionManager.cs @@ -2047,7 +2047,7 @@ namespace Game if (condition.ChrSpecializationIndex >= 0 || condition.ChrSpecializationRole >= 0) { - ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey(player.GetPrimarySpecialization()); + ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey((uint)player.GetPrimarySpecialization()); if (spec != null) { if (condition.ChrSpecializationIndex >= 0 && spec.OrderIndex != condition.ChrSpecializationIndex) @@ -2742,13 +2742,13 @@ namespace Game case UnitConditionVariable.IsEnemy: return (otherUnit && unit.GetReactionTo(otherUnit) <= ReputationRank.Hostile) ? 1 : 0; case UnitConditionVariable.IsSpecMelee: - return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).GetFlags().HasFlag(ChrSpecializationFlag.Melee)) ? 1 : 0; + return unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecializationEntry() != null && unit.ToPlayer().GetPrimarySpecializationEntry().GetFlags().HasFlag(ChrSpecializationFlag.Melee) ? 1 : 0; case UnitConditionVariable.IsSpecTank: - return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).GetRole() == ChrSpecializationRole.Tank) ? 1 : 0; + return unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecializationEntry() != null && unit.ToPlayer().GetPrimarySpecializationEntry().GetRole() == ChrSpecializationRole.Tank ? 1 : 0; case UnitConditionVariable.IsSpecRanged: - return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).GetFlags().HasFlag(ChrSpecializationFlag.Ranged)) ? 1 : 0; + return unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecializationEntry() != null && unit.ToPlayer().GetPrimarySpecializationEntry().GetFlags().HasFlag(ChrSpecializationFlag.Ranged) ? 1 : 0; case UnitConditionVariable.IsSpecHealer: - return (unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecialization() != 0 && CliDB.ChrSpecializationStorage.LookupByKey(unit.ToPlayer().GetPrimarySpecialization()).GetRole() == ChrSpecializationRole.Healer) ? 1 : 0; + return unit.IsPlayer() && unit.ToPlayer().GetPrimarySpecializationEntry()?.GetRole() == ChrSpecializationRole.Healer ? 1 : 0; case UnitConditionVariable.IsPlayerControlledNPC: return unit.IsCreature() && unit.HasUnitFlag(UnitFlags.PlayerControlled) ? 1 : 0; case UnitConditionVariable.IsDying: diff --git a/Source/Game/DataStorage/DB2Manager.cs b/Source/Game/DataStorage/DB2Manager.cs index ad96e8ea6..fef4de9b1 100644 --- a/Source/Game/DataStorage/DB2Manager.cs +++ b/Source/Game/DataStorage/DB2Manager.cs @@ -288,7 +288,7 @@ namespace Game.DataStorage _glyphBindableSpells.Add(glyphBindableSpell.GlyphPropertiesID, (uint)glyphBindableSpell.SpellID); foreach (GlyphRequiredSpecRecord glyphRequiredSpec in GlyphRequiredSpecStorage.Values) - _glyphRequiredSpecs.Add(glyphRequiredSpec.GlyphPropertiesID, glyphRequiredSpec.ChrSpecializationID); + _glyphRequiredSpecs.Add(glyphRequiredSpec.GlyphPropertiesID, (ChrSpecialization)glyphRequiredSpec.ChrSpecializationID); foreach (ItemChildEquipmentRecord itemChildEquipment in ItemChildEquipmentStorage.Values) { @@ -1442,7 +1442,7 @@ namespace Game.DataStorage return _glyphBindableSpells.LookupByKey(glyphPropertiesId); } - public List GetGlyphRequiredSpecs(uint glyphPropertiesId) + public List GetGlyphRequiredSpecs(uint glyphPropertiesId) { return _glyphRequiredSpecs.LookupByKey(glyphPropertiesId); } @@ -2253,7 +2253,7 @@ namespace Game.DataStorage MultiMap _friendshipRepReactions = new(); Dictionary _heirlooms = new(); MultiMap _glyphBindableSpells = new(); - MultiMap _glyphRequiredSpecs = new(); + MultiMap _glyphRequiredSpecs = new(); Dictionary _itemChildEquipment = new(); ItemClassRecord[] _itemClassByOldEnum = new ItemClassRecord[20]; List _itemsWithCurrencyCost = new(); diff --git a/Source/Game/Entities/Item/AzeriteItem.cs b/Source/Game/Entities/Item/AzeriteItem.cs index 8480db28c..6b48713fc 100644 --- a/Source/Game/Entities/Item/AzeriteItem.cs +++ b/Source/Game/Entities/Item/AzeriteItem.cs @@ -159,7 +159,7 @@ namespace Game.Entities selectedEssences.ModifyValue(selectedEssences.AzeriteEssenceID, i) = selectedEssenceData.AzeriteEssenceId[i]; } - if (owner != null && owner.GetPrimarySpecialization() == selectedEssenceData.SpecializationId) + if (owner != null && owner.GetPrimarySpecialization() == (ChrSpecialization)selectedEssenceData.SpecializationId) selectedEssences.ModifyValue(selectedEssences.Enabled).SetValue(true); AddDynamicUpdateFieldValue(m_values.ModifyValue(m_azeriteItemData).ModifyValue(m_azeriteItemData.SelectedEssences), selectedEssences); @@ -167,7 +167,7 @@ namespace Game.Entities // add selected essences for current spec if (owner != null && GetSelectedAzeriteEssences() == null) - CreateSelectedAzeriteEssences(owner.GetPrimarySpecialization()); + CreateSelectedAzeriteEssences((uint)owner.GetPrimarySpecialization()); if (needSave) { diff --git a/Source/Game/Entities/Item/Item.cs b/Source/Game/Entities/Item/Item.cs index f9a7c59db..05d210bc2 100644 --- a/Source/Game/Entities/Item/Item.cs +++ b/Source/Game/Entities/Item/Item.cs @@ -2503,7 +2503,7 @@ namespace Game.Entities eff.SetBonuses.Add(itemSetSpell); // spell cast only if fit form requirement, in other case will cast at form change - if (itemSetSpell.ChrSpecID == 0 || itemSetSpell.ChrSpecID == player.GetPrimarySpecialization()) + if (itemSetSpell.ChrSpecID == 0 || (ChrSpecialization)itemSetSpell.ChrSpecID == player.GetPrimarySpecialization()) player.ApplyEquipSpell(spellInfo, null, true); } } diff --git a/Source/Game/Entities/Item/ItemTemplate.cs b/Source/Game/Entities/Item/ItemTemplate.cs index a1a85683e..eb2386858 100644 --- a/Source/Game/Entities/Item/ItemTemplate.cs +++ b/Source/Game/Entities/Item/ItemTemplate.cs @@ -241,7 +241,7 @@ namespace Game.Entities uint spec = player.GetLootSpecId(); if (spec == 0) - spec = player.GetPrimarySpecialization(); + spec = (uint)player.GetPrimarySpecialization(); if (spec == 0) spec = player.GetDefaultSpecId(); diff --git a/Source/Game/Entities/Player/Player.DB.cs b/Source/Game/Entities/Player/Player.DB.cs index f85c71d27..6dff071f7 100644 --- a/Source/Game/Entities/Player/Player.DB.cs +++ b/Source/Game/Entities/Player/Player.DB.cs @@ -1137,7 +1137,7 @@ namespace Game.Entities int activeConfig = m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig => { return traitConfig.Type == (int)TraitConfigType.Combat - && traitConfig.ChrSpecializationID == GetPrimarySpecialization() + && traitConfig.ChrSpecializationID == (int)GetPrimarySpecialization() && (traitConfig.CombatConfigFlags & (int)TraitCombatConfigFlags.ActiveForSpec) != 0; }); @@ -3321,7 +3321,7 @@ namespace Game.Entities SetNumRespecs(numRespecs); SetPrimarySpecialization(primarySpecialization); SetActiveTalentGroup(activeTalentGroup); - ChrSpecializationRecord primarySpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization()); + ChrSpecializationRecord primarySpec = GetPrimarySpecializationEntry(); if (primarySpec == null || primarySpec.ClassID != (byte)GetClass() || GetActiveTalentGroup() >= PlayerConst.MaxSpecializations) ResetTalentSpecialization(); @@ -3676,7 +3676,7 @@ namespace Game.Entities //save, but in tavern/city stmt.AddValue(index++, GetTalentResetCost()); stmt.AddValue(index++, GetTalentResetTime()); - stmt.AddValue(index++, GetPrimarySpecialization()); + stmt.AddValue(index++, (uint)GetPrimarySpecialization()); stmt.AddValue(index++, (ushort)m_ExtraFlags); stmt.AddValue(index++, 0); // summonedPetNumber stmt.AddValue(index++, (ushort)atLoginFlags); @@ -3806,7 +3806,7 @@ namespace Game.Entities stmt.AddValue(index++, GetTalentResetCost()); stmt.AddValue(index++, GetTalentResetTime()); stmt.AddValue(index++, GetNumRespecs()); - stmt.AddValue(index++, GetPrimarySpecialization()); + stmt.AddValue(index++, (uint)GetPrimarySpecialization()); stmt.AddValue(index++, (ushort)m_ExtraFlags); PetStable petStable = GetPetStable(); if (petStable != null) diff --git a/Source/Game/Entities/Player/Player.Items.cs b/Source/Game/Entities/Player/Player.Items.cs index 5a770bfad..43f5c7b0a 100644 --- a/Source/Game/Entities/Player/Player.Items.cs +++ b/Source/Game/Entities/Player/Player.Items.cs @@ -1481,7 +1481,7 @@ namespace Game.Entities ArtifactRecord artifact = CliDB.ArtifactStorage.LookupByKey(proto.GetArtifactID()); if (artifact != null) - if (artifact.ChrSpecializationID != GetPrimarySpecialization()) + if ((ChrSpecialization)artifact.ChrSpecializationID != GetPrimarySpecialization()) return InventoryResult.CantUseItem; return InventoryResult.Ok; @@ -3829,7 +3829,7 @@ namespace Game.Entities if (spellproto == null) continue; - if (effectData.ChrSpecializationID != 0 && effectData.ChrSpecializationID != GetPrimarySpecialization()) + if (effectData.ChrSpecializationID != 0 && (ChrSpecialization)effectData.ChrSpecializationID != GetPrimarySpecialization()) continue; ApplyEquipSpell(spellproto, item, apply, formChange); @@ -5495,7 +5495,7 @@ namespace Game.Entities { if (apply) { - if (azeritePower.SpecSetID == 0 || Global.DB2Mgr.IsSpecSetMember(azeritePower.SpecSetID, GetPrimarySpecialization())) + if (azeritePower.SpecSetID == 0 || Global.DB2Mgr.IsSpecSetMember(azeritePower.SpecSetID, (uint)GetPrimarySpecialization())) CastSpell(this, azeritePower.SpellID, item); } else diff --git a/Source/Game/Entities/Player/Player.Spells.cs b/Source/Game/Entities/Player/Player.Spells.cs index 59756c889..95c00e5e8 100644 --- a/Source/Game/Entities/Player/Player.Spells.cs +++ b/Source/Game/Entities/Player/Player.Spells.cs @@ -299,7 +299,7 @@ namespace Game.Entities void LearnSpecializationSpells() { - var specSpells = Global.DB2Mgr.GetSpecializationSpells(GetPrimarySpecialization()); + var specSpells = Global.DB2Mgr.GetSpecializationSpells((uint)GetPrimarySpecialization()); if (specSpells != null) { for (int j = 0; j < specSpells.Count; ++j) @@ -1029,7 +1029,7 @@ namespace Game.Entities public bool CanUseMastery() { - ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization()); + ChrSpecializationRecord chrSpec = GetPrimarySpecializationEntry(); if (chrSpec != null) return HasSpell(chrSpec.MasterySpellID[0]) || HasSpell(chrSpec.MasterySpellID[1]); @@ -3257,7 +3257,7 @@ namespace Game.Entities { SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(itemSetSpell.SpellID, Difficulty.None); - if (itemSetSpell.ChrSpecID != 0 && itemSetSpell.ChrSpecID != GetPrimarySpecialization()) + if (itemSetSpell.ChrSpecID != 0 && (ChrSpecialization)itemSetSpell.ChrSpecID != GetPrimarySpecialization()) ApplyEquipSpell(spellInfo, null, false, false); // item set aura is not for current spec else { diff --git a/Source/Game/Entities/Player/Player.Talents.cs b/Source/Game/Entities/Player/Player.Talents.cs index 66ffeb281..3971be6af 100644 --- a/Source/Game/Entities/Player/Player.Talents.cs +++ b/Source/Game/Entities/Player/Player.Talents.cs @@ -120,14 +120,14 @@ namespace Game.Entities if (IsDead()) return TalentLearnResult.FailedCantDoThatRightNow; - if (GetPrimarySpecialization() == 0) + if (GetPrimarySpecialization() == ChrSpecialization.None) return TalentLearnResult.FailedNoPrimaryTreeSelected; TalentRecord talentInfo = CliDB.TalentStorage.LookupByKey(talentId); if (talentInfo == null) return TalentLearnResult.FailedUnknown; - if (talentInfo.SpecID != 0 && talentInfo.SpecID != GetPrimarySpecialization()) + if (talentInfo.SpecID != 0 && (ChrSpecialization)talentInfo.SpecID != GetPrimarySpecialization()) return TalentLearnResult.FailedUnknown; // prevent learn talent for different class (cheating) @@ -152,7 +152,7 @@ namespace Game.Entities if (talent.SpecID == 0) bestSlotMatch = talent; - else if (talent.SpecID == GetPrimarySpecialization()) + else if ((ChrSpecialization)talent.SpecID == GetPrimarySpecialization()) { bestSlotMatch = talent; break; @@ -167,7 +167,7 @@ namespace Game.Entities { foreach (TalentRecord talent in Global.DB2Mgr.GetTalentsByPosition(GetClass(), talentInfo.TierID, c)) { - if (talent.SpecID != 0 && talent.SpecID != GetPrimarySpecialization()) + if (talent.SpecID != 0 && (ChrSpecialization)talent.SpecID != GetPrimarySpecialization()) continue; if (!HasTalent(talent.Id, GetActiveTalentGroup())) @@ -241,16 +241,29 @@ namespace Game.Entities } uint GetTalentResetCost() { return _specializationInfo.ResetTalentsCost; } + void SetTalentResetCost(uint cost) { _specializationInfo.ResetTalentsCost = cost; } + long GetTalentResetTime() { return _specializationInfo.ResetTalentsTime; } + void SetTalentResetTime(long time_) { _specializationInfo.ResetTalentsTime = time_; } - public uint GetPrimarySpecialization() { return m_playerData.CurrentSpecID; } + + public ChrSpecialization GetPrimarySpecialization() { return (ChrSpecialization)m_playerData.CurrentSpecID.GetValue(); } + void SetPrimarySpecialization(uint spec) { SetUpdateFieldValue(m_values.ModifyValue(m_playerData).ModifyValue(m_playerData.CurrentSpecID), spec); } + + public ChrSpecializationRecord GetPrimarySpecializationEntry() + { + return CliDB.ChrSpecializationStorage.LookupByKey((uint)GetPrimarySpecialization()); + } + public byte GetActiveTalentGroup() { return _specializationInfo.ActiveGroup; } + void SetActiveTalentGroup(byte group) { _specializationInfo.ActiveGroup = group; } // Loot Spec public void SetLootSpecId(uint id) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.LootSpecID), (ushort)id); } + public uint GetLootSpecId() { return m_activePlayerData.LootSpecID; } public uint GetDefaultSpecId() @@ -602,7 +615,7 @@ namespace Game.Entities public void SendTalentsInfoData() { UpdateTalentData packet = new(); - packet.Info.PrimarySpecialization = GetPrimarySpecialization(); + packet.Info.PrimarySpecialization = (uint)GetPrimarySpecialization(); for (byte i = 0; i < PlayerConst.MaxSpecializations; ++i) { @@ -711,7 +724,7 @@ namespace Game.Entities if (talentInfo == null) return TalentLearnResult.FailedUnknown; - if (talentInfo.SpecID != GetPrimarySpecialization()) + if ((ChrSpecialization)talentInfo.SpecID != GetPrimarySpecialization()) return TalentLearnResult.FailedUnknown; if (talentInfo.LevelRequired > GetLevel()) diff --git a/Source/Game/Entities/StatSystem.cs b/Source/Game/Entities/StatSystem.cs index b1a31e3e3..ea52e2c7e 100644 --- a/Source/Game/Entities/StatSystem.cs +++ b/Source/Game/Entities/StatSystem.cs @@ -1608,7 +1608,7 @@ namespace Game.Entities value += GetRatingBonusValue(CombatRating.Mastery); SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Mastery), value); - ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization()); + ChrSpecializationRecord chrSpec = GetPrimarySpecializationEntry(); if (chrSpec == null) return; @@ -1982,7 +1982,7 @@ namespace Game.Entities Stats GetPrimaryStat() { byte primaryStatPriority; - var specialization = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization()); + var specialization = GetPrimarySpecializationEntry(); if (specialization != null) primaryStatPriority = (byte)specialization.PrimaryStatPriority; else diff --git a/Source/Game/Handlers/AzeriteHandler.cs b/Source/Game/Handlers/AzeriteHandler.cs index c7d941206..843f6bdc6 100644 --- a/Source/Game/Handlers/AzeriteHandler.cs +++ b/Source/Game/Handlers/AzeriteHandler.cs @@ -153,7 +153,7 @@ namespace Game } } else - azeriteItem.CreateSelectedAzeriteEssences(_player.GetPrimarySpecialization()); + azeriteItem.CreateSelectedAzeriteEssences((uint)_player.GetPrimarySpecialization()); azeriteItem.SetSelectedAzeriteEssence(azeriteEssenceActivateEssence.Slot, azeriteEssenceActivateEssence.AzeriteEssenceID); diff --git a/Source/Game/Handlers/TraitHandler.cs b/Source/Game/Handlers/TraitHandler.cs index 51e683250..dc5ae73c9 100644 --- a/Source/Game/Handlers/TraitHandler.cs +++ b/Source/Game/Handlers/TraitHandler.cs @@ -148,7 +148,7 @@ namespace Game while (_player.m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig => { return (TraitConfigType)(int)traitConfig.Type == TraitConfigType.Combat - && traitConfig.ChrSpecializationID == _player.GetPrimarySpecialization() + && traitConfig.ChrSpecializationID == (int)_player.GetPrimarySpecialization() && traitConfig.LocalIdentifier == index; }) >= 0) ++index; @@ -219,7 +219,7 @@ namespace Game while (_player.m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig => { return (TraitConfigType)(int)traitConfig.Type == TraitConfigType.Combat - && traitConfig.ChrSpecializationID == _player.GetPrimarySpecialization() + && traitConfig.ChrSpecializationID == (int)_player.GetPrimarySpecialization() && traitConfig.LocalIdentifier == freeLocalIdentifier; }) >= 0) ++freeLocalIdentifier; diff --git a/Source/Game/Networking/Packets/InspectPackets.cs b/Source/Game/Networking/Packets/InspectPackets.cs index 758665d84..fb8682432 100644 --- a/Source/Game/Networking/Packets/InspectPackets.cs +++ b/Source/Game/Networking/Packets/InspectPackets.cs @@ -220,7 +220,7 @@ namespace Game.Networking.Packets public void Initialize(Player player) { GUID = player.GetGUID(); - SpecializationID = player.GetPrimarySpecialization(); + SpecializationID = (uint)player.GetPrimarySpecialization(); Name = player.GetName(); GenderID = (byte)player.GetNativeGender(); Race = (byte)player.GetRace(); diff --git a/Source/Game/Spells/Spell.cs b/Source/Game/Spells/Spell.cs index ebab20a42..2122ebe4c 100644 --- a/Source/Game/Spells/Spell.cs +++ b/Source/Game/Spells/Spell.cs @@ -5111,10 +5111,10 @@ namespace Game.Spells if (!glyphBindableSpells.Contains(m_misc.SpellId)) return SpellCastResult.InvalidGlyph; - List glyphRequiredSpecs = Global.DB2Mgr.GetGlyphRequiredSpecs(glyphId); + List glyphRequiredSpecs = Global.DB2Mgr.GetGlyphRequiredSpecs(glyphId); if (!glyphRequiredSpecs.Empty()) { - if (caster.GetPrimarySpecialization() == 0) + if (caster.GetPrimarySpecialization() == ChrSpecialization.None) return SpellCastResult.GlyphNoSpec; if (!glyphRequiredSpecs.Contains(caster.GetPrimarySpecialization())) diff --git a/Source/Game/Spells/SpellInfo.cs b/Source/Game/Spells/SpellInfo.cs index ceefc95b7..13a71808a 100644 --- a/Source/Game/Spells/SpellInfo.cs +++ b/Source/Game/Spells/SpellInfo.cs @@ -3115,7 +3115,7 @@ namespace Game.Spells } case SpellProcsPerMinuteModType.Class: { - if (caster.GetClassMask().HasAnyFlag((uint)mod.Param)) + if (caster.GetClassMask().HasAnyFlag(mod.Param)) ppm *= 1.0f + mod.Coeff; break; } @@ -3123,7 +3123,7 @@ namespace Game.Spells { Player plrCaster = caster.ToPlayer(); if (plrCaster) - if (plrCaster.GetPrimarySpecialization() == mod.Param) + if (plrCaster.GetPrimarySpecialization() == (ChrSpecialization)mod.Param) ppm *= 1.0f + mod.Coeff; break; } diff --git a/Source/Game/Spells/TraitManager.cs b/Source/Game/Spells/TraitManager.cs index a9766b4ef..10e7d0d73 100644 --- a/Source/Game/Spells/TraitManager.cs +++ b/Source/Game/Spells/TraitManager.cs @@ -481,7 +481,7 @@ namespace Game if (condition.SpecSetID != 0) { - uint chrSpecializationId = player.GetPrimarySpecialization(); + uint chrSpecializationId = (uint)player.GetPrimarySpecialization(); if (traitConfig.Type == TraitConfigType.Combat) chrSpecializationId = (uint)traitConfig.ChrSpecializationID; diff --git a/Source/Scripts/Spells/Items.cs b/Source/Scripts/Spells/Items.cs index 394cf6c9d..eb13c47e0 100644 --- a/Source/Scripts/Spells/Items.cs +++ b/Source/Scripts/Spells/Items.cs @@ -4023,7 +4023,7 @@ namespace Scripts.Spells.Items void updateAuraIfInCorrectSpec(ChrSpecialization spec, AmalgamsSeventhSpineSpellIds aura) { - if (target.GetPrimarySpecialization() != (uint)spec) + if (target.GetPrimarySpecialization() != spec) target.RemoveAurasDueToSpell((uint)aura); else if (!target.HasAura((uint)aura)) target.CastSpell(target, (uint)aura, new CastSpellExtraArgs(aurEff)); diff --git a/Source/Scripts/Spells/Paladin.cs b/Source/Scripts/Spells/Paladin.cs index 3b884ac3b..edd125154 100644 --- a/Source/Scripts/Spells/Paladin.cs +++ b/Source/Scripts/Spells/Paladin.cs @@ -310,7 +310,7 @@ namespace Scripts.Spells.Paladin if (caster != null) { // 243597 is also being cast as protection, but CreateObject is not sent, either serverside areatrigger for this aura or unused - also no visual is seen - if (unit == caster && caster.IsPlayer() && caster.ToPlayer().GetPrimarySpecialization() == (uint)ChrSpecialization.PaladinProtection) + if (unit == caster && caster.IsPlayer() && caster.ToPlayer().GetPrimarySpecialization() == ChrSpecialization.PaladinProtection) caster.CastSpell(caster, SpellIds.ConsecrationProtectionAura); if (caster.IsValidAttackTarget(unit)) diff --git a/Source/Scripts/Spells/Shaman.cs b/Source/Scripts/Spells/Shaman.cs index 8be8f4a25..cd9c9155c 100644 --- a/Source/Scripts/Spells/Shaman.cs +++ b/Source/Scripts/Spells/Shaman.cs @@ -537,7 +537,7 @@ namespace Scripts.Spells.Shaman Player player = GetCaster().ToPlayer(); byte slot = EquipmentSlot.MainHand; - if (player.GetPrimarySpecialization() == (uint)ChrSpecialization.ShamanEnhancement) + if (player.GetPrimarySpecialization() == ChrSpecialization.ShamanEnhancement) slot = EquipmentSlot.OffHand; Item targetItem = player.GetItemByPos(InventorySlots.Bag0, slot); diff --git a/Source/Scripts/Spells/Warrior.cs b/Source/Scripts/Spells/Warrior.cs index 4a14d3f98..d17a8691b 100644 --- a/Source/Scripts/Spells/Warrior.cs +++ b/Source/Scripts/Spells/Warrior.cs @@ -696,7 +696,7 @@ namespace Scripts.Spells.Warrior void HandleOnProc(AuraEffect aurEff, ProcEventInfo procInfo) { - if (procInfo.GetActor().GetTypeId() == TypeId.Player && procInfo.GetActor().ToPlayer().GetPrimarySpecialization() == (uint)ChrSpecialization.WarriorFury) + if (procInfo.GetActor().GetTypeId() == TypeId.Player && procInfo.GetActor().ToPlayer().GetPrimarySpecialization() == ChrSpecialization.WarriorFury) PreventDefaultAction(); procInfo.GetActor().GetSpellHistory().ResetCooldown(SpellIds.ImpendingVictory, true);