RacesOfValheim/JotunnModStub/Trol/TrolStatusEffects.cs
kanym 4b5d60d4b6 feat(trol): make ability numbers and keybinds BepInEx-configurable
Adds TrolConfig.cs, following the established per-race pattern: one
Configuration Manager section per topic (Passive Combat, Throw Rock,
True Form, Log Weapon, Farming), plus the two ability keybinds (Throw
Rock, True Form). Defaults match the previous hardcoded constants
exactly.

Fixes a real sync risk found while wiring it: True Form's scale (2.0
normal / 2.5 at tier 7+) was hardcoded independently in two places - the
local transform routine in TrolRace and the remote-player sizing postfix
in TrolPatches. Both now read the same TrolConfig.TrueFormScaleNormal/
TrueFormScaleAdvanced, so a retuned value can no longer make a Trol one
size to themselves and another size to everyone else.

Tier-gate thresholds and the small hardcoded "normal size by tier" table
(1.2/1.25/1.30) stay untouched, same boundary drawn for every other
race's progression data.

Config sections stay bound alphabetically by race (Aswid, Draugh,
Dvergar, Fenrir, Furling, Skadi, Skeleton, Trenta, Trol) in
RacesOfValheim.Awake() - this is the last of the nine.
2026-08-06 15:34:05 +02:00

91 lines
3.3 KiB
C#

using Jotunn.Managers;
using Jotunn.Entities;
using UnityEngine;
namespace RacesOfValheim
{
public class SE_TrolThrowRockCooldown : SE_Stats
{
public override void Setup(Character character)
{
base.Setup(character);
name = "SE_TrolThrowRockCooldown";
m_name = "Throw Rock Cooldown";
m_tooltip = "You must wait before throwing another rock.";
m_ttl = 60f; // 1 minute cooldown
// Try to find a rock-like icon, e.g. Stone
GameObject itemPrefab = PrefabManager.Cache.GetPrefab<GameObject>("Stone");
if (itemPrefab != null)
{
ItemDrop drop = itemPrefab.GetComponent<ItemDrop>();
if (drop != null && drop.m_itemData.m_shared.m_icons.Length > 0)
{
m_icon = drop.m_itemData.m_shared.m_icons[0];
}
}
}
}
public class SE_TrolTrueForm : SE_Stats
{
public override void Setup(Character character)
{
base.Setup(character);
name = "SE_TrolTrueForm";
m_name = "True Form";
m_tooltip = "You have unleashed your inner troll!";
m_ttl = TrolConfig.TrueFormDuration.Value;
GameObject itemPrefab = PrefabManager.Cache.GetPrefab<GameObject>("Stone");
if (itemPrefab != null)
{
ItemDrop drop = itemPrefab.GetComponent<ItemDrop>();
if (drop != null && drop.m_itemData.m_shared.m_icons.Length > 0)
{
m_icon = drop.m_itemData.m_shared.m_icons[0];
}
}
}
}
public class SE_TrolTrueFormCooldown : SE_Stats
{
public override void Setup(Character character)
{
base.Setup(character);
name = "SE_TrolTrueFormCooldown";
m_name = "True Form Cooldown";
m_tooltip = "You are exhausted from your True Form.";
m_ttl = TrolConfig.TrueFormCooldown.Value;
GameObject itemPrefab = PrefabManager.Cache.GetPrefab<GameObject>("Stone");
if (itemPrefab != null)
{
ItemDrop drop = itemPrefab.GetComponent<ItemDrop>();
if (drop != null && drop.m_itemData.m_shared.m_icons.Length > 0)
{
m_icon = drop.m_itemData.m_shared.m_icons[0];
}
}
}
}
public static class TrolStatusEffects
{
public static void RegisterStatusEffects()
{
var cdSE = ScriptableObject.CreateInstance<SE_TrolThrowRockCooldown>();
cdSE.name = "SE_TrolThrowRockCooldown";
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(cdSE, fixReference: false));
var tfSE = ScriptableObject.CreateInstance<SE_TrolTrueForm>();
tfSE.name = "SE_TrolTrueForm";
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(tfSE, fixReference: false));
var tfCdSE = ScriptableObject.CreateInstance<SE_TrolTrueFormCooldown>();
tfCdSE.name = "SE_TrolTrueFormCooldown";
ItemManager.Instance.AddStatusEffect(new CustomStatusEffect(tfCdSE, fixReference: false));
}
}
}