revert(skeleton): drop the Summon on Kill aura, keep the icon

Neither the Draugr's evil_smoke nor the torch smoke showed in game once
tinted dark. The Raise the Dead icon stays, with its per-player switch.
This commit is contained in:
kanym 2026-10-24 15:50:05 +02:00
commit e41f7b610e
4 changed files with 1 additions and 134 deletions

View file

@ -434,117 +434,6 @@ namespace RacesOfValheim
aura = null;
}
/// <summary>The owner's Summon on Kill switch, for every other client to read.</summary>
public const string RaisingZdoKey = "RacesOfValheim_SkeletonRaising";
/// <summary>
/// A faint dark smoke rising off the whole body while Summon on Kill is on: the other half
/// of the indicator, beside the Raise the Dead icon, so the community can pick either or
/// both. Cosmetic only.
///
/// The smoke is the torch's own (see Build for why not the Draugr's), cloned through
/// BorrowEffect and tinted near-black. It emits from a box the
/// size of the body rather than from one point, so it comes off the arms and legs too.
/// A mesh-shaped emitter would hug the body closer, but only works on a readable mesh.
///
/// Held per player, like HeadFlame. Call Apply every frame; it builds once.
/// </summary>
public class RaisingAura
{
// The torch smoke is (0.35, 0.35, 0.35, 0.21); darker and a little thicker than that.
private static readonly Color Smoke = new Color(0.08f, 0.08f, 0.09f, 0.45f);
private static readonly Vector3 BodyBox = new Vector3(0.55f, 1.7f, 0.35f);
private const float BodyCentre = 0.95f;
private GameObject m_instance;
public void Apply(Player player, bool enable)
{
if (!enable || player == null)
{
if (m_instance != null && m_instance.activeSelf) m_instance.SetActive(false);
return;
}
if (m_instance == null && !Build(player)) return;
if (!m_instance.activeSelf) m_instance.SetActive(true);
}
private static bool warned;
private bool Build(Player player)
{
// The torch's own 'Smoke', from the same prefab the head flame burns from. The
// Draugr's evil_smoke was tried first: its material is on 'Lux Lit Particles/
// Bumped', which takes its look from the material and the scene light, so a dark
// tint on it showed nothing in game. The torch smoke is the grey everyone sees
// above a torch, so darkening it has something to darken.
GameObject torch = ResolveFlameSource();
ParticleSystem source = null;
if (torch != null)
{
foreach (ParticleSystem ps in torch.GetComponentsInChildren<ParticleSystem>(true))
{
if (ps.gameObject.name.ToLower().Contains("smoke")) { source = ps; break; }
}
}
if (source == null)
{
if (!warned)
{
warned = true;
Jotunn.Logger.LogWarning("[Skeleton] No 'Smoke' particle on the torch; the Summon on Kill aura stays off.");
}
return false;
}
m_instance = BorrowEffect(source.gameObject, player.transform, "SkeletonRaisingAura", false, "Skeleton");
if (m_instance == null) return false;
m_instance.transform.localPosition = new Vector3(0f, BodyCentre, 0f);
m_instance.transform.localRotation = Quaternion.identity;
m_instance.transform.localScale = Vector3.one;
foreach (ParticleSystem ps in m_instance.GetComponentsInChildren<ParticleSystem>(true))
{
ParticleSystem.MainModule main = ps.main;
main.startColor = new ParticleSystem.MinMaxGradient(Smoke);
// World space, so the smoke stays behind as the body moves, like a trail.
main.simulationSpace = ParticleSystemSimulationSpace.World;
main.scalingMode = ParticleSystemScalingMode.Hierarchy;
ParticleSystem.ShapeModule shape = ps.shape;
shape.enabled = true;
shape.shapeType = ParticleSystemShapeType.Box;
shape.scale = BodyBox;
shape.position = Vector3.zero;
shape.rotation = Vector3.zero;
// A tint over the particle's life would put the source's own colour back; keep
// the fade (alpha) and drop the colour.
ParticleSystem.ColorOverLifetimeModule col = ps.colorOverLifetime;
if (col.enabled)
{
Gradient faded = new Gradient();
faded.SetKeys(new[] { new GradientColorKey(Color.white, 0f), new GradientColorKey(Color.white, 1f) },
col.color.gradient != null ? col.color.gradient.alphaKeys
: new[] { new GradientAlphaKey(1f, 0f), new GradientAlphaKey(0f, 1f) });
col.color = new ParticleSystem.MinMaxGradient(faded);
}
}
// The shader decides whether a dark tint can show at all: an additive one adds
// nothing for black. If the aura is invisible in game, this line says why.
Renderer smokeRenderer = m_instance.GetComponentInChildren<Renderer>(true);
Material smokeMaterial = smokeRenderer != null ? smokeRenderer.sharedMaterial : null;
Jotunn.Logger.LogInfo($"[Skeleton] Summon on Kill aura built from '{torch.name}/{source.gameObject.name}', " +
$"material '{(smokeMaterial != null ? smokeMaterial.name : "none")}', " +
$"shader '{(smokeMaterial != null && smokeMaterial.shader != null ? smokeMaterial.shader.name : "none")}'.");
return true;
}
}
/// <summary>
/// One player's burning skull. Cosmetic only - it deals nothing and blocks nothing.
///