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).
This commit is contained in:
kanym 2026-10-29 20:04:28 +01:00
commit ecf6e1bedb
5 changed files with 63 additions and 12 deletions

View file

@ -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<AlfarMiner>();
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<MonsterAI>();