Merge branch 'fix-muspell-weapon': Muspell blocks the hidden human's attack

This commit is contained in:
kanym 2026-10-29 13:22:44 +01:00
commit 7a43ced3fb

View file

@ -498,4 +498,48 @@ namespace RacesOfValheim
target.Damage(hitData);
}
}
/// <summary>
/// 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.
/// </summary>
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<Character, bool> Blocking =
AccessTools.FieldRefAccess<Character, bool>("m_blocking");
public static void Postfix(Player __instance)
{
if (LocalInForm(__instance)) Blocking(__instance) = false;
}
}
}
}