Hearts of Iron IV - Development Diary 52 - Modding

  • We have updated our Community Code of Conduct. Please read through the new rules for the forum that are an integral part of Paradox Interactive’s User Agreement.
Status
Not open for further replies.

podcat

Game Director
Paradox Staff
12 Badges
Jul 23, 2007
12.792
38.280
  • Europa Universalis IV
  • Hearts of Iron III
  • Semper Fi
  • 500k Club
  • Europa Universalis III: Collection
  • Europa Universalis IV: Pre-order
  • Hearts of Iron II: Beta
  • Europa Universalis: Rome Collectors Edition
  • Mount & Blade: Warband
  • Paradox Order
  • Hearts of Iron IV Sign-up
  • Hearts of Iron IV: Together for Victory
Hi everyone, this weeks diary is going to get really technical! We will be talking modding and improvements we have made for the modders in HOI4. This is also going to be a very long one :)

When starting out we decided we wanted to make HOI4 our most moddable game yet. That meant not hard coding things (HOI3 had a lot of hard coded logic and references to certain nations). In HOI4 all these things are in soft code, or part of scenario script setups making it a much better platform for cool mods. We have also decided to include the tool we use (more further down), and while it is provided as-is and not really polished compared to the real game its very useful. The game is also much better at letting you know when you have made mistakes and everything that can go wrong will usually let you know with logs etc.

Tools and Getting Started
Getting started with the creation of mods are now easier than ever before!
Using the launchers mod tool will allow you to create an empty mod for the game without any hassle and without even starting the game.
XdASvVf.jpg


Then starting the game with the “-debug” flag will enable the “modder mode” that adds some extra sanity checks and enabling tools useful for modifying the game.
For example the in game Nudger tool that provides a simple interface to modify the properties of the map.
asMGY54.jpg

TVGwM7x.jpg

Here I created the awesome state of Östergötland by redistributing some provinces from Småland and tweaked the positions of the buildings.
The Nudger tool will then validate my changes and save them to the appropriate files for me and my mod, just in a few mouse clicks.

These files are of course human readable and can easily be edited with your favorite text editor for more advanced scripting or making smaller changes, most of the files (like state history setup) also have the option to be opened with a external program from the Nudger so you do not even need to find them in the filesystem.
YKRLmUq.jpg


Another nice tool is the instant feedback system aka “Error Dawg” appearing in the lower right corner that will give you instant feedback about scripting errors and oddities during gameplay. Clicking on it will of course open the error log for you, painfully reminding you about things you have forgotten or otherwise faulty scripted.
tOuBWK3.jpg


When satisfied with your mod and fixed all the errors you are just one click away from sharing it with the rest of the HoI4 community by uploading it to the steam workshop with the Mod tool.
LPI3un5.jpg


Another thing we have put a lot of effort into is reloadability. You can reload interfaces (even automatically as the game will check if files are modified and you will see changes instantly ingame) as well as several game systems. For example focus trees will reload with your changes making it really quick and easy to work with making them and not forcing you to restart the game all the time.

Scripting & Language Improvements
One of the small help functions we’ve put in is the console command “trigger_docs”. This will print a list of all the triggers and effects we have in the game along with a small description of how they are used. We hope this can be a useful tool for new modders to find what they’re looking for and old modders to discover hidden possibilities. We of course still have the beloved debug dog to bark at you when something is wrong.

We’re continuously trying to improve the user-friendliness in our script language itself. Therefore we try to take the good practices that has been introduced in our other games and integrate them to all of our titles. One of the later additions that we’ve ported over is scripted effects and triggers which function is that you can basically macro that can be referenced in the various script files of the game that will execute a whole block of an effect or a trigger respectively.

An example of this could be that you might want to show one event option for Germany's neighbors that they are not in a faction with and a different event option for the rest of the world. This could be a common occurrence for all of your events and this would require all of those event options to have the following trigger:

Code:
any_neighbor_country = {
    tag = GER
}

NOT =  { is_in_faction_with = GER }
This could instead be created as a scripted trigger which we would define in the scripted_triggers folder in the game files as the following:

Code:
is_neighbor_not_in_german_faction = {
    any_neighbor_country = {
        tag = GER
   }

   NOT =  { is_in_faction_with = GER }
}
Which could then be referenced in the different event option triggers as a one-line trigger (is_neighbor_not_in_german_faction = yes) in place of the multiple lines previously required.

As commonly used combinations of triggers and effects grow increasingly complex this script feature has two big functions. Firstly in that it decreases the amount of code duplication that would otherwise have been needed. And secondly it will also make the code easier to maintain since when you find yourself in the position that you have to change something in your common conditions for your events you could just add it inside the scripted trigger and just have to update one place instead of having to find all of the different places that would need to be updated.

Another great addition to the script language is the functionality of defining a particular scope as an event target inside an event or event chain, this feature has seen great usage in the script language of Crusader Kings II which always had an overload of scope changes.

The event targets makes it easier to reference different provinces and nations in the event text and execute effects on the correct targets without the need to have a huge amount of hidden bounce events to get the event scopes to evaluate correctly and keep track of different actors or locations. And if you want to get really creative you can try to combine these two script features and define event targets which you then use inside your scripted trigger or effect to have it act as a sort of sub-routine.

The AI
The AI in HOI3 was run though Lua scripts, but we decided to abandon these for several reasons in HOI4 (lack of lua knowledge at the company and low performance was the big ones). The AI is still however very moddable and has a lot of scripts to modify. I think its best to wait and talk about that in the dedicated dev diary on AI stuff I'll make @SteelVolt write before release though :)

Next week we'll have @Sideburnout talk about all things 2D art and interface for HOI4. See you then!

p.s whoever makes a Battletech mod first will forever live on in my heart.
 
Last edited:
  • 174
  • 162
  • 2
Reactions:

Super-Soviet

The Totalitarian Weeb
89 Badges
Jul 15, 2010
1.406
2.064
  • Tyranny - Tales from the Tiers
  • Hearts of Iron III: Their Finest Hour
  • March of the Eagles
  • Europa Universalis IV: Res Publica
  • Victoria: Revolutions
  • Rome Gold
  • Semper Fi
  • Hearts of Iron II: Armageddon
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • Sengoku
  • Europa Universalis IV: Pre-order
  • Crusader Kings II: Jade Dragon
  • Stellaris: Synthetic Dawn
  • Europa Universalis IV: Mare Nostrum
  • Stellaris: Galaxy Edition
  • Europa Universalis IV: Third Rome
  • Crusader Kings II: Reapers Due
  • Stellaris - Path to Destruction bundle
  • Crusader Kings II: The Republic
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Hearts of Iron III
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Conquest of Paradise
  • For the Motherland
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Art of War
  • Darkest Hour
  • Europa Universalis III: Chronicles
  • Stellaris Sign-up
  • Stellaris: Leviathans Story Pack
  • Stellaris: Digital Anniversary Edition
  • Tyranny: Archon Edition
  • Europa Universalis IV: Rights of Man
  • Victoria 3 Sign Up
  • Hearts of Iron IV: Cadet
  • Victoria 2
  • Hearts of Iron IV Sign-up
  • 500k Club
  • Stellaris: Galaxy Edition
  • Stellaris
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Conclave
Can we have formable nations? They aren't in vanilla, but the Stream seemed to imply that it is possible via modding.
 
  • 6
Reactions:

Nelfe

Hold the door
50 Badges
Apr 16, 2008
2.010
1.974
  • Arsenal of Democracy
  • Cities: Skylines - Green Cities
  • Hearts of Iron III
  • Lead and Gold
  • Magicka
  • Naval War: Arctic Circle
  • Europa Universalis IV: Res Publica
  • Europa Universalis: Rome
  • Semper Fi
  • Victoria 2: A House Divided
  • Victoria 2
  • Prison Architect
  • 500k Club
  • Cities: Skylines
  • Mount & Blade: Warband
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Cities: Skylines - After Dark
  • Stellaris
  • Hearts of Iron IV Sign-up
  • Hearts of Iron IV: Cadet
  • Stellaris: Leviathans Story Pack
  • Cities: Skylines - Mass Transit
  • Age of Wonders III
  • Cities: Skylines - Parklife
  • Cities: Skylines Industries
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Europa Universalis III Complete
  • Europa Universalis III Complete
  • Supreme Ruler 2020
  • Europa Universalis IV
  • Pillars of Eternity
  • For the Motherland
  • Europa Universalis IV: Call to arms event
  • Cities in Motion
  • Cities in Motion 2
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sword of Islam
  • Europa Universalis III
  • Europa Universalis III Complete
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
An example of this could be that you might want to show one event option for Germany's neighbors that they are not in a faction with and a different event option for the rest of the world. This could be a common occurrence for all of your events and this would require all of those event options to have the following trigger:

Code:
any_neighbor_country = {
    tag = GER
}

NOT =  { is_in_faction_with = GER }
This could instead be created as a scripted trigger which we would define in the scripted_triggers folder in the game files as the following:

Code:
is_neighbor_not_in_german_faction = {
    any_neighbor_country = {
        tag = GER
   }

   NOT =  { is_in_faction_with = GER }
}
Which could then be referenced in the different event option triggers as a one-line trigger (is_neighbor_not_in_german_faction = yes) in place of the multiple lines previously required

Just noticed this... Custom triggers :3
I want to marry you all. One of the best add to the scripting of the Clausewitz games.
 
  • 11
  • 2
Reactions:

Axe99

Ships for Victory
125 Badges
Feb 13, 2003
15.798
12.543
  • Europa Universalis IV
  • Stellaris: Lithoids
  • Stellaris: Federations
  • Crusader Kings III
  • Crusader Kings III: Royal Edition
  • Battle for Bosporus
  • Europa Universalis 4: Emperor
  • Stellaris: Necroids
  • Stellaris: Nemesis
  • Victoria 3 Sign Up
  • Crusader Kings II: The Republic
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Call to arms event
  • For The Glory
  • For the Motherland
  • Hearts of Iron III
  • Hearts of Iron III: Their Finest Hour
  • Heir to the Throne
  • Europa Universalis III Complete
  • Lead and Gold
  • The Kings Crusade
  • Magicka
  • Majesty 2
  • Majesty 2 Collection
  • March of the Eagles
  • Europa Universalis III Complete
  • Europa Universalis IV: Res Publica
  • Victoria: Revolutions
  • Rome Gold
  • Semper Fi
  • Ship Simulator Extremes
  • Sword of the Stars
  • Supreme Ruler 2020
  • Victoria 2
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • Rome: Vae Victis
  • 500k Club
  • Cities: Skylines
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Pre-order
  • Pride of Nations
  • Rise of Prussia
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Cities: Skylines - After Dark
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Conclave
Oh my word :D. Podcat I want to have your kittens! I was optimistic about modding capabilities in HoI4, but macro'd triggers and effects, editing tools, being able to open files in another file from within the editing tool, the emphasis on reloadability (the last time I modded anything was HoI1, and I _still_ wake up screaming from reloading it.....), trigger_docs. I'm literally pinching myself to check I'm not dreaming :D.

That Nudger's pretty awesome too. Probably not something I'd have a lot of use for myself, at least for my initial plans, but could it be used to perhaps make battle-style scenarios fairly quickly and easily (in comparison with fiddling around with text files).

And the debugging tools as well. It telling you what's wrong.

Seriously - this is so damn awesome :cool:. Unbelievably awesome, is what this modding support is. Cheers to you and the team for making it possible :D.
 
  • 16
  • 2
Reactions:

Zlovie

