Skip to content
Merged
Show file tree
Hide file tree
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
6 changes: 3 additions & 3 deletions Maple2.File.Ingest/Mapper/ItemMapper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -121,11 +121,11 @@ protected override IEnumerable<ItemMetadata> 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(
Expand Down
3 changes: 2 additions & 1 deletion Maple2.Model/Enum/ItemOptionMakeType.cs
Original file line number Diff line number Diff line change
@@ -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
}
6 changes: 3 additions & 3 deletions Maple2.Model/Metadata/ItemMetadata.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
15 changes: 7 additions & 8 deletions Maple2.Server.Game/Util/ItemStatsCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
Expand All @@ -304,7 +304,6 @@ private bool GetConstantOption(Item item, int job, ItemOptionPickTable.Option? p
option.Basic[attribute] = new BasicOption(value);
}
}

}
return option != null;
}
Expand All @@ -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);
Expand All @@ -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.
Expand Down