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

@ -98,9 +98,9 @@ namespace RacesOfValheim
}
ItemDrop itemDrop = customWep.ItemPrefab.GetComponent<ItemDrop>();
itemDrop.m_itemData.m_shared.m_maxDurability = 6f;
itemDrop.m_itemData.m_shared.m_maxDurability = TrolConfig.LogWeaponMaxDurability.Value;
itemDrop.m_itemData.m_shared.m_useDurability = true;
itemDrop.m_itemData.m_shared.m_useDurabilityDrain = 1f;
itemDrop.m_itemData.m_shared.m_useDurabilityDrain = TrolConfig.LogWeaponDurabilityDrainPerHit.Value;
itemDrop.m_itemData.m_shared.m_destroyBroken = false;
itemDrop.m_itemData.m_shared.m_weight = 0f;
itemDrop.m_itemData.m_shared.m_equipDuration = 0.1f;
@ -121,12 +121,12 @@ namespace RacesOfValheim
if (RaceInput.Allowed)
{
if (Input.GetKeyDown(KeyCode.G))
if (TrolConfig.ThrowRockKey.Value.IsDown())
{
TryThrowRock();
}
if (Input.GetKeyDown(KeyCode.H))
if (TrolConfig.TrueFormKey.Value.IsDown())
{
TryTrueForm();
}
@ -217,7 +217,9 @@ namespace RacesOfValheim
if (visual != null)
{
Vector3 startScale = visual.transform.localScale;
float trueFormScale = BossProgressionManager.GetCurrentProgressionState() >= 7 ? 2.5f : 2.0f;
float trueFormScale = BossProgressionManager.GetCurrentProgressionState() >= 7
? TrolConfig.TrueFormScaleAdvanced.Value
: TrolConfig.TrueFormScaleNormal.Value;
Vector3 targetScale = new Vector3(trueFormScale, trueFormScale, trueFormScale);
while (elapsed < duration)
@ -277,7 +279,7 @@ namespace RacesOfValheim
private System.Collections.IEnumerator ThrowRockRoutine()
{
bool isTrueForm = Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode());
float throwRockCooldown = isTrueForm ? 15f : 60f;
float throwRockCooldown = isTrueForm ? TrolConfig.ThrowRockCooldownTrueForm.Value : TrolConfig.ThrowRockCooldown.Value;
var addedSE = Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_TrolThrowRockCooldown".GetStableHashCode(), true);
if (addedSE != null)
@ -323,8 +325,8 @@ namespace RacesOfValheim
if (rb != null)
{
// 3x speed to compensate for log weight/drag
rb.velocity = Player.m_localPlayer.GetLookDir() * 60f;
// Compensates for log weight/drag
rb.velocity = Player.m_localPlayer.GetLookDir() * TrolConfig.ThrowLogVelocity.Value;
// Add some slight rotation tumbling
rb.angularVelocity = new Vector3(10f, 5f, 0f);
}
@ -343,24 +345,24 @@ namespace RacesOfValheim
if (proj != null)
{
HitData hitData = new HitData();
hitData.m_damage.m_blunt = 25f; // Base troll rock
hitData.m_damage.m_blunt = TrolConfig.ThrowRockBaseDamage.Value;
if (BossProgressionManager.GetCurrentProgressionState() >= 4)
{
hitData.m_damage.m_blunt += 10f; // Bonemass bonus
hitData.m_damage.m_blunt += TrolConfig.ThrowRockBonemassBonus.Value;
}
if (BossProgressionManager.GetCurrentProgressionState() >= 6)
{
hitData.m_damage.m_blunt += 5f; // Yagluth bonus
hitData.m_damage.m_blunt += TrolConfig.ThrowRockYagluthBonus.Value;
}
if (isTrueForm)
{
hitData.m_damage.m_blunt += 40f; // True Form bonus
hitData.m_damage.m_blunt += TrolConfig.ThrowRockTrueFormBonus.Value;
}
hitData.SetAttacker(Player.m_localPlayer);
proj.Setup(Player.m_localPlayer, Player.m_localPlayer.GetLookDir() * 20f, -1f, hitData, null, null);
proj.Setup(Player.m_localPlayer, Player.m_localPlayer.GetLookDir() * TrolConfig.ThrowRockProjectileVelocity.Value, -1f, hitData, null, null);
}
}
}