Merge branch 'main' into race-chains-and-stations

# Conflicts:
#	JotunnModStub/Aswid/AswidRace.cs
#	JotunnModStub/Factions/FactionHostilityPatch.cs
#	JotunnModStub/Factions/FactionMerchantCatalog.cs
#	JotunnModStub/Furling/FurlingPatches.cs
This commit is contained in:
kanym 2026-08-07 17:15:10 +02:00
commit f60b8d8f7d
48 changed files with 1865 additions and 380 deletions

View file

@ -0,0 +1,133 @@
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;
public static void Bind(ConfigFile config)
{
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.", 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)));
}
}
}

View file

@ -10,10 +10,10 @@ namespace RacesOfValheim
{
if (__instance == Player.m_localPlayer && TrolRace.IsTrol())
{
// Trols are weak to fire (take 50% more damage)
// Trols are weak to fire
if (hit.m_damage.m_fire > 0f)
{
hit.m_damage.m_fire *= 1.5f;
hit.m_damage.m_fire *= TrolConfig.FireWeaknessMultiplier.Value;
}
}
@ -21,37 +21,40 @@ namespace RacesOfValheim
{
if (BossProgressionManager.GetCurrentProgressionState() >= 4) // Bonemass
{
float bonus = TrolConfig.BonemassMeleeBonus.Value;
if (hit.m_skill == Skills.SkillType.Clubs || hit.m_skill == Skills.SkillType.Unarmed)
{
hit.m_damage.m_blunt += 10f;
hit.m_damage.m_blunt += bonus;
}
else if (hit.m_skill == Skills.SkillType.Axes)
{
hit.m_damage.m_slash += 10f;
hit.m_damage.m_slash += bonus;
}
}
if (BossProgressionManager.GetCurrentProgressionState() >= 6) // Yagluth
{
float bonus = TrolConfig.YagluthMeleeBonus.Value;
if (hit.m_skill == Skills.SkillType.Clubs || hit.m_skill == Skills.SkillType.Unarmed)
{
hit.m_damage.m_blunt += 5f;
hit.m_damage.m_blunt += bonus;
}
else if (hit.m_skill == Skills.SkillType.Axes)
{
hit.m_damage.m_slash += 5f;
hit.m_damage.m_slash += bonus;
}
}
if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode()))
{
float bonus = TrolConfig.TrueFormMeleeBonus.Value;
if (hit.m_skill == Skills.SkillType.Clubs || hit.m_skill == Skills.SkillType.Unarmed)
{
hit.m_damage.m_blunt += 40f;
hit.m_damage.m_blunt += bonus;
}
else if (hit.m_skill == Skills.SkillType.Axes)
{
hit.m_damage.m_slash += 40f;
hit.m_damage.m_slash += bonus;
}
}
}

View file

@ -33,7 +33,7 @@ namespace RacesOfValheim
else if (state >= 3) hit.m_toolTier = 1; // Elder (Bronze)
else if (state >= 2) hit.m_toolTier = 1; // Eikthyr (Flint/Antler)
float damageBonus = state * 3f;
float damageBonus = state * TrolConfig.UnarmedFarmingDamageBonusPerState.Value;
// Convert blunt damage to chop or pickaxe damage, plus progression bonus
if (isTree)

View file

@ -94,4 +94,35 @@ namespace RacesOfValheim
}
}
}
/// <summary>
/// A fallen log already shows a hover prompt in vanilla - its own name, via a HoverText
/// component vanilla itself attaches (confirmed live: GetComponentInParent&lt;Hoverable&gt;()
/// on a log resolves to HoverText, not TreeLog itself, which only implements IDestructible).
/// A first attempt added a second, competing Hoverable component to the same GameObject and
/// it was never reached - Unity's GetComponentInParent&lt;T&gt;() returns only the first
/// match, and vanilla's own HoverText was already there first. The fix is to append to
/// HoverText's own result instead of trying to out-compete it.
/// </summary>
[HarmonyPatch(typeof(HoverText), "GetHoverText")]
public static class Trol_LogHoverText_Patch
{
public static void Postfix(HoverText __instance, ref string __result)
{
if (Player.m_localPlayer == null || !TrolRace.IsTrol()) return;
if (BossProgressionManager.GetCurrentProgressionState() < 7) return;
if (!Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode())) return;
TreeLog log = ((Component)__instance).GetComponentInParent<TreeLog>();
if (log == null) return;
// Already holding a log - grabbing again is a no-op in TrolLogWeapon.GrabLog, so no
// prompt either.
ItemDrop.ItemData rightItem = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field<ItemDrop.ItemData>("m_rightItem").Value;
if (rightItem != null && rightItem.m_dropPrefab != null && rightItem.m_dropPrefab.name.StartsWith("TrolWeapon_")) return;
string key = TrolConfig.GrabLogKey.Value.MainKey.ToString();
__result += $"\n[<color=yellow><b>{key}</b></color>] Grab Log";
}
}
}

