Valheim
Install with App

Details

Latest version
1.2.0
Last Updated
First Uploaded
Downloads
37
Likes
0
Size
85KB
Dependants
ADDatHost Valheim hosting
30% off

KeepFoodOnDeath

Die without losing your meal. When you die, this mod keeps the food you had eaten and the effects that came with it, then brings you back at full health.

Status: this mod has not been compiled or tested in-game yet. Build it, test a death on a throwaway character first, and report any problems.

Features

  • Keeps your eaten food after death, with its remaining time.
  • Keeps status effects you had when you died (food effects, Rested, etc.), with their remaining time.
  • Excludes potions and meads by default. They are lost on death as in vanilla.
  • Full health on revival, calculated after the food bonus is applied.
  • Optional time penalty so death still costs something.
  • Server-controlled settings. All options are admin-only and synced from the server.

What is not changed

  • Tombstone, dropped items and skill loss work as in vanilla.
  • The soft-death debuff is not restored (it is in the default exclusion list).
  • Effects with no duration, such as gear and set bonuses, are never restored. Your gear is on your tombstone, so they would be wrong.
  • Harmful and environmental effects (Burning, Poison, Frost, Wet, Cold, etc.) are not restored by default.

Installation

Install on the server and on every player's game:

  1. BepInExPack Valheim
  2. Jotunn
  3. KeepFoodOnDeath.dll into BepInEx/plugins/

Players without the mod, or with a different version, are refused at login. This is intentional, so everyone follows the same rules.

Why the client needs it too

Valheim does not run a player's food and status effects on the server. They live in each player's own game, and death is handled there. The saving and restoring therefore has to run on each client. The server's job is to supply the config and enforce matching versions.

Configuration

Run the server once to generate BepInEx/config/com.example.keepfoodondeath.cfg. Edit it on the server and restart. Clients receive the server's values.

Setting Default Description
Enabled true Master switch.
KeepFoodEffects true Restore the effect attached to each food you had eaten.
KeepAllStatusEffects true Restore all timed status effects you had, except those excluded below.
ExcludePotionsAndMeads true Never restore effects from potions and meads. Detected from the game's item database, so modded meads are covered.
ExcludedEffects see file Comma-separated effect names that are never restored.
HealToFullHealth true Set health to full on revival, including the food bonus.
RemainingTimePenaltyPercent 0 Percent of remaining food and effect time lost on death. 50 loses half.
ShowMessage true Show a message when you are restored.

How it works

  1. On death, just before the game clears your food, the mod records your eaten food and your timed status effects with their remaining time. The time penalty is applied here.
  2. On respawn, once your new character exists, it puts the food back, re-applies the effects with the remaining time, recalculates max health, stamina and eitr, and sets health to full.
  3. The saved data is held in memory only. It is discarded if you switch characters or do not respawn within 15 minutes. Logging out or crashing while dead loses the food.

Building from source

Requires the .NET SDK, plus Valheim with BepInEx and Jotunn installed.

  1. Set the VALHEIM_INSTALL environment variable to your Valheim folder.
  2. If Jotunn is in a subfolder of BepInEx/plugins, update its path in KeepFoodOnDeath.csproj.
  3. Run dotnet build -c Release.
  4. Copy bin/Release/net48/KeepFoodOnDeath.dll into BepInEx/plugins/ on the server and clients.

Known limitations

  • Written against Valheim's internals from memory, so a game update may break it.
  • The server cannot verify that a client really restored the food. It only controls the settings.
  • Food effects are only restored when the game links them to a food item or they are timed effects. Foods with no extra effect simply come back as food.

Changelog

  • 1.2.0 Potions and meads are excluded from restoration. New ExcludePotionsAndMeads option.
  • 1.1.0 Restores all timed status effects. Full health on revival. New KeepAllStatusEffects, ExcludedEffects and HealToFullHealth options.
  • 1.0.0 Initial version: keeps eaten food and food effects after death.
Thunderstore development is made possible with ads. Please consider making an exception to your adblock.