Ejemplo n.º 1
0
        public void read()
        {
            using (FileStream fstream = File.Open(@"dlc\skillenchant.dlc", FileMode.Open, FileAccess.Read))
            {
                byte[] dlcheader = new byte[3];
                fstream.Read(dlcheader, 0, dlcheader.Length);
                if (Encoding.UTF8.GetString(dlcheader) == "DLC")
                {
                    DlcStream dlc = new DlcStream(fstream, CompressionMode.Decompress);
                    int       cnt = dlc.readD();
                    for (int a = 0; a < cnt; a++)
                    {
                        TSkillEnchantInfo inf = new TSkillEnchantInfo();
                        inf.id = dlc.readD();
                        inf.lv = dlc.readD();
                        int len = dlc.readD();
                        for (int b = 0; b < len; b++)
                        {
                            TSkillEnchantInfoDetail nfo = new TSkillEnchantInfoDetail();
                            nfo.route_id              = dlc.readD();
                            nfo.enchant_id            = dlc.readD();
                            nfo.enchanted_skill_level = dlc.readD();
                            nfo.importance            = dlc.readC();
                            nfo.r1 = dlc.readD();
                            nfo.r2 = dlc.readD();
                            nfo.r3 = dlc.readD();
                            nfo.r4 = dlc.readD();
                            dlc.readS(10);

                            inf.details.Add(nfo.enchanted_skill_level, nfo);
                        }

                        enchantInfo.Add(inf.id * 65536 + inf.lv, inf);
                    }
                }
            }

            SortedList <int, object> _ids = new SortedList <int, object>();

            initreg();
            using (FileStream fstream = File.Open(@"dlc\skilldb_edit.dlc", FileMode.Open, FileAccess.Read))
            {
                byte[] dlcheader = new byte[3];
                fstream.Read(dlcheader, 0, dlcheader.Length);
                if (Encoding.UTF8.GetString(dlcheader) == "DLC")
                {
                    DlcStream dlc = new DlcStream(fstream, CompressionMode.Decompress);
                    int       cnt = dlc.readD();
                    for (int a = 0; a < cnt; a++)
                    {
                        byte   len   = dlc.readC();
                        TSkill skill = new TSkill();
                        for (byte p = 0; p < len; p++)
                        {
                            byte            keyId = dlc.readC();
                            SkillLevelParam slp   = ps[keyId];
                            int             lenx;
                            string          value;
                            switch (slp.id)
                            {
                            case 1:
                                skill.skill_id = dlc.readD();
                                break;

                            case 2:
                                skill.level = dlc.readD();
                                break;

                            case 3:
                                lenx         = dlc.readD();
                                value        = dlc.readS(lenx);
                                skill.OpType = (TSkillOperational)Enum.Parse(typeof(TSkillOperational), value);
                                break;

                            case 4:
                                skill.magic_level = dlc.readD();
                                break;

                            case 6:
                                lenx  = dlc.readD();
                                value = dlc.readS(lenx);
                                skill.SetEffect_effect(value);
                                break;

                            case 8:
                                lenx  = dlc.readD();
                                value = dlc.readS(lenx);
                                skill.SetOperateCond(value);
                                break;

                            case 15:
                                skill.is_magic = (short)dlc.readD();
                                break;

                            case 16:
                                skill.mp_consume1 = dlc.readD();
                                break;

                            case 17:
                                skill.mp_consume2 = dlc.readD();
                                break;

                            case 18:
                                skill.cast_range = dlc.readD();
                                break;

                            case 19:
                                skill.effective_range = dlc.readD();
                                break;

                            case 20:
                                skill.skill_hit_time = (short)(dlc.readF() * 1000);
                                break;

                            case 21:
                                skill.skill_cool_time = (short)(dlc.readF() * 1000);
                                break;

                            case 23:
                                skill.reuse_delay = dlc.readF();
                                break;

                            case 26:
                                double rate = dlc.readF();
                                if (rate != -1)
                                {
                                    skill.activate_rate = (short)(rate * 1000);
                                }
                                break;

                            case 29:
                                skill.abnormal_time = dlc.readD();
                                break;

                            case 30:
                                skill.abnormal_lv = dlc.readD();
                                break;

                            case 31:
                                lenx = dlc.readD();
                                skill.abnormal_type = dlc.readS(lenx);
                                break;

                            case 39:    //target_type
                                lenx  = dlc.readD();
                                value = dlc.readS(lenx);
                                try
                                {
                                    skill.target_type = (TSkillTarget)Enum.Parse(typeof(TSkillTarget), value);
                                }
                                catch (Exception)
                                {
                                    skill.target_type = TSkillTarget.target;
                                    CLogger.error("skill #" + skill.skill_id + " invalid target " + value);
                                }
                                break;

                            case 40:    //affect_scope
                                lenx  = dlc.readD();
                                value = dlc.readS(lenx);
                                try
                                {
                                    skill.affect_scope = (TSkillScope)Enum.Parse(typeof(TSkillScope), value);
                                }
                                catch
                                {
                                    skill.affect_scope = TSkillScope.single;
                                    CLogger.error("skill #" + skill.skill_id + " invalid scope " + value);
                                }
                                break;

                            case 49:
                                skill.hp_consume = dlc.readD();
                                break;

                            default:
                                switch (slp.type)
                                {
                                case 1: dlc.readD();
                                    break;

                                case 2: dlc.readF();
                                    break;

                                case 3:
                                    int f = dlc.readD();
                                    dlc.readS(f);
                                    break;
                                }
                                break;
                            }
                        }

                        if (enchantInfo.ContainsKey(skill.HashID()))
                        {
                            skill.EnchantEnabled = 1;
                        }

                        _skills.Add(skill.HashID(), skill);

                        if (!_ids.ContainsKey(skill.skill_id))
                        {
                            _ids.Add(skill.skill_id, null);
                        }
                    }
                }
            }

            //using (StreamReader sreader = File.OpenText(@"scripts\skills.txt"))
            //{
            //    while (!sreader.EndOfStream)
            //    {
            //        string line = sreader.ReadLine();
            //        if (line.Length == 0 || line.StartsWith("#"))
            //            continue;

            //        string[] pt = line.Split('\t');

            //        TSkill skill = new TSkill();
            //        skill.ClientID = Convert.ToInt32(pt[0].Split('-')[0]);
            //        skill.Level = Convert.ToInt32(pt[0].Split('-')[1]);

            //        if (_idsEnchant.Contains(skill.HashID()))
            //            skill.EnchantEnabled = 1;

            //        skill.OpType = (TSkillOperational)Enum.Parse(typeof(TSkillOperational), pt[1]);

            //        for (byte ord = 2; ord < pt.Length; ord++)
            //        {
            //            string parameter = pt[ord];
            //            switch (parameter.Split('{')[0].ToLower())
            //            {
            //                case "effect":
            //                    skill.parseEffects(parameter.Substring(7));
            //                    break;
            //                case "is_magic":
            //                    skill.IsMagic = Convert.ToInt16(parameter.Remove(parameter.Length - 1).Substring(9));
            //                    break;
            //                case "mpconsume":
            //                    break;
            //                case "hit_time":
            //                    skill.HitTime = Convert.ToInt16(parameter.Remove(parameter.Length - 1).Substring(9));
            //                    break;
            //                case "cool_time":
            //                    skill.CoolTime = Convert.ToInt32(parameter.Remove(parameter.Length - 1).Substring(10));
            //                    break;
            //                case "reuse":
            //                    string reuse = parameter.Remove(parameter.Length - 1).Substring(6);
            //                    if (reuse.Contains("."))
            //                        skill.Reuse = double.Parse(reuse);
            //                    else
            //                        skill.Reuse = int.Parse(reuse);
            //                    break;
            //                case "activate_rate":
            //                    skill.ActivateRate = Convert.ToInt16(parameter.Remove(parameter.Length - 1).Substring(14));
            //                    break;
            //                case "target":
            //                    skill.setTarget(parameter.Substring(7));
            //                    break;
            //                case "cond":
            //                    break;
            //                case "bonus":
            //                    break;
            //                case "next":
            //                    break;

            //                case "abnormal_time":
            //                    skill.AbnormalTime = Convert.ToInt32(parameter.Remove(parameter.Length - 1).Substring(14));
            //                    break;
            //                case "abnormal_id":
            //                    break;
            //            }
            //        }

            //        _skills.Add(skill.HashID(), skill);

            //        if (!_ids.ContainsKey(skill.ClientID))
            //            _ids.Add(skill.ClientID, null);
            //    }
            //}

            CLogger.info("SkillTable: loaded " + _ids.Count + " skills, " + enchantInfo.Count + " enchants.");
        }
Ejemplo n.º 2
0
 private void reg(SkillLevelParam s)
 {
     ps.Add(s.id, s);
 }