RacesOfValheim/JotunnModStub/Factions/FactionMerchantCatalog.cs
kanym 1bd09ed31d feat(text): merchants, troops and the hive's shelf come from translation files
The faction merchants' 90 jokes, their generic lines and their names now
read from merchants.json. Merchant names use the game's own creature
tokens where one matches, so they arrive translated in every language
Valheim ships; the Dverg keeps a key of its own, since vanilla's token
reads "Dvergr Rogue".

The Dvergar and Trol troop names and terms, and the Sverm hive's goods,
refusals, stage names and brood kinds, follow. Their panels fill TMP texts
themselves, so they localize the names where they draw them.

The jokes have English text only for now.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-28 18:50:54 +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 = "$enemy_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 = "$enemy_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 = "$enemy_goblin",
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 = "$enemy_goblinshaman",
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 = "$enemy_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 = "$enemy_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 = "$enemy_fenringcultist",
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 = "$rov_merchant_dverg_name",
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 = "$enemy_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 = "$enemy_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 = "$enemy_ghost",
JokeCategory = JokeFantasma,
Items = WithDefaults(new List<CatalogEntry>
{
new CatalogEntry("Ectoplasm", 2),
new CatalogEntry("TrophyGhost", 350),
})
};
private static readonly ShopDefinition WraithShop = new ShopDefinition
{
DisplayName = "$enemy_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 },
};
}
}