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",