fix: Cultist breath pose holds, roar loops, Cultist stands still

The creature's CharacterAnimEvent resets Animator.speed to 1 every physics step
outside a vanilla attack, so the speed-0 pin never held: the pose is now replayed
at the pin each frame. The flame ZSFX loops without its fade-out. While breathing
the player is held still through FenrirForms.LocalAttacking (no walking cast clip
exists); the howl waits for the breath to end.
This commit is contained in:
kanym 2026-10-29 14:24:04 +01:00
commit c5387421d4

View file

@ -343,6 +343,14 @@ namespace RacesOfValheim
main.startLifetimeMultiplier *= 1.2f;
main.loop = true;
}
// The roar of the fire, the same one-throw story: set before its ZSFX first plays.
foreach (ZSFX sfx in instance.GetComponentsInChildren<ZSFX>())
{
sfx.m_fadeOutOnAwake = false;
AudioSource source = sfx.GetComponent<AudioSource>();
if (source != null) source.loop = true;
}
return instance;
}
@ -889,7 +897,7 @@ namespace RacesOfValheim
StopFire();
}
if (canAct && FenrirConfig.HowlKey.Value.IsDownIgnoringHeldKeys())
if (canAct && !isShootingFire && FenrirConfig.HowlKey.Value.IsDownIgnoringHeldKeys())
{
StartCoroutine(HowlRoutine());
}
@ -977,6 +985,10 @@ namespace RacesOfValheim
isShootingFire = true;
LocalBreathing = true;
// Planted while it breathes, as the vanilla Cultist is: its controller has no walking
// version of the cast, so a moving Cultist slid along in the casting pose.
// Fenrir_FormHoldStill_Patch holds the player; turning to the camera still works.
FenrirForms.LocalAttacking = true;
flaming = false;
fireStarted = Time.time;
fireTimer = 0f;
@ -1018,6 +1030,7 @@ namespace RacesOfValheim
private void OnDestroy()
{
if (isShootingFire) FenrirAttackSync.PublishFire(false);
if (isShootingFire) FenrirForms.LocalAttacking = false;
LocalBreathing = false;
}
@ -1025,6 +1038,7 @@ namespace RacesOfValheim
{
isShootingFire = false;
LocalBreathing = false;
FenrirForms.LocalAttacking = false;
flaming = false;
cultistAnim.ResetTrigger("attack_flames");
FenrirAttackSync.PublishFire(false);
@ -1783,18 +1797,26 @@ namespace RacesOfValheim
return t >= FlamesAt || (t < 0f && Time.time - started >= FlamesAt + 0.2f);
}
/// <summary>Holds the arms in the casting pose: the Animator stops once the clip reaches PinAt.</summary>
/// <summary>
/// Holds the arms in the casting pose: once the clip reaches PinAt it is put back there every
/// frame. Not with Animator.speed = 0, which is what the troll's pin uses: the creature's own
/// CharacterAnimEvent sits on this model and sets speed back to 1 on every physics step while
/// the player is not in a vanilla attack, so the clip ran on to its end and the Cultist went
/// back to idle with the fire still pouring out.
/// </summary>
public static void Hold(Animator anim)
{
if (!anim.IsInTransition(0) && ClipTime(anim) >= PinAt) anim.speed = 0f;
if (anim.IsInTransition(0)) return;
AnimatorStateInfo info = anim.GetCurrentAnimatorStateInfo(0);
if (info.fullPathHash != State || info.length <= 0f) return;
if (info.normalizedTime * info.length >= PinAt) anim.Play(State, 0, PinAt / info.length);
}
/// <summary>Lets the Animator run again and blends out of the clip, unless a stagger has
/// taken over (FormStagger has fired the form's own).</summary>
/// <summary>Blends out of the clip, unless a stagger has taken over (FormStagger has fired
/// the form's own).</summary>
public static void Release(Animator anim, Player player)
{
if (anim == null) return;
anim.speed = 1f;
if (ClipTime(anim) >= 0f && (player == null || !player.IsStaggering()))
anim.CrossFadeInFixedTime(MovementState, Fade, 0);
}