diff --git a/JotunnModStub/Skadi/DrakeFormBehavior.cs b/JotunnModStub/Skadi/DrakeFormBehavior.cs
index b325194..74ff020 100644
--- a/JotunnModStub/Skadi/DrakeFormBehavior.cs
+++ b/JotunnModStub/Skadi/DrakeFormBehavior.cs
@@ -20,6 +20,19 @@ namespace RacesOfValheim
// Read by RacesVisualController on other clients so they can keep this character airborne.
public const string FlyingKey = "RacesOfValheim_SkadiFlying";
+ ///
+ /// Time.time until which a breath is still streaming. Read by SkadiReverseFacingPatch to
+ /// hold the body on the aim for the duration.
+ ///
+ /// A deadline rather than a bool on purpose: the attack coroutine has several early exits
+ /// (a missing prefab, not enough stamina) and can be cut short outright when the form is
+ /// destroyed mid-breath, so a flag would leak set and pin the body forever. A timestamp
+ /// cannot leak - it expires on its own however the coroutine ends.
+ ///
+ private static float breathingUntil = -1f;
+
+ public static bool IsBreathing => Time.time < breathingUntil;
+
private void SetFlying(bool value)
{
HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_flying").SetValue(value);
@@ -85,18 +98,41 @@ namespace RacesOfValheim
{
Active = this;
anim = GetComponentInChildren();
+
if (Player.m_localPlayer != null)
{
SetFlying(false);
}
}
+ ///
+ /// Animator.SetTrigger on a name the controller does not have is silently ignored by Unity,
+ /// so a wrong trigger looks exactly like "the animation did not play" with nothing in the
+ /// log. Check before setting, while the form's real trigger names are still being pinned
+ /// down against the live prefabs.
+ ///
+ private void SetAttackTrigger(string trigger)
+ {
+ if (anim == null) return;
+
+ foreach (AnimatorControllerParameter p in anim.parameters)
+ {
+ if (p.type == AnimatorControllerParameterType.Trigger && p.name == trigger)
+ {
+ anim.SetTrigger(trigger);
+ return;
+ }
+ }
+
+ Jotunn.Logger.LogWarning($"[SkadiFormDebug] {formRules?.Form}: no trigger named '{trigger}' on this animator.");
+ }
+
private void Update()
{
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.IsDown() && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
+ if (RaceInput.Allowed && SkadiConfig.FlightToggleKey.Value.IsDownIgnoringHeldKeys() && formRules != null && formRules.Form != SkadiProgression.FormType.SkeletonDragon)
{
if (!isFlying && !isLanding)
{
@@ -155,21 +191,21 @@ namespace RacesOfValheim
// as it did when these were raw mouse-button checks.
if (CanAttackNow() && RaceInput.Allowed)
{
- if (SkadiConfig.PrimaryAttackKey.Value.IsDown())
+ if (SkadiConfig.PrimaryAttackKey.Value.IsDownIgnoringHeldKeys())
{
if (HasAttackForButton(0) && Time.time - lastAttackTime >= ATTACK_COOLDOWN)
{
StartCoroutine(PerformAttackCoroutine(0));
}
}
- else if (SkadiConfig.BreathAttackKey.Value.IsDown())
+ else if (SkadiConfig.BreathAttackKey.Value.IsDownIgnoringHeldKeys())
{
if (Time.time - lastAttackTime >= ATTACK_COOLDOWN)
{
StartCoroutine(PerformAttackCoroutine(2));
}
}
- else if (SkadiConfig.SpinAttackKey.Value.IsDown() && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // Fader Spin
+ else if (SkadiConfig.SpinAttackKey.Value.IsDownIgnoringHeldKeys() && formRules.Form == SkadiProgression.FormType.SkeletonDragon) // Fader Spin
{
if (Time.time - lastAttackTime >= ATTACK_COOLDOWN)
{
@@ -291,7 +327,19 @@ namespace RacesOfValheim
}
if (!isMelee && !TrySpendVolleyStamina(projCount)) yield break;
- if (anim != null) anim.SetTrigger(attackTrigger);
+
+ // Committed for the same reason as Fader's below: a 16- or 20-projectile volley
+ // lasts long enough for the camera to swing away from where the animation is
+ // still breathing.
+ // Grounded, the same as Fader's below: the head is held on the aim and the breath
+ // comes out of it. In the air the flight patch already steers the body, so this
+ // stays out of its way and the volley simply follows the same muzzle.
+ if (!isMelee && !isFlying && !isLanding)
+ {
+ breathingUntil = Time.time + projDelay + projCount * 0.05f + 0.5f;
+ }
+
+ SetAttackTrigger(attackTrigger);
yield return new WaitForSeconds(projDelay);
@@ -311,9 +359,9 @@ namespace RacesOfValheim
float vel = staffDrop.m_itemData.m_shared.m_attack.m_projectileVel;
for (int i = 0; i < projCount; i++)
{
- Vector3 spawnPos = Player.m_localPlayer.GetEyePoint() + Player.m_localPlayer.GetLookDir() * 3.0f;
- Vector3 targetDir = Player.m_localPlayer.GetLookDir();
-
+ Vector3 targetDir = Player.m_localPlayer.transform.forward;
+ Vector3 spawnPos = Player.m_localPlayer.GetEyePoint() + targetDir * 3.0f;
+
if (projCount > 1)
{
Vector3 right = Vector3.Cross(Vector3.up, targetDir);
@@ -377,7 +425,26 @@ namespace RacesOfValheim
}
if (!isMelee && !TrySpendVolleyStamina(projCount)) yield break;
- if (anim != null) anim.SetTrigger(attackTrigger);
+
+ // A breath is a stream, not a shot: 60 shards at 0.05 s each runs for about three
+ // seconds. Reading GetLookDir() fresh inside that loop let the ice track the
+ // crosshair live while the model's own breath VFX - baked into the animation, and
+ // so always leaving the muzzle - stayed with the body, which only turns at
+ // m_turnSpeed. Sweep the camera mid-breath and the two ended up pointing opposite
+ // ways. The direction is committed here instead, and the body is turned onto it.
+ // The breath follows the muzzle rather than a direction captured when the key went
+ // down. The model's own breath VFX is part of the animation and always leaves the
+ // mouth, so any direction the projectiles keep on their own drifts away from it -
+ // locking it at the press just swapped which of the two lagged. Pinning the body
+ // to the aim for the duration (breathingUntil, read by SkadiReverseFacingPatch)
+ // lets the mouse steer the head, and the projectiles below simply come out of
+ // wherever it has turned to, so ice and VFX cannot separate.
+ if (!isMelee)
+ {
+ breathingUntil = Time.time + projDelay + projCount * 0.05f + 0.5f;
+ }
+
+ SetAttackTrigger(attackTrigger);
yield return new WaitForSeconds(projDelay);
@@ -397,8 +464,8 @@ namespace RacesOfValheim
float vel = staffDrop.m_itemData.m_shared.m_attack.m_projectileVel;
for (int i = 0; i < projCount; i++)
{
- Vector3 spawnPos = Player.m_localPlayer.GetEyePoint() + Player.m_localPlayer.GetLookDir() * 4.0f;
- Vector3 targetDir = Player.m_localPlayer.GetLookDir();
+ Vector3 targetDir = Player.m_localPlayer.transform.forward;
+ Vector3 spawnPos = Player.m_localPlayer.GetEyePoint() + targetDir * 4.0f;
if (projCount > 1)
{
diff --git a/JotunnModStub/Skadi/SkadiPatches.cs b/JotunnModStub/Skadi/SkadiPatches.cs
index 7e1c3cd..6eba5d9 100644
--- a/JotunnModStub/Skadi/SkadiPatches.cs
+++ b/JotunnModStub/Skadi/SkadiPatches.cs
@@ -444,6 +444,19 @@ namespace RacesOfValheim
public static bool Prefix(Player __instance, ref bool __result)
{
if (__instance != Player.m_localPlayer) return true;
+
+ // A breath in progress holds the body on the aim, whether the player is moving or not.
+ // Character.UpdateRotation only steers by m_lookYaw when AlwaysRotateCamera() is true
+ // or the player is standing still - otherwise it faces m_moveDir. So running or
+ // strafing mid-breath turned the model (and the muzzle VFX baked into its animation)
+ // towards the run while our projectiles kept going where the player aimed, which is
+ // how the ice and the poison ended up pointing different ways.
+ if (DrakeFormBehavior.IsBreathing && DrakeFormBehavior.Active != null)
+ {
+ __result = true;
+ return false;
+ }
+
if (!SkadiDirectedFlightPatch.Reversing) return true;
DrakeFormBehavior form = DrakeFormBehavior.Active;
@@ -473,7 +486,7 @@ namespace RacesOfValheim
// 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 && SkadiConfig.ColdSpellKey.Value.IsPressed() &&
+ if (secondaryAttack && SkadiConfig.ColdSpellKey.Value.IsPressedIgnoringHeldKeys() &&
SkadiRace.Instance != null && SkadiRace.Instance.IsSkadi())
{
var rules = SkadiProgression.GetRules(BossProgressionManager.GetCurrentProgressionState());