Exemple #1
0
        public Evolution(string evolutionStringFormat, MetaTable <int> itemDb, MetaTable <int> mobDb)
        {
            if (String.IsNullOrEmpty(evolutionStringFormat))
            {
                return;
            }

            string[] data = evolutionStringFormat.Trim(',').Split(',');

            for (int i = 0; i < data.Length; i++)
            {
                var field = data[i];

                if (field.StartsWith("#"))
                {
                    var target = new EvolutionTarget();
                    target.Target = DbIOUtils.Name2Id(mobDb, ServerMobAttributes.AegisName, field.Substring(1), "mob_db", true).ToString();
                    Targets.Add(target);
                }
                else
                {
                    var last = Targets.Last();
                    last.ItemRequirements.Add(new Utilities.Extension.Tuple <object, int>(DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, data[i], "item_db", true), Int32.Parse(data[i + 1])));
                    i++;
                }
            }
        }
Exemple #2
0
            public string GetStringFormat(RangeListView lv, Dictionary <string, MetaTable <int> > dbs)
            {
                var           itemDb = dbs[ServerDbs.Items];
                StringBuilder b      = new StringBuilder();

                b.Append(DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, _requirement.Item1.ToString(), "item_db", true));
                b.Append(",");
                b.Append(_requirement.Item2);
                b.Append(",");

                return(b.ToString());
            }
Exemple #3
0
            public string GetStringFormat(RangeListView lv, Dictionary <string, MetaTable <int> > dbs)
            {
                var           itemDb = dbs[ServerDbs.Items];
                var           mobDb  = dbs[ServerDbs.Mobs];
                StringBuilder b      = new StringBuilder();

                b.Append("#");
                b.Append(DbIOUtils.Name2Id(mobDb, ServerMobAttributes.AegisName, EvolutionTarget.Target, "item_db", true));
                b.Append(",");

                foreach (Utilities.Extension.Tuple <object, int> item in EvolutionTarget.ItemRequirements)
                {
                    b.Append(DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, item.Item1.ToString(), "item_db", true));
                    b.Append(",");
                    b.Append(item.Item2);
                    b.Append(",");
                }

                return(b.ToString());
            }
Exemple #4
0
            //private void _tuple_TupleModified(object sender, bool value) {
            //	OnPropertyChanged();
            //}

            private void _reload()
            {
                object res = DbIOUtils.Name2Id(_mobsTable, ServerMobAttributes.AegisName, _evolutionTarget.Target, "mob_db", true);

                EvolutionName = "";

                if (res is int)
                {
                    int key = (int)res;
                    ID = res.ToString();

                    if (_mobsTable.ContainsKey(key))
                    {
                        EvolutionName = (string)_mobsTable.GetTuple(key).GetRawValue(ServerMobAttributes.KRoName.Index);
                    }
                }
                else
                {
                    ID = res.ToString();
                }
            }
Exemple #5
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);
                }
            }
        }
Exemple #6
0
            private void _reload()
            {
                object res = DbIOUtils.Name2Id(_itemsTable, ServerItemAttributes.AegisName, _requirement.Item1 as string, "mob_db", true);

                Name = "";

                if (res is int)
                {
                    int key = (int)res;
                    ID = res.ToString();

                    if (_itemsTable.ContainsKey(key))
                    {
                        Name = (string)_itemsTable.GetTuple(key).GetRawValue(ServerItemAttributes.Name.Index);
                    }
                }
                else
                {
                    ID = res.ToString();
                }

                Amount = _requirement.Item2;
            }
Exemple #7
0
        private void _miPasteRequirement_Click(object sender, RoutedEventArgs e)
        {
            try {
                if (_tab.List.SelectedItem == null)
                {
                    return;
                }
                if (!Clipboard.ContainsText())
                {
                    return;
                }

                string   text          = Clipboard.GetText();
                string[] elementsToAdd = text.Trim(',').Split(',');

                if (elementsToAdd.Length % 2 != 0)
                {
                    throw new Exception("The number of arguments must be even.");
                }

                List <Utilities.Extension.Tuple <object, int> > copy = new List <Utilities.Extension.Tuple <object, int> >();
                var itemDb = _tab.ProjectDatabase.GetMetaTable <int>(ServerDbs.Items);

                for (int i = 0; i < elementsToAdd.Length; i += 2)
                {
                    copy.Add(new Utilities.Extension.Tuple <object, int>(DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, elementsToAdd[i], "item_db", true).ToString(), Int32.Parse(elementsToAdd[i + 1])));
                }

                var btable = _tab.Table;

                btable.Commands.Begin();

                TValue item    = (TValue)_tab.List.SelectedItem;
                bool   changed = false;

                try {
                    _evolution = new Evolution();

                    foreach (var targetEv in _lv.Items.OfType <PetEvolutionView>())
                    {
                        if (targetEv == _lv.SelectedItem)
                        {
                            List <Utilities.Extension.Tuple <object, int> > requirements = new List <Utilities.Extension.Tuple <object, int> >();

                            foreach (var requirement in _lvRequirements.Items.OfType <PetEvolutionTargetView>())
                            {
                                if (copy.Any(p => p.Item1.ToString() == requirement.ID.ToString(CultureInfo.InvariantCulture) && p.Item2 == requirement.Amount))
                                {
                                    var cpyEntry = copy.Where(p => p.Item1.ToString() == requirement.ID.ToString(CultureInfo.InvariantCulture) && p.Item2 == requirement.Amount).ToList();

                                    foreach (var ea in cpyEntry)
                                    {
                                        copy.Remove(ea);
                                    }
                                }
                                else if (copy.Any(p => p.Item1.ToString() == requirement.ID.ToString(CultureInfo.InvariantCulture) && p.Item2 != requirement.Amount))
                                {
                                    var cpyEntry = copy.First(p => p.Item1.ToString() == requirement.ID.ToString(CultureInfo.InvariantCulture));

                                    requirements.Add(cpyEntry);
                                    copy.Remove(cpyEntry);
                                    changed = true;
                                }
                                else
                                {
                                    requirements.Add(requirement.Requirement);
                                }
                            }

                            if (copy.Count > 0)
                            {
                                requirements.AddRange(copy.Select(p => new Utilities.Extension.Tuple <object, int>(DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, p.Item1.ToString()), p.Item2)));
                                changed = true;
                            }

                            targetEv.EvolutionTarget.ItemRequirements = requirements;
                        }

                        _evolution.Targets.Add(targetEv.EvolutionTarget);
                    }

                    if (changed)
                    {
                        btable.Commands.Set(item, ServerPetAttributes.Evolution, _evolution.ToString());
                    }
                }
                catch (Exception err) {
                    ErrorHandler.HandleException(err);
                }

                btable.Commands.EndEdit();

                if (changed)
                {
                    _updateAction(item);
                }
            }
            catch (Exception err) {
                ErrorHandler.HandleException(err);
            }
        }
Exemple #8
0
        public static void WriteEntryYaml(StringBuilder builder, ReadableTuple <int> tuple, MetaTable <int> itemDb)
        {
            if (tuple != null)
            {
                int    value;
                bool   valueB;
                string valueS;

                builder.AppendLine("  - Id: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture));

                if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.Name)) != "")
                {
                    builder.AppendLine("    Name: " + DbIOUtils.QuoteCheck(valueS));
                }

                if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.Desc)) != "")
                {
                    builder.AppendLine("    Description: " + DbIOUtils.QuoteCheck(valueS));
                }

                builder.AppendLine("    MaxLevel: " + tuple.GetValue <int>(ServerSkillAttributes.MaxLevel));

                if ((value = tuple.GetValue <int>(ServerSkillAttributes.AttackType)) != 0)
                {
                    builder.AppendLine("    Type: " + Constants.ToString <AttackTypeType>(value));
                }

                if ((value = tuple.GetValue <int>(ServerSkillAttributes.SkillTargetType)) != 0)
                {
                    builder.AppendLine("    TargetType: " + Constants.ToString <SkillTargetType>(value));
                }

                DbIOUtils.ExpandFlag <SkillDamageType>(builder, tuple, "DamageFlags", ServerSkillAttributes.DamageFlags, YamlParser.Indent4, YamlParser.Indent6);
                DbIOUtils.ExpandFlag <SkillType2TypeNew>(builder, tuple, "Flags", ServerSkillAttributes.Inf2New, YamlParser.Indent4, YamlParser.Indent6);

                _expandList(builder, tuple, "Range", "      - Level", "Size", ServerSkillAttributes.Range, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);

                if ((value = tuple.GetValue <int>(ServerSkillAttributes.HitMode)) != 0)
                {
                    builder.AppendLine("    Hit: " + Constants.ToString <HitType>(value));
                }

                _expandList(builder, tuple, "HitCount", "      - Level", "Count", ServerSkillAttributes.HitCount, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                _expandList(builder, tuple, "Element", "      - Level", "Element", ServerSkillAttributes.SkillElement, YamlParser.Indent4, YamlParser.Indent8, "Neutral", itemDb);
                _expandList(builder, tuple, "SplashArea", "      - Level", "Area", ServerSkillAttributes.SplashArea, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                _expandList(builder, tuple, "ActiveInstance", "      - Level", "Max", ServerSkillAttributes.ActiveInstance, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                _expandList(builder, tuple, "Knockback", "      - Level", "Amount", ServerSkillAttributes.Knockback, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);

                if (tuple.GetValue <int>(ServerSkillAttributes.CopyFlags) > 0 || tuple.GetValue <int>(ServerSkillAttributes.CopyFlagsRemovedRequirement) > 0)
                {
                    builder.AppendLine("    CopyFlags:");

                    DbIOUtils.ExpandFlag <SkillCopyType>(builder, tuple, "Skill", ServerSkillAttributes.CopyFlags, YamlParser.Indent6, YamlParser.Indent8);
                    DbIOUtils.ExpandFlag <SkillCopyRemoveRequirementType>(builder, tuple, "RemoveRequirement", ServerSkillAttributes.CopyFlagsRemovedRequirement, YamlParser.Indent6, YamlParser.Indent8);
                }

                if (tuple.GetValue <int>(ServerSkillAttributes.NoNearNPCRange) > 0 || tuple.GetValue <int>(ServerSkillAttributes.NoNearNPCType) > 0)
                {
                    builder.AppendLine("    NoNearNPC:");

                    if ((value = tuple.GetValue <int>(ServerSkillAttributes.NoNearNPCRange)) != 0)
                    {
                        builder.AppendLine("      AdditionalRange: " + value);
                    }

                    DbIOUtils.ExpandFlag <NoNearNpcType>(builder, tuple, "Type", ServerSkillAttributes.NoNearNPCType, YamlParser.Indent6, YamlParser.Indent8);
                }

                if ((valueB = tuple.GetValue <bool>(ServerSkillAttributes.CastInterrupt)) != false)
                {
                    builder.AppendLine("    CastCancel: " + (valueB ? "true" : "false"));
                }

                if ((value = tuple.GetValue <int>(ServerSkillAttributes.CastDefenseReduction)) != 0)
                {
                    builder.AppendLine("    CastDefenseReduction: " + value);
                }

                _expandList(builder, tuple, "CastTime", "      - Level", "Time", ServerSkillAttributes.CastingTime, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                _expandList(builder, tuple, "AfterCastActDelay", "      - Level", "Time", ServerSkillAttributes.AfterCastActDelay, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                _expandList(builder, tuple, "AfterCastWalkDelay", "      - Level", "Time", ServerSkillAttributes.AfterCastWalkDelay, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                _expandList(builder, tuple, "Duration1", "      - Level", "Time", ServerSkillAttributes.Duration1, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                _expandList(builder, tuple, "Duration2", "      - Level", "Time", ServerSkillAttributes.Duration2, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                _expandList(builder, tuple, "Cooldown", "      - Level", "Time", ServerSkillAttributes.Cooldown, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                _expandList(builder, tuple, "FixedCastTime", "      - Level", "Time", ServerSkillAttributes.FixedCastTime, YamlParser.Indent4, YamlParser.Indent8, "0", itemDb);
                DbIOUtils.ExpandFlag <CastingFlags>(builder, tuple, "CastTimeFlags", ServerSkillAttributes.CastTimeFlags, YamlParser.Indent4, YamlParser.Indent6);
                DbIOUtils.ExpandFlag <CastingFlags>(builder, tuple, "CastDelayFlags", ServerSkillAttributes.CastDelayFlags, YamlParser.Indent4, YamlParser.Indent6);

                StringBuilder require = new StringBuilder();
                _expandList(require, tuple, "HpCost", "        - Level", "Amount", ServerSkillAttributes.RequireHpCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);
                _expandList(require, tuple, "SpCost", "        - Level", "Amount", ServerSkillAttributes.RequireSpCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);
                _expandList(require, tuple, "HpRateCost", "        - Level", "Amount", ServerSkillAttributes.RequireHpRateCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);
                _expandList(require, tuple, "SpRateCost", "        - Level", "Amount", ServerSkillAttributes.RequireSpRateCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);
                _expandList(require, tuple, "MaxHpTrigger", "        - Level", "Amount", ServerSkillAttributes.RequireMaxHpTrigger, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);
                _expandList(require, tuple, "ZenyCost", "        - Level", "Amount", ServerSkillAttributes.RequireZenyCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);

                value = tuple.GetValue <int>(ServerSkillAttributes.RequireWeapons);

                if (value != 0xFFFFFF)
                {
                    DbIOUtils.ExpandFlag <WeaponType>(require, tuple, "Weapon", ServerSkillAttributes.RequireWeapons, YamlParser.Indent6, YamlParser.Indent8);
                }

                DbIOUtils.ExpandFlag <AmmoType>(require, tuple, "Ammo", ServerSkillAttributes.RequireAmmoTypes, YamlParser.Indent6, YamlParser.Indent8);
                _expandList(require, tuple, "AmmoAmount", "        - Level", "Amount", ServerSkillAttributes.RequireAmmoAmount, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);

                if ((value = tuple.GetValue <int>(ServerSkillAttributes.RequireState)) > 0)
                {
                    valueS = "";

                    switch ((RequiredStateTypeNew)value)
                    {
                    case RequiredStateTypeNew.Hidden:
                        valueS = "Hidden";
                        break;

                    case RequiredStateTypeNew.Riding:
                        valueS = "Riding";
                        break;

                    case RequiredStateTypeNew.Falcon:
                        valueS = "Falcon";
                        break;

                    case RequiredStateTypeNew.Cart:
                        valueS = "Cart";
                        break;

                    case RequiredStateTypeNew.Shield:
                        valueS = "Shield";
                        break;

                    case RequiredStateTypeNew.RecoverWeightRate:
                        valueS = "Recover_Weight_Rate";
                        break;

                    case RequiredStateTypeNew.MoveEnable:
                        valueS = "Move_Enable";
                        break;

                    case RequiredStateTypeNew.Water:
                        valueS = "Water";
                        break;

                    case RequiredStateTypeNew.RidingDragon:
                        valueS = "Ridingdragon";
                        break;

                    case RequiredStateTypeNew.Warg:
                        valueS = "Wug";
                        break;

                    case RequiredStateTypeNew.Ridingwarg:
                        valueS = "Ridingwug";
                        break;

                    case RequiredStateTypeNew.Mado:
                        valueS = "Mado";
                        break;

                    case RequiredStateTypeNew.Elementalspirit:
                        valueS = "Elementalspirit";
                        break;

                    case RequiredStateTypeNew.Elementalspirit2:
                        valueS = "Elementalspirit2";
                        break;

                    case RequiredStateTypeNew.RidingPeco:
                        valueS = "Peco";
                        break;

                    case RequiredStateTypeNew.SunStance:
                        valueS = "Sunstance";
                        break;

                    case RequiredStateTypeNew.MoonStance:
                        valueS = "Moonstance";
                        break;

                    case RequiredStateTypeNew.StarsStance:
                        valueS = "Starstance";
                        break;

                    case RequiredStateTypeNew.UniverseStance:
                        valueS = "Universestance";
                        break;

                    default:
                        valueS = "";
                        break;
                    }

                    require.Append("      State: ");
                    require.AppendLine(valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.RequireStatuses)) != "" && valueS != "0")
                {
                    var data = valueS.Split(':');

                    if (data.Length > 0)
                    {
                        require.AppendLine("      Status:");

                        foreach (var da in data)
                        {
                            require.Append("        ");
                            require.Append(da);
                            require.AppendLine(": true");
                        }
                    }
                }

                //_DbIOUtils.ExpandFlag<AmmoType>(require, tuple, "Status", ServerSkillAttributes.RequireStatuses, YamlParser2.Indent6, YamlParser2.Indent8);
                _expandList(require, tuple, "SpiritSphereCost", "        - Level", "Amount", ServerSkillAttributes.RequireSpiritSphereCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);
                _expandList(require, tuple, "ItemCost", "        - Item", "Amount", ServerSkillAttributes.RequireItemCost, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);

                if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.RequiredEquipment)) != "" && valueS != "0")
                {
                    var data = valueS.Split(':');

                    require.AppendLine("      Equipment:");

                    foreach (var item in data)
                    {
                        require.Append("        ");
                        require.Append(DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, item));
                        require.AppendLine(": true");
                    }
                }
                //_expandList(require, tuple, "Equipment", "", "", ServerSkillAttributes.RequiredEquipment, YamlParser2.Indent6, YamlParser2.Indent8, "", itemDb);

                string requireData = require.ToString();

                if (requireData != "")
                {
                    builder.AppendLine("    Requires:");
                    builder.Append(requireData);
                }

                StringBuilder unit = new StringBuilder();

                if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.UnitId)) != "" && valueS != "0")
                {
                    unit.Append("      Id: ");
                    unit.AppendLine(valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerSkillAttributes.UnitAlternateId)) != "" && valueS != "0")
                {
                    unit.Append("      AlternateId: ");
                    unit.AppendLine(valueS);
                }

                _expandList(unit, tuple, "Layout", "        - Level", "Size", ServerSkillAttributes.UnitLayout, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);
                _expandList(unit, tuple, "Range", "        - Level", "Size", ServerSkillAttributes.UnitRange, YamlParser.Indent6, YamlParser.Indent10, "0", itemDb);

                if ((value = tuple.GetValue <int>(ServerSkillAttributes.UnitInterval)) != 0)
                {
                    unit.Append("      Interval: ");
                    unit.AppendLine(value.ToString(CultureInfo.InvariantCulture));
                }

                if ((value = tuple.GetValue <int>(ServerSkillAttributes.UnitTarget)) != 0x3F0000)
                {
                    unit.Append("      Target: ");

                    var flag = FlagsManager.GetFlag <UnitTargetType>();
                    valueS = flag.Value2Name[value];
                    unit.AppendLine(valueS);
                }

                DbIOUtils.ExpandFlag <UnitFlagType>(unit, tuple, "Flag", ServerSkillAttributes.UnitFlag, YamlParser.Indent6, YamlParser.Indent8);

                string unitData = unit.ToString();

                if (unitData != "")
                {
                    builder.AppendLine("    Unit:");
                    builder.Append(unit);
                }
            }
        }
Exemple #9
0
        public static void WriteEntryYaml <TKey>(StringBuilder builder, ReadableTuple <TKey> tuple, MetaTable <int> itemDb, MetaTable <int> mobDb)
        {
            if (tuple != null)
            {
                string valueS;
                int    value;

                builder.AppendLine("  - Id: " + tuple.GetKey <int>());

                if ((valueS = tuple.GetValue <string>(ServerQuestsAttributes.QuestTitle)) != "" && valueS != "0")
                {
                    builder.AppendLine("    Title: " + DbIOUtils.QuoteCheck(valueS));
                }

                if ((valueS = tuple.GetValue <string>(ServerQuestsAttributes.TimeLimitNew)) != "" && valueS != "0")
                {
                    builder.AppendLine("    TimeLimit: " + valueS);
                }

                if (tuple.GetValue <int>(ServerQuestsAttributes.TargetId1) > 0 || tuple.GetValue <int>(ServerQuestsAttributes.TargetId2) > 0 || tuple.GetValue <int>(ServerQuestsAttributes.TargetId3) > 0)
                {
                    builder.AppendLine("    Targets:");

                    for (int i = 0; i < 3; i++)
                    {
                        if ((valueS = tuple.GetValue <string>(ServerQuestsAttributes.TargetId1.Index + 2 * i)) != "" && valueS != "0")
                        {
                            builder.AppendLine("      - Mob: " + DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, valueS));

                            if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Val1.Index + 2 * i)) != 0)
                            {
                                builder.AppendLine("        Count: " + value);
                            }

                            if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Id1.Index + i)) != 0)
                            {
                                builder.AppendLine("        Id: " + value);
                            }

                            if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Race1.Index + i)) != 0)
                            {
                                builder.AppendLine("        Race: " + Constants.ToString <QuestRaceType>(value));
                            }

                            if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Size1.Index + i)) != 0)
                            {
                                builder.AppendLine("        Size: " + Constants.ToString <QuestSizeType>(value));
                            }

                            if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Element1.Index + i)) != 0)
                            {
                                builder.AppendLine("        Element: " + Constants.ToString <QuestElementType>(value));
                            }

                            if ((value = tuple.GetValue <int>(ServerQuestsAttributes.MinLevel1.Index + i)) != 0)
                            {
                                builder.AppendLine("        MinLevel: " + value);
                            }

                            if ((value = tuple.GetValue <int>(ServerQuestsAttributes.MaxLevel1.Index + i)) != 0)
                            {
                                builder.AppendLine("        MaxLevel: " + value);
                            }
                        }
                    }
                }

                if (tuple.GetValue <int>(ServerQuestsAttributes.NameId1) > 0 || tuple.GetValue <int>(ServerQuestsAttributes.NameId2) > 0 || tuple.GetValue <int>(ServerQuestsAttributes.NameId3) > 0)
                {
                    builder.AppendLine("    Drops:");

                    for (int i = 0; i < 3; i++)
                    {
                        if ((valueS = tuple.GetValue <string>(ServerQuestsAttributes.MobId1.Index + 3 * i)) != "" && valueS != "0")
                        {
                            builder.AppendLine("      - Mob: " + DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, valueS));

                            builder.AppendLine("        Item: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, tuple.GetValue <string>(ServerQuestsAttributes.NameId1.Index + 3 * i)));
                            builder.AppendLine("        Rate: " + tuple.GetValue <string>(ServerQuestsAttributes.Rate1.Index + 3 * i));

                            if ((value = tuple.GetValue <int>(ServerQuestsAttributes.Count1.Index + i)) != 1)
                            {
                                builder.AppendLine("        Count: " + value);
                            }
                        }
                    }
                }
            }
        }
Exemple #10
0
        public static void Loader <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> 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 quest in ele.Output["copy_paste"] ?? ele.Output["Body"])
                {
                    try {
                        int  id      = Int32.Parse(quest["Id"]);
                        TKey questId = (TKey)(object)id;

                        table.SetRaw(questId, ServerQuestsAttributes.QuestTitle, "\"" + (quest["Title"] ?? "").Trim('\"') + "\"");
                        table.SetRaw(questId, ServerQuestsAttributes.TimeLimitNew, (quest["TimeLimit"] ?? ""));

                        var targets = quest["Targets"] as ParserList;

                        if (targets != null)
                        {
                            int count = 0;

                            foreach (var target in targets)
                            {
                                if (count >= 3)
                                {
                                    debug.ReportIdExceptionWithError("The maximum amount of targets has been reached (up to 3).", id, targets.Line);
                                    continue;
                                }

                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.TargetId1.Index + 2 * count], DbIOUtils.Name2Id(mobDb, ServerMobAttributes.AegisName, target["Mob"] ?? "", "mob_db", true));
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.Val1.Index + 2 * count], target["Count"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.Id1.Index + count], target["Id"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.Race1.Index + count], target["Race"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.Size1.Index + count], target["Size"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.Element1.Index + count], target["Element"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.MinLevel1.Index + count], target["MinLevel"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.MaxLevel1.Index + count], target["MaxLevel"] ?? "0");
                                count++;
                            }
                        }

                        var drops = quest["Drops"] as ParserList;

                        if (drops != null)
                        {
                            int count = 0;

                            foreach (var drop in drops)
                            {
                                if (count >= 3)
                                {
                                    debug.ReportIdExceptionWithError("The maximum amount of drops has been reached (up to 3).", id, drops.Line);
                                    continue;
                                }

                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.NameId1.Index + 3 * count], DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, drop["Item"] ?? "", "item_db", true));
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.Rate1.Index + 3 * count], drop["Rate"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.MobId1.Index + 3 * count], DbIOUtils.Name2Id(mobDb, ServerMobAttributes.AegisName, drop["Mob"] ?? "", "mob_db", true));
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.Count1.Index + count], drop["Count"] ?? "1");
                                count++;
                            }
                        }
                    }
                    catch {
                        if (quest["Id"] == null)
                        {
                            if (!debug.ReportIdException("#", quest.Line))
                            {
                                return;
                            }
                        }
                        else if (!debug.ReportIdException(quest["Id"], quest.Line))
                        {
                            return;
                        }
                    }
                }
            }
            else if (debug.FileType == FileType.Txt)
            {
                List <DbAttribute> attributes = new List <DbAttribute>(db.AttributeList.Attributes);

                bool  rAthenaNewFormat = false;
                int[] oldColumns       =
                {
                    0, 1, 2, 3, 4, 5, 6, 7, 17
                };

                foreach (string[] elements in TextFileHelper.GetElementsByCommasQuotes(IOHelper.ReadAllBytes(debug.FilePath)))
                {
                    try {
                        TKey id = (TKey)TypeDescriptor.GetConverter(typeof(TKey)).ConvertFrom(elements[0]);

                        if (elements.Length == 18)
                        {
                            rAthenaNewFormat             = true;
                            db.Attached["rAthenaFormat"] = 18;
                        }

                        if (rAthenaNewFormat)
                        {
                            for (int index = 1; index < elements.Length; index++)
                            {
                                DbAttribute property = attributes[index];
                                db.Table.SetRaw(id, property, elements[index]);
                            }
                        }
                        else
                        {
                            for (int index = 1; index < oldColumns.Length; index++)
                            {
                                DbAttribute property = attributes[oldColumns[index]];
                                db.Table.SetRaw(id, property, elements[index]);
                            }
                        }
                    }
                    catch {
                        if (elements.Length <= 0)
                        {
                            if (!debug.ReportIdException("#"))
                            {
                                return;
                            }
                        }
                        else if (!debug.ReportIdException(elements[0]))
                        {
                            return;
                        }
                    }
                }
            }
            else if (debug.FileType == FileType.Conf)
            {
                var ele   = new LibconfigParser(debug.FilePath);
                var table = debug.AbsractDb.Table;

                foreach (var quest in ele.Output["copy_paste"] ?? ele.Output["quest_db"])
                {
                    try {
                        int  id      = Int32.Parse(quest["Id"]);
                        TKey questId = (TKey)(object)id;

                        table.SetRaw(questId, ServerQuestsAttributes.QuestTitle, "\"" + (quest["Name"] ?? "") + "\"");
                        table.SetRaw(questId, ServerQuestsAttributes.TimeLimit, (quest["TimeLimit"] ?? "0"));

                        var targets = quest["Targets"] as ParserList;

                        if (targets != null)
                        {
                            int count = 0;

                            foreach (var target in targets)
                            {
                                if (count >= 3)
                                {
                                    debug.ReportIdExceptionWithError("The maximum amount of targets has been reached (up to 3).", id, targets.Line);
                                    continue;
                                }

                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.TargetId1.Index + 2 * count], target["MobId"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.Val1.Index + 2 * count], target["Count"] ?? "0");
                                count++;
                            }
                        }

                        var drops = quest["Drops"] as ParserList;

                        if (drops != null)
                        {
                            int count = 0;

                            foreach (var drop in drops)
                            {
                                if (count >= 3)
                                {
                                    debug.ReportIdExceptionWithError("The maximum amount of drops has been reached (up to 3).", id, drops.Line);
                                    continue;
                                }

                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.NameId1.Index + 3 * count], drop["ItemId"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.Rate1.Index + 3 * count], drop["Rate"] ?? "0");
                                table.SetRaw(questId, ServerQuestsAttributes.AttributeList[ServerQuestsAttributes.MobId1.Index + 3 * count], drop["MobId"] ?? "0");
                                count++;
                            }
                        }
                    }
                    catch {
                        if (quest["Id"] == null)
                        {
                            if (!debug.ReportIdException("#", quest.Line))
                            {
                                return;
                            }
                        }
                        else if (!debug.ReportIdException(quest["Id"], quest.Line))
                        {
                            return;
                        }
                    }
                }
            }
        }
Exemple #11
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
            }
        }
Exemple #12
0
        public static void WriteEntryYaml(StringBuilder builder, ReadableTuple <int> tuple, MetaTable <int> itemDb, MetaTable <int> mobDb)
        {
            if (tuple != null)
            {
                string valueS;
                bool   valueB;

                builder.AppendLine("  - Mob: " + DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture)));

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.LureId)) != "" && valueS != "0")
                {
                    builder.AppendLine("    TameItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS));
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.EggId)) != "" && valueS != "0")
                {
                    builder.AppendLine("    EggItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS));
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.EquipId)) != "" && valueS != "0")
                {
                    builder.AppendLine("    EquipItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS));
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.FoodId)) != "" && valueS != "0")
                {
                    builder.AppendLine("    FoodItem: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS));
                }

                builder.AppendLine("    Fullness: " + tuple.GetValue <int>(ServerPetAttributes.Fullness));

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.HungryDelay)) != "60")
                {
                    builder.AppendLine("    HungryDelay: " + valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.HungerIncrease)) != "20")
                {
                    builder.AppendLine("    HungerIncrease: " + valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyStart)) != "250")
                {
                    builder.AppendLine("    IntimacyStart: " + valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyFed)) != "50")
                {
                    builder.AppendLine("    IntimacyFed: " + valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyOverfed)) != "-100")
                {
                    builder.AppendLine("    IntimacyOverfed: " + valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyHungry)) != "-5")
                {
                    builder.AppendLine("    IntimacyHungry: " + valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.IntimacyOwnerDie)) != "-20")
                {
                    builder.AppendLine("    IntimacyOwnerDie: " + valueS);
                }

                builder.AppendLine("    CaptureRate: " + tuple.GetValue <int>(ServerPetAttributes.CaptureRate));

                if ((valueB = tuple.GetValue <bool>(ServerPetAttributes.SpecialPerformance)) == false)
                {
                    builder.AppendLine("    SpecialPerformance: false");
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.AttackRate)) != "" && valueS != "0")
                {
                    builder.AppendLine("    AttackRate: " + valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.RetaliateRate)) != "" && valueS != "0")
                {
                    builder.AppendLine("    RetaliateRate: " + valueS);
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.ChangeTargetRate)) != "" && valueS != "0")
                {
                    builder.AppendLine("    ChangeTargetRate: " + valueS);
                }

                if ((valueB = tuple.GetValue <bool>(ServerPetAttributes.AllowAutoFeed)) == true)
                {
                    builder.AppendLine("    AllowAutoFeed: true");
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.LoyalScript)) != "" && valueS != "{}")
                {
                    builder.AppendLine("    Script: >");
                    builder.AppendLine(DbIOFormatting.ScriptFormatYaml(valueS, "      "));
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.PetScript)) != "" && valueS != "{}")
                {
                    builder.AppendLine("    SupportScript: >");
                    builder.AppendLine(DbIOFormatting.ScriptFormatYaml(valueS, "      "));
                }

                if ((valueS = tuple.GetValue <string>(ServerPetAttributes.Evolution)) != "" && valueS != "0")
                {
                    builder.AppendLine("    Evolution:");
                    Evolution evolution = new Evolution(valueS);

                    foreach (var evo in evolution.Targets)
                    {
                        builder.Append("      - Target: ");
                        builder.AppendLine(DbIOUtils.Id2Name(mobDb, ServerMobAttributes.AegisName, evo.Target));

                        if (evo.ItemRequirements.Count > 0)
                        {
                            builder.AppendLine("        ItemRequirements:");

                            foreach (var item in evo.ItemRequirements)
                            {
                                builder.Append("          - Item: ");
                                builder.AppendLine(DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, item.Item1.ToString()));
                                builder.Append("            Amount: ");
                                builder.AppendLine(item.Item2.ToString(CultureInfo.InvariantCulture));
                            }
                        }
                    }
                }
            }
        }
