From 09d6420320d6fda6587fe9f40ce9cd9351746914 Mon Sep 17 00:00:00 2001 From: Kamron Batman <3953314+kamronbatman@users.noreply.github.com> Date: Sat, 18 Jan 2025 10:58:22 -0800 Subject: [PATCH] fix: Fixes Item ID so it doesn't gain from non-identifiable items (#2075) --- Projects/UOContent/Items/Armor/BaseArmor.cs | 3 +- .../UOContent/Items/Weapons/BaseWeapon.cs | 3 +- .../UOContent/Skills/ItemIdentification.cs | 92 +++++++++---------- 3 files changed, 50 insertions(+), 48 deletions(-) diff --git a/Projects/UOContent/Items/Armor/BaseArmor.cs b/Projects/UOContent/Items/Armor/BaseArmor.cs index 2fd01551a..560c5ea52 100644 --- a/Projects/UOContent/Items/Armor/BaseArmor.cs +++ b/Projects/UOContent/Items/Armor/BaseArmor.cs @@ -13,7 +13,8 @@ using AMT = Server.Items.ArmorMaterialType; namespace Server.Items { [SerializationGenerator(9, false)] - public abstract partial class BaseArmor : Item, IScissorable, IFactionItem, ICraftable, IWearableDurability, IAosItem + public abstract partial class BaseArmor + : Item, IScissorable, IFactionItem, ICraftable, IWearableDurability, IAosItem, IIdentifiable { [SerializedIgnoreDupe] [SerializableField(0, setter: "private")] diff --git a/Projects/UOContent/Items/Weapons/BaseWeapon.cs b/Projects/UOContent/Items/Weapons/BaseWeapon.cs index 861b9c689..66b54cb30 100644 --- a/Projects/UOContent/Items/Weapons/BaseWeapon.cs +++ b/Projects/UOContent/Items/Weapons/BaseWeapon.cs @@ -28,7 +28,8 @@ public interface ISlayer } [SerializationGenerator(10, false)] -public abstract partial class BaseWeapon : Item, IWeapon, IFactionItem, ICraftable, ISlayer, IDurability, IAosItem +public abstract partial class BaseWeapon + : Item, IWeapon, IFactionItem, ICraftable, ISlayer, IDurability, IAosItem, IIdentifiable { private static bool _enableInstaHit; diff --git a/Projects/UOContent/Skills/ItemIdentification.cs b/Projects/UOContent/Skills/ItemIdentification.cs index 0724bce80..9d09208fb 100644 --- a/Projects/UOContent/Skills/ItemIdentification.cs +++ b/Projects/UOContent/Skills/ItemIdentification.cs @@ -2,62 +2,62 @@ using System; using Server.Mobiles; using Server.Targeting; -namespace Server.Items +namespace Server.Items; + +public interface IIdentifiable { - public static class ItemIdentification + bool Identified { get; set; } +} + +public static class ItemIdentification +{ + public static void Initialize() { - public static void Initialize() + SkillInfo.Table[(int)SkillName.ItemID].Callback = OnUse; + } + + public static TimeSpan OnUse(Mobile from) + { + from.SendLocalizedMessage(500343); // What do you wish to appraise and identify? + from.Target = new InternalTarget(); + + return TimeSpan.FromSeconds(1.0); + } + + [PlayerVendorTarget] + private class InternalTarget : Target + { + public InternalTarget() : base(8, false, TargetFlags.None) => AllowNonlocal = true; + + protected override void OnTarget(Mobile from, object o) { - SkillInfo.Table[(int)SkillName.ItemID].Callback = OnUse; - } - - public static TimeSpan OnUse(Mobile from) - { - from.SendLocalizedMessage(500343); // What do you wish to appraise and identify? - from.Target = new InternalTarget(); - - return TimeSpan.FromSeconds(1.0); - } - - [PlayerVendorTarget] - private class InternalTarget : Target - { - public InternalTarget() : base(8, false, TargetFlags.None) => AllowNonlocal = true; - - protected override void OnTarget(Mobile from, object o) + if (o is Mobile mobile) { - if (o is Item item) - { - if (from.CheckTargetSkill(SkillName.ItemID, item, 0, 100)) - { - if (item is BaseWeapon weapon) - { - weapon.Identified = true; - } - else if (item is BaseArmor armor) - { - armor.Identified = true; - } + mobile.OnSingleClick(from); + return; + } - if (!Core.AOS) - { - item.OnSingleClick(from); - } - } - else - { - from.SendLocalizedMessage(500353); // You are not certain... - } - } - else if (o is Mobile mobile) + bool identified = false; + + if (o is Item item) + { + if (item is IIdentifiable identifiable && from.CheckTargetSkill(SkillName.ItemID, item, 0, 100)) { - mobile.OnSingleClick(from); + identifiable.Identified = true; + identified = true; } - else + + if (!Core.AOS) { - from.SendLocalizedMessage(500353); // You are not certain... + item.OnSingleClick(from); } } + + + if (!identified) + { + from.SendLocalizedMessage(500353); // You are not certain... + } } } }