RacesOfValheim/JotunnModStub/Trol/TrolStatusEffects.cs
kanym 9bf144aedc feat(text): status effect names and tooltips come from translation files
Every status effect the mod registers now carries a $rov_se_ token instead
of English, and status_effects.json holds the texts in English and Italian.
Valheim localizes both fields itself when it shows them. The blood
potion's tooltip has numbers in it, so SE_BloodPotion fills its $1 and $2
in GetTooltipString, at display time.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-09-26 19:51:10 +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 = "$rov_se_trol_throwcd_name";
m_tooltip = "$rov_se_trol_throwcd_tooltip";
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 = "$rov_se_trol_trueform_name";
m_tooltip = "$rov_se_trol_trueform_tooltip";
// 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 = "$rov_se_trol_trueformcd_name";
m_tooltip = "$rov_se_trol_trueformcd_tooltip";
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));
}
}
}