SUPPORT
FORUMS
ABOUT
BLOG
An image

Home

FAQ

Modding

DLC

Press Kit

Forums

Basics

Policies

Dilemmas

Events

Situations

Simulation

Countries

What can be modded in the game?

Democracy 4 is certainly a complex game, and coding and designing it was no easy task, but actually, modding the game is surprisingly easy. Almost all of the simulation elements within the game are loaded from simple text or csv files, which can be edited using any (free) text editor or spreadsheet program. You don't need to download any SDK, learn any languages or install any software. Anyone can mod Democracy 4, even if you've never done any modding or scripting of a game before. You can add new countries, situations, dilemmas, policies and more, using nothing more than a copy of windows notepad (or similar). You may need a graphics program to create any new icons for your policies though...

The basic modding principles

Democracy 4's simulation engine is based on a neural network. This is a computer simulation designed to work in a similar way to the human brain. Pretty much everything in the game is simulated in the same way, such as a voter, a group of voters, a policy or an event. All of these 'objects' are connected to each other by 'effects'. So an object might be 'IncomeTax' and an effect might be the link between IncomeTax and the happiness of the middle class voter group. The objects and effects in the game are not hard coded, they are all loaded in from 'csv' files, which can be opened in a text editor, or more conveniently by a spreadsheet program such as Microsoft Excel. You can edit these files, and save them, then start a new game and immediately play with the changed simulation.

CSV Files

You will find the majority of the CSV files for the game inside the games \program files\democracy 4 \data\simulation folder. the names should be pretty self-explanatory. The most interesting one is probably 'policies.csv'. You should be able to open this up directly using Microsoft Excel. If you edit and then save this file be SURE that it gets saved out as a CSV file, if you let the file format change in any way, it will be unusable by the game, and you will need to start again. For this reason, always back up any files before you edit them! The CSV files for the game all have the same format with a line that starts with '#' indicating that this is an object that should be loaded into the game. Any line without a starting '#' is effectively ignored, so can be used as a comment, to help you organize things.

Effects

Looking at the policies file, you will see a whole bunch of columns in there that load in various bits of data, but towards the end of the list of columns you will see the 'effects' for that policy. For clarity, the effects are denoted as any column to the right of the '#effects' column, and there can be as many there as you like. Some policies have a few effects, some have many, but each effect entry takes up one 'cell' and has the same format which is...

[target],[value1][operator1]([value2][operator2][values3])[operator3][value4],[inertia]

Now this may be confusing because [operator3][value4] is entirely OPTIONAL, and not often included. Lets look at an actual example,. which is the second effect in that spreadsheet, and represents adult education subsidies first effect. it reads...

Education,0.04+(0.04*x),4

In this case the target of the effect is Education. because the effect is an output coming from a policy, the magic value 'x' gets substituted with the current value of the slider for AdultEducationSubsidies.The final value gives us an 'inertia' of 4 for this effect, meaning it averages out over the last 4 values of the slider (in other words it takes up to 4 turns for any slider changes to fully take effect on Education). So let's say that the AdultEducationSubsides policy has been consistently set to 0.5 for 4 turns. What would the value of the effect be?

Final Effect = 0.04 + (0.04 * 0.5) = 0.06

In other words, with the slider at 50%, we are saying we want a 6% boost to the value of our countries education, coming from the AdultEducationSubsidies policy. This is not the *whole* story, because as this is a government policy, that final value might be a bit lower if the policy is not fully implemented yet, plus it may be tweaked up or down slightly depending how competent your minister for public services is, but the principle remains the same. So what happens if we add in those optional extra values? lets look at that, along with another special ability we have, which is to reference another object from the game, for example another statistic: 'Technology'.

Education,0.04+(0.04*x)*Technology,4

In this case, the equation is entirely the same, but we end up multiplying the bracketed result by the current level of technology. like everything in the game, we can assume that the value for Technology is between 0 and 1. This lets you scale the effectiveness of a policy on the level of another value, and it is used in various places especially Taxes, where the income from alcohol tax is dependent upon the current level of alcohol consumption, as well as the slider for alcohol tax itself. To be absolutely clear, I'll add some brackets to show you how this last bit is calculated:

Education,0.04+((0.04*x)*Technology),4

You don't have to just have + or * as your operators, you can also use - / and ^. ^ is 'power', and is used to generate a lot of the fancy curves that make some of the equations so interesting. I recommend playing around with the free 'graphcalc' program to see the exact effects you can achieve.

Installation and Preparation

Each mod is basically a folder containing subfolders that mirror the folder structure of the base game. The folders all sit within a master mod folder in \my documents\my games\democracy 4\mods. (This location is different when steam workshop installs the mod).
Almost any folder within the default install of the game can be mirrored to a mod folder, and the game expects to find each file in the same place it would in the main install, so any non-vector graphics inside 'data\bitmaps', the main spreadsheets are inside 'data\simulation' and so on.
A special mod file will exist inside each mods folder called config.txt stuff in this format:

[config]
name = rural internet subsidies
path = C:\Users\cliffski\Documents/My Games/democracy4/mods/rural_internet_subsidies
guiname = rural internet subsidies
author = cliffski
description = the rural internet description

This is the file that the game looks for, and reads to gather information to display to the player in the games mod control panel:

Translated text

All of the text that is display to the player is located outside the folder structure described on the other modding pages. To isolate the text to make it easy to provide translations for a mod, the human-readable text is within folders found inside a 'translations' folder for each mod. These file exactly mirror the data inside the translations folder in the main game.

Custom Pre-Requisites

The game comes with a list of special hidden 'pre-requisite' values which may be set to 1 or 0 depending on which country is played, or other factors. You can see the list of these values in this file: data/simulation/prereqs.txt

Here are some of them:

0 = _prereq_has_coast
1 = _prereq_mining_industry
2 = _prereq_deadly_animals
3 = _prereq_preindustrialized
4 = _prereq_royal_family
5 = _prereq_land_border
6 = ...

and so on...
These are valuable because you might want to have an event in your mod that is only triggerable if a country has a coastline, and you can add this special value as a pre-requisite to ensure it does not trigger otherwise.

As of build 1.38 of the game, you will be able to add your own pre-requisite values to the game. You simply create a similar named file, in the relevant location in your mod so:

mymodname/data/simulation/prereqs.txt

And enter any new pre-requisite names that you would like. Once you have done this, its then safe to make references to the new names elsewhere in your mod, maybe in dilemmas or events.

Note to modders without english as your first language:
'pre-requisite' basically means 'something that needs to be true for this to happen'.