Ejemplo n.º 1
0
 static void CreateItemData(ItemTemplates templates)
 {
     foreach (var it in templates.TemplateList)
     {
         items.Add(it.id, it);
     }
 }
Ejemplo n.º 2
0
        static void CreateItemData(ItemTemplates templates)
        {
            foreach (var it in templates.TemplateList) {
                items.Add(it.id, it);
                if (it.bonus != null) {
                    BonusType bonusType = it.bonus[0].type;

                    Dictionary<int, List<int>> map = null;
                    if (!itemsByBonus.ContainsKey(bonusType)) {
                        map = new Dictionary<int, List<int>>();
                        itemsByBonus.Add(bonusType, map);
                    } else {
                        map = itemsByBonus[bonusType];
                    }

                    string[] bonusLevels = it.bonus[0].bonusLevel.Split(',');
                    for (int i = 0; i < bonusLevels.Length; i++) {
                        int level = Int32.Parse(bonusLevels[i]);
                        List<int> list = null;
                        if (map.ContainsKey(level))
                            list = map[level];
                        else {
                            list = new List<int>();
                            map.Add(level, list);
                        }
                        list.Add(it.id);
                    }
                }
            }
        }
Ejemplo n.º 3
0
        static void CreateItemData(ItemTemplates templates)
        {
            foreach (var it in templates.TemplateList)
            {
                items.Add(it.id, it);
                if (it.bonus != null)
                {
                    BonusType bonusType = it.bonus[0].type;

                    Dictionary <int, List <int> > map = null;
                    if (!itemsByBonus.ContainsKey(bonusType))
                    {
                        map = new Dictionary <int, List <int> >();
                        itemsByBonus.Add(bonusType, map);
                    }
                    else
                    {
                        map = itemsByBonus[bonusType];
                    }

                    string[] bonusLevels = it.bonus[0].bonusLevel.Split(',');
                    for (int i = 0; i < bonusLevels.Length; i++)
                    {
                        int        level = Int32.Parse(bonusLevels[i]);
                        List <int> list  = null;
                        if (map.ContainsKey(level))
                        {
                            list = map[level];
                        }
                        else
                        {
                            list = new List <int>();
                            map.Add(level, list);
                        }
                        list.Add(it.id);
                    }
                }
            }
        }
Ejemplo n.º 4
0
 static void CreateItemData(ItemTemplates templates)
 {
     foreach (var it in templates.TemplateList) {
         items.Add(it.id, it);
     }
 }
Ejemplo n.º 5
0
 public static void TestWorkOrders(ItemTemplates templates)
 {
     CreateItemData(templates);
     SampleWorkOrdersBonuses();
 }
