Valheim
You are viewing a potentially older version of this package. View Latest Version
Install with App

Details

Date Uploaded
2 weeks ago
Downloads
956
Size
1MB
ADDatHost Valheim hosting
€1

GhostWalk

A Valheim mod that recreates WoW's "release spirit -> get back to your body" loop on top of Valheim's existing death/tombstone system, with a "spirit healer"-style shortcut for when you don't want to make the trip.

What it does

  1. You die. Vanilla Valheim handles the tombstone/item drop and respawns you at your bed/spawn point as normal — this mod doesn't touch that part.
  2. The instant you respawn, GhostWalk puts you into spirit form:
    • Health dropped to 1 — real stakes to getting back
    • Move speed multiplied (default 2.25x) — the "ghost run"
    • Invulnerable, and attacks/blocking disabled
    • Ignored entirely by enemies — nothing targets, chases, or attacks you; anything already aggro'd on you gets its target cleared
    • A translucent blue trail + point light on your character
    • A minimap pin on your tombstone's location
    • A Spirit of Resurrection appears next to you (see below)
  3. Revive however you like:
    • Walk back and loot your tombstone — opening it revives you immediately, no penalty, same as vanilla's corpse run (toggle ReviveRequiresEmptyTombstone if you'd rather it only trigger once the tombstone is fully emptied).
    • Or talk to the Spirit of Resurrection — force-revives you on the spot, but costs 2% off every skill, durability damage to everything currently equipped, and a 15-minute Resurrection Sickness debuff (all configurable):
      • Stamina regeneration reduced by 50% for the duration
      • Any food you eat while sick has its buff duration halved
      • Both effects end automatically when the debuff's timer runs out — stamina regen and food buff durations return to normal with no further action needed
    • Or, if the tombstone won't cooperate: alt-interact on it to be teleported straight back to the Spirit of Resurrection (see "The stuck-ghost failsafe" below).

Either path restores HP/stamina to a configurable fraction of max, clears the ghost visuals/pin, and despawns the Spirit.

If you died within SkipGhostModeRadius meters of your bed, the whole ceremony is skipped — your tombstone's basically in your lap already.

The Spirit of Resurrection

Rather than building a brand-new networked creature from scratch, the Spirit is a local-only clone of the existing Haldor NPC: same humanoid model, tinted with the ghost color, with its trading/AI/combat components stripped and replaced with a single custom interaction. It spawns a few meters from you the moment you go into spirit form and disappears the moment you revive by any method.

Because it's spawned client-side (not registered with ZNetView/ZDOMan), it's simple and safe, but it's also only visible to the player who died — it isn't a shared world object other players can see or use. That's a deliberate simplification; see "Extending it" below if you want a networked, shared version instead.

The stuck-ghost failsafe

Ghost form is invulnerable and can't fight, so if the tombstone revive ever stops firing — say Iron Gate renames TombStone.m_playerID in an update and the ownership check can no longer identify your own grave — you'd be left drifting around immortal with no way back into your body. That's the one genuinely unrecoverable failure mode in the whole design, so it gets its own escape hatch.

While ghosted, a secondary interact on any grave teleports you back to wherever the Spirit of Resurrection is standing instead of opening it. From there you can take the Spirit's force-revive and get on with your life (paying the usual skill/durability/sickness cost). The grave's hover text advertises the option while you're a ghost, and says so more loudly when ownership couldn't be verified — which is exactly when you're likely to need it.

Deliberate design choices here:

  • It doesn't depend on the ownership check. Any grave works. The check being broken is the scenario this exists for, so gating it on that check would defeat the point.
  • It's permissive by default. AllowTeleportWithRestrictedItems defaults to true, so it won't refuse because you're carrying ore. Set it to false if you'd rather not hand players an ore-portal on a shared server — the trade is that it can then refuse at the worst moment.
  • It's patched in two places, defensively. Depending on game version, a grave's interact may arrive via TombStone.Interact or be forwarded to Container.Interact. Both are hooked; a 1-second cooldown means a single keypress arriving twice only teleports once. The TombStone hooks are registered manually (not via [HarmonyPatch]) so that if those methods don't exist on your version, Harmony logs a warning rather than aborting PatchAll and disabling the entire mod — a failsafe that takes the mod down with it when the game changes isn't a failsafe.
  • The destination survives the Spirit. The respawn point is stored as a plain coordinate as well as an object reference, so even if the NPC clone was never spawned (prefab lookup failed, or you disabled it in config), the teleport still puts you back where you woke up. If the Spirit is simply missing, it's re-spawned on arrival.