View file

@ -149,7 +149,7 @@ namespace RacesOfValheim
float targetScale = ScaleForState(state);
if (isTrueFormActive)
{
targetScale = state >= 7 ? 2.5f : 2.0f;
targetScale = state >= 7 ? TrolConfig.TrueFormScaleAdvanced.Value : TrolConfig.TrueFormScaleNormal.Value;
}
if (!isLocal)
@ -204,18 +204,18 @@ namespace RacesOfValheim
string race = "Human"; ZNetView nview = __instance.GetComponent<ZNetView>(); if (nview != null && nview.IsValid()) race = nview.GetZDO().GetString("RacesOfValheim_Race", "Human"); else if (__instance.m_customData != null && __instance.m_customData.TryGetValue("Race", out string savedRace)) race = savedRace; if (race == "Trol")
{
// Base carry weight is 300. We add 200 to make it 500.
// Base carry weight is 300. We add a bonus to make it 500 by default.
// If they wear Megingjord, it will become 500 + 150 = 650.
__result += 200f;
__result += TrolConfig.CarryWeightBonusBase.Value;
int state = BossProgressionManager.GetCurrentProgressionState();
if (state >= 4)
{
__result += 50f; // After Bonemass
__result += TrolConfig.CarryWeightBonusBonemass.Value;
}
if (state >= 6)
{
__result += 50f; // After Yagluth
__result += TrolConfig.CarryWeightBonusYagluth.Value;
}
}
}
@ -228,9 +228,8 @@ namespace RacesOfValheim
{
if (__instance == Player.m_localPlayer && TrolRace.IsTrol())
{
// +3 Armor per progression state (boss defeated)
int state = BossProgressionManager.GetCurrentProgressionState();
__result += 3f * state;
__result += TrolConfig.ArmorBonusPerState.Value * state;
}
}
}

View file

