Sid Meier's Civilization VI

Sid Meier's Civilization VI

Ocen: 109
Modding Guide & Tips
Autorstwa: Angryr
Please Read
The intention of this guide is to help familiarize you with the Civilization VI modding environment. Think of this guide as a miscellaneous mix of tips. This will not be covering everything you need to make a mod but it will cover the things that I found difficult to find other places (or that I just felt were import enough to cover again).

Don't forget to [Rate] if you found this helpful!
-------------------------------------------------------------------------------------------------------------------
If you'd like to donate and support my modding and modding guide click here[paypal.me].
4
2
   
Przyznaj nagrodę
Ulubione
Ulubione
Usuń z ulubionych
Folders & Paths
These folders may be referenced in this guide or may be helpful when modding (i.e. GameData & GameText).
  • User Folder* - C:\Users\<username>\OneDrive\Documents\My Games\Sid Meier's Civilization VI
  • Cache Folder - <User Folder>\Cache
  • Logs Folder - <User Folder>\Logs
  • Mods Folder - <User Folder>\Mods
  • GameData Folder - ...\Steam\steamapps\common\Sid Meier's Civilization VI\Base\Assets\Gameplay\Data
  • GameText Folder - ...\Steam\steamapps\common\Sid Meier's Civilization VI\Base\Assets\Text\en_US
* - I am using Windows 10, for other versions of Windows this folder will most likely be located where ever your "Documents" or "My Documents" folder is located.

ModBuddy
Creating a new Mod

Open up the mod tools and you should see this screen.



Click ModBuddy and eventually you'll get a screen something like the image below. To start a new mod (following steps highlighted in red) click "New Mod...", make sure you have "Civilization VI" selected (should be by default), then choose "Empty Mod".

