RacesOfValheim/JotunnModStub/Trol/TrolConfig.cs
kanym 65b488b5dc feat(trol): skin and hair colour pickers in Trol - Appearance
Two Color entries, Skin Color and Hair Color (hair and beard), defaulting
to the old peacock blue and golden blonde so no Trol changes on update.
Each Trol publishes its choice on its own ZDO and every client paints
that player with it; a Trol on an older build publishes nothing and shows
the defaults. The menu preview, with no ZDO, reads the local config.
The section is kept local by ConfigSync.

README: New in block, Trol features line and a 1.5.10 changelog entry.
2026-10-14 14:14:06 +02:00

148 lines
12 KiB
C#

using UnityEngine;
using BepInEx.Configuration;
namespace RacesOfValheim
{
/// <summary>
/// Every tunable number and keybind behind the Trol's abilities, bound as BepInEx ConfigEntry
/// so they show up in Configuration Manager without touching code - see
/// CONFIGURATION-MANAGER-HOWTO.md. Bound once, from RacesOfValheim.Awake(). One section per
/// topic (matches every other race's layout).
///
/// Tier-gate thresholds (which progression state unlocks each perk) are left as-is, same
/// boundary drawn for every other race's progression table - not exposed here.
///
/// True Form's scale (Normal/Advanced) is read from both the local transform routine
/// (TrolRace) and the remote-sizing postfix (TrolPatches) - both now read the same
/// ConfigEntry rather than each carrying its own literal, so a retuned value can no longer
/// make a Trol one size to themselves and another to everyone else.
/// </summary>
public static class TrolConfig
{
// ─── Keybinds ──────────────────────────────────────────────────────────
public static ConfigEntry<KeyboardShortcut> ThrowRockKey;
public static ConfigEntry<KeyboardShortcut> TrueFormKey;
public static ConfigEntry<KeyboardShortcut> GrabLogKey;
// ─── Passive combat ──────────────────────────────────────────────────
public static ConfigEntry<float> FireWeaknessMultiplier;
public static ConfigEntry<float> BonemassMeleeBonus;
public static ConfigEntry<float> YagluthMeleeBonus;
public static ConfigEntry<float> TrueFormMeleeBonus;
public static ConfigEntry<float> RegenMultiplierBonus;
public static ConfigEntry<float> FavoredSkillXPMultiplier;
public static ConfigEntry<float> CarryWeightBonusBase;
public static ConfigEntry<float> CarryWeightBonusBonemass;
public static ConfigEntry<float> CarryWeightBonusYagluth;
public static ConfigEntry<float> ArmorBonusPerState;
// ─── Throw Rock (tier 3+) ─────────────────────────────────────────────
public static ConfigEntry<float> ThrowRockCooldown;
public static ConfigEntry<float> ThrowRockCooldownTrueForm;
public static ConfigEntry<float> ThrowRockBaseDamage;
public static ConfigEntry<float> ThrowRockBonemassBonus;
public static ConfigEntry<float> ThrowRockYagluthBonus;
public static ConfigEntry<float> ThrowRockTrueFormBonus;
public static ConfigEntry<float> ThrowRockProjectileVelocity;
public static ConfigEntry<float> ThrowLogVelocity;
// ─── True Form (tier 5+) ───────────────────────────────────────────────
public static ConfigEntry<float> TrueFormDuration;
public static ConfigEntry<float> TrueFormCooldown;
public static ConfigEntry<float> TrueFormScaleNormal;
public static ConfigEntry<float> TrueFormScaleAdvanced;
// ─── Log Weapon (tier 7+) ──────────────────────────────────────────────
public static ConfigEntry<float> LogWeaponMaxDurability;
public static ConfigEntry<float> LogWeaponDurabilityDrainPerHit;
// ─── Farming ───────────────────────────────────────────────────────────
public static ConfigEntry<float> UnarmedFarmingDamageBonusPerState;
// ─── Appearance ────────────────────────────────────────────────────────
public static ConfigEntry<Color> SkinColor;
public static ConfigEntry<Color> HairColor;
// The colours every Trol wore before these became settings. Also what a Trol on an older
// build of the mod shows as, since that build publishes no colour of its own.
public static readonly Color DefaultSkinColor = new Color(0.1f, 0.6f, 0.7f, 1f);
public static readonly Color DefaultHairColor = new Color(0.9f, 0.8f, 0.4f, 1f);
public static void Bind(ConfigFile config)
{
const string appearance = "Trol - Appearance";
SkinColor = config.Bind(appearance, "Skin Color", DefaultSkinColor,
new ConfigDescription("Your Trol's skin. Other players see it too. The game multiplies it with the skin texture, so it comes out a little darker than the swatch. For the look of Valheim's own trolls try 7FA8C9."));
HairColor = config.Bind(appearance, "Hair Color", DefaultHairColor,
new ConfigDescription("Your Trol's hair and beard. Other players see it too."));
const string keybinds = "Trol - Keybinds";
ThrowRockKey = config.Bind(keybinds, "Throw Rock", new KeyboardShortcut(KeyCode.G),
new ConfigDescription("Throws a rock (or the log you're holding), tier 3+."));
TrueFormKey = config.Bind(keybinds, "True Form", new KeyboardShortcut(KeyCode.H),
new ConfigDescription("Transform into (or revert from) True Form, tier 5+."));
GrabLogKey = config.Bind(keybinds, "Grab Log", new KeyboardShortcut(KeyCode.E),
new ConfigDescription("Grabs a felled log as a weapon while looking at one, tier 7+ and already in True Form. Matches vanilla's own interact key rather than reusing the True Form key a second time."));
const string combat = "Trol - Passive Combat";
FireWeaknessMultiplier = config.Bind(combat, "Fire Weakness Multiplier", 1.5f,
new ConfigDescription("Multiplies incoming fire damage (1.5 = 50% weaker).", new AcceptableValueRange<float>(1f, 3f)));
BonemassMeleeBonus = config.Bind(combat, "Bonemass Melee Bonus", 10f,
new ConfigDescription("Flat damage added to Clubs/Unarmed/Axes attacks, tier 4+.", new AcceptableValueRange<float>(0f, 100f)));
YagluthMeleeBonus = config.Bind(combat, "Yagluth Melee Bonus", 5f,
new ConfigDescription("Additional flat damage added to Clubs/Unarmed/Axes attacks, tier 6+.", new AcceptableValueRange<float>(0f, 100f)));
TrueFormMeleeBonus = config.Bind(combat, "True Form Melee Bonus", 40f,
new ConfigDescription("Flat damage added to Clubs/Unarmed/Axes attacks while in True Form.", new AcceptableValueRange<float>(0f, 200f)));
RegenMultiplierBonus = config.Bind(combat, "Regen Multiplier Bonus", 0.10f,
new ConfigDescription("Health regen multiplier bonus, tier 3+ (0.10 = +10%).", new AcceptableValueRange<float>(0f, 2f)));
FavoredSkillXPMultiplier = config.Bind(combat, "Favored Skill XP Multiplier", 2f,
new ConfigDescription("Multiplies XP gain for Clubs/Unarmed/Axes/Pickaxes/WoodCutting, tier 2+.", new AcceptableValueRange<float>(0.5f, 5f)));
CarryWeightBonusBase = config.Bind(combat, "Carry Weight Bonus (Base)", 200f,
new ConfigDescription("Flat carry weight added, always active.", new AcceptableValueRange<float>(0f, 1000f)));
CarryWeightBonusBonemass = config.Bind(combat, "Carry Weight Bonus (Bonemass)", 50f,
new ConfigDescription("Additional flat carry weight, tier 4+.", new AcceptableValueRange<float>(0f, 500f)));
CarryWeightBonusYagluth = config.Bind(combat, "Carry Weight Bonus (Yagluth)", 50f,
new ConfigDescription("Additional flat carry weight, tier 6+.", new AcceptableValueRange<float>(0f, 500f)));
ArmorBonusPerState = config.Bind(combat, "Armor Bonus Per State", 3f,
new ConfigDescription("Flat armor added, per progression state.", new AcceptableValueRange<float>(0f, 20f)));
const string throwRock = "Trol - Throw Rock";
ThrowRockCooldown = config.Bind(throwRock, "Cooldown", 60f,
new ConfigDescription("Seconds between throws in human form.", new AcceptableValueRange<float>(0f, 300f)));
ThrowRockCooldownTrueForm = config.Bind(throwRock, "Cooldown (True Form)", 15f,
new ConfigDescription("Seconds between throws while in True Form.", new AcceptableValueRange<float>(0f, 300f)));
ThrowRockBaseDamage = config.Bind(throwRock, "Base Damage", 25f,
new ConfigDescription("Base blunt damage of a thrown rock (not used when throwing a log).", new AcceptableValueRange<float>(0f, 200f)));
ThrowRockBonemassBonus = config.Bind(throwRock, "Bonemass Bonus", 10f,
new ConfigDescription("Additional damage, tier 4+.", new AcceptableValueRange<float>(0f, 100f)));
ThrowRockYagluthBonus = config.Bind(throwRock, "Yagluth Bonus", 5f,
new ConfigDescription("Additional damage, tier 6+.", new AcceptableValueRange<float>(0f, 100f)));
ThrowRockTrueFormBonus = config.Bind(throwRock, "True Form Bonus", 40f,
new ConfigDescription("Additional damage while in True Form.", new AcceptableValueRange<float>(0f, 200f)));
ThrowRockProjectileVelocity = config.Bind(throwRock, "Rock Velocity", 20f,
new ConfigDescription("Travel speed of a thrown rock.", new AcceptableValueRange<float>(1f, 60f)));
ThrowLogVelocity = config.Bind(throwRock, "Log Velocity", 60f,
new ConfigDescription("Travel speed of a thrown log (compensates for its weight/drag).", new AcceptableValueRange<float>(1f, 150f)));
const string trueForm = "Trol - True Form";
TrueFormDuration = config.Bind(trueForm, "Duration", 60f,
new ConfigDescription("Seconds True Form lasts before automatically reverting. Ignored once Fader is defeated: the form then lasts until you press the key again.", new AcceptableValueRange<float>(5f, 600f)));
TrueFormCooldown = config.Bind(trueForm, "Cooldown", 600f,
new ConfigDescription("Seconds between True Form activations.", new AcceptableValueRange<float>(0f, 3600f)));
TrueFormScaleNormal = config.Bind(trueForm, "Scale", 2.0f,
new ConfigDescription("Model scale while in True Form, tier 5-6.", new AcceptableValueRange<float>(1f, 4f)));
TrueFormScaleAdvanced = config.Bind(trueForm, "Scale (Tier 7+)", 2.5f,
new ConfigDescription("Model scale while in True Form, tier 7+.", new AcceptableValueRange<float>(1f, 4f)));
const string logWeapon = "Trol - Log Weapon";
LogWeaponMaxDurability = config.Bind(logWeapon, "Max Durability", 6f,
new ConfigDescription("Hits a grabbed log weapon survives before breaking, tier 7+.", new AcceptableValueRange<float>(1f, 50f)));
LogWeaponDurabilityDrainPerHit = config.Bind(logWeapon, "Durability Drain Per Hit", 1f,
new ConfigDescription("Durability spent per hit landed.", new AcceptableValueRange<float>(0.1f, 10f)));
const string farming = "Trol - Farming";
UnarmedFarmingDamageBonusPerState = config.Bind(farming, "Unarmed Damage Bonus Per State", 3f,
new ConfigDescription("Extra chop/pickaxe damage when farming or mining unarmed, per progression state.", new AcceptableValueRange<float>(0f, 20f)));
}
}
}