fix(fenrir): hidden human no longer attacks or blocks under a form

The attack block patched Character.StartAttack, which Humanoid overrides
without calling the base, so it never ran; and it covered the Fenring only.
Every form swing also fired the hidden human's attack: stamina spent,
regen held at zero while it played, and forward_speed dropped to 0. Patch
Humanoid.StartAttack for all four forms, and clear m_blocking after
SetControls so the pad's heavy attack stops raising the guard.

Forms treat the player as airborne only after 0.25 s off the ground, so
bumps no longer flicker run to idle. Melee reach ignores the target's own
colliders and accepts a clear line from the eyes or the attack point, with
an opt-in hit log. Sunrise names the key that still works by day.
This commit is contained in:
kanym 2026-09-28 22:19:37 +02:00
commit b4b6fe3758
8 changed files with 323 additions and 153 deletions

View file

@ -22,6 +22,8 @@ namespace RacesOfValheim {
private FenrirProgression.FormRules activeRules = null;
private bool wasNight = false;
private float sunSicknessTimer = 0f;
// Said instead of the usual "back to human" line by the next reversion, then cleared.
private string revertMessage;
private void Awake()
{
@ -142,6 +144,7 @@ namespace RacesOfValheim {
if (activeRules == null || activeRules.NeedsNight)
{
sunSicknessTimer = FenrirConfig.SunSicknessDuration.Value;
if (isTransformed) revertMessage = SunTookFormMessage();
ForceRevert();
}
}
@ -213,6 +216,46 @@ namespace RacesOfValheim {
StartCoroutine(TransformIntoWolfRoutine(rules));
}
/// <summary>
/// Says why sunrise took the form, and which key still works by day.
///
/// A player reported this as a bug: "sometimes" the day turned them human even though they
/// had unlocked day forms. Which forms go by day depends on the key as well as the tier - at
/// Moder the Ulv on the Wolf key walks by day while the Fenring on the Fenrir key is still
/// night-only - so from the outside the same sunrise looked random. The rule stays; this
/// makes it readable. Shown in place of "You returned to human form", which would otherwise
/// replace it on screen half a second later.
/// </summary>
private static string SunTookFormMessage()
{
int state = BossProgressionManager.GetCurrentProgressionState();
string[] day = DayFormFor(FenrirProgression.GetGKeyRules(state), FenrirConfig.WolfFormKey.Value)
?? DayFormFor(FenrirProgression.GetHKeyRules(state), FenrirConfig.FenrirFormKey.Value)
?? DayFormFor(FenrirProgression.GetJKeyRules(state), FenrirConfig.CultistFormKey.Value);
return day != null
? ModText.Get("rov_msg_fenrir_sun_takes_form_day_key", day[0], day[1])
: ModText.Get("rov_msg_fenrir_sun_takes_form");
}
// The form's name token and the key, or null when that key's form is night-only too.
private static string[] DayFormFor(FenrirProgression.FormRules rules, BepInEx.Configuration.KeyboardShortcut key)
{
if (rules == null || rules.Form == FenrirProgression.FormType.None || rules.NeedsNight) return null;
return new[] { FormNameToken(rules.Form), key.ToString() };
}
private static string FormNameToken(FenrirProgression.FormType form)
{
switch (form)
{
case FenrirProgression.FormType.Wolf: return "$rov_msg_fenrir_formname_wolf";
case FenrirProgression.FormType.Ulv: return "$rov_msg_fenrir_formname_ulv";
case FenrirProgression.FormType.Cultist: return "$rov_msg_fenrir_formname_cultist";
}
return "$rov_msg_fenrir_formname_fenrir";
}
public void ForceRevert()
{
if (isTransformed && !isTransformingSequence)
@ -481,7 +524,8 @@ namespace RacesOfValheim {
Player.m_localPlayer.GetSEMan().RemoveStatusEffect("SE_WolfForm".GetStableHashCode());
isTransformed = false;
Player.m_localPlayer.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_fenrir_returned_human_form"));
Player.m_localPlayer.Message(MessageHud.MessageType.Center, revertMessage ?? ModText.Get("rov_msg_fenrir_returned_human_form"));
revertMessage = null;
if (activeRules != null && activeRules.CooldownMinutes > 0)
{