RacesOfValheim/JotunnModStub/Trol/TrolStatusEffects.cs
Ferdinando 8aa917cfcb chore(release): v1.4.16 - Trol True Form toggle past Fader, Gammeltroll thrown log
Past Fader the Trol's True Form never expires (SE ttl 0) and the key
toggles it off with no cooldown. The True Form log throw now fires one
projectile read off the Gammeltroll's own weapons at runtime, hitting
with the rock's damage formula, and falls back to the old physical log
if none is found; 'dumpgammel' logs what was resolved.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-13 11:33:47 +02:00

93 lines
3.5 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!";
// Past Fader the form no longer runs out: m_ttl 0 is vanilla's "never expires", and
// the True Form key becomes the only way back (see TrolRace.TryTrueForm).
m_ttl = BossProgressionManager.GetCurrentProgressionState() >= 8 ? 0f : 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));
}
}
}