private void CreateNewStats(Item item) { Constants = new(); Statics = new(); Randoms = new(); Enchants = new(); LimitBreakEnchants = new(); GemSockets = new(); if (item.Rarity is 0 or > 6) { return; } int optionId = ItemMetadataStorage.GetOptionMetadata(item.Id).OptionId; float optionLevelFactor = ItemMetadataStorage.GetOptionMetadata(item.Id).OptionLevelFactor; ConstantStats.GetStats(item, optionId, optionLevelFactor, out Dictionary <StatAttribute, ItemStat> constantStats); Constants = constantStats; StaticStats.GetStats(item, optionId, optionLevelFactor, out Dictionary <StatAttribute, ItemStat> staticStats); Statics = staticStats; RandomStats.GetStats(item, out Dictionary <StatAttribute, ItemStat> randomStats); Randoms = randomStats; if (item.EnchantLevel > 0) { Enchants = EnchantHelper.GetEnchantStats(item.EnchantLevel, item.Type, item.Level); } GetGemSockets(item, optionLevelFactor); }
public IActionResult RandomChr() { ViewData["CharacterClass"] = CharacterClassProcessor.GetRandomCharacterClass(20); ViewData["Background"] = PersonalityProcessor.randomBackground(); ViewData["Stats"] = RandomStats.RandomTheNumbers(); RangeTable rt = new RangeTable(); rt.AddEntry(1, 8, "Autocracy"); rt.AddEntry(9, 13, "Beureaucracy"); rt.AddEntry(14, 19, "Confederacy"); ViewData["Govt"] = rt.Roll(); return(View()); }
private static void HandleChangeAttributes(GameSession session, PacketReader packet) { short lockStatId = -1; bool isSpecialStat = false; long scrollUid = packet.ReadLong(); long gearUid = packet.ReadLong(); packet.Skip(9); bool useLock = packet.ReadBool(); if (useLock) { isSpecialStat = packet.ReadBool(); lockStatId = packet.ReadShort(); if (isSpecialStat) { // Match the enum ID for ItemAttribute lockStatId += 11000; } } IInventory inventory = session.Player.Inventory; Item scroll = inventory.GetByUid(scrollUid); Item gear = inventory.GetByUid(gearUid); Item scrollLock = null; // Check if gear and scroll exists in inventory if (scroll == null || gear == null) { return; } string tag = ""; if (Item.IsAccessory(gear.ItemSlot)) { tag = "LockItemOptionAccessory"; } else if (Item.IsArmor(gear.ItemSlot)) { tag = "LockItemOptionArmor"; } else if (Item.IsWeapon(gear.ItemSlot)) { tag = "LockItemOptionWeapon"; } else if (gear.IsPet()) { tag = "LockItemOptionPet"; } if (useLock) { scrollLock = inventory.GetAllByTag(tag).FirstOrDefault(x => x.Rarity == gear.Rarity); // Check if scroll lock exists in inventory if (scrollLock == null) { return; } } Item newItem = new(gear); // Set new values for attributes newItem.Stats.Randoms = RandomStats.RollNewBonusValues(newItem, lockStatId, isSpecialStat); inventory.TemporaryStorage[newItem.Uid] = newItem; session.Player.Inventory.ConsumeItem(session, scroll.Uid, 1); if (useLock) { session.Player.Inventory.ConsumeItem(session, scrollLock.Uid, 1); } session.Send(ChangeAttributesScrollPacket.PreviewNewItem(newItem)); }
private static void HandleChangeAttributes(GameSession session, PacketReader packet) { short lockStatId = -1; bool isSpecialStat = false; long itemUid = packet.ReadLong(); packet.Skip(8); bool useLock = packet.ReadBool(); if (useLock) { isSpecialStat = packet.ReadBool(); lockStatId = packet.ReadShort(); if (isSpecialStat) { // Match the enum ID for ItemAttribute lockStatId += 11000; } } IInventory inventory = session.Player.Inventory; Item gear = inventory.GetFromInventoryOrEquipped(itemUid); if (gear is null) { return; } Script script = ScriptLoader.GetScript("Functions/calcGetItemRemakeIngredient"); DynValue scriptResults = script.RunFunction("calcGetItemRemakeIngredientNew", (int)gear.Type, gear.TimesAttributesChanged, gear.Rarity, gear.Level); IReadOnlyCollection <Item> ingredient1 = inventory.GetAllByTag(scriptResults.Tuple[0].String); int ingredient1Cost = (int)scriptResults.Tuple[1].Number; IReadOnlyCollection <Item> ingredient2 = inventory.GetAllByTag(scriptResults.Tuple[2].String); int ingredient2Cost = (int)scriptResults.Tuple[3].Number; IReadOnlyCollection <Item> ingredient3 = inventory.GetAllByTag(scriptResults.Tuple[4].String); int ingredient3Cost = (int)scriptResults.Tuple[5].Number; int ingredient1TotalAmount = ingredient1.Sum(x => x.Amount); int ingredient2TotalAmount = ingredient2.Sum(x => x.Amount); int ingredient3TotalAmount = ingredient3.Sum(x => x.Amount); // Check if player has enough materials if (ingredient1TotalAmount < ingredient1Cost || ingredient2TotalAmount < ingredient2Cost || ingredient3TotalAmount < ingredient3Cost) { return; } Item scrollLock = null; string tag = ""; if (Item.IsAccessory(gear.ItemSlot)) { tag = "LockItemOptionAccessory"; } else if (Item.IsArmor(gear.ItemSlot)) { tag = "LockItemOptionArmor"; } else if (Item.IsWeapon(gear.ItemSlot)) { tag = "LockItemOptionWeapon"; } else if (gear.IsPet()) { tag = "LockItemOptionPet"; } if (useLock) { scrollLock = inventory.GetAllByTag(tag) .FirstOrDefault(i => i.Rarity == gear.Rarity); // Check if scroll lock exist in inventory if (scrollLock == null) { return; } } gear.TimesAttributesChanged++; Item newItem = new(gear); // Get random stats except stat that is locked List <ItemStat> randomList = RandomStats.RollBonusStatsWithStatLocked(newItem, lockStatId, isSpecialStat); Dictionary <StatAttribute, ItemStat> newRandoms = new(); for (int i = 0; i < newItem.Stats.Randoms.Count; i++) { ItemStat stat = newItem.Stats.Randoms.ElementAt(i).Value; // Check if BonusStats[i] is BasicStat and isSpecialStat is false // Check if BonusStats[i] is SpecialStat and isSpecialStat is true switch (stat) { case BasicStat when !isSpecialStat: case SpecialStat when isSpecialStat: switch (stat) { case SpecialStat ns when ns.ItemAttribute == (StatAttribute)lockStatId: case SpecialStat ss when ss.ItemAttribute == (StatAttribute)lockStatId: newRandoms[stat.ItemAttribute] = stat; continue; } break; } newRandoms[randomList[i].ItemAttribute] = randomList[i]; } newItem.Stats.Randoms = newRandoms; // Consume materials from inventory ConsumeMaterials(session, ingredient1Cost, ingredient2Cost, ingredient3Cost, ingredient1, ingredient2, ingredient3); if (useLock) { session.Player.Inventory.ConsumeItem(session, scrollLock.Uid, 1); } inventory.TemporaryStorage[newItem.Uid] = newItem; session.Send(ChangeAttributesPacket.PreviewNewItem(newItem)); }