minor bugfix and pad support

This commit is contained in:
Ferdinando 2026-09-12 10:42:01 +02:00
commit 6e87be3c77
21 changed files with 574 additions and 85 deletions

View file

@ -131,8 +131,13 @@ namespace RacesOfValheim
{
if (Player.m_localPlayer == null || Player.m_localPlayer.IsDead()) return;
// Handle Flight Toggle (Right Mouse by default, rebindable) - Disabled for Fader
if (RaceInput.Allowed && SkadiConfig.FlightToggleKey.Value.IsDownIgnoringHeldKeys() && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
// Handle Flight Toggle (Right Mouse by default, rebindable) - Disabled for Fader.
// On a pad it is the Block button, Right Mouse's vanilla partner (RaceInput.PadAttackDown(1)):
// the left trigger in the Classic layout. Free here - neither drake nor Moder has a
// button-1 attack; the only one is Fader's spin, and Fader never flies.
if (RaceInput.Allowed &&
(SkadiConfig.FlightToggleKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(1)) &&
formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
{
if (!isFlying && !isLanding)
{

View file

@ -305,6 +305,8 @@ namespace RacesOfValheim
// How much of the aim heading survives the climb out of water. Mostly up, with enough
// forward in it that the player still chooses which shore they surface towards.
private const float LIFTOFF_HEADING_BLEND = 0.35f;
// How far the left stick has to be pushed before it counts as W or S.
private const float StickThreshold = 0.5f;
/// <summary>
/// True while the local player is beating backwards this frame. Read by
@ -326,10 +328,17 @@ namespace RacesOfValheim
var traverse = Traverse.Create(__instance);
Vector3 lookDir = Player.m_localPlayer.GetLookDir();
bool input = RaceInput.Allowed;
bool forward = input && Input.GetKey(KeyCode.W);
// The pad's half of W/S: the left stick, read with vanilla's own sign -
// PlayerController.FixedUpdate takes forward as the NEGATED GetJoyLeftStickY.
// Flight only knows powered forward, reverse or neither, so the stick is a
// threshold, not a throttle. Steering stays on the camera, i.e. the right stick.
float stick = -ZInput.GetJoyLeftStickY();
bool forward = input && (Input.GetKey(KeyCode.W) || stick > StickThreshold);
// Forward wins a W+S mash rather than the two cancelling into a dead hover.
bool backward = input && !forward && Input.GetKey(KeyCode.S);
bool sprintKey = input && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift));
bool backward = input && !forward && (Input.GetKey(KeyCode.S) || stick < -StickThreshold);
// Sprint on a pad is vanilla's run button, wherever the chosen layout puts it.
bool sprintKey = input && (Input.GetKey(KeyCode.LeftShift) || Input.GetKey(KeyCode.RightShift) ||
ZInput.GetButton("JoyRun"));
bool onGround = __instance.IsOnGround();
// IsSwimming is the exact test UpdateMotion uses to hand the frame to UpdateSwimming
// instead of UpdateFlying, so it is also the one condition SkadiWaterFlightPatch has