• 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.
I'm not very experienced in CK2 scripting, so I'm slightly confused by the ai_will_do clause regarding Casus Belli:

does that mean that I can't use something like this:
Code:
 ai_will_do = {
factor = 0
       ROOT =
       {
           has_character_flag = peaceful_ai
       }
}

Because that is character scope, not title?
Further down in the same file:
Code:
# ai importance placed on this CB: scope is the targeted title, ROOT is the attacking character, FROM is the defending character
This is one of the unusual cases where the *starting* scope is not in fact ROOT. There are others. :confused:
 
Yep it is in the public build and has been for a few versions now, not sure when it was added though
Well, I'm going to document this for the wiki, since it's not there yet. :)

From your post, the text file needs to be directly in the CK2 documents directory. The commands are run in the scope of the player who consoles it. I assume no FROM-type scopes are set (wouldn't make sense).
 
Well, I'm going to document this for the wiki, since it's not there yet. :)

From your post, the text file needs to be directly in the CK2 documents directory. The commands are run in the scope of the player who consoles it. I assume no FROM-type scopes are set (wouldn't make sense).
Yeah the file needs to be directly in the documents directory and when you run it in game you need to include the .txt extension in the console.
ROOT is the character running the effect, it does not take an option character to set as ROOT but you can work around that by turning on charinfo and using direct scoping to the character you want to run effects on by doing c_1234 for a character with ID 1234. And yeah do not bother using FROM or chains of FROM.
 
@NoxBestia

Code:
random_character = {
  limit = {
    is_lowborn = no
  }
  random_dynasty_member_even_if_dead = {
    limit = {
      is_alive = no
      is_female = no
    }
    # your code
  }
}

Does this work?

It did not work either.
 
Does anyone know where to edit the province prosperity %? I'm thinking of giving thriving/booming counties more levies (not just reinforcement rate) in order to represent an increased population and the ability to recruit more men.
 
@Drakons

Well, I _finally_ made it work. It is kludgy and ugly, but it works. Here was my solution:

Code:
any_character = {
            limit = {
                father_even_if_dead = {
                    OR = {
                        is_alive = no
                        father_even_if_dead = {
                            OR = {
                                is_alive = no
                                father_even_if_dead = {
                                    OR = {
                                        is_alive = no
                                        father_even_if_dead = {
                                            is_alive = no
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
            random_dynasty_member_even_if_dead = {
                limit = {
                    is_alive = no
                    is_female = no
                }
                save_global_event_target_as = NOX_dead_male
            }
        }

One big limitation this solution has is that the dynasty has to have a living member in order to be included, but without the additional of a "any_character_even_if_dead" scope there is nothing I can imagine that can be done about that.
 
It did not work either.
Not sure exactly what you are doing but I noticed you are using the lowborn condition, currently the is_lowborn condition is inverted. If you want to check someone is lowborn you must do is_lowborn = yes.
This has already been fixed for 2.8 though but in 2.7.2 it is still inverted.
 
Not sure exactly what you are doing but I noticed you are using the lowborn condition, currently the is_lowborn condition is inverted. If you want to check someone is lowborn you must do is_lowborn = yes.
This has already been fixed for 2.8 though but in 2.7.2 it is still inverted.

My ultimate goal would be to be able to randomly select _any_ dead character, dynastic or lowborn, but from what I understand of the current scopes that is not possible. I found a somewhat functional workaround, but as I stated here, it only works for dynasties with at least one living member.

For a haunting event I am working on, I'd _really_ love to be able to dig into ghosts from before 400 CE, but only a few of those still have surviving dynasties, so I decided on any dead character from any time.

An even more kludey option (that might even crash the game if I had tried it) was to make a static list of the approximately 2,700 dead characters in a 769 CE start and turn those into a giant random_list, but then as the game progresses and dynasties die out they are lost to the process. EDIT: for grins, I tried this and... it didn't blow up my game but oh what a CPU spike. Worse than scope any_character ever caused me (and I run a very high end system). /laughs
 
Last edited:
Further down in the same file:
Code:
# ai importance placed on this CB: scope is the targeted title, ROOT is the attacking character, FROM is the defending character
This is one of the unusual cases where the *starting* scope is not in fact ROOT. There are others. :confused:

Ahh, so that means I could do something like this?

Code:
 ai_will_do = {
factor = 0
AND = {
       has_title_flag = some_random_title_flag #check if the specific title has a flag
       ROOT =
       {
           has_character_flag = peaceful_ai
       }
}
 
My ultimate goal would be to be able to randomly select _any_ dead character, dynastic or lowborn, but from what I understand of the current scopes that is not possible. I found a somewhat functional workaround, but as I stated here, it only works for dynasties with at least one living member.

For a haunting event I am working on, I'd _really_ love to be able to dig into ghosts from before 400 CE, but only a few of those still have surviving dynasties, so I decided on any dead character from any time.

An even more kludey option (that might even crash the game if I had tried it) was to make a static list of the approximately 2,700 dead characters in a 769 CE start and turn those into a giant random_list, but then as the game progresses and dynasties die out they are lost to the process. EDIT: for grins, I tried this and... it didn't blow up my game but oh what a CPU spike. Worse than scope any_character ever caused me (and I run a very high end system). /laughs
You can find any dead lowborn very easily. Create a lowborn character then look for any dynasty member as they all share the same dynasty.
For people with actual dynasty members it is not as easy, a better way of doing it would probably to not search for a character and then their dynasty members but instead a title and one of its holders then go to their dynasty as that way you can pick any title and then any ruler and then members of their dynasty and get a wider spread as all rulers have to be a noble.
 
You can find any dead lowborn very easily. Create a lowborn character then look for any dynasty member as they all share the same dynasty.
For people with actual dynasty members it is not as easy, a better way of doing it would probably to not search for a character and then their dynasty members but instead a title and one of its holders then go to their dynasty as that way you can pick any title and then any ruler and then members of their dynasty and get a wider spread as all rulers have to be a noble.

Is there a way to select a deceased past holder of a title, or just the current holder?
 
Is there a way to select a deceased past holder of a title, or just the current holder?
any_previous_holder when in the scope of a title.
egs:
Code:
e_hre = { any_previous_holder = { blah } }
PREVPREV = { any_previous_holder = { blah } }
 
any_previous_holder when in the scope of a title.
egs:
Code:
e_hre = { any_previous_holder = { blah } }
PREVPREV = { any_previous_holder = { blah } }

Thank you very much. I will try this out!
 
The whole thing with dukes, kings and princes joining monastic societies doesn't make sense to me and so I'm creating knightly orders in my mod and leaving the monastic orders as a secondary flavor thing for courties and the like, so I ask the following:

How do I mod said societies so that only characters with religious education traits can join? I also want to make it so that upon joining the character receives the monk/nun trait, but without the risk of disqualifying heirs/destroying dynasties. I couldn't really find it in the game files.

Alternatively add the requirement that characters joining must have the monk/nun trait beforehand, but that is a rare trait right? Only event I know of that adds it is that one from SoA, so I would need to also change it so that it happens more oftenly and so that it happens to random courtiers/lowborn/not belonging to the character's dinasty:

# Child wants to be monk/nun - select child
character_event = {
id = SoA.5216

hide_window = yes

min_age = 16
only_capable = yes
prisoner = no
ai = no
religion_group = christian

trigger = {
has_dlc = "Sons of Abraham"

any_child = {
is_ruler = no
age = 13
NOT = { age = 16 }
NOT = { trait = cynical }
NOT = { is_ascetic_trigger = yes }
}
}

mean_time_to_happen = {
months = 1000
}

immediate = {
random_child = {
limit = {
is_ruler = no
age = 13
NOT = { age = 16 }
NOT = { trait = cynical }
NOT = { is_ascetic_trigger = yes }
}
character_event = { id = SoA.5217 }
}
}
}

# Child bounce event
character_event = {
id = SoA.5217

is_triggered_only = yes

hide_window = yes

immediate = {
FROM = {
character_event = { id = SoA.5218 }
}
}
}

# Child wants to be monk/nun - parent response
character_event = {
id = SoA.5218
desc = EVTDESC_SoA_5218
picture = GFX_evt_courtiers_talking
border = GFX_event_normal_frame_religion

is_triggered_only = yes

option = {
name = EVTOPTA_SoA_5218
ai_chance = {
factor = 0
}
FROM = {
if = {
limit = {
is_female = yes
}
add_trait = nun
}
if = {
limit = {
is_female = no
}
add_trait = monk
}
opinion = {
modifier = opinion_grateful
who = ROOT
years = 100
}
}
custom_tooltip = { text = EVTTOOLTIPA_SOA_5218 }
}
option = {
name = EVTOPTB_SoA_5218
ai_chance = {
factor = 100
}
FROM = {
add_trait = stressed
opinion = {
modifier = opinion_angry
who = ROOT
years = 3
}
}
custom_tooltip = { text = EVTTOOLTIPB_SOA_5218 }
}
}
 
Also, anyway to actually make baron-tier characters have any AI at all? As in at least pursuing marriages and alliances

You could fire an on_[something]_pulse (I suggest on_five_year_pulse or on_decade_pulse, because there are plenty of barons) event for them which allows for them to marry. However, because you can't access the AI marriage logic or force the AI to use the marriage interaction, I suggest that you simply code the event to pick a random eligible Lowborn or daughter of some other baron that isn't too old or young, is of the proper religion (group), and perhaps lives up to some other conditions (e.g. same culture group) and have them either automatically marry (if the bride's host is another baron) or send a message to the bride's host about the marriage (if the bride's host is count-tier above) that an AI host is taught to always accept (perhaps excluding e.g. the baron being a rival, the prospective bride is the host's lover, or the like), and perhaps a similar pulse event for the heir of the baron. However, keep in mind that if barons marry and have children more frequently performance might suffer from there being a lot more characters around after a few generations.

You could do something similar for alliances (as you once again can't access the actual logic or interaction), but as non-patrician barons don't declare wars at all (and only rarely end up as the primary defender in a war) it would probably be rather meaningless in the end and end up simply being a performance drain.
 
Does anyone know where to edit the province prosperity %? I'm thinking of giving thriving/booming counties more levies (not just reinforcement rate) in order to represent an increased population and the ability to recruit more men.
You mean the major province modifier?
That'd be pretty straightforward: Just make a mod, and include a /common/event_modifiers folder.
Then put a file there like "my_new_prosperity_modifiers.txt" and open the vanilla file (in the folder of the same name, just in the vanilla game files) called "00_event_modifiers.txt" and search for "prosperity_modifier_1" (also 2 & 3, respectively) in it, and copy these modifiers to your own file. Then add a line to them called "levy_size = 0.1" or whatever value you want it, for each of the three prosperity modifiers.
 
Ahh, so that means I could do something like this?

Code:
 ai_will_do = {
factor = 0
AND = {
       has_title_flag = some_random_title_flag #check if the specific title has a flag
       ROOT =
       {
           has_character_flag = peaceful_ai
       }
}
Yes. You could even get back to the title scope within another scope, like so:
Code:
ai_will_do = {
    factor = 0
    AND = {
       has_title_flag = some_random_title_flag #check if the specific title has a flag
       ROOT =
       {
          has_character_flag = peaceful_ai
          PREV = { /back in title scope/ }
       }
    }
}
 
You mean the major province modifier?
That'd be pretty straightforward: Just make a mod, and include a /common/event_modifiers folder.
Then put a file there like "my_new_prosperity_modifiers.txt" and open the vanilla file (in the folder of the same name, just in the vanilla game files) called "00_event_modifiers.txt" and search for "prosperity_modifier_1" (also 2 & 3, respectively) in it, and copy these modifiers to your own file. Then add a line to them called "levy_size = 0.1" or whatever value you want it, for each of the three prosperity modifiers.
Thanks, man! I've always wanted to modify those numbers, but I could never find the file.
 
I have a society and want the starting members to be of the same religion-group as the player is. But I dont get it how to construct the condition since random_playable_ruler is not allowed in triggers.

If I use
Code:
startup_populate = {
  any_playable_ruler = {
    ai = no
    religion_group = PREV
  }
}
the society do not exists ingame. I think its because those two conditions are evaluated for every playable ruler and then connected via AND (which will always be false).