@ -102,9 +102,9 @@ namespace RacesOfValheim
}
ItemDrop itemDrop = customWep.ItemPrefab.GetComponent<ItemDrop>();
itemDrop.m_itemData.m_shared.m_maxDurability = 6f;
itemDrop.m_itemData.m_shared.m_maxDurability = TrolConfig.LogWeaponMaxDurability.Value;
itemDrop.m_itemData.m_shared.m_useDurability = true;
itemDrop.m_itemData.m_shared.m_useDurabilityDrain = 1f;
itemDrop.m_itemData.m_shared.m_useDurabilityDrain = TrolConfig.LogWeaponDurabilityDrainPerHit.Value;
itemDrop.m_itemData.m_shared.m_destroyBroken = false;
itemDrop.m_itemData.m_shared.m_weight = 0f;
itemDrop.m_itemData.m_shared.m_equipDuration = 0.1f;
@ -125,15 +125,20 @@ namespace RacesOfValheim
if (RaceInput.Allowed)
{
if (Input.GetKeyDown(KeyCode.G))
if (TrolConfig.ThrowRockKey.Value.IsDown())
{
TryThrowRock();
}
if (Input.GetKeyDown(KeyCode.H))
if (TrolConfig.TrueFormKey.Value.IsDown())
{
TryTrueForm();
}
if (TrolConfig.GrabLogKey.Value.IsDown())
{
TryGrabLog();
}
}
// Check log durability
@ -180,18 +185,9 @@ namespace RacesOfValheim
if (Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode()))
{
if (BossProgressionManager.GetCurrentProgressionState() >= 7)
{
GameObject hoverObj = Player.m_localPlayer.GetHoverObject();
if (hoverObj != null)
{
TreeLog log = hoverObj.GetComponentInParent<TreeLog>();
if (log != null)
{
TrolLogWeapon.GrabLog(Player.m_localPlayer, log);
}
}
}
// Grabbing a log now has its own key (TrolConfig.GrabLogKey, see TryGrabLog) -
// pressing True Form again while already transformed no longer tries to grab
// whatever you happen to be looking at.
return;
}
@ -209,6 +205,21 @@ namespace RacesOfValheim
}
}
private void TryGrabLog()
{
if (BossProgressionManager.GetCurrentProgressionState() < 7) return;
if (!Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode())) return;
GameObject hoverObj = Player.m_localPlayer.GetHoverObject();
if (hoverObj == null) return;
TreeLog log = hoverObj.GetComponentInParent<TreeLog>();
if (log != null)
{
TrolLogWeapon.GrabLog(Player.m_localPlayer, log);
}
}
private System.Collections.IEnumerator TransformToTrueFormRoutine()
{
isTransforming = true;
@ -221,7 +232,9 @@ namespace RacesOfValheim
if (visual != null)
{
Vector3 startScale = visual.transform.localScale;
float trueFormScale = BossProgressionManager.GetCurrentProgressionState() >= 7 ? 2.5f : 2.0f;
float trueFormScale = BossProgressionManager.GetCurrentProgressionState() >= 7
? TrolConfig.TrueFormScaleAdvanced.Value
: TrolConfig.TrueFormScaleNormal.Value;
Vector3 targetScale = new Vector3(trueFormScale, trueFormScale, trueFormScale);
while (elapsed < duration)
@ -281,7 +294,7 @@ namespace RacesOfValheim
private System.Collections.IEnumerator ThrowRockRoutine()
{
bool isTrueForm = Player.m_localPlayer.GetSEMan().HaveStatusEffect("SE_TrolTrueForm".GetStableHashCode());
float throwRockCooldown = isTrueForm ? 15f : 60f;
float throwRockCooldown = isTrueForm ? TrolConfig.ThrowRockCooldownTrueForm.Value : TrolConfig.ThrowRockCooldown.Value;
var addedSE = Player.m_localPlayer.GetSEMan().AddStatusEffect("SE_TrolThrowRockCooldown".GetStableHashCode(), true);
if (addedSE != null)
@ -327,8 +340,8 @@ namespace RacesOfValheim
if (rb != null)
{
// 3x speed to compensate for log weight/drag
rb.velocity = Player.m_localPlayer.GetLookDir() * 60f;
// Compensates for log weight/drag
rb.velocity = Player.m_localPlayer.GetLookDir() * TrolConfig.ThrowLogVelocity.Value;
// Add some slight rotation tumbling
rb.angularVelocity = new Vector3(10f, 5f, 0f);
}
@ -347,24 +360,24 @@ namespace RacesOfValheim
if (proj != null)
{
HitData hitData = new HitData();
hitData.m_damage.m_blunt = 25f; // Base troll rock
hitData.m_damage.m_blunt = TrolConfig.ThrowRockBaseDamage.Value;
if (BossProgressionManager.GetCurrentProgressionState() >= 4)
{
hitData.m_damage.m_blunt += 10f; // Bonemass bonus
hitData.m_damage.m_blunt += TrolConfig.ThrowRockBonemassBonus.Value;
}
if (BossProgressionManager.GetCurrentProgressionState() >= 6)
{
hitData.m_damage.m_blunt += 5f; // Yagluth bonus
hitData.m_damage.m_blunt += TrolConfig.ThrowRockYagluthBonus.Value;
}
if (isTrueForm)
{
hitData.m_damage.m_blunt += 40f; // True Form bonus
hitData.m_damage.m_blunt += TrolConfig.ThrowRockTrueFormBonus.Value;
}
hitData.SetAttacker(Player.m_localPlayer);
proj.Setup(Player.m_localPlayer, Player.m_localPlayer.GetLookDir() * 20f, -1f, hitData, null, null);
proj.Setup(Player.m_localPlayer, Player.m_localPlayer.GetLookDir() * TrolConfig.ThrowRockProjectileVelocity.Value, -1f, hitData, null, null);
}
}
}

View file

@ -12,7 +12,7 @@ namespace RacesOfValheim
// After The Elder (Progression State >= 2)
if (BossProgressionManager.GetCurrentProgressionState() >= 3)
{
regenMultiplier *= 1.10f; // +10% passive health regeneration
regenMultiplier *= 1f + TrolConfig.RegenMultiplierBonus.Value;
}
}
}

View file

@ -23,7 +23,7 @@ namespace RacesOfValheim
if (isTrolSkill)
{
factor *= 2f;
factor *= TrolConfig.FavoredSkillXPMultiplier.Value;
}
}
}

View file

@ -35,7 +35,7 @@ namespace RacesOfValheim
name = "SE_TrolTrueForm";
m_name = "True Form";
m_tooltip = "You have unleashed your inner troll!";
m_ttl = 60f; // 1 minute duration
m_ttl = TrolConfig.TrueFormDuration.Value;
GameObject itemPrefab = PrefabManager.Cache.GetPrefab<GameObject>("Stone");
if (itemPrefab != null)
@ -57,7 +57,7 @@ namespace RacesOfValheim
name = "SE_TrolTrueFormCooldown";
m_name = "True Form Cooldown";
m_tooltip = "You are exhausted from your True Form.";
m_ttl = 600f; // 10 minutes cooldown
m_ttl = TrolConfig.TrueFormCooldown.Value;
GameObject itemPrefab = PrefabManager.Cache.GetPrefab<GameObject>("Stone");
if (itemPrefab != null)