fix(factions): make the truce switch cover every player truce, not one of five

Reported from a live game: with "Faction truce" off, a Trenta's Greydwarves
stayed friendly. The switch was working - it just was not switched over the
patch that mattered.

Five separate Harmony postfixes answer BaseAI.IsEnemy, and only
FactionHostilityPatch was gated. A Trenta reads its Black Forest truce from
RaceHostilityManager, which had no switch, so turning the faction one off
changed nothing visible. The same held for the Fenrir's wolves, the Aswid's
progression list, the Draugh's undead, the Sverm's invertebrates, the
Furling's Plains roster and the Skeleton's undead.

Gated all four player-facing ones behind the existing flag rather than
adding a switch each: from the player's side there is one question being
asked, and a switch that answers a fifth of it is worse than none.

DvergarMercenaryTrucePatch is deliberately left alone - it is a truce
between a hired thrall and a wild dvergr, two NPCs, and has nothing to do
with whether mobs come after the player.

Key stays "Faction truce" though its scope grew: renaming it would orphan
the entry in every .cfg already written, and the file beats the default in
code, so anyone who had switched it off would silently get the truce back.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
This commit is contained in:
Ferdinando 2026-08-25 19:13:16 +02:00
commit a60f5e8217
4 changed files with 21 additions and 5 deletions

View file

@ -12,6 +12,12 @@ namespace RacesOfValheim
{
public static void Postfix(Character a, Character b, ref bool __result)
{
// The per-race truces below answer the same BaseAI.IsEnemy the Factions patches do,
// so the switch has to cover both or it covers nothing: a Trenta reads its Greydwarf
// truce from HERE, not from FactionHostilityPatch, and turning the faction one off
// left the mobs friendly anyway. Same flag rather than a second one, because from
// the player's side there is only one question being asked.
if (!FactionsConfig.Hostility) return;
if (!__result) return; // If already not enemies, skip
if (a == null || b == null) return;