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 <unannounced>
Paradox Staff
12 Badges
Jul 23, 2007
12.811
38.516
  • 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:
Can we have formable nations? They aren't in vanilla, but the Stream seemed to imply that it is possible via modding.
 
  • 6
Reactions:
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:
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:
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:
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.