• 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.

Developer Diary | Modding!

Carlo here. As Content Designers and developers, we not only make content, but we’re always trying to find new tools to do our job better and faster. And since HoI4 is crazy moddable, these tools are available to modders too, these are some of the new things you’ll be able to do when making mods, starting with Joint Focus Trees.

How do you make a Joint Focus Tree?

Well, at its core, a JFT is a Shared Focus Branch, one where depending on conditions, has a set of member countries, and the completion of the focuses is shared between them, and different effects apply either to the country completing them, to the rest of the countries or to all of them equally.
C1-Shared Focuses.jpg

And of course, under the hood they’re a bit different from Shared Focuses in a few ways. First thing you’ll notice is the text_icon parameter, we’ll talk about later, but the SECOND thing you’ll notice is the joint_trigger section. It’s a trigger that determines which countries will be considered part of the JFT and get their corresponding effects. In this case it’s checking if you have the alliance leader flag or you are in a faction with this country.
C2- Basic Trigger.png

The other thing that’s different from normal focus trees is there’s 3 (THREE) different sections for Completion Rewards.
C3 - Completion Rewards.png

First one, regular old completion_reward does its effect in every valid country in the Joint Alliance, the same for everyone.

Then there’s completion_reward_joint_originator, that only applies the effect in the country that completed the focus.

And finally the completion_reward_joint_member, which applies the effect on every valid member of the alliance that is not the country that completed the focus.

That’s basically it. It’s a simple system, but we hope it’ll be flexible enough to have a bunch of use cases and variations, especially since it doesn’t need to be a faction! We used a faction as the most obvious use for it but you can make any amount of related or unrelated countries share the tree. Every country in the continent? Sure. Every communist country? Go ahead. Countries on both sides of a war? Can’t stop you!

I can’t wait to see what you do with it.

Focus Title Background

In the previous point I mentioned a text_icon parameter, that’s the way we are giving you the ability to change the background for the Focus titles. It’s one of the features that were added to enhance the Joint Focus Tree, but can be useful for any kind of focus tree content..
C4 - Focus Title example.png

It came about because we wanted a way to quickly differentiate normal focuses from joint focuses. At first we thought about just making them have the same framing on the focus icons but that proved… Not ideal.
C5 - Joint Titles WIPs.png

The biggest problem is that it immediately made every focus icon be too busy and hard to read.
C6 - Joint Pentagons.png

Plus, when the whole tree was pentagons everywhere, it looked way too repetitive.
C7 - Pentagon Tree.png

Eventually, we accepted that we couldn’t solve this problem with art or design, and we were gonna have to resort to an extreme measure… Talking to a programmer D=

We barely survived, but after an arduous process we agreed to make a system to change the title background changeable. It was the best option; relatively simple to implement, noticeable, and we didn’t need to make every icon from scratch. Of course there was still a bit of trial and error to get the look right.
C8 - Title trials.png

Setting them up is relatively easy. First, you will have to set up the 4 GFX entries you set up in the nationalfocusview.gfx, in our case, most of the animations and masks work just fine so it was mostly copy-pasting.
C9 - GFX.png

There’s a new file called 00_titlebar_styles where you can add style entries and specify the GFXs for each state, and set one as default so you don’t need to specify the style for every single focus.
C10 - Style File.png

And now you just use your new style with the focuses you want in the text_icon parameter. They’re set on a focus by focus basis so you can go wild and do dumb stuff with any kind of focus!
C11- focus style example.png

Dynamic Focus Icons

Another feature that we added thanks to the Joint Focus Tree. You now can have the focus icons change depending on conditions. This is something I’ve wanted for a long time but never found a big enough excuse to do it… Until now.

The reason we finally added it for the JFT is that we want to have the option of playing it as more than one ideology, while still giving you some thematic distinction. After all, a democratic alliance should have a very different look from one formed by monarchies and dictatorships.
C12 - Focus Icons Example.jpg

How they’re set up is very simple. Instead of specifying a GFX, you can open brackets and enter a trigger and a value. First one to be true becomes the icon for that focus! Just remember to add the “dynamic = yes” parameter so it’s updated more easily.
C13 - Dynamic Icon Script.png

Showing Event Option Tooltips

One of the things I hate the most when doing events is showing the effects of both sides of the events in tooltips. Usually, when we have an event option that sends another event to another country, we have to show you what will happen in your country, and in the other country, so you can better judge what’s the right choice. This has always meant adding effect_tooltips and duplicating the other side’s effects inside it, which is time consuming and annoying to maintain and keep track of.
C14 - SOV Tooltip.png

Well not anymore! (Kind of). We’ve added an effect called event_option_tooltip, that allows you to show the tooltip that option will display.
C15 - SOV script.png

C16 - Focus Tooltip.png

This is also very useful for those effects that go after the “If They Accept” tooltip.
C17 - Focus Script.png

It does have some limitations, like ignoring anything inside a FROM so you don’t accidentally crash the game with an infinite loop if you have a show_event_tooltip on both sides, but it’s already been a time saver and we hope to improve on it in the future. .

Modifying the Effectiveness of Forts

You know, not every fort is built the same, but until now they were in HoI. To make it easier to represent just how bad and outdated fortifications were in Norway and Denmark we needed something extra, so we added a couple of percentual modifiers that change the attack penalty inflicted on the attacking enemy by forts: land_bunker_effectiveness_factor and coastal_bunker_effectiveness_factor.
C18 - Obsolete Armed Forces.png

Before, if we wanted to represent having bad forts, our only option was reducing their production speed, which numerically could make some sense but feels a bit off thematically. You can be very fast in making really bad forts and vice versa.
C19 - Coastal bunker effectiveness.png

For example, if a fort normally inflicts a 15% penalty and you have a -50% value in land_bunker_effectiveness_factor, that penalty will be reduced to 7.5%. Forts are already plenty effective so we’re mainly using this to make them worse, but of course, there are exceptions here and there.
C20 - Birger Eriksen.png

And that’s it for me, but Mano de Zombi has a bunch of other stuff to show you!


Mano de Zombi here!
After returning from a sunny vacation to this Swedish deluge I really needed to go through some of the code support we've been getting lately in order to give meaning to my life and remind me of the things that I enjoy and that not even this weather can ruin for me.
So here you have a selection of functionality, tools and improvements that have been added during the past months by our amazing coders:

Scripted Loc can now be used in Dynamic Modifiers
Your dynamic modifiers can now dynamically change name (previously we needed to create duplicates and swap the modifiers and it was really painful and ugly T_T)

New Generator Parameters for create_wargoal effect
We can now use an array as the generator in the effect create_wargoal, allowing us to set the generator states based on the world conditions by the time the effect is executed:
  • You can use an already set array if you so desire:
    M01 wargoal simple.png
  • Or you can create your own array and add states based on whatever requirements you’d like to have:
    M02 wargoal custom.png
New Functionality for CTRL + ALT + Click
We’ve added more functionality for the (debug-only) hotkey CTRL+ALT+Click on certain UI elements.
For those of you who might not know about this hotkey, this is an extremely useful tool for scripting and debugging: when used on a certain object in the UI, it will automatically open the file and lead to the line in which said object is defined, so you can immediately see the script behind it, and do whatever you need to do with it.
Quick example: (with debug mode on) you can CTRL+ALT+Click on a focus and it will open the appropriate focus file and lead you to the line in which it is defined:
M03 simple click.png

M04 simple script.png

As a reminder, this could already be used in focus, events (clicking on any of the event options), decisions, ideas (National Spirits, Designers, Laws, Officer Corps Spirits), characters (advisors, country leaders, unit leaders), technologies and doctrines.
Please forgive me if I forgot something, I can barely hear my thoughts on this rain…

Now, our amazing coders have fixed an issue with unavailable advisors not working with this (now they do!), and new functionality has been added so that we can now CTRL+ALT+Click on:
  • Designer Modules in the Ship/Tank/Plane Designers
    M05 designer module.png
  • Battalions in the Division Designer
    M06 battalion.png
  • Production Lines and Equipment in the Production Tab
    M07 production.png
  • Intel Agency Upgrades
    M08 agency upgrades.png
  • Operations and Phases
    M09 operations.png
  • MIO's and Traits

Improvements for Division Commanders.
We have improved a bit the way of scripting Division Commanders (Field Officers). Now you can define them with a localized name and with portraits, both in OOB files and inside the create_unit effect:
M10 div commander.png


Parameter random_select_amount
This useful new parameter can be added to all the every_[scope] effects (every_character, every_state, every_other_country, etc.). The parameter takes an integer as value, and this value is the number of times the effect will run before breaking the “for” loop running behind the scenes.

Previously, we had a few different ways of applying effects to, let’s say, 3 random states, but all of them required an unreasonable amount of script and custom tooltips in order to make sure that the effects could not be applied to the same state twice, and they all generated very shitty tooltips.

Now, the use of random_select_amount allows us to apply effects to a number of random scopes (states, characters, countries…) in a very simple way with no possibility of choosing the same scope twice and generating a standard tooltip that indicates the actual states targeted by the effect:
M11 random select.png

M12 random result.png

Filter for including invisible unit leaders in effects & triggers
If you ever had the need to apply effects to all your land and navy officers, regardless of them being visible to the country or not (due to, for example, the country not having completed a focus yet), you will find the new parameter include_invisible pretty useful.
This parameter is now available as an optional parameter in the full set of scoped triggers and effects related to unit leaders (every/random/all/any_unit/navy/army_leader). By default is set to false, so you only need to use it if you want to scope to all the unit leaders belonging to a TAG, regardless of them being visible (unlocked) to the country or not.
M13 include invisible.png

This is the full list of effects and triggers that benefit from this parameter:
every_unit_leader
random_unit_leader
every_army_leader
random_army_leader
every_navy_leader
random_navy_leader
all_unit_leader
all_army_leader
all_navy_leader
any_unit_leader
any_army_leader
any_navy_leader


Use of Variables as tag in targeted modifiers
Now it is possible to input a variable as the tag parameter inside the targeted_modifier block, allowing us to store the appropriate country inside a variable and then apply the National Spirit targeting the appropriate country very easily!
M14 var targeted.png

And this is all for me, I’ll see you soon in a future DD!
 
  • 29Like
  • 15Love
  • 6
  • 2
  • 1
Reactions:
Reserved for Developer Replies~


PDXKatten replies:
Is the next dev dairy going to be about alt Finland?
Yes it will!

CarloPDX's Replies;
Does the modifier affect all owned forts, or only forts in core provinces? (If Norway annexed France, would it magically throw the Maginot Line into disrepair?)

Can it be used in state and province scopes, or just country scopes?
It affects every single fort, but if you wanna be more specific the modifier works in the state scope too.
1) Any plans on increasing the amount of variables we gain access to? For example, we cannot access convoys.
2) Any new effects, triggers regarding the new trade system?
3) Any plans to enhance access to divisions? Some effects (e.g. history) are buggy, while accessing one specific division is very hard.

Overall, very useful changes!
They're not variables but you can access convoys as equipment, with convoy_1. I do that a lot in Norway
Something that I haven't seen yet is how the joint focus trees are defined.

Do they have to be defined in every focus tree that can access it?
Or does the Joint focus tree have it's own file that can be called within a country's focus tree if the necessary parameters are met?
It's a regular old shared national focus file, the "jointness" of them is defined focus by focus
Bit late so probably won't get a response but will characters be made more dynamic/less hardcoded (probably not this DLC cycle but like maybe the next one, or an intermediate)? Stuff like allowing characters themselves to be stored in variables and checks like "is_hired_as = <advisor slot>".
Characters can already be added as variables! And I think you can get workarounds for the hired as advisor slot

CraniumMuppet Replies;
Could you tell a bit about the "function"/code that converts Consumer Goods into actually useful bonsuses?
You just fetch the two consumer goods variables and perform your calculations as any variable and apply them as needed, there's no convert function per se
Theoretically, but they tend to break. I can't give any examples because it's been a while since I last tried, but in my experience variables/event targets that store characters always return null when I try to reference them later in script.
The 'is_<advisor_slot>' triggers got updates in one of the post NSB patches to only return true if the character was currently hired in that slot, BTW. Very useful, not sure why the triggers didn't originally work that way.
on_add/on_remove with character flag is_hired is probably the most robust one atm
Theoretically, but they tend to break. I can't give any examples because it's been a while since I last tried, but in my experience variables/event targets that store characters always return null when I try to reference them later in script.
The 'is_<advisor_slot>' triggers got updates in one of the post NSB patches to only return true if the character was currently hired in that slot, BTW. Very useful, not sure why the triggers didn't originally work that way.
We've been definitely fixing a bunch of issues with the character system and I'm pretty confident about it nowadays so try again, specially when the patch for AAT comes out =}

