Crusader Kings III

Crusader Kings III

Less Old Wives - AI Men Marry Younger Fertile Women
Morven  [developer] 4 Nov, 2021 @ 3:40am
Discussion and sample code for other marriage modifiers
By request, some sample code to add a malus modifier to men with large broods of legitimate children remarrying young women. Add it to the "marriage_ai_accept_modifier" in "common\scripted_modifiers\00_marriage_scripted_modifiers.txt" of vanilla, or this mod's version you can edit from "C:\Program Files (x86)\Steam\steamapps\workshop\content\1158310\2265131712\common\scripted_modifiers\zz_00_marriage_scripted_modifiers_less_old_wives.txt".

You'll also need to add a new description key and replace "ADD_NEW_DESC_KEY" with whatever you name the description as in your .yml file that you save in a "localization\english" folder structure with a file name that ends in "<modname>_l_english.yml". See the vanilla .yml files in the localisation folders for a format guide.
_ _ _
#Sample code to add a malus for men with four or more legitimate children marrying women under 28 (unless they are friends or lovers) modifier = { add = -100 scope:secondary_recipient = { is_female = yes age < 28 } scope:secondary_actor = { any_child = { is_alive = yes NOT = { has_trait = bastard } count > 3 } NOR = { has_relation_lover = scope:secondary_recipient has_relation_friend = scope:secondary_recipient } #is_ai = yes #Remove the hash if you DON'T want it to apply to your male player characters when they make marriage proposals } desc = ADD_NEW_DESC_KEY } #Make it apply when the woman is the actor/secondary_actor making the proposal too, needed to affect who the AI makes proposal offers to modifier = { add = -100 scope:secondary_recipient = { any_child = { is_alive = yes NOT = { has_trait = bastard } count > 3 } } scope:secondary_actor = { is_female = yes age < 28 NOR = { has_relation_lover = scope:secondary_recipient has_relation_friend = scope:secondary_recipient } #is_ai = yes #Remove the hash if you DON'T want it to apply to your female player characters when they make marriage proposals } desc = ADD_NEW_DESC_KEY }
Last edited by Morven; 4 Nov, 2021 @ 3:49am
< >
Showing 1-5 of 5 comments
Irisiane 4 Nov, 2021 @ 7:59am 
Thank you ♥
Morven  [developer] 4 Nov, 2021 @ 9:48pm 
See how you go and if it has the desired effect. -100 is a large malus but it is overcomable. If you want a complete nerf increase it to -1000. There might be rare situations where you can't marry someone who has already had children with the woman but isn't their lover, because there isn't a check to see if the woman is the mother of any of the children. You could add some code to counter that.

You can tweak the ages, how many children it kicks in at etc.
Morven  [developer] 4 Nov, 2021 @ 10:25pm 
To add a check so the malus does not apply to a man who has had any children with the woman, then you could try this:

EDIT: Fixed the logic so that any child the man has that is mothered by the woman stops the malus being applied.
#Sample code to add a malus for men with four or more legitimate children marrying women under 28 (unless they are friends or lovers, or already have a child together) modifier = { add = -100 scope:secondary_recipient = { is_female = yes age < 28 } scope:secondary_actor = { NOT = { any_child = { is_child_of = scope:secondary_recipient } } any_child = { is_alive = yes NOT = { has_trait = bastard } count > 3 } NOR = { has_relation_lover = scope:secondary_recipient has_relation_friend = scope:secondary_recipient } #is_ai = yes #Remove the hash if you DON'T want it to apply to your male player characters when they make marriage proposals } desc = ADD_NEW_DESC_KEY } #Make it apply when the woman is the actor/secondary_actor making the proposal too, needed to affect who the AI makes proposal offers to modifier = { add = -100 scope:secondary_recipient = { NOT = { any_child = { is_child_of = scope:secondary_actor } } any_child = { is_alive = yes NOT = { has_trait = bastard } count > 3 } } scope:secondary_actor = { is_female = yes age < 28 NOR = { has_relation_lover = scope:secondary_recipient has_relation_friend = scope:secondary_recipient } #is_ai = yes #Remove the hash if you DON'T want it to apply to your female player characters when they make marriage proposals } desc = ADD_NEW_DESC_KEY }
Last edited by Morven; 9 Nov, 2021 @ 4:49pm
Ri'Zakar 3 Apr, 2022 @ 8:20am 
How did you reduce the maximum age difference when betrothing boys to women? I would like to try to reduce it further from 12 to 10 years not only for boys but for girls' betrothals, too. Also, is it possible to set a maximum age difference for adult marriages as well?
Morven  [developer] 13 Apr, 2022 @ 11:36am 
Originally posted by Ri'Zakar:
How did you reduce the maximum age difference when betrothing boys to women? I would like to try to reduce it further from 12 to 10 years not only for boys but for girls' betrothals, too. Also, is it possible to set a maximum age difference for adult marriages as well?
You'd do it by adding a modifier that adds an -1000 opinion malus to marriages where the age difference is more than 10 where one party is a child.

I do it in line 1376 and 1409 of the mod's \common\scripted_modifiers\zz_00_marriage_scripted_modifiers_less_old_wives.txt

First where the actor is the boy and the recipient is the woman
modifier = { # A Recipient is VERY unlikely to agree to a marriage where the Secondary_recipient is a fertile woman and the Secondary_actor is an underage boy who won't become an adult before the woman is infertile add = -1001 #Modded from -200 scope:secondary_recipient = { is_female = yes #is_adult = yes #Hashed out so it applies to child to child betrothals that fall under the age gap set below in marriage_fertile_age_value (29-16=13 year age gap allowed) #Some hashed out vanilla code is included here in the file to make it easier to compare to vanilla code when updating or tweaking that I've deleted in this post for clarity } scope:secondary_actor = { is_adult = no } marriage_fertile_age_reverse_value >= 29 #MODDED FROM 43 #Modded from MARRY_LOW_FERTILITY_REASON desc = MARRY_AGE }
Second where the actor is the woman and the recipient of the offer is the boy
modifier = { # A Recipient is VERY unlikely to agree to a marriage where the Secondary_actor is a woman and the Secondary_recipient is an underage boy who won't become an adult before the woman is infertile add = -1002 #Modded from -200 scope:secondary_actor = { is_female = yes #is_adult = yes #Hashed out so it applies to child to child betrothals that fall under the age gap set below in marriage_fertile_age_value (29-16=13 year age gap allowed) } scope:secondary_recipient = { is_adult = no #Some hashed out vanilla code is included here in the file to make it easier to compare to vanilla code when updating or tweaking that I've deleted in this post for clarity } marriage_fertile_age_value >= 29 #MODDED FROM 43 #Modded from MARRY_LOW_FERTILITY_REASON desc = MARRY_AGE }

marriage_fertile_age_reverse_value is defined in the mod's \common\script_values\zz_00_interaction_values_less_old_wives.txt
marriage_female_fertility_cutoff_age_value = { value = { add = define:NChildbirth|MAX_FEMALE_REPRODUCTION_AGE add = -6 #MODDED FROM -3 if = { limit = { has_trait = fecund } add = 5 } if = { limit = { exists = dynasty dynasty = { has_dynasty_perk = blood_legacy_5 } } add = 5 } } }

marriage_fertile_age_value is defined in vanilla \common\script_values\00_interaction_values.txt
marriage_fertile_age_value = { value = { add = 16 subtract = scope:secondary_recipient.age add = scope:secondary_actor.age } }


Because I change the marriage_fertile_age_value from 45 to 29. This means that a 13 year gap is allowed (29-16=13). If you want to reduce it to a 10 year age gap, reduce marriage_fertile_age_value in the modifier from 29 to 27, and to make it apply to both you can # out the is_female requirement (which means you can delete the entire scope:secondary_actor block) like this where the recipient is the child:
modifier = { # A Recipient is VERY unlikely to agree to a marriage where the Secondary_actor is a woman and the Secondary_recipient is an underage boy who won't become an adult before the woman is infertile add = -1002 #Modded from -200 scope:secondary_actor = { #Note entire block can now be deleted #is_female = yes #Hashed out #is_adult = yes #Hashed out so it applies to child to child betrothals that fall under the age gap set below in marriage_fertile_age_value (29-16=13 year age gap allowed) } scope:secondary_recipient = { is_adult = no } marriage_fertile_age_value >= 27 #MODDED FROM 43 #Modded from MARRY_LOW_FERTILITY_REASON desc = MARRY_AGE }

I think you can simplify the version where the actor is the child to the reverse (I haven't thought it through fully, so double check to make sure that is right)
modifier = { # A Recipient is VERY unlikely to agree to a marriage where the Secondary_actor is a woman and the Secondary_recipient is an underage boy who won't become an adult before the woman is infertile add = -1002 #Modded from -200 scope:secondary_recipient = { #Note entire block can now be deleted #is_female = yes #Hashed out #is_adult = yes #Hashed out so it applies to child to child betrothals that fall under the age gap set below in marriage_fertile_age_value (29-16=13 year age gap allowed) } scope:secondary_actor = { is_adult = no } marriage_fertile_age_value >= 27 #MODDED FROM 43 #Modded from MARRY_LOW_FERTILITY_REASON desc = MARRY_AGE }
Last edited by Morven; 13 Apr, 2022 @ 2:12pm
< >
Showing 1-5 of 5 comments
Per page: 1530 50