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
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
// <copyright file="FixItemRequirementsPlugIn2.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 MUnique.OpenMU.AttributeSystem;
using MUnique.OpenMU.DataModel.Configuration;
using MUnique.OpenMU.DataModel.Configuration.Items;
using MUnique.OpenMU.GameLogic.Attributes;
using MUnique.OpenMU.PlugIns;

/// <summary>
/// Updates some item requirements for elf bows which were initialized wrongly.
/// This plugin fixes configurations that were created after the initial fix but before the base data was corrected.
/// </summary>
[PlugIn(PlugInName, PlugInDescription)]
[Guid("A7C9D4E1-8F2B-4A3C-9E6D-7B8F9A0E1C2D")]
public class FixItemRequirementsPlugIn2 : UpdatePlugInBase
{
private static readonly List<(int Group, int Number, int StrengthRequirement, int AgilityRequirement, int EnergyRequirement, int VitalityRequirement)> RequirementCorrections =
[
(4, 0, 20, 80, 0, 0), // Short Bow
(4, 1, 30, 90, 0, 0), // Bow
(4, 2, 30, 90, 0, 0), // Elven Bow
(4, 3, 30, 90, 0, 0), // Battle Bow
(4, 4, 30, 100, 0, 0), // Tiger Bow
(4, 5, 30, 100, 0, 0), // Silver Bow
(4, 6, 40, 150, 0, 0), // Chaos Nature Bow
];

/// <summary>
/// The plug in name.
/// </summary>
internal const string PlugInName = "Fix Item Requirements (Elf Bows) v2";

/// <summary>
/// The plug in description.
/// </summary>
internal const string PlugInDescription = "Updates some item requirements for elf bows which were initialized wrongly. This fixes configurations created after the initial fix but before the base data was corrected.";

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

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

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

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

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

/// <inheritdoc />
public override DateTime CreatedAt => new(2025, 09, 16, 19, 44, 0, DateTimeKind.Utc);

/// <inheritdoc />
protected override async ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration)
{
foreach (var reqUpdate in RequirementCorrections)
{
var item = gameConfiguration.Items.FirstOrDefault(x => x.Number == reqUpdate.Number && x.Group == reqUpdate.Group);
if (item == null)
{
continue;
}

UpdateRequirement(Stats.TotalStrengthRequirementValue, reqUpdate.StrengthRequirement);
UpdateRequirement(Stats.TotalAgilityRequirementValue, reqUpdate.AgilityRequirement);
UpdateRequirement(Stats.TotalEnergyRequirementValue, reqUpdate.EnergyRequirement);
UpdateRequirement(Stats.TotalVitalityRequirementValue, reqUpdate.VitalityRequirement);

void UpdateRequirement(AttributeDefinition stat, int newValue)
{
var requirement = item.Requirements.FirstOrDefault(r => r.Attribute == stat);
if (requirement is null && newValue == 0)
{
return;
}

if (requirement is null)
{
requirement = context.CreateNew<AttributeRequirement>();
requirement.Attribute = stat.GetPersistent(gameConfiguration);
item.Requirements.Add(requirement);
}

requirement.MinimumValue = newValue;
}
}
}
}
5 changes: 5 additions & 0 deletions src/Persistence/Initialization/Updates/UpdateVersion.cs
Original file line number Diff line number Diff line change
Expand Up @@ -309,4 +309,9 @@ public enum UpdateVersion
/// The version of the <see cref="FixEventItemsDropFromMonstersUpdatePlugIn095d"/>.
/// </summary>
FixEventItemsDropFromMonsters095d = 60,

/// <summary>
/// The version of the <see cref="FixItemRequirementsPlugIn2"/>.
/// </summary>
FixItemRequirements2 = 61,
}
14 changes: 7 additions & 7 deletions src/Persistence/Initialization/VersionSeasonSix/Items/Weapons.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,13 +213,13 @@ public override void Initialize()
this.CreateWeapon(3, 10, 0, 22, 2, 4, true, "Dragon Spear", 92, 112, 140, 35, 85, 0, 0, 170, 60, 0, 0, 0, 2, 0, 0, 0, 0, 0);
this.CreateWeapon(3, 11, 0, 22, 2, 4, false, "Beuroba", 147, 190, 226, 40, 90, 0, 0, 152, 25, 0, 0, 0, 2, 0, 1, 0, 0, 0);

this.CreateWeapon(4, 0, 1, 24, 2, 3, true, "Short Bow", 2, 3, 5, 30, 20, 0, 0, 21, 24, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 1, 1, 24, 2, 3, true, "Bow", 8, 9, 13, 30, 24, 0, 0, 27, 41, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 2, 1, 24, 2, 3, true, "Elven Bow", 16, 17, 24, 30, 28, 0, 0, 34, 63, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 3, 1, 24, 2, 3, true, "Battle Bow", 26, 28, 37, 30, 36, 0, 0, 43, 90, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 4, 1, 24, 2, 4, true, "Tiger Bow", 40, 42, 52, 30, 43, 0, 0, 56, 140, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 5, 1, 24, 2, 4, true, "Silver Bow", 56, 59, 71, 40, 48, 0, 0, 70, 188, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 6, 1, 24, 2, 4, false, "Chaos Nature Bow", 75, 88, 106, 35, 68, 0, 0, 110, 357, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 0, 1, 24, 2, 3, true, "Short Bow", 2, 3, 5, 30, 20, 0, 0, 20, 80, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 1, 1, 24, 2, 3, true, "Bow", 8, 9, 13, 30, 24, 0, 0, 30, 90, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 2, 1, 24, 2, 3, true, "Elven Bow", 16, 17, 24, 30, 28, 0, 0, 30, 90, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 3, 1, 24, 2, 3, true, "Battle Bow", 26, 28, 37, 30, 36, 0, 0, 30, 90, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 4, 1, 24, 2, 4, true, "Tiger Bow", 40, 42, 52, 30, 43, 0, 0, 30, 100, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 5, 1, 24, 2, 4, true, "Silver Bow", 56, 59, 71, 40, 48, 0, 0, 30, 100, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 6, 1, 24, 2, 4, false, "Chaos Nature Bow", 75, 88, 106, 35, 68, 0, 0, 40, 150, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 7, 1, 0, 1, 1, false, "Bolt", 0, 0, 0, 0, 255, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 8, 0, 24, 2, 2, true, "Crossbow", 4, 5, 8, 40, 22, 0, 0, 20, 90, 0, 0, 0, 0, 1, 0, 0, 0, 0);
this.CreateWeapon(4, 9, 0, 24, 2, 2, true, "Golden Crossbow", 12, 13, 19, 40, 26, 0, 0, 30, 90, 0, 0, 0, 0, 1, 0, 0, 0, 0);
Expand Down
Loading