diff --git a/JotunnModStub/Aswid/AswidClaws.cs b/JotunnModStub/Aswid/AswidClaws.cs
new file mode 100644
index 0000000..2965613
--- /dev/null
+++ b/JotunnModStub/Aswid/AswidClaws.cs
@@ -0,0 +1,69 @@
+using UnityEngine;
+
+namespace RacesOfValheim
+{
+ ///
+ /// The Claws of the Beast: the Bjorn claw, burned down to almost black.
+ ///
+ /// Everything about how they behave - issued once, never dropped, back in hand the moment the
+ /// hands are free, tier damage as slash - lives in RaceClawSet. This file is only the Aswid's
+ /// half of the answer: which model, what colour, and when the race is wearing another body.
+ ///
+ /// The tint is config rather than a constant because "almost black" is a look, not a number,
+ /// and it needs one pass in front of a mirror. It is applied to the item's own copies of the
+ /// model's materials, so the vanilla weapon is untouched for everyone else.
+ ///
+ public class AswidClaws : RaceClawSet
+ {
+ public static readonly AswidClaws Instance = new AswidClaws();
+
+ public override string RaceId => "Aswid";
+ public override string ItemName => "AswidBeastClaws";
+ public override string DisplayName => "Claws of the Beast";
+ public override string Description => "Grown in the dark, and darker for it. They do not come off.";
+
+ // The Bjorn claw first, by name, because that is the one this race is meant to wear. The
+ // rest are the near-identical ids the manifest also carries - see SvermConfig's own
+ // fallback list for why a single name is not trusted here.
+ public override string[] ModelPrefabs => new[]
+ {
+ "FistBjornClaw",
+ "FistBjornUndeadClaw",
+ "FistBjornClawUndead",
+ "FistUnbjornClaw",
+ };
+
+ /// Published by AswidRace.UpdateAswidState, so a remote Aswid claws at its own tier.
+ public override string StateZdoKey => "RacesOfValheim_AswidState";
+
+ public override Color? Tint => new Color(
+ AswidConfig.ClawTintRed.Value,
+ AswidConfig.ClawTintGreen.Value,
+ AswidConfig.ClawTintBlue.Value,
+ 1f);
+
+ ///
+ /// A bat and a bank of mist have no hands. IsTransformed is the local player's own flag;
+ /// the two ZDO booleans are how AswidPatches already publishes the same thing for everyone
+ /// else, which is what makes this answer correctly for a remote attacker.
+ ///
+ public override bool IsTransformed(Player player)
+ {
+ if (player == null) return false;
+
+ if (player == Player.m_localPlayer && AswidRace.Instance != null && AswidRace.Instance.IsTransformed)
+ {
+ return true;
+ }
+
+ ZNetView nview = player.GetComponent();
+ if (nview != null && nview.IsValid())
+ {
+ return nview.GetZDO().GetBool("Aswid_IsBatForm", false) ||
+ nview.GetZDO().GetBool("Aswid_IsMistForm", false);
+ }
+
+ return false;
+ }
+ }
+}
diff --git a/JotunnModStub/Aswid/AswidConfig.cs b/JotunnModStub/Aswid/AswidConfig.cs
index a50f8c8..b195c9f 100644
--- a/JotunnModStub/Aswid/AswidConfig.cs
+++ b/JotunnModStub/Aswid/AswidConfig.cs
@@ -59,6 +59,41 @@ namespace RacesOfValheim
public static ConfigEntry EnslaveCooldown;
public static ConfigEntry ThrallLifetime;
+ // ─── Eyes ──────────────────────────────────────────────────────────────
+ // The Aswid wears the vanilla skeleton's eye lights (AswidVisuals), and where a borrowed
+ // object sits on a borrowed rig is not something to get right by reasoning about it. All
+ // of these read live, so they can be dragged in Configuration Manager while looking at the
+ // face. Once the pose settles they could collapse back into constants, the same way the
+ // mandible's did - but unlike the mandible these are worth keeping, because the source
+ // creature and the colour are genuine preferences.
+ public static ConfigEntry EyeSourceModel;
+ public static ConfigEntry EyeFinalStage;
+ public static ConfigEntry EarlyEyeColorRed;
+ public static ConfigEntry EarlyEyeColorGreen;
+ public static ConfigEntry EarlyEyeColorBlue;
+ public static ConfigEntry EarlyEyeGlowStrength;
+ public static ConfigEntry EyeColorRed;
+ public static ConfigEntry EyeColorGreen;
+ public static ConfigEntry EyeColorBlue;
+ public static ConfigEntry EyeGlowStrength;
+ public static ConfigEntry EyeSizeMultiplier;
+ public static ConfigEntry EyeForwardOffset;
+ public static ConfigEntry EyeHeightOffset;
+ public static ConfigEntry EyeSeparationOffset;
+ public static ConfigEntry EyeRotationX;
+ public static ConfigEntry EyeRotationY;
+ public static ConfigEntry EyeRotationZ;
+ public static ConfigEntry EyeSmoke;
+ public static ConfigEntry EyeFlatColorShader;
+
+ // ─── Claws of the Beast ────────────────────────────────────────────────
+ // The tint the Bjorn claw is worn at (AswidClaws). Config rather than a constant because
+ // "almost black" is a look and not a number, and it multiplies the model's own texture, so
+ // what a given value looks like depends on the model. Reads live.
+ public static ConfigEntry ClawTintRed;
+ public static ConfigEntry ClawTintGreen;
+ public static ConfigEntry ClawTintBlue;
+
public static void Bind(ConfigFile config)
{
const string keybinds = "Aswid - Keybinds";
@@ -128,6 +163,109 @@ namespace RacesOfValheim
new ConfigDescription("Seconds between dominating a creature, tier 6+.", new AcceptableValueRange(0f, 3600f)));
ThrallLifetime = config.Bind(domination, "Thrall Lifetime", 60f,
new ConfigDescription("Seconds a dominated thrall survives before it dies on its own.", new AcceptableValueRange(10f, 600f)));
+
+ BindEyes(config);
+ BindClaws(config);
+ }
+
+ ///
+ /// The Claws of the Beast. Only their colour is tunable: everything about how they behave
+ /// is shared with the Fenrir's and the Sverm's, and a race that could quietly retune its
+ /// own claw damage would defeat the point of balancing the three against one yardstick.
+ ///
+ private static void BindClaws(ConfigFile config)
+ {
+ const string claws = "Aswid - Claws";
+
+ ClawTintRed = config.Bind(claws, "Claw Tint Red", 0.12f,
+ new ConfigDescription("Multiplied into the claw model's own colours. All three near zero is what makes them read as almost black.",
+ new AcceptableValueRange(0f, 1f), new ConfigurationManagerAttributes { Order = 30 }));
+ ClawTintGreen = config.Bind(claws, "Claw Tint Green", 0.11f,
+ new ConfigDescription("As above, green channel.",
+ new AcceptableValueRange(0f, 1f), new ConfigurationManagerAttributes { Order = 29 }));
+ ClawTintBlue = config.Bind(claws, "Claw Tint Blue", 0.13f,
+ new ConfigDescription("As above, blue channel. A shade above the other two keeps the black cold rather than muddy.",
+ new AcceptableValueRange(0f, 1f), new ConfigurationManagerAttributes { Order = 28 }));
+ }
+
+ ///
+ /// The eye lights. Everything here is read every frame by AswidVisuals, so a slider moves
+ /// the eyes while you are looking at them - no relog, no equipment change.
+ ///
+ /// The offsets are deltas on the pose the source creature authored its own eyes at, which
+ /// is why they all default to zero: zero means "exactly where the game's skeleton wears
+ /// them", and that is already the right place for a face on this rig.
+ ///
+ private static void BindEyes(ConfigFile config)
+ {
+ const string eyes = "Aswid - Eyes";
+
+ EyeSourceModel = config.Bind(eyes, "Eye Source Model", "Skeleton",
+ new ConfigDescription(
+ "Which creature's eye lights to wear. The plain skeleton's are smaller and dimmer than the poison one's; Hildir's are its own. Changing this rebuilds the pair.",
+ new AcceptableValueList("Skeleton", "Skeleton_Poison", "Skeleton_Hildir"),
+ new ConfigurationManagerAttributes { Order = 100 }));
+
+ EyeFinalStage = config.Bind(eyes, "Eye Final Stage", 8,
+ new ConfigDescription("The progression state at which the eyes turn red. Below it they burn the spectral green set out just under here; 8 is Fader, the last one.",
+ new AcceptableValueRange(1, 8), new ConfigurationManagerAttributes { Order = 95 }));
+
+ EarlyEyeColorRed = config.Bind(eyes, "Early Eye Colour Red", 0.08f,
+ new ConfigDescription("Red channel of the pre-final tint. Near zero: what little there is only keeps the green from reading as pure cyan.",
+ new AcceptableValueRange(0f, 8f), new ConfigurationManagerAttributes { Order = 94 }));
+ EarlyEyeColorGreen = config.Bind(eyes, "Early Eye Colour Green", 1.4f,
+ new ConfigDescription("Green channel of the pre-final tint - the one doing the work.",
+ new AcceptableValueRange(0f, 8f), new ConfigurationManagerAttributes { Order = 93 }));
+ EarlyEyeColorBlue = config.Bind(eyes, "Early Eye Colour Blue", 0.5f,
+ new ConfigDescription("Blue channel of the pre-final tint. A third of the green is what makes it read as cold and spectral rather than as a leaf.",
+ new AcceptableValueRange(0f, 8f), new ConfigurationManagerAttributes { Order = 92 }));
+ EarlyEyeGlowStrength = config.Bind(eyes, "Early Eye Glow Strength", 0.8f,
+ new ConfigDescription("How bright the green burns. Deliberately below the red's, so arriving at the last stage is a visible change and not just a hue swap.",
+ new AcceptableValueRange(0f, 3f), new ConfigurationManagerAttributes { Order = 91 }));
+
+ EyeColorRed = config.Bind(eyes, "Eye Colour Red", 2f,
+ new ConfigDescription("Red channel of the final-stage tint. Past 1 is HDR, which is what the bloom pass needs to make it glow rather than merely be red.",
+ new AcceptableValueRange(0f, 8f), new ConfigurationManagerAttributes { Order = 90 }));
+ EyeColorGreen = config.Bind(eyes, "Eye Colour Green", 0.05f,
+ new ConfigDescription("Green channel of the final-stage tint. Near zero is what keeps a bright red from washing out to pink.",
+ new AcceptableValueRange(0f, 8f), new ConfigurationManagerAttributes { Order = 89 }));
+ EyeColorBlue = config.Bind(eyes, "Eye Colour Blue", 0.02f,
+ new ConfigDescription("Blue channel of the final-stage tint. Near zero, same reason as green.",
+ new AcceptableValueRange(0f, 8f), new ConfigurationManagerAttributes { Order = 88 }));
+ EyeGlowStrength = config.Bind(eyes, "Eye Glow Strength", 1f,
+ new ConfigDescription("How bright the final-stage red burns - the single knob for it, since the hue is already pure. Expect a floor: below the bloom threshold the eyes stop glowing and become flat dots.",
+ new AcceptableValueRange(0f, 3f), new ConfigurationManagerAttributes { Order = 87 }));
+
+ EyeSizeMultiplier = config.Bind(eyes, "Eye Size Multiplier", 1f,
+ new ConfigDescription("Scales both sockets. 1 is the size the source creature wears them at.",
+ new AcceptableValueRange(0.1f, 5f), new ConfigurationManagerAttributes { Order = 80 }));
+
+ EyeForwardOffset = config.Bind(eyes, "Eye Forward Offset", 0f,
+ new ConfigDescription("Moves both eyes out of (or into) the face. 0 leaves them where the source creature wears them.",
+ new AcceptableValueRange(-0.1f, 0.1f), new ConfigurationManagerAttributes { Order = 70 }));
+ EyeHeightOffset = config.Bind(eyes, "Eye Height Offset", 0f,
+ new ConfigDescription("Moves both eyes up or down the face.",
+ new AcceptableValueRange(-0.1f, 0.1f), new ConfigurationManagerAttributes { Order = 69 }));
+ EyeSeparationOffset = config.Bind(eyes, "Eye Separation Offset", 0f,
+ new ConfigDescription("Pushes the two eyes apart (or together). Each moves away from the centre of the face, so this is half the change in the gap.",
+ new AcceptableValueRange(-0.1f, 0.1f), new ConfigurationManagerAttributes { Order = 68 }));
+
+ EyeRotationX = config.Bind(eyes, "Eye Rotation X", 0f,
+ new ConfigDescription("Turns both eyes on the spot. Only matters if the borrowed socket is flat enough to be seen edge-on.",
+ new AcceptableValueRange(-180f, 180f), new ConfigurationManagerAttributes { Order = 60 }));
+ EyeRotationY = config.Bind(eyes, "Eye Rotation Y", 0f,
+ new ConfigDescription("As above, around the second axis.",
+ new AcceptableValueRange(-180f, 180f), new ConfigurationManagerAttributes { Order = 59 }));
+ EyeRotationZ = config.Bind(eyes, "Eye Rotation Z", 0f,
+ new ConfigDescription("As above, around the third axis.",
+ new AcceptableValueRange(-180f, 180f), new ConfigurationManagerAttributes { Order = 58 }));
+
+ EyeSmoke = config.Bind(eyes, "Eye Smoke", true,
+ new ConfigDescription("Lights the smoke the creature carries inside its own sockets and leaves switched off. Tinted to match the eyes, so it turns with them at the last stage.",
+ null, new ConfigurationManagerAttributes { Order = 50 }));
+ EyeFlatColorShader = config.Bind(eyes, "Eye Flat Colour Shader", false,
+ new ConfigDescription("Escape hatch: if the borrowed material refuses the red tint, this repaints the sockets with a plain colour shader instead - guaranteed red, but the socket loses its own texture. Changing this rebuilds the pair.",
+ null, new ConfigurationManagerAttributes { Order = 49 }));
}
}
}
diff --git a/JotunnModStub/Aswid/AswidRace.cs b/JotunnModStub/Aswid/AswidRace.cs
index d9cc23f..67bbe53 100644
--- a/JotunnModStub/Aswid/AswidRace.cs
+++ b/JotunnModStub/Aswid/AswidRace.cs
@@ -90,6 +90,13 @@ namespace RacesOfValheim
CreateFoodItems();
AswidBloodRefinery.Register();
+ // Registered HERE and not lazily from the maintain tick: this method runs on
+ // PrefabManager.OnVanillaPrefabsAvailable, which is the one moment Jotunn will take a
+ // new item into ObjectDB. Registered later, the prefab is built and logged and looks
+ // entirely healthy - and then nobody can spawn it, which is exactly how the first
+ // version of the claws failed: two empty hands and a log full of success.
+ AswidClaws.Instance.EnsureRegistered();
+
GameObject geirrhafa = Jotunn.Managers.PrefabManager.Cache.GetPrefab("Fenring_Cultist_Hildir");
if (geirrhafa != null)
{
diff --git a/JotunnModStub/Aswid/AswidVisuals.cs b/JotunnModStub/Aswid/AswidVisuals.cs
index a6a86dc..555f85d 100644
--- a/JotunnModStub/Aswid/AswidVisuals.cs
+++ b/JotunnModStub/Aswid/AswidVisuals.cs
@@ -1,16 +1,28 @@
+using System.Collections.Generic;
+using Jotunn.Managers;
using UnityEngine;
namespace RacesOfValheim
{
///
- /// The Aswid's glowing eyes: two small emissive spheres burned into the face, evil red.
+ /// The Aswid's burning eyes: the vanilla skeleton's own eye lights, worn spectral green until
+ /// the last tier and red once it arrives.
///
- /// Built the same way the Dvergar's eyes are (see DvergarVisuals.ApplyEyes) and for the same
- /// reason - a player's eyes are painted into the skin texture, and Custom/Player has no
- /// emission channel to light them with. The geometry is shared work: both races render on the
- /// plain human rig (Aswid tints it, same as Dvergar), so the head bone, its axes, and the
- /// spherical-cap placement trick all carry over unchanged. Only the numbers differ, because an
- /// Aswid stands at normal human scale most of the time instead of the Dvergar's 0.78.
+ /// They used to be two spheres built from scratch on an Unlit/Color shader, the same trick the
+ /// Dvergar and the Sverm still use, because a player's eyes are painted into the skin texture
+ /// and Custom/Player has no emission channel to light them with. Those spheres were fine and
+ /// they were also obviously spheres. What the game already has is better: the creature named
+ /// 'Skeleton' carries two objects, eye_l and eye_r, parented to its Head bone and drawn with a
+ /// material built for exactly this - a lit socket seen from any angle.
+ ///
+ /// Borrowing them is cheap because the skeleton is skinned to the player's own rig: its Head
+ /// bone is our Head bone, so the local pose those two objects were authored at lands on a
+ /// player's face without a single measurement. The placement config below is deltas on top of
+ /// that pose, not a placement of its own, and 0 means "wherever the game put them".
+ ///
+ /// Only the Aswid is changed by this file. The Dvergar (DvergarVisuals) and the Sverm
+ /// (SvermVisuals) keep their own spheres - they each own a copy of the sphere code, so nothing
+ /// here reaches them.
///
/// Runs for local and remote players alike, which is why it takes a Player rather than reading
/// Player.m_localPlayer.
@@ -19,65 +31,19 @@ namespace RacesOfValheim
{
private const string EyesName = "AswidEyes";
- // ─── Glow colour ────────────────────────────────────────────────────
- // HDR on purpose - past 1 is what makes the bloom pass pick these up at all - but only
- // just past it. The first attempt used (6, 0.08, 0.03) at full strength and came out as a
- // white headlamp with a red halo: bloom spreads the excess outward and saturates the core,
- // so beyond a point more brightness buys nothing but a bigger white disc and *less* red.
- // The Dvergar hit this exact wall and answered it by dimming, which is the same answer
- // here.
- //
- // The near-zero green and blue are what keep it red rather than pink as it brightens.
- // Not tied to star tier: unlike the Dvergar, whose colour borrows a real creature's
- // progression, the Aswid has no such reference to read from.
- public static readonly Color EvilEyeColor = new Color(4f, 0.06f, 0.02f, 1f);
-
- // Darker than the Dvergar's 0.3, which put the red at an effective 1.2 - above 1, so the
- // core clipped to a flat saturated red and the shade was decided by the clip rather than
- // by the colour. 0.2 lands it at 0.8: under the clip, so the red keeps its depth and reads
- // as blood rather than as a warning light.
- //
- // This is the one knob for how dark the eyes are - the hue is already pure red, so with
- // green and blue at zero there is nothing left to darken *except* the intensity. Lower it
- // further for deeper, but expect a floor: bloom only picks up what is bright enough to
- // pass its threshold, so far enough down the eyes stop glowing and become flat dots.
- public static readonly float EyeGlowStrength = 0.2f;
-
- // ─── Placement ──────────────────────────────────────────────────────
- // The Dvergar's numbers, carried over unchanged. That is not laziness - it is the only
- // correct conversion, and the arithmetic says so:
- //
- // local offset = config x scale x (1 / headBone.lossyScale)
- // lossyScale = 100 (the armature's authored scale) x scale
- // => config x scale / (100 x scale) = config / 100
- //
- // The scale cancels. These constants live in the *unscaled* rig's units, and the face they
- // have to land on shrinks and grows by exactly the same factor, so the same config value
- // lands on the same part of the face at any size. Both races render on the plain human
- // rig, so the Dvergar's tuning transfers verbatim.
- //
- // The first version of this file rescaled them by 0.78 on the theory that the Dvergar's
- // values were "pre-shrink" and needed converting up to human size. They are not, and it
- // put the eyes 18mm deeper and 40mm lower in rig units - on a human skull, the drop from
- // the eye line to the mouth.
- //
- // What this also means: the Fader-tier +10% (Aswid_PlayerUpdate_Patch in AswidPatches.cs)
- // needs no special case. It is not that the multiply handles it - the multiply cancels
- // out. It is that the offsets are expressed in the head bone's own local space, and a
- // child transform rides its parent's scale for free.
- public static readonly float EyeSeparation = 0.032f; // half the distance between them
- public static readonly float EyeForward = 0.081f; // centre out from the head bone
- public static readonly float EyeHeight = 0.181f; // up from the head bone
- public static readonly float EyeSize = 0.062f; // across, so a 24mm radius at 0.78
-
- // Carried over from the Dvergar's own tuning on this same rig: the face is not flat, so
- // two eyes placed symmetrically do not come out looking symmetrical. May need a pass in
- // game to confirm it holds at Aswid's own scale - flip to index 1 in PlaceEyes if it turns
- // out to be the wrong eye.
- public static readonly float LeftEyeSizeMultiplier = 0.85f;
+ // The two objects to look for inside whichever creature the config points at. Both vanilla
+ // skeletons carry this pair; the material differs (skeleton_eye vs skeleton_eye_big) and
+ // that difference is the whole reason the source is a config and not a constant.
+ private static readonly string[] SourceEyeNames = { "eye_l", "eye_r" };
public const string PlayerHeadBoneName = "Head";
+ // ─── Placement, and why the numbers are unitless ─────────────────────
+ // The offsets below are applied as: local offset = config x scale x (1 / headBone.lossyScale)
+ // and lossyScale is the armature's authored 100x times the player's own scale, so the
+ // scale cancels and a given config value lands on the same part of the face at any size -
+ // Fader-tier growth included. Kept in the arithmetic because it is honest about intent.
+
// ─── Race check ─────────────────────────────────────────────────────
///
@@ -104,21 +70,59 @@ namespace RacesOfValheim
///
/// The skull's own idea of forward, up and right, measured once while the head is still
- /// looking where the body is. Kept on the eye holder so it survives as long as the eyes
- /// do, and so nothing is tempted to work it out again from a rig that has since moved.
+ /// looking where the body is, plus what the eyes currently in place were built from. Kept
+ /// on the eye holder so it survives as long as the eyes do, and so nothing is tempted to
+ /// work it out again from a rig that has since moved.
///
private class EyeFrame : MonoBehaviour
{
public Vector3 LocalForward = Vector3.forward;
public Vector3 LocalUp = Vector3.up;
public Vector3 LocalRight = Vector3.right;
+
+ // What these eyes were cloned from, and whether they were flattened onto a plain
+ // colour shader. Either one changing in Configuration Manager means the pair has to be
+ // built again rather than merely moved.
+ public string SourceModel = "";
+ public bool FlatShader;
}
- private static Shader cachedGlowShader;
- private static bool glowShaderResolved;
+ /// The pose an eye was authored at on the creature. Everything else is a delta on this.
+ private class EyeBase : MonoBehaviour
+ {
+ public Vector3 Position;
+ public Quaternion Rotation = Quaternion.identity;
+ public Vector3 Scale = Vector3.one;
+ }
///
- /// Keeps two small emissive spheres burning over the player's painted-on eyes. Safe to call
+ /// Reapplies the eyes every frame, which is what makes the Configuration Manager sliders
+ /// move them while you watch. Added to a player once they turn out to be an Aswid and
+ /// destroyed when they stop being one; VisEquipment's own refresh is what puts it back.
+ ///
+ public class EyeTicker : MonoBehaviour
+ {
+ private Player m_player;
+
+ private void Awake()
+ {
+ m_player = GetComponent();
+ }
+
+ private void LateUpdate()
+ {
+ if (m_player == null)
+ {
+ Destroy(this);
+ return;
+ }
+
+ ApplyEyes(m_player);
+ }
+ }
+
+ ///
+ /// Keeps the pair of lit sockets burning over the player's painted-on eyes. Safe to call
/// for anyone: it removes them again from whoever is not a living Aswid.
///
/// Parented straight onto the head bone rather than Character.m_eye - the Dvergar tried
@@ -144,23 +148,37 @@ namespace RacesOfValheim
eyes.name = EyesName + "_Removed";
Object.Destroy(eyes.gameObject);
}
+
+ EyeTicker ticker = player.GetComponent();
+ if (ticker != null) Object.Destroy(ticker);
return;
}
- if (eyes == null) eyes = BuildEyes(headBone);
- if (eyes == null) return; // already logged once by the resolver
+ if (player.GetComponent() == null)
+ {
+ player.gameObject.AddComponent();
+ }
+
+ // A different source creature, or the shader override being flipped, changes what the
+ // eyes are rather than where they sit - so the pair is thrown away and built again.
+ if (eyes != null)
+ {
+ EyeFrame existing = eyes.GetComponent();
+ if (existing == null ||
+ existing.SourceModel != AswidConfig.EyeSourceModel.Value ||
+ existing.FlatShader != AswidConfig.EyeFlatColorShader.Value)
+ {
+ eyes.name = EyesName + "_Removed";
+ Object.Destroy(eyes.gameObject);
+ eyes = null;
+ }
+ }
+
+ if (eyes == null) eyes = BuildEyes(player, headBone);
+ if (eyes == null) return; // already logged once by the builder
PlaceEyes(player, headBone, eyes);
-
- Color glow = GetEyeColor();
- foreach (Renderer renderer in eyes.GetComponentsInChildren(true))
- {
- Material material = renderer.material;
- if (material == null) continue;
-
- material.color = glow;
- if (material.HasProperty("_EmissionColor")) material.SetColor("_EmissionColor", glow);
- }
+ PaintEyes(eyes, GetEyeColor(player));
}
///
@@ -168,21 +186,29 @@ namespace RacesOfValheim
/// DvergarVisuals.FindHeadBone for why: the avatar's HumanBodyBones.Head moves with the
/// player but ignores the head's own idle animation, and only VisEquipment.m_bodyModel's
/// own bone array is the one the skinned mesh - and every animation - actually drives.
+ ///
+ /// THE ANIMATOR'S HEAD IS NOT AN ACCEPTABLE ANSWER, and this used to fall back to it
+ /// "so that something renders if the body model is not up yet". That fallback is what put
+ /// the eyes at the wrong height: the avatar's HumanBodyBones.Head is a DIFFERENT transform,
+ /// sitting at a different place in the hierarchy, so a holder parented to it hangs at the
+ /// wrong height for as long as it lives - and it lives until the player changes race. It
+ /// only ever bit once the claws landed, because equipping an item on spawn moved the first
+ /// build a few frames earlier, into the window where the body model is not up yet.
+ ///
+ /// Returning null costs nothing: the ticker calls this again next frame, and a frame with
+ /// no eyes is invisible next to a session with them on the jaw.
///
private static Transform FindHeadBone(Player player)
{
VisEquipment visEq = player.GetComponent();
- if (visEq != null && visEq.m_bodyModel != null && visEq.m_bodyModel.bones != null)
+ if (visEq == null || visEq.m_bodyModel == null || visEq.m_bodyModel.bones == null) return null;
+
+ foreach (Transform bone in visEq.m_bodyModel.bones)
{
- foreach (Transform bone in visEq.m_bodyModel.bones)
- {
- if (bone != null && bone.name == PlayerHeadBoneName) return bone;
- }
+ if (bone != null && bone.name == PlayerHeadBoneName) return bone;
}
- // Last resort, and only so that something renders if the body model is not up yet.
- Animator animator = player.GetComponentInChildren();
- return animator != null ? animator.GetBoneTransform(HumanBodyBones.Head) : null;
+ return null;
}
///
@@ -193,25 +219,55 @@ namespace RacesOfValheim
///
private static float GetPlayerScale(Player player) => player.transform.localScale.x;
- private static Color GetEyeColor()
+ ///
+ /// The tier this particular Aswid is rendering at. Off the ZDO, so a remote player's eyes
+ /// burn at their own standing rather than at ours; without one - the main-menu preview -
+ /// fall back to what this client can work out, the same fallback the Skeleton's visuals
+ /// make (SkeletonVisuals.GetProgressionState).
+ ///
+ private static int GetProgressionState(Player player)
{
- float strength = EyeGlowStrength;
- return new Color(
- EvilEyeColor.r * strength,
- EvilEyeColor.g * strength,
- EvilEyeColor.b * strength,
- EvilEyeColor.a);
+ ZNetView nview = player != null ? player.GetComponent() : null;
+ if (nview != null && nview.IsValid())
+ {
+ return nview.GetZDO().GetInt("RacesOfValheim_AswidState", 0);
+ }
+
+ return BossProgressionManager.GetCurrentProgressionState();
}
///
- /// Puts the two eyes where the face is, in the head bone's own coordinates, every frame.
- /// See DvergarVisuals.PlaceEyes for the full derivation of the axes.
+ /// Spectral green for as long as the Aswid is still becoming one, and red only at the end.
///
- /// The scale term is kept for the Dvergar's sake and because it is honest about intent,
- /// but it does not do the work it looks like it does: lossyScale already contains the
- /// player's scale, so the multiply and the divide cancel and the local offset is simply
- /// config/100 at every size. Growth is handled by the parenting, not by this arithmetic -
- /// see the note on the placement constants above.
+ /// The red was the colour from the start and it reads as arrival, so it is worth not
+ /// spending it early: every tier below the last burns a cold green instead, dimmer on
+ /// purpose - the green is the eyes of something dead, the red is the eyes of something
+ /// that has finished feeding. Each has its own brightness rather than sharing one, because
+ /// "not too bright" is exactly the difference between them.
+ ///
+ private static Color GetEyeColor(Player player)
+ {
+ bool final = GetProgressionState(player) >= AswidConfig.EyeFinalStage.Value;
+
+ float strength = final
+ ? AswidConfig.EyeGlowStrength.Value
+ : AswidConfig.EarlyEyeGlowStrength.Value;
+
+ Color hue = final
+ ? new Color(AswidConfig.EyeColorRed.Value, AswidConfig.EyeColorGreen.Value, AswidConfig.EyeColorBlue.Value)
+ : new Color(AswidConfig.EarlyEyeColorRed.Value, AswidConfig.EarlyEyeColorGreen.Value, AswidConfig.EarlyEyeColorBlue.Value);
+
+ return new Color(hue.r * strength, hue.g * strength, hue.b * strength, 1f);
+ }
+
+ ///
+ /// Moves each eye off the pose it was authored at, by the config's deltas, in the head
+ /// bone's own coordinates. Every value at 0 (and size at 1) leaves them exactly where the
+ /// game's own skeleton wears them, which is the intended starting point.
+ ///
+ /// See DvergarVisuals.PlaceEyes for the full derivation of the axes: they are measured
+ /// once at build time and snapped to the skull's square axes, because the raw measurement
+ /// is taken at whatever pose the head happens to hold that frame and arrives tilted.
///
private static void PlaceEyes(Player player, Transform headBone, Transform holder)
{
@@ -223,27 +279,69 @@ namespace RacesOfValheim
EyeFrame frame = holder.GetComponent();
if (frame == null) return;
- Vector3 localForward = frame.LocalForward;
- Vector3 localUp = frame.LocalUp;
- Vector3 localRight = frame.LocalRight;
+ float scale = GetPlayerScale(player) * toLocal;
- float scale = GetPlayerScale(player);
- Vector3 baseLocal = localForward * (EyeForward * scale * toLocal)
- + localUp * (EyeHeight * scale * toLocal);
+ Vector3 shift = frame.LocalForward * (AswidConfig.EyeForwardOffset.Value * scale)
+ + frame.LocalUp * (AswidConfig.EyeHeightOffset.Value * scale);
- float eyeLocalSize = EyeSize * scale * toLocal;
+ Quaternion twist = Quaternion.Euler(
+ AswidConfig.EyeRotationX.Value,
+ AswidConfig.EyeRotationY.Value,
+ AswidConfig.EyeRotationZ.Value);
for (int i = 0; i < holder.childCount; i++)
{
Transform eye = holder.GetChild(i);
+ EyeBase authored = eye.GetComponent();
+ if (authored == null) continue;
- // Index 0 is offset against the right axis, so it is the model's left eye - the
- // one on your right as you face it.
- float side = i == 0 ? -1f : 1f;
- float size = i == 0 ? eyeLocalSize * LeftEyeSizeMultiplier : eyeLocalSize;
+ // Which way "outwards" is for this particular eye, read from where the creature
+ // put it rather than from the order the children happen to be in. Widening then
+ // pushes both eyes apart whichever one this is.
+ float side = Mathf.Sign(Vector3.Dot(authored.Position, frame.LocalRight));
+ if (side == 0f) side = i == 0 ? -1f : 1f;
- eye.localPosition = baseLocal + localRight * (side * EyeSeparation * scale * toLocal);
- eye.localScale = Vector3.one * size;
+ eye.localPosition = authored.Position + shift +
+ frame.LocalRight * (side * AswidConfig.EyeSeparationOffset.Value * scale);
+ eye.localRotation = twist * authored.Rotation;
+ eye.localScale = authored.Scale * AswidConfig.EyeSizeMultiplier.Value;
+ }
+ }
+
+ ///
+ /// Tints the borrowed material red - the one thing about these eyes that is not the
+ /// skeleton's.
+ ///
+ /// Every colour property the shader turns out to have is written, rather than guessing
+ /// which one it uses: a Valheim VFX material can carry _Color, _TintColor, _EmissionColor
+ /// or none of them, and writing a property a shader does not have is an error while
+ /// writing all of the ones it does is free.
+ ///
+ private static void PaintEyes(Transform holder, Color glow)
+ {
+ bool smoke = AswidConfig.EyeSmoke.Value;
+
+ foreach (Renderer renderer in holder.GetComponentsInChildren(true))
+ {
+ Material material = renderer.material;
+ if (material == null) continue;
+
+ if (material.HasProperty("_Color")) material.SetColor("_Color", glow);
+ if (material.HasProperty("_TintColor")) material.SetColor("_TintColor", glow);
+ if (material.HasProperty("_BaseColor")) material.SetColor("_BaseColor", glow);
+ if (material.HasProperty("_EmissionColor")) material.SetColor("_EmissionColor", glow);
+ }
+
+ // The smoke curling out of the sockets is authored on the creature but left switched
+ // off there, waiting for a script that this clone does not have. Off by default here
+ // too: it is a much louder effect than the glow itself.
+ foreach (ParticleSystem ps in holder.GetComponentsInChildren(true))
+ {
+ if (ps.gameObject.activeSelf != smoke) ps.gameObject.SetActive(smoke);
+ if (!smoke) continue;
+
+ ParticleSystem.MainModule main = ps.main;
+ main.startColor = new ParticleSystem.MinMaxGradient(glow);
}
}
@@ -262,10 +360,18 @@ namespace RacesOfValheim
return new Vector3(0f, 0f, Mathf.Sign(direction.z));
}
- private static Transform BuildEyes(Transform headBone)
+ private static Transform BuildEyes(Player player, Transform headBone)
{
- Shader glow = ResolveGlowShader();
- if (glow == null) return null;
+ string modelName = AswidConfig.EyeSourceModel.Value;
+
+ List sources = FindSourceEyes(modelName);
+ if (sources.Count == 0) return null; // already logged once by the finder
+
+ // Anything of ours left anywhere else on this player goes first. ApplyEyes only ever
+ // looks under the head bone, so a holder that ended up on some other transform is
+ // invisible to it - it would build a second pair beside the wrong one rather than
+ // replace it. That is exactly the state the animator fallback used to leave behind.
+ SweepStrayHolders(player, headBone);
GameObject holder = new GameObject(EyesName);
holder.transform.SetParent(headBone, false);
@@ -281,35 +387,164 @@ namespace RacesOfValheim
frame.LocalForward = SnapToAxis(headBone.InverseTransformDirection(root.forward));
frame.LocalUp = SnapToAxis(headBone.InverseTransformDirection(root.up));
frame.LocalRight = Vector3.Cross(frame.LocalUp, frame.LocalForward).normalized;
+ frame.SourceModel = modelName;
+ frame.FlatShader = AswidConfig.EyeFlatColorShader.Value;
- for (int i = 0; i < 2; i++)
+ foreach (Transform source in sources)
{
- // Spheres, not quads: a quad seen edge-on is a line and vanishes, which is why an
- // earlier attempt on the Dvergar came and went with the camera angle. A sphere
- // reads the same from every direction and is properly hidden by the skull when the
- // head is between it and the camera.
- GameObject eye = GameObject.CreatePrimitive(PrimitiveType.Sphere);
- eye.name = "Eye" + i;
+ GameObject eye = Object.Instantiate(source.gameObject, holder.transform);
+ eye.name = source.name;
- foreach (Collider collider in eye.GetComponents())
+ // Remembered before anything moves it, because everything the config does is
+ // expressed as a delta on this.
+ EyeBase authored = eye.AddComponent();
+ authored.Position = source.localPosition;
+ authored.Rotation = source.localRotation;
+ authored.Scale = source.localScale;
+
+ eye.transform.localPosition = source.localPosition;
+ eye.transform.localRotation = source.localRotation;
+ eye.transform.localScale = source.localScale;
+
+ // Allowlist, not a blocklist - the same rule the skeleton's own glow and the head
+ // flame are cloned under. Whatever rode along goes, whatever type it turns out to
+ // be; EyeBase is added back afterwards because it is ours.
+ foreach (Component comp in eye.GetComponentsInChildren(true))
{
- Object.Destroy(collider);
+ if (comp is Transform || comp is MeshRenderer || comp is MeshFilter ||
+ comp is ParticleSystem || comp is ParticleSystemRenderer || comp is EyeBase)
+ {
+ continue;
+ }
+
+ Object.Destroy(comp);
}
- eye.transform.SetParent(holder.transform, false);
- eye.transform.localPosition = Vector3.zero;
- eye.transform.localRotation = Quaternion.identity;
- eye.transform.localScale = Vector3.zero; // PlaceEyes runs immediately after this
+ foreach (Renderer renderer in eye.GetComponentsInChildren(true))
+ {
+ renderer.enabled = true;
+ renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
+ renderer.receiveShadows = false;
- Renderer renderer = eye.GetComponent();
- renderer.material = new Material(glow);
- renderer.shadowCastingMode = UnityEngine.Rendering.ShadowCastingMode.Off;
- renderer.receiveShadows = false;
+ // The escape hatch, for if the borrowed material turns out not to take a tint:
+ // a plain colour shader renders past 1 so the bloom pass picks it up, at the
+ // cost of the socket's own texture.
+ if (!AswidConfig.EyeFlatColorShader.Value) continue;
+
+ Shader flat = ResolveGlowShader();
+ if (flat != null) renderer.material = new Material(flat);
+ }
+
+ eye.SetActive(true);
}
+ LogMaterialsOnce(modelName, holder.transform);
+
+ // What the pair was actually anchored to. If the height is ever wrong again, this line
+ // is the answer rather than the start of another guess: it names the bone, its parent,
+ // and the axes the offsets are measured along.
+ Jotunn.Logger.LogInfo(
+ $"[Aswid] Eyes built on bone '{headBone.name}' (parent '{(headBone.parent != null ? headBone.parent.name : "-")}') " +
+ $"at world y={headBone.position.y:F2}, lossyScale={headBone.lossyScale.x:F1}, " +
+ $"localUp={frame.LocalUp}, localForward={frame.LocalForward}.");
+
return holder.transform;
}
+ ///
+ /// Destroys every eye holder on this player that is not parented to the bone we are about
+ /// to build on. Runs only when a pair is being built, which is on a race change or a config
+ /// change - never on a hot path.
+ ///
+ private static void SweepStrayHolders(Player player, Transform keepParent)
+ {
+ if (player == null) return;
+
+ foreach (Transform t in player.GetComponentsInChildren(true))
+ {
+ if (t == null || t.name != EyesName) continue;
+ if (t.parent == keepParent) continue;
+
+ Jotunn.Logger.LogInfo(
+ $"[Aswid] Removing a stray eye holder parented to '{(t.parent != null ? t.parent.name : "-")}'.");
+
+ // Renamed first: Destroy is deferred to the end of the frame, and this sweep would
+ // otherwise find it again on the next build.
+ t.name = EyesName + "_Removed";
+ Object.Destroy(t.gameObject);
+ }
+ }
+
+ private static readonly HashSet warnedSources = new HashSet();
+ private static readonly HashSet loggedMaterials = new HashSet();
+
+ ///
+ /// The creature's own eye objects, by name. Not cached: this runs when the pair is built,
+ /// which is on a race change or a config change and not on any hot path.
+ ///
+ private static List FindSourceEyes(string modelName)
+ {
+ List found = new List();
+
+ GameObject prefab = PrefabManager.Cache.GetPrefab(modelName);
+ if (prefab == null)
+ {
+ if (warnedSources.Add(modelName))
+ {
+ Jotunn.Logger.LogWarning(
+ $"[Aswid] Eye source prefab '{modelName}' not found - the eyes stay dark. " +
+ "Check the model name in Configuration Manager.");
+ }
+ return found;
+ }
+
+ foreach (Transform t in prefab.GetComponentsInChildren(true))
+ {
+ string lower = t.name.ToLower();
+ foreach (string wanted in SourceEyeNames)
+ {
+ if (lower == wanted) { found.Add(t); break; }
+ }
+ }
+
+ if (found.Count == 0 && warnedSources.Add(modelName + ":eyes"))
+ {
+ Jotunn.Logger.LogWarning(
+ $"[Aswid] '{modelName}' carries no {string.Join("/", SourceEyeNames)} objects - the eyes stay dark.");
+ }
+
+ return found;
+ }
+
+ ///
+ /// Says what the borrowed material actually is, once per source. If red does not take,
+ /// this line is the answer: it names the shader and every colour property it exposes.
+ ///
+ private static void LogMaterialsOnce(string modelName, Transform holder)
+ {
+ if (!loggedMaterials.Add(modelName)) return;
+
+ foreach (Renderer renderer in holder.GetComponentsInChildren(true))
+ {
+ Material material = renderer.sharedMaterial;
+ if (material == null) continue;
+
+ List properties = new List();
+ foreach (string name in new[] { "_Color", "_TintColor", "_BaseColor", "_EmissionColor" })
+ {
+ if (material.HasProperty(name)) properties.Add(name);
+ }
+
+ Jotunn.Logger.LogInfo(
+ $"[Aswid] Eye '{renderer.name}' from '{modelName}': material '{material.name}' " +
+ $"shader '{(material.shader != null ? material.shader.name : "none")}' " +
+ $"colour properties: {(properties.Count > 0 ? string.Join(", ", properties.ToArray()) : "none")}");
+ }
+ }
+
+ private static Shader cachedGlowShader;
+ private static bool glowShaderResolved;
+
///
/// Finds a shader that will render a flat colour past 1 so the bloom pass picks it up.
/// Opaque first, deliberately - see DvergarVisuals.ResolveGlowShader: a transparent shader
diff --git a/JotunnModStub/Fenrir/FenrirClaws.cs b/JotunnModStub/Fenrir/FenrirClaws.cs
new file mode 100644
index 0000000..604fd0b
--- /dev/null
+++ b/JotunnModStub/Fenrir/FenrirClaws.cs
@@ -0,0 +1,56 @@
+using UnityEngine;
+
+namespace RacesOfValheim
+{
+ ///
+ /// The Cursed Claws: the flesh rippers, worn exactly as the game authored them.
+ ///
+ /// Everything about how they behave - issued once, never dropped, back in hand the moment the
+ /// hands are free, tier damage as slash - lives in RaceClawSet. This file is only the Fenrir's
+ /// half: which model, and when the race is currently a wolf.
+ ///
+ /// No tint. The fenrir claw already looks like something a Fenrir would grow, which is the
+ /// whole reason it is the one being borrowed.
+ ///
+ public class FenrirClaws : RaceClawSet
+ {
+ public static readonly FenrirClaws Instance = new FenrirClaws();
+
+ public override string RaceId => "Fenrir";
+ public override string ItemName => "FenrirCursedClaws";
+ public override string DisplayName => "Cursed Claws";
+ public override string Description => "The wolf's hands, kept on in the man's shape. They do not come off.";
+
+ public override string[] ModelPrefabs => new[]
+ {
+ "FistFenrirClaw",
+ "FistFenrirClaw_Undead",
+ "FenrirClaw",
+ };
+
+ // The Fenrir publishes no per-tier state of its own, so the damage falls back to the local
+ // player's progression. That is right for the player at the keyboard and approximate for
+ // somebody else's claws on a shared world - the same compromise the Sverm makes, and the
+ // fix if it ever matters is a state key in FenrirRace, not a change here.
+
+ ///
+ /// A wolf swings its own jaws, and FenrirFormBehavior does that damage itself. The ZDO
+ /// carries the form for everyone; the status effect is the local player's own copy of the
+ /// same fact, checked second so a form that has begun but not yet replicated still counts.
+ ///
+ public override bool IsTransformed(Player player)
+ {
+ if (player == null) return false;
+
+ ZNetView nview = player.GetComponent();
+ if (nview != null && nview.IsValid())
+ {
+ if (!string.IsNullOrEmpty(nview.GetZDO().GetString("RacesOfValheim_FenrirForm", ""))) return true;
+ }
+
+ return player == Player.m_localPlayer &&
+ player.GetSEMan() != null &&
+ player.GetSEMan().HaveStatusEffect("SE_FenrirForm".GetStableHashCode());
+ }
+ }
+}
diff --git a/JotunnModStub/Fenrir/FenrirRace.cs b/JotunnModStub/Fenrir/FenrirRace.cs
index b37968d..7f6173b 100644
--- a/JotunnModStub/Fenrir/FenrirRace.cs
+++ b/JotunnModStub/Fenrir/FenrirRace.cs
@@ -35,6 +35,11 @@ namespace RacesOfValheim {
// Fenring is ever set up as a bench.
FenrirMangiatoia.Register();
+ // Same window, same reason: this method runs on PrefabManager.OnVanillaPrefabsAvailable,
+ // which is the one moment Jotunn will take a new item into ObjectDB. Registered later
+ // the prefab exists, logs its success, and cannot be spawned by anyone.
+ FenrirClaws.Instance.EnsureRegistered();
+
curseSE = ScriptableObject.CreateInstance();
curseSE.name = "SE_FenrirCurse";
curseSE.m_name = "Fenrir's Blood";
diff --git a/JotunnModStub/RaceClaws.cs b/JotunnModStub/RaceClaws.cs
new file mode 100644
index 0000000..ba4fda8
--- /dev/null
+++ b/JotunnModStub/RaceClaws.cs
@@ -0,0 +1,600 @@
+using System.Collections.Generic;
+using HarmonyLib;
+using Jotunn.Managers;
+using UnityEngine;
+
+namespace RacesOfValheim
+{
+ ///
+ /// Claws that are part of the body, for the races that grow a pair.
+ ///
+ /// This is SvermClawSlot generalised, not reinvented: the Sverm's Vilebone Maulclaws worked out
+ /// the whole shape of the problem, and the Aswid and the Fenrir are asking for the same object
+ /// with a different face. So the machinery moved here and each race supplies only what is
+ /// genuinely its own - the item name, the model to wear, and whether it is currently a wolf.
+ /// The Sverm still runs its own copy, untouched, because it also carries a carapace, a stinger
+ /// form and a fire term at Fader that none of this knows about.
+ ///
+ /// WHY A REAL ITEM AND NOT A COSMETIC. Bolting a model to the hand bones works right up until
+ /// the game rebuilds equipment visuals - which it does on every equip - and wipes it. A real
+ /// item in a real slot has nothing to put back. The trade is that a real weapon occupies the
+ /// right hand, so three rules keep that reading as intended rather than as a bug: sheathe
+ /// anything else and the claws come back, the holster key cannot put them away, and they
+ /// cannot be dragged, moved or dropped.
+ ///
+ /// BALANCE IS SHARED ON PURPOSE. The damage is not read from the model each race wears - the
+ /// Fenrir's flesh rippers and the Bjorn claw are not worth the same, and a race should not be
+ /// stronger because its claws are prettier. Every set reads the Sverm's own reference weapon at
+ /// quality 4 and the Sverm's own per-tier percentages, so all three races hit for identical
+ /// numbers at identical tiers. What differs here is the shape of the damage: these two land it
+ /// entirely as slash, where the Sverm splits it three ways and lights it on fire at Fader.
+ ///
+ public abstract class RaceClawSet
+ {
+ // ─── What a race has to say about its own claws ──────────────────────
+
+ /// The race string in the ZDO, e.g. "Aswid".
+ public abstract string RaceId { get; }
+
+ /// Prefab id of the cloned item. Never seen by a player.
+ public abstract string ItemName { get; }
+
+ /// What the item is called in the inventory.
+ public abstract string DisplayName { get; }
+
+ public abstract string Description { get; }
+
+ ///
+ /// Models to clone, in order of preference. A list rather than a name because the install's
+ /// manifest carries several near-identical claw ids and only some of them resolve - see
+ /// SvermConfig.ClawPrefabFallbacks, which is where that lesson was learned. The winner is
+ /// logged; a miss is a warning rather than two empty hands and silence.
+ ///
+ public abstract string[] ModelPrefabs { get; }
+
+ /// ZDO key carrying this race's progression state, or null if it publishes none.
+ public virtual string StateZdoKey => null;
+
+ /// Multiplied into the model's own colours. Null leaves the model as authored.
+ public virtual Color? Tint => null;
+
+ ///
+ /// True while the player is wearing another body entirely - a bat, mist, a wolf. Claws are
+ /// neither issued nor counted while that is the case: the form does its own damage and has
+ /// its own hands, and a weapon equipped underneath it is at best invisible and at worst the
+ /// thing the game decides to swing.
+ ///
+ public abstract bool IsTransformed(Player player);
+
+ // ─── Registry ────────────────────────────────────────────────────────
+
+ private static readonly List sets = new List();
+
+ ///
+ /// The roster. Kept here rather than in RacesOfValheim.Awake so the whole feature is this
+ /// file plus one short file per race, and adding a third clawed race is one line - not one
+ /// line here and another one three hundred lines away in the plugin's startup.
+ ///
+ static RaceClawSet()
+ {
+ Register(AswidClaws.Instance);
+ Register(FenrirClaws.Instance);
+ }
+
+ public static void Register(RaceClawSet set)
+ {
+ if (set == null || sets.Contains(set)) return;
+ sets.Add(set);
+ }
+
+ /// The set that belongs to this player's race, or null for everyone else.
+ public static RaceClawSet For(Player player)
+ {
+ if (player == null) return null;
+
+ string race = GetRace(player);
+ foreach (RaceClawSet set in sets)
+ {
+ if (set.RaceId == race) return set;
+ }
+ return null;
+ }
+
+ /// True if the item is any registered race's claws.
+ public static RaceClawSet SetOwning(ItemDrop.ItemData item)
+ {
+ if (item == null || item.m_shared == null) return null;
+
+ foreach (RaceClawSet set in sets)
+ {
+ if (set.IsClaws(item)) return set;
+ }
+ return null;
+ }
+
+ ///
+ /// Reads the race off the ZDO, falling back to m_customData - the same order every visual
+ /// in this mod reads it in, so a remote player and the menu preview both answer correctly.
+ ///
+ private static string GetRace(Player player)
+ {
+ ZNetView nview = player.GetComponent();
+ if (nview != null && nview.IsValid())
+ {
+ string race = nview.GetZDO().GetString("RacesOfValheim_Race", "");
+ if (!string.IsNullOrEmpty(race)) return race;
+ }
+
+ if (player.m_customData != null && player.m_customData.TryGetValue("Race", out string custom))
+ {
+ return custom;
+ }
+
+ return "Human";
+ }
+
+ // ─── Registration of the item ────────────────────────────────────────
+
+ private bool registered;
+ private bool warnedModel;
+ private bool loggedMaterials;
+ private readonly List ownedMaterials = new List();
+
+ ///
+ /// Clones whichever of the candidate models this build actually has. Deferred until ObjectDB
+ /// is up, so it is driven from the maintain tick rather than from Awake.
+ ///
+ public void EnsureRegistered()
+ {
+ if (registered) return;
+
+ if (ObjectDB.instance != null && ObjectDB.instance.GetItemPrefab(ItemName) != null)
+ {
+ registered = true;
+ return;
+ }
+
+ GameObject source = ResolveModel();
+ if (source == null) return; // already warned once by the resolver
+
+ GameObject clone = PrefabManager.Instance.CreateClonedPrefab(ItemName, source);
+ if (clone == null)
+ {
+ Jotunn.Logger.LogWarning($"[{RaceId}] Could not clone '{source.name}'; the claws stay unregistered.");
+ return;
+ }
+
+ ItemDrop drop = clone.GetComponent();
+ if (drop != null && drop.m_itemData != null && drop.m_itemData.m_shared != null)
+ {
+ ItemDrop.ItemData.SharedData shared = drop.m_itemData.m_shared;
+ shared.m_name = DisplayName;
+ shared.m_description = Description;
+
+ // Quest item: Valheim refuses to drop, trade or stack these. It is the cheapest
+ // honest way to say "this is part of your body" without a patch per verb.
+ shared.m_questItem = true;
+ shared.m_teleportable = true;
+ shared.m_weight = 0f;
+ shared.m_maxQuality = 1;
+
+ // No recipe and no station: this item is never crafted, only issued.
+ }
+
+ TakeOwnershipOfMaterials(clone);
+
+ ItemManager.Instance.AddItem(new Jotunn.Entities.CustomItem(clone, fixReference: false));
+ registered = true;
+ Jotunn.Logger.LogInfo($"[{RaceId}] Registered '{ItemName}' from '{source.name}'.");
+
+ RefreshTint();
+ }
+
+ private GameObject ResolveModel()
+ {
+ foreach (string name in ModelPrefabs)
+ {
+ // PrefabManager's cache first, ObjectDB second: the cache answers earlier in the
+ // load, and ObjectDB is still empty when the plugin wakes.
+ GameObject candidate = PrefabManager.Cache.GetPrefab(name);
+ if (candidate == null && ObjectDB.instance != null)
+ {
+ candidate = ObjectDB.instance.GetItemPrefab(name);
+ }
+
+ if (candidate != null)
+ {
+ Jotunn.Logger.LogInfo($"[{RaceId}] Claw model resolved to '{name}'.");
+ return candidate;
+ }
+ }
+
+ // Warned once, but NOT latched: a later call may run when more of the game is loaded,
+ // and a race with no hands is worth retrying for.
+ if (!warnedModel)
+ {
+ warnedModel = true;
+ Jotunn.Logger.LogWarning($"[{RaceId}] None of " + string.Join(", ", ModelPrefabs) +
+ " resolved yet; retrying as the game loads.");
+ }
+ return null;
+ }
+
+ ///
+ /// Gives the clone its own copies of every material it draws with.
+ ///
+ /// A cloned prefab still points at the ORIGINAL material assets, so tinting them straight
+ /// would repaint the vanilla weapon in every hand in the world - a thing that would show up
+ /// as "why are the flesh rippers black now" and take an hour to trace back here. Copies
+ /// also make the tint live: an instantiated item shares these same material objects, so
+ /// writing a colour on them reaches the pair already in the player's hands.
+ ///
+ private void TakeOwnershipOfMaterials(GameObject clone)
+ {
+ ownedMaterials.Clear();
+
+ foreach (Renderer renderer in clone.GetComponentsInChildren(true))
+ {
+ Material[] materials = renderer.sharedMaterials;
+ if (materials == null) continue;
+
+ for (int i = 0; i < materials.Length; i++)
+ {
+ if (materials[i] == null) continue;
+
+ Material copy = new Material(materials[i]);
+ copy.name = materials[i].name + "_" + ItemName;
+ materials[i] = copy;
+ ownedMaterials.Add(copy);
+ }
+
+ renderer.sharedMaterials = materials;
+ }
+ }
+
+ ///
+ /// Repaints the claws. Called on the maintain tick as well as at registration, so a tint
+ /// driven by config moves while the game is running.
+ ///
+ /// Every colour property the shader turns out to have is written rather than guessing which
+ /// one it uses: writing a property a shader does not have is an error, writing all the ones
+ /// it does is free.
+ ///
+ public void RefreshTint()
+ {
+ if (Tint == null || ownedMaterials.Count == 0) return;
+
+ Color tint = Tint.Value;
+
+ foreach (Material material in ownedMaterials)
+ {
+ if (material == null) continue;
+
+ if (material.HasProperty("_Color")) material.SetColor("_Color", tint);
+ if (material.HasProperty("_BaseColor")) material.SetColor("_BaseColor", tint);
+ if (material.HasProperty("_MainColor")) material.SetColor("_MainColor", tint);
+
+ // A claw is not a lamp. Whatever the source model glowed with goes out, or the
+ // tint fights a bloom it cannot win against.
+ if (material.HasProperty("_EmissionColor")) material.SetColor("_EmissionColor", Color.black);
+ }
+
+ if (loggedMaterials) return;
+ loggedMaterials = true;
+
+ foreach (Material material in ownedMaterials)
+ {
+ if (material == null) continue;
+
+ List properties = new List();
+ foreach (string name in new[] { "_Color", "_BaseColor", "_MainColor", "_EmissionColor" })
+ {
+ if (material.HasProperty(name)) properties.Add(name);
+ }
+
+ Jotunn.Logger.LogInfo(
+ $"[{RaceId}] Claw material '{material.name}' shader " +
+ $"'{(material.shader != null ? material.shader.name : "none")}' " +
+ $"colour properties: {(properties.Count > 0 ? string.Join(", ", properties.ToArray()) : "none")}");
+ }
+ }
+
+ // ─── Issue and re-equip ──────────────────────────────────────────────
+
+ ///
+ /// Guards against re-entry, and it is not belt-and-braces - it is the fix for a crash the
+ /// Sverm hit first. Maintain equips the claws; Humanoid.EquipItem unequips the right hand
+ /// first, which fires the UnequipItem postfix, which calls Maintain... Mono answers an
+ /// unbounded recursion by killing the process outright, with no exception and a log file
+ /// that ends mid-word.
+ ///
+ private static bool maintaining;
+
+ ///
+ /// Makes sure the player owns exactly one pair and is holding them whenever both hands are
+ /// free. Safe to call on a timer: every step checks first.
+ ///
+ public void Maintain(Player player)
+ {
+ if (maintaining) return;
+ if (player == null || player != Player.m_localPlayer) return;
+ if (For(player) != this) return;
+ if (player.IsDead() || IsTransformed(player)) return;
+
+ maintaining = true;
+ try { MaintainInner(player); }
+ finally { maintaining = false; }
+ }
+
+ private void MaintainInner(Player player)
+ {
+ EnsureRegistered();
+ RefreshTint();
+
+ Inventory inventory = player.GetInventory();
+ if (inventory == null) return;
+
+ ItemDrop.ItemData claws = Find(inventory);
+
+ if (claws == null)
+ {
+ GameObject prefab = ObjectDB.instance != null ? ObjectDB.instance.GetItemPrefab(ItemName) : null;
+ if (prefab == null)
+ {
+ // The failure that cost the first version of this feature an evening. The item
+ // registers, logs its success, tints its materials - and is not in ObjectDB,
+ // because Jotunn only takes new items at OnVanillaPrefabsAvailable and this ran
+ // afterwards. It looked from the log exactly like everything had worked.
+ WarnOnce("missing-from-objectdb",
+ $"'{ItemName}' is registered but not in ObjectDB, so it cannot be issued. " +
+ "It has to be registered from CreateModAssets (PrefabManager.OnVanillaPrefabsAvailable), not later.");
+ return;
+ }
+
+ // The GameObject overload, deliberately: it is the one that is public in the
+ // shipped assembly, and this project compiles against that rather than against the
+ // publicized copy - so anything else would build here and not on a clean machine.
+ if (!inventory.AddItem(prefab, 1))
+ {
+ WarnOnce("inventory-full", $"No room in the inventory for the {DisplayName}; retrying.");
+ return;
+ }
+
+ claws = Find(inventory);
+ if (claws == null) return;
+
+ // Tidied into the bottom-right corner IF that corner is free, and left wherever the
+ // inventory put them otherwise. Nothing of the player's is ever displaced: an item
+ // that cannot be moved has no business shoving one that can.
+ Vector2i corner = new Vector2i(inventory.GetWidth() - 1, inventory.GetHeight() - 1);
+ if (corner.x >= 0 && ItemAt(inventory, corner.x, corner.y) == null)
+ {
+ claws.m_gridPos = corner;
+ }
+
+ Jotunn.Logger.LogInfo($"[{RaceId}] Issued the {DisplayName}.");
+ }
+
+ // Empty-handed means clawed. Anything else in the right hand wins until it is put away,
+ // which is the whole compromise.
+ ItemDrop.ItemData held = Traverse.Create((Humanoid)player).Field("m_rightItem").Value;
+ if (held == null && !player.InAttack())
+ {
+ player.EquipItem(claws, false);
+ }
+ }
+
+ private readonly HashSet warned = new HashSet();
+
+ ///
+ /// Says a thing once. The maintain tick runs twice a second, so a plain warning here is a
+ /// log file rather than a message - which is the other half of why this failure was silent.
+ ///
+ private void WarnOnce(string key, string message)
+ {
+ if (!warned.Add(key)) return;
+ Jotunn.Logger.LogWarning($"[{RaceId}] {message}");
+ }
+
+ ///
+ /// What is sitting at this grid position, read from the items themselves.
+ /// Inventory.GetItemAt is private in the shipped assembly, and every item already carries
+ /// its own m_gridPos, so a scan answers the same question with nothing but public members.
+ ///
+ private static ItemDrop.ItemData ItemAt(Inventory inventory, int x, int y)
+ {
+ foreach (ItemDrop.ItemData item in inventory.GetAllItems())
+ {
+ if (item != null && item.m_gridPos.x == x && item.m_gridPos.y == y) return item;
+ }
+ return null;
+ }
+
+ public ItemDrop.ItemData Find(Inventory inventory)
+ {
+ if (inventory == null) return null;
+
+ foreach (ItemDrop.ItemData item in inventory.GetAllItems())
+ {
+ if (IsClaws(item)) return item;
+ }
+ return null;
+ }
+
+ public bool IsClaws(ItemDrop.ItemData item)
+ {
+ if (item == null || item.m_shared == null) return false;
+ if (item.m_dropPrefab != null && item.m_dropPrefab.name == ItemName) return true;
+ return item.m_shared.m_name == DisplayName;
+ }
+
+ // ─── Damage ──────────────────────────────────────────────────────────
+
+ ///
+ /// The tier this player is fighting at. Remote players answer from their own ZDO where the
+ /// race publishes one; where it does not, this falls back to the local player's progression
+ /// - the same compromise SvermVisuals.GetRenderState makes, and it only ever matters for
+ /// somebody else's claws on a shared world.
+ ///
+ private int GetState(Player player)
+ {
+ if (player != null && player != Player.m_localPlayer && !string.IsNullOrEmpty(StateZdoKey))
+ {
+ ZNetView nview = player.GetComponent();
+ if (nview != null && nview.IsValid())
+ {
+ int remote = nview.GetZDO().GetInt(StateZdoKey, 0);
+ if (remote > 0)
+ {
+ return Mathf.Clamp(remote, BossProgressionManager.MinState, BossProgressionManager.MaxState);
+ }
+ }
+ }
+
+ return BossProgressionManager.GetCurrentProgressionState();
+ }
+
+ ///
+ /// Rewrites a bare-handed blow into a claw blow, as slash and nothing else.
+ ///
+ /// The figure is the Sverm's - its reference weapon at quality 4, times its percentage for
+ /// this tier - but where the Sverm keeps the weapon's own three-way split, this collapses
+ /// the whole physical total into slash. Claws cut. The total is preserved rather than the
+ /// slash component copied, so the three races stay worth the same and only the damage type
+ /// differs, which is the entire point of the exercise.
+ ///
+ public void ApplyToUnarmedHit(HitData hit, Player attacker)
+ {
+ if (hit == null || attacker == null) return;
+ if (IsTransformed(attacker)) return; // the form is doing its own damage
+
+ HitData.DamageTypes reference = SvermClaws.GetReferenceDamage();
+ float percent = SvermClaws.GetDamagePercent(GetState(attacker));
+ if (percent <= 0f) return;
+
+ float total = (reference.m_slash + reference.m_pierce + reference.m_blunt) * percent;
+
+ // Nothing to give: the reference item did not resolve. Leave vanilla's fist alone
+ // rather than zeroing the player's only attack.
+ if (total <= 0f) return;
+
+ hit.m_damage.m_slash = total;
+ hit.m_damage.m_pierce = 0f;
+ hit.m_damage.m_blunt = 0f;
+ }
+ }
+
+ // ─── Patches ─────────────────────────────────────────────────────────────
+
+ ///
+ /// Issues the claws and puts them back in hand. On a throttle rather than every frame: it is a
+ /// handful of checks that all short-circuit once the claws exist.
+ ///
+ [HarmonyPatch(typeof(Player), "Update")]
+ public static class RaceClaws_PlayerUpdate_Patch
+ {
+ private const float Interval = 0.5f;
+ private static float next;
+
+ public static void Postfix(Player __instance)
+ {
+ if (__instance != Player.m_localPlayer) return;
+ if (Time.time < next) return;
+ next = Time.time + Interval;
+
+ RaceClawSet set = RaceClawSet.For(__instance);
+ if (set != null) set.Maintain(__instance);
+ }
+ }
+
+ ///
+ /// Put anything else away and the claws come straight back. A postfix rather than a prefix: the
+ /// game is mid-way through tearing down the old item's visuals when a prefix would run, and
+ /// equipping there leaves the new item without a model.
+ ///
+ [HarmonyPatch(typeof(Humanoid), nameof(Humanoid.UnequipItem))]
+ public static class RaceClaws_UnequipItem_Patch
+ {
+ public static void Postfix(Humanoid __instance, ItemDrop.ItemData item)
+ {
+ // NULL IS THE IMPORTANT CASE. Humanoid.EquipItem calls UnequipItem(m_rightItem) before
+ // putting a weapon in the hand, and an empty hand means that argument is null. Without
+ // this line the postfix treats "nothing was unequipped" as "something was unequipped",
+ // and the recursion that follows kills the process silently.
+ if (item == null) return;
+
+ Player player = __instance as Player;
+ if (player == null || player != Player.m_localPlayer) return;
+
+ RaceClawSet set = RaceClawSet.For(player);
+ if (set == null) return;
+ if (set.IsClaws(item)) return; // do not re-equip what was just taken off
+
+ set.Maintain(player);
+ }
+ }
+
+ ///
+ /// The holster key cannot put the claws away. Refused only while the claws ARE the thing in
+ /// hand: holding a sword, R sheathes the sword normally and the unequip postfix hands the claws
+ /// back on the same action. So the key keeps working and simply never leaves the race
+ /// empty-handed.
+ ///
+ [HarmonyPatch(typeof(Humanoid), nameof(Humanoid.HideHandItems))]
+ public static class RaceClaws_HideHandItems_Patch
+ {
+ public static bool Prefix(Humanoid __instance)
+ {
+ Player player = __instance as Player;
+ if (player == null || player != Player.m_localPlayer) return true;
+
+ RaceClawSet set = RaceClawSet.For(player);
+ if (set == null) return true;
+
+ ItemDrop.ItemData held = Traverse.Create(__instance).Field("m_rightItem").Value;
+ return !set.IsClaws(held);
+ }
+ }
+
+ ///
+ /// The claws cannot be picked up with the mouse. SetupDragItem is the single door every manual
+ /// move goes through - within the inventory, out to a chest, onto the ground, into a crafting
+ /// slot - so refusing here closes all of them with one prefix.
+ ///
+ [HarmonyPatch(typeof(InventoryGui), "SetupDragItem")]
+ public static class RaceClaws_SetupDragItem_Patch
+ {
+ public static bool Prefix(ItemDrop.ItemData item)
+ {
+ if (RaceClawSet.SetOwning(item) == null) return true;
+
+ if (Player.m_localPlayer != null)
+ {
+ Player.m_localPlayer.Message(MessageHud.MessageType.Center, "They are part of your hands.");
+ }
+ return false;
+ }
+ }
+
+ ///
+ /// The tier's damage, on any bare-handed blow. Fist weapons report Unarmed, so this covers both
+ /// the equipped claws and an actually empty hand - which is what keeps the two halves of the
+ /// feature agreeing with each other.
+ ///
+ [HarmonyPatch(typeof(Character), nameof(Character.Damage))]
+ public static class RaceClaws_Damage_Patch
+ {
+ public static void Prefix(HitData hit)
+ {
+ if (hit == null || hit.m_skill != Skills.SkillType.Unarmed) return;
+
+ Player attacker = hit.GetAttacker() as Player;
+ if (attacker == null) return;
+
+ RaceClawSet set = RaceClawSet.For(attacker);
+ if (set == null) return;
+
+ set.ApplyToUnarmedHit(hit, attacker);
+ }
+ }
+}
diff --git a/JotunnModStub/RaceCompendium.cs b/JotunnModStub/RaceCompendium.cs
index 1004049..1305920 100644
--- a/JotunnModStub/RaceCompendium.cs
+++ b/JotunnModStub/RaceCompendium.cs
@@ -329,6 +329,9 @@ namespace RacesOfValheim
sb.AppendLine($"[Base Passive] Benedictus et Afflictus:");
sb.AppendLine($"Physical kills automatically consume enemies (Vae Victis) granting Blood Magic XP. Your physical stats scale progressively as you defeat Valheim's Bosses: +{arm} Armor, +{dmg} Damage, +{spd}% Speed, and +{jmp}% Jump. All your passive bonuses are doubled during the night. You can cast Blood Magic items with infinite Eitr, and your Blood Magic skill increases twice as fast.\n");
sb.AppendLine("Vampiric Aura (Like a Bat out of Hell/Weight of Shadows Only): Block with your shield (Mouse 2) while in bat or mist form to channel an AoE magic damage aura against nearby enemies, healing for 20% of the damage dealt and converting them into food when they die.\n");
+ // The live figure, so the entry cannot drift from the code: it is the same yardstick
+ // the Sverm's own claws are measured against, which is what keeps the three races even.
+ sb.AppendLine($"[Base Passive] Claws of the Beast: Blackened claws you did not forge and cannot put down. Bare-handed blows land at {SvermClaws.GetDamagePercent(state) * 100f:0}% of a full-grown pair's weight, all of it as slash, and they grow with every boss that falls. Draw a sword and they wait; sheathe it and they are back. They cannot be dropped, traded or stolen - and in bat or mist form you have no hands to hold them with.\n");
if (state >= 1)
{
// Eikthyr - Base passives already covered
@@ -369,7 +372,8 @@ namespace RacesOfValheim
int jmp = state * 3;
int arm = state * 3;
int dmg = state * 5;
- knownTexts["Fenrir Secrets"] = $"The secrets of the pack will be revealed soon...\n\nBase Passive: Physical kills automatically consume enemies (if edible). Your physical stats scale progressively as you defeat Valheim's Bosses: +{arm} Armor, +{dmg} Damage, +{spd}% Speed, and +{jmp}% Jump.";
+ knownTexts["Fenrir Secrets"] = $"The secrets of the pack will be revealed soon...\n\nBase Passive: Physical kills automatically consume enemies (if edible). Your physical stats scale progressively as you defeat Valheim's Bosses: +{arm} Armor, +{dmg} Damage, +{spd}% Speed, and +{jmp}% Jump.\n\n" +
+ $"[Base Passive] Cursed Claws: The wolf's hands, kept on in the man's shape. Bare-handed blows land at {SvermClaws.GetDamagePercent(state) * 100f:0}% of a full-grown pair's weight, all of it as slash, and they grow with every boss that falls. Draw a sword and they wait; sheathe it and they are back. They cannot be dropped, traded or stolen - and in beast form the jaws do the work instead.";
}
private static void GenerateSkadiText(Dictionary knownTexts, int state)
diff --git a/JotunnModStub/Skeleton/SkeletonEyeGlow.cs b/JotunnModStub/Skeleton/SkeletonEyeGlow.cs
new file mode 100644
index 0000000..03356c9
--- /dev/null
+++ b/JotunnModStub/Skeleton/SkeletonEyeGlow.cs
@@ -0,0 +1,264 @@
+using System.Collections.Generic;
+using Jotunn.Managers;
+using UnityEngine;
+
+namespace RacesOfValheim
+{
+ ///
+ /// The lights in the eye sockets, taken from the creature the tier's body is borrowed from.
+ ///
+ /// The body swap copies SkinnedMeshRenderers and nothing else, which is the whole of the mesh
+ /// but none of the effects hung off the creature's rig - so the race wore a skull with two
+ /// empty holes where the mob it is wearing has a lit pair. Every part of that lighting is
+ /// authored per creature, and the tiers wear three different creatures (Skeleton,
+ /// Skeleton_Poison, Skeleton_Hildir) with three different colours, so nothing here names a
+ /// colour: each tier's glow is cloned out of that tier's own prefab and arrives already the
+ /// right one.
+ ///
+ /// What counts as "the eye lights" is deliberately broad - any Light, any ParticleSystem, and
+ /// any mesh whose object is named for an eye - because which of the three a given creature
+ /// uses is the creature's business, not ours. Everything cloned is logged once per model, so
+ /// if a tier turns out to carry something this misses, the log says exactly what it carries.
+ ///
+ /// Each clone is parented to the player bone its own parent maps onto - the same by-name
+ /// mapping the body itself is skinned through - and keeps the local pose it had on the
+ /// creature, so it sits where the creature wore it and rides the head animation for free.
+ ///
+ public static class SkeletonEyeGlow
+ {
+ // Every clone carries this, followed by the model it came from: the sweep below uses the
+ // name alone to tell its own work from a previous tier's and from everyone else's.
+ private const string Prefix = "SkeletonEyeFX_";
+
+ private static readonly HashSet loggedModels = new HashSet();
+
+ ///
+ /// Makes sure the player wears the eye lights of and of no
+ /// other tier. Cheap to call on every visual refresh: once the right ones are on, it does
+ /// nothing but the sweep.
+ ///
+ public static void Apply(VisEquipment vis, string modelName)
+ {
+ Transform[] bones = GetBones(vis);
+ if (bones == null || string.IsNullOrEmpty(modelName)) return;
+
+ string wanted = Prefix + modelName + "_";
+ if (Sweep(bones, wanted)) return; // already wearing this tier's
+
+ GameObject source = PrefabManager.Cache.GetPrefab(modelName);
+ if (source == null) return; // the body swap already warns about a missing model
+
+ LogSourceEffectsOnce(modelName, source);
+
+ foreach (GameObject effect in CollectEffects(source))
+ {
+ Transform parentBone = ResolveParentBone(bones, effect.transform);
+ if (parentBone == null) continue;
+
+ Clone(effect, parentBone, wanted);
+ }
+ }
+
+ /// Takes every cloned light back off, for a player who is no longer a Skeleton.
+ public static void Clear(VisEquipment vis)
+ {
+ Transform[] bones = GetBones(vis);
+ if (bones == null) return;
+
+ Sweep(bones, null);
+ }
+
+ private static Transform[] GetBones(VisEquipment vis)
+ {
+ if (vis == null || vis.m_bodyModel == null) return null;
+ return vis.m_bodyModel.bones;
+ }
+
+ ///
+ /// Destroys clones that do not belong to and reports whether
+ /// any that do are already in place. Pass null to clear the lot.
+ ///
+ private static bool Sweep(Transform[] bones, string keepPrefix)
+ {
+ bool present = false;
+
+ foreach (Transform bone in bones)
+ {
+ if (bone == null) continue;
+
+ for (int i = bone.childCount - 1; i >= 0; i--)
+ {
+ Transform child = bone.GetChild(i);
+ if (!child.name.StartsWith(Prefix)) continue;
+
+ if (keepPrefix != null && child.name.StartsWith(keepPrefix))
+ {
+ present = true;
+ continue;
+ }
+
+ // Renamed before it goes: Destroy only takes effect at the end of the frame,
+ // and until then this sweep would keep finding it and counting it as present.
+ child.name = child.name + "_Removed";
+ Object.Destroy(child.gameObject);
+ }
+ }
+
+ return present;
+ }
+
+ ///
+ /// The objects on a creature worth bringing across. Depth first, and a match swallows its
+ /// own subtree - a light with a particle system under it is one clone, not two.
+ ///
+ private static List CollectEffects(GameObject source)
+ {
+ List found = new List();
+ HashSet taken = new HashSet();
+
+ foreach (Transform t in source.GetComponentsInChildren(true))
+ {
+ if (!IsEffect(t)) continue;
+
+ bool insideOne = false;
+ for (Transform parent = t.parent; parent != null; parent = parent.parent)
+ {
+ if (taken.Contains(parent)) { insideOne = true; break; }
+ }
+ if (insideOne) continue;
+
+ taken.Add(t);
+ found.Add(t.gameObject);
+ }
+
+ return found;
+ }
+
+ private static bool IsEffect(Transform t)
+ {
+ if (t.GetComponent() != null) return true;
+ if (t.GetComponent() != null) return true;
+
+ // Meshes are taken by name only. A creature's non-skinned meshes are mostly the
+ // weapons in its hands, and a player who sprouts a second sword out of their wrist is
+ // a worse bug than a missing glow.
+ return t.name.ToLower().Contains("eye") && t.GetComponent() != null;
+ }
+
+ ///
+ /// The player bone a creature's effect should hang from: whatever its own parent chain
+ /// first matches by name. No root fallback - an effect nobody can place is better left
+ /// off than dropped on the pelvis.
+ ///
+ private static Transform ResolveParentBone(Transform[] bones, Transform effect)
+ {
+ for (Transform parent = effect.parent; parent != null; parent = parent.parent)
+ {
+ Transform match = SkeletonPatches.VisEquipment_UpdateVisuals_Patch.FindBoneByName(bones, parent.name);
+ if (match != null) return match;
+ }
+
+ return null;
+ }
+
+ private static void Clone(GameObject source, Transform parentBone, string namePrefix)
+ {
+ GameObject copy = Object.Instantiate(source, parentBone);
+ copy.name = namePrefix + source.name;
+
+ // The pose it was authored at on the creature. Instantiate keeps the world transform,
+ // which for a prefab means nothing useful.
+ copy.transform.localPosition = source.transform.localPosition;
+ copy.transform.localRotation = source.transform.localRotation;
+ copy.transform.localScale = source.transform.localScale;
+
+ // Allowlist, not a blocklist - the same rule the head flame is built under. Whatever
+ // else rode along (an AnimEvent, a collider, a script that expects a Character above
+ // it) goes, whatever type it turns out to be; what is left is a light and the things
+ // that draw it.
+ foreach (Component comp in copy.GetComponentsInChildren(true))
+ {
+ if (comp is Transform || comp is Light || comp is ParticleSystem ||
+ comp is ParticleSystemRenderer || comp is MeshRenderer || comp is MeshFilter)
+ {
+ continue;
+ }
+
+ Object.Destroy(comp);
+ }
+
+ // A creature can leave its own effects switched off for a script to turn on later, and
+ // that script is exactly what was just destroyed.
+ copy.SetActive(true);
+ foreach (Light light in copy.GetComponentsInChildren(true)) light.enabled = true;
+ foreach (Renderer renderer in copy.GetComponentsInChildren(true)) renderer.enabled = true;
+ }
+
+ ///
+ /// Says what a creature actually carries, once per model per session.
+ ///
+ /// Which of the three shapes a glow is authored as is not something to guess at, and if a
+ /// tier arrives here with none of them, the emission on its skinned materials - printed
+ /// below - is the remaining answer to where its eyes get their colour.
+ ///
+ private static void LogSourceEffectsOnce(string modelName, GameObject source)
+ {
+ if (!loggedModels.Add(modelName)) return;
+
+ Jotunn.Logger.LogInfo($"[Skeleton] Eye glow: reading '{modelName}'.");
+
+ int count = 0;
+ foreach (Transform t in source.GetComponentsInChildren(true))
+ {
+ Light light = t.GetComponent();
+ if (light != null)
+ {
+ count++;
+ Jotunn.Logger.LogInfo(
+ $"[Skeleton] Light '{t.name}' under '{(t.parent != null ? t.parent.name : "-")}' " +
+ $"color={light.color} intensity={light.intensity:F2} range={light.range:F2} " +
+ $"active={t.gameObject.activeSelf}");
+ }
+
+ ParticleSystem ps = t.GetComponent();
+ if (ps != null)
+ {
+ count++;
+ Jotunn.Logger.LogInfo(
+ $"[Skeleton] ParticleSystem '{t.name}' under '{(t.parent != null ? t.parent.name : "-")}' " +
+ $"startColor={ps.main.startColor.color} active={t.gameObject.activeSelf}");
+ }
+
+ MeshRenderer mesh = t.GetComponent();
+ if (mesh != null)
+ {
+ count++;
+ Jotunn.Logger.LogInfo(
+ $"[Skeleton] MeshRenderer '{t.name}' under '{(t.parent != null ? t.parent.name : "-")}' " +
+ $"material='{(mesh.sharedMaterial != null ? mesh.sharedMaterial.name : "none")}' " +
+ $"active={t.gameObject.activeSelf}");
+ }
+ }
+
+ if (count == 0)
+ {
+ Jotunn.Logger.LogInfo("[Skeleton] no lights, particles or loose meshes at all.");
+ }
+
+ foreach (SkinnedMeshRenderer smr in source.GetComponentsInChildren(true))
+ {
+ foreach (Material material in smr.sharedMaterials)
+ {
+ if (material == null) continue;
+
+ string emission = material.HasProperty("_EmissionColor")
+ ? material.GetColor("_EmissionColor").ToString()
+ : "no _EmissionColor";
+ Jotunn.Logger.LogInfo(
+ $"[Skeleton] skin '{smr.name}' material '{material.name}' shader '{material.shader?.name}' " +
+ $"emission={emission} keyword={material.IsKeywordEnabled("_EMISSION")}");
+ }
+ }
+ }
+ }
+}
diff --git a/JotunnModStub/Skeleton/SkeletonJawFix.cs b/JotunnModStub/Skeleton/SkeletonJawFix.cs
new file mode 100644
index 0000000..8f9860d
--- /dev/null
+++ b/JotunnModStub/Skeleton/SkeletonJawFix.cs
@@ -0,0 +1,114 @@
+using UnityEngine;
+
+namespace RacesOfValheim
+{
+ ///
+ /// Poses the Skeleton's mandible, which the player rig alone puts in the wrong place.
+ ///
+ /// The three skeleton models are skinned to the player rig by bone name, and the rig owns a
+ /// real 'Jaw' bone, so the mandible lands on the right bone - just at the rest pose that bone
+ /// happens to hold, which sits a little low and a little far back for a skull. Nothing here
+ /// remaps anything: it moves that one bone, and only that one.
+ ///
+ /// THE POSE IS WRITTEN ABSOLUTELY, NEVER ACCUMULATED. That distinction is the whole reason
+ /// this file reads the way it does. No Valheim animation touches the Jaw bone, so nothing
+ /// resets it between frames: an earlier version added its offset to whatever the bone already
+ /// held, on the usual assumption that the Animator rewrites the rig every frame. It does not,
+ /// so the jaw drifted a few centimetres further away every frame - it left the skull entirely
+ /// within a fifth of a second, snapped back when a visual refresh happened to rebind the rig,
+ /// and started over, which is what showed up in game as a head flickering five times a second.
+ /// With the game paused nothing rebound anything and the mandible simply kept going, dragging
+ /// the vertices weighted to it into a metres-long spike. Writing the base pose back before
+ /// applying the correction makes the whole thing idempotent: applied once, five times or not
+ /// at all in a given frame, the jaw ends up in exactly the same place.
+ ///
+ /// Runs in LateUpdate, after the animation phase, so the correction cannot be undone by an
+ /// animation that does move the head around the jaw.
+ ///
+ /// Attached to every player VisEquipment rebuilds visuals for - local, remote and the
+ /// main-menu preview - so the jaw is right for everyone looking, not just for the client
+ /// wearing it.
+ ///
+ public class SkeletonJawFix : MonoBehaviour
+ {
+ // Found in game with a temporary set of Configuration Manager sliders, on the tier-3
+ // Skeleton_Poison model; the plain and the fire models share the rig and the same jaw rest
+ // pose bone for bone (confirmed in the bone-mapping dump), so one correction covers all
+ // three. Metres along the skull's own axes, so the mandible keeps following the head
+ // however it turns.
+ private static readonly Vector3 Offset = new Vector3(0.0338f, 0.0394f, 0f);
+
+ // The rig's jaw is a touch large for these skulls.
+ private const float Scale = 0.9437f;
+
+ private Player m_player;
+ private VisEquipment m_vis;
+
+ private Transform m_jaw;
+ private Vector3 m_baseLocalPosition;
+ private Vector3 m_baseLocalScale;
+ private bool m_applied;
+
+ private void Awake()
+ {
+ m_player = GetComponent();
+ m_vis = GetComponent();
+ }
+
+ private void LateUpdate()
+ {
+ if (m_player == null || m_vis == null) return;
+
+ Transform jaw = ResolveJaw();
+ if (jaw == null || jaw.parent == null) return;
+
+ if (!SkeletonVisuals.IsSkeletonPlayer(m_player))
+ {
+ // Nothing rewrites this bone on its own, so a player who stops being a Skeleton
+ // would otherwise keep wearing the correction on their human face.
+ if (m_applied)
+ {
+ jaw.localPosition = m_baseLocalPosition;
+ jaw.localScale = m_baseLocalScale;
+ m_applied = false;
+ }
+ return;
+ }
+
+ // Back to the rest pose first: this is what makes the block below absolute rather than
+ // a nudge on top of last frame's nudge. See the note in the class summary.
+ jaw.localPosition = m_baseLocalPosition;
+ jaw.localScale = m_baseLocalScale * Scale;
+
+ // In world space rather than localPosition, so the offset stays in metres whatever the
+ // rig's authored scale is, and rotated by the skull so it tracks the head.
+ jaw.position += jaw.parent.rotation * Offset;
+
+ m_applied = true;
+ }
+
+ ///
+ /// The player rig's own jaw bone, with the rest pose it holds before anything here has
+ /// touched it. Captured once per bone: re-reading it later would sample a pose this
+ /// component had already moved and bake the correction in twice.
+ ///
+ private Transform ResolveJaw()
+ {
+ if (m_jaw != null) return m_jaw;
+ if (m_vis.m_bodyModel == null || m_vis.m_bodyModel.bones == null) return null;
+
+ foreach (Transform bone in m_vis.m_bodyModel.bones)
+ {
+ if (bone == null || !bone.name.ToLower().Contains("jaw")) continue;
+
+ m_jaw = bone;
+ m_baseLocalPosition = bone.localPosition;
+ m_baseLocalScale = bone.localScale;
+ m_applied = false;
+ break;
+ }
+
+ return m_jaw;
+ }
+ }
+}
diff --git a/JotunnModStub/Skeleton/SkeletonPatches.cs b/JotunnModStub/Skeleton/SkeletonPatches.cs
index af36923..1e343f6 100644
--- a/JotunnModStub/Skeleton/SkeletonPatches.cs
+++ b/JotunnModStub/Skeleton/SkeletonPatches.cs
@@ -338,6 +338,21 @@ namespace RacesOfValheim
HideItemInstances(__instance, "m_hairItemInstance");
HideItemInstances(__instance, "m_beardItemInstance");
SetHelmetVisible(__instance, false);
+
+ // Poses the mandible, once per frame, after the animation. Attached from
+ // here rather than from SkeletonRace because this postfix is the one path
+ // every skeleton reaches - local, remote and the menu preview - and the
+ // jaw is a rig bone, so whoever is looking sees the same face.
+ if (p.GetComponent() == null)
+ {
+ p.gameObject.AddComponent();
+ }
+
+ // The lights in the eye sockets, cloned out of this tier's own creature so
+ // that each one arrives its own colour. Outside the build block above on
+ // purpose: they hang off the player's rig bones rather than off the body
+ // container, so they outlive it and have to be checked every refresh.
+ SkeletonEyeGlow.Apply(__instance, rules.ModelPrefab);
}
}
else
@@ -362,6 +377,10 @@ namespace RacesOfValheim
ShowItemInstances(__instance, "m_hairItemInstance");
ShowItemInstances(__instance, "m_beardItemInstance");
SetHelmetVisible(__instance, true);
+
+ // Parented to rig bones, not to the body container that was just switched
+ // off above - so without this a human keeps the skeleton's lit sockets.
+ SkeletonEyeGlow.Clear(__instance);
}
}
}
@@ -514,7 +533,12 @@ namespace RacesOfValheim
}
}
- private static Transform FindBoneByName(Transform[] bones, string skelBoneName)
+ ///
+ /// The player bone a creature's bone maps onto. Internal because the eye glow hangs
+ /// its clones off the same mapping the body is skinned through - one answer to
+ /// "which bone is this", not two that can drift apart.
+ ///
+ internal static Transform FindBoneByName(Transform[] bones, string skelBoneName)
{
// Exact match first
foreach (Transform b in bones)
diff --git a/JotunnModStub/Sverm/SvermClaws.cs b/JotunnModStub/Sverm/SvermClaws.cs
index 88acd56..5b01176 100644
--- a/JotunnModStub/Sverm/SvermClaws.cs
+++ b/JotunnModStub/Sverm/SvermClaws.cs
@@ -71,8 +71,12 @@ namespace RacesOfValheim
///
/// The vanilla weapon's damage at quality 4, read once. This is the ceiling the tier
/// percentages are a fraction of, and state 7 is 100% of it - the real Maulclaws.
+ ///
+ /// Public because it is the shared yardstick: the Aswid's and the Fenrir's claws
+ /// (RaceClawSet) are balanced against this same figure rather than against the models they
+ /// happen to wear, so all three races hit for the same numbers at the same tier.
///
- private static HitData.DamageTypes GetReferenceDamage()
+ public static HitData.DamageTypes GetReferenceDamage()
{
if (referenceRead) return referenceDamage;
diff --git a/README.md b/README.md
index 4cca570..ece9a78 100644
--- a/README.md
+++ b/README.md
@@ -10,6 +10,7 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing

- **Stamina-less Combat:** Skeletons use no stamina and do not have a stamina bar.
- **Undead Diet:** Cannot eat normal food. Max health increases automatically as you defeat bosses to make up for lack of food buffs.
+- **Lit Sockets:** Your skull carries the eye lights of the creature your tier is built from, in that creature's own colour — so they change as the body does.
### 2. Skadi

@@ -24,6 +25,7 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing

- **Beast Form:** Transform into a wolf-like beast.
- **Cultist Form:** Transform into a Cultist to use fire abilities.
+- **Cursed Claws:** The wolf's hands, kept on in the man's shape. They cannot be taken from you — draw a sword and the claws wait, sheathe it and they are back. Pure slash, growing with every boss.
- **Progression:** Forms grow as you defeat bosses, unlocking new powers and reducing cooldowns. Immune to fall damage.
### 4. Aswid
@@ -33,6 +35,8 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing
- **Blood Magic:** Block to activate a life-draining aura (radius doubled at night, only in Bat or Mist Form).
- **Blood Magic Mastery:** Cast Blood Magic items with infinite Eitr (health cost only).
- **Benedictus et Afflictus:** Passive speed/jump bonuses double at night.
+- **Claws of the Beast:** Blackened claws you did not forge and cannot put down. They cannot be taken from you — draw a sword and the claws wait, sheathe it and they are back. Pure slash, growing with every boss.
+- **Burning Eyes:** Spectral green sockets that hold a red glow only in the final stage, with smoke trailing off them.
- **Undead Vigor:** Infinite stamina. Consume the lifeforce of enemies instead of eating normal food.
### 5. Furling
@@ -90,14 +94,14 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing
Aswid Progression
-- **Base:** Benedictus et Afflictus. Progressive stats (+1 Armor, +2 Damage, +1% Speed, +1% Jump per boss). Passives are doubled at night. Blood magic items are free (health cost only). Physical kills auto-devour enemies for Blood Magic XP.
+- **Base:** Benedictus et Afflictus. Progressive stats (+1 Armor, +2 Damage, +1% Speed, +1% Jump per boss). Passives are doubled at night. Blood magic items are free (health cost only). Physical kills auto-devour enemies for Blood Magic XP. Claws of the Beast: permanent slash claws that climb with every boss. Eyes burn spectral green.
- **Eikthyr:** Bat Form (night only). Vampiric Aura (heal 20% on magic AoE).
- **The Elder:** Bat Form always.
- **Bonemass:** Auspex (Aura reveals wild creatures).
- **Moder:** Freezing Blood (immune to Freezing/Poison).
- **Yagluth:** Dominate (U) - Dominate enemies; Eclipse (J) - force night for 60s, 15 min cooldown.
- **The Queen:** Weight of Shadows (H) - immune to physical/poison, double aura, weak to fire/frost/spirit, breaks at sunrise.
-- **Fader:** Asmund (passive): Hair/beard black, +10% height, +30 physical damage.
+- **Fader:** Asmund (passive): Hair/beard black, +10% height, +30 physical damage. Your eyes finally turn red.
@@ -132,7 +136,7 @@ A comprehensive Valheim mod allowing you to play as unique races, each providing
Fenrir Progression
-- **Base:** +3 Armor, +5 Damage, -10% Fall Damage, +3% Speed/Jump per boss killed.
+- **Base:** +3 Armor, +5 Damage, -10% Fall Damage, +3% Speed/Jump per boss killed. Cursed Claws: permanent slash claws that climb with every boss.
- **Elder:** Wolf Form (night).
- **Bonemass:** Wolf Form (anytime). Ulv Form (night).
- **Moder:** Ulv Form (anytime). Fenring Form (night).
@@ -176,7 +180,7 @@ Right Mouse toggles flight. Glide towards aim, W = forward/climb, Shift+W = use
Skeleton Progression
-- **Base:** +50 Max Health. Undead Diet (cannot eat normal food, no stamina bar).
+- **Base:** +50 Max Health. Undead Diet (cannot eat normal food, no stamina bar). Lit eye sockets, in the colour of whichever skeleton your tier wears.
- **Eikthyr:** Poison Skeleton model, poison immunity, 5% lifesteal, +80 Max Health.
- **Elder:** 10% lifesteal, auto-stun first hit, +110 Max Health.
- **Bonemass:** 15% lifesteal, poison attacks, +140 Max Health.
@@ -292,6 +296,11 @@ Bug reports, feedback, ideas: [https://discord.gg/gbBEK2VTE](https://discord.gg/
### v1.5.0
+- **NEW - Claws for the Aswid and the Fenrir:** Both races now grow a permanent pair, on the same terms the Sverm has always had: issued once, never dropped or traded, back in hand the moment your hands are free, and refused by the holster key. The Aswid's **Claws of the Beast** are burned almost black; the Fenrir's **Cursed Claws** are the flesh rippers worn as the game made them.
+- **Claws - Balance:** All three clawed races are measured against **one** yardstick rather than against the models they wear, so the same tier is worth the same damage whichever race you are. The Aswid's and the Fenrir's land the whole of it as **slash**, where the Sverm splits it three ways and sets it alight at Fader. Neither pair counts while you are wearing another body — a bat, mist or a wolf does its own damage with its own hands.
+- **Aswid - Eyes:** Rebuilt out of the real thing: the eye lights vanilla skeletons wear, smoke and all, instead of two painted spheres. Spectral green for the whole climb, and the red is now held back for the final stage. Position, size, colour and smoke are all in Configuration Manager.
+- **Skeleton - Lit Sockets:** The skull now carries the eye lights of whichever creature its tier is built from, cloned from that creature's own prefab — so each tier arrives in its own colour rather than a colour picked by hand.
+- **Fix - Skeleton Mandible:** The jaw sat wrong on every tier, because the player rig's own jaw bone is not where a skull's belongs. Corrected once and for all, and the correction is written absolutely rather than nudged each frame — which is what had the head flickering five times a second and stretching into a spike whenever the game was paused.
- **NEW - Sverm Race:** The tenth race. Wears carapace instead of armour (never removable, always worth the next biome's full set, weightless), fights with permanent claws, is immune to poison but takes 40% more from blunt and fire, and is ignored by every invertebrate in the game from tier zero. After the Elder it stops being one body and becomes a colony.
- **NEW - The Colony (Sverm):** Build a Brood Mound and feed it whole stacks of food, wood or resin. Feeding is not instant — it digests into the nest's bank at a fixed rate. Spend that biomass, plus brood eggs the nest lays on a timer, on a roster of insect troops that follow you, walk home when dismissed and mend themselves. A Hive Market raised nearby is where everything is bought; growing the nest through its four stages opens the next rung of the roster. Vanilla beehives raised inside the nest's ten meters are taken over by the colony: twice the speed, three times the honey, royal jelly after Yagluth. Honey and royal jelly heal your insects instead of feeding the nest.
- **NEW - War Vulture (Flying Mount):** A vulture trophy on a stick that puts you on a real, network-visible flying bird. Left click to call it, click again for a controlled descent. Unlimited cruise, a limited sprint reserve on the run key that refills in mid-air, and its own bar under your stamina. Furling and Dvergar by default, configurable. No recipe yet while the flight is being proven — spawn it from the console.