From 7f7b92a191b318bc24fe8d5fc92c1ba513e81242 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 19:32:17 +0200 Subject: [PATCH 001/429] Update Aswid devour toggle, player scaling fix, and README encoding --- JotunnModStub/Aswid/AswidPatches.cs | 2 +- README.md | 51 +++++++++++++++-------------- manifest.json | 4 +-- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 1808885..19e26df 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -509,7 +509,7 @@ namespace RacesOfValheim if (__instance == Player.m_localPlayer && Input.GetKeyDown(KeyCode.I)) { AswidRace.DevourEnabled = !AswidRace.DevourEnabled; - string msg = AswidRace.DevourEnabled ? "Abilità Divora: ATTIVATA" : "Abilità Divora: DISATTIVATA"; + string msg = AswidRace.DevourEnabled ? "Devour Ability: ENABLED" : "Devour Ability: DISABLED"; __instance.Message(MessageHud.MessageType.Center, msg); } diff --git a/README.md b/README.md index ca78721..b75c83b 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# RacesOfValheim +# RacesOfValheim A comprehensive Valheim mod that allows you to play as different unique races, each offering distinct mechanics, visual transformations, and a deep progression system tailored to your journey in Valheim. @@ -58,16 +58,16 @@ This mod currently introduces 6 custom races: ### Furling Progression - **Base (No Bosses)**: Goblin head model. All weapon & combat skills gain 2x XP permanently. -- **Eikthyr**: Master of Shadows — sounds ≤15m are suppressed (near-silent movement). -- **The Elder**: The Wickerman — -50% Fire & Poison damage; arrows gain bonus fire damage. -- **Bonemass**: Dance of the Dead — Crafting meads, bombs, and ammo yields double quantity. -- **Eikthyr**: Master of Shadows  sounds ≤15m are suppressed (near-silent movement). -- **The Elder**: The Wickerman  -50% Fire & Poison damage; arrows gain bonus fire damage. -- **Bonemass**: Dance of the Dead  Crafting meads, bombs, and ammo yields double quantity. -- **Moder**: The Man/Woman on the Silver Mountain  doubles trophy drops from normal enemies within 25m, drops bonus gold from starred enemies, doubles ore mining yield. -- **Yagluth**: The King is Dead, Hail to the King/Queen  while in the Plains biome, ALL skills gain 2x XP (including magic). HUD status icon shown. -- **The Queen**: In the Mist He/She Was Standing  blue (Eitr) foods last twice as long. -- **Fader**: Through Fire and Flames  permanently on fire (visual only), immune to fire damage, physical attacks set targets on fire. +- **Eikthyr**: Master of Shadows - sounds -15m are suppressed (near-silent movement). +- **The Elder**: The Wickerman - -50% Fire & Poison damage; arrows gain bonus fire damage. +- **Bonemass**: Dance of the Dead - Crafting meads, bombs, and ammo yields double quantity. +- **Eikthyr**: Master of Shadows - sounds -15m are suppressed (near-silent movement). +- **The Elder**: The Wickerman - -50% Fire & Poison damage; arrows gain bonus fire damage. +- **Bonemass**: Dance of the Dead - Crafting meads, bombs, and ammo yields double quantity. +- **Moder**: The Man/Woman on the Silver Mountain - doubles trophy drops from normal enemies within 25m, drops bonus gold from starred enemies, doubles ore mining yield. +- **Yagluth**: The King is Dead, Hail to the King/Queen - while in the Plains biome, ALL skills gain 2x XP (including magic). HUD status icon shown. +- **The Queen**: In the Mist He/She Was Standing - blue (Eitr) foods last twice as long. +- **Fader**: Through Fire and Flames - permanently on fire (visual only), immune to fire damage, physical attacks set targets on fire. ### Aswid Progression - **Base (No Bosses)**: Benedictus et Afflictus. Progressive stats (+1 Armor, +2 Damage, +1% Speed, +1% Jump per boss killed). All passive bonuses are doubled at night! You can cast Blood Magic items with infinite Eitr, and your Blood Magic skill increases twice as fast. Physical kills automatically consume enemies (Vae Victis), granting Blood Magic XP. @@ -75,8 +75,8 @@ This mod currently introduces 6 custom races: - **The Elder**: Like a Bat out of Hell (Always active). - **Bonemass**: Auspex (Aura reveals untamed creatures). - **Moder**: Freezing Blood (Permanent immunity to Freezing and Poison). -- **Yagluth**: Dominate (E Key  Dominate non-tameable enemies). -- **The Queen**: Weight of Shadows (H Key  Immune to physical/poison, double aura damage, weak to fire/frost/spirit. Breaks at sunrise). +- **Yagluth**: Dominate (E Key - Dominate non-tameable enemies). +- **The Queen**: Weight of Shadows (H Key - Immune to physical/poison, double aura damage, weak to fire/frost/spirit. Breaks at sunrise). - **Fader**: Asmund (Passive). Your hair and beard turn as dark as the abyss. You become 10% taller and gain a flat +30 to Physical Damage. ### Skadi Progression @@ -104,8 +104,8 @@ This mod currently introduces 6 custom races: - **The Elder**: Wolf Form (Night). - **Bonemass**: Wolf Form (Day/Night). Ulv Form (Night). - **Moder**: Ulv Form (Day/Night). Fenring Form (Night). -- **Yagluth**: Cultist Form (Night — 1 min duration, 10 min cooldown). -- **The Queen**: Fenring Form (Day/Night). Cultist Form (Night — 1 min duration, 5 min cooldown). +- **Yagluth**: Cultist Form (Night - 1 min duration, 10 min cooldown). +- **The Queen**: Fenring Form (Day/Night). Cultist Form (Night - 1 min duration, 5 min cooldown). - **Fader**: Cultist Form (Day/Night). ## Development & Feedback @@ -122,22 +122,22 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** - **Bugfix**: Fixed an issue where the new automatic food consumption logic for Aswid physical kills failed to find the correct prefabs for basic animals like Deer and Boars. **v1.3.1** -- **NEW RACE — Trol**: Added the sixth playable race, the Trol. Huge size, immense strength, rock throwing, and the ability to wield trees as weapons! +- **NEW RACE - Trol**: Added the sixth playable race, the Trol. Huge size, immense strength, rock throwing, and the ability to wield trees as weapons! - **Trol Combat**: The Trol starts with increased size and carry weight, scaling stats as bosses are killed, and unlocking the ability to throw massive rocks at The Elder tier. - **Trol True Form**: Unlocked at Moder, allowing you to transform. Once you defeat The Queen, you can look at trees while in True Form to rip a log out and use it as a massive 2-handed weapon! - **Trol Stomachs**: As you progress, you unlock a 4th (Bonemass) and a 5th (Yagluth) stomach slot, allowing you to consume up to 5 foods simultaneously! - **Bugfixes**: Fixed various item/food duplication bugs and polished the new eating logic to perfectly integrate with the native UI. **v1.3.0** -- **NEW RACE — Furling**: Added the fifth playable race, the Furling (Goblin). Unique goblin head model, full progression tied to all 7 bosses. -- **Furling — Eikthyr (Master of Shadows)**: Sounds below 15m range are suppressed, making you nearly silent at night or in dungeons. -- **Furling — The Elder (The Wickerman)**: Gain -50% Fire and Poison damage resistance. Arrows gain bonus fire damage. -- **Furling — Bonemass (Dance of the Dead)**: Crafting meads, bombs, and ammo yields double the quantity. -- **Furling — Moder (The Man/Woman on the Silver Mountain)**: Trophy drops from normal enemies are doubled, starred enemies drop bonus coins, and ore mining yields are doubled. -- **Furling — Yagluth (The King is Dead, Hail to the King/Queen)**: In the Plains biome, the 2x XP multiplier extends to ALL skills (including Elemental and Blood Magic). A HUD status icon appears in the top-right when active. -- **Furling — The Queen (In the Mist He/She Was Standing)**: Eitr (blue) foods last twice as long for you. -- **Furling — Fader (Through Fire and Flames)**: You are permanently wreathed in native fire flames (SE_Burning visual, no damage, no HUD warning). Full fire immunity. All physical attacks set targets on fire. -- **Bugfix**: Fixed MineRock.RPC_Damage → MineRock.RPC_Hit Harmony patch after a Valheim update renamed the method. +- **NEW RACE - Furling**: Added the fifth playable race, the Furling (Goblin). Unique goblin head model, full progression tied to all 7 bosses. +- **Furling - Eikthyr (Master of Shadows)**: Sounds below 15m range are suppressed, making you nearly silent at night or in dungeons. +- **Furling - The Elder (The Wickerman)**: Gain -50% Fire and Poison damage resistance. Arrows gain bonus fire damage. +- **Furling - Bonemass (Dance of the Dead)**: Crafting meads, bombs, and ammo yields double the quantity. +- **Furling - Moder (The Man/Woman on the Silver Mountain)**: Trophy drops from normal enemies are doubled, starred enemies drop bonus coins, and ore mining yields are doubled. +- **Furling - Yagluth (The King is Dead, Hail to the King/Queen)**: In the Plains biome, the 2x XP multiplier extends to ALL skills (including Elemental and Blood Magic). A HUD status icon appears in the top-right when active. +- **Furling - The Queen (In the Mist He/She Was Standing)**: Eitr (blue) foods last twice as long for you. +- **Furling - Fader (Through Fire and Flames)**: You are permanently wreathed in native fire flames (SE_Burning visual, no damage, no HUD warning). Full fire immunity. All physical attacks set targets on fire. +- **Bugfix**: Fixed MineRock.RPC_Damage - MineRock.RPC_Hit Harmony patch after a Valheim update renamed the method. **v1.2.0** - **Multiplayer Sync**: Fully implemented visual syncing for Aswid forms (Bat, Mist) and Skadi forms (Bear, Wolf, Hatchling, Fader) so other players can see your transformations in multiplayer! @@ -157,3 +157,4 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** - Initial release with 4 distinct races. - Added Aswid life-draining and night transformations. - Complete progression system tied to Valheim's bosses. + diff --git a/manifest.json b/manifest.json index dbb06fc..6b2a327 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ -{ +{ "name": "RacesOfValheim", "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.1", + "version_number": "1.3.2", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 824622c582b158202d48e171a22efd8580eb9a7a Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 19:33:38 +0200 Subject: [PATCH 002/429] Remove UTF-8 BOM from README for Thunderstore --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index b75c83b..3132ba0 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# RacesOfValheim +# RacesOfValheim A comprehensive Valheim mod that allows you to play as different unique races, each offering distinct mechanics, visual transformations, and a deep progression system tailored to your journey in Valheim. From 68dd2329ddee44fceee2f9e0ba407be3e7e0b3c6 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 22:22:24 +0200 Subject: [PATCH 003/429] Remove undead and inorganic enemies from Aswid diet --- JotunnModStub/Aswid/AswidRace.cs | 13 ------------- JotunnModStub/Furling/FurlingPatches.cs | 13 +++++++++---- 2 files changed, 9 insertions(+), 17 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 124b63e..4874ae4 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -20,17 +20,8 @@ namespace RacesOfValheim { "Deer", "TrophyDeer" }, { "Wolf", "TrophyWolf" }, { "Fenring", "TrophyFenring" }, - { "Draugr", "TrophyDraugr" }, - { "Draugr_Elite", "TrophyDraugrElite" }, - { "Skeleton", "TrophySkeleton" }, - { "Skeleton_Poison", "TrophySkeletonPoison" }, - { "Surtling", "TrophySurtling" }, - { "Blob", "TrophyBlob" }, - { "BlobElite", "TrophyBlobElite" }, { "Leech", "TrophyLeech" }, - { "Wraith", "TrophyWraith" }, { "Hatchling", "TrophyHatchling" }, - { "StoneGolem", "TrophySGolem" }, { "Lox", "TrophyLox" }, { "Fuling", "TrophyGoblin" }, { "FulingShaman", "TrophyGoblinShaman" }, @@ -46,10 +37,6 @@ namespace RacesOfValheim { "Cultist", "TrophyCultist" }, { "Bat", "TrophyBat" }, { "Asksvin", "TrophyAsksvin" }, - { "Charred_Melee", "TrophyCharredMelee" }, - { "Charred_Archer", "TrophyCharredArcher" }, - { "Charred_Mage", "TrophyCharredMage" }, - { "Morgen", "TrophyMorgen" }, { "Volture", "TrophyVolture" } }; diff --git a/JotunnModStub/Furling/FurlingPatches.cs b/JotunnModStub/Furling/FurlingPatches.cs index 29074cc..c4c0ed8 100644 --- a/JotunnModStub/Furling/FurlingPatches.cs +++ b/JotunnModStub/Furling/FurlingPatches.cs @@ -124,21 +124,26 @@ namespace RacesOfValheim GameObject trophyPrefab = PrefabManager.Cache.GetPrefab("TrophyGoblin")?.gameObject; if (trophyPrefab != null) { - // instantiateInWorldSpace = false per ereditare esattamente la trasformazione base + bool wasActive = trophyPrefab.activeSelf; + trophyPrefab.SetActive(false); GameObject trophyVisual = UnityEngine.Object.Instantiate(trophyPrefab, headBone, false); + trophyPrefab.SetActive(wasActive); + trophyVisual.name = "FurlingHead_Trophy"; // Rimuoviamo tutti gli script (HoverText, ZNetView, ItemDrop, ecc.) per evitare prompt a schermo foreach (var comp in trophyVisual.GetComponentsInChildren()) { - UnityEngine.Object.Destroy(comp); + UnityEngine.Object.DestroyImmediate(comp); } if (trophyVisual.GetComponent() != null) - UnityEngine.Object.Destroy(trophyVisual.GetComponent()); + UnityEngine.Object.DestroyImmediate(trophyVisual.GetComponent()); foreach (var col in trophyVisual.GetComponentsInChildren()) { - UnityEngine.Object.Destroy(col); + UnityEngine.Object.DestroyImmediate(col); } + + trophyVisual.SetActive(true); // Valheim rig scales are huge (100). // Spostiamo la testa leggermente in alto (asse Y = 0.0015) e 5cm indietro rispetto al centro (asse X positivo = 0.0005) trophyVisual.transform.localPosition = new Vector3(0.0005f, 0.0015f, 0f); From 31beda5eeaf2cc7bb4d532a273cbf1c38d4f21cd Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 22:25:43 +0200 Subject: [PATCH 004/429] Restore Ashlands enemies (Charred/Morgen) to Aswid diet --- JotunnModStub/Aswid/AswidRace.cs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 4874ae4..67dba75 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -37,7 +37,11 @@ namespace RacesOfValheim { "Cultist", "TrophyCultist" }, { "Bat", "TrophyBat" }, { "Asksvin", "TrophyAsksvin" }, - { "Volture", "TrophyVolture" } + { "Volture", "TrophyVolture" }, + { "Charred_Melee", "TrophyCharredMelee" }, + { "Charred_Archer", "TrophyCharredArcher" }, + { "Charred_Mage", "TrophyCharredMage" }, + { "Morgen", "TrophyMorgen" } }; private static Dictionary mobToFoodMap = new Dictionary From 3104e5fabfe9480bef2534fc4257dfd2f151f5e3 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 22:29:08 +0200 Subject: [PATCH 005/429] Remove Charred and Morgen from Aswid diet again --- JotunnModStub/Aswid/AswidRace.cs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 67dba75..4874ae4 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -37,11 +37,7 @@ namespace RacesOfValheim { "Cultist", "TrophyCultist" }, { "Bat", "TrophyBat" }, { "Asksvin", "TrophyAsksvin" }, - { "Volture", "TrophyVolture" }, - { "Charred_Melee", "TrophyCharredMelee" }, - { "Charred_Archer", "TrophyCharredArcher" }, - { "Charred_Mage", "TrophyCharredMage" }, - { "Morgen", "TrophyMorgen" } + { "Volture", "TrophyVolture" } }; private static Dictionary mobToFoodMap = new Dictionary From 9c64ed00727c8dfa9b3add47a205c91b60b5bcb9 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 22:31:43 +0200 Subject: [PATCH 006/429] Fix Aswid devour failing during attack animation --- JotunnModStub/Aswid/AswidRace.cs | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 4874ae4..a1b78bd 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -1072,15 +1072,16 @@ namespace RacesOfValheim // UseItem natively plays animation and consumes it. // If stomach is full, EatFood fails, UseItem does not consume the item, and virtualInv is destroyed (disintegrated) AswidRace.BypassAswidFoodCheck = true; - Player.m_localPlayer.UseItem(virtualInv, addedItem, true); + bool successfullyEaten = Player.m_localPlayer.EatFood(addedItem); AswidRace.BypassAswidFoodCheck = false; - if (addedItem.m_stack <= 0 || virtualInv.GetItem(addedItem.m_shared.m_name) == null) + if (successfullyEaten) { - Jotunn.Logger.LogInfo($"[AswidDebug] Item was successfully eaten from virtual inventory!"); + Jotunn.Logger.LogInfo($"[AswidDebug] Item was successfully eaten from virtual inventory via EatFood!"); // 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.TopLeft, "$msg_ate " + addedItem.m_shared.m_name); // Vae Victis XP logic - similar to Dead Raiser Player.m_localPlayer.RaiseSkill(Skills.SkillType.BloodMagic, 1f); From 55d2cc97bbad66c9f419453861d7332854b330ab Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 22:34:26 +0200 Subject: [PATCH 007/429] Add Aswid passive lifesteal scaling with progression state --- JotunnModStub/Aswid/AswidPatches.cs | 38 ++++++++++++++++++------- JotunnModStub/Aswid/AswidProgression.cs | 2 ++ 2 files changed, 29 insertions(+), 11 deletions(-) diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 19e26df..e8ee699 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -654,22 +654,38 @@ namespace RacesOfValheim { if (hit == null || __instance == null || __instance.IsPlayer()) return; - // Check if it died from this hit - if (__state > 0f && __instance.GetHealth() <= 0f) + Character attacker = hit.GetAttacker(); + if (attacker != null && attacker.IsPlayer() && attacker == Player.m_localPlayer) { - Jotunn.Logger.LogInfo($"[AswidDebug] {__instance.name} died. __state: {__state}, CurrentHP: {__instance.GetHealth()}"); - Character attacker = hit.GetAttacker(); - if (attacker != null) Jotunn.Logger.LogInfo($"[AswidDebug] Attacker is: {attacker.name} / Player: {attacker.IsPlayer()} / Local: {attacker == Player.m_localPlayer}"); - - if (attacker != null && attacker.IsPlayer() && attacker == Player.m_localPlayer) + ZNetView nview = attacker.GetComponent(); + if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Aswid") { - ZNetView nview = attacker.GetComponent(); - if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Aswid") + float physDamage = hit.m_damage.m_blunt + hit.m_damage.m_slash + hit.m_damage.m_pierce + hit.m_damage.m_chop + hit.m_damage.m_pickaxe + hit.m_damage.m_damage; + + // On-hit Lifesteal + if (physDamage > 0f) { + int currentState = BossProgressionManager.GetCurrentProgressionState(); + var rules = AswidProgression.GetRules(currentState); + float lifesteal = rules.LifestealPercent; + if (EnvMan.instance != null && EnvMan.IsNight()) + { + lifesteal *= 2f; + } + if (lifesteal > 0f) + { + float healAmount = physDamage * lifesteal; + Player.m_localPlayer.Heal(healAmount, true); + } + } + + // On-death Devour + if (__state > 0f && __instance.GetHealth() <= 0f) + { + Jotunn.Logger.LogInfo($"[AswidDebug] {__instance.name} died. __state: {__state}, CurrentHP: {__instance.GetHealth()}"); Jotunn.Logger.LogInfo($"[AswidDebug] Attacker is local Aswid player. Checking damage type..."); - // Check if physical attack - if (hit.m_damage.m_blunt > 0 || hit.m_damage.m_slash > 0 || hit.m_damage.m_pierce > 0 || hit.m_damage.m_chop > 0 || hit.m_damage.m_pickaxe > 0 || hit.m_damage.m_damage > 0) + if (physDamage > 0f) { Jotunn.Logger.LogInfo($"[AswidDebug] Calling TryConsumeMob for {__instance.name}"); AswidRace.TryConsumeMob(__instance, __instance.GetMaxHealth()); diff --git a/JotunnModStub/Aswid/AswidProgression.cs b/JotunnModStub/Aswid/AswidProgression.cs index fe95061..8585d88 100644 --- a/JotunnModStub/Aswid/AswidProgression.cs +++ b/JotunnModStub/Aswid/AswidProgression.cs @@ -23,11 +23,13 @@ namespace RacesOfValheim public float BonusHealth = 0f; public float BonusStamina = 0f; public bool HasSurtlingForm = false; + public float LifestealPercent = 0f; } public static AswidRules GetRules(int state) { AswidRules rules = new AswidRules(); + rules.LifestealPercent = (state * 2f) / 100f; // 2% per state // State 0 is the base state, no modifiers yet. if (state >= 1) From 87b6b11afe836d08143ad11ebc0e10947542ab16 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 23:08:46 +0200 Subject: [PATCH 008/429] Update README.md changelog to v1.3.2 --- JotunnModStub/Package/README.md | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/JotunnModStub/Package/README.md b/JotunnModStub/Package/README.md index dbbcde8..361ccb1 100644 --- a/JotunnModStub/Package/README.md +++ b/JotunnModStub/Package/README.md @@ -55,6 +55,15 @@ This mod currently introduces 4 custom races: - **Furling**: Fine-tuned the custom 3D Goblin Head trophy alignment and scaling. It now fits perfectly inside the player's skull, revealing only the goblin ears! - **Documentation**: Added complete level-by-level progression lists to the README for all races. +**v1.3.1** +- **Aswid**: Refined the Aswid's diet. Excluded undead/inorganic Ashlands creatures (Charred, Morgen). +- **Aswid**: Added a 4th stomach slot exclusively for Aswid prey! +- **Aswid**: Added a keybind (I) to toggle the automatic devour on/off. + +**v1.3.2** +- **Aswid**: Fixed a bug where devouring a mob would fail if the player was still in an attack or movement animation. +- **Aswid**: Added a passive lifesteal scaling mechanic! You now heal for 2% of the physical damage dealt per boss defeated (up to 14% at endgame). This amount is doubled during the night! + ## Race Progressions (Level-by-Level) ### Aswid Progression From 784c913e3fbc1d2480c289566fc28308bbbdc8af Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 23:11:16 +0200 Subject: [PATCH 009/429] Bump version to 1.3.3 and update changelog --- JotunnModStub/Package/README.md | 4 ++-- JotunnModStub/Package/manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Package/README.md b/JotunnModStub/Package/README.md index 361ccb1..80f442f 100644 --- a/JotunnModStub/Package/README.md +++ b/JotunnModStub/Package/README.md @@ -55,12 +55,12 @@ This mod currently introduces 4 custom races: - **Furling**: Fine-tuned the custom 3D Goblin Head trophy alignment and scaling. It now fits perfectly inside the player's skull, revealing only the goblin ears! - **Documentation**: Added complete level-by-level progression lists to the README for all races. -**v1.3.1** +**v1.3.2** - **Aswid**: Refined the Aswid's diet. Excluded undead/inorganic Ashlands creatures (Charred, Morgen). - **Aswid**: Added a 4th stomach slot exclusively for Aswid prey! - **Aswid**: Added a keybind (I) to toggle the automatic devour on/off. -**v1.3.2** +**v1.3.3** - **Aswid**: Fixed a bug where devouring a mob would fail if the player was still in an attack or movement animation. - **Aswid**: Added a passive lifesteal scaling mechanic! You now heal for 2% of the physical damage dealt per boss defeated (up to 14% at endgame). This amount is doubled during the night! diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index 6b2a327..a5c7a50 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.2", + "version_number": "1.3.3", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 9c5f17b066d09a4ee94b4f726990bb9f27456e19 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 23:22:11 +0200 Subject: [PATCH 010/429] Bump version to 1.3.3.1 --- 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 a5c7a50..be40f26 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.3", + "version_number": "1.3.3.1", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From e1c593abc4efeb38f5895429adc67e766251ee42 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 23:24:59 +0200 Subject: [PATCH 011/429] Update root manifest and README to 1.3.3.1 --- README.md | 6 ++++++ manifest.json | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3132ba0..aae6601 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,12 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** ## Changelog +**v1.3.3.1** +- **Aswid**: Refined the Aswid's diet. Restored Ashlands creatures (except undead like Charred and Morgen) and enabled a 4th stomach slot exclusively for Aswid prey. +- **Aswid**: Added a keybind (I) to toggle the automatic devour on/off. +- **Aswid**: Fixed a bug where devouring a mob would fail if the player was still in an attack or movement animation. +- **Aswid**: Added a passive lifesteal scaling mechanic! You now heal for 2% of the physical damage dealt per boss defeated (up to 14% at endgame). This amount is doubled during the night! + **v1.3.2** - **Aswid**: Blood Magic (Vampiric Aura) is now only active when blocking in Bat or Mist form. Base damage reduced by 50%. - **Aswid**: Added thematic day/night transition messages ("what a horrible night to have a curse"). diff --git a/manifest.json b/manifest.json index 6b2a327..be40f26 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.2", + "version_number": "1.3.3.1", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 1b37d924a2f5330f4dfe0103409c77f4b96b7d20 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Thu, 30 Jul 2026 23:26:50 +0200 Subject: [PATCH 012/429] Bump version to 1.3.4 for Thunderstore compliance --- README.md | 2 +- manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index aae6601..25c34f0 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** ## Changelog -**v1.3.3.1** +**v1.3.4** - **Aswid**: Refined the Aswid's diet. Restored Ashlands creatures (except undead like Charred and Morgen) and enabled a 4th stomach slot exclusively for Aswid prey. - **Aswid**: Added a keybind (I) to toggle the automatic devour on/off. - **Aswid**: Fixed a bug where devouring a mob would fail if the player was still in an attack or movement animation. diff --git a/manifest.json b/manifest.json index be40f26..171e78a 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.3.1", + "version_number": "1.3.4", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From c580871a2d7d604257b9f10c2e4794988c22ce69 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 08:49:55 +0200 Subject: [PATCH 013/429] Add execute mechanic to Vampiric Aura and bump version to 1.3.5 --- JotunnModStub/Aswid/AswidRace.cs | 6 +++ JotunnModStub/Skeleton/SkeletonPatches.cs | 59 +++++++++++++++++++++++ README.md | 3 ++ check_localization.cs | 29 +++++++++++ check_messagehud.cs | 42 ++++++++++++++++ manifest.json | 2 +- 6 files changed, 140 insertions(+), 1 deletion(-) create mode 100644 check_localization.cs create mode 100644 check_messagehud.cs diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index a1b78bd..c05235d 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -992,6 +992,7 @@ namespace RacesOfValheim hitAnything = true; float maxHp = c.GetMaxHealth(); + float currentHp = c.GetHealth(); float baseDamage = 1.0f; // Reduced by 50% float bloodMagicFactor = Player.m_localPlayer.GetSkillFactor(Skills.SkillType.BloodMagic); @@ -1002,6 +1003,11 @@ namespace RacesOfValheim totalDamage *= 0.5f; } + if (currentHp > 0 && currentHp <= maxHp * 0.20f && !c.IsBoss()) + { + totalDamage = currentHp * 2f; // Lethal damage for execute + } + HitData hd = new HitData(); hd.m_damage.m_damage = totalDamage; hd.m_point = c.GetCenterPoint(); diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index 25450e6..71b298b 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -48,6 +48,65 @@ namespace RacesOfValheim } } + [HarmonyPatch(typeof(MessageHud), "ShowMessage")] + public static class MessageHud_ShowMessage_Patch + { + private static System.Collections.Generic.Dictionary> messageTimestamps = new System.Collections.Generic.Dictionary>(); + private static System.Collections.Generic.Dictionary messageBans = new System.Collections.Generic.Dictionary(); + + public static bool Prefix(MessageHud __instance, MessageHud.MessageType type, string text) + { + if (Player.m_localPlayer != null && SkeletonRace.IsSkeleton()) + { + if (string.IsNullOrEmpty(text)) return true; + + // Exception for resting messages to never be filtered + string lowerText = text.ToLower(); + if (text == "$se_resting_name" || text == "$se_resting" || lowerText.Contains("resting") || lowerText.Contains("riposo")) + { + return true; + } + + float currentTime = Time.time; + + // Check if message is currently banned (4 hours = 14400 seconds) + if (messageBans.TryGetValue(text, out float banTime)) + { + if (currentTime - banTime < 14400f) + { + return false; // Still banned + } + else + { + messageBans.Remove(text); // Ban expired + if (messageTimestamps.ContainsKey(text)) + { + messageTimestamps[text].Clear(); // Reset spam count + } + } + } + + if (!messageTimestamps.ContainsKey(text)) + { + messageTimestamps[text] = new System.Collections.Generic.List(); + } + + // Remove timestamps older than 5 seconds + messageTimestamps[text].RemoveAll(t => currentTime - t > 5f); + + if (messageTimestamps[text].Count >= 2) + { + // Trigger a 4-hour ban + messageBans[text] = currentTime; + return false; + } + + messageTimestamps[text].Add(currentTime); + } + return true; + } + } + [HarmonyPatch(typeof(Player), "Message")] public static class Player_Message_Patch { diff --git a/README.md b/README.md index 25c34f0..a11dbdd 100644 --- a/README.md +++ b/README.md @@ -116,6 +116,9 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** ## Changelog +**v1.3.5** +- **Aswid**: Added an Execution mechanic to Blood Magic (Vampiric Aura): Non-boss enemies that fall below 20% health while inside the aura are instantly killed! + **v1.3.4** - **Aswid**: Refined the Aswid's diet. Restored Ashlands creatures (except undead like Charred and Morgen) and enabled a 4th stomach slot exclusively for Aswid prey. - **Aswid**: Added a keybind (I) to toggle the automatic devour on/off. diff --git a/check_localization.cs b/check_localization.cs new file mode 100644 index 0000000..8fd1bb4 --- /dev/null +++ b/check_localization.cs @@ -0,0 +1,29 @@ +using System; +using System.Reflection; + +public class Program +{ + public static void Main() + { + try + { + Assembly valheimAsm = Assembly.LoadFrom(@"c:\Users\FERDINANDO\Desktop\JotunnModStub-master\RacesOfValheim\libraries\assembly_valheim_publicized.dll"); + if (valheimAsm == null) + { + valheimAsm = Assembly.LoadFrom(@"c:\Users\FERDINANDO\Desktop\JotunnModStub-master\RacesOfValheim\JotunnModStub\bin\Debug\net48\assembly_valheim_publicized.dll"); + } + + foreach (var type in valheimAsm.GetTypes()) + { + if (type.Name.Contains("Localize") || type.Name.Contains("Localization")) + { + Console.WriteLine(type.FullName); + } + } + } + catch (Exception ex) + { + Console.WriteLine(ex); + } + } +} diff --git a/check_messagehud.cs b/check_messagehud.cs new file mode 100644 index 0000000..bfcbac4 --- /dev/null +++ b/check_messagehud.cs @@ -0,0 +1,42 @@ +using System; +using System.Reflection; + +public class Program +{ + public static void Main() + { + try + { + Assembly valheimAsm = Assembly.LoadFrom(@"c:\Users\FERDINANDO\Desktop\JotunnModStub-master\RacesOfValheim\libraries\assembly_valheim_publicized.dll"); + if (valheimAsm == null) + { + // try different path if not in libraries + valheimAsm = Assembly.LoadFrom(@"c:\Users\FERDINANDO\Desktop\JotunnModStub-master\RacesOfValheim\JotunnModStub\bin\Debug\net48\assembly_valheim_publicized.dll"); + } + + Type messageHudType = valheimAsm.GetType("MessageHud"); + if (messageHudType == null) { + Console.WriteLine("Could not find MessageHud type."); + return; + } + + foreach (var m in messageHudType.GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance | BindingFlags.Static)) + { + if (m.Name.Contains("Message")) + { + Console.Write(m.Name + "("); + var p = m.GetParameters(); + for (int i = 0; i < p.Length; i++) { + Console.Write(p[i].ParameterType.Name); + if (i < p.Length - 1) Console.Write(", "); + } + Console.WriteLine(")"); + } + } + } + catch (Exception ex) + { + Console.WriteLine(ex); + } + } +} diff --git a/manifest.json b/manifest.json index 171e78a..e364df6 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.4", + "version_number": "1.3.5", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From e31ed458bd48241bfcf9b4ba5b58188ffd1b9f59 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 08:56:59 +0200 Subject: [PATCH 014/429] Update execute logic to also automatically devour --- JotunnModStub/Aswid/AswidRace.cs | 1 + README.md | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index c05235d..a09b9d7 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -1006,6 +1006,7 @@ namespace RacesOfValheim if (currentHp > 0 && currentHp <= maxHp * 0.20f && !c.IsBoss()) { totalDamage = currentHp * 2f; // Lethal damage for execute + TryConsumeMob(c, maxHp); // Automatically devour when executed } HitData hd = new HitData(); diff --git a/README.md b/README.md index a11dbdd..bccb2ad 100644 --- a/README.md +++ b/README.md @@ -117,7 +117,7 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** ## Changelog **v1.3.5** -- **Aswid**: Added an Execution mechanic to Blood Magic (Vampiric Aura): Non-boss enemies that fall below 20% health while inside the aura are instantly killed! +- **Aswid**: Added an Execution mechanic to Blood Magic (Vampiric Aura): Non-boss enemies that fall below 20% health while inside the aura are instantly killed and automatically devoured! **v1.3.4** - **Aswid**: Refined the Aswid's diet. Restored Ashlands creatures (except undead like Charred and Morgen) and enabled a 4th stomach slot exclusively for Aswid prey. From 152a2f21adb9e2d4e25a8b4f1272a3a1ff1476f0 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 09:24:07 +0200 Subject: [PATCH 015/429] Add extra debug logs for Aura execute and consume --- JotunnModStub/Aswid/AswidRace.cs | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index a09b9d7..2fbd363 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -1005,8 +1005,13 @@ namespace RacesOfValheim if (currentHp > 0 && currentHp <= maxHp * 0.20f && !c.IsBoss()) { + Jotunn.Logger.LogInfo($"[AswidDebug] Aura Execution TRIGGERED on {c.name}! HP: {currentHp}/{maxHp}"); totalDamage = currentHp * 2f; // Lethal damage for execute - TryConsumeMob(c, maxHp); // Automatically devour when executed + TryConsumeMob(c, maxHp, true); // Automatically devour when executed, bypassing cooldown + } + else + { + Jotunn.Logger.LogInfo($"[AswidDebug] Aura normal tick on {c.name}. HP: {currentHp}/{maxHp}"); } HitData hd = new HitData(); @@ -1028,12 +1033,12 @@ namespace RacesOfValheim public static bool DevourEnabled = true; private static float lastConsumeTime = 0f; - public static void TryConsumeMob(Character c, float maxHp) + public static void TryConsumeMob(Character c, float maxHp, bool bypassCooldown = false) { if (!DevourEnabled) return; Jotunn.Logger.LogInfo($"[AswidDebug] TryConsumeMob called for {c.name}"); - if (Time.time - lastConsumeTime < 5f) + if (!bypassCooldown && Time.time - lastConsumeTime < 5f) { Jotunn.Logger.LogInfo($"[AswidDebug] TryConsumeMob aborted: Cooldown active. Time.time={Time.time}, lastConsumeTime={lastConsumeTime}"); return; // Cooldown active From 6170c060ac7e110690785d752f91986e62a8e3b0 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 09:27:07 +0200 Subject: [PATCH 016/429] Add force-feed fallback to TryConsumeMob to bypass stomach limits on execute --- JotunnModStub/Aswid/AswidRace.cs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 2fbd363..2610425 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -1085,6 +1085,28 @@ namespace RacesOfValheim // If stomach is full, EatFood fails, UseItem does not consume the item, and virtualInv is destroyed (disintegrated) AswidRace.BypassAswidFoodCheck = true; bool successfullyEaten = Player.m_localPlayer.EatFood(addedItem); + + // Force-feed logic for aura executions + if (!successfullyEaten && bypassCooldown) + { + var m_foods = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_foods").GetValue>(); + if (m_foods != null) + { + Player.Food existing = m_foods.Find(f => f.m_item.m_shared.m_name == addedItem.m_shared.m_name); + if (existing != null) + { + m_foods.Remove(existing); + } + else if (m_foods.Count >= 3) + { + m_foods.Sort((a, b) => (b.m_time / b.m_item.m_shared.m_foodBurnTime).CompareTo(a.m_time / a.m_item.m_shared.m_foodBurnTime)); + m_foods.RemoveAt(0); // Remove the most digested food + } + successfullyEaten = Player.m_localPlayer.EatFood(addedItem); + Jotunn.Logger.LogInfo($"[AswidDebug] Force-feed attempted. Result: {successfullyEaten}"); + } + } + AswidRace.BypassAswidFoodCheck = false; if (successfullyEaten) From ad74ca32195e3ced8ccd7cc5044428baca4c8d4d Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 09:31:43 +0200 Subject: [PATCH 017/429] Revert force-feed logic to respect Aswid stomach limitations --- JotunnModStub/Aswid/AswidRace.cs | 22 ---------------------- 1 file changed, 22 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 2610425..2fbd363 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -1085,28 +1085,6 @@ namespace RacesOfValheim // If stomach is full, EatFood fails, UseItem does not consume the item, and virtualInv is destroyed (disintegrated) AswidRace.BypassAswidFoodCheck = true; bool successfullyEaten = Player.m_localPlayer.EatFood(addedItem); - - // Force-feed logic for aura executions - if (!successfullyEaten && bypassCooldown) - { - var m_foods = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_foods").GetValue>(); - if (m_foods != null) - { - Player.Food existing = m_foods.Find(f => f.m_item.m_shared.m_name == addedItem.m_shared.m_name); - if (existing != null) - { - m_foods.Remove(existing); - } - else if (m_foods.Count >= 3) - { - m_foods.Sort((a, b) => (b.m_time / b.m_item.m_shared.m_foodBurnTime).CompareTo(a.m_time / a.m_item.m_shared.m_foodBurnTime)); - m_foods.RemoveAt(0); // Remove the most digested food - } - successfullyEaten = Player.m_localPlayer.EatFood(addedItem); - Jotunn.Logger.LogInfo($"[AswidDebug] Force-feed attempted. Result: {successfullyEaten}"); - } - } - AswidRace.BypassAswidFoodCheck = false; if (successfullyEaten) From 225b7115bc1a4e02281327fc907a9b39d4d63d96 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 09:35:15 +0200 Subject: [PATCH 018/429] Allow Aswid stomach to refresh blinking duplicate foods when slots are fully occupied --- JotunnModStub/Aswid/AswidPatches.cs | 48 ++++++++++++++++++++++++++++- 1 file changed, 47 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index e8ee699..3909259 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -297,7 +297,25 @@ namespace RacesOfValheim } else { - __result = false; // Nessuno spazio disponibile, cibo si disintegra + bool canRefresh = false; + foreach (object foodObj in foods) + { + Player.Food f = foodObj as Player.Food; + if (f != null && f.m_item.m_shared.m_name == item.m_shared.m_name && f.CanEatAgain()) + { + canRefresh = true; + break; + } + } + + if (canRefresh) + { + __result = true; + } + else + { + __result = false; // Nessuno spazio disponibile, cibo si disintegra + } } } else @@ -353,6 +371,34 @@ namespace RacesOfValheim } } + bool refreshed = false; + foreach (object foodObj in m_foods) + { + 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); + + refreshed = true; + break; + } + } + + if (refreshed) + { + __result = true; + return false; + } + // Se pieno e senza 4° slot disponibile, fallisce e disintegra __result = false; return false; From ff9fc4db2dedb21db3118734c7bf2bd58a39dc62 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 09:42:07 +0200 Subject: [PATCH 019/429] Bind Taming ability to K key instead of E --- JotunnModStub/Aswid/AswidPatches.cs | 33 +-------------------------- JotunnModStub/Aswid/AswidRace.cs | 35 +++++++++++++++++++++++++++++ 2 files changed, 36 insertions(+), 32 deletions(-) diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 3909259..7318ab6 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -459,42 +459,11 @@ namespace RacesOfValheim if (canTame) { - __result += "\n[] Tame"; + __result += "\n[K] Tame"; } } } - [HarmonyPatch(typeof(Tameable), "Interact")] - public static class Aswid_TameInteract_Patch - { - public static bool Prefix(Tameable __instance, Humanoid user, bool hold, bool alt) - { - if (hold || alt) return true; - if (user != Player.m_localPlayer || !AswidRace.IsAswid()) return true; - if (__instance.GetComponent()?.IsTamed() == true) return true; - - string prefabName = __instance.gameObject.name.ToLower(); - int state = BossProgressionManager.GetCurrentProgressionState(); - - bool canTame = false; - if (state >= 2 && prefabName.Contains("boar")) canTame = true; - if (state >= 5 && prefabName.Contains("wolf")) canTame = true; - if (state >= 6 && prefabName.Contains("lox")) canTame = true; - if (state >= 8 && prefabName.Contains("asksvin")) canTame = true; - - if (canTame) - { - __instance.GetComponent()?.SetTamed(true); - HarmonyLib.Traverse.Create(__instance).Method("Tame").GetValue(); // attempt to call Tame for VFX if it exists - __instance.Command(user); - user.Message(MessageHud.MessageType.Center, "Tamed!"); - return false; // Skip original interact - } - - return true; - } - } - [HarmonyPatch(typeof(Hud), "UpdateStamina")] public static class Aswid_HideStamina_Patch { diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 2fbd363..b1e7304 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -512,6 +512,11 @@ namespace RacesOfValheim TryCastEclipse(state); return; } + if (Input.GetKeyDown(KeyCode.K)) + { + TryTameHoverObject(state); + return; + } } // Auto revert mist form at sunrise @@ -848,6 +853,36 @@ namespace RacesOfValheim yield return null; } + private void TryTameHoverObject(int state) + { + GameObject hoverObject = Player.m_localPlayer.GetHoverObject(); + if (hoverObject != null) + { + Tameable tameable = hoverObject.GetComponentInParent(); + if (tameable != null) + { + Character c = tameable.GetComponent(); + if (c != null && !c.IsTamed()) + { + string prefabName = c.gameObject.name.ToLower(); + bool canTame = false; + if (state >= 2 && prefabName.Contains("boar")) canTame = true; + if (state >= 5 && prefabName.Contains("wolf")) canTame = true; + if (state >= 6 && prefabName.Contains("lox")) canTame = true; + if (state >= 8 && prefabName.Contains("asksvin")) canTame = true; + + if (canTame) + { + 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!"); + } + } + } + } + } + private void TryCastEclipse(int state) { if (state < 6) return; // Requires Yagluth From 6ec621a50beb0409d66795ffb3cc23384b4678f8 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 09:47:05 +0200 Subject: [PATCH 020/429] Update README and manifest for version 1.3.6 --- README.md | 5 ++++- manifest.json | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index bccb2ad..45f92d1 100644 --- a/README.md +++ b/README.md @@ -116,8 +116,11 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** ## Changelog -**v1.3.5** +**v1.3.6** - **Aswid**: Added an Execution mechanic to Blood Magic (Vampiric Aura): Non-boss enemies that fall below 20% health while inside the aura are instantly killed and automatically devoured! +- **Aswid**: The Vampiric Aura's devour execution now flawlessly respects the Aswid's custom stomach limitations, including the ability to silently refresh duplicate blinking buffs when slots are fully occupied. +- **Aswid**: The Taming ability has been moved from the generic Interact key (E) to a dedicated keybind (K) to prevent accidental taming while interacting with the world. +- **Skeleton**: Implemented a smart anti-spam filter for HUD messages. This prevents continuous text spam (like repeating passive effects) by blocking repetitive messages for 4 hours, while specifically exempting crucial system messages like 'Resting'. **v1.3.4** - **Aswid**: Refined the Aswid's diet. Restored Ashlands creatures (except undead like Charred and Morgen) and enabled a 4th stomach slot exclusively for Aswid prey. diff --git a/manifest.json b/manifest.json index e364df6..bfaab32 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.5", + "version_number": "1.3.6", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 19de5ef0dfead3458fe092d7c7b442f6c9b6f7d4 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 09:48:40 +0200 Subject: [PATCH 021/429] Revert version bump to 1.3.5 and append changelog --- README.md | 2 +- manifest.json | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 45f92d1..71df61d 100644 --- a/README.md +++ b/README.md @@ -116,7 +116,7 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** ## Changelog -**v1.3.6** +**v1.3.5** - **Aswid**: Added an Execution mechanic to Blood Magic (Vampiric Aura): Non-boss enemies that fall below 20% health while inside the aura are instantly killed and automatically devoured! - **Aswid**: The Vampiric Aura's devour execution now flawlessly respects the Aswid's custom stomach limitations, including the ability to silently refresh duplicate blinking buffs when slots are fully occupied. - **Aswid**: The Taming ability has been moved from the generic Interact key (E) to a dedicated keybind (K) to prevent accidental taming while interacting with the world. diff --git a/manifest.json b/manifest.json index bfaab32..e364df6 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.6", + "version_number": "1.3.5", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 73da3bacd3532f2841b575c49c9edddb6313e1b6 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Fri, 31 Jul 2026 09:52:30 +0200 Subject: [PATCH 022/429] Update Skeleton changelog entry with flavor text --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71df61d..d344612 100644 --- a/README.md +++ b/README.md @@ -120,7 +120,7 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** - **Aswid**: Added an Execution mechanic to Blood Magic (Vampiric Aura): Non-boss enemies that fall below 20% health while inside the aura are instantly killed and automatically devoured! - **Aswid**: The Vampiric Aura's devour execution now flawlessly respects the Aswid's custom stomach limitations, including the ability to silently refresh duplicate blinking buffs when slots are fully occupied. - **Aswid**: The Taming ability has been moved from the generic Interact key (E) to a dedicated keybind (K) to prevent accidental taming while interacting with the world. -- **Skeleton**: Implemented a smart anti-spam filter for HUD messages. This prevents continuous text spam (like repeating passive effects) by blocking repetitive messages for 4 hours, while specifically exempting crucial system messages like 'Resting'. +- **Skeleton**: Finally removed the 'you could eat another bite' message! It now only appears occasionally to remind you of what the food of the living was like. **v1.3.4** - **Aswid**: Refined the Aswid's diet. Restored Ashlands creatures (except undead like Charred and Morgen) and enabled a 4th stomach slot exclusively for Aswid prey. From 95dcf3c1e64d166cf62b4028d5d1ad0122152753 Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 31 Jul 2026 11:24:30 +0200 Subject: [PATCH 023/429] Fix build portability: add BepInEx NuGet feed and de-hardcode package paths BepInEx.Core isn't on nuget.org (only on nuget.bepinex.dev), so restore failed on machines without it configured globally. PackageThunderstore also pointed at a contributor's personal desktop path; it now outputs to a repo-local dist/ folder and uses the checked-in Package/icon.png. Co-Authored-By: Claude Sonnet 5 --- JotunnModStub/RacesOfValheim.csproj | 12 ++++++++---- NuGet.Config | 7 +++++++ 2 files changed, 15 insertions(+), 4 deletions(-) create mode 100644 NuGet.Config diff --git a/JotunnModStub/RacesOfValheim.csproj b/JotunnModStub/RacesOfValheim.csproj index 7122411..6029e4c 100644 --- a/JotunnModStub/RacesOfValheim.csproj +++ b/JotunnModStub/RacesOfValheim.csproj @@ -93,11 +93,15 @@ - + + + $(SolutionDir)dist\ + + - - - + + + diff --git a/NuGet.Config b/NuGet.Config new file mode 100644 index 0000000..d5f366b --- /dev/null +++ b/NuGet.Config @@ -0,0 +1,7 @@ + + + + + + + From 00b1b4e9ed126fd54fda21346f21d7b058379f16 Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 31 Jul 2026 13:04:30 +0200 Subject: [PATCH 024/429] Fix Skadi resetrace, cold spell VFX, and Freezing-to-Cold conversion - resetrace never cleaned up SE_SkadiStats/SE_SkadiCooldown, so Skadi's Aura and its frost buffs stuck around after switching race. - Cold Spell projectile spawned near the feet (0.4m) and used the unarmed kick animation; now spawns at chest height and uses the galdr_cast (raised-arms) trigger instead. - Freezing-to-Cold silently did nothing from tier 1 onward: Skadi's passive Frost damage resistance made Valheim's own environmental check skip Cold/Freezing entirely before our conversion patch ever ran. Added a scoped patch that neutralizes just that environmental check for the local Skadi player, plus a guard against Valheim's own Cold-removal call flickering the converted status off every other frame, plus an explicit cleanup of any real Freezing left over from before the conversion kicked in. Co-Authored-By: Claude Sonnet 5 --- JotunnModStub/RacesOfValheim.cs | 2 + JotunnModStub/Skadi/SkadiPatches.cs | 71 +++++++++++++++++++++++++++++ JotunnModStub/Skadi/SkadiRace.cs | 17 +++---- 3 files changed, 82 insertions(+), 8 deletions(-) diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 079e3b1..9b99d9f 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -600,6 +600,8 @@ namespace RacesOfValheim Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_FenrirCurse".GetStableHashCode()); Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_AswidStats".GetStableHashCode()); Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkeletonStats".GetStableHashCode()); + Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkadiStats".GetStableHashCode()); + Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_SkadiCooldown".GetStableHashCode()); ZNetView nview = Player.m_localPlayer.GetComponent(); if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human"); diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 3b35c9a..e79121c 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -98,6 +98,10 @@ namespace RacesOfValheim if (rules.FreezingToCold) { + // Strip any real Freezing that may already be active (e.g. applied + // before this tier's conversion kicked in) so it can't linger + // alongside the converted Cold status. + __instance.RemoveStatusEffect("Freezing".GetStableHashCode(), true); nameHash = "Cold".GetStableHashCode(); } } @@ -106,6 +110,73 @@ namespace RacesOfValheim } } + // SE_SkadiStats grants a "Resistant" (or higher) Frost damage modifier from tier 1 onward, + // exactly like drinking a Frost Resistance potion. Valheim's own Player.UpdateEnvStatusEffects + // checks that same Frost damage modifier before deciding whether to apply Cold/Freezing at + // all, and skips both entirely once the character is Frost-resistant. That means real Mountain + // exposure (which applies Freezing, not Cold, per vanilla rules) never even reaches + // SkadiSEManPatch above from tier 1 onward, so the tier 2 "Freezing to Cold" conversion never + // gets a chance to run. These two patches scope out just that one environmental check: while + // Player.UpdateEnvStatusEffects is running for the local Skadi player, GetDamageModifiers is + // reported as Normal for Frost, so vanilla always attempts to apply the real status and + // SkadiSEManPatch's per-tier logic (block/convert/allow) is what actually decides the outcome. + // Frost damage resistance from hits (SkadiDamagePatch) is untouched by this. + [HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")] + public static class SkadiEnvCheckScope + { + public static bool Active = false; + + public static void Prefix(Player __instance) + { + Active = __instance == Player.m_localPlayer && SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi(); + } + + public static void Postfix() + { + Active = false; + } + } + + [HarmonyPatch(typeof(Character), "GetDamageModifiers")] + public static class SkadiEnvFrostModifierPatch + { + public static void Postfix(Character __instance, ref HitData.DamageModifiers __result) + { + if (SkadiEnvCheckScope.Active && __instance == Player.m_localPlayer) + { + __result.m_frost = HitData.DamageModifier.Normal; + } + } + } + + // Valheim's Player.UpdateEnvStatusEffects always tries RemoveStatusEffect(Cold, quiet:true) + // as the first step of applying Freezing. Since SkadiSEManPatch redirects Freezing into Cold, + // that removal would strip our converted Cold status every other frame (a permanent + // add/remove flicker that cancels the buff out). Blocking just this "quiet" removal for the + // FreezingToCold player forces Valheim to always fall through to AddStatusEffect(Freezing,...), + // which SkadiSEManPatch converts to a stable, non-resetting Cold re-application instead. + [HarmonyPatch(typeof(SEMan), "RemoveStatusEffect", new System.Type[] { typeof(int), typeof(bool) })] + public static class SkadiColdRemovalGuardPatch + { + public static bool Prefix(SEMan __instance, int nameHash, bool quiet, ref bool __result) + { + if (quiet && nameHash == "Cold".GetStableHashCode()) + { + Character character = Traverse.Create(__instance).Field("m_character").Value; + if (character == Player.m_localPlayer && SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi()) + { + var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState()); + if (rules.FreezingToCold && !rules.ImmuneToFreezing) + { + __result = false; + return false; + } + } + } + return true; + } + } + [HarmonyPatch(typeof(Character), "ApplyDamage")] public static class SkadiDamagePatch { diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index ca23977..4d5d5bd 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -230,7 +230,7 @@ namespace RacesOfValheim if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return; if (isTransformed) return; // Do not cast human spell while in dragon form - // Middle Mouse Button to cast (Kick) + // Middle Mouse Button to cast if (Input.GetMouseButtonDown(2)) { float cooldown = rules.ImprovedColdSpell ? 2.0f : 1.5f; @@ -246,10 +246,11 @@ namespace RacesOfValheim lastSpellTime = Time.time; var zanim = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_zanim").Value; - if (zanim != null) + if (zanim != null) { - // Forcing secondary attack trigger, which is kick when unarmed - zanim.SetTrigger("secondary"); + // Raised-arms Galdr cast gesture instead of the unarmed kick, so the cast + // reads as a spell instead of a leg swing near the ground. + zanim.SetTrigger("galdr_cast"); } StartCoroutine(ColdSpellKickCoroutine(rules)); @@ -258,7 +259,7 @@ namespace RacesOfValheim private IEnumerator ColdSpellKickCoroutine(SkadiProgression.FormRules rules) { - // Wait for the kick animation to reach the extension point + // Wait for the cast animation to reach the release point yield return new WaitForSeconds(0.4f); if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) yield break; @@ -287,16 +288,16 @@ namespace RacesOfValheim { if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) break; - // Spawn from the foot (low position, forward) + // Spawn from chest height, forward Vector3 lookDir = Player.m_localPlayer.GetLookDir(); - + // Add a small spread for the improved blast if (rules.ImprovedColdSpell && i > 0) { lookDir = Quaternion.Euler(UnityEngine.Random.Range(-5f, 5f), UnityEngine.Random.Range(-5f, 5f), 0f) * lookDir; } - Vector3 spawnPos = Player.m_localPlayer.transform.position + Vector3.up * 0.4f + lookDir * 0.6f; + Vector3 spawnPos = Player.m_localPlayer.transform.position + Vector3.up * 1.4f + lookDir * 0.6f; GameObject projInstance = Instantiate(projPrefab, spawnPos, Quaternion.LookRotation(lookDir)); From cccabe16ef167af70c9d8225453e6dc7017befec Mon Sep 17 00:00:00 2001 From: kanym Date: Fri, 31 Jul 2026 16:25:06 +0200 Subject: [PATCH 025/429] Rework Skadi dragon flight, enforce form duration, surface timers in HUD Flight ran on the debug-fly noclip, so it ignored aim entirely and needed Space/Ctrl for height. It now uses Character's native flying-creature movement with the camera's full look direction fed in each frame: - Aim steers, including climb and dive; W powers forward, releasing it holds level briefly and then settles into a glide instead of coasting along the aim vector (which let you climb forever without input). - The body actually turns now. m_flyTurnSpeed sat at Character's 12 deg/s default because the Player prefab was never set up to fly, so a quarter turn took over seven seconds and read as no rotation at all. - Touching down no longer slides you forward forever. Zeroing the fly speeds stops the character without fighting the AddForce UpdateFlying queues, which had caused frame-to-frame jitter and TAA ghosting. DurationMinutes was never wired to anything, so timed forms never expired and their cooldown, which only starts on reversion, was unreachable in practice. Timed forms now drop on their own, and both the remaining time and the cooldown show up beside the minimap as a Moder trophy icon. Attack capability was snapshotted when the form was entered, so reaching the Bonemass tier while already transformed left the drake unarmed until the player reverted and transformed again; it is re-read live now. --- JotunnModStub/Skadi/DrakeFormBehavior.cs | 49 ++++++++++++--- JotunnModStub/Skadi/SkadiPatches.cs | 73 +++++++++++++++++++++++ JotunnModStub/Skadi/SkadiRace.cs | 69 ++++++++++++++++++--- JotunnModStub/Skadi/SkadiStatusEffects.cs | 6 ++ README.md | 19 +++--- 5 files changed, 194 insertions(+), 22 deletions(-) diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index 53a4122..75a6a6e 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -6,11 +6,21 @@ namespace RacesOfValheim { public class DrakeFormBehavior : MonoBehaviour { + // Single active instance, read by SkadiDirectedFlightPatch to feed a + // look-direction-based m_moveDir into Character.UpdateFlying every frame. + public static DrakeFormBehavior Active { get; private set; } + private Animator anim; private bool isFlying = false; private bool isLanding = false; private float lastAttackTime = 0f; - + + public bool IsFlying => isFlying; + + // Time.time of the last powered/grounded moment. SkadiDirectedFlightPatch holds the form + // level for a short window past this before letting it start sinking. + public float LastPoweredTime; + private SkadiProgression.FormRules formRules; public void Initialize(SkadiProgression.FormRules rules) @@ -18,15 +28,37 @@ namespace RacesOfValheim this.formRules = rules; } + // formRules is a snapshot taken when the form was entered, so a progression change while + // still transformed (defeating a boss, or the increaseprogression debug command) wouldn't + // grant the attack until the player reverted and transformed again. Re-read the rules for + // the form we're currently in so the unlock applies as soon as the tier is reached. + private bool CanAttackNow() + { + if (formRules == null) return false; + + int state = BossProgressionManager.GetCurrentProgressionState(); + SkadiProgression.FormRules live = null; + + switch (formRules.Form) + { + case SkadiProgression.FormType.Drake: live = SkadiProgression.GetGKeyRules(state); break; + case SkadiProgression.FormType.Moder: live = SkadiProgression.GetHKeyRules(state); break; + case SkadiProgression.FormType.SkeletonDragon: live = SkadiProgression.GetJKeyRules(state); break; + } + + return live != null && live.Form == formRules.Form && live.CanAttackInForm; + } + private const float ATTACK_COST = 20f; private const float ATTACK_COOLDOWN = 3f; private void Start() { + Active = this; anim = GetComponentInChildren(); if (Player.m_localPlayer != null) { - HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(false); + HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_flying").SetValue(false); } } @@ -40,20 +72,22 @@ namespace RacesOfValheim if (!isFlying && !isLanding) { isFlying = true; - HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(true); + LastPoweredTime = Time.time; + HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_flying").SetValue(true); } else if (isFlying && !isLanding) { isLanding = true; isFlying = false; - HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(false); + HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_flying").SetValue(false); } else if (isLanding) { // Cancel landing, resume flight isLanding = false; isFlying = true; - HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(true); + LastPoweredTime = Time.time; + HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_flying").SetValue(true); } } @@ -88,7 +122,7 @@ namespace RacesOfValheim } // Handle Attack - if (formRules != null && formRules.CanAttackInForm) + if (CanAttackNow()) { if (Input.GetMouseButtonDown(0)) { @@ -345,9 +379,10 @@ namespace RacesOfValheim private void OnDestroy() { + if (Active == this) Active = null; if (Player.m_localPlayer != null) { - HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(false); + HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_flying").SetValue(false); } } } diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index e79121c..7675048 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -200,6 +200,79 @@ namespace RacesOfValheim + // DrakeFormBehavior flips the player into Character's native flying-creature movement + // (m_flying = true) instead of the old debug-fly noclip, which lets us feed it a full 3D + // move direction. Character.UpdateFlying normally reads whatever m_moveDir the vanilla input + // pipeline last wrote (ground-plane WASD relative to camera yaw only); this patch overwrites + // it every frame with the camera's actual look direction (pitch included) so the player always + // glides toward wherever the mouse is aiming, with W adding a speed boost (m_run) on top of the + // base glide speed instead of being required just to move. + [HarmonyPatch(typeof(Character), "UpdateFlying")] + public static class SkadiDirectedFlightPatch + { + private const float TURN_SPEED = 120f; + private const float GLIDE_SPEED = 5f; + private const float BOOST_SPEED = 12f; + private const float HOVER_SECONDS = 2f; + // Tangent of the unpowered descent angle: 0.4 sinks at roughly 22 degrees below level. + private const float DESCENT_SLOPE = 0.4f; + + public static void Prefix(Character __instance) + { + if (__instance != Player.m_localPlayer) return; + + DrakeFormBehavior form = DrakeFormBehavior.Active; + if (form == null || !form.IsFlying) return; + + var traverse = Traverse.Create(__instance); + Vector3 lookDir = Player.m_localPlayer.GetLookDir(); + bool boost = Input.GetKey(KeyCode.W); + bool onGround = __instance.IsOnGround(); + + traverse.Field("m_run").SetValue(boost); + traverse.Field("m_flyFastSpeed").SetValue(BOOST_SPEED); + + // UpdateFlying rotates the body toward m_moveDir on its own, but at m_flyTurnSpeed, + // which sits at Character's 12 deg/s default because the Player prefab was never set + // up as a flying creature - a 90 degree turn would take over seven seconds, so the + // model reads as not turning at all. Give it a speed that suits a flying mount. + traverse.Field("m_flyTurnSpeed").SetValue(TURN_SPEED); + + // Powered flight and ground contact both refresh the hover window. + if (boost || onGround) form.LastPoweredTime = Time.time; + + Vector3 moveDir = lookDir; + float coastSpeed; + + if (onGround || Time.time - form.LastPoweredTime < HOVER_SECONDS) + { + // Holding station: on the ground this keeps a touchdown from sliding the player + // forward forever, and in the air it gives the beat of level flight before the + // form starts to sink. m_moveDir stays full length so the body still turns to + // face the camera, and zeroing the speed (rather than the rigidbody velocity) + // avoids fighting the AddForce UpdateFlying queues, which caused visible jitter. + coastSpeed = 0f; + } + else + { + // Unpowered flight is a glide, not a hover with a joystick: drift along the + // heading the camera faces while losing height, so aiming at the sky without + // holding W no longer climbs. + Vector3 heading = new Vector3(lookDir.x, 0f, lookDir.z); + if (heading.sqrMagnitude < 0.0001f) + { + heading = __instance.transform.forward; + heading.y = 0f; + } + moveDir = (heading.normalized + Vector3.down * DESCENT_SLOPE).normalized; + coastSpeed = GLIDE_SPEED; + } + + traverse.Field("m_moveDir").SetValue(moveDir); + traverse.Field("m_flySlowSpeed").SetValue(coastSpeed); + } + } + [HarmonyPatch(typeof(Humanoid), "StartAttack")] public static class SkadiAttackPatch { diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 4d5d5bd..071dac5 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -11,6 +11,7 @@ namespace RacesOfValheim public static SkadiRace Instance; public static SE_SkadiStats skadiCurseSE; public static SE_FormCooldown skadiCdSE; + public static SE_SkadiForm skadiFormSE; private float auraTimer = 0f; private float lastSpellTime = 0f; @@ -18,6 +19,8 @@ namespace RacesOfValheim private bool isTransformed = false; private bool isTransformingSequence = false; private SkadiProgression.FormRules activeRules = null; + // Time.time at which a timed form drops; 0 means the current form has no time limit. + private float formExpireTime = 0f; private float lastAuraTime = 0f; private GameObject frostAuraVFX = null; @@ -47,18 +50,33 @@ namespace RacesOfValheim ItemManager.Instance.AddStatusEffect(skadiStats); skadiCurseSE = skadiStats.StatusEffect as SE_SkadiStats; + // Timed forms and their cooldown are Moder's, so they carry her trophy rather than the + // drake one used for the passive blessing. + Sprite dragonIcon = GetTrophyIcon("TrophyDragonQueen") ?? GetTrophyIcon("TrophyHatchling"); + skadiCdSE = ScriptableObject.CreateInstance(); skadiCdSE.name = "SE_SkadiCooldown"; skadiCdSE.m_name = "Dragon Form Cooldown"; - if (drakeTrophy != null) - { - ItemDrop trophyDrop = drakeTrophy.GetComponent(); - if (trophyDrop != null && trophyDrop.m_itemData.m_shared.m_icons.Length > 0) - { - skadiCdSE.m_icon = trophyDrop.m_itemData.m_shared.m_icons[0]; - } - } + 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_icon = dragonIcon; + ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(skadiFormSE, fixReference: false)); + } + + private static Sprite GetTrophyIcon(string prefabName) + { + GameObject trophy = PrefabManager.Cache.GetPrefab(prefabName)?.gameObject; + ItemDrop drop = trophy != null ? trophy.GetComponent() : null; + if (drop != null && drop.m_itemData.m_shared.m_icons.Length > 0) + { + return drop.m_itemData.m_shared.m_icons[0]; + } + return null; } @@ -139,6 +157,16 @@ namespace RacesOfValheim if (isTransformingSequence) return; + // Forms with a DurationMinutes budget drop on their own once it runs out, which is + // also what starts their cooldown - without this the timed tiers never expired. + if (isTransformed && formExpireTime > 0f && Time.time >= formExpireTime) + { + formExpireTime = 0f; + Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Your dragon form fades."); + StartCoroutine(RevertToHumanRoutine()); + return; + } + int state = BossProgressionManager.GetCurrentProgressionState(); if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(SkadiProgression.GetGKeyRules(state)); return; } if (Input.GetKeyDown(KeyCode.H)) { TryTransformWithRules(SkadiProgression.GetHKeyRules(state)); return; } @@ -589,10 +617,33 @@ namespace RacesOfValheim else if (prefabName == "Fader") Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You are Fader!"); isTransformed = true; + StartFormTimer(rules); } } } + // Drives both the expiry check in Update and the HUD icon: the status effect exists purely + // so Valheim draws Moder's trophy with its own countdown next to the minimap. + private void StartFormTimer(SkadiProgression.FormRules rules) + { + int hash = "SE_SkadiForm".GetStableHashCode(); + SEMan seman = Player.m_localPlayer.GetSEMan(); + seman.RemoveStatusEffect(hash, true); + + if (rules.DurationMinutes <= 0f) + { + formExpireTime = 0f; + return; + } + + float seconds = rules.DurationMinutes * 60f; + formExpireTime = Time.time + seconds; + + seman.AddStatusEffect(hash, true); + StatusEffect se = seman.GetStatusEffect(hash); + if (se != null) se.m_ttl = seconds; + } + private void ExecuteReversion() { Transform playerVisual = Player.m_localPlayer.transform.Find("Visual"); @@ -615,6 +666,8 @@ 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."); if (activeRules != null && activeRules.CooldownMinutes > 0) diff --git a/JotunnModStub/Skadi/SkadiStatusEffects.cs b/JotunnModStub/Skadi/SkadiStatusEffects.cs index 536e8de..b6517af 100644 --- a/JotunnModStub/Skadi/SkadiStatusEffects.cs +++ b/JotunnModStub/Skadi/SkadiStatusEffects.cs @@ -4,6 +4,12 @@ using UnityEngine; namespace RacesOfValheim { + // Timed dragon forms. m_ttl is set when the form is entered, which is all Valheim needs to + // render the countdown: StatusEffect.GetIconText() prints the remaining time by itself. + public class SE_SkadiForm : StatusEffect + { + } + public class SE_SkadiStats : SE_Stats { public override void Setup(Character character) diff --git a/README.md b/README.md index 3132ba0..813b42e 100644 --- a/README.md +++ b/README.md @@ -81,13 +81,18 @@ This mod currently introduces 6 custom races: ### Skadi Progression - **Base (No Bosses)**: Immune to Cold, Bonus Frost Damage, 50% Frost Resistance. -- **Eikthyr**: +20% Eitr Regen, Freezing to Cold, Cold Spell. -- **The Elder**: Drake Form (Cannot attack). -- **Bonemass**: Drake Form (Can attack). -- **Moder**: Moder Form (1 min duration, 10 min cooldown). -- **Yagluth**: Improved Cold Spell. Moder Form (1 min duration, 5 min cooldown). -- **The Queen**: Moder Form (Unlimited duration, no cooldown). -- **Fader**: Skeleton Dragon Form. +- **Eikthyr**: +20% Eitr Regen, Freezing to Cold, Cold Spell (Middle Mouse). +- **The Elder**: Drake Form ('G' Key) (Cannot attack). +- **Bonemass**: Drake Form ('G' Key) (Can attack). +- **Moder**: Moder Form ('H' Key) (1 min duration, 10 min cooldown). +- **Yagluth**: Improved Cold Spell. Moder Form ('H' Key) (1 min duration, 5 min cooldown). +- **The Queen**: Moder Form ('H' Key) (Unlimited duration, no cooldown). +- **Fader**: Skeleton Dragon Form ('J' Key). + +While transformed, Right Mouse toggles flight. You glide toward wherever you are aiming; hold W +to power forward and climb. Let go and the form holds level for a couple of seconds before +settling into a gentle descent. Timed forms show their remaining seconds, and their cooldown, +as a Moder trophy icon beside the minimap. ### Skeleton Progression - **Base (No Bosses)**: +50 Max Health. Undead Diet (Cannot eat mortal food, no stamina bar). From d387131086ea63e6d92d547998733c83c405dc0a Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sat, 1 Aug 2026 13:17:13 +0200 Subject: [PATCH 026/429] start draugh race --- JotunnModStub/Aswid/AswidPatches.cs | 2 +- JotunnModStub/Aswid/AswidRace.cs | 6 +- JotunnModStub/Draugh/DraughFoodPatches.cs | 180 ++++++++++++++++++++++ JotunnModStub/Draugh/DraughPatches.cs | 119 ++++++++++++++ JotunnModStub/Draugh/DraughRace.cs | 162 +++++++++++++++++++ JotunnModStub/RacesOfValheim.cs | 67 ++++++-- JotunnModStub/Skeleton/SkeletonPatches.cs | 2 +- 7 files changed, 522 insertions(+), 16 deletions(-) create mode 100644 JotunnModStub/Draugh/DraughFoodPatches.cs create mode 100644 JotunnModStub/Draugh/DraughPatches.cs create mode 100644 JotunnModStub/Draugh/DraughRace.cs diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 7318ab6..a65bcef 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -469,7 +469,7 @@ namespace RacesOfValheim { public static bool Prefix(Hud __instance, Player player) { - if (player == Player.m_localPlayer && AswidRace.IsAswid()) + if (player == Player.m_localPlayer && (AswidRace.IsAswid() || DraughRace.IsDraugh())) { if (__instance.m_staminaBar2Root != null && __instance.m_staminaBar2Root.gameObject.activeSelf) { diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index b1e7304..f89ea6f 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -35,7 +35,6 @@ namespace RacesOfValheim { "Tick", "TrophyTick" }, { "Ulv", "TrophyUlv" }, { "Cultist", "TrophyCultist" }, - { "Bat", "TrophyBat" }, { "Asksvin", "TrophyAsksvin" }, { "Volture", "TrophyVolture" } }; @@ -50,7 +49,10 @@ namespace RacesOfValheim { "Hare", "CookedHareMeat" }, { "Asksvin", "CookedAsksvinMeat" }, { "Volture", "CookedVoltureMeat" }, - { "Tick", "Bloodbag" }, // Fallback to Bloodbag if BloodClot doesn't exist + { "Tick", "BloodPudding" }, + { "Deathsquito", "BloodPudding" }, + { "Leech", "BloodPudding" }, + { "Ulv", "BloodPudding" }, { "Seeker", "CookedBugMeat" }, { "SeekerBrute", "CookedBugMeat" }, { "SeekerBrood", "CookedBugMeat" } diff --git a/JotunnModStub/Draugh/DraughFoodPatches.cs b/JotunnModStub/Draugh/DraughFoodPatches.cs new file mode 100644 index 0000000..d734b64 --- /dev/null +++ b/JotunnModStub/Draugh/DraughFoodPatches.cs @@ -0,0 +1,180 @@ +using HarmonyLib; +using System.Collections.Generic; +using UnityEngine; +using Jotunn.Entities; +using Jotunn.Managers; + +namespace RacesOfValheim +{ + [HarmonyPatch] + public static class DraughFoodPatches + { + private static List hiddenFoods = new List(); + + // Mapping from raw prefab/item name to the cooked prefab name + public static readonly Dictionary rawToCookedMapping = new Dictionary + { + { "RawMeat", "CookedMeat" }, + { "NeckTail", "NeckTailGrilled" }, + { "FishRaw", "FishCooked" }, + { "LoxMeat", "CookedLoxMeat" }, + { "SerpentMeatRaw", "SerpentMeatCooked" }, + { "WolfMeat", "CookedWolfMeat" }, + { "DeerMeat", "CookedDeerMeat" }, + { "HareMeat", "CookedHareMeat" }, + { "ChickenMeat", "CookedChickenMeat" }, + { "BugMeat", "CookedBugMeat" }, + { "VoltureMeat", "RoastedVoltureMeat" }, + { "GreydwarfEye", "DeerStew" }, + { "Entrails", "Sausages" }, + { "Bloodbag", "BloodPudding" } + }; + + [HarmonyPatch(typeof(Humanoid), "UseItem")] + [HarmonyPrefix] + public static bool UseItem_Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item, bool fromInventoryGui) + { + Player player = __instance as Player; + if (player == null || player != Player.m_localPlayer || !DraughRace.IsDraugh() || item == null || item.m_shared == null) return true; + + // Intercept right click on raw items. + // In UseItem, if it's a Consumable, Valheim will process it. If it's our EdibleUncooked_, it's a Consumable! + if (item.m_shared.m_name.StartsWith("$item_edibleuncooked_") || item.m_dropPrefab?.name.StartsWith("EdibleUncooked_") == true) + { + return true; // Let native EatFood process our custom item + } + + string prefabName = item.m_dropPrefab != null ? item.m_dropPrefab.name : ""; + string cleanName = prefabName; + if (string.IsNullOrEmpty(cleanName)) cleanName = item.m_shared.m_name.Replace("$item_", ""); + + // Is it one of the raw items in our mapping? + if (rawToCookedMapping.ContainsKey(cleanName)) + { + // We want to seamlessly swap it with EdibleUncooked_ + string customPrefabName = "EdibleUncooked_" + cleanName; + GameObject customPrefab = ObjectDB.instance.GetItemPrefab(customPrefabName); + if (customPrefab != null) + { + ItemDrop customItemDrop = customPrefab.GetComponent(); + if (customItemDrop != null) + { + // Check if we can eat it (duplicate check bypass logic handled inside EatFood) + bool ate = player.EatFood(customItemDrop.m_itemData); + if (ate) + { + inventory.RemoveItem(item, 1); + } + return false; // Skip native UseItem + } + } + else + { + Jotunn.Logger.LogWarning($"[DraughFood] Could not find custom prefab: {customPrefabName}"); + } + } + + // If it's a normal consumable (like standard cooked food or berries), we should block it! + if (item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Consumable) + { + 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."); + return false; // Block it + } + } + + return true; + } + + [HarmonyPatch(typeof(Player), "EatFood")] + [HarmonyPrefix] + public static bool EatFood_Prefix(Player __instance, ItemDrop.ItemData item, ref bool __result) + { + hiddenFoods.Clear(); + + if (__instance != Player.m_localPlayer || !DraughRace.IsDraugh()) return true; + if (item == null || item.m_shared == null) return true; + + // Handle the bypass logic (duplicate food) ONLY for our custom uncooked foods + string prefabName = item.m_dropPrefab != null ? item.m_dropPrefab.name : ""; + if (prefabName.StartsWith("EdibleUncooked_")) + { + var m_foods = Traverse.Create(__instance).Field("m_foods").GetValue(); + if (m_foods != null) + { + if (m_foods.Count >= 3) + { + // Check if we can refresh an existing identical food (if time is low) + bool refreshed = false; + foreach (object foodObj in m_foods) + { + 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); + + refreshed = true; + break; + } + } + + if (refreshed) + { + __result = true; + return false; // Skip native EatFood + } + + // Inventory full + __result = false; + return false; + } + else + { + // Temporarily hide duplicates to force Valheim to add a new slot + for (int i = m_foods.Count - 1; i >= 0; i--) + { + var foodObj = m_foods[i]; + var foodItem = Traverse.Create(foodObj).Field("m_item").GetValue(); + if (foodItem != null && foodItem.m_shared.m_name == item.m_shared.m_name) + { + hiddenFoods.Add(foodObj); + m_foods.RemoveAt(i); + } + } + } + } + } + + return true; + } + + [HarmonyPatch(typeof(Player), "EatFood")] + [HarmonyPostfix] + public static void EatFood_Postfix(Player __instance, ItemDrop.ItemData item, ref bool __result) + { + if (hiddenFoods.Count > 0) + { + var m_foods = Traverse.Create(__instance).Field("m_foods").GetValue(); + if (m_foods != null) + { + foreach (var h in hiddenFoods) + { + m_foods.Add(h); + } + } + hiddenFoods.Clear(); + } + } + } +} diff --git a/JotunnModStub/Draugh/DraughPatches.cs b/JotunnModStub/Draugh/DraughPatches.cs new file mode 100644 index 0000000..88cf022 --- /dev/null +++ b/JotunnModStub/Draugh/DraughPatches.cs @@ -0,0 +1,119 @@ +using HarmonyLib; +using UnityEngine; + +namespace RacesOfValheim +{ + [HarmonyPatch(typeof(VisEquipment), "UpdateColors")] + public static class DraughSkinColorPatch + { + public static void Postfix(VisEquipment __instance) + { + if (!__instance.m_isPlayer) return; + Player player = __instance.GetComponent(); + if (player == null) return; + + string race = "Human"; + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid()) + race = nview.GetZDO().GetString("RacesOfValheim_Race", "Human"); + else if (player.m_customData != null && player.m_customData.TryGetValue("Race", out string savedRace)) + race = savedRace; + + if (race != "Draugh") return; + + if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null) + { + // Sickly grayish-green undead skin color (corpse green) + Color draughColor = new Color(0.25f, 0.4f, 0.28f, 1f); + __instance.m_bodyModel.material.SetColor("_SkinColor", draughColor); + } + + // Desaturate and darken hair and beard + Vector3 origHairVec = Traverse.Create(__instance).Field("m_hairColor").GetValue(); + Color origHair = new Color(origHairVec.x, origHairVec.y, origHairVec.z); + float l = 0.299f * origHair.r + 0.587f * origHair.g + 0.114f * origHair.b; + Color desatHair = Color.Lerp(origHair, new Color(l, l, l), 0.75f) * 0.7f; // 75% desaturated, 30% darker + desatHair.a = 1f; + + var hairObj = Traverse.Create(__instance).Field("m_hairItemInstance").GetValue(); + if (hairObj != null) + { + foreach (var r in hairObj.GetComponentsInChildren()) + if (r.material != null && r.material.HasProperty("_SkinColor")) r.material.SetColor("_SkinColor", desatHair); + } + var hairList = Traverse.Create(__instance).Field("m_hairItemInstances").GetValue>(); + if (hairList != null) + { + foreach (var h in hairList) + if (h != null) + foreach (var r in h.GetComponentsInChildren()) + if (r.material != null && r.material.HasProperty("_SkinColor")) r.material.SetColor("_SkinColor", desatHair); + } + + var beardObj = Traverse.Create(__instance).Field("m_beardItemInstance").GetValue(); + if (beardObj != null) + { + foreach (var r in beardObj.GetComponentsInChildren()) + if (r.material != null && r.material.HasProperty("_SkinColor")) r.material.SetColor("_SkinColor", desatHair); + } + var beardList = Traverse.Create(__instance).Field("m_beardItemInstances").GetValue>(); + if (beardList != null) + { + foreach (var b in beardList) + if (b != null) + foreach (var r in b.GetComponentsInChildren()) + if (r.material != null && r.material.HasProperty("_SkinColor")) r.material.SetColor("_SkinColor", desatHair); + } + } + } + + [HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")] + public static class Draugh_VisEquipment_UpdateVisuals_Patch + { + public static string GetPlayerRace(VisEquipment visEq) + { + Player player = visEq.GetComponent(); + if (player != null) + { + ZNetView nview = player.GetComponent(); + if (nview != null && nview.IsValid()) + return nview.GetZDO().GetString("RacesOfValheim_Race", "Human"); + + if (player.m_customData != null && player.m_customData.TryGetValue("Race", out string r)) + return r; + } + return "Human"; + } + + public static void Postfix(VisEquipment __instance) + { + if (!__instance.m_isPlayer) return; + string race = GetPlayerRace(__instance); + if (race != "Draugh") return; + + // Future model swaps (e.g. Draugr head) or hiding items can go here + } + } + + [HarmonyPatch(typeof(Character), "Damage")] + public static class Draugh_Damage_Patch + { + public static void Prefix(Character __instance, HitData hit) + { + if (hit == null || __instance == null || !__instance.IsPlayer()) return; + if (__instance != Player.m_localPlayer) return; + + if (!DraughRace.IsDraugh()) return; + + // Apply specific damage modifiers for Draugh + // -20% damage received from slash, pierce, blunt + hit.m_damage.m_blunt *= 0.8f; + hit.m_damage.m_slash *= 0.8f; + hit.m_damage.m_pierce *= 0.8f; + + // +50% damage received from fire, spirit + hit.m_damage.m_fire *= 1.5f; + hit.m_damage.m_spirit *= 1.5f; + } + } +} diff --git a/JotunnModStub/Draugh/DraughRace.cs b/JotunnModStub/Draugh/DraughRace.cs new file mode 100644 index 0000000..6ce5fc1 --- /dev/null +++ b/JotunnModStub/Draugh/DraughRace.cs @@ -0,0 +1,162 @@ +using UnityEngine; + +namespace RacesOfValheim +{ + public class DraughRace : MonoBehaviour + { + public static DraughRace Instance; + + private void Awake() + { + Instance = this; + } + + public void CreateModAssets() + { + // Generate EdibleUncooked prefabs for Draugh raw food logic + foreach (var mapping in DraughFoodPatches.rawToCookedMapping) + { + string rawPrefabName = mapping.Key; + string cookedPrefabName = mapping.Value; + + GameObject rawPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab(rawPrefabName); + GameObject cookedPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab(cookedPrefabName); + + if (rawPrefab != null && cookedPrefab != null) + { + ItemDrop rawDrop = rawPrefab.GetComponent(); + ItemDrop cookedDrop = cookedPrefab.GetComponent(); + + if (rawDrop != null && cookedDrop != null) + { + string customName = "EdibleUncooked_" + rawPrefabName; + Jotunn.Entities.CustomItem customItem = new Jotunn.Entities.CustomItem(customName, cookedPrefabName); + + ItemDrop customDrop = customItem.ItemDrop; + customDrop.m_itemData.m_shared.m_name = rawDrop.m_itemData.m_shared.m_name; + customDrop.m_itemData.m_shared.m_description = rawDrop.m_itemData.m_shared.m_description; + customDrop.m_itemData.m_shared.m_icons = rawDrop.m_itemData.m_shared.m_icons; + customDrop.m_itemData.m_shared.m_foodBurnTime *= 1.5f; + + Jotunn.Managers.ItemManager.Instance.AddItem(customItem); + } + } + } + } + + public static bool IsDraugh() + { + return Player.m_localPlayer != null && + Player.m_localPlayer.m_customData.ContainsKey("Race") && + Player.m_localPlayer.m_customData["Race"] == "Draugh"; + } + + private GameObject draughVFX = null; + private float foodCheckTimer = 0f; + private int lastProgressionState = -1; + + private void Update() + { + if (Player.m_localPlayer == null) return; + + if (IsDraugh() && !Player.m_localPlayer.IsDead()) + { + EnsureVFX(true); + + foodCheckTimer += Time.deltaTime; + if (foodCheckTimer >= 2f) + { + foodCheckTimer = 0f; + int currentState = BossProgressionManager.GetCurrentProgressionState(); + if (currentState != lastProgressionState) + { + lastProgressionState = currentState; + UpdateFoodEitr(currentState >= 6); // 6 = Yagluth Defeated + } + } + } + else + { + EnsureVFX(false); + } + } + + private void UpdateFoodEitr(bool enableEitr) + { + if (ObjectDB.instance == null) return; + + foreach (var mapping in DraughFoodPatches.rawToCookedMapping) + { + string customPrefabName = "EdibleUncooked_" + mapping.Key; + GameObject customPrefab = ObjectDB.instance.GetItemPrefab(customPrefabName); + if (customPrefab != null) + { + ItemDrop drop = customPrefab.GetComponent(); + if (drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null) + { + if (enableEitr) + { + drop.m_itemData.m_shared.m_foodEitr = drop.m_itemData.m_shared.m_food / 2f; + } + else + { + drop.m_itemData.m_shared.m_foodEitr = 0f; + } + } + } + } + } + + private void EnsureVFX(bool enable) + { + if (enable && Player.m_localPlayer != null) + { + if (draughVFX == null) + { + GameObject draugrPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab("Draugr"); + if (draugrPrefab != null) + { + draughVFX = new GameObject("DraughAuraVFX"); + draughVFX.transform.SetParent(Player.m_localPlayer.transform, false); + draughVFX.transform.localPosition = new Vector3(0, 1f, 0); + + // Find all ParticleSystems in Draugr prefab + ParticleSystem[] pss = draugrPrefab.GetComponentsInChildren(true); + foreach (ParticleSystem ps in pss) + { + // We only want looping ambient effects (flies, smoke) + if (ps.main.loop) + { + GameObject psCopy = Instantiate(ps.gameObject, draughVFX.transform); + psCopy.name = ps.gameObject.name; + psCopy.SetActive(true); + + // Ensure it's positioned correctly + psCopy.transform.localPosition = ps.transform.localPosition; + psCopy.transform.localRotation = ps.transform.localRotation; + + // Make the green smoke 50% larger. We exclude "flies" in case they are separate. + if (!psCopy.name.ToLower().Contains("flies")) + { + psCopy.transform.localScale = ps.transform.localScale * 1.5f; + } + } + } + } + } + + if (draughVFX != null && !draughVFX.activeSelf) + { + draughVFX.SetActive(true); + } + } + else + { + if (draughVFX != null && draughVFX.activeSelf) + { + draughVFX.SetActive(false); + } + } + } + } +} diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index 079e3b1..0b744a3 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -31,6 +31,7 @@ namespace RacesOfValheim gameObject.AddComponent(); gameObject.AddComponent(); gameObject.AddComponent(); + gameObject.AddComponent(); PrefabManager.OnVanillaPrefabsAvailable += CreateAllModAssets; CommandManager.Instance.AddConsoleCommand(new ResetRaceCommand()); CommandManager.Instance.AddConsoleCommand(new CheckProgressionCommand()); @@ -46,6 +47,7 @@ namespace RacesOfValheim AswidRace.Instance.CreateModAssets(); FurlingRace.Instance.CreateModAssets(); TrolRace.Instance.CreateModAssets(); + DraughRace.Instance.CreateModAssets(); } // --- RACE SELECTION UI --- public void ShowRaceSelectionMenu() @@ -175,17 +177,16 @@ namespace RacesOfValheim } // Row 1 (y = 100) - CreateRaceButtonWithConfirm("Human", new Vector2(-300, 100), GetHumanIcon(), "The versatile founders of Midgard. Balanced stats with no specific weaknesses.", SelectHuman); - CreateRaceButtonWithConfirm("Fenrir", new Vector2(0, 100), GetFenrirIcon(), "Cursed by the blood of the wolf. Fast and deadly, but vulnerable to silver.", SelectFenrir); - CreateRaceButtonWithConfirm("Skadi", new Vector2(300, 100), GetSkadiIcon(), "Children of the mountains. Resistant to frost, at home in the freezing cold.", SelectSkadi); + 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); - // Row 2 (y = 0) - CreateRaceButtonWithConfirm("Skeleton", new Vector2(-300, 0), GetSkeletonIcon(), "Undead warriors. Immune to poison, but brittle against blunt trauma.", SelectSkeleton); - CreateRaceButtonWithConfirm("Aswid", new Vector2(0, 0), GetAswidIcon(), "Fierce night stalker. Strong and resilient, transforms into a bat.", SelectAswid); - CreateRaceButtonWithConfirm("Furling", new Vector2(300, 0), GetFurlingIcon(), "Cunning goblin-like creatures. Agile and resourceful.", SelectFurling); - - // Row 3 (y = -100) - CreateRaceButtonWithConfirm("Trol", new Vector2(0, -100), GetTrolIcon(), "Massive brute strength. Towering over others but slow to react.", SelectTrol); + // Row 2 (y = -20) + CreateRaceButtonWithConfirm("Aswid", new Vector2(-450, -20), GetAswidIcon(), "Fierce night stalker. Strong and resilient, transforms into a bat.", SelectAswid); + CreateRaceButtonWithConfirm("Furling", new Vector2(-150, -20), GetFurlingIcon(), "Cunning goblin-like creatures. Agile and resourceful.", SelectFurling); + CreateRaceButtonWithConfirm("Trol", new Vector2(150, -20), GetTrolIcon(), "Massive brute strength. Towering over others but slow to react.", SelectTrol); + CreateRaceButtonWithConfirm("Draugh", new Vector2(450, -20), GetDraughIcon(), "Undead warriors of the swamps. Accustomed to damp and decay.", SelectDraugh); GUIManager.BlockInput(true); } @@ -487,6 +488,48 @@ namespace RacesOfValheim return null; } + private void SelectDraugh() + { + if (Player.m_localPlayer != null) + { + Player.m_localPlayer.m_customData["Race"] = "Draugh"; + ZNetView nview = Player.m_localPlayer.GetComponent(); + if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Draugh"); + + VisEquipment visEq = Player.m_localPlayer.GetComponent(); + if (visEq != null) + { + if (!Player.m_localPlayer.m_customData.ContainsKey("OriginalSkinColor_X")) + { + Vector3 currentSkinColor = Traverse.Create(visEq).Field("m_skinColor").GetValue(); + Player.m_localPlayer.m_customData["OriginalSkinColor_X"] = currentSkinColor.x.ToString(); + Player.m_localPlayer.m_customData["OriginalSkinColor_Y"] = currentSkinColor.y.ToString(); + Player.m_localPlayer.m_customData["OriginalSkinColor_Z"] = currentSkinColor.z.ToString(); + } + + Traverse.Create(visEq).Method("SetSkinColor", new Vector3(0.25f, 0.4f, 0.28f)).GetValue(); + 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."); + CloseRaceSelectionMenu(); + } + } + + private Sprite GetDraughIcon() + { + GameObject trophyPrefab = PrefabManager.Cache.GetPrefab("TrophyDraugr")?.gameObject; + if (trophyPrefab != null) + { + ItemDrop trophyDrop = trophyPrefab.GetComponent(); + if (trophyDrop != null && trophyDrop.m_itemData.m_shared.m_icons.Length > 0) + { + return trophyDrop.m_itemData.m_shared.m_icons[0]; + } + } + return null; + } + public void CloseRaceSelectionMenu() { if (raceSelectionMenu != null) @@ -549,8 +592,8 @@ namespace RacesOfValheim __instance.GetSEMan().AddStatusEffect("SE_FenrirCurse".GetStableHashCode(), true); } - // If Skadi, Aswid, Furling or Trol, re-trigger visual update to set skin color - if (__instance.m_customData.ContainsKey("Race") && (__instance.m_customData["Race"] == "Skadi" || __instance.m_customData["Race"] == "Aswid" || __instance.m_customData["Race"] == "Furling" || __instance.m_customData["Race"] == "Trol")) + // If Skadi, Aswid, Furling, Trol or Draugh, re-trigger visual update to set skin color + if (__instance.m_customData.ContainsKey("Race") && (__instance.m_customData["Race"] == "Skadi" || __instance.m_customData["Race"] == "Aswid" || __instance.m_customData["Race"] == "Furling" || __instance.m_customData["Race"] == "Trol" || __instance.m_customData["Race"] == "Draugh")) { VisEquipment visEq = __instance.GetComponent(); if (visEq != null) visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null); diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index 71b298b..6f8c364 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -15,7 +15,7 @@ namespace RacesOfValheim { public static bool Prefix(Player __instance) { - if ((SkeletonRace.IsSkeleton() || AswidRace.IsAswid()) && __instance == Player.m_localPlayer) + if ((SkeletonRace.IsSkeleton() || AswidRace.IsAswid() || DraughRace.IsDraugh()) && __instance == Player.m_localPlayer) { // Infinite stamina: skip the original UseStamina method return false; From 16275d6abc03e107b72b7b7b2f322de8e384942e Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 1 Aug 2026 13:24:44 +0200 Subject: [PATCH 027/429] Stop remote clients spawning a dragon model every frame The multiplayer visual sync named each spawned model "
_multiplayer" but searched for an existing one called "SkadiBody_Form", a name nothing is ever assigned. The lookup therefore missed every time, and since VisEquipment.UpdateVisuals runs each frame off CustomUpdate, observers instantiated a fresh dragon roughly sixty times a second for as long as the Skadi player stayed transformed. The transformed player saw nothing wrong, because owners return early, and the pile only got cleaned up in the reverted-to-human branch, so the lag never let up on its own. Look the model up by the name actually assigned. The scan also destroys any surplus "_multiplayer" children it walks past, so clients that have already accumulated a pile clear it on the first frame after updating instead of needing to rejoin. --- JotunnModStub/Skadi/SkadiPatches.cs | 82 ++++++++++++++++------------- 1 file changed, 44 insertions(+), 38 deletions(-) diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 7675048..fc1976f 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -28,52 +28,58 @@ namespace RacesOfValheim [HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")] public static class Skadi_MultiplayerVisuals_Patch { + private const string FormSuffix = "_multiplayer"; + public static void Postfix(VisEquipment __instance) { if (!__instance.m_isPlayer) return; Player player = __instance.GetComponent(); if (player == null || player.IsOwner()) return; // Only process remote players - - ZNetView nview = player.GetComponent(); - if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Skadi") - { - string formName = nview.GetZDO().GetString("RacesOfValheim_SkadiForm", ""); - - Transform playerVisual = player.transform.Find("Visual"); - Transform formBody = player.transform.Find("SkadiBody_Form"); - - if (!string.IsNullOrEmpty(formName)) { - if (formBody != null && formBody.gameObject.name != formName + "_multiplayer") { - UnityEngine.Object.Destroy(formBody.gameObject); - formBody = null; - } - if (formBody == null) { - GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab(formName); - if (prefab != null) { - Transform visual = prefab.transform.Find("Visual"); - if (visual != null) { - GameObject formInstance = UnityEngine.Object.Instantiate(visual.gameObject, player.transform); - formInstance.name = formName + "_multiplayer"; - if (formName == "Hatchling") formInstance.transform.localPosition = new Vector3(0f, -1.0f, 0f); - else formInstance.transform.localPosition = Vector3.zero; - formInstance.transform.localRotation = Quaternion.identity; - } - } - } - if (playerVisual != null) playerVisual.gameObject.SetActive(false); - } else { - if (formBody != null) UnityEngine.Object.Destroy(formBody.gameObject); - - // Fader form has a different name? "SkadiBody_Form" was used earlier, we just find all children and destroy them if they have "_multiplayer" - foreach (Transform child in player.transform) { - if (child.name.EndsWith("_multiplayer")) { - UnityEngine.Object.Destroy(child.gameObject); - } - } - if (playerVisual != null) playerVisual.gameObject.SetActive(true); + ZNetView nview = player.GetComponent(); + if (nview == null || !nview.IsValid()) return; + if (nview.GetZDO().GetString("RacesOfValheim_Race", "Human") != "Skadi") return; + + string formName = nview.GetZDO().GetString("RacesOfValheim_SkadiForm", ""); + Transform playerVisual = player.transform.Find("Visual"); + string wanted = formName + FormSuffix; + + // VisEquipment.UpdateVisuals runs every frame off CustomUpdate, so the spawned model + // has to be found again by the exact name it was given. This used to search for + // "SkadiBody_Form" - a name nothing is ever assigned - so the lookup missed every + // time and a fresh dragon was instantiated each frame. Remote players watched the + // models pile up on the spot and their client degraded until the Skadi player + // reverted; the transformed player saw nothing, since owners return above. + // Anything left over from that, or from a previous form, is cleaned up here too. + Transform formBody = null; + foreach (Transform child in player.transform) + { + if (!child.name.EndsWith(FormSuffix)) continue; + + if (formBody == null && child.name == wanted) formBody = child; + else UnityEngine.Object.Destroy(child.gameObject); + } + + if (string.IsNullOrEmpty(formName)) + { + if (playerVisual != null) playerVisual.gameObject.SetActive(true); + return; + } + + if (formBody == null) + { + GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab(formName); + Transform visual = prefab != null ? prefab.transform.Find("Visual") : null; + if (visual != null) + { + GameObject formInstance = UnityEngine.Object.Instantiate(visual.gameObject, player.transform); + formInstance.name = wanted; + formInstance.transform.localPosition = formName == "Hatchling" ? new Vector3(0f, -1.0f, 0f) : Vector3.zero; + formInstance.transform.localRotation = Quaternion.identity; } } + + if (playerVisual != null) playerVisual.gameObject.SetActive(false); } } From bca47beda6524422c096fe6bd90264e9fd94fbfe Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 1 Aug 2026 13:25:02 +0200 Subject: [PATCH 028/429] Ignore race ability input while a GUI has focus UnityEngine.Input reads the device directly, so abilities bound to keys or mouse buttons kept firing with the map, the inventory, a chest, the chat or a menu open - clicking an item in a container also swung the transformed attack. Route that input through Player.TakeInput, which is what Valheim runs its own controls through and already reports false for those states (InventoryGui covers the backpack and chests alike). Aswid's transform keys were the only place already doing this; the shared helper replaces that one-off and covers Skadi's cold spell, form keys, flight toggle, form attacks and flight boost, Fenrir's form keys and the attacks of all four form behaviors, Trol's rock throw and true form, and Aswid's devour toggle. Cultist fire is a held button, so it is gated per read rather than around the block: opening a GUI mid-stream now falls through to StopFire() instead of leaving the flames running. --- JotunnModStub/Aswid/AswidPatches.cs | 2 +- JotunnModStub/Aswid/AswidRace.cs | 3 +- JotunnModStub/Fenrir/FenrirBehaviors.cs | 18 +++++++----- JotunnModStub/Fenrir/FenrirRace.cs | 2 ++ JotunnModStub/RaceInput.cs | 36 ++++++++++++++++++++++++ JotunnModStub/Skadi/DrakeFormBehavior.cs | 4 +-- JotunnModStub/Skadi/SkadiPatches.cs | 2 +- JotunnModStub/Skadi/SkadiRace.cs | 5 +++- JotunnModStub/Trol/TrolRace.cs | 15 ++++++---- 9 files changed, 67 insertions(+), 20 deletions(-) create mode 100644 JotunnModStub/RaceInput.cs diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs index 19e26df..bc8becb 100644 --- a/JotunnModStub/Aswid/AswidPatches.cs +++ b/JotunnModStub/Aswid/AswidPatches.cs @@ -506,7 +506,7 @@ namespace RacesOfValheim ZNetView nview = __instance.GetComponent(); if (nview != null && nview.IsValid() && nview.GetZDO().GetString("RacesOfValheim_Race", "Human") == "Aswid") { - if (__instance == Player.m_localPlayer && Input.GetKeyDown(KeyCode.I)) + if (__instance == Player.m_localPlayer && RaceInput.Allowed && Input.GetKeyDown(KeyCode.I)) { AswidRace.DevourEnabled = !AswidRace.DevourEnabled; string msg = AswidRace.DevourEnabled ? "Devour Ability: ENABLED" : "Devour Ability: DISABLED"; diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 124b63e..62fc547 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -515,8 +515,7 @@ namespace RacesOfValheim int state = BossProgressionManager.GetCurrentProgressionState(); - bool takeInput = HarmonyLib.Traverse.Create(Player.m_localPlayer).Method("TakeInput").GetValue(); - if (takeInput) + if (RaceInput.Allowed) { if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(AswidProgression.GetGKeyRules(state)); return; } if (Input.GetKeyDown(KeyCode.H)) { TryToggleMistForm(); return; } diff --git a/JotunnModStub/Fenrir/FenrirBehaviors.cs b/JotunnModStub/Fenrir/FenrirBehaviors.cs index 7954de1..e2628aa 100644 --- a/JotunnModStub/Fenrir/FenrirBehaviors.cs +++ b/JotunnModStub/Fenrir/FenrirBehaviors.cs @@ -56,7 +56,7 @@ namespace RacesOfValheim fenrirAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed")); } } - if (isGrounded) + if (isGrounded && RaceInput.Allowed) { if (Input.GetKeyDown(KeyCode.O)) { @@ -311,8 +311,12 @@ namespace RacesOfValheim if (isGrounded) { + // Gated per-read rather than around the block, so opening a GUI mid-stream + // still falls through to StopFire() instead of leaving the flames running. + bool canAct = RaceInput.Allowed; + // Fire attack on Right Click - if (Input.GetMouseButton(1)) + if (canAct && Input.GetMouseButton(1)) { if (Player.m_localPlayer.GetEitr() > 0) { @@ -335,18 +339,18 @@ namespace RacesOfValheim StopFire(); } - if (Input.GetKeyDown(KeyCode.O)) + if (canAct && Input.GetKeyDown(KeyCode.O)) { StartCoroutine(HowlRoutine()); } // Attacks on Left Click - if (Input.GetMouseButtonDown(0) && !isShootingFire) + if (canAct && Input.GetMouseButtonDown(0) && !isShootingFire) { StartCoroutine(ClawRoutine()); // Single claw } // Double claw on Middle Click - else if (Input.GetMouseButtonDown(2) && !isShootingFire) + else if (canAct && Input.GetMouseButtonDown(2) && !isShootingFire) { StartCoroutine(DoubleClawRoutine()); } @@ -671,7 +675,7 @@ namespace RacesOfValheim } } - if (isGrounded) + if (isGrounded && RaceInput.Allowed) { if (Input.GetMouseButtonDown(0)) // Left Click { @@ -844,7 +848,7 @@ namespace RacesOfValheim } } - if (isGrounded) + if (isGrounded && RaceInput.Allowed) { if (Input.GetMouseButtonDown(0)) // Left Click { diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs index 3768190..5adc796 100644 --- a/JotunnModStub/Fenrir/FenrirRace.cs +++ b/JotunnModStub/Fenrir/FenrirRace.cs @@ -143,6 +143,8 @@ namespace RacesOfValheim { } } + if (!RaceInput.Allowed) return; + int state = BossProgressionManager.GetCurrentProgressionState(); if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(FenrirProgression.GetGKeyRules(state)); return; } diff --git a/JotunnModStub/RaceInput.cs b/JotunnModStub/RaceInput.cs new file mode 100644 index 0000000..4c92a55 --- /dev/null +++ b/JotunnModStub/RaceInput.cs @@ -0,0 +1,36 @@ +using System.Reflection; +using HarmonyLib; + +namespace RacesOfValheim +{ + /// + /// Gate for race ability input. + /// + /// UnityEngine.Input reads the device directly, so abilities bound to keys or mouse buttons + /// kept firing while the map, the inventory, a chest, the chat or a menu had focus - dragging + /// an item inside a container also swung the transformed attack, for instance. Valheim runs + /// its own controls through Player.TakeInput, which reports false for exactly those states + /// (InventoryGui covers the backpack and chests alike), so mirror that instead of maintaining + /// a parallel list of GUI checks that would drift as the game changes. + /// + public static class RaceInput + { + // Not public on Player, hence the reflection; resolved once rather than per frame. + private static readonly MethodInfo TakeInputMethod = AccessTools.Method(typeof(Player), "TakeInput"); + + public static bool Allowed + { + get + { + Player player = Player.m_localPlayer; + if (player == null) return false; + + // Fail open: if a game update ever renames the method, abilities stay usable + // rather than silently going dead. + if (TakeInputMethod == null) return true; + + return (bool)TakeInputMethod.Invoke(player, null); + } + } + } +} diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index 75a6a6e..62941b0 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -67,7 +67,7 @@ namespace RacesOfValheim if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return; // Handle Flight Toggle (RMB) - Disabled for Fader - if (Input.GetMouseButtonDown(1) && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon) + if (RaceInput.Allowed && Input.GetMouseButtonDown(1) && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon) { if (!isFlying && !isLanding) { @@ -122,7 +122,7 @@ namespace RacesOfValheim } // Handle Attack - if (CanAttackNow()) + if (CanAttackNow() && RaceInput.Allowed) { if (Input.GetMouseButtonDown(0)) { diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index fc1976f..e38a81e 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -232,7 +232,7 @@ namespace RacesOfValheim var traverse = Traverse.Create(__instance); Vector3 lookDir = Player.m_localPlayer.GetLookDir(); - bool boost = Input.GetKey(KeyCode.W); + bool boost = RaceInput.Allowed && Input.GetKey(KeyCode.W); bool onGround = __instance.IsOnGround(); traverse.Field("m_run").SetValue(boost); diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 071dac5..1b45633 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -150,7 +150,7 @@ namespace RacesOfValheim } } - if (rules.ColdSpell) + if (rules.ColdSpell && RaceInput.Allowed) { HandleColdSpell(rules); } @@ -167,6 +167,9 @@ namespace RacesOfValheim return; } + // Form keys and the debug dump are ability input: they stay inert while a GUI has focus. + if (!RaceInput.Allowed) return; + int state = BossProgressionManager.GetCurrentProgressionState(); if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(SkadiProgression.GetGKeyRules(state)); return; } if (Input.GetKeyDown(KeyCode.H)) { TryTransformWithRules(SkadiProgression.GetHKeyRules(state)); return; } diff --git a/JotunnModStub/Trol/TrolRace.cs b/JotunnModStub/Trol/TrolRace.cs index ee82086..5b7eb15 100644 --- a/JotunnModStub/Trol/TrolRace.cs +++ b/JotunnModStub/Trol/TrolRace.cs @@ -119,14 +119,17 @@ namespace RacesOfValheim { if (!IsTrol()) return; - if (Input.GetKeyDown(KeyCode.G)) + if (RaceInput.Allowed) { - TryThrowRock(); - } + if (Input.GetKeyDown(KeyCode.G)) + { + TryThrowRock(); + } - if (Input.GetKeyDown(KeyCode.H)) - { - TryTrueForm(); + if (Input.GetKeyDown(KeyCode.H)) + { + TryTrueForm(); + } } // Check log durability From e975405b43018055323b635433b526d81e9e0d41 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 1 Aug 2026 13:52:37 +0200 Subject: [PATCH 029/429] Release 1.3.6: changelog for the Skadi work and version bump Covers the dragon flight rework, form duration and its HUD countdown, the cooldown that could never fire, the Freezing-to-Cold conversion, the Cold Spell position and animation, Drake attack unlock timing, the resetrace cleanup, the multiplayer dragon spawn leak and the GUI input gating. --- README.md | 12 ++++++++++++ manifest.json | 2 +- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3b53be4..e2e1fb5 100644 --- a/README.md +++ b/README.md @@ -121,6 +121,18 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE** ## Changelog +**v1.3.6** +- **Skadi**: Complete overhaul of dragon flight! Your form now flies wherever you aim, pitch included, instead of the old free-camera noclip that needed Space and Ctrl to change altitude. Hold W to power forward and climb; let go and you hold level for a couple of seconds before settling into a natural glide. +- **Skadi**: Dragon forms now turn to face the direction they are actually flying, and touching down mid-flight no longer leaves you sliding forward forever. +- **Skadi**: Timed dragon forms finally expire on their own! Moder Form now honours its duration, and the cooldown that could never trigger before now works properly. Both the remaining seconds and the cooldown appear as a Moder trophy icon with a live countdown beside the minimap. +- **Skadi**: Fixed 'Freezing to Cold' (Eikthyr tier), which never did anything at all: Skadi's own frost resistance made Valheim skip the cold check entirely. Mountains now correctly leave you with Cold instead of Freezing. +- **Skadi**: The Cold Spell is now cast from chest height with a proper spellcasting gesture, instead of a kick aimed at the ground. +- **Skadi**: Drake Form attacks unlock the moment you reach the Bonemass tier, rather than only after transforming again. +- **Skadi**: `resetrace` now clears Skadi's Aura and its frost bonuses when switching away from the race. +- **Multiplayer**: Fixed a severe bug where other players saw a transformed Skadi's dragon model respawn every single frame, stacking thousands of copies and causing lag that only got worse and never cleared on its own. The transformed player saw nothing wrong on their own screen. +- **General**: Race abilities no longer fire while the map, inventory, a chest, the chat or a menu is open, so clicking an item inside a container no longer swings your transformed attack. +- **Documentation**: The Skadi progression list now states the keybind for each form, along with the flight controls. + **v1.3.5** - **Aswid**: Added an Execution mechanic to Blood Magic (Vampiric Aura): Non-boss enemies that fall below 20% health while inside the aura are instantly killed and automatically devoured! - **Aswid**: The Vampiric Aura's devour execution now flawlessly respects the Aswid's custom stomach limitations, including the ability to silently refresh duplicate blinking buffs when slots are fully occupied. diff --git a/manifest.json b/manifest.json index e364df6..bfaab32 100644 --- a/manifest.json +++ b/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.5", + "version_number": "1.3.6", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", From 17fdeba320aa876665ec9b1275c26af053885363 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 1 Aug 2026 13:59:05 +0200 Subject: [PATCH 030/429] List Trol in the mod description and sync the packaging manifest Both manifests still described five races; Trol has been playable since 1.3.1. Draugh is deliberately left out until it ships. The packaging manifest was also stuck at 1.3.3.1, two releases behind the root one the build actually publishes. --- JotunnModStub/Package/manifest.json | 4 ++-- manifest.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json index be40f26..d664951 100644 --- a/JotunnModStub/Package/manifest.json +++ b/JotunnModStub/Package/manifest.json @@ -1,7 +1,7 @@ { "name": "RacesOfValheim", - "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", - "version_number": "1.3.3.1", + "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling, Trol) each with unique abilities, traits, and a deep boss-driven progression system.", + "version_number": "1.3.6", "website_url": "", "dependencies": [ "denikson-BepInExPack_Valheim-5.4.2333", diff --git a/manifest.json b/manifest.json index bfaab32..d664951 100644 --- a/manifest.json +++ b/manifest.json @@ -1,6 +1,6 @@ { "name": "RacesOfValheim", - "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling) each with unique abilities, traits, and a deep boss-driven progression system.", + "description": "A Valheim mod that adds custom playable races (Skeleton, Skadi, Fenrir, Aswid, Furling, Trol) each with unique abilities, traits, and a deep boss-driven progression system.", "version_number": "1.3.6", "website_url": "", "dependencies": [ From 272adddd753b81ef33dcfdb2a2783797b83ae441 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sat, 1 Aug 2026 17:49:12 +0200 Subject: [PATCH 031/429] small fix to aswin aura --- JotunnModStub/Aswid/AswidRace.cs | 14 ++++++++++---- JotunnModStub/RacesOfValheim.csproj | 12 ++++-------- 2 files changed, 14 insertions(+), 12 deletions(-) diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 3b1f9ec..591807e 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -133,10 +133,15 @@ namespace RacesOfValheim if (c != null) { float foodHp = Mathf.Min(c.m_health / 2f, 150f); + float burnTime = c.m_health * 2f; + if (mobName == "Cultist" || mobName.StartsWith("Fenring") || mobName.StartsWith("Fuling")) + { + burnTime = 1200f; // 20 minutes + } customItem.ItemDrop.m_itemData.m_shared.m_food = foodHp; customItem.ItemDrop.m_itemData.m_shared.m_foodStamina = 0f; customItem.ItemDrop.m_itemData.m_shared.m_foodEitr = 0f; - customItem.ItemDrop.m_itemData.m_shared.m_foodBurnTime = c.m_health * 2f; + customItem.ItemDrop.m_itemData.m_shared.m_foodBurnTime = burnTime; customItem.ItemDrop.m_itemData.m_shared.m_foodRegen = 1f; } } @@ -1030,13 +1035,14 @@ namespace RacesOfValheim float maxHp = c.GetMaxHealth(); float currentHp = c.GetHealth(); - float baseDamage = 1.0f; // Reduced by 50% + float baseDamage = 2.0f; float bloodMagicFactor = Player.m_localPlayer.GetSkillFactor(Skills.SkillType.BloodMagic); - float totalDamage = baseDamage + (baseDamage * bloodMagicFactor); + // Lo scaling aggiunge un massimo di +1.0 danni (al livello 100), indipendentemente dal danno base + float totalDamage = baseDamage + bloodMagicFactor; if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_MistForm".GetStableHashCode())) { - totalDamage *= 0.5f; + totalDamage *= 2.0f; // Damage doubled in Mist Form } if (currentHp > 0 && currentHp <= maxHp * 0.20f && !c.IsBoss()) diff --git a/JotunnModStub/RacesOfValheim.csproj b/JotunnModStub/RacesOfValheim.csproj index 6029e4c..3bdca4a 100644 --- a/JotunnModStub/RacesOfValheim.csproj +++ b/JotunnModStub/RacesOfValheim.csproj @@ -93,15 +93,11 @@ - - - $(SolutionDir)dist\ - - + - - - + + + From a8a14f0416e9bd4ff1f7b3b6d748e9d4d061dead Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 1 Aug 2026 18:02:24 +0200 Subject: [PATCH 032/429] Move Freezing-to-Cold to Bonemass and eitr regen to Yagluth Eikthyr was carrying three unlocks while later tiers carried little, so the two passives move up: the Freezing-to-Cold conversion now lands with Bonemass alongside the drake's attack, and eitr regeneration first appears at Yagluth with the improved Cold Spell. The +20% at Eikthyr is dropped rather than relocated, since Yagluth already granted an undocumented +50% - now written down in the README. --- JotunnModStub/Skadi/SkadiProgression.cs | 7 +++++-- README.md | 6 +++--- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/JotunnModStub/Skadi/SkadiProgression.cs b/JotunnModStub/Skadi/SkadiProgression.cs index 63d8558..63abac7 100644 --- a/JotunnModStub/Skadi/SkadiProgression.cs +++ b/JotunnModStub/Skadi/SkadiProgression.cs @@ -46,11 +46,14 @@ namespace RacesOfValheim if (state >= 2) { - rules.EitrRegenMultiplier = 1.20f; - rules.FreezingToCold = true; rules.ColdSpell = true; } + if (state >= 4) + { + rules.FreezingToCold = true; + } + if (state >= 6) { rules.EitrRegenMultiplier = 1.50f; diff --git a/README.md b/README.md index e2e1fb5..2c30ec4 100644 --- a/README.md +++ b/README.md @@ -81,11 +81,11 @@ This mod currently introduces 6 custom races: ### Skadi Progression - **Base (No Bosses)**: Immune to Cold, Bonus Frost Damage, 50% Frost Resistance. -- **Eikthyr**: +20% Eitr Regen, Freezing to Cold, Cold Spell (Middle Mouse). +- **Eikthyr**: Cold Spell (Middle Mouse). - **The Elder**: Drake Form ('G' Key) (Cannot attack). -- **Bonemass**: Drake Form ('G' Key) (Can attack). +- **Bonemass**: Freezing to Cold. Drake Form ('G' Key) (Can attack). - **Moder**: Moder Form ('H' Key) (1 min duration, 10 min cooldown). -- **Yagluth**: Improved Cold Spell. Moder Form ('H' Key) (1 min duration, 5 min cooldown). +- **Yagluth**: +50% Eitr Regen. Improved Cold Spell. Moder Form ('H' Key) (1 min duration, 5 min cooldown). - **The Queen**: Moder Form ('H' Key) (Unlimited duration, no cooldown). - **Fader**: Skeleton Dragon Form ('J' Key). From fc7fd544041aa393563f4792c8a7d7bfdbb9e890 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 1 Aug 2026 18:02:24 +0200 Subject: [PATCH 033/429] Rework Skadi combat costs, fix dead melee, add cooldown icons Dragon melee never dealt damage at all: the damage block sat behind !isMelee, so bite, claw and spin played an animation, charged eitr and did nothing. Melee now sweeps for targets the way Fenrir's claws do, and costs nothing - it is the baseline attack that has to work at every tier. Everything Skadi casts now runs on stamina rather than eitr. Eitr food only exists from the Mistlands on, while the Cold Spell unlocks at Eikthyr and the drake at the Elder, so the old costs were either unpayable or, in the drake's case, silently ignored because UseEitr never checked affordability. Ranged volleys are charged per projectile so the sixty shard breath no longer costs the same as a three shard spit, capped so the widest one stays castable. The Cold Spell also stopped borrowing the Staff of Frost's damage, which handed out Mistlands numbers from Eikthyr and multiplied them by every shard. It now scales with progression, and the improved cast spreads one budget across its shards: wider, not stronger. The kick that played over every cast was Valheim's own SecondaryAttack, bound to the same Middle Mouse button - suppressed for a Skadi holding the spell. Moder now keeps its ranged attack on Middle Mouse in the air as on the ground, with no left hand attack aloft, and Fader's airborne branch is gone since its form cannot fly. Ability cooldowns finally show on the HUD, each with its own icon and a live countdown. --- JotunnModStub/Skadi/DrakeFormBehavior.cs | 194 +++++++++++++++++----- JotunnModStub/Skadi/SkadiPatches.cs | 20 ++- JotunnModStub/Skadi/SkadiRace.cs | 86 ++++++++-- JotunnModStub/Skadi/SkadiStatusEffects.cs | 7 + 4 files changed, 251 insertions(+), 56 deletions(-) diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index 62941b0..23884cf 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -49,9 +49,25 @@ namespace RacesOfValheim return live != null && live.Form == formRules.Form && live.CanAttackInForm; } - private const float ATTACK_COST = 20f; private const float ATTACK_COOLDOWN = 3f; + // Ranged volleys charge per projectile rather than a flat fee, so the 20- and 60-shard + // breaths cost what they are worth instead of the same as a three-shard drake spit. + // Stamina rather than eitr, for the same reason the Cold Spell uses it: eitr food only + // exists from the Mistlands on, while the drake form arrives at the Elder, so an eitr + // cost left the earliest dragon tiers with no attack they could actually pay for. + private const float STAMINA_PER_PROJECTILE = 1.5f; + // Ceiling so the widest breath stays castable: 60 shards would otherwise ask 90 stamina. + private const float MAX_VOLLEY_STAMINA = 85f; + + // Melee costs nothing at all - it is the baseline attack that has to work at every tier, + // including the long stretch where the player has no eitr whatsoever. + private const float MELEE_RADIUS = 3f; + private const float MODER_MELEE_DAMAGE = 90f; + private const float FADER_MELEE_DAMAGE = 120f; + private const float FADER_SPIN_DAMAGE = 100f; + private const float FADER_SPIN_RADIUS = 5f; + private void Start() { Active = this; @@ -126,7 +142,7 @@ namespace RacesOfValheim { if (Input.GetMouseButtonDown(0)) { - if (Time.time - lastAttackTime >= ATTACK_COOLDOWN) + if (HasAttackForButton(0) && Time.time - lastAttackTime >= ATTACK_COOLDOWN) { StartCoroutine(PerformAttackCoroutine(0)); } @@ -148,15 +164,44 @@ namespace RacesOfValheim } } + // 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. + private bool HasAttackForButton(int button) + { + if (formRules == null) return false; + + bool airborne = isFlying || isLanding; + if (airborne && formRules.Form == SkadiProgression.FormType.Moder && button != 2) + { + return false; + } + + return true; + } + + private bool TrySpendVolleyStamina(int projCount) + { + 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"); + return false; + } + Player.m_localPlayer.UseStamina(cost); + return true; + } + private IEnumerator PerformAttackCoroutine(int button) { lastAttackTime = Time.time; + SkadiRace.ApplyCooldownIcon(SkadiRace.ATTACK_COOLDOWN_SE, ATTACK_COOLDOWN); if (formRules.Form == SkadiProgression.FormType.Drake) { if (button == 2) yield break; // Drake only uses LMB - - Player.m_localPlayer.UseEitr(ATTACK_COST); + + if (!TrySpendVolleyStamina(3)) yield break; if (anim != null) anim.SetTrigger("attack"); // Delay to match animation spit timing @@ -229,12 +274,17 @@ namespace RacesOfValheim projDelay = 0.5f; } } - - Player.m_localPlayer.UseEitr(ATTACK_COST); + + if (!isMelee && !TrySpendVolleyStamina(projCount)) yield break; if (anim != null) anim.SetTrigger(attackTrigger); - + yield return new WaitForSeconds(projDelay); + if (isMelee) + { + ExecuteMeleeDamage(MODER_MELEE_DAMAGE, MELEE_RADIUS); + } + if (!isMelee && projName != null) { GameObject projPrefab = PrefabManager.Cache.GetPrefab(projName); @@ -277,51 +327,50 @@ namespace RacesOfValheim int projCount = 1; float projDelay = 0.5f; bool isMelee = true; + float meleeDamage = FADER_MELEE_DAMAGE; + float meleeRadius = MELEE_RADIUS; - if (isFlying || isLanding) + // No airborne branch here: the flight toggle in Update excludes SkeletonDragon, + // so this form never leaves the ground and any air attack would be unreachable. + if (button == 2) { - // Air attack (Meteors replacement -> Ice Barrage) - attackTrigger = "attack_roar"; // taunt animation has issues in air - projName = "dragon_ice_projectile"; // spawn_fader_meteors is buggy without Fader boss script - projCount = 16; - projDelay = 1.0f; + // Ground MMB (Frost Breath stream) + attackTrigger = "attack_flamebreath"; + projName = "hatchling_cold_projectile"; + projCount = 60; // Tripled! + projDelay = 0.5f; isMelee = false; } + else if (button == 1) + { + // Ground RMB (Spin) - hits all around rather than in a forward arc + attackTrigger = "attack_Spin"; + isMelee = true; + projDelay = 0.5f; + meleeDamage = FADER_SPIN_DAMAGE; + meleeRadius = FADER_SPIN_RADIUS; + } else { - if (button == 2) - { - // Ground MMB (Frost Breath stream) - attackTrigger = "attack_flamebreath"; - projName = "hatchling_cold_projectile"; - projCount = 60; // Tripled! - projDelay = 0.5f; - isMelee = false; - } - else if (button == 1) - { - // Ground RMB (Spin) - attackTrigger = "attack_Spin"; - isMelee = true; - projDelay = 0.5f; - } - else - { - // Ground LMB (Melee mix - bite/claws) - float rand = UnityEngine.Random.value; - if (rand < 0.33f) attackTrigger = "attack_bite"; - else if (rand < 0.66f) attackTrigger = "attack_ClawL"; - else attackTrigger = "attack_ClawR"; - isMelee = true; - projDelay = 0.5f; - } + // Ground LMB (Melee mix - bite/claws) + float rand = UnityEngine.Random.value; + if (rand < 0.33f) attackTrigger = "attack_bite"; + else if (rand < 0.66f) attackTrigger = "attack_ClawL"; + else attackTrigger = "attack_ClawR"; + isMelee = true; + projDelay = 0.5f; } - Player.m_localPlayer.UseEitr(ATTACK_COST); + if (!isMelee && !TrySpendVolleyStamina(projCount)) yield break; if (anim != null) anim.SetTrigger(attackTrigger); - + yield return new WaitForSeconds(projDelay); + if (isMelee) + { + ExecuteMeleeDamage(meleeDamage, meleeRadius); + } + if (!isMelee && projName != null) { GameObject projPrefab = PrefabManager.Cache.GetPrefab(projName); @@ -377,6 +426,69 @@ namespace RacesOfValheim } } + // The dragon forms never go through Humanoid.StartAttack - SkadiAttackPatch blocks it, and + // they carry no weapon - so the bite, claw and spin animations landed no damage at all and + // simply burned eitr. Sweep for targets the way FenrirBehaviors does for its claws. + private void ExecuteMeleeDamage(float baseDamage, float radius) + { + if (Player.m_localPlayer == null) return; + + Vector3 playerPos = Player.m_localPlayer.transform.position; + Vector3 forward = Player.m_localPlayer.transform.forward; + Vector3 attackPoint = playerPos + forward * 2f + Vector3.up * 1f; + + // Spin sweeps all around; the directional attacks stay in a forward arc. + bool fullCircle = radius >= FADER_SPIN_RADIUS; + float totalDamage = baseDamage + Player.m_localPlayer.GetSkillLevel(Skills.SkillType.Unarmed); + if (fullCircle) attackPoint = playerPos + Vector3.up * 1f; + + int layerMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "piece_nonsolid", "terrain", "character", "character_net", "character_ghost", "hitbox", "character_noenv", "vehicle"); + Collider[] hits = Physics.OverlapSphere(attackPoint, radius, layerMask); + System.Collections.Generic.HashSet hitObjects = new System.Collections.Generic.HashSet(); + + foreach (Collider hit in hits) + { + if (hit.gameObject == Player.m_localPlayer.gameObject) continue; + if (hit.attachedRigidbody != null && hit.attachedRigidbody.gameObject == Player.m_localPlayer.gameObject) continue; + + IDestructible target = hit.GetComponentInParent(); + if (target == null) continue; + + Character characterTarget = target as Character; + if (characterTarget != null && characterTarget == Player.m_localPlayer) continue; + + GameObject targetObj = (target as MonoBehaviour)?.gameObject; + if (targetObj != null) + { + if (hitObjects.Contains(targetObj)) continue; + hitObjects.Add(targetObj); + } + + Vector3 targetCenter = hit.bounds.center; + Vector3 dirToTarget = (targetCenter - playerPos).normalized; + if (!fullCircle && Vector3.Angle(forward, dirToTarget) >= 70f) continue; + + Vector3 eyePos = playerPos + Vector3.up * 1.5f; + if (Physics.Linecast(eyePos, targetCenter, out RaycastHit rayHit, LayerMask.GetMask("Default", "static_solid", "terrain", "piece"))) continue; + + HitData hitData = new HitData(); + // Frost-flavoured maul; SkadiDamagePatch tops this up with the per-tier frost bonus. + hitData.m_damage.m_blunt = totalDamage * 0.6f; + hitData.m_damage.m_frost = totalDamage * 0.4f; + hitData.m_pushForce = 40f; + hitData.m_point = targetCenter; + hitData.m_dir = dirToTarget; + hitData.m_skill = Skills.SkillType.Unarmed; + hitData.m_dodgeable = true; + hitData.m_blockable = true; + hitData.m_hitType = HitData.HitType.PlayerHit; + hitData.m_toolTier = 0; + hitData.SetAttacker(Player.m_localPlayer); + + target.Damage(hitData); + } + } + private void OnDestroy() { if (Active == this) Active = null; diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index e38a81e..7007e03 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -282,12 +282,28 @@ namespace RacesOfValheim [HarmonyPatch(typeof(Humanoid), "StartAttack")] public static class SkadiAttackPatch { - public static bool Prefix(Humanoid __instance) + public static bool Prefix(Humanoid __instance, bool secondaryAttack) { - if (__instance == Player.m_localPlayer && __instance.GetComponentInChildren() != null) + if (__instance != Player.m_localPlayer) return true; + + if (__instance.GetComponentInChildren() != null) { return false; } + + // Valheim binds its own SecondaryAttack action to Middle Mouse, the same button the + // Cold Spell casts on, so pressing it also swung the unarmed secondary - the kick that + // kept showing up alongside the cast no matter which animation trigger we used. For a + // Skadi who has the spell, Middle Mouse belongs to the spell. Keyed off the live button + // state rather than a flag set during our Update, so it does not depend on whether + // PlayerController's FixedUpdate happens to run first. + if (secondaryAttack && Input.GetMouseButton(2) && + SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi()) + { + var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState()); + if (rules.ColdSpell) return false; + } + return true; } } diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 1b45633..abd1c4b 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -24,6 +24,21 @@ namespace RacesOfValheim private float lastAuraTime = 0f; private GameObject frostAuraVFX = null; + // Cold Spell tuning. Damage is 15 + 8 per progression state, so it runs from roughly 31 at + // Eikthyr to 79 at Fader - deliberately a notch under the melee options of the other races + // at each tier, which is the trade for hitting at range on a short cooldown. + public const string SPELL_COOLDOWN_SE = "SE_SkadiSpellCooldown"; + public const string ATTACK_COOLDOWN_SE = "SE_SkadiAttackCooldown"; + + private const float SPELL_STAMINA_COST = 20f; + private const float SPELL_COOLDOWN = 1.5f; + private const float IMPROVED_SPELL_COOLDOWN = 4f; + private const float SPELL_BASE_DAMAGE = 15f; + private const float SPELL_DAMAGE_PER_STATE = 8f; + private const int IMPROVED_SPELL_SHARDS = 10; + // The improved cast spreads 1.6 casts worth of damage over its shards: wider, not stronger. + private const float IMPROVED_SPELL_DAMAGE_BUDGET = 1.6f; + private void Awake() { Instance = this; @@ -52,7 +67,7 @@ namespace RacesOfValheim // Timed forms and their cooldown are Moder's, so they carry her trophy rather than the // drake one used for the passive blessing. - Sprite dragonIcon = GetTrophyIcon("TrophyDragonQueen") ?? GetTrophyIcon("TrophyHatchling"); + Sprite dragonIcon = GetItemIcon("TrophyDragonQueen") ?? GetItemIcon("TrophyHatchling"); skadiCdSE = ScriptableObject.CreateInstance(); skadiCdSE.name = "SE_SkadiCooldown"; @@ -66,9 +81,40 @@ namespace RacesOfValheim skadiFormSE.m_tooltip = "Your dragon shape holds for a while longer."; skadiFormSE.m_icon = dragonIcon; ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(skadiFormSE, fixReference: false)); + + // Per-ability cooldowns. Each gets its own icon so a spell on cooldown reads + // 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_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_icon = GetItemIcon("TrophyHatchling") ?? dragonIcon; + ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(attackCd, fixReference: false)); } - private static Sprite GetTrophyIcon(string prefabName) + // Drives the HUD countdown: Valheim prints the remaining time on any status effect whose + // m_ttl is set, so the cooldown only has to exist for the icon to tick down by itself. + public static void ApplyCooldownIcon(string effectName, float seconds) + { + if (Player.m_localPlayer == null || seconds <= 0f) return; + + int hash = effectName.GetStableHashCode(); + SEMan seman = Player.m_localPlayer.GetSEMan(); + seman.RemoveStatusEffect(hash, true); + seman.AddStatusEffect(hash, true); + + StatusEffect se = seman.GetStatusEffect(hash); + if (se != null) se.m_ttl = seconds; + } + + private static Sprite GetItemIcon(string prefabName) { GameObject trophy = PrefabManager.Cache.GetPrefab(prefabName)?.gameObject; ItemDrop drop = trophy != null ? trophy.GetComponent() : null; @@ -264,24 +310,29 @@ namespace RacesOfValheim // Middle Mouse Button to cast if (Input.GetMouseButtonDown(2)) { - float cooldown = rules.ImprovedColdSpell ? 2.0f : 1.5f; + // 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 (!Player.m_localPlayer.HaveEitr(10f)) + // 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. + if (!Player.m_localPlayer.HaveStamina(SPELL_STAMINA_COST)) { - Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Not enough Eitr"); + Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Not enough stamina"); return; } - Player.m_localPlayer.UseEitr(10f); + Player.m_localPlayer.UseStamina(SPELL_STAMINA_COST); lastSpellTime = Time.time; + ApplyCooldownIcon(SPELL_COOLDOWN_SE, cooldown); var zanim = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_zanim").Value; if (zanim != null) { - // Raised-arms Galdr cast gesture instead of the unarmed kick, so the cast - // reads as a spell instead of a leg swing near the ground. - zanim.SetTrigger("galdr_cast"); + // "galdr_cast" is not one of the triggers Valheim actually defines, so it + // never fired and the unarmed kick stayed. "gpower" is the guardian power + // raise: both arms up, which reads as casting rather than a leg swing. + zanim.SetTrigger("gpower"); } StartCoroutine(ColdSpellKickCoroutine(rules)); @@ -307,14 +358,23 @@ namespace RacesOfValheim { projPrefab = PrefabManager.Cache.GetPrefab(projName); } - if (projPrefab == null) + if (projPrefab == null) { projPrefab = staffDrop.m_itemData.m_shared.m_attack.m_attackProjectile; // Default Staff of Frost projectile } if (projPrefab == null) yield break; - int count = rules.ImprovedColdSpell ? 10 : 1; - + int count = rules.ImprovedColdSpell ? IMPROVED_SPELL_SHARDS : 1; + + // The staff prefab is borrowed for its projectile visuals and velocity only. Its damage + // is Mistlands-tier, which the spell used to hand out in full from Eikthyr onward, and + // once per shard - so the improved cast was a ten times nuke rather than a wider one. + // Scale with progression instead, and split one budget across the shards. + int state = BossProgressionManager.GetCurrentProgressionState(); + float castDamage = SPELL_BASE_DAMAGE + SPELL_DAMAGE_PER_STATE * state; + if (count > 1) castDamage *= IMPROVED_SPELL_DAMAGE_BUDGET; + float shardDamage = castDamage / count; + for (int i = 0; i < count; i++) { if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) break; @@ -336,7 +396,7 @@ namespace RacesOfValheim if (proj != null) { HitData hitData = new HitData(); - hitData.m_damage = staffDrop.m_itemData.m_shared.m_damages; + hitData.m_damage.m_frost = shardDamage; hitData.SetAttacker(Player.m_localPlayer); proj.Setup(Player.m_localPlayer, lookDir * staffDrop.m_itemData.m_shared.m_attack.m_projectileVel, -1f, hitData, staffDrop.m_itemData, null); } diff --git a/JotunnModStub/Skadi/SkadiStatusEffects.cs b/JotunnModStub/Skadi/SkadiStatusEffects.cs index b6517af..dc6e3ee 100644 --- a/JotunnModStub/Skadi/SkadiStatusEffects.cs +++ b/JotunnModStub/Skadi/SkadiStatusEffects.cs @@ -10,6 +10,13 @@ namespace RacesOfValheim { } + // Short ability cooldowns, shown purely so the HUD can count them down. Silent by design, + // unlike SE_FormCooldown which announces "... is Ready!" when it stops: tolerable once every + // few minutes for a dragon form, unbearable every three seconds for an attack. + public class SE_SkadiAbilityCooldown : StatusEffect + { + } + public class SE_SkadiStats : SE_Stats { public override void Setup(Character character) From 5d5a6eab42a673919661fc052711a49ff612d581 Mon Sep 17 00:00:00 2001 From: kanym Date: Sat, 1 Aug 2026 18:02:24 +0200 Subject: [PATCH 034/429] Fill in the Skadi compendium entry It was a placeholder reading "The secrets of winter will be revealed soon...". It now unfolds tier by tier like the Aswid and Furling ones, covering the passives, the form keybinds, the flight controls and which attacks are free. The frost bonus and spell damage figures are computed from the same formulas the code uses, so the text cannot drift when those constants are tuned. --- JotunnModStub/RaceCompendium.cs | 61 ++++++++++++++++++++++++++++++++- 1 file changed, 60 insertions(+), 1 deletion(-) diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 180472b..299f5cb 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -153,7 +153,66 @@ namespace RacesOfValheim private static void GenerateSkadiText(Dictionary knownTexts, int state) { - knownTexts["Skadi Secrets"] = "The secrets of winter will be revealed soon..."; + // Mirrors the live values so the entry cannot drift from the code: the frost bonus is + // SkadiDamagePatch's 2 per state, the spell figure SkadiRace's 15 + 8 per state. + int frostBonus = state * 2; + int spellDamage = 15 + 8 * state; + + StringBuilder sb = new StringBuilder(); + sb.AppendLine("The Secrets of Winter\n"); + + sb.AppendLine("[Base Passive] Ice Affinity:"); + sb.AppendLine($"The cold cannot touch you, and frost answers to your hand. You are immune to the Cold status, take only half damage from frost, and every blow you land carries +{frostBonus} Frost damage - a bonus that grows as each boss falls.\n"); + + if (state >= 2) + { + sb.AppendLine("[Eikthyr Unlock] Cold Spell (Middle Mouse):"); + sb.AppendLine($"Hurl a shard of ice at whatever you look upon, for {spellDamage} Frost damage. It draws on 20 stamina rather than eitr, so it serves you from your very first winter.\n"); + } + + if (state >= 3) + { + sb.AppendLine("[The Elder Unlock] Drake Form ('G' Key):"); + sb.AppendLine("Take the shape of a frost drake. Right Mouse lifts you into flight: you glide wherever you aim, hold W to climb and gather speed, and release to hold level a moment before settling into a slow descent. In this shape you cannot yet strike.\n"); + } + + if (state >= 4) + { + sb.AppendLine("[Bonemass Unlock] Winter's Welcome (Passive):"); + sb.AppendLine("The killing gales of the mountains soften to a mere chill - you suffer Cold where others would freeze.\n"); + sb.AppendLine("[Bonemass Unlock] Drake Breath (Left Mouse):"); + sb.AppendLine("Your drake form may now spit ice at your enemies.\n"); + } + + if (state >= 5) + { + sb.AppendLine("[Moder Unlock] Moder Form ('H' Key):"); + sb.AppendLine("Become the great frost dragon herself for 1 minute, then wait 10 before calling her again. Afoot, Left Mouse bites and claws for no cost at all, while Middle Mouse breathes a stream of ice. On the wing, Left Mouse looses a barrage of shards. Only the breath and the barrage draw upon eitr.\n"); + } + + if (state >= 6) + { + sb.AppendLine("[Yagluth Unlock] Heart of Winter (Passive):"); + sb.AppendLine("Freezing can no longer reach you at all, and your eitr returns half again as fast.\n"); + sb.AppendLine("[Yagluth Unlock] Improved Cold Spell:"); + sb.AppendLine("Your Cold Spell scatters into ten shards, spreading its bite across all before you. The wider cast needs 4 seconds to gather itself.\n"); + sb.AppendLine("Moder Form now answers you again after only 5 minutes.\n"); + } + + if (state >= 7) + { + sb.AppendLine("[The Queen Unlock] Winter Incarnate (Passive):"); + sb.AppendLine("Frost cannot wound you at all, and a freezing aura bleeds from your skin, gnawing at every untamed creature within 3 meters.\n"); + sb.AppendLine("Moder Form may now be held as long as you wish, with no wait between callings.\n"); + } + + if (state >= 8) + { + sb.AppendLine("[Fader Unlock] Skeleton Dragon Form ('J' Key):"); + sb.AppendLine("The bones of a dragon rise at your call, wreathed in frost. It rends with bite and claw, sweeps all around it with a spinning tail (Right Mouse), and its breath carries thrice the fury of Moder's.\n"); + } + + knownTexts["Skadi Secrets"] = sb.ToString(); } private static void GenerateSkeletonText(Dictionary knownTexts, int state) From be2f7a73cde9c5b8ec95330a4cfcee41271aaab0 Mon Sep 17 00:00:00 2001 From: Ferdinando Date: Sun, 2 Aug 2026 08:30:53 +0200 Subject: [PATCH 035/429] draughfirstdraft --- JotunnModStub/Aswid/AswidRace.cs | 170 +-------- JotunnModStub/Draugh/DraughFoodPatches.cs | 23 +- JotunnModStub/Draugh/DraughPatches.cs | 30 +- .../Draugh/DraughProgressionPatches.cs | 355 ++++++++++++++++++ JotunnModStub/Draugh/DraughRace.cs | 85 ++++- JotunnModStub/RaceCompendium.cs | 38 +- JotunnModStub/RaceHostilityManager.cs | 11 + JotunnModStub/RacesOfValheim.cs | 2 +- 8 files changed, 553 insertions(+), 161 deletions(-) create mode 100644 JotunnModStub/Draugh/DraughProgressionPatches.cs diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs index 591807e..040534c 100644 --- a/JotunnModStub/Aswid/AswidRace.cs +++ b/JotunnModStub/Aswid/AswidRace.cs @@ -12,9 +12,10 @@ namespace RacesOfValheim private static Dictionary mobToTrophyMap = new Dictionary { { "Boar", "TrophyBoar" }, + { "Greyling", "TrophyGreyling" }, { "Neck", "TrophyNeck" }, { "Greydwarf", "TrophyGreydwarf" }, - { "Greydwarf_Elite", "TrophyGreydwarfElite" }, + { "Greydwarf_Elite", "TrophyGreydwarfBrute" }, { "Greydwarf_Shaman", "TrophyGreydwarfShaman" }, { "Troll", "TrophyFrostTroll" }, { "Deer", "TrophyDeer" }, @@ -119,7 +120,7 @@ namespace RacesOfValheim } else { - customItem = new Jotunn.Entities.CustomItem(foodName, "RawMeat", config); + customItem = new Jotunn.Entities.CustomItem(foodName, "CookedMeat", config); } if (customItem != null && customItem.ItemDrop != null) @@ -244,50 +245,18 @@ namespace RacesOfValheim // Locally generate the visual if (!activeSensesLight.ContainsKey(c)) { - GameObject prefab = ZNetScene.instance?.GetPrefab("piece_groundtorch_green"); - if (prefab != null) - { - ZNetView.m_forceDisableInit = true; - GameObject tempObj = Instantiate(prefab); - ZNetView.m_forceDisableInit = false; + GameObject lightObj = new GameObject("AswidSensesLight"); + lightObj.transform.SetParent(c.transform); + lightObj.transform.position = c.GetCenterPoint(); - GameObject lightObj = new GameObject("AswidSensesLight"); - lightObj.transform.SetParent(c.transform); - lightObj.transform.localPosition = Vector3.zero; + Light pLight = lightObj.AddComponent(); + pLight.type = LightType.Point; + pLight.color = Color.green; + pLight.range = 10f; + pLight.intensity = 2f; + pLight.shadows = LightShadows.None; - Transform enabledNode = tempObj.transform.Find("_enabled"); - if (enabledNode != null) - { - enabledNode.SetParent(lightObj.transform); - enabledNode.localPosition = Vector3.zero; - enabledNode.localScale = new Vector3(2.2f, 2.2f, 2.2f); - - // FORCE ACTIVE because Fireplace script might have disabled it due to no fuel! - enabledNode.gameObject.SetActive(true); - - foreach (var col in enabledNode.GetComponentsInChildren(true)) Destroy(col); - foreach (var audio in enabledNode.GetComponentsInChildren(true)) Destroy(audio); - - foreach (var l in enabledNode.GetComponentsInChildren(true)) - { - if (l != null) l.range *= 2.2f; - } - - foreach (var mb in enabledNode.GetComponentsInChildren(true)) - { - if (mb == null) continue; - string typeName = mb.GetType().Name; - if (typeName != "ParticleSystem" && typeName != "LightFlicker") - { - Destroy(mb); - } - } - } - - Destroy(tempObj); - - activeSensesLight[c] = lightObj; - } + activeSensesLight[c] = lightObj; } } catch (Exception ex) @@ -354,111 +323,7 @@ namespace RacesOfValheim UpdateSuperhumanSenses(); - if (Input.GetKeyDown(KeyCode.F8)) - { - Jotunn.Logger.LogInfo("[AswidDebug] F8 Pressed. Dumping Player Visuals:"); - VisEquipment vis = Player.m_localPlayer.GetComponentInChildren(); - if (vis != null) - { - Jotunn.Logger.LogInfo($"[AswidDebug] m_bodyModel.enabled: {(vis.m_bodyModel != null ? vis.m_bodyModel.enabled.ToString() : "null")}"); - - var legItems = Traverse.Create(vis).Field("m_legItemInstances").GetValue>(); - if (legItems != null) - { - foreach (var go in legItems) Jotunn.Logger.LogInfo($"[AswidDebug] LegItem: {go.name}, Active: {go.activeSelf}"); - } - - var chestItems = Traverse.Create(vis).Field("m_chestItemInstances").GetValue>(); - if (chestItems != null) - { - foreach (var go in chestItems) Jotunn.Logger.LogInfo($"[AswidDebug] ChestItem: {go.name}, Active: {go.activeSelf}"); - } - } - - Transform visual = Player.m_localPlayer.transform.Find("Visual"); - if (visual != null) - { - foreach (var smr in visual.GetComponentsInChildren(true)) - { - Jotunn.Logger.LogInfo($"[AswidDebug] Player SMR: {smr.name} | Active: {smr.gameObject.activeSelf} | Enabled: {smr.enabled}"); - } - } - - GameObject geirrhafaPrefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab("Fenring_Cultist_Hildir"); - if (geirrhafaPrefab != null) - { - Jotunn.Logger.LogInfo("[AswidDebug] GEIRRHAFA PREFAB DUMP:"); - foreach (var smr in geirrhafaPrefab.GetComponentsInChildren(true)) - { - Jotunn.Logger.LogInfo($"[AswidDebug] Geirrhafa SMR: {smr.name} | Bones: {smr.bones.Length}"); - } - } - - List allChars = Character.GetAllCharacters(); - Vector3 myPos = Player.m_localPlayer.transform.position; - - int charsInRange = 0; - foreach (var c in allChars) - { - if (c == null || c == Player.m_localPlayer || c.IsDead() || c.IsTamed()) continue; - float dist = Vector3.Distance(c.transform.position, myPos); - if (dist <= 100f) - { - charsInRange++; - bool hasLight = activeSensesLight.ContainsKey(c); - bool hasMalus = c.GetSEMan() != null && c.GetSEMan().HaveStatusEffect("SE_AswidSensesMark".GetStableHashCode()); - Jotunn.Logger.LogInfo($"[AswidDebug] In range: {c.name} (Dist: {dist}), HasLight: {hasLight}, HasMalus: {hasMalus}"); - - if (hasLight) - { - GameObject lightObj = activeSensesLight[c]; - if (lightObj != null) - { - Jotunn.Logger.LogInfo($"[AswidDebug] LightObj: {lightObj.name}, ActiveSelf: {lightObj.activeSelf}, ActiveInHierarchy: {lightObj.activeInHierarchy}"); - Jotunn.Logger.LogInfo(DumpGameObject(lightObj, " ")); - } - else - { - Jotunn.Logger.LogInfo($"[AswidDebug] LightObj is NULL!"); - } - } - } - } - Jotunn.Logger.LogInfo($"[AswidDebug] Total valid chars in range: {charsInRange}"); - Jotunn.Logger.LogInfo($"[AswidDebug] activeSensesLight count: {activeSensesLight.Count}"); - - Jotunn.Logger.LogInfo("[AswidDebug] F8 pressed! Finding nearest mob to consume..."); - Character nearest = null; - float minDist = 10f; - foreach (Character c in Character.GetAllCharacters()) - { - if (c != Player.m_localPlayer && c.GetHealth() > 0) - { - float dist = UnityEngine.Vector3.Distance(Player.m_localPlayer.transform.position, c.transform.position); - if (dist < minDist) - { - minDist = dist; - nearest = c; - } - } - } - - if (nearest != null) - { - Jotunn.Logger.LogInfo($"[AswidDebug] Consuming {nearest.name} via F8!"); - TryConsumeMob(nearest, nearest.GetMaxHealth()); - - HitData hit = new HitData(); - hit.m_damage.m_damage = 99999f; - hit.m_hitType = HitData.HitType.Undefined; - hit.m_attacker = Player.m_localPlayer.GetZDOID(); - nearest.ApplyDamage(hit, true, false); - } - else - { - Jotunn.Logger.LogInfo("[AswidDebug] No mob found near player to consume."); - } - } + try { @@ -518,7 +383,7 @@ namespace RacesOfValheim TryCastEclipse(state); return; } - if (Input.GetKeyDown(KeyCode.K)) + if (Input.GetKeyDown(KeyCode.U)) { TryTameHoverObject(state); return; @@ -1222,3 +1087,8 @@ namespace RacesOfValheim public class NightAuraTintFlag : MonoBehaviour { } } + + + + + diff --git a/JotunnModStub/Draugh/DraughFoodPatches.cs b/JotunnModStub/Draugh/DraughFoodPatches.cs index d734b64..b517648 100644 --- a/JotunnModStub/Draugh/DraughFoodPatches.cs +++ b/JotunnModStub/Draugh/DraughFoodPatches.cs @@ -35,7 +35,22 @@ namespace RacesOfValheim public static bool UseItem_Prefix(Humanoid __instance, Inventory inventory, ItemDrop.ItemData item, bool fromInventoryGui) { Player player = __instance as Player; - if (player == null || player != Player.m_localPlayer || !DraughRace.IsDraugh() || item == null || item.m_shared == null) return true; + if (player == null || player != Player.m_localPlayer || item == null || item.m_shared == null) return true; + + // Prevent non-Draughs from eating Human Meat + if (item.m_dropPrefab != null && item.m_dropPrefab.name == "HumanMeat") + { + if (!DraughRace.IsDraugh()) + { + player.Message(MessageHud.MessageType.Center, "This rotting flesh is fatal to the living."); + return false; // Block consumption + } + // If it IS a Draugh, let them consume it via native mechanics + return true; + } + + // Normal Draugh Food restrictions + if (!DraughRace.IsDraugh()) return true; // Intercept right click on raw items. // In UseItem, if it's a Consumable, Valheim will process it. If it's our EdibleUncooked_, it's a Consumable! @@ -64,6 +79,12 @@ namespace RacesOfValheim if (ate) { inventory.RemoveItem(item, 1); + + var consumeEffects = Traverse.Create(player).Field("m_consumeItemEffects").GetValue(); + if (consumeEffects != null) consumeEffects.Create(player.transform.position, Quaternion.identity, player.transform, 1f, -1); + + var zanim = Traverse.Create(player).Field("m_zanim").GetValue(); + if (zanim != null) zanim.SetTrigger("eat"); } return false; // Skip native UseItem } diff --git a/JotunnModStub/Draugh/DraughPatches.cs b/JotunnModStub/Draugh/DraughPatches.cs index 88cf022..92784c2 100644 --- a/JotunnModStub/Draugh/DraughPatches.cs +++ b/JotunnModStub/Draugh/DraughPatches.cs @@ -23,8 +23,22 @@ namespace RacesOfValheim if (__instance.m_bodyModel != null && __instance.m_bodyModel.material != null) { - // Sickly grayish-green undead skin color (corpse green) - Color draughColor = new Color(0.25f, 0.4f, 0.28f, 1f); + Color draughColor = new Color(0.25f, 0.4f, 0.28f, 1f); // Sickly grayish-green undead skin color + + // Stage 6: Undying Will ghost visuals + if (DraughRace.isUndying && player == Player.m_localPlayer) + { + draughColor = new Color(0.2f, 1f, 0.2f, 0.5f); // Bright transparent green + __instance.m_bodyModel.material.SetOverrideTag("RenderType", "Transparent"); + __instance.m_bodyModel.material.SetInt("_SrcBlend", (int)UnityEngine.Rendering.BlendMode.SrcAlpha); + __instance.m_bodyModel.material.SetInt("_DstBlend", (int)UnityEngine.Rendering.BlendMode.OneMinusSrcAlpha); + __instance.m_bodyModel.material.SetInt("_ZWrite", 0); + __instance.m_bodyModel.material.DisableKeyword("_ALPHATEST_ON"); + __instance.m_bodyModel.material.EnableKeyword("_ALPHABLEND_ON"); + __instance.m_bodyModel.material.DisableKeyword("_ALPHAPREMULTIPLY_ON"); + __instance.m_bodyModel.material.renderQueue = (int)UnityEngine.Rendering.RenderQueue.Transparent; + } + __instance.m_bodyModel.material.SetColor("_SkinColor", draughColor); } @@ -114,6 +128,18 @@ namespace RacesOfValheim // +50% damage received from fire, spirit hit.m_damage.m_fire *= 1.5f; hit.m_damage.m_spirit *= 1.5f; + + // Stage 4: Undead Fortitude (Poison Immunity) + if (BossProgressionManager.GetCurrentProgressionState() >= 4) + { + hit.m_damage.m_poison = 0f; + } + + // Stage 5: Grave Chill (Frost Immunity) + if (BossProgressionManager.GetCurrentProgressionState() >= 5) + { + hit.m_damage.m_frost = 0f; + } } } } diff --git a/JotunnModStub/Draugh/DraughProgressionPatches.cs b/JotunnModStub/Draugh/DraughProgressionPatches.cs new file mode 100644 index 0000000..8aac6ce --- /dev/null +++ b/JotunnModStub/Draugh/DraughProgressionPatches.cs @@ -0,0 +1,355 @@ +using HarmonyLib; +using UnityEngine; +using System.Collections.Generic; + +namespace RacesOfValheim +{ + public static class DraughProgressionPatches + { + // ======================================== + // STAGE 2: SUNKEN MENACE (State >= 2) + // ======================================== + + [HarmonyPatch(typeof(SE_Wet), "Setup")] + public static class SE_Wet_Setup_Patch + { + public static void Postfix(SE_Wet __instance, Character character) + { + if (character == Player.m_localPlayer && DraughRace.IsDraugh()) + { + if (BossProgressionManager.GetCurrentProgressionState() >= 2) + { + // Invert the Wet debuff to actually heal the Draugh + __instance.m_healthRegenMultiplier = 1.25f; // +25% health regen + __instance.m_staminaRegenMultiplier = 1f; // No stamina penalty + __instance.m_tooltip = "The water restores your rotten flesh. Health regeneration increased."; + } + } + } + } + + // ======================================== + // STAGE 3: ROTTING EDGE (State >= 3) + // ======================================== + + [HarmonyPatch(typeof(Character), "Damage")] + public static class Draugh_DealDamage_Patch + { + public static void Prefix(Character __instance, HitData hit) + { + if (hit == null || __instance == null || hit.GetAttacker() == null) return; + + if (hit.GetAttacker() == Player.m_localPlayer && DraughRace.IsDraugh()) + { + if (BossProgressionManager.GetCurrentProgressionState() >= 3) + { + // If it's a physical attack (slash, pierce, blunt, or chop) + float physDamage = hit.m_damage.m_blunt + hit.m_damage.m_slash + hit.m_damage.m_pierce + hit.m_damage.m_chop; + if (physDamage > 0f && hit.m_skill != Skills.SkillType.BloodMagic && hit.m_skill != Skills.SkillType.ElementalMagic) + { + // Add poison damage based on the physical damage (e.g., 20% of physical damage as poison DoT) + hit.m_damage.m_poison += physDamage * 0.20f; + } + } + + if (BossProgressionManager.GetCurrentProgressionState() >= 4) + { + // Stage 4: Undead Fortitude (+30% crit damage on staggered enemies) + if (__instance.IsStaggering()) + { + hit.m_damage.m_blunt *= 1.30f; + hit.m_damage.m_slash *= 1.30f; + hit.m_damage.m_pierce *= 1.30f; + hit.m_damage.m_chop *= 1.30f; + } + } + } + } + } + + [HarmonyPatch(typeof(Humanoid), "BlockAttack")] + public static class Draugh_Parry_Patch + { + private static float lastNorthWindTime = -100f; // Track cooldown + + public static void Postfix(Humanoid __instance, HitData hit, Character attacker, ref bool __result) + { + if (!__result || __instance != Player.m_localPlayer || attacker == null) return; + + if (DraughRace.IsDraugh()) + { + int state = BossProgressionManager.GetCurrentProgressionState(); + + if (state >= 3) + { + // Check if it was a parry. + float blockTimer = Traverse.Create(__instance).Field("m_blockTimer").GetValue(); + float parryTime = 0.25f; // Default Valheim parry window + + if (blockTimer != -1f && blockTimer <= parryTime) + { + // Stage 3: Poison Splash + HitData poisonSplash = new HitData(); + poisonSplash.m_damage.m_poison = 40f; // Flat base poison splash + poisonSplash.m_point = attacker.GetCenterPoint(); + poisonSplash.SetAttacker(__instance); + poisonSplash.m_dir = (attacker.GetCenterPoint() - __instance.GetCenterPoint()).normalized; + + attacker.ApplyDamage(poisonSplash, true, false); + + // Visual effect for splash + UnityEngine.Object.Instantiate(ZNetScene.instance.GetPrefab("vfx_OozeHit"), attacker.GetCenterPoint(), Quaternion.identity); + + // Stage 5: North Wind (AoE Frost) + if (state >= 5) + { + if (Time.time - lastNorthWindTime >= 20f) + { + lastNorthWindTime = Time.time; + + // Visual effect for Nova (sledge frost effect) + GameObject iceHit = ZNetScene.instance.GetPrefab("vfx_sledge_iron_hit"); // Actually, vfx_ice_hit is better, or vfx_sledge_iron_hit which is used by Frostner + if (iceHit == null) iceHit = ZNetScene.instance.GetPrefab("vfx_ice_hit"); + if (iceHit != null) + { + UnityEngine.Object.Instantiate(iceHit, __instance.transform.position, Quaternion.identity); + } + + // Find all characters within 8 meters + List allCharacters = Character.GetAllCharacters(); + foreach (Character ch in allCharacters) + { + if (ch == null || ch == __instance || ch.IsPlayer() || ch.IsDead()) continue; + + if (Vector3.Distance(__instance.transform.position, ch.transform.position) <= 8f) + { + HitData northWind = new HitData(); + northWind.m_damage.m_frost = 50f; + northWind.m_point = ch.GetCenterPoint(); + northWind.SetAttacker(__instance); + northWind.m_dir = (ch.GetCenterPoint() - __instance.GetCenterPoint()).normalized; + northWind.m_pushForce = 20f; + + ch.ApplyDamage(northWind, true, false); + } + } + + Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "The northern wind blows"); + } + } + } + } + } + } + } + + // ======================================== + // STAGE 4: UNDEAD FORTITUDE & DEATH AURA (State >= 4) + // ======================================== + + [HarmonyPatch(typeof(Skills), "LowerAllSkills")] + public static class Draugh_NoSkillDrain_Patch + { + public static bool Prefix(Skills __instance) + { + // Check if this Skills instance belongs to the local player + Player player = Traverse.Create(__instance).Field("m_player").GetValue(); + if (player != null && player == Player.m_localPlayer) + { + if (DraughRace.IsDraugh() && BossProgressionManager.GetCurrentProgressionState() >= 4) + { + return false; // Prevent skill drain + } + } + return true; + } + } + + [HarmonyPatch(typeof(Player), "OnDeath")] + public static class Draugh_DeathAura_Patch + { + public static void Prefix(Player __instance) + { + if (BossProgressionManager.GetCurrentProgressionState() >= 4) + { + bool draughNearby = false; + foreach (Player p in Player.GetAllPlayers()) + { + if (p.m_customData != null && p.m_customData.TryGetValue("Race", out string race) && race == "Draugh") + { + if (Vector3.Distance(__instance.transform.position, p.transform.position) <= 100f) + { + draughNearby = true; + break; + } + } + } + + if (draughNearby) + { + GameObject meatPrefab = ObjectDB.instance.GetItemPrefab("HumanMeat"); + if (meatPrefab != null) + { + Vector3 dropPos = __instance.transform.position + Vector3.up * 1.0f; + GameObject dropped = UnityEngine.Object.Instantiate(meatPrefab, dropPos, Quaternion.identity); + + ItemDrop itemDrop = dropped.GetComponent(); + if (itemDrop != null) + { + itemDrop.m_itemData.m_stack = 1; + + Rigidbody rb = dropped.GetComponent(); + if (rb != null) + { + rb.linearVelocity = Vector3.up * 5f + UnityEngine.Random.insideUnitSphere * 2f; + } + } + } + } + } + } + } + + // ======================================== + // STAGE 6: UNDYING WILL (State >= 6) + // ======================================== + + [HarmonyPatch(typeof(Player), "OnDeath")] + public static class Player_OnDeath_Undying_Patch + { + public static bool Prefix(Player __instance) + { + if (__instance == Player.m_localPlayer && DraughRace.IsDraugh() && BossProgressionManager.GetCurrentProgressionState() >= 6) + { + if (DraughRace.isUndying) + { + // If they are already undying and they reach OnDeath again, it means their Eitr ran out. + // We must let them die for real this time. + return true; + } + + float currentEitr = __instance.GetEitr(); + if (currentEitr > 0f && Time.time - DraughRace.lastUndyingWillTime >= 600f) // 10 minutes + { + // Trigger Undying Will! + DraughRace.lastUndyingWillTime = Time.time; + DraughRace.isUndying = true; + + // Prevent the real death this frame, stay alive at 1 HP + __instance.SetHealth(1f); + + DraughRace.Instance.StartCoroutine(DraughRace.Instance.UndyingWillRoutine(__instance)); + + // Return false to skip the original OnDeath method + return false; + } + } + return true; + } + } + + [HarmonyPatch(typeof(Character), "ApplyDamage")] + public static class Character_ApplyDamage_Undying_Patch + { + public static bool Prefix(Character __instance, HitData hit) + { + if (__instance == Player.m_localPlayer && DraughRace.IsDraugh()) + { + if (DraughRace.isUndying) + { + // Become immune to all damage + return false; + } + } + return true; + } + } + + // ======================================== + // STAGE 7: SWARM OF TERROR (State >= 7) + // ======================================== + + [HarmonyPatch(typeof(Character), "Damage")] + public static class Character_Damage_SwarmOfTerror_Patch + { + public static void Prefix(Character __instance, HitData hit) + { + if (__instance == Player.m_localPlayer && DraughRace.IsDraugh() && BossProgressionManager.GetCurrentProgressionState() >= 7) + { + if (hit == null || hit.GetAttacker() == null || hit.m_damage.GetTotalDamage() <= 0f) return; + + // Melee check via distance + if (Vector3.Distance(hit.GetAttacker().transform.position, __instance.transform.position) <= 5f) + { + if (Time.time - DraughRace.lastSeekerSpawnTime >= 10f) + { + DraughRace.lastSeekerSpawnTime = Time.time; + + GameObject prefab = ObjectDB.instance.GetItemPrefab("SeekerBrood"); + if (prefab == null) + { + prefab = ZNetScene.instance.GetPrefab("SeekerBrood"); + } + + if (prefab != null) + { + Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Swarm of Terror!"); + + for (int i = 0; i < 2; i++) + { + Vector3 spawnPos = __instance.transform.position + __instance.transform.forward * 1f + UnityEngine.Random.insideUnitSphere * 1.5f; + spawnPos.y = __instance.transform.position.y; + + GameObject brood = UnityEngine.Object.Instantiate(prefab, spawnPos, Quaternion.identity); + Character c = brood.GetComponent(); + if (c != null) + { + c.m_faction = Character.Faction.Players; // Make it friendly + + // Remove drops + CharacterDrop drop = brood.GetComponent(); + if (drop != null) + { + UnityEngine.Object.Destroy(drop); + } + + // Kill after 9.5 seconds + DraughRace.Instance.StartCoroutine(DraughRace.Instance.KillBroodAfterTime(c, 9.5f)); + } + } + } + } + } + } + } + + public static void Postfix(Character __instance, HitData hit) + { + // STAGE 8: STEAL THEIR BREATH (State >= 8) + if (DraughRace.isUndying && __instance != Player.m_localPlayer && __instance.GetHealth() <= 0f) + { + if (BossProgressionManager.GetCurrentProgressionState() >= 8) + { + if (hit != null && hit.GetAttacker() == Player.m_localPlayer) + { + // Steal Their Breath triggered! + DraughRace.isUndying = false; // Break the routine loop + + float healAmount = Player.m_localPlayer.GetMaxHealth() * 0.25f; + Player.m_localPlayer.Heal(healAmount); + + Player.m_localPlayer.Message(MessageHud.MessageType.Center, "Steal Their Breath! Death is denied."); + + // Restore visuals immediately + if (Player.m_localPlayer.GetComponent() != null) + { + HarmonyLib.Traverse.Create(Player.m_localPlayer.GetComponent()).Method("UpdateVisuals").GetValue(); + HarmonyLib.Traverse.Create(Player.m_localPlayer.GetComponent()).Method("UpdateColors").GetValue(); + } + } + } + } + } + } + } +} diff --git a/JotunnModStub/Draugh/DraughRace.cs b/JotunnModStub/Draugh/DraughRace.cs index 6ce5fc1..3eef143 100644 --- a/JotunnModStub/Draugh/DraughRace.cs +++ b/JotunnModStub/Draugh/DraughRace.cs @@ -6,6 +6,11 @@ namespace RacesOfValheim { public static DraughRace Instance; + public static bool isUndying = false; + public static float lastUndyingWillTime = -1000f; + + public static float lastSeekerSpawnTime = -1000f; + private void Awake() { Instance = this; @@ -118,6 +123,7 @@ namespace RacesOfValheim { draughVFX = new GameObject("DraughAuraVFX"); draughVFX.transform.SetParent(Player.m_localPlayer.transform, false); + // Centro del giocatore invece che il pivot (piedi) draughVFX.transform.localPosition = new Vector3(0, 1f, 0); // Find all ParticleSystems in Draugr prefab @@ -131,14 +137,28 @@ namespace RacesOfValheim psCopy.name = ps.gameObject.name; psCopy.SetActive(true); - // Ensure it's positioned correctly - psCopy.transform.localPosition = ps.transform.localPosition; + // Entrambi (fumo e mosche) partono esattamente dal centro + psCopy.transform.localPosition = Vector3.zero; psCopy.transform.localRotation = ps.transform.localRotation; - - // Make the green smoke 50% larger. We exclude "flies" in case they are separate. - if (!psCopy.name.ToLower().Contains("flies")) + + string psName = psCopy.name.ToLower(); + + if (psName.Contains("flies")) { - psCopy.transform.localScale = ps.transform.localScale * 1.5f; + // Flies effect: leave as is + } + else if (psName.Contains("drip") || psName.Contains("drop") || psName.Contains("rain") || psName.Contains("splash")) + { + // Effetto 3 (pioggia): disattivato + psCopy.SetActive(false); + } + else + { + // Smoke effect: scale reduced to 1.5f (-40% of 2.5f) + psCopy.transform.localScale = new Vector3(1.5f, 1.5f, 1.5f); + + var main = psCopy.GetComponent().main; + main.scalingMode = ParticleSystemScalingMode.Hierarchy; } } } @@ -158,5 +178,58 @@ namespace RacesOfValheim } } } + + public System.Collections.IEnumerator UndyingWillRoutine(Player p) + { + p.Message(MessageHud.MessageType.Center, "Zombie Ritual Activated! Your borrowed time is fading..."); + + // Trigger a re-evaluation of visuals to apply the ghost effect + if (p.GetComponent() != null) + { + HarmonyLib.Traverse.Create(p.GetComponent()).Method("UpdateVisuals").GetValue(); + HarmonyLib.Traverse.Create(p.GetComponent()).Method("UpdateColors").GetValue(); + } + + while (isUndying) + { + float currentEitr = p.GetEitr(); + if (currentEitr <= 0f) + { + isUndying = false; + + // Force death properly through the damage system + HitData killHit = new HitData(); + killHit.m_damage.m_damage = 99999f; + killHit.m_point = p.transform.position; + p.Damage(killHit); + break; + } + + // Drain 2 Eitr per tick (5 ticks per second = 10 eitr/sec) + p.UseEitr(2f); + + yield return new WaitForSeconds(0.2f); + } + + // Restore visuals + if (p != null && p.GetComponent() != null) + { + HarmonyLib.Traverse.Create(p.GetComponent()).Method("UpdateVisuals").GetValue(); + HarmonyLib.Traverse.Create(p.GetComponent()).Method("UpdateColors").GetValue(); + } + } + + public System.Collections.IEnumerator KillBroodAfterTime(Character brood, float time) + { + yield return new WaitForSeconds(time); + if (brood != null && !brood.IsDead()) + { + // Force death naturally + HitData killHit = new HitData(); + killHit.m_damage.m_damage = 9999f; + killHit.m_point = brood.transform.position; + brood.Damage(killHit); + } + } } } diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs index 180472b..56ad1d9 100644 --- a/JotunnModStub/RaceCompendium.cs +++ b/JotunnModStub/RaceCompendium.cs @@ -14,7 +14,8 @@ namespace RacesOfValheim "Skadi Secrets", "Skeleton Secrets", "Furling Secrets", - "Trol Secrets" + "Trol Secrets", + "Draugh Secrets" }; public static void UpdateCompendiumText(Player player) @@ -62,6 +63,41 @@ namespace RacesOfValheim { GenerateTrolText(knownTexts, state, player); } + else if (currentRace == "Draugh") + { + GenerateDraughText(knownTexts, state, player); + } + } + + private static void GenerateDraughText(Dictionary knownTexts, int state, Player player) + { + StringBuilder sb = new StringBuilder(); + sb.AppendLine("The Draugh's Awakening\n"); + + sb.AppendLine("[Base Passive] Born Dead, Buried Alive: You are a decaying undead warrior. You have innate resistance to Poison, but are weak to Fire and Spirit damage. Your digestive system adapts to death, allowing you to consume raw and rotten meat (Neck tail, raw meat, entrails, ooze, etc.).\n"); + + if (state >= 2) + sb.AppendLine("Slowly We Rot (Passive): You are no longer hindered by water. You gain immunity to the Wet effect, your movement speed in water is greatly increased, and you passively regenerate health while wet or swimming.\n"); + + if (state >= 3) + sb.AppendLine("Toxic Trace (Passive): Your physical attacks are laced with the swamp's decay. Enemies struck by your physical weapons suffer additional poison damage over time.\n"); + + if (state >= 4) + sb.AppendLine("Flesh and the Power It Holds (Passive): Slaying humanoid enemies drops Human Meat. Consuming it grants incredible buffs. You also gain the Corpse Run buff permanently.\n"); + + if (state >= 5) + sb.AppendLine("At the Heart of Winter (Parry Effect): When you successfully parry an attack, you unleash a freezing nova of frost magic around you, pushing back and damaging enemies (20 second cooldown).\n"); + + if (state >= 6) + sb.AppendLine("Zombie Ritual (Passive Survival): When you take fatal damage, you do not die. Instead, you enter a ghostly state, becoming immune to all damage. While in this state, your Eitr drains rapidly. If your Eitr hits zero, you truly die.\n"); + + if (state >= 7) + sb.AppendLine("Swarm of Terror (Retaliation): Whenever you are struck in melee combat, you automatically spawn 2 Seeker Broods to fight for you. They live for 9.5 seconds and have a 10 second cooldown.\n"); + + if (state >= 8) + sb.AppendLine("Steal Their Breath (Execution): While surviving in the 'Zombie Ritual' ghost state, scoring a killing blow on any enemy will instantly restore 25% of your maximum health, stop the Eitr drain, and save your life, bringing you fully back to the world of the living.\n"); + + knownTexts["Draugh Secrets"] = sb.ToString(); } private static void GenerateTrolText(Dictionary knownTexts, int state, Player player) diff --git a/JotunnModStub/RaceHostilityManager.cs b/JotunnModStub/RaceHostilityManager.cs index 8fc028a..579bef8 100644 --- a/JotunnModStub/RaceHostilityManager.cs +++ b/JotunnModStub/RaceHostilityManager.cs @@ -49,6 +49,17 @@ namespace RacesOfValheim if (state >= 7 && (prefabName.Contains("hare") || prefabName.Contains("gjall"))) __result = false; if (state >= 8 && (prefabName.Contains("asksvin") || prefabName.Contains("volture") || prefabName.Contains("vulture") || prefabName.Contains("valkyrie"))) __result = false; } + + // Draugh Race Logic + if (p.m_customData.ContainsKey("Race") && p.m_customData["Race"] == "Draugh") + { + string prefabName = monster.gameObject.name.ToLower(); + if (prefabName.Contains("skeleton") || prefabName.Contains("draugr") || + prefabName.Contains("ghost") || prefabName.Contains("wraith")) + { + __result = false; + } + } } } } diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index f0e1453..a6cc6c6 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -186,7 +186,7 @@ namespace RacesOfValheim CreateRaceButtonWithConfirm("Aswid", new Vector2(-450, -20), GetAswidIcon(), "Fierce night stalker. Strong and resilient, transforms into a bat.", SelectAswid); CreateRaceButtonWithConfirm("Furling", new Vector2(-150, -20), GetFurlingIcon(), "Cunning goblin-like creatures. Agile and resourceful.", SelectFurling); CreateRaceButtonWithConfirm("Trol", new Vector2(150, -20), GetTrolIcon(), "Massive brute strength. Towering over others but slow to react.", SelectTrol); - CreateRaceButtonWithConfirm("Draugh", new Vector2(450, -20), GetDraughIcon(), "Undead warriors of the swamps. Accustomed to damp and decay.", SelectDraugh); + CreateRaceButtonWithConfirm("Draugh", new Vector2(450, -20), GetDraughIcon(), "A decaying undead warrior fueled by dark magic and extreme metal.", SelectDraugh); GUIManager.BlockInput(true); } From 5350ebda5d9d9049ab6106165ec311142c4ee9ba Mon Sep 17 00:00:00 2001 From: kanym Date: Sun, 2 Aug 2026 08:45:47 +0200 Subject: [PATCH 036/429] Add the Race Menu Ward; WIP on remote Trol/Skadi visuals Race Menu Ward: a buildable ward (2 wood, hammer/Misc, no crafting station) that manages your race outside the debug console - reset the race, switch between the server's boss progression and your own, and advance that personal progression by offering a boss's secondary drop to it. One is placed near the sacrificial stones on first load of a world, by the host only. BossProgressionManager grows a personal mode alongside the world one. The tier is stored on the character rather than the world, so a personal tier travels with the player between servers instead of being tied to whichever world unlocked it. resetrace and the ward now share RacesOfValheim.ResetRace so both paths clean up identical state. Also in progress, and NOT yet working: remote Trol sizing and remote Skadi flight. Both are computed from the observer instead of the observed - - Remote Trols are scaled from the observing player's own progression, and never show True Form, because SE_TrolTrueForm only exists on the transformed player's client. Each Trol now publishes its state and True Form flag onto its own ZDO for others to read. - Remote Skadi dragons sink to the terrain regardless of the altitude being replicated: Character.m_flying is only ever set on the flying player's client, so observers run grounded motion under gravity. Flight is mirrored through the ZDO and the remote copy's rigidbody gravity is disabled while it lasts. Neither has fixed the symptom yet, so both paths keep a throttled diagnostic log reporting what each observer actually computes. Committed to get the instrumentation onto the branch, not because it works. Packaging no longer hardcodes another machine's desktop path: Thunderstore and Nexus zips go to dist/ on Release builds only, and the DLL is copied into Valheim only when VALHEIM_INSTALL actually points at a plugins folder. --- JotunnModStub/BossProgressionManager.cs | 96 +++++- JotunnModStub/RaceMenuWard.cs | 379 +++++++++++++++++++++++ JotunnModStub/RacesOfValheim.cs | 80 +++-- JotunnModStub/RacesOfValheim.csproj | 12 +- JotunnModStub/Skadi/DrakeFormBehavior.cs | 23 +- JotunnModStub/Trol/TrolPatches.cs | 97 ++++-- JotunnModStub/ZdoVisualSync.cs | 27 +- 7 files changed, 637 insertions(+), 77 deletions(-) create mode 100644 JotunnModStub/RaceMenuWard.cs diff --git a/JotunnModStub/BossProgressionManager.cs b/JotunnModStub/BossProgressionManager.cs index 39ce04b..d688a88 100644 --- a/JotunnModStub/BossProgressionManager.cs +++ b/JotunnModStub/BossProgressionManager.cs @@ -16,6 +16,85 @@ namespace RacesOfValheim public const string TheQueen = "defeated_queen"; public const string Fader = "defeated_fader"; + public const int MinState = 1; + public const int MaxState = 8; + + // Stored on the character rather than the world, so a personal tier travels with the + // player between servers instead of being tied to whichever world unlocked it. + private const string PersonalStateKey = "RacesOfValheim_PersonalState"; + private const string PersonalModeKey = "RacesOfValheim_PersonalMode"; + + /// + /// Boss secondary drops, and the progression state each one unlocks when offered to the + /// Race Menu Ward. Keyed by prefab name, which is what the item stack carries. + /// + public static readonly Dictionary BossDropStates = new Dictionary + { + { "HardAntler", 2 }, // Eikthyr + { "CryptKey", 3 }, // The Elder + { "Wishbone", 4 }, // Bonemass + { "DragonTear", 5 }, // Moder + { "YagluthDrop", 6 }, // Yagluth + { "QueenDrop", 7 }, // The Queen - Majestic carapace + { "FaderDrop", 8 } // Fader - Fader relic + }; + + public static string GetBossNameForState(int state) + { + switch (state) + { + case 2: return "Eikthyr"; + case 3: return "The Elder"; + case 4: return "Bonemass"; + case 5: return "Moder"; + case 6: return "Yagluth"; + case 7: return "The Queen"; + case 8: return "Fader"; + default: return "No bosses"; + } + } + + /// + /// True when the player has chosen to advance on their own unlocks rather than on whatever + /// the server has already killed. + /// + public static bool UsePersonalProgression + { + get + { + Player player = Player.m_localPlayer; + if (player == null || player.m_customData == null) return false; + return player.m_customData.TryGetValue(PersonalModeKey, out string value) && value == "true"; + } + set + { + Player player = Player.m_localPlayer; + if (player == null || player.m_customData == null) return; + player.m_customData[PersonalModeKey] = value ? "true" : "false"; + } + } + + public static int PersonalState + { + get + { + Player player = Player.m_localPlayer; + if (player == null || player.m_customData == null) return MinState; + if (player.m_customData.TryGetValue(PersonalStateKey, out string value) && + int.TryParse(value, out int state)) + { + return UnityEngine.Mathf.Clamp(state, MinState, MaxState); + } + return MinState; + } + set + { + Player player = Player.m_localPlayer; + if (player == null || player.m_customData == null) return; + player.m_customData[PersonalStateKey] = UnityEngine.Mathf.Clamp(value, MinState, MaxState).ToString(); + } + } + /// /// Returns the current progression state of the world based on defeated bosses. /// 1 = No bosses defeated @@ -27,13 +106,11 @@ namespace RacesOfValheim /// 7 = The Queen defeated /// 8 = Fader defeated /// - public static int GetCurrentProgressionState() + public static int GetWorldProgressionState() { - if (DebugState != -1) return DebugState; // [DEBUG] - if (ZoneSystem.instance == null) { - return 1; // Default to 1 if ZoneSystem isn't ready + return MinState; // Default to 1 if ZoneSystem isn't ready } // We check in reverse order (highest tier first) @@ -45,7 +122,16 @@ namespace RacesOfValheim if (ZoneSystem.instance.GetGlobalKey(TheElder)) return 3; if (ZoneSystem.instance.GetGlobalKey(Eikthyr)) return 2; - return 1; // No bosses defeated + return MinState; // No bosses defeated + } + + public static int GetCurrentProgressionState() + { + if (DebugState != -1) return DebugState; // [DEBUG] + + if (UsePersonalProgression) return PersonalState; + + return GetWorldProgressionState(); } } } diff --git a/JotunnModStub/RaceMenuWard.cs b/JotunnModStub/RaceMenuWard.cs new file mode 100644 index 0000000..59c6201 --- /dev/null +++ b/JotunnModStub/RaceMenuWard.cs @@ -0,0 +1,379 @@ +using Jotunn.Configs; +using Jotunn.Entities; +using Jotunn.Managers; +using UnityEngine; +using UnityEngine.UI; + +namespace RacesOfValheim +{ + /// + /// A buildable ward that lets a player manage their race outside of the debug console: reset + /// the race, switch between the server's boss progression and their own, and advance that + /// personal progression by offering a boss's secondary drop to it. + /// + public static class RaceMenuWard + { + public const string PrefabName = "RaceMenuWard"; + + public static void Register() + { + // The Ward ("guard_stone") is only borrowed for its model and build sounds; its own + // area-protection behaviour is stripped below so it never claims territory. + GameObject prefab = PrefabManager.Instance.CreateClonedPrefab(PrefabName, "guard_stone"); + if (prefab == null) + { + Jotunn.Logger.LogWarning("Could not clone guard_stone; Race Menu Ward not registered."); + return; + } + + PrivateArea privateArea = prefab.GetComponent(); + if (privateArea != null) Object.DestroyImmediate(privateArea); + + // The Ward is a workbench recipe, and Player.HaveRequirements hides any piece whose + // crafting station is not both known and in range - which is why a fresh character + // never saw this in the hammer. Clearing the station makes it buildable anywhere. + Piece piece = prefab.GetComponent(); + if (piece != null) + { + piece.m_craftingStation = null; + // The clone arrives carrying the Ward's own recipe (fine wood, surtling cores and + // so on). Jotunn only overwrites m_resources when the config lists requirements, + // so wipe the inherited ones here and let the config below set the real cost. + piece.m_resources = new Piece.Requirement[0]; + } + + prefab.AddComponent(); + + PieceConfig config = new PieceConfig + { + Name = "Race Menu Ward", + Description = "Commune with your heritage. Offer a fallen boss's relic to claim its power.", + PieceTable = PieceTables.Hammer, + Category = PieceCategories.Misc, + // Deliberately trivial: this is a utility the player needs early, not a reward. + Requirements = new[] + { + new RequirementConfig("Wood", 2, 0, true) + } + }; + + PieceManager.Instance.AddPiece(new CustomPiece(prefab, fixReference: false, config)); + } + + // Marks a world as already having its starter ward, so it is placed exactly once rather + // than every time someone loads in. + private const string PlacedKey = "RacesOfValheim_StarterWardPlaced"; + // Clear of the stone circle itself, which is why the first attempt ended up inside a stone. + private const float SpawnRadius = 14f; + private const float ClearanceRadius = 2.5f; + + /// + /// Drops a ward beside the sacrificial stones so a fresh world has one without anyone + /// needing to build it. Only the host runs this, and only once per world. + /// + public static void TryPlaceAtSpawn() + { + if (ZoneSystem.instance == null || ZNetScene.instance == null) return; + if (ZNet.instance == null || !ZNet.instance.IsServer()) return; + if (ZoneSystem.instance.GetGlobalKey(PlacedKey)) return; + + if (!ZoneSystem.instance.GetLocationIcon("StartTemple", out Vector3 templePos)) return; + + GameObject prefab = ZNetScene.instance.GetPrefab(PrefabName); + if (prefab == null) return; + + if (!TryFindClearSpot(templePos, out Vector3 pos)) return; + + Object.Instantiate(prefab, pos, Quaternion.identity); + ZoneSystem.instance.SetGlobalKey(PlacedKey); + Jotunn.Logger.LogInfo($"Placed the starter Race Menu Ward near spawn at {pos}."); + } + + /// + /// A build piece only appears in the hammer once its name is in the player's known recipes + /// (PieceTable.UpdateAvailable filters on exactly that), and the vanilla learning pass can + /// miss a piece injected after the fact. Teach it directly and rebuild the list. Both + /// methods are non-public, hence the reflection. + /// + public static void EnsureKnown(Player player) + { + if (player == null) return; + + GameObject prefab = PrefabManager.Instance.GetPrefab(PrefabName); + if (prefab == null) + { + Jotunn.Logger.LogWarning($"{PrefabName} prefab missing; cannot teach the piece."); + return; + } + + Piece piece = prefab.GetComponent(); + if (piece == null) + { + Jotunn.Logger.LogWarning($"{PrefabName} has no Piece component."); + return; + } + + var traverse = HarmonyLib.Traverse.Create(player); + traverse.Method("AddKnownPiece", piece).GetValue(); + traverse.Method("UpdateAvailablePiecesList").GetValue(); + } + + /// + /// Walks a ring around the sacrificial stones looking for open, level terrain. Uses the + /// ground height rather than the solid height, since the latter happily reports the top of + /// a standing stone and leaves the ward embedded in it. + /// + private static bool TryFindClearSpot(Vector3 centre, out Vector3 result) + { + int obstacleMask = LayerMask.GetMask("Default", "static_solid", "Default_small", "piece", "vehicle"); + + for (int i = 0; i < 12; i++) + { + float angle = i * (360f / 12f) * Mathf.Deg2Rad; + Vector3 candidate = centre + new Vector3(Mathf.Cos(angle), 0f, Mathf.Sin(angle)) * SpawnRadius; + candidate.y = ZoneSystem.instance.GetGroundHeight(candidate); + + // Skip anything underwater, and anything with a rock, tree or build piece on it. + if (candidate.y < ZoneSystem.instance.m_waterLevel) continue; + if (Physics.CheckSphere(candidate + Vector3.up * 1.5f, ClearanceRadius, obstacleMask)) continue; + + result = candidate; + return true; + } + + // Nothing ideal: fall back to due south on the terrain rather than skipping entirely. + result = centre + new Vector3(0f, 0f, -SpawnRadius); + result.y = ZoneSystem.instance.GetGroundHeight(result); + return true; + } + } + + // The spawn point only resolves once the world is up and the local player exists, so the + // placement attempt rides along with the player spawning rather than world load. + [HarmonyLib.HarmonyPatch(typeof(Player), "OnSpawned")] + public static class RaceMenuWardSpawnPatch + { + public static void Postfix(Player __instance) + { + if (__instance != Player.m_localPlayer) return; + RaceMenuWard.TryPlaceAtSpawn(); + RaceMenuWard.EnsureKnown(__instance); + } + } + + public class RaceMenuWardBehavior : MonoBehaviour, Hoverable, Interactable + { + public string GetHoverName() => "Race Menu Ward"; + + public string GetHoverText() + { + string mode = BossProgressionManager.UsePersonalProgression ? "Personal" : "World"; + int state = BossProgressionManager.GetCurrentProgressionState(); + string boss = BossProgressionManager.GetBossNameForState(state); + + return $"Race Menu Ward\n{mode} progression - {boss} ({state}/{BossProgressionManager.MaxState})\n" + + "[E] Open\n" + + "[Use item] Offer a boss relic"; + } + + public bool Interact(Humanoid user, bool hold, bool alt) + { + if (hold) return false; + if (user != Player.m_localPlayer) return false; + + RaceMenuWardUI.Show(); + return true; + } + + /// + /// Offering a boss's secondary drop unlocks that boss's tier of personal progression. + /// Any tier may be claimed directly - holding a Dragon tear takes you straight to Moder's + /// tier whether or not the earlier ones were ever claimed. + /// + public bool UseItem(Humanoid user, ItemDrop.ItemData item) + { + if (user != Player.m_localPlayer || item == null) return false; + + 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."); + return true; + } + + if (!BossProgressionManager.UsePersonalProgression) + { + user.Message(MessageHud.MessageType.Center, "Switch to personal progression first."); + return true; + } + + if (BossProgressionManager.PersonalState >= state) + { + user.Message(MessageHud.MessageType.Center, + $"You already carry {BossProgressionManager.GetBossNameForState(state)}'s power."); + return true; + } + + Player player = Player.m_localPlayer; + player.GetInventory().RemoveOneItem(item); + BossProgressionManager.PersonalState = state; + + user.Message(MessageHud.MessageType.Center, + $"{BossProgressionManager.GetBossNameForState(state)}'s power is yours."); + + RefreshRaceState(); + return true; + } + + // Progression drives stats and unlocks that are only recalculated when equipment is set + // up, so nudge that after any change or the new tier will not show until something else + // happens to trigger it. + public static void RefreshRaceState() + { + if (Player.m_localPlayer == null) return; + HarmonyLib.Traverse.Create(Player.m_localPlayer).Method("SetupEquipment").GetValue(); + } + } + + public static class RaceMenuWardUI + { + private static GameObject panel; + + public static bool IsOpen => panel != null; + + public static void Show() + { + if (panel != null) return; + if (GUIManager.Instance == null || GUIManager.CustomGUIFront == null) + { + Jotunn.Logger.LogWarning("GUIManager not ready; cannot open the Race Menu Ward."); + return; + } + + panel = new GameObject("RaceMenuWardPanel"); + panel.transform.SetParent(GUIManager.CustomGUIFront.transform, false); + + RectTransform rect = panel.AddComponent(); + rect.anchorMin = Vector2.zero; + rect.anchorMax = Vector2.one; + rect.offsetMin = Vector2.zero; + rect.offsetMax = Vector2.zero; + + 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("Status", BuildStatusText(), 24, new Vector2(0, 110), new Vector2(900, 160)); + + AddButton("WorldBtn", "Use World Progression", new Vector2(-170, -20), new Color(0.2f, 0.35f, 0.5f, 1f), () => + { + BossProgressionManager.UsePersonalProgression = false; + RaceMenuWardBehavior.RefreshRaceState(); + Refresh(); + }); + + AddButton("PersonalBtn", "Use Personal Progression", new Vector2(170, -20), new Color(0.35f, 0.3f, 0.5f, 1f), () => + { + BossProgressionManager.UsePersonalProgression = true; + RaceMenuWardBehavior.RefreshRaceState(); + Refresh(); + }); + + AddButton("ResetBtn", "Reset Race", new Vector2(0, -110), new Color(0.5f, 0.25f, 0.2f, 1f), () => + { + Close(); + RacesOfValheim.ResetRace(); + }); + + AddButton("CloseBtn", "Close", new Vector2(0, -200), new Color(0.3f, 0.3f, 0.3f, 1f), Close); + + GUIManager.BlockInput(true); + } + + public static void Close() + { + if (panel == null) return; + Object.Destroy(panel); + panel = null; + GUIManager.BlockInput(false); + } + + private static void Refresh() + { + if (panel == null) return; + Transform status = panel.transform.Find("Status"); + if (status != null) + { + Text text = status.GetComponent(); + if (text != null) text.text = BuildStatusText(); + } + } + + private static string BuildStatusText() + { + int world = BossProgressionManager.GetWorldProgressionState(); + int personal = BossProgressionManager.PersonalState; + bool usingPersonal = BossProgressionManager.UsePersonalProgression; + + string worldLine = $"World: {BossProgressionManager.GetBossNameForState(world)} ({world}/{BossProgressionManager.MaxState})"; + string personalLine = $"Personal: {BossProgressionManager.GetBossNameForState(personal)} ({personal}/{BossProgressionManager.MaxState})"; + + if (usingPersonal) personalLine = "> " + personalLine + " <"; + else worldLine = "> " + worldLine + " <"; + + return worldLine + "\n" + personalLine + + "\n\nOffer a boss's relic to the ward to claim its tier for your personal progression."; + } + + private static void AddLabel(string name, string content, int fontSize, Vector2 position, Vector2 size) + { + GameObject obj = new GameObject(name); + obj.transform.SetParent(panel.transform, false); + + Text text = obj.AddComponent(); + text.font = GUIManager.Instance.AveriaSerifBold; + text.text = content; + text.fontSize = fontSize; + text.alignment = TextAnchor.MiddleCenter; + text.color = Color.white; + + RectTransform textRect = obj.GetComponent(); + textRect.anchoredPosition = position; + textRect.sizeDelta = size; + } + + private static void AddButton(string name, string label, Vector2 position, Color colour, UnityEngine.Events.UnityAction onClick) + { + GameObject obj = new GameObject(name); + obj.transform.SetParent(panel.transform, false); + + RectTransform btnRect = obj.AddComponent(); + btnRect.sizeDelta = new Vector2(300, 60); + btnRect.anchoredPosition = position; + + Image image = obj.AddComponent(); + image.color = colour; + + Button button = obj.AddComponent