chore(release): v1.4.21 - dragon form multiplayer sync, Sverm Ravager networking, dorsal spine fix

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
Ferdinando 2026-09-23 11:56:09 +02:00
commit e7325e4d25
12 changed files with 303 additions and 10 deletions

View file

@ -192,8 +192,8 @@ namespace RacesOfValheim
// it is a real prefab that resolves by name, and it reads as xenomorph spines rather than
// as a bird.
public const string SpinesPrefab = "UndeadBjornRibcage";
public static readonly float SpineSizeSmall = 0.45f; // metres, state 5-6
public static readonly float SpineSizeFull = 0.80f; // metres, state 7+
public static readonly float SpineSizeSmall = 0.315f; // metres, state 5-6 (0.45 * 0.7)
public static readonly float SpineSizeFull = 0.56f; // metres, state 7+ (0.80 * 0.7)
/// <summary>
/// Which bone they ride. Spine2 and ONLY Spine2 - no fallback chain.
///
@ -214,6 +214,11 @@ namespace RacesOfValheim
public static readonly float SpineRotationY = -90f;
public static readonly float SpineRotationZ = 90f;
// No extra nudge by default - ApplySpines already centres the crest on the bone (half its
// own height each way) before this is added, which is what keeps the Full-Crest size from
// reaching up over the head the way basing the whole thing at the bone once did.
public static readonly float SpineOffsetY = 0f;
/// <summary>
/// What holds a falling Sverm up: the Mistlands' own fireflies, swarming under the body.
///

View file

@ -32,6 +32,7 @@ namespace RacesOfValheim
public static ConfigEntry<float> SpineRotationX;
public static ConfigEntry<float> SpineRotationY;
public static ConfigEntry<float> SpineRotationZ;
public static ConfigEntry<float> SpineOffsetY;
// ─── Emberform ───────────────────────────────────────────────────────
public static ConfigEntry<float> EmberGlowStrength;
@ -255,6 +256,17 @@ namespace RacesOfValheim
SpineRotationX = config.Bind(spines, "Rotation X", SvermConfig.SpineRotationX, "Pitch of the spines, in degrees.");
SpineRotationY = config.Bind(spines, "Rotation Y", SvermConfig.SpineRotationY, "Yaw of the spines, in degrees.");
SpineRotationZ = config.Bind(spines, "Rotation Z", SvermConfig.SpineRotationZ, "Roll of the spines, in degrees.");
// FOUND IN PLAY: at Size Full (0.8 m) the crest reached up past the shoulders and onto
// the head - ModelBorrow.Attach grounds a borrowed model's BOTTOM at the mount point and
// grows it from there, and Spine2's own local up axis runs toward the head, not out and
// away from the back. ApplySpines now centres the crest on the bone by default (half its
// height below the mount point, half above) instead of basing the whole thing there, which
// is a size-aware correction rather than a guess; this is purely an extra nudge on top of
// that, in metres along the same axis, for whatever an eye still wants adjusted.
SpineOffsetY = config.Bind(spines, "Offset Y", SvermConfig.SpineOffsetY,
"Extra nudge along the mount bone's own up axis, in metres, on top of the automatic " +
"centring. Positive moves the crest toward the head, negative toward the tail.");
}
// ─── Live reads ──────────────────────────────────────────────────────
@ -269,6 +281,8 @@ namespace RacesOfValheim
SpineRotationZ?.Value ?? SvermConfig.SpineRotationZ);
}
public static float SpineOffset => SpineOffsetY?.Value ?? SvermConfig.SpineOffsetY;
public static float EmberStrength => EmberGlowStrength?.Value ?? SvermConfig.EmberGlowStrength;
public static int Brood => CapBrood?.Value ?? SvermConfig.CapBrood;

View file

