From c088eb74f461c903873491fc09b8fe0e755b5c04 Mon Sep 17 00:00:00 2001 From: kanym Date: Thu, 6 Aug 2026 12:45:53 +0200 Subject: [PATCH] feat(skadi): make abilities and special attacks BepInEx-configurable Binds every tunable number behind Skadi's Cold Spell, frost aura, bonus frost damage, dragon-form scale/melee/ranged attacks, and directed flight as BepInEx ConfigEntry values (SkadiConfig.cs), following CONFIGURATION-MANAGER-HOWTO.md. Defaults match the previous hardcoded constants exactly, so this is config-only, no gameplay change. BepInEx writes these to BepInEx/config/com.nandor.racesofvalheim.cfg on first run regardless of whether Configuration Manager is installed - a plain, commented, hand-editable text file - so players without the plugin can still retune values by hand. --- JotunnModStub/RacesOfValheim.cs | 1 + JotunnModStub/Skadi/DrakeFormBehavior.cs | 18 +-- JotunnModStub/Skadi/SkadiConfig.cs | 133 +++++++++++++++++++++++ JotunnModStub/Skadi/SkadiPatches.cs | 20 ++-- JotunnModStub/Skadi/SkadiRace.cs | 30 ++--- 5 files changed, 172 insertions(+), 30 deletions(-) create mode 100644 JotunnModStub/Skadi/SkadiConfig.cs diff --git a/JotunnModStub/RacesOfValheim.cs b/JotunnModStub/RacesOfValheim.cs index c1bf198..91f64b4 100644 --- a/JotunnModStub/RacesOfValheim.cs +++ b/JotunnModStub/RacesOfValheim.cs @@ -24,6 +24,7 @@ namespace RacesOfValheim private void Awake() { Instance = this; + SkadiConfig.Bind(Config); harmony.PatchAll(); gameObject.AddComponent(); gameObject.AddComponent(); diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs index 4b797ce..099fd33 100644 --- a/JotunnModStub/Skadi/DrakeFormBehavior.cs +++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs @@ -60,24 +60,26 @@ namespace RacesOfValheim return live != null && live.Form == formRules.Form && live.CanAttackInForm; } - private const float ATTACK_COOLDOWN = 3f; + // Read from SkadiConfig (BepInEx Config) rather than fixed constants, so dragon-form + // attacks can be retuned from Configuration Manager - see CONFIGURATION-MANAGER-HOWTO.md. + private static float ATTACK_COOLDOWN => SkadiConfig.FormAttackCooldown.Value; // Ranged volleys charge per projectile rather than a flat fee, so the 20- and 60-shard // breaths cost what they are worth instead of the same as a three-shard drake spit. // Stamina rather than eitr, for the same reason the Cold Spell uses it: eitr food only // exists from the Mistlands on, while the drake form arrives at the Elder, so an eitr // cost left the earliest dragon tiers with no attack they could actually pay for. - private const float STAMINA_PER_PROJECTILE = 1.5f; + private static float STAMINA_PER_PROJECTILE => SkadiConfig.StaminaPerProjectile.Value; // Ceiling so the widest breath stays castable: 60 shards would otherwise ask 90 stamina. - private const float MAX_VOLLEY_STAMINA = 85f; + private static float MAX_VOLLEY_STAMINA => SkadiConfig.MaxVolleyStamina.Value; // Melee costs nothing at all - it is the baseline attack that has to work at every tier, // including the long stretch where the player has no eitr whatsoever. - private const float MELEE_RADIUS = 3f; - private const float MODER_MELEE_DAMAGE = 90f; - private const float FADER_MELEE_DAMAGE = 120f; - private const float FADER_SPIN_DAMAGE = 100f; - private const float FADER_SPIN_RADIUS = 5f; + private static float MELEE_RADIUS => SkadiConfig.MeleeRadius.Value; + private static float MODER_MELEE_DAMAGE => SkadiConfig.ModerMeleeDamage.Value; + private static float FADER_MELEE_DAMAGE => SkadiConfig.FaderMeleeDamage.Value; + private static float FADER_SPIN_DAMAGE => SkadiConfig.FaderSpinDamage.Value; + private static float FADER_SPIN_RADIUS => SkadiConfig.FaderSpinRadius.Value; private void Start() { diff --git a/JotunnModStub/Skadi/SkadiConfig.cs b/JotunnModStub/Skadi/SkadiConfig.cs new file mode 100644 index 0000000..2b3fcfc --- /dev/null +++ b/JotunnModStub/Skadi/SkadiConfig.cs @@ -0,0 +1,133 @@ +using BepInEx.Configuration; + +namespace RacesOfValheim +{ + /// + /// Every tunable number behind Skadi's abilities and special attacks, bound as BepInEx + /// ConfigEntry so they show up in Configuration Manager without touching code - see + /// CONFIGURATION-MANAGER-HOWTO.md. Bound once, from RacesOfValheim.Awake(). + /// + /// Grouped to match the three places a Skadi actually gets these numbers from: the human + /// form's Cold Spell and passive frost aura/damage, the three dragon forms' melee and ranged + /// attacks, and directed flight. + /// + public static class SkadiConfig + { + // ─── Cold Spell (human form, Middle Mouse) ───────────────────────────── + public static ConfigEntry SpellStaminaCost; + public static ConfigEntry SpellCooldown; + public static ConfigEntry ImprovedSpellCooldown; + public static ConfigEntry SpellBaseDamage; + public static ConfigEntry SpellDamagePerState; + public static ConfigEntry ImprovedSpellShards; + public static ConfigEntry ImprovedSpellDamageBudget; + + // ─── Frost Aura (tier 7+ passive) ─────────────────────────────────────── + public static ConfigEntry AuraRadius; + public static ConfigEntry AuraDamagePerTick; + public static ConfigEntry AuraTickInterval; + + // ─── Passive combat ────────────────────────────────────────────────── + public static ConfigEntry BonusFrostDamagePerState; + + // ─── Dragon forms: scale ───────────────────────────────────────────── + public static ConfigEntry DrakeScale; + public static ConfigEntry ModerScale; + public static ConfigEntry FaderScale; + + // ─── Dragon forms: attacks ──────────────────────────────────────────── + public static ConfigEntry FormAttackCooldown; + public static ConfigEntry StaminaPerProjectile; + public static ConfigEntry MaxVolleyStamina; + public static ConfigEntry MeleeRadius; + public static ConfigEntry ModerMeleeDamage; + public static ConfigEntry FaderMeleeDamage; + public static ConfigEntry FaderSpinDamage; + public static ConfigEntry FaderSpinRadius; + + // ─── Directed flight (Drake/Moder) ──────────────────────────────────── + public static ConfigEntry FlightTurnSpeed; + public static ConfigEntry FlightGlideSpeed; + public static ConfigEntry FlightBoostSpeed; + public static ConfigEntry FlightSprintSpeed; + public static ConfigEntry FlightReverseSpeed; + public static ConfigEntry FlightLiftoffSpeed; + public static ConfigEntry FlightHoverSeconds; + public static ConfigEntry FlightSprintStaminaPerSecond; + + public static void Bind(ConfigFile config) + { + const string spell = "Skadi - Cold Spell"; + SpellStaminaCost = config.Bind(spell, "Stamina Cost", 20f, + new ConfigDescription("Stamina spent per cast.", new AcceptableValueRange(0f, 100f))); + SpellCooldown = config.Bind(spell, "Cooldown", 1.5f, + new ConfigDescription("Seconds between casts before the improved (tier 6+) cast unlocks.", new AcceptableValueRange(0.1f, 10f))); + ImprovedSpellCooldown = config.Bind(spell, "Improved Cooldown", 4f, + new ConfigDescription("Seconds between casts once the improved cast unlocks (tier 6+) - a burst rather than rapid-fire.", new AcceptableValueRange(0.1f, 15f))); + SpellBaseDamage = config.Bind(spell, "Base Damage", 15f, + new ConfigDescription("Frost damage at progression state 0, before the per-state bonus.", new AcceptableValueRange(0f, 200f))); + SpellDamagePerState = config.Bind(spell, "Damage Per Progression State", 8f, + new ConfigDescription("Extra frost damage added per boss progression state (0-8).", new AcceptableValueRange(0f, 50f))); + ImprovedSpellShards = config.Bind(spell, "Improved Shard Count", 10, + new ConfigDescription("Number of shards the improved (tier 6+) cast splits into.", new AcceptableValueRange(1, 30))); + ImprovedSpellDamageBudget = config.Bind(spell, "Improved Damage Budget", 1.6f, + new ConfigDescription("Total damage of an improved cast, as a multiple of one normal cast, before it is split across shards.", new AcceptableValueRange(0.5f, 5f))); + + const string aura = "Skadi - Frost Aura"; + AuraRadius = config.Bind(aura, "Radius", 3f, + new ConfigDescription("Meters from the player that the tier 7+ aura damages.", new AcceptableValueRange(1f, 15f))); + AuraDamagePerTick = config.Bind(aura, "Damage Per Tick", 10f, + new ConfigDescription("Frost damage dealt to every enemy in range, once per tick.", new AcceptableValueRange(0f, 50f))); + AuraTickInterval = config.Bind(aura, "Tick Interval", 1f, + new ConfigDescription("Seconds between aura damage ticks.", new AcceptableValueRange(0.1f, 5f))); + + const string combat = "Skadi - Passive Combat"; + BonusFrostDamagePerState = config.Bind(combat, "Bonus Frost Damage Per State", 2f, + new ConfigDescription("Flat frost damage added to every hit the player lands, multiplied by the current progression state.", new AcceptableValueRange(0f, 10f))); + + const string scale = "Skadi - Dragon Form Scale"; + DrakeScale = config.Bind(scale, "Drake Scale", 0.9f, + new ConfigDescription("Model scale while transformed into the Drake (tier 3-4).", new AcceptableValueRange(0.1f, 2f))); + ModerScale = config.Bind(scale, "Moder Scale", 0.5f, + new ConfigDescription("Model scale while transformed into Moder (tier 5-7).", new AcceptableValueRange(0.1f, 2f))); + FaderScale = config.Bind(scale, "Fader Scale", 0.55f, + new ConfigDescription("Model scale while transformed into the Skeleton Dragon (tier 8).", new AcceptableValueRange(0.1f, 2f))); + + const string attacks = "Skadi - Dragon Form Attacks"; + FormAttackCooldown = config.Bind(attacks, "Attack Cooldown", 3f, + new ConfigDescription("Seconds between attacks in any dragon form.", new AcceptableValueRange(0.5f, 15f))); + StaminaPerProjectile = config.Bind(attacks, "Stamina Per Projectile", 1.5f, + new ConfigDescription("Stamina charged per shard/projectile in a ranged volley.", new AcceptableValueRange(0f, 10f))); + MaxVolleyStamina = config.Bind(attacks, "Max Volley Stamina", 85f, + new ConfigDescription("Stamina ceiling for a single volley, so the widest breath (60 shards) stays castable.", new AcceptableValueRange(0f, 300f))); + MeleeRadius = config.Bind(attacks, "Melee Radius", 3f, + new ConfigDescription("Hit-sweep radius for bite/claw attacks (Moder and Fader).", new AcceptableValueRange(1f, 15f))); + ModerMeleeDamage = config.Bind(attacks, "Moder Melee Damage", 90f, + new ConfigDescription("Base damage of Moder's bite/claw attacks, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f))); + FaderMeleeDamage = config.Bind(attacks, "Fader Melee Damage", 120f, + new ConfigDescription("Base damage of the Skeleton Dragon's bite/claw attacks, before the Unarmed skill bonus.", new AcceptableValueRange(0f, 500f))); + FaderSpinDamage = config.Bind(attacks, "Fader Spin Damage", 100f, + new ConfigDescription("Base damage of the Skeleton Dragon's 360-degree spin attack.", new AcceptableValueRange(0f, 500f))); + FaderSpinRadius = config.Bind(attacks, "Fader Spin Radius", 5f, + new ConfigDescription("Hit-sweep radius for the Skeleton Dragon's spin attack.", new AcceptableValueRange(1f, 15f))); + + const string flight = "Skadi - Directed Flight"; + FlightTurnSpeed = config.Bind(flight, "Turn Speed", 120f, + new ConfigDescription("Degrees per second the dragon form turns to face its heading.", new AcceptableValueRange(10f, 360f))); + FlightGlideSpeed = config.Bind(flight, "Glide Speed", 5f, + new ConfigDescription("Speed while gliding unpowered (no W/S held).", new AcceptableValueRange(0f, 30f))); + FlightBoostSpeed = config.Bind(flight, "Boost Speed", 12f, + new ConfigDescription("Speed while holding W without sprinting.", new AcceptableValueRange(0f, 50f))); + FlightSprintSpeed = config.Bind(flight, "Sprint Speed", 22f, + new ConfigDescription("Speed while holding W and Shift, stamina permitting.", new AcceptableValueRange(0f, 60f))); + FlightReverseSpeed = config.Bind(flight, "Reverse Speed", 7f, + new ConfigDescription("Speed while beating backwards (S).", new AcceptableValueRange(0f, 30f))); + FlightLiftoffSpeed = config.Bind(flight, "Liftoff Speed", 9f, + new ConfigDescription("Climb speed while clawing out of water.", new AcceptableValueRange(0f, 30f))); + FlightHoverSeconds = config.Bind(flight, "Hover Seconds", 5f, + new ConfigDescription("How long level flight holds altitude after the last powered input before it starts to sink.", new AcceptableValueRange(0f, 30f))); + FlightSprintStaminaPerSecond = config.Bind(flight, "Sprint Stamina Per Second", 15f, + new ConfigDescription("Stamina drained per second while the sprint speed is actually granted.", new AcceptableValueRange(0f, 60f))); + } + } +} diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs index 88cce4b..571bf07 100644 --- a/JotunnModStub/Skadi/SkadiPatches.cs +++ b/JotunnModStub/Skadi/SkadiPatches.cs @@ -229,7 +229,7 @@ namespace RacesOfValheim var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState()); if (rules.BonusFrostDamage) { - hit.m_damage.m_frost += 2f * BossProgressionManager.GetCurrentProgressionState(); + hit.m_damage.m_frost += SkadiConfig.BonusFrostDamagePerState.Value * BossProgressionManager.GetCurrentProgressionState(); } } } @@ -250,17 +250,19 @@ namespace RacesOfValheim [HarmonyPatch(typeof(Character), "UpdateFlying")] public static class SkadiDirectedFlightPatch { - private const float TURN_SPEED = 120f; - private const float GLIDE_SPEED = 5f; - private const float BOOST_SPEED = 12f; - private const float SPRINT_SPEED = 22f; - private const float REVERSE_SPEED = 7f; + // Read from SkadiConfig (BepInEx Config) rather than fixed constants, so flight can be + // retuned from Configuration Manager - see CONFIGURATION-MANAGER-HOWTO.md. + private static float TURN_SPEED => SkadiConfig.FlightTurnSpeed.Value; + private static float GLIDE_SPEED => SkadiConfig.FlightGlideSpeed.Value; + private static float BOOST_SPEED => SkadiConfig.FlightBoostSpeed.Value; + private static float SPRINT_SPEED => SkadiConfig.FlightSprintSpeed.Value; + private static float REVERSE_SPEED => SkadiConfig.FlightReverseSpeed.Value; // Climbing out of water is deliberately slower than a powered climb in open air - the // wings are dragging themselves free, not racing. - private const float LIFTOFF_SPEED = 9f; - private const float HOVER_SECONDS = 5f; + private static float LIFTOFF_SPEED => SkadiConfig.FlightLiftoffSpeed.Value; + private static float HOVER_SECONDS => SkadiConfig.FlightHoverSeconds.Value; // Per second, drained only while the sprint is actually being granted. - private const float SPRINT_STAMINA_PER_SECOND = 15f; + private static float SPRINT_STAMINA_PER_SECOND => SkadiConfig.FlightSprintStaminaPerSecond.Value; // Tangent of the unpowered descent angle: 0.4 sinks at roughly 22 degrees below level. private const float DESCENT_SLOPE = 0.4f; // How much of the aim heading survives the climb out of water. Mostly up, with enough diff --git a/JotunnModStub/Skadi/SkadiRace.cs b/JotunnModStub/Skadi/SkadiRace.cs index 558c1bf..9c45f28 100644 --- a/JotunnModStub/Skadi/SkadiRace.cs +++ b/JotunnModStub/Skadi/SkadiRace.cs @@ -27,17 +27,21 @@ namespace RacesOfValheim // Cold Spell tuning. Damage is 15 + 8 per progression state, so it runs from roughly 31 at // Eikthyr to 79 at Fader - deliberately a notch under the melee options of the other races // at each tier, which is the trade for hitting at range on a short cooldown. + // + // All values below read from SkadiConfig (BepInEx Config, see SkadiConfig.cs) rather than + // being fixed constants, so they can be retuned from Configuration Manager without a + // rebuild - see CONFIGURATION-MANAGER-HOWTO.md. public const string SPELL_COOLDOWN_SE = "SE_SkadiSpellCooldown"; public const string ATTACK_COOLDOWN_SE = "SE_SkadiAttackCooldown"; - private const float SPELL_STAMINA_COST = 20f; - private const float SPELL_COOLDOWN = 1.5f; - private const float IMPROVED_SPELL_COOLDOWN = 4f; - private const float SPELL_BASE_DAMAGE = 15f; - private const float SPELL_DAMAGE_PER_STATE = 8f; - private const int IMPROVED_SPELL_SHARDS = 10; + private static float SPELL_STAMINA_COST => SkadiConfig.SpellStaminaCost.Value; + private static float SPELL_COOLDOWN => SkadiConfig.SpellCooldown.Value; + private static float IMPROVED_SPELL_COOLDOWN => SkadiConfig.ImprovedSpellCooldown.Value; + private static float SPELL_BASE_DAMAGE => SkadiConfig.SpellBaseDamage.Value; + private static float SPELL_DAMAGE_PER_STATE => SkadiConfig.SpellDamagePerState.Value; + private static int IMPROVED_SPELL_SHARDS => SkadiConfig.ImprovedSpellShards.Value; // The improved cast spreads 1.6 casts worth of damage over its shards: wider, not stronger. - private const float IMPROVED_SPELL_DAMAGE_BUDGET = 1.6f; + private static float IMPROVED_SPELL_DAMAGE_BUDGET => SkadiConfig.ImprovedSpellDamageBudget.Value; private void Awake() { @@ -158,7 +162,7 @@ namespace RacesOfValheim if (rules.FrostAura) { EnsureFrostAuraVFX(true); - if (Time.time - lastAuraTime >= 1f) + if (Time.time - lastAuraTime >= SkadiConfig.AuraTickInterval.Value) { ApplyColdAura(); lastAuraTime = Time.time; @@ -482,10 +486,10 @@ namespace RacesOfValheim if (c == Player.m_localPlayer) continue; if (c.IsTamed() || c.IsPlayer()) continue; - if (Vector3.Distance(center, c.transform.position) <= 3f) + if (Vector3.Distance(center, c.transform.position) <= SkadiConfig.AuraRadius.Value) { HitData hit = new HitData(); - hit.m_damage.m_frost = 10f; + hit.m_damage.m_frost = SkadiConfig.AuraDamagePerTick.Value; hit.m_point = c.transform.position; hit.m_dir = (c.transform.position - center).normalized; hit.SetAttacker(Player.m_localPlayer); @@ -525,9 +529,9 @@ namespace RacesOfValheim private Vector3 GetFormScale(SkadiProgression.FormType form) { - if (form == SkadiProgression.FormType.Moder) return Vector3.one * 0.5f; // Increased to 50% - if (form == SkadiProgression.FormType.SkeletonDragon) return Vector3.one * 0.55f; // 10% larger than Moder - return Vector3.one * 0.9f; // Drake (reduced by 10%) + if (form == SkadiProgression.FormType.Moder) return Vector3.one * SkadiConfig.ModerScale.Value; + if (form == SkadiProgression.FormType.SkeletonDragon) return Vector3.one * SkadiConfig.FaderScale.Value; + return Vector3.one * SkadiConfig.DrakeScale.Value; // Drake } private IEnumerator TransformRoutine(SkadiProgression.FormRules rules)