Пример #1
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();
                }
            }
        }
Пример #2
0
        public static void WriteEntry(BaseDb db, StringBuilder builder, ReadableTuple <int> tuple)
        {
            bool useConstants = db.Attached["MobDb.UseConstants"] != null && (bool)db.Attached["MobDb.UseConstants"];

            builder.AppendLine("{");
            builder.AppendLine("\tId: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture));
            builder.AppendLine("\tSpriteName: \"" + tuple.GetValue <string>(ServerMobAttributes.AegisName) + "\"");
            builder.AppendLine("\tName: \"" + tuple.GetValue <string>(ServerMobAttributes.KRoName) + "\"");

            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Lv, "1");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Hp, "1");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Sp, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Exp, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.JExp, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.AttackRange, "1");
            DbIOFormatting.TrySetAttack(tuple, builder);
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Def, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Mdef, "0");

            int stat = 0;

            for (int i = 0; i < 6; i++)
            {
                stat += tuple.GetIntNoThrow(ServerMobAttributes.Str.Index + i);
            }

            if (stat != 0)
            {
                builder.AppendLine("	Stats: {");

                for (int i = 0; i < 6; i++)
                {
                    stat = tuple.GetIntNoThrow(ServerMobAttributes.Str.Index + i);

                    if (stat != 0)
                    {
                        builder.AppendLine(String.Format("		{0}: {1}", ServerMobAttributes.AttributeList[ServerMobAttributes.Str.Index + i].AttributeName, stat));
                    }
                }

                builder.AppendLine("	}");
            }

            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.ViewRange, "1");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.ChaseRange, "1");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Size, "1", useConstants, "Size_");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.Race, "0", useConstants, "RC_");

            int element  = tuple.GetIntNoThrow(ServerMobAttributes.Element);
            int level    = element / 10;
            int property = element - level * 10;

            level = level / 2;

            if (useConstants)
            {
                builder.AppendLine("\tElement: (\"" + SdeEditor.Instance.ProjectDatabase.IntToConstant(property, "Ele_") + "\", " + level + ")");
            }
            else
            {
                builder.AppendLine("\tElement: (" + property + ", " + level + ")");
            }

            int mode = tuple.GetIntNoThrow(ServerMobAttributes.Mode);

            if ((mode & 32767) != 0)
            {
                builder.AppendLine("	Mode: {");

                if ((mode & (1 << 0)) == (1 << 0))
                {
                    builder.AppendLine("		CanMove: true");
                }
                if ((mode & (1 << 1)) == (1 << 1))
                {
                    builder.AppendLine("		Looter: true");
                }
                if ((mode & (1 << 2)) == (1 << 2))
                {
                    builder.AppendLine("		Aggressive: true");
                }
                if ((mode & (1 << 3)) == (1 << 3))
                {
                    builder.AppendLine("		Assist: true");
                }
                if ((mode & (1 << 4)) == (1 << 4))
                {
                    builder.AppendLine("		CastSensorIdle: true");
                }
                if ((mode & (1 << 5)) == (1 << 5))
                {
                    builder.AppendLine("		Boss: true");
                }
                if ((mode & (1 << 6)) == (1 << 6))
                {
                    builder.AppendLine("		Plant: true");
                }
                if ((mode & (1 << 7)) == (1 << 7))
                {
                    builder.AppendLine("		CanAttack: true");
                }
                if ((mode & (1 << 8)) == (1 << 8))
                {
                    builder.AppendLine("		Detector: true");
                }
                if ((mode & (1 << 9)) == (1 << 9))
                {
                    builder.AppendLine("		CastSensorChase: true");
                }
                if ((mode & (1 << 10)) == (1 << 10))
                {
                    builder.AppendLine("		ChangeChase: true");
                }
                if ((mode & (1 << 11)) == (1 << 11))
                {
                    builder.AppendLine("		Angry: true");
                }
                if ((mode & (1 << 12)) == (1 << 12))
                {
                    builder.AppendLine("		ChangeTargetMelee: true");
                }
                if ((mode & (1 << 13)) == (1 << 13))
                {
                    builder.AppendLine("		ChangeTargetChase: true");
                }
                if ((mode & (1 << 14)) == (1 << 14))
                {
                    builder.AppendLine("		TargetWeak: true");
                }

                builder.AppendLine("	}");
            }

            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.MoveSpeed, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.AttackDelay, "4000");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.AttackMotion, "2000");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.DamageMotion, "0");
            DbIOFormatting.TrySetIfNotDefault(tuple, builder, ServerMobAttributes.MvpExp, "0");

            stat = 0;

            for (int i = 0; i < 6; i += 2)
            {
                stat += tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i);
            }

            if (stat != 0)
            {
                builder.AppendLine("	MvpDrops: {");

                for (int i = 0; i < 6; i += 2)
                {
                    stat = tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i);

                    if (stat != 0)
                    {
                        var ttuple = SdeDatabase.GetTuple(null, stat);

                        if (ttuple != null)
                        {
                            builder.AppendLine(String.Format("		{0}: {1}", ttuple.GetStringValue(ServerItemAttributes.AegisName.Index), tuple.GetIntNoThrow(ServerMobAttributes.Mvp1ID.Index + i + 1)));
                        }
                    }
                }

                builder.AppendLine("	}");
            }

            stat = 0;

            for (int i = 0; i < 18; i += 2)
            {
                stat += tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i);
            }

            if (stat != 0)
            {
                builder.AppendLine("	Drops: {");

                for (int i = 0; i < 18; i += 2)
                {
                    stat = tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i);

                    if (stat != 0)
                    {
                        var ttuple = SdeDatabase.GetTuple(null, stat);

                        if (ttuple != null)
                        {
                            builder.AppendLine(String.Format("		{0}: {1}", ttuple.GetStringValue(ServerItemAttributes.AegisName.Index), tuple.GetIntNoThrow(ServerMobAttributes.Drop1ID.Index + i + 1)));
                        }
                    }
                }

                stat = tuple.GetIntNoThrow(ServerMobAttributes.DropCardid);

                if (stat != 0)
                {
                    var ttuple = SdeDatabase.GetTuple(null, stat);

                    if (ttuple != null)
                    {
                        builder.AppendLine(String.Format("		{0}: {1}", ttuple.GetStringValue(ServerItemAttributes.AegisName.Index), tuple.GetIntNoThrow(ServerMobAttributes.DropCardper.Index)));
                    }
                }

                builder.AppendLine("	}");
            }

            builder.Append("},");
        }
Пример #3
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++;
                        }
                    }
                }
            }
        }