RacesOfValheim/JotunnModStub/RaceScale.cs
kanym 5febc588ea feat(dvergar): rename from Dvergur, and give it a lightning affinity
Rename covers the folder, all seven filenames and every identifier, status
effect name and display string. Valheim's own Dverger/dvergr prefab references
are untouched - the names never collided.

The race id is what sits in m_customData and the ZDO, so renaming it alone would
have handed every existing character the selection menu again. DvergarRace
migrates the old id on spawn, before anything else reads it.

Runic Spark is modelled on Skadi's Ice Affinity and deliberately shares its
shape: live from the base tier and growing a flat step per progression state, so
+2 at Base through +16 after Fader. Lightning rather than frost, and like
Skadi's it rides every blow rather than melee only. AddFlat gained the elemental
channels while it was there - lightning would otherwise have landed in generic
damage.

The Trol remote-sync trace fired on a two-second timer for as long as a remote
player existed, which in the main menu is forever: Player.m_localPlayer is null
there, so the character preview counts as remote and it never stopped. Keyed on
the state it reports instead, so it still catches a remote player being sized
wrongly without narrating an idle menu.
2026-08-04 00:22:58 +02:00

35 lines
1.2 KiB
C#

namespace RacesOfValheim
{
/// <summary>
/// Which races size their own body.
///
/// Several races postfix Player.Update and set the player's "Visual" scale from there. Each of
/// them also wants to undo that scale once the player is no longer of their race, and the
/// straightforward way to write that - "if this isn't my race, force the scale back to 1" -
/// makes every such race stamp on every other one, with the winner decided by whichever
/// postfix Harmony happened to run last.
///
/// That is what left the Dvergar at full height: Trol's reset ran on the same frame and put it
/// straight back to 1. Asking here first means a race only ever resets a player that nobody
/// else is sizing.
/// </summary>
public static class RaceScale
{
private static readonly string[] SelfSizingRaces =
{
"Trol",
"Furling",
DvergarConfig.RaceId
};
public static bool ManagesOwnScale(string race)
{
if (string.IsNullOrEmpty(race)) return false;
foreach (string self in SelfSizingRaces)
{
if (race == self) return true;
}
return false;
}
}
}