diff --git a/JotunnModStub/Aswid/AswidBatAggro.cs b/JotunnModStub/Aswid/AswidBatAggro.cs
new file mode 100644
index 0000000..3bb4e6f
--- /dev/null
+++ b/JotunnModStub/Aswid/AswidBatAggro.cs
@@ -0,0 +1,182 @@
+using HarmonyLib;
+using UnityEngine;
+
+namespace RacesOfValheim
+{
+ ///
+ /// Why nothing in Valheim ever attacked the bat, and the smallest honest fix for it.
+ ///
+ /// The bat flies on Player.m_debugFly - the developer no-clip flag - because that is the only
+ /// flight vanilla actually has, and it is what BatFormBehavior sets and WarVultureMount reuses.
+ /// What nobody noticed is that vanilla reads that same flag as "this player is not really
+ /// here". Six places, all read out of assembly_valheim with Cecil rather than guessed:
+ ///
+ /// BaseAI.CanHearTarget - first line: the target is a Player in debug fly -> return false.
+ /// BaseAI.CanSeeTarget - the same first line, the same false.
+ /// BaseAI.FindEnemy - its HuntPlayer fallback throws the player away for the same reason.
+ /// MonsterAI.UpdateSleep - a sleeping monster refuses to wake for one, twice over.
+ /// Character.ApplyDamage - first line: IsDebugFlying -> return, the hit does nothing.
+ /// Character.RPC_Damage - the same.
+ ///
+ /// So the bat was never merely ignored: it was invulnerable as well, and both facts came out of
+ /// the one flag. There was nothing wrong with the Aswid's own code, which is why nothing in it
+ /// looked wrong.
+ ///
+ /// The fix keeps the flag - it IS the flight - and lies about it in exactly the places that
+ /// decide aggro and damage, and nowhere else:
+ ///
+ /// Player.InDebugFlyMode() is forced false for a bat unconditionally. That is safe, and it is
+ /// the reason this file is short: a scan of the whole assembly says that method has
+ /// exactly three callers, and all three are the sensing paths listed above. No part of
+ /// flight, camera, stamina or motion goes through it.
+ /// Player.IsDebugFlying() is NOT forced false, because Character.UpdateMotion reads it and
+ /// that read is what holds the bat in the air. It is only forced false while the call
+ /// stack is inside one of the three vanilla methods that must not honour it, which is
+ /// what the depth counter below is for.
+ ///
+ /// Both halves sit behind their own config toggle, so a bat can be made visible-but-immortal,
+ /// or put back the way it was, without touching code.
+ ///
+ public static class AswidBatForm
+ {
+ ///
+ /// The ZDO flag AswidRace writes when the form goes up. Replicated, so it answers for
+ /// remote players too - which matters here, because the machine asking "is this player a
+ /// bat" is whichever one owns the monster, not the bat's own.
+ ///
+ public const string BatZdoKey = "Aswid_IsBatForm";
+
+ private static readonly int BatFormHash = "SE_BatForm".GetStableHashCode();
+
+ // How deep we currently are inside vanilla calls that must not see the debug-fly flag. A
+ // counter and not a bool: ApplyDamage runs inside RPC_Damage, so the frames nest.
+ private static int unmaskDepth;
+
+ public static bool Unmasked => unmaskDepth > 0;
+ public static void PushUnmask() { unmaskDepth++; }
+ public static void PopUnmask() { if (unmaskDepth > 0) unmaskDepth--; }
+
+ ///
+ /// The ZDO first and the status effect only as a fallback: the ZDO is the one that is true
+ /// on every client, and the status effect covers the local player during the frames of the
+ /// transform where the ZDO write has not landed yet.
+ ///
+ public static bool IsBat(Player player)
+ {
+ if (player == null) return false;
+
+ ZNetView nview = player.GetComponent();
+ if (nview != null && nview.IsValid() && nview.GetZDO().GetBool(BatZdoKey, false)) return true;
+
+ return player == Player.m_localPlayer &&
+ player.GetSEMan() != null &&
+ player.GetSEMan().HaveStatusEffect(BatFormHash);
+ }
+ }
+
+ ///
+ /// The whole of the aggro fix. See AswidBatForm for why patching this one method flat is safe,
+ /// and why patching IsDebugFlying flat would drop the bat out of the sky instead.
+ ///
+ [HarmonyPatch(typeof(Player), "InDebugFlyMode")]
+ public static class Aswid_BatIsVisibleToAI_Patch
+ {
+ public static void Postfix(Player __instance, ref bool __result)
+ {
+ if (!__result) return;
+ if (AswidConfig.BatFormAggro != null && !AswidConfig.BatFormAggro.Value) return;
+ if (AswidBatForm.IsBat(__instance)) __result = false;
+ }
+ }
+
+ ///
+ /// The scoped half. Only ever fires inside the three vanilla methods that push the counter, and
+ /// only for a player who is a bat - so the flag still reads true everywhere flight, motion, the
+ /// camera and Player.UpdateStats look at it.
+ ///
+ [HarmonyPatch(typeof(Player), "IsDebugFlying")]
+ public static class Aswid_BatIsDebugFlying_Patch
+ {
+ public static void Postfix(Player __instance, ref bool __result)
+ {
+ if (!__result || !AswidBatForm.Unmasked) return;
+ if (AswidBatForm.IsBat(__instance)) __result = false;
+ }
+ }
+
+ ///
+ /// A hit landing on a bat. Finalizer rather than Postfix throughout this file: the counter has
+ /// to come back down even when the patched method throws, and a Postfix does not run then. A
+ /// void Finalizer leaves the original exception alone, so nothing is swallowed either.
+ ///
+ [HarmonyPatch(typeof(Character), "ApplyDamage")]
+ public static class Aswid_BatTakesDamage_Patch
+ {
+ public static void Prefix(Character __instance, ref bool __state)
+ {
+ __state = (AswidConfig.BatFormVulnerable == null || AswidConfig.BatFormVulnerable.Value)
+ && __instance is Player player && AswidBatForm.IsBat(player);
+ if (__state) AswidBatForm.PushUnmask();
+ }
+
+ public static void Finalizer(bool __state)
+ {
+ if (__state) AswidBatForm.PopUnmask();
+ }
+ }
+
+ /// The networked half of the same thing: a hit sent by another machine.
+ [HarmonyPatch(typeof(Character), "RPC_Damage")]
+ public static class Aswid_BatTakesRemoteDamage_Patch
+ {
+ public static void Prefix(Character __instance, ref bool __state)
+ {
+ __state = (AswidConfig.BatFormVulnerable == null || AswidConfig.BatFormVulnerable.Value)
+ && __instance is Player player && AswidBatForm.IsBat(player);
+ if (__state) AswidBatForm.PushUnmask();
+ }
+
+ public static void Finalizer(bool __state)
+ {
+ if (__state) AswidBatForm.PopUnmask();
+ }
+ }
+
+ ///
+ /// Sleepers. Unlike the two above this cannot pre-check who the player is - UpdateSleep picks
+ /// the closest one itself, and that may be a remote bat - so the counter goes up for the whole
+ /// call and the per-player test happens in the IsDebugFlying postfix, where it costs nothing:
+ /// that postfix only runs at all for a character who is already flying.
+ ///
+ [HarmonyPatch(typeof(MonsterAI), "UpdateSleep")]
+ public static class Aswid_BatWakesSleepers_Patch
+ {
+ public static void Prefix(ref bool __state)
+ {
+ __state = AswidConfig.BatFormAggro == null || AswidConfig.BatFormAggro.Value;
+ if (__state) AswidBatForm.PushUnmask();
+ }
+
+ public static void Finalizer(bool __state)
+ {
+ if (__state) AswidBatForm.PopUnmask();
+ }
+ }
+
+ ///
+ /// Dying as a bat only became possible with the patches above, and the revert path could not
+ /// handle it: AswidRace.Update() returns early on IsDead(), so the coroutine that takes the
+ /// form down never starts. The debug-fly flag would stay on and the ZDO would stay true, which
+ /// is a respawned player floating over the ground with a bat drawn on them.
+ ///
+ [HarmonyPatch(typeof(Player), "OnDeath")]
+ public static class Aswid_BatDiesAsBat_Patch
+ {
+ public static void Prefix(Player __instance)
+ {
+ if (__instance != Player.m_localPlayer) return;
+ if (AswidRace.Instance == null) return;
+ AswidRace.Instance.HardResetBatForm();
+ }
+ }
+}
diff --git a/JotunnModStub/Aswid/AswidBatFlight.cs b/JotunnModStub/Aswid/AswidBatFlight.cs
new file mode 100644
index 0000000..e101fb7
--- /dev/null
+++ b/JotunnModStub/Aswid/AswidBatFlight.cs
@@ -0,0 +1,57 @@
+using HarmonyLib;
+using UnityEngine;
+
+namespace RacesOfValheim
+{
+ ///
+ /// How fast the bat flies, as a factor on vanilla's own debug-fly speed.
+ ///
+ /// The form flies on Player.m_debugFly (see AswidBatForm for why), so its speed is whatever
+ /// Character.UpdateDebugFly decides. Read out of assembly_valheim rather than assumed, that
+ /// method ends with:
+ ///
+ /// m_currentVel = Vector3.Lerp(m_currentVel, b, 0.5f);
+ /// m_body.linearVelocity = m_currentVel;
+ ///
+ /// where b is m_moveDir times m_debugFlySpeed - a public STATIC INT, 20 by default, times 2.5
+ /// while the run key is held.
+ ///
+ /// Two ways to make that faster were rejected before this one:
+ ///
+ /// Retuning m_debugFlySpeed around the call. It is shared by every character in the game and
+ /// it is an int, so a 1.35x multiplier would land on 27 and a 1.37x on the same 27 - the
+ /// slider would move in 5% steps and would be writing a global while it did it.
+ ///
+ /// Scaling m_currentVel itself, which is what WarVultureMount does for the bird. That field
+ /// is the input to the NEXT frame's lerp, so scaling it feeds back: with a factor s the
+ /// velocity settles at 0.5s/(1-0.5s) times vanilla, not s times it, and at s >= 2 it does
+ /// not settle at all.
+ ///
+ /// So only the rigidbody is scaled, and m_currentVel is left exactly as vanilla wrote it. The
+ /// lerp keeps smoothing the same trajectory it always did - the ramp up, the ease off, the
+ /// standstill at zero input - and the bat simply covers it faster. Linear in the slider, with
+ /// nothing to accumulate.
+ ///
+ [HarmonyPatch(typeof(Character), "UpdateDebugFly")]
+ public static class Aswid_BatFlightSpeed_Patch
+ {
+ public static void Postfix(Character __instance, Vector3 ___m_currentVel, Rigidbody ___m_body)
+ {
+ // Bound from RacesOfValheim.Awake(), before harmony.PatchAll() - the null check is for
+ // the config that failed to bind at all, not for a race between the two.
+ if (AswidConfig.BatFormFlightSpeed == null) return;
+
+ float multiplier = AswidConfig.BatFormFlightSpeed.Value;
+ if (Mathf.Approximately(multiplier, 1f)) return;
+
+ // Local player only. Every other machine's bat moves on its replicated position, and
+ // scaling velocity here would fight that sync rather than help it.
+ Player player = __instance as Player;
+ if (player == null || player != Player.m_localPlayer) return;
+ if (___m_body == null) return;
+ if (!AswidBatForm.IsBat(player)) return;
+
+ ___m_body.linearVelocity = ___m_currentVel * multiplier;
+ }
+ }
+}
diff --git a/JotunnModStub/Aswid/AswidConfig.cs b/JotunnModStub/Aswid/AswidConfig.cs
index fd8ef0a..498f63e 100644
--- a/JotunnModStub/Aswid/AswidConfig.cs
+++ b/JotunnModStub/Aswid/AswidConfig.cs
@@ -33,6 +33,14 @@ namespace RacesOfValheim
public static ConfigEntry BloodMagicSkillGainMultiplier;
public static ConfigEntry SurtlingFormDamageBonus;
+ // ─── Bat Form ────────────────────────────────────────────────────────────
+ // Both of these undo something vanilla does to any player on the debug-fly flag, which is
+ // what the bat flies on. See AswidBatAggro for the six vanilla methods involved.
+ public static ConfigEntry BatFormAggro;
+ public static ConfigEntry BatFormVulnerable;
+ // A factor on vanilla's debug-fly speed, not a speed in metres - see AswidBatFlight.
+ public static ConfigEntry BatFormFlightSpeed;
+
// ─── Vampiric Aura (passive, always active) ──────────────────────────────
public static ConfigEntry AuraTickInterval;
public static ConfigEntry AuraRadiusDay;
@@ -122,6 +130,14 @@ namespace RacesOfValheim
SurtlingFormDamageBonus = config.Bind(combat, "Surtling Form Damage Bonus", 30f,
new ConfigDescription("Flat damage added to every attack once the tier 8 Surtling form is unlocked.", new AcceptableValueRange(0f, 100f)));
+ const string batform = "Aswid - Bat Form";
+ BatFormAggro = config.Bind(batform, "Monsters Notice The Bat", true,
+ new ConfigDescription("Lets monsters see, hear and wake up for a player in Bat Form. Vanilla refuses to notice anyone flying on the debug-fly flag, which is the flag the form uses - turn this off to go back to a bat nothing ever looks at."));
+ BatFormVulnerable = config.Bind(batform, "The Bat Can Be Hurt", true,
+ new ConfigDescription("Lets damage land on a player in Bat Form. Same cause as the setting above: vanilla drops every hit on a debug-flying character. Turn this off for a bat that is noticed and chased but cannot be killed."));
+ BatFormFlightSpeed = config.Bind(batform, "Flight Speed", 1f,
+ new ConfigDescription("How fast the bat flies, as a multiplier on the game's own flight speed (20 m/s, and 2.5x that while the run key is held). 1 is untouched, 2 is twice as fast, 0.5 is half. Local only - it changes how your own bat moves, not anyone else's.", new AcceptableValueRange(0.25f, 3f)));
+
const string aura = "Aswid - Vampiric Aura";
AuraTickInterval = config.Bind(aura, "Tick Interval", 0.25f,
new ConfigDescription("Seconds between aura damage/lifesteal ticks.", new AcceptableValueRange(0.05f, 2f)));
diff --git a/JotunnModStub/Aswid/AswidPatches.cs b/JotunnModStub/Aswid/AswidPatches.cs
index 0353ae1..5375aad 100644
--- a/JotunnModStub/Aswid/AswidPatches.cs
+++ b/JotunnModStub/Aswid/AswidPatches.cs
@@ -53,7 +53,9 @@ namespace RacesOfValheim
- [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })]
+ // Valheim 1.0 appended a 'short variant' parameter to this overload. The type array has to
+ // match it exactly or the patch silently fails to bind and PatchAll throws.
+ [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })]
public static class AswidSEManPatch
{
public static bool Prefix(SEMan __instance, ref int nameHash)
diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs
index d86cc69..4fe1d7e 100644
--- a/JotunnModStub/Aswid/AswidRace.cs
+++ b/JotunnModStub/Aswid/AswidRace.cs
@@ -416,6 +416,17 @@ namespace RacesOfValheim
{
StartCoroutine(RevertMistFormRoutine());
}
+
+ // Same rule for a night-only bat: a form the sun forbids cannot be kept through the
+ // sunrise, or the daylight gate above would only be one night's patience away from
+ // meaningless. activeRules is what the transform was actually granted under, so an
+ // Aswid who has killed The Elder (NeedsNight false) keeps flying into the morning.
+ if (IsTransformed && !isTransformingSequence && activeRules != null && activeRules.NeedsNight &&
+ EnvMan.instance != null && EnvMan.IsDay())
+ {
+ Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The morning sun drives the bat back into your body");
+ StartCoroutine(RevertToHumanRoutine());
+ }
}
private string DumpGameObject(GameObject go, string indent)
@@ -509,6 +520,17 @@ namespace RacesOfValheim
return;
}
+ // The night gate lives here, not in GetGKeyRules: the rules only say WHETHER night is
+ // required (state 2, Eikthyr) or not (state 3+, The Elder). Nothing ever read the
+ // NeedsNight flag, so an Aswid who had only killed Eikthyr could turn into a bat in
+ // broad daylight. Placed after the revert branch on purpose - a bat caught by the
+ // sunrise must always be able to turn back.
+ if (rules.NeedsNight && (EnvMan.instance == null || !EnvMan.IsNight()))
+ {
+ Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The sun burns. You can only take bat form at night.");
+ return;
+ }
+
StartCoroutine(TransformIntoBatRoutine(rules));
}
@@ -524,6 +546,49 @@ namespace RacesOfValheim
}
}
+ ///
+ /// Everything RevertToHumanRoutine does, minus the puff of smoke and the scale animation,
+ /// and without a coroutine - because the one moment this exists for is death, and by then
+ /// Update() has already bailed out on IsDead(), so a coroutine started here would be the
+ /// only thing still running on a corpse.
+ ///
+ /// Leaving the form up costs more than a missing animation: m_debugFly stays on, so the
+ /// respawned player floats; Aswid_IsBatForm stays true in the ZDO, so every other client
+ /// keeps drawing a bat over a body that is walking around as a person; and the 5% scale
+ /// stays on the transform. Called from Aswid_BatDiesAsBat_Patch.
+ ///
+ public void HardResetBatForm()
+ {
+ Player player = Player.m_localPlayer;
+ if (player == null) return;
+ if (!IsTransformed && !isTransformingSequence) return;
+
+ if (currentTransformation != null)
+ {
+ Destroy(currentTransformation);
+ currentTransformation = null;
+ }
+
+ PlayerVisualHider.Show(player.transform.Find("Visual"), "aswid-bat-death-reset");
+
+ if (player.GetSEMan() != null)
+ player.GetSEMan().RemoveStatusEffect("SE_BatForm".GetStableHashCode(), true);
+
+ ZNetView nview = player.GetComponent();
+ if (nview != null && nview.IsValid())
+ {
+ nview.GetZDO().Set("Aswid_IsBatForm", false);
+ nview.GetZDO().Set(ZDOVars.s_debugFly, false);
+ }
+ Traverse.Create(player).Field("m_debugFly").SetValue(false);
+
+ player.transform.localScale = Vector3.one;
+
+ IsTransformed = false;
+ activeRules = null;
+ isTransformingSequence = false;
+ }
+
private System.Collections.IEnumerator TransformIntoBatRoutine(AswidProgression.FormRules rules)
{
isTransformingSequence = true;
@@ -961,7 +1026,7 @@ namespace RacesOfValheim
// Create an invisible virtual inventory so the food never goes to the real bag
Inventory virtualInv = new Inventory("AswidStomach", null, 1, 1);
- ItemDrop.ItemData addedItem = virtualInv.AddItem(foodPrefab.name, 1, 1, 0, 0, "");
+ ItemDrop.ItemData addedItem = virtualInv.AddItem(foodPrefab.name, 1, 1, 0, 0, "", false);
if (addedItem != null)
{
diff --git a/JotunnModStub/Aswid/AswidThrall.cs b/JotunnModStub/Aswid/AswidThrall.cs
index 8d8297f..816517e 100644
--- a/JotunnModStub/Aswid/AswidThrall.cs
+++ b/JotunnModStub/Aswid/AswidThrall.cs
@@ -151,6 +151,10 @@ namespace RacesOfValheim
}
}
+ // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a
+ // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour.
+ public float GetHoverOffset() => 0f;
+
public string GetHoverName()
{
return ""; // Character component already provides the name
diff --git a/JotunnModStub/Aswid/BatFormBehavior.cs b/JotunnModStub/Aswid/BatFormBehavior.cs
index 27e9c2c..ef51ba2 100644
--- a/JotunnModStub/Aswid/BatFormBehavior.cs
+++ b/JotunnModStub/Aswid/BatFormBehavior.cs
@@ -1,10 +1,29 @@
+using HarmonyLib;
using UnityEngine;
using Jotunn.Managers;
namespace RacesOfValheim
{
+ ///
+ /// The bat's flight, held on for as long as the worn model exists.
+ ///
+ /// Debug fly has two halves, and this used to write only one. The field Player.m_debugFly is
+ /// what the local player's own physics reads; ZDOVars.s_debugFly is what every OTHER client
+ /// reads, because Character.IsDebugFlying consults the ZDO whenever it is not the owner. With
+ /// only the field written, a bat flew on its own screen and fell, walked and swam on everyone
+ /// else's - the fault WarVultureMount.SetFlying already names in its own summary. Both halves
+ /// go through SetFlying below now, so there is one place that can ever get it wrong again.
+ ///
+ /// Writing the ZDO every frame is not network spam: ZDO.Set(int, bool) bottoms out in
+ /// ZDOExtraData.Set, which returns false when the value is unchanged, and only a true return
+ /// bumps the data revision. Read out of the assembly rather than assumed, because "every frame"
+ /// deserved the check.
+ ///
public class BatFormBehavior : MonoBehaviour
{
+ private static readonly System.Reflection.FieldInfo DebugFlyField =
+ AccessTools.Field(typeof(Player), "m_debugFly");
+
private Animator anim;
private AswidProgression.FormRules formRules;
@@ -16,10 +35,7 @@ namespace RacesOfValheim
private void Start()
{
anim = GetComponentInChildren();
- if (Player.m_localPlayer != null)
- {
- HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(true);
- }
+ SetFlying(true);
}
private void Update()
@@ -27,7 +43,7 @@ namespace RacesOfValheim
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return;
// Ensure flight remains on continuously
- HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(true);
+ SetFlying(true);
// Sync Animator
if (anim != null)
@@ -35,7 +51,7 @@ namespace RacesOfValheim
Vector3 vel = Player.m_localPlayer.GetVelocity();
vel.y = 0f;
float speed = vel.magnitude;
-
+
// Bats don't necessarily have a complex animator like players,
// but if they do have a speed or flying parameter, we set it here.
anim.SetFloat("forward_speed", speed);
@@ -45,9 +61,25 @@ namespace RacesOfValheim
private void OnDestroy()
{
- if (Player.m_localPlayer != null)
+ SetFlying(false);
+ }
+
+ ///
+ /// Both halves of debug fly, always together. The field write survives a missing or invalid
+ /// ZNetView on purpose: without it a bat whose networking went away mid-flight would keep
+ /// flying on foot forever, which is the worse of the two failures.
+ ///
+ private static void SetFlying(bool flying)
+ {
+ Player player = Player.m_localPlayer;
+ if (player == null) return;
+
+ if (DebugFlyField != null) DebugFlyField.SetValue(player, flying);
+
+ ZNetView nview = player.GetComponent();
+ if (nview != null && nview.IsValid() && nview.IsOwner())
{
- HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_debugFly").SetValue(false);
+ nview.GetZDO().Set(ZDOVars.s_debugFly, flying);
}
}
}
diff --git a/JotunnModStub/BossProgressionManager.cs b/JotunnModStub/BossProgressionManager.cs
index d688a88..27e492e 100644
--- a/JotunnModStub/BossProgressionManager.cs
+++ b/JotunnModStub/BossProgressionManager.cs
@@ -95,6 +95,36 @@ namespace RacesOfValheim
}
}
+ ///
+ /// Whether this character carries a claimed personal tier at all. Distinct from
+ /// "PersonalState == MinState": the getter answers MinState for a character who has never
+ /// claimed anything AND for one who has been reset, and the Reset Progression button needs
+ /// to tell the player which of the two just happened.
+ ///
+ public static bool HasPersonalState
+ {
+ get
+ {
+ Player player = Player.m_localPlayer;
+ if (player == null || player.m_customData == null) return false;
+ return player.m_customData.ContainsKey(PersonalStateKey);
+ }
+ }
+
+ ///
+ /// Gives back every tier claimed with a boss relic. The key is removed rather than written
+ /// back as MinState so the character reads as one that never claimed anything - which is
+ /// what a reset means, and what HasPersonalState above then reports.
+ ///
+ /// The relics themselves do not come back: RaceMenuWardBehavior.UseItem consumed them.
+ ///
+ public static void ClearPersonalState()
+ {
+ Player player = Player.m_localPlayer;
+ if (player == null || player.m_customData == null) return;
+ player.m_customData.Remove(PersonalStateKey);
+ }
+
///
/// Returns the current progression state of the world based on defeated bosses.
/// 1 = No bosses defeated
diff --git a/JotunnModStub/Dvergar/DvergarBanco.cs b/JotunnModStub/Dvergar/DvergarBanco.cs
index d842803..f686d6a 100644
--- a/JotunnModStub/Dvergar/DvergarBanco.cs
+++ b/JotunnModStub/Dvergar/DvergarBanco.cs
@@ -400,8 +400,10 @@ namespace RacesOfValheim
/// The same shape as TrolTotemRaceLockPatch - the second station in the mod that refuses the hammer
/// outright, because hiring dvergr with dvergr money is the race's identity and not a tool it owns.
///
+ // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to
+ // match it exactly or the patch silently fails to bind and PatchAll throws.
[HarmonyPatch(typeof(Player), "PlacePiece",
- new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })]
+ new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })]
public static class DvergarBancoRaceLockPatch
{
public static bool Prefix(Player __instance, Piece __0)
diff --git a/JotunnModStub/Dvergar/DvergarBotte.cs b/JotunnModStub/Dvergar/DvergarBotte.cs
index 2a2bbeb..b389bc8 100644
--- a/JotunnModStub/Dvergar/DvergarBotte.cs
+++ b/JotunnModStub/Dvergar/DvergarBotte.cs
@@ -192,8 +192,10 @@ namespace RacesOfValheim
}
}
+ // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to
+ // match it exactly or the patch silently fails to bind and PatchAll throws.
[HarmonyPatch(typeof(Player), "PlacePiece",
- new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })]
+ new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })]
public static class DvergarBotteRaceLockPatch
{
public static bool Prefix(Player __instance, Piece __0)
diff --git a/JotunnModStub/Factions/FactionMerchantSellPanel.cs b/JotunnModStub/Factions/FactionMerchantSellPanel.cs
index ad97708..dbef7c7 100644
--- a/JotunnModStub/Factions/FactionMerchantSellPanel.cs
+++ b/JotunnModStub/Factions/FactionMerchantSellPanel.cs
@@ -169,7 +169,7 @@ namespace RacesOfValheim
int coinsEarned = entry.Price * sold;
GameObject coinPrefab = ((Component)gui.m_coinPrefab).gameObject;
- inv.AddItem(coinPrefab.name, coinsEarned, gui.m_coinPrefab.m_itemData.m_quality, gui.m_coinPrefab.m_itemData.m_variant, 0L, "");
+ inv.AddItem(coinPrefab.name, coinsEarned, gui.m_coinPrefab.m_itemData.m_quality, gui.m_coinPrefab.m_itemData.m_variant, 0L, "", false);
Trader trader = FactionMerchantRuntime.GetActiveTrader(gui);
trader?.OnSold();
diff --git a/JotunnModStub/Furling/FurlingFireAbility.cs b/JotunnModStub/Furling/FurlingFireAbility.cs
index 9d55afe..1d4d87f 100644
--- a/JotunnModStub/Furling/FurlingFireAbility.cs
+++ b/JotunnModStub/Furling/FurlingFireAbility.cs
@@ -93,8 +93,10 @@ namespace RacesOfValheim
}
// ─── Block external Burning (fire pits, arrows) from being applied ────
+ // Valheim 1.0 appended a 'short variant' parameter to this overload. The type array has to
+ // match it exactly or the patch silently fails to bind and PatchAll throws.
[HarmonyPatch(typeof(SEMan), "AddStatusEffect",
- new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })]
+ new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })]
public static class FurlingFire_SuppressExternalBurning_Patch
{
public static bool AllowNextBurning = false;
diff --git a/JotunnModStub/Furling/FurlingPatches.cs b/JotunnModStub/Furling/FurlingPatches.cs
index 2ba0df5..ce998f9 100644
--- a/JotunnModStub/Furling/FurlingPatches.cs
+++ b/JotunnModStub/Furling/FurlingPatches.cs
@@ -445,7 +445,7 @@ namespace RacesOfValheim
int quality = craftUpgradeItem != null ? craftUpgradeItem.m_quality + 1 : 1;
int craftVariant = HarmonyLib.Traverse.Create(__instance).Field("m_craftVariant").GetValue();
- ItemDrop.ItemData addedItem = player.GetInventory().AddItem(itemDrop.gameObject.name, amount, quality, craftVariant, player.GetPlayerID(), player.GetPlayerName());
+ ItemDrop.ItemData addedItem = player.GetInventory().AddItem(itemDrop.gameObject.name, amount, quality, craftVariant, player.GetPlayerID(), player.GetPlayerName(), false);
if (addedItem == null)
{
diff --git a/JotunnModStub/MaterialManPropertyBlockFix.cs b/JotunnModStub/MaterialManPropertyBlockFix.cs
new file mode 100644
index 0000000..c65b3e3
--- /dev/null
+++ b/JotunnModStub/MaterialManPropertyBlockFix.cs
@@ -0,0 +1,57 @@
+using System.Reflection;
+using HarmonyLib;
+using UnityEngine;
+
+namespace RacesOfValheim
+{
+ ///
+ /// Closes the window in Valheim 1.0 where MaterialMan hands out a null property block.
+ ///
+ /// MaterialMan splits its own start-up across two Unity callbacks:
+ ///
+ /// Awake() -> s_instance = this
+ /// Start() -> m_propertyBlock = new MaterialPropertyBlock()
+ ///
+ /// Between the two, MaterialMan.instance answers but its property block is still null. Anything
+ /// that registers with it in that gap gets a PropertyContainer built around that null - and the
+ /// container KEEPS it, because it copies the reference into a field of its own rather than
+ /// reading MaterialMan's each frame. UpdateBlock() opens with m_propertyBlock.Clear(), so that
+ /// one container then throws a NullReferenceException on every frame for the rest of the scene.
+ /// A single session logged 463 of them, all identical, all from MaterialMan.UpdateBlock.
+ ///
+ /// This is vanilla's bug, not ours, but 1.0 is what made us walk into it: VisEquipment.AttachArmor
+ /// and AttachItem now call RefreshSnowLevel, which registers with MaterialMan, and none of that
+ /// existed in 0.221. Comparing the two builds, the snow-cover system is the ONLY new caller of
+ /// MaterialMan - so a mod that dresses the main-menu preview, as this one does for every race,
+ /// reaches it during the gap where before there was nothing to reach.
+ ///
+ /// Filling the block in Awake costs one allocation, once per scene, and removes the gap: whoever
+ /// registers early now gets a real block. Start() still makes its own a moment later and every
+ /// container built after that point uses that one instead, which is fine - UpdateBlock clears and
+ /// refills the block before each renderer reads it, so a container holding a different instance
+ /// behaves identically. Vanilla is otherwise left alone.
+ ///
+ /// The symptom was only ever visible on the main menu, because loading a world builds a fresh
+ /// MaterialMan whose Start has long since run. It was never a gameplay bug - just 463 lines of
+ /// noise standing between us and the log entries that matter.
+ ///
+ [HarmonyPatch(typeof(MaterialMan), "Awake")]
+ internal static class MaterialManPropertyBlockFix
+ {
+ /// Private in the shipped assembly, so it is reached by reflection like the rest.
+ private static readonly FieldInfo PropertyBlock = AccessTools.Field(typeof(MaterialMan), "m_propertyBlock");
+
+ /// If a future build renames or removes the field, patch nothing rather than guess.
+ private static bool Prepare() => PropertyBlock != null;
+
+ private static void Postfix(MaterialMan __instance)
+ {
+ // Awake destroys itself when another instance already claimed s_instance. Writing to a
+ // component on its way out is harmless, and testing for it would cost more than it saves.
+ if (PropertyBlock.GetValue(__instance) == null)
+ {
+ PropertyBlock.SetValue(__instance, new MaterialPropertyBlock());
+ }
+ }
+ }
+}
diff --git a/JotunnModStub/Package/manifest.json b/JotunnModStub/Package/manifest.json
index 64c27c6..1f8bed5 100644
--- a/JotunnModStub/Package/manifest.json
+++ b/JotunnModStub/Package/manifest.json
@@ -1,7 +1,7 @@
{
"name": "RacesOfValheim",
"description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
- "version_number": "1.4.11",
+ "version_number": "1.4.13",
"website_url": "",
"dependencies": [
"denikson-BepInExPack_Valheim-5.4.2333",
diff --git a/JotunnModStub/PieceDensityLimit.cs b/JotunnModStub/PieceDensityLimit.cs
index ee01fe4..e39f9b4 100644
--- a/JotunnModStub/PieceDensityLimit.cs
+++ b/JotunnModStub/PieceDensityLimit.cs
@@ -186,8 +186,10 @@ namespace RacesOfValheim
/// is the build ghost, so `pos` is the authority on where this thing is actually going.
/// Parameters are bound positionally (__0, __1) so a rename cannot break startup either.
///
+ // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to
+ // match it exactly or the patch silently fails to bind and PatchAll throws.
[HarmonyPatch(typeof(Player), "PlacePiece",
- new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })]
+ new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })]
public static class PieceDensityLimitPatch
{
public static bool Prefix(Player __instance, Piece __0, Vector3 __1)
diff --git a/JotunnModStub/RaceMenuWard.cs b/JotunnModStub/RaceMenuWard.cs
index b564d26..255b38e 100644
--- a/JotunnModStub/RaceMenuWard.cs
+++ b/JotunnModStub/RaceMenuWard.cs
@@ -163,6 +163,10 @@ namespace RacesOfValheim
public class RaceMenuWardBehavior : MonoBehaviour, Hoverable, Interactable
{
+ // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a
+ // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour.
+ public float GetHoverOffset() => 0f;
+
public string GetHoverName() => "Race Menu Ward";
public string GetHoverText()
@@ -286,9 +290,12 @@ namespace RacesOfValheim
RacesOfValheim.ResetRace();
});
+ // Refresh and not Close: unlike Reset Race, this one leaves the panel up so the two
+ // World/Personal lines visibly change under the player. That is also how the old
+ // no-op was noticed - the numbers stayed put while the message claimed a reset.
AddButton("ResetProgressionBtn", "Reset Progression", new Vector2(170, -110), new Color(0.5f, 0.4f, 0.2f, 1f), () =>
{
- RacesOfValheim.ResetProgression();
+ RacesOfValheim.ResetProgression(out _);
Refresh();
});
diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs
index a0f4dc0..9929a4a 100644
--- a/JotunnModStub/RacesOfValheim.cs
+++ b/JotunnModStub/RacesOfValheim.cs
@@ -15,7 +15,7 @@ namespace RacesOfValheim
{
public const string PluginGUID = "com.nandor.racesofvalheim";
public const string PluginName = "Races Of Valheim";
- public const string PluginVersion = "1.4.11";
+ public const string PluginVersion = "1.4.13";
private readonly Harmony harmony = new Harmony(PluginGUID);
@@ -160,18 +160,59 @@ namespace RacesOfValheim
}
///
- /// Clears the boss-progression override and falls back to the natural world state.
- /// Shared by the resetprogression console command and the Race Menu Ward.
+ /// Gives back the progression a player claimed for themselves, and says plainly when there
+ /// is none to give back. Shared by the resetprogression console command and the Race Menu
+ /// Ward's Reset Progression button.
+ ///
+ /// This used to clear BossProgressionManager.DebugState and nothing else - the console-only
+ /// debug override, a static that is -1 at every launch and that the ward never writes. The
+ /// two things the ward DOES write, RacesOfValheim_PersonalState and _PersonalMode in
+ /// m_customData, were untouched, so for anyone who had not just typed increaseprogression
+ /// in this session the button was a no-op by construction. It then reported
+ /// GetCurrentProgressionState() as the result, which is the unchanged current tier - the
+ /// "it always puts me back at the tier I'm on" the testers were describing. They were
+ /// reading the one number that function could possibly have produced.
+ ///
+ /// What it resets now is the personal tier only. The progression MODE is deliberately left
+ /// alone: a player who chose to be independent of the server's kills stays independent,
+ /// they just start claiming relics again from the bottom. And world progression is not this
+ /// button's to reset - those are the world's global keys, shared by everyone on the server -
+ /// so in world mode it says so rather than pretending.
///
- public static int ResetProgression()
+ /// Human-readable account of what actually changed, for the console.
+ public static int ResetProgression(out string summary)
{
+ // Still cleared, and first: it outranks both of the others in
+ // GetCurrentProgressionState, so leaving it up would mask whatever we do below.
+ bool hadDebugOverride = BossProgressionManager.DebugState != -1;
BossProgressionManager.DebugState = -1;
+
+ bool clearedPersonal = false;
+ if (BossProgressionManager.UsePersonalProgression && BossProgressionManager.HasPersonalState)
+ {
+ BossProgressionManager.ClearPersonalState();
+ clearedPersonal = true;
+ }
+
int state = BossProgressionManager.GetCurrentProgressionState();
+ string boss = BossProgressionManager.GetBossNameForState(state);
+
+ if (clearedPersonal)
+ summary = $"Personal progression reset to {boss} ({state}/{BossProgressionManager.MaxState}). Claim your relics again.";
+ else if (BossProgressionManager.UsePersonalProgression)
+ summary = $"Nothing to reset - you have claimed no relics yet ({state}/{BossProgressionManager.MaxState}).";
+ else
+ summary = $"Nothing to reset - you follow the world's progression: {boss} ({state}/{BossProgressionManager.MaxState}).";
+
+ if (hadDebugOverride) summary += " Debug override cleared.";
Player player = Player.m_localPlayer;
if (player != null)
{
- player.Message(MessageHud.MessageType.Center, $"Progression reset to: {state}");
+ player.Message(MessageHud.MessageType.Center, summary);
+
+ // Progression drives stats and unlocks that are only recalculated when equipment is
+ // set up, so nudge that or the new tier will not show until something else does.
Traverse.Create(player).Method("SetupEquipment").GetValue();
}
@@ -1299,8 +1340,8 @@ namespace RacesOfValheim
public override void Run(string[] args)
{
- int state = RacesOfValheim.ResetProgression();
- Console.instance.Print($"[DEBUG] Progression state reset to natural world state: {state}");
+ RacesOfValheim.ResetProgression(out string summary);
+ Console.instance.Print($"[DEBUG] {summary}");
}
}
diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs
index 74ff020..cfc78a0 100644
--- a/JotunnModStub/Skadi/DrakeFormBehavior.cs
+++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs
@@ -282,7 +282,9 @@ namespace RacesOfValheim
HitData hitData = new HitData();
hitData.m_damage = staffDrop.m_itemData.m_shared.m_damages;
hitData.SetAttacker(Player.m_localPlayer);
-
+ // The Drake breath is a fixed three-shard volley, so one third each.
+ SkadiMagicSkill.TagCast(hitData, 3);
+
proj.Setup(Player.m_localPlayer, targetDir * vel, -1f, hitData, staffDrop.m_itemData, null);
}
@@ -376,6 +378,7 @@ namespace RacesOfValheim
HitData hitData = new HitData();
hitData.m_damage = staffDrop.m_itemData.m_shared.m_damages;
hitData.SetAttacker(Player.m_localPlayer);
+ SkadiMagicSkill.TagCast(hitData, projCount);
proj.Setup(Player.m_localPlayer, targetDir * vel, -1f, hitData, staffDrop.m_itemData, null);
}
@@ -484,6 +487,7 @@ namespace RacesOfValheim
hitData.m_damage.m_frost += hitData.m_damage.m_fire;
hitData.m_damage.m_fire = 0f;
hitData.SetAttacker(Player.m_localPlayer);
+ SkadiMagicSkill.TagCast(hitData, projCount);
if (proj != null)
{
diff --git a/JotunnModStub/Skadi/SkadiConfig.cs b/JotunnModStub/Skadi/SkadiConfig.cs
index 81134c3..22db0ab 100644
--- a/JotunnModStub/Skadi/SkadiConfig.cs
+++ b/JotunnModStub/Skadi/SkadiConfig.cs
@@ -45,6 +45,12 @@ namespace RacesOfValheim
public static ConfigEntry AuraDamagePerTick;
public static ConfigEntry AuraTickInterval;
+ // ─── Elemental Magic experience ─────────────────────────────────────────
+ // See SkadiMagicSkill for why a cast's budget is split across its projectiles and why the
+ // aura's share is a fraction of a cast's.
+ public static ConfigEntry MagicSkillGainPerCast;
+ public static ConfigEntry AuraSkillGainPerTick;
+
// ─── Passive combat ──────────────────────────────────────────────────
public static ConfigEntry BonusFrostDamagePerState;
@@ -126,6 +132,12 @@ namespace RacesOfValheim
AuraTickInterval = config.Bind(aura, "Tick Interval", 1f,
new ConfigDescription("Seconds between aura damage ticks.", new AcceptableValueRange(0.1f, 5f)));
+ const string magicSkill = "Skadi - Elemental Magic Skill";
+ MagicSkillGainPerCast = config.Bind(magicSkill, "Gain Per Cast", 1f,
+ new ConfigDescription("Elemental Magic experience for one cast that connects - the Cold Spell and all three dragon breaths. Split across the projectiles a cast throws, so a ten-shard burst is worth the same as one shard. Nothing is earned by a shot that hits no one. 0 turns spell experience off.", new AcceptableValueRange(0f, 5f)));
+ AuraSkillGainPerTick = config.Bind(magicSkill, "Aura Gain Per Tick", 0.1f,
+ new ConfigDescription("Elemental Magic experience for one Frost Aura tick that burned at least one enemy - once per tick, not once per enemy. Deliberately a fraction of a cast: the aura ticks every second on its own. 0 turns aura experience off.", new AcceptableValueRange(0f, 1f)));
+
const string scale = "Skadi - Dragon Form Scale";
DrakeScale = config.Bind(scale, "Drake Scale", 0.9f,
new ConfigDescription("Model scale while transformed into the Drake (tier 3-4).", new AcceptableValueRange(0.1f, 2f)));
diff --git a/JotunnModStub/Skadi/SkadiMagicSkill.cs b/JotunnModStub/Skadi/SkadiMagicSkill.cs
new file mode 100644
index 0000000..a35d23d
--- /dev/null
+++ b/JotunnModStub/Skadi/SkadiMagicSkill.cs
@@ -0,0 +1,83 @@
+namespace RacesOfValheim
+{
+ ///
+ /// Elemental Magic experience for Skadi's spellcasting, in one place because four call sites
+ /// need the same two lines and the same piece of arithmetic.
+ ///
+ /// WHY NOTHING WAS LEVELLING BEFORE. Every one of Skadi's casts builds its HitData by hand and
+ /// never touched HitData.m_skill, which leaves it at SkillType.None. Vanilla's Skills.RaiseSkill
+ /// returns on its first instruction when the type is None, so the experience was not merely
+ /// small - it was structurally impossible. Read out of assembly_valheim, along with the path
+ /// that makes the fix a one-liner:
+ ///
+ /// Projectile.Setup copies hitData.m_skill into Projectile.m_skill, and
+ /// hitData.m_skillRaiseAmount into Projectile.m_raiseSkillAmount.
+ /// Projectile.OnHit calls owner.RaiseSkill(m_skill, m_raiseSkillAmount) - once, and only
+ /// on the branch where the projectile actually damaged something.
+ ///
+ /// So a tagged HitData gets vanilla's own behaviour for free: experience on a hit that lands,
+ /// nothing for a shot into a hillside, and no double-counting. That is better than raising the
+ /// skill at cast time, which would pay a player for missing.
+ ///
+ /// WHY THE AMOUNT IS DIVIDED. A cast is one spell however many things leave the hand. The
+ /// improved Cold Spell throws ten shards and the dragon breaths throw up to a volley each, and
+ /// every one of those is its own Projectile with its own OnHit - so an untouched
+ /// m_skillRaiseAmount of 1 would pay ten times for one cast. The budget is split the same way
+ /// ColdSpellKickCoroutine already splits its damage budget across shards, for the same reason.
+ ///
+ /// WHAT IS DELIBERATELY NOT HERE. The dragon forms' melee (DrakeFormBehavior.ExecuteMeleeDamage)
+ /// stays on Unarmed: it already tags itself that way and already scales off the Unarmed skill
+ /// level - it is a maul, not a spell. And the Crystal Golem is a hammer piece, not a cast, so it
+ /// pays Building experience through vanilla's own placement path.
+ ///
+ public static class SkadiMagicSkill
+ {
+ ///
+ /// Marks a cast's HitData as Elemental Magic and gives it its share of the cast's
+ /// experience. Call it before Projectile.Setup - Setup is what copies both fields onto the
+ /// projectile, so anything written afterwards is never read.
+ ///
+ /// The HitData about to be handed to Projectile.Setup.
+ ///
+ /// How many projectiles this one cast throws. The cast's whole experience budget is divided
+ /// by it, so a ten-shard burst and a single shard are worth the same.
+ ///
+ public static void TagCast(HitData hit, int projectilesInCast)
+ {
+ if (hit == null) return;
+
+ float perCast = SkadiConfig.MagicSkillGainPerCast != null
+ ? SkadiConfig.MagicSkillGainPerCast.Value
+ : 1f;
+
+ // Zero is the off switch, and it has to leave m_skill alone as well as the amount:
+ // Skills.RaiseSkill would still be entered with a real type and a zero factor, and
+ // Skill.Raise does its own bookkeeping before it looks at the number.
+ if (perCast <= 0f) return;
+
+ if (projectilesInCast < 1) projectilesInCast = 1;
+
+ hit.m_skill = Skills.SkillType.ElementalMagic;
+ hit.m_skillRaiseAmount = perCast / projectilesInCast;
+ }
+
+ ///
+ /// The Frost Aura's share. Unlike a cast the aura has no projectile to hang experience on,
+ /// so it is raised directly - once per tick that actually burned something, never once per
+ /// enemy. A three metre aura ticking every second through a pack would otherwise pay out
+ /// several times a second and take the skill to cap on a single fight, which is why the
+ /// default is a fraction rather than the 1 a cast is worth.
+ ///
+ public static void RaiseForAuraTick()
+ {
+ if (Player.m_localPlayer == null) return;
+
+ float gain = SkadiConfig.AuraSkillGainPerTick != null
+ ? SkadiConfig.AuraSkillGainPerTick.Value
+ : 0f;
+ if (gain <= 0f) return;
+
+ Player.m_localPlayer.RaiseSkill(Skills.SkillType.ElementalMagic, gain);
+ }
+ }
+}
diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs
index 0538faa..6cdcc99 100644
--- a/JotunnModStub/Skadi/SkadiPatches.cs
+++ b/JotunnModStub/Skadi/SkadiPatches.cs
@@ -118,7 +118,9 @@ namespace RacesOfValheim
}
}
- [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })]
+ // Valheim 1.0 appended a 'short variant' parameter to this overload. The type array has to
+ // match it exactly or the patch silently fails to bind and PatchAll throws.
+ [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })]
public static class SkadiSEManPatch
{
public static bool Prefix(SEMan __instance, ref int nameHash)
diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs
index 88a3ad7..1daec80 100644
--- a/JotunnModStub/Skadi/SkadiRace.cs
+++ b/JotunnModStub/Skadi/SkadiRace.cs
@@ -431,6 +431,9 @@ namespace RacesOfValheim
HitData hitData = new HitData();
hitData.m_damage.m_frost = shardDamage;
hitData.SetAttacker(Player.m_localPlayer);
+ // Before Setup, which is what copies the skill and its amount onto the
+ // projectile. Same split as the damage budget above, and for the same reason.
+ SkadiMagicSkill.TagCast(hitData, count);
proj.Setup(Player.m_localPlayer, lookDir * staffDrop.m_itemData.m_shared.m_attack.m_projectileVel, -1f, hitData, staffDrop.m_itemData, null);
}
@@ -509,11 +512,15 @@ namespace RacesOfValheim
{
if (Player.m_localPlayer == null) return;
Vector3 center = Player.m_localPlayer.transform.position;
+
+ // Once per tick, not once per enemy - see SkadiMagicSkill.RaiseForAuraTick.
+ bool burnedSomething = false;
+
foreach (Character c in Character.GetAllCharacters())
{
if (c == Player.m_localPlayer) continue;
if (c.IsTamed() || c.IsPlayer()) continue;
-
+
if (Vector3.Distance(center, c.transform.position) <= SkadiConfig.AuraRadius.Value)
{
HitData hit = new HitData();
@@ -522,8 +529,11 @@ namespace RacesOfValheim
hit.m_dir = (c.transform.position - center).normalized;
hit.SetAttacker(Player.m_localPlayer);
c.ApplyDamage(hit, true, false);
+ burnedSomething = true;
}
}
+
+ if (burnedSomething) SkadiMagicSkill.RaiseForAuraTick();
}
private void TryTransformWithRules(SkadiProgression.FormRules rules)
diff --git a/JotunnModStub/Skeleton/SkeletonRace.cs b/JotunnModStub/Skeleton/SkeletonRace.cs
index 4855072..90311d6 100644
--- a/JotunnModStub/Skeleton/SkeletonRace.cs
+++ b/JotunnModStub/Skeleton/SkeletonRace.cs
@@ -308,8 +308,9 @@ namespace RacesOfValheim
VisEquipment vis = Player.m_localPlayer.GetComponent();
if (vis != null)
{
- vis.SetHairItem("");
- vis.SetBeardItem("");
+ // Since Valheim 1.0 these take an item hash, not a prefab name. 0 is the empty slot.
+ vis.SetHairItem(0);
+ vis.SetBeardItem(0);
}
}
}
diff --git a/JotunnModStub/Sverm/SvermHive.cs b/JotunnModStub/Sverm/SvermHive.cs
index f174aff..c3f0114 100644
--- a/JotunnModStub/Sverm/SvermHive.cs
+++ b/JotunnModStub/Sverm/SvermHive.cs
@@ -467,6 +467,10 @@ namespace RacesOfValheim
"[$KEY_Use] Feed it a stack";
}
+ // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a
+ // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour.
+ public float GetHoverOffset() => 0f;
+
public string GetHoverName() => SvermHiveStage.NameOf(SvermHiveStage.Of(transform));
private ZNetView nview;
diff --git a/JotunnModStub/Sverm/SvermHiveStore.cs b/JotunnModStub/Sverm/SvermHiveStore.cs
index d194ad3..39df58b 100644
--- a/JotunnModStub/Sverm/SvermHiveStore.cs
+++ b/JotunnModStub/Sverm/SvermHiveStore.cs
@@ -211,6 +211,10 @@ namespace RacesOfValheim
public bool UseItem(Humanoid user, ItemDrop.ItemData item) => false;
+ // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a
+ // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour.
+ public float GetHoverOffset() => 0f;
+
public string GetHoverName() => Title;
public string GetHoverText()
@@ -444,6 +448,10 @@ namespace RacesOfValheim
public bool UseItem(Humanoid user, ItemDrop.ItemData item) => false;
+ // New in Valheim 1.0: Hoverable gained this. Every vanilla implementation returns a
+ // serialised m_hoverOffset, which is 0 unless the prefab sets one, so 0 is vanilla behaviour.
+ public float GetHoverOffset() => 0f;
+
public string GetHoverName() => SvermHiveMarketPiece.DisplayName;
public string GetHoverText()
diff --git a/JotunnModStub/Sverm/SvermVisuals.cs b/JotunnModStub/Sverm/SvermVisuals.cs
index f2dca7b..94194ab 100644
--- a/JotunnModStub/Sverm/SvermVisuals.cs
+++ b/JotunnModStub/Sverm/SvermVisuals.cs
@@ -682,9 +682,10 @@ namespace RacesOfValheim
if (player.GetComponent() == null) player.gameObject.AddComponent();
- visEq.SetChestItem(SvermConfig.CarapaceChestVisual);
- visEq.SetLegItem(SvermConfig.CarapaceLegsVisual);
- visEq.SetHelmetItem(SvermConfig.CarapaceHelmetVisual);
+ // Since Valheim 1.0 these three take an item hash rather than a prefab name.
+ visEq.SetChestItem(VisualHash(SvermConfig.CarapaceChestVisual));
+ visEq.SetLegItem(VisualHash(SvermConfig.CarapaceLegsVisual));
+ visEq.SetHelmetItem(VisualHash(SvermConfig.CarapaceHelmetVisual));
int state = GetRenderState(player);
@@ -697,7 +698,7 @@ namespace RacesOfValheim
/// Puts the three slots back to whatever the player actually has equipped.
///
/// The same three lines vanilla's own Humanoid.SetupVisEquipment writes - the item's drop
- /// prefab name, or "" for an empty slot - rather than calling that method, because it also
+ /// prefab name hashed, or 0 when empty - rather than calling that method, because it also
/// rewrites the hands, the shoulders and the utility slot, and the Sverm never touched
/// those. Restoring only what was overridden cannot disturb another race's visuals or a
/// weapon that some other patch is mid-way through swapping.
@@ -707,17 +708,25 @@ namespace RacesOfValheim
///
private static void RestoreEquipmentVisuals(Player player, VisEquipment visEq)
{
- visEq.SetChestItem(EquippedVisualName(player, "m_chestItem"));
- visEq.SetLegItem(EquippedVisualName(player, "m_legItem"));
- visEq.SetHelmetItem(EquippedVisualName(player, "m_helmetItem"));
+ visEq.SetChestItem(EquippedVisualHash(player, "m_chestItem"));
+ visEq.SetLegItem(EquippedVisualHash(player, "m_legItem"));
+ visEq.SetHelmetItem(EquippedVisualHash(player, "m_helmetItem"));
}
- /// The prefab name VisEquipment wants for an equipped slot, or "" when it is empty.
- private static string EquippedVisualName(Player player, string field)
+ ///
+ /// What VisEquipment has wanted since Valheim 1.0: an item hash instead of a prefab name.
+ /// 0 is the empty slot - the same value vanilla Humanoid.SetupVisEquipment passes for a
+ /// slot holding nothing.
+ ///
+ private static int VisualHash(string prefabName) =>
+ string.IsNullOrEmpty(prefabName) ? 0 : prefabName.GetStableHashCode();
+
+ /// The item hash VisEquipment wants for an equipped slot, or 0 when it is empty.
+ private static int EquippedVisualHash(Player player, string field)
{
ItemDrop.ItemData item = Traverse.Create((Humanoid)player).Field(field).Value;
- if (item == null || item.m_dropPrefab == null) return "";
- return item.m_dropPrefab.name;
+ if (item == null || item.m_dropPrefab == null) return 0;
+ return VisualHash(item.m_dropPrefab.name);
}
private static void TintInstances(object value, int state)
diff --git a/JotunnModStub/Trenta/TrentaElderRoot.cs b/JotunnModStub/Trenta/TrentaElderRoot.cs
index 5f0fba8..ccbcc54 100644
--- a/JotunnModStub/Trenta/TrentaElderRoot.cs
+++ b/JotunnModStub/Trenta/TrentaElderRoot.cs
@@ -279,8 +279,10 @@ namespace RacesOfValheim
/// Race lock plus the boss gate, in one prefix - same shape as TrolTotemRaceLockPatch, with a
/// second refusal added for the progression check the Root also needs.
///
+ // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to
+ // match it exactly or the patch silently fails to bind and PatchAll throws.
[HarmonyPatch(typeof(Player), "PlacePiece",
- new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })]
+ new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })]
public static class TrentaElderRootPlacementPatch
{
public static bool Prefix(Player __instance, Piece __0)
diff --git a/JotunnModStub/Trenta/TrentaPatches.cs b/JotunnModStub/Trenta/TrentaPatches.cs
index 4bf50dd..33afad0 100644
--- a/JotunnModStub/Trenta/TrentaPatches.cs
+++ b/JotunnModStub/Trenta/TrentaPatches.cs
@@ -134,7 +134,9 @@ namespace RacesOfValheim
/// ever adds Wet, always through this exact four-argument SEMan.AddStatusEffect overload,
/// so patching that call is equivalent to patching every path Wet could arrive by.
///
- [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float) })]
+ // Valheim 1.0 appended a 'short variant' parameter to this overload. The type array has to
+ // match it exactly or the patch silently fails to bind and PatchAll throws.
+ [HarmonyPatch(typeof(SEMan), "AddStatusEffect", new System.Type[] { typeof(int), typeof(bool), typeof(int), typeof(float), typeof(short) })]
public static class Trenta_SEMan_AddStatusEffect_WetImmunity_Patch
{
public static bool Prefix(SEMan __instance, int nameHash)
diff --git a/JotunnModStub/Trol/TrolTotem.cs b/JotunnModStub/Trol/TrolTotem.cs
index 0dea4fb..b4beb46 100644
--- a/JotunnModStub/Trol/TrolTotem.cs
+++ b/JotunnModStub/Trol/TrolTotem.cs
@@ -362,8 +362,10 @@ namespace RacesOfValheim
/// The race lock. Every other station in this mod is buildable by anyone; this one is not, so the
/// refusal is caught at placement - before the core wood and the head are spent.
///
+ // Valheim 1.0 appended a 'bool cheated' parameter to this overload. The type array has to
+ // match it exactly or the patch silently fails to bind and PatchAll throws.
[HarmonyPatch(typeof(Player), "PlacePiece",
- new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool) })]
+ new[] { typeof(Piece), typeof(Vector3), typeof(Quaternion), typeof(bool), typeof(bool) })]
public static class TrolTotemRaceLockPatch
{
public static bool Prefix(Player __instance, Piece __0)
diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs
index 40061ef..c7d2f2f 100644
--- a/JotunnModStub/ZdoVisualSync.cs
+++ b/JotunnModStub/ZdoVisualSync.cs
@@ -122,8 +122,9 @@ namespace RacesOfValheim
VisEquipment vis = m_player.GetComponent();
if (vis != null)
{
- vis.SetHairItem("");
- vis.SetBeardItem("");
+ // Since Valheim 1.0 these take an item hash, not a prefab name. 0 is the empty slot.
+ vis.SetHairItem(0);
+ vis.SetBeardItem(0);
// Hide Helmet
var helmetObj = HarmonyLib.Traverse.Create(vis).Field("m_helmetItemInstance").Value;
diff --git a/README.md b/README.md
index 7296f46..3a74061 100644
--- a/README.md
+++ b/README.md
@@ -4,6 +4,16 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing
---
+## Warning
+
+Jotunn has not been updated for Valheim 1.0 yet, and RacesOfValheim cannot run without it. Until the official build is out, install this community rebuild of Jotunn instead:
+
+[ReefTeam — Jotunn](https://thunderstore.io/c/valheim/p/ReefTeam/Jotunn/)
+
+Remove it once the Jotunn team ships its own 1.0 release.
+
+---
+
## Development & Feedback
This is a stable release, but more races and refinements are planned!
@@ -39,6 +49,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions
- **Ice Affinity:** Resistant to cold, with unique frost mechanics.
- **Drake Form:** Can transform into a frost Drake, letting you fly.
- **Dragon Form:** Evolve into Moder and later even the Skeleton Dragon.
+- **Elemental Magic:** The Cold Spell and all three dragon breaths raise the Elemental Magic skill when they connect — one cast is worth one cast, however many shards it throws. The Frost Aura earns a fraction of that per tick that actually burns something. Both amounts are configurable, and the dragon forms' melee stays on Unarmed, where it always was.
### 3. Fenrir

@@ -52,7 +63,7 @@ Full details under [Sverm](#10-sverm) and [Sverm Progression](#race-progressions
### 4. Aswid

- **The Vampire:** Life-draining abilities.
-- **Bat Form:** Press G to become a bat and fly.
+- **Bat Form:** Press G to become a bat and fly. Monsters see, hear and wake for the bat, and can hurt it — both are configurable under `Aswid - Bat Form` if you would rather scout untouched.
- **Vampiric Aura:** A passive life-draining aura around you, always on in every form (half damage as human, full as bat, double as mist) — no key to hold. Press **[I]** to toggle it (and Devour) off, e.g. before trading with Haldor or Hildir, since it does not recognize traders from monsters.
- **Blood Magic Mastery:** Cast Blood Magic items with infinite Eitr (health cost only).
- **Benedictus et Afflictus:** Passive speed/jump bonuses double at night.
@@ -380,7 +391,7 @@ Interact to reset your race, reset your progression, or switch between:
- **World progression:** tier follows world’s bosses.
- **Personal progression:** tier saved to character (server independent).
-**Reset Progression** drops any tier override you've claimed and falls back to what the world has actually killed — the same thing the `resetprogression` console command does, without the console.
+**Reset Progression** gives back the tiers you claimed with boss relics, so you start claiming them again from the bottom. It leaves the mode alone — a character on personal progression stays on personal progression — and in world mode it says there is nothing to reset rather than pretending, because the world's bosses are the server's business and not one player's. The relics themselves are not refunded. The button and the `resetprogression` console command run the same code, so the two can't drift apart.
In personal mode, offer boss’s secondary drop to the Ward (Hard Antler, Crypt Key, Wishbone, Dragon Tear, Yagluth’s thing, Queen’s carapace, Fader’s relic) to claim boss tier.
@@ -409,6 +420,17 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact
## Changelog
+### v1.4.13
+- Update to 1.0.
+
+### v1.4.12
+- **Fix - The Aswid could turn into a bat in broad daylight after killing Eikthyr alone:** the form has always been meant to answer only at night until The Elder falls, and the progression table said exactly that — but nothing ever read the flag, so the daylight restriction had never once been in effect. It is enforced now, with a message instead of a silent refusal, and a night-only bat caught by the sunrise is put back into its body rather than being allowed to fly on until dusk. Killing The Elder still lifts the restriction for good.
+- **NEW - The bat's flight speed is a slider:** `Flight Speed` under `Aswid - Bat Form`, a multiplier on the game's own flight speed (1 is untouched, up to 3). It scales the movement the game had already computed, so the acceleration, the ease-off and the standstill at zero input all feel the same — only the ground covered changes — and holding the run key still doubles it on top. Local to your own bat.
+- **Fix - Nothing in the game ever attacked the Aswid's bat form, and nothing could hurt it either:** the bat flies on Valheim's debug-fly flag, which is the only flight the game has — and vanilla reads that flag as *this player is not really here*. Six methods act on it: the AI's sight and hearing checks both refuse a debug-flying player on their first line, the hunt-the-nearest-player fallback throws them away, sleeping monsters will not wake for one, and both damage entry points drop every hit. So a bat could glide through a draugr camp untouched, and could not be killed if it tried. The flag stays — it *is* the flight — and is now overridden in exactly the places that decide aggro and damage, and nowhere else. Two toggles under `Aswid - Bat Form` if you preferred the old ghost: **Monsters Notice The Bat** and **The Bat Can Be Hurt**, both on. Dying as a bat is possible for the first time, so the form is now taken down properly on death instead of leaving the player floating on respawn.
+- **Fix - The bat looked wrong to everyone else in multiplayer:** debug fly has two halves — a local field the flying player's own physics reads, and a networked value every *other* client reads. Only the first was ever written, so a bat flew on its own screen while walking, falling and swimming on everybody else's. Both are now written together.
+- **Fix - Reset Progression on the Race Menu Ward did nothing:** the button cleared a console-only debug override — a value that is empty at every launch and that the Ward never writes — and never touched the two things the Ward actually stores, the claimed tier and the progression mode. It then reported the unchanged current tier back as the result, which is why it always looked like it had reset you to the tier you were already on. It now gives back the tiers claimed with boss relics, leaves the mode alone (personal stays personal), and in world mode says there is nothing to reset instead of pretending. The relics are not refunded.
+- **NEW - Skadi's spells raise Elemental Magic:** they never could before — every one of Skadi's casts builds its damage by hand and left the skill field unset, and vanilla's skill code returns immediately on an unset skill, so the experience was not small but structurally impossible. The Cold Spell and all three dragon breaths now pay out through vanilla's own path: on a hit that lands, nothing for a shot into a hillside, and one cast's worth however many shards it throws — a ten-shard burst is not worth ten casts. The Frost Aura earns a fraction of a cast per tick that actually burned something, once per tick rather than once per enemy, so a pack does not take the skill to cap in one fight. Both numbers live under `Skadi - Elemental Magic Skill` and either can be set to 0. The dragon forms' melee deliberately stays on Unarmed, where it already was, and the Crystal Golem stays a hammer piece paying Building.
+
### v1.4.11
- **Fix - Bone Servant cook only ever produced one meat:** the servant swept the ground for its finished item *before* pulling a new one out of the station, so each visit collected the previous visit's item and left without grabbing what it had just pulled loose — a working hearth always had exactly one cooked meat sitting beside it. It now pulls first, in a loop bounded by the station's own slot count.
- **Fix - Bone Smith refuelling never got a turn:** fuel-loading ran behind ore-loading, and a furnace's free slots reopen the instant it eats one ore — so ore-loading always had an answer and the furnace burned down to nothing between visits. Fuel now loads first.
diff --git a/manifest.json b/manifest.json
index 64c27c6..1f8bed5 100644
--- a/manifest.json
+++ b/manifest.json
@@ -1,7 +1,7 @@
{
"name": "RacesOfValheim",
"description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
- "version_number": "1.4.11",
+ "version_number": "1.4.13",
"website_url": "",
"dependencies": [
"denikson-BepInExPack_Valheim-5.4.2333",