Esempio n. 1
0
        /// <summary>
        /// Handles the protocol request.
        /// </summary>
        /// <param name="request">The instance requesting the protcol handle.</param>
        public void Handle(LoginRequest request)
        {
            request.Buffer.Skip(1);
            int  nameHash = request.Buffer.ReadByte();
            long key      = ((long)(new Random().NextDouble() * 99999999D) << 32) + (long)(new Random().NextDouble() * 99999999D);
            GenericPacketComposer session = new GenericPacketComposer();

            session.AppendByte(0);
            session.AppendLong(key);
            request.Buffer   = null;     // Dump current buffer.
            request.NameHash = nameHash; // Save name hash.
            request.Connection.SendData(session.Serialize());
        }
Esempio n. 2
0
        /// <summary>
        /// Appends the character's current appearance.
        /// </summary>
        /// <param name="character">The character to append updates for.</param>
        /// <param name="updateBlock">The character's update block.</param>
        private static void AppendAppearanceUpdate(Character character, GenericPacketComposer updateBlock)
        {
            GenericPacketComposer properties = new GenericPacketComposer(75);

            // Gender.
            properties.AppendByte((byte)character.Appearance.Gender);

            // Head icons.
            properties.AppendByte(unchecked ((byte)character.HeadIcon.DeathIcon));
            properties.AppendByte(unchecked ((byte)character.HeadIcon.DeathIcon));

            if (!character.Appearance.IsNpc)
            {
                for (int i = 0; i < 4; i++)
                {
                    if (character.Equipment[i] != null)
                    {
                        properties.AppendShort((short)(32768 + character.Equipment[i].Definition.EquipId));
                    }
                    else
                    {
                        properties.AppendByte((byte)0);//I'll check this out later
                    }
                }

                Item chest  = character.Equipment[EquipmentSlot.Chest];
                Item shield = character.Equipment[EquipmentSlot.Shield];
                Item legs   = character.Equipment[EquipmentSlot.Legs];
                Item hat    = character.Equipment[EquipmentSlot.Hat];
                Item hands  = character.Equipment[EquipmentSlot.Hands];
                Item feet   = character.Equipment[EquipmentSlot.Feet];

                // Physical appearance.
                if (chest != null)
                {
                    properties.AppendShort((short)(32768 + chest.Definition.EquipId));
                }
                else
                {
                    properties.AppendShort((short)(0x100 + character.Appearance.Torso));
                }

                if (shield != null)
                {
                    properties.AppendShort((short)(32768 + shield.Definition.EquipId));
                }
                else
                {
                    properties.AppendByte((byte)0);
                }

                if (chest != null)
                {
                    if (!EquipmentItems.IsFullBody(chest.Id))
                    {
                        properties.AppendShort((short)(0x100 + character.Appearance.Arms));
                    }
                    else
                    {
                        properties.AppendByte((byte)0);
                    }
                }
                else
                {
                    properties.AppendShort((short)(0x100 + character.Appearance.Arms));
                }

                if (legs != null)
                {
                    properties.AppendShort((short)(32768 + legs.Definition.EquipId));
                }
                else
                {
                    properties.AppendShort((short)(0x100 + character.Appearance.Legs));
                }

                if (hat != null)
                {
                    if (!EquipmentItems.IsFullHat(hat.Id) && !EquipmentItems.IsFullMask(hat.Id))
                    {
                        properties.AppendShort((short)(0x100 + character.Appearance.Head));
                    }
                    else
                    {
                        properties.AppendByte((byte)0);
                    }
                }
                else
                {
                    properties.AppendShort((short)(0x100 + character.Appearance.Head));
                }

                if (hands != null)
                {
                    properties.AppendShort((short)(32768 + hands.Definition.EquipId));
                }
                else
                {
                    properties.AppendShort((short)(0x100 + character.Appearance.Wrist));
                }

                if (feet != null)
                {
                    properties.AppendShort((short)(32768 + feet.Definition.EquipId));
                }
                else
                {
                    properties.AppendShort((short)(0x100 + character.Appearance.Feet));
                }

                if (hat != null)
                {
                    if (!EquipmentItems.IsFullMask(hat.Id))
                    {
                        properties.AppendShort((short)(0x100 + character.Appearance.Beard));
                    }
                    else
                    {
                        properties.AppendByte((byte)0);
                    }
                }
                else
                {
                    properties.AppendShort((short)(0x100 + character.Appearance.Beard));
                }
            }
            else
            {
                properties.AppendShort(-1);
                properties.AppendShort(character.Appearance.NpcId);
            }

            // Hair colors.
            properties.AppendByte(character.Appearance.HairColor);  //Hair Color
            properties.AppendByte(character.Appearance.TorsoColor); //Torso color
            properties.AppendByte(character.Appearance.LegColor);   //Legs color
            properties.AppendByte(character.Appearance.FeetColor);  //Feet color
            properties.AppendByte(character.Appearance.SkinColor);  //Skin color

            // Emotions.
            properties.AppendShort(character.Equipment.StandAnimation); // stand
            properties.AppendShort(0x337);                              // stand turn
            properties.AppendShort(character.Equipment.WalkAnimation);  // walk
            properties.AppendShort(0x334);                              // turn 180
            properties.AppendShort(0x335);                              // turn 90 cw
            properties.AppendShort(0x336);                              // turn 90 ccw
            properties.AppendShort(character.Equipment.RunAnimation);   // run

            properties.AppendLong(character.LongName);                  // character's name
            properties.AppendByte((byte)character.Skills.CombatLevel);  // combat level
            properties.AppendShort(0);
            updateBlock.AppendByte((byte)(properties.Position & 0xFF));
            updateBlock.AppendBytes(properties.SerializeBuffer());
        }