fix(skeleton): stop the fire aura borrowing another mod's VFX by name

The tier-5 fire aura looked for "vfx_smoke", then "vfx_surtling_death".
Neither name exists in Valheim, checked against the game's own asset
manifests, so both lookups came back null and the aura has never been
visible in a plain install.

The dead branch was not harmless. PrefabManager.Cache resolves by asset
name across everything in memory, other mods' asset bundles included, and
its tie-break for a duplicate name ends in "newest wins". A name vanilla
does not use has no vanilla candidate to beat, so it is a free slot.

Magic_Supremacy fills it. The lookup resolved to
'EncounterCreatureRikoMountain_DO/vfx_smoke', a child node of one of its
creatures carrying 'club_trail_riko_DO' on 'Dreanegade/ParticleAlphaEmission'
- a weapon trail, on an emissive shader, sprayed through a 4.5m sphere on
the player. That is the purple smoke around the burning skull users
reported, on every client that could see the skeleton.

The aura now draws nothing on purpose, which costs it nothing it had. Its
damage, radius and tick are untouched. The two identical EnsureFireAuraVFX
copies in SkeletonRace and ZdoVisualSync are replaced by one
SkeletonVisuals.EnsureFireAura, shaped like DraughVisuals.EnsureAura; the
call sites stay, so reinstating the visual needs no change in either file.
The comment on it records the whole chain and the way to build it properly,
through BorrowEffect, the way HeadFlame already does.

Also keeps a resolution log on the model lookup: every magic mod in the
report ships an object called "Skeleton", which is this race's own tier-0
model name. The vanilla creature won during the repro; root=False in that
log is what says it stopped winning.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
kanym 2026-09-25 15:54:21 +02:00
commit 00d4fd6e46
4 changed files with 102 additions and 144 deletions

View file

