feat(skeleton): dark aura while Summon on Kill is on, archaic toggle messages
Beside the Raise the Dead icon, a faint near-black smoke now rises off the whole body while Summon on Kill is on: the Draugr's looping smoke, borrowed like the Draugh aura, emitted from a body-sized box in world space. The owner writes the switch to the ZDO, so other players see it. "Raise the Dead Icon" and "Raise the Dead Aura" under Skeleton - Visuals let each player keep either or both, for a community vote. The toggle now says "Thy dead shall rise again." / "Raising... nevermore.", in English, Italian and Russian.
This commit is contained in:
parent
53f6fb71a2
commit
98b1a1b5f3
7 changed files with 143 additions and 8 deletions
|
|
@ -434,6 +434,115 @@ 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 Draugr's own looping one, the same particle DraughVisuals.BuildAura
|
||||
/// borrows, 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
|
||||
{
|
||||
private static readonly Color Smoke = new Color(0.06f, 0.06f, 0.07f, 0.35f);
|
||||
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)
|
||||
{
|
||||
GameObject draugr = PrefabManager.Cache.GetPrefab<GameObject>("Draugr");
|
||||
ParticleSystem source = null;
|
||||
if (draugr != null)
|
||||
{
|
||||
foreach (ParticleSystem ps in draugr.GetComponentsInChildren<ParticleSystem>(true))
|
||||
{
|
||||
string name = ps.gameObject.name.ToLower();
|
||||
if (!ps.main.loop || name.Contains("flies") || name.Contains("drip") || name.Contains("drop") ||
|
||||
name.Contains("rain") || name.Contains("splash")) continue;
|
||||
source = ps;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (source == null)
|
||||
{
|
||||
if (!warned)
|
||||
{
|
||||
warned = true;
|
||||
Jotunn.Logger.LogWarning("[Skeleton] No looping smoke found on 'Draugr'; 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;
|
||||
|
||||
// The Draugr's tint over a particle's life would put its green 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 'Draugr/{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.
|
||||
///
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue