RacesOfValheim/JotunnModStub/Factions/FactionMerchantCatalog.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

346 lines
16 KiB
C#

using System.Collections.Generic;
namespace RacesOfValheim
{
// Data-only: the full buy/sell catalogue designed in the Factions brainstorm
// (see Pacchetto_Rame/Factions_Brainstorm.txt for the source-of-truth tables).
// Prices are symmetric: a merchant buys and sells every listed item at the
// same price, coins are never a tradeable item.
public static class FactionMerchantCatalog
{
public class CatalogEntry
{
public string PrefabName;
public int Price;
public CatalogEntry(string prefabName, int price)
{
PrefabName = prefabName;
Price = price;
}
}
public class ShopDefinition
{
public string DisplayName;
public string JokeCategory;
public List<CatalogEntry> Items;
}
// Joke category keys, matched against FactionMerchantJokes.
public const string JokeLegnoFalegname = "LegnoFalegname";
public const string JokeGoblin = "Goblin";
public const string JokeTroll = "Troll";
public const string JokeLupoLicantropo = "LupoLicantropo";
public const string JokeNano = "Nano";
public const string JokeStrega = "Strega";
public const string JokeScheletro = "Scheletro";
public const string JokeNonMortoZombie = "NonMortoZombie";
public const string JokeFantasma = "Fantasma";
// Every merchant in the mod buys/sells these regardless of what its own list
// carries - players kept running into benches that could not fence basic building
// mats. Folded into each ShopDefinition.Items below (WithDefaults) rather than
// handled in FactionMerchantSetup/FactionMerchantSellPanel, so both the buy and
// sell columns pick it up for free.
private static readonly List<CatalogEntry> DefaultItems = new List<CatalogEntry>
{
new CatalogEntry("Wood", 1),
new CatalogEntry("Stone", 1),
new CatalogEntry("FineWood", 5),
new CatalogEntry("Flint", 5),
new CatalogEntry("RoundLog", 10), // Core wood's internal prefab name
};
// Appends whichever DefaultItems aren't already named in items, explicit entries
// win so a shop can still special-price one of these if it ever needs to.
private static List<CatalogEntry> WithDefaults(List<CatalogEntry> items)
{
var combined = new List<CatalogEntry>(items);
foreach (CatalogEntry defaultEntry in DefaultItems)
{
if (!combined.Exists(e => e.PrefabName == defaultEntry.PrefabName))
{
combined.Add(defaultEntry);
}
}
return combined;
}
private static readonly ShopDefinition GreydwarfShop = new ShopDefinition
{
DisplayName = "Greydwarf",
JokeCategory = JokeLegnoFalegname,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("Resin", 5),
new CatalogEntry("GreydwarfEye", 5),
new CatalogEntry("Dandelion", 5),
new CatalogEntry("Pukeberries", 5),
new CatalogEntry("Mushroom", 5),
new CatalogEntry("Blueberries", 5),
new CatalogEntry("Thistle", 5),
new CatalogEntry("Carrot", 5),
new CatalogEntry("CarrotSeeds", 20),
new CatalogEntry("AncientSeed", 20),
new CatalogEntry("RotSeed", 500), // gates the Trenta Composter
new CatalogEntry("TrophyGreydwarf", 20),
new CatalogEntry("TrophyGreydwarfBrute", 350),
new CatalogEntry("TrophyGreydwarfShaman", 350),
})
};
private static readonly ShopDefinition TrollShop = new ShopDefinition
{
DisplayName = "Troll",
JokeCategory = JokeTroll,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("TrollHide", 1),
new CatalogEntry("DeerHide", 2),
new CatalogEntry("DeerMeat", 2),
new CatalogEntry("LeatherScraps", 5),
new CatalogEntry("RawMeat", 5),
new CatalogEntry("NeckTail", 5),
new CatalogEntry("TrophyNeck", 20),
new CatalogEntry("TrophyDeer", 20),
new CatalogEntry("TrophyBoar", 50),
new CatalogEntry("TrophyForestTroll", 1500),
})
};
private static readonly ShopDefinition FulingShop = new ShopDefinition
{
DisplayName = "Fuling",
JokeCategory = JokeGoblin,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("BlackMetalScrap", 1),
new CatalogEntry("LoxMeat", 1),
new CatalogEntry("SerpentScale", 1),
new CatalogEntry("LoxPelt", 2),
new CatalogEntry("Flax", 5),
new CatalogEntry("Barley", 5),
new CatalogEntry("Cloudberry", 5),
new CatalogEntry("Tar", 5), // Growth, folded in here: Growth lives in Plains, same biome as Lox/Ocean
// UNRESOLVED, left as-is rather than guessed: vanilla fish items are named Fish1
// through Fish12 (plus Fish4_cave), so "Tuna", "CoralCod" and "Pufferfish" below
// are display names and match no prefab - these three entries never appear on the
// bench. Which number is which fish lives in the localization, which ships inside
// compressed asset bundles and cannot be read the way the rest of this file's names
// were verified. FactionMerchantSetup already logs each unresolved entry by name at
// runtime, so hovering a Fuling merchant once will name them in the log.
new CatalogEntry("Tuna", 50),
new CatalogEntry("CoralCod", 70),
new CatalogEntry("SerpentMeat", 200),
new CatalogEntry("GoblinTotem", 350),
new CatalogEntry("TrophyGoblin", 350),
new CatalogEntry("TrophyGoblinShaman", 350),
new CatalogEntry("TrophyLox", 350),
new CatalogEntry("Pufferfish", 350),
new CatalogEntry("TrophyGrowth", 800), // Growth
new CatalogEntry("TrophyGoblinBrute", 1500),
new CatalogEntry("TrophySerpent", 1500),
})
};
// The Shaman alone stocks the Furling's crop line, so it needs a bench of its own - the four
// Fuling prefabs shared one ShopDefinition instance until now. It keeps everything the Fuling
// bench sells and adds the five on top, so splitting it off takes nothing away.
//
// Declared after FulingShop because it copies that list, and static field initialisers run
// in declaration order.
private static readonly ShopDefinition GoblinShamanShop = new ShopDefinition
{
DisplayName = "Fuling Shaman",
JokeCategory = JokeGoblin,
Items = new List<CatalogEntry>(FulingShop.Items)
{
// Plantable, millable, and the only source of these three strains anywhere.
new CatalogEntry("CopperFlax", 20),
new CatalogEntry("TinFlax", 20),
new CatalogEntry("IronFlax", 50),
// Inedible. Buying one is the only way to get a bush, but a planted bush then yields
// forever - so these are a one-off cost per bush, not a running one.
new CatalogEntry("Stoneberry", 20),
new CatalogEntry("Flintberry", 20),
}
};
/// <summary>
/// The mountain's animal bench. It used to be the WOLF, and moving it was not a preference:
/// a bench is a Trader, a Trader is Interactable, and it wins the E key. The wolf is the ONLY
/// creature vanilla lets you tame that this catalogue ever made a merchant, so every wolf in
/// the world - including the two in your own pen - answered a click with a shop window
/// instead of being pettable, nameable or commandable. Taming an animal you cannot handle is
/// not taming.
///
/// The Ulv carries the whole line now, wolf goods included. It is a mountain creature of the
/// same faction, it is not tameable, and nothing about it is spent by being a shopkeeper.
///
/// Checked while fixing this: Boar, Lox, Hen and Asksvin - the rest of what vanilla lets you
/// tame - are not benches and never were. This was the only one, so the whole class of bug
/// closes here rather than needing a rule.
/// </summary>
private static readonly ShopDefinition UlvShop = new ShopDefinition
{
DisplayName = "Ulv",
JokeCategory = JokeLupoLicantropo,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("WolfFang", 5),
new CatalogEntry("WolfMeat", 5),
new CatalogEntry("WolfPelt", 5),
new CatalogEntry("Onion", 5),
new CatalogEntry("FreezeGland", 5), // Drake, folded in here: no talk-capable rig
new CatalogEntry("OnionSeeds", 20),
new CatalogEntry("TrophyWolf", 350),
new CatalogEntry("TrophyUlv", 350),
new CatalogEntry("TrophyHatchling", 350), // Drake (internal id "Hatchling")
})
};
private static readonly ShopDefinition FenringShop = new ShopDefinition
{
DisplayName = "Fenring",
JokeCategory = JokeLupoLicantropo,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("WolfFang", 5),
new CatalogEntry("Ulvsblod", 500), // gates the Fenrir pack trough
new CatalogEntry("GreaterUlvsblod", 1500), // upgrades it: the fenrir themselves
new CatalogEntry("TrophyFenring", 350),
})
};
private static readonly ShopDefinition CultistShop = new ShopDefinition
{
DisplayName = "Cultist",
JokeCategory = JokeStrega,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("JuteRed", 2),
new CatalogEntry("GreaterFrostHeart", 1500), // the Skadi's bought reagent
new CatalogEntry("TrophyCultist", 1500),
})
};
private static readonly ShopDefinition DvergShop = new ShopDefinition
{
DisplayName = "Dverg",
JokeCategory = JokeNano,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("BlackMarble", 20),
new CatalogEntry("Softtissue", 250),
new CatalogEntry("Sap", 250), // extracted from Yggdrasil roots with Dvergr extractors
new CatalogEntry("TrophyDvergr", 1500),
})
};
private static readonly ShopDefinition DraugrShop = new ShopDefinition
{
DisplayName = "Draugr",
JokeCategory = JokeNonMortoZombie,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("Entrails", 2),
new CatalogEntry("Mushroom", 5),
new CatalogEntry("Thistle", 5),
new CatalogEntry("Turnip", 5),
new CatalogEntry("Bloodbag", 5), // Leech, folded in here: no talk-capable rig
new CatalogEntry("Guck", 1), // Abomination, folded in here: cannot speak at all
new CatalogEntry("Root", 1), // Abomination
new CatalogEntry("TurnipSeeds", 20),
new CatalogEntry("BloodCore", 500), // gates the Aswid Blood Refinery
new CatalogEntry("CursedBone", 500), // gates the Draugh body pile
new CatalogEntry("GreaterCursedBone", 1500), // upgrades it: officers
new CatalogEntry("TrophyDraugr", 350),
new CatalogEntry("TrophyLeech", 350), // Leech
new CatalogEntry("TrophyDraugrElite", 800),
new CatalogEntry("TrophyAbomination", 1500), // Abomination
})
};
private static readonly ShopDefinition SkeletonShop = new ShopDefinition
{
DisplayName = "Skeleton",
JokeCategory = JokeScheletro,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("BoneFragments", 1),
new CatalogEntry("Ooze", 2), // Blob/Oozer, folded in here: no talk-capable rig
new CatalogEntry("IronScrap", 20), // Oozer
new CatalogEntry("TrophySkeleton", 350),
new CatalogEntry("TrophyBlob", 350), // Blob
new CatalogEntry("TrophySkeletonPoison", 800),
new CatalogEntry("SoulStone", 50), // binds a skeleton archer sentry
new CatalogEntry("CursedSkull", 500), // gates the Skeleton bone pile
new CatalogEntry("GreaterCursedSkull", 1500), // upgrades it: the rotten
})
};
private static readonly ShopDefinition GhostShop = new ShopDefinition
{
DisplayName = "Ghost",
JokeCategory = JokeFantasma,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("Ectoplasm", 2),
new CatalogEntry("TrophyGhost", 350),
})
};
private static readonly ShopDefinition WraithShop = new ShopDefinition
{
DisplayName = "Wraith",
JokeCategory = JokeFantasma,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("Chain", 5),
new CatalogEntry("TrophyWraith", 1500),
})
};
// Key = vanilla creature prefab name (internal id, not the wiki display name).
// Several creature families share one ShopDefinition instance on purpose.
public static readonly Dictionary<string, ShopDefinition> Shops = new Dictionary<string, ShopDefinition>
{
{ "Greydwarf", GreydwarfShop },
{ "Greydwarf_Elite", GreydwarfShop },
{ "Greydwarf_Shaman", GreydwarfShop },
{ "Troll", TrollShop },
{ "Goblin", FulingShop },
{ "GoblinArcher", FulingShop },
{ "GoblinBrute", FulingShop },
{ "GoblinShaman", GoblinShamanShop }, // the only bench carrying the crop line
// NO "Wolf" ENTRY, and it must stay that way: a bench is a Trader and a Trader takes the
// E key, which would make every tameable wolf in the world a shop instead of an animal.
// Its goods live on the Ulv now. (The wolf stays in FactionHostilityPatch's mountain
// roster - that list is about who attacks whom and is a different question entirely.)
{ "Ulv", UlvShop },
{ "Fenring", FenringShop },
{ "Fenring_Cultist", CultistShop },
{ "Dverger", DvergShop },
{ "DvergerMageFire", DvergShop },
{ "DvergerMageIce", DvergShop },
{ "DvergerMageSupport", DvergShop },
{ "DvergerAshlands", DvergShop },
{ "Draugr", DraugrShop },
{ "Draugr_Elite", DraugrShop },
{ "Skeleton", SkeletonShop },
{ "Skeleton_Poison", SkeletonShop },
{ "Ghost", GhostShop },
{ "Wraith", WraithShop },
};
}
}