PSO2SERVER/Server/Protocol/Packets/08-SpawnPacket/08-0C-NPCSpawnPacket.cs

74 lines
2.3 KiB
C#
Raw Normal View History

using Org.BouncyCastle.Utilities;
using PSO2SERVER.Models;
2024-12-06 21:49:29 +08:00
using PSO2SERVER.Zone;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.Remoting.Messaging;
using System.Text;
using static PSO2SERVER.Models.PSOObject;
namespace PSO2SERVER.Protocol.Packets
{
public class NPCSpawnPacket : Packet
{
2024-12-06 21:49:29 +08:00
public ObjectHeader objHeader { get; set; } = new ObjectHeader();
public PSOLocation objPosition { get; set; } = new PSOLocation();
public ushort unk1 { get; set; } = 0;
public string objName { get; set; } = string.Empty;
public uint unk2 { get; set; } = 0;
public byte[] unk3 { get; set; } = new byte[0x0C];
public ushort unk4 { get; set; } = 0;
public ushort unk5 { get; set; } = 0;
public uint unk6 { get; set; } = 0;
public uint unk7 { get; set; } = 0;
public uint unk8 { get; set; } = 0;
public uint unk9 { get; set; } = 0;
public uint unk10 { get; set; } = 0;
public uint unk11 { get; set; } = 0;
public uint unk12 { get; set; } = 0;
public string unk13 { get; set; } = string.Empty; //Ascii
public NPCSpawnPacket(PSOObject obj)
{
2024-12-06 21:49:29 +08:00
objHeader = obj.Header;
objPosition = obj.Position;
objName = obj.Name;
unk8 = 1101004800;
unk12 = 1;
}
#region implemented abstract members of Packet
public override byte[] Build()
{
2024-12-06 21:49:29 +08:00
PacketWriter pkt = new PacketWriter();
pkt.WriteStruct(objHeader);
pkt.WritePosition(objPosition);
pkt.Write(unk1); // Padding?
pkt.WriteFixedLengthASCII(objName, 0x20);
pkt.Write(unk2); // Padding?
pkt.Write(unk3); // Unknown, usually zero
pkt.Write(unk4);
pkt.Write(unk5);
pkt.Write(unk6);
pkt.Write(unk7);
pkt.Write(unk8); // Always this 1101004800
pkt.Write(unk9);
pkt.Write(unk10);
pkt.Write(unk11);
pkt.Write(unk12);
pkt.WriteAscii(unk13, 0x9FCD, 0xE7);
2024-12-06 21:49:29 +08:00
return pkt.ToArray();
}
public override PacketHeader GetHeader()
{
2024-12-06 21:49:29 +08:00
return new PacketHeader(0x08, 0x0C, PacketFlags.PACKED);
}
#endregion
}
}