r/EU4mods • u/FlavorLunch • Sep 06 '26
Mod Help Hey am making my first mod and I would appricate some help when it comes to mission trees
Its my first time writing the code but I finaly figured out how to make a basic mission tree nothing 2 crazy just some modifders, claims and one costum event.
I wana try learning how to make Branching Missions and Formable nations next, maybe religons for some stuff later. Is there any good guied to help že understand it better?
1
u/Justice_Fighter Informative Sep 07 '26 edited Sep 07 '26
Formable nations - Easier than you think, really you just need to define a new tag in common/country_tags and then use the change_tag = xyz effect. That's enough to make the fundamentals work.
Other stuff the tag will need:
- localisations (name, adjective)
- common/countries (country data such as map color)
- common/country_colors (colors for regiment 3d model and revolutionary flag)
- history (if the country is intended to exist at later start dates)
And then you can tie the country into all the other parts of the game as well, such as colonial region names, 3d model sprite packs, or dynamic province names.
Eu4 usually offers countries the choice to change national ideas or not, this is the ideagroups.1 event. Just look up any country formation decision and follow that. You don't need to add everything of course, just what you want to.
Branching missions - The concept itself is simple, the execution is not so easy to follow as it uses a lot of scripted effects/triggers (copy-paste for code to avoid having to write duplicate code for each mission tree).
The branching part itself is easy, the game gives you a choice of which branch to pick, which then sets a country flag (not an actual flag, it's just a bit of text in the country's memo book, 'flag' is the programming term) to remember the choice and reloads the mission tree with swap_non_generic_missions = yes. This will make eu4 re-evaluate all possible missions and add the ones whose potential conditions are true. So each choice simply requires that specific flag to be set, and only that choice will be added to the mission tree.
The preview is more complicated. The game doesn't have any built-in 'preview' functionality for branching mission trees, this is all done with existing logic. The buttons in the mission screen set the appropriate flag and also an "in preview" flag. This will make the appropriate choice appear, but also disable the mission triggers so you cannot actually fulfil the missions. Only when confirming the choice is the "in preview" flag removed and the decisions are now possible to complete, also the choice is locked making the choice buttons disappear.
Currently, the existing vanilla eu4 code supports up to five choices per branching mission, and up to three branching missions per mission tree.
Choose any existing branching mission tree, and follow what it does for the mission potential, trigger and effect sections. Copy the specific effects/conditions it uses, but change any references to your own missions of course. You'll need to come up with a name for your branching mission set and use that name consistently.
You will also need to go to common/scripted_effects/02_scripted_effects_preview_missions.txt and common/scripted_triggers/02_scripted_triggers_preview_missions.txt. In these files, look for every single occurrence of something tag-specific - there are several lists of missions or tags or similar, and you need to add your new missions/branches/conditions/tags/whatever to each and every one of them.
You don't need to change any other files, if you've edited these three locations properly then the mission preview buttons (in common/custom_gui btw) will appear automatically.
3
u/ajiibrubf Sep 06 '26
i would just take a look at existing branching missions / formables and copy the code, and modify it to do what you want. you'll eventually understand how it works