Confirm with your password

Valheim Night Sanctuary

A lightweight, performance-optimized mod that dynamically caps late-game night spawns based on your current biome or distance from the world center.

Client & Server Comfort Enemies Valheim 1.0

· MIT license

Stars
0
Downloads
9
Version
1.2.0
Updated
Author
lotrig
Virus scan
✓ Scan successful
Runs on
Client & Server

Description

Valheim Night Sanctuary

A lightweight BepInEx mod that keeps late-game night spawns out of your starting area. You define a sanctuary by distance from the world center or by biome. Inside it, night spawns from a higher progression tier than the local biome are blocked.

The mod is one Harmony patch on the world spawner. It runs only at night and only inside the sanctuary. It adds no prefabs, RPCs or save data.

Features

  • Zone modes. Choose where the sanctuary applies:
    • CenterRadius: every zone within a set distance of the world center (default 1500 m).
    • BiomeOnly: every zone in the selected biomes, for example the Meadows.
    • WholeWorld: the whole map.
  • Progression cap (CapAtCurrentBiome). At night, a spawn that requires a boss kill is blocked when that boss belongs to a higher tier than the biome the spawn happens in. Each biome keeps its own native night spawns, so no zone goes empty.
  • Adjustable difficulty (CapWithTierOffset). The same cap, raised by BiomeTierOffset tiers. With an offset of 1, the Meadows also get Eikthyr's night spawns (Greydwarfs); with 5, everything up to Yagluth's (Fulings). See How the Cap Works.
  • Non-destructive. The mod never adds, removes or reorders spawn entries and never edits saved spawn timers. During each spawn check it lowers one runtime flag on the blocked entries and restores it right after. Spawn lists stay exactly as the game or other mods left them.
  • Live toggle. ToggleMod removes or re-applies the patch at once. No restart needed.

Not affected: daytime spawns, raids (random events), fixed spawners in locations and dungeons, spawner structures, and creatures that already exist.

How the Cap Works

Some night spawns start only after a boss is defeated. For example, after Yagluth dies, groups of Fulings roam the Meadows at night. The mod gives each biome and each boss a tier and compares them.

Biome tiers follow the progression order:

Tier Biome
0 Meadows, Ocean
1 Black Forest
2 Swamp
3 Mountain
4 Plains
5 Mistlands
6 Ashlands
7 Deep North

Boss tiers. A boss has the tier of the biome that its defeat opens up. Eikthyr opens the Black Forest, so his key has tier 1. This is why Yagluth, the Plains boss, has tier 5. The table lists the night creatures of the world spawner that need a boss key (Valheim 1.0.15):

Tier Boss Key Night spawns it unlocks (biomes they spawn in)
1 Eikthyr defeated_eikthyr Greydwarf, alone and in groups of 2–3 (Meadows)
2 The Elder defeated_gdking Greydwarf Brute and Greydwarf Shaman (Meadows); Draugr, only in misty weather (Meadows, Black Forest, Mountain, Plains)
3 Bonemass defeated_bonemass Skeleton (Meadows, Black Forest, Swamp, Mountain, Plains)
4 Moder defeated_dragon none
5 Yagluth defeated_goblinking Fuling group of 3 (Meadows, Black Forest, Mountain)
6 The Queen defeated_queen Seeker (Meadows, Black Forest, Swamp, Mountain, Plains); Seeker Brood and Tick (Mistlands)
7 Fader defeated_fader Charred Warrior and Charred Marksman (Meadows, Black Forest, Swamp, Mountain, Plains)

The rule. Inside the sanctuary at night, a spawn is allowed only when the tier of its boss is not higher than the tier of the zone's biome. Spawns without a boss key, or with a key that is not in this table, are always allowed, so every biome keeps its native night creatures.

CapWithTierOffset raises the zone's tier by BiomeTierOffset, up to 7. The offset counts bosses, not biomes. In the Meadows (tier 0):

BiomeTierOffset Night spawns this offset adds in the Meadows
0 none (same as CapAtCurrentBiome)
1 Greydwarfs (Eikthyr)
2 Greydwarf Brutes and Shamans, Draugr in mist (The Elder)
3 Skeletons (Bonemass)
4 nothing new (Moder unlocks no night spawns)
5 Fulings (Yagluth)
6 Seekers (The Queen)
7 Charred (Fader); nothing is blocked

In other biomes the count starts from that biome's tier. For example, a Black Forest zone (tier 1) with an offset of 1 allows spawns up to tier 2 (The Elder).

The sanctuary check uses the center of each 64 m × 64 m zone, so the border follows the zone grid.

Installation

Mod manager (recommended)

  1. In Gale search for Valheim Night Sanctuary and install it. The manager also installs BepInExPack_Valheim if it is missing.
  2. Start the game once from the mod manager to create the config file.

Manual

  1. Install BepInExPack_Valheim.
  2. Copy Valheim_Night_Sanctuary.dll to <Valheim>/BepInEx/plugins/Valheim_Night_Sanctuary/.
  3. Start the game once to create the config file.

Server

Install BepInExPack_Valheim, ConditionalConfigSync and this mod on the server. Edit the settings in the server's config file. Players receive them when they connect.

Configuration

File: BepInEx/config/com.lotrig.valheimnightsanctuary.cfg. Changes to the file apply while the game runs. If BepInEx.ConfigurationManager is installed, you can also change the settings in game (F1). In multiplayer, the server's file applies (see Multiplayer).

Section Key Default Description
1 - General ToggleMod true Enables the mod. Applies immediately.
2 - Zone Detection SanctuaryMode CenterRadius Which zones are sanctuary: CenterRadius, WholeWorld or BiomeOnly.
2 - Zone Detection SanctuaryRadius 1500 Radius in meters around the world center (0, 0, 0). Range 0–10500. Used by CenterRadius.
2 - Zone Detection TargetBiome Meadows Biomes that are sanctuary. Used by BiomeOnly. Separate several biomes with commas, for example Meadows, BlackForest.
3 - Night Logic SanctuaryProgressionMode CapAtCurrentBiome CapAtCurrentBiome: block out-of-tier night spawns inside the sanctuary. CapWithTierOffset: the same cap, raised by BiomeTierOffset tiers. Vanilla: no change.
3 - Night Logic BiomeTierOffset 0 How many boss tiers above the zone's biome are allowed: 0 = none, 1 = one more boss, and so on. In the Meadows, 5 allows everything up to Yagluth's Fulings. Range 0–7; 7 = no limit. Used only by CapWithTierOffset. See How the Cap Works.

Multiplayer

Valheim runs creature spawning on a client, not on the server. The player who controls a zone (usually the first player to arrive there) spawns its creatures for everybody. The mod takes effect in that player's game.

  • Single player needs only this mod. Your own config file applies.
  • For multiplayer, install ConditionalConfigSync with this mod, on the server and on every client. The server's config file then applies to everybody: the server sends its values to each player on connect and after every change, and a player's own values return after they disconnect. The server rejects players without compatible copies of both mods.
  • With ConditionalConfigSync installed, you can join only servers that run both this mod and ConditionalConfigSync.
  • Without ConditionalConfigSync, nothing is synced or checked: each player's own config applies in the zones they control, and players without the mod spawn vanilla creatures there.
  • Spawn rules are world rules. While ConditionalConfigSync is active, the server always owns every setting of this mod, and SyncPolicy.cfg cannot hand one to the players.
  • If ConditionalConfigSync causes problems, the server admin can remove it from the server and keep this mod. Players must then remove it too, because with it they cannot join such a server. The easiest way is to share a new modpack code (for example a Gale profile code) without it. After that, nothing is synced or checked.
  • A dedicated server does not spawn creatures in zones. Its copy of the mod holds the config and runs the version check.

In single-player you control every zone, so no extra setup is needed.

Compatibility

  • Built for Valheim 1.0.15 (network version 40) and BepInEx 5.4.23.
  • The mod does not change spawn lists. Entries added by spawn-editing mods such as Spawn That! are filtered by the same rule as vanilla entries. Use with Spawn That! and Spawner Tweaks has not been tested yet.
  • Optional: ConditionalConfigSync 1.x, version 1.0.9 or later (shudnal), for config sync and the version check in multiplayer. With an older version, the mod logs a warning and keeps its settings local. With version 2.0 or later, it logs a warning and still tries; if that fails, the settings stay local.