@ -283,6 +283,14 @@ namespace RacesOfValheim
if (skeletonBodyTransform == null)
{
GameObject skelPrefab = PrefabManager.Cache.GetPrefab<GameObject>(rules.ModelPrefab);
// The cache answers by name alone, and every magic mod named in the
// purple-smoke report carries an object of its own called "Skeleton" -
// which is this race's own tier-0 model name. So far the vanilla
// creature has always won; the log is here to say so, or to say which
// mod's object took its place. See SkeletonVisuals.EnsureFireAura.
SkeletonVisuals.LogResolvedPrefabOnce("model " + rules.ModelPrefab, skelPrefab);
if (skelPrefab == null)
{
// The human body was switched off two lines up, so an unresolved

View file

@ -279,7 +279,7 @@ namespace RacesOfValheim
// only path taken once they stop being one. A Fader-tier Skeleton who reset to
// Human kept a burning skull and a collapsed jaw, since neither the flame nor the
// jaw was ever switched back from outside the Skeleton branch below.
EnsureFireAuraVFX(false);
SkeletonVisuals.EnsureFireAura(Player.m_localPlayer, false, ref fireAuraVFX);
headFlame.Apply(Player.m_localPlayer, false);
RestoreJawBone();
@ -446,7 +446,7 @@ namespace RacesOfValheim
if (rules.FireAura)
{
EnsureFireAuraVFX(true);
SkeletonVisuals.EnsureFireAura(Player.m_localPlayer, true, ref fireAuraVFX);
if (Time.time - lastAuraTime >= SkeletonConfig.FireAuraTickInterval.Value)
{
ApplyFireAura();
@ -455,7 +455,7 @@ namespace RacesOfValheim
}
else
{
EnsureFireAuraVFX(false);
SkeletonVisuals.EnsureFireAura(Player.m_localPlayer, false, ref fireAuraVFX);
}
}
@ -478,79 +478,6 @@ namespace RacesOfValheim
}
}
private void EnsureFireAuraVFX(bool enable)
{
if (enable && Player.m_localPlayer != null)
{
if (fireAuraVFX == null)
{
// Look for a smoke or fog effect to tint as fire fog
GameObject sourceVFX = PrefabManager.Cache.GetPrefab<GameObject>("vfx_smoke") ??
PrefabManager.Cache.GetPrefab<GameObject>("vfx_surtling_death");
fireAuraVFX = new GameObject("SkeletonFireAuraVFX");
fireAuraVFX.transform.SetParent(Player.m_localPlayer.transform, false);
fireAuraVFX.transform.localPosition = new Vector3(0, 1f, 0);
if (sourceVFX != null)
{
ParticleSystem[] pss = sourceVFX.GetComponentsInChildren<ParticleSystem>();
if (pss.Length > 0)
{
ParticleSystem ps = fireAuraVFX.AddComponent<ParticleSystem>();
var main = ps.main;
main.loop = true;
main.duration = 1f;
main.startLifetime = 1.5f;
main.startSize = new ParticleSystem.MinMaxCurve(1.5f, 3f);
main.startSpeed = 0f;
main.simulationSpace = ParticleSystemSimulationSpace.World;
var renderer = fireAuraVFX.GetComponent<ParticleSystemRenderer>();
renderer.material = pss[0].GetComponent<ParticleSystemRenderer>().material;
var shape = ps.shape;
shape.shapeType = ParticleSystemShapeType.Sphere;
shape.radius = 4.5f; // Similar to the damage radius
var emission = ps.emission;
emission.rateOverTime = 40f;
// Add a fire-like color gradient
var colorOverLifetime = ps.colorOverLifetime;
colorOverLifetime.enabled = true;
Gradient grad = new Gradient();
grad.SetKeys(
new GradientColorKey[] {
new GradientColorKey(new Color(1f, 0.8f, 0.2f), 0.0f), // Yellow
new GradientColorKey(new Color(1f, 0.3f, 0.0f), 0.5f), // Orange/Red
new GradientColorKey(new Color(0.2f, 0.0f, 0.0f), 1.0f) // Dark red/smoke
},
new GradientAlphaKey[] {
new GradientAlphaKey(0.0f, 0.0f),
new GradientAlphaKey(0.6f, 0.2f),
new GradientAlphaKey(0.6f, 0.8f),
new GradientAlphaKey(0.0f, 1.0f)
}
);
colorOverLifetime.color = grad;
}
}
}
if (!fireAuraVFX.activeSelf)
{
fireAuraVFX.SetActive(true);
}
}
else
{
if (fireAuraVFX != null && fireAuraVFX.activeSelf)
{
fireAuraVFX.SetActive(false);
}
}
}
private void ApplyFireAura()
{
if (Player.m_localPlayer == null) return;

View file

@ -169,6 +169,49 @@ namespace RacesOfValheim
(passengers.Count == 0 ? "." : ", stripped " + string.Join(", ", passengers.ToArray()) + "."));
}
/// <summary>
/// Says what a borrowed-by-name prefab actually resolved to: which object, where it sits in
/// ITS OWN hierarchy, and the material and shader the first particle on it carries. Once per
/// name per session, so it costs a handful of lines and answers the question that took a
/// bundle extractor to answer the first time.
///
/// READ THE root FLAG FIRST. A root-level object is a real prefab and almost certainly the
/// vanilla one. A parented one is a child node that Jotunn's cache picked up because nothing
/// better in memory answered to that name - which is what happens when the name does not
/// exist in vanilla at all, and is exactly how another mod's weapon trail ended up worn as
/// this race's fire aura. See EnsureFireAura.
/// </summary>
private static readonly HashSet<string> loggedResolutions = new HashSet<string>();
public static void LogResolvedPrefabOnce(string wanted, GameObject resolved)
{
if (!loggedResolutions.Add(wanted)) return;
if (resolved == null)
{
Jotunn.Logger.LogWarning($"[Skeleton] Prefab lookup '{wanted}' resolved to NOTHING.");
return;
}
string path = resolved.name;
for (Transform t = resolved.transform.parent; t != null; t = t.parent)
{
path = t.name + "/" + path;
}
ParticleSystem first = resolved.GetComponentInChildren<ParticleSystem>(true);
ParticleSystemRenderer psr = first != null ? first.GetComponent<ParticleSystemRenderer>() : null;
Material material = psr != null ? psr.sharedMaterial : null;
Jotunn.Logger.LogInfo(
$"[Skeleton] Prefab lookup '{wanted}' resolved to '{path}' " +
$"(root={resolved.transform.parent == null}) " +
$"particle='{(first != null ? first.name : "none")}' " +
$"material='{(material != null ? material.name : "none")}' " +
$"shader='{(material != null && material.shader != null ? material.shader.name : "none")}' " +
$"startColor={(first != null ? first.main.startColor.color.ToString() : "-")}");
}
private static GameObject cachedFlameSource;
private static bool flameSourceResolved;
@ -306,6 +349,50 @@ namespace RacesOfValheim
return copy;
}
/// <summary>
/// The fire aura's visual, and the reason it now has none.
///
/// The aura itself (SkeletonRace.ApplyFireAura) burns everything inside FireAuraRadius from
/// Moder on and is untouched. What is gone is the way it used to try to show itself:
///
/// PrefabManager.Cache.GetPrefab&lt;GameObject&gt;("vfx_smoke")
/// ?? PrefabManager.Cache.GetPrefab&lt;GameObject&gt;("vfx_surtling_death")
///
/// NEITHER NAME EXISTS IN VALHEIM. Checked against the game's own asset manifest: there is no
/// vfx_smoke, and no surtling death effect under any spelling. In a plain install both
/// lookups came back null, no particle system was ever added, and this aura has never been
/// visible to anybody since the day it was written.
///
/// A dead branch would be harmless if the lookup were harmless. It is not. PrefabManager.Cache
/// is, in Jotunn's own words, a "global cache of Unity Objects by asset name" built with
/// Resources.FindObjectsOfTypeAll, so it answers with anything in memory - including the
/// contents of every other mod's asset bundle - and its tie-break for a duplicate name ends
/// in "the newly discovered object replaces the cached one". A name vanilla does not use has
/// no vanilla candidate to beat, which leaves it a free slot for whoever ships one.
///
/// Somebody shipped one. With Magic_Supremacy installed the lookup resolved to
/// 'EncounterCreatureRikoMountain_DO/vfx_smoke' - a CHILD node of one of that mod's
/// creatures, carrying the material 'club_trail_riko_DO' on the shader
/// 'Dreanegade/ParticleAlphaEmission'. A weapon trail, on an emissive shader, sprayed through
/// a 4.5m sphere centred on the player: the purple smoke around the burning skull this race
/// was reported for, on every client that could see the skeleton.
///
/// So the aura is invisible deliberately now, which costs it nothing it ever had. To give it
/// a look, build it the way HeadFlame does: resolve a prefab under a name vanilla really uses
/// (ResolveFlameSource already holds one that works) and clone it through BorrowEffect,
/// instead of hand-rolling a particle system around a material taken by name.
/// </summary>
public static void EnsureFireAura(Player player, bool enable, ref GameObject aura)
{
// Nothing is built, so there is nothing to switch on either way - but a leftover is
// destroyed rather than left riding the player, which is what a session that swapped
// this assembly in mid-flight would otherwise be stuck with.
if (aura == null) return;
Object.Destroy(aura);
aura = null;
}
/// <summary>
/// One player's burning skull. Cosmetic only - it deals nothing and blocks nothing.
///