From ecf6e1bedbec091fb87b1d19ce4200de48c37558 Mon Sep 17 00:00:00 2001 From: kanym Date: Thu, 29 Oct 2026 20:04:28 +0100 Subject: [PATCH 1/5] fix: Grafvaettir drones keep their job when their zone reloads The F8 readout showed every miner with centre (0,0,0) and no target: Valheim destroys a creature when its zone unloads and builds a fresh one from the ZDO when it comes back, and the miner's centre, radius and lifetime were plain fields, so the rebuilt drone searched for ore around the world origin and stood still. They now live in the ZDO, the birth time in network time so a rebuilt drone does not get a fresh two minutes. A drone with no job in its ZDO digs around where it stands. The throw on cooldown returned without a word, which looked like copper refusing the cast. It now says how many seconds are left (English, Italian, Russian). --- JotunnModStub/Alfar/AlfarDrones.cs | 59 +++++++++++++++++-- JotunnModStub/Alfar/AlfarMiners.cs | 13 ++-- .../Translations/English/messages.json | 1 + .../Translations/Italian/messages.json | 1 + .../Translations/Russian/messages.json | 1 + 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/JotunnModStub/Alfar/AlfarDrones.cs b/JotunnModStub/Alfar/AlfarDrones.cs index f3bb69f..95f1eea 100644 --- a/JotunnModStub/Alfar/AlfarDrones.cs +++ b/JotunnModStub/Alfar/AlfarDrones.cs @@ -255,9 +255,19 @@ namespace RacesOfValheim public float Radius = 12f; public float LiveSeconds = 120f; + // The job lives in the drone's ZDO, not only in these fields: Valheim destroys a creature + // when its zone unloads and builds a fresh one when the zone comes back, and the fresh + // one had a zero Centre, so it searched around the world origin and stood idle. The + // birth time is network time, so a rebuilt drone does not get a new two minutes either. + private static readonly int CentreKey = "rov_graf_centre".GetStableHashCode(); + private static readonly int RadiusKey = "rov_graf_radius".GetStableHashCode(); + private static readonly int LifeKey = "rov_graf_life".GetStableHashCode(); + private static readonly int BornKey = "rov_graf_born".GetStableHashCode(); + private const float Reach = 4f; - private float born; + private bool loaded; + private double bornAt; private float nextStrike; private Component target; private float lastDistance = -1f; @@ -271,14 +281,53 @@ namespace RacesOfValheim private static readonly System.Reflection.MethodInfo MoveToMethod = AccessTools.Method(typeof(BaseAI), "MoveTo", new[] { typeof(float), typeof(Vector3), typeof(float), typeof(bool) }); - private void Start() + private static double Now => ZNet.instance != null ? ZNet.instance.GetTimeSeconds() : Time.time; + + /// Called by the throw right after the drone is made: the job, into the ZDO. + public void Assign(Vector3 centre, float radius, float liveSeconds) { - born = Time.time; + Centre = centre; + Radius = radius; + LiveSeconds = liveSeconds; + bornAt = Now; + loaded = true; + + ZNetView nview = GetComponent(); + if (nview == null || !nview.IsValid()) return; + ZDO zdo = nview.GetZDO(); + zdo.Set(CentreKey, centre); + zdo.Set(RadiusKey, radius); + zdo.Set(LifeKey, liveSeconds); + zdo.Set(BornKey, (long)(bornAt * 1000.0)); + } + + /// + /// A drone rebuilt from its ZDO reads its job back. One with no job at all (thrown by an + /// older build) digs around where it stands, which is where it was thrown. + /// + private void Load() + { + loaded = true; + ZNetView nview = GetComponent(); + ZDO zdo = nview != null && nview.IsValid() ? nview.GetZDO() : null; + long born = zdo != null ? zdo.GetLong(BornKey, 0L) : 0L; + if (born == 0L) + { + Centre = transform.position; + bornAt = Now; + return; + } + Centre = zdo.GetVec3(CentreKey, transform.position); + Radius = zdo.GetFloat(RadiusKey, Radius); + LiveSeconds = zdo.GetFloat(LifeKey, LiveSeconds); + bornAt = born / 1000.0; } public bool Tick(MonsterAI ai, float dt) { - if (Time.time - born >= LiveSeconds) + if (!loaded) Load(); + + if (Now - bornAt >= LiveSeconds) { ZNetView nview = GetComponent(); if (nview != null && nview.IsValid() && nview.IsOwner()) ZNetScene.instance.Destroy(gameObject); @@ -430,7 +479,7 @@ namespace RacesOfValheim string targetName = miner.target != null ? Utils.GetPrefabName(miner.target.gameObject) : "none"; lines.Add($"[RoV graf] miner {Vector3.Distance(miner.transform.position, player.transform.position):0}m away: " + $"target {targetName} dist {miner.lastDistance:0.0} strikes {miner.strikes} " + - $"age {Time.time - miner.born:0}s centre {miner.Centre} r {miner.Radius:0}"); + $"age {Now - miner.bornAt:0}s centre {miner.Centre} r {miner.Radius:0}"); } foreach (string line in lines) diff --git a/JotunnModStub/Alfar/AlfarMiners.cs b/JotunnModStub/Alfar/AlfarMiners.cs index 59b3b22..b2c5a95 100644 --- a/JotunnModStub/Alfar/AlfarMiners.cs +++ b/JotunnModStub/Alfar/AlfarMiners.cs @@ -22,7 +22,11 @@ namespace RacesOfValheim public static void Throw(Player player) { - if (Time.time < readyAt) return; + if (Time.time < readyAt) + { + player.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_alfar_graf_cooldown", Mathf.CeilToInt(readyAt - Time.time))); + return; + } Transform aim = GameCamera.instance != null ? GameCamera.instance.transform : player.transform; Vector3 origin = aim.position; @@ -76,12 +80,7 @@ namespace RacesOfValheim GameObject spawned = Object.Instantiate(prefab, where, Quaternion.identity); AlfarMiner miner = spawned.GetComponent(); - if (miner != null) - { - miner.Centre = point; - miner.Radius = AlfarPowerConfig.GrafRadius.Value; - miner.LiveSeconds = AlfarPowerConfig.GrafSeconds.Value; - } + if (miner != null) miner.Assign(point, AlfarPowerConfig.GrafRadius.Value, AlfarPowerConfig.GrafSeconds.Value); // Tame at once so nothing flees them and they flee nothing; no anchor, no leash. MonsterAI ai = spawned.GetComponent(); diff --git a/JotunnModStub/Translations/English/messages.json b/JotunnModStub/Translations/English/messages.json index c6c484c..71c441c 100644 --- a/JotunnModStub/Translations/English/messages.json +++ b/JotunnModStub/Translations/English/messages.json @@ -227,6 +227,7 @@ "rov_msg_alfar_nexus_built": "Made: $1", "rov_msg_alfar_nexus_no_crystals": "The core holds no crystals yet.", "rov_msg_alfar_nexus_collected": "Crystals taken: $1", + "rov_msg_alfar_graf_cooldown": "The drones are not ready yet ($1s).", "rov_msg_alfar_graf_materials": "The drones need $1 stone and $2 flint.", "rov_msg_thrall_refusal_alfar": "The construct does not know your light.", "rov_msg_thrall_refusal_alfar_drone": "The drone takes no orders. It works." diff --git a/JotunnModStub/Translations/Italian/messages.json b/JotunnModStub/Translations/Italian/messages.json index 5b18030..7d442d9 100644 --- a/JotunnModStub/Translations/Italian/messages.json +++ b/JotunnModStub/Translations/Italian/messages.json @@ -227,6 +227,7 @@ "rov_msg_alfar_nexus_built": "Fatto: $1", "rov_msg_alfar_nexus_no_crystals": "Il nucleo non ha ancora cristalli.", "rov_msg_alfar_nexus_collected": "Cristalli presi: $1", + "rov_msg_alfar_graf_cooldown": "I droni non sono ancora pronti ($1s).", "rov_msg_alfar_graf_materials": "I droni vogliono $1 pietra e $2 selce.", "rov_msg_thrall_refusal_alfar": "Il costrutto non conosce la tua luce.", "rov_msg_thrall_refusal_alfar_drone": "Il drone non prende ordini. Lavora." diff --git a/JotunnModStub/Translations/Russian/messages.json b/JotunnModStub/Translations/Russian/messages.json index 433b7c6..bd2023f 100644 --- a/JotunnModStub/Translations/Russian/messages.json +++ b/JotunnModStub/Translations/Russian/messages.json @@ -227,6 +227,7 @@ "rov_msg_alfar_nexus_built": "Создано: $1", "rov_msg_alfar_nexus_no_crystals": "В ядре пока нет кристаллов.", "rov_msg_alfar_nexus_collected": "Взято кристаллов: $1", + "rov_msg_alfar_graf_cooldown": "Дроны еще не готовы ($1 с).", "rov_msg_alfar_graf_materials": "Дронам нужно $1 камня и $2 кремня.", "rov_msg_thrall_refusal_alfar": "Конструкт не знает вашего света.", "rov_msg_thrall_refusal_alfar_drone": "Дрон не слушает приказов. Он работает." From 1420db796b4cc2c99712c258c142ccd537ef17e3 Mon Sep 17 00:00:00 2001 From: kanym Date: Thu, 29 Oct 2026 20:37:31 +0100 Subject: [PATCH 2/5] chore: F8 shows what each Grafvaettir hit did on arrival Patches on Destructible.RPC_Damage, MineRock.RPC_Hit and MineRock5.DamageArea record, for hits from a miner, the health before and after, the damage left after resistances, the pickaxe damage and the tool tier against the rock's minimum. 'sent, no RPC' means the hit never reached the deposit's owner. --- JotunnModStub/Alfar/AlfarDrones.cs | 75 +++++++++++++++++++++++++++++- 1 file changed, 73 insertions(+), 2 deletions(-) diff --git a/JotunnModStub/Alfar/AlfarDrones.cs b/JotunnModStub/Alfar/AlfarDrones.cs index 95f1eea..5dbbb69 100644 --- a/JotunnModStub/Alfar/AlfarDrones.cs +++ b/JotunnModStub/Alfar/AlfarDrones.cs @@ -272,6 +272,7 @@ namespace RacesOfValheim private Component target; private float lastDistance = -1f; private int strikes; + private string lastHit = "none"; public static readonly List All = new List(); @@ -431,7 +432,7 @@ namespace RacesOfValheim private void Strike(Component deposit, Collider area, Vector3 point) { IDestructible destructible = deposit as IDestructible; - if (destructible == null) return; + if (destructible == null) { lastHit = $"{deposit.GetType().Name} is not IDestructible"; return; } HitData hit = new HitData(); hit.m_damage.m_pickaxe = AlfarNexusConfig.MinerDamage.Value; @@ -445,9 +446,79 @@ namespace RacesOfValheim // check: a hit with no attacker throws before the area can break. hit.SetAttacker(GetComponent()); + // Overwritten by the RPC patches below if the hit reaches the deposit's owner. + lastHit = "sent, no RPC"; destructible.Damage(hit); } + // ─── F8 diagnostics: what each hit did on arrival ────────────────────── + + private static AlfarMiner MinerOf(HitData hit) + { + Character attacker = hit != null ? hit.GetAttacker() : null; + return attacker != null ? attacker.GetComponent() : null; + } + + private static void Record(HitData hit, string kind, float before, float after, int minTier) + { + AlfarMiner miner = MinerOf(hit); + if (miner == null) return; + miner.lastHit = $"{kind} hp {before:0.#}->{after:0.#} dmg {hit.GetTotalDamage():0.#} " + + $"pick {hit.m_damage.m_pickaxe:0.#} tier {hit.m_toolTier}/{minTier}"; + } + + [HarmonyPatch(typeof(Destructible), "RPC_Damage")] + public static class Alfar_Miner_DestructibleHit_Patch + { + private static float Health(Destructible d) + { + ZNetView nview = d.GetComponent(); + return nview != null && nview.IsValid() ? nview.GetZDO().GetFloat(ZDOVars.s_health, d.m_health) : -1f; + } + + public static void Prefix(Destructible __instance, HitData hit, out float __state) + { + __state = MinerOf(hit) != null ? Health(__instance) : -1f; + } + + public static void Postfix(Destructible __instance, HitData hit, float __state) + { + if (MinerOf(hit) == null) return; + Record(hit, "Destructible", __state, Health(__instance), __instance.m_minToolTier); + } + } + + [HarmonyPatch(typeof(MineRock), "RPC_Hit")] + public static class Alfar_Miner_MineRockHit_Patch + { + private static float Health(MineRock rock, int area) + { + ZNetView nview = rock.GetComponent(); + return nview != null && nview.IsValid() ? nview.GetZDO().GetFloat("Health" + area, rock.GetHealth()) : -1f; + } + + public static void Prefix(MineRock __instance, HitData hit, int hitAreaIndex, out float __state) + { + __state = MinerOf(hit) != null ? Health(__instance, hitAreaIndex) : -1f; + } + + public static void Postfix(MineRock __instance, HitData hit, int hitAreaIndex, float __state) + { + if (MinerOf(hit) == null) return; + Record(hit, $"MineRock area {hitAreaIndex}", __state, Health(__instance, hitAreaIndex), __instance.m_minToolTier); + } + } + + [HarmonyPatch(typeof(MineRock5), "DamageArea")] + public static class Alfar_Miner_MineRock5Hit_Patch + { + public static void Postfix(MineRock5 __instance, int hitAreaIndex, HitData hit, bool __result) + { + if (MinerOf(hit) == null) return; + Record(hit, $"MineRock5 area {hitAreaIndex} damaged={__result}", -1f, -1f, __instance.m_minToolTier); + } + } + private static Component DepositOf(Collider collider) { Component deposit = collider.GetComponentInParent(); @@ -479,7 +550,7 @@ namespace RacesOfValheim string targetName = miner.target != null ? Utils.GetPrefabName(miner.target.gameObject) : "none"; lines.Add($"[RoV graf] miner {Vector3.Distance(miner.transform.position, player.transform.position):0}m away: " + $"target {targetName} dist {miner.lastDistance:0.0} strikes {miner.strikes} " + - $"age {Now - miner.bornAt:0}s centre {miner.Centre} r {miner.Radius:0}"); + $"age {Now - miner.bornAt:0}s centre {miner.Centre} r {miner.Radius:0} | last hit: {miner.lastHit}"); } foreach (string line in lines) From dc24cbbacd4433e24efecb001f2c5d458dda369f Mon Sep 17 00:00:00 2001 From: kanym Date: Thu, 29 Oct 2026 20:37:44 +0100 Subject: [PATCH 3/5] docs: v1.6.5 changelog carries the Grafvaettir job and cooldown fixes --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 79500a9..fdd0b24 100644 --- a/README.md +++ b/README.md @@ -481,7 +481,7 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ### v1.6.5 - **New - Free Bat Flight:** the bat flight from before v1.6.1 is back as a choice. Turn on `Aswid - Bat Form` → `Free Bat Flight` and the bat flies up to 50 m/s with Shift, costs no stamina and ignores your weight: Jump rises, Left Ctrl sinks. Handy for building tall. Each player picks their own. The server's `Bat Flight Rule` decides for everyone if the admin wants: PlayerChoice (the default), AlwaysStaminaFlight or AlwaysFreeFlight. A change counts from the next time you become a bat. Monsters still see, chase and hurt a free-flying bat. Thanks to MrBiffty for the idea. Not tested in game yet, multiplayer included. - **New - Fenrir senses:** every Fenrir form (Wolf, Ulv, Fenring, Cultist) now lights each untamed creature within 100 m with a green glow, the same senses the Aswid gets at Moder. The human shape does not have it. Set the radius under `Fenrir - Superhuman Senses`; the light itself follows the Aswid's `Marker Light` settings. Thanks to MrBiffty's friend for the idea. Not tested in game yet. -- **Fix - Grafvaettir drones, again:** the drones found the deposits after v1.6.4 but still did not break them. A flying creature in Valheim keeps a few metres above whatever is under it, rock tops included, so the drones hovered just out of reach. They now fly low and strike from closer. Editing `Mining Targets` now works without restarting the game. Thanks to snakey for the report. Not tested in game yet. +- **Fix - Grafvaettir drones, again:** the drones found the deposits after v1.6.4 but still did not break them. A flying creature in Valheim keeps a few metres above whatever is under it, rock tops included, so the drones hovered just out of reach. They now fly low and strike from closer. Drones also lost their job when you walked far enough for their area to unload: they came back with no target point and stood still. They now remember it, and their two minutes, when that happens. Throwing them again too early now tells you how long is left, instead of doing nothing. Editing `Mining Targets` now works without restarting the game. Thanks to snakey for the reports and the testing. ### v1.6.4 - **New - Skeleton helmets:** want to show off your helmet? Turn on `Skeleton - Visuals` → `Show Helmet` and the helmet you wear sits on the skull, moved and enlarged to fit it, hoods included. Off by default. Thanks to Jondar Korric, lexsonn and the other friends on Discord for the idea and the help. Each player picks their own, and other players see you the way you picked. From b870dc65b0e59856f017deb6f535f178df21b07e Mon Sep 17 00:00:00 2001 From: kanym Date: Thu, 29 Oct 2026 21:09:34 +0100 Subject: [PATCH 4/5] fix: Grafvaettir drones break copper and tin The F8 readout showed each hit entering Destructible.Damage with every gate open, this machine owning the deposit and ZRoutedRpc's id equal to the owner, and the RPC handler never running, with nothing in the log. When the drone's machine owns the deposit and the routed hit did not arrive, the drone now calls the deposit's own handler (Destructible.RPC_Damage, MineRock.RPC_Hit, MineRock5.RPC_Damage) directly: the same resistance, tier and break logic, without the routing. Why the local routing drops it is still open; a remote owner still gets the routed hit, untested. A broken copper vein (rock4_copper_frac) never matched Mining Targets: MineRock5 renames its own object to "___MineRock5 m_meshFilter" in Awake. Deposit names now come from the ZDO's prefab. Drones also drop a target another drone just broke instead of striking a dead view. F8 prints how far each drone's last hit got: Damage entered (and its gates), the RPC with health before and after, or the direct call. --- JotunnModStub/Alfar/AlfarDrones.cs | 147 +++++++++++++++++++++++++++-- 1 file changed, 140 insertions(+), 7 deletions(-) diff --git a/JotunnModStub/Alfar/AlfarDrones.cs b/JotunnModStub/Alfar/AlfarDrones.cs index 5dbbb69..669d0c0 100644 --- a/JotunnModStub/Alfar/AlfarDrones.cs +++ b/JotunnModStub/Alfar/AlfarDrones.cs @@ -335,7 +335,9 @@ namespace RacesOfValheim return true; } - if (target == null || !target.gameObject.activeInHierarchy) target = FindDeposit(); + // A deposit another drone just broke is still there until the end of the frame, with a + // dead network view: drop it and look again. + if (target == null || !target.gameObject.activeInHierarchy || !Live(target)) target = FindDeposit(); Vector3 point = Vector3.zero; Collider area = target != null ? NearestArea(target, out point) : null; if (area == null) { target = null; ai.StopMoving(); return true; } @@ -396,7 +398,8 @@ namespace RacesOfValheim Component deposit = DepositOf(collider); if (deposit == null) continue; - string prefabName = Utils.GetPrefabName(deposit.gameObject); + if (!Live(deposit)) continue; + string prefabName = DepositName(deposit); if (!IsPrecious(prefabName)) continue; float distance = Vector3.Distance(transform.position, deposit.transform.position); @@ -446,23 +449,131 @@ namespace RacesOfValheim // check: a hit with no attacker throws before the area can break. hit.SetAttacker(GetComponent()); - // Overwritten by the RPC patches below if the hit reaches the deposit's owner. - lastHit = "sent, no RPC"; - destructible.Damage(hit); + // Overwritten by the patches below at each step the hit gets through. Vanilla runs the + // RPC on this machine at once when we own the deposit, so `striking` is still set then. + lastHit = "Damage not entered"; + striking = this; + rpcRan = false; + try + { + destructible.Damage(hit); + + // The F8 readout showed the hit entering Damage with every gate open and this + // machine owning the deposit, and the RPC handler never running: the routed call + // left for the network instead of being handled here. When we own the deposit, + // call its own handler directly - the same resistance, tier and break logic, only + // without the routing. + if (!rpcRan && OwnsDeposit(deposit)) StrikeDirect(deposit, area, hit); + } + finally { striking = null; } + } + + private static bool rpcRan; + + private static readonly System.Reflection.MethodInfo DestructibleRpc = AccessTools.Method(typeof(Destructible), "RPC_Damage"); + private static readonly System.Reflection.MethodInfo MineRockRpc = AccessTools.Method(typeof(MineRock), "RPC_Hit"); + private static readonly System.Reflection.MethodInfo MineRockArea = AccessTools.Method(typeof(MineRock), "GetAreaIndex"); + private static readonly System.Reflection.MethodInfo MineRock5Rpc = AccessTools.Method(typeof(MineRock5), "RPC_Damage"); + private static readonly System.Reflection.MethodInfo MineRock5Area = AccessTools.Method(typeof(MineRock5), "GetAreaIndex"); + private static readonly System.Reflection.FieldInfo RpcIdField = AccessTools.Field(typeof(ZRoutedRpc), "m_id"); + + private static bool OwnsDeposit(Component deposit) + { + ZNetView nview = deposit.GetComponent(); + return nview != null && nview.IsValid() && nview.IsOwner(); + } + + private void StrikeDirect(Component deposit, Collider area, HitData hit) + { + long sender = ZDOMan.GetSessionID(); + string entry = lastHit; + try + { + if (deposit is Destructible && DestructibleRpc != null) + { + DestructibleRpc.Invoke(deposit, new object[] { sender, hit }); + } + else if (deposit is MineRock && MineRockRpc != null && MineRockArea != null) + { + int index = (int)MineRockArea.Invoke(deposit, new object[] { area }); + if (index < 0) { lastHit = "direct: collider is not a MineRock area"; return; } + MineRockRpc.Invoke(deposit, new object[] { sender, hit, index }); + } + else if (deposit is MineRock5 && MineRock5Rpc != null && MineRock5Area != null) + { + int index = (int)MineRock5Area.Invoke(deposit, new object[] { area }); + if (index < 0) { lastHit = "direct: collider is not a MineRock5 area"; return; } + MineRock5Rpc.Invoke(deposit, new object[] { sender, hit, index }); + } + else + { + lastHit = $"direct: no handler for {deposit.GetType().Name}"; + return; + } + lastHit = $"direct, {lastHit} | before: {entry}"; + } + catch (System.Exception ex) + { + System.Exception inner = ex.InnerException ?? ex; + lastHit = $"direct failed: {inner.GetType().Name}: {inner.Message}"; + Jotunn.Logger.LogWarning($"[Alfar] Grafvaettir direct hit failed: {inner}"); + } } // ─── F8 diagnostics: what each hit did on arrival ────────────────────── + private static AlfarMiner striking; + private static AlfarMiner MinerOf(HitData hit) { + if (striking != null) return striking; Character attacker = hit != null ? hit.GetAttacker() : null; return attacker != null ? attacker.GetComponent() : null; } + private static readonly System.Reflection.FieldInfo FirstFrameField = AccessTools.Field(typeof(Destructible), "m_firstFrame"); + + /// The gates in front of the RPC: whose deposit it is and whether the view is live. + private static void RecordEntry(Component deposit, string extra) + { + if (striking == null) return; + ZNetView nview = deposit.GetComponent(); + bool valid = nview != null && nview.IsValid(); + long owner = valid ? nview.GetZDO().GetOwner() : -1L; + long me = ZDOMan.GetSessionID(); + Character attacker = striking.GetComponent(); + object rpcId = RpcIdField != null && ZRoutedRpc.instance != null ? RpcIdField.GetValue(ZRoutedRpc.instance) : null; + striking.lastHit = $"Damage entered{extra} valid={valid} owner={owner} session={me} rpcId={rpcId} " + + $"attackerZdo={(attacker != null ? attacker.GetZDOID().ToString() : "none")}, no RPC"; + } + + [HarmonyPatch(typeof(Destructible), nameof(Destructible.Damage))] + public static class Alfar_Miner_DestructibleEnter_Patch + { + public static void Prefix(Destructible __instance) + { + object first = FirstFrameField != null ? FirstFrameField.GetValue(__instance) : null; + RecordEntry(__instance, $" firstFrame={first}"); + } + } + + [HarmonyPatch(typeof(MineRock), nameof(MineRock.Damage))] + public static class Alfar_Miner_MineRockEnter_Patch + { + public static void Prefix(MineRock __instance) => RecordEntry(__instance, ""); + } + + [HarmonyPatch(typeof(MineRock5), nameof(MineRock5.Damage))] + public static class Alfar_Miner_MineRock5Enter_Patch + { + public static void Prefix(MineRock5 __instance) => RecordEntry(__instance, ""); + } + private static void Record(HitData hit, string kind, float before, float after, int minTier) { AlfarMiner miner = MinerOf(hit); if (miner == null) return; + if (miner == striking) rpcRan = true; miner.lastHit = $"{kind} hp {before:0.#}->{after:0.#} dmg {hit.GetTotalDamage():0.#} " + $"pick {hit.m_damage.m_pickaxe:0.#} tier {hit.m_toolTier}/{minTier}"; } @@ -519,6 +630,28 @@ namespace RacesOfValheim } } + private static bool Live(Component deposit) + { + ZNetView nview = deposit.GetComponent(); + return nview != null && nview.IsValid(); + } + + /// + /// The deposit's prefab name, read from its ZDO. Not from the GameObject: MineRock5 renames + /// its own object to "___MineRock5 m_meshFilter" in Awake, so a broken copper vein + /// (rock4_copper_frac) never matched the list and the drones stopped after the first blow. + /// + private static string DepositName(Component deposit) + { + ZNetView nview = deposit.GetComponent(); + if (nview != null && nview.IsValid() && ZNetScene.instance != null) + { + GameObject prefab = ZNetScene.instance.GetPrefab(nview.GetZDO().GetPrefab()); + if (prefab != null) return prefab.name; + } + return Utils.GetPrefabName(deposit.gameObject); + } + private static Component DepositOf(Collider collider) { Component deposit = collider.GetComponentInParent(); @@ -538,7 +671,7 @@ namespace RacesOfValheim if (Physics.Raycast(aim.position, aim.forward, out RaycastHit hit, 50f, ~0, QueryTriggerInteraction.Ignore)) { Component deposit = DepositOf(hit.collider); - string prefabName = deposit != null ? Utils.GetPrefabName(deposit.gameObject) : Utils.GetPrefabName(hit.collider.transform.root.gameObject); + string prefabName = deposit != null ? DepositName(deposit) : Utils.GetPrefabName(hit.collider.transform.root.gameObject); lines.Add($"[RoV graf] look: {hit.collider.name} on {prefabName} " + (deposit != null ? $"{deposit.GetType().Name} listed={IsPrecious(prefabName)}" : "not a deposit")); } @@ -547,7 +680,7 @@ namespace RacesOfValheim foreach (AlfarMiner miner in All) { if (miner == null) continue; - string targetName = miner.target != null ? Utils.GetPrefabName(miner.target.gameObject) : "none"; + string targetName = miner.target != null ? DepositName(miner.target) : "none"; lines.Add($"[RoV graf] miner {Vector3.Distance(miner.transform.position, player.transform.position):0}m away: " + $"target {targetName} dist {miner.lastDistance:0.0} strikes {miner.strikes} " + $"age {Now - miner.bornAt:0}s centre {miner.Centre} r {miner.Radius:0} | last hit: {miner.lastHit}"); From 16cacde532d94868ccfdb9ec7b36b9a2bec1a5a6 Mon Sep 17 00:00:00 2001 From: kanym Date: Thu, 29 Oct 2026 21:09:46 +0100 Subject: [PATCH 5/5] docs: v1.6.5 changelog, the Grafvaettir drones dig copper and tin --- README.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index fdd0b24..08e30bd 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ Support the mod: [Patreon — NandorTheModder](https://www.patreon.com/c/NandorT ## New in v1.6.5 -**The old bat flight is back, and the wolves smell their prey.** Aswid players can pick Free Flight, the fast bat flight with no stamina cost, and a server can pick for everyone. Every Fenrir form now lights nearby creatures green, as the Aswid does. The Grafvaettir's drones should finally reach the ore. Full details in the [changelog](#v165). +**The old bat flight is back, and the wolves smell their prey.** Aswid players can pick Free Flight, the fast bat flight with no stamina cost, and a server can pick for everyone. Every Fenrir form now lights nearby creatures green, as the Aswid does. The Grafvaettir's drones finally dig copper and tin. Full details in the [changelog](#v165). --- @@ -481,7 +481,7 @@ Both halves have an off switch under `Factions` in Configuration Manager: **Fact ### v1.6.5 - **New - Free Bat Flight:** the bat flight from before v1.6.1 is back as a choice. Turn on `Aswid - Bat Form` → `Free Bat Flight` and the bat flies up to 50 m/s with Shift, costs no stamina and ignores your weight: Jump rises, Left Ctrl sinks. Handy for building tall. Each player picks their own. The server's `Bat Flight Rule` decides for everyone if the admin wants: PlayerChoice (the default), AlwaysStaminaFlight or AlwaysFreeFlight. A change counts from the next time you become a bat. Monsters still see, chase and hurt a free-flying bat. Thanks to MrBiffty for the idea. Not tested in game yet, multiplayer included. - **New - Fenrir senses:** every Fenrir form (Wolf, Ulv, Fenring, Cultist) now lights each untamed creature within 100 m with a green glow, the same senses the Aswid gets at Moder. The human shape does not have it. Set the radius under `Fenrir - Superhuman Senses`; the light itself follows the Aswid's `Marker Light` settings. Thanks to MrBiffty's friend for the idea. Not tested in game yet. -- **Fix - Grafvaettir drones, again:** the drones found the deposits after v1.6.4 but still did not break them. A flying creature in Valheim keeps a few metres above whatever is under it, rock tops included, so the drones hovered just out of reach. They now fly low and strike from closer. Drones also lost their job when you walked far enough for their area to unload: they came back with no target point and stood still. They now remember it, and their two minutes, when that happens. Throwing them again too early now tells you how long is left, instead of doing nothing. Editing `Mining Targets` now works without restarting the game. Thanks to snakey for the reports and the testing. +- **Fix - Grafvaettir drones, again:** the drones found the deposits after v1.6.4 but still did not break them. Several things were in the way: they hovered just out of reach (a flying creature keeps a few metres above whatever is under it, rock tops included), their blows never reached the rock, and a copper vein's broken pieces did not count as copper. They now fly low, their blows land, and they clear a whole copper vein, pieces included. Tested in single player on tin and copper; in multiplayer, throwing them at a vein another player's game is handling has not been tested yet. Drones also lost their job when you walked far enough for their area to unload: they came back with no target point and stood still. They now remember it, and their two minutes, when that happens. Throwing them again too early now tells you how long is left, instead of doing nothing. Editing `Mining Targets` now works without restarting the game. Thanks to snakey for the reports and the testing. ### v1.6.4 - **New - Skeleton helmets:** want to show off your helmet? Turn on `Skeleton - Visuals` → `Show Helmet` and the helmet you wear sits on the skull, moved and enlarged to fit it, hoods included. Off by default. Thanks to Jondar Korric, lexsonn and the other friends on Discord for the idea and the help. Each player picks their own, and other players see you the way you picked.