bugfix 24/09/26

This commit is contained in:
Ferdinando 2026-09-24 10:30:39 +02:00
commit 9bebcf340b
7 changed files with 205 additions and 31 deletions

View file

@ -234,8 +234,11 @@ namespace RacesOfValheim
refinery.m_haveMeatObject = smelter.m_haveOreObject;
refinery.m_noMeatObject = smelter.m_noOreObject;
refinery.m_animators = smelter.m_animators;
refinery.m_meatAddedEffects = smelter.m_oreAddedEffects;
refinery.m_boneAddedEffects = smelter.m_fuelAddedEffects;
// Crossed on purpose: the sounds sit the other way round from the slots. The ore
// effect is the dry clatter and the fuel effect the wet slap, so flesh takes the
// fuel one and bone the ore one.
refinery.m_meatAddedEffects = smelter.m_fuelAddedEffects;
refinery.m_boneAddedEffects = smelter.m_oreAddedEffects;
refinery.m_produceEffects = smelter.m_produceEffects;
refinery.m_smokeSpawner = smelter.m_smokeSpawner;
@ -243,8 +246,8 @@ namespace RacesOfValheim
// Two Radiators under _enabled are what shot the tester: see IsOffensive.
StripOffensive(prefab, PieceName);
SanitiseEffects(refinery.m_meatAddedEffects, PieceName + ".oreAdded");
SanitiseEffects(refinery.m_boneAddedEffects, PieceName + ".fuelAdded");
SanitiseEffects(refinery.m_meatAddedEffects, PieceName + ".fuelAdded");
SanitiseEffects(refinery.m_boneAddedEffects, PieceName + ".oreAdded");
SanitiseEffects(refinery.m_produceEffects, PieceName + ".produce");
prefab.transform.localScale = Vector3.one * ModelScale;

View file

