• 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.

Lokiness

Private
Jun 30, 2016
22
14
Does someone know how the AI chose spouses for their courtiers ? An important vassal of mine married his heir to a 65 years old woman, and I'm not having it !

It doesn't use the interaction's accept chance, otherwise this wouldn't happen. Maybe the SPOUSE_FINDER_RELEVANCE defines in NMarriage are involved ?
 
Last edited:

Anyasia

Lightbringer
72 Badges
Aug 5, 2015
428
265
  • Europa Universalis IV: Rights of Man
  • Crusader Kings Complete
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Conclave
Does someone know how the AI chose spouses for their courtiers ? An important vassal of mine married his heir to a 65 years old woman, and I'm not having it !

It doesn't use the interaction's accept chance, otherwise this wouldn't happen. Maybe the SPOUSE_FINDER_RELEVANCE defines in NMarriage are involved ?

I don't want to discourage you unnecessarily, lest someone else come along and contradict me, but questions relating to how AI handles marriages and betrothals have been raised in this thread before, with all signs pointing towards it being handled in code, and thus basically being an untouchable black box. You can check out these earlier posts, though, which might help somewhat:—

AI marriage proposal logic is hardcoded and does not use the normal character interaction logic. Indeed the vanilla interaction doesn't even have an ai_will_do. Instead there are various SPOUSE_SCORE defines which control the actual weights it uses, but these mostly only relate to alliances and prestige gain. There isn't one for divine marriage related things.

If you want the AI to always marry incestuously, your other workarounds would work, but if you just want them to weight it a bit higher there really isn't a way to do that right now.

AI marriage acceptance is modifiable though, in the marriage_ai_accept_modifier key in common\scripted_modifiers\00_marriage_scripted_modifiers.txt so you can weight it from the otherside, including with hard -1000 nerfs of marriages you don't want to happen.

The loophole is characters marrying their own unlanded courtiers, which don't go through the marriage_ai_accept_modifier logic.
 
  • 2
Reactions:

Lokiness

Private
Jun 30, 2016
22
14
I don't want to discourage you unnecessarily, lest someone else come along and contradict me, but questions relating to how AI handles marriages and betrothals have been raised in this thread before, with all signs pointing towards it being handled in code, and thus basically being an untouchable black box. You can check out these earlier posts, though, which might help somewhat:—
Thanks a lot for your answer !

If the SPOUSE_SCORE defines mentioned by Tatterhood work as I hope they do, I can fix my issue easily by making the maluses from age bigger. Then my problem is that it's hard to test if it actually worked.
 
Last edited:

swampy111

Second Lieutenant
10 Badges
Apr 3, 2019
146
13
  • Cities: Skylines
  • Magicka 2
  • Cities: Skylines - Parklife
  • Shadowrun Returns
  • Prison Architect
  • Crusader Kings III
  • Crusader Kings II
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Sons of Abraham
  • Magicka
How would I check the age difference in the trigger? Like, CK2 had a age_diff trigger; I didn't see any equivalent on the CK3 wiki. I guess I could mess around with variables, but I'm not quite clear on the syntax of using them yet
 

Anyasia

Lightbringer
72 Badges
Aug 5, 2015
428
265
  • Europa Universalis IV: Rights of Man
  • Crusader Kings Complete
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Conclave
How would I check the age difference in the trigger? Like, CK2 had a age_diff trigger; I didn't see any equivalent on the CK3 wiki. I guess I could mess around with variables, but I'm not quite clear on the syntax of using them yet

You can directly compare the age of any two characters by passing a direct reference to their scopes:—

Code:
# Compare the age of the ROOT character to that of his primary spouse, and trigger TRUE if he's older than her
age > primary_spouse.age

# Compare the age of two characters who have præviously been saved as named scopes with save_scope_as, and trigger TRUE if the first isn't older
scope:first_character.age <= scope.second_character.age

There are also a series of defined script values for testing within (or without) a range: age_plus_5, age_plus_10, age_plus_25, age_minus_5, age_minus_10, and age_minus_25:—

Code:
# Is the recipient of a character interaction no more than 10 years older than the character sending it?
scope:recipient.age <= scope:actor.age_plus_10

# Is the ROOT character more than 25 years older than his primary spouse‽
age > primary_spouse.age_plus_25

You should also be able to define these on the fly, though be warned this code is UNTESTED:—

Code:
# Is the ROOT character more than one year older than another præviously-saved character?
age > { value = scope:some_other_character.age add = 1 }

# Is the ROOT character at least twice as old as his primary spouse‽
age >= { value = primary_spouse.age multiply = 2 }
 
Last edited:
  • 1Like
Reactions:

JokCapybara

Recruit
Oct 8, 2022
7
2
Why is it that this decision
Code:
effect = {
        save_scope_as = scan_finn_former
        
        trigger_event = form_gf.0003

        show_as_tooltip = {
            reclaim_scandinavia_effect = yes
        }

        add_to_global_variable_list = {
            name = unavailable_unique_decisions
            target = flag:flag_scandinavia_finns_decision
        }

        set_global_variable = {
            name = scan_finn_formed_decision
            value = scope:scan_finn_former

        }

        add_character_modifier = { modifier = reclaimer_of_scandinavia_modifier }
        dynasty = {
        add_dynasty_modifier = {
            modifier = reclaimer_of_scandinavia_dynasty_modifier
        }
    }
    
    }
}

triggers the event "form_gf.0001" instead of the "form_gf.0003" one?

Code:
form_gf.0001 = {
    type = character_event
    title = form_gf.0001.t
    desc = form_gf.0001.desc
    theme = martial
    right_portrait = {
        character = root
        animation = personality_rational
    }

    option = {
        name = form_gf.0001.a
    }

    option = {
        name = form_gf.0001.b
    }
}

form_gf.0003 = {
    type = character_event
    title = form_gf.0003.t
    desc = form_gf.0003.desc
    theme = martial
    right_portrait = {
        character = root
        animation = personality_arrogant
    }

    immediate = {
        reclaim_scandinavia_effect = yes   
    }

    option = {
        name = form_gf.0003.a
        if = {
            limit = { has_any_nickname = yes }
            remove_nickname = yes
        }
        give_nickname = nick_child_of_ukko

    }
}
 

Birkaheim

Private
46 Badges
Aug 1, 2019
21
1
  • Europa Universalis IV: Dharma
  • Hearts of Iron IV: Colonel
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Europa Universalis IV: Mandate of Heaven
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Rule Britannia
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Holy Fury
  • Europa Universalis IV: Golden Century
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Crusader Kings III
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Conclave
  • Europa Universalis IV
  • Crusader Kings II: Jade Dragon
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Pre-order
  • Crusader Kings II
  • Europa Universalis IV: Mare Nostrum
Lately, I've been trying to get dynamic localizations for a county and a barony within a custom building's description without it ever producing good results. I'm not too familiar with the scopes and dynamic localization modding for Crusader Kings III, so if anyone would like to offer some advice then I'll appreciate it since the wiki doesn't have sufficent information regarding dynamic title localizations.
 

Anyasia

Lightbringer
72 Badges
Aug 5, 2015
428
265
  • Europa Universalis IV: Rights of Man
  • Crusader Kings Complete
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Conclave
Lately, I've been trying to get dynamic localizations for a county and a barony within a custom building's description without it ever producing good results. I'm not too familiar with the scopes and dynamic localization modding for Crusader Kings III, so if anyone would like to offer some advice then I'll appreciate it since the wiki doesn't have sufficent information regarding dynamic title localizations.

Can you provide a little more information about what exactly you're trying to do? What are your desired results, and what's happening instead?

I've been working on dynamic title localization for one of my mods, admittedly with some weird results of my own, but I might be able to guide you in the right direction if I better understood what you were hoping to accomplish.
 

Birkaheim

Private
46 Badges
Aug 1, 2019
21
1
  • Europa Universalis IV: Dharma
  • Hearts of Iron IV: Colonel
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Europa Universalis IV: Mandate of Heaven
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Rule Britannia
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Holy Fury
  • Europa Universalis IV: Golden Century
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Crusader Kings III
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Conclave
  • Europa Universalis IV
  • Crusader Kings II: Jade Dragon
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Pre-order
  • Crusader Kings II
  • Europa Universalis IV: Mare Nostrum
Can you provide a little more information about what exactly you're trying to do? What are your desired results, and what's happening instead?

I've been working on dynamic title localization for one of my mods, admittedly with some weird results of my own, but I might be able to guide you in the right direction if I better understood what you were hoping to accomplish.
I would like to get the name of the barony and the county to be displayed in the building's description. That is, if the county and barony in question change their names due to the holder being of a different culture, then the description's depiction of those names should automatically accomodate that.

I've tried to get results with codes like [c_skane.GetName], [ROOT.County.GetName], [ROOT.GetTitle], etc. What happens instead is that all text preceding the code goes missing, leaving only the text that comes after.
 

Anyasia

Lightbringer
72 Badges
Aug 5, 2015
428
265
  • Europa Universalis IV: Rights of Man
  • Crusader Kings Complete
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Conclave
I would like to get the name of the barony and the county to be displayed in the building's description. That is, if the county and barony in question change their names due to the holder being of a different culture, then the description's depiction of those names should automatically accomodate that.

I've tried to get results with codes like [c_skane.GetName], [ROOT.County.GetName], [ROOT.GetTitle], etc. What happens instead is that all text preceding the code goes missing, leaving only the text that comes after.

I'm not sure there's a way to dynamically refer to the holding in which a building is constructed within its description. While instinctively it seems like there should be a way to do so, you have to keep in mind there are places in the game where building descriptions are displayed that are disconnected from any holding in particular, such as events which mention unconstructed buildings whose descriptions are then visible in tooltips, and which would thus have no reference for a holding whatsoever.

If this is a special building, which will always and only be præsent in a specific holding (as your reference to c_skane seems to indicate), you can certainly refer to any specific title's dynamic name using code along the lines of [GetTitleByKey('c_skane').GetName].
 

Kazarion

Second Lieutenant
16 Badges
Sep 29, 2022
104
114
  • Cities in Motion 2
  • Crusader Kings II
  • Magicka
  • Cities: Skylines
  • Cities: Skylines Deluxe Edition
  • Pillars of Eternity
  • Cities: Skylines - After Dark
  • Cities: Skylines - Snowfall
  • Cities: Skylines - Natural Disasters
  • Cities: Skylines - Mass Transit
  • Cities: Skylines - Green Cities
  • Cities: Skylines - Parklife
  • Shadowrun Returns
  • Shadowrun: Dragonfall
  • Crusader Kings III
  • Crusader Kings III: Royal Edition
Hello,

Just got that in my error.log while playing, My mod don't affect this file so it's not from it.

Code:
[14:50:05][jomini_script_system.cpp:262]: Script system error!
  Error: change_variable effect [ Variable not of the 'value' scope type. Type: empty ]
  Script location: file: events/story_cycles/story_cycle_hunt_mystical_animal_events.txt; hunt_mystical_animal_immediate_effect line: 20 file: events/story_cycles/story_cycle_hunt_mystical_animal_events.txt line: 58

From the event itself it should be set :

Code:
    immediate = {
        hunt_mystical_animal_immediate_effect = {
            EVENT_NUMBER = 1001
            ENCOUNTER = yes
        }
    }
    
    And the faulty line:
    
    save_temporary_scope_value_as = {
        name = encounter
        value = flag:$ENCOUNTER$
    }

I don't really understand how can this scope can be empty, but it seems it's more that it's an issue with the content of the variable given to the effect that cause some issue.

Does anyone have some idea what went wrong here ?
 

Birkaheim

Private
46 Badges
Aug 1, 2019
21
1
  • Europa Universalis IV: Dharma
  • Hearts of Iron IV: Colonel
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Europa Universalis IV: Mandate of Heaven
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Rule Britannia
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Holy Fury
  • Europa Universalis IV: Golden Century
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Crusader Kings III
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Conclave
  • Europa Universalis IV
  • Crusader Kings II: Jade Dragon
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Pre-order
  • Crusader Kings II
  • Europa Universalis IV: Mare Nostrum
I'm not sure there's a way to dynamically refer to the holding in which a building is constructed within its description. While instinctively it seems like there should be a way to do so, you have to keep in mind there are places in the game where building descriptions are displayed that are disconnected from any holding in particular, such as events which mention unconstructed buildings whose descriptions are then visible in tooltips, and which would thus have no reference for a holding whatsoever.

If this is a special building, which will always and only be præsent in a specific holding (as your reference to c_skane seems to indicate), you can certainly refer to any specific title's dynamic name using code along the lines of [GetTitleByKey('c_skane').GetName].
Thanks for the tip! Though unfortunately, this seems to crash the game. The error.log file doesn't display anything faulty, but it's safe to assume that the string is causing it since I used no other mods than my own.
 

Anyasia

Lightbringer
72 Badges
Aug 5, 2015
428
265
  • Europa Universalis IV: Rights of Man
  • Crusader Kings Complete
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Conclave
Thanks for the tip! Though unfortunately, this seems to crash the game. The error.log file doesn't display anything faulty, but it's safe to assume that the string is causing it since I used no other mods than my own.

Yikes, I'm sorry about that! I honestly don't know why it would crash the game, though; I used the same string in my own tests (albeit with a different holding, as I was using the Buddhas of Bamian to test) and it worked just fine.

Code:
# localization/english/replace/test_l_english.yml

l_english:
 building_type_buddhas_of_bamian_01_desc:1 "BEFORE [GetTitleByKey('b_bamiyan').GetName] AFTER"

Hmm… are you putting this string directly into your building definition file, rather than setting up a localization key which is then localized in localization/english/some_file_l_english.yml (or other-language equivalent)? That's the only thing I can really think of that might cause different behavior.
 

Birkaheim

Private
46 Badges
Aug 1, 2019
21
1
  • Europa Universalis IV: Dharma
  • Hearts of Iron IV: Colonel
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Europa Universalis IV: Mandate of Heaven
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Rule Britannia
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Holy Fury
  • Europa Universalis IV: Golden Century
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Crusader Kings III
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Conclave
  • Europa Universalis IV
  • Crusader Kings II: Jade Dragon
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Pre-order
  • Crusader Kings II
  • Europa Universalis IV: Mare Nostrum
Yikes, I'm sorry about that! I honestly don't know why it would crash the game, though; I used the same string in my own tests (albeit with a different holding, as I was using the Buddhas of Bamian to test) and it worked just fine.

Code:
# localization/english/replace/test_l_english.yml

l_english:
 building_type_buddhas_of_bamian_01_desc:1 "BEFORE [GetTitleByKey('b_bamiyan').GetName] AFTER"

Hmm… are you putting this string directly into your building definition file, rather than setting up a localization key which is then localized in localization/english/some_file_l_english.yml (or other-language equivalent)? That's the only thing I can really think of that might cause different behavior.
Could you elaborate on what you mean by 'building definition file'? And when you say 'localization key', do you mean creating a custom localization string?
 

Anyasia

Lightbringer
72 Badges
Aug 5, 2015
428
265
  • Europa Universalis IV: Rights of Man
  • Crusader Kings Complete
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Conclave
Could you elaborate on what you mean by 'building definition file'? And when you say 'localization key', do you mean creating a custom localization string?

