Core/Misc: Turn ChrSpecialization into enum

Port From (https://github.com/TrinityCore/TrinityCore/commit/98007f859b7318570c0c923a00aa32fc485c8ec8)
This commit is contained in:
hondacrx
2023-09-13 20:33:47 -04:00
parent a8e62cc07d
commit 3052b1dc23
25 changed files with 69 additions and 56 deletions
+3 -1
View File
@@ -1128,6 +1128,7 @@ namespace Framework.Constants
public enum ChrSpecialization public enum ChrSpecialization
{ {
None = 0,
MageArcane = 62, MageArcane = 62,
MageFire = 63, MageFire = 63,
MageFrost = 64, MageFrost = 64,
@@ -1165,7 +1166,8 @@ namespace Framework.Constants
DemonHunterHavoc = 577, DemonHunterHavoc = 577,
DemonHunterVengeance = 581, DemonHunterVengeance = 581,
EvokerDevastation = 1467, EvokerDevastation = 1467,
EvokerPreservation = 1468 EvokerPreservation = 1468,
EvokerAugmentation = 1473
} }
public enum ContentTuningCalcType public enum ContentTuningCalcType
+6 -6
View File
@@ -377,7 +377,7 @@ namespace Game.AI
public class PlayerAI : UnitAI public class PlayerAI : UnitAI
{ {
protected new Player me; protected new Player me;
uint _selfSpec; ChrSpecialization _selfSpec;
bool _isSelfHealer; bool _isSelfHealer;
bool _isSelfRangedAttacker; bool _isSelfRangedAttacker;
@@ -394,8 +394,8 @@ namespace Game.AI
if (!who) if (!who)
return false; return false;
return who.GetPrimarySpecialization() != 0 var chrSpec = who.GetPrimarySpecializationEntry();
&& CliDB.ChrSpecializationStorage.LookupByKey(who.GetPrimarySpecialization()).GetRole() == ChrSpecializationRole.Healer; return chrSpec != null && chrSpec.GetRole() == ChrSpecializationRole.Healer;
} }
bool IsPlayerRangedAttacker(Player who) bool IsPlayerRangedAttacker(Player who)
@@ -403,8 +403,8 @@ namespace Game.AI
if (!who) if (!who)
return false; return false;
return who.GetPrimarySpecialization() != 0 var chrSpec = who.GetPrimarySpecializationEntry();
&& CliDB.ChrSpecializationStorage.LookupByKey(who.GetPrimarySpecialization()).GetFlags() == ChrSpecializationFlag.Ranged; return chrSpec != null && chrSpec.GetFlags().HasFlag(ChrSpecializationFlag.Ranged);
} }
Tuple<Spell, Unit> VerifySpellCast(uint spellId, Unit target) Tuple<Spell, Unit> VerifySpellCast(uint spellId, Unit target)
@@ -613,7 +613,7 @@ namespace Game.AI
return (!who || who == me) ? _isSelfHealer : IsPlayerHealer(who); return (!who || who == me) ? _isSelfHealer : IsPlayerHealer(who);
} }
public bool IsRangedAttacker(Player who = null) { return (!who || who == me) ? _isSelfRangedAttacker : IsPlayerRangedAttacker(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 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; } public virtual Unit SelectAttackTarget() { return me.GetCharmer() ? me.GetCharmer().GetVictim() : null; }
+2 -2
View File
@@ -3112,7 +3112,7 @@ namespace Game.Achievements
break; break;
case ModifierTreeType.PlayerLootSpecializationMatchesRole: // 263 case ModifierTreeType.PlayerLootSpecializationMatchesRole: // 263
{ {
ChrSpecializationRecord spec = CliDB.ChrSpecializationStorage.LookupByKey(referencePlayer.GetPrimarySpecialization()); ChrSpecializationRecord spec = referencePlayer.GetPrimarySpecializationEntry();
if (spec == null || spec.Role != reqValue) if (spec == null || spec.Role != reqValue)
return false; return false;
break; break;
@@ -3256,7 +3256,7 @@ namespace Game.Achievements
return false; return false;
} }
case ModifierTreeType.PlayerSpecialization: // 279 case ModifierTreeType.PlayerSpecialization: // 279
if (referencePlayer.GetPrimarySpecialization() != reqValue) if (referencePlayer.GetPrimarySpecialization() != (ChrSpecialization)reqValue)
return false; return false;
break; break;
case ModifierTreeType.PlayerMapOrCosmeticChildMap: // 280 case ModifierTreeType.PlayerMapOrCosmeticChildMap: // 280
@@ -936,7 +936,6 @@ namespace Game.BattleGrounds
BattlegroundPlayer bp = new(); BattlegroundPlayer bp = new();
bp.OfflineRemoveTime = 0; bp.OfflineRemoveTime = 0;
bp.Team = team; bp.Team = team;
bp.ActiveSpec = (int)player.GetPrimarySpecialization();
bp.Mercenary = player.IsMercenaryForBattlegroundQueueType(GetQueueId()); bp.Mercenary = player.IsMercenaryForBattlegroundQueueType(GetQueueId());
bool isInBattleground = IsPlayerInBattleground(player.GetGUID()); 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 long OfflineRemoveTime; // for tracking and removing offline players from queue after 5 Time.Minutes
public Team Team; // Player's team public Team Team; // Player's team
public int ActiveSpec; // Player's active spec
public bool Mercenary; public bool Mercenary;
} }
} }
+1 -1
View File
@@ -207,7 +207,7 @@ namespace Game.Chat.Commands
if (playerClass != talentInfo.ClassID) if (playerClass != talentInfo.ClassID)
continue; continue;
if (talentInfo.SpecID != 0 && player.GetPrimarySpecialization() != talentInfo.SpecID) if (talentInfo.SpecID != 0 && player.GetPrimarySpecialization() != (ChrSpecialization)talentInfo.SpecID)
continue; continue;
SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(talentInfo.SpellID, Difficulty.None); SpellInfo spellInfo = Global.SpellMgr.GetSpellInfo(talentInfo.SpellID, Difficulty.None);
+5 -5
View File
@@ -2047,7 +2047,7 @@ namespace Game
if (condition.ChrSpecializationIndex >= 0 || condition.ChrSpecializationRole >= 0) 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 (spec != null)
{ {
if (condition.ChrSpecializationIndex >= 0 && spec.OrderIndex != condition.ChrSpecializationIndex) if (condition.ChrSpecializationIndex >= 0 && spec.OrderIndex != condition.ChrSpecializationIndex)
@@ -2742,13 +2742,13 @@ namespace Game
case UnitConditionVariable.IsEnemy: case UnitConditionVariable.IsEnemy:
return (otherUnit && unit.GetReactionTo(otherUnit) <= ReputationRank.Hostile) ? 1 : 0; return (otherUnit && unit.GetReactionTo(otherUnit) <= ReputationRank.Hostile) ? 1 : 0;
case UnitConditionVariable.IsSpecMelee: 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: 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: 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: 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: case UnitConditionVariable.IsPlayerControlledNPC:
return unit.IsCreature() && unit.HasUnitFlag(UnitFlags.PlayerControlled) ? 1 : 0; return unit.IsCreature() && unit.HasUnitFlag(UnitFlags.PlayerControlled) ? 1 : 0;
case UnitConditionVariable.IsDying: case UnitConditionVariable.IsDying:
+3 -3
View File
@@ -288,7 +288,7 @@ namespace Game.DataStorage
_glyphBindableSpells.Add(glyphBindableSpell.GlyphPropertiesID, (uint)glyphBindableSpell.SpellID); _glyphBindableSpells.Add(glyphBindableSpell.GlyphPropertiesID, (uint)glyphBindableSpell.SpellID);
foreach (GlyphRequiredSpecRecord glyphRequiredSpec in GlyphRequiredSpecStorage.Values) 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) foreach (ItemChildEquipmentRecord itemChildEquipment in ItemChildEquipmentStorage.Values)
{ {
@@ -1442,7 +1442,7 @@ namespace Game.DataStorage
return _glyphBindableSpells.LookupByKey(glyphPropertiesId); return _glyphBindableSpells.LookupByKey(glyphPropertiesId);
} }
public List<uint> GetGlyphRequiredSpecs(uint glyphPropertiesId) public List<ChrSpecialization> GetGlyphRequiredSpecs(uint glyphPropertiesId)
{ {
return _glyphRequiredSpecs.LookupByKey(glyphPropertiesId); return _glyphRequiredSpecs.LookupByKey(glyphPropertiesId);
} }
@@ -2253,7 +2253,7 @@ namespace Game.DataStorage
MultiMap<uint, FriendshipRepReactionRecord> _friendshipRepReactions = new(); MultiMap<uint, FriendshipRepReactionRecord> _friendshipRepReactions = new();
Dictionary<uint, HeirloomRecord> _heirlooms = new(); Dictionary<uint, HeirloomRecord> _heirlooms = new();
MultiMap<uint, uint> _glyphBindableSpells = new(); MultiMap<uint, uint> _glyphBindableSpells = new();
MultiMap<uint, uint> _glyphRequiredSpecs = new(); MultiMap<uint, ChrSpecialization> _glyphRequiredSpecs = new();
Dictionary<uint, ItemChildEquipmentRecord> _itemChildEquipment = new(); Dictionary<uint, ItemChildEquipmentRecord> _itemChildEquipment = new();
ItemClassRecord[] _itemClassByOldEnum = new ItemClassRecord[20]; ItemClassRecord[] _itemClassByOldEnum = new ItemClassRecord[20];
List<uint> _itemsWithCurrencyCost = new(); List<uint> _itemsWithCurrencyCost = new();
+2 -2
View File
@@ -159,7 +159,7 @@ namespace Game.Entities
selectedEssences.ModifyValue(selectedEssences.AzeriteEssenceID, i) = selectedEssenceData.AzeriteEssenceId[i]; 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); selectedEssences.ModifyValue(selectedEssences.Enabled).SetValue(true);
AddDynamicUpdateFieldValue(m_values.ModifyValue(m_azeriteItemData).ModifyValue(m_azeriteItemData.SelectedEssences), selectedEssences); AddDynamicUpdateFieldValue(m_values.ModifyValue(m_azeriteItemData).ModifyValue(m_azeriteItemData.SelectedEssences), selectedEssences);
@@ -167,7 +167,7 @@ namespace Game.Entities
// add selected essences for current spec // add selected essences for current spec
if (owner != null && GetSelectedAzeriteEssences() == null) if (owner != null && GetSelectedAzeriteEssences() == null)
CreateSelectedAzeriteEssences(owner.GetPrimarySpecialization()); CreateSelectedAzeriteEssences((uint)owner.GetPrimarySpecialization());
if (needSave) if (needSave)
{ {
+1 -1
View File
@@ -2503,7 +2503,7 @@ namespace Game.Entities
eff.SetBonuses.Add(itemSetSpell); eff.SetBonuses.Add(itemSetSpell);
// spell cast only if fit form requirement, in other case will cast at form change // 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); player.ApplyEquipSpell(spellInfo, null, true);
} }
} }
+1 -1
View File
@@ -241,7 +241,7 @@ namespace Game.Entities
uint spec = player.GetLootSpecId(); uint spec = player.GetLootSpecId();
if (spec == 0) if (spec == 0)
spec = player.GetPrimarySpecialization(); spec = (uint)player.GetPrimarySpecialization();
if (spec == 0) if (spec == 0)
spec = player.GetDefaultSpecId(); spec = player.GetDefaultSpecId();
+4 -4
View File
@@ -1137,7 +1137,7 @@ namespace Game.Entities
int activeConfig = m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig => int activeConfig = m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig =>
{ {
return traitConfig.Type == (int)TraitConfigType.Combat return traitConfig.Type == (int)TraitConfigType.Combat
&& traitConfig.ChrSpecializationID == GetPrimarySpecialization() && traitConfig.ChrSpecializationID == (int)GetPrimarySpecialization()
&& (traitConfig.CombatConfigFlags & (int)TraitCombatConfigFlags.ActiveForSpec) != 0; && (traitConfig.CombatConfigFlags & (int)TraitCombatConfigFlags.ActiveForSpec) != 0;
}); });
@@ -3321,7 +3321,7 @@ namespace Game.Entities
SetNumRespecs(numRespecs); SetNumRespecs(numRespecs);
SetPrimarySpecialization(primarySpecialization); SetPrimarySpecialization(primarySpecialization);
SetActiveTalentGroup(activeTalentGroup); SetActiveTalentGroup(activeTalentGroup);
ChrSpecializationRecord primarySpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization()); ChrSpecializationRecord primarySpec = GetPrimarySpecializationEntry();
if (primarySpec == null || primarySpec.ClassID != (byte)GetClass() || GetActiveTalentGroup() >= PlayerConst.MaxSpecializations) if (primarySpec == null || primarySpec.ClassID != (byte)GetClass() || GetActiveTalentGroup() >= PlayerConst.MaxSpecializations)
ResetTalentSpecialization(); ResetTalentSpecialization();
@@ -3676,7 +3676,7 @@ namespace Game.Entities
//save, but in tavern/city //save, but in tavern/city
stmt.AddValue(index++, GetTalentResetCost()); stmt.AddValue(index++, GetTalentResetCost());
stmt.AddValue(index++, GetTalentResetTime()); stmt.AddValue(index++, GetTalentResetTime());
stmt.AddValue(index++, GetPrimarySpecialization()); stmt.AddValue(index++, (uint)GetPrimarySpecialization());
stmt.AddValue(index++, (ushort)m_ExtraFlags); stmt.AddValue(index++, (ushort)m_ExtraFlags);
stmt.AddValue(index++, 0); // summonedPetNumber stmt.AddValue(index++, 0); // summonedPetNumber
stmt.AddValue(index++, (ushort)atLoginFlags); stmt.AddValue(index++, (ushort)atLoginFlags);
@@ -3806,7 +3806,7 @@ namespace Game.Entities
stmt.AddValue(index++, GetTalentResetCost()); stmt.AddValue(index++, GetTalentResetCost());
stmt.AddValue(index++, GetTalentResetTime()); stmt.AddValue(index++, GetTalentResetTime());
stmt.AddValue(index++, GetNumRespecs()); stmt.AddValue(index++, GetNumRespecs());
stmt.AddValue(index++, GetPrimarySpecialization()); stmt.AddValue(index++, (uint)GetPrimarySpecialization());
stmt.AddValue(index++, (ushort)m_ExtraFlags); stmt.AddValue(index++, (ushort)m_ExtraFlags);
PetStable petStable = GetPetStable(); PetStable petStable = GetPetStable();
if (petStable != null) if (petStable != null)
+3 -3
View File
@@ -1481,7 +1481,7 @@ namespace Game.Entities
ArtifactRecord artifact = CliDB.ArtifactStorage.LookupByKey(proto.GetArtifactID()); ArtifactRecord artifact = CliDB.ArtifactStorage.LookupByKey(proto.GetArtifactID());
if (artifact != null) if (artifact != null)
if (artifact.ChrSpecializationID != GetPrimarySpecialization()) if ((ChrSpecialization)artifact.ChrSpecializationID != GetPrimarySpecialization())
return InventoryResult.CantUseItem; return InventoryResult.CantUseItem;
return InventoryResult.Ok; return InventoryResult.Ok;
@@ -3829,7 +3829,7 @@ namespace Game.Entities
if (spellproto == null) if (spellproto == null)
continue; continue;
if (effectData.ChrSpecializationID != 0 && effectData.ChrSpecializationID != GetPrimarySpecialization()) if (effectData.ChrSpecializationID != 0 && (ChrSpecialization)effectData.ChrSpecializationID != GetPrimarySpecialization())
continue; continue;
ApplyEquipSpell(spellproto, item, apply, formChange); ApplyEquipSpell(spellproto, item, apply, formChange);
@@ -5495,7 +5495,7 @@ namespace Game.Entities
{ {
if (apply) 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); CastSpell(this, azeritePower.SpellID, item);
} }
else else
+3 -3
View File
@@ -299,7 +299,7 @@ namespace Game.Entities
void LearnSpecializationSpells() void LearnSpecializationSpells()
{ {
var specSpells = Global.DB2Mgr.GetSpecializationSpells(GetPrimarySpecialization()); var specSpells = Global.DB2Mgr.GetSpecializationSpells((uint)GetPrimarySpecialization());
if (specSpells != null) if (specSpells != null)
{ {
for (int j = 0; j < specSpells.Count; ++j) for (int j = 0; j < specSpells.Count; ++j)
@@ -1029,7 +1029,7 @@ namespace Game.Entities
public bool CanUseMastery() public bool CanUseMastery()
{ {
ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization()); ChrSpecializationRecord chrSpec = GetPrimarySpecializationEntry();
if (chrSpec != null) if (chrSpec != null)
return HasSpell(chrSpec.MasterySpellID[0]) || HasSpell(chrSpec.MasterySpellID[1]); 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); 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 ApplyEquipSpell(spellInfo, null, false, false); // item set aura is not for current spec
else else
{ {
+20 -7
View File
@@ -120,14 +120,14 @@ namespace Game.Entities
if (IsDead()) if (IsDead())
return TalentLearnResult.FailedCantDoThatRightNow; return TalentLearnResult.FailedCantDoThatRightNow;
if (GetPrimarySpecialization() == 0) if (GetPrimarySpecialization() == ChrSpecialization.None)
return TalentLearnResult.FailedNoPrimaryTreeSelected; return TalentLearnResult.FailedNoPrimaryTreeSelected;
TalentRecord talentInfo = CliDB.TalentStorage.LookupByKey(talentId); TalentRecord talentInfo = CliDB.TalentStorage.LookupByKey(talentId);
if (talentInfo == null) if (talentInfo == null)
return TalentLearnResult.FailedUnknown; return TalentLearnResult.FailedUnknown;
if (talentInfo.SpecID != 0 && talentInfo.SpecID != GetPrimarySpecialization()) if (talentInfo.SpecID != 0 && (ChrSpecialization)talentInfo.SpecID != GetPrimarySpecialization())
return TalentLearnResult.FailedUnknown; return TalentLearnResult.FailedUnknown;
// prevent learn talent for different class (cheating) // prevent learn talent for different class (cheating)
@@ -152,7 +152,7 @@ namespace Game.Entities
if (talent.SpecID == 0) if (talent.SpecID == 0)
bestSlotMatch = talent; bestSlotMatch = talent;
else if (talent.SpecID == GetPrimarySpecialization()) else if ((ChrSpecialization)talent.SpecID == GetPrimarySpecialization())
{ {
bestSlotMatch = talent; bestSlotMatch = talent;
break; break;
@@ -167,7 +167,7 @@ namespace Game.Entities
{ {
foreach (TalentRecord talent in Global.DB2Mgr.GetTalentsByPosition(GetClass(), talentInfo.TierID, c)) 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; continue;
if (!HasTalent(talent.Id, GetActiveTalentGroup())) if (!HasTalent(talent.Id, GetActiveTalentGroup()))
@@ -241,16 +241,29 @@ namespace Game.Entities
} }
uint GetTalentResetCost() { return _specializationInfo.ResetTalentsCost; } uint GetTalentResetCost() { return _specializationInfo.ResetTalentsCost; }
void SetTalentResetCost(uint cost) { _specializationInfo.ResetTalentsCost = cost; } void SetTalentResetCost(uint cost) { _specializationInfo.ResetTalentsCost = cost; }
long GetTalentResetTime() { return _specializationInfo.ResetTalentsTime; } long GetTalentResetTime() { return _specializationInfo.ResetTalentsTime; }
void SetTalentResetTime(long time_) { _specializationInfo.ResetTalentsTime = time_; } 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); } 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; } public byte GetActiveTalentGroup() { return _specializationInfo.ActiveGroup; }
void SetActiveTalentGroup(byte group) { _specializationInfo.ActiveGroup = group; } void SetActiveTalentGroup(byte group) { _specializationInfo.ActiveGroup = group; }
// Loot Spec // Loot Spec
public void SetLootSpecId(uint id) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.LootSpecID), (ushort)id); } 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 GetLootSpecId() { return m_activePlayerData.LootSpecID; }
public uint GetDefaultSpecId() public uint GetDefaultSpecId()
@@ -602,7 +615,7 @@ namespace Game.Entities
public void SendTalentsInfoData() public void SendTalentsInfoData()
{ {
UpdateTalentData packet = new(); UpdateTalentData packet = new();
packet.Info.PrimarySpecialization = GetPrimarySpecialization(); packet.Info.PrimarySpecialization = (uint)GetPrimarySpecialization();
for (byte i = 0; i < PlayerConst.MaxSpecializations; ++i) for (byte i = 0; i < PlayerConst.MaxSpecializations; ++i)
{ {
@@ -711,7 +724,7 @@ namespace Game.Entities
if (talentInfo == null) if (talentInfo == null)
return TalentLearnResult.FailedUnknown; return TalentLearnResult.FailedUnknown;
if (talentInfo.SpecID != GetPrimarySpecialization()) if ((ChrSpecialization)talentInfo.SpecID != GetPrimarySpecialization())
return TalentLearnResult.FailedUnknown; return TalentLearnResult.FailedUnknown;
if (talentInfo.LevelRequired > GetLevel()) if (talentInfo.LevelRequired > GetLevel())
+2 -2
View File
@@ -1608,7 +1608,7 @@ namespace Game.Entities
value += GetRatingBonusValue(CombatRating.Mastery); value += GetRatingBonusValue(CombatRating.Mastery);
SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Mastery), value); SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.Mastery), value);
ChrSpecializationRecord chrSpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization()); ChrSpecializationRecord chrSpec = GetPrimarySpecializationEntry();
if (chrSpec == null) if (chrSpec == null)
return; return;
@@ -1982,7 +1982,7 @@ namespace Game.Entities
Stats GetPrimaryStat() Stats GetPrimaryStat()
{ {
byte primaryStatPriority; byte primaryStatPriority;
var specialization = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization()); var specialization = GetPrimarySpecializationEntry();
if (specialization != null) if (specialization != null)
primaryStatPriority = (byte)specialization.PrimaryStatPriority; primaryStatPriority = (byte)specialization.PrimaryStatPriority;
else else
+1 -1
View File
@@ -153,7 +153,7 @@ namespace Game
} }
} }
else else
azeriteItem.CreateSelectedAzeriteEssences(_player.GetPrimarySpecialization()); azeriteItem.CreateSelectedAzeriteEssences((uint)_player.GetPrimarySpecialization());
azeriteItem.SetSelectedAzeriteEssence(azeriteEssenceActivateEssence.Slot, azeriteEssenceActivateEssence.AzeriteEssenceID); azeriteItem.SetSelectedAzeriteEssence(azeriteEssenceActivateEssence.Slot, azeriteEssenceActivateEssence.AzeriteEssenceID);
+2 -2
View File
@@ -148,7 +148,7 @@ namespace Game
while (_player.m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig => while (_player.m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig =>
{ {
return (TraitConfigType)(int)traitConfig.Type == TraitConfigType.Combat return (TraitConfigType)(int)traitConfig.Type == TraitConfigType.Combat
&& traitConfig.ChrSpecializationID == _player.GetPrimarySpecialization() && traitConfig.ChrSpecializationID == (int)_player.GetPrimarySpecialization()
&& traitConfig.LocalIdentifier == index; && traitConfig.LocalIdentifier == index;
}) >= 0) }) >= 0)
++index; ++index;
@@ -219,7 +219,7 @@ namespace Game
while (_player.m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig => while (_player.m_activePlayerData.TraitConfigs.FindIndexIf(traitConfig =>
{ {
return (TraitConfigType)(int)traitConfig.Type == TraitConfigType.Combat return (TraitConfigType)(int)traitConfig.Type == TraitConfigType.Combat
&& traitConfig.ChrSpecializationID == _player.GetPrimarySpecialization() && traitConfig.ChrSpecializationID == (int)_player.GetPrimarySpecialization()
&& traitConfig.LocalIdentifier == freeLocalIdentifier; && traitConfig.LocalIdentifier == freeLocalIdentifier;
}) >= 0) }) >= 0)
++freeLocalIdentifier; ++freeLocalIdentifier;
@@ -220,7 +220,7 @@ namespace Game.Networking.Packets
public void Initialize(Player player) public void Initialize(Player player)
{ {
GUID = player.GetGUID(); GUID = player.GetGUID();
SpecializationID = player.GetPrimarySpecialization(); SpecializationID = (uint)player.GetPrimarySpecialization();
Name = player.GetName(); Name = player.GetName();
GenderID = (byte)player.GetNativeGender(); GenderID = (byte)player.GetNativeGender();
Race = (byte)player.GetRace(); Race = (byte)player.GetRace();
+2 -2
View File
@@ -5111,10 +5111,10 @@ namespace Game.Spells
if (!glyphBindableSpells.Contains(m_misc.SpellId)) if (!glyphBindableSpells.Contains(m_misc.SpellId))
return SpellCastResult.InvalidGlyph; return SpellCastResult.InvalidGlyph;
List<uint> glyphRequiredSpecs = Global.DB2Mgr.GetGlyphRequiredSpecs(glyphId); List<ChrSpecialization> glyphRequiredSpecs = Global.DB2Mgr.GetGlyphRequiredSpecs(glyphId);
if (!glyphRequiredSpecs.Empty()) if (!glyphRequiredSpecs.Empty())
{ {
if (caster.GetPrimarySpecialization() == 0) if (caster.GetPrimarySpecialization() == ChrSpecialization.None)
return SpellCastResult.GlyphNoSpec; return SpellCastResult.GlyphNoSpec;
if (!glyphRequiredSpecs.Contains(caster.GetPrimarySpecialization())) if (!glyphRequiredSpecs.Contains(caster.GetPrimarySpecialization()))
+2 -2
View File
@@ -3115,7 +3115,7 @@ namespace Game.Spells
} }
case SpellProcsPerMinuteModType.Class: case SpellProcsPerMinuteModType.Class:
{ {
if (caster.GetClassMask().HasAnyFlag((uint)mod.Param)) if (caster.GetClassMask().HasAnyFlag(mod.Param))
ppm *= 1.0f + mod.Coeff; ppm *= 1.0f + mod.Coeff;
break; break;
} }
@@ -3123,7 +3123,7 @@ namespace Game.Spells
{ {
Player plrCaster = caster.ToPlayer(); Player plrCaster = caster.ToPlayer();
if (plrCaster) if (plrCaster)
if (plrCaster.GetPrimarySpecialization() == mod.Param) if (plrCaster.GetPrimarySpecialization() == (ChrSpecialization)mod.Param)
ppm *= 1.0f + mod.Coeff; ppm *= 1.0f + mod.Coeff;
break; break;
} }
+1 -1
View File
@@ -481,7 +481,7 @@ namespace Game
if (condition.SpecSetID != 0) if (condition.SpecSetID != 0)
{ {
uint chrSpecializationId = player.GetPrimarySpecialization(); uint chrSpecializationId = (uint)player.GetPrimarySpecialization();
if (traitConfig.Type == TraitConfigType.Combat) if (traitConfig.Type == TraitConfigType.Combat)
chrSpecializationId = (uint)traitConfig.ChrSpecializationID; chrSpecializationId = (uint)traitConfig.ChrSpecializationID;
+1 -1
View File
@@ -4023,7 +4023,7 @@ namespace Scripts.Spells.Items
void updateAuraIfInCorrectSpec(ChrSpecialization spec, AmalgamsSeventhSpineSpellIds aura) void updateAuraIfInCorrectSpec(ChrSpecialization spec, AmalgamsSeventhSpineSpellIds aura)
{ {
if (target.GetPrimarySpecialization() != (uint)spec) if (target.GetPrimarySpecialization() != spec)
target.RemoveAurasDueToSpell((uint)aura); target.RemoveAurasDueToSpell((uint)aura);
else if (!target.HasAura((uint)aura)) else if (!target.HasAura((uint)aura))
target.CastSpell(target, (uint)aura, new CastSpellExtraArgs(aurEff)); target.CastSpell(target, (uint)aura, new CastSpellExtraArgs(aurEff));
+1 -1
View File
@@ -310,7 +310,7 @@ namespace Scripts.Spells.Paladin
if (caster != null) 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 // 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); caster.CastSpell(caster, SpellIds.ConsecrationProtectionAura);
if (caster.IsValidAttackTarget(unit)) if (caster.IsValidAttackTarget(unit))
+1 -1
View File
@@ -537,7 +537,7 @@ namespace Scripts.Spells.Shaman
Player player = GetCaster().ToPlayer(); Player player = GetCaster().ToPlayer();
byte slot = EquipmentSlot.MainHand; byte slot = EquipmentSlot.MainHand;
if (player.GetPrimarySpecialization() == (uint)ChrSpecialization.ShamanEnhancement) if (player.GetPrimarySpecialization() == ChrSpecialization.ShamanEnhancement)
slot = EquipmentSlot.OffHand; slot = EquipmentSlot.OffHand;
Item targetItem = player.GetItemByPos(InventorySlots.Bag0, slot); Item targetItem = player.GetItemByPos(InventorySlots.Bag0, slot);
+1 -1
View File
@@ -696,7 +696,7 @@ namespace Scripts.Spells.Warrior
void HandleOnProc(AuraEffect aurEff, ProcEventInfo procInfo) 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(); PreventDefaultAction();
procInfo.GetActor().GetSpellHistory().ResetCooldown(SpellIds.ImpendingVictory, true); procInfo.GetActor().GetSpellHistory().ResetCooldown(SpellIds.ImpendingVictory, true);