Note the green highlighting, these settings mark the directory your mod will be stored at. The checkbox indicates that there will be an additional folder added to the end of the "Location:" field with the name of your solution (so in this case "NewBuilding1" because I didn't change the name or select "Empty Mod" before taking the screenshot lol).



Mod Information

There should be a small dialog with some basic information such as mod name, description, author, etc. Just hit okay, I'm showing you next how you can change that later. You should focus on learning what you can do, not what you want to do; especially for your first mod.

Next, delete the ModArt.xml file. You won't be needing it, not for your first mod anyways. If you do need it you're probably biting off too much. The purpose of your first mod is to get you familiar with the environment, not to actually make a meaningful mod.

Mod Configuration

To see the mod's configuration right click the Project file ("EmptyMod1" in the image below) and choose Properties (bottom option). The project file will be opened and you'll be immediately taken to the "Mod Info" tab. Here is where you can change, at any time, the information you skipped when creating the project (i.e. Mod Name, Description, etc).



Now, I'm showing you this first because this is "center" of the mod. The project file contains the information telling the mod what to do with the files. If you just make a mod add the files and don't touch this part it won't do anything.

Adding Files to a Project

The project file will contain the "FrontEnd Actions" and the "In-Game Actions" tabs. 90% of the time you will be using the "In-Game Actions" tab. The "FrontEnd Actions" tab is only for things before you start the game (MainMenu, Game Setup Screen, etc). The "In-Game Actions" tab should contain the code for pretty much everything else.

In the image below you'll see Green and Blue highlighting (among others). The green comes first, then you can select one of the items highlighted in Orange and do the actions in Blue. The action type (Left Green) tells the game what to do with the mod files. The Blue tells the action which mod files.



Tools
Here are the tools (applications) I use while modding (other than the obvious Civilization VI SDK).

Both of these are open-source applications. Neither is needed though the SQLite browser is heavily recommended.


SQLite Browser Setup & Usage
  • Download the SQLite Browser (Portable version recommended).
  • Run it and you should see something similar but not the same as the screenshot below.
  • Click "Open Database" and navigate to your Cache Folder (See Folders section).
  • Open the DebugGameplay.sqlite (Note that the game may need to be running to see the file).
  • Once open you'll see 3 useful tabs "Database Structure", "Browse Data", and "Execute SQL" depending on your SQL knowledge these tabs will be of varying usefulness to you.
  • From these tabs you can see each table in the game, the data in each table, and execute SQL statements respectively.

The SQLite browser is immensely helpful when searching for examples of certain modifiers, requirement types, etc. It's slightly less helpful but still can be if you do not know SQL.

Errors & Troubleshooting
The most common set of errors you'll run into when starting out are syntax and foreign key reference errors. These are caused by typing something wrong (syntax) or not inserting a value (foreign key reference; which also can be caused by inserting a reference to something before it has been inserted itself).

The screenshot below contains examples of these types of errors (highlighted in red). The yellow lines are (roughly) each time I clicked "Start Game" at the main menu. These errors populated the database.log file in the Log Folder (See Folders section) when the game was at the loading screen.

Note - The reason I suggested Notepad++ in the tools section is that you might have the log file open before the error is thrown in there. With regular notepad you'll have to re-open the file, however; with notepad++ it will detect the file has been changed and ask you if you'd like to reload it.


The log files inside the Log Folder are a valuable set of files. Some of them more than others. For instance, the database.log shows syntax and database errors and the gameeffects.log shows issues with modifiers. These are the only two I know for certain but just knowing that the logs are there and that you can check them at least gives you a place to look when you're not sure what's going on.

Quite commonly the symptoms of there being an error in the database.log file is that something you've attempted to change is just not even remotely in the game. This was happening to me a LOT before I knew about these log files. After I found out it started taking me less and less time and I started correcting the behaviors that caused those errors in the first place (e.g. forgetting semi-colons after SQL statements).

Pitfalls
Below I will list some of the pitfalls of modding that I have discovered so far.

Arguments: I have found that if you misstype an argument (e.g. ModifierArguments, RequirementArguments, etc) value no error will be presented. I had "GENREAL" instead of "GENERAL" for a 'GreatPersonClassType' argument and it never displayed an error anywhere.

CollectionTypes: If you attach a modifier to the wrong CollectionType (defined in ModifierType AKA DynamicModifiers table) it's not necessarily going to come right out and tell you that it's wrong it may simply just fail to work with no errors present.

So becareful and double check these things when you've checked there are no errors and your mods aren't working (e.g. in these cases my text changes were occuring but the actual change wasn't taking hold).
Text & Localization
Civilization VI Text

In Civilization VI there is a lot of text. Text for units, civilizations, traits, promotions, etc, etc. You might think that it would make sense to put each unit's name, description, etc in the unit table along with its attributes like cost, movepoints, etc. but this is bad (see reasons below).

  • Languages - There are a lot of different languages a game might be translated into. Are you going to have a column for the name of a unit for each language? (e.g. EnglishName, RussianName, SpanishName, etc). No, this wouldn't make sense.
  • Performance - Civilization VI runs on a database via SQLite database tables with more data in each row tend to have slower performance.
  • Development - Keeping things separate yet connected allows teams to work on different parts of the game at different times. For example, in the early stages of the game's development the unit table might not have existed yet but everyone knows certain units will exist in the game and the person responsible for the names and descriptions might want to get a head-start on them. So having text in a separate table makes sense.

LocalizedText

Alright, so we've concluded that the text for each entity in the game is stored in a text table. That table's name is LocalizedText (I believe there are other very very minor ones but they're not important; if they exist).

The core of this table is represented by the following columns,
  • Language - en_US (English), de_DE, es_ES, fr_FR, etc. I'm going to go ahead assume you know your language.
  • Tag - This is a unique key to identify this text. Other tables simply reference this key so they know what text to grab from this table.
  • Text - This is the text you want to show. "Warrior", "ABORT MISSION!", etc.
  • Gender - NULL for English. Since I only know the English language I can't help you too much here, just look in the table for examples and I'm sure you other language speakers can figure it out.
  • Plurality - Again, NULL for English.

Tags & Conventions

If you look in the LocalizedText table you'll notice that 95% of the tags in there begin with 'LOC_' and have underscores separating words. This is the convention that Firaxis used; quite often you can simply just know what a string is for by reading the Tag or if you don't know the tag for something you can guess it based on what it is. For example, you want to know the tag for the warrior unit, well based on Firaxis' convention start with 'LOC_' what it is 'UNIT_' its base name 'WARRIOR_' and what you want 'NAME' so the tag for the warrior unit's name is 'LOC_UNIT_WARRIOR_NAME' which when you're looking at the data/code for the unit it seems obvious and excessive but can be helpful at certain times.

Note, that there is one single benefit to not using Firaxis' conventions and that is if you use some other prefix other than 'LOC_' you almost guarantee yourself to never have a conflict. I still recommend using a convention, whether you stick with Firaxis' convention is up to you.

Creating your own text

Let's say you're me and you've created a leader trait for Catherine De Medici. The trait has two pieces of text associated with it, the name and description. These two pieces of text will each need their own entries for each language you want to implement (I only do English because, again I don't know any other spoken languages). Below shows the SQL syntax for inserting the text records for my Catherine's Scout trait mod.

INSERT INTO LocalizedText (Language, Tag, Text) VALUES ('en_US', 'LOC_TRAIT_SCOUTS_IGNORE_BORDERS_NAME', 'Catherine''s Scouts'), ('en_US', 'LOC_TRAIT_SCOUTS_IGNORE_BORDERS_DESC', 'Catherine''s scouts are able to enter other civilizations'' borders without permission.');

The tricky thing to note here is that if you want to use an apostrophe in SQL you need to do two of them to escape it. Otherwise you'll get syntax errors because it thinks that's the end of the string.

Four small sections later and you now know everything I know on mod text in Civilization VI.
Kinds & Types
At the base of the Civilization VI modding heirarchy there are two tables Kinds and Types. It is likely you will need to create an entry in the Types table for almost every piece of functionality or content you mod in Civilization VI.

Kinds

The Kinds table is a table where the game's code and scripting meets the game's data. Somewhere in the game's code the kind KIND_ERA is hardcoded to be exactly that, what we think of to be an era in game. Likewise, the kind KIND_DIFFICULTY is used to tell the type DIFFICULTY_SETTLER that it is a kind of difficulty and to list it as such.

Types

The Types table is the basis for almost everything in the game. If it's in the game chances are there's a type associated with it. Each belief has a type, each building has a type, each unit has a type, and so on and so forth. Each type is associated with a Kind from the Kinds table so that the game's engine knows how to handle that Type. So as I stated above, the DIFFICULTY_SETTLER type is associated with the KIND_DIFFICULTY so that the game knows to list it as a difficulty in the difficulty settings drop down; however, a type is not the only thing you need in order create a difficulty setting but it's the start.


The Heirarchy and their tables

Below I'm going to review each table's columns and how they associate with each other. I'm going to use the Difficulties heirarchy (all tables involved in creating a difficulty setting) for the purpose of example so you're not just seeing the theory of Kinds and Types but how they exist in game.

Kinds
  • Kind - The name of the Kind. Typically in all caps and prefixed with KIND_. e.g. KIND_TRAIT, KIND_DIFFICULTY, KIND_CIVIC, etc.
  • Hash - This is simply an auto-generated number associated with the Kind column so that the game's engine may more quickly access it (for all intents and purposes you can ignore this one).

Types
  • Type - The name of the Type. Typically prefixed by the singular version of the table it's associated with. e.g. Types for the Difficulties table are prefixed with DIFFICULTY_ e.g. DIFFICULTY_SETTLER, DIFFICULTY_CHEIFTAIN, etc.
  • Hash - Same as the kinds table but for Type.
  • Kind - The Kind associated with this Type. The Kind you put in this column must exist in the Kinds table otherwise you'll get what is known as a foreign key constraint error.

Difficulties
  • DifficultyType - Similar to Kind in the Types table; Refers to a Type in the Types table. Specifies which type (e.g. DIFFICULTY_SETTLER, DIFFICULTY_CHIEFTAIN, etc) you are going to associate with this difficulty entry.
  • Name - The display name of the difficulty type. Typically this will be a key to the name starting with LOC_ (see the Text & Localization section for more information).
  • DefaultDifficulty - I'm not entirely certain the purpose of this column. It is a boolean column meaning it's only values are True (1) or False (0) and it defaults to True. So I speculate that it has to do with whether it is displayed in the usual settings (perhaps ones set to false are used for something such as scenarios?).

DifficultyTraits
  • DifficultyType - As with the Difficulties table this is the Type you're working with from the Types table.
  • TraitType - This will be another reference to the Types table but for a Trait (of KIND_TRAIT) instead. In database terms this is what is commonly called a Link Table because it doesn't have data of its own it merely links two other things together. In this specific case we're linking a difficulty type with a trait so that you may provide certain bonuses (positive or negative) to the player based on their difficulty level.
Traits & Modifiers
Modifiers
Modifiers are one of the most common ways to make a change to the game. If it's not just simply a number, chances are it is a modifier.

Examples of Modifiers In-Game:
  • Plot Yield Changes (e.g. Natural Wonders, Tech Advancements, Adjacency bonuses, etc).
  • City-State Benefits (e.g. +2 Faith, +2 Science per Campus, Free strategic resources from Hatusa, etc).
  • Great People (e.g. General Passive and all retirement effects except Great Works).
  • I think you get the point.

How do Modifiers fit into the Hierarchy?
Previously, in the Kinds & Types section, I mentioned how Types use Kinds to associate to the specific lists in the game's code. The Types table is simply a list of everything that exists in game and what its Kind is. Alone, it is worthless but without it nothing exists.

Modifiers can be connected to various things in-game (e.g. Beliefs, Buildings, Governments, etc). These things, as you've probably figured out, have their own tables named after them. These tables also have Link Tables connecting them to Modifiers. These link tables are always of the name <Object>Modifiers (e.g. BeliefModifiers, BuildingModifiers, etc). These tables simply tell which object (belief, building, etc) has which modifier(s).

Traits
Traits are pretty simple. They contain one or more modifiers and associate themselves to other objects. Just like Modifiers, Traits are associated to various objects (e.g. Civilizations, Leaders, Difficulties, etc).

Hierarchy so far
  • Kinds
  • -- Types
  • ---- Objects (e.g. Beliefs, Buildings, Governments, etc)
  • ------ Modifiers
  • ------ Traits
  • -------- Modifiers

So Objects can be associated to Modifiers or Traits (depending on the object) and Traits are associated with Modifiers too. So Traits are like named containers for Modifiers.
Dynamic Modifiers & Game Effects
Game Effects
Game effects are at the core of Modifiers. Similar to Kinds, they are what are hard-coded into the game, sometimes with customizable pieces (aka Parameters; I'll explain them later). Usually, these are named well enough to figure out or guess what they do; however, some of them will take some investigation work (look into what modifiers use them and learn what they do to better understand what the Game Effect does).

Dynamic Modifiers
Dynamic Modifiers sit between Modifiers and Game Effects. They effectively connect the two together. Dynamic Modifiers is a lot like the previously mentioned Link Table except that it also tells the game what to apply the Game Effect to via the CollectionType field. The CollectionType has values such as COLLECTION_ALL_PLAYERS, COLLECTION_ALL_CITIES, etc. indicating that the game effect associated with the dynamic modifier will be applied to players, cities, etc. Don't get thrown off by the fact it says "ALL" players or cities, you can restrict which players or cities are affected with Requirements and RequirementSets which I'll explain later.

Modifier Hierarchy so far
  • Modifiers
  • -- Dynamic Modifiers
  • ---- Game Effects
  • ------ Game's DLL Code
Komentarzy: 47
Brickburd 10 sierpnia 2024 o 9:56 
How do i upload an existing mod (ie, a civ i made in Civ-Blitz) to the Steam workshop so i can play it with my friend?
Angryr  [autor] 20 stycznia 2024 o 22:13 
If I recall correctly (it's been years at this point), I think you have to like run the game with those expansions enabled and the additional files appear in the same directory, maybe?? Hope this helps, but it's been forever since I've done any Civ modding.
Lord Of the flies 20 stycznia 2024 o 15:30 
Hey , trying my hand at modding here. How can i find the tables for expansion in Cache Folder. I open up Debug Gameplay in Sqlite lite and only can see base game tables. Cant see DLC tables.
STuRoK 23 lutego 2023 o 0:52 
Thanks D34DLY. I was just about to ask how to make the .modinfo or where the hell it was since built it multiple times. why doesn't this guide mention the .modinfo at all??

"but when you "build" it, the .modinfo file is placed in:
Documents/My Games/Sid Meiers Civilization IV/Mods"
Direct Steam uploader to this folder
JacK 16 lutego 2023 o 7:56 
Hi, i would like to upload my custom theme front page music, can u help me out with that?
Und3r6r0und Productions 1 sierpnia 2021 o 20:44 
yea, i just want to play a mod. how do i do that
i understood none of that
Erenussocrates 18 lipca 2021 o 7:13 
Hello, I'm new to Civ 6 modding. I've watched a tutorial on youtube and also viewed a few guides here on steam community as well. What I don't get is, when I'm creating a new custom district or building type, or even a new unit; how do I set it's custom yields as however I want? For example let's say I want to create a cheaty civ so I want to set insane parameters. But I couldn't find where we declare those kinds of stuff.
D34DLY 5 czerwca 2021 o 22:29 
Took me a while (many hours) to figure it out, but the initial mod is saved in:

Documents/Firaxis ModBuddy/Civilization VI

but when you "build" it, the .modinfo file is placed in:

Documents/My Games/Sid Meiers Civilization IV/Mods

I was looking in the first location where the files were made, frustrated that the .modinfo file wasn't being also being created. Posting this in case someone else has this same problem.
ChessPro2007 24 kwietnia 2021 o 10:39 
I think there is something wrong with this Mod Info file:
<?xml version="1.0" encoding="utf-8"?>
<Mod id="5b067f6d-78ea-4bdf-9acd-29ccfce218a2" version="1">
<Properties>
<Name>Additional Policies</Name>
<Description>Add multiple new policies.</Description>
<Created>1590965501</Created>
<Teaser>Add multiple new policies.</Teaser>
<Authors>ChessPro2007</Authors>
<AffectsSavedGames>0</AffectsSavedGames>
<CompatibleVersions>1</CompatibleVersions>
</Properties>
<InGameActions>
<UpdateDatabase id="Gameplay">
<File>Gameplay.xml</File>
</UpdateDatabase>
<UpdateIcons id="Icons">
<File>Icons.xml</File>
</UpdateIcons>
<UpdateText id="Text">
<File>Text.xml</File>
</UpdateText>
</InGameActions>
<Files>
<File>Gameplay.xml</File>
<File>Icons.xml</File>
<File>Text.xml</File>
</Files>
</Mod>
ChessPro2007 4 kwietnia 2021 o 11:50 
Ok, thanks