feat(trol): make ability numbers and keybinds BepInEx-configurable

Adds TrolConfig.cs, following the established per-race pattern: one
Configuration Manager section per topic (Passive Combat, Throw Rock,
True Form, Log Weapon, Farming), plus the two ability keybinds (Throw
Rock, True Form). Defaults match the previous hardcoded constants
exactly.

Fixes a real sync risk found while wiring it: True Form's scale (2.0
normal / 2.5 at tier 7+) was hardcoded independently in two places - the
local transform routine in TrolRace and the remote-player sizing postfix
in TrolPatches. Both now read the same TrolConfig.TrueFormScaleNormal/
TrueFormScaleAdvanced, so a retuned value can no longer make a Trol one
size to themselves and another size to everyone else.

Tier-gate thresholds and the small hardcoded "normal size by tier" table
(1.2/1.25/1.30) stay untouched, same boundary drawn for every other
race's progression data.

Config sections stay bound alphabetically by race (Aswid, Draugh,
Dvergar, Fenrir, Furling, Skadi, Skeleton, Trenta, Trol) in
RacesOfValheim.Awake() - this is the last of the nine.
This commit is contained in:
kanym 2026-08-06 15:34:05 +02:00
commit 4b5d60d4b6
9 changed files with 170 additions and 35 deletions

View file

@ -149,7 +149,7 @@ namespace RacesOfValheim
float targetScale = ScaleForState(state);
if (isTrueFormActive)
{
targetScale = state >= 7 ? 2.5f : 2.0f;
targetScale = state >= 7 ? TrolConfig.TrueFormScaleAdvanced.Value : TrolConfig.TrueFormScaleNormal.Value;
}
if (!isLocal)
@ -204,18 +204,18 @@ namespace RacesOfValheim
string race = "Human"; ZNetView nview = __instance.GetComponent<ZNetView>(); if (nview != null && nview.IsValid()) race = nview.GetZDO().GetString("RacesOfValheim_Race", "Human"); else if (__instance.m_customData != null && __instance.m_customData.TryGetValue("Race", out string savedRace)) race = savedRace; if (race == "Trol")
{
// Base carry weight is 300. We add 200 to make it 500.
// Base carry weight is 300. We add a bonus to make it 500 by default.
// If they wear Megingjord, it will become 500 + 150 = 650.
__result += 200f;
__result += TrolConfig.CarryWeightBonusBase.Value;
int state = BossProgressionManager.GetCurrentProgressionState();
if (state >= 4)
{
__result += 50f; // After Bonemass
__result += TrolConfig.CarryWeightBonusBonemass.Value;
}
if (state >= 6)
{
__result += 50f; // After Yagluth
__result += TrolConfig.CarryWeightBonusYagluth.Value;
}
}
}
@ -228,9 +228,8 @@ namespace RacesOfValheim
{
if (__instance == Player.m_localPlayer && TrolRace.IsTrol())
{
// +3 Armor per progression state (boss defeated)
int state = BossProgressionManager.GetCurrentProgressionState();
__result += 3f * state;
__result += TrolConfig.ArmorBonusPerState.Value * state;
}
}
}