fix: Fixes weight problem with dupe. Fixes mobile base weight. (#938)

This commit is contained in:
Kamron Batman 2022-02-18 22:11:57 -08:00 committed by GitHub
parent 699478425f
commit 6593abf418
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 27 additions and 20 deletions

View file

@ -1872,7 +1872,7 @@ namespace Server
public static bool DisableDismountInWarmode { get; set; }
public static int BodyWeight { get; set; } = 14;
public static int BodyWeight { get; set; } = 11; // 11 + 3 for the backpack
[CommandProperty(AccessLevel.GameMaster)]
public IMount Mount
@ -4107,19 +4107,25 @@ namespace Server
switch (type)
{
default:
m_TotalGold += delta;
Delta(MobileDelta.Gold);
break;
{
m_TotalGold += delta;
Delta(MobileDelta.Gold);
break;
}
case TotalType.Items:
m_TotalItems += delta;
break;
{
m_TotalItems += delta;
break;
}
case TotalType.Weight:
m_TotalWeight += delta;
Delta(MobileDelta.Weight);
OnWeightChange(m_TotalWeight - delta);
break;
{
m_TotalWeight += delta;
Delta(MobileDelta.Weight);
OnWeightChange(m_TotalWeight - delta);
break;
}
}
}

View file

@ -47,11 +47,13 @@ namespace Server.Commands
for (var i = 0; i < props.Length; i++)
{
var p = props[i];
try
{
if (props[i].CanRead && props[i].CanWrite)
// Do not set the parent since it screws up mobile/container totals and weights.
if (p.CanRead && p.CanWrite && p.Name != "Parent")
{
props[i].SetValue(dest, props[i].GetValue(src, null), null);
p.SetValue(dest, p.GetValue(src, null), null);
}
}
catch
@ -97,14 +99,12 @@ namespace Server.Commands
if (m_InBag)
{
if (copy.Parent is Container cont)
pack = copy.Parent switch
{
pack = cont;
}
else if (copy.Parent is Mobile m)
{
pack = m.Backpack;
}
Container cont => cont,
Mobile m => m.Backpack,
_ => pack
};
}
else
{
@ -130,7 +130,6 @@ namespace Server.Commands
{
CopyProperties(newItem, copy);
copy.OnAfterDuped(newItem);
newItem.Parent = null;
if (pack != null)
{
@ -141,7 +140,9 @@ namespace Server.Commands
newItem.MoveToWorld(from.Location, from.Map);
}
newItem.UpdateTotals();
newItem.InvalidateProperties();
newItem.Delta(ItemDelta.Update);
CommandLogging.WriteLine(
from,