Ejemplo n.º 6
0
        private static void InjectBonusesToItemTemplate(XmlWriterSettings saveSettings, string outputPath)
        {
            try {
                using (var fs = new FileStream(Path.Combine(root, @".\data\item_templates.xml"),
                                               FileMode.Open, FileAccess.Read))
                using (var reader = XmlReader.Create(fs)) {
                    XmlSerializer ser = new XmlSerializer(typeof(ItemTemplates));
                    Utility.OriginalItemTemplate = (ItemTemplates)ser.Deserialize(reader);
                }
            } catch (Exception ex) {
                Debug.Print(ex.ToString());
                return;
            }

            // Utility.CreateSkillMap(root);

            var allItems = itemGroups.grouped.SelectMany(g => g.items).SelectMany(s => s.items)
                                .ToDictionary(i => i.itemId, i => i);

            List<int> splitItems = Utility.ItemIndex.ItemList
                .Where(i => (i.disassembly_item.HasValue && i.disassembly_item.Value) &&
                             i.Category == ItemCategories.harvest).Select(i => i.id).ToList();

            List<int> questStart = Utility.ItemIndex.ItemList
                .Where(i => i.ActivateTarget == ActivateTargets.standalone && i.name.StartsWith("quest_") &&
                       i.quest == 3 && i.motion_name == null && i.area_to_use == null).
                    Select(i => i.id).ToList();

            Dictionary<int, List<int>> itemSkillPoints;
            Dictionary<int, List<int>> taskLevels = taskExport.RaceTasks.SelectMany(r => r.Tasks)
                .SelectMany(t => AggregatedTaskItem.CreateList(t.Items, t.race, t.skill, t.skillpoints))
                .Aggregate(itemSkillPoints = new Dictionary<int, List<int>>(), (l, a) =>
                {
                    if (a.SkillId == 0 || a.SkillPoints > 399)
                        return l;
                    int bonusLevel = a.SkillId;
                    bonusLevel <<= 10;
                    bonusLevel |= a.SkillPoints;
                    if (l.ContainsKey(a.ItemId)) {
                        var skillPoints = l[a.ItemId];
                        skillPoints.Add(bonusLevel);
                    } else {
                        List<int> list = new List<int>();
                        list.Add(bonusLevel);
                        l.Add(a.IsRecipe ? -a.ItemId : a.ItemId, list);
                    }
                    return l;
                });

            var elyosCraftItems = taskExport.RaceTasks[0].Tasks.SelectMany(t => t.Items).Select(rc => rc.id);
            var asmoCraftItems = taskExport.RaceTasks[1].Tasks.SelectMany(t => t.Items).Select(rc => rc.id);
            var commonCraftItems = elyosCraftItems.Intersect(asmoCraftItems).ToList();
            elyosCraftItems = elyosCraftItems.Except(commonCraftItems);
            asmoCraftItems = asmoCraftItems.Except(commonCraftItems);

            questStart.Add(182200214); // Namus's Diary

            // Documents which start quests
            questStart.Add(182200558); // Odium Refining Method
            questStart.Add(182200559); // Bandit's Letter
            questStart.Add(182201728); // Parchment Map
            questStart.Add(182201744); // Mapping the Revolutionaries
            questStart.Add(182201765); // Old Letter
            questStart.Add(182201770); // Adventurer's Diary
            questStart.Add(182203107); // Rolled Scroll
            questStart.Add(182203130); // Old Scroll
            questStart.Add(182203263); // A Bill Found in a Box
            questStart.Add(182204169); // Pamphlet
            questStart.Add(182204232); // Sodden Scroll
            questStart.Add(182204501); // Lepharist Book
            questStart.Add(182206084); // Lifeform Remodeling Report
            questStart.Add(182206700); // Dusty Book
            questStart.Add(182206722); // Balaur's Quartz of Memory
            questStart.Add(182206724); // Balaur's Map
            questStart.Add(182207009); // Ornate Jewelry Box
            questStart.Add(182207127); // Lifeform Remodeling Report
            questStart.Add(182207865); // Half-folded Paper
            questStart.Add(182208034); // Bloodied Note
            questStart.Add(182208043); // Red Journal
            questStart.Add(182208053); // Research Center Document
            questStart.Add(182209024); // Wet Letter
            questStart.Add(182209037); // Zombie's Diary
            questStart.Add(182209824); // Worn Book - 2.0

            questStart.Remove(182206722); // Murmur Fluid
            questStart.Remove(182206724); // Seasoned Moonflower Vegetables

            questStart.Add(182201309); // Jewel Box
            questStart.Add(182201400); // Fire Temple Key
            questStart.Add(182206842); // Vorgaltem Secret Order
            questStart.Add(182206843); // Stanis's Secret Order
            questStart.Add(182206844); // Temenos's Secret Order
            questStart.Add(182206845); // Omega's Fragment
            questStart.Add(182206846); // Violet Orb
            questStart.Add(182206847); // Violet Orb
            questStart.Add(182206848); // Violet Orb
            questStart.Add(182207845); // Angrief Special Orders
            questStart.Add(182207846); // Fundin's Special Orders
            questStart.Add(182207847); // Kirhua's Special Orders
            questStart.Add(182207848); // Shining Scroll
            questStart.Add(182207920); // Berokin's Image Marble
            questStart.Add(182207923); // Sakti's Crystal

            ItemTemplates saveTemplate = new ItemTemplates();
            List<ItemTemplate> exportTemplates = new List<ItemTemplate>();
            saveTemplate.TemplateList = new ItemTemplate[allItems.Count];
            var enumerator = allItems.Values.GetEnumerator();
            StringBuilder sqlData = new StringBuilder();

            while (enumerator.MoveNext()) {
                ItemTemplate template = new ItemTemplate();
                exportTemplates.Add(template);
                ItemExport exportItem = enumerator.Current;
                Item originalItem = exportItem.originalItem;

                template.id = exportItem.itemId;
                template.race = originalItem.race;
                template.origRace = exportItem.raceInternal;
                if (!String.IsNullOrEmpty(originalItem.gender_permitted))
                    template.gender = (Gender)Enum.Parse(typeof(Gender), originalItem.gender_permitted, true);
                if (elyosCraftItems.Contains(template.id))
                    template.origRace = ItemRace.ELYOS;
                else if (asmoCraftItems.Contains(template.id))
                    template.origRace = ItemRace.ASMODIANS;

                if (template.race != template.origRace) {
                    if (template.race != ItemRace.ALL) {
                        Debug.Print("Race mismatch... id: {0}", template.id);
                    }
                }

                if (feedItems.ContainsKey(template.id)) {
                    template.feed = feedItems[template.id].ToArray();
                }

                if (originalItem.doping_pet_useable) {
                    var feedItem = new ItemFeed() { type = FoodType.DOPING };
                    if (template.feed == null)
                        template.feed = new ItemFeed[1] { feedItem };
                    else {
                        Array.Resize(ref template.feed, template.feed.Length + 1);
                        template.feed[template.feed.Length - 1] = feedItem;
                    }
                }

                if (originalItem.quest == 0 && originalItem.Quality == ItemQualities.junk &&
                    originalItem.name.IndexOf("_pet_reward") == -1 &&
                    originalItem.name.IndexOf("_petreward") == -1 && originalItem.tag == ItemTag.none) {
                    string descr = originalItem.Description;
                    if (descr != null && descr.IndexOf("stinking", StringComparison.CurrentCultureIgnoreCase) == -1) {
                        var feedItem = new ItemFeed() { type = FoodType.MISC };
                        if (template.feed == null)
                            template.feed = new ItemFeed[1] { feedItem };
                        else {
                            Array.Resize(ref template.feed, template.feed.Length + 1);
                            template.feed[template.feed.Length - 1] = feedItem;
                        }
                    }
                }
                Thread.Sleep(10);

                if (splitItems.Contains(template.id)) {
                    if (template.actions == null) {
                        template.actions = new ItemActions[1];
                        template.actions[0] = new ItemActions();
                    }
                    template.actions[0].split = new SplitAction[1] { new SplitAction() };
                }

                if (originalItem.cash_social > 0) {
                    if (template.actions == null) {
                        template.actions = new ItemActions[1];
                        template.actions[0] = new ItemActions();
                    }
                    var ema = new EmotionAction();
                    ema.emotionid = originalItem.cash_social;
                    if (originalItem.cash_available_minute > 0) {
                        ema.expire = originalItem.cash_available_minute;
                        if (ema.expire > 60)
                            ema.expire--;
                    }
                    template.actions[0].emotion = new EmotionAction[1] { ema };
                }

                if (originalItem.cash_title > 0) {
                    if (template.actions == null) {
                        template.actions = new ItemActions[1];
                        template.actions[0] = new ItemActions();
                    }
                    var tia = new TitleAction();
                    tia.titleid = originalItem.cash_title;
                    if (originalItem.cash_available_minute > 0) {
                        tia.expire = originalItem.cash_available_minute;
                        if (tia.expire > 60)
                            tia.expire--;
                    }
                    template.actions[0].title = new TitleAction[1] { tia };
                }

                ItemExport exp = itemGroups.Manastones.Where(i => i.itemId == template.id).FirstOrDefault();
                if (exp != null) {
                    ItemBonus bonus = new ItemBonus(exp, BonusType.MANASTONE);
                    template.bonus = new ItemBonus[1] { bonus };
                }

                exp = itemGroups.CoinRewards.Where(i => i.itemId == template.id).FirstOrDefault();
                if (exp != null && exp.raceInternal != ItemRace.ALL) {
                    ItemBonus bonus = new ItemBonus(exp, BonusType.COIN);
                    template.bonus = new ItemBonus[1] { bonus };
                }

                exp = itemGroups.FoodRewards.Where(i => i.itemId == template.id).FirstOrDefault();
                if (exp != null && exp.raceInternal != ItemRace.ALL) {
                    ItemBonus bonus = new ItemBonus(exp, BonusType.FOOD);
                    template.bonus = new ItemBonus[1] { bonus };
                }

                //exp = itemGroups.EnchantRewards.Where(i => i.itemId == template.id).FirstOrDefault();
                //if (exp != null) {
                //    ItemBonus bonus = new ItemBonus(exp, BonusType.ENCHANT);
                //    template.bonus = new ItemBonus[1] { bonus };
                //}

                exp = itemGroups.MedicineRewards.Where(i => i.itemId == template.id).FirstOrDefault();
                if (exp != null) {
                    ItemBonus bonus = new ItemBonus(exp, BonusType.MEDICINE);
                    template.bonus = new ItemBonus[1] { bonus };
                }

                exp = itemGroups.BossRewards.Where(i => i.itemId == template.id).FirstOrDefault();
                if (exp != null) {
                    ItemBonus bonus = new ItemBonus(exp, BonusType.BOSS);
                    template.bonus = new ItemBonus[1] { bonus };
                }

                exp = itemGroups.MasterRecipes.Where(i => i.itemId == template.id).FirstOrDefault();
                if (exp != null) {
                    ItemBonus bonus = new ItemBonus(exp, BonusType.MASTER_RECIPE);
                    template.bonus = new ItemBonus[1] { bonus };
                }

                exp = itemGroups.QuestItems.Where(i => i.itemId == template.id).FirstOrDefault();
                if (exp != null) {
                    int pos = exp.itemName.LastIndexOf('_');
                    template.quest = Int32.Parse(exp.itemName.Substring(pos + 1, exp.itemName.Length - 2 - pos));
                    template.questSpecified = true;
                }

                exp = itemGroups.Documents.Where(i => i.itemId == template.id).FirstOrDefault();
                if (exp != null) {
                    if (template.actions == null) {
                        template.actions = new ItemActions[1];
                        template.actions[0] = new ItemActions();
                    } else if (template.actions[0].queststart != null && !questStart.Contains(template.id)) {
                        // delete queststart action (it's not a quest start item)
                        template.quest = template.actions[0].queststart[0].questid;
                        template.questSpecified = true;
                        template.actions[0].queststart = null;
                    }

                    if (exp.itemId != 182207127) {
                        template.actions[0].read = new ReadAction[1] { new ReadAction() };
                        if (template.quest == 0) {
                            Item item = Utility.ItemIndex.ItemList.Where(i => i.id == template.id).FirstOrDefault();
                            int pos = item.name.LastIndexOf('_');
                            template.quest = Int32.Parse(item.name.Substring(pos + 1, item.name.Length - 2 - pos));
                            template.questSpecified = true;
                        }
                    }
                }

                exp = itemGroups.WorkOrderItems.Where(i => i.itemId == template.id).FirstOrDefault();
                if (exp != null) {
                    int qIdStart = exp.itemName.IndexOf("_q") + 2;
                    int qIdEnd = exp.itemName.IndexOf("_", qIdStart);
                    string qStr = exp.itemName.Substring(qIdStart, qIdEnd - qIdStart);
                    int qId = Int32.Parse(qStr);
                    template.quest = qId;
                    template.questSpecified = true;
                }

                if (template.actions != null && template.actions[0] != null && !template.HasActions()) {
                    template.actions = null; // clear
                }

                if (questStart.Contains(template.id)) {
                    if (template.actions == null) {
                        template.actions = new ItemActions[1];
                        template.actions[0] = new ItemActions();
                    }
                    if (template.quest == 0) {
                        Item item = Utility.ItemIndex.ItemList.Where(i => i.id == template.id).FirstOrDefault();
                        int pos = item.name.LastIndexOf('_');
                        template.quest = Int32.Parse(item.name.Substring(pos + 1, item.name.Length - 2 - pos));
                        template.questSpecified = true;
                    }
                    var qa = new QuestStartAction();
                    // qa.questid = template.quest;
                    // qa.questidSpecified = true;
                    template.actions[0].queststart = new QuestStartAction[1] { qa };
                }

                if (taskLevels.ContainsKey(template.id) || taskLevels.ContainsKey(-template.id)) {
                    ItemBonus bonus = new ItemBonus();
                    bonus.type = taskLevels.ContainsKey(template.id) ? BonusType.TASK : BonusType.RECIPE;
                    bonus.typeSpecified = true;
                    var levels = bonus.type == BonusType.RECIPE ? taskLevels[-template.id] : taskLevels[template.id];
                    bonus.bonusLevel = String.Join(",", levels.Select(l => l.ToString()).ToArray());
                    template.bonus = new ItemBonus[1] { bonus };
                }

                template.can_fuse = exportItem.canFuse;
                // template.can_fuseSpecified = true;

                template.item_category = GetItemCategory(exportItem.itemIcon);
                template.item_type = exportItem.itemType.ToString().ToUpper();
                template.mask = exportItem.mask;
                template.maskSpecified = true;
                template.expire_time = (ExpireDuration)exportItem.expire_time;
                template.cash_item = exportItem.cash_item;
                template.cash_minute = (ExpireDuration)exportItem.cash_minute;
                template.exchange_mins = (ExpireDuration)exportItem.exchange_time;
                template.world_drop = exportItem.itemGroup == "random_drop";

                if (template.world_drop || exportItem.desc != null && exportItem.desc.StartsWith("[Event")) {
                    if (exportItem.level >= 52)
                        template.origRace = ItemRace.ALL;
                    sqlData.AppendFormat("DELETE FROM `droplist` WHERE itemId = {0};\n", template.id);
                    var allDrops = Utility.DropListTemplate.Drops.SelectMany(d => d.DropItems);
                    var removed = allDrops.Where(d => d.id == template.id).ToList();
                    foreach (var dropEntry in Utility.DropListTemplate.Drops) {
                        dropEntry.DropItems.RemoveAll(i => removed.Contains(i));
                    }
                }

                string minLevel = String.Empty;
                for (int i = 0; i < 12; i++)
                    minLevel += exportItem.level + ",";
                minLevel = minLevel.TrimEnd(',');
                if (exportItem.restricts != minLevel)
                    template.restrict = exportItem.restricts;

                if (exportItem.restricts_max != "0,0,0,0,0,0,0,0,0,0,0,0")
                    template.restrict_max = exportItem.restricts_max;

                SkillTemplate skill = exportItem.skill_use;
                if (skill != null) {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    template.actions[0].skilluse = new SkillUseAction[1] {
                        new SkillUseAction(skill.skill_id, skill.lvl)
                    };
                } else if (template.actions != null) {
                    template.actions[0].skilluse = null; // clear it
                }

                if (exportItem.modifiers != null)
                    template.modifiers = new Modifiers[1] {
                        new Modifiers() {
                            modifierList = exportItem.modifiers/*.OrderBy(m => m.GetType().Name)
                                                                 .ToList()*/
                        }
                    };
                else if (template.modifiers != null)
                    template.modifiers = null;

                template.quality = (ItemQuality)Enum.Parse(typeof(ItemQuality), originalItem.Quality.ToString().ToUpper());
                template.qualitySpecified = true;

                template.price = (int)originalItem.price;
                template.priceSpecified = template.price > 0;

                template.option_slot_bonus = originalItem.option_slot_bonus;
                template.option_slot_bonusSpecified = template.option_slot_bonus > 0;

                if (originalItem.no_enchant != null) {
                    bool value = originalItem.no_enchant.ToBoolean(CultureInfo.InvariantCulture);
                    if (value) {
                        template.no_enchant = value;
                        // template.no_enchantSpecified = true;
                    }
                }

                if (originalItem.can_proc_enchant != null) {
                    bool value = originalItem.can_proc_enchant.ToBoolean(CultureInfo.InvariantCulture);
                    if (value) {
                        template.can_proc_enchant = true;
                        // template.can_proc_enchantSpecified = true;
                    }
                }

                template.max_stack_count = originalItem.max_stack_count;
                template.max_stack_countSpecified = template.max_stack_count > 1;

                template.level = originalItem.level;
                template.levelSpecified = true;

                template.slot = (int)originalItem.EquipmentSlots;
                if (template.slot > 0)
                    template.slotSpecified = true;

                if (originalItem.weapon_boost_value > 0) {
                    template.weapon_boost = originalItem.weapon_boost_value;
                    template.weapon_boostSpecified = true;
                }

                if (originalItem.EquipmentSlots != EquipmentSlots.none) {
                    if (originalItem.WeaponType != WeaponTypes.None &&
                        originalItem.WeaponType != WeaponTypes.NoWeapon) {
                        // DAGGER_1H,MACE_1H,SWORD_1H,TOOLHOE_1H,BOOK_2H,ORB_2H,
                        // POLEARM_2H,STAFF_2H,SWORD_2H,TOOLPICK_2H,TOOLROD_2H,BOW
                        template.equipment_type = EquipType.WEAPON;
                        template.equipment_typeSpecified = true;
                        template.weapon_type = (weaponType)originalItem.WeaponType;
                        template.weapon_typeSpecified = true;
                    }
                    if (originalItem.EquipmentSlots == EquipmentSlots.right_or_left_battery) {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                        template.armor_type = armorType.SHARD;
                        template.armor_typeSpecified = true;
                    } else if (template.item_category == "SHIELD" || template.item_category == "CASH_SHIELD") {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                        template.armor_type = armorType.SHIELD;
                        template.armor_typeSpecified = true;
                    } else if (template.item_category == "ARROW") {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                        template.armor_type = armorType.ARROW;
                        template.armor_typeSpecified = true;
                    } else if (originalItem.ArmorType != ArmorTypes.none &&
                        originalItem.ArmorType != ArmorTypes.no_armor) {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                        // + SHARD, ARROW, SHIELD
                        template.armor_type = (armorType)Enum.Parse(typeof(armorType),
                                        originalItem.ArmorType.ToString().ToUpper());
                        template.armor_typeSpecified = true;
                    } else if (template.equipment_type == EquipType.NONE) {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                    }
                }

                template.dmg_decal = originalItem.dmg_decal;
                template.dmg_decalSpecified = template.dmg_decal > 0;

                if (!String.IsNullOrEmpty(originalItem.desc)) {
                    int desc = Utility.StringIndex[originalItem.desc];
                    if (desc != -1) {
                        template.desc = desc * 2 + 1;
                        template.descSpecified = true;
                    } else {
                        Debug.Print("Missing description for {0}", originalItem.id);
                    }
                }

                template.attack_gap = originalItem.attack_gap;
                template.attack_gapSpecified = template.attack_gap > 0;

                if (originalItem.item_drop_permitted != null) {
                    bool value = originalItem.item_drop_permitted.ToBoolean(CultureInfo.InvariantCulture);
                    if (value) {
                        template.drop = true;
                        // template.dropSpecified = true;
                    }
                }

                template.usedelayid = originalItem.use_delay_type_id;
                if (template.usedelayid > 0) {
                    template.usedelayidSpecified = true;
                    template.usedelay = originalItem.use_delay;
                    template.usedelaySpecified = template.usedelay > 0;
                }

                if (originalItem.require_shard > 0) {
                    template.stigma = new Stigma();
                    template.stigma.shard = originalItem.require_shard;
                    template.stigma.shardSpecified = true;
                    ClientSkill stigmaSkill = Utility.SkillIndex[originalItem.gain_skill1];
                    if (stigmaSkill != null) {
                        // gain_skill2 and gain_level2 used only in the test item
                        template.stigma.skillid = stigmaSkill.id;
                        template.stigma.skillidSpecified = true;
                        template.stigma.skilllvl = originalItem.gain_level1;
                        template.stigma.skilllvlSpecified = true;

                        var utility = Utility<Item>.Instance;
                        List<string> requiredSkills = new List<string>();
                        utility.Export<String>(originalItem, "require_skill", requiredSkills);
                        if (requiredSkills.Count > 0) {
                            List<RequireSkill> skills = new List<RequireSkill>();
                            for (int n = 1; n <= requiredSkills.Count; n++) {
                                FieldInfo fld = typeof(Item).GetField(String.Format("require_skill{0}_lv", n),
                                     BindingFlags.Instance | BindingFlags.Public);
                                int skillLvl = (int)fld.GetValue(originalItem);
                                string[] skillIds = requiredSkills[n - 1].Split(new string[] { " ", "," },
                                                                    StringSplitOptions.RemoveEmptyEntries);
                                List<int> ids = new List<int>();
                                foreach (string skillId in skillIds) {
                                    stigmaSkill = Utility.SkillIndex[skillId];
                                    if (stigmaSkill != null && stigmaSkill.id > 0)
                                        ids.Add(stigmaSkill.id);
                                }
                                if (ids.Count > 0)
                                    skills.Add(new RequireSkill()
                                    {
                                        skillId = ids.ToArray(),
                                        skilllvl = skillLvl,
                                        skilllvlSpecified = true
                                    });
                            }
                            if (skills.Count > 0)
                                template.stigma.require_skill = skills.ToArray();
                        }
                    } else {
                        Debug.Print("Missing stigma for {0}", originalItem.id);
                    }
                }

                if (originalItem.can_dye) {
                    template.dye = true;
                    // template.dyeSpecified = true;
                }

                if (originalItem.craft_recipe_info != null) {
                    var recipe = Utility.RecipeIndex[originalItem.craft_recipe_info];
                    if (recipe != null) {
                        if (template.actions == null)
                            template.actions = new ItemActions[1];
                        if (template.actions[0] == null)
                            template.actions[0] = new ItemActions();
                        var action = new CraftLearnAction();
                        action.recipeid = recipe.id;
                        action.recipeidSpecified = true;
                        template.actions[0].craftlearn = new CraftLearnAction[1] { action };
                    } else {
                        Debug.Print("Missing recipe for {0}", originalItem.id);
                    }
                }

                if (!String.IsNullOrEmpty(originalItem.dyeing_color) || originalItem.name == "dye_remover") {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new DyeAction();
                    if (originalItem.name == "dye_remover")
                        action.color = "no";
                    else
                        action.color = action.color = getHexRGB(originalItem.dyeing_color);
                    template.actions[0].dye = new DyeAction[1] { action };
                }

                if (!String.IsNullOrEmpty(originalItem.cosmetic_name)) {
                    CosmeticInfo info = Utility.CosmeticsIndex[originalItem.cosmetic_name.ToLower()];
                    if (info == null) {
                        Debug.Print("Cosmetics not found: {0}", originalItem.cosmetic_name);
                    } else {
                        if (template.actions == null)
                            template.actions = new ItemActions[1];
                        if (template.actions[0] == null)
                            template.actions[0] = new ItemActions();
                        var action = new CosmeticAction();
                        if (info.hair_type > 0) {
                            action.hairType = info.hair_type;
                        }
                        if (info.face_type > 0) {
                            action.faceType = info.face_type;
                        }
                        if (info.makeup_type > 0) {
                            action.makeupType = info.makeup_type;
                        }
                        if (info.tattoo_type > 0) {
                            action.tattooType = info.tattoo_type;
                        }
                        if (info.voice_type > 0) {
                            action.voiceType = info.voice_type;
                        }
                        if (!String.IsNullOrEmpty(info.face_color)) {
                            action.face = getHexRGB(info.face_color);
                        }
                        if (!String.IsNullOrEmpty(info.hair_color)) {
                            action.hair = getHexRGB(info.hair_color);
                        }
                        if (!String.IsNullOrEmpty(info.lip_color)) {
                            action.lips = getHexRGB(info.lip_color);
                        }
                        if (!String.IsNullOrEmpty(info.eye_color)) {
                            action.eyes = getHexRGB(info.eye_color);
                        }
                        if (!String.IsNullOrEmpty(info.preset_name)) {
                            action.preset = info.preset_name.ToUpper();
                        }
                        template.actions[0].cosmetic = new CosmeticAction[1] { action };
                    }
                }

                if (originalItem.inven_warehouse_max_extendlevel != 0 &&
                    (template.item_category == "CUBE" || template.item_category == "CASH_CARD")) {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new TicketAction();
                    action.function = template.item_category == "CUBE" ? ticketFunction.addCube : ticketFunction.addWharehouse;
                    template.actions[0].ticket = new TicketAction[1] { action };
                }

                if (!String.IsNullOrEmpty(originalItem.proc_enchant_skill)) {
                    ClientSkill enchantSkill = Utility.SkillIndex[originalItem.proc_enchant_skill];
                    if (enchantSkill != null) {
                        template.godstone = new Godstone();
                        template.godstone.probability = originalItem.proc_enchant_effect_occur_prob;
                        if (template.godstone.probability > 0)
                            template.godstone.probabilitySpecified = true;
                        template.godstone.probabilityleft = originalItem.proc_enchant_effect_occur_left_prob;
                        template.godstone.skillid = enchantSkill.id;
                        template.godstone.skillidSpecified = true;
                        template.godstone.skilllvl = originalItem.proc_enchant_skill_level;
                        template.godstone.skilllvlSpecified = true;
                    } else {
                        Debug.Print("Missing godstone for {0}", originalItem.id);
                    }
                }

                if (!String.IsNullOrEmpty(originalItem.skill_to_learn)) {
                    ClientSkill learnSkill = Utility.SkillIndex[originalItem.skill_to_learn];
                    if (learnSkill != null) {
                        if (template.actions == null)
                            template.actions = new ItemActions[1];
                        if (template.actions[0] == null)
                            template.actions[0] = new ItemActions();

                        var learns = Utility.SkillLearnIndex[originalItem.skill_to_learn];
                        if (learns.Count() > 0) {
                            var validActions = new List<SkillLearnAction>();
                            for (int i = 0; i < learns.Count(); i++) {
                                LearnSkill learn = learns.ElementAt(i);
                                if (learn.skill_level > 1)
                                    continue;
                                var action = new SkillLearnAction();
                                validActions.Add(action);
                                action.skillid = learnSkill.id;
                                action.skillidSpecified = true;
                                action.@class = (skillPlayerClass)Enum.Parse(typeof(skillPlayerClass), learn.@class);
                                action.classSpecified = true;
                                action.level = learn.pc_level;
                                action.levelSpecified = true;
                                action.race = (skillRace)Enum.Parse(typeof(skillRace), learn.race.ToUpper());
                                action.raceSpecified = true;
                            }
                            template.actions[0].skilllearn = validActions.ToArray();
                        }
                    } else {
                        Debug.Print("Missing learn skill for {0}", originalItem.id);
                    }
                }

                if (!String.IsNullOrEmpty(originalItem.toy_pet_name)) {
                    int npcId = Utility.ClientNpcIndex[originalItem.toy_pet_name];
                    if (npcId == -1)
                        Debug.Print("Missing pet NPC for {0}", originalItem.id);
                    else {
                        if (template.actions == null)
                            template.actions = new ItemActions[1];
                        if (template.actions[0] == null)
                            template.actions[0] = new ItemActions();
                        var action = new ToyPetSpawnAction();
                        action.npcid = npcId;
                        action.npcidSpecified = true;
                        template.actions[0].toypetspawn = new ToyPetSpawnAction[1] { action };
                    }
                }

                if (originalItem.return_worldid > 0) {
                    template.return_world = originalItem.return_worldid;
                    template.return_worldSpecified = true;
                    if (!String.IsNullOrEmpty(originalItem.return_alias))
                        template.return_alias = originalItem.return_alias.ToUpper();
                }

                template.cash_item = originalItem.cash_item;

                if (template.item_category == "PINCER") {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new ExtractAction();
                    template.actions[0].extract = new ExtractAction[1] { action };
                }

                if (originalItem.sub_enchant_material_many > 0) {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new EnchantItemAction();
                    action.count = originalItem.sub_enchant_material_many;
                    template.actions[0].enchant = new EnchantItemAction[1] { action };
                }

                if (originalItem.AttackType != AttackTypes.none) {
                    template.attack_type = originalItem.AttackType.ToString().ToUpper();
                }

                if (originalItem.abyss_point > 0) {
                    template.ap = (int)originalItem.abyss_point;
                }

                if (originalItem.abyss_item_count > 0) {
                    template.aic = (int)originalItem.abyss_item_count;
                }

                if (!String.IsNullOrEmpty(originalItem.abyss_item)) {
                    Item abyssItem = Utility.ItemIndex.GetItem(originalItem.abyss_item);
                    if (abyssItem == null)
                        Debug.Print("Missing abyss item for {0}", originalItem.id);
                    else {
                        template.ai = abyssItem.id;
                    }
                }

                if (originalItem.extra_currency_item_count > 0) {
                    template.eic = (int)originalItem.extra_currency_item_count;
                }

                if (!String.IsNullOrEmpty(originalItem.extra_currency_item)) {
                    Item extraItem = Utility.ItemIndex.GetItem(originalItem.extra_currency_item);
                    if (extraItem == null)
                        Debug.Print("Missing extra item for {0}", originalItem.id);
                    else {
                        template.ei = extraItem.id;
                    }
                }

                if (originalItem.coupon_item_count > 0) {
                    template.cic = (int)originalItem.coupon_item_count;
                }

                if (!String.IsNullOrEmpty(originalItem.coupon_item)) {
                    Item extraItem = Utility.ItemIndex.GetItem(originalItem.coupon_item);
                    if (extraItem == null)
                        Debug.Print("Missing extra item for {0}", originalItem.id);
                    else {
                        template.ci = extraItem.id;
                    }
                }

                if (originalItem.BonusApply != Bonuses.none) {
                    template.bonus_apply = (BonusApplyType)Enum.Parse(typeof(BonusApplyType),
                                                originalItem.BonusApply.ToString().ToUpper());
                    // template.bonus_applySpecified = true;
                }

                // template.name
            }

            saveTemplate.TemplateList = exportTemplates.OrderBy(i => i.id).ToArray();

            //var droplistDrops = Utility.DropListTemplate.Drops.SelectMany(d => d.DropItems);
            //var existingItems = exportTemplates.Select(t => t.id);
            //var nonexistant = droplistDrops.Where(d => !existingItems.Contains(d.id)).ToList();
            //foreach (var dropEntry in Utility.DropListTemplate.Drops) {
            //    dropEntry.DropItems.RemoveAll(i => nonexistant.Contains(i));
            //}

            using (FileStream stream = new FileStream(Path.Combine(outputPath, "item_templates.xml"),
                                                      FileMode.Create, FileAccess.Write)) {
                using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) {
                    XmlSerializer ser = new XmlSerializer(typeof(ItemTemplates));
                    ser.Serialize(wr, saveTemplate);
                }
            }

            using (FileStream stream = new FileStream(Path.Combine(outputPath, "clean_world_drops.sql"),
                                                      FileMode.Create, FileAccess.Write)) {
                using (var wr = new StreamWriter(stream, Encoding.ASCII)) {
                    wr.Write(sqlData.ToString());
                }
            }

            var emptyDrops = Utility.DropListTemplate.Drops.Where(d => d.DropItems.Count == 0).ToList();
            Utility.DropListTemplate.Drops.RemoveAll(d => emptyDrops.Contains(d));

            using (FileStream stream = new FileStream(Path.Combine(outputPath, "droplist.xml"),
                                                      FileMode.Create, FileAccess.Write)) {
                using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) {
                    XmlSerializer ser = new XmlSerializer(typeof(Droplist));
                    ser.Serialize(wr, Utility.DropListTemplate);
                }
            }

            // Do some tests
            // TestUtility.TestWorkOrders(itemTemplates);
        }
Ejemplo n.º 7
0
 public static void TestWorkOrders(ItemTemplates templates)
 {
     CreateItemData(templates);
     SampleWorkOrdersBonuses();
 }
Ejemplo n.º 8
0
        private static void InjectBonusesToItemTemplate(XmlWriterSettings saveSettings, string outputPath)
        {
            try {
                using (var fs = new FileStream(Path.Combine(root, @".\data\item_templates.xml"),
                                         FileMode.Open, FileAccess.Read))
                using (var reader = XmlReader.Create(fs)) {
                    XmlSerializer ser = new XmlSerializer(typeof(ItemTemplates));
                    Utility.OriginalItemTemplate = (ItemTemplates)ser.Deserialize(reader);
                }
            }
            catch (Exception ex) {
                Debug.Print(ex.ToString());
                return;
            }

            // Utility.CreateSkillMap(root);

            var allItems = itemGroups.grouped.SelectMany(g => g.items).SelectMany(s => s.items)
                            .ToDictionary(i => i.itemId, i => i);

            List<int> splitItems = Utility.ItemIndex.ItemList
                .Where(i => (i.disassembly_item.HasValue && i.disassembly_item.Value) &&
                          i.Category == ItemCategories.harvest).Select(i => i.id).ToList();

            List<int> questStart = Utility.ItemIndex.ItemList
                .Where(i => i.ActivateTarget == ActivateTargets.standalone && i.name.StartsWith("quest_") &&
                     i.quest == 3 && i.motion_name == null && i.area_to_use == null).
                   Select(i => i.id).ToList();

            Dictionary<int, List<int>> itemSkillPoints;
            Dictionary<int, List<int>> taskLevels = taskExport.RaceTasks.SelectMany(r => r.Tasks)
                .SelectMany(t => AggregatedTaskItem.CreateList(t.Items, t.race, t.skill, t.skillpoints))
                .Aggregate(itemSkillPoints = new Dictionary<int, List<int>>(), (l, a) => {
                    if (a.SkillId == 0 || a.SkillPoints > 399)
                        return l;
                    int bonusLevel = a.SkillId;
                    bonusLevel <<= 10;
                    bonusLevel |= a.SkillPoints;
                    if (l.ContainsKey(a.ItemId)) {
                        var skillPoints = l[a.ItemId];
                        skillPoints.Add(bonusLevel);
                    }
                    else {
                        List<int> list = new List<int>();
                        list.Add(bonusLevel);
                        l.Add(a.IsRecipe ? -a.ItemId : a.ItemId, list);
                    }
                    return l;
                });

            var elyosCraftItems = taskExport.RaceTasks[0].Tasks.SelectMany(t => t.Items).Select(rc => rc.id);
            var asmoCraftItems = taskExport.RaceTasks[1].Tasks.SelectMany(t => t.Items).Select(rc => rc.id);
            var commonCraftItems = elyosCraftItems.Intersect(asmoCraftItems).ToList();
            elyosCraftItems = elyosCraftItems.Except(commonCraftItems);
            asmoCraftItems = asmoCraftItems.Except(commonCraftItems);

            questStart.Add(182200214); // Namus's Diary

            // Documents which start quests
            questStart.Add(182200558); // Odium Refining Method
            questStart.Add(182200559); // Bandit's Letter
            questStart.Add(182201728); // Parchment Map
            questStart.Add(182201744); // Mapping the Revolutionaries
            questStart.Add(182201765); // Old Letter
            questStart.Add(182201770); // Adventurer's Diary
            questStart.Add(182203107); // Rolled Scroll
            questStart.Add(182203130); // Old Scroll
            questStart.Add(182203263); // A Bill Found in a Box
            questStart.Add(182204169); // Pamphlet
            questStart.Add(182204232); // Sodden Scroll
            questStart.Add(182204501); // Lepharist Book
            questStart.Add(182206084); // Lifeform Remodeling Report
            questStart.Add(182206700); // Dusty Book
            questStart.Add(182206722); // Balaur's Quartz of Memory
            questStart.Add(182206724); // Balaur's Map
            questStart.Add(182207009); // Ornate Jewelry Box
            questStart.Add(182207127); // Lifeform Remodeling Report
            questStart.Add(182207865); // Half-folded Paper
            questStart.Add(182208034); // Bloodied Note
            questStart.Add(182208043); // Red Journal
            questStart.Add(182208053); // Research Center Document
            questStart.Add(182209024); // Wet Letter
            questStart.Add(182209037); // Zombie's Diary
            questStart.Add(182209824); // Worn Book - 2.0

            questStart.Remove(182206722); // Murmur Fluid
            questStart.Remove(182206724); // Seasoned Moonflower Vegetables

            questStart.Add(182201309); // Jewel Box
            questStart.Add(182201400); // Fire Temple Key
            questStart.Add(182206842); // Vorgaltem Secret Order
            questStart.Add(182206843); // Stanis's Secret Order
            questStart.Add(182206844); // Temenos's Secret Order
            questStart.Add(182206845); // Omega's Fragment
            questStart.Add(182206846); // Violet Orb
            questStart.Add(182206847); // Violet Orb
            questStart.Add(182206848); // Violet Orb
            questStart.Add(182207845); // Angrief Special Orders
            questStart.Add(182207846); // Fundin's Special Orders
            questStart.Add(182207847); // Kirhua's Special Orders
            questStart.Add(182207848); // Shining Scroll
            questStart.Add(182207920); // Berokin's Image Marble
            questStart.Add(182207923); // Sakti's Crystal

            ItemTemplates saveTemplate = new ItemTemplates();
            List<ItemTemplate> exportTemplates = new List<ItemTemplate>();
            saveTemplate.TemplateList = new ItemTemplate[allItems.Count];
            var enumerator = allItems.Values.GetEnumerator();
            StringBuilder sqlData = new StringBuilder();

            while (enumerator.MoveNext()) {
                ItemTemplate template = new ItemTemplate();
                exportTemplates.Add(template);
                ItemExport exportItem = enumerator.Current;
                Item originalItem = exportItem.originalItem;

                template.id = exportItem.itemId;
                template.race = originalItem.race;
                template.origRace = exportItem.raceInternal;

                // zp - al3 3.0 Template Updates
                template.attack_gap = originalItem.attack_gap;
                //template.weapon_stats = originalItem.GetWeaponStats();
                template.burn_attack = originalItem.burn_on_attack;
                template.burn_defend = originalItem.burn_on_defend;
                if (originalItem.charge_level != 0) {
                    template.charge_level = originalItem.charge_level;
                    template.charge_price1 = (int)(originalItem.charge_price1 * 1000000);
                    template.charge_price2 = (int)(originalItem.charge_price2 * 1000000);
                }

                if (!String.IsNullOrEmpty(originalItem.gender_permitted))
                    template.gender = (Gender)Enum.Parse(typeof(Gender), originalItem.gender_permitted, true);

                /* zp - Correction is Incorrect? Recipe Templates are correct and items are correct before this correction?
                if (elyosCraftItems.Contains(template.id))
                    template.origRace = ItemRace.ELYOS;
                else if (asmoCraftItems.Contains(template.id))
                    template.origRace = ItemRace.ASMODIANS;

                if (template.race != template.origRace) {
                    if (template.race != ItemRace.PC_ALL) {
                        Debug.Print("Race mismatch... id: {0}", template.id);
                    }
                }
                */
                /*
                if (feedItems.ContainsKey(template.id)) {
                    template.feed = feedItems[template.id].ToArray();
                }

                if (originalItem.doping_pet_useable) {
                    var feedItem = new ItemFeed() { type = FoodType.DOPING };
                    if (template.feed == null)
                        template.feed = new ItemFeed[1] { feedItem };
                    else {
                        Array.Resize(ref template.feed, template.feed.Length + 1);
                        template.feed[template.feed.Length - 1] = feedItem;
                    }
                }

                if (originalItem.quest == 0 && originalItem.Quality == ItemQualities.junk &&
                    originalItem.name.IndexOf("_pet_reward") == -1 &&
                    originalItem.name.IndexOf("_petreward") == -1 && originalItem.tag == ItemTag.none) {
                    string descr = originalItem.Description;
                    if (descr != null && descr.IndexOf("stinking", StringComparison.CurrentCultureIgnoreCase) == -1) {
                        var feedItem = new ItemFeed() { type = FoodType.MISC };
                        if (template.feed == null)
                            template.feed = new ItemFeed[1] { feedItem };
                        else {
                            Array.Resize(ref template.feed, template.feed.Length + 1);
                            template.feed[template.feed.Length - 1] = feedItem;
                        }
                    }
                }
                Thread.Sleep(10);
                */
                if (splitItems.Contains(template.id) || Utility.OriginalDecomposableItemsFile.isDecomposable(template.id)) {
                    if (template.actions == null) {
                        template.actions = new ItemActions[1];
                        template.actions[0] = new ItemActions();
                    }
                    template.actions[0].split = new SplitAction[1] { new SplitAction() };
                }

                if (originalItem.cash_social > 0) {
                    if (template.actions == null) {
                        template.actions = new ItemActions[1];
                        template.actions[0] = new ItemActions();
                    }
                    var ema = new EmotionAction();
                    ema.emotionid = originalItem.cash_social;
                    if (originalItem.cash_available_minute > 0) {
                        ema.minutes = originalItem.cash_available_minute;
                        if (ema.minutes > 60)
                            ema.minutes--;
                    }
                    template.actions[0].emotion = new EmotionAction[1] { ema };
                }

                if (originalItem.cash_title > 0) {
                    if (template.actions == null) {
                        template.actions = new ItemActions[1];
                        template.actions[0] = new ItemActions();
                    }
                    var tia = new TitleAction();
                    tia.titleid = originalItem.cash_title;
                    if (originalItem.cash_available_minute > 0) {
                        tia.minutes = originalItem.cash_available_minute;
                        if (tia.minutes > 60)
                            tia.minutes--;
                    }
                    template.actions[0].title = new TitleAction[1] { tia };
                }

                if (template.actions != null && template.actions[0] != null && !template.HasActions()) {
                    template.actions = null; // clear
                }

                if (questStart.Contains(template.id)) {
                    if (template.actions == null) {
                        template.actions = new ItemActions[1];
                        template.actions[0] = new ItemActions();
                    }
                    /*
                    if (template.quest == 0) {
                        Item item = Utility.ItemIndex.ItemList.Where(i => i.id == template.id).FirstOrDefault();
                        int pos = item.name.LastIndexOf('_');
                        template.quest = Int32.Parse(item.name.Substring(pos + 1, item.name.Length - 2 - pos));
                        template.questSpecified = true;
                    }
                    */
                    var qa = new QuestStartAction();
                    // qa.questid = template.quest;
                    // qa.questidSpecified = true;
                    template.actions[0].queststart = new QuestStartAction[1] { qa };
                }

                template.can_fuse = exportItem.canFuse;
                // template.can_fuseSpecified = true;

                // flavour.name = Utility.StringIndex.GetString(feed.name);

                // zp strip characters
                template.name = Utility.StringIndex.GetString(Regex.Replace(Utility.StringIndex.GetString(exportItem.desc), @"[^\u0030-\u007A\u0020]", string.Empty));

                // zp add pet funct id
                if(originalItem.func_pet_name != null)
                    template.func_pet_id = Utility.ToyPetIndex[originalItem.func_pet_name];

                template.category = GetItemCategory(exportItem.itemIcon);
                template.item_type = exportItem.itemType.ToString().ToUpper();
                template.mask = exportItem.mask;
                template.maskSpecified = true;
                template.expire_time = (ExpireDuration)exportItem.expire_time;
                template.cash_minute = (ExpireDuration)exportItem.cash_minute;
                template.temp_exchange_time = (ExpireDuration)exportItem.exchange_time;

            /* zp unused for now
                template.world_drop = exportItem.itemGroup == "random_drop";

                if (template.world_drop || exportItem.desc != null && exportItem.desc.StartsWith("[Event")) {
                    if (exportItem.level >= 52)
                        template.origRace = ItemRace.PC_ALL;
                    sqlData.AppendFormat("DELETE FROM `droplist` WHERE itemId = {0};\n", template.id);
                    var allDrops = Utility.DropListTemplate.Drops.SelectMany(d => d.DropItems);
                    var removed = allDrops.Where(d => d.id == template.id).ToList();
                    foreach (var dropEntry in Utility.DropListTemplate.Drops) {
                        dropEntry.DropItems.RemoveAll(i => removed.Contains(i));
                    }
                }
            */
                /* zp testing, should always be added to template
                string minLevel = String.Empty;
                for (int i = 0; i < 12; i++)
                    minLevel += exportItem.level + ",";
                minLevel = minLevel.TrimEnd(',');
                if (exportItem.restricts != minLevel)
                    template.restrict = exportItem.restricts;
                */
                template.restrict = exportItem.restricts;

                if (exportItem.restricts_max != "0,0,0,0,0,0,0,0,0,0,0,0")
                    template.restrict_max = exportItem.restricts_max;

                SkillTemplate skill = exportItem.skill_use;
                if (skill != null) {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    template.actions[0].skilluse = new SkillUseAction[1] {
                        new SkillUseAction(skill.skill_id, skill.lvl)
                    };
                }
                else if (template.actions != null) {
                    template.actions[0].skilluse = null; // clear it
                }

                if (exportItem.modifiers != null)
                    template.modifiers = new Modifiers[1] {
                        new Modifiers() {
                            modifierList = exportItem.modifiers/*.OrderBy(m => m.GetType().Name)
                                                                 .ToList()*/
                        }
                    };
                else if (template.modifiers != null)
                    template.modifiers = null;

                template.quality = (ItemQuality)Enum.Parse(typeof(ItemQuality), originalItem.Quality.ToString().ToUpper());
                template.qualitySpecified = true;

                template.price = (int)originalItem.price;
                template.priceSpecified = template.price > 0;

                template.option_slot_bonus = originalItem.option_slot_bonus;

                if (originalItem.no_enchant != null) {
                    bool value = originalItem.no_enchant.ToBoolean(CultureInfo.InvariantCulture);
                    if (value) {
                        template.no_enchant = value;
                    }
                }

                if (originalItem.can_proc_enchant != null) {
                    bool value = originalItem.can_proc_enchant.ToBoolean(CultureInfo.InvariantCulture);
                    if (value) {
                        template.can_proc_enchant = true;
                        // template.can_proc_enchantSpecified = true;
                    }
                }

                template.max_stack_count = originalItem.max_stack_count;

                template.level = originalItem.level;
                template.levelSpecified = true;

                template.slot = (int)originalItem.EquipmentSlots;
                if (template.slot > 0)
                    template.slotSpecified = true;

                if (originalItem.weapon_boost_value > 0) {
                    template.weapon_boost = originalItem.weapon_boost_value;
                    template.weapon_boostSpecified = true;
                }

                if (originalItem.EquipmentSlots != EquipmentSlots.none) {
                    if (originalItem.WeaponType != WeaponTypes.None &&
                        originalItem.WeaponType != WeaponTypes.NoWeapon) {
                        // DAGGER_1H,MACE_1H,SWORD_1H,TOOLHOE_1H,BOOK_2H,ORB_2H,
                        // POLEARM_2H,STAFF_2H,SWORD_2H,TOOLPICK_2H,TOOLROD_2H,BOW
                        template.equipment_type = EquipType.WEAPON;
                        template.equipment_typeSpecified = true;
                        template.weapon_type = (weaponType)originalItem.WeaponType;
                        template.weapon_typeSpecified = true;
                    }
                    if (originalItem.EquipmentSlots == EquipmentSlots.right_or_left_battery) {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                        template.armor_type = armorType.SHARD;
                        template.armor_typeSpecified = true;
                    }
                    else if (template.category == "SHIELD" || template.category == "CASH_SHIELD") {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                        template.armor_type = armorType.SHIELD;
                        template.armor_typeSpecified = true;
                    }
                    else if (template.category == "ARROW") {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                        template.armor_type = armorType.ARROW;
                        template.armor_typeSpecified = true;
                    }
                    else if (originalItem.ArmorType != ArmorTypes.none &&
                      originalItem.ArmorType != ArmorTypes.no_armor) {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                        // + SHARD, ARROW, SHIELD
                        template.armor_type = (armorType)Enum.Parse(typeof(armorType),
                                     originalItem.ArmorType.ToString().ToUpper());
                        template.armor_typeSpecified = true;
                    }
                    else if (template.equipment_type == EquipType.NONE) {
                        template.equipment_type = EquipType.ARMOR;
                        template.equipment_typeSpecified = true;
                    }
                }

                //zp
                if(template.equipment_type == EquipType.ARMOR || template.equipment_type == EquipType.WEAPON){
                    //zp add manaslots bases on item rarity
                    switch (originalItem.Quality){
                        case ItemQualities.common:
                            template.m_slots = 2;
                            break;
                        case ItemQualities.rare:
                            template.m_slots = 3;
                            break;
                        case ItemQualities.legend:
                            template.m_slots = 4;
                            break;
                        case ItemQualities.unique:
                            template.m_slots = 5;
                            break;
                        case ItemQualities.epic:
                            template.m_slots = 6;
                            break;
                        default:
                            template.m_slots = 1;
                            break;
                    }

                    //zp add random manaslots bases on item type
                    switch (originalItem.ItemType) {
                        case ItemTypes.normal:
                            template.m_slots_r = 1;
                            break;
                        case ItemTypes.abyss:
                            template.m_slots_r = 2;
                            break;
                        case ItemTypes.draconic:
                            template.m_slots_r = 1;
                            break;
                        case ItemTypes.devanion:
                            template.m_slots_r = 0;
                            break;
                        default:
                            template.m_slots_r = 0;
                            break;
                    }
                }

                // Check if missing original description, some test items or bugged data in client etc?
                if (!String.IsNullOrEmpty(originalItem.desc)) {
                    int desc = Utility.StringIndex[originalItem.desc];

                    // if desc id not found in item strings keep searching
                    // search general strings
                    if (desc == -1) {
                        desc = Utility.StringIndex[originalItem.desc];
                    }

                    // if desc id not found in general strings keep searching
                    // search quest strings
                    if (desc == -1) {
                        desc = Utility.StringIndex[originalItem.desc];
                    }

                    // Log if string name id can not be found
                    // Leave -1 for template search to add missing string files if necessary
                    if (desc == -1) {
                        Debug.Print("Missing description for {0}", originalItem.id);
                    }
                    if (desc != -1) {
                        template.desc = desc * 2 + 1;
                    }
                    else {
                        template.desc = desc;
                    }
                    template.descSpecified = true;
                }

                /* Old Way to get name desc id Just for documentation
                if (!String.IsNullOrEmpty(originalItem.desc)) {
                    int desc = Utility.ItemStringIndex[originalItem.desc];
                    if (desc != -1) {
                        template.desc = desc * 2 + 1;
                        template.descSpecified = true;
                    }
                    else {
                        Debug.Print("Missing description for {0}", originalItem.id);
                    }
                }
                */

                if (originalItem.item_drop_permitted != null) {
                    bool value = originalItem.item_drop_permitted.ToBoolean(CultureInfo.InvariantCulture);
                    if (value) {
                        template.drop = true;
                        // template.dropSpecified = true;
                    }
                }

                template.usedelayid = originalItem.use_delay_type_id;
                if (template.usedelayid > 0) {
                    template.usedelayidSpecified = true;
                    template.usedelay = originalItem.use_delay;
                    template.usedelaySpecified = template.usedelay > 0;
                }

                if (originalItem.require_shard > 0) {
                    template.stigma = new Stigma();
                    template.stigma.shard = originalItem.require_shard;
                    template.stigma.shardSpecified = true;
                    ClientSkill stigmaSkill = Utility.SkillIndex[originalItem.gain_skill1];
                    if (stigmaSkill != null) {
                        // gain_skill2 and gain_level2 used only in the test item
                        template.stigma.skillid = stigmaSkill.id;
                        template.stigma.skillidSpecified = true;
                        template.stigma.skilllvl = originalItem.gain_level1;
                        template.stigma.skilllvlSpecified = true;

                        var utility = Utility<Item>.Instance;
                        List<string> requiredSkills = new List<string>();
                        utility.Export<String>(originalItem, "require_skill", requiredSkills);
                        if (requiredSkills.Count > 0) {
                            List<RequireSkill> skills = new List<RequireSkill>();
                            for (int n = 1; n <= requiredSkills.Count; n++) {
                                FieldInfo fld = typeof(Item).GetField(String.Format("require_skill{0}_lv", n),
                                    BindingFlags.Instance | BindingFlags.Public);
                                int skillLvl = (int)fld.GetValue(originalItem);
                                string[] skillIds = requiredSkills[n - 1].Split(new string[] { " ", "," },
                                                             StringSplitOptions.RemoveEmptyEntries);
                                List<int> ids = new List<int>();
                                foreach (string skillId in skillIds) {
                                    stigmaSkill = Utility.SkillIndex[skillId];
                                    if (stigmaSkill != null && stigmaSkill.id > 0)
                                        ids.Add(stigmaSkill.id);
                                }
                                if (ids.Count > 0)
                                    skills.Add(new RequireSkill() {
                                        skillId = ids.ToArray(),
                                        skilllvl = skillLvl,
                                        skilllvlSpecified = true
                                    });
                            }
                            if (skills.Count > 0)
                                template.stigma.require_skill = skills.ToArray();
                        }
                    }
                    else {
                        Debug.Print("Missing stigma for {0}", originalItem.id);
                    }
                }

                if (originalItem.can_dye) {
                    template.dye = true;
                }

                if (originalItem.craft_recipe_info != null) {
                    var recipe = Utility.RecipeIndex[originalItem.craft_recipe_info];
                    if (recipe != null) {
                        if (template.actions == null)
                            template.actions = new ItemActions[1];
                        if (template.actions[0] == null)
                            template.actions[0] = new ItemActions();
                        var action = new CraftLearnAction();
                        action.recipeid = recipe.id;
                        action.recipeidSpecified = true;
                        template.actions[0].craftlearn = new CraftLearnAction[1] { action };
                    }
                    else {
                        Debug.Print("Missing recipe for {0}", originalItem.id);
                    }
                }

                if (!String.IsNullOrEmpty(originalItem.dyeing_color) || originalItem.name == "dye_remover") {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new DyeAction();
                    if (originalItem.name == "dye_remover")
                        action.color = "no";
                    else
                        action.color = action.color = getHexRGB(originalItem.dyeing_color);
                    template.actions[0].dye = new DyeAction[1] { action };
                }

                // add item action for charging items
                if (originalItem.charge_capacity > 0) {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new ChargeAction();
                    action.capacity = originalItem.charge_capacity;
                    /*
                    if(originalItem.name.Contains("pack")){
                        action.isPack = true;
                    }else{
                        action.isPack = false;
                    }
                     */
                    template.actions[0].condition = new ChargeAction[1] { action };
                }

                // add trade items
                if (originalItem.tradeItems.Count > 0) {
                    List<TradeItem> tradelist = new List<TradeItem>();

                    foreach (var tradeItem in originalItem.tradeItems) {
                        TradeItem outputItem = new TradeItem();
                        outputItem.id = Utility.ItemIndex.GetItem(tradeItem.trade_in_item).id;
                        outputItem.price = tradeItem.trade_in_item_count;
                        tradelist.Add(outputItem);
                    }

                    TradeItemList newTradeItemList = new TradeItemList();
                    newTradeItemList.tradeItems = tradelist.ToArray();
                    template.tradeList = newTradeItemList;
                }

                // add item action for motions
                if (originalItem.name.Contains("customize_motion")) {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new MotionAction();

                    string typeofmotion = String.Empty;
                    typeofmotion = template.name.Contains("Ninja") ? "NINJA" : typeofmotion;
                    typeofmotion = template.name.Contains("Hovering") ? "HOVERING" : typeofmotion;
                    typeofmotion = template.name.Contains("Levitation") ? "LEVITATION" : typeofmotion;

                    switch (typeofmotion) {
                        case "NINJA":
                            action.idle = 1;
                            action.jump = 3;
                            action.rest = 4;
                            action.run = 2;
                            action.minutes = originalItem.anim_expire_time != 0 ? originalItem.anim_expire_time : 0;
                            break;
                        case "HOVERING":
                            action.idle = 5;
                            action.jump = 7;
                            action.rest = 8;
                            action.run = 6;
                            action.minutes = originalItem.anim_expire_time != 0 ? originalItem.anim_expire_time : 0;
                            break;
                        case "LEVITATION":
                            action.idle = 5;
                            action.jump = 7;
                            action.rest = 8;
                            action.run = 8;
                            action.minutes = originalItem.anim_expire_time != 0 ? originalItem.anim_expire_time : 0;
                            break;
                    }

                    Debug.Write("Missing animation action for itemId: " + template.id);

                    template.actions[0].motion = new MotionAction[1] { action };
                }

                // add item action for ride
                if (originalItem.name.Contains("ride_") && originalItem.ride_data_name != null) {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new RideAction();

                    // Associate with Ride data
                    // TODO: Add parser for rides.xml in client and crossreference ride id by name of ride
                    string[] rideSplit = originalItem.ride_data_name.Split('_');
                    switch (rideSplit[0].ToUpper()) {
                        case "CLOUD":
                            switch (rideSplit[1].ToUpper()) {
                                case "001":
                                    if (rideSplit.Length > 2) { action.rideId = 2000015; break; }
                                    action.rideId = 2000000; break;
                                case "002":
                                    if (rideSplit.Length > 2) { action.rideId = 2000018; break; }
                                    action.rideId = 2000001; break;
                                case "003":
                                    action.rideId = 2000002; break;
                            }
                            break;
                        case "PAGATI":
                            switch (rideSplit[1].ToUpper()) {
                                case "001":
                                    if (originalItem.ride_data_name.ToUpper() == "PAGATI_001_ET5") { action.rideId = 2000014; break; }
                                    if (rideSplit.Length > 2) { action.rideId = 2000024; break; }
                                    action.rideId = 2000003; break;
                                case "002":
                                    if (rideSplit.Length > 2) { action.rideId = 2000021; break; }
                                    action.rideId = 2000004; break;
                            }
                            break;
                        case "RAY":
                            switch (rideSplit[1].ToUpper()) {
                                case "001":
                                    action.rideId = 2000005; break;
                                case "002":
                                    action.rideId = 2000006; break;
                                case "003":
                                    action.rideId = 2000007; break;
                            }
                            break;
                        case "BIKE":
                            switch (rideSplit[1].ToUpper()) {
                                case "001":
                                    if (rideSplit.Length > 2) { action.rideId = 2000023; break; }
                                    action.rideId = 2000008; break;
                                case "002":
                                    if (rideSplit.Length > 2) { action.rideId = 2000020; break; }
                                    action.rideId = 2000009; break;
                            }
                            break;
                        case "WHALE":
                            switch (rideSplit[1].ToUpper()) {
                                case "001":
                                    if (originalItem.ride_data_name.ToUpper() == "WHALE_001_LIGHT") { action.rideId = 2000019; break; }
                                    if (rideSplit.Length > 2) { action.rideId = 2000016; break; }
                                    action.rideId = 2000010; break;
                                case "002":
                                    if (originalItem.ride_data_name.ToUpper() == "WHALE_002_ET60") { action.rideId = 2000014; break; }
                                    if (originalItem.ride_data_name.ToUpper() == "WHALE_002_WORLD") { action.rideId = 2000022; break; }
                                    if (rideSplit.Length > 2) { action.rideId = 2000017; break; }
                                    action.rideId = 2000011; break;
                                case "003":
                                    action.rideId = 2000012; break;
                            }
                            break;
                    }

                    template.actions[0].ride = new RideAction[1] { action };
                }

                if (!String.IsNullOrEmpty(originalItem.cosmetic_name)) {
                    CosmeticInfo info = Utility.CosmeticsIndex[originalItem.cosmetic_name.ToLower()];
                    if (info == null) {
                        Debug.Print("Cosmetics not found: {0}", originalItem.cosmetic_name);
                    }
                    else {
                        if (template.actions == null)
                            template.actions = new ItemActions[1];
                        if (template.actions[0] == null)
                            template.actions[0] = new ItemActions();
                        var action = new CosmeticAction();
                        if (info.hair_type > 0) {
                            action.cosmeticName = CosmeticType.hair_type;
                        }
                        if (info.face_type > 0) {
                            action.cosmeticName =  CosmeticType.face_type;
                        }
                        if (info.makeup_type > 0) {
                            action.cosmeticName =  CosmeticType.makeup_type;
                        }
                        if (info.tattoo_type > 0) {
                            action.cosmeticName =  CosmeticType.tattoo_type;
                        }
                        if (info.voice_type > 0) {
                            action.cosmeticName =  CosmeticType.voice_type;
                        }
                        if (!String.IsNullOrEmpty(info.face_color)) {
                            action.cosmeticName = CosmeticType.face_color;
                        }
                        if (!String.IsNullOrEmpty(info.hair_color)) {
                            action.cosmeticName = CosmeticType.hair_color;
                        }
                        if (!String.IsNullOrEmpty(info.lip_color)) {
                            action.cosmeticName = CosmeticType.lip_color;
                        }
                        if (!String.IsNullOrEmpty(info.eye_color)) {
                            action.cosmeticName = CosmeticType.eye_color;
                        }
                        if (!String.IsNullOrEmpty(info.preset_name)) {
                            action.cosmeticName = CosmeticType.preset_name;
                        }
                        template.actions[0].cosmetic = new CosmeticAction[1] { action };
                    }
                }

                if (originalItem.inven_warehouse_max_extendlevel != 0 &&
                    (template.category == "CUBE" || template.category == "CASH_CARD")) {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new TicketAction();
                    action.storage = template.category == "CUBE" ? StorageType.CUBE : StorageType.WAREHOUSE;
                    template.actions[0].ticket = new TicketAction[1] { action };
                }

                if (!String.IsNullOrEmpty(originalItem.proc_enchant_skill)) {
                    ClientSkill enchantSkill = Utility.SkillIndex[originalItem.proc_enchant_skill];
                    if (enchantSkill != null) {
                        template.godstone = new Godstone();
                        template.godstone.probability = originalItem.proc_enchant_effect_occur_prob;
                        if (template.godstone.probability > 0)
                            template.godstone.probabilitySpecified = true;
                        template.godstone.probabilityleft = originalItem.proc_enchant_effect_occur_left_prob;
                        template.godstone.skillid = enchantSkill.id;
                        template.godstone.skillidSpecified = true;
                        template.godstone.skilllvl = originalItem.proc_enchant_skill_level;
                        template.godstone.skilllvlSpecified = true;
                    }
                    else {
                        Debug.Print("Missing godstone for {0}", originalItem.id);
                    }
                }

                if (!String.IsNullOrEmpty(originalItem.skill_to_learn)) {
                    ClientSkill learnSkill = Utility.SkillIndex[originalItem.skill_to_learn];
                    if (learnSkill != null) {
                        if (template.actions == null)
                            template.actions = new ItemActions[1];
                        if (template.actions[0] == null)
                            template.actions[0] = new ItemActions();

                        var learns = Utility.SkillLearnIndex[originalItem.skill_to_learn];
                        if (learns.Count() > 0) {
                            var validActions = new List<SkillLearnAction>();
                            for (int i = 0; i < learns.Count(); i++) {
                                LearnSkill learn = learns.ElementAt(i);
                                if (learn.skill_level > 1)
                                    continue;
                                var action = new SkillLearnAction();
                                validActions.Add(action);
                                action.skillid = learnSkill.id;
                                action.skillidSpecified = true;
                                action.@class = (skillPlayerClass)Enum.Parse(typeof(skillPlayerClass), learn.@class);
                                action.classSpecified = true;

                                // zp fix reference
                                switch (action.@class) {
                                    case skillPlayerClass.FIGHTER:
                                        action.@class = skillPlayerClass.GLADIATOR;
                                        break;
                                    case skillPlayerClass.KNIGHT:
                                        action.@class = skillPlayerClass.TEMPLAR;
                                        break;
                                    case skillPlayerClass.WIZARD:
                                        action.@class = skillPlayerClass.SORCERER;
                                        break;
                                    case skillPlayerClass.ELEMENTALLIST:
                                        action.@class = skillPlayerClass.SPIRIT_MASTER;
                                        break;
                                }

                                action.level = learn.pc_level;
                                action.levelSpecified = true;
                                /*
                                action.race = learn.skillRace;
                                action.raceSpecified = true;
                                 */
                            }
                            template.actions[0].skilllearn = validActions.ToArray();
                        }
                    }
                    else {
                        Debug.Print("Missing learn skill for {0}", originalItem.id);
                    }
                }

                if (!String.IsNullOrEmpty(originalItem.toy_pet_name)) {
                    int npcId = Utility.ClientNpcIndex[originalItem.toy_pet_name];
                    if (npcId == -1)
                        Debug.Print("Missing pet NPC for {0}", originalItem.id);
                    else {
                        if (template.actions == null)
                            template.actions = new ItemActions[1];
                        if (template.actions[0] == null)
                            template.actions[0] = new ItemActions();
                        var action = new ToyPetSpawnAction();
                        action.npcid = npcId;
                        action.npcidSpecified = true;
                        template.actions[0].toypetspawn = new ToyPetSpawnAction[1] { action };
                    }
                }

                if (originalItem.return_worldid > 0) {
                    template.return_world = originalItem.return_worldid;
                    template.return_worldSpecified = true;
                    if (!String.IsNullOrEmpty(originalItem.return_alias))
                        template.return_alias = originalItem.return_alias.ToUpper();
                }

                if (template.category == "PINCER") {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new ExtractAction();
                    template.actions[0].extract = new ExtractAction[1] { action };
                }

                if (originalItem.sub_enchant_material_many > 0) {
                    if (template.actions == null)
                        template.actions = new ItemActions[1];
                    if (template.actions[0] == null)
                        template.actions[0] = new ItemActions();
                    var action = new EnchantItemAction();
                    //action.count = originalItem.sub_enchant_material_many;
                    template.actions[0].enchant = new EnchantItemAction[1] { action };
                }

                if (originalItem.AttackType != AttackTypes.none) {
                    template.attack_type = originalItem.AttackType.ToString().ToUpper();
                }

                if (originalItem.abyss_point > 0) {
                    template.ap = (int)originalItem.abyss_point;
                }

                if (originalItem.abyss_item_count > 0) {
                    template.aic = (int)originalItem.abyss_item_count;
                }

                if (!String.IsNullOrEmpty(originalItem.abyss_item)) {
                    Item abyssItem = Utility.ItemIndex.GetItem(originalItem.abyss_item);
                    if (abyssItem == null)
                        Debug.Print("Missing abyss item for {0}", originalItem.id);
                    else {
                        template.ai = abyssItem.id;
                    }
                }

                if (originalItem.extra_currency_item_count > 0) {
                    template.ric = (int)originalItem.extra_currency_item_count;
                }

                if (!String.IsNullOrEmpty(originalItem.extra_currency_item)) {
                    Item extraItem = Utility.ItemIndex.GetItem(originalItem.extra_currency_item);
                    if (extraItem == null)
                        Debug.Print("Missing extra item for {0}", originalItem.id);
                    else {
                        template.ri = extraItem.id;
                    }
                }
                /*
                if (originalItem.coupon_item_count > 0) {
                    template.cic = (int)originalItem.coupon_item_count;
                }

                if (!String.IsNullOrEmpty(originalItem.coupon_item)) {
                    Item extraItem = Utility.ItemIndex.GetItem(originalItem.coupon_item);
                    if (extraItem == null)
                        Debug.Print("Missing extra item for {0}", originalItem.id);
                    else {
                        template.ci = extraItem.id;
                    }
                }
                */
                if (originalItem.BonusApply != Bonuses.none) {
                    template.bonus_apply = (BonusApplyType)Enum.Parse(typeof(BonusApplyType),
                                           originalItem.BonusApply.ToString().ToUpper());
                    // template.bonus_applySpecified = true;
                }

                // template.name
            }

            saveTemplate.TemplateList = exportTemplates.OrderBy(i => i.id).ToArray();

            //var droplistDrops = Utility.DropListTemplate.Drops.SelectMany(d => d.DropItems);
            //var existingItems = exportTemplates.Select(t => t.id);
            //var nonexistant = droplistDrops.Where(d => !existingItems.Contains(d.id)).ToList();
            //foreach (var dropEntry in Utility.DropListTemplate.Drops) {
            //    dropEntry.DropItems.RemoveAll(i => nonexistant.Contains(i));
            //}

            using (FileStream stream = new FileStream(Path.Combine(outputPath, "item_templates.xml"),
                                              FileMode.Create, FileAccess.Write)) {
                using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) {
                    XmlSerializer ser = new XmlSerializer(typeof(ItemTemplates));
                    ser.Serialize(wr, saveTemplate);
                }
            }

            using (FileStream stream = new FileStream(Path.Combine(outputPath, "clean_world_drops.sql"),
                                              FileMode.Create, FileAccess.Write)) {
                using (var wr = new StreamWriter(stream, Encoding.ASCII)) {
                    wr.Write(sqlData.ToString());
                }
            }

            var emptyDrops = Utility.DropListTemplate.Drops.Where(d => d.DropItems.Count == 0).ToList();
            Utility.DropListTemplate.Drops.RemoveAll(d => emptyDrops.Contains(d));

            using (FileStream stream = new FileStream(Path.Combine(outputPath, "droplist.xml"),
                                              FileMode.Create, FileAccess.Write)) {
                using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) {
                    XmlSerializer ser = new XmlSerializer(typeof(Droplist));
                    ser.Serialize(wr, Utility.DropListTemplate);
                }
            }

            // Do some tests
            // TestUtility.TestWorkOrders(itemTemplates);
        }