• 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.
Does current_heir work on a per-title basis though? With gavelkind for example you might want all inheriting children to get the trait, while current_heir (to my knowledge) will only give it to your primary heir.
If you want all the heirs to titles to get the trait, you can also handle this in an on_death on_action. In fact, you should.

The specific heir can be found for any demesne title, so yes, it does work on a per-title basis. In fact, if this is the use case, the currently available on_death logic would be the preferred modding approach to implementing such trait inheritance and not any special trait definition features. Maybe you only want it to happen for titles meeting certain conditions, etc. Maybe only certain title heirs are eligible (were they born in the purple? are they women? are they of the same dynasty?).

Generally, I interpret this request as less complicated, though. In these cases, isn't the trait some symbolic thing-- title/status, unique sword, etc.-- that's being inherited? Don't you want that to only be inherited by one character, like everything else that's, say, inherit = yes? On the other end of the spectrum, if you want all the children to get the trait, that's just an inherit_chance = 100 trait (possibly with a potential clause to limit it to one gender or something), yes?

EDIT: Maybe you just weren't aware that you can use the current_heir scope enclosed within a title scope.
 
Last edited:
If you want all the heirs to titles to get the trait, you can also handle this in an on_death on_action. In fact, you should.

The specific heir can be found for any demesne title, so yes, it does work on a per-title basis. In fact, if this is the use case, the currently available on_death logic would be the preferred modding approach to implementing such trait inheritance and not any special trait definition features. Maybe you only want it to happen for titles meeting certain conditions, etc. Maybe only certain title heirs are eligible (were they born in the purple? are they women? are they of the same dynasty?).

Generally, I interpret this request as less complicated, though. In these cases, isn't the trait some symbolic thing-- title/status, unique sword, etc.-- that's being inherited? Don't you want that to only be inherited by one character, like everything else that's, say, inherit = yes? On the other end of the spectrum, if you want all the children to get the trait, that's just an inherit_chance = 100 trait (possibly with a potential clause to limit it to one gender or something), yes?

EDIT: Maybe you just weren't aware that you can use the current_heir scope enclosed within a title scope.
That doesn't work in the case of title usuprtions or abdications.
 
That doesn't work in the case of title usuprtions or abdications.
Abdication and usurpation are not inheritance. See the latest on_new_holder (for titles) on_action moddability request for a way to "inherit" a trait specifically tied to a title, the only cases to which usurpation and abdication apply.
 
I think they need to give modders a proper programming language to write in: Too much of the time are the modders crippled by the arbitrary decisions that are made as to what commands and options are made available
 
I think they need to give modders a proper programming language to write in: Too much of the time are the modders crippled by the arbitrary decisions that are made as to what commands and options are made available
I think the problem stems from their insistence upon being able to generate a semi-readable tooltip from every set of effects/triggers by default. This is harder to accomplish the closer you get to a traditional procedural programming approach. Thing is, if they allowed said more-traditional scripts to also generate their own tooltips manually in the same fashion, it would be a no-brainer on their side and trivial for the script author. Also, there are non-traditional grown-up programming approaches that would still lend very well to a priori tooltip generation.

There will always be the issue of what "commands and options" are [not] available, though. If we had a better language, we'd just call these holes in the API, though.
 
Modding proposal:

Overload the opinion modifier system with an optional modifier 'tag' that indicates to which set of opinion modifiers any given modifier being added between two characters belongs. This would allow multiple topic-related pools of opinion modifiers and their aggregate sums. Vanilla would stay as it is, but if I wanted to use a special opinion modifier pool for some extension that was specifically balanced so that its sum would balance around a certain point with certain extension-specific semantics, then I'd tag those special opinion modifiers together, and I'd be able use, e.g., opinion = { who = liege tag = autonomy value = 0 } as a meaningful trigger. In other words, I want the ability to use multiple instances of the opinion modifier system (in implementation, just tagged per-edge in the relations graph and the running sum for each tag updated like the default "null" tag-- just only including those modifiers of its same tag-- whenever a new opinion modifier is added, removed, or expired).

Opinion modifiers are a powerful tool that already exists in the game, but their utility is broken for applications which want to track relationships along a particular dimension only and not the sum total of all opinion modifiers in the game.
 
Modding proposal:

A reverse_transfer_scaled_wealth command, or simply complete the implementation of transfer_scaled_wealth so that it behaves properly when given a negative scaling factor (deduct from the target rather than send to the target-- both fall under "transfer").

Otherwise, only ridiculously complex methods exist to transfer money from one character to another, scaled to the income of the receiver of the funds.
 
I think the problem stems from their insistence upon being able to generate a semi-readable tooltip from every set of effects/triggers by default. This is harder to accomplish the closer you get to a traditional procedural programming approach. Thing is, if they allowed said more-traditional scripts to also generate their own tooltips manually in the same fashion, it would be a no-brainer on their side and trivial for the script author. Also, there are non-traditional grown-up programming approaches that would still lend very well to a priori tooltip generation.

There will always be the issue of what "commands and options" are [not] available, though. If we had a better language, we'd just call these holes in the API, though.

I think modders would be a lot more happy if they could actually manipulate existing data any way they wanted :)

It's one thing where you can't set part of the game world to a value that you have in a variable (lack of an API cal), it's another thing altogether where you can't even perform all logic on an existing variable.

CK2's scripting language is like a calculator that can only do division - no addition, subtraction, or multiplication

Anyway I agree with everything else you wrote :)
 
Modding proposal, extended (has already been proposed, but since EU4 v1.4 implemented even more than my previously modest suggestion, it seems reasonable to ask for the same functionality that was introduced for modders in EU4 v1.4):

Variable arithmetic and comparison (against other variables), both intra-scope (different variable names) and cross-scope (same or different variable names). Scopes supported should be at least character and province, the current scopes in which the extremely limited variable support currently in CKII already function. Please see this post from Paradox developer Captain Gars on the EU4 modding forum in response to my same request, which is when he first announced that he had implemented and tested all the new requested variable operations (and more), including cross-scope arithmetic/comparison even between different types of scopes (province vs. country in EU4), as well as automatic tooltip localisation for the variables.

He came back with this in a matter of a day. Meanwhile, CKII modders spend hours and hours each, some on a very regular basis, emulating arithmetic and simply failing to be able to provide the same kind of dynamic and powerful mod functionality that would be possible if CKII modding support were not inferior to that of EU4 v1.4, in this respect.

Official related patch notes from the release of EU4 1.4:
- Added effect multiply_variable
- Added effect divide_variable
- All variable effects can now take a second variable as an argument
- check_variable trigger now works the same way as variable effects
- All variable effects and triggers can now take a scope as an argument

So when can I stop emulating binary arithmetic through recursive events with power-of-2 compare-and-subtract chains (only works for integers)? You know, all to compare a single variable to another single variable, or a trigger like wealth... Please end the madness.
 
I think modders would be a lot more happy if they could actually manipulate existing data any way they wanted :)

It's one thing where you can't set part of the game world to a value that you have in a variable (lack of an API cal), it's another thing altogether where you can't even perform all logic on an existing variable.

CK2's scripting language is like a calculator that can only do division - no addition, subtraction, or multiplication

Anyway I agree with everything else you wrote :)

Re: the only point of contention, my point was that the language itself is part of the API, so things like manipulating data are [a largely missing] part of the API.
 
Re: the only point of contention, my point was that the language itself is part of the API, so things like manipulating data are [a largely missing] part of the API.

I think technically API refers to the interfaces between different software components. So to the interface between the modding script and the game itself, not manipulation of data in local memory even if said manipulation can only be done through provided functions and commands.

But yes, it's shameful that ck2's mod scripts have less capability than BASIC. Btw I like your proposal, it's very coherent and it touches on everything important.
 
Modding proposal, extended (has already been proposed, but since EU4 v1.4 implemented even more than my previously modest suggestion, it seems reasonable to ask for the same functionality that was introduced for modders in EU4 v1.4):

Variable arithmetic and comparison (against other variables), both intra-scope (different variable names) and cross-scope (same or different variable names). Scopes supported should be at least character and province, the current scopes in which the extremely limited variable support currently in CKII already function. Please see this post from Paradox developer Captain Gars on the EU4 modding forum in response to my same request, which is when he first announced that he had implemented and tested all the new requested variable operations (and more), including cross-scope arithmetic/comparison even between different types of scopes (province vs. country in EU4), as well as automatic tooltip localisation for the variables.

He came back with this in a matter of a day. Meanwhile, CKII modders spend hours and hours each, some on a very regular basis, emulating arithmetic and simply failing to be able to provide the same kind of dynamic and powerful mod functionality that would be possible if CKII modding support were not inferior to that of EU4 v1.4, in this respect.

Official related patch notes from the release of EU4 1.4:
- Added effect multiply_variable
- Added effect divide_variable
- All variable effects can now take a second variable as an argument
- check_variable trigger now works the same way as variable effects
- All variable effects and triggers can now take a scope as an argument

So when can I stop emulating binary arithmetic through recursive events with power-of-2 compare-and-subtract chains (only works for integers)? You know, all to compare a single variable to another single variable, or a trigger like wealth... Please end the madness.
Added a section:
Variables:

  • Allow multiplication and division of variables (like in EU4)
  • Allow comparing two variables
  • Allow comparing the same variable from two different scopes (E.G., var1 in ROOT, and var1 in FROM)
  • Allow effects/conditions to use variables instead of only pure numbers (E.G:, wealth = var)
  • Allow mathematical operations involving multiple variables (E.G., var1 = var2 * var3)
Tell me if I missed anything.
 
Added a section:
Variables:

  • Allow multiplication and division of variables (like in EU4)
  • Allow comparing two variables
  • Allow comparing the same variable from two different scopes (E.G., var1 in ROOT, and var1 in FROM)
  • Allow effects/conditions to use variables instead of only pure numbers (E.G:, wealth = var)
  • Allow mathematical operations involving multiple variables (E.G., var1 = var2 * var3)
Tell me if I missed anything.

Not on variables. Covered (and more). You might want to see my other two modding proposal points a few posts back, though.
 
