From fcb6cae3ee7c874e3230ca396f7f0089d3fae5ed Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sat, 29 Aug 2026 08:45:17 +0200 Subject: [PATCH] fix(input): abilities no longer fire while the hammer's build menu is open Skadi's cold spell is bound to middle mouse and kept casting with the piece selection panel open. The gate was already there - HandleColdSpell sits behind RaceInput.Allowed - but the gate itself was incomplete: Player.TakeInput tests Chat, Console, TextInput, StoreGui, InventoryGui, Menu, TextViewer, the map, free-fly and the barber, and nothing else (read off the IL). Vanilla does not need the build menu in that list because build input is handled separately in UpdatePlacement; a mod ability reading UnityEngine.Input directly does. Hud.IsPieceSelectionVisible is static, public and null-safe on its own instance, so it costs one call and no reflection. Checked before TakeInput so it holds on the fail-open path too. Fixed in RaceInput rather than in Skadi: that class is the mod's single input gate, so this covers every race and every bound ability - the transformations, the flight toggle and the three dragon-form attacks included. Co-Authored-By: Claude Opus 5 --- JotunnModStub/RaceInput.cs | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/JotunnModStub/RaceInput.cs b/JotunnModStub/RaceInput.cs index 04f8f08..02b3847 100644 --- a/JotunnModStub/RaceInput.cs +++ b/JotunnModStub/RaceInput.cs @@ -14,6 +14,14 @@ namespace RacesOfValheim /// its own controls through Player.TakeInput, which reports false for exactly those states /// (InventoryGui covers the backpack and chests alike), so mirror that instead of maintaining /// a parallel list of GUI checks that would drift as the game changes. + /// + /// ONE GUI THAT TakeInput DOES NOT COVER: the hammer's piece selection panel. Read off the IL, + /// TakeInput tests Chat, Console, TextInput, StoreGui, InventoryGui, Menu, TextViewer, the map, + /// free-fly and the barber - and nothing else. Vanilla does not need it there because build + /// input is handled separately in UpdatePlacement, but a mod ability reading the device + /// directly does: Skadi's cold spell is bound to middle mouse and kept casting while the build + /// menu was open. Hud.IsPieceSelectionVisible is static, public and null-safe on its own + /// instance, so it costs one call and no reflection. /// public static class RaceInput { @@ -27,6 +35,9 @@ namespace RacesOfValheim Player player = Player.m_localPlayer; if (player == null) return false; + // Checked before TakeInput, so it holds even on the fail-open path below. + if (Hud.IsPieceSelectionVisible()) return false; + // Fail open: if a game update ever renames the method, abilities stay usable // rather than silently going dead. if (TakeInputMethod == null) return true;