fix(skadi): Middle Mouse in Drake form no longer spends the attack cooldown on nothing

PerformAttackCoroutine starts the cooldown and shows its icon before it
looks at the form, and the Drake has no Middle Mouse attack, so the press
cost a cooldown and fired nothing. HasAttackForButton now answers for the
Drake too and guards all three buttons, as it already did Left Mouse.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
kanym 2026-09-27 00:52:01 +02:00
commit 0a0d9410e7

View file

@ -221,14 +221,14 @@ namespace RacesOfValheim
}
else if (SkadiConfig.BreathAttackKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(2))
{
if (Time.time - lastAttackTime >= ATTACK_COOLDOWN)
if (HasAttackForButton(2) && Time.time - lastAttackTime >= ATTACK_COOLDOWN)
{
StartCoroutine(PerformAttackCoroutine(2));
}
}
else if ((SkadiConfig.SpinAttackKey.Value.IsDownIgnoringHeldKeys() || RaceInput.PadAttackDown(1)) && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // Fader Spin
{
if (Time.time - lastAttackTime >= ATTACK_COOLDOWN)
if (HasAttackForButton(1) && Time.time - lastAttackTime >= ATTACK_COOLDOWN)
{
StartCoroutine(PerformAttackCoroutine(1));
}
@ -236,13 +236,23 @@ namespace RacesOfValheim
}
}
// Whether this form has an attack on this button right now. Asked before the cooldown for
// every button, because PerformAttackCoroutine starts the cooldown and shows its icon before
// it looks at the form: a button with nothing behind it used to spend both and fire nothing.
//
// The Drake has only its Left Mouse volley; Middle Mouse is Moder's and Fader's breath.
// Airborne Moder keeps the same hand as the ground: the ranged breath is Middle Mouse, and
// Left Mouse has no attack in the air (its ground bite and claws cannot reach from up
// there). Checked before the cooldown so a stray left click does not eat the next volley.
// there).
private bool HasAttackForButton(int button)
{
if (formRules == null) return false;
if (formRules.Form == SkadiProgression.FormType.Drake && button != 0)
{
return false;
}
bool airborne = isFlying || isLanding;
if (airborne && formRules.Form == SkadiProgression.FormType.Moder && button != 2)
{