C0RAX replies;
1) Will the new international market be moddable?
2) There was in previous dev diaries a talk about improvement to designer companies through "Military industrial Orgs.", yet so far we've had no news about their development, will this not be included in the new DLC?
3) Will the special forces tree be moddable in a similar manner to how doctrines are?
Details on the features we have announced for arms against tyranny will be in future dev diaries. You can find what is included in arms against tyranny on the steam page for the expansion pack.
Anything about modding MIO's?? Or it will get its own topic like custom achievements?
in a future DD
 
  • 2Like
  • 1
Reactions:
Hopefully that Ctrl+Alt click thing will be toggleable by console command. You don't want to accidentally open stuff, but when you do, it shouldn't require for example going to a file and changing a 0 to a 1 and restarting the game.
 
  • 1
Reactions:
Hopefully that Ctrl+Alt click thing will be toggleable by console command. You don't want to accidentally open stuff, but when you do, it shouldn't require for example going to a file and changing a 0 to a 1 and restarting the game.
If I were a bettin' boi, I'd say that the Ctrl+Alt+click thing might be limited to debug mode
 
  • 6
Reactions:
Carlo here. As Content Designers and developers, we not only make content, but we’re always trying to find new tools to do our job better and faster. And since HoI4 is crazy moddable, these tools are available to modders too, these are some of the new things you’ll be able to do when making mods, starting with Joint Focus Trees.

How do you make a Joint Focus Tree?

Well, at its core, a JFT is a Shared Focus Branch, one where depending on conditions, has a set of member countries, and the completion of the focuses is shared between them, and different effects apply either to the country completing them, to the rest of the countries or to all of them equally.

And of course, under the hood they’re a bit different from Shared Focuses in a few ways. First thing you’ll notice is the text_icon parameter, we’ll talk about later, but the SECOND thing you’ll notice is the joint_trigger section. It’s a trigger that determines which countries will be considered part of the JFT and get their corresponding effects. In this case it’s checking if you have the alliance leader flag or you are in a faction with this country.

The other thing that’s different from normal focus trees is there’s 3 (THREE) different sections for Completion Rewards.

First one, regular old completion_reward does its effect in every valid country in the Joint Alliance, the same for everyone.

Then there’s completion_reward_joint_originator, that only applies the effect in the country that completed the focus.

And finally the completion_reward_joint_member, which applies the effect on every valid member of the alliance that is not the country that completed the focus.

That’s basically it. It’s a simple system, but we hope it’ll be flexible enough to have a bunch of use cases and variations, especially since it doesn’t need to be a faction! We used a faction as the most obvious use for it but you can make any amount of related or unrelated countries share the tree. Every country in the continent? Sure. Every communist country? Go ahead. Countries on both sides of a war? Can’t stop you!

I can’t wait to see what you do with it.

Focus Title Background

In the previous point I mentioned a text_icon parameter, that’s the way we are giving you the ability to change the background for the Focus titles. It’s one of the features that were added to enhance the Joint Focus Tree, but can be useful for any kind of focus tree content..

It came about because we wanted a way to quickly differentiate normal focuses from joint focuses. At first we thought about just making them have the same framing on the focus icons but that proved… Not ideal.

The biggest problem is that it immediately made every focus icon be too busy and hard to read.

Plus, when the whole tree was pentagons everywhere, it looked way too repetitive.

Eventually, we accepted that we couldn’t solve this problem with art or design, and we were gonna have to resort to an extreme measure… Talking to a programmer D=

We barely survived, but after an arduous process we agreed to make a system to change the title background changeable. It was the best option; relatively simple to implement, noticeable, and we didn’t need to make every icon from scratch. Of course there was still a bit of trial and error to get the look right.

Setting them up is relatively easy. First, you will have to set up the 4 GFX entries you set up in the nationalfocusview.gfx, in our case, most of the animations and masks work just fine so it was mostly copy-pasting.

There’s a new file called 00_titlebar_styles where you can add style entries and specify the GFXs for each state, and set one as default so you don’t need to specify the style for every single focus.

And now you just use your new style with the focuses you want in the text_icon parameter. They’re set on a focus by focus basis so you can go wild and do dumb stuff with any kind of focus!

Dynamic Focus Icons

Another feature that we added thanks to the Joint Focus Tree. You now can have the focus icons change depending on conditions. This is something I’ve wanted for a long time but never found a big enough excuse to do it… Until now.

The reason we finally added it for the JFT is that we want to have the option of playing it as more than one ideology, while still giving you some thematic distinction. After all, a democratic alliance should have a very different look from one formed by monarchies and dictatorships.

How they’re set up is very simple. Instead of specifying a GFX, you can open brackets and enter a trigger and a value. First one to be true becomes the icon for that focus! Just remember to add the “dynamic = yes” parameter so it’s updated more easily.

Showing Event Option Tooltips

One of the things I hate the most when doing events is showing the effects of both sides of the events in tooltips. Usually, when we have an event option that sends another event to another country, we have to show you what will happen in your country, and in the other country, so you can better judge what’s the right choice. This has always meant adding effect_tooltips and duplicating the other side’s effects inside it, which is time consuming and annoying to maintain and keep track of.

Well not anymore! (Kind of). We’ve added an effect called event_option_tooltip, that allows you to show the tooltip that option will display.

This is also very useful for those effects that go after the “If They Accept” tooltip.

It does have some limitations, like ignoring anything inside a FROM so you don’t accidentally crash the game with an infinite loop if you have a show_event_tooltip on both sides, but it’s already been a time saver and we hope to improve on it in the future. .

Modifying the Effectiveness of Forts

You know, not every fort is built the same, but until now they were in HoI. To make it easier to represent just how bad and outdated fortifications were in Norway and Denmark we needed something extra, so we added a couple of percentual modifiers that change the attack penalty inflicted on the attacking enemy by forts: land_bunker_effectiveness_factor and coastal_bunker_effectiveness_factor.

Before, if we wanted to represent having bad forts, our only option was reducing their production speed, which numerically could make some sense but feels a bit off thematically. You can be very fast in making really bad forts and vice versa.

For example, if a fort normally inflicts a 15% penalty and you have a -50% value in land_bunker_effectiveness_factor, that penalty will be reduced to 7.5%. Forts are already plenty effective so we’re mainly using this to make them worse, but of course, there are exceptions here and there.

And that’s it for me, but Mano de Zombi has a bunch of other stuff to show you!


Mano de Zombi here!
After returning from a sunny vacation to this Swedish deluge I really needed to go through some of the code support we've been getting lately in order to give meaning to my life and remind me of the things that I enjoy and that not even this weather can ruin for me.
So here you have a selection of functionality, tools and improvements that have been added during the past months by our amazing coders:

Scripted Loc can now be used in Dynamic Modifiers
Your dynamic modifiers can now dynamically change name (previously we needed to create duplicates and swap the modifiers and it was really painful and ugly T_T)

New Generator Parameters for create_wargoal effect
We can now use an array as the generator in the effect create_wargoal, allowing us to set the generator states based on the world conditions by the time the effect is executed:
New Functionality for CTRL + ALT + Click
We’ve added more functionality for the (debug-only) hotkey CTRL+ALT+Click on certain UI elements.
For those of you who might not know about this hotkey, this is an extremely useful tool for scripting and debugging: when used on a certain object in the UI, it will automatically open the file and lead to the line in which said object is defined, so you can immediately see the script behind it, and do whatever you need to do with it.
Quick example: (with debug mode on) you can CTRL+ALT+Click on a focus and it will open the appropriate focus file and lead you to the line in which it is defined:

As a reminder, this could already be used in focus, events (clicking on any of the event options), decisions, ideas (National Spirits, Designers, Laws, Officer Corps Spirits), characters (advisors, country leaders, unit leaders), technologies and doctrines.
Please forgive me if I forgot something, I can barely hear my thoughts on this rain…