@ -39,6 +39,73 @@ namespace RacesOfValheim
}
}
/// <summary>
/// The attack half of somebody else's form: the owner's client publishes each trigger it fires
/// on its own copy of the Animator, RemoteFenrirAnimator replays it on the copy every other
/// client sees. The running count rides along because an unchanged ZDO string would never
/// re-fire a Unity Animator trigger when the same bite lands twice in a row - the same trick as
/// DrakeFormBehavior.AttackTriggerKey and SvermRavagerForm.AttackTriggerKey.
/// </summary>
public static class FenrirAttackSync
{
public const string Key = "RacesOfValheim_FenrirAttack";
private static int seq = 0;
// The cultist's flame is a held bool on the Animator, not a one-shot trigger, so it gets a
// key of its own: a sequence number would say "it started" but never "it stopped".
public const string FireKey = "RacesOfValheim_FenrirFire";
/// <summary>
/// The flame the cultist breathes, parented to the given player so it follows them. One
/// place for it because the owner's own copy and every onlooker's copy have to look alike.
/// </summary>
public static GameObject SpawnFlames(Player player)
{
if (player == null || ZNetScene.instance == null) return null;
// Un effetto che dura nel tempo, trovato dai log!
GameObject fireVfx = ZNetScene.instance.GetPrefab("fx_fenring_flames");
if (fireVfx == null) return null;
GameObject instance = Object.Instantiate(fireVfx, player.transform.position + Vector3.up * 1.5f + player.transform.forward, player.transform.rotation, player.transform);
// Aumentiamo la durata delle particelle del 20%
foreach (ParticleSystem ps in instance.GetComponentsInChildren<ParticleSystem>())
{
var main = ps.main;
main.startLifetimeMultiplier *= 1.2f;
}
return instance;
}
public static void PublishFire(bool on)
{
Player player = Player.m_localPlayer;
ZNetView nview = player != null ? player.GetComponent<ZNetView>() : null;
if (nview == null || !nview.IsValid()) return;
nview.GetZDO().Set(FireKey, on);
}
/// <summary>
/// Publishes a trigger, and with it the swing's sound: the candidate prefab names in the
/// order the owner's own PlaySFX would try them, or "@Creature" for a howl borrowed from
/// that creature's alert effect. Only the opening cue rides along; the impact sounds are
/// decided by what the swing hits, which an onlooker's client never works out.
/// </summary>
public static void Publish(string trigger, params string[] sfx)
{
Player player = Player.m_localPlayer;
ZNetView nview = player != null ? player.GetComponent<ZNetView>() : null;
if (nview == null || !nview.IsValid()) return;
seq++;
string payload = trigger + "#" + seq;
if (sfx != null && sfx.Length > 0) payload += "#" + string.Join("|", sfx);
nview.GetZDO().Set(Key, payload);
}
}
/// <summary>
/// The animation half of somebody else's form.
///
@ -59,15 +126,23 @@ namespace RacesOfValheim
/// Kept next to the four local behaviours on purpose: this mirrors the movement half of their
/// Update, and the two have to be changed together.
///
/// Attacks are not mirrored. Those are triggers fired from input on the owner's client and
/// nothing replicates them, so a remote form still bites in silence - that needs a counter of
/// its own on the ZDO and is a separate job.
/// Attacks are triggers fired from input on the owner's client; FenrirAttackSync publishes
/// each one on the ZDO and this component replays it below.
/// </summary>
public class RemoteFenrirAnimator : MonoBehaviour
{
private Player player;
private Animator playerAnim;
private Animator formAnim;
private ZNetView nview;
private string lastAttack;
private GameObject flames;
// The flames hang off the player, not this model, so they outlive it unless taken down.
private void OnDestroy()
{
if (flames != null) Destroy(flames);
}
private void Update()
{
@ -84,6 +159,9 @@ namespace RacesOfValheim
}
if (formAnim == null || playerAnim == null) return;
ReplayAttack();
ReplayFire();
bool grounded = playerAnim.GetBool("onGround");
// All four borrowed creatures answer to these, and they are still written through
@ -99,6 +177,84 @@ namespace RacesOfValheim
try { formAnim.SetFloat("forward_speed", still ? 0f : playerAnim.GetFloat("forward_speed")); } catch {}
try { formAnim.SetFloat("sideway_speed", still ? 0f : playerAnim.GetFloat("sideway_speed")); } catch {}
}
// Written every frame while the flag is set, and only when the controller has the bool: a
// wolf or a Ulv has no "attack_fire", and the ZDO key is only ever true for the cultist.
private void ReplayFire()
{
if (nview == null || !nview.IsValid()) return;
bool fire = nview.GetZDO().GetBool(FenrirAttackSync.FireKey, false);
// The breath itself: up while the flag is, gone when it drops. Only the cultist ever
// sets the flag, so no other form can grow flames here.
if (fire && flames == null)
{
flames = FenrirAttackSync.SpawnFlames(player);
// The roar that opens the breath, once per start, the same cue the owner hears.
GameObject sfx = PrefabManager.Cache.GetPrefab<GameObject>("sfx_cultist_attack_fire_start");
if (sfx != null) Instantiate(sfx, player.transform.position, Quaternion.identity);
}
else if (!fire && flames != null) { Destroy(flames); flames = null; }
foreach (AnimatorControllerParameter p in formAnim.parameters)
{
if (p.type == AnimatorControllerParameterType.Bool && p.name == "attack_fire")
{
formAnim.SetBool("attack_fire", fire);
break;
}
}
}
private void PlayAttackSound(string[] names)
{
foreach (string name in names)
{
if (name.StartsWith("@"))
{
FenrirCreatureSound.PlayHowl(name.Substring(1), player.transform.position);
return;
}
GameObject sfx = PrefabManager.Cache.GetPrefab<GameObject>(name);
if (sfx != null)
{
Instantiate(sfx, player.transform.position, Quaternion.identity);
return;
}
}
}
private void ReplayAttack()
{
if (nview == null) nview = player.GetComponent<ZNetView>();
if (nview == null || !nview.IsValid()) return;
string current = nview.GetZDO().GetString(FenrirAttackSync.Key, "");
// First look at the ZDO only records what is already there, so a trigger left over from
// an earlier form does not replay the instant this model is built.
if (lastAttack == null) { lastAttack = current; return; }
if (string.IsNullOrEmpty(current) || current == lastAttack) return;
lastAttack = current;
string[] parts = current.Split('#');
string trigger = parts[0];
if (parts.Length > 2) PlayAttackSound(parts[2].Split('|'));
// Only the triggers this particular borrowed controller actually has: the four forms
// share none of the attack names but the taunt.
foreach (AnimatorControllerParameter p in formAnim.parameters)
{
if (p.type == AnimatorControllerParameterType.Trigger && p.name == trigger)
{
formAnim.SetTrigger(trigger);
break;
}
}
}
}
public class FenrirFormBehavior : MonoBehaviour
@ -192,6 +348,7 @@ namespace RacesOfValheim
fenrirAnim.SetFloat("sideway_speed", 0f);
fenrirAnim.SetTrigger("attack_taunt");
FenrirAttackSync.Publish("attack_taunt", "@Fenring");
FenrirCreatureSound.PlayHowl("Fenring", Player.m_localPlayer.transform.position);
@ -208,6 +365,7 @@ namespace RacesOfValheim
fenrirAnim.SetFloat("sideway_speed", 0f);
fenrirAnim.SetTrigger(triggerName);
FenrirAttackSync.Publish(triggerName, "sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack");
PlaySFX("sfx_fenring_attack", "sfx_fenring_attack_claw", "sfx_wolf_attack");
yield return new WaitForSeconds(dmgDelay);
@ -241,6 +399,7 @@ namespace RacesOfValheim
fenrirAnim.SetFloat("sideway_speed", 0f);
fenrirAnim.SetTrigger("attack_jump");
FenrirAttackSync.Publish("attack_jump");
// Aspettiamo che l'animazione si carichi (0.75s)
yield return new WaitForSeconds(0.75f);
@ -477,6 +636,7 @@ namespace RacesOfValheim
// Cultist ha una vera e propria animazione di "taunt"
cultistAnim.SetTrigger("attack_taunt");
FenrirAttackSync.Publish("attack_taunt", "@Fenring_Cultist");
FenrirCreatureSound.PlayHowl("Fenring_Cultist", Player.m_localPlayer.transform.position);
@ -496,27 +656,13 @@ namespace RacesOfValheim
cultistAnim.SetFloat("forward_speed", 0f);
cultistAnim.SetFloat("sideway_speed", 0f);
cultistAnim.SetBool("attack_fire", true);
FenrirAttackSync.PublishFire(true);
PlaySFX("sfx_cultist_attack_fire_start");
cultistAnim.SetTrigger("attack_flames");
FenrirAttackSync.Publish("attack_flames");
if (ZNetScene.instance != null && fireEffectInstance == null)
{
// Un effetto che dura nel tempo, trovato dai log!
GameObject fireVfx = ZNetScene.instance.GetPrefab("fx_fenring_flames");
if (fireVfx != null)
{
fireEffectInstance = Instantiate(fireVfx, Player.m_localPlayer.transform.position + Vector3.up * 1.5f + Player.m_localPlayer.transform.forward, Player.m_localPlayer.transform.rotation, Player.m_localPlayer.transform);
// Aumentiamo la durata delle particelle del 20%
ParticleSystem[] pss = fireEffectInstance.GetComponentsInChildren<ParticleSystem>();
foreach (ParticleSystem ps in pss)
{
var main = ps.main;
main.startLifetimeMultiplier *= 1.2f;
}
}
}
if (fireEffectInstance == null) fireEffectInstance = FenrirAttackSync.SpawnFlames(Player.m_localPlayer);
}
private void UpdateFire()
@ -533,10 +679,17 @@ namespace RacesOfValheim
}
}
// Leaving the form mid-flame must not leave the flag up for onlookers.
private void OnDestroy()
{
if (isShootingFire) FenrirAttackSync.PublishFire(false);
}
private void StopFire()
{
isShootingFire = false;
cultistAnim.ResetTrigger("attack_flames");
FenrirAttackSync.PublishFire(false);
if (fireEffectInstance != null)
{
@ -617,6 +770,7 @@ namespace RacesOfValheim
// Per il Cultista usiamo esplicitamente il trigger dell'artigliata
cultistAnim.SetTrigger("attack_claw");
FenrirAttackSync.Publish("attack_claw", "sfx_cultist_attack", "sfx_fenring_attack", "sfx_wolf_attack");
yield return new WaitForSeconds(0.4f);
@ -642,6 +796,7 @@ namespace RacesOfValheim
cultistAnim.SetFloat("sideway_speed", 0f);
cultistAnim.SetTrigger("attack_claw_double");
FenrirAttackSync.Publish("attack_claw_double", "sfx_cultist_attack_double", "sfx_cultist_attack", "sfx_fenring_attack");
// L'animazione double claw è più lunga, facciamo il danno un po' dopo
yield return new WaitForSeconds(0.6f);
@ -805,6 +960,7 @@ namespace RacesOfValheim
try { wolfAnim.SetFloat("sideway_speed", 0f); } catch {}
wolfAnim.SetTrigger(triggerName);
FenrirAttackSync.Publish(triggerName, "sfx_wolf_attack");
yield return new WaitForSeconds(dmgDelay);
@ -979,6 +1135,7 @@ namespace RacesOfValheim
try { ulvAnim.SetFloat("sideway_speed", 0f); } catch {}
try { ulvAnim.SetTrigger(triggerName); } catch {}
FenrirAttackSync.Publish(triggerName, "sfx_ulv_attack", "sfx_wolf_attack", "sfx_fenring_attack");
// Scegli il suono appropriato per l'attacco
if (triggerName == "attack_bite")
@ -1084,6 +1241,7 @@ namespace RacesOfValheim
try { ulvAnim.SetFloat("sideway_speed", 0f); } catch {}
try { ulvAnim.SetTrigger("attack_slash"); } catch {}
FenrirAttackSync.Publish("attack_slash", "sfx_ulv_attack", "sfx_wolf_attack");
PlaySFX("sfx_ulv_attack", "sfx_wolf_attack");
yield return new WaitForSeconds(0.3f); // Wait 0.3s before leaping

View file

@ -135,9 +135,15 @@ namespace RacesOfValheim {
}
else if (!isNight && wasNight)
{
// Sunrise: force revert and block transforming again for a while
sunSicknessTimer = FenrirConfig.SunSicknessDuration.Value;
ForceRevert();
// Sunrise: a form that was granted for the night only is taken back, and the
// beast is tired for a while. A form the progression lets through by day (Queen's
// Fenrir, Fader's Cultist, Bonemass's Wolf) is not the sun's to take: activeRules is
// what the transform was actually granted under.
if (activeRules == null || activeRules.NeedsNight)
{
sunSicknessTimer = FenrirConfig.SunSicknessDuration.Value;
ForceRevert();
}
}
wasNight = isNight;
@ -166,7 +172,9 @@ namespace RacesOfValheim {
{
if (rules == null || rules.Form == FenrirProgression.FormType.None) return;
if (sunSicknessTimer > 0f)
// The tiredness is the sun's doing, so it only stands in the way of a night form; the
// forms allowed by day would otherwise be locked out right after every sunrise.
if (rules.NeedsNight && sunSicknessTimer > 0f)
{
Player.m_localPlayer.Message(MessageHud.MessageType.Center, "The beast is tired");
return;

View file

@ -1,7 +1,7 @@
{
"name": "RacesOfValheim",
"description": "A Valheim mod that adds ten custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Sverm, Trenta, Trol) each with unique abilities, traits, race stations and a deep boss-driven progression system.",
"version_number": "1.4.21",
"version_number": "1.4.22",
"website_url": "",
"dependencies": [
"denikson-BepInExPack_Valheim-5.4.2333",

View file

@ -15,7 +15,7 @@ namespace RacesOfValheim
{
public const string PluginGUID = "com.nandor.racesofvalheim";
public const string PluginName = "Races Of Valheim";
public const string PluginVersion = "1.4.21";
public const string PluginVersion = "1.4.22";
private readonly Harmony harmony = new Harmony(PluginGUID);