diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs index 78b1cf2..10fdf7d 100644 --- a/JotunnModStub/Skeleton/SkeletonPatches.cs +++ b/JotunnModStub/Skeleton/SkeletonPatches.cs @@ -283,6 +283,14 @@ namespace RacesOfValheim if (skeletonBodyTransform == null) { GameObject skelPrefab = PrefabManager.Cache.GetPrefab(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 diff --git a/JotunnModStub/Skeleton/SkeletonRace.cs b/JotunnModStub/Skeleton/SkeletonRace.cs index 90311d6..3f0a3cb 100644 --- a/JotunnModStub/Skeleton/SkeletonRace.cs +++ b/JotunnModStub/Skeleton/SkeletonRace.cs @@ -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("vfx_smoke") ?? - PrefabManager.Cache.GetPrefab("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(); - if (pss.Length > 0) - { - ParticleSystem ps = fireAuraVFX.AddComponent(); - 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(); - renderer.material = pss[0].GetComponent().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; diff --git a/JotunnModStub/Skeleton/SkeletonVisuals.cs b/JotunnModStub/Skeleton/SkeletonVisuals.cs index 825b64a..5f82dbc 100644 --- a/JotunnModStub/Skeleton/SkeletonVisuals.cs +++ b/JotunnModStub/Skeleton/SkeletonVisuals.cs @@ -169,6 +169,49 @@ namespace RacesOfValheim (passengers.Count == 0 ? "." : ", stripped " + string.Join(", ", passengers.ToArray()) + ".")); } + /// + /// 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. + /// + private static readonly HashSet loggedResolutions = new HashSet(); + + 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(true); + ParticleSystemRenderer psr = first != null ? first.GetComponent() : 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; } + /// + /// 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<GameObject>("vfx_smoke") + /// ?? PrefabManager.Cache.GetPrefab<GameObject>("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. + /// + 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; + } + /// /// One player's burning skull. Cosmetic only - it deals nothing and blocks nothing. /// diff --git a/JotunnModStub/ZdoVisualSync.cs b/JotunnModStub/ZdoVisualSync.cs index ecff680..686a831 100644 --- a/JotunnModStub/ZdoVisualSync.cs +++ b/JotunnModStub/ZdoVisualSync.cs @@ -173,8 +173,9 @@ namespace RacesOfValheim m_player.transform.localScale = targetScale; } - // Fire Aura VFX - EnsureFireAuraVFX(rules.FireAura); + // Deliberately draws nothing - see SkeletonVisuals.EnsureFireAura for why. Called + // anyway so reinstating the visual needs no change here. + SkeletonVisuals.EnsureFireAura(m_player, rules.FireAura, ref m_fireAuraVFX); } private void UpdateFenrirVisuals() @@ -263,7 +264,7 @@ namespace RacesOfValheim PlayerVisualHider.Show(playerVisual, "zdosync-revert"); if (m_currentFormInstance != null) Destroy(m_currentFormInstance); - EnsureFireAuraVFX(false); + SkeletonVisuals.EnsureFireAura(m_player, false, ref m_fireAuraVFX); DraughVisuals.EnsureAura(m_player, false, ref m_draughAuraVFX); m_skeletonHeadFlame.Apply(m_player, false); // Takes the crown off a Trenta who has died or changed race; a no-op for everyone else. @@ -283,70 +284,5 @@ namespace RacesOfValheim m_lastFenrirForm = ""; m_lastSkadiForm = ""; } - - private void EnsureFireAuraVFX(bool enable) - { - if (enable) - { - if (m_fireAuraVFX == null) - { - GameObject sourceVFX = Jotunn.Managers.PrefabManager.Cache.GetPrefab("vfx_smoke") ?? - Jotunn.Managers.PrefabManager.Cache.GetPrefab("vfx_surtling_death"); - - m_fireAuraVFX = new GameObject("SkeletonFireAuraVFX"); - m_fireAuraVFX.transform.SetParent(m_player.transform, false); - m_fireAuraVFX.transform.localPosition = new Vector3(0, 1f, 0); - - if (sourceVFX != null) - { - ParticleSystem[] pss = sourceVFX.GetComponentsInChildren(); - if (pss.Length > 0) - { - ParticleSystem ps = m_fireAuraVFX.AddComponent(); - 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 = m_fireAuraVFX.GetComponent(); - renderer.material = pss[0].GetComponent().material; - - var shape = ps.shape; - shape.shapeType = ParticleSystemShapeType.Sphere; - shape.radius = 4.5f; - - var emission = ps.emission; - emission.rateOverTime = 40f; - - 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), - new GradientColorKey(new Color(1f, 0.3f, 0.0f), 0.5f), - new GradientColorKey(new Color(0.2f, 0.0f, 0.0f), 1.0f) - }, - 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 (!m_fireAuraVFX.activeSelf) m_fireAuraVFX.SetActive(true); - } - else - { - if (m_fireAuraVFX != null && m_fireAuraVFX.activeSelf) m_fireAuraVFX.SetActive(false); - } - } } }