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:
parent
c088eb74f4
commit
7708599ff9
5 changed files with 108 additions and 22 deletions
37
JotunnModStub/ConfigurationManagerAttributes.cs
Normal file
37
JotunnModStub/ConfigurationManagerAttributes.cs
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
using System;
|
||||
using BepInEx.Configuration;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// Duck-typed by Configuration Manager (matched by field name via reflection, not by type),
|
||||
/// so nothing here needs a reference to ConfigurationManager.dll and the mod works with or
|
||||
/// without that plugin installed - see CONFIGURATION-MANAGER-HOWTO.md, "Overriding default
|
||||
/// Configuration Manager behavior". Kept internal, not public, so this shape can never collide
|
||||
/// with another mod's copy of the same trick.
|
||||
///
|
||||
/// Only the fields RacesOfValheim actually sets (Order, CustomDrawer, HideDefaultButton,
|
||||
/// ReadOnly) need to be correct; the rest of Configuration Manager's documented set is kept
|
||||
/// alongside them so future config additions do not need a second copy of this file.
|
||||
/// </summary>
|
||||
internal sealed class ConfigurationManagerAttributes
|
||||
{
|
||||
// Most of these are read by Configuration Manager itself via reflection and are never
|
||||
// assigned from our own code, which is exactly what CS0649 is warning about here.
|
||||
#pragma warning disable 0649
|
||||
public Action<ConfigEntryBase> CustomDrawer;
|
||||
public bool? Browsable;
|
||||
public string Category;
|
||||
public object DefaultValue;
|
||||
public bool? HideDefaultButton;
|
||||
public bool? HideSettingName;
|
||||
public string Description;
|
||||
public string DispName;
|
||||
public int? Order;
|
||||
public bool? ReadOnly;
|
||||
public bool? IsAdvanced;
|
||||
public Func<object, string> ObjToStr;
|
||||
public Func<string, object> StrToObj;
|
||||
#pragma warning restore 0649
|
||||
}
|
||||
}
|
||||
|
|
@ -95,8 +95,8 @@ namespace RacesOfValheim
|
|||
{
|
||||
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return;
|
||||
|
||||
// Handle Flight Toggle (RMB) - Disabled for Fader
|
||||
if (RaceInput.Allowed && Input.GetMouseButtonDown(1) && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
|
||||
// Handle Flight Toggle (Right Mouse by default, rebindable) - Disabled for Fader
|
||||
if (RaceInput.Allowed && SkadiConfig.FlightToggleKey.Value.IsDown() && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
|
||||
{
|
||||
if (!isFlying && !isLanding)
|
||||
{
|
||||
|
|
@ -150,24 +150,26 @@ namespace RacesOfValheim
|
|||
anim.SetFloat("forward_speed", speed);
|
||||
}
|
||||
|
||||
// Handle Attack
|
||||
// Handle Attack - each trigger is a rebindable SkadiConfig keybind; the button id
|
||||
// passed into PerformAttackCoroutine (0/1/2) still selects which attack runs, exactly
|
||||
// as it did when these were raw mouse-button checks.
|
||||
if (CanAttackNow() && RaceInput.Allowed)
|
||||
{
|
||||
if (Input.GetMouseButtonDown(0))
|
||||
if (SkadiConfig.PrimaryAttackKey.Value.IsDown())
|
||||
{
|
||||
if (HasAttackForButton(0) && Time.time - lastAttackTime >= ATTACK_COOLDOWN)
|
||||
{
|
||||
StartCoroutine(PerformAttackCoroutine(0));
|
||||
}
|
||||
}
|
||||
else if (Input.GetMouseButtonDown(2)) // MMB
|
||||
else if (SkadiConfig.BreathAttackKey.Value.IsDown())
|
||||
{
|
||||
if (Time.time - lastAttackTime >= ATTACK_COOLDOWN)
|
||||
{
|
||||
StartCoroutine(PerformAttackCoroutine(2));
|
||||
}
|
||||
}
|
||||
else if (Input.GetMouseButtonDown(1) && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // RMB for Fader Spin
|
||||
else if (SkadiConfig.SpinAttackKey.Value.IsDown() && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // Fader Spin
|
||||
{
|
||||
if (Time.time - lastAttackTime >= ATTACK_COOLDOWN)
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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 });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -467,12 +467,13 @@ namespace RacesOfValheim
|
|||
}
|
||||
|
||||
// Valheim binds its own SecondaryAttack action to Middle Mouse, the same button the
|
||||
// Cold Spell casts on, so pressing it also swung the unarmed secondary - the kick that
|
||||
// kept showing up alongside the cast no matter which animation trigger we used. For a
|
||||
// Skadi who has the spell, Middle Mouse belongs to the spell. Keyed off the live button
|
||||
// state rather than a flag set during our Update, so it does not depend on whether
|
||||
// Cold Spell casts on by default, so pressing it also swung the unarmed secondary -
|
||||
// the kick that kept showing up alongside the cast no matter which animation trigger
|
||||
// we used. For a Skadi who has the spell, that button belongs to the spell. Keyed off
|
||||
// the live button state (via the configured shortcut, so a rebind stays in sync)
|
||||
// rather than a flag set during our Update, so it does not depend on whether
|
||||
// PlayerController's FixedUpdate happens to run first.
|
||||
if (secondaryAttack && Input.GetMouseButton(2) &&
|
||||
if (secondaryAttack && SkadiConfig.ColdSpellKey.Value.IsPressed() &&
|
||||
SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi())
|
||||
{
|
||||
var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState());
|
||||
|
|
|
|||
|
|
@ -221,9 +221,9 @@ namespace RacesOfValheim
|
|||
if (!RaceInput.Allowed) return;
|
||||
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
if (Input.GetKeyDown(KeyCode.G)) { TryTransformWithRules(SkadiProgression.GetGKeyRules(state)); return; }
|
||||
if (Input.GetKeyDown(KeyCode.H)) { TryTransformWithRules(SkadiProgression.GetHKeyRules(state)); return; }
|
||||
if (Input.GetKeyDown(KeyCode.J)) { TryTransformWithRules(SkadiProgression.GetJKeyRules(state)); return; }
|
||||
if (SkadiConfig.DrakeFormKey.Value.IsDown()) { TryTransformWithRules(SkadiProgression.GetGKeyRules(state)); return; }
|
||||
if (SkadiConfig.ModerFormKey.Value.IsDown()) { TryTransformWithRules(SkadiProgression.GetHKeyRules(state)); return; }
|
||||
if (SkadiConfig.FaderFormKey.Value.IsDown()) { TryTransformWithRules(SkadiProgression.GetJKeyRules(state)); return; }
|
||||
|
||||
// Debug Dump
|
||||
if (Input.GetKeyDown(KeyCode.F8))
|
||||
|
|
@ -311,8 +311,8 @@ namespace RacesOfValheim
|
|||
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return;
|
||||
if (isTransformed) return; // Do not cast human spell while in dragon form
|
||||
|
||||
// Middle Mouse Button to cast
|
||||
if (Input.GetMouseButtonDown(2))
|
||||
// Middle Mouse Button to cast, by default - rebindable via SkadiConfig.ColdSpellKey.
|
||||
if (SkadiConfig.ColdSpellKey.Value.IsDown())
|
||||
{
|
||||
// The improved cast is a burst rather than a rapid-fire, so it waits longer.
|
||||
float cooldown = rules.ImprovedColdSpell ? IMPROVED_SPELL_COOLDOWN : SPELL_COOLDOWN;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue