Initial commit

This commit is contained in:
Ferdinando 2026-07-30 19:00:13 +02:00
commit c4a24c9fdf
142 changed files with 15491 additions and 0 deletions

View file

@ -0,0 +1,217 @@
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)
{
knownTexts["Skadi Secrets"] = "The secrets of winter will be revealed soon...";
}
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);
}
}
}
}