From bae4ae9da927c36b4e751beb6808e9547cf9df63 Mon Sep 17 00:00:00 2001 From: kanym Date: Wed, 12 Aug 2026 18:10:39 +0200 Subject: [PATCH 001/273] fix(aswid): remove Cold on reset, so the Night Aura smoke stops following the next race The black smoke was never an Aswid effect - it is vanilla's Cold, hijacked. Aswid_ColdStatus_Patch renames the live instance to "Night Aura" and AswidRace.ApplyNightAuraTint paints its vfx_Cold particles black and doubles the particle count, both applied directly to the instance hanging off the player. ResetRace cleared a dozen of the mod's own status effects but never Cold, since Cold is not one of them - so the blackened instance survived a race change and followed the player onto whatever they picked next, "Night Aura" label included. There is no untinting it: the original colours and emission rates were never recorded before being overwritten. So ResetRace now removes Cold outright instead. The night hands out a fresh, ordinary Cold moments later if it's still cold, with nobody left to rename or repaint it. Confirmed in game. --- JotunnModStub/RacesOfValheim.cs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index ec97d01..2a801e8 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -116,6 +116,21 @@ namespace RacesOfValheim player.GetSEMan().RemoveStatusEffect(SvermConfig.StingerSE.GetStableHashCode()); player.GetSEMan().RemoveStatusEffect(SvermConfig.StingerCdSE.GetStableHashCode()); + // COLD, which is not one of ours at all - and that is exactly why it has to go. + // + // The Aswid does not add a status effect for its night aura; it takes over the vanilla + // Cold that the night hands out anyway. Aswid_ColdStatus_Patch renames the instance to + // "Night Aura" and AswidRace.ApplyNightAuraTint paints its vfx_Cold particles black and + // doubles them, both applied to the LIVE instance hanging off the player and marked + // with NightAuraTintFlag so it is only done once. + // + // Nothing here used to remove it, so the blackened smoke - and the "Night Aura" label - + // simply stayed on through a race change and followed the player onto a Dvergar. There + // is no untinting it: the original colours and emission rates were never recorded. So + // the instance goes, and the night hands out a fresh, ordinary Cold within moments - + // this time with nobody left to rename or repaint it. + player.GetSEMan().RemoveStatusEffect("Cold".GetStableHashCode()); + ZNetView nview = player.GetComponent(); if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human"); From d79f78e9f0f91dc87431257249b546ac2c94644b Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 13 Aug 2026 19:13:24 +0200 Subject: [PATCH 002/273] warvulture --- JotunnModStub/RacesOfValheim.cs | 6 +- JotunnModStub/Skeleton/SkeletonEyeGlow.cs | 34 +-- JotunnModStub/Skeleton/SkeletonVisuals.cs | 213 +++++++++++++++-- JotunnModStub/Sverm/SvermStingerForm.cs | 11 +- .../TrolsHammer/TrolsHammerConfig.cs | 50 ++++ JotunnModStub/TrolsHammer/TrolsHammerItem.cs | 97 ++++++++ .../TrolsHammer/TrolsHammerPatches.cs | 217 ++++++++++++++++++ JotunnModStub/ZNetSceneOrphanPatch.cs | 174 ++++++++++++++ README.md | 183 +++++++++++---- manifest.json | 4 +- 10 files changed, 900 insertions(+), 89 deletions(-) create mode 100644 JotunnModStub/TrolsHammer/TrolsHammerConfig.cs create mode 100644 JotunnModStub/TrolsHammer/TrolsHammerItem.cs create mode 100644 JotunnModStub/TrolsHammer/TrolsHammerPatches.cs create mode 100644 JotunnModStub/ZNetSceneOrphanPatch.cs diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 70dc814..8c8648a 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.0"; + public const string PluginVersion = "1.4.2"; private readonly Harmony harmony = new Harmony(PluginGUID); @@ -40,6 +40,9 @@ namespace RacesOfValheim // Not a race: a summoned mount two races share, so it binds after the races rather // than inside the alphabetical run above. WarVultureConfig.Bind(Config); + // Not a race either: a tool any race can craft, so it sits beside the vulture rather + // than inside the alphabetical run above. + TrolsHammerConfig.Bind(Config); harmony.PatchAll(); gameObject.AddComponent(); gameObject.AddComponent(); @@ -126,6 +129,7 @@ namespace RacesOfValheim TrentaRace.Instance.CreateModAssets(); SvermRace.Instance.CreateModAssets(); WarVultureItem.Register(); + TrolsHammerItem.Register(); } // --- RACE SELECTION UI --- public void ShowRaceSelectionMenu() diff --git a/JotunnModStub/Skeleton/SkeletonEyeGlow.cs b/JotunnModStub/Skeleton/SkeletonEyeGlow.cs index 03356c9..9fd2706 100644 --- a/JotunnModStub/Skeleton/SkeletonEyeGlow.cs +++ b/JotunnModStub/Skeleton/SkeletonEyeGlow.cs @@ -163,35 +163,23 @@ namespace RacesOfValheim private static void Clone(GameObject source, Transform parentBone, string namePrefix) { - GameObject copy = Object.Instantiate(source, parentBone); - copy.name = namePrefix + source.name; + // Through BorrowEffect, which builds the copy inside an inactive holder and strips it + // there. This used to instantiate straight onto the bone and clean up afterwards, and + // "afterwards" is a frame too late: a borrowed node gets its Awake the moment it lands + // on a live player. That is what left burnt-in torches in people's worlds when the head + // flame did the same thing - see the note on FlameSourcePrefabs. Nothing on a creature + // is known to be as expensive as an ItemDrop, but the eye glow reads whatever the + // creature happens to carry, which is exactly the kind of place that surprise comes + // from. + GameObject copy = SkeletonVisuals.BorrowEffect(source, parentBone, namePrefix + source.name, + true, "Skeleton"); + if (copy == null) return; // The pose it was authored at on the creature. Instantiate keeps the world transform, // which for a prefab means nothing useful. copy.transform.localPosition = source.transform.localPosition; copy.transform.localRotation = source.transform.localRotation; copy.transform.localScale = source.transform.localScale; - - // Allowlist, not a blocklist - the same rule the head flame is built under. Whatever - // else rode along (an AnimEvent, a collider, a script that expects a Character above - // it) goes, whatever type it turns out to be; what is left is a light and the things - // that draw it. - foreach (Component comp in copy.GetComponentsInChildren(true)) - { - if (comp is Transform || comp is Light || comp is ParticleSystem || - comp is ParticleSystemRenderer || comp is MeshRenderer || comp is MeshFilter) - { - continue; - } - - Object.Destroy(comp); - } - - // A creature can leave its own effects switched off for a script to turn on later, and - // that script is exactly what was just destroyed. - copy.SetActive(true); - foreach (Light light in copy.GetComponentsInChildren(true)) light.enabled = true; - foreach (Renderer renderer in copy.GetComponentsInChildren(true)) renderer.enabled = true; } /// diff --git a/JotunnModStub/Skeleton/SkeletonVisuals.cs b/JotunnModStub/Skeleton/SkeletonVisuals.cs index d4ec7c0..825b64a 100644 --- a/JotunnModStub/Skeleton/SkeletonVisuals.cs +++ b/JotunnModStub/Skeleton/SkeletonVisuals.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using Jotunn.Managers; using UnityEngine; @@ -96,13 +97,78 @@ namespace RacesOfValheim return BossProgressionManager.GetCurrentProgressionState(); } - // Fire sources in preference order. The torch is an item every world has; the ground - // torch and the fire pit are the building pieces to fall back on. + /// + /// Fire sources in preference order. BUILDING PIECES ONLY, and that is the bug fix. + /// + /// This list used to start with "Torch", which is the ITEM prefab, and an item in Valheim + /// is a live world object: ItemDrop, a Rigidbody and a ZNetView, all of them on the same + /// node the fire particles are on. That the borrow was reaching that node and not a bare + /// flame was already known here - the strip below used to name "the stick mesh, ItemDrop, + /// durability", and the Rigidbody it had to destroy was the one that made an early version + /// of the clone visibly fall away from the skull. + /// + /// What was missed is that the copy was made into a holder that was ALREADY SWITCHED ON, + /// so all of it woke up for a frame before the strip could take any of it off - and a woken + /// ZNetView is not a cosmetic mistake. ZNetView.Awake with no init ZDO calls + /// ZDOMan.CreateNewZDO at the object's position, marks it persistent, stamps it with the + /// prefab hash and registers it with the scene; ZNetView.OnDestroy does none of that in + /// reverse - it only releases asset references. So every rebuild of the flame left the + /// world holding a persistent "there is a Torch here" record that nothing was drawing, + /// saved with everything else, and the next time that zone was built from the save every + /// client spawned the torch. That is the whole of the report: a torch dropped on logging + /// in and out, and a portal handing it to everyone. + /// + /// A ground torch is a building piece. It has the same fire (both carry fx_Torch_Basic) and + /// no item behaviour at all, so there is nothing on it to bring across by accident. The + /// inactive holder in Build and the two filters below are the lines of defence behind that, + /// for whatever a future source turns out to carry. + /// private static readonly string[] FlameSourcePrefabs = { - "Torch", "piece_groundtorch_wood", "piece_groundtorch", "fire_pit" + "piece_groundtorch_wood", "piece_groundtorch", "fire_pit" }; + /// + /// Particle systems that are not fire. Matched on the object name, which is how these are + /// named in the prefabs that carry them - an item's pickup glitter above all, which is a + /// ParticleSystem like any other and was worn on the skull along with the flame. + /// + private static readonly string[] NotFire = + { + "sparkle", "sparcle", "glitter", "pickup", "shine", "twinkle" + }; + + private static bool IsFire(GameObject candidate) + { + string name = candidate.name.ToLower(); + foreach (string word in NotFire) + { + if (name.Contains(word)) return false; + } + return true; + } + + // Said once per particle name per session, with everything the borrowed node carries that + // is not a particle. The point is that the next time something rides along, the log names + // it - this bug cost a bug report because nothing ever said "that flame is an item". + private static readonly HashSet loggedParticles = new HashSet(); + + private static void LogClonedOnce(GameObject source) + { + if (!loggedParticles.Add(source.name)) return; + + List passengers = new List(); + foreach (Component comp in source.GetComponentsInChildren(true)) + { + if (comp == null || IsPureVfx(comp, true)) continue; + passengers.Add(comp.GetType().Name); + } + + Jotunn.Logger.LogInfo( + $"[Skeleton] Head flame: cloned '{source.name}'" + + (passengers.Count == 0 ? "." : ", stripped " + string.Join(", ", passengers.ToArray()) + ".")); + } + private static GameObject cachedFlameSource; private static bool flameSourceResolved; @@ -119,7 +185,13 @@ namespace RacesOfValheim { GameObject prefab = PrefabManager.Cache.GetPrefab(name); if (prefab == null) continue; - if (prefab.GetComponentsInChildren(true).Length == 0) continue; + + bool hasFire = false; + foreach (ParticleSystem ps in prefab.GetComponentsInChildren(true)) + { + if (IsFire(ps.gameObject)) { hasFire = true; break; } + } + if (!hasFire) continue; Jotunn.Logger.LogInfo($"[Skeleton] Head flame source resolved to '{name}'."); cachedFlameSource = prefab; @@ -132,6 +204,108 @@ namespace RacesOfValheim return null; } + /// + /// Strips a borrowed subtree down to what a pure VFX needs, and nothing else. + /// + /// Allowlist, not a blocklist: keep the particle systems, their renderers and the lights + /// (and the loose meshes, for the eye glow), destroy every other component whatever it + /// turns out to be. A blocklist of "known bad" types (MonoBehaviour, Collider) missed + /// Rigidbody - not a MonoBehaviour in Unity - and a fire node carrying one meant physics + /// kept acting on the clone independently of the holder being repositioned every frame. + /// + /// DestroyImmediate rather than Destroy, because the caller is about to switch the holder + /// on and Destroy does not take effect until the end of the frame - by which time every + /// script it was supposed to remove would have had its Awake. + /// + /// Repeated passes, because Unity refuses to destroy a component another one still + /// requires ("Can't remove Humanoid because CharacterDrop depends on it"): the dependent + /// goes on one pass and the component it held down goes on the next. Behaviours first + /// within each pass, for the same reason. + /// + public static void StripToVfx(GameObject root, bool keepMeshes, string label) + { + if (root == null) return; + + for (int pass = 0; pass < 4; pass++) + { + bool anyLeft = false; + + foreach (MonoBehaviour behaviour in root.GetComponentsInChildren(true)) + { + if (behaviour == null) continue; + Object.DestroyImmediate(behaviour); + } + + foreach (Component comp in root.GetComponentsInChildren(true)) + { + if (comp == null || IsPureVfx(comp, keepMeshes)) continue; + Object.DestroyImmediate(comp); + anyLeft = true; + } + + if (!anyLeft) return; + } + + // Four passes and something is still holding on. Say what it is: a survivor here is the + // exact shape of bug this whole class exists to prevent, and it is about to be woken. + foreach (Component comp in root.GetComponentsInChildren(true)) + { + if (comp == null || IsPureVfx(comp, keepMeshes)) continue; + Jotunn.Logger.LogWarning( + $"[{label}] '{comp.GetType().Name}' on '{comp.gameObject.name}' could not be stripped " + + "off the borrowed effect; it will run on the player."); + } + } + + private static bool IsPureVfx(Component comp, bool keepMeshes) + { + if (comp is Transform || comp is ParticleSystem || comp is ParticleSystemRenderer || comp is Light) + { + return true; + } + + return keepMeshes && (comp is MeshRenderer || comp is MeshFilter); + } + + /// + /// Clones one node of a vanilla prefab as pure VFX and hangs it under . + /// + /// The temporary holder is created INACTIVE and the copy is made inside it. That single + /// line is the point of this method: Unity does not run Awake on an object that is not + /// active in its hierarchy, so ItemDrop, ZNetView, Rigidbody and every script on the + /// borrowed node are destroyed before any of them ever exists as far as the game is + /// concerned. Stripping AFTER the copy is already live - which is what the head flame and + /// the eye glow both used to do - is a frame too late, and one frame is all a ZNetView + /// needs to write a persistent object into the save. Same lesson, same fix, as ModelBorrow. + /// + /// The copy is handed back parented to and switched on, with its + /// pose left to the caller. + /// + public static GameObject BorrowEffect(GameObject source, Transform parent, string cloneName, + bool keepMeshes, string label) + { + if (source == null || parent == null) return null; + + GameObject holder = new GameObject("BorrowedEffectHolder"); + holder.SetActive(false); // BEFORE the Instantiate below. + + GameObject copy = Object.Instantiate(source, holder.transform); + copy.name = cloneName; + + StripToVfx(copy, keepMeshes, label); + + copy.transform.SetParent(parent, false); + Object.DestroyImmediate(holder); + + // A prefab can leave its own effects switched off for a script to turn on later, and + // that script is exactly what was just destroyed. + copy.SetActive(true); + foreach (Light light in copy.GetComponentsInChildren(true)) light.enabled = true; + foreach (Renderer renderer in copy.GetComponentsInChildren(true)) renderer.enabled = true; + + return copy; + } + /// /// One player's burning skull. Cosmetic only - it deals nothing and blocks nothing. /// @@ -191,13 +365,22 @@ namespace RacesOfValheim // Real fire is cloned rather than built by hand. The first attempt at this made a // particle system from scratch on the smoke material, and a hand-rolled gradient // over a smoke sprite reads as a wisp, not a burning skull. + // + // Every clone goes through BorrowEffect, which builds it inactive and strips it + // before it can wake. Nothing from the source prefab - a script, a Rigidbody, a + // ZNetView - ever gets a frame of life on the player. foreach (ParticleSystem ps in source.GetComponentsInChildren(true)) { - GameObject copy = Object.Instantiate(ps.gameObject, m_instance.transform); - copy.name = ps.gameObject.name; + if (!IsFire(ps.gameObject)) continue; + + GameObject copy = BorrowEffect(ps.gameObject, m_instance.transform, + ps.gameObject.name, false, "Skeleton"); + if (copy == null) continue; + + LogClonedOnce(ps.gameObject); + copy.transform.localPosition = Vector3.zero; copy.transform.localRotation = Quaternion.identity; - copy.SetActive(true); // So the holder's scale actually enlarges the fire rather than just spreading // out where the particles spawn. @@ -213,22 +396,6 @@ namespace RacesOfValheim light.intensity *= 0.6f; } - // Allowlist, not a blocklist: keep only what a pure VFX actually needs (the - // particle systems, their renderers, and the light tweaked above) and destroy - // every other component, whatever it turns out to be. A blocklist of "known bad" - // types (MonoBehaviour, Collider) missed Rigidbody - not a MonoBehaviour in Unity, - // so the old loop never touched it - and a torch's fire-particle node carrying one - // meant physics kept acting on the clone independently of m_instance being - // repositioned onto the head every frame: it visibly fell away while the empty - // parent stayed correctly tracked above it. Anything that made the source a torch - // rather than a bare flame - the stick mesh, ItemDrop, durability, all of it - - // goes the same way. - foreach (Component comp in m_instance.GetComponentsInChildren(true)) - { - if (comp is Transform || comp is ParticleSystem || comp is ParticleSystemRenderer || comp is Light) continue; - Object.Destroy(comp); - } - return true; } } diff --git a/JotunnModStub/Sverm/SvermStingerForm.cs b/JotunnModStub/Sverm/SvermStingerForm.cs index 1b90393..5c5a4f7 100644 --- a/JotunnModStub/Sverm/SvermStingerForm.cs +++ b/JotunnModStub/Sverm/SvermStingerForm.cs @@ -316,7 +316,16 @@ namespace RacesOfValheim Character character = GetComponent(); if (character == null || character.IsDead()) { - Destroy(gameObject); + // ZNetScene.Destroy, NEVER Object.Destroy, and this line was the teleport crash. + // + // An escort is a real networked creature, and ZNetView.OnDestroy - read out of the + // assembly, not assumed - only releases asset references: it does not take the + // object out of ZNetScene.m_instances. A plain Object.Destroy therefore left the + // scene holding a dead ZNetView, and the next time the world unloaded around the + // player, which is exactly what a teleport is, ZNetScene.RemoveObjects walked that + // entry and threw. See ZNetSceneOrphanPatch.cs for the whole chain. + if (ZNetScene.instance != null) ZNetScene.instance.Destroy(gameObject); + else Destroy(gameObject); return; } diff --git a/JotunnModStub/TrolsHammer/TrolsHammerConfig.cs b/JotunnModStub/TrolsHammer/TrolsHammerConfig.cs new file mode 100644 index 0000000..6410813 --- /dev/null +++ b/JotunnModStub/TrolsHammer/TrolsHammerConfig.cs @@ -0,0 +1,50 @@ +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// The two numbers behind Trol's Hammer, bound as BepInEx ConfigEntry so they can be dragged in + /// Configuration Manager rather than recompiled - the same shape as WarVultureConfig. + /// + /// Note what the switch does NOT do: turning the hammer off never un-scales anything already + /// standing. A piece carries its own size on its ZDO, and that is read back on load whatever + /// the config says, so a house built at 1.2 stays a house and not a pile of clipping walls. + /// The switch only decides whether NEW placements are enlarged. + /// + public static class TrolsHammerConfig + { + public static ConfigEntry Enabled; + public static ConfigEntry ScaleFactor; + + public static void Bind(ConfigFile config) + { + // No apostrophe, and not a typo: BepInEx rejects ' in a section name outright, and this + // Bind runs from the plugin's Awake - so "Trol's Hammer" did not merely fail to appear + // in Configuration Manager, it threw and took the whole mod's startup with it. + const string section = "Trols Hammer"; + + Enabled = config.Bind(section, "Enabled", true, + new ConfigDescription("Whether pieces placed with Trol's Hammer come out enlarged. " + + "Switching this off leaves every piece already built at the size " + + "it was built at; only new placements are affected.")); + + ScaleFactor = config.Bind(section, "Scale factor", 1.2f, + new ConfigDescription("How much bigger than the vanilla piece. 1.2 is the +20% the " + + "hammer exists for. Cost and drop never change - this is size " + + "only.", new AcceptableValueRange(1f, 3f))); + } + + /// + /// The multiplier a new placement should use, or 1 when the hammer is switched off. Clamped + /// against a zero or negative value typed straight into the .cfg file, which the + /// Configuration Manager slider cannot produce but a text editor can - and a piece scaled to + /// zero is a piece that cannot be seen, hit or removed. + /// + public static float ActiveFactor() + { + if (Enabled == null || ScaleFactor == null) return 1f; + if (!Enabled.Value) return 1f; + return ScaleFactor.Value > 0.01f ? ScaleFactor.Value : 1f; + } + } +} diff --git a/JotunnModStub/TrolsHammer/TrolsHammerItem.cs b/JotunnModStub/TrolsHammer/TrolsHammerItem.cs new file mode 100644 index 0000000..5fa4076 --- /dev/null +++ b/JotunnModStub/TrolsHammer/TrolsHammerItem.cs @@ -0,0 +1,97 @@ +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Trol's Hammer: the builder's hammer, one size up. + /// + /// It is a straight clone of the vanilla Hammer and it deliberately keeps the ONE field that + /// makes it a hammer at all - m_buildPieces, the PieceTable. Sharing the vanilla table rather + /// than cloning it is the whole trick behind "exactly the same things to build": every piece + /// vanilla puts in the hammer's menu is there, at the same cost and with the same drop, and so + /// is every piece another mod adds to that table later. A cloned table would have been a + /// snapshot of the build menu taken at startup and would have quietly gone stale. + /// + /// Nothing about the piece prefabs is touched, so the size does not live on the item: it lives + /// on the placement, and TrolsHammerPatches is where that happens. + /// + /// The recipe (1 core wood, 2 fine wood) is on a workbench rather than free-hand like the + /// vanilla hammer, because both materials already require one to exist. + /// + public static class TrolsHammerItem + { + public const string PrefabName = "TrolsHammer"; + public const string DisplayName = "Trol's Hammer"; + + private const string SourcePrefab = "Hammer"; + private const string Label = "TrolsHammer"; + + /// Core wood. The item id is RoundLog - a display name that does not predict the id. + private const string CoreWood = "RoundLog"; + private const string FineWood = "FineWood"; + + public static void Register() + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PrefabName, SourcePrefab); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[{Label}] Could not clone {SourcePrefab}; {DisplayName} not registered."); + return; + } + + ItemDrop drop = prefab.GetComponent(); + if (drop == null || drop.m_itemData == null || drop.m_itemData.m_shared == null) + { + Jotunn.Logger.LogWarning($"[{Label}] {SourcePrefab} clone has no usable ItemDrop; {DisplayName} not registered."); + return; + } + + ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; + shared.m_name = DisplayName; + shared.m_description = "A hammer swung by something that never had to duck through a " + + "doorway. It builds everything the ordinary one builds, out of the " + + "same materials, and simply builds it bigger."; + + if (shared.m_buildPieces == null) + { + // Not fatal, but worth saying out loud: without a piece table the item is a stick. + Jotunn.Logger.LogWarning($"[{Label}] The {SourcePrefab} clone carries no build piece table; " + + $"{DisplayName} will open an empty build menu."); + } + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + + ItemManager.Instance.AddRecipe(new CustomRecipe(new RecipeConfig + { + Item = PrefabName, + Amount = 1, + CraftingStation = CraftingStations.Workbench, + MinStationLevel = 1, + Requirements = new[] + { + new RequirementConfig(CoreWood, 1, 0, true), + new RequirementConfig(FineWood, 2, 0, true), + }, + })); + + Jotunn.Logger.LogInfo($"[{Label}] {DisplayName} registered on the vanilla hammer's piece table."); + } + + /// + /// Whether an item in hand is this hammer. + /// + /// m_dropPrefab is the reliable identity - it is the prefab the ItemData came from - but it + /// is null on an ItemData built before ObjectDB finished, so the display name is kept as a + /// second reading rather than as the only one. + /// + public static bool IsTrolsHammer(ItemDrop.ItemData item) + { + if (item == null) return false; + if (item.m_dropPrefab != null) return item.m_dropPrefab.name == PrefabName; + return item.m_shared != null && item.m_shared.m_name == DisplayName; + } + } +} diff --git a/JotunnModStub/TrolsHammer/TrolsHammerPatches.cs b/JotunnModStub/TrolsHammer/TrolsHammerPatches.cs new file mode 100644 index 0000000..33f3f09 --- /dev/null +++ b/JotunnModStub/TrolsHammer/TrolsHammerPatches.cs @@ -0,0 +1,217 @@ +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Where the +20% actually happens. + /// + /// Three things had to be true for this to be a feature rather than a trick, and each one is a + /// separate patch below: + /// + /// 1. the SIZE MUST SURVIVE. Valheim does not replicate localScale - a piece is rebuilt from + /// its ZDO every time the zone loads, at whatever size its prefab has. So the multiplier is + /// written onto the piece's own ZDO at placement and read back in ZNetView.Awake, which is + /// the earliest moment a ZDO is guaranteed to exist (confirmed from the assembly: + /// WearNTear.Awake returns early if GetZDO() is null, so it already assumes this order). + /// That one hook covers all three cases at once - the builder's client, every other + /// player's client, and the same world reopened next week; + /// + /// 2. the PREVIEW MUST NOT LIE. The ghost is what the game tests for clipping, overlap and + /// snapping, so an unscaled ghost would let a player place a piece that immediately + /// overlapped its neighbour. SetupPlacementGhost ends by copying the prefab's localScale + /// onto the ghost, so a postfix - and only a postfix - can multiply it; + /// + /// 3. the PIECE ITSELF MUST NOT BE TOUCHED. Nothing here writes to a piece prefab. Cost, + /// drop, health, comfort and build menu are vanilla's, untouched, which is exactly why the + /// same walls can still be built at normal size with the ordinary hammer. + /// + /// Placement is caught with a flag around Player.PlacePiece rather than by patching the piece: + /// PlacePiece is void and instantiates the PREFAB (not the ghost) inside itself, so there is no + /// return value to read and no way to reach the new object afterwards. The instantiate runs + /// synchronously, which means every Awake it triggers happens inside that window. + /// + public static class TrolsHammerScaling + { + /// + /// The ZDO key the size is written to. Hashed once: this is read in ZNetView.Awake, which + /// runs for every networked object in the world, so it is not a place to be hashing strings. + /// + public static readonly int ScaleKey = "RoV_TrolHammerScale".GetStableHashCode(); + + /// + /// True only for the few milliseconds Player.PlacePiece spends instantiating a piece the + /// player asked for with Trol's Hammer in hand. Static because the only caller is the local + /// player and the window never nests. + /// + public static bool Placing; + + public static float PlacingFactor = 1f; + + public static void Apply(Transform t, float factor) + { + if (t == null || factor <= 0f || Mathf.Approximately(factor, 1f)) return; + + // A multiply and not an assignment: a handful of vanilla pieces do not sit at scale 1, + // and the brief is "20% bigger than it was", not "20% bigger than one metre". + Vector3 s = t.localScale; + t.localScale = new Vector3(s.x * factor, s.y * factor, s.z * factor); + } + } + + /// + /// The preview, at the size it will actually be built. + /// + /// A postfix because vanilla's last act in this method is to copy the source prefab's + /// localScale onto the ghost - a prefix would be overwritten a few instructions later. + /// + /// The hand is read through the public RightItem property and NOT through GetCurrentWeapon, + /// which is the obvious-looking call and the wrong one: it only returns the right hand when + /// ItemData.IsWeapon() is true, and that method does not count ItemType.Tool. A hammer would + /// have come back as the player's fists. + /// + public static class TrolsHammerGhost + { + private static GameObject m_tracked; + private static Vector3 m_baseScale = Vector3.one; + private static float m_applied = 1f; + + /// + /// Remembers the size vanilla just gave the ghost, before anything of ours touches it. This + /// is the only moment that number is knowable: a few frames later the ghost's localScale is + /// whatever WE last wrote, and using it as a base would compound on every pass. + /// + public static void Adopt(GameObject ghost) + { + m_tracked = ghost; + m_baseScale = ghost != null ? ghost.transform.localScale : Vector3.one; + m_applied = 1f; + } + + /// + /// Puts the ghost at the size the hand in the player's right hand would build it. + /// + /// Called every frame because the ghost is NOT rebuilt when the player swaps tools: + /// SetupPlacementGhost only runs on Awake, on a piece-selection change and on a build menu + /// refresh (confirmed by walking its callers in the assembly). Swapping from one hammer to + /// the other with the same wall selected keeps the same ghost object alive, so a size + /// applied once at setup would go on lying about a piece that is now built at normal size. + /// + /// Cheap enough to be unconditional: it exits on a float comparison in every frame but the + /// one where the answer actually changed. + /// + public static void Sync(Player player, GameObject ghost) + { + if (player == null || ghost == null) + { + m_tracked = null; + return; + } + + if (ghost != m_tracked) Adopt(ghost); + + float desired = TrolsHammerItem.IsTrolsHammer(player.RightItem) + ? TrolsHammerConfig.ActiveFactor() + : 1f; + + if (Mathf.Approximately(desired, m_applied)) return; + + ghost.transform.localScale = m_baseScale * desired; + m_applied = desired; + } + } + + [HarmonyPatch(typeof(Player), "SetupPlacementGhost")] + public static class TrolsHammerGhostSetupPatch + { + private static void Postfix(Player __instance, GameObject ___m_placementGhost) + { + TrolsHammerGhost.Adopt(___m_placementGhost); + TrolsHammerGhost.Sync(__instance, ___m_placementGhost); + } + } + + /// + /// The correction pass. This also runs once inside TryPlacePiece, immediately before the piece + /// is placed, which is what guarantees the thing tested for clipping is the size that lands. + /// + [HarmonyPatch(typeof(Player), "UpdatePlacementGhost")] + public static class TrolsHammerGhostUpdatePatch + { + private static void Postfix(Player __instance, GameObject ___m_placementGhost) + { + TrolsHammerGhost.Sync(__instance, ___m_placementGhost); + } + } + + /// + /// The window. PlacePiece is void, so there is nothing to postfix onto - the flag is the whole + /// mechanism, and ZNetView.Awake is what reads it. + /// + /// A Finalizer rather than a Postfix closes the window, so the flag is cleared even if vanilla + /// throws halfway through placing. A flag left stuck on would enlarge the next unrelated + /// networked object to spawn anywhere in the world. + /// + [HarmonyPatch(typeof(Player), "PlacePiece")] + public static class TrolsHammerPlacePatch + { + private static void Prefix(Player __instance) + { + if (__instance == null || __instance != Player.m_localPlayer) return; + if (!TrolsHammerItem.IsTrolsHammer(__instance.RightItem)) return; + + float factor = TrolsHammerConfig.ActiveFactor(); + if (Mathf.Approximately(factor, 1f)) return; + + TrolsHammerScaling.Placing = true; + TrolsHammerScaling.PlacingFactor = factor; + } + + private static void Finalizer() + { + TrolsHammerScaling.Placing = false; + } + } + + /// + /// The one hook that both stamps the size and restores it. + /// + /// It runs for EVERY networked object in the world, so the ordinary path is deliberately as + /// cheap as one dictionary lookup on a pre-hashed key: no GetComponent, no string work, no + /// allocation. The GetComponent<Piece> guard is paid only inside the placement window, and + /// it is there so an effect prefab that happens to carry a ZNetView cannot be mistaken for the + /// wall being built. + /// + /// The restore branch ignores the config on purpose - see TrolsHammerConfig. + /// + [HarmonyPatch(typeof(ZNetView), "Awake")] + public static class TrolsHammerZNetViewPatch + { + private static void Postfix(ZNetView __instance) + { + if (__instance == null || !__instance.IsValid()) return; + + ZDO zdo = __instance.GetZDO(); + if (zdo == null) return; + + if (TrolsHammerScaling.Placing && __instance.GetComponent() != null) + { + float factor = TrolsHammerScaling.PlacingFactor; + + // Written before it is applied, and only by the owner - which the placing client + // always is, since this ZDO was created a few instructions ago by this very Awake. + if (zdo.IsOwner()) zdo.Set(TrolsHammerScaling.ScaleKey, factor); + TrolsHammerScaling.Apply(__instance.transform, factor); + + // The window is closed here as well as in the Finalizer: one placement is one + // piece, and leaving it open for the rest of PlacePiece would hand the same size to + // anything else that woke up inside it. + TrolsHammerScaling.Placing = false; + return; + } + + float saved = zdo.GetFloat(TrolsHammerScaling.ScaleKey, 0f); + if (saved > 0f) TrolsHammerScaling.Apply(__instance.transform, saved); + } + } +} diff --git a/JotunnModStub/ZNetSceneOrphanPatch.cs b/JotunnModStub/ZNetSceneOrphanPatch.cs new file mode 100644 index 0000000..507e194 --- /dev/null +++ b/JotunnModStub/ZNetSceneOrphanPatch.cs @@ -0,0 +1,174 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The "teleport bug", and why it is a crash about teleporting at all. + /// + /// WHAT THE REPORT LOOKS LIKE. Two NullReferenceExceptions out of ZNetScene.Update, the first + /// of them through UnityEngine.Component.get_gameObject: + /// + /// ZNetScene.RemoveObjects -> ZNetScene.CreateDestroyObjects -> ZNetScene.Update + /// + /// WHAT IT ACTUALLY IS. ZNetScene keeps a table of every networked object it has built, + /// m_instances, mapping ZDO to ZNetView, and RemoveObjects is the pass that unloads whatever is + /// no longer near the player. Read out of the assembly rather than assumed, it does exactly + /// this: + /// + /// foreach (ZNetView value in m_instances.Values) + /// if (value.GetZDO().TempRemoveEarmark != b) m_tempRemoved.Add(value); // (1) + /// ... + /// UnityEngine.Object.Destroy(zNetView.gameObject); // (2) + /// + /// Neither line can survive an entry whose object is already gone: (1) throws a plain NRE if the + /// ZDO has been reset out from under it, and (2) throws through get_gameObject - Unity's "this + /// object was destroyed and you are still using it" - if the ZNetView itself is dead. That is + /// the exact pair of stack traces in the report. + /// + /// AND THE ENTRY IS NEVER CLEANED UP BY UNITY, which is the part worth writing down, because it + /// is the trap every despawn in this mod has to avoid. ZNetView.OnDestroy, in full: + /// + /// private void OnDestroy() { _ = (bool)ZNetScene.instance; if (m_heldReferences != null) ... } + /// + /// It releases asset references and NOTHING else - it does not take itself out of m_instances. + /// So any object that is destroyed the Unity way instead of the ZNetScene way (Object.Destroy on + /// a networked creature or piece, a ZNetView stripped off a clone that had already woken, an + /// ancestor destroyed with a networked child underneath it) leaves a dead entry in the table, + /// and it sits there harmlessly until something walks the whole table. + /// + /// WHICH IS WHY IT IS ALWAYS A TELEPORT. Standing still, the dead entry is earmarked as "near" + /// every frame and line (2) is never reached for it. A teleport moves the reference position a + /// world away, so on that frame everything that was around the player becomes removable, the + /// dead entry is finally reached, and RemoveObjects throws. The throw aborts + /// CreateDestroyObjects, which aborts ZNetScene.Update - and because the offending entry is + /// removed on the line AFTER the one that threw, it is still there next frame. From that moment + /// the scene manager is dead for the rest of the session: nothing new loads, nothing unloads, + /// the player stands in an empty world. + /// + /// WHAT THIS PATCH DOES. It is a finalizer, so it costs nothing on the millions of calls that + /// work. When RemoveObjects does throw, it sweeps m_instances for entries whose ZNetView is dead + /// or whose ZDO has been reset, takes them out, and swallows the exception so the next frame + /// runs clean. Vanilla's own rule is used for the ZDO behind each one - a temporary ZDO this + /// client owns is destroyed with its object, a persistent one is world data and is left exactly + /// where it is, because "the view is broken" is not evidence that the player's building should + /// be deleted. + /// + /// If the sweep finds nothing, the exception is handed back untouched: this patch is for one + /// specific failure and must not hide anybody else's. + /// + /// AND IT NAMES THE CULPRIT. Every purge logs the PREFAB NAME behind each dead entry, which is + /// the one thing the stack trace cannot tell us. Whatever is producing these - this mod, another + /// mod, or a plain vanilla race condition - the next log from a crashed teleport says so by + /// name, and the fix can then go where it belongs: at the despawn that used Object.Destroy + /// instead of ZNetScene.Destroy. + /// + [HarmonyPatch(typeof(ZNetScene), "RemoveObjects")] + public static class ZNetScene_RemoveObjects_OrphanPatch + { + private static readonly FieldInfo InstancesField = AccessTools.Field(typeof(ZNetScene), "m_instances"); + + // Reused rather than allocated per sweep: a sweep runs from inside a failing frame, and the + // one thing that must not happen there is extra pressure on the frame that is already sick. + private static readonly List Broken = new List(); + private static readonly Dictionary CountByPrefab = new Dictionary(); + + private static int totalPurged; + + public static Exception Finalizer(Exception __exception, ZNetScene __instance) + { + if (__exception == null) return null; + + int purged = Purge(__instance); + + // Nothing broken in the table means this throw was not ours to catch. + return purged > 0 ? null : __exception; + } + + private static int Purge(ZNetScene scene) + { + if (scene == null || InstancesField == null) return 0; + + Dictionary instances = InstancesField.GetValue(scene) as Dictionary; + if (instances == null) return 0; + + Broken.Clear(); + CountByPrefab.Clear(); + + foreach (KeyValuePair instance in instances) + { + // Unity's own == is what makes the first half of this work: a component whose + // GameObject has been destroyed is still a live managed object, and only this + // comparison knows it is dead. The second half is the reset-ZDO case from line (1). + if (instance.Value != null && instance.Value.GetZDO() != null) continue; + + Broken.Add(instance.Key); + } + + if (Broken.Count == 0) return 0; + + int purged = Broken.Count; + int persistentLeftAlone = 0; + + foreach (ZDO zdo in Broken) + { + string prefab = PrefabNameOf(zdo); + int seen; + CountByPrefab.TryGetValue(prefab, out seen); + CountByPrefab[prefab] = seen + 1; + + instances.Remove(zdo); + + if (!zdo.Persistent && zdo.IsOwner() && ZDOMan.instance != null) + { + ZDOMan.instance.DestroyZDO(zdo); + } + else if (zdo.Persistent) + { + persistentLeftAlone++; + } + } + + totalPurged += purged; + + List named = new List(CountByPrefab.Count); + foreach (KeyValuePair entry in CountByPrefab) + { + named.Add(entry.Value == 1 ? entry.Key : entry.Key + " x" + entry.Value); + } + + Jotunn.Logger.LogWarning( + $"[RacesOfValheim] ZNetScene.RemoveObjects threw on {purged} dead scene " + + (purged == 1 ? "entry" : "entries") + + $" - the teleport crash. Purged: {string.Join(", ", named)}. " + + (persistentLeftAlone > 0 + ? $"{persistentLeftAlone} of them had a persistent ZDO, which is world data and was left alone. " + : "") + + $"The world keeps loading. ({totalPurged} purged this session.) " + + "Whoever destroyed those objects used Object.Destroy where ZNetScene.Destroy was needed."); + + Broken.Clear(); + CountByPrefab.Clear(); + + return purged; + } + + /// + /// The name behind a dead entry, which is the whole diagnostic value of this patch. A hash + /// with no prefab behind it is still worth printing - it means the object came from a mod + /// that is no longer loaded, which is an answer too. + /// + private static string PrefabNameOf(ZDO zdo) + { + if (zdo == null) return "no ZDO"; + + int hash = zdo.GetPrefab(); + GameObject prefab = hash != 0 && ZNetScene.instance != null ? ZNetScene.instance.GetPrefab(hash) : null; + + return prefab != null ? prefab.name : $"unknown prefab (hash {hash})"; + } + } +} diff --git a/README.md b/README.md index ece9a78..3eb8a29 100644 --- a/README.md +++ b/README.md @@ -2,6 +2,18 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing new mechanics, visual forms, and a progression system for your journey. +--- + +## New Patch v1.4.2: The Sverm + +The tenth race is an insect. The Sverm never dresses: chest, legs and helm are carapace that never comes off and is always worth a full set of the biome ahead of you — best quality, weightless, no movement penalty. It fights with claws it cannot put down, poison cannot touch it, and no invertebrate in the game will attack it from tier zero. Blunt and fire hit it 40% harder, which is the price. + +After the Elder it stops being one body and becomes a colony: a Brood Mound you feed whole stacks to, a Hive Market, a roster of insect troops, captured beehives. After Yagluth it can leave the ground entirely as a deathsquito. + +Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions-level-by-level). + +--- + ## Features **Races of Valheim introduces 10 custom playable races:** @@ -25,7 +37,8 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing ![Fenrir3](https://wiki.aledanidev.ovh/assets/images/fenrir3.gif) - **Beast Form:** Transform into a wolf-like beast. - **Cultist Form:** Transform into a Cultist to use fire abilities. -- **Cursed Claws:** The wolf's hands, kept on in the man's shape. They cannot be taken from you — draw a sword and the claws wait, sheathe it and they are back. Pure slash, growing with every boss. +- **Cursed Claws:** The wolf's hands, kept on in the man's shape — see [Permanent Claws](#permanent-claws). +- **A Pack of Your Own:** The Pack Trough keeps a standing pack of wolves, ulvs and, late, fenrir — see [Race Stations](#race-stations--companions). - **Progression:** Forms grow as you defeat bosses, unlocking new powers and reducing cooldowns. Immune to fall damage. ### 4. Aswid @@ -35,8 +48,8 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing - **Blood Magic:** Block to activate a life-draining aura (radius doubled at night, only in Bat or Mist Form). - **Blood Magic Mastery:** Cast Blood Magic items with infinite Eitr (health cost only). - **Benedictus et Afflictus:** Passive speed/jump bonuses double at night. -- **Claws of the Beast:** Blackened claws you did not forge and cannot put down. They cannot be taken from you — draw a sword and the claws wait, sheathe it and they are back. Pure slash, growing with every boss. -- **Burning Eyes:** Spectral green sockets that hold a red glow only in the final stage, with smoke trailing off them. +- **Claws of the Beast:** Blackened claws you did not forge and cannot put down — see [Permanent Claws](#permanent-claws). +- **Burning Eyes:** Spectral green sockets, smoke trailing off them, that hold a red glow only in the final stage. - **Undead Vigor:** Infinite stamina. Consume the lifeforce of enemies instead of eating normal food. ### 5. Furling @@ -61,6 +74,7 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing - **Hood Never Comes Off:** Cosmetic dvergr hood always on, but keep all helm protection. - **Master of Metal/Mine:** Favoured weapons hit harder for less stamina, mining improves, forges are more efficient. - **Kin of the Traders:** Haldor/Hildir give you better prices. +- **Coin Instead of Blood:** The Contract Bank hires professional dvergr crews and the Rune Barrel gives them drink — see [Race Stations](#race-stations--companions). - **Runes:** Late game, spend Eitr for powerful effects. ### 9. Trenta @@ -72,15 +86,25 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing - **Root and Rot:** Late game: emit healing pollen, open portals, summon hornet companions, take Elder’s shape. ### 10. Sverm -- **Chitin Plating:** You never dress. Chest, legs and helm are carapace that never comes off, worth a full set of the biome ahead of you at every tier — best quality, weightless, no movement penalty. Only cloak and trinket may still be worn. -- **Vilebone Maulclaws:** Your hands are the weapon, and they cannot be taken from you. Draw a sword and the claws wait; sheathe it and they are back. +- **Chitin Plating:** You never dress. Chest, legs and helm are carapace worth a full set of the biome ahead of you at every tier — best quality, weightless, no movement penalty. Only cloak and trinket may still be worn. +- **Vilebone Maulclaws:** Your hands are the weapon — see [Permanent Claws](#permanent-claws). - **Hive Pheromones:** No invertebrate attacks you — leeches, ticks, deathsquitos, seekers and bees all ignore you, from tier zero. -- **Toxin Immunity:** Poison cannot touch you. Blunt weapons and fire hit you 40% harder — until Fader, when the fire weakness burns out and comes back as a resistance. -- **The Colony:** After the Elder, build a Brood Mound, feed it whole stacks of food, wood or resin, and spend the digested biomass on a roster of insect troops, a Hive Market, blister ticks and captured beehives. +- **Toxin Immunity:** Poison cannot touch you. Blunt and fire hit you 40% harder — until Fader, when the fire weakness burns out and comes back as a resistance. +- **The Colony:** After the Elder, a Brood Mound, a Hive Market and a roster of insect troops bought with digested biomass. - **Stinger Morph:** After Yagluth, become a deathsquito — real flight and the creature's own sting, on a body made of paper. --- +## Permanent Claws + +Three races grow a pair of their own. The terms are identical for all three: issued once, never dropped or traded, refused by the holster key, and back in your hands the moment your hands are free — draw a sword and the claws wait, sheathe it and they are back. Damage is measured against **one** yardstick rather than against the models each race wears, so the same tier is worth the same whichever race you are, and it climbs with every boss. No pair counts while you are wearing another body: a bat, a mist, a wolf or a deathsquito does its own damage with its own hands. + +- **Aswid — Claws of the Beast:** burned almost black. Lands the whole of it as slash. +- **Fenrir — Cursed Claws:** the flesh rippers worn as the game made them. Also pure slash. +- **Sverm — Vilebone Maulclaws:** splits the same weight three ways, and sets it alight at Fader. + +--- + ## Installation 1. Install BepInExPack Valheim. @@ -94,7 +118,7 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing
Aswid Progression -- **Base:** Benedictus et Afflictus. Progressive stats (+1 Armor, +2 Damage, +1% Speed, +1% Jump per boss). Passives are doubled at night. Blood magic items are free (health cost only). Physical kills auto-devour enemies for Blood Magic XP. Claws of the Beast: permanent slash claws that climb with every boss. Eyes burn spectral green. +- **Base:** Benedictus et Afflictus. Progressive stats (+1 Armor, +2 Damage, +1% Speed, +1% Jump per boss). Passives are doubled at night. Blood magic items are free (health cost only). Physical kills auto-devour enemies for Blood Magic XP. Claws of the Beast. Eyes burn spectral green. - **Eikthyr:** Bat Form (night only). Vampiric Aura (heal 20% on magic AoE). - **The Elder:** Bat Form always. - **Bonemass:** Auspex (Aura reveals wild creatures). @@ -128,7 +152,7 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing - **Bonemass:** -13 Max Health. Smithing/gem crafting 20% cheaper. Trader prices -10%/rewards +10%. - **Moder:** -15 Max Health. Smithing cap -40%. Trader -15%/+20%. - **Yagluth:** -17.5 Max Health. Crossbows added. Trader -20%/+30%. Runic Ping (G, 25 Eitr): highlight ore/enemies nearby; 20s CD. -- **Queen:** -20 Max Health. Trader -25%/+40%. +- **Queen:** -20 Max Health. Trader -25%/+40%. The Contract Bank accepts the Queen's drop and opens its two upgraded crews. - **Fader:** Runic Overcharge (H, 60 Eitr): next favoured hit is 4x damage; lasts 15s, 60s CD.
@@ -136,11 +160,11 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing
Fenrir Progression -- **Base:** +3 Armor, +5 Damage, -10% Fall Damage, +3% Speed/Jump per boss killed. Cursed Claws: permanent slash claws that climb with every boss. +- **Base:** +3 Armor, +5 Damage, -10% Fall Damage, +3% Speed/Jump per boss killed. Cursed Claws. - **Elder:** Wolf Form (night). - **Bonemass:** Wolf Form (anytime). Ulv Form (night). -- **Moder:** Ulv Form (anytime). Fenring Form (night). -- **Yagluth:** Cultist Form (night, 1min, 10min CD). +- **Moder:** Ulv Form (anytime). Fenring Form (night). Moder's drop is in the Pack Trough's recipe, so the pack can be started here. +- **Yagluth:** Cultist Form (night, 1min, 10min CD). A Greater Ulvsblod and what Yagluth left behind upgrade the trough to raise fenrir. - **Queen:** Fenring Form (anytime). Cultist Form (night, 1min, 5min CD). - **Fader:** Cultist Form (anytime). @@ -194,7 +218,7 @@ Right Mouse toggles flight. Glide towards aim, W = forward/climb, Shift+W = use
Sverm Progression -- **Base:** Chitin Plating (carapace armour, full next-biome set at every tier, weightless, no speed penalty; only cloak and trinket wearable). Toxin Immunity — poison cannot touch you, but +40% blunt and +40% fire damage taken. Hive Pheromones — no invertebrate attacks you. Insect Metabolism — eats everything, honey counts double, alchemical blood is the one refusal. Vilebone Maulclaws — unarmed blows land at a share of the claws' full weight, rising with every tier. +- **Base:** Chitin Plating (full next-biome set at every tier, weightless, no speed penalty; only cloak and trinket wearable). Toxin Immunity — poison cannot touch you, but +40% blunt and +40% fire damage taken. Hive Pheromones — no invertebrate attacks you. Insect Metabolism — eats everything, honey counts double, alchemical blood is the one refusal. Vilebone Maulclaws — unarmed blows land at a share of the claws' full weight, rising with every tier. - **Eikthyr:** Metabolic Surge – running and jumping cost less, and you jump higher. Ventral Pouches – +100 carry weight. - **Elder:** Grinding Mandibles – seeds are food (raw nourishment, no garden buffs). Sensory Antennae – feel what lives around you, through stone and soil. **The colony wakes:** Brood Mound unlocked. - **Bonemass:** Venom Glands – every blow carries bonus poison, growing per tier. Acid Hemolymph – melee attackers take poison back. @@ -238,6 +262,66 @@ Build a **Brood Mound** with the hammer — no more than two within its density --- +## Race Stations & Companions + +Every race has a buildable station of its own, gated by a reagent bought from its faction's merchant. Stations of the same kind cannot be packed on top of each other — each has its own minimum spacing. Servants raised at any of them share one system: they follow when asked, walk home when dismissed, carry no loot on death, and knit their own wounds shut (ten seconds unhurt, then 2% a second). + +- **Aswid — Blood Refinery:** refines Blood Essence, Superior Blood Essence and Blood Core. +- **Draugh — Cursed Body Pile:** eats raw flesh and answers with tamed draugr; Draugr and Elite trophies are worth a whole batch. Anyone can build it, but only a Draugh gives the draugr orders — for everyone else it is a grave that defends its own ten meters. +- **Furling — Five crops:** Copper, Tin and Iron Flax grow metal out of poisoned soil; Stoneberry and Flintberry bushes give stone and flint. +- **Skadi — Crystal Golem:** a stonecutter-bound guardian on a leash. Skadi (and Trol) may also build inside any troll cave in the world. +- **Skeleton — Bound Bone Pile & Bound Sentry:** pay once per slot and that slot refills itself forever, because an army you re-buy after every fight is one nobody takes out of the house. The Sentry is a bound archer that cannot walk, regenerates when left alone, and hands its parts back when it falls. +- **Sverm — Brood Mound & Hive Market:** see [The Colony](#race-progressions-level-by-level). +- **Trenta — Composter & Heartwood Grove:** the Composter rots raw flesh into Fertilizer, which grows any plant on the spot. The Grove is a tree that fertilises what surrounds it, stings what approaches it, and fills a chest with honey. +- **Trol — War Totem:** hires warbands of trolls and greydwarves for coin. Race locked — the hammer refuses it to anyone who is not a Trol. A dead warband is money spent. + +### Dvergar — Contract Bank + +Coin on the table and a professional crew signs on. The one chain that needs no reagent from a merchant, because the Dvergar pay for everything: the station opens by being paid for. + +- **Build:** 10 Black Marble, 5 Yggdrasil Wood, 2 Sap, 100 Coins. Hammer, no crafting station. Race locked — the hammer refuses it to anyone who is not a Dvergar. One per square kilometre. +- **Five contract slots**, bought with coin out of your own pack and at your own trader discount (down to -25% at the Queen): + +| Crew | Price | Who signs | +| --- | --- | --- | +| Escort | 400 | 1 Dverger, 2 Seeker Broods | +| Yard Patrol | 700 | 2 Dverger, 2 Seeker Broods | +| Fire Crew | 1000 | 1 Dverger, 1 Fire Mage, 3 Seeker Broods | +| Runic Crew | 1500 | 2 Dverger, 1 Ice Mage, 1 Support Mage | +| Ash Guard | 2000 | 2 Ashlands Dverger, 1 Support Mage, 1 Seeker Brute | + +- **Upgrade:** offer the Queen's drop to the bank and the last two crews open; a heap of coin appears on the table to show for it. +- **The truce is the point:** a hired crew keeps its employer's peace with the mountain's dvergr, seekers at heel included, so walking into an outpost with an escort does not end with your escort killing the shopkeeper. +- They are not merchants, they carry no loot — a crew that dropped its own parts would turn coin into more coin — and a dead crew is money spent. + +### Dvergar — Rune Barrel + +The second half of the chain: drink for a hired crew, prepared before you walk out rather than pressed mid-fight. + +- **Build:** 10 Fine Wood, 5 Black Marble, 1 Sap. Cheap on purpose — the barrel is not the cost, the brews poured into it are, forever. +- Holds **20 doses**. Pour in any vanilla consumable and everyone you have raised within **30 m** of the barrel drinks it — the range is around the barrel, not around the bank, so a crew three biomes away is not at the table. +- It refuses nothing and promises nothing: what a brew does to a mercenary is whatever it would have done to you, *if they have the parts for it*. A healing mead heals a dvergr; a stamina mead does nothing at all, because a creature has no stamina bar to fill. + +### Fenrir — Pack Trough + +Meat goes in and a standing pack fills up, in three ranks. It is a herd you keep, not a button you press before a fight: the pack is paid for in meat, arrives one animal at a time over the better part of an hour, and only grows while its zone is loaded. + +- **Reagent:** **Ulvsblod**, bought from Fenring merchants for 500 coin. **Greater Ulvsblod** is 1500 and upgrades the trough. +- **Build:** 1 Ulvsblod, 10 Silver, 1 Dragon Tear, 20 Fine Wood — so Moder must already be down. Immune to pickaxes, so a stray swing while mining out a pen cannot cost you a pack; the hammer still takes it down deliberately. One per square mile. +- **Feed it** any flesh, on the same scale the other chains use, so a lox steak counts for more than a neck tail. The tank holds 400 — four fenrir deep, which is several trips and not one. +- **The ranks fill in order**, each waiting for the one below it to be full: + +| Rank | Slots | One every | Cost from the tank | +| --- | --- | --- | --- | +| Pack Wolf | 10 → 15 | 2 min | 25 | +| Ulv | 6 → 10 | 3 min | 50 | +| Fenrir | 0 → 5 | 5 min | 100 | + +- **Upgrade:** feed it a Greater Ulvsblod once Yagluth is down and hand over what he left behind. That is what opens the fenrir rank at all, and it raises the two below it. +- The pack is born tame and leashed, does not breed, drops nothing, heals itself, follows and walks home. Fenrir are deliberately larger than vanilla Fenring so they cannot be mistaken for a transformed player in a melee. If the trough goes, the pack withers in five minutes. + +--- + ## The War Vulture (Flying Mount) A vulture's head kept on a stick. Raise it and the bird comes back under you. @@ -253,6 +337,20 @@ Speeds, sprint duration, recharge, mount size and seat position are all in Confi --- +## Trol's Hammer (Building, One Size Up) + +A builder's hammer swung by something that never had to duck through a doorway. + +- **Craft:** 1 Core Wood, 2 Fine Wood, at a Workbench. Any race may make one. +- **Builds exactly what the ordinary hammer builds.** It shares the vanilla hammer's own build menu rather than a copy of it, so every piece is there — including pieces other mods add to the hammer — at the same cost, with the same health and the same drop when you take it down. +- **Everything comes out 20% bigger.** Size is the only thing that changes. The preview is already at full size, so what you see snapped and clipped is what you get. +- **Both hammers work in the same house.** The ordinary hammer still builds at normal size, and either one repairs or removes anything. Big pieces snap to big pieces, since their snap points grow with them. +- **It sticks.** The size is saved with the piece, so it survives a reload, and other players see the same building you do (they need the mod installed). + +The size is a slider in Configuration Manager under `Trols Hammer`. Turning the hammer off there only stops new placements from growing — anything already standing keeps the size it was built at. + +--- + ## The Race Menu Ward - Build (2 Wood, Hammer/Misc, no crafting station). First placed near Sacrificial Stones in every new world. @@ -267,10 +365,9 @@ In personal mode, offer boss’s secondary drop to the Ward (Hard Antler, Crypt ## Factions -Races are grouped in 3 factions (with vanilla creatures): +![Join the Skeleton Army!](https://wiki.aledanidev.ovh/assets/images/skeleton_march_small.gif) -- Your faction's mobs will not attack you, and some offer trading (press E). -- Buy/sell prices are always equal. +Races are grouped in 3 factions, together with vanilla creatures. Your faction's mobs will not attack you, some offer trading (press E), and buy/sell prices are always equal. **Black Forest:** Trenta, Trol, Furling / at peace with Greydwarves, Fuling (Goblin), Goblin Brute/Shaman, Troll. @@ -294,29 +391,37 @@ Bug reports, feedback, ideas: [https://discord.gg/gbBEK2VTE](https://discord.gg/ ## Changelog -### v1.5.0 +### v1.4.2 +- **NEW - Sverm Race:** the tenth race. Wears carapace instead of armour (never removable, always worth the next biome's full set, weightless), fights with permanent claws, is immune to poison but takes 40% more from blunt and fire, and is ignored by every invertebrate in the game from tier zero. After the Elder it stops being one body and becomes a colony. +- **NEW - The Colony (Sverm):** Brood Mound, digestion bank, brood eggs on a timer, an insect troop roster, a Hive Market, blister ticks that regrow free, and vanilla beehives taken over by the nest — twice the speed, three times the honey, royal jelly after Yagluth. +- **NEW - War Vulture (Flying Mount):** a vulture trophy on a stick that puts you on a real, network-visible flying bird. Unlimited cruise, a limited sprint reserve on the run key that refills in mid-air, and its own bar under your stamina. Furling and Dvergar by default, configurable. No recipe yet while the flight is being proven — spawn it from the console. +- **NEW - Trol's Hammer:** a second builder's hammer (1 Core Wood, 2 Fine Wood, Workbench) that builds everything the ordinary one builds — same menu, same cost, same drop — 20% larger. The preview is already at full size, the size is saved with the piece and shared with other players, and both hammers keep working side by side in the same house. +- **NEW - Claws for the Aswid and the Fenrir:** both races now grow a permanent pair, on the same terms the Sverm has always had. All three are measured against **one** yardstick rather than against the models they wear, so the same tier is worth the same damage whichever race you are, and no pair counts while you are wearing another body. +- **NEW - Dvergar Contract Bank:** the hire bench is now a proper contract bank — five crew slots, 400 to 2000 coin, paid at your own trader discount, with the Queen's drop opening the Runic Crew and the Ash Guard. Hired crews keep their employer's truce with the mountain's dvergr, seekers at heel included, so a band walking into an outpost no longer means a dead shopkeeper. They carry no loot, heal themselves, and a dead crew is money spent. Race locked, one per square kilometre, and the only chain that needs no reagent — the Dvergar pay for everything, so 100 coin goes in the recipe instead. +- **NEW - Dvergar Rune Barrel:** 20 doses of any vanilla brew, poured into everything you have raised within 30 m. It refuses nothing and promises nothing: a healing mead heals a dvergr, a stamina mead does nothing, because a creature has no stamina bar. +- **NEW - Fenrir Pack Trough:** built on Ulvsblod bought from the Fenring (500 coin), silver and Moder's drop, then fed any flesh into a 400-deep tank. Ten Pack Wolves fill first, one every two minutes, then six Ulv every three. A Greater Ulvsblod and what Yagluth left behind take it to 15 wolves, 10 ulv and 5 Fenrir. The pack is tame, leashed, breeds not at all, drops nothing, heals itself, and withers five minutes after the trough does. Pickaxe immune, one per square mile. + - *The earlier breeding version of this station is gone for good: cubs are a different prefab from adults, so the pen either jammed at its first litter or never stopped growing. The trough raises the pack; the pack does not raise itself.* +- **Aswid - Eyes:** rebuilt out of the real thing — the eye lights vanilla skeletons wear, smoke and all, instead of two painted spheres. Spectral green for the whole climb; the red is now held back for the final stage. Position, size, colour and smoke are in Configuration Manager. +- **Skeleton - Lit Sockets:** the skull now carries the eye lights of whichever creature its tier is built from, cloned from that creature's own prefab, so each tier arrives in its own colour rather than one picked by hand. +- **Fix - Skeleton Mandible:** the jaw sat wrong on every tier, because the player rig's own jaw bone is not where a skull's belongs. Corrected once and for all, and written absolutely rather than nudged each frame — which is what had the head flickering five times a second and stretching into a spike whenever the game was paused. +- **Skadi:** the Hidden Hollow is gone (it could not be made to behave in multiplayer). In its place, the **Crystal Golem**, a stonecutter-bound guardian on a leash — and Skadi and Trol may now build inside any troll cave in the world. +- **Skeleton:** Bound Bone Pile slots are paid for once and refill themselves forever; the Bound Sentry regenerates when left alone and hands its parts back when it falls. +- **Draugh:** the Cursed Body Pile can be built by anyone, but only a Draugh commands the draugr — for everyone else it is a grave that defends its own ten meters. +- **Trol:** the War Totem is race locked; the hammer refuses it to anyone who is not a Trol. +- **Building:** stations of the same kind can no longer be packed on top of each other — each one has its own minimum spacing. +- **Factions:** the merchant catalogue now carries the reagents that gate every station chain, and hostility rules were reworked alongside it. -- **NEW - Claws for the Aswid and the Fenrir:** Both races now grow a permanent pair, on the same terms the Sverm has always had: issued once, never dropped or traded, back in hand the moment your hands are free, and refused by the holster key. The Aswid's **Claws of the Beast** are burned almost black; the Fenrir's **Cursed Claws** are the flesh rippers worn as the game made them. -- **Claws - Balance:** All three clawed races are measured against **one** yardstick rather than against the models they wear, so the same tier is worth the same damage whichever race you are. The Aswid's and the Fenrir's land the whole of it as **slash**, where the Sverm splits it three ways and sets it alight at Fader. Neither pair counts while you are wearing another body — a bat, mist or a wolf does its own damage with its own hands. -- **Aswid - Eyes:** Rebuilt out of the real thing: the eye lights vanilla skeletons wear, smoke and all, instead of two painted spheres. Spectral green for the whole climb, and the red is now held back for the final stage. Position, size, colour and smoke are all in Configuration Manager. -- **Skeleton - Lit Sockets:** The skull now carries the eye lights of whichever creature its tier is built from, cloned from that creature's own prefab — so each tier arrives in its own colour rather than a colour picked by hand. -- **Fix - Skeleton Mandible:** The jaw sat wrong on every tier, because the player rig's own jaw bone is not where a skull's belongs. Corrected once and for all, and the correction is written absolutely rather than nudged each frame — which is what had the head flickering five times a second and stretching into a spike whenever the game was paused. -- **NEW - Sverm Race:** The tenth race. Wears carapace instead of armour (never removable, always worth the next biome's full set, weightless), fights with permanent claws, is immune to poison but takes 40% more from blunt and fire, and is ignored by every invertebrate in the game from tier zero. After the Elder it stops being one body and becomes a colony. -- **NEW - The Colony (Sverm):** Build a Brood Mound and feed it whole stacks of food, wood or resin. Feeding is not instant — it digests into the nest's bank at a fixed rate. Spend that biomass, plus brood eggs the nest lays on a timer, on a roster of insect troops that follow you, walk home when dismissed and mend themselves. A Hive Market raised nearby is where everything is bought; growing the nest through its four stages opens the next rung of the roster. Vanilla beehives raised inside the nest's ten meters are taken over by the colony: twice the speed, three times the honey, royal jelly after Yagluth. Honey and royal jelly heal your insects instead of feeding the nest. -- **NEW - War Vulture (Flying Mount):** A vulture trophy on a stick that puts you on a real, network-visible flying bird. Left click to call it, click again for a controlled descent. Unlimited cruise, a limited sprint reserve on the run key that refills in mid-air, and its own bar under your stamina. Furling and Dvergar by default, configurable. No recipe yet while the flight is being proven — spawn it from the console. -- **NEW - Race Stations and Item Chains:** Every race now has a buildable station of its own, gated by a reagent bought from its faction's merchant. Servants across all of them share one system: they follow when asked, walk home when dismissed, and knit their own wounds shut. - - **Aswid:** Blood Refinery — refines Blood Essence, Superior Blood Essence and Blood Core. - - **Trenta:** Composter — rots raw flesh into Fertilizer, which grows any plant on the spot. Heartwood Grove — a tree that fertilises what surrounds it, stings what approaches it, and fills a chest with honey. - - **Draugh:** Cursed Body Pile — eats raw flesh and answers with tamed draugr. Draugr and Elite trophies are worth a whole batch. Anyone can build it, but only a Draugh gives the draugr orders; for everyone else it is a grave that defends its own ten meters. - - **Skeleton:** Bound Bone Pile — pay once per slot and that slot refills itself forever, because skeletons are fragile and an army you re-buy after every fight is one nobody takes out of the house. Bound Sentry — a bound archer that cannot walk, regenerates when left alone, and hands its parts back when it falls. - - **Trol:** War Totem — hires warbands of trolls and greydwarves for coin. Race locked: the hammer refuses it to anyone who is not a Trol. A dead warband is money spent. - - **Dvergar:** Contract Bank — coin on the table, a professional crew signs on; they keep their race's truce, so a hired band walking into a dvergr outpost does not start a war with the shopkeeper. Rune Barrel — pour a vanilla potion into it and the crew standing around it drinks. - - **Fenrir:** Pack Trough — Ulvsblod and Greater Ulvsblod buy a roster of Pack Wolves, Ulvs and Fenrir. - - **Skadi:** Crystal Golem — a stonecutter-bound guardian on a leash. Skadi (and Trol) may now build inside any troll cave in the world. - - **Furling:** Five crops. Copper, Tin and Iron Flax grow metal out of poisoned soil; Stoneberry and Flintberry bushes give stone and flint. -- **Factions:** The merchant catalogue now carries the reagents that gate every one of the chains above, and hostility rules were reworked alongside it. -- **Building:** Stations of the same kind can no longer be packed on top of each other — each one has its own minimum spacing. -- **Fix - Crash:** Duplicate items in ObjectDB are deduplicated by name hash before the registers update, which fixes a crash on world load. +### v1.4.1 +- **NEW - Race Stations & Item Chains:** every race gets a build/economy loop tied to its identity, gated by a reagent from its faction's merchant — the full list is under [Race Stations & Companions](#race-stations--companions). +- **Aswid:** Vampiric Aura is now a toggle; Devour moved off the `I` key. +- **Factions:** same-faction mobs no longer smash player structures; Fuling/Goblin food and prefab-id lookups fixed for real prefab ids instead of display names. +- **Skadi:** dragon breath and its VFX now point the same direction. +- **Trol:** fixed the log weapon's hidden inventory slot crashing `InventoryGrid`. +- **Fenrir:** taunt howl now sourced from the real creature's alert bark. +- **Visuals:** fixed glow eyes occasionally rendering behind the skull (Aswid/Dvergar). +- **Input:** abilities no longer die while a movement key is held. +- **Compendium:** every race entry rewritten against live game code for accuracy. +- **General:** deduped `ObjectDB.m_items` by name hash to fix a duplicate-item crash when joining a server. ### v1.4.0 - **NEW - Factions:** Each race is at peace with a faction of vanilla mobs; many now trade with you if you match. Goblins (Fuling) peace/trade now works properly. @@ -354,4 +459,4 @@ Bug reports, feedback, ideas: [https://discord.gg/gbBEK2VTE](https://discord.gg/ - **Aswid:** Food buffs survive death; prey nutrition scaling fixed. - **General:** Logging cleanup. -![Furling](https://wiki.aledanidev.ovh/assets/images/fur.gif) \ No newline at end of file +![Furling](https://wiki.aledanidev.ovh/assets/images/fur.gif) diff --git a/manifest.json b/manifest.json index 7ae2ba9..c9a811b 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", - "description": "A Valheim mod that adds nine custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Trenta, Trol) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.4.0", + "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", + "version_number": "1.4.2", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 8580d65a566424415adc8a23a8ca80c6db321336 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 14 Aug 2026 15:24:33 +0200 Subject: [PATCH 003/273] warvulture --- JotunnModStub/WarVulture/WarVultureConfig.cs | 30 ++++++++++ JotunnModStub/WarVulture/WarVultureItem.cs | 58 +++++++++++++++++++- JotunnModStub/WarVulture/WarVultureMount.cs | 5 +- README.md | 4 +- 4 files changed, 90 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/WarVulture/WarVultureConfig.cs b/JotunnModStub/WarVulture/WarVultureConfig.cs index 1903f4a..8ef89f0 100644 --- a/JotunnModStub/WarVulture/WarVultureConfig.cs +++ b/JotunnModStub/WarVulture/WarVultureConfig.cs @@ -89,6 +89,36 @@ namespace RacesOfValheim "cloned from vanilla's mount stamina bar.")); } + /// + /// The race of a player, read m_customData first and the ZDO second. + /// + /// That order is the one the summon has always used, and it is kept rather than swapped for + /// the ZDO-first order the visuals use, for a reason: this only ever asks about the LOCAL + /// player, whose m_customData is authoritative and is written before the ZDO on a race + /// change. The ZDO is the fallback for the one frame after a load where m_customData has not + /// been filled in yet - without it the crafting list would flicker the recipe away. + /// + public static string RaceOf(Player player) + { + if (player == null) return null; + + if (player.m_customData != null && + player.m_customData.TryGetValue("Race", out string custom) && + !string.IsNullOrEmpty(custom)) + { + return custom; + } + + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid()) + { + string race = nview.GetZDO().GetString("RacesOfValheim_Race", ""); + if (!string.IsNullOrEmpty(race)) return race; + } + + return null; + } + /// /// Whether a race id may call the bird. An empty list means everyone, which is the honest /// reading of "no restriction" and is also what makes this testable on any character. diff --git a/JotunnModStub/WarVulture/WarVultureItem.cs b/JotunnModStub/WarVulture/WarVultureItem.cs index 8ba29ad..e3443d9 100644 --- a/JotunnModStub/WarVulture/WarVultureItem.cs +++ b/JotunnModStub/WarVulture/WarVultureItem.cs @@ -1,4 +1,6 @@ +using System.Collections.Generic; using HarmonyLib; +using Jotunn.Configs; using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; @@ -36,6 +38,12 @@ namespace RacesOfValheim private const string TrophyPrefab = "TrophyVolture"; private const string Label = "WarVulture"; + /// The three materials. Ids, not display names: the ingot is BlackMetal (the SCRAP + /// is the ore), and the raw lox meat is LoxMeat, with CookedLoxMeat being the other one. + private const string GreydwarfEye = "GreydwarfEye"; + private const string BlackMetalIngot = "BlackMetal"; + private const string RawLoxMeat = "LoxMeat"; + public static void Register() { GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PrefabName, SourcePrefab); @@ -73,9 +81,24 @@ namespace RacesOfValheim // is not. Getting that wrong once put a live Ashlands predator in the player's world. WarVultureVisual.BuildTemplate(); - // No recipe, on purpose and for now: the item is spawned from the console - // ("spawn WarVulture") while the flight is being proven. A recipe costs nothing to add - // later and would only be materials invented before anyone knows what this is worth. + // The forge, and not the workbench, for the same reason Trol's Hammer sits on a + // workbench: the station is picked by the material that is hardest to have. Eyes and + // meat are picked up off the ground; a black metal ingot means a blast furnace already + // exists, and the forge is where that metal is worked. + ItemManager.Instance.AddRecipe(new CustomRecipe(new RecipeConfig + { + Item = PrefabName, + Amount = 1, + CraftingStation = CraftingStations.Forge, + MinStationLevel = 1, + Requirements = new[] + { + new RequirementConfig(GreydwarfEye, 10, 0, true), + new RequirementConfig(BlackMetalIngot, 2, 0, true), + new RequirementConfig(RawLoxMeat, 2, 0, true), + }, + })); + Jotunn.Logger.LogInfo($"[{Label}] {DisplayName} registered: no eitr, no health, no stamina, no skeleton."); } @@ -251,6 +274,35 @@ namespace RacesOfValheim } } + /// + /// Who gets to see the recipe: the same list the bird itself answers to + /// (WarVultureConfig.AllowedRaces, "Furling,Dvergar" out of the box), read through the same + /// helper, so the crafting menu and the summon can never disagree. A race that could craft the + /// item but not call the bird would just be selling someone ten greydwarf eyes' worth of stick. + /// + /// Player.GetAvailableRecipes is the single funnel the crafting list is built from, and it is + /// public and takes the list by ref - so a Postfix that removes one entry is the whole gate. + /// The recipe is still REGISTERED for everybody, which is deliberate: it stays in ObjectDB, so + /// a character who changes race sees it appear or vanish with no world edit and no re-register. + /// + /// Filtering here rather than at the craft click also means the refusal never has to be + /// explained - an item that was never in the list cannot be clicked. + /// + [HarmonyPatch(typeof(Player), nameof(Player.GetAvailableRecipes))] + public static class WarVultureRecipeRacePatch + { + private static void Postfix(Player __instance, ref List available) + { + if (__instance == null || available == null) return; + if (WarVultureConfig.RaceAllowed(WarVultureConfig.RaceOf(__instance))) return; + + available.RemoveAll(recipe => + recipe != null && + recipe.m_item != null && + Utils.GetPrefabName(recipe.m_item.gameObject) == WarVultureItem.PrefabName); + } + } + /// /// The click. Attack.OnAttackTrigger is used rather than Attack.Start because it takes NO /// parameters - its signature cannot drift - and it fires when the animation reaches its diff --git a/JotunnModStub/WarVulture/WarVultureMount.cs b/JotunnModStub/WarVulture/WarVultureMount.cs index 027a540..1d8646a 100644 --- a/JotunnModStub/WarVulture/WarVultureMount.cs +++ b/JotunnModStub/WarVulture/WarVultureMount.cs @@ -107,8 +107,9 @@ namespace RacesOfValheim private static void Summon(Player rider) { - string race = null; - if (rider.m_customData != null) rider.m_customData.TryGetValue("Race", out race); + // Through WarVultureConfig.RaceOf rather than reading m_customData here, so this gate + // and the one hiding the recipe (WarVultureRecipeRacePatch) are literally the same read. + string race = WarVultureConfig.RaceOf(rider); if (!WarVultureConfig.RaceAllowed(race)) { diff --git a/README.md b/README.md index 3eb8a29..dd323fc 100644 --- a/README.md +++ b/README.md @@ -327,11 +327,11 @@ Meat goes in and a standing pack fills up, in three ranks. It is a herd you keep A vulture's head kept on a stick. Raise it and the bird comes back under you. - **Who can call it:** Furling and Dvergar by default. The list is a config entry (`War Vulture - Access`) — add races to it, or leave it empty to let everyone ride. In anyone else's hands the item is an inert trophy. +- **Crafting:** 10 greydwarf eyes, 2 black metal ingots and 2 raw lox meat, at a forge. The recipe is only in the crafting list for the races allowed above — change that config and it appears or disappears for your character with no new world and no restart. - **Summon and dismount:** Left click the item to call the bird. Left click again and the vulture starts a controlled descent, ignoring your input until the ground arrives; a third click lets go on the spot. - **Flying:** Same feel as the Aswid's bat form — you steer where you look. Cruise speed is unlimited, because a vulture stays up for hours. - **Sprint:** Hold the vanilla run key for full speed. The bird only has so much wind in it (10s by default) before it settles back to a glide, and it refills in the air as soon as you let go — landing is not required. The reserve is drawn as a bar under your own stamina. - **Seen by others:** Everyone else sees you sitting on a real vulture; the bird and the riding pose are network-synced. -- **Not craftable yet.** There is deliberately no recipe while the flight is being proven — the item is spawned from the console (`spawn WarVulture`). A recipe will land once it is clear what the ride is worth in materials. Speeds, sprint duration, recharge, mount size and seat position are all in Configuration Manager under `War Vulture`. @@ -394,7 +394,7 @@ Bug reports, feedback, ideas: [https://discord.gg/gbBEK2VTE](https://discord.gg/ ### v1.4.2 - **NEW - Sverm Race:** the tenth race. Wears carapace instead of armour (never removable, always worth the next biome's full set, weightless), fights with permanent claws, is immune to poison but takes 40% more from blunt and fire, and is ignored by every invertebrate in the game from tier zero. After the Elder it stops being one body and becomes a colony. - **NEW - The Colony (Sverm):** Brood Mound, digestion bank, brood eggs on a timer, an insect troop roster, a Hive Market, blister ticks that regrow free, and vanilla beehives taken over by the nest — twice the speed, three times the honey, royal jelly after Yagluth. -- **NEW - War Vulture (Flying Mount):** a vulture trophy on a stick that puts you on a real, network-visible flying bird. Unlimited cruise, a limited sprint reserve on the run key that refills in mid-air, and its own bar under your stamina. Furling and Dvergar by default, configurable. No recipe yet while the flight is being proven — spawn it from the console. +- **NEW - War Vulture (Flying Mount):** a vulture trophy on a stick that puts you on a real, network-visible flying bird. Unlimited cruise, a limited sprint reserve on the run key that refills in mid-air, and its own bar under your stamina. Furling and Dvergar by default, configurable. Crafted at a forge from 10 greydwarf eyes, 2 black metal ingots and 2 raw lox meat, and the recipe is hidden from every race that cannot ride. - **NEW - Trol's Hammer:** a second builder's hammer (1 Core Wood, 2 Fine Wood, Workbench) that builds everything the ordinary one builds — same menu, same cost, same drop — 20% larger. The preview is already at full size, the size is saved with the piece and shared with other players, and both hammers keep working side by side in the same house. - **NEW - Claws for the Aswid and the Fenrir:** both races now grow a permanent pair, on the same terms the Sverm has always had. All three are measured against **one** yardstick rather than against the models they wear, so the same tier is worth the same damage whichever race you are, and no pair counts while you are wearing another body. - **NEW - Dvergar Contract Bank:** the hire bench is now a proper contract bank — five crew slots, 400 to 2000 coin, paid at your own trader discount, with the Queen's drop opening the Runic Crew and the Ash Guard. Hired crews keep their employer's truce with the mountain's dvergr, seekers at heel included, so a band walking into an outpost no longer means a dead shopkeeper. They carry no loot, heal themselves, and a dead crew is money spent. Race locked, one per square kilometre, and the only chain that needs no reagent — the Dvergar pay for everything, so 100 coin goes in the recipe instead. From 0aa1dc4dc82dec7f7f8b5cb35581ce2dd77f69fd Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sun, 16 Aug 2026 07:44:44 +0200 Subject: [PATCH 004/273] warvulture --- JotunnModStub/Butler/BoneServant.cs | 292 ++++ JotunnModStub/Butler/BoneServantAI.cs | 1286 +++++++++++++++++ JotunnModStub/Butler/ButlerConfig.cs | 50 + JotunnModStub/Butler/ButlerStation.cs | 496 +++++++ JotunnModStub/Butler/ServantTableBehaviour.cs | 170 +++ JotunnModStub/Dvergar/DvergarBanco.cs | 11 + .../Factions/FactionMerchantPatches.cs | 44 + JotunnModStub/RaceClaws.cs | 16 +- JotunnModStub/RaceCompendium.cs | 2 +- JotunnModStub/RacesOfValheim.cs | 6 +- JotunnModStub/Sverm/SvermClawSlot.cs | 25 +- JotunnModStub/Sverm/SvermClaws.cs | 8 +- JotunnModStub/Sverm/SvermConfig.cs | 4 +- JotunnModStub/Sverm/SvermProgression.cs | 2 +- JotunnModStub/Sverm/SvermStingerForm.cs | 4 +- JotunnModStub/Sverm/SvermVisuals.cs | 2 +- JotunnModStub/Trol/TrolTotem.cs | 11 + README.md | 25 +- manifest.json | 2 +- 19 files changed, 2432 insertions(+), 24 deletions(-) create mode 100644 JotunnModStub/Butler/BoneServant.cs create mode 100644 JotunnModStub/Butler/BoneServantAI.cs create mode 100644 JotunnModStub/Butler/ButlerConfig.cs create mode 100644 JotunnModStub/Butler/ButlerStation.cs create mode 100644 JotunnModStub/Butler/ServantTableBehaviour.cs diff --git a/JotunnModStub/Butler/BoneServant.cs b/JotunnModStub/Butler/BoneServant.cs new file mode 100644 index 0000000..bbd9147 --- /dev/null +++ b/JotunnModStub/Butler/BoneServant.cs @@ -0,0 +1,292 @@ +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The two Bone Servants and their tables. Servants that work the stations around them and never + /// lift a hand against anything. + /// + /// TWO TRADES, and that was the first thing the working version asked for. One servant serving a + /// whole yard spends its life walking: with the kitchen at one edge of the circle and the furnaces + /// at the other, travel eats the margin that keeps food off the fire. So there is a SMITH for the + /// Smelter family and a COOK for cooking stations and mead, each with its own table, each with its + /// own twenty-metre circle - and the two circles may sit on top of each other, because the servants + /// never look at the same station. PieceDensityLimit counts by prefab name, so "no second table + /// within forty metres" keeps smith away from smith and cook away from cook, and needed no change + /// at all to let a smith and a cook stand side by side. + /// + /// The smith keeps the ORIGINAL prefab names, BoneServant and ServantTable. That is not tidiness - + /// it means a table already standing in a test world keeps working and keeps its servant instead of + /// becoming a missing prefab at the next load. + /// + /// TWO PREFABS EACH, forced the same way the sentry's are: a Character cannot sit in the hammer's + /// piece table, so the buildable thing is the table and the servant is instantiated by it. Unlike + /// the sentry there is no seed piece to throw away, because here the table is not scaffolding - it + /// is the anchor, the summoning point and the only interface the feature has. + /// + /// WHAT WAS DELIBERATELY NOT REUSED. The design said the servant would be a RaisedThrall, and it is + /// not. RaisedThrall brings the anchor, the leash and the withering, all of which are wanted - but + /// it also brings RaisedThrallInteractPatch, which turns E on the creature into a follow command. + /// A servant that can be told to follow you out of its own circle is a servant that stops serving, + /// and "E does nothing on the servant" was decided explicitly. So the useful half is reused as a + /// static - RaisedThrall.RegisterStation / StationStandsAt, which is what makes the table findable - + /// and the anchor and wither clock are thirty lines inside BoneServantAI. The alternative was + /// editing RaisedThrall.cs, which is shared with five other chains. + /// + public static class BoneServant + { + // The smith inherits the names the single servant had, so nothing already built is orphaned. + public const string SmithName = "BoneServant"; + public const string SmithTableName = "ServantTable"; + public const string SmithDisplay = "Bone Smith"; + public const string SmithTableDisplay = "Smith's Table"; + + public const string CookName = "BoneCook"; + public const string CookTableName = "CookTable"; + public const string CookDisplay = "Bone Cook"; + public const string CookTableDisplay = "Cook's Table"; + + /// Vanilla's guaranteed-melee skeleton: the plain one rolls its own weapon, and the + /// point here is to have none at all. + private const string ServantSource = "Skeleton_NoArcher"; + + public const float Health = 100f; + + /// Two circles of twenty metres cannot overlap if the tables are forty apart, which is + /// how the question of two servants of the SAME trade fighting over one chest was answered - by + /// making the situation impossible to build rather than by sharing state between them. + public const float TableSpacing = 40f; + + private const float TableScale = 0.8f; + + /// + /// One skull, one wishbone, eight stone - the same price for both tables. + /// + /// The skull is TrophySkeleton and NOT this mod's own CursedSkull, and that is forced rather + /// than chosen: the cursed skull is bought from the Skeleton faction's merchant, so building it + /// into the cook's price would make the cook unbuildable by the only race allowed to build it. + /// A skeleton trophy is a skull anyone can go and get. + /// + /// The wishbone is a real cost and worth knowing about: it is Bonemass's drop and the only + /// treasure-finder in the game, so a standing table keeps yours locked up. Recovered in full + /// when the table is removed, like every other recipe in this mod. + /// + private static RequirementConfig[] Recipe() + { + return new[] + { + new RequirementConfig("TrophySkeleton", 1, 0, true), + new RequirementConfig("Wishbone", 1, 0, true), + new RequirementConfig("Stone", 8, 0, true), + }; + } + + public static void Register() + { + if (RegisterServant(SmithName, SmithDisplay, ButlerFamily.Forge)) + { + RegisterTable(SmithTableName, SmithTableDisplay, SmithName, ButlerFamily.Forge, + "A slab of bone and slate, dusted with ore. Something patient waits by the fires.", + "Coal"); + + PieceDensityLimit.Register(SmithTableName, TableSpacing, 1, + "Another smith's table stands within forty paces. One smith to a yard."); + + // Two races, and it is the wider of the two locks: the Skeleton raises the dead to work + // for it, and Skadi's hold is a forge under ice. + PieceDensityLimit.RegisterGate(SmithTableName, (player, position) => + { + if (SkeletonRace.IsSkeleton() || SkadiRace.IsLocalSkadi()) return true; + + if (player != null) + { + player.Message(MessageHud.MessageType.Center, + "The bones do not answer to your blood."); + } + return false; + }); + } + + if (RegisterServant(CookName, CookDisplay, ButlerFamily.Kitchen)) + { + RegisterTable(CookTableName, CookTableDisplay, CookName, ButlerFamily.Kitchen, + "A slab of bone and slate, worn smooth. Something patient waits by the hearth.", + "CookedMeat"); + + PieceDensityLimit.Register(CookTableName, TableSpacing, 1, + "Another cook's table stands within forty paces. One cook to a yard."); + + // Skadi alone. A hearth kept by something dead is hers, not the Skeleton's. + PieceDensityLimit.RegisterGate(CookTableName, (player, position) => + { + if (SkadiRace.IsLocalSkadi()) return true; + + if (player != null) + { + player.Message(MessageHud.MessageType.Center, + "Only Skadi's hearth is kept by the dead."); + } + return false; + }); + } + } + + // ---------------------------------------------------------------- the servants + + private static bool RegisterServant(string prefabName, string displayName, ButlerFamily family) + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(prefabName, ServantSource); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Butler] Could not clone {ServantSource}; " + + $"{displayName} is not registered."); + return false; + } + + Character character = prefab.GetComponent(); + if (character != null) + { + character.m_name = displayName; + character.m_health = Health; + character.m_faction = Character.Faction.Players; + } + + // Nothing in its hands, and nothing to roll for. Belt and braces with the AI prefix: the + // code that would swing a weapon never runs, but a servant carrying a rusty sword around + // the kitchen would still look like a mistake. + Humanoid humanoid = prefab.GetComponent(); + if (humanoid != null) + { + humanoid.m_defaultItems = new GameObject[0]; + humanoid.m_randomWeapon = new GameObject[0]; + humanoid.m_randomArmor = new GameObject[0]; + humanoid.m_randomShield = new GameObject[0]; + humanoid.m_randomSets = new Humanoid.ItemSet[0]; + } + + BaseAI ai = prefab.GetComponent(); + if (ai != null) + { + ai.m_randomMoveRange = 0f; // it never wanders: every step it takes is a decision + ai.m_avoidFire = false; // it works next to kilns for a living + ai.m_afraidOfFire = false; + } + + // A servant that dropped bones would be a bone mill, exactly as with the garrison. + foreach (CharacterDrop drops in prefab.GetComponentsInChildren(true)) + { + if (drops != null) Object.DestroyImmediate(drops); + } + + // Ten seconds unhurt, then two percent a second. The sentry's regeneration, whole. + prefab.AddComponent(); + + BoneServantAI servant = prefab.AddComponent(); + servant.m_family = family; + + PrefabManager.Instance.AddPrefab(prefab); + return true; + } + + // ---------------------------------------------------------------- the tables + + private static void RegisterTable(string pieceName, string displayName, string servantPrefab, + ButlerFamily family, string description, string iconSource) + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(pieceName, "piece_cartographytable"); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Butler] Could not clone piece_cartographytable; " + + $"the {displayName} is not registered."); + return; + } + + // The MapTable trap, and it is the reason this is a blanket sweep by capability rather than + // a named DestroyImmediate: MapTable is Interactable AND Hoverable, so it takes the E key + // before our own Switch ever sees it and opens the shared map instead. Same bug as the + // barrel's Container on the Fenrir trough and the Trader on the vanilla wolf; the Dvergar + // contract bank pays for this lesson already. + foreach (MonoBehaviour behaviour in prefab.GetComponentsInChildren(true)) + { + if (behaviour == null) continue; + if (behaviour is Piece || behaviour is ZNetView || behaviour is WearNTear) continue; + Object.DestroyImmediate(behaviour); + } + + prefab.transform.localScale = Vector3.one * TableScale; + + ServantTableBehaviour table = prefab.AddComponent(); + table.m_switch = prefab.AddComponent(); + table.m_switch.m_name = displayName; + table.m_title = displayName; + table.m_servantPrefab = servantPrefab; + table.m_family = family; + + Sprite icon = BorrowIcon(iconSource) ?? BorrowIcon("TrophySkeleton"); + + Piece piece = prefab.GetComponent() ?? prefab.AddComponent(); + piece.m_craftingStation = null; + piece.m_resources = new Piece.Requirement[0]; + piece.m_name = displayName; + piece.m_canBeRemoved = true; + piece.m_groundPiece = true; + piece.m_groundOnly = true; + piece.m_icon = icon; + + Piece template = PrefabManager.Cache.GetPrefab("piece_workbench"); + if (template != null && template.m_placeEffect != null) piece.m_placeEffect = template.m_placeEffect; + + PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig + { + Name = displayName, + Description = description, + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Crafting, + Icon = icon, + Requirements = Recipe(), + })); + } + + public static void EnsureKnown(Player player) + { + if (player == null) return; + + Traverse traverse = Traverse.Create(player); + LearnPiece(traverse, SmithTableName); + LearnPiece(traverse, CookTableName); + traverse.Method("UpdateAvailablePiecesList").GetValue(); + } + + private static void LearnPiece(Traverse player, string pieceName) + { + GameObject prefab = PrefabManager.Instance.GetPrefab(pieceName); + Piece piece = prefab != null ? prefab.GetComponent() : null; + if (piece == null) return; + + player.Method("AddKnownPiece", piece).GetValue(); + } + + private static Sprite BorrowIcon(string prefabName) + { + ItemDrop drop = PrefabManager.Cache.GetPrefab(prefabName); + Sprite[] icons = drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null + ? drop.m_itemData.m_shared.m_icons + : null; + return icons != null && icons.Length > 0 ? icons[0] : null; + } + } + + [HarmonyPatch(typeof(Player), "OnSpawned")] + public static class BoneServantKnownPatch + { + public static void Postfix(Player __instance) + { + if (__instance != Player.m_localPlayer) return; + BoneServant.EnsureKnown(__instance); + } + } +} diff --git a/JotunnModStub/Butler/BoneServantAI.cs b/JotunnModStub/Butler/BoneServantAI.cs new file mode 100644 index 0000000..c6eee21 --- /dev/null +++ b/JotunnModStub/Butler/BoneServantAI.cs @@ -0,0 +1,1286 @@ +using System.Collections.Generic; +using System.Text; +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Bone Servant's own head. Everything it does is here; vanilla's MonsterAI never runs on it. + /// + /// HOW IT MOVES, which was the one open question in the design and is answered here rather than in + /// the doc. Three candidates were on the table: a ghost follow-target, pinning m_patrolPoint the way + /// RaisedThrall does, and calling BaseAI.MoveTo directly. The IL settled it: + /// + /// - BaseAI has NO Update and NO FixedUpdate. UpdateAI(dt) is driven centrally by + /// MonoUpdaters.FixedUpdate over BaseAI.Instances, and that list is maintained by OnEnable / + /// OnDisable. So "disable the AI and drive MoveTo yourself" kills the only thing that would + /// call anything: a disabled BaseAI is not ticked at all. That candidate is dead. + /// - BaseAI.UpdateAI itself does almost nothing - IsOwner, UpdateTakeoffLanding, + /// UpdateRegeneration - so skipping it costs a flying check we do not need and a regeneration + /// we already have from SkeletonSentryBehaviour. + /// + /// So: a PREFIX on MonsterAI.UpdateAI that hands the tick to this class and returns false. The + /// servant keeps its place in the central tick, keeps vanilla pathing through BaseAI.MoveTo, and + /// vanilla's own AI - targeting, fleeing, wandering, attacking - never executes a single line. That + /// is also why the servant cannot fight: not because its weapon was taken (it was), but because the + /// code that would swing it is never reached. + /// + /// MoveTo(dt, point, dist, run) is private, hence the cached MethodInfo. It returns TRUE on arrival + /// (read in the IL: DistanceXZ under the threshold calls StopMoving and returns 1), which is the + /// whole arrival test - no distance maths of our own. + /// + /// THE PAYLOAD IS VIRTUAL. The servant has no inventory. Every station's input RPC takes a STRING, + /// so what it carries is a list of prefab names and counts in its own ZDO, which survives saving, + /// zone reload and - the case that matters - a change of owner mid-job in multiplayer. The one + /// thing this costs is that the goods do not exist as objects while in transit, so they have to be + /// put back into the world by hand if the servant dies holding them. That is , + /// and it is the reason nothing here can quietly delete a player's ore. + /// + public class BoneServantAI : MonoBehaviour + { + // ─── ZDO keys ──────────────────────────────────────────────────────── + public const string KeyAnchor = "RoV_butlerAnchor"; + public const string KeyOrphanAt = "RoV_butlerOrphanAt"; + public const string KeyLoad = "RoV_butlerLoad"; + public const string KeySource = "RoV_butlerSource"; + public const string KeyTarget = "RoV_butlerTarget"; + public const string KeyStatus = "RoV_butlerStatus"; + + /// Written into a STATION's ZDO: the chest whose material is in it right now, so the + /// product goes home to where the raw came from even after a reload, and even if a different + /// client collects it. + public const string KeyFedBy = "RoV_butlerFedBy"; + + // ─── numbers that are not worth a config entry ─────────────────────── + private const float PlanInterval = 1.5f; + + /// + /// How close is close enough. Measured to the piece's ORIGIN, which on a furnace or a kiln sits + /// inside a metre or so of solid collider - so anything tight enough to look like hugging the + /// thing is a distance the servant can never actually reach, and it would time out and put a + /// perfectly good station in the penalty box. Two and a half metres is roughly where a player + /// stands to use one. + /// + private const float ArriveDistance = 2.5f; + + private const float CollectRadius = 3.5f; + private const float JobTimeout = 25f; + private const float PenaltySeconds = 180f; + + /// Set aside briefly when a job was reached but achieved nothing. Without this, a job + /// that arrives and finds nothing to do is re-planned identically on the next tick and the + /// servant stands there deciding the same thing forever. + private const float ShortPenaltySeconds = 20f; + private const float FleeSeconds = 6f; + private const float WitherSeconds = 30f; + private const float HomeCheckRange = 25f; + + /// A cooking slot inside this many seconds of burning outranks everything else. Twelve + /// seconds is a walk of about twenty metres with room to spare, which is the whole radius. + private const float SpoilPanicSeconds = 12f; + + /// How long a station may sit unserved before its wait starts outweighing distance. + /// This is what stops a furnace at the edge of the circle from starving while the servant + /// shuttles between two closer ones. + private const float WaitToMetres = 0.25f; + + private const int PayloadCap = 120; + + private static readonly System.Reflection.MethodInfo MoveToMethod = + AccessTools.Method(typeof(BaseAI), "MoveTo", + new[] { typeof(float), typeof(Vector3), typeof(float), typeof(bool) }); + + private static readonly System.Reflection.FieldInfo AllPiecesField = + AccessTools.Field(typeof(Piece), "s_allPieces"); + + private static readonly System.Reflection.MethodInfo ContainerSaveMethod = + AccessTools.Method(typeof(Container), "Save"); + + private static int s_itemMask = -1; + + /// Which stations this one serves. Set on the prefab at registration, so it travels + /// with every instance the table raises. + public ButlerFamily m_family = ButlerFamily.Forge; + + private ZNetView m_nview; + private Character m_character; + private MonsterAI m_ai; + + private readonly object[] m_moveArgs = new object[4]; + private readonly List m_payload = new List(); + private readonly Dictionary m_penalties = new Dictionary(); + private readonly Dictionary m_idleSince = new Dictionary(); + + private readonly List m_stations = new List(); + private readonly List m_chests = new List(); + private float m_scannedAt = -99f; + + private Job m_job; + private float m_nextPlan; + private float m_jobDeadline; + private float m_fleeUntil; + private string m_status = ""; + + private class Load + { + public string Name; + public int Count; + } + + private class Job + { + public string Kind; // load | fuel | collect | deposit | drop + public ZDOID Target; + public Vector3 Point; + public bool Hurry; + public string Label; + } + + // ================================================================ life + + private void Awake() + { + m_nview = GetComponent(); + m_character = GetComponent(); + m_ai = GetComponent(); + + ReadPayload(); + } + + private void OnDestroy() + { + // Only a DEATH scatters the load. A zone unloading destroys this object too, and there the + // payload must stay in the ZDO where it will be read again on the way back in - dropping it + // would mint a copy every time the player walked away. + if (m_character != null && m_character.IsDead()) DropPayload(); + } + + /// Called by the table the moment it raises one. + public void Bind(Vector3 anchor) + { + if (m_nview == null || !m_nview.IsValid()) return; + + m_nview.GetZDO().Set(KeyAnchor, anchor); + + if (m_ai != null) m_ai.MakeTame(); + if (m_character != null) m_character.SetTamed(true); + } + + public Vector3? Anchor + { + get + { + if (m_nview == null || !m_nview.IsValid()) return null; + + Vector3 anchor = m_nview.GetZDO().GetVec3(KeyAnchor, Vector3.zero); + return anchor == Vector3.zero ? (Vector3?)null : anchor; + } + } + + public bool IsBoundTo(Vector3 anchor) + { + Vector3? own = Anchor; + return own != null && Vector3.SqrMagnitude(own.Value - anchor) < 0.25f; + } + + /// The one line the table's hover shows. Read from the ZDO so a client that does not + /// own the servant still sees what it is doing. + public string Status + { + get + { + if (m_nview == null || !m_nview.IsValid()) return m_status; + return m_nview.GetZDO().GetString(KeyStatus, m_status); + } + } + + private void SetStatus(string text) + { + if (text == m_status) return; + + m_status = text; + if (m_nview != null && m_nview.IsValid() && m_nview.IsOwner()) + { + m_nview.GetZDO().Set(KeyStatus, text); + } + } + + /// Hit by something: stop working and walk home. It never fights back - there is + /// nothing in this class that could. + public void NoteDamage() + { + m_fleeUntil = Time.time + FleeSeconds; + m_job = null; + } + + // ================================================================ the tick + + /// Everything. Returns what MonsterAI.UpdateAI would have returned. + public bool Tick(float dt) + { + if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return false; + if (m_character == null || m_character.IsDead()) return false; + + if (TickWither()) return true; + + if (Time.time < m_fleeUntil) + { + SetStatus("Driven off."); + GoHome(dt); + return true; + } + + if (Time.time >= m_nextPlan) + { + m_nextPlan = Time.time + PlanInterval; + Plan(); + } + + Execute(dt); + return true; + } + + /// + /// The table is gone: start the clock, and stop when it runs out. Same shape as RaisedThrall's, + /// and deliberately only asked near home - further out the table's zone is simply not loaded, so + /// "nothing there" would be a lie. + /// + private bool TickWither() + { + Vector3? anchor = Anchor; + if (anchor == null || ZNet.instance == null) return false; + + long stamp = m_nview.GetZDO().GetLong(KeyOrphanAt, 0L); + + if (stamp == 0L) + { + if (Vector3.SqrMagnitude(transform.position - anchor.Value) > + HomeCheckRange * HomeCheckRange) return false; + if (RaisedThrall.StationStandsAt(anchor.Value)) return false; + + m_nview.GetZDO().Set(KeyOrphanAt, ZNet.instance.GetTime().Ticks); + return false; + } + + if (RaisedThrall.StationStandsAt(anchor.Value)) + { + m_nview.GetZDO().Set(KeyOrphanAt, 0L); + return false; + } + + double elapsed = (ZNet.instance.GetTime() - new System.DateTime(stamp)).TotalSeconds; + if (elapsed < WitherSeconds) return false; + + HitData hit = new HitData(); + hit.m_damage.m_damage = 1E+10f; + hit.m_hitType = HitData.HitType.Undefined; + m_character.ApplyDamage(hit, true, false); + return true; + } + + // ================================================================ planning + + private void Plan() + { + Vector3? anchor = Anchor; + if (anchor == null) { m_job = null; return; } + + Scan(anchor.Value); + ExpirePenalties(); + + if (m_payload.Count > 0) { m_job = PlanDelivery(anchor.Value); return; } + + // The forge has no clock: a smelter holds its ore indefinitely and puts its own output on + // the floor, so PlanRescue would ask a question whose answer is always no. The smith is a + // four-state machine and the cook is a five-state one, and that is the whole of the + // simplification the split bought. + Job job = m_family == ButlerFamily.Kitchen ? PlanRescue() : null; + job = job ?? PlanCollect() ?? PlanLoad() ?? PlanFuel(); + + if (job != null && (m_job == null || m_job.Kind != job.Kind || m_job.Target != job.Target)) + { + m_jobDeadline = Time.time + JobTimeout; + } + m_job = job; + } + + /// + /// Everything within the radius, once every planning tick. Piece.s_allPieces is the cheap way in + /// - it is the list the game already keeps of every built piece - so there is no OverlapSphere + /// and no guessing at layer masks for the part that runs constantly. + /// + private void Scan(Vector3 anchor) + { + if (Time.time - m_scannedAt < PlanInterval * 0.5f) return; + m_scannedAt = Time.time; + + m_stations.Clear(); + m_chests.Clear(); + + List pieces = AllPiecesField != null ? AllPiecesField.GetValue(null) as List : null; + if (pieces == null) return; + + float radius = ButlerConfig.WorkRadius.Value; + float radiusSq = radius * radius; + + for (int i = 0; i < pieces.Count; i++) + { + Piece piece = pieces[i]; + if (piece == null) continue; + if (Vector3.SqrMagnitude(piece.transform.position - anchor) > radiusSq) continue; + + // A station of the other trade is not this servant's business, but it is still not a + // chest - hence the continue either way. + ButlerStation station = ButlerStation.From(piece.gameObject); + if (station != null) + { + if (station.Family == m_family) m_stations.Add(station); + continue; + } + + Container container = piece.GetComponent(); + if (container != null && IsSealed(container)) m_chests.Add(container); + } + } + + /// A chest is the servant's only if it holds the sigil. The sigil itself is never + /// counted as material and never carried away - see TakeFrom. + private static bool IsSealed(Container container) + { + if (container == null || container.IsInUse()) return false; + + Inventory inventory = container.GetInventory(); + if (inventory == null) return false; + + string sigil = SigilSharedName(); + if (string.IsNullOrEmpty(sigil)) return false; + + return inventory.CountItems(sigil) > 0; + } + + private static string s_sigilShared; + private static string s_sigilFor; + + /// Inventory.CountItems matches on the SHARED name ($item_...), not on the prefab name + /// the stations use, so the configured prefab is resolved once into the other kind of name. + private static string SigilSharedName() + { + string wanted = ButlerConfig.SigilItem.Value; + if (s_sigilFor == wanted) return s_sigilShared; + + s_sigilFor = wanted; + s_sigilShared = null; + + GameObject prefab = ObjectDB.instance != null ? ObjectDB.instance.GetItemPrefab(wanted) : null; + ItemDrop drop = prefab != null ? prefab.GetComponent() : null; + if (drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null) + { + s_sigilShared = drop.m_itemData.m_shared.m_name; + } + else + { + Jotunn.Logger.LogWarning($"[Butler] No item '{wanted}' to use as the sigil; " + + "no chest can be marked until that name is right."); + } + + return s_sigilShared; + } + + // ---------------------------------------------------------------- the five states + + /// 1. SAVE. A slot about to burn beats everything, and it is the only job it runs to. + private Job PlanRescue() + { + ButlerStation best = null; + float soonest = SpoilPanicSeconds; + + foreach (ButlerStation station in m_stations) + { + if (!station.Alive || IsPenalised(station.Id)) continue; + if (!station.HasOutput) continue; // nothing pullable yet, panic changes nothing + + float left = station.SecondsToSpoil; + if (left >= soonest) continue; + + soonest = left; + best = station; + } + + if (best == null) return null; + + return new Job + { + Kind = "collect", + Target = best.Id, + Point = best.Position, + Hurry = true, + Label = "Saving the food", + }; + } + + /// 2. COLLECT. Anything finished, and anything already lying under a station. + private Job PlanCollect() + { + ButlerStation best = null; + float bestScore = float.MaxValue; + + foreach (ButlerStation station in m_stations) + { + if (!station.Alive || IsPenalised(station.Id)) continue; + if (!station.HasOutput && !HasDropsNear(station.Position)) continue; + + float score = Vector3.Distance(transform.position, station.Position); + if (score >= bestScore) continue; + + bestScore = score; + best = station; + } + + if (best == null) return null; + + return new Job + { + Kind = "collect", + Target = best.Id, + Point = best.Position, + Label = "Collecting", + }; + } + + /// + /// 3. LOAD. Urgency, then distance - and the urgency of a station with nothing wrong with it is + /// how long it has been waiting. A metre of walking is worth four seconds of a station standing + /// idle, so the far furnace wins eventually instead of never. + /// + private Job PlanLoad() + { + ButlerStation best = null; + string bestItem = null; + Container bestChest = null; + float bestScore = float.MaxValue; + + foreach (ButlerStation station in m_stations) + { + if (!station.Alive || IsPenalised(station.Id)) continue; + if (!station.Operable || station.FreeSlots <= 0) continue; + + Container chest; + string item = FindMaterialFor(station, out chest); + if (item == null) { m_idleSince.Remove(station.Id); continue; } + + float waited = NoteIdle(station.Id); + float score = Vector3.Distance(transform.position, chest.transform.position) + + Vector3.Distance(chest.transform.position, station.Position) - + waited * WaitToMetres; + + if (score >= bestScore) continue; + + bestScore = score; + best = station; + bestItem = item; + bestChest = chest; + } + + if (best == null) return null; + + // The chest first - the station is where the payload goes afterwards, and PlanDelivery + // works that out from the target written on the load. + return new Job + { + Kind = "load", + Target = ZdoOf(bestChest), + Point = bestChest.transform.position, + Label = "Fetching " + bestItem, + }; + } + + /// 4. REFUEL. Only stations that actually have something to work on. + private Job PlanFuel() + { + foreach (ButlerStation station in m_stations) + { + if (!station.Alive || IsPenalised(station.Id)) continue; + if (!station.Operable) continue; + + int wanted = station.FuelWanted; + if (wanted <= 0) continue; + + string fuel = station.FuelPrefab; + if (string.IsNullOrEmpty(fuel)) continue; + + Container chest = FindChestWith(fuel); + if (chest == null) continue; + + return new Job + { + Kind = "fuel", + Target = ZdoOf(chest), + Point = chest.transform.position, + Label = "Fetching " + fuel, + }; + } + + return null; + } + + /// Where the load in hand is going: on to its station, or back into a chest. + private Job PlanDelivery(Vector3 anchor) + { + ZDOID target = m_nview.GetZDO().GetZDOID(KeyTarget); + if (target != ZDOID.None) + { + // NO FreeSlots CHECK HERE, and that was the first bug found in play: fuel does not go + // into a slot. A furnace filled to m_maxOre with copper has FreeSlots 0 and still wants + // coal, so gating the delivery on free slots sent the servant back to the chest with + // the coal it had just fetched - and then PlanFuel sent it out for the same coal again, + // forever. AcceptsAnything already asks the right question of both doors. + ButlerStation station = StationById(target); + if (station != null && station.Alive && station.Operable && AcceptsAnything(station)) + { + return new Job + { + Kind = "deposit_station", + Target = target, + Point = station.Position, + Label = "Loading " + Describe(), + }; + } + + // The station is gone, full or cold. The goods are ours to put back, not to hold. + m_nview.GetZDO().Set(KeyTarget, ZDOID.None); + } + + Container chest = ChestForProduct(); + if (chest != null) + { + return new Job + { + Kind = "deposit", + Target = ZdoOf(chest), + Point = chest.transform.position, + Label = "Storing " + Describe(), + }; + } + + // Every sealed chest is full. Beside the table it goes: a stalled chain is worse than a + // tidy floor, and nothing may vanish (sec. 7.3). + return new Job + { + Kind = "drop", + Target = ZDOID.None, + Point = anchor, + Label = "Nowhere to put " + Describe(), + }; + } + + // ================================================================ execution + + private void Execute(float dt) + { + if (m_job == null) + { + SetStatus(m_stations.Count == 0 ? "Nothing to serve." : "Nothing to do."); + GoHome(dt); + return; + } + + SetStatus(m_job.Label); + + if (!MoveToPoint(dt, m_job.Point, ArriveDistance, m_job.Hurry)) + { + // Doors do not open for pathfinding. A target it cannot reach goes into the penalty box + // and the servant gets on with something it can do. + if (Time.time > m_jobDeadline) + { + Penalise(m_job.Target); + Jotunn.Logger.LogInfo($"[Butler] Could not reach {m_job.Kind} target; " + + "setting it aside for a few minutes."); + m_job = null; + m_nextPlan = 0f; + } + return; + } + + bool achieved; + switch (m_job.Kind) + { + case "load": achieved = DoLoad(); break; + case "fuel": achieved = DoFuel(); break; + case "collect": achieved = DoCollect(); break; + case "deposit_station": achieved = DoDepositStation(); break; + case "deposit": achieved = DoDeposit(); break; + case "drop": DropPayload(); achieved = true; break; + default: achieved = true; break; + } + + // Arrived and nothing happened: the world moved while it walked. Set that target aside for + // twenty seconds so the next plan picks something else instead of re-deciding the same + // errand on every tick. + if (!achieved) PenaliseShort(m_job.Target); + + m_job = null; + m_nextPlan = 0f; // arriving changes the world; re-plan on the next tick rather than in 1.5 s + } + + /// At the chest: take what the chosen station will eat, and remember where it came from. + private bool DoLoad() + { + Container chest = ContainerById(m_job.Target); + if (chest == null) return false; + + // The station is chosen again here rather than carried on the job, because the walk took + // time and the world may have moved on. + ButlerStation station = null; + string item = null; + + foreach (ButlerStation candidate in m_stations) + { + if (!candidate.Alive || !candidate.Operable || candidate.FreeSlots <= 0) continue; + if (IsPenalised(candidate.Id)) continue; + + string found = FirstAccepted(candidate, chest); + if (found == null) continue; + + station = candidate; + item = found; + break; + } + + if (station == null || item == null) return false; + + int taken = TakeFrom(chest, item, station.FreeSlots); + if (taken <= 0) return false; + + AddToPayload(item, taken); + m_nview.GetZDO().Set(KeySource, ZdoOf(chest)); + m_nview.GetZDO().Set(KeyTarget, station.Id); + WritePayload(); + return true; + } + + /// At the chest, for fuel. Same shape as DoLoad, and kept separate because fuel goes in + /// through a different door and is never the thing being processed. + private bool DoFuel() + { + Container chest = ContainerById(m_job.Target); + if (chest == null) return false; + + foreach (ButlerStation station in m_stations) + { + if (!station.Alive || !station.Operable || IsPenalised(station.Id)) continue; + + int wanted = station.FuelWanted; + string fuel = station.FuelPrefab; + if (wanted <= 0 || string.IsNullOrEmpty(fuel)) continue; + + int taken = TakeFrom(chest, fuel, wanted); + if (taken <= 0) continue; + + AddToPayload(fuel, taken); + m_nview.GetZDO().Set(KeySource, ZdoOf(chest)); + m_nview.GetZDO().Set(KeyTarget, station.Id); + WritePayload(); + return true; + } + + return false; + } + + /// + /// At a station with something finished. Pull first, sweep second - and the sweep is the only + /// place the servant ever picks anything up off the ground, which is what keeps it from tidying + /// away things the player left lying about on purpose. + /// + private bool DoCollect() + { + ButlerStation station = StationById(m_job.Target); + if (station == null || !station.Alive) return false; + + int before = PayloadCount(); + SweepDrops(station.Position); + bool swept = PayloadCount() > before; + + bool pulled = false; + if (station.HasOutput) + { + station.PullOutput(transform.position); + pulled = true; + } + + if (swept) + { + // The product belongs to whoever fed the station. If nothing was written there - the + // player loaded it by hand - it goes to the nearest sealed chest instead, which is the + // "yes, it collects your work too" decision paying its own way. + ZDOID fedBy = station.Nview.GetZDO().GetZDOID(KeyFedBy); + m_nview.GetZDO().Set(KeySource, fedBy); + m_nview.GetZDO().Set(KeyTarget, ZDOID.None); + WritePayload(); + } + + return swept || pulled; + } + + /// At the station, with raw material in hand. + private bool DoDepositStation() + { + ButlerStation station = StationById(m_job.Target); + if (station == null || !station.Alive || !station.Operable) return false; + + bool loadedAny = false; + + for (int i = m_payload.Count - 1; i >= 0; i--) + { + Load load = m_payload[i]; + + while (load.Count > 0 && station.FreeSlots > 0 && station.Accepts(load.Name)) + { + station.Add(load.Name); + load.Count--; + loadedAny = true; + } + + // Fuel goes in through its own door, and only for as long as it is wanted. + if (load.Count > 0 && load.Name == station.FuelPrefab) + { + int wanted = station.FuelWanted; + while (load.Count > 0 && wanted > 0) + { + station.AddFuel(); + load.Count--; + wanted--; + loadedAny = true; + } + } + + if (load.Count <= 0) m_payload.RemoveAt(i); + } + + if (loadedAny) + { + // Whoever fed it, gets it back. + ZDOID source = m_nview.GetZDO().GetZDOID(KeySource); + if (source != ZDOID.None && station.Nview.IsValid()) + { + if (!station.Nview.IsOwner()) station.Nview.ClaimOwnership(); + station.Nview.GetZDO().Set(KeyFedBy, source); + } + } + + if (m_payload.Count == 0) m_nview.GetZDO().Set(KeyTarget, ZDOID.None); + WritePayload(); + return loadedAny; + } + + /// At a chest, with the finished goods. + private bool DoDeposit() + { + Container chest = ContainerById(m_job.Target); + if (chest == null) return false; + + ZNetView nview = chest.GetComponent(); + if (nview == null || !nview.IsValid()) return false; + if (!nview.IsOwner()) nview.ClaimOwnership(); + + Inventory inventory = chest.GetInventory(); + if (inventory == null) return false; + + bool wrote = false; + + for (int i = m_payload.Count - 1; i >= 0; i--) + { + Load load = m_payload[i]; + + GameObject prefab = ObjectDB.instance != null + ? ObjectDB.instance.GetItemPrefab(load.Name) + : null; + if (prefab == null) continue; + + // One at a time: it stacks correctly, it stops exactly when the chest is full, and the + // counts are small enough that being tidy costs nothing. + while (load.Count > 0 && inventory.CanAddItem(prefab, 1) && inventory.AddItem(prefab, 1)) + { + load.Count--; + wrote = true; + } + + if (load.Count <= 0) m_payload.RemoveAt(i); + } + + if (wrote && ContainerSaveMethod != null) ContainerSaveMethod.Invoke(chest, null); + WritePayload(); + + // Still holding something: that chest is full, so do not choose it again on the next pass. + if (m_payload.Count > 0) Penalise(m_job.Target); + return wrote; + } + + // ================================================================ moving + + /// Vanilla pathing, through the private MoveTo. True the moment it has arrived. + private bool MoveToPoint(float dt, Vector3 point, float distance, bool run) + { + if (m_ai == null || MoveToMethod == null) return true; // cannot walk: act in place + + m_moveArgs[0] = dt; + m_moveArgs[1] = point; + m_moveArgs[2] = distance; + m_moveArgs[3] = run; + + return (bool)MoveToMethod.Invoke(m_ai, m_moveArgs); + } + + private void GoHome(float dt) + { + Vector3? anchor = Anchor; + if (anchor == null) + { + if (m_ai != null) m_ai.StopMoving(); + return; + } + + MoveToPoint(dt, anchor.Value, 2.5f, false); + } + + // ================================================================ the ground + + private static int ItemMask() + { + if (s_itemMask >= 0) return s_itemMask; + + int mask = LayerMask.GetMask("item"); + s_itemMask = mask != 0 ? mask : ~0; + return s_itemMask; + } + + private bool HasDropsNear(Vector3 point) + { + Collider[] hits = Physics.OverlapSphere(point, CollectRadius, ItemMask()); + foreach (Collider hit in hits) + { + if (hit == null) continue; + ItemDrop drop = hit.GetComponentInParent(); + if (drop != null && drop.m_itemData != null) return true; + } + return false; + } + + /// + /// Picks up everything lying around a station. The drop is destroyed and its contents become + /// entries in the virtual payload, which is the same road the smelter's bars, the oven's bread + /// and the fermenter's bottles all arrive by - one pickup routine for three families. + /// + private void SweepDrops(Vector3 point) + { + Collider[] hits = Physics.OverlapSphere(point, CollectRadius, ItemMask()); + + foreach (Collider hit in hits) + { + if (hit == null) continue; + if (PayloadCount() >= PayloadCap) return; + + ItemDrop drop = hit.GetComponentInParent(); + if (drop == null || drop.m_itemData == null) continue; + + ZNetView nview = drop.GetComponent(); + if (nview == null || !nview.IsValid()) continue; + if (!nview.IsOwner()) nview.ClaimOwnership(); + + string name = drop.m_itemData.m_dropPrefab != null + ? drop.m_itemData.m_dropPrefab.name + : Utils.GetPrefabName(drop.gameObject); + if (string.IsNullOrEmpty(name)) continue; + + AddToPayload(name, Mathf.Max(1, drop.m_itemData.m_stack)); + if (ZNetScene.instance != null) ZNetScene.instance.Destroy(drop.gameObject); + } + } + + /// + /// Puts the virtual load back into the world as real objects. Called when the servant dies and + /// when there is nowhere left to put anything - the two ends of the same promise, which is that + /// nothing the player owns is ever deleted by this feature. + /// + public void DropPayload() + { + if (m_payload.Count == 0) return; + if (ObjectDB.instance == null) { m_payload.Clear(); return; } + + Vector3 at = transform.position + Vector3.up * 0.4f; + + foreach (Load load in m_payload) + { + GameObject prefab = ObjectDB.instance.GetItemPrefab(load.Name); + ItemDrop template = prefab != null ? prefab.GetComponent() : null; + if (template == null || template.m_itemData == null) continue; + + int left = load.Count; + int max = Mathf.Max(1, template.m_itemData.m_shared.m_maxStackSize); + + while (left > 0) + { + int stack = Mathf.Min(left, max); + ItemDrop.DropItem(template.m_itemData.Clone(), stack, + at + Random.insideUnitSphere * 0.3f, Quaternion.identity); + left -= stack; + } + } + + m_payload.Clear(); + WritePayload(); + } + + // ================================================================ chests + + /// + /// Takes up to of a prefab out of a chest. The sigil is skipped by name, + /// which is the one thing in here that must never be got wrong: carrying it off would unmark the + /// chest halfway through a job. + /// + private int TakeFrom(Container chest, string prefabName, int want) + { + if (chest == null || want <= 0) return 0; + if (prefabName == ButlerConfig.SigilItem.Value) return 0; + + ZNetView nview = chest.GetComponent(); + if (nview == null || !nview.IsValid()) return 0; + if (!nview.IsOwner()) nview.ClaimOwnership(); + + Inventory inventory = chest.GetInventory(); + if (inventory == null) return 0; + + List matches = new List(); + foreach (ItemDrop.ItemData item in inventory.GetAllItems()) + { + if (item == null || item.m_dropPrefab == null) continue; + if (item.m_dropPrefab.name != prefabName) continue; + matches.Add(item); + } + + int taken = 0; + foreach (ItemDrop.ItemData item in matches) + { + if (taken >= want) break; + + int amount = Mathf.Min(item.m_stack, want - taken); + if (amount <= 0) continue; + + inventory.RemoveItem(item, amount); + taken += amount; + } + + if (taken > 0 && ContainerSaveMethod != null) ContainerSaveMethod.Invoke(chest, null); + return taken; + } + + /// The first thing in any sealed chest that this station will take. + private string FindMaterialFor(ButlerStation station, out Container chest) + { + foreach (Container candidate in m_chests) + { + if (candidate == null || candidate.IsInUse()) continue; + + string item = FirstAccepted(station, candidate); + if (item == null) continue; + + chest = candidate; + return item; + } + + chest = null; + return null; + } + + private string FirstAccepted(ButlerStation station, Container chest) + { + Inventory inventory = chest != null ? chest.GetInventory() : null; + if (inventory == null) return null; + + string sigil = ButlerConfig.SigilItem.Value; + string fuel = station.FuelPrefab; + + foreach (ItemDrop.ItemData item in inventory.GetAllItems()) + { + if (item == null || item.m_dropPrefab == null) continue; + + string name = item.m_dropPrefab.name; + if (name == sigil) continue; + if (name == fuel) continue; // fuel has its own errand + if (!station.Accepts(name)) continue; + + return name; + } + + return null; + } + + private Container FindChestWith(string prefabName) + { + foreach (Container chest in m_chests) + { + if (chest == null || chest.IsInUse()) continue; + + Inventory inventory = chest.GetInventory(); + if (inventory == null) continue; + + foreach (ItemDrop.ItemData item in inventory.GetAllItems()) + { + if (item != null && item.m_dropPrefab != null && item.m_dropPrefab.name == prefabName) + { + return chest; + } + } + } + + return null; + } + + /// Where the finished goods go: the chest that fed the station, or the nearest sealed + /// one with room if that chest is gone, full, or never existed. + private Container ChestForProduct() + { + ZDOID source = m_nview.GetZDO().GetZDOID(KeySource); + + Container home = ContainerById(source); + if (home != null && !IsPenalised(source) && HasRoomFor(home)) return home; + + Container best = null; + float bestDistance = float.MaxValue; + + foreach (Container chest in m_chests) + { + if (chest == null || chest.IsInUse()) continue; + if (IsPenalised(ZdoOf(chest))) continue; + if (!HasRoomFor(chest)) continue; + + float distance = Vector3.Distance(transform.position, chest.transform.position); + if (distance >= bestDistance) continue; + + bestDistance = distance; + best = chest; + } + + return best; + } + + private bool HasRoomFor(Container chest) + { + Inventory inventory = chest != null ? chest.GetInventory() : null; + if (inventory == null || ObjectDB.instance == null) return false; + + foreach (Load load in m_payload) + { + GameObject prefab = ObjectDB.instance.GetItemPrefab(load.Name); + if (prefab != null && inventory.CanAddItem(prefab, 1)) return true; + } + + return false; + } + + // ================================================================ payload + + private bool AcceptsAnything(ButlerStation station) + { + foreach (Load load in m_payload) + { + if (station.Accepts(load.Name)) return true; + if (load.Name == station.FuelPrefab && station.FuelWanted > 0) return true; + } + return false; + } + + private void AddToPayload(string name, int count) + { + if (string.IsNullOrEmpty(name) || count <= 0) return; + + foreach (Load load in m_payload) + { + if (load.Name != name) continue; + load.Count += count; + WritePayload(); + return; + } + + m_payload.Add(new Load { Name = name, Count = count }); + WritePayload(); + } + + private int PayloadCount() + { + int total = 0; + foreach (Load load in m_payload) total += load.Count; + return total; + } + + private string Describe() + { + if (m_payload.Count == 0) return "nothing"; + if (m_payload.Count == 1) return m_payload[0].Count + "x " + m_payload[0].Name; + + return PayloadCount() + " items"; + } + + /// "Copper:8;Coal:12". Small, readable in a ZDO dump, and enough to survive a handover + /// mid-job - which is the whole reason the payload lives in the ZDO instead of in this class. + private void WritePayload() + { + if (m_nview == null || !m_nview.IsValid()) return; + + StringBuilder builder = new StringBuilder(); + foreach (Load load in m_payload) + { + if (load.Count <= 0) continue; + if (builder.Length > 0) builder.Append(';'); + builder.Append(load.Name).Append(':').Append(load.Count); + } + + m_nview.GetZDO().Set(KeyLoad, builder.ToString()); + } + + private void ReadPayload() + { + m_payload.Clear(); + if (m_nview == null || !m_nview.IsValid()) return; + + string raw = m_nview.GetZDO().GetString(KeyLoad, ""); + if (string.IsNullOrEmpty(raw)) return; + + foreach (string entry in raw.Split(';')) + { + if (string.IsNullOrEmpty(entry)) continue; + + int split = entry.LastIndexOf(':'); + if (split <= 0) continue; + + int count; + if (!int.TryParse(entry.Substring(split + 1), out count) || count <= 0) continue; + + m_payload.Add(new Load { Name = entry.Substring(0, split), Count = count }); + } + } + + // ================================================================ small change + + private static ZDOID ZdoOf(Component component) + { + ZNetView nview = component != null ? component.GetComponent() : null; + return nview != null && nview.IsValid() ? nview.GetZDO().m_uid : ZDOID.None; + } + + private Container ContainerById(ZDOID id) + { + if (id == ZDOID.None || ZNetScene.instance == null) return null; + + GameObject go = ZNetScene.instance.FindInstance(id); + return go != null ? go.GetComponent() : null; + } + + private ButlerStation StationById(ZDOID id) + { + foreach (ButlerStation station in m_stations) + { + if (station.Id == id) return station; + } + + if (id == ZDOID.None || ZNetScene.instance == null) return null; + + GameObject go = ZNetScene.instance.FindInstance(id); + return go != null ? ButlerStation.From(go) : null; + } + + private void Penalise(ZDOID id) + { + if (id == ZDOID.None) return; + m_penalties[id] = Time.time + PenaltySeconds; + } + + /// Never shortens a penalty already running: a target set aside for three minutes + /// because it could not be reached must not be let back in after twenty seconds. + private void PenaliseShort(ZDOID id) + { + if (id == ZDOID.None) return; + + float until; + float wanted = Time.time + ShortPenaltySeconds; + if (m_penalties.TryGetValue(id, out until) && until > wanted) return; + + m_penalties[id] = wanted; + } + + private bool IsPenalised(ZDOID id) + { + float until; + return m_penalties.TryGetValue(id, out until) && Time.time < until; + } + + private void ExpirePenalties() + { + if (m_penalties.Count == 0) return; + + List done = null; + foreach (KeyValuePair entry in m_penalties) + { + if (Time.time < entry.Value) continue; + if (done == null) done = new List(); + done.Add(entry.Key); + } + + if (done == null) return; + foreach (ZDOID id in done) m_penalties.Remove(id); + } + + /// Seconds this station has been waiting with work available. + private float NoteIdle(ZDOID id) + { + float since; + if (!m_idleSince.TryGetValue(id, out since)) + { + m_idleSince[id] = Time.time; + return 0f; + } + + return Time.time - since; + } + } + + /// + /// The whole of the servant's mind, in one prefix. + /// + /// Returning false skips MonsterAI.UpdateAI entirely - targeting, alerting, fleeing, wandering and + /// attacking with it - so the servant is peaceful by construction rather than by having its weapon + /// confiscated. __result is legitimate here and not the old PlacePiece trap: that one threw because + /// the patched method was VOID. This one returns bool, which is exactly what a prefix may write. + /// + /// Bound positionally (__0) so a parameter rename in a future patch cannot stop the mod from + /// applying its patches at startup. + /// + [HarmonyPatch(typeof(MonsterAI), "UpdateAI")] + public static class BoneServantUpdateAIPatch + { + public static bool Prefix(MonsterAI __instance, float __0, ref bool __result) + { + if (__instance == null) return true; + + BoneServantAI servant = __instance.GetComponent(); + if (servant == null) return true; + + __result = servant.Tick(__0); + return false; + } + } + + /// Hit and it walks home. The same postfix shape the sentry's regeneration uses, on the + /// same method, which is a shape known to work in this project. + [HarmonyPatch(typeof(Character), "Damage")] + public static class BoneServantDamagePatch + { + public static void Postfix(Character __instance) + { + if (__instance == null) return; + + BoneServantAI servant = __instance.GetComponent(); + if (servant != null) servant.NoteDamage(); + } + } +} diff --git a/JotunnModStub/Butler/ButlerConfig.cs b/JotunnModStub/Butler/ButlerConfig.cs new file mode 100644 index 0000000..c7ac2f6 --- /dev/null +++ b/JotunnModStub/Butler/ButlerConfig.cs @@ -0,0 +1,50 @@ +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// The four knobs the Bone Servant exposes, and deliberately only four. + /// + /// Butler_BoneServant.txt sec. 14 turned down "expose everything": tick cadence, safety margins, + /// penalty-box time and the spacing between tables are constants in the code, because they are + /// numbers that get tuned once during the test and then never again - and every config entry is + /// maintained forever. + /// + /// The sigil is here for a different reason from the other three. It is a PLACEHOLDER: bone + /// fragments stand in for a craftable sigil that only gets made if the feature leaves the test, + /// and being able to move the mark onto another item without a rebuild is the whole point of the + /// entry. + /// + public static class ButlerConfig + { + public static ConfigEntry SigilItem; + public static ConfigEntry WorkRadius; + public static ConfigEntry FuelThreshold; + public static ConfigEntry ResummonSeconds; + + public static void Bind(ConfigFile config) + { + const string section = "Butler - Bone Servant"; + + SigilItem = config.Bind(section, "Sigil Item", "BoneFragments", + new ConfigDescription("Prefab name of the item that marks a chest as the servant's. " + + "A chest holding at least one of these is worked from and " + + "delivered to; every other chest is left alone. The sigil itself " + + "is never taken and never processed.")); + + WorkRadius = config.Bind(section, "Work Radius", 20f, + new ConfigDescription("Metres from the Servant's Table within which chests and stations " + + "are served.", new AcceptableValueRange(5f, 40f))); + + FuelThreshold = config.Bind(section, "Fuel Threshold", 0.25f, + new ConfigDescription("Refuel a station when its fuel drops below this fraction of its " + + "maximum, and only while it has something to work on.", + new AcceptableValueRange(0f, 1f))); + + ResummonSeconds = config.Bind(section, "Resummon Cooldown", 0f, + new ConfigDescription("Seconds that must pass before a fallen servant can be raised " + + "again. Zero is free and immediate, which is what the test runs on.", + new AcceptableValueRange(0f, 600f))); + } + } +} diff --git a/JotunnModStub/Butler/ButlerStation.cs b/JotunnModStub/Butler/ButlerStation.cs new file mode 100644 index 0000000..2b47de5 --- /dev/null +++ b/JotunnModStub/Butler/ButlerStation.cs @@ -0,0 +1,496 @@ +using System; +using System.Reflection; +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Which servant a station belongs to. + /// + /// The split is not cosmetic, it is the answer to the one complaint the first working version drew: + /// with a kitchen at one edge of the circle and three furnaces at the other, a single servant spends + /// its life walking and the margin that keeps food off the fire gets eaten by travel. Two servants + /// with two tables in the same yard walk half as far each. + /// + /// It also cuts the AI in half along a seam that was already there. FORGE cannot spoil - a smelter + /// holds its ore forever and drops its own output - so the forge servant has no clock, never runs, + /// and never pre-empts itself. All of that machinery lives on in the KITCHEN, which is the only + /// place it was ever needed. + /// + public enum ButlerFamily + { + /// Smelter: furnace, blast furnace, charcoal kiln, windmill, spinning wheel, eitr + /// refinery. Nothing here has a deadline. + Forge, + + /// CookingStation and Fermenter: hearths, ovens and mead. The only family with a + /// clock. + Kitchen, + } + + /// + /// One working station, seen through the handful of questions the servant ever asks it. + /// + /// THREE FAMILIES, and they are not variations on a theme - they behave OPPOSITELY on output, which + /// is the single fact the whole feature is built around (Butler_BoneServant.txt sec. 5, all of it + /// read off assembly_valheim.dll with Cecil rather than guessed): + /// + /// Smelter furnace, blast furnace, charcoal kiln, windmill, spinning wheel, eitr + /// refinery. Its output FALLS ON THE GROUND BY ITSELF - UpdateSmelter runs + /// RemoveOneOre -> QueueProcessed -> SpawnProcessed with nobody asking. Nothing + /// to pull; the servant just picks the bars up. + /// CookingStation hearth, iron cooking station, stone oven. Output STAYS IN THE SLOT and keeps + /// cooking: Done at m_cookTime, Burnt at exactly twice it (verified: the IL + /// literally loads m_cookTime, pushes 2 and multiplies). This is the family that + /// can lose you food, and the only one with a clock. + /// Fermenter mead. Output stays in until the tap is opened, and never spoils. + /// + /// NOTHING HERE KNOWS WHAT A MATERIAL IS. Every family exposes IsItemAllowed(string) and + /// GetItemConversion(string), matching on the PREFAB name (m_from.gameObject.name - verified), so + /// the servant asks the station "do you take this?" instead of carrying a list of ores and crops. + /// That is what makes it serve this mod's own stations, other races' stations, and other mods' + /// stations without a line of code per station. + /// + /// WHY SO MUCH REFLECTION. Every one of those question methods is PRIVATE in this build - + /// GetQueueSize, IsItemAllowed, GetSlot, GetFuel, HaveDoneItem, IsFireLit, GetStatus, the lot - and + /// both Status enums are private nested types, so they cannot even be named in source. The + /// alternative was reimplementing each station's rules by reading its public m_conversion list, + /// which would be a second copy of vanilla's logic drifting out of step at the next patch. Calling + /// the real method through a cached MethodInfo is the smaller lie. The enum values are hard-coded + /// as ints, and they are not guesses: Cecil reports NotDone=0, Done=1, Burnt=2 and Empty=0, + /// Fermenting=1, Exposed=2, Ready=3. + /// + /// Every write goes through InvokeRPC with the name the station REGISTERED, which carries the + /// "RPC_" prefix in this build - "RPC_AddOre", not "AddOre". A wrong name here is a silent no-op, + /// which is exactly the class of bug that takes an evening to find, so the four names below were + /// read out of each Awake() rather than remembered. + /// + public abstract class ButlerStation + { + public Component Behaviour; + public ZNetView Nview; + public Transform Transform; + + public Vector3 Position { get { return Transform.position; } } + + public ZDOID Id + { + get { return Nview != null && Nview.IsValid() ? Nview.GetZDO().m_uid : ZDOID.None; } + } + + public bool Alive { get { return Behaviour != null && Nview != null && Nview.IsValid(); } } + + /// Wraps whichever of the three this object is, or null if it is not a station. + public static ButlerStation From(GameObject go) + { + if (go == null) return null; + + ZNetView nview = go.GetComponent(); + if (nview == null || !nview.IsValid()) return null; + + Smelter smelter = go.GetComponent(); + if (smelter != null) return Fill(new SmelterStation { m_smelter = smelter }, smelter, nview); + + CookingStation cooking = go.GetComponent(); + if (cooking != null) return Fill(new CookingStationStation { m_cooking = cooking }, cooking, nview); + + Fermenter fermenter = go.GetComponent(); + if (fermenter != null) return Fill(new FermenterStation { m_fermenter = fermenter }, fermenter, nview); + + return null; + } + + private static ButlerStation Fill(ButlerStation station, Component behaviour, ZNetView nview) + { + station.Behaviour = behaviour; + station.Nview = nview; + station.Transform = behaviour.transform; + return station; + } + + /// + /// Taking ownership before writing is the multiplayer rule of this feature (sec. 10), and it + /// buys a second thing that matters here: once we own the ZDO the RPC runs locally and + /// immediately, so GetQueueSize and GetFuel answer truthfully on the very next line instead of + /// a network round trip later. + /// + protected void Claim() + { + if (Nview != null && Nview.IsValid() && !Nview.IsOwner()) Nview.ClaimOwnership(); + } + + // ---------------------------------------------------------------- what the servant asks + + /// Which of the two servants this one belongs to. + public abstract ButlerFamily Family { get; } + + /// Can it work at all right now - fire lit, roof up? An inoperable station is skipped + /// in silence, which is a decision and not an oversight (sec. 7.7). + public abstract bool Operable { get; } + + /// How many more items it can take. Zero means full. + public abstract int FreeSlots { get; } + + public abstract bool Accepts(string prefabName); + + /// Puts one unit in. Called FreeSlots times at most, never more. + public abstract void Add(string prefabName); + + /// True while it has something to work on - so an empty furnace is never stoked. + public abstract bool HasWork { get; } + + public abstract string FuelPrefab { get; } + + /// Units of fuel it wants right now, already filtered by the configured threshold. + public abstract int FuelWanted { get; } + + public abstract void AddFuel(); + + /// Something finished and needs a hand to get out. Always false for the Smelter, which + /// throws its own output on the floor. + public abstract bool HasOutput { get; } + + /// Gets the finished goods onto the ground at , where the one + /// pickup routine will find them. + public abstract void PullOutput(Vector3 at); + + /// Seconds until something in here is ruined. float.MaxValue for the two families that + /// cannot spoil, which is what keeps the urgency comparison honest without special cases. + public virtual float SecondsToSpoil { get { return float.MaxValue; } } + + // ================================================================ the private doors + + /// + /// Every private member of the three station classes this feature touches, resolved once. + /// + /// Anything that fails to resolve stays null and its caller falls back to the safe answer - + /// "cannot tell, do not act" - so a future patch that renames one method costs that one + /// capability and a line in the log, not a servant that stands still or, worse, one that keeps + /// pouring ore into a station it can no longer read. + /// + private static class Vanilla + { + public static readonly MethodInfo SmelterQueueSize = AccessTools.Method(typeof(Smelter), "GetQueueSize"); + public static readonly MethodInfo SmelterAllowed = + AccessTools.Method(typeof(Smelter), "IsItemAllowed", new[] { typeof(string) }); + public static readonly MethodInfo SmelterFuel = AccessTools.Method(typeof(Smelter), "GetFuel"); + public static readonly FieldInfo SmelterHaveRoof = AccessTools.Field(typeof(Smelter), "m_haveRoof"); + + public static readonly MethodInfo CookGetSlot = AccessTools.Method(typeof(CookingStation), "GetSlot"); + public static readonly MethodInfo CookEmpty = AccessTools.Method(typeof(CookingStation), "IsEmpty"); + public static readonly MethodInfo CookHaveDone = AccessTools.Method(typeof(CookingStation), "HaveDoneItem"); + public static readonly MethodInfo CookAllowed = + AccessTools.Method(typeof(CookingStation), "IsItemAllowed", new[] { typeof(string) }); + public static readonly MethodInfo CookConversion = + AccessTools.Method(typeof(CookingStation), "GetItemConversion", new[] { typeof(string) }); + public static readonly MethodInfo CookFuel = AccessTools.Method(typeof(CookingStation), "GetFuel"); + public static readonly MethodInfo CookFireLit = AccessTools.Method(typeof(CookingStation), "IsFireLit"); + + public static readonly MethodInfo FermenterStatus = AccessTools.Method(typeof(Fermenter), "GetStatus"); + public static readonly MethodInfo FermenterAllowed = + AccessTools.Method(typeof(Fermenter), "IsItemAllowed", new[] { typeof(string) }); + + // CookingStation.Status and Fermenter.Status are private nested enums: they cannot be named + // in source, so they travel as ints. Values read from the assembly, not assumed. + public const int CookNotDone = 0; + public const int CookDone = 1; + public const int CookBurnt = 2; + + public const int FermentEmpty = 0; + public const int FermentExposed = 2; + public const int FermentReady = 3; + + public static bool Call(MethodInfo method, object target, bool fallback) + { + if (method == null) return fallback; + return (bool)method.Invoke(target, null); + } + + public static int CallInt(MethodInfo method, object target, int fallback) + { + if (method == null) return fallback; + return Convert.ToInt32(method.Invoke(target, null)); + } + + public static float CallFloat(MethodInfo method, object target, float fallback) + { + if (method == null) return fallback; + return Convert.ToSingle(method.Invoke(target, null)); + } + + public static bool Allowed(MethodInfo method, object target, string prefabName) + { + if (method == null || string.IsNullOrEmpty(prefabName)) return false; + return (bool)method.Invoke(target, new object[] { prefabName }); + } + } + + // ================================================================ Smelter + + private class SmelterStation : ButlerStation + { + public Smelter m_smelter; + + public override ButlerFamily Family { get { return ButlerFamily.Forge; } } + + public override bool Operable + { + get + { + if (!m_smelter.m_requiresRoof) return true; + if (Vanilla.SmelterHaveRoof == null) return true; // cannot tell: let it try + return (bool)Vanilla.SmelterHaveRoof.GetValue(m_smelter); + } + } + + private int Queued { get { return Vanilla.CallInt(Vanilla.SmelterQueueSize, m_smelter, int.MaxValue); } } + + public override int FreeSlots + { + get { return Mathf.Max(0, m_smelter.m_maxOre - Queued); } + } + + public override bool Accepts(string prefabName) + { + return Vanilla.Allowed(Vanilla.SmelterAllowed, m_smelter, prefabName); + } + + public override void Add(string prefabName) + { + Claim(); + Nview.InvokeRPC("RPC_AddOre", prefabName); + } + + public override bool HasWork { get { return Queued > 0; } } + + public override string FuelPrefab + { + get { return m_smelter.m_fuelItem != null ? m_smelter.m_fuelItem.gameObject.name : null; } + } + + public override int FuelWanted + { + get + { + if (m_smelter.m_fuelItem == null || m_smelter.m_maxFuel <= 0) return 0; + if (!HasWork) return 0; + + float fuel = Vanilla.CallFloat(Vanilla.SmelterFuel, m_smelter, float.MaxValue); + if (fuel >= m_smelter.m_maxFuel * ButlerConfig.FuelThreshold.Value) return 0; + + return Mathf.Max(0, Mathf.FloorToInt(m_smelter.m_maxFuel - fuel)); + } + } + + public override void AddFuel() + { + Claim(); + Nview.InvokeRPC("RPC_AddFuel"); + } + + // The whole point of this family: nothing to collect, it drops its own. + public override bool HasOutput { get { return false; } } + public override void PullOutput(Vector3 at) { } + } + + // ================================================================ CookingStation + + private class CookingStationStation : ButlerStation + { + public CookingStation m_cooking; + + public override ButlerFamily Family { get { return ButlerFamily.Kitchen; } } + + private int SlotCount + { + get { return m_cooking.m_slots != null ? m_cooking.m_slots.Length : 0; } + } + + /// GetSlot hands back three values through out parameters, one of which is a + /// private enum. Through reflection that means an args array and an int. + private bool ReadSlot(int index, out string name, out float cooked, out int status) + { + name = null; + cooked = 0f; + status = Vanilla.CookNotDone; + + if (Vanilla.CookGetSlot == null) return false; + + object[] args = new object[] { index, null, null, null }; + Vanilla.CookGetSlot.Invoke(m_cooking, args); + + name = args[1] as string; + cooked = Convert.ToSingle(args[2]); + status = Convert.ToInt32(args[3]); + return true; + } + + public override bool Operable + { + get { return !m_cooking.m_requireFire || Vanilla.Call(Vanilla.CookFireLit, m_cooking, false); } + } + + public override int FreeSlots + { + get + { + int free = 0; + for (int i = 0; i < SlotCount; i++) + { + string name; + float cooked; + int status; + if (!ReadSlot(i, out name, out cooked, out status)) return 0; + if (string.IsNullOrEmpty(name)) free++; + } + return free; + } + } + + public override bool Accepts(string prefabName) + { + return Vanilla.Allowed(Vanilla.CookAllowed, m_cooking, prefabName); + } + + public override void Add(string prefabName) + { + Claim(); + Nview.InvokeRPC("RPC_AddItem", prefabName); + } + + public override bool HasWork { get { return !Vanilla.Call(Vanilla.CookEmpty, m_cooking, true); } } + + public override string FuelPrefab + { + get + { + return m_cooking.m_useFuel && m_cooking.m_fuelItem != null + ? m_cooking.m_fuelItem.gameObject.name + : null; + } + } + + public override int FuelWanted + { + get + { + if (!m_cooking.m_useFuel || m_cooking.m_fuelItem == null || m_cooking.m_maxFuel <= 0) return 0; + if (!HasWork) return 0; + + float fuel = Vanilla.CallFloat(Vanilla.CookFuel, m_cooking, float.MaxValue); + if (fuel >= m_cooking.m_maxFuel * ButlerConfig.FuelThreshold.Value) return 0; + + return Mathf.Max(0, Mathf.FloorToInt(m_cooking.m_maxFuel - fuel)); + } + } + + public override void AddFuel() + { + Claim(); + Nview.InvokeRPC("RPC_AddFuel"); + } + + public override bool HasOutput { get { return Vanilla.Call(Vanilla.CookHaveDone, m_cooking, false); } } + + /// + /// ONE per done slot, and the 1 is not a stylistic choice. RPC_RemoveDoneItem spawns the + /// item amount times PER SLOT (verified in the IL: the inner loop runs to the + /// argument), so passing anything above 1 would not collect faster - it would print money. + /// + public override void PullOutput(Vector3 at) + { + Claim(); + Nview.InvokeRPC("RPC_RemoveDoneItem", at, 1); + } + + /// + /// The clock this whole feature exists for. Done at m_cookTime, Burnt at 2x - so what is + /// left is 2*cookTime - cookedTime, and a slot already Done is the urgent one because its + /// remaining half is all that stands between dinner and charcoal. + /// + /// GetItemConversion is asked with whatever name the slot currently holds, which is the raw + /// item before Done and the COOKED one after: CookingStation.GetItemConversion matches on + /// both m_from and m_to (verified), so the cook time is readable in either phase. + /// + public override float SecondsToSpoil + { + get + { + if (Vanilla.CookConversion == null) return float.MaxValue; + + float soonest = float.MaxValue; + + for (int i = 0; i < SlotCount; i++) + { + string name; + float cooked; + int status; + if (!ReadSlot(i, out name, out cooked, out status)) break; + + if (string.IsNullOrEmpty(name)) continue; + if (status == Vanilla.CookBurnt) continue; // already lost, no hurry + + CookingStation.ItemConversion conversion = + Vanilla.CookConversion.Invoke(m_cooking, new object[] { name }) + as CookingStation.ItemConversion; + if (conversion == null) continue; + + float left = conversion.m_cookTime * 2f - cooked; + if (left < soonest) soonest = left; + } + + return soonest; + } + } + } + + // ================================================================ Fermenter + + private class FermenterStation : ButlerStation + { + public Fermenter m_fermenter; + + /// Mead goes with the food. It has no deadline of its own, so it costs the cook + /// nothing beyond one more thing to fill and one more tap to open. + public override ButlerFamily Family { get { return ButlerFamily.Kitchen; } } + + private int Status + { + get { return Vanilla.CallInt(Vanilla.FermenterStatus, m_fermenter, Vanilla.FermentExposed); } + } + + public override bool Operable { get { return Status != Vanilla.FermentExposed; } } + + public override int FreeSlots { get { return Status == Vanilla.FermentEmpty ? 1 : 0; } } + + public override bool Accepts(string prefabName) + { + return Vanilla.Allowed(Vanilla.FermenterAllowed, m_fermenter, prefabName); + } + + public override void Add(string prefabName) + { + Claim(); + Nview.InvokeRPC("RPC_AddItem", prefabName); + } + + public override bool HasWork { get { return Status != Vanilla.FermentEmpty; } } + + public override string FuelPrefab { get { return null; } } + public override int FuelWanted { get { return 0; } } + public override void AddFuel() { } + + public override bool HasOutput { get { return Status == Vanilla.FermentReady; } } + + /// Opens the tap. The bottles are not out yet when this returns - DelayedTap waits + /// m_tapDelay for the animation - so the servant collects them on a later pass, which the + /// pickup sweep handles without knowing anything about fermenting. + public override void PullOutput(Vector3 at) + { + Claim(); + Nview.InvokeRPC("RPC_Tap"); + } + } + } +} diff --git a/JotunnModStub/Butler/ServantTableBehaviour.cs b/JotunnModStub/Butler/ServantTableBehaviour.cs new file mode 100644 index 0000000..4d70f81 --- /dev/null +++ b/JotunnModStub/Butler/ServantTableBehaviour.cs @@ -0,0 +1,170 @@ +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// A servant's table: an anchor, a summoning point and the feature's only window. One class serves + /// both trades - what changes between the smith's and the cook's is three fields set at + /// registration, not behaviour. + /// + /// It does no work of its own. Everything it knows it asks the servant, and everything the servant + /// says it says here - the hover text is the ONE feedback channel this feature has, by decision, so + /// a servant that has stopped must be able to explain itself from a line of text or it is + /// indistinguishable from a broken mod. + /// + /// E RAISES, and that is all E does. There is no pause switch and no automatic re-forming: a fallen + /// servant leaves the table empty until somebody notices. That was chosen over a sixty-second + /// respawn on the grounds that a death nobody notices is a death that might as well not happen. + /// + /// It registers itself with RaisedThrall's station list, which is what BoneServantAI's wither clock + /// asks when it wants to know whether its table is still standing. That list is the only part of + /// the thrall machinery this feature uses. + /// + public class ServantTableBehaviour : MonoBehaviour + { + public Switch m_switch; + + /// Set on the prefab at registration, so both travel to every instance. + public string m_title = "Servant's Table"; + public string m_servantPrefab = BoneServant.SmithName; + public ButlerFamily m_family = ButlerFamily.Forge; + + private const string KeyLastRaise = "RoV_butlerRaisedAt"; + + /// Where the servant stands up: in front of the table, clear of the mesh. + private const float RaiseOffset = 1.2f; + + private ZNetView m_nview; + + private void Awake() + { + RaisedThrall.RegisterStation(transform); + + m_nview = GetComponent(); + + if (m_switch != null) + { + m_switch.m_onUse = OnUse; + m_switch.m_onHover = Hover; + } + } + + private void OnDestroy() + { + RaisedThrall.UnregisterStation(transform); + } + + // ---------------------------------------------------------------- interaction + + private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + Player player = user as Player; + if (player == null) return false; + + if (item != null) + { + player.Message(MessageHud.MessageType.Center, "$msg_wontwork"); + return false; + } + + if (Servant() != null) + { + player.Message(MessageHud.MessageType.Center, "It is already at work."); + return false; + } + + float wait = Cooldown(); + if (wait > 0f) + { + player.Message(MessageHud.MessageType.Center, + $"The bones are not ready. {Mathf.CeilToInt(wait)}s."); + return false; + } + + return Raise(player); + } + + private bool Raise(Player player) + { + if (m_nview == null || !m_nview.IsValid()) return false; + if (ZNetScene.instance == null) return false; + + GameObject prefab = ZNetScene.instance.GetPrefab(m_servantPrefab); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Butler] No '{m_servantPrefab}' in ZNetScene; nothing was raised."); + player.Message(MessageHud.MessageType.Center, "Nothing answers."); + return false; + } + + // Owner-only, so in multiplayer exactly one servant stands up rather than one per client. + m_nview.ClaimOwnership(); + + Vector3 at = transform.position + transform.forward * RaiseOffset; + GameObject spawned = Object.Instantiate(prefab, at, Quaternion.identity); + + BoneServantAI servant = spawned.GetComponent(); + if (servant != null) servant.Bind(transform.position); + + if (ZNet.instance != null) m_nview.GetZDO().Set(KeyLastRaise, ZNet.instance.GetTime().Ticks); + + player.Message(MessageHud.MessageType.Center, "The servant rises."); + return true; + } + + /// Seconds still to wait, or zero. Kept in world time so logging out does not pay it off + /// for free - and configured to zero for the test, where it is simply never in the way. + private float Cooldown() + { + if (m_nview == null || !m_nview.IsValid() || ZNet.instance == null) return 0f; + + float required = ButlerConfig.ResummonSeconds.Value; + if (required <= 0f) return 0f; + + long stamp = m_nview.GetZDO().GetLong(KeyLastRaise, 0L); + if (stamp == 0L) return 0f; + + double elapsed = (ZNet.instance.GetTime() - new System.DateTime(stamp)).TotalSeconds; + return Mathf.Max(0f, required - (float)elapsed); + } + + // ---------------------------------------------------------------- the hover + + private string Hover() + { + BoneServantAI servant = Servant(); + + if (servant == null) + { + return m_title + "\nNo servant stands here.\n" + + "[$KEY_Use] Raise one"; + } + + string status = servant.Status; + if (string.IsNullOrEmpty(status)) status = "Waiting."; + + return m_title + "\n" + status; + } + + /// + /// This table's servant, if it is alive and loaded. + /// + /// Matched by anchor rather than by a stored id, so a table rebuilt on the same spot adopts the + /// servant already standing there - and by TRADE as well, because a smith's table and a cook's + /// table are allowed to stand a metre apart and must not adopt each other's servant. + /// + private BoneServantAI Servant() + { + foreach (Character character in Character.GetAllCharacters()) + { + if (character == null || character.IsDead()) continue; + + BoneServantAI servant = character.GetComponent(); + if (servant == null || servant.m_family != m_family) continue; + if (servant.IsBoundTo(transform.position)) return servant; + } + + return null; + } + } +} diff --git a/JotunnModStub/Dvergar/DvergarBanco.cs b/JotunnModStub/Dvergar/DvergarBanco.cs index 2b519aa..d842803 100644 --- a/JotunnModStub/Dvergar/DvergarBanco.cs +++ b/JotunnModStub/Dvergar/DvergarBanco.cs @@ -295,6 +295,17 @@ namespace RacesOfValheim // Trol/TrolTotemStore.cs, which is generic and is deliberately NOT copied here. Trader trader = prefab.GetComponent() ?? prefab.AddComponent(); trader.m_name = PieceDisplayName; + + // DISABLED ON PURPOSE, and it is the line that keeps the log clean. Trader was written for + // Haldor, who is a creature with an animator and a LookAt rig: Trader.Update() calls + // m_animator.SetBool("Stand", ...) and m_lookAt.ResetTarget() with no null check on every + // frame no player is nearby, and Trader.Start() calls InvokeRepeating("RandomTalk", 0, 0) + // on a component nobody authored in the editor. On a table both of those are null, so the + // bank threw a NullReferenceException every frame from the moment it was built. A disabled + // component runs neither, and StoreGui needs neither: Show() only reads fields off the + // Trader and asks it for its item list, and GetComponent finds it disabled just the same. + // This is the same fix SvermHiveStore.Mount already carries for the Hive Market. + trader.enabled = false; trader.m_items = new List(); trader.m_useItems = new List(); trader.m_randomTalk = new List(); diff --git a/JotunnModStub/Factions/FactionMerchantPatches.cs b/JotunnModStub/Factions/FactionMerchantPatches.cs index c308da0..dbdecfa 100644 --- a/JotunnModStub/Factions/FactionMerchantPatches.cs +++ b/JotunnModStub/Factions/FactionMerchantPatches.cs @@ -11,19 +11,63 @@ namespace RacesOfValheim // notices the player - not what a "press E to talk" merchant should do. Skipping Update() // entirely leaves Interactable.Interact() (E opens StoreGui) and Hoverable.GetHoverText() // (the "E - Talk" prompt) untouched, since neither of those depends on Update() running. + // + // The same prefix also refuses to run Update() on a Trader that has no rig to drive, which is + // the general form of a bug that reached a tester: Trader.Start() resolves m_animator and + // m_lookAt with GetComponentInChildren, and Update() then dereferences BOTH with no null check - + // m_animator.SetBool("Stand", ...) and m_lookAt.ResetTarget() on the branch taken whenever no + // player is nearby, which is most frames. A building is not a creature and has neither, so a + // Trader bolted onto one threw a NullReferenceException every frame and filled the BepInEx + // console. The prefabs that do that (the Dvergar bank, the Trol totem, the Hive Market) now + // disable their Trader outright, which is the real fix; this check is the net under it, and it + // costs one cached field read per trader per frame. [HarmonyPatch(typeof(Trader), "Update")] public static class FactionMerchantSuppressAmbientPatch { + // Both fields are private in the assembly this project compiles against. Resolved once + // rather than through Traverse, because this runs on every trader on every frame. + private static readonly AccessTools.FieldRef AnimatorField = + AccessTools.FieldRefAccess("m_animator"); + private static readonly AccessTools.FieldRef LookAtField = + AccessTools.FieldRefAccess("m_lookAt"); + public static bool Prefix(Trader __instance) { if (((Component)__instance).GetComponent() != null) { return false; } + + if (AnimatorField(__instance) == null || LookAtField(__instance) == null) + { + return false; + } + return true; } } + // Trader.Start() ends with InvokeRepeating("RandomTalk", m_randomTalkInterval, + // m_randomTalkInterval), and a Trader added with AddComponent comes up with that interval at + // zero, because nobody authored it in the editor. On a faction merchant the repeat is pure + // waste for as long as the creature exists: RandomTalk's first act is to read the animator's + // "Stand" bool, and nothing ever sets it, because Update() - the only thing that would - is + // suppressed for these by the patch above. So it wakes up, asks one question, answers no, and + // is scheduled again. + // + // Cancelled in a postfix rather than by skipping Start with a prefix: Start also resolves + // m_animator and m_lookAt and snaps a SnapToGround rig to the terrain, and none of that is in + // the way. Only the timer is. + [HarmonyPatch(typeof(Trader), "Start")] + public static class FactionMerchantStopRandomTalkPatch + { + public static void Postfix(Trader __instance) + { + if (((Component)__instance).GetComponent() == null) return; + __instance.CancelInvoke("RandomTalk"); + } + } + // Player.FindHoverObject() always figures out m_hoveringCreature correctly (it only // needs a Character component on the hit collider, no Hoverable/Interactable // involved) but separately sets m_hovering - the field the "E - Talk" prompt and the diff --git a/JotunnModStub/RaceClaws.cs b/JotunnModStub/RaceClaws.cs index ba4fda8..2e11b50 100644 --- a/JotunnModStub/RaceClaws.cs +++ b/JotunnModStub/RaceClaws.cs @@ -8,7 +8,7 @@ namespace RacesOfValheim /// /// Claws that are part of the body, for the races that grow a pair. /// - /// This is SvermClawSlot generalised, not reinvented: the Sverm's Vilebone Maulclaws worked out + /// This is SvermClawSlot generalised, not reinvented: the Sverm's Chitin Claws worked out /// the whole shape of the problem, and the Aswid and the Fenrir are asking for the same object /// with a different face. So the machinery moved here and each race supplies only what is /// genuinely its own - the item name, the model to wear, and whether it is currently a wolf. @@ -178,6 +178,15 @@ namespace RacesOfValheim shared.m_weight = 0f; shared.m_maxQuality = 1; + // INDESTRUCTIBLE, and it has to be the flag rather than a big number. The claws are + // never crafted, so no workbench will ever repair them: left on normal durability + // they wear down to zero and Humanoid.EquipItem then refuses to put them back in + // hand, which strands the race bare-fisted for good. m_useDurability = false is the + // single switch every path reads - the attack drain, the broken-item check, the + // inventory bar and the tooltip line all skip the item entirely. + shared.m_useDurability = false; + shared.m_canBeReparied = false; + // No recipe and no station: this item is never crafted, only issued. } @@ -375,6 +384,11 @@ namespace RacesOfValheim Jotunn.Logger.LogInfo($"[{RaceId}] Issued the {DisplayName}."); } + // A pair issued before the claws stopped wearing out is still carrying whatever it had + // ground down to. Nothing reads that number any more, but it is saved with the item, so + // it is put back to full once rather than left as a stale figure in the save file. + if (claws.m_durability < claws.GetMaxDurability()) claws.m_durability = claws.GetMaxDurability(); + // Empty-handed means clawed. Anything else in the right hand wins until it is put away, // which is the whole compromise. ItemDrop.ItemData held = Traverse.Create((Humanoid)player).Field("m_rightItem").Value; diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 1305920..7c9861e 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -135,7 +135,7 @@ namespace RacesOfValheim sb.AppendLine("[Base Passive] Insect Metabolism: You eat everything anyone else eats, and honey is worth double to you. Alchemical blood is the one thing you will not swallow.\n"); - sb.AppendLine($"[Base Passive] Vilebone Maulclaws: Your hands are the weapon. Bare-handed blows land at {rules.ClawDamagePercent * 100f:0}% of the claws' full weight, and they cannot be taken from you - draw a sword and they wait, sheathe it and they are back.\n"); + sb.AppendLine($"[Base Passive] Chitin Claws: Your hands are the weapon. Bare-handed blows land at {rules.ClawDamagePercent * 100f:0}% of the claws' full weight, and they cannot be taken from you - draw a sword and they wait, sheathe it and they are back.\n"); if (rules.MetabolicSurge) sb.AppendLine("[Eikthyr Unlock] Metabolic Surge: Running and jumping cost you less, and you jump higher.\n"); diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 8c8648a..495b593 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.2"; + public const string PluginVersion = "1.4.3"; private readonly Harmony harmony = new Harmony(PluginGUID); @@ -43,6 +43,9 @@ namespace RacesOfValheim // Not a race either: a tool any race can craft, so it sits beside the vulture rather // than inside the alphabetical run above. TrolsHammerConfig.Bind(Config); + // Not a race either: the two Bone Servants, shared by the Skeleton and Skadi, so they + // bind here rather than inside either race's run. + ButlerConfig.Bind(Config); harmony.PatchAll(); gameObject.AddComponent(); gameObject.AddComponent(); @@ -130,6 +133,7 @@ namespace RacesOfValheim SvermRace.Instance.CreateModAssets(); WarVultureItem.Register(); TrolsHammerItem.Register(); + BoneServant.Register(); } // --- RACE SELECTION UI --- public void ShowRaceSelectionMenu() diff --git a/JotunnModStub/Sverm/SvermClawSlot.cs b/JotunnModStub/Sverm/SvermClawSlot.cs index 11b911c..17b783c 100644 --- a/JotunnModStub/Sverm/SvermClawSlot.cs +++ b/JotunnModStub/Sverm/SvermClawSlot.cs @@ -6,7 +6,7 @@ using UnityEngine; namespace RacesOfValheim { /// - /// The Maulclaws as a REAL equipped weapon, sitting in the inventory in plain sight and + /// The Chitin Claws as a REAL equipped weapon, sitting in the inventory in plain sight and /// refusing to be moved. /// /// WHY THIS REPLACED THE COSMETIC VERSION. Bolting a model to the hand bones worked, but the @@ -36,8 +36,13 @@ namespace RacesOfValheim /// public static class SvermClawSlot { + /// + /// The prefab id, and it keeps the old spelling on purpose: it is what every save on disk + /// names the item by, and renaming it would leave a Sverm holding an item ObjectDB can no + /// longer resolve. The display name below is the only half a player ever reads. + /// public const string ItemName = "SvermMaulclaws"; - public const string ItemDisplayName = "Vilebone Maulclaws"; + public const string ItemDisplayName = "Chitin Claws"; /// Row in the reserved column the claws sit on. The other three await the carapace. private const int ClawRow = 0; @@ -84,6 +89,15 @@ namespace RacesOfValheim shared.m_weight = 0f; shared.m_maxQuality = 1; + // INDESTRUCTIBLE, and it has to be the flag rather than a big number. The claws are + // never crafted, so no workbench will ever repair them: left on normal durability + // they wear down to zero and Humanoid.EquipItem then refuses to put them back in + // hand, which strands the Sverm bare-fisted for good. m_useDurability = false is the + // single switch every path reads - the attack drain, the broken-item check, the + // inventory bar and the tooltip line all skip the item entirely. + shared.m_useDurability = false; + shared.m_canBeReparied = false; + // No recipe and no station: this item is never crafted, only issued. } @@ -153,9 +167,14 @@ namespace RacesOfValheim claws.m_gridPos = corner; } - Jotunn.Logger.LogInfo("[Sverm] Issued the Maulclaws."); + Jotunn.Logger.LogInfo("[Sverm] Issued the Chitin Claws."); } + // A pair issued before the claws stopped wearing out is still carrying whatever it had + // ground down to. Nothing reads that number any more, but it is saved with the item, so + // it is put back to full once rather than left as a stale figure in the save file. + if (claws.m_durability < claws.GetMaxDurability()) claws.m_durability = claws.GetMaxDurability(); + // Empty-handed means clawed. Anything else in the right hand wins until it is put // away, which is the whole compromise. ItemDrop.ItemData held = Traverse.Create((Humanoid)player).Field("m_rightItem").Value; diff --git a/JotunnModStub/Sverm/SvermClaws.cs b/JotunnModStub/Sverm/SvermClaws.cs index 5b01176..0e03b1a 100644 --- a/JotunnModStub/Sverm/SvermClaws.cs +++ b/JotunnModStub/Sverm/SvermClaws.cs @@ -3,7 +3,7 @@ using UnityEngine; namespace RacesOfValheim { /// - /// The Vilebone Maulclaws: attached to the hands for good, and never equipped. + /// The Chitin Claws: attached to the hands for good, and never equipped. /// /// WHY NOT A REAL WEAPON. Valheim has one weapon slot. A claw that is genuinely equipped locks /// the Sverm out of every sword, bow and staff in the game for the whole run, which is not @@ -52,7 +52,7 @@ namespace RacesOfValheim if (candidate != null) { resolved = candidate; - Jotunn.Logger.LogInfo($"[Sverm] Maulclaws resolved to '{name}'."); + Jotunn.Logger.LogInfo($"[Sverm] Chitin Claws resolved to '{name}'."); return resolved; } } @@ -70,7 +70,7 @@ namespace RacesOfValheim /// /// The vanilla weapon's damage at quality 4, read once. This is the ceiling the tier - /// percentages are a fraction of, and state 7 is 100% of it - the real Maulclaws. + /// percentages are a fraction of, and state 7 is 100% of it - the real Chitin Claws. /// /// Public because it is the shared yardstick: the Aswid's and the Fenrir's claws /// (RaceClawSet) are balanced against this same figure rather than against the models they @@ -108,7 +108,7 @@ namespace RacesOfValheim }; referenceRead = true; - Jotunn.Logger.LogInfo($"[Sverm] Maulclaws at quality {SvermConfig.ArmorReferenceQuality}: " + + Jotunn.Logger.LogInfo($"[Sverm] Chitin Claws at quality {SvermConfig.ArmorReferenceQuality}: " + $"slash {referenceDamage.m_slash:0.#}, pierce {referenceDamage.m_pierce:0.#}, " + $"blunt {referenceDamage.m_blunt:0.#}."); return referenceDamage; diff --git a/JotunnModStub/Sverm/SvermConfig.cs b/JotunnModStub/Sverm/SvermConfig.cs index e75684a..cda6818 100644 --- a/JotunnModStub/Sverm/SvermConfig.cs +++ b/JotunnModStub/Sverm/SvermConfig.cs @@ -88,7 +88,7 @@ namespace RacesOfValheim public const string CarapaceLegsVisual = "ArmorCarapaceLegs"; public const string CarapaceHelmetVisual = "HelmetCarapace"; - // ─── Vilebone Maulclaws ────────────────────────────────────────────── + // ─── Chitin Claws ──────────────────────────────────────────────────── // FOUR near-identical names exist in the manifest and only some carry a recipe, so the // prefab is resolved by trying them in order and logging which one answered. A wrong guess // here fails soft and silently - two empty hands - which is exactly the failure this @@ -106,7 +106,7 @@ namespace RacesOfValheim /// /// Fraction of the vanilla weapon's quality-4 damage the bare hands hit for, per state. - /// State 7 is the ceiling - the real Maulclaws - and state 8 adds fire on top rather than + /// State 7 is the ceiling - the real Chitin Claws - and state 8 adds fire on top rather than /// going past it. Index 0 unused, as above. /// public static readonly float[] ClawDamagePercentByState = diff --git a/JotunnModStub/Sverm/SvermProgression.cs b/JotunnModStub/Sverm/SvermProgression.cs index 1e311d9..ac1f09b 100644 --- a/JotunnModStub/Sverm/SvermProgression.cs +++ b/JotunnModStub/Sverm/SvermProgression.cs @@ -28,7 +28,7 @@ namespace RacesOfValheim /// public float FireWeakness; - /// Fraction of the Maulclaws' quality-4 damage a bare-handed blow lands for. + /// Fraction of the Chitin Claws' quality-4 damage a bare-handed blow lands for. public float ClawDamagePercent; public bool MetabolicSurge; // cheaper running and jumping, higher jump diff --git a/JotunnModStub/Sverm/SvermStingerForm.cs b/JotunnModStub/Sverm/SvermStingerForm.cs index 5c5a4f7..a3a789e 100644 --- a/JotunnModStub/Sverm/SvermStingerForm.cs +++ b/JotunnModStub/Sverm/SvermStingerForm.cs @@ -84,7 +84,7 @@ namespace RacesOfValheim // // The first version emptied the hands completely and the form could not attack: with // nothing equipped there is no weapon to swing, and Valheim's bare fist is not the - // thing this form is supposed to be throwing. Leaving the Maulclaws equipped makes the + // thing this form is supposed to be throwing. Leaving the Chitin Claws equipped makes the // sting an ordinary weapon attack - which works - and costs nothing visually, because // the whole body is hidden a line later. Fist weapons report Skills.SkillType.Unarmed, // so the damage patch still recognises the blow and swaps the deathsquito's figure in. @@ -254,7 +254,7 @@ namespace RacesOfValheim } Jotunn.Logger.LogWarning($"[Sverm] Could not read a weapon off '{SvermConfig.StingerCreature}'; " + - "the sting falls back to the Maulclaws."); + "the sting falls back to the Chitin Claws."); stingerDamageRead = true; return stingerDamage; // all zeroes: the damage patch then leaves the claw values alone } diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index 9e5b79c..07477b5 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -16,7 +16,7 @@ namespace RacesOfValheim /// matures on screen as it advances. /// /// What gets mounted, all of it borrowed from vanilla: - /// the claws - the Vilebone Maulclaws, on both hands, always; + /// the claws - the Chitin Claws, on both hands, always; /// the spines - UndeadBjornRibcage worn spine-up, a static crest, from tier 5; /// the eyes - two emissive spheres, the Aswid's geometry unchanged; /// the motes - a firefly swarm under the body, only while falling; diff --git a/JotunnModStub/Trol/TrolTotem.cs b/JotunnModStub/Trol/TrolTotem.cs index 945433f..0dea4fb 100644 --- a/JotunnModStub/Trol/TrolTotem.cs +++ b/JotunnModStub/Trol/TrolTotem.cs @@ -261,6 +261,17 @@ namespace RacesOfValheim // GameObject - walks straight into Say(m_randomStartTrade, ...) right after opening the store. Trader trader = prefab.GetComponent() ?? prefab.AddComponent(); trader.m_name = PieceDisplayName; + + // DISABLED ON PURPOSE, and it is the line that keeps the log clean. Trader was written for + // Haldor, who is a creature with an animator and a LookAt rig: Trader.Update() calls + // m_animator.SetBool("Stand", ...) and m_lookAt.ResetTarget() with no null check on every + // frame no player is nearby, and Trader.Start() calls InvokeRepeating("RandomTalk", 0, 0) + // on a component nobody authored in the editor. On a totem both of those are null, so the + // piece threw a NullReferenceException every frame from the moment it was raised. A + // disabled component runs neither, and StoreGui needs neither: Show() only reads fields off + // the Trader and asks it for its item list, and GetComponent finds it disabled just the + // same. This is the same fix SvermHiveStore.Mount already carries for the Hive Market. + trader.enabled = false; trader.m_items = new List(); trader.m_useItems = new List(); trader.m_randomTalk = new List(); diff --git a/README.md b/README.md index dd323fc..80a5c3d 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,13 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing --- -## New Patch v1.4.2: The Sverm +## New Patch v1.4.3 + +The War Vulture is craftable at last, Trol's Hammer builds everything 20% bigger, and two portal bugs are gone. See the [Changelog](#changelog). + +--- + +## The Sverm The tenth race is an insect. The Sverm never dresses: chest, legs and helm are carapace that never comes off and is always worth a full set of the biome ahead of you — best quality, weightless, no movement penalty. It fights with claws it cannot put down, poison cannot touch it, and no invertebrate in the game will attack it from tier zero. Blunt and fire hit it 40% harder, which is the price. @@ -87,7 +93,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions ### 10. Sverm - **Chitin Plating:** You never dress. Chest, legs and helm are carapace worth a full set of the biome ahead of you at every tier — best quality, weightless, no movement penalty. Only cloak and trinket may still be worn. -- **Vilebone Maulclaws:** Your hands are the weapon — see [Permanent Claws](#permanent-claws). +- **Chitin Claws:** Your hands are the weapon — see [Permanent Claws](#permanent-claws). - **Hive Pheromones:** No invertebrate attacks you — leeches, ticks, deathsquitos, seekers and bees all ignore you, from tier zero. - **Toxin Immunity:** Poison cannot touch you. Blunt and fire hit you 40% harder — until Fader, when the fire weakness burns out and comes back as a resistance. - **The Colony:** After the Elder, a Brood Mound, a Hive Market and a roster of insect troops bought with digested biomass. @@ -101,7 +107,7 @@ Three races grow a pair of their own. The terms are identical for all three: iss - **Aswid — Claws of the Beast:** burned almost black. Lands the whole of it as slash. - **Fenrir — Cursed Claws:** the flesh rippers worn as the game made them. Also pure slash. -- **Sverm — Vilebone Maulclaws:** splits the same weight three ways, and sets it alight at Fader. +- **Sverm — Chitin Claws:** splits the same weight three ways, and sets it alight at Fader. --- @@ -218,7 +224,7 @@ Right Mouse toggles flight. Glide towards aim, W = forward/climb, Shift+W = use
Sverm Progression -- **Base:** Chitin Plating (full next-biome set at every tier, weightless, no speed penalty; only cloak and trinket wearable). Toxin Immunity — poison cannot touch you, but +40% blunt and +40% fire damage taken. Hive Pheromones — no invertebrate attacks you. Insect Metabolism — eats everything, honey counts double, alchemical blood is the one refusal. Vilebone Maulclaws — unarmed blows land at a share of the claws' full weight, rising with every tier. +- **Base:** Chitin Plating (full next-biome set at every tier, weightless, no speed penalty; only cloak and trinket wearable). Toxin Immunity — poison cannot touch you, but +40% blunt and +40% fire damage taken. Hive Pheromones — no invertebrate attacks you. Insect Metabolism — eats everything, honey counts double, alchemical blood is the one refusal. Chitin Claws — unarmed blows land at a share of the claws' full weight, rising with every tier. - **Eikthyr:** Metabolic Surge – running and jumping cost less, and you jump higher. Ventral Pouches – +100 carry weight. - **Elder:** Grinding Mandibles – seeds are food (raw nourishment, no garden buffs). Sensory Antennae – feel what lives around you, through stone and soil. **The colony wakes:** Brood Mound unlocked. - **Bonemass:** Venom Glands – every blow carries bonus poison, growing per tier. Acid Hemolymph – melee attackers take poison back. @@ -385,17 +391,22 @@ The **Sverm** belongs to no faction. Its Hive Pheromones make every invertebrate ## Development & Feedback This is a stable release, but more races and refinements are planned! -Bug reports, feedback, ideas: [https://discord.gg/gbBEK2VTE](https://discord.gg/gbBEK2VTE) +Bug reports, feedback, ideas: [https://discord.gg/gbBEK2VTE](https://discord.gg/gbBEK2VTE) +Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorTheModder) --- ## Changelog +### v1.4.3 +- **NEW - Trol's Hammer:** a second builder's hammer (1 Core Wood, 2 Fine Wood, Workbench) that builds everything the ordinary one builds, 20% larger. Any race can craft it. +- **War Vulture:** now craftable — 10 Greydwarf Eyes, 2 Black Metal, 2 Raw Lox Meat at a Forge. The recipe only appears for the races that can ride. +- **Fix - Portals:** teleporting no longer leaves you in a world that has stopped loading, and the Skeleton's head flame no longer burns torches into the world for everyone to find. + ### v1.4.2 - **NEW - Sverm Race:** the tenth race. Wears carapace instead of armour (never removable, always worth the next biome's full set, weightless), fights with permanent claws, is immune to poison but takes 40% more from blunt and fire, and is ignored by every invertebrate in the game from tier zero. After the Elder it stops being one body and becomes a colony. - **NEW - The Colony (Sverm):** Brood Mound, digestion bank, brood eggs on a timer, an insect troop roster, a Hive Market, blister ticks that regrow free, and vanilla beehives taken over by the nest — twice the speed, three times the honey, royal jelly after Yagluth. -- **NEW - War Vulture (Flying Mount):** a vulture trophy on a stick that puts you on a real, network-visible flying bird. Unlimited cruise, a limited sprint reserve on the run key that refills in mid-air, and its own bar under your stamina. Furling and Dvergar by default, configurable. Crafted at a forge from 10 greydwarf eyes, 2 black metal ingots and 2 raw lox meat, and the recipe is hidden from every race that cannot ride. -- **NEW - Trol's Hammer:** a second builder's hammer (1 Core Wood, 2 Fine Wood, Workbench) that builds everything the ordinary one builds — same menu, same cost, same drop — 20% larger. The preview is already at full size, the size is saved with the piece and shared with other players, and both hammers keep working side by side in the same house. +- **NEW - War Vulture (Flying Mount):** a vulture trophy on a stick that puts you on a real, network-visible flying bird. Unlimited cruise, a limited sprint reserve on the run key that refills in mid-air, and its own bar under your stamina. Furling and Dvergar by default, configurable. No recipe yet while the flight is being proven — spawn it from the console. - **NEW - Claws for the Aswid and the Fenrir:** both races now grow a permanent pair, on the same terms the Sverm has always had. All three are measured against **one** yardstick rather than against the models they wear, so the same tier is worth the same damage whichever race you are, and no pair counts while you are wearing another body. - **NEW - Dvergar Contract Bank:** the hire bench is now a proper contract bank — five crew slots, 400 to 2000 coin, paid at your own trader discount, with the Queen's drop opening the Runic Crew and the Ash Guard. Hired crews keep their employer's truce with the mountain's dvergr, seekers at heel included, so a band walking into an outpost no longer means a dead shopkeeper. They carry no loot, heal themselves, and a dead crew is money spent. Race locked, one per square kilometre, and the only chain that needs no reagent — the Dvergar pay for everything, so 100 coin goes in the recipe instead. - **NEW - Dvergar Rune Barrel:** 20 doses of any vanilla brew, poured into everything you have raised within 30 m. It refuses nothing and promises nothing: a healing mead heals a dvergr, a stamina mead does nothing, because a creature has no stamina bar. diff --git a/manifest.json b/manifest.json index c9a811b..b78d9d0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.2", + "version_number": "1.4.3", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 70bb2636090a77f8c99926b29ce2bb882c6a8ccd Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Mon, 17 Aug 2026 07:56:07 +0200 Subject: [PATCH 005/273] warvulture --- .../Factions/FactionMerchantCatalog.cs | 75 +++++++++++++------ JotunnModStub/RacesOfValheim.cs | 28 ++++++- README.md | 33 +++++--- manifest.json | 2 +- 4 files changed, 100 insertions(+), 38 deletions(-) diff --git a/JotunnModStub/Factions/FactionMerchantCatalog.cs b/JotunnModStub/Factions/FactionMerchantCatalog.cs index 440aef4..ca9454d 100644 --- a/JotunnModStub/Factions/FactionMerchantCatalog.cs +++ b/JotunnModStub/Factions/FactionMerchantCatalog.cs @@ -38,14 +38,41 @@ namespace RacesOfValheim public const string JokeNonMortoZombie = "NonMortoZombie"; public const string JokeFantasma = "Fantasma"; + // Every merchant in the mod buys/sells these regardless of what its own list + // carries - players kept running into benches that could not fence basic building + // mats. Folded into each ShopDefinition.Items below (WithDefaults) rather than + // handled in FactionMerchantSetup/FactionMerchantSellPanel, so both the buy and + // sell columns pick it up for free. + private static readonly List DefaultItems = new List + { + new CatalogEntry("Wood", 1), + new CatalogEntry("Stone", 1), + new CatalogEntry("FineWood", 5), + new CatalogEntry("Flint", 5), + new CatalogEntry("RoundLog", 10), // Core wood's internal prefab name + }; + + // Appends whichever DefaultItems aren't already named in items, explicit entries + // win so a shop can still special-price one of these if it ever needs to. + private static List WithDefaults(List items) + { + var combined = new List(items); + foreach (CatalogEntry defaultEntry in DefaultItems) + { + if (!combined.Exists(e => e.PrefabName == defaultEntry.PrefabName)) + { + combined.Add(defaultEntry); + } + } + return combined; + } + private static readonly ShopDefinition GreydwarfShop = new ShopDefinition { DisplayName = "Greydwarf", JokeCategory = JokeLegnoFalegname, - Items = new List + Items = WithDefaults(new List { - new CatalogEntry("Wood", 1), - new CatalogEntry("Stone", 2), new CatalogEntry("Resin", 5), new CatalogEntry("GreydwarfEye", 5), new CatalogEntry("Dandelion", 5), @@ -60,14 +87,14 @@ namespace RacesOfValheim new CatalogEntry("TrophyGreydwarf", 20), new CatalogEntry("TrophyGreydwarfBrute", 350), new CatalogEntry("TrophyGreydwarfShaman", 350), - } + }) }; private static readonly ShopDefinition TrollShop = new ShopDefinition { DisplayName = "Troll", JokeCategory = JokeTroll, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("TrollHide", 1), new CatalogEntry("DeerHide", 2), @@ -79,14 +106,14 @@ namespace RacesOfValheim new CatalogEntry("TrophyDeer", 20), new CatalogEntry("TrophyBoar", 50), new CatalogEntry("TrophyForestTroll", 1500), - } + }) }; private static readonly ShopDefinition FulingShop = new ShopDefinition { DisplayName = "Fuling", JokeCategory = JokeGoblin, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("BlackMetalScrap", 1), new CatalogEntry("LoxMeat", 1), @@ -114,7 +141,7 @@ namespace RacesOfValheim new CatalogEntry("TrophyGrowth", 800), // Growth new CatalogEntry("TrophyGoblinBrute", 1500), new CatalogEntry("TrophySerpent", 1500), - } + }) }; // The Shaman alone stocks the Furling's crop line, so it needs a bench of its own - the four @@ -160,7 +187,7 @@ namespace RacesOfValheim { DisplayName = "Ulv", JokeCategory = JokeLupoLicantropo, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("WolfFang", 5), new CatalogEntry("WolfMeat", 5), @@ -171,52 +198,52 @@ namespace RacesOfValheim new CatalogEntry("TrophyWolf", 350), new CatalogEntry("TrophyUlv", 350), new CatalogEntry("TrophyHatchling", 350), // Drake (internal id "Hatchling") - } + }) }; private static readonly ShopDefinition FenringShop = new ShopDefinition { DisplayName = "Fenring", JokeCategory = JokeLupoLicantropo, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("WolfFang", 5), new CatalogEntry("Ulvsblod", 500), // gates the Fenrir pack trough new CatalogEntry("GreaterUlvsblod", 1500), // upgrades it: the fenrir themselves new CatalogEntry("TrophyFenring", 350), - } + }) }; private static readonly ShopDefinition CultistShop = new ShopDefinition { DisplayName = "Cultist", JokeCategory = JokeStrega, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("JuteRed", 2), new CatalogEntry("GreaterFrostHeart", 1500), // the Skadi's bought reagent new CatalogEntry("TrophyCultist", 1500), - } + }) }; private static readonly ShopDefinition DvergShop = new ShopDefinition { DisplayName = "Dverg", JokeCategory = JokeNano, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("BlackMarble", 20), new CatalogEntry("Softtissue", 250), new CatalogEntry("Sap", 250), // extracted from Yggdrasil roots with Dvergr extractors new CatalogEntry("TrophyDvergr", 1500), - } + }) }; private static readonly ShopDefinition DraugrShop = new ShopDefinition { DisplayName = "Draugr", JokeCategory = JokeNonMortoZombie, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("Entrails", 2), new CatalogEntry("Mushroom", 5), @@ -234,14 +261,14 @@ namespace RacesOfValheim new CatalogEntry("TrophyLeech", 350), // Leech new CatalogEntry("TrophyDraugrElite", 800), new CatalogEntry("TrophyAbomination", 1500), // Abomination - } + }) }; private static readonly ShopDefinition SkeletonShop = new ShopDefinition { DisplayName = "Skeleton", JokeCategory = JokeScheletro, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("BoneFragments", 1), new CatalogEntry("Ooze", 2), // Blob/Oozer, folded in here: no talk-capable rig @@ -252,29 +279,29 @@ namespace RacesOfValheim new CatalogEntry("SoulStone", 50), // binds a skeleton archer sentry new CatalogEntry("CursedSkull", 500), // gates the Skeleton bone pile new CatalogEntry("GreaterCursedSkull", 1500), // upgrades it: the rotten - } + }) }; private static readonly ShopDefinition GhostShop = new ShopDefinition { DisplayName = "Ghost", JokeCategory = JokeFantasma, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("Ectoplasm", 2), new CatalogEntry("TrophyGhost", 350), - } + }) }; private static readonly ShopDefinition WraithShop = new ShopDefinition { DisplayName = "Wraith", JokeCategory = JokeFantasma, - Items = new List + Items = WithDefaults(new List { new CatalogEntry("Chain", 5), new CatalogEntry("TrophyWraith", 1500), - } + }) }; // Key = vanilla creature prefab name (internal id, not the wiki display name). diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 495b593..18d25ab 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.3"; + public const string PluginVersion = "1.4.4"; private readonly Harmony harmony = new Harmony(PluginGUID); @@ -80,6 +80,8 @@ namespace RacesOfValheim Player player = Player.m_localPlayer; if (player == null) return; + RemovePermanentRaceEquipment(player); + player.m_customData.Remove("Race"); player.m_customData.Remove("FenrirCurse_Active"); @@ -118,6 +120,30 @@ namespace RacesOfValheim } } + /// + /// Strips whatever body-part weapon the outgoing race grew. The Aswid/Fenrir claws + /// (RaceClawSet) and the Sverm's Chitin Claws (SvermClawSlot) are quest items a player can + /// neither drop nor sell, so a race change has to take them off the same way it takes the + /// stats away - otherwise they sit in the inventory forever as leftovers from a race that + /// no longer applies. Checked by item identity rather than by the race being left, so it + /// also mops up anything a previous, already-abandoned race left behind. + /// + private static void RemovePermanentRaceEquipment(Player player) + { + Inventory inventory = player.GetInventory(); + if (inventory == null) return; + + // Copied out first: removing items while GetAllItems()'s own list is still being + // walked corrupts the enumeration. + foreach (ItemDrop.ItemData item in inventory.GetAllItems().ToArray()) + { + if (RaceClawSet.SetOwning(item) == null && !SvermClawSlot.IsClaws(item)) continue; + + if (player.IsItemEquiped(item)) player.UnequipItem(item, false); + inventory.RemoveItem(item); + } + } + private void CreateAllModAssets() { PrefabManager.OnVanillaPrefabsAvailable -= CreateAllModAssets; RaceMenuWard.Register(); diff --git a/README.md b/README.md index 80a5c3d..adafefb 100644 --- a/README.md +++ b/README.md @@ -4,9 +4,11 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing --- -## New Patch v1.4.3 +## Development & Feedback -The War Vulture is craftable at last, Trol's Hammer builds everything 20% bigger, and two portal bugs are gone. See the [Changelog](#changelog). +This is a stable release, but more races and refinements are planned! +Bug reports, feedback, ideas: [https://discord.gg/gbBEK2VTE](https://discord.gg/gbBEK2VTE) +Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorTheModder) --- @@ -275,8 +277,8 @@ Every race has a buildable station of its own, gated by a reagent bought from it - **Aswid — Blood Refinery:** refines Blood Essence, Superior Blood Essence and Blood Core. - **Draugh — Cursed Body Pile:** eats raw flesh and answers with tamed draugr; Draugr and Elite trophies are worth a whole batch. Anyone can build it, but only a Draugh gives the draugr orders — for everyone else it is a grave that defends its own ten meters. - **Furling — Five crops:** Copper, Tin and Iron Flax grow metal out of poisoned soil; Stoneberry and Flintberry bushes give stone and flint. -- **Skadi — Crystal Golem:** a stonecutter-bound guardian on a leash. Skadi (and Trol) may also build inside any troll cave in the world. -- **Skeleton — Bound Bone Pile & Bound Sentry:** pay once per slot and that slot refills itself forever, because an army you re-buy after every fight is one nobody takes out of the house. The Sentry is a bound archer that cannot walk, regenerates when left alone, and hands its parts back when it falls. +- **Skadi — Crystal Golem & Bone Cook:** a stonecutter-bound guardian on a leash. Skadi (and Trol) may also build inside any troll cave in the world. The Cook is Skadi's own half of the [Bone Servants](#skeleton--skadi--bone-servants). +- **Skeleton — Bound Bone Pile, Bound Sentry & Bone Smith:** pay once per slot and that slot refills itself forever, because an army you re-buy after every fight is one nobody takes out of the house. The Sentry is a bound archer that cannot walk, regenerates when left alone, and hands its parts back when it falls. The Smith is Skeleton and Skadi's shared half of the [Bone Servants](#skeleton--skadi--bone-servants). - **Sverm — Brood Mound & Hive Market:** see [The Colony](#race-progressions-level-by-level). - **Trenta — Composter & Heartwood Grove:** the Composter rots raw flesh into Fertilizer, which grows any plant on the spot. The Grove is a tree that fertilises what surrounds it, stings what approaches it, and fills a chest with honey. - **Trol — War Totem:** hires warbands of trolls and greydwarves for coin. Race locked — the hammer refuses it to anyone who is not a Trol. A dead warband is money spent. @@ -326,6 +328,16 @@ Meat goes in and a standing pack fills up, in three ranks. It is a herd you keep - **Upgrade:** feed it a Greater Ulvsblod once Yagluth is down and hand over what he left behind. That is what opens the fenrir rank at all, and it raises the two below it. - The pack is born tame and leashed, does not breed, drops nothing, heals itself, follows and walks home. Fenrir are deliberately larger than vanilla Fenring so they cannot be mistaken for a transformed player in a melee. If the trough goes, the pack withers in five minutes. +### Skeleton & Skadi — Bone Servants + +Two disarmed skeletons that never fight, summoned at their own table to work every station and marked chest within 20 m of it. + +- **Build (either table):** 1 Skeleton Trophy, 1 Wishbone, 8 Stone, at a Hammer — no crafting station needed. Removed and the cost comes back in full, like every other station. One table of each kind per forty meters — but a smith's circle and a cook's may sit right on top of each other, since neither ever touches the other's stations. +- **Bone Smith (Smith's Table):** works the Forge family — smelters, kilns, anything that turns ore into metal on its own. Open to **Skeleton or Skadi**. +- **Bone Cook (Cook's Table):** works cooking stations and the fermenter. Open to **Skadi only** — the hearth answers to nobody else's dead. +- **How they work:** any chest holding at least one Bone Fragment (the sigil, configurable) is theirs to draw from. They carry material in, fill a station in one trip mixing types freely, refuel it once it drops under 25%, and put the finished batch back in the chest it came from. A station that cannot work right now — no fire lit, an uncovered fermenter — is skipped without a word. +- **If one falls,** press **E** on its table to raise it again; that is the table's only function. Work radius, fuel threshold, resummon time and the sigil item are all in Configuration Manager under `Butler - Bone Servant`. + --- ## The War Vulture (Flying Mount) @@ -388,16 +400,13 @@ The **Sverm** belongs to no faction. Its Hive Pheromones make every invertebrate --- -## Development & Feedback - -This is a stable release, but more races and refinements are planned! -Bug reports, feedback, ideas: [https://discord.gg/gbBEK2VTE](https://discord.gg/gbBEK2VTE) -Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorTheModder) - ---- - ## Changelog +### v1.4.4 +- **NEW - Bone Servants (Skeleton & Skadi):** two disarmed skeletons, the **Bone Smith** and the **Bone Cook**, summoned at their own table to fetch material from marked chests and keep nearby stations fed — the Smith works the Forge family for Skeleton or Skadi, the Cook works cooking stations and the fermenter for Skadi alone. Full details under [Skeleton & Skadi — Bone Servants](#skeleton--skadi--bone-servants). +- **Fix - Race Change:** switching race no longer leaves permanent claws (Aswid, Fenrir, Sverm) stuck in your inventory — resetting your race now strips them along with the rest of that race's stats. +- **Fix - Faction Merchants:** every faction merchant now buys and sells Wood, Stone, Fine Wood, Flint and Core Wood regardless of its own catalogue, so no bench refuses basic building materials. + ### v1.4.3 - **NEW - Trol's Hammer:** a second builder's hammer (1 Core Wood, 2 Fine Wood, Workbench) that builds everything the ordinary one builds, 20% larger. Any race can craft it. - **War Vulture:** now craftable — 10 Greydwarf Eyes, 2 Black Metal, 2 Raw Lox Meat at a Forge. The recipe only appears for the races that can ride. diff --git a/manifest.json b/manifest.json index b78d9d0..660f981 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.3", + "version_number": "1.4.4", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 4559e0b9e1914ae5260c35eb801cefb1c052ba7c Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Tue, 18 Aug 2026 16:51:07 +0200 Subject: [PATCH 006/273] warvulture --- JotunnModStub/Aswid/AswidClaws.cs | 7 +- JotunnModStub/Aswid/AswidConfig.cs | 2 +- JotunnModStub/Aswid/AswidPatches.cs | 3 +- JotunnModStub/Aswid/AswidRace.cs | 12 +- JotunnModStub/Fenrir/FenrirClaws.cs | 7 +- JotunnModStub/RaceClaws.cs | 320 ++++++++++++++++++++-- JotunnModStub/RaceClawsConfig.cs | 33 +++ JotunnModStub/RaceCompendium.cs | 6 +- JotunnModStub/RacesOfValheim.cs | 5 +- JotunnModStub/Skadi/SkadiPatches.cs | 45 ++- JotunnModStub/Skadi/SkadiRace.cs | 17 +- JotunnModStub/Skadi/SkadiStatusEffects.cs | 21 ++ README.md | 23 +- manifest.json | 2 +- 14 files changed, 455 insertions(+), 48 deletions(-) create mode 100644 JotunnModStub/RaceClawsConfig.cs diff --git a/JotunnModStub/Aswid/AswidClaws.cs b/JotunnModStub/Aswid/AswidClaws.cs index 2965613..cbfe3db 100644 --- a/JotunnModStub/Aswid/AswidClaws.cs +++ b/JotunnModStub/Aswid/AswidClaws.cs @@ -5,9 +5,10 @@ namespace RacesOfValheim /// /// The Claws of the Beast: the Bjorn claw, burned down to almost black. /// - /// Everything about how they behave - issued once, never dropped, back in hand the moment the - /// hands are free, tier damage as slash - lives in RaceClawSet. This file is only the Aswid's - /// half of the answer: which model, what colour, and when the race is wearing another body. + /// Everything about how they behave - a timed skill (RaceClawsConfig.ActivateKey), issued and + /// retracted on its own, back in hand the moment the hands are free while it runs, tier damage + /// as slash - lives in RaceClawSet. This file is only the Aswid's half of the answer: which + /// model, what colour, and when the race is wearing another body. /// /// The tint is config rather than a constant because "almost black" is a look, not a number, /// and it needs one pass in front of a mirror. It is applied to the item's own copies of the diff --git a/JotunnModStub/Aswid/AswidConfig.cs b/JotunnModStub/Aswid/AswidConfig.cs index b195c9f..f7e6a87 100644 --- a/JotunnModStub/Aswid/AswidConfig.cs +++ b/JotunnModStub/Aswid/AswidConfig.cs @@ -106,7 +106,7 @@ namespace RacesOfValheim TameKey = config.Bind(keybinds, "Tame", new KeyboardShortcut(KeyCode.U), new ConfigDescription("Tames the creature under your cursor, if your tier allows it.")); ToggleDevourKey = config.Bind(keybinds, "Toggle Devour Ability", new KeyboardShortcut(KeyCode.I), - new ConfigDescription("Turns the automatic Devour-on-kill behavior on or off.")); + new ConfigDescription("Turns the Vampiric Aura and the automatic Devour-on-kill behavior on or off together. Turn this off before talking to Haldor/Hildir - the aura does not recognize traders and will attack them.")); const string combat = "Aswid - Passive Combat"; DamageBonusPerState = config.Bind(combat, "Damage Bonus Per State", 2f, diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 07166f1..95ab0c6 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -532,7 +532,8 @@ namespace RacesOfValheim if (__instance == Player.m_localPlayer && RaceInput.Allowed && AswidConfig.ToggleDevourKey.Value.IsDown()) { AswidRace.DevourEnabled = !AswidRace.DevourEnabled; - string msg = AswidRace.DevourEnabled ? "Devour Ability: ENABLED" : "Devour Ability: DISABLED"; + AswidRace.AuraEnabled = AswidRace.DevourEnabled; + string msg = AswidRace.DevourEnabled ? "Vampiric Aura: ENABLED" : "Vampiric Aura: DISABLED"; __instance.Message(MessageHud.MessageType.Center, msg); } diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 67bbe53..d2085f4 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -832,11 +832,18 @@ namespace RacesOfValheim private float damageTickTimer = 0f; /// - /// The Vampiric Aura is passive: it drains on its own, in every form, with no key to hold and - /// no icon or message of its own. The form only decides how hard it bites. + /// The Vampiric Aura drains on its own, in every form, with no key to hold - but it does not + /// distinguish traders from monsters, so it can execute Haldor/Hildir on approach. AuraEnabled + /// (toggled with Devour on the same key) is the escape hatch for that. /// private void HandleVampiricAura() { + if (!AuraEnabled) + { + damageTickTimer = 0f; + return; + } + damageTickTimer += Time.deltaTime; if (damageTickTimer < AswidConfig.AuraTickInterval.Value) return; @@ -914,6 +921,7 @@ namespace RacesOfValheim } public static bool DevourEnabled = true; + public static bool AuraEnabled = true; private static float lastConsumeTime = 0f; public static void TryConsumeMob(Character c, float maxHp, bool bypassCooldown = false) diff --git a/JotunnModStub/Fenrir/FenrirClaws.cs b/JotunnModStub/Fenrir/FenrirClaws.cs index 604fd0b..ebe749d 100644 --- a/JotunnModStub/Fenrir/FenrirClaws.cs +++ b/JotunnModStub/Fenrir/FenrirClaws.cs @@ -5,9 +5,10 @@ namespace RacesOfValheim /// /// The Cursed Claws: the flesh rippers, worn exactly as the game authored them. /// - /// Everything about how they behave - issued once, never dropped, back in hand the moment the - /// hands are free, tier damage as slash - lives in RaceClawSet. This file is only the Fenrir's - /// half: which model, and when the race is currently a wolf. + /// Everything about how they behave - a timed skill (RaceClawsConfig.ActivateKey), issued and + /// retracted on its own, back in hand the moment the hands are free while it runs, tier damage + /// as slash - lives in RaceClawSet. This file is only the Fenrir's half: which model, and when + /// the race is currently a wolf. /// /// No tint. The fenrir claw already looks like something a Fenrir would grow, which is the /// whole reason it is the one being borrowed. diff --git a/JotunnModStub/RaceClaws.cs b/JotunnModStub/RaceClaws.cs index 2e11b50..251d38b 100644 --- a/JotunnModStub/RaceClaws.cs +++ b/JotunnModStub/RaceClaws.cs @@ -1,33 +1,42 @@ using System.Collections.Generic; using HarmonyLib; +using Jotunn.Entities; using Jotunn.Managers; using UnityEngine; namespace RacesOfValheim { /// - /// Claws that are part of the body, for the races that grow a pair. + /// Claws that are part of the body, for the races that grow a pair - as an ACTIVE SKILL. A + /// keypress (RaceClawsConfig.ActivateKey) grows them for RaceClawsConfig.DurationSeconds, and + /// they retract - unequipped and removed from the inventory outright - the moment that timer + /// runs out. Recasting mid-window simply restarts the timer. /// /// This is SvermClawSlot generalised, not reinvented: the Sverm's Chitin Claws worked out /// the whole shape of the problem, and the Aswid and the Fenrir are asking for the same object /// with a different face. So the machinery moved here and each race supplies only what is /// genuinely its own - the item name, the model to wear, and whether it is currently a wolf. - /// The Sverm still runs its own copy, untouched, because it also carries a carapace, a stinger - /// form and a fire term at Fader that none of this knows about. + /// The Sverm still runs its own copy, untouched (permanent, not timed), because it also carries + /// a carapace, a stinger form and a fire term at Fader that none of this knows about. /// /// WHY A REAL ITEM AND NOT A COSMETIC. Bolting a model to the hand bones works right up until /// the game rebuilds equipment visuals - which it does on every equip - and wipes it. A real /// item in a real slot has nothing to put back. The trade is that a real weapon occupies the /// right hand, so three rules keep that reading as intended rather than as a bug: sheathe - /// anything else and the claws come back, the holster key cannot put them away, and they - /// cannot be dragged, moved or dropped. + /// anything else and the claws come back (while the skill is still running), the holster key + /// cannot put them away, and they cannot be dragged, moved or dropped. None of that costs an + /// inventory slot outside the two-minute window any more, which was the whole reason to move + /// off the earlier "issued once, forever" version: a slot permanently occupied by an + /// unremovable item was a standing annoyance, not a feature. /// /// BALANCE IS SHARED ON PURPOSE. The damage is not read from the model each race wears - the /// Fenrir's flesh rippers and the Bjorn claw are not worth the same, and a race should not be /// stronger because its claws are prettier. Every set reads the Sverm's own reference weapon at /// quality 4 and the Sverm's own per-tier percentages, so all three races hit for identical /// numbers at identical tiers. What differs here is the shape of the damage: these two land it - /// entirely as slash, where the Sverm splits it three ways and lights it on fire at Fader. + /// entirely as slash, where the Sverm splits it three ways and lights it on fire at Fader. The + /// damage bonus itself only applies while the claws are the thing actually equipped - see + /// ApplyToUnarmedHit - so a bare-fisted punch after they retract is a bare-fisted punch. /// public abstract class RaceClawSet { @@ -69,21 +78,52 @@ namespace RacesOfValheim // ─── Registry ──────────────────────────────────────────────────────── private static readonly List sets = new List(); + private static bool rosterBuilt; /// /// The roster. Kept here rather than in RacesOfValheim.Awake so the whole feature is this /// file plus one short file per race, and adding a third clawed race is one line - not one /// line here and another one three hundred lines away in the plugin's startup. + /// + /// BUILT LAZILY, AND NOT FROM A STATIC CONSTRUCTOR. That is the fix for a bug that cost the + /// Fenrir this entire feature while the Aswid worked perfectly, which is exactly what made + /// it hard to see: the item registered, the model resolved, the patch ran, and the race + /// resolved to "Fenrir" - the set simply was not in this list. + /// + /// The trap is .NET type initialisation re-entrancy. FenrirRace.CreateModAssets touches + /// FenrirClaws.Instance first (before AswidRace does its own), which starts FenrirClaws's + /// type initialiser; constructing that instance triggers this base type's static + /// constructor, which reaches back for FenrirClaws.Instance - still null, because its field + /// initialiser is halfway through running further down the same stack. The CLR does not + /// wait and does not re-run it: it hands back null. Register(null) then returned quietly and + /// the Fenrir was absent from the roster forever, while the Aswid - reached from inside the + /// static constructor rather than from outside it - was added normally. + /// + /// Called from For/SetOwning, which only ever run from Player.Update and the inventory GUI, + /// long after every type initialiser has finished. Register also complains about a null now + /// rather than swallowing it, so this class of failure is loud the next time. /// - static RaceClawSet() + private static void EnsureRoster() { + if (rosterBuilt) return; + rosterBuilt = true; // set first: a re-entrant call must not build the list twice + Register(AswidClaws.Instance); Register(FenrirClaws.Instance); + + List names = new List(); + foreach (RaceClawSet set in sets) names.Add(set.RaceId); + Jotunn.Logger.LogInfo($"[RaceClaws] Roster: {(names.Count > 0 ? string.Join(", ", names.ToArray()) : "EMPTY")}."); } public static void Register(RaceClawSet set) { - if (set == null || sets.Contains(set)) return; + if (set == null) + { + Jotunn.Logger.LogWarning("[RaceClaws] Refused to register a null claw set - that race will have no claws."); + return; + } + if (sets.Contains(set)) return; sets.Add(set); } @@ -91,6 +131,7 @@ namespace RacesOfValheim public static RaceClawSet For(Player player) { if (player == null) return null; + EnsureRoster(); string race = GetRace(player); foreach (RaceClawSet set in sets) @@ -104,6 +145,7 @@ namespace RacesOfValheim public static RaceClawSet SetOwning(ItemDrop.ItemData item) { if (item == null || item.m_shared == null) return null; + EnsureRoster(); foreach (RaceClawSet set in sets) { @@ -115,6 +157,13 @@ namespace RacesOfValheim /// /// Reads the race off the ZDO, falling back to m_customData - the same order every visual /// in this mod reads it in, so a remote player and the menu preview both answer correctly. + /// + /// "Human" in the ZDO is treated as no answer rather than as an answer, and that is not + /// cosmetic: ResetRace writes exactly that string into the ZDO before reopening the + /// selection menu, so a client whose ZDO write lost the race afterwards would otherwise be + /// stuck reading "Human" forever with a perfectly correct "Fenrir" sitting in m_customData + /// right next to it. Falling through to m_customData costs one dictionary lookup and closes + /// that hole. /// private static string GetRace(Player player) { @@ -122,7 +171,7 @@ namespace RacesOfValheim if (nview != null && nview.IsValid()) { string race = nview.GetZDO().GetString("RacesOfValheim_Race", ""); - if (!string.IsNullOrEmpty(race)) return race; + if (!string.IsNullOrEmpty(race) && race != "Human") return race; } if (player.m_customData != null && player.m_customData.TryGetValue("Race", out string custom)) @@ -133,6 +182,26 @@ namespace RacesOfValheim return "Human"; } + /// + /// Both raw values the race is read from, for the diagnostic line. Kept next to GetRace so + /// the two cannot drift apart. + /// + internal static string DescribeRaceSources(Player player) + { + if (player == null) return "player is null"; + + ZNetView nview = player.GetComponent(); + string zdo = nview == null ? "no ZNetView" + : !nview.IsValid() ? "ZDO not valid" + : $"'{nview.GetZDO().GetString("RacesOfValheim_Race", "")}'"; + + string custom = player.m_customData == null ? "no customData" + : player.m_customData.TryGetValue("Race", out string c) ? $"'{c}'" + : "absent"; + + return $"ZDO={zdo}, customData={custom}, resolved='{GetRace(player)}'"; + } + // ─── Registration of the item ──────────────────────────────────────── private bool registered; @@ -196,9 +265,50 @@ namespace RacesOfValheim registered = true; Jotunn.Logger.LogInfo($"[{RaceId}] Registered '{ItemName}' from '{source.name}'."); + RegisterActiveStatusEffect(drop); RefreshTint(); } + /// + /// The buff the player sees while the claws are out: the claw item's OWN icon, with the + /// countdown the game draws under any effect carrying a m_ttl. No custom HUD, no second + /// timer to keep in sync with this one - vanilla already draws exactly this. + /// + /// Registered from here, which is to say from CreateModAssets, and that timing is the whole + /// point rather than a detail: an earlier version created this effect lazily on the first + /// activation and it never appeared, because Jotunn only takes new entries into ObjectDB at + /// OnVanillaPrefabsAvailable. SEMan.AddStatusEffect then looked the name up, found nothing, + /// and did nothing - silently, exactly the way the claws themselves failed the first time + /// round (see the WarnOnce in MaintainInner). + /// + /// The icon is read off the cloned item rather than named here, so each race shows its own + /// claws and nobody has to remember to update a second list when a model changes. + /// + private void RegisterActiveStatusEffect(ItemDrop drop) + { + Sprite icon = drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null && + drop.m_itemData.m_shared.m_icons != null && drop.m_itemData.m_shared.m_icons.Length > 0 + ? drop.m_itemData.m_shared.m_icons[0] + : null; + + if (icon == null) + { + // Worth saying out loud: the effect still works and still counts down, but a buff + // with no icon is nearly invisible in the HUD, which would read as "the timer is + // broken" rather than "the sprite was missing". + Jotunn.Logger.LogWarning($"[{RaceId}] '{ItemName}' carries no icon, so the claws' buff will show without one."); + } + + StatusEffect se = ScriptableObject.CreateInstance(); + se.name = ActiveSeName; + se.m_name = DisplayName; + se.m_tooltip = "Your claws are out. They retract when this runs out."; + se.m_icon = icon; + + ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(se, fixReference: false)); + Jotunn.Logger.LogInfo($"[{RaceId}] Registered the claws' buff '{ActiveSeName}'."); + } + private GameObject ResolveModel() { foreach (string name in ModelPrefabs) @@ -308,6 +418,124 @@ namespace RacesOfValheim } } + // ─── Active skill: grow, then retract ───────────────────────────────── + + /// + /// Time.time at which the skill's current window ends. Starts in the past, so a set that + /// has never been activated - including a save carried over from before this was a timed + /// skill - reads as inactive and MaintainInner strips whatever leftover item it finds. + /// + private float activeUntil = -1f; + + /// True while the two-minute window is still running. + public bool IsActive => Time.time < activeUntil; + + /// Seconds left on the window, floored at zero. What the HUD timer counts down. + public float SecondsRemaining => Mathf.Max(0f, activeUntil - Time.time); + + /// + /// Published on the local player's own ZDO every Maintain tick, one flag shared by both + /// races (whichever set is running is the only one that could ever be true for a given + /// player, since a player is only ever one race). Read back for a REMOTE attacker in + /// ApplyToUnarmedHit - IsActive itself is this client's own timer and answers nothing about + /// somebody else's, the same problem GetState solves for progression tier. + /// + private const string ClawsActiveZdoKey = "RacesOfValheim_ClawsActive"; + + /// + /// Grows the claws for RaceClawsConfig.DurationSeconds. Safe to call again mid-window - it + /// just restarts the timer rather than stacking or refusing. + /// + public void Activate(Player player) + { + if (player == null || player != Player.m_localPlayer) return; + + // Logged rather than silent: this is the one path a keypress can go nowhere from, and + // "nothing happened" with no line in the log is exactly the failure mode that cost the + // registration timing bug an evening (see the comment in MaintainInner). + if (For(player) != this) + { + Jotunn.Logger.LogInfo( + $"[{RaceId}] Grow-claws key ignored: this player's race is not {RaceId} " + + $"({DescribeRaceSources(player)})."); + return; + } + if (player.IsDead()) + { + Jotunn.Logger.LogInfo($"[{RaceId}] Grow-claws key ignored: player is dead."); + return; + } + if (IsTransformed(player)) + { + Jotunn.Logger.LogInfo($"[{RaceId}] Grow-claws key ignored: player is currently transformed."); + return; + } + + activeUntil = Time.time + RaceClawsConfig.DurationSeconds.Value; + ApplyActiveIcon(RaceClawsConfig.DurationSeconds.Value); + Jotunn.Logger.LogInfo($"[{RaceId}] Grow-claws key pressed: growing the {DisplayName} for {RaceClawsConfig.DurationSeconds.Value}s."); + + // Issues and equips immediately rather than waiting for the next throttled Maintain + // tick, so the keypress reads as instant rather than landing up to half a second late. + Maintain(player); + + PlayGrowAnimation(player); + } + + /// + /// The draw gesture, so the claws arrive with a movement rather than simply being in hand + /// on the next frame. + /// + /// "equip_hip" is not a guess and not a borrowed approximation: it is the trigger vanilla's + /// own Humanoid.ShowHandItems fires when it takes a sheathed weapon back out, read out of + /// assembly_valheim rather than assumed. That makes it exactly the right motion here - the + /// claws are being drawn - and it carries no baked Animation Event, unlike the "gpower" + /// gesture the transformations borrow, which needed a suppressor to stop it casting the + /// player's real Guardian Power (see RaceInput.SuppressGuardianPowerBriefly). + /// + private static void PlayGrowAnimation(Player player) + { + ZSyncAnimation zanim = player.GetComponent(); + if (zanim != null) zanim.SetTrigger("equip_hip"); + } + + // ─── The buff the player sees ──────────────────────────────────────── + + /// + /// One effect per race rather than one shared between them, so each shows its own claws in + /// the buff bar. Derived from the item name, so a new clawed race needs nothing here. + /// + private string ActiveSeName => "SE_" + ItemName + "Active"; + + /// + /// Puts the buff up (or restarts it, if the skill was recast mid-window) and gives it the + /// remaining time. The countdown under the icon is the game's own - see + /// RegisterActiveStatusEffect. + /// + private void ApplyActiveIcon(float seconds) + { + if (Player.m_localPlayer == null || seconds <= 0f) return; + + int hash = ActiveSeName.GetStableHashCode(); + SEMan seman = Player.m_localPlayer.GetSEMan(); + seman.RemoveStatusEffect(hash, true); + seman.AddStatusEffect(hash, true); + + StatusEffect se = seman.GetStatusEffect(hash); + if (se != null) se.m_ttl = seconds; + } + + /// + /// Takes the buff down. The effect's own m_ttl already expires on its own when the window + /// runs out normally; this is for the retractions that happen off the clock - a race change, + /// or a form taken while the claws were still out. + /// + private void ClearActiveIcon(Player player) + { + if (player == null) return; + player.GetSEMan().RemoveStatusEffect(ActiveSeName.GetStableHashCode(), true); + } + // ─── Issue and re-equip ────────────────────────────────────────────── /// @@ -320,8 +548,9 @@ namespace RacesOfValheim private static bool maintaining; /// - /// Makes sure the player owns exactly one pair and is holding them whenever both hands are - /// free. Safe to call on a timer: every step checks first. + /// While the skill is active: makes sure the player owns exactly one pair and is holding + /// them whenever both hands are free. Once the window closes: takes that pair back off the + /// player entirely. Safe to call on a timer either way - every step checks first. /// public void Maintain(Player player) { @@ -340,11 +569,29 @@ namespace RacesOfValheim EnsureRegistered(); RefreshTint(); + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid()) nview.GetZDO().Set(ClawsActiveZdoKey, IsActive); + Inventory inventory = player.GetInventory(); if (inventory == null) return; ItemDrop.ItemData claws = Find(inventory); + // The window has closed (or never opened this session). Retract: unequip if still in + // hand, then remove the item outright - no slot sits occupied between activations, + // which is the entire point of moving this off the old "issued once, forever" design. + if (!IsActive) + { + if (claws != null) + { + if (player.IsItemEquiped(claws)) player.UnequipItem(claws, false); + inventory.RemoveItem(claws); + ClearActiveIcon(player); + Jotunn.Logger.LogInfo($"[{RaceId}] The {DisplayName} retracted."); + } + return; + } + if (claws == null) { GameObject prefab = ObjectDB.instance != null ? ObjectDB.instance.GetItemPrefab(ItemName) : null; @@ -469,7 +716,9 @@ namespace RacesOfValheim } /// - /// Rewrites a bare-handed blow into a claw blow, as slash and nothing else. + /// Rewrites a bare-handed blow into a claw blow, as slash and nothing else - but only while + /// the claws are actually the thing in hand, which since this became a timed skill is no + /// longer every unarmed hit by default. /// /// The figure is the Sverm's - its reference weapon at quality 4, times its percentage for /// this tier - but where the Sverm keeps the weapon's own three-way split, this collapses @@ -482,6 +731,22 @@ namespace RacesOfValheim if (hit == null || attacker == null) return; if (IsTransformed(attacker)) return; // the form is doing its own damage + // Outside the skill's window this is just a bare fist - vanilla's own unarmed damage, + // not the claw tier. IsActive answers for the local player; a remote Aswid/Fenrir's + // punch reads the same flag published on their own ZDO, the same fallback GetState + // uses for progression tier - inventories are not something a remote client can read. + bool active; + if (attacker == Player.m_localPlayer) + { + active = IsActive; + } + else + { + ZNetView nview = attacker.GetComponent(); + active = nview != null && nview.IsValid() && nview.GetZDO().GetBool(ClawsActiveZdoKey, false); + } + if (!active) return; + HitData.DamageTypes reference = SvermClaws.GetReferenceDamage(); float percent = SvermClaws.GetDamagePercent(GetState(attacker)); if (percent <= 0f) return; @@ -501,8 +766,9 @@ namespace RacesOfValheim // ─── Patches ───────────────────────────────────────────────────────────── /// - /// Issues the claws and puts them back in hand. On a throttle rather than every frame: it is a - /// handful of checks that all short-circuit once the claws exist. + /// Reads the activation key every frame (a keypress lasts one frame, so this cannot be + /// throttled), then issues/retracts the claws and puts them back in hand on a throttle - that + /// half is a handful of checks that all short-circuit once state matches the target. /// [HarmonyPatch(typeof(Player), "Update")] public static class RaceClaws_PlayerUpdate_Patch @@ -513,11 +779,27 @@ namespace RacesOfValheim public static void Postfix(Player __instance) { if (__instance != Player.m_localPlayer) return; + + RaceClawSet set = RaceClawSet.For(__instance); + + if (set == null) return; + + if (RaceClawsConfig.ActivateKey.Value.IsDown()) + { + if (RaceInput.Allowed) + { + set.Activate(__instance); + } + else + { + Jotunn.Logger.LogInfo($"[{set.RaceId}] Grow-claws key pressed but ignored: RaceInput.Allowed is false (a menu/GUI has focus)."); + } + } + if (Time.time < next) return; next = Time.time + Interval; - RaceClawSet set = RaceClawSet.For(__instance); - if (set != null) set.Maintain(__instance); + set.Maintain(__instance); } } @@ -591,9 +873,9 @@ namespace RacesOfValheim } /// - /// The tier's damage, on any bare-handed blow. Fist weapons report Unarmed, so this covers both - /// the equipped claws and an actually empty hand - which is what keeps the two halves of the - /// feature agreeing with each other. + /// The tier's damage, on any bare-handed blow - RaceClawSet.ApplyToUnarmedHit itself checks + /// whether the claws are actually equipped, so a genuinely empty hand (skill not running, or + /// still mid-retract) falls through to vanilla's own unarmed damage instead. /// [HarmonyPatch(typeof(Character), nameof(Character.Damage))] public static class RaceClaws_Damage_Patch diff --git a/JotunnModStub/RaceClawsConfig.cs b/JotunnModStub/RaceClawsConfig.cs new file mode 100644 index 0000000..5332d25 --- /dev/null +++ b/JotunnModStub/RaceClawsConfig.cs @@ -0,0 +1,33 @@ +using UnityEngine; +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// The one keybind and the one duration behind the Claws skill (RaceClaws.cs), shared by every + /// race that grows a pair rather than bound separately per race - there is only one skill here, + /// not one per race wearing it. Bound once, from RacesOfValheim.Awake(), alongside the other + /// non-race shared config (WarVultureConfig, ButlerConfig, ...). + /// + /// The default is K rather than O: O was the first pick, but Fenrir already owns it for Howl + /// (FenrirConfig.HowlKey), and colliding the two on one client would leave one of them dead + /// without any error to say why. Either can still be moved onto the other from Configuration + /// Manager if that turns out to be wanted after all. + /// + public static class RaceClawsConfig + { + public static ConfigEntry ActivateKey; + public static ConfigEntry DurationSeconds; + + public static void Bind(ConfigFile config) + { + const string keybinds = "Race Claws - Keybinds"; + ActivateKey = config.Bind(keybinds, "Grow Claws", new KeyboardShortcut(KeyCode.K), + new ConfigDescription("Grows the claws (Aswid: Claws of the Beast, Fenrir: Cursed Claws) for the duration below. Pressed again mid-window, restarts the timer instead of stacking.")); + + const string skill = "Race Claws - Skill"; + DurationSeconds = config.Bind(skill, "Duration", 120f, + new ConfigDescription("Seconds the claws stay grown before retracting on their own. The remaining time shows under the claws' own icon in the buff bar.", new AcceptableValueRange(10f, 600f))); + } + } +} diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 7c9861e..1f232d0 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -328,10 +328,10 @@ namespace RacesOfValheim sb.AppendLine($"[Base Passive] Benedictus et Afflictus:"); sb.AppendLine($"Physical kills automatically consume enemies (Vae Victis) granting Blood Magic XP. Your physical stats scale progressively as you defeat Valheim's Bosses: +{arm} Armor, +{dmg} Damage, +{spd}% Speed, and +{jmp}% Jump. All your passive bonuses are doubled during the night. You can cast Blood Magic items with infinite Eitr, and your Blood Magic skill increases twice as fast.\n"); - sb.AppendLine("Vampiric Aura (Like a Bat out of Hell/Weight of Shadows Only): Block with your shield (Mouse 2) while in bat or mist form to channel an AoE magic damage aura against nearby enemies, healing for 20% of the damage dealt and converting them into food when they die.\n"); + sb.AppendLine("Vampiric Aura (Passive, [I] to toggle): A magic damage aura drains nearby enemies automatically, at all times and in every form - no key to hold. It deals half damage as a human, full as a bat, and double as mist, healing you for 20% of the damage dealt. Weakened enemies are executed outright and converted into food. It cannot tell traders from monsters, so switch it off with [I] before talking to Haldor or Hildir.\n"); // The live figure, so the entry cannot drift from the code: it is the same yardstick // the Sverm's own claws are measured against, which is what keeps the three races even. - sb.AppendLine($"[Base Passive] Claws of the Beast: Blackened claws you did not forge and cannot put down. Bare-handed blows land at {SvermClaws.GetDamagePercent(state) * 100f:0}% of a full-grown pair's weight, all of it as slash, and they grow with every boss that falls. Draw a sword and they wait; sheathe it and they are back. They cannot be dropped, traded or stolen - and in bat or mist form you have no hands to hold them with.\n"); + sb.AppendLine($"Claws of the Beast ([K], {RaceClawsConfig.DurationSeconds.Value:0}s): Grows blackened claws for a limited time instead of a weapon. Bare-handed blows land at {SvermClaws.GetDamagePercent(state) * 100f:0}% of a full-grown pair's weight, all of it as slash, and they grow with every boss that falls. Draw a sword and they wait, sheathe it and they are back, until the timer runs out and they retract on their own - no slot wasted between casts. They cannot be dropped, traded or stolen while grown - and in bat or mist form you have no hands to hold them with.\n"); if (state >= 1) { // Eikthyr - Base passives already covered @@ -373,7 +373,7 @@ namespace RacesOfValheim int arm = state * 3; int dmg = state * 5; knownTexts["Fenrir Secrets"] = $"The secrets of the pack will be revealed soon...\n\nBase Passive: Physical kills automatically consume enemies (if edible). Your physical stats scale progressively as you defeat Valheim's Bosses: +{arm} Armor, +{dmg} Damage, +{spd}% Speed, and +{jmp}% Jump.\n\n" + - $"[Base Passive] Cursed Claws: The wolf's hands, kept on in the man's shape. Bare-handed blows land at {SvermClaws.GetDamagePercent(state) * 100f:0}% of a full-grown pair's weight, all of it as slash, and they grow with every boss that falls. Draw a sword and they wait; sheathe it and they are back. They cannot be dropped, traded or stolen - and in beast form the jaws do the work instead."; + $"Cursed Claws ([K], {RaceClawsConfig.DurationSeconds.Value:0}s): The wolf's hands, kept on in the man's shape for a limited time instead of a weapon. Bare-handed blows land at {SvermClaws.GetDamagePercent(state) * 100f:0}% of a full-grown pair's weight, all of it as slash, and they grow with every boss that falls. Draw a sword and they wait, sheathe it and they are back, until the timer runs out and they retract on their own. They cannot be dropped, traded or stolen while grown - and in beast form the jaws do the work instead."; } private static void GenerateSkadiText(Dictionary knownTexts, int state) diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 18d25ab..c9c1a14 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.4"; + public const string PluginVersion = "1.4.5"; private readonly Harmony harmony = new Harmony(PluginGUID); @@ -46,6 +46,9 @@ namespace RacesOfValheim // Not a race either: the two Bone Servants, shared by the Skeleton and Skadi, so they // bind here rather than inside either race's run. ButlerConfig.Bind(Config); + // Not a race either: the Claws skill Aswid and Fenrir share, so it binds here rather + // than inside either race's run. + RaceClawsConfig.Bind(Config); harmony.PatchAll(); gameObject.AddComponent(); gameObject.AddComponent(); diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 7e1c3cd..d8d1cb6 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -1,3 +1,4 @@ +using System.Collections.Generic; using System.Reflection; using HarmonyLib; using UnityEngine; @@ -158,9 +159,16 @@ namespace RacesOfValheim // SkadiSEManPatch above from tier 1 onward, so the tier 2 "Freezing to Cold" conversion never // gets a chance to run. These two patches scope out just that one environmental check: while // Player.UpdateEnvStatusEffects is running for the local Skadi player, GetDamageModifiers is - // reported as Normal for Frost, so vanilla always attempts to apply the real status and - // SkadiSEManPatch's per-tier logic (block/convert/allow) is what actually decides the outcome. - // Frost damage resistance from hits (SkadiDamagePatch) is untouched by this. + // reported without SE_SkadiStats' own Frost contribution, so vanilla attempts to apply the + // real status and SkadiSEManPatch's per-tier logic (block/convert/allow) is what actually + // decides the outcome. Frost damage resistance from hits (SkadiDamagePatch) is untouched. + // + // Only the race's own contribution is discounted. This used to report a flat Normal, which + // also erased Frost resistance coming from a wolf/lox cape, a frost resistance mead or food: + // a Skadi who had beaten Moder still caught the converted Cold on the Mountain while wearing + // gear that makes a human immune, and below tier 4 caught real Freezing through the same gear. + // The tiered ladder is meant to make the race better than a bare human, never worse than an + // equipped one, so anything the player is actually wearing or drinking still counts. [HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")] public static class SkadiEnvCheckScope { @@ -180,11 +188,38 @@ namespace RacesOfValheim [HarmonyPatch(typeof(Character), "GetDamageModifiers")] public static class SkadiEnvFrostModifierPatch { + private static readonly int SkadiStatsHash = "SE_SkadiStats".GetStableHashCode(); + // Handed to the aura in place of its own list while the recompute runs. SE_Stats applies + // m_mods as-is, so an empty list is simply "this effect grants nothing". + private static readonly List NoMods = new List(); + private static bool recomputing = false; + public static void Postfix(Character __instance, ref HitData.DamageModifiers __result) { - if (SkadiEnvCheckScope.Active && __instance == Player.m_localPlayer) + if (recomputing) return; + if (!SkadiEnvCheckScope.Active || __instance != Player.m_localPlayer) return; + + // Character.GetDamageModifiers composes base modifiers + equipment + status effects, + // and DamageModifiers.Apply keeps the strongest of the lot - there is no way to + // subtract one contributor from a finished result. So the aura is muted and the whole + // thing recomputed: what comes back is exactly what this player would have without + // the race. The recursive call re-enters this postfix, which the flag turns into a + // no-op. The status effect on the player is a clone of the registered prototype + // (SEMan.AddStatusEffect clones on add), hence the lookup by hash rather than + // SkadiRace.skadiCurseSE. + SE_Stats aura = __instance.GetSEMan().GetStatusEffect(SkadiStatsHash) as SE_Stats; + List auraMods = aura != null ? aura.m_mods : null; + + recomputing = true; + if (aura != null) aura.m_mods = NoMods; + try { - __result.m_frost = HitData.DamageModifier.Normal; + __result.m_frost = __instance.GetDamageModifiers(null).m_frost; + } + finally + { + if (aura != null) aura.m_mods = auraMods; + recomputing = false; } } } diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 63fe55c..7980895 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -167,11 +167,24 @@ namespace RacesOfValheim // Update the stats SE if (skadiCurseSE != null) { + int auraHash = skadiCurseSE.name.GetStableHashCode(); + SEMan seman = Player.m_localPlayer.GetSEMan(); + skadiCurseSE.UpdateStats(rules); - if (!Player.m_localPlayer.GetSEMan().HaveStatusEffect(skadiCurseSE.name.GetStableHashCode())) + if (!seman.HaveStatusEffect(auraHash)) { - Player.m_localPlayer.GetSEMan().AddStatusEffect(skadiCurseSE.name.GetStableHashCode(), true); + seman.AddStatusEffect(auraHash, true); } + + // SEMan.AddStatusEffect stores a Clone() of the prototype, so updating + // skadiCurseSE alone only changed the copy that gets stamped out at the next add: + // the aura already running on the player kept whatever tier it was born with. + // Beating a boss mid-session left the old frost modifier and eitr regen in place + // until the effect was re-added (race reselection or a relog) - most visibly at + // the Queen, where Immune never replaced Resistant. Refresh the live one as well; + // UpdateStats is a no-op unless the tier actually moved a value. + SE_SkadiStats liveAura = seman.GetStatusEffect(auraHash) as SE_SkadiStats; + if (liveAura != null) liveAura.UpdateStats(rules); } if (rules.FrostAura) diff --git a/JotunnModStub/Skadi/SkadiStatusEffects.cs b/JotunnModStub/Skadi/SkadiStatusEffects.cs index dc6e3ee..00a7e56 100644 --- a/JotunnModStub/Skadi/SkadiStatusEffects.cs +++ b/JotunnModStub/Skadi/SkadiStatusEffects.cs @@ -27,8 +27,29 @@ namespace RacesOfValheim m_tooltip = "Empowered by the frost."; } + // What the last UpdateStats call actually wrote. SEMan.AddStatusEffect stores a Clone() of + // the registered prototype, so the effect running on the player is a separate object that + // has to be refreshed too (SkadiRace.Update does that) - and both of them are asked to + // update every frame. Rebuilding the mod list each time would churn a List per frame per + // instance, so nothing is rewritten until a tier change actually moves a value. These + // fields are not serialized, so a fresh clone starts at "never applied" and rebuilds once. + private bool statsApplied = false; + private float appliedFrostResistance = 0f; + private float appliedEitrRegenMultiplier = 0f; + public void UpdateStats(SkadiProgression.FormRules rules) { + if (statsApplied && + rules.FrostResistance == appliedFrostResistance && + rules.EitrRegenMultiplier == appliedEitrRegenMultiplier) + { + return; + } + + statsApplied = true; + appliedFrostResistance = rules.FrostResistance; + appliedEitrRegenMultiplier = rules.EitrRegenMultiplier; + m_mods = new List(); if (rules.FrostResistance >= 1f) { diff --git a/README.md b/README.md index adafefb..e6d041d 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions ![Fenrir3](https://wiki.aledanidev.ovh/assets/images/fenrir3.gif) - **Beast Form:** Transform into a wolf-like beast. - **Cultist Form:** Transform into a Cultist to use fire abilities. -- **Cursed Claws:** The wolf's hands, kept on in the man's shape — see [Permanent Claws](#permanent-claws). +- **Cursed Claws:** The wolf's hands, kept on in the man's shape — see [Claws](#claws). - **A Pack of Your Own:** The Pack Trough keeps a standing pack of wolves, ulvs and, late, fenrir — see [Race Stations](#race-stations--companions). - **Progression:** Forms grow as you defeat bosses, unlocking new powers and reducing cooldowns. Immune to fall damage. @@ -53,10 +53,10 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions ![Aswid](https://wiki.aledanidev.ovh/assets/images/aswidchallenge.gif) - **The Vampire:** Life-draining abilities. - **Bat Form:** Press G to become a bat and fly. -- **Blood Magic:** Block to activate a life-draining aura (radius doubled at night, only in Bat or Mist Form). +- **Vampiric Aura:** A passive life-draining aura around you, always on in every form (half damage as human, full as bat, double as mist) — no key to hold. Press **[I]** to toggle it (and Devour) off, e.g. before trading with Haldor or Hildir, since it does not recognize traders from monsters. - **Blood Magic Mastery:** Cast Blood Magic items with infinite Eitr (health cost only). - **Benedictus et Afflictus:** Passive speed/jump bonuses double at night. -- **Claws of the Beast:** Blackened claws you did not forge and cannot put down — see [Permanent Claws](#permanent-claws). +- **Claws of the Beast:** Press [K] to grow blackened claws for a limited time — see [Claws](#claws). - **Burning Eyes:** Spectral green sockets, smoke trailing off them, that hold a red glow only in the final stage. - **Undead Vigor:** Infinite stamina. Consume the lifeforce of enemies instead of eating normal food. @@ -95,7 +95,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions ### 10. Sverm - **Chitin Plating:** You never dress. Chest, legs and helm are carapace worth a full set of the biome ahead of you at every tier — best quality, weightless, no movement penalty. Only cloak and trinket may still be worn. -- **Chitin Claws:** Your hands are the weapon — see [Permanent Claws](#permanent-claws). +- **Chitin Claws:** Your hands are the weapon — see [Claws](#claws). - **Hive Pheromones:** No invertebrate attacks you — leeches, ticks, deathsquitos, seekers and bees all ignore you, from tier zero. - **Toxin Immunity:** Poison cannot touch you. Blunt and fire hit you 40% harder — until Fader, when the fire weakness burns out and comes back as a resistance. - **The Colony:** After the Elder, a Brood Mound, a Hive Market and a roster of insect troops bought with digested biomass. @@ -103,13 +103,15 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions --- -## Permanent Claws +## Claws -Three races grow a pair of their own. The terms are identical for all three: issued once, never dropped or traded, refused by the holster key, and back in your hands the moment your hands are free — draw a sword and the claws wait, sheathe it and they are back. Damage is measured against **one** yardstick rather than against the models each race wears, so the same tier is worth the same whichever race you are, and it climbs with every boss. No pair counts while you are wearing another body: a bat, a mist, a wolf or a deathsquito does its own damage with its own hands. +Three races grow a pair of their own, refused by the holster key and never draggable, moveable or dropped while grown — draw a sword and the claws wait, sheathe it and they are back. Damage is measured against **one** yardstick rather than against the models each race wears, so the same tier is worth the same whichever race you are, and it climbs with every boss. No pair counts while you are wearing another body: a bat, a mist, a wolf or a deathsquito does its own damage with its own hands. - **Aswid — Claws of the Beast:** burned almost black. Lands the whole of it as slash. - **Fenrir — Cursed Claws:** the flesh rippers worn as the game made them. Also pure slash. -- **Sverm — Chitin Claws:** splits the same weight three ways, and sets it alight at Fader. +- **Sverm — Chitin Claws:** splits the same weight three ways, and sets it alight at Fader. Permanent, like the rest of the Sverm's carapace — never times out. + +**Aswid and Fenrir claws are a timed skill, not a permanent fixture:** press **[K]** to grow them for 120 seconds (configurable in Configuration Manager under "Race Claws"); casting again mid-window restarts the timer instead of stacking. When time runs out they retract and are removed from your inventory outright, so they never sit as a dead, unremovable item in a slot between fights. The damage bonus only applies while they are actually equipped. --- @@ -402,6 +404,13 @@ The **Sverm** belongs to no faction. Its Hive Pheromones make every invertebrate ## Changelog +### v1.4.5 +- **CHANGED - Claws are now a timed skill (Aswid & Fenrir):** press **[K]** to grow Claws of the Beast / Cursed Claws for 120 seconds (configurable) instead of holding them forever — they retract and are removed from your inventory when the timer ends, so they never sit as a permanent dead item in a slot. The damage bonus only applies while they're actually equipped. Sverm's Chitin Claws are untouched and stay permanent. Along the way, fixed the Fenrir claws never registering at all (a .NET static-initialization order bug that left Fenrir's set out of the roster while Aswid's worked fine) and a race-detection bug where "Human" written to the ZDO by `resetrace` could shadow a correctly-chosen race. +- **Fix - Vampiric Aura vs traders (Aswid):** the passive aura doesn't distinguish traders from monsters and could execute Haldor, Hildir or other faction merchants on approach. Press **[I]** (same key as Devour) to toggle the Aura off before trading. +- **Fix - Skadi cold resistance:** the race's own frost-check patch was zeroing out *all* frost resistance during the environmental check, including a wolf/lox cape, frost resistance mead or food — so a Skadi with that gear still froze or caught Cold where an equipped human wouldn't. Now only the race's own passive contribution is discounted; worn/drunk resistance counts again. +- **Fix - Skadi aura mid-session:** frost immunity and the Eitr regen bonus only updated on the next relog after a boss kill, because the live status effect was a frozen clone of the one last rebuilt. Both now update immediately — most noticeable at the Queen tier, where Immune replaces Resistant instantly. +- **Compendium/README:** Vampiric Aura and Claws entries rewritten to match current behavior — no longer describe the old block-to-channel aura or the old always-permanent claws. + ### v1.4.4 - **NEW - Bone Servants (Skeleton & Skadi):** two disarmed skeletons, the **Bone Smith** and the **Bone Cook**, summoned at their own table to fetch material from marked chests and keep nearby stations fed — the Smith works the Forge family for Skeleton or Skadi, the Cook works cooking stations and the fermenter for Skadi alone. Full details under [Skeleton & Skadi — Bone Servants](#skeleton--skadi--bone-servants). - **Fix - Race Change:** switching race no longer leaves permanent claws (Aswid, Fenrir, Sverm) stuck in your inventory — resetting your race now strips them along with the rest of that race's stats. diff --git a/manifest.json b/manifest.json index 660f981..78d5bdf 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.4", + "version_number": "1.4.5", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From e9d6e78ec848527c4387381932bdaba4c3a071d6 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Wed, 19 Aug 2026 19:18:24 +0200 Subject: [PATCH 007/273] warvulture --- .../Factions/FactionHostilityPatch.cs | 22 +- JotunnModStub/RaceCompendium.cs | 4 +- JotunnModStub/RaceHostilityManager.cs | 19 +- JotunnModStub/RacesOfValheim.cs | 64 +- JotunnModStub/Sverm/SvermConfig.cs | 76 +- JotunnModStub/Sverm/SvermConfigManagement.cs | 49 +- JotunnModStub/Sverm/SvermPatches.cs | 47 +- JotunnModStub/Sverm/SvermProgression.cs | 4 +- JotunnModStub/Sverm/SvermRace.cs | 8 +- JotunnModStub/Sverm/SvermRavagerAttacks.cs | 88 +++ JotunnModStub/Sverm/SvermRavagerForm.cs | 718 ++++++++++++++++++ JotunnModStub/Sverm/SvermStatusEffects.cs | 38 +- JotunnModStub/Sverm/SvermStingerForm.cs | 384 ---------- README.md | 7 +- manifest.json | 2 +- 15 files changed, 1041 insertions(+), 489 deletions(-) create mode 100644 JotunnModStub/Sverm/SvermRavagerAttacks.cs create mode 100644 JotunnModStub/Sverm/SvermRavagerForm.cs delete mode 100644 JotunnModStub/Sverm/SvermStingerForm.cs diff --git a/JotunnModStub/Factions/FactionHostilityPatch.cs b/JotunnModStub/Factions/FactionHostilityPatch.cs index 48fc181..dffbcdc 100644 --- a/JotunnModStub/Factions/FactionHostilityPatch.cs +++ b/JotunnModStub/Factions/FactionHostilityPatch.cs @@ -69,13 +69,33 @@ namespace RacesOfValheim public static bool IsSameFaction(Player player, Character monster) { if (player == null || monster == null) return false; - if (!player.m_customData.TryGetValue("Race", out string race)) return false; + string race = GetPlayerRace(player); + if (race == null) return false; if (!RaceFactionMobs.TryGetValue(race, out HashSet mobs)) return false; string prefabName = monster.gameObject.name.Replace("(Clone)", "").Trim(); return mobs.Contains(prefabName); } + // m_customData is the local save file's dictionary: it is only ever populated for + // the client's own m_localPlayer, so IsEnemy running on a remote AI owner (a + // dedicated server, or any other nearby player who ends up owning the mob's ZDO) + // read an empty dictionary here and treated every truce as hostile. Every other + // race-aware patch in this project reads "RacesOfValheim_Race" off the ZDO instead + // because that field actually replicates - check it first, and only fall back to + // m_customData for the single-player/local-owner case where the ZDO hasn't been + // written yet (e.g. brand new character before the race pick's Set() call runs). + public static string GetPlayerRace(Player player) + { + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid()) + { + string zdoRace = nview.GetZDO().GetString("RacesOfValheim_Race", ""); + if (!string.IsNullOrEmpty(zdoRace)) return zdoRace; + } + return player.m_customData.TryGetValue("Race", out string race) ? race : null; + } + public static void Postfix(Character a, Character b, ref bool __result) { if (!__result) return; // already not enemies, nothing to add diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 1f232d0..f18caec 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -158,8 +158,8 @@ namespace RacesOfValheim if (rules.FallDamageModifier <= 0f) sb.AppendLine("[Moder Unlock] Vestigial Wings: Small wings, and no ground hard enough to hurt you.\n"); - if (rules.StingerMorph) - sb.AppendLine($"[Yagluth Unlock] Stinger Morph ('{SvermConfigManagement.StingerKey.Value}' Key): Become a deathsquito. Real flight and the creature's own sting - and a body made of paper. It is how you kill, not how you travel.\n"); + if (rules.RavagerForm) + sb.AppendLine($"[Yagluth Unlock] Ravager Strain ('{SvermConfigManagement.RavagerKey.Value}' Key): Become a Seeker Brute. The claws still fight, the carapace is worth double, and nothing about it flies. It is how you hold a fight, not how you leave one.\n"); if (rules.BodyScale > 1f) sb.AppendLine("[Queen Unlock] Surrenal Glands: You stand a tenth larger, and the carapace takes its greatest leap.\n"); diff --git a/JotunnModStub/RaceHostilityManager.cs b/JotunnModStub/RaceHostilityManager.cs index a60aa07..0b6b261 100644 --- a/JotunnModStub/RaceHostilityManager.cs +++ b/JotunnModStub/RaceHostilityManager.cs @@ -24,19 +24,24 @@ namespace RacesOfValheim Player p = playerCharacter as Player; if (p != null) { + // Reads the ZDO copy of the race first - see GetPlayerRace's comment in + // FactionHostilityPatch for why m_customData alone breaks this for anyone + // but the local client (e.g. a dedicated server owning the mob's AI). + string playerRace = FactionHostilityPatch.GetPlayerRace(p); + // Fenrir Race Logic - if (p.m_customData.ContainsKey("Race") && p.m_customData["Race"] == "Fenrir") + if (playerRace == "Fenrir") { string prefabName = monster.gameObject.name.ToLower(); - if (prefabName.Contains("wolf") || prefabName.Contains("fenring") || + if (prefabName.Contains("wolf") || prefabName.Contains("fenring") || prefabName.Contains("ulv") || prefabName.Contains("cultist")) { __result = false; } } - + // Aswid Race Logic - if (p.m_customData.ContainsKey("Race") && p.m_customData["Race"] == "Aswid") + if (playerRace == "Aswid") { string prefabName = monster.gameObject.name.ToLower(); int state = BossProgressionManager.GetCurrentProgressionState(); @@ -51,7 +56,7 @@ namespace RacesOfValheim } // Draugh Race Logic - if (p.m_customData.ContainsKey("Race") && p.m_customData["Race"] == "Draugh") + if (playerRace == "Draugh") { string prefabName = monster.gameObject.name.ToLower(); if (prefabName.Contains("skeleton") || prefabName.Contains("draugr") || @@ -71,7 +76,7 @@ namespace RacesOfValheim // Fuling/Troll "choose" not to fight one - but there is no third state to code // for: vanilla's own damage-response AI already makes any of them retaliate if // the Trenta strikes first, same as it does for Fenrir's wolves above. - if (p.m_customData.ContainsKey("Race") && p.m_customData["Race"] == TrentaConfig.RaceId) + if (playerRace == TrentaConfig.RaceId) { string prefabName = monster.gameObject.name.ToLower(); @@ -105,7 +110,7 @@ namespace RacesOfValheim // // Bonemass is deliberately NOT here. It is a mass of ooze and it would // qualify, but a boss that ignores the player is not a boss. - if (p.m_customData.ContainsKey("Race") && p.m_customData["Race"] == SvermConfig.RaceId) + if (playerRace == SvermConfig.RaceId) { string prefabName = monster.gameObject.name.ToLower(); diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index c9c1a14..5bed9da 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -1074,6 +1074,14 @@ namespace RacesOfValheim { Jotunn.Logger.LogInfo($" param: {param.name} ({param.type})"); } + + // Every clip the controller can play. Parameters only say what CAN be driven, + // not what actually exists to play - a wrong trigger name silently plays nothing, + // so this is the list to check a guessed name against. + foreach (AnimationClip clip in animator.runtimeAnimatorController.animationClips) + { + if (clip != null) Jotunn.Logger.LogInfo($" clip: {clip.name}"); + } } if (!anyAnimator) Jotunn.Logger.LogInfo(" (no Animator found anywhere in the hierarchy)"); @@ -1081,7 +1089,20 @@ namespace RacesOfValheim Humanoid humanoid = prefab.GetComponent(); if (humanoid == null) { - Jotunn.Logger.LogInfo(" (no Humanoid component on the prefab root)"); + // Not every prefab worth checking is a creature - a registered weapon clone + // (e.g. `dumpelder SvermRavagerBite`) is an item on its own, and this is the only + // way to see what a runtime mutation (Attack.Clone() plus field edits) actually + // left on it, as opposed to what the SOURCE creature's own copy still says. + ItemDrop directItem = prefab.GetComponent(); + if (directItem != null) + { + Jotunn.Logger.LogInfo(" (no Humanoid - dumping the prefab's own ItemDrop instead)"); + DumpWeaponAttacks(prefab); + } + else + { + Jotunn.Logger.LogInfo(" (no Humanoid component and no ItemDrop on the prefab root)"); + } } else { @@ -1112,21 +1133,44 @@ namespace RacesOfValheim if (drop == null || drop.m_itemData == null || drop.m_itemData.m_shared == null) return; ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; - Jotunn.Logger.LogInfo($" weapon '{itemPrefab.name}' ({shared.m_name}): damages={DumpDamageTypes(shared.m_damages)}"); + Jotunn.Logger.LogInfo($" weapon '{itemPrefab.name}' ({shared.m_name}): damages={DumpDamageTypes(shared.m_damages)} " + + $"skill={shared.m_skillType}"); DumpAttack("primary", shared.m_attack); DumpAttack("secondary", shared.m_secondaryAttack); } + /// + /// Every field an "identical" replica would need: the hitbox shape (melee reach, angle, + /// height, offset, ray width), how the damage lands (multiplier, multi-hit, through + /// walls, force), the animation, and every VFX slot Attack.Start can fire - start, trail, + /// hit, hit-on-terrain, trigger, burst, plus anything it spawns on top of the swing. + /// private static void DumpAttack(string label, Attack attack) { if (attack == null) return; Jotunn.Logger.LogInfo( $" {label}: animation='{attack.m_attackAnimation}' randomAnimations={attack.m_attackRandomAnimations} " + $"chainLevels={attack.m_attackChainLevels} damageMultiplier={attack.m_damageMultiplier} " + - $"type={attack.m_attackType} range={attack.m_attackRange} angle={attack.m_attackAngle} " + - $"spawnOnTrigger='{(attack.m_spawnOnTrigger != null ? attack.m_spawnOnTrigger.name : "none")}' " + + $"type={attack.m_attackType}"); + Jotunn.Logger.LogInfo( + $" hitbox: range={attack.m_attackRange} angle={attack.m_attackAngle} " + + $"height={attack.m_attackHeight} offset={attack.m_attackOffset} rayWidth={attack.m_attackRayWidth} " + + $"originJoint='{attack.m_attackOriginJoint}' multiHit={attack.m_multiHit} " + + $"hitThroughWalls={attack.m_hitThroughWalls} hitFriendly={attack.m_hitFriendly} " + + $"hitTerrain={attack.m_hitTerrain} forceMultiplier={attack.m_forceMultiplier} " + + $"recoilPushback={attack.m_recoilPushback}"); + Jotunn.Logger.LogInfo( + $" spawnOnTrigger='{(attack.m_spawnOnTrigger != null ? attack.m_spawnOnTrigger.name : "none")}' " + + $"spawnOnHit='{(attack.m_spawnOnHit != null ? attack.m_spawnOnHit.name : "none")}' " + $"projectile='{(attack.m_attackProjectile != null ? attack.m_attackProjectile.name : "none")}'"); + DumpEffectList("startEffect", attack.m_startEffect); + DumpEffectList("trailStartEffect", attack.m_trailStartEffect); + DumpEffectList("hitEffect", attack.m_hitEffect); + DumpEffectList("hitTerrainEffect", attack.m_hitTerrainEffect); + DumpEffectList("triggerEffect", attack.m_triggerEffect); + DumpEffectList("burstEffect", attack.m_burstEffect); + if (attack.m_attackProjectile != null) { Projectile proj = attack.m_attackProjectile.GetComponent(); @@ -1142,6 +1186,18 @@ namespace RacesOfValheim } } + private static void DumpEffectList(string label, EffectList effects) + { + if (effects == null || effects.m_effectPrefabs == null || effects.m_effectPrefabs.Length == 0) return; + + foreach (EffectList.EffectData data in effects.m_effectPrefabs) + { + if (data == null || data.m_prefab == null) continue; + Jotunn.Logger.LogInfo($" {label}: '{data.m_prefab.name}' attach={data.m_attach} " + + $"follow={data.m_follow} childTransform='{data.m_childTransform}'"); + } + } + private static string DumpDamageTypes(HitData.DamageTypes d) { if (d == null) return "none"; diff --git a/JotunnModStub/Sverm/SvermConfig.cs b/JotunnModStub/Sverm/SvermConfig.cs index cda6818..69e7a82 100644 --- a/JotunnModStub/Sverm/SvermConfig.cs +++ b/JotunnModStub/Sverm/SvermConfig.cs @@ -24,8 +24,8 @@ namespace RacesOfValheim public const string RaceId = "Sverm"; public const string StatsSE = "SE_SvermStats"; - public const string StingerSE = "SE_SvermStingerForm"; - public const string StingerCdSE = "SE_SvermStingerCooldown"; + public const string RavagerSE = "SE_SvermRavagerForm"; + public const string RavagerCdSE = "SE_SvermRavagerCooldown"; // Mirrors the ZDO key layout the other races use, so remote clients can work out the tier // without having the local player's progression state. @@ -144,7 +144,7 @@ namespace RacesOfValheim public const int VenomGlandsState = 4; public const int AcidHemolymphState = 4; public const int VestigialWingsState = 5; - public const int StingerMorphState = 6; + public const int RavagerFormState = 6; public const int EitrSacsState = 6; public const int MajesticCarapaceState = 7; public const int SurrenalGlandsState = 7; @@ -231,38 +231,60 @@ namespace RacesOfValheim // ─── Carapace Regeneration (state 8) ───────────────────────────────── public static readonly float CarapaceRegenPerSecond = 0.5f; - // ─── Stinger Morph (state 6) ───────────────────────────────────────── - public const string StingerCreature = "Deathsquito"; - public static readonly float StingerDurationSeconds = 120f; - public static readonly float StingerCooldownSeconds = 480f; + // ─── Ravager Strain (state 6) ──────────────────────────────────────── + // Replaces the old Stinger Morph (a Deathsquito flight form). Players found that form's + // glass-cannon trade too strong for what it cost; this is the opposite shape - no flight, + // no summons, and the fragility multiplier is gone, replaced by a straight armour buff. + // Same duration and cooldown as the form it replaces. + public const string RavagerCreature = "SeekerBrute"; + public static readonly float RavagerDurationSeconds = 120f; // 2 minutes + public static readonly float RavagerCooldownSeconds = 300f; // 5 minutes + + // The Brute's four real attack items, named and verified with `dumpelder SeekerBrute` in + // a live world - not guessed. Their numbers are read once by SvermRavagerAttacks and + // applied by hand in RavagerFormBehavior's own attack coroutines (Physics.OverlapSphere, + // the same method Fenrir and Skadi's forms already use); nothing here is cloned or + // equipped any more. + public const string RavagerBiteWeapon = "SeekerBrute_bite"; // slash 100, left click + public const string RavagerRamWeapon = "SeekerBrute_ram"; // blunt/chop/pickaxe 100, right click / G + public const string RavagerSlamWeapon = "SeekerBrute_groundslam"; // AoE stomp, blunt/chop/pickaxe 120-100-100, middle click /// - /// Multiplier on every point of damage taken while in form. 2.5 means a blow that the - /// carapace would shrug off very nearly ends you. - /// - /// This is the entire cost of the ability and it has to be steep: in form you deal the - /// hardest single hit in the Plains and you can leave any fight by going straight up. The - /// balance is not the cooldown, it is that a single arrow answers you. + /// The Brute's roar. type=None on the real creature - it lands no hit there - but the + /// item still carries real numbers (slash 80, chop 10) nobody ever wired to a hitbox. + /// Players asked for a use for it: a short-cooldown AoE around the player rather than a + /// forward swing, bound to G once G stopped being needed for anything else. /// - public static readonly float StingerFragility = 2.5f; + public const string RavagerTauntWeapon = "SeekerBrute_Taunt"; - // ─── The escort ────────────────────────────────────────────────────── /// - /// Two deathsquitoes called up with the form, and they OUTLIVE it on purpose. - /// - /// Three minutes against the form's two. The extra minute is the whole idea: the form ends - /// wherever it ends, usually in the air, and the Sverm comes back to being a slow armoured - /// thing halfway through a fall. The escort is what covers that minute. Then it dies too. + /// What the carapace's own armour value (SvermCarapace.GetArmor) is multiplied by while + /// the form is up. 2 means the tank doubles its damage reduction for the same two minutes + /// the old form spent being nearly one-shot by anything. /// - public const int EscortCount = 2; - public static readonly float EscortLifetimeSeconds = 180f; - public static readonly float EscortSpawnSpread = 2.5f; + public static readonly float RavagerArmorMultiplier = 2f; + + // ─── The taunt (G) ─────────────────────────────────────────────────── + /// Its own cooldown, short and separate from the main three attacks' own lock timing. + public static readonly float RavagerTauntCooldownSeconds = 10f; + + /// Centred on the player, not projected forward like a swing - a roar goes out, not in. + public static readonly float RavagerTauntRadius = 3f; + + // Candidates tried in order, same PlayEffect pattern MorphIn/MorphOutEffects already use: + // a wrong guess is silently skipped rather than an error. Not confirmed to exist - the + // Brute's own Attack effect slots were all empty when dumped, so if a roar sound exists + // at all it lives somewhere this file has not found yet. + public static readonly string[] RavagerTauntSoundEffects = { "sfx_seeker_brute_taunt", "sfx_seekerbrute_taunt", "sfx_seeker_taunt" }; // ─── Transformation effects ────────────────────────────────────────── - // The Seeker's own spawn and death bursts, verified in the manifest. vfx_boar_death is the - // fallback because it is what the Aswid uses and is certain to exist. - public static readonly string[] MorphInEffects = { "fx_seeker_spawn", "vfx_boar_death" }; - public static readonly string[] MorphOutEffects = { "fx_seeker_death", "vfx_boar_death" }; + // The Seeker's own spawn and death bursts are the verified fallback - carried over from + // the old Stinger Morph, which used them successfully. A Brute-specific pair is tried + // first on the chance this build has one; PlayEffect already skips silently past any name + // that does not resolve, so a wrong guess here costs nothing. vfx_boar_death is the last + // resort because it is what the Aswid uses and is certain to exist. + public static readonly string[] RavagerMorphInEffects = { "fx_seeker_brute_spawn", "fx_seeker_spawn", "vfx_boar_death" }; + public static readonly string[] RavagerMorphOutEffects = { "fx_seeker_brute_death", "fx_seeker_death", "vfx_boar_death" }; // ─── Palette ───────────────────────────────────────────────────────── // Read off a Seeker Soldier. The exposed skin is almost black and matte: what makes the diff --git a/JotunnModStub/Sverm/SvermConfigManagement.cs b/JotunnModStub/Sverm/SvermConfigManagement.cs index 0480f26..72a5051 100644 --- a/JotunnModStub/Sverm/SvermConfigManagement.cs +++ b/JotunnModStub/Sverm/SvermConfigManagement.cs @@ -37,11 +37,12 @@ namespace RacesOfValheim public static ConfigEntry EmberGlowStrength; // ─── Keybinds ──────────────────────────────────────────────────────── - public static ConfigEntry StingerKey; + public static ConfigEntry RavagerKey; - // ─── Stinger Morph, the model ──────────────────────────────────────── - public static ConfigEntry StingerScaleMultiplier; - public static ConfigEntry StingerYawDegrees; + // ─── Ravager Strain, the model ─────────────────────────────────────── + public static ConfigEntry RavagerScaleMultiplier; + public static ConfigEntry RavagerYawDegrees; + public static ConfigEntry RavagerAttackOffsetValue; // ─── Colony caps ───────────────────────────────────────────────────── // Every ceiling on how many things the colony can have alive at once, in one section, so @@ -82,14 +83,15 @@ namespace RacesOfValheim // G, like every other first transformation in the mod - the Aswid's bat, the Fenrir's // wolf, the Dvergar's ping. A character only ever has one race, so they never collide. - StingerKey = config.Bind(keybinds, "Stinger Morph", new KeyboardShortcut(UnityEngine.KeyCode.G), - "Turns into a Deathsquito, and back. Unlocked at Yagluth."); + RavagerKey = config.Bind(keybinds, "Ravager Strain", new KeyboardShortcut(UnityEngine.KeyCode.G), + "Turns into a Seeker Brute, and back. Unlocked at Yagluth."); - const string stinger = "Sverm - Stinger Morph"; + const string ravager = "Sverm - Ravager Strain"; - StingerScaleMultiplier = config.Bind(stinger, "Scale", 1f, - "Multiplies the deathsquito model's OWN authored scale. 1 means 'the size the " + - "game draws one'. Raise it if the insect reads as too small to be you."); + RavagerScaleMultiplier = config.Bind(ravager, "Scale", 1f, + "Multiplies the Seeker Brute model's OWN authored scale. 1 means 'the full size " + + "the game draws one, bulk and all' - the form is meant to be worn at the " + + "creature's own size, not shrunk to fit."); const string nest = "Sverm - Nest"; @@ -180,10 +182,24 @@ namespace RacesOfValheim "infected and producing a worker, so this is the number that really decides how " + "busy a base gets."); - StingerYawDegrees = config.Bind(stinger, "Yaw", 180f, - "Turns the model on the vertical axis, in degrees. The creature's forward is not " + - "the player's, so without this it flies looking back at you. 180 is the usual " + - "answer; try 90 or -90 if it comes out sideways."); + // FOUND IN PLAY: 180, the figure that fixed the flying Deathsquito, faces the Seeker + // Brute straight at the camera - its own forward already matches the player's, unlike + // the Deathsquito's. Different source rig, different answer; 0 is correct here. + RavagerYawDegrees = config.Bind(ravager, "Yaw", 0f, + "Turns the model on the vertical axis, in degrees. 0 is correct for the Seeker " + + "Brute; try 180 (or 90 / -90) if a future model swap ends up facing the wrong way."); + + // FOUND IN PLAY: the hit itself lands where the PLAYER'S own body is, at the Brute's + // native scale (RavagerScale) the visible mouth/claws sit well forward of that - so + // the swing visibly connects a metre or more short of where the model appears to + // bite. Attack.m_attackOffset pushes the hit-detection origin forward from the + // player before m_attackRange is measured out from it; 1.5 is a first guess sized + // against the model's own scale, not a verified figure, so it lives here to be + // walked in by eye rather than baked into SvermConfig as if it were. + RavagerAttackOffsetValue = config.Bind(ravager, "Attack Reach Offset", 1.5f, + "How far forward of the player, in metres, the Brute's attacks are measured from. " + + "Raise it if a swing visibly connects short of the model's mouth/claws; lower it " + + "if it connects well past them."); EmberGlowStrength = config.Bind(ember, "Glow Strength", SvermConfig.EmberGlowStrength, "How hot the chitin burns at Fader. This multiplies an HDR colour and it is applied " + @@ -246,8 +262,9 @@ namespace RacesOfValheim public static float NestVfxScale => NestVfxScaleValue?.Value ?? SvermConfig.NestVfxScale; public static float BeehiveVfxScale => BeehiveVfxScaleValue?.Value ?? SvermConfig.BeehiveVfxScale; - public static float StingerScale => StingerScaleMultiplier?.Value ?? 1f; - public static float StingerYaw => StingerYawDegrees?.Value ?? 180f; + public static float RavagerScale => RavagerScaleMultiplier?.Value ?? 1f; + public static float RavagerYaw => RavagerYawDegrees?.Value ?? 0f; + public static float RavagerAttackOffset => RavagerAttackOffsetValue?.Value ?? 1.5f; public static float SizeSmall => SpineSizeSmall?.Value ?? SvermConfig.SpineSizeSmall; public static float SizeFull => SpineSizeFull?.Value ?? SvermConfig.SpineSizeFull; diff --git a/JotunnModStub/Sverm/SvermPatches.cs b/JotunnModStub/Sverm/SvermPatches.cs index f662304..407004d 100644 --- a/JotunnModStub/Sverm/SvermPatches.cs +++ b/JotunnModStub/Sverm/SvermPatches.cs @@ -37,7 +37,19 @@ namespace RacesOfValheim public static void Postfix(Player __instance, ref float __result) { if (__instance == null || !SvermVisuals.IsSvermPlayer(__instance)) return; - __result += SvermCarapace.GetArmor(SvermVisuals.GetRenderState(__instance)); + + float carapace = SvermCarapace.GetArmor(SvermVisuals.GetRenderState(__instance)); + + // Ravager Strain's whole benefit: the carapace is worth double for as long as the + // form holds. Multiplying only the carapace's own contribution, not the total, + // keeps a cape or trinket's armour honest instead of doubling gear the form had + // nothing to do with. + if (SvermRavagerForm.IsActive) + { + carapace *= SvermConfig.RavagerArmorMultiplier; + } + + __result += carapace; } } @@ -106,26 +118,13 @@ namespace RacesOfValheim int state = SvermVisuals.GetRenderState(attackingPlayer); SvermProgression.SvermRules rules = SvermProgression.GetRules(state); + // Unarmed only - the claws' own tier-scaled blow. Ravager Strain's own hits + // (RavagerFormBehavior.ExecuteDamage) are built with Skills.SkillType.Swords + // on purpose, specifically so they never reach this branch and get overwritten + // by the claws' numbers - the Brute's own damage is meant to stand as-is. if (hit.m_skill == Skills.SkillType.Unarmed) { - // In Stinger Morph the hands are gone and what lands is a needle. The - // deathsquito's own figure is read off the creature, so it stays whatever - // vanilla says a deathsquito is worth; if it could not be read it comes - // back as zeroes and the claws answer instead. - HitData.DamageTypes sting = SvermStingerForm.IsActive - ? SvermStingerForm.GetStingDamage() - : default(HitData.DamageTypes); - - if (sting.m_pierce + sting.m_slash + sting.m_blunt > 0f) - { - hit.m_damage.m_pierce = sting.m_pierce; - hit.m_damage.m_slash = sting.m_slash; - hit.m_damage.m_blunt = sting.m_blunt; - } - else - { - SvermClaws.ApplyToUnarmedHit(hit, state); - } + SvermClaws.ApplyToUnarmedHit(hit, state); } if (rules.VenomOnHit > 0f) @@ -140,13 +139,9 @@ namespace RacesOfValheim SvermProgression.SvermRules victimRules = SvermProgression.GetRules(SvermVisuals.GetRenderState(victim)); - // The whole price of the form: out of the shell, a Sverm is an insect. Applied - // before the blunt and fire terms so it multiplies everything, not just the two - // types the carapace was ever weak to. - if (SvermStingerForm.IsActive) - { - hit.m_damage.Modify(SvermConfig.StingerFragility); - } + // Ravager Strain no longer touches incoming damage directly - its whole benefit is + // the doubled carapace armour applied in Sverm_GetBodyArmor_Patch below, which + // Valheim's own armour formula turns into reduced damage the normal way. if (victimRules.BluntWeakness != 0f && hit.m_damage.m_blunt > 0f) { diff --git a/JotunnModStub/Sverm/SvermProgression.cs b/JotunnModStub/Sverm/SvermProgression.cs index ac1f09b..fabf11e 100644 --- a/JotunnModStub/Sverm/SvermProgression.cs +++ b/JotunnModStub/Sverm/SvermProgression.cs @@ -45,7 +45,7 @@ namespace RacesOfValheim /// How tall the dorsal spines stand, in metres. 0 before they grow. public float SpineSize; - public bool StingerMorph; // the Deathsquito form is unlocked + public bool RavagerForm; // the Seeker Brute form is unlocked public float BodyScale; // Surrenal Glands public float CarapaceRegenPerSecond; public bool Emberform; // black chitin, red burn, burning claws @@ -94,7 +94,7 @@ namespace RacesOfValheim : state >= SvermConfig.VestigialWingsState ? SvermConfig.SpineSizeSmall : 0f, - StingerMorph = state >= SvermConfig.StingerMorphState, + RavagerForm = state >= SvermConfig.RavagerFormState, BodyScale = state >= SvermConfig.SurrenalGlandsState ? SvermConfig.BodyScaleAtQueen : 1f, diff --git a/JotunnModStub/Sverm/SvermRace.cs b/JotunnModStub/Sverm/SvermRace.cs index c883f06..f3f1450 100644 --- a/JotunnModStub/Sverm/SvermRace.cs +++ b/JotunnModStub/Sverm/SvermRace.cs @@ -57,6 +57,10 @@ namespace RacesOfValheim // launches proved a mouth on a shared body is a race between colliders. It has to come // after the nest: its placement gate asks whether one is standing nearby. SvermHiveMarketPiece.Register(); + + // Ravager Strain's worn model, stripped down to a costume here because this is the + // one safe moment to do it - see SvermRavagerForm.BuildTemplate. + SvermRavagerForm.BuildTemplate(); } public static bool IsSverm() @@ -74,8 +78,8 @@ namespace RacesOfValheim SvermAntennae.Tick(Player.m_localPlayer); // Also outside the race guard, and for the same reason: it has to be able to drop the - // form and give the player their body back if they stop being a Sverm mid-flight. - SvermStingerForm.Tick(Player.m_localPlayer); + // form and give the player their body back if they stop being a Sverm mid-transformation. + SvermRavagerForm.Tick(Player.m_localPlayer); if (Player.m_localPlayer == null || !IsSverm()) return; diff --git a/JotunnModStub/Sverm/SvermRavagerAttacks.cs b/JotunnModStub/Sverm/SvermRavagerAttacks.cs new file mode 100644 index 0000000..2bf3567 --- /dev/null +++ b/JotunnModStub/Sverm/SvermRavagerAttacks.cs @@ -0,0 +1,88 @@ +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Seeker Brute's three real damage profiles - a trigger name and a set of real damage + /// numbers, read once from the Brute's own weapons and cached. Nothing is cloned, registered + /// or equipped. + /// + /// THIS REPLACES A WHOLE FILE (SvermRavagerWeapons.cs) THAT TRIED TO EQUIP THE REAL ITEMS AND + /// LET VALHEIM'S OWN Attack.Start RUN. It fought the game at every turn: Humanoid. + /// GetCurrentBlocker routed right-click into a parry because the source items were + /// m_blockable; player.InAttack() stopped rooting the player before the visible clip on the + /// model had actually finished; wiring a working secondary attack meant cloning and mutating + /// Attack objects by hand. None of that is necessary, because this mod already has two + /// working examples of "become a creature and attack" - FenrirBehaviors.cs and + /// DrakeFormBehavior.cs - and NEITHER of them equips anything. A trigger on the model's own + /// Animator plus a timed Physics.OverlapSphere, the same two calls every other transformation + /// in this mod already uses, is the whole mechanism. See RavagerFormBehavior.AttackRoutine. + /// + public static class SvermRavagerAttacks + { + public struct Profile + { + public string Trigger; + public HitData.DamageTypes Damage; + } + + private static Profile bite; + private static Profile ram; + private static Profile slam; + private static Profile taunt; + private static bool read; + + public static Profile Bite { get { EnsureRead(); return bite; } } + public static Profile Ram { get { EnsureRead(); return ram; } } + public static Profile Slam { get { EnsureRead(); return slam; } } + + /// + /// type=None on the real Brute, so its Attack fields (range/angle/hitbox) were never + /// meant to land a hit - only m_attackAnimation and m_damages are trustworthy here, which + /// is why the taunt is handled by its own AoE routine rather than folded into + /// AttackRoutine's forward-swing shape. + /// + public static Profile Taunt { get { EnsureRead(); return taunt; } } + + private static void EnsureRead() + { + if (read) return; + read = true; + + bite = ReadOne(SvermConfig.RavagerBiteWeapon); + ram = ReadOne(SvermConfig.RavagerRamWeapon); + slam = ReadOne(SvermConfig.RavagerSlamWeapon); + taunt = ReadOne(SvermConfig.RavagerTauntWeapon); + } + + private static Profile ReadOne(string sourcePrefabName) + { + GameObject source = Jotunn.Managers.PrefabManager.Cache.GetPrefab(sourcePrefabName); + ItemDrop drop = source != null ? source.GetComponent() : null; + ItemDrop.ItemData.SharedData shared = drop != null ? drop.m_itemData?.m_shared : null; + + if (shared == null) + { + Jotunn.Logger.LogWarning($"[Sverm] No '{sourcePrefabName}' to read Ravager Strain damage " + + "from; that attack will land for nothing."); + return default; + } + + Profile profile = new Profile + { + Trigger = shared.m_attack != null ? (shared.m_attack.m_attackAnimation ?? "") : "", + Damage = shared.m_damages, + }; + + Jotunn.Logger.LogInfo($"[Sverm] Ravager Strain reads '{profile.Trigger}' off '{sourcePrefabName}' - " + + $"{DumpDamage(profile.Damage)}."); + return profile; + } + + private static string DumpDamage(HitData.DamageTypes d) + { + return $"blunt={d.m_blunt:0.#} slash={d.m_slash:0.#} pierce={d.m_pierce:0.#} " + + $"chop={d.m_chop:0.#} pickaxe={d.m_pickaxe:0.#}"; + } + } +} diff --git a/JotunnModStub/Sverm/SvermRavagerForm.cs b/JotunnModStub/Sverm/SvermRavagerForm.cs new file mode 100644 index 0000000..f74a02f --- /dev/null +++ b/JotunnModStub/Sverm/SvermRavagerForm.cs @@ -0,0 +1,718 @@ +using HarmonyLib; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Ravager Strain: from Yagluth on, a Sverm can become a Seeker Brute for two minutes. + /// + /// Replaces the earlier Stinger Morph (a Deathsquito flight form). Players found that form's + /// glass-cannon shape too strong for what it cost, so this is the opposite trade: no flight, + /// no summons, and the carapace is worth twice as much for as long as the form holds - the + /// carapace itself is never removed. Same duration, same cooldown as the form it replaces; + /// only the shape of the trade changed. + /// + /// COMBAT FOLLOWS FENRIR AND SKADI'S OWN PATTERN, not Valheim's weapon system. Nothing gets + /// equipped. Humanoid.StartAttack is blocked outright for as long as the form is up, and + /// RavagerFormBehavior runs its own attack coroutines instead - a trigger on the model's + /// Animator, a timed Physics.OverlapSphere, real damage numbers borrowed from + /// SvermRavagerAttacks. The earlier version tried to clone the Brute's own weapons and let + /// them run through Valheim's real Attack.Start, and it never stopped fighting the game: + /// GetCurrentBlocker turning right-click into a parry, player.InAttack() ending before the + /// visible clip did, wiring a working secondary attack by hand. Left click bites, right click + /// rams, middle click slams, G roars - a short-cooldown AoE around the player rather than a + /// fourth forward swing, since the Brute's own taunt was never a hit in the first place. + /// + public static class SvermRavagerForm + { + public static bool IsActive { get; private set; } + + private static GameObject model; + private static float expiresAt; + private static float nextAllowedAt; + + // Guards the ~1.1s "gpower" gesture in EnterRoutine, and separately the shrink in + // ExitRoutine: without them, a second key press mid-gesture would start a second routine + // on top of the first, the same double-transform bug Aswid's own isTransformingSequence + // flag exists to prevent. + private static bool transforming; + private static bool exiting; + + private static GameObject template; + private static bool templateBuildAttempted; + + // ─── The template ─────────────────────────────────────────────────── + + /// + /// Strips the Seeker Brute's borrowed model down to a costume, once, from a moment where + /// that is safe to do - the same rule ModelBorrow exists to enforce, and the same one + /// WarVultureVisual.BuildTemplate follows for its own borrowed bird. Call it from a + /// CreateAllModAssets-time hook; it no-ops on every call after the first. + /// + /// FOUND IN PLAY: the old code instantiated the source's Animator sub-object directly at + /// Enter() time, mid-gameplay, and never stripped it. The Brute's own footstep-effect + /// script came along for the ride, alive, and spent every frame of the form logging + /// "FAiled to find foot:l.backfoot" because the bones it wanted only exist on the + /// source's own untouched rig - along with whatever else survived (Character, MonsterAI, + /// a Rigidbody, a ZNetView) that this class never meant to carry. + /// + /// DestroyImmediate only, and only because the holder is inactive before the Instantiate + /// below: an active clone would Awake every one of those scripts for a frame before the + /// strip could remove them, which is the exact bug ModelBorrow's own docstring names. + /// Object.Destroy (deferred) would not be safe here for the same reason - by the time it + /// actually runs, the frame that mattered has already passed. + /// + public static void BuildTemplate() + { + if (template != null || templateBuildAttempted) return; + templateBuildAttempted = true; + + GameObject source = PrefabManager.Cache.GetPrefab(SvermConfig.RavagerCreature); + GameObject animated = source != null ? source.GetComponentInChildren()?.gameObject : null; + + if (animated == null) + { + Jotunn.Logger.LogWarning($"[Sverm] No '{SvermConfig.RavagerCreature}' model to build the " + + "Ravager Strain template from; the form will run without a body."); + return; + } + + GameObject holder = new GameObject("SvermRavagerTemplate"); + Object.DontDestroyOnLoad(holder); + holder.SetActive(false); // BEFORE Instantiate: nothing on the copy gets to Awake. + + GameObject copy = Object.Instantiate(animated, holder.transform); + copy.name = "model"; + copy.transform.localPosition = Vector3.zero; + copy.transform.localRotation = Quaternion.identity; + copy.transform.localScale = animated.transform.localScale; + + // Everything that is not a Renderer or a Transform. Animator is a Behaviour, not a + // MonoBehaviour, so it is never touched by the first loop and survives on purpose - + // it is the one live thing this costume is allowed to keep. + foreach (MonoBehaviour behaviour in copy.GetComponentsInChildren(true)) + { + if (behaviour != null) Object.DestroyImmediate(behaviour); + } + foreach (Collider collider in copy.GetComponentsInChildren(true)) + { + if (collider != null) Object.DestroyImmediate(collider); + } + foreach (Rigidbody body in copy.GetComponentsInChildren(true)) + { + if (body != null) Object.DestroyImmediate(body); + } + foreach (ZNetView nview in copy.GetComponentsInChildren(true)) + { + if (nview != null) Object.DestroyImmediate(nview); + } + + template = copy; + Jotunn.Logger.LogInfo($"[Sverm] Ravager Strain template built from '{SvermConfig.RavagerCreature}'."); + } + + // ─── Driver ────────────────────────────────────────────────────────── + + public static void Tick(Player player) + { + if (player == null || player != Player.m_localPlayer) + { + return; + } + + // While the entry gesture (EnterRoutine) or the exit shrink (ExitRoutine) is still + // playing, nothing below should react to a key press or a death mid-sequence. + if (transforming || exiting) return; + + // Death ends it immediately, and so does ceasing to be a Sverm. Both leave a body + // hidden and a bug that is very hard to read, so they are checked before anything + // else - and neither one gets the graceful shrink, on purpose: a corpse or a race + // change is not the moment for a half-second animation, it is the moment to clean up. + if (IsActive && (player.IsDead() || !SvermVisuals.IsSvermPlayer(player))) + { + Exit(player, spendCooldown: false); + return; + } + + if (IsActive && Time.time >= expiresAt) + { + RunExit(player, spendCooldown: true, "The shell recedes."); + return; + } + + // No manual cancel: the form is short (two minutes) on purpose, and letting G end it + // early meant a stray press mid-fight burned the whole cooldown for a form that had + // barely started. While IsActive, the key does nothing at all - the timer is the only + // way out, same as death or losing the race. + if (IsActive) return; + + if (!SvermConfigManagement.RavagerKey.Value.IsDown()) return; + if (!SvermVisuals.IsSvermPlayer(player)) return; + + if (!SvermProgression.Current.RavagerForm) + { + player.Message(MessageHud.MessageType.Center, "The strain has not taken yet."); + return; + } + + if (Time.time < nextAllowedAt) + { + player.Message(MessageHud.MessageType.Center, "The strain is spent."); + return; + } + + if (SvermRace.Instance != null) + { + SvermRace.Instance.StartCoroutine(EnterRoutine(player)); + } + else + { + // No host to run the gesture on - a state that should not happen outside a very + // early loading frame, but the form working ungestured beats it not working at + // all. + Enter(player); + } + } + + /// + /// The transformation's own animation: the same "gpower" arms-raised gesture Aswid, + /// Skadi and Fenrir all borrow for their own transformations (RaceInput's own comment + /// names all three), suppressed so it never fires the player's real Guardian Power. The + /// actual state change - IsActive, the weapons, the hidden body, the worn model - waits + /// out the gesture first, the same order TransformIntoBatRoutine uses in AswidRace.cs. + /// + private static System.Collections.IEnumerator EnterRoutine(Player player) + { + transforming = true; + + ZSyncAnimation zAnim = player.GetComponent(); + if (zAnim != null) + { + RaceInput.SuppressGuardianPowerBriefly(); + zAnim.SetTrigger("gpower"); + } + + yield return new WaitForSeconds(1.1f); + + // The gesture takes over a second; a lot can happen to the player in that window. + if (player == null || player != Player.m_localPlayer || player.IsDead() || !SvermVisuals.IsSvermPlayer(player)) + { + transforming = false; + yield break; + } + + Enter(player); + transforming = false; + } + + // ─── Enter and leave ───────────────────────────────────────────────── + + private static void Enter(Player player) + { + IsActive = true; + expiresAt = Time.time + SvermConfig.RavagerDurationSeconds; + + player.GetSEMan().AddStatusEffect(SvermConfig.RavagerSE.GetStableHashCode(), true); + + Transform visual = player.transform.Find("Visual"); + PlayerVisualHider.Hide(visual, "sverm-ravager"); + + // BuildTemplate is NOT called from here. Enter() runs from Tick(), inside Update, and + // the strip needs DestroyImmediate on an inactive object - safe only from the + // CreateAllModAssets-time hook that actually builds this. If that hook never ran, the + // template stays null and the form falls back to a bare body below rather than + // risking an unsafe strip mid-gameplay. + if (template != null) + { + // A plain Instantiate of an already-stripped template - safe in this context + // (mid-gameplay, inside Update) precisely because nothing left on it can Awake + // into anything. See BuildTemplate for why that matters. + model = Object.Instantiate(template, player.transform.position, player.transform.rotation, player.transform); + model.transform.localPosition = Vector3.zero; + + // SCALE COMES FROM THE SOURCE, not from 1 - same reasoning as the old Stinger + // Morph. The multiplier defaults to 1 (the Brute's own authored size, full bulk, + // by design) and is only there for an eye to correct it against. + Vector3 fullScale = template.transform.localScale * SvermConfigManagement.RavagerScale; + + // Grows in rather than popping to full size at once, starting at half scale and + // reaching full over half a second - the entrance the transformation itself was + // missing. ScaleTween owns the model reference for that half second, not Enter, + // so nothing here needs to wait on it. + model.transform.localScale = fullScale * 0.5f; + if (SvermRace.Instance != null) + { + SvermRace.Instance.StartCoroutine(ScaleTween(model, fullScale * 0.5f, fullScale, 0.5f)); + } + else + { + model.transform.localScale = fullScale; + } + + // Which way the model faces is a thing only an eye can settle, so it is a config + // value and not a constant - same as the old form. + model.transform.localRotation = Quaternion.Euler(0f, SvermConfigManagement.RavagerYaw, 0f); + + model.AddComponent(); + } + else + { + // No model is survivable - the carapace and the armour buff still apply - but it + // is worth saying out loud rather than leaving someone to wonder why they turned + // into nothing. + GameObject bare = new GameObject("SvermRavagerBody"); + bare.transform.SetParent(player.transform, false); + bare.AddComponent(); + model = bare; + } + + PlayEffect(SvermConfig.RavagerMorphInEffects, player.transform.position); + + player.Message(MessageHud.MessageType.Center, "The Ravager Strain takes hold."); + } + + private static void PlayEffect(string[] candidates, Vector3 where) + { + foreach (string name in candidates) + { + GameObject fx = PrefabManager.Cache.GetPrefab(name); + if (fx == null) continue; + + Object.Instantiate(fx, where, Quaternion.identity); + return; + } + } + + private static void Exit(Player player, bool spendCooldown) + { + IsActive = false; + + PlayEffect(SvermConfig.RavagerMorphOutEffects, player.transform.position); + + // Nothing was ever equipped for this form - see the class doc for why - so there is + // nothing to hand back here. SvermClawSlot's own throttled pass (Sverm_PlayerUpdate_Patch) + // keeps the claws maintained regardless of Ravager Strain, on its own schedule. + + if (model != null) + { + // FOUND IN PLAY: Object.Destroy is deferred to the end of the frame, so + // RavagerFormBehavior's own LateUpdate - the one that re-hides the player's + // Visual every frame to kill the equipment-swap flicker - was still firing AFTER + // Show() ran a few lines below, undoing it the instant it happened. Nothing called + // Show() again afterward, so the player (and whatever VisEquipment had just + // rebuilt while unequipping the Ravager weapon above - the carapace included) + // stayed hidden for good. SetActive(false) makes Unity skip every further + // Update/LateUpdate on this GameObject for the rest of the frame even though the + // object itself is not gone yet, which is the only part of "destroyed" that + // actually matters here. + model.SetActive(false); + Object.Destroy(model); + model = null; + } + + player.GetSEMan().RemoveStatusEffect(SvermConfig.RavagerSE.GetStableHashCode()); + + Transform visual = player.transform.Find("Visual"); + PlayerVisualHider.Show(visual, "sverm-ravager-revert"); + + if (spendCooldown) + { + nextAllowedAt = Time.time + SvermConfig.RavagerCooldownSeconds; + player.GetSEMan().AddStatusEffect(SvermConfig.RavagerCdSE.GetStableHashCode(), true); + } + } + + /// Kicks off the graceful exit (shrink, then Exit) if there is a host to run it on. + private static void RunExit(Player player, bool spendCooldown, string message) + { + if (SvermRace.Instance != null) + { + SvermRace.Instance.StartCoroutine(ExitRoutine(player, spendCooldown, message)); + } + else + { + Exit(player, spendCooldown); + if (message != null) player.Message(MessageHud.MessageType.Center, message); + } + } + + /// + /// The mirror of EnterRoutine's grow-in: the model shrinks to half its current scale over + /// half a second before Exit() actually tears anything down, so the form has a send-off + /// instead of a hard cut. Used for the two GRACEFUL exits only (timeout, manual toggle) - + /// death and a race change go through Exit() directly, immediately, on purpose. + /// + private static System.Collections.IEnumerator ExitRoutine(Player player, bool spendCooldown, string message) + { + exiting = true; + + if (model != null) + { + Vector3 current = model.transform.localScale; + yield return ScaleTween(model, current, current * 0.5f, 0.5f); + } + + Exit(player, spendCooldown); + if (message != null) player.Message(MessageHud.MessageType.Center, message); + + exiting = false; + } + + /// + /// Linear scale from to over + /// seconds. Bails cleanly if the target disappears mid-tween + /// rather than assuming it cannot - Exit() is free to destroy the model while this is + /// still yielding. + /// + private static System.Collections.IEnumerator ScaleTween(GameObject target, Vector3 from, Vector3 to, float duration) + { + if (target == null) yield break; + + float elapsed = 0f; + while (elapsed < duration) + { + if (target == null) yield break; + elapsed += Time.deltaTime; + target.transform.localScale = Vector3.Lerp(from, to, elapsed / duration); + yield return null; + } + + if (target != null) target.transform.localScale = to; + } + + // ─── The three attacks ─────────────────────────────────────────────── + + /// + /// Blocks Valheim's own attack system outright for the whole form, the same way + /// SkadiAttackPatch blocks it for the dragon forms. Whatever the player happens to have + /// equipped never swings and never deals damage while this is up; RavagerFormBehavior's + /// own coroutines are the only thing that can land a hit. + /// + [HarmonyPatch(typeof(Humanoid), "StartAttack")] + public static class Sverm_RavagerBlockNativeAttack_Patch + { + public static bool Prefix(Humanoid __instance) + { + if (__instance != Player.m_localPlayer) return true; + return !IsActive; + } + } + + /// No food, no mead, no potions. The form is meant to be survived, not sustained. + [HarmonyPatch(typeof(Humanoid), "UseItem")] + public static class Sverm_RavagerUseItem_Patch + { + public static bool Prefix(Humanoid __instance) + { + if (!IsActive) return true; + return !(__instance is Player player) || player != Player.m_localPlayer; + } + } + } + + /// + /// Locomotion AND combat, both held on every frame while the form is up - built on the same + /// method FenrirFormBehavior and DrakeFormBehavior already use for their own transformations, + /// not on Valheim's weapon system. See SvermRavagerAttacks for why. + /// + /// UNLIKE THE OLD STINGER MORPH, this never touches m_debugFly - the whole point of Ravager + /// Strain is that it stays on the ground. The player moves exactly as they always do; this + /// component only feeds the worn model's own Animator whatever standard Valheim monster + /// parameters it actually has - forward_speed and onGround, the same pair DrakeFormBehavior + /// drives - plus a jump cue IF the Brute's controller turns out to carry one, checked once at + /// Start rather than assumed. Every SetFloat/SetBool/SetTrigger is guarded by that check, the + /// same pattern WarVultureVisual.Has uses: driving a parameter name the controller does not + /// have is a silent no-op in Unity, but the guard is what makes "does it have one" an answer + /// this logs instead of a guess nobody can see. + /// + public class RavagerFormBehavior : MonoBehaviour + { + private Animator anim; + private bool hasForwardSpeed; + private bool hasOnGround; + private bool hasJumpTrigger; + private bool hasJumpBool; + private bool wasGrounded = true; + + // While true, Update skips both the locomotion sync and any new attack input - the same + // gate FenrirFormBehavior's own isAttacking flag uses, and the direct answer to "the + // animation has to finish before the Brute can move": nothing here can start moving the + // model again, or start a second attack, until the coroutine below clears it. + private bool isAttacking; + + // The taunt's own cooldown - short, and tracked separately from the other three, which + // have no cooldown of their own beyond their own lock duration. + private float nextTauntAt; + + // Every distinct trigger name that has been checked against this Animator and found + // present, so PlayAttack does not pass a name to SetTrigger the controller cannot use. + private readonly System.Collections.Generic.HashSet knownTriggers = new System.Collections.Generic.HashSet(); + + private void Start() + { + anim = GetComponentInChildren(); + if (anim == null || anim.runtimeAnimatorController == null) return; + + // The same three settings WarVultureVisual.PrepareAnimator uses on its own borrowed + // model, for the same reasons. applyRootMotion=false: the slam's clip carries real + // baked motion, and left at the default Unity would walk the COSTUME out from under + // its wearer - the model has no collider and no gameplay meaning, only the player + // does, and the player already moves through Valheim's own code, not an animation + // clip. fireEvents=false: attack clips carry animation events aimed at + // CharacterAnimEvent, which BuildTemplate already stripped off this model, so left on + // every swing would log "has no receiver" for nothing. cullingMode: keeps the model + // animating even when it is partly off the bottom of the screen, the way a body + // standing close to the camera often is. + anim.applyRootMotion = false; + anim.fireEvents = false; + anim.cullingMode = AnimatorCullingMode.AlwaysAnimate; + + foreach (AnimatorControllerParameter param in anim.parameters) + { + if (param.type == AnimatorControllerParameterType.Float && param.name == "forward_speed") + hasForwardSpeed = true; + else if (param.type == AnimatorControllerParameterType.Bool && param.name == "onGround") + hasOnGround = true; + else if (param.type == AnimatorControllerParameterType.Trigger && param.name == "jump") + hasJumpTrigger = true; + else if (param.type == AnimatorControllerParameterType.Bool && param.name == "jump") + hasJumpBool = true; + else if (param.type == AnimatorControllerParameterType.Trigger) + knownTriggers.Add(param.name); + } + + Jotunn.Logger.LogInfo($"[Sverm] Ravager Strain model animator: forward_speed={hasForwardSpeed}, " + + $"onGround={hasOnGround}, jump=" + + (hasJumpTrigger ? "trigger" : hasJumpBool ? "bool" : "none") + "."); + } + + /// + /// FOUND IN PLAY: the real body flickered into view on every equipment change elsewhere + /// in the game (a nearby player's gear, a tamed animal, anything that shares + /// VisEquipment's rebuild path) - PlayerVisualHider's own comment already says gear + /// changes make hidden things visible again, which is why it re-sweeps on a timer rather + /// than hiding once. That timer is 0.25s, long enough to be noticed. + /// + /// LateUpdate, not Update: Unity runs every component's Update before any component's + /// LateUpdate in a given frame, so this always runs after whatever rebuilt visuals + /// earlier in the same frame, rather than racing it. Re-hiding every single frame the + /// form is up closes the gap the 0.25s timer leaves open, without touching + /// PlayerVisualHider's own interval, which every other race's hidden body still relies on. + /// + private void LateUpdate() + { + Player player = Player.m_localPlayer; + if (player == null) return; + + Transform visual = player.transform.Find("Visual"); + PlayerVisualHider.Hide(visual, "sverm-ravager"); + } + + private void Update() + { + Player player = Player.m_localPlayer; + if (player == null || player.IsDead()) return; + + if (isAttacking) return; + + bool grounded = player.IsOnGround(); + + if (hasForwardSpeed) + { + Vector3 velocity = player.GetVelocity(); + velocity.y = 0f; + anim.SetFloat("forward_speed", velocity.magnitude); + } + + if (hasOnGround) anim.SetBool("onGround", grounded); + + if (hasJumpTrigger) + { + // The rising edge only, so a trigger fires once per jump rather than once per + // frame spent airborne. + if (!grounded && wasGrounded) anim.SetTrigger("jump"); + } + else if (hasJumpBool) + { + anim.SetBool("jump", !grounded); + } + + wasGrounded = grounded; + + if (!RaceInput.Allowed || !grounded) return; + + // Right click rams, left click bites, middle click slams. All three read raw + // UnityEngine.Input rather than going anywhere near Humanoid.StartAttack, which + // Sverm_RavagerBlockNativeAttack_Patch refuses outright for the whole form - see the + // class doc for why that turned out to be the only reliable option. + if (Input.GetMouseButtonDown(1)) + { + StartCoroutine(AttackRoutine(SvermRavagerAttacks.Ram, 2f, 0.3f, 0.7f)); + } + else if (Input.GetMouseButtonDown(0)) + { + StartCoroutine(AttackRoutine(SvermRavagerAttacks.Bite, 2f, 0.3f, 0.6f)); + } + else if (Input.GetMouseButtonDown(2)) + { + StartCoroutine(AttackRoutine(SvermRavagerAttacks.Slam, 1.2f, 0.4f, 1.0f)); + } + else if (SvermConfigManagement.RavagerKey.Value.IsDown() && Time.time >= nextTauntAt) + { + nextTauntAt = Time.time + SvermConfig.RavagerTauntCooldownSeconds; + StartCoroutine(TauntRoutine()); + } + } + + /// + /// One swing: play the clip, wait for the moment it should land, hit whatever is there, + /// then hold isAttacking until the swing is fully spent. FenrirFormBehavior.ClawRoutine in + /// every particular except the damage itself, which here is the Brute's own real numbers + /// (SvermRavagerAttacks) instead of one tuned float. + /// + private System.Collections.IEnumerator AttackRoutine(SvermRavagerAttacks.Profile profile, float radius, + float hitDelay, float lockDuration) + { + isAttacking = true; + + if (hasForwardSpeed) anim.SetFloat("forward_speed", 0f); + + if (!string.IsNullOrEmpty(profile.Trigger) && knownTriggers.Contains(profile.Trigger)) + { + anim.SetTrigger(profile.Trigger); + } + + yield return new WaitForSeconds(hitDelay); + + ExecuteDamage(profile, radius); + + float remaining = lockDuration - hitDelay; + if (remaining > 0f) yield return new WaitForSeconds(remaining); + + isAttacking = false; + } + + /// + /// The taunt, played as a short-cooldown AoE around the player rather than a forward + /// swing - the roar reaches out in every direction, so the sphere is centred on the + /// player instead of offset ahead of them the way AttackRoutine's three do. Deliberately + /// silent: no message, no status effect, nothing in a corner of the screen - just the + /// animation, the sound if one resolves, and the hit. + /// + private System.Collections.IEnumerator TauntRoutine() + { + isAttacking = true; + + SvermRavagerAttacks.Profile profile = SvermRavagerAttacks.Taunt; + + if (hasForwardSpeed) anim.SetFloat("forward_speed", 0f); + + if (!string.IsNullOrEmpty(profile.Trigger) && knownTriggers.Contains(profile.Trigger)) + { + anim.SetTrigger(profile.Trigger); + } + + PlaySound(SvermConfig.RavagerTauntSoundEffects); + + yield return new WaitForSeconds(0.3f); + + Player player = Player.m_localPlayer; + if (player != null) + { + ApplyDamageInSphere(player.transform.position + Vector3.up, SvermConfig.RavagerTauntRadius, profile.Damage); + } + + yield return new WaitForSeconds(0.4f); + + isAttacking = false; + } + + /// Tries each candidate in order and plays the first that resolves, same as SvermRavagerForm.PlayEffect. + private static void PlaySound(string[] candidates) + { + Player player = Player.m_localPlayer; + if (player == null) return; + + foreach (string name in candidates) + { + GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab(name); + if (prefab == null) continue; + + Object.Instantiate(prefab, player.transform.position, Quaternion.identity); + return; + } + } + + /// + /// FenrirBehaviors.ExecuteClawDamage, unchanged in shape: a sphere swept against the same + /// broad layer mask every melee form in this mod already uses. + /// + private void ExecuteDamage(SvermRavagerAttacks.Profile profile, float radius) + { + Player player = Player.m_localPlayer; + if (player == null) return; + + float reach = SvermConfigManagement.RavagerAttackOffset; + Vector3 attackPoint = player.transform.position + player.transform.forward * reach + Vector3.up; + ApplyDamageInSphere(attackPoint, radius, profile.Damage); + } + + /// + /// The actual sweep, shared by every attack this form has (the three forward swings and + /// the taunt's own AoE) - only the sphere's centre and radius differ between them. + /// + /// m_skill is Swords, deliberately NOT Unarmed: Sverm_Damage_Patch rewrites any Unarmed + /// hit from a Sverm into the Chitin Claws' own tier damage, and that patch fires for THIS + /// call too, since it hooks Character.Damage itself rather than caring who dealt the hit. + /// Swords keeps that rewrite from overwriting the Brute's real numbers with the claws'. + /// + private static void ApplyDamageInSphere(Vector3 center, float radius, HitData.DamageTypes damage) + { + Player player = Player.m_localPlayer; + if (player == null) return; + + int layerMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", + "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", + "hitbox", "character_noenv", "vehicle"); + + Collider[] hits = Physics.OverlapSphere(center, radius, layerMask); + var hitObjects = new System.Collections.Generic.HashSet(); + + foreach (Collider hit in hits) + { + if (hit.gameObject == player.gameObject) continue; + if (hit.attachedRigidbody != null && hit.attachedRigidbody.gameObject == player.gameObject) continue; + + IDestructible target = hit.GetComponentInParent(); + if (target == null) continue; + + if (target is Character characterTarget && characterTarget == player) continue; + + GameObject targetObj = (target as MonoBehaviour)?.gameObject; + if (targetObj != null) + { + if (hitObjects.Contains(targetObj)) continue; + hitObjects.Add(targetObj); + } + + Vector3 targetCenter = hit.bounds.center; + Vector3 dirToTarget = (targetCenter - player.transform.position).normalized; + + HitData hitData = new HitData(); + hitData.m_damage = damage; + hitData.m_point = targetCenter; + hitData.m_dir = dirToTarget; + hitData.m_pushForce = 40f; + hitData.m_skill = Skills.SkillType.Swords; + hitData.m_dodgeable = true; + hitData.m_blockable = true; + hitData.m_hitType = HitData.HitType.PlayerHit; + hitData.m_toolTier = 100; + hitData.SetAttacker(player); + + target.Damage(hitData); + } + } + } +} diff --git a/JotunnModStub/Sverm/SvermStatusEffects.cs b/JotunnModStub/Sverm/SvermStatusEffects.cs index 190856e..7d05d34 100644 --- a/JotunnModStub/Sverm/SvermStatusEffects.cs +++ b/JotunnModStub/Sverm/SvermStatusEffects.cs @@ -92,29 +92,37 @@ namespace RacesOfValheim } /// - /// Stinger Morph's cooldown. Purely a marker with a countdown, the way + /// Ravager Strain's cooldown. Purely a marker with a countdown, the way /// SE_DvergarAbilityCooldown is: Valheim prints the remaining time of any effect with a m_ttl, /// so the HUD comes for free. /// - public class SE_SvermStingerCooldown : StatusEffect + public class SE_SvermRavagerCooldown : StatusEffect { public override void Setup(Character character) { base.Setup(character); - m_name = "Stinger Morph Cooldown"; - m_tooltip = "The wings are spent. They will carry you again soon."; - m_ttl = SvermConfig.StingerCooldownSeconds; + m_name = "Ravager Strain Cooldown"; + m_tooltip = "The strain is spent. It will take again soon."; + m_ttl = SvermConfig.RavagerCooldownSeconds; } } - /// Held while the Deathsquito form is up, so anything can ask "am I a bug right now". - public class SE_SvermStingerForm : StatusEffect + /// + /// Held while the Seeker Brute form is up, so anything can ask "am I wearing the Brute right + /// now". FOUND IN PLAY: without m_ttl, this icon showed with no countdown at all while the + /// cooldown icon right next to it did - the same top-right corner telling two different + /// stories about how a timer works. Setting it means the HUD counts the form down to zero the + /// same way it already counts the cooldown down, and the two hand off from one to the other + /// exactly as SvermRavagerForm.Exit/Enter's own timers do. + /// + public class SE_SvermRavagerForm : StatusEffect { public override void Setup(Character character) { base.Setup(character); - m_name = "Stinger Morph"; - m_tooltip = "Wings, a needle, and nothing to hide behind."; + m_name = "Ravager Strain"; + m_tooltip = "The shell doubles, and nothing that hits it lands the same again."; + m_ttl = SvermConfig.RavagerDurationSeconds; } } @@ -136,15 +144,15 @@ namespace RacesOfValheim ItemManager.Instance.AddStatusEffect(customStats); StatsSE = customStats.StatusEffect as SE_SvermStats; - var form = ScriptableObject.CreateInstance(); - form.name = SvermConfig.StingerSE; - form.m_name = "Stinger Morph"; + var form = ScriptableObject.CreateInstance(); + form.name = SvermConfig.RavagerSE; + form.m_name = "Ravager Strain"; form.m_icon = icon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(form, fixReference: false)); - var cooldown = ScriptableObject.CreateInstance(); - cooldown.name = SvermConfig.StingerCdSE; - cooldown.m_name = "Stinger Morph Cooldown"; + var cooldown = ScriptableObject.CreateInstance(); + cooldown.name = SvermConfig.RavagerCdSE; + cooldown.m_name = "Ravager Strain Cooldown"; cooldown.m_icon = icon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(cooldown, fixReference: false)); } diff --git a/JotunnModStub/Sverm/SvermStingerForm.cs b/JotunnModStub/Sverm/SvermStingerForm.cs deleted file mode 100644 index a3a789e..0000000 --- a/JotunnModStub/Sverm/SvermStingerForm.cs +++ /dev/null @@ -1,384 +0,0 @@ -using HarmonyLib; -using Jotunn.Managers; -using UnityEngine; - -namespace RacesOfValheim -{ - /// - /// Stinger Morph: from Yagluth on, a Sverm can become a Deathsquito for two minutes. - /// - /// It is the one thing in the race that is not armour. Everything else the Sverm has says - /// "stand there and survive"; this says the opposite, and it is deliberate that the two do not - /// overlap - in form there is no carapace, no claws, no inventory and no hammer, only a needle - /// and the ability to leave. A glass cannon that flies is the role the tank was missing. - /// - /// Built on two things that already work: BatFormBehavior for flight (Valheim's own - /// m_debugFly, held on every frame) and PlayerVisualHider for swapping the body out. The - /// duration and cooldown follow FenrirProgression.FormRules' shape - a timer and a status - /// effect the HUD can count down - without borrowing that race's tables. - /// - public static class SvermStingerForm - { - public static bool IsActive { get; private set; } - - private static GameObject model; - private static float expiresAt; - private static float nextAllowedAt; - - private static HitData.DamageTypes stingerDamage; - private static bool stingerDamageRead; - - // ─── Driver ────────────────────────────────────────────────────────── - - public static void Tick(Player player) - { - if (player == null || player != Player.m_localPlayer) - { - return; - } - - // Death ends it immediately, and so does ceasing to be a Sverm. Both leave a body - // hidden and a bug that is very hard to read, so they are checked before anything else. - if (IsActive && (player.IsDead() || !SvermVisuals.IsSvermPlayer(player))) - { - Exit(player, spendCooldown: false); - return; - } - - if (IsActive && Time.time >= expiresAt) - { - Exit(player, spendCooldown: true); - player.Message(MessageHud.MessageType.Center, "The wings fold away."); - return; - } - - if (!SvermConfigManagement.StingerKey.Value.IsDown()) return; - if (!SvermVisuals.IsSvermPlayer(player)) return; - - if (IsActive) - { - Exit(player, spendCooldown: true); - return; - } - - if (!SvermProgression.Current.StingerMorph) - { - player.Message(MessageHud.MessageType.Center, "Your wings are still vestigial."); - return; - } - - if (Time.time < nextAllowedAt) - { - player.Message(MessageHud.MessageType.Center, "The wings are spent."); - return; - } - - Enter(player); - } - - // ─── Enter and leave ───────────────────────────────────────────────── - - private static void Enter(Player player) - { - // THE CLAWS STAY ON, and everything else comes off. - // - // The first version emptied the hands completely and the form could not attack: with - // nothing equipped there is no weapon to swing, and Valheim's bare fist is not the - // thing this form is supposed to be throwing. Leaving the Chitin Claws equipped makes the - // sting an ordinary weapon attack - which works - and costs nothing visually, because - // the whole body is hidden a line later. Fist weapons report Skills.SkillType.Unarmed, - // so the damage patch still recognises the blow and swaps the deathsquito's figure in. - ItemDrop.ItemData held = Traverse.Create((Humanoid)player).Field("m_rightItem").Value; - if (held != null && !SvermClawSlot.IsClaws(held)) - { - player.UnequipItem(held, false); - SvermClawSlot.Maintain(player); // hands back the claws in its place - } - - IsActive = true; - expiresAt = Time.time + SvermConfig.StingerDurationSeconds; - - player.GetSEMan().AddStatusEffect(SvermConfig.StingerSE.GetStableHashCode(), true); - - Transform visual = player.transform.Find("Visual"); - PlayerVisualHider.Hide(visual, "sverm-stinger"); - - GameObject source = PrefabManager.Cache.GetPrefab(SvermConfig.StingerCreature); - GameObject animated = source != null ? source.GetComponentInChildren()?.gameObject : null; - - if (animated != null) - { - model = Object.Instantiate(animated, player.transform.position, player.transform.rotation, player.transform); - model.transform.localPosition = Vector3.zero; - - // SCALE COMES FROM THE SOURCE, not from 1. - // - // Forcing Vector3.one is what the Aswid does for the bat and it happens to be - // right there, because a bat's animated child is authored at 1. A deathsquito's is - // not - forcing 1 blew it up to something the size of a house. Keeping the source's - // own scale means the model arrives the size the game draws it, and the multiplier - // is there only for taste. - model.transform.localScale = animated.transform.localScale * SvermConfigManagement.StingerScale; - - // AND IT FACES THE WRONG WAY without this. The creature's own forward is not the - // player's, so the model arrived looking back at the camera. Which way to turn it - // is a thing only an eye can settle, so it is a config value and not a constant. - model.transform.localRotation = Quaternion.Euler(0f, SvermConfigManagement.StingerYaw, 0f); - - model.AddComponent(); - } - else - { - // No model is survivable - you fly as an invisible insect - but it is worth saying - // out loud rather than leaving someone to wonder why they turned into nothing. - Jotunn.Logger.LogWarning($"[Sverm] No '{SvermConfig.StingerCreature}' model to wear; " + - "Stinger Morph flies without a body."); - GameObject bare = new GameObject("SvermStingerFlight"); - bare.transform.SetParent(player.transform, false); - bare.AddComponent(); - model = bare; - } - - PlayEffect(SvermConfig.MorphInEffects, player.transform.position); - SummonEscort(player); - - player.Message(MessageHud.MessageType.Center, "You take to the air."); - } - - /// - /// Two deathsquitoes, tamed, that outlive the form by a minute. - /// - /// They are NOT tied to the form's lifetime and that is the point: the form ends where it - /// ends, usually mid-air, and the player becomes a slow armoured thing halfway through a - /// fall. The escort covers exactly that minute and then dies on its own. - /// - /// Tamed rather than merely friendly, because tamed is the one state every part of the - /// game already understands - they will not be attacked by the player, they will not - /// attack the player, and BaseAI already knows to fight what fights them. - /// - private static void SummonEscort(Player player) - { - GameObject prefab = PrefabManager.Cache.GetPrefab(SvermConfig.StingerCreature); - if (prefab == null) return; - - for (int i = 0; i < SvermConfig.EscortCount; i++) - { - // Spread them apart, and above: spawning two creatures inside each other and - // inside the player is how you get three things shoved through the floor. - float angle = 360f / Mathf.Max(1, SvermConfig.EscortCount) * i; - Vector3 offset = Quaternion.Euler(0f, angle, 0f) * Vector3.forward * SvermConfig.EscortSpawnSpread; - Vector3 where = player.transform.position + offset + Vector3.up * 1.5f; - - GameObject spawned = Object.Instantiate(prefab, where, Quaternion.identity); - if (spawned == null) continue; - - Character character = spawned.GetComponent(); - if (character != null) character.SetTamed(true); - - // Nothing to farm: an escort that dropped trophies would be a deathsquito printer - // on an eight minute cooldown. Same reasoning as the thralls' stripped drop tables. - CharacterDrop drop = spawned.GetComponent(); - if (drop != null) Object.Destroy(drop); - - spawned.AddComponent().Expires = Time.time + SvermConfig.EscortLifetimeSeconds; - } - } - - private static void PlayEffect(string[] candidates, Vector3 where) - { - foreach (string name in candidates) - { - GameObject fx = PrefabManager.Cache.GetPrefab(name); - if (fx == null) continue; - - Object.Instantiate(fx, where, Quaternion.identity); - return; - } - } - - private static void Exit(Player player, bool spendCooldown) - { - IsActive = false; - - PlayEffect(SvermConfig.MorphOutEffects, player.transform.position); - - // The escort is deliberately NOT dismissed here. It has its own minute left to run. - - if (model != null) - { - Object.Destroy(model); - model = null; - } - - player.GetSEMan().RemoveStatusEffect(SvermConfig.StingerSE.GetStableHashCode()); - - Transform visual = player.transform.Find("Visual"); - PlayerVisualHider.Show(visual, "sverm-stinger-revert"); - - if (spendCooldown) - { - nextAllowedAt = Time.time + SvermConfig.StingerCooldownSeconds; - player.GetSEMan().AddStatusEffect(SvermConfig.StingerCdSE.GetStableHashCode(), true); - } - } - - // ─── The sting ─────────────────────────────────────────────────────── - - /// - /// The Deathsquito's own damage, read off the creature rather than invented. - /// - /// Vanilla's deathsquito hits harder per blow than anything else in the Plains, and that - /// number is the entire reason the form is worth its cooldown. Reading it means the form - /// tracks whatever the game says a deathsquito is worth, forever. - /// - public static HitData.DamageTypes GetStingDamage() - { - if (stingerDamageRead) return stingerDamage; - - GameObject creature = PrefabManager.Cache.GetPrefab(SvermConfig.StingerCreature); - Humanoid humanoid = creature != null ? creature.GetComponent() : null; - - if (humanoid != null && humanoid.m_defaultItems != null) - { - foreach (GameObject weapon in humanoid.m_defaultItems) - { - ItemDrop drop = weapon != null ? weapon.GetComponent() : null; - if (drop == null || drop.m_itemData == null || drop.m_itemData.m_shared == null) continue; - - stingerDamage = drop.m_itemData.m_shared.m_damages; - stingerDamageRead = true; - Jotunn.Logger.LogInfo($"[Sverm] Stinger reads {stingerDamage.m_pierce:0.#} pierce " + - $"off '{weapon.name}'."); - return stingerDamage; - } - } - - Jotunn.Logger.LogWarning($"[Sverm] Could not read a weapon off '{SvermConfig.StingerCreature}'; " + - "the sting falls back to the Chitin Claws."); - stingerDamageRead = true; - return stingerDamage; // all zeroes: the damage patch then leaves the claw values alone - } - - // ─── What the form may not do ──────────────────────────────────────── - - /// - /// No weapons in form, which also means no hammer - so "cannot build" needs no patch of - /// its own, it falls out of having nothing to build with. - /// - [HarmonyPatch(typeof(Humanoid), nameof(Humanoid.EquipItem))] - public static class Sverm_StingerEquip_Patch - { - public static bool Prefix(Humanoid __instance, ItemDrop.ItemData item, ref bool __result) - { - if (!IsActive) return true; - - Player player = __instance as Player; - if (player == null || player != Player.m_localPlayer) return true; - - // The claws are the exception, and they have to be: they are what the form - // attacks with, and SvermClawSlot.Maintain hands them back whenever the hands go - // empty. Refusing them here would fight that loop every half second. - if (SvermClawSlot.IsClaws(item)) return true; - - player.Message(MessageHud.MessageType.Center, "An insect carries nothing."); - __result = false; - return false; - } - } - - /// No food, no mead, no potions. The form is meant to be survived, not sustained. - [HarmonyPatch(typeof(Humanoid), "UseItem")] - public static class Sverm_StingerUseItem_Patch - { - public static bool Prefix(Humanoid __instance) - { - if (!IsActive) return true; - return !(__instance is Player player) || player != Player.m_localPlayer; - } - } - } - - /// - /// An escort deathsquito's own clock. - /// - /// It dies rather than vanishing - Character.Damage with enough to finish it - so the death - /// plays its effects and reads as the summon running out rather than as a creature popping out - /// of existence. The drop table was stripped at spawn, so dying costs the world nothing. - /// - public class SvermEscortLife : MonoBehaviour - { - public float Expires; - - private void Update() - { - if (Time.time < Expires) return; - - Character character = GetComponent(); - if (character == null || character.IsDead()) - { - // ZNetScene.Destroy, NEVER Object.Destroy, and this line was the teleport crash. - // - // An escort is a real networked creature, and ZNetView.OnDestroy - read out of the - // assembly, not assumed - only releases asset references: it does not take the - // object out of ZNetScene.m_instances. A plain Object.Destroy therefore left the - // scene holding a dead ZNetView, and the next time the world unloaded around the - // player, which is exactly what a teleport is, ZNetScene.RemoveObjects walked that - // entry and threw. See ZNetSceneOrphanPatch.cs for the whole chain. - if (ZNetScene.instance != null) ZNetScene.instance.Destroy(gameObject); - else Destroy(gameObject); - return; - } - - HitData hit = new HitData(); - hit.m_damage.m_damage = character.GetMaxHealth() * 10f; - hit.m_point = character.GetCenterPoint(); - character.Damage(hit); - - enabled = false; // the death takes a moment; do not queue another blow every frame - } - } - - /// - /// Flight, held on every frame. - /// - /// m_debugFly is Valheim's own free-flight switch and it is re-asserted every Update rather - /// than set once, because plenty of things in the game turn it back off - the same reason - /// BatFormBehavior does it that way. OnDestroy putting it back is what stops a Sverm from - /// walking on air after the form ends. - /// - public class StingerFormBehavior : MonoBehaviour - { - private Animator anim; - - private void Start() - { - anim = GetComponentInChildren(); - SetFly(true); - } - - private void Update() - { - if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return; - - SetFly(true); - - if (anim == null) return; - - Vector3 velocity = Player.m_localPlayer.GetVelocity(); - velocity.y = 0f; - anim.SetFloat("forward_speed", velocity.magnitude); - anim.SetBool("flying", true); - } - - private void OnDestroy() - { - SetFly(false); - } - - private static void SetFly(bool on) - { - if (Player.m_localPlayer == null) return; - Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(on); - } - } -} diff --git a/README.md b/README.md index e6d041d..bacba17 100644 --- a/README.md +++ b/README.md @@ -99,7 +99,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions - **Hive Pheromones:** No invertebrate attacks you — leeches, ticks, deathsquitos, seekers and bees all ignore you, from tier zero. - **Toxin Immunity:** Poison cannot touch you. Blunt and fire hit you 40% harder — until Fader, when the fire weakness burns out and comes back as a resistance. - **The Colony:** After the Elder, a Brood Mound, a Hive Market and a roster of insect troops bought with digested biomass. -- **Stinger Morph:** After Yagluth, become a deathsquito — real flight and the creature's own sting, on a body made of paper. +- **Ravager Strain:** After Yagluth, become a Seeker Brute — the claws keep fighting, and the carapace is worth double. --- @@ -233,7 +233,7 @@ Right Mouse toggles flight. Glide towards aim, W = forward/climb, Shift+W = use - **Elder:** Grinding Mandibles – seeds are food (raw nourishment, no garden buffs). Sensory Antennae – feel what lives around you, through stone and soil. **The colony wakes:** Brood Mound unlocked. - **Bonemass:** Venom Glands – every blow carries bonus poison, growing per tier. Acid Hemolymph – melee attackers take poison back. - **Moder:** Vestigial Wings – no fall damage, and small wings appear. -- **Yagluth:** Stinger Morph (configurable key) – become a deathsquito: real flight and its sting, on a fragile body. +- **Yagluth:** Ravager Strain (configurable key) – become a Seeker Brute: claws still fight, carapace armour doubles, same duration and cooldown. - **Queen:** Surrenal Glands – 10% larger, and the carapace takes its greatest leap. - **Fader:** Carapace Regeneration – 0.5 health a second, always. Annealed Chitin and Emberform – fire stops hurting you and becomes a 40% resistance; the chitin goes black with a red heat under it. @@ -404,6 +404,9 @@ The **Sverm** belongs to no faction. Its Hive Pheromones make every invertebrate ## Changelog +### v1.4.6 +- **Fix - Race truces in multiplayer:** every race's mob-truce check (Fenrir/wolves, Aswid, Draugh, Trenta, Sverm, and Skadi/Fenrir/Dvergar's Montagna set including the Drake) read the player's race from a local-only field that is never populated for anyone but your own client. On a dedicated server, or whenever another player ended up owning a mob's AI, the check silently failed and the "neutral" mob stayed hostile — this is why Skadi players were seeing Drakes attack them. Both hostility patches now read the race from the ZDO copy that actually replicates over the network, falling back to the local field only when the ZDO isn't available yet. + ### v1.4.5 - **CHANGED - Claws are now a timed skill (Aswid & Fenrir):** press **[K]** to grow Claws of the Beast / Cursed Claws for 120 seconds (configurable) instead of holding them forever — they retract and are removed from your inventory when the timer ends, so they never sit as a permanent dead item in a slot. The damage bonus only applies while they're actually equipped. Sverm's Chitin Claws are untouched and stay permanent. Along the way, fixed the Fenrir claws never registering at all (a .NET static-initialization order bug that left Fenrir's set out of the roster while Aswid's worked fine) and a race-detection bug where "Human" written to the ZDO by `resetrace` could shadow a correctly-chosen race. - **Fix - Vampiric Aura vs traders (Aswid):** the passive aura doesn't distinguish traders from monsters and could execute Haldor, Hildir or other faction merchants on approach. Press **[I]** (same key as Devour) to toggle the Aura off before trading. diff --git a/manifest.json b/manifest.json index 78d5bdf..91e2556 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.5", + "version_number": "1.4.6", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 4b95e705e74031c60eb97714f4545890192b49c8 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 21 Aug 2026 11:22:52 +0200 Subject: [PATCH 008/273] warvulture --- JotunnModStub/Package/manifest.json | 4 +- JotunnModStub/RaceMenuWard.cs | 8 +- JotunnModStub/RacesOfValheim.cs | 29 +- JotunnModStub/Trenta/TrentaComposter.cs | 1 + JotunnModStub/Trenta/TrentaConfig.cs | 59 ++++ .../Trenta/TrentaConfigManagement.cs | 19 ++ JotunnModStub/Trenta/TrentaElderRoot.cs | 306 ++++++++++++++++++ JotunnModStub/Trenta/TrentaRace.cs | 1 + README.md | 3 +- 9 files changed, 418 insertions(+), 12 deletions(-) create mode 100644 JotunnModStub/Trenta/TrentaElderRoot.cs diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 7ae2ba9..91e2556 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", - "description": "A Valheim mod that adds nine custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Trenta, Trol) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.4.0", + "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", + "version_number": "1.4.6", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RaceMenuWard.cs b/JotunnModStub/RaceMenuWard.cs index 59c6201..b564d26 100644 --- a/JotunnModStub/RaceMenuWard.cs +++ b/JotunnModStub/RaceMenuWard.cs @@ -280,12 +280,18 @@ namespace RacesOfValheim Refresh(); }); - AddButton("ResetBtn", "Reset Race", new Vector2(0, -110), new Color(0.5f, 0.25f, 0.2f, 1f), () => + AddButton("ResetRaceBtn", "Reset Race", new Vector2(-170, -110), new Color(0.5f, 0.25f, 0.2f, 1f), () => { Close(); RacesOfValheim.ResetRace(); }); + AddButton("ResetProgressionBtn", "Reset Progression", new Vector2(170, -110), new Color(0.5f, 0.4f, 0.2f, 1f), () => + { + RacesOfValheim.ResetProgression(); + Refresh(); + }); + AddButton("CloseBtn", "Close", new Vector2(0, -200), new Color(0.3f, 0.3f, 0.3f, 1f), Close); GUIManager.BlockInput(true); diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 5bed9da..f74d342 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.5"; + public const string PluginVersion = "1.4.6"; private readonly Harmony harmony = new Harmony(PluginGUID); @@ -123,6 +123,25 @@ namespace RacesOfValheim } } + /// + /// Clears the boss-progression override and falls back to the natural world state. + /// Shared by the resetprogression console command and the Race Menu Ward. + /// + public static int ResetProgression() + { + BossProgressionManager.DebugState = -1; + int state = BossProgressionManager.GetCurrentProgressionState(); + + Player player = Player.m_localPlayer; + if (player != null) + { + player.Message(MessageHud.MessageType.Center, $"Progression reset to: {state}"); + Traverse.Create(player).Method("SetupEquipment").GetValue(); + } + + return state; + } + /// /// Strips whatever body-part weapon the outgoing race grew. The Aswid/Fenrir claws /// (RaceClawSet) and the Sverm's Chitin Claws (SvermClawSlot) are quest items a player can @@ -1238,14 +1257,8 @@ namespace RacesOfValheim public override void Run(string[] args) { - BossProgressionManager.DebugState = -1; - int state = BossProgressionManager.GetCurrentProgressionState(); + int state = RacesOfValheim.ResetProgression(); Console.instance.Print($"[DEBUG] Progression state reset to natural world state: {state}"); - if (Player.m_localPlayer != null) - { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"Progression reset to: {state}"); - Traverse.Create(Player.m_localPlayer).Method("SetupEquipment").GetValue(); - } } } } diff --git a/JotunnModStub/Trenta/TrentaComposter.cs b/JotunnModStub/Trenta/TrentaComposter.cs index b245c2e..92ddd18 100644 --- a/JotunnModStub/Trenta/TrentaComposter.cs +++ b/JotunnModStub/Trenta/TrentaComposter.cs @@ -461,6 +461,7 @@ namespace RacesOfValheim if (__instance != Player.m_localPlayer) return; TrentaComposter.EnsureKnown(__instance); TrentaHeartwoodGrove.EnsureKnown(__instance); + TrentaElderRoot.EnsureKnown(__instance); FurlingCrops.EnsureKnown(__instance); } } diff --git a/JotunnModStub/Trenta/TrentaConfig.cs b/JotunnModStub/Trenta/TrentaConfig.cs index a44b93c..f395a6e 100644 --- a/JotunnModStub/Trenta/TrentaConfig.cs +++ b/JotunnModStub/Trenta/TrentaConfig.cs @@ -444,6 +444,65 @@ namespace RacesOfValheim public static readonly Color RotSeedTint = new Color(0.16f, 0.12f, 0.08f, 1f); + // ─── Root of the Elder (item progression, defensive) ────────────────── + // Race-locked, hammer-only, permanent: a piece that heals itself and, once a minute, heals + // every player-built thing within reach of it too. Full design in Trenta_ElderRoot.txt. + // + // No crafting station, same reasoning as the Composter/Grove chain's own station-free entry + // point would need if it had one: this is a race identity piece, not a purchase from + // someone else's bench (see the War Totem's own note on the same choice). + public const string ElderRootPieceName = "TrentaElderRoot"; + public const string ElderRootDisplayName = "Root of the Elder"; + + public const int ElderRootUnlockState = 3; // The Elder dead + + public const string ElderRootRecipeGuck = "Guck"; + public const int ElderRootRecipeGuckAmount = 5; + public const string ElderRootRecipeFineWood = "FineWood"; + public const int ElderRootRecipeFineWoodAmount = 10; + + // Source of the borrowed model - swamp scenery, already safe to strip under ModelBorrow's + // rules (no MonoBehaviour worth stripping in the first place, unlike a living prefab). + // THE ELDER'S SUMMONED ROOT - the thing that claws its way out of the ground and attacks + // whoever comes near during the boss fight. Verified by its path in manifest_extended: + // Assets/Characters/Greydwarf_king/TentaRoot + // "Assets/Characters/..." means CREATURE (the same path convention Trol_WarTotem.txt sez. + // 2.1 wrote down after the GoblinTotem item/piece mix-up), and "Greydwarf_king" is The + // Elder. Its whole kit sits in the same folder - misc/spawn_roots (the emergence), + // misc/tentaroot_attack, animation/tentaroot, fx_tentaroot_death, sfx_tentaroot_attack. + // The Mistlands Staff of Green Roots summons the same creature (staff_greenroots_tentaroot), + // which is the second confirmation that this is a summon and not decoration. + // + // TWO WRONG PICKS BEFORE THIS ONE, both found by searching the manifest for a word instead + // of asking what the boss actually spawns: + // "Vines" - unrelated swamp scenery, inert. + // "gdking_root_projectile" - the spike the Elder SHOOTS. A projectile/vfx, not the + // summon. Still correctly used further down for Muspell's + // ranged attack, which is what it really is. + // + // BORROWING FROM THIS IS NOT LIKE BORROWING SCENERY: it carries a Character, and + // ModelBorrow strips in a single pass, which is the exact shape of the bug that once broke + // the hammer for every piece in the game. TrentaElderRoot.ResolveModelSource walks to the + // "Visual" child first - the same thing FenrirRace and SkadiRace do for their forms - so + // no Character is ever handed to ModelBorrow. + public const string ElderRootModelSourcePrefab = "TentaRoot"; + + /// Child of a creature prefab that holds only mesh and animator, no Character. + public const string CreatureVisualChildName = "Visual"; + + // Height in metres of the borrowed model's largest dimension. NOT a guess any more: the + // mesh measures (0.48, 4.51, 0.47) at native size - a tall, thin root - and the first two + // tries in game (1.2 then 1.6) both came out about 70% too short. 2.7 m is roughly 60% of + // the creature's own height and stands a good head above the player. + public const float ElderRootModelSize = 2.7f; + + // Forward to TrentaConfigManagement (BepInEx ConfigEntry) - see that class. + public static float ElderRootHealth => TrentaConfigManagement.ElderRootHealth.Value; + public static float ElderRootSelfHealDelay => TrentaConfigManagement.ElderRootSelfHealDelay.Value; + public static float ElderRootSelfHealPercentPerSecond => TrentaConfigManagement.ElderRootSelfHealPercentPerSecond.Value; + public static float ElderRootRepairRadius => TrentaConfigManagement.ElderRootRepairRadius.Value; + public static float ElderRootRepairInterval => TrentaConfigManagement.ElderRootRepairInterval.Value; + // ─── Heartwood Grove (item progression, tier 2) ────────────────────── // Plant a seed, wait, and the tree that comes up fertilises what surrounds it, stings what // approaches it, and fills a chest with honey. Three independent functions on one piece. diff --git a/JotunnModStub/Trenta/TrentaConfigManagement.cs b/JotunnModStub/Trenta/TrentaConfigManagement.cs index 6b058b3..081a808 100644 --- a/JotunnModStub/Trenta/TrentaConfigManagement.cs +++ b/JotunnModStub/Trenta/TrentaConfigManagement.cs @@ -50,6 +50,13 @@ namespace RacesOfValheim public static ConfigEntry LastStandMaxArmorBonus; public static ConfigEntry ThornsReflectPercent; + // ─── Root of the Elder (tier 3+, defensive piece) ───────────────────── + public static ConfigEntry ElderRootHealth; + public static ConfigEntry ElderRootSelfHealDelay; + public static ConfigEntry ElderRootSelfHealPercentPerSecond; + public static ConfigEntry ElderRootRepairRadius; + public static ConfigEntry ElderRootRepairInterval; + // ─── Homecoming Portal (tier 6+) ────────────────────────────────────── public static ConfigEntry PortalCooldown; public static ConfigEntry PortalLifetime; @@ -113,6 +120,18 @@ namespace RacesOfValheim ThornsReflectPercent = config.Bind(lastStand, "Thorns Reflect Percent", 0.2f, new ConfigDescription("Fraction of every hit taken reflected back at the attacker, tier 5+.", new AcceptableValueRange(0f, 1f))); + const string elderRoot = "Trenta - Root of the Elder"; + ElderRootHealth = config.Bind(elderRoot, "Health", 300f, + new ConfigDescription("Max structural health of the piece itself.", new AcceptableValueRange(50f, 2000f))); + ElderRootSelfHealDelay = config.Bind(elderRoot, "Self-Heal Delay", 10f, + new ConfigDescription("Seconds without taking a hit before the piece starts healing itself.", new AcceptableValueRange(0f, 60f))); + ElderRootSelfHealPercentPerSecond = config.Bind(elderRoot, "Self-Heal Percent Per Second", 0.02f, + new ConfigDescription("Fraction of max health regained per second once healing starts.", new AcceptableValueRange(0f, 1f))); + ElderRootRepairRadius = config.Bind(elderRoot, "Repair Radius", 5f, + new ConfigDescription("Meters from the piece within which every player-built thing gets repaired.", new AcceptableValueRange(1f, 30f))); + ElderRootRepairInterval = config.Bind(elderRoot, "Repair Interval", 60f, + new ConfigDescription("Seconds between repair pulses.", new AcceptableValueRange(5f, 600f))); + const string portal = "Trenta - Homecoming Portal"; PortalCooldown = config.Bind(portal, "Cooldown", 300f, new ConfigDescription("Seconds between casts, tier 6+.", new AcceptableValueRange(0f, 3600f))); diff --git a/JotunnModStub/Trenta/TrentaElderRoot.cs b/JotunnModStub/Trenta/TrentaElderRoot.cs new file mode 100644 index 0000000..5f0fba8 --- /dev/null +++ b/JotunnModStub/Trenta/TrentaElderRoot.cs @@ -0,0 +1,306 @@ +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Trenta's defensive piece: a gnarled root left over from the Elder, permanent once + /// planted, that heals itself and, once a minute, heals everything a player built within reach + /// of it too. + /// + /// Full design in Trenta_ElderRoot.txt. Two facts from that document matter for reading this + /// file: + /// + /// - WearNTear.Repair() and WearNTear.ApplyDamage(float, HitData) are both read from IL, not + /// guessed. Repair() is the same full-heal-and-broadcast the hammer itself uses. + /// ApplyDamage subtracts its float argument from current health and broadcasts the result - + /// a NEGATIVE amount heals, which is how the self-heal below works without a second RPC. + /// - Piece.IsPlacedByPlayer() is the filter, copied from Sverm/SvermWorker.cs (the mod's own + /// precedent for "heal player buildings in a radius"). Without it this piece would also try + /// to mend ruins, troll-cave walls and any other scenery that happens to carry a WearNTear. + /// + /// The clone base and the strip pattern are TrolTotem's, unchanged: piece_workbench is a real + /// Piece (unlike the item-prefab trap that piece's own file documents), stripped to + /// Piece/ZNetView/WearNTear and given a borrowed look instead of the bench's own mesh. + /// + public static class TrentaElderRoot + { + public static void Register() + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab( + TrentaConfig.ElderRootPieceName, "piece_workbench"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Trenta] Could not clone piece_workbench; the Root of the Elder is not registered."); + return; + } + + // Strip the workbench down to a placeable shell: no station, no crafting, no furniture. + // The look comes from the borrowed Vines model below. + foreach (MonoBehaviour behaviour in prefab.GetComponentsInChildren(true)) + { + if (behaviour == null) continue; + if (behaviour is Piece || behaviour is ZNetView || behaviour is WearNTear) continue; + Object.DestroyImmediate(behaviour); + } + foreach (Renderer renderer in prefab.GetComponentsInChildren(true)) + { + if (renderer != null) renderer.enabled = false; // the bench's own mesh, hidden + } + + AswidBloodRefinery.StripOffensive(prefab, TrentaConfig.ElderRootPieceName); + + GameObject modelSource = ResolveModelSource(); + if (modelSource != null) + { + ModelBorrow.Attach(prefab.transform, "RootModel", modelSource, + Vector3.zero, Quaternion.identity, TrentaConfig.ElderRootModelSize, "Trenta"); + } + + // Belt as well as braces, exactly as SvermHive.Register does after its own guard: even + // though ResolveModelSource never hands a Character to ModelBorrow, anything that could + // still act alive comes off the finished piece. This is the line that keeps the + // hammer-breaking failure (see ResolveModelSource) impossible rather than merely + // unlikely. + SvermHive.StripLife(prefab); + + WearNTear wear = prefab.GetComponent(); + if (wear != null) + { + wear.m_health = TrentaConfig.ElderRootHealth; + wear.m_materialType = WearNTear.MaterialType.Wood; + } + + prefab.AddComponent(); + + Sprite icon = BorrowIcon(TrentaConfig.ElderRootRecipeGuck); + + Piece piece = prefab.GetComponent() ?? prefab.AddComponent(); + piece.m_craftingStation = null; + piece.m_resources = new Piece.Requirement[0]; + piece.m_name = TrentaConfig.ElderRootDisplayName; + piece.m_canBeRemoved = true; + piece.m_groundPiece = true; + piece.m_groundOnly = true; + piece.m_icon = icon; + + Piece template = PrefabManager.Cache.GetPrefab("piece_workbench"); + if (template != null && template.m_placeEffect != null) piece.m_placeEffect = template.m_placeEffect; + + PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig + { + Name = TrentaConfig.ElderRootDisplayName, + Description = "What the Elder left behind, still growing. Mends itself, and " + + "everything a player built close enough to it.", + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Crafting, + Icon = icon, + Requirements = new[] + { + new RequirementConfig(TrentaConfig.ElderRootRecipeGuck, TrentaConfig.ElderRootRecipeGuckAmount, 0, true), + new RequirementConfig(TrentaConfig.ElderRootRecipeFineWood, TrentaConfig.ElderRootRecipeFineWoodAmount, 0, true), + } + })); + + Jotunn.Logger.LogInfo($"[Trenta] Registered '{TrentaConfig.ElderRootPieceName}' " + + $"({TrentaConfig.ElderRootDisplayName}) on the hammer's Crafting page."); + } + + /// + /// The model to borrow, with the creature carefully left behind. + /// + /// TentaRoot is a CHARACTER (verified by its manifest path, Assets/Characters/...), and + /// handing a Character to ModelBorrow is the precise bug that once stopped the hammer + /// working for every piece in the game: ModelBorrow strips in ONE pass over + /// GetComponentsInChildren<MonoBehaviour>, and Unity refuses to destroy a component + /// another one still requires - "Can't remove Humanoid because CharacterDrop depends on + /// it". The Humanoid survives, every placement ghost wakes one, and + /// Character.GetCharactersInRange throws inside Player.UpdatePlacementGhost. + /// + /// So the creature is never borrowed from directly. Its "Visual" child is - the node that + /// holds mesh and animator and nothing alive - which is the same route FenrirRace and + /// SkadiRace already take for every one of their transformations. If that child is missing + /// the answer is to attach nothing and say so, NOT to fall back to the creature: an + /// invisible piece is a cosmetic bug, a live Humanoid on a building is a broken hammer. + /// + private static GameObject ResolveModelSource() + { + string sourceName = TrentaConfig.ElderRootModelSourcePrefab; + GameObject source = PrefabManager.Cache.GetPrefab(sourceName); + if (source == null) + { + Jotunn.Logger.LogWarning($"[Trenta] No '{sourceName}' to borrow the Root's model from; " + + "the piece is registered without a model."); + return null; + } + + Transform visual = source.transform.Find(TrentaConfig.CreatureVisualChildName); + if (visual != null) + { + Jotunn.Logger.LogInfo($"[Trenta] Root model taken from '{sourceName}/" + + $"{TrentaConfig.CreatureVisualChildName}' - the creature itself is left alone."); + return visual.gameObject; + } + + // No Visual child. If the prefab is harmless scenery after all we can still use it; + // if it is alive we refuse, loudly, and the piece comes up invisible. + if (SvermHive.IsSafeScenery(source, sourceName)) + { + Jotunn.Logger.LogInfo($"[Trenta] '{sourceName}' has no '{TrentaConfig.CreatureVisualChildName}' " + + "child but carries nothing alive; borrowing from it whole."); + return source; + } + + Jotunn.Logger.LogWarning($"[Trenta] '{sourceName}' is alive and has no " + + $"'{TrentaConfig.CreatureVisualChildName}' child to borrow safely. " + + "The Root is registered WITHOUT a model rather than risking a live " + + "Character on a building - run `dumpelder " + sourceName + "` in the " + + "console to see its real hierarchy and name the right child here."); + return null; + } + + private static Sprite BorrowIcon(string prefabName) + { + ItemDrop drop = PrefabManager.Cache.GetPrefab(prefabName); + Sprite[] icons = drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null + ? drop.m_itemData.m_shared.m_icons + : null; + return icons != null && icons.Length > 0 ? icons[0] : null; + } + + /// + /// Teaches the piece to the local player. Every dynamically cloned hammer piece in this mod + /// needs this - see the shared OnSpawned postfix in TrentaComposter.cs, which now calls this + /// too. + /// + public static void EnsureKnown(Player player) + { + if (player == null) return; + + GameObject prefab = PrefabManager.Instance.GetPrefab(TrentaConfig.ElderRootPieceName); + Piece piece = prefab != null ? prefab.GetComponent() : null; + if (piece == null) return; + + Traverse traverse = Traverse.Create(player); + traverse.Method("AddKnownPiece", piece).GetValue(); + traverse.Method("UpdateAvailablePiecesList").GetValue(); + } + } + + /// + /// Lives on the placed piece. Two independent jobs, both on the same tick cadence rules as the + /// rest of the mod: no coroutine, just Time.time comparisons in Update. + /// + public class TrentaElderRootBehaviour : MonoBehaviour + { + private WearNTear m_wear; + private float m_lastHitTime = -9999f; + private float m_nextRepairTick; + + private void Start() + { + m_wear = GetComponent(); + if (m_wear != null) m_wear.m_onDamaged += OnHit; + + m_nextRepairTick = Time.time + TrentaConfig.ElderRootRepairInterval; + } + + private void OnDestroy() + { + if (m_wear != null) m_wear.m_onDamaged -= OnHit; + } + + private void OnHit() + { + m_lastHitTime = Time.time; + } + + private void Update() + { + TickSelfHeal(); + + if (Time.time >= m_nextRepairTick) + { + m_nextRepairTick = Time.time + TrentaConfig.ElderRootRepairInterval; + RunRepairPulse(); + } + } + + /// + /// The piece's own regeneration: unhurt for a while, then a fraction of max health back + /// every second. Cannot reuse SkeletonSentryBehaviour - that class heals a Character, and + /// this is a WearNTear, exactly the distinction SkeletonSentry.cs's own header explains for + /// why the Bound Sentry is cloned from a live creature rather than built as a piece. + /// + /// ApplyDamage(float, HitData) has no built-in cap against m_health (read from its IL), so + /// the clamp against the remaining gap happens here, not inside the engine call. + /// + private void TickSelfHeal() + { + if (m_wear == null) return; + ZNetView nview = m_wear.GetComponent(); + if (nview == null || !nview.IsValid() || !nview.IsOwner()) return; + if (Time.time - m_lastHitTime < TrentaConfig.ElderRootSelfHealDelay) return; + + float current = nview.GetZDO().GetFloat(ZDOVars.s_health, m_wear.m_health); + if (current >= m_wear.m_health) return; + + float healThisFrame = TrentaConfig.ElderRootSelfHealPercentPerSecond * m_wear.m_health * Time.deltaTime; + healThisFrame = Mathf.Min(healThisFrame, m_wear.m_health - current); + if (healThisFrame > 0f) m_wear.ApplyDamage(-healThisFrame, null); + } + + /// + /// Everything in range, in one pass - deliberately not the one-piece-per-tick pacing + /// Sverm/SvermWorker.cs uses for the same kind of aura. Kept different on purpose; see + /// Trenta_ElderRoot.txt sez. 4.2 before "fixing" this to match that precedent. + /// + private void RunRepairPulse() + { + foreach (Collider collider in Physics.OverlapSphere(transform.position, TrentaConfig.ElderRootRepairRadius)) + { + if (collider == null) continue; + + WearNTear otherWear = collider.GetComponentInParent(); + if (otherWear == null || otherWear == m_wear) continue; + + Piece piece = otherWear.GetComponent(); + if (piece == null || !piece.IsPlacedByPlayer()) continue; + + otherWear.Repair(); + } + } + } + + /// + /// Race lock plus the boss gate, in one prefix - same shape as TrolTotemRaceLockPatch, with a + /// second refusal added for the progression check the Root also needs. + /// + [HarmonyPatch(typeof(Player), "PlacePiece", + new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })] + public static class TrentaElderRootPlacementPatch + { + public static bool Prefix(Player __instance, Piece __0) + { + if (__instance != Player.m_localPlayer || __0 == null) return true; + if (Utils.GetPrefabName(__0.gameObject) != TrentaConfig.ElderRootPieceName) return true; + + if (!TrentaRace.IsTrenta()) + { + __instance.Message(MessageHud.MessageType.Center, "The root will not take hold for you."); + return false; + } + + if (BossProgressionManager.GetCurrentProgressionState() < TrentaConfig.ElderRootUnlockState) + { + __instance.Message(MessageHud.MessageType.Center, "The Elder has not fallen yet."); + return false; + } + + return true; + } + } +} diff --git a/JotunnModStub/Trenta/TrentaRace.cs b/JotunnModStub/Trenta/TrentaRace.cs index eac4cca..491fe62 100644 --- a/JotunnModStub/Trenta/TrentaRace.cs +++ b/JotunnModStub/Trenta/TrentaRace.cs @@ -34,6 +34,7 @@ namespace RacesOfValheim // before that catalogue is read. TrentaComposter.Register(); TrentaHeartwoodGrove.Register(); + TrentaElderRoot.Register(); } /// diff --git a/README.md b/README.md index bacba17..e39985e 100644 --- a/README.md +++ b/README.md @@ -282,7 +282,7 @@ Every race has a buildable station of its own, gated by a reagent bought from it - **Skadi — Crystal Golem & Bone Cook:** a stonecutter-bound guardian on a leash. Skadi (and Trol) may also build inside any troll cave in the world. The Cook is Skadi's own half of the [Bone Servants](#skeleton--skadi--bone-servants). - **Skeleton — Bound Bone Pile, Bound Sentry & Bone Smith:** pay once per slot and that slot refills itself forever, because an army you re-buy after every fight is one nobody takes out of the house. The Sentry is a bound archer that cannot walk, regenerates when left alone, and hands its parts back when it falls. The Smith is Skeleton and Skadi's shared half of the [Bone Servants](#skeleton--skadi--bone-servants). - **Sverm — Brood Mound & Hive Market:** see [The Colony](#race-progressions-level-by-level). -- **Trenta — Composter & Heartwood Grove:** the Composter rots raw flesh into Fertilizer, which grows any plant on the spot. The Grove is a tree that fertilises what surrounds it, stings what approaches it, and fills a chest with honey. +- **Trenta — Composter, Heartwood Grove & Root of the Elder:** the Composter rots raw flesh into Fertilizer, which grows any plant on the spot. The Grove is a tree that fertilises what surrounds it, stings what approaches it, and fills a chest with honey. The Root is one of the Elder's own summoned roots, planted for good: it knits its own wounds shut, and once a minute it repairs every player-built thing within five meters of it — anyone's, not just the Trenta's. Race locked, and only after the Elder falls. - **Trol — War Totem:** hires warbands of trolls and greydwarves for coin. Race locked — the hammer refuses it to anyone who is not a Trol. A dead warband is money spent. ### Dvergar — Contract Bank @@ -405,6 +405,7 @@ The **Sverm** belongs to no faction. Its Hive Pheromones make every invertebrate ## Changelog ### v1.4.6 +- **NEW - Root of the Elder (Trenta):** one of the Elder's own summoned roots, planted for good instead of fading. Built with the hammer for 5 Guck and 10 Fine Wood once the Elder is down, race locked to the Trenta. It knits its own wounds shut when left alone, and once a minute it repairs **every player-built thing within five meters** — anyone's buildings, not just its owner's. No damage, no armor: the Trenta defends what it has built rather than fighting for it. - **Fix - Race truces in multiplayer:** every race's mob-truce check (Fenrir/wolves, Aswid, Draugh, Trenta, Sverm, and Skadi/Fenrir/Dvergar's Montagna set including the Drake) read the player's race from a local-only field that is never populated for anyone but your own client. On a dedicated server, or whenever another player ended up owning a mob's AI, the check silently failed and the "neutral" mob stayed hostile — this is why Skadi players were seeing Drakes attack them. Both hostility patches now read the race from the ZDO copy that actually replicates over the network, falling back to the local field only when the ZDO isn't available yet. ### v1.4.5 From 0afba60ed697fec7f85134f72b1b1d2fd53e75d0 Mon Sep 17 00:00:00 2001 From: kanym Date: Mon, 24 Aug 2026 13:34:30 +0200 Subject: [PATCH 009/273] Remove leftover TrolSync/SkadiSync debug logging These periodic Jotunn.Logger.LogInfo calls were spamming the console for every remote player update; drop them along with their now-unused throttle fields. --- JotunnModStub/Trol/TrolPatches.cs | 20 -------------------- JotunnModStub/ZdoVisualSync.cs | 9 --------- 2 files changed, 29 deletions(-) diff --git a/JotunnModStub/Trol/TrolPatches.cs b/JotunnModStub/Trol/TrolPatches.cs index 4fd11b1..68007df 100644 --- a/JotunnModStub/Trol/TrolPatches.cs +++ b/JotunnModStub/Trol/TrolPatches.cs @@ -95,13 +95,6 @@ namespace RacesOfValheim public const string StateKey = "RacesOfValheim_State"; public const string TrueFormKey = "RacesOfValheim_TrolTrueForm"; - // Remote sync tracing. It used to fire on a 2-second timer for as long as a remote player - // existed, which in the main menu means forever: Player.m_localPlayer is null there, so the - // character-preview player counts as remote and the log never stopped. Keyed on the state - // it reports instead, so it still catches a remote player being sized wrongly - the reason - // it exists - without narrating a menu that is doing nothing. - private static string lastRemoteLogKey = ""; - private static float ScaleForState(int state) { if (state >= 6) return 1.30f; @@ -152,19 +145,6 @@ namespace RacesOfValheim targetScale = state >= 7 ? TrolConfig.TrueFormScaleAdvanced.Value : TrolConfig.TrueFormScaleNormal.Value; } - if (!isLocal) - { - string logKey = $"{__instance.GetPlayerName()}|{race}|{zdoReady}|{state}|{isTrueFormActive}|{targetScale:F2}"; - if (logKey != lastRemoteLogKey) - { - lastRemoteLogKey = logKey; - Jotunn.Logger.LogInfo( - $"[TrolSync] remote '{__instance.GetPlayerName()}' race='{race}' zdoReady={zdoReady} " + - $"state={state} trueForm={isTrueFormActive} target={targetScale:F2} " + - $"currentScale={visual.transform.localScale.x:F2} rootScale={__instance.transform.localScale.x:F2}"); - } - } - if (race == "Trol") { // Local player has a coroutine that smooth-scales during the active transformation, diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs index 4559f86..40061ef 100644 --- a/JotunnModStub/ZdoVisualSync.cs +++ b/JotunnModStub/ZdoVisualSync.cs @@ -41,7 +41,6 @@ namespace RacesOfValheim private GameObject m_fireAuraVFX = null; private GameObject m_draughAuraVFX = null; private readonly SkeletonVisuals.HeadFlame m_skeletonHeadFlame = new SkeletonVisuals.HeadFlame(); - private float m_lastFlightLog = 0f; private void Awake() { @@ -245,14 +244,6 @@ namespace RacesOfValheim { body.useGravity = !flying; } - - if (Time.time - m_lastFlightLog > 2f) - { - m_lastFlightLog = Time.time; - Jotunn.Logger.LogInfo( - $"[SkadiSync] remote '{m_player.GetPlayerName()}' form='{currentForm}' flying={flying} " + - $"y={m_player.transform.position.y:F1} gravity={(body != null ? body.useGravity.ToString() : "no-body")}"); - } } private void RevertAllVisuals() From 189177b643875cb15a8aa3280df07fd93272006f Mon Sep 17 00:00:00 2001 From: kanym Date: Mon, 24 Aug 2026 13:47:53 +0200 Subject: [PATCH 010/273] Fix Trol compendium: remove bogus consume-on-kill line, correct off-by-one progression gates - Trol has no consume/devour mechanic; that line was copy-pasted from Aswid's entry, which does. - Every boss-gated line was checking state >= N-1 instead of N, so each unlock (Eikthyr XP bonus, Elder's rock throw/regen, Bonemass/Yagluth bonuses, Moder's True Form, Queen's Log Weapon, Fader's Ashlands smash) displayed a full tier early. Aligned all seven gates with BossProgressionManager's state mapping and the actual code gates in TrolSkillPatches, TrolRegenPatches, TrolRace, and TrolFarmingPatches. - Yagluth melee bonus line said +10; TrolConfig.YagluthMeleeBonus defaults to 5, matching the Rock Throwing figure beside it. - Bonemass/Yagluth melee bonus text omitted Axes, though the bonus (TrolDamagePatches) applies to Axes too. --- JotunnModStub/RaceCompendium.cs | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 886d4ae..6346e01 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -332,27 +332,27 @@ namespace RacesOfValheim StringBuilder sb = new StringBuilder(); sb.AppendLine("The Trol's Heritage\n"); - sb.AppendLine($"Base Passive: Physical kills automatically consume enemies (if edible). You are natively 20% larger than a human with immense strength. You have +200 Max Carry Weight, gain +3 Armor per boss defeated, and carry a 4th food slot from your very first meal - no boss required.\n"); - - if (state >= 1) - sb.AppendLine("Eikthyr Defeated: Increased XP gain for physical labor and blunt combat (Clubs, Unarmed, Axes, Pickaxes, WoodCutting).\n"); + sb.AppendLine($"Base Passive: You are natively 20% larger than a human with immense strength. You have +200 Max Carry Weight, gain +3 Armor per boss defeated, and carry a 4th food slot from your very first meal - no boss required.\n"); if (state >= 2) - sb.AppendLine("The Elder Defeated: Unlocked Rock Throwing ability. +10% passive health regeneration.\n"); + sb.AppendLine("Eikthyr Defeated: Increased XP gain for physical labor and blunt combat (Clubs, Unarmed, Axes, Pickaxes, WoodCutting).\n"); if (state >= 3) - sb.AppendLine("Bonemass Defeated: +5% Size, +50 Carry Weight, +10 Damage to Clubs/Unarmed, +10 Rock Throwing Damage.\n"); - + sb.AppendLine("The Elder Defeated: Unlocked Rock Throwing ability. +10% passive health regeneration.\n"); + if (state >= 4) - sb.AppendLine("Moder Defeated: Unlocked True Form (Transformation ability).\n"); - + sb.AppendLine("Bonemass Defeated: +5% Size, +50 Carry Weight, +10 Damage to Clubs/Unarmed/Axes, +10 Rock Throwing Damage.\n"); + if (state >= 5) - sb.AppendLine("Yagluth Defeated: +5% Size, +50 Carry Weight, +10 Damage to Clubs/Unarmed, +5 Rock Throwing Damage. Unlocked 5th Food Slot.\n"); - + sb.AppendLine("Moder Defeated: Unlocked True Form (Transformation ability).\n"); + if (state >= 6) - sb.AppendLine("The Queen Defeated: Unlocked Log Weapon (in True Form, interact with trees to wield them as weapons). True Form size is massively increased.\n"); - + sb.AppendLine("Yagluth Defeated: +5% Size, +50 Carry Weight, +5 Damage to Clubs/Unarmed/Axes, +5 Rock Throwing Damage. Unlocked 5th Food Slot.\n"); + if (state >= 7) + sb.AppendLine("The Queen Defeated: Unlocked Log Weapon (in True Form, interact with trees to wield them as weapons). True Form size is massively increased.\n"); + + if (state >= 8) sb.AppendLine("Fader Defeated: Your wielded trees can now instantly smash through the toughest materials in the Ashlands.\n"); knownTexts["Trol Secrets"] = sb.ToString(); From fbaa2e9502acc7eadb089f4de1fc9a0b257a333a Mon Sep 17 00:00:00 2001 From: kanym Date: Mon, 24 Aug 2026 13:49:03 +0200 Subject: [PATCH 011/273] Fix Fenrir compendium: remove bogus consume-on-kill line Same copy-paste artifact as Trol's entry - Fenrir has no consume/devour mechanic, only Aswid does (TryConsumeMob/Devour). --- JotunnModStub/RaceCompendium.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 886d4ae..a9c28f5 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -457,7 +457,7 @@ namespace RacesOfValheim StringBuilder sb = new StringBuilder(); sb.AppendLine("The Curse of the Pack\n"); - sb.AppendLine($"[Base Passive] The Beast Within: Physical kills automatically consume edible enemies. Your physical stats scale with every boss you defeat: +{arm} Armor, +{dmg} Damage, +{spd}% Speed, +{jmp}% Jump, and -{fall}% Fall Damage.\n"); + sb.AppendLine($"[Base Passive] The Beast Within: Your physical stats scale with every boss you defeat: +{arm} Armor, +{dmg} Damage, +{spd}% Speed, +{jmp}% Jump, and -{fall}% Fall Damage.\n"); // The live figure, so the entry cannot drift from the code: the same yardstick the // Sverm's own claws are measured against, which is what keeps the three races even. From 1e75efd31148ef807430a47e1e8a8585553aa9d9 Mon Sep 17 00:00:00 2001 From: kanym Date: Mon, 24 Aug 2026 14:03:40 +0200 Subject: [PATCH 012/273] Limit troll cave placement-refusal log to near a cave ReportWhyIfRefused fired on every refused placement by any Trol/Skadi player, anywhere in the world - not just cave-related ones - since it only rate-limits on the reason changing, not on location. Gate it on distance to the nearest TrollCave02 mouth (100m) so it still catches a refusal that survives near a cave, without logging every ordinary "can't build here" the rest of the world produces. --- JotunnModStub/RaceCaveBuilding.cs | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-) diff --git a/JotunnModStub/RaceCaveBuilding.cs b/JotunnModStub/RaceCaveBuilding.cs index c34cb9d..4e026d7 100644 --- a/JotunnModStub/RaceCaveBuilding.cs +++ b/JotunnModStub/RaceCaveBuilding.cs @@ -33,6 +33,13 @@ namespace RacesOfValheim /// Slack on the location's own radius, since the inside of a cave is not a neat sphere. private const float RadiusSlack = 12f; + /// + /// How far from a troll cave mouth a refusal is still worth logging. Wide enough to catch + /// "standing at the mouth but not detected", far too narrow to catch the ordinary "can't + /// build here" that happens anywhere else in the world and has nothing to do with caves. + /// + private const float ReportRadius = 100f; + private const float CheckInterval = 0.25f; private float nextCheck; @@ -188,22 +195,28 @@ namespace RacesOfValheim string statusName = status.ToString(); if (statusName == "Valid") { lastReport = null; return; } - string report = statusName + "|" + lastHow; - if (report == lastReport) return; - lastReport = report; - // The player's own position and the distance to the nearest troll cave MOUTH are here for // one reason: if a refusal ever survives with "in troll cave=False", these two numbers say // whether the interior sits near its mouth or has been relocated somewhere else entirely - // which is the difference between a tolerance to widen and a wrong idea about the world. Vector3 position = player.transform.position; string nearest = ""; + float distance = float.PositiveInfinity; if (ZoneSystem.instance != null && ZoneSystem.instance.FindClosestLocation("TrollCave02", position, out ZoneSystem.LocationInstance closest)) { - nearest = $"{Vector3.Distance(position, closest.m_position):0} m away at {closest.m_position}"; + distance = Vector3.Distance(position, closest.m_position); + nearest = $"{distance:0} m away at {closest.m_position}"; } + // Not worth logging anywhere but near a cave - otherwise this fires on every ordinary + // "can't build here" a Trol/Skadi player runs into across the rest of the world. + if (!allowing && distance > ReportRadius) { lastReport = null; return; } + + string report = statusName + "|" + lastHow; + if (report == lastReport) return; + lastReport = report; + Jotunn.Logger.LogInfo($"[Races] Placement refused: {statusName} " + $"(in troll cave={allowing}, pieces flipped={flipped.Count}). " + $"Detection said: {lastHow}. Player at {position}; nearest TrollCave02 mouth {nearest}."); From ee5a2e2e7bb7033be6de51c442cd68ce52a084ae Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Mon, 24 Aug 2026 19:17:47 +0200 Subject: [PATCH 013/273] warvulture --- .../Factions/FactionHostilityPatch.cs | 27 +++ JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RaceCompendium.cs | 26 ++- JotunnModStub/RacesOfValheim.cs | 4 +- JotunnModStub/Sverm/SvermBrood.cs | 76 +++++++- JotunnModStub/Sverm/SvermHive.cs | 20 +- JotunnModStub/Sverm/SvermHiveStore.cs | 8 +- JotunnModStub/Trol/TrolFoodManager.cs | 171 ++++++++++++------ JotunnModStub/Trol/TrolFoodPatches.cs | 18 ++ JotunnModStub/Trol/TrolRace.cs | 16 +- README.md | 20 +- manifest.json | 2 +- 12 files changed, 314 insertions(+), 76 deletions(-) diff --git a/JotunnModStub/Factions/FactionHostilityPatch.cs b/JotunnModStub/Factions/FactionHostilityPatch.cs index dffbcdc..91542f2 100644 --- a/JotunnModStub/Factions/FactionHostilityPatch.cs +++ b/JotunnModStub/Factions/FactionHostilityPatch.cs @@ -111,4 +111,31 @@ namespace RacesOfValheim } } } + + // IsEnemy is not the only way a mob picks the player, and the other way ignores it + // completely. BaseAI.FindEnemy() walks every character asking IsEnemy - which both truce + // patches above answer - but when that walk comes up empty and the creature HuntPlayer()s, + // it falls through to Player.GetClosestPlayer(transform.position, 200f) and returns whoever + // it finds, without asking anything about factions. + // + // That fall-through is why the Black Forest truce looked broken to the Trol's testers: + // MonsterAI.UpdateAI turns hunting on for every IsEventCreature() while an event is running, + // and the events that reach a Trol are "the forest is moving" (Greydwarves), "you are being + // hunted" (Trolls) and the Fuling army - the exact three they named. Anything a SpawnSystem + // entry or a TriggerSpawner flags with huntPlayer arrives by the same door. + // + // Filtering the RESULT rather than restating the rule keeps one source of truth: the public + // instance IsEnemy(Character) calls the static overload both postfixes above hook, so this + // honours whatever the faction sets and RaceHostilityManager's per-race lists already agree + // on. Retaliation is untouched - a mob the player hits is targeted through + // BaseAI.OnDamaged/SetTarget, which never goes near FindEnemy. + [HarmonyPatch(typeof(BaseAI), "FindEnemy")] + public static class FactionHuntPlayerPatch + { + public static void Postfix(BaseAI __instance, ref Character __result) + { + if (__result == null || !__result.IsPlayer()) return; + if (!__instance.IsEnemy(__result)) __result = null; + } + } } diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 91e2556..47fbce3 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.6", + "version_number": "1.4.8", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index f18caec..63752ed 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -292,25 +292,37 @@ namespace RacesOfValheim sb.AppendLine($"Base Passive: Physical kills automatically consume enemies (if edible). You are natively 20% larger than a human with immense strength. You have +200 Max Carry Weight and gain +3 Armor per boss defeated.\n"); - if (state >= 1) + // Written from the config so a retuned multiplier can't leave the compendium lying. + // It was missing outright, which made the Trol the only race whose one drawback was + // nowhere in its own entry - the Sverm and the Skeleton both name theirs. + sb.AppendLine($"Base Weakness - Kindling: Fire finds you where nothing else does. Every burn you take lands for {(TrolConfig.FireWeaknessMultiplier.Value - 1f) * 100f:0}% more than it would on anyone else, and no armor or resistance changes that.\n"); + + sb.AppendLine("Base Passive: Black Forest kin. Greydwarves, Fulings and Trolls have no quarrel with you and will not open a fight - though hitting one still buys you the answer you asked for.\n"); + + // These gates were each one tier early: BossProgressionManager starts at MinState = 1 + // with NO boss down, so state 2 is Eikthyr and state 8 is Fader - which is what every + // other race's entry in this file uses, and what the Trol's own patches check. A fresh + // Trol was being promised the Eikthyr XP bonus before killing anything, then finding + // TrolSkillPatches (state >= 2) refusing it, and the same slip ran the whole ladder. + if (state >= 2) sb.AppendLine("Eikthyr Defeated: Increased XP gain for physical labor and blunt combat (Clubs, Unarmed, Axes, Pickaxes, WoodCutting).\n"); - if (state >= 2) + if (state >= 3) sb.AppendLine("The Elder Defeated: Unlocked Rock Throwing ability. +10% passive health regeneration.\n"); - if (state >= 3) + if (state >= 4) sb.AppendLine("Bonemass Defeated: +5% Size, +50 Carry Weight, +10 Damage to Clubs/Unarmed, +10 Rock Throwing Damage. Unlocked 4th Food Slot.\n"); - if (state >= 4) + if (state >= 5) sb.AppendLine("Moder Defeated: Unlocked True Form (Transformation ability).\n"); - if (state >= 5) + if (state >= 6) sb.AppendLine("Yagluth Defeated: +5% Size, +50 Carry Weight, +10 Damage to Clubs/Unarmed, +5 Rock Throwing Damage. Unlocked 5th Food Slot.\n"); - if (state >= 6) + if (state >= 7) sb.AppendLine("The Queen Defeated: Unlocked Log Weapon (in True Form, interact with trees to wield them as weapons). True Form size is massively increased.\n"); - if (state >= 7) + if (state >= 8) sb.AppendLine("Fader Defeated: Your wielded trees can now instantly smash through the toughest materials in the Ashlands.\n"); knownTexts["Trol Secrets"] = sb.ToString(); diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index f74d342..ca31287 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.6"; + public const string PluginVersion = "1.4.8"; private readonly Harmony harmony = new Harmony(PluginGUID); @@ -319,7 +319,7 @@ namespace RacesOfValheim // Row 2 (y = -20) CreateRaceButtonWithConfirm("Aswid", new Vector2(-450, -20), GetAswidIcon(), "Fierce night stalker. Strong and resilient, transforms into a bat.", SelectAswid); CreateRaceButtonWithConfirm("Furling", new Vector2(-150, -20), GetFurlingIcon(), "Cunning goblin-like creatures. Agile and resourceful.", SelectFurling); - CreateRaceButtonWithConfirm("Trol", new Vector2(150, -20), GetTrolIcon(), "Massive brute strength. Towering over others but slow to react.", SelectTrol); + CreateRaceButtonWithConfirm("Trol", new Vector2(150, -20), GetTrolIcon(), $"Massive brute strength. Towering over others, at peace with the Black Forest - but fire burns a Trol {(TrolConfig.FireWeaknessMultiplier.Value - 1f) * 100f:0}% harder than anyone else.", SelectTrol); CreateRaceButtonWithConfirm("Draugh", new Vector2(450, -20), GetDraughIcon(), "A decaying undead warrior fueled by dark magic and extreme metal.", SelectDraugh); // Row 3 (y = -140) diff --git a/JotunnModStub/Sverm/SvermBrood.cs b/JotunnModStub/Sverm/SvermBrood.cs index 1d52a0e..df9514e 100644 --- a/JotunnModStub/Sverm/SvermBrood.cs +++ b/JotunnModStub/Sverm/SvermBrood.cs @@ -36,6 +36,7 @@ namespace RacesOfValheim public float Price; public int Stage; // the nest stage it becomes available at public float Cooldown; // seconds between two of these + public float SpawnHeight = 0.5f; // how far above the nest it is put down public string PrefabName => PrefabPrefix + Source; public int Cap => CapOf(Id); @@ -53,7 +54,7 @@ namespace RacesOfValheim new Kind { Id = "brood", Display = "Brood", Source = "SeekerBrood", Icon = "TrophySeeker", Price = 100f, Stage = 1, Cooldown = 60f }, new Kind { Id = "seeker", Display = "Seeker", Source = "Seeker", Icon = "TrophySeeker", Price = 250f, Stage = 2, Cooldown = 150f }, new Kind { Id = "soldier", Display = "Soldier", Source = "SeekerBrute", Icon = "TrophySeekerBrute", Price = 500f, Stage = 3, Cooldown = 300f }, - new Kind { Id = "gjall", Display = "Gjall", Source = "Gjall", Icon = "TrophyGjall", Price = 1000f, Stage = 4, Cooldown = 600f }, + new Kind { Id = "gjall", Display = "Gjall", Source = "Gjall", Icon = "TrophyGjall", Price = 1000f, Stage = 4, Cooldown = 600f, SpawnHeight = 10f }, }; private static int CapOf(string id) @@ -141,7 +142,7 @@ namespace RacesOfValheim } /// - /// Puts one on the ground beside the nest, bound to it and born at whatever star the colony + /// Puts one down beside the nest, bound to it and born at whatever star the colony /// has bought. /// public static bool Hatch(SvermHiveBehaviour hive, Kind kind) @@ -156,9 +157,7 @@ namespace RacesOfValheim return false; } - Vector3 offset = Random.insideUnitSphere * 2f; - offset.y = 0f; - Vector3 where = hive.transform.position + offset + Vector3.up * 0.5f; + Vector3 where = SpawnSpot(hive, kind); GameObject spawned = Object.Instantiate(prefab, where, Quaternion.Euler(0f, Random.Range(0, 360), 0f)); if (spawned == null) return false; @@ -179,6 +178,73 @@ namespace RacesOfValheim return true; } + + /// How much open ground is left between the nest's own skirt and a newborn. + private const float SpawnClearance = 2.5f; + + /// + /// Where the newborn is put down: on a ring OUTSIDE the nest, never in the middle of it. + /// + /// Troops were hatching at the nest's own position and half a metre up, which is inside a + /// building several metres wide - so they came out wedged in its collider. This walks a ring + /// from a random angle, takes the first spot with nothing standing on it, and drops the + /// creature on the TERRAIN height there, so a nest on a slope does not bury anyone either. + /// The per-kind height goes on top, which is what keeps the Gjall in the air. + /// + private static Vector3 SpawnSpot(SvermHiveBehaviour hive, Kind kind) + { + Vector3 centre = hive.transform.position; + float radius = RingRadius(hive); + int obstacleMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "vehicle"); + float start = Random.Range(0f, 360f); + + for (int i = 0; i < 12; i++) + { + float angle = (start + i * (360f / 12f)) * Mathf.Deg2Rad; + Vector3 candidate = centre + new Vector3(Mathf.Cos(angle), 0f, Mathf.Sin(angle)) * radius; + if (ZoneSystem.instance != null) candidate.y = ZoneSystem.instance.GetGroundHeight(candidate); + + if (Physics.CheckSphere(candidate + Vector3.up * 1.5f, 1f, obstacleMask)) continue; + + return candidate + Vector3.up * kind.SpawnHeight; + } + + // Twelve tries and everything is built up: due south on the ring anyway. Still outside + // the nest, which is the thing this is here to guarantee. + Vector3 fallback = centre + new Vector3(0f, 0f, -radius); + if (ZoneSystem.instance != null) fallback.y = ZoneSystem.instance.GetGroundHeight(fallback); + return fallback + Vector3.up * kind.SpawnHeight; + } + + /// + /// How wide the ring is: the nest's own footprint plus a couple of metres. + /// + /// MEASURED and not a number, because the nest grows with its stage - a stage four nest is + /// several times the width of the one that was placed, so any fixed radius that clears the + /// small one hatches troops inside the big one. Only solid meshes are measured; the hive's + /// particle effects have bounds of their own and would report a ring the size of a field. + /// + private static float RingRadius(SvermHiveBehaviour hive) + { + Vector3 centre = hive.transform.position; + float widest = 0f; + + foreach (Renderer renderer in hive.GetComponentsInChildren(true)) + { + if (renderer == null) continue; + if (!(renderer is MeshRenderer) && !(renderer is SkinnedMeshRenderer)) continue; + + Bounds bounds = renderer.bounds; // world space, so the stage's growth is already in it + float reach = Mathf.Max(Mathf.Abs(bounds.center.x - centre.x) + bounds.extents.x, + Mathf.Abs(bounds.center.z - centre.z) + bounds.extents.z); + if (reach > widest) widest = reach; + } + + // Nothing readable means nothing to be stuck in either, but the floor keeps a newborn off + // the nest's own doorstep, and the ceiling stops one measuring mistake spawning troops + // half a zone away. + return Mathf.Clamp(widest, 2f, 20f) + SpawnClearance; + } } /// diff --git a/JotunnModStub/Sverm/SvermHive.cs b/JotunnModStub/Sverm/SvermHive.cs index f5ed0ca..59a3b89 100644 --- a/JotunnModStub/Sverm/SvermHive.cs +++ b/JotunnModStub/Sverm/SvermHive.cs @@ -111,7 +111,25 @@ namespace RacesOfValheim wear.m_hitEffect = new EffectList(); } - if (prefab.GetComponent() == null) prefab.AddComponent(); + // PERSISTENT, EXPLICITLY, and this is the whole reason a nest could vanish at world + // load. Every other station in the mod is cloned from a real building - a workbench, a + // barrel, a cartography table - and inherits a ZNetView that is already persistent. The + // nest is the one piece built out of SCENERY, and a CreepProp is not saved with the + // world: it belongs to the location that placed it and is put back by the location, so + // its ZNetView (or the bare one added here, which defaults to false) marks the ZDO as + // throwaway. The hive stood, worked, took biomass - and was not written to the save. + // Next load, no ZDO, no nest. + // + // m_syncInitialScale stays OFF on purpose. It looks like the obvious partner to this + // line and it would be a bug: the stage growth is applied to the transform at runtime, + // so a ZNetView that stored the scale would restore the GROWN size, Awake would read it + // back as builtScale, and the nest would multiply itself by its stage again every + // reload. The size is derived from the stage on the ZDO instead, by every client. + ZNetView view = prefab.GetComponent() ?? prefab.AddComponent(); + view.m_persistent = true; + view.m_distant = false; + view.m_type = ZDO.ObjectType.Default; + prefab.AddComponent(); MountMouths(prefab); diff --git a/JotunnModStub/Sverm/SvermHiveStore.cs b/JotunnModStub/Sverm/SvermHiveStore.cs index d813ee3..c4fd0d1 100644 --- a/JotunnModStub/Sverm/SvermHiveStore.cs +++ b/JotunnModStub/Sverm/SvermHiveStore.cs @@ -336,7 +336,13 @@ namespace RacesOfValheim wear.m_hitEffect = new EffectList(); } - if (prefab.GetComponent() == null) prefab.AddComponent(); + // The workbench this is cloned from brings a persistent ZNetView with it, so this is + // belt as well as braces - but it is the line the NEST turned out to need after players + // reported hives gone at world load, and a counter that saves only because of what + // it was copied from is one refactor away from not saving at all. + ZNetView view = prefab.GetComponent() ?? prefab.AddComponent(); + view.m_persistent = true; + prefab.AddComponent(); Jotunn.Managers.PieceManager.Instance.AddPiece(new Jotunn.Entities.CustomPiece(prefab, fixReference: false, diff --git a/JotunnModStub/Trol/TrolFoodManager.cs b/JotunnModStub/Trol/TrolFoodManager.cs index 727533e..6476d9e 100644 --- a/JotunnModStub/Trol/TrolFoodManager.cs +++ b/JotunnModStub/Trol/TrolFoodManager.cs @@ -1,100 +1,163 @@ using System.Collections.Generic; +using System.Globalization; using UnityEngine; namespace RacesOfValheim { + /// + /// The Trol's 4th and 5th stomach. The runtime side is two dictionaries; the persistent side + /// is four keys in Player.m_customData, which is the only per-character store Valheim writes + /// to disk (Player.Save/Player.Load pack it into the profile). + /// + /// Two rules hold this file together, and both exist because breaking them ate people's food: + /// + /// 1. Never write to m_customData from a path that cannot prove what it is looking at. + /// Removing a key here is not "failing to load" - it is a deletion from the save file. + /// 2. The two slots are independent. Slot 5 is not a continuation of slot 4 and must never + /// be gated behind slot 4 having something in it. + /// public static class TrolFoodManager { - // Runtime dictionary holding the 4th food slot per player + // Runtime dictionaries holding the 4th and 5th food slot per player public static Dictionary ExtraFoods = new Dictionary(); public static Dictionary ExtraFoods5 = new Dictionary(); - // Called when player spawns to load the 4th and 5th food from custom data + private const string Slot4Prefab = "TrolFood_Prefab"; + private const string Slot4Time = "TrolFood_Time"; + private const string Slot5Prefab = "TrolFood5_Prefab"; + private const string Slot5Time = "TrolFood5_Time"; + + // Called when the player spawns, to restore both extra stomachs from custom data. public static void LoadFood(Player player) { if (player == null) return; - - // If they are no longer a Trol, clear it out - if (!TrolRace.IsTrol()) + + // GetPlayerRace returns null when the race cannot be read at all - ZDO empty AND no + // m_customData entry - and that is the case this method used to get catastrophically + // wrong. It asked TrolRace.IsTrol(), which answered a flat "no" during the spawn frame + // (see IsTrol's comment for why), and then called ClearFood on that "no", deleting all + // four keys. Every reload dropped the Trol's 4th and 5th stomach on the floor. + // + // Now only a race we actually READ, and that is not ours, may touch the save file. + // "I cannot tell yet" drops the runtime entries and leaves the disk alone. + string race = FactionHostilityPatch.GetPlayerRace(player); + if (race != "Trol") { - ClearFood(player); + ExtraFoods.Remove(player); + ExtraFoods5.Remove(player); + if (race != null) ClearFood(player); return; } - if (!player.m_customData.ContainsKey("TrolFood_Prefab")) return; + LoadSlot(player, ExtraFoods, Slot4Prefab, Slot4Time); + LoadSlot(player, ExtraFoods5, Slot5Prefab, Slot5Time); + } + + /// + /// Restores one slot. Called once per slot rather than once for both: slot 5 used to sit + /// inside slot 4's early return, so a Trol carrying food in the 5th stomach and nothing in + /// the 4th lost the 5th on every load, independently of everything else wrong here. + /// + private static void LoadSlot(Player player, Dictionary dict, string prefabKey, string timeKey) + { + dict.Remove(player); + + if (!player.m_customData.TryGetValue(prefabKey, out string prefabName)) return; + if (ObjectDB.instance == null) return; - string prefabName = player.m_customData["TrolFood_Prefab"]; GameObject prefab = ObjectDB.instance.GetItemPrefab(prefabName); if (prefab == null) return; ItemDrop itemDrop = prefab.GetComponent(); if (itemDrop == null) return; - // Build food object - Player.Food food = new Player.Food(); - food.m_item = itemDrop.m_itemData.Clone(); // Clone to be safe - - // Try parse remaining time - if (player.m_customData.TryGetValue("TrolFood_Time", out string timeStr) && float.TryParse(timeStr, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out float time)) + float time = 0f; + if (player.m_customData.TryGetValue(timeKey, out string timeStr)) { - food.m_time = time; + float.TryParse(timeStr, NumberStyles.Float, CultureInfo.InvariantCulture, out time); } - - food.m_health = itemDrop.m_itemData.m_shared.m_food; - food.m_stamina = itemDrop.m_itemData.m_shared.m_foodStamina; - food.m_eitr = itemDrop.m_itemData.m_shared.m_foodEitr; - - ExtraFoods[player] = food; - if (player.m_customData.ContainsKey("TrolFood5_Prefab")) + ItemDrop.ItemData.SharedData shared = itemDrop.m_itemData.m_shared; + + // A meal that finished digesting is not restored, and its keys go with it - otherwise + // a stale pair could sit in the save forever, since UpdateFood only prunes what it can + // already see in the dictionaries. + if (shared.m_foodBurnTime > 0f && time >= shared.m_foodBurnTime) { - string prefabName5 = player.m_customData["TrolFood5_Prefab"]; - GameObject prefab5 = ObjectDB.instance.GetItemPrefab(prefabName5); - if (prefab5 != null) - { - ItemDrop itemDrop5 = prefab5.GetComponent(); - if (itemDrop5 != null) - { - Player.Food food5 = new Player.Food(); - food5.m_item = itemDrop5.m_itemData.Clone(); - if (player.m_customData.TryGetValue("TrolFood5_Time", out string timeStr5) && float.TryParse(timeStr5, System.Globalization.NumberStyles.Float, System.Globalization.CultureInfo.InvariantCulture, out float time5)) - { - food5.m_time = time5; - } - food5.m_health = itemDrop5.m_itemData.m_shared.m_food; - food5.m_stamina = itemDrop5.m_itemData.m_shared.m_foodStamina; - food5.m_eitr = itemDrop5.m_itemData.m_shared.m_foodEitr; - ExtraFoods5[player] = food5; - } - } + player.m_customData.Remove(prefabKey); + player.m_customData.Remove(timeKey); + return; } + + Player.Food food = new Player.Food(); + food.m_item = itemDrop.m_itemData.Clone(); + food.m_item.m_stack = 1; + food.m_time = time; + + // Restore the values the stomach actually had, not a fresh meal's. Same lerp + // Trol_PlayerUpdateFood_Patch runs every frame; without it a reload handed back full + // nourishment until the next tick corrected it. + float factor = shared.m_foodBurnTime > 0f ? Mathf.Clamp01(time / shared.m_foodBurnTime) : 0f; + food.m_health = Mathf.Lerp(shared.m_food, shared.m_food * 0.2f, factor); + food.m_stamina = Mathf.Lerp(shared.m_foodStamina, shared.m_foodStamina * 0.2f, factor); + food.m_eitr = Mathf.Lerp(shared.m_foodEitr, shared.m_foodEitr * 0.2f, factor); + + dict[player] = food; } - // Called to save the current runtime 4th food to custom data for persistence + // Saves the current runtime state of both extra stomachs. Authoritative: it is called from + // SetExtraFood/SetExtraFood5, where the dictionaries are known to be current, and it + // removes the keys of an empty slot on purpose. Do NOT call it from anywhere that could + // run before LoadFood has populated the dictionaries - use SaveFoodTimes there. public static void SaveFood(Player player) { if (player == null) return; if (ExtraFoods.TryGetValue(player, out Player.Food food) && food != null && food.m_item != null) { - player.m_customData["TrolFood_Prefab"] = food.m_item.m_dropPrefab.name; - player.m_customData["TrolFood_Time"] = food.m_time.ToString(System.Globalization.CultureInfo.InvariantCulture); + player.m_customData[Slot4Prefab] = food.m_item.m_dropPrefab.name; + player.m_customData[Slot4Time] = food.m_time.ToString(CultureInfo.InvariantCulture); } else { - player.m_customData.Remove("TrolFood_Prefab"); - player.m_customData.Remove("TrolFood_Time"); + player.m_customData.Remove(Slot4Prefab); + player.m_customData.Remove(Slot4Time); } if (ExtraFoods5.TryGetValue(player, out Player.Food food5) && food5 != null && food5.m_item != null) { - player.m_customData["TrolFood5_Prefab"] = food5.m_item.m_dropPrefab.name; - player.m_customData["TrolFood5_Time"] = food5.m_time.ToString(System.Globalization.CultureInfo.InvariantCulture); + player.m_customData[Slot5Prefab] = food5.m_item.m_dropPrefab.name; + player.m_customData[Slot5Time] = food5.m_time.ToString(CultureInfo.InvariantCulture); } else { - player.m_customData.Remove("TrolFood5_Prefab"); - player.m_customData.Remove("TrolFood5_Time"); + player.m_customData.Remove(Slot5Prefab); + player.m_customData.Remove(Slot5Time); + } + } + + /// + /// Writes how far each stomach has digested, and nothing else. Called from a Player.Save + /// prefix, because the time was previously only ever written at the moment of eating - + /// always as 0 - so both extra stomachs came back from a reload at full duration while the + /// three vanilla slots kept their remaining time. + /// + /// This updates existing entries and never removes a key. Player.Save can run at any + /// moment, including before OnSpawned has restored the dictionaries, and a save hook able + /// to empty the save file is the exact bug this file is recovering from. + /// + public static void SaveFoodTimes(Player player) + { + if (player == null) return; + WriteTime(player, ExtraFoods, Slot4Time); + WriteTime(player, ExtraFoods5, Slot5Time); + } + + private static void WriteTime(Player player, Dictionary dict, string timeKey) + { + if (dict.TryGetValue(player, out Player.Food food) && food != null && food.m_item != null) + { + player.m_customData[timeKey] = food.m_time.ToString(CultureInfo.InvariantCulture); } } @@ -131,10 +194,10 @@ namespace RacesOfValheim if (player == null) return; ExtraFoods.Remove(player); ExtraFoods5.Remove(player); - player.m_customData.Remove("TrolFood_Prefab"); - player.m_customData.Remove("TrolFood_Time"); - player.m_customData.Remove("TrolFood5_Prefab"); - player.m_customData.Remove("TrolFood5_Time"); + player.m_customData.Remove(Slot4Prefab); + player.m_customData.Remove(Slot4Time); + player.m_customData.Remove(Slot5Prefab); + player.m_customData.Remove(Slot5Time); } } } diff --git a/JotunnModStub/Trol/TrolFoodPatches.cs b/JotunnModStub/Trol/TrolFoodPatches.cs index 7dc0770..7ff2255 100644 --- a/JotunnModStub/Trol/TrolFoodPatches.cs +++ b/JotunnModStub/Trol/TrolFoodPatches.cs @@ -252,4 +252,22 @@ namespace RacesOfValheim return true; } } + + // m_customData only reaches the disk through Player.Save, and TrolFood_Time / TrolFood5_Time + // were only ever written at the moment of eating - always as 0. Both extra stomachs therefore + // came back from every reload with a full burn time ahead of them, digesting from scratch, + // while the three vanilla slots kept whatever they had left. Refreshing the two timestamps + // just before the package is packed puts all five on the same footing. + // + // A prefix, so the two keys are already in m_customData when Save packs it. SaveFoodTimes only + // updates keys that already exist and never removes one - see its comment for why that + // distinction matters here. + [HarmonyPatch(typeof(Player), nameof(Player.Save))] + public static class Trol_PlayerSave_Patch + { + public static void Prefix(Player __instance) + { + TrolFoodManager.SaveFoodTimes(__instance); + } + } } diff --git a/JotunnModStub/Trol/TrolRace.cs b/JotunnModStub/Trol/TrolRace.cs index ec5376e..36b6936 100644 --- a/JotunnModStub/Trol/TrolRace.cs +++ b/JotunnModStub/Trol/TrolRace.cs @@ -24,12 +24,26 @@ namespace RacesOfValheim } } + // The ZDO copy is authoritative once it has been written - but it is written by a + // Player.OnSpawned postfix in ZdoVisualSync that Harmony registers AFTER this race's own + // OnSpawned postfix (type 363 against type 319 in the built assembly), and the player's + // ZDO is a brand new empty one every session. So on every single load there is a window + // where m_customData is the only place the race exists, and returning out of the ZDO + // branch unconditionally made that window answer "not a Trol" - which is what had + // TrolFoodManager.LoadFood wiping the 4th and 5th stomach out of the save file on reload. + // + // Same fix, same reason, as FactionHostilityPatch.GetPlayerRace: only trust the ZDO + // string when it is non-empty. An explicit "Human" written by resetrace IS non-empty and + // still wins over a stale m_customData, which is the behaviour that fix was added for. public static bool IsTrol() { if (Player.m_localPlayer == null) return false; ZNetView nview = Player.m_localPlayer.GetComponent(); if (nview != null && nview.IsValid()) - return nview.GetZDO().GetString("RacesOfValheim_Race", "") == "Trol"; + { + string zdoRace = nview.GetZDO().GetString("RacesOfValheim_Race", ""); + if (!string.IsNullOrEmpty(zdoRace)) return zdoRace == "Trol"; + } return Player.m_localPlayer.m_customData.TryGetValue("Race", out string r) && r == "Trol"; } diff --git a/README.md b/README.md index e39985e..89d3109 100644 --- a/README.md +++ b/README.md @@ -67,6 +67,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions ### 6. Trol - **Trol Heritage:** 20% larger than a human. +- **Kindling:** the one drawback — fire lands 50% harder on a Trol than on anyone else, and no armour or resistance changes that. - **Immense Strength:** Increased carry weight; armor scales up as you defeat bosses. - **Rock Throwing:** Hurl huge boulders at enemies. - **Tree Weaponry:** At higher tiers, True Form lets you rip logs and wield them as weapons or throw them. @@ -259,7 +260,7 @@ Build a **Brood Mound** with the hammer — no more than two within its density
Trol Progression -- **Base:** +20% size, +200 carry weight, +3 armor per boss. +- **Base:** +20% size, +200 carry weight, +3 armor per boss. Fire hits 50% harder — the race's only weakness. - **Eikthyr:** Increased XP for physical labor and blunt combat. - **Elder:** Rock Throwing unlocked, +10% passive regen. - **Bonemass:** +5% size, +50 carry, +10 club/unarmed damage, +10 rock throw, unlocks 4th food slot. @@ -375,10 +376,12 @@ The size is a slider in Configuration Manager under `Trols Hammer`. Turning the - Build (2 Wood, Hammer/Misc, no crafting station). First placed near Sacrificial Stones in every new world. -Interact to reset race, or switch between: +Interact to reset your race, reset your progression, or switch between: - **World progression:** tier follows world’s bosses. - **Personal progression:** tier saved to character (server independent). +**Reset Progression** drops any tier override you've claimed and falls back to what the world has actually killed — the same thing the `resetprogression` console command does, without the console. + In personal mode, offer boss’s secondary drop to the Ward (Hard Antler, Crypt Key, Wishbone, Dragon Tear, Yagluth’s thing, Queen’s carapace, Fader’s relic) to claim boss tier. --- @@ -404,8 +407,19 @@ The **Sverm** belongs to no faction. Its Hive Pheromones make every invertebrate ## Changelog -### v1.4.6 +### v1.4.8 +- **Fix - Trol losing the 4th and 5th stomach on every reload:** the food was being saved correctly and then deleted while loading. `TrolRace.IsTrol()` read the race from the ZDO and returned that answer even when the ZDO was empty — and the player's ZDO is a brand new empty one every session, written a fraction of a second later by a different `Player.OnSpawned` postfix that Harmony happens to register after the Trol's own. So the loader asked "am I a Trol?" during the one window where the honest answer lives in the save file instead, got told no, and wiped all four keys out of the character. `IsTrol()` now falls back to the saved race when the ZDO has nothing to say (the same fix the hostility patches got in v1.4.6), and the loader is no longer allowed to delete anything on a race it could not read. Food already lost is gone; from this build on it stays. +- **Fix - Trol 5th stomach lost even when the 4th was empty:** a separate bug in the same loader — slot 5 was restored inside slot 4's early return, so a Trol who had eaten into the fifth and let the fourth run out lost the fifth. The two slots are now loaded independently. +- **Fix - Trol extra stomachs restarting full after a reload:** the remaining burn time was only ever written the moment you ate, always as zero, so both extra slots came back from a reload with a whole meal ahead of them while the three vanilla slots kept their leftovers. The time is now written into the character as the game saves, and restored with the right nourishment left in it — the extra stomachs digest across sessions like every other one. +- **Fix - Faction truces vs. raids:** a mob that hunts players never asked about factions at all. `BaseAI.FindEnemy` checks `IsEnemy` while it scans the creatures around it, but when that scan finds nobody it falls through to "grab the nearest player within 200 m" — and every creature spawned by an event hunts players for as long as the event runs. So the Black Forest truce held right up until *the forest is moving*, *you are being hunted* or a Fuling army arrived, at which point the exact three creatures a Trol is supposed to be at peace with — Greydwarves, Trolls and Fulings — came straight for them. That fall-through now respects the same truce as everything else, for every faction. Raiders still tear into your buildings; they just no longer single you out. +- **Fix - Trol compendium was a tier ahead of itself:** every line in the Trol's entry was gated one boss early, so a Trol with nothing killed yet was already being promised the Eikthyr XP bonus that the code only grants after Eikthyr, and True Form was advertised at Bonemass instead of Moder. The whole ladder now matches what the race actually does. +- **Fix - Trol fire weakness was undocumented:** the Trol takes 50% more fire damage and always has, but neither the race-selection blurb nor the compendium ever said so. Both now do, reading the number out of the config so a retuned multiplier can't leave the text lying. + +### v1.4.7 - **NEW - Root of the Elder (Trenta):** one of the Elder's own summoned roots, planted for good instead of fading. Built with the hammer for 5 Guck and 10 Fine Wood once the Elder is down, race locked to the Trenta. It knits its own wounds shut when left alone, and once a minute it repairs **every player-built thing within five meters** — anyone's buildings, not just its owner's. No damage, no armor: the Trenta defends what it has built rather than fighting for it. +- **NEW - Reset Progression on the Race Menu Ward:** the Ward now carries a **Reset Progression** button beside Reset Race, so dropping a claimed tier override and falling back to the world's real boss state no longer needs the console. The button and the `resetprogression` command run the same code, so the two can't drift apart. + +### v1.4.6 - **Fix - Race truces in multiplayer:** every race's mob-truce check (Fenrir/wolves, Aswid, Draugh, Trenta, Sverm, and Skadi/Fenrir/Dvergar's Montagna set including the Drake) read the player's race from a local-only field that is never populated for anyone but your own client. On a dedicated server, or whenever another player ended up owning a mob's AI, the check silently failed and the "neutral" mob stayed hostile — this is why Skadi players were seeing Drakes attack them. Both hostility patches now read the race from the ZDO copy that actually replicates over the network, falling back to the local field only when the ZDO isn't available yet. ### v1.4.5 diff --git a/manifest.json b/manifest.json index 91e2556..47fbce3 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.6", + "version_number": "1.4.8", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From a60f5e82173c01194dd732bd6b2eb366a4bd82e0 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Tue, 25 Aug 2026 19:13:16 +0200 Subject: [PATCH 014/273] fix(factions): make the truce switch cover every player truce, not one of five Reported from a live game: with "Faction truce" off, a Trenta's Greydwarves stayed friendly. The switch was working - it just was not switched over the patch that mattered. Five separate Harmony postfixes answer BaseAI.IsEnemy, and only FactionHostilityPatch was gated. A Trenta reads its Black Forest truce from RaceHostilityManager, which had no switch, so turning the faction one off changed nothing visible. The same held for the Fenrir's wolves, the Aswid's progression list, the Draugh's undead, the Sverm's invertebrates, the Furling's Plains roster and the Skeleton's undead. Gated all four player-facing ones behind the existing flag rather than adding a switch each: from the player's side there is one question being asked, and a switch that answers a fifth of it is worse than none. DvergarMercenaryTrucePatch is deliberately left alone - it is a truce between a hired thrall and a wild dvergr, two NPCs, and has nothing to do with whether mobs come after the player. Key stays "Faction truce" though its scope grew: renaming it would orphan the entry in every .cfg already written, and the file beats the default in code, so anyone who had switched it off would silently get the truce back. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Factions/FactionsConfig.cs | 18 +++++++++++++----- JotunnModStub/Furling/FurlingPatches.cs | 1 + JotunnModStub/RaceHostilityManager.cs | 6 ++++++ JotunnModStub/Skeleton/SkeletonPatches.cs | 1 + 4 files changed, 21 insertions(+), 5 deletions(-) diff --git a/JotunnModStub/Factions/FactionsConfig.cs b/JotunnModStub/Factions/FactionsConfig.cs index 332c622..2898c7a 100644 --- a/JotunnModStub/Factions/FactionsConfig.cs +++ b/JotunnModStub/Factions/FactionsConfig.cs @@ -31,13 +31,21 @@ namespace RacesOfValheim { const string factions = "Factions"; + // Key kept as "Faction truce" even though it now covers the per-race truces too: + // renaming it would orphan the entry in every .cfg already written, and an existing + // .cfg beats the default in code - anyone who had switched this off would silently + // get the truce back. HostilityEnabled = config.Bind(factions, "Faction truce", true, - new ConfigDescription("Mobs of your race's faction leave you alone - they will not open a fight, " + + new ConfigDescription("Mobs your race is at peace with leave you alone - they will not open a fight, " + "hunt you during events, or smash structures near you. Turn this off and every " + - "creature treats you exactly as vanilla would. Does not touch the older per-race " + - "truces in RaceHostilityManager (Fenrir, Aswid, Draugh, Trenta), which have no " + - "switch of their own. Hitting a mob still starts a fight either way: retaliation " + - "runs through BaseAI.OnDamaged, which no truce has a say over.")); + "creature treats you exactly as vanilla would. Covers BOTH halves, because both " + + "answer the same BaseAI.IsEnemy and a switch over only one of them changes " + + "nothing for most races: the faction rules in FactionHostilityPatch, and the " + + "per-race passives in RaceHostilityManager - Fenrir's wolves, Aswid's " + + "progression list, the Draugh's undead, the Trenta's Black Forest, the Sverm's " + + "invertebrates. Switching this off gives those five races up along with the " + + "faction truce. Hitting a mob still starts a fight either way: retaliation runs " + + "through BaseAI.OnDamaged, which no truce has a say over.")); MerchantsEnabled = config.Bind(factions, "Faction merchants", true, new ConfigDescription("Certain mobs of your own faction can be traded with - 'E - Talk' opens a shop " + diff --git a/JotunnModStub/Furling/FurlingPatches.cs b/JotunnModStub/Furling/FurlingPatches.cs index 3588c9d..2ba0df5 100644 --- a/JotunnModStub/Furling/FurlingPatches.cs +++ b/JotunnModStub/Furling/FurlingPatches.cs @@ -75,6 +75,7 @@ namespace RacesOfValheim { public static void Postfix(Character a, Character b, ref bool __result) { + if (!FactionsConfig.Hostility) return; if (!__result || !FurlingRace.IsFurling() || Player.m_localPlayer == null) return; Character playerChar = Player.m_localPlayer; diff --git a/JotunnModStub/RaceHostilityManager.cs b/JotunnModStub/RaceHostilityManager.cs index 0b6b261..ae99bc0 100644 --- a/JotunnModStub/RaceHostilityManager.cs +++ b/JotunnModStub/RaceHostilityManager.cs @@ -12,6 +12,12 @@ namespace RacesOfValheim { public static void Postfix(Character a, Character b, ref bool __result) { + // The per-race truces below answer the same BaseAI.IsEnemy the Factions patches do, + // so the switch has to cover both or it covers nothing: a Trenta reads its Greydwarf + // truce from HERE, not from FactionHostilityPatch, and turning the faction one off + // left the mobs friendly anyway. Same flag rather than a second one, because from + // the player's side there is only one question being asked. + if (!FactionsConfig.Hostility) return; if (!__result) return; // If already not enemies, skip if (a == null || b == null) return; diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index 1e343f6..fda8d95 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -702,6 +702,7 @@ namespace RacesOfValheim { public static void Postfix(Character a, Character b, ref bool __result) { + if (!FactionsConfig.Hostility) return; if (!__result || !SkeletonRace.IsSkeleton() || Player.m_localPlayer == null) return; Character playerChar = Player.m_localPlayer; From 163ad205e7e84ae24943ba6f7730a941c8e95ec0 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Tue, 25 Aug 2026 19:27:14 +0200 Subject: [PATCH 015/273] chore(release): v1.4.9 - Factions on/off switches, serpent meat price, Draugh cooking fix Version bumped in the three places that carry it: manifest.json (the one the packaging target reads), Package/manifest.json and PluginVersion. README: changelog entry for the release, and the Factions section now documents both switches - including the part worth knowing before flipping one, that the truce switch covers every race's own peace and not just the faction rules. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RacesOfValheim.cs | 2 +- README.md | 7 +++++++ manifest.json | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 47fbce3..05a29e0 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.8", + "version_number": "1.4.9", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 8bf1ae8..92802b4 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.8"; + public const string PluginVersion = "1.4.9"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/README.md b/README.md index 89d3109..cb4574c 100644 --- a/README.md +++ b/README.md @@ -403,10 +403,17 @@ Aswid, Draugh, Skeleton / at peace with Ghost, Skeleton, Draugr, Wraith, Leech, The **Sverm** belongs to no faction. Its Hive Pheromones make every invertebrate in the game ignore it instead — leeches, ticks, deathsquitos, seekers and bees — with no boss gate and no trading. +Both halves have an off switch under `Factions` in Configuration Manager: **Faction truce** for whether your faction's mobs leave you alone, **Faction merchants** for whether they will trade. Both are on by default and both take effect without a restart. Be aware that turning the truce off also gives up every race's own peace — Fenrir's wolves, the Aswid's list, the Draugh's undead, the Trenta's Black Forest, the Sverm's invertebrates, the Furling's Plains roster and the Skeleton's undead — because they are all the same question asked of the same vanilla method. + --- ## Changelog +### v1.4.9 +- **NEW - Factions can be switched off:** two toggles under `Factions` in Configuration Manager, both on by default. **Faction truce** decides whether mobs leave you alone; **Faction merchants** decides whether they can be traded with. Both are read live, so flipping either takes effect without restarting the game. Two switches rather than one because the halves fail differently — the truce is invisible when it works, the merchants are a whole second interaction bolted onto creatures vanilla never meant to talk, and anyone chasing a mod conflict wants to rule out one without losing the other. Note that **Faction truce** covers every truce the player has, not only the faction ones: Fenrir's wolves, the Aswid's progression list, the Draugh's undead, the Trenta's Black Forest, the Sverm's invertebrates, the Furling's Plains roster and the Skeleton's undead all answer the same `BaseAI.IsEnemy`, and a switch over one of them would have changed nothing for most races. Switching it off gives those passives up along with the faction truce. The Dvergar mercenaries' truce with wild dvergr is left alone — that one is between two NPCs and has nothing to do with whether mobs come after you. +- **CHANGED - Serpent meat is worth selling again:** the Fuling bench paid **1** gold for it, the same as a scrap of black metal, for something you have to build a boat and win a fight at sea to get. It now pays **200**. +- **Fix - A Draugh could never cook serpent meat:** the raw-to-cooked table asked for a prefab called `SerpentMeatRaw`, which does not exist — the internal id is `SerpentMeat`. Every other meat in the game cooked on the spot for a Draugh and this one silently did nothing. + ### v1.4.8 - **Fix - Trol losing the 4th and 5th stomach on every reload:** the food was being saved correctly and then deleted while loading. `TrolRace.IsTrol()` read the race from the ZDO and returned that answer even when the ZDO was empty — and the player's ZDO is a brand new empty one every session, written a fraction of a second later by a different `Player.OnSpawned` postfix that Harmony happens to register after the Trol's own. So the loader asked "am I a Trol?" during the one window where the honest answer lives in the save file instead, got told no, and wiped all four keys out of the character. `IsTrol()` now falls back to the saved race when the ZDO has nothing to say (the same fix the hostility patches got in v1.4.6), and the loader is no longer allowed to delete anything on a race it could not read. Food already lost is gone; from this build on it stays. - **Fix - Trol 5th stomach lost even when the 4th was empty:** a separate bug in the same loader — slot 5 was restored inside slot 4's early return, so a Trol who had eaten into the fifth and let the fourth run out lost the fifth. The two slots are now loaded independently. diff --git a/manifest.json b/manifest.json index 47fbce3..05a29e0 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.8", + "version_number": "1.4.9", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From cca594015a84c97b0fd4686388504f8f2fa36539 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Tue, 25 Aug 2026 19:36:33 +0200 Subject: [PATCH 016/273] docs(changelog): shorten the serpent meat line to match the published one Co-Authored-By: Claude Opus 5 --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cb4574c..ce261da 100644 --- a/README.md +++ b/README.md @@ -411,7 +411,7 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ### v1.4.9 - **NEW - Factions can be switched off:** two toggles under `Factions` in Configuration Manager, both on by default. **Faction truce** decides whether mobs leave you alone; **Faction merchants** decides whether they can be traded with. Both are read live, so flipping either takes effect without restarting the game. Two switches rather than one because the halves fail differently — the truce is invisible when it works, the merchants are a whole second interaction bolted onto creatures vanilla never meant to talk, and anyone chasing a mod conflict wants to rule out one without losing the other. Note that **Faction truce** covers every truce the player has, not only the faction ones: Fenrir's wolves, the Aswid's progression list, the Draugh's undead, the Trenta's Black Forest, the Sverm's invertebrates, the Furling's Plains roster and the Skeleton's undead all answer the same `BaseAI.IsEnemy`, and a switch over one of them would have changed nothing for most races. Switching it off gives those passives up along with the faction truce. The Dvergar mercenaries' truce with wild dvergr is left alone — that one is between two NPCs and has nothing to do with whether mobs come after you. -- **CHANGED - Serpent meat is worth selling again:** the Fuling bench paid **1** gold for it, the same as a scrap of black metal, for something you have to build a boat and win a fight at sea to get. It now pays **200**. +- **CHANGED - Serpent meat:** now 200 gold at the Fuling bench, up from 1. - **Fix - A Draugh could never cook serpent meat:** the raw-to-cooked table asked for a prefab called `SerpentMeatRaw`, which does not exist — the internal id is `SerpentMeat`. Every other meat in the game cooked on the spot for a Draugh and this one silently did nothing. ### v1.4.8 From c99a386e4fd6dcf4228750842c9d627437fd600c Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Tue, 25 Aug 2026 19:37:33 +0200 Subject: [PATCH 017/273] docs(readme): correct three claims that no longer matched the code - The Sverm intro still promised flight after Yagluth; the Stinger Morph was replaced by the Ravager Strain, which is a Seeker Brute and does not fly. - Trol progression put the 4th food slot behind Bonemass. TrolFoodPatches gates only the 5th (state >= 6); the 4th has never had a gate. - Trol melee bonus listed +10 at Yagluth and left axes out at both tiers. TrolConfig has BonemassMeleeBonus 10 and YagluthMeleeBonus 5, and TrolDamagePatches sends axes to m_slash, so axes do get it. Same three corrections the compendium already got; the README had been missed. Co-Authored-By: Claude Opus 5 --- README.md | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index ce261da..af1aeed 100644 --- a/README.md +++ b/README.md @@ -16,7 +16,7 @@ Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorT The tenth race is an insect. The Sverm never dresses: chest, legs and helm are carapace that never comes off and is always worth a full set of the biome ahead of you — best quality, weightless, no movement penalty. It fights with claws it cannot put down, poison cannot touch it, and no invertebrate in the game will attack it from tier zero. Blunt and fire hit it 40% harder, which is the price. -After the Elder it stops being one body and becomes a colony: a Brood Mound you feed whole stacks to, a Hive Market, a roster of insect troops, captured beehives. After Yagluth it can leave the ground entirely as a deathsquito. +After the Elder it stops being one body and becomes a colony: a Brood Mound you feed whole stacks to, a Hive Market, a roster of insect troops, captured beehives. After Yagluth it can put on a second body entirely and fight as a Seeker Brute. Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions-level-by-level). @@ -260,12 +260,12 @@ Build a **Brood Mound** with the hammer — no more than two within its density
Trol Progression -- **Base:** +20% size, +200 carry weight, +3 armor per boss. Fire hits 50% harder — the race's only weakness. +- **Base:** +20% size, +200 carry weight, +3 armor per boss, 4th food slot from the first meal. Fire hits 50% harder — the race's only weakness. - **Eikthyr:** Increased XP for physical labor and blunt combat. - **Elder:** Rock Throwing unlocked, +10% passive regen. -- **Bonemass:** +5% size, +50 carry, +10 club/unarmed damage, +10 rock throw, unlocks 4th food slot. +- **Bonemass:** +5% size, +50 carry, +10 club/unarmed/axes damage, +10 rock throw. - **Moder:** Unlock True Form. -- **Yagluth:** +5% size, +50 carry, +10 club/unarmed, +5 rock throw, unlocks 5th food slot. +- **Yagluth:** +5% size, +50 carry, +5 club/unarmed/axes, +5 rock throw, unlocks 5th food slot. - **Queen:** Log Weapon (True Form): interact with trees to wield/throw. True Form is massive (2.5x size). - **Fader:** Trees you wield instantly destroy any material in Ashlands. From e042579e17b95be5eba5ee0f53a6c444a73c9f3b Mon Sep 17 00:00:00 2001 From: kanym Date: Tue, 25 Aug 2026 22:48:30 +0200 Subject: [PATCH 018/273] Fix Bone Servant crash when dropping a payload it can't place DropPayload() cloned template.m_itemData straight off the ObjectDB prefab and handed the clone to ItemDrop.DropItem, which instantiates item.m_dropPrefab - a field a clone off a raw prefab never carries (same pitfall already fixed in AswidBloodPotions.MakeFood). The result was an unhandled ArgumentException instantiating null. This fires whenever a servant is holding something with nowhere sealed to put it - e.g. chests without the sigil item yet, as in the bug report - and since the exception aborts before m_payload.Clear() runs, the same broken load is retried, and crashes, on every AI tick after: relogging or killing the servant doesn't clear it, because the payload lives in the ZDO, not the character. Fix: set clone.m_dropPrefab = prefab before dropping, same as the existing fix. --- JotunnModStub/Butler/BoneServantAI.cs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Butler/BoneServantAI.cs b/JotunnModStub/Butler/BoneServantAI.cs index c6eee21..922cb36 100644 --- a/JotunnModStub/Butler/BoneServantAI.cs +++ b/JotunnModStub/Butler/BoneServantAI.cs @@ -921,7 +921,15 @@ namespace RacesOfValheim while (left > 0) { int stack = Mathf.Min(left, max); - ItemDrop.DropItem(template.m_itemData.Clone(), stack, + + // ItemDrop.DropItem instantiates item.m_dropPrefab - a clone off a raw ObjectDB + // prefab does not carry that (see AswidBloodPotions.MakeFood for the same fix). + // Without this, dropping a payload throws instantiating null and never clears + // it, so the same broken load is retried - and crashes - on every AI tick after. + ItemDrop.ItemData clone = template.m_itemData.Clone(); + clone.m_dropPrefab = prefab; + + ItemDrop.DropItem(clone, stack, at + Random.insideUnitSphere * 0.3f, Quaternion.identity); left -= stack; } From 03c1006511eefd9dfbbe29bb54f578febb0846c9 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sat, 29 Aug 2026 08:45:09 +0200 Subject: [PATCH 019/273] fix(butler): the cook's lost meat, the furnace that starved, the coal with nowhere to go Three tester reports against the Bone Servant, all with the same shape: the servant was doing what the code said and the code said the wrong thing. Two vanilla methods were re-read off the IL rather than trusted. RPC_RemoveDoneItem empties ONE slot per call - it finds the first Done slot, spawns its item, clears it and returns - not every slot, as the comment on PullOutput claimed. DoCollect also swept the ground BEFORE pulling, so each visit collected the previous visit's item and dropped a fresh one; since Plan() diverts to PlanDelivery the moment the payload is non-empty, the servant then left for the chest and abandoned what it had just pulled. A working hearth therefore always had exactly one cooked meat lying beside it. Now it pulls first, in a loop bounded by a new ButlerStation.OutputPulls - the slot count for a cooking station, 1 everywhere else, because the fermenter's Ready survives its own tap for the length of the animation and a bare while(HasOutput) would spam RPC_Tap. PlanFuel sat last, behind PlanLoad, and FreeSlots goes back above zero the instant a furnace eats one ore - so loading always had an answer and refuelling never got a turn. The blast furnace burned down to nothing. PlanFuel now runs ahead of PlanLoad, which cannot starve loading in return because FuelWanted is 0 for a station with no work, and it scores candidates by the walk the way PlanLoad does now that the choice matters. PlanDelivery offers the load to the nearest station that will CONSUME it, as material or as fuel, after the chest search fails and before dropping it on the floor. UpdateSmelter only calls SpawnProcessed once the ore queue empties, so the charcoal kiln releases its whole batch at once - exactly the delivery a nearly full chest cannot absorb. The coal now walks into the furnace beside it instead of onto the ground. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Butler/BoneServantAI.cs | 119 ++++++++++++++++++++++---- JotunnModStub/Butler/ButlerStation.cs | 26 +++++- 2 files changed, 124 insertions(+), 21 deletions(-) diff --git a/JotunnModStub/Butler/BoneServantAI.cs b/JotunnModStub/Butler/BoneServantAI.cs index 922cb36..e5c1894 100644 --- a/JotunnModStub/Butler/BoneServantAI.cs +++ b/JotunnModStub/Butler/BoneServantAI.cs @@ -295,8 +295,14 @@ namespace RacesOfValheim // the floor, so PlanRescue would ask a question whose answer is always no. The smith is a // four-state machine and the cook is a five-state one, and that is the whole of the // simplification the split bought. + // REFUEL BEFORE LOAD, and that order is the whole of the blast furnace fix. FreeSlots goes + // back above zero the instant a furnace eats one ore, so while there is scrap left in any + // chest PlanLoad always has an answer and PlanFuel, sitting behind it, never got a turn - + // the furnace was topped up forever and burned down to nothing. Fuel cannot starve loading + // in return, because FuelWanted is zero for a station with no work: an empty furnace asks + // for no coal, gets filled, and only then becomes worth stoking. Job job = m_family == ButlerFamily.Kitchen ? PlanRescue() : null; - job = job ?? PlanCollect() ?? PlanLoad() ?? PlanFuel(); + job = job ?? PlanCollect() ?? PlanFuel() ?? PlanLoad(); if (job != null && (m_job == null || m_job.Kind != job.Kind || m_job.Target != job.Target)) { @@ -449,7 +455,7 @@ namespace RacesOfValheim } /// - /// 3. LOAD. Urgency, then distance - and the urgency of a station with nothing wrong with it is + /// 4. LOAD. Urgency, then distance - and the urgency of a station with nothing wrong with it is /// how long it has been waiting. A metre of walking is worth four seconds of a station standing /// idle, so the far furnace wins eventually instead of never. /// @@ -495,9 +501,20 @@ namespace RacesOfValheim }; } - /// 4. REFUEL. Only stations that actually have something to work on. + /// + /// 3. REFUEL. Only stations that actually have something to work on. + /// + /// Scored by the walk, the same way PlanLoad is, and for a reason that only appeared once this + /// moved up the list: taking the first station in scan order was harmless while refuelling was + /// the job of last resort, but ahead of loading it lets one furnace at the edge of the circle + /// hold the servant while a cold one two metres away waits. + /// private Job PlanFuel() { + Container bestChest = null; + string bestFuel = null; + float bestScore = float.MaxValue; + foreach (ButlerStation station in m_stations) { if (!station.Alive || IsPenalised(station.Id)) continue; @@ -512,16 +529,24 @@ namespace RacesOfValheim Container chest = FindChestWith(fuel); if (chest == null) continue; - return new Job - { - Kind = "fuel", - Target = ZdoOf(chest), - Point = chest.transform.position, - Label = "Fetching " + fuel, - }; + float score = Vector3.Distance(transform.position, chest.transform.position) + + Vector3.Distance(chest.transform.position, station.Position); + if (score >= bestScore) continue; + + bestScore = score; + bestChest = chest; + bestFuel = fuel; } - return null; + if (bestChest == null) return null; + + return new Job + { + Kind = "fuel", + Target = ZdoOf(bestChest), + Point = bestChest.transform.position, + Label = "Fetching " + bestFuel, + }; } /// Where the load in hand is going: on to its station, or back into a chest. @@ -563,8 +588,31 @@ namespace RacesOfValheim }; } - // Every sealed chest is full. Beside the table it goes: a stalled chain is worse than a - // tidy floor, and nothing may vanish (sec. 7.3). + // Every sealed chest is full - but a chest is not the only place a thing can go. A station + // that BURNS what is in hand is a destination too, and for the smith it is usually the + // right one: the charcoal kiln releases its whole batch in one go (verified in the IL - + // UpdateSmelter only calls SpawnProcessed once the ore queue empties), which is exactly the + // delivery a nearly full chest cannot absorb, and the coal it makes is what the furnace + // beside it is waiting for. Offering the load to a consumer before giving up is what turns + // "nowhere to put 20x Coal" into a full blast furnace. + // + // It comes AFTER the chest and not before, so a product still goes home to the chest that + // paid for it whenever there is room; this is the step before the floor, not instead of + // storing. + ButlerStation consumer = StationWanting(); + if (consumer != null) + { + return new Job + { + Kind = "deposit_station", + Target = consumer.Id, + Point = consumer.Position, + Label = "Loading " + Describe(), + }; + } + + // Nothing will take it. Beside the table it goes: a stalled chain is worse than a tidy + // floor, and nothing may vanish (sec. 7.3). return new Job { Kind = "drop", @@ -574,6 +622,29 @@ namespace RacesOfValheim }; } + /// The nearest station that will take something out of the payload, as material or as + /// fuel. No FreeSlots check, for the reason spelled out above the KeyTarget branch: fuel does + /// not go into a slot, and AcceptsAnything already asks the right question of both doors. + private ButlerStation StationWanting() + { + ButlerStation best = null; + float bestDistance = float.MaxValue; + + foreach (ButlerStation station in m_stations) + { + if (!station.Alive || IsPenalised(station.Id)) continue; + if (!station.Operable || !AcceptsAnything(station)) continue; + + float distance = Vector3.Distance(transform.position, station.Position); + if (distance >= bestDistance) continue; + + bestDistance = distance; + best = station; + } + + return best; + } + // ================================================================ execution private void Execute(float dt) @@ -691,23 +762,35 @@ namespace RacesOfValheim /// At a station with something finished. Pull first, sweep second - and the sweep is the only /// place the servant ever picks anything up off the ground, which is what keeps it from tidying /// away things the player left lying about on purpose. + /// + /// THE ORDER IS THE POINT, and it used to be the other way round. Sweeping first meant every + /// visit collected what the LAST visit had thrown on the floor and then threw a fresh one down; + /// since Plan() hands the servant to PlanDelivery the moment it is carrying anything, it walked + /// off to the chest the instant the sweep landed and abandoned the item it had just pulled. + /// While a hearth kept working there was therefore always exactly one cooked meat lying on the + /// ground - the "loses one per batch, whether that is two or five" the testers reported. + /// + /// The loop is the other half of it. RPC_RemoveDoneItem empties ONE slot per call, so a hearth + /// with five done slots needs five calls; one per visit turned one batch into five round trips + /// to the chest. It runs against OutputPulls rather than against HasOutput alone because the + /// fermenter's Ready survives its own tap for the length of the animation. ///
private bool DoCollect() { ButlerStation station = StationById(m_job.Target); if (station == null || !station.Alive) return false; - int before = PayloadCount(); - SweepDrops(station.Position); - bool swept = PayloadCount() > before; - bool pulled = false; - if (station.HasOutput) + for (int i = 0; i < station.OutputPulls && station.HasOutput; i++) { station.PullOutput(transform.position); pulled = true; } + int before = PayloadCount(); + SweepDrops(station.Position); + bool swept = PayloadCount() > before; + if (swept) { // The product belongs to whoever fed the station. If nothing was written there - the diff --git a/JotunnModStub/Butler/ButlerStation.cs b/JotunnModStub/Butler/ButlerStation.cs index 2b47de5..be76226 100644 --- a/JotunnModStub/Butler/ButlerStation.cs +++ b/JotunnModStub/Butler/ButlerStation.cs @@ -155,6 +155,17 @@ namespace RacesOfValheim /// pickup routine will find them.
public abstract void PullOutput(Vector3 at); + /// + /// How many times PullOutput is worth calling in a single visit, which is not the same question + /// as how much is finished. + /// + /// One, everywhere except the hearth. The Fermenter is the reason this is not simply "keep + /// pulling while HasOutput": tapping does not clear Ready straight away - DelayedTap waits + /// m_tapDelay for the animation - so a loop on HasOutput would pull the same tap over and over + /// in one frame. + /// + public virtual int OutputPulls { get { return 1; } } + /// Seconds until something in here is ruined. float.MaxValue for the two families that /// cannot spoil, which is what keeps the urgency comparison honest without special cases. public virtual float SecondsToSpoil { get { return float.MaxValue; } } @@ -394,9 +405,14 @@ namespace RacesOfValheim public override bool HasOutput { get { return Vanilla.Call(Vanilla.CookHaveDone, m_cooking, false); } } /// - /// ONE per done slot, and the 1 is not a stylistic choice. RPC_RemoveDoneItem spawns the - /// item amount times PER SLOT (verified in the IL: the inner loop runs to the - /// argument), so passing anything above 1 would not collect faster - it would print money. + /// ONE CALL, ONE SLOT - and the 1 is the count, not the slot. + /// + /// Read again off the IL after the cook was reported losing a meat per batch, because the + /// first reading of it was wrong in a way that mattered. RPC_RemoveDoneItem walks the slots, + /// finds the FIRST one that is Done, spawns its item amount times, clears that slot, + /// sends RPC_SetSlotVisual and RETURNS. It does not go on to the other slots. So the + /// argument is a multiplier - anything above 1 prints money - and a hearth with five cooked + /// slots needs five calls, which is what OutputPulls below is for. /// public override void PullOutput(Vector3 at) { @@ -404,6 +420,10 @@ namespace RacesOfValheim Nview.InvokeRPC("RPC_RemoveDoneItem", at, 1); } + /// One call per slot, so a full hearth is emptied in one visit instead of one item + /// per errand. The loop that uses this stops on HasOutput anyway; this is only its bound. + public override int OutputPulls { get { return Mathf.Max(1, SlotCount); } } + /// /// The clock this whole feature exists for. Done at m_cookTime, Burnt at 2x - so what is /// left is 2*cookTime - cookedTime, and a slot already Done is the urgent one because its From fcb6cae3ee7c874e3230ca396f7f0089d3fae5ed Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sat, 29 Aug 2026 08:45:17 +0200 Subject: [PATCH 020/273] 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; From 7ac7f99287b2bbcfff773908aa1a03c446065d1f Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sat, 29 Aug 2026 08:45:28 +0200 Subject: [PATCH 021/273] feat(sverm): enforce the beehive cap, and put the aura and the nest limits in config "Beehives per Aura" was bound into the config and then read by nobody. SvermConfigManagement.Beehives had no callers and neither did the constant behind it, so the entry described a limit that did not exist and a player could raise thirty hives in one aura and get thirty workers. SweepAura is two passes now, with the cap between them. The first applies to hives already taken and counts them - that maintenance is not skippable, it is what survives a zone reload - and only then are new candidates considered. One pass would have let the order the physics query happens to return decide whether a hive counted against the cap or was measured by it. The minute keeps running on a hive that does not fit today, so when a taken hive is destroyed the one that has waited longest is claimed on the next sweep instead of starting over; lowering the cap never hands a hive back. Three limits are now the player's: Aura Radius, Nests per Radius and Nest Spacing Radius. PieceDensityLimit.Register takes a snapshot of its numbers, so the Hive Market and the Brood Mound both watch their entries and re-register when one moves - Register replaces an entry rather than stacking a second limit on the same piece. All three are clamped, and the reason is not tidiness: Register REFUSES a radius of zero or a maximum below one, and a refused limit is no limit at all. A player typing 0 into "Nests per Radius" to mean "no nests" would have been handed unlimited nests. Every player-facing string that stated the old numbers now reads the live ones - the two build refusals, the orphaned market's message and hover, and the two Compendium lines. The nest's hover shows the cap next to the count, so moving the knob has visible effect. Co-Authored-By: Claude Opus 5 --- JotunnModStub/RaceCompendium.cs | 6 +- JotunnModStub/Sverm/SvermBeehive.cs | 46 ++++++++++--- JotunnModStub/Sverm/SvermConfig.cs | 8 ++- JotunnModStub/Sverm/SvermConfigManagement.cs | 71 ++++++++++++++++++-- JotunnModStub/Sverm/SvermHive.cs | 27 ++++++-- JotunnModStub/Sverm/SvermHiveStore.cs | 37 +++++++--- 6 files changed, 165 insertions(+), 30 deletions(-) diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 5710509..fcb3abc 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -184,13 +184,13 @@ namespace RacesOfValheim } else { - sb.AppendLine($"Brood Mound (Hammer): Your nest, and no more than two of them may stand within {SvermConfig.HiveDensityRadius:0} meters of each other. Press it, or the hive at its foot, to feed it a whole stack out of your pack: any food, any wood, any resin. Honey and royal jelly are medicine now and it will not take them.\n"); + sb.AppendLine($"Brood Mound (Hammer): Your nest, and no more than {SvermConfigManagement.NestMax} of them may stand within {SvermConfigManagement.NestRadius:0} meters of each other. Press it, or the hive at its foot, to feed it a whole stack out of your pack: any food, any wood, any resin. Honey and royal jelly are medicine now and it will not take them.\n"); sb.AppendLine($"Digestion: what you feed it is not yours to spend yet. It seeps into the nest's bank at {SvermConfigManagement.DigestRate:0.#} a second, and only what has arrived can be spent.\n"); sb.AppendLine($"Brood Eggs: the nest lays one every {SvermConfig.EggInterval:0} seconds and holds {SvermConfig.EggCapBase + 1} of them at its first stage, one more at each stage after. Every troop costs an egg as well as biomass - the egg grows back, the biomass does not.\n"); - sb.AppendLine("Hive Market (Hammer): a counter raised within ten meters of a nest. Everything the colony buys is bought here, out of that nest's bank.\n"); + sb.AppendLine($"Hive Market (Hammer): a counter raised within {SvermConfigManagement.AuraRadius:0} meters of a nest. Everything the colony buys is bought here, out of that nest's bank.\n"); sb.AppendLine($"Growth: {SvermHiveStage.NameOf(2)} {SvermHiveStage.PriceToLeave(1):0}, {SvermHiveStage.NameOf(3)} {SvermHiveStage.PriceToLeave(2):0}, {SvermHiveStage.NameOf(4)} {SvermHiveStage.PriceToLeave(3):0}. Each one costs that stage's whole tankful and opens the next rung of the roster.\n"); @@ -210,7 +210,7 @@ namespace RacesOfValheim sb.AppendLine("Surrenal Glands 800 and Hyperplasia 1600: everything hatched after them is born with one star, then two.\n"); - sb.AppendLine($"The beehives: raise vanilla hives inside the nest's ten meters and the colony takes them over after a minute - twice the speed, three times the honey, and royal jelly instead once Yagluth is down. Press honey or royal jelly on one of your own insects to heal it: {SvermConfig.HoneyHealing:0} and {SvermConfig.RoyalJellyHealing:0}.\n"); + sb.AppendLine($"The beehives: raise vanilla hives inside the nest's {SvermConfigManagement.AuraRadius:0} meters and the colony takes them over after a minute, up to {SvermConfigManagement.Beehives} of them per nest - twice the speed, three times the honey, and royal jelly instead once Yagluth is down. Press honey or royal jelly on one of your own insects to heal it: {SvermConfig.HoneyHealing:0} and {SvermConfig.RoyalJellyHealing:0}.\n"); } knownTexts["Sverm Secrets"] = sb.ToString(); diff --git a/JotunnModStub/Sverm/SvermBeehive.cs b/JotunnModStub/Sverm/SvermBeehive.cs index bd0ad1e..975a540 100644 --- a/JotunnModStub/Sverm/SvermBeehive.cs +++ b/JotunnModStub/Sverm/SvermBeehive.cs @@ -38,19 +38,42 @@ namespace RacesOfValheim /// /// Called by the nest, on a timer. Claims what is in range and ripens what has waited. + /// + /// TWO PASSES, AND THE CAP SITS BETWEEN THEM. "Beehives per Aura" was bound into the config + /// and then read by nobody: the number sat in the file describing a limit that did not + /// exist, and a player could raise thirty hives in one aura and get thirty workers. The + /// maintenance of hives already taken has to happen either way - Apply is what survives a + /// zone reload, so skipping it would quietly hand hives back at vanilla speed - which is + /// exactly why the count has to be finished before the first new one is considered. One + /// pass would let the order the physics query happens to return decide whether a hive + /// counts against the cap or is measured by it. + /// + /// LOWERING THE CAP NEVER UNTAKES ANYTHING. An infected hive is an egg the player has been + /// looking at and a worker that already exists; the cap governs what happens next, not what + /// has happened. Over the cap simply means nothing new is claimed until one goes. /// public static void SweepAura(Vector3 nest) { - foreach (Beehive hive in Find(nest)) + List hives = Find(nest); + int taken = 0; + + foreach (Beehive hive in hives) { ZNetView nview = hive.GetComponent(); if (nview == null || !nview.IsValid()) continue; + if (!nview.GetZDO().GetBool(InfectedKey, false)) continue; - if (nview.GetZDO().GetBool(InfectedKey, false)) - { - Apply(hive, nview); - continue; - } + Apply(hive, nview); + taken++; + } + + int cap = SvermConfigManagement.Beehives; + + foreach (Beehive hive in hives) + { + ZNetView nview = hive.GetComponent(); + if (nview == null || !nview.IsValid()) continue; + if (nview.GetZDO().GetBool(InfectedKey, false)) continue; // First sighting starts the clock. Stored as world time rather than counted in a // field, because a nest that unloads and comes back must not restart the minute. @@ -63,10 +86,17 @@ namespace RacesOfValheim if (ZNet.instance.GetTimeSeconds() - claimedAt < SvermConfig.BeehiveInfectionSeconds) continue; + // Ripe, and the colony may still be full. The cap is tested HERE and not at the top + // of the loop so the minute keeps running on a hive that does not fit today: when a + // taken hive is destroyed, the one that has been waiting longest is claimed on the + // very next sweep instead of starting its minute over. + if (taken >= cap) continue; + nview.GetZDO().Set(InfectedKey, true); Apply(hive, nview); + taken++; - Jotunn.Logger.LogInfo("[Sverm] A beehive has been taken over by the colony."); + Jotunn.Logger.LogInfo($"[Sverm] A beehive has been taken over by the colony ({taken} of {cap})."); } } @@ -130,7 +160,7 @@ namespace RacesOfValheim { List found = new List(); - foreach (Collider collider in Physics.OverlapSphere(nest, SvermConfig.HiveAuraRadius)) + foreach (Collider collider in Physics.OverlapSphere(nest, SvermConfigManagement.AuraRadius)) { if (collider == null) continue; diff --git a/JotunnModStub/Sverm/SvermConfig.cs b/JotunnModStub/Sverm/SvermConfig.cs index 69e7a82..c96e988 100644 --- a/JotunnModStub/Sverm/SvermConfig.cs +++ b/JotunnModStub/Sverm/SvermConfig.cs @@ -351,7 +351,9 @@ namespace RacesOfValheim public static readonly float EyeGlowStrength = 0.22f; // ─── The colony (stub - see SvermHive when that half is written) ───── - /// Two nests per square mile. A square mile is 2.59 km2; the circle of equal area has r = 908 m. + /// Two nests per square mile. A square mile is 2.59 km2; the circle of equal area + /// has r = 908 m. The DEFAULT pair only - both are bound in SvermConfigManagement, and + /// SvermHive re-registers its density limit when either moves. public static readonly float HiveDensityRadius = 908f; public const int HiveDensityMax = 2; @@ -361,8 +363,8 @@ namespace RacesOfValheim // ─── Colony caps ───────────────────────────────────────────────────── // The DEFAULTS. What is actually enforced comes from SvermConfigManagement, which binds // these into the .cfg so a machine that cannot carry nineteen creatures can say so without - // a rebuild. Only the nest density stays out of reach - two per square mile is a rule - // about the world, not a comfort setting. + // a rebuild. Nothing in this block is read directly by the game any more - the nest density + // above was the last exception and it is bound too now. public const int CapBrood = 8; public const int CapSeeker = 6; public const int CapSoldier = 3; diff --git a/JotunnModStub/Sverm/SvermConfigManagement.cs b/JotunnModStub/Sverm/SvermConfigManagement.cs index 72a5051..ccc36e3 100644 --- a/JotunnModStub/Sverm/SvermConfigManagement.cs +++ b/JotunnModStub/Sverm/SvermConfigManagement.cs @@ -60,6 +60,9 @@ namespace RacesOfValheim public static ConfigEntry CapFarmers; public static ConfigEntry CapHaulers; public static ConfigEntry CapBeehives; + public static ConfigEntry AuraRadiusValue; + public static ConfigEntry NestRadiusValue; + public static ConfigEntry NestMaxValue; // ─── The nest and its mark ─────────────────────────────────────────── public static ConfigEntry WorkerChestRangeValue; @@ -137,7 +140,7 @@ namespace RacesOfValheim MarketSizeValue = config.Bind(nest, "Market Bench Size", SvermConfig.MarketSize, "How big the Hive Market bench is, in metres. It is a building you raise inside a " + - "hive's ten metres, not a part of the nest."); + "hive's aura, not a part of the nest - see 'Aura Radius' under Colony Caps."); DigestRateValue = config.Bind(nest, "Digestion Rate", SvermConfig.BiomassDigestRate, "How much biomass moves from digestion into the hive's spendable bank each second. " + @@ -178,9 +181,29 @@ namespace RacesOfValheim "nearby chests into the hive. Separate pool from the farmers."); CapBeehives = config.Bind(caps, "Beehives per Aura", SvermConfig.HiveAuraBeehiveMax, - "How many beehives may stand in one nest's ten metres. Every one of them ends up " + - "infected and producing a worker, so this is the number that really decides how " + - "busy a base gets."); + "How many beehives one nest will take over. Every taken hive ends up producing a " + + "worker, so this is the number that really decides how busy a base gets. Hives past " + + "the cap are left alone and stay the player's; 0 stops the takeover entirely. " + + "Lowering it never hands a hive BACK - what is already the colony's stays taken."); + + AuraRadiusValue = config.Bind(caps, "Aura Radius", SvermConfig.HiveAuraRadius, + "Metres around a nest that count as its aura. It is one circle doing three jobs: " + + "which beehives get taken over, how far a Hive Market may stand from its nest, and " + + "how far a market looks to find one. Takes effect immediately - beehives that fall " + + "outside a shrunk aura simply stop being swept, but a market already built stays " + + "where it is."); + + NestMaxValue = config.Bind(caps, "Nests per Radius", SvermConfig.HiveDensityMax, + "How many Brood Mounds may stand within 'Nest Spacing Radius' of each other. The " + + "default pair, over the default radius, is two nests per square mile. Minimum 1 - " + + "for practical purposes 'no limit' is a large number here, not zero. Only checked " + + "when a nest is PLACED: lowering it leaves nests already standing where they are."); + + NestRadiusValue = config.Bind(caps, "Nest Spacing Radius", SvermConfig.HiveDensityRadius, + "Metres over which 'Nests per Radius' is counted. 908 m is not an arbitrary figure: " + + "it is the radius of a circle with the area of one square mile, which is how the " + + "rule was written down. Counted over ZDOs rather than loaded objects, so a nest on " + + "the far side of the world still counts."); // FOUND IN PLAY: 180, the figure that fixed the flying Deathsquito, faces the Seeker // Brute straight at the camera - its own forward already matches the player's, unlike @@ -248,6 +271,46 @@ namespace RacesOfValheim public static int Haulers => CapHaulers?.Value ?? SvermConfig.CapHaulers; public static int Beehives => CapBeehives?.Value ?? SvermConfig.HiveAuraBeehiveMax; + /// + /// The aura, in metres. Clamped above zero because it is fed straight into an OverlapSphere + /// and into PieceDensityLimit.Register, which refuses a radius of zero and would leave the + /// market uncapped rather than infinitely capped - a typed 0 must not be the one value that + /// turns a limit off. + /// + public static float AuraRadius + { + get + { + float value = AuraRadiusValue?.Value ?? SvermConfig.HiveAuraRadius; + return value > 0.01f ? value : SvermConfig.HiveAuraRadius; + } + } + + /// + /// How far apart nests must be spread, and how many fit. Clamped for the same reason + /// AuraRadius is, and it bites harder here: PieceDensityLimit.Register refuses a radius of + /// zero OR a maximum below one and logs a warning, and a refused limit is not a strict limit + /// - it is NO limit. Typing 0 to mean "no nests" would hand the player unlimited nests, + /// which is the exact opposite of what they asked for. + /// + public static float NestRadius + { + get + { + float value = NestRadiusValue?.Value ?? SvermConfig.HiveDensityRadius; + return value > 0.01f ? value : SvermConfig.HiveDensityRadius; + } + } + + public static int NestMax + { + get + { + int value = NestMaxValue?.Value ?? SvermConfig.HiveDensityMax; + return value >= 1 ? value : 1; + } + } + public static float ChestRange => WorkerChestRangeValue?.Value ?? SvermConfig.WorkerChestRange; public static bool WorkerDebug => WorkerDebugValue?.Value ?? false; diff --git a/JotunnModStub/Sverm/SvermHive.cs b/JotunnModStub/Sverm/SvermHive.cs index 59a3b89..f174aff 100644 --- a/JotunnModStub/Sverm/SvermHive.cs +++ b/JotunnModStub/Sverm/SvermHive.cs @@ -152,10 +152,22 @@ namespace RacesOfValheim }, })); - // Two per square mile, as before. The radius is 908 m because that is the circle of + // Two per square mile by default. The radius is 908 m because that is the circle of // equal area, and PieceDensityLimit counts over ZDOs rather than loaded objects. - PieceDensityLimit.Register(PieceName, SvermConfig.HiveDensityRadius, SvermConfig.HiveDensityMax, - "There is already a hive holding this ground."); + // + // Both numbers are the player's now. Register takes a snapshot, so - exactly as the Hive + // Market does with the aura - the two entries are watched and the limit re-registered + // when either moves; Register replaces the entry rather than stacking a second one. + RegisterNestDensity(); + + if (SvermConfigManagement.NestRadiusValue != null) + { + SvermConfigManagement.NestRadiusValue.SettingChanged += (sender, args) => RegisterNestDensity(); + } + if (SvermConfigManagement.NestMaxValue != null) + { + SvermConfigManagement.NestMaxValue.SettingChanged += (sender, args) => RegisterNestDensity(); + } // The gate. Race first, then the boss - two separate refusals, because "you are not a // Sverm" and "you have not killed The Elder" are different problems and a player who @@ -182,6 +194,13 @@ namespace RacesOfValheim Jotunn.Logger.LogInfo($"[Sverm] Registered '{PieceName}' from '{sourcePrefab}'."); } + /// Re-read how thinly nests must be spread. Safe to call any number of times. + private static void RegisterNestDensity() + { + PieceDensityLimit.Register(PieceName, SvermConfigManagement.NestRadius, SvermConfigManagement.NestMax, + "There is already a hive holding this ground."); + } + /// /// What the two mouths borrow their look from, best first. SCENERY ONLY. /// @@ -444,7 +463,7 @@ namespace RacesOfValheim // disappears is one the player has to notice twice before they believe it. return $"{SvermHiveStage.NameOf(SvermHiveStage.Of(transform))}\n" + SvermHiveReadout.Tank(transform) + - $"Beehives {infected} taken of {beehives} in range\n" + + $"Beehives {infected} taken of {SvermConfigManagement.Beehives} allowed, {beehives} in range\n" + "[$KEY_Use] Feed it a stack"; } diff --git a/JotunnModStub/Sverm/SvermHiveStore.cs b/JotunnModStub/Sverm/SvermHiveStore.cs index c4fd0d1..d194ad3 100644 --- a/JotunnModStub/Sverm/SvermHiveStore.cs +++ b/JotunnModStub/Sverm/SvermHiveStore.cs @@ -366,9 +366,18 @@ namespace RacesOfValheim })); // One counter to a nest. The radius is the nest's own aura, so "another market too close" - // and "inside this nest's ten metres" are the same circle measured from opposite ends. - PieceDensityLimit.Register(PieceName, SvermConfig.HiveAuraRadius, 1, - "This hive already has a market."); + // and "inside this nest's aura" are the same circle measured from opposite ends. + // + // Register takes a SNAPSHOT of the radius, so the aura being configurable means this one + // has to be told when it changes - the gate below and the sweep read the live value on + // every call and need nothing. Re-registering is the documented way to do it: Register + // replaces the entry rather than stacking a second limit on the same piece. + RegisterMarketDensity(); + + if (SvermConfigManagement.AuraRadiusValue != null) + { + SvermConfigManagement.AuraRadiusValue.SettingChanged += (sender, args) => RegisterMarketDensity(); + } PieceDensityLimit.RegisterGate(PieceName, (player, position) => { @@ -380,10 +389,10 @@ namespace RacesOfValheim return false; } - if (SvermHive.NearestNest(position, SvermConfig.HiveAuraRadius) == null) + if (SvermHive.NearestNest(position, SvermConfigManagement.AuraRadius) == null) { player.Message(MessageHud.MessageType.Center, - "A market has to stand within ten metres of a hive."); + $"A market has to stand within {SvermConfigManagement.AuraRadius:0} metres of a hive."); return false; } @@ -392,12 +401,19 @@ namespace RacesOfValheim Jotunn.Logger.LogInfo($"[Sverm] Registered '{PieceName}' from '{sourceName}'."); } + + /// Re-read the aura and cap the market to it. Safe to call any number of times. + private static void RegisterMarketDensity() + { + PieceDensityLimit.Register(PieceName, SvermConfigManagement.AuraRadius, 1, + "This hive already has a market."); + } } /// The bench itself. Press E, the store opens on the nest it stands in. public class SvermHiveMarket : MonoBehaviour, Hoverable, Interactable { - private SvermHiveBehaviour Nest => SvermHive.NearestNest(transform.position, SvermConfig.HiveAuraRadius); + private SvermHiveBehaviour Nest => SvermHive.NearestNest(transform.position, SvermConfigManagement.AuraRadius); public bool Interact(Humanoid user, bool hold, bool alt) { @@ -418,7 +434,8 @@ namespace RacesOfValheim SvermHiveBehaviour nest = Nest; if (nest == null) { - player.Message(MessageHud.MessageType.Center, "No hive within ten metres. This counter is dead."); + player.Message(MessageHud.MessageType.Center, + $"No hive within {SvermConfigManagement.AuraRadius:0} metres. This counter is dead."); return true; } @@ -432,7 +449,11 @@ namespace RacesOfValheim public string GetHoverText() { SvermHiveBehaviour nest = Nest; - if (nest == null) return $"{SvermHiveMarketPiece.DisplayName}\nNo hive within ten metres."; + if (nest == null) + { + return $"{SvermHiveMarketPiece.DisplayName}\n" + + $"No hive within {SvermConfigManagement.AuraRadius:0} metres."; + } return $"{SvermHiveMarketPiece.DisplayName}\n" + SvermHiveReadout.Tank(nest.transform) + From 819abb1a2741a04a66463df812c784d5ef71328d Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sat, 29 Aug 2026 11:47:49 +0200 Subject: [PATCH 022/273] tester-fixes --- JotunnModStub/RaceClaws.cs | 33 +++++++++++++++++++++++++++++---- 1 file changed, 29 insertions(+), 4 deletions(-) diff --git a/JotunnModStub/RaceClaws.cs b/JotunnModStub/RaceClaws.cs index 5d0846d..3e3c540 100644 --- a/JotunnModStub/RaceClaws.cs +++ b/JotunnModStub/RaceClaws.cs @@ -636,10 +636,35 @@ namespace RacesOfValheim // it is put back to full once rather than left as a stale figure in the save file. if (claws.m_durability < claws.GetMaxDurability()) claws.m_durability = claws.GetMaxDurability(); - // Empty-handed means clawed. Anything else in the right hand wins until it is put away, - // which is the whole compromise. - ItemDrop.ItemData held = Traverse.Create((Humanoid)player).Field("m_rightItem").Value; - if (held == null && !player.InAttack()) + // Empty-handed means clawed. Anything the player is actually holding wins until it is + // put away, which is the whole compromise. + // + // BOTH HANDS, and asking only about the right one is what broke the bow. A bow is held + // in m_leftItem, so a bow-wielding player read as empty-handed here and got the claws + // forced into his hands - and Humanoid.EquipItem's OneHandedWeapon branch (read off the + // IL) does this before it puts anything in the right hand: + // + // UnequipItem(m_rightItem); + // if (m_leftItem != null && m_leftItem.m_shared.m_itemType != Shield) + // UnequipItem(m_leftItem); + // + // Everything but a shield is torn out of the left hand. So the archer's bow was pulled + // out from under him, up to twice a second - and not only on the throttled tick, because + // RaceClaws_UnequipItem_Patch calls Maintain from inside UnequipItem and EquipItem calls + // UnequipItem first, so drawing a bow started the fight immediately. + // + // Free is therefore defined as "nothing the claws would displace", which is that rule + // mirrored rather than a second guess at it: a shield stays because equipping the claws + // over a shield costs the player nothing. + Humanoid humanoid = player; + ItemDrop.ItemData right = Traverse.Create(humanoid).Field("m_rightItem").Value; + ItemDrop.ItemData left = Traverse.Create(humanoid).Field("m_leftItem").Value; + + bool leftIsShield = left != null && left.m_shared != null && + left.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Shield; + bool handsFree = right == null && (left == null || leftIsShield); + + if (handsFree && !player.InAttack()) { player.EquipItem(claws, false); } From 8c24ae3340d4a1e65b4bb3ae2e2e9e0eb0f85ba0 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 29 Aug 2026 16:01:23 +0200 Subject: [PATCH 023/273] fix(skeleton): Summon on Kill was completely dead - fix the whole chain Queen/Fader-tier Skeletons were supposed to raise a tamed ally from every kill, but nothing ever spawned. Several independent bugs stacked up: - Kill attribution failed whenever the death blow was a poison DOT tick (SE_Poison builds its own attacker-less HitData every second, and Character.ApplyDamage overwrites m_lastHit on every one of those ticks). Since PoisonAttacks bakes bonus poison onto every Skeleton hit from Bonemass on, this was the common case, not an edge case. Character_Damage_Patch now tracks recent player hits per ZDOID as a fallback (RecentSkeletonHits), the same pattern Aswid's own life-drain-kill check already uses. - SummonPrefabName pointed at "Skeleton_friendly", which isn't a real prefab (confirmed against the live ZNetScene registry). Reuses the Bound Bone Pile's own SkeletonThrall_Melee instead - tamed, loot-stripped, forced-melee, and already proven to work. - The rise VFX names ("vfx_skeleton_spawn", "vfx_bloodmagic_aoe") were guesses that never existed either; fx_summon_skeleton_spawn is the real one. Same fix applied to the pre-existing Auto-Resurrect effect, which had the identical wrong names. - The actual "climbing out of the ground" motion is a separate Animator bool ("wakeup") set via ZSyncAnimation - the exact call vanilla's own CreatureSpawner makes. Without it the model was simply active from frame one, VFX playing around a skeleton that was already standing. - Vanilla skeletons carry no Tameable component, which spammed "is tamed but missing tameable or monster AI script!" every time a raised one landed a hit. Same fix Fenrir already uses for the Ulv and Fenring: copy one in from the vanilla Wolf, done once at prefab registration so it also quietly fixes the Bound Bone Pile's own thralls. - Added RaisedThrall.SetExpiry(), a station-independent hard lifespan - these skeletons are never bound to a pile, so the existing anchor/wither pair had nothing to key off. Summoned skeletons now wither 2 minutes after being raised. Also adds a permanent `listprefabs ` debug console command - queries the live ZNetScene registry directly, which is how the wrong prefab/VFX names above were actually confirmed rather than guessed. --- JotunnModStub/RacesOfValheim.cs | 48 +++++++ JotunnModStub/RaisedThrall.cs | 29 ++++ JotunnModStub/Skeleton/SkeletonBonePile.cs | 25 ++++ JotunnModStub/Skeleton/SkeletonPatches.cs | 135 ++++++++++++++++-- JotunnModStub/Skeleton/SkeletonProgression.cs | 7 +- 5 files changed, 232 insertions(+), 12 deletions(-) diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 92802b4..8a6cdde 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -75,6 +75,7 @@ namespace RacesOfValheim CommandManager.Instance.AddConsoleCommand(new DumpElderCommand()); CommandManager.Instance.AddConsoleCommand(new FenrirPackSpawnCommand()); CommandManager.Instance.AddConsoleCommand(new DumpPotionsCommand()); + CommandManager.Instance.AddConsoleCommand(new ListPrefabsCommand()); } /// @@ -1302,4 +1303,51 @@ namespace RacesOfValheim Console.instance.Print($"[DEBUG] Progression state reset to natural world state: {state}"); } } + + /// + /// Ground truth for "does this prefab actually exist", the same problem that made + /// SummonOnKill's rise VFX ("vfx_skeleton_spawn", "vfx_bloodmagic_aoe") a guess instead of a + /// fact. ZNetScene.GetPrefabNames() is the live registry the running game actually built, so + /// this beats grepping asset bundles offline - those are compressed and unsearchable as plain + /// text, which is exactly why that VFX name had to be confirmed in-game instead. + /// + public class ListPrefabsCommand : ConsoleCommand + { + public override string Name => "listprefabs"; + public override string Help => "[DEBUG] Logs every ZNetScene prefab name containing the given substring (case-insensitive)"; + + public override void Run(string[] args) + { + if (args.Length == 0) + { + Console.instance.Print("Usage: listprefabs "); + return; + } + + if (ZNetScene.instance == null) + { + Console.instance.Print("ZNetScene is not ready yet."); + return; + } + + string filter = args[0]; + System.Collections.Generic.List matches = new System.Collections.Generic.List(); + foreach (string prefabName in ZNetScene.instance.GetPrefabNames()) + { + if (prefabName.IndexOf(filter, System.StringComparison.OrdinalIgnoreCase) >= 0) + { + matches.Add(prefabName); + } + } + matches.Sort(); + + Console.instance.Print($"[DEBUG] {matches.Count} prefab(s) containing '{filter}':"); + Jotunn.Logger.LogInfo($"[DEBUG] listprefabs '{filter}': {matches.Count} match(es)"); + foreach (string name in matches) + { + Console.instance.Print(" " + name); + Jotunn.Logger.LogInfo(" " + name); + } + } + } } diff --git a/JotunnModStub/RaisedThrall.cs b/JotunnModStub/RaisedThrall.cs index c838ec8..5625274 100644 --- a/JotunnModStub/RaisedThrall.cs +++ b/JotunnModStub/RaisedThrall.cs @@ -32,6 +32,12 @@ namespace RacesOfValheim public const string KeyAnchor = "RoV_draughAnchor"; public const string KeyOrphanAt = "RoV_draughOrphanAt"; + // A hard, station-independent lifespan - unlike the wither above, which only starts once + // an anchor's station is gone. Nothing sets this by default; a thrall raised at a real + // pile never expires on its own. SummonOnKill uses it because its skeletons are never + // bound to a pile in the first place, so the anchor/wither pair has nothing to key off. + public const string KeyExpiresAt = "RoV_thrallExpiresAt"; + // ─── Set on the prefab at registration ─────────────────────────────── /// Groups thralls for follower caps and for a station's per-kind roster. @@ -151,6 +157,10 @@ namespace RacesOfValheim if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return; if (m_character == null || m_character.IsDead()) return; + // A hard cap, checked before anything anchor-based - it has to fire regardless of + // where this thrall is standing or whether it is following, unlike the wither below. + if (TickExpiry()) return; + // Checked before anything else, and NOT skipped while following: a thrall out with its // master still has to wither if the station behind it has fallen. if (TickWither()) return; @@ -161,6 +171,25 @@ namespace RacesOfValheim GoHome(); } + /// Sets a hard lifespan from now, independent of any station anchor. Overwrites + /// any expiry already set. + public void SetExpiry(float seconds) + { + if (m_nview == null || !m_nview.IsValid() || ZNet.instance == null) return; + m_nview.GetZDO().Set(KeyExpiresAt, (ZNet.instance.GetTime() + TimeSpan.FromSeconds(seconds)).Ticks); + } + + /// True once it has killed this one for running out the clock set by SetExpiry. + /// A no-op for any thrall that never had one set (the ZDO key stays at its default 0). + private bool TickExpiry() + { + long expiresAt = m_nview.GetZDO().GetLong(KeyExpiresAt, 0L); + if (expiresAt == 0L || ZNet.instance.GetTime() < new DateTime(expiresAt)) return false; + + Kill(); + return true; + } + /// Starts the clock when the station is gone, and stops the thrall when it runs out. /// Returns true once it has killed this one, so the caller stops bothering with it. private bool TickWither() diff --git a/JotunnModStub/Skeleton/SkeletonBonePile.cs b/JotunnModStub/Skeleton/SkeletonBonePile.cs index 19f22f7..8824612 100644 --- a/JotunnModStub/Skeleton/SkeletonBonePile.cs +++ b/JotunnModStub/Skeleton/SkeletonBonePile.cs @@ -252,6 +252,31 @@ namespace RacesOfValheim if (drops != null) Object.DestroyImmediate(drops); } + // Vanilla skeletons carry no Tameable at all. Without one, Character.RaiseSkill logs + // "is tamed but missing tameable or monster AI script!" every time this thrall lands a + // hit - harmless (it only gates the vanilla creature-leveling system, which none of + // this mod's thralls use), but it was never actually silenced until it showed up in + // testing. Same fix Fenrir already uses for the Ulv and the Fenring: copy a real one + // in from the vanilla Wolf. + if (prefab.GetComponent() == null) + { + GameObject wolf = PrefabManager.Cache.GetPrefab("Wolf"); + Tameable sourceTame = wolf != null ? wolf.GetComponent() : null; + if (sourceTame != null) + { + Tameable copy = prefab.AddComponent(); + foreach (System.Reflection.FieldInfo field in typeof(Tameable).GetFields( + System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance)) + { + field.SetValue(copy, field.GetValue(sourceTame)); + } + } + else + { + Jotunn.Logger.LogWarning($"[Skeleton] {prefabName}: could not borrow a Tameable from the vanilla Wolf."); + } + } + RaisedThrall thrall = prefab.AddComponent(); thrall.m_kind = kind; thrall.m_commandingRace = RaceId; diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index fda8d95..78b1cf2 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -583,6 +583,18 @@ namespace RacesOfValheim { private static float lastStunTime = 0f; + // SummonOnKill needs to know "did the local Skeleton player damage this creature + // recently", not just "who threw the exact hit that zeroed its health" - a poison + // DOT tick (SE_Poison.UpdateStatusEffect) builds its own HitData every second with no + // attacker set at all, and Character.ApplyDamage overwrites m_lastHit on every one of + // those ticks. Since PoisonAttacks bakes bonus poison onto every Skeleton hit from + // Bonemass on, a large share of kills finish on an attacker-less poison tick rather + // than the swing itself - Character_OnDeath_Patch falls back to this map when that + // happens. Keyed by ZDOID rather than Character, since the character can already be + // gone by the time OnDeath's Prefix runs. + public static readonly System.Collections.Generic.Dictionary RecentSkeletonHits = + new System.Collections.Generic.Dictionary(); + public static bool Prefix(Character __instance, HitData hit) { if (Player.m_localPlayer == null) return true; @@ -601,9 +613,10 @@ namespace RacesOfValheim Player.m_localPlayer.Heal(Player.m_localPlayer.GetMaxHealth(), true); Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_SkeletonResurrectCooldown".GetStableHashCode(), true); - // Spawn VFX - GameObject vfx = PrefabManager.Cache.GetPrefab("vfx_skeleton_spawn") ?? - PrefabManager.Cache.GetPrefab("vfx_bloodmagic_aoe"); + // Spawn VFX - confirmed real via 'listprefabs'; see SummonOnKill below + // for how the previous two guesses here were caught and replaced. + GameObject vfx = PrefabManager.Cache.GetPrefab("fx_summon_skeleton_spawn") ?? + PrefabManager.Cache.GetPrefab("fx_summon_skeleton"); if (vfx != null) { UnityEngine.Object.Instantiate(vfx, Player.m_localPlayer.transform.position, Quaternion.identity); @@ -619,6 +632,8 @@ namespace RacesOfValheim Character attacker = hit.GetAttacker(); if (attacker != null && attacker == Player.m_localPlayer && SkeletonRace.IsSkeleton()) { + RecentSkeletonHits[__instance.GetZDOID()] = Time.time; + // Auto Stun if (rules.AutoStunFirstHit && Time.time - lastStunTime > SkeletonConfig.AutoStunCooldown.Value) { @@ -653,12 +668,49 @@ namespace RacesOfValheim { public static System.Collections.Generic.List activeMinions = new System.Collections.Generic.List(); + // How long a recent Skeleton hit still counts toward a kill once the actual death + // blow turns out to be an attacker-less poison tick. Poison's own TTL (SE_Poison, + // vanilla) can run well past 10s on a heavy stack, so this errs generous - the only + // cost of a false positive here is one extra friendly skeleton, not anything unsafe. + private const float KillAttributionWindow = 20f; + + // How long a SummonOnKill skeleton lasts before it withers on its own. These are never + // bound to a pile, so RaisedThrall's normal anchor/wither pair has nothing to key off - + // this is the hard, station-independent cap added for exactly that case (see + // RaisedThrall.SetExpiry). + private const float SummonLifetimeSeconds = 120f; + public static void Prefix(Character __instance) { if (Player.m_localPlayer == null || !SkeletonRace.IsSkeleton()) return; - + HitData lastHit = HarmonyLib.Traverse.Create(__instance).Field("m_lastHit").GetValue(); - if (lastHit != null && lastHit.GetAttacker() == Player.m_localPlayer) + bool killedByPlayer = lastHit != null && lastHit.GetAttacker() == Player.m_localPlayer; + + ZDOID zdoid = __instance.GetZDOID(); + if (!killedByPlayer && + Character_Damage_Patch.RecentSkeletonHits.TryGetValue(zdoid, out float hitTime) && + Time.time - hitTime <= KillAttributionWindow) + { + // The death blow was very likely an attacker-less poison DOT tick - see the + // comment on RecentSkeletonHits. Credit the kill anyway. + killedByPlayer = true; + } + + // The map only needs to remember live targets; drop this one and anything else + // that's aged out, so it can't grow across a long play session. + Character_Damage_Patch.RecentSkeletonHits.Remove(zdoid); + if (Character_Damage_Patch.RecentSkeletonHits.Count > 0) + { + var stale = new System.Collections.Generic.List(); + foreach (var kv in Character_Damage_Patch.RecentSkeletonHits) + { + if (Time.time - kv.Value > KillAttributionWindow) stale.Add(kv.Key); + } + foreach (var key in stale) Character_Damage_Patch.RecentSkeletonHits.Remove(key); + } + + if (killedByPlayer) { int state = BossProgressionManager.GetCurrentProgressionState(); var rules = SkeletonProgression.GetRules(state); @@ -671,24 +723,85 @@ namespace RacesOfValheim if (activeMinions.Count < rules.MaxSummons) { GameObject minionPrefab = PrefabManager.Cache.GetPrefab(rules.SummonPrefab); - if (minionPrefab != null) + if (minionPrefab == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] SummonOnKill: no '{rules.SummonPrefab}' prefab in the cache; nothing raised from {__instance.m_name}."); + } + else { GameObject minion = UnityEngine.Object.Instantiate(minionPrefab, __instance.transform.position, Quaternion.identity); Character minionChar = minion.GetComponent(); - - if (minionChar != null) + + if (minionChar == null) { - // Make it friendly + Jotunn.Logger.LogWarning($"[Skeleton] SummonOnKill: '{rules.SummonPrefab}' has no Character component; destroying the spawned instance."); + UnityEngine.Object.Destroy(minion); + } + else + { + // Confirmed against the live ZNetScene registry via + // 'listprefabs' - "vfx_skeleton_spawn" and "vfx_bloodmagic_aoe" + // (used below by Auto-Resurrect too) were both guesses that + // never actually existed. fx_summon_skeleton_spawn is the real + // vanilla effect for exactly this moment. + GameObject riseVfx = PrefabManager.Cache.GetPrefab("fx_summon_skeleton_spawn") ?? + PrefabManager.Cache.GetPrefab("fx_summon_skeleton"); + if (riseVfx != null) + { + UnityEngine.Object.Instantiate(riseVfx, minion.transform.position, Quaternion.identity); + } + else + { + Jotunn.Logger.LogWarning("[Skeleton] SummonOnKill: neither 'fx_summon_skeleton_spawn' nor 'fx_summon_skeleton' resolved to a prefab; no rise effect played."); + } + + // The particles above are dressing; the actual "climbing out of + // the ground" motion is the creature's own Animator, played by + // setting this bool - the exact call vanilla's CreatureSpawner + // makes (see Spawner_Skeleton_rise) when m_wakeUpAnimation is + // set. Without it the model is simply active from frame one. + ZSyncAnimation zAnim = minion.GetComponent(); + if (zAnim != null) + { + zAnim.SetBool("wakeup", true); + } + else + { + Jotunn.Logger.LogWarning($"[Skeleton] SummonOnKill: '{rules.SummonPrefab}' has no ZSyncAnimation; cannot play the wakeup animation."); + } + + // Make it friendly - same as RaisedThrall.Bind(), minus the + // station anchor, since this one wasn't raised at a pile. minionChar.m_faction = Character.Faction.Players; BaseAI ai = minion.GetComponent(); - if (ai != null) + if (ai == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] SummonOnKill: '{rules.SummonPrefab}' has no BaseAI; it will stand where it spawned and never follow."); + } + else { MonsterAI monsterAI = minion.GetComponent(); - if (monsterAI != null) + if (monsterAI == null) { + Jotunn.Logger.LogWarning($"[Skeleton] SummonOnKill: '{rules.SummonPrefab}' has a BaseAI but no MonsterAI; cannot set a follow target."); + } + else + { + monsterAI.MakeTame(); monsterAI.SetFollowTarget(Player.m_localPlayer.gameObject); } } + + RaisedThrall raised = minion.GetComponent(); + if (raised == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] SummonOnKill: '{rules.SummonPrefab}' has no RaisedThrall; it will never wither on its own."); + } + else + { + raised.SetExpiry(SummonLifetimeSeconds); + } + activeMinions.Add(minionChar); } } diff --git a/JotunnModStub/Skeleton/SkeletonProgression.cs b/JotunnModStub/Skeleton/SkeletonProgression.cs index 2e6d9d6..b8f4fb7 100644 --- a/JotunnModStub/Skeleton/SkeletonProgression.cs +++ b/JotunnModStub/Skeleton/SkeletonProgression.cs @@ -47,7 +47,12 @@ namespace RacesOfValheim // shorter and wore a 0.85/1.20/0.85 squeeze to compensate. Tied to the model, not a tier. public static readonly UnityEngine.Vector3 FireModelScale = UnityEngine.Vector3.one; - public const string SummonPrefabName = "Skeleton_friendly"; + // Reuses the Bound Bone Pile's own melee thrall (SkeletonBonePile.ThrallMeleeName) rather + // than a standalone prefab, so a Queen/Fader kill raises the same tamed, loot-stripped, + // forced-melee skeleton the pile does - not a separate, unproven asset. "Skeleton_friendly" + // was tried first and never resolved to a real prefab; see the mod's own log for the + // "no prefab in the cache" warning that caught it. + public const string SummonPrefabName = SkeletonBonePile.ThrallMeleeName; // Fader's dead stand taller than everyone else's. Applied to the player's root transform, // which is how this race has always sized itself - so it carries the collider, the camera From 6968480749fc07e8fd59e514cdf0ff3cbd7cd927 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 29 Aug 2026 16:24:45 +0200 Subject: [PATCH 024/273] chore(release): v1.4.10 - Skeleton Summon on Kill fully fixed Bumps the version and rolls the changelog entry documenting the whole Summon on Kill fix chain from this session into README.md. Also trims the changelog to start at v1.4.0 - everything older now points at the wiki's release notes instead of being duplicated here. --- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RacesOfValheim.cs | 2 +- README.md | 33 +++++++---------------------- manifest.json | 2 +- 4 files changed, 11 insertions(+), 28 deletions(-) diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 05a29e0..ac30f75 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.9", + "version_number": "1.4.10", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 8a6cdde..3d28698 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.9"; + public const string PluginVersion = "1.4.10"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/README.md b/README.md index af1aeed..2c493e4 100644 --- a/README.md +++ b/README.md @@ -409,6 +409,13 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.10 +- **Fix - Summon on Kill (Skeleton) credited almost no kills:** the death blow was usually an attacker-less poison DOT tick rather than a direct hit — Bonemass's Poison Attacks bonus means most Skeleton kills finish that way, and vanilla overwrites `m_lastHit` on every tick, wiping out attribution each time. Kills within a short recent-hit window are now credited even when the literal death blow carries no attacker. +- **Fix - Summon on Kill's skeleton was never real:** `Skeleton_friendly`, the configured prefab, doesn't exist. Reuses the Bound Bone Pile's own tamed, loot-stripped `SkeletonThrall_Melee` instead. +- **Fix - The rise effect never played:** two more guessed prefab names (`vfx_skeleton_spawn`, `vfx_bloodmagic_aoe`) that never existed — the same mistake the pre-existing Auto-Resurrect effect made, fixed there too. Both now play the real `fx_summon_skeleton_spawn`. The "climbing out of the ground" motion is a separate Animator trigger vanilla's own creature spawners set; without it the model was simply standing from the first frame. +- **Fix - Raised skeletons spammed a harmless log warning** on every hit ("is tamed but missing tameable or monster AI script!") — vanilla skeletons carry no `Tameable` component. Same fix Fenrir already uses for the Ulv and Fenring: copy one in from the vanilla Wolf. +- **NEW - Summoned skeletons wither two minutes after being raised**, independent of any station — they were never bound to one, so the existing pile-wither system had nothing to key off. + ### v1.4.9 - **NEW - Factions can be switched off:** two toggles under `Factions` in Configuration Manager, both on by default. **Faction truce** decides whether mobs leave you alone; **Faction merchants** decides whether they can be traded with. Both are read live, so flipping either takes effect without restarting the game. Two switches rather than one because the halves fail differently — the truce is invisible when it works, the merchants are a whole second interaction bolted onto creatures vanilla never meant to talk, and anyone chasing a mod conflict wants to rule out one without losing the other. Note that **Faction truce** covers every truce the player has, not only the faction ones: Fenrir's wolves, the Aswid's progression list, the Draugh's undead, the Trenta's Black Forest, the Sverm's invertebrates, the Furling's Plains roster and the Skeleton's undead all answer the same `BaseAI.IsEnemy`, and a switch over one of them would have changed nothing for most races. Switching it off gives those passives up along with the faction truce. The Dvergar mercenaries' truce with wild dvergr is left alone — that one is between two NPCs and has nothing to do with whether mobs come after you. - **CHANGED - Serpent meat:** now 200 gold at the Fuling bench, up from 1. @@ -487,30 +494,6 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact - **Factions:** Fixed Goblin (Fuling) peace/trade logic across all Black Forest races. - **Aswid:** Proper Goblin food scaling and duration. -### v1.3.12 -- **Skadi:** Flight overhaul: 5s stasis, Shift+W for speed, S for back/up, works from water. All controls and cooldowns visible on HUD. Dragon forms behave for observers. Keybinds clarified. -- **Fenrir:** Body hiding fixed; correct multiplayer visuals. -- **Trenta:** Branch crown added. -- **Draugh:** Rot visuals multiplayer-synced. -- **Skeleton:** Tier unlocks and stat progression fixed; poison/fire immunities now persist through death; health bonus matches progression (not invisible foods); Moder regen fixed; visual unlocks at right tiers; no leftover burning skull glitches. -- **General:** Log spam eliminated for Trol in main menu. - -### v1.3.11 -- **Trenta Race added.** -- **Dvergur renamed to Dvergar.** Existing characters auto-migrate. -- **Dvergar:** Runic Spark: all attacks do scaling lightning damage. -- **Aswid:** Blood Magic Mastery works fully; Vampiric Aura is now passive; correct world "no skill loss" logic. -- **General:** No skill progress lost on death in "no skill loss" worlds. - -### v1.3.10 -- **Dvergur Race added.** -- **Aswid:** Vampiric Aura origin and scaling fixed. -- **Form transforms** (Aswid/Skadi/Fenrir): no longer trigger guardian power by accident. - -### v1.3.9 -- **Transforming** to/from forms: no more forced spawn animation. -- **Multiplayer:** Skadi flight sync and Trol sizing fixed. -- **Aswid:** Food buffs survive death; prey nutrition scaling fixed. -- **General:** Logging cleanup. +Versions before v1.4.0 are no longer listed here — see the [wiki's release notes](https://wiki.aledanidev.ovh/release-notes) for the full history back to v1.0.0. ![Furling](https://wiki.aledanidev.ovh/assets/images/fur.gif) diff --git a/manifest.json b/manifest.json index 05a29e0..ac30f75 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.9", + "version_number": "1.4.10", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 5104f86ede6f79816d37d9e83bd24078526b2850 Mon Sep 17 00:00:00 2001 From: kanym Date: Sun, 30 Aug 2026 19:07:17 +0200 Subject: [PATCH 025/273] chore(release): v1.4.11 - Bone Servant, input-lockout and Sverm beehive-cap fixes Bumps the version and rolls the tester-fixes merge into the changelog: the Bone Servant cook losing meat and the furnace starving on fuel, an input gate that let abilities fire with the build menu open, and the Sverm beehive cap that was configured but never actually read. --- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RacesOfValheim.cs | 2 +- README.md | 7 +++++++ manifest.json | 2 +- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index ac30f75..64c27c6 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.10", + "version_number": "1.4.11", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 3d28698..a0f4dc0 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.10"; + public const string PluginVersion = "1.4.11"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/README.md b/README.md index 2c493e4..7296f46 100644 --- a/README.md +++ b/README.md @@ -409,6 +409,13 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.11 +- **Fix - Bone Servant cook only ever produced one meat:** the servant swept the ground for its finished item *before* pulling a new one out of the station, so each visit collected the previous visit's item and left without grabbing what it had just pulled loose — a working hearth always had exactly one cooked meat sitting beside it. It now pulls first, in a loop bounded by the station's own slot count. +- **Fix - Bone Smith refuelling never got a turn:** fuel-loading ran behind ore-loading, and a furnace's free slots reopen the instant it eats one ore — so ore-loading always had an answer and the furnace burned down to nothing between visits. Fuel now loads first. +- **Fix - A full chest meant fuel got dropped on the ground:** delivery now offers a load to the nearest station that will actually consume it, as material or as fuel, before giving up and dropping it — so a charcoal kiln's whole released batch walks into the furnace beside it instead of piling up on the floor. +- **Fix - Abilities could fire with the build menu open:** Skadi's Cold Spell (and every other bound ability, since this is the mod's single input gate) kept casting while the piece-selection panel was open. Vanilla's own input-blocking check has no reason to include the build menu — build input is handled separately — but a mod ability reading input directly does. The build menu is now part of that check, for every race. +- **NEW - Sverm colony limits are configurable, and the beehive cap is actually enforced:** `Beehives per Aura` was already a config entry, but nothing read it — a player could take over every hive in range and get unlimited free workers. It's now enforced, alongside two new entries, `Aura Radius` and `Nest Spacing Radius`, both clamped so a 0 or absurd value can't be typed in to mean "unlimited." Every player-facing message — the build refusals, the orphaned market's hover text, the compendium — now reads the live numbers instead of the old hardcoded ones. + ### v1.4.10 - **Fix - Summon on Kill (Skeleton) credited almost no kills:** the death blow was usually an attacker-less poison DOT tick rather than a direct hit — Bonemass's Poison Attacks bonus means most Skeleton kills finish that way, and vanilla overwrites `m_lastHit` on every tick, wiping out attribution each time. Kills within a short recent-hit window are now credited even when the literal death blow carries no attacker. - **Fix - Summon on Kill's skeleton was never real:** `Skeleton_friendly`, the configured prefab, doesn't exist. Reuses the Bound Bone Pile's own tamed, loot-stripped `SkeletonThrall_Melee` instead. diff --git a/manifest.json b/manifest.json index ac30f75..64c27c6 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.10", + "version_number": "1.4.11", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 6193b3ee2d5720f7d2d6ae89589085df34d70995 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 10 Sep 2026 18:05:24 +0200 Subject: [PATCH 026/273] 1.0 compatibility --- JotunnModStub/Aswid/AswidBatAggro.cs | 182 ++++++++++++++++++ JotunnModStub/Aswid/AswidBatFlight.cs | 57 ++++++ JotunnModStub/Aswid/AswidConfig.cs | 16 ++ JotunnModStub/Aswid/AswidPatches.cs | 4 +- JotunnModStub/Aswid/AswidRace.cs | 67 ++++++- JotunnModStub/Aswid/AswidThrall.cs | 4 + JotunnModStub/Aswid/BatFormBehavior.cs | 48 ++++- JotunnModStub/BossProgressionManager.cs | 30 +++ JotunnModStub/Dvergar/DvergarBanco.cs | 4 +- JotunnModStub/Dvergar/DvergarBotte.cs | 4 +- .../Factions/FactionMerchantSellPanel.cs | 2 +- JotunnModStub/Furling/FurlingFireAbility.cs | 4 +- JotunnModStub/Furling/FurlingPatches.cs | 2 +- JotunnModStub/MaterialManPropertyBlockFix.cs | 57 ++++++ JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/PieceDensityLimit.cs | 4 +- JotunnModStub/RaceMenuWard.cs | 9 +- JotunnModStub/RacesOfValheim.cs | 55 +++++- JotunnModStub/Skadi/DrakeFormBehavior.cs | 6 +- JotunnModStub/Skadi/SkadiConfig.cs | 12 ++ JotunnModStub/Skadi/SkadiMagicSkill.cs | 83 ++++++++ JotunnModStub/Skadi/SkadiPatches.cs | 4 +- JotunnModStub/Skadi/SkadiRace.cs | 12 +- JotunnModStub/Skeleton/SkeletonRace.cs | 5 +- JotunnModStub/Sverm/SvermHive.cs | 4 + JotunnModStub/Sverm/SvermHiveStore.cs | 8 + JotunnModStub/Sverm/SvermVisuals.cs | 31 +-- JotunnModStub/Trenta/TrentaElderRoot.cs | 4 +- JotunnModStub/Trenta/TrentaPatches.cs | 4 +- JotunnModStub/Trol/TrolTotem.cs | 4 +- JotunnModStub/ZdoVisualSync.cs | 5 +- README.md | 26 ++- manifest.json | 2 +- 33 files changed, 712 insertions(+), 49 deletions(-) create mode 100644 JotunnModStub/Aswid/AswidBatAggro.cs create mode 100644 JotunnModStub/Aswid/AswidBatFlight.cs create mode 100644 JotunnModStub/MaterialManPropertyBlockFix.cs create mode 100644 JotunnModStub/Skadi/SkadiMagicSkill.cs diff --git a/JotunnModStub/Aswid/AswidBatAggro.cs b/JotunnModStub/Aswid/AswidBatAggro.cs new file mode 100644 index 0000000..3bb4e6f --- /dev/null +++ b/JotunnModStub/Aswid/AswidBatAggro.cs @@ -0,0 +1,182 @@ +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Why nothing in Valheim ever attacked the bat, and the smallest honest fix for it. + /// + /// The bat flies on Player.m_debugFly - the developer no-clip flag - because that is the only + /// flight vanilla actually has, and it is what BatFormBehavior sets and WarVultureMount reuses. + /// What nobody noticed is that vanilla reads that same flag as "this player is not really + /// here". Six places, all read out of assembly_valheim with Cecil rather than guessed: + /// + /// BaseAI.CanHearTarget - first line: the target is a Player in debug fly -> return false. + /// BaseAI.CanSeeTarget - the same first line, the same false. + /// BaseAI.FindEnemy - its HuntPlayer fallback throws the player away for the same reason. + /// MonsterAI.UpdateSleep - a sleeping monster refuses to wake for one, twice over. + /// Character.ApplyDamage - first line: IsDebugFlying -> return, the hit does nothing. + /// Character.RPC_Damage - the same. + /// + /// So the bat was never merely ignored: it was invulnerable as well, and both facts came out of + /// the one flag. There was nothing wrong with the Aswid's own code, which is why nothing in it + /// looked wrong. + /// + /// The fix keeps the flag - it IS the flight - and lies about it in exactly the places that + /// decide aggro and damage, and nowhere else: + /// + /// Player.InDebugFlyMode() is forced false for a bat unconditionally. That is safe, and it is + /// the reason this file is short: a scan of the whole assembly says that method has + /// exactly three callers, and all three are the sensing paths listed above. No part of + /// flight, camera, stamina or motion goes through it. + /// Player.IsDebugFlying() is NOT forced false, because Character.UpdateMotion reads it and + /// that read is what holds the bat in the air. It is only forced false while the call + /// stack is inside one of the three vanilla methods that must not honour it, which is + /// what the depth counter below is for. + /// + /// Both halves sit behind their own config toggle, so a bat can be made visible-but-immortal, + /// or put back the way it was, without touching code. + /// + public static class AswidBatForm + { + /// + /// The ZDO flag AswidRace writes when the form goes up. Replicated, so it answers for + /// remote players too - which matters here, because the machine asking "is this player a + /// bat" is whichever one owns the monster, not the bat's own. + /// + public const string BatZdoKey = "Aswid_IsBatForm"; + + private static readonly int BatFormHash = "SE_BatForm".GetStableHashCode(); + + // How deep we currently are inside vanilla calls that must not see the debug-fly flag. A + // counter and not a bool: ApplyDamage runs inside RPC_Damage, so the frames nest. + private static int unmaskDepth; + + public static bool Unmasked => unmaskDepth > 0; + public static void PushUnmask() { unmaskDepth++; } + public static void PopUnmask() { if (unmaskDepth > 0) unmaskDepth--; } + + /// + /// The ZDO first and the status effect only as a fallback: the ZDO is the one that is true + /// on every client, and the status effect covers the local player during the frames of the + /// transform where the ZDO write has not landed yet. + /// + public static bool IsBat(Player player) + { + if (player == null) return false; + + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid() && nview.GetZDO().GetBool(BatZdoKey, false)) return true; + + return player == Player.m_localPlayer && + player.GetSEMan() != null && + player.GetSEMan().HaveStatusEffect(BatFormHash); + } + } + + /// + /// The whole of the aggro fix. See AswidBatForm for why patching this one method flat is safe, + /// and why patching IsDebugFlying flat would drop the bat out of the sky instead. + /// + [HarmonyPatch(typeof(Player), "InDebugFlyMode")] + public static class Aswid_BatIsVisibleToAI_Patch + { + public static void Postfix(Player __instance, ref bool __result) + { + if (!__result) return; + if (AswidConfig.BatFormAggro != null && !AswidConfig.BatFormAggro.Value) return; + if (AswidBatForm.IsBat(__instance)) __result = false; + } + } + + /// + /// The scoped half. Only ever fires inside the three vanilla methods that push the counter, and + /// only for a player who is a bat - so the flag still reads true everywhere flight, motion, the + /// camera and Player.UpdateStats look at it. + /// + [HarmonyPatch(typeof(Player), "IsDebugFlying")] + public static class Aswid_BatIsDebugFlying_Patch + { + public static void Postfix(Player __instance, ref bool __result) + { + if (!__result || !AswidBatForm.Unmasked) return; + if (AswidBatForm.IsBat(__instance)) __result = false; + } + } + + /// + /// A hit landing on a bat. Finalizer rather than Postfix throughout this file: the counter has + /// to come back down even when the patched method throws, and a Postfix does not run then. A + /// void Finalizer leaves the original exception alone, so nothing is swallowed either. + /// + [HarmonyPatch(typeof(Character), "ApplyDamage")] + public static class Aswid_BatTakesDamage_Patch + { + public static void Prefix(Character __instance, ref bool __state) + { + __state = (AswidConfig.BatFormVulnerable == null || AswidConfig.BatFormVulnerable.Value) + && __instance is Player player && AswidBatForm.IsBat(player); + if (__state) AswidBatForm.PushUnmask(); + } + + public static void Finalizer(bool __state) + { + if (__state) AswidBatForm.PopUnmask(); + } + } + + /// The networked half of the same thing: a hit sent by another machine. + [HarmonyPatch(typeof(Character), "RPC_Damage")] + public static class Aswid_BatTakesRemoteDamage_Patch + { + public static void Prefix(Character __instance, ref bool __state) + { + __state = (AswidConfig.BatFormVulnerable == null || AswidConfig.BatFormVulnerable.Value) + && __instance is Player player && AswidBatForm.IsBat(player); + if (__state) AswidBatForm.PushUnmask(); + } + + public static void Finalizer(bool __state) + { + if (__state) AswidBatForm.PopUnmask(); + } + } + + /// + /// Sleepers. Unlike the two above this cannot pre-check who the player is - UpdateSleep picks + /// the closest one itself, and that may be a remote bat - so the counter goes up for the whole + /// call and the per-player test happens in the IsDebugFlying postfix, where it costs nothing: + /// that postfix only runs at all for a character who is already flying. + /// + [HarmonyPatch(typeof(MonsterAI), "UpdateSleep")] + public static class Aswid_BatWakesSleepers_Patch + { + public static void Prefix(ref bool __state) + { + __state = AswidConfig.BatFormAggro == null || AswidConfig.BatFormAggro.Value; + if (__state) AswidBatForm.PushUnmask(); + } + + public static void Finalizer(bool __state) + { + if (__state) AswidBatForm.PopUnmask(); + } + } + + /// + /// Dying as a bat only became possible with the patches above, and the revert path could not + /// handle it: AswidRace.Update() returns early on IsDead(), so the coroutine that takes the + /// form down never starts. The debug-fly flag would stay on and the ZDO would stay true, which + /// is a respawned player floating over the ground with a bat drawn on them. + /// + [HarmonyPatch(typeof(Player), "OnDeath")] + public static class Aswid_BatDiesAsBat_Patch + { + public static void Prefix(Player __instance) + { + if (__instance != Player.m_localPlayer) return; + if (AswidRace.Instance == null) return; + AswidRace.Instance.HardResetBatForm(); + } + } +} diff --git a/JotunnModStub/Aswid/AswidBatFlight.cs b/JotunnModStub/Aswid/AswidBatFlight.cs new file mode 100644 index 0000000..e101fb7 --- /dev/null +++ b/JotunnModStub/Aswid/AswidBatFlight.cs @@ -0,0 +1,57 @@ +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// How fast the bat flies, as a factor on vanilla's own debug-fly speed. + /// + /// The form flies on Player.m_debugFly (see AswidBatForm for why), so its speed is whatever + /// Character.UpdateDebugFly decides. Read out of assembly_valheim rather than assumed, that + /// method ends with: + /// + /// m_currentVel = Vector3.Lerp(m_currentVel, b, 0.5f); + /// m_body.linearVelocity = m_currentVel; + /// + /// where b is m_moveDir times m_debugFlySpeed - a public STATIC INT, 20 by default, times 2.5 + /// while the run key is held. + /// + /// Two ways to make that faster were rejected before this one: + /// + /// Retuning m_debugFlySpeed around the call. It is shared by every character in the game and + /// it is an int, so a 1.35x multiplier would land on 27 and a 1.37x on the same 27 - the + /// slider would move in 5% steps and would be writing a global while it did it. + /// + /// Scaling m_currentVel itself, which is what WarVultureMount does for the bird. That field + /// is the input to the NEXT frame's lerp, so scaling it feeds back: with a factor s the + /// velocity settles at 0.5s/(1-0.5s) times vanilla, not s times it, and at s >= 2 it does + /// not settle at all. + /// + /// So only the rigidbody is scaled, and m_currentVel is left exactly as vanilla wrote it. The + /// lerp keeps smoothing the same trajectory it always did - the ramp up, the ease off, the + /// standstill at zero input - and the bat simply covers it faster. Linear in the slider, with + /// nothing to accumulate. + /// + [HarmonyPatch(typeof(Character), "UpdateDebugFly")] + public static class Aswid_BatFlightSpeed_Patch + { + public static void Postfix(Character __instance, Vector3 ___m_currentVel, Rigidbody ___m_body) + { + // Bound from RacesOfValheim.Awake(), before harmony.PatchAll() - the null check is for + // the config that failed to bind at all, not for a race between the two. + if (AswidConfig.BatFormFlightSpeed == null) return; + + float multiplier = AswidConfig.BatFormFlightSpeed.Value; + if (Mathf.Approximately(multiplier, 1f)) return; + + // Local player only. Every other machine's bat moves on its replicated position, and + // scaling velocity here would fight that sync rather than help it. + Player player = __instance as Player; + if (player == null || player != Player.m_localPlayer) return; + if (___m_body == null) return; + if (!AswidBatForm.IsBat(player)) return; + + ___m_body.linearVelocity = ___m_currentVel * multiplier; + } + } +} diff --git a/JotunnModStub/Aswid/AswidConfig.cs b/JotunnModStub/Aswid/AswidConfig.cs index fd8ef0a..498f63e 100644 --- a/JotunnModStub/Aswid/AswidConfig.cs +++ b/JotunnModStub/Aswid/AswidConfig.cs @@ -33,6 +33,14 @@ namespace RacesOfValheim public static ConfigEntry BloodMagicSkillGainMultiplier; public static ConfigEntry SurtlingFormDamageBonus; + // ─── Bat Form ──────────────────────────────────────────────────────────── + // Both of these undo something vanilla does to any player on the debug-fly flag, which is + // what the bat flies on. See AswidBatAggro for the six vanilla methods involved. + public static ConfigEntry BatFormAggro; + public static ConfigEntry BatFormVulnerable; + // A factor on vanilla's debug-fly speed, not a speed in metres - see AswidBatFlight. + public static ConfigEntry BatFormFlightSpeed; + // ─── Vampiric Aura (passive, always active) ────────────────────────────── public static ConfigEntry AuraTickInterval; public static ConfigEntry AuraRadiusDay; @@ -122,6 +130,14 @@ namespace RacesOfValheim SurtlingFormDamageBonus = config.Bind(combat, "Surtling Form Damage Bonus", 30f, new ConfigDescription("Flat damage added to every attack once the tier 8 Surtling form is unlocked.", new AcceptableValueRange(0f, 100f))); + const string batform = "Aswid - Bat Form"; + BatFormAggro = config.Bind(batform, "Monsters Notice The Bat", true, + new ConfigDescription("Lets monsters see, hear and wake up for a player in Bat Form. Vanilla refuses to notice anyone flying on the debug-fly flag, which is the flag the form uses - turn this off to go back to a bat nothing ever looks at.")); + BatFormVulnerable = config.Bind(batform, "The Bat Can Be Hurt", true, + new ConfigDescription("Lets damage land on a player in Bat Form. Same cause as the setting above: vanilla drops every hit on a debug-flying character. Turn this off for a bat that is noticed and chased but cannot be killed.")); + BatFormFlightSpeed = config.Bind(batform, "Flight Speed", 1f, + new ConfigDescription("How fast the bat flies, as a multiplier on the game's own flight speed (20 m/s, and 2.5x that while the run key is held). 1 is untouched, 2 is twice as fast, 0.5 is half. Local only - it changes how your own bat moves, not anyone else's.", new AcceptableValueRange(0.25f, 3f))); + const string aura = "Aswid - Vampiric Aura"; AuraTickInterval = config.Bind(aura, "Tick Interval", 0.25f, new ConfigDescription("Seconds between aura damage/lifesteal ticks.", new AcceptableValueRange(0.05f, 2f))); diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 0353ae1..5375aad 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -53,7 +53,9 @@ namespace RacesOfValheim - [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })] + // Valheim 1.0 appended a 'short variant' parameter to this overload. The type array has to + // match it exactly or the patch silently fails to bind and PatchAll throws. + [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })] public static class AswidSEManPatch { public static bool Prefix(SEMan __instance, ref int nameHash) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index d86cc69..4fe1d7e 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -416,6 +416,17 @@ namespace RacesOfValheim { StartCoroutine(RevertMistFormRoutine()); } + + // Same rule for a night-only bat: a form the sun forbids cannot be kept through the + // sunrise, or the daylight gate above would only be one night's patience away from + // meaningless. activeRules is what the transform was actually granted under, so an + // Aswid who has killed The Elder (NeedsNight false) keeps flying into the morning. + if (IsTransformed && !isTransformingSequence && activeRules != null && activeRules.NeedsNight && + EnvMan.instance != null && EnvMan.IsDay()) + { + Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The morning sun drives the bat back into your body"); + StartCoroutine(RevertToHumanRoutine()); + } } private string DumpGameObject(GameObject go, string indent) @@ -509,6 +520,17 @@ namespace RacesOfValheim return; } + // The night gate lives here, not in GetGKeyRules: the rules only say WHETHER night is + // required (state 2, Eikthyr) or not (state 3+, The Elder). Nothing ever read the + // NeedsNight flag, so an Aswid who had only killed Eikthyr could turn into a bat in + // broad daylight. Placed after the revert branch on purpose - a bat caught by the + // sunrise must always be able to turn back. + if (rules.NeedsNight && (EnvMan.instance == null || !EnvMan.IsNight())) + { + Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The sun burns. You can only take bat form at night."); + return; + } + StartCoroutine(TransformIntoBatRoutine(rules)); } @@ -524,6 +546,49 @@ namespace RacesOfValheim } } + /// + /// Everything RevertToHumanRoutine does, minus the puff of smoke and the scale animation, + /// and without a coroutine - because the one moment this exists for is death, and by then + /// Update() has already bailed out on IsDead(), so a coroutine started here would be the + /// only thing still running on a corpse. + /// + /// Leaving the form up costs more than a missing animation: m_debugFly stays on, so the + /// respawned player floats; Aswid_IsBatForm stays true in the ZDO, so every other client + /// keeps drawing a bat over a body that is walking around as a person; and the 5% scale + /// stays on the transform. Called from Aswid_BatDiesAsBat_Patch. + /// + public void HardResetBatForm() + { + Player player = Player.m_localPlayer; + if (player == null) return; + if (!IsTransformed && !isTransformingSequence) return; + + if (currentTransformation != null) + { + Destroy(currentTransformation); + currentTransformation = null; + } + + PlayerVisualHider.Show(player.transform.Find("Visual"), "aswid-bat-death-reset"); + + if (player.GetSEMan() != null) + player.GetSEMan().RemoveStatusEffect("SE_BatForm".GetStableHashCode(), true); + + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid()) + { + nview.GetZDO().Set("Aswid_IsBatForm", false); + nview.GetZDO().Set(ZDOVars.s_debugFly, false); + } + Traverse.Create(player).Field("m_debugFly").SetValue(false); + + player.transform.localScale = Vector3.one; + + IsTransformed = false; + activeRules = null; + isTransformingSequence = false; + } + private System.Collections.IEnumerator TransformIntoBatRoutine(AswidProgression.FormRules rules) { isTransformingSequence = true; @@ -961,7 +1026,7 @@ namespace RacesOfValheim // Create an invisible virtual inventory so the food never goes to the real bag Inventory virtualInv = new Inventory("AswidStomach", null, 1, 1); - ItemDrop.ItemData addedItem = virtualInv.AddItem(foodPrefab.name, 1, 1, 0, 0, ""); + ItemDrop.ItemData addedItem = virtualInv.AddItem(foodPrefab.name, 1, 1, 0, 0, "", false); if (addedItem != null) { diff --git a/JotunnModStub/Aswid/AswidThrall.cs b/JotunnModStub/Aswid/AswidThrall.cs index 8d8297f..816517e 100644 --- a/JotunnModStub/Aswid/AswidThrall.cs +++ b/JotunnModStub/Aswid/AswidThrall.cs @@ -151,6 +151,10 @@ namespace RacesOfValheim } } + // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a + // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour. + public float GetHoverOffset() => 0f; + public string GetHoverName() { return ""; // Character component already provides the name diff --git a/JotunnModStub/Aswid/BatFormBehavior.cs b/JotunnModStub/Aswid/BatFormBehavior.cs index 27e9c2c..ef51ba2 100644 --- a/JotunnModStub/Aswid/BatFormBehavior.cs +++ b/JotunnModStub/Aswid/BatFormBehavior.cs @@ -1,10 +1,29 @@ +using HarmonyLib; using UnityEngine; using Jotunn.Managers; namespace RacesOfValheim { + /// + /// The bat's flight, held on for as long as the worn model exists. + /// + /// Debug fly has two halves, and this used to write only one. The field Player.m_debugFly is + /// what the local player's own physics reads; ZDOVars.s_debugFly is what every OTHER client + /// reads, because Character.IsDebugFlying consults the ZDO whenever it is not the owner. With + /// only the field written, a bat flew on its own screen and fell, walked and swam on everyone + /// else's - the fault WarVultureMount.SetFlying already names in its own summary. Both halves + /// go through SetFlying below now, so there is one place that can ever get it wrong again. + /// + /// Writing the ZDO every frame is not network spam: ZDO.Set(int, bool) bottoms out in + /// ZDOExtraData.Set, which returns false when the value is unchanged, and only a true return + /// bumps the data revision. Read out of the assembly rather than assumed, because "every frame" + /// deserved the check. + /// public class BatFormBehavior : MonoBehaviour { + private static readonly System.Reflection.FieldInfo DebugFlyField = + AccessTools.Field(typeof(Player), "m_debugFly"); + private Animator anim; private AswidProgression.FormRules formRules; @@ -16,10 +35,7 @@ namespace RacesOfValheim private void Start() { anim = GetComponentInChildren(); - if (Player.m_localPlayer != null) - { - HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(true); - } + SetFlying(true); } private void Update() @@ -27,7 +43,7 @@ namespace RacesOfValheim if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return; // Ensure flight remains on continuously - HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(true); + SetFlying(true); // Sync Animator if (anim != null) @@ -35,7 +51,7 @@ namespace RacesOfValheim Vector3 vel = Player.m_localPlayer.GetVelocity(); vel.y = 0f; float speed = vel.magnitude; - + // Bats don't necessarily have a complex animator like players, // but if they do have a speed or flying parameter, we set it here. anim.SetFloat("forward_speed", speed); @@ -45,9 +61,25 @@ namespace RacesOfValheim private void OnDestroy() { - if (Player.m_localPlayer != null) + SetFlying(false); + } + + /// + /// Both halves of debug fly, always together. The field write survives a missing or invalid + /// ZNetView on purpose: without it a bat whose networking went away mid-flight would keep + /// flying on foot forever, which is the worse of the two failures. + /// + private static void SetFlying(bool flying) + { + Player player = Player.m_localPlayer; + if (player == null) return; + + if (DebugFlyField != null) DebugFlyField.SetValue(player, flying); + + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid() && nview.IsOwner()) { - HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(false); + nview.GetZDO().Set(ZDOVars.s_debugFly, flying); } } } diff --git a/JotunnModStub/BossProgressionManager.cs b/JotunnModStub/BossProgressionManager.cs index d688a88..27e492e 100644 --- a/JotunnModStub/BossProgressionManager.cs +++ b/JotunnModStub/BossProgressionManager.cs @@ -95,6 +95,36 @@ namespace RacesOfValheim } } + /// + /// Whether this character carries a claimed personal tier at all. Distinct from + /// "PersonalState == MinState": the getter answers MinState for a character who has never + /// claimed anything AND for one who has been reset, and the Reset Progression button needs + /// to tell the player which of the two just happened. + /// + public static bool HasPersonalState + { + get + { + Player player = Player.m_localPlayer; + if (player == null || player.m_customData == null) return false; + return player.m_customData.ContainsKey(PersonalStateKey); + } + } + + /// + /// Gives back every tier claimed with a boss relic. The key is removed rather than written + /// back as MinState so the character reads as one that never claimed anything - which is + /// what a reset means, and what HasPersonalState above then reports. + /// + /// The relics themselves do not come back: RaceMenuWardBehavior.UseItem consumed them. + /// + public static void ClearPersonalState() + { + Player player = Player.m_localPlayer; + if (player == null || player.m_customData == null) return; + player.m_customData.Remove(PersonalStateKey); + } + /// /// Returns the current progression state of the world based on defeated bosses. /// 1 = No bosses defeated diff --git a/JotunnModStub/Dvergar/DvergarBanco.cs b/JotunnModStub/Dvergar/DvergarBanco.cs index d842803..f686d6a 100644 --- a/JotunnModStub/Dvergar/DvergarBanco.cs +++ b/JotunnModStub/Dvergar/DvergarBanco.cs @@ -400,8 +400,10 @@ namespace RacesOfValheim /// The same shape as TrolTotemRaceLockPatch - the second station in the mod that refuses the hammer /// outright, because hiring dvergr with dvergr money is the race's identity and not a tool it owns. /// + // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to + // match it exactly or the patch silently fails to bind and PatchAll throws. [HarmonyPatch(typeof(Player), "PlacePiece", - new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })] + new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })] public static class DvergarBancoRaceLockPatch { public static bool Prefix(Player __instance, Piece __0) diff --git a/JotunnModStub/Dvergar/DvergarBotte.cs b/JotunnModStub/Dvergar/DvergarBotte.cs index 2a2bbeb..b389bc8 100644 --- a/JotunnModStub/Dvergar/DvergarBotte.cs +++ b/JotunnModStub/Dvergar/DvergarBotte.cs @@ -192,8 +192,10 @@ namespace RacesOfValheim } } + // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to + // match it exactly or the patch silently fails to bind and PatchAll throws. [HarmonyPatch(typeof(Player), "PlacePiece", - new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })] + new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })] public static class DvergarBotteRaceLockPatch { public static bool Prefix(Player __instance, Piece __0) diff --git a/JotunnModStub/Factions/FactionMerchantSellPanel.cs b/JotunnModStub/Factions/FactionMerchantSellPanel.cs index ad97708..dbef7c7 100644 --- a/JotunnModStub/Factions/FactionMerchantSellPanel.cs +++ b/JotunnModStub/Factions/FactionMerchantSellPanel.cs @@ -169,7 +169,7 @@ namespace RacesOfValheim int coinsEarned = entry.Price * sold; GameObject coinPrefab = ((Component)gui.m_coinPrefab).gameObject; - inv.AddItem(coinPrefab.name, coinsEarned, gui.m_coinPrefab.m_itemData.m_quality, gui.m_coinPrefab.m_itemData.m_variant, 0L, ""); + inv.AddItem(coinPrefab.name, coinsEarned, gui.m_coinPrefab.m_itemData.m_quality, gui.m_coinPrefab.m_itemData.m_variant, 0L, "", false); Trader trader = FactionMerchantRuntime.GetActiveTrader(gui); trader?.OnSold(); diff --git a/JotunnModStub/Furling/FurlingFireAbility.cs b/JotunnModStub/Furling/FurlingFireAbility.cs index 9d55afe..1d4d87f 100644 --- a/JotunnModStub/Furling/FurlingFireAbility.cs +++ b/JotunnModStub/Furling/FurlingFireAbility.cs @@ -93,8 +93,10 @@ namespace RacesOfValheim } // ─── Block external Burning (fire pits, arrows) from being applied ──── + // Valheim 1.0 appended a 'short variant' parameter to this overload. The type array has to + // match it exactly or the patch silently fails to bind and PatchAll throws. [HarmonyPatch(typeof(SEMan), "AddStatusEffect", - new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })] + new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })] public static class FurlingFire_SuppressExternalBurning_Patch { public static bool AllowNextBurning = false; diff --git a/JotunnModStub/Furling/FurlingPatches.cs b/JotunnModStub/Furling/FurlingPatches.cs index 2ba0df5..ce998f9 100644 --- a/JotunnModStub/Furling/FurlingPatches.cs +++ b/JotunnModStub/Furling/FurlingPatches.cs @@ -445,7 +445,7 @@ namespace RacesOfValheim int quality = craftUpgradeItem != null ? craftUpgradeItem.m_quality + 1 : 1; int craftVariant = HarmonyLib.Traverse.Create(__instance).Field("m_craftVariant").GetValue(); - ItemDrop.ItemData addedItem = player.GetInventory().AddItem(itemDrop.gameObject.name, amount, quality, craftVariant, player.GetPlayerID(), player.GetPlayerName()); + ItemDrop.ItemData addedItem = player.GetInventory().AddItem(itemDrop.gameObject.name, amount, quality, craftVariant, player.GetPlayerID(), player.GetPlayerName(), false); if (addedItem == null) { diff --git a/JotunnModStub/MaterialManPropertyBlockFix.cs b/JotunnModStub/MaterialManPropertyBlockFix.cs new file mode 100644 index 0000000..c65b3e3 --- /dev/null +++ b/JotunnModStub/MaterialManPropertyBlockFix.cs @@ -0,0 +1,57 @@ +using System.Reflection; +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Closes the window in Valheim 1.0 where MaterialMan hands out a null property block. + /// + /// MaterialMan splits its own start-up across two Unity callbacks: + /// + /// Awake() -> s_instance = this + /// Start() -> m_propertyBlock = new MaterialPropertyBlock() + /// + /// Between the two, MaterialMan.instance answers but its property block is still null. Anything + /// that registers with it in that gap gets a PropertyContainer built around that null - and the + /// container KEEPS it, because it copies the reference into a field of its own rather than + /// reading MaterialMan's each frame. UpdateBlock() opens with m_propertyBlock.Clear(), so that + /// one container then throws a NullReferenceException on every frame for the rest of the scene. + /// A single session logged 463 of them, all identical, all from MaterialMan.UpdateBlock. + /// + /// This is vanilla's bug, not ours, but 1.0 is what made us walk into it: VisEquipment.AttachArmor + /// and AttachItem now call RefreshSnowLevel, which registers with MaterialMan, and none of that + /// existed in 0.221. Comparing the two builds, the snow-cover system is the ONLY new caller of + /// MaterialMan - so a mod that dresses the main-menu preview, as this one does for every race, + /// reaches it during the gap where before there was nothing to reach. + /// + /// Filling the block in Awake costs one allocation, once per scene, and removes the gap: whoever + /// registers early now gets a real block. Start() still makes its own a moment later and every + /// container built after that point uses that one instead, which is fine - UpdateBlock clears and + /// refills the block before each renderer reads it, so a container holding a different instance + /// behaves identically. Vanilla is otherwise left alone. + /// + /// The symptom was only ever visible on the main menu, because loading a world builds a fresh + /// MaterialMan whose Start has long since run. It was never a gameplay bug - just 463 lines of + /// noise standing between us and the log entries that matter. + /// + [HarmonyPatch(typeof(MaterialMan), "Awake")] + internal static class MaterialManPropertyBlockFix + { + /// Private in the shipped assembly, so it is reached by reflection like the rest. + private static readonly FieldInfo PropertyBlock = AccessTools.Field(typeof(MaterialMan), "m_propertyBlock"); + + /// If a future build renames or removes the field, patch nothing rather than guess. + private static bool Prepare() => PropertyBlock != null; + + private static void Postfix(MaterialMan __instance) + { + // Awake destroys itself when another instance already claimed s_instance. Writing to a + // component on its way out is harmless, and testing for it would cost more than it saves. + if (PropertyBlock.GetValue(__instance) == null) + { + PropertyBlock.SetValue(__instance, new MaterialPropertyBlock()); + } + } + } +} diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 64c27c6..1f8bed5 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.11", + "version_number": "1.4.13", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/PieceDensityLimit.cs b/JotunnModStub/PieceDensityLimit.cs index ee01fe4..e39f9b4 100644 --- a/JotunnModStub/PieceDensityLimit.cs +++ b/JotunnModStub/PieceDensityLimit.cs @@ -186,8 +186,10 @@ namespace RacesOfValheim /// is the build ghost, so `pos` is the authority on where this thing is actually going. /// Parameters are bound positionally (__0, __1) so a rename cannot break startup either. /// + // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to + // match it exactly or the patch silently fails to bind and PatchAll throws. [HarmonyPatch(typeof(Player), "PlacePiece", - new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })] + new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })] public static class PieceDensityLimitPatch { public static bool Prefix(Player __instance, Piece __0, Vector3 __1) diff --git a/JotunnModStub/RaceMenuWard.cs b/JotunnModStub/RaceMenuWard.cs index b564d26..255b38e 100644 --- a/JotunnModStub/RaceMenuWard.cs +++ b/JotunnModStub/RaceMenuWard.cs @@ -163,6 +163,10 @@ namespace RacesOfValheim public class RaceMenuWardBehavior : MonoBehaviour, Hoverable, Interactable { + // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a + // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour. + public float GetHoverOffset() => 0f; + public string GetHoverName() => "Race Menu Ward"; public string GetHoverText() @@ -286,9 +290,12 @@ namespace RacesOfValheim RacesOfValheim.ResetRace(); }); + // Refresh and not Close: unlike Reset Race, this one leaves the panel up so the two + // World/Personal lines visibly change under the player. That is also how the old + // no-op was noticed - the numbers stayed put while the message claimed a reset. AddButton("ResetProgressionBtn", "Reset Progression", new Vector2(170, -110), new Color(0.5f, 0.4f, 0.2f, 1f), () => { - RacesOfValheim.ResetProgression(); + RacesOfValheim.ResetProgression(out _); Refresh(); }); diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index a0f4dc0..9929a4a 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.11"; + public const string PluginVersion = "1.4.13"; private readonly Harmony harmony = new Harmony(PluginGUID); @@ -160,18 +160,59 @@ namespace RacesOfValheim } /// - /// Clears the boss-progression override and falls back to the natural world state. - /// Shared by the resetprogression console command and the Race Menu Ward. + /// Gives back the progression a player claimed for themselves, and says plainly when there + /// is none to give back. Shared by the resetprogression console command and the Race Menu + /// Ward's Reset Progression button. + /// + /// This used to clear BossProgressionManager.DebugState and nothing else - the console-only + /// debug override, a static that is -1 at every launch and that the ward never writes. The + /// two things the ward DOES write, RacesOfValheim_PersonalState and _PersonalMode in + /// m_customData, were untouched, so for anyone who had not just typed increaseprogression + /// in this session the button was a no-op by construction. It then reported + /// GetCurrentProgressionState() as the result, which is the unchanged current tier - the + /// "it always puts me back at the tier I'm on" the testers were describing. They were + /// reading the one number that function could possibly have produced. + /// + /// What it resets now is the personal tier only. The progression MODE is deliberately left + /// alone: a player who chose to be independent of the server's kills stays independent, + /// they just start claiming relics again from the bottom. And world progression is not this + /// button's to reset - those are the world's global keys, shared by everyone on the server - + /// so in world mode it says so rather than pretending. /// - public static int ResetProgression() + /// Human-readable account of what actually changed, for the console. + public static int ResetProgression(out string summary) { + // Still cleared, and first: it outranks both of the others in + // GetCurrentProgressionState, so leaving it up would mask whatever we do below. + bool hadDebugOverride = BossProgressionManager.DebugState != -1; BossProgressionManager.DebugState = -1; + + bool clearedPersonal = false; + if (BossProgressionManager.UsePersonalProgression && BossProgressionManager.HasPersonalState) + { + BossProgressionManager.ClearPersonalState(); + clearedPersonal = true; + } + int state = BossProgressionManager.GetCurrentProgressionState(); + string boss = BossProgressionManager.GetBossNameForState(state); + + if (clearedPersonal) + summary = $"Personal progression reset to {boss} ({state}/{BossProgressionManager.MaxState}). Claim your relics again."; + else if (BossProgressionManager.UsePersonalProgression) + summary = $"Nothing to reset - you have claimed no relics yet ({state}/{BossProgressionManager.MaxState})."; + else + summary = $"Nothing to reset - you follow the world's progression: {boss} ({state}/{BossProgressionManager.MaxState})."; + + if (hadDebugOverride) summary += " Debug override cleared."; Player player = Player.m_localPlayer; if (player != null) { - player.Message(MessageHud.MessageType.Center, $"Progression reset to: {state}"); + player.Message(MessageHud.MessageType.Center, summary); + + // Progression drives stats and unlocks that are only recalculated when equipment is + // set up, so nudge that or the new tier will not show until something else does. Traverse.Create(player).Method("SetupEquipment").GetValue(); } @@ -1299,8 +1340,8 @@ namespace RacesOfValheim public override void Run(string[] args) { - int state = RacesOfValheim.ResetProgression(); - Console.instance.Print($"[DEBUG] Progression state reset to natural world state: {state}"); + RacesOfValheim.ResetProgression(out string summary); + Console.instance.Print($"[DEBUG] {summary}"); } } diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index 74ff020..cfc78a0 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -282,7 +282,9 @@ namespace RacesOfValheim HitData hitData = new HitData(); hitData.m_damage = staffDrop.m_itemData.m_shared.m_damages; hitData.SetAttacker(Player.m_localPlayer); - + // The Drake breath is a fixed three-shard volley, so one third each. + SkadiMagicSkill.TagCast(hitData, 3); + proj.Setup(Player.m_localPlayer, targetDir * vel, -1f, hitData, staffDrop.m_itemData, null); } @@ -376,6 +378,7 @@ namespace RacesOfValheim HitData hitData = new HitData(); hitData.m_damage = staffDrop.m_itemData.m_shared.m_damages; hitData.SetAttacker(Player.m_localPlayer); + SkadiMagicSkill.TagCast(hitData, projCount); proj.Setup(Player.m_localPlayer, targetDir * vel, -1f, hitData, staffDrop.m_itemData, null); } @@ -484,6 +487,7 @@ namespace RacesOfValheim hitData.m_damage.m_frost += hitData.m_damage.m_fire; hitData.m_damage.m_fire = 0f; hitData.SetAttacker(Player.m_localPlayer); + SkadiMagicSkill.TagCast(hitData, projCount); if (proj != null) { diff --git a/JotunnModStub/Skadi/SkadiConfig.cs b/JotunnModStub/Skadi/SkadiConfig.cs index 81134c3..22db0ab 100644 --- a/JotunnModStub/Skadi/SkadiConfig.cs +++ b/JotunnModStub/Skadi/SkadiConfig.cs @@ -45,6 +45,12 @@ namespace RacesOfValheim public static ConfigEntry AuraDamagePerTick; public static ConfigEntry AuraTickInterval; + // ─── Elemental Magic experience ───────────────────────────────────────── + // See SkadiMagicSkill for why a cast's budget is split across its projectiles and why the + // aura's share is a fraction of a cast's. + public static ConfigEntry MagicSkillGainPerCast; + public static ConfigEntry AuraSkillGainPerTick; + // ─── Passive combat ────────────────────────────────────────────────── public static ConfigEntry BonusFrostDamagePerState; @@ -126,6 +132,12 @@ namespace RacesOfValheim AuraTickInterval = config.Bind(aura, "Tick Interval", 1f, new ConfigDescription("Seconds between aura damage ticks.", new AcceptableValueRange(0.1f, 5f))); + const string magicSkill = "Skadi - Elemental Magic Skill"; + MagicSkillGainPerCast = config.Bind(magicSkill, "Gain Per Cast", 1f, + new ConfigDescription("Elemental Magic experience for one cast that connects - the Cold Spell and all three dragon breaths. Split across the projectiles a cast throws, so a ten-shard burst is worth the same as one shard. Nothing is earned by a shot that hits no one. 0 turns spell experience off.", new AcceptableValueRange(0f, 5f))); + AuraSkillGainPerTick = config.Bind(magicSkill, "Aura Gain Per Tick", 0.1f, + new ConfigDescription("Elemental Magic experience for one Frost Aura tick that burned at least one enemy - once per tick, not once per enemy. Deliberately a fraction of a cast: the aura ticks every second on its own. 0 turns aura experience off.", new AcceptableValueRange(0f, 1f))); + const string scale = "Skadi - Dragon Form Scale"; DrakeScale = config.Bind(scale, "Drake Scale", 0.9f, new ConfigDescription("Model scale while transformed into the Drake (tier 3-4).", new AcceptableValueRange(0.1f, 2f))); diff --git a/JotunnModStub/Skadi/SkadiMagicSkill.cs b/JotunnModStub/Skadi/SkadiMagicSkill.cs new file mode 100644 index 0000000..a35d23d --- /dev/null +++ b/JotunnModStub/Skadi/SkadiMagicSkill.cs @@ -0,0 +1,83 @@ +namespace RacesOfValheim +{ + /// + /// Elemental Magic experience for Skadi's spellcasting, in one place because four call sites + /// need the same two lines and the same piece of arithmetic. + /// + /// WHY NOTHING WAS LEVELLING BEFORE. Every one of Skadi's casts builds its HitData by hand and + /// never touched HitData.m_skill, which leaves it at SkillType.None. Vanilla's Skills.RaiseSkill + /// returns on its first instruction when the type is None, so the experience was not merely + /// small - it was structurally impossible. Read out of assembly_valheim, along with the path + /// that makes the fix a one-liner: + /// + /// Projectile.Setup copies hitData.m_skill into Projectile.m_skill, and + /// hitData.m_skillRaiseAmount into Projectile.m_raiseSkillAmount. + /// Projectile.OnHit calls owner.RaiseSkill(m_skill, m_raiseSkillAmount) - once, and only + /// on the branch where the projectile actually damaged something. + /// + /// So a tagged HitData gets vanilla's own behaviour for free: experience on a hit that lands, + /// nothing for a shot into a hillside, and no double-counting. That is better than raising the + /// skill at cast time, which would pay a player for missing. + /// + /// WHY THE AMOUNT IS DIVIDED. A cast is one spell however many things leave the hand. The + /// improved Cold Spell throws ten shards and the dragon breaths throw up to a volley each, and + /// every one of those is its own Projectile with its own OnHit - so an untouched + /// m_skillRaiseAmount of 1 would pay ten times for one cast. The budget is split the same way + /// ColdSpellKickCoroutine already splits its damage budget across shards, for the same reason. + /// + /// WHAT IS DELIBERATELY NOT HERE. The dragon forms' melee (DrakeFormBehavior.ExecuteMeleeDamage) + /// stays on Unarmed: it already tags itself that way and already scales off the Unarmed skill + /// level - it is a maul, not a spell. And the Crystal Golem is a hammer piece, not a cast, so it + /// pays Building experience through vanilla's own placement path. + /// + public static class SkadiMagicSkill + { + /// + /// Marks a cast's HitData as Elemental Magic and gives it its share of the cast's + /// experience. Call it before Projectile.Setup - Setup is what copies both fields onto the + /// projectile, so anything written afterwards is never read. + /// + /// The HitData about to be handed to Projectile.Setup. + /// + /// How many projectiles this one cast throws. The cast's whole experience budget is divided + /// by it, so a ten-shard burst and a single shard are worth the same. + /// + public static void TagCast(HitData hit, int projectilesInCast) + { + if (hit == null) return; + + float perCast = SkadiConfig.MagicSkillGainPerCast != null + ? SkadiConfig.MagicSkillGainPerCast.Value + : 1f; + + // Zero is the off switch, and it has to leave m_skill alone as well as the amount: + // Skills.RaiseSkill would still be entered with a real type and a zero factor, and + // Skill.Raise does its own bookkeeping before it looks at the number. + if (perCast <= 0f) return; + + if (projectilesInCast < 1) projectilesInCast = 1; + + hit.m_skill = Skills.SkillType.ElementalMagic; + hit.m_skillRaiseAmount = perCast / projectilesInCast; + } + + /// + /// The Frost Aura's share. Unlike a cast the aura has no projectile to hang experience on, + /// so it is raised directly - once per tick that actually burned something, never once per + /// enemy. A three metre aura ticking every second through a pack would otherwise pay out + /// several times a second and take the skill to cap on a single fight, which is why the + /// default is a fraction rather than the 1 a cast is worth. + /// + public static void RaiseForAuraTick() + { + if (Player.m_localPlayer == null) return; + + float gain = SkadiConfig.AuraSkillGainPerTick != null + ? SkadiConfig.AuraSkillGainPerTick.Value + : 0f; + if (gain <= 0f) return; + + Player.m_localPlayer.RaiseSkill(Skills.SkillType.ElementalMagic, gain); + } + } +} diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 0538faa..6cdcc99 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -118,7 +118,9 @@ namespace RacesOfValheim } } - [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })] + // Valheim 1.0 appended a 'short variant' parameter to this overload. The type array has to + // match it exactly or the patch silently fails to bind and PatchAll throws. + [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })] public static class SkadiSEManPatch { public static bool Prefix(SEMan __instance, ref int nameHash) diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 88a3ad7..1daec80 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -431,6 +431,9 @@ namespace RacesOfValheim HitData hitData = new HitData(); hitData.m_damage.m_frost = shardDamage; hitData.SetAttacker(Player.m_localPlayer); + // Before Setup, which is what copies the skill and its amount onto the + // projectile. Same split as the damage budget above, and for the same reason. + SkadiMagicSkill.TagCast(hitData, count); proj.Setup(Player.m_localPlayer, lookDir * staffDrop.m_itemData.m_shared.m_attack.m_projectileVel, -1f, hitData, staffDrop.m_itemData, null); } @@ -509,11 +512,15 @@ namespace RacesOfValheim { if (Player.m_localPlayer == null) return; Vector3 center = Player.m_localPlayer.transform.position; + + // Once per tick, not once per enemy - see SkadiMagicSkill.RaiseForAuraTick. + bool burnedSomething = false; + foreach (Character c in Character.GetAllCharacters()) { if (c == Player.m_localPlayer) continue; if (c.IsTamed() || c.IsPlayer()) continue; - + if (Vector3.Distance(center, c.transform.position) <= SkadiConfig.AuraRadius.Value) { HitData hit = new HitData(); @@ -522,8 +529,11 @@ namespace RacesOfValheim hit.m_dir = (c.transform.position - center).normalized; hit.SetAttacker(Player.m_localPlayer); c.ApplyDamage(hit, true, false); + burnedSomething = true; } } + + if (burnedSomething) SkadiMagicSkill.RaiseForAuraTick(); } private void TryTransformWithRules(SkadiProgression.FormRules rules) diff --git a/JotunnModStub/Skeleton/SkeletonRace.cs b/JotunnModStub/Skeleton/SkeletonRace.cs index 4855072..90311d6 100644 --- a/JotunnModStub/Skeleton/SkeletonRace.cs +++ b/JotunnModStub/Skeleton/SkeletonRace.cs @@ -308,8 +308,9 @@ namespace RacesOfValheim VisEquipment vis = Player.m_localPlayer.GetComponent(); if (vis != null) { - vis.SetHairItem(""); - vis.SetBeardItem(""); + // Since Valheim 1.0 these take an item hash, not a prefab name. 0 is the empty slot. + vis.SetHairItem(0); + vis.SetBeardItem(0); } } } diff --git a/JotunnModStub/Sverm/SvermHive.cs b/JotunnModStub/Sverm/SvermHive.cs index f174aff..c3f0114 100644 --- a/JotunnModStub/Sverm/SvermHive.cs +++ b/JotunnModStub/Sverm/SvermHive.cs @@ -467,6 +467,10 @@ namespace RacesOfValheim "[$KEY_Use] Feed it a stack"; } + // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a + // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour. + public float GetHoverOffset() => 0f; + public string GetHoverName() => SvermHiveStage.NameOf(SvermHiveStage.Of(transform)); private ZNetView nview; diff --git a/JotunnModStub/Sverm/SvermHiveStore.cs b/JotunnModStub/Sverm/SvermHiveStore.cs index d194ad3..39df58b 100644 --- a/JotunnModStub/Sverm/SvermHiveStore.cs +++ b/JotunnModStub/Sverm/SvermHiveStore.cs @@ -211,6 +211,10 @@ namespace RacesOfValheim public bool UseItem(Humanoid user, ItemDrop.ItemData item) => false; + // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a + // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour. + public float GetHoverOffset() => 0f; + public string GetHoverName() => Title; public string GetHoverText() @@ -444,6 +448,10 @@ namespace RacesOfValheim public bool UseItem(Humanoid user, ItemDrop.ItemData item) => false; + // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a + // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour. + public float GetHoverOffset() => 0f; + public string GetHoverName() => SvermHiveMarketPiece.DisplayName; public string GetHoverText() diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index f2dca7b..94194ab 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -682,9 +682,10 @@ namespace RacesOfValheim if (player.GetComponent() == null) player.gameObject.AddComponent(); - visEq.SetChestItem(SvermConfig.CarapaceChestVisual); - visEq.SetLegItem(SvermConfig.CarapaceLegsVisual); - visEq.SetHelmetItem(SvermConfig.CarapaceHelmetVisual); + // Since Valheim 1.0 these three take an item hash rather than a prefab name. + visEq.SetChestItem(VisualHash(SvermConfig.CarapaceChestVisual)); + visEq.SetLegItem(VisualHash(SvermConfig.CarapaceLegsVisual)); + visEq.SetHelmetItem(VisualHash(SvermConfig.CarapaceHelmetVisual)); int state = GetRenderState(player); @@ -697,7 +698,7 @@ namespace RacesOfValheim /// Puts the three slots back to whatever the player actually has equipped. /// /// The same three lines vanilla's own Humanoid.SetupVisEquipment writes - the item's drop - /// prefab name, or "" for an empty slot - rather than calling that method, because it also + /// prefab name hashed, or 0 when empty - rather than calling that method, because it also /// rewrites the hands, the shoulders and the utility slot, and the Sverm never touched /// those. Restoring only what was overridden cannot disturb another race's visuals or a /// weapon that some other patch is mid-way through swapping. @@ -707,17 +708,25 @@ namespace RacesOfValheim /// private static void RestoreEquipmentVisuals(Player player, VisEquipment visEq) { - visEq.SetChestItem(EquippedVisualName(player, "m_chestItem")); - visEq.SetLegItem(EquippedVisualName(player, "m_legItem")); - visEq.SetHelmetItem(EquippedVisualName(player, "m_helmetItem")); + visEq.SetChestItem(EquippedVisualHash(player, "m_chestItem")); + visEq.SetLegItem(EquippedVisualHash(player, "m_legItem")); + visEq.SetHelmetItem(EquippedVisualHash(player, "m_helmetItem")); } - /// The prefab name VisEquipment wants for an equipped slot, or "" when it is empty. - private static string EquippedVisualName(Player player, string field) + /// + /// What VisEquipment has wanted since Valheim 1.0: an item hash instead of a prefab name. + /// 0 is the empty slot - the same value vanilla Humanoid.SetupVisEquipment passes for a + /// slot holding nothing. + /// + private static int VisualHash(string prefabName) => + string.IsNullOrEmpty(prefabName) ? 0 : prefabName.GetStableHashCode(); + + /// The item hash VisEquipment wants for an equipped slot, or 0 when it is empty. + private static int EquippedVisualHash(Player player, string field) { ItemDrop.ItemData item = Traverse.Create((Humanoid)player).Field(field).Value; - if (item == null || item.m_dropPrefab == null) return ""; - return item.m_dropPrefab.name; + if (item == null || item.m_dropPrefab == null) return 0; + return VisualHash(item.m_dropPrefab.name); } private static void TintInstances(object value, int state) diff --git a/JotunnModStub/Trenta/TrentaElderRoot.cs b/JotunnModStub/Trenta/TrentaElderRoot.cs index 5f0fba8..ccbcc54 100644 --- a/JotunnModStub/Trenta/TrentaElderRoot.cs +++ b/JotunnModStub/Trenta/TrentaElderRoot.cs @@ -279,8 +279,10 @@ namespace RacesOfValheim /// Race lock plus the boss gate, in one prefix - same shape as TrolTotemRaceLockPatch, with a /// second refusal added for the progression check the Root also needs. ///
+ // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to + // match it exactly or the patch silently fails to bind and PatchAll throws. [HarmonyPatch(typeof(Player), "PlacePiece", - new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })] + new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })] public static class TrentaElderRootPlacementPatch { public static bool Prefix(Player __instance, Piece __0) diff --git a/JotunnModStub/Trenta/TrentaPatches.cs b/JotunnModStub/Trenta/TrentaPatches.cs index 4bf50dd..33afad0 100644 --- a/JotunnModStub/Trenta/TrentaPatches.cs +++ b/JotunnModStub/Trenta/TrentaPatches.cs @@ -134,7 +134,9 @@ namespace RacesOfValheim /// ever adds Wet, always through this exact four-argument SEMan.AddStatusEffect overload, /// so patching that call is equivalent to patching every path Wet could arrive by. ///
- [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })] + // Valheim 1.0 appended a 'short variant' parameter to this overload. The type array has to + // match it exactly or the patch silently fails to bind and PatchAll throws. + [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })] public static class Trenta_SEMan_AddStatusEffect_WetImmunity_Patch { public static bool Prefix(SEMan __instance, int nameHash) diff --git a/JotunnModStub/Trol/TrolTotem.cs b/JotunnModStub/Trol/TrolTotem.cs index 0dea4fb..b4beb46 100644 --- a/JotunnModStub/Trol/TrolTotem.cs +++ b/JotunnModStub/Trol/TrolTotem.cs @@ -362,8 +362,10 @@ namespace RacesOfValheim /// The race lock. Every other station in this mod is buildable by anyone; this one is not, so the /// refusal is caught at placement - before the core wood and the head are spent. ///
+ // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to + // match it exactly or the patch silently fails to bind and PatchAll throws. [HarmonyPatch(typeof(Player), "PlacePiece", - new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })] + new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })] public static class TrolTotemRaceLockPatch { public static bool Prefix(Player __instance, Piece __0) diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs index 40061ef..c7d2f2f 100644 --- a/JotunnModStub/ZdoVisualSync.cs +++ b/JotunnModStub/ZdoVisualSync.cs @@ -122,8 +122,9 @@ namespace RacesOfValheim VisEquipment vis = m_player.GetComponent(); if (vis != null) { - vis.SetHairItem(""); - vis.SetBeardItem(""); + // Since Valheim 1.0 these take an item hash, not a prefab name. 0 is the empty slot. + vis.SetHairItem(0); + vis.SetBeardItem(0); // Hide Helmet var helmetObj = HarmonyLib.Traverse.Create(vis).Field("m_helmetItemInstance").Value; diff --git a/README.md b/README.md index 7296f46..3a74061 100644 --- a/README.md +++ b/README.md @@ -4,6 +4,16 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing --- +## Warning + +Jotunn has not been updated for Valheim 1.0 yet, and RacesOfValheim cannot run without it. Until the official build is out, install this community rebuild of Jotunn instead: + +[ReefTeam — Jotunn](https://thunderstore.io/c/valheim/p/ReefTeam/Jotunn/) + +Remove it once the Jotunn team ships its own 1.0 release. + +--- + ## Development & Feedback This is a stable release, but more races and refinements are planned! @@ -39,6 +49,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions - **Ice Affinity:** Resistant to cold, with unique frost mechanics. - **Drake Form:** Can transform into a frost Drake, letting you fly. - **Dragon Form:** Evolve into Moder and later even the Skeleton Dragon. +- **Elemental Magic:** The Cold Spell and all three dragon breaths raise the Elemental Magic skill when they connect — one cast is worth one cast, however many shards it throws. The Frost Aura earns a fraction of that per tick that actually burns something. Both amounts are configurable, and the dragon forms' melee stays on Unarmed, where it always was. ### 3. Fenrir ![Fenrir1](https://wiki.aledanidev.ovh/assets/images/fenrir1.gif) @@ -52,7 +63,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions ### 4. Aswid ![Aswid](https://wiki.aledanidev.ovh/assets/images/aswidchallenge.gif) - **The Vampire:** Life-draining abilities. -- **Bat Form:** Press G to become a bat and fly. +- **Bat Form:** Press G to become a bat and fly. Monsters see, hear and wake for the bat, and can hurt it — both are configurable under `Aswid - Bat Form` if you would rather scout untouched. - **Vampiric Aura:** A passive life-draining aura around you, always on in every form (half damage as human, full as bat, double as mist) — no key to hold. Press **[I]** to toggle it (and Devour) off, e.g. before trading with Haldor or Hildir, since it does not recognize traders from monsters. - **Blood Magic Mastery:** Cast Blood Magic items with infinite Eitr (health cost only). - **Benedictus et Afflictus:** Passive speed/jump bonuses double at night. @@ -380,7 +391,7 @@ Interact to reset your race, reset your progression, or switch between: - **World progression:** tier follows world’s bosses. - **Personal progression:** tier saved to character (server independent). -**Reset Progression** drops any tier override you've claimed and falls back to what the world has actually killed — the same thing the `resetprogression` console command does, without the console. +**Reset Progression** gives back the tiers you claimed with boss relics, so you start claiming them again from the bottom. It leaves the mode alone — a character on personal progression stays on personal progression — and in world mode it says there is nothing to reset rather than pretending, because the world's bosses are the server's business and not one player's. The relics themselves are not refunded. The button and the `resetprogression` console command run the same code, so the two can't drift apart. In personal mode, offer boss’s secondary drop to the Ward (Hard Antler, Crypt Key, Wishbone, Dragon Tear, Yagluth’s thing, Queen’s carapace, Fader’s relic) to claim boss tier. @@ -409,6 +420,17 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.13 +- Update to 1.0. + +### v1.4.12 +- **Fix - The Aswid could turn into a bat in broad daylight after killing Eikthyr alone:** the form has always been meant to answer only at night until The Elder falls, and the progression table said exactly that — but nothing ever read the flag, so the daylight restriction had never once been in effect. It is enforced now, with a message instead of a silent refusal, and a night-only bat caught by the sunrise is put back into its body rather than being allowed to fly on until dusk. Killing The Elder still lifts the restriction for good. +- **NEW - The bat's flight speed is a slider:** `Flight Speed` under `Aswid - Bat Form`, a multiplier on the game's own flight speed (1 is untouched, up to 3). It scales the movement the game had already computed, so the acceleration, the ease-off and the standstill at zero input all feel the same — only the ground covered changes — and holding the run key still doubles it on top. Local to your own bat. +- **Fix - Nothing in the game ever attacked the Aswid's bat form, and nothing could hurt it either:** the bat flies on Valheim's debug-fly flag, which is the only flight the game has — and vanilla reads that flag as *this player is not really here*. Six methods act on it: the AI's sight and hearing checks both refuse a debug-flying player on their first line, the hunt-the-nearest-player fallback throws them away, sleeping monsters will not wake for one, and both damage entry points drop every hit. So a bat could glide through a draugr camp untouched, and could not be killed if it tried. The flag stays — it *is* the flight — and is now overridden in exactly the places that decide aggro and damage, and nowhere else. Two toggles under `Aswid - Bat Form` if you preferred the old ghost: **Monsters Notice The Bat** and **The Bat Can Be Hurt**, both on. Dying as a bat is possible for the first time, so the form is now taken down properly on death instead of leaving the player floating on respawn. +- **Fix - The bat looked wrong to everyone else in multiplayer:** debug fly has two halves — a local field the flying player's own physics reads, and a networked value every *other* client reads. Only the first was ever written, so a bat flew on its own screen while walking, falling and swimming on everybody else's. Both are now written together. +- **Fix - Reset Progression on the Race Menu Ward did nothing:** the button cleared a console-only debug override — a value that is empty at every launch and that the Ward never writes — and never touched the two things the Ward actually stores, the claimed tier and the progression mode. It then reported the unchanged current tier back as the result, which is why it always looked like it had reset you to the tier you were already on. It now gives back the tiers claimed with boss relics, leaves the mode alone (personal stays personal), and in world mode says there is nothing to reset instead of pretending. The relics are not refunded. +- **NEW - Skadi's spells raise Elemental Magic:** they never could before — every one of Skadi's casts builds its damage by hand and left the skill field unset, and vanilla's skill code returns immediately on an unset skill, so the experience was not small but structurally impossible. The Cold Spell and all three dragon breaths now pay out through vanilla's own path: on a hit that lands, nothing for a shot into a hillside, and one cast's worth however many shards it throws — a ten-shard burst is not worth ten casts. The Frost Aura earns a fraction of a cast per tick that actually burned something, once per tick rather than once per enemy, so a pack does not take the skill to cap in one fight. Both numbers live under `Skadi - Elemental Magic Skill` and either can be set to 0. The dragon forms' melee deliberately stays on Unarmed, where it already was, and the Crystal Golem stays a hammer piece paying Building. + ### v1.4.11 - **Fix - Bone Servant cook only ever produced one meat:** the servant swept the ground for its finished item *before* pulling a new one out of the station, so each visit collected the previous visit's item and left without grabbing what it had just pulled loose — a working hearth always had exactly one cooked meat sitting beside it. It now pulls first, in a loop bounded by the station's own slot count. - **Fix - Bone Smith refuelling never got a turn:** fuel-loading ran behind ore-loading, and a furnace's free slots reopen the instant it eats one ore — so ore-loading always had an answer and the furnace burned down to nothing between visits. Fuel now loads first. diff --git a/manifest.json b/manifest.json index 64c27c6..1f8bed5 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.11", + "version_number": "1.4.13", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From ce671e7124a11710fdc858062905626afea9e473 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 10 Sep 2026 19:14:05 +0200 Subject: [PATCH 027/273] jotunn 2.30 compatibility + minor bugs --- JotunnModStub/Fenrir/FenrirBehaviors.cs | 24 +++++------ JotunnModStub/Package/manifest.json | 4 +- JotunnModStub/RaceInput.cs | 43 ++++++++++++++++++++ JotunnModStub/RacesOfValheim.cs | 2 +- JotunnModStub/Skadi/DrakeFormBehavior.cs | 9 ++-- JotunnModStub/Skadi/SkadiRace.cs | 3 +- JotunnModStub/Sverm/SvermConfig.cs | 7 +++- JotunnModStub/Sverm/SvermConfigManagement.cs | 11 ++++- JotunnModStub/Sverm/SvermRavagerForm.cs | 15 +++---- JotunnModStub/Sverm/SvermVisuals.cs | 10 +++-- JotunnModStub/Trenta/TrentaMuspell.cs | 4 +- JotunnModStub/Trol/TrolFoodPatches.cs | 6 ++- README.md | 14 ++----- manifest.json | 4 +- 14 files changed, 107 insertions(+), 49 deletions(-) diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 58549a7..20c7157 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -92,15 +92,15 @@ namespace RacesOfValheim { StartCoroutine(HowlRoutine()); } - else if (Input.GetMouseButtonDown(1)) // Tasto destro (Heavy Claw) + else if (RaceInput.AttackDown(1)) // Tasto destro (Heavy Claw) { StartCoroutine(ClawRoutine("attack_claw1", FenrirConfig.FenringHeavyClawDamage.Value, 1.2f, 0.5f)); } - else if (Input.GetMouseButtonDown(0)) // Tasto sinistro + else if (RaceInput.AttackDown(0)) // Tasto sinistro { StartCoroutine(ClawRoutine("attack_claw0", FenrirConfig.FenringLightClawDamage.Value, 1.0f, 0.4f)); } - else if (Input.GetMouseButtonDown(2)) // Tasto centrale + else if (RaceInput.AttackDown(2)) // Tasto centrale { StartCoroutine(JumpAttackRoutine()); } @@ -346,7 +346,7 @@ namespace RacesOfValheim bool canAct = RaceInput.Allowed; // Fire attack on Right Click - if (canAct && Input.GetMouseButton(1)) + if (canAct && RaceInput.AttackHeld(1)) { if (Player.m_localPlayer.GetEitr() > 0) { @@ -375,12 +375,12 @@ namespace RacesOfValheim } // Attacks on Left Click - if (canAct && Input.GetMouseButtonDown(0) && !isShootingFire) + if (canAct && RaceInput.AttackDown(0) && !isShootingFire) { StartCoroutine(ClawRoutine()); // Single claw } // Double claw on Middle Click - else if (canAct && Input.GetMouseButtonDown(2) && !isShootingFire) + else if (canAct && RaceInput.AttackDown(2) && !isShootingFire) { StartCoroutine(DoubleClawRoutine()); } @@ -706,15 +706,15 @@ namespace RacesOfValheim if (isGrounded && RaceInput.Allowed) { - if (Input.GetMouseButtonDown(0)) // Left Click + if (RaceInput.AttackDown(0)) // Left Click { StartCoroutine(WolfAttackRoutine("attack1", FenrirConfig.WolfAttack1Damage.Value, 0.6f, 0.2f)); } - else if (Input.GetMouseButtonDown(1)) // Right Click + else if (RaceInput.AttackDown(1)) // Right Click { StartCoroutine(WolfAttackRoutine("attack2", FenrirConfig.WolfAttack2Damage.Value, 0.8f, 0.3f)); } - else if (Input.GetMouseButtonDown(2)) // Middle Click + else if (RaceInput.AttackDown(2)) // Middle Click { StartCoroutine(WolfAttackRoutine("attack3", FenrirConfig.WolfAttack3Damage.Value, 1.0f, 0.4f)); } @@ -879,16 +879,16 @@ namespace RacesOfValheim if (isGrounded && RaceInput.Allowed) { - if (Input.GetMouseButtonDown(0)) // Left Click + if (RaceInput.AttackDown(0)) // Left Click { StartCoroutine(UlvAttackRoutine("attack_bite", FenrirConfig.UlvBiteDamage.Value, 0.6f, 0.2f)); } - else if (Input.GetMouseButtonDown(1)) // Right Click + else if (RaceInput.AttackDown(1)) // Right Click { // Right click uses bite but as a heavier attack since slash is moved to jump StartCoroutine(UlvAttackRoutine("attack_bite", FenrirConfig.UlvHeavyBiteDamage.Value, 0.8f, 0.3f)); } - else if (Input.GetMouseButtonDown(2)) // Middle Click + else if (RaceInput.AttackDown(2)) // Middle Click { StartCoroutine(UlvJumpAttackRoutine()); } diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 1f8bed5..921c41a 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,10 +1,10 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.13", + "version_number": "1.4.14", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", - "ValheimModding-Jotunn-2.26.1" + "ValheimModding-Jotunn-2.30.0" ] } diff --git a/JotunnModStub/RaceInput.cs b/JotunnModStub/RaceInput.cs index 02b3847..0f08de1 100644 --- a/JotunnModStub/RaceInput.cs +++ b/JotunnModStub/RaceInput.cs @@ -99,6 +99,49 @@ namespace RacesOfValheim } return true; } + + // Gamepad counterparts of the three mouse buttons, indexed like Input.GetMouseButton. + // Not a free choice: ZInput.ResetKBMButtons binds Attack to Mouse0, Block to Mouse1 and + // SecondaryAttack to Mouse2, so each form attack lands on the pad button vanilla already + // pairs with the same mouse button - and does whatever that button does in vanilla at the + // same time, exactly as the mouse already did. Going through ZInput rather than raw + // joystick buttons also follows the pad layout picked in the game settings. + private static readonly string[] PadAttackButtons = { "JoyAttack", "JoyBlock", "JoySecondaryAttack" }; + + /// + /// Transformed-form attack input: the mouse button, or its gamepad counterpart. Forms read + /// the device directly instead of going through Humanoid.StartAttack, so before this a + /// gamepad player had no way to attack in any of them. + /// + public static bool AttackDown(int mouseButton) + { + return Input.GetMouseButtonDown(mouseButton) || PadAttackDown(mouseButton); + } + + /// Held-down counterpart of . + public static bool AttackHeld(int mouseButton) + { + return Input.GetMouseButton(mouseButton) || PadAttackHeld(mouseButton); + } + + /// The gamepad half of alone, for attacks whose mouse + /// side is a rebindable KeyboardShortcut rather than a fixed button. + public static bool PadAttackDown(int mouseButton) + { + string button = PadButton(mouseButton); + return button != null && ZInput.GetButtonDown(button); + } + + public static bool PadAttackHeld(int mouseButton) + { + string button = PadButton(mouseButton); + return button != null && ZInput.GetButton(button); + } + + private static string PadButton(int mouseButton) + { + return mouseButton >= 0 && mouseButton < PadAttackButtons.Length ? PadAttackButtons[mouseButton] : null; + } } [HarmonyPatch(typeof(Player), "ActivateGuardianPower")] diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 9929a4a..94adc40 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.13"; + public const string PluginVersion = "1.4.14"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index cfc78a0..4f49e9a 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -188,24 +188,25 @@ namespace RacesOfValheim // Handle Attack - each trigger is a rebindable SkadiConfig keybind; the button id // passed into PerformAttackCoroutine (0/1/2) still selects which attack runs, exactly - // as it did when these were raw mouse-button checks. + // as it did when these were raw mouse-button checks. The same id also picks the + // gamepad button (RaceInput.PadAttackDown), which stays fixed even if the key is rebound. if (CanAttackNow() && RaceInput.Allowed) { - if (SkadiConfig.PrimaryAttackKey.Value.IsDownIgnoringHeldKeys()) + if (SkadiConfig.PrimaryAttackKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(0)) { if (HasAttackForButton(0) && Time.time - lastAttackTime >= ATTACK_COOLDOWN) { StartCoroutine(PerformAttackCoroutine(0)); } } - else if (SkadiConfig.BreathAttackKey.Value.IsDownIgnoringHeldKeys()) + else if (SkadiConfig.BreathAttackKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(2)) { if (Time.time - lastAttackTime >= ATTACK_COOLDOWN) { StartCoroutine(PerformAttackCoroutine(2)); } } - else if (SkadiConfig.SpinAttackKey.Value.IsDownIgnoringHeldKeys() && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // Fader Spin + else if ((SkadiConfig.SpinAttackKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(1)) && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // Fader Spin { if (Time.time - lastAttackTime >= ATTACK_COOLDOWN) { diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 1daec80..aa141fa 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -340,7 +340,8 @@ namespace RacesOfValheim if (isTransformed) return; // Do not cast human spell while in dragon form // Middle Mouse Button to cast, by default - rebindable via SkadiConfig.ColdSpellKey. - if (SkadiConfig.ColdSpellKey.Value.IsDownIgnoringHeldKeys()) + // On a gamepad, the secondary attack button (the pad's own middle-mouse equivalent). + if (SkadiConfig.ColdSpellKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(2)) { // The improved cast is a burst rather than a rapid-fire, so it waits longer. float cooldown = rules.ImprovedColdSpell ? IMPROVED_SPELL_COOLDOWN : SPELL_COOLDOWN; diff --git a/JotunnModStub/Sverm/SvermConfig.cs b/JotunnModStub/Sverm/SvermConfig.cs index c96e988..1feebec 100644 --- a/JotunnModStub/Sverm/SvermConfig.cs +++ b/JotunnModStub/Sverm/SvermConfig.cs @@ -195,14 +195,17 @@ namespace RacesOfValheim public static readonly float SpineSizeSmall = 0.45f; // metres, state 5-6 public static readonly float SpineSizeFull = 0.80f; // metres, state 7+ /// - /// Which bone they ride. Spine3 and ONLY Spine3 - no fallback chain. + /// Which bone they ride. Spine2 and ONLY Spine2 - no fallback chain. /// /// The earlier version tried Spine2, then Spine1, then Spine, on the theory that a missing /// bone should degrade rather than disappear. On this rig all three exist, so the fallback /// never fired for the right reason and only ever meant "somewhere on the back, roughly" - /// which is not good enough for a crest that was positioned by eye. One bone, or nothing. + /// + /// It was Spine3 until this was caught: the player rig counts Spine, Spine1 and Spine2 and has + /// no Spine3, so the crest never mounted anywhere and the only trace was a warning in the log. /// - public const string SpineBoneName = "Spine3"; + public const string SpineBoneName = "Spine2"; // Found in game with the crest on screen. A ribcage is authored lying around a body, so // standing it up out of a back is a quarter turn on two axes - not something anybody was diff --git a/JotunnModStub/Sverm/SvermConfigManagement.cs b/JotunnModStub/Sverm/SvermConfigManagement.cs index ccc36e3..4cd7290 100644 --- a/JotunnModStub/Sverm/SvermConfigManagement.cs +++ b/JotunnModStub/Sverm/SvermConfigManagement.cs @@ -239,7 +239,16 @@ namespace RacesOfValheim SpineBoneName = config.Bind(spines, "Bone", SvermConfig.SpineBoneName, "Which bone the spines ride. This bone and no other - there is no fallback, so a " + "name that is not in the rig means no crest at all. Leave it blank to use " + - "Spine3."); + "Spine2."); + + // Spine3 was the shipped default and is not a bone this rig has, so a .cfg still holding it + // has never shown a crest. BepInEx keeps the value in the file over a changed default, so + // without this the fix would only ever reach fresh installs. Nobody can have picked Spine3 + // on purpose and seen it work, which is what makes overwriting it safe. + if (string.Equals(SpineBoneName.Value?.Trim(), "Spine3", System.StringComparison.OrdinalIgnoreCase)) + { + SpineBoneName.Value = SvermConfig.SpineBoneName; + } // Defaults are the values found in game with the crest on screen, not zeroes: changing // nothing here now reproduces the placement that was actually approved. diff --git a/JotunnModStub/Sverm/SvermRavagerForm.cs b/JotunnModStub/Sverm/SvermRavagerForm.cs index f74a02f..c2cbbfb 100644 --- a/JotunnModStub/Sverm/SvermRavagerForm.cs +++ b/JotunnModStub/Sverm/SvermRavagerForm.cs @@ -542,19 +542,20 @@ namespace RacesOfValheim if (!RaceInput.Allowed || !grounded) return; - // Right click rams, left click bites, middle click slams. All three read raw - // UnityEngine.Input rather than going anywhere near Humanoid.StartAttack, which - // Sverm_RavagerBlockNativeAttack_Patch refuses outright for the whole form - see the - // class doc for why that turned out to be the only reliable option. - if (Input.GetMouseButtonDown(1)) + // Right click rams, left click bites, middle click slams. All three read the device + // directly (mouse, or its gamepad counterpart - see RaceInput.AttackDown) rather than + // going anywhere near Humanoid.StartAttack, which Sverm_RavagerBlockNativeAttack_Patch + // refuses outright for the whole form - see the class doc for why that turned out to + // be the only reliable option. + if (RaceInput.AttackDown(1)) { StartCoroutine(AttackRoutine(SvermRavagerAttacks.Ram, 2f, 0.3f, 0.7f)); } - else if (Input.GetMouseButtonDown(0)) + else if (RaceInput.AttackDown(0)) { StartCoroutine(AttackRoutine(SvermRavagerAttacks.Bite, 2f, 0.3f, 0.6f)); } - else if (Input.GetMouseButtonDown(2)) + else if (RaceInput.AttackDown(2)) { StartCoroutine(AttackRoutine(SvermRavagerAttacks.Slam, 1.2f, 0.4f, 1.0f)); } diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index 94194ab..f8017c0 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -414,7 +414,7 @@ namespace RacesOfValheim Transform bone = FindBone(player, SvermConfigManagement.Bone); if (bone == null) { - WarnMissingSpineBone(); + WarnMissingSpineBone(player); return; } @@ -496,7 +496,7 @@ namespace RacesOfValheim /// Said once, not forty times a minute. The cosmetic pass runs on a timer, so an /// unqualified LogWarning here would bury the log in the time it takes to read it. ///
- private static void WarnMissingSpineBone() + private static void WarnMissingSpineBone(Player player) { if (warnedMissingSpineBone) return; warnedMissingSpineBone = true; @@ -505,8 +505,10 @@ namespace RacesOfValheim // the rig simply has no Spine3 - it counts Spine, Spine1, Spine2 - and there was no // way to know that from a warning that only said what was missing. System.Text.StringBuilder spine = new System.Text.StringBuilder(); - Player local = Player.m_localPlayer; - VisEquipment visEq = local != null ? local.GetComponent() : null; + // Read off the player being dressed, not Player.m_localPlayer. On the main menu the one + // being dressed is the character preview and m_localPlayer is still null, so the old read + // answered "none found" about a rig that has three spine bones. + VisEquipment visEq = player != null ? player.GetComponent() : null; if (visEq != null && visEq.m_bodyModel != null && visEq.m_bodyModel.bones != null) { foreach (Transform b in visEq.m_bodyModel.bones) diff --git a/JotunnModStub/Trenta/TrentaMuspell.cs b/JotunnModStub/Trenta/TrentaMuspell.cs index 015292b..01157a9 100644 --- a/JotunnModStub/Trenta/TrentaMuspell.cs +++ b/JotunnModStub/Trenta/TrentaMuspell.cs @@ -252,11 +252,11 @@ namespace RacesOfValheim if (!isGrounded || !RaceInput.Allowed) return; - if (Input.GetMouseButtonDown(0)) // Stomp + if (RaceInput.AttackDown(0)) // Stomp { StartCoroutine(StompRoutine()); } - else if (Input.GetMouseButtonDown(1)) // Spike volley + else if (RaceInput.AttackDown(1)) // Spike volley { StartCoroutine(SpikeRoutine()); } diff --git a/JotunnModStub/Trol/TrolFoodPatches.cs b/JotunnModStub/Trol/TrolFoodPatches.cs index 7ff2255..77e46d5 100644 --- a/JotunnModStub/Trol/TrolFoodPatches.cs +++ b/JotunnModStub/Trol/TrolFoodPatches.cs @@ -54,7 +54,11 @@ namespace RacesOfValheim { if (__instance == Player.m_localPlayer && TrolRace.IsTrol()) { - if (item != null && item.m_shared != null && item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Consumable) + // Only real food goes through the stomach check. Meads and potions have m_food == 0 and + // vanilla never sends them to CanEat - only to the status-effect cooldown below it. Catching + // every Consumable here refused potions whenever the extra stomachs were full, and + // skipped that cooldown the rest of the time. + if (item != null && item.m_shared != null && item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Consumable && item.m_shared.m_food > 0f) { __result = CanTrolEat(__instance, item); return false; diff --git a/README.md b/README.md index 3a74061..a3d9f22 100644 --- a/README.md +++ b/README.md @@ -4,16 +4,6 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing --- -## Warning - -Jotunn has not been updated for Valheim 1.0 yet, and RacesOfValheim cannot run without it. Until the official build is out, install this community rebuild of Jotunn instead: - -[ReefTeam — Jotunn](https://thunderstore.io/c/valheim/p/ReefTeam/Jotunn/) - -Remove it once the Jotunn team ships its own 1.0 release. - ---- - ## Development & Feedback This is a stable release, but more races and refinements are planned! @@ -420,6 +410,10 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.14 +- **Fix - The Trol could not drink potions or meads:** the Trol's extra-stomach check caught every consumable, not just food, so a potion or a mead was refused whenever the extra stomachs were full — and when they had room, it skipped the potion's own cooldown instead. Only real food goes through the stomach check now; potions and meads are back on vanilla's rules. +- **NEW - Transformed forms can attack with a gamepad:** form attacks read the mouse buttons directly, so a gamepad player had no way to attack in any of them. Each form attack now also answers the pad button vanilla pairs with the same mouse button — Attack for left click, Block for right click, Secondary Attack for middle click — following the pad layout picked in the game settings. Covers the Fenrir forms, Skadi's dragon forms and her Cold Spell, the Sverm Ravager and the Trenta Muspell. On Skadi the keyboard keys stay rebindable; the pad buttons are fixed. + ### v1.4.13 - Update to 1.0. diff --git a/manifest.json b/manifest.json index 1f8bed5..921c41a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,10 +1,10 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.13", + "version_number": "1.4.14", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", - "ValheimModding-Jotunn-2.26.1" + "ValheimModding-Jotunn-2.30.0" ] } From 6e87be3c77dec0fc483e2d9e84a1fcb769032650 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sat, 12 Sep 2026 10:42:01 +0200 Subject: [PATCH 028/273] minor bugfix and pad support --- JotunnModStub/Aswid/AswidBloodPotions.cs | 7 +- JotunnModStub/Butler/BoneServantAI.cs | 80 ++++++++- JotunnModStub/Butler/ButlerStation.cs | 24 ++- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RaceClaws.cs | 2 +- JotunnModStub/RaceCompendium.cs | 19 ++- JotunnModStub/RaceInput.cs | 28 +++ JotunnModStub/RaceRadial.cs | 209 +++++++++++++++++++++++ JotunnModStub/RacesOfValheim.cs | 2 +- JotunnModStub/RaisedThrall.cs | 9 + JotunnModStub/Skadi/DrakeFormBehavior.cs | 9 +- JotunnModStub/Skadi/SkadiPatches.cs | 15 +- JotunnModStub/Sverm/SvermBlisterTick.cs | 9 + JotunnModStub/Sverm/SvermBrood.cs | 20 ++- JotunnModStub/Sverm/SvermConfig.cs | 17 +- JotunnModStub/Sverm/SvermHive.cs | 5 +- JotunnModStub/Sverm/SvermPatches.cs | 8 + JotunnModStub/Sverm/SvermRavagerForm.cs | 6 +- JotunnModStub/Sverm/SvermWorker.cs | 174 ++++++++++++++----- README.md | 12 ++ manifest.json | 2 +- 21 files changed, 574 insertions(+), 85 deletions(-) create mode 100644 JotunnModStub/RaceRadial.cs diff --git a/JotunnModStub/Aswid/AswidBloodPotions.cs b/JotunnModStub/Aswid/AswidBloodPotions.cs index 5e7e10f..83ebf3c 100644 --- a/JotunnModStub/Aswid/AswidBloodPotions.cs +++ b/JotunnModStub/Aswid/AswidBloodPotions.cs @@ -234,8 +234,11 @@ namespace RacesOfValheim { if (fermenter == null || GetContentMethod == null) return false; - string content = GetContentMethod.Invoke(fermenter, null) as string; - return content == BaseName || content == SuperiorBaseName; + // Valheim 1.0: GetContent returns the stable hash of the prefab name, not the name. The old + // "as string" read null for every barrel and the speed-up silently stopped. + int content = System.Convert.ToInt32(GetContentMethod.Invoke(fermenter, null)); + return content != 0 + && (content == BaseName.GetStableHashCode() || content == SuperiorBaseName.GetStableHashCode()); } private static Player.Food MakeFood(ItemDrop drop, GameObject prefab, string prefabName) diff --git a/JotunnModStub/Butler/BoneServantAI.cs b/JotunnModStub/Butler/BoneServantAI.cs index e5c1894..db77b6d 100644 --- a/JotunnModStub/Butler/BoneServantAI.cs +++ b/JotunnModStub/Butler/BoneServantAI.cs @@ -103,6 +103,31 @@ namespace RacesOfValheim /// with every instance the table raises.
public ButlerFamily m_family = ButlerFamily.Forge; + /// + /// Whether this one stands and fights instead of walking home when trouble comes. Off for the + /// Bone Servants, which are pacifists by decision; on for the Sverm's Seeker Workers, which + /// keep the forge AND defend the nest. See . + /// + public bool m_fightsBack = false; + + /// + /// How close to the anchor counts as home, and how far past the configured radius it works. + /// 2.5 and 0 for a table. A Sverm nest is metres of collider that grows with its stage, so + /// SvermWorkerBehaviour sets both to the nest's measured edge - otherwise an idle worker would + /// spend its life walking into the trunk, and the work circle would be mostly nest. + /// + public float m_homeDistance = 2.5f; + public float m_radiusBonus = 0f; + + /// For a servant that fights back: how close an enemy has to be to stop the work, how + /// often that is asked, and how long the fight holds after the last sign of one. + private const float FightRange = 12f; + private const float FightScanInterval = 1f; + private const float FightLinger = 5f; + + private float m_nextFightScan; + private float m_fightUntil; + private ZNetView m_nview; private Character m_character; private MonsterAI m_ai; @@ -207,13 +232,58 @@ namespace RacesOfValheim } /// Hit by something: stop working and walk home. It never fights back - there is - /// nothing in this class that could. + /// nothing in this class that could. A servant that fights back ignores this: vanilla already + /// holds the attacker as its target (MonsterAI.OnDamaged calls SetTarget, read off the IL), and + /// gives it the tick on the next frame.
public void NoteDamage() { + if (m_fightsBack) return; + m_fleeUntil = Time.time + FleeSeconds; m_job = null; } + /// + /// True while vanilla's MonsterAI should have the tick instead of the work - only ever for a + /// servant that fights back, and only on the client that runs it. + /// + /// VANILLA DOES THE FIGHTING, this only decides when. Two things start a fight: a target the + /// MonsterAI already holds - which covers being hit, see NoteDamage - and an enemy inside + /// FightRange, found with BaseAI.FindClosestEnemy. That one is a static sweep of distance and + /// IsEnemy with no line of sight (IL), which is why the range is short. Either holds the fight + /// for FightLinger seconds, so the worker does not flicker between swinging and walking to the + /// chest on alternate ticks. + /// + /// The job is dropped, not the payload: whatever it was carrying stays in the ZDO, and the + /// first plan after the fight carries it on to where it was going. + /// + public bool HandsToVanilla() + { + if (!m_fightsBack || m_ai == null || m_character == null || m_character.IsDead()) return false; + if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return false; + + Character target = m_ai.GetTargetCreature(); + if (target != null && !target.IsDead()) + { + m_fightUntil = Time.time + FightLinger; + } + else if (Time.time >= m_nextFightScan) + { + m_nextFightScan = Time.time + FightScanInterval; + if (BaseAI.FindClosestEnemy(m_character, transform.position, FightRange) != null) + { + m_fightUntil = Time.time + FightLinger; + } + } + + if (Time.time >= m_fightUntil) return false; + + m_job = null; + m_nextPlan = 0f; // the fight moved it; plan afresh the moment it hands back + SetStatus("Fighting."); + return true; + } + // ================================================================ the tick /// Everything. Returns what MonsterAI.UpdateAI would have returned. @@ -327,7 +397,7 @@ namespace RacesOfValheim List pieces = AllPiecesField != null ? AllPiecesField.GetValue(null) as List : null; if (pieces == null) return; - float radius = ButlerConfig.WorkRadius.Value; + float radius = ButlerConfig.WorkRadius.Value + m_radiusBonus; float radiusSq = radius * radius; for (int i = 0; i < pieces.Count; i++) @@ -923,7 +993,7 @@ namespace RacesOfValheim return; } - MoveToPoint(dt, anchor.Value, 2.5f, false); + MoveToPoint(dt, anchor.Value, m_homeDistance, false); } // ================================================================ the ground @@ -1356,6 +1426,10 @@ namespace RacesOfValheim BoneServantAI servant = __instance.GetComponent(); if (servant == null) return true; + // The one way back into vanilla: a servant that fights back hands over the whole tick for + // as long as there is a fight. Always false for the Bone Servants themselves. + if (servant.HandsToVanilla()) return true; + __result = servant.Tick(__0); return false; } diff --git a/JotunnModStub/Butler/ButlerStation.cs b/JotunnModStub/Butler/ButlerStation.cs index be76226..e276167 100644 --- a/JotunnModStub/Butler/ButlerStation.cs +++ b/JotunnModStub/Butler/ButlerStation.cs @@ -65,6 +65,11 @@ namespace RacesOfValheim /// "RPC_" prefix in this build - "RPC_AddOre", not "AddOre". A wrong name here is a silent no-op, /// which is exactly the class of bug that takes an evening to find, so the four names below were /// read out of each Awake() rather than remembered. + /// + /// A wrong ARGUMENT LIST is not silent: Valheim 1.0 added a trailing "bool cheated" to every + /// add-item RPC (and the Fermenter's now takes the prefab's stable hash, not its name), and the + /// old calls threw EndOfStreamException on the receiving end, every tick. The servant's goods + /// are real, so cheated is always false. ///
public abstract class ButlerStation { @@ -199,8 +204,9 @@ namespace RacesOfValheim public static readonly MethodInfo CookFireLit = AccessTools.Method(typeof(CookingStation), "IsFireLit"); public static readonly MethodInfo FermenterStatus = AccessTools.Method(typeof(Fermenter), "GetStatus"); + // 1.0 dropped the string overload: the Fermenter matches on GetStableHashCode of the name. public static readonly MethodInfo FermenterAllowed = - AccessTools.Method(typeof(Fermenter), "IsItemAllowed", new[] { typeof(string) }); + AccessTools.Method(typeof(Fermenter), "IsItemAllowed", new[] { typeof(int) }); // CookingStation.Status and Fermenter.Status are private nested enums: they cannot be named // in source, so they travel as ints. Values read from the assembly, not assumed. @@ -270,7 +276,7 @@ namespace RacesOfValheim public override void Add(string prefabName) { Claim(); - Nview.InvokeRPC("RPC_AddOre", prefabName); + Nview.InvokeRPC("RPC_AddOre", prefabName, false); } public override bool HasWork { get { return Queued > 0; } } @@ -318,8 +324,9 @@ namespace RacesOfValheim get { return m_cooking.m_slots != null ? m_cooking.m_slots.Length : 0; } } - /// GetSlot hands back three values through out parameters, one of which is a - /// private enum. Through reflection that means an args array and an int. + /// GetSlot hands back four values through out parameters, one of which is a + /// private enum. Through reflection that means an args array and an int. The fourth, a + /// bool "cheated", arrived with 1.0; it is ignored, but the array must have room for it. private bool ReadSlot(int index, out string name, out float cooked, out int status) { name = null; @@ -328,7 +335,7 @@ namespace RacesOfValheim if (Vanilla.CookGetSlot == null) return false; - object[] args = new object[] { index, null, null, null }; + object[] args = new object[] { index, null, null, null, null }; Vanilla.CookGetSlot.Invoke(m_cooking, args); name = args[1] as string; @@ -367,7 +374,7 @@ namespace RacesOfValheim public override void Add(string prefabName) { Claim(); - Nview.InvokeRPC("RPC_AddItem", prefabName); + Nview.InvokeRPC("RPC_AddItem", prefabName, false); } public override bool HasWork { get { return !Vanilla.Call(Vanilla.CookEmpty, m_cooking, true); } } @@ -486,13 +493,14 @@ namespace RacesOfValheim public override bool Accepts(string prefabName) { - return Vanilla.Allowed(Vanilla.FermenterAllowed, m_fermenter, prefabName); + if (Vanilla.FermenterAllowed == null || string.IsNullOrEmpty(prefabName)) return false; + return (bool)Vanilla.FermenterAllowed.Invoke(m_fermenter, new object[] { prefabName.GetStableHashCode() }); } public override void Add(string prefabName) { Claim(); - Nview.InvokeRPC("RPC_AddItem", prefabName); + Nview.InvokeRPC("RPC_AddItem", prefabName.GetStableHashCode(), false); } public override bool HasWork { get { return Status != Vanilla.FermentEmpty; } } diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 921c41a..e6bdf76 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.14", + "version_number": "1.4.15", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RaceClaws.cs b/JotunnModStub/RaceClaws.cs index 3e3c540..660fabc 100644 --- a/JotunnModStub/RaceClaws.cs +++ b/JotunnModStub/RaceClaws.cs @@ -809,7 +809,7 @@ namespace RacesOfValheim if (set == null) return; - if (RaceClawsConfig.ActivateKey.Value.IsDown()) + if (RaceClawsConfig.ActivateKey.Value.IsDown() || RaceInput.ConsumePress(RaceClawsConfig.ActivateKey.Value)) { if (RaceInput.Allowed) { diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index fcb3abc..b66c7ef 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -201,10 +201,21 @@ namespace RacesOfValheim } sb.AppendLine($"Troops: {roster}They follow when you ask, walk home when you let them go, and mend themselves.\n"); - string haulers = state >= SvermConfig.HaulerUnlockState - ? $", and up to {SvermConfigManagement.Haulers} haulers come out of the nest to carry food back into it" - : ", and the haulers who carry food back into it will not hatch until Bonemass falls"; - sb.AppendLine($"Seeker Workers: free, and always free - no biomass, no egg, and a new one when an old one dies. Two trades that never share hands: up to {SvermConfigManagement.Farmers} farmers come out of the infected beehives to work the ground{haulers}. They are half a Seeker in size, in health and in reach, they take no orders and they never follow - they stay where they were born and defend what stands there.\n"); + string workers = state >= SvermConfig.HaulerUnlockState + ? $"up to {SvermConfigManagement.Haulers} come out of the nest" + : "none will come out of the nest until Bonemass falls"; + + // The sigil by its in-game name, so the page says what the player actually has to put + // in the chest rather than a prefab name. + string sigil = ButlerConfig.SigilItem.Value; + UnityEngine.GameObject sigilPrefab = ObjectDB.instance != null ? ObjectDB.instance.GetItemPrefab(sigil) : null; + ItemDrop sigilDrop = sigilPrefab != null ? sigilPrefab.GetComponent() : null; + if (sigilDrop != null && sigilDrop.m_itemData?.m_shared != null && Localization.instance != null) + { + sigil = Localization.instance.Localize(sigilDrop.m_itemData.m_shared.m_name); + } + + sb.AppendLine($"Seeker Workers: free, and always free - no biomass, no egg, and a new one when an old one dies; {workers}. While they live the nest feeds itself from the chests at its foot, and they keep the forge the way a Bone Smith does: put {sigil} in a chest within {ButlerConfig.WorkRadius.Value:0} meters of the nest's edge and they carry ore and fuel from it to the smelters, kilns and mills around, then bring what comes out back to that chest. They are half a Seeker in size, in health and in bite, they take no orders and they never follow - they fight what comes near, mend what you built, and go back to work.\n"); sb.AppendLine($"Blister Tick {SvermConfig.TickPrice:0}: buys a slot forever. It runs at what you are fighting and bursts, and the nest grows another one {SvermConfig.TickRespawnSeconds:0} seconds later, free.\n"); diff --git a/JotunnModStub/RaceInput.cs b/JotunnModStub/RaceInput.cs index 0f08de1..4ec970b 100644 --- a/JotunnModStub/RaceInput.cs +++ b/JotunnModStub/RaceInput.cs @@ -77,6 +77,7 @@ namespace RacesOfValheim ///
public static bool IsDownIgnoringHeldKeys(this KeyboardShortcut shortcut) { + if (ConsumePress(shortcut)) return true; if (shortcut.MainKey == KeyCode.None) return false; if (!Input.GetKeyDown(shortcut.MainKey)) return false; @@ -100,6 +101,33 @@ namespace RacesOfValheim return true; } + // A key press that came from somewhere other than the keyboard - the race group in the radial + // menu (RaceRadial). Held for a short window rather than one frame, because the radial closes + // with an animation and the race reading the key may not run on the very next frame; the + // first matching read takes it, so it fires once. + private const float PressWindow = 0.5f; + private static KeyboardShortcut pressed = KeyboardShortcut.Empty; + private static float pressedUntil = -1f; + + public static void Press(KeyboardShortcut shortcut) + { + pressed = shortcut; + pressedUntil = Time.time + PressWindow; + } + + /// True once if was pressed through . + /// IsDownIgnoringHeldKeys already asks; the two readers still on BepInEx's own IsDown() ask + /// directly. + public static bool ConsumePress(KeyboardShortcut shortcut) + { + if (Time.time > pressedUntil) return false; + if (shortcut.MainKey == KeyCode.None || shortcut.MainKey != pressed.MainKey) return false; + if (!System.Linq.Enumerable.SequenceEqual(shortcut.Modifiers, pressed.Modifiers)) return false; + + pressedUntil = -1f; + return true; + } + // Gamepad counterparts of the three mouse buttons, indexed like Input.GetMouseButton. // Not a free choice: ZInput.ResetKBMButtons binds Attack to Mouse0, Block to Mouse1 and // SecondaryAttack to Mouse2, so each form attack lands on the pad button vanilla already diff --git a/JotunnModStub/RaceRadial.cs b/JotunnModStub/RaceRadial.cs new file mode 100644 index 0000000..f381421 --- /dev/null +++ b/JotunnModStub/RaceRadial.cs @@ -0,0 +1,209 @@ +using System; +using System.Collections.Generic; +using System.Reflection; +using BepInEx.Configuration; +using HarmonyLib; +using UnityEngine; +using Valheim.UI; +using Object = UnityEngine.Object; + +namespace RacesOfValheim +{ + /// + /// The race's powers on a gamepad: one more group in Valheim 1.0's radial menu, named after the + /// player's race, with one entry per form and ability. + /// + /// WHY THE RADIAL AND NOT A BUTTON. Read off the 1.0 assemblies with Cecil: every physical pad + /// button is bound in all four layouts, the only chords vanilla leaves alone are LT+X and LT+R3 + /// in Classic only, and LT is already the transformed forms' Mouse1 attack through + /// RaceInput.PadAttackButtons. The radial is opened the way vanilla opens it (hold R3, or the + /// keyboard's own radial key), follows whatever layout is picked, and has room for every race. + /// + /// NO RACE CODE CHANGES. An entry does not call into the race: it "presses" the key the player + /// already has bound (RaceInput.Press), and the race's own IsDownIgnoringHeldKeys check picks it + /// up on its next Update. Unlock rules, cooldowns and the messages that go with them therefore + /// behave exactly as they do from the keyboard, and a rebound key is followed for free. + /// + /// Everything vanilla-side was read, not guessed: ValheimRadialConfig.InitRadialConfig builds + /// its top page by calling AddEmoteGroup(radial, elements) among others, a group is a + /// GroupElement instantiated from RadialData.SO and Init'ed with (config, back, radial), and its + /// Interact just calls radial.QueuedOpen(config, back). Leaves are elements whose Interact and + /// CloseOnInteract are public Func<bool> setters; Name's setter is private, hence the + /// reflection. + /// + public static class RaceRadial + { + private class Entry + { + public string Race; + public string Label; + public Func> Key; + public string Icon; // an item prefab whose icon is borrowed; may not exist + public Func Available; // null means always, for that race + } + + private static readonly List Entries = new List + { + new Entry { Race = "Fenrir", Label = "Wolf Form", Key = () => FenrirConfig.WolfFormKey, Icon = "TrophyWolf" }, + new Entry { Race = "Fenrir", Label = "Fenrir Form", Key = () => FenrirConfig.FenrirFormKey, Icon = "TrophyFenring" }, + new Entry { Race = "Fenrir", Label = "Cultist Form", Key = () => FenrirConfig.CultistFormKey, Icon = "TrophyCultist" }, + new Entry { Race = "Fenrir", Label = "Howl", Key = () => FenrirConfig.HowlKey, Icon = "TrophyUlv" }, + + new Entry { Race = "Aswid", Label = "Bat Form", Key = () => AswidConfig.BatFormKey, Icon = "TrophyBat" }, + new Entry { Race = "Aswid", Label = "Mist Form", Key = () => AswidConfig.MistFormKey, Icon = "TrophyWraith" }, + new Entry { Race = "Aswid", Label = "Eclipse", Key = () => AswidConfig.EclipseKey, Icon = "TrophyFader" }, + new Entry { Race = "Aswid", Label = "Tame", Key = () => AswidConfig.TameKey, Icon = "TrophyWolf" }, + new Entry { Race = "Aswid", Label = "Devour", Key = () => AswidConfig.ToggleDevourKey, Icon = "TrophyDraugr" }, + + new Entry { Race = "Skadi", Label = "Drake Form", Key = () => SkadiConfig.DrakeFormKey, Icon = "TrophyHatchling" }, + new Entry { Race = "Skadi", Label = "Moder Form", Key = () => SkadiConfig.ModerFormKey, Icon = "TrophyDragonQueen" }, + new Entry { Race = "Skadi", Label = "Fader Form", Key = () => SkadiConfig.FaderFormKey, Icon = "TrophyFader" }, + + new Entry { Race = "Trol", Label = "True Form", Key = () => TrolConfig.TrueFormKey, Icon = "TrophyFrostTroll" }, + new Entry { Race = "Trol", Label = "Throw Rock", Key = () => TrolConfig.ThrowRockKey, Icon = "Stone" }, + new Entry { Race = "Trol", Label = "Grab Log", Key = () => TrolConfig.GrabLogKey, Icon = "Wood" }, + + new Entry { Race = "Trenta", Label = "Purple Rain", Key = () => TrentaConfigManagement.PurpleRainKey, Icon = "Blueberries" }, + new Entry { Race = "Trenta", Label = "Homecoming Portal", Key = () => TrentaConfigManagement.PortalKey, Icon = "SurtlingCore" }, + new Entry { Race = "Trenta", Label = "Muspell Form", Key = () => TrentaConfigManagement.MuspellKey, Icon = "TrophySurtling" }, + + new Entry { Race = "Dvergar", Label = "Runic Ping", Key = () => DvergarConfigManagement.RunicPingKey, Icon = "TrophyDvergr" }, + new Entry { Race = "Dvergar", Label = "Runic Overcharge", Key = () => DvergarConfigManagement.RunicOverchargeKey, Icon = "Eitr" }, + + new Entry { Race = "Sverm", Label = "Ravager Strain", Key = () => SvermConfigManagement.RavagerKey, Icon = "TrophySeekerBrute" }, + + // Any race: shown to whoever RaceClawSet has claws for. + new Entry { Race = null, Label = "Grow Claws", Key = () => RaceClawsConfig.ActivateKey, Icon = "TrophyWolf", + Available = player => RaceClawSet.For(player) != null }, + }; + + private static readonly MethodInfo SetName = AccessTools.PropertySetter(typeof(RadialMenuElement), "Name"); + + /// Called from the AddEmoteGroup postfix: appends the race's group to vanilla's top page. + public static void AddGroup(IRadialConfig back, RadialBase radial, List elements) + { + Player player = Player.m_localPlayer; + if (player == null || radial == null || elements == null) return; + if (RadialData.SO == null || RadialData.SO.GroupElement == null) return; + + string race = RaceOf(player); + List mine = For(player, race); + if (mine.Count == 0) return; + + GroupElement group = Object.Instantiate(RadialData.SO.GroupElement); + group.Init(new RaceRadialConfig(race, mine), back, radial); + elements.Add(group); + } + + private static List For(Player player, string race) + { + List mine = new List(); + foreach (Entry entry in Entries) + { + if (entry.Race != null && entry.Race != race) continue; + if (entry.Available != null && !entry.Available(player)) continue; + if (entry.Key() == null) continue; // that race's config never bound: nothing to press + mine.Add(entry); + } + return mine; + } + + /// The same two sources RaceClaws.GetRace reads, in the same order, "Human" in the + /// ZDO counting as no answer. + private static string RaceOf(Player player) + { + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid()) + { + string race = nview.GetZDO().GetString("RacesOfValheim_Race", ""); + if (!string.IsNullOrEmpty(race) && race != "Human") return race; + } + + if (player.m_customData != null && player.m_customData.TryGetValue("Race", out string custom)) + { + return custom; + } + + return "Human"; + } + + /// An item's inventory icon, or null - a missing prefab only costs the picture. + private static Sprite IconOf(string prefabName) + { + if (ObjectDB.instance == null || string.IsNullOrEmpty(prefabName)) return null; + + GameObject prefab = ObjectDB.instance.GetItemPrefab(prefabName); + ItemDrop drop = prefab != null ? prefab.GetComponent() : null; + if (drop == null || drop.m_itemData?.m_shared?.m_icons == null || drop.m_itemData.m_shared.m_icons.Length == 0) return null; + + return drop.m_itemData.GetIcon(); + } + + /// The group's own page: one leaf per entry, built fresh every time it is opened so a + /// rebound key or a newly grown claw set is always current. + private class RaceRadialConfig : IRadialConfig + { + private readonly string m_race; + private readonly List m_entries; + + public RaceRadialConfig(string race, List entries) + { + m_race = race; + m_entries = entries; + } + + public string LocalizedName => m_race; + + public Sprite Sprite => m_entries.Count > 0 ? IconOf(m_entries[0].Icon) : null; + + public void InitRadialConfig(RadialBase radial) + { + List leaves = new List(); + + foreach (Entry entry in m_entries) + { + RadialMenuElement leaf = Object.Instantiate(RadialData.SO.EmoteElement); + Entry captured = entry; + + string key = entry.Key().Value.ToString(); + SetName?.Invoke(leaf, new object[] { string.IsNullOrEmpty(key) ? entry.Label : $"{entry.Label} ({key})" }); + + leaf.Interact = () => + { + RaceInput.Press(captured.Key().Value); + return true; + }; + leaf.CloseOnInteract = () => true; + + Sprite icon = IconOf(entry.Icon); + if (leaf.Icon != null) + { + leaf.Icon.gameObject.SetActive(icon != null); + leaf.Icon.sprite = icon; + } + + leaves.Add(leaf); + } + + radial.ConstructRadial(leaves); + } + } + } + + [HarmonyPatch(typeof(ValheimRadialConfig), "AddEmoteGroup")] + public static class RaceRadial_AddEmoteGroup_Patch + { + // Wrapped: a mistake here must cost the race group, never the player's whole radial menu. + public static void Postfix(ValheimRadialConfig __instance, RadialBase radial, List elements) + { + try + { + RaceRadial.AddGroup(__instance, radial, elements); + } + catch (Exception e) + { + Jotunn.Logger.LogWarning($"[RaceRadial] Could not add the race group to the radial menu: {e}"); + } + } + } +} diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 94adc40..c44adc6 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.14"; + public const string PluginVersion = "1.4.15"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/JotunnModStub/RaisedThrall.cs b/JotunnModStub/RaisedThrall.cs index 5625274..f1ecd9c 100644 --- a/JotunnModStub/RaisedThrall.cs +++ b/JotunnModStub/RaisedThrall.cs @@ -313,6 +313,15 @@ namespace RacesOfValheim return false; } + // THE PATROL POINT GOES OFF while it follows, and GoHome puts it back when it is let go. + // MonsterAI.UpdateTarget measures a tame creature's target from its patrol point whenever + // it has one, and only falls back to the follow target when it has none (IL). Left on, a + // thrall walking beside its master kept judging every enemy by its distance from the + // STATION - so the further from home, the fewer fights it would take. ResetPatrolPoint + // writes the ZDO as well as the field, which matters: GetPatrolPoint re-reads the ZDO + // every second and would switch it straight back on. + if (m_ai != null) m_ai.ResetPatrolPoint(); + m_monsterAI.SetFollowTarget(player.gameObject); if (announce) player.Message(MessageHud.MessageType.Center, $"{m_character.m_name} follows."); return true; diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index 4f49e9a..7258cb8 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -131,8 +131,13 @@ namespace RacesOfValheim { if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return; - // Handle Flight Toggle (Right Mouse by default, rebindable) - Disabled for Fader - if (RaceInput.Allowed && SkadiConfig.FlightToggleKey.Value.IsDownIgnoringHeldKeys() && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon) + // Handle Flight Toggle (Right Mouse by default, rebindable) - Disabled for Fader. + // On a pad it is the Block button, Right Mouse's vanilla partner (RaceInput.PadAttackDown(1)): + // the left trigger in the Classic layout. Free here - neither drake nor Moder has a + // button-1 attack; the only one is Fader's spin, and Fader never flies. + if (RaceInput.Allowed && + (SkadiConfig.FlightToggleKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(1)) && + formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon) { if (!isFlying && !isLanding) { diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 6cdcc99..482dad4 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -305,6 +305,8 @@ namespace RacesOfValheim // How much of the aim heading survives the climb out of water. Mostly up, with enough // forward in it that the player still chooses which shore they surface towards. private const float LIFTOFF_HEADING_BLEND = 0.35f; + // How far the left stick has to be pushed before it counts as W or S. + private const float StickThreshold = 0.5f; /// /// True while the local player is beating backwards this frame. Read by @@ -326,10 +328,17 @@ namespace RacesOfValheim var traverse = Traverse.Create(__instance); Vector3 lookDir = Player.m_localPlayer.GetLookDir(); bool input = RaceInput.Allowed; - bool forward = input && Input.GetKey(KeyCode.W); + // The pad's half of W/S: the left stick, read with vanilla's own sign - + // PlayerController.FixedUpdate takes forward as the NEGATED GetJoyLeftStickY. + // Flight only knows powered forward, reverse or neither, so the stick is a + // threshold, not a throttle. Steering stays on the camera, i.e. the right stick. + float stick = -ZInput.GetJoyLeftStickY(); + bool forward = input && (Input.GetKey(KeyCode.W) || stick > StickThreshold); // Forward wins a W+S mash rather than the two cancelling into a dead hover. - bool backward = input && !forward && Input.GetKey(KeyCode.S); - bool sprintKey = input && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift)); + bool backward = input && !forward && (Input.GetKey(KeyCode.S) || stick < -StickThreshold); + // Sprint on a pad is vanilla's run button, wherever the chosen layout puts it. + bool sprintKey = input && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) || + ZInput.GetButton("JoyRun")); bool onGround = __instance.IsOnGround(); // IsSwimming is the exact test UpdateMotion uses to hand the frame to UpdateSwimming // instead of UpdateFlying, so it is also the one condition SkadiWaterFlightPatch has diff --git a/JotunnModStub/Sverm/SvermBlisterTick.cs b/JotunnModStub/Sverm/SvermBlisterTick.cs index f8c0869..7363fb1 100644 --- a/JotunnModStub/Sverm/SvermBlisterTick.cs +++ b/JotunnModStub/Sverm/SvermBlisterTick.cs @@ -57,6 +57,15 @@ namespace RacesOfValheim BaseAI ai = prefab.GetComponent(); if (ai != null) ai.m_randomMoveRange = SvermConfig.TroopLeashRange; + // The same fighting bounds as the rest of the swarm - SvermConfig.TroopAlertRange. A tick + // with the vanilla numbers ran off after anything in sight and burst far from home. + MonsterAI monster = prefab.GetComponent(); + if (monster != null) + { + monster.m_alertRange = SvermConfig.TroopAlertRange; + monster.m_maxChaseDistance = SvermConfig.TroopAlertRange; + } + // Nothing to farm off something that respawns for free forever. This one matters more // than on the other troops for exactly that reason. foreach (CharacterDrop drops in prefab.GetComponentsInChildren(true)) diff --git a/JotunnModStub/Sverm/SvermBrood.cs b/JotunnModStub/Sverm/SvermBrood.cs index df9514e..f67c92d 100644 --- a/JotunnModStub/Sverm/SvermBrood.cs +++ b/JotunnModStub/Sverm/SvermBrood.cs @@ -98,6 +98,15 @@ namespace RacesOfValheim BaseAI ai = prefab.GetComponent(); if (ai != null) ai.m_randomMoveRange = SvermConfig.TroopLeashRange; + // The hive's own bounds for a fight - see SvermConfig.TroopAlertRange. Without these the + // troops kept the vanilla prefab's numbers and chased whatever they could see. + MonsterAI monster = prefab.GetComponent(); + if (monster != null) + { + monster.m_alertRange = SvermConfig.TroopAlertRange; + monster.m_maxChaseDistance = SvermConfig.TroopAlertRange; + } + foreach (CharacterDrop drops in prefab.GetComponentsInChildren(true)) { if (drops != null) Object.DestroyImmediate(drops); @@ -191,7 +200,10 @@ namespace RacesOfValheim /// creature on the TERRAIN height there, so a nest on a slope does not bury anyone either. /// The per-kind height goes on top, which is what keeps the Gjall in the air. /// - private static Vector3 SpawnSpot(SvermHiveBehaviour hive, Kind kind) + private static Vector3 SpawnSpot(SvermHiveBehaviour hive, Kind kind) => SpawnSpot(hive, kind.SpawnHeight); + + /// The same ring, for anything else the nest puts on the ground - the workers. + internal static Vector3 SpawnSpot(SvermHiveBehaviour hive, float height) { Vector3 centre = hive.transform.position; float radius = RingRadius(hive); @@ -206,14 +218,14 @@ namespace RacesOfValheim if (Physics.CheckSphere(candidate + Vector3.up * 1.5f, 1f, obstacleMask)) continue; - return candidate + Vector3.up * kind.SpawnHeight; + return candidate + Vector3.up * height; } // Twelve tries and everything is built up: due south on the ring anyway. Still outside // the nest, which is the thing this is here to guarantee. Vector3 fallback = centre + new Vector3(0f, 0f, -radius); if (ZoneSystem.instance != null) fallback.y = ZoneSystem.instance.GetGroundHeight(fallback); - return fallback + Vector3.up * kind.SpawnHeight; + return fallback + Vector3.up * height; } /// @@ -224,7 +236,7 @@ namespace RacesOfValheim /// small one hatches troops inside the big one. Only solid meshes are measured; the hive's /// particle effects have bounds of their own and would report a ring the size of a field. /// - private static float RingRadius(SvermHiveBehaviour hive) + internal static float RingRadius(SvermHiveBehaviour hive) { Vector3 centre = hive.transform.position; float widest = 0f; diff --git a/JotunnModStub/Sverm/SvermConfig.cs b/JotunnModStub/Sverm/SvermConfig.cs index 1feebec..0a74c95 100644 --- a/JotunnModStub/Sverm/SvermConfig.cs +++ b/JotunnModStub/Sverm/SvermConfig.cs @@ -444,15 +444,12 @@ namespace RacesOfValheim public static readonly float WorkerHealthFraction = 0.5f; public static readonly float WorkerDamageFraction = 0.5f; - /// One out of every infected beehive on this timer, until the pool is full. + /// One out of the nest on this timer, until the pool is full. public static readonly float WorkerSpawnInterval = 120f; /// Haulers only start after Bonemass. public const int HaulerUnlockState = 4; - /// Ten metres. Also the radius it keeps in repair. - public static readonly float WorkerLeashRange = 10f; - /// How far a worker reaches to mend, and how often it mends one thing. public static readonly float WorkerRepairRange = 10f; public static readonly float WorkerRepairInterval = 5f; @@ -509,6 +506,18 @@ namespace RacesOfValheim /// How far a troop wanders from the nest when nobody is leading it. public static readonly float TroopLeashRange = 12f; + /// + /// How far from home a troop will fight: the leash on the TARGET, not on the walk. + /// + /// Set on the prefab as both m_alertRange and m_maxChaseDistance, and it has to be. Vanilla + /// drops a tame creature's target once the target is further than m_alertRange from its + /// patrol point (the nest, pinned by RaisedThrall) - read off MonsterAI.UpdateTarget - and the + /// troops used to inherit whatever the Seeker, Gjall and Tick prefabs carry, which is 9999 in + /// code. They hunted anything they could see. While a troop FOLLOWS, the patrol point is off + /// and the same range is measured from the player instead. + /// + public static readonly float TroopAlertRange = 25f; + /// How long a troop outlives the nest that hatched it, in seconds. public static readonly float TroopWitherSeconds = 60f; diff --git a/JotunnModStub/Sverm/SvermHive.cs b/JotunnModStub/Sverm/SvermHive.cs index c3f0114..6e8f53b 100644 --- a/JotunnModStub/Sverm/SvermHive.cs +++ b/JotunnModStub/Sverm/SvermHive.cs @@ -464,6 +464,7 @@ namespace RacesOfValheim return $"{SvermHiveStage.NameOf(SvermHiveStage.Of(transform))}\n" + SvermHiveReadout.Tank(transform) + $"Beehives {infected} taken of {SvermConfigManagement.Beehives} allowed, {beehives} in range\n" + + SvermWorker.Readout(transform.position) + "[$KEY_Use] Feed it a stack"; } @@ -591,8 +592,8 @@ namespace RacesOfValheim Haul(); - // Haulers come out of the NEST, and only after Bonemass. The farmers are the beehives' - // business, not the nest's - see SvermBeehive. + // Workers come out of the NEST, and only after Bonemass. There is no second pool: the + // farmers section 19.3 wanted out of the beehives were dropped with the farming. if (BossProgressionManager.GetCurrentProgressionState() >= SvermConfig.HaulerUnlockState && Time.time >= nextHauler && SvermWorker.HasRoom(SvermWorker.Job.Hauler)) diff --git a/JotunnModStub/Sverm/SvermPatches.cs b/JotunnModStub/Sverm/SvermPatches.cs index 4a2b4a3..4a21dc6 100644 --- a/JotunnModStub/Sverm/SvermPatches.cs +++ b/JotunnModStub/Sverm/SvermPatches.cs @@ -112,6 +112,14 @@ namespace RacesOfValheim Character attacker = hit.GetAttacker(); + // ── Seeker Workers bite at half a Seeker's weight. Scaled on the blow and not on the + // weapon, because the blow comes from the Seeker's default weapon and that weapon's + // shared data is every Seeker's in the world. + if (attacker != null && SvermWorker.IsWorker(attacker)) + { + hit.m_damage.Modify(SvermConfig.WorkerDamageFraction); + } + // ── Outgoing if (attacker is Player attackingPlayer && SvermVisuals.IsSvermPlayer(attackingPlayer)) { diff --git a/JotunnModStub/Sverm/SvermRavagerForm.cs b/JotunnModStub/Sverm/SvermRavagerForm.cs index c2cbbfb..9ef37a1 100644 --- a/JotunnModStub/Sverm/SvermRavagerForm.cs +++ b/JotunnModStub/Sverm/SvermRavagerForm.cs @@ -147,7 +147,8 @@ namespace RacesOfValheim // way out, same as death or losing the race. if (IsActive) return; - if (!SvermConfigManagement.RavagerKey.Value.IsDown()) return; + if (!SvermConfigManagement.RavagerKey.Value.IsDown() && + !RaceInput.ConsumePress(SvermConfigManagement.RavagerKey.Value)) return; if (!SvermVisuals.IsSvermPlayer(player)) return; if (!SvermProgression.Current.RavagerForm) @@ -559,7 +560,8 @@ namespace RacesOfValheim { StartCoroutine(AttackRoutine(SvermRavagerAttacks.Slam, 1.2f, 0.4f, 1.0f)); } - else if (SvermConfigManagement.RavagerKey.Value.IsDown() && Time.time >= nextTauntAt) + else if ((SvermConfigManagement.RavagerKey.Value.IsDown() || + RaceInput.ConsumePress(SvermConfigManagement.RavagerKey.Value)) && Time.time >= nextTauntAt) { nextTauntAt = Time.time + SvermConfig.RavagerTauntCooldownSeconds; StartCoroutine(TauntRoutine()); diff --git a/JotunnModStub/Sverm/SvermWorker.cs b/JotunnModStub/Sverm/SvermWorker.cs index 255349d..3a1b6cd 100644 --- a/JotunnModStub/Sverm/SvermWorker.cs +++ b/JotunnModStub/Sverm/SvermWorker.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using System.Text; using Jotunn.Managers; using UnityEngine; @@ -8,18 +9,21 @@ namespace RacesOfValheim /// The Seeker Worker: half a Seeker, and the reason the colony feels like a colony rather than /// like a barracks. /// - /// TWO JOBS, TWO POOLS, and the pools do not share. Farmers come out of the infected beehives - /// and work the ground; haulers come out of the nest after Bonemass and carry food into it. - /// Nine alive at most between them, and neither trade can starve the other of hands - which is - /// the whole reason they are counted separately instead of out of one number. + /// ONE TRADE. They come out of the nest after Bonemass, up to the hauler cap, and they earn their + /// keep twice over: the nest eats out of the chests at its foot once per living worker (see + /// SvermHiveBehaviour.Haul), and the workers themselves keep the forge the way the Skeleton's + /// Bone Smith does - the same brain, the same sigil chests, the same stations. Section 19.3's + /// farmers were the other trade; farming was tried and rejected, and nothing ever spawned one. + /// The Job enum keeps the name only so the cap entries in players' .cfg files still mean what + /// they say. /// /// They are FREE. No biomass, no egg, and they are replaced when they die. That is deliberate: /// they are labour, not army. Nothing they do competes with Brood, Seeker, Soldier or Gjall for - /// the tank, and nothing about them is commandable - they stay where they were born, defend - /// what is there, and never follow. + /// the tank, and nothing about them is commandable - they work, they fight what comes near, and + /// they never follow. /// /// Half size, half health, half damage. The size and health are set on the prefab; the damage - /// is halved in the damage patch, because a creature's blow comes from its default weapon and + /// is halved in Sverm_Damage_Patch, because a creature's blow comes from its default weapon and /// that weapon's shared data belongs to every Seeker in the world. ///
public static class SvermWorker @@ -68,8 +72,22 @@ namespace RacesOfValheim CharacterDrop drop = prefab.GetComponent(); if (drop != null) Object.DestroyImmediate(drop); + BaseAI ai = prefab.GetComponent(); + if (ai != null) + { + ai.m_avoidFire = false; // it works next to kilns for a living + ai.m_afraidOfFire = false; + } + prefab.AddComponent(); + // The Bone Smith's brain, whole: the Forge family of stations, fed from chests that hold + // the sigil. It takes the MonsterAI tick over completely, so the worker only ever swings at + // anything because m_fightsBack hands the tick back to vanilla while there is a fight. + BoneServantAI smith = prefab.AddComponent(); + smith.m_family = ButlerFamily.Forge; + smith.m_fightsBack = true; + PrefabManager.Instance.AddPrefab(prefab); Jotunn.Logger.LogInfo($"[Sverm] Registered '{PrefabName}' at {SvermConfig.WorkerScale:P0} of a Seeker."); } @@ -99,11 +117,18 @@ namespace RacesOfValheim public static bool HasRoom(Job job) => CountLive(job) < Cap(job); + /// Puts a worker on the roll. Idempotent - Spawn and the worker's own Awake both + /// call it, and a worker loaded back from the save only ever gets the second. + internal static void Track(SvermWorkerBehaviour worker) + { + if (worker != null && !live.Contains(worker)) live.Add(worker); + } + /// - /// Puts one worker on the ground and ties it to whatever produced it. + /// Puts one worker on the ground, bound to the nest that produced it. /// - /// The anchor is not decoration: it is where the worker idles, what it defends, and the - /// centre of the three metres it searches for chests. A worker with no anchor has no job. + /// The binding lives in the worker's own ZDO, written by the smith's brain: it is the centre + /// of the work circle, where the worker goes when idle, and what its wither clock asks after. /// public static void Spawn(Job job, Transform anchor) { @@ -112,50 +137,87 @@ namespace RacesOfValheim GameObject prefab = ZNetScene.instance != null ? ZNetScene.instance.GetPrefab(PrefabName) : null; if (prefab == null) return; - Vector3 where = anchor.position + Vector3.up * 0.5f + Random.insideUnitSphere * 0.5f; - where.y = anchor.position.y + 0.5f; + // Outside the nest, on the ring the troops hatch on. Put down at the nest's own centre a + // worker comes out wedged in several metres of collider - fatal for a creature whose whole + // job is walking to a furnace. + SvermHiveBehaviour hive = anchor.GetComponent(); + Vector3 where = hive != null ? SvermBrood.SpawnSpot(hive, 0.5f) : anchor.position + Vector3.up * 0.5f; - GameObject spawned = Object.Instantiate(prefab, where, Quaternion.identity); + GameObject spawned = Object.Instantiate(prefab, where, Quaternion.Euler(0f, Random.Range(0f, 360f), 0f)); if (spawned == null) return; - Character character = spawned.GetComponent(); - if (character != null) character.SetTamed(true); + BoneServantAI smith = spawned.GetComponent(); + if (smith != null) + { + smith.Bind(anchor.position); // tames it, too + } + else + { + Character character = spawned.GetComponent(); + if (character != null) character.SetTamed(true); + } SvermWorkerBehaviour behaviour = spawned.GetComponent() ?? spawned.AddComponent(); behaviour.Trade = job; - behaviour.Anchor = anchor; - - live.Add(behaviour); + Track(behaviour); } public static bool IsWorker(Character character) { return character != null && character.GetComponent() != null; } + + /// + /// One line per worker bound to this nest, for the nest's hover. + /// + /// The smith's brain writes what it is doing into the worker's ZDO, and the Bone Smith shows it + /// on its table - the one feedback channel that feature has. A worker's table is the nest, so + /// this is the same channel. Read on every client: the roll is filled by Awake, which runs + /// everywhere, and the status comes off the ZDO. + /// + public static string Readout(Vector3 nest) + { + StringBuilder text = new StringBuilder(); + + foreach (SvermWorkerBehaviour worker in live) + { + if (worker == null || worker.Dead) continue; + + BoneServantAI smith = worker.GetComponent(); + if (smith == null || !smith.IsBoundTo(nest)) continue; + + string status = smith.Status; + text.Append("Worker: ").Append(string.IsNullOrEmpty(status) ? "Waiting." : status).Append('\n'); + } + + return text.ToString(); + } } /// - /// One worker's whole life: stay home, mend what the player built, and fight what comes. + /// What a worker does on top of the smith's brain: keep what the player built in repair, keep + /// its orders its own, and tell the brain how big home is. /// - /// THIS IS THE THIRD DESIGN AND THE FIRST HONEST ONE. The first two hung the colony's economy - /// on a creature that walks: workers carried food from chests to the hive, and every time one - /// wandered off or got killed the supply chain went with it - chests full, tank at zero, and - /// nothing in the log to blame. Hauling belongs to something that cannot walk away, and - /// feeding the hive is now the player's own job through the shop. - /// - /// What is left is what a creature is actually good at: being somewhere, keeping it in repair, - /// and defending it. No carrying, no farming, no orders. + /// No farming and no orders. The carrying is the Bone Smith's and lives in BoneServantAI - the + /// earlier hauling that hung the colony's economy on a walking creature is still gone: the nest + /// feeds itself from its own chests, and a dead worker only ever costs the forge a trip. /// public class SvermWorkerBehaviour : MonoBehaviour { - public SvermWorker.Job Trade; - public Transform Anchor; + /// Hauler by default, and the default matters: a worker loaded back from the save + /// never goes through Spawn, so this is the trade it is counted under. + public SvermWorker.Job Trade = SvermWorker.Job.Hauler; public bool Dead => m_character == null || m_character.IsDead(); + /// How far a worker that has no nest on its ZDO looks for one to adopt. + private const float AdoptRange = 40f; + private Character m_character; private MonsterAI m_ai; + private ZNetView m_nview; + private BoneServantAI m_smith; private float m_nextHomeCheck; private float m_nextRepair; @@ -163,13 +225,28 @@ namespace RacesOfValheim { m_character = GetComponent(); m_ai = GetComponent(); + m_nview = GetComponent(); + m_smith = GetComponent(); + + // Counted from the moment it exists, not from the moment it was spawned. The roll used to + // be kept by Spawn alone, so every worker that came back from the save was invisible to it + // and the nest hatched a fresh one on top, two minutes at a time, reload after reload. + SvermWorker.Track(this); } private void Update() { - if (Dead || Anchor == null) return; + if (Dead) return; - KeepHome(); + // The owner's round only, like the smith's brain it sits beside: two clients repairing and + // rebinding the same worker is two answers to one question. + if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return; + + if (Time.time >= m_nextHomeCheck) + { + m_nextHomeCheck = Time.time + 2f; + KeepHome(); + } if (Time.time < m_nextRepair) return; m_nextRepair = Time.time + SvermConfig.WorkerRepairInterval; @@ -178,30 +255,33 @@ namespace RacesOfValheim } /// - /// Ten metres, and told to the AI rather than forced on the transform. + /// The three things the smith's brain cannot know about a nest. /// - /// Writing transform.position does not hold a Valheim Character - a Rigidbody and a - /// ZSyncTransform both overwrite it on the next frame, which is why the earlier leash did - /// nothing at all and the workers kept wandering off to die. A patrol point is the game's - /// own way of saying "this is where you live": the AI walks back on its own pathfinding. + /// Orders: none, from anyone. The brain never follows, but vanilla holds the tick during a + /// fight, and an Aswid's Dominate writes a follow target straight into it. /// - /// SetPatrolPoint takes no argument and posts the creature where it currently STANDS, so - /// it is put in place first. That raw write does not survive the frame, but it survives - /// long enough for this one call to read it - and the patrol point is what holds afterwards. + /// A home: a worker with nothing on its ZDO - hatched before the workers had this brain - + /// adopts the nearest nest, or it would stand where it is forever with an empty circle. + /// + /// Its size: re-measured every round, because the nest grows with its stage. /// private void KeepHome() { - if (m_ai == null || Time.time < m_nextHomeCheck) return; - m_nextHomeCheck = Time.time + 2f; + if (m_ai != null && m_ai.GetFollowTarget() != null) m_ai.SetFollowTarget(null); - if (m_ai.GetFollowTarget() != null) m_ai.SetFollowTarget(null); + if (m_smith == null) return; - if (Vector3.Distance(transform.position, Anchor.position) > SvermConfig.WorkerLeashRange) - { - transform.position = Anchor.position + Vector3.up * 0.5f; - } + Vector3? anchor = m_smith.Anchor; + SvermHiveBehaviour nest = anchor != null + ? SvermHive.NearestNest(anchor.Value, 1f) + : SvermHive.NearestNest(transform.position, AdoptRange); + if (nest == null) return; - m_ai.SetPatrolPoint(); + if (anchor == null) m_smith.Bind(nest.transform.position); + + float edge = SvermBrood.RingRadius(nest); + m_smith.m_homeDistance = edge; + m_smith.m_radiusBonus = edge; } /// diff --git a/README.md b/README.md index a3d9f22..2cea4f6 100644 --- a/README.md +++ b/README.md @@ -410,6 +410,18 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.15 +- **Fix - Bone Servants stopped working at every furnace, hearth and mead barrel after the 1.0 update:** Valheim 1.0 added an extra value to the calls that put an item into a station, and the servant was still sending the old ones. At a smelter, kiln, windmill or spinning wheel that threw an `EndOfStreamException` into the log on every tick and the Bone Smith stood in front of it holding its ore; the Bone Cook hit the same wall at hearths and ovens, and reading the cooking slots failed too. The mead barrel failed silently — 1.0 now identifies its contents by a number instead of a name, so the servant's "do you take this?" was answered no for every ingredient and barrels were never filled. All four are fixed; nothing a servant was carrying was lost, it simply could not put it down. +- **Fix - The Aswid blood brews lost their four-times fermentation speed:** the same 1.0 change to how a barrel records its contents meant the check for "is one of our blood bases in there?" read nothing for every barrel, so blood brews fermented at vanilla speed. They are back to four times as fast. +- **NEW - Race powers in the radial menu:** Valheim 1.0's radial menu (hold the right stick, or the keyboard's radial key) now has a group named after your race, with one entry for each of its forms and abilities — the Fenrir, Aswid and Skadi forms, the Trol's True Form, rock and log, the Trenta's three powers, the Dvergar runes, the Sverm Ravager and Grow Claws. Every controller button is already taken by vanilla in all four layouts, so this is how a gamepad player reaches them. An entry presses the key you already have bound, so unlocks, cooldowns, day/night rules and their messages behave exactly as they do from the keyboard, and a rebound key is followed automatically. +- **NEW - Skadi's Drake and Moder can fly with a gamepad:** the flight toggle and the flight controls only read the mouse and the keyboard, so a gamepad player could neither take off nor move once airborne. The Block button (the left trigger in the Classic layout) now takes off, lands, and cancels a landing, the left stick powers forward and back, the run button sprints, and the right stick steers the way the mouse does. The keyboard and mouse are unchanged. +- **CHANGED - Sverm Seeker Workers keep the forge:** the workers now have the Bone Smith's brain. Put the Bone Servant sigil in a chest within the work radius of the nest's edge and they carry ore and fuel from it to the smelters, kilns and mills around, then bring what comes out back to that chest. They still defend the nest — anything within 12 metres stops the work, the fight is left to the game's own combat, and they go back to what they were carrying afterwards — and they still mend what you built. The nest's hover now shows what each of its workers is doing, and the compendium page says all of this. +- **Fix - Sverm workers multiplied on every reload:** the nest only counted workers it had just hatched, so every worker that came back with the save was invisible to it and a fresh one hatched on top, two minutes at a time. Workers are counted from the moment they exist now. +- **Fix - Sverm workers hatched stuck inside the nest:** they were put down at the nest's own centre, inside several metres of collider. They now come out on the same ring outside the nest the troops use. +- **Fix - Sverm workers hit as hard as a full Seeker:** they were always meant to bite at half weight, and the code said so, but nothing ever halved the blow. It is halved now. +- **Fix - Sverm troops and Blister Ticks chased anything they could see:** they kept the vanilla creatures' unlimited alert range, so a garrison would run off after something across the valley and a tick would burst far from home. They now fight within 25 metres of the nest — or of you, while they follow you. +- **Fix - Summoned creatures that follow you picked fights as if they were still at home:** while a thrall followed you, the game kept judging every enemy by its distance from the station it came from, so the further you led it from home, the fewer fights it would take. It now judges them from you while it follows, and goes back to guarding its station when you let it go. Covers every summoned creature in the mod that can follow — the Draugh spawner's, the Dvergar bank's mercenaries, the Fenrir trough's pack and the Sverm troops. + ### v1.4.14 - **Fix - The Trol could not drink potions or meads:** the Trol's extra-stomach check caught every consumable, not just food, so a potion or a mead was refused whenever the extra stomachs were full — and when they had room, it skipped the potion's own cooldown instead. Only real food goes through the stomach check now; potions and meads are back on vanilla's rules. - **NEW - Transformed forms can attack with a gamepad:** form attacks read the mouse buttons directly, so a gamepad player had no way to attack in any of them. Each form attack now also answers the pad button vanilla pairs with the same mouse button — Attack for left click, Block for right click, Secondary Attack for middle click — following the pad layout picked in the game settings. Covers the Fenrir forms, Skadi's dragon forms and her Cold Spell, the Sverm Ravager and the Trenta Muspell. On Skadi the keyboard keys stay rebindable; the pad buttons are fixed. diff --git a/manifest.json b/manifest.json index 921c41a..e6bdf76 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.14", + "version_number": "1.4.15", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 8aa917cfcb9456d2b6352b20142260595f80cadd Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sun, 13 Sep 2026 11:33:47 +0200 Subject: [PATCH 029/273] chore(release): v1.4.16 - Trol True Form toggle past Fader, Gammeltroll thrown log Past Fader the Trol's True Form never expires (SE ttl 0) and the key toggles it off with no cooldown. The True Form log throw now fires one projectile read off the Gammeltroll's own weapons at runtime, hitting with the rock's damage formula, and falls back to the old physical log if none is found; 'dumpgammel' logs what was resolved. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RaceCompendium.cs | 2 +- JotunnModStub/RacesOfValheim.cs | 3 +- JotunnModStub/Trol/TrolConfig.cs | 2 +- JotunnModStub/Trol/TrolGammelLog.cs | 126 ++++++++++++++++++++++++ JotunnModStub/Trol/TrolRace.cs | 74 +++++++++----- JotunnModStub/Trol/TrolStatusEffects.cs | 4 +- README.md | 6 +- manifest.json | 2 +- 9 files changed, 192 insertions(+), 29 deletions(-) create mode 100644 JotunnModStub/Trol/TrolGammelLog.cs diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index e6bdf76..7d0605c 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.15", + "version_number": "1.4.16", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index b66c7ef..cb9eca4 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -376,7 +376,7 @@ namespace RacesOfValheim sb.AppendLine("The Queen Defeated: Unlocked Log Weapon (in True Form, interact with trees to wield them as weapons). True Form size is massively increased.\n"); if (state >= 8) - sb.AppendLine("Fader Defeated: Your wielded trees can now instantly smash through the toughest materials in the Ashlands.\n"); + sb.AppendLine("Fader Defeated: Your wielded trees can now instantly smash through the toughest materials in the Ashlands. True Form no longer runs out and has no cooldown - press the key again to return to your normal size.\n"); knownTexts["Trol Secrets"] = sb.ToString(); } diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index c44adc6..3872a0d 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.15"; + public const string PluginVersion = "1.4.16"; private readonly Harmony harmony = new Harmony(PluginGUID); @@ -73,6 +73,7 @@ namespace RacesOfValheim CommandManager.Instance.AddConsoleCommand(new ResetProgressionCommand()); CommandManager.Instance.AddConsoleCommand(new DumpDvergerCommand()); CommandManager.Instance.AddConsoleCommand(new DumpElderCommand()); + CommandManager.Instance.AddConsoleCommand(new DumpGammelCommand()); CommandManager.Instance.AddConsoleCommand(new FenrirPackSpawnCommand()); CommandManager.Instance.AddConsoleCommand(new DumpPotionsCommand()); CommandManager.Instance.AddConsoleCommand(new ListPrefabsCommand()); diff --git a/JotunnModStub/Trol/TrolConfig.cs b/JotunnModStub/Trol/TrolConfig.cs index ab70e87..ffca8af 100644 --- a/JotunnModStub/Trol/TrolConfig.cs +++ b/JotunnModStub/Trol/TrolConfig.cs @@ -111,7 +111,7 @@ namespace RacesOfValheim const string trueForm = "Trol - True Form"; TrueFormDuration = config.Bind(trueForm, "Duration", 60f, - new ConfigDescription("Seconds True Form lasts before automatically reverting.", new AcceptableValueRange(5f, 600f))); + new ConfigDescription("Seconds True Form lasts before automatically reverting. Ignored once Fader is defeated: the form then lasts until you press the key again.", new AcceptableValueRange(5f, 600f))); TrueFormCooldown = config.Bind(trueForm, "Cooldown", 600f, new ConfigDescription("Seconds between True Form activations.", new AcceptableValueRange(0f, 3600f))); TrueFormScaleNormal = config.Bind(trueForm, "Scale", 2.0f, diff --git a/JotunnModStub/Trol/TrolGammelLog.cs b/JotunnModStub/Trol/TrolGammelLog.cs new file mode 100644 index 0000000..68cbb16 --- /dev/null +++ b/JotunnModStub/Trol/TrolGammelLog.cs @@ -0,0 +1,126 @@ +using System.Collections.Generic; +using Jotunn.Entities; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The thrown log in True Form borrows ONE projectile from the Gammeltroll (Valheim 1.0), the + /// one it fires a whole rose of. The prefab names live in compressed asset bundles, so nothing + /// here is hard-coded past the monster itself: the projectile is read off the Gammeltroll's own + /// weapons at runtime, the same way Attack.Start would find it. Two shapes are handled: + /// - the rose is m_projectiles > 1 on the attack: the attack's projectile already IS one log; + /// - the rose is a single projectile that splits on hit (m_spawnOnHit with m_spawnCount > 1): + /// then the log is the child, and the parent would bring the whole rose along with it. + /// If none of that resolves, GetProjectile returns null and TrolRace falls back to the old + /// physical log. "dumpgammel" in the console logs what was actually found. + /// + public static class TrolGammelLog + { + private const string GammeltrollPrefab = "Gammeltroll"; + + private static GameObject cachedProjectile; + private static float cachedVelocity; + private static bool warned; + + public static GameObject GetProjectile(out float velocity) + { + if (cachedProjectile == null && ZNetScene.instance != null) + { + Resolve(out cachedProjectile, out cachedVelocity, null); + if (cachedProjectile == null && !warned) + { + warned = true; + Jotunn.Logger.LogWarning("[Trol] Gammeltroll log projectile not found - falling back to the physical log throw. Run 'dumpgammel' to see why."); + } + } + velocity = cachedVelocity > 0f ? cachedVelocity : TrolConfig.ThrowLogVelocity.Value; + return cachedProjectile; + } + + /// log is null for the silent path; the dump command passes a sink. + internal static void Resolve(out GameObject projectile, out float velocity, System.Action log) + { + projectile = null; + velocity = 0f; + + GameObject troll = FindGammeltroll(); + if (troll == null) { log?.Invoke("Gammeltroll prefab not found in ZNetScene."); return; } + log?.Invoke($"Monster prefab: '{troll.name}'"); + + Humanoid humanoid = troll.GetComponent(); + if (humanoid == null) { log?.Invoke(" no Humanoid on it."); return; } + + // Prefer the attack that fires several projectiles at once (the rose); any other + // projectile attack is only a fallback. + Attack best = null; + foreach (GameObject item in ItemsOf(humanoid)) + { + ItemDrop drop = item != null ? item.GetComponent() : null; + if (drop == null) continue; + var shared = drop.m_itemData.m_shared; + foreach (Attack attack in new[] { shared.m_attack, shared.m_secondaryAttack }) + { + if (attack == null) continue; + log?.Invoke($" item '{item.name}' anim='{attack.m_attackAnimation}' projectile='{(attack.m_attackProjectile != null ? attack.m_attackProjectile.name : "-")}' count={attack.m_projectiles} bursts={attack.m_projectileBursts} vel={attack.m_projectileVel} acc={attack.m_projectileAccuracy}"); + if (attack.m_attackProjectile == null) continue; + if (best == null || (attack.m_projectiles > 1 && best.m_projectiles <= 1)) best = attack; + } + } + if (best == null) { log?.Invoke(" no attack with a projectile."); return; } + + projectile = best.m_attackProjectile; + velocity = best.m_projectileVel; + + Projectile p = projectile.GetComponent(); + if (p != null) + { + log?.Invoke($" chosen '{projectile.name}': spawnOnHit='{(p.m_spawnOnHit != null ? p.m_spawnOnHit.name : "-")}' spawnCount={p.m_spawnCount} randomSpawns={(p.m_randomSpawnOnHit != null ? p.m_randomSpawnOnHit.Count : 0)} damage={p.m_damage.GetTotalDamage()}"); + if (p.m_spawnOnHit != null && p.m_spawnCount > 1 && p.m_spawnOnHit.GetComponent() != null) + { + projectile = p.m_spawnOnHit; + log?.Invoke($" it splits on hit - using the child '{projectile.name}' instead."); + } + } + log?.Invoke($"=> thrown log: '{projectile.name}', velocity {velocity}"); + } + + private static GameObject FindGammeltroll() + { + GameObject exact = ZNetScene.instance.GetPrefab(GammeltrollPrefab); + if (exact != null) return exact; + foreach (GameObject prefab in ZNetScene.instance.m_prefabs) + { + if (prefab != null && prefab.name.ToLowerInvariant().Contains("gammel") && prefab.GetComponent() != null) + return prefab; + } + return null; + } + + private static IEnumerable ItemsOf(Humanoid h) + { + if (h.m_defaultItems != null) foreach (var go in h.m_defaultItems) yield return go; + if (h.m_randomWeapon != null) foreach (var go in h.m_randomWeapon) yield return go; + if (h.m_randomSets != null) + foreach (var set in h.m_randomSets) + if (set.m_items != null) foreach (var go in set.m_items) yield return go; + if (h.m_randomItems != null) foreach (var ri in h.m_randomItems) yield return ri.m_prefab; + } + } + + public class DumpGammelCommand : ConsoleCommand + { + public override string Name => "dumpgammel"; + public override string Help => "[DEBUG] Logs the Gammeltroll's projectile attacks and which one the Trol throws as a log"; + + public override void Run(string[] args) + { + if (ZNetScene.instance == null) { Console.instance.Print("Load a world first."); return; } + TrolGammelLog.Resolve(out _, out _, line => + { + Jotunn.Logger.LogInfo("[dumpgammel] " + line); + Console.instance.Print(line); + }); + } + } +} diff --git a/JotunnModStub/Trol/TrolRace.cs b/JotunnModStub/Trol/TrolRace.cs index d565936..3016bca 100644 --- a/JotunnModStub/Trol/TrolRace.cs +++ b/JotunnModStub/Trol/TrolRace.cs @@ -202,6 +202,12 @@ namespace RacesOfValheim // Grabbing a log now has its own key (TrolConfig.GrabLogKey, see TryGrabLog) - // pressing True Form again while already transformed no longer tries to grab // whatever you happen to be looking at. + // Past Fader the form never runs out, so the key is a toggle instead: dropping + // the SE lets Update's auto-revert check shrink the Trol back. + if (BossProgressionManager.GetCurrentProgressionState() >= 8 && !isTransforming) + { + Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_TrolTrueForm".GetStableHashCode(), true); + } return; } @@ -288,7 +294,9 @@ namespace RacesOfValheim visual.transform.localScale = targetScale; } - Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_TrolTrueFormCooldown".GetStableHashCode(), true); + // No cooldown past Fader - reverting is a choice there, not the form running out. + if (BossProgressionManager.GetCurrentProgressionState() < 8) + Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_TrolTrueFormCooldown".GetStableHashCode(), true); isTransforming = false; } @@ -342,9 +350,24 @@ namespace RacesOfValheim if (isHoldingLog && !string.IsNullOrEmpty(logName)) { - // Spawn original log asset further away so it doesn't instantly collide with the player + // Spawn further away so it doesn't instantly collide with the player Vector3 logSpawnPos = Player.m_localPlayer.GetEyePoint() + Player.m_localPlayer.GetLookDir() * 3.5f; - GameObject originalLogPrefab = ZNetScene.instance.GetPrefab(logName); + + // One log out of the Gammeltroll's rose (see TrolGammelLog); the physical log + // below is only the fallback if that projectile can't be found. + GameObject gammelPrefab = TrolGammelLog.GetProjectile(out float gammelVelocity); + Projectile gammelProj = null; + if (gammelPrefab != null) + { + GameObject gammelInstance = UnityEngine.Object.Instantiate(gammelPrefab, logSpawnPos, Quaternion.LookRotation(Player.m_localPlayer.GetLookDir())); + gammelProj = gammelInstance.GetComponent(); + if (gammelProj != null) + gammelProj.Setup(Player.m_localPlayer, Player.m_localPlayer.GetLookDir() * gammelVelocity, -1f, BuildThrowHitData(isTrueForm), null, null); + else + ZNetScene.instance.Destroy(gammelInstance); + } + + GameObject originalLogPrefab = gammelProj == null ? ZNetScene.instance.GetPrefab(logName) : null; if (originalLogPrefab != null) { GameObject logInstance = UnityEngine.Object.Instantiate(originalLogPrefab, logSpawnPos, Quaternion.LookRotation(Player.m_localPlayer.GetLookDir())); @@ -373,29 +396,36 @@ namespace RacesOfValheim Projectile proj = projInstance.GetComponent(); if (proj != null) { - HitData hitData = new HitData(); - hitData.m_damage.m_blunt = TrolConfig.ThrowRockBaseDamage.Value; - - if (BossProgressionManager.GetCurrentProgressionState() >= 4) - { - hitData.m_damage.m_blunt += TrolConfig.ThrowRockBonemassBonus.Value; - } - if (BossProgressionManager.GetCurrentProgressionState() >= 6) - { - hitData.m_damage.m_blunt += TrolConfig.ThrowRockYagluthBonus.Value; - } - - if (isTrueForm) - { - hitData.m_damage.m_blunt += TrolConfig.ThrowRockTrueFormBonus.Value; - } - - hitData.SetAttacker(Player.m_localPlayer); - proj.Setup(Player.m_localPlayer, Player.m_localPlayer.GetLookDir() * TrolConfig.ThrowRockProjectileVelocity.Value, -1f, hitData, null, null); + proj.Setup(Player.m_localPlayer, Player.m_localPlayer.GetLookDir() * TrolConfig.ThrowRockProjectileVelocity.Value, -1f, BuildThrowHitData(isTrueForm), null, null); } } } } + + // Shared by the rock and the Gammeltroll log, so a thrown log hits as hard as a + // True Form rock rather than with whatever the monster's own weapon carries. + private static HitData BuildThrowHitData(bool isTrueForm) + { + HitData hitData = new HitData(); + hitData.m_damage.m_blunt = TrolConfig.ThrowRockBaseDamage.Value; + + if (BossProgressionManager.GetCurrentProgressionState() >= 4) + { + hitData.m_damage.m_blunt += TrolConfig.ThrowRockBonemassBonus.Value; + } + if (BossProgressionManager.GetCurrentProgressionState() >= 6) + { + hitData.m_damage.m_blunt += TrolConfig.ThrowRockYagluthBonus.Value; + } + + if (isTrueForm) + { + hitData.m_damage.m_blunt += TrolConfig.ThrowRockTrueFormBonus.Value; + } + + hitData.SetAttacker(Player.m_localPlayer); + return hitData; + } } public class LogImpactBreaker : MonoBehaviour diff --git a/JotunnModStub/Trol/TrolStatusEffects.cs b/JotunnModStub/Trol/TrolStatusEffects.cs index e5277f6..9c0c4dc 100644 --- a/JotunnModStub/Trol/TrolStatusEffects.cs +++ b/JotunnModStub/Trol/TrolStatusEffects.cs @@ -35,7 +35,9 @@ namespace RacesOfValheim name = "SE_TrolTrueForm"; m_name = "True Form"; m_tooltip = "You have unleashed your inner troll!"; - m_ttl = TrolConfig.TrueFormDuration.Value; + // Past Fader the form no longer runs out: m_ttl 0 is vanilla's "never expires", and + // the True Form key becomes the only way back (see TrolRace.TryTrueForm). + m_ttl = BossProgressionManager.GetCurrentProgressionState() >= 8 ? 0f : TrolConfig.TrueFormDuration.Value; GameObject itemPrefab = PrefabManager.Cache.GetPrefab("Stone"); if (itemPrefab != null) diff --git a/README.md b/README.md index 2cea4f6..c78db3e 100644 --- a/README.md +++ b/README.md @@ -268,7 +268,7 @@ Build a **Brood Mound** with the hammer — no more than two within its density - **Moder:** Unlock True Form. - **Yagluth:** +5% size, +50 carry, +5 club/unarmed/axes, +5 rock throw, unlocks 5th food slot. - **Queen:** Log Weapon (True Form): interact with trees to wield/throw. True Form is massive (2.5x size). -- **Fader:** Trees you wield instantly destroy any material in Ashlands. +- **Fader:** Trees you wield instantly destroy any material in Ashlands. True Form lasts forever and the key becomes a toggle (no cooldown).
@@ -410,6 +410,10 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.16 +- **CHANGED - The Trol's True Form no longer runs out after Fader:** once Fader is defeated the form lasts until you press the True Form key again, and there is no cooldown — reverting is a choice there, not the form running out. Before Fader nothing changes: it lasts `Duration` seconds and then the cooldown applies. The radial menu entry presses the same key, so it is a toggle from the gamepad too. A form already running when Fader falls keeps its old duration; the next one is permanent. +- **CHANGED - The Trol's thrown log is a Gammeltroll log:** in True Form the log you throw is now one of the projectiles the Gammeltroll (Valheim 1.0) fires in a rose, just one instead of the whole spread. It is read off the monster's own weapons at runtime rather than by a hard-coded name. It hits exactly as hard as a True Form rock, with the same `Throw Rock` bonuses from Bonemass and Yagluth, and it no longer breaks into wood. If the projectile can't be found, the old physical log is thrown instead and a warning goes to the log. `dumpgammel` in the console shows what was found. + ### v1.4.15 - **Fix - Bone Servants stopped working at every furnace, hearth and mead barrel after the 1.0 update:** Valheim 1.0 added an extra value to the calls that put an item into a station, and the servant was still sending the old ones. At a smelter, kiln, windmill or spinning wheel that threw an `EndOfStreamException` into the log on every tick and the Bone Smith stood in front of it holding its ore; the Bone Cook hit the same wall at hearths and ovens, and reading the cooking slots failed too. The mead barrel failed silently — 1.0 now identifies its contents by a number instead of a name, so the servant's "do you take this?" was answered no for every ingredient and barrels were never filled. All four are fixed; nothing a servant was carrying was lost, it simply could not put it down. - **Fix - The Aswid blood brews lost their four-times fermentation speed:** the same 1.0 change to how a barrel records its contents meant the check for "is one of our blood bases in there?" read nothing for every barrel, so blood brews fermented at vanilla speed. They are back to four times as fast. diff --git a/manifest.json b/manifest.json index e6bdf76..7d0605c 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.15", + "version_number": "1.4.16", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From c7cbd6bece39acd153c22e9edefbc123ea161377 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 18 Sep 2026 17:10:24 +0200 Subject: [PATCH 030/273] chore(release): v1.4.18 - Valheim hotfix flight fix, 1.0 shop fixes, Fenrir speed Drake flight resolves ZInput.GetJoyLeftStickY at runtime, since the hotfix dropped its bool parameter. Faction merchant TradeItems now set the 1.0 fields StoreGui dereferences (m_tooltip, m_buyPlayerEffects), and the Dvergar trader discount clones the whole TradeItem instead of rebuilding four fields. Trol totem refusals return true so vanilla's $msg_cantuseon no longer covers them. The Fenrir curse speed modifier is the bonus alone (SE_Stats adds it), not 1 + bonus. New Discord link. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Dvergar/DvergarPatches.cs | 16 +++++++++------- .../Factions/FactionMerchantSetup.cs | 8 ++++++++ JotunnModStub/Fenrir/FenrirStatusEffects.cs | 4 +++- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RacesOfValheim.cs | 2 +- JotunnModStub/Skadi/SkadiPatches.cs | 19 ++++++++++++++++++- JotunnModStub/Trol/TrolTotemBehaviour.cs | 12 ++++++++---- README.md | 11 ++++++++++- manifest.json | 2 +- 9 files changed, 59 insertions(+), 17 deletions(-) diff --git a/JotunnModStub/Dvergar/DvergarPatches.cs b/JotunnModStub/Dvergar/DvergarPatches.cs index 430ff2d..6de3f31 100644 --- a/JotunnModStub/Dvergar/DvergarPatches.cs +++ b/JotunnModStub/Dvergar/DvergarPatches.cs @@ -281,17 +281,19 @@ namespace RacesOfValheim { if (item == null) continue; - discounted.Add(new Trader.TradeItem - { - m_prefab = item.m_prefab, - m_stack = item.m_stack, - m_price = Mathf.Max(1, Mathf.RoundToInt(item.m_price * (1f - discount))), - m_requiredGlobalKey = item.m_requiredGlobalKey - }); + // A full copy, not a hand-picked one: Valheim 1.0 hangs name, tooltip, icon, + // buy/increment keys and buy effects off TradeItem, and StoreGui reads some + // of them without null checks. Only the price is ours to change. + var copy = (Trader.TradeItem)MemberwiseCloneMethod.Invoke(item, null); + copy.m_price = Mathf.Max(1, Mathf.RoundToInt(item.m_price * (1f - discount))); + discounted.Add(copy); } __result = discounted; } + + private static readonly System.Reflection.MethodInfo MemberwiseCloneMethod = + AccessTools.Method(typeof(object), "MemberwiseClone"); } /// diff --git a/JotunnModStub/Factions/FactionMerchantSetup.cs b/JotunnModStub/Factions/FactionMerchantSetup.cs index cab0e4b..abe283a 100644 --- a/JotunnModStub/Factions/FactionMerchantSetup.cs +++ b/JotunnModStub/Factions/FactionMerchantSetup.cs @@ -52,6 +52,14 @@ namespace RacesOfValheim m_prefab = itemDrop, m_stack = 1, m_price = entry.Price, + // Valheim 1.0 fields that StoreGui dereferences without a null check: + // FillList reads m_tooltip.Length, BuySelectedItem calls + // m_buyPlayerEffects.Create. Empty means "use the item's own". + m_name = string.Empty, + m_tooltip = string.Empty, + m_buyKey = string.Empty, + m_incrementKey = string.Empty, + m_buyPlayerEffects = new EffectList(), }); } diff --git a/JotunnModStub/Fenrir/FenrirStatusEffects.cs b/JotunnModStub/Fenrir/FenrirStatusEffects.cs index eab5005..b519103 100644 --- a/JotunnModStub/Fenrir/FenrirStatusEffects.cs +++ b/JotunnModStub/Fenrir/FenrirStatusEffects.cs @@ -39,7 +39,9 @@ namespace RacesOfValheim int state = BossProgressionManager.GetCurrentProgressionState(); m_fallDamageModifier = FenrirProgression.GetFallDamageModifier(state); - m_speedModifier = 1.0f + FenrirProgression.GetSpeedModifier(state); + // SE_Stats.ModifySpeed adds baseSpeed * m_speedModifier, so this is the bonus alone: + // 0 is vanilla speed, 0.03 is +3%. A leading 1.0f here was a flat +100%. + m_speedModifier = FenrirProgression.GetSpeedModifier(state); m_jumpModifier = new Vector3(0, FenrirProgression.GetJumpModifier(state), 0); } } diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 7d0605c..fe12525 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.16", + "version_number": "1.4.18", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 3872a0d..2cf0c9f 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.16"; + public const string PluginVersion = "1.4.18"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 482dad4..6db166c 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -314,6 +314,23 @@ namespace RacesOfValheim /// public static bool Reversing { get; private set; } + // The September 2026 hotfix dropped the bool parameter from ZInput.GetJoyLeftStickY. + // A direct call binds to whichever signature we compiled against and throws + // MissingMethodException on the other, so resolve it at runtime and accept either. + private static readonly MethodInfo JoyLeftStickYMethod = + AccessTools.Method(typeof(ZInput), "GetJoyLeftStickY", new System.Type[0]) ?? + AccessTools.Method(typeof(ZInput), "GetJoyLeftStickY", new[] { typeof(bool) }); + + private static float JoyLeftStickY() + { + if (JoyLeftStickYMethod == null) return 0f; + return (float)JoyLeftStickYMethod.Invoke(null, JoyLeftStickYArgs); + } + + // Old signature: pass smooth = true, which was its default. + private static readonly object[] JoyLeftStickYArgs = + JoyLeftStickYMethod != null && JoyLeftStickYMethod.GetParameters().Length == 1 ? new object[] { true } : null; + public static void Prefix(Character __instance, float dt) { if (__instance != Player.m_localPlayer) return; @@ -332,7 +349,7 @@ namespace RacesOfValheim // PlayerController.FixedUpdate takes forward as the NEGATED GetJoyLeftStickY. // Flight only knows powered forward, reverse or neither, so the stick is a // threshold, not a throttle. Steering stays on the camera, i.e. the right stick. - float stick = -ZInput.GetJoyLeftStickY(); + float stick = -JoyLeftStickY(); bool forward = input && (Input.GetKey(KeyCode.W) || stick > StickThreshold); // Forward wins a W+S mash rather than the two cancelling into a dead hover. bool backward = input && !forward && (Input.GetKey(KeyCode.S) || stick < -StickThreshold); diff --git a/JotunnModStub/Trol/TrolTotemBehaviour.cs b/JotunnModStub/Trol/TrolTotemBehaviour.cs index c3ab254..4543646 100644 --- a/JotunnModStub/Trol/TrolTotemBehaviour.cs +++ b/JotunnModStub/Trol/TrolTotemBehaviour.cs @@ -71,7 +71,9 @@ namespace RacesOfValheim if (!TrolRace.IsTrol()) { player.Message(MessageHud.MessageType.Center, "The head will not shout for you."); - return false; + // With an item in hand, false makes Humanoid.UseItem cover this message with its + // generic "$msg_cantuseon"; true tells it the use was handled here. + return item != null; } // Yagluth's drop in hand upgrades it: a new head, and two more warbands on the list. @@ -83,24 +85,26 @@ namespace RacesOfValheim if (item != null) { player.Message(MessageHud.MessageType.Center, "$msg_wontwork"); - return false; + return true; } return OpenStore(player); } + // Every refusal still returns true: this only runs from an item use, where false would + // make Humanoid.UseItem replace our message with the generic "$msg_cantuseon". private bool TryUpgrade(Player player, ItemDrop.ItemData item) { if (IsUpgraded()) { player.Message(MessageHud.MessageType.Center, "It has already had one."); - return false; + return true; } if (BossProgressionManager.GetCurrentProgressionState() < TrolTotem.UpgradeProgressionState) { player.Message(MessageHud.MessageType.Center, "Not until the one it belonged to has fallen."); - return false; + return true; } player.GetInventory().RemoveItem(item, 1); diff --git a/README.md b/README.md index c78db3e..56c3a61 100644 --- a/README.md +++ b/README.md @@ -7,7 +7,7 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing ## Development & Feedback This is a stable release, but more races and refinements are planned! -Bug reports, feedback, ideas: [https://discord.gg/gbBEK2VTE](https://discord.gg/gbBEK2VTE) +Bug reports, feedback, ideas: [https://discord.gg/jJzuKBZNC](https://discord.gg/jJzuKBZNC) Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorTheModder) --- @@ -410,6 +410,15 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.18 +- **Fix - Drake flight stopped working after the latest Valheim hotfix:** the hotfix changed how the game reads the gamepad's left stick, and the drake's flight still asked for it the old way. Every frame in the air threw a `MissingMethodException` into the log and the drake could not fly. Flight now works on both the new and the old version of the game. +- **Fix - Faction merchants would not open their shop:** Valheim 1.0 added a name, tooltip, buy effects and unlock keys to every shop item, and the shop window reads some of them without checking they are there. The merchants' goods were missing them, so pressing E threw a `NullReferenceException` and nothing opened. Buying is covered too — it would have hit the same wall on the buy effects. Thanks to the tester who tracked this down. +- **Fix - Haldor and Hildir's Dvergar discount broke their shops:** the discounted copies of their goods were rebuilt with only the old fields, so a Dvergar hit the same shop error, and items that unlock something when bought (like Haldor's extra inventory row) lost what they unlock. The discount now copies the whole item and changes only the price. +- **Fix - The Trol totem's own messages were replaced by "Can't use X on Y":** using Yagluth's drop on a totem that already has one, or before Yagluth has fallen, or using any other item on it, now shows the totem's message instead of the generic one. Thanks to the tester who spotted it. +- **Fix - The Fenrir was 100% faster than intended:** the curse's speed bonus was applied as a multiplier on top of normal speed instead of as a bonus, so every Fenrir moved at double speed plus the bonus (103% faster after one boss instead of 3%). It is now the +3% per boss the race has always listed. +- **Changed - New Discord link:** [https://discord.gg/jJzuKBZNC](https://discord.gg/jJzuKBZNC). +- 1.4.17 was 1.4.16 republished on Thunderstore with only the version number changed; there is no separate 1.4.17 changelog. + ### v1.4.16 - **CHANGED - The Trol's True Form no longer runs out after Fader:** once Fader is defeated the form lasts until you press the True Form key again, and there is no cooldown — reverting is a choice there, not the form running out. Before Fader nothing changes: it lasts `Duration` seconds and then the cooldown applies. The radial menu entry presses the same key, so it is a toggle from the gamepad too. A form already running when Fader falls keeps its old duration; the next one is permanent. - **CHANGED - The Trol's thrown log is a Gammeltroll log:** in True Form the log you throw is now one of the projectiles the Gammeltroll (Valheim 1.0) fires in a rose, just one instead of the whole spread. It is read off the monster's own weapons at runtime rather than by a hard-coded name. It hits exactly as hard as a True Form rock, with the same `Throw Rock` bonuses from Bonemass and Yagluth, and it no longer breaks into wood. If the projectile can't be found, the old physical log is thrown instead and a warning goes to the log. `dumpgammel` in the console shows what was found. diff --git a/manifest.json b/manifest.json index 7d0605c..fe12525 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.16", + "version_number": "1.4.18", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 5f74c57e72718ef3a3682eca4a2a43c3a80fdf7c Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 18 Sep 2026 17:13:16 +0200 Subject: [PATCH 031/273] fix: race buildings keep their own message when an item is used on them Humanoid.UseItem shows the generic $msg_cantuseon whenever the interactable's UseItem returns false, covering the refusal message the building had just shown. Same fix as the Trol totem in v1.4.18, applied to the Servant table, Dvergar barrel and bank, Fenrir trough, Draugr and Skeleton piles, Blood Refinery, Grove and Composter: an item in hand always counts as handled. Empty-handed interactions are unchanged. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Aswid/BloodRefineryBehaviour.cs | 6 ++++-- JotunnModStub/Butler/ServantTableBehaviour.cs | 3 ++- JotunnModStub/Draugh/DraughSpawnerBehaviour.cs | 7 +++++++ JotunnModStub/Dvergar/DvergarBancoBehaviour.cs | 12 ++++++++---- JotunnModStub/Dvergar/DvergarBotteBehaviour.cs | 7 +++++-- JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs | 7 +++++++ JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs | 7 +++++++ JotunnModStub/Trenta/ComposterBehaviour.cs | 7 +++++++ JotunnModStub/Trenta/GroveBehaviour.cs | 7 +++++++ README.md | 1 + 10 files changed, 55 insertions(+), 9 deletions(-) diff --git a/JotunnModStub/Aswid/BloodRefineryBehaviour.cs b/JotunnModStub/Aswid/BloodRefineryBehaviour.cs index f64e983..d06b47b 100644 --- a/JotunnModStub/Aswid/BloodRefineryBehaviour.cs +++ b/JotunnModStub/Aswid/BloodRefineryBehaviour.cs @@ -79,14 +79,16 @@ namespace RacesOfValheim private bool OnAddMeat(Switch caller, Humanoid user, ItemDrop.ItemData item) { - return TryAdd(user, item, isMeat: true); + return TryAdd(user, item, isMeat: true) || item != null; } private bool OnAddBone(Switch caller, Humanoid user, ItemDrop.ItemData item) { - return TryAdd(user, item, isMeat: false); + return TryAdd(user, item, isMeat: false) || item != null; } + // Both switches treat an item in hand as handled whatever TryAdd says: false makes + // Humanoid.UseItem cover our own message with the generic "$msg_cantuseon". private bool TryAdd(Humanoid user, ItemDrop.ItemData item, bool isMeat) { if (user == null) return false; diff --git a/JotunnModStub/Butler/ServantTableBehaviour.cs b/JotunnModStub/Butler/ServantTableBehaviour.cs index 4d70f81..6aab038 100644 --- a/JotunnModStub/Butler/ServantTableBehaviour.cs +++ b/JotunnModStub/Butler/ServantTableBehaviour.cs @@ -64,7 +64,8 @@ namespace RacesOfValheim if (item != null) { player.Message(MessageHud.MessageType.Center, "$msg_wontwork"); - return false; + // True, not false: false makes Humanoid.UseItem cover the message with $msg_cantuseon. + return true; } if (Servant() != null) diff --git a/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs b/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs index 98c760d..faf40ee 100644 --- a/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs +++ b/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs @@ -65,7 +65,14 @@ namespace RacesOfValheim /// Raw flesh feeds it, a Draugr trophy is a whole batch, an Elite trophy is an officer, and a /// Greater Cursed Bone upgrades it. Empty hands just report. ///
+ // With an item in hand every outcome counts as handled, refusals included: false makes + // Humanoid.UseItem cover our own message with the generic "$msg_cantuseon". private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + return Use(user, item) || item != null; + } + + private bool Use(Humanoid user, ItemDrop.ItemData item) { if (user == null) return false; diff --git a/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs b/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs index dbbfa6e..a0646a7 100644 --- a/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs +++ b/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs @@ -67,7 +67,9 @@ namespace RacesOfValheim if (!DvergarRace.IsDvergar()) { player.Message(MessageHud.MessageType.Center, "The ledger is not written for you."); - return false; + // With an item in hand, false makes Humanoid.UseItem cover this message with its + // generic "$msg_cantuseon"; true tells it the use was handled here. + return item != null; } // The Queen's drop in hand rewrites the ledger: coin on the table, and two more crews. @@ -79,24 +81,26 @@ namespace RacesOfValheim if (item != null) { player.Message(MessageHud.MessageType.Center, "$msg_wontwork"); - return false; + return true; } return OpenStore(player); } + // Every refusal still returns true: this only runs from an item use, where false would + // make Humanoid.UseItem replace our message with the generic "$msg_cantuseon". private bool TryUpgrade(Player player, ItemDrop.ItemData item) { if (IsUpgraded()) { player.Message(MessageHud.MessageType.Center, "It has already had one."); - return false; + return true; } if (BossProgressionManager.GetCurrentProgressionState() < DvergarBanco.UpgradeProgressionState) { player.Message(MessageHud.MessageType.Center, "Not while she still sits under the mist."); - return false; + return true; } player.GetInventory().RemoveItem(item, 1); diff --git a/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs b/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs index 829f94f..84b810c 100644 --- a/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs +++ b/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs @@ -63,9 +63,12 @@ namespace RacesOfValheim if (!DvergarBotte.IsBrew(prefabName)) { player.Message(MessageHud.MessageType.Center, "$msg_wontwork"); - return false; + return true; } - return Fill(player, inventory, item, prefabName); + // Always true from an item use, refusals included: false makes Humanoid.UseItem + // cover Fill's own message with the generic $msg_cantuseon. + Fill(player, inventory, item, prefabName); + return true; } // Bare hands: pour a round if there is one, otherwise go looking for something to pour. diff --git a/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs b/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs index 0929e64..a7e2bfb 100644 --- a/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs +++ b/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs @@ -272,7 +272,14 @@ namespace RacesOfValheim // ---------------------------------------------------------------- interaction + // With an item in hand every outcome counts as handled, refusals included: false makes + // Humanoid.UseItem cover our own message with the generic "$msg_cantuseon". private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + return Use(user, item) || item != null; + } + + private bool Use(Humanoid user, ItemDrop.ItemData item) { if (user == null) return false; diff --git a/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs b/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs index 83c6046..002e2a4 100644 --- a/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs +++ b/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs @@ -68,7 +68,14 @@ namespace RacesOfValheim /// Empty hands were free to use for this because the pile's own hover already carries the /// status the Draugh needs an empty-handed click to report. ///
+ // With an item in hand every outcome counts as handled, refusals included: false makes + // Humanoid.UseItem cover our own message with the generic "$msg_cantuseon". private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + return Use(user, item) || item != null; + } + + private bool Use(Humanoid user, ItemDrop.ItemData item) { Player player = user as Player; if (player == null) return false; diff --git a/JotunnModStub/Trenta/ComposterBehaviour.cs b/JotunnModStub/Trenta/ComposterBehaviour.cs index f59dbe8..4dd7524 100644 --- a/JotunnModStub/Trenta/ComposterBehaviour.cs +++ b/JotunnModStub/Trenta/ComposterBehaviour.cs @@ -77,7 +77,14 @@ namespace RacesOfValheim /// click means. Holding flesh feeds it; empty hands tap it when it is ready and otherwise /// just report what it is doing. /// + // With an item in hand every outcome counts as handled, refusals included: false makes + // Humanoid.UseItem cover our own message with the generic "$msg_cantuseon". private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + return Use(user, item) || item != null; + } + + private bool Use(Humanoid user, ItemDrop.ItemData item) { if (user == null) return false; diff --git a/JotunnModStub/Trenta/GroveBehaviour.cs b/JotunnModStub/Trenta/GroveBehaviour.cs index 39388e4..0d0fde3 100644 --- a/JotunnModStub/Trenta/GroveBehaviour.cs +++ b/JotunnModStub/Trenta/GroveBehaviour.cs @@ -257,7 +257,14 @@ namespace RacesOfValheim /// doing. Loading a tank before the tree has grown is allowed on purpose - there is no reason /// to make the player come back twice. /// + // With an item in hand every outcome counts as handled, refusals included: false makes + // Humanoid.UseItem cover our own message with the generic "$msg_cantuseon". private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + return Use(user, item) || item != null; + } + + private bool Use(Humanoid user, ItemDrop.ItemData item) { if (user == null) return false; diff --git a/README.md b/README.md index 56c3a61..11e2bba 100644 --- a/README.md +++ b/README.md @@ -415,6 +415,7 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact - **Fix - Faction merchants would not open their shop:** Valheim 1.0 added a name, tooltip, buy effects and unlock keys to every shop item, and the shop window reads some of them without checking they are there. The merchants' goods were missing them, so pressing E threw a `NullReferenceException` and nothing opened. Buying is covered too — it would have hit the same wall on the buy effects. Thanks to the tester who tracked this down. - **Fix - Haldor and Hildir's Dvergar discount broke their shops:** the discounted copies of their goods were rebuilt with only the old fields, so a Dvergar hit the same shop error, and items that unlock something when bought (like Haldor's extra inventory row) lost what they unlock. The discount now copies the whole item and changes only the price. - **Fix - The Trol totem's own messages were replaced by "Can't use X on Y":** using Yagluth's drop on a totem that already has one, or before Yagluth has fallen, or using any other item on it, now shows the totem's message instead of the generic one. Thanks to the tester who spotted it. +- **Fix - The same "Can't use X on Y" was covering the messages of nine other race buildings:** using an item on the Bone Servant table, the Dvergar barrel and contract bank, the Fenrir trough, the Draugr and Skeleton piles, the Aswid Blood Refinery, the Trenta Grove and Composter now shows their own answer — "It's full", "It has already had one.", "Still rotting.", the boss gates and the rest — instead of the generic one. - **Fix - The Fenrir was 100% faster than intended:** the curse's speed bonus was applied as a multiplier on top of normal speed instead of as a bonus, so every Fenrir moved at double speed plus the bonus (103% faster after one boss instead of 3%). It is now the +3% per boss the race has always listed. - **Changed - New Discord link:** [https://discord.gg/jJzuKBZNC](https://discord.gg/jJzuKBZNC). - 1.4.17 was 1.4.16 republished on Thunderstore with only the version number changed; there is no separate 1.4.17 changelog. From 834d6647fd676cb96e42b1efc192a06a6a33aad9 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sun, 20 Sep 2026 08:26:22 +0200 Subject: [PATCH 032/273] chore(release): v1.4.19 - eye height, remote forms, food refresh, faction retaliation Race body scale moved the model and not the camera: Character.m_eye hangs off the unscaled root, so a Trol or a Dvergar changed height for everyone but themselves. RaceEyeHeight moves the eye by whatever scale the Visual is wearing, for every player, so aim rays follow too. Remote copies of a Fenrir form had no one writing to their Animator and stood in the controller's default state, sliding. RemoteFenrirAnimator mirrors the four local behaviours off the player's own replicated animator, the way RemoteSkadiAnimator already did for Skadi. Player.Food.m_time is time remaining, not time elapsed: the Aswid, Trenta and Draugh repeat-meal branches all set it to 0 and expired the slot they meant to renew, and left the nutrition values stale. RaceFoodRefresh does what vanilla's own branch does, in one place instead of three. The Trenta prefix now reports __result, or a working refresh would have renewed the slot without consuming the seed. Aswid devour was gated by one timestamp shared by every corpse, so a pack killed at once fed the player once; it is now per corpse, floored at a second, and a refused meal says $msg_nomore. MonsterAI.UpdateTarget discards any target IsEnemy refuses, so a truced mob could not retaliate at all - it stood still or fled. RaceGrudge records the hit on the AI owner's client and both truce postfixes stand down for that pair. The Aswid drain and the Skadi frost aura now skip kin, as the Skeleton's fire aura already did, or an always-on aura would hold every truce permanently broken. Faction sets matched exact prefab names with families half-listed: added Skeleton_NoArcher and Draugr_Ranged to the Swamp, Greyling to the Black Forest. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Aswid/AswidConfig.cs | 2 +- JotunnModStub/Aswid/AswidPatches.cs | 16 +-- JotunnModStub/Aswid/AswidRace.cs | 87 ++++++++++-- JotunnModStub/Draugh/DraughFoodPatches.cs | 16 +-- .../Factions/FactionHostilityPatch.cs | 29 +++- JotunnModStub/Factions/FactionsConfig.cs | 16 ++- JotunnModStub/Fenrir/FenrirBehaviors.cs | 62 +++++++++ JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RaceEyeHeight.cs | 93 +++++++++++++ JotunnModStub/RaceFoodRefresh.cs | 63 +++++++++ JotunnModStub/RaceGrudge.cs | 127 ++++++++++++++++++ JotunnModStub/RaceHostilityManager.cs | 11 +- JotunnModStub/RacesOfValheim.cs | 2 +- JotunnModStub/Skadi/SkadiRace.cs | 5 + JotunnModStub/Trenta/TrentaFoodPatches.cs | 29 ++-- JotunnModStub/ZdoVisualSync.cs | 7 + README.md | 10 ++ manifest.json | 2 +- 18 files changed, 524 insertions(+), 55 deletions(-) create mode 100644 JotunnModStub/RaceEyeHeight.cs create mode 100644 JotunnModStub/RaceFoodRefresh.cs create mode 100644 JotunnModStub/RaceGrudge.cs diff --git a/JotunnModStub/Aswid/AswidConfig.cs b/JotunnModStub/Aswid/AswidConfig.cs index 498f63e..da24f9d 100644 --- a/JotunnModStub/Aswid/AswidConfig.cs +++ b/JotunnModStub/Aswid/AswidConfig.cs @@ -172,7 +172,7 @@ namespace RacesOfValheim const string devour = "Aswid - Devour"; DevourCooldown = config.Bind(devour, "Consume Cooldown", 5f, - new ConfigDescription("Minimum seconds between devouring a corpse, outside of an execute (which bypasses this).", new AcceptableValueRange(0f, 60f))); + new ConfigDescription("How long one body stays drunk-dry, in seconds. A single death is reported to the devour more than once - by two damage patches, by the aura's execute, by a thrall's kill - and this is the window that keeps those from feeding you twice off the same corpse. It is per body, not per player: killing a whole pack at once devours every one of them. One second is used as the floor, so no corpse feeds you twice even at 0.", new AcceptableValueRange(0f, 60f))); const string domination = "Aswid - Domination"; EnslaveCooldown = config.Bind(domination, "Enslave Cooldown", 900f, diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 5375aad..400e4a4 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -383,17 +383,11 @@ namespace RacesOfValheim Player.Food f = foodObj as Player.Food; if (f != null && f.m_item.m_shared.m_name == item.m_shared.m_name && f.CanEatAgain()) { - f.m_time = 0f; - f.m_item = item; - - var consumeEffects = HarmonyLib.Traverse.Create(__instance).Field("m_consumeItemEffects").GetValue(); - if (consumeEffects != null) consumeEffects.Create(__instance.transform.position, Quaternion.identity, __instance.transform, 1f, -1); - - var zanim = HarmonyLib.Traverse.Create(__instance).Field("m_zanim").GetValue(); - if (zanim != null) zanim.SetTrigger("eat"); - - if (item.m_shared.m_food > 0f) __instance.Heal(item.m_shared.m_food, true); - + // Was `f.m_time = 0f`, which expired the meal instead of renewing + // it - see RaceFoodRefresh for the whole story. The fourth slot + // above genuinely does count up from zero; this list does not. + RaceFoodRefresh.Refresh(__instance, f, item); + refreshed = true; break; } diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 4fe1d7e..3078f06 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -949,6 +949,20 @@ namespace RacesOfValheim continue; } + // The truce holds here too, or it holds nowhere. This aura is always on + // and asks nothing of the player, so before RaceGrudge it quietly drained + // and executed the race's own kin while they stood there and took it; + // after RaceGrudge that same drain would have kept every leech, draugr and + // blob in the swamp permanently angry at an Aswid who never raised a hand. + // Asking BaseAI.IsEnemy is what the Skeleton's fire aura already does, and + // it is the one question both truce patches answer, so the aura now agrees + // with everything else by construction. The execute is untouched: it still + // fires, on anything the Aswid is actually at war with. + if (!c.IsPlayer() && !BaseAI.IsEnemy(Player.m_localPlayer, c)) + { + continue; + } + float maxHp = c.GetMaxHealth(); float currentHp = c.GetHealth(); @@ -960,7 +974,7 @@ namespace RacesOfValheim if (currentHp > 0 && currentHp <= maxHp * AswidConfig.AuraExecuteThreshold.Value && !c.IsBoss()) { totalDamage = currentHp * 2f; // Lethal damage for execute - TryConsumeMob(c, maxHp, true); // Automatically devour when executed, bypassing cooldown + TryConsumeMob(c, maxHp); // Automatically devour when executed } HitData hd = new HitData(); @@ -987,17 +1001,40 @@ namespace RacesOfValheim public static bool DevourEnabled = true; public static bool AuraEnabled = true; - private static float lastConsumeTime = 0f; - public static void TryConsumeMob(Character c, float maxHp, bool bypassCooldown = false) + /// + /// When each corpse was last drunk from, so one body is never devoured twice. + /// + /// This used to be a single timestamp shared by every corpse in the world, which is what + /// testers hit as "killing with the claws or the aura sometimes adds nothing at all": + /// clear a pack with one blast and the first body ate the cooldown for all of them, the + /// rest dying unnoticed inside the window. The guard was never about pacing kills - it is + /// there because a single death reaches TryConsumeMob from more than one place (two + /// Character.Damage postfixes, the aura's own execute, a thrall's kill), and without it + /// one corpse could feed the player twice. Keyed per corpse it does that job exactly and + /// stops taxing the kills that follow. + /// + private static readonly Dictionary lastConsumedCorpse = new Dictionary(); + private static float lastCorpseSweep = 0f; + + public static void TryConsumeMob(Character c, float maxHp) { if (!DevourEnabled) return; + if (c == null) return; - if (!bypassCooldown && Time.time - lastConsumeTime < AswidConfig.DevourCooldown.Value) + // The window is the config's own "Consume Cooldown", scoped to the body it is about. + // Floored at a second even when that is set to zero: the paths that report one death + // all arrive within the same frame or two, and letting a corpse feed the player twice + // is a bug rather than a setting. + float window = Mathf.Max(AswidConfig.DevourCooldown != null ? AswidConfig.DevourCooldown.Value : 5f, 1f); + ZDOID corpse = c.GetZDOID(); + if (lastConsumedCorpse.TryGetValue(corpse, out float drunkAt) && Time.time - drunkAt < window) { - return; // Cooldown active + return; // This body has already been drunk from. } + SweepConsumedCorpses(window); + string cleanName = c.name.Replace("(Clone)", "").Trim(); string customFoodName = "AswidFood_" + cleanName; @@ -1012,6 +1049,11 @@ namespace RacesOfValheim // Fallback to RawMeat if no specific custom item was generated (e.g. mob not in trophy map) if (foodPrefab == null) { + // Logged rather than shown: a creature with no blood food of its own is a whole + // category, not an event, and a message on every such kill would be noise. It is + // here at all because from the player's chair this looks exactly like a devour + // that failed, and the log is the only way to tell the two apart. + Jotunn.Logger.LogDebug($"[Aswid] '{cleanName}' has no '{customFoodName}' to drink - not edible."); return; // Mob is not edible } @@ -1030,7 +1072,7 @@ namespace RacesOfValheim if (addedItem != null) { - lastConsumeTime = Time.time; + lastConsumedCorpse[corpse] = Time.time; // UseItem natively plays animation and consumes it. // If stomach is full, EatFood fails, UseItem does not consume the item, and virtualInv is destroyed (disintegrated) @@ -1047,8 +1089,15 @@ namespace RacesOfValheim // Vae Victis XP logic - similar to Dead Raiser Player.m_localPlayer.RaiseSkill(Skills.SkillType.BloodMagic, 1f); } - // If it was not eaten the stomach was full: the item disintegrates with - // the virtual inventory, so there is nothing to clean up. + else + { + // The stomach was full and had nothing worth refreshing, so the food + // disintegrates with the virtual inventory - there is nothing to clean + // up, but there used to be nothing to see either. Silence is what made + // a refused meal indistinguishable from a devour that never fired: + // vanilla's own "can't eat more" line, localized for free. + Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "$msg_nomore"); + } } else { @@ -1058,6 +1107,28 @@ namespace RacesOfValheim } } + /// + /// Drops corpses the window has passed, so a long session does not carry a growing list of + /// bodies nobody will ever drink from again. Once every window at most - this runs off + /// kills, and a pack dying together should not walk the list once per body. + /// + private static void SweepConsumedCorpses(float window) + { + if (Time.time - lastCorpseSweep < window) return; + lastCorpseSweep = Time.time; + if (lastConsumedCorpse.Count == 0) return; + + List stale = null; + foreach (var entry in lastConsumedCorpse) + { + if (Time.time - entry.Value < window) continue; + if (stale == null) stale = new List(); + stale.Add(entry.Key); + } + if (stale == null) return; + foreach (ZDOID id in stale) lastConsumedCorpse.Remove(id); + } + private static void SpawnBloodVFX(Character target) { try diff --git a/JotunnModStub/Draugh/DraughFoodPatches.cs b/JotunnModStub/Draugh/DraughFoodPatches.cs index 7e2e1af..847a615 100644 --- a/JotunnModStub/Draugh/DraughFoodPatches.cs +++ b/JotunnModStub/Draugh/DraughFoodPatches.cs @@ -134,17 +134,11 @@ namespace RacesOfValheim Player.Food f = foodObj as Player.Food; if (f != null && f.m_item.m_shared.m_name == item.m_shared.m_name && f.CanEatAgain()) { - f.m_time = 0f; - f.m_item = item.Clone(); - - var consumeEffects = Traverse.Create(__instance).Field("m_consumeItemEffects").GetValue(); - if (consumeEffects != null) consumeEffects.Create(__instance.transform.position, Quaternion.identity, __instance.transform, 1f, -1); - - var zanim = Traverse.Create(__instance).Field("m_zanim").GetValue(); - if (zanim != null) zanim.SetTrigger("eat"); - - if (item.m_shared.m_food > 0f) __instance.Heal(item.m_shared.m_food, true); - + // Was `f.m_time = 0f`, which expired the flesh instead of renewing + // it. This is the original of the copy the Aswid and the Trenta + // both inherited - see RaceFoodRefresh. + RaceFoodRefresh.Refresh(__instance, f, item); + refreshed = true; break; } diff --git a/JotunnModStub/Factions/FactionHostilityPatch.cs b/JotunnModStub/Factions/FactionHostilityPatch.cs index a9743c4..2ba265b 100644 --- a/JotunnModStub/Factions/FactionHostilityPatch.cs +++ b/JotunnModStub/Factions/FactionHostilityPatch.cs @@ -24,8 +24,15 @@ namespace RacesOfValheim // is the same as no truce at all - the unexempted Fulings open fire, the player defends // themselves, and every Berserker in earshot joins in through damage retaliation, which // IsEnemy has no say over. Verified against the asset manifest, not the wiki's display names. + // Matching is by exact prefab name, so every variant of a creature has to be named here in + // its own right - a family left half-listed is what made the truce look random by biome + // (see PaludeMobs below for the report that turned this up). "Greyling" is the Meadows + // greydwarf and was missing outright: a Trol or a Furling was at peace with the whole + // Black Forest and still fought the smallest thing in it. The Trenta never noticed, + // because its own list in RaceHostilityManager matches on substrings instead. private static readonly HashSet NeraForestaMobs = new HashSet { + "Greyling", "Greydwarf", "Greydwarf_Elite", "Greydwarf_Shaman", "Goblin", "GoblinArcher", "GoblinBrute", "GoblinShaman", "Troll", @@ -38,10 +45,19 @@ namespace RacesOfValheim "Dverger", "DvergerMageFire", "DvergerMageIce", "DvergerMageSupport", "DvergerAshlands", }; + // Skeleton_NoArcher and Draugr_Ranged are the two that were missing, and they are why an + // Aswid reported skeletons that were peaceful in one biome and hostile in another: it was + // never the biome, it was which variant that particular spawner places. Skeleton_NoArcher + // is vanilla's guaranteed-melee skeleton (the same one SkeletonBonePile borrows), so a + // spawner using it produced hostile skeletons standing next to peaceful ones. Draugr_Ranged + // is the bow draugr, left out while the melee and elite ones were exempt. + // + // Skeleton_Hildir stays out deliberately, on the same rule that keeps GoblinKing and the + // Hildir brothers out of the Black Forest set: a quest boss is not somebody's kin. private static readonly HashSet PaludeMobs = new HashSet { - "Ghost", "Skeleton", "Skeleton_Poison", // Skeleton, Rancid remains - "Draugr", "Draugr_Elite", + "Ghost", "Skeleton", "Skeleton_NoArcher", "Skeleton_Poison", // Skeleton, Rancid remains + "Draugr", "Draugr_Elite", "Draugr_Ranged", "Wraith", "Leech", "Abomination", "Blob", "BlobElite", "BlobTar", // Blob, Oozer, Growth }; @@ -107,6 +123,10 @@ namespace RacesOfValheim Character monster = a.IsPlayer() ? b : (b.IsPlayer() ? a : null); if (!(playerCharacter is Player p) || monster == null) return; + // Same stand-down as the per-race truces get: hit your own faction and it hits back + // until the grudge runs out. See RaceGrudge. + if (RaceGrudge.Holds(monster, p)) return; + if (IsSameFaction(p, monster)) { __result = false; @@ -170,8 +190,9 @@ namespace RacesOfValheim // Filtering the RESULT rather than restating the rule keeps one source of truth: the public // instance IsEnemy(Character) calls the static overload both postfixes above hook, so this // honours whatever the faction sets and RaceHostilityManager's per-race lists already agree - // on. Retaliation is untouched - a mob the player hits is targeted through - // BaseAI.OnDamaged/SetTarget, which never goes near FindEnemy. + // on. Retaliation does not come through here either way - a mob the player hits is targeted + // through BaseAI.OnDamaged/SetTarget, which never goes near FindEnemy. That target only + // SURVIVES because of RaceGrudge, though: UpdateTarget drops anything IsEnemy refuses. [HarmonyPatch(typeof(BaseAI), "FindEnemy")] public static class FactionHuntPlayerPatch { diff --git a/JotunnModStub/Factions/FactionsConfig.cs b/JotunnModStub/Factions/FactionsConfig.cs index 2898c7a..91edfe6 100644 --- a/JotunnModStub/Factions/FactionsConfig.cs +++ b/JotunnModStub/Factions/FactionsConfig.cs @@ -20,12 +20,14 @@ namespace RacesOfValheim { public static ConfigEntry HostilityEnabled; public static ConfigEntry MerchantsEnabled; + public static ConfigEntry GrudgeDuration; // Null-safe, defaulting to ON, for the same reason WarVultureConfig guards its own reads: // a patch that somehow runs before Bind() should behave like the shipped default rather // than throw. Awake() binds before harmony.PatchAll(), so this should never fire. public static bool Hostility => HostilityEnabled?.Value ?? true; public static bool Merchants => MerchantsEnabled?.Value ?? true; + public static float GrudgeSeconds => GrudgeDuration?.Value ?? 60f; public static void Bind(ConfigFile config) { @@ -44,8 +46,18 @@ namespace RacesOfValheim "per-race passives in RaceHostilityManager - Fenrir's wolves, Aswid's " + "progression list, the Draugh's undead, the Trenta's Black Forest, the Sverm's " + "invertebrates. Switching this off gives those five races up along with the " + - "faction truce. Hitting a mob still starts a fight either way: retaliation runs " + - "through BaseAI.OnDamaged, which no truce has a say over.")); + "faction truce. Hitting a mob still starts a fight: see Faction grudge below, " + + "which is what makes that true.")); + + GrudgeDuration = config.Bind(factions, "Faction grudge", 60f, + new ConfigDescription("Seconds a creature stays angry at a player of its own faction who hit it. " + + "Without this the truce is absolute in both directions: MonsterAI.UpdateTarget " + + "throws away any target BaseAI.IsEnemy calls a non-enemy, so a truced mob could " + + "not fight back even after being struck - it stood still, or fled because it " + + "was hurt and had no enemy it was allowed to have. The grudge is per attacker " + + "and per creature, on whichever machine runs that creature's AI. 0 restores the " + + "old absolute truce.", + new AcceptableValueRange(0f, 600f))); MerchantsEnabled = config.Bind(factions, "Faction merchants", true, new ConfigDescription("Certain mobs of your own faction can be traded with - 'E - Talk' opens a shop " + diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 20c7157..19e880a 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -39,6 +39,68 @@ namespace RacesOfValheim } } + /// + /// The animation half of somebody else's form. + /// + /// The four behaviours below drive their model's Animator from the player's own, and every + /// one of them runs on the transformed player's client only: FenrirRace.ExecuteTransformation + /// is what adds them, and they read Player.m_localPlayer throughout. RacesVisualController + /// spawns the same model on every other client from the ZDO, and used to spawn nothing else - + /// no parameter was ever written to that copy's Animator, so it sat in its controller's + /// default state and slid across the terrain. The wolf's owner saw a wolf running; everyone + /// else saw a statue on rails. + /// + /// This is the piece that was missing, and it is the arrangement Skadi already uses for its + /// remote dragons (RemoteSkadiAnimator). The parameters come from the remote player's own + /// Visual Animator, which ZSyncAnimation keeps fed over the network for every character a + /// client can see - hiding the body hides renderers, not the animation - so the form walks, + /// runs, jumps and creeps exactly when the real player does. + /// + /// Kept next to the four local behaviours on purpose: this mirrors the movement half of their + /// Update, and the two have to be changed together. + /// + /// Attacks are not mirrored. Those are triggers fired from input on the owner's client and + /// nothing replicates them, so a remote form still bites in silence - that needs a counter of + /// its own on the ZDO and is a separate job. + /// + public class RemoteFenrirAnimator : MonoBehaviour + { + private Player player; + private Animator playerAnim; + private Animator formAnim; + + private void Update() + { + // Resolved here rather than in Start: the model is instantiated under a player who may + // still be assembling their own rig on the frame it arrives. + if (player == null) player = GetComponentInParent(); + if (player == null) return; + + if (formAnim == null) formAnim = GetComponent() ?? GetComponentInChildren(); + if (playerAnim == null) + { + Transform visual = player.transform.Find("Visual"); + if (visual != null) playerAnim = visual.GetComponent(); + } + if (formAnim == null || playerAnim == null) return; + + bool grounded = playerAnim.GetBool("onGround"); + + // All four borrowed creatures answer to these, and they are still written through + // try/catch the way the local behaviours do it: a controller missing one of them would + // otherwise throw once per frame, for every onlooker. + try { formAnim.SetBool("onGround", grounded); } catch {} + try { formAnim.SetBool("inWater", playerAnim.GetBool("inWater")); } catch {} + + // The same three cases the local behaviours use, so both views of the same wolf agree: + // airborne and crouching each read as standing still. Player.IsCrouching answers off + // the animator's current state, which is replicated, so it is true here too. + bool still = !grounded || player.IsCrouching(); + try { formAnim.SetFloat("forward_speed", still ? 0f : playerAnim.GetFloat("forward_speed")); } catch {} + try { formAnim.SetFloat("sideway_speed", still ? 0f : playerAnim.GetFloat("sideway_speed")); } catch {} + } + } + public class FenrirFormBehavior : MonoBehaviour { private Animator playerAnim; diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index fe12525..e88f106 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.18", + "version_number": "1.4.19", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RaceEyeHeight.cs b/JotunnModStub/RaceEyeHeight.cs new file mode 100644 index 0000000..7195861 --- /dev/null +++ b/JotunnModStub/RaceEyeHeight.cs @@ -0,0 +1,93 @@ +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Puts the camera at the height of the body the player is actually wearing. + /// + /// Every race that resizes a player does it on the "Visual" child and never on the root: the + /// root carries the collider and the camera pivot, and scaling that drops the player through + /// the ground they are standing on. The cost of that - which is what testers reported - is + /// that Character.m_eye hangs off the same unscaled root. GameCamera.GetCameraBaseOffset takes + /// the camera from m_eye.position minus the root's, and aim raycasts start there too, so a + /// Trol grew a head taller for everyone else while still seeing the world from human eye + /// level, and a Dvergar shrank without ever having to look up at anything. The height was + /// real, and only the other players could see it. + /// + /// The eye is moved by whatever factor the Visual is wearing at that instant, rather than by a + /// per-race number: that way it follows the Trol's transformation lerp for free, costs nothing + /// for a race that is not sizing anybody (the factor is 1), and returns to the measured + /// original the moment a player stops being of that race. + /// + /// Races that scale the player root instead - the Skeleton is the one - are already carrying + /// their eye with them, and read as a factor of 1 here, so they are left alone by + /// construction. So is a player inside a borrowed form (wolf, drake, bat): those hide the + /// body's renderers and leave its scale at 1, and the form's own camera handling is its + /// business. + /// + /// Applied to every player, not just the one at the keyboard. m_eye is also what a mob aims + /// at, so a Dvergar's head being where the Dvergar's head is matters on every client. + /// + public static class RaceEyeHeight + { + // Below this the body is not small, it is being hidden - an old scale-to-zero trick, or a + // transformation caught mid-lerp. Dividing the player's viewpoint down with it would put + // the camera inside the ground, so the eye is left where it last was. + private const float MinScale = 0.05f; + + /// + /// Remembers where the eye sat before any race touched it, on the eye itself, so it dies + /// with the player object and can never be read back as an already-scaled value. + /// + private class EyeRest : MonoBehaviour + { + public Vector3 LocalPosition; + } + + public static void Apply(Player player) + { + if (player == null) return; + + Transform eye = Traverse.Create(player).Field("m_eye").GetValue(); + if (eye == null) return; + + GameObject visual = Traverse.Create(player).Field("m_visual").GetValue(); + if (visual == null) return; + + // If this build ever parents the eye inside the rig, the body scale already carries + // it and doing the same thing here would apply it twice. + if (eye.IsChildOf(visual.transform)) return; + + EyeRest rest = eye.GetComponent(); + if (rest == null) + { + rest = eye.gameObject.AddComponent(); + rest.LocalPosition = eye.localPosition; + } + + float scale = visual.transform.localScale.y; + if (scale < MinScale) return; + + Vector3 wanted = rest.LocalPosition * scale; + if ((eye.localPosition - wanted).sqrMagnitude > 0.000001f) + { + eye.localPosition = wanted; + } + } + + /// + /// Driven from Player.Update, the same place the scales themselves are applied from. The + /// order the postfixes run in does not matter: this reads whatever scale is on the Visual + /// now, so the worst a late scale can cost is one frame. + /// + [HarmonyPatch(typeof(Player), "Update")] + public static class Player_Update_EyeHeight_Patch + { + public static void Postfix(Player __instance) + { + Apply(__instance); + } + } + } +} diff --git a/JotunnModStub/RaceFoodRefresh.cs b/JotunnModStub/RaceFoodRefresh.cs new file mode 100644 index 0000000..daa2a66 --- /dev/null +++ b/JotunnModStub/RaceFoodRefresh.cs @@ -0,0 +1,63 @@ +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Eating something you are already digesting, for the three races that hand their own food + /// straight to Player.EatFood instead of going through the native right-click path. + /// + /// WHAT WAS WRONG. All three wrote `food.m_time = 0f` to mean "this meal is fresh again". + /// Player.Food.m_time is the opposite: it is the time LEFT. Read out of assembly_valheim - + /// Player.EatFood refreshes a repeat meal with + /// + /// food.m_time = item.m_shared.m_foodBurnTime; + /// + /// and Player.UpdateFood counts it down with `m_time -= dt` and drops the entry the moment it + /// reaches zero. So the line meant to restart the timer was expiring the food on the spot, and + /// the stomach slot vanished instead. + /// + /// The inversion came in honestly: the Aswid's fourth slot and the Trol's fifth are run by + /// this mod rather than by Valheim, and those DO count up from zero (see + /// Aswid_PlayerUpdateFood_Patch). Two opposite conventions, one field name, three copies of + /// the same code - which is why this now lives in one place instead of three. + /// + /// Only a food that answers Player.Food.CanEatAgain() may be refreshed, which is vanilla's own + /// rule (`m_time < m_foodBurnTime / 2`): you cannot top up a meal you have barely started. + /// The callers check it; this does the refreshing. + /// + public static class RaceFoodRefresh + { + /// + /// Puts a slot back to a full meal and plays the eating feedback, exactly as vanilla's own + /// repeat-meal branch does - the three nutrition values included. Leaving those stale was + /// the second half of the bug: a refreshed meal kept whatever health, stamina and eitr the + /// old one had decayed to, so even a correct timer handed back a worn-out slot. + /// + /// Whoever is eating; the one being fed the effects and the heal. + /// The slot already holding this meal. + /// What is being eaten now. Cloned, so the caller's copy - which for the + /// Aswid is a virtual inventory that is thrown away on the next line - can go. + public static void Refresh(Player player, Player.Food food, ItemDrop.ItemData item) + { + if (player == null || food == null || item == null || item.m_shared == null) return; + + food.m_item = item.Clone(); + food.m_time = item.m_shared.m_foodBurnTime; + food.m_health = item.m_shared.m_food; + food.m_stamina = item.m_shared.m_foodStamina; + food.m_eitr = item.m_shared.m_foodEitr; + + EffectList consumeEffects = Traverse.Create(player).Field("m_consumeItemEffects").GetValue(); + if (consumeEffects != null) + { + consumeEffects.Create(player.transform.position, Quaternion.identity, player.transform, 1f, -1); + } + + ZSyncAnimation zanim = Traverse.Create(player).Field("m_zanim").GetValue(); + if (zanim != null) zanim.SetTrigger("eat"); + + if (item.m_shared.m_food > 0f) player.Heal(item.m_shared.m_food, true); + } + } +} diff --git a/JotunnModStub/RaceGrudge.cs b/JotunnModStub/RaceGrudge.cs new file mode 100644 index 0000000..927f4b5 --- /dev/null +++ b/JotunnModStub/RaceGrudge.cs @@ -0,0 +1,127 @@ +using System.Collections.Generic; +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Hit something that is at peace with you and it hits back. + /// + /// WHY THIS HAS TO EXIST. Both truce patches answer BaseAI.IsEnemy with false, and the comment + /// they each carried - that retaliation runs through BaseAI.OnDamaged and no truce has a say + /// over it - is wrong. Read out of assembly_valheim: + /// + /// MonsterAI.OnDamaged calls SetTarget(attacker), so the mob does take the hit + /// personally, exactly as those comments said, and then + /// MonsterAI.UpdateTarget on its very next tick does + /// if (!IsEnemy(m_targetCreature)) m_targetCreature = null; + /// + /// so the target is thrown away a frame later. A truced mob could not fight back at all: it + /// stood there being hit, or - hurt, with no enemy it was allowed to have - fell into + /// UpdateAI's flee branches and ran away. That is what testers saw and reported. + /// + /// WHAT THIS DOES. It remembers who hit whom, for a while, and both truce postfixes stand down + /// for that one pair while the memory lasts. The mob is an enemy again by vanilla's own rules, + /// which means everything downstream - acquiring, chasing, retaliating, giving up - is vanilla + /// behaviour rather than anything reimplemented here. + /// + /// WHERE IT RUNS. On the client that owns the mob's AI, which is the only one whose UpdateTarget + /// matters and the only one that runs Character.ApplyDamage for it. BaseAI.OnDamaged is reached + /// through the character's damage callback on exactly that machine, so the record is made where + /// it will be read. Nothing is replicated and nothing needs to be: another client's copy of the + /// same mob is not the one deciding who it chases. + /// + /// Vanilla has its own version of this idea in BaseAI.SetAggravated, and it is not usable here: + /// it does nothing unless the prefab sets m_aggravatable, which only the dvergr and the seekers + /// do. + /// + public static class RaceGrudge + { + private struct Grudge + { + public ZDOID Attacker; + public float Until; + } + + // One grudge per mob, against the last thing that hit it. A creature can only chase one + // target anyway, and if two players of the same race are both poking it, the one it wants + // is whoever hit it last. + private static readonly Dictionary grudges = new Dictionary(); + private static float lastSweep = 0f; + + private static float Duration => FactionsConfig.GrudgeSeconds; + + /// + /// True while is owed a hit by . Both + /// truce postfixes ask this first and leave IsEnemy alone when it answers yes. + /// + public static bool Holds(Character monster, Character player) + { + if (monster == null || player == null) return false; + if (Duration <= 0f) return false; + + if (!grudges.TryGetValue(monster.GetZDOID(), out Grudge grudge)) return false; + if (Time.time >= grudge.Until) return false; + + return grudge.Attacker == player.GetZDOID(); + } + + public static void Remember(Character monster, Character attacker) + { + if (monster == null || attacker == null) return; + if (Duration <= 0f) return; + + grudges[monster.GetZDOID()] = new Grudge + { + Attacker = attacker.GetZDOID(), + Until = Time.time + Duration + }; + + Sweep(); + } + + /// + /// Drops grudges nobody is owed any more. At most once per duration: a fight is a burst of + /// damage events and the list should not be walked on each one. + /// + private static void Sweep() + { + if (Time.time - lastSweep < Duration) return; + lastSweep = Time.time; + + List expired = null; + foreach (var entry in grudges) + { + if (Time.time < entry.Value.Until) continue; + if (expired == null) expired = new List(); + expired.Add(entry.Key); + } + if (expired == null) return; + foreach (ZDOID id in expired) grudges.Remove(id); + } + + /// + /// The one place a grudge is born. BaseAI.OnDamaged is the base every AI's own override + /// calls first, so patching it here covers MonsterAI and AnimalAI both, and it lands before + /// MonsterAI.OnDamaged's SetTarget on the same hit - the grudge is on the books by the time + /// UpdateTarget next asks whether that target is allowed. + /// + /// Only a player's hit counts. A greydwarf caught in another greydwarf's swing has vanilla's + /// own rules for that and no truce of ours in the way. + /// + [HarmonyPatch(typeof(BaseAI), "OnDamaged")] + public static class BaseAI_OnDamaged_Grudge_Patch + { + public static void Postfix(BaseAI __instance, Character attacker) + { + if (!FactionsConfig.Hostility) return; + if (attacker == null || !attacker.IsPlayer()) return; + + Character monster = Traverse.Create(__instance).Field("m_character").Value; + if (monster == null || monster.IsPlayer()) return; + + Remember(monster, attacker); + } + } + } +} diff --git a/JotunnModStub/RaceHostilityManager.cs b/JotunnModStub/RaceHostilityManager.cs index ae99bc0..e182951 100644 --- a/JotunnModStub/RaceHostilityManager.cs +++ b/JotunnModStub/RaceHostilityManager.cs @@ -25,6 +25,11 @@ namespace RacesOfValheim Character playerCharacter = a.IsPlayer() ? a : (b.IsPlayer() ? b : null); Character monster = a.IsPlayer() ? b : (b.IsPlayer() ? a : null); + // A truce the player has just broken is not a truce. Without this the mob cannot + // retaliate at all - not because it does not try, but because MonsterAI.UpdateTarget + // throws away any target this method calls a non-enemy. See RaceGrudge. + if (RaceGrudge.Holds(monster, playerCharacter)) return; + if (playerCharacter != null && monster != null) { Player p = playerCharacter as Player; @@ -80,8 +85,10 @@ namespace RacesOfValheim // only in flavour text - Greyling/Greydwarf/Leech/Deathsquito "don't see" a // Trenta as prey (root-kin, or simply nothing with blood to sense), while // Fuling/Troll "choose" not to fight one - but there is no third state to code - // for: vanilla's own damage-response AI already makes any of them retaliate if - // the Trenta strikes first, same as it does for Fenrir's wolves above. + // for. Striking first is handled, though not by the AI on its own as this + // comment used to claim: MonsterAI.UpdateTarget discards any target IsEnemy + // calls a non-enemy, so retaliation needed RaceGrudge, checked at the top of + // this method. if (playerRace == TrentaConfig.RaceId) { string prefabName = monster.gameObject.name.ToLower(); diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 2cf0c9f..78db93b 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.18"; + public const string PluginVersion = "1.4.19"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index aa141fa..fe7a3ef 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -522,6 +522,11 @@ namespace RacesOfValheim if (c == Player.m_localPlayer) continue; if (c.IsTamed() || c.IsPlayer()) continue; + // Same guard as the Skeleton's fire aura and the Aswid's drain: an always-on aura + // that burns the race's own kin would, with RaceGrudge in place, keep every wolf, + // drake and dverger permanently angry at a Skadi who never attacked anything. + if (!BaseAI.IsEnemy(Player.m_localPlayer, c)) continue; + if (Vector3.Distance(center, c.transform.position) <= SkadiConfig.AuraRadius.Value) { HitData hit = new HitData(); diff --git a/JotunnModStub/Trenta/TrentaFoodPatches.cs b/JotunnModStub/Trenta/TrentaFoodPatches.cs index c20b87f..f083369 100644 --- a/JotunnModStub/Trenta/TrentaFoodPatches.cs +++ b/JotunnModStub/Trenta/TrentaFoodPatches.cs @@ -137,7 +137,14 @@ namespace RacesOfValheim [HarmonyPatch(typeof(Player), "EatFood")] public static class Trenta_Player_EatFood_DuplicateGuard_Patch { - public static bool Prefix(Player __instance, ItemDrop.ItemData item) + // __result matters here, unlike in a prefix that only ever falls through to vanilla: + // the caller above is TrentaFoodPatches' own UseItem prefix, and it removes the seed + // from the bag only when EatFood answers true. Without this the refresh below would + // renew the slot and leave the seed in the inventory to be eaten again, forever. It + // went unnoticed while the refresh was broken: the old code destroyed the slot instead + // of renewing it, so the free seed had nothing to show for it. The Aswid and the + // Draugh versions of this patch already took __result. + public static bool Prefix(Player __instance, ItemDrop.ItemData item, ref bool __result) { hiddenFoods.Clear(); @@ -155,22 +162,18 @@ namespace RacesOfValheim Player.Food f = foodObj as Player.Food; if (f != null && f.m_item.m_shared.m_name == item.m_shared.m_name && f.CanEatAgain()) { - f.m_time = 0f; - f.m_item = item.Clone(); + // Was `f.m_time = 0f`, which expired the seed instead of renewing it - + // this is the "eating a second seed deletes the first" report. See + // RaceFoodRefresh. + RaceFoodRefresh.Refresh(__instance, f, item); - var consumeEffects = Traverse.Create(__instance).Field("m_consumeItemEffects").GetValue(); - if (consumeEffects != null) consumeEffects.Create(__instance.transform.position, Quaternion.identity, __instance.transform, 1f, -1); - - var zanim = Traverse.Create(__instance).Field("m_zanim").GetValue(); - if (zanim != null) zanim.SetTrigger("eat"); - - if (item.m_shared.m_food > 0f) __instance.Heal(item.m_shared.m_food, true); - - return false; // Refreshed ourselves - skip native EatFood + __result = true; // Eaten: the caller consumes the seed. + return false; // Refreshed ourselves - skip native EatFood } } - return false; // Full, and nothing to refresh + __result = false; // Full, and nothing in it worth topping up: the seed stays. + return false; } // Temporarily hide any existing slot with the same name to force native EatFood diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs index c7d2f2f..ecff680 100644 --- a/JotunnModStub/ZdoVisualSync.cs +++ b/JotunnModStub/ZdoVisualSync.cs @@ -217,6 +217,13 @@ namespace RacesOfValheim { Destroy(col); } + + // Without this the model arrives with nobody writing to its + // Animator and stands in its default pose, sliding wherever the + // player walks. The local form has four behaviours doing this job; + // none of them can run here, because all of them are built around + // Player.m_localPlayer. + m_currentFormInstance.AddComponent(); } } } diff --git a/README.md b/README.md index 11e2bba..1db8120 100644 --- a/README.md +++ b/README.md @@ -404,12 +404,22 @@ Aswid, Draugh, Skeleton / at peace with Ghost, Skeleton, Draugr, Wraith, Leech, The **Sverm** belongs to no faction. Its Hive Pheromones make every invertebrate in the game ignore it instead — leeches, ticks, deathsquitos, seekers and bees — with no boss gate and no trading. +A truce is not a shield: hit one of your own and it hits back, for **Faction grudge** seconds (60 by default), then forgets about it. Your always-on auras — the Aswid's drain, the Skadi's frost — leave your own kin alone, so they never start that fight for you. + Both halves have an off switch under `Factions` in Configuration Manager: **Faction truce** for whether your faction's mobs leave you alone, **Faction merchants** for whether they will trade. Both are on by default and both take effect without a restart. Be aware that turning the truce off also gives up every race's own peace — Fenrir's wolves, the Aswid's list, the Draugh's undead, the Trenta's Black Forest, the Sverm's invertebrates, the Furling's Plains roster and the Skeleton's undead — because they are all the same question asked of the same vanilla method. --- ## Changelog +### v1.4.19 +- **Fix - You could not see your own height:** the Trol stood a head taller and the Dvergar came up short for everyone except themselves — the body was resized, but the camera stayed at human eye level, so from your own chair nothing had changed. Your eyes now sit where your head is, and your shots start from there too. Every race that resizes its body is covered, at whatever size it happens to be wearing: the Trol's True Form lifts the view as it grows and lowers it again on the way back. Thanks to the testers who noticed it only worked on other people. +- **Fix - Other players saw a Fenrir's wolf standing still and sliding:** the form's animations were only ever driven on the transformed player's own screen. Everyone else got the model in its default pose, gliding across the ground. Wolf, Ulv, Fenring and Cultist now walk, run, jump and creep for every player who can see them. Their attacks are still silent to onlookers — that needs its own fix and is not in this build. +- **Fix - Eating the same creature or seed again destroyed that food instead of refreshing it:** the timer was being set to "expired" rather than "full", so a repeat meal deleted the slot it was meant to renew — and it only happened once the food was under half, which is exactly when it starts flashing. Above half, nothing happened at all. The Aswid's devoured creatures, the Trenta's awakened seeds and the Draugh's raw flesh all had it; all three now renew the slot the way any vanilla food does, nourishment included. Thanks to the tester who worked out that it was the flashing ones. +- **Fix - Devouring only ever caught the first kill:** the Aswid's devour was on a five-second timer shared by every corpse in the world, so clearing a group with the claws or the aura fed you once and let the rest die unnoticed. It is now per body: kill a pack and you drink from all of them. A refused meal also says so instead of failing silently. +- **Fix - Mobs of your own faction would not fight back:** attacking one of your own kin did nothing — it stood there, or ran away — because the truce was absolute in both directions and the game threw away any target it was not allowed to have. Now hitting one starts a real fight for **Faction grudge** seconds (60 by default, configurable, 0 for the old behaviour), per creature and per attacker. The Aswid's drain and the Skadi's frost aura no longer touch their own kin, so an always-on aura can no longer pick that fight on your behalf. Thanks to the tester who reported the Trenta and the Aswid. +- **Fix - Friendly skeletons in one biome, hostile ones in the next:** the faction truce matched creatures by exact name and several families were only half-listed, so an Aswid was at peace with one kind of skeleton and at war with another standing next to it. Added the melee-only skeleton and the bow draugr to the Swamp, and the greyling to the Black Forest — a Trol or a Furling was at peace with the whole forest and still fought the smallest thing in it. Thanks to the tester who mapped it out biome by biome. + ### v1.4.18 - **Fix - Drake flight stopped working after the latest Valheim hotfix:** the hotfix changed how the game reads the gamepad's left stick, and the drake's flight still asked for it the old way. Every frame in the air threw a `MissingMethodException` into the log and the drake could not fly. Flight now works on both the new and the old version of the game. - **Fix - Faction merchants would not open their shop:** Valheim 1.0 added a name, tooltip, buy effects and unlock keys to every shop item, and the shop window reads some of them without checking they are there. The merchants' goods were missing them, so pressing E threw a `NullReferenceException` and nothing opened. Buying is covered too — it would have hit the same wall on the buy effects. Thanks to the tester who tracked this down. diff --git a/manifest.json b/manifest.json index fe12525..e88f106 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.18", + "version_number": "1.4.19", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 64d8869f987007845d62cb209a339d72d9cd238b Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Mon, 21 Sep 2026 09:05:56 +0200 Subject: [PATCH 033/273] bugfix 21/09/26 --- JotunnModStub/PieceDensityLimit.cs | 42 +++++++++++++++++++++++++++++ JotunnModStub/Skadi/SkadiPatches.cs | 5 +++- JotunnModStub/Skadi/SkadiRace.cs | 26 ++++++++++++++++-- 3 files changed, 70 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/PieceDensityLimit.cs b/JotunnModStub/PieceDensityLimit.cs index e39f9b4..1546e21 100644 --- a/JotunnModStub/PieceDensityLimit.cs +++ b/JotunnModStub/PieceDensityLimit.cs @@ -199,4 +199,46 @@ namespace RacesOfValheim return PieceDensityLimit.Allow(__instance, Utils.GetPrefabName(__0.gameObject), __1); } } + + /// + /// What makes "a prefix returning false spends nothing" TRUE, which on its own it is not. + /// + /// Read off the 1.0 IL: nothing is paid inside PlacePiece. TryPlacePiece calls it and then does an + /// unconditional `ldc.i4.1; ret`, and it is UpdatePlacement that, on that true, runs + /// ConsumeResources and UseStamina. So every race lock in the mod - this class's gates, the Trol + /// totem, the Dvergar bank and barrel, the Trenta Root - stopped the building and still took the + /// wood: "Only the Sverm can raise a hive", and 40 wood and 20 resin gone. + /// + /// Fixed here once rather than in each lock: a last-priority prefix on the same PlacePiece + /// overload sees __runOriginal after every other prefix has had its say, and if any of them said + /// no, TryPlacePiece reports false - the path vanilla already takes for a blocked placement, which + /// charges nothing. Any lock added later is covered without knowing this exists. + /// + [HarmonyPatch(typeof(Player), "PlacePiece", + new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })] + public static class PlacementRefusalWatch + { + internal static bool Refused; + + [HarmonyPriority(Priority.Last)] + public static void Prefix(bool __runOriginal) + { + if (!__runOriginal) Refused = true; + } + } + + [HarmonyPatch(typeof(Player), "TryPlacePiece")] + public static class PlacementRefusalCharge + { + public static void Prefix() + { + PlacementRefusalWatch.Refused = false; + } + + public static void Postfix(ref bool __result) + { + if (PlacementRefusalWatch.Refused) __result = false; + PlacementRefusalWatch.Refused = false; + } + } } diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 6db166c..1a793db 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -549,7 +549,10 @@ namespace RacesOfValheim // the live button state (via the configured shortcut, so a rebind stays in sync) // rather than a flag set during our Update, so it does not depend on whether // PlayerController's FixedUpdate happens to run first. - if (secondaryAttack && SkadiConfig.ColdSpellKey.Value.IsPressedIgnoringHeldKeys() && + // The pad's secondary attack casts only bare-handed (SkadiRace.PadCastsColdSpell), so it + // swallows the kick only then; with a weapon in hand the weapon's secondary goes through. + bool padCast = RaceInput.PadAttackHeld(2) && SkadiRace.PadCastsColdSpell(Player.m_localPlayer); + if (secondaryAttack && (SkadiConfig.ColdSpellKey.Value.IsPressedIgnoringHeldKeys() || padCast) && SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi()) { var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState()); diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index fe7a3ef..34886e8 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -339,9 +339,18 @@ namespace RacesOfValheim if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return; if (isTransformed) return; // Do not cast human spell while in dragon form + // Hammer, hoe or cultivator in hand: every build button is vanilla's. Middle mouse is + // Remove on the keyboard, and on the pad JoySecondaryAttack shares its physical button + // with JoyRemove (Classic) or JoyPlace (Alt2) - read off ZInput.AddGamepad*Buttons - so + // each piece built or removed also cast the spell and drained the stamina for it. + if (Player.m_localPlayer.InPlaceMode()) return; + // Middle Mouse Button to cast, by default - rebindable via SkadiConfig.ColdSpellKey. - // On a gamepad, the secondary attack button (the pad's own middle-mouse equivalent). - if (SkadiConfig.ColdSpellKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(2)) + // On a gamepad, the secondary attack button (the pad's own middle-mouse equivalent) - + // but only bare-handed: the pad has no separate spell key, so with a weapon or a tool + // that button belongs to the item's own secondary attack, as it does in vanilla. + if (SkadiConfig.ColdSpellKey.Value.IsDownIgnoringHeldKeys() || + (RaceInput.PadAttackDown(2) && PadCastsColdSpell(Player.m_localPlayer))) { // The improved cast is a burst rather than a rapid-fire, so it waits longer. float cooldown = rules.ImprovedColdSpell ? IMPROVED_SPELL_COOLDOWN : SPELL_COOLDOWN; @@ -373,6 +382,19 @@ namespace RacesOfValheim } } + /// + /// Whether the pad's secondary attack button casts the Cold Spell right now: out of build + /// mode and with nothing in either hand. Shared with SkadiAttackPatch, which swallows the + /// unarmed kick under exactly the same condition. + /// + public static bool PadCastsColdSpell(Player player) + { + if (player == null || player.InPlaceMode()) return false; + var hands = HarmonyLib.Traverse.Create(player); + return hands.Field("m_rightItem").Value == null && + hands.Field("m_leftItem").Value == null; + } + private IEnumerator ColdSpellKickCoroutine(SkadiProgression.FormRules rules) { // Wait for the cast animation to reach the release point From 6499eb71df89df8ffdf2768c2eb88c8803c6e013 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Mon, 21 Sep 2026 17:38:53 +0200 Subject: [PATCH 034/273] chore(release): v1.4.20 - refused buildings cost nothing, Skadi pad cold spell Co-Authored-By: Claude Opus 5 --- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RacesOfValheim.cs | 2 +- README.md | 5 +++++ manifest.json | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index e88f106..4c8d434 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.19", + "version_number": "1.4.20", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 78db93b..b050b4b 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.19"; + public const string PluginVersion = "1.4.20"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/README.md b/README.md index 1db8120..68ac96b 100644 --- a/README.md +++ b/README.md @@ -412,6 +412,11 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.20 +- **Fix - A refused race building still took your materials:** building something your race is not allowed to build, or before its boss has fallen, showed the refusal and then charged the full cost anyway — a non-Sverm trying the Brood Mound got "Only the Sverm can raise a hive." and lost 40 wood and 20 resin. The refusal stopped the building, but Valheim takes the cost in a separate step that never heard about it. Now a refused building costs nothing, no stamina included. This covered every locked building in the mod: the Sverm hive and market (and the one-hive-per-area limit), the Skadi golem, the Dvergar contract bank and barrel, the Trenta Elder Root and the Trol totem. Thanks to the tester who noticed the wood going missing. +- **Fix - On a gamepad the Skadi cast the Cold Spell every time she built:** the spell sits on the pad's secondary attack button, which Valheim also uses to remove pieces (Classic layout) or place them (Alt 2). Every piece built or removed also cast the spell and drained stamina, which made building nearly impossible. The spell no longer casts while you hold the hammer, hoe or cultivator — on the keyboard as well, where middle mouse is Remove. +- **Changed - On a gamepad the Cold Spell now casts bare-handed only:** the pad has no separate key for the spell, so with a weapon, shield, torch or tool in hand the button goes back to that item's own secondary attack, as it does in vanilla. Previously both fired together. Bare-handed, the spell casts without the unarmed kick. Keyboard players are unaffected: the Cold Spell key works as before. Thanks to the tester who reported it from a controller. + ### v1.4.19 - **Fix - You could not see your own height:** the Trol stood a head taller and the Dvergar came up short for everyone except themselves — the body was resized, but the camera stayed at human eye level, so from your own chair nothing had changed. Your eyes now sit where your head is, and your shots start from there too. Every race that resizes its body is covered, at whatever size it happens to be wearing: the Trol's True Form lifts the view as it grows and lowers it again on the way back. Thanks to the testers who noticed it only worked on other people. - **Fix - Other players saw a Fenrir's wolf standing still and sliding:** the form's animations were only ever driven on the transformed player's own screen. Everyone else got the model in its default pose, gliding across the ground. Wolf, Ulv, Fenring and Cultist now walk, run, jump and creep for every player who can see them. Their attacks are still silent to onlookers — that needs its own fix and is not in this build. diff --git a/manifest.json b/manifest.json index e88f106..4c8d434 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.19", + "version_number": "1.4.20", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From e7325e4d256e27791bbd4f9ec11b3ba8505ffe9f Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Wed, 23 Sep 2026 11:56:09 +0200 Subject: [PATCH 035/273] chore(release): v1.4.21 - dragon form multiplayer sync, Sverm Ravager networking, dorsal spine fix Co-Authored-By: Claude Sonnet 5 --- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RacesOfValheim.cs | 2 +- JotunnModStub/Skadi/DrakeFormBehavior.cs | 15 +++ JotunnModStub/Skadi/SkadiPatches.cs | 47 ++++++- JotunnModStub/Skadi/SkadiRace.cs | 12 ++ JotunnModStub/Sverm/SvermConfig.cs | 9 +- JotunnModStub/Sverm/SvermConfigManagement.cs | 14 ++ JotunnModStub/Sverm/SvermPatches.cs | 135 +++++++++++++++++++ JotunnModStub/Sverm/SvermRavagerForm.cs | 54 ++++++++ JotunnModStub/Sverm/SvermVisuals.cs | 14 +- README.md | 7 + manifest.json | 2 +- 12 files changed, 303 insertions(+), 10 deletions(-) diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 4c8d434..3baa445 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.20", + "version_number": "1.4.21", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index b050b4b..009df99 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.20"; + public const string PluginVersion = "1.4.21"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index 7258cb8..ffd3b74 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -105,6 +105,14 @@ namespace RacesOfValheim } } + // Read by RemoteSkadiAnimator (SkadiPatches.cs) so other clients' copy of the form actually + // plays the bite/claw/breath clip instead of just locomotion. The suffix is a running count, + // not just the trigger name, because the same attack (e.g. two bites in a row) has to look + // like a NEW event to a remote client diffing the ZDO string - an unchanged value never + // re-triggers a Unity Animator trigger parameter. + public const string AttackTriggerKey = "RacesOfValheim_SkadiAttackTrigger"; + private static int attackTriggerSeq = 0; + /// /// Animator.SetTrigger on a name the controller does not have is silently ignored by Unity, /// so a wrong trigger looks exactly like "the animation did not play" with nothing in the @@ -120,6 +128,13 @@ namespace RacesOfValheim if (p.type == AnimatorControllerParameterType.Trigger && p.name == trigger) { anim.SetTrigger(trigger); + + ZNetView nview = Player.m_localPlayer?.GetComponent(); + if (nview != null && nview.IsValid()) + { + attackTriggerSeq++; + nview.GetZDO().Set(AttackTriggerKey, trigger + "#" + attackTriggerSeq); + } return; } } diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 1a793db..2979b84 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -78,7 +78,11 @@ namespace RacesOfValheim formInstance.name = wanted; formInstance.transform.localPosition = formName == "Hatchling" ? new Vector3(0f, -1.0f, 0f) : Vector3.zero; formInstance.transform.localRotation = Quaternion.identity; - + // Same config-driven size the transforming player's own client applies (see + // SkadiRace.GetFormScale) - without it every remote observer saw the prefab's + // raw 1x Visual scale, Moder's ModerScale shrink included. + formInstance.transform.localScale = SkadiRace.GetFormScaleForPrefab(formName); + if (formInstance.GetComponent() == null) { formInstance.AddComponent(); @@ -94,27 +98,62 @@ namespace RacesOfValheim { private Animator anim; private Player player; + private ZNetView nview; + + // Seeded from whatever the ZDO already holds in Start, not "", so a value left over from an + // earlier transformation on this same player does not read as a brand-new attack the moment + // this component is built and replay a stale trigger on entry. + private string lastAttackTrigger; private void Start() { anim = GetComponent(); if (anim == null) anim = GetComponentInChildren(); player = GetComponentInParent(); + nview = player != null ? player.GetComponent() : null; + + if (nview != null && nview.IsValid()) + { + lastAttackTrigger = nview.GetZDO().GetString(DrakeFormBehavior.AttackTriggerKey, ""); + } } private void Update() { if (anim == null || player == null) return; - + bool flying = HarmonyLib.Traverse.Create(player).Field("m_flying").Value; bool grounded = !flying && player.IsOnGround(); - + anim.SetBool("onGround", grounded); anim.SetBool("flying", flying); - + Vector3 vel = player.GetVelocity(); vel.y = 0f; anim.SetFloat("forward_speed", vel.magnitude); + + // The bite/claw/breath trigger DrakeFormBehavior fires on the transforming player's own + // client - without this, remote observers only ever saw locomotion, never an attack play. + if (nview != null && nview.IsValid()) + { + string current = nview.GetZDO().GetString(DrakeFormBehavior.AttackTriggerKey, ""); + if (!string.IsNullOrEmpty(current) && current != lastAttackTrigger) + { + lastAttackTrigger = current; + + int seqAt = current.LastIndexOf('#'); + string trigger = seqAt >= 0 ? current.Substring(0, seqAt) : current; + + foreach (AnimatorControllerParameter p in anim.parameters) + { + if (p.type == AnimatorControllerParameterType.Trigger && p.name == trigger) + { + anim.SetTrigger(trigger); + break; + } + } + } + } } } diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 34886e8..af64056 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -600,6 +600,18 @@ namespace RacesOfValheim return Vector3.one * SkadiConfig.DrakeScale.Value; // Drake } + // Same lookup, keyed by the prefab name the ZDO actually carries ("RacesOfValheim_SkadiForm"), + // so Skadi_MultiplayerVisuals_Patch can size a remote observer's copy of the form the same way + // the transforming player's own client does. Without this the remote instance was left at the + // prefab's raw Visual scale (1x) no matter which form or config value was in play - Moder's + // ModerScale nerf, in particular, only ever applied on the transformed player's own screen. + public static Vector3 GetFormScaleForPrefab(string prefabName) + { + if (prefabName == "Dragon") return Vector3.one * SkadiConfig.ModerScale.Value; + if (prefabName == "Fader") return Vector3.one * SkadiConfig.FaderScale.Value; + return Vector3.one * SkadiConfig.DrakeScale.Value; // Hatchling + } + private IEnumerator TransformRoutine(SkadiProgression.FormRules rules) { isTransformingSequence = true; diff --git a/JotunnModStub/Sverm/SvermConfig.cs b/JotunnModStub/Sverm/SvermConfig.cs index 0a74c95..f5f0c93 100644 --- a/JotunnModStub/Sverm/SvermConfig.cs +++ b/JotunnModStub/Sverm/SvermConfig.cs @@ -192,8 +192,8 @@ namespace RacesOfValheim // it is a real prefab that resolves by name, and it reads as xenomorph spines rather than // as a bird. public const string SpinesPrefab = "UndeadBjornRibcage"; - public static readonly float SpineSizeSmall = 0.45f; // metres, state 5-6 - public static readonly float SpineSizeFull = 0.80f; // metres, state 7+ + public static readonly float SpineSizeSmall = 0.315f; // metres, state 5-6 (0.45 * 0.7) + public static readonly float SpineSizeFull = 0.56f; // metres, state 7+ (0.80 * 0.7) /// /// Which bone they ride. Spine2 and ONLY Spine2 - no fallback chain. /// @@ -214,6 +214,11 @@ namespace RacesOfValheim public static readonly float SpineRotationY = -90f; public static readonly float SpineRotationZ = 90f; + // No extra nudge by default - ApplySpines already centres the crest on the bone (half its + // own height each way) before this is added, which is what keeps the Full-Crest size from + // reaching up over the head the way basing the whole thing at the bone once did. + public static readonly float SpineOffsetY = 0f; + /// /// What holds a falling Sverm up: the Mistlands' own fireflies, swarming under the body. /// diff --git a/JotunnModStub/Sverm/SvermConfigManagement.cs b/JotunnModStub/Sverm/SvermConfigManagement.cs index 4cd7290..30ebfce 100644 --- a/JotunnModStub/Sverm/SvermConfigManagement.cs +++ b/JotunnModStub/Sverm/SvermConfigManagement.cs @@ -32,6 +32,7 @@ namespace RacesOfValheim public static ConfigEntry SpineRotationX; public static ConfigEntry SpineRotationY; public static ConfigEntry SpineRotationZ; + public static ConfigEntry SpineOffsetY; // ─── Emberform ─────────────────────────────────────────────────────── public static ConfigEntry EmberGlowStrength; @@ -255,6 +256,17 @@ namespace RacesOfValheim SpineRotationX = config.Bind(spines, "Rotation X", SvermConfig.SpineRotationX, "Pitch of the spines, in degrees."); SpineRotationY = config.Bind(spines, "Rotation Y", SvermConfig.SpineRotationY, "Yaw of the spines, in degrees."); SpineRotationZ = config.Bind(spines, "Rotation Z", SvermConfig.SpineRotationZ, "Roll of the spines, in degrees."); + + // FOUND IN PLAY: at Size Full (0.8 m) the crest reached up past the shoulders and onto + // the head - ModelBorrow.Attach grounds a borrowed model's BOTTOM at the mount point and + // grows it from there, and Spine2's own local up axis runs toward the head, not out and + // away from the back. ApplySpines now centres the crest on the bone by default (half its + // height below the mount point, half above) instead of basing the whole thing there, which + // is a size-aware correction rather than a guess; this is purely an extra nudge on top of + // that, in metres along the same axis, for whatever an eye still wants adjusted. + SpineOffsetY = config.Bind(spines, "Offset Y", SvermConfig.SpineOffsetY, + "Extra nudge along the mount bone's own up axis, in metres, on top of the automatic " + + "centring. Positive moves the crest toward the head, negative toward the tail."); } // ─── Live reads ────────────────────────────────────────────────────── @@ -269,6 +281,8 @@ namespace RacesOfValheim SpineRotationZ?.Value ?? SvermConfig.SpineRotationZ); } + public static float SpineOffset => SpineOffsetY?.Value ?? SvermConfig.SpineOffsetY; + public static float EmberStrength => EmberGlowStrength?.Value ?? SvermConfig.EmberGlowStrength; public static int Brood => CapBrood?.Value ?? SvermConfig.CapBrood; diff --git a/JotunnModStub/Sverm/SvermPatches.cs b/JotunnModStub/Sverm/SvermPatches.cs index 4a21dc6..5d909f1 100644 --- a/JotunnModStub/Sverm/SvermPatches.cs +++ b/JotunnModStub/Sverm/SvermPatches.cs @@ -310,6 +310,141 @@ namespace RacesOfValheim } } + // ─── Ravager Strain (remote observers) ────────────────────────────── + + /// + /// Mirrors SvermRavagerForm.Enter/Exit for every OTHER client, the same way + /// Skadi_MultiplayerVisuals_Patch mirrors SkadiRace's dragon forms. SvermRavagerForm itself + /// only ever touches Player.m_localPlayer - Tick(), Enter() and RavagerFormBehavior are all + /// built around it - so without this an observer's client never knew the form was up at + /// all: no model, no hidden human body, nothing standing in for the Brute. + /// + [HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")] + public static class Sverm_RavagerRemoteVisuals_Patch + { + private const string RemoteModelName = "SvermRavagerRemoteModel"; + + public static void Postfix(VisEquipment __instance) + { + if (__instance == null || !__instance.m_isPlayer) return; + + Player player = __instance.GetComponent(); + if (player == null || player.IsOwner()) return; // Local player: SvermRavagerForm handles itself. + + if (!SvermVisuals.IsSvermPlayer(player)) return; + + ZNetView nview = player.GetComponent(); + if (nview == null || !nview.IsValid()) return; + + bool active = nview.GetZDO().GetBool(SvermRavagerForm.ActiveKey, false); + Transform existing = player.transform.Find(RemoteModelName); + Transform playerVisual = player.transform.Find("Visual"); + + if (!active) + { + if (existing != null) + { + Object.Destroy(existing.gameObject); + PlayerVisualHider.Show(playerVisual, "sverm-ravager-remote-revert"); + } + return; + } + + if (existing == null) + { + GameObject model = SvermRavagerForm.SpawnRemoteModel(player.transform); + if (model != null) + { + model.name = RemoteModelName; + model.AddComponent(); + } + } + + PlayerVisualHider.Hide(playerVisual, "sverm-ravager-remote"); + } + } + + /// + /// RemoteSkadiAnimator's counterpart for the Ravager Strain: locomotion off the replicated + /// Character, plus the bite/ram/slam/taunt trigger RavagerFormBehavior publishes through + /// SvermRavagerForm.PublishAttackTrigger. LateUpdate re-hides the player's own Visual every + /// frame for the same reason RavagerFormBehavior does on the local client - any nearby + /// equipment rebuild (VisEquipment's own refresh path) makes a hidden body visible again. + /// + public class RemoteRavagerAnimator : MonoBehaviour + { + private Animator anim; + private Player player; + private ZNetView nview; + private bool hasForwardSpeed; + private bool hasOnGround; + + // Seeded from the ZDO's current value in Start, not "", so a trigger left over from an + // earlier Ravager Strain on this same player does not replay the instant this + // component is built. + private string lastAttackTrigger; + + private void Start() + { + anim = GetComponentInChildren(); + player = GetComponentInParent(); + nview = player != null ? player.GetComponent() : null; + + if (anim != null) + { + foreach (AnimatorControllerParameter p in anim.parameters) + { + if (p.type == AnimatorControllerParameterType.Float && p.name == "forward_speed") hasForwardSpeed = true; + else if (p.type == AnimatorControllerParameterType.Bool && p.name == "onGround") hasOnGround = true; + } + } + + if (nview != null && nview.IsValid()) + { + lastAttackTrigger = nview.GetZDO().GetString(SvermRavagerForm.AttackTriggerKey, ""); + } + } + + private void LateUpdate() + { + if (player == null) return; + PlayerVisualHider.Hide(player.transform.Find("Visual"), "sverm-ravager-remote"); + } + + private void Update() + { + if (anim == null || player == null) return; + + if (hasForwardSpeed) + { + Vector3 vel = player.GetVelocity(); + vel.y = 0f; + anim.SetFloat("forward_speed", vel.magnitude); + } + + if (hasOnGround) anim.SetBool("onGround", player.IsOnGround()); + + if (nview == null || !nview.IsValid()) return; + + string current = nview.GetZDO().GetString(SvermRavagerForm.AttackTriggerKey, ""); + if (string.IsNullOrEmpty(current) || current == lastAttackTrigger) return; + + lastAttackTrigger = current; + + int seqAt = current.LastIndexOf('#'); + string trigger = seqAt >= 0 ? current.Substring(0, seqAt) : current; + + foreach (AnimatorControllerParameter p in anim.parameters) + { + if (p.type == AnimatorControllerParameterType.Trigger && p.name == trigger) + { + anim.SetTrigger(trigger); + break; + } + } + } + } + // ─── Spawn ─────────────────────────────────────────────────────────── /// diff --git a/JotunnModStub/Sverm/SvermRavagerForm.cs b/JotunnModStub/Sverm/SvermRavagerForm.cs index 9ef37a1..a8b9b88 100644 --- a/JotunnModStub/Sverm/SvermRavagerForm.cs +++ b/JotunnModStub/Sverm/SvermRavagerForm.cs @@ -28,6 +28,18 @@ namespace RacesOfValheim { public static bool IsActive { get; private set; } + // Read by Sverm_RavagerRemoteVisuals_Patch (SvermPatches.cs) so every other client can + // tell the form is up at all - without this the whole thing was local-only, exactly like + // DrakeFormBehavior's flight flag and Fenrir's own form key, and other players saw nothing + // but a Sverm standing still for the whole two minutes. + public const string ActiveKey = "RacesOfValheim_SvermRavagerForm"; + + // Same running-count trick as DrakeFormBehavior.AttackTriggerKey: the trigger name alone + // cannot tell a remote client "a new bite just happened" when the same trigger fires twice + // in a row, since an unchanged ZDO string never re-fires a Unity Animator trigger. + public const string AttackTriggerKey = "RacesOfValheim_SvermRavagerAttack"; + private static int attackTriggerSeq = 0; + private static GameObject model; private static float expiresAt; private static float nextAllowedAt; @@ -214,6 +226,9 @@ namespace RacesOfValheim IsActive = true; expiresAt = Time.time + SvermConfig.RavagerDurationSeconds; + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid()) nview.GetZDO().Set(ActiveKey, true); + player.GetSEMan().AddStatusEffect(SvermConfig.RavagerSE.GetStableHashCode(), true); Transform visual = player.transform.Find("Visual"); @@ -289,6 +304,9 @@ namespace RacesOfValheim { IsActive = false; + ZNetView exitNview = player.GetComponent(); + if (exitNview != null && exitNview.IsValid()) exitNview.GetZDO().Set(ActiveKey, false); + PlayEffect(SvermConfig.RavagerMorphOutEffects, player.transform.position); // Nothing was ever equipped for this form - see the class doc for why - so there is @@ -382,6 +400,40 @@ namespace RacesOfValheim if (target != null) target.transform.localScale = to; } + // ─── Remote observers ─────────────────────────────────────────────── + + /// + /// Builds the same costume Enter() does, minus the grow-in tween (a remote observer just + /// needs the steady-state model, not the entrance) and minus RavagerFormBehavior, which is + /// built around Player.m_localPlayer and would do nothing useful on a copy driven by + /// someone else's client. Sverm_RavagerRemoteVisuals_Patch adds RemoteRavagerAnimator + /// instead, the same way Skadi_MultiplayerVisuals_Patch adds RemoteSkadiAnimator. + /// + public static GameObject SpawnRemoteModel(Transform playerTransform) + { + if (template == null) return null; + + GameObject model = Object.Instantiate(template, playerTransform.position, playerTransform.rotation, playerTransform); + model.transform.localPosition = Vector3.zero; + model.transform.localScale = template.transform.localScale * SvermConfigManagement.RavagerScale; + model.transform.localRotation = Quaternion.Euler(0f, SvermConfigManagement.RavagerYaw, 0f); + return model; + } + + /// + /// Called by RavagerFormBehavior right after it fires a trigger on the local player's own + /// copy of the Animator, so RemoteRavagerAnimator can replay the same clip on every other + /// client. See AttackTriggerKey for why a sequence number rides along with the name. + /// + public static void PublishAttackTrigger(Player player, string trigger) + { + ZNetView nview = player != null ? player.GetComponent() : null; + if (nview == null || !nview.IsValid()) return; + + attackTriggerSeq++; + nview.GetZDO().Set(AttackTriggerKey, trigger + "#" + attackTriggerSeq); + } + // ─── The three attacks ─────────────────────────────────────────────── /// @@ -584,6 +636,7 @@ namespace RacesOfValheim if (!string.IsNullOrEmpty(profile.Trigger) && knownTriggers.Contains(profile.Trigger)) { anim.SetTrigger(profile.Trigger); + SvermRavagerForm.PublishAttackTrigger(Player.m_localPlayer, profile.Trigger); } yield return new WaitForSeconds(hitDelay); @@ -614,6 +667,7 @@ namespace RacesOfValheim if (!string.IsNullOrEmpty(profile.Trigger) && knownTriggers.Contains(profile.Trigger)) { anim.SetTrigger(profile.Trigger); + SvermRavagerForm.PublishAttackTrigger(Player.m_localPlayer, profile.Trigger); } PlaySound(SvermConfig.RavagerTauntSoundEffects); diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs index f8017c0..5dd352c 100644 --- a/JotunnModStub/Sverm/SvermVisuals.cs +++ b/JotunnModStub/Sverm/SvermVisuals.cs @@ -454,9 +454,19 @@ namespace RacesOfValheim // metres and degrees - what was ASKED for - not bone-local numbers. Quaternion wantedRotation = SvermConfigManagement.SpineRotation(); + // Basing the whole crest AT the bone and growing it upward (ModelBorrow.Attach grounds + // a borrowed model's bottom at the mount point) reached up past the shoulders and onto + // the head once the crest got tall - Spine2's own local up axis runs toward the head, + // not out and away from the back. Centring it on the bone instead - half its height + // below the mount point, half above - keeps the same rotation an eye already approved + // while stopping the Full Crest size from overshooting. SpineOffsetY is an additional + // nudge along the same axis, for whatever still needs adjusting by eye. + float wantedOffsetY = -wanted / 2f + SvermConfigManagement.SpineOffset; + SvermSpineTag tag = existing != null ? existing.GetComponent() : null; if (existing != null && (tag == null || !Mathf.Approximately(tag.Size, wanted) + || !Mathf.Approximately(tag.OffsetY, wantedOffsetY) || Quaternion.Angle(tag.Rotation, wantedRotation) > 0.5f)) { existing.name = SpinesName + "_Removed"; @@ -474,7 +484,7 @@ namespace RacesOfValheim bone, SpinesName, SvermConfig.SpinesPrefab, - Vector3.zero, + new Vector3(0f, wantedOffsetY / lossy, 0f), wantedRotation, wanted / lossy, "Sverm"); @@ -484,6 +494,7 @@ namespace RacesOfValheim SvermSpineTag built = holder.AddComponent(); built.Size = wanted; built.Rotation = wantedRotation; + built.OffsetY = wantedOffsetY; existing = holder.transform; } @@ -532,6 +543,7 @@ namespace RacesOfValheim { public float Size; public Quaternion Rotation = Quaternion.identity; + public float OffsetY; } // ─── Glide motes ───────────────────────────────────────────────────── diff --git a/README.md b/README.md index 68ac96b..c0e1878 100644 --- a/README.md +++ b/README.md @@ -412,6 +412,13 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.21 +- **Fix - Other players saw Moder, the Drake and Fader at full size no matter what:** the dragon forms' own size (Moder's shrink included) was only ever applied on the transformed player's own screen — every other client built the remote copy at the prefab's raw scale. Two Skadi players who both turned into Moder each saw themselves correctly and the other one full-sized. Thanks to the tester who caught it from a second Skadi. +- **Fix - Drake and Moder's bite, claw and breath attacks played no animation for onlookers:** the attack trigger was only ever set on the transforming player's own Animator, so everyone else saw the form fly, walk and idle but never actually swing or breathe. The trigger now reaches every other client too. +- **Fix - Sverm Ravager Strain was invisible to everyone but the player using it:** the whole form — the model, the hidden human body, the attacks — was built entirely around the local player and never told the ZDO it was active. Other players saw a Sverm standing still for the whole two minutes with no Brute in sight. It is now networked the same way the Skadi and Fenrir forms already are. +- **Fix - The Sverm's dorsal spines were mounted up over the shoulders, onto the face:** the crest was based at its mount bone and grown upward from there, which reached past the head once the Full Crest size (Queen tier on) came in. It is now centred on the bone instead, with a live "Offset Y" knob under `[Sverm - Dorsal Spines]` in Configuration Manager for any further nudging. Thanks to the tester who sent the screenshot. +- **Changed - The Sverm's dorsal spines are 30% smaller:** 0.45 m down to 0.315 m from Moder to the Queen, 0.8 m down to 0.56 m from the Queen on. + ### v1.4.20 - **Fix - A refused race building still took your materials:** building something your race is not allowed to build, or before its boss has fallen, showed the refusal and then charged the full cost anyway — a non-Sverm trying the Brood Mound got "Only the Sverm can raise a hive." and lost 40 wood and 20 resin. The refusal stopped the building, but Valheim takes the cost in a separate step that never heard about it. Now a refused building costs nothing, no stamina included. This covered every locked building in the mod: the Sverm hive and market (and the one-hive-per-area limit), the Skadi golem, the Dvergar contract bank and barrel, the Trenta Elder Root and the Trol totem. Thanks to the tester who noticed the wood going missing. - **Fix - On a gamepad the Skadi cast the Cold Spell every time she built:** the spell sits on the pad's secondary attack button, which Valheim also uses to remove pieces (Classic layout) or place them (Alt 2). Every piece built or removed also cast the spell and drained stamina, which made building nearly impossible. The spell no longer casts while you hold the hammer, hoe or cultivator — on the keyboard as well, where middle mouse is Remove. diff --git a/manifest.json b/manifest.json index 4c8d434..3baa445 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.20", + "version_number": "1.4.21", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 9bebcf340b1e7ab812adf047045a6cbc5c7ea684 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 24 Sep 2026 10:30:39 +0200 Subject: [PATCH 036/273] bugfix 24/09/26 --- JotunnModStub/Aswid/AswidBloodRefinery.cs | 11 +- JotunnModStub/Fenrir/FenrirBehaviors.cs | 198 +++++++++++++++++++--- JotunnModStub/Fenrir/FenrirRace.cs | 16 +- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RacesOfValheim.cs | 2 +- README.md | 5 + manifest.json | 2 +- 7 files changed, 205 insertions(+), 31 deletions(-) diff --git a/JotunnModStub/Aswid/AswidBloodRefinery.cs b/JotunnModStub/Aswid/AswidBloodRefinery.cs index 1990b1e..c89a2fd 100644 --- a/JotunnModStub/Aswid/AswidBloodRefinery.cs +++ b/JotunnModStub/Aswid/AswidBloodRefinery.cs @@ -234,8 +234,11 @@ namespace RacesOfValheim refinery.m_haveMeatObject = smelter.m_haveOreObject; refinery.m_noMeatObject = smelter.m_noOreObject; refinery.m_animators = smelter.m_animators; - refinery.m_meatAddedEffects = smelter.m_oreAddedEffects; - refinery.m_boneAddedEffects = smelter.m_fuelAddedEffects; + // Crossed on purpose: the sounds sit the other way round from the slots. The ore + // effect is the dry clatter and the fuel effect the wet slap, so flesh takes the + // fuel one and bone the ore one. + refinery.m_meatAddedEffects = smelter.m_fuelAddedEffects; + refinery.m_boneAddedEffects = smelter.m_oreAddedEffects; refinery.m_produceEffects = smelter.m_produceEffects; refinery.m_smokeSpawner = smelter.m_smokeSpawner; @@ -243,8 +246,8 @@ namespace RacesOfValheim // Two Radiators under _enabled are what shot the tester: see IsOffensive. StripOffensive(prefab, PieceName); - SanitiseEffects(refinery.m_meatAddedEffects, PieceName + ".oreAdded"); - SanitiseEffects(refinery.m_boneAddedEffects, PieceName + ".fuelAdded"); + SanitiseEffects(refinery.m_meatAddedEffects, PieceName + ".fuelAdded"); + SanitiseEffects(refinery.m_boneAddedEffects, PieceName + ".oreAdded"); SanitiseEffects(refinery.m_produceEffects, PieceName + ".produce"); prefab.transform.localScale = Vector3.one * ModelScale; diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 19e880a..2d1180c 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -39,6 +39,73 @@ namespace RacesOfValheim } } + /// + /// The attack half of somebody else's form: the owner's client publishes each trigger it fires + /// on its own copy of the Animator, RemoteFenrirAnimator replays it on the copy every other + /// client sees. The running count rides along because an unchanged ZDO string would never + /// re-fire a Unity Animator trigger when the same bite lands twice in a row - the same trick as + /// DrakeFormBehavior.AttackTriggerKey and SvermRavagerForm.AttackTriggerKey. + /// + public static class FenrirAttackSync + { + public const string Key = "RacesOfValheim_FenrirAttack"; + private static int seq = 0; + + // The cultist's flame is a held bool on the Animator, not a one-shot trigger, so it gets a + // key of its own: a sequence number would say "it started" but never "it stopped". + public const string FireKey = "RacesOfValheim_FenrirFire"; + + /// + /// The flame the cultist breathes, parented to the given player so it follows them. One + /// place for it because the owner's own copy and every onlooker's copy have to look alike. + /// + public static GameObject SpawnFlames(Player player) + { + if (player == null || ZNetScene.instance == null) return null; + + // Un effetto che dura nel tempo, trovato dai log! + GameObject fireVfx = ZNetScene.instance.GetPrefab("fx_fenring_flames"); + if (fireVfx == null) return null; + + GameObject instance = Object.Instantiate(fireVfx, player.transform.position + Vector3.up * 1.5f + player.transform.forward, player.transform.rotation, player.transform); + + // Aumentiamo la durata delle particelle del 20% + foreach (ParticleSystem ps in instance.GetComponentsInChildren()) + { + var main = ps.main; + main.startLifetimeMultiplier *= 1.2f; + } + return instance; + } + + public static void PublishFire(bool on) + { + Player player = Player.m_localPlayer; + ZNetView nview = player != null ? player.GetComponent() : null; + if (nview == null || !nview.IsValid()) return; + + nview.GetZDO().Set(FireKey, on); + } + + /// + /// Publishes a trigger, and with it the swing's sound: the candidate prefab names in the + /// order the owner's own PlaySFX would try them, or "@Creature" for a howl borrowed from + /// that creature's alert effect. Only the opening cue rides along; the impact sounds are + /// decided by what the swing hits, which an onlooker's client never works out. + /// + public static void Publish(string trigger, params string[] sfx) + { + Player player = Player.m_localPlayer; + ZNetView nview = player != null ? player.GetComponent() : null; + if (nview == null || !nview.IsValid()) return; + + seq++; + string payload = trigger + "#" + seq; + if (sfx != null && sfx.Length > 0) payload += "#" + string.Join("|", sfx); + nview.GetZDO().Set(Key, payload); + } + } + /// /// The animation half of somebody else's form. /// @@ -59,15 +126,23 @@ namespace RacesOfValheim /// Kept next to the four local behaviours on purpose: this mirrors the movement half of their /// Update, and the two have to be changed together. /// - /// Attacks are not mirrored. Those are triggers fired from input on the owner's client and - /// nothing replicates them, so a remote form still bites in silence - that needs a counter of - /// its own on the ZDO and is a separate job. + /// Attacks are triggers fired from input on the owner's client; FenrirAttackSync publishes + /// each one on the ZDO and this component replays it below. /// public class RemoteFenrirAnimator : MonoBehaviour { private Player player; private Animator playerAnim; private Animator formAnim; + private ZNetView nview; + private string lastAttack; + private GameObject flames; + + // The flames hang off the player, not this model, so they outlive it unless taken down. + private void OnDestroy() + { + if (flames != null) Destroy(flames); + } private void Update() { @@ -84,6 +159,9 @@ namespace RacesOfValheim } if (formAnim == null || playerAnim == null) return; + ReplayAttack(); + ReplayFire(); + bool grounded = playerAnim.GetBool("onGround"); // All four borrowed creatures answer to these, and they are still written through @@ -99,6 +177,84 @@ namespace RacesOfValheim try { formAnim.SetFloat("forward_speed", still ? 0f : playerAnim.GetFloat("forward_speed")); } catch {} try { formAnim.SetFloat("sideway_speed", still ? 0f : playerAnim.GetFloat("sideway_speed")); } catch {} } + + // Written every frame while the flag is set, and only when the controller has the bool: a + // wolf or a Ulv has no "attack_fire", and the ZDO key is only ever true for the cultist. + private void ReplayFire() + { + if (nview == null || !nview.IsValid()) return; + + bool fire = nview.GetZDO().GetBool(FenrirAttackSync.FireKey, false); + + // The breath itself: up while the flag is, gone when it drops. Only the cultist ever + // sets the flag, so no other form can grow flames here. + if (fire && flames == null) + { + flames = FenrirAttackSync.SpawnFlames(player); + + // The roar that opens the breath, once per start, the same cue the owner hears. + GameObject sfx = PrefabManager.Cache.GetPrefab("sfx_cultist_attack_fire_start"); + if (sfx != null) Instantiate(sfx, player.transform.position, Quaternion.identity); + } + else if (!fire && flames != null) { Destroy(flames); flames = null; } + + foreach (AnimatorControllerParameter p in formAnim.parameters) + { + if (p.type == AnimatorControllerParameterType.Bool && p.name == "attack_fire") + { + formAnim.SetBool("attack_fire", fire); + break; + } + } + } + + private void PlayAttackSound(string[] names) + { + foreach (string name in names) + { + if (name.StartsWith("@")) + { + FenrirCreatureSound.PlayHowl(name.Substring(1), player.transform.position); + return; + } + + GameObject sfx = PrefabManager.Cache.GetPrefab(name); + if (sfx != null) + { + Instantiate(sfx, player.transform.position, Quaternion.identity); + return; + } + } + } + + private void ReplayAttack() + { + if (nview == null) nview = player.GetComponent(); + if (nview == null || !nview.IsValid()) return; + + string current = nview.GetZDO().GetString(FenrirAttackSync.Key, ""); + + // First look at the ZDO only records what is already there, so a trigger left over from + // an earlier form does not replay the instant this model is built. + if (lastAttack == null) { lastAttack = current; return; } + if (string.IsNullOrEmpty(current) || current == lastAttack) return; + lastAttack = current; + + string[] parts = current.Split('#'); + string trigger = parts[0]; + if (parts.Length > 2) PlayAttackSound(parts[2].Split('|')); + + // Only the triggers this particular borrowed controller actually has: the four forms + // share none of the attack names but the taunt. + foreach (AnimatorControllerParameter p in formAnim.parameters) + { + if (p.type == AnimatorControllerParameterType.Trigger && p.name == trigger) + { + formAnim.SetTrigger(trigger); + break; + } + } + } } public class FenrirFormBehavior : MonoBehaviour @@ -192,6 +348,7 @@ namespace RacesOfValheim fenrirAnim.SetFloat("sideway_speed", 0f); fenrirAnim.SetTrigger("attack_taunt"); + FenrirAttackSync.Publish("attack_taunt", "@Fenring"); FenrirCreatureSound.PlayHowl("Fenring", Player.m_localPlayer.transform.position); @@ -208,6 +365,7 @@ namespace RacesOfValheim fenrirAnim.SetFloat("sideway_speed", 0f); fenrirAnim.SetTrigger(triggerName); + FenrirAttackSync.Publish(triggerName, "sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack"); PlaySFX("sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack"); yield return new WaitForSeconds(dmgDelay); @@ -241,6 +399,7 @@ namespace RacesOfValheim fenrirAnim.SetFloat("sideway_speed", 0f); fenrirAnim.SetTrigger("attack_jump"); + FenrirAttackSync.Publish("attack_jump"); // Aspettiamo che l'animazione si carichi (0.75s) yield return new WaitForSeconds(0.75f); @@ -477,6 +636,7 @@ namespace RacesOfValheim // Cultist ha una vera e propria animazione di "taunt" cultistAnim.SetTrigger("attack_taunt"); + FenrirAttackSync.Publish("attack_taunt", "@Fenring_Cultist"); FenrirCreatureSound.PlayHowl("Fenring_Cultist", Player.m_localPlayer.transform.position); @@ -496,27 +656,13 @@ namespace RacesOfValheim cultistAnim.SetFloat("forward_speed", 0f); cultistAnim.SetFloat("sideway_speed", 0f); cultistAnim.SetBool("attack_fire", true); + FenrirAttackSync.PublishFire(true); PlaySFX("sfx_cultist_attack_fire_start"); cultistAnim.SetTrigger("attack_flames"); + FenrirAttackSync.Publish("attack_flames"); - if (ZNetScene.instance != null && fireEffectInstance == null) - { - // Un effetto che dura nel tempo, trovato dai log! - GameObject fireVfx = ZNetScene.instance.GetPrefab("fx_fenring_flames"); - if (fireVfx != null) - { - fireEffectInstance = Instantiate(fireVfx, Player.m_localPlayer.transform.position + Vector3.up * 1.5f + Player.m_localPlayer.transform.forward, Player.m_localPlayer.transform.rotation, Player.m_localPlayer.transform); - - // Aumentiamo la durata delle particelle del 20% - ParticleSystem[] pss = fireEffectInstance.GetComponentsInChildren(); - foreach (ParticleSystem ps in pss) - { - var main = ps.main; - main.startLifetimeMultiplier *= 1.2f; - } - } - } + if (fireEffectInstance == null) fireEffectInstance = FenrirAttackSync.SpawnFlames(Player.m_localPlayer); } private void UpdateFire() @@ -533,10 +679,17 @@ namespace RacesOfValheim } } + // Leaving the form mid-flame must not leave the flag up for onlookers. + private void OnDestroy() + { + if (isShootingFire) FenrirAttackSync.PublishFire(false); + } + private void StopFire() { isShootingFire = false; cultistAnim.ResetTrigger("attack_flames"); + FenrirAttackSync.PublishFire(false); if (fireEffectInstance != null) { @@ -617,6 +770,7 @@ namespace RacesOfValheim // Per il Cultista usiamo esplicitamente il trigger dell'artigliata cultistAnim.SetTrigger("attack_claw"); + FenrirAttackSync.Publish("attack_claw", "sfx_cultist_attack", "sfx_fenring_attack", "sfx_wolf_attack"); yield return new WaitForSeconds(0.4f); @@ -642,6 +796,7 @@ namespace RacesOfValheim cultistAnim.SetFloat("sideway_speed", 0f); cultistAnim.SetTrigger("attack_claw_double"); + FenrirAttackSync.Publish("attack_claw_double", "sfx_cultist_attack_double", "sfx_cultist_attack", "sfx_fenring_attack"); // L'animazione double claw è più lunga, facciamo il danno un po' dopo yield return new WaitForSeconds(0.6f); @@ -805,6 +960,7 @@ namespace RacesOfValheim try { wolfAnim.SetFloat("sideway_speed", 0f); } catch {} wolfAnim.SetTrigger(triggerName); + FenrirAttackSync.Publish(triggerName, "sfx_wolf_attack"); yield return new WaitForSeconds(dmgDelay); @@ -979,6 +1135,7 @@ namespace RacesOfValheim try { ulvAnim.SetFloat("sideway_speed", 0f); } catch {} try { ulvAnim.SetTrigger(triggerName); } catch {} + FenrirAttackSync.Publish(triggerName, "sfx_ulv_attack", "sfx_wolf_attack", "sfx_fenring_attack"); // Scegli il suono appropriato per l'attacco if (triggerName == "attack_bite") @@ -1084,6 +1241,7 @@ namespace RacesOfValheim try { ulvAnim.SetFloat("sideway_speed", 0f); } catch {} try { ulvAnim.SetTrigger("attack_slash"); } catch {} + FenrirAttackSync.Publish("attack_slash", "sfx_ulv_attack", "sfx_wolf_attack"); PlaySFX("sfx_ulv_attack", "sfx_wolf_attack"); yield return new WaitForSeconds(0.3f); // Wait 0.3s before leaping diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index 51617c8..784cffd 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -135,9 +135,15 @@ namespace RacesOfValheim { } else if (!isNight && wasNight) { - // Sunrise: force revert and block transforming again for a while - sunSicknessTimer = FenrirConfig.SunSicknessDuration.Value; - ForceRevert(); + // Sunrise: a form that was granted for the night only is taken back, and the + // beast is tired for a while. A form the progression lets through by day (Queen's + // Fenrir, Fader's Cultist, Bonemass's Wolf) is not the sun's to take: activeRules is + // what the transform was actually granted under. + if (activeRules == null || activeRules.NeedsNight) + { + sunSicknessTimer = FenrirConfig.SunSicknessDuration.Value; + ForceRevert(); + } } wasNight = isNight; @@ -166,7 +172,9 @@ namespace RacesOfValheim { { if (rules == null || rules.Form == FenrirProgression.FormType.None) return; - if (sunSicknessTimer > 0f) + // The tiredness is the sun's doing, so it only stands in the way of a night form; the + // forms allowed by day would otherwise be locked out right after every sunrise. + if (rules.NeedsNight && sunSicknessTimer > 0f) { Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The beast is tired"); return; diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 3baa445..14ffb1a 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.21", + "version_number": "1.4.22", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 009df99..e5b9d0a 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.21"; + public const string PluginVersion = "1.4.22"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/README.md b/README.md index c0e1878..d7f1b85 100644 --- a/README.md +++ b/README.md @@ -412,6 +412,11 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.22 +- **Fix - Other players saw Fenrir forms standing silent:** every form's attacks - the Fenring's claws, the Cultist's claws and flames, the Wolf's and the Ulv's bites - were only ever triggered on the transformed player's own Animator, so onlookers saw the form run but never swing. The attacks now reach every other client, along with the opening sound of each swing and the howls. The Cultist's flame breath, its roar and the fire itself are shown to onlookers too. The sounds of the impact itself and the Fenring's jump are still heard only by the player who makes them. +- **Fix - Fenrir players turned back to human at every sunrise, even with a form the day allows:** after the Queen the Fenring form (and the Wolf after Bonemass, the Cultist after Fader) is meant to work day and night, but sunrise took it away regardless. Only forms granted for the night alone are taken back now, and "The beast is tired" no longer blocks the daytime forms either. Thanks to the tester who noticed it. +- **Fix - The Aswid's Blood Refinery had the insertion sounds the wrong way round:** flesh and bone played each other's sound. They are swapped. + ### v1.4.21 - **Fix - Other players saw Moder, the Drake and Fader at full size no matter what:** the dragon forms' own size (Moder's shrink included) was only ever applied on the transformed player's own screen — every other client built the remote copy at the prefab's raw scale. Two Skadi players who both turned into Moder each saw themselves correctly and the other one full-sized. Thanks to the tester who caught it from a second Skadi. - **Fix - Drake and Moder's bite, claw and breath attacks played no animation for onlookers:** the attack trigger was only ever set on the transforming player's own Animator, so everyone else saw the form fly, walk and idle but never actually swing or breathe. The trigger now reaches every other client too. diff --git a/manifest.json b/manifest.json index 3baa445..14ffb1a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.21", + "version_number": "1.4.22", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From f64fe83d9d9385b97f80412faa5c9fc4faa4b1c2 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 25 Sep 2026 12:26:51 +0200 Subject: [PATCH 037/273] bugfix 25/09/26 --- JotunnModStub/ConfigSync.cs | 96 ++++++++++++++++++++++++ JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RacesOfValheim.cs | 4 +- JotunnModStub/Trol/TrolFarmingPatches.cs | 11 +-- README.md | 4 + manifest.json | 2 +- 6 files changed, 111 insertions(+), 8 deletions(-) create mode 100644 JotunnModStub/ConfigSync.cs diff --git a/JotunnModStub/ConfigSync.cs b/JotunnModStub/ConfigSync.cs new file mode 100644 index 0000000..fb38b9c --- /dev/null +++ b/JotunnModStub/ConfigSync.cs @@ -0,0 +1,96 @@ +using System; +using System.Linq; +using System.Reflection; +using BepInEx.Configuration; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Marks every gameplay config entry as admin-only so Jotunn syncs it from the server to the + /// clients (and locks it for non-admins in Configuration Manager). + /// + /// Jotunn only recognises ITS OWN ConfigurationManagerAttributes (global namespace, in + /// Jotunn.dll) as a tag - it does an `is` check, not the field-name duck typing Configuration + /// Manager does - so our internal look-alike tag is not enough. This runs once after every + /// Bind() and adds Jotunn's tag beside whatever tags the entry already has, rather than + /// touching each of the ~350 Bind() calls. + /// + /// Left local, because they are per-player preferences and syncing them would only take the + /// choice away from the player: keybinds, and the purely cosmetic entries (eye/claw colours, + /// glow, tint, rotation and offset of models, the VFX toggle, the stamina-bar toggle, debug + /// logging). Anything that changes a number the game computes with stays synced. + /// + internal static class ConfigSync + { + // Whole sections that are cosmetic or per-player. + private static readonly string[] LocalSections = + { + "Aswid - Claws", + "Aswid - Eyes", + "Skeleton - Visuals", + "Sverm - Dorsal Spines", + "Sverm - Emberform", + "War Vulture - Model", + "War Vulture - Interface", + }; + + // Cosmetic entries scattered through otherwise gameplay sections. + private static readonly string[] LocalKeyParts = + { + "marker light", "tint", "colour", "color", "glow", "swarm scale", "log rounds", "debug", + }; + + public static void Apply(ConfigFile config) + { + FieldInfo descField = typeof(ConfigEntryBase) + .GetFields(BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public) + .FirstOrDefault(f => f.FieldType == typeof(ConfigDescription)); + if (descField == null) + { + Debug.LogWarning("[RacesOfValheim] Config sync skipped: ConfigEntryBase has no ConfigDescription field."); + return; + } + + int synced = 0, local = 0; + foreach (ConfigDefinition def in config.Keys.ToList()) + { + ConfigEntryBase entry = config[def]; + if (!ShouldSync(entry)) { local++; continue; } + + ConfigDescription old = entry.Description; + object[] tags = (old.Tags ?? new object[0]).Concat(new object[] + { + new global::ConfigurationManagerAttributes { IsAdminOnly = true } + }).ToArray(); + descField.SetValue(entry, new ConfigDescription(old.Description, old.AcceptableValues, tags)); + synced++; + } + Debug.Log($"[RacesOfValheim] Config sync: {synced} entries admin-synced, {local} left local."); + } + + private static bool ShouldSync(ConfigEntryBase entry) + { + Type type = entry.SettingType; + if (type == typeof(KeyboardShortcut) || type == typeof(KeyCode)) return false; + + string section = entry.Definition.Section ?? ""; + string key = (entry.Definition.Key ?? "").ToLowerInvariant(); + + if (section.EndsWith("Keybinds", StringComparison.OrdinalIgnoreCase)) return false; + if (LocalSections.Contains(section, StringComparer.OrdinalIgnoreCase)) return false; + if (LocalKeyParts.Any(key.Contains)) return false; + + // Model pose nudges (rotation/offset/yaw) are cosmetic, but "Attack Reach Offset" is a + // real hit-detection distance and must stay in step with the server. + if ((key.Contains("rotation") || key.Contains("offset") || key.Contains("yaw")) + && !key.Contains("reach")) return false; + + // Decorative note lines (CustomDrawer/ReadOnly) carry no value worth sending. + ConfigurationManagerAttributes ours = (entry.Description?.Tags ?? new object[0]).OfType().FirstOrDefault(); + if (ours != null && (ours.CustomDrawer != null || ours.ReadOnly == true)) return false; + + return true; + } + } +} diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 14ffb1a..fc74963 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.22", + "version_number": "1.4.23", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index e5b9d0a..7061303 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.22"; + public const string PluginVersion = "1.4.23"; private readonly Harmony harmony = new Harmony(PluginGUID); @@ -52,6 +52,8 @@ namespace RacesOfValheim // Not a race either: the faction truce and the faction merchants, which cut across // every race at once, so they bind last rather than inside the alphabetical run above. FactionsConfig.Bind(Config); + // After every Bind above: tags the gameplay entries for Jotunn's server-to-client sync. + ConfigSync.Apply(Config); harmony.PatchAll(); gameObject.AddComponent(); gameObject.AddComponent(); diff --git a/JotunnModStub/Trol/TrolFarmingPatches.cs b/JotunnModStub/Trol/TrolFarmingPatches.cs index 1e43a40..00be181 100644 --- a/JotunnModStub/Trol/TrolFarmingPatches.cs +++ b/JotunnModStub/Trol/TrolFarmingPatches.cs @@ -51,7 +51,8 @@ namespace RacesOfValheim } } - [HarmonyPatch(typeof(TreeBase), "RPC_Damage")] + // Patched on Damage (attacker side), not RPC_Damage: the RPC runs on the object owner (host), where the attacker is not the local player. + [HarmonyPatch(typeof(TreeBase), "Damage")] public static class Trol_TreeBase_RPC_Damage_Patch { public static void Prefix(HitData hit) @@ -60,7 +61,7 @@ namespace RacesOfValheim } } - [HarmonyPatch(typeof(TreeLog), "RPC_Damage")] + [HarmonyPatch(typeof(TreeLog), "Damage")] public static class Trol_TreeLog_RPC_Damage_Patch { public static void Prefix(HitData hit) @@ -69,7 +70,7 @@ namespace RacesOfValheim } } - [HarmonyPatch(typeof(Destructible), "RPC_Damage")] + [HarmonyPatch(typeof(Destructible), "Damage")] public static class Trol_Destructible_RPC_Damage_Patch { public static void Prefix(HitData hit, Destructible __instance) @@ -81,7 +82,7 @@ namespace RacesOfValheim } } - [HarmonyPatch(typeof(MineRock), "RPC_Hit")] + [HarmonyPatch(typeof(MineRock), "Damage")] public static class Trol_MineRock_RPC_Hit_Patch { public static void Prefix(HitData hit) @@ -90,7 +91,7 @@ namespace RacesOfValheim } } - [HarmonyPatch(typeof(MineRock5), "DamageArea")] + [HarmonyPatch(typeof(MineRock5), "Damage")] public static class Trol_MineRock5_DamageArea_Patch { public static void Prefix(HitData hit) diff --git a/README.md b/README.md index d7f1b85..010b03d 100644 --- a/README.md +++ b/README.md @@ -412,6 +412,10 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.23 +- **Fix - Trol clients could not chop trees or mine rocks with their fists:** the fist bonus (chop and pickaxe damage, and the tool tier that grows with the bosses) was applied on whichever machine owned the tree or rock - usually the host - where the hit did not belong to the local player, so it only ever worked for the host. It is now applied on the attacking player's own machine before the hit is sent. Thanks to the players who reported it. +- **New - Configuration is synced from the server:** every gameplay setting now follows the server's value in multiplayer, and is locked in Configuration Manager for players who are not admins. Keybinds and the purely cosmetic settings (eye and claw colours, glow, model rotation and offsets, the Head Fire VFX and stamina-bar toggles, debug logging) stay local, so each player keeps their own. + ### v1.4.22 - **Fix - Other players saw Fenrir forms standing silent:** every form's attacks - the Fenring's claws, the Cultist's claws and flames, the Wolf's and the Ulv's bites - were only ever triggered on the transformed player's own Animator, so onlookers saw the form run but never swing. The attacks now reach every other client, along with the opening sound of each swing and the howls. The Cultist's flame breath, its roar and the fire itself are shown to onlookers too. The sounds of the impact itself and the Fenring's jump are still heard only by the player who makes them. - **Fix - Fenrir players turned back to human at every sunrise, even with a form the day allows:** after the Queen the Fenring form (and the Wolf after Bonemass, the Cultist after Fader) is meant to work day and night, but sunrise took it away regardless. Only forms granted for the night alone are taken back now, and "The beast is tired" no longer blocks the daytime forms either. Thanks to the tester who noticed it. diff --git a/manifest.json b/manifest.json index 14ffb1a..fc74963 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.22", + "version_number": "1.4.23", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 00d4fd6e4688cd39fff34ff02a14acf1cbd893e3 Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 25 Sep 2026 15:54:21 +0200 Subject: [PATCH 038/273] fix(skeleton): stop the fire aura borrowing another mod's VFX by name The tier-5 fire aura looked for "vfx_smoke", then "vfx_surtling_death". Neither name exists in Valheim, checked against the game's own asset manifests, so both lookups came back null and the aura has never been visible in a plain install. The dead branch was not harmless. PrefabManager.Cache resolves by asset name across everything in memory, other mods' asset bundles included, and its tie-break for a duplicate name ends in "newest wins". A name vanilla does not use has no vanilla candidate to beat, so it is a free slot. Magic_Supremacy fills it. The lookup resolved to 'EncounterCreatureRikoMountain_DO/vfx_smoke', a child node of one of its creatures carrying 'club_trail_riko_DO' on 'Dreanegade/ParticleAlphaEmission' - a weapon trail, on an emissive shader, sprayed through a 4.5m sphere on the player. That is the purple smoke around the burning skull users reported, on every client that could see the skeleton. The aura now draws nothing on purpose, which costs it nothing it had. Its damage, radius and tick are untouched. The two identical EnsureFireAuraVFX copies in SkeletonRace and ZdoVisualSync are replaced by one SkeletonVisuals.EnsureFireAura, shaped like DraughVisuals.EnsureAura; the call sites stay, so reinstating the visual needs no change in either file. The comment on it records the whole chain and the way to build it properly, through BorrowEffect, the way HeadFlame already does. Also keeps a resolution log on the model lookup: every magic mod in the report ships an object called "Skeleton", which is this race's own tier-0 model name. The vanilla creature won during the repro; root=False in that log is what says it stopped winning. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Skeleton/SkeletonPatches.cs | 8 +++ JotunnModStub/Skeleton/SkeletonRace.cs | 79 +------------------- JotunnModStub/Skeleton/SkeletonVisuals.cs | 87 +++++++++++++++++++++++ JotunnModStub/ZdoVisualSync.cs | 72 ++----------------- 4 files changed, 102 insertions(+), 144 deletions(-) diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index 78b1cf2..10fdf7d 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -283,6 +283,14 @@ namespace RacesOfValheim if (skeletonBodyTransform == null) { GameObject skelPrefab = PrefabManager.Cache.GetPrefab(rules.ModelPrefab); + + // The cache answers by name alone, and every magic mod named in the + // purple-smoke report carries an object of its own called "Skeleton" - + // which is this race's own tier-0 model name. So far the vanilla + // creature has always won; the log is here to say so, or to say which + // mod's object took its place. See SkeletonVisuals.EnsureFireAura. + SkeletonVisuals.LogResolvedPrefabOnce("model " + rules.ModelPrefab, skelPrefab); + if (skelPrefab == null) { // The human body was switched off two lines up, so an unresolved diff --git a/JotunnModStub/Skeleton/SkeletonRace.cs b/JotunnModStub/Skeleton/SkeletonRace.cs index 90311d6..3f0a3cb 100644 --- a/JotunnModStub/Skeleton/SkeletonRace.cs +++ b/JotunnModStub/Skeleton/SkeletonRace.cs @@ -279,7 +279,7 @@ namespace RacesOfValheim // only path taken once they stop being one. A Fader-tier Skeleton who reset to // Human kept a burning skull and a collapsed jaw, since neither the flame nor the // jaw was ever switched back from outside the Skeleton branch below. - EnsureFireAuraVFX(false); + SkeletonVisuals.EnsureFireAura(Player.m_localPlayer, false, ref fireAuraVFX); headFlame.Apply(Player.m_localPlayer, false); RestoreJawBone(); @@ -446,7 +446,7 @@ namespace RacesOfValheim if (rules.FireAura) { - EnsureFireAuraVFX(true); + SkeletonVisuals.EnsureFireAura(Player.m_localPlayer, true, ref fireAuraVFX); if (Time.time - lastAuraTime >= SkeletonConfig.FireAuraTickInterval.Value) { ApplyFireAura(); @@ -455,7 +455,7 @@ namespace RacesOfValheim } else { - EnsureFireAuraVFX(false); + SkeletonVisuals.EnsureFireAura(Player.m_localPlayer, false, ref fireAuraVFX); } } @@ -478,79 +478,6 @@ namespace RacesOfValheim } } - private void EnsureFireAuraVFX(bool enable) - { - if (enable && Player.m_localPlayer != null) - { - if (fireAuraVFX == null) - { - // Look for a smoke or fog effect to tint as fire fog - GameObject sourceVFX = PrefabManager.Cache.GetPrefab("vfx_smoke") ?? - PrefabManager.Cache.GetPrefab("vfx_surtling_death"); - - fireAuraVFX = new GameObject("SkeletonFireAuraVFX"); - fireAuraVFX.transform.SetParent(Player.m_localPlayer.transform, false); - fireAuraVFX.transform.localPosition = new Vector3(0, 1f, 0); - - if (sourceVFX != null) - { - ParticleSystem[] pss = sourceVFX.GetComponentsInChildren(); - if (pss.Length > 0) - { - ParticleSystem ps = fireAuraVFX.AddComponent(); - var main = ps.main; - main.loop = true; - main.duration = 1f; - main.startLifetime = 1.5f; - main.startSize = new ParticleSystem.MinMaxCurve(1.5f, 3f); - main.startSpeed = 0f; - main.simulationSpace = ParticleSystemSimulationSpace.World; - - var renderer = fireAuraVFX.GetComponent(); - renderer.material = pss[0].GetComponent().material; - - var shape = ps.shape; - shape.shapeType = ParticleSystemShapeType.Sphere; - shape.radius = 4.5f; // Similar to the damage radius - - var emission = ps.emission; - emission.rateOverTime = 40f; - - // Add a fire-like color gradient - var colorOverLifetime = ps.colorOverLifetime; - colorOverLifetime.enabled = true; - Gradient grad = new Gradient(); - grad.SetKeys( - new GradientColorKey[] { - new GradientColorKey(new Color(1f, 0.8f, 0.2f), 0.0f), // Yellow - new GradientColorKey(new Color(1f, 0.3f, 0.0f), 0.5f), // Orange/Red - new GradientColorKey(new Color(0.2f, 0.0f, 0.0f), 1.0f) // Dark red/smoke - }, - new GradientAlphaKey[] { - new GradientAlphaKey(0.0f, 0.0f), - new GradientAlphaKey(0.6f, 0.2f), - new GradientAlphaKey(0.6f, 0.8f), - new GradientAlphaKey(0.0f, 1.0f) - } - ); - colorOverLifetime.color = grad; - } - } - } - if (!fireAuraVFX.activeSelf) - { - fireAuraVFX.SetActive(true); - } - } - else - { - if (fireAuraVFX != null && fireAuraVFX.activeSelf) - { - fireAuraVFX.SetActive(false); - } - } - } - private void ApplyFireAura() { if (Player.m_localPlayer == null) return; diff --git a/JotunnModStub/Skeleton/SkeletonVisuals.cs b/JotunnModStub/Skeleton/SkeletonVisuals.cs index 825b64a..5f82dbc 100644 --- a/JotunnModStub/Skeleton/SkeletonVisuals.cs +++ b/JotunnModStub/Skeleton/SkeletonVisuals.cs @@ -169,6 +169,49 @@ namespace RacesOfValheim (passengers.Count == 0 ? "." : ", stripped " + string.Join(", ", passengers.ToArray()) + ".")); } + /// + /// Says what a borrowed-by-name prefab actually resolved to: which object, where it sits in + /// ITS OWN hierarchy, and the material and shader the first particle on it carries. Once per + /// name per session, so it costs a handful of lines and answers the question that took a + /// bundle extractor to answer the first time. + /// + /// READ THE root FLAG FIRST. A root-level object is a real prefab and almost certainly the + /// vanilla one. A parented one is a child node that Jotunn's cache picked up because nothing + /// better in memory answered to that name - which is what happens when the name does not + /// exist in vanilla at all, and is exactly how another mod's weapon trail ended up worn as + /// this race's fire aura. See EnsureFireAura. + /// + private static readonly HashSet loggedResolutions = new HashSet(); + + public static void LogResolvedPrefabOnce(string wanted, GameObject resolved) + { + if (!loggedResolutions.Add(wanted)) return; + + if (resolved == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] Prefab lookup '{wanted}' resolved to NOTHING."); + return; + } + + string path = resolved.name; + for (Transform t = resolved.transform.parent; t != null; t = t.parent) + { + path = t.name + "/" + path; + } + + ParticleSystem first = resolved.GetComponentInChildren(true); + ParticleSystemRenderer psr = first != null ? first.GetComponent() : null; + Material material = psr != null ? psr.sharedMaterial : null; + + Jotunn.Logger.LogInfo( + $"[Skeleton] Prefab lookup '{wanted}' resolved to '{path}' " + + $"(root={resolved.transform.parent == null}) " + + $"particle='{(first != null ? first.name : "none")}' " + + $"material='{(material != null ? material.name : "none")}' " + + $"shader='{(material != null && material.shader != null ? material.shader.name : "none")}' " + + $"startColor={(first != null ? first.main.startColor.color.ToString() : "-")}"); + } + private static GameObject cachedFlameSource; private static bool flameSourceResolved; @@ -306,6 +349,50 @@ namespace RacesOfValheim return copy; } + /// + /// The fire aura's visual, and the reason it now has none. + /// + /// The aura itself (SkeletonRace.ApplyFireAura) burns everything inside FireAuraRadius from + /// Moder on and is untouched. What is gone is the way it used to try to show itself: + /// + /// PrefabManager.Cache.GetPrefab<GameObject>("vfx_smoke") + /// ?? PrefabManager.Cache.GetPrefab<GameObject>("vfx_surtling_death") + /// + /// NEITHER NAME EXISTS IN VALHEIM. Checked against the game's own asset manifest: there is no + /// vfx_smoke, and no surtling death effect under any spelling. In a plain install both + /// lookups came back null, no particle system was ever added, and this aura has never been + /// visible to anybody since the day it was written. + /// + /// A dead branch would be harmless if the lookup were harmless. It is not. PrefabManager.Cache + /// is, in Jotunn's own words, a "global cache of Unity Objects by asset name" built with + /// Resources.FindObjectsOfTypeAll, so it answers with anything in memory - including the + /// contents of every other mod's asset bundle - and its tie-break for a duplicate name ends + /// in "the newly discovered object replaces the cached one". A name vanilla does not use has + /// no vanilla candidate to beat, which leaves it a free slot for whoever ships one. + /// + /// Somebody shipped one. With Magic_Supremacy installed the lookup resolved to + /// 'EncounterCreatureRikoMountain_DO/vfx_smoke' - a CHILD node of one of that mod's + /// creatures, carrying the material 'club_trail_riko_DO' on the shader + /// 'Dreanegade/ParticleAlphaEmission'. A weapon trail, on an emissive shader, sprayed through + /// a 4.5m sphere centred on the player: the purple smoke around the burning skull this race + /// was reported for, on every client that could see the skeleton. + /// + /// So the aura is invisible deliberately now, which costs it nothing it ever had. To give it + /// a look, build it the way HeadFlame does: resolve a prefab under a name vanilla really uses + /// (ResolveFlameSource already holds one that works) and clone it through BorrowEffect, + /// instead of hand-rolling a particle system around a material taken by name. + /// + public static void EnsureFireAura(Player player, bool enable, ref GameObject aura) + { + // Nothing is built, so there is nothing to switch on either way - but a leftover is + // destroyed rather than left riding the player, which is what a session that swapped + // this assembly in mid-flight would otherwise be stuck with. + if (aura == null) return; + + Object.Destroy(aura); + aura = null; + } + /// /// One player's burning skull. Cosmetic only - it deals nothing and blocks nothing. /// diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs index ecff680..686a831 100644 --- a/JotunnModStub/ZdoVisualSync.cs +++ b/JotunnModStub/ZdoVisualSync.cs @@ -173,8 +173,9 @@ namespace RacesOfValheim m_player.transform.localScale = targetScale; } - // Fire Aura VFX - EnsureFireAuraVFX(rules.FireAura); + // Deliberately draws nothing - see SkeletonVisuals.EnsureFireAura for why. Called + // anyway so reinstating the visual needs no change here. + SkeletonVisuals.EnsureFireAura(m_player, rules.FireAura, ref m_fireAuraVFX); } private void UpdateFenrirVisuals() @@ -263,7 +264,7 @@ namespace RacesOfValheim PlayerVisualHider.Show(playerVisual, "zdosync-revert"); if (m_currentFormInstance != null) Destroy(m_currentFormInstance); - EnsureFireAuraVFX(false); + SkeletonVisuals.EnsureFireAura(m_player, false, ref m_fireAuraVFX); DraughVisuals.EnsureAura(m_player, false, ref m_draughAuraVFX); m_skeletonHeadFlame.Apply(m_player, false); // Takes the crown off a Trenta who has died or changed race; a no-op for everyone else. @@ -283,70 +284,5 @@ namespace RacesOfValheim m_lastFenrirForm = ""; m_lastSkadiForm = ""; } - - private void EnsureFireAuraVFX(bool enable) - { - if (enable) - { - if (m_fireAuraVFX == null) - { - GameObject sourceVFX = Jotunn.Managers.PrefabManager.Cache.GetPrefab("vfx_smoke") ?? - Jotunn.Managers.PrefabManager.Cache.GetPrefab("vfx_surtling_death"); - - m_fireAuraVFX = new GameObject("SkeletonFireAuraVFX"); - m_fireAuraVFX.transform.SetParent(m_player.transform, false); - m_fireAuraVFX.transform.localPosition = new Vector3(0, 1f, 0); - - if (sourceVFX != null) - { - ParticleSystem[] pss = sourceVFX.GetComponentsInChildren(); - if (pss.Length > 0) - { - ParticleSystem ps = m_fireAuraVFX.AddComponent(); - var main = ps.main; - main.loop = true; - main.duration = 1f; - main.startLifetime = 1.5f; - main.startSize = new ParticleSystem.MinMaxCurve(1.5f, 3f); - main.startSpeed = 0f; - main.simulationSpace = ParticleSystemSimulationSpace.World; - - var renderer = m_fireAuraVFX.GetComponent(); - renderer.material = pss[0].GetComponent().material; - - var shape = ps.shape; - shape.shapeType = ParticleSystemShapeType.Sphere; - shape.radius = 4.5f; - - var emission = ps.emission; - emission.rateOverTime = 40f; - - var colorOverLifetime = ps.colorOverLifetime; - colorOverLifetime.enabled = true; - Gradient grad = new Gradient(); - grad.SetKeys( - new GradientColorKey[] { - new GradientColorKey(new Color(1f, 0.8f, 0.2f), 0.0f), - new GradientColorKey(new Color(1f, 0.3f, 0.0f), 0.5f), - new GradientColorKey(new Color(0.2f, 0.0f, 0.0f), 1.0f) - }, - new GradientAlphaKey[] { - new GradientAlphaKey(0.0f, 0.0f), - new GradientAlphaKey(0.6f, 0.2f), - new GradientAlphaKey(0.6f, 0.8f), - new GradientAlphaKey(0.0f, 1.0f) - } - ); - colorOverLifetime.color = grad; - } - } - } - if (!m_fireAuraVFX.activeSelf) m_fireAuraVFX.SetActive(true); - } - else - { - if (m_fireAuraVFX != null && m_fireAuraVFX.activeSelf) m_fireAuraVFX.SetActive(false); - } - } } } From e75c7072c4241f9f4b24051fa66deeebb8659f60 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 00:20:02 +0200 Subject: [PATCH 039/273] fix(prefabs): replace every lookup name that does not exist in vanilla An audit of all 59 prefab names the mod resolves, against the game's own asset manifests, found nine that are not in Valheim at all. A name vanilla does not use has no vanilla candidate to beat in Jotunn's name cache, so it is a free slot for whoever ships one - which is how another mod's weapon trail became the Skeleton's fire aura in 00d4fd6. Eight of the nine failed in silence, which is why none of them was ever reported: vfx_corpse_destruction -> _medium, _large for the Muspell. The puff that covers a transformation. Fenrir and Skadi at least had their sparks; the Muspell swapped bodies in plain view with nothing at all. vfx_surtling_death -> vfx_wraith_death for the Aswid's Mist Form, which reads as mist by construction and is the same creature the form already borrows its Visual from; vfx_corpse_destruction_medium for the thrall, where nothing is misty. Vanilla has no surtling death effect under any spelling. TrophyTroll -> TrophyForestTroll. TrophyBat -> TrophyDeathsquito. Vanilla ships no bat trophy, so the Aswid's two status effects and its radial entry had no icon. vfx_smoke -> gone. It was the Trenta's fallback for Purple Rain's particle material behind Greydwarf_Shaman, and the day the Shaman failed to resolve it would have worn whatever a mod supplies. Purple Rain is purple by design, so nobody would ever have reported it. The ninth did not fail in silence. vfx_OozeHit was passed to Instantiate unguarded, so every successful Draugh parry threw ArgumentException and took the North Wind nova below it down as well. It is vfx_blob_hit. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Aswid/AswidRace.cs | 16 ++++++++++++++-- JotunnModStub/Aswid/AswidStatusEffects.cs | 4 ++-- JotunnModStub/Aswid/AswidThrall.cs | 5 ++++- .../Draugh/DraughProgressionPatches.cs | 12 ++++++++++-- JotunnModStub/Fenrir/FenrirRace.cs | 5 ++++- JotunnModStub/RaceRadial.cs | 2 +- JotunnModStub/RacesOfValheim.cs | 5 ++++- JotunnModStub/Skadi/SkadiRace.cs | 5 ++++- JotunnModStub/Trenta/TrentaAbilities.cs | 18 ++++++++++++++++-- JotunnModStub/Trenta/TrentaMuspell.cs | 7 ++++++- 10 files changed, 65 insertions(+), 14 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 3078f06..b1f1cd2 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -708,7 +708,17 @@ namespace RacesOfValheim { isTransformingSequence = true; - GameObject poofPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab("vfx_surtling_death"); + // WAS "vfx_surtling_death", WHICH IS NOT A PREFAB IN THIS GAME. The surtling has no + // death effect under any spelling, so this resolved to nothing and the Mist Form has + // always appeared and disappeared with no puff at all - both here and in + // RevertMistFormRoutine. Kept as a note rather than a fallback: a name vanilla does not + // use is a free slot for any mod that ships one, which is how another mod's weapon trail + // became the Skeleton's fire aura (see SkeletonVisuals.EnsureFireAura). + // + // The Wraith's own death effect reads as mist by construction, which is what this wanted, + // and it is already the right creature: the form borrows the Wraith's Visual a few lines + // below. If the look wants changing, that effect is the thing to alter. + GameObject poofPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab("vfx_wraith_death"); if (poofPrefab != null) Instantiate(poofPrefab, Player.m_localPlayer.transform.position, Quaternion.identity); Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_MistForm".GetStableHashCode(), true); @@ -763,7 +773,9 @@ namespace RacesOfValheim { isTransformingSequence = true; - GameObject poofPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab("vfx_surtling_death"); + // The same puff as going in - see TransformIntoMistRoutine for why the old name never + // resolved to anything. + GameObject poofPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab("vfx_wraith_death"); if (poofPrefab != null) Instantiate(poofPrefab, Player.m_localPlayer.transform.position, Quaternion.identity); Transform playerVisual = Player.m_localPlayer.transform.Find("Visual"); diff --git a/JotunnModStub/Aswid/AswidStatusEffects.cs b/JotunnModStub/Aswid/AswidStatusEffects.cs index f87e9bb..ac3ab3f 100644 --- a/JotunnModStub/Aswid/AswidStatusEffects.cs +++ b/JotunnModStub/Aswid/AswidStatusEffects.cs @@ -114,13 +114,13 @@ namespace RacesOfValheim { var aswidStats = ScriptableObject.CreateInstance(); aswidStats.name = "SE_AswidStats"; - aswidStats.m_icon = PrefabManager.Cache.GetPrefab("TrophyBat")?.m_itemData.m_shared.m_icons[0]; + aswidStats.m_icon = PrefabManager.Cache.GetPrefab("TrophyDeathsquito")?.m_itemData.m_shared.m_icons[0]; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(aswidStats, fixReference: false)); var batForm = ScriptableObject.CreateInstance(); batForm.name = "SE_BatForm"; - batForm.m_icon = PrefabManager.Cache.GetPrefab("TrophyBat")?.m_itemData.m_shared.m_icons[0]; + batForm.m_icon = PrefabManager.Cache.GetPrefab("TrophyDeathsquito")?.m_itemData.m_shared.m_icons[0]; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(batForm, fixReference: false)); diff --git a/JotunnModStub/Aswid/AswidThrall.cs b/JotunnModStub/Aswid/AswidThrall.cs index 816517e..35d1562 100644 --- a/JotunnModStub/Aswid/AswidThrall.cs +++ b/JotunnModStub/Aswid/AswidThrall.cs @@ -117,7 +117,10 @@ namespace RacesOfValheim m_ai.SetFollowTarget(user.gameObject); } - GameObject vfx = ZNetScene.instance.GetPrefab("vfx_surtling_death"); + // "vfx_surtling_death" was asked for here and is not a prefab in this game, so dominating + // a creature happened with no effect at all. The generic body-sized puff, rather than the + // Wraith's mist the Mist Form wears: nothing about domination is misty. + GameObject vfx = ZNetScene.instance.GetPrefab("vfx_corpse_destruction_medium"); if (vfx) Instantiate(vfx, m_character.transform.position, Quaternion.identity); user.Message(MessageHud.MessageType.Center, $"{m_character.m_name} dominated!"); diff --git a/JotunnModStub/Draugh/DraughProgressionPatches.cs b/JotunnModStub/Draugh/DraughProgressionPatches.cs index 8162551..f56ce0f 100644 --- a/JotunnModStub/Draugh/DraughProgressionPatches.cs +++ b/JotunnModStub/Draugh/DraughProgressionPatches.cs @@ -98,8 +98,16 @@ namespace RacesOfValheim attacker.ApplyDamage(poisonSplash, true, false); - // Visual effect for splash - UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("vfx_OozeHit"), attacker.GetCenterPoint(), Quaternion.identity); + // Visual effect for splash. "vfx_OozeHit" is not a prefab in this game - + // the blob's hit effect is vfx_blob_hit - and this was the one dead name + // in the mod that was passed to Instantiate unguarded, so every + // successful parry threw ArgumentException here and took the North Wind + // nova below down with it. + GameObject splashVfx = ZNetScene.instance.GetPrefab("vfx_blob_hit"); + if (splashVfx != null) + { + UnityEngine.Object.Instantiate(splashVfx, attacker.GetCenterPoint(), Quaternion.identity); + } // Stage 5: North Wind (AoE Frost) if (state >= 5) diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index 784cffd..a98f6d3 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -316,7 +316,10 @@ namespace RacesOfValheim { if (Player.m_localPlayer == null) return; Vector3 pos = Player.m_localPlayer.transform.position + Vector3.up; - GameObject smoke = PrefabManager.Cache.GetPrefab("vfx_corpse_destruction"); + // Vanilla's puff carries a size suffix and has no bare "vfx_corpse_destruction" - so + // this used to resolve to nothing and the body swap happened in plain view, with only + // the sparks below to soften it. _medium is the one built for a body this size. + GameObject smoke = PrefabManager.Cache.GetPrefab("vfx_corpse_destruction_medium"); if (smoke != null) Instantiate(smoke, pos, Quaternion.identity); GameObject sparks = PrefabManager.Cache.GetPrefab("vfx_HitSparks"); diff --git a/JotunnModStub/RaceRadial.cs b/JotunnModStub/RaceRadial.cs index f381421..3e4e0da 100644 --- a/JotunnModStub/RaceRadial.cs +++ b/JotunnModStub/RaceRadial.cs @@ -49,7 +49,7 @@ namespace RacesOfValheim new Entry { Race = "Fenrir", Label = "Cultist Form", Key = () => FenrirConfig.CultistFormKey, Icon = "TrophyCultist" }, new Entry { Race = "Fenrir", Label = "Howl", Key = () => FenrirConfig.HowlKey, Icon = "TrophyUlv" }, - new Entry { Race = "Aswid", Label = "Bat Form", Key = () => AswidConfig.BatFormKey, Icon = "TrophyBat" }, + new Entry { Race = "Aswid", Label = "Bat Form", Key = () => AswidConfig.BatFormKey, Icon = "TrophyDeathsquito" }, new Entry { Race = "Aswid", Label = "Mist Form", Key = () => AswidConfig.MistFormKey, Icon = "TrophyWraith" }, new Entry { Race = "Aswid", Label = "Eclipse", Key = () => AswidConfig.EclipseKey, Icon = "TrophyFader" }, new Entry { Race = "Aswid", Label = "Tame", Key = () => AswidConfig.TameKey, Icon = "TrophyWolf" }, diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 7061303..0235ed9 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -695,7 +695,10 @@ namespace RacesOfValheim private Sprite GetTrolIcon() { GameObject trophyPrefab = PrefabManager.Cache.GetPrefab("TrophyFrostTroll")?.gameObject; - if (trophyPrefab == null) trophyPrefab = PrefabManager.Cache.GetPrefab("TrophyTroll")?.gameObject; + // TrophyForestTroll, not "TrophyTroll": the latter is not a prefab in this game, so the + // fallback could never fire and the name sat here as a free slot for any mod that + // happens to ship one. See SkeletonVisuals.EnsureFireAura for what that costs. + if (trophyPrefab == null) trophyPrefab = PrefabManager.Cache.GetPrefab("TrophyForestTroll")?.gameObject; if (trophyPrefab != null) { ItemDrop trophyDrop = trophyPrefab.GetComponent(); diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index af64056..cfe78d4 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -690,7 +690,10 @@ namespace RacesOfValheim if (Player.m_localPlayer == null) return; Vector3 pos = Player.m_localPlayer.transform.position + Vector3.up; - GameObject smoke = PrefabManager.Cache.GetPrefab("vfx_corpse_destruction"); + // _medium, not a bare "vfx_corpse_destruction": that name is not in the game, so this + // resolved to nothing and the swap into a drake happened in plain view. See + // FenrirRace.SpawnPoofEffect for the same fix. + GameObject smoke = PrefabManager.Cache.GetPrefab("vfx_corpse_destruction_medium"); if (smoke != null) Instantiate(smoke, pos, Quaternion.identity); GameObject sparks = PrefabManager.Cache.GetPrefab("vfx_HitSparks"); diff --git a/JotunnModStub/Trenta/TrentaAbilities.cs b/JotunnModStub/Trenta/TrentaAbilities.cs index 8e8e3c9..4380e28 100644 --- a/JotunnModStub/Trenta/TrentaAbilities.cs +++ b/JotunnModStub/Trenta/TrentaAbilities.cs @@ -233,13 +233,27 @@ namespace RacesOfValheim if (!vfxMaterialResolved) { vfxMaterialResolved = true; - GameObject source = PrefabManager.Cache.GetPrefab(TrentaConfig.PurpleRainVfxSourcePrefab) - ?? PrefabManager.Cache.GetPrefab("vfx_smoke"); + // The "vfx_smoke" fallback that used to sit here is gone. That name is not a prefab + // in this game, so it could only ever resolve to another mod's object - and with + // Magic_Supremacy installed it resolved to a weapon trail, which is what put purple + // smoke on the Skeleton (see SkeletonVisuals.EnsureFireAura). Purple Rain is purple + // by design, so the same theft here would never have looked wrong enough to report. + // + // Losing the fallback means a miss is now a miss. Said out loud, because the resolve + // is cached for the session either way and a silent one would be invisible: 1.0 + // loads creature assets lazily, so the Shaman is not guaranteed to be in memory. + GameObject source = PrefabManager.Cache.GetPrefab(TrentaConfig.PurpleRainVfxSourcePrefab); if (source != null) { ParticleSystemRenderer sourceRenderer = source.GetComponentInChildren(true); if (sourceRenderer != null) cachedVfxMaterial = sourceRenderer.material; } + else + { + Jotunn.Logger.LogWarning( + $"[Trenta] Purple Rain: '{TrentaConfig.PurpleRainVfxSourcePrefab}' not in the prefab " + + "cache; falling back to Unity's default particle material for this session."); + } } GameObject vfx = new GameObject("TrentaPurpleRainVFX"); diff --git a/JotunnModStub/Trenta/TrentaMuspell.cs b/JotunnModStub/Trenta/TrentaMuspell.cs index 01157a9..6f7fbf6 100644 --- a/JotunnModStub/Trenta/TrentaMuspell.cs +++ b/JotunnModStub/Trenta/TrentaMuspell.cs @@ -141,7 +141,12 @@ namespace RacesOfValheim if (player == null) return; Vector3 pos = player.transform.position + Vector3.up; - GameObject smoke = PrefabManager.Cache.GetPrefab("vfx_corpse_destruction"); + // _large rather than the _medium the other two forms use: the Muspell is the biggest + // thing this mod turns a player into, and a body-sized puff does not cover it. A bare + // "vfx_corpse_destruction" is not a prefab in this game, so until now the Muspell was + // the one transformation with no covering effect of any kind - Fenrir and Skadi at least + // had their sparks. + GameObject smoke = PrefabManager.Cache.GetPrefab("vfx_corpse_destruction_large"); if (smoke != null) Object.Instantiate(smoke, pos, Quaternion.identity); } From 276ff9383401fd5733e7dda01d94c81a967c355b Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 00:20:16 +0200 Subject: [PATCH 040/273] feat(draugh): add the Human Meat item the Bonemass perk has always promised Two places in the mod used an item called "HumanMeat" and nothing registered it: the drop in Draugh_DeathAura_Patch and the "fatal to the living" block in DraughFoodPatches. Both check for null, so the perk has been a no-op since it was written - a README line with no item behind it. The two consumers are unchanged; what was missing was the producer. Built from two vanilla items, one for the look and one for the numbers. RawMeat gives the model and icon, because that is what a piece of somebody looks like and because raw flesh is the Draugh's whole food identity. BloodPudding gives the nourishment, copied field by field at start-up rather than written down here, so the item stays balanced against the game's own progression and follows any change made to it. Blood Pudding's stamina goes onto health and stamina is left at zero. A Draugh does not use stamina, so nourishment spent there is thrown away: the food slot would read full while giving the race half of what it cost. RawMeat is a Material in vanilla - raw meat is not edible - so m_itemType is forced to Consumable. That is the one assumption worth knowing about, and the registration logs what it produced so a silent failure cannot hide. The meat is tinted on copies of the materials, never the shared ones, or every piece of raw meat in the world would darken with it. The README said humanoids drop it. The patch is on Player.OnDeath and always was, so the line now says what the code does: a player who dies inside the death aura, the Draugh included. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Draugh/DraughConfig.cs | 5 + JotunnModStub/Draugh/DraughHumanMeat.cs | 140 ++++++++++++++++++++++++ JotunnModStub/Draugh/DraughRace.cs | 4 + README.md | 2 +- 4 files changed, 150 insertions(+), 1 deletion(-) create mode 100644 JotunnModStub/Draugh/DraughHumanMeat.cs diff --git a/JotunnModStub/Draugh/DraughConfig.cs b/JotunnModStub/Draugh/DraughConfig.cs index 8f3c8fe..8aa0a88 100644 --- a/JotunnModStub/Draugh/DraughConfig.cs +++ b/JotunnModStub/Draugh/DraughConfig.cs @@ -33,6 +33,7 @@ namespace RacesOfValheim // ─── Undead Fortitude (tier 4+: crit on staggered, death aura) ────────── public static ConfigEntry StaggerCritMultiplier; public static ConfigEntry DeathAuraRadius; + public static ConfigEntry HumanMeatNourishmentMultiplier; // ─── North Wind (tier 5+: AoE frost on parry, on the same cooldown) ────── public static ConfigEntry NorthWindCooldown; @@ -79,6 +80,10 @@ namespace RacesOfValheim new ConfigDescription("Multiplies physical damage dealt to staggered enemies, tier 4+.", new AcceptableValueRange(1f, 3f))); DeathAuraRadius = config.Bind(fortitude, "Death Aura Radius", 100f, new ConfigDescription("Meters within which an ally's death drops Human Meat for you, tier 4+.", new AcceptableValueRange(10f, 300f))); + // A multiplier rather than absolute numbers: Human Meat is built from Blood Pudding's own + // nourishment at start-up, and those are the game's values, not ours to hardcode. + HumanMeatNourishmentMultiplier = config.Bind(fortitude, "Human Meat Nourishment Multiplier", 1f, + new ConfigDescription("Scales Human Meat's health, stamina and eitr against the Blood Pudding it is built from. Read once at start-up.", new AcceptableValueRange(0.1f, 3f))); const string northWind = "Draugh - North Wind"; NorthWindCooldown = config.Bind(northWind, "Cooldown", 20f, diff --git a/JotunnModStub/Draugh/DraughHumanMeat.cs b/JotunnModStub/Draugh/DraughHumanMeat.cs new file mode 100644 index 0000000..6ba3293 --- /dev/null +++ b/JotunnModStub/Draugh/DraughHumanMeat.cs @@ -0,0 +1,140 @@ +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Human Meat, the Bonemass-tier reward: an ally who dies near a Draugh leaves a piece of + /// themselves behind, and only a Draugh can stomach it. + /// + /// THIS ITEM DID NOT EXIST. Two places in the mod already used it - the drop in + /// DraughProgressionPatches.Draugh_DeathAura_Patch and the "fatal to the living" block in + /// DraughFoodPatches - and both looked it up by the name "HumanMeat", which nothing registered. + /// So the drop never happened and the block never fired: a perk the README has promised since + /// 1.4 with no item behind it. The two consumers are unchanged; what was missing was the + /// producer. + /// + /// BUILT FROM TWO VANILLA ITEMS, one for the look and one for the numbers: + /// + /// RawMeat gives the clone its model and icon, because that is what a piece of somebody looks + /// like, and because the Draugh's whole food identity is raw flesh. + /// + /// BloodPudding gives the nourishment, copied field by field at start-up rather than written + /// down here. Blood Pudding is a real cooked food in the game's own progression, so its + /// numbers are balanced against the rest of it, and reading them means this item follows any + /// change the game makes to them. DraughConfig.HumanMeatNourishmentMultiplier scales them. + /// Its stamina is folded into health rather than copied across - see the note further down. + /// + /// RawMeat is a Material in vanilla - raw meat is not edible - so m_itemType is forced to + /// Consumable. That is the one assumption in here worth knowing about: the alternative, which + /// DraughRace.CreateModAssets uses for its EdibleUncooked_ items, is to clone the COOKED item and + /// dress it as the raw one, which gets consumability for free but keeps the cooked model. If the + /// game ever refuses to eat this, that is the fallback, and the log line below prints exactly + /// what was produced so it can be told apart from a missing prefab. + /// + internal static class DraughHumanMeat + { + /// The name the two consumers look it up by. Changing it breaks both. + public const string PrefabName = "HumanMeat"; + + private const string LookSource = "RawMeat"; + private const string NourishmentSource = "BloodPudding"; + + /// + /// Darkens the meat and pulls it towards blood, so a stack of Human Meat is not mistaken for + /// the deer meat it is built from. Multiplied into the material's own colour, so it darkens + /// whatever the texture already is rather than replacing it. + /// + private static readonly Color Tint = new Color(0.62f, 0.34f, 0.38f, 1f); + + /// + /// Called from DraughRace.CreateModAssets, which is to say while vanilla prefabs are + /// available and before anything can ask for this item. + /// + public static void Register() + { + ItemDrop look = FindItem(LookSource); + ItemDrop nourishment = FindItem(NourishmentSource); + + if (look == null || nourishment == null) + { + // Nothing is registered rather than a half-built item: the two consumers both check + // for null, so no meat is a quiet no-op, while a nameless inedible one is not. + Jotunn.Logger.LogWarning( + $"[Draugh] Human Meat not registered: '{LookSource}' " + + $"{(look == null ? "missing" : "ok")}, '{NourishmentSource}' " + + $"{(nourishment == null ? "missing" : "ok")}."); + return; + } + + CustomItem item = new CustomItem(PrefabName, LookSource); + ItemDrop.ItemData.SharedData shared = item.ItemDrop.m_itemData.m_shared; + ItemDrop.ItemData.SharedData source = nourishment.m_itemData.m_shared; + + shared.m_name = "Human Meat"; + shared.m_description = "A piece of somebody. The living gag on it; you do not."; + + // Raw meat is a Material in vanilla, so none of the food fields below would be read + // without this. + shared.m_itemType = ItemDrop.ItemData.ItemType.Consumable; + + // BLOOD PUDDING'S STAMINA GOES ONTO HEALTH, AND STAMINA IS LEFT AT ZERO. A Draugh does + // not use stamina, so nourishment spent there is nourishment thrown away - the food + // slot would look full while giving the race half of what it cost. Adding the two + // together keeps the item worth the same as the pudding it is balanced against, which + // is the point of reading the pudding at all. + float scale = DraughConfig.HumanMeatNourishmentMultiplier.Value; + shared.m_food = (source.m_food + source.m_foodStamina) * scale; + shared.m_foodStamina = 0f; + shared.m_foodEitr = source.m_foodEitr * scale; + shared.m_foodRegen = source.m_foodRegen; + shared.m_foodBurnTime = source.m_foodBurnTime; + shared.m_maxStackSize = source.m_maxStackSize; + shared.m_consumeStatusEffect = source.m_consumeStatusEffect; + + Recolour(item.ItemDrop.gameObject); + + ItemManager.Instance.AddItem(item); + + Jotunn.Logger.LogInfo( + $"[Draugh] Human Meat registered from '{LookSource}' + '{NourishmentSource}': " + + $"type={shared.m_itemType} food={shared.m_food:F0} stamina={shared.m_foodStamina:F0} " + + $"eitr={shared.m_foodEitr:F0} regen={shared.m_foodRegen:F0} " + + $"burn={shared.m_foodBurnTime:F0}s stack={shared.m_maxStackSize}."); + } + + private static ItemDrop FindItem(string prefabName) + { + GameObject prefab = PrefabManager.Cache.GetPrefab(prefabName); + return prefab != null ? prefab.GetComponent() : null; + } + + /// + /// Tints the clone's own materials, on copies. + /// + /// The clone's renderers still point at the vanilla RawMeat materials, which are shared with + /// every piece of raw meat in the world - writing a colour into one of those would tint the + /// lot. Each renderer gets its own copy instead, which this prefab then owns. + /// + private static void Recolour(GameObject root) + { + foreach (Renderer renderer in root.GetComponentsInChildren(true)) + { + Material[] materials = renderer.sharedMaterials; + if (materials == null) continue; + + for (int i = 0; i < materials.Length; i++) + { + if (materials[i] == null) continue; + + Material copy = new Material(materials[i]); + if (copy.HasProperty("_Color")) copy.color = copy.color * Tint; + materials[i] = copy; + } + + renderer.sharedMaterials = materials; + } + } + } +} diff --git a/JotunnModStub/Draugh/DraughRace.cs b/JotunnModStub/Draugh/DraughRace.cs index a9f130f..9362f5c 100644 --- a/JotunnModStub/Draugh/DraughRace.cs +++ b/JotunnModStub/Draugh/DraughRace.cs @@ -23,6 +23,10 @@ namespace RacesOfValheim // Draugr is ever set up as a bench. DraughSpawner.Register(); + // The Bonemass-tier drop. Registered here for the same reason as the pile: two places in + // the mod already look it up by name, and until now nothing created it. + DraughHumanMeat.Register(); + // Generate EdibleUncooked prefabs for Draugh raw food logic foreach (var mapping in DraughFoodPatches.rawToCookedMapping) { diff --git a/README.md b/README.md index 010b03d..d3141fa 100644 --- a/README.md +++ b/README.md @@ -147,7 +147,7 @@ Three races grow a pair of their own, refused by the holster key and never dragg - **Base:** Born Dead, Buried Alive. -20% Slash/Pierce/Blunt; +50% Fire/Spirit taken. Poison resistant. Eats only raw flesh, eyes, entrails, blood. Swamp undead ignore you. - **Eikthyr:** Immune to Wet, swim faster, regen when wet/swimming. - **Elder:** Toxic Trace – attacks poison over time. -- **Bonemass:** Flesh and the Power It Holds – humanoids drop Human Meat food. Corpse Run permanently active. +- **Bonemass:** Flesh and the Power It Holds – a player who dies inside your death aura leaves Human Meat behind, yourself included. Only a Draugh can eat it. Corpse Run permanently active. - **Moder:** Parrying unleashes freezing nova (20s CD). - **Yagluth:** Zombie Ritual – fatal damage = ghost state, immune to damage, Eitr drains, die if Eitr hits 0. Raw food gives Eitr. - **Queen:** Swarm of Terror – being hit summons 2 Seeker Broods to fight for you. From 9907cae29237bb296d86600ea39902fe2ee9225b Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 00:20:31 +0200 Subject: [PATCH 041/273] fix(fenrir): give the forms a voice, and stop the sounds writing to the save Every sound the Fenrir forms played was looked up by a name, and most of those names are not prefabs in this game. The chains hid it: PlaySFX walks its arguments and stops at the first that resolves, so a claw that asked for "sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack" had a Fenring swinging with a wolf's voice through a fallback nobody noticed. The cultist's double claw asked for three dead names in a row and was silent from the day it was written. The creatures do have their own sounds. The forms now use them: sfx_fenring_claw_start for the swing, sfx_fenring_claw_hit for the landing, sfx_fenring_fireclaw to open the fire breath. The Ulv keeps the wolf's, since vanilla ships it nothing but sfx_ulv_death. THE HOWL WAS NEVER A PREFAB TO LOOK UP. It is an AnimationEvent inside the wolf's 'C_Hawl' clip, firing at 0.39s with the sound handed over as an object reference - and a player in wolf form idles through that clip and howls out loud already, with the game's own AnimationEffect doing the work. Three spellings of one word are why this took so long to find: the clip is 'C_Hawl', the sound is 'sfx_wolf_haul', and the mod was looking for 'sfx_wolf_howl', the only correct spelling of the three and the only one that does not exist. The Fenring has no howl of its own at all, so it borrows the wolf's over its Taunt. The jump attack's impact moved to where the jump lands, next to the damage, instead of firing before the dash while the form is still standing. FenrirCreatureSound.Spawn is the other half. Some vanilla sound prefabs carry a ZNetView - sfx_fenring_alerted does - and one that wakes with no init ZDO writes a persistent record into the world, once per swing. Spawning now runs inside ZNetView.StartGhostInit, the game's own answer, so no ZDO is made. All nine sound spawns in these forms go through it. sfx_fenring_howl resolves to an ordinary sound prefab and hard-exits the process when spawned on its own. It is named in a Suspect set, described in the log and never instantiated, because a name nobody records is a name somebody adds back. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Fenrir/FenrirBehaviors.cs | 286 ++++++++++++++++----- JotunnModStub/Fenrir/FenrirRace.cs | 62 ++++- JotunnModStub/Fenrir/FormAnimEventSound.cs | 89 +++++++ 3 files changed, 363 insertions(+), 74 deletions(-) create mode 100644 JotunnModStub/Fenrir/FormAnimEventSound.cs diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 2d1180c..380f47c 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -1,4 +1,5 @@ using System.Collections; +using System.Collections.Generic; using BepInEx; using HarmonyLib; using Jotunn.Configs; @@ -10,32 +11,202 @@ using UnityEngine.UI; // Added for UI namespace RacesOfValheim { /// - /// Howl vocalisation, borrowed from the real creature instead of guessed at. Wolves and their - /// kin do not carry a standalone "sfx_wolf_howl"-style prefab that PlaySFX's - /// PrefabManager.Cache lookup could ever find - dumpdverger's own hierarchy dump for - /// Fenring_Cultist shows no ZSFX anywhere on it. + /// The voice of the creature a Fenrir is wearing. /// - /// BaseAI.m_idleSound was the first guess and was wrong in a quieter way: it is real, but it - /// is the creature's passive ambient noise (DoIdleSound, on a timer while it is doing nothing - /// in particular) - a small grunt, not a howl, and it played back sounding like whatever - /// generic "the form did something" cue the transformation itself already uses. What a - /// creature actually vocalises WHEN IT SPOTS SOMETHING is BaseAI.m_alertedEffects, fired from - /// SetAlerted(true) - reading that off the real "Fenring"/"Fenring_Cultist" prefab and calling - /// Create() plays the same aggressive bark the creature itself makes going on alert. + /// THE HISTORY MATTERS HERE, because two reasonable-sounding answers were tried and both were + /// silent, and the note that used to sit in this place asserted the second one worked. + /// + /// "sfx_wolf_howl" was the first guess. There is no such prefab in the game. + /// + /// BaseAI.m_idleSound was the second. Real, but it is the creature's ambient grunt on a timer + /// (DoIdleSound) - the wrong sound even when it plays. + /// + /// BaseAI.m_alertedEffects was the third, on the reasoning that a creature's alert bark is the + /// nearest thing it has to a howl and that these creatures carry no standalone ZSFX at all. + /// That last part is simply not true - see the table below - and calling Create() on a PREFAB's + /// EffectList produced nothing audible in testing while instantiating a sound prefab directly, + /// two lines away in the same file, worked. So the alert-list route is now the last resort + /// rather than the plan. + /// + /// What actually plays is a real prefab, instantiated the same way the claw and the landing thud + /// are. Every name below was checked against the game's own asset manifest. Note "sfx_wolf_haul", + /// which is the wolf's howl under the game's own misspelling - that single typo is most of why + /// nobody found it by searching for "howl". /// internal static class FenrirCreatureSound { + /// + /// Per creature, best first, and every name checked against the game's own asset manifest. + /// The Ulv has no vocalisation of its own in vanilla beyond sfx_ulv_death, so it borrows the + /// wolf's. "sfx_wolf_haul" is the wolf's howl under the game's own misspelling, which is most + /// of why nobody found it by searching for "howl". + /// + /// THE FENRING BORROWS THE WOLF'S HOWL. It has none of its own: its 19 clips carry no howl, + /// and its taunt fires no sound event at all. Its own "sfx_fenring_howl" is in Suspect below + /// and must not be spawned. Its alert bark stays as the second entry - that is its real voice, + /// just not an ululation. + /// + private static readonly Dictionary Howls = new Dictionary + { + { "Wolf", new[] { "sfx_wolf_haul", "sfx_wolf_alerted" } }, + { "Ulv", new[] { "sfx_wolf_haul", "sfx_wolf_alerted" } }, + { "Fenring", new[] { "sfx_wolf_haul", "sfx_fenring_alerted" } }, + { "Fenring_Cultist", new[] { "sfx_wolf_haul", "sfx_fenring_alerted" } }, + }; + + /// The cue that opens the cultist's fire breath: its own fire-claw snarl. + private static readonly string[] FireRoar = { "sfx_fenring_fireclaw" }; + + /// + /// PREFABS THAT RESOLVE AND MUST NOT BE INSTANTIATED. + /// + /// "sfx_fenring_howl" exists, resolves through the cache to a real GameObject, and takes the + /// process down with it - not an exception BepInEx can catch, a hard exit. It killed the game + /// the first time a Fenrir transformation reached it, and the only reason we know which prefab + /// did it is that its log line had been flushed a moment before. + /// + /// Best guess is that it is not a standalone sound at all but a node belonging to the + /// creature's own rig, fired by that creature's animator and meaningless off it. Described + /// here rather than deleted, because the description is what will settle that - and because a + /// name nobody records is a name somebody adds back. + /// + private static readonly HashSet Suspect = new HashSet { "sfx_fenring_howl" }; + + // Said once per name, because "the howl is silent" cost two rounds of testing to notice and + // the log said nothing either time. + private static readonly HashSet logged = new HashSet(); + public static void PlayHowl(string sourcePrefabName, Vector3 position) + { + string[] names; + if (Howls.TryGetValue(sourcePrefabName, out names) && Play(names, position, sourcePrefabName)) + { + return; + } + + // A form not in the table, or one whose whole list was refused, still gets a voice. + PlayAlertedEffects(sourcePrefabName, position); + } + + public static void PlayFireRoar(Vector3 position) + { + if (!Play(FireRoar, position, "fire roar")) PlayAlertedEffects("Fenring_Cultist", position); + } + + /// Instantiates the first name that resolves and is safe. True if anything played. + private static bool Play(string[] prefabNames, Vector3 position, string label) + { + foreach (string name in prefabNames) + { + GameObject prefab = PrefabManager.Cache.GetPrefab(name); + if (prefab == null) continue; + + // BEFORE the Instantiate, not after. Anything that goes the way sfx_fenring_howl went + // now names itself, and says what it is, while the log can still be written. + if (logged.Add(name)) Describe(label, name, prefab); + + if (Suspect.Contains(name)) continue; + + // A parented object is not a prefab, it is a node inside somebody else's hierarchy. + // Spawning one on its own is the thing this route is suspected of getting wrong. + if (prefab.transform.parent != null) continue; + + Spawn(prefab, position); + return true; + } + + return false; + } + + /// + /// Spawns a sound prefab without letting it write itself into the save. + /// + /// SOME VANILLA SOUND PREFABS CARRY A ZNetView. "sfx_fenring_alerted" is one - the Describe + /// line below printed it, which is how this was noticed. A ZNetView that wakes with no init + /// ZDO calls ZDOMan.CreateNewZDO at its position, marks itself persistent, stamps itself with + /// the prefab hash and registers with the scene. On a sound played every time somebody howls + /// or swings a claw, that is one persistent "there is a noise here" record per swing, saved + /// with the world. It is the same bug that left burnt-in torches in people's worlds; the long + /// version is on SkeletonVisuals.BorrowEffect. + /// + /// ZNetView.StartGhostInit is the game's own answer, not ours: between the two calls a + /// ZNetView comes up with no ZDO at all. Cheaper and far less invasive than stripping the + /// component off a copy, and free on the prefabs that carry no ZNetView. + /// + /// The finally matters. Leaving ghost init switched on because an Instantiate threw would + /// break every ZNetView created afterwards, for the rest of the session. + /// + public static void Spawn(GameObject prefab, Vector3 position) + { + if (prefab == null) return; + + ZNetView.StartGhostInit(); + try + { + Object.Instantiate(prefab, position, Quaternion.identity); + } + finally + { + ZNetView.FinishGhostInit(); + } + + // NOT FOLLOWED BY A Play() CALL, and that took a while to establish. ZSFX is ticked by + // CustomUpdate rather than Unity's Update, so it starts on a later frame: reading + // AudioSource.isPlaying straight after this says false for every sound there is, and + // nudging Play() in on top of a prefab whose own m_playOnAwake is already set is as + // likely to interrupt it as to help. Every sound this mod spawns self-starts. If one ever + // turns up that does not - m_playOnAwake false, checked with "dumpanim " - that is + // the moment to call ZSFX.Play() here, and not before. + } + + /// + /// What a resolved sound actually is: where it sits in its own hierarchy, and what it carries. + /// The root flag is the one to read first - see Play. + /// + private static void Describe(string label, string name, GameObject prefab) + { + string path = prefab.name; + for (Transform t = prefab.transform.parent; t != null; t = t.parent) path = t.name + "/" + path; + + List parts = new List(); + foreach (Component comp in prefab.GetComponentsInChildren(true)) + { + if (comp != null && !(comp is Transform)) parts.Add(comp.GetType().Name); + } + + Jotunn.Logger.LogInfo( + $"[FenrirForm] {label}: '{name}' -> '{path}' root={prefab.transform.parent == null} " + + $"suspect={Suspect.Contains(name)} carries=[{string.Join(", ", parts.ToArray())}]"); + } + + /// + /// The creature's alert EffectList, kept as a fallback. Not trusted as the primary any more: + /// it is what left every howl in the mod silent. + /// + private static void PlayAlertedEffects(string sourcePrefabName, Vector3 position) { GameObject source = PrefabManager.Cache.GetPrefab(sourcePrefabName); BaseAI ai = source != null ? source.GetComponent() : null; - if (ai == null || ai.m_alertedEffects == null) + if (ai == null || ai.m_alertedEffects == null || ai.m_alertedEffects.m_effectPrefabs == null || + ai.m_alertedEffects.m_effectPrefabs.Length == 0) { - Jotunn.Logger.LogWarning($"[FenrirForm] No BaseAI.m_alertedEffects found on '{sourcePrefabName}'."); + if (logged.Add(sourcePrefabName + "-alerted")) + { + Jotunn.Logger.LogWarning( + $"[FenrirForm] No sound for '{sourcePrefabName}': nothing from its table was " + + "playable and its BaseAI.m_alertedEffects is empty."); + } return; } ai.m_alertedEffects.Create(position, Quaternion.identity); + if (logged.Add(sourcePrefabName + "-alerted")) + { + Jotunn.Logger.LogWarning( + $"[FenrirForm] '{sourcePrefabName}': fell through to BaseAI.m_alertedEffects " + + $"({ai.m_alertedEffects.m_effectPrefabs.Length} effect(s)). This route has been " + + "silent before - if you hear nothing, that is why."); + } } } @@ -193,8 +364,9 @@ namespace RacesOfValheim flames = FenrirAttackSync.SpawnFlames(player); // The roar that opens the breath, once per start, the same cue the owner hears. - GameObject sfx = PrefabManager.Cache.GetPrefab("sfx_cultist_attack_fire_start"); - if (sfx != null) Instantiate(sfx, player.transform.position, Quaternion.identity); + // "sfx_cultist_attack_fire_start" was asked for here and there is no sfx_cultist_* + // prefab in the game at all; the fenring's own fire-claw snarl is the real one. + FenrirCreatureSound.PlayFireRoar(player.transform.position); } else if (!fire && flames != null) { Destroy(flames); flames = null; } @@ -221,7 +393,7 @@ namespace RacesOfValheim GameObject sfx = PrefabManager.Cache.GetPrefab(name); if (sfx != null) { - Instantiate(sfx, player.transform.position, Quaternion.identity); + FenrirCreatureSound.Spawn(sfx, player.transform.position); return; } } @@ -333,7 +505,7 @@ namespace RacesOfValheim GameObject sfx = PrefabManager.Cache.GetPrefab(name); if (sfx != null) { - Instantiate(sfx, Player.m_localPlayer.transform.position, Quaternion.identity); + FenrirCreatureSound.Spawn(sfx, Player.m_localPlayer.transform.position); return; } } @@ -365,19 +537,19 @@ namespace RacesOfValheim fenrirAnim.SetFloat("sideway_speed", 0f); fenrirAnim.SetTrigger(triggerName); - FenrirAttackSync.Publish(triggerName, "sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack"); - PlaySFX("sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack"); + // The swing. The chain here used to be "sfx_fenring_attack", "sfx_fenring_attack_claw", + // "sfx_wolf_attack", and only the last of those is a prefab in this game - so a Fenring + // has been swinging with a wolf's voice, through a fallback, while the creature's own + // sound sat there unused under a different name. + FenrirAttackSync.Publish(triggerName, "sfx_fenring_claw_start"); + PlaySFX("sfx_fenring_claw_start"); yield return new WaitForSeconds(dmgDelay); - if (ZNetScene.instance != null) - { - GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_fenring_attack"); - if (attackSfx != null) - { - Instantiate(attackSfx, Player.m_localPlayer.transform.position, Quaternion.identity); - } - } + // The hit, as opposed to the swing PlaySFX covers above. This asked for + // "sfx_fenring_attack" on its own, which is not a prefab in this game, so the claw landed + // in silence - same dead name as the jump attack's, same replacement. + PlaySFX("sfx_fenring_claw_hit"); ExecuteClawDamage(baseDamage); @@ -404,16 +576,12 @@ namespace RacesOfValheim // Aspettiamo che l'animazione si carichi (0.75s) yield return new WaitForSeconds(0.75f); - if (ZNetScene.instance != null) - { - GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_fenring_attack"); - if (attackSfx != null) - { - Instantiate(attackSfx, Player.m_localPlayer.transform.position, Quaternion.identity); - } - } + // The impact sound used to be played HERE, which is mid-air: the jump has not started + // yet, let alone landed. It now fires at the end of the dash, next to the damage. It also + // asked for "sfx_fenring_attack", which is not a prefab in this game, so it was silent + // either way. - // Invece di una singola spinta di velocità (che viene subito annullata da Valheim), + // Invece di una singola spinta di velocità (che viene subito annullata da Valheim), // muoviamo esplicitamente il personaggio fotogramma per fotogramma per 0.2 secondi float dashDuration = 0.2f; float elapsedDash = 0f; @@ -438,7 +606,9 @@ namespace RacesOfValheim yield return new WaitForFixedUpdate(); } - // Infliggiamo il danno al termine dello scatto + // Infliggiamo il danno al termine dello scatto, che è anche il momento dell'atterraggio: + // il suono d'impatto va qui, non prima dello scatto. + PlaySFX("sfx_fenring_claw_hit"); ExecuteClawDamage(FenrirConfig.FenringJumpAttackDamage.Value); // Tempo per riprendersi dall'atterraggio prima di potersi muovere di nuovo @@ -620,7 +790,7 @@ namespace RacesOfValheim GameObject sfx = PrefabManager.Cache.GetPrefab(name); if (sfx != null) { - Instantiate(sfx, Player.m_localPlayer.transform.position, Quaternion.identity); + FenrirCreatureSound.Spawn(sfx, Player.m_localPlayer.transform.position); return; } } @@ -658,7 +828,8 @@ namespace RacesOfValheim cultistAnim.SetBool("attack_fire", true); FenrirAttackSync.PublishFire(true); - PlaySFX("sfx_cultist_attack_fire_start"); + // Same cue the remote mirror plays - see the fire branch in the sync behaviour above. + FenrirCreatureSound.PlayFireRoar(Player.m_localPlayer.transform.position); cultistAnim.SetTrigger("attack_flames"); FenrirAttackSync.Publish("attack_flames"); @@ -770,11 +941,11 @@ namespace RacesOfValheim // Per il Cultista usiamo esplicitamente il trigger dell'artigliata cultistAnim.SetTrigger("attack_claw"); - FenrirAttackSync.Publish("attack_claw", "sfx_cultist_attack", "sfx_fenring_attack", "sfx_wolf_attack"); + FenrirAttackSync.Publish("attack_claw", "sfx_fenring_claw_start"); yield return new WaitForSeconds(0.4f); - PlaySFX("sfx_cultist_attack", "sfx_fenring_attack", "sfx_wolf_attack"); + PlaySFX("sfx_fenring_claw_start"); ExecuteClawDamage(FenrirConfig.CultistClawDamage.Value); @@ -796,12 +967,12 @@ namespace RacesOfValheim cultistAnim.SetFloat("sideway_speed", 0f); cultistAnim.SetTrigger("attack_claw_double"); - FenrirAttackSync.Publish("attack_claw_double", "sfx_cultist_attack_double", "sfx_cultist_attack", "sfx_fenring_attack"); + FenrirAttackSync.Publish("attack_claw_double", "sfx_fenring_claw_start"); // L'animazione double claw è più lunga, facciamo il danno un po' dopo yield return new WaitForSeconds(0.6f); - PlaySFX("sfx_cultist_attack_double", "sfx_cultist_attack", "sfx_fenring_attack"); + PlaySFX("sfx_fenring_claw_start"); ExecuteClawDamage(FenrirConfig.CultistDoubleClawDamage.Value); @@ -946,7 +1117,7 @@ namespace RacesOfValheim GameObject sfx = PrefabManager.Cache.GetPrefab(name); if (sfx != null) { - Instantiate(sfx, Player.m_localPlayer.transform.position, Quaternion.identity); + FenrirCreatureSound.Spawn(sfx, Player.m_localPlayer.transform.position); return; } } @@ -969,7 +1140,7 @@ namespace RacesOfValheim GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_wolf_attack"); if (attackSfx != null) { - Instantiate(attackSfx, Player.m_localPlayer.transform.position, Quaternion.identity); + FenrirCreatureSound.Spawn(attackSfx, Player.m_localPlayer.transform.position); } } @@ -1121,7 +1292,7 @@ namespace RacesOfValheim GameObject sfx = PrefabManager.Cache.GetPrefab(name); if (sfx != null) { - Instantiate(sfx, Player.m_localPlayer.transform.position, Quaternion.identity); + FenrirCreatureSound.Spawn(sfx, Player.m_localPlayer.transform.position); return; } } @@ -1135,17 +1306,12 @@ namespace RacesOfValheim try { ulvAnim.SetFloat("sideway_speed", 0f); } catch {} try { ulvAnim.SetTrigger(triggerName); } catch {} - FenrirAttackSync.Publish(triggerName, "sfx_ulv_attack", "sfx_wolf_attack", "sfx_fenring_attack"); + FenrirAttackSync.Publish(triggerName, "sfx_wolf_attack"); - // Scegli il suono appropriato per l'attacco - if (triggerName == "attack_bite") - { - PlaySFX("sfx_ulv_attack", "sfx_wolf_attack", "sfx_fenring_attack"); - } - else - { - PlaySFX("sfx_ulv_attack", "sfx_wolf_attack", "sfx_fenring_attack"); - } + // Un solo suono per entrambi i trigger. I due rami esistevano per scegliere fra + // "sfx_ulv_attack" e il ripiego sul lupo, ma l'Ulv non ha un prefab d'attacco in vanilla + // - c'e solo sfx_ulv_death - quindi entrambi suonavano il lupo comunque. + PlaySFX("sfx_wolf_attack"); yield return new WaitForSeconds(dmgDelay); @@ -1154,7 +1320,7 @@ namespace RacesOfValheim GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_wood_hit"); if (attackSfx != null) { - Instantiate(attackSfx, Player.m_localPlayer.transform.position, Quaternion.identity); + FenrirCreatureSound.Spawn(attackSfx, Player.m_localPlayer.transform.position); } } @@ -1241,8 +1407,8 @@ namespace RacesOfValheim try { ulvAnim.SetFloat("sideway_speed", 0f); } catch {} try { ulvAnim.SetTrigger("attack_slash"); } catch {} - FenrirAttackSync.Publish("attack_slash", "sfx_ulv_attack", "sfx_wolf_attack"); - PlaySFX("sfx_ulv_attack", "sfx_wolf_attack"); + FenrirAttackSync.Publish("attack_slash", "sfx_wolf_attack"); + PlaySFX("sfx_wolf_attack"); yield return new WaitForSeconds(0.3f); // Wait 0.3s before leaping @@ -1267,7 +1433,7 @@ namespace RacesOfValheim GameObject attackSfx = ZNetScene.instance.GetPrefab("sfx_wood_hit"); if (attackSfx != null) { - Instantiate(attackSfx, Player.m_localPlayer.transform.position, Quaternion.identity); + FenrirCreatureSound.Spawn(attackSfx, Player.m_localPlayer.transform.position); } } diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index a98f6d3..4e55a80 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -236,11 +236,16 @@ namespace RacesOfValheim { SpawnPoofEffect(); - if (ZNetScene.instance != null) - { - GameObject howlPrefab = ZNetScene.instance.GetPrefab("sfx_wolf_howl") ?? ZNetScene.instance.GetPrefab("sfx_fenring_idle"); - if (howlPrefab != null) Instantiate(howlPrefab, Player.m_localPlayer.transform.position, Quaternion.identity); - } + // The howl of the creature being turned into, read off that creature. This used to look + // for "sfx_wolf_howl" and fall back to "sfx_fenring_idle": the first is not a prefab in + // this game, and the second is real but is the creature's ambient grunt, so every + // transformation announced itself with a small idle noise. FenrirCreatureSound exists for + // exactly this - see the note at the top of FenrirBehaviors for how it reads a creature's + // own voice off BaseAI.m_alertedEffects, which is the only route the Wolf and the Ulv + // have. The two Fenring forms could do better: vanilla does ship "sfx_fenring_howl", a + // real howl rather than an alert bark, and preferring it when it exists would cost four + // lines here. + FenrirCreatureSound.PlayHowl(CreaturePrefabFor(rules.Form), Player.m_localPlayer.transform.position); yield return new WaitForSeconds(0.1f); @@ -326,18 +331,26 @@ namespace RacesOfValheim { if (sparks != null) Instantiate(sparks, pos, Quaternion.identity); } + /// + /// The vanilla creature a form is built from. One place rather than two, because the howl + /// that announces a transformation has to be read off the same creature the body comes from. + /// + private static string CreaturePrefabFor(FenrirProgression.FormType form) + { + switch (form) + { + case FenrirProgression.FormType.Wolf: return "Wolf"; + case FenrirProgression.FormType.Ulv: return "Ulv"; + case FenrirProgression.FormType.Fenring: return "Fenring"; + case FenrirProgression.FormType.Cultist: return "Fenring_Cultist"; + } + return ""; + } + private void ExecuteTransformation(FenrirProgression.FormRules rules) { Transform playerVisual = Player.m_localPlayer.transform.Find("Visual"); - string prefabName = ""; - - switch (rules.Form) - { - case FenrirProgression.FormType.Wolf: prefabName = "Wolf"; break; - case FenrirProgression.FormType.Ulv: prefabName = "Ulv"; break; - case FenrirProgression.FormType.Fenring: prefabName = "Fenring"; break; - case FenrirProgression.FormType.Cultist: prefabName = "Fenring_Cultist"; break; - } + string prefabName = CreaturePrefabFor(rules.Form); GameObject prefab = PrefabManager.Cache.GetPrefab(prefabName); @@ -363,9 +376,30 @@ namespace RacesOfValheim { currentTransformation = Instantiate(visual.gameObject, Player.m_localPlayer.transform); currentTransformation.transform.localPosition = Vector3.zero; currentTransformation.transform.localRotation = Quaternion.identity; + // DEAD LINE, kept until somebody decides what it was for. The game has no type + // called "AnimEvent" - the animation-event dispatcher is CharacterAnimEvent - and + // GetComponent(string) matches a type name in full, so this has never found + // anything and the Destroy has never run. Component animEvent = currentTransformation.GetComponent("AnimEvent"); if (animEvent != null) Destroy(animEvent); + // The creature's own animations carry their sounds as events; this is what hears + // them. On the object that owns the Animator, because that is where Unity delivers + // an animation event - for the wolf that is WolfSmooth, two levels down, not the + // Visual this method has in hand. + Animator formAnimator = currentTransformation.GetComponentInChildren(true); + if (formAnimator != null) + { + formAnimator.gameObject.AddComponent(); + Jotunn.Logger.LogInfo( + $"[FenrirForm] animation-event listener on '{formAnimator.gameObject.name}'."); + } + else + { + Jotunn.Logger.LogWarning( + "[FenrirForm] no Animator under the form; animation sounds will not play."); + } + float ttl = rules.DurationMinutes > 0 ? (rules.DurationMinutes * 60f) : 0f; if (prefabName == "Ulv") diff --git a/JotunnModStub/Fenrir/FormAnimEventSound.cs b/JotunnModStub/Fenrir/FormAnimEventSound.cs new file mode 100644 index 0000000..4fdea87 --- /dev/null +++ b/JotunnModStub/Fenrir/FormAnimEventSound.cs @@ -0,0 +1,89 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Plays the sounds Valheim wires into a creature's own animation clips, for a player wearing + /// that creature. + /// + /// THE HOWL WAS NEVER A PREFAB TO LOOK UP. It is an AnimationEvent. The wolf's animator carries a + /// clip called 'C_Hawl' whose single event, at 0.39s, calls a method named Effect and hands it the + /// sound as an object reference: + /// + /// 'C_Hawl' 3.13s loop=True events=1 + /// @0.39s Effect() ref='sfx_wolf_haul' (GameObject) + /// + /// Two things follow from that, and both are better than what the mod was doing. First, the clip + /// already plays on its own: a player in wolf form idles through 'C_Hawl' like any other idle, so + /// the howl animation costs nothing to get. Second, the sound belongs at 0.39s into that clip and + /// nowhere else, which is something no amount of instantiating a prefab on a keypress can match. + /// + /// Three names, three spellings, and that is the whole reason this took so long to find: the clip + /// is 'C_Hawl', the sound is 'sfx_wolf_haul', and the mod was looking for 'sfx_wolf_howl' - the + /// only correct spelling of the three, and the only one that does not exist. + /// + /// Unity calls Effect BY NAME on the components of the GameObject that owns the Animator, so this + /// has to sit there and the method must keep that name. + /// + internal class FormAnimEventSound : MonoBehaviour + { + private static readonly HashSet logged = new HashSet(); + + /// + /// Off whenever the game's own receiver is on this object, which in practice is always. + /// + /// A player in wolf form idles through 'C_Hawl' and howls, out loud, with no help from this + /// class - confirmed in game. AnimationEffect, which sits beside the Animator on the form + /// along with CharacterAnimEvent, is doing that already. Two receivers for one event means two + /// howls, so this stands down and stays only as cover for a form that turns out not to carry + /// one. The log says which of the two happened, once per form, so nobody has to wonder. + /// + private bool standDown; + + private void Awake() + { + standDown = GetComponent("AnimationEffect") != null; + + if (logged.Add("attach/" + name)) + { + Jotunn.Logger.LogInfo( + standDown + ? $"[FenrirForm] '{name}' already carries AnimationEffect; leaving animation sounds to it." + : $"[FenrirForm] '{name}' has no AnimationEffect; handling animation sounds here."); + } + } + + /// + /// CALLED BY UNITY from an AnimationEvent. Do not rename, and do not make it private. + /// + /// Only object references are taken, and only when they carry audio. The clips also fire + /// Effect with a string and no reference - 'Jump' does, with string='jump' - and that form + /// means "look something up", which is a different job and somebody else's. The audio test is + /// there because an animation can reference anything at all, and a form is not the place to + /// find out what spawning an arbitrary vanilla object does. + /// + public void Effect(AnimationEvent e) + { + if (standDown) return; + + GameObject prefab = e.objectReferenceParameter as GameObject; + if (prefab == null) return; + + bool audible = prefab.GetComponentInChildren(true) != null; + + if (logged.Add(prefab.name)) + { + Jotunn.Logger.LogInfo( + $"[FenrirForm] animation event Effect on '{name}' -> '{prefab.name}' " + + $"audio={audible}{(audible ? "" : ", skipped")}."); + } + + if (!audible) return; + + // Through the same ghost-init spawn as everything else here: some vanilla sound prefabs + // carry a ZNetView, and this one fires every time the animation comes round. + FenrirCreatureSound.Spawn(prefab, transform.position); + } + } +} From 22170087aeaef5373597affbc4ecf8d662e25edf Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 00:20:42 +0200 Subject: [PATCH 042/273] feat(debug): dumpanim, for reading an animator instead of guessing at it Guessing at animation has cost this mod real time: a howl looked for under three wrong names, a taunt animation nobody knew played, and a sound prefab that kills the process when spawned on its own. dumpanim lists a creature's parameters, layers, every clip in its controller with name and length, and every AnimationEvent on every clip - the instant, the method called, and the asset an event hands over. That last column is where a sound wired into an animation lives, and it is what finally found the wolf's howl. It also prints the components beside the Animator, because an animation event is delivered to those and nowhere else. On a prefab with no animator at all it falls back to dumping the hierarchy, the components and the audio setup, which is how a sound prefab gets looked at without being spawned - and some of them must not be spawned. dumpanim live watches every animator under the player and reports each clip change as it happens. Standing still in wolf form and reading the log is what showed 'C_Hawl' coming round in the idle rotation on its own. What Unity will not give up, and it is worth knowing before starting: the state machine. States and transitions are editor-only and GetCurrentAnimatorStateInfo returns hashes with no names, so a state can only be guessed and then confirmed. Co-Authored-By: Claude Opus 5 --- JotunnModStub/AnimatorDump.cs | 303 ++++++++++++++++++++++++++++++++ JotunnModStub/RacesOfValheim.cs | 1 + 2 files changed, 304 insertions(+) create mode 100644 JotunnModStub/AnimatorDump.cs diff --git a/JotunnModStub/AnimatorDump.cs b/JotunnModStub/AnimatorDump.cs new file mode 100644 index 0000000..edb5e40 --- /dev/null +++ b/JotunnModStub/AnimatorDump.cs @@ -0,0 +1,303 @@ +using System.Collections.Generic; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Reads out a creature's animator, because guessing at animation has cost this mod real time: + /// a howl that was looked for under three wrong names, a taunt animation nobody knew played, and + /// a sound prefab that killed the process when spawned on its own. + /// + /// WHAT UNITY LETS US SEE AT RUNTIME, and what it does not, because the line matters: + /// + /// Readable. Every parameter with its type. Every layer. Every CLIP in the controller with its + /// name and length, through RuntimeAnimatorController.animationClips - so a creature's whole + /// vocabulary can be listed without ever wearing it. And every AnimationEvent on every clip: + /// the instant, the method name it calls, and its parameters. That last one is where a sound + /// fired by an animation lives, which is the thing this was written to find. + /// + /// Not readable. The state machine. States and transitions live in AnimatorController, which is + /// an editor-only type, and GetCurrentAnimatorStateInfo hands back hashes with no names. States + /// can only be guessed and then confirmed: AnimatorStateInfo.IsName("Layer.Name") answers yes or + /// no, and Animator.Play takes a state name we can try and then verify by reading back which + /// clip actually started. + /// + /// So "catch the howl and trigger just that stretch" is possible, in this order: list the clips + /// here, find the one that looks like a howl, look at its events to see whether the sound is + /// wired into the animation, then Play the state and CrossFade back to idle at the point wanted. + /// Worth knowing before starting: if the sound is an animation event, playing the clip alone will + /// not make it, because events are dispatched to a component on the animated object and Valheim's + /// dispatcher is CharacterAnimEvent. The animation is the prize; the audio we already play + /// ourselves. + /// + public class DumpAnimCommand : ConsoleCommand + { + public override string Name => "dumpanim"; + + public override string Help => + "[DEBUG] dumpanim - lists a creature's animator parameters, layers, clips and " + + "every animation event on them. dumpanim live - logs which clip each animator under you " + + "starts playing, as it happens; run it again to stop."; + + public override void Run(string[] args) + { + if (args.Length == 0) + { + Console.instance.Print("dumpanim | dumpanim live"); + return; + } + + if (args[0].ToLower() == "live") + { + ToggleWatcher(); + return; + } + + DumpPrefab(args[0]); + } + + /// + /// Everything the controller of can play. Reads a prefab in + /// memory, so it needs no transformation and cannot disturb a live one. + /// + private static void DumpPrefab(string prefabName) + { + GameObject prefab = PrefabManager.Cache.GetPrefab(prefabName); + if (prefab == null) + { + Report($"[Anim] '{prefabName}' is not in the prefab cache."); + return; + } + + Animator[] animators = prefab.GetComponentsInChildren(true); + if (animators.Length == 0) + { + // Not a creature. Say what it is anyway: this is also how a sound prefab gets looked + // at without being spawned, which matters for the ones that cannot safely be spawned. + Report($"[Anim] '{prefabName}' has no Animator. Contents:"); + foreach (Transform t in prefab.GetComponentsInChildren(true)) + { + Jotunn.Logger.LogInfo($"[Anim] '{PathOf(t)}' [{ComponentsOf(t.gameObject)}]"); + DescribeAudio(t.gameObject); + } + return; + } + + Report($"[Anim] '{prefabName}': {animators.Length} animator(s)."); + + foreach (Animator animator in animators) + { + RuntimeAnimatorController controller = animator.runtimeAnimatorController; + Report($"[Anim] on '{PathOf(animator.transform)}' controller " + + $"'{(controller != null ? controller.name : "none")}'"); + + // What else lives on that object, because an animation event is delivered to THESE + // components and nowhere else. CharacterAnimEvent showing up here is the game's own + // receiver; a form that carries it is a form where vanilla is already handling - or + // already failing to handle - every event the clips fire. + Jotunn.Logger.LogInfo($"[Anim] receivers: [{ComponentsOf(animator.gameObject)}]"); + + if (controller == null) continue; + + foreach (AnimatorControllerParameter p in animator.parameters) + { + Jotunn.Logger.LogInfo($"[Anim] param {p.name} ({p.type})"); + } + + for (int i = 0; i < animator.layerCount; i++) + { + Jotunn.Logger.LogInfo($"[Anim] layer {i} '{animator.GetLayerName(i)}'"); + } + + AnimationClip[] clips = controller.animationClips; + Report($"[Anim] {clips.Length} clip(s):"); + + foreach (AnimationClip clip in clips) + { + if (clip == null) continue; + + AnimationEvent[] events = clip.events; + Jotunn.Logger.LogInfo( + $"[Anim] '{clip.name}' {clip.length:F2}s loop={clip.isLooping} " + + $"events={events.Length}"); + + foreach (AnimationEvent e in events) + { + // The object reference is the interesting one: a sound wired into an + // animation arrives here as the asset itself, name included. + string reference = e.objectReferenceParameter != null + ? $" ref='{e.objectReferenceParameter.name}' ({e.objectReferenceParameter.GetType().Name})" + : ""; + Jotunn.Logger.LogInfo( + $"[Anim] @{e.time:F2}s {e.functionName}(" + + $"string='{e.stringParameter}' float={e.floatParameter:F2} " + + $"int={e.intParameter}){reference}"); + } + } + } + } + + private static void ToggleWatcher() + { + if (Player.m_localPlayer == null) + { + Console.instance.Print("dumpanim live needs you to be in the world."); + return; + } + + AnimatorWatcher existing = Player.m_localPlayer.GetComponent(); + if (existing != null) + { + Object.Destroy(existing); + Report("[Anim] live watch off."); + return; + } + + Player.m_localPlayer.gameObject.AddComponent(); + Report("[Anim] live watch on: every clip change under you, as it happens."); + } + + /// + /// Why a sound prefab is or is not audible when it is simply instantiated. + /// + /// The AudioSource settings say whether anything starts by itself, and ZSFX's own fields say + /// what it would play if asked - it keeps a LIST of clips and chooses at play time, so a + /// prefab whose AudioSource has no clip is normal rather than broken. Read through reflection + /// because these are the game's private serialized fields. + /// + private static void DescribeAudio(GameObject go) + { + AudioSource audio = go.GetComponent(); + if (audio != null) + { + Jotunn.Logger.LogInfo( + $"[Anim] AudioSource playOnAwake={audio.playOnAwake} " + + $"clip='{(audio.clip != null ? audio.clip.name : "none")}' " + + $"volume={audio.volume:F2} spatialBlend={audio.spatialBlend:F2} " + + $"range={audio.minDistance:F1}-{audio.maxDistance:F1} loop={audio.loop} " + + $"mixer='{(audio.outputAudioMixerGroup != null ? audio.outputAudioMixerGroup.name : "none")}'"); + } + + foreach (Component comp in go.GetComponents()) + { + if (comp == null || comp.GetType().Name != "ZSFX") continue; + + List fields = new List(); + foreach (System.Reflection.FieldInfo f in comp.GetType().GetFields( + System.Reflection.BindingFlags.Instance | + System.Reflection.BindingFlags.Public | + System.Reflection.BindingFlags.NonPublic)) + { + object value = f.GetValue(comp); + System.Array array = value as System.Array; + if (array == null) + { + fields.Add($"{f.Name}={value}"); + continue; + } + + // The elements, not just the count. m_audioClips is where a sound's actual clips + // live, and whether they are AudioClips or unloaded soft references is the whole + // question when a sound spawns and stays silent. + List elements = new List(); + for (int e = 0; e < array.Length && e < 4; e++) + { + object item = array.GetValue(e); + Object asObject = item as Object; + elements.Add(item == null + ? "null" + : $"{item.GetType().Name}:'{(asObject != null ? asObject.name : item.ToString())}'"); + } + fields.Add($"{f.Name}[{array.Length}]={{{string.Join(", ", elements.ToArray())}}}"); + } + + Jotunn.Logger.LogInfo($"[Anim] ZSFX {string.Join(" ", fields.ToArray())}"); + Jotunn.Logger.LogInfo( + $"[Anim] ZSFX methods: {string.Join(", ", MethodNamesOf(comp))}"); + } + } + + private static string[] MethodNamesOf(Component comp) + { + List names = new List(); + foreach (System.Reflection.MethodInfo m in comp.GetType().GetMethods( + System.Reflection.BindingFlags.Instance | + System.Reflection.BindingFlags.Public | + System.Reflection.BindingFlags.DeclaredOnly)) + { + names.Add(m.Name + "(" + m.GetParameters().Length + ")"); + } + return names.ToArray(); + } + + /// The component type names on one object, Transform left out as noise. + private static string ComponentsOf(GameObject go) + { + List names = new List(); + foreach (Component comp in go.GetComponents()) + { + if (comp != null && !(comp is Transform)) names.Add(comp.GetType().Name); + } + return string.Join(", ", names.ToArray()); + } + + private static string PathOf(Transform t) + { + string path = t.name; + for (Transform p = t.parent; p != null; p = p.parent) path = p.name + "/" + path; + return path; + } + + /// To the log and to the console both, since one of the two is always the wrong one. + private static void Report(string line) + { + Jotunn.Logger.LogInfo(line); + if (Console.instance != null) Console.instance.Print(line); + } + + /// + /// Watches every animator under the player and says when one starts a different clip. + /// + /// Only the change is logged, not the state: an animator asked every frame would fill the log + /// with the idle it is already playing. The heaviest clip is the one reported, because during + /// a transition two are live at once and the heavier one is the one being watched on screen. + /// + private class AnimatorWatcher : MonoBehaviour + { + private readonly Dictionary last = new Dictionary(); + + private void Update() + { + foreach (Animator animator in GetComponentsInChildren(true)) + { + if (animator == null || animator.runtimeAnimatorController == null) continue; + + AnimatorClipInfo[] playing = animator.GetCurrentAnimatorClipInfo(0); + if (playing.Length == 0) continue; + + AnimationClip heaviest = null; + float weight = -1f; + foreach (AnimatorClipInfo info in playing) + { + if (info.clip != null && info.weight > weight) + { + heaviest = info.clip; + weight = info.weight; + } + } + if (heaviest == null) continue; + + string previous; + if (last.TryGetValue(animator, out previous) && previous == heaviest.name) continue; + + last[animator] = heaviest.name; + Jotunn.Logger.LogInfo( + $"[Anim] live: '{PathOf(animator.transform)}' -> '{heaviest.name}' " + + $"{heaviest.length:F2}s weight={weight:F2} events={heaviest.events.Length}"); + } + } + } + } +} diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 0235ed9..c703e24 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -79,6 +79,7 @@ namespace RacesOfValheim CommandManager.Instance.AddConsoleCommand(new FenrirPackSpawnCommand()); CommandManager.Instance.AddConsoleCommand(new DumpPotionsCommand()); CommandManager.Instance.AddConsoleCommand(new ListPrefabsCommand()); + CommandManager.Instance.AddConsoleCommand(new DumpAnimCommand()); } /// From da896179fd6c4d4f407900d13a0d98a12cf8bb87 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 01:41:00 +0200 Subject: [PATCH 043/273] feat(fenrir): howl on demand, in every form The howl key was only ever read by the two Fenring forms. As a wolf or an Ulv it did nothing at all - not a misconfiguration, the classes simply never looked at it. All four forms read it now. The wolf and the Ulv perform the creature's own howl animation and NO SOUND IS SPAWNED, because their clip already carries one: 'C_Hawl' fires an animation event at 0.39s holding sfx_wolf_haul, and the game's own AnimationEffect plays it. The audio comes out of the animation, at the instant the animation means it to, which no prefab fired on a keypress can match. Spawning one as well would be a second howl over the first. A trigger is looked for before a state, and that is about multiplayer rather than tidiness: FenrirAttackSync replicates trigger names, so a howl fired through a trigger is one the other clients see and hear, while Animator.Play is local and nobody else knows. Which route was taken is logged once per creature, and if neither exists the log prints the animator's whole parameter list rather than leaving another keypress that quietly does nothing. The Fenring and the Cultist have no howl clip in vanilla - 19 and 18 clips, none of them a howl, and their taunt fires no sound event - so they keep the Taunt animation and take the wolf's howl as their voice. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Fenrir/FenrirBehaviors.cs | 141 +++++++++++++++++++++++- 1 file changed, 139 insertions(+), 2 deletions(-) diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 380f47c..70137f4 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -93,6 +93,71 @@ namespace RacesOfValheim if (!Play(FireRoar, position, "fire roar")) PlayAlertedEffects("Fenring_Cultist", position); } + /// + /// State names to try when a creature has no howl trigger. 'C_Hawl' first, and that spelling + /// is not a typo here - it is the game's, on the wolf's own clip. + /// + private static readonly string[] HowlStates = { "C_Hawl", "C_Howl", "Hawl", "Howl", "Taunt" }; + + /// + /// Makes the worn creature perform its own howl, and says whether it could. + /// + /// WORTH KNOWING BEFORE READING THE CODE: on the wolf this brings the sound with it. Its howl + /// clip carries the sound as an animation event - 'C_Hawl' fires Effect at 0.39s holding + /// sfx_wolf_haul - and the game's own AnimationEffect, which sits beside the Animator on the + /// form, plays it. So for the wolf and the Ulv there is no sound to spawn at all: play the + /// animation and the howl comes out of it, at the instant the animation means it to. + /// + /// A TRIGGER IS TRIED BEFORE A STATE, and the reason is multiplayer rather than tidiness. + /// FenrirAttackSync replicates trigger names, so a howl fired through a trigger is a howl the + /// other clients see and hear. Animator.Play is local: it works, and nobody else knows. + /// comes back non-null exactly when the caller has something + /// worth publishing. + /// + public static bool TryHowlAnimation(Animator animator, string creature, out string triggerName) + { + triggerName = null; + if (animator == null || animator.runtimeAnimatorController == null) return false; + + foreach (AnimatorControllerParameter p in animator.parameters) + { + if (p.type != AnimatorControllerParameterType.Trigger) continue; + + string lower = p.name.ToLower(); + if (!lower.Contains("hawl") && !lower.Contains("howl") && !lower.Contains("taunt")) continue; + + animator.SetTrigger(p.name); + triggerName = p.name; + LogHowlRouteOnce(creature, $"trigger '{p.name}'"); + return true; + } + + foreach (string state in HowlStates) + { + int hash = Animator.StringToHash(state); + if (!animator.HasState(0, hash)) continue; + + animator.Play(hash, 0); + LogHowlRouteOnce(creature, $"state '{state}', played directly - local only, " + + "no trigger exists to replicate it"); + return true; + } + + // Nothing matched, so say what there was to match against. A keypress that does nothing is + // the thing this whole exercise started from. + List parameters = new List(); + foreach (AnimatorControllerParameter p in animator.parameters) parameters.Add($"{p.name}({p.type})"); + LogHowlRouteOnce(creature, + "no howl trigger and no howl state. Parameters: " + string.Join(", ", parameters.ToArray()) + + ". Run 'dumpanim " + creature + "' for its clip list"); + return false; + } + + private static void LogHowlRouteOnce(string creature, string route) + { + if (logged.Add("howl/" + creature)) Jotunn.Logger.LogInfo($"[FenrirForm] howl for '{creature}': {route}."); + } + /// Instantiates the first name that resolves and is safe. True if anything played. private static bool Play(string[] prefabNames, Vector3 position, string label) { @@ -1094,7 +1159,13 @@ namespace RacesOfValheim if (isGrounded && RaceInput.Allowed) { - if (RaceInput.AttackDown(0)) // Left Click + // The howl, on the same key as every other form. It used to be read only by the + // two Fenring forms, so pressing it as a wolf did nothing at all. + if (!isAttacking && FenrirConfig.HowlKey.Value.IsDownIgnoringHeldKeys()) + { + StartCoroutine(WolfHowlRoutine()); + } + else if (RaceInput.AttackDown(0)) // Left Click { StartCoroutine(WolfAttackRoutine("attack1", FenrirConfig.WolfAttack1Damage.Value, 0.6f, 0.2f)); } @@ -1123,6 +1194,36 @@ 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. + /// + private IEnumerator WolfHowlRoutine() + { + isAttacking = true; + + 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); + } + + // 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); + + isAttacking = false; + } + private IEnumerator WolfAttackRoutine(string triggerName, float baseDamage, float lockDuration, float dmgDelay) { isAttacking = true; @@ -1268,7 +1369,13 @@ namespace RacesOfValheim if (isGrounded && RaceInput.Allowed) { - if (RaceInput.AttackDown(0)) // Left Click + // The howl, on the same key as every other form. It used to be read only by the + // two Fenring forms, so pressing it as a wolf did nothing at all. + if (!isAttacking && FenrirConfig.HowlKey.Value.IsDownIgnoringHeldKeys()) + { + StartCoroutine(UlvHowlRoutine()); + } + else if (RaceInput.AttackDown(0)) // Left Click { StartCoroutine(UlvAttackRoutine("attack_bite", FenrirConfig.UlvBiteDamage.Value, 0.6f, 0.2f)); } @@ -1298,6 +1405,36 @@ 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. + /// + private IEnumerator UlvHowlRoutine() + { + isAttacking = true; + + 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); + } + + // 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); + + isAttacking = false; + } + private IEnumerator UlvAttackRoutine(string triggerName, float baseDamage, float lockDuration, float dmgDelay) { isAttacking = true; From 421bc72eb73c1481aa1975e6c239b122dc18cf99 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 01:45:08 +0200 Subject: [PATCH 044/273] chore(release): v1.4.24 Version bumped in both places that carry it - manifest.json is what Thunderstore ships, PluginVersion is what the game logs - since those two have drifted apart before. The Nexus description is generated now rather than rewritten by hand. It had fallen thirteen versions behind the README, which is how a hand-maintained copy of a 72KB document goes. scripts/nexus-readme.py converts README.md to the BBCode the page wants, following what the 1.4.11 page did by hand so the two are comparable, and writes dist/NEXUS_README_.bbcode.txt. The wiki link was on the Nexus page and had never been in the README, so every other channel shipped without it. It is in the README now, which means it reaches Nexus, Thunderstore and the repository from one place. Co-Authored-By: Claude Opus 5 --- JotunnModStub/RacesOfValheim.cs | 2 +- README.md | 10 +++ manifest.json | 2 +- scripts/nexus-readme.py | 105 ++++++++++++++++++++++++++++++++ 4 files changed, 117 insertions(+), 2 deletions(-) create mode 100644 scripts/nexus-readme.py diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index c703e24..9b7a5c3 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public const string PluginGUID = "com.nandor.racesofvalheim"; public const string PluginName = "Races Of Valheim"; - public const string PluginVersion = "1.4.23"; + public const string PluginVersion = "1.4.24"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/README.md b/README.md index d3141fa..48a2fbd 100644 --- a/README.md +++ b/README.md @@ -7,6 +7,7 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing ## Development & Feedback This is a stable release, but more races and refinements are planned! +Wiki: [https://wiki.aledanidev.ovh/](https://wiki.aledanidev.ovh/) Bug reports, feedback, ideas: [https://discord.gg/jJzuKBZNC](https://discord.gg/jJzuKBZNC) Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorTheModder) @@ -412,6 +413,15 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ## Changelog +### v1.4.24 +- **Fix - Purple smoke around the Skeleton's burning skull with some magic mods installed:** the fire aura the Skeleton wears from Moder on looked for its particles under two names that are not in Valheim at all. A name the game does not use is a free slot for whichever mod ships one, and with Magic Supremacy installed the aura picked up that mod's weapon trail on an emissive shader and sprayed it through a five-metre sphere. The aura had never actually been visible in a plain install, so it now draws nothing on purpose; its damage, radius and tick are untouched. Thanks to the players who reported it and named the mods they were running. +- **Fix - Effects and sounds that were quietly missing across five races:** an audit of every prefab the mod asks for by name found nine that do not exist in the game, each one failing in silence. The puff that covers a transformation never played for the Fenrir, the Skadi or the Trenta's Muspell; the Aswid's Mist Form appeared and vanished with no effect at all, and so did dominating a creature with a thrall; the Aswid's two status effects and its Bat Form entry in the radial had no icon. All of them now use names the game really has. +- **Fix - A Draugh's successful parry threw an error and cancelled its own frost nova:** the poison splash asked for an effect that does not exist and passed it straight to the game without checking, so every parry inside the window failed at that line - taking the North Wind nova that runs immediately after it down as well. Both work now. +- **New - Human Meat is a real item at last:** the Bonemass tier has promised it since 1.4 and nothing ever created it, so the drop never happened and the "fatal to the living" warning never fired. A player who dies inside your death aura now leaves a piece behind, yourself included, and only a Draugh can stomach it. It is built from Blood Pudding's own nourishment, with its stamina folded into health since a Draugh has no use for stamina, and is tunable under `Draugh - Undead Fortitude`. +- **Fix - Fenrir forms fought in a borrowed voice, or in silence:** every form's sounds were looked up by name and most of those names are not in the game. The chains hid it - a Fenring swung with a wolf's voice through a fallback - and the Cultist's double claw asked for three dead names in a row and had never made a sound at all. Each form now uses the creature's own sounds, and the jump attack's impact lands with the jump instead of firing while the form is still standing. +- **New - Howl on demand in every Fenrir form:** the howl key was only ever read by the Fenring and the Cultist. As a wolf or an Ulv it did nothing. All four howl now, and the wolf and the Ulv use the creature's real howl animation - the sound is carried inside that animation, so it lands at the moment the animation means it to. +- **Fix - Fenrir form sounds no longer write into your world save:** some of the game's sound prefabs carry a networked component, and spawning one the ordinary way leaves a persistent record behind - one per claw swing. They are now spawned the way the game itself does it, and leave nothing. + ### v1.4.23 - **Fix - Trol clients could not chop trees or mine rocks with their fists:** the fist bonus (chop and pickaxe damage, and the tool tier that grows with the bosses) was applied on whichever machine owned the tree or rock - usually the host - where the hit did not belong to the local player, so it only ever worked for the host. It is now applied on the attacking player's own machine before the hit is sent. Thanks to the players who reported it. - **New - Configuration is synced from the server:** every gameplay setting now follows the server's value in multiplayer, and is locked in Configuration Manager for players who are not admins. Keybinds and the purely cosmetic settings (eye and claw colours, glow, model rotation and offsets, the Head Fire VFX and stamina-bar toggles, debug logging) stay local, so each player keeps their own. diff --git a/manifest.json b/manifest.json index fc74963..23d6c7d 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.23", + "version_number": "1.4.24", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/scripts/nexus-readme.py b/scripts/nexus-readme.py new file mode 100644 index 0000000..d83142d --- /dev/null +++ b/scripts/nexus-readme.py @@ -0,0 +1,105 @@ +"""Turns the mod's README.md into the BBCode Nexus wants. + +The Nexus page had been rewritten by hand each release and had fallen thirteen +versions behind the README, so it is generated now. Run it after the changelog +entry is in and the version is bumped: + + python scripts/nexus-readme.py + +It reads manifest.json for the version and writes +dist/NEXUS_README_.bbcode.txt. + +The conversion follows what the 1.4.11 page did by hand, so the two are +comparable: headings become sized bold, a horizontal rule goes above every +top-level section, images are gathered onto one line per group, backticks +become quotes because Nexus has no code style, and the
wrappers +around the progressions are dropped while their summaries survive as headings. +""" +import json +import pathlib +import re + +ROOT = pathlib.Path(__file__).resolve().parent.parent +RULE = "[s]---------------------------------------------------[/s]" + + +def inline(text): + """Markdown's inline marks, in an order where they cannot eat each other.""" + text = re.sub(r"\*\*(.+?)\*\*", r"[b]\1[/b]", text) + text = re.sub(r"`([^`]+)`", r'"\1"', text) + # An in-page anchor means nothing on a Nexus description, so the link text stays and the + # link goes: "Full details under Sverm" reads the same, and a dead #10-sverm does not. + text = re.sub(r"\[([^\]]+)\]\(#[^)]*\)", r"\1", text) + text = re.sub(r"\[([^\]]+)\]\(([^)]+)\)", r"[url=\2]\1[/url]", text) + return text + + +def image(url): + # The march gif is a strip rather than a portrait, and was shown smaller by hand. + return f"[img height={200 if 'small' in url else 350}]{url}[/img]" + + +def table_row(line): + cells = [inline(c.strip()) for c in line.strip().strip("|").split("|")] + if not cells: + return None + return "- [b]" + cells[0] + "[/b]" + ("" if len(cells) == 1 else " — " + " — ".join(cells[1:])) + + +def convert(markdown): + out = [] + pending_images = [] + + def flush_images(): + if pending_images: + out.append("".join(pending_images)) + pending_images.clear() + + for line in markdown.splitlines(): + stripped = line.strip() + + # Images stack up so a group of them lands on one line, the way Nexus shows them. + match = re.fullmatch(r"!\[[^\]]*\]\(([^)]+)\)", stripped) + if match: + pending_images.append(image(match.group(1))) + continue + flush_images() + + if not stripped or stripped in ("
", "
", "---"): + continue + + match = re.fullmatch(r"(.+?)", stripped) + if match: + out.append(f"[size=4][b]{inline(match.group(1))}[/b][/size]") + continue + + match = re.fullmatch(r"(#{1,3})\s+(.*)", stripped) + if match: + level, title = len(match.group(1)), inline(match.group(2)) + if level == 2: + out.append(RULE) + out.append(f"[size={7 - level}][b]{title}[/b][/size]") + continue + + if stripped.startswith("|"): + if re.fullmatch(r"\|[\s\-:|]+\|", stripped): # the --- separator row + continue + row = table_row(stripped) + if row: + out.append(row) + continue + + out.append(inline(stripped)) + + flush_images() + return "\n".join(out) + "\n" + + +def main(): + version = json.loads((ROOT / "manifest.json").read_text(encoding="utf-8-sig"))["version_number"] + target = ROOT / "dist" / f"NEXUS_README_{version}.bbcode.txt" + target.write_text(convert((ROOT / "README.md").read_text(encoding="utf-8-sig")), encoding="utf-8") + print(f"{target.relative_to(ROOT)} ({len(target.read_text(encoding='utf-8').splitlines())} lines)") + + +main() From 1c8fa7357fbbb7555c170f8bb81d37e3b356d7fd Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 01:50:21 +0200 Subject: [PATCH 045/273] chore(release): sync the packaging manifest to 1.4.24 JotunnModStub/Package/manifest.json is a second copy of the root manifest, kept by hand and differing from it only in the version - a third place for the version to drift, on top of the two MAINTAINING.md already warns about. It was still on 1.4.23. Synced rather than fixed: the packaging step should copy the root manifest instead of there being two, which is a change to make when the artifacts are built rather than in a version bump. Co-Authored-By: Claude Opus 5 --- JotunnModStub/Package/manifest.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index fc74963..23d6c7d 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.", - "version_number": "1.4.23", + "version_number": "1.4.24", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 6b43d3544e3a2b92b1d7cb04c2fa046a3423eb1a Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 14:00:21 +0200 Subject: [PATCH 046/273] feat(fenrir): say why the fire breath did not come, and log a Draugh's parry Holding right mouse as a Cultist with no eitr did nothing whatsoever - no flames, no sound, no reason given. The form arrives at Yagluth and eitr is a Mistlands thing, so a Cultist meets that silence before it ever meets the fire. It now says "Only breath comes out. The fire wants eitr." on a three-second timer, since the button is read every frame and the message would otherwise be a wall. The parry that fires the Draugh's poison splash is logged, with the block timer against the window and whether the splash effect resolved. A parry has to land inside a quarter-second window while blocking, so "nothing looks different after tier 3" is as likely to mean the window was missed as it is to mean the splash did not draw, and there was no way to tell those apart. Co-Authored-By: Claude Opus 5 --- .../Draugh/DraughProgressionPatches.cs | 9 +++++++ JotunnModStub/Fenrir/FenrirBehaviors.cs | 24 +++++++++++++++++-- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/JotunnModStub/Draugh/DraughProgressionPatches.cs b/JotunnModStub/Draugh/DraughProgressionPatches.cs index f56ce0f..105eb1b 100644 --- a/JotunnModStub/Draugh/DraughProgressionPatches.cs +++ b/JotunnModStub/Draugh/DraughProgressionPatches.cs @@ -109,6 +109,15 @@ namespace RacesOfValheim UnityEngine.Object.Instantiate(splashVfx, attacker.GetCenterPoint(), Quaternion.identity); } + // Said on every parry, which are rare enough not to be noise. A parry has + // to land inside a quarter-second window while blocking, so "nothing looks + // different" is as likely to mean the window was missed as it is to mean + // the splash did not draw - and there was no way to tell the two apart. + Jotunn.Logger.LogInfo( + $"[Draugh] Parry on '{attacker.name}': {DraughConfig.PoisonSplashDamage.Value:F0} poison, " + + $"blockTimer={blockTimer:F3} of {parryTime:F2}, " + + $"splash vfx={(splashVfx != null ? "vfx_blob_hit" : "NOT RESOLVED")}."); + // Stage 5: North Wind (AoE Frost) if (state >= 5) { diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 70137f4..ef2d09c 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -815,9 +815,14 @@ namespace RacesOfValheim UpdateFire(); } } - else if (isShootingFire) + else { - StopFire(); + // Held with an empty pool. Until now this did nothing whatsoever: no + // flames, no sound, no reason given - and the form's own tier is Yagluth + // while eitr is a Mistlands thing, so a Cultist meets this before it ever + // meets the fire. + SayNoEitr(); + if (isShootingFire) StopFire(); } } else if (isShootingFire) @@ -883,6 +888,21 @@ namespace RacesOfValheim private GameObject fireEffectInstance; + private float lastNoEitrMessage = -100f; + + /// + /// Says why the fire did not come. Held down rather than tapped, so it is on a timer: the + /// button is read every frame and the message would otherwise be a wall. + /// + private void SayNoEitr() + { + if (Player.m_localPlayer == null || Time.time - lastNoEitrMessage < 3f) return; + + lastNoEitrMessage = Time.time; + Player.m_localPlayer.Message(MessageHud.MessageType.Center, + "Only breath comes out. The fire wants eitr."); + } + private void StartFire() { if (Player.m_localPlayer == null || isShootingFire) return; From cd1072259475800f123481b2c4d7142b01e6331a Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 16:27:42 +0200 Subject: [PATCH 047/273] docs: say that the Cultist's fire breath runs on eitr The feature list said "Transform into a Cultist to use fire abilities" and never mentioned a cost. The flames take 12.5 eitr per second, and eitr comes from the Mistlands while the form unlocks at Yagluth - so the form can be had with its signature attack still out of reach. Both the feature bullet and the changelog say so now. Co-Authored-By: Claude Opus 5 --- README.md | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 48a2fbd..3f7f542 100644 --- a/README.md +++ b/README.md @@ -46,7 +46,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions ![Fenrir1](https://wiki.aledanidev.ovh/assets/images/fenrir1.gif) ![Fenrir3](https://wiki.aledanidev.ovh/assets/images/fenrir3.gif) - **Beast Form:** Transform into a wolf-like beast. -- **Cultist Form:** Transform into a Cultist to use fire abilities. +- **Cultist Form:** Transform into a Cultist. Its claws cost nothing, but the **fire breath (hold Right Mouse) runs on eitr** — 12.5 per second — and eitr comes from the Mistlands, so the form unlocks at Yagluth with its flames still out of reach. Holding the button with an empty pool now says so. - **Cursed Claws:** The wolf's hands, kept on in the man's shape — see [Claws](#claws). - **A Pack of Your Own:** The Pack Trough keeps a standing pack of wolves, ulvs and, late, fenrir — see [Race Stations](#race-stations--companions). - **Progression:** Forms grow as you defeat bosses, unlocking new powers and reducing cooldowns. Immune to fall damage. @@ -419,6 +419,7 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact - **Fix - A Draugh's successful parry threw an error and cancelled its own frost nova:** the poison splash asked for an effect that does not exist and passed it straight to the game without checking, so every parry inside the window failed at that line - taking the North Wind nova that runs immediately after it down as well. Both work now. - **New - Human Meat is a real item at last:** the Bonemass tier has promised it since 1.4 and nothing ever created it, so the drop never happened and the "fatal to the living" warning never fired. A player who dies inside your death aura now leaves a piece behind, yourself included, and only a Draugh can stomach it. It is built from Blood Pudding's own nourishment, with its stamina folded into health since a Draugh has no use for stamina, and is tunable under `Draugh - Undead Fortitude`. - **Fix - Fenrir forms fought in a borrowed voice, or in silence:** every form's sounds were looked up by name and most of those names are not in the game. The chains hid it - a Fenring swung with a wolf's voice through a fallback - and the Cultist's double claw asked for three dead names in a row and had never made a sound at all. Each form now uses the creature's own sounds, and the jump attack's impact lands with the jump instead of firing while the form is still standing. +- **New - The Cultist says why its fire will not come:** holding Right Mouse with no eitr did nothing whatsoever - no flames, no sound, no reason given. The form arrives at Yagluth and eitr is a Mistlands thing, so a Cultist meets that silence before it ever meets the fire. It now tells you the flames want eitr. - **New - Howl on demand in every Fenrir form:** the howl key was only ever read by the Fenring and the Cultist. As a wolf or an Ulv it did nothing. All four howl now, and the wolf and the Ulv use the creature's real howl animation - the sound is carried inside that animation, so it lands at the moment the animation means it to. - **Fix - Fenrir form sounds no longer write into your world save:** some of the game's sound prefabs carry a networked component, and spawning one the ordinary way leaves a persistent record behind - one per claw swing. They are now spawned the way the game itself does it, and leave nothing. From 7ad1d6920ea8100582909e6a5a9f9dc74eade928 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 16:55:19 +0200 Subject: [PATCH 048/273] 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; } From 2b900d91e782dfa0f30f2364591f7fe6ed76206b Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 17:15:21 +0200 Subject: [PATCH 049/273] fix(input): the radial menu no longer swings the form it is opening a menu on Clicking an entry in the race wheel also fired the transformed form's attack. The click picks the entry AND is read here as a raw mouse button, because the forms read the device directly rather than going through Humanoid.StartAttack. Vanilla attacks never had this: they go through ZInput, which the radial already blocks, so only input read straight off the device got through - which is all of ours. Hud.InRadial() answers it, the same shape of call as the Hud.IsPieceSelectionVisible() already here for the hammer's build panel. That is now the second GUI Player.TakeInput knows nothing about. CHECKED IN AttackDown AND NOT IN Allowed, deliberately. The radial fires an ability by queueing its keybind through Press(), and the ability's own reader picks that up inside an Allowed gate - so blocking Allowed while the wheel is open would risk the wheel swallowing the abilities it exists to trigger. The second half is the same bug one layer down: an ability bound to a mouse BUTTON does not go through AttackDown at all. Skadi's cold spell sits on middle mouse, so middle-clicking an entry in the wheel cast it. IsDownIgnoringHeldKeys now takes the queued press first and without any gate - that one is the radial itself - and ignores a raw mouse button while the wheel is up. Keys at the keyboard are untouched: nothing about an open wheel makes pressing K ambiguous. Co-Authored-By: Claude Opus 5 --- JotunnModStub/RaceInput.cs | 55 +++++++++++++++++++++++++++++++++++++- 1 file changed, 54 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/RaceInput.cs b/JotunnModStub/RaceInput.cs index 4ec970b..2622a5d 100644 --- a/JotunnModStub/RaceInput.cs +++ b/JotunnModStub/RaceInput.cs @@ -15,13 +15,16 @@ namespace RacesOfValheim /// (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, + /// TWO GUIS THAT TakeInput DOES NOT COVER. The first is 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. + /// + /// The second is the radial menu, and it is handled in AttackDown rather than here - see + /// RadialOpen for why the difference matters. /// public static class RaceInput { @@ -77,8 +80,18 @@ namespace RacesOfValheim ///
public static bool IsDownIgnoringHeldKeys(this KeyboardShortcut shortcut) { + // The queued press is taken FIRST and without any gate, because that is the radial menu + // firing this very ability - see Press(). Everything below is the device being read raw. if (ConsumePress(shortcut)) return true; if (shortcut.MainKey == KeyCode.None) return false; + + // A keybind that sits on a mouse button is the radial's own click as far as the device is + // concerned, so the wheel closes this door too. AttackDown covers the forms' attacks; + // this covers abilities bound to a button instead - Skadi's cold spell is on middle + // mouse, and middle-clicking an entry in the wheel used to cast it. Keys at the keyboard + // are left alone: nothing about the wheel makes pressing K ambiguous. + if (RadialOpen && IsMouseButton(shortcut.MainKey)) return false; + if (!Input.GetKeyDown(shortcut.MainKey)) return false; foreach (KeyCode modifier in shortcut.Modifiers) @@ -143,15 +156,55 @@ namespace RacesOfValheim ///
public static bool AttackDown(int mouseButton) { + if (RadialOpen) return false; return Input.GetMouseButtonDown(mouseButton) || PadAttackDown(mouseButton); } /// Held-down counterpart of . public static bool AttackHeld(int mouseButton) { + if (RadialOpen) return false; return Input.GetMouseButton(mouseButton) || PadAttackHeld(mouseButton); } + /// + /// Whether the radial menu is up, which is a third GUI TakeInput knows nothing about. + /// + /// Clicking an entry in the wheel was also swinging the transformed form's attack: the click + /// picks the entry AND is read here as a raw mouse button. Vanilla attacks are untouched by + /// this because they go through ZInput, which the radial already blocks - only input read + /// straight off the device gets through, which is all of ours. + /// + /// CHECKED HERE AND NOT IN , deliberately. The radial fires an ability by + /// queueing its keybind through Press(), and the ability's own reader picks that up inside an + /// Allowed gate - so blocking Allowed while the wheel is open would risk the wheel swallowing + /// the very abilities it exists to trigger. The queued press does survive, since it holds for + /// PressWindow rather than a single frame, but there is no reason to lean on that when only + /// the mouse reads are the problem. Keybinds pressed at the keyboard while the wheel is open + /// are left alone for the same reason. + /// + private static bool IsMouseButton(KeyCode key) + { + return key >= KeyCode.Mouse0 && key <= KeyCode.Mouse6; + } + + private static bool RadialOpen + { + get + { + try + { + return Hud.InRadial(); + } + catch + { + // Fail open, like the TakeInput path above: a game update that moves this must + // cost the fix, not every attack in every form. + return false; + } + } + } + /// The gamepad half of alone, for attacks whose mouse /// side is a rebindable KeyboardShortcut rather than a fixed button. public static bool PadAttackDown(int mouseButton) From e973e2100307757da11087cce92a89e1071e173b Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 17:30:35 +0200 Subject: [PATCH 050/273] chore(input): quieten the radial proof to one line per state The transition log did its job - it showed Hud.InRadial() reporting False at spawn with no wheel on screen, which is what the gate depends on and what the method's name alone could not promise. Left in, because that proof is worth one line in every player's log, but said once per state instead of twice per use of the wheel. Co-Authored-By: Claude Opus 5 --- JotunnModStub/RaceInput.cs | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/RaceInput.cs b/JotunnModStub/RaceInput.cs index 2622a5d..283b34e 100644 --- a/JotunnModStub/RaceInput.cs +++ b/JotunnModStub/RaceInput.cs @@ -188,13 +188,33 @@ namespace RacesOfValheim return key >= KeyCode.Mouse0 && key <= KeyCode.Mouse6; } + // Said once for each answer it ever gives, and then never again. The whole gate rests on what + // Hud.InRadial() means, and that was read off the method's name rather than its body - so it + // is worth one line of proof in every player's log that it reports False with no wheel on + // screen. If it ever logs only True, the gate is eating input it has no business eating. + private static bool loggedOpen; + private static bool loggedClosed; + private static bool RadialOpen { get { try { - return Hud.InRadial(); + bool open = Hud.InRadial(); + + if (open && !loggedOpen) + { + loggedOpen = true; + Jotunn.Logger.LogInfo("[RaceInput] Radial menu open: form attacks and mouse-bound abilities are held."); + } + else if (!open && !loggedClosed) + { + loggedClosed = true; + Jotunn.Logger.LogInfo("[RaceInput] Radial menu closed: form attacks and mouse-bound abilities are live."); + } + + return open; } catch { From 97d02855e5fda8df211ed7aa938d35dd46b61d77 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 18:12:34 +0200 Subject: [PATCH 051/273] feat(skadi): say why a Cold Spell press did not cast, and log each step of the cast Every gate on the spell was silent, so "it does nothing" looked the same as "it was never pressed". Each refusal now logs its reason once per session, and the cast logs each step before taking it, because the crash it chases kills the process without a stack trace. The prefab descriptions run after the Instantiate, so reading them can't be what makes the spawn safe. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Skadi/SkadiRace.cs | 140 +++++++++++++++++++++++++++++-- 1 file changed, 133 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index cfe78d4..4746139 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -232,6 +232,12 @@ namespace RacesOfValheim { HandleColdSpell(rules); } + else if (ColdSpellKeyPressed()) + { + ColdSpellBail(!rules.ColdSpell + ? $"the tier does not grant it - state {BossProgressionManager.GetCurrentProgressionState()}, needs 2" + : "RaceInput.Allowed is false - a GUI has the input"); + } if (isTransformingSequence) return; @@ -334,16 +340,84 @@ namespace RacesOfValheim Jotunn.Logger.LogInfo($"=== END {prefabName.ToUpper()} DEBUG INFO ==="); } + /// + /// Whether the Cold Spell's own key went down this frame, read raw and with no gate at all. + /// Only for the diagnostics below: five different conditions can swallow this spell and every + /// one of them is silent, so "it does nothing" was impossible to tell apart from "it was + /// never pressed". + /// + private static bool ColdSpellKeyPressed() + { + KeyCode key = SkadiConfig.ColdSpellKey.Value.MainKey; + return key != KeyCode.None && Input.GetKeyDown(key); + } + + private static readonly System.Collections.Generic.HashSet coldSpellBails = + new System.Collections.Generic.HashSet(); + + /// One step of the cast, said before it is taken. Once per distinct step. + private static void ColdSpellStep(string step) + { + if (coldSpellBails.Add("step:" + step)) + { + Jotunn.Logger.LogInfo($"[Skadi] Cold Spell: {step}."); + } + } + + /// + /// What a borrowed prefab actually is. The root flag matters for the same reason it did on + /// the Skeleton's fire aura: a parented object is a node inside somebody else's hierarchy, + /// not a prefab, and spawning one on its own is how this mod has crashed before. + /// + private static string Describe(GameObject prefab) + { + if (prefab == null) return "null"; + + string path = prefab.name; + for (Transform t = prefab.transform.parent; t != null; t = t.parent) path = t.name + "/" + path; + + var parts = new System.Collections.Generic.List(); + foreach (Component comp in prefab.GetComponents()) + { + if (comp != null && !(comp is Transform)) parts.Add(comp.GetType().Name); + } + + return $"{path}' root={prefab.transform.parent == null} carries=[{string.Join(", ", parts.ToArray())}]"; + } + + /// Says why a press did not become a cast, once per reason per session. + private static void ColdSpellBail(string reason) + { + if (coldSpellBails.Add(reason)) + { + Jotunn.Logger.LogInfo($"[Skadi] Cold Spell key pressed but not cast: {reason}."); + } + } + private void HandleColdSpell(SkadiProgression.FormRules rules) { - if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return; - if (isTransformed) return; // Do not cast human spell while in dragon form + bool pressed = ColdSpellKeyPressed(); + + if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) + { + if (pressed) ColdSpellBail("the player is dead"); + return; + } + if (isTransformed) + { + if (pressed) ColdSpellBail("you are in a dragon form"); + return; + } // Hammer, hoe or cultivator in hand: every build button is vanilla's. Middle mouse is // Remove on the keyboard, and on the pad JoySecondaryAttack shares its physical button // with JoyRemove (Classic) or JoyPlace (Alt2) - read off ZInput.AddGamepad*Buttons - so // each piece built or removed also cast the spell and drained the stamina for it. - if (Player.m_localPlayer.InPlaceMode()) return; + if (Player.m_localPlayer.InPlaceMode()) + { + if (pressed) ColdSpellBail("a hammer, hoe or cultivator is in hand"); + return; + } // Middle Mouse Button to cast, by default - rebindable via SkadiConfig.ColdSpellKey. // On a gamepad, the secondary attack button (the pad's own middle-mouse equivalent) - @@ -354,7 +428,11 @@ namespace RacesOfValheim { // The improved cast is a burst rather than a rapid-fire, so it waits longer. float cooldown = rules.ImprovedColdSpell ? IMPROVED_SPELL_COOLDOWN : SPELL_COOLDOWN; - if (Time.time - lastSpellTime < cooldown) return; + if (Time.time - lastSpellTime < cooldown) + { + ColdSpellBail($"it is on cooldown - {cooldown - (Time.time - lastSpellTime):F1}s left of {cooldown:F0}s"); + return; + } // Stamina, never eitr: the spell unlocks at Eikthyr but eitr food only exists from // the Mistlands onward, so the old HaveEitr gate left it unusable for five tiers. @@ -378,8 +456,17 @@ namespace RacesOfValheim zanim.SetTrigger("gpower"); } + if (coldSpellBails.Add("cast")) Jotunn.Logger.LogInfo("[Skadi] Cold Spell cast."); + StartCoroutine(ColdSpellKickCoroutine(rules)); } + else if (pressed) + { + // The key physically went down and the wrapper still said no. That is the last place + // left for this to fail, and the only one with no condition of its own above it. + ColdSpellBail($"'{SkadiConfig.ColdSpellKey.Value.MainKey}' went down but " + + "IsDownIgnoringHeldKeys refused it"); + } } /// @@ -402,10 +489,31 @@ namespace RacesOfValheim if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) yield break; + // EVERY STEP BELOW IS SAID BEFORE IT IS TAKEN, once per session. Casting this spell exits + // the process outright - no exception, no stack, the log simply stops - which is the same + // signature as sfx_fenring_howl, the sound that cannot be spawned either. The only reason + // we know where either one dies is that the line before it had already been flushed. + ColdSpellStep("resolving 'StaffIceShards'"); + GameObject staffPrefab = PrefabManager.Cache.GetPrefab("StaffIceShards"); - if (staffPrefab == null) yield break; + if (staffPrefab == null) + { + ColdSpellStep("'StaffIceShards' did not resolve - no shards fired"); + yield break; + } ItemDrop staffDrop = staffPrefab.GetComponent(); - if (staffDrop == null) yield break; + if (staffDrop == null) + { + ColdSpellStep("'StaffIceShards' has no ItemDrop - no shards fired"); + yield break; + } + // NOT described here, deliberately, and this is an experiment rather than a style choice. + // Describe() reads the prefab's components, and reading them may be what forces a + // soft-referenced asset to finish loading - which would mean the diagnostic was quietly + // fixing the crash it was added to measure. Both descriptions now run AFTER the shards + // are spawned, so nothing touches either prefab before the Instantiate that was dying. + // If the crash comes back, the touch was the fix and becomes a real one. If it does not, + // the crash was never about loading. string projName = rules.ImprovedColdSpell ? "hatchling_cold_projectile" : null; GameObject projPrefab = null; @@ -418,7 +526,13 @@ namespace RacesOfValheim { projPrefab = staffDrop.m_itemData.m_shared.m_attack.m_attackProjectile; // Default Staff of Frost projectile } - if (projPrefab == null) yield break; + if (projPrefab == null) + { + ColdSpellStep("no projectile prefab at all - no shards fired"); + yield break; + } + ColdSpellStep("projectile chosen from " + + (projName != null ? $"'{projName}' or the staff" : "the staff")); int count = rules.ImprovedColdSpell ? IMPROVED_SPELL_SHARDS : 1; @@ -446,7 +560,19 @@ namespace RacesOfValheim Vector3 spawnPos = Player.m_localPlayer.transform.position + Vector3.up * 1.4f + lookDir * 0.6f; + ColdSpellStep($"instantiating shard {i + 1} of {count}"); + GameObject projInstance = Instantiate(projPrefab, spawnPos, Quaternion.LookRotation(lookDir)); + + ColdSpellStep("shard instantiated"); + + // Described only now that a shard has survived being spawned, so the reading itself + // cannot be what made the spawning safe. See the note above the staff lookup. + if (i == 0) + { + ColdSpellStep($"staff was '{Describe(staffPrefab)}"); + ColdSpellStep($"projectile was '{Describe(projPrefab)}"); + } Projectile proj = projInstance.GetComponent(); if (proj != null) From 5bdd7200a58ba805f2e3860f7bc75acae9f37786 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 18:17:37 +0200 Subject: [PATCH 052/273] fix(fenrir): the Ulv no longer asks the player for feet called LeftHand The form's CharacterAnimEvent finds its FootStep on the nearest Character up the hierarchy, which for a form parented under the player is the player. The Ulv's Run clip names its front paws LeftHand and RightHand, a human rig has neither, and vanilla logged "FAiled to find foot" twice per stride. The form's receivers are now cut from the player's FootStep, on the local form and on the copy other players see. The footsteps stay: the hidden human animator keeps running and FootStep steps off its curve. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Fenrir/FenrirRace.cs | 2 ++ JotunnModStub/Fenrir/FormFootsteps.cs | 47 +++++++++++++++++++++++++++ JotunnModStub/ZdoVisualSync.cs | 4 ++- 3 files changed, 52 insertions(+), 1 deletion(-) create mode 100644 JotunnModStub/Fenrir/FormFootsteps.cs diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index 4e55a80..5c00200 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -383,6 +383,8 @@ namespace RacesOfValheim { Component animEvent = currentTransformation.GetComponent("AnimEvent"); if (animEvent != null) Destroy(animEvent); + FormFootsteps.Detach(currentTransformation, prefabName); + // The creature's own animations carry their sounds as events; this is what hears // them. On the object that owns the Animator, because that is where Unity delivers // an animation event - for the wolf that is WolfSmooth, two levels down, not the diff --git a/JotunnModStub/Fenrir/FormFootsteps.cs b/JotunnModStub/Fenrir/FormFootsteps.cs new file mode 100644 index 0000000..d106301 --- /dev/null +++ b/JotunnModStub/Fenrir/FormFootsteps.cs @@ -0,0 +1,47 @@ +using System.Collections.Generic; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Stops a Fenrir form's own animations from stepping on the player's FootStep. + /// + /// The form's CharacterAnimEvent resolves its FootStep in Awake, from + /// GetComponentInParent<Character>() - and a form parented under the player finds the + /// PLAYER. So when the Ulv's 'Run' clip fires FootStep('LeftHand') and FootStep('RightHand') + /// for its front paws, vanilla looks for feet with those names on a human rig, finds none, and + /// logs "FAiled to find foot:LeftHand" twice per stride. That is the warning a user reported. + /// + /// Nothing is lost by cutting the link. The player's hidden Visual keeps animating (the hider + /// only switches renderers off), and FootStep drives its steps from that animator's footstep + /// curve, so the form already has footsteps. A form event naming a foot the player does have + /// would only play a second step on top of that one. + /// + /// CharacterAnimEvent.FootStep checks m_footStep before calling it, so nulling the field is + /// all it takes. It has to happen after Instantiate, which is when that Awake has run. + /// + internal static class FormFootsteps + { + private static readonly HashSet logged = new HashSet(); + + public static void Detach(GameObject form, string formName) + { + if (form == null) return; + + int detached = 0; + foreach (CharacterAnimEvent cae in form.GetComponentsInChildren(true)) + { + var field = HarmonyLib.Traverse.Create(cae).Field("m_footStep"); + if (field.GetValue() == null) continue; + field.SetValue(null); + detached++; + } + + if (logged.Add(formName)) + { + Jotunn.Logger.LogInfo( + $"[FenrirForm] '{formName}': {detached} animation-event receiver(s) cut from the player's FootStep."); + } + } + } +} diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs index 686a831..93422ed 100644 --- a/JotunnModStub/ZdoVisualSync.cs +++ b/JotunnModStub/ZdoVisualSync.cs @@ -212,7 +212,9 @@ namespace RacesOfValheim m_currentFormInstance.transform.localRotation = Quaternion.identity; Component animEvent = m_currentFormInstance.GetComponent("AnimEvent"); if (animEvent != null) Destroy(animEvent); - + + FormFootsteps.Detach(m_currentFormInstance, currentForm); + // Clean up colliders on remote visuals foreach (var col in m_currentFormInstance.GetComponentsInChildren()) { From 8f477dd3be5c1c47f890be04334404b6dad2ee17 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 18:29:34 +0200 Subject: [PATCH 053/273] fix(aswid): Eclipse brings the night instead of dying on its first line The coroutine set EnvMan's two debug-time fields the wrong way round and asked for 0.5, which is noon. Handing a bool to the float field threw, so the cast stopped right after the announcement and IsEclipseActive stayed true, and every later press returned without a word. The fields are now set directly, to midnight, and a finally frees the ability if anything in there throws again. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Aswid/AswidRace.cs | 35 +++++++++++++++++++++----------- 1 file changed, 23 insertions(+), 12 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index b1f1cd2..b3612bc 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -887,23 +887,34 @@ namespace RacesOfValheim yield return null; } - // Force night client-side - if (EnvMan.instance != null) + // Force night client-side. EnvMan's switch is the bool m_debugTimeOfDay and the time it + // pins is the float m_debugTime, a day fraction where 0 is midnight and 0.5 is noon. + // These two used to be written the other way round: handing a bool to the float threw, + // the coroutine died right after "An Eclipse descends...", and IsEclipseActive stayed + // true for the rest of the session, so every later press returned without a word. + // Public fields both, so no Traverse to get the names wrong through. + try { - HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTime").SetValue(true); - HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTimeOfDay").SetValue(0.5f); // Midnight + if (EnvMan.instance != null) + { + EnvMan.instance.m_debugTime = 0f; + EnvMan.instance.m_debugTimeOfDay = true; + } + + yield return new WaitForSeconds(AswidConfig.EclipseDuration.Value); + } + finally + { + // In a finally so that a throw in here can never again leave the ability locked. + // Unity does not dispose a coroutine it stops, so this does not cover that case. + if (EnvMan.instance != null) EnvMan.instance.m_debugTimeOfDay = false; + IsEclipseActive = false; } - yield return new WaitForSeconds(AswidConfig.EclipseDuration.Value); - - // Revert to server time - if (EnvMan.instance != null) + if (Player.m_localPlayer != null) { - HarmonyLib.Traverse.Create(EnvMan.instance).Field("m_debugTime").SetValue(false); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The Eclipse has ended."); } - - IsEclipseActive = false; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The Eclipse has ended."); } private float damageTickTimer = 0f; From 0674329592adbe36e54af39863217563558bcbea Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 18:50:51 +0200 Subject: [PATCH 054/273] fix(fenrir): spawn sounds the way vanilla spawns effects, without ghost init Ghost init was meant to keep a sound's ZNetView from writing a ZDO. It does not: ZNetView.Awake still creates the ZDO and only skips registering the instance, so ZNetScene sees an unbuilt ZDO and builds a second copy. Vanilla's EffectList.Create uses a plain Instantiate, and TimedDestruction deletes the ZDO through ZNetScene.Destroy when the sound ends. The spawn now does the same. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Fenrir/FenrirBehaviors.cs | 36 ++++++++-------------- JotunnModStub/Fenrir/FormAnimEventSound.cs | 3 +- 2 files changed, 14 insertions(+), 25 deletions(-) diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 86d25fc..9b13a35 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -214,36 +214,26 @@ namespace RacesOfValheim } /// - /// Spawns a sound prefab without letting it write itself into the save. + /// Spawns a sound prefab the way the game's own EffectList.Create does: a plain Instantiate. /// - /// SOME VANILLA SOUND PREFABS CARRY A ZNetView. "sfx_fenring_alerted" is one - the Describe - /// line below printed it, which is how this was noticed. A ZNetView that wakes with no init - /// ZDO calls ZDOMan.CreateNewZDO at its position, marks itself persistent, stamps itself with - /// the prefab hash and registers with the scene. On a sound played every time somebody howls - /// or swings a claw, that is one persistent "there is a noise here" record per swing, saved - /// with the world. It is the same bug that left burnt-in torches in people's worlds; the long - /// version is on SkeletonVisuals.BorrowEffect. + /// THIS USED TO WRAP THE INSTANTIATE IN ZNetView GHOST INIT, and that was wrong. Some vanilla + /// sound and effect prefabs carry a ZNetView ("sfx_fenring_alerted" does), and the fear was + /// one persistent ZDO per play left in the save. The ones logged so far also carry + /// TimedDestruction, which ends in ZNetScene.Destroy, and that deletes the ZDO. They are + /// network effects by design, which is how other players hear them. /// - /// ZNetView.StartGhostInit is the game's own answer, not ours: between the two calls a - /// ZNetView comes up with no ZDO at all. Cheaper and far less invasive than stripping the - /// component off a copy, and free on the prefabs that carry no ZNetView. - /// - /// The finally matters. Leaving ghost init switched on because an Instantiate threw would - /// break every ZNetView created afterwards, for the rest of the session. + /// Ghost init does not prevent the ZDO either. Read off ZNetView.Awake: it still calls + /// CreateNewZDO and only skips ZNetScene.AddInstance. That leaves the ZDO with Created=false, + /// and ZNetScene.CreateObjectsSorted builds a second copy of the object from it. Vanilla + /// uses ghost init for zone generation, where the ZDOs are the point and the objects are not. + /// The switch that really yields no ZDO is m_forceDisableInit, which is for item icons and + /// inventory copies, not for anything meant to be seen or heard by others. /// public static void Spawn(GameObject prefab, Vector3 position) { if (prefab == null) return; - ZNetView.StartGhostInit(); - try - { - Object.Instantiate(prefab, position, Quaternion.identity); - } - finally - { - ZNetView.FinishGhostInit(); - } + Object.Instantiate(prefab, position, Quaternion.identity); // NOT FOLLOWED BY A Play() CALL, and that took a while to establish. ZSFX is ticked by // CustomUpdate rather than Unity's Update, so it starts on a later frame: reading diff --git a/JotunnModStub/Fenrir/FormAnimEventSound.cs b/JotunnModStub/Fenrir/FormAnimEventSound.cs index 4fdea87..3a2ee51 100644 --- a/JotunnModStub/Fenrir/FormAnimEventSound.cs +++ b/JotunnModStub/Fenrir/FormAnimEventSound.cs @@ -81,8 +81,7 @@ namespace RacesOfValheim if (!audible) return; - // Through the same ghost-init spawn as everything else here: some vanilla sound prefabs - // carry a ZNetView, and this one fires every time the animation comes round. + // Through the same spawn as every other Fenrir sound, so a change there reaches this too. FenrirCreatureSound.Spawn(prefab, transform.position); } } From 055635d1b43c6b7c061c8a243c947491f4f30346 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 19:16:08 +0200 Subject: [PATCH 055/273] feat(aswid): Eclipse runs the sky through dusk instead of cutting to night While EnvMan's debug time is on it copies the value straight onto the sky, so setting midnight in one go made night fall in a single frame. The clock now eases forward from the current hour to midnight over 3.5 seconds. The dawn already eased back on its own, because EnvMan smooths towards the real time once the switch is off. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Aswid/AswidRace.cs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index b3612bc..7a7543f 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -863,6 +863,9 @@ namespace RacesOfValheim StartCoroutine(EclipseRoutine()); } + /// How long the sky takes to run from the cast to midnight. + private const float EclipseDuskSeconds = 3.5f; + private System.Collections.IEnumerator EclipseRoutine() { IsEclipseActive = true; @@ -897,8 +900,22 @@ namespace RacesOfValheim { if (EnvMan.instance != null) { - EnvMan.instance.m_debugTime = 0f; + // Run the clock forward through dusk to midnight rather than cutting to it. + // While m_debugTimeOfDay is on, EnvMan copies m_debugTime straight onto the sky + // with no smoothing of its own, so the easing has to happen here. Forward means + // up to 1, which is midnight again; the Aswid's night buffs start at 0.75, + // partway through. The way back needs nothing: once the switch is off, EnvMan + // eases towards the real time by itself. + float from = EnvMan.instance.GetDayFraction(); + EnvMan.instance.m_debugTime = from; EnvMan.instance.m_debugTimeOfDay = true; + + for (float t = 0f; t < EclipseDuskSeconds && EnvMan.instance != null; t += Time.deltaTime) + { + EnvMan.instance.m_debugTime = Mathf.Lerp(from, 1f, Mathf.SmoothStep(0f, 1f, t / EclipseDuskSeconds)); + yield return null; + } + if (EnvMan.instance != null) EnvMan.instance.m_debugTime = 1f; } yield return new WaitForSeconds(AswidConfig.EclipseDuration.Value); From 52c26d9b52383b31c56e6945e10bf27729007650 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 19:24:23 +0200 Subject: [PATCH 056/273] feat(aswid): the Eclipse's dusk spends its time on the sunset An even sweep from the afternoon to midnight looked still for three seconds and then fell dark in half of one, because the sky hardly changes between 0.25 and 0.75 and does its darkening around sunset. The dusk now walks keyframes: half a second to late afternoon, three through the sunset band, half a second to midnight. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Aswid/AswidRace.cs | 44 +++++++++++++++++++++++++++----- 1 file changed, 37 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 7a7543f..c864a7f 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -863,8 +863,37 @@ namespace RacesOfValheim StartCoroutine(EclipseRoutine()); } - /// How long the sky takes to run from the cast to midnight. - private const float EclipseDuskSeconds = 3.5f; + /// + /// The Eclipse's dusk as (seconds, day fraction) keys, walked linearly between them. + /// + /// Not one even sweep, because the sky does not change evenly. EnvMan keeps it looking like + /// day from 0.25 to 0.75 and does all its darkening around sunset, so an even run from + /// the afternoon to midnight looked still for three seconds and then fell dark in half of + /// one. Here the afternoon goes by in half a second and the sunset band gets three. + /// The first key's fraction is replaced by the time of the cast, and any key earlier in + /// the day than that is lifted to it, so a cast near dusk does not run the clock backwards. + /// + private static readonly Vector2[] EclipseDuskKeys = + { + new Vector2(0f, 0f), // the time of the cast + new Vector2(0.5f, 0.70f), // late afternoon, just before the sky starts to change + new Vector2(3.5f, 0.95f), // through the sunset band, slowly + new Vector2(4f, 1f), // midnight + }; + + private static float EclipseDuskFraction(float from, float seconds) + { + float prevT = 0f, prevF = from; + for (int i = 1; i < EclipseDuskKeys.Length; i++) + { + float keyT = EclipseDuskKeys[i].x; + float keyF = Mathf.Max(EclipseDuskKeys[i].y, from); + if (seconds <= keyT) return Mathf.Lerp(prevF, keyF, Mathf.InverseLerp(prevT, keyT, seconds)); + prevT = keyT; + prevF = keyF; + } + return 1f; + } private System.Collections.IEnumerator EclipseRoutine() { @@ -902,17 +931,18 @@ namespace RacesOfValheim { // Run the clock forward through dusk to midnight rather than cutting to it. // While m_debugTimeOfDay is on, EnvMan copies m_debugTime straight onto the sky - // with no smoothing of its own, so the easing has to happen here. Forward means - // up to 1, which is midnight again; the Aswid's night buffs start at 0.75, - // partway through. The way back needs nothing: once the switch is off, EnvMan + // with no smoothing of its own, so the pacing has to happen here - see + // EclipseDuskKeys. Forward means up to 1, which is midnight again; the Aswid's + // night buffs start at 0.75, partway through. The way back needs nothing: once the switch is off, EnvMan // eases towards the real time by itself. float from = EnvMan.instance.GetDayFraction(); EnvMan.instance.m_debugTime = from; EnvMan.instance.m_debugTimeOfDay = true; - for (float t = 0f; t < EclipseDuskSeconds && EnvMan.instance != null; t += Time.deltaTime) + float duskSeconds = EclipseDuskKeys[EclipseDuskKeys.Length - 1].x; + for (float t = 0f; t < duskSeconds && EnvMan.instance != null; t += Time.deltaTime) { - EnvMan.instance.m_debugTime = Mathf.Lerp(from, 1f, Mathf.SmoothStep(0f, 1f, t / EclipseDuskSeconds)); + EnvMan.instance.m_debugTime = EclipseDuskFraction(from, t); yield return null; } if (EnvMan.instance != null) EnvMan.instance.m_debugTime = 1f; From 19c934777235603075b60785a33af151b80c2b2f Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 19:30:56 +0200 Subject: [PATCH 057/273] fix(skadi): the Cold Spell key's description says tier 2+, where it unlocks Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Skadi/SkadiConfig.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/JotunnModStub/Skadi/SkadiConfig.cs b/JotunnModStub/Skadi/SkadiConfig.cs index 22db0ab..133d7c1 100644 --- a/JotunnModStub/Skadi/SkadiConfig.cs +++ b/JotunnModStub/Skadi/SkadiConfig.cs @@ -90,7 +90,7 @@ namespace RacesOfValheim PrimaryAttackKey = config.Bind(keybinds, "Dragon Primary Attack", new KeyboardShortcut(KeyCode.Mouse0), KeyDesc("Bite/claw attack in any dragon form.", keyOrder--)); ColdSpellKey = config.Bind(keybinds, "Cold Spell Cast", new KeyboardShortcut(KeyCode.Mouse2), - KeyDesc("Casts the Cold Spell in human form, tier 1+.", keyOrder--)); + KeyDesc("Casts the Cold Spell in human form, tier 2+ (Eikthyr).", keyOrder--)); BreathAttackKey = config.Bind(keybinds, "Dragon Breath Attack", new KeyboardShortcut(KeyCode.Mouse2), KeyDesc("Ranged breath/barrage attack in Moder and Skeleton Dragon form.", keyOrder--)); SpinAttackKey = config.Bind(keybinds, "Fader Spin Attack", new KeyboardShortcut(KeyCode.Mouse1), From 73b67cd6ce547057e070a666d6f261018584ee62 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 19:43:48 +0200 Subject: [PATCH 058/273] feat(text): the race menu reads its texts from translation files First step of moving every piece of text out of the code so modders can translate the mod. The texts live in Translations//*.json, one file per kind of text, which Jotunn finds on its own and falls back to English for. ModText reads them; values take Valheim's $1, $2 placeholders. This step covers the race selection menu: title, buttons, every race's name and description, in English and Italian. The race ID and the name on screen are now separate strings. The ID is what the save and the ZDO hold, so it must never be translated. The files are deployed to plugins\RacesOfValheim\Translations and packed into both release zips. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/ModText.cs | 50 +++++++++++++++++++ JotunnModStub/RacesOfValheim.cs | 48 ++++++++++-------- JotunnModStub/RacesOfValheim.csproj | 17 ++++++- JotunnModStub/Translations/English/races.json | 38 ++++++++++++++ JotunnModStub/Translations/Italian/races.json | 38 ++++++++++++++ 5 files changed, 169 insertions(+), 22 deletions(-) create mode 100644 JotunnModStub/ModText.cs create mode 100644 JotunnModStub/Translations/English/races.json create mode 100644 JotunnModStub/Translations/Italian/races.json diff --git a/JotunnModStub/ModText.cs b/JotunnModStub/ModText.cs new file mode 100644 index 0000000..4e43258 --- /dev/null +++ b/JotunnModStub/ModText.cs @@ -0,0 +1,50 @@ +using System.Linq; + +namespace RacesOfValheim +{ + /// + /// Every piece of text the mod shows, read from the translation files instead of the code. + /// + /// The files are JSON under Translations/<Language>/, one per kind of text, next to the DLL. + /// Jotunn finds them on its own: it searches the whole plugins folder for any .json whose + /// grandparent folder is called "Translations", takes the language from the folder name + /// (Valheim's own names: English, Italian, German...), and falls back to English for any key a + /// language leaves out. A key missing from English too shows up on screen as [key]. + /// + /// Keys go in the files without the leading $ and are read here the same way. Values take + /// Valheim's own placeholders, $1, $2..., filled from the arguments in order, so a translator + /// can move a number to wherever their grammar wants it. + /// + internal static class ModText + { + public static string Get(string key, params object[] args) + { + if (Localization.instance == null) return "[" + key + "]"; + + string[] words = args.Select(a => a?.ToString() ?? "").ToArray(); + return Localization.instance.Localize("$" + key, words); + } + + /// + /// A race's name as the player reads it. Only ever for display. + /// + /// The race ID ("Skadi", "Trol"...) is a different thing and never goes through here: it is + /// written into the character save and the ZDO, and compared all over the code. Translate + /// that and a character saved under one language stops being recognised under another. + /// + public static string RaceName(string raceId) + { + return Get(RaceKey(raceId) + "_name"); + } + + public static string RaceDescription(string raceId, params object[] args) + { + return Get(RaceKey(raceId) + "_desc", args); + } + + private static string RaceKey(string raceId) + { + return "rov_race_" + raceId.ToLowerInvariant(); + } + } +} diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 9b7a5c3..7778632 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -303,7 +303,7 @@ namespace RacesOfValheim titleObj.transform.SetParent(selectionPanel.transform, false); Text titleText = titleObj.AddComponent(); titleText.font = GUIManager.Instance.AveriaSerifBold; - titleText.text = "Choose your Race"; + titleText.text = ModText.Get("rov_menu_choose_race"); titleText.fontSize = 50; titleText.alignment = TextAnchor.MiddleCenter; titleText.color = Color.white; @@ -346,7 +346,7 @@ namespace RacesOfValheim btnOkTxtObj.transform.SetParent(btnOkObj.transform, false); Text btnOkTxt = btnOkTxtObj.AddComponent(); btnOkTxt.font = GUIManager.Instance.AveriaSerifBold; - btnOkTxt.text = "OK"; + btnOkTxt.text = ModText.Get("rov_menu_ok"); btnOkTxt.fontSize = 24; btnOkTxt.alignment = TextAnchor.MiddleCenter; btnOkTxt.color = Color.white; @@ -371,7 +371,7 @@ namespace RacesOfValheim btnBackTxtObj.transform.SetParent(btnBackObj.transform, false); Text btnBackTxt = btnBackTxtObj.AddComponent(); btnBackTxt.font = GUIManager.Instance.AveriaSerifBold; - btnBackTxt.text = "Back"; + btnBackTxt.text = ModText.Get("rov_menu_back"); btnBackTxt.fontSize = 24; btnBackTxt.alignment = TextAnchor.MiddleCenter; btnBackTxt.color = Color.white; @@ -379,34 +379,40 @@ namespace RacesOfValheim btnBackTxtRect.anchorMin = Vector2.zero; btnBackTxtRect.anchorMax = Vector2.one; btnBackTxtRect.offsetMin = Vector2.zero; btnBackTxtRect.offsetMax = Vector2.zero; - void CreateRaceButtonWithConfirm(string label, Vector2 position, Sprite iconSprite, string description, UnityEngine.Events.UnityAction onConfirm) + // The race ID picks the texts and is what gets saved; the button, the title and the + // description only ever show the translated name. See ModText.RaceName for why the two + // must never be the same string. + void CreateRaceButtonWithConfirm(string raceId, Vector2 position, Sprite iconSprite, UnityEngine.Events.UnityAction onConfirm, params object[] descArgs) { - CreateRaceButton(label, position, iconSprite, selectionPanel.transform, () => { + string name = ModText.RaceName(raceId); + CreateRaceButton(raceId, name, position, iconSprite, selectionPanel.transform, () => { selectionPanel.SetActive(false); confirmationPanel.SetActive(true); - confTitleText.text = label; - confDescText.text = description; + confTitleText.text = name; + confDescText.text = ModText.RaceDescription(raceId, descArgs); btnOk.onClick.RemoveAllListeners(); btnOk.onClick.AddListener(onConfirm); }); } // Row 1 (y = 100) - CreateRaceButtonWithConfirm("Human", new Vector2(-450, 100), GetHumanIcon(), "The versatile founders of Midgard. Balanced stats with no specific weaknesses.", SelectHuman); - CreateRaceButtonWithConfirm("Fenrir", new Vector2(-150, 100), GetFenrirIcon(), "Cursed by the blood of the wolf. Fast and deadly, but vulnerable to silver.", SelectFenrir); - CreateRaceButtonWithConfirm("Skadi", new Vector2(150, 100), GetSkadiIcon(), "Children of the mountains. Resistant to frost, at home in the freezing cold.", SelectSkadi); - CreateRaceButtonWithConfirm("Skeleton", new Vector2(450, 100), GetSkeletonIcon(), "Undead warriors. Immune to poison, but brittle against blunt trauma.", SelectSkeleton); - + CreateRaceButtonWithConfirm("Human", new Vector2(-450, 100), GetHumanIcon(), SelectHuman); + CreateRaceButtonWithConfirm("Fenrir", new Vector2(-150, 100), GetFenrirIcon(), SelectFenrir); + CreateRaceButtonWithConfirm("Skadi", new Vector2(150, 100), GetSkadiIcon(), SelectSkadi); + CreateRaceButtonWithConfirm(SkeletonVisuals.RaceId, new Vector2(450, 100), GetSkeletonIcon(), SelectSkeleton); + // Row 2 (y = -20) - CreateRaceButtonWithConfirm("Aswid", new Vector2(-450, -20), GetAswidIcon(), "Fierce night stalker. Strong and resilient, transforms into a bat.", SelectAswid); - CreateRaceButtonWithConfirm("Furling", new Vector2(-150, -20), GetFurlingIcon(), "Cunning goblin-like creatures. Agile and resourceful.", SelectFurling); - CreateRaceButtonWithConfirm("Trol", new Vector2(150, -20), GetTrolIcon(), $"Massive brute strength. Towering over others, at peace with the Black Forest - but fire burns a Trol {(TrolConfig.FireWeaknessMultiplier.Value - 1f) * 100f:0}% harder than anyone else.", SelectTrol); - CreateRaceButtonWithConfirm("Draugh", new Vector2(450, -20), GetDraughIcon(), "A decaying undead warrior fueled by dark magic and extreme metal.", SelectDraugh); + CreateRaceButtonWithConfirm("Aswid", new Vector2(-450, -20), GetAswidIcon(), SelectAswid); + CreateRaceButtonWithConfirm("Furling", new Vector2(-150, -20), GetFurlingIcon(), SelectFurling); + // $1 in the Trol's description is how much harder fire burns it, read from the config. + CreateRaceButtonWithConfirm("Trol", new Vector2(150, -20), GetTrolIcon(), SelectTrol, + ((TrolConfig.FireWeaknessMultiplier.Value - 1f) * 100f).ToString("0")); + CreateRaceButtonWithConfirm(DraughVisuals.RaceId, new Vector2(450, -20), GetDraughIcon(), SelectDraugh); // Row 3 (y = -140) - CreateRaceButtonWithConfirm("Dvergar", new Vector2(-450, -140), GetDvergarIcon(), "Small, stubborn smiths of the deep. Frail of frame, but masters of metal, mine and market.", SelectDvergar); - CreateRaceButtonWithConfirm("Trenta", new Vector2(-150, -140), GetTrentaIcon(), "Tree-born folk, kin to root and leaf. Patient and hard to fell.", SelectTrenta); - CreateRaceButtonWithConfirm("Sverm", new Vector2(150, -140), GetSvermIcon(), "Chitin-born swarm kin. Armoured from birth and never slowed, venomous, at peace with every crawling thing - but blunt trauma and fire find the seams.", SelectSverm); + CreateRaceButtonWithConfirm(DvergarConfig.RaceId, new Vector2(-450, -140), GetDvergarIcon(), SelectDvergar); + CreateRaceButtonWithConfirm(TrentaConfig.RaceId, new Vector2(-150, -140), GetTrentaIcon(), SelectTrenta); + CreateRaceButtonWithConfirm(SvermConfig.RaceId, new Vector2(150, -140), GetSvermIcon(), SelectSverm); GUIManager.BlockInput(true); } @@ -481,9 +487,9 @@ namespace RacesOfValheim return null; } - private void CreateRaceButton(string label, Vector2 position, Sprite iconSprite, Transform parentTransform, UnityEngine.Events.UnityAction onClick) + private void CreateRaceButton(string raceId, string label, Vector2 position, Sprite iconSprite, Transform parentTransform, UnityEngine.Events.UnityAction onClick) { - GameObject btnObj = new GameObject(label + "Button"); + GameObject btnObj = new GameObject(raceId + "Button"); btnObj.transform.SetParent(parentTransform, false); RectTransform btnRect = btnObj.AddComponent(); btnRect.sizeDelta = new Vector2(250, 80); diff --git a/JotunnModStub/RacesOfValheim.csproj b/JotunnModStub/RacesOfValheim.csproj index 58ed010..188493c 100644 --- a/JotunnModStub/RacesOfValheim.csproj +++ b/JotunnModStub/RacesOfValheim.csproj @@ -138,18 +138,33 @@ + + + + + + $(REPO_ROOT)dist\ + + + $(IntermediateOutputPath)nexus\ + + + - + diff --git a/JotunnModStub/Translations/English/races.json b/JotunnModStub/Translations/English/races.json new file mode 100644 index 0000000..8d930c3 --- /dev/null +++ b/JotunnModStub/Translations/English/races.json @@ -0,0 +1,38 @@ +{ + "rov_menu_choose_race": "Choose your Race", + "rov_menu_ok": "OK", + "rov_menu_back": "Back", + + "rov_race_human_name": "Human", + "rov_race_human_desc": "The versatile founders of Midgard. Balanced stats with no specific weaknesses.", + + "rov_race_fenrir_name": "Fenrir", + "rov_race_fenrir_desc": "Cursed by the blood of the wolf. Fast and deadly, but vulnerable to silver.", + + "rov_race_skadi_name": "Skadi", + "rov_race_skadi_desc": "Children of the mountains. Resistant to frost, at home in the freezing cold.", + + "rov_race_skeleton_name": "Skeleton", + "rov_race_skeleton_desc": "Undead warriors. Immune to poison, but brittle against blunt trauma.", + + "rov_race_aswid_name": "Aswid", + "rov_race_aswid_desc": "Fierce night stalker. Strong and resilient, transforms into a bat.", + + "rov_race_furling_name": "Furling", + "rov_race_furling_desc": "Cunning goblin-like creatures. Agile and resourceful.", + + "rov_race_trol_name": "Trol", + "rov_race_trol_desc": "Massive brute strength. Towering over others, at peace with the Black Forest - but fire burns a Trol $1% harder than anyone else.", + + "rov_race_draugh_name": "Draugh", + "rov_race_draugh_desc": "A decaying undead warrior fueled by dark magic and extreme metal.", + + "rov_race_dvergar_name": "Dvergar", + "rov_race_dvergar_desc": "Small, stubborn smiths of the deep. Frail of frame, but masters of metal, mine and market.", + + "rov_race_trenta_name": "Trenta", + "rov_race_trenta_desc": "Tree-born folk, kin to root and leaf. Patient and hard to fell.", + + "rov_race_sverm_name": "Sverm", + "rov_race_sverm_desc": "Chitin-born swarm kin. Armoured from birth and never slowed, venomous, at peace with every crawling thing - but blunt trauma and fire find the seams." +} diff --git a/JotunnModStub/Translations/Italian/races.json b/JotunnModStub/Translations/Italian/races.json new file mode 100644 index 0000000..2e29263 --- /dev/null +++ b/JotunnModStub/Translations/Italian/races.json @@ -0,0 +1,38 @@ +{ + "rov_menu_choose_race": "Scegli la tua razza", + "rov_menu_ok": "OK", + "rov_menu_back": "Indietro", + + "rov_race_human_name": "Umano", + "rov_race_human_desc": "I versatili fondatori di Midgard. Statistiche equilibrate, senza debolezze particolari.", + + "rov_race_fenrir_name": "Fenrir", + "rov_race_fenrir_desc": "Maledetti dal sangue del lupo. Veloci e letali, ma vulnerabili all'argento.", + + "rov_race_skadi_name": "Skadi", + "rov_race_skadi_desc": "Figli delle montagne. Resistenti al gelo, a casa loro nel freddo più rigido.", + + "rov_race_skeleton_name": "Scheletro", + "rov_race_skeleton_desc": "Guerrieri non morti. Immuni al veleno, ma fragili contro i colpi contundenti.", + + "rov_race_aswid_name": "Aswid", + "rov_race_aswid_desc": "Feroce cacciatore notturno. Forte e resistente, si trasforma in pipistrello.", + + "rov_race_furling_name": "Furling", + "rov_race_furling_desc": "Astute creature simili a goblin. Agili e piene di risorse.", + + "rov_race_trol_name": "Trol", + "rov_race_trol_desc": "Forza bruta smisurata. Sovrasta tutti gli altri ed è in pace con la Foresta Nera, ma il fuoco brucia un Trol il $1% in più di chiunque altro.", + + "rov_race_draugh_name": "Draugh", + "rov_race_draugh_desc": "Un guerriero non morto in decomposizione, alimentato da magia oscura e metallo estremo.", + + "rov_race_dvergar_name": "Dvergar", + "rov_race_dvergar_desc": "Piccoli e testardi fabbri del profondo. Fragili nel fisico, ma maestri di metallo, miniera e mercato.", + + "rov_race_trenta_name": "Trenta", + "rov_race_trenta_desc": "Popolo nato dagli alberi, parente di radici e foglie. Paziente e difficile da abbattere.", + + "rov_race_sverm_name": "Sverm", + "rov_race_sverm_desc": "Stirpe dello sciame nata dalla chitina. Corazzata dalla nascita e mai rallentata, velenosa, in pace con ogni cosa che striscia, ma i colpi contundenti e il fuoco trovano le giunture." +} From 9bf144aedc255833bcbfa1e15ee7c4ba394d921b Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 19:51:10 +0200 Subject: [PATCH 059/273] feat(text): status effect names and tooltips come from translation files Every status effect the mod registers now carries a $rov_se_ token instead of English, and status_effects.json holds the texts in English and Italian. Valheim localizes both fields itself when it shows them. The blood potion's tooltip has numbers in it, so SE_BloodPotion fills its $1 and $2 in GetTooltipString, at display time. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Aswid/AswidBloodPotions.cs | 15 ++++- JotunnModStub/Aswid/AswidPatches.cs | 4 +- JotunnModStub/Aswid/AswidStatusEffects.cs | 20 +++--- .../Draugh/DraughProgressionPatches.cs | 2 +- JotunnModStub/Dvergar/DvergarStatusEffects.cs | 18 +++--- JotunnModStub/Fenrir/FenrirRace.cs | 14 ++--- JotunnModStub/RaceClaws.cs | 2 +- JotunnModStub/Skadi/SkadiRace.cs | 16 ++--- JotunnModStub/Skadi/SkadiStatusEffects.cs | 4 +- JotunnModStub/Skeleton/SkeletonRace.cs | 2 +- .../Skeleton/SkeletonStatusEffects.cs | 4 +- JotunnModStub/Sverm/SvermStatusEffects.cs | 18 +++--- .../Translations/English/status_effects.json | 62 +++++++++++++++++++ .../Translations/Italian/status_effects.json | 62 +++++++++++++++++++ JotunnModStub/Trenta/TrentaStatusEffects.cs | 14 ++--- JotunnModStub/Trol/TrolStatusEffects.cs | 12 ++-- 16 files changed, 203 insertions(+), 66 deletions(-) create mode 100644 JotunnModStub/Translations/English/status_effects.json create mode 100644 JotunnModStub/Translations/Italian/status_effects.json diff --git a/JotunnModStub/Aswid/AswidBloodPotions.cs b/JotunnModStub/Aswid/AswidBloodPotions.cs index 83ebf3c..a9a17f1 100644 --- a/JotunnModStub/Aswid/AswidBloodPotions.cs +++ b/JotunnModStub/Aswid/AswidBloodPotions.cs @@ -176,7 +176,7 @@ namespace RacesOfValheim SE_BloodPotion effect = ScriptableObject.CreateInstance(); effect.name = name; effect.m_name = displayName; - effect.m_tooltip = $"Stomachs filled with blood. Healing {Mathf.RoundToInt(fraction * 100f)}% over {HealDuration:0} seconds."; + effect.m_tooltip = "$rov_se_aswid_bloodpotion_tooltip"; // numbers go in at display, see GetTooltipString effect.m_ttl = HealDuration; effect.m_healFraction = fraction; effect.m_essencePrefab = essencePrefab; @@ -287,6 +287,19 @@ namespace RacesOfValheim public float m_healFraction = 0.05f; public string m_essencePrefab = ""; + /// + /// The tooltip's $1 and $2 are the heal share and the duration. Filled in here, at display + /// time, because a translation can only be looked up once the language is loaded, and the + /// game localizes this string after us in a single pass that would leave $1 as it is. + /// + public override string GetTooltipString() + { + string text = base.GetTooltipString(); + if (Localization.instance == null) return text; + return Localization.instance.Localize(text, + Mathf.RoundToInt(m_healFraction * 100f).ToString(), m_ttl.ToString("0")); + } + public override void Setup(Character character) { // SEMan clones the effect before setting it up, so writing the resolved amount here diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 400e4a4..0bc1753 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -502,9 +502,9 @@ namespace RacesOfValheim __instance.m_icon = null; } - __instance.m_name = "Night Aura"; + __instance.m_name = "$rov_se_aswid_nightaura_name"; __instance.m_startMessage = ""; // "The darkness empowers you."; - __instance.m_tooltip = "The cold strengthens your beastly senses."; + __instance.m_tooltip = "$rov_se_aswid_nightaura_tooltip"; if (__instance is SE_Stats stats) { diff --git a/JotunnModStub/Aswid/AswidStatusEffects.cs b/JotunnModStub/Aswid/AswidStatusEffects.cs index ac3ab3f..0a91feb 100644 --- a/JotunnModStub/Aswid/AswidStatusEffects.cs +++ b/JotunnModStub/Aswid/AswidStatusEffects.cs @@ -11,8 +11,8 @@ namespace RacesOfValheim { base.Setup(character); name = "SE_AswidStats"; - m_name = "Benedictus et Afflictus"; - m_tooltip = "Vampiric senses and life drain."; + m_name = "$rov_se_aswid_stats_name"; + m_tooltip = "$rov_se_aswid_stats_tooltip"; } public void UpdateStats(int state) @@ -59,8 +59,8 @@ namespace RacesOfValheim { base.Setup(character); name = "SE_BatForm"; - m_name = "Like a Bat out of Hell"; - m_tooltip = "You have taken the form of a Bat. You can fly, but cannot attack."; + m_name = "$rov_se_aswid_batform_name"; + m_tooltip = "$rov_se_aswid_batform_tooltip"; m_fallDamageModifier = -1f; // Immune to fall damage just in case } } @@ -71,8 +71,8 @@ namespace RacesOfValheim { base.Setup(character); name = "SE_MistForm"; - m_name = "Weight of Shadows"; - m_tooltip = "You are mist. Immune to physical damage and poison. Cannot attack or run."; + m_name = "$rov_se_aswid_mistform_name"; + m_tooltip = "$rov_se_aswid_mistform_tooltip"; m_fallDamageModifier = -1f; m_mods = new System.Collections.Generic.List { @@ -90,7 +90,7 @@ namespace RacesOfValheim { base.Setup(character); name = "SE_AswidSensesMark"; - m_name = "Sensed"; + m_name = "$rov_se_aswid_sensed_name"; m_tooltip = ""; m_ttl = 2f; m_icon = null; // No icon needed for mobs @@ -103,8 +103,8 @@ namespace RacesOfValheim { base.Setup(character); name = "SE_SuperhumanSenses"; - m_name = "Auspex"; - m_tooltip = "Sensing life force of nearby creatures."; + m_name = "$rov_se_aswid_auspex_name"; + m_tooltip = "$rov_se_aswid_auspex_tooltip"; } } @@ -132,7 +132,7 @@ namespace RacesOfValheim var sensesMark = ScriptableObject.CreateInstance(); sensesMark.name = "SE_AswidSensesMark"; - sensesMark.m_name = "Sensed"; + sensesMark.m_name = "$rov_se_aswid_sensed_name"; sensesMark.m_ttl = 2f; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(sensesMark, fixReference: false)); diff --git a/JotunnModStub/Draugh/DraughProgressionPatches.cs b/JotunnModStub/Draugh/DraughProgressionPatches.cs index 105eb1b..eaa8357 100644 --- a/JotunnModStub/Draugh/DraughProgressionPatches.cs +++ b/JotunnModStub/Draugh/DraughProgressionPatches.cs @@ -22,7 +22,7 @@ namespace RacesOfValheim // Invert the Wet debuff to actually heal the Draugh __instance.m_healthRegenMultiplier = DraughConfig.WetHealthRegenMultiplier.Value; __instance.m_staminaRegenMultiplier = 1f; // No stamina penalty - __instance.m_tooltip = "The water restores your rotten flesh. Health regeneration increased."; + __instance.m_tooltip = "$rov_se_draugh_wet_tooltip"; } } } diff --git a/JotunnModStub/Dvergar/DvergarStatusEffects.cs b/JotunnModStub/Dvergar/DvergarStatusEffects.cs index 10f83d1..23055b9 100644 --- a/JotunnModStub/Dvergar/DvergarStatusEffects.cs +++ b/JotunnModStub/Dvergar/DvergarStatusEffects.cs @@ -16,8 +16,8 @@ namespace RacesOfValheim { base.Setup(character); name = DvergarConfig.StatsSE; - m_name = "Stone and Forge"; - m_tooltip = "Small, sturdy, and born to the anvil."; + m_name = "$rov_se_dvergar_stats_name"; + m_tooltip = "$rov_se_dvergar_stats_tooltip"; } public override void ModifyAttackStaminaUsage(float baseStaminaUse, ref float staminaUse) @@ -80,7 +80,7 @@ namespace RacesOfValheim var stats = ScriptableObject.CreateInstance(); stats.name = DvergarConfig.StatsSE; - stats.m_name = "Stone and Forge"; + stats.m_name = "$rov_se_dvergar_stats_name"; stats.m_icon = icon; CustomStatusEffect customStats = new CustomStatusEffect(stats, fixReference: false); ItemManager.Instance.AddStatusEffect(customStats); @@ -88,22 +88,22 @@ namespace RacesOfValheim var overcharge = ScriptableObject.CreateInstance(); overcharge.name = DvergarConfig.OverchargeSE; - overcharge.m_name = "Runic Overcharge"; - overcharge.m_tooltip = "Your next blow with a favoured weapon carries the whole of the charge."; + overcharge.m_name = "$rov_se_dvergar_overcharge_name"; + overcharge.m_tooltip = "$rov_se_dvergar_overcharge_tooltip"; overcharge.m_icon = GetItemIcon("Eitr") ?? icon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(overcharge, fixReference: false)); var pingCd = ScriptableObject.CreateInstance(); pingCd.name = DvergarConfig.RunicPingCdSE; - pingCd.m_name = "Runic Ping"; - pingCd.m_tooltip = "The runes must settle before you may call on them again."; + pingCd.m_name = "$rov_se_dvergar_pingcd_name"; + pingCd.m_tooltip = "$rov_se_dvergar_pingcd_tooltip"; pingCd.m_icon = GetItemIcon("DvergrKeyFragment") ?? icon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(pingCd, fixReference: false)); var overchargeCd = ScriptableObject.CreateInstance(); overchargeCd.name = DvergarConfig.OverchargeCdSE; - overchargeCd.m_name = "Overcharge Cooldown"; - overchargeCd.m_tooltip = "The runes are spent."; + overchargeCd.m_name = "$rov_se_dvergar_overchargecd_name"; + overchargeCd.m_tooltip = "$rov_se_dvergar_overchargecd_tooltip"; overchargeCd.m_icon = GetItemIcon("Eitr") ?? icon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(overchargeCd, fixReference: false)); } diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index 5c00200..22c1ee6 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -42,8 +42,8 @@ namespace RacesOfValheim { curseSE = ScriptableObject.CreateInstance(); curseSE.name = "SE_FenrirCurse"; - curseSE.m_name = "Fenrir's Blood"; - curseSE.m_tooltip = "You are of the Fenrir race."; + curseSE.m_name = "$rov_se_fenrir_curse_name"; + curseSE.m_tooltip = "$rov_se_fenrir_curse_tooltip"; curseSE.m_mods = new System.Collections.Generic.List() { new HitData.DamageModPair() { m_type = HitData.DamageType.Spirit, m_modifier = HitData.DamageModifier.Weak } @@ -64,19 +64,19 @@ namespace RacesOfValheim { fenrirCdSE = ScriptableObject.CreateInstance(); fenrirCdSE.name = "SE_FenrirCooldown"; - fenrirCdSE.m_name = "Fenrir Form Cooldown"; + fenrirCdSE.m_name = "$rov_se_fenrir_formcd_name"; fenrirCdSE.m_icon = fenringTrophyIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(fenrirCdSE, fixReference: false)); cultistCdSE = ScriptableObject.CreateInstance(); cultistCdSE.name = "SE_CultistCooldown"; - cultistCdSE.m_name = "Cultist Form Cooldown"; + cultistCdSE.m_name = "$rov_se_fenrir_cultistcd_name"; cultistCdSE.m_icon = fenringTrophyIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(cultistCdSE, fixReference: false)); formBuffSE = ScriptableObject.CreateInstance(); formBuffSE.name = "SE_FenrirForm"; - formBuffSE.m_name = "Bestial Fury"; + formBuffSE.m_name = "$rov_se_fenrir_form_name"; formBuffSE.m_speedModifier = FenrirConfig.FullFormSpeedBonus.Value; formBuffSE.m_jumpModifier = new Vector3(0, FenrirConfig.FullFormJumpBonus.Value, 0); formBuffSE.m_fallDamageModifier = -FenrirConfig.FullFormFallDamageReduction.Value; @@ -87,7 +87,7 @@ namespace RacesOfValheim { cultistFormBuffSE = ScriptableObject.CreateInstance(); cultistFormBuffSE.name = "SE_CultistForm"; - cultistFormBuffSE.m_name = "Cultist Fury"; + cultistFormBuffSE.m_name = "$rov_se_fenrir_cultistform_name"; cultistFormBuffSE.m_speedModifier = FenrirConfig.FullFormSpeedBonus.Value; cultistFormBuffSE.m_jumpModifier = new Vector3(0, FenrirConfig.FullFormJumpBonus.Value, 0); cultistFormBuffSE.m_fallDamageModifier = -FenrirConfig.FullFormFallDamageReduction.Value; @@ -98,7 +98,7 @@ namespace RacesOfValheim { wolfFormBuffSE = ScriptableObject.CreateInstance(); wolfFormBuffSE.name = "SE_WolfForm"; - wolfFormBuffSE.m_name = "Wolf Senses"; + wolfFormBuffSE.m_name = "$rov_se_fenrir_wolfform_name"; wolfFormBuffSE.m_speedModifier = FenrirConfig.WolfFormSpeedBonus.Value; wolfFormBuffSE.m_fallDamageModifier = -FenrirConfig.WolfFormFallDamageReduction.Value; wolfFormBuffSE.m_staminaRegenMultiplier = FenrirConfig.FormStaminaRegenMultiplier.Value; diff --git a/JotunnModStub/RaceClaws.cs b/JotunnModStub/RaceClaws.cs index 660fabc..3fc2bbb 100644 --- a/JotunnModStub/RaceClaws.cs +++ b/JotunnModStub/RaceClaws.cs @@ -302,7 +302,7 @@ namespace RacesOfValheim StatusEffect se = ScriptableObject.CreateInstance(); se.name = ActiveSeName; se.m_name = DisplayName; - se.m_tooltip = "Your claws are out. They retract when this runs out."; + se.m_tooltip = "$rov_se_claws_tooltip"; se.m_icon = icon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(se, fixReference: false)); diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 4746139..fbdffb6 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -58,7 +58,7 @@ namespace RacesOfValheim var se = ScriptableObject.CreateInstance(); se.name = "SE_SkadiStats"; - se.m_name = "Skadi's Blessing"; + se.m_name = "$rov_se_skadi_stats_name"; // Icon GameObject drakeTrophy = PrefabManager.Cache.GetPrefab("TrophyHatchling")?.gameObject; @@ -81,14 +81,14 @@ namespace RacesOfValheim skadiCdSE = ScriptableObject.CreateInstance(); skadiCdSE.name = "SE_SkadiCooldown"; - skadiCdSE.m_name = "Dragon Form Cooldown"; + skadiCdSE.m_name = "$rov_se_skadi_formcd_name"; skadiCdSE.m_icon = dragonIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(skadiCdSE, fixReference: false)); skadiFormSE = ScriptableObject.CreateInstance(); skadiFormSE.name = "SE_SkadiForm"; - skadiFormSE.m_name = "Dragon Form"; - skadiFormSE.m_tooltip = "Your dragon shape holds for a while longer."; + skadiFormSE.m_name = "$rov_se_skadi_form_name"; + skadiFormSE.m_tooltip = "$rov_se_skadi_form_tooltip"; skadiFormSE.m_icon = dragonIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(skadiFormSE, fixReference: false)); @@ -96,15 +96,15 @@ namespace RacesOfValheim // differently from a dragon attack on cooldown at a glance. var spellCd = ScriptableObject.CreateInstance(); spellCd.name = SPELL_COOLDOWN_SE; - spellCd.m_name = "Cold Spell"; - spellCd.m_tooltip = "The frost must gather again before you may cast."; + spellCd.m_name = "$rov_se_skadi_coldspellcd_name"; + spellCd.m_tooltip = "$rov_se_skadi_coldspellcd_tooltip"; spellCd.m_icon = GetItemIcon("StaffIceShards") ?? dragonIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(spellCd, fixReference: false)); var attackCd = ScriptableObject.CreateInstance(); attackCd.name = ATTACK_COOLDOWN_SE; - attackCd.m_name = "Dragon Attack"; - attackCd.m_tooltip = "Your dragon shape must ready itself to strike again."; + attackCd.m_name = "$rov_se_skadi_dragonattackcd_name"; + attackCd.m_tooltip = "$rov_se_skadi_dragonattackcd_tooltip"; attackCd.m_icon = GetItemIcon("TrophyHatchling") ?? dragonIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(attackCd, fixReference: false)); } diff --git a/JotunnModStub/Skadi/SkadiStatusEffects.cs b/JotunnModStub/Skadi/SkadiStatusEffects.cs index 00a7e56..6f47454 100644 --- a/JotunnModStub/Skadi/SkadiStatusEffects.cs +++ b/JotunnModStub/Skadi/SkadiStatusEffects.cs @@ -23,8 +23,8 @@ namespace RacesOfValheim { base.Setup(character); name = "SE_SkadiStats"; - m_name = "Skadi's Aura"; - m_tooltip = "Empowered by the frost."; + m_name = "$rov_se_skadi_aura_name"; + m_tooltip = "$rov_se_skadi_aura_tooltip"; } // What the last UpdateStats call actually wrote. SEMan.AddStatusEffect stores a Clone() of diff --git a/JotunnModStub/Skeleton/SkeletonRace.cs b/JotunnModStub/Skeleton/SkeletonRace.cs index 3f0a3cb..22bc3ec 100644 --- a/JotunnModStub/Skeleton/SkeletonRace.cs +++ b/JotunnModStub/Skeleton/SkeletonRace.cs @@ -24,7 +24,7 @@ namespace RacesOfValheim var se = ScriptableObject.CreateInstance(); se.name = "SE_SkeletonStats"; - se.m_name = "Undead Fortitude"; + se.m_name = "$rov_se_skeleton_stats_name"; // Icon GameObject skelTrophy = PrefabManager.Cache.GetPrefab("TrophySkeleton")?.gameObject; diff --git a/JotunnModStub/Skeleton/SkeletonStatusEffects.cs b/JotunnModStub/Skeleton/SkeletonStatusEffects.cs index 502dd04..6bc69ac 100644 --- a/JotunnModStub/Skeleton/SkeletonStatusEffects.cs +++ b/JotunnModStub/Skeleton/SkeletonStatusEffects.cs @@ -60,8 +60,8 @@ namespace RacesOfValheim public override void Setup(Character character) { base.Setup(character); - m_name = "Resurrection Cooldown"; - m_tooltip = "Your skeletal body is too weak to resurrect again right now."; + m_name = "$rov_se_skeleton_resurrectcd_name"; + m_tooltip = "$rov_se_skeleton_resurrectcd_tooltip"; m_icon = Jotunn.Managers.PrefabManager.Cache.GetPrefab("TrophySkeletonPoison")?.GetComponent()?.m_itemData.GetIcon() ?? Jotunn.Managers.PrefabManager.Cache.GetPrefab("TrophySkeleton")?.GetComponent()?.m_itemData.GetIcon(); m_ttl = SkeletonConfig.ResurrectionCooldown.Value; diff --git a/JotunnModStub/Sverm/SvermStatusEffects.cs b/JotunnModStub/Sverm/SvermStatusEffects.cs index 7d05d34..3566dcc 100644 --- a/JotunnModStub/Sverm/SvermStatusEffects.cs +++ b/JotunnModStub/Sverm/SvermStatusEffects.cs @@ -30,8 +30,8 @@ namespace RacesOfValheim { base.Setup(character); name = SvermConfig.StatsSE; - m_name = "Chitin Plating"; - m_tooltip = "Armoured, venomous, and never alone."; + m_name = "$rov_se_sverm_stats_name"; + m_tooltip = "$rov_se_sverm_stats_tooltip"; RebuildForState(); } @@ -101,8 +101,8 @@ namespace RacesOfValheim public override void Setup(Character character) { base.Setup(character); - m_name = "Ravager Strain Cooldown"; - m_tooltip = "The strain is spent. It will take again soon."; + m_name = "$rov_se_sverm_ravagercd_name"; + m_tooltip = "$rov_se_sverm_ravagercd_tooltip"; m_ttl = SvermConfig.RavagerCooldownSeconds; } } @@ -120,8 +120,8 @@ namespace RacesOfValheim public override void Setup(Character character) { base.Setup(character); - m_name = "Ravager Strain"; - m_tooltip = "The shell doubles, and nothing that hits it lands the same again."; + m_name = "$rov_se_sverm_ravager_name"; + m_tooltip = "$rov_se_sverm_ravager_tooltip"; m_ttl = SvermConfig.RavagerDurationSeconds; } } @@ -138,7 +138,7 @@ namespace RacesOfValheim var stats = ScriptableObject.CreateInstance(); stats.name = SvermConfig.StatsSE; - stats.m_name = "Chitin Plating"; + stats.m_name = "$rov_se_sverm_stats_name"; stats.m_icon = icon; CustomStatusEffect customStats = new CustomStatusEffect(stats, fixReference: false); ItemManager.Instance.AddStatusEffect(customStats); @@ -146,13 +146,13 @@ namespace RacesOfValheim var form = ScriptableObject.CreateInstance(); form.name = SvermConfig.RavagerSE; - form.m_name = "Ravager Strain"; + form.m_name = "$rov_se_sverm_ravager_name"; form.m_icon = icon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(form, fixReference: false)); var cooldown = ScriptableObject.CreateInstance(); cooldown.name = SvermConfig.RavagerCdSE; - cooldown.m_name = "Ravager Strain Cooldown"; + cooldown.m_name = "$rov_se_sverm_ravagercd_name"; cooldown.m_icon = icon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(cooldown, fixReference: false)); } diff --git a/JotunnModStub/Translations/English/status_effects.json b/JotunnModStub/Translations/English/status_effects.json new file mode 100644 index 0000000..ba0b959 --- /dev/null +++ b/JotunnModStub/Translations/English/status_effects.json @@ -0,0 +1,62 @@ +{ + "rov_se_aswid_auspex_name": "Auspex", + "rov_se_aswid_auspex_tooltip": "Sensing life force of nearby creatures.", + "rov_se_aswid_batform_name": "Like a Bat out of Hell", + "rov_se_aswid_batform_tooltip": "You have taken the form of a Bat. You can fly, but cannot attack.", + "rov_se_aswid_bloodpotion_tooltip": "Stomachs filled with blood. Healing $1% over $2 seconds.", + "rov_se_aswid_mistform_name": "Weight of Shadows", + "rov_se_aswid_mistform_tooltip": "You are mist. Immune to physical damage and poison. Cannot attack or run.", + "rov_se_aswid_nightaura_name": "Night Aura", + "rov_se_aswid_nightaura_tooltip": "The cold strengthens your beastly senses.", + "rov_se_aswid_sensed_name": "Sensed", + "rov_se_aswid_stats_name": "Benedictus et Afflictus", + "rov_se_aswid_stats_tooltip": "Vampiric senses and life drain.", + "rov_se_claws_tooltip": "Your claws are out. They retract when this runs out.", + "rov_se_draugh_wet_tooltip": "The water restores your rotten flesh. Health regeneration increased.", + "rov_se_dvergar_overcharge_name": "Runic Overcharge", + "rov_se_dvergar_overcharge_tooltip": "Your next blow with a favoured weapon carries the whole of the charge.", + "rov_se_dvergar_overchargecd_name": "Overcharge Cooldown", + "rov_se_dvergar_overchargecd_tooltip": "The runes are spent.", + "rov_se_dvergar_pingcd_name": "Runic Ping", + "rov_se_dvergar_pingcd_tooltip": "The runes must settle before you may call on them again.", + "rov_se_dvergar_stats_name": "Stone and Forge", + "rov_se_dvergar_stats_tooltip": "Small, sturdy, and born to the anvil.", + "rov_se_fenrir_cultistcd_name": "Cultist Form Cooldown", + "rov_se_fenrir_cultistform_name": "Cultist Fury", + "rov_se_fenrir_curse_name": "Fenrir's Blood", + "rov_se_fenrir_curse_tooltip": "You are of the Fenrir race.", + "rov_se_fenrir_form_name": "Bestial Fury", + "rov_se_fenrir_formcd_name": "Fenrir Form Cooldown", + "rov_se_fenrir_wolfform_name": "Wolf Senses", + "rov_se_skadi_aura_name": "Skadi's Aura", + "rov_se_skadi_aura_tooltip": "Empowered by the frost.", + "rov_se_skadi_coldspellcd_name": "Cold Spell", + "rov_se_skadi_coldspellcd_tooltip": "The frost must gather again before you may cast.", + "rov_se_skadi_dragonattackcd_name": "Dragon Attack", + "rov_se_skadi_dragonattackcd_tooltip": "Your dragon shape must ready itself to strike again.", + "rov_se_skadi_form_name": "Dragon Form", + "rov_se_skadi_form_tooltip": "Your dragon shape holds for a while longer.", + "rov_se_skadi_formcd_name": "Dragon Form Cooldown", + "rov_se_skadi_stats_name": "Skadi's Blessing", + "rov_se_skeleton_resurrectcd_name": "Resurrection Cooldown", + "rov_se_skeleton_resurrectcd_tooltip": "Your skeletal body is too weak to resurrect again right now.", + "rov_se_skeleton_stats_name": "Undead Fortitude", + "rov_se_sverm_ravager_name": "Ravager Strain", + "rov_se_sverm_ravager_tooltip": "The shell doubles, and nothing that hits it lands the same again.", + "rov_se_sverm_ravagercd_name": "Ravager Strain Cooldown", + "rov_se_sverm_ravagercd_tooltip": "The strain is spent. It will take again soon.", + "rov_se_sverm_stats_name": "Chitin Plating", + "rov_se_sverm_stats_tooltip": "Armoured, venomous, and never alone.", + "rov_se_trenta_portalcd_name": "Homecoming Portal", + "rov_se_trenta_portalcd_tooltip": "The way home has not yet settled enough to open again.", + "rov_se_trenta_purpleraincd_name": "Purple Rain", + "rov_se_trenta_purpleraincd_tooltip": "The pollen must settle before you may call the rain again.", + "rov_se_trenta_stats_name": "Heartwood", + "rov_se_trenta_stats_tooltip": "Rooted, patient, and hard to fell.", + "rov_se_trol_throwcd_name": "Throw Rock Cooldown", + "rov_se_trol_throwcd_tooltip": "You must wait before throwing another rock.", + "rov_se_trol_trueform_name": "True Form", + "rov_se_trol_trueform_tooltip": "You have unleashed your inner troll!", + "rov_se_trol_trueformcd_name": "True Form Cooldown", + "rov_se_trol_trueformcd_tooltip": "You are exhausted from your True Form." +} diff --git a/JotunnModStub/Translations/Italian/status_effects.json b/JotunnModStub/Translations/Italian/status_effects.json new file mode 100644 index 0000000..4e8c742 --- /dev/null +++ b/JotunnModStub/Translations/Italian/status_effects.json @@ -0,0 +1,62 @@ +{ + "rov_se_aswid_auspex_name": "Auspex", + "rov_se_aswid_auspex_tooltip": "Percepisci la forza vitale delle creature vicine.", + "rov_se_aswid_batform_name": "Come un pipistrello dall'inferno", + "rov_se_aswid_batform_tooltip": "Hai preso la forma di un pipistrello. Puoi volare, ma non puoi attaccare.", + "rov_se_aswid_bloodpotion_tooltip": "Stomaci pieni di sangue. Cura il $1% in $2 secondi.", + "rov_se_aswid_mistform_name": "Peso delle ombre", + "rov_se_aswid_mistform_tooltip": "Sei nebbia. Immune ai danni fisici e al veleno. Non puoi attaccare né correre.", + "rov_se_aswid_nightaura_name": "Aura notturna", + "rov_se_aswid_nightaura_tooltip": "Il freddo acuisce i tuoi sensi bestiali.", + "rov_se_aswid_sensed_name": "Percepito", + "rov_se_aswid_stats_name": "Benedictus et Afflictus", + "rov_se_aswid_stats_tooltip": "Sensi vampirici e risucchio vitale.", + "rov_se_claws_tooltip": "Hai gli artigli fuori. Si ritraggono quando questo effetto finisce.", + "rov_se_draugh_wet_tooltip": "L'acqua ristora la tua carne putrefatta. Rigenerazione della salute aumentata.", + "rov_se_dvergar_overcharge_name": "Sovraccarico runico", + "rov_se_dvergar_overcharge_tooltip": "Il tuo prossimo colpo con un'arma prediletta scarica tutta la carica.", + "rov_se_dvergar_overchargecd_name": "Ricarica del sovraccarico", + "rov_se_dvergar_overchargecd_tooltip": "Le rune sono esaurite.", + "rov_se_dvergar_pingcd_name": "Richiamo runico", + "rov_se_dvergar_pingcd_tooltip": "Le rune devono assestarsi prima che tu possa invocarle di nuovo.", + "rov_se_dvergar_stats_name": "Pietra e forgia", + "rov_se_dvergar_stats_tooltip": "Piccolo, robusto e nato per l'incudine.", + "rov_se_fenrir_cultistcd_name": "Ricarica forma Cultista", + "rov_se_fenrir_cultistform_name": "Furia del Cultista", + "rov_se_fenrir_curse_name": "Sangue di Fenrir", + "rov_se_fenrir_curse_tooltip": "Sei della razza Fenrir.", + "rov_se_fenrir_form_name": "Furia bestiale", + "rov_se_fenrir_formcd_name": "Ricarica forma Fenrir", + "rov_se_fenrir_wolfform_name": "Sensi del lupo", + "rov_se_skadi_aura_name": "Aura di Skadi", + "rov_se_skadi_aura_tooltip": "Potenziato dal gelo.", + "rov_se_skadi_coldspellcd_name": "Incantesimo del freddo", + "rov_se_skadi_coldspellcd_tooltip": "Il gelo deve raccogliersi di nuovo prima che tu possa lanciare.", + "rov_se_skadi_dragonattackcd_name": "Attacco del drago", + "rov_se_skadi_dragonattackcd_tooltip": "La tua forma di drago deve prepararsi prima di colpire ancora.", + "rov_se_skadi_form_name": "Forma di drago", + "rov_se_skadi_form_tooltip": "La tua forma di drago resiste ancora per un po'.", + "rov_se_skadi_formcd_name": "Ricarica forma di drago", + "rov_se_skadi_stats_name": "Benedizione di Skadi", + "rov_se_skeleton_resurrectcd_name": "Ricarica resurrezione", + "rov_se_skeleton_resurrectcd_tooltip": "Il tuo corpo scheletrico è troppo debole per risorgere di nuovo adesso.", + "rov_se_skeleton_stats_name": "Tempra non morta", + "rov_se_sverm_ravager_name": "Ceppo Devastatore", + "rov_se_sverm_ravager_tooltip": "Il guscio raddoppia, e niente di ciò che lo colpisce va a segno come prima.", + "rov_se_sverm_ravagercd_name": "Ricarica Ceppo Devastatore", + "rov_se_sverm_ravagercd_tooltip": "Il ceppo è esaurito. Attecchirà di nuovo presto.", + "rov_se_sverm_stats_name": "Corazza di chitina", + "rov_se_sverm_stats_tooltip": "Corazzato, velenoso e mai solo.", + "rov_se_trenta_portalcd_name": "Portale del ritorno", + "rov_se_trenta_portalcd_tooltip": "La via di casa non si è ancora assestata abbastanza per riaprirsi.", + "rov_se_trenta_purpleraincd_name": "Pioggia viola", + "rov_se_trenta_purpleraincd_tooltip": "Il polline deve posarsi prima che tu possa richiamare la pioggia.", + "rov_se_trenta_stats_name": "Durame", + "rov_se_trenta_stats_tooltip": "Radicato, paziente e difficile da abbattere.", + "rov_se_trol_throwcd_name": "Ricarica lancio di massi", + "rov_se_trol_throwcd_tooltip": "Devi aspettare prima di lanciare un altro masso.", + "rov_se_trol_trueform_name": "Vera forma", + "rov_se_trol_trueform_tooltip": "Hai scatenato il troll che è in te!", + "rov_se_trol_trueformcd_name": "Ricarica vera forma", + "rov_se_trol_trueformcd_tooltip": "Sei esausto dopo la tua vera forma." +} diff --git a/JotunnModStub/Trenta/TrentaStatusEffects.cs b/JotunnModStub/Trenta/TrentaStatusEffects.cs index 7afb670..ae0351d 100644 --- a/JotunnModStub/Trenta/TrentaStatusEffects.cs +++ b/JotunnModStub/Trenta/TrentaStatusEffects.cs @@ -16,8 +16,8 @@ namespace RacesOfValheim { base.Setup(character); name = TrentaConfig.StatsSE; - m_name = "Heartwood"; - m_tooltip = "Rooted, patient, and hard to fell."; + m_name = "$rov_se_trenta_stats_name"; + m_tooltip = "$rov_se_trenta_stats_tooltip"; // Resistant/Weak are exactly ±50% damage taken (0.5x / 1.5x) - verified against // HitData.ApplyModifier's own IL rather than assumed, since the enum names alone @@ -83,7 +83,7 @@ namespace RacesOfValheim { var stats = ScriptableObject.CreateInstance(); stats.name = TrentaConfig.StatsSE; - stats.m_name = "Heartwood"; + stats.m_name = "$rov_se_trenta_stats_name"; stats.m_icon = GetItemIcon("Wood"); // TODO: pick the icon the race should carry CustomStatusEffect customStats = new CustomStatusEffect(stats, fixReference: false); @@ -92,15 +92,15 @@ namespace RacesOfValheim var purpleRainCd = ScriptableObject.CreateInstance(); purpleRainCd.name = TrentaConfig.PurpleRainCdSE; - purpleRainCd.m_name = "Purple Rain"; - purpleRainCd.m_tooltip = "The pollen must settle before you may call the rain again."; + purpleRainCd.m_name = "$rov_se_trenta_purpleraincd_name"; + purpleRainCd.m_tooltip = "$rov_se_trenta_purpleraincd_tooltip"; purpleRainCd.m_icon = GetItemIcon("TrophyGreydwarfShaman") ?? GetItemIcon("Wood"); ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(purpleRainCd, fixReference: false)); var portalCd = ScriptableObject.CreateInstance(); portalCd.name = TrentaConfig.PortalCdSE; - portalCd.m_name = "Homecoming Portal"; - portalCd.m_tooltip = "The way home has not yet settled enough to open again."; + portalCd.m_name = "$rov_se_trenta_portalcd_name"; + portalCd.m_tooltip = "$rov_se_trenta_portalcd_tooltip"; portalCd.m_icon = GetItemIcon("Wood"); ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(portalCd, fixReference: false)); } diff --git a/JotunnModStub/Trol/TrolStatusEffects.cs b/JotunnModStub/Trol/TrolStatusEffects.cs index 9c0c4dc..7873ce7 100644 --- a/JotunnModStub/Trol/TrolStatusEffects.cs +++ b/JotunnModStub/Trol/TrolStatusEffects.cs @@ -10,8 +10,8 @@ namespace RacesOfValheim { base.Setup(character); name = "SE_TrolThrowRockCooldown"; - m_name = "Throw Rock Cooldown"; - m_tooltip = "You must wait before throwing another rock."; + m_name = "$rov_se_trol_throwcd_name"; + m_tooltip = "$rov_se_trol_throwcd_tooltip"; m_ttl = 60f; // 1 minute cooldown // Try to find a rock-like icon, e.g. Stone @@ -33,8 +33,8 @@ namespace RacesOfValheim { base.Setup(character); name = "SE_TrolTrueForm"; - m_name = "True Form"; - m_tooltip = "You have unleashed your inner troll!"; + m_name = "$rov_se_trol_trueform_name"; + m_tooltip = "$rov_se_trol_trueform_tooltip"; // Past Fader the form no longer runs out: m_ttl 0 is vanilla's "never expires", and // the True Form key becomes the only way back (see TrolRace.TryTrueForm). m_ttl = BossProgressionManager.GetCurrentProgressionState() >= 8 ? 0f : TrolConfig.TrueFormDuration.Value; @@ -57,8 +57,8 @@ namespace RacesOfValheim { base.Setup(character); name = "SE_TrolTrueFormCooldown"; - m_name = "True Form Cooldown"; - m_tooltip = "You are exhausted from your True Form."; + m_name = "$rov_se_trol_trueformcd_name"; + m_tooltip = "$rov_se_trol_trueformcd_tooltip"; m_ttl = TrolConfig.TrueFormCooldown.Value; GameObject itemPrefab = PrefabManager.Cache.GetPrefab("Stone"); From b177c89c71619e19248890dc681d7482739c8a88 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 19:58:53 +0200 Subject: [PATCH 060/273] feat(text): item, piece and creature names come from translation files The mod's own items, build pieces and summoned creatures now carry $rov_item_, $rov_piece_ and $rov_creature_ tokens for their names and descriptions, and items.json holds the texts in English and Italian. Valheim localizes these fields wherever it shows them: tooltips, hover texts, messages, the build menu. Where a name doubles as an identifier, both sides use the same constant, so the comparisons still hold. The Aswid foods keep their prefix as a constant for the refinery's check and now name the creature with its vanilla token, so "Boar" translates too. The Furling crops get one whole description per crop instead of an English sentence with the metal dropped in. The Race Menu Ward's panel title is a mod UI Text, so it reads the translation directly. Saves are unaffected: items and eaten foods are stored by prefab name. The Sverm hive's goods stay for the merchant step. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Aswid/AswidBloodPotions.cs | 17 ++- JotunnModStub/Aswid/AswidBloodRefinery.cs | 20 ++- JotunnModStub/Aswid/AswidClaws.cs | 4 +- JotunnModStub/Aswid/AswidRace.cs | 11 +- JotunnModStub/Aswid/AswidSpectralClaw.cs | 4 +- JotunnModStub/Butler/BoneServant.cs | 12 +- JotunnModStub/Draugh/DraughHumanMeat.cs | 4 +- JotunnModStub/Draugh/DraughSpawner.cs | 16 +-- JotunnModStub/Dvergar/DvergarBanco.cs | 4 +- JotunnModStub/Dvergar/DvergarBotte.cs | 5 +- JotunnModStub/Fenrir/FenrirClaws.cs | 4 +- JotunnModStub/Fenrir/FenrirMangiatoia.cs | 26 ++-- JotunnModStub/Furling/FurlingCrops.cs | 49 ++++--- JotunnModStub/RaceMenuWard.cs | 8 +- JotunnModStub/Skadi/SkadiFrostHeart.cs | 4 +- JotunnModStub/Skadi/SkadiGolem.cs | 5 +- JotunnModStub/Skeleton/SkeletonBonePile.cs | 23 ++- JotunnModStub/Skeleton/SkeletonSentry.cs | 4 +- JotunnModStub/Sverm/SvermBlisterTick.cs | 2 +- JotunnModStub/Sverm/SvermClawSlot.cs | 4 +- JotunnModStub/Sverm/SvermConfig.cs | 2 +- JotunnModStub/Sverm/SvermHive.cs | 2 +- JotunnModStub/Sverm/SvermHiveStore.cs | 4 +- JotunnModStub/Sverm/SvermRace.cs | 2 +- JotunnModStub/Translations/English/items.json | 131 ++++++++++++++++++ JotunnModStub/Translations/Italian/items.json | 131 ++++++++++++++++++ JotunnModStub/Trenta/TrentaComposter.cs | 8 +- JotunnModStub/Trenta/TrentaConfig.cs | 14 +- JotunnModStub/Trenta/TrentaElderRoot.cs | 3 +- JotunnModStub/Trenta/TrentaHeartwoodGrove.cs | 4 +- JotunnModStub/Trol/TrolRace.cs | 4 +- JotunnModStub/Trol/TrolTotem.cs | 4 +- JotunnModStub/TrolsHammer/TrolsHammerItem.cs | 6 +- JotunnModStub/WarVulture/WarVultureItem.cs | 6 +- 34 files changed, 405 insertions(+), 142 deletions(-) create mode 100644 JotunnModStub/Translations/English/items.json create mode 100644 JotunnModStub/Translations/Italian/items.json diff --git a/JotunnModStub/Aswid/AswidBloodPotions.cs b/JotunnModStub/Aswid/AswidBloodPotions.cs index a9a17f1..cf592e4 100644 --- a/JotunnModStub/Aswid/AswidBloodPotions.cs +++ b/JotunnModStub/Aswid/AswidBloodPotions.cs @@ -27,8 +27,8 @@ namespace RacesOfValheim public const string SuperiorBaseName = "MeadBaseSuperiorBloodPotion"; public const string SuperiorPotionName = "MeadSuperiorBloodPotion"; - private const string PotionDisplayName = "Blood Potion"; - private const string SuperiorPotionDisplayName = "Superior Blood Potion"; + private const string PotionDisplayName = "$rov_item_aswid_bloodpotion_name"; + private const string SuperiorPotionDisplayName = "$rov_item_aswid_superiorbloodpotion_name"; private const float HealDuration = 8f; private const float HealFraction = 0.05f; @@ -54,15 +54,14 @@ namespace RacesOfValheim SE_BloodPotion superiorDrink = CreateEffect("SE_SuperiorBloodPotion", SuperiorPotionDisplayName, SuperiorHealFraction, AswidBloodRefinery.SuperiorEssenceName, "MoltenCore"); - GameObject meadBase = CloneItem(BaseName, "MeadBaseHealthMinor", "Blood Potion Mead Base", - "Blood, berries and crypt light, waiting on a barrel."); + GameObject meadBase = CloneItem(BaseName, "MeadBaseHealthMinor", "$rov_item_aswid_bloodpotionbase_name", + "$rov_item_aswid_bloodpotionbase_desc"); GameObject potion = CloneItem(PotionName, "MeadHealthMinor", PotionDisplayName, - "Drink and the hunger stops mattering for a while. Fills every stomach with blood essence, " + - "full or not, and knits the flesh back together."); - GameObject superiorBase = CloneItem(SuperiorBaseName, "MeadBaseHealthMedium", "Superior Blood Potion Mead Base", - "The twice-rendered draught, still raw."); + "$rov_item_aswid_bloodpotion_desc"); + GameObject superiorBase = CloneItem(SuperiorBaseName, "MeadBaseHealthMedium", "$rov_item_aswid_superiorbloodpotionbase_name", + "$rov_item_aswid_superiorbloodpotionbase_desc"); GameObject superiorPotion = CloneItem(SuperiorPotionName, "MeadHealthMedium", SuperiorPotionDisplayName, - "The same mercy, twice as deep."); + "$rov_item_aswid_superiorbloodpotion_desc"); AttachEffect(potion, drink); AttachEffect(superiorPotion, superiorDrink); diff --git a/JotunnModStub/Aswid/AswidBloodRefinery.cs b/JotunnModStub/Aswid/AswidBloodRefinery.cs index c89a2fd..0e8d711 100644 --- a/JotunnModStub/Aswid/AswidBloodRefinery.cs +++ b/JotunnModStub/Aswid/AswidBloodRefinery.cs @@ -30,10 +30,10 @@ namespace RacesOfValheim // The Aswid food patches recognise a meal by its display name, so these strings are part // of the contract with AswidPatches - see IsAswidMeal. - public const string EssenceDisplayName = "Blood Essence"; - public const string SuperiorEssenceDisplayName = "Superior Blood Essence"; - public const string CoreDisplayName = "Blood Core"; - public const string PieceDisplayName = "Blood Refinery"; + public const string EssenceDisplayName = "$rov_item_aswid_bloodessence_name"; + public const string SuperiorEssenceDisplayName = "$rov_item_aswid_superiorbloodessence_name"; + public const string CoreDisplayName = "$rov_item_aswid_bloodcore_name"; + public const string PieceDisplayName = "$rov_piece_aswid_bloodrefinery_name"; // Regeneration is tied to the health value rather than set per tier, so 60 hp gives 5 and // 80 hp gives 6.67 without a second number to keep in sync. @@ -94,7 +94,7 @@ namespace RacesOfValheim public static bool IsAswidMeal(ItemDrop.ItemData item) { if (item == null || item.m_shared == null || item.m_shared.m_name == null) return false; - return item.m_shared.m_name.StartsWith("Aswid Food:") + return item.m_shared.m_name.StartsWith(AswidRace.AswidFoodNamePrefix) || item.m_shared.m_name == EssenceDisplayName || IsEssence(item); } @@ -122,8 +122,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = CoreDisplayName; - shared.m_description = "A knot of clotted blood kept beating by something that is not a heart. " + - "The dead trade them; only the dead know how they are made."; + shared.m_description = "$rov_item_aswid_bloodcore_desc"; shared.m_itemType = ItemDrop.ItemData.ItemType.Material; shared.m_food = 0f; shared.m_foodStamina = 0f; @@ -142,8 +141,7 @@ namespace RacesOfValheim EssencePrefab = BuildEssence( EssenceName, EssenceDisplayName, - "Blood rendered down to what it actually is. The only real food an Aswid can " + - "still chew, and the base of every draught worth brewing.", + "$rov_item_aswid_bloodessence_desc", food: 60f, tint: EssenceTint, iconSource: "GemstoneRed"); @@ -151,7 +149,7 @@ namespace RacesOfValheim SuperiorEssencePrefab = BuildEssence( SuperiorEssenceName, SuperiorEssenceDisplayName, - "The same blood, rendered twice. Darker, thicker, and worth five of the first pass.", + "$rov_item_aswid_superiorbloodessence_desc", food: 80f, tint: SuperiorEssenceTint, iconSource: "MoltenCore"); @@ -267,7 +265,7 @@ namespace RacesOfValheim PieceConfig config = new PieceConfig { Name = PieceDisplayName, - Description = "Flesh goes in, bone goes in, and what is left of both comes out red.", + Description = "$rov_piece_aswid_bloodrefinery_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Requirements = new[] diff --git a/JotunnModStub/Aswid/AswidClaws.cs b/JotunnModStub/Aswid/AswidClaws.cs index cbfe3db..774857d 100644 --- a/JotunnModStub/Aswid/AswidClaws.cs +++ b/JotunnModStub/Aswid/AswidClaws.cs @@ -20,8 +20,8 @@ namespace RacesOfValheim public override string RaceId => "Aswid"; public override string ItemName => "AswidBeastClaws"; - public override string DisplayName => "Claws of the Beast"; - public override string Description => "Grown in the dark, and darker for it. They do not come off."; + public override string DisplayName => "$rov_item_aswid_claws_name"; + public override string Description => "$rov_item_aswid_claws_desc"; // The Bjorn claw first, by name, because that is the one this race is meant to wear. The // rest are the near-identical ids the manifest also carries - see SvermConfig's own diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index c864a7f..2ca35de 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -7,6 +7,9 @@ namespace RacesOfValheim { public class AswidRace : MonoBehaviour { + /// The start of every Aswid food's name, and how those items are told apart. + public const string AswidFoodNamePrefix = "$rov_item_aswid_food_name"; + public static AswidRace Instance { get; private set; } private static Dictionary mobToTrophyMap = new Dictionary @@ -117,8 +120,12 @@ namespace RacesOfValheim string foodName = "AswidFood_" + mobName; Jotunn.Configs.ItemConfig config = new Jotunn.Configs.ItemConfig(); - config.Name = "Aswid Food: " + mobName; - config.Description = "The life force of the conquered."; + // The prefix token and the creature's own vanilla token ("$enemy_boar"), which the + // game translates too. The prefix is also how the refinery recognises these items - + // see AswidBloodRefinery.IsAswidMeal - so the two must stay the same string. + string mobDisplay = Jotunn.Managers.PrefabManager.Cache.GetPrefab(mobName)?.m_name; + config.Name = AswidFoodNamePrefix + " " + (string.IsNullOrEmpty(mobDisplay) ? mobName : mobDisplay); + config.Description = "$rov_item_aswid_food_desc"; Jotunn.Entities.CustomItem customItem = null; diff --git a/JotunnModStub/Aswid/AswidSpectralClaw.cs b/JotunnModStub/Aswid/AswidSpectralClaw.cs index 64f2c87..01e568d 100644 --- a/JotunnModStub/Aswid/AswidSpectralClaw.cs +++ b/JotunnModStub/Aswid/AswidSpectralClaw.cs @@ -156,8 +156,8 @@ namespace RacesOfValheim ItemDrop itemDrop = clone.GetComponent(); if (itemDrop == null) return false; - itemDrop.m_itemData.m_shared.m_name = "Spectral Claw"; - itemDrop.m_itemData.m_shared.m_description = "A claw of pure shadow, bound to your rage rather than your grip."; + itemDrop.m_itemData.m_shared.m_name = "$rov_item_aswid_spectralclaw_name"; + itemDrop.m_itemData.m_shared.m_description = "$rov_item_aswid_spectralclaw_desc"; itemDrop.m_itemData.m_shared.m_weight = 0f; itemDrop.m_itemData.m_shared.m_useDurability = false; itemDrop.m_itemData.m_shared.m_questItem = true; // undroppable, unsellable diff --git a/JotunnModStub/Butler/BoneServant.cs b/JotunnModStub/Butler/BoneServant.cs index bbd9147..8c7a0a3 100644 --- a/JotunnModStub/Butler/BoneServant.cs +++ b/JotunnModStub/Butler/BoneServant.cs @@ -42,13 +42,13 @@ namespace RacesOfValheim // The smith inherits the names the single servant had, so nothing already built is orphaned. public const string SmithName = "BoneServant"; public const string SmithTableName = "ServantTable"; - public const string SmithDisplay = "Bone Smith"; - public const string SmithTableDisplay = "Smith's Table"; + public const string SmithDisplay = "$rov_creature_bonesmith_name"; + public const string SmithTableDisplay = "$rov_piece_smithtable_name"; public const string CookName = "BoneCook"; public const string CookTableName = "CookTable"; - public const string CookDisplay = "Bone Cook"; - public const string CookTableDisplay = "Cook's Table"; + public const string CookDisplay = "$rov_creature_bonecook_name"; + public const string CookTableDisplay = "$rov_piece_cooktable_name"; /// Vanilla's guaranteed-melee skeleton: the plain one rolls its own weapon, and the /// point here is to have none at all. @@ -90,7 +90,7 @@ namespace RacesOfValheim if (RegisterServant(SmithName, SmithDisplay, ButlerFamily.Forge)) { RegisterTable(SmithTableName, SmithTableDisplay, SmithName, ButlerFamily.Forge, - "A slab of bone and slate, dusted with ore. Something patient waits by the fires.", + "$rov_piece_smithtable_desc", "Coal"); PieceDensityLimit.Register(SmithTableName, TableSpacing, 1, @@ -114,7 +114,7 @@ namespace RacesOfValheim if (RegisterServant(CookName, CookDisplay, ButlerFamily.Kitchen)) { RegisterTable(CookTableName, CookTableDisplay, CookName, ButlerFamily.Kitchen, - "A slab of bone and slate, worn smooth. Something patient waits by the hearth.", + "$rov_piece_cooktable_desc", "CookedMeat"); PieceDensityLimit.Register(CookTableName, TableSpacing, 1, diff --git a/JotunnModStub/Draugh/DraughHumanMeat.cs b/JotunnModStub/Draugh/DraughHumanMeat.cs index 6ba3293..8a4977f 100644 --- a/JotunnModStub/Draugh/DraughHumanMeat.cs +++ b/JotunnModStub/Draugh/DraughHumanMeat.cs @@ -72,8 +72,8 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = item.ItemDrop.m_itemData.m_shared; ItemDrop.ItemData.SharedData source = nourishment.m_itemData.m_shared; - shared.m_name = "Human Meat"; - shared.m_description = "A piece of somebody. The living gag on it; you do not."; + shared.m_name = "$rov_item_draugh_humanmeat_name"; + shared.m_description = "$rov_item_draugh_humanmeat_desc"; // Raw meat is a Material in vanilla, so none of the food fields below would be read // without this. diff --git a/JotunnModStub/Draugh/DraughSpawner.cs b/JotunnModStub/Draugh/DraughSpawner.cs index b921be7..9e00fd5 100644 --- a/JotunnModStub/Draugh/DraughSpawner.cs +++ b/JotunnModStub/Draugh/DraughSpawner.cs @@ -25,17 +25,17 @@ namespace RacesOfValheim { // ─── Names ─────────────────────────────────────────────────────────── public const string PieceName = "DraughBodyPile"; - public const string PieceDisplayName = "Cursed Body Pile"; + public const string PieceDisplayName = "$rov_piece_draugh_bodypile_name"; public const string BoneName = "CursedBone"; - public const string BoneDisplayName = "Cursed Bone"; + public const string BoneDisplayName = "$rov_item_draugh_cursedbone_name"; public const string GreaterBoneName = "GreaterCursedBone"; - public const string GreaterBoneDisplayName = "Greater Cursed Bone"; + public const string GreaterBoneDisplayName = "$rov_item_draugh_greatercursedbone_name"; public const string ThrallName = "DraughThrall_Draugr"; public const string ThrallEliteName = "DraughThrall_DraugrElite"; - public const string ThrallDisplayName = "Draugr Thrall"; - public const string ThrallEliteDisplayName = "Draugr Elite Thrall"; + public const string ThrallDisplayName = "$rov_creature_draugh_thrall_name"; + public const string ThrallEliteDisplayName = "$rov_creature_draugh_thrallelite_name"; // RaisedThrall groups by kind for follower caps and for the roster, so these are the strings // that decide "is this one an officer" - no longer a display-name comparison. @@ -118,9 +118,9 @@ namespace RacesOfValheim public static void Register() { RegisterBone(BoneName, BoneDisplayName, BoneTint, - "A bone that will not stay quiet. The dead sell them; the dead do not say why."); + "$rov_item_draugh_cursedbone_desc"); RegisterBone(GreaterBoneName, GreaterBoneDisplayName, GreaterBoneTint, - "The same bone, older, and louder. A pile fed one of these starts keeping officers."); + "$rov_item_draugh_greatercursedbone_desc"); RegisterThrall(ThrallName, "Draugr", ThrallDisplayName, KindNormal, MaxFollowers); RegisterThrall(ThrallEliteName, "Draugr_Elite", ThrallEliteDisplayName, KindElite, MaxEliteFollowers); @@ -263,7 +263,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = PieceDisplayName, - Description = "Feed it and it answers. The dead here are yours, if you are dead enough to ask.", + Description = "$rov_piece_draugh_bodypile_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Icon = BorrowIcon(TrophyDraugr), diff --git a/JotunnModStub/Dvergar/DvergarBanco.cs b/JotunnModStub/Dvergar/DvergarBanco.cs index f686d6a..b18e968 100644 --- a/JotunnModStub/Dvergar/DvergarBanco.cs +++ b/JotunnModStub/Dvergar/DvergarBanco.cs @@ -36,7 +36,7 @@ namespace RacesOfValheim public static class DvergarBanco { public const string PieceName = "DvergarContractBank"; - public const string PieceDisplayName = "Contract Bank"; + public const string PieceDisplayName = "$rov_piece_dvergar_contractbank_name"; public const string RaceId = DvergarConfig.RaceId; /// The Queen's drop, mapped to state 7 in BossProgressionManager. Mistlands money for @@ -348,7 +348,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = PieceDisplayName, - Description = "A ledger, a seal and a heap of coin. Sign here and someone else does the dying.", + Description = "$rov_piece_dvergar_contractbank_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Icon = BorrowIcon("TrophyDvergr"), diff --git a/JotunnModStub/Dvergar/DvergarBotte.cs b/JotunnModStub/Dvergar/DvergarBotte.cs index b389bc8..05ee712 100644 --- a/JotunnModStub/Dvergar/DvergarBotte.cs +++ b/JotunnModStub/Dvergar/DvergarBotte.cs @@ -33,7 +33,7 @@ namespace RacesOfValheim public static class DvergarBotte { public const string PieceName = "DvergarRuneBarrel"; - public const string PieceDisplayName = "Rune Barrel"; + public const string PieceDisplayName = "$rov_piece_dvergar_runebarrel_name"; public const string RaceId = DvergarConfig.RaceId; /// How many drinks it holds. One dose is one mercenary served, so twenty is four @@ -101,8 +101,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = PieceDisplayName, - Description = "Pour a brew in and the crew drinks. What it does to them is whatever it " + - "would have done to you - if they have the parts for it.", + Description = "$rov_piece_dvergar_runebarrel_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Icon = BorrowIcon("MeadHealthMinor") ?? BorrowIcon("TrophyDvergr"), diff --git a/JotunnModStub/Fenrir/FenrirClaws.cs b/JotunnModStub/Fenrir/FenrirClaws.cs index ebe749d..a9a8f15 100644 --- a/JotunnModStub/Fenrir/FenrirClaws.cs +++ b/JotunnModStub/Fenrir/FenrirClaws.cs @@ -19,8 +19,8 @@ namespace RacesOfValheim public override string RaceId => "Fenrir"; public override string ItemName => "FenrirCursedClaws"; - public override string DisplayName => "Cursed Claws"; - public override string Description => "The wolf's hands, kept on in the man's shape. They do not come off."; + public override string DisplayName => "$rov_item_fenrir_claws_name"; + public override string Description => "$rov_item_fenrir_claws_desc"; public override string[] ModelPrefabs => new[] { diff --git a/JotunnModStub/Fenrir/FenrirMangiatoia.cs b/JotunnModStub/Fenrir/FenrirMangiatoia.cs index 79a9c38..b098f0a 100644 --- a/JotunnModStub/Fenrir/FenrirMangiatoia.cs +++ b/JotunnModStub/Fenrir/FenrirMangiatoia.cs @@ -35,12 +35,12 @@ namespace RacesOfValheim { // ─── Names ─────────────────────────────────────────────────────────── public const string PieceName = "FenrirPackTrough"; - public const string PieceDisplayName = "Pack Trough"; + public const string PieceDisplayName = "$rov_piece_fenrir_packtrough_name"; public const string UlvsblodName = "Ulvsblod"; - public const string UlvsblodDisplayName = "Ulvsblod"; + public const string UlvsblodDisplayName = "$rov_item_fenrir_ulvsblod_name"; public const string GreaterUlvsblodName = "GreaterUlvsblod"; - public const string GreaterUlvsblodDisplayName = "Greater Ulvsblod"; + public const string GreaterUlvsblodDisplayName = "$rov_item_fenrir_greaterulvsblod_name"; public const int UlvsblodPrice = 500; public const int GreaterUlvsblodPrice = 1500; @@ -49,9 +49,9 @@ namespace RacesOfValheim public const string UlvName = "FenrirPack_Ulv"; public const string FenrirName = "FenrirPack_Fenrir"; - public const string WolfDisplayName = "Pack Wolf"; - public const string UlvDisplayName = "Ulv"; - public const string FenrirDisplayName = "Fenrir"; + public const string WolfDisplayName = "$rov_creature_fenrir_packwolf_name"; + public const string UlvDisplayName = "$rov_creature_fenrir_packulv_name"; + public const string FenrirDisplayName = "$rov_creature_fenrir_packfenrir_name"; public const string KindWolf = "FenrirPackWolf"; public const string KindUlv = "FenrirPackUlv"; @@ -140,18 +140,16 @@ namespace RacesOfValheim public static void Register() { RegisterUlvsblod(UlvsblodName, UlvsblodDisplayName, UlvsblodTint, - "Wolf blood, kept warm by something that should not be able to keep anything warm. " + - "The Fenring sell it and do not explain it."); + "$rov_item_fenrir_ulvsblod_desc"); RegisterUlvsblod(GreaterUlvsblodName, GreaterUlvsblodDisplayName, GreaterUlvsblodTint, - "Older blood, and further down the line. A trough given one of these starts raising " + - "something worse than ulv."); + "$rov_item_fenrir_greaterulvsblod_desc"); RegisterPackAnimal(WolfName, "Wolf", WolfDisplayName, KindWolf, - "It answers to the blood of the wolf, not to you.", 1f); + "$rov_creature_fenrir_pack_desc", 1f); RegisterPackAnimal(UlvName, "Ulv", UlvDisplayName, KindUlv, - "It answers to the blood of the wolf, not to you.", 1f); + "$rov_creature_fenrir_pack_desc", 1f); RegisterPackAnimal(FenrirName, "Fenring", FenrirDisplayName, KindFenrir, - "Only the blood of the wolf commands this one.", FenrirScale); + "$rov_creature_fenrir_packfenrir_desc", FenrirScale); RegisterPiece(); @@ -338,7 +336,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = PieceDisplayName, - Description = "Fill it with meat and the pack comes. One at a time, and it remembers its dead.", + Description = "$rov_piece_fenrir_packtrough_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Icon = BorrowIcon("TrophyFenring"), diff --git a/JotunnModStub/Furling/FurlingCrops.cs b/JotunnModStub/Furling/FurlingCrops.cs index 75a7455..79cf5c9 100644 --- a/JotunnModStub/Furling/FurlingCrops.cs +++ b/JotunnModStub/Furling/FurlingCrops.cs @@ -65,27 +65,27 @@ namespace RacesOfValheim { new MetalCrop { - Metal = "Copper", FlaxName = "CopperFlax", FlaxDisplay = "Copper Flax", - DustName = "CopperDust", DustDisplay = "Copper Dust", + Metal = "Copper", FlaxName = "CopperFlax", FlaxDisplay = "$rov_item_furling_copperflax_name", + DustName = "CopperDust", DustDisplay = "$rov_item_furling_copperdust_name", PickableName = "Pickable_CopperFlax", SaplingName = "sapling_copperflax", - SaplingDisplay = "Copper Flax", OrePrefab = "CopperOre", + SaplingDisplay = "$rov_piece_furling_copperflaxsapling_name", OrePrefab = "CopperOre", Tint = new Color(0.72f, 0.45f, 0.20f, 1f), }, new MetalCrop { - Metal = "Tin", FlaxName = "TinFlax", FlaxDisplay = "Tin Flax", - DustName = "TinDust", DustDisplay = "Tin Dust", + Metal = "Tin", FlaxName = "TinFlax", FlaxDisplay = "$rov_item_furling_tinflax_name", + DustName = "TinDust", DustDisplay = "$rov_item_furling_tindust_name", PickableName = "Pickable_TinFlax", SaplingName = "sapling_tinflax", - SaplingDisplay = "Tin Flax", OrePrefab = "TinOre", + SaplingDisplay = "$rov_piece_furling_tinflaxsapling_name", OrePrefab = "TinOre", Tint = new Color(0.80f, 0.82f, 0.85f, 1f), }, new MetalCrop { - Metal = "Iron", FlaxName = "IronFlax", FlaxDisplay = "Iron Flax", - DustName = "IronDust", DustDisplay = "Iron Dust", + Metal = "Iron", FlaxName = "IronFlax", FlaxDisplay = "$rov_item_furling_ironflax_name", + DustName = "IronDust", DustDisplay = "$rov_item_furling_irondust_name", PickableName = "Pickable_IronFlax", SaplingName = "sapling_ironflax", // Iron's raw form is IronScrap, not "IronOre" - there is no IronOre prefab. - SaplingDisplay = "Iron Flax", OrePrefab = "IronScrap", + SaplingDisplay = "$rov_piece_furling_ironflaxsapling_name", OrePrefab = "IronScrap", Tint = new Color(0.35f, 0.36f, 0.38f, 1f), }, }; @@ -104,18 +104,29 @@ namespace RacesOfValheim { new RockBerry { - BerryName = "Stoneberry", BerryDisplay = "Stoneberry", - BushName = "StoneberryBush", BushDisplay = "Stoneberry Bush", + BerryName = "Stoneberry", BerryDisplay = "$rov_item_furling_stoneberry_name", + BushName = "StoneberryBush", BushDisplay = "$rov_piece_furling_stoneberrybush_name", YieldPrefab = "Stone", Tint = new Color(0.55f, 0.55f, 0.55f, 1f), }, new RockBerry { - BerryName = "Flintberry", BerryDisplay = "Flintberry", - BushName = "FlintberryBush", BushDisplay = "Flintberry Bush", + BerryName = "Flintberry", BerryDisplay = "$rov_item_furling_flintberry_name", + BushName = "FlintberryBush", BushDisplay = "$rov_piece_furling_flintberrybush_name", YieldPrefab = "Flint", Tint = new Color(0.30f, 0.32f, 0.35f, 1f), }, }; + /// + /// The description token that goes with a name token: "$rov_item_furling_tinflax_name" gives + /// "$rov_item_furling_tinflax_desc". One whole sentence per crop in the translation files, + /// rather than one sentence with the metal dropped in, so a translator can decline the metal + /// or move it wherever their language wants it. + /// + private static string DescriptionFor(string nameToken) + { + return nameToken.EndsWith("_name") ? nameToken.Substring(0, nameToken.Length - 5) + "_desc" : nameToken; + } + public static void Register() { foreach (MetalCrop crop in Crops) RegisterCrop(crop); @@ -151,8 +162,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = crop.FlaxDisplay; - shared.m_description = $"Flax grown in {crop.Metal.ToLowerInvariant()}-poisoned soil, and it took. " + - "Useless as cloth. Grind it and see."; + shared.m_description = DescriptionFor(crop.FlaxDisplay); // Teleportable is inherited from Flax and left alone on purpose: the flax travels, the // dust does not. That asymmetry is the whole point of the chain. @@ -177,8 +187,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = crop.DustDisplay; - shared.m_description = $"A sack of {crop.Metal.ToLowerInvariant()} ground fine. " + - "A furnace cannot tell it from ore, and it will not go through a portal either."; + shared.m_description = DescriptionFor(crop.DustDisplay); shared.m_itemType = ItemDrop.ItemData.ItemType.Material; shared.m_food = 0f; shared.m_foodStamina = 0f; @@ -280,7 +289,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = crop.SaplingDisplay, - Description = $"Plant it and it grows more {crop.FlaxDisplay}.", + Description = DescriptionFor(crop.SaplingDisplay), PieceTable = PieceTables.Cultivator, Requirements = new[] { new RequirementConfig(crop.FlaxName, 1, 0, true) }, })); @@ -310,7 +319,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = berry.BerryDisplay; - shared.m_description = $"Not a berry, whatever it looks like. Bury one and a {berry.YieldPrefab.ToLowerInvariant()}-bearing bush comes up."; + shared.m_description = DescriptionFor(berry.BerryDisplay); // Inedible, as designed. Material with every food value at zero also keeps it clear of // the Trenta's vegan check and of the Aswid/Skeleton food gates, all three of which only @@ -385,7 +394,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = berry.BushDisplay, - Description = $"Yields {berry.YieldPrefab.ToLowerInvariant()}, and keeps yielding it.", + Description = DescriptionFor(berry.BushDisplay), PieceTable = PieceTables.Cultivator, // The one thing that was actually missing the first time round. Icon = BorrowIcon(berry.YieldPrefab), diff --git a/JotunnModStub/RaceMenuWard.cs b/JotunnModStub/RaceMenuWard.cs index 255b38e..5457560 100644 --- a/JotunnModStub/RaceMenuWard.cs +++ b/JotunnModStub/RaceMenuWard.cs @@ -46,8 +46,8 @@ namespace RacesOfValheim PieceConfig config = new PieceConfig { - Name = "Race Menu Ward", - Description = "Commune with your heritage. Offer a fallen boss's relic to claim its power.", + Name = "$rov_piece_racemenuward_name", + Description = "$rov_piece_racemenuward_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Misc, // Deliberately trivial: this is a utility the player needs early, not a reward. @@ -167,7 +167,7 @@ namespace RacesOfValheim // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour. public float GetHoverOffset() => 0f; - public string GetHoverName() => "Race Menu Ward"; + public string GetHoverName() => "$rov_piece_racemenuward_name"; public string GetHoverText() { @@ -266,7 +266,7 @@ namespace RacesOfValheim Image bg = panel.AddComponent(); bg.color = new Color(0f, 0f, 0f, 0.85f); - AddLabel("Title", "Race Menu Ward", 46, new Vector2(0, 230), new Vector2(700, 90)); + AddLabel("Title", ModText.Get("rov_piece_racemenuward_name"), 46, new Vector2(0, 230), new Vector2(700, 90)); AddLabel("Status", BuildStatusText(), 24, new Vector2(0, 110), new Vector2(900, 160)); diff --git a/JotunnModStub/Skadi/SkadiFrostHeart.cs b/JotunnModStub/Skadi/SkadiFrostHeart.cs index 0b53594..d2d50cc 100644 --- a/JotunnModStub/Skadi/SkadiFrostHeart.cs +++ b/JotunnModStub/Skadi/SkadiFrostHeart.cs @@ -18,7 +18,7 @@ namespace RacesOfValheim public static class SkadiFrostHeart { public const string PrefabName = "GreaterFrostHeart"; - public const string DisplayName = "Greater Frost Heart"; + public const string DisplayName = "$rov_item_skadi_greaterfrostheart_name"; public const int Price = 1500; private const string SourcePrefab = "FreezeGland"; @@ -43,7 +43,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = DisplayName; - shared.m_description = "Older cold than the mountain's. The cultists sell it and will not say where they dig."; + shared.m_description = "$rov_item_skadi_greaterfrostheart_desc"; shared.m_itemType = ItemDrop.ItemData.ItemType.Material; shared.m_weight = 0.5f; shared.m_maxStackSize = 10; diff --git a/JotunnModStub/Skadi/SkadiGolem.cs b/JotunnModStub/Skadi/SkadiGolem.cs index 07e6aeb..9a1035e 100644 --- a/JotunnModStub/Skadi/SkadiGolem.cs +++ b/JotunnModStub/Skadi/SkadiGolem.cs @@ -39,7 +39,7 @@ namespace RacesOfValheim // ─── Names ─────────────────────────────────────────────────────────── public const string GolemName = "SkadiCrystalGolem"; public const string SeedPieceName = "SkadiCrystalGolemSeed"; - public const string DisplayName = "Crystal Golem"; + public const string DisplayName = "$rov_creature_skadi_crystalgolem_name"; private const string SourceGolem = "StoneGolem"; @@ -271,8 +271,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = DisplayName, - Description = "Cut at the stone and woken with a tear. It will not follow you, and it " + - "will not leave the stonecutter that shaped it.", + Description = "$rov_piece_skadi_crystalgolem_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, // The stonecutter is the station, so vanilla itself refuses to place one anywhere its diff --git a/JotunnModStub/Skeleton/SkeletonBonePile.cs b/JotunnModStub/Skeleton/SkeletonBonePile.cs index 8824612..35fcdd9 100644 --- a/JotunnModStub/Skeleton/SkeletonBonePile.cs +++ b/JotunnModStub/Skeleton/SkeletonBonePile.cs @@ -33,29 +33,29 @@ namespace RacesOfValheim { // ─── Names ─────────────────────────────────────────────────────────── public const string PieceName = "SkeletonBonePile"; - public const string PieceDisplayName = "Bound Bone Pile"; + public const string PieceDisplayName = "$rov_piece_skeleton_bonepile_name"; // The Soul Stone: a green ruby, sold by the Skeleton bench, and the thing that binds a skull and // ten fragments into a sentry that cannot walk. Cheap on purpose - 50 coins - because the real // cost of a sentry is the skull, which has to be taken off a skeleton rather than bought. public const string SoulStoneName = "SoulStone"; - public const string SoulStoneDisplayName = "Soul Stone"; + public const string SoulStoneDisplayName = "$rov_item_skeleton_soulstone_name"; public const int SoulStonePrice = 50; private static readonly Color SoulStoneTint = new Color(0.15f, 0.85f, 0.35f, 1f); public const string SkullName = "CursedSkull"; - public const string SkullDisplayName = "Cursed Skull"; + public const string SkullDisplayName = "$rov_item_skeleton_cursedskull_name"; public const string GreaterSkullName = "GreaterCursedSkull"; - public const string GreaterSkullDisplayName = "Greater Cursed Skull"; + public const string GreaterSkullDisplayName = "$rov_item_skeleton_greatercursedskull_name"; public const string ThrallMeleeName = "SkeletonThrall_Melee"; public const string ThrallRangedName = "SkeletonThrall_Ranged"; public const string ThrallRancidName = "SkeletonThrall_Rancid"; - public const string ThrallMeleeDisplay = "Bound Skeleton"; - public const string ThrallRangedDisplay = "Bound Archer"; - public const string ThrallRancidDisplay = "Bound Rancid Remains"; + public const string ThrallMeleeDisplay = "$rov_creature_skeleton_thrallmelee_name"; + public const string ThrallRangedDisplay = "$rov_creature_skeleton_thrallranged_name"; + public const string ThrallRancidDisplay = "$rov_creature_skeleton_thrallrancid_name"; public const string KindMelee = "SkeletonMelee"; public const string KindRanged = "SkeletonRanged"; @@ -119,9 +119,9 @@ namespace RacesOfValheim public static void Register() { RegisterSkull(SkullName, SkullDisplayName, SkullTint, - "A skull that keeps counting. Set it down and the ground starts answering."); + "$rov_item_skeleton_cursedskull_desc"); RegisterSkull(GreaterSkullName, GreaterSkullDisplayName, GreaterSkullTint, - "Older, and it counts higher. A pile given one of these raises the rotten too."); + "$rov_item_skeleton_greatercursedskull_desc"); RegisterSoulStone(); @@ -191,8 +191,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = SoulStoneDisplayName; - shared.m_description = "Something is still in there, and it is still angry. Bind it to a skull " + - "and it will stand watch as long as the bones hold."; + shared.m_description = "$rov_item_skeleton_soulstone_desc"; shared.m_itemType = ItemDrop.ItemData.ItemType.Material; shared.m_weight = 0.5f; shared.m_maxStackSize = 20; @@ -339,7 +338,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = PieceDisplayName, - Description = "Twenty fragments buy a place in the line. The one who fills it will keep standing up.", + Description = "$rov_piece_skeleton_bonepile_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Icon = BorrowIcon("TrophySkeleton"), diff --git a/JotunnModStub/Skeleton/SkeletonSentry.cs b/JotunnModStub/Skeleton/SkeletonSentry.cs index ef37404..dd96949 100644 --- a/JotunnModStub/Skeleton/SkeletonSentry.cs +++ b/JotunnModStub/Skeleton/SkeletonSentry.cs @@ -26,7 +26,7 @@ namespace RacesOfValheim { public const string SentryName = "SkeletonSentry"; public const string SeedPieceName = "SkeletonSentrySeed"; - public const string DisplayName = "Bound Sentry"; + public const string DisplayName = "$rov_creature_skeleton_sentry_name"; /// Seconds without being hit before it starts closing its wounds. public const float RegenDelay = 10f; @@ -157,7 +157,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = DisplayName, - Description = "A skull on a soul stone. It will not walk, and it will not stop watching.", + Description = "$rov_piece_skeleton_sentry_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Icon = BorrowIcon("TrophySkeleton"), diff --git a/JotunnModStub/Sverm/SvermBlisterTick.cs b/JotunnModStub/Sverm/SvermBlisterTick.cs index 7363fb1..507b97f 100644 --- a/JotunnModStub/Sverm/SvermBlisterTick.cs +++ b/JotunnModStub/Sverm/SvermBlisterTick.cs @@ -22,7 +22,7 @@ namespace RacesOfValheim public static class SvermBlisterTick { public const string PrefabName = "SvermBlisterTick"; - public const string DisplayName = "Blister Tick"; + public const string DisplayName = "$rov_creature_sverm_blistertick_name"; private const string SourcePrefab = "Tick"; /// How many slots this nest has bought. Permanent, and the respawn reads it. diff --git a/JotunnModStub/Sverm/SvermClawSlot.cs b/JotunnModStub/Sverm/SvermClawSlot.cs index 54201c6..34bf82e 100644 --- a/JotunnModStub/Sverm/SvermClawSlot.cs +++ b/JotunnModStub/Sverm/SvermClawSlot.cs @@ -42,7 +42,7 @@ namespace RacesOfValheim /// longer resolve. The display name below is the only half a player ever reads. /// public const string ItemName = "SvermMaulclaws"; - public const string ItemDisplayName = "Chitin Claws"; + public const string ItemDisplayName = "$rov_item_sverm_claws_name"; /// Row in the reserved column the claws sit on. The other three await the carapace. private const int ClawRow = 0; @@ -80,7 +80,7 @@ namespace RacesOfValheim { ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = ItemDisplayName; - shared.m_description = "Grown, not forged. They do not come off."; + shared.m_description = "$rov_item_sverm_claws_desc"; // Quest item: Valheim refuses to drop, trade or stack these. It is the cheapest // honest way to say "this is part of your body" without a patch per verb. diff --git a/JotunnModStub/Sverm/SvermConfig.cs b/JotunnModStub/Sverm/SvermConfig.cs index f5f0c93..0a341ca 100644 --- a/JotunnModStub/Sverm/SvermConfig.cs +++ b/JotunnModStub/Sverm/SvermConfig.cs @@ -444,7 +444,7 @@ namespace RacesOfValheim public static readonly float MarketSize = 1.6f; // metres, the borrowed model's largest side // ─── Seeker Worker ─────────────────────────────────────────────────── - public const string WorkerDisplayName = "Seeker Worker"; + public const string WorkerDisplayName = "$rov_creature_sverm_worker_name"; public static readonly float WorkerScale = 0.5f; public static readonly float WorkerHealthFraction = 0.5f; public static readonly float WorkerDamageFraction = 0.5f; diff --git a/JotunnModStub/Sverm/SvermHive.cs b/JotunnModStub/Sverm/SvermHive.cs index 6e8f53b..3c2266b 100644 --- a/JotunnModStub/Sverm/SvermHive.cs +++ b/JotunnModStub/Sverm/SvermHive.cs @@ -95,7 +95,7 @@ namespace RacesOfValheim // station ends up unplaceable with no error. Piece piece = prefab.GetComponent() ?? prefab.AddComponent(); piece.m_name = DisplayName; - piece.m_description = "The colony begins here. Everything else grows out of it."; + piece.m_description = "$rov_piece_sverm_broodmound_desc"; piece.m_groundPiece = true; piece.m_groundOnly = true; piece.m_cultivatedGroundOnly = false; diff --git a/JotunnModStub/Sverm/SvermHiveStore.cs b/JotunnModStub/Sverm/SvermHiveStore.cs index 39df58b..f63f642 100644 --- a/JotunnModStub/Sverm/SvermHiveStore.cs +++ b/JotunnModStub/Sverm/SvermHiveStore.cs @@ -258,7 +258,7 @@ namespace RacesOfValheim public static class SvermHiveMarketPiece { public const string PieceName = "SvermHiveMarket"; - public const string DisplayName = "Hive Market"; + public const string DisplayName = "$rov_piece_sverm_hivemarket_name"; /// Scenery only, and checked rather than trusted - see SvermHive.MouthCandidates. private static readonly string[] SourceCandidates = @@ -325,7 +325,7 @@ namespace RacesOfValheim piece.m_craftingStation = null; piece.m_resources = new Piece.Requirement[0]; piece.m_name = DisplayName; - piece.m_description = "Where the colony trades. It spends the tank of the nest it stands in."; + piece.m_description = "$rov_piece_sverm_hivemarket_desc"; piece.m_groundPiece = true; piece.m_groundOnly = true; piece.m_canBeRemoved = true; diff --git a/JotunnModStub/Sverm/SvermRace.cs b/JotunnModStub/Sverm/SvermRace.cs index f3f1450..69a11f9 100644 --- a/JotunnModStub/Sverm/SvermRace.cs +++ b/JotunnModStub/Sverm/SvermRace.cs @@ -101,6 +101,6 @@ namespace RacesOfValheim public static class SvermHiveNames { public const string PieceName = "SvermBroodMound"; - public const string PieceDisplayName = "Brood Mound"; + public const string PieceDisplayName = "$rov_piece_sverm_broodmound_name"; } } diff --git a/JotunnModStub/Translations/English/items.json b/JotunnModStub/Translations/English/items.json new file mode 100644 index 0000000..1d707d6 --- /dev/null +++ b/JotunnModStub/Translations/English/items.json @@ -0,0 +1,131 @@ +{ + "rov_creature_bonecook_name": "Bone Cook", + "rov_creature_bonesmith_name": "Bone Smith", + "rov_creature_draugh_thrall_name": "Draugr Thrall", + "rov_creature_draugh_thrallelite_name": "Draugr Elite Thrall", + "rov_creature_fenrir_pack_desc": "It answers to the blood of the wolf, not to you.", + "rov_creature_fenrir_packfenrir_desc": "Only the blood of the wolf commands this one.", + "rov_creature_fenrir_packfenrir_name": "Fenrir", + "rov_creature_fenrir_packulv_name": "Ulv", + "rov_creature_fenrir_packwolf_name": "Pack Wolf", + "rov_creature_skadi_crystalgolem_name": "Crystal Golem", + "rov_creature_skeleton_sentry_name": "Bound Sentry", + "rov_creature_skeleton_thrallmelee_name": "Bound Skeleton", + "rov_creature_skeleton_thrallrancid_name": "Bound Rancid Remains", + "rov_creature_skeleton_thrallranged_name": "Bound Archer", + "rov_creature_sverm_blistertick_name": "Blister Tick", + "rov_creature_sverm_worker_name": "Seeker Worker", + "rov_item_aswid_bloodcore_desc": "A knot of clotted blood kept beating by something that is not a heart. The dead trade them; only the dead know how they are made.", + "rov_item_aswid_bloodcore_name": "Blood Core", + "rov_item_aswid_bloodessence_desc": "Blood rendered down to what it actually is. The only real food an Aswid can still chew, and the base of every draught worth brewing.", + "rov_item_aswid_bloodessence_name": "Blood Essence", + "rov_item_aswid_bloodpotion_desc": "Drink and the hunger stops mattering for a while. Fills every stomach with blood essence, full or not, and knits the flesh back together.", + "rov_item_aswid_bloodpotion_name": "Blood Potion", + "rov_item_aswid_bloodpotionbase_desc": "Blood, berries and crypt light, waiting on a barrel.", + "rov_item_aswid_bloodpotionbase_name": "Blood Potion Mead Base", + "rov_item_aswid_claws_desc": "Grown in the dark, and darker for it. They do not come off.", + "rov_item_aswid_claws_name": "Claws of the Beast", + "rov_item_aswid_food_desc": "The life force of the conquered.", + "rov_item_aswid_food_name": "Aswid Food:", + "rov_item_aswid_spectralclaw_desc": "A claw of pure shadow, bound to your rage rather than your grip.", + "rov_item_aswid_spectralclaw_name": "Spectral Claw", + "rov_item_aswid_superiorbloodessence_desc": "The same blood, rendered twice. Darker, thicker, and worth five of the first pass.", + "rov_item_aswid_superiorbloodessence_name": "Superior Blood Essence", + "rov_item_aswid_superiorbloodpotion_desc": "The same mercy, twice as deep.", + "rov_item_aswid_superiorbloodpotion_name": "Superior Blood Potion", + "rov_item_aswid_superiorbloodpotionbase_desc": "The twice-rendered draught, still raw.", + "rov_item_aswid_superiorbloodpotionbase_name": "Superior Blood Potion Mead Base", + "rov_item_draugh_cursedbone_desc": "A bone that will not stay quiet. The dead sell them; the dead do not say why.", + "rov_item_draugh_cursedbone_name": "Cursed Bone", + "rov_item_draugh_greatercursedbone_desc": "The same bone, older, and louder. A pile fed one of these starts keeping officers.", + "rov_item_draugh_greatercursedbone_name": "Greater Cursed Bone", + "rov_item_draugh_humanmeat_desc": "A piece of somebody. The living gag on it; you do not.", + "rov_item_draugh_humanmeat_name": "Human Meat", + "rov_item_fenrir_claws_desc": "The wolf's hands, kept on in the man's shape. They do not come off.", + "rov_item_fenrir_claws_name": "Cursed Claws", + "rov_item_fenrir_greaterulvsblod_desc": "Older blood, and further down the line. A trough given one of these starts raising something worse than ulv.", + "rov_item_fenrir_greaterulvsblod_name": "Greater Ulvsblod", + "rov_item_fenrir_ulvsblod_desc": "Wolf blood, kept warm by something that should not be able to keep anything warm. The Fenring sell it and do not explain it.", + "rov_item_fenrir_ulvsblod_name": "Ulvsblod", + "rov_item_furling_copperdust_desc": "A sack of copper ground fine. A furnace cannot tell it from ore, and it will not go through a portal either.", + "rov_item_furling_copperdust_name": "Copper Dust", + "rov_item_furling_copperflax_desc": "Flax grown in copper-poisoned soil, and it took. Useless as cloth. Grind it and see.", + "rov_item_furling_copperflax_name": "Copper Flax", + "rov_item_furling_flintberry_desc": "Not a berry, whatever it looks like. Bury one and a flint-bearing bush comes up.", + "rov_item_furling_flintberry_name": "Flintberry", + "rov_item_furling_irondust_desc": "A sack of iron ground fine. A furnace cannot tell it from ore, and it will not go through a portal either.", + "rov_item_furling_irondust_name": "Iron Dust", + "rov_item_furling_ironflax_desc": "Flax grown in iron-poisoned soil, and it took. Useless as cloth. Grind it and see.", + "rov_item_furling_ironflax_name": "Iron Flax", + "rov_item_furling_stoneberry_desc": "Not a berry, whatever it looks like. Bury one and a stone-bearing bush comes up.", + "rov_item_furling_stoneberry_name": "Stoneberry", + "rov_item_furling_tindust_desc": "A sack of tin ground fine. A furnace cannot tell it from ore, and it will not go through a portal either.", + "rov_item_furling_tindust_name": "Tin Dust", + "rov_item_furling_tinflax_desc": "Flax grown in tin-poisoned soil, and it took. Useless as cloth. Grind it and see.", + "rov_item_furling_tinflax_name": "Tin Flax", + "rov_item_skadi_greaterfrostheart_desc": "Older cold than the mountain's. The cultists sell it and will not say where they dig.", + "rov_item_skadi_greaterfrostheart_name": "Greater Frost Heart", + "rov_item_skeleton_cursedskull_desc": "A skull that keeps counting. Set it down and the ground starts answering.", + "rov_item_skeleton_cursedskull_name": "Cursed Skull", + "rov_item_skeleton_greatercursedskull_desc": "Older, and it counts higher. A pile given one of these raises the rotten too.", + "rov_item_skeleton_greatercursedskull_name": "Greater Cursed Skull", + "rov_item_skeleton_soulstone_desc": "Something is still in there, and it is still angry. Bind it to a skull and it will stand watch as long as the bones hold.", + "rov_item_skeleton_soulstone_name": "Soul Stone", + "rov_item_sverm_claws_desc": "Grown, not forged. They do not come off.", + "rov_item_sverm_claws_name": "Chitin Claws", + "rov_item_trenta_fertilizer_desc": "Everything that was meat, a month later. Press it into the soil and whatever is rooted there stops waiting.", + "rov_item_trenta_fertilizer_name": "Fertilizer", + "rov_item_trenta_heartwoodseed_desc": "A seed fed on a whole barrel of rot. Plant it and go away for a while.", + "rov_item_trenta_heartwoodseed_name": "Heartwood Seed", + "rov_item_trenta_rotseed_desc": "A seed that died before it could sprout, and did not stop. The forest folk sell them; only the forest knows what grows from one.", + "rov_item_trenta_rotseed_name": "Rot Seed", + "rov_item_trol_giantslog_desc": "A massive tree log wielded as a weapon.", + "rov_item_trol_giantslog_name": "Giant's Log", + "rov_item_trolshammer_desc": "A hammer swung by something that never had to duck through a doorway. It builds everything the ordinary one builds, out of the same materials, and simply builds it bigger.", + "rov_item_trolshammer_name": "Trol's Hammer", + "rov_item_warvulture_desc": "A vulture's head, kept. Raise it and the bird comes back under you, and it will carry you as long as you care to stay up - though it only has so much haste in it before it settles into a glide.", + "rov_item_warvulture_name": "War Vulture", + "rov_piece_aswid_bloodrefinery_desc": "Flesh goes in, bone goes in, and what is left of both comes out red.", + "rov_piece_aswid_bloodrefinery_name": "Blood Refinery", + "rov_piece_cooktable_desc": "A slab of bone and slate, worn smooth. Something patient waits by the hearth.", + "rov_piece_cooktable_name": "Cook's Table", + "rov_piece_draugh_bodypile_desc": "Feed it and it answers. The dead here are yours, if you are dead enough to ask.", + "rov_piece_draugh_bodypile_name": "Cursed Body Pile", + "rov_piece_dvergar_contractbank_desc": "A ledger, a seal and a heap of coin. Sign here and someone else does the dying.", + "rov_piece_dvergar_contractbank_name": "Contract Bank", + "rov_piece_dvergar_runebarrel_desc": "Pour a brew in and the crew drinks. What it does to them is whatever it would have done to you - if they have the parts for it.", + "rov_piece_dvergar_runebarrel_name": "Rune Barrel", + "rov_piece_fenrir_packtrough_desc": "Fill it with meat and the pack comes. One at a time, and it remembers its dead.", + "rov_piece_fenrir_packtrough_name": "Pack Trough", + "rov_piece_furling_copperflaxsapling_desc": "Plant it and it grows more Copper Flax.", + "rov_piece_furling_copperflaxsapling_name": "Copper Flax", + "rov_piece_furling_flintberrybush_desc": "Yields flint, and keeps yielding it.", + "rov_piece_furling_flintberrybush_name": "Flintberry Bush", + "rov_piece_furling_ironflaxsapling_desc": "Plant it and it grows more Iron Flax.", + "rov_piece_furling_ironflaxsapling_name": "Iron Flax", + "rov_piece_furling_stoneberrybush_desc": "Yields stone, and keeps yielding it.", + "rov_piece_furling_stoneberrybush_name": "Stoneberry Bush", + "rov_piece_furling_tinflaxsapling_desc": "Plant it and it grows more Tin Flax.", + "rov_piece_furling_tinflaxsapling_name": "Tin Flax", + "rov_piece_racemenuward_desc": "Commune with your heritage. Offer a fallen boss's relic to claim its power.", + "rov_piece_racemenuward_name": "Race Menu Ward", + "rov_piece_skadi_crystalgolem_desc": "Cut at the stone and woken with a tear. It will not follow you, and it will not leave the stonecutter that shaped it.", + "rov_piece_skeleton_bonepile_desc": "Twenty fragments buy a place in the line. The one who fills it will keep standing up.", + "rov_piece_skeleton_bonepile_name": "Bound Bone Pile", + "rov_piece_skeleton_sentry_desc": "A skull on a soul stone. It will not walk, and it will not stop watching.", + "rov_piece_smithtable_desc": "A slab of bone and slate, dusted with ore. Something patient waits by the fires.", + "rov_piece_smithtable_name": "Smith's Table", + "rov_piece_sverm_broodmound_desc": "The colony begins here. Everything else grows out of it.", + "rov_piece_sverm_broodmound_name": "Brood Mound", + "rov_piece_sverm_hivemarket_desc": "Where the colony trades. It spends the tank of the nest it stands in.", + "rov_piece_sverm_hivemarket_name": "Hive Market", + "rov_piece_trenta_composter_desc": "What rots is not lost. It feeds.", + "rov_piece_trenta_composter_name": "Composter", + "rov_piece_trenta_elderroot_desc": "What the Elder left behind, still growing. Mends itself, and everything a player built close enough to it.", + "rov_piece_trenta_elderroot_name": "Root of the Elder", + "rov_piece_trenta_heartwoodgrove_desc": "A crate of rot with something growing out of it. Give it time.", + "rov_piece_trenta_heartwoodgrove_name": "Heartwood Grove", + "rov_piece_trenta_heartwoodsapling_name": "Heartwood Sapling", + "rov_piece_trol_wartotem_desc": "A head that still remembers how to shout. Coin goes in, a warband walks out.", + "rov_piece_trol_wartotem_name": "War Totem" +} diff --git a/JotunnModStub/Translations/Italian/items.json b/JotunnModStub/Translations/Italian/items.json new file mode 100644 index 0000000..40e5ddd --- /dev/null +++ b/JotunnModStub/Translations/Italian/items.json @@ -0,0 +1,131 @@ +{ + "rov_creature_bonecook_name": "Cuoco d'ossa", + "rov_creature_bonesmith_name": "Fabbro d'ossa", + "rov_creature_draugh_thrall_name": "Servo Draugr", + "rov_creature_draugh_thrallelite_name": "Servo Draugr d'élite", + "rov_creature_fenrir_pack_desc": "Risponde al sangue del lupo, non a te.", + "rov_creature_fenrir_packfenrir_desc": "Solo il sangue del lupo comanda questo.", + "rov_creature_fenrir_packfenrir_name": "Fenrir", + "rov_creature_fenrir_packulv_name": "Ulv", + "rov_creature_fenrir_packwolf_name": "Lupo del branco", + "rov_creature_skadi_crystalgolem_name": "Golem di cristallo", + "rov_creature_skeleton_sentry_name": "Sentinella vincolata", + "rov_creature_skeleton_thrallmelee_name": "Scheletro vincolato", + "rov_creature_skeleton_thrallrancid_name": "Resti rancidi vincolati", + "rov_creature_skeleton_thrallranged_name": "Arciere vincolato", + "rov_creature_sverm_blistertick_name": "Zecca vescicante", + "rov_creature_sverm_worker_name": "Operaio cercatore", + "rov_item_aswid_bloodcore_desc": "Un grumo di sangue rappreso che batte ancora, tenuto in vita da qualcosa che non è un cuore. I morti lo commerciano; solo i morti sanno come si fa.", + "rov_item_aswid_bloodcore_name": "Nucleo di sangue", + "rov_item_aswid_bloodessence_desc": "Sangue ridotto a ciò che è davvero. L'unico vero cibo che un Aswid riesce ancora a masticare, e la base di ogni pozione che valga la pena distillare.", + "rov_item_aswid_bloodessence_name": "Essenza di sangue", + "rov_item_aswid_bloodpotion_desc": "Bevi e la fame smette di contare per un po'. Riempie ogni stomaco di essenza di sangue, pieno o no, e ricuce la carne.", + "rov_item_aswid_bloodpotion_name": "Pozione di sangue", + "rov_item_aswid_bloodpotionbase_desc": "Sangue, bacche e luce di cripta, in attesa in un barile.", + "rov_item_aswid_bloodpotionbase_name": "Base per pozione di sangue", + "rov_item_aswid_claws_desc": "Cresciuti nel buio, e più scuri per questo. Non si staccano.", + "rov_item_aswid_claws_name": "Artigli della Bestia", + "rov_item_aswid_food_desc": "La forza vitale dei vinti.", + "rov_item_aswid_food_name": "Cibo Aswid:", + "rov_item_aswid_spectralclaw_desc": "Un artiglio di pura ombra, legato alla tua furia più che alla tua presa.", + "rov_item_aswid_spectralclaw_name": "Artiglio spettrale", + "rov_item_aswid_superiorbloodessence_desc": "Lo stesso sangue, ridotto due volte. Più scuro, più denso, e vale cinque volte il primo passaggio.", + "rov_item_aswid_superiorbloodessence_name": "Essenza di sangue superiore", + "rov_item_aswid_superiorbloodpotion_desc": "La stessa pietà, due volte più profonda.", + "rov_item_aswid_superiorbloodpotion_name": "Pozione di sangue superiore", + "rov_item_aswid_superiorbloodpotionbase_desc": "L'infuso ridotto due volte, ancora crudo.", + "rov_item_aswid_superiorbloodpotionbase_name": "Base per pozione di sangue superiore", + "rov_item_draugh_cursedbone_desc": "Un osso che non vuole stare zitto. I morti lo vendono; i morti non dicono perché.", + "rov_item_draugh_cursedbone_name": "Osso maledetto", + "rov_item_draugh_greatercursedbone_desc": "Lo stesso osso, più vecchio e più rumoroso. Un mucchio nutrito con uno di questi comincia a tenere ufficiali.", + "rov_item_draugh_greatercursedbone_name": "Osso maledetto superiore", + "rov_item_draugh_humanmeat_desc": "Un pezzo di qualcuno. Ai vivi viene il voltastomaco; a te no.", + "rov_item_draugh_humanmeat_name": "Carne umana", + "rov_item_fenrir_claws_desc": "Le mani del lupo, rimaste nella forma dell'uomo. Non si staccano.", + "rov_item_fenrir_claws_name": "Artigli maledetti", + "rov_item_fenrir_greaterulvsblod_desc": "Sangue più antico, più in basso nella discendenza. Una mangiatoia che ne riceve uno comincia a far nascere qualcosa di peggio di un ulv.", + "rov_item_fenrir_greaterulvsblod_name": "Ulvsblod superiore", + "rov_item_fenrir_ulvsblod_desc": "Sangue di lupo, tenuto caldo da qualcosa che non dovrebbe poter scaldare niente. I Fenring lo vendono e non lo spiegano.", + "rov_item_fenrir_ulvsblod_name": "Ulvsblod", + "rov_item_furling_copperdust_desc": "Un sacco di rame macinato fine. Una fornace non lo distingue dal minerale, e non passa nemmeno da un portale.", + "rov_item_furling_copperdust_name": "Polvere di rame", + "rov_item_furling_copperflax_desc": "Lino cresciuto in un terreno avvelenato dal rame, e ha attecchito. Inutile come stoffa. Macinalo e vedrai.", + "rov_item_furling_copperflax_name": "Lino di rame", + "rov_item_furling_flintberry_desc": "Non è una bacca, anche se ci somiglia. Seppelliscine una e spunta un cespuglio che dà selce.", + "rov_item_furling_flintberry_name": "Bacca di selce", + "rov_item_furling_irondust_desc": "Un sacco di ferro macinato fine. Una fornace non lo distingue dal minerale, e non passa nemmeno da un portale.", + "rov_item_furling_irondust_name": "Polvere di ferro", + "rov_item_furling_ironflax_desc": "Lino cresciuto in un terreno avvelenato dal ferro, e ha attecchito. Inutile come stoffa. Macinalo e vedrai.", + "rov_item_furling_ironflax_name": "Lino di ferro", + "rov_item_furling_stoneberry_desc": "Non è una bacca, anche se ci somiglia. Seppelliscine una e spunta un cespuglio che dà pietra.", + "rov_item_furling_stoneberry_name": "Bacca di pietra", + "rov_item_furling_tindust_desc": "Un sacco di stagno macinato fine. Una fornace non lo distingue dal minerale, e non passa nemmeno da un portale.", + "rov_item_furling_tindust_name": "Polvere di stagno", + "rov_item_furling_tinflax_desc": "Lino cresciuto in un terreno avvelenato dallo stagno, e ha attecchito. Inutile come stoffa. Macinalo e vedrai.", + "rov_item_furling_tinflax_name": "Lino di stagno", + "rov_item_skadi_greaterfrostheart_desc": "Un freddo più antico di quello della montagna. I cultisti lo vendono e non dicono dove scavano.", + "rov_item_skadi_greaterfrostheart_name": "Cuore di gelo superiore", + "rov_item_skeleton_cursedskull_desc": "Un teschio che continua a contare. Posalo e il terreno comincia a rispondere.", + "rov_item_skeleton_cursedskull_name": "Teschio maledetto", + "rov_item_skeleton_greatercursedskull_desc": "Più vecchio, e conta più in alto. Un mucchio che ne riceve uno fa risorgere anche i rancidi.", + "rov_item_skeleton_greatercursedskull_name": "Teschio maledetto superiore", + "rov_item_skeleton_soulstone_desc": "Là dentro c'è ancora qualcosa, ed è ancora arrabbiato. Legalo a un teschio e farà la guardia finché le ossa reggono.", + "rov_item_skeleton_soulstone_name": "Pietra dell'anima", + "rov_item_sverm_claws_desc": "Cresciuti, non forgiati. Non si staccano.", + "rov_item_sverm_claws_name": "Artigli di chitina", + "rov_item_trenta_fertilizer_desc": "Tutto ciò che era carne, un mese dopo. Premilo nel terreno e ciò che vi è radicato smette di aspettare.", + "rov_item_trenta_fertilizer_name": "Fertilizzante", + "rov_item_trenta_heartwoodseed_desc": "Un seme nutrito con un intero barile di marciume. Piantalo e vattene per un po'.", + "rov_item_trenta_heartwoodseed_name": "Seme di durame", + "rov_item_trenta_rotseed_desc": "Un seme morto prima di germogliare, che non si è fermato. Il popolo della foresta li vende; solo la foresta sa cosa ne cresce.", + "rov_item_trenta_rotseed_name": "Seme marcio", + "rov_item_trol_giantslog_desc": "Un enorme tronco d'albero brandito come arma.", + "rov_item_trol_giantslog_name": "Tronco del gigante", + "rov_item_trolshammer_desc": "Un martello brandito da qualcosa che non ha mai dovuto chinarsi sotto una porta. Costruisce tutto ciò che costruisce quello normale, con gli stessi materiali, e lo fa semplicemente più grande.", + "rov_item_trolshammer_name": "Martello del Trol", + "rov_item_warvulture_desc": "La testa di un avvoltoio, conservata. Sollevala e l'uccello torna sotto di te, e ti porterà finché vorrai restare in aria, anche se ha solo un po' di slancio prima di mettersi a planare.", + "rov_item_warvulture_name": "Avvoltoio da guerra", + "rov_piece_aswid_bloodrefinery_desc": "Entra carne, entra osso, e quel che resta di entrambi esce rosso.", + "rov_piece_aswid_bloodrefinery_name": "Raffineria di sangue", + "rov_piece_cooktable_desc": "Una lastra di osso e ardesia, consumata dall'uso. Qualcosa di paziente aspetta accanto al focolare.", + "rov_piece_cooktable_name": "Tavolo del cuoco", + "rov_piece_draugh_bodypile_desc": "Nutrilo e risponde. I morti qui sono tuoi, se sei abbastanza morto da chiederlo.", + "rov_piece_draugh_bodypile_name": "Mucchio di corpi maledetto", + "rov_piece_dvergar_contractbank_desc": "Un registro, un sigillo e un mucchio di monete. Firma qui e a morire ci pensa qualcun altro.", + "rov_piece_dvergar_contractbank_name": "Banca dei contratti", + "rov_piece_dvergar_runebarrel_desc": "Versaci una bevanda e la squadra beve. Quello che fa a loro è quello che avrebbe fatto a te, se hanno i pezzi giusti.", + "rov_piece_dvergar_runebarrel_name": "Barile runico", + "rov_piece_fenrir_packtrough_desc": "Riempila di carne e il branco arriva. Uno alla volta, e ricorda i suoi morti.", + "rov_piece_fenrir_packtrough_name": "Mangiatoia del branco", + "rov_piece_furling_copperflaxsapling_desc": "Piantalo e crescerà altro lino di rame.", + "rov_piece_furling_copperflaxsapling_name": "Lino di rame", + "rov_piece_furling_flintberrybush_desc": "Dà selce, e continua a darla.", + "rov_piece_furling_flintberrybush_name": "Cespuglio di bacche di selce", + "rov_piece_furling_ironflaxsapling_desc": "Piantalo e crescerà altro lino di ferro.", + "rov_piece_furling_ironflaxsapling_name": "Lino di ferro", + "rov_piece_furling_stoneberrybush_desc": "Dà pietra, e continua a darla.", + "rov_piece_furling_stoneberrybush_name": "Cespuglio di bacche di pietra", + "rov_piece_furling_tinflaxsapling_desc": "Piantalo e crescerà altro lino di stagno.", + "rov_piece_furling_tinflaxsapling_name": "Lino di stagno", + "rov_piece_racemenuward_desc": "Entra in comunione con la tua stirpe. Offri la reliquia di un boss caduto per reclamarne il potere.", + "rov_piece_racemenuward_name": "Sigillo della razza", + "rov_piece_skadi_crystalgolem_desc": "Tagliato dalla pietra e risvegliato con una lacrima. Non ti seguirà, e non lascerà lo scalpellino che l'ha plasmato.", + "rov_piece_skeleton_bonepile_desc": "Venti frammenti comprano un posto nella fila. Chi lo occupa continuerà a rialzarsi.", + "rov_piece_skeleton_bonepile_name": "Mucchio d'ossa vincolato", + "rov_piece_skeleton_sentry_desc": "Un teschio su una pietra dell'anima. Non camminerà, e non smetterà di guardare.", + "rov_piece_smithtable_desc": "Una lastra di osso e ardesia, spolverata di minerale. Qualcosa di paziente aspetta accanto ai fuochi.", + "rov_piece_smithtable_name": "Tavolo del fabbro", + "rov_piece_sverm_broodmound_desc": "La colonia comincia qui. Tutto il resto cresce da questo.", + "rov_piece_sverm_broodmound_name": "Cumulo della covata", + "rov_piece_sverm_hivemarket_desc": "Dove la colonia commercia. Spende la riserva del nido in cui si trova.", + "rov_piece_sverm_hivemarket_name": "Mercato dell'alveare", + "rov_piece_trenta_composter_desc": "Ciò che marcisce non è perduto. Nutre.", + "rov_piece_trenta_composter_name": "Compostiera", + "rov_piece_trenta_elderroot_desc": "Ciò che l'Antico si è lasciato dietro, ancora in crescita. Si ripara da sé, e ripara tutto ciò che un giocatore ha costruito abbastanza vicino.", + "rov_piece_trenta_elderroot_name": "Radice dell'Antico", + "rov_piece_trenta_heartwoodgrove_desc": "Una cassa di marciume con qualcosa che ci cresce dentro. Dagli tempo.", + "rov_piece_trenta_heartwoodgrove_name": "Boschetto di durame", + "rov_piece_trenta_heartwoodsapling_name": "Germoglio di durame", + "rov_piece_trol_wartotem_desc": "Una testa che ricorda ancora come si urla. Entrano monete, esce una banda da guerra.", + "rov_piece_trol_wartotem_name": "Totem di guerra" +} diff --git a/JotunnModStub/Trenta/TrentaComposter.cs b/JotunnModStub/Trenta/TrentaComposter.cs index 92ddd18..914ec5e 100644 --- a/JotunnModStub/Trenta/TrentaComposter.cs +++ b/JotunnModStub/Trenta/TrentaComposter.cs @@ -100,8 +100,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = TrentaConfig.RotSeedDisplayName; - shared.m_description = "A seed that died before it could sprout, and did not stop. " + - "The forest folk sell them; only the forest knows what grows from one."; + shared.m_description = "$rov_item_trenta_rotseed_desc"; shared.m_itemType = ItemDrop.ItemData.ItemType.Material; shared.m_weight = 0.5f; shared.m_maxStackSize = 20; @@ -125,8 +124,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = TrentaConfig.FertilizerDisplayName; - shared.m_description = "Everything that was meat, a month later. Press it into the soil and " + - "whatever is rooted there stops waiting."; + shared.m_description = "$rov_item_trenta_fertilizer_desc"; // Consumable, not Material, and this is the only reason: a Material never reaches // Humanoid.UseItem - vanilla refuses it before that - while a Consumable does, which is @@ -223,7 +221,7 @@ namespace RacesOfValheim PieceConfig config = new PieceConfig { Name = TrentaConfig.ComposterDisplayName, - Description = "What rots is not lost. It feeds.", + Description = "$rov_piece_trenta_composter_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Requirements = new[] diff --git a/JotunnModStub/Trenta/TrentaConfig.cs b/JotunnModStub/Trenta/TrentaConfig.cs index f395a6e..35fc25d 100644 --- a/JotunnModStub/Trenta/TrentaConfig.cs +++ b/JotunnModStub/Trenta/TrentaConfig.cs @@ -405,13 +405,13 @@ namespace RacesOfValheim // The chain: a Rot Seed bought from the Greydwarf faction bench gates the Composter, the // Composter rots raw flesh into Fertilizer, and Fertilizer grows any plant on the spot. public const string ComposterPieceName = "TrentaComposter"; - public const string ComposterDisplayName = "Composter"; + public const string ComposterDisplayName = "$rov_piece_trenta_composter_name"; public const string FertilizerName = "Fertilizer"; - public const string FertilizerDisplayName = "Fertilizer"; + public const string FertilizerDisplayName = "$rov_item_trenta_fertilizer_name"; public const string RotSeedName = "RotSeed"; - public const string RotSeedDisplayName = "Rot Seed"; + public const string RotSeedDisplayName = "$rov_item_trenta_rotseed_name"; // Same band as the Aswid's Blood Core, which does the same job for the same reason. public const int RotSeedPrice = 500; @@ -452,7 +452,7 @@ namespace RacesOfValheim // point would need if it had one: this is a race identity piece, not a purchase from // someone else's bench (see the War Totem's own note on the same choice). public const string ElderRootPieceName = "TrentaElderRoot"; - public const string ElderRootDisplayName = "Root of the Elder"; + public const string ElderRootDisplayName = "$rov_piece_trenta_elderroot_name"; public const int ElderRootUnlockState = 3; // The Elder dead @@ -507,11 +507,11 @@ namespace RacesOfValheim // Plant a seed, wait, and the tree that comes up fertilises what surrounds it, stings what // approaches it, and fills a chest with honey. Three independent functions on one piece. public const string GroveSeedName = "HeartwoodSeed"; - public const string GroveSeedDisplayName = "Heartwood Seed"; + public const string GroveSeedDisplayName = "$rov_item_trenta_heartwoodseed_name"; public const string GroveSaplingPieceName = "TrentaHeartwoodSapling"; - public const string GroveSaplingDisplayName = "Heartwood Sapling"; + public const string GroveSaplingDisplayName = "$rov_piece_trenta_heartwoodsapling_name"; public const string GrovePieceName = "TrentaHeartwoodGrove"; - public const string GroveDisplayName = "Heartwood Grove"; + public const string GroveDisplayName = "$rov_piece_trenta_heartwoodgrove_name"; // A grove costs exactly one full Composter batch. That is the whole balance argument. public const int GroveSeedFertilizerCost = ComposterYield; diff --git a/JotunnModStub/Trenta/TrentaElderRoot.cs b/JotunnModStub/Trenta/TrentaElderRoot.cs index ccbcc54..d36d67c 100644 --- a/JotunnModStub/Trenta/TrentaElderRoot.cs +++ b/JotunnModStub/Trenta/TrentaElderRoot.cs @@ -93,8 +93,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = TrentaConfig.ElderRootDisplayName, - Description = "What the Elder left behind, still growing. Mends itself, and " + - "everything a player built close enough to it.", + Description = "$rov_piece_trenta_elderroot_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Icon = icon, diff --git a/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs b/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs index aeb43c1..a8ca08c 100644 --- a/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs +++ b/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs @@ -58,7 +58,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = TrentaConfig.GroveSeedDisplayName; - shared.m_description = "A seed fed on a whole barrel of rot. Plant it and go away for a while."; + shared.m_description = "$rov_item_trenta_heartwoodseed_desc"; shared.m_itemType = ItemDrop.ItemData.ItemType.Material; shared.m_weight = 1f; shared.m_maxStackSize = 10; @@ -129,7 +129,7 @@ namespace RacesOfValheim PieceConfig config = new PieceConfig { Name = TrentaConfig.GroveDisplayName, - Description = "A crate of rot with something growing out of it. Give it time.", + Description = "$rov_piece_trenta_heartwoodgrove_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Misc, Requirements = new[] diff --git a/JotunnModStub/Trol/TrolRace.cs b/JotunnModStub/Trol/TrolRace.cs index 3016bca..591ca5b 100644 --- a/JotunnModStub/Trol/TrolRace.cs +++ b/JotunnModStub/Trol/TrolRace.cs @@ -77,8 +77,8 @@ namespace RacesOfValheim if (logPrefab != null) { Jotunn.Configs.ItemConfig config = new Jotunn.Configs.ItemConfig(); - config.Name = "Giant's Log"; - config.Description = "A massive tree log wielded as a weapon."; + config.Name = "$rov_item_trol_giantslog_name"; + config.Description = "$rov_item_trol_giantslog_desc"; CustomItem customWep = new CustomItem("TrolWeapon_" + logName, "MaceIron", config); if (customWep != null && customWep.ItemPrefab != null) diff --git a/JotunnModStub/Trol/TrolTotem.cs b/JotunnModStub/Trol/TrolTotem.cs index b4beb46..512437b 100644 --- a/JotunnModStub/Trol/TrolTotem.cs +++ b/JotunnModStub/Trol/TrolTotem.cs @@ -26,7 +26,7 @@ namespace RacesOfValheim public static class TrolTotem { public const string PieceName = "TrolWarTotem"; - public const string PieceDisplayName = "War Totem"; + public const string PieceDisplayName = "$rov_piece_trol_wartotem_name"; public const string RaceId = "Trol"; /// Core wood. The item is RoundLog - another display name that does not predict the id. @@ -313,7 +313,7 @@ namespace RacesOfValheim PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, new PieceConfig { Name = PieceDisplayName, - Description = "A head that still remembers how to shout. Coin goes in, a warband walks out.", + Description = "$rov_piece_trol_wartotem_desc", PieceTable = PieceTables.Hammer, Category = PieceCategories.Crafting, Icon = BorrowIcon(TrollHead), diff --git a/JotunnModStub/TrolsHammer/TrolsHammerItem.cs b/JotunnModStub/TrolsHammer/TrolsHammerItem.cs index 5fa4076..b008b59 100644 --- a/JotunnModStub/TrolsHammer/TrolsHammerItem.cs +++ b/JotunnModStub/TrolsHammer/TrolsHammerItem.cs @@ -24,7 +24,7 @@ namespace RacesOfValheim public static class TrolsHammerItem { public const string PrefabName = "TrolsHammer"; - public const string DisplayName = "Trol's Hammer"; + public const string DisplayName = "$rov_item_trolshammer_name"; private const string SourcePrefab = "Hammer"; private const string Label = "TrolsHammer"; @@ -51,9 +51,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = DisplayName; - shared.m_description = "A hammer swung by something that never had to duck through a " + - "doorway. It builds everything the ordinary one builds, out of the " + - "same materials, and simply builds it bigger."; + shared.m_description = "$rov_item_trolshammer_desc"; if (shared.m_buildPieces == null) { diff --git a/JotunnModStub/WarVulture/WarVultureItem.cs b/JotunnModStub/WarVulture/WarVultureItem.cs index e3443d9..7b735fa 100644 --- a/JotunnModStub/WarVulture/WarVultureItem.cs +++ b/JotunnModStub/WarVulture/WarVultureItem.cs @@ -32,7 +32,7 @@ namespace RacesOfValheim public static class WarVultureItem { public const string PrefabName = "WarVulture"; - public const string DisplayName = "War Vulture"; + public const string DisplayName = "$rov_item_warvulture_name"; private const string SourcePrefab = "StaffSkeleton"; private const string TrophyPrefab = "TrophyVolture"; @@ -62,9 +62,7 @@ namespace RacesOfValheim ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; shared.m_name = DisplayName; - shared.m_description = "A vulture's head, kept. Raise it and the bird comes back under you, " + - "and it will carry you as long as you care to stay up - though it only " + - "has so much haste in it before it settles into a glide."; + shared.m_description = "$rov_item_warvulture_desc"; shared.m_useDurability = false; // ItemType is left exactly as the vanilla staff has it: it decides the equip slot and From b0d18b0654976ddb1fe5d170e06c07658231d49c Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 26 Sep 2026 20:30:03 +0200 Subject: [PATCH 061/273] feat(text): on-screen messages come from translation files Every message the mod puts in the middle or corner of the screen now reads its text through ModText.Get, and messages.json holds 191 texts in English and Italian. Values computed in code become $1, $2 in the text, so a translator can put them wherever the sentence needs them. Branching messages get one key per branch. A few messages travel through a field before they are shown: thralls' refusals and the building limits now hold a token or key there. Boss and form names inside messages use tokens too, the bosses the game's own, so "The Elder" arrives translated. ModText.Get now localizes each argument before inserting it. A token argument left for a later pass ran into the text after it: "$1's power" became the unknown token "enemy_eikthyr's". Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Aswid/AswidBloodRefinery.cs | 2 +- JotunnModStub/Aswid/AswidPatches.cs | 2 +- JotunnModStub/Aswid/AswidRace.cs | 18 +- JotunnModStub/Aswid/AswidThrall.cs | 8 +- JotunnModStub/Aswid/BloodRefineryBehaviour.cs | 2 +- JotunnModStub/BossProgressionManager.cs | 20 ++ JotunnModStub/Butler/BoneServant.cs | 8 +- JotunnModStub/Butler/ServantTableBehaviour.cs | 8 +- JotunnModStub/Draugh/DraughFoodPatches.cs | 4 +- .../Draugh/DraughProgressionPatches.cs | 6 +- JotunnModStub/Draugh/DraughRace.cs | 2 +- JotunnModStub/Draugh/DraughSpawner.cs | 4 +- .../Draugh/DraughSpawnerBehaviour.cs | 12 +- JotunnModStub/Dvergar/DvergarAbilities.cs | 8 +- JotunnModStub/Dvergar/DvergarBanco.cs | 6 +- .../Dvergar/DvergarBancoBehaviour.cs | 14 +- JotunnModStub/Dvergar/DvergarBotte.cs | 2 +- .../Dvergar/DvergarBotteBehaviour.cs | 14 +- JotunnModStub/Dvergar/DvergarPatches.cs | 2 +- JotunnModStub/Fenrir/FenrirBehaviors.cs | 2 +- JotunnModStub/Fenrir/FenrirMangiatoia.cs | 2 +- .../Fenrir/FenrirMangiatoiaBehaviour.cs | 12 +- JotunnModStub/Fenrir/FenrirRace.cs | 19 +- JotunnModStub/Fenrir/FenrirStatusEffects.cs | 2 +- JotunnModStub/ModText.cs | 8 +- JotunnModStub/PieceDensityLimit.cs | 3 +- JotunnModStub/RaceCaveBuilding.cs | 2 +- JotunnModStub/RaceClaws.cs | 2 +- JotunnModStub/RaceMenuWard.cs | 8 +- JotunnModStub/RacesOfValheim.cs | 36 ++-- JotunnModStub/RaisedThrall.cs | 16 +- JotunnModStub/Skadi/DrakeFormBehavior.cs | 2 +- JotunnModStub/Skadi/SkadiGolem.cs | 10 +- JotunnModStub/Skadi/SkadiGolemBehaviour.cs | 2 +- JotunnModStub/Skadi/SkadiRace.cs | 16 +- JotunnModStub/Skeleton/SkeletonBonePile.cs | 4 +- .../Skeleton/SkeletonBonePileBehaviour.cs | 18 +- JotunnModStub/Skeleton/SkeletonPatches.cs | 6 +- JotunnModStub/Sverm/SvermBlisterTick.cs | 2 +- JotunnModStub/Sverm/SvermBrood.cs | 2 +- JotunnModStub/Sverm/SvermClawSlot.cs | 2 +- JotunnModStub/Sverm/SvermFood.cs | 2 +- JotunnModStub/Sverm/SvermHive.cs | 8 +- JotunnModStub/Sverm/SvermHiveGoods.cs | 2 +- JotunnModStub/Sverm/SvermHiveStore.cs | 18 +- JotunnModStub/Sverm/SvermMedicine.cs | 2 +- JotunnModStub/Sverm/SvermPatches.cs | 2 +- JotunnModStub/Sverm/SvermRavagerForm.cs | 8 +- .../Translations/English/messages.json | 193 ++++++++++++++++++ .../Translations/Italian/messages.json | 193 ++++++++++++++++++ JotunnModStub/Trenta/ComposterBehaviour.cs | 4 +- JotunnModStub/Trenta/GroveBehaviour.cs | 4 +- JotunnModStub/Trenta/TrentaComposter.cs | 8 +- JotunnModStub/Trenta/TrentaElderRoot.cs | 4 +- JotunnModStub/Trenta/TrentaFoodPatches.cs | 2 +- JotunnModStub/Trenta/TrentaHeartwoodGrove.cs | 2 +- JotunnModStub/Trenta/TrentaMuspell.cs | 4 +- JotunnModStub/Trol/TrolLogWeapon.cs | 6 +- JotunnModStub/Trol/TrolTotem.cs | 4 +- JotunnModStub/Trol/TrolTotemBehaviour.cs | 14 +- JotunnModStub/WarVulture/WarVultureMount.cs | 8 +- 61 files changed, 606 insertions(+), 200 deletions(-) create mode 100644 JotunnModStub/Translations/English/messages.json create mode 100644 JotunnModStub/Translations/Italian/messages.json diff --git a/JotunnModStub/Aswid/AswidBloodRefinery.cs b/JotunnModStub/Aswid/AswidBloodRefinery.cs index 0e8d711..78a9867 100644 --- a/JotunnModStub/Aswid/AswidBloodRefinery.cs +++ b/JotunnModStub/Aswid/AswidBloodRefinery.cs @@ -567,7 +567,7 @@ namespace RacesOfValheim if (!AswidBloodRefinery.IsEssence(item)) return true; if (AswidRace.IsAswid()) return true; - player.Message(MessageHud.MessageType.Center, "Living blood curdles in a living throat."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_living_blood_curdles_living_throat")); return false; } } diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 0bc1753..9361df9 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -529,7 +529,7 @@ namespace RacesOfValheim { AswidRace.DevourEnabled = !AswidRace.DevourEnabled; AswidRace.AuraEnabled = AswidRace.DevourEnabled; - string msg = AswidRace.DevourEnabled ? "Vampiric Aura: ENABLED" : "Vampiric Aura: DISABLED"; + string msg = ModText.Get(AswidRace.DevourEnabled ? "rov_msg_aswid_aura_enabled" : "rov_msg_aswid_aura_disabled"); __instance.Message(MessageHud.MessageType.Center, msg); } diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 2ca35de..edfbdc5 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -338,11 +338,11 @@ namespace RacesOfValheim { if (isNight) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "what a horrible night to have a curse"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_what_horrible_night_have_curse")); } else { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The morning sun has vanquished the horrible night"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_morning_sun_has_vanquished_horrible")); } } wasNight = isNight; @@ -431,7 +431,7 @@ namespace RacesOfValheim if (IsTransformed && !isTransformingSequence && activeRules != null && activeRules.NeedsNight && EnvMan.instance != null && EnvMan.IsDay()) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The morning sun drives the bat back into your body"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_morning_sun_drives_bat_back")); StartCoroutine(RevertToHumanRoutine()); } } @@ -534,7 +534,7 @@ namespace RacesOfValheim // sunrise must always be able to turn back. if (rules.NeedsNight && (EnvMan.instance == null || !EnvMan.IsNight())) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The sun burns. You can only take bat form at night."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_sun_burns_can_only_take")); return; } @@ -844,7 +844,7 @@ namespace RacesOfValheim c.SetTamed(true); HarmonyLib.Traverse.Create(tameable).Method("Tame").GetValue(); // attempt to call Tame for VFX if it exists tameable.Command(Player.m_localPlayer); - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Tamed!"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_tamed")); } } } @@ -863,7 +863,7 @@ namespace RacesOfValheim if (Time.time - lastEclipseTime < cooldown) { int remaining = (int)(cooldown - (Time.time - lastEclipseTime)); - Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"Eclipse is on cooldown. Remaining: {remaining}s"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_eclipse_cooldown_remaining_s", remaining)); return; } @@ -915,7 +915,7 @@ namespace RacesOfValheim } // Lock player for the duration of the cast (approx 2 seconds) - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "An Eclipse descends..."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_eclipse_descends")); float castTimer = 0f; while(castTimer < AswidConfig.EclipseCastTime.Value) @@ -967,7 +967,7 @@ namespace RacesOfValheim if (Player.m_localPlayer != null) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The Eclipse has ended."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_eclipse_has_ended")); } } @@ -1160,7 +1160,7 @@ namespace RacesOfValheim if (successfullyEaten) { // Show the Vae Victis message in the center of the screen - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Vae Victis"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_vae_victis")); Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "$msg_ate " + addedItem.m_shared.m_name); // Vae Victis XP logic - similar to Dead Raiser diff --git a/JotunnModStub/Aswid/AswidThrall.cs b/JotunnModStub/Aswid/AswidThrall.cs index 35d1562..638ce4e 100644 --- a/JotunnModStub/Aswid/AswidThrall.cs +++ b/JotunnModStub/Aswid/AswidThrall.cs @@ -81,12 +81,12 @@ namespace RacesOfValheim if (m_ai.GetFollowTarget() == user.gameObject) { m_ai.SetFollowTarget(null); - user.Message(MessageHud.MessageType.Center, $"{m_character.m_name} is staying."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_staying", m_character.m_name)); } else { m_ai.SetFollowTarget(user.gameObject); - user.Message(MessageHud.MessageType.Center, $"{m_character.m_name} is following."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_following", m_character.m_name)); } } return true; @@ -98,7 +98,7 @@ namespace RacesOfValheim float cooldown = AswidRace.GetEnslaveCooldown(); if (cooldown > 0) { - user.Message(MessageHud.MessageType.Center, $"Dominate on cooldown ({Mathf.CeilToInt(cooldown / 60f)}m {Mathf.CeilToInt(cooldown % 60f)}s)"); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_dominate_cooldown_m_s", Mathf.CeilToInt(cooldown / 60f), Mathf.CeilToInt(cooldown % 60f))); return false; } @@ -123,7 +123,7 @@ namespace RacesOfValheim GameObject vfx = ZNetScene.instance.GetPrefab("vfx_corpse_destruction_medium"); if (vfx) Instantiate(vfx, m_character.transform.position, Quaternion.identity); - user.Message(MessageHud.MessageType.Center, $"{m_character.m_name} dominated!"); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_aswid_dominated", m_character.m_name)); return true; } diff --git a/JotunnModStub/Aswid/BloodRefineryBehaviour.cs b/JotunnModStub/Aswid/BloodRefineryBehaviour.cs index d06b47b..ada6820 100644 --- a/JotunnModStub/Aswid/BloodRefineryBehaviour.cs +++ b/JotunnModStub/Aswid/BloodRefineryBehaviour.cs @@ -98,7 +98,7 @@ namespace RacesOfValheim if (item == null) item = FindUsable(inventory, isMeat); if (item == null) { - user.Message(MessageHud.MessageType.Center, isMeat ? "No raw flesh to render." : "No bone to grind."); + user.Message(MessageHud.MessageType.Center, (isMeat ? ModText.Get("rov_msg_aswid_no_raw_flesh_render") : ModText.Get("rov_msg_aswid_no_bone_grind"))); return false; } diff --git a/JotunnModStub/BossProgressionManager.cs b/JotunnModStub/BossProgressionManager.cs index 27e492e..cc7f2ad 100644 --- a/JotunnModStub/BossProgressionManager.cs +++ b/JotunnModStub/BossProgressionManager.cs @@ -39,6 +39,26 @@ namespace RacesOfValheim { "FaderDrop", 8 } // Fader - Fader relic }; + /// + /// The boss's name as the game's own localization token, for text shown to players: + /// Valheim translates it wherever it is localized, so "The Elder" arrives in every language. + /// GetBossNameForState stays English, for logs and anything not localized. + /// + public static string GetBossTokenForState(int state) + { + switch (state) + { + case 2: return "$enemy_eikthyr"; + case 3: return "$enemy_gdking"; + case 4: return "$enemy_bonemass"; + case 5: return "$enemy_dragon"; + case 6: return "$enemy_goblinking"; + case 7: return "$enemy_seekerqueen"; + case 8: return "$enemy_fader"; + default: return GetBossNameForState(state); + } + } + public static string GetBossNameForState(int state) { switch (state) diff --git a/JotunnModStub/Butler/BoneServant.cs b/JotunnModStub/Butler/BoneServant.cs index 8c7a0a3..6126d1d 100644 --- a/JotunnModStub/Butler/BoneServant.cs +++ b/JotunnModStub/Butler/BoneServant.cs @@ -94,7 +94,7 @@ namespace RacesOfValheim "Coal"); PieceDensityLimit.Register(SmithTableName, TableSpacing, 1, - "Another smith's table stands within forty paces. One smith to a yard."); + "rov_msg_build_limit_smithtable"); // Two races, and it is the wider of the two locks: the Skeleton raises the dead to work // for it, and Skadi's hold is a forge under ice. @@ -105,7 +105,7 @@ namespace RacesOfValheim if (player != null) { player.Message(MessageHud.MessageType.Center, - "The bones do not answer to your blood."); + ModText.Get("rov_msg_butler_bones_do_not_answer_blood")); } return false; }); @@ -118,7 +118,7 @@ namespace RacesOfValheim "CookedMeat"); PieceDensityLimit.Register(CookTableName, TableSpacing, 1, - "Another cook's table stands within forty paces. One cook to a yard."); + "rov_msg_build_limit_cooktable"); // Skadi alone. A hearth kept by something dead is hers, not the Skeleton's. PieceDensityLimit.RegisterGate(CookTableName, (player, position) => @@ -128,7 +128,7 @@ namespace RacesOfValheim if (player != null) { player.Message(MessageHud.MessageType.Center, - "Only Skadi's hearth is kept by the dead."); + ModText.Get("rov_msg_butler_only_skadi_s_hearth_kept")); } return false; }); diff --git a/JotunnModStub/Butler/ServantTableBehaviour.cs b/JotunnModStub/Butler/ServantTableBehaviour.cs index 6aab038..bac4a73 100644 --- a/JotunnModStub/Butler/ServantTableBehaviour.cs +++ b/JotunnModStub/Butler/ServantTableBehaviour.cs @@ -70,7 +70,7 @@ namespace RacesOfValheim if (Servant() != null) { - player.Message(MessageHud.MessageType.Center, "It is already at work."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_butler_already_at_work")); return false; } @@ -78,7 +78,7 @@ namespace RacesOfValheim if (wait > 0f) { player.Message(MessageHud.MessageType.Center, - $"The bones are not ready. {Mathf.CeilToInt(wait)}s."); + ModText.Get("rov_msg_butler_bones_are_not_ready_s", Mathf.CeilToInt(wait))); return false; } @@ -94,7 +94,7 @@ namespace RacesOfValheim if (prefab == null) { Jotunn.Logger.LogWarning($"[Butler] No '{m_servantPrefab}' in ZNetScene; nothing was raised."); - player.Message(MessageHud.MessageType.Center, "Nothing answers."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_butler_nothing_answers")); return false; } @@ -109,7 +109,7 @@ namespace RacesOfValheim if (ZNet.instance != null) m_nview.GetZDO().Set(KeyLastRaise, ZNet.instance.GetTime().Ticks); - player.Message(MessageHud.MessageType.Center, "The servant rises."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_butler_servant_rises")); return true; } diff --git a/JotunnModStub/Draugh/DraughFoodPatches.cs b/JotunnModStub/Draugh/DraughFoodPatches.cs index 847a615..f6d7fe7 100644 --- a/JotunnModStub/Draugh/DraughFoodPatches.cs +++ b/JotunnModStub/Draugh/DraughFoodPatches.cs @@ -42,7 +42,7 @@ namespace RacesOfValheim { if (!DraughRace.IsDraugh()) { - player.Message(MessageHud.MessageType.Center, "This rotting flesh is fatal to the living."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_this_rotting_flesh_fatal_living")); return false; // Block consumption } // If it IS a Draugh, let them consume it via native mechanics @@ -101,7 +101,7 @@ namespace RacesOfValheim bool isFood = item.m_shared.m_food > 0 || item.m_shared.m_foodStamina > 0 || item.m_shared.m_foodEitr > 0; if (isFood) { - player.Message(MessageHud.MessageType.Center, "Draugr consume only raw flesh, eyes, entrails or blood."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_draugr_consume_only_raw_flesh")); return false; // Block it } } diff --git a/JotunnModStub/Draugh/DraughProgressionPatches.cs b/JotunnModStub/Draugh/DraughProgressionPatches.cs index eaa8357..26743f5 100644 --- a/JotunnModStub/Draugh/DraughProgressionPatches.cs +++ b/JotunnModStub/Draugh/DraughProgressionPatches.cs @@ -153,7 +153,7 @@ namespace RacesOfValheim } } - Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "The northern wind blows"); + Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, ModText.Get("rov_msg_draugh_northern_wind_blows")); } } } @@ -312,7 +312,7 @@ namespace RacesOfValheim if (prefab != null) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Swarm of Terror!"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_swarm_terror")); for (int i = 0; i < DraughConfig.SwarmSpawnCount.Value; i++) { @@ -356,7 +356,7 @@ namespace RacesOfValheim float healAmount = Player.m_localPlayer.GetMaxHealth() * DraughConfig.StealBreathHealPercent.Value; Player.m_localPlayer.Heal(healAmount); - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Steal Their Breath! Death is denied."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_steal_their_breath_death_denied")); // Restore visuals immediately if (Player.m_localPlayer.GetComponent() != null) diff --git a/JotunnModStub/Draugh/DraughRace.cs b/JotunnModStub/Draugh/DraughRace.cs index 9362f5c..f654eac 100644 --- a/JotunnModStub/Draugh/DraughRace.cs +++ b/JotunnModStub/Draugh/DraughRace.cs @@ -133,7 +133,7 @@ namespace RacesOfValheim public System.Collections.IEnumerator UndyingWillRoutine(Player p) { - p.Message(MessageHud.MessageType.Center, "Zombie Ritual Activated! Your borrowed time is fading..."); + p.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_zombie_ritual_activated_borrowed_time")); // Trigger a re-evaluation of visuals to apply the ghost effect if (p.GetComponent() != null) diff --git a/JotunnModStub/Draugh/DraughSpawner.cs b/JotunnModStub/Draugh/DraughSpawner.cs index 9e00fd5..a2604b2 100644 --- a/JotunnModStub/Draugh/DraughSpawner.cs +++ b/JotunnModStub/Draugh/DraughSpawner.cs @@ -129,7 +129,7 @@ namespace RacesOfValheim PieceDensityLimit.Register(PieceName, PieceDensityLimit.RadiusForArea(DensityAreaKm2), MaxPilesInRange, - "The ground here already carries {0} of these. Find another country."); + "rov_msg_build_limit_draugh_bodypile"); } // ---------------------------------------------------------------- items @@ -201,7 +201,7 @@ namespace RacesOfValheim thrall.m_maxFollowers = maxFollowers; thrall.m_witherSeconds = OrphanWitherSeconds; thrall.m_homeCheckRange = HomeCheckRange; - thrall.m_refusalMessage = "The dead do not take orders from the living."; + thrall.m_refusalMessage = "$rov_msg_thrall_refusal_draugh"; PrefabManager.Instance.AddPrefab(prefab); } diff --git a/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs b/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs index faf40ee..39b1dd7 100644 --- a/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs +++ b/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs @@ -82,7 +82,7 @@ namespace RacesOfValheim if (item == null) item = FindAnyInput(inventory); if (item == null) { - user.Message(MessageHud.MessageType.Center, "It wants flesh, or the head of one of its own."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_wants_flesh_or_head_one")); return false; } @@ -93,7 +93,7 @@ namespace RacesOfValheim if (prefabName == DraughSpawner.TrophyDraugrElite && !IsUpgraded()) { - user.Message(MessageHud.MessageType.Center, "This pile keeps no officers yet."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_this_pile_keeps_no_officers")); return false; } @@ -162,19 +162,19 @@ namespace RacesOfValheim { if (IsUpgraded()) { - user.Message(MessageHud.MessageType.Center, "It has already had one."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_has_already_had_one")); return false; } if (BossProgressionManager.GetCurrentProgressionState() < DraughSpawner.UpgradeProgressionState) { - user.Message(MessageHud.MessageType.Center, "The bone will not wake. Something older has to fall first."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_bone_will_not_wake_something")); return false; } inventory.RemoveItem(item, 1); m_nview.InvokeRPC("RoV_DraughUpgrade"); - user.Message(MessageHud.MessageType.Center, "The pile stirs. It will keep officers now."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_draugh_pile_stirs_will_keep_officers")); return true; } @@ -294,7 +294,7 @@ namespace RacesOfValheim if (bound.Count > 0 && Player.m_localPlayer != null) { Player.m_localPlayer.Message(MessageHud.MessageType.Center, - $"The pile is broken. {bound.Count} will not outlast it by more than a minute."); + ModText.Get("rov_msg_draugh_pile_broken_will_not_outlast", bound.Count)); } SetFlesh(0f); diff --git a/JotunnModStub/Dvergar/DvergarAbilities.cs b/JotunnModStub/Dvergar/DvergarAbilities.cs index 11cc807..63daff3 100644 --- a/JotunnModStub/Dvergar/DvergarAbilities.cs +++ b/JotunnModStub/Dvergar/DvergarAbilities.cs @@ -45,7 +45,7 @@ namespace RacesOfValheim if (player.GetEitr() < DvergarConfig.RunicPingEitrCost) { - player.Message(MessageHud.MessageType.Center, "Not enough eitr"); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_not_enough_eitr")); return; } @@ -55,7 +55,7 @@ namespace RacesOfValheim int marked = MarkSurroundings(player); player.Message(MessageHud.MessageType.Center, - marked > 0 ? $"Runic Ping: {marked} echoes answer" : "Runic Ping: the stone is silent"); + (marked > 0 ? ModText.Get("rov_msg_dvergar_runic_ping_echoes_answer", marked) : ModText.Get("rov_msg_dvergar_runic_ping_stone_silent"))); } /// @@ -173,7 +173,7 @@ namespace RacesOfValheim if (player.GetEitr() < DvergarConfig.RunicOverchargeEitrCost) { - player.Message(MessageHud.MessageType.Center, "Not enough eitr"); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_not_enough_eitr")); return; } @@ -186,7 +186,7 @@ namespace RacesOfValheim // The charge is held, not permanent: it lapses if no favoured blow lands in time. if (se != null) se.m_ttl = DvergarConfig.RunicOverchargeWindow; - player.Message(MessageHud.MessageType.Center, "Runic Overcharge: your next blow is loaded"); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_runic_overcharge_next_blow_loaded")); } /// diff --git a/JotunnModStub/Dvergar/DvergarBanco.cs b/JotunnModStub/Dvergar/DvergarBanco.cs index b18e968..98559ee 100644 --- a/JotunnModStub/Dvergar/DvergarBanco.cs +++ b/JotunnModStub/Dvergar/DvergarBanco.cs @@ -195,7 +195,7 @@ namespace RacesOfValheim PieceDensityLimit.Register(PieceName, PieceDensityLimit.RadiusForArea(DensityAreaKm2), MaxBanksInRange, - "There is already {0} contract bank within a day's walk. One ledger per valley."); + "rov_msg_build_limit_dvergar_contractbank"); } // ---------------------------------------------------------------- the hired @@ -233,7 +233,7 @@ namespace RacesOfValheim thrall.m_maxFollowers = MaxFollowers; thrall.m_witherSeconds = WitherSeconds; thrall.m_homeCheckRange = HomeCheckRange; - thrall.m_refusalMessage = "Your name is not on the contract."; + thrall.m_refusalMessage = "$rov_msg_thrall_refusal_dvergar"; // Ten seconds unhurt, then two percent a second - the sentry's regeneration, shared with // the Trol's troops and the Fenrir's pack. A dead mercenary still stays dead. @@ -412,7 +412,7 @@ namespace RacesOfValheim if (Utils.GetPrefabName(__0.gameObject) != DvergarBanco.PieceName) return true; if (DvergarRace.IsDvergar()) return true; - __instance.Message(MessageHud.MessageType.Center, "The contract is in runic. You do not sign it."); + __instance.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_contract_runic_do_not_sign")); return false; } } diff --git a/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs b/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs index a0646a7..cb381e0 100644 --- a/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs +++ b/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs @@ -66,7 +66,7 @@ namespace RacesOfValheim if (!DvergarRace.IsDvergar()) { - player.Message(MessageHud.MessageType.Center, "The ledger is not written for you."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_ledger_not_written")); // With an item in hand, false makes Humanoid.UseItem cover this message with its // generic "$msg_cantuseon"; true tells it the use was handled here. return item != null; @@ -93,19 +93,19 @@ namespace RacesOfValheim { if (IsUpgraded()) { - player.Message(MessageHud.MessageType.Center, "It has already had one."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_has_already_had_one")); return true; } if (BossProgressionManager.GetCurrentProgressionState() < DvergarBanco.UpgradeProgressionState) { - player.Message(MessageHud.MessageType.Center, "Not while she still sits under the mist."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_not_while_she_still_sits")); return true; } player.GetInventory().RemoveItem(item, 1); m_nview.InvokeRPC("RoV_DvergarUpgrade"); - player.Message(MessageHud.MessageType.Center, "The ledger is rewritten. Better names sign it now."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_ledger_rewritten_better_names_sign")); return true; } @@ -119,7 +119,7 @@ namespace RacesOfValheim Trader trader = GetComponent(); if (trader == null || StoreGui.instance == null) { - player.Message(MessageHud.MessageType.Center, "The ledger is shut."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_ledger_shut")); return false; } @@ -144,7 +144,7 @@ namespace RacesOfValheim if (CountGroups() >= DvergarBanco.MaxTroops) { - player.Message(MessageHud.MessageType.Center, "Five contracts is all the ledger holds."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_five_contracts_all_ledger_holds")); return; } @@ -163,7 +163,7 @@ namespace RacesOfValheim TakeCoins(inventory, price); m_nview.InvokeRPC("RoV_DvergarHire", troop.Id); - player.Message(MessageHud.MessageType.Center, $"{troop.Display} signs on."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_signs", troop.Display)); } private const string CoinsPrefab = "Coins"; diff --git a/JotunnModStub/Dvergar/DvergarBotte.cs b/JotunnModStub/Dvergar/DvergarBotte.cs index 05ee712..e0a7953 100644 --- a/JotunnModStub/Dvergar/DvergarBotte.cs +++ b/JotunnModStub/Dvergar/DvergarBotte.cs @@ -203,7 +203,7 @@ namespace RacesOfValheim if (Utils.GetPrefabName(__0.gameObject) != DvergarBotte.PieceName) return true; if (DvergarRace.IsDvergar()) return true; - __instance.Message(MessageHud.MessageType.Center, "You do not know what goes in it."); + __instance.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_do_not_know_what_goes")); return false; } } diff --git a/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs b/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs index 84b810c..32d4a82 100644 --- a/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs +++ b/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs @@ -77,7 +77,7 @@ namespace RacesOfValheim ItemDrop.ItemData found = FindAnyBrew(inventory); if (found == null) { - player.Message(MessageHud.MessageType.Center, "It is empty, and so are you."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_empty_so_are")); return false; } @@ -106,7 +106,7 @@ namespace RacesOfValheim if (!string.IsNullOrEmpty(current) && current != prefabName && GetDoses() > 0) { player.Message(MessageHud.MessageType.Center, - $"There is still {DvergarBotte.BrewDisplayName(current)} in it."); + ModText.Get("rov_msg_dvergar_there_still", DvergarBotte.BrewDisplayName(current))); return false; } @@ -151,14 +151,14 @@ namespace RacesOfValheim StatusEffect effect = DvergarBotte.BrewEffect(brew); if (effect == null) { - player.Message(MessageHud.MessageType.Center, "Whatever is in it does nothing to anyone."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_whatever_does_nothing_anyone")); return false; } List drinkers = InRange(); if (drinkers.Count == 0) { - player.Message(MessageHud.MessageType.Center, "Nobody is at the barrel."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_nobody_at_barrel")); return false; } @@ -173,16 +173,14 @@ namespace RacesOfValheim if (served == 0) { - player.Message(MessageHud.MessageType.Center, "Not a drop went down."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_dvergar_not_drop_went_down")); return false; } m_nview.InvokeRPC("RoV_DvergarBotteSpend", served); string what = DvergarBotte.BrewDisplayName(brew); - player.Message(MessageHud.MessageType.Center, served < drinkers.Count - ? $"{served} drink {what}. The barrel runs dry." - : $"{served} drink {what}."); + player.Message(MessageHud.MessageType.Center, (served < drinkers.Count ? ModText.Get("rov_msg_dvergar_drink_barrel_runs_dry", served, what) : ModText.Get("rov_msg_dvergar_drink", served, what))); return true; } diff --git a/JotunnModStub/Dvergar/DvergarPatches.cs b/JotunnModStub/Dvergar/DvergarPatches.cs index 6de3f31..de75252 100644 --- a/JotunnModStub/Dvergar/DvergarPatches.cs +++ b/JotunnModStub/Dvergar/DvergarPatches.cs @@ -110,7 +110,7 @@ namespace RacesOfValheim DvergarAbilities.ConsumeOvercharge(Player.m_localPlayer)) { ScalePhysical(hit, DvergarConfig.RunicOverchargeMultiplier); - Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "Runic Overcharge discharges"); + Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, ModText.Get("rov_msg_dvergar_runic_overcharge_discharges")); } } diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 9b13a35..9f71886 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -920,7 +920,7 @@ namespace RacesOfValheim lastNoEitrMessage = Time.time; Player.m_localPlayer.Message(MessageHud.MessageType.Center, - "Only breath comes out. The fire wants eitr."); + ModText.Get("rov_msg_fenrir_only_breath_comes_out_fire")); } private void StartFire() diff --git a/JotunnModStub/Fenrir/FenrirMangiatoia.cs b/JotunnModStub/Fenrir/FenrirMangiatoia.cs index b098f0a..8280607 100644 --- a/JotunnModStub/Fenrir/FenrirMangiatoia.cs +++ b/JotunnModStub/Fenrir/FenrirMangiatoia.cs @@ -155,7 +155,7 @@ namespace RacesOfValheim PieceDensityLimit.Register(PieceName, PieceDensityLimit.RadiusForArea(DensityAreaKm2), MaxTroughsInRange, - "There is already {0} of these within a day's walk. A pack needs room."); + "rov_msg_build_limit_fenrir_packtrough"); } // ---------------------------------------------------------------- items diff --git a/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs b/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs index a7e2bfb..8a54e0f 100644 --- a/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs +++ b/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs @@ -289,7 +289,7 @@ namespace RacesOfValheim if (item == null) item = FindAnyInput(inventory); if (item == null) { - user.Message(MessageHud.MessageType.Center, "It wants meat. Any meat."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_wants_meat_any_meat")); return false; } @@ -342,19 +342,19 @@ namespace RacesOfValheim { if (IsUpgraded()) { - user.Message(MessageHud.MessageType.Center, "It has already had one."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_has_already_had_one")); return false; } if (BossProgressionManager.GetCurrentProgressionState() < FenrirMangiatoia.UpgradeProgressionState) { - user.Message(MessageHud.MessageType.Center, "The blood will not take. Something in the plains has to fall first."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_blood_will_not_take_something")); return false; } if (inventory.CountItems(YagluthDropName()) < 1) { - user.Message(MessageHud.MessageType.Center, "It wants what Yagluth left behind."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_wants_what_yagluth_left_behind")); return false; } @@ -362,7 +362,7 @@ namespace RacesOfValheim inventory.RemoveItem(item, 1); m_nview.InvokeRPC("RoV_FenrirUpgrade"); - user.Message(MessageHud.MessageType.Center, "The trough takes it. The line runs deeper now."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_trough_takes_line_runs_deeper")); return true; } @@ -404,7 +404,7 @@ namespace RacesOfValheim if (bound.Count > 0 && Player.m_localPlayer != null) { Player.m_localPlayer.Message(MessageHud.MessageType.Center, - $"The trough is broken. {bound.Count} will not outlast it by long."); + ModText.Get("rov_msg_fenrir_trough_broken_will_not_outlast", bound.Count)); } SetFeed(0f); diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index 22c1ee6..f6ff044 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -176,7 +176,7 @@ namespace RacesOfValheim { // forms allowed by day would otherwise be locked out right after every sunrise. if (rules.NeedsNight && sunSicknessTimer > 0f) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The beast is tired"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_beast_tired")); return; } @@ -188,7 +188,7 @@ namespace RacesOfValheim { if (rules.NeedsNight && !EnvMan.IsNight()) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The beast rests. You can only transform at night."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_beast_rests_can_only_transform")); return; } @@ -203,8 +203,9 @@ namespace RacesOfValheim { if (remaining < 0) remaining = 0; int rMin = Mathf.FloorToInt(remaining / 60f); int rSec = Mathf.FloorToInt(remaining % 60f); - string formName = rules.Form == FenrirProgression.FormType.Cultist ? "Cultist" : "Fenrir"; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"{formName} form is on cooldown ({rMin}:{rSec:00})."); + // A token, which the message's own localization pass translates along with the rest. + string formName = rules.Form == FenrirProgression.FormType.Cultist ? "$rov_msg_fenrir_formname_cultist" : "$rov_msg_fenrir_formname_fenrir"; + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_form_cooldown", formName, rMin, (rSec).ToString("00"))); return; } } @@ -410,7 +411,7 @@ namespace RacesOfValheim { Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_WolfForm".GetStableHashCode(), true); var se = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_WolfForm".GetStableHashCode()); if (se != null) se.m_ttl = ttl; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are an Ulv!"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_are_ulv")); } else if (prefabName == "Wolf") { @@ -418,7 +419,7 @@ namespace RacesOfValheim { Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_WolfForm".GetStableHashCode(), true); var se = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_WolfForm".GetStableHashCode()); if (se != null) se.m_ttl = ttl; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are a Wolf!"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_are_wolf")); } else if (prefabName == "Fenring_Cultist") { @@ -426,7 +427,7 @@ namespace RacesOfValheim { Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_CultistForm".GetStableHashCode(), true); var se = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_CultistForm".GetStableHashCode()); if (se != null) se.m_ttl = ttl; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are a Cultist!"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_are_cultist")); } else { @@ -434,7 +435,7 @@ namespace RacesOfValheim { Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_FenrirForm".GetStableHashCode(), true); var se = Player.m_localPlayer.GetSEMan().GetStatusEffect("SE_FenrirForm".GetStableHashCode()); if (se != null) se.m_ttl = ttl; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are a Fenring!"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_are_fenring")); } isTransformed = true; @@ -480,7 +481,7 @@ namespace RacesOfValheim { Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_WolfForm".GetStableHashCode()); isTransformed = false; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You returned to human form."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_returned_human_form")); if (activeRules != null && activeRules.CooldownMinutes > 0) { diff --git a/JotunnModStub/Fenrir/FenrirStatusEffects.cs b/JotunnModStub/Fenrir/FenrirStatusEffects.cs index b519103..43de139 100644 --- a/JotunnModStub/Fenrir/FenrirStatusEffects.cs +++ b/JotunnModStub/Fenrir/FenrirStatusEffects.cs @@ -17,7 +17,7 @@ namespace RacesOfValheim base.Stop(); if (Player.m_localPlayer != null) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"{m_name} is Ready!"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_ready", m_name)); } } } diff --git a/JotunnModStub/ModText.cs b/JotunnModStub/ModText.cs index 4e43258..b5bb3e9 100644 --- a/JotunnModStub/ModText.cs +++ b/JotunnModStub/ModText.cs @@ -21,7 +21,13 @@ namespace RacesOfValheim { if (Localization.instance == null) return "[" + key + "]"; - string[] words = args.Select(a => a?.ToString() ?? "").ToArray(); + // Each argument is localized on its own before it goes in. An argument is often a token + // itself - a creature's m_name, a boss - and left for a later pass it would run into + // whatever follows the $1: "$enemy_eikthyr's power" reads as the token + // "enemy_eikthyr's", because an apostrophe does not end a token. + string[] words = args + .Select(a => Localization.instance.Localize(a?.ToString() ?? "")) + .ToArray(); return Localization.instance.Localize("$" + key, words); } diff --git a/JotunnModStub/PieceDensityLimit.cs b/JotunnModStub/PieceDensityLimit.cs index 1546e21..daf3047 100644 --- a/JotunnModStub/PieceDensityLimit.cs +++ b/JotunnModStub/PieceDensityLimit.cs @@ -62,6 +62,7 @@ namespace RacesOfValheim /// Caps a piece. Call once from the chain's Register(); calling twice just replaces the entry, /// so a Register() that runs more than once cannot stack limits. /// + /// A translation key, not text: its $1 is how many stand nearby, $2 the limit. public static void Register(string piecePrefabName, float radius, int max, string refusalMessage) { if (string.IsNullOrEmpty(piecePrefabName) || max < 1 || radius <= 0f) @@ -156,7 +157,7 @@ namespace RacesOfValheim if (player != null) { - player.Message(MessageHud.MessageType.Center, string.Format(limit.Message, nearby, limit.Max)); + player.Message(MessageHud.MessageType.Center, ModText.Get(limit.Message, nearby, limit.Max)); } return false; } diff --git a/JotunnModStub/RaceCaveBuilding.cs b/JotunnModStub/RaceCaveBuilding.cs index 4e026d7..e9ddb8f 100644 --- a/JotunnModStub/RaceCaveBuilding.cs +++ b/JotunnModStub/RaceCaveBuilding.cs @@ -155,7 +155,7 @@ namespace RacesOfValheim allowing = true; Jotunn.Logger.LogInfo($"[Races] In a troll cave: {flipped.Count} pieces temporarily allowed in dungeons."); - player.Message(MessageHud.MessageType.Center, "This cave will hold what you build in it."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_build_this_cave_will_hold_what")); } /// diff --git a/JotunnModStub/RaceClaws.cs b/JotunnModStub/RaceClaws.cs index 3fc2bbb..818ffc7 100644 --- a/JotunnModStub/RaceClaws.cs +++ b/JotunnModStub/RaceClaws.cs @@ -899,7 +899,7 @@ namespace RacesOfValheim if (owner == null) return true; if (Player.m_localPlayer == null || owner != RaceClawSet.For(Player.m_localPlayer)) return true; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "They are part of your hands."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_claws_they_are_part_hands")); return false; } } diff --git a/JotunnModStub/RaceMenuWard.cs b/JotunnModStub/RaceMenuWard.cs index 5457560..94ef37a 100644 --- a/JotunnModStub/RaceMenuWard.cs +++ b/JotunnModStub/RaceMenuWard.cs @@ -201,20 +201,20 @@ namespace RacesOfValheim string prefabName = item.m_dropPrefab != null ? item.m_dropPrefab.name : null; if (prefabName == null || !BossProgressionManager.BossDropStates.TryGetValue(prefabName, out int state)) { - user.Message(MessageHud.MessageType.Center, "The ward has no use for that."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_ward_ward_has_no_use_that")); return true; } if (!BossProgressionManager.UsePersonalProgression) { - user.Message(MessageHud.MessageType.Center, "Switch to personal progression first."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_ward_switch_personal_progression_first")); return true; } if (BossProgressionManager.PersonalState >= state) { user.Message(MessageHud.MessageType.Center, - $"You already carry {BossProgressionManager.GetBossNameForState(state)}'s power."); + ModText.Get("rov_msg_ward_already_carry_s_power", BossProgressionManager.GetBossTokenForState(state))); return true; } @@ -223,7 +223,7 @@ namespace RacesOfValheim BossProgressionManager.PersonalState = state; user.Message(MessageHud.MessageType.Center, - $"{BossProgressionManager.GetBossNameForState(state)}'s power is yours."); + ModText.Get("rov_msg_ward_s_power_yours", BossProgressionManager.GetBossTokenForState(state))); RefreshRaceState(); return true; diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 7778632..f9d3462 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -199,16 +199,16 @@ namespace RacesOfValheim } int state = BossProgressionManager.GetCurrentProgressionState(); - string boss = BossProgressionManager.GetBossNameForState(state); + string boss = BossProgressionManager.GetBossTokenForState(state); if (clearedPersonal) - summary = $"Personal progression reset to {boss} ({state}/{BossProgressionManager.MaxState}). Claim your relics again."; + summary = ModText.Get("rov_msg_core_progression_reset", boss, state, BossProgressionManager.MaxState); else if (BossProgressionManager.UsePersonalProgression) - summary = $"Nothing to reset - you have claimed no relics yet ({state}/{BossProgressionManager.MaxState})."; + summary = ModText.Get("rov_msg_core_nothing_reset_personal", state, BossProgressionManager.MaxState); else - summary = $"Nothing to reset - you follow the world's progression: {boss} ({state}/{BossProgressionManager.MaxState})."; + summary = ModText.Get("rov_msg_core_nothing_reset_world", boss, state, BossProgressionManager.MaxState); - if (hadDebugOverride) summary += " Debug override cleared."; + if (hadDebugOverride) summary += " " + ModText.Get("rov_msg_core_debug_override_cleared"); Player player = Player.m_localPlayer; if (player != null) @@ -537,7 +537,7 @@ namespace RacesOfValheim Player.m_localPlayer.m_customData["Race"] = "Human"; ZNetView nview = Player.m_localPlayer.GetComponent(); if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human"); - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose to remain Human."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_remain_human")); } CloseRaceSelectionMenu(); } @@ -552,7 +552,7 @@ namespace RacesOfValheim Player.m_localPlayer.m_customData["FenrirCurse_Active"] = "true"; Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_FenrirCurse".GetStableHashCode(), true); - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Fenrir."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_fenrir")); } CloseRaceSelectionMenu(); } @@ -565,7 +565,7 @@ namespace RacesOfValheim ZNetView nview = Player.m_localPlayer.GetComponent(); if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Skadi"); - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of Skadi."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_skadi")); // Force update skin colors VisEquipment visEq = Player.m_localPlayer.GetComponent(); @@ -594,7 +594,7 @@ namespace RacesOfValheim visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null); } - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Skeleton."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_skeleton")); CloseRaceSelectionMenu(); } } @@ -624,7 +624,7 @@ namespace RacesOfValheim visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null); } - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Aswid."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_aswid")); CloseRaceSelectionMenu(); } } @@ -652,7 +652,7 @@ namespace RacesOfValheim visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null); } - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Furling."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_furling")); CloseRaceSelectionMenu(); } } @@ -694,7 +694,7 @@ namespace RacesOfValheim visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null); } - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Trol."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_trol")); CloseRaceSelectionMenu(); } } @@ -740,7 +740,7 @@ namespace RacesOfValheim visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null); } - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Draugh."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_draugh")); CloseRaceSelectionMenu(); } } @@ -777,7 +777,7 @@ namespace RacesOfValheim visEq.GetType().GetMethod("UpdateVisuals", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null); } - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Dvergar."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_dvergar")); CloseRaceSelectionMenu(); } } @@ -813,7 +813,7 @@ namespace RacesOfValheim visEq.GetType().GetMethod("UpdateVisuals", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null); } - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Sverm."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_sverm")); CloseRaceSelectionMenu(); } } @@ -868,7 +868,7 @@ namespace RacesOfValheim visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null); } - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Trenta."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_chose_path_trenta")); CloseRaceSelectionMenu(); } } @@ -1015,7 +1015,7 @@ namespace RacesOfValheim if (Player.m_localPlayer != null) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"World Progression State: {state}"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_world_progression_state", state)); } } } @@ -1038,7 +1038,7 @@ namespace RacesOfValheim Console.instance.Print($"[DEBUG] Progression state increased to: {BossProgressionManager.DebugState}"); if (Player.m_localPlayer != null) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"Progression State: {BossProgressionManager.DebugState}"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_core_progression_state", BossProgressionManager.DebugState)); Traverse.Create(Player.m_localPlayer).Method("SetupEquipment").GetValue(); } } diff --git a/JotunnModStub/RaisedThrall.cs b/JotunnModStub/RaisedThrall.cs index f1ecd9c..c46aea5 100644 --- a/JotunnModStub/RaisedThrall.cs +++ b/JotunnModStub/RaisedThrall.cs @@ -53,7 +53,7 @@ namespace RacesOfValheim public float m_homeCheckRange = 20f; /// Shown in the refusal when a station is not this player's to command. - public string m_refusalMessage = "It does not answer to you."; + public string m_refusalMessage = "$rov_msg_thrall_refusal_default"; /// /// How many thralls of OTHER kinds, from the same station, come along when this one is @@ -298,7 +298,7 @@ namespace RacesOfValheim { m_monsterAI.SetFollowTarget(null); GoHome(); - if (announce) player.Message(MessageHud.MessageType.Center, $"{m_character.m_name} returns."); + if (announce) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_returns", m_character.m_name)); return true; } @@ -308,7 +308,7 @@ namespace RacesOfValheim { if (announce) { - player.Message(MessageHud.MessageType.Center, $"Only {m_maxFollowers} may walk with you."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_only_may_walk_with", m_maxFollowers)); } return false; } @@ -323,7 +323,7 @@ namespace RacesOfValheim if (m_ai != null) m_ai.ResetPatrolPoint(); m_monsterAI.SetFollowTarget(player.gameObject); - if (announce) player.Message(MessageHud.MessageType.Center, $"{m_character.m_name} follows."); + if (announce) player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_follows", m_character.m_name)); return true; } @@ -355,9 +355,7 @@ namespace RacesOfValheim if (other.SetFollowing(player, follow, announce: false)) taken++; } - player.Message(MessageHud.MessageType.Center, follow - ? $"{m_character.m_name} rises with {taken}." - : $"{m_character.m_name} stands down with {taken}."); + player.Message(MessageHud.MessageType.Center, (follow ? ModText.Get("rov_msg_thrall_rises_with", m_character.m_name, taken) : ModText.Get("rov_msg_thrall_stands_down_with", m_character.m_name, taken))); } private static int CountFollowers(Player player, string kind) @@ -445,12 +443,12 @@ namespace RacesOfValheim if (came > 0) { - player.Message(MessageHud.MessageType.Center, $"{came} answer the call."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_answer_call", came)); } else if (refused > 0) { // The only way SetFollowing refuses a thrall that may be commanded is the cap. - player.Message(MessageHud.MessageType.Center, "No more may walk with you."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_thrall_no_more_may_walk_with")); } } diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index ffd3b74..53b9049 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -257,7 +257,7 @@ namespace RacesOfValheim float cost = Mathf.Min(STAMINA_PER_PROJECTILE * projCount, MAX_VOLLEY_STAMINA); if (!Player.m_localPlayer.HaveStamina(cost)) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Not enough stamina"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_not_enough_stamina")); return false; } Player.m_localPlayer.UseStamina(cost); diff --git a/JotunnModStub/Skadi/SkadiGolem.cs b/JotunnModStub/Skadi/SkadiGolem.cs index 9a1035e..99fca6a 100644 --- a/JotunnModStub/Skadi/SkadiGolem.cs +++ b/JotunnModStub/Skadi/SkadiGolem.cs @@ -306,21 +306,21 @@ namespace RacesOfValheim if (!SkadiRace.IsLocalSkadi()) { - player.Message(MessageHud.MessageType.Center, "The stone does not answer to you."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_stone_does_not_answer")); return false; } if (BossProgressionManager.GetCurrentProgressionState() < ModerProgressionState) { player.Message(MessageHud.MessageType.Center, - "The tear is cold. Nothing wakes in the stone until the mountain's queen has fallen."); + ModText.Get("rov_msg_skadi_tear_cold_nothing_wakes_stone")); return false; } CraftingStation station = FindStonecutter(position); if (station == null) { - player.Message(MessageHud.MessageType.Center, "It needs a stonecutter to be cut at."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_needs_stonecutter_cut_at")); return false; } @@ -328,7 +328,7 @@ namespace RacesOfValheim if (bound >= MaxPerStation) { player.Message(MessageHud.MessageType.Center, - $"That stonecutter already holds {bound}. It will not hold more."); + ModText.Get("rov_msg_skadi_that_stonecutter_already_holds_will", bound)); return false; } @@ -336,7 +336,7 @@ namespace RacesOfValheim if (nearby >= MaxInArea) { player.Message(MessageHud.MessageType.Center, - $"There are already {nearby} of these within a day's walk. The stone is spent."); + ModText.Get("rov_msg_skadi_there_are_already_these_within", nearby)); return false; } diff --git a/JotunnModStub/Skadi/SkadiGolemBehaviour.cs b/JotunnModStub/Skadi/SkadiGolemBehaviour.cs index b21621a..36554c4 100644 --- a/JotunnModStub/Skadi/SkadiGolemBehaviour.cs +++ b/JotunnModStub/Skadi/SkadiGolemBehaviour.cs @@ -181,7 +181,7 @@ namespace RacesOfValheim Vector3.Distance(Player.m_localPlayer.transform.position, transform.position) < 30f) { Player.m_localPlayer.Message(MessageHud.MessageType.Center, - "The stonecutter is gone. What it cut will not outlast it by long."); + ModText.Get("rov_msg_skadi_stonecutter_gone_what_cut_will")); } } diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index fbdffb6..16744af 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -246,7 +246,7 @@ namespace RacesOfValheim if (isTransformed && formExpireTime > 0f && Time.time >= formExpireTime) { formExpireTime = 0f; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Your dragon form fades."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_dragon_form_fades")); StartCoroutine(RevertToHumanRoutine()); return; } @@ -265,7 +265,7 @@ namespace RacesOfValheim DumpPrefabDebugInfo("Dragon"); DumpPrefabDebugInfo("Hatchling"); DumpPrefabDebugInfo("Fader"); - if (Player.m_localPlayer != null) Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Dumped Dragon/Drake/Fader debug info to console!"); + if (Player.m_localPlayer != null) Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_dumped_dragon_drake_fader_debug")); } } @@ -438,7 +438,7 @@ namespace RacesOfValheim // the Mistlands onward, so the old HaveEitr gate left it unusable for five tiers. if (!Player.m_localPlayer.HaveStamina(SPELL_STAMINA_COST)) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Not enough stamina"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_not_enough_stamina")); return; } @@ -710,7 +710,7 @@ namespace RacesOfValheim if (remaining < 0) remaining = 0; int rMin = Mathf.FloorToInt(remaining / 60f); int rSec = Mathf.FloorToInt(remaining % 60f); - Player.m_localPlayer.Message(MessageHud.MessageType.Center, $"Dragon Form is on cooldown ({rMin}:{rSec:00})."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_dragon_form_cooldown", rMin, (rSec).ToString("00"))); return; } } @@ -891,9 +891,9 @@ namespace RacesOfValheim DrakeFormBehavior behavior = currentTransformation.AddComponent(); behavior.Initialize(rules); - if (prefabName == "Hatchling") Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are a Drake!"); - else if (prefabName == "Dragon") Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are Moder!"); - else if (prefabName == "Fader") Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are Fader!"); + if (prefabName == "Hatchling") Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_are_drake")); + else if (prefabName == "Dragon") Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_are_moder")); + else if (prefabName == "Fader") Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_are_fader")); isTransformed = true; StartFormTimer(rules); @@ -943,7 +943,7 @@ namespace RacesOfValheim isTransformed = false; formExpireTime = 0f; Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkadiForm".GetStableHashCode(), true); - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You returned to human form."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skadi_returned_human_form")); if (activeRules != null && activeRules.CooldownMinutes > 0) { diff --git a/JotunnModStub/Skeleton/SkeletonBonePile.cs b/JotunnModStub/Skeleton/SkeletonBonePile.cs index 35fcdd9..9c6d6c1 100644 --- a/JotunnModStub/Skeleton/SkeletonBonePile.cs +++ b/JotunnModStub/Skeleton/SkeletonBonePile.cs @@ -136,7 +136,7 @@ namespace RacesOfValheim PieceDensityLimit.Register(PieceName, PieceDensityLimit.RadiusForArea(DensityAreaKm2), MaxPilesInRange, - "There are already {0} of these listening nearby. Take it further out."); + "rov_msg_build_limit_skeleton_bonepile"); } // ---------------------------------------------------------------- items @@ -282,7 +282,7 @@ namespace RacesOfValheim thrall.m_maxFollowers = MaxFollowers; thrall.m_witherSeconds = OrphanWitherSeconds; thrall.m_homeCheckRange = HomeCheckRange; - thrall.m_refusalMessage = "These bones answer only to their own kind."; + thrall.m_refusalMessage = "$rov_msg_thrall_refusal_skeleton"; thrall.m_escortCount = escortCount; PrefabManager.Instance.AddPrefab(prefab); diff --git a/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs b/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs index 002e2a4..f65e631 100644 --- a/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs +++ b/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs @@ -108,7 +108,7 @@ namespace RacesOfValheim { if (!IsUpgraded()) { - player.Message(MessageHud.MessageType.Center, "This pile cannot hold the rotten yet."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_this_pile_cannot_hold_rotten")); return false; } room = RancidCap() - GetSlots(SkeletonBonePile.KindRancid); @@ -149,7 +149,7 @@ namespace RacesOfValheim List bound = RaisedThrall.BoundTo(transform.position); if (bound.Count == 0) { - player.Message(MessageHud.MessageType.Center, "Nothing is standing yet. It wants bone."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_nothing_standing_yet_wants_bone")); return false; } @@ -169,13 +169,11 @@ namespace RacesOfValheim if (moved == 0) { // Every one of them refused, which for these means the player is not a Skeleton. - player.Message(MessageHud.MessageType.Center, "These bones answer only to their own kind."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_these_bones_answer_only_their")); return false; } - player.Message(MessageHud.MessageType.Center, anyFollowing - ? $"{moved} return to the pile." - : $"{moved} rise and follow."); + player.Message(MessageHud.MessageType.Center, (anyFollowing ? ModText.Get("rov_msg_skeleton_return_pile", moved) : ModText.Get("rov_msg_skeleton_rise_follow", moved))); return true; } @@ -183,19 +181,19 @@ namespace RacesOfValheim { if (IsUpgraded()) { - player.Message(MessageHud.MessageType.Center, "It has already had one."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_has_already_had_one")); return false; } if (BossProgressionManager.GetCurrentProgressionState() < SkeletonBonePile.UpgradeProgressionState) { - player.Message(MessageHud.MessageType.Center, "The skull will not wake. Something older has to fall first."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_skull_will_not_wake_something")); return false; } inventory.RemoveItem(item, 1); m_nview.InvokeRPC("RoV_SkelUpgrade"); - player.Message(MessageHud.MessageType.Center, "The pile deepens. The rotten will stand here too."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_pile_deepens_rotten_will_stand")); return true; } @@ -332,7 +330,7 @@ namespace RacesOfValheim if (bound.Count > 0 && Player.m_localPlayer != null) { Player.m_localPlayer.Message(MessageHud.MessageType.Center, - $"The pile is broken. {bound.Count} fall where they stand."); + ModText.Get("rov_msg_skeleton_pile_broken_fall_where_they", bound.Count)); } } diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index 10fdf7d..6ffb291 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -80,7 +80,7 @@ namespace RacesOfValheim { if (SkeletonRace.IsSkeleton() && item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Consumable && (item.m_shared.m_food > 0 || item.m_shared.m_foodStamina > 0 || item.m_shared.m_foodEitr > 0)) { - __instance.Message(MessageHud.MessageType.Center, "Skeletons do not need to eat."); + __instance.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_skeletons_do_not_need_eat")); __result = false; return false; } @@ -88,7 +88,7 @@ namespace RacesOfValheim // survive this blanket refusal - everything else mortal still bounces. else if (AswidRace.IsAswid() && !AswidRace.BypassAswidFoodCheck && !AswidBloodRefinery.IsAswidMeal(item) && item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Consumable && (item.m_shared.m_food > 0 || item.m_shared.m_foodStamina > 0 || item.m_shared.m_foodEitr > 0)) { - __instance.Message(MessageHud.MessageType.Center, "Mortal food disgusts you."); + __instance.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_mortal_food_disgusts")); __result = false; return false; } @@ -630,7 +630,7 @@ namespace RacesOfValheim UnityEngine.Object.Instantiate(vfx, Player.m_localPlayer.transform.position, Quaternion.identity); } - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You have been resurrected by dark magic!"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_have_been_resurrected_by_dark")); return false; // Skip applying this lethal damage } } diff --git a/JotunnModStub/Sverm/SvermBlisterTick.cs b/JotunnModStub/Sverm/SvermBlisterTick.cs index 507b97f..b0fd8ad 100644 --- a/JotunnModStub/Sverm/SvermBlisterTick.cs +++ b/JotunnModStub/Sverm/SvermBlisterTick.cs @@ -79,7 +79,7 @@ namespace RacesOfValheim thrall.m_maxFollowers = -1; thrall.m_witherSeconds = SvermConfig.TroopWitherSeconds; thrall.m_homeCheckRange = SvermConfig.TroopHomeCheckRange; - thrall.m_refusalMessage = "It does not smell your colony on you."; + thrall.m_refusalMessage = "$rov_msg_thrall_refusal_sverm"; // No SkeletonSentryBehaviour. A tick that healed itself would be a tick that never gets // round to exploding, which is its entire job. diff --git a/JotunnModStub/Sverm/SvermBrood.cs b/JotunnModStub/Sverm/SvermBrood.cs index f67c92d..be162e4 100644 --- a/JotunnModStub/Sverm/SvermBrood.cs +++ b/JotunnModStub/Sverm/SvermBrood.cs @@ -118,7 +118,7 @@ namespace RacesOfValheim thrall.m_maxFollowers = -1; // the cap is the colony's, counted at the nest, not per player thrall.m_witherSeconds = SvermConfig.TroopWitherSeconds; thrall.m_homeCheckRange = SvermConfig.TroopHomeCheckRange; - thrall.m_refusalMessage = "It does not smell your colony on you."; + thrall.m_refusalMessage = "$rov_msg_thrall_refusal_sverm"; // Section 11.2, reused whole: ten seconds untouched, then two percent a second. Healing // and not respawning - a dead troop is dead, and the egg it cost is already back. diff --git a/JotunnModStub/Sverm/SvermClawSlot.cs b/JotunnModStub/Sverm/SvermClawSlot.cs index 34bf82e..3d9212b 100644 --- a/JotunnModStub/Sverm/SvermClawSlot.cs +++ b/JotunnModStub/Sverm/SvermClawSlot.cs @@ -300,7 +300,7 @@ namespace RacesOfValheim if (!SvermClawSlot.IsClaws(item)) return true; if (Player.m_localPlayer == null || !SvermVisuals.IsSvermPlayer(Player.m_localPlayer)) return true; - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "They are part of your hands."); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_they_are_part_hands")); return false; } } diff --git a/JotunnModStub/Sverm/SvermFood.cs b/JotunnModStub/Sverm/SvermFood.cs index dad338b..21402c9 100644 --- a/JotunnModStub/Sverm/SvermFood.cs +++ b/JotunnModStub/Sverm/SvermFood.cs @@ -235,7 +235,7 @@ namespace RacesOfValheim if (item.m_dropPrefab != null && item.m_dropPrefab.name.StartsWith("SvermMeal_") == false && IsAswidBlood(item)) { - player.Message(MessageHud.MessageType.Center, "Alchemical blood is not food."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_alchemical_blood_not_food")); return false; } diff --git a/JotunnModStub/Sverm/SvermHive.cs b/JotunnModStub/Sverm/SvermHive.cs index 3c2266b..468846b 100644 --- a/JotunnModStub/Sverm/SvermHive.cs +++ b/JotunnModStub/Sverm/SvermHive.cs @@ -178,13 +178,13 @@ namespace RacesOfValheim if (!SvermVisuals.IsSvermPlayer(player)) { - player.Message(MessageHud.MessageType.Center, "Only the Sverm can raise a hive."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_only_sverm_can_raise_hive")); return false; } if (BossProgressionManager.GetCurrentProgressionState() < SvermConfig.HiveUnlockState) { - player.Message(MessageHud.MessageType.Center, "The colony will not wake until the Elder falls."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_colony_will_not_wake_until")); return false; } @@ -198,7 +198,7 @@ namespace RacesOfValheim private static void RegisterNestDensity() { PieceDensityLimit.Register(PieceName, SvermConfigManagement.NestRadius, SvermConfigManagement.NestMax, - "There is already a hive holding this ground."); + "rov_msg_build_limit_sverm_hive"); } /// @@ -437,7 +437,7 @@ namespace RacesOfValheim if (!SvermVisuals.IsSvermPlayer(player)) { - player.Message(MessageHud.MessageType.Center, "The hive does not know you."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_hive_does_not_know")); return true; } diff --git a/JotunnModStub/Sverm/SvermHiveGoods.cs b/JotunnModStub/Sverm/SvermHiveGoods.cs index 7962d3c..7ba51e6 100644 --- a/JotunnModStub/Sverm/SvermHiveGoods.cs +++ b/JotunnModStub/Sverm/SvermHiveGoods.cs @@ -297,7 +297,7 @@ namespace RacesOfValheim // stage it was not paid for cannot be undone. if (!SvermBiomass.Spend(hive.transform, good.Price)) { - player?.Message(MessageHud.MessageType.Center, "Not enough biomass in the bank."); + player?.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_not_enough_biomass_bank")); return false; } diff --git a/JotunnModStub/Sverm/SvermHiveStore.cs b/JotunnModStub/Sverm/SvermHiveStore.cs index f63f642..fe7a064 100644 --- a/JotunnModStub/Sverm/SvermHiveStore.cs +++ b/JotunnModStub/Sverm/SvermHiveStore.cs @@ -128,7 +128,7 @@ namespace RacesOfValheim float room = SvermBiomass.Space(hive.transform); if (room <= 0f) { - player.Message(MessageHud.MessageType.Center, "The hive is full. Give it time to digest."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_hive_full_give_time_digest")); return true; } @@ -149,12 +149,12 @@ namespace RacesOfValheim inventory.RemoveItem(item, units); player.Message(MessageHud.MessageType.TopLeft, - $"{name} x{units} -> +{fed:0} biomass, digesting"); + ModText.Get("rov_msg_sverm_x_biomass_digesting", name, units, (fed).ToString("0"))); return true; } player.Message(MessageHud.MessageType.Center, - "Nothing here it will eat. Food, wood and resin - honey and royal jelly are medicine."); + ModText.Get("rov_msg_sverm_nothing_here_will_eat_food")); return true; } } @@ -202,7 +202,7 @@ namespace RacesOfValheim if (!SvermVisuals.IsSvermPlayer(player)) { - player.Message(MessageHud.MessageType.Center, "The hive does not know you."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_hive_does_not_know")); return true; } @@ -389,14 +389,14 @@ namespace RacesOfValheim if (!SvermVisuals.IsSvermPlayer(player)) { - player.Message(MessageHud.MessageType.Center, "Only the Sverm can raise a market."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_only_sverm_can_raise_market")); return false; } if (SvermHive.NearestNest(position, SvermConfigManagement.AuraRadius) == null) { player.Message(MessageHud.MessageType.Center, - $"A market has to stand within {SvermConfigManagement.AuraRadius:0} metres of a hive."); + ModText.Get("rov_msg_sverm_market_has_stand_within_metres", (SvermConfigManagement.AuraRadius).ToString("0"))); return false; } @@ -410,7 +410,7 @@ namespace RacesOfValheim private static void RegisterMarketDensity() { PieceDensityLimit.Register(PieceName, SvermConfigManagement.AuraRadius, 1, - "This hive already has a market."); + "rov_msg_build_limit_sverm_market"); } } @@ -428,7 +428,7 @@ namespace RacesOfValheim if (!SvermVisuals.IsSvermPlayer(player)) { - player.Message(MessageHud.MessageType.Center, "The hive does not know you."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_hive_does_not_know")); return true; } @@ -439,7 +439,7 @@ namespace RacesOfValheim if (nest == null) { player.Message(MessageHud.MessageType.Center, - $"No hive within {SvermConfigManagement.AuraRadius:0} metres. This counter is dead."); + ModText.Get("rov_msg_sverm_no_hive_within_metres_this", (SvermConfigManagement.AuraRadius).ToString("0"))); return true; } diff --git a/JotunnModStub/Sverm/SvermMedicine.cs b/JotunnModStub/Sverm/SvermMedicine.cs index 5fa46cd..3605304 100644 --- a/JotunnModStub/Sverm/SvermMedicine.cs +++ b/JotunnModStub/Sverm/SvermMedicine.cs @@ -54,7 +54,7 @@ namespace RacesOfValheim // Localized, because a creature's m_name is a token: printing it raw would put // "$enemy_seeker is not hurt" on the screen. string who = Localization.instance.Localize(patient.m_name); - player.Message(MessageHud.MessageType.Center, $"{who} is not hurt."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_not_hurt", who)); return true; } diff --git a/JotunnModStub/Sverm/SvermPatches.cs b/JotunnModStub/Sverm/SvermPatches.cs index 5d909f1..8d43fcc 100644 --- a/JotunnModStub/Sverm/SvermPatches.cs +++ b/JotunnModStub/Sverm/SvermPatches.cs @@ -76,7 +76,7 @@ namespace RacesOfValheim if (player == Player.m_localPlayer) { - player.Message(MessageHud.MessageType.Center, "Your carapace has no room for that."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_carapace_has_no_room_that")); } __result = false; diff --git a/JotunnModStub/Sverm/SvermRavagerForm.cs b/JotunnModStub/Sverm/SvermRavagerForm.cs index a8b9b88..91055b1 100644 --- a/JotunnModStub/Sverm/SvermRavagerForm.cs +++ b/JotunnModStub/Sverm/SvermRavagerForm.cs @@ -149,7 +149,7 @@ namespace RacesOfValheim if (IsActive && Time.time >= expiresAt) { - RunExit(player, spendCooldown: true, "The shell recedes."); + RunExit(player, spendCooldown: true, "$rov_msg_sverm_shell_recedes"); return; } @@ -165,13 +165,13 @@ namespace RacesOfValheim if (!SvermProgression.Current.RavagerForm) { - player.Message(MessageHud.MessageType.Center, "The strain has not taken yet."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_strain_has_not_taken_yet")); return; } if (Time.time < nextAllowedAt) { - player.Message(MessageHud.MessageType.Center, "The strain is spent."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_strain_spent")); return; } @@ -285,7 +285,7 @@ namespace RacesOfValheim PlayEffect(SvermConfig.RavagerMorphInEffects, player.transform.position); - player.Message(MessageHud.MessageType.Center, "The Ravager Strain takes hold."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_sverm_ravager_strain_takes_hold")); } private static void PlayEffect(string[] candidates, Vector3 where) diff --git a/JotunnModStub/Translations/English/messages.json b/JotunnModStub/Translations/English/messages.json new file mode 100644 index 0000000..a8b69c1 --- /dev/null +++ b/JotunnModStub/Translations/English/messages.json @@ -0,0 +1,193 @@ +{ + "rov_msg_aswid_aura_disabled": "Vampiric Aura: DISABLED", + "rov_msg_aswid_aura_enabled": "Vampiric Aura: ENABLED", + "rov_msg_aswid_dominate_cooldown_m_s": "Dominate on cooldown ($1m $2s)", + "rov_msg_aswid_dominated": "$1 dominated!", + "rov_msg_aswid_eclipse_cooldown_remaining_s": "Eclipse is on cooldown. Remaining: $1s", + "rov_msg_aswid_eclipse_descends": "An Eclipse descends...", + "rov_msg_aswid_eclipse_has_ended": "The Eclipse has ended.", + "rov_msg_aswid_following": "$1 is following.", + "rov_msg_aswid_living_blood_curdles_living_throat": "Living blood curdles in a living throat.", + "rov_msg_aswid_morning_sun_drives_bat_back": "The morning sun drives the bat back into your body", + "rov_msg_aswid_morning_sun_has_vanquished_horrible": "The morning sun has vanquished the horrible night", + "rov_msg_aswid_no_bone_grind": "No bone to grind.", + "rov_msg_aswid_no_raw_flesh_render": "No raw flesh to render.", + "rov_msg_aswid_staying": "$1 is staying.", + "rov_msg_aswid_sun_burns_can_only_take": "The sun burns. You can only take bat form at night.", + "rov_msg_aswid_tamed": "Tamed!", + "rov_msg_aswid_vae_victis": "Vae Victis", + "rov_msg_aswid_what_horrible_night_have_curse": "what a horrible night to have a curse", + "rov_msg_build_limit_cooktable": "Another cook's table stands within forty paces. One cook to a yard.", + "rov_msg_build_limit_draugh_bodypile": "The ground here already carries $1 of these. Find another country.", + "rov_msg_build_limit_dvergar_contractbank": "There is already $1 contract bank within a day's walk. One ledger per valley.", + "rov_msg_build_limit_fenrir_packtrough": "There is already $1 of these within a day's walk. A pack needs room.", + "rov_msg_build_limit_skeleton_bonepile": "There are already $1 of these listening nearby. Take it further out.", + "rov_msg_build_limit_smithtable": "Another smith's table stands within forty paces. One smith to a yard.", + "rov_msg_build_limit_sverm_hive": "There is already a hive holding this ground.", + "rov_msg_build_limit_sverm_market": "This hive already has a market.", + "rov_msg_build_limit_trenta_grove": "This country already answers to $1 of these. Plant it somewhere else.", + "rov_msg_build_this_cave_will_hold_what": "This cave will hold what you build in it.", + "rov_msg_butler_already_at_work": "It is already at work.", + "rov_msg_butler_bones_are_not_ready_s": "The bones are not ready. $1s.", + "rov_msg_butler_bones_do_not_answer_blood": "The bones do not answer to your blood.", + "rov_msg_butler_nothing_answers": "Nothing answers.", + "rov_msg_butler_only_skadi_s_hearth_kept": "Only Skadi's hearth is kept by the dead.", + "rov_msg_butler_servant_rises": "The servant rises.", + "rov_msg_claws_they_are_part_hands": "They are part of your hands.", + "rov_msg_core_chose_path_aswid": "You chose the path of the Aswid.", + "rov_msg_core_chose_path_draugh": "You chose the path of the Draugh.", + "rov_msg_core_chose_path_dvergar": "You chose the path of the Dvergar.", + "rov_msg_core_chose_path_fenrir": "You chose the path of the Fenrir.", + "rov_msg_core_chose_path_furling": "You chose the path of the Furling.", + "rov_msg_core_chose_path_skadi": "You chose the path of Skadi.", + "rov_msg_core_chose_path_skeleton": "You chose the path of the Skeleton.", + "rov_msg_core_chose_path_sverm": "You chose the path of the Sverm.", + "rov_msg_core_chose_path_trenta": "You chose the path of the Trenta.", + "rov_msg_core_chose_path_trol": "You chose the path of the Trol.", + "rov_msg_core_chose_remain_human": "You chose to remain Human.", + "rov_msg_core_debug_override_cleared": "Debug override cleared.", + "rov_msg_core_nothing_reset_personal": "Nothing to reset - you have claimed no relics yet ($1/$2).", + "rov_msg_core_nothing_reset_world": "Nothing to reset - you follow the world's progression: $1 ($2/$3).", + "rov_msg_core_progression_reset": "Personal progression reset to $1 ($2/$3). Claim your relics again.", + "rov_msg_core_progression_state": "Progression State: $1", + "rov_msg_core_world_progression_state": "World Progression State: $1", + "rov_msg_draugh_bone_will_not_wake_something": "The bone will not wake. Something older has to fall first.", + "rov_msg_draugh_draugr_consume_only_raw_flesh": "Draugr consume only raw flesh, eyes, entrails or blood.", + "rov_msg_draugh_has_already_had_one": "It has already had one.", + "rov_msg_draugh_northern_wind_blows": "The northern wind blows", + "rov_msg_draugh_pile_broken_will_not_outlast": "The pile is broken. $1 will not outlast it by more than a minute.", + "rov_msg_draugh_pile_stirs_will_keep_officers": "The pile stirs. It will keep officers now.", + "rov_msg_draugh_steal_their_breath_death_denied": "Steal Their Breath! Death is denied.", + "rov_msg_draugh_swarm_terror": "Swarm of Terror!", + "rov_msg_draugh_this_pile_keeps_no_officers": "This pile keeps no officers yet.", + "rov_msg_draugh_this_rotting_flesh_fatal_living": "This rotting flesh is fatal to the living.", + "rov_msg_draugh_wants_flesh_or_head_one": "It wants flesh, or the head of one of its own.", + "rov_msg_draugh_zombie_ritual_activated_borrowed_time": "Zombie Ritual Activated! Your borrowed time is fading...", + "rov_msg_dvergar_contract_runic_do_not_sign": "The contract is in runic. You do not sign it.", + "rov_msg_dvergar_do_not_know_what_goes": "You do not know what goes in it.", + "rov_msg_dvergar_drink": "$1 drink $2.", + "rov_msg_dvergar_drink_barrel_runs_dry": "$1 drink $2. The barrel runs dry.", + "rov_msg_dvergar_empty_so_are": "It is empty, and so are you.", + "rov_msg_dvergar_five_contracts_all_ledger_holds": "Five contracts is all the ledger holds.", + "rov_msg_dvergar_has_already_had_one": "It has already had one.", + "rov_msg_dvergar_ledger_not_written": "The ledger is not written for you.", + "rov_msg_dvergar_ledger_rewritten_better_names_sign": "The ledger is rewritten. Better names sign it now.", + "rov_msg_dvergar_ledger_shut": "The ledger is shut.", + "rov_msg_dvergar_nobody_at_barrel": "Nobody is at the barrel.", + "rov_msg_dvergar_not_drop_went_down": "Not a drop went down.", + "rov_msg_dvergar_not_enough_eitr": "Not enough eitr", + "rov_msg_dvergar_not_while_she_still_sits": "Not while she still sits under the mist.", + "rov_msg_dvergar_runic_overcharge_discharges": "Runic Overcharge discharges", + "rov_msg_dvergar_runic_overcharge_next_blow_loaded": "Runic Overcharge: your next blow is loaded", + "rov_msg_dvergar_runic_ping_echoes_answer": "Runic Ping: $1 echoes answer", + "rov_msg_dvergar_runic_ping_stone_silent": "Runic Ping: the stone is silent", + "rov_msg_dvergar_signs": "$1 signs on.", + "rov_msg_dvergar_there_still": "There is still $1 in it.", + "rov_msg_dvergar_whatever_does_nothing_anyone": "Whatever is in it does nothing to anyone.", + "rov_msg_fenrir_are_cultist": "You are a Cultist!", + "rov_msg_fenrir_are_fenring": "You are a Fenring!", + "rov_msg_fenrir_are_ulv": "You are an Ulv!", + "rov_msg_fenrir_are_wolf": "You are a Wolf!", + "rov_msg_fenrir_beast_rests_can_only_transform": "The beast rests. You can only transform at night.", + "rov_msg_fenrir_beast_tired": "The beast is tired", + "rov_msg_fenrir_blood_will_not_take_something": "The blood will not take. Something in the plains has to fall first.", + "rov_msg_fenrir_form_cooldown": "$1 form is on cooldown ($2:$3).", + "rov_msg_fenrir_formname_cultist": "Cultist", + "rov_msg_fenrir_formname_fenrir": "Fenrir", + "rov_msg_fenrir_has_already_had_one": "It has already had one.", + "rov_msg_fenrir_only_breath_comes_out_fire": "Only breath comes out. The fire wants eitr.", + "rov_msg_fenrir_ready": "$1 is Ready!", + "rov_msg_fenrir_returned_human_form": "You returned to human form.", + "rov_msg_fenrir_trough_broken_will_not_outlast": "The trough is broken. $1 will not outlast it by long.", + "rov_msg_fenrir_trough_takes_line_runs_deeper": "The trough takes it. The line runs deeper now.", + "rov_msg_fenrir_wants_meat_any_meat": "It wants meat. Any meat.", + "rov_msg_fenrir_wants_what_yagluth_left_behind": "It wants what Yagluth left behind.", + "rov_msg_skadi_are_drake": "You are a Drake!", + "rov_msg_skadi_are_fader": "You are Fader!", + "rov_msg_skadi_are_moder": "You are Moder!", + "rov_msg_skadi_dragon_form_cooldown": "Dragon Form is on cooldown ($1:$2).", + "rov_msg_skadi_dragon_form_fades": "Your dragon form fades.", + "rov_msg_skadi_dumped_dragon_drake_fader_debug": "Dumped Dragon/Drake/Fader debug info to console!", + "rov_msg_skadi_needs_stonecutter_cut_at": "It needs a stonecutter to be cut at.", + "rov_msg_skadi_not_enough_stamina": "Not enough stamina", + "rov_msg_skadi_returned_human_form": "You returned to human form.", + "rov_msg_skadi_stone_does_not_answer": "The stone does not answer to you.", + "rov_msg_skadi_stonecutter_gone_what_cut_will": "The stonecutter is gone. What it cut will not outlast it by long.", + "rov_msg_skadi_tear_cold_nothing_wakes_stone": "The tear is cold. Nothing wakes in the stone until the mountain's queen has fallen.", + "rov_msg_skadi_that_stonecutter_already_holds_will": "That stonecutter already holds $1. It will not hold more.", + "rov_msg_skadi_there_are_already_these_within": "There are already $1 of these within a day's walk. The stone is spent.", + "rov_msg_skeleton_has_already_had_one": "It has already had one.", + "rov_msg_skeleton_have_been_resurrected_by_dark": "You have been resurrected by dark magic!", + "rov_msg_skeleton_mortal_food_disgusts": "Mortal food disgusts you.", + "rov_msg_skeleton_nothing_standing_yet_wants_bone": "Nothing is standing yet. It wants bone.", + "rov_msg_skeleton_pile_broken_fall_where_they": "The pile is broken. $1 fall where they stand.", + "rov_msg_skeleton_pile_deepens_rotten_will_stand": "The pile deepens. The rotten will stand here too.", + "rov_msg_skeleton_return_pile": "$1 return to the pile.", + "rov_msg_skeleton_rise_follow": "$1 rise and follow.", + "rov_msg_skeleton_skeletons_do_not_need_eat": "Skeletons do not need to eat.", + "rov_msg_skeleton_skull_will_not_wake_something": "The skull will not wake. Something older has to fall first.", + "rov_msg_skeleton_these_bones_answer_only_their": "These bones answer only to their own kind.", + "rov_msg_skeleton_this_pile_cannot_hold_rotten": "This pile cannot hold the rotten yet.", + "rov_msg_sverm_alchemical_blood_not_food": "Alchemical blood is not food.", + "rov_msg_sverm_carapace_has_no_room_that": "Your carapace has no room for that.", + "rov_msg_sverm_colony_will_not_wake_until": "The colony will not wake until the Elder falls.", + "rov_msg_sverm_hive_does_not_know": "The hive does not know you.", + "rov_msg_sverm_hive_full_give_time_digest": "The hive is full. Give it time to digest.", + "rov_msg_sverm_market_has_stand_within_metres": "A market has to stand within $1 metres of a hive.", + "rov_msg_sverm_no_hive_within_metres_this": "No hive within $1 metres. This counter is dead.", + "rov_msg_sverm_not_enough_biomass_bank": "Not enough biomass in the bank.", + "rov_msg_sverm_not_hurt": "$1 is not hurt.", + "rov_msg_sverm_nothing_here_will_eat_food": "Nothing here it will eat. Food, wood and resin - honey and royal jelly are medicine.", + "rov_msg_sverm_only_sverm_can_raise_hive": "Only the Sverm can raise a hive.", + "rov_msg_sverm_only_sverm_can_raise_market": "Only the Sverm can raise a market.", + "rov_msg_sverm_ravager_strain_takes_hold": "The Ravager Strain takes hold.", + "rov_msg_sverm_shell_recedes": "The shell recedes.", + "rov_msg_sverm_strain_has_not_taken_yet": "The strain has not taken yet.", + "rov_msg_sverm_strain_spent": "The strain is spent.", + "rov_msg_sverm_they_are_part_hands": "They are part of your hands.", + "rov_msg_sverm_x_biomass_digesting": "$1 x$2 -> +$3 biomass, digesting", + "rov_msg_thrall_answer_call": "$1 answer the call.", + "rov_msg_thrall_follows": "$1 follows.", + "rov_msg_thrall_no_more_may_walk_with": "No more may walk with you.", + "rov_msg_thrall_only_may_walk_with": "Only $1 may walk with you.", + "rov_msg_thrall_refusal_default": "It does not answer to you.", + "rov_msg_thrall_refusal_draugh": "The dead do not take orders from the living.", + "rov_msg_thrall_refusal_dvergar": "Your name is not on the contract.", + "rov_msg_thrall_refusal_skeleton": "These bones answer only to their own kind.", + "rov_msg_thrall_refusal_sverm": "It does not smell your colony on you.", + "rov_msg_thrall_refusal_trol": "They were not paid by you.", + "rov_msg_thrall_returns": "$1 returns.", + "rov_msg_thrall_rises_with": "$1 rises with $2.", + "rov_msg_thrall_stands_down_with": "$1 stands down with $2.", + "rov_msg_trenta_are_muspell_ash_ember_given": "You are Muspell, ash and ember given shape.", + "rov_msg_trenta_elder_has_not_fallen_yet": "The Elder has not fallen yet.", + "rov_msg_trenta_grows": "It grows.", + "rov_msg_trenta_no_raw_flesh_rot": "No raw flesh to rot.", + "rov_msg_trenta_nothing_feed_wants_fertilizer": "Nothing to feed it. It wants Fertilizer.", + "rov_msg_trenta_nothing_there_feed": "Nothing there to feed.", + "rov_msg_trenta_return_rooted_form": "You return to your rooted form.", + "rov_msg_trenta_ripe_already": "It is ripe already.", + "rov_msg_trenta_root_will_not_take_hold": "The root will not take hold for you.", + "rov_msg_trenta_still_growing_minutes": "Still growing. $1 minutes.", + "rov_msg_trenta_still_rotting_minutes": "Still rotting. $1 minutes.", + "rov_msg_trenta_this_one_not_well_nothing": "This one is not well. Nothing will hurry it.", + "rov_msg_trenta_trenta_eat_only_what_grows": "The Trenta eat only what grows from root and leaf - no meat, fish, egg or honey.", + "rov_msg_trol_answers": "$1 answers.", + "rov_msg_trol_are_already_holding_log": "You are already holding a log!", + "rov_msg_trol_five_warbands_all_can_shout": "Five warbands is all it can shout for.", + "rov_msg_trol_has_already_had_one": "It has already had one.", + "rov_msg_trol_head_has_nothing_say": "The head has nothing to say.", + "rov_msg_trol_head_will_not_shout": "The head will not shout for you.", + "rov_msg_trol_must_true_form_lift_this": "You must be in True Form to lift this!", + "rov_msg_trol_no_room_lift": "No room to lift it!", + "rov_msg_trol_not_until_one_belonged_has": "Not until the one it belonged to has fallen.", + "rov_msg_trol_totem_wears_king_now": "The totem wears a king now.", + "rov_msg_ward_already_carry_s_power": "You already carry $1's power.", + "rov_msg_ward_s_power_yours": "$1's power is yours.", + "rov_msg_ward_switch_personal_progression_first": "Switch to personal progression first.", + "rov_msg_ward_ward_has_no_use_that": "The ward has no use for that.", + "rov_msg_warvulture_bird_does_not_know": "The bird does not know you.", + "rov_msg_warvulture_vulture_does_not_answer": "The vulture does not answer.", + "rov_msg_warvulture_vulture_settles_into_glide": "The vulture settles into a glide.", + "rov_msg_warvulture_vulture_spirals_down": "The vulture spirals down." +} diff --git a/JotunnModStub/Translations/Italian/messages.json b/JotunnModStub/Translations/Italian/messages.json new file mode 100644 index 0000000..b03faf1 --- /dev/null +++ b/JotunnModStub/Translations/Italian/messages.json @@ -0,0 +1,193 @@ +{ + "rov_msg_aswid_aura_disabled": "Aura vampirica: DISATTIVATA", + "rov_msg_aswid_aura_enabled": "Aura vampirica: ATTIVATA", + "rov_msg_aswid_dominate_cooldown_m_s": "Dominio in ricarica ($1m $2s)", + "rov_msg_aswid_dominated": "$1 dominato!", + "rov_msg_aswid_eclipse_cooldown_remaining_s": "L'Eclissi è in ricarica. Mancano: $1s", + "rov_msg_aswid_eclipse_descends": "Un'Eclissi discende...", + "rov_msg_aswid_eclipse_has_ended": "L'Eclissi è finita.", + "rov_msg_aswid_following": "$1 ti segue.", + "rov_msg_aswid_living_blood_curdles_living_throat": "Il sangue vivo si rapprende in una gola viva.", + "rov_msg_aswid_morning_sun_drives_bat_back": "Il sole del mattino ricaccia il pipistrello nel tuo corpo", + "rov_msg_aswid_morning_sun_has_vanquished_horrible": "Il sole del mattino ha sconfitto l'orribile notte", + "rov_msg_aswid_no_bone_grind": "Nessun osso da macinare.", + "rov_msg_aswid_no_raw_flesh_render": "Nessuna carne cruda da raffinare.", + "rov_msg_aswid_staying": "$1 resta qui.", + "rov_msg_aswid_sun_burns_can_only_take": "Il sole brucia. Puoi prendere la forma di pipistrello solo di notte.", + "rov_msg_aswid_tamed": "Addomesticato!", + "rov_msg_aswid_vae_victis": "Vae Victis", + "rov_msg_aswid_what_horrible_night_have_curse": "che notte orribile per avere una maledizione", + "rov_msg_build_limit_cooktable": "C'è già un altro tavolo del cuoco entro quaranta passi. Un cuoco per cortile.", + "rov_msg_build_limit_draugh_bodypile": "Questo terreno ne porta già $1. Trova un'altra contrada.", + "rov_msg_build_limit_dvergar_contractbank": "C'è già $1 banca dei contratti a una giornata di cammino. Un registro per valle.", + "rov_msg_build_limit_fenrir_packtrough": "Ce n'è già $1 a una giornata di cammino. Un branco ha bisogno di spazio.", + "rov_msg_build_limit_skeleton_bonepile": "Ce ne sono già $1 in ascolto qui vicino. Portalo più lontano.", + "rov_msg_build_limit_smithtable": "C'è già un altro tavolo del fabbro entro quaranta passi. Un fabbro per cortile.", + "rov_msg_build_limit_sverm_hive": "C'è già un alveare che occupa questo terreno.", + "rov_msg_build_limit_sverm_market": "Questo alveare ha già un mercato.", + "rov_msg_build_limit_trenta_grove": "Questa contrada ne ospita già $1. Piantalo altrove.", + "rov_msg_build_this_cave_will_hold_what": "Questa grotta terrà ciò che vi costruisci.", + "rov_msg_butler_already_at_work": "È già al lavoro.", + "rov_msg_butler_bones_are_not_ready_s": "Le ossa non sono pronte. $1s.", + "rov_msg_butler_bones_do_not_answer_blood": "Le ossa non rispondono al tuo sangue.", + "rov_msg_butler_nothing_answers": "Niente risponde.", + "rov_msg_butler_only_skadi_s_hearth_kept": "Solo il focolare di Skadi è tenuto dai morti.", + "rov_msg_butler_servant_rises": "Il servitore si alza.", + "rov_msg_claws_they_are_part_hands": "Fanno parte delle tue mani.", + "rov_msg_core_chose_path_aswid": "Hai scelto la via degli Aswid.", + "rov_msg_core_chose_path_draugh": "Hai scelto la via dei Draugh.", + "rov_msg_core_chose_path_dvergar": "Hai scelto la via dei Dvergar.", + "rov_msg_core_chose_path_fenrir": "Hai scelto la via dei Fenrir.", + "rov_msg_core_chose_path_furling": "Hai scelto la via dei Furling.", + "rov_msg_core_chose_path_skadi": "Hai scelto la via di Skadi.", + "rov_msg_core_chose_path_skeleton": "Hai scelto la via degli Scheletri.", + "rov_msg_core_chose_path_sverm": "Hai scelto la via degli Sverm.", + "rov_msg_core_chose_path_trenta": "Hai scelto la via dei Trenta.", + "rov_msg_core_chose_path_trol": "Hai scelto la via dei Trol.", + "rov_msg_core_chose_remain_human": "Hai scelto di restare Umano.", + "rov_msg_core_debug_override_cleared": "Override di debug rimosso.", + "rov_msg_core_nothing_reset_personal": "Niente da azzerare: non hai ancora reclamato reliquie ($1/$2).", + "rov_msg_core_nothing_reset_world": "Niente da azzerare: segui la progressione del mondo: $1 ($2/$3).", + "rov_msg_core_progression_reset": "Progressione personale azzerata a $1 ($2/$3). Reclama di nuovo le tue reliquie.", + "rov_msg_core_progression_state": "Stato di progressione: $1", + "rov_msg_core_world_progression_state": "Stato di progressione del mondo: $1", + "rov_msg_draugh_bone_will_not_wake_something": "L'osso non si sveglia. Qualcosa di più antico deve cadere prima.", + "rov_msg_draugh_draugr_consume_only_raw_flesh": "I Draugr consumano solo carne cruda, occhi, interiora o sangue.", + "rov_msg_draugh_has_already_had_one": "Ne ha già avuto uno.", + "rov_msg_draugh_northern_wind_blows": "Soffia il vento del nord", + "rov_msg_draugh_pile_broken_will_not_outlast": "Il mucchio è distrutto. $1 non gli sopravviveranno più di un minuto.", + "rov_msg_draugh_pile_stirs_will_keep_officers": "Il mucchio si agita. Ora terrà anche degli ufficiali.", + "rov_msg_draugh_steal_their_breath_death_denied": "Ruba il loro respiro! La morte è negata.", + "rov_msg_draugh_swarm_terror": "Sciame del terrore!", + "rov_msg_draugh_this_pile_keeps_no_officers": "Questo mucchio non tiene ancora ufficiali.", + "rov_msg_draugh_this_rotting_flesh_fatal_living": "Questa carne putrefatta è letale per i vivi.", + "rov_msg_draugh_wants_flesh_or_head_one": "Vuole carne, o la testa di uno dei suoi.", + "rov_msg_draugh_zombie_ritual_activated_borrowed_time": "Rituale zombie attivato! Il tuo tempo in prestito sta svanendo...", + "rov_msg_dvergar_contract_runic_do_not_sign": "Il contratto è in runico. Non lo firmi.", + "rov_msg_dvergar_do_not_know_what_goes": "Non sai cosa ci va dentro.", + "rov_msg_dvergar_drink": "$1 bevono $2.", + "rov_msg_dvergar_drink_barrel_runs_dry": "$1 bevono $2. Il barile si svuota.", + "rov_msg_dvergar_empty_so_are": "È vuoto, e lo sei anche tu.", + "rov_msg_dvergar_five_contracts_all_ledger_holds": "Cinque contratti è tutto ciò che il registro contiene.", + "rov_msg_dvergar_has_already_had_one": "Ne ha già avuto uno.", + "rov_msg_dvergar_ledger_not_written": "Il registro non è scritto per te.", + "rov_msg_dvergar_ledger_rewritten_better_names_sign": "Il registro è riscritto. Ora lo firmano nomi migliori.", + "rov_msg_dvergar_ledger_shut": "Il registro è chiuso.", + "rov_msg_dvergar_nobody_at_barrel": "Non c'è nessuno al barile.", + "rov_msg_dvergar_not_drop_went_down": "Non è andata giù nemmeno una goccia.", + "rov_msg_dvergar_not_enough_eitr": "Eitr insufficiente", + "rov_msg_dvergar_not_while_she_still_sits": "Non finché lei siede ancora sotto la nebbia.", + "rov_msg_dvergar_runic_overcharge_discharges": "Il sovraccarico runico si scarica", + "rov_msg_dvergar_runic_overcharge_next_blow_loaded": "Sovraccarico runico: il tuo prossimo colpo è carico", + "rov_msg_dvergar_runic_ping_echoes_answer": "Richiamo runico: rispondono $1 echi", + "rov_msg_dvergar_runic_ping_stone_silent": "Richiamo runico: la pietra tace", + "rov_msg_dvergar_signs": "$1 firma.", + "rov_msg_dvergar_there_still": "C'è ancora $1 dentro.", + "rov_msg_dvergar_whatever_does_nothing_anyone": "Qualunque cosa ci sia dentro, non fa niente a nessuno.", + "rov_msg_fenrir_are_cultist": "Sei un Cultista!", + "rov_msg_fenrir_are_fenring": "Sei un Fenring!", + "rov_msg_fenrir_are_ulv": "Sei un Ulv!", + "rov_msg_fenrir_are_wolf": "Sei un Lupo!", + "rov_msg_fenrir_beast_rests_can_only_transform": "La bestia riposa. Puoi trasformarti solo di notte.", + "rov_msg_fenrir_beast_tired": "La bestia è stanca", + "rov_msg_fenrir_blood_will_not_take_something": "Il sangue non attecchisce. Qualcosa nelle pianure deve cadere prima.", + "rov_msg_fenrir_form_cooldown": "La forma $1 è in ricarica ($2:$3).", + "rov_msg_fenrir_formname_cultist": "Cultista", + "rov_msg_fenrir_formname_fenrir": "Fenrir", + "rov_msg_fenrir_has_already_had_one": "Ne ha già avuto uno.", + "rov_msg_fenrir_only_breath_comes_out_fire": "Esce solo fiato. Il fuoco vuole eitr.", + "rov_msg_fenrir_ready": "$1 è pronto!", + "rov_msg_fenrir_returned_human_form": "Sei tornato in forma umana.", + "rov_msg_fenrir_trough_broken_will_not_outlast": "La mangiatoia è distrutta. $1 non le sopravviveranno a lungo.", + "rov_msg_fenrir_trough_takes_line_runs_deeper": "La mangiatoia lo accetta. Ora la discendenza va più a fondo.", + "rov_msg_fenrir_wants_meat_any_meat": "Vuole carne. Qualsiasi carne.", + "rov_msg_fenrir_wants_what_yagluth_left_behind": "Vuole ciò che Yagluth ha lasciato.", + "rov_msg_skadi_are_drake": "Sei un Drake!", + "rov_msg_skadi_are_fader": "Sei Fader!", + "rov_msg_skadi_are_moder": "Sei Moder!", + "rov_msg_skadi_dragon_form_cooldown": "La forma di drago è in ricarica ($1:$2).", + "rov_msg_skadi_dragon_form_fades": "La tua forma di drago svanisce.", + "rov_msg_skadi_dumped_dragon_drake_fader_debug": "Info di debug Dragon/Drake/Fader scritte nella console!", + "rov_msg_skadi_needs_stonecutter_cut_at": "Ha bisogno di uno scalpellino per essere tagliato.", + "rov_msg_skadi_not_enough_stamina": "Stamina insufficiente", + "rov_msg_skadi_returned_human_form": "Sei tornato in forma umana.", + "rov_msg_skadi_stone_does_not_answer": "La pietra non ti risponde.", + "rov_msg_skadi_stonecutter_gone_what_cut_will": "Lo scalpellino non c'è più. Ciò che ha tagliato non gli sopravviverà a lungo.", + "rov_msg_skadi_tear_cold_nothing_wakes_stone": "La lacrima è fredda. Niente si sveglia nella pietra finché la regina della montagna non è caduta.", + "rov_msg_skadi_that_stonecutter_already_holds_will": "Quello scalpellino ne tiene già $1. Non ne terrà altri.", + "rov_msg_skadi_there_are_already_these_within": "Ce ne sono già $1 a una giornata di cammino. La pietra è esaurita.", + "rov_msg_skeleton_has_already_had_one": "Ne ha già avuto uno.", + "rov_msg_skeleton_have_been_resurrected_by_dark": "Sei stato resuscitato dalla magia oscura!", + "rov_msg_skeleton_mortal_food_disgusts": "Il cibo dei mortali ti disgusta.", + "rov_msg_skeleton_nothing_standing_yet_wants_bone": "Non c'è ancora niente in piedi. Vuole ossa.", + "rov_msg_skeleton_pile_broken_fall_where_they": "Il mucchio è distrutto. $1 cadono dove si trovano.", + "rov_msg_skeleton_pile_deepens_rotten_will_stand": "Il mucchio si fa più profondo. Anche i rancidi si alzeranno qui.", + "rov_msg_skeleton_return_pile": "$1 tornano al mucchio.", + "rov_msg_skeleton_rise_follow": "$1 si alzano e ti seguono.", + "rov_msg_skeleton_skeletons_do_not_need_eat": "Gli scheletri non hanno bisogno di mangiare.", + "rov_msg_skeleton_skull_will_not_wake_something": "Il teschio non si sveglia. Qualcosa di più antico deve cadere prima.", + "rov_msg_skeleton_these_bones_answer_only_their": "Queste ossa rispondono solo ai loro simili.", + "rov_msg_skeleton_this_pile_cannot_hold_rotten": "Questo mucchio non può ancora tenere i rancidi.", + "rov_msg_sverm_alchemical_blood_not_food": "Il sangue alchemico non è cibo.", + "rov_msg_sverm_carapace_has_no_room_that": "Il tuo carapace non ha spazio per quello.", + "rov_msg_sverm_colony_will_not_wake_until": "La colonia non si sveglierà finché l'Antico non sarà caduto.", + "rov_msg_sverm_hive_does_not_know": "L'alveare non ti conosce.", + "rov_msg_sverm_hive_full_give_time_digest": "L'alveare è pieno. Dagli tempo di digerire.", + "rov_msg_sverm_market_has_stand_within_metres": "Un mercato deve stare entro $1 metri da un alveare.", + "rov_msg_sverm_no_hive_within_metres_this": "Nessun alveare entro $1 metri. Questo bancone è morto.", + "rov_msg_sverm_not_enough_biomass_bank": "Non c'è abbastanza biomassa nella riserva.", + "rov_msg_sverm_not_hurt": "$1 non è ferito.", + "rov_msg_sverm_nothing_here_will_eat_food": "Qui non c'è niente che mangerebbe. Cibo, legno e resina: miele e pappa reale sono medicine.", + "rov_msg_sverm_only_sverm_can_raise_hive": "Solo gli Sverm possono far sorgere un alveare.", + "rov_msg_sverm_only_sverm_can_raise_market": "Solo gli Sverm possono far sorgere un mercato.", + "rov_msg_sverm_ravager_strain_takes_hold": "Il Ceppo Devastatore attecchisce.", + "rov_msg_sverm_shell_recedes": "Il guscio si ritrae.", + "rov_msg_sverm_strain_has_not_taken_yet": "Il ceppo non ha ancora attecchito.", + "rov_msg_sverm_strain_spent": "Il ceppo è esaurito.", + "rov_msg_sverm_they_are_part_hands": "Fanno parte delle tue mani.", + "rov_msg_sverm_x_biomass_digesting": "$1 x$2 -> +$3 biomassa, in digestione", + "rov_msg_thrall_answer_call": "$1 rispondono alla chiamata.", + "rov_msg_thrall_follows": "$1 ti segue.", + "rov_msg_thrall_no_more_may_walk_with": "Nessun altro può camminare con te.", + "rov_msg_thrall_only_may_walk_with": "Solo $1 possono camminare con te.", + "rov_msg_thrall_refusal_default": "Non ti risponde.", + "rov_msg_thrall_refusal_draugh": "I morti non prendono ordini dai vivi.", + "rov_msg_thrall_refusal_dvergar": "Il tuo nome non è sul contratto.", + "rov_msg_thrall_refusal_skeleton": "Queste ossa rispondono solo ai loro simili.", + "rov_msg_thrall_refusal_sverm": "Non sente l'odore della tua colonia su di te.", + "rov_msg_thrall_refusal_trol": "Non li hai pagati tu.", + "rov_msg_thrall_returns": "$1 torna indietro.", + "rov_msg_thrall_rises_with": "$1 si alza con $2.", + "rov_msg_thrall_stands_down_with": "$1 si ritira con $2.", + "rov_msg_trenta_are_muspell_ash_ember_given": "Sei Muspell, cenere e brace fatte forma.", + "rov_msg_trenta_elder_has_not_fallen_yet": "L'Antico non è ancora caduto.", + "rov_msg_trenta_grows": "Cresce.", + "rov_msg_trenta_no_raw_flesh_rot": "Nessuna carne cruda da far marcire.", + "rov_msg_trenta_nothing_feed_wants_fertilizer": "Niente con cui nutrirlo. Vuole fertilizzante.", + "rov_msg_trenta_nothing_there_feed": "Non c'è niente da nutrire.", + "rov_msg_trenta_return_rooted_form": "Torni alla tua forma radicata.", + "rov_msg_trenta_ripe_already": "È già maturo.", + "rov_msg_trenta_root_will_not_take_hold": "La radice non attecchisce per te.", + "rov_msg_trenta_still_growing_minutes": "Sta ancora crescendo. $1 minuti.", + "rov_msg_trenta_still_rotting_minutes": "Sta ancora marcendo. $1 minuti.", + "rov_msg_trenta_this_one_not_well_nothing": "Questo non sta bene. Niente lo farà affrettare.", + "rov_msg_trenta_trenta_eat_only_what_grows": "I Trenta mangiano solo ciò che nasce da radice e foglia: niente carne, pesce, uova o miele.", + "rov_msg_trol_answers": "$1 risponde.", + "rov_msg_trol_are_already_holding_log": "Stai già tenendo un tronco!", + "rov_msg_trol_five_warbands_all_can_shout": "Cinque bande da guerra è tutto ciò che può chiamare.", + "rov_msg_trol_has_already_had_one": "Ne ha già avuto uno.", + "rov_msg_trol_head_has_nothing_say": "La testa non ha niente da dire.", + "rov_msg_trol_head_will_not_shout": "La testa non urlerà per te.", + "rov_msg_trol_must_true_form_lift_this": "Devi essere nella Vera forma per sollevarlo!", + "rov_msg_trol_no_room_lift": "Non c'è spazio per sollevarlo!", + "rov_msg_trol_not_until_one_belonged_has": "Non finché colui a cui apparteneva non sarà caduto.", + "rov_msg_trol_totem_wears_king_now": "Ora il totem porta un re.", + "rov_msg_ward_already_carry_s_power": "Porti già il potere di $1.", + "rov_msg_ward_s_power_yours": "Il potere di $1 è tuo.", + "rov_msg_ward_switch_personal_progression_first": "Passa prima alla progressione personale.", + "rov_msg_ward_ward_has_no_use_that": "Al sigillo non serve.", + "rov_msg_warvulture_bird_does_not_know": "L'uccello non ti conosce.", + "rov_msg_warvulture_vulture_does_not_answer": "L'avvoltoio non risponde.", + "rov_msg_warvulture_vulture_settles_into_glide": "L'avvoltoio si mette a planare.", + "rov_msg_warvulture_vulture_spirals_down": "L'avvoltoio scende a spirale." +} diff --git a/JotunnModStub/Trenta/ComposterBehaviour.cs b/JotunnModStub/Trenta/ComposterBehaviour.cs index 4dd7524..82c9871 100644 --- a/JotunnModStub/Trenta/ComposterBehaviour.cs +++ b/JotunnModStub/Trenta/ComposterBehaviour.cs @@ -98,7 +98,7 @@ namespace RacesOfValheim if (state == State.Composting) { - user.Message(MessageHud.MessageType.Center, $"Still rotting. {MinutesLeft()} minutes."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_still_rotting_minutes", MinutesLeft())); return false; } @@ -108,7 +108,7 @@ namespace RacesOfValheim if (item == null) item = FindFlesh(inventory); if (item == null) { - user.Message(MessageHud.MessageType.Center, "No raw flesh to rot."); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_no_raw_flesh_rot")); return false; } diff --git a/JotunnModStub/Trenta/GroveBehaviour.cs b/JotunnModStub/Trenta/GroveBehaviour.cs index 0d0fde3..64f3989 100644 --- a/JotunnModStub/Trenta/GroveBehaviour.cs +++ b/JotunnModStub/Trenta/GroveBehaviour.cs @@ -274,9 +274,7 @@ namespace RacesOfValheim if (item == null) item = FindFertilizer(inventory); if (item == null) { - user.Message(MessageHud.MessageType.Center, IsGrown() - ? "Nothing to feed it. It wants Fertilizer." - : $"Still growing. {MinutesLeft()} minutes."); + user.Message(MessageHud.MessageType.Center, (IsGrown() ? ModText.Get("rov_msg_trenta_nothing_feed_wants_fertilizer") : ModText.Get("rov_msg_trenta_still_growing_minutes", MinutesLeft()))); return false; } diff --git a/JotunnModStub/Trenta/TrentaComposter.cs b/JotunnModStub/Trenta/TrentaComposter.cs index 914ec5e..64bcf5d 100644 --- a/JotunnModStub/Trenta/TrentaComposter.cs +++ b/JotunnModStub/Trenta/TrentaComposter.cs @@ -387,19 +387,19 @@ namespace RacesOfValheim { case GrowOutcome.Grown: if (inventory != null) inventory.RemoveItem(item, 1); - player.Message(MessageHud.MessageType.Center, "It grows."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_grows")); break; case GrowOutcome.AlreadyRipe: - player.Message(MessageHud.MessageType.Center, "It is ripe already."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_ripe_already")); break; case GrowOutcome.Unhealthy: - player.Message(MessageHud.MessageType.Center, "This one is not well. Nothing will hurry it."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_this_one_not_well_nothing")); break; case GrowOutcome.NoTarget: - player.Message(MessageHud.MessageType.Center, "Nothing there to feed."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_nothing_there_feed")); break; default: diff --git a/JotunnModStub/Trenta/TrentaElderRoot.cs b/JotunnModStub/Trenta/TrentaElderRoot.cs index d36d67c..ba21936 100644 --- a/JotunnModStub/Trenta/TrentaElderRoot.cs +++ b/JotunnModStub/Trenta/TrentaElderRoot.cs @@ -291,13 +291,13 @@ namespace RacesOfValheim if (!TrentaRace.IsTrenta()) { - __instance.Message(MessageHud.MessageType.Center, "The root will not take hold for you."); + __instance.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_root_will_not_take_hold")); return false; } if (BossProgressionManager.GetCurrentProgressionState() < TrentaConfig.ElderRootUnlockState) { - __instance.Message(MessageHud.MessageType.Center, "The Elder has not fallen yet."); + __instance.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_elder_has_not_fallen_yet")); return false; } diff --git a/JotunnModStub/Trenta/TrentaFoodPatches.cs b/JotunnModStub/Trenta/TrentaFoodPatches.cs index f083369..bc17d19 100644 --- a/JotunnModStub/Trenta/TrentaFoodPatches.cs +++ b/JotunnModStub/Trenta/TrentaFoodPatches.cs @@ -81,7 +81,7 @@ namespace RacesOfValheim if (TrentaConfig.VeganFoodPrefabNames.Contains(prefabName)) return true; - player.Message(MessageHud.MessageType.Center, "The Trenta eat only what grows from root and leaf - no meat, fish, egg or honey."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_trenta_eat_only_what_grows")); return false; // Block consumption } } diff --git a/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs b/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs index a8ca08c..ce9f741 100644 --- a/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs +++ b/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs @@ -39,7 +39,7 @@ namespace RacesOfValheim PieceDensityLimit.Register(TrentaConfig.GrovePieceName, PieceDensityLimit.RadiusForArea(TrentaConfig.GroveDensityAreaKm2), TrentaConfig.GroveMaxInRange, - "This country already answers to {0} of these. Plant it somewhere else."); + "rov_msg_build_limit_trenta_grove"); } // ---------------------------------------------------------------- the seed diff --git a/JotunnModStub/Trenta/TrentaMuspell.cs b/JotunnModStub/Trenta/TrentaMuspell.cs index 6f7fbf6..2864acf 100644 --- a/JotunnModStub/Trenta/TrentaMuspell.cs +++ b/JotunnModStub/Trenta/TrentaMuspell.cs @@ -185,7 +185,7 @@ namespace RacesOfValheim IsTransformed = true; - player.Message(MessageHud.MessageType.Center, "You are Muspell, ash and ember given shape."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_are_muspell_ash_ember_given")); } private static void ExecuteReversion(Player player) @@ -208,7 +208,7 @@ namespace RacesOfValheim IsTransformed = false; - player.Message(MessageHud.MessageType.Center, "You return to your rooted form."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trenta_return_rooted_form")); } } diff --git a/JotunnModStub/Trol/TrolLogWeapon.cs b/JotunnModStub/Trol/TrolLogWeapon.cs index fa42538..f315494 100644 --- a/JotunnModStub/Trol/TrolLogWeapon.cs +++ b/JotunnModStub/Trol/TrolLogWeapon.cs @@ -19,7 +19,7 @@ namespace RacesOfValheim if (!seman.HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode())) { - user.Message(MessageHud.MessageType.Center, "You must be in True Form to lift this!"); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_must_true_form_lift_this")); return; } @@ -47,7 +47,7 @@ namespace RacesOfValheim ItemDrop.ItemData rightItem = HarmonyLib.Traverse.Create(user).Field("m_rightItem").Value; if (rightItem != null && rightItem.m_dropPrefab != null && rightItem.m_dropPrefab.name.StartsWith("TrolWeapon_")) { - user.Message(MessageHud.MessageType.Center, "You are already holding a log!"); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_are_already_holding_log")); return; } @@ -80,7 +80,7 @@ namespace RacesOfValheim Vector2i gridPos = HarmonyLib.Traverse.Create(user.GetInventory()).Method("FindEmptySlot", false).GetValue(); if (gridPos.x == -1) { - user.Message(MessageHud.MessageType.Center, "No room to lift it!"); + user.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_no_room_lift")); return; } newItem.m_gridPos = gridPos; diff --git a/JotunnModStub/Trol/TrolTotem.cs b/JotunnModStub/Trol/TrolTotem.cs index 512437b..9187631 100644 --- a/JotunnModStub/Trol/TrolTotem.cs +++ b/JotunnModStub/Trol/TrolTotem.cs @@ -190,7 +190,7 @@ namespace RacesOfValheim thrall.m_maxFollowers = MaxFollowers; thrall.m_witherSeconds = WitherSeconds; thrall.m_homeCheckRange = HomeCheckRange; - thrall.m_refusalMessage = "They were not paid by you."; + thrall.m_refusalMessage = "$rov_msg_thrall_refusal_trol"; // The sentry's regeneration, reused whole: untouched for ten seconds, then two percent a // second. "Rigenerarsi come i nostri scheletri" is the healing, not a respawn - a dead @@ -374,7 +374,7 @@ namespace RacesOfValheim if (Utils.GetPrefabName(__0.gameObject) != TrolTotem.PieceName) return true; if (TrolRace.IsTrol()) return true; - __instance.Message(MessageHud.MessageType.Center, "The head will not shout for you."); + __instance.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_head_will_not_shout")); return false; } } diff --git a/JotunnModStub/Trol/TrolTotemBehaviour.cs b/JotunnModStub/Trol/TrolTotemBehaviour.cs index 4543646..b567f9d 100644 --- a/JotunnModStub/Trol/TrolTotemBehaviour.cs +++ b/JotunnModStub/Trol/TrolTotemBehaviour.cs @@ -70,7 +70,7 @@ namespace RacesOfValheim if (!TrolRace.IsTrol()) { - player.Message(MessageHud.MessageType.Center, "The head will not shout for you."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_head_will_not_shout")); // With an item in hand, false makes Humanoid.UseItem cover this message with its // generic "$msg_cantuseon"; true tells it the use was handled here. return item != null; @@ -97,19 +97,19 @@ namespace RacesOfValheim { if (IsUpgraded()) { - player.Message(MessageHud.MessageType.Center, "It has already had one."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_has_already_had_one")); return true; } if (BossProgressionManager.GetCurrentProgressionState() < TrolTotem.UpgradeProgressionState) { - player.Message(MessageHud.MessageType.Center, "Not until the one it belonged to has fallen."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_not_until_one_belonged_has")); return true; } player.GetInventory().RemoveItem(item, 1); m_nview.InvokeRPC("RoV_TrolUpgrade"); - player.Message(MessageHud.MessageType.Center, "The totem wears a king now."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_totem_wears_king_now")); return true; } @@ -123,7 +123,7 @@ namespace RacesOfValheim Trader trader = GetComponent(); if (trader == null || StoreGui.instance == null) { - player.Message(MessageHud.MessageType.Center, "The head has nothing to say."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_head_has_nothing_say")); return false; } @@ -148,7 +148,7 @@ namespace RacesOfValheim if (CountGroups() >= TrolTotem.MaxTroops) { - player.Message(MessageHud.MessageType.Center, "Five warbands is all it can shout for."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_five_warbands_all_can_shout")); return; } @@ -163,7 +163,7 @@ namespace RacesOfValheim TakeCoins(inventory, troop.Price); m_nview.InvokeRPC("RoV_TrolHire", troop.Id); - player.Message(MessageHud.MessageType.Center, $"{troop.Display} answers."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_trol_answers", troop.Display)); } private const string CoinsPrefab = "Coins"; diff --git a/JotunnModStub/WarVulture/WarVultureMount.cs b/JotunnModStub/WarVulture/WarVultureMount.cs index 1d8646a..3667b5d 100644 --- a/JotunnModStub/WarVulture/WarVultureMount.cs +++ b/JotunnModStub/WarVulture/WarVultureMount.cs @@ -113,13 +113,13 @@ namespace RacesOfValheim if (!WarVultureConfig.RaceAllowed(race)) { - rider.Message(MessageHud.MessageType.Center, "The bird does not know you."); + rider.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_warvulture_bird_does_not_know")); return; } if (!WarVultureVisual.Ready) { - rider.Message(MessageHud.MessageType.Center, "The vulture does not answer."); + rider.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_warvulture_vulture_does_not_answer")); Jotunn.Logger.LogWarning($"[{Label}] Call refused: the stripped model template was never built, " + "so there is no bird to show. The reason is logged at startup - and " + "refusing is deliberate, because the alternative is putting an unstripped " + @@ -245,7 +245,7 @@ namespace RacesOfValheim { landing = true; landingStartedAt = Time.time; - player.Message(MessageHud.MessageType.Center, "The vulture spirals down."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_warvulture_vulture_spirals_down")); } private void UpdateLanding() @@ -304,7 +304,7 @@ namespace RacesOfValheim wind = Mathf.Max(0f, wind - dt); if (wind <= 0f) { - player.Message(MessageHud.MessageType.Center, "The vulture settles into a glide."); + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_warvulture_vulture_settles_into_glide")); } } else if (wind < WarVultureConfig.SprintSeconds.Value) From 0a0d9410e76a3b6bae2aab06cb65776614ed8469 Mon Sep 17 00:00:00 2001 From: kanym Date: Sun, 27 Sep 2026 00:52:01 +0200 Subject: [PATCH 062/273] fix(skadi): Middle Mouse in Drake form no longer spends the attack cooldown on nothing PerformAttackCoroutine starts the cooldown and shows its icon before it looks at the form, and the Drake has no Middle Mouse attack, so the press cost a cooldown and fired nothing. HasAttackForButton now answers for the Drake too and guards all three buttons, as it already did Left Mouse. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Skadi/DrakeFormBehavior.cs | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index 53b9049..b86a59e 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -221,14 +221,14 @@ namespace RacesOfValheim } else if (SkadiConfig.BreathAttackKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(2)) { - if (Time.time - lastAttackTime >= ATTACK_COOLDOWN) + if (HasAttackForButton(2) && Time.time - lastAttackTime >= ATTACK_COOLDOWN) { StartCoroutine(PerformAttackCoroutine(2)); } } else if ((SkadiConfig.SpinAttackKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(1)) && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // Fader Spin { - if (Time.time - lastAttackTime >= ATTACK_COOLDOWN) + if (HasAttackForButton(1) && Time.time - lastAttackTime >= ATTACK_COOLDOWN) { StartCoroutine(PerformAttackCoroutine(1)); } @@ -236,13 +236,23 @@ namespace RacesOfValheim } } + // Whether this form has an attack on this button right now. Asked before the cooldown for + // every button, because PerformAttackCoroutine starts the cooldown and shows its icon before + // it looks at the form: a button with nothing behind it used to spend both and fire nothing. + // + // The Drake has only its Left Mouse volley; Middle Mouse is Moder's and Fader's breath. // Airborne Moder keeps the same hand as the ground: the ranged breath is Middle Mouse, and // Left Mouse has no attack in the air (its ground bite and claws cannot reach from up - // there). Checked before the cooldown so a stray left click does not eat the next volley. + // there). private bool HasAttackForButton(int button) { if (formRules == null) return false; + if (formRules.Form == SkadiProgression.FormType.Drake && button != 0) + { + return false; + } + bool airborne = isFlying || isLanding; if (airborne && formRules.Form == SkadiProgression.FormType.Moder && button != 2) { From 99a1817eb0c59e933a5dc19b5d9db33e9b98eaeb Mon Sep 17 00:00:00 2001 From: kanym Date: Mon, 28 Sep 2026 13:55:14 +0200 Subject: [PATCH 063/273] feat(text): hover texts come from translation files What the stations, thralls, the ward and the hive show under the crosshair now reads its text through ModText.Get, and hover.json holds 50 texts in English and Italian. The Aswid thralls and the Race Menu Ward wrote the use key as a literal E; they now use $KEY_Use, which shows the key the player actually bound. For that to work, ModText.Get runs a second localization pass when a $ is left in the result: Valheim resolves tokens once and never looks inside what it inserted, and hover texts go to the HUD without another pass. The Sverm hive stage names stay English for now: the compendium and the hive's goods show them too, and those come with the merchants step. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Aswid/AswidThrall.cs | 6 +-- JotunnModStub/Butler/ServantTableBehaviour.cs | 5 +- .../Draugh/DraughSpawnerBehaviour.cs | 9 ++-- .../Dvergar/DvergarBancoBehaviour.cs | 8 +-- .../Dvergar/DvergarBotteBehaviour.cs | 6 +-- .../Fenrir/FenrirMangiatoiaBehaviour.cs | 15 ++---- JotunnModStub/ModText.cs | 9 +++- JotunnModStub/RaceMenuWard.cs | 8 ++- .../Skeleton/SkeletonBonePileBehaviour.cs | 14 ++--- JotunnModStub/Sverm/SvermHive.cs | 6 +-- JotunnModStub/Sverm/SvermHiveStore.cs | 23 ++++---- JotunnModStub/Translations/English/hover.json | 52 +++++++++++++++++++ JotunnModStub/Translations/Italian/hover.json | 52 +++++++++++++++++++ JotunnModStub/Trenta/ComposterBehaviour.cs | 8 ++- JotunnModStub/Trenta/GroveBehaviour.cs | 16 +++--- JotunnModStub/Trol/TrolTotemBehaviour.cs | 6 +-- 16 files changed, 164 insertions(+), 79 deletions(-) create mode 100644 JotunnModStub/Translations/English/hover.json create mode 100644 JotunnModStub/Translations/Italian/hover.json diff --git a/JotunnModStub/Aswid/AswidThrall.cs b/JotunnModStub/Aswid/AswidThrall.cs index 638ce4e..9566bd9 100644 --- a/JotunnModStub/Aswid/AswidThrall.cs +++ b/JotunnModStub/Aswid/AswidThrall.cs @@ -142,15 +142,15 @@ namespace RacesOfValheim if (isEnslaved) { bool following = m_ai != null && m_ai.GetFollowTarget() != null; - return following ? "[E] Stay" : "[E] Follow"; + return (following ? ModText.Get("rov_hover_aswid_stay") : ModText.Get("rov_hover_aswid_follow")); } else { if (BossProgressionManager.GetCurrentProgressionState() < 6) return ""; float cd = AswidRace.GetEnslaveCooldown(); - if (cd > 0) return $"[E] Dominate (Cooldown: {Mathf.CeilToInt(cd / 60f)}m)"; - return "[E] Dominate"; + if (cd > 0) return ModText.Get("rov_hover_aswid_dominate_cooldown_m", Mathf.CeilToInt(cd / 60f)); + return ModText.Get("rov_hover_aswid_dominate"); } } diff --git a/JotunnModStub/Butler/ServantTableBehaviour.cs b/JotunnModStub/Butler/ServantTableBehaviour.cs index bac4a73..e4964e6 100644 --- a/JotunnModStub/Butler/ServantTableBehaviour.cs +++ b/JotunnModStub/Butler/ServantTableBehaviour.cs @@ -137,12 +137,11 @@ namespace RacesOfValheim if (servant == null) { - return m_title + "\nNo servant stands here.\n" + - "[$KEY_Use] Raise one"; + return ModText.Get("rov_hover_butler_no_servant_stands_here_raise", m_title); } string status = servant.Status; - if (string.IsNullOrEmpty(status)) status = "Waiting."; + if (string.IsNullOrEmpty(status)) status = ModText.Get("rov_hover_butler_waiting"); return m_title + "\n" + status; } diff --git a/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs b/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs index 39b1dd7..e7a6a10 100644 --- a/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs +++ b/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs @@ -328,21 +328,20 @@ namespace RacesOfValheim if (thrall.Kind == DraughSpawner.KindElite) aliveElite++; else aliveNormal++; } - string body = $"flesh {Mathf.Floor(GetFlesh())}/{DraughSpawner.FleshPerThrall}, " + - $"risen {aliveNormal}/{AliveCap()}, waiting {GetReserve()}/{DraughSpawner.ReserveCap}"; + string body = ModText.Get("rov_hover_draugh_flesh_risen_waiting", Mathf.Floor(GetFlesh()), DraughSpawner.FleshPerThrall, aliveNormal, AliveCap(), GetReserve(), DraughSpawner.ReserveCap); if (IsUpgraded()) { - body += $"\nofficers {aliveElite}/{EliteCap()}, waiting {GetReserveElite()}/{DraughSpawner.ReserveCapElite}"; + body += ModText.Get("rov_hover_draugh_officers_waiting", aliveElite, EliteCap(), GetReserveElite(), DraughSpawner.ReserveCapElite); } if (m_respawnTimer > 0f) { int left = Mathf.Max(1, Mathf.CeilToInt(DraughSpawner.RespawnSeconds - m_respawnTimer)); - body += $"\nnext rises in {left}s"; + body += ModText.Get("rov_hover_draugh_next_rises_s", left); } - body += "\n[$KEY_Use] Feed it flesh, or a draugr's head"; + body += ModText.Get("rov_hover_draugh_feed_flesh_or_draugr_s"); return Localization.instance.Localize($"{DraughSpawner.PieceDisplayName} ({body})"); } diff --git a/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs b/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs index cb381e0..444b065 100644 --- a/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs +++ b/JotunnModStub/Dvergar/DvergarBancoBehaviour.cs @@ -277,16 +277,16 @@ namespace RacesOfValheim private string Hover() { - string body = $"contracts {CountGroups()}/{DvergarBanco.MaxTroops}"; + string body = ModText.Get("rov_hover_dvergar_contracts", CountGroups(), DvergarBanco.MaxTroops); // Said in as many words: a player who cannot see their own discount will read the lower // number in the window as a mistake. float discount = Mathf.Clamp01(DvergarProgression.Current.TraderBuyDiscount); - if (discount > 0f) body += $"\nyour seal is worth {Mathf.RoundToInt(discount * 100f)}% off"; + if (discount > 0f) body += ModText.Get("rov_hover_dvergar_seal_worth_off", Mathf.RoundToInt(discount * 100f)); - if (!IsUpgraded()) body += "\n(what the Queen left behind buys two more crews)"; + if (!IsUpgraded()) body += ModText.Get("rov_hover_dvergar_what_queen_left_behind_buys"); - body += "\n[$KEY_Use] Read the ledger"; + body += ModText.Get("rov_hover_dvergar_read_ledger"); return Localization.instance.Localize($"{DvergarBanco.PieceDisplayName} ({body})"); } diff --git a/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs b/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs index 32d4a82..de506db 100644 --- a/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs +++ b/JotunnModStub/Dvergar/DvergarBotteBehaviour.cs @@ -252,14 +252,12 @@ namespace RacesOfValheim string body; if (doses <= 0 || string.IsNullOrEmpty(brew)) { - body = "empty\n[$KEY_Use] Pour a brew in"; + body = ModText.Get("rov_hover_dvergar_empty_pour_brew"); } else { int waiting = InRange().Count; - body = $"{DvergarBotte.BrewDisplayName(brew)} {doses}/{DvergarBotte.MaxDoses}" + - $"\n{waiting} at the barrel" + - $"\n[$KEY_Use] Pour a round"; + body = ModText.Get("rov_hover_dvergar_at_barrel_pour_round", DvergarBotte.BrewDisplayName(brew), doses, DvergarBotte.MaxDoses, waiting); } return Localization.instance.Localize($"{DvergarBotte.PieceDisplayName} ({body})"); diff --git a/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs b/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs index 8a54e0f..94fce8c 100644 --- a/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs +++ b/JotunnModStub/Fenrir/FenrirMangiatoiaBehaviour.cs @@ -440,13 +440,10 @@ namespace RacesOfValheim { Count(out int wolves, out int ulv, out int fenrir); - string body = $"meat {Mathf.Floor(GetFeed())}/{FenrirMangiatoia.TankCap}" + - $"\nwolves {wolves}/{WolfCap()}, ulv {ulv}/{UlvCap()}"; + string body = ModText.Get("rov_hover_fenrir_meat_wolves_ulv", Mathf.Floor(GetFeed()), FenrirMangiatoia.TankCap, wolves, WolfCap(), ulv, UlvCap()); // Said in as many words, because the upgrade is deliberately invisible on the model. - body += IsUpgraded() - ? $", fenrir {fenrir}/{FenrirCap()}" - : "\nthe blood is thin here - it raises no fenrir yet"; + body += (IsUpgraded() ? ModText.Get("rov_hover_fenrir_fenrir", fenrir, FenrirCap()) : ModText.Get("rov_hover_fenrir_blood_thin_here_raises_no")); if (m_waitingFor != null) { @@ -458,16 +455,14 @@ namespace RacesOfValheim : m_waitingFor == FenrirMangiatoia.KindUlv ? FenrirMangiatoia.UlvCost : FenrirMangiatoia.FenrirCost; - body += GetFeed() < cost - ? $"\nnot enough meat for the next one ({cost} needed)" - : $"\nnext in {Mathf.Max(1, Mathf.CeilToInt(wait - m_timer))}s"; + body += (GetFeed() < cost ? ModText.Get("rov_hover_fenrir_not_enough_meat_next_one", cost) : ModText.Get("rov_hover_fenrir_next_s", Mathf.Max(1, Mathf.CeilToInt(wait - m_timer)))); } else { - body += "\nthe pack is whole"; + body += ModText.Get("rov_hover_fenrir_pack_whole"); } - body += "\n[$KEY_Use] Fill it with meat"; + body += ModText.Get("rov_hover_fenrir_fill_with_meat"); return Localization.instance.Localize($"{FenrirMangiatoia.PieceDisplayName} ({body})"); } diff --git a/JotunnModStub/ModText.cs b/JotunnModStub/ModText.cs index b5bb3e9..a60f631 100644 --- a/JotunnModStub/ModText.cs +++ b/JotunnModStub/ModText.cs @@ -28,7 +28,14 @@ namespace RacesOfValheim string[] words = args .Select(a => Localization.instance.Localize(a?.ToString() ?? "")) .ToArray(); - return Localization.instance.Localize("$" + key, words); + string text = Localization.instance.Localize("$" + key, words); + + // Valheim resolves tokens in one pass and never looks inside what it put in, so a + // "$KEY_Use" written in a translation came out as it was. Places that localize the + // result again (MessageHud, the stations' own Localize) hid that; hover texts returned + // straight to the HUD did not. A second pass costs nothing when there is no $ left. + if (text.IndexOf('$') >= 0) text = Localization.instance.Localize(text); + return text; } /// diff --git a/JotunnModStub/RaceMenuWard.cs b/JotunnModStub/RaceMenuWard.cs index 94ef37a..e59b237 100644 --- a/JotunnModStub/RaceMenuWard.cs +++ b/JotunnModStub/RaceMenuWard.cs @@ -171,13 +171,11 @@ namespace RacesOfValheim public string GetHoverText() { - string mode = BossProgressionManager.UsePersonalProgression ? "Personal" : "World"; + string mode = (BossProgressionManager.UsePersonalProgression ? ModText.Get("rov_hover_ward_personal") : ModText.Get("rov_hover_ward_world")); int state = BossProgressionManager.GetCurrentProgressionState(); - string boss = BossProgressionManager.GetBossNameForState(state); + string boss = BossProgressionManager.GetBossTokenForState(state); - return $"Race Menu Ward\n{mode} progression - {boss} ({state}/{BossProgressionManager.MaxState})\n" + - "[E] Open\n" + - "[Use item] Offer a boss relic"; + return ModText.Get("rov_hover_ward_race_menu_ward_progression_open", mode, boss, state, BossProgressionManager.MaxState); } public bool Interact(Humanoid user, bool hold, bool alt) diff --git a/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs b/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs index f65e631..aaa454f 100644 --- a/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs +++ b/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs @@ -362,25 +362,21 @@ namespace RacesOfValheim // upgraded, so there was no way to know the cap was two until ten trophies had gone in. // Every shelf is now visible whether or not it can be used yet, and says why when it cannot. string body = - $"\nmelee {alive[SkeletonBonePile.KindMelee]}/{GetSlots(SkeletonBonePile.KindMelee)} of {MeleeCap()}" + - $"\narchers {alive[SkeletonBonePile.KindRanged]}/{GetSlots(SkeletonBonePile.KindRanged)} of {RangedCap()}" + - $"\nrotten {alive[SkeletonBonePile.KindRancid]}/{GetSlots(SkeletonBonePile.KindRancid)} of {RancidCap()}"; + ModText.Get("rov_hover_skeleton_melee_archers_rotten", alive[SkeletonBonePile.KindMelee], GetSlots(SkeletonBonePile.KindMelee), MeleeCap(), alive[SkeletonBonePile.KindRanged], GetSlots(SkeletonBonePile.KindRanged), RangedCap(), alive[SkeletonBonePile.KindRancid], GetSlots(SkeletonBonePile.KindRancid), RancidCap()); - if (!IsUpgraded()) body += " (needs a Greater Cursed Skull)"; + if (!IsUpgraded()) body += ModText.Get("rov_hover_skeleton_needs_greater_cursed_skull"); int bonesToward = m_nview.GetZDO().GetInt(KeyBones); int placesLeft = TotalCap() - PaidSlots(); - body += placesLeft > 0 - ? $"\nbone {bonesToward}/{SkeletonBonePile.BonesPerSlot} toward the next of {placesLeft} places" - : "\nevery place is bought"; + body += (placesLeft > 0 ? ModText.Get("rov_hover_skeleton_bone_toward_next_places", bonesToward, SkeletonBonePile.BonesPerSlot, placesLeft) : ModText.Get("rov_hover_skeleton_every_place_bought")); if (m_respawnTimer > 0f) { int left = Mathf.Max(1, Mathf.CeilToInt(RespawnSeconds() - m_respawnTimer)); - body += $"\nnext rises in {left}s"; + body += ModText.Get("rov_hover_skeleton_next_rises_s", left); } - body += "\n[$KEY_Use] Bone in hand to buy a place, empty hands to move the line"; + body += ModText.Get("rov_hover_skeleton_bone_hand_buy_place_empty"); return Localization.instance.Localize($"{SkeletonBonePile.PieceDisplayName} ({body})"); } diff --git a/JotunnModStub/Sverm/SvermHive.cs b/JotunnModStub/Sverm/SvermHive.cs index 468846b..5470162 100644 --- a/JotunnModStub/Sverm/SvermHive.cs +++ b/JotunnModStub/Sverm/SvermHive.cs @@ -461,11 +461,7 @@ namespace RacesOfValheim // Both numbers, always, even when nothing is going down. A line that appears and // disappears is one the player has to notice twice before they believe it. - return $"{SvermHiveStage.NameOf(SvermHiveStage.Of(transform))}\n" + - SvermHiveReadout.Tank(transform) + - $"Beehives {infected} taken of {SvermConfigManagement.Beehives} allowed, {beehives} in range\n" + - SvermWorker.Readout(transform.position) + - "[$KEY_Use] Feed it a stack"; + return ModText.Get("rov_hover_sverm_beehives_taken_allowed_range_feed", SvermHiveStage.NameOf(SvermHiveStage.Of(transform)), SvermHiveReadout.Tank(transform), infected, SvermConfigManagement.Beehives, beehives, SvermWorker.Readout(transform.position)); } // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a diff --git a/JotunnModStub/Sverm/SvermHiveStore.cs b/JotunnModStub/Sverm/SvermHiveStore.cs index fe7a064..ef96cc7 100644 --- a/JotunnModStub/Sverm/SvermHiveStore.cs +++ b/JotunnModStub/Sverm/SvermHiveStore.cs @@ -222,17 +222,15 @@ namespace RacesOfValheim SvermHiveBehaviour hive = Hive; if (hive == null) return Title; - return $"{Title}\n" + - SvermHiveReadout.Tank(hive.transform) + - $"[$KEY_Use] {Prompt}"; + return ModText.Get("rov_hover_sverm_msg", Title, SvermHiveReadout.Tank(hive.transform), Prompt); } } /// The hive at the foot of the nest. Press E, a stack goes in. public class SvermHiveStomach : SvermHiveMouth { - protected override string Title => "Hive Stomach"; - protected override string Prompt => "Feed it a stack"; + protected override string Title => "$rov_hover_sverm_stomach_title"; + protected override string Prompt => "$rov_hover_sverm_stomach_prompt"; protected override bool Use(SvermHiveBehaviour hive, Player player) { @@ -459,13 +457,11 @@ namespace RacesOfValheim SvermHiveBehaviour nest = Nest; if (nest == null) { - return $"{SvermHiveMarketPiece.DisplayName}\n" + - $"No hive within {SvermConfigManagement.AuraRadius:0} metres."; + return ModText.Get("rov_hover_sverm_market_no_hive", SvermHiveMarketPiece.DisplayName, + SvermConfigManagement.AuraRadius.ToString("0")); } - return $"{SvermHiveMarketPiece.DisplayName}\n" + - SvermHiveReadout.Tank(nest.transform) + - "[$KEY_Use] Trade with the hive"; + return ModText.Get("rov_hover_sverm_trade_with_hive", SvermHiveMarketPiece.DisplayName, SvermHiveReadout.Tank(nest.transform)); } } @@ -474,9 +470,10 @@ namespace RacesOfValheim { public static string Tank(Transform nest) { - return $"Biomass {SvermBiomass.Bank(nest):0} / {SvermBiomass.Capacity(nest):0}\n" + - $"Digesting {SvermBiomass.Digesting(nest):0}\n" + - $"Brood eggs {SvermBroodEggs.Count(nest)} / {SvermBroodEggs.Cap(nest)}\n"; + return ModText.Get("rov_hover_sverm_tank", + SvermBiomass.Bank(nest).ToString("0"), SvermBiomass.Capacity(nest).ToString("0"), + SvermBiomass.Digesting(nest).ToString("0"), + SvermBroodEggs.Count(nest), SvermBroodEggs.Cap(nest)); } } diff --git a/JotunnModStub/Translations/English/hover.json b/JotunnModStub/Translations/English/hover.json new file mode 100644 index 0000000..9c09cb6 --- /dev/null +++ b/JotunnModStub/Translations/English/hover.json @@ -0,0 +1,52 @@ +{ + "rov_hover_aswid_dominate": "[$KEY_Use] Dominate", + "rov_hover_aswid_dominate_cooldown_m": "[$KEY_Use] Dominate (Cooldown: $1m)", + "rov_hover_aswid_follow": "[$KEY_Use] Follow", + "rov_hover_aswid_stay": "[$KEY_Use] Stay", + "rov_hover_butler_no_servant_stands_here_raise": "$1\nNo servant stands here.\n[$KEY_Use] Raise one", + "rov_hover_butler_waiting": "Waiting.", + "rov_hover_draugh_feed_flesh_or_draugr_s": "\n[$KEY_Use] Feed it flesh, or a draugr's head", + "rov_hover_draugh_flesh_risen_waiting": "flesh $1/$2, risen $3/$4, waiting $5/$6", + "rov_hover_draugh_next_rises_s": "\nnext rises in $1s", + "rov_hover_draugh_officers_waiting": "\nofficers $1/$2, waiting $3/$4", + "rov_hover_dvergar_at_barrel_pour_round": "$1 $2/$3\n$4 at the barrel\n[$KEY_Use] Pour a round", + "rov_hover_dvergar_contracts": "contracts $1/$2", + "rov_hover_dvergar_empty_pour_brew": "empty\n[$KEY_Use] Pour a brew in", + "rov_hover_dvergar_read_ledger": "\n[$KEY_Use] Read the ledger", + "rov_hover_dvergar_seal_worth_off": "\nyour seal is worth $1% off", + "rov_hover_dvergar_what_queen_left_behind_buys": "\n(what the Queen left behind buys two more crews)", + "rov_hover_fenrir_blood_thin_here_raises_no": "\nthe blood is thin here - it raises no fenrir yet", + "rov_hover_fenrir_fenrir": ", fenrir $1/$2", + "rov_hover_fenrir_fill_with_meat": "\n[$KEY_Use] Fill it with meat", + "rov_hover_fenrir_meat_wolves_ulv": "meat $1/$2\nwolves $3/$4, ulv $5/$6", + "rov_hover_fenrir_next_s": "\nnext in $1s", + "rov_hover_fenrir_not_enough_meat_next_one": "\nnot enough meat for the next one ($1 needed)", + "rov_hover_fenrir_pack_whole": "\nthe pack is whole", + "rov_hover_skeleton_bone_hand_buy_place_empty": "\n[$KEY_Use] Bone in hand to buy a place, empty hands to move the line", + "rov_hover_skeleton_bone_toward_next_places": "\nbone $1/$2 toward the next of $3 places", + "rov_hover_skeleton_every_place_bought": "\nevery place is bought", + "rov_hover_skeleton_melee_archers_rotten": "\nmelee $1/$2 of $3\narchers $4/$5 of $6\nrotten $7/$8 of $9", + "rov_hover_skeleton_needs_greater_cursed_skull": " (needs a Greater Cursed Skull)", + "rov_hover_skeleton_next_rises_s": "\nnext rises in $1s", + "rov_hover_sverm_beehives_taken_allowed_range_feed": "$1\n$2Beehives $3 taken of $4 allowed, $5 in range\n$6[$KEY_Use] Feed it a stack", + "rov_hover_sverm_market_no_hive": "$1\nNo hive within $2 metres.", + "rov_hover_sverm_msg": "$1\n$2[$KEY_Use] $3", + "rov_hover_sverm_stomach_prompt": "Feed it a stack", + "rov_hover_sverm_stomach_title": "Hive Stomach", + "rov_hover_sverm_tank": "Biomass $1 / $2\nDigesting $3\nBrood eggs $4 / $5\n", + "rov_hover_sverm_trade_with_hive": "$1\n$2[$KEY_Use] Trade with the hive", + "rov_hover_trenta_flesh_feed_raw_flesh": "flesh $1/$2\n[$KEY_Use] Feed it raw flesh", + "rov_hover_trenta_grove_growing": "$1 (growing, $2 minutes left)", + "rov_hover_trenta_grove_grown": "$1 ($2 $3/$4, honey $5)\n[$KEY_Use] Feed it Fertilizer", + "rov_hover_trenta_honey_full": "$1, full", + "rov_hover_trenta_honey_next": "$1, next in $2 min", + "rov_hover_trenta_honey_none": "none (no honey item found)", + "rov_hover_trenta_ready_empty": "ready: $1 $2\n[$KEY_Use] Empty it", + "rov_hover_trenta_rotting_minutes_left": "rotting, $1 minutes left", + "rov_hover_trol_call_warbands": "\n[$KEY_Use] Call the warbands", + "rov_hover_trol_warbands": "warbands $1/$2", + "rov_hover_trol_yagluth_drop_hand_buys_king": "\n(a Yagluth drop in hand buys a king's head, and two more bands)", + "rov_hover_ward_personal": "Personal", + "rov_hover_ward_race_menu_ward_progression_open": "$rov_piece_racemenuward_name\n$1 progression - $2 ($3/$4)\n[$KEY_Use] Open\n[Use item] Offer a boss relic", + "rov_hover_ward_world": "World" +} diff --git a/JotunnModStub/Translations/Italian/hover.json b/JotunnModStub/Translations/Italian/hover.json new file mode 100644 index 0000000..d332961 --- /dev/null +++ b/JotunnModStub/Translations/Italian/hover.json @@ -0,0 +1,52 @@ +{ + "rov_hover_aswid_dominate": "[$KEY_Use] Domina", + "rov_hover_aswid_dominate_cooldown_m": "[$KEY_Use] Domina (ricarica: $1m)", + "rov_hover_aswid_follow": "[$KEY_Use] Segui", + "rov_hover_aswid_stay": "[$KEY_Use] Resta", + "rov_hover_butler_no_servant_stands_here_raise": "$1\nQui non c'è nessun servitore.\n[$KEY_Use] Fanne alzare uno", + "rov_hover_butler_waiting": "In attesa.", + "rov_hover_draugh_feed_flesh_or_draugr_s": "\n[$KEY_Use] Nutrilo di carne, o della testa di un draugr", + "rov_hover_draugh_flesh_risen_waiting": "carne $1/$2, risorti $3/$4, in attesa $5/$6", + "rov_hover_draugh_next_rises_s": "\nil prossimo si alza tra $1s", + "rov_hover_draugh_officers_waiting": "\nufficiali $1/$2, in attesa $3/$4", + "rov_hover_dvergar_at_barrel_pour_round": "$1 $2/$3\n$4 al barile\n[$KEY_Use] Versa un giro", + "rov_hover_dvergar_contracts": "contratti $1/$2", + "rov_hover_dvergar_empty_pour_brew": "vuoto\n[$KEY_Use] Versaci una bevanda", + "rov_hover_dvergar_read_ledger": "\n[$KEY_Use] Leggi il registro", + "rov_hover_dvergar_seal_worth_off": "\nil tuo sigillo vale uno sconto del $1%", + "rov_hover_dvergar_what_queen_left_behind_buys": "\n(ciò che la Regina ha lasciato compra altre due squadre)", + "rov_hover_fenrir_blood_thin_here_raises_no": "\nqui il sangue è debole: non fa ancora nascere fenrir", + "rov_hover_fenrir_fenrir": ", fenrir $1/$2", + "rov_hover_fenrir_fill_with_meat": "\n[$KEY_Use] Riempila di carne", + "rov_hover_fenrir_meat_wolves_ulv": "carne $1/$2\nlupi $3/$4, ulv $5/$6", + "rov_hover_fenrir_next_s": "\nil prossimo tra $1s", + "rov_hover_fenrir_not_enough_meat_next_one": "\nnon c'è abbastanza carne per il prossimo (ne serve $1)", + "rov_hover_fenrir_pack_whole": "\nil branco è al completo", + "rov_hover_skeleton_bone_hand_buy_place_empty": "\n[$KEY_Use] Osso in mano per comprare un posto, mani vuote per muovere la fila", + "rov_hover_skeleton_bone_toward_next_places": "\nossa $1/$2 per il prossimo dei $3 posti", + "rov_hover_skeleton_every_place_bought": "\nogni posto è comprato", + "rov_hover_skeleton_melee_archers_rotten": "\nmischia $1/$2 di $3\narcieri $4/$5 di $6\nrancidi $7/$8 di $9", + "rov_hover_skeleton_needs_greater_cursed_skull": " (serve un teschio maledetto superiore)", + "rov_hover_skeleton_next_rises_s": "\nil prossimo si alza tra $1s", + "rov_hover_sverm_beehives_taken_allowed_range_feed": "$1\n$2Alveari $3 occupati su $4 consentiti, $5 nel raggio\n$6[$KEY_Use] Dagli da mangiare una pila", + "rov_hover_sverm_market_no_hive": "$1\nNessun alveare entro $2 metri.", + "rov_hover_sverm_msg": "$1\n$2[$KEY_Use] $3", + "rov_hover_sverm_stomach_prompt": "Dagli da mangiare una pila", + "rov_hover_sverm_stomach_title": "Stomaco dell'alveare", + "rov_hover_sverm_tank": "Biomassa $1 / $2\nIn digestione $3\nUova della covata $4 / $5\n", + "rov_hover_sverm_trade_with_hive": "$1\n$2[$KEY_Use] Commercia con l'alveare", + "rov_hover_trenta_flesh_feed_raw_flesh": "carne $1/$2\n[$KEY_Use] Nutrila di carne cruda", + "rov_hover_trenta_grove_growing": "$1 (in crescita, mancano $2 minuti)", + "rov_hover_trenta_grove_grown": "$1 ($2 $3/$4, miele $5)\n[$KEY_Use] Nutrilo di fertilizzante", + "rov_hover_trenta_honey_full": "$1, pieno", + "rov_hover_trenta_honey_next": "$1, il prossimo tra $2 min", + "rov_hover_trenta_honey_none": "nessuno (oggetto miele non trovato)", + "rov_hover_trenta_ready_empty": "pronto: $1 $2\n[$KEY_Use] Svuotala", + "rov_hover_trenta_rotting_minutes_left": "sta marcendo, mancano $1 minuti", + "rov_hover_trol_call_warbands": "\n[$KEY_Use] Chiama le bande da guerra", + "rov_hover_trol_warbands": "bande da guerra $1/$2", + "rov_hover_trol_yagluth_drop_hand_buys_king": "\n(un bottino di Yagluth in mano compra la testa di un re, e altre due bande)", + "rov_hover_ward_personal": "Personale", + "rov_hover_ward_race_menu_ward_progression_open": "$rov_piece_racemenuward_name\nProgressione $1 - $2 ($3/$4)\n[$KEY_Use] Apri\n[Usa oggetto] Offri una reliquia di boss", + "rov_hover_ward_world": "del mondo" +} diff --git a/JotunnModStub/Trenta/ComposterBehaviour.cs b/JotunnModStub/Trenta/ComposterBehaviour.cs index 82c9871..df7caf1 100644 --- a/JotunnModStub/Trenta/ComposterBehaviour.cs +++ b/JotunnModStub/Trenta/ComposterBehaviour.cs @@ -243,17 +243,15 @@ namespace RacesOfValheim switch (GetState()) { case State.Ready: - body = $"ready: {m_yield} {TrentaConfig.FertilizerDisplayName}\n" + - "[$KEY_Use] Empty it"; + body = ModText.Get("rov_hover_trenta_ready_empty", m_yield, TrentaConfig.FertilizerDisplayName); break; case State.Composting: - body = $"rotting, {MinutesLeft()} minutes left"; + body = ModText.Get("rov_hover_trenta_rotting_minutes_left", MinutesLeft()); break; default: - body = $"flesh {Mathf.Floor(GetFlesh())}/{m_capacity}\n" + - "[$KEY_Use] Feed it raw flesh"; + body = ModText.Get("rov_hover_trenta_flesh_feed_raw_flesh", Mathf.Floor(GetFlesh()), m_capacity); break; } diff --git a/JotunnModStub/Trenta/GroveBehaviour.cs b/JotunnModStub/Trenta/GroveBehaviour.cs index 64f3989..a40c1ce 100644 --- a/JotunnModStub/Trenta/GroveBehaviour.cs +++ b/JotunnModStub/Trenta/GroveBehaviour.cs @@ -318,34 +318,32 @@ namespace RacesOfValheim { if (!IsGrown()) { - return Localization.instance.Localize( - $"{TrentaConfig.GroveDisplayName} (growing, {MinutesLeft()} minutes left)"); + return ModText.Get("rov_hover_trenta_grove_growing", TrentaConfig.GroveDisplayName, MinutesLeft()); } // The honey line is here because it was missing, and its absence is why a grove that // was quietly producing nothing looked exactly like one that was working. - return Localization.instance.Localize( - $"{TrentaConfig.GroveDisplayName} ({TrentaConfig.FertilizerDisplayName} " + - $"{GetFertilizer()}/{TrentaConfig.GroveFertilizerCapacity}, honey {HoneyStatus()})\n" + - "[$KEY_Use] Feed it Fertilizer"); + return ModText.Get("rov_hover_trenta_grove_grown", TrentaConfig.GroveDisplayName, + TrentaConfig.FertilizerDisplayName, GetFertilizer(), TrentaConfig.GroveFertilizerCapacity, + HoneyStatus()); } /// How much honey is in the crate and how long until the next drop of it. private string HoneyStatus() { - if (m_honeyPrefab == null) return "none (no honey item found)"; + if (m_honeyPrefab == null) return ModText.Get("rov_hover_trenta_honey_none"); Inventory inventory = m_container != null ? m_container.GetInventory() : null; int stored = inventory != null ? CountHoney(inventory) : 0; string status = $"{stored}/{m_honeyCapacity}"; - if (stored >= m_honeyCapacity) return status + ", full"; + if (stored >= m_honeyCapacity) return ModText.Get("rov_hover_trenta_honey_full", status); long stamp = m_nview.GetZDO().GetLong(KeyHoneyTime, 0L); if (stamp == 0L || ZNet.instance == null) return status; double left = m_secPerHoney - (ZNet.instance.GetTime() - new DateTime(stamp)).TotalSeconds; - return status + $", next in {Mathf.Max(1, Mathf.CeilToInt((float)left / 60f))} min"; + return ModText.Get("rov_hover_trenta_honey_next", status, Mathf.Max(1, Mathf.CeilToInt((float)left / 60f))); } // ---------------------------------------------------------------- state diff --git a/JotunnModStub/Trol/TrolTotemBehaviour.cs b/JotunnModStub/Trol/TrolTotemBehaviour.cs index b567f9d..cf040b6 100644 --- a/JotunnModStub/Trol/TrolTotemBehaviour.cs +++ b/JotunnModStub/Trol/TrolTotemBehaviour.cs @@ -276,14 +276,14 @@ namespace RacesOfValheim private string Hover() { - string body = $"warbands {CountGroups()}/{TrolTotem.MaxTroops}"; + string body = ModText.Get("rov_hover_trol_warbands", CountGroups(), TrolTotem.MaxTroops); - if (!IsUpgraded()) body += "\n(a Yagluth drop in hand buys a king's head, and two more bands)"; + if (!IsUpgraded()) body += ModText.Get("rov_hover_trol_yagluth_drop_hand_buys_king"); // The roster lives in the window now, not in the hover - so this only has to get the player // to open it. The hold gesture it used to advertise was unreadable: it cycled faster than // anyone could see what was selected. - body += "\n[$KEY_Use] Call the warbands"; + body += ModText.Get("rov_hover_trol_call_warbands"); return Localization.instance.Localize($"{TrolTotem.PieceDisplayName} ({body})"); } From b555da99f266b9da2700290bb818bf347e950a9e Mon Sep 17 00:00:00 2001 From: kanym Date: Mon, 28 Sep 2026 13:55:45 +0200 Subject: [PATCH 064/273] feat(text): the Tame and Grab Log hover prompts come from translation files Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Aswid/AswidPatches.cs | 2 +- JotunnModStub/Translations/English/hover.json | 2 ++ JotunnModStub/Translations/Italian/hover.json | 2 ++ JotunnModStub/Trol/TrolLogWeapon.cs | 2 +- 4 files changed, 6 insertions(+), 2 deletions(-) diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 9361df9..e2bb353 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -463,7 +463,7 @@ namespace RacesOfValheim // AswidConfig.TameKey) - the hint never matched the working key, and would have // gone stale again the moment that key was rebound. MainKey.ToString() reads back // whatever is actually bound. - __result += $"\n[{AswidConfig.TameKey.Value.MainKey}] Tame"; + __result += ModText.Get("rov_hover_aswid_tame", AswidConfig.TameKey.Value.MainKey); } } } diff --git a/JotunnModStub/Translations/English/hover.json b/JotunnModStub/Translations/English/hover.json index 9c09cb6..daaefdf 100644 --- a/JotunnModStub/Translations/English/hover.json +++ b/JotunnModStub/Translations/English/hover.json @@ -3,6 +3,7 @@ "rov_hover_aswid_dominate_cooldown_m": "[$KEY_Use] Dominate (Cooldown: $1m)", "rov_hover_aswid_follow": "[$KEY_Use] Follow", "rov_hover_aswid_stay": "[$KEY_Use] Stay", + "rov_hover_aswid_tame": "\n[$1] Tame", "rov_hover_butler_no_servant_stands_here_raise": "$1\nNo servant stands here.\n[$KEY_Use] Raise one", "rov_hover_butler_waiting": "Waiting.", "rov_hover_draugh_feed_flesh_or_draugr_s": "\n[$KEY_Use] Feed it flesh, or a draugr's head", @@ -44,6 +45,7 @@ "rov_hover_trenta_ready_empty": "ready: $1 $2\n[$KEY_Use] Empty it", "rov_hover_trenta_rotting_minutes_left": "rotting, $1 minutes left", "rov_hover_trol_call_warbands": "\n[$KEY_Use] Call the warbands", + "rov_hover_trol_grab_log": "\n[$1] Grab Log", "rov_hover_trol_warbands": "warbands $1/$2", "rov_hover_trol_yagluth_drop_hand_buys_king": "\n(a Yagluth drop in hand buys a king's head, and two more bands)", "rov_hover_ward_personal": "Personal", diff --git a/JotunnModStub/Translations/Italian/hover.json b/JotunnModStub/Translations/Italian/hover.json index d332961..01d1d9f 100644 --- a/JotunnModStub/Translations/Italian/hover.json +++ b/JotunnModStub/Translations/Italian/hover.json @@ -3,6 +3,7 @@ "rov_hover_aswid_dominate_cooldown_m": "[$KEY_Use] Domina (ricarica: $1m)", "rov_hover_aswid_follow": "[$KEY_Use] Segui", "rov_hover_aswid_stay": "[$KEY_Use] Resta", + "rov_hover_aswid_tame": "\n[$1] Addomestica", "rov_hover_butler_no_servant_stands_here_raise": "$1\nQui non c'è nessun servitore.\n[$KEY_Use] Fanne alzare uno", "rov_hover_butler_waiting": "In attesa.", "rov_hover_draugh_feed_flesh_or_draugr_s": "\n[$KEY_Use] Nutrilo di carne, o della testa di un draugr", @@ -44,6 +45,7 @@ "rov_hover_trenta_ready_empty": "pronto: $1 $2\n[$KEY_Use] Svuotala", "rov_hover_trenta_rotting_minutes_left": "sta marcendo, mancano $1 minuti", "rov_hover_trol_call_warbands": "\n[$KEY_Use] Chiama le bande da guerra", + "rov_hover_trol_grab_log": "\n[$1] Afferra il tronco", "rov_hover_trol_warbands": "bande da guerra $1/$2", "rov_hover_trol_yagluth_drop_hand_buys_king": "\n(un bottino di Yagluth in mano compra la testa di un re, e altre due bande)", "rov_hover_ward_personal": "Personale", diff --git a/JotunnModStub/Trol/TrolLogWeapon.cs b/JotunnModStub/Trol/TrolLogWeapon.cs index f315494..5480273 100644 --- a/JotunnModStub/Trol/TrolLogWeapon.cs +++ b/JotunnModStub/Trol/TrolLogWeapon.cs @@ -137,7 +137,7 @@ namespace RacesOfValheim if (rightItem != null && rightItem.m_dropPrefab != null && rightItem.m_dropPrefab.name.StartsWith("TrolWeapon_")) return; string key = TrolConfig.GrabLogKey.Value.MainKey.ToString(); - __result += $"\n[{key}] Grab Log"; + __result += ModText.Get("rov_hover_trol_grab_log", key); } } } From 83bade65cbb01b32a949b20280b801bfb0279d0f Mon Sep 17 00:00:00 2001 From: kanym Date: Mon, 28 Sep 2026 15:06:21 +0200 Subject: [PATCH 065/273] fix(trol): True Form no longer switches itself off as it comes on The plugin adds TrolRace itself, but Instance did not know that and built a second copy on first read, so two Updates read every key. Past Fader the True Form key is a toggle: one copy put the form on, the other saw it on in the same frame and took it off. The Trol grew and shrank back with no status. Awake now registers the plugin's copy and removes any other. FurlingRace had the same pattern, harmless there, and gets the same fix. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Furling/FurlingRace.cs | 15 +++++++++++++++ JotunnModStub/Trol/TrolRace.cs | 18 ++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/JotunnModStub/Furling/FurlingRace.cs b/JotunnModStub/Furling/FurlingRace.cs index bf33e7e..da3c59d 100644 --- a/JotunnModStub/Furling/FurlingRace.cs +++ b/JotunnModStub/Furling/FurlingRace.cs @@ -8,6 +8,21 @@ namespace RacesOfValheim public class FurlingRace : MonoBehaviour { private static FurlingRace _instance; + + // The plugin adds this component itself, so Instance must find that copy rather than build + // a second one on first read. Same fault as TrolRace's, where two Updates reading one key + // switched the True Form off as it came on; here the only per-frame work is idempotent, so + // it had no visible effect, but two copies of a race component is never intended. + private void Awake() + { + if (_instance != null && _instance != this) + { + Destroy(this); + return; + } + _instance = this; + } + public static FurlingRace Instance { get diff --git a/JotunnModStub/Trol/TrolRace.cs b/JotunnModStub/Trol/TrolRace.cs index 591ca5b..e1894ec 100644 --- a/JotunnModStub/Trol/TrolRace.cs +++ b/JotunnModStub/Trol/TrolRace.cs @@ -10,6 +10,24 @@ namespace RacesOfValheim public class TrolRace : MonoBehaviour { private static TrolRace _instance; + + // THE PLUGIN ADDS THIS COMPONENT ITSELF, in RacesOfValheim.Awake, and nothing used to tell + // Instance so. The first read of Instance - CreateModAssets, on every start - found _instance + // empty and built a second TrolRace on a GameObject of its own, and from then on two Updates + // read every key. At Fader and past it the True Form key is a toggle: one copy put the form + // on and began to grow, the other saw the form already on in the same frame, was not itself + // transforming, and took it straight off. The Trol grew and shrank back, with no status and + // - since past Fader there is none - no cooldown. + private void Awake() + { + if (_instance != null && _instance != this) + { + Destroy(this); + return; + } + _instance = this; + } + public static TrolRace Instance { get From 2c5079bf8ce7b24690013d2e3d3110648d070c61 Mon Sep 17 00:00:00 2001 From: kanym Date: Mon, 28 Sep 2026 15:06:22 +0200 Subject: [PATCH 066/273] fix(build): the mod's stations appear under Crafting in Valheim 1.0's build menu Valheim 1.0 lists pieces by Piece.m_usage tags. Jotunn sets only the old category, so a cloned piece kept its source's tags: the Crystal Golem and the Bound Sentry, cloned from guard_stone, landed under Decorations. A postfix on PieceManager.AddPiece now sets the tag from the category for every Hammer piece of this mod. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/PieceUsageTags.cs | 42 +++++++++++++++++++++++++++++++++ 1 file changed, 42 insertions(+) create mode 100644 JotunnModStub/PieceUsageTags.cs diff --git a/JotunnModStub/PieceUsageTags.cs b/JotunnModStub/PieceUsageTags.cs new file mode 100644 index 0000000..d72d926 --- /dev/null +++ b/JotunnModStub/PieceUsageTags.cs @@ -0,0 +1,42 @@ +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; + +namespace RacesOfValheim +{ + /// + /// Puts every Hammer piece of this mod under the right entry of Valheim 1.0's build menu. + /// + /// The 1.0 menu lists pieces by Piece.m_usage, a set of tags (Crafting, Decor, Defense...), and + /// no longer by the old m_category alone. Jotunn's PieceConfig.Category still sets m_category and + /// leaves m_usage untouched, so a cloned piece keeps the tags of whatever it was cloned from. The + /// Crystal Golem and the Bound Sentry are cloned from guard_stone, a decoration, and turned up + /// under Decorations while every other race station sat under Crafting only because their own + /// source pieces happened to be crafting ones. + /// + /// One patch rather than a line at each of the eighteen registrations: every piece goes through + /// PieceManager.AddPiece, and Jotunn has already applied the config's category by then, so the + /// tag is read off that. Other mods' pieces and the cultivator's are left alone. + /// + [HarmonyPatch(typeof(PieceManager), nameof(PieceManager.AddPiece))] + public static class PieceUsageTags + { + public static void Postfix(CustomPiece customPiece) + { + if (customPiece?.Piece == null || customPiece.SourceMod == null) return; + if (customPiece.SourceMod.GUID != RacesOfValheim.PluginGUID) return; + if (customPiece.PieceTable != PieceTables.Hammer) return; + + switch (customPiece.Piece.m_category) + { + case Piece.PieceCategory.Crafting: + customPiece.Piece.m_usage = Piece.UsageTagFlags.Crafting; + break; + case Piece.PieceCategory.Misc: + customPiece.Piece.m_usage = Piece.UsageTagFlags.Misc; + break; + } + } + } +} From 1bd09ed31d072c5b8efdcc5229cc1364ba8abf96 Mon Sep 17 00:00:00 2001 From: kanym Date: Mon, 28 Sep 2026 18:50:54 +0200 Subject: [PATCH 067/273] feat(text): merchants, troops and the hive's shelf come from translation files The faction merchants' 90 jokes, their generic lines and their names now read from merchants.json. Merchant names use the game's own creature tokens where one matches, so they arrive translated in every language Valheim ships; the Dverg keeps a key of its own, since vanilla's token reads "Dvergr Rogue". The Dvergar and Trol troop names and terms, and the Sverm hive's goods, refusals, stage names and brood kinds, follow. Their panels fill TMP texts themselves, so they localize the names where they draw them. The jokes have English text only for now. Co-Authored-By: Claude Opus 5.5 --- JotunnModStub/Dvergar/DvergarBanco.cs | 10 +- JotunnModStub/Dvergar/DvergarBancoStore.cs | 9 +- .../Factions/FactionMerchantCatalog.cs | 24 +-- .../Factions/FactionMerchantJokes.cs | 180 +++++++++--------- .../Factions/FactionMerchantSetup.cs | 6 +- JotunnModStub/Sverm/SvermBrood.cs | 8 +- JotunnModStub/Sverm/SvermHive.cs | 2 +- JotunnModStub/Sverm/SvermHiveGoods.cs | 58 +++--- JotunnModStub/Sverm/SvermHiveStage.cs | 9 +- .../Translations/English/merchants.json | 133 +++++++++++++ .../Translations/Italian/merchants.json | 43 +++++ JotunnModStub/Trol/TrolTotem.cs | 10 +- JotunnModStub/Trol/TrolTotemStore.cs | 7 +- 13 files changed, 332 insertions(+), 167 deletions(-) create mode 100644 JotunnModStub/Translations/English/merchants.json create mode 100644 JotunnModStub/Translations/Italian/merchants.json diff --git a/JotunnModStub/Dvergar/DvergarBanco.cs b/JotunnModStub/Dvergar/DvergarBanco.cs index 98559ee..34ab389 100644 --- a/JotunnModStub/Dvergar/DvergarBanco.cs +++ b/JotunnModStub/Dvergar/DvergarBanco.cs @@ -99,7 +99,7 @@ namespace RacesOfValheim { new Troop { - Id = "escort", Display = "Escort", Price = 400, NeedsUpgrade = false, Icon = "TrophyDvergr", + Id = "escort", Display = "$rov_troop_dvergar_escort", Price = 400, NeedsUpgrade = false, Icon = "TrophyDvergr", Members = new[] { new KeyValuePair("Dverger", 1), @@ -108,7 +108,7 @@ namespace RacesOfValheim }, new Troop { - Id = "yard_patrol", Display = "Yard Patrol", Price = 700, NeedsUpgrade = false, Icon = "TrophyDvergr", + Id = "yard_patrol", Display = "$rov_troop_dvergar_yard_patrol", Price = 700, NeedsUpgrade = false, Icon = "TrophyDvergr", Members = new[] { new KeyValuePair("Dverger", 2), @@ -117,7 +117,7 @@ namespace RacesOfValheim }, new Troop { - Id = "fire_crew", Display = "Fire Crew", Price = 1000, NeedsUpgrade = false, Icon = "TrophyDvergr", + Id = "fire_crew", Display = "$rov_troop_dvergar_fire_crew", Price = 1000, NeedsUpgrade = false, Icon = "TrophyDvergr", Members = new[] { new KeyValuePair("Dverger", 1), @@ -127,7 +127,7 @@ namespace RacesOfValheim }, new Troop { - Id = "runic_crew", Display = "Runic Crew", Price = 1500, NeedsUpgrade = true, Icon = "TrophyDvergr", + Id = "runic_crew", Display = "$rov_troop_dvergar_runic_crew", Price = 1500, NeedsUpgrade = true, Icon = "TrophyDvergr", Members = new[] { new KeyValuePair("Dverger", 2), @@ -137,7 +137,7 @@ namespace RacesOfValheim }, new Troop { - Id = "ash_guard", Display = "Ash Guard", Price = 2000, NeedsUpgrade = true, Icon = "TrophySeekerBrute", + Id = "ash_guard", Display = "$rov_troop_dvergar_ash_guard", Price = 2000, NeedsUpgrade = true, Icon = "TrophySeekerBrute", Members = new[] { new KeyValuePair("DvergerAshlands", 2), diff --git a/JotunnModStub/Dvergar/DvergarBancoStore.cs b/JotunnModStub/Dvergar/DvergarBancoStore.cs index e225ae0..a313f86 100644 --- a/JotunnModStub/Dvergar/DvergarBancoStore.cs +++ b/JotunnModStub/Dvergar/DvergarBancoStore.cs @@ -123,14 +123,14 @@ namespace RacesOfValheim else Jotunn.Logger.LogWarning($"[Dvergar] No icon on '{troop.Icon}' for {troop.Display}; the row " + "keeps whatever the cloned element was showing."); - element.transform.Find("name").GetComponent().text = troop.Display; + element.transform.Find("name").GetComponent().text = Localization.instance.Localize(troop.Display); // The DISCOUNTED price, because that is what will actually leave the player's pocket. TMP_Text price = FindDescendant(element.transform, "price"); if (price != null) price.text = DvergarBanco.PriceFor(troop).ToString(); UITooltip tooltip = element.GetComponent(); - if (tooltip != null) tooltip.Set(troop.Display, Composition(troop), gui.m_tooltipAnchor, default(Vector2)); + if (tooltip != null) tooltip.Set(Localization.instance.Localize(troop.Display), Composition(troop), gui.m_tooltipAnchor, default(Vector2)); string id = troop.Id; element.GetComponent private static readonly ShopDefinition UlvShop = new ShopDefinition { - DisplayName = "Ulv", + DisplayName = "$enemy_ulv", JokeCategory = JokeLupoLicantropo, Items = WithDefaults(new List { @@ -203,7 +203,7 @@ namespace RacesOfValheim private static readonly ShopDefinition FenringShop = new ShopDefinition { - DisplayName = "Fenring", + DisplayName = "$enemy_fenring", JokeCategory = JokeLupoLicantropo, Items = WithDefaults(new List { @@ -216,7 +216,7 @@ namespace RacesOfValheim private static readonly ShopDefinition CultistShop = new ShopDefinition { - DisplayName = "Cultist", + DisplayName = "$enemy_fenringcultist", JokeCategory = JokeStrega, Items = WithDefaults(new List { @@ -228,7 +228,7 @@ namespace RacesOfValheim private static readonly ShopDefinition DvergShop = new ShopDefinition { - DisplayName = "Dverg", + DisplayName = "$rov_merchant_dverg_name", JokeCategory = JokeNano, Items = WithDefaults(new List { @@ -241,7 +241,7 @@ namespace RacesOfValheim private static readonly ShopDefinition DraugrShop = new ShopDefinition { - DisplayName = "Draugr", + DisplayName = "$enemy_draugr", JokeCategory = JokeNonMortoZombie, Items = WithDefaults(new List { @@ -266,7 +266,7 @@ namespace RacesOfValheim private static readonly ShopDefinition SkeletonShop = new ShopDefinition { - DisplayName = "Skeleton", + DisplayName = "$enemy_skeleton", JokeCategory = JokeScheletro, Items = WithDefaults(new List { @@ -284,7 +284,7 @@ namespace RacesOfValheim private static readonly ShopDefinition GhostShop = new ShopDefinition { - DisplayName = "Ghost", + DisplayName = "$enemy_ghost", JokeCategory = JokeFantasma, Items = WithDefaults(new List { @@ -295,7 +295,7 @@ namespace RacesOfValheim private static readonly ShopDefinition WraithShop = new ShopDefinition { - DisplayName = "Wraith", + DisplayName = "$enemy_wraith", JokeCategory = JokeFantasma, Items = WithDefaults(new List { diff --git a/JotunnModStub/Factions/FactionMerchantJokes.cs b/JotunnModStub/Factions/FactionMerchantJokes.cs index ca811e9..8c38aaa 100644 --- a/JotunnModStub/Factions/FactionMerchantJokes.cs +++ b/JotunnModStub/Factions/FactionMerchantJokes.cs @@ -11,120 +11,120 @@ namespace RacesOfValheim { [FactionMerchantCatalog.JokeScheletro] = new[] { - "What do you call a skeleton who never does his chores? Lazy bones.", - "Why did the skeleton quit his job? His heart wasn't in it.", - "What skeleton was the first emperor of France? Napoleon Bone-aparte.", - "Who is the world's most famous skeleton detective? Sherlock Bones.", - "What did the French skeletons say before eating their dinner? Bone appetit!", - "What do skeletons always order when they go to a restaurant? Spare ribs.", - "How do skeletons call each other? On their tele-bone.", - "What's a skeleton's favorite fruit? Bone-ana!", - "Why are skeletons bad at lying? You can see right through them!", - "Why don't skeletons fight each other? They don't have the guts.", + "$rov_joke_scheletro_01", + "$rov_joke_scheletro_02", + "$rov_joke_scheletro_03", + "$rov_joke_scheletro_04", + "$rov_joke_scheletro_05", + "$rov_joke_scheletro_06", + "$rov_joke_scheletro_07", + "$rov_joke_scheletro_08", + "$rov_joke_scheletro_09", + "$rov_joke_scheletro_10", }, [FactionMerchantCatalog.JokeNonMortoZombie] = new[] { - "When do zombies go to sleep? When they are dead tired.", - "What streets do zombies live on? Dead ends.", - "Where do zombies go sailing? Lake Eerie.", - "What do you call a zombie in pajamas? The sleepwalking dead.", - "How are zombies like computers? They use mega-bites!", - "Why did the zombie lose his lawsuit? He had no leg to stand on!", - "Why did the zombie eat a light bulb? Because he wanted a light snack.", - "Why don't zombies eat clowns? Because they taste funny!", - "Why did the zombie go to school? To improve his brainpower.", - "Zombies are hopeless romantics, seeking their ghoul-mate.", + "$rov_joke_nonmortozombie_01", + "$rov_joke_nonmortozombie_02", + "$rov_joke_nonmortozombie_03", + "$rov_joke_nonmortozombie_04", + "$rov_joke_nonmortozombie_05", + "$rov_joke_nonmortozombie_06", + "$rov_joke_nonmortozombie_07", + "$rov_joke_nonmortozombie_08", + "$rov_joke_nonmortozombie_09", + "$rov_joke_nonmortozombie_10", }, [FactionMerchantCatalog.JokeFantasma] = new[] { - "Why was the ghost lonely? It had no-body.", - "What's the most useless room in a house for a ghost? A living room.", - "What's a ghost's favourite cheese? Ghoul-da cheese.", - "What's a ghost's favourite food? Boo-rritos.", - "What's a ghost's favourite dessert? I-scream.", - "What's a ghost's favourite game? Hide and Shriek.", - "What do you call a ghost with a broken leg? A hoblin goblin.", - "What happens when a ghost gets lost in the fog? He is mist.", - "Ghosts love elevators because it lifts their spirits.", - "Why did the ghost cross the road? Because it was a poultry-geist.", + "$rov_joke_fantasma_01", + "$rov_joke_fantasma_02", + "$rov_joke_fantasma_03", + "$rov_joke_fantasma_04", + "$rov_joke_fantasma_05", + "$rov_joke_fantasma_06", + "$rov_joke_fantasma_07", + "$rov_joke_fantasma_08", + "$rov_joke_fantasma_09", + "$rov_joke_fantasma_10", }, [FactionMerchantCatalog.JokeTroll] = new[] { - "Why do trolls love bridges? They're always crossing into new territory.", - "Why did the troll get a bad grade? He was always under the bridge of understanding.", - "Trolls don't watch TV - they stream mischief.", - "Trolls love parties - they bring the bridge snacks.", - "Trolls hate Mondays - they bridge the gap to Friday.", - "Where do trolls keep their money? Under the bridge, of course.", - "What's a troll's favorite candy? Bridge bars.", - "Why did the troll go to school? To bridge the knowledge gap.", - "What's a troll's favorite movie? The Bridge Runner.", - "What makes a troll laugh? Someone taking it seriously.", + "$rov_joke_troll_01", + "$rov_joke_troll_02", + "$rov_joke_troll_03", + "$rov_joke_troll_04", + "$rov_joke_troll_05", + "$rov_joke_troll_06", + "$rov_joke_troll_07", + "$rov_joke_troll_08", + "$rov_joke_troll_09", + "$rov_joke_troll_10", }, [FactionMerchantCatalog.JokeNano] = new[] { - "A dwarf who loved gardening had a real green thumbelina.", - "Dwarves make excellent bakers; their scone courses are always the shortest.", - "Why do dwarfs make great secret agents? They can really keep things low-key.", - "A dwarf walks into a bar and hits his head - the bar was set too low.", - "Why are dwarfs so good at math? Because it's the little things that count.", - "I saw a dwarf climbing down a prison wall - it was a little condescending.", - "What do dwarfs use to fight trolls? Short swords.", - "What's a dwarf warrior's motto? Small but deadly.", - "A dwarf opened a bakery because he kneaded dough at his level.", - "What do you call a dwarf who can be invisible? A short circuit!", + "$rov_joke_nano_01", + "$rov_joke_nano_02", + "$rov_joke_nano_03", + "$rov_joke_nano_04", + "$rov_joke_nano_05", + "$rov_joke_nano_06", + "$rov_joke_nano_07", + "$rov_joke_nano_08", + "$rov_joke_nano_09", + "$rov_joke_nano_10", }, [FactionMerchantCatalog.JokeLupoLicantropo] = new[] { - "Why did the werewolf laugh while chewing on the skeleton? He got to the funny bone.", - "Why did the werewolf need to talk with the skeleton? He had a bone to pick with him.", - "A what-to-wear-wolf.", - "My werewolf skills are claw-some.", - "'Howl'-oween, hands down - a werewolf's favorite holiday.", - "Why don't werewolves use cell phones? Because they prefer to roam.", - "Why did the werewolf sit in the corner? He didn't want to be spotted.", - "Why don't werewolves gossip? They can't keep a straight paw.", - "You're fur-ociously awesome.", - "Howl you doin' tonight?", + "$rov_joke_lupolicantropo_01", + "$rov_joke_lupolicantropo_02", + "$rov_joke_lupolicantropo_03", + "$rov_joke_lupolicantropo_04", + "$rov_joke_lupolicantropo_05", + "$rov_joke_lupolicantropo_06", + "$rov_joke_lupolicantropo_07", + "$rov_joke_lupolicantropo_08", + "$rov_joke_lupolicantropo_09", + "$rov_joke_lupolicantropo_10", }, [FactionMerchantCatalog.JokeStrega] = new[] { - "Resting witch face.", - "Hag a nice day.", - "What do you call a mage in the desert? A sand-witch.", - "What happens to witches who break the rules at school? They get ex-spelled.", - "What do witches put in their hair? Scare spray.", - "Why did three witches call in the plumber? Hubble, bubble, toilet trouble.", - "Why couldn't the little witch read her spellbook? It was written in curse-ive.", - "Why did the witch become a lawyer? She wanted to practice witchcraft.", - "Witches don't fart. They cast smells.", - "A witch tells the time by looking at her witch watch.", + "$rov_joke_strega_01", + "$rov_joke_strega_02", + "$rov_joke_strega_03", + "$rov_joke_strega_04", + "$rov_joke_strega_05", + "$rov_joke_strega_06", + "$rov_joke_strega_07", + "$rov_joke_strega_08", + "$rov_joke_strega_09", + "$rov_joke_strega_10", }, [FactionMerchantCatalog.JokeLegnoFalegname] = new[] { - "Carpenters nail it every time: that's their true calling.", - "I told my saw a joke: it couldn't handle the cut.", - "I dated a carpenter once: it was a solid relationship.", - "Carpenters have great timing: they always measure up.", - "My friend builds furniture: he really wood make you laugh.", - "A good carpenter never quits: he just saws what he started.", - "I asked the wood if it was okay: it said, 'I'm board.'", - "I made a joke about a piece of wood, but it was too plane.", - "How do trees access the internet? They just log on!", - "Why did the plank cross the road? To get to the other siding!", + "$rov_joke_legnofalegname_01", + "$rov_joke_legnofalegname_02", + "$rov_joke_legnofalegname_03", + "$rov_joke_legnofalegname_04", + "$rov_joke_legnofalegname_05", + "$rov_joke_legnofalegname_06", + "$rov_joke_legnofalegname_07", + "$rov_joke_legnofalegname_08", + "$rov_joke_legnofalegname_09", + "$rov_joke_legnofalegname_10", }, [FactionMerchantCatalog.JokeGoblin] = new[] { - "Those goblin fingers are dexter-gnome-us.", - "Why did the goblin break the vase? He wanted to smash expectations.", - "That goblin really gnome-napped my sandwich.", - "Just goblin around.", - "They love orc-strating trouble.", - "If a goblin smiles at you, check your pockets.", - "Why don't goblins shower? They prefer natural grime.", - "What's a goblin's favorite sport? Lootball.", - "How do goblins shop? Five-finger discount only.", - "What's a goblin's password? 'MineMineMine!'", + "$rov_joke_goblin_01", + "$rov_joke_goblin_02", + "$rov_joke_goblin_03", + "$rov_joke_goblin_04", + "$rov_joke_goblin_05", + "$rov_joke_goblin_06", + "$rov_joke_goblin_07", + "$rov_joke_goblin_08", + "$rov_joke_goblin_09", + "$rov_joke_goblin_10", }, }; } diff --git a/JotunnModStub/Factions/FactionMerchantSetup.cs b/JotunnModStub/Factions/FactionMerchantSetup.cs index abe283a..6c973db 100644 --- a/JotunnModStub/Factions/FactionMerchantSetup.cs +++ b/JotunnModStub/Factions/FactionMerchantSetup.cs @@ -16,9 +16,9 @@ namespace RacesOfValheim private static readonly string[] GenericGreets = { "..." }; private static readonly string[] GenericGoodbye = { "..." }; - private static readonly string[] GenericStartTrade = { "What do you need?" }; - private static readonly string[] GenericBuy = { "Deal." }; - private static readonly string[] GenericSell = { "Thanks." }; + private static readonly string[] GenericStartTrade = { "$rov_merchant_start_trade" }; + private static readonly string[] GenericBuy = { "$rov_merchant_buy" }; + private static readonly string[] GenericSell = { "$rov_merchant_sell" }; public static void Postfix(Character __instance) { diff --git a/JotunnModStub/Sverm/SvermBrood.cs b/JotunnModStub/Sverm/SvermBrood.cs index be162e4..a77e0ac 100644 --- a/JotunnModStub/Sverm/SvermBrood.cs +++ b/JotunnModStub/Sverm/SvermBrood.cs @@ -51,10 +51,10 @@ namespace RacesOfValheim /// public static readonly List Roster = new List { - new Kind { Id = "brood", Display = "Brood", Source = "SeekerBrood", Icon = "TrophySeeker", Price = 100f, Stage = 1, Cooldown = 60f }, - new Kind { Id = "seeker", Display = "Seeker", Source = "Seeker", Icon = "TrophySeeker", Price = 250f, Stage = 2, Cooldown = 150f }, - new Kind { Id = "soldier", Display = "Soldier", Source = "SeekerBrute", Icon = "TrophySeekerBrute", Price = 500f, Stage = 3, Cooldown = 300f }, - new Kind { Id = "gjall", Display = "Gjall", Source = "Gjall", Icon = "TrophyGjall", Price = 1000f, Stage = 4, Cooldown = 600f, SpawnHeight = 10f }, + new Kind { Id = "brood", Display = "$rov_troop_sverm_brood", Source = "SeekerBrood", Icon = "TrophySeeker", Price = 100f, Stage = 1, Cooldown = 60f }, + new Kind { Id = "seeker", Display = "$rov_troop_sverm_seeker", Source = "Seeker", Icon = "TrophySeeker", Price = 250f, Stage = 2, Cooldown = 150f }, + new Kind { Id = "soldier", Display = "$rov_troop_sverm_soldier", Source = "SeekerBrute", Icon = "TrophySeekerBrute", Price = 500f, Stage = 3, Cooldown = 300f }, + new Kind { Id = "gjall", Display = "$rov_troop_sverm_gjall", Source = "Gjall", Icon = "TrophyGjall", Price = 1000f, Stage = 4, Cooldown = 600f, SpawnHeight = 10f }, }; private static int CapOf(string id) diff --git a/JotunnModStub/Sverm/SvermHive.cs b/JotunnModStub/Sverm/SvermHive.cs index 5470162..cc30a09 100644 --- a/JotunnModStub/Sverm/SvermHive.cs +++ b/JotunnModStub/Sverm/SvermHive.cs @@ -468,7 +468,7 @@ namespace RacesOfValheim // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour. public float GetHoverOffset() => 0f; - public string GetHoverName() => SvermHiveStage.NameOf(SvermHiveStage.Of(transform)); + public string GetHoverName() => Localization.instance.Localize(SvermHiveStage.NameOf(SvermHiveStage.Of(transform))); private ZNetView nview; private float nextSweep; diff --git a/JotunnModStub/Sverm/SvermHiveGoods.cs b/JotunnModStub/Sverm/SvermHiveGoods.cs index 7ba51e6..6284a2d 100644 --- a/JotunnModStub/Sverm/SvermHiveGoods.cs +++ b/JotunnModStub/Sverm/SvermHiveGoods.cs @@ -68,13 +68,11 @@ namespace RacesOfValheim StageUpgrade(3, "TrophySeekerBrute"), StageUpgrade(4, "TrophySeekerQueen"), - Star(1, "Surrenal Glands", 800f, "TrophySeeker", - "Every troop hatched from now on is born with one star.\n\n" + - "It does nothing for the ones already walking around: what is born is born."), + Star(1, ModText.Get("rov_sverm_good_glands_name"), 800f, "TrophySeeker", + ModText.Get("rov_sverm_good_glands_desc")), - Star(2, "Hyperplasia", 1600f, "TrophySeekerQueen", - "Every troop hatched from now on is born with two stars.\n\n" + - "The colony has to have grown the glands first."), + Star(2, ModText.Get("rov_sverm_good_hyperplasia_name"), 1600f, "TrophySeekerQueen", + ModText.Get("rov_sverm_good_hyperplasia_desc")), }; foreach (SvermBrood.Kind kind in SvermBrood.Roster) shelf.Add(Troop(kind)); @@ -94,23 +92,20 @@ namespace RacesOfValheim return new Good { Id = "blistertick", - Name = SvermBlisterTick.DisplayName, + Name = Localization.instance.Localize(SvermBlisterTick.DisplayName), Price = SvermConfig.TickPrice, Icon = "TrophyTick", - Description = "Buys a PERMANENT slot in the colony. What stands in it runs at whatever " + - "the colony is fighting and bursts, and thirty seconds later the nest " + - "grows another one - no egg, no biomass, forever.\n\n" + - "The blast spares you, your tames and the rest of the colony.", + Description = ModText.Get("rov_sverm_good_tick_desc"), Refusal = hive => { int slots = SvermBlisterTick.SlotsOf(hive.transform); if (slots >= SvermConfigManagement.BlisterTick) { - return $"The colony already keeps {slots} of them."; + return ModText.Get("rov_sverm_refusal_keeps", slots); } - if (SvermBroodEggs.Count(hive.transform) < 1) return "No brood egg ready."; + if (SvermBroodEggs.Count(hive.transform) < 1) return ModText.Get("rov_sverm_refusal_no_egg"); return null; }, @@ -143,20 +138,17 @@ namespace RacesOfValheim return new Good { Id = "stage" + target, - Name = SvermHiveStage.NameOf(target), + Name = Localization.instance.Localize(SvermHiveStage.NameOf(target)), Price = SvermHiveStage.PriceToLeave(from), Icon = icon, - Description = $"Grows the nest into a {SvermHiveStage.NameOf(target)}: it holds " + - $"{SvermHiveStage.Capacity(target):0} biomass instead of " + - $"{SvermHiveStage.Capacity(from):0}, and stands half again as tall.\n\n" + - "It costs this stage's whole tankful, so it leaves the hive all but " + - "empty. Grow or field an army - never both in the same breath.", + Description = ModText.Get("rov_sverm_good_stage_desc", SvermHiveStage.NameOf(target), + SvermHiveStage.Capacity(target).ToString("0"), SvermHiveStage.Capacity(from).ToString("0")), Refusal = hive => { int stage = SvermHiveStage.Of(hive.transform); - if (stage > from) return "Already grown past this."; - if (stage < from) return $"The nest has to be a {SvermHiveStage.NameOf(from)} first."; + if (stage > from) return ModText.Get("rov_sverm_refusal_grown_past"); + if (stage < from) return ModText.Get("rov_sverm_refusal_stage_first", SvermHiveStage.NameOf(from)); return null; }, @@ -187,8 +179,8 @@ namespace RacesOfValheim Refusal = hive => { int have = SvermBroodStars.Of(hive.transform); - if (have >= stars) return "The colony already breeds like this."; - if (have < stars - 1) return "One star at a time."; + if (have >= stars) return ModText.Get("rov_sverm_refusal_already_breeds"); + if (have < stars - 1) return ModText.Get("rov_sverm_refusal_one_star"); return null; }, @@ -208,25 +200,23 @@ namespace RacesOfValheim return new Good { Id = "troop_" + kind.Id, - Name = kind.Display, + Name = Localization.instance.Localize(kind.Display), Price = kind.Price, Icon = kind.Icon, - Description = $"Hatches a {kind.Display}, bound to this nest: it follows when you ask, " + - $"walks home when you let it go, and mends itself.\n\n" + - $"Costs one brood egg as well as the biomass. At most {kind.Cap} of them alive at once.", + Description = ModText.Get("rov_sverm_good_troop_desc", kind.Display, kind.Cap), Refusal = hive => { int stage = SvermHiveStage.Of(hive.transform); if (stage < kind.Stage) { - return $"The nest has to be a {SvermHiveStage.NameOf(kind.Stage)} first."; + return ModText.Get("rov_sverm_refusal_stage_first", SvermHiveStage.NameOf(kind.Stage)); } int alive = SvermBrood.CountAlive(hive, kind); - if (alive >= kind.Cap) return $"The colony is already keeping {alive} of them."; + if (alive >= kind.Cap) return ModText.Get("rov_sverm_refusal_keeping", alive); - if (SvermBroodEggs.Count(hive.transform) < 1) return "No brood egg ready."; + if (SvermBroodEggs.Count(hive.transform) < 1) return ModText.Get("rov_sverm_refusal_no_egg"); return null; }, @@ -265,7 +255,7 @@ namespace RacesOfValheim /// public static string RefusalFor(Good good, SvermHiveBehaviour hive) { - if (good == null || hive == null) return "No hive."; + if (good == null || hive == null) return ModText.Get("rov_sverm_refusal_no_hive"); string ownRefusal = good.Refusal != null ? good.Refusal(hive) : null; if (ownRefusal != null) return ownRefusal; @@ -274,11 +264,11 @@ namespace RacesOfValheim if (waitingSeconds > 0L) { return waitingSeconds >= 60L - ? $"The hive is still working on the last one ({waitingSeconds / 60}m)." - : $"The hive is still working on the last one ({waitingSeconds}s)."; + ? ModText.Get("rov_sverm_refusal_working_m", waitingSeconds / 60) + : ModText.Get("rov_sverm_refusal_working_s", waitingSeconds); } - if (SvermBiomass.Bank(hive.transform) < good.Price) return "Not enough biomass in the bank."; + if (SvermBiomass.Bank(hive.transform) < good.Price) return ModText.Get("rov_msg_sverm_not_enough_biomass_bank"); return null; } diff --git a/JotunnModStub/Sverm/SvermHiveStage.cs b/JotunnModStub/Sverm/SvermHiveStage.cs index 1ccbb8a..09f8b32 100644 --- a/JotunnModStub/Sverm/SvermHiveStage.cs +++ b/JotunnModStub/Sverm/SvermHiveStage.cs @@ -27,12 +27,13 @@ namespace RacesOfValheim public const int Last = 4; /// The four names from section 2. The piece is registered under the first one. + /// Translation tokens, not text: localize them wherever they are shown. public static readonly string[] Names = { - "Brood Mound", - "Gorged Hive", - "Nesting Spire", - "Hive Citadel", + "$rov_piece_sverm_broodmound_name", + "$rov_sverm_stage_gorgedhive", + "$rov_sverm_stage_nestingspire", + "$rov_sverm_stage_hivecitadel", }; public static int Of(Transform nest) diff --git a/JotunnModStub/Translations/English/merchants.json b/JotunnModStub/Translations/English/merchants.json new file mode 100644 index 0000000..3b40204 --- /dev/null +++ b/JotunnModStub/Translations/English/merchants.json @@ -0,0 +1,133 @@ +{ + "rov_joke_fantasma_01": "Why was the ghost lonely? It had no-body.", + "rov_joke_fantasma_02": "What's the most useless room in a house for a ghost? A living room.", + "rov_joke_fantasma_03": "What's a ghost's favourite cheese? Ghoul-da cheese.", + "rov_joke_fantasma_04": "What's a ghost's favourite food? Boo-rritos.", + "rov_joke_fantasma_05": "What's a ghost's favourite dessert? I-scream.", + "rov_joke_fantasma_06": "What's a ghost's favourite game? Hide and Shriek.", + "rov_joke_fantasma_07": "What do you call a ghost with a broken leg? A hoblin goblin.", + "rov_joke_fantasma_08": "What happens when a ghost gets lost in the fog? He is mist.", + "rov_joke_fantasma_09": "Ghosts love elevators because it lifts their spirits.", + "rov_joke_fantasma_10": "Why did the ghost cross the road? Because it was a poultry-geist.", + "rov_joke_goblin_01": "Those goblin fingers are dexter-gnome-us.", + "rov_joke_goblin_02": "Why did the goblin break the vase? He wanted to smash expectations.", + "rov_joke_goblin_03": "That goblin really gnome-napped my sandwich.", + "rov_joke_goblin_04": "Just goblin around.", + "rov_joke_goblin_05": "They love orc-strating trouble.", + "rov_joke_goblin_06": "If a goblin smiles at you, check your pockets.", + "rov_joke_goblin_07": "Why don't goblins shower? They prefer natural grime.", + "rov_joke_goblin_08": "What's a goblin's favorite sport? Lootball.", + "rov_joke_goblin_09": "How do goblins shop? Five-finger discount only.", + "rov_joke_goblin_10": "What's a goblin's password? 'MineMineMine!'", + "rov_joke_legnofalegname_01": "Carpenters nail it every time: that's their true calling.", + "rov_joke_legnofalegname_02": "I told my saw a joke: it couldn't handle the cut.", + "rov_joke_legnofalegname_03": "I dated a carpenter once: it was a solid relationship.", + "rov_joke_legnofalegname_04": "Carpenters have great timing: they always measure up.", + "rov_joke_legnofalegname_05": "My friend builds furniture: he really wood make you laugh.", + "rov_joke_legnofalegname_06": "A good carpenter never quits: he just saws what he started.", + "rov_joke_legnofalegname_07": "I asked the wood if it was okay: it said, 'I'm board.'", + "rov_joke_legnofalegname_08": "I made a joke about a piece of wood, but it was too plane.", + "rov_joke_legnofalegname_09": "How do trees access the internet? They just log on!", + "rov_joke_legnofalegname_10": "Why did the plank cross the road? To get to the other siding!", + "rov_joke_lupolicantropo_01": "Why did the werewolf laugh while chewing on the skeleton? He got to the funny bone.", + "rov_joke_lupolicantropo_02": "Why did the werewolf need to talk with the skeleton? He had a bone to pick with him.", + "rov_joke_lupolicantropo_03": "A what-to-wear-wolf.", + "rov_joke_lupolicantropo_04": "My werewolf skills are claw-some.", + "rov_joke_lupolicantropo_05": "'Howl'-oween, hands down - a werewolf's favorite holiday.", + "rov_joke_lupolicantropo_06": "Why don't werewolves use cell phones? Because they prefer to roam.", + "rov_joke_lupolicantropo_07": "Why did the werewolf sit in the corner? He didn't want to be spotted.", + "rov_joke_lupolicantropo_08": "Why don't werewolves gossip? They can't keep a straight paw.", + "rov_joke_lupolicantropo_09": "You're fur-ociously awesome.", + "rov_joke_lupolicantropo_10": "Howl you doin' tonight?", + "rov_joke_nano_01": "A dwarf who loved gardening had a real green thumbelina.", + "rov_joke_nano_02": "Dwarves make excellent bakers; their scone courses are always the shortest.", + "rov_joke_nano_03": "Why do dwarfs make great secret agents? They can really keep things low-key.", + "rov_joke_nano_04": "A dwarf walks into a bar and hits his head - the bar was set too low.", + "rov_joke_nano_05": "Why are dwarfs so good at math? Because it's the little things that count.", + "rov_joke_nano_06": "I saw a dwarf climbing down a prison wall - it was a little condescending.", + "rov_joke_nano_07": "What do dwarfs use to fight trolls? Short swords.", + "rov_joke_nano_08": "What's a dwarf warrior's motto? Small but deadly.", + "rov_joke_nano_09": "A dwarf opened a bakery because he kneaded dough at his level.", + "rov_joke_nano_10": "What do you call a dwarf who can be invisible? A short circuit!", + "rov_joke_nonmortozombie_01": "When do zombies go to sleep? When they are dead tired.", + "rov_joke_nonmortozombie_02": "What streets do zombies live on? Dead ends.", + "rov_joke_nonmortozombie_03": "Where do zombies go sailing? Lake Eerie.", + "rov_joke_nonmortozombie_04": "What do you call a zombie in pajamas? The sleepwalking dead.", + "rov_joke_nonmortozombie_05": "How are zombies like computers? They use mega-bites!", + "rov_joke_nonmortozombie_06": "Why did the zombie lose his lawsuit? He had no leg to stand on!", + "rov_joke_nonmortozombie_07": "Why did the zombie eat a light bulb? Because he wanted a light snack.", + "rov_joke_nonmortozombie_08": "Why don't zombies eat clowns? Because they taste funny!", + "rov_joke_nonmortozombie_09": "Why did the zombie go to school? To improve his brainpower.", + "rov_joke_nonmortozombie_10": "Zombies are hopeless romantics, seeking their ghoul-mate.", + "rov_joke_scheletro_01": "What do you call a skeleton who never does his chores? Lazy bones.", + "rov_joke_scheletro_02": "Why did the skeleton quit his job? His heart wasn't in it.", + "rov_joke_scheletro_03": "What skeleton was the first emperor of France? Napoleon Bone-aparte.", + "rov_joke_scheletro_04": "Who is the world's most famous skeleton detective? Sherlock Bones.", + "rov_joke_scheletro_05": "What did the French skeletons say before eating their dinner? Bone appetit!", + "rov_joke_scheletro_06": "What do skeletons always order when they go to a restaurant? Spare ribs.", + "rov_joke_scheletro_07": "How do skeletons call each other? On their tele-bone.", + "rov_joke_scheletro_08": "What's a skeleton's favorite fruit? Bone-ana!", + "rov_joke_scheletro_09": "Why are skeletons bad at lying? You can see right through them!", + "rov_joke_scheletro_10": "Why don't skeletons fight each other? They don't have the guts.", + "rov_joke_strega_01": "Resting witch face.", + "rov_joke_strega_02": "Hag a nice day.", + "rov_joke_strega_03": "What do you call a mage in the desert? A sand-witch.", + "rov_joke_strega_04": "What happens to witches who break the rules at school? They get ex-spelled.", + "rov_joke_strega_05": "What do witches put in their hair? Scare spray.", + "rov_joke_strega_06": "Why did three witches call in the plumber? Hubble, bubble, toilet trouble.", + "rov_joke_strega_07": "Why couldn't the little witch read her spellbook? It was written in curse-ive.", + "rov_joke_strega_08": "Why did the witch become a lawyer? She wanted to practice witchcraft.", + "rov_joke_strega_09": "Witches don't fart. They cast smells.", + "rov_joke_strega_10": "A witch tells the time by looking at her witch watch.", + "rov_joke_troll_01": "Why do trolls love bridges? They're always crossing into new territory.", + "rov_joke_troll_02": "Why did the troll get a bad grade? He was always under the bridge of understanding.", + "rov_joke_troll_03": "Trolls don't watch TV - they stream mischief.", + "rov_joke_troll_04": "Trolls love parties - they bring the bridge snacks.", + "rov_joke_troll_05": "Trolls hate Mondays - they bridge the gap to Friday.", + "rov_joke_troll_06": "Where do trolls keep their money? Under the bridge, of course.", + "rov_joke_troll_07": "What's a troll's favorite candy? Bridge bars.", + "rov_joke_troll_08": "Why did the troll go to school? To bridge the knowledge gap.", + "rov_joke_troll_09": "What's a troll's favorite movie? The Bridge Runner.", + "rov_joke_troll_10": "What makes a troll laugh? Someone taking it seriously.", + "rov_merchant_buy": "Deal.", + "rov_merchant_dverg_name": "Dverg", + "rov_merchant_sell": "Thanks.", + "rov_merchant_start_trade": "What do you need?", + "rov_sverm_good_glands_desc": "Every troop hatched from now on is born with one star.\n\nIt does nothing for the ones already walking around: what is born is born.", + "rov_sverm_good_glands_name": "Surrenal Glands", + "rov_sverm_good_hyperplasia_desc": "Every troop hatched from now on is born with two stars.\n\nThe colony has to have grown the glands first.", + "rov_sverm_good_hyperplasia_name": "Hyperplasia", + "rov_sverm_good_stage_desc": "Grows the nest into a $1: it holds $2 biomass instead of $3, and stands half again as tall.\n\nIt costs this stage's whole tankful, so it leaves the hive all but empty. Grow or field an army - never both in the same breath.", + "rov_sverm_good_tick_desc": "Buys a PERMANENT slot in the colony. What stands in it runs at whatever the colony is fighting and bursts, and thirty seconds later the nest grows another one - no egg, no biomass, forever.\n\nThe blast spares you, your tames and the rest of the colony.", + "rov_sverm_good_troop_desc": "Hatches a $1, bound to this nest: it follows when you ask, walks home when you let it go, and mends itself.\n\nCosts one brood egg as well as the biomass. At most $2 of them alive at once.", + "rov_sverm_refusal_already_breeds": "The colony already breeds like this.", + "rov_sverm_refusal_grown_past": "Already grown past this.", + "rov_sverm_refusal_keeping": "The colony is already keeping $1 of them.", + "rov_sverm_refusal_keeps": "The colony already keeps $1 of them.", + "rov_sverm_refusal_no_egg": "No brood egg ready.", + "rov_sverm_refusal_no_hive": "No hive.", + "rov_sverm_refusal_one_star": "One star at a time.", + "rov_sverm_refusal_stage_first": "The nest has to be a $1 first.", + "rov_sverm_refusal_working_m": "The hive is still working on the last one ($1m).", + "rov_sverm_refusal_working_s": "The hive is still working on the last one ($1s).", + "rov_sverm_stage_gorgedhive": "Gorged Hive", + "rov_sverm_stage_hivecitadel": "Hive Citadel", + "rov_sverm_stage_nestingspire": "Nesting Spire", + "rov_troop_dvergar_ash_guard": "Ash Guard", + "rov_troop_dvergar_escort": "Escort", + "rov_troop_dvergar_fire_crew": "Fire Crew", + "rov_troop_dvergar_runic_crew": "Runic Crew", + "rov_troop_dvergar_seal_price": "List price $1 - your seal takes it to $2.", + "rov_troop_dvergar_terms": "They answer the follow command, knit their own wounds shut, keep your truce with the mountain's dvergr, drop nothing, and do not come back. A dead crew is money spent.", + "rov_troop_dvergar_yard_patrol": "Yard Patrol", + "rov_troop_sverm_brood": "Brood", + "rov_troop_sverm_gjall": "Gjall", + "rov_troop_sverm_seeker": "Seeker", + "rov_troop_sverm_soldier": "Soldier", + "rov_troop_trol_goblin_band": "Fuling War Band", + "rov_troop_trol_goblin_patrol": "Fuling Patrol", + "rov_troop_trol_greydwarf_patrol": "Greydwarf Patrol", + "rov_troop_trol_terms": "They answer the follow command, knit their own wounds shut, drop nothing, and do not come back. A dead warband is money spent.", + "rov_troop_trol_troll": "Troll", + "rov_troop_trol_troll_summoned": "Staff Troll" +} diff --git a/JotunnModStub/Translations/Italian/merchants.json b/JotunnModStub/Translations/Italian/merchants.json new file mode 100644 index 0000000..2c9fc31 --- /dev/null +++ b/JotunnModStub/Translations/Italian/merchants.json @@ -0,0 +1,43 @@ +{ + "rov_merchant_buy": "Affare fatto.", + "rov_merchant_dverg_name": "Dverg", + "rov_merchant_sell": "Grazie.", + "rov_merchant_start_trade": "Di cosa hai bisogno?", + "rov_sverm_good_glands_desc": "Da ora ogni truppa che si schiude nasce con una stella.\n\nNon cambia niente per quelle che già camminano: ciò che è nato è nato.", + "rov_sverm_good_glands_name": "Ghiandole surrenali", + "rov_sverm_good_hyperplasia_desc": "Da ora ogni truppa che si schiude nasce con due stelle.\n\nPrima la colonia deve aver sviluppato le ghiandole.", + "rov_sverm_good_hyperplasia_name": "Iperplasia", + "rov_sverm_good_stage_desc": "Fa crescere il nido fino a $1: contiene $2 di biomassa invece di $3, ed è alto una volta e mezza.\n\nCosta l'intera riserva di questo stadio, quindi lascia l'alveare quasi vuoto. Cresci o schiera un esercito: mai entrambe le cose insieme.", + "rov_sverm_good_tick_desc": "Compra un posto PERMANENTE nella colonia. Ciò che lo occupa corre contro chiunque la colonia stia combattendo ed esplode, e trenta secondi dopo il nido ne fa crescere un altro: niente uovo, niente biomassa, per sempre.\n\nL'esplosione risparmia te, le tue creature addomesticate e il resto della colonia.", + "rov_sverm_good_troop_desc": "Fa schiudere: $1, legato a questo nido. Ti segue quando glielo chiedi, torna a casa quando lo lasci andare e si ripara da solo.\n\nCosta un uovo della covata oltre alla biomassa. Al massimo $2 vivi alla volta.", + "rov_sverm_refusal_already_breeds": "La colonia si riproduce già così.", + "rov_sverm_refusal_grown_past": "Già cresciuto oltre questo stadio.", + "rov_sverm_refusal_keeping": "La colonia ne sta già tenendo $1.", + "rov_sverm_refusal_keeps": "La colonia ne tiene già $1.", + "rov_sverm_refusal_no_egg": "Nessun uovo della covata pronto.", + "rov_sverm_refusal_no_hive": "Nessun alveare.", + "rov_sverm_refusal_one_star": "Una stella alla volta.", + "rov_sverm_refusal_stage_first": "Prima il nido deve diventare: $1.", + "rov_sverm_refusal_working_m": "L'alveare sta ancora lavorando all'ultimo ($1m).", + "rov_sverm_refusal_working_s": "L'alveare sta ancora lavorando all'ultimo ($1s).", + "rov_sverm_stage_gorgedhive": "Alveare rigonfio", + "rov_sverm_stage_hivecitadel": "Cittadella dell'alveare", + "rov_sverm_stage_nestingspire": "Guglia del nido", + "rov_troop_dvergar_ash_guard": "Guardia di cenere", + "rov_troop_dvergar_escort": "Scorta", + "rov_troop_dvergar_fire_crew": "Squadra del fuoco", + "rov_troop_dvergar_runic_crew": "Squadra runica", + "rov_troop_dvergar_seal_price": "Prezzo di listino $1: il tuo sigillo lo porta a $2.", + "rov_troop_dvergar_terms": "Rispondono al comando di seguirti, si ricuciono da soli le ferite, rispettano la tua tregua con i dvergr della montagna, non lasciano bottino e non tornano. Una squadra morta è denaro speso.", + "rov_troop_dvergar_yard_patrol": "Ronda del cortile", + "rov_troop_sverm_brood": "Covata", + "rov_troop_sverm_gjall": "Gjall", + "rov_troop_sverm_seeker": "Cercatore", + "rov_troop_sverm_soldier": "Soldato", + "rov_troop_trol_goblin_band": "Banda da guerra Fuling", + "rov_troop_trol_goblin_patrol": "Pattuglia Fuling", + "rov_troop_trol_greydwarf_patrol": "Pattuglia di nani grigi", + "rov_troop_trol_terms": "Rispondono al comando di seguirti, si ricuciono da soli le ferite, non lasciano bottino e non tornano. Una banda morta è denaro speso.", + "rov_troop_trol_troll": "Troll", + "rov_troop_trol_troll_summoned": "Troll del bastone" +} diff --git a/JotunnModStub/Trol/TrolTotem.cs b/JotunnModStub/Trol/TrolTotem.cs index 9187631..99f94c9 100644 --- a/JotunnModStub/Trol/TrolTotem.cs +++ b/JotunnModStub/Trol/TrolTotem.cs @@ -93,7 +93,7 @@ namespace RacesOfValheim { new Troop { - Id = "greydwarf_patrol", Display = "Greydwarf Patrol", Price = 400, NeedsUpgrade = false, Icon = "TrophyGreydwarfBrute", + Id = "greydwarf_patrol", Display = "$rov_troop_trol_greydwarf_patrol", Price = 400, NeedsUpgrade = false, Icon = "TrophyGreydwarfBrute", Members = new[] { new KeyValuePair("Greydwarf", 4), @@ -103,17 +103,17 @@ namespace RacesOfValheim }, new Troop { - Id = "troll", Display = "Troll", Price = 700, NeedsUpgrade = false, Icon = "TrophyForestTroll", + Id = "troll", Display = "$rov_troop_trol_troll", Price = 700, NeedsUpgrade = false, Icon = "TrophyForestTroll", Members = new[] { new KeyValuePair("Troll", 1) } }, new Troop { - Id = "troll_summoned", Display = "Staff Troll", Price = 900, NeedsUpgrade = false, Icon = "TrophyForestTroll", + Id = "troll_summoned", Display = "$rov_troop_trol_troll_summoned", Price = 900, NeedsUpgrade = false, Icon = "TrophyForestTroll", Members = new[] { new KeyValuePair("Troll_Summoned", 1) } }, new Troop { - Id = "goblin_patrol", Display = "Fuling Patrol", Price = 1400, NeedsUpgrade = true, Icon = "TrophyGoblinBrute", + Id = "goblin_patrol", Display = "$rov_troop_trol_goblin_patrol", Price = 1400, NeedsUpgrade = true, Icon = "TrophyGoblinBrute", Members = new[] { new KeyValuePair("Goblin", 4), @@ -123,7 +123,7 @@ namespace RacesOfValheim }, new Troop { - Id = "goblin_band", Display = "Fuling War Band", Price = 2000, NeedsUpgrade = true, Icon = "TrophyGoblin", + Id = "goblin_band", Display = "$rov_troop_trol_goblin_band", Price = 2000, NeedsUpgrade = true, Icon = "TrophyGoblin", Members = new[] { new KeyValuePair("Goblin", 4), diff --git a/JotunnModStub/Trol/TrolTotemStore.cs b/JotunnModStub/Trol/TrolTotemStore.cs index 2bb61f1..c361c1e 100644 --- a/JotunnModStub/Trol/TrolTotemStore.cs +++ b/JotunnModStub/Trol/TrolTotemStore.cs @@ -128,13 +128,13 @@ namespace RacesOfValheim else Jotunn.Logger.LogWarning($"[Trol] No icon on '{troop.Icon}' for {troop.Display}; the row keeps " + "whatever the cloned element was showing."); - element.transform.Find("name").GetComponent().text = troop.Display; + element.transform.Find("name").GetComponent().text = Localization.instance.Localize(troop.Display); TMP_Text price = FindDescendant(element.transform, "price"); if (price != null) price.text = troop.Price.ToString(); UITooltip tooltip = element.GetComponent(); - if (tooltip != null) tooltip.Set(troop.Display, Composition(troop), gui.m_tooltipAnchor, default(Vector2)); + if (tooltip != null) tooltip.Set(Localization.instance.Localize(troop.Display), Composition(troop), gui.m_tooltipAnchor, default(Vector2)); string id = troop.Id; element.GetComponent