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.
This commit is contained in:
Kamron Batman 2026-10-17 16:17:11 -07:00 • committed by GitHub
parent 257b4c8c1b
commit 410a964789
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 29 additions and 34 deletions

View file

@ -5724,6 +5724,20 @@ namespace Server.Mobiles
}
}
/// <summary>
/// Equips <paramref name="item" /> in place of whatever an inherited outfit put on its layer.
/// AddItem would stack both on one layer, and EquipItem would refuse and orphan the item.
/// </summary>
public void ReplaceEquipment(Item item)
{
FindItemOnLayer(item.Layer)?.Delete();
if (!EquipItem(item))
{
item.Delete();
}
}
public virtual void HealStart(Mobile patient)
{
StopHeal();

View file

@ -47,7 +47,8 @@ namespace Server.Mobiles
pack.DropItem(new Bolt(Utility.RandomMinMax(10, 20)));
pack.DropItem(new Bolt(Utility.RandomMinMax(10, 20)));
AddItem(
// The crossbow is wielded; the sword would share its hands, so it is carried as loot.
pack.DropItem(
Utility.Random(6) switch
{
0 => new Longsword(),

View file

@ -42,8 +42,8 @@ namespace Server.Mobiles
Fame = 18000;
Karma = -18000;
AddItem(new Shoes(0x537));
AddItem(new Robe(0x452));
ReplaceEquipment(new Shoes(0x537));
ReplaceEquipment(new Robe(0x452));
for (var i = 0; i < 2; ++i)
{

View file

@ -176,11 +176,8 @@ namespace Server.Mobiles
{
_disguiseTimerToken.Cancel();
if (!IsBodyMod)
{
return;
}
// BodyMod is not saved, so after a restart a disguised kitsune comes back without it but still
// wearing the disguise; strip it regardless.
Name = null;
Title = null;
BodyMod = 0;

View file

@ -33,15 +33,6 @@ public partial class Merchant : BaseEscortable
public override void InitOutfit()
{
if (Female)
{
AddItem(new PlainDress());
}
else
{
AddItem(new Shirt(GetRandomHue()));
}
var lowHue = GetRandomHue();
AddItem(new ThighBoots());

View file

@ -58,14 +58,6 @@ namespace Server.Mobiles
AddItem(new FullApron(Utility.RandomBrightHue()));
}
AddItem(
Utility.Random(3) switch
{
0 => new Bandana(Utility.RandomBrightHue()),
_ => new JesterHat(Utility.RandomBrightHue()) // 1-2
}
);
AddItem(new Bascinet());
AddItem(new SmithHammer());

View file

@ -26,10 +26,10 @@ namespace Server.Mobiles
{
base.InitOutfit();
AddItem(new FancyShirt(0x3E4));
AddItem(new LongPants(0x192));
ReplaceEquipment(new FancyShirt(0x3E4));
ReplaceEquipment(new LongPants(0x192));
AddItem(new Pickaxe());
AddItem(new ThighBoots(0x283));
ReplaceEquipment(new ThighBoots(0x283));
}
}
}

View file

@ -31,10 +31,10 @@ namespace Server.Mobiles
{
base.InitOutfit();
AddItem(new Shirt(Utility.RandomNeutralHue()));
AddItem(new LongPants(Utility.RandomNeutralHue()));
ReplaceEquipment(new Shirt(Utility.RandomNeutralHue()));
ReplaceEquipment(new LongPants(Utility.RandomNeutralHue()));
AddItem(new Bow());
AddItem(new ThighBoots(Utility.RandomNeutralHue()));
ReplaceEquipment(new ThighBoots(Utility.RandomNeutralHue()));
}
}
}

View file

@ -31,10 +31,10 @@ namespace Server.Mobiles
{
base.InitOutfit();
AddItem(new Shirt(Utility.RandomNeutralHue()));
AddItem(new LongPants(Utility.RandomNeutralHue()));
ReplaceEquipment(new Shirt(Utility.RandomNeutralHue()));
ReplaceEquipment(new LongPants(Utility.RandomNeutralHue()));
AddItem(new Dagger());
AddItem(new ThighBoots(Utility.RandomNeutralHue()));
ReplaceEquipment(new ThighBoots(Utility.RandomNeutralHue()));
}
}
}