N3bby-HexenBeGone icon

HexenBeGone

A switch for each way Hexen spawn, synced from the server. By default only stops natural Deep North spawns; dungeon and invasion Hexen stay. AI-assisted.

Last updated 2 weeks ago
Total downloads 71
Total rating 0 
Categories Tweaks Enemies Server-side Client-side AI Generated Deep North Update
Dependency string N3bby-HexenBeGone-1.1.0
Dependants 0 other packages depend on this package

This mod requires the following mods to function

denikson-BepInExPack_Valheim-5.4.2351 icon
denikson-BepInExPack_Valheim

BepInEx pack for Valheim. Preconfigured with the correct entry point for mods and preferred defaults for the community.

Preferred version: 5.4.2351

README

HexenBeGone

A small BepInEx mod for Valheim that gives you a switch for each way Hexen can spawn. By default it only stops the natural Deep North spawns, the roaming Hexen that start showing up after you've destroyed the crystal in Mörkhalla. Hexen still appear in Mörkhalla and during Jotun invasions.

Settings sync from the server to every player, so everyone on a server plays by the same rules.

Spawn types

These are all the ways the base game spawns Hexen, taken from the game's own data:

Setting Default Where Hexen come from
AllowNaturalSpawns off Roaming Deep North spawns (Jotun Witch Patrol), unlocked by the jotun_killed key.
AllowInvasionSpawns on Deep North spawns that only run during the Jotun invasion (Fimbulvinter - Jotun Witches).
AllowSpawnerStructureSpawns on The Black Ice core at Jotun invasion sites. When off, the core spawns Krigen instead.
AllowDungeonSpawns on The fixed spawn points in Mörkhalla rooms.
AllowRaidSpawns on Random raids. No vanilla raid includes Hexen, but this covers other creatures you add and mods that add raids.

Every other creature always spawns as normal. To apply the same switches to other creatures, add their prefab names to AffectedPrefabs.

Installation

Install it on the server and on every player's game, like TameProtection:

Installed on Gameplay effect Configuration
Players only Works for the areas each player's game is running Local, per-player
Server only Nothing —
Both Works Server decides; admins can edit it live

Valheim runs spawning on the game of whichever player "owns" that part of the world, not on the server. So every player needs the mod, and a player without it still gets vanilla spawns around them. The server copy is what makes the settings authoritative. It pushes its synced settings to players when they connect. Without the mod on the server, each player just uses their own config.

A player without the mod isn't kicked. They just don't get the effect.

  • r2modman / Thunderstore Mod Manager: install it like any other mod, on the server profile and on every player's profile.
  • Manual: copy plugins/HexenBeGone/ into BepInEx/plugins/.

Configuration

The config file is BepInEx/config/n3bby.valheim.hexenbegone.cfg, created on first run.

Setting Default Synced Meaning
LockConfiguration true yes While connected, only server admins may change synced settings.
AffectedPrefabs JotunWitch yes Comma-separated creature prefab names the spawn switches apply to.
AllowNaturalSpawns false yes See Spawn types.
AllowInvasionSpawns true yes See Spawn types.
AllowSpawnerStructureSpawns true yes See Spawn types.
AllowRaidSpawns true yes See Spawn types.
AllowDungeonSpawns true yes See Spawn types.
VerboseLogging false no Logs every spawn this mod blocks. Noisy; testing only.

Admins can change synced settings live from an in-game configuration manager.

How it works

Three Harmony patches, one for each part of the game that spawns creatures:

  • SpawnSystem.UpdateSpawnList: the periodic spawn loop. It covers natural spawns, invasion spawns (entries tied to a persistent event such as jotun_invasion), and raids (the active random event's list). Blocked entries are switched off for that one pass and switched straight back on afterwards.
  • SpawnArea.SelectWeightedPrefab: the pick made by spawner structures such as the Black Ice core. Blocked creatures are left out of the weighted pick, so the structure spawns one of its other creatures instead.
  • CreatureSpawner.Spawn: fixed spawn points such as Mörkhalla's. A blocked spawn point simply doesn't spawn. If the setting is switched back on later, it spawns as normal.

Config syncing uses ServerSync by blaxxun, included as source under its MIT license (ServerSync.LICENSE.txt).

AI disclosure

This mod was written with the help of an AI coding assistant (Claude, by Anthropic). That includes the code, this README, PUBLISHING.md and the generated icon.png. The list of spawn types comes from the game's own assemblies and data, not guesswork.

It was compiled against the real game assemblies and tested on the Valheim dedicated server with BepInEx. A test plugin drove each patched spawn method with the game's real Deep North spawn list, Black Ice core and Mörkhalla spawn point. It checked that each switch blocks only its own spawn type, that every other creature is untouched, and that the default settings are right. All 18 checks passed.

It has not been play-tested in a normal game client. Server-to-player config syncing uses the same library and setup as TameProtection, but hasn't been tested with a real player connecting. Please open an issue if something doesn't behave as described.

Building from source

Requires the .NET SDK (8.x is fine) and a local Valheim + BepInExPack install (the game assemblies can't be redistributed).

git clone https://github.com/N3bby/HexenBeGone.git
cd HexenBeGone
export VALHEIM_MANAGED_DIR="/path/to/Valheim/valheim_Data/Managed"
# Only needed if BepInEx isn't installed inside that Valheim folder:
# export BEPINEX_CORE_DIR="/path/to/BepInEx/core"
dotnet build HexenBeGone/HexenBeGone.csproj -c Release

The output is HexenBeGone/bin/Release/netstandard2.1/HexenBeGone.dll.

See PUBLISHING.md for packaging and uploading to Thunderstore.

License

MIT. See LICENSE. ServerSync is MIT, see ServerSync.LICENSE.txt.