• 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 anyone know how do you mod a specific character or title to be a vassal clan in a nomadic empire on game start? I've looked in the history files and it's not apparent, the clan title looks to be dynamically generated, and I don't see how the game choose who is a clan. Is it just chosen by the game by some criteria? Is it based on character or based on titles? I also found the historical_nomad flag for titles, but how it works is unintuitive, is that related to clans or is it just independent realms?
I believe all same culture vassals with a government with can_change_to_nomad_on_start = yes of historical_nomad lieges become nomad vassals. Of course, nomads are a largely hardcoded mess, so...
You probably also need to ensure that there aren't 8 other possible nomad vassals who might be evaluated before the modded character. (Nomad empires are limited to 9 clans, ie. 1 khagan + 8 khans.)
 
I believe all same culture vassals with a government with can_change_to_nomad_on_start = yes of historical_nomad lieges become nomad vassals. Of course, nomads are a largely hardcoded mess, so...
What determines the government of a vassal? Is it depending on their capital holding (using the capital command)?

I'm pretty sure I've done that, tribal government, setting every county title he owns to historical_nomad, character is same culture and religion as liege (mongol empire in this case), and he's still not turning into a clan. I compared him to other clans in the history setup and I can't find any notable difference, although the code was confusing because their counties often don't have historical_nomad, the de jure duchies have it but was unowned, so the logic was unclear. The provinces don't have the same culture though, but I notice other clans didn't have the same culture provinces either, and when they turn into a clan they override the province culture.

I also notice that some tribal vassals were default under a clan, but I don't see how that was done in the history setup, since I don't think you can set a clan's dynamic title as liege?
 
You probably also need to ensure that there aren't 8 other possible nomad vassals who might be evaluated before the modded character. (Nomad empires are limited to 9 clans, ie. 1 khagan + 8 khans.)
Yep there's less than 8 other clans, I even tried taking out one of the existing clans, and he still didn't turn into one, the number of clans just dropped. It seemed like there are specific requirements to turn into one that is not apparent.
 
This issue has been driving me crazy. Would anyone know how to change a title depending on conditions? Like I want the Emperor of England to be called King unless they have passed the imperial administration. I also want the Kings who become vassals to have their title changed as well to Lord Regent and back again under independence. Please help if you can.
 
This issue has been driving me crazy. Would anyone know how to change a title depending on conditions? Like I want the Emperor of England to be called King unless they have passed the imperial administration. I also want the Kings who become vassals to have their title changed as well to Lord Regent and back again under independence. Please help if you can.
Override the default localisation strings for emperor/king using custom localisation commands?

(This won't work for the 1% of titles that have their own customisation in landed_titles.txt, eg. Principate of Antioch, but it's a start...)
 
Override the default localisation strings for emperor/king using custom localisation commands?

(This won't work for the 1% of titles that have their own customisation in landed_titles.txt, eg. Principate of Antioch, but it's a start...)
Custom localisation for ruler titles isn't evaluated in all circumstances. In particular, it isn't evaluated during character selection on startup, so you'd end up being offered '[GBKingEmperorLoc] George' or something.

nd
 
Unfortunately, that did not work. I am try set_special_character_title but it doesnt work very well. I have seen some stuff on variables, would that work? I dont know much about how to get it set up though.
 
Answering my own question after a lot of trial and error.

So there's an additional requirement for nomad clan generation: the character cannot be the same dynasty of an already existing clan.

But apparently there is a way to violate that, where the game gets confused about who a character's liege actually is due to a history setup or history processing bug. It makes it possible to have same dynasty clans, and this exists in the vanilla game, which is what threw me off hard.

The case I found was when a vassal under 1 nomadic khagan owns non de-jure counties where its de-jure king (turned nomadic khagan) exists and is a different independent liege. In the vanilla game, the mongol empire Jochi owns counties in Cumania, where the Cumania king exists and was turned into his own nomadic khagan by the game. Even though Jochi owns the de-jure duchy title and has the proper liege set to mongol empire, this still happens. On the New game map screen, it shows the counties as under Cumania, clicking on it shows Jochi under Mongol Empire. Starting the game, Jochi becomes part of the Mongol Empire as his own clan, same dynasty as Genghis Khan but separate clan. If you don't trigger this bug with the ownership setup, the game will not turn the same dynasty character as his own clan.
 
After coding numerous new event chains, the game I'm playing to try them out keeps hanging every so often, after about 15 years of play. Once or twice a year, it will just stop on a date, and not be able to start again for 30 seconds to a minute. Once it didn't start again and I had to End Task.

How do I find out what's causing the game to choke? It's gotta be something in the new event chains I added, but I don't have any idea how I'd know which of them is slowing it down and choking it, or why.
After a lot of testing, I've tentatively narrowed down the culprit to casus belli. I've made one new casus belli, and added a minor alteration to a default cb. Can anyone spot anything in the code that would cause the game to slow down/hitch/choke?

Here is the custom cb
Code:
#rank 2 county conquest, cribbed from pagan_county_conquest and muslim_county_conquest
warmonger_county_conquest = {
    name = CB_NAME_COUNTY_CONQUEST
    war_name = WAR_NAME_COUNTY_CONQUEST
    sprite = 22
    truce_days = 1825
    hostile_against_others = yes
    is_permanent = yes
    check_all_titles = yes # if permanent, setting this to true will check against all of someones titles, including vassal held titles
    can_ask_to_join_war = no
    
    allow_distant = yes
    allowed_to_target_tributaries = no
    
    sort_priority = 700
    

    #THIS is the ONLY change I made to the code, iirc. I allowed it to be used in the same realm, and I required the character to either be rank 2 in a custom society or have a custom  modifier
    can_use = {
        ROOT = {
            mercenary = no
            NOT = { is_liege_or_above = FROM }
            #NOT = { same_realm = FROM }
            ROOT = {
                OR = {
                    society_rank = {
                        society = custom_warmonger_society
                        rank = 2
                    }
                    has_character_modifier = custom_warmonger_modifier
                }
            }
        }
    }

    can_use_title = {
        tier = count
        OR = {
            FROM = {
                has_landed_title = PREV
            }
            holder_scope = {
                is_liege_or_above = FROM
                #NOT = { same_realm = ROOT }
            }
        }

        NOT = {
            OR = {
                ROOT = {
                    has_landed_title = PREV
                }
                holder_scope = {
                    is_liege_or_above = ROOT
                }
            }
        }
        
        location = {
            any_neighbor_province = {
                owner = {
                    OR = {
                        character = ROOT
                        is_liege_or_above = ROOT
                    }
                }
            }
        }
    }

    is_valid_title = {
        OR = {
            FROM = {
                has_landed_title = PREV
            }
            holder_scope = {
                is_liege_or_above = FROM
            }
        }
    }

    on_success_title = { #winning the war
        usurp_title_plus_barony_if_unlanded = { target = ROOT type = invasion }
        
        any_de_jure_vassal_title = { # take all baronies too
            limit = {
                has_holder = yes
                holder_scope = {
                    OR = {
                        character = FROM
                        is_liege_or_above = FROM
                        AND = {
                            is_liege_or_above = ROOT
                            NOT = { culture = ROOT }
                            NOT = { religion = ROOT }
                        }
                    }
                }
            }
            show_scope_change = no
            usurp_title = ROOT
        }
        
        ROOT = {
            show_scope_change = no
            participation_scaled_prestige = 100
            participation_scaled_piety = 50
        }
        any_attacker = {
            limit = { NOT = { character = ROOT } }
            hidden_tooltip = { 
                participation_scaled_prestige = 100 
                participation_scaled_piety = 50
            }
        }
        
        if = {
            limit = {
                NOT = { FROM = { religion = ROOT } }
            }
            ROOT = {
                show_scope_change = no
                religion_authority = {
                    modifier = won_county_conquest
                }
            }
        }

        #pagan_county_conquest has a section for handling warrior lodge quest to conquer a county, check that later if I had a similar quest
    }

    on_fail_title = { #white peace
        ROOT = {
            show_scope_change = no
            prestige = -100
        }
        
        if = {
            limit = {
                NOT = { FROM = { religion = ROOT } }
            }
            ROOT = {
                show_scope_change = no
                religion_authority = {
                    modifier = lost_county_conquest
                }
            }
        }
    
        FROM = {
            show_scope_change = no
            participation_scaled_prestige = 50
        }
        any_defender = {
            limit = { NOT = { character = FROM } }
            hidden_tooltip = { participation_scaled_prestige = 50 }
        }
    }

    on_reverse_demand = { #losing the war
        ROOT = {
            show_scope_change = no
            prestige = -200
            transfer_scaled_wealth = {
                to = FROM
                value = 4.0
            }
        }
        
        if = {
            limit = {
                NOT = { FROM = { religion = ROOT } }
            }
            ROOT = {
                show_scope_change = no
                religion_authority = {
                    modifier = lost_county_conquest
                }
            }
        }
        
        FROM = {
            show_scope_change = no
            participation_scaled_prestige = 100
            participation_scaled_piety = 50
        }
        any_defender = {
            limit = { NOT = { character = FROM } }
            hidden_tooltip = {
                participation_scaled_prestige = 100 
                participation_scaled_piety = 50
            }
        }
    }
    on_reverse_demand_title = {
        #To handle Warrior Lodge mission "Wage War" completion...
        attacker = { save_event_target_as = attacker_target }
        defender = { save_event_target_as = defender_target }

        if = { 
            limit = {
                event_target:attacker_target = { has_quest = quest_warrior_lodge_war }
                is_quest_target_of = event_target:attacker_target
            }
            event_target:attacker_target = {
                show_scope_change = no
                tooltip = { clr_quest = quest_warrior_lodge_war }
                set_character_flag = lost_war@event_target:defender_target
                #character_event = { id = HF.10514 days = 3 } #Sent from on_action instead
            }
        }
    }

    attacker_ai_victory_worth = {
        factor = -1 # always accept
    }
    
    attacker_ai_defeat_worth = {
        factor = 100
    }

    defender_ai_victory_worth = {
        factor = -1 # always accept
    }
    
    defender_ai_defeat_worth = {
        factor = 100
    }
    
    ai_will_do = { 
        factor = 1
        
        modifier = {
            factor = 3.0
            ROOT = {
                trait = ambitious
            }
        }
    }
}

The default cb that I changed was tribal_invasion. The only thing I changed was to add a custom trait as a potential condition for declaring the cb under can_use_title, at the bottom of the quoted code below.
Code:
ROOT = {
            OR = {
                ai = yes
                multiplayer = no
                NOT = {
                    has_game_rule = {
                        name = multiplayer_invasions
                        value = off
                    }
                }
            }
            is_nomadic = no
            OR = {
                AND = {
                    has_dlc = "Horse Lords"
                    higher_tier_than = COUNT
                    OR = {
                        has_character_flag = horde_invader
                        AND = {
                            independent = yes
                            religion_group = pagan_group
                            OR = {
                                culture_group = altaic
                                culture_group = magyar
                                culture_group = mesoamerican
                            }
                            FROM = {
                                NOT = { religion_group = pagan_group } # Should subjugate these instead
                            }
                            OR = {
                                is_tribal = yes
                                primary_title = {
                                    has_law = succ_elective_gavelkind
                                }
                                has_landed_title = e_mongol_empire
                                has_landed_title = e_mexikha
                            }
                        }
                    }
                }
                AND = {
                    NOT = { has_dlc = "Horse Lords" }
                    independent = yes
                    higher_tier_than = COUNT
                    OR = {
                        religion_group = pagan_group
                        AND = {
                            OR = {
                                has_horde_culture = yes
                                has_character_flag = horde_invader
                            }
                            NOT = { religion_group = christian }
                        }
                    }
                    OR = {
                        culture_group = altaic
                        culture_group = magyar
                        culture_group = mesoamerican
                    }
                    OR = {
                        has_horde_culture = yes
                        has_character_flag = horde_invader
                        FROM = {
                            NOT = { religion_group = pagan_group } # Should subjugate these instead
                        }
                    }
                    OR = {
                        has_character_flag = horde_invader
                        is_tribal = yes
                        primary_title = {
                            has_law = succ_elective_gavelkind
                        }
                    }
                }
                AND = {
                    mercenary = yes
                    NOT = {
                        num_of_titles = 2
                    }
                }
                AND = {
                    has_character_flag = is_child_of_destiny
                    any_owned_bloodline = {
                        has_bloodline_flag = founder_invasions
                    }
                }
                AND = {
                    NOT = { has_character_flag = flag_declared_bloodline_invasion }
                    any_owned_bloodline = {
                        has_bloodline_flag = bloodline_great_conquerors
                    }
                }
                trait = custom_warmonger_trait #THIS IS THE CUSTOM TRAIT
            }
        }
 
After a lot of testing, I've tentatively narrowed down the culprit to casus belli. I've made one new casus belli, and added a minor alteration to a default cb. Can anyone spot anything in the code that would cause the game to slow down/hitch/choke?

