// Roll new values for existing bonus stats public static List <ItemStat> RollNewBonusValues(Item item, short ignoreStat, bool isSpecialStat) { List <ItemStat> newBonus = new List <ItemStat>(); foreach (NormalStat stat in item.Stats.BonusStats.Where(x => x.GetType() == typeof(NormalStat))) { if (!isSpecialStat && (short)stat.Id == ignoreStat) { newBonus.Add(stat); continue; } newBonus.Add(NormalStat.Of(GetRange(item.Id)[stat.Id][Roll(item.Level)])); } foreach (SpecialStat stat in item.Stats.BonusStats.Where(x => x.GetType() == typeof(SpecialStat))) { if (isSpecialStat && (short)stat.Id == ignoreStat) { newBonus.Add(stat); continue; } newBonus.Add(SpecialStat.Of(GetSpecialRange(item.Id)[stat.Id][Roll(item.Level)])); } return(newBonus); }
// Roll new bonus stats and values except the locked stat public static List <ItemStat> RollBonusStatsWithStatLocked(Item item, short ignoreStat, bool isSpecialStat) { int id = item.Id; int level = item.Level; bool isTwoHand = item.IsTwoHand; if (!ItemOptionsMetadataStorage.GetRandomBonus(id, out List <ItemOption> randomBonusList)) { return(null); } Random random = new Random(); ItemOption itemOption = randomBonusList.FirstOrDefault(options => options.Rarity == item.Rarity && options.Slots > 0); if (itemOption == null) { return(null); } List <ItemStat> itemStats = new List <ItemStat>(); List <ItemAttribute> attributes = isSpecialStat ? itemOption.Stats : itemOption.Stats.Where(x => (short)x != ignoreStat).ToList(); List <SpecialItemAttribute> specialAttributes = isSpecialStat ? itemOption.SpecialStats.Where(x => (short)x != ignoreStat).ToList() : itemOption.SpecialStats; foreach (ItemAttribute attribute in attributes) { Dictionary <ItemAttribute, List <ParserStat> > dictionary = GetRange(id); if (!dictionary.ContainsKey(attribute)) { continue; } NormalStat normalStat = NormalStat.Of(dictionary[attribute][Roll(level)]); if (isTwoHand) { normalStat.Flat *= 2; normalStat.Percent *= 2; } itemStats.Add(normalStat); } foreach (SpecialItemAttribute attribute in specialAttributes) { Dictionary <SpecialItemAttribute, List <ParserSpecialStat> > dictionary = GetSpecialRange(id); if (!dictionary.ContainsKey(attribute)) { continue; } SpecialStat specialStat = SpecialStat.Of(dictionary[attribute][Roll(level)]); if (isTwoHand) { specialStat.Flat *= 2; specialStat.Percent *= 2; } itemStats.Add(specialStat); } return(itemStats.OrderBy(x => random.Next()).Take(item.Stats.BonusStats.Count).ToList()); }
// Roll new bonus stats and values except the locked stat public static List <ItemStat> RollBonusStatsWithStatLocked(int itemId, int rarity, int slots, int level, short ignoreStat, bool isSpecialStat) { if (!ItemOptionsMetadataStorage.GetRandomBonus(itemId, out List <ItemOption> randomBonusList)) { return(null); } Random random = new Random(); ItemOption itemOption = randomBonusList.FirstOrDefault(options => options.Rarity == rarity && options.Slots > 0); if (itemOption == null) { return(null); } List <ItemStat> itemStats = new List <ItemStat>(); List <ItemAttribute> attributes = isSpecialStat ? itemOption.Stats : itemOption.Stats.Where(x => (short)x != ignoreStat).ToList(); List <SpecialItemAttribute> specialAttributes = isSpecialStat ? itemOption.SpecialStats.Where(x => (short)x != ignoreStat).ToList() : itemOption.SpecialStats; foreach (ItemAttribute attribute in attributes) { itemStats.Add(NormalStat.Of(GetRange(itemId)[attribute][Roll(level)])); } foreach (SpecialItemAttribute attribute in specialAttributes) { itemStats.Add(SpecialStat.Of(GetSpecialRange(itemId)[attribute][Roll(level)])); } return(itemStats.OrderBy(x => random.Next()).Take(slots).ToList()); }
// Roll new bonus stats and values public static List <ItemStat> RollBonusStats(int itemId, int rarity, int level) { if (!ItemOptionsMetadataStorage.GetRandomBonus(itemId, out List <ItemOption> randomBonusList)) { return(null); } Random random = new Random(); ItemOption itemOption = randomBonusList.FirstOrDefault(options => options.Rarity == rarity && options.Slots > 0); if (itemOption == null) { return(null); } List <ItemStat> itemStats = new List <ItemStat>(); foreach (ItemAttribute attribute in itemOption.Stats) { itemStats.Add(NormalStat.Of(GetRange(itemId)[attribute][Roll(level)])); } foreach (SpecialItemAttribute attribute in itemOption.SpecialStats) { itemStats.Add(SpecialStat.Of(GetSpecialRange(itemId)[attribute][Roll(level)])); } return(itemStats.OrderBy(x => random.Next()).Take(itemOption.Slots).ToList()); }
public void GetStaticStats(int itemId, int rarity, List <NormalStat> normalStats, List <SpecialStat> specialStats) { //Get Static Stats int staticId = ItemMetadataStorage.GetOptionStatic(itemId); ItemOptionsStatic staticOptions = ItemOptionStaticMetadataStorage.GetMetadata(staticId, rarity); if (staticOptions == null) { BasicStats.AddRange(normalStats); BasicStats.AddRange(specialStats); return; } foreach (ParserStat stat in staticOptions.Stats) { NormalStat normalStat = normalStats.FirstOrDefault(x => x.ItemAttribute == stat.Id); if (normalStat == null) { normalStats.Add(new NormalStat(stat.Id, stat.Flat, stat.Percent)); continue; } int index = normalStats.FindIndex(x => x.ItemAttribute == stat.Id); int summedFlat = normalStat.Flat + stat.Flat; float summedPercent = normalStat.Percent + stat.Percent; normalStats[index] = new NormalStat(stat.Id, summedFlat, summedPercent); } foreach (ParserSpecialStat stat in staticOptions.SpecialStats) { SpecialStat normalStat = specialStats.FirstOrDefault(x => x.ItemAttribute == stat.Id); if (normalStat == null) { specialStats.Add(new SpecialStat(stat.Id, stat.Flat, stat.Percent)); continue; } int index = specialStats.FindIndex(x => x.ItemAttribute == stat.Id); float summedFlat = normalStat.Flat + stat.Flat; float summedPercent = normalStat.Percent + stat.Percent; specialStats[index] = new SpecialStat(stat.Id, summedFlat, summedPercent); } if (staticOptions.HiddenDefenseAdd > 0) { AddHiddenNormalStat(normalStats, ItemAttribute.Defense, staticOptions.HiddenDefenseAdd, staticOptions.DefenseCalibrationFactor); } if (staticOptions.HiddenWeaponAtkAdd > 0) { AddHiddenNormalStat(normalStats, ItemAttribute.MinWeaponAtk, staticOptions.HiddenWeaponAtkAdd, staticOptions.WeaponAtkCalibrationFactor); AddHiddenNormalStat(normalStats, ItemAttribute.MaxWeaponAtk, staticOptions.HiddenWeaponAtkAdd, staticOptions.WeaponAtkCalibrationFactor); } BasicStats.AddRange(normalStats); BasicStats.AddRange(specialStats); }
// Roll new bonus stats and values except the locked stat public static List <ItemStat> RollBonusStatsWithStatLocked(Item item, short ignoreStat, bool isSpecialStat) { int id = item.Id; int randomId = ItemMetadataStorage.GetOptionRandom(id); ItemOptionRandom randomOptions = ItemOptionRandomMetadataStorage.GetMetadata(randomId, item.Rarity); if (randomOptions == null) { return(null); } Random random = new Random(); List <ItemStat> itemStats = new List <ItemStat>(); List <ParserStat> attributes = isSpecialStat ? randomOptions.Stats : randomOptions.Stats.Where(x => (short)x.Id != ignoreStat).ToList(); List <ParserSpecialStat> specialAttributes = isSpecialStat ? randomOptions.SpecialStats.Where(x => (short)x.Id != ignoreStat).ToList() : randomOptions.SpecialStats; foreach (ParserStat attribute in attributes) { Dictionary <ItemAttribute, List <ParserStat> > dictionary = GetRange(randomId); if (!dictionary.ContainsKey(attribute.Id)) { continue; } NormalStat normalStat = new NormalStat(dictionary[attribute.Id][Roll(id)]); if (randomOptions.MultiplyFactor > 0) { normalStat.Flat *= (int)Math.Ceiling(randomOptions.MultiplyFactor); normalStat.Percent *= randomOptions.MultiplyFactor; } itemStats.Add(normalStat); } foreach (ParserSpecialStat attribute in specialAttributes) { Dictionary <SpecialItemAttribute, List <ParserSpecialStat> > dictionary = GetSpecialRange(randomId); if (!dictionary.ContainsKey(attribute.Id)) { continue; } SpecialStat specialStat = new SpecialStat(dictionary[attribute.Id][Roll(id)]); if (randomOptions.MultiplyFactor > 0) { specialStat.Flat *= (int)Math.Ceiling(randomOptions.MultiplyFactor); specialStat.Percent *= randomOptions.MultiplyFactor; } itemStats.Add(specialStat); } return(itemStats.OrderBy(x => random.Next()).Take(item.Stats.BonusStats.Count).ToList()); }
public static List <ItemStat> RollStats(ItemOptionRandom randomOptions, int randomId, int itemId) { List <ItemStat> itemStats = new List <ItemStat>(); foreach (ParserStat stat in randomOptions.Stats) { Dictionary <ItemAttribute, List <ParserStat> > rangeDictionary = GetRange(randomId); if (!rangeDictionary.ContainsKey(stat.Id)) { continue; } NormalStat normalStat = new NormalStat(rangeDictionary[stat.Id][Roll(itemId)]); if (randomOptions.MultiplyFactor > 0) { normalStat.Flat *= (int)Math.Ceiling(randomOptions.MultiplyFactor); normalStat.Percent *= randomOptions.MultiplyFactor; } itemStats.Add(normalStat); } foreach (ParserSpecialStat stat in randomOptions.SpecialStats) { Dictionary <SpecialItemAttribute, List <ParserSpecialStat> > rangeDictionary = GetSpecialRange(randomId); if (!rangeDictionary.ContainsKey(stat.Id)) { continue; } SpecialStat specialStat = new SpecialStat(rangeDictionary[stat.Id][Roll(itemId)]); if (randomOptions.MultiplyFactor > 0) { specialStat.Flat *= (int)Math.Ceiling(randomOptions.MultiplyFactor); specialStat.Percent *= randomOptions.MultiplyFactor; } itemStats.Add(specialStat); } return(itemStats); }
// Get random values for each stat and check if item is two-handed private static List <ItemStat> RollStats(int itemId, int level, bool isTwoHand, ItemOption itemOption) { List <ItemStat> itemStats = new List <ItemStat>(); foreach (ItemAttribute attribute in itemOption.Stats) { Dictionary <ItemAttribute, List <ParserStat> > dictionary = GetRange(itemId); if (!dictionary.ContainsKey(attribute)) { continue; } NormalStat normalStat = NormalStat.Of(dictionary[attribute][Roll(level)]); if (isTwoHand) { normalStat.Flat *= 2; normalStat.Percent *= 2; } itemStats.Add(normalStat); } foreach (SpecialItemAttribute attribute in itemOption.SpecialStats) { Dictionary <SpecialItemAttribute, List <ParserSpecialStat> > dictionary = GetSpecialRange(itemId); if (!dictionary.ContainsKey(attribute)) { continue; } SpecialStat specialStat = SpecialStat.Of(dictionary[attribute][Roll(level)]); if (isTwoHand) { specialStat.Flat *= 2; specialStat.Percent *= 2; } itemStats.Add(specialStat); } return(itemStats); }
// Roll new values for existing bonus stats public static List <ItemStat> RollNewBonusValues(Item item, short ignoreStat, bool isSpecialStat) { List <ItemStat> newBonus = new List <ItemStat>(); foreach (NormalStat stat in item.Stats.BonusStats.Where(x => x.GetType() == typeof(NormalStat))) { if (!isSpecialStat && (short)stat.Id == ignoreStat) { newBonus.Add(stat); continue; } Dictionary <ItemAttribute, List <ParserStat> > dictionary = GetRange(item.Id); if (!dictionary.ContainsKey(stat.Id)) { continue; } newBonus.Add(NormalStat.Of(dictionary[stat.Id][Roll(item.Level)])); } foreach (SpecialStat stat in item.Stats.BonusStats.Where(x => x.GetType() == typeof(SpecialStat))) { if (isSpecialStat && (short)stat.Id == ignoreStat) { newBonus.Add(stat); continue; } Dictionary <SpecialItemAttribute, List <ParserSpecialStat> > dictionary = GetSpecialRange(item.Id); if (!dictionary.ContainsKey(stat.Id)) { continue; } newBonus.Add(SpecialStat.Of(dictionary[stat.Id][Roll(item.Level)])); } return(newBonus); }
// Roll new basic stats and values public List <ItemStat> RollBasicStats(int itemId, int rarity, int level) { if (!ItemOptionsMetadataStorage.GetBasic(itemId, out List <ItemOption> basicList)) { return(null); } ItemOption itemOptions = basicList.Find(options => options.Rarity == rarity); if (itemOptions == null) { return(null); } // Weapon and pet atk comes from each Item option and not from stat ranges if (itemOptions.MaxWeaponAtk != 0) { BasicStats.Add(NormalStat.Of(ItemAttribute.MinWeaponAtk, itemOptions.MinWeaponAtk)); BasicStats.Add(NormalStat.Of(ItemAttribute.MaxWeaponAtk, itemOptions.MaxWeaponAtk)); } if (itemOptions.PetAtk != 0) { BasicStats.Add(NormalStat.Of(ItemAttribute.PetBonusAtk, itemOptions.PetAtk)); } List <ItemStat> itemStats = new List <ItemStat>(); foreach (ItemAttribute attribute in itemOptions.Stats) { itemStats.Add(NormalStat.Of(GetRange(itemId)[attribute][Roll(level)])); } foreach (SpecialItemAttribute attribute in itemOptions.SpecialStats) { itemStats.Add(SpecialStat.Of(GetSpecialRange(itemId)[attribute][Roll(level)])); } return(itemStats); }