コード例 #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 WriteCharacterInfo(long characterId, Player player)
        {
            PacketWriter pWriter = PacketWriter.Of(SendOp.CHARACTER_INFO);

            pWriter.WriteLong(characterId);
            pWriter.WriteBool(player != null);
            if (player == null)
            {
                return(pWriter);
            }
            pWriter.WriteLong(); // unknown
            pWriter.WriteLong(player.CharacterId);
            pWriter.WriteLong(DateTimeOffset.UtcNow.ToUnixTimeSeconds());

            PacketWriter characterBuffer = new PacketWriter();

            characterBuffer.WriteLong(player.AccountId);
            characterBuffer.WriteLong(player.CharacterId);
            characterBuffer.WriteUnicodeString(player.Name);
            characterBuffer.WriteShort(player.Levels.Level);
            characterBuffer.WriteEnum(player.Job);
            characterBuffer.WriteEnum(player.JobCode);
            characterBuffer.WriteInt(player.Gender);
            characterBuffer.WriteInt(player.Levels.PrestigeLevel);
            characterBuffer.WriteByte();
            WriteStats(characterBuffer, player);

            // Unknown data
            characterBuffer.WriteZero(1300);

            characterBuffer.WriteUnicodeString(player.ProfileUrl);
            characterBuffer.WriteUnicodeString(player.Motto);

            if (player.Guild == null)
            {
                characterBuffer.WriteUnicodeString(string.Empty);
                characterBuffer.WriteUnicodeString(string.Empty);
            }
            else
            {
                characterBuffer.WriteUnicodeString(player.Guild.Name);
                characterBuffer.WriteUnicodeString(player.Guild.Ranks[player.GuildMember.Rank].Name);
            }

            characterBuffer.WriteUnicodeString(player.Account.Home?.Name ?? string.Empty);
            characterBuffer.WriteZero(12);
            characterBuffer.WriteInt(player.TitleId);
            characterBuffer.WriteInt(player.Titles.Count);
            foreach (int titleId in player.Titles)
            {
                characterBuffer.WriteInt(titleId);
            }
            characterBuffer.WriteInt(player.TrophyCount.Sum());
            characterBuffer.WriteInt();  // gear score
            characterBuffer.WriteLong(); // timestamp
            characterBuffer.WriteLong();
            characterBuffer.Write(player.SkinColor);
            characterBuffer.WriteZero(14);

            pWriter.WriteInt(characterBuffer.Length);
            pWriter.Write(characterBuffer.ToArray());

            PacketWriter appearanceBuffer = new PacketWriter();

            CharacterListPacket.WriteEquipsAndCosmetics(appearanceBuffer, player);

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

            pWriter.WriteInt(appearanceBuffer.Length);
            pWriter.Write(appearanceBuffer.ToArray());

            PacketWriter badgeBuffer = new PacketWriter();

            CharacterListPacket.WriteBadges(badgeBuffer, player);

            pWriter.WriteInt(badgeBuffer.Length);
            pWriter.Write(badgeBuffer.ToArray());

            return(pWriter);
        }