Here is the custom cb
...
#THIS is the ONLY change I made to the code, iirc. I allowed it to be used in the same realm, and I required the character to either be rank 2 in a custom society or have a custom modifier

Initially, I thought that perhaps the slowdown could be caused by literally every AI evaluating whether they wanted to go to war with literally every neighbour. But then I realised that this is also gated on society rank and/or modifier, which probably means that only a few characters can potentially use this CB. (At least, I'm assuming there aren't hundreds of landed AI in the society...) For example, this CB should have fewer evaluations than the Germanic coastal conquest CB, where any landed Germanic character can target any coastal county in a different realm.

Then again, your problem description says you wait 15 years then the slowdowns happen once or twice per year... and that would be consistent with a new society forming, being populated, and then needing to wait a while for some members to reach rank 2.

Side-note #1: Since this can explicitly only target neighbours, perhaps you don't need allow_distant = yes. There doesn't appear to be any documentation for this, but the name suggests it's something like "can AI attack someone far away", which would be needed for Germanic county conquest, but not for conquest of neighbours.

Side-note #2: It seems unlikely, but maybe unlanded characters are evaluating the CB? There doesn't seem to be anything in can_use that would block an unlanded character from trying to use it... but I wouldn't expect the engine to try to evaluate CBs for characters with no troops, hence why this seems implausible. You could add is_landed = yes or higher_real_tier_than = BARON to be sure, although it seems a bit like gold-plating.

---

The default cb that I changed was tribal_invasion. The only thing I changed was to add a custom trait as a potential condition for declaring the cb under can_use_title, at the bottom of the quoted code below.

I can't see any obvious problems with this.

---

Overall, assuming that you're correct about not having changed anything else, I don't see anything in these CBs that would affect performance.

If I were you, my next step would be to design a test that would definitively confirm or deny the hypothesis that it's the CBs that are causing the problem. For example, run a game in observer both with and without the CBs (and with no other changes) - if the slowdowns occur in both runs then it's not the CBs.

Also, it's worth considering whether the slowdowns are caused by an external factor, eg. if some other program on your computer is sucking up all of the resources for some reason, eg. antivirus gone crazy. If you've got a second monitor, it might be worthwhile to play CK2 with task manager visible in that second monitor, so you can see if it's CK2 or another program that spikes to 100% CPU usage during these periodic slowdowns.
 
Last edited:
Initially, I thought that perhaps the slowdown could be caused by literally every AI evaluating whether they wanted to go to war with literally every neighbour. But then I realised that this is also gated on society rank and/or modifier, which probably means that only a few characters can potentially use this CB. (At least, I'm assuming there aren't hundreds of landed AI in the society...) For example, this CB should have fewer evaluations than the Germanic coastal conquest CB, where any landed Germanic character can target any coastal county in a different realm.

Then again, your problem description says you wait 15 years then the slowdowns happen once or twice per year... and that would be consistent with a new society forming, being populated, and then needing to wait a while for some members to reach rank 2.

Side-note #1: Since this can explicitly only target neighbours, perhaps you don't need allow_distant = yes. There doesn't appear to be any documentation for this, but the name suggests it's something like "can AI attack someone far away", which would be needed for Germanic county conquest, but not for conquest of neighbours.

Side-note #2: It seems unlikely, but maybe unlanded characters are evaluating the CB? There doesn't seem to be anything in can_use that would block an unlanded character from trying to use it... but I wouldn't expect the engine to try to evaluate CBs for characters with no troops, hence why this seems implausible. You could add is_landed = yes or higher_real_tier_than = BARON to be sure, although it seems a bit like gold-plating.

---



I can't see any obvious problems with this.

---

Overall, assuming that you're correct about not having changed anything else, I don't see anything in these CBs that would affect performance.

If I were you, my next step would be to design a test that would definitively confirm or deny the hypothesis that it's the CBs that are causing the problem. For example, run a game in observer both with and without the CBs (and with no other changes) - if the slowdowns occur in both runs then it's not the CBs.

Also, it's worth considering whether the slowdowns are caused by an external factor, eg. if some other program on your computer is sucking up all of the resources for some reason, eg. antivirus gone crazy. If you've got a second monitor, it might be worthwhile to play CK2 with task manager visible in that second monitor, so you can see if it's CK2 or another program that spikes to 100% CPU usage during these periodic slowdowns.
I've been taking out files a few at a time, starting a new game with similar conditions (random world, Catholic duke, vassal to someone else), and running it for 30 years. Once a game starts hitching or choking around the 15 to 30 year mark (it's varied), I quit, move the removed files back where they were, and take out a few different files instead, rinse and repeat. When I took out the cb_types folder and started a new game, I finally had a game where it didn't hitch or choke. So it's pretty likely that the problem is in there.

Thanks for breaking it down. I didn't see any obvious problems either. I wondered if maybe is_landed should be used, but like you said it does seem pretty unlikely that anyone without troops would even be evaluated for a CB. Guess I'll have to try.
 
  • 1Like
Reactions:
How does an AI commit suicide? I checked the commit_suicide and commit_suicide_immortal decisions, and those both have ai = no pre-filters.

Curious because a vassal king who was also my son committed suicide. He was one-handed, Stressed, and had the character flag has_PTSD, so those are evident reasons why he might have done so, but how?
 
How does an AI commit suicide? I checked the commit_suicide and commit_suicide_immortal decisions, and those both have ai = no pre-filters.

Curious because a vassal king who was also my son committed suicide. He was one-handed, Stressed, and had the character flag has_PTSD, so those are evident reasons why he might have done so, but how?

Might be an event that makes them do it. Check for the death_reasons related to it and see what pops up.
 
How does an AI commit suicide? I checked the commit_suicide and commit_suicide_immortal decisions, and those both have ai = no pre-filters.

Curious because a vassal king who was also my son committed suicide. He was one-handed, Stressed, and had the character flag has_PTSD, so those are evident reasons why he might have done so, but how?
In general, events. Search the CK2 events folder for "death_suicide" (don't require the whole word, as there are different types of suicide), and there are quite a few hits. I checked a couple, and the AI wasn't obviously blocked from committing suicide in this way.

1676507754124.png
 
  • 1Like
Reactions:
In general, events. Search the CK2 events folder for "death_suicide" (don't require the whole word, as there are different types of suicide), and there are quite a few hits. I checked a couple, and the AI wasn't obviously blocked from committing suicide in this way.

That's extremely helpful, thank you. How do I search all files at once like that? I only know to open each file one at a time and Ctrl + F, which is tedious given how many event files there are.
 
In general, events. Search the CK2 events folder for "death_suicide" (don't require the whole word, as there are different types of suicide), and there are quite a few hits. I checked a couple, and the AI wasn't obviously blocked from committing suicide in this way.

That's extremely helpful, thank you. How do I search all files at once like that? I only know to open each file one at a time and Ctrl + F, which is tedious given how many event files there are.
 
That's extremely helpful, thank you. How do I search all files at once like that? I only know to open each file one at a time and Ctrl + F, which is tedious given how many event files there are.
Get Notepad++. (There are also portable versions in case you don't have admin rights or simply don't want to install for whatever reason.)

In Notepad++: "Search" > "Find in Files..."

Optional: Install the CK2 scripting language UDL (forum thread) (optional because, for many years, I used the built-in C++ syntax highlighter)
 
  • 1
  • 1Like
Reactions:
Get Notepad++. (There are also portable versions in case you don't have admin rights or simply don't want to install for whatever reason.)

In Notepad++: "Search" > "Find in Files..."

Optional: Install the CK2 scripting language UDL (forum thread) (optional because, for many years, I used the built-in C++ syntax highlighter)
I do use Notepad++ but I didn't know about that function. Thank you!
 
  • 1Like
Reactions:
Get Notepad++. (There are also portable versions in case you don't have admin rights or simply don't want to install for whatever reason.)

In Notepad++: "Search" > "Find in Files..."

Optional: Install the CK2 scripting language UDL (forum thread) (optional because, for many years, I used the built-in C++ syntax highlighter)
For Mac users: TextWrangler/BBEdit is a great editor, and also will do multi-file search. You can even set up and save different sets of folders to search.
 
  • 1Like
Reactions:
According to the wiki, holy sites are made by flagging the counties in landed_titles.txt. It suggests making a new file and only putting the county in it, to override the original without a lot of maintenance.

Should I still put the counties' associated baronies in my copied/overwrite entry? Should I still include the duchy, kingdom, and empire entries that the county is part of?

I'm worried that just putting the county, without its associated baronies or duchies, might lead to weird map or de jure behavior, so wish to clarify.