diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs
index dfbbaeb..2b0783d 100644
--- a/JotunnModStub/Fenrir/FenrirBehaviors.cs
+++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs
@@ -514,7 +514,10 @@ namespace RacesOfValheim
private readonly FormLocomotion locomotion = new FormLocomotion();
private float busySince = -1f;
- private bool isAttacking = false;
+ // A property so every form tells FenrirForms.LocalAttacking too: Fenrir_FormHoldStill_Patch
+ // holds the player still for exactly as long as an attack clip runs.
+ private bool attacking;
+ private bool isAttacking { get => attacking; set { attacking = value; FenrirForms.LocalAttacking = value; } }
void Start()
{
@@ -766,7 +769,10 @@ namespace RacesOfValheim
private readonly FormLocomotion locomotion = new FormLocomotion();
private float busySince = -1f;
- private bool isAttacking = false;
+ // A property so every form tells FenrirForms.LocalAttacking too: Fenrir_FormHoldStill_Patch
+ // holds the player still for exactly as long as an attack clip runs.
+ private bool attacking;
+ private bool isAttacking { get => attacking; set { attacking = value; FenrirForms.LocalAttacking = value; } }
private bool isShootingFire = false;
private float fireTimer = 0f;
@@ -1150,7 +1156,10 @@ namespace RacesOfValheim
private Animator wolfAnim;
private readonly FormLocomotion locomotion = new FormLocomotion();
private float busySince = -1f;
- private bool isAttacking = false;
+ // A property so every form tells FenrirForms.LocalAttacking too: Fenrir_FormHoldStill_Patch
+ // holds the player still for exactly as long as an attack clip runs.
+ private bool attacking;
+ private bool isAttacking { get => attacking; set { attacking = value; FenrirForms.LocalAttacking = value; } }
void Start()
{
@@ -1363,7 +1372,10 @@ namespace RacesOfValheim
private readonly FormLocomotion locomotion = new FormLocomotion();
private float busySince = -1f;
- private bool isAttacking = false;
+ // A property so every form tells FenrirForms.LocalAttacking too: Fenrir_FormHoldStill_Patch
+ // holds the player still for exactly as long as an attack clip runs.
+ private bool attacking;
+ private bool isAttacking { get => attacking; set { attacking = value; FenrirForms.LocalAttacking = value; } }
void Start()
{
diff --git a/JotunnModStub/Fenrir/FenrirFormShared.cs b/JotunnModStub/Fenrir/FenrirFormShared.cs
index e74407c..f412620 100644
--- a/JotunnModStub/Fenrir/FenrirFormShared.cs
+++ b/JotunnModStub/Fenrir/FenrirFormShared.cs
@@ -14,6 +14,10 @@ namespace RacesOfValheim
/// SE_FenrirForm and the Cultist SE_CultistForm. Checking only SE_FenrirForm, as the attack
/// block used to, left three of the four forms out.
///
+ /// True while the local form is inside an attack, a howl or a breath. Cleared by the
+ /// form's own routines, and on every revert.
+ public static bool LocalAttacking { get; set; }
+
public static bool LocalInForm(Character character)
{
if (character == null || character != Player.m_localPlayer) return false;
@@ -83,10 +87,25 @@ namespace RacesOfValheim
(hasSleeping ? "sitting puts it to sleep." : "sitting keeps it idle."));
}
}
- if (hasSleeping) form.SetBool("sleeping", player != null && player.IsSitting());
+ if (hasSleeping) form.SetBool("sleeping", IsSitting(player));
return grounded;
}
+
+ ///
+ /// The sit key, or a chair. The sit key is an EMOTE, not the "sitting" animator tag that
+ /// Humanoid.IsSitting asks about - that tag belongs to chairs and benches - so IsSitting alone
+ /// never saw it and the Ulv stayed on its feet. Player.StartEmote writes the emote's name on the
+ /// ZDO, which every client reads, so this is right for an onlooker's copy as well.
+ ///
+ private static bool IsSitting(Player player)
+ {
+ if (player == null) return false;
+ if (player.IsSitting()) return true;
+
+ ZNetView nview = player.GetComponent();
+ return nview != null && nview.IsValid() && nview.GetZDO().GetString(ZDOVars.s_emote, "") == "sit";
+ }
}
///
@@ -215,4 +234,28 @@ namespace RacesOfValheim
Jotunn.Logger.LogInfo($"[FenrirForm] {form} swing: {candidates} collider(s) in reach.");
}
}
+ ///
+ /// Holds the player still through a form's attack clips, the way a human stands to swing. The
+ /// hidden player kept walking under the creature, so the bite slid toward whatever WASD held.
+ /// SkeletonRiseControlsPatch's arrangement: the move direction is SetControls' first argument,
+ /// bound by position. The Fenring's and the Ulv's leaps move the body directly and are untouched.
+ ///
+ [HarmonyLib.HarmonyPatch(typeof(Player), "SetControls")]
+ public static class Fenrir_FormHoldStill_Patch
+ {
+ public static void Prefix(Player __instance, ref Vector3 __0, ref bool jump, ref bool crouch, ref bool dodge)
+ {
+ if (__instance != Player.m_localPlayer || !FenrirForms.LocalAttacking) return;
+ if (!FenrirForms.LocalInForm(__instance))
+ {
+ FenrirForms.LocalAttacking = false;
+ return;
+ }
+
+ __0 = Vector3.zero;
+ jump = false;
+ crouch = false;
+ dodge = false;
+ }
+ }
}
diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs
index ee5cd5a..655cb86 100644
--- a/JotunnModStub/Fenrir/FenrirRace.cs
+++ b/JotunnModStub/Fenrir/FenrirRace.cs
@@ -300,6 +300,7 @@ namespace RacesOfValheim {
player.GetSEMan().RemoveStatusEffect("SE_WolfForm".GetStableHashCode());
}
+ FenrirForms.LocalAttacking = false;
isTransformed = false;
isTransformingSequence = false;
activeRules = null;
@@ -575,6 +576,7 @@ namespace RacesOfValheim {
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_CultistForm".GetStableHashCode());
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_WolfForm".GetStableHashCode());
+ FenrirForms.LocalAttacking = false;
isTransformed = false;
Player.m_localPlayer.Message(MessageHud.MessageType.Center, revertMessage ?? ModText.Get("rov_msg_fenrir_returned_human_form"));
revertMessage = null;