Merge branch 'war-vulture' into main

Brings in v1.4.3-v1.4.5 work: Trol's Hammer, Bone Servants, War Vulture
craftability, and the Aswid/Fenrir timed-claws rework, on top of the
bugfixes merged into main since v1.4.2.

Resolved conflicts in 7 files where main's post-v1.4.2 fixes overlapped
war-vulture's claws rework:
- README.md, manifest.json: took war-vulture's v1.4.5 content (main
  hadn't touched either since the v1.4.2 release).
- RacesOfValheim.cs: plugin version -> 1.4.5.
- RaceClaws.cs: kept war-vulture's lazy EnsureRoster() fix for the
  Fenrir claw-registration bug over main's belt-and-suspenders
  Register(this), and dropped the now-stale comment referencing the
  removed static constructor. Main's SetupDragItem race-ownership fix
  carried through untouched.
- AswidConfig.cs/AswidRace.cs/AswidPatches.cs: adopted war-vulture's
  single-key design (I toggles both Vampiric Aura and Devour together)
  to match the documented v1.4.5 trader-safety fix, removing a duplicate
  AuraEnabled field the two branches had each declared independently.
  Kept main's IsDownIgnoringHeldKeys() input fix on top.
- RaceCompendium.cs: kept main's fact-checked Aswid/Fenrir entries
  (war-vulture's copies were pre-fix stubs, one referencing a
  nonexistent variable) and layered in war-vulture's timed-claws
  wording.

Build verified clean (0 errors) after resolution.
This commit is contained in:
kanym 2026-08-18 17:36:42 +02:00
commit c2212df322
38 changed files with 3831 additions and 192 deletions

View file

@ -1,3 +1,4 @@
using System.Collections.Generic;
using System.Reflection;
using HarmonyLib;
using UnityEngine;
@ -158,9 +159,16 @@ namespace RacesOfValheim
// SkadiSEManPatch above from tier 1 onward, so the tier 2 "Freezing to Cold" conversion never
// gets a chance to run. These two patches scope out just that one environmental check: while
// Player.UpdateEnvStatusEffects is running for the local Skadi player, GetDamageModifiers is
// reported as Normal for Frost, so vanilla always attempts to apply the real status and
// SkadiSEManPatch's per-tier logic (block/convert/allow) is what actually decides the outcome.
// Frost damage resistance from hits (SkadiDamagePatch) is untouched by this.
// reported without SE_SkadiStats' own Frost contribution, so vanilla attempts to apply the
// real status and SkadiSEManPatch's per-tier logic (block/convert/allow) is what actually
// decides the outcome. Frost damage resistance from hits (SkadiDamagePatch) is untouched.
//
// Only the race's own contribution is discounted. This used to report a flat Normal, which
// also erased Frost resistance coming from a wolf/lox cape, a frost resistance mead or food:
// a Skadi who had beaten Moder still caught the converted Cold on the Mountain while wearing
// gear that makes a human immune, and below tier 4 caught real Freezing through the same gear.
// The tiered ladder is meant to make the race better than a bare human, never worse than an
// equipped one, so anything the player is actually wearing or drinking still counts.
[HarmonyPatch(typeof(Player), "UpdateEnvStatusEffects")]
public static class SkadiEnvCheckScope
{
@ -180,11 +188,38 @@ namespace RacesOfValheim
[HarmonyPatch(typeof(Character), "GetDamageModifiers")]
public static class SkadiEnvFrostModifierPatch
{
private static readonly int SkadiStatsHash = "SE_SkadiStats".GetStableHashCode();
// Handed to the aura in place of its own list while the recompute runs. SE_Stats applies
// m_mods as-is, so an empty list is simply "this effect grants nothing".
private static readonly List<HitData.DamageModPair> NoMods = new List<HitData.DamageModPair>();
private static bool recomputing = false;
public static void Postfix(Character __instance, ref HitData.DamageModifiers __result)
{
if (SkadiEnvCheckScope.Active && __instance == Player.m_localPlayer)
if (recomputing) return;
if (!SkadiEnvCheckScope.Active || __instance != Player.m_localPlayer) return;
// Character.GetDamageModifiers composes base modifiers + equipment + status effects,
// and DamageModifiers.Apply keeps the strongest of the lot - there is no way to
// subtract one contributor from a finished result. So the aura is muted and the whole
// thing recomputed: what comes back is exactly what this player would have without
// the race. The recursive call re-enters this postfix, which the flag turns into a
// no-op. The status effect on the player is a clone of the registered prototype
// (SEMan.AddStatusEffect clones on add), hence the lookup by hash rather than
// SkadiRace.skadiCurseSE.
SE_Stats aura = __instance.GetSEMan().GetStatusEffect(SkadiStatsHash) as SE_Stats;
List<HitData.DamageModPair> auraMods = aura != null ? aura.m_mods : null;
recomputing = true;
if (aura != null) aura.m_mods = NoMods;
try
{
__result.m_frost = HitData.DamageModifier.Normal;
__result.m_frost = __instance.GetDamageModifiers(null).m_frost;
}
finally
{
if (aura != null) aura.m_mods = auraMods;
recomputing = false;
}
}
}

View file

@ -167,11 +167,24 @@ namespace RacesOfValheim
// Update the stats SE
if (skadiCurseSE != null)
{
int auraHash = skadiCurseSE.name.GetStableHashCode();
SEMan seman = Player.m_localPlayer.GetSEMan();
skadiCurseSE.UpdateStats(rules);
if (!Player.m_localPlayer.GetSEMan().HaveStatusEffect(skadiCurseSE.name.GetStableHashCode()))
if (!seman.HaveStatusEffect(auraHash))
{
Player.m_localPlayer.GetSEMan().AddStatusEffect(skadiCurseSE.name.GetStableHashCode(), true);
seman.AddStatusEffect(auraHash, true);
}
// SEMan.AddStatusEffect stores a Clone() of the prototype, so updating
// skadiCurseSE alone only changed the copy that gets stamped out at the next add:
// the aura already running on the player kept whatever tier it was born with.
// Beating a boss mid-session left the old frost modifier and eitr regen in place
// until the effect was re-added (race reselection or a relog) - most visibly at
// the Queen, where Immune never replaced Resistant. Refresh the live one as well;
// UpdateStats is a no-op unless the tier actually moved a value.
SE_SkadiStats liveAura = seman.GetStatusEffect(auraHash) as SE_SkadiStats;
if (liveAura != null) liveAura.UpdateStats(rules);
}
if (rules.FrostAura)

View file

@ -27,8 +27,29 @@ namespace RacesOfValheim
m_tooltip = "Empowered by the frost.";
}
// What the last UpdateStats call actually wrote. SEMan.AddStatusEffect stores a Clone() of
// the registered prototype, so the effect running on the player is a separate object that
// has to be refreshed too (SkadiRace.Update does that) - and both of them are asked to
// update every frame. Rebuilding the mod list each time would churn a List per frame per
// instance, so nothing is rewritten until a tier change actually moves a value. These
// fields are not serialized, so a fresh clone starts at "never applied" and rebuilds once.
private bool statsApplied = false;
private float appliedFrostResistance = 0f;
private float appliedEitrRegenMultiplier = 0f;
public void UpdateStats(SkadiProgression.FormRules rules)
{
if (statsApplied &&
rules.FrostResistance == appliedFrostResistance &&
rules.EitrRegenMultiplier == appliedEitrRegenMultiplier)
{
return;
}
statsApplied = true;
appliedFrostResistance = rules.FrostResistance;
appliedEitrRegenMultiplier = rules.EitrRegenMultiplier;
m_mods = new List<HitData.DamageModPair>();
if (rules.FrostResistance >= 1f)
{