コード例 #1
0
        public PCreateCharacter(PlayerMobile character, int cityIndex, uint clientIP, int serverIndex, uint slot, byte profession) : base(0x00)
        {
            int skillcount = 3;

            if (Client.Version >= ClientVersion.CV_70160)
            {
                skillcount++;
                this[0] = 0xF8;
            }

            WriteUInt(0xEDEDEDED);
            WriteUShort(0xFFFF);
            WriteUShort(0xFFFF);
            WriteByte(0x00);
            WriteASCII(character.Name, 30);
            WriteUShort(0x00);

            WriteUInt((uint)Client.Protocol);
            WriteUInt(0x01);
            WriteUInt(0x0);
            WriteByte(profession); // Profession
            Skip(15);
            byte val;

            if (Client.Version < ClientVersion.CV_4011D)
            {
                val = Convert.ToByte(character.Flags.HasFlag(Flags.Female));
            }
            else
            {
                val = (byte)character.Race;

                if (Client.Version < ClientVersion.CV_7000)
                {
                    val--;
                }

                val = (byte)(val * 2 + Convert.ToByte(character.Flags.HasFlag(Flags.Female)));
            }

            WriteByte(val);
            WriteByte((byte)character.Strength);
            WriteByte((byte)character.Dexterity);
            WriteByte((byte)character.Intelligence);

            List <Skill> skills = character.Skills.OrderByDescending(o => o.Value)
                                  .Take(skillcount)
                                  .ToList();

            foreach (Skill skill in skills)
            {
                WriteByte((byte)skill.Index);
                WriteByte((byte)skill.ValueFixed);
            }

            WriteUShort(character.Hue);
            Item hair = character.FindItemByLayer(Layer.Hair);

            if (hair != null)
            {
                WriteUShort(hair.Graphic);
                WriteUShort(hair.Hue);
            }
            else
            {
                WriteUShort(0x00);
                WriteUShort(0x00);
            }

            Item beard = character.FindItemByLayer(Layer.Beard);

            if (beard != null)
            {
                WriteUShort(beard.Graphic);
                WriteUShort(beard.Hue);
            }
            else
            {
                WriteUShort(0x00);
                WriteUShort(0x00);
            }

            WriteUShort((ushort)cityIndex);
            WriteUShort(0x0000);
            WriteUShort((ushort)slot);

            //if (Client.Version >= ClientVersion.CV_70160)
            //{
            //    WriteUShort((ushort) cityIndex);
            //    WriteUShort(0x0000);
            //    WriteUShort((ushort) slot);
            //}
            //else
            //{
            //    WriteByte((byte) serverIndex);
            //    if (Client.Version < ClientVersion.CV_70130 && cityIndex > 0)
            //        cityIndex--;

            //    WriteByte((byte) cityIndex);
            //    WriteUInt(slot);
            //}

            WriteUInt(clientIP);

            Item shirt = character.FindItemByLayer(Layer.Shirt);

            if (shirt != null)
            {
                WriteUShort(shirt.Hue);
            }
            else
            {
                WriteUShort(0);
            }

            Item pants = character.FindItemByLayer(Layer.Pants);

            if (pants != null)
            {
                WriteUShort(pants.Hue);
            }
            else
            {
                WriteUShort(0x00);
            }
        }