chore(release): v1.4.19 - eye height, remote forms, food refresh, faction retaliation

Race body scale moved the model and not the camera: Character.m_eye hangs
off the unscaled root, so a Trol or a Dvergar changed height for everyone
but themselves. RaceEyeHeight moves the eye by whatever scale the Visual
is wearing, for every player, so aim rays follow too.

Remote copies of a Fenrir form had no one writing to their Animator and
stood in the controller's default state, sliding. RemoteFenrirAnimator
mirrors the four local behaviours off the player's own replicated
animator, the way RemoteSkadiAnimator already did for Skadi.

Player.Food.m_time is time remaining, not time elapsed: the Aswid, Trenta
and Draugh repeat-meal branches all set it to 0 and expired the slot they
meant to renew, and left the nutrition values stale. RaceFoodRefresh does
what vanilla's own branch does, in one place instead of three. The Trenta
prefix now reports __result, or a working refresh would have renewed the
slot without consuming the seed.

Aswid devour was gated by one timestamp shared by every corpse, so a pack
killed at once fed the player once; it is now per corpse, floored at a
second, and a refused meal says $msg_nomore.

MonsterAI.UpdateTarget discards any target IsEnemy refuses, so a truced
mob could not retaliate at all - it stood still or fled. RaceGrudge
records the hit on the AI owner's client and both truce postfixes stand
down for that pair. The Aswid drain and the Skadi frost aura now skip
kin, as the Skeleton's fire aura already did, or an always-on aura would
hold every truce permanently broken.

Faction sets matched exact prefab names with families half-listed:
added Skeleton_NoArcher and Draugr_Ranged to the Swamp, Greyling to the
Black Forest.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Ferdinando 2026-09-20 08:26:22 +02:00
commit 834d6647fd
18 changed files with 525 additions and 56 deletions

View file

@ -949,6 +949,20 @@ namespace RacesOfValheim
continue;
}
// The truce holds here too, or it holds nowhere. This aura is always on
// and asks nothing of the player, so before RaceGrudge it quietly drained
// and executed the race's own kin while they stood there and took it;
// after RaceGrudge that same drain would have kept every leech, draugr and
// blob in the swamp permanently angry at an Aswid who never raised a hand.
// Asking BaseAI.IsEnemy is what the Skeleton's fire aura already does, and
// it is the one question both truce patches answer, so the aura now agrees
// with everything else by construction. The execute is untouched: it still
// fires, on anything the Aswid is actually at war with.
if (!c.IsPlayer() && !BaseAI.IsEnemy(Player.m_localPlayer, c))
{
continue;
}
float maxHp = c.GetMaxHealth();
float currentHp = c.GetHealth();
@ -960,7 +974,7 @@ namespace RacesOfValheim
if (currentHp > 0 && currentHp <= maxHp * AswidConfig.AuraExecuteThreshold.Value && !c.IsBoss())
{
totalDamage = currentHp * 2f; // Lethal damage for execute
TryConsumeMob(c, maxHp, true); // Automatically devour when executed, bypassing cooldown
TryConsumeMob(c, maxHp); // Automatically devour when executed
}
HitData hd = new HitData();
@ -987,17 +1001,40 @@ namespace RacesOfValheim
public static bool DevourEnabled = true;
public static bool AuraEnabled = true;
private static float lastConsumeTime = 0f;
public static void TryConsumeMob(Character c, float maxHp, bool bypassCooldown = false)
/// <summary>
/// When each corpse was last drunk from, so one body is never devoured twice.
///
/// This used to be a single timestamp shared by every corpse in the world, which is what
/// testers hit as "killing with the claws or the aura sometimes adds nothing at all":
/// clear a pack with one blast and the first body ate the cooldown for all of them, the
/// rest dying unnoticed inside the window. The guard was never about pacing kills - it is
/// there because a single death reaches TryConsumeMob from more than one place (two
/// Character.Damage postfixes, the aura's own execute, a thrall's kill), and without it
/// one corpse could feed the player twice. Keyed per corpse it does that job exactly and
/// stops taxing the kills that follow.
/// </summary>
private static readonly Dictionary<ZDOID, float> lastConsumedCorpse = new Dictionary<ZDOID, float>();
private static float lastCorpseSweep = 0f;
public static void TryConsumeMob(Character c, float maxHp)
{
if (!DevourEnabled) return;
if (c == null) return;
if (!bypassCooldown && Time.time - lastConsumeTime < AswidConfig.DevourCooldown.Value)
// The window is the config's own "Consume Cooldown", scoped to the body it is about.
// Floored at a second even when that is set to zero: the paths that report one death
// all arrive within the same frame or two, and letting a corpse feed the player twice
// is a bug rather than a setting.
float window = Mathf.Max(AswidConfig.DevourCooldown != null ? AswidConfig.DevourCooldown.Value : 5f, 1f);
ZDOID corpse = c.GetZDOID();
if (lastConsumedCorpse.TryGetValue(corpse, out float drunkAt) && Time.time - drunkAt < window)
{
return; // Cooldown active
return; // This body has already been drunk from.
}
SweepConsumedCorpses(window);
string cleanName = c.name.Replace("(Clone)", "").Trim();
string customFoodName = "AswidFood_" + cleanName;
@ -1012,6 +1049,11 @@ namespace RacesOfValheim
// Fallback to RawMeat if no specific custom item was generated (e.g. mob not in trophy map)
if (foodPrefab == null)
{
// Logged rather than shown: a creature with no blood food of its own is a whole
// category, not an event, and a message on every such kill would be noise. It is
// here at all because from the player's chair this looks exactly like a devour
// that failed, and the log is the only way to tell the two apart.
Jotunn.Logger.LogDebug($"[Aswid] '{cleanName}' has no '{customFoodName}' to drink - not edible.");
return; // Mob is not edible
}
@ -1030,7 +1072,7 @@ namespace RacesOfValheim
if (addedItem != null)
{
lastConsumeTime = Time.time;
lastConsumedCorpse[corpse] = Time.time;
// UseItem natively plays animation and consumes it.
// If stomach is full, EatFood fails, UseItem does not consume the item, and virtualInv is destroyed (disintegrated)
@ -1047,8 +1089,15 @@ namespace RacesOfValheim
// Vae Victis XP logic - similar to Dead Raiser
Player.m_localPlayer.RaiseSkill(Skills.SkillType.BloodMagic, 1f);
}
// If it was not eaten the stomach was full: the item disintegrates with
// the virtual inventory, so there is nothing to clean up.
else
{
// The stomach was full and had nothing worth refreshing, so the food
// disintegrates with the virtual inventory - there is nothing to clean
// up, but there used to be nothing to see either. Silence is what made
// a refused meal indistinguishable from a devour that never fired:
// vanilla's own "can't eat more" line, localized for free.
Player.m_localPlayer.Message(MessageHud.MessageType.TopLeft, "$msg_nomore");
}
}
else
{
@ -1058,6 +1107,28 @@ namespace RacesOfValheim
}
}
/// <summary>
/// Drops corpses the window has passed, so a long session does not carry a growing list of
/// bodies nobody will ever drink from again. Once every window at most - this runs off
/// kills, and a pack dying together should not walk the list once per body.
/// </summary>
private static void SweepConsumedCorpses(float window)
{
if (Time.time - lastCorpseSweep < window) return;
lastCorpseSweep = Time.time;
if (lastConsumedCorpse.Count == 0) return;
List<ZDOID> stale = null;
foreach (var entry in lastConsumedCorpse)
{
if (Time.time - entry.Value < window) continue;
if (stale == null) stale = new List<ZDOID>();
stale.Add(entry.Key);
}
if (stale == null) return;
foreach (ZDOID id in stale) lastConsumedCorpse.Remove(id);
}
private static void SpawnBloodVFX(Character target)
{
try