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

HoI4 Dev Diary - Modding Changes

Hello, and welcome back to another Dev Diary for No Step back and 1.11 Barbarossa. Today we will be pulling back the veil a bit and show you how modders can affect and use the new features coming in 1.11.

For those of you who do not get unreasonably excited by hearing about new script commands and changes to databases, the long and short of it is this: We made some fundamental changes to the way the game handles some things, which will probably require your favorite mods to spend some time updating. On the flip side, those changes also allow for some exciting possibilities down the line. If you came here hoping for a release date, we must ask you for just a little more patience. We promise the announcement is very close - but not today.

Characters

Probably the biggest change is in how we handle people on the backend (or ponies, for that matter - we do not discriminate). In the current live version, the game has no real concept of a person as a distinct thing. It only knows about country leaders, military leaders, political and military advisors, and operatives. Cases where a country leader could also be a general had to be handled manually, leading to lots of exciting bugs when the country leader was removed but the general was forgotten about and other such cases.

We have overhauled that side of the game from the ground up with the introduction of characters. This should dramatically reduce the amount of potential zombie generals shambling around, which I am sure the non-zombie population will greatly appreciate.

Characters are defined in the common/character folder, and their definitions look like this:

Screenshot_4.png


Every character is defined as a container for different roles they can fulfill, like General (corps_commander), Advisor, country leader etc. Due to technical concerns, Operatives remain their own thing. On the character level itself, things like name and gender are handled. This also means that character names can now be localised and you can refer to a character by ID instead of by name (this helps a lot with character names that have non-english characters in them - turns out this broke some triggers and effects).

Screenshot_5.png


This also means that if a character is removed from play - say, through a purge - they are automatically removed from all roles that they could have, which makes such systems a lot easier to do script-side. It also means that if we wanted to allow Zhukov to become a country leader, we could simply add a country leader role for him in the character file, like this:


Screenshot_6.png

Or we could also add the role later on, via focus, event, decision... like we do here with Beriya:


Screenshot_7.png

That means there is a lot less confusion and duplication of effort necessary when putting a character into a new role, since stuff like portraits, name etc. are already handled. A broken portrait only needs to be fixed in one place instead of five etc.

Once defined, characters are recruited in the country history file in order to be added to the game. As you can see in the first screenshot, you can use visible triggers for unit leaders to ensure they are not shown if you don’t want them to be.

Characters that can potentially become country leaders are made into country leaders using the promote_character effect, like so:

Screenshot_8.png


This is a clear departure from the practice in the live version of the game, where you would create a new country leader in that effect. The old script with create_country_leader and other such effects should still be working, but obviously you don’t get any of the advantages of the unified character system.

So let’s talk about some more things you can do with it!

You can set and check character flags for nefarious purposes:

Screenshot_9.png


You can change the traits of advisors without having to make a whole new advisor:


Screenshot_10.png

You can check if a character is a certain type of character:

Screenshot_11.png


You can save the character as a variable to refer to them later, such as spamming debug messages in the console!


Screenshot_12.png

Tank Designer

Next, let’s talk a bit about how the tank designer works on the backend. It shares a lot of concepts with the ship designer, such as modules and module slots. It does, however, work a little differently in some other, important aspects.

While the system pretends that there are only a handful of chassis (light, medium, heavy, super-heavy, amphibious, modern), this is not technically true. Instead, the system maintains a whole host of other, dynamically created chassis. This allows us to make sure that tank designs with the tank destroyer role actually go into tank destroyer battalions etc.

However, these dynamic chassis are still generated from the base chassis, so any changes to them will carry over.

The roles are enabled and disabled on individual modules:

Screenshot_13.png



Screenshot_14.png

For the unlock of new module categories, you can then use this on a module to unlock that category:

Screenshot_15.png


Railways

Railways function a little differently from other buildings. While they are technically province buildings like forts, they are in reality closer to a building that connects two provinces. A railway line is effectively a series of two-province connections, and the lowest one in the chain determines the level of the railroad connection between two supply hubs.

To make it easier to change and maintain the historical railway setup, we have added an option to draw railways into the nudger tool, which you can access by using the nudge command in the console.
Screenshot_16.png


The railway setup is in the supply menu in the nudger, and you can easily add new railway lines to the existing setup in this way. It took me about a week and a half to do the entire 1936 setup, including tracking down reference maps (with a lot of help from some of our testers).

If you want to add railways through script, you have the build_railway effect. It gives you a lot of options, with the most basic one being to lay out the path one province at a time:

Screenshot_17.png


This is obviously a little cumbersome for longer railways, especially if you don’t really care about the exact path. For that, you have the option to define a start and an end province:

Screenshot_18.png


The game will then automatically generate a path from one end to the other using advanced neural network-based self-learning algorithms that use blockchain (read: I have no idea how it works but this sounds impressive).

If finding the province is too much work, or if you want to be somewhat dynamic, you can even use start and end states (also note that you can specify what level of connection should be built):

Screenshot_19.png


Note that you can’t mix these, so you can’t define a starting province and a target state for example.

There are also corresponding triggers like can_build_railway and has_railway_connection:

Screenshot_20.png


The first checks if a railway can be built between two locations, while the other checks if one such connection already exists.

Finally, there is has_railway_level, which checks if the specified state has a railway line in it with the specified level:

Screenshot_21.png

Miscellaneous new effects, triggers, modifiers

In addition to the things described above, we have added a number of useful things that some of you might find useful:

  • Building_cost_factor: a new modifier that affects the construction cost of buildings. This takes the buildings from the 00_buildings file, so it should work with mods that add more buildings.
  • Core_state scope list, allowing you to run effects and triggers on a country’s core states:
Screenshot_22.png


  • Add_equipment_to_stockpile effect can now take a variant name to ensure that you add the right kind of equipment.
That’s all for today, I hope you enjoyed these little insights and we are all excited about what crazy things you will do with the new tools at your disposal.
 
  • 106Like
  • 23Love
  • 23
  • 10
  • 2
Reactions:
Can leader portraits be updated via console?
No.
Can a character have different portraits for when they are a general vs an advisor vs a leader?

Also can you remove characters from a role while keeping them around in others?
Yes (certainly Advisor vs. General/Political Leader)
Can Building_cost_factor be tied to a single building type at a time? because if it's not possible then i don't see that much difference from a construction speed modifier
Yes. The difference seems small at first look, but production_speed is good to have for temporary buffs, while building_cost is better to have as permanent bonuses.
Wow, really like most of this! It's great to see how the railway works, been waiting to see if it'd be too hard to adapt to current infrastructure focuses/decisions I have :)

What I'm really, really, interested in however is the characters thing. Just a handful of questions regarding them:
- As leaders and generals are currently stored in the country's history file, I take it they've been moved out into this new 'characters' folder?
- Next point requires this example:
View attachment 766440
Would this work with how events currently handle leader swaps then? So when Baldwin resigns for example, does that now "promote_character" Chamberlain? If that is the case, I imagine elections will be much, much easier to implement due to being able to just make all the leaders you need, then promote when they're elected.

And finally, how much conflict does this have with the live version? If there's one think I don't like about modding, it's the scouring through files to see what's broken after a patch, so just wondering if I'm going to be spending my first week after the patch un-breaking everything :p
Yes, the database entries are moved into their own files. You still recruit the characters in the history file (and only in the history file - doing it in other places leads to weird edge cases where the game tries to do stuff with a character that doesn't exist yet) and then promote them in the right spot.

As I said, most of this should be backwards compatible, but going from experience there will be a lot of weird edge cases. We have converted all of our databases and are going to be using it when fixing issues in the future, and I would recommend mods do the same. It'll be a lot of work initially, but from what I understand the bigger mods have been forewarned.
Hi !

1) Are country specific effects in terrains now possible ?
2) Can we mod trucks for supply hubs so that they use fuel ?
3) Nothing new for AI modding ?
1) Not that I'm aware of.
2) No
3) Last week we showed off some new debugging tools that should help with AI modding.
Rewriting pol leader/generals/advisors into one category is soooooooooo damn good !
It was also a lot of work, but it was clear that this was something that would be very useful going forward. Honestly something we should have done sooner (ideally before we did something as crazy as the Spanish civil war).

I guess what I'm saying is

sigh

Should have been in the Base Game.
So Character names are localised ?
Does this mean the name of the character can be changed in-game without having to kill the character and then replace them with a similar one ?
That's a good question. I think dynamic localisation should work there, but I won't promise it.
 
  • 24Like
  • 17
  • 3
  • 1Love
  • 1
Reactions:
  • 29Haha
  • 5Like
  • 2
  • 1
Reactions:
So I am curious why tank chassis are dynamically created? You have a base model of light, medium, etc. Then flag of fixed turret or not, + other options? Seems simpler on the backend to only need to reference the defined base chassis. Of course I don't know the rest of the code but it is always interesting to hear about design decisions when it comes to programming. Usually so many possibly traps to fall into that only become apparent once you start on the feature :D

Brief looks like a nice step forward for modding!
It was the easiest way we could tell the game that a given design is a tank destroyer and should go into tank destroyer battalions, since the entire backend is already set up for it. No need to reinvent the wheel. It comes with some unfortunate side-effects, but it did save a lot of time we were able to invest into other parts of that feature.
From a design perspective, I would usually think that having a railway connection generator handled on a state-to-state basis would go something like this:

Call function state_connect(start_state,end_state) which generates (probably randomly, but in theory any way you like) a start_province in start_state and then an end_province in end_state and then connects the two using the same algorithm that the player can use to connect to provinces (i.e. the way the game connects them via provinces instead of states)

Is the reason why you cannot simply use start_province instead of start_state (i.e. have it accept both state_id and prov_id):
1. Because provid number ranges and stateid number ranges overlap (or could in theory overlap?)
2. Some other reason
3. Just because you want to keep it clean (a fine reason!)
This is not a modding question, I don't know anything about modding, just asking
You can absolutely specify start provinces and end provinces in script. Start and end states are primarily for content designers who just want a railway to go from "somewhere over here" to "somewhere over there".
This new character feature looks promising.

Just curious if is it possible to assign multiple ideologies to one character?
Take vanilla Manchuria as an example, both neutrality and fascism have Pu Yi as leader but fundamentally they're two different "characters" defined in history file. So if I retire/kill one of them the other will still linger as a zombie.

And speaking of country leader is it possible to add an trigger for leader ideology(subtype)? Vanilla's sub-ideology really lacks some actual purposes, and its moddability is terrible without corresponding triggers and can only be accessed via brute force methods (country flag, leader trait etc) instead of directly checking in leader scope.
1634739380759.png

No Zombie Pu Yi!

The subideologies can't be checked against, and in general that whole system needs a rethink.
 
  • 15
  • 8Like
  • 1Love
Reactions:
Regarding character portraits, many characters already have both large and small portraits but given the way this works does that mean all portraits are now doubled in this way? What about characters like Fevzi Çakmak who has both a Political Advisor portrait and a Military High Command portrait? If I promote a new general with a generic portrait and then level him up and "kick him upstairs" will he always have a matching advisor portrait? Even for DLC portraits like those added with WtT or MtG?

Regarding these any_character and random_character scopes, are they able to be scoped specifically to serving advisors? It looks as though the samples in these screenshots are scoping to the whole pool of political advisors, whether active or not, but would I be right in assuming there would be some way to make sure to scope only to an active advisor?

Regarding character ids, does the keep_unit_leaders function of start_civil_war accept these character tags? I see a legacy_id line in Zhukov's script so I assume it will continue to accept, well, legacy ids, but can the new character tag be used instead? Can it be used along side legacy ids?
The portraits should match.

I can't seem to find an instance where we check for active duty, but it should be possible to make a workaround for advisors at least by using has_idea_with_trait or checking a character flag. I will make a code support request to add a trigger, but I make no promises that it will be ready for release.

You can use legacy_id or use keep_unit_leader_trigger, which allows the use of flags, traits etc. to check against. In the worst case you can transfer them after you start the civil war.
very interesting. Thrilled about core state scope!

concerned about the character ID and hope for some clarification:
1) Do id have to be numerical?
2) do they have to be sequential?

my main concern is breaking compatibility between mods that add a bunch of leaders and generals. Like mods that add or modify states, if ids have to be numerical and sequential this becomes mod breaking.

i would suggest ids allowing for alpha numerical so you could prevent this
IDs are largely obsolete now. Anything previously done with IDs is now done with the identifying token (SOV_georgy_zhukov). They are in the script to ensure that old content does not break (as much). Mods that use the exact same token for characters will probably conflict, but there is really no way around that.
Hey hey, I have a question about the character system and portraits. Previously portraits and characters were listed by country in the gfx folder and country history. Would it not be possible under this system to create a country leader using the tools for lets say South Africa and let them gain 'Edward VIII' as a country leader despite not having the portrait for Edward VIII in their GFX folder or history file - or would you still have to copy some stuff over from ENG country folder and portraits?

Also if characters are connected to operatives too - if you have an operative in other roles such as a general or national leader - if they were to take a certain cyanide pill then would the national leader and general die too. Its interesting to hear how functionality would work across sections - like operatives being imprisoned who are also national leaders. Generals being ill from North african desert despite being your backroom backstabber or somehting haha
It was always possible to assign portraits as needed. The Folder structure was mostly for housekeeping when tracking down an art asset, not for technical reasons. Operatives are not characters due to reasons (which I was assured were very good).
 
  • 19
  • 3Like
  • 1Love
  • 1
Reactions:
Since we are talking about modding and characters, I think that there are two missing triggers for navy leaders. The triggers attack_skill_level, defense_skill_level, planning_skill_level, and logistics_skill_level exist already, but coordination_skill_level and maneuver_skill_level are missing. The effects add_coordination and add_maneuver are present and working though.

As for other triggers, would it possible to make the trigger free_building_slots work without specifying a building type or have a generic value like "building = any"? Despite the trigger name, I don't know how to check if a state has a free building slot, meaning if the owner can build anything. Maybe you could make a workaround by checking every type of building, but I'm not sure how that would turn out. The fact that the vanilla decision "Region-wide Industrial Integration" does not do that and sometimes has no effects tells me that it's either not possible or not worth it.

Lastly, a small QoL/OCD request: since you made it possible to order division templates in the designer, could you also let us re-order army groups? I can move around armies in a army group, but I cannot move army groups. The order is fixed on creation, I have to create them in the order I want to begin with.
1) Good points, I will put it on the list
2) The building slots for "proper" buildings are interchangeable, so you can just check for arms_factory and cover the regular building slots. For the other limitations like Airbases and radar stations you'd have to check for those separately.
3) also good point, but I make no promises
Can we have a random_province scope?
There are about 800 states in the game, and using any_state excessively already causes measurable slowdown. There are 17000 provinces.
 
  • 18
  • 3Like
  • 1Love
Reactions:
While this is really my thing, I really appreciate the communication about the release date situation. Thanks for keeping us informed about when its coming.

For those who missed it:

If you came here hoping for a release date, we must ask you for just a little more patience. We promise the announcement is very close - but not today.
 
  • 11
  • 9Like
  • 1
Reactions:
Before 1.10.8 we used steam argument "-hands_off", which automatically started the game at speed 5 as PAR (in vanilla). 1.10.8 broke it - the game just doesn't start with this argument. Here is the report created earlier. Here is a description from hoi4 wiki:
  • -hands_off: starts a human_ai game as URG, enabling ai_view, speed 4, and various other settings
We actively used it to run AFK games to gather game data, logs and profiler files - it required fewer actions (exactly 1 - to launch the game) than using 'human_ai' console command (launch the game - pick the country - start the game - open console - enter command - unpause the game). Thanks in advance!
Ah gotcha, I misunderstood a bit. I just tried it on our development build and its working (but not in 1.10.8 for me) so hopefully its fixed when barbarossa drops
 
  • 13
  • 3Like
  • 2Love
Reactions:
Looking forward to play Operation Barbarossa with Total War and Black ICE ;)
 
  • 12Like
  • 2
Reactions:
Thank you for responding. I was confused then by this statement:
"On the character level itself, things like name and gender are handled. This also means that character names can now be localised and you can refer to a character by ID instead of by name (this helps a lot with character names that have non-english characters in them - turns out this broke some triggers and effects)."

So we don't HAVE to utilize an id to reference them in any script it's just option (like it is now for generals) I assume?

If so, this is a great feature. While it's cumbersome to clean up an existing mod it's clearly a better organization going forward.
Yeah, you effectively create the identifying token when you create the character. You can set a legacy ID, but you don't have to. Overall it should lead to a lot fewer bugs when trying to reference a specific character.
Has the new tank designer resulted in any knock-on changes to the ship designer I should know about? I'm working on a mod for the ship designer (as well as the AI's use of it) and I'd like to know if anything might break.
It shouldn't.
 
  • 11
  • 1Like
  • 1Love
Reactions:
Can a character have different portraits for when they are a general vs an advisor vs a leader?

Also can you remove characters from a role while keeping them around in others?
 
  • 12
Reactions:
So I am curious why tank chassis are dynamically created? You have a base model of light, medium, etc. Then flag of fixed turret or not, + other options? Seems simpler on the backend to only need to reference the defined base chassis. Of course I don't know the rest of the code but it is always interesting to hear about design decisions when it comes to programming. Usually so many possibly traps to fall into that only become apparent once you start on the feature :D

Brief looks like a nice step forward for modding!
So we have the main chassis defined for most values that are generic in the normal groupings, we then define subtypes and have modifiers/overrides only for that subtype without having to predefine all the values. It also allows you to load into the designer and design any subtype for the base chassis and what the player puts on the chassis will determine the available subtypes and selecting those subtypes will change the stats as talked about above.
 
  • 10
  • 1Like
  • 1Love
Reactions:
May I please ask that is it possible to let two countries get the same generals by the same code?
For example, using the code "SOV_georgy_zhukov" from this diary for two different countries and then they can both have this character, does it work? If not then what should I do? Can I delete the code of "legacy_id = 410"?
The most important is that, "Characters are defined in the common/character folder", so is it still possible to add new generals by events, focus and decisions whiout writing the specific country tag? In other words, creating new generals by events and decisions.
Some mods are used to add new generals for any countries which the player is controling, it's impossible to specificly write that which tag it is...
I'm the developer of Maid Corps, I really hope to know it...
You can still transfer leaders that have been created elsewhere to a different country.
What are the prospects of eventually placing characters on the map at a division HQ or on a task force flag ship to create a chance of capture?

Modder question: Will it eventually be possible to apply character traits to tank or ship modules?
Extremely low chance of that happening.
 
  • 9
  • 1Like
  • 1Love
  • 1
Reactions:
Don't care about/understand modding DDs, but:
On the flip side, those changes also allow for some exciting possibilities down the line. If you came here hoping for a release date, we must ask you for just a little more patience. We promise the announcement is very close - but not today.
This is great news. Looking forward to it.
 
  • 10Like
  • 1
Reactions:
Does it means that character names will be soft-coded in Vanilla?
If so, a lot of love from Japan, because you can finally localize the names!
That's the idea!
When youre already at adding a building cost modifier, could you *please* look into an on_built function for buildings? :3
That on_action would run a lot and probably negatively impact performance.
 
  • 9
  • 2Love
  • 2
Reactions:
This is so cool.

This also solves my question from the prior dev diaries about how the general advisors would work.

I didn't notice, but I assume we are able to assign existing advisor/minister gfx to instead of it auto-creating them? I've figured the new system would just take the general/admiral portrait and turn them into an advisor when you promoted them, but we can set specific gfx instead?

No, the portraits work more or less the same as they do now. They are separate dds files that are assigned either by path or in a GFX file. The existing GFX entries work as expected.
 
  • 6
  • 4Like
  • 1Love
Reactions: