Пример #1
0
        public static Packet AddBoss(IFieldObject <Mob> mob)
        {
            PacketWriter pWriter = PacketWriter.Of(SendOp.FIELD_ADD_NPC);

            pWriter.WriteInt(mob.ObjectId);
            pWriter.WriteInt(mob.Value.Id);
            pWriter.Write(mob.Coord);
            pWriter.Write(CoordF.From(0, 0, 0));       // Unknown
            pWriter.WriteMapleString(mob.Value.Model); // StrA - kfm model string
            // If NPC is not valid, the packet seems to stop here

            // NPC Stat
            StatPacket.DefaultStatsMob(pWriter, mob);
            // NPC Stat
            pWriter.WriteLong();
            pWriter.WriteLong();
            pWriter.WriteInt();
            pWriter.WriteByte();
            int count = 0;

            pWriter.WriteInt(count); // branch
            for (int i = 0; i < count; i++)
            {
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteShort();
                pWriter.WriteInt();
                pWriter.WriteByte();
                pWriter.WriteLong();
            }
            // Unknown
            pWriter.WriteLong();
            pWriter.WriteByte();
            pWriter.WriteInt(1);
            pWriter.WriteInt();
            pWriter.WriteByte();

            return(pWriter);
        }
Пример #2
0
        public static Packet AddMob(IFieldObject <Mob> mob)
        {
            PacketWriter pWriter = PacketWriter.Of(SendOp.FIELD_ADD_NPC);

            pWriter.WriteInt(mob.ObjectId);
            pWriter.WriteInt(mob.Value.Id);
            pWriter.Write(mob.Coord);
            pWriter.Write(mob.Rotation);
            // If NPC is not valid, the packet seems to stop here

            StatPacket.DefaultStatsMob(pWriter, mob);

            pWriter.WriteLong();
            pWriter.WriteInt();
            pWriter.WriteInt(0x0E); // NPC level
            pWriter.WriteInt();
            pWriter.WriteByte();

            return(pWriter);
        }
Пример #3
0
        public static Packet AddNpc(IFieldObject <Npc> npc)
        {
            PacketWriter pWriter = PacketWriter.Of(SendOp.FIELD_ADD_NPC)
                                   .WriteInt(npc.ObjectId)
                                   .WriteInt(npc.Value.Id)
                                   .Write(npc.Coord)
                                   .Write(CoordF.From(0, 0, 0)); // Unknown

            // If NPC is not valid, the packet seems to stop here

            // NPC Stat
            StatPacket.DefaultStatsNpc(pWriter);
            // NPC Stat

            pWriter.WriteByte();
            short count = 0;

            pWriter.WriteShort(count); // branch
            for (int i = 0; i < count; i++)
            {
                pWriter.WriteInt()
                .WriteInt()
                .WriteInt()
                .WriteInt()
                .WriteInt()
                .WriteInt()
                .WriteShort()
                .WriteInt()
                .WriteByte()
                .WriteLong();
            }

            pWriter.WriteLong() // uid
            .WriteByte()
            .WriteInt(1)
            .WriteInt()
            .WriteByte();

            return(pWriter);
        }
Пример #4
0
        public static Packet AddNpc(IFieldObject <Npc> npc)
        {
            PacketWriter pWriter = PacketWriter.Of(SendOp.FIELD_ADD_NPC);

            pWriter.WriteInt(npc.ObjectId);
            pWriter.WriteInt(npc.Value.Id);
            pWriter.Write(npc.Coord);
            pWriter.Write(npc.Rotation);
            // If NPC is not valid, the packet seems to stop here

            StatPacket.DefaultStatsNpc(pWriter);

            pWriter.WriteByte();
            short count = 0;

            pWriter.WriteShort(count); // branch
            for (int i = 0; i < count; i++)
            {
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteInt();
                pWriter.WriteShort();
                pWriter.WriteInt();
                pWriter.WriteByte();
                pWriter.WriteLong();
            }

            pWriter.WriteLong(); // uid
            pWriter.WriteByte();
            pWriter.WriteInt(1); // NPC level
            pWriter.WriteInt();
            pWriter.WriteByte();

            return(pWriter);
        }
Пример #5
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);
        }
Пример #6
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);
        }