public AggregatedTaskItem(RecipeItem rcItem, ItemRace race, string skill, int skillPoints) { this.ItemId = rcItem.id; this.SkillId = (Utility.GetSkillIdFromName("_" + skill + "_") & 0xF); this.SkillPoints = skillPoints; this.Race = race; this.IsRecipe = rcItem.isRecipe; }
static void Main(string[] args) { Utility.WriteExeDetails(); InvBonuses bonuses = new InvBonuses(); bonuses.BonusItems = new List<BonusData>(); var utility = Utility<Quest>.Instance; Console.WriteLine("Loading strings..."); Utility.LoadStrings(root); Console.WriteLine("Loading items..."); Utility.LoadItems(root); var test = Utility.ItemIndex.ItemList.Where(i => i.name.IndexOf("_head_") != -1 && i.Description != null /*&& i.Description.IndexOf("hairpin", StringComparison.InvariantCultureIgnoreCase) != -1*/ ); StringBuilder heads = new StringBuilder(); foreach (var hh in test) { string trimmed = hh.name.Remove(hh.name.Length - 4, 4); if (trimmed.EndsWith("_a_r2") || trimmed.EndsWith("_a_l2")) heads.AppendLine(String.Format("{0}\t{1}\t{2}", hh.name, hh.Description, hh.Quality)); } CultureInfo ci = new CultureInfo(""); int lvl = 0; var junks = Utility.ItemIndex.ItemList.Where(i => i.Quality == ItemQualities.junk && i.quest == 0); var lvlJunks = from it in junks let under = it.desc.LastIndexOf('_') let hasNumber = under == -1 ? false : Int32.TryParse(it.desc.Substring(under + 1), out lvl) where hasNumber && it.desc.StartsWith("STR_JUNK_") select new { Item = it, Level = lvl, Name = it.desc.Substring(9, under - 9) }; Console.WriteLine("Loading pet feeds..."); Utility.LoadClientPetFeed(root); var expFeed = Utility<ToypetFeed>.Instance; expFeed.AddGetter("favorite_flavor_id"); expFeed.AddGetter("favorite_flavor_desc"); var ourFeed = new PetFeed(); string[] groupNames = Enum.GetNames(typeof(FoodType)); ourFeed.ItemGroups = groupNames.Select(n => new ItemGroup() { type = ((FoodType)Enum.Parse(typeof(FoodType), n)) }).Where(g => g.type != FoodType.ALL && g.type != FoodType.NONE && g.type != FoodType.DOPING) .ToArray(); foreach (ItemGroup group in ourFeed.ItemGroups) { if (group.type == FoodType.ARMOR) { var ncArmors = lvlJunks.Where(i => armors.Contains(i.Name)); group.itemids = String.Join(",", ncArmors.Select(i => i.Item.id.ToString()).ToArray()); foreach (var armor in ncArmors) { List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type, level = armor.Level }; if (feedItems.ContainsKey(armor.Item.id)) feeds = feedItems[armor.Item.id]; else { feeds = new List<ItemFeed>(); feedItems.Add(armor.Item.id, feeds); } feeds.Add(feedItem); } } else if (group.type == FoodType.BALAUR) { var ncScales = lvlJunks.Where(i => balaurscales.Contains(i.Name)); group.itemids = String.Join(",", ncScales.Select(i => i.Item.id.ToString()).ToArray()); foreach (var scale in ncScales) { List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type, level = scale.Level }; if (feedItems.ContainsKey(scale.Item.id)) feeds = feedItems[scale.Item.id]; else { feeds = new List<ItemFeed>(); feedItems.Add(scale.Item.id, feeds); } feeds.Add(feedItem); } } else if (group.type == FoodType.BISCUIT) { group.itemids = String.Join(",", biscuits.Select(i => i.ToString()).ToArray()); foreach (var bis in biscuits) { List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type }; if (feedItems.ContainsKey(bis)) feeds = feedItems[bis]; else { feeds = new List<ItemFeed>(); feedItems.Add(bis, feeds); } feeds.Add(feedItem); } } else if (group.type == FoodType.BONE) { var ncBones = lvlJunks.Where(i => bones.Contains(i.Name)); group.itemids = String.Join(",", ncBones.Select(i => i.Item.id.ToString()).ToArray()); foreach (var bone in ncBones) { List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type, level = bone.Level }; if (feedItems.ContainsKey(bone.Item.id)) feeds = feedItems[bone.Item.id]; else { feeds = new List<ItemFeed>(); feedItems.Add(bone.Item.id, feeds); } feeds.Add(feedItem); } } else if (group.type == FoodType.CRYSTAL) { group.itemids = "182006376"; List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type }; if (feedItems.ContainsKey(182006376)) feeds = feedItems[182006376]; else { feeds = new List<ItemFeed>(); feedItems.Add(182006376, feeds); } feeds.Add(feedItem); } else if (group.type == FoodType.FLUID) { var ncFluids = lvlJunks.Where(i => fluids.Contains(i.Name)); group.itemids = String.Join(",", ncFluids.Select(i => i.Item.id.ToString()).ToArray()); foreach (var fluid in ncFluids) { List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type, level = fluid.Level }; if (feedItems.ContainsKey(fluid.Item.id)) feeds = feedItems[fluid.Item.id]; else { feeds = new List<ItemFeed>(); feedItems.Add(fluid.Item.id, feeds); } feeds.Add(feedItem); } } else if (group.type == FoodType.GEM) { group.itemids = "182006377"; List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type }; if (feedItems.ContainsKey(182006377)) feeds = feedItems[182006377]; else { feeds = new List<ItemFeed>(); feedItems.Add(182006377, feeds); } feeds.Add(feedItem); } else if (group.type == FoodType.HEALTHY1 || group.type == FoodType.HEALTHY2) { group.itemids = String.Join(",", healthyfood.Select(i => i.ToString()).ToArray()); foreach (var hf in healthyfood) { List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type }; if (feedItems.ContainsKey(hf)) feeds = feedItems[hf]; else { feeds = new List<ItemFeed>(); feedItems.Add(hf, feeds); } feeds.Add(feedItem); } } else if (group.type == FoodType.POWDER) { group.itemids = "182006375"; List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type }; if (feedItems.ContainsKey(182006375)) feeds = feedItems[182006375]; else { feeds = new List<ItemFeed>(); feedItems.Add(182006375, feeds); } feeds.Add(feedItem); } else if (group.type == FoodType.SOUL) { var ncSouls = lvlJunks.Where(i => souls.Contains(i.Name)); group.itemids = String.Join(",", ncSouls.Select(i => i.Item.id.ToString()).ToArray()); foreach (var soul in ncSouls) { List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type, level = soul.Level }; if (feedItems.ContainsKey(soul.Item.id)) feeds = feedItems[soul.Item.id]; else { feeds = new List<ItemFeed>(); feedItems.Add(soul.Item.id, feeds); } feeds.Add(feedItem); } } else if (group.type == FoodType.THORN) { var ncThorns = lvlJunks.Where(i => souls.Contains(i.Name)); group.itemids = String.Join(",", ncThorns.Select(i => i.Item.id.ToString()).ToArray()); foreach (var thorn in ncThorns) { List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type, level = thorn.Level }; if (feedItems.ContainsKey(thorn.Item.id)) feeds = feedItems[thorn.Item.id]; else { feeds = new List<ItemFeed>(); feedItems.Add(thorn.Item.id, feeds); } feeds.Add(feedItem); } } else if (group.type == FoodType.MISC) { group.itemids = "MISC"; } else if (group.type == FoodType.MISC1) { group.itemids = "182006362"; List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type }; if (feedItems.ContainsKey(182006362)) feeds = feedItems[182006362]; else { feeds = new List<ItemFeed>(); feedItems.Add(182006362, feeds); } feeds.Add(feedItem); } else if (group.type == FoodType.MISC2) { group.itemids = String.Join(",", testfeed.Select(i => i.ToString()).ToArray()); foreach (var t in testfeed) { List<ItemFeed> feeds; var feedItem = new ItemFeed() { type = group.type }; if (feedItems.ContainsKey(t)) feeds = feedItems[t]; else { feeds = new List<ItemFeed>(); feedItems.Add(t, feeds); } feeds.Add(feedItem); } } } Dictionary<FoodType, OrderedDictionary> priceLevelStats = new Dictionary<FoodType, OrderedDictionary>(); foreach (var gr in ourFeed.ItemGroups) { if (gr.itemids == null) continue; OrderedDictionary levelStats = null; if (!priceLevelStats.ContainsKey(gr.type)) { levelStats = new OrderedDictionary(); priceLevelStats.Add(gr.type, levelStats); } else { levelStats = priceLevelStats[gr.type]; } List<int> itemIds = new List<int>(); if (gr.itemids == "MISC") { itemIds.AddRange(Utility.ItemIndex.ItemList.Where(i => i.quest == 0 && i.Quality == ItemQualities.junk) .Select(i => i.id)); } else { itemIds.AddRange(gr.itemids.Split(',').Select(i => Int32.Parse(i))); } foreach (int id in itemIds) { Item item = Utility.ItemIndex.GetItem(id); MinMaxMean stats = null; if (!levelStats.Contains(item.level)) { stats = new MinMaxMean(); levelStats.Add(item.level, stats); } else { stats = (MinMaxMean)levelStats[(object)item.level]; } stats.AddValue(item.price, item); } } StringBuilder print = new StringBuilder(); foreach (var pair in priceLevelStats) { print.AppendLine(String.Format("Food type {0}", pair.Key.ToString())); foreach (DictionaryEntry entry in pair.Value) { MinMaxMean stat = (MinMaxMean)entry.Value; print.AppendLine(String.Format("\tLevel {0}: Min={1} ({2}), Max={3} ({4}), Mean={5}", entry.Key, stat.Min, stat.MinItem.id, stat.Max, stat.MaxItem.id, stat.Mean)); } print.AppendLine(); } foreach (ToypetFeed feed in Utility.PetFeed.Items) { PetFlavour flavour = new PetFlavour(); flavour.id = feed.id; flavour.count = feed.feeding_count; flavour.cd = feed.feeding_cooltime; flavour.love_count = feed.limit_love_count; // flavour.name = Utility.StringIndex.GetString(feed.name); flavour.desc = Utility.StringIndex.GetString(feed.desc); List<PetFood> list = new List<PetFood>(); expFeed.Export<PetFood>(feed, "favorite_flavor_id", list); expFeed.Export<PetFood>(feed, "favorite_flavor_desc", list); List<PetFood> lovedList = new List<PetFood>(); expFeed.Export<PetFood>(feed, "love_flavor_id_", lovedList); expFeed.Export<PetFood>(feed, "love_flavor_desc_", lovedList); list.AddRange(lovedList); flavour.food = list.Where(f => f.type != FoodType.NONE && (f.type != FoodType.ALL || f.rewards.Count > 0)) .ToList(); ourFeed.Flavours.Add(flavour); } HashSet<int> exportedRwds = new HashSet<int>(); foreach (var f in ourFeed.Flavours) { foreach (var i in f.food) { int nonEventItems = 0; foreach (var ri in i.rewards) { Item item = Utility.ItemIndex.GetItem(ri.item); if (!item.Description.StartsWith("[Event]")) nonEventItems++; } bool usePercent = true; int healthyStartItem = 182006413; int count = i.loved ? f.love_count : f.count; for (int x = 0; x < i.rewards.Count; x++) { PetReward r = i.rewards[x]; int priceItem = 0; switch (i.type) { case FoodType.POWDER: priceItem = 182006375; break; case FoodType.CRYSTAL: priceItem = 182006376; break; case FoodType.GEM: priceItem = 182006377; break; case FoodType.HEALTHY1: case FoodType.HEALTHY2: priceItem = healthyStartItem++; break; default: usePercent = false; priceItem = r.item; count = 1; break; } Item item = Utility.ItemIndex.GetItem(r.item); if (!item.Description.StartsWith("[Event]")) { decimal percent = 100; if (usePercent) percent -= 100M / nonEventItems * (nonEventItems - x - 1); decimal finalPrice = Utility.ItemIndex.GetItem(priceItem).price * count * percent / 100; r.price = (long)Math.Round(finalPrice, 0); } exportedRwds.Add(r.item); } } } var prwd = Utility.ItemIndex.ItemList.Where(i => i.tag == ItemTag.pet && !exportedRwds.Contains(i.id)); StringBuilder ps = new StringBuilder(); foreach (var p in prwd) ps.AppendLine(String.Format("{0}: {1}\t{2}\t{3}", p.id, p.Description, p.name, p.Quality)); var saveSettings = new XmlWriterSettings() { CheckCharacters = false, CloseOutput = false, Encoding = new UTF8Encoding(false), Indent = true, IndentChars = "\t", NewLineChars = "\n", }; string outputPath = Path.Combine(root, @".\output\"); if (!Directory.Exists(outputPath)) Directory.CreateDirectory(outputPath); using (FileStream stream = new FileStream(Path.Combine(outputPath, "pet_feed.xml"), FileMode.Create, FileAccess.Write)) { using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) { XmlSerializer ser = new XmlSerializer(typeof(PetFeed)); ser.Serialize(wr, ourFeed); } } Console.WriteLine("Loading quests..."); Utility.LoadQuestFile(root); Console.WriteLine("Loading cosmetics..."); Utility.LoadClientCosmetics(root); Console.WriteLine("Loading recipes..."); Utility.LoadCombinedRecipes(root); Console.WriteLine("Loading skills..."); Utility.LoadSkills(root); Console.WriteLine("Loading skill learns..."); Utility.LoadSkillLearns(root); Console.WriteLine("Loading NPCs..."); Utility.LoadClientNpcs(root); Console.WriteLine("Loading droplist..."); Utility.LoadDroplist(root); Console.WriteLine("Loading presets..."); string presetsPath = Path.Combine(root, @"data\presets"); string[] presetFiles = Directory.GetFiles(presetsPath, "preset_*.xml"); ClientPresetFile combinedPresets = null; foreach (string presetPath in presetFiles) { Utility.LoadClientPreset(presetPath); if (combinedPresets == null) { combinedPresets = Utility.Presets; } else { ClientPresetFile newPreset = Utility.Presets; combinedPresets.Presets.Add(newPreset.Presets.First()); } } List<OurPreset> ourPresets = new List<OurPreset>(); foreach (Preset preset in combinedPresets.Presets) { OurPreset ourPreset = new OurPreset() { name = preset.name.ToUpper(), @class = (Class)Enum.Parse(typeof(Class), preset.pc_class.ToString(), true), detail = preset.detail.ToLower(), gender = preset.pc_type == PcType.pc_dm || preset.pc_type == PcType.pc_lm ? Gender.MALE : Gender.FEMALE, race = preset.pc_type == PcType.pc_df || preset.pc_type == PcType.pc_dm ? ItemRace.ASMODIANS : ItemRace.ELYOS, hair_color = getHexRGB(preset.hair_color), lip_color = getHexRGB(preset.lip_color), skin_color = getHexRGB(preset.skin_color), height = (float)preset.scale, hair_type = preset.hair_type, face_type = preset.face_type }; ourPresets.Add(ourPreset); } Utility.Presets.Presets = null; Utility.Presets.OurPresets = ourPresets; Console.WriteLine("Saving presets..."); using (FileStream stream = new FileStream(Path.Combine(outputPath, "presets.xml"), FileMode.Create, FileAccess.Write)) { using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) { XmlSerializer ser = new XmlSerializer(typeof(ClientPresetFile)); ser.Serialize(wr, Utility.Presets); } } Console.WriteLine("Saving item groups..."); ExportItemGroups(saveSettings, outputPath); Console.WriteLine("Saving recipes..."); ExportRecipes(saveSettings, outputPath); Console.WriteLine("Saving grouped task items... "); taskExport = new TaskExport(); foreach (var recipe in Utility.RecipeIndex.RecipeList) { if (recipe.qualification_race == RecipeRace.all) continue; Task task = null; string skill = recipe.name; if (skill.StartsWith("rd")) skill = skill.Remove(0, 1); skill = skill.Remove(0, 2).Substring(0, 2); if (recipe.qualification_race == RecipeRace.pc_light) task = taskExport.RaceTasks[0][recipe.required_skillpoint, skill]; else task = taskExport.RaceTasks[1][recipe.required_skillpoint, skill]; List<string> searchSuffixes = new List<string>(); if (skill == "ha") { searchSuffixes.Add("jr"); searchSuffixes.Add("hw"); } searchSuffixes.Add(skill); HashSet<string> items = new HashSet<string>(); foreach (string suffix in searchSuffixes) { // products only if used to produce other products // This won't add items as "item_d_ha_q6302" if (recipe.product.Contains("_" + suffix + "_") && !recipe.product.StartsWith("item_")) items.Add(recipe.product); if (recipe.component1.StartsWith(suffix + "_part") || recipe.component1.StartsWith("shopmaterial_" + suffix + "_")) items.Add(recipe.component1); if (recipe.component2 != null && (recipe.component2.StartsWith(suffix + "_part") || recipe.component2.StartsWith("shopmaterial_" + suffix + "_"))) items.Add(recipe.component2); if (recipe.component3 != null && (recipe.component3.StartsWith(suffix + "_part") || recipe.component3.StartsWith("shopmaterial_" + suffix + "_"))) items.Add(recipe.component3); if (recipe.component4 != null && (recipe.component4.StartsWith(suffix + "_part") || recipe.component4.StartsWith("shopmaterial_" + suffix + "_"))) items.Add(recipe.component4); if (recipe.component5 != null && (recipe.component5.StartsWith(suffix + "_part") || recipe.component5.StartsWith("shopmaterial_" + suffix + "_"))) items.Add(recipe.component5); if (recipe.component6 != null && (recipe.component6.StartsWith(suffix + "_part") || recipe.component6.StartsWith("shopmaterial_" + suffix + "_"))) items.Add(recipe.component6); if (recipe.component7 != null && (recipe.component7.StartsWith(suffix + "_part") || recipe.component7.StartsWith("shopmaterial_" + suffix + "_"))) items.Add(recipe.component7); } items.Add("rec_" + recipe.name); // All shopmaterials fall into range: min = 169400010; max = 169405025 foreach (string item in items) { Item inItem = Utility.ItemIndex.GetItem(item); if (inItem != null) { if (task.ContainsItem(inItem.id)) continue; // exclude recipes which are autolearned if (inItem.craft_recipe_info != null && Utility.RecipeIndex[inItem.craft_recipe_info].auto_learn > 0) continue; RecipeItem rcItem = new RecipeItem(); rcItem.id = inItem.id; rcItem.level = inItem.level; rcItem.name = inItem.name; rcItem.price = inItem.price; rcItem.desc = inItem.Description; rcItem.race = task.race; rcItem.isRecipe = inItem.craft_recipe_info != null; task.Items.Add(rcItem); } else { Debug.Print("Missing recipe item: '{0}'", item); } } } taskExport.RaceTasks[0].Tasks = taskExport.RaceTasks[0].Tasks.OrderBy(t => t.SortString).ToList(); taskExport.RaceTasks[1].Tasks = taskExport.RaceTasks[1].Tasks.OrderBy(t => t.SortString).ToList(); using (FileStream stream = new FileStream(Path.Combine(root, @".\output\tasks.xml"), FileMode.Create, FileAccess.Write)) { using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) { XmlSerializer ser = new XmlSerializer(typeof(TaskExport)); ser.Serialize(wr, taskExport); } } Console.WriteLine("Modifying item templates..."); InjectBonusesToItemTemplate(saveSettings, outputPath); Console.Write("Parsing quests... "); int top = Console.CursorTop; int left = Console.CursorLeft; foreach (var q in Utility.QuestIndex.QuestList) { Console.SetCursorPosition(left, top); Console.Write("Q" + q.id); //WrappedBonus wi = null; //if (q.reward_item_ext_1 != null && q.reward_item_ext_1.StartsWith("wrap_")) { // wi = new WrappedBonus(); // string[] itemData = q.reward_item_ext_1.Split(' '); // Item item = Utility.ItemIndex.GetItem(itemData[0]); // if (item == null) // wi.originalItemId = 0; // else // wi.originalItemId = item.id; // wi.bonusLevel = Utility.GetLevelFromName(itemData[0]); // if (itemData[0].Contains("_enchant_")) // wi.type = BonusType.ENCHANT; // else if (itemData[0].Contains("_matter_option_")) // wi.type = BonusType.MANASTONE; // else // wi = null; // _matter_matter_ do not contain names in client_strings yet //} if (q.HasRandomRaward()) { BonusData bi = new BonusData(); bi.questId = q.id; bi.BonusInfos = new List<AbstractInventoryBonus>(); var container = new DummyContainer(); container.checkItems = new List<CheckItem>(); utility.Export(q, "reward_item", container.checkItems); utility.Export(q, "check_item", container.checkItems); bi.BonusInfos = container.checkItems.Where(item => item.bonuses.Count > 0) .SelectMany(item => item.bonuses).ToList(); //if (wi != null) { // bi.BonusInfos.Add(wi); //} bonuses.BonusItems.Add(bi); } /*else if (wi != null) { BonusData bi = new BonusData(); bi.questId = q.id; bi.BonusInfos = new List<AbstractInventoryBonus>() { wi }; bonuses.BonusItems.Add(bi); }*/ Thread.Sleep(1); } Console.Clear(); Console.WriteLine("Saving bonuses template... "); using (FileStream stream = new FileStream(Path.Combine(outputPath, "bonuses.xml"), FileMode.Create, FileAccess.Write)) { using (XmlWriter wr = XmlWriter.Create(stream, saveSettings)) { XmlSerializer ser = new XmlSerializer(typeof(InvBonuses)); ser.Serialize(wr, bonuses); } } Console.WriteLine("Done. Press any key..."); Console.Read(); }