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

CK2 Dev Diary #58: Modding and a bit of optimization

Good afternoon, all. I’m Magne “Meneth” Skjæran, the programmer on CK2. In the past I’ve written dev diaries about modding, optimization, and quality of life improvements, as well as last week’s dev diary talking about the life of a bug, and the one before that about what each role on the team is responsible for.

Summer is still ongoing, and most of the office is gone until the end of July, including the majority of the CK2 team. The show must still go on, so for these four weeks I’ll be writing most of the CK2 dev diaries.

Since most of the team being on vacation means that little development is happening, that means that these four dev diaries will be pretty light on info about the upcoming expansion and patch, but I hope to provide you with some interesting insights, info, and tidbits regardless.

Today, I’ll be talking about what we’re doing to make the game more moddable in 2.8. As a former modder, this is one of my favorite topics, and I’ve had the privilege to implement much of the functionality I’ll be mentioning.

I’ll also talk briefly about some optimizations we’ve made to the game to make it faster.
At the end of this diary, I’ll also share five changelog entries from the 2.8 patch chosen (mostly) at random.

Our Commitment
As I talked about in the Mods and Mod Telemetry dev diary, we consider mods and modders to be a great thing for CK2. Mods increase the longevity of the game by letting people tweak it to their liking, to explore alternate scenarios, and alternate realities. At the time of writing, just under half (48%) of all players who played yesterday were using at least one mod, up from 42% when I wrote the Mods and Mod Telemetry dev diary.
On top of that, a significant number of people at PDS are former modders.
Additionally, most things that make modders happy also makes our content designers’ work easier, or opens up new possibilities entirely.

As such, moddability has long been something we as a team have been dedicated to, and the 2.8 patch will be no exception to that.

Some Highlights
The moddability changelog (see the bottom of this post) in 2.8 will be massive, so I want to highlight a few features in particular that I think people will like:

- Most effects and triggers that take a number can now take a variable name instead, and will grab the variable from the current scope. E.G., "wealth = test_variable"

This adds a huge amount of flexibility to what can be done with variables. While before you couldn’t really use variables beyond localisation and comparisons, now you can use them in almost all numeric effects and triggers.

- Made the following console commands that before were only available to devs and beta testers available to everyone: guibounds, noai, join_society, leave_society, society_rank_up/down, society_currency, set_society_grandmaster, get_all_artifacts, activate_artifacts

Especially the first console command will be useful, which is why I mentioned it back in the Mods and Mod Telemetry dev diary.

- Targeted decisions now support having a 3rd party character or artifact

While before we had targeted decisions to allow you to select one other character that’s affected by a decision, now you can select a third. This can use all the same filters as the regular targeted decisions can, with the player selecting the target character or artifact from a list that contains the characters/artifacts that meet the decision’s third party potential. I’m looking forward to seeing what sort of stuff people will come up with based on this. It also supports a scriptable scoring system for the third party, which is used for sorting the list, and can also be referenced in script via variables.

- Now possible to store variables in the same manner as event targets; any variable starting with "local_" will work this way, meaning it'll persist as long as the event chain does, but not be accessible outside it

For any variable that’s only used for a single event chain, this means you no longer have to deal with resetting it once the chain is done.

- Uploading mods to Steam is no longer limited to 50MB

This is probably the change with the biggest immediate effect. Right now the max size of CK2 mods is significantly limited, but with 2.8 that will be a thing of the past.

- Effect and trigger scope changes now have an optional "show_scope_change" parameter. If set to "no", the scope change won't be shown in the tooltip. It'll be shown as just "effect description" rather than "scope change: effect description". This functionality isn't supported by any/random scopes.

While purely visual, this can in many cases result in much nicer looking tooltips.

- Added "conditional_tooltip"; defines when a given piece of trigger script should be displayed. Its contents are only evaluated if it is displayed

If you’ve ever had a trigger that varies based on someone’s tier, you’re likely to have wanted this. With this you can make sure only the trigger that’s relevant for the current situation is displayed, significantly reducing the size of many tooltips. In vanilla it is also useful for requirements that vary based on DLC.

- Absolutely all tooltips now support custom loc. Generally, "Root" will be the player

This means that custom loc that only depends on the viewer will now work nearly everywhere, which should make showing what you want a lot easier.

- All numerical triggers now support comparison operators (>=, <=, <, >, and ==) with a few exceptions: tier triggers, among_most_powerful_vassals. These exceptions are due to operation triggers breaking existing behavior (E.G., "tier = duke" isn't equivalent to "tier >= duke", which the comparison operators assume)

This is something I’ve wanted to do ever since we introduced comparison operators, however the sheer amount of time it’d take has prevented it until now. This should make a lot of script cleaner, as well as opening up some new possibilities. Especially when combined with variables being usable as the right-hand-side.

- Added support for "else_if" and "else". If one of these is placed after an "if" or "else_if", it will be executed if the "if"/"else_if" limit returns false. Example
Code:
    if = { limit = { something = yes } do_something = yes }
    else_if = { limit = { something_else = yes } do_something_else = yes }
    else = { do_another_thing = yes }
This is another piece of functionality that was already possible to replicate in script, but incredibly tedious. Now, those horrible checks where you want to figure out which of several alternatives to use can be condensed significantly.

- Added a fail_trigger_effect field for events. This effect is triggered if script attempts to trigger an event, but the trigger isn't fulfilled. Useful for handling things like one character in a chain dying for unrelated reasons partway through the chain

Added on the same day as I’m writing this at Matthew Clohessy’s (GoT modder who is working as a content designer on CK2 for the summer) request, this should make handling event chains that could go awry due to unrelated happenings a lot easier.

Optimization
With the highlights of our modding improvements covered, let’s talk a bit about optimization.

While the speed increase won’t be nearly as big as the improvement that came with the 2.6 patch, we’ve spent several days making the game faster. In part, this was to make up for the addition of Tibet, but we didn’t simply stop when the game was once more as fast as 2.7.1.

Overall, the game is in my tests about 8% faster than 2.7.1, though the exact improvement will vary from machine to machine.

Here’s a list of some of the things we’ve done to achieve this:
  • Ported the GUI optimization HoI4 mentioned half a year ago
  • A number of other GUI optimizations, most notably making the outliner faster
  • Moved a number of things from serial evaluation to parallel evaluation
  • Avoiding a number of unnecessary updates to province and character modifiers. For example, acquiring an artifact with no effect will no longer cause the character’s modifier to refresh
  • Making courtiers check events less often (but still having the same overall chance to get them)
  • Eliminating a number of unused variables that were being pointlessly saved
  • Making the AI check a large number of decisions less often when it had a low chance of taking them. E.G., if it had a 1% chance of taking a decision each month, it’ll now generally have a 10% chance of taking it each year instead
  • Further reductions to the number of unnecessary characters generated. For example, when the AI wants to get rid of a barony it’ll now try to find someone appropriate to give it to, and only if that fails will it generate a random character
  • Various structural changes to code to make it more performant
All in all, this should result in a small, but noticeable, improvement to game speed.

Summary
Modding and game speed is very dear to us on the CK2 team, and thus something we’ve spent some time on improving for 2.8.

Now, as promised, here’s the modding changelog for 2.8. Note that some entries that relate to features that have not yet been revealed have been removed from the list. This list is also not final; more will almost certainly be added before 2.8 is released.

Code:
- Split the defines CONTESTED_TITLE_OCCUPIED_WARSCORE_BONUS and CONTESTED_TITLE_OCCUPIED_WARSCORE_BONUS_INDEP into attacker and defender version
- Split the 'ticking_war_score_multiplier' in Casus Belli scripts into 'att_ticking_war_score_multiplier' and 'def_ticking_war_score_multiplier'
- Added a new define for the effect of Fort Level on defender morale in sieges: FORT_LEVEL_MORALE_LOSS_REDUCTION_MULT
- Fixed a number of scopes not getting localised as effects, only as triggers
- error.log will now usually tell you if you've saved a map file in the wrong format
- The game will now crash slightly earlier if the province map is the wrong size (not a multiple of 64), making the issue easier to identify
- Cultures can now have "dynasty_name_first = yes" which puts the dynasty name before the personal name
- Added a "holding_types" folder in common. This can be used to define additional triggers for building each holding type
- The scaled_wealth trigger now supports "min" and "max" just like the scaled_wealth effect
- Fixed "effect" in history not being seeded, meaning that all effects with a random component would always produce the exact same result. Now the result will be properly randomized
- Build cost and build time modifiers now apply to forts, trade posts, and hospitals too. Note that there are still no type-specific modifiers for these three holdings
- on_heresy_takeover no longer creates a dummy character for the religion scope, but instead uses an actual religion scope
- "Religion" in loc while already in a religion will just return the same religion, to ensure that any loc written based on some on-actions using characters as makeshift religion scopes continue to work. The same has been done for "Culture" in culture scopes
- Most effects and triggers that take a number can now take a variable name instead, and will grab the variable from the current scope. E.G., "wealth = test_variable"
- gain_effect now fires in all cases (except history and death) for job titles and minor titles, including when added through script
- lose_effect or retire_effect now fires in all cases (except history and death) for job titles and minor titles. Being given a new job title will fire retire_effect on the old title, and gain_effect on the new title
- Fixed resigning as a commander firing lose_effect rather than retire_effect
- Added death_effect for job titles and minor titles, which fires when a character dies while holding the job/minor title
- Made the following console commands that before were only available to devs and beta testers available to everyone: guibounds, noai, join_society, leave_society, society_rank_up/down, society_currency, set_society_grandmaster, get_all_artifacts, activate_artifacts
- Added the console command "province_religion" or ("prov_rel") to change the religion of a province. Syntax is: "province_religion <province> <religion>"
- Targeted decisions now support having a 3rd party character or artifact
- Now possible to store variables in the same manner as event targets; any variable starting with "local_" will work this way, meaning it'll persist as long as the event chain does, but not be accessible outside it
- Uploading mods to Steam is no longer limited to 50MB
- Added the following targeted decision filters: court_including_me, home_court_including_me, dynasty_including_me, all_including_me, society_including_me, realm_including_me, sub_realm_including_me
- The regular versions of the above now consistently exclude the character themselves; in some cases before this restriction only applied if the AI was taking the decision
- Added max_defender_occupation_score and max_attacker_occupation_score modifiers for casus belli types
- Added documentation for the "aggression" parameter for governments
- Added a become_secret_heretic effect
- Added TRADE_ROUTE_SIEGE_MULTIPLIER and TRADE_ROUTE_OCCUPATION_MULTIPLIER defines
- Made the tributary system moddable and modular. You can now add new tributary types defining:
    - when and if the tributary relation breaks
    - what CBs the tributaries can use against their suzerain
    - The allowed_to_target_suzerains CB parameter no longer has any effect, as the above replaces it
    - if tributaries can unite together against their suzerain
    - if tributaries can fight against each other
    - if the suzerain can call their tributaries to arms, and if the tributaries are forced to join
    - if the tributaries can call their suzerain to their defense, and if the suzerain is forced to join
    - how much of what is paid by the tributary to the suzerain
    - What icon to use for the diplomatic relation
    - What modifiers to give the tributary
- You can now use the is_tributary trigger to check for a specific type, and a specific suzerain
- You can now use custom loc in the is_tributary trigger
- The set_tribute_suzerain now takes a "type" parameter, specifying the type. If none is specified, "default" is used
- Added set_trade_route_base_value and set_trade_route_value_multiplier effects
- Provinces with several trade routes will now show the presence and effect of all of them in their tooltip
- Effect and trigger scope changes now have an optional "show_scope_change" parameter. If set to "no", the scope change won't be shown in the tooltip. It'll be shown as just "effect description" rather than "scope change: effect description". This functionality isn't supported by any/random scopes.
- Added hostages_block_cb parameter for CBs
- Variables that haven't been set yet now work in localisation; they'll show "0" rather than simply being blank. "GetName" works as well. So [global_test.GetName] will return 0 for GetValue, and the "global_test" localisation for GetName
- Fixed the is_interested_in_society trigger not localising properly if negated, and not ending with a linebreak
- Added interested_in_society_of_character trigger
- Fixed empty "OR" triggers in some cases crashing the game on launch
- show_as_title = yes for minor titles now works even if the character has no titles
- Fixed a crash that could happen when a selectable object overlapped with an impassable province
- Fixed setting someone's employer on the same date that employer becomes landed not working properly
- Fixed capital changes in some cases failing if the county holder became holder on the same day as the capital change
- Added as_if_allied_to parameter for gain_settlements_under_title, vassalize_or_take_under_title, subjugate_or_take_under_title, and vassalize_or_take_under_title_destroy_duchies. This ensures that land occupied by people in that character's war against the title's holder can be taken
- Castes can now be enabled for individual religions rather than being hardcoded to the Indian group. This is done using the "castes" parameter
- Removed various hardcoding associated with the Hindu religion. This is now connected to the "caste_opinions" parameter instead
- The subjugation opinion is no longer applied when using vassalize_or_take_under_title, just subjugate_or_take_under_title
- Added event pretrigger for Game Book
- Decisions can now have a "_desc_extra" localisation key defined. This will be shown after the Requirements section in its tooltip
- Added "conditional_tooltip"; defines when a given piece of trigger script should be displayed. Its contents are only evaluated if it is displayed
- Added government parameters gets_religion_opinion_penalties, gives_religion_opinion_penalties, and vassal_government_opinion_penalties. See _governments.info for documentation
- Added title parameters can_be_claimed and can_be_usurped. See 00_landed_titles.info for documentation
- You can now use "extended" (bracket-based) localization in Artifact scopes:
    - [GetName] will display the name
    - [Owner] will rescope to the current owner of the artifact
    - [OriginalOwner] will rescope to the original owner of the artifact
- There is now an AI exclusion pretrigger in decision "ai = no" that can be used to avoid decisions being considered by the AI at all
- Removed the "coalition_threat" CB parameter as it had nothing to do with coalitions
- Fixed rulers in some cases being considered to have no primary holding on the day of their death when going backwards in history
- Added console commands "print_global_flags" (aka "pgf") and "print_global_variables" (aka "print_global_vars" and "pgv"). They print whatever they're named after
- "character_info" aliased to "debug_mode" since it is used by more than just character to display debug info
- Added "attrition" character modifier. This will reduce/increase the attrition suffered by the army they command. It is capped at -99%
- Added "army_reinforce_rate" character modifier. This will make the army the character commands reinforce faster. Affects retinues and horde units as well, not just levies. Does not affect the reinforcement of the settlement itself. Cannot go below 0
- Added "days_of_supply" character modifier. This modifies the number of days of supply of the army the character commands by an absolute number of days. Days of supply cannot go below 1
- Added command modifiers phase_skirmish_attack, phase_pursue_attack, phase_melee_attack, phase_skirmish_defense, phase_pursue_defense, and phase_melee_defense
- Added scopes any_neighbor_independent_ruler and random_neighbor_independent_ruler. A "neighbor independent ruler" is a ruler that neighbors the realm you're in (E.G., the HRE if you're a count in the HRE)
- Added "demesne_size_compared_to_limit" trigger. For example, "demesne_size_compared_to_limit < 0.5" will check if someone is below 50% of their demesne limit
- Added "multiplicative_trade_post_income_modifier" holding modifier
- Added "can_create_empires" government parameter (can_create_kingdoms already exists)
- Added "extra_ai_eval_troops" title parameter. See 00_landed_titles.info for documentation
- Added "relative_realm_size" trigger. For example, relative_realm_size = { who = liege size > 0.2 } checks that your realm size is at least 20% of your liege's
- Strings that are too long (above 1023 characters) will no longer crash the game, though they should still be avoided as they simply don't work beyond 1023 characters. This should also solve crashes involving mismatched quote signs
- Strings that are too long now get logged in error.log
- The game will no longer crash if more than 32767 flags (E.G., set_character_flag) are used. New limit is 2^32, which you will run out of memory long before reaching
- Using export_to_variable on a dead character will no longer crash the game
- has_coa_on_barony_only can now be set to yes/no on individual religions rather than just groups. This will override whatever has been set for the group
- The "give_title" console command now gives more feedback if something is wrong with the parameters
- Absolutely all tooltips now support custom loc. Generally, "Root" will be the player
- Most text directly related to religion (E.G., religion name, description, holy war name) now provide the religion itself for custom loc purposes
- Added a "RelHead" promotion for religion loc, meaning you can now for example name a religion "Cult of [RelHead.GetFirstName]"
- Added optional generate_tooltip parameter for hidden effects. If set to "no", the game won't generate the tooltip at all. Note that if event targets are set in the hidden effect, this will break them in tooltips. It may also break randomization, so only ever use it if you have a really compelling reason to do so
- Added 'add_modifier' and 'remove_modifier' console commands (for Character Modifiers.)
- Added 'decision' console command, which ignores the trigger conditions
- Stewardship no longer applies a debuff when below 5; 0 is its baseline now like all the other stats
- Added 'realm_levies_plus_allies' as an exportable value for the 'export_to_variable' effect.
- Added a Define for Looter army maintenance cost (LOOTER_ARMY_MAINT_MULT)
- random_list chances below 1% but above 0% will now use 2 decimals rather than 0
- The game will now log invalid tributary relationships in history (E.G., someone being a tributary of a title with no holder)
- Fixed looting for raiding adventurers not of a religion/culture/government that allows raiding not working
- If the flag "always_show_in_marriage_selection" is set on a character, they will bypass most conditions to be shown in the marriage selection view. Note that this does *not* allow otherwise illegal marriages, just ensures they show up in the listing
- Fixed observing unplayable characters instantly booting you back to regular observe mode
- Fixed the "completely_controls" trigger not considering empty non-wasteland provinces
- Fixed scoping to event targets in effects not being properly localised, thus showing just a colon with no name before it
- Added "ai_check_interval" parameter for decisions. This determines how rarely the AI checks a given decision, and can be useful for performance-heavy decisions that don't need to be checked often. See 00_decisions.info for documentation
- Added a "shares_realm_border_with" trigger. Checks if any province in your realm (everything under your titles) borders any province in their realm
- Added COALITION_THREAT_MAX_DISTANCE define. Independent AIs will consider independent rulers within this range to be threats if they're strong enough (COALITION_SCARY_TROOP_STRENGTH_THREAT_RATIO)
- "Added COURTIER_EVENT_PROCESS_OFFSET define, which determines how often courtiers check MTTH events. Set to 50, as compared to 20 for rulers". This changelog entry from 2.7 now actually has an effect
- Added num_of_society_members trigger. Scope must be a character or society. Returns true if the society has at least this many members. Also supports <, <=, ==, and >=
- A lot of error messages that previously only showed in the internal beta .exe now get logged at all times
- Added "hire_range" parameter for mercenary titles. If set, this overrides the MERCENARY_HIRE_DISTANCE_THRESHOLD define for that specific mercenary
- Added "can_demand_religious_conversion" government parameter. Decides whether people with the government can use the Demand Religious Conversion interaction. Defaults to yes
- create_character now supports "dynasty = actually_culture" which picks a random dynasty name from the culture if there's no unused static dynasty to use, rather than just resorting to a random holding in the world (what "dynasty = culture" does)
- Now possible to scope to timed modifiers in localisation. For example, if ROOT is a character, [Root.modifier_name.GetExpiryDate] would show the expiry date of the modifier. If no such modifier is present, nothing gets shown. Also supports "GetName"
- random_direct_de_jure_vassal_title now exists. Works like any_direct_de_jure_vassal_title, except picks one at random
- Fixed start_date and current_date checking that the days are equal rather than equal or greater
- All numerical triggers now support comparison operators (>=, <=, <, >, and ==) with a few exceptions: tier triggers, among_most_powerful_vassals. These exceptions are due to operation triggers breaking existing behavior (E.G., "tier = duke" isn't equivalent to "tier >= duke", which the comparison operators assume)
- Added "unsafe_destroy_artifact" effect, which can destroy indestructible artifacts
- Artifact localisation (E.G., name and desc) now provides the artifact as From
- The artifact activation and gift triggers now provide the artifact as From
- Added support for "else_if" and "else". If one of these is placed after an "if" or "else_if", it will be executed if the "if"/"else_if" limit returns false. Example:
    if = { limit = { something = yes } do_something = yes }
    else_if = { limit = { something_else = yes } do_something_else = yes }
    else = { do_another_thing = yes }
- Added trigger "artifact_can_be_gifted_to = ROOT", which checks if the artifact currently scoped to can be gifted to the target character
- Now possible to specify "sound = no" for death reasons, which will prevent killing someone with that reason causing a death sound
- Fixed FROMFROM (the holding title) not always being available in the building trigger
- Fixed whatever character is FROM getting included in event option portrait lists if you scope to something that isn't a character
- Improved the error messages for the reload_texture command, and made it more forgiving when it comes to "/" vs. "\\" and ".dds" vs. ".tga". Also fixed it in some cases crashing. Generally, simply copying the path specified in the .gfx file should work
- Added COST_COMBAT_RATING define for specifying the cost of combat rating in the ruler designer
- Added unsafe_impregnate and unsafe_impregnate_cuckoo effects. These can impregnate someone who is already pregnant, while the two old effects are no longer able to do so
- Added a fail_trigger_effect field for events. This effect is triggered if script attempts to trigger an event, but the trigger isn't fulfilled. Useful for handling things like one character in a chain dying for unrelated reasons partway through the chain
- Fixed not all parts of the society rank tooltip having the appropriate scopes set
- spawn_unit can now take "province = closest_to_capital", which will spawn as close to the character's capital as possible
- The "debug_mode" console command (AKA "charinfo") will now also show extra information about titles

I hope you’ve found what we’re doing for modders in 2.8 interesting.

And as promised, here’s five entries from the 2.8 changelog:
- Told the AI that if it is the attacker in a war, it *might* be a good idea to actually go attack the defender even if you're targeting their whole realm rather than a specific title within it, and it is a bit of a long walk
- The holy site icon for heresies are now shown in the holding view if their parent religion does not have the same holy sites (E.G., Ibadi and Manichean holy sites)
- Fixed the retinue screen showing the Horse Archer icon even if your retinues are composed of another special unit
- Armies now use whichever flank leader has the best siege modifier for determining the leader bonus to sieges, and the best movement speed flank leader for determining movement speed
- Raiding adventurers now realize once they've been settled that maybe, just maybe, they should consider their new realm their base of army operations, and return armies there when they're not up to anything

That’s all for this week. Next week I’ll be handing the reins over to Gustav “Gruffa” Groth, CK2’s Product Manager, who will tell you about what he and the publishing wing of Paradox does for CK2.
 
I think your problem might simply be that there's no way to scope to a flank except via its leader? There's left_flank_leader, but no left_flank.
I thought there were flank scopes though? I recall them being used with tactics? ah, guess I need to begin asking for you to add in flank scopes then! :D
 
I thought there were flank scopes though? I recall them being used with tactics? ah, guess I need to begin asking for you to add in flank scopes then! :D
Flank scopes exist, but you can't get to them unless they're already set by code (like in tactics selection) or from someone leading the flank or a subunit within it.
 
BTW, just to point out that in the charlemagne start date Tang dynasty had protectorates in Tarim Basin. Maybe not add them under China but as just chinese rulers.
 
Flank scopes exist, but you can't get to them unless they're already set by code (like in tactics selection) or from someone leading the flank or a subunit within it.
Ah, would it be difficult then to add the flank scopes in for event scripting then? That would certainly explain the difficulties that I have been having, and having those scopes would be very useful.
 
Ah, would it be difficult then to add the flank scopes in for event scripting then? That would certainly explain the difficulties that I have been having, and having those scopes would be very useful.
Not especially. No promises though.
 
Cheers for the DD Meneth :cool:. While I don't think I'll ever mod CK2 (nothing personal, but I'm a really slow modder, and I suspect I'll be on HoI4 until CK3 appears) I still play the occasional CK2 mod, and those changes look excellent :). Optimisation also goes well. Be sure to redecorate the office in whatever colour you feel most appropriate while everyone's on holiday :D.
 
Be sure to redecorate the office in whatever colour you feel most appropriate while everyone's on holiday :D.
I'm actually on holiday as well. Wrote the DD last week before I left for Oslo.
Only person left on the CK2 now is Matt. I'll be back next week though, as will a few other people.
 
Oh God! This is one of the best dev diaries I have ever read, it nearly brought me to tears (no kidding) with the increased amount of moddability it allows. :D
 
This is absolutely amazing. :D

Edit:
- Most effects and triggers that take a number can now take a variable name instead, and will grab the variable from the current scope. E.G., "wealth = test_variable"

I'm just wondering... would it be possible to get this for modifiers as well?
 
Last edited:
The only thing I understand about those modding changes is that people who are far more computer literate than me will do great things with them.
 
Lots of good stuff here! Won't even try to comment on everything, but will comment on some of my favourites

- Most effects and triggers that take a number can now take a variable name instead, and will grab the variable from the current scope. E.G., "wealth = test_variable"

This adds a huge amount of flexibility to what can be done with variables. While before you couldn’t really use variables beyond localisation and comparisons, now you can use them in almost all numeric effects and triggers.

Should be useful as you'll no longer need to check for the size of a variable before adding/subtracting it to something...

- Targeted decisions now support having a 3rd party character or artifact

While before we had targeted decisions to allow you to select one other character that’s affected by a decision, now you can select a third. This can use all the same filters as the regular targeted decisions can, with the player selecting the target character or artifact from a list that contains the characters/artifacts that meet the decision’s third party potential. I’m looking forward to seeing what sort of stuff people will come up with based on this. It also supports a scriptable scoring system for the third party, which is used for sorting the list, and can also be referenced in script via variables.

