fix(dvergur): correct the health malus, body scale and hood

Health: the malus was taken off Character.GetMaxHealth, which only made the
getter lie. Character.SetMaxHealth is the one thing that clamps current health
to the new maximum and it never saw a lower number, so the bar shrank while the
value stayed where it was. Player.SetMaxHealth also flashes the bar whenever the
new maximum is above GetMaxHealth(), so against a getter that always read low
every food tick looked like an increase and re-triggered the flash. Taking the
malus off Player.GetTotalFoodValue instead puts it upstream of both, and leaves
Valheim to do its own clamping on an honest number.

Scale: applied from the plugin MonoBehaviour, it was overwritten on the same
frame by Trol's Player.Update postfix, which forced every non-Trol player back
to scale 1. Sizing now happens in a postfix on that same method, the way the
Trol does it, and RaceScale records which races size themselves so they stop
undoing each other. This also fixes the Furling, which was losing the same race.

Hood: the Dverger Circlet is a metal band, not the hood, and instantiating a
skinned mesh leaves its bones pointing at the source prefab so it renders
nowhere. The headgear is now lifted off the Dvergr NPC and rebound to the
player's own bones by name, as the Skeleton does for whole bodies.

Skin is tinted to a dvergr grey, saved and restored through the same
OriginalSkinColor keys the other tinted races use.

Adds a dumpdverger console command: prefab contents live in the asset bundles
and cannot be read outside a running game, so this is how the hood mesh and the
per-star LevelEffects colours get identified.
This commit is contained in:
kanym 2026-08-02 22:58:11 +02:00
commit 79a54fb533
8 changed files with 388 additions and 118 deletions

View file

@ -35,21 +35,27 @@ namespace RacesOfValheim
// is set to zero, and would bake the old value into any assembly built against this one.
public static readonly float VisualScale = 0.70f; // -30% versus a human
// ─── Skin ────────────────────────────────────────────────────────────
// Tint applied over the human skin texture, the same multiplicative m_skinColor the
// Furling and Trol use. Ashen grey with a blue cast, to read as one of the deep folk.
public static readonly Vector3 SkinColor = new Vector3(0.72f, 0.74f, 0.82f);
// ─── Cosmetic hood ───────────────────────────────────────────────────
// The helmet slot itself stays free — whatever the player equips keeps all of its stats,
// only the mesh is swapped. Tried in order; the first prefab that resolves wins.
public static readonly string[] HoodPrefabCandidates =
{
"HelmetDverger", // Dverger circlet item
"helmet_dverger", // its attach visual, if the item prefab is unavailable
"Dverger" // last resort: lift the headgear renderer off the creature
};
// only the mesh is swapped.
//
// The hood is lifted straight off the Dvergr NPC rather than off the Dverger Circlet item:
// the circlet is a metal band, not the hood the race is meant to wear.
public const string DvergerPrefabName = "Dverger";
// Valheim rigs are authored at scale 100, hence the very small numbers. Tuned against
// the head bone, same approach as the Furling trophy head.
public static readonly Vector3 HoodLocalPosition = new Vector3(0f, 0.0012f, 0f);
public static readonly Vector3 HoodLocalRotation = new Vector3(-90f, 0f, 90f);
public static readonly float HoodLocalScale = 0.0075f;
// Matched against renderer object names inside that prefab, lowercased, by Contains.
public static readonly string[] HoodRendererNames = { "hat", "hood", "helmet", "cap" };
// Applied on top of whatever the rig positions the hood at. Identity is correct when the
// bone remap succeeds; these exist so a stubborn mesh can be nudged without a code change.
public static readonly Vector3 HoodOffsetPosition = Vector3.zero;
public static readonly Vector3 HoodOffsetRotation = Vector3.zero;
public static readonly float HoodExtraScale = 1f;
// ─── Health malus ────────────────────────────────────────────────────