Skip to content

Commit

Permalink
Merge pull request #494 from ze-dom/bugfix/jewelery_ability_mana_options
Browse files Browse the repository at this point in the history
Fixed jewelery option level multipliers for max Ability and Mana increase
  • Loading branch information
sven-n authored Sep 27, 2024
2 parents 9f35daf + 17dfdf7 commit 935ec7d
Show file tree
Hide file tree
Showing 4 changed files with 80 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/Persistence/Initialization/InitializerBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,15 @@ 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++)
{
var optionOfLevel = this.Context.CreateNew<ItemOptionOfLevel>();
optionOfLevel.Level = level;
optionOfLevel.PowerUpDefinition = this.CreatePowerUpDefinition(
itemOption.PowerUpDefinition.TargetAttribute!,
level * valueIncrementPerLevel,
baseValue + (level * valueIncrementPerLevel),
aggregateType);
itemOption.LevelDependentOptions.Add(optionOfLevel);
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
// <copyright file="FixMaxManaAndAbilityJewelryOptionsUpdateSeason6.cs" company="MUnique">
// Licensed under the MIT License. See LICENSE file in the project root for full license information.
// </copyright>

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;

/// <summary>
/// This update fixes the calculation for max mana/AG % increase provided by Ring of Magic/Pendant of Ability options.
/// </summary>
[PlugIn(PlugInName, PlugInDescription)]
[Guid("EAC7C809-D4B8-443F-BE52-E56560003483")]
public class FixMaxManaAndAbilityJewelryOptionsUpdateSeason6 : UpdatePlugInBase
{
/// <summary>
/// The plug in name.
/// </summary>
internal const string PlugInName = "Fix max mana/AG % increase jewelry options";

/// <summary>
/// The plug in description.
/// </summary>
internal const string PlugInDescription = "This update fixes the calculation for max mana/AG % increase provided by Ring of Magic/Pendant of Ability options";

/// <inheritdoc />
public override string Name => PlugInName;

/// <inheritdoc />
public override string Description => PlugInDescription;

/// <inheritdoc />
public override UpdateVersion Version => UpdateVersion.FixMaxManaAndAbilityJewelryOptionsSeason6;

/// <inheritdoc />
public override string DataInitializationKey => VersionSeasonSix.DataInitialization.Id;

/// <inheritdoc />
public override bool IsMandatory => true;

/// <inheritdoc />
public override DateTime CreatedAt => new(2024, 09, 26, 10, 00, 0, DateTimeKind.Utc);

/// <inheritdoc />
protected override async ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration)
{
var itemOptionGuids = new List<Guid> { 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;
}
}
}
}
}
}
5 changes: 5 additions & 0 deletions src/Persistence/Initialization/Updates/UpdateVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,4 +159,9 @@ public enum UpdateVersion
/// The version of the <see cref="AddItemDropGroupForJewelsUpdateSeason6"/>.
/// </summary>
AddItemDropGroupForJewelsSeason6 = 30,

/// <summary>
/// The version of the <see cref="FixMaxManaAndAbilityJewelryOptionsUpdateSeason6"/>.
/// </summary>
FixMaxManaAndAbilityJewelryOptionsSeason6 = 31,
}
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 935ec7d

Please sign in to comment.