示例#1
0
        private bool ParseSkillDB(string skilldbPath, RoGrfFile grf)
        {
            ReportUpdate("skill_db.txt");

            if (File.Exists(skilldbPath) == false)
            {
                return(false);
            }

            string[] lines = File.ReadAllLines(skilldbPath);
            for (int i = 0; i < lines.Length; i++)
            {
                string line = lines[i].Trim();
                if (line.Length == 0 || line.StartsWith("//") == true)
                {
                    continue;
                }

                string[] parts = line.Split(new char[] { ',' }, StringSplitOptions.None);
                if (parts.Length != 17)
                {
                    continue;
                }
                //id,range,hit,inf,element,nk,splash,max,list_num,castcancel,cast_defence_rate,inf2,maxcount,skill_type,blow_count,name,description

                /*
                 *      00: id
                 *      range
                 *      hit
                 *      inf
                 *      04: element
                 *      nk
                 *      splash
                 *      max
                 *      list_num
                 *      castcancel
                 *      cast_defence_rate
                 *      inf2
                 *      maxcount
                 *      skill_type
                 *      blow_count
                 *      15: name
                 *      16: description
                 */
                int    id      = int.Parse(parts[0].Trim());
                string grvName = parts[15].Trim();
                string eaName  = parts[16].Trim();
                // Element may be splitted by level
                // ele_on_lv_1:ele_on_lv_2: ..
                // in this case, choose first element
                EElement eaElement;
                if (parts[4].Contains(':') == true)
                {
                    string[] eleParts = parts[4].Split(':');
                    eaElement = (EElement)int.Parse(eleParts[0].Trim());
                }
                else
                {
                    eaElement = (EElement)int.Parse(parts[4].Trim());
                }

                if (mSkillsTemp.ContainsKey(grvName) == false)
                {
                    // mh..
                    mSkillsTemp.Remove(grvName);
                    System.Diagnostics.Debug.WriteLine("Skill not found in skill_db.txt: " + grvName);
                    continue;
                }
                // Skip NPC, Item, Cash, All Skills..
                if (grvName.StartsWith("NPC_") == true || grvName.StartsWith("ITEM_") == true || grvName.StartsWith("CASH_") == true || grvName.StartsWith("ALL_") == true || grvName.StartsWith("MER_") == true)
                {
                    mSkillsTemp.Remove(grvName);
                    continue;
                }

                if (id >= MAX_SKILL_ID)
                {
                    mSkillsTemp.Remove(grvName);
                    continue;
                }

                mSkillsTemp[grvName].ID          = id;
                mSkillsTemp[grvName].Element     = eaElement;
                mSkillsTemp[grvName].NameEathena = eaName;

                ReportUpdate("[Skill] " + mSkillsTemp[grvName].ToString());

                if (mSkillsTemp[grvName].ImageExists == false)
                {
                    // Load Image..
                    // We try to get the sprite name based on eAthena's Sprite_Name field..
                    RoGrfFileItem grfItem = grf.GetFileByName("data/texture/À¯ÀúÀÎÅÍÆäÀ̽º/item/" + grvName.ToLower() + ".bmp");
                    if (grfItem != null)
                    {
                        grf.CacheFileData(grfItem, true);

                        mSkillsTemp[grvName].ExportImage(grfItem);
                    }
                    else
                    {
                        Debug.WriteLine("Skill image not found: " + mSkillsTemp[grvName].ToString());
                    }
                }
            }

            return(true);
        }