From 7ad1d6920ea8100582909e6a5a9f9dc74eade928 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 16:55:19 +0200 Subject: [PATCH] fix(fenrir): the Ulv was mouthing a silent howl The howl code took a playing animation as proof the sound was coming, because the wolf's does bring it: 'C_Hawl' fires an Effect event at 0.39s holding sfx_wolf_haul. The Ulv is the same family on the same rig and its 'Idle Howl' carries no event at all - events=0, read straight off dumpanim - so pressing the key as an Ulv played the animation and nothing else. The muzzle went up in silence. Which creatures bring their own sound is now written down rather than assumed, and it is only the wolf. FenrirCreatureSound.Howl does the whole thing - animation, trigger published for the other clients, and a sound unless the animation is already carrying one - so the four forms call one line and the distinction lives in one place. The Ulv's hold also went from 3.3s to 3.8s: it was the wolf's clip length, copied, and 'Idle Howl' runs 3.67s. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Fenrir/FenrirBehaviors.cs | 69 +++++++++++++++---------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index ef2d09c..86d25fc 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -99,6 +99,36 @@ namespace RacesOfValheim /// private static readonly string[] HowlStates = { "C_Hawl", "C_Howl", "Hawl", "Howl", "Taunt" }; + /// + /// The creatures whose howl ANIMATION already carries the sound, so playing a prefab as well + /// would be a second howl over the first. + /// + /// ONLY THE WOLF. Its 'C_Hawl' fires an Effect event at 0.39s holding sfx_wolf_haul. The Ulv + /// is the same family on the same rig and its 'Idle Howl' carries no event at all - checked + /// with "dumpanim Ulv", which reads events=0 on that clip. Assuming the two behaved alike is + /// what made the Ulv mouth a silent howl: the animation played, the code took that as proof + /// the sound was coming, and nothing was ever spawned. + /// + private static readonly HashSet HowlAnimationHasSound = new HashSet { "Wolf" }; + + /// + /// One howl: the creature's own animation where it has one, and a sound unless that animation + /// is already bringing it. The four forms call this and nothing else. + /// + public static void Howl(Animator animator, string creature, Vector3 position) + { + string trigger; + bool animated = TryHowlAnimation(animator, creature, out trigger); + + // A trigger replicates to the other clients; a state played directly does not. + if (animated && trigger != null) FenrirAttackSync.Publish(trigger); + + if (!animated || !HowlAnimationHasSound.Contains(creature)) + { + PlayHowl(creature, position); + } + } + /// /// Makes the worn creature perform its own howl, and says whether it could. /// @@ -1216,9 +1246,9 @@ namespace RacesOfValheim /// - /// The howl on demand, which for this creature is the animation and nothing else: its clip - /// carries the sound as an event, so spawning one on top would be a second howl over the - /// first. The prefab is only reached if the animator turns out to have no howl at all. + /// The howl on demand. For the wolf it is the animation and nothing else: 'C_Hawl' carries + /// the sound as an event, so spawning a prefab on top would be a second howl over the first. + /// FenrirCreatureSound.Howl knows which creatures those are. /// private IEnumerator WolfHowlRoutine() { @@ -1227,15 +1257,7 @@ namespace RacesOfValheim try { wolfAnim.SetFloat("forward_speed", 0f); } catch {} try { wolfAnim.SetFloat("sideway_speed", 0f); } catch {} - string trigger; - if (FenrirCreatureSound.TryHowlAnimation(wolfAnim, "Wolf", out trigger)) - { - if (trigger != null) FenrirAttackSync.Publish(trigger); - } - else - { - FenrirCreatureSound.PlayHowl("Wolf", Player.m_localPlayer.transform.position); - } + FenrirCreatureSound.Howl(wolfAnim, "Wolf", Player.m_localPlayer.transform.position); // The wolf's howl clip runs 3.13s. Held a little past it so the form does not snap back // into a bite the instant the sound ends. @@ -1427,9 +1449,10 @@ namespace RacesOfValheim /// - /// The howl on demand, which for this creature is the animation and nothing else: its clip - /// carries the sound as an event, so spawning one on top would be a second howl over the - /// first. The prefab is only reached if the animator turns out to have no howl at all. + /// The howl on demand. The Ulv animates one and carries NO sound with it - 'Idle Howl' has no + /// events at all - so unlike the wolf it needs a prefab played over the animation. Assuming + /// the two behaved alike is what left this howl silent; FenrirCreatureSound.Howl holds the + /// distinction now. /// private IEnumerator UlvHowlRoutine() { @@ -1438,19 +1461,11 @@ namespace RacesOfValheim try { ulvAnim.SetFloat("forward_speed", 0f); } catch {} try { ulvAnim.SetFloat("sideway_speed", 0f); } catch {} - string trigger; - if (FenrirCreatureSound.TryHowlAnimation(ulvAnim, "Ulv", out trigger)) - { - if (trigger != null) FenrirAttackSync.Publish(trigger); - } - else - { - FenrirCreatureSound.PlayHowl("Ulv", Player.m_localPlayer.transform.position); - } + FenrirCreatureSound.Howl(ulvAnim, "Ulv", Player.m_localPlayer.transform.position); - // The wolf's howl clip runs 3.13s. Held a little past it so the form does not snap back - // into a bite the instant the sound ends. - yield return new WaitForSeconds(3.3f); + // The Ulv's 'Idle Howl' runs 3.67s. Held a little past it so the form does not snap + // back into a bite the instant it ends. + yield return new WaitForSeconds(3.8f); isAttacking = false; }