Modding guide for KCD

From Nexus Mods Wiki
Jump to: navigation, search
The features in this article are available in KCD version 1.3 and later

Mod installation

Mods are loaded from the "Mods" folder in the game's root directory. In the Steam version you can usually find it at C:\Program Files (x86)\Steam\steamapps\common\KingdomComeDeliverance\Mods\. If the Mods folder doesn't exist, create it.

To install a mod, simply move it to the Mods folder.

To uninstall a mod, delete it from the Mods folder. You can also temporarily disable a mod by using mod_order.txt.

Mod structure

In the Mods folder each mod has its own subfolder, which replicates the game's directory structure, for example:

  • Mods\mod_name\mod.cfg
  • Mods\mod_name\mod.manifest
  • Mods\mod_name\Data\mod.pak
  • Mods\mod_name\Data\Levels\rataje\mod.pak
  • Mods\mod_name\Data\Levels\new_level_name_1\level.pak
  • Mods\mod_name\Data\Levels\new_level_name_2\level.pak
  • Mods\mod_name\Localization\english_xml.pak
  • Mods\mod_name\Localization\english.pak

All files in a mod are optional, you have to create only those which you want to override.

In the mod's root you can create two special files: mod.manifest and mod.cfg.

Pak files

All game data must be stored in pak files. To make a pak file, create a zip archive and rename the extension to pak. Rar, tar, 7z or other archive types are not supported. Data in the zip can be compressed, except videos, which must be stored without compression. In the mod's Data folder you can name your paks however you like, you don't have to mimic the game's pak names. Usually a single mod.pak or mod_name.pak will suffice. Paks have a maximal size of around 2GB. If your mod is larger, you can use multiple paks.

Levels can be modded by creating pak files in the mod_name\Data\Levels\level_name\ folder. New levels can be added by creating level.pak in mod_name\Data\Levels\new_level_name\ folder.

When modding localization, the mod pak name must exactly match the pak name in the game's localization folder. You can also add new languages by creating new_language_name_xml.pak and new_language_name.pak files in the mod's localization folder. When adding a new language, you will have to correctly set sys_languages and sys_languages_audio CVars.

If you want to override data from the Engine folder, you have to put your pak it in the mod's Data folder.

Tables.Pak modding

If you're making a mod that overrides a parameter file inside Tables.pak, note that for every *.xml file inside this zip container, there is a twin *.tbl file instead. The "table" file is loaded as the primary, but is a binary file. The *.xml file is the one that is human-readable, and can be safely cloned to use as an override file in a new *.pak mod.

HOWEVER because of the *.tbl preference, you want to include a 0-byte copy of the matching *.tbl file, so the game will ignore the original *.tbl file and load your *.xml override instead! Just make an empty text file and give it the same name as the relevant *.tbl file.

The most common example of this is all the small mods here on Nexus that change things like thievery settings. They include only an edited rpg_param.xml file, accompanied by an empty rpg_param.tbl file.


Pak loading order

When a pak file is loaded, it overrides data in previously loaded paks.

Paks are loaded in this order:

  1. Data\*.pak
  2. Engine\*.pak
  3. Localization\language_name_xml.pak
  4. Localization\ipl_language_name.pak
  5. Localization\language_name.pak
  6. Data\Levels\level_name\level.pak
  7. Data\Levels\level_name\*.pak
  8. Data\_fastload\*.pak
  9. Mods\mod_name_1\Data\*.pak
  10. Mods\mod_name_2\Data\*.pak
  11. Mods\mod_name_1\Localization\language_name_xml.pak
  12. Mods\mod_name_2\Localization\language_name_xml.pak
  13. Mods\mod_name_1\Localization\language_name.pak
  14. Mods\mod_name_2\Localization\language_name.pak
  15. Mods\mod_name_1\Data\Levels\level_name\*.pak
  16. Mods\mod_name_2\Data\Levels\level_name\*.pak

Some of the early mods were named zzz_* to ensure that they are loaded last and override all other paks. As you can see, this is not necessary anymore, because paks in Mods\ are loaded after all other paks.

Mod loading order

Mods in Mods folder are loaded in alphabetical order by default. You can specify custom mod loading order by creating an optional mod_order.txt file in the Mods folder. For each line in mod_order.txt the game will try to load the mod from the specified folder.

The format of mod_order.txt is:

# Comment
mod_name_2
mod_name_1 # Comment
mod_name_3

When the mod_order.txt file exists, it also functions as a whitelist: only the mods mentioned in it will be loaded. This can be used to disable a mod without deleting it, by simply commenting out that line.

Mod manifest

For each installed mod the game will try to load the optional mod.manifest file in the mod's root. The format of mod.manifest is:

<?xml version="1.0" encoding="utf-8"?>
<kcd_mod>
  <info>
    <name>Name of mod -- can be different from mod folder name</name>
    <description>Some text</description>
    <author>Your name</author>
    <version>Version of the mod -- string</version>
    <created_on>some date -- string</created_on>
    <dependencies>
      <req_mod>name of a required other mod</req_mod>
      ...
    </dependencies>
  </info>
  <supports>
    <kcd_version>1.2</kcd_version>
    <kcd_version>1.3</kcd_version>
    ...
  </supports>
</kcd_mod>

The whole info block is skipped for now, but the game checks that one of the entries in kcd_version matches against the current game version (wh_sys_version in system.cfg). If no matching version is found, the mod will be disabled.

In KCD version 1.3.4 and later you are able to use wildcards like <kcd_version>1.3.*</kcd_version>. It is implemented as a string comparison up until the "*" character, so these will not work as expected: <kcd_version>1.*.4</kcd_version>, <kcd_version>1.3.[1-5]</kcd_version>.

Mod config

Another optional file in the mod's root is mod.cfg. When present, it will be loaded after system.cfg, but before user.cfg, which means it overrides CVars in system.cfg, but not in user.cfg. You can use the mod.cfg in simple mods when all you want to do is set some CVars. The order in which mod.cfg files are loaded also depends on mod order.

Fastload paks

The purpose of paks in Data\_fastload is to reduce disk access during level load. They contain a number of small files: various xml files (.mtl, .animevents, .bspace, .chrparams, .cdf...), smallest mipmaps of splitted dds files and cgf files without render geometry. At the beginning of level loading, all fastload paks are loaded in the memory. Since they are loaded after regular Data paks, they will be searched first, and the game doesn't have to access the disk. At the end of level loading, all fastload paks are unloaded from the memory and are closed.

Some of the early mods required copying the mod paks both to Data\ and Data\_fastload folders to ensure that the mod properly overrides the game data. This is not necessary anymore, because paks in Mods\ are loaded after the fastload paks.

A mod can have its own fastload paks in Mods\mod_name_1\Data\_fastload\*.pak, but for small mods it is unnecessary. For large mods like texture packs with thousands of textures or total conversion mods with hundreds of new geometry creating fastload paks could be beneficial.


Textures and Images

see Textures and Images


see also