@ -310,6 +310,141 @@ namespace RacesOfValheim
}
}
// ─── Ravager Strain (remote observers) ──────────────────────────────
/// <summary>
/// Mirrors SvermRavagerForm.Enter/Exit for every OTHER client, the same way
/// Skadi_MultiplayerVisuals_Patch mirrors SkadiRace's dragon forms. SvermRavagerForm itself
/// only ever touches Player.m_localPlayer - Tick(), Enter() and RavagerFormBehavior are all
/// built around it - so without this an observer's client never knew the form was up at
/// all: no model, no hidden human body, nothing standing in for the Brute.
/// </summary>
[HarmonyPatch(typeof(VisEquipment), "UpdateVisuals")]
public static class Sverm_RavagerRemoteVisuals_Patch
{
private const string RemoteModelName = "SvermRavagerRemoteModel";
public static void Postfix(VisEquipment __instance)
{
if (__instance == null || !__instance.m_isPlayer) return;
Player player = __instance.GetComponent<Player>();
if (player == null || player.IsOwner()) return; // Local player: SvermRavagerForm handles itself.
if (!SvermVisuals.IsSvermPlayer(player)) return;
ZNetView nview = player.GetComponent<ZNetView>();
if (nview == null || !nview.IsValid()) return;
bool active = nview.GetZDO().GetBool(SvermRavagerForm.ActiveKey, false);
Transform existing = player.transform.Find(RemoteModelName);
Transform playerVisual = player.transform.Find("Visual");
if (!active)
{
if (existing != null)
{
Object.Destroy(existing.gameObject);
PlayerVisualHider.Show(playerVisual, "sverm-ravager-remote-revert");
}
return;
}
if (existing == null)
{
GameObject model = SvermRavagerForm.SpawnRemoteModel(player.transform);
if (model != null)
{
model.name = RemoteModelName;
model.AddComponent<RemoteRavagerAnimator>();
}
}
PlayerVisualHider.Hide(playerVisual, "sverm-ravager-remote");
}
}
/// <summary>
/// RemoteSkadiAnimator's counterpart for the Ravager Strain: locomotion off the replicated
/// Character, plus the bite/ram/slam/taunt trigger RavagerFormBehavior publishes through
/// SvermRavagerForm.PublishAttackTrigger. LateUpdate re-hides the player's own Visual every
/// frame for the same reason RavagerFormBehavior does on the local client - any nearby
/// equipment rebuild (VisEquipment's own refresh path) makes a hidden body visible again.
/// </summary>
public class RemoteRavagerAnimator : MonoBehaviour
{
private Animator anim;
private Player player;
private ZNetView nview;
private bool hasForwardSpeed;
private bool hasOnGround;
// Seeded from the ZDO's current value in Start, not "", so a trigger left over from an
// earlier Ravager Strain on this same player does not replay the instant this
// component is built.
private string lastAttackTrigger;
private void Start()
{
anim = GetComponentInChildren<Animator>();
player = GetComponentInParent<Player>();
nview = player != null ? player.GetComponent<ZNetView>() : null;
if (anim != null)
{
foreach (AnimatorControllerParameter p in anim.parameters)
{
if (p.type == AnimatorControllerParameterType.Float && p.name == "forward_speed") hasForwardSpeed = true;
else if (p.type == AnimatorControllerParameterType.Bool && p.name == "onGround") hasOnGround = true;
}
}
if (nview != null && nview.IsValid())
{
lastAttackTrigger = nview.GetZDO().GetString(SvermRavagerForm.AttackTriggerKey, "");
}
}
private void LateUpdate()
{
if (player == null) return;
PlayerVisualHider.Hide(player.transform.Find("Visual"), "sverm-ravager-remote");
}
private void Update()
{
if (anim == null || player == null) return;
if (hasForwardSpeed)
{
Vector3 vel = player.GetVelocity();
vel.y = 0f;
anim.SetFloat("forward_speed", vel.magnitude);
}
if (hasOnGround) anim.SetBool("onGround", player.IsOnGround());
if (nview == null || !nview.IsValid()) return;
string current = nview.GetZDO().GetString(SvermRavagerForm.AttackTriggerKey, "");
if (string.IsNullOrEmpty(current) || current == lastAttackTrigger) return;
lastAttackTrigger = current;
int seqAt = current.LastIndexOf('#');
string trigger = seqAt >= 0 ? current.Substring(0, seqAt) : current;
foreach (AnimatorControllerParameter p in anim.parameters)
{
if (p.type == AnimatorControllerParameterType.Trigger && p.name == trigger)
{
anim.SetTrigger(trigger);
break;
}
}
}
}
// ─── Spawn ───────────────────────────────────────────────────────────
/// <summary>

View file

