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
|
|
@ -191,7 +191,9 @@ namespace RacesOfValheim
|
|||
|
||||
// ─── Health malus ────────────────────────────────────────────────────
|
||||
// Indexed by progression state; index 0 is unused so the state number indexes directly.
|
||||
// Base -10, growing to -20 once The Queen falls.
|
||||
// Base -10, growing to -20 once The Queen falls. Left as a plain per-tier table, same
|
||||
// boundary drawn everywhere else in this mod (Skadi's progression table included) -
|
||||
// not exposed through Configuration Manager.
|
||||
public static readonly float[] HealthMalusByState =
|
||||
{
|
||||
0f, // (unused)
|
||||
|
|
@ -206,7 +208,10 @@ namespace RacesOfValheim
|
|||
};
|
||||
|
||||
// A Dvergar must never be reduced below this, however the malus and food line up.
|
||||
public static readonly float MinMaxHealth = 5f;
|
||||
// Forwards to DvergarConfigManagement (BepInEx ConfigEntry) so every existing call site
|
||||
// keeps reading DvergarConfig.MinMaxHealth unchanged - see that class for why this one
|
||||
// field, and not the rest of this file, is configurable.
|
||||
public static float MinMaxHealth => DvergarConfigManagement.MinMaxHealth.Value;
|
||||
|
||||
// ─── Elemental affinity ──────────────────────────────────────────────
|
||||
// Runes in the blood: every blow the Dvergar lands carries lightning.
|
||||
|
|
@ -215,21 +220,28 @@ namespace RacesOfValheim
|
|||
// growing by a flat step per progression state, so +2 at Base through +16 after Fader -
|
||||
// with lightning in place of frost. SkadiDamagePatch is the reference; like it, this
|
||||
// applies to every blow the player lands, not only melee.
|
||||
public static readonly float ElementalDamagePerState = 2f;
|
||||
public static float ElementalDamagePerState => DvergarConfigManagement.ElementalDamagePerState.Value;
|
||||
|
||||
public static readonly HitData.DamageType ElementalDamageType = HitData.DamageType.Lightning;
|
||||
|
||||
// ─── Weapon affinity ─────────────────────────────────────────────────
|
||||
// Bonus damage plus a stamina discount on the attack. Neither scales with the tier - a
|
||||
// tier only ever adds a new weapon to the list - and skill XP is deliberately untouched.
|
||||
//
|
||||
// DamagePercent and StaminaPercent below are fallback shape values only: identical across
|
||||
// every weapon today, and DvergarProgression.GetRules overrides both with
|
||||
// DvergarConfigManagement's live (and configurable) values before handing rules out - see
|
||||
// the comment there. FlatDamage and StaminaFlat stay literal zero-and-unconfigured: both
|
||||
// are currently inert placeholders (FlatDamage's whole effect is gated behind
|
||||
// `if (affinity.FlatDamage > 0f)` in DvergarPatches, which never fires at zero).
|
||||
public struct WeaponAffinity
|
||||
{
|
||||
public Skills.SkillType Skill;
|
||||
public int UnlockState;
|
||||
public HitData.DamageType FlatDamageType; // channel the flat bonus lands on
|
||||
public float FlatDamage; // TODO
|
||||
public float DamagePercent; // TODO, share of physical damage added
|
||||
public float StaminaPercent; // TODO, share of attack stamina refunded
|
||||
public float DamagePercent; // fallback shape only, see above
|
||||
public float StaminaPercent; // fallback shape only, see above
|
||||
public float StaminaFlat; // TODO, flat stamina refunded
|
||||
public string DisplayName;
|
||||
}
|
||||
|
|
@ -275,13 +287,14 @@ namespace RacesOfValheim
|
|||
public const int MiningAffinityState = 2;
|
||||
|
||||
// Faster mining is modelled as extra pickaxe damage per swing rather than a swing-rate
|
||||
// change: rock HP is what actually gates how long a vein takes.
|
||||
public static readonly float MiningDamageMultiplier = 1.20f; // TODO: 20% faster?
|
||||
public static readonly float MiningStaminaPercent = 0.40f; // TODO: or 40% less stamina?
|
||||
// change: rock HP is what actually gates how long a vein takes. Forward to
|
||||
// DvergarConfigManagement (BepInEx ConfigEntry) - see that class.
|
||||
public static float MiningDamageMultiplier => DvergarConfigManagement.MiningDamageMultiplier.Value;
|
||||
public static float MiningStaminaPercent => DvergarConfigManagement.MiningStaminaPercent.Value;
|
||||
|
||||
// Chance for a mined vein to yield an extra unit of ore. 0 disables the yield half of
|
||||
// the affinity and leaves it purely a speed/stamina perk.
|
||||
public static readonly float MiningExtraDropChance = 0.25f; // TODO
|
||||
public static float MiningExtraDropChance => DvergarConfigManagement.MiningExtraDropChance.Value;
|
||||
|
||||
// Matched against the drop prefab name, lowercased, by Contains.
|
||||
public static readonly string[] OreDropNames =
|
||||
|
|
@ -344,18 +357,21 @@ namespace RacesOfValheim
|
|||
};
|
||||
|
||||
// ─── Runic Ping (Yagluth) ────────────────────────────────────────────
|
||||
public const int RunicPingState = 6;
|
||||
public const KeyCode RunicPingKey = KeyCode.G;
|
||||
// The keybind used to live here as a KeyCode const; it is now DvergarConfigManagement's
|
||||
// RunicPingKey (a rebindable KeyboardShortcut), read directly by DvergarAbilities.
|
||||
public const int RunicPingState = 6;
|
||||
|
||||
public static readonly float RunicPingEitrCost = 25f; // TODO
|
||||
public static readonly float RunicPingRadius = 40f; // TODO
|
||||
public static readonly float RunicPingDuration = 10f; // TODO
|
||||
public static readonly float RunicPingCooldown = 20f; // TODO
|
||||
// Every numeric knob below forwards to DvergarConfigManagement (BepInEx ConfigEntry) -
|
||||
// see that class for why these, and not the colours, are configurable.
|
||||
public static float RunicPingEitrCost => DvergarConfigManagement.RunicPingEitrCost.Value;
|
||||
public static float RunicPingRadius => DvergarConfigManagement.RunicPingRadius.Value;
|
||||
public static float RunicPingDuration => DvergarConfigManagement.RunicPingDuration.Value;
|
||||
public static float RunicPingCooldown => DvergarConfigManagement.RunicPingCooldown.Value;
|
||||
|
||||
public static readonly Color RunicPingOreColor = new Color(0.4f, 0.8f, 1f);
|
||||
public static readonly Color RunicPingEnemyColor = new Color(1f, 0.35f, 0.35f);
|
||||
public static readonly float RunicPingLightRange = 8f;
|
||||
public static readonly float RunicPingLightIntensity = 2f;
|
||||
public static readonly Color RunicPingOreColor = new Color(0.4f, 0.8f, 1f);
|
||||
public static readonly Color RunicPingEnemyColor = new Color(1f, 0.35f, 0.35f);
|
||||
public static float RunicPingLightRange => DvergarConfigManagement.RunicPingLightRange.Value;
|
||||
public static float RunicPingLightIntensity => DvergarConfigManagement.RunicPingLightIntensity.Value;
|
||||
|
||||
// Vein prefabs are matched on name, lowercased, by Contains - MineRock5_Copper,
|
||||
// silvervein, rock4_copper and friends all fall out of this list.
|
||||
|
|
@ -365,13 +381,14 @@ namespace RacesOfValheim
|
|||
};
|
||||
|
||||
// ─── Runic Overcharge (Fader) ────────────────────────────────────────
|
||||
public const int RunicOverchargeState = 8;
|
||||
public const KeyCode RunicOverchargeKey = KeyCode.H;
|
||||
// The keybind used to live here as a KeyCode const; it is now DvergarConfigManagement's
|
||||
// RunicOverchargeKey (a rebindable KeyboardShortcut), read directly by DvergarAbilities.
|
||||
public const int RunicOverchargeState = 8;
|
||||
|
||||
public static readonly float RunicOverchargeEitrCost = 60f; // TODO
|
||||
public static readonly float RunicOverchargeMultiplier = 4f; // TODO, applied to physical damage
|
||||
public static readonly float RunicOverchargeWindow = 15f; // seconds the charge is held
|
||||
public static readonly float RunicOverchargeCooldown = 60f; // TODO
|
||||
public static float RunicOverchargeEitrCost => DvergarConfigManagement.RunicOverchargeEitrCost.Value;
|
||||
public static float RunicOverchargeMultiplier => DvergarConfigManagement.RunicOverchargeMultiplier.Value; // applied to physical damage
|
||||
public static float RunicOverchargeWindow => DvergarConfigManagement.RunicOverchargeWindow.Value; // seconds the charge is held
|
||||
public static float RunicOverchargeCooldown => DvergarConfigManagement.RunicOverchargeCooldown.Value;
|
||||
|
||||
// ─── Helpers ─────────────────────────────────────────────────────────
|
||||
/// <summary>Clamped table lookup, so a state outside 1..8 can never index out of range.</summary>
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue