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.
This commit is contained in:
kanym 2026-08-04 00:22:58 +02:00
commit 5febc588ea
12 changed files with 287 additions and 219 deletions

View file

@ -32,7 +32,7 @@ namespace RacesOfValheim
gameObject.AddComponent<FurlingRace>();
gameObject.AddComponent<TrolRace>();
gameObject.AddComponent<DraughRace>();
gameObject.AddComponent<DvergurRace>();
gameObject.AddComponent<DvergarRace>();
PrefabManager.OnVanillaPrefabsAvailable += CreateAllModAssets;
CommandManager.Instance.AddConsoleCommand(new ResetRaceCommand());
CommandManager.Instance.AddConsoleCommand(new CheckProgressionCommand());
@ -74,8 +74,8 @@ namespace RacesOfValheim
player.GetSEMan().RemoveStatusEffect("SE_SkeletonStats".GetStableHashCode());
player.GetSEMan().RemoveStatusEffect("SE_SkadiStats".GetStableHashCode());
player.GetSEMan().RemoveStatusEffect("SE_SkadiCooldown".GetStableHashCode());
player.GetSEMan().RemoveStatusEffect(DvergurConfig.StatsSE.GetStableHashCode());
player.GetSEMan().RemoveStatusEffect(DvergurConfig.OverchargeSE.GetStableHashCode());
player.GetSEMan().RemoveStatusEffect(DvergarConfig.StatsSE.GetStableHashCode());
player.GetSEMan().RemoveStatusEffect(DvergarConfig.OverchargeSE.GetStableHashCode());
ZNetView nview = player.GetComponent<ZNetView>();
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", "Human");
@ -97,7 +97,7 @@ namespace RacesOfValheim
FurlingRace.Instance.CreateModAssets();
TrolRace.Instance.CreateModAssets();
DraughRace.Instance.CreateModAssets();
DvergurRace.Instance.CreateModAssets();
DvergarRace.Instance.CreateModAssets();
}
// --- RACE SELECTION UI ---
public void ShowRaceSelectionMenu()
@ -239,7 +239,7 @@ namespace RacesOfValheim
CreateRaceButtonWithConfirm("Draugh", new Vector2(450, -20), GetDraughIcon(), "A decaying undead warrior fueled by dark magic and extreme metal.", SelectDraugh);
// Row 3 (y = -140)
CreateRaceButtonWithConfirm("Dvergur", new Vector2(-450, -140), GetDvergurIcon(), "Small, stubborn smiths of the deep. Frail of frame, but masters of metal, mine and market.", SelectDvergur);
CreateRaceButtonWithConfirm("Dvergar", new Vector2(-450, -140), GetDvergarIcon(), "Small, stubborn smiths of the deep. Frail of frame, but masters of metal, mine and market.", SelectDvergar);
GUIManager.BlockInput(true);
}
@ -583,30 +583,30 @@ namespace RacesOfValheim
return null;
}
private void SelectDvergur()
private void SelectDvergar()
{
if (Player.m_localPlayer != null)
{
Player.m_localPlayer.m_customData["Race"] = DvergurConfig.RaceId;
Player.m_localPlayer.m_customData["Race"] = DvergarConfig.RaceId;
ZNetView nview = Player.m_localPlayer.GetComponent<ZNetView>();
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", DvergurConfig.RaceId);
if (nview != null && nview.IsValid()) nview.GetZDO().Set("RacesOfValheim_Race", DvergarConfig.RaceId);
Player.m_localPlayer.GetSEMan().AddStatusEffect(DvergurConfig.StatsSE.GetStableHashCode(), true);
Player.m_localPlayer.GetSEMan().AddStatusEffect(DvergarConfig.StatsSE.GetStableHashCode(), true);
// No SetSkinColor here: the tint is written onto the material by the UpdateColors
// postfix in DvergurPatches, which keys off the race and so needs nothing saved.
// postfix in DvergarPatches, which keys off the race and so needs nothing saved.
VisEquipment visEq = Player.m_localPlayer.GetComponent<VisEquipment>();
if (visEq != null)
{
visEq.GetType().GetMethod("UpdateVisuals", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
}
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Dvergur.");
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "You chose the path of the Dvergar.");
CloseRaceSelectionMenu();
}
}
private Sprite GetDvergurIcon()
private Sprite GetDvergarIcon()
{
GameObject prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("HelmetDverger")?.gameObject;
if (prefab == null) prefab = PrefabManager.Cache.GetPrefab<ItemDrop>("DvergrKeyFragment")?.gameObject;
@ -679,6 +679,11 @@ namespace RacesOfValheim
{
if (__instance == Player.m_localPlayer)
{
// Runs before anything reads the race, so the rest of this method - and the race
// check further down that would otherwise reopen the selection menu - sees the
// renamed id rather than the old one.
DvergarRace.MigrateLegacyRaceId(__instance);
if (__instance.m_customData.ContainsKey("FenrirCurse_Active") && __instance.m_customData["FenrirCurse_Active"] == "true")
{
__instance.GetSEMan().AddStatusEffect("SE_FenrirCurse".GetStableHashCode(), true);
@ -691,7 +696,7 @@ namespace RacesOfValheim
if (visEq != null) visEq.GetType().GetMethod("UpdateColors", System.Reflection.BindingFlags.Instance | System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Public)?.Invoke(visEq, null);
}
// The Dvergur needs no entry here: its tint is applied by the UpdateColors postfix
// The Dvergar needs no entry here: its tint is applied by the UpdateColors postfix
// every time Valheim refreshes the body, rather than being stored on the player.
// Check for Race Selection
@ -784,7 +789,7 @@ namespace RacesOfValheim
public override void Run(string[] args)
{
string prefabName = args.Length > 0 ? args[0] : DvergurConfig.DvergerPrefabName;
string prefabName = args.Length > 0 ? args[0] : DvergarConfig.DvergerPrefabName;
GameObject prefab = Jotunn.Managers.PrefabManager.Cache.GetPrefab<GameObject>(prefabName);
if (prefab == null)
{