Galactic Civilizations IV

Galactic Civilizations IV

Not enough ratings
Making a simple mod
By Draver and 1 collaborators
This guide will teach you the basic principles on how to mod GCIV XML files through an easy to implement example
   
Award
Favorite
Favorited
Unfavorite
Introduction
In this tutorial you will learn how to make a simple mod that adds a repeatable Terraforming Project which gives you an artifact charge that increases the number of tiles on a core world. The principles you will learn here can be applied to make all sorts of other modifications to the game.

Note that while the principle you learn here will remain the same, as the game changes from patches to patches some of the specific details may vary. A good example of what could be different is the number of tiles that the added terraforming project will provide: in a later version of the game, that number was increased to 3 tiles instead of 1. As balance evolve, these kind of small details may change.

This tutorial expects you to have some basic knowledge about file editions, etc.
Setting up the folder and file structure
First, you will need to get your hands on Notepad++[notepad-plus-plus.org] a very powerful editing tool.

Once installed, head over to your GC4 install folder.
It should be somewhere like D:\SteamLibrary\steamapps\common\Galactic Civilizations IV.

From there you will open two XML files in Notepad++:
ImprovementDefs.xml from the Data/Gameplay folder
and
ImprovementText.xml from the Data/English/Text folder.

ProTips: You can open all the XML files from the Gameplay folder in Notepad++ and do search in all the files at once using CTRL-F and the "Find All in All Opened Documents" button; very useful when you are trying to find a specific instance of something and don’t know in which files it’s listed.

Now head to your GC4 mod folder.
It should be somewhere like C:\Users\YourUserName\Documents\My Games\GalCiv4\Mods.

There create a new folder that will contain your mod; you can name it anything you want. Let’s use TerraformUP for this exercise.

Now go into ExampleMod and copy the Data folder there into TerraformUP. You should end up with a folder structure like this:
 
Now these are only folders, with no files in them yet. To add some files, we’re going to go into Gameplay and create a new empty file named ImprovementDefs_mod.xml. Open it in Notepad++. Now go back to your Data folders and open the Text folder and create a new empty file in there named ImprovementText_mod.xml. Open it in Notepad++.

ProTip: You can drag and drop the file tabs in Notepad++ into an empty space on your desktop to open a new instance of Notepad++ showing that tab. You can then drag and drop tabs between instances of Notepad++ for easier editing.

At the end of all this you should have four files open in Notepad++:
ImprovementDefs.xml
ImprovementText.xml
ImprovementDefs_mod.xml
ImprovementText_mod.xml
Let's start modding
Now our goal is to add a new core world Project that produces a vault charge, so lets use something that already exists in game that does something similar and we'll modify it.

Head into ImprovementDefs.xml file from the base game that we opened earlier. In there we will find the ConstructBroadcastModule. It's exactly what we’re looking for: it allows you to build broadcast modules artifact charges, very much like what we are trying to do.

So in Notepad++ do a search (CTRL-F) and look for ConstructBroadcastModule. This should lead you to a block of information between <Improvement> </Improvement> for the Broadcast Module.
 
Select this block like in the above picture and copy it into ImprovementDefs_mod.xml. We’ll use it as a base for our new repeatable project. Make sure you only modify things inside our modded xml.

Now to make our modded file compatible with GC4 mod system, we’ll need to copy the header and footer at the start of the file and end of the file of ImprovementDefs.xml into the mod file (check the screenshot below for the final structure):

Header
<?xml version="1.0" encoding="utf-8" standalone="yes" ?> <DefaultImprovementList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Schema/ImprovementDefs.xsd">

Footer
</DefaultImprovementList>

We can now change the various values to what we want, with the most important lines being
<PerformAction> <Action>GiveArtifactPower</Action> <StringParam>PlanetTiles</StringParam> </PerformAction>
Which will give the PlanetTiles artifact charges to your vault once that project is built.

Change the internal Name, Display Name and Descriptions tag to something else. We’ll add new text strings in ImprovementText_mod.xml later that reference theses.
<InternalName>ConstructPlanetTiles</InternalName> <DisplayName>ConstructPlanetTiles_Name</DisplayName> <ShortDescription>ConstructPlanetTiles_ShortDec</ShortDescription> <Description>ConstructPlanetTiles_Dec</Description>

Choose an icon for your new project. The one below is taken from the PlanetTile artifact charge, so the icon matched the power it’ll give you.
<Icon>artifact_small_17.png</Icon> <BuildIcon>artifact_small_17.png</BuildIcon> <ListIcon>artifact_small_17.png</ListIcon>

Increase the cost to something that makes sense, 300 is a good start for such a powerful artifact.
<BonusType>Flat</BonusType> <Value>300</Value>

Change the tech requirement to Terraforming which all civilizations get access to one way or another.
<Techs> <Option>Tech_Terraforming</Option> </Techs>

Remove the RaceTrait prerequisite if you want to make this accessible to all civilizations and not just Synthetics

Notice the CivilizationCapital requriment, this means that the project can only be built on your capital world with the Civilization Capital in place.

With all these changes, here’s how the final file should look like.
Adding some descriptions
We’re almost done. Now let’s put some interesting text for our icons and description in game. Switch to ImprovementText.xml and do a search for Broadcast Culture. Copy in ImprovementText_mod.xml the block you find between the StringTable for both the Name and ShortDec has shown below.
 
As with the other file you’ll also need to copy the header and footer at the start of the file and end of the file.

Header
<?xml version="1.0" encoding="utf-8" standalone="yes"?> <StringTableList xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../../Schema/Lib/StringTable.xsd">

Footer
</StringTableList>

Now let’s modify the entries to match what we changed in ImprovementsDefs_mod.xml.
<Label>ConstructPlanetTiles_Name</Label> <String>Modify Planet</String>
and
<Label>ConstructPlanetTiles_ShortDec</Label> <String>Produces a Modify Planet charge for our Vault which can be used to add a tile on a friendly planet.</String>

We should end up with a file looking like this
 
Now if you haven't done so already, save your two modded files in notepad++.
Testing your mod
Time to test it out. Launch GC4 and go in the settings and enable mods. Restart GC4.
 
Create a new game with any of the civs. Go in the Technology Library and scroll down to Terraforming. Mouse hover and you should see Modify Planet in the list of Unlocks.
 
If you want to test it out quickly, make sure you have Cheat enable in Steam launch options like this.
 
In game hit the ~ key to bring up the console and type unlock all 0 to unlock all techs. You can also use the fastunlock command.
 
Go on your homeworld, place the Capital City and Voila! You can now use the Modify Planet project at will.
 
It’ll give you access to a vault charge when it finishes.
Conclusion
Using these principles you can now go through the XML files and make your own addition at will. In this example, what we did is append the game files to add a new project. If you want to modify a value found in the base game XMLs you may need to use the Modify method instead. To do so, you can read ModdingReadme.txt in the Mods folder which will give you guidance on how to make this happen by using the proper Header and Footer for your modded files.

For even more advance modding, you can delve into the Schema files found in .../Galactic Civilizations IV\Data\Schema folder and discover functions not currently in use in the XMLs but still available to you.

If you have questions or would like to dig deeper into modding, feel free to hop on Galactic Civilization Discord[discord.gg] modding channel. Many enthusiast modders will be happy to help you out.

Happy modding!
4 Comments
Draver  [author] 28 Dec, 2023 @ 6:55pm 
You're welcome! Come over on Discord if you want to ask more questions, the modding channel is a good place to ask questions about it.
weregamer 28 Dec, 2023 @ 5:34pm 
Thanks for doing this. I still have lots of unanswered questions but a working example is pure gold.
Draver  [author] 25 Oct, 2023 @ 7:28am 
You're welcome!
ops 23 Oct, 2023 @ 8:26pm 
TYVM Draver for this guide !