diff --git a/Maple2.File.Ingest/Mapper/ItemMapper.cs b/Maple2.File.Ingest/Mapper/ItemMapper.cs index 519421871..c8cc2b2a0 100644 --- a/Maple2.File.Ingest/Mapper/ItemMapper.cs +++ b/Maple2.File.Ingest/Mapper/ItemMapper.cs @@ -121,11 +121,11 @@ protected override IEnumerable Map() { } ItemMetadataOption? option = !hasOption ? null : new ItemMetadataOption( StaticId: data.option.@static, - StaticType: data.option.staticMakeType, + StaticType: (ItemOptionMakeType) data.option.staticMakeType, RandomId: data.option.random, - RandomType: (RandomMakeType) data.option.randomMakeType, + ItemOptionType: (ItemOptionMakeType) data.option.randomMakeType, ConstantId: data.option.constant, - ConstantType: data.option.constantMakeType, + ConstantType: (ItemOptionMakeType) data.option.constantMakeType, LevelFactor: levelFactor, PickId: data.option.optionID); ItemMetadataMusic? music = data.property.type != 12 ? null : new ItemMetadataMusic( diff --git a/Maple2.Model/Enum/ItemOptionMakeType.cs b/Maple2.Model/Enum/ItemOptionMakeType.cs index 78670b10d..6274e2c0d 100644 --- a/Maple2.Model/Enum/ItemOptionMakeType.cs +++ b/Maple2.Model/Enum/ItemOptionMakeType.cs @@ -1,6 +1,7 @@ namespace Maple2.Model.Enum; -public enum RandomMakeType { +public enum ItemOptionMakeType { Base = 0, // uses itemoptionvariation table Range = 1, // uses itemoptionvariation_* tables + Lua = 2, // uses lua functions } diff --git a/Maple2.Model/Metadata/ItemMetadata.cs b/Maple2.Model/Metadata/ItemMetadata.cs index a8dd1b21c..b29c5279f 100644 --- a/Maple2.Model/Metadata/ItemMetadata.cs +++ b/Maple2.Model/Metadata/ItemMetadata.cs @@ -89,11 +89,11 @@ public record ItemMetadataAdditionalEffect( public record ItemMetadataOption( int StaticId, - int StaticType, + ItemOptionMakeType StaticType, int RandomId, - RandomMakeType RandomType, + ItemOptionMakeType ItemOptionType, int ConstantId, - int ConstantType, + ItemOptionMakeType ConstantType, int LevelFactor, int PickId); diff --git a/Maple2.Server.Game/Util/ItemStatsCalculator.cs b/Maple2.Server.Game/Util/ItemStatsCalculator.cs index 059285a2d..236cf34b6 100644 --- a/Maple2.Server.Game/Util/ItemStatsCalculator.cs +++ b/Maple2.Server.Game/Util/ItemStatsCalculator.cs @@ -192,8 +192,8 @@ int GetValue(Item item, ItemOption itemOptionMetadata, BasicAttribute? attribute return (int) (weightedRates.Get() * 1000); } } else { - switch (item.Metadata.Option!.RandomType) { - case RandomMakeType.Range: + switch (item.Metadata.Option!.ItemOptionType) { + case ItemOptionMakeType.Range: switch (item.Metadata.Option.LevelFactor) { case < 50: if (rollMax) { @@ -257,7 +257,7 @@ int GetValue(Item item, ItemOption itemOptionMetadata, BasicAttribute? attribute return (int) (weightedRates.Get() * 1000); } break; - case RandomMakeType.Base: + case ItemOptionMakeType.Base: default: float minRate = 0; int minValue = 0; @@ -292,7 +292,7 @@ private bool GetConstantOption(Item item, int job, ItemOptionPickTable.Option? p option = ConstantItemOption(itemOptionConstant); } - if (pick != null) { + if (item.Metadata.Option.ConstantType == ItemOptionMakeType.Lua && pick != null) { if (option == null) { option = new ItemStats.Option(); } @@ -304,7 +304,6 @@ private bool GetConstantOption(Item item, int job, ItemOptionPickTable.Option? p option.Basic[attribute] = new BasicOption(value); } } - } return option != null; } @@ -321,10 +320,11 @@ private bool GetStaticOption(Item item, int job, ItemOptionPickTable.Option? pic option = RandomItemOption(itemOption); } - if (pick != null) { + if (item.Metadata.Option.StaticType == ItemOptionMakeType.Lua && pick != null) { if (option == null) { option = new ItemStats.Option(); } + foreach ((BasicAttribute attribute, int deviation) in pick.StaticValue) { int currentValue = option.Basic.TryGetValue(attribute, out BasicOption basicOption) ? basicOption.Value : 0; int value = StaticValue(attribute, currentValue, deviation, item.Type.Type, job, item.Metadata.Option.LevelFactor, item.Rarity, (ushort) item.Metadata.Limit.Level); @@ -334,8 +334,7 @@ private bool GetStaticOption(Item item, int job, ItemOptionPickTable.Option? pic } return true; } - - return false; + return option != null; } // Used to calculate the default random attributes for a given item.