Major script debugging improvement suggestion (would love to see it released as soon as CKII's India patch):

A new scope-free, argument-free debugging effect called assert (mirrors standard assert programming paradigm)

Advantages:
- Extremely simple
+ No state
+ No arguments
+ No scopes
+ No effect upon game state
+ No new scripting engine computation that isn't already done de jure
- Will save thousands of scripter troubleshooting hours quickly
- Adapts widely-used assertion programming paradigm to Paradox script cleanly (see: C/C++ assert)
- Provides first/only way to affect error.log (or a separate log file, if preferred) via a runtime script trigger
- Will improve code quality of mods / DLC content
- Will enable new scripters to learn all triggers and their usage much faster

Disadvantages:
- None

Optional increased complexity (features):
- Skip executing all assert effects if CKII's -debugscripts command-line option was not specified, largely in order to to avoid coding a safeguard against infinite loops writing to error.log but also to maintain zero execution overhead while running normally
- Custom error messages

How it works:

As an effect (not intended for any usage as part of a trigger), it basically acts like hidden_tooltip-- just without the tooltip snazz and instead, whenever its encapsulated trigger evaluates to false upon execution, it appends a standard "runtime script assert failed: <filename>: line <number>" message to error.log.

Context:
- Anywhere an effect is valid
- An enclosing character scope is demonstrated here, but like hidden_tooltip, it should work seamlessly through any scope type.

Contrived example code:

Code:
assert = {
    is_adult = no
    has_character_flag = standard_education
    
    OR = {
        is_female = no
        NOT = { religion_group = muslim }
    }
}

Or, simply:

Code:
assert = {
    always = no
}

If the trigger within assert evaluates false, then the aforementioned standardized error message with a filename and line number is appended to error.log. If the trigger within the assert evaluates true, assert does nothing at all.

This seems the most natural, most simple implementation, although you might prefer the [slightly] more verbose syntax below (mirroring the way if works as an effect with limit encapsulating its trigger), which could also optionally work a little like custom_tooltip and provide a human-readable error message:

Code:
assert = {
    limit = {
        NOT = { has_global_flag = startup_complete }
    }
    text = "mod ABC: scenario XYZ: game startup completed before scenario initialized"
}

Obviously, you get the idea.

If custom error messages were provided, supporting optional use of localisation keys (with standard custom_tooltip-style embedded variable/command substitution support) for them would obviously be the penultimate in troubleshooting utility, but such features are by no means necessary to reap the first 95% of benefit that a simple, line-numbers-only assert would provide over the current, extraordinarily poor script debugging status quo.

Personally, this would save me a ton of hours and start being used right away in my public modding. The coder of this scripting extension would certainly reap remarkably good code karma, and it'd go a long way toward Paradox's recently-stated modding support goals (better debugging) with what I'd guess to only be an afternoon of light work for the right developer.
 
Even more critical script debugging support improvement suggestion, which would also eliminate the need for the previous suggestion (assert):

Tracing support (runtime debug logging)
Actually get data / trace info out of the game and into a serial text log in a way that cannot even be matched by comprehensive save-game parsing.

Advantages:
  • Easy to implement
    • No state
    • No scopes
    • No need for filenames or line numbers to be associated with syntax elements
    • No effect upon game state
    • No new types of scripting computation
  • Will save countless script troubleshooting hours
  • Will enable more sophisticated problems to be solved through scripting
  • Will allow first/only runtime logging support from scripts
  • Will improve code quality of mods / DLC content
  • What was once intractable post-analysis of aggregate game behavior (e.g., for balance or AI improvement evaluation) becomes trivial
  • Applies to all Clausewitz-style games
Complexity:
  • Requires some command-line (or settings.txt) option to enable user logging/tracing command (otherwise it should be ignored), -debugscripts works fine for CKII
  • A new effect which takes two arguments, one of which is optional
  • Usage of text-substituted localisation (exactly like custom_tooltip but without any tooltip display)
  • If events are multi-threaded, thread synchronization when appending to the same log file (probably already built-in to logging given that it has to be done for at least game.log)
Gist:

  • Allow custom_tooltip-style printing of text-substituted/-expanded localisation strings to a log rather than just the display
  • Serialized and timestamped (by game date) appending to a user-defined log file (given by basename-- e.g., "project_balance")
  • Logging commands are not executed unless the debug feature is explicitly turned-on, so they can stay in the script across all testing and release phases

Context of New Effect:

  • Anywhere an effect is valid (any scope)
  • Never where a trigger is expected (has no meaning as a trigger)

How It Looks:

Code:
log = { text = LOCALISATION_KEY }

or, with an explicit log file name (good for separate mods and easy topic-based logging):

Code:
log = {
    which = faction_voting
    text = LOCALISATION_KEY
}

or, in the style of CKII's localisation keys in general, allowing use of a literal string instead of a localisation key (but then you get no support for embedded text-substitution commands like [This.GetID] or [Prev.GetID]):

Code:
log = {
    which = project_balance
    text = "Removing ahistorical de jure empires..."
}


Miscellany:

  • By default, trace logs are directed to "user_trace.log" (which="user_trace")
  • It should be impossible to specify log filenames outside of the game logs/ directory (no relative path components in which) to safeguard overwriting user files
  • The right-hand-side of which can be quoted to allow spaces and the like (unlikely use case, though, since it's for a filename)

This is so direly needed that is practically worth a Kickstarter campaign to incentivize some heroic Paradox developer to implement it. Once implemented, almost all other debugging improvements that really matter to scripters can be accomplished via this mechanism. Just this one thing! If I was a wealthy man, I would value this feature at $200,000USD within the first 6 months of usage by scripters. And, again, this may be an afternoon or two of work for the right developer.
 
One minor idea:

The ability to make it impossible to demand conversion for religions other than unreformed pagans, would be useful for religions such as the Druze who don't accept converts.
 
One minor idea:

The ability to make it impossible to demand conversion for religions other than unreformed pagans, would be useful for religions such as the Druze who don't accept converts.

Couldn't you add it in the conversation event?