ModernUO/Projects/UOContent/Mobiles/Vendors/NPC/IronWorker.cs
Kamron Batman 410a964789
fix: NPC outfits no longer stack two items on one layer (#2715)
Companion to #2712, which covers HireRanger's refused `EquipItem`. A sweep that built every constructible Mobile 2,000 times under each expansion found these other outfits that put two items on one layer. They don't leak, because `AddItem` skips `CheckEquip`, but the NPC wears both items and the client draws only one.

| NPC | Conflict |
|---|---|
| Miner, Ranger, Thief | Own shirt/pants/ThighBoots added on top of the random `BaseVendor.InitOutfit` (shoes doubled on every spawn) |
| MasterTheophilus | Shoes + Robe added over `EvilMageLord`'s Sandals + Robe |
| Merchant | Shirt + FancyShirt, or PlainDress + FancyDress |
| IronWorker | Bandana/JesterHat + Bascinet |
| MeerCaptain | One-handed sword + Crossbow |
| BakeKitsune | `BodyMod` isn't saved, so after a restart `RemoveDisguise` bailed and the next `Disguise()` stacked a second robe and pair of shoes |

## Changes
- `BaseCreature.ReplaceEquipment(item)` equips an item in place of whatever an inherited outfit put on its layer, and deletes the item if it still can't be equipped.
- Miner, Ranger, Thief, MasterTheophilus: their own pieces replace the inherited ones.
- Merchant and IronWorker: dropped the duplicate roll. Each kept the item the client was already drawing, which is the last one sent: the fancy set and the Bascinet.
- MeerCaptain: the sword goes into its pack as loot. **Behavior change:** `Mobile.Weapon` checks the one-handed layer first, so it was fighting with the sword despite its archer AI, its Archery skill and the bolts in its pack. It now uses the crossbow.
- BakeKitsune: `RemoveDisguise` strips the disguise without checking `IsBodyMod`.

## Testing
- I re-ran the sweep (local diagnostic, not committed; needs client tiledata) at 500 rolls × 12 expansions. Only HireRanger (#2712) and LordOaks (separate fix coming) remain.
- UOContent.Tests: 1218 passed, 2 skipped.
2026-10-17 16:17:11 -07:00

107 lines
3 KiB
C#

using ModernUO.Serialization;
using System.Collections.Generic;
using Server.Items;
namespace Server.Mobiles
{
[SerializationGenerator(0, false)]
public partial class IronWorker : BaseVendor
{
private readonly List<SBInfo> m_SBInfos = new();
[Constructible]
public IronWorker() : base("the iron worker")
{
SetSkill(SkillName.ArmsLore, 36.0, 68.0);
SetSkill(SkillName.Blacksmith, 65.0, 88.0);
SetSkill(SkillName.Fencing, 60.0, 83.0);
SetSkill(SkillName.Macing, 61.0, 93.0);
SetSkill(SkillName.Swords, 60.0, 83.0);
SetSkill(SkillName.Tactics, 60.0, 83.0);
SetSkill(SkillName.Parry, 61.0, 93.0);
}
protected override List<SBInfo> SBInfos => m_SBInfos;
public override VendorShoeType ShoeType => VendorShoeType.None;
public override void InitSBInfo()
{
m_SBInfos.Add(new SBAxeWeapon());
m_SBInfos.Add(new SBKnifeWeapon());
m_SBInfos.Add(new SBMaceWeapon());
m_SBInfos.Add(new SBSmithTools());
m_SBInfos.Add(new SBPoleArmWeapon());
m_SBInfos.Add(new SBSpearForkWeapon());
m_SBInfos.Add(new SBSwordWeapon());
m_SBInfos.Add(new SBMetalShields());
m_SBInfos.Add(new SBHelmetArmor());
m_SBInfos.Add(new SBPlateArmor());
m_SBInfos.Add(new SBChainmailArmor());
m_SBInfos.Add(new SBRingmailArmor());
m_SBInfos.Add(new SBStuddedArmor());
m_SBInfos.Add(new SBLeatherArmor());
}
public override void InitOutfit()
{
base.InitOutfit();
Item item = Utility.RandomBool() ? null : new RingmailChest();
if (item != null && !EquipItem(item))
{
item.Delete();
AddItem(new FullApron(Utility.RandomBrightHue()));
}
AddItem(new Bascinet());
AddItem(new SmithHammer());
item = FindItemOnLayer(Layer.Pants);
if (item != null)
{
item.Hue = Utility.RandomBrightHue();
}
item = FindItemOnLayer(Layer.OuterLegs);
if (item != null)
{
item.Hue = Utility.RandomBrightHue();
}
item = FindItemOnLayer(Layer.InnerLegs);
if (item != null)
{
item.Hue = Utility.RandomBrightHue();
}
item = FindItemOnLayer(Layer.OuterTorso);
if (item != null)
{
item.Hue = Utility.RandomBrightHue();
}
item = FindItemOnLayer(Layer.InnerTorso);
if (item != null)
{
item.Hue = Utility.RandomBrightHue();
}
item = FindItemOnLayer(Layer.Shirt);
if (item != null)
{
item.Hue = Utility.RandomBrightHue();
}
}
}
}