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
+37 -6
View File
@@ -38,10 +38,10 @@ namespace Game.Entities
{
public partial class Player
{
void _LoadInventory(SQLResult result, SQLResult artifactsResult, SQLResult azeriteResult, SQLResult azeriteItemMilestonePowersResult, SQLResult azeriteItemUnlockedEssencesResult, uint timeDiff)
void _LoadInventory(SQLResult result, SQLResult artifactsResult, SQLResult azeriteResult, SQLResult azeriteItemMilestonePowersResult, SQLResult azeriteItemUnlockedEssencesResult, SQLResult azeriteEmpoweredItemResult, uint timeDiff)
{
Dictionary<ulong, ItemAdditionalLoadInfo> additionalData = new Dictionary<ulong, ItemAdditionalLoadInfo>();
ItemAdditionalLoadInfo.Init(additionalData, artifactsResult, azeriteResult, azeriteItemMilestonePowersResult, azeriteItemUnlockedEssencesResult);
ItemAdditionalLoadInfo.Init(additionalData, artifactsResult, azeriteResult, azeriteItemMilestonePowersResult, azeriteItemUnlockedEssencesResult, azeriteEmpoweredItemResult);
if (!result.IsEmpty())
{
@@ -70,6 +70,13 @@ namespace Game.Entities
if (azeriteItem != null)
azeriteItem.LoadAzeriteItemData(this, addionalData.AzeriteItem);
}
if (addionalData.AzeriteEmpoweredItem != null)
{
AzeriteEmpoweredItem azeriteEmpoweredItem = item.ToAzeriteEmpoweredItem();
if (azeriteEmpoweredItem != null)
azeriteEmpoweredItem.LoadAzeriteEmpoweredItemData(this, addionalData.AzeriteEmpoweredItem);
}
}
@@ -328,6 +335,7 @@ namespace Game.Entities
Item.DeleteFromInventoryDB(trans, itemGuid);
Item.DeleteFromDB(trans, itemGuid);
AzeriteItem.DeleteFromDB(trans, itemGuid);
AzeriteEmpoweredItem.DeleteFromDB(trans, itemGuid);
}
return item;
}
@@ -1201,8 +1209,12 @@ namespace Game.Entities
stmt.AddValue(0, GetGUID().GetCounter());
SQLResult azeriteItemUnlockedEssencesResult = DB.Characters.Query(stmt);
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_MAILITEMS_AZERITE_EMPOWERED);
stmt.AddValue(0, GetGUID().GetCounter());
SQLResult azeriteEmpoweredItemResult = DB.Characters.Query(stmt);
Dictionary<ulong, ItemAdditionalLoadInfo> additionalData = new Dictionary<ulong, ItemAdditionalLoadInfo>();
ItemAdditionalLoadInfo.Init(additionalData, artifactResult, azeriteResult, azeriteItemMilestonePowersResult, azeriteItemUnlockedEssencesResult);
ItemAdditionalLoadInfo.Init(additionalData, artifactResult, azeriteResult, azeriteItemMilestonePowersResult, azeriteItemUnlockedEssencesResult, azeriteEmpoweredItemResult);
do
{
@@ -1233,6 +1245,7 @@ namespace Game.Entities
Item.DeleteFromDB(trans, itemGuid);
AzeriteItem.DeleteFromDB(trans, itemGuid);
AzeriteEmpoweredItem.DeleteFromDB(trans, itemGuid);
DB.Characters.CommitTransaction(trans);
return null;
@@ -1266,6 +1279,13 @@ namespace Game.Entities
if (azeriteItem != null)
azeriteItem.LoadAzeriteItemData(player, addionalData.AzeriteItem);
}
if (addionalData.AzeriteEmpoweredItem != null)
{
AzeriteEmpoweredItem azeriteEmpoweredItem = item.ToAzeriteEmpoweredItem();
if (azeriteEmpoweredItem != null)
azeriteEmpoweredItem.LoadAzeriteEmpoweredItemData(player, addionalData.AzeriteEmpoweredItem);
}
}
if (mail != null)
@@ -2083,6 +2103,7 @@ namespace Game.Entities
{
Item.DeleteFromDB(trans, mailItemInfo.item_guid);
AzeriteItem.DeleteFromDB(trans, mailItemInfo.item_guid);
AzeriteEmpoweredItem.DeleteFromDB(trans, mailItemInfo.item_guid);
}
}
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_MAIL_BY_ID);
@@ -2862,6 +2883,7 @@ namespace Game.Entities
_LoadSkills(holder.GetResult(PlayerLoginQueryLoad.Skills));
UpdateSkillsForLevel();
SetNumRespecs(result.Read<byte>(76));
SetPrimarySpecialization(result.Read<uint>(36));
SetActiveTalentGroup(result.Read<byte>(64));
ChrSpecializationRecord primarySpec = CliDB.ChrSpecializationStorage.LookupByKey(GetPrimarySpecialization());
@@ -2913,8 +2935,8 @@ namespace Game.Entities
// must be before inventory (some items required reputation check)
reputationMgr.LoadFromDB(holder.GetResult(PlayerLoginQueryLoad.Reputation));
_LoadInventory(holder.GetResult(PlayerLoginQueryLoad.Inventory), holder.GetResult(PlayerLoginQueryLoad.Artifacts), holder.GetResult(PlayerLoginQueryLoad.LoadAzerite),
holder.GetResult(PlayerLoginQueryLoad.LoadAzeriteMilestonePowers), holder.GetResult(PlayerLoginQueryLoad.LoadAzeriteUnlockedEssences), time_diff);
_LoadInventory(holder.GetResult(PlayerLoginQueryLoad.Inventory), holder.GetResult(PlayerLoginQueryLoad.Artifacts), holder.GetResult(PlayerLoginQueryLoad.Azerite),
holder.GetResult(PlayerLoginQueryLoad.AzeriteMilestonePowers), holder.GetResult(PlayerLoginQueryLoad.AzeriteUnlockedEssences), holder.GetResult(PlayerLoginQueryLoad.AzeriteEmpowered), time_diff);
if (IsVoidStorageUnlocked())
_LoadVoidStorage(holder.GetResult(PlayerLoginQueryLoad.VoidStorage));
@@ -3173,6 +3195,7 @@ namespace Game.Entities
//save, but in tavern/city
stmt.AddValue(index++, GetTalentResetCost());
stmt.AddValue(index++, GetTalentResetTime());
stmt.AddValue(index++, GetNumRespecs());
stmt.AddValue(index++, GetPrimarySpecialization());
stmt.AddValue(index++, (ushort)m_ExtraFlags);
stmt.AddValue(index++, m_stableSlots);
@@ -3665,8 +3688,12 @@ namespace Game.Entities
stmt.AddValue(0, guid);
SQLResult azeriteItemUnlockedEssencesResult = DB.Characters.Query(stmt);
stmt = DB.Characters.GetPreparedStatement(CharStatements.SEL_MAILITEMS_AZERITE_EMPOWERED);
stmt.AddValue(0, guid);
SQLResult azeriteEmpoweredItemResult = DB.Characters.Query(stmt);
Dictionary<ulong, ItemAdditionalLoadInfo> additionalData = new Dictionary<ulong, ItemAdditionalLoadInfo>();
ItemAdditionalLoadInfo.Init(additionalData, artifactResult, azeriteResult, azeriteItemMilestonePowersResult, azeriteItemUnlockedEssencesResult);
ItemAdditionalLoadInfo.Init(additionalData, artifactResult, azeriteResult, azeriteItemMilestonePowersResult, azeriteItemUnlockedEssencesResult, azeriteEmpoweredItemResult);
do
{
@@ -3884,6 +3911,10 @@ namespace Game.Entities
stmt.AddValue(0, guid);
trans.Append(stmt);
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_ITEM_INSTANCE_AZERITE_EMPOWERED_BY_OWNER);
stmt.AddValue(0, guid);
trans.Append(stmt);
stmt = DB.Characters.GetPreparedStatement(CharStatements.DEL_ITEM_INSTANCE_BY_OWNER);
stmt.AddValue(0, guid);
trans.Append(stmt);
@@ -1655,6 +1655,8 @@ namespace Game.Entities
}
}
pItem.AddItemFlag2(ItemFieldFlags2.Equipped);
if (IsInWorld && update)
{
pItem.AddToWorld();
@@ -1824,6 +1826,8 @@ namespace Game.Entities
byte slot = (byte)(pos & 255);
VisualizeItem(slot, pItem);
pItem.AddItemFlag2(ItemFieldFlags2.Equipped);
if (IsInWorld)
{
pItem.AddToWorld();
@@ -1933,6 +1937,7 @@ namespace Game.Entities
Item.RemoveItemsSetItem(this, pProto);
_ApplyItemMods(pItem, slot, false, update);
pItem.RemoveItemFlag2(ItemFieldFlags2.Equipped);
// remove item dependent auras and casts (only weapon and armor slots)
if (slot < EquipmentSlot.End)
@@ -4475,6 +4480,20 @@ namespace Game.Entities
}
}
void ApplyAllAzeriteEmpoweredItemMods(bool apply)
{
for (byte i = 0; i < InventorySlots.BagEnd; ++i)
{
if (m_items[i])
{
if (!m_items[i].IsAzeriteEmpoweredItem() || m_items[i].IsBroken() || !CanUseAttackType(Player.GetAttackBySlot(i, m_items[i].GetTemplate().GetInventoryType())))
continue;
ApplyAzeritePowers(m_items[i], apply);
}
}
}
public ObjectGuid GetLootWorldObjectGUID(ObjectGuid lootObjectGuid)
{
var guid = m_AELootView.LookupByKey(lootObjectGuid);
@@ -5520,6 +5539,22 @@ namespace Game.Entities
(AzeriteItemMilestoneType)Global.DB2Mgr.GetAzeriteItemMilestonePower(slot).Type == AzeriteItemMilestoneType.MajorEssence, apply);
}
}
else
{
AzeriteEmpoweredItem azeriteEmpoweredItem = item.ToAzeriteEmpoweredItem();
if (azeriteEmpoweredItem)
{
if (!apply || GetItemByEntry(PlayerConst.ItemIdHeartOfAzeroth, ItemSearchLocation.InEquipment))
{
for (int i = 0; i < SharedConst.MaxAzeriteEmpoweredTier; ++i)
{
AzeritePowerRecord azeritePower = CliDB.AzeritePowerStorage.LookupByKey(azeriteEmpoweredItem.GetSelectedAzeritePower(i));
if (azeritePower != null)
ApplyAzeritePower(azeriteEmpoweredItem, azeritePower, apply);
}
}
}
}
}
public void ApplyAzeriteItemMilestonePower(AzeriteItem item, AzeriteItemMilestonePowerRecord azeriteItemMilestonePower, bool apply)
@@ -5591,6 +5626,17 @@ namespace Game.Entities
}
}
public void ApplyAzeritePower(AzeriteEmpoweredItem item, AzeritePowerRecord azeritePower, bool apply)
{
if (apply)
{
if (azeritePower.SpecSetID == 0 || Global.DB2Mgr.IsSpecSetMember(azeritePower.SpecSetID, GetPrimarySpecialization()))
CastSpell(this, azeritePower.SpellID, true, item);
}
else
RemoveAurasDueToItemSpell(azeritePower.SpellID, item.GetGUID());
}
public bool HasItemOrGemWithIdEquipped(uint item, uint count, byte except_slot = ItemConst.NullSlot)
{
uint tempcount = 0;
@@ -429,12 +429,18 @@ namespace Game.Entities
if (azeriteItem != null)
{
if (azeriteItem.IsEquipped())
{
ApplyAllAzeriteEmpoweredItemMods(false);
ApplyAzeritePowers(azeriteItem, false);
}
azeriteItem.SetSelectedAzeriteEssences(spec.Id);
if (azeriteItem.IsEquipped())
{
ApplyAzeritePowers(azeriteItem, true);
ApplyAllAzeriteEmpoweredItemMods(true);
}
azeriteItem.SetState(ItemUpdateState.Changed, this);
}
+4 -1
View File
@@ -1912,7 +1912,7 @@ namespace Game.Entities
if (transport)
{
transferPending.Ship.HasValue = true;
transferPending.Ship.Value.ID = transport.GetEntry();
transferPending.Ship.Value.Id = transport.GetEntry();
transferPending.Ship.Value.OriginMapID = (int)GetMapId();
}
@@ -7443,6 +7443,9 @@ namespace Game.Entities
public void RemovePlayerLocalFlag(PlayerLocalFlags flags) { RemoveUpdateFieldFlagValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.LocalFlags), (int)flags); }
public void SetPlayerLocalFlags(PlayerLocalFlags flags) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.LocalFlags), (int)flags); }
public byte GetNumRespecs() { return m_activePlayerData.NumRespecs; }
public void SetNumRespecs(byte numRespecs) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.NumRespecs), numRespecs); }
public void SetWatchedFactionIndex(uint index) { SetUpdateFieldValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.WatchedFactionIndex), index); }
public void AddAuraVision(PlayerFieldByte2Flags flags) { SetUpdateFieldFlagValue(m_values.ModifyValue(m_activePlayerData).ModifyValue(m_activePlayerData.AuraVision), (byte)flags); }