Please disclose if any significant portion of your mod was created using AI tools by adding the 'AI Generated' category. Failing to do so may result in the mod being removed from Thunderstore.
Decompiled source of Parry Rebalanced for Very Hard v1.0.2
plugins/ParryRebalancedForVeryHard.dll
Decompiled 2 months agousing System; using System.Diagnostics; using System.Reflection; using System.Runtime.CompilerServices; using System.Runtime.Versioning; using BepInEx; using BepInEx.Configuration; using HarmonyLib; using Microsoft.CodeAnalysis; using UnityEngine; [assembly: CompilationRelaxations(8)] [assembly: RuntimeCompatibility(WrapNonExceptionThrows = true)] [assembly: Debuggable(DebuggableAttribute.DebuggingModes.IgnoreSymbolStoreSequencePoints)] [assembly: TargetFramework(".NETFramework,Version=v4.8", FrameworkDisplayName = ".NET Framework 4.8")] [assembly: AssemblyCompany("ScottDark")] [assembly: AssemblyConfiguration("Release")] [assembly: AssemblyCopyright("Copyright (c) 2026 ScottDark")] [assembly: AssemblyFileVersion("1.0.2.0")] [assembly: AssemblyInformationalVersion("1.0.2")] [assembly: AssemblyProduct("Parry Rebalanced for Very Hard")] [assembly: AssemblyTitle("ParryRebalancedForVeryHard")] [assembly: AssemblyVersion("1.0.2.0")] [module: RefSafetyRules(11)] namespace Microsoft.CodeAnalysis { [CompilerGenerated] [Embedded] internal sealed class EmbeddedAttribute : Attribute { } } namespace System.Runtime.CompilerServices { [CompilerGenerated] [Embedded] [AttributeUsage(AttributeTargets.Module, AllowMultiple = false, Inherited = false)] internal sealed class RefSafetyRulesAttribute : Attribute { public readonly int Version; public RefSafetyRulesAttribute(int P_0) { Version = P_0; } } } namespace ParryRebalancedForVeryHard { [BepInPlugin("ScottDark.ParryRebalancedForVeryHard", "Parry Rebalanced for Very Hard", "1.0.2")] public sealed class Plugin : BaseUnityPlugin { public const string Id = "ScottDark.ParryRebalancedForVeryHard"; internal static ConfigEntry<bool> Enabled; private Harmony harmony; private void Awake() { //IL_0026: Unknown result type (might be due to invalid IL or missing references) //IL_0030: Expected O, but got Unknown Enabled = ((BaseUnityPlugin)this).Config.Bind<bool>("General", "Enabled", true, "Evaluate timed enemy parries without the extra world enemy-damage multiplier. Overflow damage still uses the full multiplier. Timing, gear, skills, stars and regular blocks retain their vanilla rules."); harmony = new Harmony("ScottDark.ParryRebalancedForVeryHard"); try { harmony.PatchAll(typeof(Plugin).Assembly); ((BaseUnityPlugin)this).Logger.LogInfo((object)"Parry Rebalanced for Very Hard 1.0.2 loaded. Timed PvE parries compensate for Game.m_enemyDamageRate above 1; overflow damage retains difficulty scaling."); } catch (Exception ex) { harmony.UnpatchSelf(); ((BaseUnityPlugin)this).Logger.LogError((object)("Parry Rebalanced for Very Hard could not patch this game version: " + ex)); } } private void OnDestroy() { Harmony obj = harmony; if (obj != null) { obj.UnpatchSelf(); } } } [HarmonyPatch(typeof(Humanoid), "BlockAttack", new Type[] { typeof(HitData), typeof(Character) })] internal static class BlockPatch { internal sealed class State { internal float Scale; internal DamageTypes Original; } private static readonly MethodInfo Blocker = AccessTools.Method(typeof(Humanoid), "GetCurrentBlocker", (Type[])null, (Type[])null); [HarmonyPrefix] [HarmonyPriority(0)] private static void Prefix(Humanoid __instance, HitData hit, Character attacker, float ___m_blockTimer, out State __state) { //IL_0045: Unknown result type (might be due to invalid IL or missing references) //IL_004b: Expected O, but got Unknown //IL_0055: Unknown result type (might be due to invalid IL or missing references) //IL_0060: Unknown result type (might be due to invalid IL or missing references) //IL_00ae: Unknown result type (might be due to invalid IL or missing references) //IL_00b3: Unknown result type (might be due to invalid IL or missing references) __state = null; if (Plugin.Enabled.Value && hit != null && ((Character)__instance).IsPlayer() && !((Object)(object)attacker == (Object)null) && !attacker.IsPlayer() && !(Game.m_enemyDamageRate <= 1f)) { ItemData val = (ItemData)Blocker.Invoke(__instance, null); float num = ParryRules.Compensation(enabled: true, playerDefender: true, enemyAttacker: true, hit.m_blockable, Vector3.Dot(hit.m_dir, ((Component)__instance).transform.forward) <= 0f, ___m_blockTimer, val?.m_shared.m_timedBlockBonus ?? 0f, Game.m_enemyDamageRate); if (!(num <= 1f)) { __state = new State { Scale = num, Original = hit.m_damage }; ((DamageTypes)(ref hit.m_damage)).Modify(1f / num); } } } [HarmonyFinalizer] [HarmonyPriority(800)] private static Exception Finalizer(HitData hit, State __state, Exception __exception) { //IL_001b: Unknown result type (might be due to invalid IL or missing references) //IL_0020: Unknown result type (might be due to invalid IL or missing references) if (__state != null) { if (__exception == null) { ((DamageTypes)(ref hit.m_damage)).Modify(__state.Scale); } else { hit.m_damage = __state.Original; } } return __exception; } } internal static class ParryRules { internal static float Compensation(bool enabled, bool playerDefender, bool enemyAttacker, bool blockable, bool frontHit, float timer, float parryBonus, float enemyDamageRate) { if (!enabled || !playerDefender || !enemyAttacker || !blockable || !frontHit || timer < 0f || timer >= 0.25f || parryBonus <= 1f || float.IsNaN(enemyDamageRate) || float.IsInfinity(enemyDamageRate) || enemyDamageRate <= 1f) { return 1f; } return enemyDamageRate; } } }