The best kittens, technology, and video games blog in the world.

Sunday, March 25, 2018

How to mod EU4 1.25 new mission system

https://www.flickr.com/photos/limowreck666/159234606/

One thing we lost in transition to the new 1.25 mission system were missions for idea groups, so I was wondering how they could be restored.

But first, I needed to do some investigating. This post is my notes, and it's primarily meant for other modders, but it could be of some use to people who just play and are interested in shenanigans.

If you want to check it from player's perspective, DDRJake recorded a series of quick presentations for some of the countries with more interesting missions.

How the old system worked

Until 1.24 every mission had separate potential check, and it could randomly appear for every country if its circumstances matched. Tag-specific missions usually had much higher weight than generic missions, so they usually appeared "in order".

On the upside, it was no trouble whatsoever for missions to be based on your rivals, idea groups, and so on.

On the downside, it was harder for this mission system to provide much guidance to players, and sometimes the RNG was pretty weird.

How HoI4 focus trees system works

The new system is clearly inspired by HoI4 focus trees, but there are some major differences too. Focuses are sort of like missions.

In HoI4 every major country has completely hardcoded tree of focuses. Focuses never change, so starting a game you'll already see Communist and Fascist focuses, even if you won't be able to ever do both same campaign (barring some major shenanigans). 

Minor countries all have the same generic focus tree, also with multiple mutually exclusive branches.

This system allows some interesting chains (see Kaiserreich for an example), and it works OKish with the full screen UI, but in the end it's basically one huge checklist per country, with nothing shared (except by copying and pasting), and no opportunity for anything dynamic - other than by making the checklist even larger.

Constraints behind design of the 1.25 mission system

The new mission system was obviously inspired by HoI4, but they faced different constraints.

People play a lot more countries in EU4. HoI4 after a few expansions has 22 focus trees, and while this isn't enough to stop demands for more, most players would be happy enough once about 30-40 or so top countries get national ideas. The kind of people who play Bhutan or Panama are a tiny minority, and generic ideas are powerful ideas that they don't have to be interesting.

In EU4 a lot more countries are played than in HoI4. There are already 353 national idea groups (counting both unique and regional groups) for 700 or so tags. There's no way in hell devs would be able to create HoI4 style trees for that many countries in a reasonable time.

Fortunately EU4 doesn't really need that kind of complexity. So instead they created modular system which allows wide range of mission trees from completely generic to completely unique.

How 1.25 mission system works

There are 5 column-shaped slots in mission pool, conveniently labelled 1 to 5 left to right.

Missions are all in groups. Each group has designated column, potential condition, and is marked as generic or not.

Each mission within a group can have a position (row), otherwise it will take the first free row instead.

When campaign starts or the mission pool is reinitialized (on some tag switching events), every mission group is checked. Every group for which potential condition is true is added to its column.

As an exception, if a generic missions wants a slot already taken by a non-generic mission, its whole group is removed. So if there's a group of generic missions for slot 4, positions 1-5, and a single non-generic mission for slot 4 position 1, then none of those generic missions will be available. Those in slots 2 and 3 won't be affected.

You can still have generic and non-generic missions in same slot, by explicitly giving them positions 6+.

If you're mixing missions this way, load order matters, as game doesn't like putting missions above previously placed missions. That's why generic missions are loaded first (file name starts with 00_).

Also putting generic missions under non-generic missions doesn't seem to work.

You could have multiple non-generic groups in same column (with or without explicit positions), but as far as I can tell, it's not used anywhere.

Possible mission pools

These combinations are used in the game:
  • countries Paradox really didn't care about like New World minors have only generic missions in columns 2, 3, 4, positions 1-5 each, for a total of 15 missions
  • slightly more important countries like Ulm get one or more regional generic missions groups in column 5. Ulm gets two groups there - one for all Europeans, and one specifically for HRE minors.
  • secondary powers like Bavaria get all that, and also tag-specific missions in column 1
  • as a slight variant, Coptic African countries get Coptic missions in column 1, African regional missions in column 5, and generic missions in columns 2, 3, 4
  • most big countries like Castile or Muscovy still get all generic missions in columns 2, 3, 4. They also get unique missions in columns 1 and 5 - and explicitly positioned unique missions in columns 2, 3, 4, under generic missions
  • a few countries like France do that, and they also replace some of generic missions. For France columns 2 and 4 include generic missions, and unique missions on the bottom; columns 1, 3, and 5 include unique missions
  • some countries like England replace all generic missions in all 5 columns
There are a few more things we could do.

How missions pools are reset

Mission pools are only changed explicitly if decision or event uses swap_non_generic_missions = yes

It is not triggered automatically, so if your Mazovia joins HRE, it won't get missions HRE minor get.

The change is included in some tag changing decisions. More or less those for which target tag has unique missions, but the lists don't seem to match exactly (like some decisions to form Japan reset missions, others don't). It's probably a few minor bugs, I don't think they're usefully exploitable.

This means that if you form England (which includes the reset) as France you get English missions, but if you form Shan (which doesn't), you keep French missions. They'll have Shan shield on them, the shield is purely decorative.

What can be easily modded?

First, the good news. If you want to create missions in format similar to what already exists, it's very easy.

So your Trebizond Mission Pack mod, or Indonesian Minor Mission Pack mod will require no shenanigans.

For this kind of mods simply check existing files, they're very easy to understand.

What requires manual resets

Now, the bad news. Anything else will require messing with the system.

For example if you religion-specific mission packs like Coptic do, let's say Sunni Mission Pack, you could simply add them to column 1 or 5, and just accept that countries which override it (like Ottomans and Mamluks) won't get your missions.

Then you could try writing mission packs for Catholics, Protestant etc., putting missions in column 1, and you'll run into a big problem - your newly Protestant Anhalt will still keep its Catholic missions, as it started the campaign Catholic.

From testing so far it seems that triggering swap_non_generic_missions = yes is completely harmless, so if you see good event for it (on_actions - on_religion_change), you could simply stuff it there. 

For things like missions based on idea groups, there's no good place to put the trigger, so perhaps it needs a regularly triggered maintenance event which will periodically reset mission pool regardless of them being needed. You can probably live with a small delay.

You could also create a decision to manually reset the mission pool. It feels a bit awkward, but works just fine from the testing. I'm not sure how to tell AI to click it the right times, so it could be in addition to other mechanisms.

Can we have more columns?

For extra missions it would be nice to add extra columns 6+. This way we could for example add religious missions in column 6, culture specific missions in column 7, idea group missions in columns 8-10, and not worry about overlap.

With vanilla UI it doesn't display at all, and a quick look at defines and interface files don't show any obvious fix. It would be nice if someone did some testing here. I'm not seeing any obvious reason why it shouldn't work.

Dev Diary once said "The grid can be as wide and tall as you like, it will automatically expand to fit all missions" - testing shows it's false, and expansion is only rows.

Idea group missions

And finally let's get back to where we started - missions for idea groups. Let's say 2 missions per full group, which is not amazing, but it's a decent start.

If we had columns, we could just put generic missions in those extra columns, somehow reset mission pool when ideas are taken (or on some timer if that's not possible).

As far as testing goes, what actually works is this:
  • create a file with some late name like missions/ZZZ_Idea_Group_Missions.txt.
  • create some mission groups, let's say all administrative idea missions in column 2, diplomatic idea missions in column 3, and military idea missions in column 4
  • even though they'll be the most generic missions possible, you need to mark them as generic = no, so they display even if nation already has non-generic missions in given column.
  • don't make them display nation's shield, it's not necessary.
  • you need to explicitly mark position, lower than any exiting missions. Portuguese and English missions use positions up to 11, so you can start at 12 unless I missed something. Or a bit below, the only difference will be extra scrolling
  • those missions will display for every nation, and simply use checks like full_idea_group = administrative_ideas in their fulfilment criteria.
Now that the investigation is complete, the only thing to do is creating a bunch of interesting missions and uploading them as a mod.

No comments: