Exemplo n.º 1
0
        public void LoadNpcAppearance(uint id)
        {
            using (MySqlConnection conn = new MySqlConnection(String.Format("Server={0}; Port={1}; Database={2}; UID={3}; Password={4}", ConfigConstants.DATABASE_HOST, ConfigConstants.DATABASE_PORT, ConfigConstants.DATABASE_NAME, ConfigConstants.DATABASE_USERNAME, ConfigConstants.DATABASE_PASSWORD)))
            {
                try
                {
                    conn.Open();

                    string query = @"
                                    SELECT                 
                                    base,
                                    size,
                                    hairStyle,
                                    hairHighlightColor,
                                    hairVariation,
                                    faceType,   
                                    characteristics,
                                    characteristicsColor,
                                    faceEyebrows,
                                    faceIrisSize,
                                    faceEyeShape,
                                    faceNose,
                                    faceFeatures,
                                    faceMouth,
                                    ears,
                                    hairColor,
                                    skinColor,
                                    eyeColor,
                                    voice,
                                    mainHand,
                                    offHand,
                                    spMainHand,
                                    spOffHand,
                                    throwing,
                                    pack,
                                    pouch,
                                    head,
                                    body,
                                    legs,
                                    hands,
                                    feet,
                                    waist,
                                    neck,
                                    leftEar,
                                    rightEar,
                                    leftIndex,
                                    rightIndex,
                                    leftFinger,
                                    rightFinger
                                    FROM gamedata_actor_appearance
                                    WHERE id = @templateId
                                    ";

                    MySqlCommand cmd = new MySqlCommand(query, conn);
                    cmd.Parameters.AddWithValue("@templateId", id);

                    using (MySqlDataReader reader = cmd.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            //Handle Appearance
                            modelId = reader.GetUInt32(0);
                            appearanceIds[Character.SIZE]           = reader.GetUInt32(1);
                            appearanceIds[Character.COLORINFO]      = (uint)(reader.GetUInt32(16) | (reader.GetUInt32(15) << 10) | (reader.GetUInt32(17) << 20)); //17 - Skin Color, 16 - Hair Color, 18 - Eye Color
                            appearanceIds[Character.FACEINFO]       = PrimitiveConversion.ToUInt32(CharacterUtils.GetFaceInfo(reader.GetByte(6), reader.GetByte(7), reader.GetByte(5), reader.GetByte(14), reader.GetByte(13), reader.GetByte(12), reader.GetByte(11), reader.GetByte(10), reader.GetByte(9), reader.GetByte(8)));
                            appearanceIds[Character.HIGHLIGHT_HAIR] = (uint)(reader.GetUInt32(3) | reader.GetUInt32(2) << 10);                                    //5- Hair Highlight, 4 - Hair Style
                            appearanceIds[Character.VOICE]          = reader.GetUInt32(17);
                            appearanceIds[Character.MAINHAND]       = reader.GetUInt32(19);
                            appearanceIds[Character.OFFHAND]        = reader.GetUInt32(20);
                            appearanceIds[Character.SPMAINHAND]     = reader.GetUInt32(21);
                            appearanceIds[Character.SPOFFHAND]      = reader.GetUInt32(22);
                            appearanceIds[Character.THROWING]       = reader.GetUInt32(23);
                            appearanceIds[Character.PACK]           = reader.GetUInt32(24);
                            appearanceIds[Character.POUCH]          = reader.GetUInt32(25);
                            appearanceIds[Character.HEADGEAR]       = reader.GetUInt32(26);
                            appearanceIds[Character.BODYGEAR]       = reader.GetUInt32(27);
                            appearanceIds[Character.LEGSGEAR]       = reader.GetUInt32(28);
                            appearanceIds[Character.HANDSGEAR]      = reader.GetUInt32(29);
                            appearanceIds[Character.FEETGEAR]       = reader.GetUInt32(30);
                            appearanceIds[Character.WAISTGEAR]      = reader.GetUInt32(31);
                            appearanceIds[Character.NECKGEAR]       = reader.GetUInt32(32);
                            appearanceIds[Character.R_EAR]          = reader.GetUInt32(33);
                            appearanceIds[Character.L_EAR]          = reader.GetUInt32(34);
                            appearanceIds[Character.R_INDEXFINGER]  = reader.GetUInt32(35);
                            appearanceIds[Character.L_INDEXFINGER]  = reader.GetUInt32(36);
                            appearanceIds[Character.R_RINGFINGER]   = reader.GetUInt32(37);
                            appearanceIds[Character.L_RINGFINGER]   = reader.GetUInt32(38);
                        }
                    }
                }
                catch (MySqlException e)
                { Console.WriteLine(e); }
                finally
                {
                    conn.Dispose();
                }
            }
        }