Ah… ignore me, sorry, I forgot that the building descriptions aren't actually included in their definitions, so that question was entirely irrelevant. I guess a more general and relevant question is, 'Where exactly are you trying to include this string?' You mentioned that it was in the building's description, yes? So my assumption, and how I tested it, was to use the localization key for the building description, which is in the form of building_<key>_desc, where <key> is the key given to the building where it's defined in a file in the common/buildings directory (that's what I meant by the 'definition file'). I then used that localization key in a file in localization/english, putting the aforementioned [GetTitleByKey('b_bamiyan').GetName] therein, and as I say, it worked just fine for me. My only thought is perhaps I'm missing or misunderstanding something about how you're trying to use this code that would cause it to not work properly for you when it does for me, so I'm trying to work out if that's the case.
 

Birkaheim

Private
46 Badges
Aug 1, 2019
21
1
  • Europa Universalis IV: Dharma
  • Hearts of Iron IV: Colonel
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Europa Universalis IV: Mandate of Heaven
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Rule Britannia
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Holy Fury
  • Europa Universalis IV: Golden Century
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Crusader Kings III
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Conclave
  • Europa Universalis IV
  • Crusader Kings II: Jade Dragon
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Pre-order
  • Crusader Kings II
  • Europa Universalis IV: Mare Nostrum
Ah… ignore me, sorry, I forgot that the building descriptions aren't actually included in their definitions, so that question was entirely irrelevant. I guess a more general and relevant question is, 'Where exactly are you trying to include this string?' You mentioned that it was in the building's description, yes? So my assumption, and how I tested it, was to use the localization key for the building description, which is in the form of building_<key>_desc, where <key> is the key given to the building where it's defined in a file in the common/buildings directory (that's what I meant by the 'definition file'). I then used that localization key in a file in localization/english, putting the aforementioned [GetTitleByKey('b_bamiyan').GetName] therein, and as I say, it worked just fine for me. My only thought is perhaps I'm missing or misunderstanding something about how you're trying to use this code that would cause it to not work properly for you when it does for me, so I'm trying to work out if that's the case.
Oh okay, I see what you mean. Yes, I've done such a thing (even including the fact that my building has a '_type_' part to signify that the building is unique), but there result was that the game crashed with no explanation in the logs. This is how my string looks like:

building_type_uppakra_temple_01_desc: "This text should appear. [GetTitleByKey('c_skane').GetName] <- This text succeeds this."
 

Mcgan

Lt. General
18 Badges
Mar 19, 2020
1.236
1.820
  • Crusader Kings III: Royal Edition
  • Stellaris: Galaxy Edition
  • Stellaris - Path to Destruction bundle
  • Stellaris: Distant Stars
  • Stellaris: Synthetic Dawn
  • Stellaris: Leviathans Story Pack
  • Stellaris: Apocalypse
  • Stellaris: Megacorp
  • Stellaris: Ancient Relics
  • Stellaris: Federations
  • Stellaris: Nemesis
  • Stellaris: Humanoids Species Pack
  • Stellaris: Digital Anniversary Edition
  • Stellaris: Lithoids
  • Stellaris: Necroids
This is how my string looks like:

building_type_uppakra_temple_01_desc: "This text should appear. [GetTitleByKey('c_skane').GetName] <- This text succeeds this."
Does it still crash if you remove "<" from your line?
 

Anyasia

Lightbringer
72 Badges
Aug 5, 2015
428
265
  • Europa Universalis IV: Rights of Man
  • Crusader Kings Complete
  • Crusader Kings II
  • Crusader Kings III
  • Europa Universalis IV: Call to arms event
  • Crusader Kings II: Conclave
Oh okay, I see what you mean. Yes, I've done such a thing (even including the fact that my building has a '_type_' part to signify that the building is unique), but there result was that the game crashed with no explanation in the logs. This is how my string looks like:

building_type_uppakra_temple_01_desc: "This text should appear. [GetTitleByKey('c_skane').GetName] <- This text succeeds this."

Unfortunately I can't tell you why it's crashing, but I don't think it has anything to do with the localization. Here's my entire file setup and the resulting, perfectly-functional localization:—

Code:
# common/buildings/anyasia_test_buildings.txt

