public ItemBonus(ItemExport exported, BonusType type) { if (type != BonusType.NONE) { this.type = type; this.typeSpecified = true; } bonusLevel = exported.suffix.ToString(); }
private static void ExportItemGroups(XmlWriterSettings saveSettings, string outputPath) { itemGroups = new ItemsExportFile(); var forwardItems = new HashSet<string>(StringComparer.InvariantCultureIgnoreCase); SkillMap skillMap = new SkillMap(); skillMap.LoadFromFile(root); foreach (var item in Utility.ItemIndex.ItemList) { string[] nameParts = item.name.Split('_'); var exportItem = new ItemExport(); exportItem.itemId = item.id; exportItem.itemName = item.name; exportItem.armorType = item.ArmorType; exportItem.category = item.Category; exportItem.itemType = item.ItemType; exportItem.level = item.level; exportItem.quality = (Qualities)item.Quality; exportItem.raceInternal = item.race; exportItem.slot = item.EquipmentSlots; exportItem.weaponType = item.WeaponType; if (item.can_composite_weapon != null) exportItem.canFuse = item.can_composite_weapon.ToBoolean(CultureInfo.CurrentCulture); exportItem.itemIcon = item.icon_name; exportItem.mask = item.GetMask(); exportItem.expire_time = item.expire_time; exportItem.cash_item = item.cash_item; exportItem.cash_minute = item.cash_available_minute; exportItem.exchange_time = item.temporary_exchange_time; exportItem.race = item.race; exportItem.restricts = item.GetRestrictions(); exportItem.restricts_max = item.GetMaxRestrictions(); exportItem.modifiers = item.GetModifiers(skillMap); exportItem.originalItem = item; exportItem.tag = item.tag; if (!String.IsNullOrEmpty(item.activation_skill)) { ClientSkill skill = Utility.SkillIndex[item.activation_skill]; if (skill == null) { Debug.Print("Missing skill description: {0}", item.activation_skill); } else { // level can not be zero exportItem.skill_use = new SkillTemplate(skill.id, item.activation_level); } } Item it = Utility.ItemIndex.GetItem(item.name); if (it != null) { exportItem.desc = it.Description; } //if (exportItem.desc != null) { // if (exportItem.desc.StartsWith("Shadetouched ") || // exportItem.desc.StartsWith("Suntouched ")) { // exportItem.raceInternal = Race.All; // don't export selectable rewards // continue; // } //} if (exportItem.raceInternal != ItemRace.ALL) { // don't change } else { if (forwardItems.Contains(exportItem.itemName, StringComparer.InvariantCultureIgnoreCase)) { exportItem.raceInternal = ItemRace.ELYOS; forwardItems.Remove(exportItem.itemName); } else { bool dFound = false; bool startFound = false; int dIndex = 0; for (int i = 0; i < nameParts.Length; i++) { string np = nameParts[i]; if (!startFound && np.Length == 1) startFound = true; if (!startFound && np.Length > 1) continue; if (!dFound && np == "d") { dFound = true; dIndex = i; exportItem.raceInternal = ItemRace.ASMODIANS; continue; } if (dFound && np == "d") { if (item.ItemType != ItemTypes.draconic) { // NPC Balic items and one wrap box } } } if (exportItem.raceInternal == ItemRace.ASMODIANS) { string nameL = String.Join("_", nameParts, 0, dIndex); string nameR = String.Join("_", nameParts, dIndex + 1, nameParts.Length - dIndex - 1); string lightName = String.Concat(nameL, "_", nameR).TrimStart('_'); Item lightItem = Utility.ItemIndex.GetItem(lightName); if (lightItem != null) { // Debug.Print("Asmodian: {0}, Elyos: {1}", exportItem.itemId, lightItem.id); if (itemGroups.allNames.ContainsKey(lightName)) itemGroups.allNames[lightName].raceInternal = ItemRace.ELYOS; else forwardItems.Add(lightName.ToLower()); } else { lightName = String.Concat(nameL, "_l_", nameR).TrimStart('_'); lightItem = Utility.ItemIndex.GetItem(lightName); if (lightItem != null) { // Debug.Print("Asmodian: {0}, Elyos: {1}", exportItem.itemId, lightItem.id); if (itemGroups.allNames.ContainsKey(lightName)) itemGroups.allNames[lightName].raceInternal = ItemRace.ELYOS; else forwardItems.Add(lightName.ToLower()); } } } } } string suffix = nameParts.Last().ToLower(); bool isTaskItem = nameParts[0] == "item" && nameParts[1] == "part"; // always ends with _a or _b if (suffix.EndsWith("day")) { exportItem.rentDays = Int32.Parse(nameParts.Last().Replace("day", String.Empty)); Array.Resize(ref nameParts, nameParts.Length - 1); } else if (suffix.EndsWith("ae") || suffix.EndsWith("an") || suffix.EndsWith("ex")) { Array.Resize(ref nameParts, nameParts.Length - 1); } if (item.id == 110500631) { } if (nameParts.Length > 2) { exportItem.suffix = Utility.GetLevelFromName(nameParts.Last()); int lvl = exportItem.suffix >> 7; if (exportItem.suffix != 0) { string prior = nameParts[nameParts.Length - 2]; if (prior.Length < 3) { if (prior == "p" && lvl > 30 && nameParts[0] == "rec" && nameParts[nameParts.Length - 4] == "d") { int skillId = Utility.GetSkillIdFromName(item.name) & 0xF; if (lvl > 50) lvl = 60; exportItem.suffix = (skillId << 10) | (((int)exportItem.quality << 7) | lvl); exportItem.itemGroup = "hearts"; } else { char qPrefix = Char.ToLower(exportItem.quality.ToString()[0]); // check if _c1_c_10b, then group is "c" string before = nameParts[nameParts.Length - 3]; if (before[0] == qPrefix && (before.Length == 1 || before.Length == 2 && Char.IsDigit(before[1]))) { exportItem.itemGroup = prior; } } } else if (prior.Length == 6 && prior.EndsWith("stats") && nameParts[0] == "rec" && nameParts[4] == "dr" && lvl > 30) { int skillId = Utility.GetSkillIdFromName(item.name) & 0xF; exportItem.suffix = (skillId << 10) | (((int)exportItem.quality << 7) | lvl); exportItem.itemGroup = "hearts"; } else if (prior == "dark" || prior == "light") { // fix race, because it can contain _d_ for elyos exportItem.raceInternal = prior[0] == 'd' ? ItemRace.ASMODIANS : ItemRace.ELYOS; exportItem.itemGroup = prior; } if (nameParts[0] == "potion" || nameParts[0] == "remedy") { exportItem.itemGroup = "medicine"; } else if (nameParts[0] == "shopmaterial") { exportItem.itemGroup = "shopmaterial"; } else if (nameParts[0] == "junk") { if (nameParts[1] == "q" || nameParts[2] == "q") exportItem.itemGroup = "quest_junk"; else exportItem.itemGroup = "junk"; } else if (nameParts[0] == "key") { exportItem.itemGroup = "keys"; } else if (nameParts[0] == "test") { exportItem.itemGroup = "tests"; } else if (nameParts[0] == "jewelry") { exportItem.itemGroup = "ores"; } else if (nameParts[0] == "food" && exportItem.category != ItemCategories.harvest) { /*if (nameParts[1] == "r" || nameParts[1] == "d" && nameParts[2] == "r") exportItem.itemGroup = "food_tasty"; else */ if (nameParts[1] == "dr") { if (nameParts[2] == "r" || nameParts[2] == "d" && nameParts[3] == "r") exportItem.itemGroup = "food_draconic_tasty"; else exportItem.itemGroup = "food_draconic"; } else exportItem.itemGroup = "food"; } else if (nameParts[0] == "matter" && nameParts[1] == "option" && nameParts[2] == "r") { exportItem.itemGroup = "manastone_reward"; } else if (nameParts[0] == "matter" && nameParts[1] == "enchant") { exportItem.itemGroup = "enchant"; } else if (nameParts[0].ToLower() == "doc") { exportItem.itemGroup = "docs"; exportItem.suffix = 0; } else if (nameParts[0] == "harvest") { exportItem.itemGroup = "harvest"; exportItem.suffix = 0; } else if (nameParts[0] == "rmc") { exportItem.itemGroup = "legion_rewards"; } else if (isTaskItem) { exportItem.itemGroup = "craft_tasks"; } else if (nameParts[1] == "part") { exportItem.itemGroup = "task_rewards"; } else if (nameParts[0] == "wrap") { exportItem.itemGroup = "wrapped_rewards"; } } else if (nameParts[nameParts.Length - 2] == "m") { exportItem.isMaster = true; } else if (nameParts[0] == "stigma") { exportItem.itemGroup = "stigmas"; exportItem.suffix = 0; } else if (nameParts[0] == "skillbook") { exportItem.itemGroup = "skillbooks"; exportItem.suffix = 0; } if (exportItem.itemGroup == "c") exportItem.itemGroup = "coin_rewards"; if (exportItem.itemGroup == "g") exportItem.itemGroup = "boss"; if ((exportItem.itemGroup == "r" || exportItem.itemGroup == "R") && !exportItem.originalItem.Description.StartsWith("Level ")) { if (exportItem.originalItem.level >= 52) exportItem.raceInternal = ItemRace.ALL; exportItem.itemGroup = "random_drop"; } } else { if (nameParts[0].ToLower() == "quest") { exportItem.itemGroup = "quest_items"; exportItem.suffix = 0; } else if (nameParts[0] == "coin") { exportItem.itemGroup = "coins"; exportItem.suffix = 0; } else if (nameParts[0] == "medal") { exportItem.itemGroup = "medals"; exportItem.suffix = 0; } } if (exportItem.rentDays > 0) { exportItem.itemGroup = "rent"; } if (exportItem.tag != ItemTag.none) { exportItem.itemGroup = exportItem.tag.ToString(); } itemGroups.items.Add(exportItem); itemGroups.allNames.Add(exportItem.itemName, exportItem); } var lowerLevel = itemGroups.items.Where(i => i.level > i.minLevel); StringBuilder sb = new StringBuilder(); foreach (var it in lowerLevel) { sb.AppendFormat("{0} - {1} ({2})\r\n", it.itemId, it.desc, it.category); } var groupedLookup = itemGroups.items.ToLookup(it => it.itemGroup, it => it); var abyssGroup = groupedLookup.Where(g => g.Key == "a"); Dictionary<string, ItemRace> worldDrops = new Dictionary<string, ItemRace>() { { "Soul", ItemRace.ALL }, { "Sky", ItemRace.ALL }, { "Eldritch", ItemRace.ALL }, { "Grounded", ItemRace.ALL }, { "Angry", ItemRace.ALL }, { "Battlefield", ItemRace.ALL }, { "Zealous", ItemRace.ALL }, { "Wraith's", ItemRace.ALL }, { "Fascination", ItemRace.ALL }, { "Eternity", ItemRace.ALL }, { "Blood Seeking", ItemRace.ALL }, { "Divisive", ItemRace.ALL }, { "Celestial", ItemRace.ALL }, { "Everwatcher's", ItemRace.ALL }, { "Old Guard's", ItemRace.ALL }, { "Invader's", ItemRace.ALL }, { "Ancient Daeva's", ItemRace.ALL }, { "Carved", ItemRace.ALL }, { "Anonymous", ItemRace.ALL }, { "Reddened", ItemRace.ALL }, { "White", ItemRace.ALL }, { "Red Dragon Legion", ItemRace.ALL }, { "Rain", ItemRace.ALL }, { "Immemorial", ItemRace.ALL }, { "Departed Soul's", ItemRace.ALL }, { "Purehorn's", ItemRace.ALL }, { "Calamity", ItemRace.ALL }, { "Sleeper's", ItemRace.ALL }, { "Buried", ItemRace.ALL }, { "Immortal", ItemRace.ALL }, { "Fallen Legionary's", ItemRace.ALL }, { "Nebulous", ItemRace.ALL }, { "Reaper's", ItemRace.ALL }, { "Odious", ItemRace.ALL }, { "Protector's", ItemRace.ALL }, { "Martyr's", ItemRace.ALL }, { "Oblate", ItemRace.ALL }, { "Dimensional", ItemRace.ALL }, { "Giant Lord's", ItemRace.ALL }, { "Ancient Giant's", ItemRace.ALL }, { "Restoration", ItemRace.ALL }, { "Miracle", ItemRace.ALL }, { "Comet", ItemRace.ALL }, { "Meteor", ItemRace.ALL }, { "Ancient Hero's", ItemRace.ALL }, { "Giant's", ItemRace.ALL }, { "Elder", ItemRace.ALL }, { "Catastrophic", ItemRace.ALL }, { "Horrific", ItemRace.ALL }, { "Chaos", ItemRace.ALL }, { "Dolan", ItemRace.ALL }, { "Judgment", ItemRace.ALL }, { "Demolition", ItemRace.ALL }, { "Gracefull", ItemRace.ALL }, { "Death", ItemRace.ALL }, { "Life", ItemRace.ALL }, { "Destructive", ItemRace.ALL }, { "Storm", ItemRace.ALL }, { "Sage", ItemRace.ALL }, { "Sunset", ItemRace.ALL }, { "Angel's", ItemRace.ALL }, { "Guarded", ItemRace.ALL }, { "Dispelling", ItemRace.ALL }, { "Archbishop", ItemRace.ALL }, { "Restless", ItemRace.ALL }, { "Prayer", ItemRace.ALL }, { "Torment", ItemRace.ALL } }; foreach (var abyssSuffix in abyssGroup) { foreach (string name in worldDrops.Keys) { var abyssItems = abyssSuffix.Where(a => a.desc.StartsWith(name)); foreach (var abyssItem in abyssItems) abyssItem.itemGroup = "random_drop"; } } foreach (var entry in groupedLookup) { IEnumerable<ItemExport> group = groupedLookup[entry.Key]; ItemGroups itGroup = new ItemGroups(); if (entry.Key != null) itGroup.group = entry.Key; var suffixLookup = group.ToLookup(it => it.suffix, it => it); foreach (var suffixEntry in suffixLookup) { IEnumerable<ItemExport> suffixGroup = suffixLookup[suffixEntry.Key]; ItemSuffixes itSuffix = new ItemSuffixes(); itSuffix.suffix = suffixEntry.Key; foreach (var item in suffixGroup) { //item.itemGroup = null; //item.suffix = 0; itSuffix.items.Add(item); } itGroup.items.Add(itSuffix); } itGroup.items = itGroup.items.OrderBy(it => it.suffix).ToList(); itemGroups.grouped.Add(itGroup); } itemGroups.items.Clear(); itemGroups.allNames.Clear(); using (FileStream stream = new FileStream(Path.Combine(outputPath, "items.xml"), FileMode.Create, FileAccess.Write)) { using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) { XmlSerializer ser = new XmlSerializer(typeof(ItemsExportFile)); ser.Serialize(wr, itemGroups); } } }