Hearts of Iron IV

Hearts of Iron IV

30 ratings
Getting Started With Modding!
By AnorakRaven
A guide showing off the basics of modding. Information taken from The Iron Workshop here.
   
Award
Favorite
Favorited
Unfavorite
Introduction | Things To Keep In Mind, Resources, & Useful Tools
So, you wanna learn how to mod?
Hearts of Iron IV is a great game to mod due to its ease of use, integrated mod support, and simplicity. Allow me to make it very clear:

You do not need to know programming, you do however need to know SYNTAX,

which we will get into shortly. I also wish to say that while you CAN make mods which require DLC, I highly recommend disabling DLC and building up the majority of your mod before making forays into adding DLC-based content or functionality. Even if Paradox has sold off core parts of the game as aftermarket content there's still plenty of functionality in vanilla. There's more effort involved in making mods compatible with Vanilla, whether or not that's worth it is up to you.

Tools of the Trade

Visual Studio[code.visualstudio.com] isn't as lightweight or speedy as something like Notepad++, however there's actually a few incredibly useful extensions for modding HoI4 with it. Go to the Extension tab, then put these terms in the search bar in order to subscribe to each extension.

tboby.cwtools-vscode
chaofan.hoi4modutilities
tboby.paradox-syntax


Image Editing Software is a necessity for adding in, editing, or removing things like leader portraits, flags, general & field marshal portraits, etc. For this I highly recommend https://www.getpaint.net/ and/or GIMP (GNU Image Manipulation Program.)[www.gimp.org]

XnConvert[www.xnview.com] is used for editing/modifying image data/formatting, things like metadata, color depth, changing size and rotation, etc are what this will be used for. Its also able to do this in batches instead of having to go one-by-one through each image.
https://hoi4modding.com/ is extremely useful for streamlining the process of modding the game, however I'd recommend reading this guide before looking into using it as this allows you to get an underlying understanding of what the website is doing on the back-end, its nothing more than a GUI.
LukeZurg22's Flag Converter[github.com] allows you to take any bitmapped image (JPG, PNG, etc) and convert it into the TGA fomat used for the flags in-game, it also automatically creates the small, medium, and large versions for each flag while allowing you to convert them and drop them directly into the directory where HoI4 will use them.
Resources

Hearts of Iron 4 Modding Subreddit (and their discord by extension.)
Filled with highly knowledgeable and experienced modders, everything from the RT56 staff to Kaiserreich and makers as of yet unreleased mods thrive here.
Hearts of Iron 4 Wikipedia Modding Page[hoi4.paradoxwikis.com]
Incredibly useful even if a bit outdated at times.


Final Note

Custom Countries are first because everything in the game links back TO the countries and their respective files & directories. While you can make mods for the vanilla nations and expand upon what's already in the game, this guide's primary focus is on adding in new content, not editing or replacing the old (it should still come in handy in that case however.)
Introduction | Setting Up Quick-Launch & Debug Mode
You're going to be opening and closing the game hundreds if not thousands of times throughout this process, so to speed up that process (and enable the debug mode) we're going to make a custom shortcut that you can use to kick you straight in game and completely bypass the launcher.

But wait! What's debug mode?
Debug mode (or developer mode if you wanna call it that) allows you to make in-game edits to the map, nations, and other such things while also allowing you to view information needed in order to develop mods (such as the file paths for images, the IDs of states & provinces, etc.) at a moments notice. Perhaps its best features are how it automatically opens the error.log file to let you see if you committed any errors while developing your mod, it also automatically updates the game and allows you to save DIRECTLY TO YOUR DOCUMENTS FOLDER whenever you wish to save changes via the "Nudge!" option. Even if it isn't perfect, it is damn close to being so.

Enabling Debug Mode & Side-Stepping The Launcher.

Step 0| Go into the launcher, edit any settings you wish, then go in-game and do the same. Any setting you make in the base game will then carry over to the debug mode.

Step 1|Go to your C:\Program Files (x86)\Steam\steamapps\common\Hearts of Iron IV folder and look for the hoi4.exe file. Make a shortcut of it and move the Shortcut wherever you want (Start menu, desktop, taskbar, etc.)

Step 2|Right-click the shortcut, click properties, select the target address field.

Step 3|On the end of the target address field, add on a -debug mutator.
Syntax
Syntax is a form of coding that is used by the devs and modders alike to give commands to the game and change the behavior of various different parts of the game. All Paradox games have a roughly similar syntax structure, as such you can expect to be able to roughly translate your modding skills from one Paradox game to another (like talking to people of different dialects or from different regions that share a mother-language.)

Things to Know

Syntax within HoI4 does not allow the usage of spaces, it instead uses underscores (_.)

You can combine various different forms of syntax, as you get more skilled and more complex in your modding endeavors this will become mandatory.

YOU'RE GONNA SCREW UP! BUCKLE UP AND GET READY TO READ THE ERROR LOG A TON.

Types of Syntax

Effects are single-use triggers that can be used on a country, leader, or state, for example: GER = {army_experience = 50 } will add 50 army experience to Germany.
https://hoi4.paradoxwikis.com/Commands
Conditions are used to retrieve info for an object in-game (I.E Country, state, or leader.) An example would be GER = { has_idea = { bitter_loser } } in order to tell the game to check if France has the Bitter Loser National Spirit (Yeah yeah, Spirit is different from ideas, sue me.)
https://hoi4.paradoxwikis.com/Conditions
Modifiers apply a permanent or temporary, time-based debuff utilizing percentages. A good example would be core_manpower 0.34
https://hoi4.paradoxwikis.com/Modifiers
Scopes are used for locating an object (country, state, leader, etc) when we don't know the specific identity for it. This can be used to mass-apply buffs from focus tree paths and is how things such as the +Opinion focus modifiers work, (ya know, the ones where you gain +20 relations with multiple countries?) An example would be: every_country = {
limit = {
has_war_support < 0.9
} add_political_power = 200
}
https://hoi4.paradoxwikis.com/Scopes
Flags are (no, not the actual flags you see in-game) are used to mark an object in order to apply an effect or scope it more easily, think of it as grouping certain objects together based on their category ( set_country_flag ) will set flags based on whether or not an object is a country.

Booleans allow you to determine a specific parameter within the game, these are purely yes/no values and will often be used to check things like if a country is at war or if they have capitulated.

Base Code otherwise known as Core code, this allows you to define what part of the game you are changing and then tell the game that. things like focus branches (focus = {},) news events ( news_event = {} ), etc fall under this category.
Creating a Mod Template
Creating a mod template is simple.

Step 1|Launch the game from Steam in order to open the Paradox Launcher, click the mods button.

Step 2|Click the 'Create Mod' button, assign it a version number and make a directory folder. This creates the bare-bone files needed to build any kind of mod.

The way mods function within HoI4 is that the game searches for mods (be they compressed packages like a steam workshop mod or loose files like the mod you just created) within the mods folder, scans what it adds/edits/replaces, and overrides the vanilla-game with those modifications.
That's all for now!
Yeah, sorry about this, I wish I could've made an entire guide for every single aspect of HoI4 modding but I'm not that ♥♥♥♥♥♥♥ insane. I'll start working on other guides which will sprout off from and link back to this guide here.
4 Comments
SoyPobre123 Jan 23 @ 9:38am 
step 2. Fuck you Paradox, make a Fucking modding tool
StarDroid877 Jan 16, 2023 @ 7:27pm 
Step 1. Do not unless you want to suffer.
motorass Nov 13, 2021 @ 9:15am 
Just FYI you don't need XnConvert or the flag converter if you use Paint.net
Khe-Tal May 10, 2021 @ 9:51am 
All those tools helped a lot! Since I am not a Steam modder, your method to activate debug helped a lot.