User:Kernelmethod/Sandbox:ZoneBuilders
![]() |
This page is about modding. See the modding overview for an abstract on modding. |
![]() |
This article has information that is missing or not up to par.
Reason: This article is currently a work-in-progress. Please check back later. |
Reason: This article is currently a work-in-progress. Please check back later.
Zone builders are bits of code that allow you to shape the generation of a zone. At the lowest level of detail they are used to place and remove objects from zones; more broadly, they can be used to shape the geometry and encounters that a player runs into in a room.
The game provides a limited suite of generic builders that you may find useful for your mod. In general, if you are making small alterations to a zone you do not need to deal with zone builders. On the other hand, if you're planning to create your own maps with custom procedural generation, you will want to know how to write them by hand.
Using zone builders
When you enter a new zone, the game uses a zone factory (an implementation of IZoneFactory
) to generate your zone, using the zone factory appropriate to the world that you are currently in. It starts with a blank zone and successively triggers whatever builders have been specified for the zone.
Most commonly, these zone builders are specified in Worlds.xml
. For example, here's the specification of MoonStairCell
(used to generate generic Moon Stair zones):
<cell Name="MoonStairCell" Inherits="DefaultJoppaCell" ApplyTo="TerrainMoonStair">
<zone Level="5-9" x="0-2" y="0-2" Name="sky above the Moon Stair" IndefiniteArticle="the" AmbientBed="Sounds/Ambiences/amb_bed_moonstair">
<builder Class="Sky"></builder>
</zone>
<zone Level="10" x="0-2" y="0-2" Name="Moon Stair" IndefiniteArticle="the" AmbientBed="Sounds/Ambiences/amb_bed_moonstair">
<builder Class="MoonStair"></builder>
<builder Class="FactionEncounters" Population="GenericFactionPopulation"></builder>
<music Track="Reflections of Ptoh" />
<postbuilder Class="ZoneTemplate:MoonStair"></postbuilder>
</zone>
<zone Level="11-15" x="0-2" y="0-2" Name="subterranean stair">
<builder Class="MoonStair"></builder>
<builder Class="PossibleCryotube"></builder>
<builder Class="FactionEncounters" Population="GenericFactionPopulation"></builder>
<music Track="Reflections of Ptoh" />
<postbuilder Class="ZoneTemplate:MoonStairCaves"></postbuilder>
</zone>
</cell>
Cell specifications are broken up by X, Y, and Z-levels. Depending on where the player is, they will trigger different builders appropriate to their location.
The other place that zone builders are often added is dynamically during world generation. For example, this is how Oboroqoru, Ape God's lair, goatfolk yurts, and dynamic villages are placed by JoppaWorldBuilder
. It is possible, but less common, to dynamically apply zone builders in other parts of the game.
Generic, pre-existing zone builders
The game provides a limited suite of zone builders that are sufficiently generic that they can be easily applied to any zone.
Builder name | Description |
---|---|
Connecter | |
FactionEncounters | Adds encounters with legendary creatures sampled from a provided table. |
MapBuilder | This builder loads a map from a .rpm file. A MapBuilder is implicitly to a zone by the <map/> tag in Worlds.xml. For example, the map for the Yd Freehold is added as follows:
<map FileName="YdFreehold.rpm" />
|
Music | Adds a music track to a zone. A Music zone builder is implicitly added by the <music/> tag in Worlds.xml. For example, the music for the salt dunes is added with
<music Track="MoghrayiRemembrance" />
|
SolidEarth | Fills the entire map with shale. This is useful when you wish to carve out the geometry of your zone (i.e., specify the empty space rather than specify the filled space). |
StairConnector | |
StairsDown | Adds a set of stairs down to the next Z-level. You can specify X- and Y- coordinates to influence the region in which the stairs are placed. |
StairsUp | Adds a set of stairs up to the previous Z-level. You can specify X- and Y- coordinates to influence the region in which the stairs are placed. |
TileBuilding |
In general, the game's existing zone builders tend to be highly monolithic, so any zone builders not listed above are not recommended for use in creating new types of zones. For new zones modders should favor a more modular architecture.
Strategies for creating ZoneBuilders
This article is a stub. You can help Caves of Qud Wiki by expanding it. |
The ZoneBuilderSandbox interface
ZoneBuilderSandbox
is the primary interface for creating new zone builders. Any builders that you add to the game will inherit from this class.
Most zone builders only need to define one method: BuildZone
. This method accepts a zone instance, and returns a boolean that signals whether or not subsequent zone builders should also run[1]. As an example, here is the definition for the SolidEarth
zone builder:
namespace XRL.World.ZoneBuilders;
public class SolidEarth
{
public bool BuildZone(Zone Z)
{
for (int i = 0; i < Z.Width; i++)
{
for (int j = 0; j < Z.Height; j++)
{
Z.GetCell(i, j).Clear();
Z.GetCell(i, j).AddObject(GameObjectFactory.Factory.CreateObject("Shale"));
}
}
return true;
}
}
This builder
- loops over each cell in the zone (incidentally: nowadays there is a
Zone.GetCells
method to make this even easier); - clears all objects that are currently in the cell; and
- adds a shale object to the cell.
Helpful utilities
This article is a stub. You can help Caves of Qud Wiki by expanding it. |
Creating encounters with zone templates
This article is a stub. You can help Caves of Qud Wiki by expanding it. |
Procedural generation
This article is a stub. You can help Caves of Qud Wiki by expanding it. |
- ↑
XRL.World.ZoneManager
, methodApplyBuilderToZone