RacesOfValheim/JotunnModStub/Trol/TrolConfig.cs
kanym db29f868ea fix(trol): True Form troll size, log, reach, root during attacks, slam
The troll pulsed several times a second and stayed small because
PlayerVisualHider.Hide put the hidden Visual back to scale 1 every
frame while Trol_PlayerUpdate_Patch grew it back, and the troll follows
that scale. Hide and Show take keepScale now, and the Trol calls pass
it. The camera height, which reads the same scale, stops jumping too.

The log in the troll's hand is the troll's own log model, hung the way
VisEquipment does it, instead of the Trol's, which was built for a
person's hand and came out huge and sideways.

Punch and slam reach further and hit wider, with a new Troll Attack
Reach option (1.3). The player is held still through every attack
clip, throw included.

The ground slam spawns the troll's own troll_groundslam_aoe with the
player's damage, kept off friends, plus its trigger and terrain
effects. It carries chop and pickaxe at least equal to its blunt, so
it breaks trees and rocks, and with Ground Slam Crater on it digs into
the terrain where it lands, never inside a ward without access.
2026-10-14 17:08:20 +02:00

163 lines
13 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;
public static ConfigEntry<bool> TrueFormUseTrollModel;
public static ConfigEntry<float> TrueFormModelSize;
public static ConfigEntry<float> TrueFormTrollDamageShare;
public static ConfigEntry<float> TrueFormAttackReach;
public static ConfigEntry<bool> TrueFormSlamCrater;
// ─── 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)));
TrueFormUseTrollModel = config.Bind(trueForm, "Troll Model", true,
new ConfigDescription("Wear Valheim's own troll in True Form, with its own punch and ground slam instead of your weapons. Off: the old True Form, a bigger Trol with weapons in hand."));
TrueFormModelSize = config.Bind(trueForm, "Troll Model Size", 1f,
new ConfigDescription("How tall the troll stands, as a share of the True Form size set by Scale above. 1 = exactly as tall as the old True Form.", new AcceptableValueRange<float>(0.5f, 2f)));
TrueFormTrollDamageShare = config.Bind(trueForm, "Troll Attack Damage", 0.5f,
new ConfigDescription("Share of a real troll's damage each troll attack deals. Your Clubs skill then scales it the way it scales a club, and the True Form Melee Bonus and tier bonuses add on top.", new AcceptableValueRange<float>(0.1f, 2f)));
TrueFormAttackReach = config.Bind(trueForm, "Troll Attack Reach", 1.3f,
new ConfigDescription("Multiplies how far the troll's punch and slam reach and how wide they hit. 1 = a real troll's reach at the size you stand.", new AcceptableValueRange<float>(0.5f, 3f)));
TrueFormSlamCrater = config.Bind(trueForm, "Ground Slam Crater", true,
new ConfigDescription("The ground slam digs into the ground where it lands, like a pickaxe blow. Never inside a ward you have no access to."));
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)));
}
}
}