RacesOfValheim/JotunnModStub/Factions/FactionsConfig.cs
Ferdinando 34bdf35325 Merge branch 'war-vulture' into main
Sverm Ravager Strain (replacing the Stinger Morph), Trenta Elder Root, the
Trol food and Black Forest truce work, and the faction FindEnemy patch.

Conflicts resolved:

- FactionHostilityPatch.cs: both sides added a class at the same spot and
  they cover different holes, so both are kept - FactionStaticTargetPatch
  (main, stops same-faction mobs smashing structures) and
  FactionHuntPlayerPatch (war-vulture, closes the HuntPlayer fall-through).

- RaceCompendium.cs: both branches independently fixed the same off-by-one
  in the Trol's progression gates. Took main's wording, which matches the
  code - Axes are in the melee bonus (TrolDamagePatches sends them to
  m_slash), the 4th food slot has no gate at all, and Yagluth is +5 not +10
  (TrolConfig.YagluthMeleeBonus). Kept war-vulture's two new lines, the
  Kindling fire weakness and the Black Forest truce.

- Package/manifest.json: 1.4.8, which is what the root manifest and
  PluginVersion already said.

RacesOfValheim.cs referenced SvermConfig.StingerSE/StingerCdSE, which
war-vulture renamed to Ravager. Git merged those lines without a conflict
and the result did not compile; renamed.

Also in this commit:

- Factions on/off switches (FactionsConfig): "Faction truce" and "Faction
  merchants", both default on, both read live so they take effect without a
  restart. The truce gates its three postfixes; the merchants gate the
  Character.Awake setup plus every behavioural patch, so turning them off
  drops the prompt and the trade window on mobs already awake.

- SerpentMeat sells for 200 instead of 1 at the Fuling bench, moved to keep
  the list's ascending price order (the sell panel renders it as declared).

- DraughFoodPatches mapped "SerpentMeatRaw", which is not a prefab; the
  internal id is SerpentMeat, so serpent meat never cooked for a Draugh.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-08-25 18:52:10 +02:00

50 lines
3.1 KiB
C#

using BepInEx.Configuration;
namespace RacesOfValheim
{
/// <summary>
/// The two switches that turn the Factions feature off, bound as BepInEx ConfigEntry so they
/// show up in Configuration Manager - same shape as WarVultureConfig, which is the house model.
///
/// Two switches rather than one because the halves fail differently. The truce is invisible
/// when it works and only shows up as mobs that ignore you; the merchants are a whole second
/// interaction bolted onto creatures that vanilla never meant to talk. Anyone hunting a mod
/// conflict wants to rule out one without losing the other.
///
/// Both read live, on every call, rather than being cached at patch time: the patches stay
/// installed and answer "not my business" while a switch is off. That costs one bool read per
/// call and buys a toggle that takes effect without restarting the game - with one asymmetry
/// worth knowing about, spelled out on Merchants below.
/// </summary>
public static class FactionsConfig
{
public static ConfigEntry<bool> HostilityEnabled;
public static ConfigEntry<bool> MerchantsEnabled;
// Null-safe, defaulting to ON, for the same reason WarVultureConfig guards its own reads:
// a patch that somehow runs before Bind() should behave like the shipped default rather
// than throw. Awake() binds before harmony.PatchAll(), so this should never fire.
public static bool Hostility => HostilityEnabled?.Value ?? true;
public static bool Merchants => MerchantsEnabled?.Value ?? true;
public static void Bind(ConfigFile config)
{
const string factions = "Factions";
HostilityEnabled = config.Bind(factions, "Faction truce", true,
new ConfigDescription("Mobs of your race's faction leave you alone - they will not open a fight, " +
"hunt you during events, or smash structures near you. Turn this off and every " +
"creature treats you exactly as vanilla would. Does not touch the older per-race " +
"truces in RaceHostilityManager (Fenrir, Aswid, Draugh, Trenta), which have no " +
"switch of their own. Hitting a mob still starts a fight either way: retaliation " +
"runs through BaseAI.OnDamaged, which no truce has a say over."));
MerchantsEnabled = config.Bind(factions, "Faction merchants", true,
new ConfigDescription("Certain mobs of your own faction can be traded with - 'E - Talk' opens a shop " +
"where you sell them what their kind wants. Turn this off and they are ordinary " +
"creatures again. Takes effect immediately for the prompt, the trade window and " +
"the no-hit protection; the hidden Trader component already grafted onto mobs " +
"that woke up earlier stays until they unload, but nothing will read it."));
}
}
}