Captain
66 Badges
Mar 19, 2007
371
91
  • Europa Universalis IV: Cossacks
  • Victoria 2
  • Victoria 2: A House Divided
  • Victoria 2: Heart of Darkness
  • 500k Club
  • Cities: Skylines
  • Crusader Kings II: Holy Knight (pre-order)
  • Europa Universalis IV: El Dorado
  • Europa Universalis IV: Pre-order
  • Hearts of Iron: The Card Game
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Horse Lords
  • Sengoku
  • Crusader Kings II: Conclave
  • Europa Universalis IV: Mare Nostrum
  • Stellaris
  • Hearts of Iron IV Sign-up
  • Stellaris Sign-up
  • Hearts of Iron IV: Cadet
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV: Together for Victory
  • Europa Universalis IV: Mandate of Heaven
  • Europa Universalis IV: Third Rome
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis 4: Emperor
  • Europa Universalis IV: Art of War
  • Cities in Motion 2
  • Crusader Kings II
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Deus Vult
  • Europa Universalis III
  • Divine Wind
  • Europa Universalis IV
  • Hearts of Iron II: Armageddon
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • For the Motherland
  • Hearts of Iron III
  • Heir to the Throne
  • Europa Universalis III Complete
  • Europa Universalis III Complete
  • Europa Universalis IV: Res Publica
  • Rome Gold
There´s one thing I´m really curious of:

In the last WWW they mentioned that you can take anything you want, if you defeat an enemy. Is it possible to mod that, so that you can only take claimed states for example?
 
  • 5
  • 3
Reactions:

samin

Captain
101 Badges
Jun 21, 2012
310
486
  • Imperator: Rome Sign Up
  • Europa Universalis IV: Dharma
  • Warlock 2: The Exiled
  • 500k Club
  • Europa Universalis IV: El Dorado
  • Magicka: Wizard Wars Founder Wizard
  • Crusader Kings II: Way of Life
  • Pillars of Eternity
  • Stellaris: Lithoids
  • Europa Universalis IV: Common Sense
  • Stellaris: Federations
  • Imperator: Rome - Magna Graecia
  • Crusader Kings II: Conclave
  • Hearts of Iron IV: Death or Dishonor
  • Prison Architect
  • Stellaris: Galaxy Edition
  • Imperator: Rome Deluxe Edition
  • Hearts of Iron IV Sign-up
  • Stellaris Sign-up
  • Hearts of Iron IV: Cadet
  • Surviving Mars: First Colony Edition
  • Europa Universalis IV: Rights of Man
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Leviathans Story Pack
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Victoria 2
  • Europa Universalis IV: Golden Century
  • Age of Wonders III
  • Cities: Skylines - Green Cities
  • Crusader Kings III
  • Hearts of Iron IV: Expansion Pass
  • Stellaris: Humanoids Species Pack
  • Stellaris: Apocalypse
  • Europa Universalis IV: Rule Britannia
  • Cities: Skylines - Parklife
  • Stellaris: Distant Stars
  • Surviving Mars
  • Europa Universalis IV
  • BATTLETECH
  • Stellaris: Necroids
  • Europa Universalis III Complete
  • Europa Universalis 4: Emperor
  • Stellaris: Nemesis
  • Europa Universalis III Complete
  • Cities: Skylines - Mass Transit
  • Europa Universalis IV: Mandate of Heaven
  • Crusader Kings II: Holy Fury
  • Teleglitch: Die More Edition
  • Crusader Kings II
Another thing we have put a lot of effort into is reloadability. You can reload interfaces (even automatically as the game will check if files are modified and you will see changes instantly ingame) as well as several game systems. For example focus trees will reload with your changes making it really quick and easy to work with making them and not forcing you to restart the game all the time.
This is huge, is there a chance for this to be at least partially back-ported into EU4 (and CK2) eventually? And will this feature also be in Stellaris?
 
  • 13
Reactions:
Status
Not open for further replies.