Пример #1
0
        public override void DisplayTo(VisibleObject obj)
        {
            if (obj is Player)
            {
                var player = (obj as Player);
                var client = player.Client;

                var p = new ServerPacket(0x07);
                p.WriteUInt16(1);
                p.WriteUInt16((ushort)Point.X);
                p.WriteUInt16((ushort)Point.Y);
                p.WriteUInt32((uint)ID);
                if (Value < 10)
                {
                    p.WriteUInt16((ushort)(139 + 0x8000));
                }
                else if (Value < 100)
                {
                    p.WriteUInt16((ushort)(142 + 0x8000));
                }
                else if (Value < 1000)
                {
                    p.WriteUInt16((ushort)(138 + 0x8000));
                }
                else if (Value < 10000)
                {
                    p.WriteUInt16((ushort)(141 + 0x8000));
                }
                else if (Value < 100000)
                {
                    p.WriteUInt16((ushort)(137 + 0x8000));
                }
                else if (Value < 1000000)
                {
                    p.WriteUInt16((ushort)(140 + 0x8000));
                }
                else
                {
                    p.WriteUInt16((ushort)(136 + 0x8000));
                }
                p.WriteByte(0); // random 1
                p.WriteByte(0); // random 2
                p.WriteByte(0); // random 3

                client.Enqueue(p);
            }
        }
Пример #2
0
        private void MsgHandler_RequestNotification(Client client, ClientPacket msg)
        {
            var p1 = new ServerPacket(0x60);

            p1.WriteByte(0x01);
            p1.WriteUInt16((ushort)Notification.RawData.Length);
            p1.Write(Notification.RawData);
            client.Enqueue(p1);
        }
Пример #3
0
        public void SendWorldMap()
        {
            Player.WorldMap.IsOpen = true;
            var packet = new ServerPacket(0x2E);

            packet.WriteString8(Player.WorldMap.FileName);
            packet.WriteByte((byte)Player.WorldMap.Nodes.Count);
            packet.WriteByte(0x09);
            for (int i = 0; i < Player.WorldMap.Nodes.Count; i++)
            {
                var node = Player.WorldMap.Nodes[i];
                packet.WriteUInt16((ushort)node.X);
                packet.WriteUInt16((ushort)node.Y);
                packet.WriteString8(node.MapName);
                packet.WriteInt32(i);
                packet.WriteUInt16((ushort)node.MapX);
                packet.WriteUInt16((ushort)node.MapY);
            }
            Enqueue(packet);
        }
Пример #4
0
        public void SendPlayerID(uint id)
        {
            var p = new ServerPacket(0x05);

            p.WriteUInt32(id);
            p.WriteByte(1);
            p.WriteByte(213);
            p.WriteByte((byte)Player.Class);
            p.WriteUInt16(0);
            Enqueue(p);
        }
Пример #5
0
        public override void DisplayTo(VisibleObject obj)
        {
            if (obj is Player)
            {
                var player = (obj as Player);
                var client = player.Client;

                if (player.Quests.ContainsKey(QuestName))
                {
                    bool returnQuest = true;

                    var quest = player.Quests[QuestName];
                    if (QuestStep == quest.CurrentStep)
                    {
                        var subQuest = quest.QuestStep;
                        if (subQuest.Progress == QuestProgress.InProgress)
                        {
                            returnQuest = false;
                        }
                    }

                    if (returnQuest)
                    {
                        return;
                    }
                }

                var p = new ServerPacket(0x07);
                p.WriteUInt16(1);
                p.WriteUInt16((ushort)Point.X);
                p.WriteUInt16((ushort)Point.Y);
                p.WriteUInt32((uint)ID);
                p.WriteUInt16((ushort)(Sprite + 0x8000));
                p.WriteByte(0); // random 1
                p.WriteByte(0); // random 2
                p.WriteByte(0); // random 3

                client.Enqueue(p);
            }
        }
Пример #6
0
        public void SendMap(Map map)
        {
            int tile = 0;

            for (int row = 0; row < map.Height; row++)
            {
                var p = new ServerPacket(0x3C);
                p.WriteUInt16((ushort)row);
                for (int column = 0; column < map.Width * 6; column += 2)
                {
                    p.WriteByte(map.RawData[tile + 1]);
                    p.WriteByte(map.RawData[tile]);
                    tile += 2;
                }
                Enqueue(p);
            }
        }
