This reverts commit 179cb50557.
This commit is contained in:
parent
179cb50557
commit
c2ecc76457
588 changed files with 16260 additions and 10926 deletions
|
|
@ -100,7 +100,7 @@ namespace Server.Items
|
|||
public Corpse(Mobile owner, HairInfo hair, FacialHairInfo facialhair, List<Item> equipItems)
|
||||
: base(0x2006)
|
||||
{
|
||||
// To suppress console warnings, stackable must be true
|
||||
// To supress console warnings, stackable must be true
|
||||
Stackable = true;
|
||||
Amount = owner.Body; // protocol defines that for itemid 0x2006, amount=body
|
||||
Stackable = false;
|
||||
|
|
@ -193,7 +193,16 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
[CommandProperty(AccessLevel.GameMaster)]
|
||||
public virtual bool InstancedCorpse => Core.SE && DateTime.UtcNow < TimeOfDeath + InstancedCorpseTime;
|
||||
public virtual bool InstancedCorpse
|
||||
{
|
||||
get
|
||||
{
|
||||
if (!Core.SE)
|
||||
return false;
|
||||
|
||||
return DateTime.UtcNow < TimeOfDeath + InstancedCorpseTime;
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsDecoContainer => false;
|
||||
|
||||
|
|
@ -293,7 +302,9 @@ namespace Server.Items
|
|||
Mobile dead = Owner;
|
||||
|
||||
if (GetFlag(CorpseFlag.Carved) || dead == null)
|
||||
{
|
||||
from.SendLocalizedMessage(500485); // You see nothing useful to carve from the corpse.
|
||||
}
|
||||
else if (((Body)Amount).IsHuman && ItemID == 0x2006)
|
||||
{
|
||||
new Blood(0x122D).MoveToWorld(Location, Map);
|
||||
|
|
@ -317,9 +328,13 @@ namespace Server.Items
|
|||
from.CriminalAction(true);
|
||||
}
|
||||
else if (dead is BaseCreature creature)
|
||||
{
|
||||
creature.OnCarve(from, this, item);
|
||||
}
|
||||
else
|
||||
{
|
||||
from.SendLocalizedMessage(500485); // You see nothing useful to carve from the corpse.
|
||||
}
|
||||
}
|
||||
|
||||
public override bool IsChildVisibleTo(Mobile m, Item child) =>
|
||||
|
|
@ -332,7 +347,8 @@ namespace Server.Items
|
|||
if (Aggressors.Count == 0 || Items.Count == 0)
|
||||
return;
|
||||
|
||||
m_InstancedItems ??= new Dictionary<Item, InstancedItemInfo>();
|
||||
if (m_InstancedItems == null)
|
||||
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
|
||||
|
||||
List<Item> m_Stackables = new List<Item>();
|
||||
List<Item> m_Unstackables = new List<Item>();
|
||||
|
|
@ -385,7 +401,7 @@ namespace Server.Items
|
|||
}
|
||||
|
||||
if (remainder == 0)
|
||||
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[^1]));
|
||||
m_InstancedItems.Add(item, new InstancedItemInfo(item, attackers[attackers.Count - 1]));
|
||||
else
|
||||
m_Unstackables.Add(item);
|
||||
}
|
||||
|
|
@ -411,7 +427,9 @@ namespace Server.Items
|
|||
|
||||
if (InstancedCorpse)
|
||||
{
|
||||
m_InstancedItems ??= new Dictionary<Item, InstancedItemInfo>();
|
||||
if (m_InstancedItems == null)
|
||||
m_InstancedItems = new Dictionary<Item, InstancedItemInfo>();
|
||||
|
||||
m_InstancedItems.Add(carved, new InstancedItemInfo(carved, carver));
|
||||
}
|
||||
}
|
||||
|
|
@ -446,6 +464,7 @@ namespace Server.Items
|
|||
public override void OnAfterDelete()
|
||||
{
|
||||
m_DecayTimer?.Stop();
|
||||
|
||||
m_DecayTimer = null;
|
||||
}
|
||||
|
||||
|
|
@ -524,23 +543,29 @@ namespace Server.Items
|
|||
|
||||
writer.WriteDeltaTime(TimeOfDeath);
|
||||
|
||||
if (m_RestoreTable == null)
|
||||
writer.Write(0);
|
||||
else
|
||||
List<KeyValuePair<Item, Point3D>> list = m_RestoreTable == null
|
||||
? null
|
||||
: new List<KeyValuePair<Item, Point3D>>(m_RestoreTable);
|
||||
int count = list?.Count ?? 0;
|
||||
|
||||
writer.Write(count);
|
||||
|
||||
for (int i = 0; i < count; ++i)
|
||||
{
|
||||
writer.Write(m_RestoreTable.Count);
|
||||
KeyValuePair<Item, Point3D> kvp = list[i];
|
||||
Item item = kvp.Key;
|
||||
Point3D loc = kvp.Value;
|
||||
|
||||
foreach (var (item, loc) in m_RestoreTable)
|
||||
writer.Write(item);
|
||||
|
||||
if (item.Location == loc)
|
||||
{
|
||||
writer.Write(item);
|
||||
|
||||
if (item.Location == loc)
|
||||
writer.Write(false);
|
||||
else
|
||||
{
|
||||
writer.Write(true);
|
||||
writer.Write(loc);
|
||||
}
|
||||
writer.Write(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(true);
|
||||
writer.Write(loc);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -732,8 +757,12 @@ namespace Server.Items
|
|||
if (!(((Body)Amount).IsHuman && ItemID == 0x2006))
|
||||
return;
|
||||
|
||||
CorpsePackets.SendCorpseContent(state, state.Mobile, this);
|
||||
CorpsePackets.SendCorpseEquip(state, state.Mobile, this);
|
||||
if (state.ContainerGridLines)
|
||||
state.Send(new CorpseContent6017(state.Mobile, this));
|
||||
else
|
||||
state.Send(new CorpseContent(state.Mobile, this));
|
||||
|
||||
state.Send(new CorpseEquip(state.Mobile, this));
|
||||
}
|
||||
|
||||
public bool IsCriminalAction(Mobile from)
|
||||
|
|
@ -807,7 +836,8 @@ namespace Server.Items
|
|||
if (item == null)
|
||||
return;
|
||||
|
||||
m_RestoreTable ??= new Dictionary<Item, Point3D>();
|
||||
if (m_RestoreTable == null)
|
||||
m_RestoreTable = new Dictionary<Item, Point3D>();
|
||||
|
||||
m_RestoreTable[item] = loc;
|
||||
}
|
||||
|
|
@ -1035,7 +1065,7 @@ namespace Server.Items
|
|||
ObjectPropertyList opl = PropertyList;
|
||||
|
||||
if (opl.Header > 0)
|
||||
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, opl.Header, Name, opl.HeaderArgs);
|
||||
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, hue, 3, opl.Header, Name, opl.HeaderArgs));
|
||||
}
|
||||
|
||||
public override void OnSingleClick(Mobile from)
|
||||
|
|
@ -1045,12 +1075,14 @@ namespace Server.Items
|
|||
if (ItemID == 0x2006) // Corpse form
|
||||
{
|
||||
if (m_CorpseName != null)
|
||||
Packets.SendAsciiMessage(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, "", m_CorpseName);
|
||||
from.Send(new AsciiMessage(Serial, ItemID, MessageType.Label, hue, 3, "", m_CorpseName));
|
||||
else
|
||||
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name);
|
||||
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name));
|
||||
}
|
||||
else // Bone form
|
||||
Packets.SendMessageLocalized(from.NetState, Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name);
|
||||
{
|
||||
from.Send(new MessageLocalized(Serial, ItemID, MessageType.Label, hue, 3, 1046414, "", Name));
|
||||
}
|
||||
}
|
||||
|
||||
private class InstancedItemInfo
|
||||
|
|
|
|||
|
|
@ -1,29 +1,24 @@
|
|||
using System.Collections.Generic;
|
||||
using Server.Buffers;
|
||||
using System.IO;
|
||||
using Server.Items;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
public static class CorpsePackets
|
||||
public sealed class CorpseEquip : Packet
|
||||
{
|
||||
public static void SendCorpseEquip(NetState ns, Mobile beholder, Corpse beheld)
|
||||
public CorpseEquip(Mobile beholder, Corpse beheld) : base(0x89)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
List<Item> list = beheld.EquipItems;
|
||||
|
||||
int length = 8 + list.Count * 5;
|
||||
if (beheld.Hair?.ItemID > 0)
|
||||
length += 5;
|
||||
if (beheld.FacialHair?.ItemID > 0)
|
||||
length += 5;
|
||||
int count = list.Count;
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
|
||||
writer.Write((byte)0x89); // Packet ID
|
||||
writer.Write((ushort)length); // Dynamic Length
|
||||
EnsureCapacity(8 + count * 5);
|
||||
|
||||
writer.Write(beheld.Serial);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
|
||||
for (int i = 0; i < list.Count; ++i)
|
||||
{
|
||||
|
|
@ -31,180 +26,173 @@ namespace Server.Network
|
|||
|
||||
if (!item.Deleted && beholder.CanSee(item) && item.Parent == beheld)
|
||||
{
|
||||
writer.Write((byte)(item.Layer + 1));
|
||||
writer.Write(item.Serial);
|
||||
m_Stream.Write((byte)(item.Layer + 1));
|
||||
m_Stream.Write(item.Serial);
|
||||
}
|
||||
}
|
||||
|
||||
if (beheld.Hair?.ItemID > 0)
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
{
|
||||
writer.Write((byte)(Layer.Hair + 1));
|
||||
writer.Write(HairInfo.FakeSerial(beheld.Owner.Serial) - 2);
|
||||
m_Stream.Write((byte)(Layer.Hair + 1));
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
}
|
||||
|
||||
if (beheld.FacialHair?.ItemID > 0)
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
{
|
||||
writer.Write((byte)(Layer.FacialHair + 1));
|
||||
writer.Write(FacialHairInfo.FakeSerial(beheld.Owner.Serial) - 2);
|
||||
m_Stream.Write((byte)(Layer.FacialHair + 1));
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
}
|
||||
|
||||
writer.Position++; // writer.Write((byte)Layer.Invalid);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
public static void SendCorpseContent(NetState ns, Mobile beholder, Corpse corpse)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
if (ns.ContainerGridLines)
|
||||
SendCorpseContentNew(ns, beholder, corpse);
|
||||
else
|
||||
SendCorpseContentOld(ns, beholder, corpse);
|
||||
}
|
||||
|
||||
public static void SendCorpseContentOld(NetState ns, Mobile beholder, Corpse corpse)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
List<Item> items = corpse.EquipItems;
|
||||
int length = 5 + items.Count * 19;
|
||||
|
||||
if (corpse.Hair?.ItemID > 0)
|
||||
length += 19;
|
||||
if (corpse.FacialHair?.ItemID > 0)
|
||||
length += 19;
|
||||
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
|
||||
writer.Write((byte)0x3C); // Packet ID
|
||||
writer.Write((ushort)length); // Dynamic Length
|
||||
writer.Position += 2;
|
||||
|
||||
ushort written = 0;
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item child = items[i];
|
||||
|
||||
if (!child.Deleted && child.Parent == corpse && beholder.CanSee(child))
|
||||
{
|
||||
writer.Write(child.Serial);
|
||||
writer.Write((ushort)child.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)child.Amount);
|
||||
writer.Write((short)child.X);
|
||||
writer.Write((short)child.Y);
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)child.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
}
|
||||
|
||||
if (corpse.Hair?.ItemID > 0)
|
||||
{
|
||||
writer.Write(HairInfo.FakeSerial(corpse.Owner.Serial) - 2);
|
||||
writer.Write((ushort)corpse.Hair.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)1);
|
||||
writer.Position += 4;
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)corpse.Hair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
if (corpse.FacialHair?.ItemID > 0)
|
||||
{
|
||||
writer.Write(FacialHairInfo.FakeSerial(corpse.Owner.Serial) - 2);
|
||||
writer.Write((ushort)corpse.FacialHair.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)1);
|
||||
writer.Position += 4;
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)corpse.FacialHair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
writer.Position = 3;
|
||||
writer.Write(written);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
}
|
||||
|
||||
public static void SendCorpseContentNew(NetState ns, Mobile beholder, Corpse corpse)
|
||||
{
|
||||
if (ns == null)
|
||||
return;
|
||||
|
||||
List<Item> items = corpse.EquipItems;
|
||||
int length = 5 + items.Count * 20;
|
||||
|
||||
if (corpse.Hair?.ItemID > 0)
|
||||
length += 20;
|
||||
if (corpse.FacialHair?.ItemID > 0)
|
||||
length += 20;
|
||||
|
||||
SpanWriter writer = new SpanWriter(stackalloc byte[length]);
|
||||
writer.Write((byte)0x3C); // Packet ID
|
||||
writer.Write((ushort)length); // Dynamic Length
|
||||
writer.Position += 2;
|
||||
|
||||
ushort written = 0;
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item child = items[i];
|
||||
|
||||
if (!child.Deleted && child.Parent == corpse && beholder.CanSee(child))
|
||||
{
|
||||
writer.Write(child.Serial);
|
||||
writer.Write((ushort)child.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)child.Amount);
|
||||
writer.Write((short)child.X);
|
||||
writer.Write((short)child.Y);
|
||||
writer.Position++; // grid location
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)child.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
}
|
||||
|
||||
if (corpse.Hair?.ItemID > 0)
|
||||
{
|
||||
writer.Write(HairInfo.FakeSerial(corpse.Owner.Serial) - 2);
|
||||
writer.Write((ushort)corpse.Hair.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)1);
|
||||
writer.Position += 5;
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)corpse.Hair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
if (corpse.FacialHair?.ItemID > 0)
|
||||
{
|
||||
writer.Write(FacialHairInfo.FakeSerial(corpse.Owner.Serial) - 2);
|
||||
writer.Write((ushort)corpse.FacialHair.ItemID);
|
||||
writer.Position++; // signed, itemID offset
|
||||
writer.Write((ushort)1);
|
||||
writer.Position += 5;
|
||||
writer.Write(corpse.Serial);
|
||||
writer.Write((ushort)corpse.FacialHair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
writer.Position = 3;
|
||||
writer.Write(written);
|
||||
|
||||
ns.Send(writer.Span);
|
||||
m_Stream.Write((byte)Layer.Invalid);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CorpseContent : Packet
|
||||
{
|
||||
public CorpseContent(Mobile beholder, Corpse beheld)
|
||||
: base(0x3C)
|
||||
{
|
||||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
|
||||
EnsureCapacity(5 + count * 19);
|
||||
|
||||
long pos = m_Stream.Position;
|
||||
|
||||
int written = 0;
|
||||
|
||||
m_Stream.Write((ushort)0);
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item child = items[i];
|
||||
|
||||
if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
|
||||
{
|
||||
m_Stream.Write(child.Serial);
|
||||
m_Stream.Write((ushort)child.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)child.Amount);
|
||||
m_Stream.Write((short)child.X);
|
||||
m_Stream.Write((short)child.Y);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)child.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
}
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.Hair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.Hair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
m_Stream.Seek(pos, SeekOrigin.Begin);
|
||||
m_Stream.Write((ushort)written);
|
||||
}
|
||||
}
|
||||
|
||||
public sealed class CorpseContent6017 : Packet
|
||||
{
|
||||
public CorpseContent6017(Mobile beholder, Corpse beheld)
|
||||
: base(0x3C)
|
||||
{
|
||||
List<Item> items = beheld.EquipItems;
|
||||
int count = items.Count;
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
count++;
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
count++;
|
||||
|
||||
EnsureCapacity(5 + count * 20);
|
||||
|
||||
long pos = m_Stream.Position;
|
||||
|
||||
int written = 0;
|
||||
|
||||
m_Stream.Write((ushort)0);
|
||||
|
||||
for (int i = 0; i < items.Count; ++i)
|
||||
{
|
||||
Item child = items[i];
|
||||
|
||||
if (!child.Deleted && child.Parent == beheld && beholder.CanSee(child))
|
||||
{
|
||||
m_Stream.Write(child.Serial);
|
||||
m_Stream.Write((ushort)child.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)child.Amount);
|
||||
m_Stream.Write((short)child.X);
|
||||
m_Stream.Write((short)child.Y);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)child.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
}
|
||||
|
||||
if (beheld.Hair != null && beheld.Hair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(HairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.Hair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.Hair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
if (beheld.FacialHair != null && beheld.FacialHair.ItemID > 0)
|
||||
{
|
||||
m_Stream.Write(FacialHairInfo.FakeSerial(beheld.Owner) - 2);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.ItemID);
|
||||
m_Stream.Write((byte)0); // signed, itemID offset
|
||||
m_Stream.Write((ushort)1);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((short)0);
|
||||
m_Stream.Write((byte)0); // Grid Location?
|
||||
m_Stream.Write(beheld.Serial);
|
||||
m_Stream.Write((ushort)beheld.FacialHair.Hue);
|
||||
|
||||
++written;
|
||||
}
|
||||
|
||||
m_Stream.Seek(pos, SeekOrigin.Begin);
|
||||
m_Stream.Write((ushort)written);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue