• 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.
Using `only_rulers = yes` seems safer.
Since the number of characters of any religion can chance drastically during the game... So let's say that the player is playing as Norse pagan in the previous example, and manages to somehow convert most of the map... then any events that use that religion as the pre-trigger would be heavier than if it used only_rulers.
 
  • 2
Reactions:
Using `only_rulers = yes` seems safer.
Since the number of characters of any religion can chance drastically during the game... So let's say that the player is playing as Norse pagan in the previous example, and manages to somehow convert most of the map... then any events that use that religion as the pre-trigger would be heavier than if it used only_rulers.
Yes, totally, although quick correction: it'd be the number of pagan_group characters, not norse_pagan specifically, for which the events are evaluated.
 
That would depend on if religion or religion_group pretrigger was used.
 
That would depend on if religion or religion_group pretrigger was used.
In both cases, the filter includes every character in the religion_group. Using the specific religion pre-trigger merely acts as a fast trigger upon the particular religion within the filtered group.

EDIT: To be clear, when you use the specific 'religion' pre-trigger without any event filters that take precedence over the religion/religion_group filter (e.g., no only_playable, only_rulers, etc.), the engine uses the filtered-by-religion-group character list and then applies the 'religion' pre-trigger to that list (but still must evaluate for the entire group).

Both of the following events are evaluated for the entire Christian religion group, but the first form is preferred because it at least eliminates any other Christian religions without having to actually evaluate the official 'trigger' block for non-Lollards, which would be more expensive:

Code:
character_event = {
    id = dwarven_lollards.1

    religion = lollard

    trigger = {
        trait = dwarf
        any_friend = { trait = dwarf }
    }

    # ...
}

Not preferred, but uses the same exact character list for evaluation:

Code:
character_event = {
    id = dwarven_lollards.2

    religion_group = christian

    trigger = {
        religion = lollard
        trait = dwarf
        any_friend = { trait = dwarf }
    }

    # ...
}
 
Last edited:
  • 1
Reactions:
In both cases, the filter includes every character in the religion_group. Using the specific religion pre-trigger merely acts as a fast trigger upon the particular religion within the filtered group.

EDIT: To be clear, when you use the specific 'religion' pre-trigger without any event filters that take precedence over the religion/religion_group filter (e.g., no only_playable, only_rulers, etc.), the engine uses the filtered-by-religion-group character list and then applies the 'religion' pre-trigger to that list (but still must evaluate for the entire group).

Both of the following events are evaluated for the entire Christian religion group, but the first form is preferred because it at least eliminates any other Christian religions without having to actually evaluate the official 'trigger' block, which is a bit more expensive:

Code:
character_event = {
    id = dwarven_lollards.1

    religion = lollard

    trigger = {
        trait = dwarf
        any_friend = { trait = dwarf }
    }

    # ...
}

Not preferred, but uses the same exact character list for evaluation:

Code:
character_event = {
    id = dwarven_lollards.2

    religion_group = christian

    trigger = {
        religion = lollard
        trait = dwarf
        any_friend = { trait = dwarf }
    }

    # ...
}
I don't think @Meneth's OP actually clearly states that.
religion/religion_group - If you specify a religion or religion group, the event will only be evaluated for members of the group. It is worth noting that this is mutually exclusive with the other filtering pre-triggers, so in some cases it might actually be better to just use “religion_group = SOME_RARE_GROUP” and leave out “only_rulers = yes”. The quick-triggers take precedence in the order listed here, so only_playable and only_rulers both override religion/religion_group
"members of the group" could mean "members of the religion_group" only, as you are interpreting it, or "members of the religion or religion_group" as I am. I think we need @Meneth to clarify.
 
I don't think @Meneth's OP actually clearly states that.

"members of the group" could mean "members of the religion_group" only, as you are interpreting it, or "members of the religion or religion_group" as I am. I think we need @Meneth to clarify.
Heh, sure.

EDIT: I'm absolutely certain that I'm correct, as my very source is @Meneth, but if you think the wording in the OP is ambiguous (admittedly, I do not, but I also knew the truth before reading it), then it ought be adjusted.
 
Last edited:
Huh... mutually exclusive?

So you're saying that between

