RacesOfValheim/JotunnModStub/Trenta/TrentaConfigManagement.cs
kanym 14648aaf62 feat(trenta): make ability numbers and keybinds BepInEx-configurable
Adds TrentaConfigManagement.cs rather than reusing the TrentaConfig name,
same reasoning as DvergarConfigManagement: that existing class holds
identity constants that must never change (RaceId, status effect and
prefab names), hand-tuned cosmetic placement numbers (skin colour, crown
position), and design-time tables (HealthBonusByState, the per-biome
AwakenedSeedFoods list) left alone under the same boundary drawn for
every other race's progression table.

Only the genuine ability knobs move: Photosynthesis, Purple Rain, Last
Stand/Thorns, Homecoming Portal, Hornet's Nest, Muspell, and the vegan
food duration bonus each get a Configuration Manager section, plus the
three transform/ability keybinds (Purple Rain, Portal, Muspell).
TrentaConfig's fields for those now forward to TrentaConfigManagement
(same const-to-property trick used for Skadi and Dvergar), so every
existing call site kept working unchanged except the three keybind
consumers in TrentaAbilities, which now read the live configured key.

Fixes a BepInEx startup crash caught while testing: the Hornet's Nest
section name used a straight ASCII apostrophe, which
ConfigDefinition.CheckInvalidConfigChars rejects outright (section/key
names may not contain = \n \t \ " ' [ ]). Switched to the typographic
apostrophe (U+2019), which reads the same and isn't on the forbidden list.

Config sections stay bound alphabetically by race (Aswid, Draugh,
Dvergar, Fenrir, Furling, Skadi, Skeleton, Trenta) in
RacesOfValheim.Awake().
2026-08-06 15:20:10 +02:00

155 lines
12 KiB
C#
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using UnityEngine;
using BepInEx.Configuration;
namespace RacesOfValheim
{
/// <summary>
/// The BepInEx-configurable slice of the Trenta's numbers, bound as ConfigEntry so they show
/// up in Configuration Manager without touching code - see CONFIGURATION-MANAGER-HOWTO.md.
/// Bound once, from RacesOfValheim.Awake(). One section per topic (matches every other race's
/// layout).
///
/// Named separately from the pre-existing TrentaConfig (rather than folding into it), same
/// reasoning as DvergarConfigManagement: that class is a different kind of thing - identity
/// constants that must never change once a player has the race (RaceId, status effect and
/// prefab names - renaming them would orphan saved characters or break asset lookups),
/// hand-tuned cosmetic placement numbers (skin colour, crown position), and design-time data
/// tables (HealthBonusByState, the per-biome AwakenedSeedFoods list) left alone under the same
/// boundary drawn for every other race's progression table. Only the genuine ability knobs -
/// Photosynthesis, Purple Rain, Last Stand/Thorns, Homecoming Portal, Hornet's Nest, Muspell,
/// and the vegan food duration bonus - plus the three transform/ability keybinds, belong here.
/// TrentaConfig's own fields for those now forward to this class (same const-to-property trick
/// used for Skadi and Dvergar), so every existing call site kept working unchanged except the
/// three keybind consumers in TrentaAbilities, which now read the live configured key.
///
/// Everything here is read live on every use - TrentaProgression.GetRules only caches
/// HealthBonus (from the untouched table above), so none of this needs a relog to take effect.
/// </summary>
public static class TrentaConfigManagement
{
// ─── Keybinds ──────────────────────────────────────────────────────────
public static ConfigEntry<KeyboardShortcut> PurpleRainKey;
public static ConfigEntry<KeyboardShortcut> PortalKey;
public static ConfigEntry<KeyboardShortcut> MuspellKey;
// ─── Photosynthesis (tier 1+, passive) ───────────────────────────────
public static ConfigEntry<float> PhotosynthesisStillnessSeconds;
public static ConfigEntry<int> PhotosynthesisHealSeconds;
public static ConfigEntry<float> PhotosynthesisHealPercentPerSecond;
public static ConfigEntry<float> PhotosynthesisRestBaseMinutes;
public static ConfigEntry<float> PhotosynthesisRestMinutesPerBoss;
// ─── Purple Rain (tier 3+) ────────────────────────────────────────────
public static ConfigEntry<float> PurpleRainCooldown;
public static ConfigEntry<float> MuspellPurpleRainCooldown;
public static ConfigEntry<float> PurpleRainRadius;
public static ConfigEntry<float> PurpleRainHealAmount;
public static ConfigEntry<float> PurpleRainPoisonDamage;
// ─── Last Stand & Thorns (tier 5+) ────────────────────────────────────
public static ConfigEntry<float> LastStandMaxArmorBonus;
public static ConfigEntry<float> ThornsReflectPercent;
// ─── Homecoming Portal (tier 6+) ──────────────────────────────────────
public static ConfigEntry<float> PortalCooldown;
public static ConfigEntry<float> PortalLifetime;
public static ConfigEntry<float> PortalSpawnDistance;
// ─── Hornet's Nest (tier 7+, passive) ─────────────────────────────────
public static ConfigEntry<float> HornetsNestDamagePerTick;
public static ConfigEntry<float> HornetsNestTickInterval;
public static ConfigEntry<float> HornetsNestEngageRadius;
public static ConfigEntry<float> HornetsNestFollowSpeed;
public static ConfigEntry<float> HornetsNestOrbitRadius;
public static ConfigEntry<float> HornetsNestAttackHeight;
// ─── Muspell (tier 8) ──────────────────────────────────────────────────
public static ConfigEntry<float> MuspellScale;
public static ConfigEntry<float> MuspellStompDamage;
public static ConfigEntry<float> MuspellStompRadius;
public static ConfigEntry<float> MuspellSpikeDamage;
public static ConfigEntry<float> MuspellSpikeVelocity;
// ─── Diet ──────────────────────────────────────────────────────────────
public static ConfigEntry<float> FoodDurationMultiplier;
public static void Bind(ConfigFile config)
{
const string keybinds = "Trenta - Keybinds";
PurpleRainKey = config.Bind(keybinds, "Purple Rain", new KeyboardShortcut(KeyCode.G),
new ConfigDescription("Casts Purple Rain, tier 3+."));
PortalKey = config.Bind(keybinds, "Homecoming Portal", new KeyboardShortcut(KeyCode.H),
new ConfigDescription("Opens the Homecoming Portal pair, tier 6+."));
MuspellKey = config.Bind(keybinds, "Muspell Form", new KeyboardShortcut(KeyCode.J),
new ConfigDescription("Transform into (or revert from) Muspell, tier 8."));
const string photo = "Trenta - Photosynthesis";
PhotosynthesisStillnessSeconds = config.Bind(photo, "Stillness Seconds", 10f,
new ConfigDescription("Seconds standing still in daylight, out from under a roof, before healing begins.", new AcceptableValueRange<float>(1f, 60f)));
PhotosynthesisHealSeconds = config.Bind(photo, "Heal Ticks", 8,
new ConfigDescription("Number of 1-second heal ticks once it fires.", new AcceptableValueRange<int>(1, 30)));
PhotosynthesisHealPercentPerSecond = config.Bind(photo, "Heal Percent Per Tick", 0.10f,
new ConfigDescription("Fraction of max health healed per tick.", new AcceptableValueRange<float>(0f, 1f)));
PhotosynthesisRestBaseMinutes = config.Bind(photo, "Rest Base Minutes", 5f,
new ConfigDescription("Rested-buff duration granted at base tier.", new AcceptableValueRange<float>(0f, 60f)));
PhotosynthesisRestMinutesPerBoss = config.Bind(photo, "Rest Minutes Per Boss", 1f,
new ConfigDescription("Extra Rested-buff minutes, per boss defeated.", new AcceptableValueRange<float>(0f, 10f)));
const string purpleRain = "Trenta - Purple Rain";
PurpleRainCooldown = config.Bind(purpleRain, "Cooldown", 20f,
new ConfigDescription("Seconds between casts in human form.", new AcceptableValueRange<float>(0f, 300f)));
MuspellPurpleRainCooldown = config.Bind(purpleRain, "Muspell Cooldown", 10f,
new ConfigDescription("Seconds between casts while transformed into Muspell.", new AcceptableValueRange<float>(0f, 300f)));
PurpleRainRadius = config.Bind(purpleRain, "Radius", 8f,
new ConfigDescription("Meters from the player the spray reaches.", new AcceptableValueRange<float>(1f, 30f)));
PurpleRainHealAmount = config.Bind(purpleRain, "Ally Heal Amount", 40f,
new ConfigDescription("Flat heal applied to every ally hit.", new AcceptableValueRange<float>(0f, 200f)));
PurpleRainPoisonDamage = config.Bind(purpleRain, "Enemy Poison Damage", 40f,
new ConfigDescription("Flat poison damage applied to every enemy hit.", new AcceptableValueRange<float>(0f, 200f)));
const string lastStand = "Trenta - Last Stand & Thorns";
LastStandMaxArmorBonus = config.Bind(lastStand, "Last Stand Max Armor Bonus", 0.5f,
new ConfigDescription("Armor multiplier bonus at near-zero health, tier 5+ (0.5 = +50%). Scales down to 0 at full health.", new AcceptableValueRange<float>(0f, 3f)));
ThornsReflectPercent = config.Bind(lastStand, "Thorns Reflect Percent", 0.2f,
new ConfigDescription("Fraction of every hit taken reflected back at the attacker, tier 5+.", new AcceptableValueRange<float>(0f, 1f)));
const string portal = "Trenta - Homecoming Portal";
PortalCooldown = config.Bind(portal, "Cooldown", 300f,
new ConfigDescription("Seconds between casts, tier 6+.", new AcceptableValueRange<float>(0f, 3600f)));
PortalLifetime = config.Bind(portal, "Lifetime", 30f,
new ConfigDescription("Seconds the portal pair stays open.", new AcceptableValueRange<float>(5f, 300f)));
PortalSpawnDistance = config.Bind(portal, "Spawn Distance", 2f,
new ConfigDescription("Meters in front of the player the cast-side portal opens.", new AcceptableValueRange<float>(0.5f, 10f)));
const string hornets = "Trenta - Hornet’s Nest";
HornetsNestDamagePerTick = config.Bind(hornets, "Damage Per Tick", 10f,
new ConfigDescription("Poison and pierce damage dealt per sting, tier 7+.", new AcceptableValueRange<float>(0f, 50f)));
HornetsNestTickInterval = config.Bind(hornets, "Tick Interval", 4f,
new ConfigDescription("Seconds between stings on an engaged target.", new AcceptableValueRange<float>(0.5f, 20f)));
HornetsNestEngageRadius = config.Bind(hornets, "Engage Radius", 6f,
new ConfigDescription("Meters from the player within which a foe is engaged.", new AcceptableValueRange<float>(1f, 30f)));
HornetsNestFollowSpeed = config.Bind(hornets, "Follow Speed", 8f,
new ConfigDescription("Meters per second the nest moves to reach its target or resting orbit.", new AcceptableValueRange<float>(1f, 30f)));
HornetsNestOrbitRadius = config.Bind(hornets, "Orbit Radius", 0.6f,
new ConfigDescription("How tightly it hugs the player while at rest.", new AcceptableValueRange<float>(0.1f, 5f)));
HornetsNestAttackHeight = config.Bind(hornets, "Attack Height", 1.5f,
new ConfigDescription("Meters above a target it hovers while stinging.", new AcceptableValueRange<float>(0f, 5f)));
const string muspell = "Trenta - Muspell";
MuspellScale = config.Bind(muspell, "Model Scale", 0.5f,
new ConfigDescription("Model scale while transformed, tier 8.", new AcceptableValueRange<float>(0.1f, 2f)));
MuspellStompDamage = config.Bind(muspell, "Stomp Damage", 60f,
new ConfigDescription("Base damage of the stomp attack, before the Unarmed skill bonus.", new AcceptableValueRange<float>(0f, 300f)));
MuspellStompRadius = config.Bind(muspell, "Stomp Radius", 2.5f,
new ConfigDescription("Hit-sweep radius for the stomp.", new AcceptableValueRange<float>(1f, 10f)));
MuspellSpikeDamage = config.Bind(muspell, "Spike Damage", 35f,
new ConfigDescription("Base pierce damage of the root-spike projectile, before the Unarmed skill bonus.", new AcceptableValueRange<float>(0f, 200f)));
MuspellSpikeVelocity = config.Bind(muspell, "Spike Velocity", 20f,
new ConfigDescription("Travel speed of the root-spike projectile.", new AcceptableValueRange<float>(1f, 60f)));
const string diet = "Trenta - Diet";
FoodDurationMultiplier = config.Bind(diet, "Vegan Food Duration Multiplier", 2f,
new ConfigDescription("Multiplies digestion time for every vegan-safe food eaten.", new AcceptableValueRange<float>(1f, 5f)));
}
}
}