feat(skadi): add rebindable keybinds for abilities and special attacks

Adds a Skadi - Keybinds config section (bound first, ahead of the other
Skadi sections) covering every ability/attack trigger: dragon primary
attack, cold spell cast, breath attack, Fader spin, flight toggle, and the
three transform keys (Drake/Moder/Fader). Defaults match the previous
fixed inputs exactly. SkadiAttackPatch's kick-suppression check now reads
the configured Cold Spell key instead of a hardcoded Middle Mouse, so it
stays correct if that key is rebound.

Entries within Keybinds carry an explicit Order (via the new
ConfigurationManagerAttributes shim, per CONFIGURATION-MANAGER-HOWTO.md)
so they list as attack -> cast -> breath -> spin -> flight -> the three
transform keys, rather than alphabetically.
This commit is contained in:
kanym 2026-08-06 13:08:05 +02:00
commit 7708599ff9
5 changed files with 108 additions and 22 deletions

View file

@ -1,19 +1,37 @@
using UnityEngine;
using BepInEx.Configuration;
namespace RacesOfValheim
{
/// <summary>
/// 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
/// Every tunable number and keybind 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.
/// One section per sub-group (rather than everything under one "Skadi" section) so each shows
/// up as its own entry in Configuration Manager's category list - collapsing them into a
/// single section made that list disappear. Keybinds is bound first, before its section
/// otherwise sorts alphabetically among the rest, since it is the group most worth reaching
/// quickly; within it every entry carries an explicit Order (Configuration Manager otherwise
/// sorts a section's own entries alphabetically) so it reads attack -> cast -> breath -> spin
/// -> flight -> the three transform keys, the order abilities actually chain in a fight,
/// rather than alphabetically.
/// </summary>
public static class SkadiConfig
{
// ─── Cold Spell (human form, Middle Mouse) ─────────────────────────────
// ─── Keybinds ──────────────────────────────────────────────────────────
// Defaults match today's fixed inputs exactly, so nobody's controls change until they
// open Configuration Manager (or the .cfg) and rebind one on purpose.
public static ConfigEntry<KeyboardShortcut> PrimaryAttackKey;
public static ConfigEntry<KeyboardShortcut> ColdSpellKey;
public static ConfigEntry<KeyboardShortcut> BreathAttackKey;
public static ConfigEntry<KeyboardShortcut> SpinAttackKey;
public static ConfigEntry<KeyboardShortcut> FlightToggleKey;
public static ConfigEntry<KeyboardShortcut> DrakeFormKey;
public static ConfigEntry<KeyboardShortcut> ModerFormKey;
public static ConfigEntry<KeyboardShortcut> FaderFormKey;
// ─── Cold Spell (human form) ─────────────────────────────────────────
public static ConfigEntry<float> SpellStaminaCost;
public static ConfigEntry<float> SpellCooldown;
public static ConfigEntry<float> ImprovedSpellCooldown;
@ -57,6 +75,29 @@ namespace RacesOfValheim
public static void Bind(ConfigFile config)
{
// Bound first, and ahead of everything else in the file, in case Configuration
// Manager's category list preserves bind order rather than sorting sections
// alphabetically - either way, the keybinds themselves still land in the requested
// order via the explicit Order below, which is guaranteed.
const string keybinds = "Skadi - Keybinds";
int keyOrder = 8;
PrimaryAttackKey = config.Bind(keybinds, "Dragon Primary Attack", new KeyboardShortcut(KeyCode.Mouse0),
KeyDesc("Bite/claw attack in any dragon form.", keyOrder--));
ColdSpellKey = config.Bind(keybinds, "Cold Spell Cast", new KeyboardShortcut(KeyCode.Mouse2),
KeyDesc("Casts the Cold Spell in human form, tier 1+.", keyOrder--));
BreathAttackKey = config.Bind(keybinds, "Dragon Breath Attack", new KeyboardShortcut(KeyCode.Mouse2),
KeyDesc("Ranged breath/barrage attack in Moder and Skeleton Dragon form.", keyOrder--));
SpinAttackKey = config.Bind(keybinds, "Fader Spin Attack", new KeyboardShortcut(KeyCode.Mouse1),
KeyDesc("360-degree spin attack, Skeleton Dragon form only.", keyOrder--));
FlightToggleKey = config.Bind(keybinds, "Flight Toggle", new KeyboardShortcut(KeyCode.Mouse1),
KeyDesc("Takes off or lands while in Drake or Moder form.", keyOrder--));
DrakeFormKey = config.Bind(keybinds, "Drake Form", new KeyboardShortcut(KeyCode.G),
KeyDesc("Transform into (or revert from) the Drake, tier 3+.", keyOrder--));
ModerFormKey = config.Bind(keybinds, "Moder Form", new KeyboardShortcut(KeyCode.H),
KeyDesc("Transform into (or revert from) Moder, tier 5+.", keyOrder--));
FaderFormKey = config.Bind(keybinds, "Fader Form", new KeyboardShortcut(KeyCode.J),
KeyDesc("Transform into (or revert from) the Skeleton Dragon, tier 8.", keyOrder--));
const string spell = "Skadi - Cold Spell";
SpellStaminaCost = config.Bind(spell, "Stamina Cost", 20f,
new ConfigDescription("Stamina spent per cast.", new AcceptableValueRange<float>(0f, 100f)));
@ -129,5 +170,10 @@ namespace RacesOfValheim
FlightSprintStaminaPerSecond = config.Bind(flight, "Sprint Stamina Per Second", 15f,
new ConfigDescription("Stamina drained per second while the sprint speed is actually granted.", new AcceptableValueRange<float>(0f, 60f)));
}
private static ConfigDescription KeyDesc(string description, int order)
{
return new ConfigDescription(description, null, new ConfigurationManagerAttributes { Order = order });
}
}
}