From 2df8264c42279f941d0aae6ef31f27271ccd6009 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 17 Oct 2026 19:06:08 +0200 Subject: [PATCH] debug: log the Ulv's sleep state while the player sits (temporary) --- JotunnModStub/Fenrir/FenrirFormShared.cs | 29 +++++++++++++++++++++++- 1 file changed, 28 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Fenrir/FenrirFormShared.cs b/JotunnModStub/Fenrir/FenrirFormShared.cs index f412620..e1a8b72 100644 --- a/JotunnModStub/Fenrir/FenrirFormShared.cs +++ b/JotunnModStub/Fenrir/FenrirFormShared.cs @@ -87,7 +87,9 @@ namespace RacesOfValheim (hasSleeping ? "sitting puts it to sleep." : "sitting keeps it idle.")); } } - if (hasSleeping) form.SetBool("sleeping", IsSitting(player)); + bool sitting = IsSitting(player); + if (hasSleeping) form.SetBool("sleeping", sitting); + DebugSleep(form, player, sitting); return grounded; } @@ -98,6 +100,31 @@ namespace RacesOfValheim /// 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. /// + // TEMPORARY DEBUG for the Ulv that will not sleep. Remove with the fix. + private bool lastSitting; + private float nextSleepLog; + private void DebugSleep(Animator form, Player player, bool sitting) + { + if (player == null || player != Player.m_localPlayer) return; + ZNetView nview = player.GetComponent(); + string emote = nview != null && nview.IsValid() ? nview.GetZDO().GetString(ZDOVars.s_emote, "") : "?"; + if (sitting != lastSitting) + { + lastSitting = sitting; + Jotunn.Logger.LogInfo($"[SleepDebug] sitting={sitting} IsSitting={player.IsSitting()} emote='{emote}' hasSleeping={hasSleeping}"); + } + if (!sitting && emote != "sit") return; + if (Time.time < nextSleepLog) return; + nextSleepLog = Time.time + 1f; + string clip = "?"; + var clips = form.GetCurrentAnimatorClipInfo(0); + if (clips.Length > 0 && clips[0].clip != null) clip = clips[0].clip.name; + bool sleepingNow = false; + try { sleepingNow = form.GetBool("sleeping"); } catch {} + Jotunn.Logger.LogInfo($"[SleepDebug] sitting={sitting} emote='{emote}' sleepingBool={sleepingNow} clip='{clip}' " + + $"inTransition={form.IsInTransition(0)} enabled={form.enabled} speed={form.speed}"); + } + private static bool IsSitting(Player player) { if (player == null) return false;