Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions Maple2.Server.Game/Util/ItemStatsCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,7 @@ public sealed class ItemStatsCalculator {


if (TableMetadata.ItemOptionRandomTable.Options.TryGetValue(item.Metadata.Option.RandomId, item.Rarity, out ItemOption? itemOption)) {
ItemStats.Option option = GetRandomOption(itemOption, item.Type, ItemStats.Type.Random);
ItemStats.Option option = GetRandomOption(item.Id, itemOption, item.Type, ItemStats.Type.Random);
RandomizeValues(item, itemOption, ref option, rollMax);
stats[ItemStats.Type.Random] = option;
}
Expand Down Expand Up @@ -158,7 +158,7 @@ public bool UpdateRandomOption(ref Item item, params LockOption[] presets) {
if (!TableMetadata.ItemOptionRandomTable.Options.TryGetValue(item.Metadata.Option.RandomId, item.Rarity, out ItemOption? itemOption)) {
return false;
}
ItemStats.Option randomOption = GetRandomOption(itemOption, item.Type, ItemStats.Type.Random, option.Count, presets);
ItemStats.Option randomOption = GetRandomOption(item.Id, itemOption, item.Type, ItemStats.Type.Random, option.Count, presets);

if (!RandomizeValues(item, itemOption, ref randomOption)) {
return false;
Expand Down Expand Up @@ -392,7 +392,7 @@ private bool GetStaticOption(Item item, int job, ItemStats.Type statsType, ItemO

if (TableMetadata.ItemOptionStaticTable.Options.TryGetValue(item.Metadata.Option.StaticId, item.Rarity, out ItemOption? itemOption)) {
// We're using RandomItemOption here considering the logic is the same.
option = RandomItemOption(itemOption, item.Type, statsType);
option = RandomItemOption(item.Id, itemOption, item.Type, statsType);
}

if (item.Metadata.Option.StaticType == ItemOptionMakeType.Lua && pick != null) {
Expand All @@ -413,8 +413,8 @@ private bool GetStaticOption(Item item, int job, ItemStats.Type statsType, ItemO
}

// Used to calculate the default random attributes for a given item.
private ItemStats.Option GetRandomOption(ItemOption itemOption, in ItemType itemType, ItemStats.Type statsType, int count = -1, params LockOption[] presets) {
return RandomItemOption(itemOption, itemType, statsType, count, presets);
private ItemStats.Option GetRandomOption(int itemId, ItemOption itemOption, in ItemType itemType, ItemStats.Type statsType, int count = -1, params LockOption[] presets) {
return RandomItemOption(itemId, itemOption, itemType, statsType, count, presets);
}

private ItemEquipVariationTable? GetVariationTable(in ItemType type) {
Expand Down Expand Up @@ -506,7 +506,7 @@ private static ItemStats.Option ConstantItemOption(ItemOptionConstant option) {
return new ItemStats.Option(statResult, specialResult);
}

private static ItemStats.Option RandomItemOption(ItemOption option, in ItemType itemType, ItemStats.Type statsType, int count = -1, params LockOption[] presets) {
private static ItemStats.Option RandomItemOption(int itemId, ItemOption option, in ItemType itemType, ItemStats.Type statsType, int count = -1, params LockOption[] presets) {
var statResult = new Dictionary<BasicAttribute, BasicOption>();
var specialResult = new Dictionary<SpecialAttribute, SpecialOption>();

Expand Down Expand Up @@ -548,8 +548,8 @@ private static ItemStats.Option RandomItemOption(ItemOption option, in ItemType
availableEntries.Remove(entry);
}

if (availableEntries.Count == 0) {
Log.Logger.Error("Failed to select random item option, no more entries available. ItemType: {ItemType}, StatsType: {StatsType}, Total: {Total}", itemType, statsType, total);
if (availableEntries.Count == 0 && statResult.Count + specialResult.Count < total) {
Log.Logger.Error("Failed to select random item option, no more entries available. ItemId: {Item}", itemId);
}

return new ItemStats.Option(statResult, specialResult, multiplyFactor: option.MultiplyFactor);
Expand Down