If AltInteract isn't reaching the mod on your setup, set TombstoneTeleportTrigger to HoldInteract or Both.

Project layout

GhostWalk/
  GhostWalk/
    GhostWalk.csproj                  - build file (net472, BepInEx+HarmonyX via NuGet)
    Plugin.cs                         - BepInEx entry point + all config options
    GhostWalkController.cs            - ghost state machine (health, visuals, revive, penalties)
    SpiritOfResurrectionInteract.cs   - Interactable/Hoverable component on the Spirit NPC
    Patches.cs                         - Harmony patches wiring everything into the game
    TombstoneUtil.cs                   - shared grave logic: ownership check, teleport failsafe, hover text
    manifest.json                      - Thunderstore-style package manifest (optional)

Building

This project does not use NuGet for anything. Every reference is a DLL that already exists on disk once you have Valheim + BepInEx installed, so there's no restore step, no internet requirement, and nothing that can fail with an NU1101/proxy/VPN error.

dotnet build -c Release ^
  /p:ValheimPath="F:\SteamLibrary\steamapps\common\Valheim" ^
  /p:BepInExPath="C:\Users\Jason\AppData\Roaming\Thunderstore Mod Manager\DataFolder\Valheim\profiles\CranFlakes Valheim\BepInEx"
  • ValheimPath — your actual Steam install (for assembly_valheim.dll, UnityEngine.dll, etc. under valheim_Data\Managed\).
  • BepInExPath — the BepInEx folder that contains a core subfolder with BepInEx.dll and 0Harmony.dll. For a plain install this is <ValheimPath>\BepInEx and you can usually omit this flag entirely. For r2modman/Thunderstore Mod Manager, it's that tool's profile folder (e.g. ...\profiles\<your profile name>\BepInEx), not the Steam install — pass it explicitly as shown above.

If either DLL is missing from BepInExPath\core\, BepInEx itself isn't actually installed there — reinstall the BepInExPack for that profile first.

This produces GhostWalk.dll in bin/Release/net472/.

Installing

  1. Install BepInEx for Valheim (the "BepInExPack Valheim" on Thunderstore is the easiest route, or via r2modman/Thunderstore Mod Manager).
  2. Drop GhostWalk.dll into BepInEx/plugins/GhostWalk/.
  3. Launch the game — BepInEx/config/cranflakes.ghostwalk.cfg is created on first load.

Config (BepInEx/config/cranflakes.ghostwalk.cfg)

Section Setting Default Description
General Enabled true Master on/off switch
Ghost SpeedMultiplier 2.25 Ghost move speed multiplier
Ghost SkipGhostModeRadius 3 Distance (m) from bed that skips the whole sequence
Ghost ReviveHealthFraction 0.5 Fraction of max HP restored on revive
Ghost ReviveStaminaFraction 0.5 Fraction of max stamina restored on revive
Ghost Invulnerable true No damage while a ghost
Ghost BlockAttacks true No attacking/blocking while a ghost
Ghost PreventEnemyTargeting true Enemies never target/pursue/attack you while ghosted; clears any existing aggro too
Ghost ShowCorpsePin true Minimap pin on your tombstone
Visuals EnableGhostVisual true Spirit trail + tinted light
Visuals GhostTintColor (0.35, 0.65, 1, 1) Color for the ghost effects and the Spirit NPC tint
Revive ReviveRequiresEmptyTombstone false false: revive on opening the tombstone. true: revive only once it's fully looted
Revive TombstoneTeleportEnabled true Alt-interact on a grave while ghosted teleports you back to the Spirit
Revive TombstoneTeleportTrigger AltInteract AltInteract, HoldInteract, or Both
Revive AllowTeleportWithRestrictedItems true true: teleport works regardless of what you carry. false: respects the usual ore/portal restriction
SpiritOfResurrection Enabled true Spawn the Spirit near you on death
SpiritOfResurrection SkillLossPercent 2 % knocked off every skill on a Spirit-assisted revive
SpiritOfResurrection DurabilityLossPercent 10 % of max durability knocked off equipped gear on a Spirit-assisted revive
SpiritOfResurrection SicknessDurationMinutes 15 How long Resurrection Sickness lasts after a Spirit-assisted revive
SpiritOfResurrection SicknessStaminaRegenReductionPercent 50 Stamina regen reduction while sick
SpiritOfResurrection SicknessFoodDurationReductionPercent 50 How much shorter newly-eaten food buffs are while sick

A note on Valheim's API

Valheim ships no official modding SDK. The method/field names this mod hooks — Player.OnDeath, Player.OnRespawn, Player.GetJogSpeedFactor, Player.GetRunSpeedFactor, Character.Damage, Humanoid.StartAttack, Container.Interact, Container.OnClose, TombStone.Interact, TombStone.GetHoverText, TombStone.m_playerID, Player.TeleportTo, Player.IsTeleportable, Humanoid.GetEquipedItems() (yes, misspelled in the base game), Skills.RaiseSkill, BaseAI.IsValidTarget, BaseAI.m_targetCreature, BaseAI.m_alerted, SE_Stats.m_staminaRegenMultiplier, Player.EatFood, Player.m_foods / Player.Food.m_time — match the public API as referenced across the modding community for several game versions, but Iron Gate does occasionally rename things in big content updates.

Resurrection Sickness specifically is built from two independent pieces with very different confidence levels:

  • The stamina regen penalty rides on SE_Stats, a real, well-documented Valheim status effect class used for exactly this kind of stat modifier (the same base class behind effects like Rested). This should be reliable.
  • The food duration penalty assumes Player keeps a private list (m_foods) of entries with a m_time field that counts down to zero. This is the single most speculative piece in the whole mod. It fails quietly (a one-time console warning, no crash) if either assumption is wrong for your game version — the stamina penalty keeps working regardless. If it doesn't seem to be shortening food buffs in-game, this is the first place to check with dnSpy/ILSpy.

If the mod fails to build, or a patch silently doesn't fire, after a game update:

  1. Open assembly_valheim.dll (in valheim_Data/Managed/) in dnSpy or ILSpy.
  2. Search for the method/field names above and confirm the signature still matches.
  3. Update the [HarmonyPatch(...)] attribute (or the Traverse.Create(...) field name in Patches.cs) accordingly — GhostWalkController.cs and Plugin.cs shouldn't need any changes for a rename alone.

One patch failing no longer takes the other patches with it. Early builds called _harmony.PatchAll() once - if a single [HarmonyPatch] target couldn't be found (this happened for real: BaseAI.IsValidTarget doesn't exist by that name on some game versions), the exception aborted the entire call, and with it every other patch, all config bindings, and the "loaded" log line - the mod silently vanished from the console and Configuration Manager with no other symptom. Plugin.cs's PatchAllResilient now applies each [HarmonyPatch] class one at a time in its own try/catch: a target that doesn't exist on your game version logs Patch class 'X' could not be applied on this game version and has been skipped and disables just that one feature, while everything else - ghost form, tombstone revive, the Spirit, Resurrection Sickness - keeps working. Check the log for these lines after any game update; they tell you exactly which feature (if any) needs its patch target re-pointed, without guessing from silence.

The TombStone ownership check specifically fails "open" (allows the revive anyway) if m_playerID can't be found by reflection, so a rename there degrades gracefully instead of soft-locking a player in ghost form forever — and if even that isn't enough, the alt-interact teleport above gets the player back to the Spirit regardless of what the ownership check thinks.

Player.TeleportTo is the one new call with real consequences if its signature drifts. It's wrapped in a try/catch that falls back to setting the player's transform position directly, which is cruder (no fade, no zone pre-load) but gets you where you're going.

Ideas for extending it

  • Give the Spirit of Resurrection an actual ZNetView + a registered location (the Jotunn library is the standard tool for this) so it's a real, shared, persistent NPC other players in your world can also see and use — useful if you want a fixed "spirit healer" spot rather than one that follows each death.
  • Swap the trail/light visual for actual shader-based transparency on the player model for a closer look-alike to WoW's ghost.
  • Block building/interacting with the world too while ghosted (patch Player.UpdatePlacementGhost / relevant interact methods), not just combat.
  • Scale the Spirit's skill/durability penalty with how far you died from your bed, so it's a bigger tradeoff for a long corpse run avoided.
  • Add a bindable emergency hotkey as a third layer of failsafe, for the case where you can't reach any grave to alt-interact on.
  • Charge something for the teleport itself (it's currently free — only the revive at the far end costs you), if players start using it as a fast travel route back to their bed.
DatHost — Valheim server hosting, first month for one euro
DatHost — Valheim server hosting, first month for one euro
DatHost — Valheim server hosting, first month for one euro
DatHost — Valheim server hosting, first month for one euro
DatHost — Valheim server hosting, first month for one euro