diff --git a/JotunnModStub/RaceEyeHeight.cs b/JotunnModStub/RaceEyeHeight.cs
index 7195861..563f50d 100644
--- a/JotunnModStub/RaceEyeHeight.cs
+++ b/JotunnModStub/RaceEyeHeight.cs
@@ -24,7 +24,8 @@ namespace RacesOfValheim
/// their eye with them, and read as a factor of 1 here, so they are left alone by
/// construction. So is a player inside a borrowed form (wolf, drake, bat): those hide the
/// body's renderers and leave its scale at 1, and the form's own camera handling is its
- /// business.
+ /// business. The Trenta's Muspell is the exception: it hands over its own eye height, see
+ /// TrentaMuspell.TryGetEyeHeight.
///
/// Applied to every player, not just the one at the keyboard. m_eye is also what a mob aims
/// at, so a Dvergar's head being where the Dvergar's head is matters on every client.
@@ -66,10 +67,21 @@ namespace RacesOfValheim
rest.LocalPosition = eye.localPosition;
}
- float scale = visual.transform.localScale.y;
- if (scale < MinScale) return;
+ Vector3 wanted;
+ if (TrentaMuspell.TryGetEyeHeight(player, out float formEye))
+ {
+ // The one borrowed form that sets its own eye: the Muspell is too tall to look out
+ // of from a person's height. Asked before the hidden-body check below, because the
+ // Muspell is exactly what hides the body.
+ wanted = new Vector3(rest.LocalPosition.x, formEye, rest.LocalPosition.z);
+ }
+ else
+ {
+ float scale = visual.transform.localScale.y;
+ if (scale < MinScale) return;
+ wanted = rest.LocalPosition * scale;
+ }
- Vector3 wanted = rest.LocalPosition * scale;
if ((eye.localPosition - wanted).sqrMagnitude > 0.000001f)
{
eye.localPosition = wanted;
diff --git a/JotunnModStub/Trenta/TrentaMuspell.cs b/JotunnModStub/Trenta/TrentaMuspell.cs
index 2864acf..4499faf 100644
--- a/JotunnModStub/Trenta/TrentaMuspell.cs
+++ b/JotunnModStub/Trenta/TrentaMuspell.cs
@@ -22,6 +22,31 @@ namespace RacesOfValheim
private static GameObject currentTransformation;
private static bool isTransformingSequence;
+ ///
+ /// How high the form's head sits above the player's feet at a form scale of 1, measured
+ /// off the clone the moment it is made. Multiplied by the form's current scale it gives the
+ /// eye height, so the camera rides the grow and shrink tween with the model.
+ ///
+ private static float headHeightAtScaleOne;
+
+ ///
+ /// The eye height the Muspell wants for , for RaceEyeHeight.
+ ///
+ /// The form hides the player's own body by shrinking its Visual to 0.001, and RaceEyeHeight
+ /// reads anything that small as "hidden" and leaves the eye alone - so the camera stayed at
+ /// a person's eye level inside something the size of a house. The form is local only, so
+ /// this only ever answers for the local player.
+ ///
+ public static bool TryGetEyeHeight(Player player, out float height)
+ {
+ height = 0f;
+ if (!IsTransformed || currentTransformation == null || headHeightAtScaleOne <= 0f) return false;
+ if (player == null || player != Player.m_localPlayer) return false;
+
+ height = headHeightAtScaleOne * currentTransformation.transform.localScale.y;
+ return true;
+ }
+
public static void Toggle(Player player)
{
if (isTransformingSequence) return;
@@ -167,6 +192,14 @@ namespace RacesOfValheim
currentTransformation.transform.localPosition = Vector3.zero;
currentTransformation.transform.localRotation = Quaternion.identity;
+ // Measured here, straight off the clone, before the grow tween touches its scale. The
+ // head is the same bone the spike volley fires from.
+ Transform head = currentTransformation.transform.Find(MuspellFormBehavior.HeadPath);
+ float cloneScale = currentTransformation.transform.localScale.y;
+ headHeightAtScaleOne = head != null && cloneScale > 0f
+ ? (head.position.y - player.transform.position.y) / cloneScale
+ : 0f;
+
// Same reasoning as FenrirRace.ExecuteTransformation: the clone must never carry
// whatever AI/gameplay component made the source a functioning boss.
Component animEvent = currentTransformation.GetComponent("AnimEvent");
@@ -219,6 +252,8 @@ namespace RacesOfValheim
///
public class MuspellFormBehavior : MonoBehaviour
{
+ public const string HeadPath = "Armature/root/spine1/spine2/spine3/head";
+
private Animator playerAnim;
private Animator formAnim;
private Transform muzzle;
@@ -232,7 +267,7 @@ namespace RacesOfValheim
// The spike volley should leave from the Elder's own mouth, not the (now hidden)
// player's eye point underneath it.
- muzzle = transform.Find("Armature/root/spine1/spine2/spine3/head");
+ muzzle = transform.Find(HeadPath);
}
private void Update()
@@ -255,6 +290,8 @@ namespace RacesOfValheim
TrySet(() => formAnim.SetFloat("sideway_speed", playerAnim.GetFloat("sideway_speed")));
}
+ LoopIdle();
+
if (!isGrounded || !RaceInput.Allowed) return;
if (RaceInput.AttackDown(0)) // Stomp
@@ -267,6 +304,42 @@ namespace RacesOfValheim
}
}
+ private const string IdleClip = "Unarmed Idle";
+
+ ///
+ /// Keeps the idle going. The Elder's "Unarmed Idle" clip is not a looping clip (dumpanim:
+ /// loop=False, 1.90s), so after the stand-up or any attack the form played it once and
+ /// froze on its last frame. The boss never showed it, being hardly ever idle; a player in
+ /// the form is idle most of the time. The clip's flag lives in the game's asset, so the
+ /// state is restarted from here instead, once it has run to its end.
+ ///
+ /// The idle shares a locomotion blend tree with the four Swagger Walk clips, so the clip
+ /// list for the state holds all of them and the idle is not necessarily first: it is found
+ /// by name and must be carrying most of the weight, which is what "standing still" means.
+ /// Play and not CrossFade: Unity can ignore a cross-fade from a state into itself, and
+ /// the first version of this did exactly nothing for that reason.
+ ///
+ private void LoopIdle()
+ {
+ if (formAnim.IsInTransition(0)) return;
+
+ bool idle = false;
+ foreach (AnimatorClipInfo info in formAnim.GetCurrentAnimatorClipInfo(0))
+ {
+ if (info.clip != null && info.clip.name == IdleClip && info.weight >= 0.5f)
+ {
+ idle = true;
+ break;
+ }
+ }
+ if (!idle) return;
+
+ AnimatorStateInfo state = formAnim.GetCurrentAnimatorStateInfo(0);
+ if (state.normalizedTime < 1f) return;
+
+ formAnim.Play(state.fullPathHash, 0, 0f);
+ }
+
private static void TrySet(System.Action set)
{
try { set(); } catch { }