diff --git a/src/GameLogic/Attributes/Stats.cs b/src/GameLogic/Attributes/Stats.cs index e696962782..54057ade35 100644 --- a/src/GameLogic/Attributes/Stats.cs +++ b/src/GameLogic/Attributes/Stats.cs @@ -1472,24 +1472,31 @@ public class Stats public static AttributeDefinition MaximumAllianceSize { get; } = new(new Guid("B3C7E9D2-5A1F-4E8B-92C7-6D3F8A4B7E5C"), "Maximum Alliance Size", string.Empty); /// - /// Gets the fully recover mana after hit chance definition. + /// Gets the fully recover mana after hit (received) chance definition. /// public static AttributeDefinition FullyRecoverManaAfterHitChance { get; } = new(new Guid("EB06D3A2-DA82-4B81-81B9-A16D39974531"), "Chance to fully recover mana when getting hit", "3rd Wing Option"); /// - /// Gets the fully recover health after hit chance definition. + /// Gets the fully recover health after hit (received) chance definition. /// public static AttributeDefinition FullyRecoverHealthAfterHitChance { get; } = new(new Guid("3CA72C07-9C2C-4FC5-8BCB-9BD737F83664"), "Chance to fully recover health when getting hit", "3rd Wing Option"); /// - /// Gets the fully reflect damage after hit chance definition. + /// Gets the fully reflect damage after hit (received) chance definition. /// public static AttributeDefinition FullyReflectDamageAfterHitChance { get; } = new(new Guid("1F7C1E04-4FBD-4FCB-A6C2-EB51A91D8C3E"), "Chance to fully reflect damage when getting hit", "3rd Wing Option"); /// - /// Gets the health loss after hit definition. + /// Gets the health loss after hit (received) definition. /// - public static AttributeDefinition HealthLossAfterHit { get; } = new(new Guid("D84A719B-D18E-433E-BF55-9F08A214AB00"), "Health loss after hitting a target", "Caused by wearing wings"); + /// A health toll apart from received damage (e.g., by equipping a dark horse). + public static AttributeDefinition HealthLossAfterHit { get; } = new(new Guid("E6EB76C4-4464-42E7-9BEB-6E192D0F15EE"), "Health loss after getting hit", "Caused by equipping a dark horse"); + + /// + /// Gets the health loss after dealt hit definition. + /// + /// Wings, imp, dinorant impose a health toll to their user. + public static AttributeDefinition HealthLossAfterDealtHit { get; } = new(new Guid("D84A719B-D18E-433E-BF55-9F08A214AB00"), "Health loss after hitting a target", "Caused by wearing wings, imp, dinorant"); /// /// Gets the skill extra mana cost definition. @@ -1499,7 +1506,12 @@ public class Stats /// /// Gets the CanFly attribute for warping to icarus. /// - public static AttributeDefinition CanFly { get; } = new(new Guid("EC34C673-84DE-4811-8962-CD2164A2248C"), "Requirement of the Icarus map.", "You can enter Icarus only with wings, dinorant, fenrir."); + public static AttributeDefinition CanFly { get; } = new(new Guid("EC34C673-84DE-4811-8962-CD2164A2248C"), "Requirement of the Icarus map.", "You can enter Icarus only with wings, dinorant, horse, fenrir."); + + /// + /// Gets the is wing equipped attribute. + /// + public static AttributeDefinition IsWingEquipped { get; } = new(new Guid("7C4A2E91-D58B-4F3A-8B6D-9E1C5F2A7B40"), "Is Wing Equipped", string.Empty); /// /// Gets the hit shock chance attribute definition. @@ -1535,6 +1547,17 @@ public class Stats /// public static AttributeDefinition IsDinorantEquipped { get; } = new(new Guid("C52B5CA4-34BA-4E31-963B-E37089671C37"), "Is Dinorant Equipped", string.Empty); + /// + /// Gets the target has dinorant health toll. + /// + /// The health loss caused by attacking a player wearing a dinorant. + public static AttributeDefinition TargetHasDinorantHealthToll { get; } = new(new Guid("E937BDF8-3DDB-40AF-BA0C-E18E7C69B7E9"), "Target Has Dinorant Health Toll", "The health loss caused by attacking a player wearing a dinorant"); + + /// + /// Gets the is imp equipped attribute definition. + /// + public static AttributeDefinition IsImpEquipped { get; } = new(new Guid("947DED52-3141-45AA-8D6E-F4C549ED5B36"), "Is Imp Equipped", string.Empty); + /// /// Gets the is pet skeleton equipped attribute definition. /// @@ -1716,6 +1739,11 @@ public class Stats MaximumValue = 1, }; + /// + /// Gets the skill health loss after dealt hit definition. + /// + public static AttributeDefinition SkillHealthLossAfterDealtHit { get; } = new(new Guid("BF8D6F29-7083-490F-978B-CCEBEEF139A1"), "Skill health loss after hitting a target", string.Empty); + /// /// Gets the dictionary which relates the jewelry element resistance attribute to the correspondent DMG bonus attribute. /// diff --git a/src/GameLogic/NPC/AttackableNpcBase.cs b/src/GameLogic/NPC/AttackableNpcBase.cs index f8c633552c..3ccf067fd0 100644 --- a/src/GameLogic/NPC/AttackableNpcBase.cs +++ b/src/GameLogic/NPC/AttackableNpcBase.cs @@ -109,6 +109,7 @@ public int Health public async ValueTask AttackByAsync(IAttacker attacker, SkillEntry? skill, bool isCombo, double damageFactor = 1.0, bool? isFinalStreakHit = null) { if (this.Definition.ObjectKind == NpcObjectKind.Guard + || !this.IsAlive || this.IsAttackBlockedBySafezone(attacker) || !this.CanBeAttackedBy(attacker)) { @@ -145,7 +146,7 @@ public int Health if (attacker is Player player) { - await player.AfterHitTargetAsync(this.Attributes[Stats.DefensePvm], skill?.Skill?.DamageType).ConfigureAwait(false); + await player.AfterHitTargetAsync(this.Attributes[Stats.DefensePvm], skill).ConfigureAwait(false); if (this.IsAlive && Rand.NextRandomBool(player.Attributes![Stats.MaceMasteryStunChance])) { diff --git a/src/GameLogic/Player.cs b/src/GameLogic/Player.cs index b08663d1c7..b989d551ee 100644 --- a/src/GameLogic/Player.cs +++ b/src/GameLogic/Player.cs @@ -816,7 +816,8 @@ public async ValueTask KillInstantlyAsync() throw new InvalidOperationException("AttributeSystem not set."); } - if (this.IsAttackBlockedBySafezone(attacker) + if (!this.IsAlive + || this.IsAttackBlockedBySafezone(attacker) || this.IsAttackPreventedByPlugIns(attacker)) { return null; @@ -862,6 +863,7 @@ public async ValueTask KillInstantlyAsync() await this.MagicEffectList.ClearAllEffectsProducingSpecificStatAsync(Stats.IsAsleep).ConfigureAwait(false); } + this.Attributes[Stats.CurrentHealth] -= this.Attributes[Stats.HealthLossAfterHit]; if (Rand.NextRandomBool(this.Attributes[Stats.FullyRecoverHealthAfterHitChance])) { this.Attributes[Stats.CurrentHealth] = this.Attributes[Stats.MaximumHealth]; @@ -886,7 +888,7 @@ public async ValueTask KillInstantlyAsync() if (attacker is Player attackerPlayer) { - await attackerPlayer.AfterHitTargetAsync(this.Attributes[Stats.DefenseFinal], skill?.Skill?.DamageType).ConfigureAwait(false); + await attackerPlayer.AfterHitTargetAsync(this.Attributes[Stats.DefenseFinal], skill, this).ConfigureAwait(false); if (this.IsAlive && Rand.NextRandomBool(attackerPlayer.Attributes![Stats.MaceMasteryStunChance])) { @@ -901,12 +903,29 @@ public async ValueTask KillInstantlyAsync() /// Is called after the player successfully hit a target. /// /// The target's defense. - /// The damage type. - public async ValueTask AfterHitTargetAsync(float targetDefense, DamageType? damageType) + /// The attacking skill. + /// The target player. + public async ValueTask AfterHitTargetAsync(float targetDefense, SkillEntry? skill, Player? target = null) { - this.Attributes![Stats.CurrentHealth] = Math.Max(this.Attributes[Stats.CurrentHealth] - this.Attributes[Stats.HealthLossAfterHit], 1); + var healthLossAfterDealtHit = this.Attributes![Stats.HealthLossAfterDealtHit]; + if (skill?.EnsureSkillAttributes(this.Attributes) is { } skillAttributes && skillAttributes[Stats.SkillHealthLossAfterDealtHit] > 0) + { + healthLossAfterDealtHit = skillAttributes[Stats.SkillHealthLossAfterDealtHit]; + } + + if (target?.Attributes?[Stats.IsDinorantEquipped] > 0) + { + healthLossAfterDealtHit += this.Attributes[Stats.TargetHasDinorantHealthToll]; + } + + this.Attributes[Stats.CurrentHealth] -= healthLossAfterDealtHit; + if (this.Attributes[Stats.CurrentHealth] < 1) + { + this.LastDeath = new DeathInformation(0, string.Empty, default, 0); + await this.OnDeathAsync(null).ConfigureAwait(false); + } - await this.DecreaseWeaponDurabilityAfterHitAsync(targetDefense, damageType ?? DamageType.Physical).ConfigureAwait(false); + await this.DecreaseWeaponDurabilityAfterHitAsync(targetDefense, skill?.Skill?.DamageType ?? DamageType.Physical).ConfigureAwait(false); } /// diff --git a/src/Persistence/Initialization/CharacterClasses/CharacterClassInitialization.cs b/src/Persistence/Initialization/CharacterClasses/CharacterClassInitialization.cs index a2df7edcd4..18a9d4bf27 100644 --- a/src/Persistence/Initialization/CharacterClasses/CharacterClassInitialization.cs +++ b/src/Persistence/Initialization/CharacterClasses/CharacterClassInitialization.cs @@ -143,6 +143,8 @@ private void AddCommonAttributeRelationships(ICollection attributeRelationships.Add(this.CreateAttributeRelationship(Stats.ManaRecoveryMultiplier, 0.03f, Stats.IsResting)); attributeRelationships.Add(this.CreateAttributeRelationship(Stats.AbilityRecoveryAbsolute, 3, Stats.IsInSafezone)); + attributeRelationships.Add(this.CreateAttributeRelationship(Stats.CanFly, 1, Stats.IsWingEquipped)); + if (this.UseClassicPvp) { attributeRelationships.Add(this.CreateAttributeRelationship(Stats.DefenseRatePvp, 1, Stats.DefenseRatePvm)); diff --git a/src/Persistence/Initialization/CharacterClasses/ClassDarkKnight.cs b/src/Persistence/Initialization/CharacterClasses/ClassDarkKnight.cs index 416a43f238..f1625cecda 100644 --- a/src/Persistence/Initialization/CharacterClasses/ClassDarkKnight.cs +++ b/src/Persistence/Initialization/CharacterClasses/ClassDarkKnight.cs @@ -88,6 +88,8 @@ protected CharacterClass CreateDarkKnight(CharacterClassNumber number, Localized result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 5, Stats.TotalVitality)); result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 7, Stats.TotalEnergy)); + result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.HealthLossAfterDealtHit, 3, Stats.IsWingEquipped)); + if (!this.UseClassicPvp) { result.StatAttributes.Add(this.CreateStatAttributeDefinition(Stats.CurrentShield, 1, false)); diff --git a/src/Persistence/Initialization/CharacterClasses/ClassDarkLord.cs b/src/Persistence/Initialization/CharacterClasses/ClassDarkLord.cs index 88dc645124..6ee6283c2f 100644 --- a/src/Persistence/Initialization/CharacterClasses/ClassDarkLord.cs +++ b/src/Persistence/Initialization/CharacterClasses/ClassDarkLord.cs @@ -89,6 +89,8 @@ private CharacterClass CreateDarkLord(CharacterClassNumber number, LocalizedStri result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 3, Stats.TotalEnergy)); result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 3, Stats.TotalLeadership)); + result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.HealthLossAfterDealtHit, 3, Stats.IsWingEquipped)); + result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.RavenMinimumDamage, 1.0f / 8, Stats.TotalLeadership)); result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.RavenMinimumDamage, 15, Stats.RavenLevel)); result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.RavenMaximumDamage, 1.0f / 4, Stats.TotalLeadership)); diff --git a/src/Persistence/Initialization/CharacterClasses/ClassDarkWizard.cs b/src/Persistence/Initialization/CharacterClasses/ClassDarkWizard.cs index 694703658d..437c6f2526 100644 --- a/src/Persistence/Initialization/CharacterClasses/ClassDarkWizard.cs +++ b/src/Persistence/Initialization/CharacterClasses/ClassDarkWizard.cs @@ -92,6 +92,8 @@ protected CharacterClass CreateDarkWizard(CharacterClassNumber number, Localized result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 7, Stats.TotalVitality)); result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 3, Stats.TotalEnergy)); + result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.HealthLossAfterDealtHit, 1, Stats.IsWingEquipped)); + if (!this.UseClassicPvp) { result.StatAttributes.Add(this.CreateStatAttributeDefinition(Stats.CurrentShield, 1, false)); diff --git a/src/Persistence/Initialization/CharacterClasses/ClassFairyElf.cs b/src/Persistence/Initialization/CharacterClasses/ClassFairyElf.cs index 27eb128ce7..57f3c29a89 100644 --- a/src/Persistence/Initialization/CharacterClasses/ClassFairyElf.cs +++ b/src/Persistence/Initialization/CharacterClasses/ClassFairyElf.cs @@ -101,6 +101,8 @@ protected CharacterClass CreateFairyElf(CharacterClassNumber number, LocalizedSt result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 7, Stats.TotalVitality)); result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 5, Stats.TotalEnergy)); + result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.HealthLossAfterDealtHit, 1, Stats.IsWingEquipped)); + if (!this.UseClassicPvp) { result.StatAttributes.Add(this.CreateStatAttributeDefinition(Stats.CurrentShield, 1, false)); diff --git a/src/Persistence/Initialization/CharacterClasses/ClassMagicGladiator.cs b/src/Persistence/Initialization/CharacterClasses/ClassMagicGladiator.cs index af63dfe524..0f1e90142c 100644 --- a/src/Persistence/Initialization/CharacterClasses/ClassMagicGladiator.cs +++ b/src/Persistence/Initialization/CharacterClasses/ClassMagicGladiator.cs @@ -103,6 +103,8 @@ protected CharacterClass CreateMagicGladiator(CharacterClassNumber number, Local result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 5, Stats.TotalVitality)); result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 7, Stats.TotalEnergy)); + result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.HealthLossAfterDealtHit, 3, Stats.IsWingEquipped)); + if (!this.UseClassicPvp) { result.StatAttributes.Add(this.CreateStatAttributeDefinition(Stats.CurrentShield, 1, false)); diff --git a/src/Persistence/Initialization/CharacterClasses/ClassRageFighter.cs b/src/Persistence/Initialization/CharacterClasses/ClassRageFighter.cs index e7d9efbcca..78151ed1b0 100644 --- a/src/Persistence/Initialization/CharacterClasses/ClassRageFighter.cs +++ b/src/Persistence/Initialization/CharacterClasses/ClassRageFighter.cs @@ -94,6 +94,8 @@ private CharacterClass CreateRageFighter(CharacterClassNumber number, LocalizedS result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 3, Stats.TotalVitality)); result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 7, Stats.TotalEnergy)); + result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.HealthLossAfterDealtHit, 3, Stats.IsWingEquipped)); + result.BaseAttributeValues.Add(this.CreateConstValueAttribute(57, Stats.MaximumHealth)); result.BaseAttributeValues.Add(this.CreateConstValueAttribute(7, Stats.MaximumMana)); result.BaseAttributeValues.Add(this.CreateConstValueAttribute(0.5f, Stats.SkillMultiplier)); diff --git a/src/Persistence/Initialization/CharacterClasses/ClassSummoner.cs b/src/Persistence/Initialization/CharacterClasses/ClassSummoner.cs index afb28d6430..a837923a14 100644 --- a/src/Persistence/Initialization/CharacterClasses/ClassSummoner.cs +++ b/src/Persistence/Initialization/CharacterClasses/ClassSummoner.cs @@ -137,6 +137,8 @@ private CharacterClass CreateSummoner(CharacterClassNumber number, LocalizedStri result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 7, Stats.TotalVitality)); result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.FenrirBaseDmg, 1.0f / 3, Stats.TotalEnergy)); + result.AttributeCombinations.Add(this.CreateAttributeRelationship(Stats.HealthLossAfterDealtHit, 1, Stats.IsWingEquipped)); + result.BaseAttributeValues.Add(this.CreateConstValueAttribute(39, Stats.MaximumHealth)); result.BaseAttributeValues.Add(this.CreateConstValueAttribute(6, Stats.MaximumMana)); result.BaseAttributeValues.Add(this.CreateConstValueAttribute(1, Stats.SkillMultiplier)); diff --git a/src/Persistence/Initialization/GameConfigurationInitializerBase.cs b/src/Persistence/Initialization/GameConfigurationInitializerBase.cs index 3f61089f45..72de5ce4ef 100644 --- a/src/Persistence/Initialization/GameConfigurationInitializerBase.cs +++ b/src/Persistence/Initialization/GameConfigurationInitializerBase.cs @@ -319,5 +319,8 @@ private void AddGlobalBaseAttributeValues() var hitShockDamageThreshold = this.Context.CreateNew(5f, Stats.HitShockDamageThreshold.GetPersistent(this.GameConfiguration), AggregateType.AddRaw); this.GameConfiguration.GlobalBaseAttributeValues.Add(hitShockDamageThreshold); + + var targetHasDinorantHealthToll = this.Context.CreateNew(1f, Stats.TargetHasDinorantHealthToll.GetPersistent(this.GameConfiguration), AggregateType.AddRaw); + this.GameConfiguration.GlobalBaseAttributeValues.Add(targetHasDinorantHealthToll); } } diff --git a/src/Persistence/Initialization/Properties/PlugInResources.Designer.cs b/src/Persistence/Initialization/Properties/PlugInResources.Designer.cs index b28f142580..aafe96d11a 100644 --- a/src/Persistence/Initialization/Properties/PlugInResources.Designer.cs +++ b/src/Persistence/Initialization/Properties/PlugInResources.Designer.cs @@ -2886,6 +2886,24 @@ public static string SystemConfigurationAddedPlugInBase_Name { } } + /// + /// Looks up a localized string similar to Updates wing flight attributes, pet hit tolls, and skill-specific hit tolls for Season Six.. + /// + public static string UpdateWingAndPetHitTollsPlugIn_Description { + get { + return ResourceManager.GetString("UpdateWingAndPetHitTollsPlugIn_Description", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to Update wing and pet hit tolls. + /// + public static string UpdateWingAndPetHitTollsPlugIn_Name { + get { + return ResourceManager.GetString("UpdateWingAndPetHitTollsPlugIn_Name", resourceCulture); + } + } + /// /// Looks up a localized string similar to This update adds the following skills: Wizardry Enhance, Increase Health, Increase Block, Ignore Defense.. /// diff --git a/src/Persistence/Initialization/Properties/PlugInResources.de.resx b/src/Persistence/Initialization/Properties/PlugInResources.de.resx index d3cdd1df9f..ded19c1fe6 100644 --- a/src/Persistence/Initialization/Properties/PlugInResources.de.resx +++ b/src/Persistence/Initialization/Properties/PlugInResources.de.resx @@ -942,6 +942,12 @@ Fügt die globalen Einstellungen für Treffer-Schock-Chance und Schadensschwelle sowie die Uniria-Kennzeichnung hinzu, damit Spieler mit ausgerüsteter Uniria keinen Treffer-Schock erleiden. + + Flügel- und Begleiter-Zoll aktualisieren + + + Aktualisiert Flugattribute für Flügel, Trefferabzüge für Begleiter und fertigkeitsabhängige Trefferabzüge für Season Six. + Item-Droprate der Siegel hinzufügen diff --git a/src/Persistence/Initialization/Properties/PlugInResources.resx b/src/Persistence/Initialization/Properties/PlugInResources.resx index 2d2d07d4a6..67c59c2066 100644 --- a/src/Persistence/Initialization/Properties/PlugInResources.resx +++ b/src/Persistence/Initialization/Properties/PlugInResources.resx @@ -444,6 +444,8 @@ This update adds the invitation to the santa village, which warps the player to the santa village, and a spawn gate to the santa village. Add hit-shock settings Adds the global hit-shock chance and damage threshold settings, and the Uniria marker so Uniria-equipped players are excluded from hit shock. + Update wing and pet hit tolls + Updates wing flight attributes, pet hit tolls, and skill-specific hit tolls for Season Six. Fix Kanturu Ruins 3 landing area Narrows the original Kanturu Ruins 3 warp landing area to walkable terrain. Customized destinations and unrelated settings are kept. Add the item drop rate of seals diff --git a/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugIn075.cs b/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugIn075.cs new file mode 100644 index 0000000000..51f47ab87c --- /dev/null +++ b/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugIn075.cs @@ -0,0 +1,21 @@ +// +// 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 MUnique.OpenMU.Persistence.Initialization.Properties; +using MUnique.OpenMU.PlugIns; + +/// +/// Updates wing and pet hit toll configuration for version 0.75. +/// +[PlugIn] +[Display(Name = nameof(PlugInResources.UpdateWingAndPetHitTollsPlugIn_Name), Description = nameof(PlugInResources.UpdateWingAndPetHitTollsPlugIn_Description), ResourceType = typeof(PlugInResources))] +[Guid("6C3AA59D-83A9-45E7-A07F-B5CC77D7F528")] +public class UpdateWingAndPetHitTollsPlugIn075 : UpdateWingAndPetHitTollsPlugInBase +{ + /// + public override string DataInitializationKey => Version075.DataInitialization.Id; +} \ No newline at end of file diff --git a/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugIn095d.cs b/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugIn095d.cs new file mode 100644 index 0000000000..b92198cf74 --- /dev/null +++ b/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugIn095d.cs @@ -0,0 +1,21 @@ +// +// 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 MUnique.OpenMU.Persistence.Initialization.Properties; +using MUnique.OpenMU.PlugIns; + +/// +/// Updates wing and pet hit toll configuration for version 0.95d. +/// +[PlugIn] +[Display(Name = nameof(PlugInResources.UpdateWingAndPetHitTollsPlugIn_Name), Description = nameof(PlugInResources.UpdateWingAndPetHitTollsPlugIn_Description), ResourceType = typeof(PlugInResources))] +[Guid("8455AD08-2FE4-468B-901A-F7006D099FEC")] +public class UpdateWingAndPetHitTollsPlugIn095D : UpdateWingAndPetHitTollsPlugInBase +{ + /// + public override string DataInitializationKey => Version095d.DataInitialization.Id; +} \ No newline at end of file diff --git a/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugInBase.cs b/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugInBase.cs new file mode 100644 index 0000000000..752c8e9434 --- /dev/null +++ b/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugInBase.cs @@ -0,0 +1,195 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.Persistence.Initialization.Updates; + +using MUnique.OpenMU.AttributeSystem; +using MUnique.OpenMU.DataModel.Configuration; +using MUnique.OpenMU.DataModel.Configuration.Items; +using MUnique.OpenMU.GameLogic.Attributes; +using MUnique.OpenMU.Persistence.Initialization.CharacterClasses; +using MUnique.OpenMU.Persistence.Initialization.Properties; +using MUnique.OpenMU.Persistence.Initialization.Skills; + +/// +/// Updates the wing and pet attributes used for hit tolls and flight. +/// +public abstract class UpdateWingAndPetHitTollsPlugInBase : UpdatePlugInBase +{ + /// + /// Gets the skill-specific toll values used by the Season Six update. + /// + protected static readonly (short SkillNumber, float Toll)[] SkillTolls = + [ + ((short)SkillNumber.KillingBlow, 2), + ((short)SkillNumber.BeastUppercut, 2), + ((short)SkillNumber.DragonRoar, 2), + ((short)SkillNumber.PhoenixShot, 2), + ((short)SkillNumber.DarkSide, 4), + ((short)SkillNumber.Charge, 4), + ((short)SkillNumber.ChainDrive, 4), + ((short)SkillNumber.DragonSlasher, 100), + ]; + + /// + public override string Name => PlugInResources.UpdateWingAndPetHitTollsPlugIn_Name; + + /// + public override string Description => PlugInResources.UpdateWingAndPetHitTollsPlugIn_Description; + + /// + public override bool IsMandatory => true; + + /// + public override DateTime CreatedAt => new(2026, 11, 23, 0, 0, 0, DateTimeKind.Utc); + + /// + /// Adds or updates a relationship between two attributes. + /// + /// The persistence context. + /// The collection of relationships to update. + /// The game configuration. + /// The target attribute. + /// The input multiplier. + /// The input attribute. + protected static void SetAttributeRelationship( + IContext context, + ICollection relationships, + GameConfiguration gameConfiguration, + AttributeDefinition targetAttribute, + float multiplier, + AttributeDefinition inputAttribute) + { + var persistentTarget = targetAttribute.GetPersistent(gameConfiguration); + var persistentInput = inputAttribute.GetPersistent(gameConfiguration); + var relationship = relationships.FirstOrDefault(existing => + existing.TargetAttribute?.Id == persistentTarget.Id + && existing.InputAttribute?.Id == persistentInput.Id + && existing.OperandAttribute is null + && existing.InputOperator == InputOperator.Multiply); + + if (relationship is null) + { + relationship = context.CreateNew(); + relationships.Add(relationship); + } + + relationship.TargetAttribute = persistentTarget; + relationship.InputAttribute = persistentInput; + relationship.OperandAttribute = null; + relationship.InputOperator = InputOperator.Multiply; + relationship.InputOperand = multiplier; + relationship.AggregateType = AggregateType.AddRaw; + } + + /// + protected override ValueTask ApplyAsync(IContext context, GameConfiguration gameConfiguration) + { + this.AddStatIfNotExists(context, gameConfiguration, Stats.IsWingEquipped); + this.AddStatIfNotExists(context, gameConfiguration, Stats.HealthLossAfterHit); + this.AddStatIfNotExists(context, gameConfiguration, Stats.IsImpEquipped); + this.AddStatIfNotExists(context, gameConfiguration, Stats.SkillHealthLossAfterDealtHit); + this.AddStatIfNotExists(context, gameConfiguration, Stats.TargetHasDinorantHealthToll); + + this.AddGlobalBaseAttributeValueIfNotExists(context, gameConfiguration, Stats.TargetHasDinorantHealthToll, 1); + this.UpdateCharacterClassRelationships(context, gameConfiguration); + this.UpdateWingPowerUps(context, gameConfiguration); + this.UpdatePetPowerUps(context, gameConfiguration); + this.UpdateSkillTolls(context, gameConfiguration); + return ValueTask.CompletedTask; + } + + /// + /// Updates the skill-specific toll relationships, if supported by the game version. + /// + /// The persistence context. + /// The game configuration. + protected virtual void UpdateSkillTolls(IContext context, GameConfiguration gameConfiguration) + { + } + + private void AddGlobalBaseAttributeValueIfNotExists(IContext context, GameConfiguration gameConfiguration, AttributeDefinition attribute, float value) + { + var persistentAttribute = attribute.GetPersistent(gameConfiguration); + if (gameConfiguration.GlobalBaseAttributeValues.Any(existingValue => existingValue.Definition?.Id == persistentAttribute.Id)) + { + return; + } + + gameConfiguration.GlobalBaseAttributeValues.Add(context.CreateNew(value, persistentAttribute, AggregateType.AddRaw)); + } + + private void UpdateCharacterClassRelationships(IContext context, GameConfiguration gameConfiguration) + { + foreach (var characterClass in gameConfiguration.CharacterClasses) + { + SetAttributeRelationship(context, characterClass.AttributeCombinations, gameConfiguration, Stats.CanFly, 1, Stats.IsWingEquipped); + + var classNumber = (CharacterClassNumber)characterClass.Number; + var healthToll = classNumber switch + { + CharacterClassNumber.DarkKnight + or CharacterClassNumber.BladeKnight + or CharacterClassNumber.BladeMaster + or CharacterClassNumber.MagicGladiator + or CharacterClassNumber.DuelMaster + or CharacterClassNumber.DarkLord + or CharacterClassNumber.LordEmperor + or CharacterClassNumber.RageFighter + or CharacterClassNumber.FistMaster => 3, + _ => 1, + }; + SetAttributeRelationship(context, characterClass.AttributeCombinations, gameConfiguration, Stats.HealthLossAfterDealtHit, healthToll, Stats.IsWingEquipped); + } + } + + private void UpdateWingPowerUps(IContext context, GameConfiguration gameConfiguration) + { + var canFly = Stats.CanFly.GetPersistent(gameConfiguration); + var isWingEquipped = Stats.IsWingEquipped.GetPersistent(gameConfiguration); + foreach (var wing in gameConfiguration.Items.Where(item => item.Group == 12)) + { + foreach (var powerUp in wing.BasePowerUpAttributes.Where(powerUp => powerUp.TargetAttribute?.Id == canFly.Id)) + { + powerUp.TargetAttribute = isWingEquipped; + } + + this.SetItemPowerUp(context, gameConfiguration, wing, Stats.IsWingEquipped, 1, AggregateType.AddRaw); + } + } + + private void UpdatePetPowerUps(IContext context, GameConfiguration gameConfiguration) + { + foreach (var imp in gameConfiguration.Items.Where(item => item.Group == 13 && item.Number == 1)) + { + this.SetItemPowerUp(context, gameConfiguration, imp, Stats.IsImpEquipped, 1, AggregateType.AddRaw); + this.SetItemPowerUp(context, gameConfiguration, imp, Stats.HealthLossAfterDealtHit, 3, AggregateType.AddRaw); + } + + foreach (var dinorant in gameConfiguration.Items.Where(item => item.Group == 13 && item.Number == 3)) + { + this.SetItemPowerUp(context, gameConfiguration, dinorant, Stats.HealthLossAfterDealtHit, 1, AggregateType.AddRaw); + } + + foreach (var darkHorse in gameConfiguration.Items.Where(item => item.Group == 13 && item.Number == 4)) + { + this.SetItemPowerUp(context, gameConfiguration, darkHorse, Stats.HealthLossAfterHit, 1, AggregateType.AddRaw); + } + } + + private void SetItemPowerUp(IContext context, GameConfiguration gameConfiguration, ItemDefinition item, AttributeDefinition attribute, float value, AggregateType aggregateType) + { + var persistentAttribute = attribute.GetPersistent(gameConfiguration); + var powerUp = item.BasePowerUpAttributes.FirstOrDefault(existing => existing.TargetAttribute?.Id == persistentAttribute.Id); + if (powerUp is null) + { + powerUp = context.CreateNew(); + item.BasePowerUpAttributes.Add(powerUp); + } + + powerUp.TargetAttribute = persistentAttribute; + powerUp.BaseValue = value; + powerUp.AggregateType = aggregateType; + } +} \ No newline at end of file diff --git a/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugInSeasonSix.cs b/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugInSeasonSix.cs new file mode 100644 index 0000000000..d895de8ab1 --- /dev/null +++ b/src/Persistence/Initialization/Updates/UpdateWingAndPetHitTollsPlugInSeasonSix.cs @@ -0,0 +1,45 @@ +// +// 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 MUnique.OpenMU.AttributeSystem; +using MUnique.OpenMU.DataModel.Configuration; +using MUnique.OpenMU.GameLogic.Attributes; +using MUnique.OpenMU.Persistence.Initialization.Properties; +using MUnique.OpenMU.PlugIns; + +/// +/// Updates wing, pet, and skill hit toll configuration for Season Six. +/// +[PlugIn] +[Display(Name = nameof(PlugInResources.UpdateWingAndPetHitTollsPlugIn_Name), Description = nameof(PlugInResources.UpdateWingAndPetHitTollsPlugIn_Description), ResourceType = typeof(PlugInResources))] +[Guid("D7D5EE55-51DA-4D38-9B0D-50EB2E121C37")] +public class UpdateWingAndPetHitTollsPlugInSeasonSix : UpdateWingAndPetHitTollsPlugInBase +{ + /// + public override string DataInitializationKey => VersionSeasonSix.DataInitialization.Id; + + /// + protected override void UpdateSkillTolls(IContext context, GameConfiguration gameConfiguration) + { + foreach (var (skillNumber, toll) in SkillTolls) + { + var skill = gameConfiguration.Skills.FirstOrDefault(existing => existing.Number == skillNumber); + if (skill is null) + { + continue; + } + + SetSkillToll(context, gameConfiguration, skill.AttributeRelationships, toll, Stats.IsImpEquipped); + SetSkillToll(context, gameConfiguration, skill.AttributeRelationships, toll, Stats.IsWingEquipped); + } + } + + private static void SetSkillToll(IContext context, GameConfiguration gameConfiguration, ICollection relationships, float toll, AttributeDefinition inputAttribute) + { + SetAttributeRelationship(context, relationships, gameConfiguration, Stats.SkillHealthLossAfterDealtHit, toll, inputAttribute); + } +} \ No newline at end of file diff --git a/src/Persistence/Initialization/Version075/Items/Pets.cs b/src/Persistence/Initialization/Version075/Items/Pets.cs index b9c51f807b..883f043182 100644 --- a/src/Persistence/Initialization/Version075/Items/Pets.cs +++ b/src/Persistence/Initialization/Version075/Items/Pets.cs @@ -42,7 +42,9 @@ public override void Initialize() 1, LocalizedString.FromResource(() => ItemNames.Imp), 28, - (Stats.AttackDamageIncrease, 1.3f, AggregateType.Multiplicate)); + (Stats.IsImpEquipped, 1.0f, AggregateType.AddRaw), + (Stats.AttackDamageIncrease, 1.3f, AggregateType.Multiplicate), + (Stats.HealthLossAfterDealtHit, 3.0f, AggregateType.AddRaw)); this.AddItemToJewelItemDrop(imp); var uniria = this.CreatePet( 2, diff --git a/src/Persistence/Initialization/Version075/Items/Wings.cs b/src/Persistence/Initialization/Version075/Items/Wings.cs index 55ead05fc8..64b574351d 100644 --- a/src/Persistence/Initialization/Version075/Items/Wings.cs +++ b/src/Persistence/Initialization/Version075/Items/Wings.cs @@ -120,11 +120,11 @@ private ItemDefinition CreateWing(byte number, byte width, byte height, Localize wing.QualifiedCharacters.Add(characterClass); } - // add CanFly Attribute to all wings - var canFlyPowerUp = this.Context.CreateNew(); - canFlyPowerUp.TargetAttribute = Stats.CanFly.GetPersistent(this.GameConfiguration); - canFlyPowerUp.BaseValue = 1; - wing.BasePowerUpAttributes.Add(canFlyPowerUp); + // add IsWingEquipped Attribute to all wings + var isWingEquippedPowerUp = this.Context.CreateNew(); + isWingEquippedPowerUp.TargetAttribute = Stats.IsWingEquipped.GetPersistent(this.GameConfiguration); + isWingEquippedPowerUp.BaseValue = 1; + wing.BasePowerUpAttributes.Add(isWingEquippedPowerUp); wing.BasePowerUpAttributes.Add(this.CreateItemBasePowerUpDefinition(Stats.MovementSpeed, MovementSpeedConstants.DefaultWingMovementSpeed, AggregateType.Maximum)); wing.BasePowerUpAttributes.Add(this.CreateItemBasePowerUpDefinition(Stats.MovementSpeedUnderwater, MovementSpeedConstants.DefaultWingMovementSpeed, AggregateType.Maximum)); diff --git a/src/Persistence/Initialization/Version095d/Items/Pets.cs b/src/Persistence/Initialization/Version095d/Items/Pets.cs index e56d358966..c7a60eaaba 100644 --- a/src/Persistence/Initialization/Version095d/Items/Pets.cs +++ b/src/Persistence/Initialization/Version095d/Items/Pets.cs @@ -47,7 +47,9 @@ public override void Initialize() LocalizedString.FromResource(() => ItemNames.Imp), 28, true, - (Stats.AttackDamageIncrease, 1.3f, AggregateType.Multiplicate)); + (Stats.IsImpEquipped, 1.0f, AggregateType.AddRaw), + (Stats.AttackDamageIncrease, 1.3f, AggregateType.Multiplicate), + (Stats.HealthLossAfterDealtHit, 3.0f, AggregateType.AddRaw)); this.AddItemToJewelItemDrop(imp); var uniria = this.CreatePet( 2, @@ -71,7 +73,8 @@ public override void Initialize() (Stats.MovementSpeed, MovementSpeedConstants.BasicMountMovementSpeed, AggregateType.Maximum), (Stats.MovementSpeedUnderwater, MovementSpeedConstants.BasicMountMovementSpeed, AggregateType.Maximum), (Stats.DamageReceiveDecrement, 0.9f, AggregateType.Multiplicate), - (Stats.AttackDamageIncrease, 1.15f, AggregateType.Multiplicate)); + (Stats.AttackDamageIncrease, 1.15f, AggregateType.Multiplicate), + (Stats.HealthLossAfterDealtHit, 1.0f, AggregateType.AddRaw)); this.AddDinorantOptions(dinorant); } diff --git a/src/Persistence/Initialization/Version095d/Items/Wings.cs b/src/Persistence/Initialization/Version095d/Items/Wings.cs index 5508755bfa..d1106962ca 100644 --- a/src/Persistence/Initialization/Version095d/Items/Wings.cs +++ b/src/Persistence/Initialization/Version095d/Items/Wings.cs @@ -116,11 +116,11 @@ private ItemDefinition CreateWing(byte number, byte width, byte height, Localize var qualifiedCharacterClasses = this.GameConfiguration.DetermineCharacterClasses(qualifiedClasses); qualifiedCharacterClasses.ToList().ForEach(wing.QualifiedCharacters.Add); - // add CanFly Attribute to all wings - var canFlyPowerUp = this.Context.CreateNew(); - canFlyPowerUp.TargetAttribute = Stats.CanFly.GetPersistent(this.GameConfiguration); - canFlyPowerUp.BaseValue = 1; - wing.BasePowerUpAttributes.Add(canFlyPowerUp); + // add IsWingEquipped Attribute to all wings + var isWingEquippedPowerUp = this.Context.CreateNew(); + isWingEquippedPowerUp.TargetAttribute = Stats.IsWingEquipped.GetPersistent(this.GameConfiguration); + isWingEquippedPowerUp.BaseValue = 1; + wing.BasePowerUpAttributes.Add(isWingEquippedPowerUp); wing.BasePowerUpAttributes.Add(this.CreateItemBasePowerUpDefinition(Stats.MovementSpeed, MovementSpeedConstants.DefaultWingMovementSpeed, AggregateType.Maximum)); wing.BasePowerUpAttributes.Add(this.CreateItemBasePowerUpDefinition(Stats.MovementSpeedUnderwater, MovementSpeedConstants.DefaultWingMovementSpeed, AggregateType.Maximum)); diff --git a/src/Persistence/Initialization/VersionSeasonSix/Items/Pets.cs b/src/Persistence/Initialization/VersionSeasonSix/Items/Pets.cs index 7e3a5a6d9c..ad79cec8a1 100644 --- a/src/Persistence/Initialization/VersionSeasonSix/Items/Pets.cs +++ b/src/Persistence/Initialization/VersionSeasonSix/Items/Pets.cs @@ -64,7 +64,9 @@ public override void Initialize() 28, true, true, - (Stats.AttackDamageIncrease, 1.3f, AggregateType.Multiplicate)); + (Stats.IsImpEquipped, 1.0f, AggregateType.AddRaw), + (Stats.AttackDamageIncrease, 1.3f, AggregateType.Multiplicate), + (Stats.HealthLossAfterDealtHit, 3.0f, AggregateType.AddRaw)); this.AddItemToJewelItemDrop(imp); var uniria = this.CreatePet( 2, @@ -94,7 +96,8 @@ public override void Initialize() (Stats.MovementSpeed, MovementSpeedConstants.BasicMountMovementSpeed, AggregateType.Maximum), (Stats.MovementSpeedUnderwater, MovementSpeedConstants.BasicMountMovementSpeed, AggregateType.Maximum), (Stats.DamageReceiveDecrement, 0.9f, AggregateType.Multiplicate), - (Stats.AttackDamageIncrease, 1.15f, AggregateType.Multiplicate)); + (Stats.AttackDamageIncrease, 1.15f, AggregateType.Multiplicate), + (Stats.HealthLossAfterDealtHit, 1.0f, AggregateType.AddRaw)); this.AddDinorantOptions(dinorant); var darkHorse = this.CreatePet( @@ -109,7 +112,8 @@ public override void Initialize() (Stats.IsHorseEquipped, 1, AggregateType.AddRaw), (Stats.CanFly, 1.0f, AggregateType.AddRaw), (Stats.MovementSpeed, MovementSpeedConstants.HorseOrFenrirMovementSpeed, AggregateType.Maximum), - (Stats.MovementSpeedUnderwater, MovementSpeedConstants.HorseOrFenrirMovementSpeed, AggregateType.Maximum)); + (Stats.MovementSpeedUnderwater, MovementSpeedConstants.HorseOrFenrirMovementSpeed, AggregateType.Maximum), + (Stats.HealthLossAfterHit, 1.0f, AggregateType.AddRaw)); this.AddDarkHorseOptions(darkHorse); this.GameConfiguration.DetermineCharacterClasses(CharacterClasses.AllLords).ForEach(darkHorse.QualifiedCharacters.Add); darkHorse.PetExperienceFormula = PetExperienceFormula; diff --git a/src/Persistence/Initialization/VersionSeasonSix/Items/Wings.cs b/src/Persistence/Initialization/VersionSeasonSix/Items/Wings.cs index cedf35455f..1f1af35280 100644 --- a/src/Persistence/Initialization/VersionSeasonSix/Items/Wings.cs +++ b/src/Persistence/Initialization/VersionSeasonSix/Items/Wings.cs @@ -312,11 +312,11 @@ private ItemDefinition CreateWing(byte number, byte width, byte height, Localize wing.QualifiedCharacters.Add(characterClass); } - // add CanFly Attribute to all wings - var canFlyPowerUp = this.Context.CreateNew(); - canFlyPowerUp.TargetAttribute = Stats.CanFly.GetPersistent(this.GameConfiguration); - canFlyPowerUp.BaseValue = 1; - wing.BasePowerUpAttributes.Add(canFlyPowerUp); + // add IsWingEquipped Attribute to all wings + var isWingEquippedPowerUp = this.Context.CreateNew(); + isWingEquippedPowerUp.TargetAttribute = Stats.IsWingEquipped.GetPersistent(this.GameConfiguration); + isWingEquippedPowerUp.BaseValue = 1; + wing.BasePowerUpAttributes.Add(isWingEquippedPowerUp); wing.BasePowerUpAttributes.Add(this.CreateItemBasePowerUpDefinition(Stats.MovementSpeed, movementSpeed, AggregateType.Maximum)); wing.BasePowerUpAttributes.Add(this.CreateItemBasePowerUpDefinition(Stats.MovementSpeedUnderwater, movementSpeed, AggregateType.Maximum)); diff --git a/src/Persistence/Initialization/VersionSeasonSix/SkillsInitializer.cs b/src/Persistence/Initialization/VersionSeasonSix/SkillsInitializer.cs index c853f58838..0a846e85c6 100644 --- a/src/Persistence/Initialization/VersionSeasonSix/SkillsInitializer.cs +++ b/src/Persistence/Initialization/VersionSeasonSix/SkillsInitializer.cs @@ -695,6 +695,26 @@ private void InitializeSkillAttributes() this.AddAttributeRelationship(SkillNumber.TripleShot, Stats.SkillExtraProjectiles, 1, Stats.ExtraProjectiles); this.AddAttributeRelationship(SkillNumber.TripleShot, Stats.SkillExtraProjectiles, 1, Stats.TripleShotExtraProjectiles); this.AddAttributeRelationship(SkillNumber.MultiShot, Stats.SkillExtraProjectiles, 1, Stats.ExtraProjectiles); + + // Imp toll damage + this.AddAttributeRelationship(SkillNumber.KillingBlow, Stats.SkillHealthLossAfterDealtHit, 2.0f, Stats.IsImpEquipped); + this.AddAttributeRelationship(SkillNumber.BeastUppercut, Stats.SkillHealthLossAfterDealtHit, 2.0f, Stats.IsImpEquipped); + this.AddAttributeRelationship(SkillNumber.DragonRoar, Stats.SkillHealthLossAfterDealtHit, 2.0f, Stats.IsImpEquipped); + this.AddAttributeRelationship(SkillNumber.PhoenixShot, Stats.SkillHealthLossAfterDealtHit, 2.0f, Stats.IsImpEquipped); + this.AddAttributeRelationship(SkillNumber.DarkSide, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsImpEquipped); + this.AddAttributeRelationship(SkillNumber.Charge, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsImpEquipped); + this.AddAttributeRelationship(SkillNumber.ChainDrive, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsImpEquipped); + this.AddAttributeRelationship(SkillNumber.DragonSlasher, Stats.SkillHealthLossAfterDealtHit, 100.0f, Stats.IsImpEquipped); + + // Wings toll damage + this.AddAttributeRelationship(SkillNumber.KillingBlow, Stats.SkillHealthLossAfterDealtHit, 2.0f, Stats.IsWingEquipped); + this.AddAttributeRelationship(SkillNumber.BeastUppercut, Stats.SkillHealthLossAfterDealtHit, 2.0f, Stats.IsWingEquipped); + this.AddAttributeRelationship(SkillNumber.DragonRoar, Stats.SkillHealthLossAfterDealtHit, 2.0f, Stats.IsWingEquipped); + this.AddAttributeRelationship(SkillNumber.PhoenixShot, Stats.SkillHealthLossAfterDealtHit, 2.0f, Stats.IsWingEquipped); + this.AddAttributeRelationship(SkillNumber.DarkSide, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsWingEquipped); + this.AddAttributeRelationship(SkillNumber.Charge, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsWingEquipped); + this.AddAttributeRelationship(SkillNumber.ChainDrive, Stats.SkillHealthLossAfterDealtHit, 4.0f, Stats.IsWingEquipped); + this.AddAttributeRelationship(SkillNumber.DragonSlasher, Stats.SkillHealthLossAfterDealtHit, 100.0f, Stats.IsWingEquipped); } private void AddAttributeRelationship(SkillNumber skillNumber, AttributeDefinition targetAttribute, float multiplier, AttributeDefinition sourceAttribute, InputOperator inputOperator = InputOperator.Multiply, AggregateType aggregateType = AggregateType.AddRaw) diff --git a/tests/MUnique.OpenMU.Persistence.Initialization.Tests/SmallWingsDataTest.cs b/tests/MUnique.OpenMU.Persistence.Initialization.Tests/SmallWingsDataTest.cs index dcde602337..daf2dd2fcf 100644 --- a/tests/MUnique.OpenMU.Persistence.Initialization.Tests/SmallWingsDataTest.cs +++ b/tests/MUnique.OpenMU.Persistence.Initialization.Tests/SmallWingsDataTest.cs @@ -77,6 +77,9 @@ private static void AssertSmallWing(GameConfiguration gameConfiguration, short n { var item = gameConfiguration.Items.Single(i => i.Group == 12 && i.Number == number); var wingsOfElf = gameConfiguration.Items.Single(i => i is { Group: 12, Number: 0 }); + var icarusRequirement = gameConfiguration.Maps + .Single(map => map.Number == Version095d.Maps.Icarus.Number) + .MapRequirements.Single(requirement => requirement.Attribute == Stats.CanFly); Assert.Multiple(() => { @@ -93,9 +96,18 @@ private static void AssertSmallWing(GameConfiguration gameConfiguration, short n Assert.That(GetPowerUp(item, Stats.DefenseBase).BaseValue, Is.EqualTo(defense)); Assert.That(GetPowerUp(item, Stats.AttackDamageIncrease).BaseValue, Is.EqualTo(1f + (damagePercent / 100f))); Assert.That(GetPowerUp(item, Stats.DamageReceiveDecrement).BaseValue, Is.EqualTo(1f - (damagePercent / 100f))); - Assert.That(GetPowerUp(item, Stats.CanFly).BaseValue, Is.EqualTo(1)); + Assert.That(GetPowerUp(item, Stats.IsWingEquipped).BaseValue, Is.EqualTo(1)); Assert.That(GetPowerUp(item, Stats.MovementSpeed).BaseValue, Is.EqualTo(GetPowerUp(wingsOfElf, Stats.MovementSpeed).BaseValue)); + foreach (var characterClass in item.QualifiedCharacters) + { + using var attributes = new AttributeSystem([], [], characterClass.AttributeCombinations); + attributes.AddElement(new SimpleElement(1, AggregateType.AddRaw), Stats.IsWingEquipped); + + Assert.That(attributes[Stats.CanFly], Is.GreaterThanOrEqualTo(icarusRequirement.MinimumValue), $"{characterClass.Name} can enter Icarus with these wings"); + Assert.That(attributes[Stats.HealthLossAfterDealtHit], Is.EqualTo(GetWingHealthToll(characterClass)), $"{characterClass.Name} pays the wing health toll"); + } + // The bonus per level is the same as for the first wings. foreach (var attribute in new[] { Stats.DefenseBase, Stats.AttackDamageIncrease, Stats.DamageReceiveDecrement }) { @@ -111,6 +123,23 @@ private static void AssertSmallWing(GameConfiguration gameConfiguration, short n }); } + private static float GetWingHealthToll(CharacterClass characterClass) + { + return (CharacterClassNumber)characterClass.Number switch + { + CharacterClassNumber.DarkKnight + or CharacterClassNumber.BladeKnight + or CharacterClassNumber.BladeMaster + or CharacterClassNumber.MagicGladiator + or CharacterClassNumber.DuelMaster + or CharacterClassNumber.DarkLord + or CharacterClassNumber.LordEmperor + or CharacterClassNumber.RageFighter + or CharacterClassNumber.FistMaster => 3, + _ => 1, + }; + } + private static ItemBasePowerUpDefinition GetPowerUp(ItemDefinition item, AttributeDefinition attribute) { return item.BasePowerUpAttributes.Single(p => p.TargetAttribute == attribute); diff --git a/tests/MUnique.OpenMU.Tests/PlayerHitTollTests.cs b/tests/MUnique.OpenMU.Tests/PlayerHitTollTests.cs new file mode 100644 index 0000000000..f2ee665f9a --- /dev/null +++ b/tests/MUnique.OpenMU.Tests/PlayerHitTollTests.cs @@ -0,0 +1,99 @@ +// +// Licensed under the MIT License. See LICENSE file in the project root for full license information. +// + +namespace MUnique.OpenMU.Tests; + +using MUnique.OpenMU.AttributeSystem; +using MUnique.OpenMU.DataModel.Configuration; +using MUnique.OpenMU.DataModel.Entities; +using MUnique.OpenMU.GameLogic; +using MUnique.OpenMU.GameLogic.Attributes; +using Moq; + +/// +/// Tests player health tolls applied after a successful hit. +/// +[TestFixture] +public class PlayerHitTollTests +{ + /// + /// A skill-specific toll replaces the regular toll. + /// + [Test] + public async Task SkillTollReplacesRegularTollAsync() + { + var attacker = await PlayerTestHelper.CreatePlayerAsync().ConfigureAwait(false); + attacker.Attributes![Stats.CurrentHealth] = 10; + attacker.Attributes.AddElement(new SimpleElement(3, AggregateType.AddRaw), Stats.HealthLossAfterDealtHit); + attacker.Attributes.AddElement(new SimpleElement(1, AggregateType.AddRaw), Stats.IsImpEquipped); + + var skill = new Mock(); + skill.Setup(existing => existing.AttributeRelationships).Returns( + [ + new AttributeRelationship(Stats.SkillHealthLossAfterDealtHit, 2, Stats.IsImpEquipped), + ]); + var skillEntry = new SkillEntry { Skill = skill.Object }; + + await attacker.AfterHitTargetAsync(0, skillEntry).ConfigureAwait(false); + + Assert.That(attacker.Attributes[Stats.CurrentHealth], Is.EqualTo(8)); + } + + /// + /// Hitting a player with a Dinorant adds the configured target toll. + /// + [Test] + public async Task DinorantTargetTollIsAddedAsync() + { + var attacker = await PlayerTestHelper.CreatePlayerAsync().ConfigureAwait(false); + var target = await PlayerTestHelper.CreatePlayerAsync().ConfigureAwait(false); + attacker.Attributes![Stats.CurrentHealth] = 10; + attacker.Attributes.AddElement(new SimpleElement(3, AggregateType.AddRaw), Stats.HealthLossAfterDealtHit); + attacker.Attributes.AddElement(new SimpleElement(1, AggregateType.AddRaw), Stats.TargetHasDinorantHealthToll); + target.Attributes!.AddElement(new SimpleElement(1, AggregateType.AddRaw), Stats.IsDinorantEquipped); + + await attacker.AfterHitTargetAsync(0, null, target).ConfigureAwait(false); + + Assert.That(attacker.Attributes[Stats.CurrentHealth], Is.EqualTo(6)); + } + + /// + /// A health toll for dealing a hit can kill the attacker. + /// + [Test] + public async Task HitTollCanKillAttackerAsync() + { + var attacker = await PlayerTestHelper.CreatePlayerAsync().ConfigureAwait(false); + attacker.Attributes![Stats.CurrentHealth] = 3; + attacker.Attributes.AddElement(new SimpleElement(3, AggregateType.AddRaw), Stats.HealthLossAfterDealtHit); + + await attacker.AfterHitTargetAsync(0, null).ConfigureAwait(false); + + Assert.Multiple(() => + { + Assert.That(attacker.Attributes[Stats.CurrentHealth], Is.EqualTo(0)); + Assert.That(attacker.IsAlive, Is.False); + Assert.That(attacker.PlayerState.CurrentState, Is.EqualTo(PlayerState.Dead)); + Assert.That(attacker.LastDeath, Is.EqualTo(new DeathInformation(0, string.Empty, default, 0))); + }); + } + + /// + /// A health toll for receiving damage is applied. + /// + [Test] + public async Task HealthTollForReceivingDamageIsAppliedAsync() + { + var attacker = await PlayerTestHelper.CreatePlayerAsync().ConfigureAwait(false); + var target = await PlayerTestHelper.CreatePlayerAsync().ConfigureAwait(false); + target.GameContext.Configuration.Maps.Single().BattleZone = new BattleZoneDefinition(); + attacker.Attributes!.AddElement(new SimpleElement(100, AggregateType.AddRaw), Stats.AttackRatePvp); + target.Attributes![Stats.CurrentHealth] = 10; + target.Attributes.AddElement(new SimpleElement(3, AggregateType.AddRaw), Stats.HealthLossAfterHit); + + await target.AttackByAsync(attacker, null, false).ConfigureAwait(false); + + Assert.That(target.Attributes[Stats.CurrentHealth], Is.EqualTo(6)); + } +} \ No newline at end of file