fix: stealing no longer takes items out of a locked container (#2681)

`TryStealItem` doesn't check for a locked container, so an item that can still be targeted inside one (the gump stays open when it gets locked, or the client targets by serial) is stolen without picking the lock. 

It now refuses with 501747 ("It appears to be locked."); GMs are exempt, and stealing the locked container itself is unchanged. It checks the lock directly rather than calling `CheckLift`, which would also refuse items in deco containers.
This commit is contained in:
Sergi Rosell 2026-09-28 19:32:01 +02:00 • committed by GitHub
parent 225c634bf7
commit e440c6fafa
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -45,6 +45,9 @@ public static class Stealing
public static bool IsEmptyHanded(Mobile from) =>
from.FindItemOnLayer(Layer.OneHanded) == null && from.FindItemOnLayer(Layer.TwoHanded) == null;
private static bool IsInLockedContainer(Item item) =>
item.Parent is Item parent && (parent is LockableContainer { Locked: true } || IsInLockedContainer(parent));
public static TimeSpan OnUse(Mobile m)
{
if (!IsEmptyHanded(m))
@ -249,6 +252,10 @@ public static class Stealing
{
_thief.SendLocalizedMessage(502710); // You can't steal that!
}
else if (_thief.AccessLevel < AccessLevel.GameMaster && IsInLockedContainer(toSteal))
{
_thief.SendLocalizedMessage(501747); // It appears to be locked.
}
else
{
var w = toSteal.Weight + toSteal.TotalWeight;