Sounds very useful if you want to try to build your own marriage/betrothal/concubinage system (though figuring out proper AI logic will still be an interesting experience). Can the third party item include titles, if we want to try to build a homemade title grant/revokation/etc. system?

- Added "conditional_tooltip"; defines when a given piece of trigger script should be displayed. Its contents are only evaluated if it is displayed

If you’ve ever had a trigger that varies based on someone’s tier, you’re likely to have wanted this. With this you can make sure only the trigger that’s relevant for the current situation is displayed, significantly reducing the size of many tooltips. In vanilla it is also useful for requirements that vary based on DLC.

Should be useful. Of course, it might potentially be annoying as you want know how the conditions will change if your tier changes (e.g. "If you are a king, pay 100 g, if you are an emperor, pay 1000 g), though that will hopefully not prove to be a major issue.

- All numerical triggers now support comparison operators (>=, <=, <, >, and ==) with a few exceptions: tier triggers, among_most_powerful_vassals. These exceptions are due to operation triggers breaking existing behavior (E.G., "tier = duke" isn't equivalent to "tier >= duke", which the comparison operators assume)

This is something I’ve wanted to do ever since we introduced comparison operators, however the sheer amount of time it’d take has prevented it until now. This should make a lot of script cleaner, as well as opening up some new possibilities. Especially when combined with variables being usable as the right-hand-side.

- Added support for "else_if" and "else". If one of these is placed after an "if" or "else_if", it will be executed if the "if"/"else_if" limit returns false. Example
Code:
    if = { limit = { something = yes } do_something = yes }
    else_if = { limit = { something_else = yes } do_something_else = yes }
    else = { do_another_thing = yes }
This is another piece of functionality that was already possible to replicate in script, but incredibly tedious. Now, those horrible checks where you want to figure out which of several alternatives to use can be condensed significantly.

Nice!

- Added a fail_trigger_effect field for events. This effect is triggered if script attempts to trigger an event, but the trigger isn't fulfilled. Useful for handling things like one character in a chain dying for unrelated reasons partway through the chain

Added on the same day as I’m writing this at Matthew Clohessy’s (GoT modder who is working as a content designer on CK2 for the summer) request, this should make handling event chains that could go awry due to unrelated happenings a lot easier.

This should be useful.

Making the AI check a large number of decisions less often when it had a low chance of taking them. E.G., if it had a 1% chance of taking a decision each month, it’ll now generally have a 10% chance of taking it each year instead

Excellent! This should make it less problematic if you have a lot of rare decisions available. How does this work with targeted decisions, though? Will the AI check them less frequently per target, or less frequently in total, e.g. if the "Seduce" targeted decision is set to be checked once per year for the AI, will it be checking target A once per year and target B once per year, or will it check one target every year?

- Cultures can now have "dynasty_name_first = yes" which puts the dynasty name before the personal name

Nice! A semi-related question/request: Currently, if you do not set "dynasty_title_names = yes" for a culture but set "has_coa_on_barony_only = no", the CoA for the title will be randomized, but if you enable dynasty_title_names as well you get the dynasty's CoA for the title. Could these triggers be decoupled so that you can use non-dynastic title names (if the dynasty has a culture with them disabled) but dynastic CoAs for a specific religion? The opposite (dynastic title names but proper CoAs) is already possible for some combinations of culture and religion (e.g. a Christian Andalusian Andalusia will use the regular CoA but be called e.g. "the Umayyad Sultanate"), and it would be situationally interesting to use the opposite (e.g. having some pagan religion use the proper title names but use their dynastic CoA for their primary title).

- Added a "holding_types" folder in common. This can be used to define additional triggers for building each holding type

Should be useful. Does this include forts, hospitals, and trade posts as well?

- Added the following targeted decision filters: court_including_me, home_court_including_me, dynasty_including_me, all_including_me, society_including_me, realm_including_me, sub_realm_including_me

Nice! Could we possibly have something like "close_relatives", "close_relatives_and_marriage_ties", "friends", and "lovers" added as well (it might be a bit late for this patch, though)? I would assume that it is more cost-effective to have those as pre-defined filters than scoping to them from the "all" scope...

- Made the tributary system moddable and modular. You can now add new tributary types defining:
- when and if the tributary relation breaks
- what CBs the tributaries can use against their suzerain
- The allowed_to_target_suzerains CB parameter no longer has any effect, as the above replaces it
- if tributaries can unite together against their suzerain
- if tributaries can fight against each other
- if the suzerain can call their tributaries to arms, and if the tributaries are forced to join
- if the tributaries can call their suzerain to their defense, and if the suzerain is forced to join
- how much of what is paid by the tributary to the suzerain
- What icon to use for the diplomatic relation
- What modifiers to give the tributary

This will of course be very useful.

- The subjugation opinion is no longer applied when using vassalize_or_take_under_title, just subjugate_or_take_under_title

Good! Will be great to avoid having that opinion modifier added where it is unwanted...

- Added title parameters can_be_claimed and can_be_usurped. See 00_landed_titles.info for documentation

Sounds like it might be useful (though slightly vague when this short).

- Added a "RelHead" promotion for religion loc, meaning you can now for example name a religion "Cult of [RelHead.GetFirstName]"

Neat!

- Added 'add_modifier' and 'remove_modifier' console commands (for Character Modifiers.)

Any chance this might be added for province modifiers down the line?

- Added "can_demand_religious_conversion" government parameter. Decides whether people with the government can use the Demand Religious Conversion interaction. Defaults to yes

Should be useful. A semi-related question/request: Any chance the nomadic willingness to intermarry with foreign religions could be changed from always being a thing (which can lead to unwanted marriage offers between them and non-nomads) and replaced with a can_intermarry_with block for governments (taking a list of other governments that characters with the government will accept intermarriage with) and an intermarry_with_own_government parameter (defaulting to "no", allowing two characters with the same government to intermarry even if their religions don't normally allow it if set to "yes")? Could be useful for various kinds of situational intermarriage where the regular "intermarry = X" setting is likely to cause issues (e.g. if you have some culture-specific government that you want to allow intermarrying for but you normally want the relevant religions to avoid intermarriage)...

- create_character now supports "dynasty = actually_culture" which picks a random dynasty name from the culture if there's no unused static dynasty to use, rather than just resorting to a random holding in the world (what "dynasty = culture" does)

Nice!

- Added unsafe_impregnate and unsafe_impregnate_cuckoo effects. These can impregnate someone who is already pregnant, while the two old effects are no longer able to do so

Nice to know that the old ones have been fixed to avoid that issue if we forget to check for it. How does the new command interact with father_of_unborn, though, given that the fathers might differ (which might be an issue if you are checking for infidelity and one child has the proper father but the other(s) don't)? Also, a somewhat related question: Any chance we might get an end_pregnancy effect? It could be useful for all kinds of fantasy modding with restrictive interbreeding and if we want to add in miscarriages, abortions, or the like.

- spawn_unit can now take "province = closest_to_capital", which will spawn as close to the character's capital as possible

Will this try to find a province without hostiles in it? Also, any chance we could have a closest_to_de_jure_capital too (I assume the command above checks for the de facto capital)?

- The "debug_mode" console command (AKA "charinfo") will now also show extra information about titles

What kind of information can we see? Title flags would be one thing, I assume, but anything else?

And as promised, here’s five entries from the 2.8 changelog:
- Told the AI that if it is the attacker in a war, it *might* be a good idea to actually go attack the defender even if you're targeting their whole realm rather than a specific title within it, and it is a bit of a long walk
- The holy site icon for heresies are now shown in the holding view if their parent religion does not have the same holy sites (E.G., Ibadi and Manichean holy sites)
- Fixed the retinue screen showing the Horse Archer icon even if your retinues are composed of another special unit
- Armies now use whichever flank leader has the best siege modifier for determining the leader bonus to sieges, and the best movement speed flank leader for determining movement speed
- Raiding adventurers now realize once they've been settled that maybe, just maybe, they should consider their new realm their base of army operations, and return armies there when they're not up to anything

Some useful stuff, and some amusing stuff.
 
Sounds very useful if you want to try to build your own marriage/betrothal/concubinage system (though figuring out proper AI logic will still be an interesting experience). Can the third party item include titles, if we want to try to build a homemade title grant/revokation/etc. system?
No title support at the moment.

Excellent! This should make it less problematic if you have a lot of rare decisions available. How does this work with targeted decisions, though? Will the AI check them less frequently per target, or less frequently in total, e.g. if the "Seduce" targeted decision is set to be checked once per year for the AI, will it be checking target A once per year and target B once per year, or will it check one target every year?
The overall frequency changes. Before it'd check all possible targets each month. Now it'll check all possible targets every say, 3 months.
Should be useful. Does this include forts, hospitals, and trade posts as well?
Yep!
Nice! Could we possibly have something like "close_relatives", "close_relatives_and_marriage_ties", "friends", and "lovers" added as well (it might be a bit late for this patch, though)? I would assume that it is more cost-effective to have those as pre-defined filters than scoping to them from the "all" scope...
"friends" is already a filter.
The others might be neat. No promises.
How does the new command interact with father_of_unborn, though, given that the fathers might differ (which might be an issue if you are checking for infidelity and one child has the proper father but the other(s) don't)? Also, a somewhat related question: Any chance we might get an end_pregnancy effect? It could be useful for all kinds of fantasy modding with restrictive interbreeding and if we want to add in miscarriages, abortions, or the like.
Same as the old one.
An effect like that wouldn't be too difficult to make. No promises though.
Will this try to find a province without hostiles in it? Also, any chance we could have a closest_to_de_jure_capital too (I assume the command above checks for the de facto capital)?
It's meant for ships, so hostiles don't really matter to it. For land, it is pretty easy to just scope to exactly where you want to spawn something, but that's trickier for sea, hence this command.
What kind of information can we see? Title flags would be one thing, I assume, but anything else?
Title flags, and some attributes like "IsTemporary" and "IsDynamic". Also the numerical ID for the title, and the name in script (E.G., k_norway).
 
No title support at the moment.

I see. The feature will still be useful without it, though title support would be nice in the future.

The overall frequency changes. Before it'd check all possible targets each month. Now it'll check all possible targets every say, 3 months.

Seems good. Should make a lot of infrequent targeted decisions less taxing.


Awesome! This will come in handy.

"friends" is already a filter.

Ah. I haven't had a need to use it (yet), and it wasn't listed on the wiki, so I didn't know it was a thing.

The others might be neat. No promises.

Understandable.

Same as the old one.

That begs the question: How does the old one currently work if there are multiple pregnancies with different fathers? I don't think I have experienced it, but it seems like it could get messy if you want to alert the father of unborn child #1 about something but not the father of unborn child #2 (if different).

An effect like that wouldn't be too difficult to make. No promises though.

Understandable.

[]QUOTEIt's meant for ships, so hostiles don't really matter to it. For land, it is pretty easy to just scope to exactly where you want to spawn something, but that's trickier for sea, hence this command.[/QUOTE]

I thought it might be used on land as well, hence the question.

Title flags, and some attributes like "IsTemporary" and "IsDynamic". Also the numerical ID for the title, and the name in script (E.G., k_norway).

Seems neat.
 
Nice! A semi-related question/request: Currently, if you do not set "dynasty_title_names = yes" for a culture but set "has_coa_on_barony_only = no", the CoA for the title will be randomized, but if you enable dynasty_title_names as well you get the dynasty's CoA for the title. Could these triggers be decoupled so that you can use non-dynastic title names (if the dynasty has a culture with them disabled) but dynastic CoAs for a specific religion? The opposite (dynastic title names but proper CoAs) is already possible for some combinations of culture and religion (e.g. a Christian Andalusian Andalusia will use the regular CoA but be called e.g. "the Umayyad Sultanate"), and it would be situationally interesting to use the opposite (e.g. having some pagan religion use the proper title names but use their dynastic CoA for their primary title).

This would be awesome, as, if I'm understanding correctly, it would potentially allow you make everyone use their own CoA for their nation, but be called whatever the nation actually is.
 
This would be awesome, as, if I'm understanding correctly, it would potentially allow you make everyone use their own CoA for their nation, but be called whatever the nation actually is.

That's what I meant, yes; e.g. if the Romuva faith had "has_coa_on_barony_only = no" (and it always used the dynastic CoA without "dynasty_title_names = yes" for the culture) all Romuva primary titles would use the dynastic CoA but be named e.g. "Lithuania" rather than being named "of Žemaiteje" (which would be the case with "dynasty_title_names = yes", rgardless of religion) or having a random title CoA (which currently happens if you have "has_coa_on_barony_only = no" for the religion and "dynasty_title_names = no" for the culture).