feat(dvergar): make ability numbers and keybinds BepInEx-configurable
Adds DvergarConfigManagement.cs rather than reusing the DvergarConfig name: that existing class is a different kind of thing - identity constants that must never change (renaming RaceId would orphan saved characters), hand-tuned cosmetic placement numbers (eye/hood position), and per-tier tables (health malus, smithing/trader discounts) left alone under the same boundary drawn for every other race's progression table. Only the genuine ability knobs move: Runic Ping and Runic Overcharge (cost, radius, duration, cooldown, marker light) each get a Configuration Manager section, plus mining and weapon-affinity percentages under Passive Combat, plus the two keybinds. DvergarConfig's fields for those now forward to DvergarConfigManagement (same const-to-property trick used for Skadi), so all 109 existing call sites across 11 files kept working unchanged except the two keybind consumers (DvergarAbilities, RaceCompendium's in-game ability text), which now read the live configured key so a rebind stays reflected everywhere it's shown. Weapon-affinity DamagePercent/StaminaPercent are overridden with the live config value inside DvergarProgression.GetRules rather than baked into the static WeaponAffinities array, since that array evaluates at class-load time - before RacesOfValheim.Awake() calls Bind - and would risk a null-reference on the ConfigEntry. Config sections stay bound alphabetically by race (Aswid, Draugh, Dvergar, Skadi) in RacesOfValheim.Awake().
This commit is contained in:
parent
8595b7108a
commit
3607d7323d
6 changed files with 173 additions and 33 deletions
111
JotunnModStub/Dvergar/DvergarConfigManagement.cs
Normal file
111
JotunnModStub/Dvergar/DvergarConfigManagement.cs
Normal file
|
|
@ -0,0 +1,111 @@
|
|||
using UnityEngine;
|
||||
using BepInEx.Configuration;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The BepInEx-configurable slice of the Dvergar'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
|
||||
/// SkadiConfig/AswidConfig/DraughConfig's layout).
|
||||
///
|
||||
/// Named separately from the pre-existing DvergarConfig (rather than folding into it) because
|
||||
/// that class is a different kind of thing: identity constants that must never change once a
|
||||
/// player has the race (RaceId, status effect names - renaming them would orphan saved
|
||||
/// characters), hand-tuned cosmetic placement numbers (eye/hood position - exposing those as
|
||||
/// sliders would just let someone accidentally break the model), and per-tier tables (health
|
||||
/// malus, smithing/trader discounts - the same "leave alone" boundary drawn for every other
|
||||
/// race's progression table). Only the genuine ability knobs - Runic Ping/Overcharge and their
|
||||
/// two keybinds, mining and weapon-affinity percentages - belong here. DvergarConfig's own
|
||||
/// fields for those now forward to this class (see the comments there), so every existing call
|
||||
/// site kept working unchanged.
|
||||
///
|
||||
/// One caveat worth knowing: DvergarProgression.GetRules caches its result per progression
|
||||
/// state the first time that state is reached. ElementalDamagePerState and the weapon-affinity
|
||||
/// percentages below are read into that cache, so retuning them mid-session only affects tiers
|
||||
/// the cache hasn't already built - a relog (or reaching a new tier) picks up the new value.
|
||||
/// Runic Ping/Overcharge and mining read their config live on every use and are unaffected.
|
||||
/// </summary>
|
||||
public static class DvergarConfigManagement
|
||||
{
|
||||
// ─── Keybinds ──────────────────────────────────────────────────────────
|
||||
public static ConfigEntry<KeyboardShortcut> RunicPingKey;
|
||||
public static ConfigEntry<KeyboardShortcut> RunicOverchargeKey;
|
||||
|
||||
// ─── Passive combat ──────────────────────────────────────────────────
|
||||
public static ConfigEntry<float> ElementalDamagePerState;
|
||||
public static ConfigEntry<float> MinMaxHealth;
|
||||
public static ConfigEntry<float> WeaponAffinityDamagePercent;
|
||||
public static ConfigEntry<float> WeaponAffinityStaminaPercent;
|
||||
|
||||
// ─── Mining ────────────────────────────────────────────────────────────
|
||||
public static ConfigEntry<float> MiningDamageMultiplier;
|
||||
public static ConfigEntry<float> MiningStaminaPercent;
|
||||
public static ConfigEntry<float> MiningExtraDropChance;
|
||||
|
||||
// ─── Runic Ping (tier 6+) ─────────────────────────────────────────────
|
||||
public static ConfigEntry<float> RunicPingEitrCost;
|
||||
public static ConfigEntry<float> RunicPingRadius;
|
||||
public static ConfigEntry<float> RunicPingDuration;
|
||||
public static ConfigEntry<float> RunicPingCooldown;
|
||||
public static ConfigEntry<float> RunicPingLightRange;
|
||||
public static ConfigEntry<float> RunicPingLightIntensity;
|
||||
|
||||
// ─── Runic Overcharge (tier 8) ────────────────────────────────────────
|
||||
public static ConfigEntry<float> RunicOverchargeEitrCost;
|
||||
public static ConfigEntry<float> RunicOverchargeMultiplier;
|
||||
public static ConfigEntry<float> RunicOverchargeWindow;
|
||||
public static ConfigEntry<float> RunicOverchargeCooldown;
|
||||
|
||||
public static void Bind(ConfigFile config)
|
||||
{
|
||||
const string keybinds = "Dvergar - Keybinds";
|
||||
RunicPingKey = config.Bind(keybinds, "Runic Ping", new KeyboardShortcut(KeyCode.G),
|
||||
new ConfigDescription("Lights up ore veins and hidden enemies nearby, tier 6+."));
|
||||
RunicOverchargeKey = config.Bind(keybinds, "Runic Overcharge", new KeyboardShortcut(KeyCode.H),
|
||||
new ConfigDescription("Loads the next favoured-weapon blow with bonus damage, tier 8."));
|
||||
|
||||
const string combat = "Dvergar - Passive Combat";
|
||||
ElementalDamagePerState = config.Bind(combat, "Elemental Damage Per State", 2f,
|
||||
new ConfigDescription("Lightning added to every blow the player lands, multiplied by the current progression state.", new AcceptableValueRange<float>(0f, 10f)));
|
||||
MinMaxHealth = config.Bind(combat, "Minimum Max Health", 5f,
|
||||
new ConfigDescription("A Dvergar's max health is never reduced below this, however the per-tier malus lines up.", new AcceptableValueRange<float>(1f, 50f)));
|
||||
WeaponAffinityDamagePercent = config.Bind(combat, "Weapon Affinity Damage Percent", 0.15f,
|
||||
new ConfigDescription("Extra physical damage with a favoured weapon (Hammer/Bow/Axe/Crossbow), as a fraction.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
WeaponAffinityStaminaPercent = config.Bind(combat, "Weapon Affinity Stamina Percent", 0.20f,
|
||||
new ConfigDescription("Stamina refunded on attacks with a favoured weapon, as a fraction.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
|
||||
const string mining = "Dvergar - Mining";
|
||||
MiningDamageMultiplier = config.Bind(mining, "Damage Multiplier", 1.20f,
|
||||
new ConfigDescription("Multiplies pickaxe damage against rock, tier 2+.", new AcceptableValueRange<float>(1f, 3f)));
|
||||
MiningStaminaPercent = config.Bind(mining, "Stamina Discount Percent", 0.40f,
|
||||
new ConfigDescription("Stamina saved per pickaxe swing, as a fraction.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
MiningExtraDropChance = config.Bind(mining, "Extra Ore Drop Chance", 0.25f,
|
||||
new ConfigDescription("Chance a mined vein yields one extra unit of ore. 0 disables the yield half of the affinity.", new AcceptableValueRange<float>(0f, 1f)));
|
||||
|
||||
const string ping = "Dvergar - Runic Ping";
|
||||
RunicPingEitrCost = config.Bind(ping, "Eitr Cost", 25f,
|
||||
new ConfigDescription("Eitr spent per cast.", new AcceptableValueRange<float>(0f, 100f)));
|
||||
RunicPingRadius = config.Bind(ping, "Radius", 40f,
|
||||
new ConfigDescription("Meters within which ore veins and hidden enemies are marked.", new AcceptableValueRange<float>(5f, 100f)));
|
||||
RunicPingDuration = config.Bind(ping, "Marker Duration", 10f,
|
||||
new ConfigDescription("Seconds a marker light stays lit.", new AcceptableValueRange<float>(1f, 60f)));
|
||||
RunicPingCooldown = config.Bind(ping, "Cooldown", 20f,
|
||||
new ConfigDescription("Seconds between casts.", new AcceptableValueRange<float>(0f, 300f)));
|
||||
RunicPingLightRange = config.Bind(ping, "Marker Light Range", 8f,
|
||||
new ConfigDescription("Range of each marker light.", new AcceptableValueRange<float>(1f, 30f)));
|
||||
RunicPingLightIntensity = config.Bind(ping, "Marker Light Intensity", 2f,
|
||||
new ConfigDescription("Intensity of each marker light.", new AcceptableValueRange<float>(0.1f, 10f)));
|
||||
|
||||
const string overcharge = "Dvergar - Runic Overcharge";
|
||||
RunicOverchargeEitrCost = config.Bind(overcharge, "Eitr Cost", 60f,
|
||||
new ConfigDescription("Eitr spent to load a charge.", new AcceptableValueRange<float>(0f, 200f)));
|
||||
RunicOverchargeMultiplier = config.Bind(overcharge, "Damage Multiplier", 4f,
|
||||
new ConfigDescription("Multiplies physical damage on the blow that discharges the loaded weapon.", new AcceptableValueRange<float>(1f, 10f)));
|
||||
RunicOverchargeWindow = config.Bind(overcharge, "Charge Window", 15f,
|
||||
new ConfigDescription("Seconds a loaded charge is held before it lapses unused.", new AcceptableValueRange<float>(1f, 60f)));
|
||||
RunicOverchargeCooldown = config.Bind(overcharge, "Cooldown", 60f,
|
||||
new ConfigDescription("Seconds between casts.", new AcceptableValueRange<float>(0f, 300f)));
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue