From 29daec37fc6f9bbdf17f74b53f61726e26e9c28f Mon Sep 17 00:00:00 2001 From: Arsenii Fomin Date: Wed, 6 Mar 2024 16:44:03 +0700 Subject: [PATCH 1/3] Split ModifyParry into ModifyParry and ModifyParryForce effects; --- EpicLoot/EpicLoot.csproj | 1 + EpicLoot/ItemDrop_Patch_MagicItemTooltip.cs | 17 +++++++--- EpicLoot/MagicItemEffectDefinitions_Setup.cs | 1 + EpicLoot/MagicItemEffects/ModifyParry.cs | 23 ------------- EpicLoot/MagicItemEffects/ModifyParryForce.cs | 28 ++++++++++++++++ EpicLoot/magiceffects.json | 32 +++++++++++++++++++ EpicLoot/translations.json | 7 +++- 7 files changed, 80 insertions(+), 29 deletions(-) create mode 100644 EpicLoot/MagicItemEffects/ModifyParryForce.cs diff --git a/EpicLoot/EpicLoot.csproj b/EpicLoot/EpicLoot.csproj index 08a668af7..a9c60a18f 100644 --- a/EpicLoot/EpicLoot.csproj +++ b/EpicLoot/EpicLoot.csproj @@ -232,6 +232,7 @@ + diff --git a/EpicLoot/ItemDrop_Patch_MagicItemTooltip.cs b/EpicLoot/ItemDrop_Patch_MagicItemTooltip.cs index 1cbbb3b0b..4cba418de 100644 --- a/EpicLoot/ItemDrop_Patch_MagicItemTooltip.cs +++ b/EpicLoot/ItemDrop_Patch_MagicItemTooltip.cs @@ -126,6 +126,9 @@ private static bool Prefix(ref string __result, ItemDrop.ItemData item, int qual var magicParry = magicItem.HasEffect(MagicEffectType.ModifyParry); var totalParryBonusMod = magicItem.GetTotalEffectValue(MagicEffectType.ModifyParry, 0.01f); var magicParryColor = magicParry ? magicColor : "orange"; + var magicParryForce = magicItem.HasEffect(MagicEffectType.ModifyParryForce); + var magicParryForceColor = magicParryForce ? magicColor : "orange"; + var deflectionForce = item.GetDeflectionForce(qualityLevel); switch (item.m_shared.m_itemType) { case ItemDrop.ItemData.ItemType.Consumable: @@ -172,10 +175,12 @@ private static bool Prefix(ref string __result, ItemDrop.ItemData item, int qual var blockPowerTooltipValue = item.GetBlockPowerTooltip(qualityLevel); var blockPowerPercentageString = blockPowerTooltipValue.ToString("0"); text.Append($"\n$item_blockpower: {baseBlockPower1} ({blockPowerPercentageString})"); + if (deflectionForce > 0) + { + text.Append($"\n$item_deflection: {deflectionForce}"); + } if (item.m_shared.m_timedBlockBonus > 1.0) { - text.Append($"\n$item_deflection: {item.GetDeflectionForce(qualityLevel)}"); - var timedBlockBonus = item.m_shared.m_timedBlockBonus; if (magicParry) { @@ -214,10 +219,12 @@ private static bool Prefix(ref string __result, ItemDrop.ItemData item, int qual blockPowerTooltipValue = item.GetBlockPowerTooltip(qualityLevel); var str5 = blockPowerTooltipValue.ToString("0"); text.Append($"\n$item_blockpower: {baseBlockPower2} ({str5})"); + if (deflectionForce > 0) + { + text.Append($"\n$item_deflection: {deflectionForce}"); + } if (item.m_shared.m_timedBlockBonus > 1.0) { - text.Append($"\n$item_deflection: {item.GetDeflectionForce(qualityLevel)}"); - var timedBlockBonus = item.m_shared.m_timedBlockBonus; if (magicParry) { @@ -559,7 +566,7 @@ public static Tuple PreprocessTooltipStat(ItemDrop.ItemData item break; case "$item_deflection": - if (magicItem.HasEffect(MagicEffectType.ModifyParry)) + if (magicItem.HasEffect(MagicEffectType.ModifyParryForce)) { value = $"{item.GetDeflectionForce(item.m_quality)}"; } diff --git a/EpicLoot/MagicItemEffectDefinitions_Setup.cs b/EpicLoot/MagicItemEffectDefinitions_Setup.cs index b4962b90e..a264499c9 100644 --- a/EpicLoot/MagicItemEffectDefinitions_Setup.cs +++ b/EpicLoot/MagicItemEffectDefinitions_Setup.cs @@ -17,6 +17,7 @@ public static partial class MagicEffectType public static string RemoveSpeedPenalty = nameof(RemoveSpeedPenalty); public static string ModifyBlockPower = nameof(ModifyBlockPower); public static string ModifyParry = nameof(ModifyParry); + public static string ModifyParryForce = nameof(ModifyParryForce); public static string ModifyArmor = nameof(ModifyArmor); public static string ModifyBackstab = nameof(ModifyBackstab); public static string IncreaseHealth = nameof(IncreaseHealth); diff --git a/EpicLoot/MagicItemEffects/ModifyParry.cs b/EpicLoot/MagicItemEffects/ModifyParry.cs index 2f0723f46..0305c3b2d 100644 --- a/EpicLoot/MagicItemEffects/ModifyParry.cs +++ b/EpicLoot/MagicItemEffects/ModifyParry.cs @@ -3,29 +3,6 @@ namespace EpicLoot.MagicItemEffects { - //public float GetDeflectionForce(int quality) - [HarmonyPatch(typeof(ItemDrop.ItemData), nameof(ItemDrop.ItemData.GetDeflectionForce), typeof(int))] - public static class ModifyParry_ItemData_GetDeflectionForce_Patch - { - public static void Postfix(ItemDrop.ItemData __instance, ref float __result) - { - var player = PlayerExtensions.GetPlayerWithEquippedItem(__instance); - var totalParryMod = 0f; - ModifyWithLowHealth.Apply(player, MagicEffectType.ModifyParry, effect => - { - totalParryMod += MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, __instance, effect, 0.01f); - }); - - __result *= 1.0f + totalParryMod; - if (player != null && player.m_leftItem == null && MagicEffectsHelper.HasActiveMagicEffect(player, __instance, MagicEffectType.Duelist)) - { - __result += __instance.GetDamage().GetTotalDamage() / 2 * MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, __instance, MagicEffectType.Duelist, 0.01f); - } - - __result = (float) Math.Round(__result, 1); - } - } - //public override bool BlockAttack(HitData hit, Character attacker) [HarmonyPatch(typeof(Humanoid), nameof(Humanoid.BlockAttack))] public static class ModifyParry_Humanoid_BlockAttack_Patch diff --git a/EpicLoot/MagicItemEffects/ModifyParryForce.cs b/EpicLoot/MagicItemEffects/ModifyParryForce.cs new file mode 100644 index 000000000..d1e3bf28f --- /dev/null +++ b/EpicLoot/MagicItemEffects/ModifyParryForce.cs @@ -0,0 +1,28 @@ +using System; +using HarmonyLib; + +namespace EpicLoot.MagicItemEffects +{ + //public float GetDeflectionForce(int quality) + [HarmonyPatch(typeof(ItemDrop.ItemData), nameof(ItemDrop.ItemData.GetDeflectionForce), typeof(int))] + public static class ModifyParryForce_ItemData_GetDeflectionForce_Patch + { + public static void Postfix(ItemDrop.ItemData __instance, ref float __result) + { + var player = PlayerExtensions.GetPlayerWithEquippedItem(__instance); + var totalParryForceMod = 0f; + ModifyWithLowHealth.Apply(player, MagicEffectType.ModifyParryForce, effect => + { + totalParryForceMod += MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, __instance, effect, 0.01f); + }); + + __result *= 1.0f + totalParryForceMod; + if (player != null && player.m_leftItem == null && MagicEffectsHelper.HasActiveMagicEffect(player, __instance, MagicEffectType.Duelist)) + { + __result += __instance.GetDamage().GetTotalDamage() / 2 * MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, __instance, MagicEffectType.Duelist, 0.01f); + } + + __result = (float) Math.Round(__result, 1); + } + } +} \ No newline at end of file diff --git a/EpicLoot/magiceffects.json b/EpicLoot/magiceffects.json index f0d527e92..f80e8e4c0 100644 --- a/EpicLoot/magiceffects.json +++ b/EpicLoot/magiceffects.json @@ -322,6 +322,38 @@ "$mod_epicloot_me_modifyparry_suffix1" ] }, + { + "Type" : "ModifyParryForce", + "DisplayText" : "$mod_epicloot_me_modifyparryforce_display", + "Description" : "$mod_epicloot_me_modifyparryforce_desc", + "Requirements" : { + "AllowedItemTypes" : [ + "Shield", + "TwoHandedWeapon" + ], + "ExcludedSkillTypes": [ + "Pickaxes" + ], + "ExcludedItemNames": [ + "$item_shield_serpentscale" + ], + "ItemHasParryPower" : true + }, + "ValuesPerRarity" : { + "Magic" : { "MinValue" : 10, "MaxValue" : 20, "Increment" : 1 }, + "Rare" : { "MinValue" : 10, "MaxValue" : 20, "Increment" : 1 }, + "Epic" : { "MinValue" : 10, "MaxValue" : 20, "Increment" : 1 }, + "Legendary" : { "MinValue" : 15, "MaxValue" : 25, "Increment" : 1 } + }, + "SelectionWeight" : 1, + "Prefixes": [ + "$mod_epicloot_me_modifyparryforce_prefix1", + "$mod_epicloot_me_modifyparryforce_prefix2" + ], + "Suffixes": [ + "$mod_epicloot_me_modifyparryforce_suffix1" + ] + }, { "Type" : "ModifyArmor", "DisplayText" : "$mod_epicloot_me_modifyarmor_display", diff --git a/EpicLoot/translations.json b/EpicLoot/translations.json index 21d0c0611..be1b13b82 100644 --- a/EpicLoot/translations.json +++ b/EpicLoot/translations.json @@ -586,10 +586,15 @@ "mod_epicloot_me_modifyblockpower_suffix1": "Stopping", "mod_epicloot_me_modifyblockpower_suffix2": "the Defender", "mod_epicloot_me_modifyparry_display": "Parry +{0:0.#}%", - "mod_epicloot_me_modifyparry_desc": "Increase the parry block armor, parry force, and parry bonus of the magic by +X%.", + "mod_epicloot_me_modifyparry_desc": "Increase the parry block armor and parry bonus of the magic item by +X%.", "mod_epicloot_me_modifyparry_prefix1": "Elusive", "mod_epicloot_me_modifyparry_prefix2": "Rebuking", "mod_epicloot_me_modifyparry_suffix1": "Repelling", + "mod_epicloot_me_modifyparryforce_display": "Parry Force +{0:0.#}%", + "mod_epicloot_me_modifyparryforce_desc": "Increase the parry force of the magic item by +X%.", + "mod_epicloot_me_modifyparryforce_prefix1": "Weighty", + "mod_epicloot_me_modifyparryforce_prefix2": "Ponderous", + "mod_epicloot_me_modifyparryforce_suffix1": "Tossing", "mod_epicloot_me_modifyarmor_display": "Armor +{0:0.#}%", "mod_epicloot_me_modifyarmor_desc": "Increase the armor value of the magic equipment by +X%.", "mod_epicloot_me_modifyarmor_prefix1": "Heavy", From 41f396e737cb068bee5d69cbca7e127c0660d565 Mon Sep 17 00:00:00 2001 From: Arsenii Fomin Date: Wed, 6 Mar 2024 17:13:44 +0700 Subject: [PATCH 2/3] Reworked Duelist effect values calculation logic --- EpicLoot/MagicItemEffects/ModifyBlockPower.cs | 6 +++--- EpicLoot/MagicItemEffects/ModifyParryForce.cs | 7 ++++--- EpicLoot/translations.json | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/EpicLoot/MagicItemEffects/ModifyBlockPower.cs b/EpicLoot/MagicItemEffects/ModifyBlockPower.cs index d602d6cc5..fca9416ee 100644 --- a/EpicLoot/MagicItemEffects/ModifyBlockPower.cs +++ b/EpicLoot/MagicItemEffects/ModifyBlockPower.cs @@ -16,13 +16,13 @@ public static void Postfix(ItemDrop.ItemData __instance, ref float __result) totalBlockPowerMod += MagicEffectsHelper.GetTotalActiveMagicEffectValue(player, __instance, effect, 0.01f); }); - __result *= 1.0f + totalBlockPowerMod; - if (player != null && player.m_leftItem == null && player.HasActiveMagicEffect(MagicEffectType.Duelist)) { - __result += __instance.GetDamage().GetTotalDamage() * player.GetTotalActiveMagicEffectValue(MagicEffectType.Duelist, 0.01f); + totalBlockPowerMod += player.GetTotalActiveMagicEffectValue(MagicEffectType.Duelist, 0.01f); } + __result *= 1.0f + totalBlockPowerMod; + __result = (float)Math.Round(__result, 1); } } diff --git a/EpicLoot/MagicItemEffects/ModifyParryForce.cs b/EpicLoot/MagicItemEffects/ModifyParryForce.cs index d1e3bf28f..f82f8a5c3 100644 --- a/EpicLoot/MagicItemEffects/ModifyParryForce.cs +++ b/EpicLoot/MagicItemEffects/ModifyParryForce.cs @@ -16,13 +16,14 @@ public static void Postfix(ItemDrop.ItemData __instance, ref float __result) totalParryForceMod += MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, __instance, effect, 0.01f); }); - __result *= 1.0f + totalParryForceMod; if (player != null && player.m_leftItem == null && MagicEffectsHelper.HasActiveMagicEffect(player, __instance, MagicEffectType.Duelist)) { - __result += __instance.GetDamage().GetTotalDamage() / 2 * MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, __instance, MagicEffectType.Duelist, 0.01f); + totalParryForceMod += MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, __instance, MagicEffectType.Duelist, 0.01f); } - __result = (float) Math.Round(__result, 1); + __result *= 1.0f + totalParryForceMod; + + __result = (float) Math.Round(__result, 1); } } } \ No newline at end of file diff --git a/EpicLoot/translations.json b/EpicLoot/translations.json index be1b13b82..c554afcc7 100644 --- a/EpicLoot/translations.json +++ b/EpicLoot/translations.json @@ -955,7 +955,7 @@ "mod_epicloot_me_opportunist_prefix1": "Opportunist's", "mod_epicloot_me_opportunist_suffix1": "Opportunity", "mod_epicloot_me_duelist_display": "Duelist +{0:0.#}%", - "mod_epicloot_me_duelist_desc": "When using the magic weapon without anything in the player's off hand, its block armor is increased by +X% of the weapon's attack power, and its parry force is increased by +X/2% of the weapon's attack power.", + "mod_epicloot_me_duelist_desc": "When using the magic weapon without anything in the player's off hand, its block armor and parry force are increased by +X%.", "mod_epicloot_me_duelist_prefix1": "Duelist's", "mod_epicloot_me_duelist_suffix1": "Dueling", "mod_epicloot_me_immovable_display": "Immovable", From 031a76c9920f3b79a8970544726562ede7bcf8cb Mon Sep 17 00:00:00 2001 From: Arsenii Fomin Date: Thu, 7 Mar 2024 11:45:57 +0700 Subject: [PATCH 3/3] Reduce parry force effective value by half --- EpicLoot/MagicItemEffects/ModifyParryForce.cs | 2 +- EpicLoot/translations.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/EpicLoot/MagicItemEffects/ModifyParryForce.cs b/EpicLoot/MagicItemEffects/ModifyParryForce.cs index f82f8a5c3..f0e1ab6bc 100644 --- a/EpicLoot/MagicItemEffects/ModifyParryForce.cs +++ b/EpicLoot/MagicItemEffects/ModifyParryForce.cs @@ -18,7 +18,7 @@ public static void Postfix(ItemDrop.ItemData __instance, ref float __result) if (player != null && player.m_leftItem == null && MagicEffectsHelper.HasActiveMagicEffect(player, __instance, MagicEffectType.Duelist)) { - totalParryForceMod += MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, __instance, MagicEffectType.Duelist, 0.01f); + totalParryForceMod += MagicEffectsHelper.GetTotalActiveMagicEffectValueForWeapon(player, __instance, MagicEffectType.Duelist, 0.01f) / 2.0f; } __result *= 1.0f + totalParryForceMod; diff --git a/EpicLoot/translations.json b/EpicLoot/translations.json index c554afcc7..7bbc46bc9 100644 --- a/EpicLoot/translations.json +++ b/EpicLoot/translations.json @@ -955,7 +955,7 @@ "mod_epicloot_me_opportunist_prefix1": "Opportunist's", "mod_epicloot_me_opportunist_suffix1": "Opportunity", "mod_epicloot_me_duelist_display": "Duelist +{0:0.#}%", - "mod_epicloot_me_duelist_desc": "When using the magic weapon without anything in the player's off hand, its block armor and parry force are increased by +X%.", + "mod_epicloot_me_duelist_desc": "When using the magic weapon without anything in the player's off hand, its block armor is increased by +X%. Half of the effect value applied to parry force.", "mod_epicloot_me_duelist_prefix1": "Duelist's", "mod_epicloot_me_duelist_suffix1": "Dueling", "mod_epicloot_me_immovable_display": "Immovable",