uppakra_temple_01 = {
    construction_time = very_slow_construction_time

    type_icon = "icon_structure_buddhas_of_bamiyan.dds"
   
    can_construct_potential = {
        building_requirement_tribal = no
    }

    is_enabled = {
        always = yes
    }
   
    cost_gold = 3000

    character_modifier = {
        monthly_piety_gain_mult = 0.1
        diplomacy_per_piety_level = 1
    }
    county_modifier = {
        tax_mult = 0.1
        development_growth = 0.2
        development_growth_factor = 0.75
    }
   
    ai_value = {
        base = 100
        modifier = { # Fill all building slots before going for special buildings
            factor = 0
            free_building_slots > 0
        }
    }
   
    type = special
}

Code:
# history/provinces/z_anyasia_test_buildings.txt

70 = {        #LUND
    culture = norse
    religion = norse_pagan
    holding = tribal_holding
    965.1.1 = {
        culture = danish
        religion = catholic
    }
    1020.1.1 = {
        holding = castle_holding
        special_building = uppakra_temple_01
    }
    1066.1.1 = {
        buildings = {
            common_tradeport_01
            cereal_fields_01
            pastures_01
        }
    }
}

Code:
# localization/english/anyasia_test_building_l_english.yml

l_english:
 building_type_uppakra_temple_01:0 "Uppakra Temple"
 building_type_uppakra_temple_01_desc:0 "This text should appear. [GetTitleByKey('c_skane').GetName] <- This text succeeds this."
 building_uppakra_temple_01:0 "$building_type_uppakra_temple_01$"
 building_uppakra_temple_01_desc:0 "$building_type_uppakra_temple_01_desc$"

20221016172020_1.jpg


One thought that came to mind when I was coding this was that, if you've put it in Lund as I have, it might be related to Lund's province definition having special_building_slot = lund_cathedral_01 defined by default—I don't have really any experience modding buildings, but I note that every province with one of these slots defined has only one slot defined and if it has any special building defined in the history at all, it's the one defined by the slot. Perhaps a mismatch between this and your custom building is responsible for the crash? I didn't test it—you'll see I removed that line from my province definition above—but It's really the only immediate thing coming to mind, unfortunately. :(

Edit: Or maybe it's the lack of key version in your localization (the 0 following the colon in mine, absent in yours)? That seems even less likely, given I don't think it's required, but hey, who knows, I'm at a loss, so any little discrepancy becomes suspect, heh.
 

Birkaheim

Private
46 Badges
Aug 1, 2019
21
1
  • Europa Universalis IV: Dharma
  • Hearts of Iron IV: Colonel
  • Crusader Kings II: Reapers Due
  • Europa Universalis IV: Rights of Man
  • Hearts of Iron IV: Together for Victory
  • Crusader Kings II: Monks and Mystics
  • Europa Universalis IV: Mandate of Heaven
  • Hearts of Iron IV: Death or Dishonor
  • Europa Universalis IV: Cradle of Civilization
  • Hearts of Iron IV: Expansion Pass
  • Europa Universalis IV: Rule Britannia
  • Hearts of Iron IV: Cadet
  • Crusader Kings II: Holy Fury
  • Europa Universalis IV: Golden Century
  • Imperator: Rome Deluxe Edition
  • Imperator: Rome
  • Hearts of Iron IV: Expansion Pass
  • Hearts of Iron IV: La Resistance
  • Crusader Kings III
  • Battle for Bosporus
  • Hearts of Iron IV: No Step Back
  • Europa Universalis IV: Cossacks
  • Crusader Kings II: Horse Lords
  • Europa Universalis IV: Common Sense
  • Crusader Kings II: Way of Life
  • Europa Universalis IV: El Dorado
  • Crusader Kings II: Conclave
  • Europa Universalis IV
  • Crusader Kings II: Jade Dragon
  • Crusader Kings II: Charlemagne
  • Crusader Kings II: Legacy of Rome
  • Crusader Kings II: The Old Gods
  • Crusader Kings II: Rajas of India
  • Crusader Kings II: The Republic
  • Crusader Kings II: Sons of Abraham
  • Crusader Kings II: Sunset Invasion
  • Crusader Kings II: Sword of Islam
  • Europa Universalis IV: Art of War
  • Europa Universalis IV: Conquest of Paradise
  • Europa Universalis IV: Wealth of Nations
  • Europa Universalis IV: Call to arms event
  • Europa Universalis IV: Res Publica
  • Europa Universalis IV: Third Rome
  • Europa Universalis IV: Pre-order
  • Crusader Kings II
  • Europa Universalis IV: Mare Nostrum
Unfortunately I can't tell you why it's crashing, but I don't think it has anything to do with the localization. Here's my entire file setup and the resulting, perfectly-functional localization:—

Code:
# common/buildings/anyasia_test_buildings.txt

uppakra_temple_01 = {
    construction_time = very_slow_construction_time

    type_icon = "icon_structure_buddhas_of_bamiyan.dds"
 
    can_construct_potential = {
        building_requirement_tribal = no
    }

    is_enabled = {
        always = yes
    }
 
    cost_gold = 3000

    character_modifier = {
        monthly_piety_gain_mult = 0.1
        diplomacy_per_piety_level = 1
    }
    county_modifier = {
        tax_mult = 0.1
        development_growth = 0.2
        development_growth_factor = 0.75
    }
 
    ai_value = {
        base = 100
        modifier = { # Fill all building slots before going for special buildings
            factor = 0
            free_building_slots > 0
        }
    }
 
    type = special
}

Code:
# history/provinces/z_anyasia_test_buildings.txt

70 = {        #LUND
    culture = norse
    religion = norse_pagan
    holding = tribal_holding
    965.1.1 = {
        culture = danish
        religion = catholic
    }
    1020.1.1 = {
        holding = castle_holding
        special_building = uppakra_temple_01
    }
    1066.1.1 = {
        buildings = {
            common_tradeport_01
            cereal_fields_01
            pastures_01
        }
    }
}

Code:
# localization/english/anyasia_test_building_l_english.yml

l_english:
 building_type_uppakra_temple_01:0 "Uppakra Temple"
 building_type_uppakra_temple_01_desc:0 "This text should appear. [GetTitleByKey('c_skane').GetName] <- This text succeeds this."
 building_uppakra_temple_01:0 "$building_type_uppakra_temple_01$"
 building_uppakra_temple_01_desc:0 "$building_type_uppakra_temple_01_desc$"

View attachment 891287

One thought that came to mind when I was coding this was that, if you've put it in Lund as I have, it might be related to Lund's province definition having special_building_slot = lund_cathedral_01 defined by default—I don't have really any experience modding buildings, but I note that every province with one of these slots defined has only one slot defined and if it has any special building defined in the history at all, it's the one defined by the slot. Perhaps a mismatch between this and your custom building is responsible for the crash? I didn't test it—you'll see I removed that line from my province definition above—but It's really the only immediate thing coming to mind, unfortunately. :(

Edit: Or maybe it's the lack of key version in your localization (the 0 following the colon in mine, absent in yours)? That seems even less likely, given I don't think it's required, but hey, who knows, I'm at a loss, so any little discrepancy becomes suspect, heh.
Still doesn't work, I'm afraid. The province history file is like this, as well:

70 = { #LUND culture = norse religion = norse_pagan holding = tribal_holding special_building = uppakra_temple_01 965.1.1 = { culture = danish religion = catholic } 1020.1.1 = { holding = castle_holding } 1066.1.1 = { buildings = { common_tradeport_01 cereal_fields_01 pastures_01 } } }

However, I have this idea to separate the building from the other modifications that I've done on my personal mod. If it still crashes even if the building is a separate mod, I'm gonna take a guess and assume there's something up for me with the game.

UPDATE: Still crashes. Gonna try and verify the game files.

UPDATE 2: No luck there, either. I've run out of ideas for now.
 
Last edited: