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

@ -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);