From b2346c1437e44794b6e68cbc414553452a026c3b Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 17 Oct 2026 15:32:06 +0200 Subject: [PATCH] feat(trol): Legacy True Form switch, chosen per player The Troll Model option becomes Legacy True Form, off by default. On, True Form is the old one: the player's own Trol grown bigger, weapons in hand, body untouched, which player model mods such as VRM need. It is a local preference, not a synced one, so a server cannot force the troll costume on a VRM user. The owner publishes the choice on the ZDO and every other client reads it from there, so onlookers see each Trol the way that Trol's owner picked. --- JotunnModStub/ConfigSync.cs | 3 +++ JotunnModStub/Trol/TrolConfig.cs | 6 +++--- JotunnModStub/Trol/TrolTrueFormBehavior.cs | 3 ++- JotunnModStub/Trol/TrolTrueFormModel.cs | 13 ++++++++++++- 4 files changed, 20 insertions(+), 5 deletions(-) diff --git a/JotunnModStub/ConfigSync.cs b/JotunnModStub/ConfigSync.cs index 996168a..f743b4c 100644 --- a/JotunnModStub/ConfigSync.cs +++ b/JotunnModStub/ConfigSync.cs @@ -40,6 +40,9 @@ namespace RacesOfValheim private static readonly string[] LocalKeyParts = { "marker light", "tint", "colour", "color", "glow", "swarm scale", "log rounds", "debug", + // Each player picks their own True Form: a player model mod (VRM and the like) breaks + // under the troll costume, so a server cannot be allowed to force the costume on. + "legacy true form", }; public static void Apply(ConfigFile config) diff --git a/JotunnModStub/Trol/TrolConfig.cs b/JotunnModStub/Trol/TrolConfig.cs index 2588e9a..5521be7 100644 --- a/JotunnModStub/Trol/TrolConfig.cs +++ b/JotunnModStub/Trol/TrolConfig.cs @@ -51,7 +51,7 @@ namespace RacesOfValheim public static ConfigEntry TrueFormCooldown; public static ConfigEntry TrueFormScaleNormal; public static ConfigEntry TrueFormScaleAdvanced; - public static ConfigEntry TrueFormUseTrollModel; + public static ConfigEntry TrueFormLegacy; public static ConfigEntry TrueFormModelSize; public static ConfigEntry TrueFormTrollDamageShare; public static ConfigEntry TrueFormAttackReach; @@ -138,8 +138,8 @@ namespace RacesOfValheim new ConfigDescription("Model scale while in True Form, tier 5-6.", new AcceptableValueRange(1f, 4f))); TrueFormScaleAdvanced = config.Bind(trueForm, "Scale (Tier 7+)", 2.5f, new ConfigDescription("Model scale while in True Form, tier 7+.", new AcceptableValueRange(1f, 4f))); - TrueFormUseTrollModel = config.Bind(trueForm, "Troll Model", true, - new ConfigDescription("Wear Valheim's own troll in True Form, with its own punch and ground slam instead of your weapons. Off: the old True Form, a bigger Trol with weapons in hand.")); + TrueFormLegacy = config.Bind(trueForm, "Legacy True Form", false, + new ConfigDescription("Off: True Form wears Valheim's own troll, with its punch and ground slam instead of your weapons. On: the old True Form, your own Trol grown bigger with weapons in hand. Turn it on if you use a player model mod such as VRM, which needs the player's body to stay visible. Your own choice: other players see you the way you picked.")); TrueFormModelSize = config.Bind(trueForm, "Troll Model Size", 1f, new ConfigDescription("How tall the troll stands, as a share of the True Form size set by Scale above. 1 = exactly as tall as the old True Form.", new AcceptableValueRange(0.5f, 2f))); TrueFormTrollDamageShare = config.Bind(trueForm, "Troll Attack Damage", 0.5f, diff --git a/JotunnModStub/Trol/TrolTrueFormBehavior.cs b/JotunnModStub/Trol/TrolTrueFormBehavior.cs index 4cf4acd..4e17311 100644 --- a/JotunnModStub/Trol/TrolTrueFormBehavior.cs +++ b/JotunnModStub/Trol/TrolTrueFormBehavior.cs @@ -483,7 +483,8 @@ namespace RacesOfValheim if (nview == null || !nview.IsValid()) return; ZDO zdo = nview.GetZDO(); - bool active = TrolConfig.TrueFormUseTrollModel.Value && + // The owner's choice, not this client's: see TrolTrueFormModel.LegacyKey. + bool active = !zdo.GetBool(TrolTrueFormModel.LegacyKey, false) && !player.IsDead() && zdo.GetString("RacesOfValheim_Race", "Human") == "Trol" && zdo.GetBool(Trol_PlayerUpdate_Patch.TrueFormKey, false); diff --git a/JotunnModStub/Trol/TrolTrueFormModel.cs b/JotunnModStub/Trol/TrolTrueFormModel.cs index 5437696..ef02c33 100644 --- a/JotunnModStub/Trol/TrolTrueFormModel.cs +++ b/JotunnModStub/Trol/TrolTrueFormModel.cs @@ -37,6 +37,10 @@ namespace RacesOfValheim // Published by the owner after every trigger it fires, with a running count so the same // punch twice in a row still reads as two - see FenrirAttackSync. public const string AttackTriggerKey = "RacesOfValheim_TrolTrueFormAttack"; + + // The owner's Legacy True Form choice, so every other client draws this Trol the way its + // owner picked rather than the way the onlooker's own setting says. + public const string LegacyKey = "RacesOfValheim_TrolTrueFormLegacy"; private static int attackSeq; private static readonly int TrueFormHash = "SE_TrolTrueForm".GetStableHashCode(); @@ -96,7 +100,14 @@ namespace RacesOfValheim { if (player == null || player != Player.m_localPlayer) return; - bool wanted = TrolConfig.TrueFormUseTrollModel.Value && + bool legacy = TrolConfig.TrueFormLegacy.Value; + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid() && nview.GetZDO().GetBool(LegacyKey, false) != legacy) + { + nview.GetZDO().Set(LegacyKey, legacy); + } + + bool wanted = !legacy && !player.IsDead() && TrolRace.IsTrol() && player.GetSEMan().HaveStatusEffect(TrueFormHash);