Modding

From Hearts of Iron 4 Wiki
Jump to: navigation, search

Modding, or creating mods, is the act of modifying the behavior of the base game (often referred as vanilla), either for personal use, or to release publicly to other players, for instance via the Steam Workshop.

As for all Paradox games, Hearts of Iron IV is moddable to a great extent. Motivations of modders may vary widely: better translation to native language, more events or decisions, better map, major overhaul, etc.

This guide is intended to lower the entry barriers to the world of Hearts of Iron IV modding. However, there is still a learning curve to it, and it cannot replace the need to read some working vanilla code, and do lots of trial and error experimentation!

Guidelines[edit]

  • Never modify game files: use a mod even for small changes, and never modify directly game files in Steam Hearts of Iron 4 folder, as your changes may be undone without warning.
  • Use a good text editor (like Atom, Notepad++ or Sublime Text) to edit files and search into multiple files.
  • Minimize overwrites of vanilla files by adding separate files and loading from folders whenever possible, to improve mod compatibility and maintenance. (Your files can have any name, all files in the folder will be loaded by the game. So choose a name, no one else will ever use, like the name of your mod. Ex: coolmod_countries)
  • Use a proper merge tool (like WinMerge), to merge between folders, and update modified vanilla files to a new vanilla patch.
  • Backup your work to avoid losing everything. Consider using a source control system like Git and a collaborative forge like GitHub to manage team collaboration, or just make a copy of the file somewhere else.
  • Use UTF-8 encoding for text files.
  • Use UTF-8-BOM for localisation files (.yml).
  • Indent properly to easily spot unclosed curly braced. Vanilla uses 1 tab for indentation rather than spaces.
  • Use comments starting with # character, to remember reasons for writing tricky stuff.

Mod structure[edit]

Mods are located in the folder ~/.local/share/Paradox Interactive/Hearts of Iron IV/mod or C:\Users\<Username>\Documents\Paradox Interactive\Hearts of Iron IV\mod, which must contain:

  • the '.mod' file, to tell the launcher what to do with the mod-folder.
  • the mod folder or zip containing the mod data. The mod data must have the same file and folder structure as the game's directory itself.

(Subscribed and downloaded mods from the steam workshop are in .../Paradox Interactive/Hearts of Iron IV/workshop/content/394360)

Note that folder and file names are case sensitive on Mac OS X and Linux.


For example, to create a mod called "Test1", create a new text file called test1.mod and a folder named 'test1' within ...\Paradox\Hearts of Iron IV\mod.

The contents of test1.mod should be as follows:

name="Test1"
path="mod/test1"
tags={
	"Alternative History"
}
supported_version="1.0.0.19987"

This is done to provide the game launcher with information about the mod. This includes the mod's name, location (from the mod file), tags (extra descriptors), and supported game version.

As Mods can modify the game using the same structure as the game directory.

For example, a simple modification could be changing test that appears in the game.

To change the quotes that appear in the loading screen, copy the "localisation/loading_tips_I_english.yml" file from the base install of the game, ".../Hearts of Iron IV/localisation/loading_tips_I_english.yml" to a "localisation" folder you create in the new "mod/test1" folder.

The file structure now looks like the following:

 ...\Paradox Interactive\Hearts of Iron IV\mod
     test1.mod
     test1 (dir)
       localisation (dir)
         loading_tips_I_english.yml

As "loading_tips_I_english.yml" is unaltered, the game will run the same as usual. However, if it is changed, the information will be used by the game instead of the usual "loading_tips_I_english.yml". Modify the "loading_tips_I_english.yml" file in the mod folder so that it contains this:

 l_english:
  LOADING_TIP_0:0 "Test1 mod"

When the game is loading with this mod active in the English language, the only quote shown will be "Test1 mod".

Understand that the Game will not check any further than the file directory for changes. If one is trying to add a line to a text file, one must copy the entire text file and add the line within said text file.


Mods downloaded from the Steam Workshop are treated differently than those manually installed or created.
Though the mods .mod files will appear in the mod folder (represented by a remote_file_id), The content of the mod will be stored in ...\Paradox\Hearts of Iron IV\workshop\content\394360\<remote_file_id> in a zip format.
The remote_file_id is an id given to mods from the workshop. The id is displayed as the name of the mod's .mod and zip files, but is further represented within the .mod and descriptor.mod files as such:

name="New Ideologies"
archive="workshop/content/281990/678893824/newideologies.zip"
tags={
	"Balance"
	"Gameplay"
}
remote_file_id="678893824"
supported_version="1.0.0.19987"

Game data[edit]

Image file formats[edit]

Use DDS format for images. Most of the files are saved in 8.8.8.8 ARGB, 32 bit unsigned sub-format. Some files (like leader portraits) are saved using 1.5.5.5 ARGB 16 bit unsigned variant. Event Image can also be of the .tga format

Tools & utilities[edit]

  • Atom - Powerful, hackable, free open source editor from GitHub.
  • Notepad++ - Powerful editor to change files.
  • Maya exporter - Clausewitz Maya Exporter to create your own 3D models.
  • FETM - Useful graphical tool for viewing and editing National Focus trees.
  • Steam Workshop - The place for where you can share your creations with other players.

See also[edit]

References[edit]