diff --git a/src/GameLogic/DefaultDropGenerator.cs b/src/GameLogic/DefaultDropGenerator.cs index bd42a50f7..b59c78b8a 100644 --- a/src/GameLogic/DefaultDropGenerator.cs +++ b/src/GameLogic/DefaultDropGenerator.cs @@ -150,6 +150,7 @@ public DefaultDropGenerator(GameConfiguration config, IRandomizer randomizer) } item.Level = GetItemLevelByMonsterLevel(item.Definition!, monsterLvl); + item.Durability = item.GetMaximumDurabilityOfOnePiece(); return item; } @@ -159,8 +160,9 @@ public DefaultDropGenerator(GameConfiguration config, IRandomizer randomizer) /// The item. protected void ApplyRandomOptions(Item item) { - item.Durability = item.GetMaximumDurabilityOfOnePiece(); - foreach (var option in item.Definition!.PossibleItemOptions.Where(o => o.AddsRandomly)) + foreach (var option in item.Definition!.PossibleItemOptions.Where(o => + o.AddsRandomly && + !o.PossibleOptions.Any(po => object.Equals(po.OptionType, ItemOptionTypes.Excellent)))) { this.ApplyOption(item, option); } @@ -198,6 +200,7 @@ protected void ApplyRandomOptions(Item item) item.HasSkill = item.CanHaveSkill(); // every excellent item got skill this.AddRandomExcOptions(item); + item.Durability = item.GetMaximumDurabilityOfOnePiece(); return item; } @@ -216,6 +219,7 @@ protected void ApplyRandomOptions(Item item) item.HasSkill = item.CanHaveSkill(); // every ancient item got skill this.ApplyRandomAncientOption(item); + item.Durability = item.GetMaximumDurabilityOfOnePiece(); return item; } @@ -295,6 +299,7 @@ private static bool IsGroupRelevant(MonsterDefinition monsterDefinition, DropIte this.AddRandomExcOptions(item); } + item.Durability = item.GetMaximumDurabilityOfOnePiece(); return item; } @@ -314,7 +319,7 @@ private void ApplyOption(Item item, ItemOptionDefinition option) var itemOptionLink = new ItemOptionLink { ItemOption = newOption, - Level = newOption?.LevelDependentOptions.Select(l => l.Level).SelectRandom() ?? 0 + Level = newOption?.LevelDependentOptions.Select(l => l.Level).SelectRandom() ?? 0, }; item.ItemOptions.Add(itemOptionLink); } diff --git a/src/Persistence/Initialization/InitializerBase.cs b/src/Persistence/Initialization/InitializerBase.cs index 3826a4c2a..2569d90c2 100644 --- a/src/Persistence/Initialization/InitializerBase.cs +++ b/src/Persistence/Initialization/InitializerBase.cs @@ -180,6 +180,7 @@ protected IncreasableItemOption CreateItemOption(int number, AttributeDefinition itemOption.Number = number; itemOption.PowerUpDefinition = this.CreatePowerUpDefinition(attributeDefinition, value, aggregateType); + float baseValue = aggregateType == AggregateType.Multiplicate ? 1.0f : 0.0f; for (int level = 1; level <= this.MaximumOptionLevel; level++) { @@ -187,7 +188,7 @@ protected IncreasableItemOption CreateItemOption(int number, AttributeDefinition optionOfLevel.Level = level; optionOfLevel.PowerUpDefinition = this.CreatePowerUpDefinition( itemOption.PowerUpDefinition.TargetAttribute!, - level * valueIncrementPerLevel, + baseValue + (level * valueIncrementPerLevel), aggregateType); itemOption.LevelDependentOptions.Add(optionOfLevel); } diff --git a/src/Persistence/Initialization/Updates/FixMaxManaAndAbilityJewelryOptionsUpdateSeason6.cs b/src/Persistence/Initialization/Updates/FixMaxManaAndAbilityJewelryOptionsUpdateSeason6.cs new file mode 100644 index 000000000..24eda9dcc --- /dev/null +++ b/src/Persistence/Initialization/Updates/FixMaxManaAndAbilityJewelryOptionsUpdateSeason6.cs @@ -0,0 +1,72 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.Persistence.Initialization.Updates; + +using System.Runtime.InteropServices; +using System.Threading.Tasks; +using MUnique.OpenMU.AttributeSystem; +using MUnique.OpenMU.DataModel.Configuration; +using MUnique.OpenMU.PlugIns; + +/// +/// This update fixes the calculation for max mana/AG % increase provided by Ring of Magic/Pendant of Ability options. +/// +[PlugIn(PlugInName, PlugInDescription)] +[Guid("EAC7C809-D4B8-443F-BE52-E56560003483")] +public class FixMaxManaAndAbilityJewelryOptionsUpdateSeason6 : UpdatePlugInBase +{ + /// + /// The plug in name. + /// + internal const string PlugInName = "Fix max mana/AG % increase jewelry options"; + + /// + /// The plug in description. + /// + internal const string PlugInDescription = "This update fixes the calculation for max mana/AG % increase provided by Ring of Magic/Pendant of Ability options"; + + /// + public override string Name => PlugInName; + + /// + public override string Description => PlugInDescription; + + /// + public override UpdateVersion Version => UpdateVersion.FixMaxManaAndAbilityJewelryOptionsSeason6; + + /// + public override string DataInitializationKey => VersionSeasonSix.DataInitialization.Id; + + /// + public override bool IsMandatory => true; + + /// + public override DateTime CreatedAt => new(2024, 09, 26, 10, 00, 0, DateTimeKind.Utc); + + /// + protected override async ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration) + { + var itemOptionGuids = new List { new("00000083-d018-8826-0000-000000000000"), new("00000083-d01c-bbba-0000-000000000000") }; + var itemOptions = gameConfiguration.ItemOptions.Where(io => itemOptionGuids.Contains(io.GetId())); + + foreach (var itemOption in itemOptions) + { + var optionsOfLevel = itemOption?.PossibleOptions.FirstOrDefault()?.LevelDependentOptions + .Where(opt => opt.Level > 1) + .OrderBy(opt => opt.Level); + + if (optionsOfLevel is not null) + { + for (int i = 0; i < optionsOfLevel.Count(); i++) + { + if (optionsOfLevel.ElementAt(i).PowerUpDefinition?.Boost?.ConstantValue is SimpleElement elmt && elmt.Value > i + 2) + { + elmt.Value -= i + 1; + } + } + } + } + } +} \ No newline at end of file diff --git a/src/Persistence/Initialization/Updates/UpdateVersion.cs b/src/Persistence/Initialization/Updates/UpdateVersion.cs index a273401f2..b66aae1d0 100644 --- a/src/Persistence/Initialization/Updates/UpdateVersion.cs +++ b/src/Persistence/Initialization/Updates/UpdateVersion.cs @@ -159,4 +159,9 @@ public enum UpdateVersion /// The version of the . /// AddItemDropGroupForJewelsSeason6 = 30, + + /// + /// The version of the . + /// + FixMaxManaAndAbilityJewelryOptionsSeason6 = 31, } \ No newline at end of file diff --git a/src/Persistence/Initialization/VersionSeasonSix/Items/Jewelery.cs b/src/Persistence/Initialization/VersionSeasonSix/Items/Jewelery.cs index 1eaf95e14..181982c96 100644 --- a/src/Persistence/Initialization/VersionSeasonSix/Items/Jewelery.cs +++ b/src/Persistence/Initialization/VersionSeasonSix/Items/Jewelery.cs @@ -206,7 +206,7 @@ private ItemDefinition CreateJewelery(byte number, int slot, bool dropsFromMonst if (optionTargetAttribute != Stats.HealthRecoveryMultiplier && optionTargetAttribute is not null) { // Then it's either maximum mana or ability increase by 1% for each option level - var option = this.CreateOption("Jewelery option " + optionTargetAttribute.Designation, optionTargetAttribute, 1.01f, item.GetItemId(), AggregateType.Multiplicate); + var option = this.CreateOption("Jewelery option " + optionTargetAttribute.Designation, optionTargetAttribute, 0.01f, item.GetItemId(), AggregateType.Multiplicate); item.PossibleItemOptions.Add(option); }