Core/Items: Implement azerite empowered items

Port From (https://github.com/TrinityCore/TrinityCore/commit/d934824421c83598853487c5cc9e4cbb3c5d0006)
This commit is contained in:
hondacrx
2019-12-05 22:55:44 -05:00
parent 86e1065da0
commit 5b9ad41953
47 changed files with 1050 additions and 239 deletions
+116 -3
View File
@@ -63,8 +63,11 @@ namespace Game.DataStorage
CliDB.ArtifactPowerRankStorage.Clear();
foreach (AzeriteEmpoweredItemRecord azeriteEmpoweredItem in CliDB.AzeriteEmpoweredItemStorage.Values)
_azeriteEmpoweredItems[azeriteEmpoweredItem.ItemID] = azeriteEmpoweredItem;
foreach (AzeriteEssencePowerRecord azeriteEssencePower in CliDB.AzeriteEssencePowerStorage.Values)
_azeriteEssencePowersByIdAndRank[Tuple.Create((uint)azeriteEssencePower.AzeriteEssenceID, (uint)azeriteEssencePower.Tier)] = azeriteEssencePower;
_azeriteEssencePowersByIdAndRank[((uint)azeriteEssencePower.AzeriteEssenceID, (uint)azeriteEssencePower.Tier)] = azeriteEssencePower;
foreach (AzeriteItemMilestonePowerRecord azeriteItemMilestonePower in CliDB.AzeriteItemMilestonePowerStorage.Values)
_azeriteItemMilestonePowers.Add(azeriteItemMilestonePower);
@@ -81,7 +84,25 @@ namespace Game.DataStorage
_azeriteItemMilestonePowerByEssenceSlot[azeriteEssenceSlot] = azeriteItemMilestonePower;
++azeriteEssenceSlot;
}
}
}
foreach (AzeritePowerSetMemberRecord azeritePowerSetMember in CliDB.AzeritePowerSetMemberStorage.Values)
if (CliDB.AzeritePowerStorage.ContainsKey(azeritePowerSetMember.AzeritePowerID))
_azeritePowers.Add(azeritePowerSetMember.AzeritePowerSetID, azeritePowerSetMember);
foreach (AzeriteTierUnlockRecord azeriteTierUnlock in CliDB.AzeriteTierUnlockStorage.Values)
{
var key = (azeriteTierUnlock.AzeriteTierUnlockSetID, (ItemContext)azeriteTierUnlock.ItemCreationContext);
if (!_azeriteTierUnlockLevels.ContainsKey(key))
_azeriteTierUnlockLevels[key] = new byte[SharedConst.MaxAzeriteEmpoweredTier];
_azeriteTierUnlockLevels[key][azeriteTierUnlock.Tier] = azeriteTierUnlock.AzeriteLevel;
}
MultiMap<uint, AzeriteUnlockMappingRecord> azeriteUnlockMappings = new MultiMap<uint, AzeriteUnlockMappingRecord>();
foreach (AzeriteUnlockMappingRecord azeriteUnlockMapping in CliDB.AzeriteUnlockMappingStorage.Values)
azeriteUnlockMappings.Add(azeriteUnlockMapping.AzeriteUnlockMappingSetID, azeriteUnlockMapping);
foreach (CharacterFacialHairStylesRecord characterFacialStyle in CliDB.CharacterFacialHairStylesStorage.Values)
_characterFacialHairStyles.Add(Tuple.Create(characterFacialStyle.RaceID, characterFacialStyle.SexID, (uint)characterFacialStyle.VariationID));
@@ -286,6 +307,9 @@ namespace Game.DataStorage
CliDB.ItemXBonusTreeStorage.Clear();
foreach (var pair in _azeriteEmpoweredItems)
LoadAzeriteEmpoweredItemUnlockMappings(azeriteUnlockMappings, pair.Key);
foreach (MapDifficultyRecord entry in CliDB.MapDifficultyStorage.Values)
{
if (!_mapDifficulties.ContainsKey(entry.MapID))
@@ -745,6 +769,11 @@ namespace Game.DataStorage
return _artifactPowerRanks.LookupByKey(Tuple.Create(artifactPowerId, rank));
}
public AzeriteEmpoweredItemRecord GetAzeriteEmpoweredItem(uint itemId)
{
return _azeriteEmpoweredItems.LookupByKey(itemId);
}
public bool IsAzeriteItem(uint itemId)
{
return CliDB.AzeriteItemStorage.Any(pair => pair.Value.ItemID == itemId);
@@ -766,6 +795,33 @@ namespace Game.DataStorage
return _azeriteItemMilestonePowerByEssenceSlot[slot];
}
public List<AzeritePowerSetMemberRecord> GetAzeritePowers(uint itemId)
{
AzeriteEmpoweredItemRecord azeriteEmpoweredItem = GetAzeriteEmpoweredItem(itemId);
if (azeriteEmpoweredItem != null)
return _azeritePowers.LookupByKey(azeriteEmpoweredItem.AzeritePowerSetID);
return null;
}
public uint GetRequiredAzeriteLevelForAzeritePowerTier(uint azeriteUnlockSetId, ItemContext context, uint tier)
{
//ASSERT(tier < MAX_AZERITE_EMPOWERED_TIER);
var levels = _azeriteTierUnlockLevels.LookupByKey((azeriteUnlockSetId, context));
if (levels != null)
return levels[tier];
AzeriteTierUnlockSetRecord azeriteTierUnlockSet = CliDB.AzeriteTierUnlockSetStorage.LookupByKey(azeriteUnlockSetId);
if (azeriteTierUnlockSet != null && azeriteTierUnlockSet.Flags.HasAnyFlag(AzeriteTierUnlockSetFlags.Default))
{
levels = _azeriteTierUnlockLevels.LookupByKey((azeriteUnlockSetId, ItemContext.None));
if (levels != null)
return levels[tier];
}
return (uint)CliDB.AzeriteLevelInfoStorage.Count;
}
public string GetBroadcastTextValue(BroadcastTextRecord broadcastText, LocaleConstant locale = LocaleConstant.enUS, Gender gender = Gender.Male, bool forceGender = false)
{
if ((gender == Gender.Female || gender == Gender.None) && (forceGender || broadcastText.Text1.HasString(SharedConst.DefaultLocale)))
@@ -1208,12 +1264,65 @@ namespace Game.DataStorage
bonusListIDs.Add(itemSelectorQuality.QualityItemBonusListID);
}
}
AzeriteUnlockMappingRecord azeriteUnlockMapping = _azeriteUnlockMappings.LookupByKey((proto.Id, itemContext));
if (azeriteUnlockMapping != null)
{
switch (proto.inventoryType)
{
case InventoryType.Head:
bonusListIDs.Add(azeriteUnlockMapping.ItemBonusListHead);
break;
case InventoryType.Shoulders:
bonusListIDs.Add(azeriteUnlockMapping.ItemBonusListShoulders);
break;
case InventoryType.Chest:
case InventoryType.Robe:
bonusListIDs.Add(azeriteUnlockMapping.ItemBonusListChest);
break;
}
}
}
});
return bonusListIDs;
}
void LoadAzeriteEmpoweredItemUnlockMappings(MultiMap<uint, AzeriteUnlockMappingRecord> azeriteUnlockMappingsBySet, uint itemId)
{
ItemSparseRecord proto = CliDB.ItemSparseStorage.LookupByKey(itemId);
if (proto == null)
return;
VisitItemBonusTree(itemId, bonusTreeNode =>
{
if (bonusTreeNode.ChildItemBonusListID == 0 && bonusTreeNode.ChildItemLevelSelectorID != 0)
{
ItemLevelSelectorRecord selector = CliDB.ItemLevelSelectorStorage.LookupByKey(bonusTreeNode.ChildItemLevelSelectorID);
if (selector == null)
return;
var azeriteUnlockMappings = azeriteUnlockMappingsBySet.LookupByKey(selector.AzeriteUnlockMappingSet);
if (azeriteUnlockMappings != null)
{
AzeriteUnlockMappingRecord selectedAzeriteUnlockMapping = null;
foreach (AzeriteUnlockMappingRecord azeriteUnlockMapping in azeriteUnlockMappings)
{
if (azeriteUnlockMapping.ItemLevel > selector.MinItemLevel ||
(selectedAzeriteUnlockMapping != null && selectedAzeriteUnlockMapping.ItemLevel > azeriteUnlockMapping.ItemLevel))
continue;
selectedAzeriteUnlockMapping = azeriteUnlockMapping;
}
if (selectedAzeriteUnlockMapping != null)
_azeriteUnlockMappings[(proto.Id, (ItemContext)bonusTreeNode.ItemContext)] = selectedAzeriteUnlockMapping;
}
}
});
}
public ItemChildEquipmentRecord GetItemChildEquipment(uint itemId)
{
return _itemChildEquipment.LookupByKey(itemId);
@@ -1988,9 +2097,13 @@ namespace Game.DataStorage
MultiMap<uint, ArtifactPowerRecord> _artifactPowers = new MultiMap<uint, ArtifactPowerRecord>();
MultiMap<uint, uint> _artifactPowerLinks = new MultiMap<uint, uint>();
Dictionary<Tuple<uint, byte>, ArtifactPowerRankRecord> _artifactPowerRanks = new Dictionary<Tuple<uint, byte>, ArtifactPowerRankRecord>();
Dictionary<Tuple<uint, uint>, AzeriteEssencePowerRecord> _azeriteEssencePowersByIdAndRank = new Dictionary<Tuple<uint, uint>, AzeriteEssencePowerRecord>();
Dictionary<uint, AzeriteEmpoweredItemRecord> _azeriteEmpoweredItems = new Dictionary<uint, AzeriteEmpoweredItemRecord>();
Dictionary<(uint azeriteEssenceId, uint rank), AzeriteEssencePowerRecord> _azeriteEssencePowersByIdAndRank = new Dictionary<(uint azeriteEssenceId, uint rank), AzeriteEssencePowerRecord>();
List<AzeriteItemMilestonePowerRecord> _azeriteItemMilestonePowers = new List<AzeriteItemMilestonePowerRecord>();
AzeriteItemMilestonePowerRecord[] _azeriteItemMilestonePowerByEssenceSlot = new AzeriteItemMilestonePowerRecord[SharedConst.MaxAzeriteEssenceSlot];
MultiMap<uint, AzeritePowerSetMemberRecord> _azeritePowers = new MultiMap<uint, AzeritePowerSetMemberRecord>();
Dictionary<(uint azeriteUnlockSetId, ItemContext itemContext), byte[]> _azeriteTierUnlockLevels = new Dictionary<(uint azeriteUnlockSetId, ItemContext itemContext), byte[]>();
Dictionary<(uint itemId, ItemContext itemContext), AzeriteUnlockMappingRecord> _azeriteUnlockMappings = new Dictionary<(uint itemId, ItemContext itemContext), AzeriteUnlockMappingRecord>();
List<Tuple<byte, byte, uint>> _characterFacialHairStyles = new List<Tuple<byte, byte, uint>>();
MultiMap<Tuple<byte, byte, CharBaseSectionVariation>, CharSectionsRecord> _charSections = new MultiMap<Tuple<byte, byte, CharBaseSectionVariation>, CharSectionsRecord>();
Dictionary<uint, CharStartOutfitRecord> _charStartOutfits = new Dictionary<uint, CharStartOutfitRecord>();