From 51367df0d253e4a079e7bbc3a7a7066112ba7fdb Mon Sep 17 00:00:00 2001 From: Bohica <53943479+Bohicatv@users.noreply.github.com> Date: Wed, 5 Feb 2025 19:54:56 -0800 Subject: [PATCH] fix: Fixes AR/Durability/Tool Uses for Pre-UOR and LBR (#2113) --- Projects/UOContent/Items/Armor/BaseArmor.cs | 178 +++++++++++------- .../Musical Instruments/BaseInstrument.cs | 19 +- .../Items/Skill Items/Tools/BaseTool.cs | 14 +- .../UOContent/Items/Weapons/Axes/Pickaxe.cs | 24 +++ .../UOContent/Items/Weapons/BaseWeapon.cs | 2 +- Projects/UOContent/Misc/Loot.cs | 16 +- 6 files changed, 172 insertions(+), 81 deletions(-) diff --git a/Projects/UOContent/Items/Armor/BaseArmor.cs b/Projects/UOContent/Items/Armor/BaseArmor.cs index 560c5ea527..b1e7139a37 100644 --- a/Projects/UOContent/Items/Armor/BaseArmor.cs +++ b/Projects/UOContent/Items/Armor/BaseArmor.cs @@ -313,26 +313,35 @@ public virtual double ArmorRating if (_protectionLevel != ArmorProtectionLevel.Regular) { - ar += 10 + 5 * (int)_protectionLevel; + if (Core.UOR) + { + ar += 10; + } + + ar += 5 * (int)_protectionLevel; } - ar += _resource switch + // Colored armor does not give a bonus until UOR+ + if (Core.UOR) { - CraftResource.DullCopper => 2, - CraftResource.ShadowIron => 4, - CraftResource.Copper => 6, - CraftResource.Bronze => 8, - CraftResource.Gold => 10, - CraftResource.Agapite => 12, - CraftResource.Verite => 14, - CraftResource.Valorite => 16, - CraftResource.SpinedLeather => 10, - CraftResource.HornedLeather => 13, - CraftResource.BarbedLeather => 16, - _ => 0 - }; + ar += _resource switch + { + CraftResource.DullCopper => 2, + CraftResource.ShadowIron => 4, + CraftResource.Copper => 6, + CraftResource.Bronze => 8, + CraftResource.Gold => 10, + CraftResource.Agapite => 12, + CraftResource.Verite => 14, + CraftResource.Valorite => 16, + CraftResource.SpinedLeather => 10, + CraftResource.HornedLeather => 13, + CraftResource.BarbedLeather => 16, + _ => 0 + }; + } - ar += -8 + 8 * (int)_quality; + ar += 8 * (int)(_quality - 1); return ScaleArmorByDurability(ar); } } @@ -546,7 +555,7 @@ public override int Hue } } - public int OnCraft( + public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) @@ -578,8 +587,9 @@ public int OnCraft( { DistributeBonuses( tool is BaseRunicTool ? 6 : + // Not sure since when, but right now 15 points are added, not 14. Core.SE ? 15 : 14 - ); // Not sure since when, but right now 15 points are added, not 14. + ); } if (Core.ML && this is not BaseShield) @@ -591,20 +601,30 @@ public int OnCraft( switch (Utility.Random(5)) { case 0: - PhysicalBonus++; - break; + { + PhysicalBonus++; + break; + } case 1: - FireBonus++; - break; + { + FireBonus++; + break; + } case 2: - ColdBonus++; - break; + { + ColdBonus++; + break; + } case 3: - EnergyBonus++; - break; + { + EnergyBonus++; + break; + } case 4: - PoisonBonus++; - break; + { + PoisonBonus++; + break; + } } } @@ -832,20 +852,30 @@ public void DistributeBonuses(int amount) switch (Utility.Random(5)) { case 0: - ++PhysicalBonus; - break; + { + ++PhysicalBonus; + break; + } case 1: - ++FireBonus; - break; + { + ++FireBonus; + break; + } case 2: - ++ColdBonus; - break; + { + ++ColdBonus; + break; + } case 3: - ++PoisonBonus; - break; + { + ++PoisonBonus; + break; + } case 4: - ++EnergyBonus; - break; + { + ++EnergyBonus; + break; + } } } @@ -857,49 +887,61 @@ public CraftAttributeInfo GetResourceAttrs() => public int GetProtOffset() { - return _protectionLevel switch + if (Core.T2A) { - ArmorProtectionLevel.Guarding => 1, - ArmorProtectionLevel.Hardening => 2, - ArmorProtectionLevel.Fortification => 3, - ArmorProtectionLevel.Invulnerability => 4, - _ => 0 - }; + return _protectionLevel switch + { + ArmorProtectionLevel.Defense => 5, + ArmorProtectionLevel.Guarding => 10, + ArmorProtectionLevel.Hardening => 15, + ArmorProtectionLevel.Fortification => 20, + ArmorProtectionLevel.Invulnerability => 25, + _ => 0 // regular + }; + } + else + { + return _protectionLevel switch + { + ArmorProtectionLevel.Defense => 2, + ArmorProtectionLevel.Guarding => 4, + ArmorProtectionLevel.Hardening => 6, + ArmorProtectionLevel.Fortification => 8, + ArmorProtectionLevel.Invulnerability => 10, + _ => 0 // regular + }; + } } public int GetDurabilityBonus() { - var bonus = _quality == ArmorQuality.Exceptional ? 20 : 0; - - bonus += _durability switch - { - ArmorDurabilityLevel.Durable => 20, - ArmorDurabilityLevel.Substantial => 50, - ArmorDurabilityLevel.Massive => 70, - ArmorDurabilityLevel.Fortified => 100, - ArmorDurabilityLevel.Indestructible => 120, - _ => 0 - }; - - if (Core.AOS) + if (Core.UOR) { - bonus += ArmorAttributes.DurabilityBonus; - - var resInfo = CraftResources.GetInfo(_resource); - CraftAttributeInfo attrInfo = null; + var bonus = _durability switch + { + ArmorDurabilityLevel.Durable => 20, + ArmorDurabilityLevel.Substantial => 50, + ArmorDurabilityLevel.Massive => 70, + ArmorDurabilityLevel.Fortified => 100, + ArmorDurabilityLevel.Indestructible => 120, + _ => 0 + }; - if (resInfo != null) + if (Core.AOS) { - attrInfo = resInfo.AttributeInfo; + var resInfo = CraftResources.GetInfo(_resource); + bonus += ArmorAttributes.DurabilityBonus + (resInfo?.AttributeInfo?.ArmorDurability ?? 0); } - if (attrInfo != null) + if (_quality == ArmorQuality.Exceptional) { - bonus += attrInfo.ArmorDurability; + return bonus + 20; } + + return bonus; } - return bonus; + return (int)_durability * 5 + ((int)_quality - 1) * 10; } public static void ValidateMobile(Mobile m) @@ -1596,7 +1638,7 @@ private string DurabilityText(out bool articleAn) ArmorDurabilityLevel.Substantial => "substantial", ArmorDurabilityLevel.Massive => "massive", ArmorDurabilityLevel.Fortified => "fortified", - ArmorDurabilityLevel.Indestructible => "indestructable", + ArmorDurabilityLevel.Indestructible => "indestructible", _ => null }; } diff --git a/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs b/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs index 5024891a87..b014162112 100644 --- a/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs +++ b/Projects/UOContent/Items/Skill Items/Musical Instruments/BaseInstrument.cs @@ -52,8 +52,8 @@ public BaseInstrument(int itemID, int wellSound, int badlySound) : base(itemID) _usesRemaining = Utility.RandomMinMax(InitMinUses, InitMaxUses); } - public virtual int InitMinUses => 350; - public virtual int InitMaxUses => 450; + public virtual int InitMinUses => Core.UOR ? 350 : 100; + public virtual int InitMaxUses => Core.UOR ? 450 : 150; public virtual TimeSpan ChargeReplenishRate => TimeSpan.FromMinutes(5.0); @@ -116,7 +116,7 @@ public int UsesRemaining } } - public int OnCraft( + public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) @@ -128,6 +128,19 @@ public int OnCraft( Crafter = from?.RawName; } + // Publish 16 change + if (Core.LBR) + { + if (Quality == InstrumentQuality.Exceptional) + { + UsesRemaining += 100; + } + } + else if (Quality != InstrumentQuality.Regular) + { + UsesRemaining += (int)(UsesRemaining * ((int)Quality - 1) * 0.1); + } + return quality; } diff --git a/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs b/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs index 4697c53790..74af05e694 100644 --- a/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs +++ b/Projects/UOContent/Items/Skill Items/Tools/BaseTool.cs @@ -56,7 +56,7 @@ public ToolQuality Quality private bool ShowUsesRemaining { get; set; } = true; - public int OnCraft( + public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) @@ -68,6 +68,18 @@ public int OnCraft( Crafter = from?.RawName; } + if (Core.UOR) + { + if (Quality == ToolQuality.Exceptional) + { + UsesRemaining = 100; + } + } + else if (Quality != ToolQuality.Regular) + { + UsesRemaining += (int)(UsesRemaining * ((int)Quality - 1) * 0.2); + } + return quality; } diff --git a/Projects/UOContent/Items/Weapons/Axes/Pickaxe.cs b/Projects/UOContent/Items/Weapons/Axes/Pickaxe.cs index 07cac1b083..4747123089 100644 --- a/Projects/UOContent/Items/Weapons/Axes/Pickaxe.cs +++ b/Projects/UOContent/Items/Weapons/Axes/Pickaxe.cs @@ -1,4 +1,6 @@ +using System; using ModernUO.Serialization; +using Server.Engines.Craft; using Server.Engines.Harvest; namespace Server.Items @@ -35,5 +37,27 @@ public Pickaxe() : base(0xE86) public override int InitMaxHits => 60; public override WeaponAnimation DefAnimation => WeaponAnimation.Slash1H; + + public override int OnCraft( + int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, + CraftItem craftItem, int resHue + ) + { + var result = base.OnCraft(quality, makersMark, from, craftSystem, typeRes, tool, craftItem, resHue); + + if (Core.UOR) + { + if (Quality == WeaponQuality.Exceptional) + { + UsesRemaining += 50; + } + } + else if (Quality != WeaponQuality.Regular) + { + UsesRemaining += (int)(UsesRemaining * ((int)Quality - 1) * 0.2); + } + + return result; + } } } diff --git a/Projects/UOContent/Items/Weapons/BaseWeapon.cs b/Projects/UOContent/Items/Weapons/BaseWeapon.cs index 66b54cb308..7a1a3c0734 100644 --- a/Projects/UOContent/Items/Weapons/BaseWeapon.cs +++ b/Projects/UOContent/Items/Weapons/BaseWeapon.cs @@ -662,7 +662,7 @@ public CraftResource Resource [SerializableFieldDefault(23)] private CraftResource ResourceDefaultValue() => CraftResource.Iron; - public int OnCraft( + public virtual int OnCraft( int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, CraftItem craftItem, int resHue ) diff --git a/Projects/UOContent/Misc/Loot.cs b/Projects/UOContent/Misc/Loot.cs index 4c597586cc..82a73054b8 100644 --- a/Projects/UOContent/Misc/Loot.cs +++ b/Projects/UOContent/Misc/Loot.cs @@ -547,33 +547,33 @@ public static BaseArmor RandomArmorOrShield(bool inTokuno = false, bool isMondai return Construct(_oldArmorOrShieldTypes); } - private static readonly Type[][] _mlArmorOrHatOrShieldOrJeweleyTypes = + private static readonly Type[][] _mlArmorOrHatOrShieldOrJewelryTypes = [MLArmorTypes, ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes]; - private static readonly Type[][] _seArmorOrHatOrShieldOrJeweleyTypes = + private static readonly Type[][] _seArmorOrHatOrShieldOrJewelryTypes = [SEArmorTypes, ArmorTypes, SEHatTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes]; - private static readonly Type[][] _aosArmorOrHatOrShieldOrJeweleyTypes = + private static readonly Type[][] _aosArmorOrHatOrShieldOrJewelryTypes = [ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes]; - private static readonly Type[][] _oldArmorOrHatOrShieldOrJeweleyTypes = + private static readonly Type[][] _oldArmorOrHatOrShieldOrJewelryTypes = [ArmorTypes, HatTypes, ShieldTypes, JewelryTypes]; public static Item RandomArmorOrShieldOrJewelry(bool inTokuno = false, bool isMondain = false) { if (Core.ML && isMondain) { - return Construct(_mlArmorOrHatOrShieldOrJeweleyTypes); + return Construct(_mlArmorOrHatOrShieldOrJewelryTypes); } if (Core.SE && inTokuno) { - return Construct(_seArmorOrHatOrShieldOrJeweleyTypes); + return Construct(_seArmorOrHatOrShieldOrJewelryTypes); } if (Core.AOS) { - return Construct(_aosArmorOrHatOrShieldOrJeweleyTypes); + return Construct(_aosArmorOrHatOrShieldOrJewelryTypes); } - return Construct(_oldArmorOrHatOrShieldOrJeweleyTypes); + return Construct(_oldArmorOrHatOrShieldOrJewelryTypes); } private static readonly Type[][] _mlWeaponOrRangedOrArmorOrHatOrShieldTypes =