fix(core): Converts death animation (#356)
- [X] Converts death animation - [X] Fixes tests for movement packets
This commit is contained in:
parent
77ce2e1980
commit
90393fea2a
8 changed files with 65 additions and 89 deletions
|
|
@ -5072,21 +5072,13 @@ namespace Server
|
|||
|
||||
var c = CreateCorpseHandler?.Invoke(this, hair, facialhair, content, equip);
|
||||
|
||||
/*m_Corpse = c;
|
||||
|
||||
for ( int i = 0; c != null && i < content.Count; ++i )
|
||||
c.DropItem( (Item)content[i] );
|
||||
|
||||
if (c != null)
|
||||
c.MoveToWorld( this.Location, this.Map );*/
|
||||
|
||||
if (m_Map != null)
|
||||
{
|
||||
Packet animPacket = null;
|
||||
|
||||
var eable = m_Map.GetClientsInRange(m_Location);
|
||||
var corpseSerial = c?.Serial ?? Serial.Zero;
|
||||
|
||||
Span<byte> deathAnimation = stackalloc byte[OutgoingMobilePackets.DeathAnimationPacketLength];
|
||||
OutgoingMobilePackets.CreateDeathAnimation(ref deathAnimation, Serial, corpseSerial);
|
||||
Span<byte> removeEntity = stackalloc byte[OutgoingEntityPackets.RemoveEntityLength];
|
||||
OutgoingEntityPackets.CreateRemoveEntity(ref removeEntity, Serial);
|
||||
|
||||
|
|
@ -5094,9 +5086,7 @@ namespace Server
|
|||
{
|
||||
if (state != m_NetState)
|
||||
{
|
||||
animPacket ??= Packet.Acquire(new DeathAnimation(Serial, corpseSerial));
|
||||
|
||||
state.Send(animPacket);
|
||||
state.Send(deathAnimation);
|
||||
|
||||
if (!state.Mobile.CanSee(this))
|
||||
{
|
||||
|
|
@ -5105,8 +5095,6 @@ namespace Server
|
|||
}
|
||||
}
|
||||
|
||||
Packet.Release(animPacket);
|
||||
|
||||
eable.Free();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -21,6 +21,7 @@ namespace Server.Network
|
|||
public static class OutgoingMobilePackets
|
||||
{
|
||||
public const int BondedStatusPacketLength = 11;
|
||||
public const int DeathAnimationPacketLength = 13;
|
||||
|
||||
public static void CreateBondedStatus(ref Span<byte> buffer, Serial serial, bool bonded)
|
||||
{
|
||||
|
|
@ -41,14 +42,35 @@ namespace Server.Network
|
|||
}
|
||||
|
||||
var writer = new CircularBufferWriter(buffer);
|
||||
writer.Write((byte)0xBF); // Packet ID
|
||||
writer.Write((ushort)11); // Length
|
||||
writer.Write((byte)0xBF); // Packet ID
|
||||
writer.Write((ushort)11); // Length
|
||||
writer.Write((ushort)0x19); // Subpacket ID
|
||||
writer.Write((byte)0); // Command
|
||||
writer.Write((byte)0); // Command
|
||||
writer.Write(serial);
|
||||
writer.Write(bonded);
|
||||
|
||||
ns.Send(ref buffer, writer.Position);
|
||||
}
|
||||
|
||||
public static void CreateDeathAnimation(ref Span<byte> buffer, Serial killed, Serial corpse)
|
||||
{
|
||||
var writer = new SpanWriter(buffer);
|
||||
writer.Write((byte)0xAF); // Packet ID
|
||||
writer.Write(killed);
|
||||
writer.Write(corpse);
|
||||
writer.Write(0); // ??
|
||||
}
|
||||
|
||||
public static void SendDeathAnimation(this NetState ns, Serial killed, Serial corpse)
|
||||
{
|
||||
if (ns == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Span<byte> span = stackalloc byte[DeathAnimationPacketLength];
|
||||
CreateDeathAnimation(ref span, killed, corpse);
|
||||
ns.Send(span);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -14,6 +14,7 @@
|
|||
*************************************************************************/
|
||||
|
||||
using System.Buffers;
|
||||
using System.IO;
|
||||
|
||||
namespace Server.Network
|
||||
{
|
||||
|
|
@ -99,6 +100,7 @@ namespace Server.Network
|
|||
|
||||
var writer = new CircularBufferWriter(buffer);
|
||||
writer.Write((byte)0xBF); // Packet ID
|
||||
writer.Seek(2, SeekOrigin.Current);
|
||||
writer.Write((ushort)0x1); // Subpacket
|
||||
writer.Write(keys[0]);
|
||||
writer.Write(keys[1]);
|
||||
|
|
@ -107,6 +109,7 @@ namespace Server.Network
|
|||
writer.Write(keys[4]);
|
||||
writer.Write(keys[5]);
|
||||
|
||||
writer.WritePacketLength();
|
||||
ns.Send(ref buffer, writer.Position);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue