feat(skeleton): per-player options to eat real food and spend stamina

Two options in "Skeleton - Mortal Habits", both off and not synced by
the server, since each only gives up an advantage.

Eats Mortal Food: the Skeleton eats like the living. The max health
override and the fake foods step aside, so meals decide health and
stamina and the tier's health bonus, which stood in for food, no longer
applies. The food HUD shows again.

Feels Fatigue: the Skeleton spends stamina. Without eating, its max
stamina is base plus the stamina of the tier's stand-in meals, because
the fake foods sit at m_time 0 and give none.

The compendium builds its diet line from four new keys (English,
Italian, Russian) when either option is on.
This commit is contained in:
kanym 2026-11-02 23:31:58 +01:00
commit 9ed606a9aa
9 changed files with 86 additions and 13 deletions

View file

@ -49,6 +49,10 @@ namespace RacesOfValheim
public static ConfigEntry<bool> RaiseDeadIcon;
public static ConfigEntry<bool> ShowHelmet;
// ─── Mortal Habits (per player) ────────────────────────────────────────
public static ConfigEntry<bool> EatsMortalFood;
public static ConfigEntry<bool> FeelsFatigue;
public static void Bind(ConfigFile config)
{
const string combat = "Skeleton - Passive Combat";
@ -88,6 +92,16 @@ namespace RacesOfValheim
RaiseDeadIcon = config.Bind(visuals, "Raise the Dead Icon", true,
new ConfigDescription("Shows the Raise the Dead status icon while your Summon on Kill is on."));
ShowHelmet = config.Bind(visuals, "Show Helmet", false,
new ConfigDescription("Off: your helmet stays hidden over the skull. On: the helmet you wear shows. Helmets and hoods are moved and enlarged to fit the skull. Your own choice: other players see you the way you picked. A viking body (Body Model Enabled off) always shows its helmet.")); }
new ConfigDescription("Off: your helmet stays hidden over the skull. On: the helmet you wear shows. Helmets and hoods are moved and enlarged to fit the skull. Your own choice: other players see you the way you picked. A viking body (Body Model Enabled off) always shows its helmet."));
// For groups who want the Skeleton but miss Valheim's food or stamina. Both only take
// away an advantage (permanent best-tier food, infinite stamina), so each player picks
// for themselves and the server does not sync them.
const string habits = "Skeleton - Mortal Habits";
EatsMortalFood = config.Bind(habits, "Eats Mortal Food", false,
new ConfigDescription("Off: you never eat, and your Maximum Health comes from your standing (the bosses you have defeated). On: you eat like the living, your health and stamina come from your meals, and the standing's health bonus is gone. Your other Skeleton powers stay. Your own choice, not synced by the server."));
FeelsFatigue = config.Bind(habits, "Feels Fatigue", false,
new ConfigDescription("Off: you have no stamina and never tire. On: you spend stamina like the living. Without Eats Mortal Food your stamina grows with your standing, from the same meals your health is measured by. Your own choice, not synced by the server."));
}
}
}

View file

@ -44,16 +44,26 @@ namespace RacesOfValheim
/// 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.
///
/// A Skeleton with "Eats Mortal Food" is left to vanilla: its real meals decide both
/// numbers, and the tier's health, which stands in for those meals, does not stack on top.
/// One with "Feels Fatigue" who does not eat gets the stand-in meals' stamina, which the
/// fake foods themselves never deliver.
/// </summary>
[HarmonyPatch(typeof(Player), "GetTotalFoodValue")]
public static class Player_GetTotalFoodValue_SkeletonHealth_Patch
{
public static void Postfix(Player __instance, ref float hp)
public static void Postfix(Player __instance, ref float hp, ref float stamina)
{
if (__instance != Player.m_localPlayer || !SkeletonRace.IsSkeleton()) return;
if (SkeletonConfig.EatsMortalFood.Value) return;
int state = BossProgressionManager.GetCurrentProgressionState();
hp = __instance.m_baseHP + SkeletonProgression.GetMaxHealthBonus(state);
if (SkeletonConfig.FeelsFatigue.Value)
{
stamina = __instance.m_baseStamina + SkeletonRace.GetStandInStamina(state);
}
}
}
@ -63,7 +73,7 @@ namespace RacesOfValheim
public static bool Prefix(Player __instance)
{
// The Aswid used to be on this list. It spends stamina now, see Aswid_UseStamina_Patch.
if ((SkeletonRace.IsSkeleton() || DraughRace.IsDraugh()) && __instance == Player.m_localPlayer)
if (((SkeletonRace.IsSkeleton() && !SkeletonConfig.FeelsFatigue.Value) || DraughRace.IsDraugh()) && __instance == Player.m_localPlayer)
{
// Infinite stamina: skip the original UseStamina method
return false;
@ -79,7 +89,7 @@ namespace RacesOfValheim
{
if (__instance == Player.m_localPlayer)
{
if (SkeletonRace.IsSkeleton() && item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Consumable && (item.m_shared.m_food > 0 || item.m_shared.m_foodStamina > 0 || item.m_shared.m_foodEitr > 0))
if (SkeletonRace.IsSkeleton() && !SkeletonConfig.EatsMortalFood.Value && item.m_shared.m_itemType == ItemDrop.ItemData.ItemType.Consumable && (item.m_shared.m_food > 0 || item.m_shared.m_foodStamina > 0 || item.m_shared.m_foodEitr > 0))
{
__instance.Message(MessageHud.MessageType.Center, ModText.Get("rov_msg_skeleton_skeletons_do_not_need_eat"));
__result = false;
@ -194,7 +204,7 @@ namespace RacesOfValheim
{
try
{
if (player == Player.m_localPlayer && SkeletonRace.IsSkeleton())
if (player == Player.m_localPlayer && SkeletonRace.IsSkeleton() && !SkeletonConfig.EatsMortalFood.Value)
{
if (__instance.m_foodBarRoot != null && __instance.m_foodBarRoot.gameObject.activeSelf)
{
@ -233,7 +243,7 @@ namespace RacesOfValheim
}
catch (System.Exception e)
{
if (player == Player.m_localPlayer && SkeletonRace.IsSkeleton()) return false;
if (player == Player.m_localPlayer && SkeletonRace.IsSkeleton() && !SkeletonConfig.EatsMortalFood.Value) return false;
return true;
}
}

View file

@ -125,6 +125,22 @@ namespace RacesOfValheim
Player.m_localPlayer.m_customData["Race"] == "Skeleton";
}
/// <summary>
/// Stamina from the tier's stand-in meals, for a Skeleton who feels fatigue but does not
/// eat. The fake foods cannot supply it: they are kept at m_time 0, so UpdateFood scales
/// their stamina to nothing on every tick.
/// </summary>
public static float GetStandInStamina(int state)
{
var foods = GetBestRealFoods(state);
float stamina = 0f;
if (foods != null)
{
foreach (var f in foods) stamina += f.m_shared.m_foodStamina;
}
return stamina;
}
private static readonly int StatsEffectHash = "SE_SkeletonStats".GetStableHashCode();
private float lastAuraTime = 0f;
@ -137,7 +153,7 @@ namespace RacesOfValheim
private static List<ItemDrop.ItemData>[] cachedRealFoods = new List<ItemDrop.ItemData>[9];
private List<ItemDrop.ItemData> GetBestRealFoods(int state)
private static List<ItemDrop.ItemData> GetBestRealFoods(int state)
{
if (state < 1) state = 1;
if (state > 8) state = 8;
@ -453,8 +469,15 @@ namespace RacesOfValheim
// Manage Fake Foods
var foods = Player.m_localPlayer.GetFoods();
bool needsFood = false;
if (foods.Count != 3)
if (SkeletonConfig.EatsMortalFood.Value)
{
// Real meals instead. The stand-in foods are the ones held at m_time 0 or below;
// dropped here at once rather than left for UpdateFood, which would announce each
// one as "food done".
foods.RemoveAll(f => f.m_time <= 0f);
}
else if (foods.Count != 3)
{
needsFood = true;
}