コード例 #1
0
        public static Packet AddPlayer(IFieldObject <Player> fieldPlayer)
        {
            Player       player  = fieldPlayer.Value;
            PacketWriter pWriter = PacketWriter.Of(SendOp.FIELD_ADD_USER);

            pWriter.WriteInt(fieldPlayer.ObjectId);
            CharacterListPacket.WriteCharacter(player, pWriter);

            // Skills
            pWriter.WriteEnum(player.JobCode);
            pWriter.WriteByte(1);
            pWriter.WriteEnum(player.Job);
            JobPacket.WriteSkills(pWriter, player);

            // Coords
            pWriter.Write(fieldPlayer.Coord);
            pWriter.Write(fieldPlayer.Rotation);
            pWriter.WriteByte();

            // Stats
            StatPacket.WriteFieldStats(pWriter, player.Stats);

            pWriter.WriteBool(player.CombatCTS != null);
            pWriter.WriteBool(player.Guide?.Value.Type == 0);
            pWriter.WriteInt();
            pWriter.WriteLong();
            pWriter.WriteLong();

            // ???
            bool flagA = false;

            pWriter.WriteBool(flagA);
            if (flagA)
            {
                pWriter.WriteLong();
                pWriter.WriteUnicodeString("");
                pWriter.WriteUnicodeString("");
                pWriter.WriteByte();
                pWriter.WriteInt();
                pWriter.WriteLong();
                pWriter.WriteLong();
                pWriter.WriteUnicodeString("");
                pWriter.WriteLong();
                pWriter.WriteUnicodeString("");
                pWriter.WriteByte();
            }

            pWriter.WriteInt(1);
            pWriter.Write(player.SkinColor);
            pWriter.WriteUnicodeString(player.ProfileUrl);

            pWriter.WriteBool(player.Mount != null);
            if (player.Mount != null)
            {
                pWriter.WriteMount(player.Mount);

                // Unknown
                byte countA = 0;
                pWriter.WriteByte(countA);
                for (int i = 0; i < countA; i++)
                {
                    pWriter.WriteInt();
                    pWriter.WriteByte();
                }
            }
            pWriter.WriteInt();
            pWriter.WriteLong(DateTimeOffset.UtcNow.ToUnixTimeSeconds()); // some timestamp
            pWriter.WriteInt();
            pWriter.WriteInt();

            bool appearance = true;

            pWriter.WriteBool(appearance);
            if (appearance)
            {
                PacketWriter appearanceBuffer = new PacketWriter();
                CharacterListPacket.WriteEquipsAndCosmetics(appearanceBuffer, player);

                appearanceBuffer.WriteByte(1);
                appearanceBuffer.WriteLong();
                appearanceBuffer.WriteLong();
                appearanceBuffer.WriteByte();

                pWriter.WriteDeflated(appearanceBuffer.Buffer, 0, appearanceBuffer.Length);
            }
            else
            {
                pWriter.WriteDeflated(new byte[1], 0, 1); // Empty buffer
            }

            bool unusuedBuffer = false;

            pWriter.WriteBool(unusuedBuffer);
            if (unusuedBuffer)
            {
                // kms2 outfits? Unused buffer for gms2
            }
            else
            {
                pWriter.WriteDeflated(new byte[1], 0, 1); // Empty buffer
            }

            List <Item> badges = player.Inventory.Badges.Where(x => x != null).ToList();

            pWriter.WriteBool(badges.Count > 0);
            if (badges.Count > 0)
            {
                PacketWriter badgesBuffer = new PacketWriter();
                CharacterListPacket.WriteBadges(badgesBuffer, player);
                pWriter.WriteDeflated(badgesBuffer.Buffer, 0, badgesBuffer.Length);
            }
            else
            {
                pWriter.WriteDeflated(new byte[1], 0, 1); // Empty buffer
            }

            JobPacket.WritePassiveSkills(pWriter, fieldPlayer);

            pWriter.WriteInt();
            pWriter.WriteInt();
            pWriter.WriteByte();
            pWriter.WriteInt();
            pWriter.WriteByte();
            pWriter.WriteByte();
            pWriter.WriteInt(player.TitleId);
            pWriter.WriteShort(player.InsigniaId);
            pWriter.WriteByte();
            pWriter.WriteInt();
            pWriter.WriteByte();
            pWriter.WriteLong(); // Another timestamp
            pWriter.WriteInt(int.MaxValue);
            pWriter.WriteByte();
            pWriter.WriteInt(); // MushkingRoyale taileffect kill count
            pWriter.WriteInt();
            pWriter.WriteShort();

            return(pWriter);
        }
コード例 #2
0
        public static Packet AddPlayer(IFieldObject <Player> fieldPlayer)
        {
            Player       player  = fieldPlayer.Value;
            PacketWriter pWriter = PacketWriter.Of(SendOp.FIELD_ADD_USER);

            pWriter.WriteInt(fieldPlayer.ObjectId);
            CharacterListPacket.WriteCharacter(player, pWriter);

            // Skills
            pWriter.WriteEnum(player.JobCode);
            pWriter.WriteByte(1);
            pWriter.WriteEnum(player.Job);
            JobPacket.WriteSkills(pWriter, player);

            // Coords
            pWriter.Write(fieldPlayer.Coord);
            pWriter.Write(player.Rotation);
            pWriter.WriteByte();

            // Stats
            StatPacket.WriteTotalStats(pWriter, ref player.Stats);

            pWriter.WriteByte();
            pWriter.WriteByte();
            pWriter.WriteInt();
            pWriter.WriteLong();
            pWriter.WriteLong();

            // ???
            bool flagA = false;

            pWriter.WriteBool(flagA);
            if (flagA)
            {
                pWriter.WriteLong();
                pWriter.WriteUnicodeString("");
                pWriter.WriteUnicodeString("");
                pWriter.WriteByte();
                pWriter.WriteInt();
                pWriter.WriteLong();
                pWriter.WriteLong();
                pWriter.WriteUnicodeString("");
                pWriter.WriteLong();
                pWriter.WriteUnicodeString("");
                pWriter.WriteByte();
            }

            pWriter.WriteInt(1);
            pWriter.Write <SkinColor>(player.SkinColor);
            pWriter.WriteUnicodeString(player.ProfileUrl); // Profile URL

            pWriter.WriteBool(player.Mount != null);
            if (player.Mount != null)
            {
                pWriter.WriteMount(player.Mount);

                // Unknown
                byte countA = 0;
                pWriter.WriteByte(countA);
                for (int i = 0; i < countA; i++)
                {
                    pWriter.WriteInt();
                    pWriter.WriteByte();
                }
            }
            pWriter.WriteInt();
            pWriter.WriteLong(DateTimeOffset.UtcNow.ToUnixTimeSeconds()); // some timestamp
            pWriter.WriteInt();
            pWriter.WriteInt();

            // This seems to be character appearance encoded as a blob
            pWriter.WriteBool(true);
            if (true)
            {
                PacketWriter appearanceBuffer = new PacketWriter();
                appearanceBuffer.WriteByte((byte)player.Equips.Count);  // num equips
                foreach ((ItemSlot slot, Item equip) in player.Equips)
                {
                    CharacterListPacket.WriteEquip(slot, equip, appearanceBuffer);
                }

                appearanceBuffer.WriteByte(1);
                appearanceBuffer.WriteLong();
                appearanceBuffer.WriteLong();
                appearanceBuffer.WriteByte();

                pWriter.WriteDeflated(appearanceBuffer.Buffer, 0, appearanceBuffer.Length);
                pWriter.WriteByte();                      // Separator?
                pWriter.WriteDeflated(new byte[1], 0, 1); // Unknown
                pWriter.WriteByte();                      // Separator?
                pWriter.WriteDeflated(new byte[1], 0, 1); // Badge appearances

                JobPacket.WritePassiveSkills(pWriter, fieldPlayer);

                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteByte();
                pWriter.WriteInt();
                pWriter.WriteByte();
                pWriter.WriteByte();
                pWriter.WriteInt(player.TitleId);
                pWriter.WriteShort(player.InsigniaId);
                pWriter.WriteByte();
                pWriter.WriteInt();
                pWriter.WriteByte();
                pWriter.WriteLong(); // Another timestamp
                pWriter.WriteInt(int.MaxValue);
                pWriter.WriteByte();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteShort();
            }
            else
            {
                //pWriter.WriteInt(); commented out to remove warning
            }

            return(pWriter);
        }