Exemple #13
0
        public static void Loader <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> 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);

                var stateFlags = new Dictionary <string, long>();
                stateFlags["none"]   = 0;
                stateFlags["hidden"] = 1;
                stateFlags["riding"] = 2;
                stateFlags["falcon"] = 3;
                stateFlags["cart"]   = 4;
                stateFlags["shield"] = 5;
                stateFlags["recover_weight_rate"] = 6;
                stateFlags["move_enable"]         = 7;
                stateFlags["water"]            = 8;
                stateFlags["ridingdragon"]     = 9;
                stateFlags["wug"]              = 10;
                stateFlags["ridingwug"]        = 11;
                stateFlags["mado"]             = 12;
                stateFlags["elementalspirit"]  = 13;
                stateFlags["elementalspirit2"] = 14;
                stateFlags["peco"]             = 15;
                stateFlags["sunstance"]        = 16;
                stateFlags["moonstance"]       = 17;
                stateFlags["starstance"]       = 18;
                stateFlags["universestance"]   = 19;

                foreach (var skill in ele.Output["copy_paste"] ?? ele.Output["Body"])
                {
                    try {
                        int  id      = Int32.Parse(skill["Id"]);
                        TKey skillId = (TKey)(object)id;

                        table.SetRaw(skillId, ServerSkillAttributes.Name, skill["Name"] ?? "");
                        table.SetRaw(skillId, ServerSkillAttributes.Desc, skill["Description"] ?? "");
                        table.SetRaw(skillId, ServerSkillAttributes.MaxLevel, skill["MaxLevel"] ?? "1");
                        table.SetRaw(skillId, ServerSkillAttributes.AttackType, Constants.Parse2DbString <AttackTypeType>(skill["Type"] ?? "None"));
                        table.SetRaw(skillId, ServerSkillAttributes.SkillTargetType, Constants.Parse2DbString <SkillTargetType>(skill["TargetType"] ?? "0"));
                        table.SetRaw(skillId, ServerSkillAttributes.DamageFlags, DbIOUtils.LoadFlag <SkillDamageType>(skill["DamageFlags"], "0"));
                        table.SetRaw(skillId, ServerSkillAttributes.Inf2New, DbIOUtils.LoadFlag <SkillType2TypeNew>(skill["Flags"], "0"));
                        table.SetRaw(skillId, ServerSkillAttributes.Range, _loadListToString(skill["Range"], "Level", "Size"));
                        table.SetRaw(skillId, ServerSkillAttributes.HitMode, Constants.Parse2DbString <HitType>(skill["Hit"] ?? "0"));
                        table.SetRaw(skillId, ServerSkillAttributes.HitCount, _loadListToString(skill["HitCount"], "Level", "Count", "0"));
                        table.SetRaw(skillId, ServerSkillAttributes.SkillElement, _loadListToString(skill["Element"], "Level", "Element", "Neutral"));
                        table.SetRaw(skillId, ServerSkillAttributes.SplashArea, _loadListToString(skill["SplashArea"], "Level", "Area"));
                        table.SetRaw(skillId, ServerSkillAttributes.ActiveInstance, _loadListToString(skill["ActiveInstance"], "Level", "Max"));
                        table.SetRaw(skillId, ServerSkillAttributes.Knockback, _loadListToString(skill["Knockback"], "Level", "Amount"));

                        if (skill["CopyFlags"] != null)
                        {
                            var entry = skill["CopyFlags"];

                            table.SetRaw(skillId, ServerSkillAttributes.CopyFlags, DbIOUtils.LoadFlag <SkillCopyType>(entry["Skill"], "0"));
                            table.SetRaw(skillId, ServerSkillAttributes.CopyFlagsRemovedRequirement, DbIOUtils.LoadFlag <SkillCopyRemoveRequirementType>(entry["RemoveRequirement"], "0"));
                        }

                        if (skill["NoNearNPC"] != null)
                        {
                            var entry = skill["NoNearNPC"];

                            table.SetRaw(skillId, ServerSkillAttributes.NoNearNPCRange, entry["AdditionalRange"] ?? "0");
                            table.SetRaw(skillId, ServerSkillAttributes.NoNearNPCType, DbIOUtils.LoadFlag <NoNearNpcType>(entry["Type"], "0"));
                        }

                        table.SetRaw(skillId, ServerSkillAttributes.CastInterrupt, skill["CastCancel"] ?? "false");
                        table.SetRaw(skillId, ServerSkillAttributes.CastDefenseReduction, skill["CastDefenseReduction"] ?? "0");
                        table.SetRaw(skillId, ServerSkillAttributes.CastingTime, _loadListToString(skill["CastTime"], "Level", "Time"));
                        table.SetRaw(skillId, ServerSkillAttributes.AfterCastActDelay, _loadListToString(skill["AfterCastActDelay"], "Level", "Time"));
                        table.SetRaw(skillId, ServerSkillAttributes.AfterCastWalkDelay, _loadListToString(skill["AfterCastWalkDelay"], "Level", "Time"));
                        table.SetRaw(skillId, ServerSkillAttributes.Duration1, _loadListToString(skill["Duration1"], "Level", "Time"));
                        table.SetRaw(skillId, ServerSkillAttributes.Duration2, _loadListToString(skill["Duration2"], "Level", "Time"));
                        table.SetRaw(skillId, ServerSkillAttributes.Cooldown, _loadListToString(skill["Cooldown"], "Level", "Time"));
                        table.SetRaw(skillId, ServerSkillAttributes.FixedCastTime, _loadListToString(skill["FixedCastTime"], "Level", "Time"));
                        table.SetRaw(skillId, ServerSkillAttributes.CastTimeFlags, DbIOUtils.LoadFlag <CastingFlags>(skill["CastTimeFlags"], "0"));
                        table.SetRaw(skillId, ServerSkillAttributes.CastDelayFlags, DbIOUtils.LoadFlag <CastingFlags>(skill["CastDelayFlags"], "0"));

                        if (skill["Requires"] != null)
                        {
                            var entry = skill["Requires"];

                            table.SetRaw(skillId, ServerSkillAttributes.RequireHpCost, _loadListToString(entry["HpCost"], "Level", "Amount"));
                            table.SetRaw(skillId, ServerSkillAttributes.RequireSpCost, _loadListToString(entry["SpCost"], "Level", "Amount"));
                            table.SetRaw(skillId, ServerSkillAttributes.RequireHpRateCost, _loadListToString(entry["HpRateCost"], "Level", "Amount"));
                            table.SetRaw(skillId, ServerSkillAttributes.RequireSpRateCost, _loadListToString(entry["SpRateCost"], "Level", "Amount"));
                            table.SetRaw(skillId, ServerSkillAttributes.RequireMaxHpTrigger, _loadListToString(entry["MaxHpTrigger"], "Level", "Amount"));
                            table.SetRaw(skillId, ServerSkillAttributes.RequireZenyCost, _loadListToString(entry["ZenyCost"], "Level", "Amount"));
                            table.SetRaw(skillId, ServerSkillAttributes.RequireWeapons, DbIOUtils.LoadFlag <WeaponType>(entry["Weapon"], "0xFFFFFF"));
                            table.SetRaw(skillId, ServerSkillAttributes.RequireAmmoTypes, DbIOUtils.LoadFlag <AmmoType>(entry["Ammo"], "0"));
                            table.SetRaw(skillId, ServerSkillAttributes.RequireAmmoAmount, entry["AmmoAmount"] ?? "0");
                            table.SetRaw(skillId, ServerSkillAttributes.RequireState, DbIOUtils.LoadFlag(entry["State"], stateFlags, "0"));

                            if (entry["Status"] != null)
                            {
                                table.SetRaw(skillId, ServerSkillAttributes.RequireStatuses, Methods.Aggregate(entry["Status"].OfType <ParserKeyValue>().Select(p => p.Key).ToList(), ":"));
                            }
                            else
                            {
                                table.SetRaw(skillId, ServerSkillAttributes.RequireStatuses, "");
                            }

                            table.SetRaw(skillId, ServerSkillAttributes.RequireSpiritSphereCost, _loadListToString(entry["SpiritSphereCost"], "Level", "Amount"));

                            if (entry["ItemCost"] != null)
                            {
                                StringBuilder b        = new StringBuilder();
                                var           itemList = entry["ItemCost"];

                                foreach (var item in itemList)
                                {
                                    string key   = item["Item"];
                                    int    value = Int32.Parse(item["Amount"]);

                                    key = DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, key, "item_db", true).ToString();
                                    b.Append(key);
                                    b.Append(":");
                                    b.Append(value);
                                    b.Append(":");
                                }

                                table.SetRaw(skillId, ServerSkillAttributes.RequireItemCost, b.ToString().Trim(':'));
                            }

                            if (entry["Equipment"] != null)
                            {
                                StringBuilder b        = new StringBuilder();
                                var           itemList = entry["Equipment"];

                                foreach (var item in itemList.OfType <ParserKeyValue>())
                                {
                                    string key = item.Key;

                                    key = DbIOUtils.Name2Id(itemDb, ServerItemAttributes.AegisName, key, "item_db", true).ToString();
                                    b.Append(key);
                                    b.Append(":");
                                }

                                table.SetRaw(skillId, ServerSkillAttributes.RequiredEquipment, b.ToString().Trim(':'));
                            }
                        }

                        if (skill["Unit"] != null)
                        {
                            var entry = skill["Unit"];

                            table.SetRaw(skillId, ServerSkillAttributes.UnitId, entry["Id"] ?? "");
                            table.SetRaw(skillId, ServerSkillAttributes.UnitAlternateId, entry["AlternateId"] ?? "");
                            table.SetRaw(skillId, ServerSkillAttributes.UnitLayout, _loadListToString(entry["Layout"], "Level", "Size"));
                            table.SetRaw(skillId, ServerSkillAttributes.UnitRange, _loadListToString(entry["Range"], "Level", "Size"));
                            table.SetRaw(skillId, ServerSkillAttributes.UnitInterval, entry["Interval"] ?? "0");
                            table.SetRaw(skillId, ServerSkillAttributes.UnitTarget, DbIOUtils.LoadFlag <UnitTargetType>(entry["Target"], "0x3F0000"));
                            table.SetRaw(skillId, ServerSkillAttributes.UnitFlag, DbIOUtils.LoadFlag <UnitFlagType>(entry["Flag"], "0"));
                        }
                    }
                    catch (FileParserException fpe) {
                        debug.ReportIdException(fpe, skill["Id"]);
                    }
                    catch {
                        if (skill["Id"] == null)
                        {
                            if (!debug.ReportIdException("#", skill.Line))
                            {
                                return;
                            }
                        }
                        else if (!debug.ReportIdException(skill["Id"], skill.Line))
                        {
                            return;
                        }
                    }
                }
            }
        }
Exemple #14
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();
                }
            }
        }
Exemple #15
0
        public static void Writer <TKey>(DbDebugItem <TKey> debug, AbstractDb <TKey> db)
        {
            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, "Id");

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

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

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

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

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
            else if (debug.FileType == FileType.Conf)
            {
                try {
                    var lines = new LibconfigParser(debug.OldPath, ParserMode.Write);
                    lines.Remove(db);
                    string line;

                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                    {
                        int           key     = tuple.GetKey <int>();
                        StringBuilder builder = new StringBuilder();
                        WriteEntry(builder, tuple);
                        line = builder.ToString();
                        lines.Write(key.ToString(CultureInfo.InvariantCulture), line);
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
            else
            {
                int format = db.GetAttacked <int>("rAthenaFormat");

                try {
                    IntLineStream lines = new IntLineStream(debug.OldPath);
                    lines.Remove(db);
                    string line;

                    foreach (ReadableTuple <TKey> tuple in db.Table.FastItems.Where(p => !p.Normal).OrderBy(p => p.GetKey <TKey>()))
                    {
                        int key = tuple.GetKey <int>();

                        if (format == 18)
                        {
                            line = string.Join(",", tuple.GetRawElements().Take(18).Select(p => (p ?? "").ToString()).ToArray());
                        }
                        else
                        {
                            line = string.Join(",", tuple.GetRawElements().Take(ServerQuestsAttributes.MobId1.Index).Concat(new object[] { tuple.GetRawValue(ServerQuestsAttributes.QuestTitle.Index) }).Select(p => (p ?? "").ToString()).ToArray());
                        }

                        lines.Write(key, line);
                    }

                    lines.WriteFile(debug.FilePath);
                }
                catch (Exception err) {
                    debug.ReportException(err);
                }
            }
        }
Exemple #16
0
        public static void WriteEntryYaml(StringBuilder builder, ReadableTuple <int> tuple, MetaTable <int> itemDb)
        {
            if (tuple != null)
            {
                builder.AppendLine("  - Id: " + tuple.GetKey <int>().ToString(CultureInfo.InvariantCulture));
                builder.AppendLine("    AegisName: " + tuple.GetValue <string>(ServerMobAttributes.AegisName));
                builder.AppendLine("    Name: " + DbIOUtils.QuoteCheck(tuple.GetValue <string>(ServerMobAttributes.IRoName)));

                if (tuple.GetValue <string>(ServerMobAttributes.IRoName) != tuple.GetValue <string>(ServerMobAttributes.KRoName))
                {
                    builder.AppendLine("    JapaneseName: " + DbIOUtils.QuoteCheck(tuple.GetValue <string>(ServerMobAttributes.KRoName)));
                }

                int value;
                //bool valueB;
                string valueS;
                //int type = 0;

                builder.AppendLine("    Level: " + tuple.GetValue <int>(ServerMobAttributes.Lv));

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Hp)) != 1)
                {
                    builder.AppendLine("    Hp: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Sp)) != 1)
                {
                    builder.AppendLine("    Sp: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Exp)) != 0)
                {
                    builder.AppendLine("    BaseExp: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.JExp)) != 0)
                {
                    builder.AppendLine("    JobExp: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.MvpExp)) != 0)
                {
                    builder.AppendLine("    MvpExp: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Atk1)) != 0)
                {
                    builder.AppendLine("    Attack: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Atk2)) != 0)
                {
                    builder.AppendLine("    Attack2: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Def)) != 0)
                {
                    builder.AppendLine("    Defense: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Mdef)) != 0)
                {
                    builder.AppendLine("    MagicDefense: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Str)) != 1)
                {
                    builder.AppendLine("    Str: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Agi)) != 1)
                {
                    builder.AppendLine("    Agi: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Vit)) != 1)
                {
                    builder.AppendLine("    Vit: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Int)) != 1)
                {
                    builder.AppendLine("    Int: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Dex)) != 1)
                {
                    builder.AppendLine("    Dex: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Luk)) != 1)
                {
                    builder.AppendLine("    Luk: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.AttackRange)) != 0)
                {
                    builder.AppendLine("    AttackRange: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.ViewRange)) != 0)
                {
                    builder.AppendLine("    SkillRange: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.ChaseRange)) != 0)
                {
                    builder.AppendLine("    ChaseRange: " + value);
                }

                //if ((value = tuple.GetValue<int>(ServerMobAttributes.Size)) != 0) {
                builder.AppendLine("    Size: " + Constants.ToString <SizeType>(tuple.GetValue <int>(ServerMobAttributes.Size)));
                //}

                builder.AppendLine("    Race: " + Constants.ToString <MobRaceType>(tuple.GetValue <int>(ServerMobAttributes.Race)));

                DbIOUtils.ExpandFlag <MobGroup2Type>(builder, tuple, "RaceGroups", ServerMobAttributes.RaceGroups, YamlParser.Indent4, YamlParser.Indent6);

                int elementLevel = tuple.GetValue <int>(ServerMobAttributes.Element) / 20;
                int element      = tuple.GetValue <int>(ServerMobAttributes.Element) % 20;

                switch (element)
                {
                case 0: builder.AppendLine("    Element: Neutral"); break;

                case 1: builder.AppendLine("    Element: Water"); break;

                case 2: builder.AppendLine("    Element: Earth"); break;

                case 3: builder.AppendLine("    Element: Fire"); break;

                case 4: builder.AppendLine("    Element: Wind"); break;

                case 5: builder.AppendLine("    Element: Poison"); break;

                case 6: builder.AppendLine("    Element: Holy"); break;

                case 7: builder.AppendLine("    Element: Dark"); break;

                case 8: builder.AppendLine("    Element: Ghost"); break;

                case 9: builder.AppendLine("    Element: Undead"); break;
                }

                builder.AppendLine("    ElementLevel: " + elementLevel);

                if ((value = tuple.GetValue <int>(ServerMobAttributes.MoveSpeed)) != 0)
                {
                    builder.AppendLine("    WalkSpeed: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.AttackDelay)) != 0)
                {
                    builder.AppendLine("    AttackDelay: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.AttackMotion)) != 0)
                {
                    builder.AppendLine("    AttackMotion: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.DamageMotion)) != 0)
                {
                    builder.AppendLine("    DamageMotion: " + value);
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.DamageTaken)) != 100)
                {
                    builder.AppendLine("    DamageTaken: " + value);
                }

                long mode = FormatConverters.LongOrHexConverter(tuple.GetValue <string>(ServerMobAttributes.NewMode));

                if ((mode & 0xB695) == 0xB695)
                {
                    builder.AppendLine("    Ai: 26");
                    mode &= ~0xB695;
                }
                else if ((mode & 0x8084) == 0x8084)
                {
                    builder.AppendLine("    Ai: 27");
                    mode &= ~0x8084;
                }
                else if ((mode & 0x7085) == 0x7085)
                {
                    builder.AppendLine("    Ai: 08");
                    mode &= ~0x7085;
                }
                else if ((mode & 0x3885) == 0x3885)
                {
                    builder.AppendLine("    Ai: 04");
                    mode &= ~0x3885;
                }
                else if ((mode & 0x3695) == 0x3695)
                {
                    builder.AppendLine("    Ai: 21");
                    mode &= ~0x3695;
                }
                else if ((mode & 0x3295) == 0x3295)
                {
                    builder.AppendLine("    Ai: 20");
                    mode &= ~0x3295;
                }
                else if ((mode & 0x3095) == 0x3095)
                {
                    builder.AppendLine("    Ai: 09");
                    mode &= ~0x3095;
                }
                else if ((mode & 0x308D) == 0x308D)
                {
                    builder.AppendLine("    Ai: 13");
                    mode &= ~0x308D;
                }
                else if ((mode & 0x2085) == 0x2085)
                {
                    builder.AppendLine("    Ai: 05");
                    mode &= ~0x2085;
                }
                else if ((mode & 0x108B) == 0x108B)
                {
                    builder.AppendLine("    Ai: 07");
                    mode &= ~0x108B;
                }
                else if ((mode & 0x1089) == 0x1089)
                {
                    builder.AppendLine("    Ai: 03");
                    mode &= ~0x1089;
                }
                else if ((mode & 0xA1) == 0xA1)
                {
                    builder.AppendLine("    Ai: 24");
                    mode &= ~0xA1;
                }
                else if ((mode & 0x91) == 0x91)
                {
                    builder.AppendLine("    Ai: 17");
                    mode &= ~0x91;
                }
                else if ((mode & 0x84) == 0x84)
                {
                    builder.AppendLine("    Ai: 10");
                    mode &= ~0x84;
                }
                else if ((mode & 0x83) == 0x83)
                {
                    builder.AppendLine("    Ai: 02");
                    mode &= ~0x83;
                }
                else if ((mode & 0x81) == 0x81)
                {
                    builder.AppendLine("    Ai: 01");
                    mode &= ~0x81;
                }
                else if ((mode & 0x1) == 0x1)
                {
                    builder.AppendLine("    Ai: 25");
                    mode &= ~0x1;
                }

                if ((value = tuple.GetValue <int>(ServerMobAttributes.Class)) != 0)
                {
                    builder.AppendLine("    Class: " + Constants.ToString <ClassType>(value));
                }

                if (mode > 0)
                {
                    builder.AppendLine("    Modes:");
                    if ((mode & 0x1) == 0x1)
                    {
                        builder.AppendLine("      CanMove: true");
                    }
                    if ((mode & 0x80) == 0x80)
                    {
                        builder.AppendLine("      CanAttack: true");
                    }
                    if ((mode & 0x40) == 0x40)
                    {
                        builder.AppendLine("      NoCast: true");
                    }
                    if ((mode & 0x2) == 0x2)
                    {
                        builder.AppendLine("      Looter: true");
                    }
                    if ((mode & 0x4) == 0x4)
                    {
                        builder.AppendLine("      Aggressive: true");
                    }
                    if ((mode & 0x8) == 0x8)
                    {
                        builder.AppendLine("      Assist: true");
                    }
                    if ((mode & 0x20) == 0x20)
                    {
                        builder.AppendLine("      NoRandomWalk: true");
                    }
                    if ((mode & 0x200) == 0x200)
                    {
                        builder.AppendLine("      CastSensorChase: true");
                    }
                    if ((mode & 0x10) == 0x10)
                    {
                        builder.AppendLine("      CastSensorIdle: true");
                    }
                    if ((mode & 0x800) == 0x800)
                    {
                        builder.AppendLine("      Angry: true");
                    }
                    if ((mode & 0x400) == 0x400)
                    {
                        builder.AppendLine("      ChangeChase: true");
                    }
                    if ((mode & 0x1000) == 0x1000)
                    {
                        builder.AppendLine("      ChangeTargetMelee: true");
                    }
                    if ((mode & 0x2000) == 0x2000)
                    {
                        builder.AppendLine("      ChangeTargetChase: true");
                    }
                    if ((mode & 0x4000) == 0x4000)
                    {
                        builder.AppendLine("      TargetWeak: true");
                    }
                    if ((mode & 0x8000) == 0x8000)
                    {
                        builder.AppendLine("      RandomTarget: true");
                    }
                    if ((mode & 0x20000) == 0x20000)
                    {
                        builder.AppendLine("      IgnoreMagic: true");
                    }
                    if ((mode & 0x10000) == 0x10000)
                    {
                        builder.AppendLine("      IgnoreMelee: true");
                    }
                    if ((mode & 0x100000) == 0x100000)
                    {
                        builder.AppendLine("      IgnoreMisc: true");
                    }
                    if ((mode & 0x40000) == 0x40000)
                    {
                        builder.AppendLine("      IgnoreRanged: true");
                    }
                    if ((mode & 0x400000) == 0x400000)
                    {
                        builder.AppendLine("      TeleportBlock: true");
                    }
                    if ((mode & 0x1000000) == 0x1000000)
                    {
                        builder.AppendLine("      FixedItemDrop: true");
                    }
                    if ((mode & 0x2000000) == 0x2000000)
                    {
                        builder.AppendLine("      Detector: true");
                    }
                    if ((mode & 0x200000) == 0x200000)
                    {
                        builder.AppendLine("      KnockBackImmune: true");
                    }
                    if ((mode & 0x4000000) == 0x4000000)
                    {
                        builder.AppendLine("      StatusImmune: true");
                    }
                    if ((mode & 0x8000000) == 0x8000000)
                    {
                        builder.AppendLine("      SkillImmune: true");
                    }
                    if ((mode & 0x80000) == 0x80000)
                    {
                        builder.AppendLine("      Mvp: true");
                    }
                }

                int 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)
                    {
                        valueS = tuple.GetValue <string>(ServerMobAttributes.Mvp1ID.Index + i);

                        if (stat != 0 && valueS != "0" && valueS != "")
                        {
                            builder.AppendLine("      - Item: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS));
                            builder.AppendLine("        Rate: " + tuple.GetValue <int>(ServerMobAttributes.Mvp1ID.Index + i + 1));

                            if ((valueS = tuple.GetValue <string>(ServerMobAttributes.Mvp1RandomOptionGroup.Index + (i / 2))) != "")
                            {
                                builder.AppendLine("        RandomOptionGroup: " + valueS);
                            }
                        }
                    }
                }

                stat = 0;

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

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

                    for (int i = 0; i < 20; i += 2)
                    {
                        valueS = tuple.GetValue <string>(ServerMobAttributes.Drop1ID.Index + i);

                        if (stat != 0 && valueS != "0" && valueS != "")
                        {
                            builder.AppendLine("      - Item: " + DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, valueS));
                            builder.AppendLine("        Rate: " + tuple.GetValue <int>(ServerMobAttributes.Drop1ID.Index + i + 1));

                            if ((valueS = tuple.GetValue <string>(ServerMobAttributes.Drop1Flags.Index + (i / 2))) != "" && valueS != null)
                            {
                                if (FormatConverters.BooleanConverter(valueS))
                                {
                                    builder.AppendLine("        StealProtected: true");
                                }
                            }

                            if ((valueS = tuple.GetValue <string>(ServerMobAttributes.Drop1RandomOptionGroup.Index + (i / 2))) != "")
                            {
                                builder.AppendLine("        RandomOptionGroup: " + valueS);
                            }
                        }
                    }
                }
            }
        }
Exemple #17
0
        private static void _expandList(StringBuilder builder, ReadableTuple <int> tuple, string name, string level, string amount, DbAttribute attribute, string indent1, string indent2, string def, MetaTable <int> itemDb)
        {
            string value = tuple.GetValue <string>(attribute);

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

            string[] data = value.Split(':');
            int      k    = 1;

            if (data.Length == 1)
            {
                builder.Append(indent1);
                builder.Append(name);
                builder.Append(": ");
                builder.AppendLine(data[0]);
                return;
            }

            builder.Append(indent1);
            builder.Append(name);
            builder.AppendLine(":");

            if (attribute == ServerSkillAttributes.RequireItemCost)
            {
                for (int i = 0; i < data.Length; i += 2)
                {
                    builder.Append(level);
                    builder.Append(": ");
                    builder.AppendLine(DbIOUtils.Id2Name(itemDb, ServerItemAttributes.AegisName, data[i]));

                    if (i + 1 < data.Length)
                    {
                        builder.Append(indent2);
                        builder.Append(amount);
                        builder.Append(": ");
                        builder.AppendLine(data[i + 1]);
                    }
                    else
                    {
                        builder.Append(indent2);
                        builder.Append(amount);
                        builder.AppendLine(": 0");
                    }
                }

                return;
            }

            foreach (var field in data)
            {
                if (field == "")
                {
                    k++;
                    continue;
                }

                builder.Append(level);
                builder.Append(": ");
                builder.AppendLine(k.ToString(CultureInfo.InvariantCulture));
                k++;

                builder.Append(indent2);
                builder.Append(amount);
                builder.Append(": ");
                builder.AppendLine(field);
            }
        }