Troubleshooting

  • The mod logs a warning when the settings leave the sanctuary empty: SanctuaryRadius is 0, or TargetBiome is None in BiomeOnly mode. It logs an info line when BiomeTierOffset is 7 in CapWithTierOffset mode, because then no spawn is blocked, and when BiomeTierOffset is above 0 in CapAtCurrentBiome mode, because then the offset is ignored.
  • To see which spawns the mod blocks, set LogLevels = All under [Logging.Disk] in BepInEx/config/BepInEx.cfg. LogOutput.log then gets one Blocked night spawn line for each blocked spawn entry and zone.

Building from Source

You need a current .NET SDK.

  1. Copy .env.example to .env and set VALHEIM_DIR (the folder that contains valheim_Data) and MOD_DIR (the folder that contains BepInEx/). The build uses the nearest .env in the project folder or any folder above it. .env is git-ignored.
  2. Run dotnet build Valheim_Night_Sanctuary.csproj, and add -c Release for a release build.

-p:ValheimDir=... and -p:ModDir=... override the .env values. After a build, the DLL is copied to <MOD_DIR>/BepInEx/plugins/Valheim_Night_Sanctuary/ if that folder exists.

Changelog

All notable changes to Valheim Night Sanctuary are listed in this file. The format follows Keep a Changelog, and the version numbers follow Semantic Versioning.

1.2.0 Latest

Added

  • CapWithTierOffset value for SanctuaryProgressionMode: the CapAtCurrentBiome cap, raised by BiomeTierOffset tiers. The default mode stays CapAtCurrentBiome, which works as before.
  • BiomeTierOffset setting (section 3 - Night Logic, range 0–7, default 0), used only by CapWithTierOffset: how many boss tiers above the zone's biome may unlock night spawns. In the Meadows, 1 allows Greydwarfs (Eikthyr), 5 everything up to Fulings (Yagluth), and 7 blocks nothing.
  • README: "How the Cap Works" lists the night spawns that each boss key unlocks, taken from the Valheim 1.0.15 game data.
  • Info log lines when BiomeTierOffset is 7 in CapWithTierOffset mode (the cap then blocks no spawn), and when it is above 0 in CapAtCurrentBiome mode (the offset is then ignored).

Changed

  • ConditionalConfigSync syncs BiomeTierOffset from the server, like every other setting.
  • With ConditionalConfigSync installed, the minimum required version is now 1.2.0: a 1.2.0 server rejects 1.1.0 clients.
1.1.0

Added

  • Optional ConditionalConfigSync support (soft dependency, 1.x from 1.0.9). When it is installed, the server's settings apply to every player, and the server rejects players without compatible copies of both mods. Without it, the settings stay local.
  • Live reload of the config file: edits to the .cfg apply while the game runs.
  • Warnings when the settings leave the sanctuary empty (SanctuaryRadius is 0, or TargetBiome is None in BiomeOnly mode), and an info line when SanctuaryProgressionMode is Vanilla.
  • Debug log line Blocked night spawn, once for each blocked spawn entry and zone.
  • Package files for hexium.gg: manifest.json and icon.png.

Changed

  • The game assembly is publicized at build time. The patch targets SpawnSystem.UpdateSpawnList through nameof(), so a rename in a game update fails the build instead of the patch at run time.
  • Build paths come from a per-machine .env file (VALHEIM_DIR, MOD_DIR), and the build stops with one clear message when a path is wrong.

Removed

  • Unpatching in OnDestroy, following the BepInEx wiki best practices.
1.0.0

Initial prototype.

Added

  • Sanctuary zone modes: CenterRadius (default 1500 m around the world center), BiomeOnly and WholeWorld.
  • CapAtCurrentBiome progression cap: at night, inside the sanctuary, a spawn entry is blocked when its boss key belongs to a higher tier than the zone biome it spawns in. Raids are not affected.
  • Non-destructive blocking: a Harmony prefix lowers m_spawnAtNight on blocked entries for one spawn check, and a [HarmonyFinalizer] restores it, also when the game method throws. Spawn lists and spawn timers stay unchanged.
  • ToggleMod: removes or re-applies the patch while the game runs.

Full version history & older downloads →

Manual installation instructions
1

Install BepInExPack Valheim

BepInExPack Valheim is required to run mods in Valheim.

Download BepInExPack Valheim 5.4.2351 · View mod page

Check out the mod page for detailed installation instructions.

2

Install Valheim Night Sanctuary

This mod must be installed on both the client and the server.

Download Valheim Night Sanctuary 1.2.0

Extract the ZIP and place the file(s) into the BepInEx/plugins/ folder inside your Valheim game folder.