From 851247ea6036a4760a148792cb4d99dff7e1137a Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 7 Aug 2026 09:56:16 +0200 Subject: [PATCH 001/311] chore(release): v1.4.0 - Factions, Configuration Manager, Trol log-grab fix Documents everything that landed on main since 1.3.12 (Factions peace + merchants, BepInEx Configuration Manager across all nine races, Dvergar/Aswid eye glow, Skeleton head-visibility and menu-preview fixes) and bumps the version accordingly. Also fixes a real bug found while writing this changelog: Trol's True Form log-grab was piggybacked on pressing the True Form key a second time, with no on-screen hint it existed. It now has its own keybind (default E, configurable like every other race's keys) and a proper crosshair prompt patched onto vanilla's own HoverText component - the first attempt added a second, competing Hoverable component to the log and it was silently never reached, since Unity's GetComponentInParent() only returns the first match and vanilla's own HoverText was already on the object. --- JotunnModStub/Package/manifest.json | 2 +- JotunnModStub/RacesOfValheim.cs | 2 +- JotunnModStub/Trol/TrolConfig.cs | 3 +++ JotunnModStub/Trol/TrolLogWeapon.cs | 31 +++++++++++++++++++++++++ JotunnModStub/Trol/TrolRace.cs | 35 +++++++++++++++++++---------- README.md | 25 ++++++++++++++++++++- manifest.json | 2 +- 7 files changed, 84 insertions(+), 16 deletions(-) diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 2ea7b24..7ae2ba9 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.3.12", + "version_number": "1.4.0", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 09d87f8..f39e47e 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.3.12"; + public const string PluginVersion = "1.4.0"; private readonly Harmony harmony = new Harmony(PluginGUID); diff --git a/JotunnModStub/Trol/TrolConfig.cs b/JotunnModStub/Trol/TrolConfig.cs index de2c18e..ab70e87 100644 --- a/JotunnModStub/Trol/TrolConfig.cs +++ b/JotunnModStub/Trol/TrolConfig.cs @@ -22,6 +22,7 @@ namespace RacesOfValheim // ─── Keybinds ────────────────────────────────────────────────────────── public static ConfigEntry ThrowRockKey; public static ConfigEntry TrueFormKey; + public static ConfigEntry GrabLogKey; // ─── Passive combat ────────────────────────────────────────────────── public static ConfigEntry FireWeaknessMultiplier; @@ -65,6 +66,8 @@ namespace RacesOfValheim new ConfigDescription("Throws a rock (or the log you're holding), tier 3+.")); TrueFormKey = config.Bind(keybinds, "True Form", new KeyboardShortcut(KeyCode.H), new ConfigDescription("Transform into (or revert from) True Form, tier 5+.")); + GrabLogKey = config.Bind(keybinds, "Grab Log", new KeyboardShortcut(KeyCode.E), + new ConfigDescription("Grabs a felled log as a weapon while looking at one, tier 7+ and already in True Form. Matches vanilla's own interact key rather than reusing the True Form key a second time.")); const string combat = "Trol - Passive Combat"; FireWeaknessMultiplier = config.Bind(combat, "Fire Weakness Multiplier", 1.5f, diff --git a/JotunnModStub/Trol/TrolLogWeapon.cs b/JotunnModStub/Trol/TrolLogWeapon.cs index 97fcbf8..34b55a4 100644 --- a/JotunnModStub/Trol/TrolLogWeapon.cs +++ b/JotunnModStub/Trol/TrolLogWeapon.cs @@ -94,4 +94,35 @@ namespace RacesOfValheim } } } + + /// + /// A fallen log already shows a hover prompt in vanilla - its own name, via a HoverText + /// component vanilla itself attaches (confirmed live: GetComponentInParent<Hoverable>() + /// on a log resolves to HoverText, not TreeLog itself, which only implements IDestructible). + /// A first attempt added a second, competing Hoverable component to the same GameObject and + /// it was never reached - Unity's GetComponentInParent<T>() returns only the first + /// match, and vanilla's own HoverText was already there first. The fix is to append to + /// HoverText's own result instead of trying to out-compete it. + /// + [HarmonyPatch(typeof(HoverText), "GetHoverText")] + public static class Trol_LogHoverText_Patch + { + public static void Postfix(HoverText __instance, ref string __result) + { + if (Player.m_localPlayer == null || !TrolRace.IsTrol()) return; + if (BossProgressionManager.GetCurrentProgressionState() < 7) return; + if (!Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode())) return; + + TreeLog log = ((Component)__instance).GetComponentInParent(); + if (log == null) return; + + // Already holding a log - grabbing again is a no-op in TrolLogWeapon.GrabLog, so no + // prompt either. + ItemDrop.ItemData rightItem = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_rightItem").Value; + 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"; + } + } } diff --git a/JotunnModStub/Trol/TrolRace.cs b/JotunnModStub/Trol/TrolRace.cs index a132bc8..edb3439 100644 --- a/JotunnModStub/Trol/TrolRace.cs +++ b/JotunnModStub/Trol/TrolRace.cs @@ -130,6 +130,11 @@ namespace RacesOfValheim { TryTrueForm(); } + + if (TrolConfig.GrabLogKey.Value.IsDown()) + { + TryGrabLog(); + } } // Check log durability @@ -176,18 +181,9 @@ namespace RacesOfValheim if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode())) { - if (BossProgressionManager.GetCurrentProgressionState() >= 7) - { - GameObject hoverObj = Player.m_localPlayer.GetHoverObject(); - if (hoverObj != null) - { - TreeLog log = hoverObj.GetComponentInParent(); - if (log != null) - { - TrolLogWeapon.GrabLog(Player.m_localPlayer, log); - } - } - } + // 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. return; } @@ -205,6 +201,21 @@ namespace RacesOfValheim } } + private void TryGrabLog() + { + if (BossProgressionManager.GetCurrentProgressionState() < 7) return; + if (!Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode())) return; + + GameObject hoverObj = Player.m_localPlayer.GetHoverObject(); + if (hoverObj == null) return; + + TreeLog log = hoverObj.GetComponentInParent(); + if (log != null) + { + TrolLogWeapon.GrabLog(Player.m_localPlayer, log); + } + } + private System.Collections.IEnumerator TransformToTrueFormRoutine() { isTransforming = true; diff --git a/README.md b/README.md index 10a993b..67cc45a 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ A comprehensive Valheim mod that allows you to play as different unique races, e ## Features -This mod currently introduces 8 custom races: +This mod currently introduces 9 custom races: ### 1. Skeleton - **Stamina-less Combat**: Skeletons do not consume stamina and do not use the stamina bar. @@ -173,6 +173,20 @@ stored on your character and travels with you between servers). In personal mode boss's secondary drop to the ward - Hard Antler, Crypt Key, Wishbone, Dragon Tear, Yagluth's thing, the Queen's carapace, Fader's relic - to claim that boss's tier. +## Factions + +Every race is grouped into one of three factions, alongside a handful of vanilla creatures. +None of your faction's mobs will attack you first, and several of them go a step further: +approach one and press **E** to trade. Buy price and sell price are always the same, so +nothing is a loss to sell back. + +- **Black Forest** - Trenta, Trol, Furling: at peace with Greydwarves (and their Elite and + Shaman kin), Fuling, Goblin Brute, Goblin Shaman, and Troll. +- **Mountain** - Skadi, Fenrir, Dvergar: at peace with the Drake, Wolf, Ulv, Fenring (and its + Cultists), and every Dverger. +- **Swamp** - Aswid, Draugh, Skeleton: at peace with Ghosts, Skeletons, Draugr, Wraiths, + Leeches, Abominations, and Blobs. + ## Development & Feedback This is a stable release of Races of Valheim, but the mod is actively in development! We plan to add more races, gameplay elements, and refine the mechanics in future updates. @@ -181,6 +195,15 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** ## Changelog +**v1.4.0** +- **NEW - Factions**: Every race now has peace with a slice of vanilla's hostile roster, grouped into three factions - Black Forest (Trenta, Trol, Furling: Greydwarves, Fuling, Goblin Brute/Shaman, Troll), Mountain (Skadi, Fenrir, Dvergar: Drake, Wolf, Ulv, Fenring/Cultist, Dverger), and Swamp (Aswid, Draugh, Skeleton: Ghost, Skeleton, Draugr, Wraith, Leech, Abomination, Blob). Several of those mobs also talk and trade now - approach one with your matching race and it opens a shop instead of attacking, buying and selling at the same price. +- **NEW - Configuration Manager for every race**: every ability number, cooldown and keybind across all nine races can now be retuned from BepInEx's Configuration Manager, organized into per-topic sections (Keybinds first, then Passive Combat, then the rest), or by hand-editing the .cfg file it generates. +- **Trol**: Grabbing a felled log as a True Form weapon (tier 7+) has its own keybind now (default **E**) instead of piggybacking on the True Form key a second time, and shows a proper crosshair prompt - **[E] Grab Log** - so it's no longer a hidden mechanic with no on-screen hint. +- **Dvergar**: Eyes finally glow - a cold teal-blue that shifts to a starred creature's own colours once you're strong enough to earn them. +- **Aswid**: Eyes glow an evil red, the way the compendium always described them. +- **Skeleton**: Fixed a bug where a helmet or beard could stay visible even while the race's own head-hiding was active. +- **Skeleton**: Your chosen race now shows correctly on the main-menu character preview. + **v1.3.12** - **Skadi**: Dragon flight reworked. The stasis that holds a form level after you stop powering now lasts 5 seconds instead of 2. Hold Shift with W to spend 15 stamina a second on a burst of speed - the only part of flight that costs anything, since the drake arrives at The Elder long before you could pay just to stay airborne, and running dry drops you back to normal speed rather than out of the sky. S beats backwards along your aim, pitch included: look down and press it to rise away from whatever you are watching, without turning to face away from it. - **Skadi**: Water is no longer a trap. A flying form beats its way back out of the sea instead of paddling on the surface until it finds land. Valheim hands a swimming character to its swimming code before it ever asks whether they are flying, which is why the Aswid's bat could always take off from water and Moder never could. diff --git a/manifest.json b/manifest.json index 2ea7b24..7ae2ba9 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.3.12", + "version_number": "1.4.0", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From fc6cd4f4d45ced83ef0a7b41fbc45d3ade533398 Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 7 Aug 2026 10:13:00 +0200 Subject: [PATCH 002/311] fix(skeleton): stop the burning skull's torch clone falling off The head-flame VFX clones only the source torch's ParticleSystem subtree, then stripped components with a blocklist (every MonoBehaviour, every Collider) to leave a bare flame. The blocklist missed Rigidbody - not a MonoBehaviour in Unity - so a torch whose fire-particle node carried one kept being acted on by physics independently of the parent GameObject that tracks the head each frame, and visibly fell away from the skull. Switched to an allowlist: keep only Transform/ParticleSystem/ ParticleSystemRenderer/Light, destroy everything else on the clone. Can't miss a component type this way, whatever it turns out to be next. --- JotunnModStub/Skeleton/SkeletonVisuals.cs | 18 ++++++++++++------ 1 file changed, 12 insertions(+), 6 deletions(-) diff --git a/JotunnModStub/Skeleton/SkeletonVisuals.cs b/JotunnModStub/Skeleton/SkeletonVisuals.cs index 1c5f41e..d4ec7c0 100644 --- a/JotunnModStub/Skeleton/SkeletonVisuals.cs +++ b/JotunnModStub/Skeleton/SkeletonVisuals.cs @@ -213,15 +213,21 @@ namespace RacesOfValheim light.intensity *= 0.6f; } - // Anything that made the source a torch rather than a fire. - foreach (MonoBehaviour comp in m_instance.GetComponentsInChildren(true)) + // 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); } - foreach (Collider col in m_instance.GetComponentsInChildren(true)) - { - Object.Destroy(col); - } return true; } From 78010c8fb0faea17167dc6d2acead57a6664901f Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 7 Aug 2026 10:21:31 +0200 Subject: [PATCH 003/311] docs: add Skeleton head-flame fix to the v1.4.0 changelog --- README.md | 1 + 1 file changed, 1 insertion(+) diff --git a/README.md b/README.md index 67cc45a..95e1354 100644 --- a/README.md +++ b/README.md @@ -203,6 +203,7 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** - **Aswid**: Eyes glow an evil red, the way the compendium always described them. - **Skeleton**: Fixed a bug where a helmet or beard could stay visible even while the race's own head-hiding was active. - **Skeleton**: Your chosen race now shows correctly on the main-menu character preview. +- **Skeleton**: The burning skull (Moder tier+) no longer sheds a lit torch that falls to the ground - the flame's clone is stripped down to just the particles and light it actually needs. **v1.3.12** - **Skadi**: Dragon flight reworked. The stasis that holds a form level after you stop powering now lasts 5 seconds instead of 2. Hold Shift with W to spend 15 stamina a second on a burst of speed - the only part of flight that costs anything, since the drake arrives at The Elder long before you could pay just to stay airborne, and running dry drops you back to normal speed rather than out of the sky. S beats backwards along your aim, pitch included: look down and press it to rise away from whatever you are watching, without turning to face away from it. From 9287bd060d1a3e460ccbb5b5a86ea6b26a116270 Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 7 Aug 2026 11:32:13 +0200 Subject: [PATCH 004/311] fix(factions): use the real 'Goblin' prefab id, not the display name 'Fuling' FactionHostilityPatch's NeraForestaMobs set and FactionMerchantCatalog's Shops dictionary both keyed the base Goblin by its in-game display name, "Fuling", instead of its actual prefab id. Confirmed against the game's own asset paths (Assets/Characters/Goblin/, TrophyGoblin.prefab) rather than assumption - "Fuling" appears nowhere as a real prefab, only as flavor text (kept as-is on the shop's own DisplayName, which is just UI label text). Neither peace nor merchant status ever actually applied to a plain Goblin for any Black Forest race (Trenta, Trol, Furling) as a result - only the GoblinBrute/GoblinShaman entries, which already used their real ids, worked. Confirmed a related but separate bug while investigating, left alone per request: AswidRace.cs's mobToTrophyMap also keys off "Fuling" and feeds it into a live prefab lookup for food nutrition tuning - same wrong-id pattern, milder failure mode (falls back to generic values rather than breaking anything). Not fixed here. --- JotunnModStub/Factions/FactionHostilityPatch.cs | 2 +- JotunnModStub/Factions/FactionMerchantCatalog.cs | 6 +++--- JotunnModStub/Furling/FurlingPatches.cs | 4 ++-- README.md | 1 + 4 files changed, 7 insertions(+), 6 deletions(-) diff --git a/JotunnModStub/Factions/FactionHostilityPatch.cs b/JotunnModStub/Factions/FactionHostilityPatch.cs index 7a20956..b23b2ae 100644 --- a/JotunnModStub/Factions/FactionHostilityPatch.cs +++ b/JotunnModStub/Factions/FactionHostilityPatch.cs @@ -20,7 +20,7 @@ namespace RacesOfValheim private static readonly HashSet NeraForestaMobs = new HashSet { "Greydwarf", "Greydwarf_Elite", "Greydwarf_Shaman", - "Fuling", "GoblinBrute", "GoblinShaman", + "Goblin", "GoblinBrute", "GoblinShaman", // "Goblin" is the real prefab id - "Fuling" is only the in-game display name "Troll", }; diff --git a/JotunnModStub/Factions/FactionMerchantCatalog.cs b/JotunnModStub/Factions/FactionMerchantCatalog.cs index 126cee9..fbc4698 100644 --- a/JotunnModStub/Factions/FactionMerchantCatalog.cs +++ b/JotunnModStub/Factions/FactionMerchantCatalog.cs @@ -72,7 +72,7 @@ namespace RacesOfValheim new CatalogEntry("DeerHide", 2), new CatalogEntry("DeerMeat", 2), new CatalogEntry("LeatherScraps", 5), - new CatalogEntry("BoarMeat", 5), + new CatalogEntry("RawMeat", 5), // was "BoarMeat" - not a real prefab id, never appeared new CatalogEntry("NeckTail", 5), new CatalogEntry("TrophyNeck", 20), new CatalogEntry("TrophyDeer", 20), @@ -94,7 +94,7 @@ namespace RacesOfValheim new CatalogEntry("LoxPelt", 2), new CatalogEntry("Flax", 5), new CatalogEntry("Barley", 5), - new CatalogEntry("Cloudberries", 5), + new CatalogEntry("Cloudberry", 5), // was "Cloudberries" - not a real prefab id, never appeared new CatalogEntry("Tar", 5), // Growth, folded in here: Growth lives in Plains, same biome as Lox/Ocean new CatalogEntry("Tuna", 50), new CatalogEntry("CoralCod", 70), @@ -240,7 +240,7 @@ namespace RacesOfValheim { "Troll", TrollShop }, - { "Fuling", FulingShop }, + { "Goblin", FulingShop }, // "Goblin" is the real prefab id - "Fuling" is only the in-game display name { "GoblinBrute", FulingShop }, { "GoblinShaman", FulingShop }, diff --git a/JotunnModStub/Furling/FurlingPatches.cs b/JotunnModStub/Furling/FurlingPatches.cs index 8e0167c..9895050 100644 --- a/JotunnModStub/Furling/FurlingPatches.cs +++ b/JotunnModStub/Furling/FurlingPatches.cs @@ -62,8 +62,8 @@ namespace RacesOfValheim if (otherChar != null) { string name = otherChar.gameObject.name.Replace("(Clone)", "").ToLower(); - if (name == "goblin" || - name == "goblinbrute" || + if (name == "goblin" || + name == "goblinbrute" || name == "goblinshaman" || name == "lox" || name == "deathsquito" || diff --git a/README.md b/README.md index 95e1354..5f444b1 100644 --- a/README.md +++ b/README.md @@ -204,6 +204,7 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** - **Skeleton**: Fixed a bug where a helmet or beard could stay visible even while the race's own head-hiding was active. - **Skeleton**: Your chosen race now shows correctly on the main-menu character preview. - **Skeleton**: The burning skull (Moder tier+) no longer sheds a lit torch that falls to the ground - the flame's clone is stripped down to just the particles and light it actually needs. +- **Factions**: The base Goblin (in-game display name "Fuling") wasn't actually covered by Black Forest peace or trading for any race - the code used the display name "Fuling" instead of the real prefab id "Goblin". Trenta, Trol and Furling now get real peace with it, and it trades like every other Black Forest mob. **v1.3.12** - **Skadi**: Dragon flight reworked. The stasis that holds a form level after you stop powering now lasts 5 seconds instead of 2. Hold Shift with W to spend 15 stamina a second on a burst of speed - the only part of flight that costs anything, since the drake arrives at The Elder long before you could pay just to stay airborne, and running dry drops you back to normal speed rather than out of the sky. S beats backwards along your aim, pitch included: look down and press it to rise away from whatever you are watching, without turning to face away from it. From f4eaf9e53c1f20b69884a057e31dac742455ece5 Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 7 Aug 2026 11:48:31 +0200 Subject: [PATCH 005/311] fix(aswid): use the real Goblin prefab ids for Fuling-family food nutrition Same root cause as the Factions fix (9287bd0): mobToTrophyMap keyed the Goblin family by "Fuling"/"FulingShaman"/"FulingBerserker" - none of which are real prefab ids - instead of "Goblin"/"GoblinShaman"/"GoblinBrute". The trophy icon lookup was unaffected (it already used the correct TrophyGoblin/TrophyGoblinShaman/TrophyGoblinBrute ids on the dictionary's value side), but the food-tuning block gated on PrefabManager.Cache.GetPrefab(mobName) succeeding silently never ran for any of the three - so their food fell back to generic CookedMeat nutrition instead of a Goblin-scaled amount, and never got the 20-minute humanoid-prey burn time the "StartsWith Fuling" check was meant to grant them. Renamed the check to "StartsWith Goblin" to match. Verified in-game. --- JotunnModStub/Aswid/AswidRace.cs | 8 ++++---- README.md | 1 + 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index e3b1765..4424892 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -24,9 +24,9 @@ namespace RacesOfValheim { "Leech", "TrophyLeech" }, { "Hatchling", "TrophyHatchling" }, { "Lox", "TrophyLox" }, - { "Fuling", "TrophyGoblin" }, - { "FulingShaman", "TrophyGoblinShaman" }, - { "FulingBerserker", "TrophyGoblinBrute" }, + { "Goblin", "TrophyGoblin" }, // "Goblin" is the real prefab id - "Fuling" is only the in-game display name + { "GoblinShaman", "TrophyGoblinShaman" }, + { "GoblinBrute", "TrophyGoblinBrute" }, { "Deathsquito", "TrophyDeathsquito" }, { "Hare", "TrophyHare" }, { "Seeker", "TrophySeeker" }, @@ -137,7 +137,7 @@ namespace RacesOfValheim { float foodHp = Mathf.Min(c.m_health / 2f, 150f); float burnTime = c.m_health * 2f; - if (mobName == "Cultist" || mobName.StartsWith("Fenring") || mobName.StartsWith("Fuling")) + if (mobName == "Cultist" || mobName.StartsWith("Fenring") || mobName.StartsWith("Goblin")) { burnTime = 1200f; // 20 minutes } diff --git a/README.md b/README.md index 5f444b1..98cd072 100644 --- a/README.md +++ b/README.md @@ -205,6 +205,7 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** - **Skeleton**: Your chosen race now shows correctly on the main-menu character preview. - **Skeleton**: The burning skull (Moder tier+) no longer sheds a lit torch that falls to the ground - the flame's clone is stripped down to just the particles and light it actually needs. - **Factions**: The base Goblin (in-game display name "Fuling") wasn't actually covered by Black Forest peace or trading for any race - the code used the display name "Fuling" instead of the real prefab id "Goblin". Trenta, Trol and Furling now get real peace with it, and it trades like every other Black Forest mob. +- **Aswid**: The same "Fuling" mix-up meant the Goblin family's food never got its intended values - it silently fell back to generic nutrition instead of a Goblin-scaled amount and the promised 20-minute humanoid-prey burn time. Fixed for the Goblin, the Goblin Shaman and the Goblin Brute alike. **v1.3.12** - **Skadi**: Dragon flight reworked. The stasis that holds a form level after you stop powering now lasts 5 seconds instead of 2. Hold Shift with W to spend 15 stamina a second on a burst of speed - the only part of flight that costs anything, since the drake arrives at The Elder long before you could pay just to stay airborne, and running dry drops you back to normal speed rather than out of the sky. S beats backwards along your aim, pitch included: look down and press it to rise away from whatever you are watching, without turning to face away from it. From b1f5da2249065e16af2884ed8c197a18d05b8413 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 7 Aug 2026 17:02:34 +0200 Subject: [PATCH 006/311] feat: shared foundations for stations and servants RaisedThrall is the common servant base (leash, wither timer, follow command, anchor), used by Draugh, Skeleton and Trol. ModelBorrow lends a vanilla prefab's look without its behaviour. PieceDensityLimit caps how many of a piece fit in an area. Co-Authored-By: Claude Opus 5 --- JotunnModStub/ModelBorrow.cs | 189 +++++++++++ JotunnModStub/PieceDensityLimit.cs | 147 +++++++++ JotunnModStub/RaisedThrall.cs | 491 +++++++++++++++++++++++++++++ 3 files changed, 827 insertions(+) create mode 100644 JotunnModStub/ModelBorrow.cs create mode 100644 JotunnModStub/PieceDensityLimit.cs create mode 100644 JotunnModStub/RaisedThrall.cs diff --git a/JotunnModStub/ModelBorrow.cs b/JotunnModStub/ModelBorrow.cs new file mode 100644 index 0000000..097f44d --- /dev/null +++ b/JotunnModStub/ModelBorrow.cs @@ -0,0 +1,189 @@ +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Borrowing a vanilla prefab's LOOK without borrowing anything it does. + /// + /// This exists because of a bug that shipped: the Trol's war totem mounted trophy models by calling + /// Instantiate and then stripping the components off the copy. Instantiate runs Awake FIRST, so for + /// one frame the copy was a real, live object - and a trophy is an ItemDrop, which means a giant + /// Yagluth head fell out of the sky every time the totem's ghost was drawn. + /// + /// For a world prop (the Trenta grove borrows a Yggdrasil shoot this way) the stray frame does + /// nothing visible, which is why the technique looked fine the first two times it was used. For + /// anything carrying ItemDrop, ZNetView or a Rigidbody it is a live object with physics. + /// + /// The fix is one line and it is the reason this is a shared helper rather than a third copy of the + /// same loop: instantiate into a holder that is ALREADY INACTIVE. Unity does not run Awake on a + /// component that comes up disabled, so the strip happens before anything can wake. + /// + /// SECOND ROUND: the borrowed model is now sized in METRES instead of by a multiplier, because a + /// multiplier against an unknown mesh is a guess and guesses shipped a Yagluth head three times + /// taller than the post it stood on. The mesh is measured and scaled to fit, and it is grounded so + /// the holder's origin is the model's BOTTOM CENTRE rather than whatever the item's author happened + /// to use as a pivot - which is what makes "put the head on top of the totem" a subtraction instead + /// of another guess. This is rule 3.2 of the house guide applied to geometry: a number that was + /// measured is already balanced. + /// + public static class ModelBorrow + { + /// + /// Hangs the renderers of a vanilla prefab under and returns the holder, + /// which the caller can switch on and off. Null-safe: a missing source logs and returns an empty + /// holder rather than throwing, so a wrong name costs a warning and not a startup. + /// + /// is where the model's BOTTOM CENTRE goes. + /// is how big its largest dimension should end up, in metres, + /// measured AFTER has been applied. + /// + public static GameObject Attach(Transform parent, string holderName, string sourcePrefab, + Vector3 localPosition, Quaternion localRotation, float targetSize, + string label) + { + GameObject holder = new GameObject(holderName); + holder.transform.SetParent(parent, false); + holder.transform.localPosition = localPosition; + + // BEFORE the Instantiate below. This single line is the whole point of the class. + holder.SetActive(false); + + GameObject source = Jotunn.Managers.PrefabManager.Cache.GetPrefab(sourcePrefab); + if (source == null) + { + Jotunn.Logger.LogWarning($"[{label}] No '{sourcePrefab}' to borrow a model from; nothing was attached."); + holder.SetActive(true); + return holder; + } + + GameObject copy = Object.Instantiate(source, holder.transform); + copy.name = "model"; + copy.transform.localPosition = Vector3.zero; + copy.transform.localRotation = localRotation; + copy.transform.localScale = Vector3.one; + + // Everything that is not a Renderer or a Transform. Order matters for the same reason it did + // on the Aswid's lights: behaviours first, then the things they hold references to. + 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); + } + + FitAndGround(copy.transform, holder.transform, targetSize, sourcePrefab, label); + + holder.SetActive(true); + return holder; + } + + /// + /// How tall the borrowed model actually turned out, in the holder's parent's space. Used to stack + /// one borrowed model on top of another without a magic offset. + /// + public static float HeightOf(GameObject holder) + { + if (holder == null) return 0f; + return TryMeasure(holder.transform, holder.transform, out Bounds bounds) ? bounds.size.y : 0f; + } + + // ---------------------------------------------------------------- measuring + + /// + /// Scales the copy so its largest dimension is metres, then slides it + /// so its bottom centre sits on the holder's origin. + /// + private static void FitAndGround(Transform copy, Transform holder, float targetSize, + string sourcePrefab, string label) + { + if (!TryMeasure(copy, holder, out Bounds raw)) + { + Jotunn.Logger.LogWarning($"[{label}] '{sourcePrefab}' has no readable mesh, so it could not be " + + "sized or grounded; it is attached at scale 1 and may sit wrong."); + return; + } + + float biggest = Mathf.Max(raw.size.x, Mathf.Max(raw.size.y, raw.size.z)); + if (biggest <= 0.0001f) + { + Jotunn.Logger.LogWarning($"[{label}] '{sourcePrefab}' measured as a point ({raw.size}); " + + "left at scale 1."); + return; + } + + float scale = targetSize / biggest; + copy.localScale = Vector3.one * scale; + + if (TryMeasure(copy, holder, out Bounds fitted)) + { + copy.localPosition = new Vector3(-fitted.center.x, -fitted.min.y, -fitted.center.z); + } + + Jotunn.Logger.LogInfo($"[{label}] Borrowed '{sourcePrefab}': measured {raw.size}, " + + $"scaled by {scale:0.###} to fit {targetSize} m, grounded on its own base."); + } + + /// + /// Bounds of every mesh under , expressed in 's local + /// coordinates. Read from sharedMesh rather than Renderer.bounds on purpose: the holder is INACTIVE + /// while this runs (that is the whole point of the class) and a renderer that has never been enabled + /// has no world bounds yet, so Renderer.bounds would quietly return zero. + /// + private static bool TryMeasure(Transform root, Transform space, out Bounds bounds) + { + bounds = new Bounds(); + bool any = false; + + Matrix4x4 toSpace = space.worldToLocalMatrix; + + foreach (Renderer renderer in root.GetComponentsInChildren(true)) + { + if (renderer == null) continue; + + Mesh mesh; + if (renderer is SkinnedMeshRenderer skinned) + { + mesh = skinned.sharedMesh; + } + else + { + MeshFilter filter = renderer.GetComponent(); + mesh = filter != null ? filter.sharedMesh : null; + } + if (mesh == null) continue; + + Encapsulate(ref bounds, ref any, toSpace * renderer.transform.localToWorldMatrix, mesh.bounds); + } + + return any; + } + + /// All eight corners, because a rotated box's bounds are not its centre plus its extents. + private static void Encapsulate(ref Bounds bounds, ref bool any, Matrix4x4 matrix, Bounds local) + { + Vector3 centre = local.center; + Vector3 extents = local.extents; + + for (int corner = 0; corner < 8; corner++) + { + Vector3 point = matrix.MultiplyPoint3x4(centre + new Vector3( + (corner & 1) == 0 ? -extents.x : extents.x, + (corner & 2) == 0 ? -extents.y : extents.y, + (corner & 4) == 0 ? -extents.z : extents.z)); + + if (!any) { bounds = new Bounds(point, Vector3.zero); any = true; } + else bounds.Encapsulate(point); + } + } + } +} diff --git a/JotunnModStub/PieceDensityLimit.cs b/JotunnModStub/PieceDensityLimit.cs new file mode 100644 index 0000000..024014f --- /dev/null +++ b/JotunnModStub/PieceDensityLimit.cs @@ -0,0 +1,147 @@ +using System.Collections.Generic; +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// "How many of these may stand in one region." One place, one patch, one line per station. + /// + /// Every station in the per-race item-progression system that produces something continuously has + /// to be capped, or five copies are five times the effect - a field of groves is a carpet of bees, + /// five body piles are fifty draugr. Each chain used to be expected to write its own placement + /// check; this exists so the five races still to come add a limit with one call instead of + /// re-deriving ZDO counting, and so there is exactly one Player.PlacePiece prefix rather than one + /// per race. + /// + /// Counting is done over ZDOs and not over loaded GameObjects, and that distinction is the whole + /// point: Valheim keeps only a handful of zones alive around the player, a few hundred metres at + /// most, so counting objects would let anyone dodge the cap by walking away and building again. + /// + /// HONEST LIMIT: a client only holds the ZDOs the server has sent it. In singleplayer and on the + /// host the count is exact; on a remote client it can undercount, so a cap can be exceeded by + /// someone building far from every other copy. It still closes the case that matters - fifty of + /// them around one base - and no client-side hook can do better without a server-authoritative + /// check. + /// + public static class PieceDensityLimit + { + private class Limit + { + public float Radius; + public int Max; + public string Message; + } + + private static readonly Dictionary Limits = new Dictionary(); + + /// + /// The radius of a circle with the given area, so a limit can be written the way it is + /// actually discussed - "five per 1.6 square kilometres" - instead of as a magic distance. + /// + public static float RadiusForArea(float squareKilometres) + { + return Mathf.Sqrt(squareKilometres * 1000000f / Mathf.PI); + } + + /// + /// 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. + /// + public static void Register(string piecePrefabName, float radius, int max, string refusalMessage) + { + if (string.IsNullOrEmpty(piecePrefabName) || max < 1 || radius <= 0f) + { + Jotunn.Logger.LogWarning($"[Density] Refusing a nonsense limit for '{piecePrefabName}' " + + $"(radius {radius}, max {max}); it will not be capped."); + return; + } + + Limits[piecePrefabName] = new Limit { Radius = radius, Max = max, Message = refusalMessage }; + Jotunn.Logger.LogInfo($"[Density] {piecePrefabName}: at most {max} within {radius:0} m."); + } + + /// + /// How many of that piece already stand within the radius of a point, or -1 if the world + /// cannot be asked right now - in which case callers must let the placement through rather + /// than refuse on no information. + /// + public static int Count(string piecePrefabName, Vector3 position, float radius) + { + if (ZDOMan.instance == null) return -1; + + List zdos = new List(); + int index = 0; + // The iterative sweep hands back a chunk per call and reports true when it is done. The + // guard is so a pathological world cannot spin here forever. + for (int guard = 0; guard < 1000; guard++) + { + if (ZDOMan.instance.GetAllZDOsWithPrefabIterative(piecePrefabName, zdos, ref index)) break; + } + + float rangeSq = radius * radius; + int count = 0; + foreach (ZDO zdo in zdos) + { + if (zdo == null) continue; + if (Vector3.SqrMagnitude(zdo.GetPosition() - position) <= rangeSq) count++; + } + + return count; + } + + /// + /// True if one more may be placed there. Unknown pieces are always allowed - a station with no + /// registered limit is not this class's business. + /// + public static bool Allow(Player player, string piecePrefabName, Vector3 position) + { + if (!Limits.TryGetValue(piecePrefabName, out Limit limit)) return true; + + int nearby = Count(piecePrefabName, position, limit.Radius); + if (nearby < 0 || nearby < limit.Max) return true; + + if (player != null) + { + player.Message(MessageHud.MessageType.Center, string.Format(limit.Message, nearby, limit.Max)); + } + return false; + } + } + + /// + /// The single enforcement point, at the moment of building - which is the only moment a refusal is + /// both cheap and understandable. Refusing later, or building and then quietly deleting what it + /// produced, would spend the player's gate item before telling them no. + /// + /// + /// The single enforcement point. + /// + /// The signature is spelled out because it is NOT the one every Valheim modding example uses. The + /// familiar `bool PlacePiece(Piece)` does not exist in this build; the real one is + /// + /// void PlacePiece(Piece piece, Vector3 pos, Quaternion rot, bool doAttack) + /// + /// read off the HarmonyX error this patch produced on the first launch. Two things follow, and the + /// first one cost a whole startup: + /// - it returns VOID, so there is no __result to write. Asking for one throws "Cannot get result + /// from void method" at patch time, and that exception propagates out of Harmony.PatchAll() - + /// which means one bad signature here stops the rest of the mod's patches from being applied + /// at all. A prefix returning false is the whole mechanism: the original simply does not run, + /// nothing is placed, and no resources are spent. + /// - the placement position is an ARGUMENT, not the piece's transform. At prefix time the Piece + /// 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. + /// + [HarmonyPatch(typeof(Player), "PlacePiece", + new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })] + public static class PieceDensityLimitPatch + { + public static bool Prefix(Player __instance, Piece __0, Vector3 __1) + { + if (__instance != Player.m_localPlayer || __0 == null) return true; + + return PieceDensityLimit.Allow(__instance, Utils.GetPrefabName(__0.gameObject), __1); + } + } +} diff --git a/JotunnModStub/RaisedThrall.cs b/JotunnModStub/RaisedThrall.cs new file mode 100644 index 0000000..c838ec8 --- /dev/null +++ b/JotunnModStub/RaisedThrall.cs @@ -0,0 +1,491 @@ +using System; +using System.Collections.Generic; +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// One conjured servant, of any race. Keeps itself within its leash of the station that made it, + /// unless the right kind of player has told it to follow. + /// + /// This started life as DraughThrall and was generalised the moment the Skeleton needed the same + /// thing - which is the call ItemProgression_Guida.txt 8.3 says to make BEFORE writing the second + /// copy rather than after. Nothing in here is draugr-specific: a leash, a wither timer, a follow + /// command and an anchor are the same problem whoever raised the body. + /// + /// The leash is not custom pathing - it is vanilla's own patrol behaviour, pointed at the station. + /// BaseAI already has m_patrol and m_patrolPoint and already wanders around that point inside + /// m_randomMoveRange, which each prefab sets to its own leash. All this component does is keep the + /// point pinned, which is also what makes "stay" send one home rather than root it wherever it + /// happened to be standing. + /// + /// The anchor lives in the creature's own ZDO as a Vector3 and doubles as the mark of which + /// station owns it - so a station can count its own even when one is three biomes away following + /// its master. + /// + public class RaisedThrall : MonoBehaviour + { + // Deliberately still spelled "draugh". These keys are in players' save files already, on + // thralls raised before this class was generalised; renaming them would leave every existing + // thrall anchorless - no leash, no wither, no orders - for the sake of a tidier string. + public const string KeyAnchor = "RoV_draughAnchor"; + public const string KeyOrphanAt = "RoV_draughOrphanAt"; + + // ─── Set on the prefab at registration ─────────────────────────────── + + /// Groups thralls for follower caps and for a station's per-kind roster. + public string m_kind = ""; + + /// Only a player of this race may give orders. Empty means anyone may. + public string m_commandingRace = ""; + + /// How many of this KIND may follow one player at once. -1 for no limit. + public int m_maxFollowers = -1; + + public float m_witherSeconds = 60f; + 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."; + + /// + /// How many thralls of OTHER kinds, from the same station, come along when this one is + /// commanded directly. 0 for a thrall that only speaks for itself. + /// + /// This is what makes a Rancid Remains a squad leader: clicking it takes it and five of the + /// rank and file, rather than the whole garrison the pile would send. Only applies to a direct + /// click - a station moving its whole line calls SetFollowing itself, so the two cannot nest. + /// + public int m_escortCount = 0; + + // SetPatrolPoint(Vector3) is private - only the parameterless overload, which uses the + // creature's current position, is public. Resolved once here rather than per call. + private static readonly System.Reflection.MethodInfo SetPatrolPointMethod = + AccessTools.Method(typeof(BaseAI), "SetPatrolPoint", new[] { typeof(Vector3) }); + + /// + /// Every station currently loaded that owns thralls. Registered by the station's own behaviour + /// so a thrall can ask "is my station still standing?" without sweeping ZDOs or raycasting on a + /// two-second timer, ten thralls at a time. + /// + /// TRANSFORMS, not positions, and that is the whole bug this once had: the first version cached + /// transform.position at Awake, which is not yet the object's final placement. Every lookup then + /// missed, every thrall decided it was an orphan, and with the Skeleton's zero-second wither the + /// whole garrison died about four seconds after it rose. Reading .position at query time is what + /// the Draugh's own list did before it was generalised, and why that one worked. + /// + private static readonly List LiveStations = new List(); + + public static void RegisterStation(Transform station) + { + if (station != null && !LiveStations.Contains(station)) LiveStations.Add(station); + } + + public static void UnregisterStation(Transform station) => LiveStations.Remove(station); + + /// True if a loaded station stands at that point. Only meaningful when the asker is + /// close enough that the station would be loaded if it existed - see m_homeCheckRange. + public static bool StationStandsAt(Vector3 position) + { + for (int i = LiveStations.Count - 1; i >= 0; i--) + { + Transform station = LiveStations[i]; + if (station == null) { LiveStations.RemoveAt(i); continue; } // destroyed without notice + + if (Vector3.SqrMagnitude(station.position - position) < 0.25f) return true; + } + return false; + } + + private Character m_character; + private BaseAI m_ai; + private MonsterAI m_monsterAI; + private ZNetView m_nview; + + private void Awake() + { + m_character = GetComponent(); + m_ai = GetComponent(); + m_monsterAI = GetComponent(); + m_nview = GetComponent(); + + InvokeRepeating("TickLeash", 2f, 2f); + } + + /// Where the station that made this one stands, or null if it was not made by one. + 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 string Kind => m_kind; + + public bool IsFollowing(Player player) + { + return m_monsterAI != null && player != null && m_monsterAI.GetFollowTarget() == player.gameObject; + } + + /// Called at spawn by the station. Tames it, marks it, and sends it home. + public void Bind(Vector3 anchor) + { + if (m_nview == null || !m_nview.IsValid()) return; + + m_nview.GetZDO().Set(KeyAnchor, anchor); + if (m_monsterAI != null) m_monsterAI.MakeTame(); + if (m_character != null) m_character.SetTamed(true); + + GoHome(); + } + + // ---------------------------------------------------------------- the leash + + private void TickLeash() + { + if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return; + if (m_character == null || m_character.IsDead()) 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; + + // Following overrides the leash entirely; that is the whole point of the command. + if (m_monsterAI != null && m_monsterAI.GetFollowTarget() != null) return; + + GoHome(); + } + + /// 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() + { + Vector3? anchor = Anchor; + if (anchor == null || ZNet.instance == null) return false; + + long stamp = m_nview.GetZDO().GetLong(KeyOrphanAt, 0L); + + if (stamp == 0L) + { + // The station marks its own thralls when it falls, but it can only mark the ones that + // are loaded at that moment. This is the other half: a thrall that was away comes + // home, finds nothing there, and marks itself. + // + // Deliberately only asked near home. Further out the station's zone is almost + // certainly unloaded, so "nothing here" would be a lie - and acting on it would kill + // the escort of anyone who walked away from their base. + if (Vector3.SqrMagnitude(transform.position - anchor.Value) > + m_homeCheckRange * m_homeCheckRange) return false; + + if (StationStandsAt(anchor.Value)) return false; + + MarkOrphaned(); + return false; + } + + // Rebuilt in time, on the same spot: the clock is cleared and the thrall lives. Safe to + // ask unconditionally - StationStandsAt can only answer true where one is actually + // loaded, so being far from home simply never rescues anything. And it opens no exploit: + // a station on the same spot adopts these thralls by anchor anyway. + if (StationStandsAt(anchor.Value)) + { + m_nview.GetZDO().Set(KeyOrphanAt, 0L); + return false; + } + + double elapsed = (ZNet.instance.GetTime() - new DateTime(stamp)).TotalSeconds; + if (elapsed < m_witherSeconds) return false; + + Kill(); + return true; + } + + /// + /// Starts the wither clock, once. Called by the station as it is destroyed, and by the thrall + /// itself if it comes home to nothing. Idempotent so the two cannot restart each other's clock + /// and keep an orphan alive forever. + /// + public void MarkOrphaned() + { + if (m_nview == null || !m_nview.IsValid() || ZNet.instance == null) return; + if (m_nview.GetZDO().GetLong(KeyOrphanAt, 0L) != 0L) return; + + m_nview.ClaimOwnership(); + m_nview.GetZDO().Set(KeyOrphanAt, ZNet.instance.GetTime().Ticks); + } + + /// + /// Pins the patrol point back onto the station. Cheap enough to call on a timer, and calling it + /// repeatedly is what stops a thrall drifting after it has been pushed, knocked back or told to + /// stay somewhere far from home. + /// + private void GoHome() + { + Vector3? anchor = Anchor; + if (anchor == null || m_ai == null) return; + + if (SetPatrolPointMethod != null) + { + SetPatrolPointMethod.Invoke(m_ai, new object[] { anchor.Value }); + } + else + { + // Fall back to writing the two fields the private method writes. + Traverse traverse = Traverse.Create(m_ai); + traverse.Field("m_patrolPoint").SetValue(anchor.Value); + traverse.Field("m_patrol").SetValue(true); + } + } + + // ---------------------------------------------------------------- commands + + public bool MayBeCommandedBy(Player player) + { + if (player == null) return false; + if (string.IsNullOrEmpty(m_commandingRace)) return true; + + return player.m_customData != null && + player.m_customData.TryGetValue("Race", out string race) && + race == m_commandingRace; + } + + /// Sends it after the player, or home. Returns false if it refused. + public bool SetFollowing(Player player, bool follow, bool announce) + { + if (player == null || m_monsterAI == null || m_character == null) return false; + + if (!MayBeCommandedBy(player)) + { + if (announce) player.Message(MessageHud.MessageType.Center, m_refusalMessage); + return false; + } + + if (!follow) + { + m_monsterAI.SetFollowTarget(null); + GoHome(); + if (announce) player.Message(MessageHud.MessageType.Center, $"{m_character.m_name} returns."); + return true; + } + + // Counted fresh on every command so deaths and dismissals free slots up on their own, + // with no tally to drift out of step. + if (m_maxFollowers >= 0 && CountFollowers(player, m_kind) >= m_maxFollowers) + { + if (announce) + { + player.Message(MessageHud.MessageType.Center, $"Only {m_maxFollowers} may walk with you."); + } + return false; + } + + m_monsterAI.SetFollowTarget(player.gameObject); + if (announce) player.Message(MessageHud.MessageType.Center, $"{m_character.m_name} follows."); + return true; + } + + /// + /// Follow if it is not, come home if it is - the wolf's own single-key behaviour, plus an escort + /// if this thrall leads one. + /// + public void ToggleCommand(Player player) + { + bool follow = !IsFollowing(player); + if (!SetFollowing(player, follow, announce: m_escortCount <= 0)) return; + if (m_escortCount <= 0) return; + + // A squad, not the whole line. Anchor-bound, other kinds only - the rank and file, never + // another leader - and capped at m_escortCount. + Vector3? anchor = Anchor; + if (anchor == null) return; + + int taken = 0; + foreach (RaisedThrall other in BoundTo(anchor.Value)) + { + if (other == this || other.m_kind == m_kind) continue; + + // Going out: only pick up ones that are not already out. Coming home: only send back + // the ones that are actually with this player, so another squad is left alone. + if (follow ? other.IsFollowing(player) : !other.IsFollowing(player)) continue; + if (taken >= m_escortCount) break; + + 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}."); + } + + private static int CountFollowers(Player player, string kind) + { + int count = 0; + foreach (Character character in Character.GetAllCharacters()) + { + if (character == null || character.IsDead()) continue; + + RaisedThrall thrall = character.GetComponent(); + if (thrall == null || thrall.m_kind != kind) continue; + if (thrall.IsFollowing(player)) count++; + } + return count; + } + + /// Every living thrall bound to the station at this position. + public static List BoundTo(Vector3 anchor) + { + List bound = new List(); + + foreach (Character character in Character.GetAllCharacters()) + { + if (character == null || character.IsDead()) continue; + + RaisedThrall thrall = character.GetComponent(); + if (thrall == null) continue; + + Vector3? own = thrall.Anchor; + // A generous epsilon: a station never moves, so this only has to survive float + // round-tripping through the ZDO. + if (own != null && Vector3.SqrMagnitude(own.Value - anchor) < 0.25f) bound.Add(thrall); + } + + return bound; + } + + // ---------------------------------------------------------------- the call + + /// Earshot. A shouted gesture reaches what is nearby, not the whole world. + public const float TauntRange = 30f; + + /// + /// The emote that calls thralls to their master. A SET rather than one string because the emote + /// names are not in the assembly at all - Valheim builds them from what the player types in + /// chat, so unlike every other name in this project this one could not be read off the game and + /// verified. The patch below logs whatever it actually receives, so a wrong guess here is one + /// line away from being right instead of a mystery. + /// + private static readonly HashSet TauntEmotes = new HashSet + { + "comehere", "come_here", "followme", + }; + + /// + /// Everything within earshot that answers to this player falls in behind them. + /// + /// Only ever a call, never a dismissal: "come here" means come here. Sending them home stays + /// with the station and with a click on the thrall itself. + /// + /// The per-race follower cap needs no special handling - SetFollowing enforces m_maxFollowers + /// itself, so the Skeleton's whole garrison answers (-1, no limit) and the Draugh's gets three + /// draugr and one officer, from exactly the same call. + /// + public static void CallToArms(Player player) + { + if (player == null) return; + + int came = 0; + int refused = 0; + + foreach (Character character in Character.GetAllCharacters()) + { + if (character == null || character.IsDead()) continue; + + RaisedThrall thrall = character.GetComponent(); + if (thrall == null || thrall.IsFollowing(player)) continue; + if (!thrall.MayBeCommandedBy(player)) continue; + if (Vector3.SqrMagnitude(character.transform.position - player.transform.position) > + TauntRange * TauntRange) continue; + + if (thrall.SetFollowing(player, true, announce: false)) came++; + else refused++; + } + + if (came > 0) + { + player.Message(MessageHud.MessageType.Center, $"{came} answer the call."); + } + 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."); + } + } + + public static bool IsTauntEmote(string emote) + { + return emote != null && TauntEmotes.Contains(emote.ToLowerInvariant()); + } + + public void Kill() + { + if (m_character == null || m_character.IsDead()) return; + + HitData hit = new HitData(); + hit.m_damage.m_damage = 1E+10f; + hit.m_hitType = HitData.HitType.Undefined; + m_character.ApplyDamage(hit, true, false); + } + } + + /// + /// Routes E on a thrall to , before vanilla resolves the + /// target itself. + /// + /// This is a prefix on Player.Interact rather than an Interactable on the thrall, and that is not + /// a style choice. AswidPatches' own Character.Awake postfix adds AswidThrall - also Interactable + /// - to essentially every mob carrying a MonsterAI, and it wins vanilla's + /// GetComponentInParent<Interactable>() race on whatever it touches. That is the exact bug + /// FactionMerchantInteractPatch exists to work around, where pressing E called AswidThrall.Interact + /// instead of Trader.Interact, silently and with no error. Handling our own thralls here sidesteps + /// component order entirely instead of depending on it. + /// + /// The feedback is a centre-screen message and not hover text for the same reason: Character is + /// itself Hoverable and sits ahead of everything added later, so hover is a race this cannot win + /// cleanly. The station's own hover text carries the roster and the rules. + /// + /// + /// The "come here" gesture calls every thrall in earshot to its master. + /// + /// A POSTFIX with positional binding and no __result, which is the safest shape available: postfixes + /// need no return value, so this cannot repeat the PlacePiece failure where asking for a __result on + /// a void method threw at patch time and stopped the rest of the mod being patched. + /// + /// The emote name is logged on every emote the local player performs, because the names are the one + /// class of string in this project that could not be verified against the game - they are built from + /// the player's own chat input, not stored in the assembly. Do the gesture once and the log names it. + /// + [HarmonyPatch(typeof(Player), "StartEmote")] + public static class RaisedThrallTauntPatch + { + public static void Postfix(Player __instance, string __0) + { + if (__instance != Player.m_localPlayer) return; + + Jotunn.Logger.LogInfo($"[Thrall] emote '{__0}'" + + (RaisedThrall.IsTauntEmote(__0) ? " - calling thralls." : ".")); + + if (RaisedThrall.IsTauntEmote(__0)) RaisedThrall.CallToArms(__instance); + } + } + + [HarmonyPatch(typeof(Player), "Interact")] + public static class RaisedThrallInteractPatch + { + public static bool Prefix(Player __instance, GameObject go, bool hold, bool alt) + { + if (go == null || hold) return true; + if (__instance != Player.m_localPlayer) return true; + + RaisedThrall thrall = go.GetComponentInParent(); + if (thrall == null) return true; // not ours - let vanilla's own resolution run + + thrall.ToggleCommand(__instance); + return false; + } + } +} From fae82162beed7cd81e0a126729c4f17f156f42ab Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 7 Aug 2026 17:02:34 +0200 Subject: [PATCH 007/311] feat(aswid): blood refinery and blood potions Co-Authored-By: Claude Opus 5 --- JotunnModStub/Aswid/AswidBloodPotions.cs | 298 +++++++++ JotunnModStub/Aswid/AswidBloodRefinery.cs | 573 ++++++++++++++++++ JotunnModStub/Aswid/AswidPatches.cs | 4 +- JotunnModStub/Aswid/AswidRace.cs | 18 +- JotunnModStub/Aswid/BloodRefineryBehaviour.cs | 299 +++++++++ 5 files changed, 1185 insertions(+), 7 deletions(-) create mode 100644 JotunnModStub/Aswid/AswidBloodPotions.cs create mode 100644 JotunnModStub/Aswid/AswidBloodRefinery.cs create mode 100644 JotunnModStub/Aswid/BloodRefineryBehaviour.cs diff --git a/JotunnModStub/Aswid/AswidBloodPotions.cs b/JotunnModStub/Aswid/AswidBloodPotions.cs new file mode 100644 index 0000000..5e7e10f --- /dev/null +++ b/JotunnModStub/Aswid/AswidBloodPotions.cs @@ -0,0 +1,298 @@ +using System.Collections; +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The second step of the refinement chain, brewed at the Mead Ketill: + /// + /// 5 Blood Essence -> 1 Superior Blood Essence + /// 3 Blood Essence + 5 Blueberries + /// + 5 Yellow Mushrooms -> Blood Potion mead base + /// 3 Superior Blood Essence + 5 Sap + /// + 5 Cloudberry -> Superior Blood Potion mead base + /// + /// Either base then goes into a Fermenter and comes out as five bottles. Drinking one force + /// feeds every food slot with the matching essence - full stomachs and all - and heals a + /// percentage of maximum health over eight seconds. + /// + public static class AswidBloodPotions + { + public const string BaseName = "MeadBaseBloodPotion"; + public const string PotionName = "MeadBloodPotion"; + 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 float HealDuration = 8f; + private const float HealFraction = 0.05f; + private const float SuperiorHealFraction = 0.10f; + + // Five bottles per barrel, as designed. + private const int BottlesPerBrew = 5; + + /// + /// Blood brews are done in a quarter of the normal time. The fermenter keeps a single + /// duration for every recipe, so instead of shortening it - which would speed up every + /// vanilla mead in the barrel - the elapsed time is multiplied while our base is inside. + /// + public const double FermentSpeedMultiplier = 4.0; + + private static readonly System.Reflection.MethodInfo GetContentMethod = + AccessTools.Method(typeof(Fermenter), "GetContent"); + + public static void Register() + { + SE_BloodPotion drink = CreateEffect("SE_BloodPotion", PotionDisplayName, HealFraction, + AswidBloodRefinery.EssenceName, "GemstoneRed"); + 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 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."); + GameObject superiorPotion = CloneItem(SuperiorPotionName, "MeadHealthMedium", SuperiorPotionDisplayName, + "The same mercy, twice as deep."); + + AttachEffect(potion, drink); + AttachEffect(superiorPotion, superiorDrink); + + AddRecipe(AswidBloodRefinery.SuperiorEssenceName, new[] + { + new RequirementConfig(AswidBloodRefinery.EssenceName, 5), + }); + + AddRecipe(BaseName, new[] + { + new RequirementConfig(AswidBloodRefinery.EssenceName, 3), + new RequirementConfig("Blueberries", 5), + // "Funghi luminosi": the Yellow Mushroom, the one that glows in the burial + // chambers. Same tier as the blueberries, unlike the Mistlands blue one. + new RequirementConfig("MushroomYellow", 5), + }); + + AddRecipe(SuperiorBaseName, new[] + { + new RequirementConfig(AswidBloodRefinery.SuperiorEssenceName, 3), + new RequirementConfig("Sap", 5), + new RequirementConfig("Cloudberry", 5), + }); + + AddFermenterConversion(meadBase, potion); + AddFermenterConversion(superiorBase, superiorPotion); + } + + // ---------------------------------------------------------------- items + + private static GameObject CloneItem(string prefabName, string source, string displayName, string description) + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(prefabName, source); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Aswid] Could not clone '{source}'; {displayName} not registered."); + return null; + } + + ItemDrop drop = prefab.GetComponent(); + if (drop == null) return null; + + ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; + shared.m_name = displayName; + shared.m_description = description; + // The clone arrives carrying the vanilla health mead's own effect; ours is attached + // afterwards, and the mead bases must carry none at all. + shared.m_consumeStatusEffect = null; + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + return prefab; + } + + private static void AttachEffect(GameObject potion, SE_BloodPotion effect) + { + ItemDrop drop = potion != null ? potion.GetComponent() : null; + if (drop == null || effect == null) return; + drop.m_itemData.m_shared.m_consumeStatusEffect = effect; + } + + private static void AddRecipe(string item, RequirementConfig[] requirements) + { + ItemManager.Instance.AddRecipe(new CustomRecipe(new RecipeConfig + { + Item = item, + Amount = 1, + CraftingStation = CraftingStations.MeadKetill, + Requirements = requirements, + })); + } + + /// + /// Teaches the vanilla fermenter one more brew. The vanilla prefab's conversion list is + /// appended to rather than replaced, so every stock mead still works. + /// + private static void AddFermenterConversion(GameObject from, GameObject to) + { + if (from == null || to == null) return; + + GameObject barrel = PrefabManager.Cache.GetPrefab("fermenter"); + Fermenter fermenter = barrel != null ? barrel.GetComponent() : null; + if (fermenter == null) + { + Jotunn.Logger.LogWarning("[Aswid] No fermenter prefab; blood potions cannot be brewed."); + return; + } + + ItemDrop fromDrop = from.GetComponent(); + ItemDrop toDrop = to.GetComponent(); + if (fromDrop == null || toDrop == null) return; + + foreach (Fermenter.ItemConversion existing in fermenter.m_conversion) + { + if (existing != null && existing.m_from == fromDrop) return; // already taught + } + + fermenter.m_conversion.Add(new Fermenter.ItemConversion + { + m_from = fromDrop, + m_to = toDrop, + m_producedItems = BottlesPerBrew, + }); + } + + // ---------------------------------------------------------------- status effect + + private static SE_BloodPotion CreateEffect(string name, string displayName, float fraction, + string essencePrefab, string iconSource) + { + 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_ttl = HealDuration; + effect.m_healFraction = fraction; + effect.m_essencePrefab = essencePrefab; + + // A flat m_healthOverTime cannot express "5% of maximum health", so the real number is + // computed per drinker in SE_BloodPotion.Setup. One tick a second over the eight. + effect.m_healthOverTimeDuration = HealDuration; + effect.m_healthOverTimeInterval = 1f; + + ItemDrop source = PrefabManager.Cache.GetPrefab(iconSource); + Sprite[] icons = source != null && source.m_itemData != null && source.m_itemData.m_shared != null + ? source.m_itemData.m_shared.m_icons + : null; + if (icons != null && icons.Length > 0) effect.m_icon = icons[0]; + + ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(effect, fixReference: false)); + return effect; + } + + /// + /// Force feeds every food slot with the given essence, ignoring whether the stomachs are + /// full - that refusal is the whole point of drinking the potion. The Aswid's fourth slot + /// is filled too once the progression has unlocked it. + /// + public static void FillStomachs(Player player, string essencePrefabName) + { + if (player == null || ObjectDB.instance == null) return; + + GameObject prefab = ObjectDB.instance.GetItemPrefab(essencePrefabName); + ItemDrop drop = prefab != null ? prefab.GetComponent() : null; + if (drop == null) return; + + Traverse traverse = Traverse.Create(player); + IList foods = traverse.Field("m_foods").GetValue(); + if (foods == null) return; + + foods.Clear(); + for (int slot = 0; slot < 3; slot++) + { + foods.Add(MakeFood(drop, prefab, essencePrefabName)); + } + + if (AswidRace.IsAswid() && BossProgressionManager.GetCurrentProgressionState() >= 8) + { + ItemDrop.ItemData item = drop.m_itemData.Clone(); + item.m_dropPrefab = prefab; + AswidFoodManager.SetExtraFood(player, item); + } + + traverse.Method("UpdateFood", 0f, true).GetValue(); + } + + /// True while one of our two mead bases is the thing fermenting in that barrel. + public static bool IsBloodBrew(Fermenter fermenter) + { + if (fermenter == null || GetContentMethod == null) return false; + + string content = GetContentMethod.Invoke(fermenter, null) as string; + return content == BaseName || content == SuperiorBaseName; + } + + private static Player.Food MakeFood(ItemDrop drop, GameObject prefab, string prefabName) + { + ItemDrop.ItemData item = drop.m_itemData.Clone(); + // Vanilla reads m_dropPrefab.name when it rebuilds a food entry, and a cloned + // ItemData off a raw prefab does not carry it. + item.m_dropPrefab = prefab; + + return new Player.Food + { + m_name = prefabName, + m_item = item, + m_time = item.m_shared.m_foodBurnTime, + m_health = item.m_shared.m_food, + m_stamina = item.m_shared.m_foodStamina, + m_eitr = item.m_shared.m_foodEitr, + }; + } + } + + /// + /// Blood ferments fast. GetFermentationTime is the single place the barrel measures progress + /// from - GetStatus is its only caller - so scaling the elapsed time here makes the brew ready + /// at a quarter of the duration and keeps the hover text agreeing with it, without touching + /// m_fermentationDuration and dragging every vanilla mead along. + /// + [HarmonyPatch(typeof(Fermenter), "GetFermentationTime")] + public static class AswidBloodPotionFermentPatch + { + public static void Postfix(Fermenter __instance, ref double __result) + { + if (__result <= 0.0) return; + if (!AswidBloodPotions.IsBloodBrew(__instance)) return; + + __result *= AswidBloodPotions.FermentSpeedMultiplier; + } + } + + /// + /// The effect both potions apply. Heals a fraction of maximum health rather than a flat + /// amount, which SE_Stats cannot express on its own, and refills the drinker's food slots. + /// + public class SE_BloodPotion : SE_Stats + { + public float m_healFraction = 0.05f; + public string m_essencePrefab = ""; + + public override void Setup(Character character) + { + // SEMan clones the effect before setting it up, so writing the resolved amount here + // touches this drinker's copy only. + if (character != null) m_healthOverTime = character.GetMaxHealth() * m_healFraction; + + base.Setup(character); + + AswidBloodPotions.FillStomachs(character as Player, m_essencePrefab); + } + } +} diff --git a/JotunnModStub/Aswid/AswidBloodRefinery.cs b/JotunnModStub/Aswid/AswidBloodRefinery.cs new file mode 100644 index 0000000..1990b1e --- /dev/null +++ b/JotunnModStub/Aswid/AswidBloodRefinery.cs @@ -0,0 +1,573 @@ +using System.Collections.Generic; +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Aswid station: a half-size, blood-dark copy of the Eitr Refinery that eats raw flesh + /// and bone and produces Blood Essence, the base currency of the (future) Aswid potion tree. + /// + /// The whole chain is gated behind the Blood Core, an item sold by the Draugr faction + /// merchant, so the station cannot be reached without going through the Factions system. + /// + /// The vanilla refinery is a : a queue of "ore" names plus a single + /// fuel type, one product per queued item. That shape does not fit two numeric tanks fed by + /// many different items with different yields, so the Smelter component is stripped after its + /// scene references (switches, animators, output point, effect lists, state objects) are + /// handed over to . That is why the animation and the VFX + /// stay exactly the ones the vanilla refinery plays. + /// + public static class AswidBloodRefinery + { + public const string PieceName = "AswidBloodRefinery"; + public const string EssenceName = "BloodEssence"; + public const string SuperiorEssenceName = "SuperiorBloodEssence"; + public const string CoreName = "BloodCore"; + + // 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"; + + // 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. + private const float RegenPerHealth = 12f; + + public static GameObject EssencePrefab { get; private set; } + public static GameObject SuperiorEssencePrefab { get; private set; } + + // Half size, as designed. Everything under the root scales with it. + private const float ModelScale = 0.5f; + + private static readonly Color BodyTint = new Color(0.13f, 0.07f, 0.07f, 1f); + private static readonly Color BodyEmission = new Color(0.20f, 0.01f, 0.01f, 1f); + private static readonly Color EssenceTint = new Color(0.62f, 0.03f, 0.04f, 1f); + private static readonly Color SuperiorEssenceTint = new Color(0.85f, 0.0f, 0.02f, 1f); + private static readonly Color EssenceEmission = new Color(0.16f, 0.0f, 0.0f, 1f); + + /// + /// Every bone in the game and what it is worth to the machine. Bones carry no food values + /// to derive a number from, unlike meat, so this table is explicit. Names verified against + /// the shipped asset manifest, not guessed; entries the running game does not have are + /// simply never matched. + /// + public static readonly Dictionary BoneValues = new Dictionary + { + { "BoneFragments", 1 }, // Swamp / skeletons, the common one + { "CharredBone", 2 }, // Ashlands + { "Charredskull", 3 }, // Ashlands + { "WitheredBone", 3 }, // Bonemass offering, still just a bone + { "AsksvinCarrionNeck", 2 }, // Ashlands asksvin carrion + { "AsksvinCarrionPelvic", 2 }, + { "AsksvinCarrionRibcage", 3 }, + { "AsksvinCarrionSkull", 3 }, + { "UndeadBjornRibcage", 3 }, // Deep North + }; + + // Vanilla grills. Anything they cook counts as raw flesh, which keeps modded meat working. + private static readonly string[] CookingStationPrefabs = + { + "piece_cookingstation", + "piece_cookingstation_iron", + }; + + private static Dictionary meatToCooked; + + public static void Register() + { + RegisterCore(); + RegisterEssence(); + RegisterPiece(); + AswidBloodPotions.Register(); + } + + /// + /// True for anything the Aswid is allowed to put in a food slot: the blood drained from a + /// mob, or refined Blood Essence. AswidPatches routes both through the same slot logic. + /// + 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:") + || item.m_shared.m_name == EssenceDisplayName + || IsEssence(item); + } + + /// Either tier of refined blood - the things only an Aswid may swallow. + public static bool IsEssence(ItemDrop.ItemData item) + { + if (item == null || item.m_shared == null || item.m_shared.m_name == null) return false; + return item.m_shared.m_name == EssenceDisplayName || item.m_shared.m_name == SuperiorEssenceDisplayName; + } + + // ---------------------------------------------------------------- items + + private static void RegisterCore() + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(CoreName, "Bloodbag"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Aswid] Could not clone Bloodbag; Blood Core not registered."); + return; + } + + ItemDrop drop = prefab.GetComponent(); + if (drop == null) return; + + 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_itemType = ItemDrop.ItemData.ItemType.Material; + shared.m_food = 0f; + shared.m_foodStamina = 0f; + shared.m_foodEitr = 0f; + shared.m_weight = 0.5f; + shared.m_maxStackSize = 20; + + Sprite icon = BorrowIcon("MorgenHeart"); + if (icon != null) shared.m_icons = new[] { icon }; + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + } + + private static void RegisterEssence() + { + 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.", + food: 60f, + tint: EssenceTint, + iconSource: "GemstoneRed"); + + SuperiorEssencePrefab = BuildEssence( + SuperiorEssenceName, + SuperiorEssenceDisplayName, + "The same blood, rendered twice. Darker, thicker, and worth five of the first pass.", + food: 80f, + tint: SuperiorEssenceTint, + iconSource: "MoltenCore"); + } + + /// + /// Both essences are the same object with a different weight of red behind them. Stamina + /// and burn time are deliberately shared: only the health and the regeneration that scales + /// off it change between the two tiers. + /// + private static GameObject BuildEssence(string prefabName, string displayName, string description, + float food, Color tint, string iconSource) + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(prefabName, "Eitr"); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Aswid] Could not clone Eitr; {displayName} not registered."); + return null; + } + + // Refined eitr carries a Radiator of its own plus a point light. The design calls for + // red spheres that emit no light and hurt nothing, so both go. + StripOffensive(prefab, prefabName); + StripGlow(prefab, prefabName); + Recolour(prefab, tint, EssenceEmission); + RedShiftEffects(prefab, tint); + + ItemDrop drop = prefab.GetComponent(); + if (drop == null) return null; + + ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; + shared.m_name = displayName; + shared.m_description = description; + shared.m_itemType = ItemDrop.ItemData.ItemType.Consumable; + shared.m_weight = 0.2f; + + // Top of the food ladder on purpose: it costs a station, a purchased Core, and a pile + // of corpses, and no other race can swallow it. + shared.m_food = food; + shared.m_foodStamina = 60f; + shared.m_foodEitr = 0f; + shared.m_foodBurnTime = 2400f; // 40 minutes + shared.m_foodRegen = food / RegenPerHealth; + shared.m_consumeStatusEffect = null; + + // Repainting the eitr sprite pixel by pixel produced an empty slot in the inventory + // (the icon atlas is not readable), so a vanilla red icon is borrowed instead. + Sprite icon = BorrowIcon(iconSource); + if (icon != null) shared.m_icons = new[] { icon }; + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + return prefab; + } + + // ---------------------------------------------------------------- piece + + private static void RegisterPiece() + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PieceName, "eitrrefinery"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Aswid] Could not clone eitrrefinery; Blood Refinery not registered."); + return; + } + + Smelter smelter = prefab.GetComponentInChildren(true); + if (smelter == null) + { + Jotunn.Logger.LogWarning("[Aswid] eitrrefinery clone has no Smelter; Blood Refinery not registered."); + return; + } + + BloodRefineryBehaviour refinery = smelter.gameObject.AddComponent(); + refinery.m_addMeatSwitch = smelter.m_addOreSwitch; // the soft tissue slot + refinery.m_addBoneSwitch = smelter.m_addWoodSwitch; // the sap slot + refinery.m_outputPoint = smelter.m_outputPoint; + refinery.m_enabledObject = smelter.m_enabledObject; + refinery.m_disabledObject = smelter.m_disabledObject; + refinery.m_haveBoneObject = smelter.m_haveFuelObject; + 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; + refinery.m_produceEffects = smelter.m_produceEffects; + refinery.m_smokeSpawner = smelter.m_smokeSpawner; + + Object.DestroyImmediate(smelter); + + // 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_produceEffects, PieceName + ".produce"); + + prefab.transform.localScale = Vector3.one * ModelScale; + Recolour(prefab, BodyTint, BodyEmission); + RedShiftEffects(prefab); + + Piece piece = prefab.GetComponent(); + if (piece != null) + { + // Same call as RaceMenuWard: a piece whose crafting station is out of range is + // hidden from the hammer entirely, and this one has to be findable. + piece.m_craftingStation = null; + piece.m_resources = new Piece.Requirement[0]; + piece.m_name = PieceDisplayName; + } + + PieceConfig config = new PieceConfig + { + Name = PieceDisplayName, + Description = "Flesh goes in, bone goes in, and what is left of both comes out red.", + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Crafting, + Requirements = new[] + { + new RequirementConfig(CoreName, 1, 0, true), + new RequirementConfig("Stone", 20, 0, true), + new RequirementConfig("Bronze", 10, 0, true), + } + }; + + PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, config)); + } + + /// + /// A piece only shows up in the hammer once it is in the player's known recipes, and the + /// vanilla learning pass misses pieces injected after the fact - the same trap + /// RaceMenuWard fell into. The Blood Core requirement is the real gate; this only makes + /// the entry visible (greyed out until you own one). + /// + public static void EnsureKnown(Player player) + { + if (player == null) return; + + GameObject prefab = PrefabManager.Instance.GetPrefab(PieceName); + 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(); + } + + // ---------------------------------------------------------------- input values + + /// Units of blood a single piece of this item is worth, 0 if it is not flesh. + public static int BloodValue(string prefabName) + { + EnsureMeatMap(); + if (string.IsNullOrEmpty(prefabName) || !meatToCooked.TryGetValue(prefabName, out string cookedName)) return 0; + + // The yield is what the COOKED version would have given the eater: health plus + // stamina, so a lox steak is worth more than a neck tail without a second table. + ItemDrop.ItemData.SharedData source = SharedOf(cookedName) ?? SharedOf(prefabName); + if (source == null) return 1; + + int units = Mathf.CeilToInt((source.m_food + source.m_foodStamina) / 20f); + return Mathf.Max(1, units); + } + + /// + /// The same question BloodValue answers - "how much soft tissue is this piece of flesh + /// worth" - under a name that does not say "blood", for callers outside the Aswid. The + /// Trenta's Composter rots the same meat this refinery renders, so it asks here rather + /// than keeping a second table that would drift out of step with this one. + /// + public static int FleshValue(string prefabName) => BloodValue(prefabName); + + /// Units of bone a single piece of this item is worth, 0 if it is not a bone. + public static int BoneValue(string prefabName) + { + if (string.IsNullOrEmpty(prefabName)) return 0; + return BoneValues.TryGetValue(prefabName, out int units) ? units : 0; + } + + private static void EnsureMeatMap() + { + if (meatToCooked != null) return; + + // The raw -> cooked table the Draugh already maintains is the source of truth. + meatToCooked = new Dictionary(DraughFoodPatches.rawToCookedMapping); + meatToCooked.Remove("GreydwarfEye"); // stew ingredient, not flesh + meatToCooked["AsksvinMeat"] = "CookedAsksvinMeat"; + meatToCooked["BoneMawSerpentMeat"] = "CookedBoneMawSerpentMeat"; + + foreach (string stationName in CookingStationPrefabs) + { + GameObject station = PrefabManager.Cache.GetPrefab(stationName); + CookingStation cooking = station != null ? station.GetComponent() : null; + if (cooking == null || cooking.m_conversion == null) continue; + + foreach (CookingStation.ItemConversion conversion in cooking.m_conversion) + { + if (conversion == null || conversion.m_from == null || conversion.m_to == null) continue; + string from = conversion.m_from.gameObject.name; + if (!meatToCooked.ContainsKey(from)) meatToCooked[from] = conversion.m_to.gameObject.name; + } + } + } + + private static ItemDrop.ItemData.SharedData SharedOf(string prefabName) + { + GameObject prefab = ObjectDB.instance != null ? ObjectDB.instance.GetItemPrefab(prefabName) : null; + ItemDrop drop = prefab != null ? prefab.GetComponent() : null; + return drop != null ? drop.m_itemData.m_shared : null; + } + + // ---------------------------------------------------------------- prefab surgery + + /// + /// Removes anything on the prefab that can hurt somebody. Kept type-based rather than + /// name-based so a game update that renames a child object cannot quietly bring the + /// damage back. + /// + internal static void StripOffensive(GameObject root, string label) + { + foreach (MonoBehaviour behaviour in root.GetComponentsInChildren(true)) + { + if (behaviour == null || !IsOffensive(behaviour)) continue; + + Jotunn.Logger.LogInfo($"[Aswid] {label}: stripped {behaviour.GetType().Name} from '{behaviour.gameObject.name}'."); + Object.DestroyImmediate(behaviour); + } + } + + private static bool IsOffensive(MonoBehaviour behaviour) + { + // Radiator is the one that shoots. It is a plain MonoBehaviour holding a projectile + // prefab in a field and firing it every 2-5 seconds while its object is enabled, which + // is why neither an interface check nor a hierarchy scan for projectiles found it. The + // refinery carries two under _enabled (so only while it is running) and refined eitr + // carries one of its own - hence the 60 damage plus poison out of nowhere. + if (behaviour is Radiator) return true; + if (behaviour is IProjectile || behaviour is Aoe || behaviour is Turret) return true; + + // An EffectArea is usually harmless bookkeeping - PlayerBase marks the thing as part of + // a home, and stripping that was a mistake in the first pass. Only the burning kinds go. + EffectArea area = behaviour as EffectArea; + if (area == null) return false; + return (area.m_type & (EffectArea.Type.Heat | EffectArea.Type.Fire | EffectArea.Type.Burning)) != 0; + } + + private static bool IsOffensivePrefab(GameObject prefab) + { + if (prefab == null) return false; + if (prefab.name.ToLowerInvariant().Contains("radiation")) return true; + + foreach (MonoBehaviour behaviour in prefab.GetComponentsInChildren(true)) + { + if (behaviour != null && IsOffensive(behaviour)) return true; + } + return false; + } + + /// + /// Drops any effect the refinery plays that carries something damaging with it. Only the + /// list on our own clone is rebuilt - the referenced prefabs are the vanilla ones and are + /// never touched, so the real eitr refinery keeps working. + /// + private static void SanitiseEffects(EffectList list, string label) + { + if (list == null || list.m_effectPrefabs == null) return; + + List kept = new List(); + foreach (EffectList.EffectData data in list.m_effectPrefabs) + { + if (data == null || data.m_prefab == null) continue; + + if (IsOffensivePrefab(data.m_prefab)) + { + Jotunn.Logger.LogInfo($"[Aswid] {label}: dropped effect '{data.m_prefab.name}' (carries damage)."); + continue; + } + + Jotunn.Logger.LogInfo($"[Aswid] {label}: kept effect '{data.m_prefab.name}'."); + kept.Add(data); + } + list.m_effectPrefabs = kept.ToArray(); + } + + private static void StripGlow(GameObject root, string label) + { + // LightFlicker and LightLod both grab the Light in Awake without a null check, so + // deleting the Light on its own threw on every sphere the machine produced. They go + // first, and the light after. + foreach (LightFlicker flicker in root.GetComponentsInChildren(true)) + { + if (flicker != null) Object.DestroyImmediate(flicker); + } + foreach (LightLod lod in root.GetComponentsInChildren(true)) + { + if (lod != null) Object.DestroyImmediate(lod); + } + foreach (Light light in root.GetComponentsInChildren(true)) + { + if (light != null) Object.DestroyImmediate(light); + } + + foreach (Transform child in root.GetComponentsInChildren(true)) + { + if (child == null || child == root.transform) continue; + string name = child.gameObject.name.ToLowerInvariant(); + if (name.Contains("radiation") || name.Contains("gamma") || name.Contains("halo") || name.Contains("glow")) + { + Jotunn.Logger.LogInfo($"[Aswid] {label}: removed glow child '{child.gameObject.name}'."); + Object.DestroyImmediate(child.gameObject); + } + } + } + + /// + /// Turns the borrowed eitr VFX from purple to blood: particle tint and every remaining + /// light. The refinery keeps its lights - a running one should glow red - while the + /// essence spheres had theirs removed outright by StripGlow. + /// + private static void RedShiftEffects(GameObject root) + { + RedShiftEffects(root, EssenceTint); + } + + private static void RedShiftEffects(GameObject root, Color tint) + { + foreach (ParticleSystem particles in root.GetComponentsInChildren(true)) + { + if (particles == null) continue; + + ParticleSystem.MainModule main = particles.main; + main.startColor = new ParticleSystem.MinMaxGradient(tint); + } + + foreach (Light light in root.GetComponentsInChildren(true)) + { + if (light != null) light.color = tint; + } + } + + 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; + if (icons != null && icons.Length > 0 && icons[0] != null) return icons[0]; + + Jotunn.Logger.LogWarning($"[Aswid] Could not borrow the icon from '{prefabName}'."); + return null; + } + + private static void Recolour(GameObject root, Color tint, Color emission) + { + foreach (Renderer renderer in root.GetComponentsInChildren(true)) + { + if (renderer == null) continue; + + // Particle renderers are handled by RedShiftEffects - painting flames and smoke + // with the dark body tint just turns the VFX into soot. + if (renderer is ParticleSystemRenderer) continue; + + // renderer.material instantiates a copy, so the vanilla refinery and the vanilla + // eitr keep their own look. + foreach (Material material in renderer.materials) + { + if (material == null) continue; + material.color = tint; + if (material.HasProperty("_Color")) material.SetColor("_Color", tint); + if (material.HasProperty("_EmissionColor")) material.SetColor("_EmissionColor", emission); + } + } + } + } + + /// + /// Teaches the piece on spawn, exactly like RaceMenuWard does, because a piece registered + /// after the vanilla learning pass never reaches the hammer on its own. + /// + [HarmonyPatch(typeof(Player), "OnSpawned")] + public static class AswidBloodRefineryKnownPatch + { + public static void Postfix(Player __instance) + { + if (__instance != Player.m_localPlayer) return; + AswidBloodRefinery.EnsureKnown(__instance); + } + } + + /// + /// Blood Essence is Aswid food. Anyone else who tries to swallow it gets nothing, the same + /// way the Draugh's human meat is refused to the living. + /// + [HarmonyPatch(typeof(Player), "CanConsumeItem")] + public static class AswidBloodEssenceGatePatch + { + public static void Postfix(Player __instance, ItemDrop.ItemData item, ref bool __result) + { + if (__instance != Player.m_localPlayer || item == null || item.m_shared == null) return; + if (!AswidBloodRefinery.IsEssence(item)) return; + if (AswidRace.IsAswid()) return; + + __result = false; + } + } + + [HarmonyPatch(typeof(Humanoid), "UseItem")] + public static class AswidBloodEssenceMessagePatch + { + public static bool Prefix(Humanoid __instance, ItemDrop.ItemData item) + { + Player player = __instance as Player; + if (player == null || player != Player.m_localPlayer || item == null || item.m_shared == null) return true; + if (!AswidBloodRefinery.IsEssence(item)) return true; + if (AswidRace.IsAswid()) return true; + + player.Message(MessageHud.MessageType.Center, "Living blood curdles in a living throat."); + return false; + } + } +} diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index e3f2724..c115515 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -285,7 +285,7 @@ namespace RacesOfValheim { public static void Postfix(Player __instance, ItemDrop.ItemData item, ref bool __result) { - if (__instance == Player.m_localPlayer && AswidRace.IsAswid() && item != null && item.m_shared != null && item.m_shared.m_name.StartsWith("Aswid Food:")) + if (__instance == Player.m_localPlayer && AswidRace.IsAswid() && AswidBloodRefinery.IsAswidMeal(item)) { var foods = HarmonyLib.Traverse.Create(__instance).Field("m_foods").GetValue(); if (foods != null) @@ -339,7 +339,7 @@ namespace RacesOfValheim public static bool Prefix(Player __instance, ItemDrop.ItemData item, ref bool __result) { hiddenFoods.Clear(); - if (__instance == Player.m_localPlayer && AswidRace.IsAswid() && item != null && item.m_shared != null && item.m_shared.m_name.StartsWith("Aswid Food:")) + if (__instance == Player.m_localPlayer && AswidRace.IsAswid() && AswidBloodRefinery.IsAswidMeal(item)) { var m_foods = HarmonyLib.Traverse.Create(__instance).Field("m_foods").GetValue(); if (m_foods != null) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index a117fa9..93606cf 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -24,9 +24,13 @@ namespace RacesOfValheim { "Leech", "TrophyLeech" }, { "Hatchling", "TrophyHatchling" }, { "Lox", "TrophyLox" }, - { "Fuling", "TrophyGoblin" }, - { "FulingShaman", "TrophyGoblinShaman" }, - { "FulingBerserker", "TrophyGoblinBrute" }, + // The Fuling family is named Goblin* in code - "Fuling" is only ever the display name, + // and no prefab by that name exists. These three keys never matched anything, so the + // Aswid could not drain a Fuling of any kind. Verified against the asset manifest. + { "Goblin", "TrophyGoblin" }, + { "GoblinArcher", "TrophyGoblin" }, + { "GoblinShaman", "TrophyGoblinShaman" }, + { "GoblinBrute", "TrophyGoblinBrute" }, { "Deathsquito", "TrophyDeathsquito" }, { "Hare", "TrophyHare" }, { "Seeker", "TrophySeeker" }, @@ -35,7 +39,7 @@ namespace RacesOfValheim { "Gjall", "TrophyGjall" }, { "Tick", "TrophyTick" }, { "Ulv", "TrophyUlv" }, - { "Cultist", "TrophyCultist" }, + { "Fenring_Cultist", "TrophyCultist" }, // the prefab is Fenring_Cultist, not "Cultist" { "Asksvin", "TrophyAsksvin" }, { "Volture", "TrophyVolture" } }; @@ -84,6 +88,7 @@ namespace RacesOfValheim { AswidStatusEffects.RegisterStatusEffects(); CreateFoodItems(); + AswidBloodRefinery.Register(); GameObject geirrhafa = Jotunn.Managers.PrefabManager.Cache.GetPrefab("Fenring_Cultist_Hildir"); if (geirrhafa != null) @@ -137,7 +142,10 @@ namespace RacesOfValheim { float foodHp = Mathf.Min(c.m_health / 2f, 150f); float burnTime = c.m_health * 2f; - if (mobName == "Cultist" || mobName.StartsWith("Fenring") || mobName.StartsWith("Fuling")) + // StartsWith("Fenring") already covers Fenring_Cultist. "Fuling" was + // never a prefab prefix - the family is Goblin* - so that arm of the + // test matched nothing until now. + if (mobName.StartsWith("Fenring") || mobName.StartsWith("Goblin")) { burnTime = 1200f; // 20 minutes } diff --git a/JotunnModStub/Aswid/BloodRefineryBehaviour.cs b/JotunnModStub/Aswid/BloodRefineryBehaviour.cs new file mode 100644 index 0000000..f64e983 --- /dev/null +++ b/JotunnModStub/Aswid/BloodRefineryBehaviour.cs @@ -0,0 +1,299 @@ +using System; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Blood Refinery's logic. Modelled on - same one-second tick, same + /// owner-only accounting with everything in the ZDO so it keeps working in multiplayer and + /// keeps ticking while the zone is unloaded - but with two numeric tanks instead of an ore + /// queue and a single fuel item. + /// + /// Raw flesh is destroyed on the spot and becomes blood; bone is destroyed on the spot and + /// becomes bone dust. When both tanks can pay, the machine refines a Blood Essence and spits + /// it out of the vanilla output point. It never deals damage - see AswidBloodRefinery for the + /// strip pass that guarantees that. + /// + public class BloodRefineryBehaviour : MonoBehaviour + { + // Wired up from the vanilla Smelter before it is destroyed, which is what keeps the + // animation and the VFX identical to the eitr refinery's. + public Switch m_addMeatSwitch; + public Switch m_addBoneSwitch; + public Transform m_outputPoint; + public GameObject m_enabledObject; + public GameObject m_disabledObject; + public GameObject m_haveMeatObject; + public GameObject m_haveBoneObject; + public GameObject m_noMeatObject; + public Animator[] m_animators; + public EffectList m_meatAddedEffects; + public EffectList m_boneAddedEffects; + public EffectList m_produceEffects; + public SmokeSpawner m_smokeSpawner; + + // Balance. Ten units of blood is roughly one cooked lox steak's worth. + public float m_maxBlood = 50f; + public float m_maxBone = 20f; + public float m_bloodPerEssence = 5f; + public float m_bonePerEssence = 2f; + public float m_secPerEssence = 20f; + + private const string KeyBlood = "RoV_blood"; + private const string KeyBone = "RoV_bone"; + private const string KeyTimer = "RoV_refineTimer"; + private const string KeyAccumulator = "RoV_accTime"; + private const string KeyStartTime = "RoV_startTime"; + + private ZNetView m_nview; + private bool m_blockedSmoke; + + private void Awake() + { + m_nview = GetComponent(); + if (m_nview == null) m_nview = GetComponentInParent(); + if (m_nview == null || m_nview.GetZDO() == null) return; + + if (m_addMeatSwitch != null) + { + m_addMeatSwitch.m_onUse = OnAddMeat; + m_addMeatSwitch.m_onHover = HoverMeat; + } + if (m_addBoneSwitch != null) + { + m_addBoneSwitch.m_onUse = OnAddBone; + m_addBoneSwitch.m_onHover = HoverBone; + } + + m_nview.Register("RoV_AddMeat", RPC_AddMeat); + m_nview.Register("RoV_AddBone", RPC_AddBone); + + WearNTear wear = GetComponent(); + if (wear == null) wear = GetComponentInParent(); + if (wear != null) wear.m_onDestroyed = (Action)Delegate.Combine(wear.m_onDestroyed, new Action(OnDestroyed)); + + InvokeRepeating("UpdateRefinery", 1f, 1f); + } + + // ---------------------------------------------------------------- input + + private bool OnAddMeat(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + return TryAdd(user, item, isMeat: true); + } + + private bool OnAddBone(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + return TryAdd(user, item, isMeat: false); + } + + private bool TryAdd(Humanoid user, ItemDrop.ItemData item, bool isMeat) + { + if (user == null) return false; + Inventory inventory = user.GetInventory(); + if (inventory == null) return false; + + 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."); + return false; + } + + string prefabName = item.m_dropPrefab != null ? item.m_dropPrefab.name : null; + int value = isMeat ? AswidBloodRefinery.BloodValue(prefabName) : AswidBloodRefinery.BoneValue(prefabName); + if (value <= 0) + { + user.Message(MessageHud.MessageType.Center, "$msg_wontwork"); + return false; + } + + float stored = isMeat ? GetBlood() : GetBone(); + float capacity = isMeat ? m_maxBlood : m_maxBone; + if (stored >= capacity) + { + user.Message(MessageHud.MessageType.Center, "$msg_itsfull"); + return false; + } + + user.Message(MessageHud.MessageType.Center, "$msg_added " + item.m_shared.m_name); + inventory.RemoveItem(item, 1); + m_nview.InvokeRPC(isMeat ? "RoV_AddMeat" : "RoV_AddBone", prefabName); + return true; + } + + private ItemDrop.ItemData FindUsable(Inventory inventory, bool isMeat) + { + foreach (ItemDrop.ItemData candidate in inventory.GetAllItems()) + { + if (candidate == null || candidate.m_dropPrefab == null) continue; + string prefabName = candidate.m_dropPrefab.name; + int value = isMeat ? AswidBloodRefinery.BloodValue(prefabName) : AswidBloodRefinery.BoneValue(prefabName); + if (value > 0) return candidate; + } + return null; + } + + private void RPC_AddMeat(long sender, string prefabName) + { + if (!m_nview.IsOwner()) return; + + int value = AswidBloodRefinery.BloodValue(prefabName); + if (value <= 0) return; + + SetBlood(Mathf.Min(m_maxBlood, GetBlood() + value)); + if (m_meatAddedEffects != null) m_meatAddedEffects.Create(transform.position, transform.rotation); + } + + private void RPC_AddBone(long sender, string prefabName) + { + if (!m_nview.IsOwner()) return; + + int value = AswidBloodRefinery.BoneValue(prefabName); + if (value <= 0) return; + + SetBone(Mathf.Min(m_maxBone, GetBone() + value)); + if (m_boneAddedEffects != null) m_boneAddedEffects.Create(transform.position, transform.rotation, transform); + } + + // ---------------------------------------------------------------- the loop + + private void UpdateRefinery() + { + if (m_nview == null || !m_nview.IsValid()) return; + + m_blockedSmoke = m_smokeSpawner != null && m_smokeSpawner.IsBlocked(); + UpdateState(); + + if (!m_nview.IsOwner()) return; + + float accumulator = m_nview.GetZDO().GetFloat(KeyAccumulator) + (float)GetDeltaTime(); + if (accumulator > 3600f) accumulator = 3600f; // one hour of catch-up, as vanilla + + while (accumulator >= 1f) + { + accumulator -= 1f; + if (!IsActive()) continue; + + float timer = m_nview.GetZDO().GetFloat(KeyTimer) + 1f; + if (timer >= m_secPerEssence) + { + timer = 0f; + SetBlood(GetBlood() - m_bloodPerEssence); + SetBone(GetBone() - m_bonePerEssence); + Produce(); + } + m_nview.GetZDO().Set(KeyTimer, timer); + } + + m_nview.GetZDO().Set(KeyAccumulator, accumulator); + } + + private void Produce() + { + GameObject prefab = ObjectDB.instance != null + ? ObjectDB.instance.GetItemPrefab(AswidBloodRefinery.EssenceName) + : null; + if (prefab == null || m_outputPoint == null) return; + + if (m_produceEffects != null) m_produceEffects.Create(transform.position, transform.rotation); + + GameObject spawned = Instantiate(prefab, m_outputPoint.position, m_outputPoint.rotation); + ItemDrop drop = spawned.GetComponent(); + if (drop != null) + { + drop.m_itemData.m_stack = 1; + ItemDrop.OnCreateNew(drop); + } + } + + /// + /// Bones survive the machine, blood does not, so a demolished refinery gives the bone back + /// and keeps the blood. The hover text says so before anyone swings a hammer at it. + /// + private void OnDestroyed() + { + if (m_nview == null || !m_nview.IsOwner()) return; + + int bones = Mathf.FloorToInt(GetBone()); + SetBone(0f); + SetBlood(0f); + if (bones <= 0) return; + + GameObject prefab = ObjectDB.instance != null ? ObjectDB.instance.GetItemPrefab("BoneFragments") : null; + if (prefab == null) return; + + for (int i = 0; i < bones; i++) + { + Vector3 position = transform.position + Vector3.up * 0.5f + UnityEngine.Random.insideUnitSphere * 0.3f; + Quaternion rotation = Quaternion.Euler(0f, UnityEngine.Random.Range(0, 360), 0f); + ItemDrop.OnCreateNew(Instantiate(prefab, position, rotation)); + } + } + + // ---------------------------------------------------------------- state and display + + public bool IsActive() + { + if (m_blockedSmoke) return false; + return GetBlood() >= m_bloodPerEssence && GetBone() >= m_bonePerEssence; + } + + private void UpdateState() + { + bool active = IsActive(); + + if (m_enabledObject != null) m_enabledObject.SetActive(active); + if (m_disabledObject != null) m_disabledObject.SetActive(!active); + if (m_haveBoneObject != null) m_haveBoneObject.SetActive(GetBone() > 0f); + if (m_haveMeatObject != null) m_haveMeatObject.SetActive(GetBlood() > 0f); + if (m_noMeatObject != null) m_noMeatObject.SetActive(GetBlood() <= 0f); + + if (m_animators == null) return; + foreach (Animator animator in m_animators) + { + if (animator == null || !animator.gameObject.activeInHierarchy) continue; + animator.SetBool("active", active); + animator.SetFloat("activef", active ? 1f : 0f); + } + } + + private string HoverMeat() + { + return Localization.instance.Localize( + $"{AswidBloodRefinery.PieceDisplayName} (blood {Mathf.Floor(GetBlood())}/{m_maxBlood})\n" + + "[$KEY_Use] Render raw flesh"); + } + + private string HoverBone() + { + return Localization.instance.Localize( + $"{AswidBloodRefinery.PieceDisplayName} (bone {Mathf.Floor(GetBone())}/{m_maxBone})\n" + + "[$KEY_Use] Grind bone"); + } + + // ---------------------------------------------------------------- ZDO accessors + + private double GetDeltaTime() + { + DateTime now = ZNet.instance.GetTime(); + DateTime last = new DateTime(m_nview.GetZDO().GetLong(KeyStartTime, now.Ticks)); + m_nview.GetZDO().Set(KeyStartTime, now.Ticks); + return (now - last).TotalSeconds; + } + + private float GetBlood() => m_nview != null && m_nview.IsValid() ? m_nview.GetZDO().GetFloat(KeyBlood) : 0f; + + private float GetBone() => m_nview != null && m_nview.IsValid() ? m_nview.GetZDO().GetFloat(KeyBone) : 0f; + + private void SetBlood(float value) + { + if (m_nview != null && m_nview.IsValid()) m_nview.GetZDO().Set(KeyBlood, Mathf.Max(0f, value)); + } + + private void SetBone(float value) + { + if (m_nview != null && m_nview.IsValid()) m_nview.GetZDO().Set(KeyBone, Mathf.Max(0f, value)); + } + } +} From 96bc7796f9319ef5e816917f08df544c0b5abe16 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 7 Aug 2026 17:02:34 +0200 Subject: [PATCH 008/311] feat(draugh): body pile spawner Co-Authored-By: Claude Opus 5 --- JotunnModStub/Draugh/DraughRace.cs | 5 + JotunnModStub/Draugh/DraughSpawner.cs | 335 ++++++++++++++++ .../Draugh/DraughSpawnerBehaviour.cs | 366 ++++++++++++++++++ 3 files changed, 706 insertions(+) create mode 100644 JotunnModStub/Draugh/DraughSpawner.cs create mode 100644 JotunnModStub/Draugh/DraughSpawnerBehaviour.cs diff --git a/JotunnModStub/Draugh/DraughRace.cs b/JotunnModStub/Draugh/DraughRace.cs index 0293ec8..0fa6662 100644 --- a/JotunnModStub/Draugh/DraughRace.cs +++ b/JotunnModStub/Draugh/DraughRace.cs @@ -18,6 +18,11 @@ namespace RacesOfValheim public void CreateModAssets() { + // The body pile and its thralls. Registered here because the faction merchant catalogue + // resolves its entries by prefab name, so the two cursed bones have to exist before a + // Draugr is ever set up as a bench. + DraughSpawner.Register(); + // Generate EdibleUncooked prefabs for Draugh raw food logic foreach (var mapping in DraughFoodPatches.rawToCookedMapping) { diff --git a/JotunnModStub/Draugh/DraughSpawner.cs b/JotunnModStub/Draugh/DraughSpawner.cs new file mode 100644 index 0000000..b921be7 --- /dev/null +++ b/JotunnModStub/Draugh/DraughSpawner.cs @@ -0,0 +1,335 @@ +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Draugh station: a smaller, green body pile that eats raw flesh and answers with tamed + /// draugr. Third of the per-race station chains, after the Aswid's Blood Refinery and the + /// Trenta's Composter, and it takes its input rules straight from the second one - 100 units of + /// flesh valued by , one batch, one draugr. + /// + /// What makes it a Draugh thing rather than a piece of furniture anyone can use: the pile itself + /// works for whoever built it, but the draugr only take ORDERS from a Draugh. Anyone else gets a + /// grave that defends its own ten metres; a Draugh gets an escort. That asymmetry is the design, + /// not a limitation. + /// + /// Two special inputs, both of them draugr remains, because the pile is not fussy about where the + /// meat comes from: a Draugr trophy is worth a whole batch, and an Elite trophy is worth an elite + /// outright once the pile has been upgraded to hold any. + /// + public static class DraughSpawner + { + // ─── Names ─────────────────────────────────────────────────────────── + public const string PieceName = "DraughBodyPile"; + public const string PieceDisplayName = "Cursed Body Pile"; + + public const string BoneName = "CursedBone"; + public const string BoneDisplayName = "Cursed Bone"; + public const string GreaterBoneName = "GreaterCursedBone"; + public const string GreaterBoneDisplayName = "Greater Cursed Bone"; + + 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"; + + // 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. + public const string KindNormal = "DraughDraugr"; + public const string KindElite = "DraughDraugrElite"; + + public const string RaceId = "Draugh"; + + // The two trophies the pile accepts in place of meat. + public const string TrophyDraugr = "TrophyDraugr"; + public const string TrophyDraugrElite = "TrophyDraugrElite"; + + // ─── Balance ───────────────────────────────────────────────────────── + // 100 units is one full Composter batch on the same FleshValue scale, which is deliberate: + // it makes a Draugr trophy (worth exactly one batch) the real currency and raw meat the + // fallback. A trophy drops from roughly one draugr in ten, so the pile is fed mostly by + // doing the thing it is thematically about. + public const float FleshPerThrall = 100f; + + public const int AliveCap = 5; + public const int AliveCapUpgraded = 7; // +2 normals, as designed + public const int EliteCap = 0; // none at all until upgraded + public const int EliteCapUpgraded = 3; + + public const int ReserveCap = 5; + public const int ReserveCapElite = 3; + + // Local seconds, and only while the zone is loaded - see DraughSpawnerBehaviour. + public const float RespawnSeconds = 60f; + + // How long a thrall outlives the pile that made it. The same minute as the respawn on + // purpose: the player learns one number and it reads as "this pile thinks in minutes". + // + // Not zero, which is what it used to be. Killing them on the spot closed the duplication + // exploit but read terribly - dismantle your own pile and ten bodies drop with no + // explanation - and it disarmed you mid-fight if a raid took the pile down while your + // escort was out with you. A minute is short enough that rebuilding elsewhere to keep the + // old thralls is not worth the walk, and the anchor check in RaisedThrall is what actually + // closes that door rather than the length of this timer. + // + // World time, not local: an orphan has to keep withering while its zone is unloaded, or + // walking away would be a way to keep a dead pile's army alive indefinitely. + public const float OrphanWitherSeconds = 60f; + + // A thrall only asks "is my pile still standing?" when it is this close to home, because the + // answer can only be trusted where the pile would be loaded if it existed. Further out - out + // following its master, most of the time - the question is unanswerable and gets skipped. + // The leash is 10 m; this leaves room for one that has been knocked about. + public const float HomeCheckRange = 20f; + + // How far a thrall strays from the pile when it is not following anybody. Written onto the + // clone's BaseAI.m_randomMoveRange, which is the radius vanilla's own patrol wandering uses. + public const float LeashRange = 10f; + + // An escort, not a doomstack. The pile can hold ten; it can lend you four. + public const int MaxFollowers = 3; + public const int MaxEliteFollowers = 1; + + // Upgrading is gated on the lord of the swamp dead rather than on money alone. + public const int UpgradeProgressionState = 4; // Bonemass + + // ─── Density ───────────────────────────────────────────────────────── + // Five piles per 1.6 square kilometres, enforced by PieceDensityLimit. For scale, a Valheim + // zone is 64 m square, so 1.6 km2 is a disc about 22 zones across - big enough that five + // piles is a regional army rather than base decoration. + public const int MaxPilesInRange = 5; + public const float DensityAreaKm2 = 1.6f; + + // ─── Looks ─────────────────────────────────────────────────────────── + // Bigger than the vanilla pile, not smaller. The first pass went to 0.8 on the assumption that + // a buildable wants to be unobtrusive; in game it read as a scrap heap rather than as something + // that raises the dead. 1.2 gives it the presence the feature deserves. + private const float ModelScale = 1.2f; + + // Green, and far enough from the vanilla pile's brown-grey to be told apart across a swamp. + private static readonly Color PileTint = new Color(0.22f, 0.52f, 0.24f, 1f); + private static readonly Color BoneTint = new Color(0.35f, 0.45f, 0.30f, 1f); + private static readonly Color GreaterBoneTint = new Color(0.20f, 0.55f, 0.25f, 1f); + + 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."); + RegisterBone(GreaterBoneName, GreaterBoneDisplayName, GreaterBoneTint, + "The same bone, older, and louder. A pile fed one of these starts keeping officers."); + + RegisterThrall(ThrallName, "Draugr", ThrallDisplayName, KindNormal, MaxFollowers); + RegisterThrall(ThrallEliteName, "Draugr_Elite", ThrallEliteDisplayName, KindElite, MaxEliteFollowers); + + RegisterPiece(); + + PieceDensityLimit.Register(PieceName, + PieceDensityLimit.RadiusForArea(DensityAreaKm2), MaxPilesInRange, + "The ground here already carries {0} of these. Find another country."); + } + + // ---------------------------------------------------------------- items + + private static void RegisterBone(string prefabName, string displayName, Color tint, string description) + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(prefabName, "BoneFragments"); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Draugh] Could not clone BoneFragments; {displayName} not registered."); + return; + } + + Recolour(prefab, tint); + + ItemDrop drop = prefab.GetComponent(); + if (drop == null) return; + + ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; + shared.m_name = displayName; + shared.m_description = description; + shared.m_itemType = ItemDrop.ItemData.ItemType.Material; + shared.m_weight = 1f; + shared.m_maxStackSize = 10; + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + } + + // ---------------------------------------------------------------- thralls + + /// + /// A draugr that is born tame and on a leash. + /// + /// Cloned rather than tamed in place so the leash range, the name and the loot table are the + /// prefab's own business and no vanilla draugr is touched. Its CharacterDrop is destroyed + /// outright: a conjured corpse leaves nothing behind. Without that, killing your own thralls + /// would farm the entrails and bone fragments this whole chain is built out of - and, at a one + /// in ten trophy rate, hand back a slice of the flesh that paid for it. + /// + private static void RegisterThrall(string prefabName, string source, string displayName, + string kind, int maxFollowers) + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(prefabName, source); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Draugh] Could not clone {source}; {displayName} not registered."); + return; + } + + Character character = prefab.GetComponent(); + if (character != null) character.m_name = displayName; + + BaseAI ai = prefab.GetComponent(); + if (ai != null) + { + // The radius vanilla's own patrol wandering keeps to around m_patrolPoint, which + // RaisedThrall pins to the pile. + ai.m_randomMoveRange = LeashRange; + } + + foreach (CharacterDrop drops in prefab.GetComponentsInChildren(true)) + { + if (drops != null) Object.DestroyImmediate(drops); + } + + RaisedThrall thrall = prefab.AddComponent(); + thrall.m_kind = kind; + thrall.m_commandingRace = RaceId; // only a Draugh may give these orders + thrall.m_maxFollowers = maxFollowers; + thrall.m_witherSeconds = OrphanWitherSeconds; + thrall.m_homeCheckRange = HomeCheckRange; + thrall.m_refusalMessage = "The dead do not take orders from the living."; + + PrefabManager.Instance.AddPrefab(prefab); + } + + // ---------------------------------------------------------------- piece + + private static void RegisterPiece() + { + // Spawner_DraugrPile is the visible, destructible body pile of the swamps - the only one + // of the seven Spawner_Draugr* prefabs with hit and destruction effects of its own, which + // is what says it has a model rather than being a world-generation spawn point. + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PieceName, "Spawner_DraugrPile"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Draugh] Could not clone Spawner_DraugrPile; the body pile is not registered."); + return; + } + + // The vanilla pile's whole job is spawning hostile draugr on a timer at anyone who walks + // past. Every bit of that goes: what it produces, when, and for whom is ours now. + foreach (SpawnArea area in prefab.GetComponentsInChildren(true)) + { + if (area != null) Object.DestroyImmediate(area); + } + + // Same belt as the Composter: a bone pile carries nothing that shoots, but the eitr + // refinery taught this codebase not to assume. A silent log is the proof. + AswidBloodRefinery.StripOffensive(prefab, PieceName); + + DraughSpawnerBehaviour behaviour = prefab.AddComponent(); + + // One interaction point, as on the Composter: what is in your hand decides what the click + // means. Any Switch the prefab happened to carry goes first so it cannot win the hover + // from a child collider - the components only, never their colliders. + foreach (Switch existing in prefab.GetComponentsInChildren(true)) + { + if (existing != null) Object.DestroyImmediate(existing); + } + behaviour.m_switch = prefab.AddComponent(); + behaviour.m_switch.m_name = PieceDisplayName; + + prefab.transform.localScale = Vector3.one * ModelScale; + Recolour(prefab, PileTint); + + Piece piece = prefab.GetComponent() ?? prefab.AddComponent(); + piece.m_craftingStation = null; + piece.m_resources = new Piece.Requirement[0]; + piece.m_name = PieceDisplayName; + piece.m_canBeRemoved = true; + piece.m_groundPiece = true; + piece.m_groundOnly = true; + piece.m_icon = BorrowIcon(TrophyDraugr); + + // Learned on the Furling's bushes: a Piece added to world scenery is born with no icon + // and no place effect, and a null icon is a blank, unclickable square in the build menu. + 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 = PieceDisplayName, + Description = "Feed it and it answers. The dead here are yours, if you are dead enough to ask.", + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Crafting, + Icon = BorrowIcon(TrophyDraugr), + Requirements = new[] + { + new RequirementConfig(BoneName, 1, 0, true), + new RequirementConfig("Entrails", 10, 0, true), + new RequirementConfig("BoneFragments", 20, 0, true), + } + })); + } + + /// + /// Same reason as the Composter's and the Furling's: a piece registered after the vanilla + /// learning pass never reaches the hammer on its own. The purchased Cursed Bone is the gate. + /// + public static void EnsureKnown(Player player) + { + if (player == null) return; + + GameObject prefab = PrefabManager.Instance.GetPrefab(PieceName); + 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(); + } + + // ---------------------------------------------------------------- helpers + + 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; + if (icons != null && icons.Length > 0 && icons[0] != null) return icons[0]; + + Jotunn.Logger.LogWarning($"[Draugh] Could not borrow the icon from '{prefabName}'."); + return null; + } + + private static void Recolour(GameObject root, Color tint) + { + foreach (Renderer renderer in root.GetComponentsInChildren(true)) + { + if (renderer == null || renderer is ParticleSystemRenderer) continue; + + foreach (Material material in renderer.materials) + { + if (material == null) continue; + material.color = tint; + if (material.HasProperty("_Color")) material.SetColor("_Color", tint); + } + } + } + } + + [HarmonyPatch(typeof(Player), "OnSpawned")] + public static class DraughSpawnerKnownPatch + { + public static void Postfix(Player __instance) + { + if (__instance != Player.m_localPlayer) return; + DraughSpawner.EnsureKnown(__instance); + } + } +} diff --git a/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs b/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs new file mode 100644 index 0000000..98c760d --- /dev/null +++ b/JotunnModStub/Draugh/DraughSpawnerBehaviour.cs @@ -0,0 +1,366 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The body pile's logic. Same skeleton as ComposterBehaviour - one Switch, one numeric tank fed + /// by many different meats, all state in the ZDO, owner-only accounting - with a roster on top. + /// + /// Two deliberate differences from the Composter's timing, both of them about not punishing the + /// player for walking away: + /// - the respawn timer runs on LOCAL time and only while the zone is loaded. The Composter's + /// seal time is world time, because rotting happens whether anyone watches; a grave refilling + /// itself while unloaded would instead let a wandering troll drain the whole reserve into a + /// field of corpses nobody was there to use. + /// - the roster is counted, never tallied. Alive thralls are found by asking the world which + /// creatures are bound to this pile, so a death, a despawn or a player killing his own thrall + /// all correct themselves with no bookkeeping to drift. + /// + public class DraughSpawnerBehaviour : MonoBehaviour + { + public Switch m_switch; + + private const string KeyFlesh = "RoV_draughFlesh"; + private const string KeyReserve = "RoV_draughReserve"; + private const string KeyReserveElite = "RoV_draughReserveElite"; + private const string KeyUpgraded = "RoV_draughUpgraded"; + + private ZNetView m_nview; + private float m_respawnTimer; + + private void OnDestroy() + { + RaisedThrall.UnregisterStation(transform); + } + + private void Awake() + { + // The shared registry RaisedThrall consults to answer "is my pile still standing?". + RaisedThrall.RegisterStation(transform); + + m_nview = GetComponent(); + if (m_nview == null || m_nview.GetZDO() == null) return; + + if (m_switch != null) + { + m_switch.m_onUse = OnUse; + m_switch.m_onHover = Hover; + } + + m_nview.Register("RoV_DraughFeed", RPC_Feed); + m_nview.Register("RoV_DraughUpgrade", RPC_Upgrade); + + WearNTear wear = GetComponent(); + if (wear != null) wear.m_onDestroyed = (Action)Delegate.Combine(wear.m_onDestroyed, new Action(OnDestroyed)); + + InvokeRepeating("UpdatePile", 2f, 2f); + } + + // ---------------------------------------------------------------- interaction + + /// + /// One interaction point, like the Composter's: what is in hand decides what the click means. + /// 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. + /// + private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + if (user == null) return false; + + Inventory inventory = user.GetInventory(); + if (inventory == null) return false; + + 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."); + return false; + } + + string prefabName = item.m_dropPrefab != null ? item.m_dropPrefab.name : null; + if (prefabName == null) return false; + + if (prefabName == DraughSpawner.GreaterBoneName) return TryUpgrade(user, inventory, item); + + if (prefabName == DraughSpawner.TrophyDraugrElite && !IsUpgraded()) + { + user.Message(MessageHud.MessageType.Center, "This pile keeps no officers yet."); + return false; + } + + if (prefabName != DraughSpawner.TrophyDraugr && + prefabName != DraughSpawner.TrophyDraugrElite && + AswidBloodRefinery.FleshValue(prefabName) <= 0) + { + user.Message(MessageHud.MessageType.Center, "$msg_wontwork"); + return false; + } + + // Fullness depends on which shelf the input goes on. Asking the wrong one is not cosmetic: + // an Elite trophy accepted here and then dropped by RPC_Feed for want of an officer slot + // would be an item destroyed for nothing. + bool elite = prefabName == DraughSpawner.TrophyDraugrElite; + if (elite ? GetReserveElite() >= DraughSpawner.ReserveCapElite : IsFull()) + { + user.Message(MessageHud.MessageType.Center, "$msg_itsfull"); + return false; + } + + // An Elite trophy banks an officer each, and the shelf holds three - so a stack of ten + // would have had seven of them clamped away by RPC_Feed and destroyed. Found on the + // Skeleton's pile, which has the identical shape, and fixed here before it could bite. + // Flesh needs no equivalent because its remainder stays in the tank rather than vanishing. + if (elite) + { + int room = DraughSpawner.ReserveCapElite - GetReserveElite(); + int takenElite = Mathf.Min(Mathf.Max(1, item.m_stack), room); + + user.Message(MessageHud.MessageType.Center, $"$msg_added {item.m_shared.m_name} x{takenElite}"); + inventory.RemoveItem(item, takenElite); + m_nview.InvokeRPC("RoV_DraughFeed", prefabName, takenElite); + return true; + } + + // A whole stack per click. The Composter asks for a hundred units one item at a time and + // gets away with it because a batch is the end of the story; a full complement here is ten + // batches, and clicking that out one neck tail at a time is not a mechanic. + // + // The count goes over as an argument rather than as one RPC per item - a stack of fifty + // neck tails would otherwise be fifty round trips to say the same thing. + int stack = Mathf.Max(1, item.m_stack); + user.Message(MessageHud.MessageType.Center, $"$msg_added {item.m_shared.m_name} x{stack}"); + inventory.RemoveItem(item, stack); + + m_nview.InvokeRPC("RoV_DraughFeed", prefabName, stack); + return true; + } + + private ItemDrop.ItemData FindAnyInput(Inventory inventory) + { + foreach (ItemDrop.ItemData candidate in inventory.GetAllItems()) + { + if (candidate == null || candidate.m_dropPrefab == null) continue; + + string name = candidate.m_dropPrefab.name; + if (name == DraughSpawner.TrophyDraugr) return candidate; + if (name == DraughSpawner.TrophyDraugrElite && IsUpgraded()) return candidate; + if (AswidBloodRefinery.FleshValue(name) > 0) return candidate; + } + return null; + } + + private bool TryUpgrade(Humanoid user, Inventory inventory, ItemDrop.ItemData item) + { + if (IsUpgraded()) + { + user.Message(MessageHud.MessageType.Center, "It 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."); + return false; + } + + inventory.RemoveItem(item, 1); + m_nview.InvokeRPC("RoV_DraughUpgrade"); + user.Message(MessageHud.MessageType.Center, "The pile stirs. It will keep officers now."); + return true; + } + + // ---------------------------------------------------------------- accounting + + private void RPC_Feed(long sender, string prefabName, int count) + { + if (!m_nview.IsOwner()) return; + if (count < 1) count = 1; + + // An Elite trophy is not flesh - it banks an officer outright. + if (prefabName == DraughSpawner.TrophyDraugrElite) + { + if (!IsUpgraded()) return; + SetReserveElite(GetReserveElite() + count); // the setter clamps to the shelf + return; + } + + float value = prefabName == DraughSpawner.TrophyDraugr + ? DraughSpawner.FleshPerThrall // a head is worth a whole batch + : AswidBloodRefinery.FleshValue(prefabName); + if (value <= 0f) return; + + float flesh = GetFlesh() + value * count; + + // Every complete batch becomes a banked thrall. A loop rather than a single test so a + // trophy - or a stack of them - cannot overflow into flesh that never gets counted. + while (flesh >= DraughSpawner.FleshPerThrall && GetReserve() < DraughSpawner.ReserveCap) + { + flesh -= DraughSpawner.FleshPerThrall; + SetReserve(GetReserve() + 1); + } + + SetFlesh(flesh); + } + + private void RPC_Upgrade(long sender) + { + if (!m_nview.IsOwner()) return; + m_nview.GetZDO().Set(KeyUpgraded, true); + } + + private void UpdatePile() + { + if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return; + + List bound = RaisedThrall.BoundTo(transform.position); + int aliveNormal = 0; + int aliveElite = 0; + foreach (RaisedThrall thrall in bound) + { + if (thrall.Kind == DraughSpawner.KindElite) aliveElite++; else aliveNormal++; + } + + bool wantsNormal = aliveNormal < AliveCap() && GetReserve() > 0; + bool wantsElite = aliveElite < EliteCap() && GetReserveElite() > 0; + + if (!wantsNormal && !wantsElite) + { + m_respawnTimer = 0f; + return; + } + + m_respawnTimer += 2f; // the tick interval + if (m_respawnTimer < DraughSpawner.RespawnSeconds) return; + m_respawnTimer = 0f; + + // Officers first: they are the scarcer resource and the reason to upgrade at all. + if (wantsElite) + { + if (Spawn(DraughSpawner.ThrallEliteName)) SetReserveElite(GetReserveElite() - 1); + } + else if (wantsNormal) + { + if (Spawn(DraughSpawner.ThrallName)) SetReserve(GetReserve() - 1); + } + } + + private bool Spawn(string prefabName) + { + GameObject prefab = ZNetScene.instance != null ? ZNetScene.instance.GetPrefab(prefabName) : null; + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Draugh] No '{prefabName}' in ZNetScene; the pile cannot raise anything."); + return false; + } + + Vector3 offset = UnityEngine.Random.insideUnitSphere * 2f; + offset.y = 0f; + Vector3 position = transform.position + offset + Vector3.up * 0.5f; + + GameObject spawned = Instantiate(prefab, position, Quaternion.Euler(0f, UnityEngine.Random.Range(0, 360), 0f)); + RaisedThrall thrall = spawned.GetComponent(); + if (thrall != null) thrall.Bind(transform.position); + + return true; + } + + /// + /// The pile sustains them, so it takes them with it - but on a minute's delay rather than on + /// the spot. Without some form of this a pile is a duplication exploit: fill it, dismantle it, + /// rebuild it elsewhere, fill it again, and keep every thrall from every round. + /// + /// This marks the ones it can reach. It cannot reach thralls whose zone is unloaded right now, + /// which is why RaisedThrall also checks for itself once it is home again - between the two, + /// nothing outlives its pile. + /// + private void OnDestroyed() + { + if (m_nview == null || !m_nview.IsOwner()) return; + + List bound = RaisedThrall.BoundTo(transform.position); + foreach (RaisedThrall thrall in bound) thrall.MarkOrphaned(); + + // Said once, by the client that just knocked it down, because the hover text that would + // otherwise explain this is going away with the pile. + 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."); + } + + SetFlesh(0f); + SetReserve(0); + SetReserveElite(0); + } + + // ---------------------------------------------------------------- state and display + + public bool IsUpgraded() => m_nview != null && m_nview.IsValid() && m_nview.GetZDO().GetBool(KeyUpgraded, false); + + private int AliveCap() => IsUpgraded() ? DraughSpawner.AliveCapUpgraded : DraughSpawner.AliveCap; + + private int EliteCap() => IsUpgraded() ? DraughSpawner.EliteCapUpgraded : DraughSpawner.EliteCap; + + /// Full when there is nowhere left to put a finished thrall. + private bool IsFull() => GetReserve() >= DraughSpawner.ReserveCap; + + /// + /// Everything a player needs to know without opening a log, which is the standard this project + /// arrived at the hard way: a mechanic that cannot say whether it is working looks exactly like + /// one that is broken. + /// + private string Hover() + { + List bound = RaisedThrall.BoundTo(transform.position); + int aliveNormal = 0; + int aliveElite = 0; + foreach (RaisedThrall thrall in bound) + { + if (thrall.Kind == DraughSpawner.KindElite) aliveElite++; else aliveNormal++; + } + + string body = $"flesh {Mathf.Floor(GetFlesh())}/{DraughSpawner.FleshPerThrall}, " + + $"risen {aliveNormal}/{AliveCap()}, waiting {GetReserve()}/{DraughSpawner.ReserveCap}"; + + if (IsUpgraded()) + { + body += $"\nofficers {aliveElite}/{EliteCap()}, waiting {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 += "\n[$KEY_Use] Feed it flesh, or a draugr's head"; + + return Localization.instance.Localize($"{DraughSpawner.PieceDisplayName} ({body})"); + } + + // ---------------------------------------------------------------- ZDO accessors + + private float GetFlesh() => m_nview != null && m_nview.IsValid() ? m_nview.GetZDO().GetFloat(KeyFlesh) : 0f; + + private void SetFlesh(float value) + { + if (m_nview != null && m_nview.IsValid()) m_nview.GetZDO().Set(KeyFlesh, Mathf.Max(0f, value)); + } + + private int GetReserve() => m_nview != null && m_nview.IsValid() ? m_nview.GetZDO().GetInt(KeyReserve) : 0; + + private void SetReserve(int value) + { + if (m_nview != null && m_nview.IsValid()) m_nview.GetZDO().Set(KeyReserve, Mathf.Clamp(value, 0, DraughSpawner.ReserveCap)); + } + + private int GetReserveElite() => m_nview != null && m_nview.IsValid() ? m_nview.GetZDO().GetInt(KeyReserveElite) : 0; + + private void SetReserveElite(int value) + { + if (m_nview != null && m_nview.IsValid()) m_nview.GetZDO().Set(KeyReserveElite, Mathf.Clamp(value, 0, DraughSpawner.ReserveCapElite)); + } + } +} From b67a324cb8ce9b94347a196ee7aca034772ae53f Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 7 Aug 2026 17:02:35 +0200 Subject: [PATCH 009/311] feat(skeleton): bound bone pile and bound sentry Co-Authored-By: Claude Opus 5 --- JotunnModStub/Skeleton/SkeletonBonePile.cs | 383 +++++++++++++++++ .../Skeleton/SkeletonBonePileBehaviour.cs | 403 ++++++++++++++++++ JotunnModStub/Skeleton/SkeletonPatches.cs | 4 +- JotunnModStub/Skeleton/SkeletonRace.cs | 5 + JotunnModStub/Skeleton/SkeletonSentry.cs | 283 ++++++++++++ 5 files changed, 1077 insertions(+), 1 deletion(-) create mode 100644 JotunnModStub/Skeleton/SkeletonBonePile.cs create mode 100644 JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs create mode 100644 JotunnModStub/Skeleton/SkeletonSentry.cs diff --git a/JotunnModStub/Skeleton/SkeletonBonePile.cs b/JotunnModStub/Skeleton/SkeletonBonePile.cs new file mode 100644 index 0000000..19f22f7 --- /dev/null +++ b/JotunnModStub/Skeleton/SkeletonBonePile.cs @@ -0,0 +1,383 @@ +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Skeleton station: a bone pile from the crypts that raises a standing garrison. + /// + /// Same family as the Draugh's body pile and it shares that feature's whole thrall layer + /// (), but the economy is the opposite way round on purpose. The Draugh + /// pays per draugr out of a reserve that empties; the Skeleton pays ONCE PER SLOT and that slot + /// then refills itself forever. Skeletons are fragile - a troll or a drake clears the whole line + /// in one swing - so an army you have to re-buy after every fight is an army nobody would take + /// out of the house. + /// + /// That permanent slot is also, by itself, the "skeletons leave exactly the materials that made + /// them" idea: the bones are not dropped and re-fed, they simply get up again. Nothing is + /// generated, nothing is consumed, and the same twenty fragments stand back up as many times as + /// they are knocked down. It needs no death hook and no drop table - which is why the thralls have + /// their CharacterDrop stripped like the Draugh's, rather than filled in. + /// + /// Two differences from the Draugh worth stating because they are deliberate, not oversights: + /// - a destroyed pile kills its garrison INSTANTLY, where a body pile gives its draugr a minute. + /// Free perpetual regeneration is the trade for a hard off switch. + /// - melee and ranged are the same vanilla creature with different hands. There is no ranged + /// skeleton prefab: Skeleton_NoArcher is vanilla's own guaranteed-melee variant, and the + /// archer is a plain Skeleton whose loadout is forced to the bow. + /// + public static class SkeletonBonePile + { + // ─── Names ─────────────────────────────────────────────────────────── + public const string PieceName = "SkeletonBonePile"; + public const string PieceDisplayName = "Bound Bone Pile"; + + // 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 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 GreaterSkullName = "GreaterCursedSkull"; + public const string GreaterSkullDisplayName = "Greater Cursed Skull"; + + 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 KindMelee = "SkeletonMelee"; + public const string KindRanged = "SkeletonRanged"; + public const string KindRancid = "SkeletonRancid"; + + public const string RaceId = "Skeleton"; + + /// The one material a slot is bought with. Fixed, not a fungible bone tank - see the + /// class comment on why "exactly the materials that made them" needs a recipe. + public const string BonePrefab = "BoneFragments"; + public const int BonesPerSlot = 20; + + /// Buys a Rancid slot outright, the way an Elite trophy buys the Draugh an officer. + public const string RancidTrophy = "TrophySkeletonPoison"; + + // ─── Balance ───────────────────────────────────────────────────────── + public const int MeleeSlots = 4; + public const int RangedSlots = 4; + public const int MeleeSlotsUpgraded = 5; + public const int RangedSlotsUpgraded = 5; + public const int RancidSlots = 0; // none at all until upgraded + public const int RancidSlotsUpgraded = 2; + + // Local seconds, and only while the zone is loaded - a garrison should not quietly rebuild + // itself in an unloaded zone. Faster once upgraded: the pile gets better at it. + public const float RespawnSeconds = 20f; + public const float RespawnSecondsUpgraded = 15f; + + // NOT the "instant" from the design conversation - that lives in the pile's OnDestroyed, which + // calls Kill() on the spot. This number only governs the FALLBACK: a skeleton that was in an + // unloaded zone when the pile fell and finds nothing at home when it loads again. + // + // It was 0, and zero has no tolerance for a hiccup: a pile whose zone unloads for a moment + // while a skeleton at the boundary stays loaded reads as "no pile" and wipes the garrison with + // no appeal. Five seconds costs nothing anyone can perceive - the deliberate destruction path + // is still immediate - and it means one bad frame is not a wipe. + public const float OrphanWitherSeconds = 5f; + public const float HomeCheckRange = 20f; + public const float LeashRange = 10f; + + // No cap: the whole point of the new command is that the garrison moves as one. + public const int MaxFollowers = -1; + + // A Rancid Remains clicked directly takes five of the rank and file with it, instead of the + // whole line the pile would send. Its own squad, and small enough that it stays a squad. + public const int RancidEscort = 5; + + public const int UpgradeProgressionState = 4; // Bonemass, same gate as the Draugh's officers + + public const int MaxPilesInRange = 5; + public const float DensityAreaKm2 = 1.6f; + + // ─── Looks ─────────────────────────────────────────────────────────── + private const float ModelScale = 1.2f; + + // Cold bone-white, so it never reads as the Draugh's green pile at a glance. + private static readonly Color PileTint = new Color(0.82f, 0.84f, 0.78f, 1f); + private static readonly Color SkullTint = new Color(0.78f, 0.80f, 0.74f, 1f); + private static readonly Color GreaterSkullTint = new Color(0.62f, 0.72f, 0.80f, 1f); + + public static void Register() + { + RegisterSkull(SkullName, SkullDisplayName, SkullTint, + "A skull that keeps counting. Set it down and the ground starts answering."); + RegisterSkull(GreaterSkullName, GreaterSkullDisplayName, GreaterSkullTint, + "Older, and it counts higher. A pile given one of these raises the rotten too."); + + RegisterSoulStone(); + + RegisterThrall(ThrallMeleeName, "Skeleton_NoArcher", ThrallMeleeDisplay, KindMelee, null); + RegisterThrall(ThrallRangedName, "Skeleton", ThrallRangedDisplay, KindRanged, "skeleton_bow"); + RegisterThrall(ThrallRancidName, "Skeleton_Poison", ThrallRancidDisplay, KindRancid, null, RancidEscort); + + RegisterPiece(); + + // The standing sentry. Registered after the archer it clones, so that prefab exists first. + SkeletonSentry.Register(); + + PieceDensityLimit.Register(PieceName, + PieceDensityLimit.RadiusForArea(DensityAreaKm2), MaxPilesInRange, + "There are already {0} of these listening nearby. Take it further out."); + } + + // ---------------------------------------------------------------- items + + private static void RegisterSkull(string prefabName, string displayName, Color tint, string description) + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(prefabName, "TrophySkeleton"); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] Could not clone TrophySkeleton; {displayName} not registered."); + return; + } + + Recolour(prefab, tint); + + ItemDrop drop = prefab.GetComponent(); + if (drop == null) return; + + ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared; + shared.m_name = displayName; + shared.m_description = description; + shared.m_itemType = ItemDrop.ItemData.ItemType.Material; + shared.m_weight = 1f; + shared.m_maxStackSize = 10; + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + } + + /// + /// A ruby, turned green. Cloned rather than tinted in place so real rubies keep being red, the + /// same discipline every other borrowed prefab in this project follows. + /// + /// One caveat that always applies and is worth repeating on a gemstone: the tint reaches the + /// world and held models but NOT the inventory icon, because icons are atlas sprites and + /// repainting one produces an empty slot. In the inventory this reads as a ruby; the name and + /// the tooltip are what tell it apart. If that matters, borrow the icon of a green vanilla item + /// instead - it is one line. + /// + private static void RegisterSoulStone() + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(SoulStoneName, "Ruby"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Skeleton] Could not clone Ruby; Soul Stone not registered."); + return; + } + + Recolour(prefab, SoulStoneTint); + + ItemDrop drop = prefab.GetComponent(); + if (drop == null) return; + + 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_itemType = ItemDrop.ItemData.ItemType.Material; + shared.m_weight = 0.5f; + shared.m_maxStackSize = 20; + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + } + + // ---------------------------------------------------------------- thralls + + /// + /// One kind of bound skeleton, born tame and leashed to its pile. + /// + /// The weapon argument is what separates melee from ranged, because the distinction does not + /// exist at the prefab level: Skeleton_NoArcher is vanilla's guaranteed-melee variant, and a + /// plain Skeleton rolls its own weapon. Forcing m_defaultItems and clearing the random lists is + /// what makes an archer an archer every time instead of four times in eight. + /// + /// CharacterDrop is destroyed for the same reason as the Draugh's, plus one of its own: a + /// garrison that regenerates for free and drops its bones on death would be a bone mill. + /// + private static void RegisterThrall(string prefabName, string source, string displayName, + string kind, string forcedWeapon, int escortCount = 0) + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(prefabName, source); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] Could not clone {source}; {displayName} not registered."); + return; + } + + Character character = prefab.GetComponent(); + if (character != null) character.m_name = displayName; + + BaseAI ai = prefab.GetComponent(); + if (ai != null) ai.m_randomMoveRange = LeashRange; + + if (forcedWeapon != null) + { + Humanoid humanoid = prefab.GetComponent(); + GameObject weapon = PrefabManager.Cache.GetPrefab(forcedWeapon); + if (humanoid != null && weapon != null) + { + humanoid.m_defaultItems = new[] { weapon }; + humanoid.m_randomWeapon = new GameObject[0]; + humanoid.m_randomSets = new Humanoid.ItemSet[0]; + Jotunn.Logger.LogInfo($"[Skeleton] {prefabName}: loadout forced to '{forcedWeapon}'."); + } + else + { + Jotunn.Logger.LogWarning($"[Skeleton] {prefabName}: could not force '{forcedWeapon}'; " + + "it will roll a random weapon like a wild one."); + } + } + + foreach (CharacterDrop drops in prefab.GetComponentsInChildren(true)) + { + if (drops != null) Object.DestroyImmediate(drops); + } + + RaisedThrall thrall = prefab.AddComponent(); + thrall.m_kind = kind; + thrall.m_commandingRace = RaceId; + 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_escortCount = escortCount; + + PrefabManager.Instance.AddPrefab(prefab); + } + + // ---------------------------------------------------------------- piece + + private static void RegisterPiece() + { + // BonePileSpawner is the skeleton's own crypt spawner - the right base rather than a + // repainted body pile, and it already has hit and destruction effects of its own. + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PieceName, "BonePileSpawner"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Skeleton] Could not clone BonePileSpawner; the bone pile is not registered."); + return; + } + + // Its whole vanilla job is throwing hostile skeletons at whoever walks past. All of it goes. + foreach (SpawnArea area in prefab.GetComponentsInChildren(true)) + { + if (area != null) Object.DestroyImmediate(area); + } + + AswidBloodRefinery.StripOffensive(prefab, PieceName); + + SkeletonBonePileBehaviour behaviour = prefab.AddComponent(); + + foreach (Switch existing in prefab.GetComponentsInChildren(true)) + { + if (existing != null) Object.DestroyImmediate(existing); + } + behaviour.m_switch = prefab.AddComponent(); + behaviour.m_switch.m_name = PieceDisplayName; + + prefab.transform.localScale = Vector3.one * ModelScale; + Recolour(prefab, PileTint); + + Piece piece = prefab.GetComponent() ?? prefab.AddComponent(); + piece.m_craftingStation = null; + piece.m_resources = new Piece.Requirement[0]; + piece.m_name = PieceDisplayName; + piece.m_canBeRemoved = true; + piece.m_groundPiece = true; + piece.m_groundOnly = true; + piece.m_icon = BorrowIcon("TrophySkeleton"); + + // A Piece added to world scenery is born with no icon and no place effect - the Furling's + // bushes taught this the hard way, where the entry existed as a blank unclickable square. + 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 = PieceDisplayName, + Description = "Twenty fragments buy a place in the line. The one who fills it will keep standing up.", + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Crafting, + Icon = BorrowIcon("TrophySkeleton"), + Requirements = new[] + { + new RequirementConfig(SkullName, 1, 0, true), + new RequirementConfig("BoneFragments", 30, 0, true), + new RequirementConfig("Ooze", 10, 0, true), + } + })); + } + + public static void EnsureKnown(Player player) + { + if (player == null) return; + + GameObject prefab = PrefabManager.Instance.GetPrefab(PieceName); + 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(); + } + + // ---------------------------------------------------------------- helpers + + 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; + if (icons != null && icons.Length > 0 && icons[0] != null) return icons[0]; + + Jotunn.Logger.LogWarning($"[Skeleton] Could not borrow the icon from '{prefabName}'."); + return null; + } + + private static void Recolour(GameObject root, Color tint) + { + foreach (Renderer renderer in root.GetComponentsInChildren(true)) + { + if (renderer == null || renderer is ParticleSystemRenderer) continue; + + foreach (Material material in renderer.materials) + { + if (material == null) continue; + material.color = tint; + if (material.HasProperty("_Color")) material.SetColor("_Color", tint); + } + } + } + } + + [HarmonyPatch(typeof(Player), "OnSpawned")] + public static class SkeletonBonePileKnownPatch + { + public static void Postfix(Player __instance) + { + if (__instance != Player.m_localPlayer) return; + SkeletonBonePile.EnsureKnown(__instance); + SkeletonSentry.EnsureKnown(__instance); + } + } +} diff --git a/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs b/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs new file mode 100644 index 0000000..83c6046 --- /dev/null +++ b/JotunnModStub/Skeleton/SkeletonBonePileBehaviour.cs @@ -0,0 +1,403 @@ +using System; +using System.Collections.Generic; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The bone pile's logic. Simpler than the body pile's, because there is no reserve to keep books + /// on: the ZDO holds how many SLOTS have been paid for per kind, and a slot with nobody standing + /// in it refills itself on a timer, forever. + /// + /// That is the whole "skeletons are immortal" mechanic, and it is why nothing here drops or + /// consumes bones on death. Twenty fragments buy a place in the line once; whoever is standing in + /// that place gets back up as often as they are knocked down. No death hook, no drop table, no + /// resource created or destroyed. + /// + /// The roster is counted from the world rather than tallied, exactly like the body pile's, so a + /// death, a despawn or a player killing his own skeleton all correct themselves. + /// + public class SkeletonBonePileBehaviour : MonoBehaviour + { + public Switch m_switch; + + private const string KeyBones = "RoV_skelBones"; + private const string KeySlotsMelee = "RoV_skelSlotsMelee"; + private const string KeySlotsRanged = "RoV_skelSlotsRanged"; + private const string KeySlotsRancid = "RoV_skelSlotsRancid"; + private const string KeyUpgraded = "RoV_skelUpgraded"; + + private ZNetView m_nview; + private float m_respawnTimer; + + private void Awake() + { + // The registry RaisedThrall consults to answer "is my pile still standing?". + RaisedThrall.RegisterStation(transform); + + m_nview = GetComponent(); + if (m_nview == null || m_nview.GetZDO() == null) return; + + if (m_switch != null) + { + m_switch.m_onUse = OnUse; + m_switch.m_onHover = Hover; + } + + m_nview.Register("RoV_SkelFeed", RPC_Feed); + m_nview.Register("RoV_SkelUpgrade", RPC_Upgrade); + + WearNTear wear = GetComponent(); + if (wear != null) wear.m_onDestroyed = (Action)Delegate.Combine(wear.m_onDestroyed, new Action(OnDestroyed)); + + InvokeRepeating("UpdatePile", 2f, 2f); + } + + private void OnDestroy() + { + RaisedThrall.UnregisterStation(transform); + } + + // ---------------------------------------------------------------- interaction + + /// + /// Bones in hand feed it, a Greater Cursed Skull upgrades it, a Rancid trophy buys an officer - + /// and EMPTY HANDS move the whole garrison. That last one is the mechanic the Draugh does not + /// have: a body pile is commanded draugr by draugr, a bone pile is commanded as a line. + /// + /// 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. + /// + private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + Player player = user as Player; + if (player == null) return false; + + Inventory inventory = player.GetInventory(); + if (inventory == null) return false; + + // EMPTY HANDS MEAN THE COMMAND, always, and nothing else is consulted. + // + // This used to scan the pack for something to feed first, copied from the body pile where + // empty hands mean nothing else. Two bugs came out of it: a Rancid trophy in the pack was + // skipped in SILENCE when the pile was not upgraded yet - the refusal that explains why was + // only reachable by holding the item - and, worse, anyone carrying bone fragments (which is + // everyone) would feed the pile when they meant to move the line. The hover has always said + // "bone in hand to buy a place, empty hands to move the line"; now the code agrees with it. + if (item == null) return ToggleGarrison(player); + + string prefabName = item.m_dropPrefab != null ? item.m_dropPrefab.name : null; + if (prefabName == null) return false; + + if (prefabName == SkeletonBonePile.GreaterSkullName) return TryUpgrade(player, inventory, item); + + // How many of this the pile can still take. Not "is there room for one" - that was the bug: + // the old check only asked whether a single trophy would fit and then handed over the WHOLE + // stack, so ten Rancid trophies went in, RPC_Feed clamped the slots to two, and eight were + // destroyed for nothing. Anything taken from the player has to be something the pile will + // actually keep. + int room; + if (prefabName == SkeletonBonePile.RancidTrophy) + { + if (!IsUpgraded()) + { + player.Message(MessageHud.MessageType.Center, "This pile cannot hold the rotten yet."); + return false; + } + room = RancidCap() - GetSlots(SkeletonBonePile.KindRancid); + } + else if (prefabName == SkeletonBonePile.BonePrefab) + { + // Bone is measured in fragments, not places: what is left to buy, minus what is already + // part-paid towards the next place. + room = (TotalCap() - PaidSlots()) * SkeletonBonePile.BonesPerSlot + - m_nview.GetZDO().GetInt(KeyBones); + } + else + { + player.Message(MessageHud.MessageType.Center, "$msg_wontwork"); + return false; + } + + if (room <= 0) + { + player.Message(MessageHud.MessageType.Center, "$msg_itsfull"); + return false; + } + + int taken = Mathf.Min(Mathf.Max(1, item.m_stack), room); + player.Message(MessageHud.MessageType.Center, $"$msg_added {item.m_shared.m_name} x{taken}"); + inventory.RemoveItem(item, taken); + + m_nview.InvokeRPC("RoV_SkelFeed", prefabName, taken); + return true; + } + + /// + /// The new command: every skeleton of this pile follows, or every one of them comes home. One + /// click for the line, decided by whether any of them is already out. + /// + private bool ToggleGarrison(Player player) + { + List bound = RaisedThrall.BoundTo(transform.position); + if (bound.Count == 0) + { + player.Message(MessageHud.MessageType.Center, "Nothing is standing yet. It wants bone."); + return false; + } + + bool anyFollowing = false; + foreach (RaisedThrall thrall in bound) + { + if (thrall.IsFollowing(player)) { anyFollowing = true; break; } + } + + int moved = 0; + foreach (RaisedThrall thrall in bound) + { + // announce: false - one message for the line, not one per skeleton. + if (thrall.SetFollowing(player, !anyFollowing, announce: false)) moved++; + } + + 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."); + return false; + } + + player.Message(MessageHud.MessageType.Center, anyFollowing + ? $"{moved} return to the pile." + : $"{moved} rise and follow."); + return true; + } + + private bool TryUpgrade(Player player, Inventory inventory, ItemDrop.ItemData item) + { + if (IsUpgraded()) + { + player.Message(MessageHud.MessageType.Center, "It 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."); + 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."); + return true; + } + + // ---------------------------------------------------------------- accounting + + private void RPC_Feed(long sender, string prefabName, int count) + { + if (!m_nview.IsOwner()) return; + if (count < 1) count = 1; + + if (prefabName == SkeletonBonePile.RancidTrophy) + { + if (!IsUpgraded()) return; + SetSlots(SkeletonBonePile.KindRancid, + Mathf.Min(RancidCap(), GetSlots(SkeletonBonePile.KindRancid) + count)); + return; + } + + if (prefabName != SkeletonBonePile.BonePrefab) return; + + int bones = m_nview.GetZDO().GetInt(KeyBones) + count; + + // Melee places fill first, then the archers'. A loop rather than a single test so a whole + // stack cannot overflow into bones that are never counted. + while (bones >= SkeletonBonePile.BonesPerSlot && PaidSlots() < TotalCap()) + { + bones -= SkeletonBonePile.BonesPerSlot; + + if (GetSlots(SkeletonBonePile.KindMelee) < MeleeCap()) + { + SetSlots(SkeletonBonePile.KindMelee, GetSlots(SkeletonBonePile.KindMelee) + 1); + } + else + { + SetSlots(SkeletonBonePile.KindRanged, GetSlots(SkeletonBonePile.KindRanged) + 1); + } + } + + m_nview.GetZDO().Set(KeyBones, bones); + } + + private void RPC_Upgrade(long sender) + { + if (!m_nview.IsOwner()) return; + m_nview.GetZDO().Set(KeyUpgraded, true); + } + + private void UpdatePile() + { + if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return; + + string empty = FirstEmptyKind(); + if (empty == null) + { + m_respawnTimer = 0f; + return; + } + + m_respawnTimer += 2f; // the tick interval + if (m_respawnTimer < RespawnSeconds()) return; + m_respawnTimer = 0f; + + Spawn(empty); + } + + /// A kind that has a paid slot with nobody standing in it, or null. Rotten first - + /// they are the scarcest and the reason to upgrade. + private string FirstEmptyKind() + { + Dictionary alive = CountAlive(); + + if (alive[SkeletonBonePile.KindRancid] < GetSlots(SkeletonBonePile.KindRancid)) return SkeletonBonePile.KindRancid; + if (alive[SkeletonBonePile.KindMelee] < GetSlots(SkeletonBonePile.KindMelee)) return SkeletonBonePile.KindMelee; + if (alive[SkeletonBonePile.KindRanged] < GetSlots(SkeletonBonePile.KindRanged)) return SkeletonBonePile.KindRanged; + return null; + } + + private Dictionary CountAlive() + { + Dictionary alive = new Dictionary + { + { SkeletonBonePile.KindMelee, 0 }, + { SkeletonBonePile.KindRanged, 0 }, + { SkeletonBonePile.KindRancid, 0 }, + }; + + foreach (RaisedThrall thrall in RaisedThrall.BoundTo(transform.position)) + { + if (thrall.Kind != null && alive.ContainsKey(thrall.Kind)) alive[thrall.Kind]++; + } + return alive; + } + + private void Spawn(string kind) + { + string prefabName = + kind == SkeletonBonePile.KindRancid ? SkeletonBonePile.ThrallRancidName : + kind == SkeletonBonePile.KindRanged ? SkeletonBonePile.ThrallRangedName : + SkeletonBonePile.ThrallMeleeName; + + GameObject prefab = ZNetScene.instance != null ? ZNetScene.instance.GetPrefab(prefabName) : null; + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] No '{prefabName}' in ZNetScene; the pile cannot raise anything."); + return; + } + + Vector3 offset = UnityEngine.Random.insideUnitSphere * 2f; + offset.y = 0f; + Vector3 position = transform.position + offset + Vector3.up * 0.5f; + + GameObject spawned = Instantiate(prefab, position, Quaternion.Euler(0f, UnityEngine.Random.Range(0, 360), 0f)); + RaisedThrall thrall = spawned.GetComponent(); + if (thrall != null) thrall.Bind(transform.position); + } + + /// + /// Instantly, unlike the body pile's minute. The garrison rebuilds itself for free forever, so + /// the pile being broken has to be an immediate off switch or there is no counterweight at all. + /// MarkOrphaned still covers any that were unloaded when it fell - with a wither of zero they + /// die on their first tick home rather than lingering. + /// + private void OnDestroyed() + { + if (m_nview == null || !m_nview.IsOwner()) return; + + List bound = RaisedThrall.BoundTo(transform.position); + foreach (RaisedThrall thrall in bound) + { + thrall.MarkOrphaned(); + thrall.Kill(); + } + + 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."); + } + } + + // ---------------------------------------------------------------- state and display + + public bool IsUpgraded() => m_nview != null && m_nview.IsValid() && m_nview.GetZDO().GetBool(KeyUpgraded, false); + + private int MeleeCap() => IsUpgraded() ? SkeletonBonePile.MeleeSlotsUpgraded : SkeletonBonePile.MeleeSlots; + + private int RangedCap() => IsUpgraded() ? SkeletonBonePile.RangedSlotsUpgraded : SkeletonBonePile.RangedSlots; + + private int RancidCap() => IsUpgraded() ? SkeletonBonePile.RancidSlotsUpgraded : SkeletonBonePile.RancidSlots; + + private float RespawnSeconds() => + IsUpgraded() ? SkeletonBonePile.RespawnSecondsUpgraded : SkeletonBonePile.RespawnSeconds; + + /// Paid melee and archer places. Rotten ones are bought with trophies, not bone, so + /// they are counted separately and do not compete for the same twenty fragments. + private int PaidSlots() => GetSlots(SkeletonBonePile.KindMelee) + GetSlots(SkeletonBonePile.KindRanged); + + private int TotalCap() => MeleeCap() + RangedCap(); + + private string Hover() + { + Dictionary alive = CountAlive(); + + // A line per kind, each reading "standing / places bought / places possible", because the + // first version told the player none of that: the rotten line was hidden until the pile was + // 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()}"; + + if (!IsUpgraded()) body += " (needs a 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"; + + if (m_respawnTimer > 0f) + { + int left = Mathf.Max(1, Mathf.CeilToInt(RespawnSeconds() - m_respawnTimer)); + body += $"\nnext rises in {left}s"; + } + + body += "\n[$KEY_Use] Bone in hand to buy a place, empty hands to move the line"; + + return Localization.instance.Localize($"{SkeletonBonePile.PieceDisplayName} ({body})"); + } + + // ---------------------------------------------------------------- ZDO accessors + + private int GetSlots(string kind) + { + if (m_nview == null || !m_nview.IsValid()) return 0; + return m_nview.GetZDO().GetInt(KeyFor(kind)); + } + + private void SetSlots(string kind, int value) + { + if (m_nview != null && m_nview.IsValid()) m_nview.GetZDO().Set(KeyFor(kind), Mathf.Max(0, value)); + } + + private static string KeyFor(string kind) + { + if (kind == SkeletonBonePile.KindRanged) return KeySlotsRanged; + if (kind == SkeletonBonePile.KindRancid) return KeySlotsRancid; + return KeySlotsMelee; + } + } +} diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index 1fee96c..10a6ce5 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -84,7 +84,9 @@ namespace RacesOfValheim __result = false; return false; } - else if (AswidRace.IsAswid() && !AswidRace.BypassAswidFoodCheck && 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)) + // Blood Essence is the one real food an Aswid can still chew, so it has to + // 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."); __result = false; diff --git a/JotunnModStub/Skeleton/SkeletonRace.cs b/JotunnModStub/Skeleton/SkeletonRace.cs index fa1b74f..b894318 100644 --- a/JotunnModStub/Skeleton/SkeletonRace.cs +++ b/JotunnModStub/Skeleton/SkeletonRace.cs @@ -17,6 +17,11 @@ namespace RacesOfValheim public void CreateModAssets() { + // The bone pile and its garrison. Registered here because the faction merchant catalogue + // resolves its entries by prefab name, so the two cursed skulls have to exist before a + // Skeleton is ever set up as a bench. + SkeletonBonePile.Register(); + var se = ScriptableObject.CreateInstance(); se.name = "SE_SkeletonStats"; se.m_name = "Undead Fortitude"; diff --git a/JotunnModStub/Skeleton/SkeletonSentry.cs b/JotunnModStub/Skeleton/SkeletonSentry.cs new file mode 100644 index 0000000..ef37404 --- /dev/null +++ b/JotunnModStub/Skeleton/SkeletonSentry.cs @@ -0,0 +1,283 @@ +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// A bound archer that cannot walk: built with the hammer, stands where it is put, shoots what comes + /// near, knits itself back together when left alone, and hands its parts back when it falls. + /// + /// TWO PREFABS, and that is forced rather than chosen. The design settled on cloning the tamed + /// archer, so the sentry is a CHARACTER - and a Character cannot sit in the hammer's piece table, + /// because the hammer builds Piece. So a small seed piece goes in the table, spawns the sentry the + /// moment it is placed, and removes itself. The alternative was cloning the Ballista, which would + /// have brought WearNTear's health, repair and component refund for free; cloning the archer instead + /// means those are written here, which is the trade that was made deliberately. + /// + /// The refund is a CharacterDrop at full chance - which makes the sentry the one skeleton in this mod + /// that drops anything. Every other thrall has its drop table stripped precisely so a garrison that + /// regenerates for free cannot be farmed; this one is not free and does not regenerate its slot, so + /// giving the parts back is safe and is what was asked for. + /// + public static class SkeletonSentry + { + public const string SentryName = "SkeletonSentry"; + public const string SeedPieceName = "SkeletonSentrySeed"; + public const string DisplayName = "Bound Sentry"; + + /// Seconds without being hit before it starts closing its wounds. + public const float RegenDelay = 10f; + + /// Fraction of maximum health per second once it starts. + public const float RegenPerSecond = 0.02f; + + // What it costs, and therefore exactly what it gives back. + public const int BoneCost = 10; + + public static void Register() + { + GameObject sentry = BuildSentry(); + if (sentry != null) BuildSeedPiece(); + } + + // ---------------------------------------------------------------- the sentry + + private static GameObject BuildSentry() + { + // The archer we already register for the bone pile, so its forced bow loadout comes along. + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(SentryName, SkeletonBonePile.ThrallRangedName); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] Could not clone {SkeletonBonePile.ThrallRangedName}; the sentry is not registered."); + return null; + } + + Character character = prefab.GetComponent(); + if (character != null) + { + character.m_name = DisplayName; + + // Rooted. Every way it could move, set to nothing - and m_randomMoveRange so it does not + // even try to wander. If the AI still shuffles or stops shooting because it wants to + // close distance and cannot, the fallback is to pin it from the AI side instead, with + // the patrol trick the thralls and the grove already use. + character.m_speed = 0f; + character.m_walkSpeed = 0f; + character.m_runSpeed = 0f; + character.m_acceleration = 0f; + character.m_jumpForce = 0f; + } + + BaseAI ai = prefab.GetComponent(); + if (ai != null) ai.m_randomMoveRange = 0f; + + // Its parts back, all of them, every time. Replaces the stripped table the archer clone + // inherits rather than adding to it. + foreach (CharacterDrop existing in prefab.GetComponentsInChildren(true)) + { + if (existing != null) Object.DestroyImmediate(existing); + } + + CharacterDrop drops = prefab.AddComponent(); + drops.m_drops = new System.Collections.Generic.List(); + AddDrop(drops, SkeletonBonePile.SoulStoneName, 1); + AddDrop(drops, "TrophySkeleton", 1); + AddDrop(drops, SkeletonBonePile.BonePrefab, BoneCost); + + prefab.AddComponent(); + + PrefabManager.Instance.AddPrefab(prefab); + return prefab; + } + + private static void AddDrop(CharacterDrop drops, string prefabName, int amount) + { + GameObject prefab = PrefabManager.Cache.GetPrefab(prefabName); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] Sentry: no '{prefabName}' to give back; that part is lost on death."); + return; + } + + drops.m_drops.Add(new CharacterDrop.Drop + { + m_prefab = prefab, + m_amountMin = amount, + m_amountMax = amount, + m_chance = 1f, + m_levelMultiplier = false, + m_dontScale = true, // the refund is the cost, not a loot roll + m_onePerPlayer = false, + }); + } + + // ---------------------------------------------------------------- the seed + + /// + /// The hammer entry. Exists only to be placed and immediately replaced by the sentry, which is + /// how a creature gets into a piece table at all. + /// + private static void BuildSeedPiece() + { + // An armour stand, because the seed's real job is its BUILD GHOST: the sentry itself only + // exists a frame later, so what the player aims at while placing is this prefab's silhouette. + // A workbench read as furniture; a standing human frame reads as "someone will be here", which + // is what is about to happen. ArmorStand is the buildable one, so it arrives with the Piece, + // ZNetView and WearNTear the strip below keeps. + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(SeedPieceName, "ArmorStand"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Skeleton] Could not clone ArmorStand; the sentry cannot be built."); + return; + } + + // Everything the stand actually DOES goes - its armour slots included. All that is wanted is a + // placeable shell with the right outline, alive for one frame. + 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.AddComponent(); + + 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 = BorrowIcon("TrophySkeleton"); + + 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.", + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Crafting, + Icon = BorrowIcon("TrophySkeleton"), + Requirements = new[] + { + new RequirementConfig(SkeletonBonePile.SoulStoneName, 1, 0, true), + new RequirementConfig("TrophySkeleton", 1, 0, true), + new RequirementConfig(SkeletonBonePile.BonePrefab, BoneCost, 0, true), + } + })); + } + + public static void EnsureKnown(Player player) + { + if (player == null) return; + + GameObject prefab = PrefabManager.Instance.GetPrefab(SeedPieceName); + 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(); + } + + 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; + if (icons != null && icons.Length > 0 && icons[0] != null) return icons[0]; + return null; + } + } + + /// + /// Lives for one frame: swaps itself for the sentry and goes. Owner only, so in multiplayer exactly + /// one archer stands up rather than one per client. + /// + public class SkeletonSentrySeed : MonoBehaviour + { + private void Start() + { + ZNetView nview = GetComponent(); + if (nview == null || !nview.IsValid() || !nview.IsOwner()) return; + + GameObject prefab = ZNetScene.instance != null + ? ZNetScene.instance.GetPrefab(SkeletonSentry.SentryName) + : null; + + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Skeleton] No '{SkeletonSentry.SentryName}' in ZNetScene; nothing was raised."); + return; + } + + GameObject spawned = Instantiate(prefab, transform.position, transform.rotation); + + // Tamed, so it never turns on the person who built it. The bone pile's thralls get this from + // RaisedThrall.Bind; a sentry has no pile to be bound to, so it is done here. + MonsterAI ai = spawned.GetComponent(); + if (ai != null) ai.MakeTame(); + Character character = spawned.GetComponent(); + if (character != null) character.SetTamed(true); + + ZNetScene.instance.Destroy(gameObject); + } + } + + /// + /// The regeneration: untouched for ten seconds, then two percent of maximum health a second until + /// whole. The clock is local rather than world time on purpose - a sentry nobody is near is a sentry + /// in an unloaded zone, and healing through that would mean coming home to a full-health guard that + /// was left at death's door. + /// + public class SkeletonSentryBehaviour : MonoBehaviour + { + private Character m_character; + private ZNetView m_nview; + private float m_sinceDamage; + + private void Awake() + { + m_character = GetComponent(); + m_nview = GetComponent(); + InvokeRepeating("TickRegen", 1f, 1f); + } + + /// Called from the Character.Damage postfix below. + public void NoteDamage() => m_sinceDamage = 0f; + + private void TickRegen() + { + if (m_character == null || m_character.IsDead()) return; + if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return; + + m_sinceDamage += 1f; + if (m_sinceDamage < SkeletonSentry.RegenDelay) return; + + float max = m_character.GetMaxHealth(); + if (m_character.GetHealth() >= max) return; + + m_character.Heal(max * SkeletonSentry.RegenPerSecond, false); + } + } + + /// + /// Resets a sentry's regeneration clock whenever it is hit. A postfix on the same method the Trenta's + /// Thorns already patches, so the shape is known to work. + /// + [HarmonyPatch(typeof(Character), "Damage")] + public static class SkeletonSentryDamagePatch + { + public static void Postfix(Character __instance) + { + if (__instance == null) return; + + SkeletonSentryBehaviour sentry = __instance.GetComponent(); + if (sentry != null) sentry.NoteDamage(); + } + } +} From 1a741978bfea915e35c9767b14a6e576e69c19fa Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 7 Aug 2026 17:02:47 +0200 Subject: [PATCH 010/311] feat(trenta): composter and heartwood grove Co-Authored-By: Claude Opus 5 --- JotunnModStub/Trenta/ComposterBehaviour.cs | 279 +++++++++++ JotunnModStub/Trenta/GroveBehaviour.cs | 373 ++++++++++++++ JotunnModStub/Trenta/TrentaComposter.cs | 488 +++++++++++++++++++ JotunnModStub/Trenta/TrentaConfig.cs | 157 +++++- JotunnModStub/Trenta/TrentaHeartwoodGrove.cs | 237 +++++++++ JotunnModStub/Trenta/TrentaHornetsNest.cs | 137 +++++- JotunnModStub/Trenta/TrentaRace.cs | 7 + 7 files changed, 1659 insertions(+), 19 deletions(-) create mode 100644 JotunnModStub/Trenta/ComposterBehaviour.cs create mode 100644 JotunnModStub/Trenta/GroveBehaviour.cs create mode 100644 JotunnModStub/Trenta/TrentaComposter.cs create mode 100644 JotunnModStub/Trenta/TrentaHeartwoodGrove.cs diff --git a/JotunnModStub/Trenta/ComposterBehaviour.cs b/JotunnModStub/Trenta/ComposterBehaviour.cs new file mode 100644 index 0000000..f59dbe8 --- /dev/null +++ b/JotunnModStub/Trenta/ComposterBehaviour.cs @@ -0,0 +1,279 @@ +using System; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Composter's logic. Modelled on - same one-second tick, same + /// owner-only accounting with all state in the ZDO - but with a numeric tank filled by many + /// different meats in place of the barrel's single stored item. + /// + /// Three states, and the barrel already has a visual for each of them: filling, composting, + /// ready. Raw flesh is destroyed on the spot and becomes mass; at capacity the lid closes and + /// the clock starts; when it runs out the tap gives a batch of Fertilizer and the cycle resets. + /// + /// One simplification over worth pointing out: the refinery + /// has to carry a time accumulator because it produces continuously and must catch up on every + /// second it spent unloaded. This works in batches, so the whole timer is one stored timestamp + /// compared against ZNet's world clock - which gets "keeps composting while the zone is + /// unloaded and the game is shut" for free rather than by bookkeeping. + /// + public class ComposterBehaviour : MonoBehaviour + { + // Handed over from the vanilla Fermenter before it is destroyed, which is what keeps the + // three visual states, the sounds and the tap effects identical to the real barrel's. The + // Switch is ours - see the comment in TrentaComposter.RegisterPiece for why. + public Switch m_switch; + public GameObject m_topObject; + public GameObject m_fermentingObject; + public GameObject m_readyObject; + public Transform m_outputPoint; + public EffectList m_addedEffects; + public EffectList m_tapEffects; + public EffectList m_spawnEffects; + + public float m_capacity = 100f; + public float m_compostSeconds = 2400f; + public int m_yield = 20; + + private const string KeyFlesh = "RoV_compostFlesh"; + private const string KeySealed = "RoV_compostSealed"; + + private ZNetView m_nview; + + public enum State + { + Filling, + Composting, + Ready, + } + + private void Awake() + { + m_nview = GetComponent(); + if (m_nview == null) m_nview = GetComponentInParent(); + if (m_nview == null || m_nview.GetZDO() == null) return; + + if (m_switch != null) + { + m_switch.m_onUse = OnUse; + m_switch.m_onHover = Hover; + } + + m_nview.Register("RoV_CompostAdd", RPC_Add); + m_nview.Register("RoV_CompostTap", RPC_Tap); + + WearNTear wear = GetComponent(); + if (wear == null) wear = GetComponentInParent(); + if (wear != null) wear.m_onDestroyed = (Action)Delegate.Combine(wear.m_onDestroyed, new Action(OnDestroyed)); + + InvokeRepeating("UpdateComposter", 1f, 1f); + } + + // ---------------------------------------------------------------- interaction + + /// + /// One interaction point, exactly like the vanilla barrel: the item in hand decides what the + /// click means. Holding flesh feeds it; empty hands tap it when it is ready and otherwise + /// just report what it is doing. + /// + private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + if (user == null) return false; + + State state = GetState(); + + if (state == State.Ready) + { + m_nview.InvokeRPC("RoV_CompostTap"); + return true; + } + + if (state == State.Composting) + { + user.Message(MessageHud.MessageType.Center, $"Still rotting. {MinutesLeft()} minutes."); + return false; + } + + Inventory inventory = user.GetInventory(); + if (inventory == null) return false; + + if (item == null) item = FindFlesh(inventory); + if (item == null) + { + user.Message(MessageHud.MessageType.Center, "No raw flesh to rot."); + return false; + } + + string prefabName = item.m_dropPrefab != null ? item.m_dropPrefab.name : null; + if (AswidBloodRefinery.FleshValue(prefabName) <= 0) + { + user.Message(MessageHud.MessageType.Center, "$msg_wontwork"); + return false; + } + + user.Message(MessageHud.MessageType.Center, "$msg_added " + item.m_shared.m_name); + inventory.RemoveItem(item, 1); + m_nview.InvokeRPC("RoV_CompostAdd", prefabName); + return true; + } + + private ItemDrop.ItemData FindFlesh(Inventory inventory) + { + foreach (ItemDrop.ItemData candidate in inventory.GetAllItems()) + { + if (candidate == null || candidate.m_dropPrefab == null) continue; + if (AswidBloodRefinery.FleshValue(candidate.m_dropPrefab.name) > 0) return candidate; + } + return null; + } + + private void RPC_Add(long sender, string prefabName) + { + if (!m_nview.IsOwner()) return; + if (GetState() != State.Filling) return; + + int value = AswidBloodRefinery.FleshValue(prefabName); + if (value <= 0) return; + + float flesh = Mathf.Min(m_capacity, GetFlesh() + value); + SetFlesh(flesh); + + // Reaching capacity is what starts the clock. Stamped once, here, so a barrel that fills + // up while nobody is watching still seals at the right moment. + if (flesh >= m_capacity) m_nview.GetZDO().Set(KeySealed, ZNet.instance.GetTime().Ticks); + + if (m_addedEffects != null) m_addedEffects.Create(transform.position, transform.rotation); + } + + private void RPC_Tap(long sender) + { + if (!m_nview.IsOwner()) return; + if (GetState() != State.Ready) return; + + SetFlesh(0f); + m_nview.GetZDO().Set(KeySealed, 0L); + Produce(); + } + + private void Produce() + { + GameObject prefab = ObjectDB.instance != null + ? ObjectDB.instance.GetItemPrefab(TrentaConfig.FertilizerName) + : null; + if (prefab == null || m_outputPoint == null) return; + + if (m_tapEffects != null) m_tapEffects.Create(transform.position, transform.rotation); + if (m_spawnEffects != null) m_spawnEffects.Create(m_outputPoint.position, m_outputPoint.rotation); + + // One stack rather than twenty objects on the ground: Fertilizer stacks to 50, so the + // whole batch fits, the same way Smelter.m_spawnStack gathers its output. + GameObject spawned = Instantiate(prefab, m_outputPoint.position, m_outputPoint.rotation); + ItemDrop drop = spawned.GetComponent(); + if (drop != null) + { + drop.m_itemData.m_stack = m_yield; + ItemDrop.OnCreateNew(drop); + } + } + + /// + /// A finished batch is given back; flesh that has already rotted is not. Same rule the Blood + /// Refinery follows for blood, and for the same reason - what the machine has absorbed is + /// gone by design, and the hover text says so before anyone swings a hammer at it. + /// + private void OnDestroyed() + { + if (m_nview == null || !m_nview.IsOwner()) return; + + bool ready = GetState() == State.Ready; + SetFlesh(0f); + m_nview.GetZDO().Set(KeySealed, 0L); + if (!ready) return; + + GameObject prefab = ObjectDB.instance != null + ? ObjectDB.instance.GetItemPrefab(TrentaConfig.FertilizerName) + : null; + if (prefab == null) return; + + Vector3 position = transform.position + Vector3.up * 0.5f; + GameObject spawned = Instantiate(prefab, position, Quaternion.Euler(0f, UnityEngine.Random.Range(0, 360), 0f)); + ItemDrop drop = spawned.GetComponent(); + if (drop != null) + { + drop.m_itemData.m_stack = m_yield; + ItemDrop.OnCreateNew(drop); + } + } + + // ---------------------------------------------------------------- state and display + + public State GetState() + { + if (GetFlesh() < m_capacity) return State.Filling; + return SecondsSealed() >= m_compostSeconds ? State.Ready : State.Composting; + } + + private void UpdateComposter() + { + if (m_nview == null || !m_nview.IsValid()) return; + + State state = GetState(); + if (m_topObject != null) m_topObject.SetActive(state == State.Filling); + if (m_fermentingObject != null) m_fermentingObject.SetActive(state == State.Composting); + if (m_readyObject != null) m_readyObject.SetActive(state == State.Ready); + } + + private int MinutesLeft() + { + double left = m_compostSeconds - SecondsSealed(); + return Mathf.Max(1, Mathf.CeilToInt((float)left / 60f)); + } + + private string Hover() + { + string body; + switch (GetState()) + { + case State.Ready: + body = $"ready: {m_yield} {TrentaConfig.FertilizerDisplayName}\n" + + "[$KEY_Use] Empty it"; + break; + + case State.Composting: + body = $"rotting, {MinutesLeft()} minutes left"; + break; + + default: + body = $"flesh {Mathf.Floor(GetFlesh())}/{m_capacity}\n" + + "[$KEY_Use] Feed it raw flesh"; + break; + } + + return Localization.instance.Localize($"{TrentaConfig.ComposterDisplayName} ({body})"); + } + + // ---------------------------------------------------------------- ZDO accessors + + /// + /// Seconds since the barrel sealed itself, on ZNet's world clock rather than on frames - so + /// it keeps counting while the zone is unloaded and across a restart. 0 while still filling. + /// + private double SecondsSealed() + { + if (m_nview == null || !m_nview.IsValid() || ZNet.instance == null) return 0.0; + + long ticks = m_nview.GetZDO().GetLong(KeySealed, 0L); + if (ticks == 0L) return 0.0; + + return (ZNet.instance.GetTime() - new DateTime(ticks)).TotalSeconds; + } + + private float GetFlesh() => m_nview != null && m_nview.IsValid() ? m_nview.GetZDO().GetFloat(KeyFlesh) : 0f; + + private void SetFlesh(float value) + { + if (m_nview != null && m_nview.IsValid()) m_nview.GetZDO().Set(KeyFlesh, Mathf.Max(0f, value)); + } + } +} diff --git a/JotunnModStub/Trenta/GroveBehaviour.cs b/JotunnModStub/Trenta/GroveBehaviour.cs new file mode 100644 index 0000000..39388e4 --- /dev/null +++ b/JotunnModStub/Trenta/GroveBehaviour.cs @@ -0,0 +1,373 @@ +using System; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Heartwood Grove's logic: three independent jobs on one timer. + /// + /// GROWING UP one timestamp on ZNet's world clock, exactly like the Composter's seal time, so + /// a planted grove keeps ageing with the zone unloaded and the game shut. The only + /// visible effect is which of the two models is showing. + /// FERTILISING once grown, one plant per minute inside the radius, one Fertilizer each, drawn + /// from a tank the player fills through the Switch on the trunk. Deliberately one + /// plant per tick and not the whole radius: a full tank is then twenty minutes of + /// autonomy instead of one tick's worth. + /// HONEY accrues into the Container on the root at the vanilla Beehive's own rate, read + /// off that prefab rather than invented. + /// + /// A tank that is empty stops the fertilising and nothing else. The bees do not care, and neither + /// does the honey - they are three jobs, not three stages. + /// + /// Everything that changes state runs on the ZNetView owner only, which is also why the swarm is + /// spawned there: bees on every client would mean every client's copy landing its own sting. + /// + public class GroveBehaviour : MonoBehaviour + { + public Switch m_switch; + public Container m_container; + public GameObject m_youngModel; + public GameObject m_grownModel; + + private const string KeyPlanted = "RoV_grovePlanted"; + private const string KeyFertilizer = "RoV_groveFert"; + private const string KeyHoneyTime = "RoV_groveHoneyTime"; + + // Container.Save is private, so it is reached the same way AswidBloodPotions reaches + // Fermenter.GetContent. Honey added by us has to be written to the ZDO explicitly: a player + // dropping items in goes through the inventory's own change callback, and nothing guarantees + // that callback covers a write made from outside the container's own UI. + private static readonly System.Reflection.MethodInfo ContainerSaveMethod = + HarmonyLib.AccessTools.Method(typeof(Container), "Save"); + + private ZNetView m_nview; + private GameObject m_bees; + + // Read off the vanilla Beehive at Awake, so the grove uses the game's own honey rate. Only + // the capacity is scaled - a tree of bees has to last while the player is away. + private float m_secPerHoney = 1200f; + private int m_honeyCapacity = 20; + private GameObject m_honeyPrefab; + + // The fertilise tick is local time, not world time, and that is correct rather than lazy: an + // unloaded grove cannot grow plants in a zone that is not there, so banking the time it spent + // unloaded would hand back growth that never could have happened. Honey banks; growth does not. + private float m_fertilizeTimer; + + private void Awake() + { + m_nview = GetComponent(); + if (m_nview == null || m_nview.GetZDO() == null) return; + + if (m_switch != null) + { + m_switch.m_onUse = OnUse; + m_switch.m_onHover = Hover; + } + + m_nview.Register("RoV_GroveFeed", RPC_Feed); + + ReadHoneyRates(); + + if (m_nview.IsOwner()) + { + // Stamped once, on the first client to own it, which is the moment it was planted. + if (m_nview.GetZDO().GetLong(KeyPlanted, 0L) == 0L) + { + m_nview.GetZDO().Set(KeyPlanted, ZNet.instance.GetTime().Ticks); + } + if (m_nview.GetZDO().GetLong(KeyHoneyTime, 0L) == 0L) + { + m_nview.GetZDO().Set(KeyHoneyTime, ZNet.instance.GetTime().Ticks); + } + } + + InvokeRepeating("UpdateGrove", 1f, 1f); + } + + private void OnDestroy() + { + if (m_bees != null) Destroy(m_bees); + } + + /// + /// Borrows m_secPerUnit, m_maxHoney and the honey item off the vanilla Beehive. The rate is + /// not a design decision this mod gets to make - a hive's is already tuned - so only the + /// capacity is multiplied. + /// + private void ReadHoneyRates() + { + Beehive hive = TrentaConfig.FindVanillaBeehive(); + + if (hive != null) + { + if (hive.m_secPerUnit > 0f) m_secPerHoney = hive.m_secPerUnit; + if (hive.m_maxHoney > 0) m_honeyCapacity = hive.m_maxHoney * TrentaConfig.GroveHoneyCapacityFactor; + if (hive.m_honeyItem != null) m_honeyPrefab = hive.m_honeyItem.gameObject; + } + else + { + Jotunn.Logger.LogWarning("[Trenta] Heartwood Grove: no vanilla beehive; falling back to default honey rates."); + } + + if (m_honeyPrefab == null && ObjectDB.instance != null) + { + m_honeyPrefab = ObjectDB.instance.GetItemPrefab("Honey"); + } + + // Without this the honey half fails silently, which is exactly how the night-gate bug + // managed to hide: nothing appeared and nothing said why. The log line also settles a + // question the design doc left open - whether the tuned Beehive component lives on + // "Beehive" or on "piece_beehive" - by printing what was actually read. + if (m_honeyPrefab == null) + { + Jotunn.Logger.LogWarning("[Trenta] Heartwood Grove: no honey prefab found; this grove will never produce honey."); + return; + } + + Jotunn.Logger.LogInfo($"[Trenta] Heartwood Grove: honey every {m_secPerHoney:0}s, capacity {m_honeyCapacity} " + + $"(rates {(hive != null ? "read from the vanilla beehive" : "defaulted")})."); + } + + // ---------------------------------------------------------------- the loop + + private void UpdateGrove() + { + if (m_nview == null || !m_nview.IsValid()) return; + + bool grown = IsGrown(); + if (m_youngModel != null) m_youngModel.SetActive(!grown); + if (m_grownModel != null) m_grownModel.SetActive(grown); + + if (!m_nview.IsOwner()) return; + + if (!grown) return; + + EnsureBees(); + TickHoney(); + + m_fertilizeTimer += 1f; + if (m_fertilizeTimer >= TrentaConfig.GroveFertilizeInterval) + { + m_fertilizeTimer = 0f; + TickFertilize(); + } + } + + private void EnsureBees() + { + if (m_bees != null) return; + m_bees = TrentaHornetSwarm.SpawnAtAnchor(transform, TrentaConfig.GroveStingRadius); + } + + /// + /// Grows exactly one thing per tick, through the very same method a player's Fertilizer click + /// goes through. That sharing is the point: two tiers growing plants by two slightly + /// different sets of rules is the failure this is written to prevent. + /// + private void TickFertilize() + { + if (GetFertilizer() <= 0) return; + + foreach (Collider collider in Physics.OverlapSphere(transform.position, TrentaConfig.GroveRadius)) + { + if (collider == null) continue; + + if (TrentaComposter.TryGrow(collider.gameObject) != TrentaComposter.GrowOutcome.Grown) continue; + + SetFertilizer(GetFertilizer() - 1); + return; // One per tick, by design + } + } + + private void TickHoney() + { + if (m_honeyPrefab == null || m_container == null) return; + + long stamp = m_nview.GetZDO().GetLong(KeyHoneyTime, 0L); + if (stamp == 0L) return; + + DateTime now = ZNet.instance.GetTime(); + + // No night gate. There used to be one, and it was what stopped the honey ever appearing - + // see the long note in TrentaConfig where GroveHoneyAtNight used to live. + double elapsed = (now - new DateTime(stamp)).TotalSeconds; + if (elapsed < m_secPerHoney) return; + + Inventory inventory = m_container.GetInventory(); + if (inventory == null) return; + + int produced = 0; + bool blocked = false; + while (elapsed >= m_secPerHoney) + { + if (CountHoney(inventory) >= m_honeyCapacity || !inventory.AddItem(m_honeyPrefab, 1)) + { + blocked = true; + break; + } + + elapsed -= m_secPerHoney; + produced++; + } + + if (blocked) + { + // Full chest: the clock is reset to now and the surplus is thrown away, so an + // untouched grove cannot bank an unbounded debt that dumps all at once the moment + // the player finally empties it. This is also what a vanilla hive does when it caps. + m_nview.GetZDO().Set(KeyHoneyTime, now.Ticks); + } + else + { + // Only the time actually spent on the honey produced is consumed. Resetting to now + // here instead would silently throw away the remainder on every single unit and + // leave the grove producing slower than the hive whose rate it borrowed. + m_nview.GetZDO().Set(KeyHoneyTime, now.AddSeconds(-elapsed).Ticks); + } + + if (produced > 0 && ContainerSaveMethod != null) ContainerSaveMethod.Invoke(m_container, null); + } + + private int CountHoney(Inventory inventory) + { + if (m_honeyPrefab == null) return 0; + + ItemDrop drop = m_honeyPrefab.GetComponent(); + string name = drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null + ? drop.m_itemData.m_shared.m_name + : null; + if (name == null) return 0; + + // Counted by hand rather than through Inventory.CountItems so no overload's quality and + // world-level arguments have to be guessed at. + int total = 0; + foreach (ItemDrop.ItemData item in inventory.GetAllItems()) + { + if (item != null && item.m_shared != null && item.m_shared.m_name == name) total += item.m_stack; + } + return total; + } + + // ---------------------------------------------------------------- interaction + + /// + /// E on the tree. Holding Fertilizer fills the tank; empty-handed it reports what the grove is + /// doing. Loading a tank before the tree has grown is allowed on purpose - there is no reason + /// to make the player come back twice. + /// + private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + if (user == null) return false; + + Inventory inventory = user.GetInventory(); + if (inventory == null) return false; + + 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."); + return false; + } + + if (!TrentaComposter.IsFertilizer(item)) + { + user.Message(MessageHud.MessageType.Center, "$msg_wontwork"); + return false; + } + + if (GetFertilizer() >= TrentaConfig.GroveFertilizerCapacity) + { + user.Message(MessageHud.MessageType.Center, "$msg_itsfull"); + return false; + } + + user.Message(MessageHud.MessageType.Center, "$msg_added " + item.m_shared.m_name); + inventory.RemoveItem(item, 1); + m_nview.InvokeRPC("RoV_GroveFeed"); + return true; + } + + private ItemDrop.ItemData FindFertilizer(Inventory inventory) + { + foreach (ItemDrop.ItemData candidate in inventory.GetAllItems()) + { + if (TrentaComposter.IsFertilizer(candidate)) return candidate; + } + return null; + } + + private void RPC_Feed(long sender) + { + if (!m_nview.IsOwner()) return; + + int stored = GetFertilizer(); + if (stored >= TrentaConfig.GroveFertilizerCapacity) return; + SetFertilizer(stored + 1); + } + + private string Hover() + { + if (!IsGrown()) + { + return Localization.instance.Localize( + $"{TrentaConfig.GroveDisplayName} (growing, {MinutesLeft()} minutes left)"); + } + + // 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"); + } + + /// 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)"; + + 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"; + + 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"; + } + + // ---------------------------------------------------------------- state + + public bool IsGrown() => SecondsSincePlanted() >= TrentaConfig.GroveGrowSeconds; + + private double SecondsSincePlanted() + { + if (m_nview == null || !m_nview.IsValid() || ZNet.instance == null) return 0.0; + + long ticks = m_nview.GetZDO().GetLong(KeyPlanted, 0L); + if (ticks == 0L) return 0.0; + + return (ZNet.instance.GetTime() - new DateTime(ticks)).TotalSeconds; + } + + private int MinutesLeft() + { + double left = TrentaConfig.GroveGrowSeconds - SecondsSincePlanted(); + return Mathf.Max(1, Mathf.CeilToInt((float)left / 60f)); + } + + private int GetFertilizer() => m_nview != null && m_nview.IsValid() ? m_nview.GetZDO().GetInt(KeyFertilizer) : 0; + + private void SetFertilizer(int value) + { + if (m_nview != null && m_nview.IsValid()) m_nview.GetZDO().Set(KeyFertilizer, Mathf.Max(0, value)); + } + } +} diff --git a/JotunnModStub/Trenta/TrentaComposter.cs b/JotunnModStub/Trenta/TrentaComposter.cs new file mode 100644 index 0000000..b245c2e --- /dev/null +++ b/JotunnModStub/Trenta/TrentaComposter.cs @@ -0,0 +1,488 @@ +using System.Collections.Generic; +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Trenta station: a slightly smaller fermenter wearing the Draugr's flies and green gas, + /// which rots raw flesh into Fertilizer. A Fertilizer used on any plant grows it on the spot. + /// + /// Second half of the per-race "item progression" system the Aswid's Blood Refinery started, + /// and deliberately the same shape: an item bought from a faction merchant gates a buildable + /// station, and the station produces the race's own material. Design doc: Trenta_Composter.txt. + /// + /// Where it differs from the refinery is worth stating, because it drove the code: the refinery + /// produces FOOD for its race and runs continuously off two tanks, while this produces a TOOL + /// that acts on the world and runs in batches, because that is what a fermenter does. And the + /// vanilla is one item in, N items out, which is no more usable here + /// than 's ore queue was there - so the component is stripped after its + /// scene references are handed to , which is what keeps the + /// barrel's three visual states and its sounds identical to the vanilla one's. + /// + public static class TrentaComposter + { + /// What a single use of Fertilizer managed to do, so callers can pick the message. + public enum GrowOutcome + { + NoTarget, + NotGrowable, + AlreadyRipe, + Unhealthy, + Grown, + } + + /// + /// Every Pickable the Fertilizer is allowed to bring back, as a CLOSED list - the same + /// standard the Aswid's bone table is held to, and for a sharper reason here. + /// + /// The "wild plant" branch works by un-picking a Pickable, and Pickable is also what a tin + /// deposit, a flint pile, a tar pit, a meteorite and every crypt remains pile are. Deducing + /// "is this a plant?" from the component would hand the player a fertilizer that regenerates + /// ore, which is an exploit made entirely of code nobody wrote. Names verified against the + /// shipped asset manifest; entries the running game does not have are simply never matched. + /// + public static readonly HashSet GrowablePickables = new HashSet + { + // Cultivated crops, in their grown-and-harvestable form + "Pickable_Carrot", "Pickable_Turnip", "Pickable_Onion", + "Pickable_Barley", "Pickable_Flax", + "Pickable_SeedCarrot", "Pickable_SeedOnion", "Pickable_SeedTurnip", + + // Wild versions of the same + "Pickable_Barley_Wild", "Pickable_Flax_Wild", + + // Wild plants and mushrooms + "Pickable_Mushroom", "Pickable_Mushroom_yellow", "Pickable_Mushroom_blue", + "Pickable_Mushroom_Magecap", "Pickable_Mushroom_JotunPuffs", "Pickable_SmokePuff", + "Pickable_Thistle", "Pickable_Dandelion", "Pickable_Fiddlehead", + + // Berry bushes - not Pickable_-prefixed, the Pickable sits on the bush itself + "RaspberryBush", "BlueberryBush", "CloudberryBush", + + // Grown vines (the sapling stages are Plants and go through the other branch) + "VineGreen", "VineAsh", + }; + + public static void Register() + { + RegisterRotSeed(); + RegisterFertilizer(); + RegisterPiece(); + } + + /// True for the Fertilizer, by prefab first and display name only as a fallback. + public static bool IsFertilizer(ItemDrop.ItemData item) + { + if (item == null || item.m_shared == null) return false; + if (item.m_dropPrefab != null) return item.m_dropPrefab.name == TrentaConfig.FertilizerName; + return item.m_shared.m_name == TrentaConfig.FertilizerDisplayName; + } + + // ---------------------------------------------------------------- items + + private static void RegisterRotSeed() + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(TrentaConfig.RotSeedName, "AncientSeed"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Trenta] Could not clone AncientSeed; Rot Seed not registered."); + return; + } + + Recolour(prefab, TrentaConfig.RotSeedTint); + + ItemDrop drop = prefab.GetComponent(); + if (drop == null) return; + + 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_itemType = ItemDrop.ItemData.ItemType.Material; + shared.m_weight = 0.5f; + shared.m_maxStackSize = 20; + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + } + + private static void RegisterFertilizer() + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(TrentaConfig.FertilizerName, "Entrails"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Trenta] Could not clone Entrails; Fertilizer not registered."); + return; + } + + Recolour(prefab, TrentaConfig.FertilizerTint); + + ItemDrop drop = prefab.GetComponent(); + if (drop == null) return; + + 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."; + + // 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 + // where TrentaFertilizerUsePatch takes it over. With every food value at zero it also + // stays invisible to the two prefixes that would otherwise fight over it: the vegan + // check in TrentaFoodPatches, and the "Mortal food disgusts you" block on + // Player.ConsumeItem in Skeleton/SkeletonPatches.cs. + shared.m_itemType = ItemDrop.ItemData.ItemType.Consumable; + shared.m_food = 0f; + shared.m_foodStamina = 0f; + shared.m_foodEitr = 0f; + shared.m_foodBurnTime = 0f; + shared.m_foodRegen = 0f; + shared.m_consumeStatusEffect = null; + + shared.m_weight = 0.5f; + shared.m_maxStackSize = 50; + + // The tint above only reaches the world and held models. Icons are atlas sprites and + // cannot be repainted - repainting one produced an empty inventory slot when the Aswid + // tried it - so a vanilla dark icon is borrowed instead. + Sprite icon = BorrowIcon(TrentaConfig.FertilizerIconSource); + if (icon != null) shared.m_icons = new[] { icon }; + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + } + + // ---------------------------------------------------------------- piece + + private static void RegisterPiece() + { + // "fermenter", not "piece_fermenter" - the same name AswidBloodPotions already reads. + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(TrentaConfig.ComposterPieceName, "fermenter"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Trenta] Could not clone fermenter; Composter not registered."); + return; + } + + Fermenter fermenter = prefab.GetComponentInChildren(true); + if (fermenter == null) + { + Jotunn.Logger.LogWarning("[Trenta] fermenter clone has no Fermenter; Composter not registered."); + return; + } + + ComposterBehaviour composter = fermenter.gameObject.AddComponent(); + composter.m_topObject = fermenter.m_topObject; + composter.m_fermentingObject = fermenter.m_fermentingObject; + composter.m_readyObject = fermenter.m_readyObject; + composter.m_outputPoint = fermenter.m_outputPoint; + composter.m_addedEffects = fermenter.m_addedEffects; + composter.m_tapEffects = fermenter.m_tapEffects; + composter.m_spawnEffects = fermenter.m_spawnEffects; + composter.m_capacity = TrentaConfig.ComposterCapacity; + composter.m_compostSeconds = TrentaConfig.ComposterCompostSeconds; + composter.m_yield = TrentaConfig.ComposterYield; + + // The vanilla barrel is its own Hoverable and Interactable: one interaction point on the + // root, unlike the eitr refinery, whose two assigned Switches the Blood Refinery could + // simply inherit. So the interaction is rebuilt with a Switch of our own on the same + // object, which is a component this repo already drives (see BloodRefineryBehaviour) and + // costs no interface implementation. Any Switch the prefab happened to carry is dropped + // first so it cannot win the hover from a child collider - the components only, never + // their colliders, which the barrel still needs. + foreach (Switch existing in prefab.GetComponentsInChildren(true)) + { + if (existing != null) Object.DestroyImmediate(existing); + } + + Object.DestroyImmediate(fermenter); + + composter.m_switch = composter.gameObject.AddComponent(); + composter.m_switch.m_name = TrentaConfig.ComposterDisplayName; + + // A barrel carries nothing that shoots, unlike the eitr refinery and its two Radiators. + // Called anyway as a belt: it logs whatever it finds, and a silent log is the proof. + AswidBloodRefinery.StripOffensive(prefab, TrentaConfig.ComposterPieceName); + + prefab.transform.localScale = Vector3.one * TrentaConfig.ComposterScale; + BuildRotVfx(prefab.transform); + + Piece piece = prefab.GetComponent(); + if (piece != null) + { + // Same call as RaceMenuWard and the Blood Refinery: a piece with a crafting station + // set vanishes from the hammer whenever that station is out of range, and this one + // has to stay findable. + piece.m_craftingStation = null; + piece.m_resources = new Piece.Requirement[0]; + piece.m_name = TrentaConfig.ComposterDisplayName; + } + + PieceConfig config = new PieceConfig + { + Name = TrentaConfig.ComposterDisplayName, + Description = "What rots is not lost. It feeds.", + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Crafting, + Requirements = new[] + { + new RequirementConfig(TrentaConfig.RotSeedName, 1, 0, true), + new RequirementConfig("Wood", 20, 0, true), + new RequirementConfig("Resin", 10, 0, true), + new RequirementConfig("Bronze", 5, 0, true), + } + }; + + PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, config)); + } + + /// + /// Hangs the Draugr's flies and green gas over the lid. + /// + /// The same particles, off the same prefab, with the same loop filter DraughVisuals.BuildAura + /// uses - looping is what separates a creature's ambient rot from its one-shot hit and death + /// effects. Copied rather than shared: DraughVisuals takes a Player, is driven by both + /// DraughRace and ZdoVisualSync, and generalising it to oblige a compost barrel would put a + /// working multiplayer aura at risk to save twenty lines. + /// + /// The holder is parented to the ROOT, never to the three state objects, which + /// ComposterBehaviour switches on and off - the VFX would blink out with them. + /// + private static void BuildRotVfx(Transform root) + { + GameObject source = PrefabManager.Cache.GetPrefab(TrentaConfig.ComposterVfxSourcePrefab); + if (source == null) + { + Jotunn.Logger.LogWarning($"[Trenta] Composter: could not find VFX source prefab '{TrentaConfig.ComposterVfxSourcePrefab}'."); + return; + } + + GameObject holder = new GameObject("ComposterVFX"); + holder.transform.SetParent(root, false); + holder.transform.localPosition = TrentaConfig.ComposterVfxLocalPosition; + + foreach (ParticleSystem particles in source.GetComponentsInChildren(true)) + { + if (particles == null || !particles.main.loop) continue; + + string name = particles.gameObject.name.ToLowerInvariant(); + + // Dripping water reads as rain coming off the barrel. DraughVisuals rejects the + // same three for the same reason. + if (name.Contains("drip") || name.Contains("drop") || name.Contains("rain") || name.Contains("splash")) continue; + + GameObject copy = Object.Instantiate(particles.gameObject, holder.transform); + copy.name = particles.gameObject.name; + copy.SetActive(true); + copy.transform.localPosition = Vector3.zero; + copy.transform.localRotation = particles.transform.localRotation; + } + } + + /// + /// A piece only reaches the hammer once it is in the player's known recipes, and the vanilla + /// learning pass misses pieces injected after the fact - the trap RaceMenuWard and the Blood + /// Refinery both fell into. The Rot Seed requirement is the real gate; this only makes the + /// entry visible, greyed out until one is owned. + /// + public static void EnsureKnown(Player player) + { + if (player == null) return; + + GameObject prefab = PrefabManager.Instance.GetPrefab(TrentaConfig.ComposterPieceName); + 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(); + } + + // ---------------------------------------------------------------- growing things + + /// + /// Grows one thing, now. The single place that knows how, called both by a player clicking a + /// Fertilizer and by a Heartwood Grove's own tick - the two tiers must not grow plants by + /// two slightly different rules, which is exactly what would happen if this were written + /// twice. + /// + /// Three families, and the order matters: a planted carrot is a Plant (sapling_carrot) and + /// only becomes a Pickable (Pickable_Carrot) once grown, so asking Pickable first would try + /// to "un-pick" a seedling, do nothing visible, and eat the item. + /// + public static GrowOutcome TryGrow(GameObject candidate) + { + if (candidate == null) return GrowOutcome.NoTarget; + + // a. Cultivated crops and tree saplings. Plant.Grow is the very method Plant.SUpdate + // calls once the natural timer runs out, so calling it by hand means literally "the + // time has passed" - no state is faked and nothing is short-circuited. + Plant plant = candidate.GetComponentInParent(); + if (plant != null) + { + // Growing regardless of conditions would beat sun, space, biome and cultivated + // ground all at once and make half of vanilla farming pointless. GetStatus is + // public, so this costs one comparison. + if (plant.GetStatus() != Plant.Status.Healthy) return GrowOutcome.Unhealthy; + + ZNetView nview = plant.GetComponent(); + if (nview == null || !nview.IsValid()) return GrowOutcome.NotGrowable; + + // Grow() instantiates the grown prefab and destroys this one through ZNetScene: + // both are the owner's work. + nview.ClaimOwnership(); + plant.Grow(); + return GrowOutcome.Grown; + } + + // b. Wild plants that are already grown. A berry bush does not grow, it ripens: for + // those, "grow instantly" means "be ripe again now". + Pickable pickable = candidate.GetComponentInParent(); + if (pickable != null) + { + if (!IsGrowablePickable(pickable)) return GrowOutcome.NotGrowable; + if (!pickable.GetPicked()) return GrowOutcome.AlreadyRipe; + + ZNetView nview = pickable.GetComponent(); + if (nview == null || !nview.IsValid()) return GrowOutcome.NotGrowable; + + nview.ClaimOwnership(); + pickable.SetPicked(false); + return GrowOutcome.Grown; + } + + // c. Everything else, a full-grown tree included: TreeBase.Grow is the growth animation + // a fresh trunk plays for itself, not a stage to advance. + return GrowOutcome.NotGrowable; + } + + private static bool IsGrowablePickable(Pickable pickable) + { + if (GrowablePickables.Contains(Utils.GetPrefabName(pickable.gameObject))) return true; + + // Safety net for modded plants the closed list above cannot know about: allow one if + // what it produces is something the Trenta itself calls food. Deliberately NOT a plain + // "does it drop something edible" test - that would let a meat pile through. + ItemDrop drop = pickable.m_itemPrefab != null ? pickable.m_itemPrefab.GetComponent() : null; + if (drop == null) return false; + + return TrentaConfig.VeganFoodPrefabNames.Contains(Utils.GetPrefabName(pickable.m_itemPrefab)); + } + + /// + /// A Fertilizer used from the hotbar. The plant is whatever the player is looking at: + /// Player.GetHoverObject already enforces the vanilla interact distance on its own, so + /// there is no raycast and no radius here. + /// + /// One unit per plant grown, and only when something actually grew - every refusal leaves + /// the inventory alone. + /// + public static void UseFertilizer(Player player, Inventory inventory, ItemDrop.ItemData item) + { + if (player == null || item == null) return; + if (inventory == null) inventory = player.GetInventory(); + + GrowOutcome outcome = TryGrow(player.GetHoverObject()); + switch (outcome) + { + case GrowOutcome.Grown: + if (inventory != null) inventory.RemoveItem(item, 1); + player.Message(MessageHud.MessageType.Center, "It grows."); + break; + + case GrowOutcome.AlreadyRipe: + player.Message(MessageHud.MessageType.Center, "It is ripe already."); + break; + + case GrowOutcome.Unhealthy: + player.Message(MessageHud.MessageType.Center, "This one is not well. Nothing will hurry it."); + break; + + case GrowOutcome.NoTarget: + player.Message(MessageHud.MessageType.Center, "Nothing there to feed."); + break; + + default: + player.Message(MessageHud.MessageType.Center, "$msg_wontwork"); + break; + } + } + + // ---------------------------------------------------------------- prefab surgery + + /// + /// Darkens every material on the clone. renderer.materials instantiates a copy, so the real + /// Entrails and the real Ancient seed keep their own look - which is the whole reason this + /// is the technique the Aswid settled on too. + /// + private static void Recolour(GameObject root, Color tint) + { + foreach (Renderer renderer in root.GetComponentsInChildren(true)) + { + if (renderer == null) continue; + if (renderer is ParticleSystemRenderer) continue; + + foreach (Material material in renderer.materials) + { + if (material == null) continue; + material.color = tint; + if (material.HasProperty("_Color")) material.SetColor("_Color", tint); + if (material.HasProperty("_EmissionColor")) material.SetColor("_EmissionColor", Color.black); + } + } + } + + 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; + if (icons != null && icons.Length > 0 && icons[0] != null) return icons[0]; + + Jotunn.Logger.LogWarning($"[Trenta] Could not borrow the icon from '{prefabName}'."); + return null; + } + } + + /// + /// Teaches every piece this mod registers after the vanilla learning pass, exactly like + /// RaceMenuWard does - none of them reach their table on their own. It lives in the Trenta's file + /// for historical reasons and now also covers the Furling's cultivator entries; one OnSpawned + /// postfix teaching all of them beats three postfixes doing the same thing. + /// + [HarmonyPatch(typeof(Player), "OnSpawned")] + public static class TrentaComposterKnownPatch + { + public static void Postfix(Player __instance) + { + if (__instance != Player.m_localPlayer) return; + TrentaComposter.EnsureKnown(__instance); + TrentaHeartwoodGrove.EnsureKnown(__instance); + FurlingCrops.EnsureKnown(__instance); + } + } + + /// + /// Turns using a Fertilizer into growing whatever the player is looking at. + /// + /// A prefix on the same method - and with the same signature - as + /// TrentaFoodPatches.Trenta_Humanoid_UseItem_Patch. The two never collide: that one returns + /// early for anything without food values, and the Fertilizer has none. + /// + [HarmonyPatch(typeof(Humanoid), "UseItem")] + public static class TrentaFertilizerUsePatch + { + public static bool Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item) + { + Player player = __instance as Player; + if (player == null || player != Player.m_localPlayer) return true; + if (!TrentaComposter.IsFertilizer(item)) return true; + + TrentaComposter.UseFertilizer(player, inventory, item); + return false; // Never let vanilla try to eat it + } + } +} diff --git a/JotunnModStub/Trenta/TrentaConfig.cs b/JotunnModStub/Trenta/TrentaConfig.cs index 3db2fec..429c3d3 100644 --- a/JotunnModStub/Trenta/TrentaConfig.cs +++ b/JotunnModStub/Trenta/TrentaConfig.cs @@ -200,7 +200,6 @@ namespace RacesOfValheim // Source of the buzz: the ambient bee-swarm effect a placed Beehive plays, read for its // AudioClip only - never instantiated, so nothing about how it looks ever enters this // ability, matching "la sua unica componente visiva sarà le mosche" literally. - public const string HornetsNestBeehivePrefab = "Beehive"; // ─── Muspell (Fader) ───────────────────────────────────────────────── // A toggled transformation, the same shape as FenrirRace's own G/H/J forms: press J to @@ -387,7 +386,163 @@ namespace RacesOfValheim return lookup; } + // ─── Composter (item progression, tier 1) ──────────────────────────── + // The Trenta's half of the per-race station system the Aswid's Blood Refinery started. + // Full design in Trenta_Composter.txt; every number it settles on lives here. + // + // 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 FertilizerName = "Fertilizer"; + public const string FertilizerDisplayName = "Fertilizer"; + + public const string RotSeedName = "RotSeed"; + public const string RotSeedDisplayName = "Rot Seed"; + + // Same band as the Aswid's Blood Core, which does the same job for the same reason. + public const int RotSeedPrice = 500; + + // "Slightly smaller than a fermenter" - the vanilla barrel is already human-sized, so this + // is a shave rather than the halving the (enormous) eitr refinery needed. + public const float ComposterScale = 0.85f; + + // One batch: 100 units of flesh in, 20 Fertilizer out after the compost time, so 5 units + // of flesh per Fertilizer. Flesh is valued by AswidBloodRefinery.FleshValue. + public const float ComposterCapacity = 100f; + public const float ComposterCompostSeconds = 2400f; // as a normal fermenter + public const int ComposterYield = 20; + + // Where the Draugr's flies and green gas hang over the lid. The scaled barrel is roughly a + // metre tall; this is an eyeball figure and is meant to be adjusted in game. + public static readonly Vector3 ComposterVfxLocalPosition = new Vector3(0f, 1f, 0f); + + // Same prefab TrentaHornetsNest and DraughVisuals already read their particles off. The + // Composter keeps the same subset DraughVisuals keeps - flies plus the green smoke - which + // is why the swarm on a Heartwood Grove and the haze over a Composter match by default. + public const string ComposterVfxSourcePrefab = "Draugr"; + + // Entrails, darkened to loam. Only the world/held model takes the tint - the inventory + // icon is an atlas sprite and cannot be repainted (proven the hard way on the Aswid's + // Blood Essence), so the icon is borrowed from Guck instead: green-black reads as + // "compost" without reading as "intestine". + public static readonly Color FertilizerTint = new Color(0.18f, 0.13f, 0.09f, 1f); + public const string FertilizerIconSource = "Guck"; + + public static readonly Color RotSeedTint = new Color(0.16f, 0.12f, 0.08f, 1f); + + // ─── 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. + public const string GroveSeedName = "HeartwoodSeed"; + public const string GroveSeedDisplayName = "Heartwood Seed"; + public const string GroveSaplingPieceName = "TrentaHeartwoodSapling"; + public const string GroveSaplingDisplayName = "Heartwood Sapling"; + public const string GrovePieceName = "TrentaHeartwoodGrove"; + public const string GroveDisplayName = "Heartwood Grove"; + + // A grove costs exactly one full Composter batch. That is the whole balance argument. + public const int GroveSeedFertilizerCost = ComposterYield; + + // World time, not session time: Plant.TimeSincePlanted reads ZNet's clock, so a sapling + // keeps growing with the zone unloaded and the game shut, same as the Composter's timer. + public const float GroveGrowSeconds = 7200f; + + // One radius for both halves on purpose - the grove defends exactly the ground it farms, + // and the player only has to learn one number. Matches PurpleRainRadius. + public const float GroveRadius = 8f; + + // One plant per tick, not the whole radius: 20 Fertilizer is then 20 minutes of autonomy. + // Growing everything at once would empty the trough in a single tick. + public const float GroveFertilizeInterval = 60f; + public const int GroveFertilizerCapacity = ComposterYield; + + // The honey rate is not invented: m_secPerUnit and m_maxHoney are read off the vanilla + // Beehive at registration. Only the capacity is scaled - a whole tree of bees has to last + // while the player is away, where a hive only has to last until they walk past it. + public const int GroveHoneyCapacityFactor = 5; + + // Honey accrues day and night, exactly as a vanilla hive's does. + // + // This used to be a GroveHoneyAtNight knob defaulting to false, on the reading that + // Beehive.m_effectOnlyInDaylight meant "bees only work in daylight". It does not: by its + // name and by the only method that touches it (Beehive.UpdateBees), it gates m_beeEffect - + // the buzz and the particles - not production. Vanilla hives make honey overnight. + // + // Getting that wrong did not merely slow the grove down, it starved it. The night was + // discarded by resetting the accrual stamp, which meant a whole m_secPerUnit had to fit + // inside one unbroken stretch of daylight - and m_secPerUnit is of the same order as a + // Valheim day is long (a full cycle is EnvMan.m_dayLengthSec, 1800s by default, of which + // roughly 1260s is not night). So honey was somewhere between rare and arithmetically + // impossible depending on the hive's real rate and what time it was when the tree matured. + // + // If the "bees sleep at night" flavour is ever wanted, it belongs where vanilla puts it: + // on the swarm's buzz, not on the honey. + + // Only the model is taken off this prefab, never its TreeBase or its log drop - the same + // discipline the VFX borrowing follows. A Yggdrasil shoot reads as "grown from a root of + // the world" rather than as any old beech, and matches YggdrasilWood being in the recipe. + public const string GroveModelPrefab = "YggaShoot_small1"; + public const float GroveModelScale = 1f; + + // Cloned for the sapling stage; must be a prefab that carries a Plant component. + public const string GroveSaplingSourcePrefab = "Beech_Sapling"; + + // The grove's swarm is the Hornet's Nest swarm with a different anchor - deliberately not + // a second copy of that code, so a change to the sting is a change to both. It therefore + // reads HornetsNestDamagePerTick / HornetsNestTickInterval and has no damage of its own. + // + // A grove is a piece, not a Character, so BaseAI.IsEnemy cannot be asked directly the way + // the player-anchored swarm asks it. The fallback rule lives in TrentaHornetSwarm. + public const float GroveStingRadius = GroveRadius; + + // Density cap, enforced by PieceDensityLimit. Without one, a field of groves is a carpet of + // bees that kills anything that comes near, and this was a known open point for two rounds. + // + // More permissive than the Draugh body pile's five, on the reading that a grove is a farm + // rather than an army and costs a Composter batch rather than a 500-coin bone. Unlike almost + // every other number in this file it has no vanilla equivalent to be read off, so it IS a + // guess - change it freely, it is one line and nothing else depends on it. + public const int GroveMaxInRange = 10; + public const float GroveDensityAreaKm2 = 1.6f; // the same frame the body pile uses + + // ─── The vanilla beehive ───────────────────────────────────────────── + // Two features read this prefab: the grove borrows its honey rate and capacity, and the + // Hornet's Nest borrows the AudioClip off its bee effect. + // + // Both used to look up "Beehive" and both silently got nothing - confirmed from the BepInEx + // log, which is the whole reason those lookups now warn instead of returning quietly. There is + // a Beehive.prefab in the asset manifest, but it is not what PrefabManager resolves under that + // name; the buildable hive is "piece_beehive", and that is the one carrying the tuned Beehive + // component. Both names are tried in order so a game update that moves it cannot silence this + // again without saying so. + public static readonly string[] BeehiveSourcePrefabs = { "piece_beehive", "Beehive" }; + // ─── Helpers ───────────────────────────────────────────────────────── + + /// + /// The vanilla Beehive component, or null. Shared by the grove and the Hornet's Nest so the + /// two cannot disagree about where it lives. + /// + public static Beehive FindVanillaBeehive() + { + foreach (string name in BeehiveSourcePrefabs) + { + GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab(name); + Beehive hive = prefab != null ? prefab.GetComponent() : null; + if (hive != null) + { + Jotunn.Logger.LogInfo($"[Trenta] Vanilla beehive resolved from '{name}'."); + return hive; + } + } + + Jotunn.Logger.LogWarning("[Trenta] No vanilla beehive found under any of: " + + string.Join(", ", BeehiveSourcePrefabs)); + return null; + } + /// Clamped table lookup, so a state outside 1..8 can never index out of range. public static float Lookup(float[] table, int state) { diff --git a/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs b/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs new file mode 100644 index 0000000..aeb43c1 --- /dev/null +++ b/JotunnModStub/Trenta/TrentaHeartwoodGrove.cs @@ -0,0 +1,237 @@ +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// Tier 2 of the Trenta's item chain: plant it, wait, and the tree that comes up fertilises what + /// surrounds it, stings what approaches it, and fills a chest with honey. Three functions that do + /// not depend on each other, on one piece. Design doc: Trenta_Composter.txt section 11. + /// + /// ONE piece, not two. The doc called for a sapling carrying a vanilla Plant whose m_grownPrefabs + /// pointed at a separate grown prefab; this grows in place instead - same crate, same ZNetView, + /// with the young model swapped for the grown one when the clock runs out. Three risks went away + /// with that decision and nothing was lost: + /// - no second prefab to register outside a piece table, and no question about whether Jotunn + /// has put it in ZNetScene by the time a Plant tries to instantiate it; + /// - no dependency on Beech_Sapling actually carrying a Plant, which was the one link in the + /// tier-1 design nobody had opened yet; + /// - the honey chest and the Fertilizer trough survive the transition, because there is no + /// transition - nothing is destroyed and re-spawned, so nothing has to be carried over. + /// The growth timer is the same shape as the Composter's: one timestamp on ZNet's world clock, so + /// it advances with the zone unloaded and across a restart. + /// + /// The layout is forced by a single fact worth stating plainly: there is one ZNetView per + /// instantiated prefab, and Container keeps its inventory in the ZDO. So there can be exactly one + /// real chest, and it is the honey one. The Fertilizer goes in through a Switch on the plant + /// itself - E on the crate opens the honey, E on the tree feeds it - which is the same division + /// of labour the vanilla fermenter uses between its root component and its child switches. + /// + public static class TrentaHeartwoodGrove + { + public static void Register() + { + RegisterSeed(); + RegisterPiece(); + + PieceDensityLimit.Register(TrentaConfig.GrovePieceName, + PieceDensityLimit.RadiusForArea(TrentaConfig.GroveDensityAreaKm2), TrentaConfig.GroveMaxInRange, + "This country already answers to {0} of these. Plant it somewhere else."); + } + + // ---------------------------------------------------------------- the seed + + private static void RegisterSeed() + { + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(TrentaConfig.GroveSeedName, "AncientSeed"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Trenta] Could not clone AncientSeed; Heartwood Seed not registered."); + return; + } + + ItemDrop drop = prefab.GetComponent(); + if (drop == null) return; + + 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_itemType = ItemDrop.ItemData.ItemType.Material; + shared.m_weight = 1f; + shared.m_maxStackSize = 10; + + ItemManager.Instance.AddItem(new CustomItem(prefab, fixReference: false)); + + // One grove costs exactly one full Composter batch - 100 units of flesh and forty + // minutes. That is the whole balance argument, and it is why the cost is expressed in + // Fertilizer rather than in some second currency. + ItemManager.Instance.AddRecipe(new CustomRecipe(new RecipeConfig + { + Item = TrentaConfig.GroveSeedName, + Amount = 1, + CraftingStation = "piece_preptable", + Requirements = new[] + { + new RequirementConfig(TrentaConfig.FertilizerName, TrentaConfig.GroveSeedFertilizerCost), + new RequirementConfig(TrentaConfig.RotSeedName, 1), + new RequirementConfig("YggdrasilWood", 10), + } + })); + } + + // ---------------------------------------------------------------- the piece + + private static void RegisterPiece() + { + // A wooden chest is the base because it arrives with everything a honey store needs + // already wired: ZNetView, Piece, WearNTear, colliders, and a Container whose lid + // objects and effect lists are assigned. Building one from scratch would mean assigning + // all of that by hand and finding out in game which field Container.Awake dereferences + // without checking. + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(TrentaConfig.GrovePieceName, "piece_chest_wood"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Trenta] Could not clone piece_chest_wood; Heartwood Grove not registered."); + return; + } + + Container container = prefab.GetComponent(); + if (container == null) + { + Jotunn.Logger.LogWarning("[Trenta] piece_chest_wood clone has no Container; Heartwood Grove not registered."); + return; + } + + container.m_name = TrentaConfig.GroveDisplayName; + + GroveBehaviour grove = prefab.AddComponent(); + grove.m_container = container; + grove.m_youngModel = BuildModel(prefab.transform, "GroveYoung", TrentaConfig.GroveSaplingSourcePrefab, TrentaConfig.GroveModelScale); + grove.m_grownModel = BuildModel(prefab.transform, "GroveGrown", TrentaConfig.GroveModelPrefab, TrentaConfig.GroveModelScale); + + // The plant is the second interaction point. It carries its own collider so the hover + // raycast resolves to the Switch on it rather than walking up to the Container on the + // root - which is how the crate keeps meaning "open the honey" while the tree means + // "feed me". Sized generously: it has to be clickable at both growth stages. + grove.m_switch = BuildTroughSwitch(grove.m_grownModel, grove.m_youngModel); + + Piece piece = prefab.GetComponent(); + if (piece != null) + { + piece.m_craftingStation = null; + piece.m_resources = new Piece.Requirement[0]; + piece.m_name = TrentaConfig.GroveDisplayName; + } + + PieceConfig config = new PieceConfig + { + Name = TrentaConfig.GroveDisplayName, + Description = "A crate of rot with something growing out of it. Give it time.", + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Misc, + Requirements = new[] + { + new RequirementConfig(TrentaConfig.GroveSeedName, 1, 0, true), + } + }; + + PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, config)); + } + + /// + /// Borrows the visible half of a world prefab and nothing else. + /// + /// The same discipline the VFX borrowing follows, and here it matters more: the Yggdrasil + /// shoot is a TreeBase, so taken whole it would bring a choppable trunk, a log drop and a + /// tree collider along with the mesh - a grove that can be felled for wood instead of being + /// destroyed as a piece. Only Renderers and their transforms survive; every component that + /// is not a Renderer, and every collider, is stripped. + /// + private static GameObject BuildModel(Transform root, string name, string sourcePrefabName, float scale) + { + GameObject holder = new GameObject(name); + holder.transform.SetParent(root, false); + holder.transform.localPosition = Vector3.zero; + + GameObject source = PrefabManager.Cache.GetPrefab(sourcePrefabName); + if (source == null) + { + Jotunn.Logger.LogWarning($"[Trenta] Heartwood Grove: could not find model prefab '{sourcePrefabName}'."); + return holder; + } + + GameObject copy = Object.Instantiate(source, holder.transform); + copy.name = "model"; + copy.transform.localPosition = Vector3.zero; + copy.transform.localScale = Vector3.one * scale; + + 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 (ZNetView nview in copy.GetComponentsInChildren(true)) + { + if (nview != null) Object.DestroyImmediate(nview); + } + + return holder; + } + + /// + /// The Fertilizer input: a Switch with a collider of its own, hung off the grown model but + /// parented so it stays live at both stages (the models get toggled, this does not). + /// + private static Switch BuildTroughSwitch(GameObject grownModel, GameObject youngModel) + { + // Parented to the models' shared parent - the piece root - precisely so GroveBehaviour + // can switch the two models on and off without taking the interaction point with them. + Transform parent = grownModel != null ? grownModel.transform.parent : youngModel.transform.parent; + + GameObject holder = new GameObject("GroveTrough"); + holder.transform.SetParent(parent, false); + holder.transform.localPosition = new Vector3(0f, 1.2f, 0f); + + // Two decisions here that both come down to "will the hover raycast find this at all", + // which is the one thing about this piece that cannot be settled by reading code: + // - the layer is copied from the piece root rather than left on Default, because + // Player.FindHoverObject raycasts against a mask and a brand new GameObject starts + // on whatever layer 0 happens to be; + // - it is NOT a trigger. Physics.queriesHitTriggers is a global whose value here is + // not ours, so a trigger collider might simply be invisible to that raycast. Solid + // also happens to be right: it is a tree trunk, and walking through it would be odd. + holder.layer = parent.gameObject.layer; + + BoxCollider collider = holder.AddComponent(); + collider.size = new Vector3(1.2f, 2.4f, 1.2f); + collider.isTrigger = false; + + Switch trough = holder.AddComponent(); + trough.m_name = TrentaConfig.GroveDisplayName; + return trough; + } + + /// + /// Same reason as the Composter's: a piece registered after the vanilla learning pass never + /// reaches the hammer on its own. The Heartwood Seed requirement is the real gate. + /// + public static void EnsureKnown(Player player) + { + if (player == null) return; + + GameObject prefab = PrefabManager.Instance.GetPrefab(TrentaConfig.GrovePieceName); + 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(); + } + } +} diff --git a/JotunnModStub/Trenta/TrentaHornetsNest.cs b/JotunnModStub/Trenta/TrentaHornetsNest.cs index ced6a53..dff625a 100644 --- a/JotunnModStub/Trenta/TrentaHornetsNest.cs +++ b/JotunnModStub/Trenta/TrentaHornetsNest.cs @@ -7,13 +7,22 @@ namespace RacesOfValheim /// /// The swarm itself. Not a Character - it has no health, no hitbox anything else can target, /// so "indistruttibile" falls out of what it simply isn't rather than needing invulnerability - /// code of its own. Idles in a slow orbit around the Trenta; the instant an enemy comes within - /// range it breaks off, hovers over that enemy instead, and sting-ticks it on a timer until it - /// dies or leaves range, then returns to orbiting. + /// code of its own. Idles in a slow orbit around whatever it is tied to; the instant an enemy + /// comes within range it breaks off, hovers over that enemy instead, and sting-ticks it on a + /// timer until it dies or leaves range, then returns to orbiting. + /// + /// Two things it can be tied to, and the difference is only in what counts as an enemy: + /// - a Trenta player (the Hornet's Nest perk), which can be asked BaseAI.IsEnemy directly; + /// - a Heartwood Grove's trunk (the tier-2 station), which cannot, because a piece is not a + /// Character. See IsHostile. + /// Deliberately one class rather than two copies: the sting is combat logic, and a second copy + /// means the next tweak to the venom gets made in one place and forgotten in the other. /// public class TrentaHornetSwarm : MonoBehaviour { - private Player owner; + private Player owner; // null for a grove swarm + private Transform anchor; // what it orbits; the owner's own transform for a player swarm + private float engageRadius; private Character target; private float tickTimer; private float orbitAngle; @@ -21,11 +30,38 @@ namespace RacesOfValheim public static GameObject Spawn(Player player) { - GameObject go = new GameObject("TrentaHornetsNest"); - go.transform.position = player.transform.position + Vector3.up; + GameObject go = Build("TrentaHornetsNest", player.transform.position + Vector3.up); + + TrentaHornetSwarm swarm = go.GetComponent(); + swarm.owner = player; + swarm.anchor = player.transform; + swarm.engageRadius = TrentaConfig.HornetsNestEngageRadius; + + return go; + } + + /// + /// The grove's swarm: same bees, tied to a fixed point instead of to a player. The radius is + /// its own number because 6 metres is tuned for something that walks - a tree that cannot + /// chase has to reach further, and it matches the ground the grove fertilises. + /// + public static GameObject SpawnAtAnchor(Transform anchorPoint, float radius) + { + GameObject go = Build("TrentaGroveBees", anchorPoint.position + Vector3.up); + + TrentaHornetSwarm swarm = go.GetComponent(); + swarm.anchor = anchorPoint; + swarm.engageRadius = radius; + + return go; + } + + private static GameObject Build(string name, Vector3 position) + { + GameObject go = new GameObject(name); + go.transform.position = position; TrentaHornetSwarm swarm = go.AddComponent(); - swarm.owner = player; BuildFliesVfx(go.transform); swarm.buzz = BuildBuzzAudio(go.transform); @@ -33,15 +69,20 @@ namespace RacesOfValheim return go; } + private Vector3 AnchorPosition => anchor != null ? anchor.position : transform.position; + private void Update() { - if (owner == null || owner.IsDead()) + // A player swarm dies with its player; a grove swarm dies with its tree. Either way the + // check is "is there still something to orbit", which is also what makes the swarm clean + // itself up when the grove is destroyed without the grove having to say so. + if (anchor == null || (owner != null && owner.IsDead())) { Destroy(gameObject); return; } - if (target != null && (target.IsDead() || Vector3.Distance(target.transform.position, owner.transform.position) > TrentaConfig.HornetsNestEngageRadius * 1.5f)) + if (target != null && (target.IsDead() || Vector3.Distance(target.transform.position, AnchorPosition) > engageRadius * 1.5f)) { target = null; } @@ -74,7 +115,7 @@ namespace RacesOfValheim // them - reads as "trying to stay on him" without looking glued in place. orbitAngle += Time.deltaTime * 60f; Vector3 orbitOffset = new Vector3(Mathf.Cos(orbitAngle * Mathf.Deg2Rad), 0.3f, Mathf.Sin(orbitAngle * Mathf.Deg2Rad)) * TrentaConfig.HornetsNestOrbitRadius; - Vector3 restPoint = owner.transform.position + Vector3.up + orbitOffset; + Vector3 restPoint = AnchorPosition + Vector3.up + orbitOffset; transform.position = Vector3.MoveTowards(transform.position, restPoint, TrentaConfig.HornetsNestFollowSpeed * Time.deltaTime); } } @@ -83,16 +124,17 @@ namespace RacesOfValheim { Character nearest = null; float nearestDist = float.MaxValue; + Vector3 centre = AnchorPosition; - foreach (Collider collider in Physics.OverlapSphere(owner.transform.position, TrentaConfig.HornetsNestEngageRadius)) + foreach (Collider collider in Physics.OverlapSphere(centre, engageRadius)) { if (collider == null) continue; Character character = collider.GetComponentInParent(); - if (character == null || character == owner || character.IsDead()) continue; - if (!BaseAI.IsEnemy(owner, character)) continue; + if (character == null || character == owner) continue; + if (!IsHostile(character)) continue; - float dist = Vector3.Distance(character.transform.position, owner.transform.position); + float dist = Vector3.Distance(character.transform.position, centre); if (dist < nearestDist) { nearestDist = dist; @@ -103,6 +145,59 @@ namespace RacesOfValheim return nearest; } + /// + /// Who gets stung. + /// + /// For a player swarm this is one line - BaseAI.IsEnemy - and it is the most valuable line in + /// the file: RaceHostilityManager is a postfix on that very method, so the Trenta's own + /// alliances (greyling, greydwarf, fuling, troll, leech, deathsquito) are honoured for free. + /// + /// A grove has no Character to ask on its own behalf, so the rule is rebuilt from parts: + /// never players, never tamed, and only things carrying a MonsterAI - which is the cut that + /// spares wild deer and boar, since vanilla gives passive animals AnimalAI instead. And if + /// there is a Trenta standing inside the radius, IsEnemy is consulted against them too, so + /// the alliances come back the moment someone is there to carry them. + /// + private bool IsHostile(Character character) + { + if (character == null || character.IsDead()) return false; + if (character.IsPlayer()) return false; + if (character.IsTamed()) return false; + + if (owner != null) return BaseAI.IsEnemy(owner, character); + + if (character.GetComponent() == null) return false; + + Player trenta = NearestTrenta(); + return trenta == null || BaseAI.IsEnemy(trenta, character); + } + + /// + /// The nearest Trenta inside the swarm's own radius, or null. Used both to borrow their + /// alliances and to attribute the sting - a hit with no attacker at all is what the old eitr + /// refinery's mystery damage looked like, and worth avoiding whenever there is a real one. + /// + private Player NearestTrenta() + { + Player nearest = null; + float nearestDist = float.MaxValue; + Vector3 centre = AnchorPosition; + + foreach (Player player in Player.GetAllPlayers()) + { + if (player == null || player.IsDead() || !TrentaVisuals.IsTrentaPlayer(player)) continue; + + float dist = Vector3.Distance(player.transform.position, centre); + if (dist <= engageRadius && dist < nearestDist) + { + nearestDist = dist; + nearest = player; + } + } + + return nearest; + } + /// /// Two hits, matching "come se il giocatore fosse costantemente avvelenato dalle api, più /// lo stesso danno ma perforante da sopra" literally: one Poison hit at the wild Bee @@ -111,16 +206,20 @@ namespace RacesOfValheim /// private void Sting(Character victim) { + // A grove's bees are still somebody's bees when a Trenta is standing under the tree; + // when nobody is, the sting lands with no attacker rather than picking one at random. + Character attacker = owner != null ? owner : NearestTrenta(); + HitData poison = new HitData(); poison.m_damage.m_poison = TrentaConfig.HornetsNestDamagePerTick; - poison.SetAttacker(owner); + if (attacker != null) poison.SetAttacker(attacker); poison.m_point = victim.GetCenterPoint(); poison.m_dir = Vector3.zero; victim.Damage(poison); HitData pierce = new HitData(); pierce.m_damage.m_pierce = TrentaConfig.HornetsNestDamagePerTick; - pierce.SetAttacker(owner); + if (attacker != null) pierce.SetAttacker(attacker); pierce.m_point = victim.GetCenterPoint(); pierce.m_dir = Vector3.down; victim.Damage(pierce); @@ -165,8 +264,10 @@ namespace RacesOfValheim source.spatialBlend = 1f; // 3D - it should sound like it is coming from the swarm source.volume = 0.6f; - GameObject beehivePrefab = PrefabManager.Cache.GetPrefab(TrentaConfig.HornetsNestBeehivePrefab); - Beehive beehive = beehivePrefab != null ? beehivePrefab.GetComponent() : null; + // Resolved through TrentaConfig, which tries "piece_beehive" before "Beehive". This used + // to look up "Beehive" alone and got nothing, every time, which is why the swarm has been + // silent since it was written - found in the BepInEx log, not by listening. + Beehive beehive = TrentaConfig.FindVanillaBeehive(); GameObject beeEffect = beehive != null ? Traverse.Create(beehive).Field("m_beeEffect").Value : null; AudioSource sourceClipHolder = beeEffect != null ? beeEffect.GetComponentInChildren(true) : null; diff --git a/JotunnModStub/Trenta/TrentaRace.cs b/JotunnModStub/Trenta/TrentaRace.cs index 7ce994d..eac4cca 100644 --- a/JotunnModStub/Trenta/TrentaRace.cs +++ b/JotunnModStub/Trenta/TrentaRace.cs @@ -27,6 +27,13 @@ namespace RacesOfValheim { TrentaStatusEffects.RegisterStatusEffects(); CreateAwakenedSeedFoods(); + + // The item-progression chain: the Composter and its Fertilizer, then the Heartwood Grove + // that runs on that Fertilizer. Registered here rather than lazily because the faction + // merchant catalogue resolves the Rot Seed by prefab name, so the item has to exist + // before that catalogue is read. + TrentaComposter.Register(); + TrentaHeartwoodGrove.Register(); } /// From df7ce7c893cf77f0ba640a62512f885ec6a7c7cc Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 7 Aug 2026 17:02:48 +0200 Subject: [PATCH 011/311] feat(trol): war totem and its mercenary store Co-Authored-By: Claude Opus 5 --- JotunnModStub/Trol/TrolRace.cs | 4 + JotunnModStub/Trol/TrolTotem.cs | 368 +++++++++++++++++++++++ JotunnModStub/Trol/TrolTotemBehaviour.cs | 288 ++++++++++++++++++ JotunnModStub/Trol/TrolTotemStore.cs | 257 ++++++++++++++++ 4 files changed, 917 insertions(+) create mode 100644 JotunnModStub/Trol/TrolTotem.cs create mode 100644 JotunnModStub/Trol/TrolTotemBehaviour.cs create mode 100644 JotunnModStub/Trol/TrolTotemStore.cs diff --git a/JotunnModStub/Trol/TrolRace.cs b/JotunnModStub/Trol/TrolRace.cs index 5b7eb15..9867b73 100644 --- a/JotunnModStub/Trol/TrolRace.cs +++ b/JotunnModStub/Trol/TrolRace.cs @@ -38,6 +38,10 @@ namespace RacesOfValheim Jotunn.Logger.LogInfo("Initializing Trol Race..."); TrolStatusEffects.RegisterStatusEffects(); + // The war totem and every creature it can hire. Race-locked at placement, unlike every + // other station in the mod. + TrolTotem.Register(); + // No custom projectile needed anymore string[] logNames = new string[] { diff --git a/JotunnModStub/Trol/TrolTotem.cs b/JotunnModStub/Trol/TrolTotem.cs new file mode 100644 index 0000000..945433f --- /dev/null +++ b/JotunnModStub/Trol/TrolTotem.cs @@ -0,0 +1,368 @@ +using System.Collections.Generic; +using HarmonyLib; +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The Trol's totem: a troll's head on a core-wood post that hires warbands for coin. + /// + /// The first station in the mod that is RACE LOCKED. Every other chain can be built by anyone and + /// only its output is restricted; this one refuses the hammer outright to anyone who is not a Trol, + /// because a warband of trolls and greydwarves for money is the Trol's whole identity rather than a + /// tool it happens to own. + /// + /// The troops are the real creatures, unaltered - a Troll is a Troll - with three differences: + /// - they answer to the follow command, because they carry RaisedThrall like every other servant + /// in this mod, so the taunt and the click already work on them with no new code; + /// - they knit their wounds back up when left alone, the sentry's regeneration reused whole; + /// - they drop NOTHING and never come back. A dead warband is money spent. That is the balance + /// against troops that cost coin instead of materials, and it is why they are worth what they + /// are worth. + /// + public static class TrolTotem + { + public const string PieceName = "TrolWarTotem"; + public const string PieceDisplayName = "War Totem"; + public const string RaceId = "Trol"; + + /// Core wood. The item is RoundLog - another display name that does not predict the id. + public const string CoreWood = "RoundLog"; + public const string TrollHead = "TrophyForestTroll"; + + /// Yagluth's secondary drop, already mapped to state 6 in BossProgressionManager. + /// Distinct from TrophyGoblinKing, which is the head that replaces the troll's on upgrade. + public const string UpgradeItem = "YagluthDrop"; + public const string YagluthHead = "TrophyGoblinKing"; + + public const int UpgradeProgressionState = 6; // Yagluth + public const int MaxTroops = 5; + + // ---------------------------------------------------------------- the look, in metres + // These used to be bare multipliers (3f for the totem, 1.5f for the head) guessed against meshes + // nobody had measured, and the head came out with a circumference three times the height of the + // post under it. ModelBorrow now measures the mesh and scales it to fit, so a number here is a + // SIZE and not a factor: 2.2 m is a totem you can stand next to, 0.55 m is a head on top of it. + private const float TotemHeight = 2.2f; + private const float HeadSize = 0.9f; + + /// + /// How far the head sinks into the totem's crown, as a fraction of its own size. Mounting it exactly + /// ON the measured top left it hovering with daylight under it - a trophy sitting on a post shares + /// some of the post, so the two models are made to overlap instead of merely touching. + /// + private const float HeadSink = 0.35f; + + /// + /// A trophy is authored lying down, and the first correction (Euler(90,0,0)) stood it up but left it + /// upside down and facing away - seen in game, not reasoned about. Another half turn on each of the + /// two axes that were wrong puts it the right way up and looking out. + /// If it is still off, this is the ONE line to touch: the two 180s are what was added. + /// + private static readonly Quaternion HeadTilt = Quaternion.Euler(90f + 180f, 180f, 0f); + + /// Written into each hired creature's ZDO so the totem can tell its warbands apart - + /// five slots means counting groups, not bodies. + public const string KeyGroup = "RoV_trolGroup"; + + public const float LeashRange = 12f; + public const float WitherSeconds = 60f; + public const float HomeCheckRange = 25f; + + /// No cap: a hired warband follows as a warband. + public const int MaxFollowers = -1; + + public class Troop + { + public string Id; + public string Display; + public int Price; + public bool NeedsUpgrade; + /// Trophy of the strongest thing in the band - the face it wears in the rack. + public string Icon; + /// Vanilla creature prefab -> how many of it. + public KeyValuePair[] Members; + } + + // Anchored at 2000 for the strongest, as specified, and laddered by what each band can actually + // do rather than by head count. + public static readonly Troop[] Troops = + { + new Troop + { + Id = "greydwarf_patrol", Display = "Greydwarf Patrol", Price = 400, NeedsUpgrade = false, Icon = "TrophyGreydwarfBrute", + Members = new[] + { + new KeyValuePair("Greydwarf", 4), + new KeyValuePair("Greydwarf_Shaman", 1), + new KeyValuePair("Greydwarf_Elite", 1), + } + }, + new Troop + { + Id = "troll", Display = "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", + Members = new[] { new KeyValuePair("Troll_Summoned", 1) } + }, + new Troop + { + Id = "goblin_patrol", Display = "Fuling Patrol", Price = 1400, NeedsUpgrade = true, Icon = "TrophyGoblinBrute", + Members = new[] + { + new KeyValuePair("Goblin", 4), + new KeyValuePair("GoblinShaman", 1), + new KeyValuePair("GoblinBrute", 1), + } + }, + new Troop + { + Id = "goblin_band", Display = "Fuling War Band", Price = 2000, NeedsUpgrade = true, Icon = "TrophyGoblin", + Members = new[] + { + new KeyValuePair("Goblin", 4), + new KeyValuePair("GoblinArcher", 4), + } + }, + }; + + public static Troop Find(string id) + { + foreach (Troop troop in Troops) if (troop.Id == id) return troop; + return null; + } + + /// Every distinct creature the totem can hire, so their clones exist before anyone buys. + private static readonly Dictionary HiredPrefabs = new Dictionary(); + + public static string HiredNameFor(string vanillaPrefab) => + HiredPrefabs.TryGetValue(vanillaPrefab, out string name) ? name : null; + + public static void Register() + { + HashSet sources = new HashSet(); + foreach (Troop troop in Troops) + { + foreach (KeyValuePair member in troop.Members) sources.Add(member.Key); + } + foreach (string source in sources) RegisterHired(source); + + RegisterPiece(); + } + + // ---------------------------------------------------------------- the hired + + /// + /// One hired creature: the vanilla thing, tamed, leashed, healing, and worth nothing dead. + /// + /// CharacterDrop is destroyed for the reason it always is here - a mercenary that dropped a troll + /// hide would make the totem a farm - and this time it is also what "leaves nothing when it dies" + /// literally means. + /// + private static void RegisterHired(string source) + { + string prefabName = "TrolHired_" + source; + + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(prefabName, source); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Trol] Could not clone {source}; that troop cannot be hired."); + return; + } + + BaseAI ai = prefab.GetComponent(); + if (ai != null) ai.m_randomMoveRange = LeashRange; + + foreach (CharacterDrop drops in prefab.GetComponentsInChildren(true)) + { + if (drops != null) Object.DestroyImmediate(drops); + } + + RaisedThrall thrall = prefab.AddComponent(); + thrall.m_kind = prefabName; + thrall.m_commandingRace = RaceId; + thrall.m_maxFollowers = MaxFollowers; + thrall.m_witherSeconds = WitherSeconds; + thrall.m_homeCheckRange = HomeCheckRange; + thrall.m_refusalMessage = "They were not paid by you."; + + // 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 + // mercenary stays dead and has to be hired again. + prefab.AddComponent(); + + PrefabManager.Instance.AddPrefab(prefab); + HiredPrefabs[source] = prefabName; + } + + // ---------------------------------------------------------------- the totem + + private static void RegisterPiece() + { + // A REAL PIECE as the base, and this is the whole bug fix. The first version cloned + // "GoblinTotem", which lives in Assets/GameElements/Items/misc - it is the ITEM offered at + // Yagluth's altar, not a building. An ItemDrop wearing a Piece destroyed itself the moment it + // was placed and left the item lying on the ground. Verified in this very project when the + // merchant catalogue's "FulingTotem" was corrected to "GoblinTotem" as an ITEM, and then + // contradicted here. + // + // piece_workbench is a genuine piece and is already the stripped base of the Skeleton + // sentry's seed, so the pattern is proven. goblin_totempole was the other candidate and is + // not a piece either - it is dungeon scenery under Assets/world. + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PieceName, "piece_workbench"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("[Trol] Could not clone piece_workbench; the war totem is not registered."); + return; + } + + // Strip the workbench down to a placeable shell: no station, no crafting, no furniture. The + // look comes from the borrowed totem 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, PieceName); + + // The look the player asked for: the totem itself, not a log with a head on it. Grounded on + // its own base, so Vector3.zero really is "standing on the spot the hammer picked". + GameObject totemModel = ModelBorrow.Attach(prefab.transform, "TotemModel", "GoblinTotem", + Vector3.zero, Quaternion.identity, TotemHeight, "Trol"); + + TrolTotemBehaviour totem = prefab.AddComponent(); + + foreach (Switch existing in prefab.GetComponentsInChildren(true)) + { + if (existing != null) Object.DestroyImmediate(existing); + } + totem.m_switch = prefab.AddComponent(); + totem.m_switch.m_name = PieceDisplayName; + + // A Trader with an empty catalogue: StoreGui needs one to open at all, and an empty list is + // exactly "sells troops, buys nothing". An empty catalogue is also what used to kill the whole + // window - see StoreGuiEmptyCatalogueGuardPatch in TrolTotemStore.cs, which is the fix. + // + // Every list is filled in even though this trader never talks: a Trader added with + // AddComponent comes up with all of them null, and Trader.Interact - which fires if the + // player's E happens to reach the Trader instead of our Switch, both being on this same + // GameObject - walks straight into Say(m_randomStartTrade, ...) right after opening the store. + Trader trader = prefab.GetComponent() ?? prefab.AddComponent(); + trader.m_name = PieceDisplayName; + trader.m_items = new List(); + trader.m_useItems = new List(); + trader.m_randomTalk = new List(); + trader.m_randomGreets = new List(); + trader.m_randomGoodbye = new List(); + trader.m_randomStartTrade = new List(); + trader.m_randomBuy = new List(); + trader.m_randomSell = new List(); + trader.m_randomGiveItemNo = new List(); + trader.m_randomUseItemAlreadyRecieved = new List(); + trader.m_randomTalkConditionals = new List(); + + // Only ONE head now, and only for the upgraded tier. At tier one the totem is just a totem, + // which is what was asked for - the troll head on a post was the thing being replaced, and + // mounting trophies is also what dropped a giant Yagluth head out of the sky. Borrowed + // safely this time, and mounted on the MEASURED top of the totem rather than at a guessed + // 2.2 m up an unmeasured post - sunk into the crown so it sits on it instead of over it. + float crown = ModelBorrow.HeightOf(totemModel); + Jotunn.Logger.LogInfo($"[Trol] Totem crown measured at {crown:0.##} m; the king's head is " + + $"{HeadSize} m across and sunk {HeadSize * HeadSink:0.##} m into it."); + + totem.m_yagluthHead = ModelBorrow.Attach(prefab.transform, "TotemHeadYagluth", YagluthHead, + new Vector3(0f, crown - HeadSize * HeadSink, 0f), + HeadTilt, HeadSize, "Trol"); + totem.m_yagluthHead.SetActive(false); + + Piece piece = prefab.GetComponent() ?? prefab.AddComponent(); + piece.m_craftingStation = null; + piece.m_resources = new Piece.Requirement[0]; + piece.m_name = PieceDisplayName; + piece.m_canBeRemoved = true; + piece.m_groundPiece = true; + piece.m_groundOnly = true; + piece.m_icon = BorrowIcon(TrollHead); + + 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 = PieceDisplayName, + Description = "A head that still remembers how to shout. Coin goes in, a warband walks out.", + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Crafting, + Icon = BorrowIcon(TrollHead), + Requirements = new[] + { + new RequirementConfig(CoreWood, 1, 0, true), + new RequirementConfig(TrollHead, 1, 0, true), + } + })); + } + + public static void EnsureKnown(Player player) + { + if (player == null) return; + + GameObject prefab = PrefabManager.Instance.GetPrefab(PieceName); + 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(); + } + + 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 TrolTotemKnownPatch + { + public static void Postfix(Player __instance) + { + if (__instance != Player.m_localPlayer) return; + TrolTotem.EnsureKnown(__instance); + } + } + + /// + /// 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. + /// + [HarmonyPatch(typeof(Player), "PlacePiece", + new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })] + public static class TrolTotemRaceLockPatch + { + public static bool Prefix(Player __instance, Piece __0) + { + if (__instance != Player.m_localPlayer || __0 == null) return true; + 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."); + return false; + } + } +} diff --git a/JotunnModStub/Trol/TrolTotemBehaviour.cs b/JotunnModStub/Trol/TrolTotemBehaviour.cs new file mode 100644 index 0000000..c3ab254 --- /dev/null +++ b/JotunnModStub/Trol/TrolTotemBehaviour.cs @@ -0,0 +1,288 @@ +using System; +using System.Collections.Generic; +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + /// + /// The totem's logic: five warband slots, bought with coin, disbanded on demand. + /// + /// Slots count GROUPS, not bodies - a six-greydwarf patrol is one slot, and it stays one slot as its + /// members die. Each hired creature carries the group's id in its own ZDO, so the count survives a + /// reload and corrects itself when a whole band is wiped, with nothing tallied anywhere. + /// + /// E opens the vanilla store with a warband column in it, built in TrolTotemStore. It replaced a + /// hold-to-cycle gesture on the Switch that fired faster than anyone could read it. + /// Factions/FactionMerchantSellPanel.cs is the blueprint that made it possible without guessing at a + /// single UI field name. + /// + /// There is no disband button and no rack of slots: a warband that dies is dead, and a butcher knife + /// already dismisses one that has outlived its use. The count is the only bookkeeping there is. + /// + public class TrolTotemBehaviour : MonoBehaviour + { + public Switch m_switch; + public GameObject m_yagluthHead; + + private const string KeyUpgraded = "RoV_trolTotemUpgraded"; + private const string KeyNextGroup = "RoV_trolTotemNextGroup"; + + private ZNetView m_nview; + + private void Awake() + { + RaisedThrall.RegisterStation(transform); + + m_nview = GetComponent(); + if (m_nview == null || m_nview.GetZDO() == null) return; + + if (m_switch != null) + { + m_switch.m_onUse = OnUse; + m_switch.m_onHover = Hover; + } + + m_nview.Register("RoV_TrolHire", RPC_Hire); + m_nview.Register("RoV_TrolUpgrade", RPC_Upgrade); + + InvokeRepeating("UpdateHeads", 0.5f, 2f); + } + + private void OnDestroy() + { + RaisedThrall.UnregisterStation(transform); + } + + /// Both heads are mounted; the tier decides which one is looking at you. + private void UpdateHeads() + { + // Tier one is a plain totem; the king's head only appears once it has been earned. + if (m_yagluthHead != null) m_yagluthHead.SetActive(IsUpgraded()); + } + + // ---------------------------------------------------------------- interaction + + private bool OnUse(Switch caller, Humanoid user, ItemDrop.ItemData item) + { + Player player = user as Player; + if (player == null) return false; + + if (!TrolRace.IsTrol()) + { + player.Message(MessageHud.MessageType.Center, "The head will not shout for you."); + return false; + } + + // Yagluth's drop in hand upgrades it: a new head, and two more warbands on the list. + if (item != null && item.m_dropPrefab != null && item.m_dropPrefab.name == TrolTotem.UpgradeItem) + { + return TryUpgrade(player, item); + } + + if (item != null) + { + player.Message(MessageHud.MessageType.Center, "$msg_wontwork"); + return false; + } + + return OpenStore(player); + } + + private bool TryUpgrade(Player player, ItemDrop.ItemData item) + { + if (IsUpgraded()) + { + player.Message(MessageHud.MessageType.Center, "It has already had one."); + return false; + } + + if (BossProgressionManager.GetCurrentProgressionState() < TrolTotem.UpgradeProgressionState) + { + player.Message(MessageHud.MessageType.Center, "Not until the one it belonged to has fallen."); + return false; + } + + player.GetInventory().RemoveItem(item, 1); + m_nview.InvokeRPC("RoV_TrolUpgrade"); + player.Message(MessageHud.MessageType.Center, "The totem wears a king now."); + return true; + } + + /// + /// Opens the vanilla store window, with the warband column hung off it by + /// TrolTotemStore. A Trader has to be present for StoreGui.Show to have anything to show; the + /// totem's own sells nothing, which is how "does not buy from the player" is expressed. + /// + private bool OpenStore(Player player) + { + Trader trader = GetComponent(); + if (trader == null || StoreGui.instance == null) + { + player.Message(MessageHud.MessageType.Center, "The head has nothing to say."); + return false; + } + + // Nothing is handed to the panel here on purpose: TrolTotemStore reads the totem back out of + // StoreGui's own m_trader when it repaints, so the window cannot end up drawing one totem's + // warbands while showing another's - and there is no static left over to go stale. + StoreGui.instance.Show(trader); + return true; + } + + // ---------------------------------------------------------------- what the store calls + + /// Hire by id, from a row the player clicked. Every check TryHire makes still applies. + public void HireFromStore(string troopId) + { + Player player = Player.m_localPlayer; + if (player == null) return; + + TrolTotem.Troop troop = TrolTotem.Find(troopId); + if (troop == null) return; + if (troop.NeedsUpgrade && !IsUpgraded()) return; + + if (CountGroups() >= TrolTotem.MaxTroops) + { + player.Message(MessageHud.MessageType.Center, "Five warbands is all it can shout for."); + return; + } + + Inventory inventory = player.GetInventory(); + if (inventory == null) return; + + if (CountCoins(inventory) < troop.Price) + { + player.Message(MessageHud.MessageType.Center, "$msg_notenoughmoney"); + return; + } + + TakeCoins(inventory, troop.Price); + m_nview.InvokeRPC("RoV_TrolHire", troop.Id); + player.Message(MessageHud.MessageType.Center, $"{troop.Display} answers."); + } + + private const string CoinsPrefab = "Coins"; + + private static int CountCoins(Inventory inventory) + { + int total = 0; + foreach (ItemDrop.ItemData item in inventory.GetAllItems()) + { + if (item != null && item.m_dropPrefab != null && item.m_dropPrefab.name == CoinsPrefab) + { + total += item.m_stack; + } + } + return total; + } + + private static void TakeCoins(Inventory inventory, int amount) + { + foreach (ItemDrop.ItemData item in new List(inventory.GetAllItems())) + { + if (amount <= 0) return; + if (item == null || item.m_dropPrefab == null || item.m_dropPrefab.name != CoinsPrefab) continue; + + int take = Mathf.Min(amount, item.m_stack); + inventory.RemoveItem(item, take); + amount -= take; + } + } + + // ---------------------------------------------------------------- hiring + + private void RPC_Hire(long sender, string troopId) + { + if (!m_nview.IsOwner()) return; + + TrolTotem.Troop troop = TrolTotem.Find(troopId); + if (troop == null || CountGroups() >= TrolTotem.MaxTroops) return; + if (troop.NeedsUpgrade && !IsUpgraded()) return; + + int next = m_nview.GetZDO().GetInt(KeyNextGroup) + 1; + m_nview.GetZDO().Set(KeyNextGroup, next); + string group = troopId + "#" + next; + + foreach (KeyValuePair member in troop.Members) + { + string hired = TrolTotem.HiredNameFor(member.Key); + if (hired == null) continue; + + GameObject prefab = ZNetScene.instance != null ? ZNetScene.instance.GetPrefab(hired) : null; + if (prefab == null) + { + Jotunn.Logger.LogWarning($"[Trol] No '{hired}' in ZNetScene; part of {troop.Display} did not arrive."); + continue; + } + + for (int i = 0; i < member.Value; i++) SpawnOne(prefab, group); + } + } + + private void SpawnOne(GameObject prefab, string group) + { + Vector3 offset = UnityEngine.Random.insideUnitSphere * 3f; + offset.y = 0f; + Vector3 position = transform.position + offset + Vector3.up * 0.5f; + + GameObject spawned = Instantiate(prefab, position, Quaternion.Euler(0f, UnityEngine.Random.Range(0, 360), 0f)); + + ZNetView nview = spawned.GetComponent(); + if (nview != null && nview.IsValid()) nview.GetZDO().Set(TrolTotem.KeyGroup, group); + + RaisedThrall thrall = spawned.GetComponent(); + if (thrall != null) thrall.Bind(transform.position); + } + + private void RPC_Upgrade(long sender) + { + if (!m_nview.IsOwner()) return; + m_nview.GetZDO().Set(KeyUpgraded, true); + } + + // ---------------------------------------------------------------- state + + public bool IsUpgraded() => m_nview != null && m_nview.IsValid() && m_nview.GetZDO().GetBool(KeyUpgraded, false); + + private static string GroupOf(RaisedThrall thrall) + { + ZNetView nview = thrall != null ? thrall.GetComponent() : null; + if (nview == null || !nview.IsValid()) return null; + + string group = nview.GetZDO().GetString(TrolTotem.KeyGroup, ""); + return string.IsNullOrEmpty(group) ? null : group; + } + + /// + /// Live warbands, counted as distinct groups rather than as bodies. This is the whole of the + /// five-slot mechanic now that the rack is gone: nothing is stored, the count is the truth, and it + /// corrects itself the moment a band is wiped out. + /// + public int CountGroups() + { + HashSet groups = new HashSet(); + foreach (RaisedThrall thrall in RaisedThrall.BoundTo(transform.position)) + { + string group = GroupOf(thrall); + if (group != null) groups.Add(group); + } + return groups.Count; + } + + private string Hover() + { + string body = $"warbands {CountGroups()}/{TrolTotem.MaxTroops}"; + + if (!IsUpgraded()) body += "\n(a Yagluth drop in hand buys a king's head, and two more bands)"; + + // 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"; + + return Localization.instance.Localize($"{TrolTotem.PieceDisplayName} ({body})"); + } + } + +} diff --git a/JotunnModStub/Trol/TrolTotemStore.cs b/JotunnModStub/Trol/TrolTotemStore.cs new file mode 100644 index 0000000..2bb61f1 --- /dev/null +++ b/JotunnModStub/Trol/TrolTotemStore.cs @@ -0,0 +1,257 @@ +using System.Collections.Generic; +using System.Text; +using HarmonyLib; +using TMPro; +using UnityEngine; +using UnityEngine.UI; + +namespace RacesOfValheim +{ + /// + /// The war totem's window: the merchant's own store, with a column of hireable warbands in it. + /// + /// Built by cloning the vanilla store's list the way Factions/FactionMerchantSellPanel.cs already + /// does - same three patch points (Awake to build, FillList to repaint, Hide to clear), same trick of + /// instantiating StoreGui.m_listElement for rows. That file is the reason this one could be written + /// without guessing at a single UI field name. + /// + /// It replaces a hold-to-cycle gesture on the Switch, which was unreadable: the hold fired faster + /// than anyone could see what was selected. + /// + /// NO SLOT RACK. There was one, with five squares wearing the trophies of the bands standing in them + /// and a yes/no box to disband one. It is gone at the player's call: a warband that dies is simply + /// dead, and a butcher knife already dismisses one that has outlived its use - tested in game. The + /// five-band CEILING stays, counted in TrolTotemBehaviour and reported by the totem's hover text; it + /// was only ever the rack that was UI, not the limit. + /// + /// WHY THIS FILE ONCE DREW NOTHING AT ALL - see StoreGuiEmptyCatalogueGuardPatch at the bottom. It + /// was not this panel failing; it was vanilla FillList throwing on its last instruction, and a + /// Postfix never runs when the original throws. + /// + public static class TrolTotemStore + { + private static RectTransform _troopList; + private static readonly List _rows = new List(); + + /// + /// The totem the open window belongs to, read back out of StoreGui's own m_trader instead of being + /// pushed in by the totem before Show(). + /// + /// It used to be a static the totem set on its way in, which meant the panel's correctness depended + /// on the order Show/Hide/FillList happen to run in. Reading it back makes the question local: this + /// window belongs to whatever trader vanilla says it belongs to, and if that trader has a + /// TrolTotemBehaviour on it, it is a totem. Same field the factions sell panel reads. + /// + public static TrolTotemBehaviour ActiveTotem(StoreGui gui) + { + Trader trader = FactionMerchantRuntime.GetActiveTrader(gui); + return trader != null ? trader.GetComponent() : null; + } + + // ---------------------------------------------------------------- build + + public static void Create(StoreGui gui) + { + if (gui == null || gui.m_listRoot == null) + { + Jotunn.Logger.LogWarning("[Trol] StoreGui has no m_listRoot; the war totem's window cannot be built."); + return; + } + if (_troopList != null) return; + + GameObject clone = Object.Instantiate(gui.m_listRoot.gameObject, gui.m_listRoot.parent); + clone.name = "TrolTroopList"; + _troopList = clone.GetComponent(); + _troopList.anchoredPosition = gui.m_listRoot.anchoredPosition; + + // The clone carries whatever rows the vanilla list held at Awake. Usually none, but a leftover + // would sit under ours forever, so it starts empty by construction. + foreach (Transform child in _troopList) Object.Destroy(child.gameObject); + + _troopList.gameObject.SetActive(false); + } + + public static void Clear() + { + foreach (GameObject row in _rows) if (row != null) Object.Destroy(row); + _rows.Clear(); + + if (_troopList != null) _troopList.gameObject.SetActive(false); + } + + // ---------------------------------------------------------------- fill + + public static void Refresh(StoreGui gui) + { + Clear(); + + TrolTotemBehaviour totem = ActiveTotem(gui); + if (totem == null) return; // an ordinary merchant. Not ours, and not worth a line in the log. + + if (_troopList == null) + { + Jotunn.Logger.LogWarning("[Trol] The war totem's column was never built (did the patch on " + + "StoreGui.Awake fail?), so nothing can be drawn into it."); + return; + } + + _troopList.gameObject.SetActive(true); + + int row = 0; + int hidden = 0; + foreach (TrolTotem.Troop troop in TrolTotem.Troops) + { + if (troop.NeedsUpgrade && !totem.IsUpgraded()) { hidden++; continue; } + BuildRow(gui, totem, troop, row++); + } + + float baseSize = Traverse.Create(gui).Field("m_itemlistBaseSize").GetValue(); + _troopList.SetSizeWithCurrentAnchors(RectTransform.Axis.Vertical, + Mathf.Max(baseSize, row * gui.m_itemSpacing)); + + Jotunn.Logger.LogInfo($"[Trol] War totem window: {row} warbands on offer, {hidden} still behind " + + $"the king's head, {totem.CountGroups()}/{TrolTotem.MaxTroops} bands alive."); + } + + private static void BuildRow(StoreGui gui, TrolTotemBehaviour totem, TrolTotem.Troop troop, int rowIndex) + { + GameObject element = Object.Instantiate(gui.m_listElement, _troopList); + element.SetActive(true); + + RectTransform rt = (RectTransform)element.transform; + float offset = (_troopList.rect.width - rt.rect.width) / 2f; + rt.anchoredPosition = new Vector2(offset, rowIndex * -gui.m_itemSpacing - offset); + + Sprite icon = TrophyIcon(troop.Icon); + Image iconImage = element.transform.Find("icon").GetComponent(); + if (icon != null) iconImage.sprite = icon; + 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; + + 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)); + + string id = troop.Id; + element.GetComponent + // 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 070/311] 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 071/311] 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 072/311] 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 073/311] 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 074/311] 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 075/311] 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 076/311] 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 077/311] 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 078/311] 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 079/311] 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 080/311] 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 081/311] 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 082/311] 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 083/311] 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 084/311] 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 085/311] 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 086/311] 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 087/311] 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 088/311] 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 089/311] 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 090/311] 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 091/311] 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 092/311] 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 093/311] 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 094/311] 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 095/311] 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 096/311] 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 097/311] 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 098/311] 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 099/311] 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 100/311] 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 101/311] 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 102/311] 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 103/311] 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 104/311] 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 105/311] 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