Code:
only_rulers = yes
religion = norse_pagan
and
Code:
religion = norse_pagan
trigger = {
    only_rulers = yes
}

#2 is better
#1 won't work properly
#1 and #2 work the same

I got into optimising CK2Plus pretriggers, about a week ago, good results so far :)
Both will work, and will have the same effect.
If there are fewer Pagans (it goes by group, not religion, when filtering) than there are rulers, #2 will be faster.

Tl;dr: What ziji said.
I've clarified the bit about religion/religion group in the post.
 
  • 3
Reactions:
Both will work, and will have the same effect.
If there are fewer Pagans (it goes by group, not religion, when filtering) than there are rulers, #2 will be faster.

Tl;dr: What ziji said.
I've clarified the bit about religion/religion group in the post.
What is the point of writing religion = norse_pagan instead of just religion = pagan if both just filters for the pagan group?
 
  • 1
Reactions:
What is the point of writing religion = norse_pagan instead of just religion = pagan if both just filters for the pagan group?
It'll check the religion as well.
Imagine instead that it didn't filter this way, and was just a regular pre-trigger.
religion_group = pagan
religion = norse_pagan

That would be better than:
religion_group = pagan
trigger = { religion = norse_pagan }

With how it works, just "religion = norse_pagan" on its own is equivalent to that first example.
 
  • 1
Reactions:
What about has_character_flag? How efficient it is, and where should it go?
Pretriggers, but you can only put one there. The rest go in normal triggers, so put the most restrictive in pretriggers. It should be very efficient.
 
I converted my mod to use has_character_flag pre-triggers (where possible) a while back, and it resulted in a noticeable performance boost. It's especially handy for removing temporary traits, and for cleanup checks that can't be covered by on_actions.

For example, I wrote a series of events that generate random accidents (ranging from wounded to death). Each character is checked at birth. The unlucky ones get an accident_check flag and are doomed to suffer one or more accidents during their life. The rest get filtered out of the event, because they don't have the flag.

The downside is that all the flags inflate the saves a bit. ...and I wish those worked with decisions, too.
 
Last edited:
what i want to know does having such a flag in event outright stop event from being evaluated for anyone except the people who have that flag, or is it just one more way to avoid trigger block evaluation?
 
what i want to know does having such a flag in event outright stop event from being evaluated for anyone except the people who have that flag, or is it just one more way to avoid trigger block evaluation?
The latter. Meneth didn't list it as one of the filtering pretriggers.
 
I'm in the process of converting a bunch of triggered modifiers to event modifiers. Some of these are progressive, and I'd like to know if it is safe to use remove_character_modifier without checking for the presence of said character modifier, or if it is best practice to always enclose the removal in an if block testing for its presence?
 
I'm in the process of converting a bunch of triggered modifiers to event modifiers. Some of these are progressive, and I'd like to know if it is safe to use remove_character_modifier without checking for the presence of said character modifier, or if it is best practice to always enclose the removal in an if block testing for its presence?
Pretty sure it is safe, but not 100% sure.
 
Not sure if this is off topic since my issue doesn't appear to be event related but it is optimization related. It seems the game does a calculation every month; depending on how many days are in the month it's on the 18th, 25th or for Feb on the 2nd. I'm thinking it has something to do with troops, like the AI evaluating their strength vs neighbors, claimants, etc, but that is just a guess. When we've done load testing at work we always do a couple tests with ridiculous load to see where the bottlenecks are and where we would get the biggest bang for our buck with new hardware or better code. If you want I can send you the mod and a save file.
 
Not sure if this is off topic since my issue doesn't appear to be event related but it is optimization related. It seems the game does a calculation every month; depending on how many days are in the month it's on the 18th, 25th or for Feb on the 2nd. I'm thinking it has something to do with troops, like the AI evaluating their strength vs neighbors, claimants, etc, but that is just a guess. When we've done load testing at work we always do a couple tests with ridiculous load to see where the bottlenecks are and where we would get the biggest bang for our buck with new hardware or better code. If you want I can send you the mod and a save file.
Nothing I can do about it as my internship is over, sorry.
 
Are culture and culture_group valid pre-triggers?
Culture is. Not 100% sure about culture_group, but I think it is too.
However, unlike religion it doesn't have a massive performance effect. It's better than putting it in the trigger, but not by a massive amount.