RacesOfValheim/JotunnModStub/Dvergar/DvergarConfigManagement.cs
kanym 2e31f98380 feat(dvergar): add Fire Construct base-defense piece (Mountain faction feature)
Stationary Hammer piece cloned from DvergerMageFire: scans a configurable
radius for hostile, non-Mountain-faction, non-player Characters and fires its
own fireball (real attack data pulled off Humanoid.m_defaultItems, grounded in
an in-game dumpelder dump, not guessed).

Fire-only for this first pass; Ice/Support are a later append to the same
pattern. Several in-game fixes along the way: a missing piece icon (Jotunn
silently drops any piece without one), a missing known-piece teach on spawn
(same fix RaceMenuWard already needed), a kinematic Rigidbody fighting
Character's own velocity writes, and MonsterAI needing to be disabled rather
than destroyed - several vanilla systems (EnemyHud, most likely damage
registration too) assume any combat-relevant Character has one.

FactionHostilityPatch gains a public IsMountainFactionMob accessor so the
construct's target filter shares the same Mountain roster as the rest of
Factions instead of a second hand-maintained list.
2026-08-07 08:23:04 +02:00

126 lines
9.7 KiB
C#

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;
// ─── Fire Construct (placeable turret) ─────────────────────────────────
// See DvergarFireConstruct.cs. Fire-only for this first pass; Ice/Support are a later
// append to the same piece/recipe pattern, not a redesign.
public static ConfigEntry<float> ConstructScanRadius;
public static ConfigEntry<float> ConstructScanInterval;
public static ConfigEntry<float> ConstructFireCooldown;
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)));
const string construct = "Dvergar - Fire Construct";
ConstructScanRadius = config.Bind(construct, "Scan Radius", 10f,
new ConfigDescription("Meters within which the construct looks for a target. Kept close to the fireball's own 7m attack range so it doesn't open fire on something it can't actually hit yet.", new AcceptableValueRange<float>(3f, 30f)));
ConstructScanInterval = config.Bind(construct, "Scan Interval", 0.5f,
new ConfigDescription("Seconds between target scans.", new AcceptableValueRange<float>(0.1f, 5f)));
ConstructFireCooldown = config.Bind(construct, "Fire Cooldown", 3f,
new ConfigDescription("Seconds between shots once a target is found.", new AcceptableValueRange<float>(0.5f, 15f)));
}
}
}