fix: Fixes AR/Durability/Tool Uses for Pre-UOR and LBR (#2113)

This commit is contained in:
Bohica 2025-02-05 19:54:56 -08:00 • committed by GitHub
parent d407847fc4
commit 51367df0d2
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
6 changed files with 173 additions and 82 deletions

View file

@ -313,26 +313,35 @@ namespace Server.Items
if (_protectionLevel != ArmorProtectionLevel.Regular) 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, ar += _resource switch
CraftResource.ShadowIron => 4, {
CraftResource.Copper => 6, CraftResource.DullCopper => 2,
CraftResource.Bronze => 8, CraftResource.ShadowIron => 4,
CraftResource.Gold => 10, CraftResource.Copper => 6,
CraftResource.Agapite => 12, CraftResource.Bronze => 8,
CraftResource.Verite => 14, CraftResource.Gold => 10,
CraftResource.Valorite => 16, CraftResource.Agapite => 12,
CraftResource.SpinedLeather => 10, CraftResource.Verite => 14,
CraftResource.HornedLeather => 13, CraftResource.Valorite => 16,
CraftResource.BarbedLeather => 16, CraftResource.SpinedLeather => 10,
_ => 0 CraftResource.HornedLeather => 13,
}; CraftResource.BarbedLeather => 16,
_ => 0
};
}
ar += -8 + 8 * (int)_quality; ar += 8 * (int)(_quality - 1);
return ScaleArmorByDurability(ar); return ScaleArmorByDurability(ar);
} }
} }
@ -546,7 +555,7 @@ namespace Server.Items
} }
} }
public int OnCraft( public virtual int OnCraft(
int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
CraftItem craftItem, int resHue CraftItem craftItem, int resHue
) )
@ -578,8 +587,9 @@ namespace Server.Items
{ {
DistributeBonuses( DistributeBonuses(
tool is BaseRunicTool ? 6 : tool is BaseRunicTool ? 6 :
// Not sure since when, but right now 15 points are added, not 14.
Core.SE ? 15 : 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) if (Core.ML && this is not BaseShield)
@ -591,20 +601,30 @@ namespace Server.Items
switch (Utility.Random(5)) switch (Utility.Random(5))
{ {
case 0: case 0:
PhysicalBonus++; {
break; PhysicalBonus++;
break;
}
case 1: case 1:
FireBonus++; {
break; FireBonus++;
break;
}
case 2: case 2:
ColdBonus++; {
break; ColdBonus++;
break;
}
case 3: case 3:
EnergyBonus++; {
break; EnergyBonus++;
break;
}
case 4: case 4:
PoisonBonus++; {
break; PoisonBonus++;
break;
}
} }
} }
@ -832,20 +852,30 @@ namespace Server.Items
switch (Utility.Random(5)) switch (Utility.Random(5))
{ {
case 0: case 0:
++PhysicalBonus; {
break; ++PhysicalBonus;
break;
}
case 1: case 1:
++FireBonus; {
break; ++FireBonus;
break;
}
case 2: case 2:
++ColdBonus; {
break; ++ColdBonus;
break;
}
case 3: case 3:
++PoisonBonus; {
break; ++PoisonBonus;
break;
}
case 4: case 4:
++EnergyBonus; {
break; ++EnergyBonus;
break;
}
} }
} }
@ -857,49 +887,61 @@ namespace Server.Items
public int GetProtOffset() public int GetProtOffset()
{ {
return _protectionLevel switch if (Core.T2A)
{ {
ArmorProtectionLevel.Guarding => 1, return _protectionLevel switch
ArmorProtectionLevel.Hardening => 2, {
ArmorProtectionLevel.Fortification => 3, ArmorProtectionLevel.Defense => 5,
ArmorProtectionLevel.Invulnerability => 4, ArmorProtectionLevel.Guarding => 10,
_ => 0 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() public int GetDurabilityBonus()
{ {
var bonus = _quality == ArmorQuality.Exceptional ? 20 : 0; if (Core.UOR)
bonus += _durability switch
{ {
ArmorDurabilityLevel.Durable => 20, var bonus = _durability switch
ArmorDurabilityLevel.Substantial => 50,
ArmorDurabilityLevel.Massive => 70,
ArmorDurabilityLevel.Fortified => 100,
ArmorDurabilityLevel.Indestructible => 120,
_ => 0
};
if (Core.AOS)
{
bonus += ArmorAttributes.DurabilityBonus;
var resInfo = CraftResources.GetInfo(_resource);
CraftAttributeInfo attrInfo = null;
if (resInfo != null)
{ {
attrInfo = resInfo.AttributeInfo; ArmorDurabilityLevel.Durable => 20,
ArmorDurabilityLevel.Substantial => 50,
ArmorDurabilityLevel.Massive => 70,
ArmorDurabilityLevel.Fortified => 100,
ArmorDurabilityLevel.Indestructible => 120,
_ => 0
};
if (Core.AOS)
{
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) public static void ValidateMobile(Mobile m)
@ -1596,7 +1638,7 @@ namespace Server.Items
ArmorDurabilityLevel.Substantial => "substantial", ArmorDurabilityLevel.Substantial => "substantial",
ArmorDurabilityLevel.Massive => "massive", ArmorDurabilityLevel.Massive => "massive",
ArmorDurabilityLevel.Fortified => "fortified", ArmorDurabilityLevel.Fortified => "fortified",
ArmorDurabilityLevel.Indestructible => "indestructable", ArmorDurabilityLevel.Indestructible => "indestructible",
_ => null _ => null
}; };
} }

View file

@ -52,8 +52,8 @@ public abstract partial class BaseInstrument : Item, ICraftable, ISlayer
_usesRemaining = Utility.RandomMinMax(InitMinUses, InitMaxUses); _usesRemaining = Utility.RandomMinMax(InitMinUses, InitMaxUses);
} }
public virtual int InitMinUses => 350; public virtual int InitMinUses => Core.UOR ? 350 : 100;
public virtual int InitMaxUses => 450; public virtual int InitMaxUses => Core.UOR ? 450 : 150;
public virtual TimeSpan ChargeReplenishRate => TimeSpan.FromMinutes(5.0); public virtual TimeSpan ChargeReplenishRate => TimeSpan.FromMinutes(5.0);
@ -116,7 +116,7 @@ public abstract partial class BaseInstrument : Item, ICraftable, ISlayer
} }
} }
public int OnCraft( public virtual int OnCraft(
int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
CraftItem craftItem, int resHue CraftItem craftItem, int resHue
) )
@ -128,6 +128,19 @@ public abstract partial class BaseInstrument : Item, ICraftable, ISlayer
Crafter = from?.RawName; 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; return quality;
} }

View file

@ -56,7 +56,7 @@ public abstract partial class BaseTool : Item, IUsesRemaining, ICraftable
private bool ShowUsesRemaining { get; set; } = true; 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, int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
CraftItem craftItem, int resHue CraftItem craftItem, int resHue
) )
@ -68,6 +68,18 @@ public abstract partial class BaseTool : Item, IUsesRemaining, ICraftable
Crafter = from?.RawName; 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; return quality;
} }

View file

@ -1,4 +1,6 @@
using System;
using ModernUO.Serialization; using ModernUO.Serialization;
using Server.Engines.Craft;
using Server.Engines.Harvest; using Server.Engines.Harvest;
namespace Server.Items namespace Server.Items
@ -35,5 +37,27 @@ namespace Server.Items
public override int InitMaxHits => 60; public override int InitMaxHits => 60;
public override WeaponAnimation DefAnimation => WeaponAnimation.Slash1H; 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;
}
} }
} }

View file

@ -662,7 +662,7 @@ public abstract partial class BaseWeapon
[SerializableFieldDefault(23)] [SerializableFieldDefault(23)]
private CraftResource ResourceDefaultValue() => CraftResource.Iron; private CraftResource ResourceDefaultValue() => CraftResource.Iron;
public int OnCraft( public virtual int OnCraft(
int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool, int quality, bool makersMark, Mobile from, CraftSystem craftSystem, Type typeRes, BaseTool tool,
CraftItem craftItem, int resHue CraftItem craftItem, int resHue
) )

View file

@ -547,33 +547,33 @@ namespace Server
return Construct<BaseArmor>(_oldArmorOrShieldTypes); return Construct<BaseArmor>(_oldArmorOrShieldTypes);
} }
private static readonly Type[][] _mlArmorOrHatOrShieldOrJeweleyTypes = private static readonly Type[][] _mlArmorOrHatOrShieldOrJewelryTypes =
[MLArmorTypes, ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes]; [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]; [SEArmorTypes, ArmorTypes, SEHatTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes];
private static readonly Type[][] _aosArmorOrHatOrShieldOrJeweleyTypes = private static readonly Type[][] _aosArmorOrHatOrShieldOrJewelryTypes =
[ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes]; [ArmorTypes, AosHatTypes, HatTypes, AosShieldTypes, ShieldTypes, JewelryTypes];
private static readonly Type[][] _oldArmorOrHatOrShieldOrJeweleyTypes = private static readonly Type[][] _oldArmorOrHatOrShieldOrJewelryTypes =
[ArmorTypes, HatTypes, ShieldTypes, JewelryTypes]; [ArmorTypes, HatTypes, ShieldTypes, JewelryTypes];
public static Item RandomArmorOrShieldOrJewelry(bool inTokuno = false, bool isMondain = false) public static Item RandomArmorOrShieldOrJewelry(bool inTokuno = false, bool isMondain = false)
{ {
if (Core.ML && isMondain) if (Core.ML && isMondain)
{ {
return Construct(_mlArmorOrHatOrShieldOrJeweleyTypes); return Construct(_mlArmorOrHatOrShieldOrJewelryTypes);
} }
if (Core.SE && inTokuno) if (Core.SE && inTokuno)
{ {
return Construct(_seArmorOrHatOrShieldOrJeweleyTypes); return Construct(_seArmorOrHatOrShieldOrJewelryTypes);
} }
if (Core.AOS) if (Core.AOS)
{ {
return Construct(_aosArmorOrHatOrShieldOrJeweleyTypes); return Construct(_aosArmorOrHatOrShieldOrJewelryTypes);
} }
return Construct(_oldArmorOrHatOrShieldOrJeweleyTypes); return Construct(_oldArmorOrHatOrShieldOrJewelryTypes);
} }
private static readonly Type[][] _mlWeaponOrRangedOrArmorOrHatOrShieldTypes = private static readonly Type[][] _mlWeaponOrRangedOrArmorOrHatOrShieldTypes =