Skip to content

Commit

Permalink
Merge branch 'master' into dev/protocol-extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
sven-n authored Oct 6, 2024
2 parents b9c4791 + bad3dbb commit e4b255c
Show file tree
Hide file tree
Showing 5 changed files with 88 additions and 5 deletions.
11 changes: 8 additions & 3 deletions src/GameLogic/DefaultDropGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,7 @@ public DefaultDropGenerator(GameConfiguration config, IRandomizer randomizer)
}

item.Level = GetItemLevelByMonsterLevel(item.Definition!, monsterLvl);
item.Durability = item.GetMaximumDurabilityOfOnePiece();
return item;
}

Expand All @@ -159,8 +160,9 @@ public DefaultDropGenerator(GameConfiguration config, IRandomizer randomizer)
/// <param name="item">The item.</param>
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);
}
Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
}

Expand Down Expand Up @@ -295,6 +299,7 @@ private static bool IsGroupRelevant(MonsterDefinition monsterDefinition, DropIte
this.AddRandomExcOptions(item);
}

item.Durability = item.GetMaximumDurabilityOfOnePiece();
return item;
}

Expand All @@ -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);
}
Expand Down
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 e4b255c

Please sign in to comment.