fix(skeleton): Summon on Kill was completely dead - fix the whole chain

Queen/Fader-tier Skeletons were supposed to raise a tamed ally from every
kill, but nothing ever spawned. Several independent bugs stacked up:

- Kill attribution failed whenever the death blow was a poison DOT tick
  (SE_Poison builds its own attacker-less HitData every second, and
  Character.ApplyDamage overwrites m_lastHit on every one of those ticks).
  Since PoisonAttacks bakes bonus poison onto every Skeleton hit from
  Bonemass on, this was the common case, not an edge case. Character_Damage_Patch
  now tracks recent player hits per ZDOID as a fallback (RecentSkeletonHits),
  the same pattern Aswid's own life-drain-kill check already uses.
- SummonPrefabName pointed at "Skeleton_friendly", which isn't a real
  prefab (confirmed against the live ZNetScene registry). Reuses the
  Bound Bone Pile's own SkeletonThrall_Melee instead - tamed, loot-stripped,
  forced-melee, and already proven to work.
- The rise VFX names ("vfx_skeleton_spawn", "vfx_bloodmagic_aoe") were
  guesses that never existed either; fx_summon_skeleton_spawn is the real
  one. Same fix applied to the pre-existing Auto-Resurrect effect, which
  had the identical wrong names.
- The actual "climbing out of the ground" motion is a separate Animator
  bool ("wakeup") set via ZSyncAnimation - the exact call vanilla's own
  CreatureSpawner makes. Without it the model was simply active from
  frame one, VFX playing around a skeleton that was already standing.
- Vanilla skeletons carry no Tameable component, which spammed "is tamed
  but missing tameable or monster AI script!" every time a raised one
  landed a hit. Same fix Fenrir already uses for the Ulv and Fenring:
  copy one in from the vanilla Wolf, done once at prefab registration so
  it also quietly fixes the Bound Bone Pile's own thralls.
- Added RaisedThrall.SetExpiry(), a station-independent hard lifespan -
  these skeletons are never bound to a pile, so the existing anchor/wither
  pair had nothing to key off. Summoned skeletons now wither 2 minutes
  after being raised.

Also adds a permanent `listprefabs <substring>` debug console command -
queries the live ZNetScene registry directly, which is how the wrong
prefab/VFX names above were actually confirmed rather than guessed.
This commit is contained in:
kanym 2026-08-29 16:01:23 +02:00
commit 8c24ae3340
5 changed files with 232 additions and 12 deletions

View file

@ -32,6 +32,12 @@ namespace RacesOfValheim
public const string KeyAnchor = "RoV_draughAnchor";
public const string KeyOrphanAt = "RoV_draughOrphanAt";
// A hard, station-independent lifespan - unlike the wither above, which only starts once
// an anchor's station is gone. Nothing sets this by default; a thrall raised at a real
// pile never expires on its own. SummonOnKill uses it because its skeletons are never
// bound to a pile in the first place, so the anchor/wither pair has nothing to key off.
public const string KeyExpiresAt = "RoV_thrallExpiresAt";
// ─── Set on the prefab at registration ───────────────────────────────
/// <summary>Groups thralls for follower caps and for a station's per-kind roster.</summary>
@ -151,6 +157,10 @@ namespace RacesOfValheim
if (m_nview == null || !m_nview.IsValid() || !m_nview.IsOwner()) return;
if (m_character == null || m_character.IsDead()) return;
// A hard cap, checked before anything anchor-based - it has to fire regardless of
// where this thrall is standing or whether it is following, unlike the wither below.
if (TickExpiry()) return;
// Checked before anything else, and NOT skipped while following: a thrall out with its
// master still has to wither if the station behind it has fallen.
if (TickWither()) return;
@ -161,6 +171,25 @@ namespace RacesOfValheim
GoHome();
}
/// <summary>Sets a hard lifespan from now, independent of any station anchor. Overwrites
/// any expiry already set.</summary>
public void SetExpiry(float seconds)
{
if (m_nview == null || !m_nview.IsValid() || ZNet.instance == null) return;
m_nview.GetZDO().Set(KeyExpiresAt, (ZNet.instance.GetTime() + TimeSpan.FromSeconds(seconds)).Ticks);
}
/// <summary>True once it has killed this one for running out the clock set by SetExpiry.
/// A no-op for any thrall that never had one set (the ZDO key stays at its default 0).</summary>
private bool TickExpiry()
{
long expiresAt = m_nview.GetZDO().GetLong(KeyExpiresAt, 0L);
if (expiresAt == 0L || ZNet.instance.GetTime() < new DateTime(expiresAt)) return false;
Kill();
return true;
}
/// <summary>Starts the clock when the station is gone, and stops the thrall when it runs out.
/// Returns true once it has killed this one, so the caller stops bothering with it.</summary>
private bool TickWither()