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

@ -78,7 +78,11 @@ namespace RacesOfValheim
formInstance.name = wanted;
formInstance.transform.localPosition = formName == "Hatchling" ? new Vector3(0f, -1.0f, 0f) : Vector3.zero;
formInstance.transform.localRotation = Quaternion.identity;
// Same config-driven size the transforming player's own client applies (see
// SkadiRace.GetFormScale) - without it every remote observer saw the prefab's
// raw 1x Visual scale, Moder's ModerScale shrink included.
formInstance.transform.localScale = SkadiRace.GetFormScaleForPrefab(formName);
if (formInstance.GetComponent<RemoteSkadiAnimator>() == null)
{
formInstance.AddComponent<RemoteSkadiAnimator>();
@ -94,27 +98,62 @@ namespace RacesOfValheim
{
private Animator anim;
private Player player;
private ZNetView nview;
// Seeded from whatever the ZDO already holds in Start, not "", so a value left over from an
// earlier transformation on this same player does not read as a brand-new attack the moment
// this component is built and replay a stale trigger on entry.
private string lastAttackTrigger;
private void Start()
{
anim = GetComponent<Animator>();
if (anim == null) anim = GetComponentInChildren<Animator>();
player = GetComponentInParent<Player>();
nview = player != null ? player.GetComponent<ZNetView>() : null;
if (nview != null && nview.IsValid())
{
lastAttackTrigger = nview.GetZDO().GetString(DrakeFormBehavior.AttackTriggerKey, "");
}
}
private void Update()
{
if (anim == null || player == null) return;
bool flying = HarmonyLib.Traverse.Create(player).Field<bool>("m_flying").Value;
bool grounded = !flying && player.IsOnGround();
anim.SetBool("onGround", grounded);
anim.SetBool("flying", flying);
Vector3 vel = player.GetVelocity();
vel.y = 0f;
anim.SetFloat("forward_speed", vel.magnitude);
// The bite/claw/breath trigger DrakeFormBehavior fires on the transforming player's own
// client - without this, remote observers only ever saw locomotion, never an attack play.
if (nview != null && nview.IsValid())
{
string current = nview.GetZDO().GetString(DrakeFormBehavior.AttackTriggerKey, "");
if (!string.IsNullOrEmpty(current) && current != lastAttackTrigger)
{
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;
}
}
}
}
}
}