@ -28,6 +28,18 @@ namespace RacesOfValheim
{
public static bool IsActive { get; private set; }
// Read by Sverm_RavagerRemoteVisuals_Patch (SvermPatches.cs) so every other client can
// tell the form is up at all - without this the whole thing was local-only, exactly like
// DrakeFormBehavior's flight flag and Fenrir's own form key, and other players saw nothing
// but a Sverm standing still for the whole two minutes.
public const string ActiveKey = "RacesOfValheim_SvermRavagerForm";
// Same running-count trick as DrakeFormBehavior.AttackTriggerKey: the trigger name alone
// cannot tell a remote client "a new bite just happened" when the same trigger fires twice
// in a row, since an unchanged ZDO string never re-fires a Unity Animator trigger.
public const string AttackTriggerKey = "RacesOfValheim_SvermRavagerAttack";
private static int attackTriggerSeq = 0;
private static GameObject model;
private static float expiresAt;
private static float nextAllowedAt;
@ -214,6 +226,9 @@ namespace RacesOfValheim
IsActive = true;
expiresAt = Time.time + SvermConfig.RavagerDurationSeconds;
ZNetView nview = player.GetComponent<ZNetView>();
if (nview != null && nview.IsValid()) nview.GetZDO().Set(ActiveKey, true);
player.GetSEMan().AddStatusEffect(SvermConfig.RavagerSE.GetStableHashCode(), true);
Transform visual = player.transform.Find("Visual");
@ -289,6 +304,9 @@ namespace RacesOfValheim
{
IsActive = false;
ZNetView exitNview = player.GetComponent<ZNetView>();
if (exitNview != null && exitNview.IsValid()) exitNview.GetZDO().Set(ActiveKey, false);
PlayEffect(SvermConfig.RavagerMorphOutEffects, player.transform.position);
// Nothing was ever equipped for this form - see the class doc for why - so there is
@ -382,6 +400,40 @@ namespace RacesOfValheim
if (target != null) target.transform.localScale = to;
}
// ─── Remote observers ───────────────────────────────────────────────
/// <summary>
/// Builds the same costume Enter() does, minus the grow-in tween (a remote observer just
/// needs the steady-state model, not the entrance) and minus RavagerFormBehavior, which is
/// built around Player.m_localPlayer and would do nothing useful on a copy driven by
/// someone else's client. Sverm_RavagerRemoteVisuals_Patch adds RemoteRavagerAnimator
/// instead, the same way Skadi_MultiplayerVisuals_Patch adds RemoteSkadiAnimator.
/// </summary>
public static GameObject SpawnRemoteModel(Transform playerTransform)
{
if (template == null) return null;
GameObject model = Object.Instantiate(template, playerTransform.position, playerTransform.rotation, playerTransform);
model.transform.localPosition = Vector3.zero;
model.transform.localScale = template.transform.localScale * SvermConfigManagement.RavagerScale;
model.transform.localRotation = Quaternion.Euler(0f, SvermConfigManagement.RavagerYaw, 0f);
return model;
}
/// <summary>
/// Called by RavagerFormBehavior right after it fires a trigger on the local player's own
/// copy of the Animator, so RemoteRavagerAnimator can replay the same clip on every other
/// client. See AttackTriggerKey for why a sequence number rides along with the name.
/// </summary>
public static void PublishAttackTrigger(Player player, string trigger)
{
ZNetView nview = player != null ? player.GetComponent<ZNetView>() : null;
if (nview == null || !nview.IsValid()) return;
attackTriggerSeq++;
nview.GetZDO().Set(AttackTriggerKey, trigger + "#" + attackTriggerSeq);
}
// ─── The three attacks ───────────────────────────────────────────────
/// <summary>
@ -584,6 +636,7 @@ namespace RacesOfValheim
if (!string.IsNullOrEmpty(profile.Trigger) && knownTriggers.Contains(profile.Trigger))
{
anim.SetTrigger(profile.Trigger);
SvermRavagerForm.PublishAttackTrigger(Player.m_localPlayer, profile.Trigger);
}
yield return new WaitForSeconds(hitDelay);
@ -614,6 +667,7 @@ namespace RacesOfValheim
if (!string.IsNullOrEmpty(profile.Trigger) && knownTriggers.Contains(profile.Trigger))
{
anim.SetTrigger(profile.Trigger);
SvermRavagerForm.PublishAttackTrigger(Player.m_localPlayer, profile.Trigger);
}
PlaySound(SvermConfig.RavagerTauntSoundEffects);

View file

@ -454,9 +454,19 @@ namespace RacesOfValheim
// metres and degrees - what was ASKED for - not bone-local numbers.
Quaternion wantedRotation = SvermConfigManagement.SpineRotation();
// Basing the whole crest AT the bone and growing it upward (ModelBorrow.Attach grounds
// a borrowed model's bottom at the mount point) reached up past the shoulders and onto
// the head once the crest got tall - Spine2's own local up axis runs toward the head,
// not out and away from the back. Centring it on the bone instead - half its height
// below the mount point, half above - keeps the same rotation an eye already approved
// while stopping the Full Crest size from overshooting. SpineOffsetY is an additional
// nudge along the same axis, for whatever still needs adjusting by eye.
float wantedOffsetY = -wanted / 2f + SvermConfigManagement.SpineOffset;
SvermSpineTag tag = existing != null ? existing.GetComponent<SvermSpineTag>() : null;
if (existing != null && (tag == null
|| !Mathf.Approximately(tag.Size, wanted)
|| !Mathf.Approximately(tag.OffsetY, wantedOffsetY)
|| Quaternion.Angle(tag.Rotation, wantedRotation) > 0.5f))
{
existing.name = SpinesName + "_Removed";
@ -474,7 +484,7 @@ namespace RacesOfValheim
bone,
SpinesName,
SvermConfig.SpinesPrefab,
Vector3.zero,
new Vector3(0f, wantedOffsetY / lossy, 0f),
wantedRotation,
wanted / lossy,
"Sverm");
@ -484,6 +494,7 @@ namespace RacesOfValheim
SvermSpineTag built = holder.AddComponent<SvermSpineTag>();
built.Size = wanted;
built.Rotation = wantedRotation;
built.OffsetY = wantedOffsetY;
existing = holder.transform;
}
@ -532,6 +543,7 @@ namespace RacesOfValheim
{
public float Size;
public Quaternion Rotation = Quaternion.identity;
public float OffsetY;
}
// ─── Glide motes ─────────────────────────────────────────────────────