Merge pull request 'fix-skeleton-bugs' (#13) from fix-skeleton-bugs into main
Reviewed-on: #13
This commit is contained in:
commit
93157632a4
11 changed files with 543 additions and 91 deletions
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "RacesOfValheim",
|
||||
"description": "A Valheim mod that adds nine custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Trenta, Trol) each with unique abilities, traits, and a deep boss-driven progression system.",
|
||||
"version_number": "1.3.11",
|
||||
"version_number": "1.3.12",
|
||||
"website_url": "",
|
||||
"dependencies": [
|
||||
"denikson-BepInExPack_Valheim-5.4.2333",
|
||||
|
|
|
|||
|
|
@ -299,9 +299,77 @@ namespace RacesOfValheim
|
|||
knownTexts["Skadi Secrets"] = sb.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// This was a one-line placeholder that returned the same sentence at every tier, which is
|
||||
/// why players reported that "Skeleton Secrets never populates after bosses" - it was never
|
||||
/// written, rather than broken. It now unfolds tier by tier with the real numbers, the way
|
||||
/// the Skadi entry above does.
|
||||
/// </summary>
|
||||
private static void GenerateSkeletonText(Dictionary<string, string> knownTexts, int state)
|
||||
{
|
||||
knownTexts["Skeleton Secrets"] = "The secrets of the crypt will be revealed soon...";
|
||||
var rules = SkeletonProgression.GetRules(state);
|
||||
float health = SkeletonProgression.GetMaxHealthBonus(state);
|
||||
int lifesteal = Mathf.RoundToInt(rules.LifestealPercent * 100f);
|
||||
|
||||
StringBuilder sb = new StringBuilder();
|
||||
sb.AppendLine("The Secrets of the Crypt\n");
|
||||
|
||||
// Says out loud which tier the race thinks it is on. A player who has killed a boss and
|
||||
// seen nothing change can read this line back and know immediately whether the tier
|
||||
// failed to advance or the unlock itself is broken.
|
||||
sb.AppendLine(state <= BossProgressionManager.MinState
|
||||
? "You stand at the first of eight standings; no boss has yet fallen to your reckoning.\n"
|
||||
: $"You stand at the {state} of eight standings, earned by the fall of {BossProgressionManager.GetBossNameForState(state)}.\n");
|
||||
|
||||
sb.AppendLine("[Base Passive] Undead Diet:");
|
||||
sb.AppendLine($"No hunger moves you and no meal can help you - mortal food is nothing to dry bones. In its place the dead grow strong as their betters fall: you carry +{health:0} Maximum Health at your present standing. Nor does effort tire you; you have no stamina to spend at all.\n");
|
||||
|
||||
sb.AppendLine("[Base Passive] Bones and Blades:");
|
||||
sb.AppendLine("Blades and points find little to cut in you and do half their work, but a hammer's weight finds everything, and hurts you the more for it.\n");
|
||||
|
||||
if (state >= 2)
|
||||
{
|
||||
sb.AppendLine("[Eikthyr Unlock] The Green Rot:");
|
||||
sb.AppendLine($"Poison has nothing left to poison - it cannot touch you at all - and your bones take on its sickly cast. Every blow you land returns {lifesteal}% of what it deals in physical harm to your own frame.\n");
|
||||
}
|
||||
|
||||
if (state >= 3)
|
||||
{
|
||||
sb.AppendLine("[The Elder Unlock] The First Blow:");
|
||||
sb.AppendLine("The first strike out of the dark staggers whatever it lands upon. The dead may do this once every 5 seconds.\n");
|
||||
}
|
||||
|
||||
if (state >= 4)
|
||||
{
|
||||
sb.AppendLine("[Bonemass Unlock] Rotten Touch:");
|
||||
sb.AppendLine("What you strike, you sicken - every blow carries 20 Poison damage of its own.\n");
|
||||
}
|
||||
|
||||
if (state >= 5)
|
||||
{
|
||||
sb.AppendLine("[Moder Unlock] Bones Alight:");
|
||||
sb.AppendLine("Your frame is remade in a harder cast, and fire clings to it: everything near enough to feel it is scorched. Your wounds also close faster than bone has any right to.\n");
|
||||
}
|
||||
|
||||
if (state >= 6)
|
||||
{
|
||||
sb.AppendLine("[Yagluth Unlock] Risen Again:");
|
||||
sb.AppendLine("A killing blow no longer ends you. You are made whole where you stand - and then the dark magic must gather itself for 5 minutes before it will do so again.\n");
|
||||
}
|
||||
|
||||
if (state >= 7)
|
||||
{
|
||||
sb.AppendLine("[The Queen Unlock] The Crypt Answers:");
|
||||
sb.AppendLine($"Every enemy you put down rises to fight for you, up to {rules.MaxSummons} at your side at once.\n");
|
||||
}
|
||||
|
||||
if (state >= 8)
|
||||
{
|
||||
sb.AppendLine("[Fader Unlock] A Host of Your Own:");
|
||||
sb.AppendLine($"{rules.MaxSummons} of the dead now follow you, and {lifesteal}% of the harm you deal comes back as your own strength.\n");
|
||||
}
|
||||
|
||||
knownTexts["Skeleton Secrets"] = sb.ToString();
|
||||
}
|
||||
|
||||
private static void GenerateFurlingText(Dictionary<string, string> knownTexts, int state, Player player)
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace RacesOfValheim
|
|||
{
|
||||
public const string PluginGUID = "com.nandor.racesofvalheim";
|
||||
public const string PluginName = "Races Of Valheim";
|
||||
public const string PluginVersion = "1.3.11";
|
||||
public const string PluginVersion = "1.3.12";
|
||||
|
||||
private readonly Harmony harmony = new Harmony(PluginGUID);
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,53 @@ namespace RacesOfValheim
|
|||
private static Mesh skeletonMesh = null;
|
||||
private static Material[] skeletonMaterials = null;
|
||||
|
||||
// Model names already reported as missing. The body swap runs from a visual refresh, so
|
||||
// without this a mistyped prefab id would log every time equipment changes.
|
||||
private static readonly System.Collections.Generic.HashSet<string> warnedMissingModels =
|
||||
new System.Collections.Generic.HashSet<string>();
|
||||
|
||||
// Model parts whose bone mapping has already been reported this session.
|
||||
private static readonly System.Collections.Generic.HashSet<string> loggedBoneMaps =
|
||||
new System.Collections.Generic.HashSet<string>();
|
||||
|
||||
private static void WarnMissingModelOnce(string prefabName)
|
||||
{
|
||||
if (!warnedMissingModels.Add(prefabName)) return;
|
||||
|
||||
Jotunn.Logger.LogWarning(
|
||||
$"[Skeleton] Body model prefab '{prefabName}' not found - the race has no mesh at this tier. " +
|
||||
"Check the id in SkeletonProgression.");
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes the Skeleton's max health exactly what its progression promises.
|
||||
///
|
||||
/// A Skeleton cannot eat, so SkeletonRace fakes three permanent foods whose values are
|
||||
/// scaled to add up to the tier's bonus. That is a good way to keep food-based health
|
||||
/// regeneration working - Valheim regenerates from the food list, so a Skeleton with no
|
||||
/// food would never heal - but a bad way to land an exact number: the value the game reads
|
||||
/// is Food.m_health, which UpdateFood recomputes every second as
|
||||
/// Pow(remaining/burnTime, 0.3) * m_food, and anything that leaves those three foods
|
||||
/// partly burnt, partly rebuilt or one short quietly costs health. A Bonemass-tier
|
||||
/// Skeleton reported 95 max health where the table promises 25 + 140.
|
||||
///
|
||||
/// So the foods stay, for regeneration, and the total they feed into is overwritten here.
|
||||
/// GetTotalFoodValue has exactly one caller, Player.UpdateFood, which passes the result
|
||||
/// straight to SetMaxHealth - so this is the single point where the number is decided, and
|
||||
/// it now comes from the progression table rather than from three scaled sausages.
|
||||
/// </summary>
|
||||
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
|
||||
public static class Player_GetTotalFoodValue_SkeletonHealth_Patch
|
||||
{
|
||||
public static void Postfix(Player __instance, ref float hp)
|
||||
{
|
||||
if (__instance != Player.m_localPlayer || !SkeletonRace.IsSkeleton()) return;
|
||||
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
hp = __instance.m_baseHP + SkeletonProgression.GetMaxHealthBonus(state);
|
||||
}
|
||||
}
|
||||
|
||||
[HarmonyPatch(typeof(Player), "UseStamina")]
|
||||
public static class Player_UseStamina_Patch
|
||||
{
|
||||
|
|
@ -231,6 +278,13 @@ namespace RacesOfValheim
|
|||
if (skeletonBodyTransform == null)
|
||||
{
|
||||
GameObject skelPrefab = PrefabManager.Cache.GetPrefab<GameObject>(rules.ModelPrefab);
|
||||
if (skelPrefab == null)
|
||||
{
|
||||
// The human body was switched off two lines up, so an unresolved
|
||||
// model leaves an invisible player rather than an obvious error.
|
||||
// Say so once per tier instead of failing silently.
|
||||
WarnMissingModelOnce(rules.ModelPrefab);
|
||||
}
|
||||
if (skelPrefab != null)
|
||||
{
|
||||
GameObject skelObj = new GameObject(targetBodyName);
|
||||
|
|
@ -245,17 +299,18 @@ namespace RacesOfValheim
|
|||
|
||||
// Map bones by name
|
||||
Transform[] playerBones = __instance.m_bodyModel.bones;
|
||||
LogBoneMapping(rules.ModelPrefab, newSmr, playerBones);
|
||||
|
||||
Transform[] newBones = new Transform[newSmr.bones.Length];
|
||||
for (int i = 0; i < newSmr.bones.Length; i++)
|
||||
{
|
||||
Transform matchedBone = FindBoneByName(playerBones, newSmr.bones[i].name);
|
||||
newBones[i] = matchedBone != null ? matchedBone : playerBones[0];
|
||||
newBones[i] = ResolveBone(playerBones, newSmr.bones[i]);
|
||||
}
|
||||
newSmr.bones = newBones;
|
||||
|
||||
|
||||
if (newSmr.rootBone != null)
|
||||
{
|
||||
newSmr.rootBone = FindBoneByName(playerBones, newSmr.rootBone.name) ?? playerBones[0];
|
||||
newSmr.rootBone = ResolveBone(playerBones, newSmr.rootBone);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -347,6 +402,90 @@ namespace RacesOfValheim
|
|||
catch (System.Exception e) { }
|
||||
}
|
||||
|
||||
// Bones worth reporting on. Not remapped - the player rig has a real 'Jaw' bone and the
|
||||
// name match lands on it correctly, which is exactly why the plain and poison skeletons
|
||||
// always looked right. An earlier attempt pinned this group to the head instead and
|
||||
// deformed all three models; the log is what settled it.
|
||||
private static readonly string[] SkullParts = { "jaw", "teeth", "tooth", "tongue", "chin", "mandible" };
|
||||
|
||||
/// <summary>
|
||||
/// Finds the player bone a creature bone should be skinned to.
|
||||
/// </summary>
|
||||
private static Transform ResolveBone(Transform[] playerBones, Transform sourceBone)
|
||||
{
|
||||
if (sourceBone == null) return playerBones[0];
|
||||
|
||||
Transform direct = FindBoneByName(playerBones, sourceBone.name);
|
||||
if (direct != null) return direct;
|
||||
|
||||
// Nothing by that name. Follow the creature's own hierarchy upward until something
|
||||
// matches, so an unmapped part rides its nearest real parent rather than being
|
||||
// dumped on bones[0], which is the root.
|
||||
for (Transform parent = sourceBone.parent; parent != null; parent = parent.parent)
|
||||
{
|
||||
Transform match = FindBoneByName(playerBones, parent.name);
|
||||
if (match != null) return match;
|
||||
}
|
||||
|
||||
return playerBones[0];
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Reports how a model's bones landed on the player rig, once per model per session.
|
||||
/// The mandible problem is not diagnosable from a screenshot - it matters whether the
|
||||
/// jaw has a bone at all, whether it matched something, and what it matched - and this
|
||||
/// answers all three in one line each.
|
||||
/// </summary>
|
||||
private static void LogBoneMapping(string modelName, SkinnedMeshRenderer smr, Transform[] playerBones)
|
||||
{
|
||||
if (!loggedBoneMaps.Add($"{modelName}/{smr.name}")) return;
|
||||
|
||||
Jotunn.Logger.LogInfo($"[Skeleton] '{modelName}' part '{smr.name}': {smr.bones.Length} bones.");
|
||||
|
||||
foreach (Transform bone in smr.bones)
|
||||
{
|
||||
if (bone == null) continue;
|
||||
|
||||
string lower = bone.name.ToLower();
|
||||
bool interesting = false;
|
||||
foreach (string part in SkullParts)
|
||||
{
|
||||
if (lower.Contains(part)) { interesting = true; break; }
|
||||
}
|
||||
|
||||
Transform resolved = ResolveBone(playerBones, bone);
|
||||
bool isRootFallback = resolved == playerBones[0] &&
|
||||
FindBoneByName(playerBones, bone.name) == null;
|
||||
|
||||
if (!interesting && !isRootFallback) continue;
|
||||
|
||||
// The rest pose comes with it. Three models share this rig bone for bone, yet
|
||||
// only one of them wears its jaw wrongly - so the difference is in how that
|
||||
// jaw is posed or bound, not in where it is mapped. Printing the source
|
||||
// transform next to the player's own gives the exact correction to apply
|
||||
// rather than another guess at it.
|
||||
Transform playerEquivalent = FindBoneByName(playerBones, bone.name);
|
||||
|
||||
Jotunn.Logger.LogInfo(
|
||||
$"[Skeleton] '{bone.name}' -> '{(resolved != null ? resolved.name : "null")}'" +
|
||||
(isRootFallback ? " (ROOT FALLBACK)" : "") +
|
||||
(interesting ? " (skull part)" : ""));
|
||||
|
||||
if (!interesting) continue;
|
||||
|
||||
Jotunn.Logger.LogInfo(
|
||||
$"[Skeleton] source rest: pos={bone.localPosition:F4} " +
|
||||
$"rot={bone.localRotation.eulerAngles:F2} scale={bone.localScale:F3}");
|
||||
|
||||
if (playerEquivalent != null)
|
||||
{
|
||||
Jotunn.Logger.LogInfo(
|
||||
$"[Skeleton] player rest: pos={playerEquivalent.localPosition:F4} " +
|
||||
$"rot={playerEquivalent.localRotation.eulerAngles:F2} scale={playerEquivalent.localScale:F3}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static Transform FindBoneByName(Transform[] bones, string skelBoneName)
|
||||
{
|
||||
// Exact match first
|
||||
|
|
|
|||
|
|
@ -34,6 +34,34 @@ namespace RacesOfValheim
|
|||
public UnityEngine.Vector3 ScaleMultiplier;
|
||||
}
|
||||
|
||||
public const string BaseModel = "Skeleton";
|
||||
public const string PoisonModel = "Skeleton_Poison";
|
||||
|
||||
// The model worn from Moder on. It used to arrive at Fader; if that is preferred, move it
|
||||
// and its scale back to the state >= 8 block - nothing else in this file depends on where
|
||||
// they sit.
|
||||
public const string FireModel = "Skeleton_Hildir";
|
||||
|
||||
// Hildir's skeleton is built on the same rig as the plain one, so it needs no reshaping to
|
||||
// read as a player - unlike the charred twitcher this replaced, which is broader and
|
||||
// shorter and wore a 0.85/1.20/0.85 squeeze to compensate. Tied to the model, not a tier.
|
||||
public static readonly UnityEngine.Vector3 FireModelScale = UnityEngine.Vector3.one;
|
||||
|
||||
public const string SummonPrefabName = "Skeleton_friendly";
|
||||
|
||||
// Fader's dead stand taller than everyone else's. Applied to the player's root transform,
|
||||
// which is how this race has always sized itself - so it carries the collider, the camera
|
||||
// pivot and every equipment attachment up with it, rather than only the mesh.
|
||||
public static readonly UnityEngine.Vector3 FaderScale = UnityEngine.Vector3.one * 1.15f;
|
||||
|
||||
/// <summary>
|
||||
/// Every tier, exactly as the race's published progression describes it. The table had
|
||||
/// drifted a long way from that description - poison immunity arrived two tiers late,
|
||||
/// auto-stun four tiers late, and lifesteal jumped 20/30/40 instead of climbing in fives -
|
||||
/// which is what players were reporting as "progression doesn't work".
|
||||
///
|
||||
/// The blocks are cumulative: each one only states what its boss adds or replaces.
|
||||
/// </summary>
|
||||
public static SkeletonRules GetRules(int state)
|
||||
{
|
||||
SkeletonRules rules = new SkeletonRules
|
||||
|
|
@ -48,48 +76,51 @@ namespace RacesOfValheim
|
|||
SummonPrefab = "",
|
||||
AutoStunFirstHit = false,
|
||||
FireAura = false,
|
||||
ModelPrefab = "Skeleton",
|
||||
ModelPrefab = BaseModel,
|
||||
ScaleMultiplier = UnityEngine.Vector3.one
|
||||
};
|
||||
|
||||
if (state >= 2)
|
||||
{
|
||||
rules.ModelPrefab = "Skeleton_Poison";
|
||||
rules.LifestealPercent = 0.20f;
|
||||
}
|
||||
if (state >= 3)
|
||||
{
|
||||
rules.EnhancedRegen = true;
|
||||
}
|
||||
if (state >= 4)
|
||||
if (state >= 2) // Eikthyr
|
||||
{
|
||||
rules.ModelPrefab = PoisonModel;
|
||||
rules.PoisonImmunity = true;
|
||||
rules.LifestealPercent = 0.05f;
|
||||
}
|
||||
if (state >= 3) // The Elder
|
||||
{
|
||||
rules.LifestealPercent = 0.10f;
|
||||
rules.AutoStunFirstHit = true;
|
||||
}
|
||||
if (state >= 4) // Bonemass
|
||||
{
|
||||
rules.LifestealPercent = 0.15f;
|
||||
rules.PoisonAttacks = true;
|
||||
}
|
||||
if (state >= 5)
|
||||
if (state >= 5) // Moder
|
||||
{
|
||||
rules.LifestealPercent = 0.20f;
|
||||
rules.ModelPrefab = FireModel;
|
||||
rules.ScaleMultiplier = FireModelScale;
|
||||
rules.FireAura = true;
|
||||
rules.EnhancedRegen = true;
|
||||
}
|
||||
if (state >= 6) // Yagluth
|
||||
{
|
||||
rules.LifestealPercent = 0.25f;
|
||||
rules.AutoResurrect = true;
|
||||
}
|
||||
if (state >= 6)
|
||||
if (state >= 7) // The Queen
|
||||
{
|
||||
rules.ModelPrefab = "Skeleton_Poison";
|
||||
rules.LifestealPercent = 0.30f;
|
||||
rules.SummonOnKill = true;
|
||||
rules.MaxSummons = 2;
|
||||
rules.SummonPrefab = "Skeleton_friendly";
|
||||
rules.ScaleMultiplier = UnityEngine.Vector3.one * 1.1f;
|
||||
rules.MaxSummons = 3;
|
||||
rules.SummonPrefab = SummonPrefabName;
|
||||
}
|
||||
if (state >= 7)
|
||||
if (state >= 8) // Fader
|
||||
{
|
||||
rules.AutoStunFirstHit = true;
|
||||
rules.LifestealPercent = 0.40f;
|
||||
}
|
||||
if (state >= 8)
|
||||
{
|
||||
rules.ModelPrefab = "Charred_Twitcher";
|
||||
rules.SummonPrefab = "Charred_Twitcher";
|
||||
rules.FireAura = true;
|
||||
rules.ScaleMultiplier = new UnityEngine.Vector3(0.85f, 1.20f, 0.85f);
|
||||
rules.LifestealPercent = 0.35f;
|
||||
rules.MaxSummons = 5;
|
||||
rules.ScaleMultiplier = FaderScale;
|
||||
}
|
||||
|
||||
return rules;
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
using UnityEngine;
|
||||
using UnityEngine;
|
||||
using Jotunn.Managers;
|
||||
using Jotunn.Entities;
|
||||
using System.Collections.Generic;
|
||||
|
|
@ -49,8 +49,16 @@ namespace RacesOfValheim
|
|||
Player.m_localPlayer.m_customData["Race"] == "Skeleton";
|
||||
}
|
||||
|
||||
private static readonly int StatsEffectHash = "SE_SkeletonStats".GetStableHashCode();
|
||||
|
||||
private float lastAuraTime = 0f;
|
||||
private GameObject fireAuraVFX = null;
|
||||
|
||||
// The local player's burning skull. The build lives in SkeletonVisuals so that
|
||||
// RacesVisualController can grow the same one on every remote skeleton - this script only
|
||||
// ever sees the player at the keyboard, which is why nobody else could see the fire.
|
||||
private readonly SkeletonVisuals.HeadFlame headFlame = new SkeletonVisuals.HeadFlame();
|
||||
|
||||
private static List<ItemDrop.ItemData>[] cachedRealFoods = new List<ItemDrop.ItemData>[9];
|
||||
|
||||
private List<ItemDrop.ItemData> GetBestRealFoods(int state)
|
||||
|
|
@ -176,9 +184,16 @@ namespace RacesOfValheim
|
|||
|
||||
if (Player.m_localPlayer == null) return;
|
||||
|
||||
if (!IsSkeleton() || Player.m_localPlayer.IsDead())
|
||||
if (!IsSkeleton() || Player.m_localPlayer.IsDead())
|
||||
{
|
||||
// Everything the race puts on the player has to come off here, because this is the
|
||||
// only path taken once they stop being one. A Fader-tier Skeleton who reset to
|
||||
// Human kept a burning skull and a collapsed jaw, since neither the flame nor the
|
||||
// jaw was ever switched back from outside the Skeleton branch below.
|
||||
EnsureFireAuraVFX(false);
|
||||
headFlame.Apply(Player.m_localPlayer, false);
|
||||
RestoreJawBone();
|
||||
|
||||
if (Player.m_localPlayer.transform.localScale != Vector3.one)
|
||||
{
|
||||
Player.m_localPlayer.transform.localScale = Vector3.one;
|
||||
|
|
@ -210,6 +225,17 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// Undead Fortitude carries every one of the race's damage modifiers - the pierce and
|
||||
// slash resistance, the weakness to blunt, and the poison immunity. It was applied in
|
||||
// exactly one place: the moment the player clicked "Skeleton" in the race menu. Status
|
||||
// effects are not saved with a character and do not survive death, so from the next
|
||||
// respawn or the next login onward a Skeleton had none of them, which is why poison
|
||||
// still landed at tiers that grant immunity. Put it back whenever it is missing.
|
||||
if (!Player.m_localPlayer.GetSEMan().HaveStatusEffect(StatsEffectHash))
|
||||
{
|
||||
Player.m_localPlayer.GetSEMan().AddStatusEffect(StatsEffectHash, true);
|
||||
}
|
||||
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
var rules = SkeletonProgression.GetRules(state);
|
||||
|
||||
|
|
@ -242,25 +268,12 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// Hide Charred Twitcher Jaw
|
||||
if (currentVis != null && currentVis.m_bodyModel != null && currentVis.m_bodyModel.bones != null)
|
||||
{
|
||||
foreach (Transform bone in currentVis.m_bodyModel.bones)
|
||||
{
|
||||
if (bone != null && bone.name.ToLower().Contains("jaw"))
|
||||
{
|
||||
if (state >= 8)
|
||||
{
|
||||
if (bone.localScale != Vector3.zero) bone.localScale = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bone.localScale == Vector3.zero) bone.localScale = Vector3.one;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
// Fader used to collapse this bone, because the charred twitcher it wore there carried
|
||||
// a jaw of its own and the two doubled up. That model is gone from every tier now, and
|
||||
// the skeleton worn in its place has a jaw that belongs on the face - so the tier lost
|
||||
// its mandible for no reason at all. Kept as a restore so anyone left with a collapsed
|
||||
// jaw by the old build gets it back.
|
||||
RestoreJawBone();
|
||||
|
||||
// Apply Scale
|
||||
Vector3 targetScale = rules.ScaleMultiplier;
|
||||
|
|
@ -331,25 +344,19 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// Enhanced Health Regeneration
|
||||
// Enhanced Health Regeneration. The multiplier itself now lives on the status effect,
|
||||
// which sets it on the live instance - writing it here only ever reached the template
|
||||
// SEMan clones from, so it changed nothing for the player. What stays here is the tick
|
||||
// rate, which is the player's own field.
|
||||
if (rules.EnhancedRegen)
|
||||
{
|
||||
if (skeletonStatsSE != null)
|
||||
{
|
||||
skeletonStatsSE.m_healthRegenMultiplier = 1.5f;
|
||||
}
|
||||
|
||||
// Speed up regen ticks by 20% (1.25x faster timer accumulation)
|
||||
float currentTimer = HarmonyLib.Traverse.Create(Player.m_localPlayer).Field<float>("m_foodRegenTimer").Value;
|
||||
HarmonyLib.Traverse.Create(Player.m_localPlayer).Field("m_foodRegenTimer").SetValue(currentTimer + Time.deltaTime * 0.25f);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (skeletonStatsSE != null)
|
||||
{
|
||||
skeletonStatsSE.m_healthRegenMultiplier = 1.0f;
|
||||
}
|
||||
}
|
||||
|
||||
// Flames on the skull, worn with the fire-tier model and nothing else.
|
||||
headFlame.Apply(Player.m_localPlayer, rules.ModelPrefab == SkeletonProgression.FireModel);
|
||||
|
||||
if (rules.FireAura)
|
||||
{
|
||||
|
|
@ -366,6 +373,25 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts the player's jaw back if anything collapsed it. Safe to call every frame and for
|
||||
/// any race - it does nothing unless the bone is actually at zero scale.
|
||||
/// </summary>
|
||||
private static void RestoreJawBone()
|
||||
{
|
||||
VisEquipment vis = Player.m_localPlayer != null
|
||||
? Player.m_localPlayer.GetComponent<VisEquipment>()
|
||||
: null;
|
||||
if (vis == null || vis.m_bodyModel == null || vis.m_bodyModel.bones == null) return;
|
||||
|
||||
foreach (Transform bone in vis.m_bodyModel.bones)
|
||||
{
|
||||
if (bone == null || !bone.name.ToLower().Contains("jaw")) continue;
|
||||
if (bone.localScale == Vector3.zero) bone.localScale = Vector3.one;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void EnsureFireAuraVFX(bool enable)
|
||||
{
|
||||
if (enable && Player.m_localPlayer != null)
|
||||
|
|
|
|||
|
|
@ -5,29 +5,53 @@ namespace RacesOfValheim
|
|||
{
|
||||
public class SE_SkeletonStats : SE_Stats
|
||||
{
|
||||
// The tier the current m_mods were built for. -1 means "never built".
|
||||
private int m_appliedState = -1;
|
||||
|
||||
public override void Setup(Character character)
|
||||
{
|
||||
base.Setup(character);
|
||||
|
||||
// Apply Damage Modifiers
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
SkeletonProgression.SkeletonRules rules = SkeletonProgression.GetRules(state);
|
||||
|
||||
m_mods = new List<HitData.DamageModPair>();
|
||||
m_mods.Add(new HitData.DamageModPair { m_type = HitData.DamageType.Pierce, m_modifier = HitData.DamageModifier.Resistant });
|
||||
m_mods.Add(new HitData.DamageModPair { m_type = HitData.DamageType.Slash, m_modifier = HitData.DamageModifier.Resistant });
|
||||
m_mods.Add(new HitData.DamageModPair { m_type = HitData.DamageType.Blunt, m_modifier = HitData.DamageModifier.Weak });
|
||||
|
||||
if (rules.PoisonImmunity)
|
||||
{
|
||||
m_mods.Add(new HitData.DamageModPair { m_type = HitData.DamageType.Poison, m_modifier = HitData.DamageModifier.Immune });
|
||||
}
|
||||
RebuildForState();
|
||||
}
|
||||
|
||||
public override void UpdateStatusEffect(float dt)
|
||||
{
|
||||
base.UpdateStatusEffect(dt);
|
||||
// Health is handled in SkeletonPatches.Player_GetMaxHealth_Patch
|
||||
|
||||
// Setup runs once, when the effect is first applied - so the damage modifiers were
|
||||
// frozen at whatever tier the player happened to be on then, usually tier 1 because the
|
||||
// effect goes on at spawn before a boss is ever killed. Poison immunity therefore never
|
||||
// arrived: killing the boss changed the rules, and nothing ever asked them again.
|
||||
// Everything else the race does re-reads GetRules per hit, which is why only the
|
||||
// modifiers looked broken. Re-check here instead; the state comparison makes it free.
|
||||
RebuildForState();
|
||||
}
|
||||
|
||||
private void RebuildForState()
|
||||
{
|
||||
int state = BossProgressionManager.GetCurrentProgressionState();
|
||||
if (state == m_appliedState) return;
|
||||
m_appliedState = state;
|
||||
|
||||
SkeletonProgression.SkeletonRules rules = SkeletonProgression.GetRules(state);
|
||||
|
||||
// Set here, on the live effect, rather than by SkeletonRace on the registered
|
||||
// template: SEMan.AddStatusEffect clones what it is given and adds the clone, so
|
||||
// anything written to the template afterwards reaches nobody. That is why the Moder
|
||||
// regeneration bonus never applied either.
|
||||
m_healthRegenMultiplier = rules.EnhancedRegen ? 1.5f : 1.0f;
|
||||
|
||||
m_mods = new List<HitData.DamageModPair>
|
||||
{
|
||||
new HitData.DamageModPair { m_type = HitData.DamageType.Pierce, m_modifier = HitData.DamageModifier.Resistant },
|
||||
new HitData.DamageModPair { m_type = HitData.DamageType.Slash, m_modifier = HitData.DamageModifier.Resistant },
|
||||
new HitData.DamageModPair { m_type = HitData.DamageType.Blunt, m_modifier = HitData.DamageModifier.Weak }
|
||||
};
|
||||
|
||||
if (rules.PoisonImmunity)
|
||||
{
|
||||
m_mods.Add(new HitData.DamageModPair { m_type = HitData.DamageType.Poison, m_modifier = HitData.DamageModifier.Immune });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
150
JotunnModStub/Skeleton/SkeletonVisuals.cs
Normal file
150
JotunnModStub/Skeleton/SkeletonVisuals.cs
Normal file
|
|
@ -0,0 +1,150 @@
|
|||
using Jotunn.Managers;
|
||||
using UnityEngine;
|
||||
|
||||
namespace RacesOfValheim
|
||||
{
|
||||
/// <summary>
|
||||
/// The Skeleton's cosmetics that any client can grow for itself.
|
||||
///
|
||||
/// The head flame started life inside SkeletonRace, which is a single MonoBehaviour that only
|
||||
/// ever looks at Player.m_localPlayer - so the fire existed on one client, on one player, and
|
||||
/// everyone else saw a bare skull. Same shape of bug as the Draugh's aura, and the same fix:
|
||||
/// the build takes a Player, and each client grows a copy for every skeleton it can see.
|
||||
///
|
||||
/// Nothing here is networked and nothing needs to be. The tier is already on the ZDO, so every
|
||||
/// client can work out for itself whether a given skeleton should be alight.
|
||||
/// </summary>
|
||||
public static class SkeletonVisuals
|
||||
{
|
||||
// Fire sources in preference order. The torch is an item every world has; the ground
|
||||
// torch and the fire pit are the building pieces to fall back on.
|
||||
private static readonly string[] FlameSourcePrefabs =
|
||||
{
|
||||
"Torch", "piece_groundtorch_wood", "piece_groundtorch", "fire_pit"
|
||||
};
|
||||
|
||||
private static GameObject cachedFlameSource;
|
||||
private static bool flameSourceResolved;
|
||||
|
||||
/// <summary>
|
||||
/// Finds a vanilla prefab that carries real fire particles. Resolved once per session,
|
||||
/// failure included, so a miss cannot turn into a per-frame log.
|
||||
/// </summary>
|
||||
private static GameObject ResolveFlameSource()
|
||||
{
|
||||
if (flameSourceResolved) return cachedFlameSource;
|
||||
flameSourceResolved = true;
|
||||
|
||||
foreach (string name in FlameSourcePrefabs)
|
||||
{
|
||||
GameObject prefab = PrefabManager.Cache.GetPrefab<GameObject>(name);
|
||||
if (prefab == null) continue;
|
||||
if (prefab.GetComponentsInChildren<ParticleSystem>(true).Length == 0) continue;
|
||||
|
||||
Jotunn.Logger.LogInfo($"[Skeleton] Head flame source resolved to '{name}'.");
|
||||
cachedFlameSource = prefab;
|
||||
return cachedFlameSource;
|
||||
}
|
||||
|
||||
Jotunn.Logger.LogWarning(
|
||||
"[Skeleton] No fire prefab resolved (" + string.Join(", ", FlameSourcePrefabs) +
|
||||
"); the skull stays unlit.");
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// One player's burning skull. Cosmetic only - it deals nothing and blocks nothing.
|
||||
///
|
||||
/// Held per player rather than statically: a static would hand the second skeleton in view
|
||||
/// the first one's fire. Call Apply every frame; it builds once and then only follows.
|
||||
/// </summary>
|
||||
public class HeadFlame
|
||||
{
|
||||
// Above the head bone's own origin, which sits at the base of the skull.
|
||||
private const float Height = 0.18f;
|
||||
|
||||
// Torch flames are authored for a fist-sized fire on a stick, so the skull wears a big
|
||||
// multiple of one.
|
||||
private const float Scale = 1.8f;
|
||||
|
||||
private GameObject m_instance;
|
||||
private Transform m_headBone;
|
||||
|
||||
public void Apply(Player player, bool enable)
|
||||
{
|
||||
if (!enable)
|
||||
{
|
||||
if (m_instance != null && m_instance.activeSelf) m_instance.SetActive(false);
|
||||
return;
|
||||
}
|
||||
|
||||
if (player == null) return;
|
||||
|
||||
if (m_instance == null && !Build(player)) return;
|
||||
|
||||
if (!m_instance.activeSelf) m_instance.SetActive(true);
|
||||
|
||||
// Follows the skull without inheriting its scale.
|
||||
if (m_headBone != null)
|
||||
{
|
||||
m_instance.transform.position = m_headBone.position + Vector3.up * Height;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>Returns false while the pieces it needs are not ready yet.</summary>
|
||||
private bool Build(Player player)
|
||||
{
|
||||
Animator anim = player.GetComponentInChildren<Animator>();
|
||||
m_headBone = anim != null ? anim.GetBoneTransform(HumanBodyBones.Head) : null;
|
||||
if (m_headBone == null) return false; // rig not up yet; try again next frame
|
||||
|
||||
GameObject source = ResolveFlameSource();
|
||||
if (source == null) return false; // already logged once by the resolver
|
||||
|
||||
// Deliberately not parented to the head bone: the player rig is authored at
|
||||
// roughly 100x, and a particle system inheriting that would put a bonfire where a
|
||||
// candle belongs. It hangs off the player and is moved onto the bone each frame.
|
||||
m_instance = new GameObject("SkeletonHeadFlameVFX");
|
||||
m_instance.transform.SetParent(player.transform, false);
|
||||
m_instance.transform.localScale = Vector3.one * Scale;
|
||||
|
||||
// Real fire is cloned rather than built by hand. The first attempt at this made a
|
||||
// particle system from scratch on the smoke material, and a hand-rolled gradient
|
||||
// over a smoke sprite reads as a wisp, not a burning skull.
|
||||
foreach (ParticleSystem ps in source.GetComponentsInChildren<ParticleSystem>(true))
|
||||
{
|
||||
GameObject copy = Object.Instantiate(ps.gameObject, m_instance.transform);
|
||||
copy.name = ps.gameObject.name;
|
||||
copy.transform.localPosition = Vector3.zero;
|
||||
copy.transform.localRotation = Quaternion.identity;
|
||||
copy.SetActive(true);
|
||||
|
||||
// So the holder's scale actually enlarges the fire rather than just spreading
|
||||
// out where the particles spawn.
|
||||
ParticleSystem.MainModule main = copy.GetComponent<ParticleSystem>().main;
|
||||
main.scalingMode = ParticleSystemScalingMode.Hierarchy;
|
||||
}
|
||||
|
||||
// A torch's own light is tuned to light a corridor from waist height; on a head it
|
||||
// blows out the whole face. Keep the glow, lose the floodlight.
|
||||
foreach (Light light in m_instance.GetComponentsInChildren<Light>(true))
|
||||
{
|
||||
light.range *= 0.5f;
|
||||
light.intensity *= 0.6f;
|
||||
}
|
||||
|
||||
// Anything that made the source a torch rather than a fire.
|
||||
foreach (MonoBehaviour comp in m_instance.GetComponentsInChildren<MonoBehaviour>(true))
|
||||
{
|
||||
Object.Destroy(comp);
|
||||
}
|
||||
foreach (Collider col in m_instance.GetComponentsInChildren<Collider>(true))
|
||||
{
|
||||
Object.Destroy(col);
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -40,6 +40,7 @@ namespace RacesOfValheim
|
|||
private GameObject m_currentFormInstance = null;
|
||||
private GameObject m_fireAuraVFX = null;
|
||||
private GameObject m_draughAuraVFX = null;
|
||||
private readonly SkeletonVisuals.HeadFlame m_skeletonHeadFlame = new SkeletonVisuals.HeadFlame();
|
||||
private float m_lastFlightLog = 0f;
|
||||
|
||||
private void Awake()
|
||||
|
|
@ -148,27 +149,25 @@ namespace RacesOfValheim
|
|||
}
|
||||
}
|
||||
|
||||
// Hide Jaw for Charred Twitcher
|
||||
// Fader used to collapse this bone here too, for the charred twitcher it wore at
|
||||
// that tier. That model is gone and the skeleton in its place has a jaw of its
|
||||
// own, so this is only a restore now - the same as the local path. Without it,
|
||||
// other players would still see a Fader with no mandible.
|
||||
if (vis.m_bodyModel != null && vis.m_bodyModel.bones != null)
|
||||
{
|
||||
foreach (Transform bone in vis.m_bodyModel.bones)
|
||||
{
|
||||
if (bone != null && bone.name.ToLower().Contains("jaw"))
|
||||
{
|
||||
if (state >= 8)
|
||||
{
|
||||
if (bone.localScale != Vector3.zero) bone.localScale = Vector3.zero;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (bone.localScale == Vector3.zero) bone.localScale = Vector3.one;
|
||||
}
|
||||
break;
|
||||
}
|
||||
if (bone == null || !bone.name.ToLower().Contains("jaw")) continue;
|
||||
if (bone.localScale == Vector3.zero) bone.localScale = Vector3.one;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The burning skull, grown locally for whoever we are looking at. The tier is on the
|
||||
// ZDO, so this client can work out for itself whether they should be alight.
|
||||
m_skeletonHeadFlame.Apply(m_player, rules.ModelPrefab == SkeletonProgression.FireModel);
|
||||
|
||||
// Apply Scale
|
||||
Vector3 targetScale = rules.ScaleMultiplier;
|
||||
if (m_player.transform.localScale != targetScale)
|
||||
|
|
@ -269,6 +268,7 @@ namespace RacesOfValheim
|
|||
if (m_currentFormInstance != null) Destroy(m_currentFormInstance);
|
||||
EnsureFireAuraVFX(false);
|
||||
DraughVisuals.EnsureAura(m_player, false, ref m_draughAuraVFX);
|
||||
m_skeletonHeadFlame.Apply(m_player, false);
|
||||
// Takes the crown off a Trenta who has died or changed race; a no-op for everyone else.
|
||||
TrentaVisuals.ApplyCrown(m_player);
|
||||
|
||||
|
|
|
|||
14
README.md
14
README.md
|
|
@ -181,6 +181,20 @@ Please write to us on my Discord server: **https://discord.gg/gbBEK2VTE**
|
|||
|
||||
## Changelog
|
||||
|
||||
**v1.3.12**
|
||||
- **Skadi**: Dragon flight reworked. The stasis that holds a form level after you stop powering now lasts 5 seconds instead of 2. Hold Shift with W to spend 15 stamina a second on a burst of speed - the only part of flight that costs anything, since the drake arrives at The Elder long before you could pay just to stay airborne, and running dry drops you back to normal speed rather than out of the sky. S beats backwards along your aim, pitch included: look down and press it to rise away from whatever you are watching, without turning to face away from it.
|
||||
- **Skadi**: Water is no longer a trap. A flying form beats its way back out of the sea instead of paddling on the surface until it finds land. Valheim hands a swimming character to its swimming code before it ever asks whether they are flying, which is why the Aswid's bat could always take off from water and Moder never could.
|
||||
- **Fenrir**: The human body no longer stands inside the wolf. Every form hid you by shrinking your body to nothing, and the reset that keeps a non-Trol player at normal size put it straight back a frame later. Wolf, Ulv, Fenring and Cultist are all fixed, and so is the copy other players see.
|
||||
- **Trenta**: A crown of horns and dead branches now grows from your head - a greydwarf shaman's, sunk into the skull until only the branches clear it.
|
||||
- **Draugh**: The rot is visible to everyone. The drifting smoke and the cloud of flies only ever existed on your own screen, so in multiplayer every other player saw an ordinary, unrotted Viking.
|
||||
- **Skeleton**: The progression finally does what its description says. Poison immunity arrived at Bonemass instead of Eikthyr, auto-stun at The Queen instead of The Elder, and lifesteal jumped 20/30/40% where the list promises a climb in fives from 5% to 35%. Every tier now matches, boss for boss.
|
||||
- **Skeleton**: Poison immunity - and the physical resistances alongside it - never survived a death or a login. Undead Fortitude was applied once, the moment you picked the race from the menu, and status effects are not saved with a character, so from your next respawn onward you had none of it. It is kept on you now, and a boss killed mid-session takes effect immediately instead of waiting for a respawn.
|
||||
- **Skeleton**: Max health is exactly what the tier promises. A Skeleton cannot eat, so the race feeds you three permanent invisible meals to carry the bonus - good for keeping regeneration alive, bad for landing an exact number, and a Bonemass Skeleton could find itself at 95 health where the table promises 165. The meals stay; the total no longer depends on them.
|
||||
- **Skeleton**: The Moder regeneration bonus now applies at all.
|
||||
- **Skeleton**: Skeleton Secrets unfolds tier by tier with the real numbers, instead of the same "will be revealed soon" line at every standing. It opens by naming the standing you are on, so when a boss falls and nothing seems to change you can tell at a glance whether the tier failed to advance or the unlock failed to fire.
|
||||
- **Skeleton**: From Moder on you wear Hildir's bones with your skull alight, and the flames are visible to other players. At Fader you stand 15% taller.
|
||||
- **Skeleton**: Fader no longer loses its lower jaw, and returning to Human no longer leaves you with a burning skull and an invisible one.
|
||||
|
||||
**v1.3.11**
|
||||
- **NEW RACE - Trenta**: Added the ninth playable race, the Trenta. Tree-born folk, kin to root and leaf: green-skinned, fed on what grows, and digesting it twice as slowly as anyone else. Stand still in daylight and you put down roots, healing and standing up Rested. The forest does not see you as prey - greylings, greydwarves, fulings, trolls, leeches and deathsquitos leave you alone from the very first tier. Later comes healing pollen that poisons whatever fights you, a portal home that ignores the ore restriction, a nest of hornets that stings anything that comes near, and finally The Elder's own shape. Full progression across all 8 tiers - see Trenta Progression above.
|
||||
- **Dvergur is now the Dvergar**: The race has been renamed. Characters created as a Dvergur are migrated automatically on your next spawn - you keep your race, your tier and your progress, and nothing needs re-picking.
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
{
|
||||
"name": "RacesOfValheim",
|
||||
"description": "A Valheim mod that adds nine custom playable races (Aswid, Draugh, Dvergar, Fenrir, Furling, Skadi, Skeleton, Trenta, Trol) each with unique abilities, traits, and a deep boss-driven progression system.",
|
||||
"version_number": "1.3.11",
|
||||
"version_number": "1.3.12",
|
||||
"website_url": "",
|
||||
"dependencies": [
|
||||
"denikson-BepInExPack_Valheim-5.4.2333",
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue