Beispiel #1
0
        public void loadNpcTemplate(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.WEAPON2] = reader.GetUInt32(22);
                            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.R_EAR]        = reader.GetUInt32(32);
                            appearanceIds[Character.L_EAR]        = reader.GetUInt32(33);
                            appearanceIds[Character.R_RINGFINGER] = reader.GetUInt32(36);
                            appearanceIds[Character.L_RINGFINGER] = reader.GetUInt32(37);
                        }
                    }
                }
                catch (MySqlException e)
                { Console.WriteLine(e); }
                finally
                {
                    conn.Dispose();
                }
            }
        }
Beispiel #2
0
        public static String BuildForCharaList(Character chara, Appearance appearance)
        {
            byte[] data;

            using (MemoryStream stream = new MemoryStream())
            {
                using (BinaryWriter writer = new BinaryWriter(stream))
                {
                    //Build faceinfo for later
                    FaceInfo faceInfo = new FaceInfo();
                    faceInfo.characteristics      = appearance.characteristics;
                    faceInfo.characteristicsColor = appearance.characteristicsColor;
                    faceInfo.type     = appearance.faceType;
                    faceInfo.ears     = appearance.ears;
                    faceInfo.features = appearance.faceFeatures;
                    faceInfo.eyebrows = appearance.faceEyebrows;
                    faceInfo.eyeShape = appearance.faceEyeShape;
                    faceInfo.irisSize = appearance.faceIrisSize;
                    faceInfo.mouth    = appearance.faceMouth;
                    faceInfo.nose     = appearance.faceNose;

                    string location1 = "prv0Inn01\0";
                    string location2 = "defaultTerritory\0";

                    writer.Write((UInt32)0x000004c0);
                    writer.Write((UInt32)0x232327ea);
                    writer.Write((UInt32)System.Text.Encoding.UTF8.GetBytes(chara.name + '\0').Length);
                    writer.Write(System.Text.Encoding.UTF8.GetBytes(chara.name + '\0'));
                    writer.Write((UInt32)0x1c);
                    writer.Write((UInt32)0x04);
                    writer.Write((UInt32)GetTribeModel(chara.tribe));
                    writer.Write((UInt32)appearance.size);
                    uint colorVal = appearance.skinColor | (uint)(appearance.hairColor << 10) | (uint)(appearance.eyeColor << 20);
                    writer.Write((UInt32)colorVal);

                    var bitfield = PrimitiveConversion.ToUInt32(faceInfo);

                    writer.Write((UInt32)bitfield); //FACE, Figure this out!
                    uint hairVal = appearance.hairHighlightColor | (uint)(appearance.hairStyle << 10) | (uint)(appearance.characteristicsColor << 20);
                    writer.Write((UInt32)hairVal);
                    writer.Write((UInt32)appearance.voice);
                    writer.Write((UInt32)appearance.mainHand);
                    writer.Write((UInt32)appearance.offHand);

                    writer.Write((UInt32)0);
                    writer.Write((UInt32)0);
                    writer.Write((UInt32)0);
                    writer.Write((UInt32)0);
                    writer.Write((UInt32)0);

                    writer.Write((UInt32)appearance.head);
                    writer.Write((UInt32)appearance.body);
                    writer.Write((UInt32)appearance.legs);
                    writer.Write((UInt32)appearance.hands);
                    writer.Write((UInt32)appearance.feet);
                    writer.Write((UInt32)appearance.waist);

                    writer.Write((UInt32)0);

                    writer.Write((UInt32)appearance.rightEar);
                    writer.Write((UInt32)appearance.leftEar);

                    writer.Write((UInt32)0);
                    writer.Write((UInt32)0);

                    writer.Write((UInt32)appearance.rightFinger);
                    writer.Write((UInt32)appearance.leftFinger);

                    for (int i = 0; i < 0x8; i++)
                    {
                        writer.Write((byte)0);
                    }

                    writer.Write((UInt32)1);
                    writer.Write((UInt32)1);

                    writer.Write((byte)chara.currentClass);
                    writer.Write((UInt16)chara.currentLevel);
                    writer.Write((byte)chara.currentJob);
                    writer.Write((UInt16)1);
                    writer.Write((byte)chara.tribe);

                    writer.Write((UInt32)0xe22222aa);

                    writer.Write((UInt32)System.Text.Encoding.UTF8.GetBytes(location1).Length);
                    writer.Write(System.Text.Encoding.UTF8.GetBytes(location1));
                    writer.Write((UInt32)System.Text.Encoding.UTF8.GetBytes(location2).Length);
                    writer.Write(System.Text.Encoding.UTF8.GetBytes(location2));

                    writer.Write((byte)chara.guardian);
                    writer.Write((byte)chara.birthMonth);
                    writer.Write((byte)chara.birthDay);

                    writer.Write((UInt16)0x17);
                    writer.Write((UInt32)4);
                    writer.Write((UInt32)4);

                    writer.BaseStream.Seek(0x10, SeekOrigin.Current);

                    writer.Write((UInt32)chara.initialTown);
                    writer.Write((UInt32)chara.initialTown);
                }

                data = stream.GetBuffer();
            }

            return(Convert.ToBase64String(data).Replace('+', '-').Replace('/', '_'));
        }