Modding:Encounters and Population

There are two primary population systems in Caves of Qud, the legacy  system, and the  +  system. Encounter tables are an older system and we prefer to use zone templates + population tables these days, but much of the game is still populated via.

Like, both the   and the   support use of the   attribute to merge content into existing tables defined by the base game files. This will append entries to the specified table instead of overwriting it.

Many zone template encounters draw objects from dynamically created population tables. Check out the following tags in  to see them in use: ,. Some dynamic population tables are created based on the base type of the object, so new objects will begin appearing immediately in areas generated with dynamic population tables unless they are tagged with. Refer to the section below for more information about Dynamic population tables.

The unaffiliated cave systems are one area that is heavily populated with the zone template+population system.

Extending Encounter Tables
You may add new entries to existing encounter tables by including  in your mod, using an existing table name and setting the   property on the encountertable tag.

Adding "My New Ammo" to the "Ammo 1" built-in encounter table

Extending Population Tables
To modify existing populations, you can take a similar approach. For example, the following could be used in a mod's  file to add a new type of Wristblade Legendary merchant lair:

Of course, this would also need to be supplemented with an ObjectBlueprints.xml that defines the new "WristbladeMerchant". It would likely inherit from "BaseMerchant" and have the appropriate parts defined, similar to other legendary merchants.

Full Example Usage
Here is some example XML from a mod that creates a fully functional Six Day Stilt vendor using a combination of  tables and new tables defined by the mod. This is everything that's needed in the mod's PopulationTables.xml file, though this won't work by itself. It would also require an ObjectBlueprints.xml to define the various Blueprint objects that are not included here.

Dynamic Tables
The game sometimes uses dynamically generated population tables, which are constructed from objects in ObjectBlueprints.xml.

For example,  may select an object from the ,  , or   tables depending on the type of dervish. This table will select any item that inherits from "BaseLongBlade" as long as it does not have the  tag. For dynamic tables of this type with a tier, the game will strongly weight items of the specified tier, but items of other tiers can also be selected.

For example,  will give a weight of 1000 to items of the specified tier, a weight of 100 to items one tier above or below that, a weight of 10 to items two tiers above or below that, and a weight of 1 to all other items. This results in a population table being constructed by the game similar to the following:

Additional Info
Here's a thread on Steam where Brian discusses using encounter and population tables: http://steamcommunity.com/app/333640/discussions/3/358415738194955181/