Now, our amazing coders have fixed an issue with unavailable advisors not working with this (now they do!), and new functionality has been added so that we can now CTRL+ALT+Click on:

Improvements for Division Commanders.
We have improved a bit the way of scripting Division Commanders (Field Officers). Now you can define them with a localized name and with portraits, both in OOB files and inside the create_unit effect:


Parameter random_select_amount
This useful new parameter can be added to all the every_[scope] effects (every_character, every_state, every_other_country, etc.). The parameter takes an integer as value, and this value is the number of times the effect will run before breaking the “for” loop running behind the scenes.

Previously, we had a few different ways of applying effects to, let’s say, 3 random states, but all of them required an unreasonable amount of script and custom tooltips in order to make sure that the effects could not be applied to the same state twice, and they all generated very shitty tooltips.

Now, the use of random_select_amount allows us to apply effects to a number of random scopes (states, characters, countries…) in a very simple way with no possibility of choosing the same scope twice and generating a standard tooltip that indicates the actual states targeted by the effect:

Filter for including invisible unit leaders in effects & triggers
If you ever had the need to apply effects to all your land and navy officers, regardless of them being visible to the country or not (due to, for example, the country not having completed a focus yet), you will find the new parameter include_invisible pretty useful.
This parameter is now available as an optional parameter in the full set of scoped triggers and effects related to unit leaders (every/random/all/any_unit/navy/army_leader). By default is set to false, so you only need to use it if you want to scope to all the unit leaders belonging to a TAG, regardless of them being visible (unlocked) to the country or not.

This is the full list of effects and triggers that benefit from this parameter:
every_unit_leader
random_unit_leader
every_army_leader
random_army_leader
every_navy_leader
random_navy_leader
all_unit_leader
all_army_leader
all_navy_leader
any_unit_leader
any_army_leader
any_navy_leader


Use of Variables as tag in targeted modifiers
Now it is possible to input a variable as the tag parameter inside the targeted_modifier block, allowing us to store the appropriate country inside a variable and then apply the National Spirit targeting the appropriate country very easily!

And this is all for me, I’ll see you soon in a future DD!
Y’all need to add a historical leader for both Democratic Mexico at start as well as fascist France, and I think it would be interesting for y’all to add Marcus Garvey to the game, for instance you take over the Caribbean or the USA as Ethiopia, you can have Garvey be the viceroy of those territories… or at least have him as leader of Fascist Jamaica
 
  • 5Like
  • 1Haha
Reactions:
These are great tools for modders!

Another great tool would be functions for getting party names for custom ideologies. In vanilla there's [GetCommunistParty], but it doesn't work if a mod has new ideologies, for example, Kaiserreich [GetTotalistParty]. Will you add this function? It would add a lot of flavor to mods!
 
  • 5
  • 2
  • 1Like
Reactions:
Did you know that currently in communist Japan, the code generating 3 random generals for Japan is not working? The code itself is normally, but only one general is created when playing.

In one focus, the code that generates multiple random people is currently not functioning normally. could this be improved in the next DLC?
 
  • 5
Reactions:
To make it easier to represent just how bad and outdated fortifications were in Norway and Denmark we needed something extra, so we added a couple of percentual modifiers that change the attack penalty inflicted on the attacking enemy by forts: land_bunker_effectiveness_factor and coastal_bunker_effectiveness_factor.
Does the modifier affect all owned forts, or only forts in core provinces? (If Norway annexed France, would it magically throw the Maginot Line into disrepair?)

Can it be used in state and province scopes, or just country scopes?
 
  • 4
  • 1
Reactions:
1) Any plans on increasing the amount of variables we gain access to? For example, we cannot access convoys.
2) Any new effects, triggers regarding the new trade system?
3) Any plans to enhance access to divisions? Some effects (e.g. history) are buggy, while accessing one specific division is very hard.

Overall, very useful changes!
 
  • 2
Reactions:
Hopefully that Ctrl+Alt click thing will be toggleable by console command. You don't want to accidentally open stuff, but when you do, it shouldn't require for example going to a file and changing a 0 to a 1 and restarting the game.
If I were a bettin' boi, I'd say that the Ctrl+Alt+click thing might be limited to debug mode
Ya'll:
1694616308358.png
 
  • 2
Reactions: