fix(fenrir): hidden human no longer attacks or blocks under a form
The attack block patched Character.StartAttack, which Humanoid overrides without calling the base, so it never ran; and it covered the Fenring only. Every form swing also fired the hidden human's attack: stamina spent, regen held at zero while it played, and forward_speed dropped to 0. Patch Humanoid.StartAttack for all four forms, and clear m_blocking after SetControls so the pad's heavy attack stops raising the guard. Forms treat the player as airborne only after 0.25 s off the ground, so bumps no longer flicker run to idle. Melee reach ignores the target's own colliders and accepts a clear line from the eyes or the attack point, with an opt-in hit log. Sunrise names the key that still works by day.
This commit is contained in:
parent
19d331789a
commit
b4b6fe3758
8 changed files with 323 additions and 153 deletions
|
|
@ -9,23 +9,33 @@ using UnityEngine.UI; // Added for UI
|
|||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
[HarmonyPatch(typeof(Character), nameof(Character.StartAttack))]
|
||||
/// <summary>
|
||||
/// The hidden human does not attack while a form does.
|
||||
///
|
||||
/// This patched Character.StartAttack, and it never ran once: Humanoid overrides StartAttack
|
||||
/// without calling the base, and a player is a Humanoid. Skadi, the Aswid and the Sverm all
|
||||
/// patch Humanoid, which is why their forms were clean and the Fenrir's were not. So every
|
||||
/// claw and bite also fired the invisible human's own attack on the same button, and that
|
||||
/// attack is what a player saw as three separate bugs:
|
||||
/// - it spent stamina on every swing, and while its animation ran Player.UpdateStats held
|
||||
/// stamina regen at zero (InAttack), so an empty bar did not come back mid-fight;
|
||||
/// - a human mid-attack stands still, so the forward_speed the form copies dropped to 0 and
|
||||
/// the creature fell back to idle in the middle of a fight;
|
||||
/// - it did so with whatever weapon was in hand.
|
||||
/// It also only ever looked at SE_FenrirForm, so even working it would have covered the Fenring
|
||||
/// alone and left the Wolf, the Ulv and the Cultist out.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Humanoid), nameof(Humanoid.StartAttack))]
|
||||
public static class BlockPlayerLogicAttackPatch
|
||||
{
|
||||
public static bool Prefix(Character __instance)
|
||||
public static bool Prefix(Humanoid __instance)
|
||||
{
|
||||
if (__instance != null && __instance == Player.m_localPlayer)
|
||||
{
|
||||
if (__instance.GetSEMan().HaveStatusEffect("SE_FenrirForm".GetStableHashCode()))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
return !FenrirForms.LocalInForm(__instance);
|
||||
}
|
||||
}
|
||||
|
||||
// --- PATCH 2: BLOCCO ANIMAZIONI ED EFFETTI SONORI NATIVI ---
|
||||
// Every form now, not the Fenring alone: see BlockPlayerLogicAttackPatch.
|
||||
[HarmonyPatch(typeof(ZSyncAnimation), nameof(ZSyncAnimation.SetTrigger))]
|
||||
public static class BlockPlayerAnimationsPatch
|
||||
{
|
||||
|
|
@ -33,7 +43,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
if (Player.m_localPlayer != null && __instance.gameObject == Player.m_localPlayer.gameObject)
|
||||
{
|
||||
if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_FenrirForm".GetStableHashCode()))
|
||||
if (FenrirForms.LocalInForm(Player.m_localPlayer))
|
||||
{
|
||||
string triggerName = name.ToLower();
|
||||
if (triggerName.Contains("attack") || triggerName.Contains("swing") || triggerName.Contains("punch"))
|
||||
|
|
@ -46,6 +56,28 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The hidden human does not block while a form is up either. The forms put their heavy attack
|
||||
/// on Right Mouse, and on a gamepad RaceInput maps that to JoyBlock, so every heavy bite also
|
||||
/// raised the human's guard: it turned to face the camera and strafed (the form copies that
|
||||
/// movement) and regenerated stamina at 80%. A wolf has no shield to raise.
|
||||
///
|
||||
/// Cleared after SetControls rather than by answering IsBlocking with false: Player also reads
|
||||
/// the raw m_blocking flag for the strafe, and the block-and-jump dodge is worked out inside
|
||||
/// SetControls before this runs, so the dodge still works.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), nameof(Player.SetControls))]
|
||||
public static class BlockPlayerGuardPatch
|
||||
{
|
||||
private static readonly AccessTools.FieldRef<Character, bool> Blocking =
|
||||
AccessTools.FieldRefAccess<Character, bool>("m_blocking");
|
||||
|
||||
public static void Postfix(Player __instance)
|
||||
{
|
||||
if (FenrirForms.LocalInForm(__instance)) Blocking(__instance) = false;
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch]
|
||||
public static class FenrirDamagePatch
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue