diff --git a/JotunnModStub/Trenta/TrentaMuspell.cs b/JotunnModStub/Trenta/TrentaMuspell.cs index d3af9ef..473ced8 100644 --- a/JotunnModStub/Trenta/TrentaMuspell.cs +++ b/JotunnModStub/Trenta/TrentaMuspell.cs @@ -498,4 +498,48 @@ namespace RacesOfValheim target.Damage(hitData); } } + + /// + /// The hidden human does not fight under the Muspell. Every other form already had these + /// (see Fenrir's BlockPlayerLogicAttackPatch); the Muspell had none, so each stomp and spike + /// also swung the weapon in hand, and the Elder clone's own CharacterAnimEvent fired the held + /// bow or crossbow through OnAttackTrigger on top of that: a tester's bow shot several times a + /// swing. Right Mouse is the spike and the Block button at once, so the guard is cleared too, + /// as BlockPlayerGuardPatch does it. + /// + internal static class TrentaMuspellAttackBlock + { + private static bool LocalInForm(Character character) => + TrentaMuspell.IsTransformed && character != null && character == Player.m_localPlayer; + + [HarmonyPatch(typeof(Humanoid), nameof(Humanoid.StartAttack))] + public static class Trenta_MuspellBlockNativeAttack_Patch + { + public static bool Prefix(Humanoid __instance) => !LocalInForm(__instance); + } + + [HarmonyPatch(typeof(Player), "PlayerAttackInput")] + public static class Trenta_MuspellBlockAttackInput_Patch + { + public static bool Prefix(Player __instance) => !LocalInForm(__instance); + } + + [HarmonyPatch(typeof(Humanoid), nameof(Humanoid.OnAttackTrigger))] + public static class Trenta_MuspellBlockAttackTrigger_Patch + { + public static bool Prefix(Humanoid __instance) => !LocalInForm(__instance); + } + + [HarmonyPatch(typeof(Player), nameof(Player.SetControls))] + public static class Trenta_MuspellBlockGuard_Patch + { + private static readonly AccessTools.FieldRef Blocking = + AccessTools.FieldRefAccess("m_blocking"); + + public static void Postfix(Player __instance) + { + if (LocalInForm(__instance)) Blocking(__instance) = false; + } + } + } }