Democracy 3 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 3, 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 3'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 3 \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...
Now this may be confusing because [operator3][value4] is entirely OPTIONAL, and not often included. Lets look at an actual example,. which is the very first 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 entirely of '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.
Modding New Policies
Policies are basically just a line in a spreadsheet. In this case that spreadsheet is in \program files\data\simulation\policies.csv, and each row that starts with a '#' in the first column becomes a policy that gets loaded into the game. The key to adding policies is to understand what all those columns do, so here is a breakdown of each one, and what it means. I'm using the titles for each column taken from the very first row to describe them...
Name, GUIName
The Name is the word or words used to reference this object internaly within the game by other objects. This is never shown in the game. The GUIName is actualyl displayed as the name of the policy to the player
Slider
if set to 'default' then the slider for this policy has no specific features. If set to a name, this name is used inside 'sliders.csv' to select a bunch of names for the different slider positions, and optionally to 'clamp' them to a series of fixed options.
Description
This is displayed on the policy details screen to the player.
Flags
Can be blank, or one of a number of presets. UNCANCELLABLE means the cancel button is greyed out and the policy is always implemented at 0.5 strength unless specified at a different level. MULTIPLYINCOME means that when determining the amount of income generated by the policy, the various inputs to the income get multipleid rather than added (see below).
Introduce,Cancel,Raise,Lower
This is the amount of political capital required to introduce this as a new policy, cancel it, and raise or lower the current slider level once it's implemented.
Department
Decides which 'zone' on the screen the icon for this policy will appear in, which category on the new policies screen it will be listed under, and also which cabinet minister will be in charge of the policy, and thus affect the efficiency with which it is implemented.
MinCost, MaxCost
These show the cost of the policy per turn at a levekl of 0 on the slider and at maximum on the slider. This is a fixed value, which then gets multiplied by a set multiplier for each country (specified within the country file) and then adjusted for ministerial competence to get an actual cost for this policy (This is then adjusted by the next column...)
Cost Multiplier
A series of inputs, separated by colons, which determine how we get a 'cost multiplier' for the policy, which is a value by which the final cost of the policy is multiplied. Each entry in the list is either _default_ and a set value or it's an actual effect, as specified here.
Implementation
How many turns it will take for this policy to be fully implemented (or cancelled). This will be adjusted in practice for the competence of the minister in charge of this policy.
MinIncome,MaxIncome
Same as MinCost,MaxCost but for income
Income Multiplier
Exactly the same as Cost Multiplier, except the flag MULTIPLYINCOME under flags can convert this to be a value where the inputs are multiplied together rather than added.
Effects
This special column marks the start of the effects list (one in each cell) for this policy. These are all 'outputs' from this policy to other items, probably voter groups, situations and simulation values/statistics.
Restricted
This optional entry at the end of the effects has #Restricted as the cell entry. This means that the policy is not available to all policies but only the ones whose object names (not GUINames) are listed in the cells after this in a line. You can have just one entry, several or none, and the #restricted cell is entirely optional.
Modding Dilemmas
Dilemmas are not loaded from a CSV file but from individual files for each dilemma within \program files\democracy 3 \data\simulation\dilemmas. Each one has certain criteria that may cause it to trigger. The dilemmas can be shown again and again, but once triggered will not be eligible for triggering again for 32 turns.
Grudges
Grudges are created by various parts of the game. They are basically a hidden 'temporary' object (although theoretically they can have a 100% 'decay' value which means they last forever...) that can have an effect on another game object. For example, many game events create a grudge which has effects on public opinion, allowing them to have a temporary and fading out value as they drift from memory. The grudges are created by a special bit of 'script' which is used a lot in the dilemma code. A grudge has a target object, a value and a decay, although technically it's the inverse of a decay, meaning that a decay of 0.9 means that each turn the value of the grudge is multiplied by 0.9, so gradually fading out. The higher that value, the longer the effect will last. Here is a breakdown of the data you will find in a dilemma file...
[dilemma]
This section loads in a name, used internally by the program a GUIName displayed to the player, and a text description, also displayed to the player at the top of the dilemma window.
[influences]
This is a numbered list of input 'effects' which are calculated each turn to give the 'likelihood' of this dilemma being triggered. The top dilemma each turn is triggered, unless an event has also triggered that turn. For more on how to format an effect see here, although note you cannot use inertia for these effects. The name at the start of the effect here is the 'source' rather than the target (which is clearly this dilemma). So for example this influence:
1 = Health,0.8-(0.6*x)
Says that the value of this dilemma (Chance of it triggering) has 0.8 added to it, then (0.6*Health) is subtracted from it. In other words, the higher your health value, the less chance of this dilemma being triggered. There is also a special class of effect for these influences which is the random influence which is formatted like this:
0 = _random_,0,0.3
What this means is to generate a random number between 0 and 0.3, and add that number to the dilemmas current value. This is to give some random variation to the probability of this dilemma being triggered.
You can have as many influences to a dilemma as you like.
[option0] (and also [option1])
These two sections represent the two options the player must choose from. Each one has a Name, which is displayed to the player, and A description which is also displayed. there is then a line called 'OnImplement' which is only processed if this is the option which the player selects. This line is a 'script' which is run to implement the effects of this decision. For example:
The script is almost always just a string of CreateGrudge() statements separated by a semicolon. Each of these calls creates a new grudge with the given values. For example:
This creates a new grudge (see above) which has a player-visible name of 'Children's Food', and an internal name that matches the dilemma name. The next two values are the 'effect' of the grudge and it's decay. In this case, the grudge reduces Health by 0.05, but that value is itself multiplied by 0.9 each turn. So a turn after the choice, it will be just -0.045, and so on. You can have a high but quickly trailing off effect, or vice-versa, by fiddling with those two numbers. You can also make those effects positive or negative, and the target can be any named object.
Modding Events
Events can be found as simple text files within \democracy 3 \data\simulation\events. Every text file in the folder is considered to be a separate events. every 3 turns, the 'event manager' will evaluate the chances of every single event happening, and if the highest-scoring one has a value above 70%, it is triggered. The score of an event is based on a number of 'influences' that are effects from other items in the game, and once triggered the event runs a script, which effectively creates temporary effects.
The config section
The [config] section of an event has lines for Name, GUIName, Texture and Description. These are the internal name, the name displayed to the player, the graphic used for display when the player clicks to see details of the event, and the text displayed in that window. There is also a GUISound line, which is the name of a sound effect file that will be played while that window is active.
OnImplement
That section also has a line called 'OnImplement' which looks like this:
This is a 'script' which has a number of 'functions' each of which are separated by a semicolon (;). The functions are always called 'CreateGrudge', and what these do is to create a 'temporary' and hidden object called a grudge, which decays over time, but while it is active, will exert an effect on another object within the game. The Parameters to the function are as follows:
GUIName of Parent (for displaying on effects)
Object Name of Parent (This is the same as the event name)
Target Object Name (Internal name for the object we wish to affect...)
Effect value (At the maximum, ie: the start of the grudge)
Decay (Actually the inverse of a decay, so a 0.97 is multiplied by 0.97 each turn. Higher numbers lead to slower decays)
There is no limit to the number of grudges an event can create. Note that most effects create a negative grudge against themselves, to prevent frequent repetition.
The influences section
This is a numbered list of inputs into the event, to determine the likelihood of it being triggered. You can have any input into these items, and also use the magic value of "_random_" which then takes a minimum and a maximum value to be calculated each time the event score is evaluated. This is used to add some random variation. See the basic modding intro for more information on the syntax of effects.
Modding Situations
Situations are rows loaded in from the CSV file found at \program files\democracy 3\data\simulation\situations.csv. Each line that starts with a '#' is a situation that is loaded in and may be triggered. The game will pre-calculate to see if any situations should be running given the situation at the start of the game. From left to right, the different columns of data are as follows...
Name and GUIName
The internally used 'object' name of the situation, and then the GUIName which is actually displayed to the player when referring to this item.
Description
This is displayed on the details screen for this specific situation
Department
This picks which area of the main screen shows this situation
Icon
The name of the file used to display this situation. Note that it's just an icon, the circular background is displayed and colored automatically. The file can exist anywhere within a folder that the game looks in for graphics.
Start text and end text
Shown to the player when the situation starts or stops and the player clicks on that item on the quarterly report screen.
Positive
A value of 1 means this situation is shown in the game with a green background. 0 means a red background.
Start and stop triggers
These are the values for this situation that conform to triggering a 'start' or a 'stop'. By default these values are all set with a similar gap, but you can set them however you want, although I can't vouch for what happens if they are reversed or the same!
Cost and Income per turn
These are fixed values earned or spent each turn that the situation is on-going. These crude values are then multiplied by the multiplier value set up in each country's country file to get the final figure applied in the game.
Inputs and Effects
All the remaining entries represent the effects for this situation, but some are inputs which cause the event to trigger (or to stop) and the others are the outputs which represent the impact this situation has on everyone else when it is running. The effects are all inputs, up until the '#' enrty, after which the remaining ones are effects. Obviously with inputs, the first item is the source of the effect, and with outputs the first item is the target of the effect. There is support for a special 'default' object, which can be used to set a 'base' level for the situation.
Modding Simulation Values
Simulation values are the blue icons. These are loaded in from a spreadsheet found here: \Democracy 3 \data\simulation\simulation.csv. Each line of the CSV that starts with a '#' is loaded in as a new simulation value. The columns in the spreadsheet all do different things and are explained below:
Name(column B) Used internally as the 'object name' for this value in effects.
GUIName(column C) Used to display the name of this value to the player.
Description Shown to the player on the details screen for this simulation value.
Zone Chooses which of the screen areas and policy groups this simulation value is displayed under. This is purely visual so that the player has all of the same kind of data in the same place.
Default This is the initial value given to this object regardless of what other effects may have an influence. Should be between 0 and 1.0
Min and Max Always set these to be 0 and 1.0. I should get rid of them really :D
Emotion Decides whether a change in the value is portrayed as good or bad or unknown on the 'changes' graph for showing what has changed since you were elected. This sets a value to red, green or black depending what you select and what direction the value has moved in. Try to avoid any partisan value judgements.
Icon The name of the icon used to display this item. This is just the central icon, the blue circle surround is added automatically.
# (Start of inputs) This column denotes that the columns to the right of it represent inputs into this simulation value. These are then effects added in the standard format, which create a link from other objects feeding into this one. You can have as many as you like, or none at all, and they end at the next '#' entry.
# (Start of outputs) The second '#' denotes the start of outputs from this simulation value, which are basically effects FROM this TO other items, so they are the equations that represent the effect of this value on everything else in the game. Don't forget that can be other simulation values, voter groups, situations, events, anything you like :D.
Modding Countries
Adding a new country to the game takes some work, but can be done. The countries are folders under the path \democracy 3\data\missions. Each folder contains a number of additional files and information. You also need to provide a large flag and small flag graphic, which are found in \data\bitmaps\flags (large) and data\bitmaps\missions (small).
File Structure
Inside the folder for your new country you need one text file and two more folders. The folder are 'overrides' and 'scripts' and the file is called countryname.txt where countryname is the same as the folder. That text file contains the majority of the information for controlling the state of the country, split into four sections called [config], [options], [stats] and [policies].
[config]
There are a large number of lines in this section which control how the country looks and behaves. Here is a breakdown:
currency This is the text used to denote the currency for this country as is used throughout the GUI.
population This is the amount of voters represented by each simulated voter. there are 2,000 simulated voters so divide the countries true population by 2,000 to get this figure
economic_cycle_start The global economic cycle works on a sine wave, and this shows the percentage through the route o that sine wave that the missions starts at with regards to the state of the global economy.
min_income and max_income The range, in the currency listed above, which voters salaries are distributed between. Makes no difference to the simulation, it is entirely for visual purposes.
min_gdp,max_gdp Only the max works, and it is used as a scalar against which debt is measured to calculate debt as a percentage of GDP, and thus credit ratings. It is probably best calculated by comparing as nations debt against an existing mission nations debt and adjusting accordingly.
wealth_mod A relative multiplier showing the cost and income of things relative to other countries. All policy costs and incomes and other values are multiplied by this amount. So again, it's best to compare a country to an existing one and pick an appropriate value based on the size of their economy.
The level of government debt at the start of the missions.
name Used internally
guiname Displayed to the player.
names_file filename of the file used to load in a list of first, last and surnames for ministers and citizens in this country. That file can of course be modded.
term_length Default value.
max_terms Default value.
details_image Small graphic used on the choose mission screen.
description Shown on the choose mission screen.
flag Large flag background used in some screens.
apathy Default value.
jobtitle Allows swapping of 'chancellor,'prime minister' or whatever else the head of government should be called for this country.
GUID Used to locate the mission in the list of missions on the choose mission screen.
[options]
This is a list of special values that turn on values that can be checked for items such as dilemmas. For example MONARCHY is set as an option, and can then be a pre-requisite for an event such as RoyalScandal. Anything can be added here, as a piece of text, and then checked for it's existence later as a pre-requisite.
[stats]
These are the lines of text data displayed on the choose mission screen, and can include anything of interest to the player.
[policies]
Each line in this section is a policy name and it's starting value. There are some 'uncancellable' policies which are always set (like labourlaws) and if their value is not overidden here, those policies will default to a value of 0.5. Any policy listed here is automatically set as active, with the slider set to the given value. It is entirely implemented at the start of the mission, and it's effects should be fully worked-through the simulation at the start of the game.
The overrides files
if you open up the folder called 'overrides' in any of the mission folders you will find a new bunch of text files. This is where you can put files that denote changes to the simulation that take place only for that mission. Each file represents a single override, and you can have as many as you like. The format is as follows:
TargetName This helps identify the effect that you want to change in the game. This is the object name of the target of the effect. There does not already have to be an effect with this combination, it can be used to create entirely new effects between items just for this mission.
HostName As above, but this is the target of the effect.
Equation Either a new standard 'effect' style equation for this effect (perhaps stronger or weaker than the existing one) or the word DELETE meaning just remove the existing effect.
Inertia Inertia that is applied to the given effect.
The scripts files
This folder contains scripts run at the start of that mission, basically to create grudges. See the 'Events' modding page for more details. The most obvious uses here are to create changes in the composition of voter groups for each country, but you may also wish to start off a country with a GDP boost or cut, or some other temporary or permanent feature to it's economy or society.
Creating packaged mods
Democracy 3 is intended to be as moddable as possible. Although you can edit all of the values currently in the game, add new files to the folders that exist etc, this is very messy and hard to 'undo' and can leave both modders and mod-players in an unfortunate mess. To avoid this, Democracy 3 has been designed with a modular modding system in place. Essentially this is a system for allowing mods to be placed in discrete folders (yet still be loaded) and allowing the player to enable or disable mods at will from a special modding control panel.
The mods folder
There is an (empty) folder here \democracy 3\data\mods. This is where a config file for each installed mod should be placed. It has a special format and should be a text file (mymod.txt for example). It should be laid out like this:
This should be fairly self explanatory. It mostly describes the information seen on the 'mods' window selected from the main menu of the game, but the special part is the 'path' line. This says where the root folder for the mod will be from the Democracy3 folder. So in this example, the mods files will be found within \program files\democracy3\sample_mod
What this system does is allow the player to install half a dozen mods, without changing anything at all in the main folders for the gam, and then enable or disable the mods at will. Disabled mods are entirely ignored, none of their data is loaded or can be referenced by anything else.
Placing Mod files
Once you have your 'sample_mod' folder, you need to create subfolders under it that match the main game to place new data. For example, you should create these folders:
\data (empty)
\data\simulation
\data\simulation\dilemmas
\data\simulation\events
\data\bitmaps
\data\missions
\data\sounds
items placed in these folders should be happily loaded in by the game just as if they were in the main folder.
Installing your mod
So in summary, to install a mod so it uses the cunning new system, you need to drop a single file into the \program files\democracy 3 \data\mods folder, and then you create another folder for your mod, and dump everything else in a mirrored directory structure from that. I strongly recommend using the completely free 'inno setup' program.