Пример #7
0
        public void SendMapInfo()
        {
            var p = new ServerPacket(0x15);

            p.WriteUInt16((ushort)Player.Map.Number);
            p.WriteByte((byte)(Player.Map.Width % 256));
            p.WriteByte((byte)(Player.Map.Height % 256));
            byte flags = 0;

            if ((Player.Map.Flags & MapFlags.Snow) == MapFlags.Snow)
            {
                flags |= 1;
            }
            if ((Player.Map.Flags & MapFlags.Rain) == MapFlags.Rain)
            {
                flags |= 2;
            }
            if ((Player.Map.Flags & MapFlags.NoMap) == MapFlags.NoMap)
            {
                flags |= 64;
            }
            if ((Player.Map.Flags & MapFlags.Winter) == MapFlags.Winter)
            {
                flags |= 128;
            }
            p.WriteByte(flags);
            p.WriteByte((byte)(Player.Map.Width / 256));
            p.WriteByte((byte)(Player.Map.Height / 256));
            p.WriteByte((byte)(Player.Map.Checksum % 256));
            p.WriteByte((byte)(Player.Map.Checksum / 256));
            p.WriteString8(Player.Map.Name);
            Enqueue(p);

            if (Player.CurrentMusic != Player.Map.Music)
            {
                Player.CurrentMusic = Player.Map.Music;
                SoundEffect(0x8000 + Player.Map.Music);
            }

            Player.WorldMap.IsOpen = false;
        }
Пример #8
0
        private void MsgHandler_ServerTable(Client client, ClientPacket msg)
        {
            bool mismatch = msg.ReadBoolean();
            int  serverId = msg.ReadByte();

            if (mismatch)
            {
                var p = new ServerPacket(0x56);
                p.WriteUInt16((ushort)Program.RawData.Length);
                p.Write(Program.RawData);
                client.Enqueue(p);
            }
            else
            {
                Redirection r = new Redirection();
                r.DestinationServer    = Program.GameServers[serverId].LoginServer;
                r.EncryptionParameters = client.EncryptionParams;
                r.Name         = String.Format(String.Empty, r.ID);
                r.SourceServer = this;
                client.Redirect(r);
            }
        }
Пример #9
0
        public void SendStatistics(StatUpdateFlags flags)
        {
            if (Player.CanWalkThroughWalls || Player.CanWalkThroughUnits)
            {
                flags |= StatUpdateFlags.GameMasterA;
            }
            else
            {
                flags |= StatUpdateFlags.Swimming;
            }

            var p = new ServerPacket(0x08);

            p.WriteByte((byte)flags);
            if ((flags & StatUpdateFlags.Primary) == StatUpdateFlags.Primary)
            {
                p.Write(new byte[] { 1, 0, 0 });
                p.WriteByte((byte)Player.Level);
                p.WriteByte(0x00);
                p.WriteByte((byte)Player.Ability);
                p.WriteUInt32(Player.MaximumHP);
                p.WriteUInt32(Player.MaximumMP);
                p.WriteUInt16(Player.Str);
                p.WriteUInt16(Player.Int);
                p.WriteUInt16(Player.Wis);
                p.WriteUInt16(Player.Con);
                p.WriteUInt16(Player.Dex);
                p.WriteByte(Player.AvailableStatPoints > 0);
                p.WriteByte((byte)Player.AvailableStatPoints);
                p.WriteUInt16((ushort)Player.MaximumWeight);
                p.WriteUInt16((ushort)Player.CurrentWeight);
                p.WriteUInt32(uint.MinValue);
            }
            if ((flags & StatUpdateFlags.Current) == StatUpdateFlags.Current)
            {
                p.WriteUInt32((uint)Player.CurrentHP);
                p.WriteUInt32((uint)Player.CurrentMP);
            }
            if ((flags & StatUpdateFlags.Experience) == StatUpdateFlags.Experience)
            {
                p.WriteUInt32((uint)Player.Experience);
                p.WriteUInt32((uint)(Player.ToNextLevel - Player.Experience));
                p.WriteUInt32((uint)(Player.ToNextLevel - Player.ToThisLevel));
                p.WriteUInt32((uint)Player.AbilityExp);
                p.WriteUInt32((uint)(Player.ToNextAbility - Player.AbilityExp));
                p.WriteUInt32((uint)(Player.ToNextAbility - Player.ToThisAbility));
                p.WriteUInt32((uint)Player.GamePoints);
                p.WriteUInt32((uint)Player.Gold);
            }
            if ((flags & StatUpdateFlags.Secondary) == StatUpdateFlags.Secondary)
            {
                p.WriteUInt32(uint.MinValue);
                p.WriteUInt16(ushort.MinValue);
                p.WriteByte((byte)Player.OffenseElement);
                p.WriteByte((byte)Player.DefenseElement);
                p.WriteByte((byte)(Player.MagicResistance / 10));
                p.WriteByte(byte.MinValue);
                p.WriteSByte(Player.ArmorClass);
                p.WriteSByte(Player.Dmg);
                p.WriteSByte(Player.Hit);
            }
            Enqueue(p);
        }
Пример #10
0
        public void SendProfile()
        {
            var p = new ServerPacket(0x39);

            p.WriteByte(Player.GameServer.NationDatabase[Player.Nation].Flag);
            p.WriteString8((Player.Guild != null) ? Player.GuildRank.ToString() : string.Empty);

            var masks = new List <byte>();

            for (int i = 0; i < Player.GameServer.TitleDatabase.Count; i++)
            {
                var title = Player.GameServer.TitleDatabase[i];

                var value = i % 8;

                if (value == 0)
                {
                    masks.Add(0);
                }

                var index = masks.Count - 1;

                if (title.Available(Player))
                {
                    switch (value)
                    {
                    case 0: masks[index] += 0x80; break;

                    case 1: masks[index] += 0x40; break;

                    case 2: masks[index] += 0x20; break;

                    case 3: masks[index] += 0x10; break;

                    case 4: masks[index] += 0x08; break;

                    case 5: masks[index] += 0x04; break;

                    case 6: masks[index] += 0x02; break;

                    case 7: masks[index] += 0x01; break;
                    }
                }
            }

            p.WriteByte((byte)masks.Count);
            foreach (var mask in masks)
            {
                p.WriteByte(mask);
            }

            p.WriteByte((byte)Player.Title);
            if (!Player.Group.HasMembers)
            {
                p.WriteString8("그룹 없음");
            }
            else
            {
                StringBuilder sb = new StringBuilder("그룹구성원\n");
                foreach (var player in Player.Group.Members)
                {
                    sb.AppendFormat("{0} {1}\n", (player == Player.Group.Leader) ? "*" : " ", player.Name);
                }
                sb.AppendFormat("총 {0}명", Player.Group.Members.Count);
                p.WriteString8(sb.ToString());
            }
            p.WriteByte(Player.GroupToggle);
            p.WriteByte(0x00); // ??
            p.WriteByte((byte)Player.Class);
            p.WriteByte(0x01); // ??
            p.WriteByte(0x00); // ??
            p.WriteString8(string.Format("{0}{1}{2}",
                                         Player.Master ? "Master " : string.Empty,
                                         (Player.Specialization != Specialization.None) ? Player.Specialization + " " : string.Empty,
                                         Player.Class));
            p.WriteString8((Player.Guild != null) ? Player.Guild.Name : string.Empty);
            p.WriteByte((byte)Player.Legend.Count);
            foreach (var kvp in Player.Legend.OrderBy(l => l.Value.DateUpdated))
            {
                p.WriteByte((byte)kvp.Value.Icon);
                p.WriteByte((byte)kvp.Value.Color);
                p.WriteString8(kvp.Value.Key);
                p.WriteString8(kvp.Value.ToString());
            }
            p.WriteByte(0x00);   // ??
            p.WriteUInt16(Player.DisplayBitmask);
            p.WriteByte(0x02);   // ??
            p.WriteUInt32(0x00); // ??
            p.WriteByte(0x00);   // ??
            Enqueue(p);
        }