The Guide to Adding New Content to CDDA for 1st Time Modders now lives on github and you should follow that fine hand-crafted link to the current version.
This thread is meant to provide a quick, accessible overview of how to add specific features to CDDA. It’s intended for people who want to add a thing, but don’t know where to start.
Hey, what if CDDA had a
- new way to craft an item (a recipe!)
- new item!
- new location!
- better NPC dialogue!
- new quest!
- new monster!
- new morale effect!
- new vehicle part!
- new vehicle!
All of these can be added to the game by editing text files, because they’re data files and most of CDDA’s data is stored in a text file format called JSON.
A brief intro to JSON
CDDA’s data files are stored in a text format called JSON. JSON looks complicated and intimidating when you first start, but it is just text. You can learn to read it and understand it, and then it isn’t mysterious.
True story - I’ve been a professional programmer for more than 20 years. When I first started dealing with JSON a couple of years ago, I thought it was complicated, mysterious, and intimidating. But I learned a bit about and now I can write JSON and even write guides telling other people about JSON.
Why should I care about JSON?
JSON defines that game’s data. If you add JSON to the game that matches the game’s expectations about what a bit of JSON should look like, you can add new content to the game.
You can edit JSON with a text editor, like notepad++ on Windows. Notepad++ has a syntax highlighting mode that understands JSON, so it will help highlight possible mistakes. On Linux, you can use any text editor that you prefer and most of them have JSON syntax modes.
JSON Overview
CDDA’s data files are stored in data/json inside the game’s folder. Each JSON file has content that looks something like this:
[
{
"id": "sig_40",
"type": "GUN",
"reload_noise_volume": 10,
"name": "SIG Pro .40",
"name_plural": "SIG Pro .40",
"description": "Originally marketed as a lightweight and compact alternative to older SIG handguns, the Pro .40 is popular among European police forces.",
"weight": 680,
"volume": 2,
"price": 75000,
"to_hit": -2,
"bashing": 8,
"material": [ "steel", "plastic" ]
}
]
JSON has 5 types of things in it:
- lists are collections of other things, and are enclosed in brackets like this
[ "thing", "other thing" ]
. items in a list are separated by commas. - objects are also collections of other things, but each item in an object consists of a key and a value, like this
"volume": 2,
. Again, items are separated by commas, and the entire object is enclosed in braces likes this{ "sample_object": "value" }
- strings are words or sentences, and are always enclosed in quotes like this
"string"
. the keys of an object are strings. - numbers are numbers, and aren’t enclosed in quotes.
-
true
andfalse
are special words that are never enclosed in quotes. they’re referred to as booleans.
So the sample bit of JSON above is a list with a single object in it. that object has several keys, some of which have string values, others have number values, and one has a list value and that list is made up of string values.
About file locations
All files locations below start in the game’s folder. So if your game is in C:\Users\bob\Cataclysm, then data/json/items/gun/50.json is at C:\Users\bob\Catacylsm\data\json\items\gun\50.json. Also, I’m a Linux guy and I use slashes the right way to separate folders so if you’re on Windows, you’ll need to convert my “/” to Windows-style “\”.
Also, although the game stores certain JSON objects in certain files or folders, it’s the content of the objects that matter, not the location. Even though 7.62mm rifles are normally defined in data/json/items/gun/762,json, you can define one in data/json/skills.json and it will still work.
Continued in getting started
(This document now lives on the CDDA github wiki so you should probably check there for the most up to date version)