Creating Dungeons - Valheim-Modding/Wiki GitHub Wiki

This page is a work in progress

Overview

A valheim Dungeon consists of two main parts:

  1. An exterior location
  2. An interior collection of procedurally placed rooms.

Dungeon Exterior

The dungeon exterior is similar to all other locations. It is placed during world generation and will follow location placement rules. However, it should have an attached DungeonGenerator to generate the dungeon rooms as well as a teleport to transfer the player from exterior to interior.

  • It's a good idea to set the exterior BiomeArea to Median. This ensures the resulting DG transform will be likely be placed inside the zone.

Dungeon Interior

A dungeon interior is a collection of procedurally placed rooms. A DungeonGenerator holds a Theme field and will attempt to place rooms with the same Theme. Each room has one to many connections. For each connection, the DungeonGenerator will attempt to place another room given a set of room connection parameters. Dungeon generation will stop when the max rooms is met or when a room exceeds the bounds of it's starting zone.

  • If using m_useCustomInteriorTransform, then also set the transform.position.z value of DungeonGenerator prefab to -30.
  • Endcaps should have at least one Room.Size value equal to 0.
  • Endcaps should use a transform.rotation of 0,0,0

Building Rooms in UnityEditor

There are a few quirks to building dungeon rooms in Valheim.

  1. Room sizes should be configured so as to not allow rooms to exceed the bounds of their starting zone. If a room exceeds the bounds of it's starting zone and therefore places a room connection outside the starting zone, that room connection will not receive another room. This can be circumvented by ensuring all rooms fit neatly into a 64x64 size zone or by creating endcaps with a room size of 0.

  2. The transform rotation values on room connections must follow a specific pattern. See attached image below. With the UnityEditor compass in the same orientation as shown. North facing room connections must use the rotation values on the top of the black square. South facing room connections must use the rotation values on the bottom of the black square. Etc...

Valheim Dungeon Room Connection Transform Values

  1. Room connection prefab transform.position values should be integers. The room connection prefab should be placed at the edge of room. For example, if a room is 8x8x8 and has a transform.position of 0,0,0 then the local position of a room connection prefab should be 8,0,0.

Debugging

  • Many issues arise from incorrect transform.rotation values.