• 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.
Thanks for your reply! This is very helpful to me.
I really didn't put any conditions, because I want to test whether the redesigned event could be triggered normally first, so I created a decision. But at this point, there will be situations like the one I mentioned, such as the Umayyads of 769 triggering two invasions simultaneously.
To investigate the cause, I created ten "empty events"(randominvasion.0022 to randominvasion.0031, only generate one courtier, so based on the number of wars faced by the ruler at the same time, I can quickly found whether all the triggered events are within random_list), I found that the two events triggered simultaneously in this situation are still in random_list, but I don't understand why this situation would trigger in a specific character.( Just now I had a new idea, I thought it might be related to the title rather than the character? )
BTW, there is another reason why I haven't set conditions, I found when realm_size is used as condition for judgment, it seems that the event will not be triggered by the Khan of the nomadic government.
If you want khans to get hit, put an or block with realm size or nomadic and an appropriate size condition.


And make sure they are triggered only if they are being called from an on_action. I would go with on_yearly_pulse (or is it annual_pulse).
 
If you want khans to get hit, put an or block with realm size or nomadic and an appropriate size condition.
You can also create a size constraint for nomads, something like this:
Code:
OR = {
   
    # Non-nomad with realm_size >= 100
    AND = {
        is_nomadic = no
        realm_size >= 100
    }
    
    # Nomad with >= 20 counties in their realm
    AND = {
        is_nomadic = yes
        any_realm_title = {
            tier = COUNT
            count = 20
        }
    }
   
}
 
You can also create a size constraint for nomads, something like this:
Code:
OR = {
   
    # Non-nomad with realm_size >= 100
    AND = {
        is_nomadic = no
        realm_size >= 100
    }
    
    # Nomad with >= 20 counties in their realm
    AND = {
        is_nomadic = yes
        any_realm_title = {
            tier = COUNT
            count = 20
        }
    }
   
}

Probably better to just use num_of_count_titles_in_realm >= 20 instead. Also much better for performance than using any_ scoping to count things.
 
  • 1
Reactions:
Well, you haven't put any conditions on the events. Something like this might be a good start:

Code:
character_event = {
    id = randominvasion.0001
    hide_window = yes
    is_triggered_only = yes
    trigger = {
        independent = yes
        is_landed = yes
        realm_size >= 100 # Invasions can only be triggered on *large* independent rulers
        war = no # Invasions can only be triggered on rulers who are at peace (among other things, this prevents a ruler from being targeted twice)
    }
After testing, being invaded twice at the same time is indeed related to the title, but not completely related. In 769, the Andalusian king(Umayyads of 769, or other Andalusian king) would trigger this, but not in 867. Moreover, nomadic invaders generated through events will quickly abandon war and turn to raiding. These leaves me very confused.
 
I'm trying to make a mod with an alternate version of Alexander's Bloodline Invasion CB, does anyone know what that CB is in the game files?

It's the tribal_invasion CB, just a special condition on eligibility.
 
I'm trying to make a mod with an alternate version of Alexander's Bloodline Invasion CB, does anyone know what that CB is in the game files?
It's the tribal_invasion CB, just a special condition on eligibility.
To enable the CB, you simply need to include the bloodline_great_conquerors flag in your new bloodline.

If you want to tell the user that "this bloodline enables invasions", you should probably also include a custom bloodline effect - either copy the one from the Alexander bloodline, or make your own.

It may also be a good idea to include the bloodline flags created_bloodline and bloodline_ambition, so that the game prevents duplicative events. (Eg: So you can't earn the base Alexander/Ashoka bloodline if you're already a member of your new bloodline.)

Eg:
Code:
emb_true_heir_of_alexander_bloodline_m = {
	combat_rating = 5
	monthly_character_prestige = 0.5
	emb_bloodline_effect_blank1_for_spacing = 1                   # Blank line, to ensure proper distribution of effects in bloodline screen
	emb_bloodline_effect_blank2_for_spacing = 1                   # Blank line, to ensure proper distribution of effects in bloodline screen
	emb_great_conqueror_bloodline_effect_one_invasion = 1         # These effects don't do anything - they simply describe the invasion effect (and the fact it doesn't stack with the base game Alex bloodline) (and an additional effect I haven't yet implemented)
	emb_great_conqueror_bloodline_effect_expected_conquest = 1    # These effects don't do anything - they simply describe the invasion effect (and the fact it doesn't stack with the base game Alex bloodline) (and an additional effect I haven't yet implemented)
	inheritance = patrilineal
	allow_bastards = yes
	picture = GFX_bloodlines_symbol_bucephalus
	flags = { emb emb_m emb_alexander_bloodline emb_alexander_bloodline_flavor_alexander created_bloodline bloodline_great_conquerors bloodline_ambition emb_bloodline_effect_expected_conquest }
}
 
I used events to generate new characters with random culture and random ethnicity(Random list , culture=, set_graphical_culture=), I hope his courtiers will also have the same culture and ethnicity, But because the ethnicity of the lord is random, the ethnicity of courtiers will be based on the culture of the lord rather than ethnicity.
set_graphical_culture=ROOT does not take effect in this case, so what code should I use to generate courtiers for the lord whose culture and ethnicity are both random?
 
I used events to generate new characters with random culture and random ethnicity(Random list , culture=, set_graphical_culture=), I hope his courtiers will also have the same culture and ethnicity, But because the ethnicity of the lord is random, the ethnicity of courtiers will be based on the culture of the lord rather than ethnicity.
set_graphical_culture=ROOT does not take effect in this case, so what code should I use to generate courtiers for the lord whose culture and ethnicity are both random?

I believe

Code:
<copy scope> = {
    gfx_culture_scope = {
        <target scope> = {
            set_graphical_culture = PREV
        }
    }
}

would give you the desired effect, but you'd have to trigger it whenever a character is spawned in a manner that excludes e.g. newborn children, most likely using on_host_change, a character flag, and some conditions that avoids randomizing certain characters.
 
  • 1
Reactions:
I believe

Code:
<copy scope> = {
    gfx_culture_scope = {
        <target scope> = {
            set_graphical_culture = PREV
        }
    }
}

would give you the desired effect, but you'd have to trigger it whenever a character is spawned in a manner that excludes e.g. newborn children, most likely using on_host_change, a character flag, and some conditions that avoids randomizing certain characters.
Code:
create_character = {
female = 50
random_traits = yes
age = 16
}
new_character = {
religion = ROOT
culture = ROOT
}

Thank you for your reply, but as a beginner in mod code, I am not quite sure what your code means. I imitated generate_familys_events to generate courtiers for the character (creat_character=, new_character= ), could you show me an example?
 
Code:
create_character = {
female = 50
random_traits = yes
age = 16
}
new_character = {
religion = ROOT
culture = ROOT
}

Thank you for your reply, but as a beginner in mod code, I am not quite sure what your code means. I imitated generate_familys_events to generate courtiers for the character (creat_character=, new_character= ), could you show me an example?

Okay, so you're creating these courtiers explicitly? That simplifies things.

You'll need a scope pointing at your "random culture character"; I recommend simply firing an event for them after you land them since that makes them ROOT. Then simply put the following inside that event for each new character.

Code:
create_character = {
    female = 50
    random_traits = yes
    age = 16
    culture = ROOT
    religion = ROOT
    race = ROOT # Graphical culture
}

Regarding the new_character block, whose culture/religion are they supposed to flip to? If it's the "random culture character", it's unnecessary with the setup above. If it is someone else, target that scope (e.g. if the "random culture character" was created in event A and that event fired for the correct character, you'd use FROM).
 
Okay, so you're creating these courtiers explicitly? That simplifies things.

You'll need a scope pointing at your "random culture character"; I recommend simply firing an event for them after you land them since that makes them ROOT. Then simply put the following inside that event for each new character.

Code:
create_character = {
    female = 50
    random_traits = yes
    age = 16
    culture = ROOT
    religion = ROOT
    race = ROOT # Graphical culture
}

Regarding the new_character block, whose culture/religion are they supposed to flip to? If it's the "random culture character", it's unnecessary with the setup above. If it is someone else, target that scope (e.g. if the "random culture character" was created in event A and that event fired for the correct character, you'd use FROM).
Thank you for your help, sadly, race=ROOT doesn't seem to be effective, whether in creat_character= or new_character=.
 
Thank you for your help, sadly, race=ROOT doesn't seem to be effective, whether in creat_character= or new_character=.

The parameter works as expected in the create_character command ("race" is not a command and thus doesn't work in new_character, as that's a scope), at least assuming the ROOT scope points to a character.

I've executed the below twice

Code:
create_character = {
    culture = norse
    religion = catholic
    female = 50
    race = ROOT
}

resulting in the following two characters

View attachment 1210783

1730547781603.png


Both have Greek ethnicity (I loaded in as Konstantinos X, who of course is Greek), Norse culture, and Catholic religion, as would be expected.
 
The parameter works as expected in the create_character command ("race" is not a command and thus doesn't work in new_character, as that's a scope), at least assuming the ROOT scope points to a character.

I've executed the below twice

Code:
create_character = {
    culture = norse
    religion = catholic
    female = 50
    race = ROOT
}

resulting in the following two characters

View attachment 1210783

View attachment 1210784

Both have Greek ethnicity (I loaded in as Konstantinos X, who of course is Greek), Norse culture, and Catholic religion, as would be expected.
After several tests, I still cannot succeed. May I ask what is the ethnicity and culture of ROOT in your example?
 
The parameter works as expected in the create_character command ("race" is not a command and thus doesn't work in new_character, as that's a scope), at least assuming the ROOT scope points to a character.

I've executed the below twice

Code:
create_character = {
    culture = norse
    religion = catholic
    female = 50
    race = ROOT
}

resulting in the following two characters

View attachment 1210783

View attachment 1210784

Both have Greek ethnicity (I loaded in as Konstantinos X, who of course is Greek), Norse culture, and Catholic religion, as would be expected.
These are my test files, I use chaosworld_decisions to trigger chaosworld_events to generate invaders with random culture, religion, and ethnicity. I'm not sure if I wrote something wrong.
 

Attachments

  • random_ck2.7z
    3,9 KB · Views: 0
After several tests, I still cannot succeed. May I ask what is the ethnicity and culture of ROOT in your example?

Konstantinos X is Greek, both culturally and ethnically.

These are my test files, I use chaosworld_decisions to trigger chaosworld_events to generate invaders with random culture, religion, and ethnicity. I'm not sure if I wrote something wrong.

Okay, so some assorted comments:

- Change "any_character" to "any_independent_ruler" in chaosworld_decisions and cut the "independent = yes" condition; there's absolutely no reason not to use that scope instead of a more inefficient scope and limit to get the same effect.

- chaosworld.0001 is completely pointless; any character that passes the check in chaosworld_decisions passes this event, and since there's no delay between the decision and the event you're just firing a bunch of useless events.

- There's no "taoist_reformed" religion tag in vanilla or your mod, so the event with the random_list might not work with a malformed tag.

- "dynasty = random" does not work in the "new_character" scope, or any scope other than "create_character" or its equivalents; see https://ck2.paradoxwikis.com/Commands.

- Unless you really want to cover cultures/religions that are explicitly forbidden from spawning normally, the random_list setup for culture/religion would seem to be overkill when "culture = random" and "religion = random" could be used in create_character... and putting it there means they'll actually get a suitable name (otherwise you name them based on ROOT's culture (and possibly religion) prior to flipping their culture/religion).

- I suspect you might run into issues with raiding adventurers that aren't permitted to raid depending on culture/religion/government as currently implemented.

- chaosworld.0003 has an empty "trigger" block; delete it.

- Nothing obvious sticks out as far as the "race" parameter goes, but the character that spawns has no culture or religion set, which might be a requirement when using "race"; try adding that.

- I'm not really sure what you're trying to accomplish with that one random courtier that you spawn, seeing as you're clearly not spawning a designated commander or spouse or something like that. Since extra characters are a drain on performance, I'm not sure they're worth having if they're just "random character hanging around".

- The initial "ROOT" scope inside the immediate block does nothing; you are already in the ROOT scope.

- The event "flow" is very weird; why are you creating a raiding adventurer and then immediately turning them into a non-raiding adventurer waging a war? I can also not see any reason why 0003 and 9998 need to be different events (and arguably you could merge everything into the same event, or even into the decision, provided you update the scopes); you don't have any delays between the events, so why use multiple event?

- Your CB likely needs work; for example, you're setting the government type ahead of the character becoming landed and don't check if they'd be eligible for the government (e.g. a Muslim character will not remain Feudal, nor will someone that only gets a temple), and you've left a bunch of junk in it (Timur/etc. is never the attacker...) that's not even commented out, which really should be cleaned up to make it more readable and to make it clear to Future You (or anyone else) what's supposed to be happening.

- Your indentation is a mess, which makes the files hard to read, which makes it harder to spot possible issues.
 
Konstantinos X is Greek, both culturally and ethnically.



Okay, so some assorted comments:

- Change "any_character" to "any_independent_ruler" in chaosworld_decisions and cut the "independent = yes" condition; there's absolutely no reason not to use that scope instead of a more inefficient scope and limit to get the same effect.

- chaosworld.0001 is completely pointless; any character that passes the check in chaosworld_decisions passes this event, and since there's no delay between the decision and the event you're just firing a bunch of useless events.

- There's no "taoist_reformed" religion tag in vanilla or your mod, so the event with the random_list might not work with a malformed tag.

- "dynasty = random" does not work in the "new_character" scope, or any scope other than "create_character" or its equivalents; see https://ck2.paradoxwikis.com/Commands.

- Unless you really want to cover cultures/religions that are explicitly forbidden from spawning normally, the random_list setup for culture/religion would seem to be overkill when "culture = random" and "religion = random" could be used in create_character... and putting it there means they'll actually get a suitable name (otherwise you name them based on ROOT's culture (and possibly religion) prior to flipping their culture/religion).

- I suspect you might run into issues with raiding adventurers that aren't permitted to raid depending on culture/religion/government as currently implemented.

- chaosworld.0003 has an empty "trigger" block; delete it.

- Nothing obvious sticks out as far as the "race" parameter goes, but the character that spawns has no culture or religion set, which might be a requirement when using "race"; try adding that.

- I'm not really sure what you're trying to accomplish with that one random courtier that you spawn, seeing as you're clearly not spawning a designated commander or spouse or something like that. Since extra characters are a drain on performance, I'm not sure they're worth having if they're just "random character hanging around".

- The initial "ROOT" scope inside the immediate block does nothing; you are already in the ROOT scope.

- The event "flow" is very weird; why are you creating a raiding adventurer and then immediately turning them into a non-raiding adventurer waging a war? I can also not see any reason why 0003 and 9998 need to be different events (and arguably you could merge everything into the same event, or even into the decision, provided you update the scopes); you don't have any delays between the events, so why use multiple event?

- Your CB likely needs work; for example, you're setting the government type ahead of the character becoming landed and don't check if they'd be eligible for the government (e.g. a Muslim character will not remain Feudal, nor will someone that only gets a temple), and you've left a bunch of junk in it (Timur/etc. is never the attacker...) that's not even commented out, which really should be cleaned up to make it more readable and to make it clear to Future You (or anyone else) what's supposed to be happening.

- Your indentation is a mess, which makes the files hard to read, which makes it harder to spot possible issues.
I am very grateful that you are willing to take the time to read my terrible mod files, because at first I just wanted your help to see why I couldn't control the race of the newly generated character. As I mentioned before, I am a beginner in mod code, I referred to some original files and mod files to try making a mod, so all the mod files looked messy. I am grateful that you have read all of these, your reply is very helpful to me.
 
Would anyone know anything about modding succession laws? I am trying to get a dynastic succession where only the rulers dynasty is considered but also follows primogeniture. I have something that kind of works but it is done through elective gravelkind and first heir gets older the game will vote for the 2nd youngest heir. I would like for it to go from the rulers children, grandchildren and if they dont have any to go to siblings then uncles/aunts etc. Hopefully this makes sense, would anyone be willing to help?
 
Would anyone know anything about modding succession laws? I am trying to get a dynastic succession where only the rulers dynasty is considered but also follows primogeniture. I have something that kind of works but it is done through elective gravelkind and first heir gets older the game will vote for the 2nd youngest heir. I would like for it to go from the rulers children, grandchildren and if they dont have any to go to siblings then uncles/aunts etc. Hopefully this makes sense, would anyone be willing to help?
Maybe it'll work better if you base it off feudal_elective instead of elective gavelkind? Because that approach sounds like it should work - maybe it's the "gavelkind" part that's messing up?

However, writing a script that encodes the primogeniture rules for the purpose of elections could be very tricky. Especially since you might have to go up and down 5-10 generations to find the next valid heir. On second thoughts, make that very very very tricky...

Can you give some more background on your high-level goal? There may be a better way...
 
  • 1Like
Reactions: