Beispiel #1
0
        public static void Loader(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            if (debug.FileType == FileType.Yaml)
            {
                var ele   = new YamlParser(debug.FilePath);
                var table = debug.AbsractDb.Table;

                if (ele.Output == null || ((ParserArray)ele.Output).Objects.Count == 0 || (ele.Output["copy_paste"] ?? ele.Output["Body"]) == null)
                {
                    return;
                }

                foreach (var castle in ele.Output["copy_paste"] ?? ele.Output["Body"])
                {
                    int castleId = (int)(object)Int32.Parse(castle["Id"]);

                    table.SetRaw(castleId, ServerCastleAttributes.MapName, castle["Map"] ?? "");
                    table.SetRaw(castleId, ServerCastleAttributes.CastleName, castle["Name"] ?? "");
                    table.SetRaw(castleId, ServerCastleAttributes.NpcName, castle["Npc"] ?? "");
                }
            }
            else if (debug.FileType == FileType.Txt)
            {
                DbIOMethods.DbLoaderComma(debug, db);
            }
        }
Beispiel #2
0
        public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            if (debug.FileType == FileType.Txt)
            {
                DbIOMethods.DbWriterComma(debug, db);
            }
            else if (debug.FileType == FileType.Yaml)
            {
                try {
                    var lines = new YamlParser(debug.OldPath, ParserMode.Write, "Id");

                    if (lines.Output == null)
                    {
                        return;
                    }

                    lines.Remove(db);

                    foreach (ReadableTuple <int> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <int>()))
                    {
                        string key = tuple.Key.ToString(CultureInfo.InvariantCulture);

                        StringBuilder builder = new StringBuilder();
                        WriteEntryYaml(builder, tuple);
                        lines.Write(key, builder.ToString().Trim('\r', '\n'));
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
        }
Beispiel #3
0
 public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db)
 {
     if (debug.FileType == FileType.Conf)
     {
         DbIOMethods.DbIOWriter(debug, db, WriteEntry);
     }
     else if (debug.FileType == FileType.Yaml)
     {
         DbIOMethods.DbIOWriter(debug, db, WriteEntryYaml);
     }
 }
Beispiel #4
0
 public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db)
 {
     if (debug.FileType == FileType.Conf)
     {
         DbIOMethods.DbIOWriterConf(debug, db, (q, r) => WriteEntry(db, q, r));
     }
     else if (debug.FileType == FileType.Txt)
     {
         DbIOMethods.DbWriterComma(debug, db);
     }
 }
Beispiel #5
0
        public static void Loader <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            if (debug.FileType == FileType.Txt)
            {
                DbIOMethods.DbLoaderAny(debug, db, TextFileHelper.GetElementsByTabs);
            }
            else if (debug.FileType == FileType.Conf)
            {
                var ele   = new LibconfigParser(debug.FilePath);
                var table = debug.AbsractDb.Table;

                foreach (var constant in ele.Output["copy_paste"] ?? ele.Output["constants_db"])
                {
                    try {
                        var keyValue = constant as LibconfigKeyValue;

                        if (keyValue != null)
                        {
                            if (keyValue.Key == "comment__")
                            {
                                continue;
                            }

                            if (keyValue.Value is LibconfigArrayBase)
                            {
                                var arrayList = (LibconfigArrayBase)keyValue.Value;

                                table.SetRaw((TKey)(object)keyValue.Key, ServerConstantsAttributes.Deprecated, arrayList["Deprecated"] ?? "false");
                                table.SetRaw((TKey)(object)keyValue.Key, ServerConstantsAttributes.Value, arrayList["Value"] ?? "0");

                                if (arrayList["Parameter"] != null)
                                {
                                    table.SetRaw((TKey)(object)keyValue.Key, ServerConstantsAttributes.Type, Boolean.Parse(arrayList["Parameter"]) ? "1" : "0");
                                }
                            }
                            else
                            {
                                table.SetRaw((TKey)(object)keyValue.Key, ServerConstantsAttributes.Value, keyValue.ObjectValue);
                            }
                        }
                    }
                    catch {
                        if (!debug.ReportIdException(constant.ObjectValue, constant.Line))
                        {
                            return;
                        }
                    }
                }
            }
        }
Beispiel #6
0
        public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            try {
                var itemDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                if (debug.FileType == FileType.Yaml)
                {
                    DbIOMethods.DbIOWriter(debug, db, (r, q) => WriteEntryYaml(r, q, itemDb));
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Beispiel #7
0
 public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db)
 {
     if (debug.FileType == FileType.Conf)
     {
         DbIOMethods.DbIOWriter(debug, db, (q, r) => WriteEntry(db, q, r));
     }
     else if (debug.FileType == FileType.Txt)
     {
         DbIOMethods.DbWriterComma(debug, db);
     }
     else if (debug.FileType == FileType.Yaml)
     {
         var itemDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);
         DbIOMethods.DbIOWriter(debug, db, (r, q) => WriteEntryYaml(r, q, itemDb));
     }
 }
Beispiel #8
0
        public static void DbItemsWriter(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            try {
                StringBuilder builder = new StringBuilder();

                if (debug.FileType == FileType.Txt)
                {
                    if (DbPathLocator.GetServerType() == ServerType.RAthena)
                    {
                        DbIOMethods.DbWriterComma(debug, db, 0, ServerItemAttributes.OnUnequipScript.Index + 1, (tuple, items) => {
                            if (db.ProjectDatabase.IsRenewal)
                            {
                                string value = tuple.GetValue <string>(ServerItemAttributes.Matk) ?? "";

                                if (value == "" || value == "0")
                                {
                                    return;
                                }

                                string atk = items[ServerItemAttributes.Attack.Index].ToString();

                                items[ServerItemAttributes.Attack.Index] = (atk == "" ? "0" : atk) + ":" + value;
                            }
                        });
                        return;
                    }

                    DbItemsWriterSub(builder, db, db.Table.FastItems.OrderBy(p => p.GetKey <int>()), ServerType.RAthena);
                    FtpHelper.WriteAllText(debug.FilePath, builder.ToString());
                }
                else if (debug.FileType == FileType.Conf)
                {
                    DbIOMethods.DbIOWriterConf(debug, db, (r, q) => WriteEntry(db, r, q));
                }
                else if (debug.FileType == FileType.Sql)
                {
                    SqlParser.DbSqlItems(debug, db);
                }
            }
            catch (Exception err) {
                debug.ReportException(err);
            }
        }
Beispiel #9
0
        public static void DbSqlMobs(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            DbSqlWriter writer = new DbSqlWriter();

            writer.Init(debug);

            if (DbPathLocator.DetectPath(debug.DbSource).EndsWith(".conf"))
            {
                object value = db.Attached["EntireRewrite"];
                db.Attached["EntireRewrite"] = true;
                DbIOMethods.DbWriterComma(debug, db);
                db.Attached["EntireRewrite"] = value;
            }
            else
            {
                DbIOMethods.DbWriterComma(debug, db);
            }

            if (debug.DestinationServer == ServerType.RAthena)
            {
                writer.AppendHeader(ResourceString.Get("RAthenaMobDbSqlHeader"));
            }
            else if (debug.DestinationServer == ServerType.Hercules)
            {
                writer.AppendHeader(ResourceString.Get("HerculesMobDbSqlHeader"), writer.TableName.Replace("_re", ""));
                writer.TableName = "mob_db";
            }

            foreach (string line in writer.Read())
            {
                string[] elements = TextFileHelper.ExcludeBrackets(line.Trim('\t'));
                if (!_getMob(writer.IsHercules, writer.TableName, writer.Builder, elements))
                {
                    writer.Line(writer.IsHercules ? line.ReplaceFirst("//", "--" + (writer.NumberOfLinesProcessed > 1 ? " " : "")) : line.ReplaceFirst("//", "#"));
                }
                else
                {
                    writer.NumberOfLinesProcessed++;
                }
            }

            writer.Write();
        }
Beispiel #10
0
        public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            if (debug.FileType == FileType.Txt)
            {
                DbIOMethods.DbWriterComma(debug, db, 0, db.TabGenerator.MaxElementsToCopyInCustomMethods);
                //DbIOMethods.DbWriterComma(debug, db, 0, 22);
            }
            //else if (debug.FileType == FileType.Conf)
            //	DbIOMethods.DbIOWriter(debug, db, WriteEntry);
            else if (debug.FileType == FileType.Yaml)
            {
                var itemDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);
                var mobDb  = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);

                try {
                    var lines = new YamlParser(debug.OldPath, ParserMode.Write, "Mob");

                    if (lines.Output == null)
                    {
                        return;
                    }

                    lines.Remove(db, v => DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, v.ToString(CultureInfo.InvariantCulture)));

                    foreach (ReadableTuple <int> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <int>()))
                    {
                        string key = tuple.Key.ToString(CultureInfo.InvariantCulture);

                        StringBuilder builder = new StringBuilder();
                        WriteEntryYaml(builder, tuple, itemDb, mobDb);
                        lines.Write(DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, key), builder.ToString().Trim('\r', '\n'));
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
        }
Beispiel #11
0
        public static void Loader(DbDebugItem <int> debug, AbstractDb <int> db, int groupId)
        {
            bool hasGuessedAttributes     = false;
            List <DbAttribute> attributes = new List <DbAttribute>(ServerMobGroupSubAttributes.AttributeList.Attributes.Where(p => p.Visibility == VisibleState.Visible));
            var table = db.Table;

            if (!table.ContainsKey(groupId))
            {
                ReadableTuple <int> tuple = new ReadableTuple <int>(groupId, db.AttributeList);
                tuple.SetRawValue(ServerItemGroupAttributes.Table, new Dictionary <int, ReadableTuple <int> >());
                table.Add(groupId, tuple);
            }

            var dico = (Dictionary <int, ReadableTuple <int> >)table.GetRaw(groupId, ServerMobGroupAttributes.Table);

            foreach (string[] elements in TextFileHelper.GetElementsByCommas(IOHelper.ReadAllBytes(debug.FilePath)))
            {
                try {
                    if (!hasGuessedAttributes)
                    {
                        db.Attached["Scanned"] = null;
                        DbIOMethods.GuessAttributes(elements, attributes, -1, db);
                        hasGuessedAttributes = true;
                    }

                    if (attributes.Count == 4)
                    {
                        // rAthena
                        int id = Int32.Parse(elements[1]);

                        ReadableTuple <int> tuple = new ReadableTuple <int>(id, ServerMobGroupSubAttributes.AttributeList);
                        tuple.SetRawValue(ServerMobGroupSubAttributes.Rate, elements[3]);
                        tuple.SetRawValue(ServerMobGroupSubAttributes.DummyName, elements[2]);
                        tuple.SetRawValue(ServerMobGroupSubAttributes.ParentGroup, groupId);
                        dico[id] = tuple;
                    }
                    else
                    {
                        // Hercules
                        int id = Int32.Parse(elements[0]);

                        ReadableTuple <int> tuple = new ReadableTuple <int>(id, ServerMobGroupSubAttributes.AttributeList);
                        tuple.SetRawValue(ServerMobGroupSubAttributes.Rate, elements[2]);
                        tuple.SetRawValue(ServerMobGroupSubAttributes.DummyName, elements[1]);
                        tuple.SetRawValue(ServerMobGroupSubAttributes.ParentGroup, groupId);
                        dico[id] = tuple;
                    }
                }
                catch {
                    if (elements.Length <= 0)
                    {
                        if (!debug.ReportIdException("#"))
                        {
                            return;
                        }
                    }
                    else if (!debug.ReportIdException(elements[0]))
                    {
                        return;
                    }
                }
            }
        }
Beispiel #12
0
 public static void Writer(DbDebugItem <int> debug, AbstractDb <int> db)
 {
     DbIOMethods.DbIOWriterConf(debug, db, WriteEntry);
 }
Beispiel #13
0
        public static void Loader <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            if (debug.FileType == FileType.Txt)
            {
                DbIOMethods.DbLoaderAny(debug, db, TextFileHelper.GetElementsByCommas);
            }
            else if (debug.FileType == FileType.Conf)
            {
                DbIOMethods.GuessAttributes(new string[] { }, db.AttributeList.Attributes.ToList(), -1, db);

                var ele   = new LibconfigParser(debug.FilePath);
                var table = debug.AbsractDb.Table;

                foreach (var parser in ele.Output["copy_paste"] ?? ele.Output["mob_db"])
                {
                    TKey itemId = (TKey)(object)Int32.Parse(parser["Id"]);

                    table.SetRaw(itemId, ServerMobAttributes.AegisName, parser["SpriteName"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.IRoName, parser["Name"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.KRoName, parser["Name"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.Lv, parser["Lv"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Hp, parser["Hp"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Sp, parser["Sp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Exp, parser["Exp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.JExp, parser["JExp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.AttackRange, parser["AttackRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Atk1, Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 0));
                    table.SetRaw(itemId, ServerMobAttributes.Atk2, (Int32.Parse(Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 0)) + Int32.Parse(Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 1))).ToString(CultureInfo.InvariantCulture));
                    table.SetRaw(itemId, ServerMobAttributes.Def, parser["Def"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Mdef, parser["Mdef"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Str, parser["Stats.Str"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Agi, parser["Stats.Agi"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Vit, parser["Stats.Vit"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Int, parser["Stats.Int"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Dex, parser["Stats.Dex"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Luk, parser["Stats.Luk"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.ViewRange, parser["ViewRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.ChaseRange, parser["ChaseRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Size, SdeEditor.Instance.ProjectDatabase.ConstantToInt(parser["Size"] ?? "1").ToString(CultureInfo.InvariantCulture));
                    table.SetRaw(itemId, ServerMobAttributes.Race, SdeEditor.Instance.ProjectDatabase.ConstantToInt(parser["Race"] ?? "0").ToString(CultureInfo.InvariantCulture));

                    var element = parser["Element"];
                    int elLevel;
                    int elType;

                    if (element != null)
                    {
                        debug.AbsractDb.Attached["MobDb.UseConstants"] = true;
                        elLevel = Int32.Parse(((ParserList)element).Objects[1].ObjectValue);
                        elType  = SdeEditor.Instance.ProjectDatabase.ConstantToInt(((ParserList)element).Objects[0].ObjectValue);
                    }
                    else
                    {
                        elLevel = 0;
                        elType  = 0;
                    }

                    table.SetRaw(itemId, ServerMobAttributes.Element, ((elLevel) * 20 + elType).ToString(CultureInfo.InvariantCulture));

                    table.SetRaw(itemId, ServerMobAttributes.Mode, (
                                     (!Boolean.Parse((parser["Mode.CanMove"] ?? "false")) ? 0 : (1 << 0)) |
                                     (!Boolean.Parse((parser["Mode.Looter"] ?? "false")) ? 0 : (1 << 1)) |
                                     (!Boolean.Parse((parser["Mode.Aggressive"] ?? "false")) ? 0 : (1 << 2)) |
                                     (!Boolean.Parse((parser["Mode.Assist"] ?? "false")) ? 0 : (1 << 3)) |
                                     (!Boolean.Parse((parser["Mode.CastSensorIdle"] ?? "false")) ? 0 : (1 << 4)) |
                                     (!Boolean.Parse((parser["Mode.Boss"] ?? "false")) ? 0 : (1 << 5)) |
                                     (!Boolean.Parse((parser["Mode.Plant"] ?? "false")) ? 0 : (1 << 6)) |
                                     (!Boolean.Parse((parser["Mode.CanAttack"] ?? "false")) ? 0 : (1 << 7)) |
                                     (!Boolean.Parse((parser["Mode.Detector"] ?? "false")) ? 0 : (1 << 8)) |
                                     (!Boolean.Parse((parser["Mode.CastSensorChase"] ?? "false")) ? 0 : (1 << 9)) |
                                     (!Boolean.Parse((parser["Mode.ChangeChase"] ?? "false")) ? 0 : (1 << 10)) |
                                     (!Boolean.Parse((parser["Mode.Angry"] ?? "false")) ? 0 : (1 << 11)) |
                                     (!Boolean.Parse((parser["Mode.ChangeTargetMelee"] ?? "false")) ? 0 : (1 << 12)) |
                                     (!Boolean.Parse((parser["Mode.ChangeTargetChase"] ?? "false")) ? 0 : (1 << 13)) |
                                     (!Boolean.Parse((parser["Mode.TargetWeak"] ?? "false")) ? 0 : (1 << 14))
                                     ).ToString(CultureInfo.InvariantCulture));

                    table.SetRaw(itemId, ServerMobAttributes.MoveSpeed, parser["MoveSpeed"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.AttackDelay, parser["AttackDelay"] ?? "4000");
                    table.SetRaw(itemId, ServerMobAttributes.AttackMotion, parser["AttackMotion"] ?? "2000");
                    table.SetRaw(itemId, ServerMobAttributes.DamageMotion, parser["DamageMotion"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.MvpExp, parser["MvpExp"] ?? "0");

                    int id = 0;

                    var mvpDrops = parser["MvpDrops"];

                    if (mvpDrops != null)
                    {
                        foreach (var drop in mvpDrops)
                        {
                            if (id > 2)
                            {
                                debug.ReportIdException("Too many MVP mob drops.", itemId, ErrorLevel.Critical);
                                break;
                            }

                            int tItemId = SdeDatabase.AegisNameToId(debug, itemId, ((ParserKeyValue)drop).Key);
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id + 1], drop.ObjectValue);
                            id++;
                        }
                    }

                    id = 0;

                    var regularDrops = parser["Drops"];

                    if (regularDrops != null)
                    {
                        foreach (var drop in regularDrops)
                        {
                            if (id > 8)
                            {
                                debug.ReportIdException("Too regular mob drops.", itemId, ErrorLevel.Critical);
                                break;
                            }

                            int tItemId = SdeDatabase.AegisNameToId(debug, itemId, ((ParserKeyValue)drop).Key);
                            var tuple   = SdeDatabase.GetTuple(debug, tItemId);

                            if (tuple != null && tuple.GetValue <TypeType>(ServerItemAttributes.Type) == TypeType.Card)
                            {
                                table.SetRaw(itemId, ServerMobAttributes.DropCardid, tItemId.ToString(CultureInfo.InvariantCulture));
                                table.SetRaw(itemId, ServerMobAttributes.DropCardper, drop.ObjectValue);
                                id++;
                                continue;
                            }

                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id + 1], drop.ObjectValue);
                            id++;
                        }
                    }
                }
            }
            else if (debug.FileType == FileType.Yaml)
            {
                try {
                    DbIOMethods.GuessAttributes(new string[] { }, db.AttributeList.Attributes.ToList(), -1, db);

                    var ele   = new YamlParser(debug.FilePath);
                    var table = debug.AbsractDb.Table;

                    if (ele.Output == null || ((ParserArray)ele.Output).Objects.Count == 0)
                    {
                        return;
                    }

                    if ((ele.Output["copy_paste"] ?? ele.Output["Body"]) == null)
                    {
                        return;
                    }

                    DbIOUtils.ClearBuffer();
                    var mobDb  = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);
                    var itemDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                    foreach (var parser in ele.Output["copy_paste"] ?? ele.Output["Body"])
                    {
                        TKey itemId = (TKey)(object)Int32.Parse(parser["Id"]);

                        table.SetRaw(itemId, ServerMobAttributes.AegisName, parser["AegisName"].ObjectValue);
                        table.SetRaw(itemId, ServerMobAttributes.IRoName, parser["Name"].ObjectValue);
                        table.SetRaw(itemId, ServerMobAttributes.KRoName, (parser["JapaneseName"] ?? parser["Name"]).ObjectValue);
                        table.SetRaw(itemId, ServerMobAttributes.Lv, parser["Level"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Hp, parser["Hp"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Sp, parser["Sp"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Exp, parser["BaseExp"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.JExp, parser["JobExp"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.MvpExp, parser["MvpExp"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.Atk1, parser["Attack"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.Atk2, parser["Attack2"] ?? "0");

                        table.SetRaw(itemId, ServerMobAttributes.Def, parser["Defense"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.Mdef, parser["MagicDefense"] ?? "0");

                        table.SetRaw(itemId, ServerMobAttributes.Str, parser["Str"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Agi, parser["Agi"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Vit, parser["Vit"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Int, parser["Int"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Dex, parser["Dex"] ?? "1");
                        table.SetRaw(itemId, ServerMobAttributes.Luk, parser["Luk"] ?? "1");

                        table.SetRaw(itemId, ServerMobAttributes.AttackRange, parser["AttackRange"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.ViewRange, parser["SkillRange"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.ChaseRange, parser["ChaseRange"] ?? "0");

                        table.SetRaw(itemId, ServerMobAttributes.Size, DbIOUtils.LoadFlag <SizeType>(parser["Size"], "0"));
                        table.SetRaw(itemId, ServerMobAttributes.Race, DbIOUtils.LoadFlag <MobRaceType>(parser["Race"], "0"));
                        table.SetRaw(itemId, ServerMobAttributes.RaceGroups, DbIOUtils.LoadFlag <MobGroup2Type>(parser["RaceGroups"], "0"));

                        var element = parser["Element"];
                        int elLevel;
                        int elType;

                        if (element != null)
                        {
                            switch (element.ObjectValue)
                            {
                            case "Neutral": elType = 0; break;

                            case "Water": elType = 1; break;

                            case "Earth": elType = 2; break;

                            case "Fire": elType = 3; break;

                            case "Wind": elType = 4; break;

                            case "Poison": elType = 5; break;

                            case "Holy": elType = 6; break;

                            case "Dark": elType = 7; break;

                            case "Ghost": elType = 8; break;

                            case "Undead": elType = 9; break;

                            default: elType = 0; break;
                            }
                        }
                        else
                        {
                            elType = 0;
                        }

                        element = parser["ElementLevel"];

                        if (element != null)
                        {
                            elLevel = Int32.Parse(element.ObjectValue);
                        }
                        else
                        {
                            elLevel = 1;
                        }

                        table.SetRaw(itemId, ServerMobAttributes.Element, ((elLevel) * 20 + elType).ToString(CultureInfo.InvariantCulture));

                        table.SetRaw(itemId, ServerMobAttributes.MoveSpeed, parser["WalkSpeed"] ?? "");
                        table.SetRaw(itemId, ServerMobAttributes.AttackDelay, parser["AttackDelay"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.AttackMotion, parser["AttackMotion"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.DamageMotion, parser["DamageMotion"] ?? "0");
                        table.SetRaw(itemId, ServerMobAttributes.DamageTaken, parser["DamageTaken"] ?? "100");

                        long mode = 0;

                        if (parser["Ai"] != null)
                        {
                            int ai = Int32.Parse(parser["Ai"].ObjectValue);

                            switch (ai)
                            {
                            case 1: mode |= 0x81; break;

                            case 2: mode |= 0x83; break;

                            case 3: mode |= 0x1089; break;

                            case 4: mode |= 0x3885; break;

                            case 5: mode |= 0x2085; break;

                            case 6: mode |= 0; break;

                            case 7: mode |= 0x108B; break;

                            case 8: mode |= 0x7085; break;

                            case 9: mode |= 0x3095; break;

                            case 10: mode |= 0x84; break;

                            case 11: mode |= 0x84; break;

                            case 12: mode |= 0x2085; break;

                            case 13: mode |= 0x308D; break;

                            case 17: mode |= 0x91; break;

                            case 19: mode |= 0x3095; break;

                            case 20: mode |= 0x3295; break;

                            case 21: mode |= 0x3695; break;

                            case 24: mode |= 0xA1; break;

                            case 25: mode |= 0x1; break;

                            case 26: mode |= 0xB695; break;

                            case 27: mode |= 0x8084; break;
                            }
                        }

                        mode |= Int64.Parse(DbIOUtils.LoadFlag <NewMobModeType>(parser["Modes"], "0"));

                        table.SetRaw(itemId, ServerMobAttributes.NewMode, mode.ToString(CultureInfo.InvariantCulture));
                        table.SetRaw(itemId, ServerMobAttributes.Class, DbIOUtils.LoadFlag <ClassType>(parser["Class"], "0"));
                        table.SetRaw(itemId, ServerMobAttributes.Sprite, parser["Sprite"] ?? "");


                        int id = 0;

                        var mvpDrops = parser["MvpDrops"];

                        if (mvpDrops != null)
                        {
                            foreach (var drop in mvpDrops)
                            {
                                if (id > 2)
                                {
                                    debug.ReportIdException("Too many MVP mob drops.", itemId, ErrorLevel.Critical);
                                    break;
                                }

                                int tItemId = (int)DbIOUtils.Name2IdBuffered(itemDb, ServerItemAttributes.AegisName, drop["Item"] ?? "", "item_db", false);
                                table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                                table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id + 1], drop["Rate"] ?? "0");

                                if (drop["RandomOptionGroup"] != null)
                                {
                                    table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1RandomOptionGroup.Index + id], drop["RandomOptionGroup"].ObjectValue);
                                }

                                id++;
                            }
                        }

                        id = 0;

                        var regularDrops = parser["Drops"];

                        if (regularDrops != null)
                        {
                            foreach (var drop in regularDrops)
                            {
                                if (id > 9)
                                {
                                    debug.ReportIdException("Too many regular mob drops.", itemId, ErrorLevel.Critical);
                                    break;
                                }

                                int tItemId = (int)DbIOUtils.Name2IdBuffered(itemDb, ServerItemAttributes.AegisName, drop["Item"] ?? "", "item_db", false);

                                table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                                table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id + 1], drop["Rate"] ?? "0");

                                if (drop["StealProtected"] != null)
                                {
                                    if (Boolean.Parse(drop["StealProtected"].ObjectValue))
                                    {
                                        table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1Flags.Index + id], "true");
                                    }
                                }

                                if (drop["RandomOptionGroup"] != null)
                                {
                                    table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1RandomOptionGroup.Index + id], drop["RandomOptionGroup"].ObjectValue);
                                }

                                id++;
                            }
                        }
                    }
                }
                finally {
                    DbIOUtils.ClearBuffer();
                }
            }
        }
Beispiel #14
0
        private static void _loadEntry(Table <int, ReadableTuple <int> > table, LuaKeyValue item)
        {
            int           itemIndex      = Int32.Parse(item.Key.Substring(1, item.Key.Length - 2));
            LuaList       itemProperties = item.Value as LuaList;
            LuaList       contentProperties;
            StringBuilder resources;

            if (itemProperties != null)
            {
                foreach (LuaKeyValue itemProperty in itemProperties.Variables)
                {
                    switch (itemProperty.Key)
                    {
                    case "UI_Type":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.UiType, ((LuaValue)itemProperty.Value).Value);
                        break;

                    case "group":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.GroupId, DbIOMethods.RemoveQuotes(((LuaValue)itemProperty.Value).Value));
                        break;

                    case "major":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.Major, ((LuaValue)itemProperty.Value).Value);
                        break;

                    case "minor":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.Minor, ((LuaValue)itemProperty.Value).Value);
                        break;

                    case "title":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.Name, DbIOMethods.RemoveQuotes(((LuaValue)itemProperty.Value).Value));
                        break;

                    case "reward":
                    case "content":
                        contentProperties = itemProperty.Value as LuaList;

                        if (contentProperties == null)
                        {
                            continue;
                        }

                        foreach (LuaKeyValue contentProperty in contentProperties.Variables)
                        {
                            switch (contentProperty.Key)
                            {
                            case "summary":
                                table.SetRaw(itemIndex, ClientCheevoAttributes.Summary, DbIOMethods.RemoveQuotes(((LuaValue)contentProperty.Value).Value));
                                break;

                            case "details":
                                table.SetRaw(itemIndex, ClientCheevoAttributes.Details, DbIOMethods.RemoveQuotes(((LuaValue)contentProperty.Value).Value));
                                break;

                            case "title":
                                table.SetRaw(itemIndex, ClientCheevoAttributes.RewardTitleId, ((LuaValue)contentProperty.Value).Value);
                                break;

                            case "buff":
                                table.SetRaw(itemIndex, ClientCheevoAttributes.RewardBuff, ((LuaValue)contentProperty.Value).Value);
                                break;

                            case "item":
                                table.SetRaw(itemIndex, ClientCheevoAttributes.RewardId, ((LuaValue)contentProperty.Value).Value);
                                break;
                            }
                        }

                        break;

                    case "resource":
                        resources = new StringBuilder();

                        contentProperties = itemProperty.Value as LuaList;

                        if (contentProperties == null)
                        {
                            continue;
                        }

                        foreach (LuaKeyValue contentProperty in contentProperties.Variables)
                        {
                            int     resId = Int32.Parse(contentProperty.Key.Substring(1, contentProperty.Key.Length - 2));
                            LuaList resourceProperties = contentProperty.Value as LuaList;

                            if (resourceProperties == null)
                            {
                                continue;
                            }

                            resources.Append(resId);

                            foreach (LuaKeyValue resourceProperty in resourceProperties.Variables)
                            {
                                string value = ((LuaValue)resourceProperty.Value).Value;
                                resources.Append("__%");
                                resources.Append(resourceProperty.Key);
                                resources.Append("__%");

                                if (value.StartsWith("\""))
                                {
                                    resources.Append(DbIOMethods.RemoveQuotes(value));
                                }
                                else
                                {
                                    resources.Append(value);
                                }
                            }

                            resources.Append("__&");
                        }

                        table.SetRaw(itemIndex, ClientCheevoAttributes.Resources, resources.ToString());
                        break;

                    case "score":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.Score, ((LuaValue)itemProperty.Value).Value);
                        break;
                    }
                }
            }
        }
Beispiel #15
0
        public static void Loader(AbstractDb <int> db, string file)
        {
            if (file == null)
            {
                Debug.Ignore(() => DbDebugHelper.OnUpdate(db.DbSource, null, "achievement_list table will not be loaded."));
                return;
            }

            LuaList list;

            var table   = db.Table;
            var metaGrf = db.ProjectDatabase.MetaGrf;

            string outputPath = GrfPath.Combine(SdeAppConfiguration.TempPath, Path.GetFileName(file));

            byte[] itemData = metaGrf.GetData(file);

            if (itemData == null)
            {
                Debug.Ignore(() => DbDebugHelper.OnUpdate(db.DbSource, file, "File not found."));
                return;
            }

            File.WriteAllBytes(outputPath, itemData);

            if (!File.Exists(outputPath))
            {
                return;
            }

            if (Methods.ByteArrayCompare(itemData, 0, 4, new byte[] { 0x1b, 0x4c, 0x75, 0x61 }, 0))
            {
                // Decompile lub file
                Lub lub  = new Lub(itemData);
                var text = lub.Decompile();
                itemData = EncodingService.DisplayEncoding.GetBytes(text);
                File.WriteAllBytes(outputPath, itemData);
            }

            DbIOMethods.DetectAndSetEncoding(itemData);

            using (LuaReader reader = new LuaReader(outputPath, DbIOMethods.DetectedEncoding)) {
                list = reader.ReadAll();
            }

            LuaKeyValue itemVariable = list.Variables[0] as LuaKeyValue;

            if (itemVariable != null && itemVariable.Key == "achievement_tbl")
            {
                LuaList items = itemVariable.Value as LuaList;

                if (items != null)
                {
                    foreach (LuaKeyValue item in items.Variables)
                    {
                        _loadEntry(table, item);
                    }
                }
            }
            else
            {
                // Possible copy-paste data
                foreach (LuaKeyValue item in list.Variables)
                {
                    _loadEntry(table, item);
                }
            }

            Debug.Ignore(() => DbDebugHelper.OnLoaded(db.DbSource, metaGrf.FindTkPath(file), db));
        }
Beispiel #16
0
        public static void Loader <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            if (debug.FileType == FileType.Txt)
            {
                DbIOMethods.DbLoaderAny(debug, db, TextFileHelper.GetElementsByCommas);
            }
            else if (debug.FileType == FileType.Conf)
            {
                DbIOMethods.GuessAttributes(new string[] { }, db.AttributeList.Attributes.ToList(), -1, db);

                var ele   = new LibconfigParser(debug.FilePath);
                var table = debug.AbsractDb.Table;

                foreach (var parser in ele.Output["copy_paste"] ?? ele.Output["mob_db"])
                {
                    TKey itemId = (TKey)(object)Int32.Parse(parser["Id"]);

                    table.SetRaw(itemId, ServerMobAttributes.SpriteName, parser["SpriteName"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.IRoName, parser["Name"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.KRoName, parser["Name"].ObjectValue);
                    table.SetRaw(itemId, ServerMobAttributes.Lv, parser["Lv"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Hp, parser["Hp"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Sp, parser["Sp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Exp, parser["Exp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.JExp, parser["JExp"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.AttackRange, parser["AttackRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Atk1, Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 0));
                    table.SetRaw(itemId, ServerMobAttributes.Atk2, (Int32.Parse(Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 0)) + Int32.Parse(Extensions.ParseBracket(parser["Attack"] ?? "[0, 0]", 1))).ToString(CultureInfo.InvariantCulture));
                    table.SetRaw(itemId, ServerMobAttributes.Def, parser["Def"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Mdef, parser["Mdef"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Str, parser["Stats.Str"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Agi, parser["Stats.Agi"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Vit, parser["Stats.Vit"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Int, parser["Stats.Int"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Dex, parser["Stats.Dex"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.Luk, parser["Stats.Luk"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.ViewRange, parser["ViewRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.ChaseRange, parser["ChaseRange"] ?? "1");
                    table.SetRaw(itemId, ServerMobAttributes.Size, SdeEditor.Instance.ProjectDatabase.ConstantToInt(parser["Size"] ?? "1").ToString(CultureInfo.InvariantCulture));
                    table.SetRaw(itemId, ServerMobAttributes.Race, SdeEditor.Instance.ProjectDatabase.ConstantToInt(parser["Race"] ?? "0").ToString(CultureInfo.InvariantCulture));

                    var element = parser["Element"];
                    int elLevel;
                    int elType;

                    if (element != null)
                    {
                        debug.AbsractDb.Attached["MobDb.UseConstants"] = true;
                        elLevel = Int32.Parse(((LibconfigList)element).Objects[1].ObjectValue);
                        elType  = SdeEditor.Instance.ProjectDatabase.ConstantToInt(((LibconfigList)element).Objects[0].ObjectValue);
                    }
                    else
                    {
                        elLevel = 0;
                        elType  = 0;
                    }

                    table.SetRaw(itemId, ServerMobAttributes.Element, ((elLevel) * 20 + elType).ToString(CultureInfo.InvariantCulture));

                    table.SetRaw(itemId, ServerMobAttributes.Mode, (
                                     (!Boolean.Parse((parser["Mode.CanMove"] ?? "false")) ? 0 : (1 << 0)) |
                                     (!Boolean.Parse((parser["Mode.Looter"] ?? "false")) ? 0 : (1 << 1)) |
                                     (!Boolean.Parse((parser["Mode.Aggressive"] ?? "false")) ? 0 : (1 << 2)) |
                                     (!Boolean.Parse((parser["Mode.Assist"] ?? "false")) ? 0 : (1 << 3)) |
                                     (!Boolean.Parse((parser["Mode.CastSensorIdle"] ?? "false")) ? 0 : (1 << 4)) |
                                     (!Boolean.Parse((parser["Mode.Boss"] ?? "false")) ? 0 : (1 << 5)) |
                                     (!Boolean.Parse((parser["Mode.Plant"] ?? "false")) ? 0 : (1 << 6)) |
                                     (!Boolean.Parse((parser["Mode.CanAttack"] ?? "false")) ? 0 : (1 << 7)) |
                                     (!Boolean.Parse((parser["Mode.Detector"] ?? "false")) ? 0 : (1 << 8)) |
                                     (!Boolean.Parse((parser["Mode.CastSensorChase"] ?? "false")) ? 0 : (1 << 9)) |
                                     (!Boolean.Parse((parser["Mode.ChangeChase"] ?? "false")) ? 0 : (1 << 10)) |
                                     (!Boolean.Parse((parser["Mode.Angry"] ?? "false")) ? 0 : (1 << 11)) |
                                     (!Boolean.Parse((parser["Mode.ChangeTargetMelee"] ?? "false")) ? 0 : (1 << 12)) |
                                     (!Boolean.Parse((parser["Mode.ChangeTargetChase"] ?? "false")) ? 0 : (1 << 13)) |
                                     (!Boolean.Parse((parser["Mode.TargetWeak"] ?? "false")) ? 0 : (1 << 14))
                                     ).ToString(CultureInfo.InvariantCulture));

                    table.SetRaw(itemId, ServerMobAttributes.MoveSpeed, parser["MoveSpeed"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.AttackDelay, parser["AttackDelay"] ?? "4000");
                    table.SetRaw(itemId, ServerMobAttributes.AttackMotion, parser["AttackMotion"] ?? "2000");
                    table.SetRaw(itemId, ServerMobAttributes.DamageMotion, parser["DamageMotion"] ?? "0");
                    table.SetRaw(itemId, ServerMobAttributes.MvpExp, parser["MvpExp"] ?? "0");

                    int id = 0;

                    var mvpDrops = parser["MvpDrops"];

                    if (mvpDrops != null)
                    {
                        foreach (var drop in mvpDrops)
                        {
                            if (id > 2)
                            {
                                debug.ReportIdException("Too many MVP mob drops.", itemId, ErrorLevel.Critical);
                                break;
                            }

                            int tItemId = SdeDatabase.AegisNameToId(debug, itemId, ((LibconfigKeyValue)drop).Key);
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Mvp1ID.Index + 2 * id + 1], drop.ObjectValue);
                            id++;
                        }
                    }

                    id = 0;

                    var regularDrops = parser["Drops"];

                    if (regularDrops != null)
                    {
                        foreach (var drop in regularDrops)
                        {
                            if (id > 8)
                            {
                                debug.ReportIdException("Too regular mob drops.", itemId, ErrorLevel.Critical);
                                break;
                            }

                            int tItemId = SdeDatabase.AegisNameToId(debug, itemId, ((LibconfigKeyValue)drop).Key);
                            var tuple   = SdeDatabase.GetTuple(debug, tItemId);

                            if (tuple != null && tuple.GetValue <TypeType>(ServerItemAttributes.Type) == TypeType.Card)
                            {
                                table.SetRaw(itemId, ServerMobAttributes.DropCardid, tItemId.ToString(CultureInfo.InvariantCulture));
                                table.SetRaw(itemId, ServerMobAttributes.DropCardper, drop.ObjectValue);
                                id++;
                                continue;
                            }

                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id], tItemId.ToString(CultureInfo.InvariantCulture));
                            table.SetRaw(itemId, ServerMobAttributes.AttributeList[ServerMobAttributes.Drop1ID.Index + 2 * id + 1], drop.ObjectValue);
                            id++;
                        }
                    }
                }
            }
        }
Beispiel #17
0
        public static void Loader(DbDebugItem <int> debug, AbstractDb <int> db)
        {
            if (debug.FileType == FileType.Yaml)
            {
                var ele   = new YamlParser(debug.FilePath);
                var table = debug.AbsractDb.Table;

                if (ele.Output == null || ((ParserArray)ele.Output).Objects.Count == 0 || (ele.Output["copy_paste"] ?? ele.Output["Body"]) == null)
                {
                    return;
                }

                var mobDb  = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Mobs);
                var itemDb = SdeEditor.Instance.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                foreach (var pet in ele.Output["copy_paste"] ?? ele.Output["Body"])
                {
                    string mob = pet["Mob"] ?? "";

                    int mobId = (int)DbIOUtils.Name2Id(mobDb, ServerMobAttributes.AegisName, mob, "mob_db", false);

                    table.SetRaw(mobId, ServerPetAttributes.LureId, DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, pet["TameItem"] ?? "", "item_db", true));
                    table.SetRaw(mobId, ServerPetAttributes.Name, mob);
                    table.SetRaw(mobId, ServerPetAttributes.EggId, DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, pet["EggItem"] ?? "", "item_db", true));
                    table.SetRaw(mobId, ServerPetAttributes.EquipId, DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, pet["EquipItem"] ?? "", "item_db", true));
                    table.SetRaw(mobId, ServerPetAttributes.FoodId, DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, pet["FoodItem"] ?? "", "item_db", true));
                    table.SetRaw(mobId, ServerPetAttributes.Fullness, pet["Fullness"] ?? "");
                    table.SetRaw(mobId, ServerPetAttributes.HungryDelay, pet["HungryDelay"] ?? ServerPetAttributes.HungryDelay.Default.ToString());
                    table.SetRaw(mobId, ServerPetAttributes.HungerIncrease, pet["HungerIncrease"] ?? ServerPetAttributes.HungerIncrease.Default.ToString());

                    table.SetRaw(mobId, ServerPetAttributes.IntimacyStart, pet["IntimacyStart"] ?? ServerPetAttributes.IntimacyStart.Default.ToString());
                    table.SetRaw(mobId, ServerPetAttributes.IntimacyFed, pet["IntimacyFed"] ?? ServerPetAttributes.IntimacyFed.Default.ToString());
                    table.SetRaw(mobId, ServerPetAttributes.IntimacyOverfed, pet["IntimacyOverfed"] ?? ServerPetAttributes.IntimacyOverfed.Default.ToString());
                    table.SetRaw(mobId, ServerPetAttributes.IntimacyHungry, pet["IntimacyHungry"] ?? ServerPetAttributes.IntimacyHungry.Default.ToString());
                    table.SetRaw(mobId, ServerPetAttributes.IntimacyOwnerDie, pet["Intimacy.OwnerDie"] ?? ServerPetAttributes.IntimacyOwnerDie.Default.ToString());
                    table.SetRaw(mobId, ServerPetAttributes.CaptureRate, pet["CaptureRate"] ?? ServerPetAttributes.CaptureRate.Default.ToString());

                    table.SetRaw(mobId, ServerPetAttributes.SpecialPerformance, (pet["SpecialPerformance"] ?? "true") == "true" ? "1" : "0");
                    table.SetRaw(mobId, ServerPetAttributes.AttackRate, pet["AttackRate"] ?? "");
                    table.SetRaw(mobId, ServerPetAttributes.RetaliateRate, pet["RetaliateRate"] ?? "");
                    table.SetRaw(mobId, ServerPetAttributes.ChangeTargetRate, pet["ChangeTargetRate"] ?? "");
                    table.SetRaw(mobId, ServerPetAttributes.AllowAutoFeed, pet["AllowAutoFeed"] ?? "");
                    table.SetRaw(mobId, ServerPetAttributes.LoyalScript, pet["Script"] ?? "");
                    table.SetRaw(mobId, ServerPetAttributes.PetScript, pet["SupportScript"] ?? "");

                    if (pet["Evolution"] != null)
                    {
                        var evolution = pet["Evolution"];

                        Evolution evolutionObj = new Evolution();

                        foreach (var target in evolution)
                        {
                            EvolutionTarget targetObj = new EvolutionTarget();
                            targetObj.Target = target["Target"];

                            foreach (var requirement in target["ItemRequirements"])
                            {
                                targetObj.ItemRequirements.Add(new Utilities.Extension.Tuple <object, int>(requirement["Item"] ?? "501", Int32.Parse(requirement["Amount"])));
                            }

                            evolutionObj.Targets.Add(targetObj);
                        }

                        table.SetRaw(mobId, ServerPetAttributes.Evolution, evolutionObj.ToString());
                    }
                }
            }
            else if (debug.FileType == FileType.Txt)
            {
                //DbIOMethods.DbLoaderComma(debug, db);
                DbIOMethods.DbLoaderAny(debug, db, TextFileHelper.GetElementsByCommas, true, 25);
                //numberOfAttributesToGuess
            }
        }
Beispiel #18
0
        private static void _loadEntry(Table <int, ReadableTuple <int> > table, LuaKeyValue item)
        {
            int     itemIndex      = Int32.Parse(item.Key.Substring(1, item.Key.Length - 2));
            LuaList itemProperties = item.Value as LuaList;
            LuaList itemList;

            if (itemProperties != null)
            {
                foreach (LuaKeyValue itemProperty in itemProperties.Variables)
                {
                    switch (itemProperty.Key)
                    {
                    case "unidentifiedDisplayName":
                        table.SetRaw(itemIndex, ClientItemAttributes.UnidentifiedDisplayName, DbIOMethods.RemoveQuotes(((LuaValue)itemProperty.Value).Value));
                        break;

                    case "unidentifiedResourceName":
                        table.SetRaw(itemIndex, ClientItemAttributes.UnidentifiedResourceName, DbIOMethods.RemoveQuotes(((LuaValue)itemProperty.Value).Value));
                        break;

                    case "identifiedDisplayName":
                        table.SetRaw(itemIndex, ClientItemAttributes.IdentifiedDisplayName, DbIOMethods.RemoveQuotes(((LuaValue)itemProperty.Value).Value));
                        break;

                    case "identifiedResourceName":
                        table.SetRaw(itemIndex, ClientItemAttributes.IdentifiedResourceName, DbIOMethods.RemoveQuotes(((LuaValue)itemProperty.Value).Value));
                        break;

                    case "slotCount":
                        table.SetRaw(itemIndex, ClientItemAttributes.NumberOfSlots, ((LuaValue)itemProperty.Value).Value);
                        break;

                    case "ClassNum":
                        table.SetRaw(itemIndex, ClientItemAttributes.ClassNumber, ((LuaValue)itemProperty.Value).Value);
                        break;

                    case "costume":
                        table.SetRaw(itemIndex, ClientItemAttributes.IsCostume, Boolean.Parse(((LuaValue)itemProperty.Value).Value));
                        break;

                    case "unidentifiedDescriptionName":
                        itemList = itemProperty.Value as LuaList;
                        if (itemList != null)
                        {
                            StringBuilder b = new StringBuilder();
                            b.Append("\r\n");
                            foreach (LuaValue itemDescItem in itemList.Variables)
                            {
                                b.Append(DbIOMethods.RemoveQuotes(itemDescItem.Value));
                                b.Append("\r\n");
                            }
                            table.SetRaw(itemIndex, ClientItemAttributes.UnidentifiedDescription, b.ToString());
                        }
                        break;

                    case "identifiedDescriptionName":
                        itemList = itemProperty.Value as LuaList;
                        if (itemList != null)
                        {
                            StringBuilder b = new StringBuilder();
                            b.Append("\r\n");
                            foreach (LuaValue itemDescItem in itemList.Variables)
                            {
                                b.Append(DbIOMethods.RemoveQuotes(itemDescItem.Value));
                                b.Append("\r\n");
                            }
                            table.SetRaw(itemIndex, ClientItemAttributes.IdentifiedDescription, b.ToString());
                        }
                        break;
                    }
                }
            }
        }
Beispiel #19
0
        private static void _loadEntry(Table <int, ReadableTuple <int> > table, LuaKeyValue item)
        {
            int           itemIndex      = Int32.Parse(item.Key.Substring(1, item.Key.Length - 2));
            LuaList       itemProperties = item.Value as LuaList;
            LuaList       contentProperties;
            StringBuilder resources;

            if (itemProperties != null)
            {
                foreach (LuaKeyValue itemProperty in itemProperties.Variables)
                {
                    switch (itemProperty.Key)
                    {
                    case "UI_Type":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.UiType, ((LuaValue)itemProperty.Value).Value);
                        break;

                    case "group":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.GroupId, DbIOMethods.RemoveQuotes(((LuaValue)itemProperty.Value).Value));
                        break;

                    case "major":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.Major, ((LuaValue)itemProperty.Value).Value);
                        break;

                    case "minor":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.Minor, ((LuaValue)itemProperty.Value).Value);
                        break;

                    case "title":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.Name, DbIOMethods.RemoveQuotes(((LuaValue)itemProperty.Value).Value));
                        break;

                    case "reward":
                    case "content":
                        contentProperties = itemProperty.Value as LuaList;

                        if (contentProperties == null)
                        {
                            continue;
                        }

                        try {
                            foreach (LuaKeyValue contentProperty in contentProperties.Variables)
                            {
                                switch (contentProperty.Key)
                                {
                                case "summary":
                                    table.SetRaw(itemIndex, ClientCheevoAttributes.Summary, DbIOMethods.RemoveQuotes(((LuaValue)contentProperty.Value).Value));
                                    break;

                                case "details":
                                    table.SetRaw(itemIndex, ClientCheevoAttributes.Details, DbIOMethods.RemoveQuotes(((LuaValue)contentProperty.Value).Value));
                                    break;

                                case "title":
                                    table.SetRaw(itemIndex, ClientCheevoAttributes.RewardTitleId, ((LuaValue)contentProperty.Value).Value);
                                    break;

                                case "buff":
                                    table.SetRaw(itemIndex, ClientCheevoAttributes.RewardBuff, ((LuaValue)contentProperty.Value).Value);
                                    break;

                                case "item":
                                    table.SetRaw(itemIndex, ClientCheevoAttributes.RewardId, ((LuaValue)contentProperty.Value).Value);
                                    break;
                                }
                            }
                        }
                        catch (Exception err) {
                            ErrorHandler.HandleException(err);
                        }

                        break;

                    case "resource":
                        resources = new StringBuilder();

                        contentProperties = itemProperty.Value as LuaList;

                        if (contentProperties == null)
                        {
                            continue;
                        }

                        foreach (LuaKeyValue contentProperty in contentProperties.Variables)
                        {
                            try {
                                int resId;

                                if (!Int32.TryParse(contentProperty.Key.Substring(1, contentProperty.Key.Length - 2), out resId))
                                {
                                    DbIOErrorHandler.Handle(StackTraceException.GetStrackTraceException(),
                                                            String.Format("ID: {0}, file: '{1}', exception: '{2}'",
                                                                          itemIndex.ToString(CultureInfo.InvariantCulture),
                                                                          TextFileHelper.LatestFile,
                                                                          "Invalid resource ID, found \"" + contentProperty.Key + "\", expected an integer."), ErrorLevel.Warning);
                                    continue;
                                }

                                LuaList resourceProperties = contentProperty.Value as LuaList;

                                if (resourceProperties == null)
                                {
                                    continue;
                                }

                                resources.Append(resId);

                                foreach (LuaKeyValue resourceProperty in resourceProperties.Variables)
                                {
                                    string value = ((LuaValue)resourceProperty.Value).Value;
                                    resources.Append("__%");
                                    resources.Append(resourceProperty.Key);
                                    resources.Append("__%");

                                    if (value.StartsWith("\""))
                                    {
                                        resources.Append(DbIOMethods.RemoveQuotes(value));
                                    }
                                    else
                                    {
                                        resources.Append(value);
                                    }
                                }

                                resources.Append("__&");
                            }
                            catch (Exception err) {
                                throw new Exception("Failed to read resource for ID " + itemIndex, err);
                            }
                        }

                        table.SetRaw(itemIndex, ClientCheevoAttributes.Resources, resources.ToString());
                        break;

                    case "score":
                        table.SetRaw(itemIndex, ClientCheevoAttributes.Score, ((LuaValue)itemProperty.Value).Value);
                        break;
                    }
                }
            }
        }
Beispiel #20
0
        public static void Loader <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            if (debug.FileType == FileType.Txt)
            {
                DbIOMethods.DbLoaderAny(debug, db, TextFileHelper.GetElementsByCommas2);

                if (db.ProjectDatabase.IsRenewal)
                {
                    string val;

                    foreach (var tuple in db.Table.FastItems)
                    {
                        try {
                            val = tuple.GetStringValue(ServerItemAttributes.Attack.Index);

                            if (val != null && val.Contains(":"))
                            {
                                string[] values = val.Split(':');

                                tuple.SetRawValue(ServerItemAttributes.Attack, values[0]);
                                tuple.SetRawValue(ServerItemAttributes.Matk, values[1]);
                            }
                        }
                        catch (Exception) {
                            if (!debug.ReportIdException(tuple.Key))
                            {
                                return;
                            }
                        }
                    }
                }
            }
            else if (debug.FileType == FileType.Conf)
            {
                var ele   = new LibconfigParser(debug.FilePath);
                var table = debug.AbsractDb.Table;

                foreach (var item in ele.Output["copy_paste"] ?? ele.Output["item_db"])
                {
                    TKey itemId = (TKey)(object)Int32.Parse(item["Id"]);

                    var defaultGender = "2";

                    // The .conf is actually quite confusing
                    // Overriding values are not setup for some reason and the parser
                    // has to guess and fix the issues.
                    int ival;
                    if (Int32.TryParse(item["Id"], out ival))
                    {
                        // Whips overrides the default property to 0
                        if (ival >= 1950 && ival < 2000)
                        {
                            defaultGender = "0";
                        }

                        // Bride_Ring, I'm assuming it's hard coded in the client and
                        // people thought it would be wise to ignore setting its gender
                        if (ival == 2635)
                        {
                            defaultGender = "0";
                        }

                        // Bridegroom_Ring
                        if (ival == 2634)
                        {
                            defaultGender = "1";
                        }
                    }

                    table.SetRaw(itemId, ServerItemAttributes.AegisName, item["AegisName"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Name, item["Name"] ?? "");

                    var type = item["Type"] ?? "3";
                    var defaultRefineable = "false";

                    if (type == "4" || type == "5")
                    {
                        defaultRefineable = "true";

                        if (!SdeAppConfiguration.RevertItemTypes)
                        {
                            if (type == "4")
                            {
                                type = "5";
                            }
                            else if (type == "5")
                            {
                                type = "4";
                            }
                        }
                    }

                    table.SetRaw(itemId, ServerItemAttributes.Type, type);
                    table.SetRaw(itemId, ServerItemAttributes.Buy, item["Buy"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Sell, item["Sell"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Weight, item["Weight"] ?? "0");
                    table.SetRaw(itemId, ServerItemAttributes.Attack, item["Atk"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Defense, item["Def"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Range, item["Range"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.NumberOfSlots, item["Slots"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.ApplicableJob, _jobToId(debug.AbsractDb.To <int>(), item));
                    table.SetRaw(itemId, ServerItemAttributes.Upper, item["Upper"] ?? "0x3f");
                    table.SetRaw(itemId, ServerItemAttributes.Gender, item["Gender"] ?? defaultGender);
                    table.SetRaw(itemId, ServerItemAttributes.Location, item["Loc"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.WeaponLevel, item["WeaponLv"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.EquipLevel, item["EquipLv"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Refineable, item["Refine"] ?? defaultRefineable);
                    table.SetRaw(itemId, ServerItemAttributes.ClassNumber, item["View"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Script, item["Script"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.OnEquipScript, item["OnEquipScript"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.OnUnequipScript, item["OnUnequipScript"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.KeepAfterUse, item["KeepAfterUse"] ?? "false");
                    table.SetRaw(itemId, ServerItemAttributes.ForceSerial, item["ForceSerial"] ?? "false");

                    table.SetRaw(itemId, ServerItemAttributes.Matk, item["Matk"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.BindOnEquip, item["BindOnEquip"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.BuyingStore, item["BuyingStore"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Delay, item["Delay"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Stack, item["Stack"] ?? "");
                    table.SetRaw(itemId, ServerItemAttributes.Sprite, item["Sprite"] ?? "");

                    table.SetRaw(itemId, ServerItemAttributes.TradeOverride, item["Trade.override"] ?? "100");
                    table.SetRaw(itemId, ServerItemAttributes.TradeFlag, (
                                     (!Boolean.Parse((item["Trade.nodrop"] ?? "false")) ? 0 : (1 << 0)) |
                                     (!Boolean.Parse((item["Trade.notrade"] ?? "false")) ? 0 : (1 << 1)) |
                                     (!Boolean.Parse((item["Trade.partneroverride"] ?? "false")) ? 0 : (1 << 2)) |
                                     (!Boolean.Parse((item["Trade.noselltonpc"] ?? "false")) ? 0 : (1 << 3)) |
                                     (!Boolean.Parse((item["Trade.nocart"] ?? "false")) ? 0 : (1 << 4)) |
                                     (!Boolean.Parse((item["Trade.nostorage"] ?? "false")) ? 0 : (1 << 5)) |
                                     (!Boolean.Parse((item["Trade.nogstorage"] ?? "false")) ? 0 : (1 << 6)) |
                                     (!Boolean.Parse((item["Trade.nomail"] ?? "false")) ? 0 : (1 << 7)) |
                                     (!Boolean.Parse((item["Trade.noauction"] ?? "false")) ? 0 : (1 << 8))
                                     ).ToString(CultureInfo.InvariantCulture));

                    table.SetRaw(itemId, ServerItemAttributes.NoUseOverride, item["Nouse.override"] ?? "100");
                    table.SetRaw(itemId, ServerItemAttributes.NoUseFlag, (
                                     (!Boolean.Parse((item["Nouse.sitting"] ?? "false")) ? 0 : (1 << 0))
                                     ).ToString(CultureInfo.InvariantCulture));
                }
            }
        }