RacesOfValheim/JotunnModStub/RaceCompendium.cs
kanym 5d5a6eab42 Fill in the Skadi compendium entry
It was a placeholder reading "The secrets of winter will be revealed
soon...". It now unfolds tier by tier like the Aswid and Furling ones,
covering the passives, the form keybinds, the flight controls and which
attacks are free. The frost bonus and spell damage figures are computed
from the same formulas the code uses, so the text cannot drift when
those constants are tuned.
2026-08-01 18:02:24 +02:00

276 lines
14 KiB
C#

using UnityEngine;
using HarmonyLib;
using System.Text;
using System.Collections.Generic;
namespace RacesOfValheim
{
public static class RaceCompendium
{
private static readonly string[] RaceTitles = new string[]
{
"Aswid Secrets",
"Fenrir Secrets",
"Skadi Secrets",
"Skeleton Secrets",
"Furling Secrets",
"Trol Secrets"
};
public static void UpdateCompendiumText(Player player)
{
if (player == null) return;
var knownTexts = HarmonyLib.Traverse.Create(player).Field("m_knownTexts").GetValue<Dictionary<string, string>>();
if (knownTexts == null) return;
// 1. Remove all old race texts to keep it clean
foreach (var title in RaceTitles)
{
if (knownTexts.ContainsKey(title))
{
knownTexts.Remove(title);
}
}
// 2. Determine current race
ZNetView nview = player.GetComponent<ZNetView>();
if (nview == null || !nview.IsValid()) return;
string currentRace = nview.GetZDO().GetString("RacesOfValheim_Race", "Human");
int state = BossProgressionManager.GetCurrentProgressionState();
if (currentRace == "Aswid")
{
GenerateAswidText(knownTexts, state);
}
else if (currentRace == "Fenrir")
{
GenerateFenrirText(knownTexts, state);
}
else if (currentRace == "Skadi")
{
GenerateSkadiText(knownTexts, state);
}
else if (currentRace == "Skeleton")
{
GenerateSkeletonText(knownTexts, state);
}
else if (currentRace == "Furling")
{
GenerateFurlingText(knownTexts, state, player);
}
else if (currentRace == "Trol")
{
GenerateTrolText(knownTexts, state, player);
}
}
private static void GenerateTrolText(Dictionary<string, string> knownTexts, int state, Player player)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("The Trol's Heritage\n");
sb.AppendLine($"Base Passive: Physical kills automatically consume enemies (if edible). You are natively 20% larger than a human with immense strength. You have +200 Max Carry Weight and gain +3 Armor per boss defeated.\n");
if (state >= 1)
sb.AppendLine("Eikthyr Defeated: Increased XP gain for physical labor and blunt combat (Clubs, Unarmed, Axes, Pickaxes, WoodCutting).\n");
if (state >= 2)
sb.AppendLine("The Elder Defeated: Unlocked Rock Throwing ability. +10% passive health regeneration.\n");
if (state >= 3)
sb.AppendLine("Bonemass Defeated: +5% Size, +50 Carry Weight, +10 Damage to Clubs/Unarmed, +10 Rock Throwing Damage. Unlocked 4th Food Slot.\n");
if (state >= 4)
sb.AppendLine("Moder Defeated: Unlocked True Form (Transformation ability).\n");
if (state >= 5)
sb.AppendLine("Yagluth Defeated: +5% Size, +50 Carry Weight, +10 Damage to Clubs/Unarmed, +5 Rock Throwing Damage. Unlocked 5th Food Slot.\n");
if (state >= 6)
sb.AppendLine("The Queen Defeated: Unlocked Log Weapon (in True Form, interact with trees to wield them as weapons). True Form size is massively increased.\n");
if (state >= 7)
sb.AppendLine("Fader Defeated: Your wielded trees can now instantly smash through the toughest materials in the Ashlands.\n");
knownTexts["Trol Secrets"] = sb.ToString();
}
private static void GenerateAswidText(Dictionary<string, string> knownTexts, int state)
{
int spd = state * 3;
int jmp = state * 3;
int arm = state * 3;
int dmg = state * 5;
StringBuilder sb = new StringBuilder();
sb.AppendLine("The Aswid's Curse\n");
sb.AppendLine($"[Base Passive] Benedictus et Afflictus:");
sb.AppendLine($"Physical kills automatically consume enemies (Vae Victis) granting Blood Magic XP. Your physical stats scale progressively as you defeat Valheim's Bosses: +{arm} Armor, +{dmg} Damage, +{spd}% Speed, and +{jmp}% Jump. All your passive bonuses are doubled during the night. You can cast Blood Magic items with infinite Eitr, and your Blood Magic skill increases twice as fast.\n");
sb.AppendLine("Vampiric Aura (Like a Bat out of Hell/Weight of Shadows Only): Block with your shield (Mouse 2) while in bat or mist form to channel an AoE magic damage aura against nearby enemies, healing for 20% of the damage dealt and converting them into food when they die.\n");
if (state >= 1)
{
// Eikthyr - Base passives already covered
}
if (state >= 5)
{
sb.AppendLine("[Moder Unlock] Freezing Blood (Passive):");
sb.AppendLine("You gain permanent immunity to the Freezing status (mountains/snowstorms) and Poison damage.\n");
sb.AppendLine("[Moder Unlock] Auspex (Passive):");
sb.AppendLine("You emit a 10-meter aura that reveals the presence of untamed creatures by wreathing them in ethereal flames.\n");
}
if (state >= 6)
{
sb.AppendLine("[Yagluth Unlock] Dominate (E Key):");
sb.AppendLine("Press E on non-tameable, non-boss enemies to dominate them for 60 seconds (15-min cooldown). Dominated thralls fight alongside you and drop standard loot.\n");
}
if (state >= 7)
{
sb.AppendLine("[The Queen Unlock] Weight of Shadows (H Key):");
sb.AppendLine("You transform into an elusive mist. You become immune to physical and poison damage, but weak to fire, frost, and spirit. Your Vampiric Aura deals double damage, but you cannot attack or run. Sunrise breaks the transformation.\n");
}
if (state >= 8)
{
sb.AppendLine("[Fader Unlock] Asmund (Passive):");
sb.AppendLine("Your hair and beard turn as dark as the abyss. You become 10% taller and gain a flat +30 to Physical Damage.\n");
}
knownTexts["Aswid Secrets"] = sb.ToString();
}
private static void GenerateFenrirText(Dictionary<string, string> knownTexts, int state)
{
int spd = state * 3;
int jmp = state * 3;
int arm = state * 3;
int dmg = state * 5;
knownTexts["Fenrir Secrets"] = $"The secrets of the pack will be revealed soon...\n\nBase Passive: Physical kills automatically consume enemies (if edible). Your physical stats scale progressively as you defeat Valheim's Bosses: +{arm} Armor, +{dmg} Damage, +{spd}% Speed, and +{jmp}% Jump.";
}
private static void GenerateSkadiText(Dictionary<string, string> knownTexts, int state)
{
// Mirrors the live values so the entry cannot drift from the code: the frost bonus is
// SkadiDamagePatch's 2 per state, the spell figure SkadiRace's 15 + 8 per state.
int frostBonus = state * 2;
int spellDamage = 15 + 8 * state;
StringBuilder sb = new StringBuilder();
sb.AppendLine("The Secrets of Winter\n");
sb.AppendLine("[Base Passive] Ice Affinity:");
sb.AppendLine($"The cold cannot touch you, and frost answers to your hand. You are immune to the Cold status, take only half damage from frost, and every blow you land carries +{frostBonus} Frost damage - a bonus that grows as each boss falls.\n");
if (state >= 2)
{
sb.AppendLine("[Eikthyr Unlock] Cold Spell (Middle Mouse):");
sb.AppendLine($"Hurl a shard of ice at whatever you look upon, for {spellDamage} Frost damage. It draws on 20 stamina rather than eitr, so it serves you from your very first winter.\n");
}
if (state >= 3)
{
sb.AppendLine("[The Elder Unlock] Drake Form ('G' Key):");
sb.AppendLine("Take the shape of a frost drake. Right Mouse lifts you into flight: you glide wherever you aim, hold W to climb and gather speed, and release to hold level a moment before settling into a slow descent. In this shape you cannot yet strike.\n");
}
if (state >= 4)
{
sb.AppendLine("[Bonemass Unlock] Winter's Welcome (Passive):");
sb.AppendLine("The killing gales of the mountains soften to a mere chill - you suffer Cold where others would freeze.\n");
sb.AppendLine("[Bonemass Unlock] Drake Breath (Left Mouse):");
sb.AppendLine("Your drake form may now spit ice at your enemies.\n");
}
if (state >= 5)
{
sb.AppendLine("[Moder Unlock] Moder Form ('H' Key):");
sb.AppendLine("Become the great frost dragon herself for 1 minute, then wait 10 before calling her again. Afoot, Left Mouse bites and claws for no cost at all, while Middle Mouse breathes a stream of ice. On the wing, Left Mouse looses a barrage of shards. Only the breath and the barrage draw upon eitr.\n");
}
if (state >= 6)
{
sb.AppendLine("[Yagluth Unlock] Heart of Winter (Passive):");
sb.AppendLine("Freezing can no longer reach you at all, and your eitr returns half again as fast.\n");
sb.AppendLine("[Yagluth Unlock] Improved Cold Spell:");
sb.AppendLine("Your Cold Spell scatters into ten shards, spreading its bite across all before you. The wider cast needs 4 seconds to gather itself.\n");
sb.AppendLine("Moder Form now answers you again after only 5 minutes.\n");
}
if (state >= 7)
{
sb.AppendLine("[The Queen Unlock] Winter Incarnate (Passive):");
sb.AppendLine("Frost cannot wound you at all, and a freezing aura bleeds from your skin, gnawing at every untamed creature within 3 meters.\n");
sb.AppendLine("Moder Form may now be held as long as you wish, with no wait between callings.\n");
}
if (state >= 8)
{
sb.AppendLine("[Fader Unlock] Skeleton Dragon Form ('J' Key):");
sb.AppendLine("The bones of a dragon rise at your call, wreathed in frost. It rends with bite and claw, sweeps all around it with a spinning tail (Right Mouse), and its breath carries thrice the fury of Moder's.\n");
}
knownTexts["Skadi Secrets"] = sb.ToString();
}
private static void GenerateSkeletonText(Dictionary<string, string> knownTexts, int state)
{
knownTexts["Skeleton Secrets"] = "The secrets of the crypt will be revealed soon...";
}
private static void GenerateFurlingText(Dictionary<string, string> knownTexts, int state, Player player)
{
StringBuilder sb = new StringBuilder();
sb.AppendLine("The secrets of the hoard will be revealed soon...\n");
sb.AppendLine("[Base Passive] Combat Mastery:");
sb.AppendLine("All weapon and combat skills gain 2x XP permanently. You're short, but very fast — your movement speed is permanently increased by 10%.\n");
if (state >= 5)
{
int modelIndex = Traverse.Create(player.GetComponent<VisEquipment>()).Field<int>("m_modelIndex").Value;
string title = modelIndex == 1 ? "The Woman on the Silver Mountain" : "The Man on the Silver Mountain";
sb.AppendLine($"[Moder Unlock] {title} (Passive):");
sb.AppendLine("Whenever a normal enemy dies within 25 meters, its trophy drops are doubled and it drops guaranteed gold coins based on its stars. Furthermore, whenever you mine raw ore deposits, your yield is doubled.\n");
}
if (state >= 6)
{
int modelIndex = Traverse.Create(player.GetComponent<VisEquipment>()).Field<int>("m_modelIndex").Value;
string title = modelIndex == 1 ? "The King is Dead, Hail to the Queen" : "The King is Dead, Hail to the King";
sb.AppendLine($"[Yagluth Unlock] {title} (Passive):");
sb.AppendLine("While you are in the Plains biome, your 2x XP multiplier is extended to all non-combat skills (including Elemental Magic and Blood Magic).\n");
}
if (state >= 7)
{
int modelIndex = Traverse.Create(player.GetComponent<VisEquipment>()).Field<int>("m_modelIndex").Value;
string title = modelIndex == 1 ? "In the Mist She Was Standing" : "In the Mist He Was Standing";
sb.AppendLine($"[The Queen Unlock] {title} (Passive):");
sb.AppendLine("Blue foods (those that restore Eitr) last twice as long for you compared to normal players.\n");
}
if (state >= 8)
{
sb.AppendLine("[Fader Unlock] Through Fire and Flames (Passive):");
sb.AppendLine("You are permanently wreathed in flames. You are completely immune to fire damage. All your physical attacks (regardless of weapon or unarmed) set the target on fire.\n");
}
knownTexts["Furling Secrets"] = sb.ToString();
}
}
[HarmonyPatch(typeof(TextsDialog), "Setup")]
public static class CompendiumSetup_Patch
{
public static void Prefix(Player player)
{
if (player != null)
{
RaceCompendium.UpdateCompendiumText(player);
}
}
}
}