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:
parent
6499eb71df
commit
e7325e4d25
12 changed files with 303 additions and 10 deletions
|
|
@ -105,6 +105,14 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// Read by RemoteSkadiAnimator (SkadiPatches.cs) so other clients' copy of the form actually
|
||||
// plays the bite/claw/breath clip instead of just locomotion. The suffix is a running count,
|
||||
// not just the trigger name, because the same attack (e.g. two bites in a row) has to look
|
||||
// like a NEW event to a remote client diffing the ZDO string - an unchanged value never
|
||||
// re-triggers a Unity Animator trigger parameter.
|
||||
public const string AttackTriggerKey = "RacesOfValheim_SkadiAttackTrigger";
|
||||
private static int attackTriggerSeq = 0;
|
||||
|
||||
/// <summary>
|
||||
/// 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
|
||||
|
|
@ -120,6 +128,13 @@ namespace RacesOfValheim
|
|||
if (p.type == AnimatorControllerParameterType.Trigger && p.name == trigger)
|
||||
{
|
||||
anim.SetTrigger(trigger);
|
||||
|
||||
ZNetView nview = Player.m_localPlayer?.GetComponent<ZNetView>();
|
||||
if (nview != null && nview.IsValid())
|
||||
{
|
||||
attackTriggerSeq++;
|
||||
nview.GetZDO().Set(AttackTriggerKey, trigger + "#" + attackTriggerSeq);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -600,6 +600,18 @@ namespace RacesOfValheim
|
|||
return Vector3.one * SkadiConfig.DrakeScale.Value; // Drake
|
||||
}
|
||||
|
||||
// Same lookup, keyed by the prefab name the ZDO actually carries ("RacesOfValheim_SkadiForm"),
|
||||
// so Skadi_MultiplayerVisuals_Patch can size a remote observer's copy of the form the same way
|
||||
// the transforming player's own client does. Without this the remote instance was left at the
|
||||
// prefab's raw Visual scale (1x) no matter which form or config value was in play - Moder's
|
||||
// ModerScale nerf, in particular, only ever applied on the transformed player's own screen.
|
||||
public static Vector3 GetFormScaleForPrefab(string prefabName)
|
||||
{
|
||||
if (prefabName == "Dragon") return Vector3.one * SkadiConfig.ModerScale.Value;
|
||||
if (prefabName == "Fader") return Vector3.one * SkadiConfig.FaderScale.Value;
|
||||
return Vector3.one * SkadiConfig.DrakeScale.Value; // Hatchling
|
||||
}
|
||||
|
||||
private IEnumerator TransformRoutine(SkadiProgression.FormRules rules)
|
||||
{
|
||||
isTransformingSequence = true;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue