From 3ce916a82c8b655fc59c1e150883d1e2678856a3 Mon Sep 17 00:00:00 2001 From: hondacrx Date: Wed, 27 Nov 2019 11:22:20 -0500 Subject: [PATCH] Core/Items: Implement new item bonus types Port From (https://github.com/TrinityCore/TrinityCore/commit/3d9e21193dd9f7d5f38a7a8edb3d6f6f8daa1867) --- Source/Framework/Constants/ItemConst.cs | 4 +++- Source/Game/Entities/Item/Item.cs | 16 +++++++++++++--- Source/Game/Entities/Item/ItemTemplate.cs | 2 +- Source/Game/Groups/Group.cs | 2 ++ 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/Source/Framework/Constants/ItemConst.cs b/Source/Framework/Constants/ItemConst.cs index 55d062c39..57be0e16b 100644 --- a/Source/Framework/Constants/ItemConst.cs +++ b/Source/Framework/Constants/ItemConst.cs @@ -345,7 +345,9 @@ namespace Framework.Constants RandomEnchantment = 15, // Responsible for showing "" or "+%d Rank Random Minor Trait" in the tooltip before item is obtained Bounding = 16, RelicType = 17, - OverrideRequiredLevel = 18 + OverrideRequiredLevel = 18, + OverrideCanDisenchant = 21, + OverrideCanScrap = 22 } public enum ItemContext : byte diff --git a/Source/Game/Entities/Item/Item.cs b/Source/Game/Entities/Item/Item.cs index 8b2a91f82..5af27f6bb 100644 --- a/Source/Game/Entities/Item/Item.cs +++ b/Source/Game/Entities/Item/Item.cs @@ -1957,6 +1957,9 @@ namespace Game.Entities public ItemDisenchantLootRecord GetDisenchantLoot(Player owner) { + if (!_bonusData.CanDisenchant) + return null; + return GetDisenchantLoot(GetTemplate(), (uint)GetQuality(), GetItemLevel(owner)); } @@ -2834,9 +2837,10 @@ namespace Game.Entities RepairCostMultiplier = 1.0f; ScalingStatDistribution = proto.GetScalingStatDistribution(); RelicType = -1; - HasItemLevelBonus = false; HasFixedLevel = false; RequiredLevelOverride = 0; + CanDisenchant = !proto.GetFlags().HasAnyFlag(ItemFlags.NoDisenchant); + CanScrap = proto.GetFlags4().HasAnyFlag(ItemFlags4.Scrapable); _state.AppearanceModPriority = int.MaxValue; _state.ScalingStatDistributionPriority = int.MaxValue; @@ -2865,7 +2869,6 @@ namespace Game.Entities { case ItemBonusType.ItemLevel: ItemLevelBonus += values[0]; - HasItemLevelBonus = true; break; case ItemBonusType.Stat: { @@ -2935,6 +2938,12 @@ namespace Game.Entities case ItemBonusType.OverrideRequiredLevel: RequiredLevelOverride = values[0]; break; + case ItemBonusType.OverrideCanDisenchant: + CanDisenchant = values[0] != 0; + break; + case ItemBonusType.OverrideCanScrap: + CanScrap = values[0] != 0; + break; } } @@ -2956,7 +2965,8 @@ namespace Game.Entities public ushort[] GemRelicRankBonus = new ushort[ItemConst.MaxGemSockets]; public int RelicType; public int RequiredLevelOverride; - public bool HasItemLevelBonus; + public bool CanDisenchant; + public bool CanScrap; public bool HasFixedLevel; State _state; diff --git a/Source/Game/Entities/Item/ItemTemplate.cs b/Source/Game/Entities/Item/ItemTemplate.cs index 83046521a..7864ed7aa 100644 --- a/Source/Game/Entities/Item/ItemTemplate.cs +++ b/Source/Game/Entities/Item/ItemTemplate.cs @@ -254,7 +254,7 @@ namespace Game.Entities public ItemFlags GetFlags() { return (ItemFlags)ExtendedData.Flags[0]; } public ItemFlags2 GetFlags2() { return (ItemFlags2)ExtendedData.Flags[1]; } public ItemFlags3 GetFlags3() { return (ItemFlags3)ExtendedData.Flags[2]; } - public uint GetFlags4() { return ExtendedData.Flags[3]; } + public ItemFlags4 GetFlags4() { return (ItemFlags4)ExtendedData.Flags[3]; } public float GetPriceRandomValue() { return ExtendedData.PriceRandomValue; } public float GetPriceVariance() { return ExtendedData.PriceVariance; } public uint GetBuyCount() { return Math.Max(ExtendedData.VendorStackCount, 1u); } diff --git a/Source/Game/Groups/Group.cs b/Source/Game/Groups/Group.cs index 52c0db2b1..f0000cd28 100644 --- a/Source/Game/Groups/Group.cs +++ b/Source/Game/Groups/Group.cs @@ -2673,6 +2673,8 @@ namespace Game.Groups { ItemInstance itemInstance = new ItemInstance(lootItemInSlot); BonusData bonusData = new BonusData(itemInstance); + if (!bonusData.CanDisenchant) + return null; ItemTemplate itemTemplate = Global.ObjectMgr.GetItemTemplate(itemid); uint itemLevel = Item.GetItemLevel(itemTemplate, bonusData, player.GetLevel(), 0, 0, 0, 0, false, 0);