﻿namespace = lmf_spouse

##########################
# EXPANDED SPOUSE EVENTS #
##########################

scripted_trigger extra_spouse_availability_trigger = {
	is_physically_able = yes
	has_recoverable_disease_trigger = no
	available_or_same_location = { EXCEPTION = primary_spouse }
	primary_spouse = {
		is_physically_able = yes
		has_recoverable_disease_trigger = no
		available_or_same_location = { EXCEPTION = root }
		trigger_if = {
			limit = { is_playable_character = yes }
			NOT = { is_at_war_with = root }
		}
	}
}

scripted_trigger standard_spouse_availability_trigger = {
	is_available = yes
	has_recoverable_disease_trigger = no
	primary_spouse = {
		is_available = yes
		has_recoverable_disease_trigger = no
		trigger_if = {
			limit = { is_playable_character = yes }
			NOT = { is_at_war_with = root }
		}
	}
}

scripted_trigger has_secret_spouse_can_reveal_trigger = {
	has_any_secrets = yes
	is_adult = yes
	NOR = {
		this = root.primary_spouse
		has_relation_friend = root.primary_spouse
		reverse_opinion = { target = root.primary_spouse value >= 50 }
	}
	OR = {
		intrigue <= root.primary_spouse.intrigue
		root.primary_spouse.intrigue >= 15
	}
	save_temporary_scope_as = potential_courtier_secret
	any_secret = {
		NOR = {
			is_known_by = root
			secret_is_incriminating_trigger = { TARGET = root }
			secret_is_incriminating_trigger = { TARGET = root.primary_spouse }
			AND = {
				secret_type = secret_unmarried_illegitimate_child
				OR = {
					secret_target = { real_father ?= root }
					secret_target = { real_father ?= root.primary_spouse }
				}
			}
			AND = {
				secret_type = secret_disputed_heritage
				OR = {
					secret_target = { real_father ?= root }
					secret_target = { real_father ?= root.primary_spouse }
				}
			}
		}
		OR = {
			is_blackmailable_secret_trigger = { BLACKMAILER = root PARTICIPANT = scope:potential_courtier_secret }
			secret_is_always_interesting_trigger = yes
		}
	}
}

scripted_trigger good_spouse_introduction = {
	OR = {
		has_personality_dominant_trigger = yes
		has_personality_benevolent_trigger = yes
		has_personality_levelheaded_trigger = yes
		AND = {
			has_trait = gregarious
			has_trait_introverted_trigger = no
		}
		AND = {
			has_trait = diligent
			has_trait_emotional_trigger = no
		}
		has_trait = intellect_good_2
		has_trait = intellect_good_3
		has_trait = shrewd
	}
}

scripted_trigger bad_spouse_introduction = {
	OR = {
		has_trait = lunatic
		has_trait = possessed
		has_personality_malicious_trigger = yes
		AND = {
			OR = {
				has_trait = wrathful
				has_trait = impatient
				has_trait = sadistic
				has_trait = vengeful
			}
			has_trait_levelheaded_trigger = no
		}
		AND = {
			has_trait = arrogant
			has_trait_benevolent_trigger = no
		}
		has_trait = drunkard
		has_trait = intellect_bad_2
		has_trait = intellect_bad_3
		has_trait = dull
	}
}

scripted_trigger neutral_spouse_introduction = {
	OR = {
		has_personality_submissive_trigger = yes
		has_personality_introverted_trigger = yes
		has_trait = depressed
	}
}

scripted_effect add_spouse_event_variables = {
	if = {
		limit = { has_character_flag = spouse_event_player_delay }
		remove_character_flag = spouse_event_player_delay
	}
	add_character_flag = { flag = spouse_event_player_delay months = 20 }
}

# Initial marriage event
lmf_spouse.100 = {
	type = character_event
	hidden = yes

	trigger = {
		can_get_lmf_spouse_events = yes
		exists = capital_province
		primary_spouse ?= {
			this = scope:new_spouse
			is_physically_able_ai = yes
			NOT = { exists = involved_activity }
			OR = {
				location ?= root.capital_province
				is_playable_character = yes
			}
		}
		NOT = {
			any_former_spouse = {
				this = scope:new_spouse
			}
		}
	}

	on_trigger_fail = {
		if = {
			limit = {
				can_get_lmf_spouse_events = yes
				exists = capital_province
				primary_spouse ?= {
					this = scope:new_spouse
					is_physically_able_ai = yes
				}
			}
			add_spouse_event_variables = yes
			trigger_event = { id = lmf_spouse.100 days = 15 }
		}
	}

	immediate = {
		capital_county = { save_scope_as = home } # for the reaction of "the people"

		scope:new_spouse = {
			# are they a ruler?
			if = {
				limit = { is_playable_character = yes }
				primary_title = { save_scope_as = spouse_title }
				if = {
					limit = {
						is_independent_ruler = no
						NOT = { top_liege = root.top_liege }
					}
					top_liege = { save_scope_as = spouse_top_liege }
				}
			}

			# are they a relative of a ruler
			if = {
				limit = {
					NOT = { is_close_family_of = root }
				}
				every_close_or_extended_family_member = {
					even_if_dead = yes
					limit = { exists = primary_title }
					add_to_list = spouse_ruler_relatives
				}
			}
			if = {
				limit = { list_size:spouse_ruler_relatives > 0 }
				ordered_in_list = {
					list = spouse_ruler_relatives
					order_by = primary_title.tier
					limit = { is_parent_of = scope:new_spouse }
					alternative_limit = { is_close_family_of = scope:new_spouse }
					alternative_limit = { is_close_or_extended_family_of = scope:new_spouse }
					save_scope_as = spouse_relative
				}
			}

			# first set the variables for reputation & remarkable
			set_variable = { name = spouse_reputation value = 0 }
			set_variable = { name = spouse_remarkable value = 0 }

			# then track how many reputation instances appear, in order of importance
			if = {
				limit = {
					OR = {
						AND = {
							has_trait = cannibal
							trait_is_shunned_or_criminal_in_faith_trigger = { TRAIT = trait:cannibal FAITH = scope:home.faith GENDER_CHARACTER = scope:new_spouse }
						}
						AND = {
							has_trait = incestuous
							trait_is_shunned_or_criminal_in_faith_trigger = { TRAIT = trait:incestuous FAITH = scope:home.faith GENDER_CHARACTER = scope:new_spouse }
						}
						AND = {
							has_trait = sodomite
							trait_is_shunned_or_criminal_in_faith_trigger = { TRAIT = trait:sodomite FAITH = scope:home.faith GENDER_CHARACTER = scope:new_spouse }
						}
						AND = {
							has_trait = witch
							trait_is_shunned_or_criminal_in_faith_trigger = { TRAIT = trait:witch FAITH = scope:home.faith GENDER_CHARACTER = scope:new_spouse }
						}
					}
				}
				if = {
					limit = {
						has_trait = cannibal
						trait_is_shunned_or_criminal_in_faith_trigger = { TRAIT = trait:cannibal FAITH = scope:home.faith GENDER_CHARACTER = scope:new_spouse }
					}
					set_variable = { name = has_bad_rep_cannibal value = yes days = 3 }
				}
				else_if = {
					limit = {
						has_trait = incestuous
						trait_is_shunned_or_criminal_in_faith_trigger = { TRAIT = trait:incestuous FAITH = scope:home.faith GENDER_CHARACTER = scope:new_spouse }
					}
					set_variable = { name = has_bad_rep_incestuous value = yes days = 3 }
				}
				else_if = {
					limit = {
						has_trait = sodomite
						trait_is_shunned_or_criminal_in_faith_trigger = { TRAIT = trait:sodomite FAITH = scope:home.faith GENDER_CHARACTER = scope:new_spouse }
					}
					set_variable = { name = has_bad_rep_sodomite value = yes days = 3 }
				}
				else = {
					set_variable = { name = has_bad_rep_witch value = yes days = 3 }
				}
				change_variable = { name = spouse_reputation add = 1 }
				set_variable = { name = has_bad_rep value = yes days = 3 }
			}
			if = {
				limit = { has_trait = murderer }
				change_variable = { name = spouse_reputation add = 1 }
				set_variable = { name = has_murderer_rep value = yes days = 3 }
			}
			if = {
				limit = {
					NOT = { exists = var:has_bad_rep_sodomite }
					OR = {
						AND = {
							has_trait = adulterer
							trait_is_shunned_or_criminal_in_faith_trigger = { TRAIT = trait:adulterer FAITH = scope:home.faith GENDER_CHARACTER = scope:new_spouse }
						}
						AND = {
							has_trait = fornicator
							trait_is_shunned_or_criminal_in_faith_trigger = { TRAIT = trait:fornicator FAITH = scope:home.faith GENDER_CHARACTER = scope:new_spouse }
						}
					}
				}
				change_variable = { name = spouse_reputation add = 1 }
				set_variable = { name = has_adulterer_rep value = yes days = 3 }
			}
			if = {
				limit = {
					NOR = {
						religion = root.religion
						religion = scope:home.religion
					}
					scope:home.faith = {
						faith_hostility_level = {
							target = scope:new_spouse.faith
							value > faith_astray_level
						}
					}
				}
				change_variable = { name = spouse_reputation add = 1 }
				set_variable = { name = has_religion_rep value = yes days = 3 }
			}
			if = {
				limit = {
					OR = {
						is_illegitimate = yes
						has_trait = disputed_heritage
					}
					NOT = {
						scope:home.faith = { has_doctrine_parameter = bastards_none }
					}
				}
				if = {
					limit = { is_illegitimate = yes }
					set_variable = { name = has_bastard_rep_illegitimate value = yes days = 3 }
				}
				else = {
					set_variable = { name = has_bastard_rep_disputed value = yes days = 3 }
				}
				change_variable = { name = spouse_reputation add = 1 }
			}
			if = {
				limit = {
					OR = {
						AND = {
							religion = root.religion
							NOT = { faith = root.faith }
							scope:home.faith = {
								faith_hostility_level = {
									target = scope:new_spouse.faith
									value > faith_fully_accepted_level
								}
							}
						}
						AND = {
							NOR = {
								culture = root.culture
								culture = scope:home.culture
							}
							root.culture = {
								cultural_acceptance = {
									target = scope:new_spouse.culture
									value < miniscule_cultural_acceptance_value
								}
							}
						}
					}
				}
				if = {
					limit = {
						religion = root.religion
						NOT = { faith = root.faith }
						scope:home.faith = {
							faith_hostility_level = {
								target = scope:new_spouse.faith
								value > faith_fully_accepted_level
							}
						}
					}
					set_variable = { name = has_faithculture_rep_faith value = yes days = 3 }
				}
				else = {
					set_variable = { name = has_faithculture_rep_culture value = yes days = 3 }
				}
				change_variable = { name = spouse_reputation add = 1 }
			}

			# then track how many remarkable instances appear, in order of importance
			if = {
				limit = { has_trait = pregnant }
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_pregnant value = yes days = 3 }
			}
			if = {
				limit = { has_trait = leper }
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_leper value = yes days = 3 }
			}
			if = {
				limit = { has_trait = albino }
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_albino value = yes days = 3 }
			}
			if = {
				limit = { has_trait = giant }
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_giant value = yes days = 3 }
			}
			if = {
				limit = { has_trait = dwarf }
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_dwarf value = yes days = 3 }
			}
			if = {
				limit = { has_trait = inbred }
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_inbred value = yes days = 3 }
			}
			if = {
				limit = {
					OR = {
						has_trait = maimed
						has_trait = one_legged
						has_trait = disfigured
						has_trait = scaly
						has_trait = hunchbacked
					}
				}
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_disfigured value = yes days = 3 }
			}
			if = {
				limit = {
					OR = {
						has_trait = infirm
						AND = {
							is_female = yes
							age >= 45
						}
						AND = {
							is_male = yes
							age >= 60
						}
					}
				}
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_old value = yes days = 3 }
			}
			if = {
				limit = {
					OR = {
						has_trait = beauty_bad_2
						has_trait = beauty_bad_3
					}
				}
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_ugly value = yes days = 3 }
			}
			if = {
				limit = { current_weight >= 75 }
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_fat value = yes days = 3 }
			}
			if = {
				limit = {
					OR = {
						has_trait = beauty_good_2
						has_trait = beauty_good_3
					}
					is_malformed_trigger = no
					NOT = { exists = var:is_disfigured }
					NOT = { exists = var:is_fat }
				}
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_beautiful value = yes days = 3 }
			}
			if = {
				limit = {
					has_trait = beauty_good_1
					is_malformed_trigger = no
					NOT = { exists = var:is_disfigured }
					NOT = { exists = var:is_fat }
				}
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_pretty value = yes days = 3 }
			}
			if = {
				limit = {
					is_male = yes
					OR = {
						has_trait = spindly
						has_trait = physique_bad_2
						has_trait = physique_bad_3
					}
					NOT = { exists = var:is_beautiful }
					NOT = { exists = var:is_ugly }
				}
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_weak value = yes days = 3 }
			}
			if = {
				limit = {
					is_male = yes
					OR = {
						has_trait = physique_good_2
						has_trait = physique_good_3
					}
					NOT = { exists = var:is_weak }
				}
				change_variable = { name = spouse_remarkable add = 1 }
				set_variable = { name = is_strong value = yes days = 3 }
			}

			# then figure out how their introduction at court went
			random_list = {
				50 = {
					trigger = { good_spouse_introduction = yes }
					modifier = {
						add = 50
						has_trait = intellect_good_3
					}
					modifier = {
						add = 50
						calc_true_if = {
							amount > 1
							has_personality_dominant_trigger = yes
							has_personality_benevolent_trigger = yes
							has_personality_levelheaded_trigger = yes
							AND = {
								has_trait = gregarious
								has_trait_introverted_trigger = no
							}
							AND = {
								has_trait = diligent
								has_trait_emotional_trigger = no
							}
							has_trait = intellect_good_2
							has_trait = intellect_good_3
							has_trait = shrewd
						}
					}
					set_variable = { name = spouse_court value = flag:good days = 3 }
				}
				50 = {
					trigger = { bad_spouse_introduction = yes }
					modifier = {
						add = 50
						has_trait = intellect_bad_3
					}
					modifier = {
						add = 50
						has_trait = lunatic
					}
					modifier = {
						add = 50
						calc_true_if = {
							amount > 1
							has_trait = lunatic
							has_trait = possessed
							has_personality_malicious_trigger = yes
							AND = {
								OR = {
									has_trait = wrathful
									has_trait = impatient
									has_trait = sadistic
									has_trait = vengeful
								}
								has_trait_levelheaded_trigger = no
							}
							AND = {
								has_trait = arrogant
								has_trait_benevolent_trigger = no
							}
							has_trait = drunkard
							has_trait = intellect_bad_2
							has_trait = intellect_bad_3
							has_trait = dull
						}
					}
					set_variable = { name = spouse_court value = flag:bad days = 3 }
				}
				25 = {
					trigger = { neutral_spouse_introduction = yes }
					modifier = {
						add = 25
						has_trait = depressed
					}
					modifier = {
						add = 25
						calc_true_if = {
							amount > 1
							has_personality_submissive_trigger = yes
							has_personality_introverted_trigger = yes
							has_trait = depressed
						}
					}
					set_variable = { name = spouse_court value = flag:neutral days = 3 }
				}
				100 = {
					trigger = {
						good_spouse_introduction = no
						bad_spouse_introduction = no
						neutral_spouse_introduction = no
					}
					set_variable = { name = spouse_court value = flag:fallthrough days = 3 }
				}
			}
		}

		trigger_event = lmf_spouse.101
	}
}

lmf_spouse.101 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:new_spouse = { has_dynasty = no }
				}
				desc = lmf_spouse.101.t.lowborn
			}
			triggered_desc = {
				trigger = {
					scope:new_spouse = {
						is_playable_character = yes
						highest_held_title_tier > tier_duchy
					}
				}
				desc = lmf_spouse.101.t.ruler
			}
			triggered_desc = {
				trigger = { is_close_family_of = scope:new_spouse }
				desc = lmf_spouse.101.t.relative
			}
			triggered_desc = {
				trigger = {
					scope:new_spouse = { is_playable_character = yes }
				}
				desc = lmf_spouse.101.t.ruler
			}
			triggered_desc = {
				trigger = { is_extended_family_of = scope:new_spouse }
				desc = lmf_spouse.101.t.relative
			}
			desc = lmf_spouse.101.t.default
		}
	}
	desc = {
		desc = lmf_spouse.101.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:new_spouse = { has_dynasty = no }
				}
				desc = lmf_spouse.101.desc.start.lowborn
			}
			triggered_desc = {
				trigger = { is_close_family_of = scope:new_spouse }
				desc = lmf_spouse.101.desc.start.relative
			}
			triggered_desc = {
				trigger = {
					scope:new_spouse = { is_playable_character = yes }
					exists = scope:spouse_top_liege
				}
				desc = lmf_spouse.101.desc.start.rulerdistant
			}
			triggered_desc = {
				trigger = {
					scope:new_spouse = { is_playable_character = yes }
				}
				desc = lmf_spouse.101.desc.start.ruler
			}
			triggered_desc = {
				trigger = {
					exists = scope:spouse_relative
					scope:spouse_relative = { is_close_family_of = scope:new_spouse }
				}
				desc = lmf_spouse.101.desc.start.rulerrelative
			}
			triggered_desc = {
				trigger = { is_extended_family_of = scope:new_spouse }
				desc = lmf_spouse.101.desc.start.relative
			}
			triggered_desc = {
				trigger = {
					exists = scope:spouse_relative
					scope:spouse_relative = { is_extended_family_of = scope:new_spouse }
				}
				desc = lmf_spouse.101.desc.start.rulerrelative
			}
			triggered_desc = {
				trigger = {
					scope:spouse.dynasty = {
						OR = {
							dynasty_prestige_level > 2
							any_dynasty_member = { count >= 20 }
							any_dynasty_member = { highest_held_title_tier >= tier_duchy }
						}
					}
				}
				desc = lmf_spouse.101.desc.start.dynasty
			}
			desc = lmf_spouse.101.desc.start.default
		}
		first_valid = {
			triggered_desc = {
				trigger = { scope:new_spouse.var:spouse_reputation > 1 }
				desc = lmf_spouse.101.desc.hasrep2
			}
			triggered_desc = {
				trigger = { scope:new_spouse.var:spouse_reputation > 0 }
				desc = lmf_spouse.101.desc.hasrep1
			}
			desc = lmf_spouse.101.desc.hasrep0
		}
		first_valid = {
			triggered_desc = {
				trigger = { scope:new_spouse.var:spouse_remarkable > 1 }
				desc = lmf_spouse.101.desc.hasrem2
			}
			triggered_desc = {
				trigger = { scope:new_spouse.var:spouse_remarkable > 0 }
				desc = lmf_spouse.101.desc.hasrem1
			}
			desc = lmf_spouse.101.desc.hasrem0
		}
		desc = lmf_spouse.101.desc.mid
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:new_spouse.var:spouse_court = flag:good
					scope:new_spouse = { has_recoverable_disease_trigger = yes }
				}
				desc = lmf_spouse.101.desc.goodsick
			}
			triggered_desc = {
				trigger = { scope:new_spouse.var:spouse_court = flag:good }
				desc = lmf_spouse.101.desc.good
			}
			triggered_desc = {
				trigger = {
					scope:new_spouse.var:spouse_court = flag:bad
					scope:new_spouse = { has_recoverable_disease_trigger = yes }
				}
				desc = lmf_spouse.101.desc.badsick
			}
			triggered_desc = {
				trigger = { scope:new_spouse.var:spouse_court = flag:bad }
				desc = lmf_spouse.101.desc.bad
			}
			triggered_desc = {
				trigger = {
					scope:new_spouse = { has_recoverable_disease_trigger = yes }
				}
				desc = lmf_spouse.101.desc.defaultsick
			}
			desc = lmf_spouse.101.desc.default
		}
	}
	theme = marriage

	right_portrait = {
		character = scope:new_spouse
		triggered_animation = {
			trigger = {
				scope:new_spouse.var:spouse_court = flag:neutral
				scope:new_spouse = { has_trait = depressed }
			}
			animation = sadness
		}
		triggered_animation = {
			trigger = {
				scope:new_spouse.var:spouse_court = flag:bad
				scope:new_spouse = {
					OR = {
						has_trait = intellect_bad_2
						has_trait = intellect_bad_3
						has_trait = dull
					}
				}
			}
			animation = shame
		}
		triggered_animation = {
			trigger = {
				scope:new_spouse.var:spouse_court = flag:bad
				scope:new_spouse = { has_trait = drunkard }
			}
			animation = wedding_drunk
		}
		triggered_animation = {
			trigger = {
				scope:new_spouse.var:spouse_court = flag:bad
				scope:new_spouse = {
					has_trait = arrogant
					has_trait_benevolent_trigger = no
				}
			}
			animation = disapproval
		}
		triggered_animation = {
			trigger = {
				scope:new_spouse.var:spouse_court = flag:bad
				scope:new_spouse = {
					OR = {
						has_trait = wrathful
						has_trait = impatient
						has_trait = sadistic
						has_trait = vengeful
					}
					has_trait_levelheaded_trigger = no
				}
			}
			animation = anger
		}
		triggered_animation = {
			trigger = {
				scope:new_spouse.var:spouse_court = flag:bad
				scope:new_spouse = {
					OR = {
						has_trait = lunatic
						has_trait = possessed
					}
				}
			}
			animation = manic
		}
		triggered_animation = {
			trigger = {
				scope:new_spouse.var:spouse_court = flag:good
				scope:new_spouse = {
					has_trait = diligent
					has_trait_emotional_trigger = no
				}
			}
			animation = personality_bold
		}
		triggered_animation = {
			trigger = {
				scope:new_spouse.var:spouse_court = flag:good
				scope:new_spouse = {
					has_trait = gregarious
					has_trait_introverted_trigger = no
				}
			}
			animation = laugh
		}
		animation = idle
		camera = camera_body
	}

	override_background = { reference = throne_room }

	immediate = {
		if = {
			limit = { has_character_flag = spouse_event_player_delay }
			remove_character_flag = spouse_event_player_delay
		}
		add_character_flag = { flag = spouse_event_player_delay months = 12 }
	}

	option = {
		name = lmf_spouse.101.a
		if = {
			limit = { scope:new_spouse.var:spouse_court = flag:good }
			scope:new_spouse = {
				add_character_modifier = {
					modifier = spouse_good_introduction_modifier
					years = 3
				}
			}
		}
		if = {
			limit = { scope:new_spouse.var:spouse_court = flag:bad }
			scope:new_spouse = {
				add_character_modifier = {
					modifier = spouse_bad_introduction_modifier
					years = 3
				}
			}
		}
		scope:new_spouse = {
			remove_variable = spouse_reputation
			remove_variable = spouse_remarkable
		}
	}
}

# Spouse bounce event
lmf_spouse.500 = {
	type = character_event
	hidden = yes

	trigger = {
		NOT = { has_character_flag = spouse_event_player_delay }
	}

	immediate = {
		random_list = {
			50 = {
				modifier = {
					age < 40
					add = -25
				}
				if = {
					limit = {
						is_ai = no
						NOT = { has_character_flag = lmf_spouse_second_check }
						extra_spouse_availability_trigger = no
					}
					add_character_flag = lmf_spouse_second_check
					trigger_event = { id = lmf_spouse.500 days = 120 }
				}
				else = {
					if = {
						limit = { has_variable = lmf_spouse_no_event_counter }
						change_variable = { name = lmf_spouse_no_event_counter add = 1 }
					}
					else = {
						set_variable = { name = lmf_spouse_no_event_counter value = 1 }
					}
				}
			}
			50 = {
				trigger = {
					exists = location
					primary_spouse = { exists = location }
				}
				modifier = {
					age < 40
					add = 25
				}
				modifier = {
					has_variable = lmf_spouse_no_event_counter
					add = {
						value = var:lmf_spouse_no_event_counter
						multiply = 25
					}
				}
				if = {
					limit = { has_character_flag = lmf_spouse_second_check }
					remove_character_flag = lmf_spouse_second_check
				}
				if = {
					limit = { has_variable = lmf_spouse_no_event_counter }
					remove_variable = lmf_spouse_no_event_counter
				}
				trigger_event = { on_action = lmf_spouse_events }
			}
		}
	}
}

# The bliss of having a soulmate spouse
lmf_spouse.1000 = {
	type = character_event
	title = lmf_spouse.1000.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { is_in_army = yes }
				desc = lmf_spouse.1000.desc.army
			}
			triggered_desc = {
				trigger = { is_travelling = yes }
				desc = lmf_spouse.1000.desc.travel
			}
			triggered_desc = {
				trigger = { exists = involved_activity }
				desc = lmf_spouse.1000.desc.activity
			}
			triggered_desc = {
				trigger = { is_at_same_location = primary_spouse }
				desc = lmf_spouse.1000.desc.local
			}
			desc = lmf_spouse.1000.desc.notlocal
		}
		desc = lmf_spouse.1000.desc.end
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = love
	}
	right_portrait = {
		character = root
		animation = happiness
	}
	override_background = {
		trigger = {
			is_travelling = yes
		}
		reference = terrain
	}
	override_background = {
		trigger = {
			is_travelling = no
			is_in_army = yes
		}
		reference = army_camp
	}
	override_background = {
		trigger = {
			is_travelling = no
			is_in_army = no
		}
		reference = courtyard
	}

	trigger = {
		has_relation_soulmate = primary_spouse
		NOR = {
			has_character_flag = had_lmf_spouse_1000_event
			has_character_modifier = soulmate_bliss_modifier
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			stress > normal_baseline_stress
		}
		modifier = {
			factor = 2
			stress >= high_medium_stress
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
		modifier = {
			factor = 0.5
			NOT = { stress > 0 }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1000_event years = 10 }
		add_spouse_event_variables = yes
		have_sex_if_extra_pregnancy_restrictions = { PARTNER = primary_spouse }
	}

	option = {
		name = lmf_spouse.1000.a
		stress_impact = {
			base = medium_stress_loss
		}
		add_character_modifier = {
			modifier = soulmate_bliss_modifier
			years = 5
		}
		hidden_effect = {
			move_pool_lover_to_root_location = { TARGET = primary_spouse }
		}
	}
}

# Soulmate spouse influences you to change a trait
lmf_spouse.1005 = {
	type = character_event
	title = lmf_spouse.1005.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { trait_is_sin = scope:lover_trait }
				}
				desc = lmf_spouse.1005.desc.sinful
			}
			triggered_desc = {
				trigger = {
					scope:lover_trait = { is_positive_ruler_trait = yes }
				}
				desc = lmf_spouse.1005.desc.sinful
			}
			desc = lmf_spouse.1005.desc.normal
		}
		desc = lmf_spouse.1005.desc.mid
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:lover_opposite_trait }
				desc = lmf_spouse.1005.desc.opposite
			}
			desc = lmf_spouse.1005.desc.notopp
		}
		desc = lmf_spouse.1005.desc.end
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:lover_opposite_trait }
				desc = lmf_spouse.1005.desc.opposite2
			}
			desc = lmf_spouse.1005.desc.notopp2
		}
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		triggered_animation = {
			trigger = { exists = scope:lover_opposite_trait }
			animation = disapproval
		}
		animation = debating
	}
	right_portrait = {
		character = root
		animation = thinking
	}

	trigger = {
		age > 25
		primary_spouse.age > 25
		has_relation_soulmate = primary_spouse
		primary_spouse = {
			has_personality_submissive_trigger = no
			any_character_trait = {
				has_trait_category = personality
				OR = {
					any_opposite_trait = {
						root = { has_trait = prev }
					}
					root = {
						NOT = { has_trait = prev }
						number_of_personality_traits < 4
					}
				}
			}
		}
		NOT = { has_character_flag = had_lmf_spouse_1005_event }
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 1.5
			primary_spouse = { has_trait = stubborn }
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				NOR = {
					has_personality_dominant_trigger = yes
					has_personality_extroverted_trigger = yes
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1005_event years = 10 }
		add_spouse_event_variables = yes
		move_pool_lover_to_root_location = { TARGET = primary_spouse }

		# pick out the soulmate trait to influence
		primary_spouse = {
			random_character_trait = {
				limit = {
					has_trait_category = personality
					is_positive_ruler_trait = yes
					any_opposite_trait = {
						root = { has_trait = prev }
					}
				}
				alternative_limit = {
					has_trait_category = personality
					is_positive_ruler_trait = yes
					root = {
						NOT = { has_trait = prev }
						number_of_personality_traits < 4
					}
				}
				alternative_limit = {
					has_trait_category = personality
					any_opposite_trait = {
						root = { has_trait = prev }
					}
				}
				alternative_limit = {
					has_trait_category = personality
					root = {
						NOT = { has_trait = prev }
						number_of_personality_traits < 4
					}
				}
				save_scope_as = lover_trait
			}
			# and mark if root currently has an opposite to it
			if = {
				limit = {
					scope:lover_trait = {
						any_opposite_trait = {
							root = { has_trait = prev }
						}
					}
				}
				scope:lover_trait = {
					random_opposite_trait = {
						limit = {
							root = { has_trait = prev }
						}
						save_scope_as = lover_opposite_trait
					}
				}
			}
		}
	}

	option = {
		name = lmf_spouse.1005.a # Let it happen
		if = {
			limit = { exists = scope:lover_opposite_trait }
			remove_trait_force_tooltip = scope:lover_opposite_trait
		}
		add_trait_force_tooltip = scope:lover_trait
		ai_chance = {
			base = 50
			modifier = {
				add = 100
				scope:lover_trait = { is_positive_ruler_trait = yes }
			}
			modifier = {
				add = 50
				has_trait = trusting
			}
			modifier = {
				add = 50
				has_trait = content
			}
			ai_value_modifier = {
				ai_boldness = -1
			}
			min = 1
		}
	}
	option = {
		name = lmf_spouse.1005.b # Resist their influence
		stress_impact = {
			base = minor_stress_gain
			stubborn = medium_stress_impact_loss
			paranoid = minor_stress_impact_loss
			trusting = minor_stress_impact_gain
			content = minor_stress_impact_gain
		}
		random = {
			chance = 20
			modifier = {
				add = 20
				exists = scope:lover_opposite_trait
			}
			send_interface_message = {
				type = event_generic_bad
				title = lmf_spouse.1005.b.tt
				left_icon = primary_spouse
				reverse_add_opinion = {
					target = primary_spouse
					modifier = irritated_opinion
					opinion = -10
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 100
				faith = { trait_is_sin = scope:lover_trait }
			}
			modifier = {
				add = 100
				has_trait = stubborn
			}
			modifier = {
				add = 50
				has_trait = paranoid
			}
			ai_value_modifier = {
				ai_boldness = 1
			}
			min = 0
		}
	}
}

# You influence soulmate spouse to change a trait
lmf_spouse.1010 = {
	type = character_event
	title = lmf_spouse.1010.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					faith = { trait_is_sin = scope:lover_trait }
				}
				desc = lmf_spouse.1010.desc.sinful
			}
			triggered_desc = {
				trigger = {
					scope:lover_trait = { is_positive_ruler_trait = yes }
				}
				desc = lmf_spouse.1010.desc.sinful
			}
			desc = lmf_spouse.1010.desc.normal
		}
		desc = lmf_spouse.1010.desc.mid
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:lover_opposite_trait }
				desc = lmf_spouse.1010.desc.opposite
			}
			desc = lmf_spouse.1010.desc.notopp
		}
		desc = lmf_spouse.1010.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:lover_opposite_trait }
			animation = disapproval
		}
		animation = debating
	}
	right_portrait = {
		character = primary_spouse
		animation = thinking
	}

	trigger = {
		age > 25
		primary_spouse.age > 25
		has_relation_soulmate = primary_spouse
		any_character_trait = {
			has_trait_category = personality
			OR = {
				any_opposite_trait = {
					root.primary_spouse = { has_trait = prev }
				}
				root.primary_spouse = {
					number_of_personality_traits < 4
					NOT = { has_trait = prev }
				}
			}
		}
		NOT = { has_character_flag = had_lmf_spouse_1010_event }
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 1.5
			has_trait = stubborn
		}
		modifier = {
			factor = 1.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_trait = stubborn }
		}
		modifier = {
			factor = 0.5
			NOR = {
				has_personality_dominant_trigger = yes
				has_personality_extroverted_trigger = yes
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1010_event years = 10 }
		add_spouse_event_variables = yes
		move_pool_lover_to_root_location = { TARGET = primary_spouse }

		# pick out the soulmate trait to influence
		every_character_trait = {
			limit = {
				has_trait_category = personality
				root.primary_spouse = {
					NOT = { has_trait = prev }
				}
			}
			add_to_list = trait_list
		}

		random_in_list = {
			list = trait_list
			limit = {
				OR = {
					any_opposite_trait = {
						root.primary_spouse = { has_trait = prev }
					}
					root.primary_spouse = {
						number_of_personality_traits < 4
						NOT = { has_trait = prev }
					}
				}
			}
			weight = {
				base = 5
				modifier = {
					add = -2
					primary_spouse.faith = { trait_is_sin = prev }
				}
				modifier = {
					add = 2
					is_positive_ruler_trait = yes
				}
			}
			save_scope_as = lover_trait
			# and mark if the lover currently has an opposite to it
			if = {
				limit = {
					scope:lover_trait = {
						any_opposite_trait = {
							root.primary_spouse = { has_trait = prev }
						}
					}
				}
				scope:lover_trait = {
					random_opposite_trait = {
						limit = {
							root.primary_spouse = { has_trait = prev }
						}
						save_scope_as = lover_opposite_trait
					}
				}
			}
		}
	}

	option = {
		name = lmf_spouse.1010.a
		primary_spouse = {
			if = {
				limit = { exists = scope:lover_opposite_trait }
				remove_trait_force_tooltip = scope:lover_opposite_trait
			}
			add_trait_force_tooltip = scope:lover_trait
		}
	}
}

# Lover spouse at court reveals a secret they’ve learned
lmf_spouse.1015 = {
	type = character_event
	title = lmf_spouse.1015.t
	desc = lmf_spouse.1015.desc
	theme = marriage

	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = primary_spouse
		animation = laugh
	}

	override_background = { reference = bedchamber }

	trigger = {
		primary_spouse = {
			has_relation_lover = root
			is_courtier_of = root
		}
		NOT = { has_character_flag = had_lmf_spouse_1015_event }
		standard_spouse_availability_trigger = yes

		# see if there's a secret at court to be had
		OR = {
			any_courtier = { has_secret_spouse_can_reveal_trigger = yes }
			any_councillor = { has_secret_spouse_can_reveal_trigger = yes }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 1.5
			primary_spouse.intrigue > 11
		}
		modifier = {
			factor = 1.5
			primary_spouse.intrigue > 15
		}
		modifier = {
			factor = 1.5
			primary_spouse = { has_trait = ambitious }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_trait = humble }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_trait = honest }
		}
		modifier = {
			factor = 0.5
			primary_spouse.intrigue < 8
		}
		modifier = {
			factor = 0.5
			primary_spouse.intrigue < 5
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1015_event years = 10 }
		root = { make_naked_effect = yes }
		primary_spouse = { make_naked_effect = yes }
		add_spouse_event_variables = yes

		have_sex_if_extra_pregnancy_restrictions = { PARTNER = root.primary_spouse }

		# select the secret to reveal
		every_courtier = {
			limit = { has_secret_spouse_can_reveal_trigger = yes }
			every_secret = {
				limit = {
					NOR = {
						is_known_by = root
						secret_is_incriminating_trigger = { TARGET = root }
						secret_is_incriminating_trigger = { TARGET = root.primary_spouse }
					}
					OR = {
						is_blackmailable_secret_trigger = { BLACKMAILER = root PARTICIPANT = scope:potential_courtier_secret }
						secret_is_always_interesting_trigger = yes
					}
				}
				add_to_list = lover_secret_list
			}
		}
		every_councillor = {
			limit = { has_secret_spouse_can_reveal_trigger = yes }
			every_secret = {
				limit = {
					NOR = {
						is_known_by = root
						secret_is_incriminating_trigger = { TARGET = root }
						secret_is_incriminating_trigger = { TARGET = root.primary_spouse }
					}
					OR = {
						is_blackmailable_secret_trigger = { BLACKMAILER = root PARTICIPANT = scope:potential_courtier_secret }
						secret_is_always_interesting_trigger = yes
					}
				}
				add_to_list = lover_secret_list
			}
		}
		random_in_list = {
			list = lover_secret_list
			weight = {
				base = 5
				modifier = {
					add = 50
					is_known_by = root.primary_spouse
				}
				modifier = {
					add = 20
					secret_owner = { is_of_major_interest_to_root_trigger = yes }
				}
				modifier = {
					add = 10
					secret_owner = {
						is_of_major_interest_to_root_trigger = no
						is_of_minor_interest_to_root_trigger = yes
					}
				}
				modifier = {
					add = -3
					secret_owner = { has_no_real_status_trigger = yes }
				}
				modifier = {
					add = 20
					exists = secret_target
					secret_target = root
				}
				modifier = {
					add = 10
					exists = secret_target
					secret_target = { is_of_major_interest_to_root_trigger = yes }
				}
			}
			save_scope_as = known_lover_secret
		}
	}

	option = {
		name = lmf_spouse.1015.a
		scope:known_lover_secret = {
			if = {
				limit = {
					NOT = { is_known_by = root.primary_spouse }
				}
				hidden_effect = { reveal_to = root.primary_spouse }
			}
			reveal_to_without_events_effect = { CHARACTER = root }
		}
		hidden_effect = {
			add_opinion = { modifier = grateful_opinion target = root.primary_spouse opinion = 20 }
		}
	}

	after = {
		root = { remove_naked_effect = yes }
		primary_spouse = { remove_naked_effect = yes }
	}
}

# Skilled spouse lover offers support
lmf_spouse.1020 = {
	type = character_event
	title = lmf_spouse.1020.t
	desc = {
		desc = lmf_spouse.1020.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = { highest_skill = diplomacy }
				}
				desc = lmf_spouse.1020.desc.diplomacy
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { highest_skill = martial }
				}
				desc = lmf_spouse.1020.desc.martial
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { highest_skill = stewardship }
				}
				desc = lmf_spouse.1020.desc.stewardship
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { highest_skill = intrigue }
				}
				desc = lmf_spouse.1020.desc.intrigue
			}
			desc = lmf_spouse.1020.desc.learning
		}
		desc = lmf_spouse.1020.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		character = primary_spouse
		animation = interested_left
	}

	override_background = { reference = throne_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_lover_1030_event }
		primary_spouse = {
			has_relation_lover = root
			is_courtier_of = root
			highest_skill_value >= medium_skill_rating
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_soulmate = root.primary_spouse
		}
		modifier = {
			factor = 2
			primary_spouse = { highest_skill_value >= high_skill_rating }
		}
		modifier = {
			factor = 2
			primary_spouse = { highest_skill_value >= extremely_high_skill_rating }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { highest_skill_value < decent_skill_rating }
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_lover_1030_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1020.a
		if = {
			limit = {
				primary_spouse = { highest_skill = diplomacy }
			}
			if = {
				limit = { primary_spouse.diplomacy >= 15 }
				add_character_modifier = { modifier = lover_diplomacy_help_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_diplomacy_help_small_modifier years = 5 }
			}
		}
		else_if = {
			limit = {
				primary_spouse = { highest_skill = martial }
			}
			if = {
				limit = { primary_spouse.martial >= 15 }
				add_character_modifier = { modifier = lover_martial_help_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_martial_help_small_modifier years = 5 }
			}
		}
		else_if = {
			limit = {
				primary_spouse = { highest_skill = stewardship }
			}
			if = {
				limit = { primary_spouse.stewardship >= 15 }
				add_character_modifier = { modifier = lover_stewardship_help_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_stewardship_help_small_modifier years = 5 }
			}
		}
		else_if = {
			limit = {
				primary_spouse = { highest_skill = intrigue }
			}
			if = {
				limit = { primary_spouse.intrigue >= 15 }
				add_character_modifier = { modifier = lover_intrigue_help_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_intrigue_help_small_modifier years = 5 }
			}
		}
		else = {
			if = {
				limit = { primary_spouse.learning >= 15 }
				add_character_modifier = { modifier = lover_learning_help_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_learning_help_small_modifier years = 5 }
			}
		}
	}
}

# Wealthy and generous spouse offers you a gift
lmf_spouse.1025 = {
	type = character_event
	title = lmf_spouse.1025.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						is_playable_character = yes
						exists = capital_province
						NOT = { location.county = root.location.county }
					}
				}
				desc = lmf_spouse.1025.desc.ruler
			}
			triggered_desc = {
				trigger = {
					NOT = { primary_spouse.location.county = root.location.county }
				}
				desc = lmf_spouse.1025.desc.notlocation
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { is_courtier_of = root }
				}
				desc = lmf_spouse.1025.desc.courtier
			}
			desc = lmf_spouse.1025.desc.location
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						NOT = { location.county = root.location.county }
					}
				}
				desc = lmf_spouse.1025.desc.messenger
			}
			desc = lmf_spouse.1025.desc.inperson
		}
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = happiness
	}
	right_portrait = {
		trigger = {
			primary_spouse = {
				location.county = root.location.county
			}
		}
		character = primary_spouse
		animation = admiration
	}

	override_background = { reference = bp2_courtyard }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1025_event }
		primary_spouse = {
			has_relation_lover = root
			trigger_if = {
				limit = { is_playable_character = yes }
				ai_greed < 0
			}
			trigger_else = {
				ai_greed <= -25 #no income, so they need to be VERY generous
			}
			OR = {
				is_male = yes
				has_trait = generous
			}
			opinion = { target = root value >= 50 }
			short_term_gold >= medium_gold_value
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 1.5
			gold < medium_gold_value
		}
		modifier = {
			factor = 2
			gold < 0
		}
		modifier = {
			factor = 1.5
			gold < -100
		}
		modifier = {
			factor = 1.5
			primary_spouse.ai_greed <= -80
		}
		modifier = {
			factor = 1.5
			primary_spouse = {
				is_playable_character = yes
				short_term_gold >= massive_gold_value
			}
		}
		modifier = {
			factor = 0.75
			primary_spouse.ai_greed >= -50
		}
		modifier = {
			factor = 0.5
			primary_spouse = { is_playable_character = no }
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				is_playable_character = yes
				ai_greed >= -25
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1025_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1025.a
		primary_spouse = {
			pay_short_term_gold = {
				target = root
				gold = medium_gold_value
			}
		}
		hidden_effect = {
			add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 20 }
		}
	}
}

# Spouse is in debt - should you help out?
lmf_spouse.1030 = {
	type = character_event
	title = lmf_spouse.1030.t
	desc = {
		desc = lmf_spouse.1030.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { primary_spouse = { has_trait = stubborn } }
				desc = lmf_spouse.1030.desc.stubborn
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_trait = humble } }
				desc = lmf_spouse.1030.desc.humble
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_trait = shy } }
				desc = lmf_spouse.1030.desc.shy
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_trait = craven } }
				desc = lmf_spouse.1030.desc.craven
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_trait = paranoid } }
				desc = lmf_spouse.1030.desc.paranoid
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_trait = content } }
				desc = lmf_spouse.1030.desc.content
			}
			desc = lmf_spouse.1030.desc.proud
		}
		desc = lmf_spouse.1030.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = thinking
	}
	lower_right_portrait = primary_spouse

	override_background = { reference = throne_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1030_event }
		primary_spouse = {
			is_playable_character = yes
			exists = capital_province
			gold < 0
		}
		short_term_gold >= medium_gold_value
		is_available = yes
		has_recoverable_disease_trigger = no
		primary_spouse = {
			is_incapable = no
			NOT = { is_at_war_with = root }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 1.5
			primary_spouse = { gold < -100 }
		}
		modifier = {
			factor = 0.5
			OR = {
				opinion = { target = primary_spouse value <= 0 }
				reverse_opinion = { target = primary_spouse value <= 0 }
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1030_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1030.a #Yes, of course I'll help out!
		pay_short_term_gold = {
			target = primary_spouse
			gold = medium_gold_value
		}
		reverse_add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 20 }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				who = root.primary_spouse
				ai_greed = 1
				min = 0
			}
			ai_value_modifier = {
				ai_greed = -2
				ai_compassion = 0.5
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1030.b #No, they're on their own
		if = {
			limit = { primary_spouse.ai_greed >= 25 }
			reverse_add_opinion = { target = primary_spouse modifier = disappointed_opinion opinion = -20 }
		}
		else = {
			reverse_add_opinion = { target = primary_spouse modifier = disappointed_opinion opinion = -10 }
		}
		random = {
			chance = 5
			ai_value_modifier = {
				who = root.primary_spouse
				ai_greed = 1
				ai_vengefulness = 0.5
				min = 0
				max = 95
			}
			send_interface_message = {
				type = event_generic_bad
				title = lmf_spouse.1030.b.tt
				left_icon = primary_spouse
				reverse_add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -20 }
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_greed = 1
				ai_compassion = -0.5
			}
			min = 1
		}
	}
}

scripted_effect duel_spouse_advice_skill_effect = {
	duel = {
		skill = $SKILL$
		value = 12
		60 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = 3.5
			}
			min = 5
			desc = lmf_spouse.1035.a.success
			send_interface_toast = {
				title = lmf_spouse.1035.a.success
				left_icon = root
				right_icon = root.primary_spouse
				reverse_add_opinion = { modifier = grateful_opinion target = root.primary_spouse opinion = 20 }
			}
		}
		40 = {
			compare_modifier = {
				value = scope:duel_value
				multiplier = -3.5
			}
			min = 10
			random_list = {
				30 = {
					ai_value_modifier = {
						who = root.primary_spouse
						ai_vengefulness = 0.7
						ai_rationality = -0.3
						min = -25
					}
					desc = lmf_spouse.1035.a.fail.angry
					send_interface_toast = {
						title = lmf_spouse.1035.a.fail.angry
						left_icon = root
						right_icon = root.primary_spouse
						reverse_add_opinion = { modifier = upset_opinion target = root.primary_spouse opinion = -20 }
					}
				}
				70 = {
					ai_value_modifier = {
						who = root.primary_spouse
						ai_vengefulness = -0.7
						ai_rationality = 0.3
						min = -60
					}
					desc = lmf_spouse.1035.a.fail.disappointed
					send_interface_toast = {
						title = lmf_spouse.1035.a.fail.disappointed
						left_icon = root
						right_icon = root.primary_spouse
						reverse_add_opinion = { modifier = disappointed_opinion target = root.primary_spouse opinion = -10 }
					}
				}
			}
		}
	}
}

# Spouse ruler asks for advice, if your skill is higher than theirs
lmf_spouse.1035 = {
	type = character_event
	title = lmf_spouse.1035.t
	desc = {
		desc = lmf_spouse.1035.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { scope:advice_skill = flag:diplomacy }
				desc = lmf_spouse.1035.desc.diplomacy
			}
			triggered_desc = {
				trigger = { scope:advice_skill = flag:martial }
				desc = lmf_spouse.1035.desc.martial
			}
			triggered_desc = {
				trigger = { scope:advice_skill = flag:stewardship }
				desc = lmf_spouse.1035.desc.stewardship
			}
			desc = lmf_spouse.1035.desc.intrigue
		}
		desc = lmf_spouse.1035.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = throne_room_conversation_4
	}
	right_portrait = {
		character = primary_spouse
		animation = stress
	}

	override_background = { reference = throne_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1035_event }
		primary_spouse = {
			is_playable_character = yes
			exists = capital_province
			OR = {
				diplomacy < root.diplomacy
				martial < root.martial
				stewardship < root.stewardship
				intrigue < root.intrigue
			}
			NOT = { has_relation_rival = root }
			opinion = { target = root value > 0 }
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 1.5
			primary_spouse = { has_trait = trusting }
		}
		modifier = {
			factor = 1.5
			primary_spouse = { has_trait = diligent }
		}
		modifier = {
			factor = 2
			OR = {
				AND = {
					diplomacy >= 10
					diplomacy > root.primary_spouse.diplomacy_plus_5
				}
				AND = {
					martial >= 10
					martial > root.primary_spouse.martial_plus_5
				}
				AND = {
					stewardship >= 10
					stewardship > root.primary_spouse.stewardship_plus_5
				}
				AND = {
					intrigue >= 10
					intrigue > root.primary_spouse.intrigue_plus_5
				}
			}
		}
		modifier = {
			factor = 0.5
			NOT = { has_relation_lover = primary_spouse }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_trait = lazy }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_trait = paranoid }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1035_event years = 10 }
		add_spouse_event_variables = yes

		# pick the skill that the advice is requested for
		random_list = {
			10 = {
				trigger = { diplomacy > root.primary_spouse.diplomacy }
				modifier = {
					add = {
						value = diplomacy
						subtract = root.primary_spouse.diplomacy
						multiply = 10
					}
					always = yes
				}
				modifier = {
					factor = 0.5
					diplomacy < 10
				}
				modifier = {
					factor = 2
					highest_skill = diplomacy
				}
				save_scope_value_as = { name = advice_skill value = flag:diplomacy }
			}
			10 = {
				trigger = { martial > root.primary_spouse.martial }
				modifier = {
					add = {
						value = martial
						subtract = root.primary_spouse.martial
						multiply = 10
					}
					always = yes
				}
				modifier = {
					factor = 0.5
					martial < 10
				}
				modifier = {
					factor = 2
					highest_skill = martial
				}
				save_scope_value_as = { name = advice_skill value = flag:martial }
			}
			10 = {
				trigger = { stewardship > root.primary_spouse.stewardship }
				modifier = {
					add = {
						value = stewardship
						subtract = root.primary_spouse.stewardship
						multiply = 10
					}
					always = yes
				}
				modifier = {
					factor = 0.5
					stewardship < 10
				}
				modifier = {
					factor = 2
					highest_skill = stewardship
				}
				save_scope_value_as = { name = advice_skill value = flag:stewardship }
			}
			10 = {
				trigger = { intrigue > root.primary_spouse.intrigue }
				modifier = {
					add = {
						value = intrigue
						subtract = root.primary_spouse.intrigue
						multiply = 10
					}
					always = yes
				}
				modifier = {
					factor = 0.5
					intrigue < 10
				}
				modifier = {
					factor = 2
					highest_skill = intrigue
				}
				save_scope_value_as = { name = advice_skill value = flag:intrigue }
			}
		}
	}

	option = {
		name = lmf_spouse.1035.a #Try and help them out
		if = {
			limit = { scope:advice_skill = flag:diplomacy }
			duel_spouse_advice_skill_effect = { SKILL = diplomacy }
		}
		else_if = {
			limit = { scope:advice_skill = flag:martial }
			duel_spouse_advice_skill_effect = { SKILL = martial }
		}
		else_if = {
			limit = { scope:advice_skill = flag:stewardship }
			duel_spouse_advice_skill_effect = { SKILL = stewardship }
		}
		else = {
			limit = { scope:advice_skill = flag:intrigue }
			duel_spouse_advice_skill_effect = { SKILL = intrigue }
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = arrogant
			}
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_rationality = 0.5
			}
			modifier = {
				add = 50
				OR = {
					AND = {
						scope:advice_skill = flag:diplomacy
						diplomacy > 15
					}
					AND = {
						scope:advice_skill = flag:martial
						martial > 15
					}
					AND = {
						scope:advice_skill = flag:martial
						martial > 15
					}
					AND = {
						scope:advice_skill = flag:intrigue
						intrigue > 15
					}
				}
			}
		}
	}
	option = {
		name = lmf_spouse.1035.b #Get out of it
		duel = {
			skill = intrigue
			value = root.primary_spouse
			50 = {
				ai_value_modifier = {
					who = root.primary_spouse
					ai_vengefulness = -0.5
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				compare_modifier = {
					value = diplomacy
					multiplier = 2
				}
				min = 10
				desc = lmf_spouse.1035.b.success
				send_interface_toast = {
					title = lmf_spouse.1035.b.success
					left_icon = root
					right_icon = root.primary_spouse
					reverse_add_opinion = { modifier = helpful_opinion target = root.primary_spouse opinion = 10 }
				}
			}
			50 = {
				ai_value_modifier = {
					who = root.primary_spouse
					ai_vengefulness = 0.5
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				min = 10
				desc = lmf_spouse.1035.b.fail
				send_interface_toast = {
					title = lmf_spouse.1035.b.fail
					left_icon = root
					right_icon = root.primary_spouse
					reverse_add_opinion = { modifier = upset_opinion target = root.primary_spouse opinion = -20 }
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				has_trait = humble
			}
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_rationality = -0.5
			}
			modifier = {
				add = 100
				OR = {
					AND = {
						scope:advice_skill = flag:diplomacy
						diplomacy < 10
					}
					AND = {
						scope:advice_skill = flag:martial
						martial < 10
					}
					AND = {
						scope:advice_skill = flag:martial
						martial < 10
					}
					AND = {
						scope:advice_skill = flag:intrigue
						intrigue < 10
					}
				}
			}
		}
	}
}

# Spouse gives advice, if skill higher than yours
lmf_spouse.1040 = {
	type = character_event
	title = lmf_spouse.1040.t
	desc = {
		desc = lmf_spouse.1040.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { scope:advice_skill = flag:diplomacy }
				desc = lmf_spouse.1040.desc.diplomacy
			}
			triggered_desc = {
				trigger = { scope:advice_skill = flag:martial }
				desc = lmf_spouse.1040.desc.martial
			}
			triggered_desc = {
				trigger = { scope:advice_skill = flag:stewardship }
				desc = lmf_spouse.1040.desc.stewardship
			}
			triggered_desc = {
				trigger = { scope:advice_skill = flag:intrigue }
				desc = lmf_spouse.1040.desc.intrigue
			}
			desc = lmf_spouse.1040.desc.learning
		}
		desc = lmf_spouse.1040.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = primary_spouse
		animation = debating
	}

	override_background = { reference = garden }

	trigger = {
		is_landed = yes
		NOT = { has_character_flag = had_lmf_lover_1045_event }
		primary_spouse = {
			has_relation_lover = root
			OR = {
				AND = {
					diplomacy >= 10
					diplomacy > root.diplomacy
				}
				AND = {
					martial >= 10
					martial > root.martial
				}
				AND = {
					stewardship >= 10
					stewardship > root.stewardship
				}
				AND = {
					intrigue >= 10
					intrigue > root.intrigue
				}
				AND = {
					learning >= 10
					learning > root.learning
				}
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 2
			primary_spouse = {
				OR = {
					AND = {
						diplomacy >= 10
						diplomacy >= root.diplomacy_plus_5
					}
					AND = {
						martial >= 10
						martial >= root.martial_plus_5
					}
					AND = {
						stewardship >= 10
						stewardship >= root.stewardship_plus_5
					}
					AND = {
						intrigue >= 10
						intrigue >= root.intrigue_plus_5
					}
					AND = {
						learning >= 10
						learning >= root.learning_plus_5
					}
				}
			}
		}
		modifier = {
			factor = 1.5
			primary_spouse.ai_compassion >= medium_positive_ai_value
		}
		modifier = {
			factor = 1.5
			primary_spouse.ai_compassion >= very_high_positive_ai_value
		}
		modifier = {
			factor = 0.75
			primary_spouse.ai_compassion <= low_negative_ai_value
		}
		modifier = {
			factor = 0.75
			primary_spouse.ai_compassion <= high_negative_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_lover_1045_event years = 5 }
		add_spouse_event_variables = yes
		move_pool_lover_to_root_location = { TARGET = primary_spouse }

		# pick out the skill
		random_list = {
			1 = {
				trigger = { diplomacy < primary_spouse.diplomacy }
				modifier = {
					add = {
						value = primary_spouse.diplomacy
						subtract = diplomacy
					}
					always = yes
				}
				modifier = {
					factor = 2
					primary_spouse = { highest_skill = diplomacy }
				}
				save_scope_value_as = { name = advice_skill value = flag:diplomacy }
			}
			1 = {
				trigger = { martial < primary_spouse.martial }
				modifier = {
					add = {
						value = primary_spouse.martial
						subtract = martial
					}
					always = yes
				}
				modifier = {
					factor = 2
					primary_spouse = { highest_skill = martial }
				}
				save_scope_value_as = { name = advice_skill value = flag:martial }
			}
			1 = {
				trigger = { stewardship < primary_spouse.stewardship }
				modifier = {
					add = {
						value = primary_spouse.stewardship
						subtract = stewardship
					}
					always = yes
				}
				modifier = {
					factor = 2
					primary_spouse = { highest_skill = stewardship }
				}
				save_scope_value_as = { name = advice_skill value = flag:stewardship }
			}
			1 = {
				trigger = { intrigue < primary_spouse.intrigue }
				modifier = {
					add = {
						value = primary_spouse.intrigue
						subtract = intrigue
					}
					always = yes
				}
				modifier = {
					factor = 2
					primary_spouse = { highest_skill = intrigue }
				}
				save_scope_value_as = { name = advice_skill value = flag:intrigue }
			}
			1 = {
				trigger = { learning < primary_spouse.learning }
				modifier = {
					add = {
						value = primary_spouse.learning
						subtract = learning
					}
					always = yes
				}
				modifier = {
					factor = 2
					primary_spouse = { highest_skill = learning }
				}
				save_scope_value_as = { name = advice_skill value = flag:learning }
			}
		}
	}

	option = {
		name = lmf_spouse.1040.a
		if = {
			limit = { scope:advice_skill = flag:diplomacy }
			if = {
				limit = { diplomacy_plus_5 <= primary_spouse.diplomacy }
				add_character_modifier = { modifier = lover_diplomacy_advice_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_diplomacy_advice_small_modifier years = 5 }
			}
		}
		else_if = {
			limit = { scope:advice_skill = flag:martial }
			if = {
				limit = { martial_plus_5 <= primary_spouse.martial }
				add_character_modifier = { modifier = lover_martial_advice_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_martial_advice_small_modifier years = 5 }
			}
		}
		else_if = {
			limit = { scope:advice_skill = flag:stewardship }
			if = {
				limit = { stewardship_plus_5 <= primary_spouse.stewardship }
				add_character_modifier = { modifier = lover_stewardship_advice_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_stewardship_advice_small_modifier years = 5 }
			}
		}
		else_if = {
			limit = { scope:advice_skill = flag:intrigue }
			if = {
				limit = { intrigue_plus_5 <= primary_spouse.intrigue }
				add_character_modifier = { modifier = lover_intrigue_advice_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_intrigue_advice_small_modifier years = 5 }
			}
		}
		else_if = {
			limit = { scope:advice_skill = flag:learning }
			if = {
				limit = { learning_plus_5 <= primary_spouse.learning }
				add_character_modifier = { modifier = lover_learning_advice_modifier years = 5 }
			}
			else = {
				add_character_modifier = { modifier = lover_learning_advice_small_modifier years = 5 }
			}
		}
	}
}

# Lover looks after you while you’re sick
lmf_spouse.1045 = {
	type = character_event
	title = lmf_spouse.1045.t
	desc = {
		desc = lmf_spouse.1045.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						location.county = root.location.county
					}
				}
				desc = lmf_spouse.1045.desc.location
			}
			triggered_desc = {
				trigger = {
					primary_spouse = {
						is_playable_character = yes
						exists = capital_province
					}
				}
				desc = lmf_spouse.1045.desc.ruler
			}
			desc = lmf_spouse.1045.desc.notlocation
		}
		desc = lmf_spouse.1045.desc.mid
	}
	theme = marriage

	right_portrait = {
		character = root
		animation = sick
	}
	left_portrait = {
		character = primary_spouse
		animation = admiration
	}

	override_background = { reference = bedchamber }

	trigger = {
		NOR = {
			has_character_flag = had_lmf_spouse_1045_event
			has_character_modifier = lover_nurses_me_modifier
			has_character_modifier = physician_lover_nurses_me_modifier
			has_character_modifier = councillor_spouse_health_modifier
		}
		has_recoverable_disease_trigger = yes
		is_travelling = no
		is_in_army = no
		is_imprisoned = no
		is_incapable = no
		NOR = {
			exists = involved_activity
			has_variable = homage_liege_scope
			has_character_flag = meditation_character_flag
			has_character_flag = petition_liege_character_flag
			has_character_flag = holding_court_character_flag
			is_being_visited_on_tour_strict = yes
			has_character_flag = planning_an_activity
		}
		primary_spouse = {
			ai_compassion >= 25
			ai_boldness >= 0
			has_relation_lover = root
			is_available = yes
			has_recoverable_disease_trigger = no
			trigger_if = {
				limit = { is_playable_character = yes }
				NOT = { is_at_war_with = root }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = {
				learning > 10
				NOT = { has_trait = blind }
				OR = {
					has_trait = lifestyle_physician
					has_trait = lifestyle_mystic
					has_trait = lifestyle_herbalist
				}
			}
		}
		modifier = {
			factor = 2
			has_contagious_deadly_disease_trigger = yes
		}
		modifier = {
			factor = 1.5
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 1.5
			primary_spouse.ai_compassion >= high_positive_ai_value
		}
		modifier = {
			factor = 1.5
			primary_spouse.ai_compassion >= very_high_positive_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_trait = paranoid }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_trait = craven }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1045_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1045.a #Submit to her ministrations
		if = {
			limit = {
				primary_spouse = {
					learning > 10
					NOT = { has_trait = blind }
					OR = {
						has_trait = lifestyle_physician
						has_trait = lifestyle_mystic
						has_trait = lifestyle_herbalist
					}
				}
			}
			add_character_modifier = {
				modifier = physician_lover_nurses_me_modifier
				years = 2
			}
		}
		else = {
			add_character_modifier = {
				modifier = lover_nurses_me_modifier
				years = 2
			}
		}
		if = {
			limit = {
				OR = {
					AND = {
						has_trait = bubonic_plague
						primary_spouse = { can_contract_disease_trigger = { DISEASE = bubonic_plague } }
					}
					AND = {
						has_trait = smallpox
						primary_spouse = { can_contract_disease_trigger = { DISEASE = smallpox } }
					}
					AND = {
						has_trait = typhus
						primary_spouse = { can_contract_disease_trigger = { DISEASE = typhus } }
					}
					AND = {
						has_trait = consumption
						primary_spouse = { can_contract_disease_trigger = { DISEASE = consumption } }
					}
					AND = {
						has_trait = measles
						primary_spouse = { can_contract_disease_trigger = { DISEASE = measles } }
					}
					AND = {
						has_trait = dysentery
						primary_spouse = { can_contract_disease_trigger = { DISEASE = dysentery } }
					}
				}
			}
			random = {
				chance = 50
				if = {
					limit = { has_trait = bubonic_plague }
					primary_spouse = {
						contract_disease_effect = { DISEASE = bubonic_plague TREATMENT_EVENT = yes }
					}
				}
				else_if = {
					limit = { has_trait = smallpox }
					primary_spouse = {
						contract_disease_effect = { DISEASE = smallpox TREATMENT_EVENT = yes }
					}
				}
				else_if = {
					limit = { has_trait = typhus }
					primary_spouse = {
						contract_disease_effect = { DISEASE = typhus TREATMENT_EVENT = yes }
					}
				}
				else_if = {
					limit = { has_trait = consumption }
					primary_spouse = {
						contract_disease_effect = { DISEASE = consumption TREATMENT_EVENT = yes }
					}
				}
				else_if = {
					limit = { has_trait = measles }
					primary_spouse = {
						contract_disease_effect = { DISEASE = measles TREATMENT_EVENT = yes }
					}
				}
				else = {
					primary_spouse = {
						contract_disease_effect = { DISEASE = dysentery TREATMENT_EVENT = yes }
					}
				}
			}
		}
		else = {
			random = {
				chance = 25
				primary_spouse = {
					contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
				}
			}
		}
	}

	after = {
		move_pool_lover_to_root_location = { TARGET = primary_spouse }
	}
}

# Lover spouse learns a secret of yours
lmf_spouse.1050 = {
	type = character_event
	title = lmf_spouse.1050.t
	desc = lmf_spouse.1050.desc
	theme = marriage

	left_portrait = {
		character = root.primary_spouse
		triggered_animation = {
			trigger = { exists = scope:lover_upset }
			animation = shock
		}
		animation = eavesdrop
	}

	override_background = { reference = bedchamber }

	trigger = {
		has_relation_lover = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1050_event }
		intrigue <= primary_spouse.intrigue
		has_any_secrets = yes
		any_secret = {
			is_blackmailable_secret_trigger = { BLACKMAILER = root.primary_spouse PARTICIPANT = root }
			NOR = {
				is_known_by = root.primary_spouse
				secret_is_incriminating_trigger = { TARGET = root.primary_spouse }
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			intrigue_plus_5 <= primary_spouse.intrigue
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1050_event years = 10 }
		add_spouse_event_variables = yes
		move_pool_lover_to_root_location = { TARGET = root.primary_spouse }

		# pick out secret to reveal
		random_secret = {
			limit = {
				is_blackmailable_secret_trigger = { BLACKMAILER = root.primary_spouse PARTICIPANT = root }
				NOR = {
					is_known_by = root.primary_spouse
					secret_is_incriminating_trigger = { TARGET = root.primary_spouse }
				}
			}
			save_scope_as = secret
			reveal_to = root.primary_spouse
		}

		# see if it's a secret that would upset the lover
		if = {
			limit = {
				scope:secret = {
					OR = {
						secret_type = secret_lover
						AND = {
							secret_type = secret_deviant
							root.primary_spouse = { has_negative_attitude_towards_trait_trigger = { TRAIT = trait:deviant GENDER_CHARACTER = root } }
						}
						AND = {
							secret_type = secret_incest
							root.primary_spouse = { has_negative_attitude_towards_trait_trigger = { TRAIT = trait:incestuous GENDER_CHARACTER = root } }
						}
						AND = {
							secret_type = secret_witch
							root.primary_spouse = { has_negative_attitude_towards_trait_trigger = { TRAIT = trait:witch GENDER_CHARACTER = root } }
						}
						AND = {
							secret_type = secret_cannibal
							root.primary_spouse = { has_negative_attitude_towards_trait_trigger = { TRAIT = trait:cannibal GENDER_CHARACTER = root } }
						}
						AND = {
							secret_type = secret_homosexual
							root.primary_spouse = {
								is_female = yes
								has_negative_attitude_towards_trait_trigger = { TRAIT = trait:sodomite GENDER_CHARACTER = root }
							}
						}
						secret_target = {
							save_temporary_scope_as = target_check
							OR = {
								this = root.primary_spouse
								root.primary_spouse = {
									any_close_or_extended_family_member = {
										even_if_dead = yes
										this = scope:target_check
									}
								}
								root.primary_spouse = {
									any_spouse = {
										even_if_dead = yes
										this = scope:target_check
									}
								}
							}
						}
					}
				}
			}
			save_scope_value_as = { name = lover_upset value = yes }
			worsen_relationship_effect = {
				TARGET = root.primary_spouse
				REASON = learned_terrible_secret
			}
		}
	}

	option = {
		name = lmf_spouse.1050.a # There's nothing to be done, now
		stress_impact = {
			base = major_stress_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.5
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1050.b # Promise her anything in return for her silence
		trigger = {
			primary_spouse = {
				can_add_hook = {
					target = root
					type = favor_hook
				}
			}
			scope:secret = {
				NOR = {
					secret_type = secret_lover
					secret_target = root.primary_spouse
				}
			}
		}
		stress_impact = {
			arrogant = medium_stress_impact_gain
			ambitious = minor_stress_impact_gain
			paranoid = medium_stress_impact_gain
			craven = minor_stress_impact_loss
		}
		custom_tooltip = spouse_promise_to_keep_secret
		primary_spouse = {
			add_hook = {
				target = root
				type = favor_hook
			}
		}
		scope:secret = {
			set_variable = {
				name = promised_not_to_reveal
				value = root.primary_spouse
			}
		}
		ai_chance = {
			base = 40
		}
	}
	option = {
		name = lmf_spouse.1050.c # She'll be silent if she's in a cell!
		trigger = {
			primary_spouse = {
				is_courtier_of = root
			}
			scope:secret = {
				NOR = {
					secret_type = secret_lover
					secret_target = root.primary_spouse
				}
			}
		}
		stress_impact = {
			base = medium_stress_impact_gain
			arrogant = minor_stress_impact_loss
			paranoid = minor_stress_impact_loss
			forgiving = medium_stress_impact_gain
			trusting = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		custom_tooltip = spouse_jailed_to_keep_secret
		lover_breakup_effect = { BREAKER = root LOVER = root.primary_spouse }
		imprison_character_effect = {
			TARGET = root.primary_spouse
			IMPRISONER = root
		}
		scope:secret = {
			set_variable = {
				name = promised_not_to_reveal
				value = root.primary_spouse
			}
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_vengefulness = 1
			}
			modifier = {
				factor = 0
				NOR = {
					has_personality_malicious_trigger = yes
					has_trait = lunatic
				}
			}
			min = 0
		}
	}
}

# You learn a lover spouse's secret
lmf_spouse.1055 = {
	type = character_event
	title = lmf_spouse.1055.t
	desc = lmf_spouse.1055.desc
	theme = marriage

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { exists = scope:lover_upset }
			animation = shock
		}
		animation = disappointed
	}
	right_portrait = {
		character = primary_spouse
		animation = shame
	}

	override_background = { reference = bedchamber }

	trigger = {
		has_relation_lover = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1055_event }
		intrigue >= primary_spouse.intrigue
		primary_spouse = {
			has_any_secrets = yes
			any_secret = {
				is_blackmailable_secret_trigger = { BLACKMAILER = root PARTICIPANT = root.primary_spouse }
				NOR = {
					is_known_by = root
					secret_is_incriminating_trigger = { TARGET = root }
				}
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			intrigue >= root.primary_spouse.intrigue_plus_5
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1055_event years = 10 }
		add_spouse_event_variables = yes
		move_pool_lover_to_root_location = { TARGET = root.primary_spouse }

		# pick out secret to reveal
		primary_spouse = {
			random_secret = {
				limit = {
					is_blackmailable_secret_trigger = { BLACKMAILER = root PARTICIPANT = root.primary_spouse }
					NOR = {
						is_known_by = root
						secret_is_incriminating_trigger = { TARGET = root }
					}
				}
				save_scope_as = secret
			}
		}

		# see if it's a secret that should upset you
		if = {
			limit = {
				scope:secret = {
					OR = {
						secret_type = secret_lover
						AND = {
							secret_type = secret_deviant
							root = { has_negative_attitude_towards_trait_trigger = { TRAIT = trait:deviant GENDER_CHARACTER = root.primary_spouse } }
						}
						AND = {
							secret_type = secret_incest
							root = { has_negative_attitude_towards_trait_trigger = { TRAIT = trait:incestuous GENDER_CHARACTER = root.primary_spouse } }
						}
						AND = {
							secret_type = secret_witch
							root = { has_negative_attitude_towards_trait_trigger = { TRAIT = trait:witch GENDER_CHARACTER = root.primary_spouse } }
						}
						AND = {
							secret_type = secret_cannibal
							root = { has_negative_attitude_towards_trait_trigger = { TRAIT = trait:cannibal GENDER_CHARACTER = root.primary_spouse } }
						}
						AND = {
							secret_type = secret_homosexual
							root = {
								is_female = yes
								has_negative_attitude_towards_trait_trigger = { TRAIT = trait:sodomite GENDER_CHARACTER = root.primary_spouse }
							}
						}
						secret_target = {
							save_temporary_scope_as = target_check
							OR = {
								this = root
								root = {
									any_close_or_extended_family_member = {
										even_if_dead = yes
										this = scope:target_check
									}
								}
								root = {
									any_spouse = {
										even_if_dead = yes
										this = scope:target_check
									}
								}
							}
						}
					}
				}
			}
			save_scope_value_as = { name = lover_upset value = yes }
		}
	}

	option = {
		name = lmf_spouse.1055.a
		scope:secret = { reveal_to_without_events_effect = { CHARACTER = root } }
		if = {
			limit = { exists = scope:lover_upset }
			primary_spouse = {
				worsen_relationship_effect = {
					TARGET = root
					REASON = learned_terrible_secret
				}
			}
		}
	}
}

# Lover spouse writes to you while you're far away
lmf_spouse.1060 = {
	type = letter_event
	opening = lmf_spouse.1060.opening
	desc = {
		desc = lmf_spouse.1060.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { is_in_army = yes }
				desc = lmf_spouse.1060.desc.army
			}
			triggered_desc = {
				trigger = { is_travelling = yes }
				desc = lmf_spouse.1060.desc.travel
			}
			desc = lmf_spouse.1060.desc.event
		}
		desc = lmf_spouse.1060.desc.end
	}
	sender = {
		character = root.primary_spouse
		animation = love
	}

	trigger = {
		has_relation_lover = primary_spouse
		NOT = { has_character_flag = had_lmf_lover_1080_event }
		exists = capital_province
		OR = {
			is_travelling = yes
			is_in_army = yes
			exists = involved_activity
		}
		is_incapable = no
		is_imprisoned = no
		primary_spouse = {
			learning > 4 #knows how to write a letter
			is_available = yes
			has_recoverable_disease_trigger = no
			is_courtier_of = root
			location = {
				squared_distance = { target = root.location value > 300000 }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_lover_1080_event years = 10 }
		add_spouse_event_variables = yes
		location.duchy = { save_scope_as = my_camp }
	}

	option = {
		name = lmf_spouse.1060.a
		stress_impact = {
			base = medium_stress_loss
		}
		reverse_add_opinion = { target = root.primary_spouse modifier = romantic_gesture_opinion }
		hidden_effect = {
			add_opinion = { target = root.primary_spouse modifier = romantic_gesture_opinion  }
		}
	}
}

# Lover spouse writes to you while you're imprisoned
lmf_spouse.1065 = {
	type = letter_event
	opening = lmf_spouse.1065.opening
	desc = lmf_spouse.1065.desc
	sender = {
		character = primary_spouse
		animation = love
	}

	trigger = {
		has_relation_lover = primary_spouse
		is_imprisoned = yes
		time_in_prison = { weeks >= 2 }
		NOR = {
			has_character_flag = had_lmf_lover_1090_event
			is_imprisoned_by = primary_spouse
		}
		exists = capital_province
		is_incapable = no
		primary_spouse = {
			learning > 4 #knows how to write a letter
			is_available = yes
			has_recoverable_disease_trigger = no
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_lover_1090_event years = 10 }
		add_spouse_event_variables = yes
		imprisoner = { save_scope_as = my_imprisoner }
	}

	option = {
		name = lmf_spouse.1065.a
		stress_impact = {
			base = medium_stress_loss
		}
		reverse_add_opinion = { target = root.primary_spouse modifier = romantic_gesture_opinion }
		hidden_effect = {
			add_opinion = { target = root.primary_spouse modifier = romantic_gesture_opinion  }
		}
	}
}

# Greedy spouse demands an expensive gift
lmf_spouse.1070 = {
	type = character_event
	title = lmf_spouse.1070.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { has_relation_lover = primary_spouse }
				desc = lmf_spouse.1070.desc.start.lover
			}
			desc = lmf_spouse.1070.desc.start.notlover
		}
		desc = lmf_spouse.1070.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root.primary_spouse }
						has_education_martial_trigger = yes
					}
				}
				desc = lmf_spouse.1070.desc.sword
			}
			triggered_desc = {
				trigger = {
					primary_spouse = {
						OR = {
							has_education_learning_trigger = yes
							is_clergy = yes
							has_council_position = councillor_court_chaplain
						}
					}
				}
				desc = lmf_spouse.1070.desc.book
			}
			triggered_desc = {
				trigger = {
					primary_spouse = {
						has_education_intrigue_trigger = yes
						learning >= 8
					}
				}
				desc = lmf_spouse.1070.desc.manuals
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { is_male = yes }
				}
				desc = lmf_spouse.1070.desc.robe
			}
			desc = lmf_spouse.1070.desc.jewelry
		}
		desc = lmf_spouse.1070.desc.end
		first_valid = {
			triggered_desc = {
				trigger = { has_relation_lover = primary_spouse }
				desc = lmf_spouse.1070.desc.end.lover
			}
			desc = lmf_spouse.1070.desc.end.notlover
		}
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = primary_spouse
		animation = interested_left
	}

	override_background = {
		trigger = { has_relation_lover = primary_spouse }
		reference = bedchamber
	}
	override_background = {
		trigger = { NOT = { has_relation_lover = primary_spouse } }
		reference = sitting_room
	}

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1070_event }
		primary_spouse.ai_greed >= high_positive_ai_value
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse.ai_boldness >= high_positive_ai_value
		}
		modifier = {
			factor = 2
			primary_spouse.ai_greed >= 100
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_honor >= low_positive_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_trait_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse.gold >= root.minor_gold_value
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				is_playable_character = yes
				highest_held_title_tier >= tier_duchy
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1070_event years = 10 }
		add_spouse_event_variables = yes
		move_pool_lover_to_root_location = { TARGET = primary_spouse }
		if = {
			limit = { has_relation_lover = primary_spouse }
			root = { make_naked_effect = yes }
			primary_spouse = { make_naked_effect = yes }
		}
	}

	option = {
		name = lmf_spouse.1070.a #Wow her with something amazing
		trigger = {
			OR = {
				has_trait = generous
				has_trait = compassionate
			}
		}
		show_as_unavailable = {
			NOR = {
				has_trait = generous
				has_trait = compassionate
			}
		}
		remove_short_term_gold = major_gold_value
		reverse_add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 20 }
		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_greed = -1
				ai_compassion = 0.5
			}
			modifier = {
				factor = 0.1
				short_term_gold < major_gold_value
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1070.b #Give in and get it for her
		remove_short_term_gold = medium_gold_value
		reverse_add_opinion = { target = primary_spouse modifier = pleased_opinion opinion = 10 }
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_greed = -1
				ai_compassion = 0.5
			}
			modifier = {
				factor = 0.5
				short_term_gold < medium_gold_value
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1070.c #Is she joking? Absolutely not!
		reverse_add_opinion = { target = primary_spouse modifier = disappointed_opinion opinion = -20 }
		ai_chance = {
			base = 50
			modifier = {
				add = -20
				has_trait = generous
			}
			ai_value_modifier = {
				ai_greed = 1
				ai_compassion = -0.5
			}
			modifier = {
				factor = 2
				short_term_gold < medium_gold_value
			}
			modifier = {
				factor = 2
				gold < 0
			}
			min = 1
		}
	}

	after = {
		if = {
			limit = { has_relation_lover = primary_spouse }
			root = { remove_naked_effect = yes }
			primary_spouse = { remove_naked_effect = yes }
		}
	}
}

# Spouse demands that you do something about courtier insult
lmf_spouse.1075 = {
	type = character_event
	title = lmf_spouse.1075.t
	desc = {
		desc = lmf_spouse.1075.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:my_courtier = {
						has_any_court_relationship_with = { CHARACTER = root }
					}
				}
				desc = lmf_spouse.1075.desc.relation
			}
			desc = lmf_spouse.1075.desc.norelation
		}
		desc = lmf_spouse.1075.desc.end
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = { has_dynasty = no }
					scope:my_courtier = {
						OR = {
							has_trait = arrogant
							has_personality_malicious_trigger = yes
						}
					}
				}
				desc = lmf_spouse.1075.desc.commoner
			}
			triggered_desc = {
				trigger = {
					scope:my_courtier = { has_relation_rival = root.primary_spouse }
				}
				desc = lmf_spouse.1075.desc.rival
			}
			desc = lmf_spouse.1075.desc.temper
		}
		desc = lmf_spouse.1075.desc.end2
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = primary_spouse
		animation = rage
	}
	lower_right_portrait = scope:my_courtier

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1075_event }
		primary_spouse = {
			is_courtier_of = root
			has_personality_benevolent_trigger = no
		}
		standard_spouse_availability_trigger = yes
		any_courtier = {
			is_adult = yes
			ai_compassion <= 0
			opinion = { target = root.primary_spouse value < 0 }
			is_available_ai = yes
			has_recoverable_disease_trigger = no
			has_no_real_status_trigger = no
			has_trait_submissive_trigger = no
			OR = {
				AND = {
					root.primary_spouse = { has_dynasty = no }
					OR = {
						has_trait = arrogant
						has_personality_malicious_trigger = yes
					}
				}
				has_relation_rival = root.primary_spouse
				is_hot_headed_trigger = yes
			}
			NOR = {
				this = root.primary_spouse
				is_consort_of = root
				is_consort_of = root.primary_spouse
				is_close_or_extended_family_of = root
				is_close_or_extended_family_of = root.primary_spouse
				is_councillor_of = root
				has_friendly_relationship_trigger = { CHARACTER = root.primary_spouse }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = { has_personality_malicious_trigger = yes }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_annoying_trigger = yes }
		}
		modifier = {
			factor = 2
			has_personality_submissive_trigger = yes
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1075_event years = 10 }
		add_spouse_event_variables = yes

		random_courtier = {
			limit = {
				is_adult = yes
				ai_compassion <= 0
				opinion = { target = root.primary_spouse value < 0 }
				is_available_ai = yes
				has_recoverable_disease_trigger = no
				has_no_real_status_trigger = no
				has_trait_submissive_trigger = no
				OR = {
					AND = {
						root.primary_spouse = { has_dynasty = no }
						OR = {
							has_trait = arrogant
							has_personality_malicious_trigger = yes
						}
					}
					has_relation_rival = root.primary_spouse
					is_hot_headed_trigger = yes
				}
				NOR = {
					this = root.primary_spouse
					is_consort_of = root
					is_consort_of = root.primary_spouse
					is_close_family_of = root
					is_close_family_of = root.primary_spouse
					is_councillor_of = root
					has_friendly_relationship_trigger = { CHARACTER = root.primary_spouse }
				}
			}
			weight = {
				base = 5
				modifier = {
					add = 5
					opinion = { target = root.primary_spouse value <= -25 }
				}
				modifier = {
					add = 5
					opinion = { target = root.primary_spouse value <= -50 }
				}
				modifier = {
					add = 2
					ai_compassion <= -20
				}
				modifier = {
					add = 2
					ai_compassion <= -50
				}
				modifier = {
					add = 2
					ai_compassion <= -75
				}
				modifier = {
					add = 2
					ai_boldness >= 20
				}
				modifier = {
					add = 10
					has_relation_potential_rival = root.primary_spouse
				}
				modifier = {
					add = 5
					has_friendly_relationship_trigger = { CHARACTER = root }
				}
				modifier = {
					add = 50
					has_relation_rival = root.primary_spouse
				}
				modifier = {
					factor = 0.5
					OR = {
						age > root.primary_spouse.age_plus_10
						age > 50
						sum_of_all_skills_value < 25
					}
				}
			}
			save_scope_as = my_courtier
			add_opinion = { target = root.primary_spouse modifier = disrespect_opinion opinion = -20 }
			reverse_add_opinion = { target = root.primary_spouse modifier = insult_opinion opinion = -20 }
		}
	}

	option = {
		name = lmf_spouse.1075.a #I will send them away
		trigger = {
			scope:my_courtier = {
				bp2_valid_for_standard_interactions_trigger = yes
				NOT = {
					any_traveling_family_member = { lover_kick_from_court_validity_trigger = no }
				}
			}
		}
		stress_impact = {
			just = medium_stress_impact_gain
			gregarious = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
			arbitrary = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
		}
		if = {
			limit = { is_landless_adventurer = yes }
			add_prestige = minor_prestige_loss
		}
		else_if = {
			limit = {
				scope:my_courtier = {
					any_traveling_family_member = {
						count = all
						is_lowborn = yes
					}
				}
			}
			add_prestige = minor_prestige_loss
		}
		else = {
			add_prestige = medium_prestige_loss
		}

		reverse_add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 20 }
		if = {
			limit = {
				scope:my_courtier = {
					can_set_relation_rival_trigger = { CHARACTER = root.primary_spouse }
				}
			}
			scope:my_courtier = {
				set_relation_rival = {
					target = root.primary_spouse
					reason = got_me_kicked_from_court
				}
			}
		}

		kick_out_courtier_effect = { KICKED = scope:my_courtier KICKER = root }

		ai_chance = {
			base = 30
			opinion_modifier = {
				who = root
				opinion_target = scope:my_courtier
				multiplier = -0.50
			}
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_vengefulness = 1
			}
			modifier = {
				factor = 0.5
				scope:my_courtier = {
					OR = {
						is_knight_of = root
						has_any_court_position = yes
						dynasty != root.dynasty
					}
				}
			}
			modifier = {
				factor = 0
				scope:my_courtier = {
					any_traveling_family_member = {
						NOT = { this = scope:my_courtier }
						OR = {
							is_councillor_of = root
							has_friendly_relationship_trigger = { CHARACTER = root }
							is_close_or_extended_family_of = root
						}
					}
				}
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1075.b #I will severely reprimand them
		stress_impact = {
			base = minor_stress_gain
			forgiving = minor_stress_impact_gain
			shy = minor_stress_impact_gain
			just = minor_stress_impact_gain
			arbitrary = minor_stress_impact_loss
			vengeful = minor_stress_impact_loss
			sadistic = minor_stress_impact_loss
		}
		reverse_add_opinion = { target = primary_spouse modifier = pleased_opinion opinion = 10 }
		duel = {
			skill = diplomacy
			target = scope:my_courtier
			60 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 1.5
				}
				min = 10
				desc = lmf_spouse.1075.b.success
				send_interface_toast = {
					title = lmf_spouse.1075.b.success
					left_icon = root
					right_icon = scope:my_courtier
					scope:my_courtier = {
						add_opinion = { target = root modifier = frustrated_opinion opinion = -10 }
						remove_opinion = { target = root.primary_spouse modifier = disrespect_opinion }
					}
				}
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				min = 5
				desc = lmf_spouse.1075.b.failure
				send_interface_toast = {
					title = lmf_spouse.1075.b.failure
					left_icon = root
					right_icon = scope:my_courtier
					if = {
						limit = {
							scope:my_courtier = {
								can_set_relation_rival_trigger = { CHARACTER = root.primary_spouse }
							}
						}
						scope:my_courtier = {
							set_relation_rival = {
								target = root.primary_spouse
								reason = got_me_reprimanded_unjustly
							}
						}
					}
					scope:my_courtier = {
						worsen_relationship_effect = {
							TARGET = root
							REASON = reprimanded_me_unjustly_spouse
						}
					}
				}
			}
		}
		ai_chance = {
			base = 30
			opinion_modifier = {
				who = root
				opinion_target = scope:my_courtier
				multiplier = -0.20
			}
			ai_value_modifier = {
				ai_vengefulness = 1
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1075.c #She will have to put up with it
		stress_impact = {
			forgiving = minor_stress_impact_loss
			vengeful = minor_stress_impact_gain
		}
		reverse_add_opinion = { target = primary_spouse modifier = upset_opinion opinion = -20 }
		primary_spouse = {
			worsen_relationship_effect = {
				TARGET = scope:my_courtier
				REASON = insulted_lover
			}
		}
		ai_chance = {
			base = 40
			opinion_modifier = {
				who = root
				opinion_target = scope:my_courtier
				multiplier = 0.50
			}
			modifier = {
				add = -30
				has_personality_submissive_trigger = yes
			}
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.5
				ai_vengefulness = -1
			}
			min = 1
		}
	}
}

# Needy spouse proves to be a distraction
lmf_spouse.1080 = {
	type = character_event
	title = lmf_spouse.1080.t
	desc = lmf_spouse.1080.desc
	theme = marriage

	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = primary_spouse
		animation = admiration
	}

	override_background = { reference = garden }

	trigger = {
		has_relation_lover = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1080_event }
		primary_spouse = {
			is_courtier_of = root
			ai_sociability >= 0
			ai_energy >= 0
			age < 40
			NOR = {
				has_any_court_position = yes
				num_of_relation_ward > 0
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 1.5
			primary_spouse.ai_sociability >= 50
		}
		modifier = {
			factor = 1.5
			primary_spouse.ai_energy >= 50
		}
		modifier = {
			factor = 2
			primary_spouse = { has_trait = lustful }
		}
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_trait = chaste }
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1080_event years = 10 }
		add_spouse_event_variables = yes
		move_pool_lover_to_root_location = { TARGET = primary_spouse }
	}

	option = {
		name = lmf_spouse.1080.a #I'm fine with being distracted
		stress_impact = {
			base = medium_stress_loss
			lustful = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
			chaste = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
		}
		reverse_add_opinion = { target = primary_spouse modifier = pleased_opinion opinion = 20 }
		add_character_modifier = {
			modifier = lover_distraction_modifier
			years = 3
		}
		have_sex_if_extra_pregnancy_restrictions = { PARTNER = root.primary_spouse }
		ai_chance = {
			base = 50
			modifier = {
				add = 100
				has_trait = lustful
			}
			modifier = {
				add = 50
				has_trait = lazy
			}
			modifier = {
				add = 50
				has_relation_soulmate = primary_spouse
			}
			modifier = {
				add = 50
				stress > normal_baseline_stress
			}
			modifier = {
				add = 50
				stress >= high_medium_stress
			}
			ai_value_modifier = {
				ai_compassion = -1
			}
			min = 1
		}
	}
	option = {
		name = lmf_spouse.1080.b #I need to focus on my duties
		stress_impact = {
			lustful = minor_stress_impact_gain
			lazy = minor_stress_impact_gain
			chaste = minor_stress_impact_loss
			diligent = minor_stress_impact_loss
		}
		reverse_add_opinion = { target = primary_spouse modifier = disappointed_opinion opinion = -20 }
		ai_chance = {
			base = 50
			modifier = {
				add = 100
				has_trait = chaste
			}
			modifier = {
				add = 50
				has_trait = diligent
			}
			modifier = {
				add = 50
				stress = 0
			}
			ai_value_modifier = {
				ai_compassion = 1
			}
			min = 0
		}
	}
}

# Spending the day with spouse lover
lmf_spouse.1085 = {
	type = character_event
	title = lmf_spouse.1085.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = { is_courtier_of = root }
				}
				desc = lmf_spouse.1085.desc.courtier
			}
			desc = lmf_spouse.1085.desc.ruler
		}
		desc = lmf_spouse.1085.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = { is_courtier_of = root }
				}
				desc = lmf_spouse.1085.mid.courtier
			}
			desc = lmf_spouse.1085.mid.ruler
		}
		desc = lmf_spouse.1085.desc.mid
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = primary_spouse
		animation = laugh
	}

	override_background = { reference = garden }

	trigger = {
		has_relation_lover = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1085_event }
		primary_spouse = {
			OR = {
				is_courtier_of = root
				is_playable_character = yes
			}
		}
		stress > 0
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			stress > normal_baseline_stress
		}
		modifier = {
			factor = 2
			stress >= high_medium_stress
		}
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			stress <= low_stress
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_compassion <= high_negative_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_energy <= high_negative_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_energy <= -100
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
		modifier = {
			factor = 0.5
			NOT = { stress > 0 }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1085_event years = 10 }
		add_spouse_event_variables = yes
		root = { make_naked_effect = yes }
		primary_spouse = { make_naked_effect = yes }
	}

	option = {
		name = lmf_spouse.1085.a
		had_sex_with_effect = { CHARACTER = primary_spouse PREGNANCY_CHANCE = pregnancy_chance }
		if = {
			limit = { has_relation_soulmate = primary_spouse }
			stress_impact = { base = massive_stress_loss }
			primary_spouse = {
				stress_impact = { base = massive_stress_loss }
			}
		}
		else = {
			stress_impact = { base = major_stress_loss }
			primary_spouse = {
				stress_impact = { base = major_stress_loss }
			}
		}
	}

	after = {
		root = { remove_naked_effect = yes }
		primary_spouse = { remove_naked_effect = yes }
	}
}

# Spouse comes to you when the army camps
lmf_spouse.1090 = {
	type = character_event
	title = lmf_spouse.1090.t
	desc = lmf_spouse.1090.desc
	theme = marriage

	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = primary_spouse
		animation = laugh
	}

	override_background = { reference = army_camp }

	trigger = {
		has_relation_lover = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1090_event }
		is_in_same_army_location_as = { CHARACTER = root.primary_spouse }
		stress > 0
		is_physically_able = yes
		has_recoverable_disease_trigger = no
		exists = location
		location = { is_sea_province = no }
		primary_spouse = {
			is_physically_able = yes
			has_recoverable_disease_trigger = no
			can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			stress > normal_baseline_stress
		}
		modifier = {
			factor = 2
			stress >= high_medium_stress
		}
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			stress <= low_stress
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_compassion <= high_negative_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_energy <= high_negative_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_energy <= -100
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1090_event years = 10 }
		add_spouse_event_variables = yes
		root = { make_naked_effect = yes }
		primary_spouse = { make_naked_effect = yes }
		if = {
			limit = { exists = commanding_army }
			commanding_army = { save_scope_as = army }
		}
		else = {
			knight_army = { save_scope_as = army }
		}
		scope:army.location = { save_scope_as = army_location }
	}

	option = {
		name = lmf_spouse.1090.a
		had_sex_with_effect = { CHARACTER = primary_spouse PREGNANCY_CHANCE = pregnancy_chance }
		if = {
			limit = { has_relation_soulmate = primary_spouse }
			stress_impact = { base = massive_stress_loss }
			primary_spouse = {
				stress_impact = { base = massive_stress_loss }
			}
		}
		else = {
			stress_impact = { base = major_stress_loss }
			primary_spouse = {
				stress_impact = { base = major_stress_loss }
			}
		}
	}

	after = {
		root = { remove_naked_effect = yes }
		primary_spouse = { remove_naked_effect = yes }
	}
}

# Spending time with spouse while travelling
lmf_spouse.1095 = {
	type = character_event
	title = lmf_spouse.1095.t
	desc = {
		desc = lmf_spouse.1095.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { location_has_winter_trigger = yes }
				desc = lmf_spouse.1095.desc.cold
			}
			triggered_desc = {
				trigger = {
					location = {
						OR = {
							terrain = oasis
							graphical_wilderness_desert_trigger = yes
						}
					}
				}
				desc = lmf_spouse.1095.desc.sand
			}
			triggered_desc = {
				trigger = {
					location = {
						OR = {
							graphical_wilderness_forest_pine_trigger = yes
							graphical_wilderness_forest_trigger = yes
							graphical_wilderness_wetlands_trigger = yes
							graphical_wilderness_jungle_trigger = yes
						}
					}
				}
				desc = lmf_spouse.1095.desc.bugs
			}
			desc = lmf_spouse.1095.desc.default
		}
		desc = lmf_spouse.1095.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = interested
	}
	right_portrait = {
		character = primary_spouse
		animation = laugh
	}

	override_background = { reference = wilderness }

	trigger = {
		has_relation_lover = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1095_event }
		is_travelling = yes
		exists = current_travel_plan
		location = { is_sea_province = no }
		stress > 0
		is_physically_able = yes
		has_recoverable_disease_trigger = no
		current_travel_plan = {
			OR = {
				travel_plan_owner = { this = root.primary_spouse }
				any_entourage_character = { this = root.primary_spouse }
			}
		}
		primary_spouse = {
			is_physically_able = yes
			has_recoverable_disease_trigger = no
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			stress > normal_baseline_stress
		}
		modifier = {
			factor = 2
			stress >= high_medium_stress
		}
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			stress <= low_stress
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_compassion <= high_negative_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_energy <= high_negative_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_energy <= -100
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1095_event years = 10 }
		add_spouse_event_variables = yes
		root = { make_naked_effect = yes }
		primary_spouse = { make_naked_effect = yes }
	}

	option = {
		name = lmf_spouse.1095.a
		had_sex_with_effect = { CHARACTER = primary_spouse PREGNANCY_CHANCE = pregnancy_chance }
		if = {
			limit = { has_relation_soulmate = primary_spouse }
			stress_impact = { base = massive_stress_loss }
			primary_spouse = {
				stress_impact = { base = massive_stress_loss }
			}
		}
		else = {
			stress_impact = { base = major_stress_loss }
			primary_spouse = {
				stress_impact = { base = major_stress_loss }
			}
		}
	}

	after = {
		root = { remove_naked_effect = yes }
		primary_spouse = { remove_naked_effect = yes }
	}
}

# Malicious/Greedy lover sells a secret of yours to a rival
lmf_spouse.1100 = {
	type = character_event
	title = lmf_spouse.1100.t
	desc = lmf_spouse.1100.desc
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = scheme
	}
	lower_right_portrait = scope:my_rival

	override_background = { reference = corridor_night }

	trigger = {
		has_any_secrets = yes
		num_of_relation_rival > 0
		is_physically_able = yes
		primary_spouse = {
			OR = {
				ai_greed >= high_positive_ai_value
				has_personality_malicious_trigger = yes
				untrustworthy_trigger = yes
			}
			ai_greed >= 0
			ai_honor <= 0
			is_available = yes
			has_recoverable_disease_trigger = no
			NOR = {
				has_character_flag = had_lmf_spouse_1100_event
				has_relation_friend = root
				has_relation_soulmate = root
			}
		}
		any_relation = {
			type = rival
			short_term_gold >= 100
			is_available = yes
			has_recoverable_disease_trigger = no
			save_temporary_scope_as = potential_blackmailer
			root = {
				any_secret = {
					is_blackmailable_secret_trigger = { BLACKMAILER = scope:potential_blackmailer PARTICIPANT = root }
					NOT = { secret_is_incriminating_trigger = { TARGET = root.primary_spouse } }
					OR = {
						is_known_by = root.primary_spouse
						root.primary_spouse.intrigue >= root.intrigue_plus_5
					}
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse.ai_greed >= 100
		}
		modifier = {
			factor = 2
			primary_spouse.ai_honor <= high_negative_ai_value
		}
		modifier = {
			factor = 0.5
			reverse_opinion = { target = primary_spouse value > 0 }
		}
	}

	immediate = {
		primary_spouse = {
			add_character_flag = { flag = had_lmf_spouse_1100_event years = 10 }
		}
		add_spouse_event_variables = yes
		primary_spouse = { save_scope_as = lover } #for theme

		# to change the background to wherever they are
		primary_spouse = { save_scope_as = bg_override_char }

		# now pick the rival
		random_relation = {
			type = rival
			limit = {
				short_term_gold >= 100
				is_available = yes
				has_recoverable_disease_trigger = no
				save_temporary_scope_as = potential_blackmailer
				root = {
					any_secret = {
						is_blackmailable_secret_trigger = { BLACKMAILER = scope:potential_blackmailer PARTICIPANT = root }
						NOT = { secret_is_incriminating_trigger = { TARGET = root.primary_spouse } }
						OR = {
							is_known_by = root.primary_spouse
							root.primary_spouse.intrigue >= root.intrigue_plus_5
						}
					}
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 10
					short_term_gold >= 200
				}
				modifier = {
					add = 20
					is_ai = no
				}
			}
			save_scope_as = my_rival
		}
		# and then pick the secret
		random_secret = {
			limit = {
				is_blackmailable_secret_trigger = { BLACKMAILER = scope:my_rival PARTICIPANT = root }
				NOT = { secret_is_incriminating_trigger = { TARGET = root.primary_spouse } }
				OR = {
					is_known_by = root.primary_spouse
					root.primary_spouse.intrigue >= root.intrigue_plus_5
				}
			}
			weight = {
				base = 1
				modifier = {
					add = 100
					is_known_by = root.primary_spouse
				}
			}
			save_scope_as = secret
		}
		# a player rival gets a separate event
		if = {
			limit = {
				scope:my_rival = { is_ai = no }
			}
			root = { save_scope_as = player_rival }
			scope:my_rival = { trigger_event = lmf_spouse.1101 }
		}
		else = {
			scope:my_rival = {
				hidden_effect = {
					pay_short_term_gold = {
						target = root.primary_spouse
						gold = 100
					}
				}
			}
			scope:secret = {
				hidden_effect = { reveal_to = scope:my_rival }
			}
		}
	}

	option = {
		name = lmf_spouse.1100.a
		stress_impact = {
			base = minor_stress_gain
			wrathful = minor_stress_impact_gain
			calm = minor_stress_impact_loss
			paranoid = medium_stress_impact_gain
			trusting = minor_stress_impact_gain
			vengeful = minor_stress_impact_gain
		}
	}
}

lmf_spouse.1101 = {
	type = letter_event
	opening = lmf_spouse.1101.opening
	desc = {
		triggered_desc = {
			trigger = {
				NOT = { has_RelationToMe_relation = { CHARACTER = root.primary_spouse } }
			}
			desc = lmf_spouse.1101.stranger
		}
		desc = lmf_spouse.1101.start
		first_valid = {
			triggered_desc = {
				trigger = { has_RelationToMe_relation = { CHARACTER = root.primary_spouse } }
				desc = lmf_spouse.1101.know
			}
			desc = lmf_spouse.1101.stranger2
		}
	}
	sender = primary_spouse

	option = {
		name = lmf_spouse.1101.a #A rival's secret? Yes, please!
		pay_short_term_gold = {
			target = primary_spouse
			gold = 100
		}
		scope:secret = { reveal_to = root }
	}
	option = {
		name = lmf_spouse.1101.b #Not interested
	}
}

# Spouse lover is sick - do you take time to care for them?
lmf_spouse.1105 = {
	type = character_event
	title = lmf_spouse.1105.t
	desc = {
		desc = lmf_spouse.1105.desc.start
		desc = lmf_spouse.1105.desc.courtier
		desc = lmf_spouse.1105.desc.end
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = sick
	}

	override_background = { reference = bedchamber }

	trigger = {
		has_relation_lover = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1105_event }
		is_available = yes
		has_recoverable_disease_trigger = no
		primary_spouse = {
			is_courtier_of = root
			has_recoverable_disease_trigger = yes
			is_travelling = no
			is_in_army = no
			is_imprisoned = no
			is_incapable = no
			NOR = {
				exists = involved_activity
				has_variable = homage_liege_scope
				has_character_flag = meditation_character_flag
				has_character_flag = petition_liege_character_flag
				has_character_flag = holding_court_character_flag
				is_being_visited_on_tour_strict = yes
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			learning > 10
			NOT = { has_trait = blind }
			OR = {
				has_trait = lifestyle_physician
				has_trait = lifestyle_mystic
				has_trait = lifestyle_herbalist
			}
		}
		modifier = {
			factor = 2
			primary_spouse = { has_contagious_deadly_disease_trigger = yes }
		}
		modifier = {
			factor = 1.5
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 1.5
			ai_compassion >= high_positive_ai_value
		}
		modifier = {
			factor = 1.5
			ai_compassion >= very_high_positive_ai_value
		}
		modifier = {
			factor = 0.5
			has_trait = paranoid
		}
		modifier = {
			factor = 0.5
			has_trait = craven
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1105_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1105.a #Of course I'll look after her!
		reverse_add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 20 }
		primary_spouse = {
			if = {
				limit = {
					root = {
						learning > 10
						NOT = { has_trait = blind }
						OR = {
							has_trait = lifestyle_physician
							has_trait = lifestyle_mystic
							has_trait = lifestyle_herbalist
						}
					}
				}
				add_character_modifier = {
					modifier = physician_lover_nurses_me_modifier
					years = 2
				}
			}
			else = {
				add_character_modifier = {
					modifier = lover_nurses_me_modifier
					years = 2
				}
			}
			hidden_effect = {
				recheck_disease_recovery_effect = yes
			}
		}
		if = {
			limit = {
				OR = {
					AND = {
						primary_spouse = { has_trait = bubonic_plague }
						can_contract_disease_trigger = { DISEASE = bubonic_plague }
					}
					AND = {
						primary_spouse = { has_trait = smallpox }
						can_contract_disease_trigger = { DISEASE = smallpox }
					}
					AND = {
						primary_spouse = { has_trait = typhus }
						can_contract_disease_trigger = { DISEASE = typhus }
					}
					AND = {
						primary_spouse = { has_trait = consumption }
						can_contract_disease_trigger = { DISEASE = consumption }
					}
					AND = {
						primary_spouse = { has_trait = measles }
						can_contract_disease_trigger = { DISEASE = measles }
					}
					AND = {
						primary_spouse = { has_trait = dysentery }
						can_contract_disease_trigger = { DISEASE = dysentery }
					}
				}
			}
			random = {
				chance = 50
				if = {
					limit = { primary_spouse = { has_trait = bubonic_plague } }
					contract_disease_effect = { DISEASE = bubonic_plague TREATMENT_EVENT = yes }
				}
				else_if = {
					limit = { primary_spouse = { has_trait = smallpox } }
					contract_disease_effect = { DISEASE = smallpox TREATMENT_EVENT = yes }
				}
				else_if = {
					limit = { primary_spouse = { has_trait = typhus } }
					contract_disease_effect = { DISEASE = typhus TREATMENT_EVENT = yes }
				}
				else_if = {
					limit = { primary_spouse = { has_trait = consumption } }
					contract_disease_effect = { DISEASE = consumption TREATMENT_EVENT = yes }
				}
				else_if = {
					limit = { primary_spouse = { has_trait = measles } }
					contract_disease_effect = { DISEASE = measles TREATMENT_EVENT = yes }
				}
				else = {
					contract_disease_effect = { DISEASE = dysentery TREATMENT_EVENT = yes }
				}
			}
		}
		else = {
			random = {
				chance = 25
				contract_disease_effect = { DISEASE = ill TREATMENT_EVENT = yes }
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 1
				ai_boldness = 0.5
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1105.c #She'll be treated like any other courtier
		reverse_add_opinion = { target = primary_spouse modifier = disappointed_opinion opinion = -20 }
		primary_spouse = {
			hidden_effect = {
				recheck_disease_recovery_effect = yes
			}
		}
		ai_chance = {
			base = 150
			modifier = {
				add = 100
				has_trait = paranoid
			}
			ai_value_modifier = {
				ai_compassion = -1
				ai_boldness = -0.5
			}
			min = 1
		}
	}
}

# Spouse demands that you end an affair
lmf_spouse.1110 = {
	type = character_event
	hidden = yes

	trigger = {
		NOR = {
			has_character_flag = had_lmf_lover_1175_event
			faith = { has_doctrine_parameter = no_unfaithfulness_penalty_active }
			has_relation_unfruitful_marriage = primary_spouse
		}
		any_relation = {
			type = lover
			is_available = yes
			has_recoverable_disease_trigger = no
			NOR = {
				is_consort_of = root
				has_friendly_relationship_trigger = { CHARACTER = root.primary_spouse }
			}
			trigger_if = {
				limit = { is_playable_character = yes }
				NOT = { is_at_war_with = root }
			}
			trigger_if = {
				limit = { is_courtier_of = root }
				bp2_valid_for_standard_interactions_trigger = yes
				NOR = {
					lover_kick_from_court_validity_trigger = no
					any_traveling_family_member = { lover_kick_from_court_validity_trigger = no }
				}
			}
			trigger_if = {
				limit = {
					any_secret = {
						type = secret_lover
						secret_target = root
					}
				}
				any_secret = {
					type = secret_lover
					is_known_by = root.primary_spouse
					secret_target = root
				}
			}
		}
		primary_spouse = {
			has_trait_submissive_trigger = no
			has_negative_attitude_towards_trait_trigger = { TRAIT = trait:adulterer GENDER_CHARACTER = root }
			is_available_ai = yes
			has_recoverable_disease_trigger = no
			NOR = {
				has_relation_nemesis = root
				faith = { has_doctrine_parameter = no_unfaithfulness_penalty_active }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse.ai_vengefulness > 0
		}
		modifier = {
			factor = 2
			primary_spouse.ai_vengefulness >= 50
		}
		modifier = {
			factor = 2
			primary_spouse.ai_vengefulness >= 100
		}
		modifier = {
			factor = 2
			primary_spouse = { has_relation_lover = root }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_relation_soulmate = root }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_relation_rival = scope:lover }
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_boldness < 0
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_boldness <= -50
		}
	}

	immediate = {
		random_relation = {
			type = lover
			limit = {
				is_available = yes
				has_recoverable_disease_trigger = no
				NOR = {
					is_consort_of = root
					has_friendly_relationship_trigger = { CHARACTER = root.primary_spouse }
				}
				trigger_if = {
					limit = { is_playable_character = yes }
					NOT = { is_at_war_with = root }
				}
				trigger_if = {
					limit = { is_courtier_of = root }
					bp2_valid_for_standard_interactions_trigger = yes
					NOR = {
						lover_kick_from_court_validity_trigger = no
						any_traveling_family_member = { lover_kick_from_court_validity_trigger = no }
					}
				}
				trigger_if = {
					limit = {
						any_secret = {
							type = secret_lover
							secret_target = root
						}
					}
					any_secret = {
						type = secret_lover
						is_known_by = root.primary_spouse
						secret_target = root
					}
				}
			}
			save_scope_as = lover
		}
		random_owned_story = {
			type = lmf_lover_story_cycle
			limit = { var:lover_target ?= scope:lover }
			save_scope_as = story
		}
		add_spouse_event_variables = yes
		trigger_event = lmf_lover.1175
	}
}

# Spouse lover's opinion of you drops too low
lmf_spouse.1115 = {
	type = character_event
	title = lmf_spouse.1115.t
	desc = lmf_spouse.1115.desc
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = disapproval
	}

	override_background = { reference = courtyard }

	trigger = {
		has_relation_lover = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1115_event }
		is_physically_able = yes
		primary_spouse = { is_physically_able = yes }
		trigger_if = {
			limit = { has_relation_soulmate = primary_spouse }
			reverse_opinion = { target = primary_spouse value <= 60 }
		}
		trigger_else = {
			reverse_opinion = { target = primary_spouse value <= 30 }
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
			reverse_opinion = { target = primary_spouse value <= 30 }
		}
		modifier = {
			factor = 2
			reverse_opinion = { target = primary_spouse value <= 0 }
		}
		modifier = {
			factor = 4
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1115_event years = 10 }
		add_spouse_event_variables = yes

		# to change the background to wherever they are
		primary_spouse = { save_scope_as = bg_override_char }
	}

	option = {
		name = lmf_spouse.1115.a
		if = {
			limit = { has_relation_soulmate = primary_spouse }
			remove_relation_soulmate = primary_spouse
			set_relation_lover = primary_spouse
		}
		else = {
			lover_breakup_effect = { BREAKER = root.primary_spouse LOVER = root }
		}
	}
}

# Spouse's opinion increases because of common personality
lmf_spouse.1120 = {
	type = character_event
	title = lmf_spouse.1120.t
	desc = {
		desc = lmf_spouse.1120.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					trait_compatibility = {
						target = root.primary_spouse
						value >= high_positive_trait_compatibility
					}
				}
				desc = lmf_spouse.1120.desc.high
			}
			triggered_desc = {
				trigger = {
					trait_compatibility = {
						target = root.primary_spouse
						value >= medium_positive_trait_compatibility
					}
				}
				desc = lmf_spouse.1120.desc.mid
			}
			desc = lmf_spouse.1120.desc.low
		}
		desc = lmf_spouse.1120.desc.end
	}
	theme = marriage

	right_portrait = {
		character = root
		animation = interested
	}
	left_portrait = {
		character = primary_spouse
		animation = happiness
	}

	override_background = { reference = courtyard }

	trigger = {
		trait_compatibility = {
			target = root.primary_spouse
			value >= low_positive_trait_compatibility
		}
		NOR = {
			has_character_flag = had_lmf_spouse_1120_event
			has_relation_rival = primary_spouse
			has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root.primary_spouse }
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1120_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1120.a
		stress_impact = {
			base = medium_stress_loss
		}
		reverse_add_opinion = { target = primary_spouse modifier = respect_opinion opinion = 20 }
		hidden_effect = {
			add_opinion = { target = primary_spouse modifier = respect_opinion opinion = 20 }
		}
	}
}

# Spouse's opinion increases because of common lifestyle
lmf_spouse.1125 = {
	type = character_event
	title = lmf_spouse.1125.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:common_interest = flag:diplomat }
				desc = lmf_spouse.1125.desc.diplomat
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:reveler }
				desc = lmf_spouse.1125.desc.reveler
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:blademaster }
				desc = lmf_spouse.1125.desc.blademaster
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:hunter }
				desc = lmf_spouse.1125.desc.hunter
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:strategist }
				desc = lmf_spouse.1125.desc.strategist
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:architect }
				desc = lmf_spouse.1125.desc.architect
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:intrigue }
				desc = lmf_spouse.1125.desc.intrigue
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:celibate }
				desc = lmf_spouse.1125.desc.celibate
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:learning }
				desc = lmf_spouse.1125.desc.learning
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:family }
				desc = lmf_spouse.1125.desc.family
			}
			triggered_desc = {
				trigger = { scope:common_interest = flag:sadistic }
				desc = lmf_spouse.1125.desc.sadistic
			}
			desc = lmf_spouse.1125.desc.lunatic
		}
	}
	theme = marriage

	right_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:common_interest = flag:blademaster }
			animation = aggressive_sword
		}
		triggered_animation = {
			trigger = { scope:common_interest = flag:hunter }
			animation = hunting_shortbow_rest_arrow_default
		}
		triggered_animation = {
			trigger = { scope:common_interest = flag:intrigue }
			animation = scheme
		}
		triggered_animation = {
			trigger = { scope:common_interest = flag:learning }
			animation = reading
		}
		triggered_animation = {
			trigger = { scope:common_interest = flag:sadistic }
			animation = thinking
		}
		triggered_animation = {
			trigger = { scope:common_interest = flag:lunatic }
			animation = shock
		}
		triggered_outfit = {
			trigger = { scope:common_interest = flag:hunter }
			remove_default_outfit = no
			outfit_tags = { travel_cloak }
		}
		triggered_outfit = {
			trigger = { scope:common_interest = flag:celibate }
			remove_default_outfit = yes
			outfit_tags = { nightgown }
		}
		animation = happiness
	}
	left_portrait = {
		character = primary_spouse
		triggered_animation = {
			trigger = { scope:common_interest = flag:learning }
			animation = debating
		}
		triggered_outfit = {
			trigger = { scope:common_interest = flag:hunter }
			remove_default_outfit = no
			outfit_tags = { travel_cloak }
		}
		triggered_outfit = {
			trigger = { scope:common_interest = flag:celibate }
			remove_default_outfit = yes
			outfit_tags = { nightgown }
		}
		animation = love
	}

	override_background = {
		trigger = { scope:common_interest = flag:diplomat }
		reference = throne_room
	}
	override_background = {
		trigger = { scope:common_interest = flag:reveler }
		reference = feast
	}
	override_background = {
		trigger = { scope:common_interest = flag:blademaster }
		reference = armory
	}
	override_background = {
		trigger = { scope:common_interest = flag:hunter }
		reference = wilderness_forest
	}
	override_background = {
		trigger = { scope:common_interest = flag:strategist }
		reference = council_chamber
	}
	override_background = {
		trigger = { scope:common_interest = flag:architect }
		reference = study
	}
	override_background = {
		trigger = { scope:common_interest = flag:intrigue }
		reference = council_chamber
	}
	override_background = {
		trigger = { scope:common_interest = flag:celibate }
		reference = bedchamber
	}
	override_background = {
		trigger = { scope:common_interest = flag:learning }
		reference = study
	}
	override_background = {
		trigger = { scope:common_interest = flag:family }
		reference = sitting_room
	}
	override_background = {
		trigger = { scope:common_interest = flag:sadistic }
		reference = dungeon
	}
	override_background = {
		trigger = { scope:common_interest = flag:lunatic }
		reference = corridor_night
	}

	trigger = {
		primary_spouse = { has_same_lifestyle_as_root_trigger = yes }
		NOR = {
			has_character_flag = had_lmf_spouse_1125_event
			has_relation_rival = primary_spouse
			has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root.primary_spouse }
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1125_event years = 10 }
		add_spouse_event_variables = yes

		#select commonality
		random_list = {
			10 = {
				trigger = {
					has_trait = diplomat
					primary_spouse = { has_trait = diplomat }
				}
				save_scope_value_as = { name = common_interest value = flag:diplomat }
			}
			10 = {
				trigger = {
					has_trait = lifestyle_reveler
					primary_spouse = { has_trait = lifestyle_reveler }
				}
				save_scope_value_as = { name = common_interest value = flag:reveler }
			}
			10 = {
				trigger = {
					has_trait = lifestyle_blademaster
					primary_spouse = { has_trait = lifestyle_blademaster }
				}
				save_scope_value_as = { name = common_interest value = flag:blademaster }
				add_character_flag = wear_armor
				primary_spouse = { add_character_flag = wear_armor }
			}
			10 = {
				trigger = {
					has_trait = lifestyle_hunter
					primary_spouse = { has_trait = lifestyle_hunter }
				}
				save_scope_value_as = { name = common_interest value = flag:hunter }
			}
			10 = {
				trigger = {
					has_trait = strategist
					primary_spouse = { has_trait = strategist }
				}
				save_scope_value_as = { name = common_interest value = flag:strategist }
			}
			10 = {
				trigger = {
					has_trait = architect
					primary_spouse = { has_trait = architect }
				}
				save_scope_value_as = { name = common_interest value = flag:architect }
			}
			10 = {
				trigger = {
					has_intrigue_lifestyle_trait_trigger = yes
					primary_spouse = { has_intrigue_lifestyle_trait_trigger = yes }
				}
				save_scope_value_as = { name = common_interest value = flag:intrigue }
			}
			10 = {
				trigger = {
					has_trait = celibate
					primary_spouse = { has_trait = celibate }
				}
				save_scope_value_as = { name = common_interest value = flag:celibate }
			}
			10 = {
				trigger = {
					has_learning_lifestyle_trait_trigger = yes
					primary_spouse = { has_learning_lifestyle_trait_trigger = yes }
				}
				save_scope_value_as = { name = common_interest value = flag:learning }
			}
			10 = {
				trigger = {
					has_trait = family_first
					primary_spouse = { has_trait = family_first }
				}
				save_scope_value_as = { name = common_interest value = flag:family }
			}
			10 = {
				trigger = {
					has_trait = sadistic
					primary_spouse = { has_trait = sadistic }
				}
				save_scope_value_as = { name = common_interest value = flag:sadistic }
			}
			10 = {
				trigger = {
					has_trait = lunatic
					primary_spouse = { has_trait = lunatic }
				}
				save_scope_value_as = { name = common_interest value = flag:lunatic }
			}
		}
	}

	option = {
		name = lmf_spouse.1125.a
		stress_impact = {
			base = medium_stress_loss
		}
		reverse_add_opinion = { target = primary_spouse modifier = respect_opinion opinion = 20 }
		hidden_effect = {
			add_opinion = { target = primary_spouse modifier = respect_opinion opinion = 20 }
		}
	}

	after = {
		if = {
			limit = { scope:common_interest = flag:blademaster }
			remove_character_flag = wear_armor
			primary_spouse = { remove_character_flag = wear_armor }
		}
	}
}

# Spouse's opinion decreases because of opposite personality trait
lmf_spouse.1130 = {
	type = character_event
	title = lmf_spouse.1130.t
	desc = lmf_spouse.1130.desc
	theme = marriage

	right_portrait = {
		character = root
		animation = disgusted
	}
	left_portrait = {
		character = primary_spouse
		animation = anger
	}

	override_background = { reference = corridor_day }

	trigger = {
		primary_spouse = {
			any_character_trait = {
				has_trait_category = personality
				any_opposite_trait = {
					root = { has_trait = prev }
				}
			}
			number_of_personality_traits_in_common = {
				target = root
				value < 2
			}
		}
		NOT = { has_character_flag = had_lmf_spouse_1130_event }
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_rival = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_nemesis = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_best_friend = primary_spouse
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1130_event years = 10 }
		add_spouse_event_variables = yes

		primary_spouse = {
			random_character_trait = {
				limit = {
					has_trait_category = personality
					any_opposite_trait = {
						root = { has_trait = prev }
					}
				}
				save_scope_as = their_trait
			}
		}
		scope:their_trait = {
			random_opposite_trait = {
				limit = {
					root = { has_trait = prev }
				}
				save_scope_as = my_trait
			}
		}
	}

	option = {
		name = lmf_spouse.1130.a
		stress_impact = {
			base = medium_stress_impact_gain
		}
		reverse_add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -20 }
		hidden_effect = {
			add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -20 }
		}
	}
}

# Many arguments with spouse lately
lmf_spouse.1135 = {
	type = character_event
	title = lmf_spouse.1135.t
	desc = {
		desc = lmf_spouse.1135.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						OR = {
							has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
							has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
							has_opinion_modifier = { modifier = betrayed_our_promise target = root }
						}
					}
				}
				desc = lmf_spouse.1135.desc.unfaithful
			}
			triggered_desc = {
				trigger = {
					primary_spouse = {
						has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
					}
				}
				desc = lmf_spouse.1135.desc.revenge
			}
			triggered_desc = {
				trigger = { has_relation_rival = primary_spouse }
				desc = lmf_spouse.1135.desc.rival
			}
			triggered_desc = {
				trigger = { reverse_opinion = { target = primary_spouse value < 0 } }
				desc = lmf_spouse.1135.desc.hate
			}
			triggered_desc = {
				trigger = { has_relation_soulmate = primary_spouse }
				desc = lmf_spouse.1135.desc.soulmate
			}
			triggered_desc = {
				trigger = { has_relation_lover = primary_spouse }
				desc = lmf_spouse.1135.desc.lover
			}
			triggered_desc = {
				trigger = { has_relation_friend = primary_spouse }
				desc = lmf_spouse.1135.desc.friend
			}
			desc = lmf_spouse.1135.desc.like
		}
		desc = lmf_spouse.1135.desc.end
	}
	theme = marriage

	right_portrait = {
		character = root
		animation = dismissal
	}
	left_portrait = {
		character = primary_spouse
		animation = disapproval
	}

	override_background = { reference = council_chamber }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1135_event }
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 5
			has_relation_nemesis = primary_spouse
		}
		modifier = {
			factor = 3
			has_relation_rival = primary_spouse
			NOT = { has_relation_nemesis = primary_spouse }
		}
		modifier = {
			factor = 2
			reverse_opinion = { target = primary_spouse value < 0 }
		}
		modifier = {
			factor = 0.5
			reverse_opinion = { target = primary_spouse value >= 30 }
		}
		modifier = {
			factor = 0.5
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_best_friend = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_soulmate = primary_spouse
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1135_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1135.a
		stress_impact = {
			base = medium_stress_impact_gain
		}
		reverse_add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -20 }
		hidden_effect = {
			add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -20 }
		}
	}
}

# Getting along well with spouse
lmf_spouse.1140 = {
	type = character_event
	title = lmf_spouse.1140.t
	desc = {
		desc = lmf_spouse.1140.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { primary_spouse = { is_playable_character = yes } }
				desc = lmf_spouse.1140.desc.ruler
			}
			desc = lmf_spouse.1140.desc.default
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						OR = {
							has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
							has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
							has_opinion_modifier = { modifier = betrayed_our_promise target = root }
						}
					}
				}
				desc = lmf_spouse.1140.desc.unfaithful
			}
			triggered_desc = {
				trigger = {
					primary_spouse = {
						has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
					}
				}
				desc = lmf_spouse.1140.desc.revenge
			}
			triggered_desc = {
				trigger = { has_relation_rival = primary_spouse }
				desc = lmf_spouse.1140.desc.rival
			}
			triggered_desc = {
				trigger = { reverse_opinion = { target = primary_spouse value < 0 } }
				desc = lmf_spouse.1140.desc.hate
			}
			triggered_desc = {
				trigger = { has_relation_soulmate = primary_spouse }
				desc = lmf_spouse.1140.desc.soulmate
			}
			triggered_desc = {
				trigger = { has_relation_lover = primary_spouse }
				desc = lmf_spouse.1140.desc.lover
			}
			triggered_desc = {
				trigger = { has_relation_friend = primary_spouse }
				desc = lmf_spouse.1140.desc.friend
			}
			desc = lmf_spouse.1140.desc.like
		}
		desc = lmf_spouse.1140.desc.end
		first_valid = {
			triggered_desc = {
				trigger = {
					OR = {
						has_relation_lover = primary_spouse
						has_relation_friend = primary_spouse
					}
				}
				desc = lmf_spouse.1140.desc.end.good
			}
			desc = lmf_spouse.1140.desc.end.poor
		}
	}
	theme = marriage

	right_portrait = {
		character = root
		animation = throne_room_bow_2
		outfit_tags = { travel_cloak }
		camera = camera_event_very_right
	}
	left_portrait = {
		character = primary_spouse
		animation = throne_room_conversation_4
		camera = camera_event_very_left
	}

	override_background = { reference = courtyard }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1140_event }
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_best_friend = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 1.5
			reverse_opinion = { target = primary_spouse value >= 30 }
		}
		modifier = {
			factor = 0.75
			reverse_opinion = { target = primary_spouse value < 0 }
		}
		modifier = {
			factor = 0.5
			has_relation_nemesis = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_rival = primary_spouse
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
		modifier = {
			factor = 0.5
			NOT = { stress > 0 }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1140_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1140.a
		stress_impact = {
			base = medium_stress_loss
		}
		reverse_add_opinion = { target = primary_spouse modifier = respect_opinion opinion = 20 }
		hidden_effect = {
			add_opinion = { target = primary_spouse modifier = respect_opinion opinion = 20 }
		}
	}
}

# Spouse's opinion increases because of common friend
lmf_spouse.1145 = {
	type = character_event
	title = lmf_spouse.1145.t
	desc = {
		desc = lmf_spouse.1145.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { is_close_or_extended_family_of = scope:mutual_friend }
				desc = lmf_spouse.1145.desc.relation
			}
			desc = lmf_spouse.1145.desc.norelation
		}
		desc = lmf_spouse.1145.desc.mid
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
					}
				}
				desc = lmf_spouse.1145.desc.revenge
			}
			triggered_desc = {
				trigger = { has_relation_rival = primary_spouse }
				desc = lmf_spouse.1145.desc.rival
			}
			triggered_desc = {
				trigger = { reverse_opinion = { target = primary_spouse value >= 30 } }
				desc = lmf_spouse.1145.desc.like
			}
			triggered_desc = {
				trigger = { reverse_opinion = { target = primary_spouse value >= 0 } }
				desc = lmf_spouse.1145.desc.neutral
			}
			desc = lmf_spouse.1145.desc.hate
		}
		desc = lmf_spouse.1145.desc.end
	}
	theme = marriage

	right_portrait = {
		character = scope:mutual_friend
		animation = debating
	}
	left_portrait = {
		character = primary_spouse
		animation = thinking
	}
	lower_left_portrait = root

	override_background = { reference = garden }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1145_event }
		primary_spouse = {
			is_available = yes
			has_recoverable_disease_trigger = no
			trigger_if = {
				limit = { is_playable_character = yes }
				NOT = { is_at_war_with = root }
			}
			NOR = {
				has_relation_friend = root
				has_relation_lover = root
			}
			any_relation = {
				type = friend
				has_relation_friend = root
				is_available = yes
				has_recoverable_disease_trigger = no
				trigger_if = {
					limit = { is_playable_character = yes }
					NOT = { is_at_war_with = root }
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			has_relation_rival = primary_spouse
			factor = 0.5
		}
		modifier = {
			has_relation_nemesis = primary_spouse
			factor = 0.5
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1145_event years = 10 }
		add_spouse_event_variables = yes

		random_relation = {
			type = friend
			limit = {
				has_relation_friend = root.primary_spouse
				is_available = yes
				has_recoverable_disease_trigger = no
				trigger_if = {
					limit = { is_playable_character = yes }
					NOT = { is_at_war_with = root }
				}
			}
			save_scope_as = mutual_friend
		}
	}

	option = {
		name = lmf_spouse.1145.a
		improve_relationship_effect = {
			TARGET = root.primary_spouse
			REASON = talked_up_by_friend
		}
		hidden_effect = {
			add_opinion = { target = scope:mutual_friend modifier = grateful_opinion opinion = 20 }
		}
	}
}

# Spouse takes on your stress
lmf_spouse.1150 = {
	type = character_event
	title = lmf_spouse.1150.t
	desc = {
		desc = lmf_spouse.1150.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { primary_spouse = { has_personality_benevolent_trigger = yes } }
				desc = lmf_spouse.1150.compassionate
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_trait = diligent } }
				desc = lmf_spouse.1150.diligent
			}
			desc = lmf_spouse.1150.dominant
		}
		desc = lmf_spouse.1150.desc.end
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		triggered_animation = {
			trigger = {
				primary_spouse = {
					has_personality_benevolent_trigger = yes
				}
			}
			animation = personality_compassionate
		}
		triggered_animation = {
			trigger = {
				primary_spouse = {
					has_personality_benevolent_trigger = no
					has_trait = diligent
				}
			}
			animation = personality_honorable
		}
		animation = personality_bold
	}

	override_background = { reference = throne_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1150_event }
		stress_level >= 1
		primary_spouse = {
			stress_level < 2
			is_courtier_of = root
			is_councillor_of = root
			OR = {
				has_personality_benevolent_trigger = yes
				has_personality_dominant_trigger = yes
				has_trait = diligent
			}
			NOT = { has_relation_rival = root }
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse.ai_compassion >= 100
		}
		modifier = {
			factor = 2
			primary_spouse.ai_energy >= 100
		}
		modifier = {
			factor = 1.5
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 1.5
			has_relation_best_friend = primary_spouse
		}
		modifier = {
			factor = 1.5
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 1.5
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			reverse_opinion = { target = primary_spouse value < 30 }
		}
		modifier = {
			factor = 0.5
			reverse_opinion = { target = primary_spouse value < 0 }
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1150_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1150.a
		stress_impact = {
			base = major_stress_loss
		}
		primary_spouse = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
		}
		hidden_effect = {
			add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 20 }
		}
	}
}

# Do you take on spouse's stress?
lmf_spouse.1155 = {
	type = character_event
	title = lmf_spouse.1155.t
	desc = {
		desc = lmf_spouse.1155.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { primary_spouse = { has_personality_submissive_trigger = yes } }
				desc = lmf_spouse.1155.submissive
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_trait = lazy } }
				desc = lmf_spouse.1155.lazy
			}
			desc = lmf_spouse.1155.introvert
		}
		desc = lmf_spouse.1155.desc.end
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = stress
	}

	override_background = { reference = throne_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1155_event }
		stress_level < 2
		primary_spouse = {
			stress_level >= 1
			is_courtier_of = root
			is_councillor_of = root
			OR = {
				has_personality_submissive_trigger = yes
				has_personality_introverted_trigger = yes
				has_trait = lazy
			}
			NOT = { has_relation_rival = root }
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			ai_compassion >= 100
		}
		modifier = {
			factor = 2
			ai_energy >= 100
		}
		modifier = {
			factor = 1.5
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 1.5
			has_relation_best_friend = primary_spouse
		}
		modifier = {
			factor = 1.5
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 1.5
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			opinion = { target = primary_spouse value < 30 }
		}
		modifier = {
			factor = 0.5
			opinion = { target = primary_spouse value < 0 }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1155_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1155.a #Yes, of course I'll help out
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_energy = 0.5
			}
			modifier = {
				factor = 0.5
				stress_level >= 1
			}
			min = 0
		}
		stress_impact = {
			base = medium_stress_impact_gain
		}
		primary_spouse = {
			stress_impact = {
				base = major_stress_loss
			}
			add_opinion = { target = root modifier = grateful_opinion opinion = 20 }
		}
	}
	option = {
		name = lmf_spouse.1155.b #She needs to deal with this on her own
		primary_spouse = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
			add_opinion = { target = root modifier = disappointed_opinion opinion = -10 }
		}
		ai_chance = {
			base = 50
			modifier = {
				factor = 2
				stress_level >= 1
			}
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_energy = -0.5
			}
			min = 1
		}
	}
}

# Spouse stressed by position
lmf_spouse.1160 = {
	type = character_event
	title = lmf_spouse.1160.t
	desc = {
		desc = lmf_spouse.1160.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { primary_spouse = { has_relation_rival = root } }
				desc = lmf_spouse.1160.rival
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_personality_dominant_trigger = yes } }
				desc = lmf_spouse.1160.dominant
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_personality_levelheaded_trigger = yes } }
				desc = lmf_spouse.1160.levelheaded
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_personality_malicious_trigger = yes } }
				desc = lmf_spouse.1160.malicious
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_personality_benevolent_trigger = yes } }
				desc = lmf_spouse.1160.benevolent
			}
			triggered_desc = {
				trigger = { primary_spouse = { has_trait = diligent } }
				desc = lmf_spouse.1160.diligent
			}
			desc = lmf_spouse.1160.default
		}
		desc = lmf_spouse.1160.desc.end
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = stress
	}

	override_background = { reference = throne_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1160_event }
		primary_spouse = {
			is_courtier_of = root
			is_councillor_of = root
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			sum_of_all_skills_value <= 35
		}
		modifier = {
			factor = 2
			primary_spouse.ai_energy < 0
		}
		modifier = {
			factor = 2
			primary_spouse.ai_energy <= -50
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_energy > 0
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_energy >= 50
		}
		modifier = {
			factor = 0.5
			sum_of_all_skills_value >= 60
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1160_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1160.a
		primary_spouse = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
		}
	}
}

scripted_trigger could_be_spouse_friend = {
	save_temporary_scope_as = potential_spouse_friend
	is_physically_able_ai = yes
	has_recoverable_disease_trigger = no
	is_adult = yes
	sex_same_as = root.primary_spouse
	age <= root.primary_spouse.age_plus_5
	age >= root.primary_spouse.age_minus_5
	has_dynasty = yes
	NOR = {
		this = root.primary_spouse
		has_relation_friend = root.primary_spouse
		has_relation_lover = root.primary_spouse
		has_relation_rival = root.primary_spouse
	}
	trait_compatibility = {
		target = root.primary_spouse
		value >= 5
	}
	OR = {
		faith = root.primary_spouse.faith
		root.primary_spouse.faith = {
			faith_hostility_level = {
				target = scope:potential_spouse_friend.faith
				value <= faith_hostility_prevents_marriage_level
			}
		}
	}
	OR = {
		culture = root.primary_spouse.culture
		root.primary_spouse.culture = {
			cultural_acceptance = {
				target = scope:potential_spouse_friend.culture
				value > 0
			}
		}
	}
	in_diplomatic_range = root.primary_spouse
}

# Bored spouse asks for advice
lmf_spouse.1165 = {
	type = character_event
	title = lmf_spouse.1165.t
	desc = lmf_spouse.1165.desc
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = throne_room_conversation_3
		camera = camera_event_right
	}

	override_background = { reference = garden }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1165_event }
		primary_spouse = {
			is_courtier_of = root
			NOR = {
				has_relation_soulmate = root
				is_knight = yes
				has_any_court_position = yes
				any_relation = { type = ward }
				has_trait = pregnant
				has_trait = lazy
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			has_relation_friend = root
			factor = 2
		}
		modifier = {
			has_relation_lover = root
			factor = 2
		}
		modifier = {
			primary_spouse.ai_energy >= 20
			factor = 2
		}
		modifier = {
			primary_spouse.ai_energy <= -20
			factor = 0.5
		}
		modifier = {
			has_relation_rival = root
			factor = 0.5
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1165_event years = 10 }
		add_spouse_event_variables = yes

		#find a possible friend
		every_courtier = {
			limit = { could_be_spouse_friend = yes }
			add_to_list = potential_spouse_friends
		}
		every_vassal = {
			if = {
				limit = { could_be_spouse_friend = yes }
				add_to_list = potential_spouse_friends
			}
			if = {
				limit = {
					exists = primary_spouse
					primary_spouse = { could_be_spouse_friend = yes }
				}
				primary_spouse = { add_to_list = potential_spouse_friends }
			}
		}
		if = {
			limit = { list_size:potential_spouse_friends > 0 }
			random_in_list = {
				list = potential_spouse_friends
				weight = {
					base = 1
					modifier = {
						add = 10
						has_relation_potential_friend = root.primary_spouse
					}
					modifier = {
						add = 5
						trait_compatibility = {
							target = root.primary_spouse
							value >= medium_positive_trait_compatibility
						}
					}
					modifier = {
						add = 10
						trait_compatibility = {
							target = root.primary_spouse
							value >= high_positive_trait_compatibility
						}
					}
				}
				save_scope_as = new_spouse_friend
			}
		}

		#find a possible lover
		if = {
			limit = {
				primary_spouse = {
					is_below_ai_lover_soft_cap_trigger = yes
					might_cheat_on_every_partner_trigger = yes
					is_involved_in_any_romantic_scheme = no
				}
			}
			every_courtier = {
				limit = {
					is_appropriate_ai_seduction_target = { LOVER = root.primary_spouse TARGET = this }
				}
				add_to_list = potential_spouse_lovers
			}
			every_vassal = {
				if = {
					limit = {
						is_appropriate_ai_seduction_target = { LOVER = root.primary_spouse TARGET = this }
					}
					add_to_list = potential_spouse_lovers
				}
				if = {
					limit = {
						primary_spouse ?= {
							is_appropriate_ai_seduction_target = { LOVER = root.primary_spouse TARGET = this }
						}
					}
					primary_spouse = { add_to_list = potential_spouse_lovers }
				}
			}
			if = {
				limit = { list_size:potential_spouse_lovers > 0 }
				random_in_list = {
					list = potential_spouse_lovers
					weight = {
						base = 1
						modifier = {
							add = 10
							has_relation_potential_lover = root.primary_spouse
						}
						compatibility_modifier = {
							compatibility_target = root
							multiplier = 5
						}
						modifier = {
							add = {
								value = attraction
								multiply = 0.5
							}
						}
						modifier = {
							add = 20
							likely_to_take_lover_trigger = yes
						}
						modifier = {
							add = 10
							willing_to_take_character_as_lover = { LOVER = root.primary_spouse }
						}
						modifier = {
							factor = 0.5
							might_cheat_on_every_partner_trigger = no
						}
					}
					save_scope_as = new_spouse_lover
				}
			}
		}

		#find a possible court position
		if = {
			limit = {
				is_landed_or_landless_administrative = yes
				primary_spouse = {
					highest_skill_value >= medium_skill_rating
					can_be_employed_as_any_court_position_trigger = yes
				}
			}
			primary_spouse = {
				court_position_generator_effect = { VAR = target EMPLOYER = root ONLY_EMPTY = no }
			}
		}
	}

	option = {
		name = lmf_spouse.1165.a # Tell her that she needs a new friend
		trigger = { exists = scope:new_spouse_friend }
		primary_spouse = {
			stress_impact = {
				base = medium_stress_loss
			}
			add_opinion = { target = root modifier = irritated_opinion opinion = -10 }
			set_random_friendship_reason = { TARGET = scope:new_spouse_friend }
		}
		if = {
			limit = { exists = scope:new_spouse_lover }
			hidden_effect = {
				primary_spouse = {
					begin_scheme_basic_effect = {
						SCHEME_TYPE = seduce
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:new_spouse_lover
					}
				}
			}
		}
		ai_chance = {
			base = 50
		}
	}
	option = {
		name = lmf_spouse.1165.b # She could improve her skills
		primary_spouse = {
			stress_impact = {
				base = medium_stress_impact_gain
				diligent = minor_stress_impact_loss
				ambitious = minor_stress_impact_loss
				lazy = minor_stress_impact_gain
				content = minor_stress_impact_gain
			}
			add_opinion = { target = root modifier = irritated_opinion opinion = -10 }
			random_list = {
				100 = {
					modifier = {
						is_performing_council_task = task_court_politics
						factor = 2
					}
					add_diplomacy_skill = 1
				}
				100 = {
					modifier = {
						is_performing_council_task = task_manage_domain
						factor = 2
					}
					add_stewardship_skill = 1
				}
				100 = {
					trigger = {
						OR = {
							can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
							is_performing_council_task = task_chivalry
						}
					}
					modifier = {
						is_performing_council_task = task_chivalry
						factor = 2
					}
					add_martial_skill = 1
					if = {
						limit = { can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root } }
						add_prowess_skill = 1
					}
				}
				100 = {
					modifier = {
						is_performing_council_task = task_court_intrigue
						factor = 2
					}
					add_intrigue_skill = 1
				}
				100 = {
					modifier = {
						is_performing_council_task = task_patronage
						factor = 2
					}
					add_learning_skill = 1
				}
			}
		}
		if = {
			limit = { exists = scope:new_spouse_lover }
			hidden_effect = {
				primary_spouse = {
					begin_scheme_basic_effect = {
						SCHEME_TYPE = seduce
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:new_spouse_lover
					}
				}
			}
		}
		ai_chance = {
			base = 50
		}
	}
	option = {
		name = lmf_spouse.1165.c # The two of us could spend more time together
		stress_impact = {
			base = medium_stress_impact_gain
		}
		improve_relationship_effect = {
			TARGET = root.primary_spouse
			REASON = spent_more_time_together
		}
		ai_chance = {
			base = 50
			modifier = {
				stress_level >= 1
				factor = 0
			}
		}
	}
	option = {
		name = lmf_spouse.1165.e # Take a court position
		trigger = { exists = primary_spouse.var:target_court_position }
		stress_impact = {
			generous = minor_stress_impact_loss
			compassionate = minor_stress_impact_loss
		}
		primary_spouse = {
			add_opinion = { target = root modifier = pleased_opinion opinion = 20 }
			stress_impact = {
				base = medium_stress_impact_gain
				diligent = minor_stress_impact_loss
				ambitious = minor_stress_impact_loss
				lazy = minor_stress_impact_gain
				content = minor_stress_impact_gain
			}
		}
		court_position_generator_assignment_effect = { VAR = target CANDIDATE = root.primary_spouse  EMPLOYER = root }
		ai_chance = {
			base = 20
		}
	}
	option = {
		name = lmf_spouse.1165.d # Find something to do, I don't care!
		worsen_relationship_effect = {
			TARGET = root.primary_spouse
			REASON = spurned_spouse_request_for_advice
		}
		if = {
			limit = { exists = scope:new_spouse_lover }
			hidden_effect = {
				primary_spouse = {
					begin_scheme_basic_effect = {
						SCHEME_TYPE = seduce
						TARGET_TYPE = target_character
						TARGET_SCOPE = scope:new_spouse_lover
					}
				}
			}
		}
		ai_chance = {
			base = 10
		}
	}

	after = {
		primary_spouse = {
			remove_variable ?= target_court_position
		}
	}
}

scripted_trigger spouse_will_be_good_guardian = {
	AND = {
		num_of_relation_guardian = 0
		OR = {
			AND = {
				has_focus = education_diplomacy
				root.primary_spouse.diplomacy >= 12
				trigger_if = {
					limit = {
						root = { employs_court_position = court_tutor_court_position }
					}
					root.primary_spouse.diplomacy >= root.court_position:court_tutor_court_position.diplomacy
				}
			}
			AND = {
				has_focus = education_martial
				root.primary_spouse.martial >= 12
				trigger_if = {
					limit = {
						root = { employs_court_position = court_tutor_court_position }
					}
					root.primary_spouse.martial >= root.court_position:court_tutor_court_position.martial
				}
			}
			AND = {
				has_focus = education_stewardship
				root.primary_spouse.stewardship >= 12
				trigger_if = {
					limit = {
						root = { employs_court_position = court_tutor_court_position }
					}
					root.primary_spouse.stewardship >= root.court_position:court_tutor_court_position.stewardship
				}
			}
			AND = {
				has_focus = education_intrigue
				root.primary_spouse.intrigue >= 12
				trigger_if = {
					limit = {
						root = { employs_court_position = court_tutor_court_position }
					}
					root.primary_spouse.intrigue >= root.court_position:court_tutor_court_position.intrigue
				}
			}
			AND = {
				has_focus = education_learning
				root.primary_spouse.learning >= 12
				trigger_if = {
					limit = {
						root = { employs_court_position = court_tutor_court_position }
					}
					root.primary_spouse.learning >= root.court_position:court_tutor_court_position.learning
				}
			}
		}
	}
}

scripted_trigger spouse_is_better_guardian = {
	OR = {
		AND = {
			scope:potential_spouse_ward = { has_focus = education_diplomacy }
			OR = {
				diplomacy <= root.primary_spouse.diplomacy
				AND = {
					root.primary_spouse.diplomacy >= 12
					has_relation_rival = root.primary_spouse
				}
			}
		}
		AND = {
			scope:potential_spouse_ward = { has_focus = education_martial }
			OR = {
				martial <= root.primary_spouse.martial
				AND = {
					root.primary_spouse.martial >= 12
					has_relation_rival = root.primary_spouse
				}
			}
		}
		AND = {
			scope:potential_spouse_ward = { has_focus = education_stewardship }
			OR = {
				stewardship <= root.primary_spouse.stewardship
				AND = {
					root.primary_spouse.stewardship >= 12
					has_relation_rival = root.primary_spouse
				}
			}
		}
		AND = {
			scope:potential_spouse_ward = { has_focus = education_intrigue }
			OR = {
				intrigue <= root.primary_spouse.intrigue
				AND = {
					root.primary_spouse.intrigue >= 12
					has_relation_rival = root.primary_spouse
				}
			}
		}
		AND = {
			scope:potential_spouse_ward = { has_focus = education_learning }
			OR = {
				learning <= root.primary_spouse.learning
				AND = {
					root.primary_spouse.learning >= 12
					has_relation_rival = root.primary_spouse
				}
			}
		}
	}
}

# Spouse wants to tutor child
lmf_spouse.1170 = {
	type = character_event
	title = lmf_spouse.1170.t
	desc = {
		desc = lmf_spouse.1170.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { primary_spouse = { is_playable_character = yes } }
				desc = lmf_spouse.1170.desc.ruler
			}
			desc = lmf_spouse.1170.desc.courtier
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:spouse_ward_guardian }
				desc = {
					desc = lmf_spouse.1170.desc.hasguardian
					first_valid = {
						triggered_desc = {
							trigger = { primary_spouse = { has_relation_rival = scope:spouse_ward_guardian } }
							desc = lmf_spouse.1170.desc.rival
						}
						desc = lmf_spouse.1170.desc.skill
					}
				}
			}
			desc = lmf_spouse.1170.desc.noguardian
		}
		desc = lmf_spouse.1170.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = thinking
	}
	right_portrait = {
		character = primary_spouse
		animation = beg
	}
	lower_right_portrait = scope:ward
	lower_left_portrait = scope:spouse_ward_guardian

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1170_event }
		primary_spouse = {
			num_of_relation_ward < FF_ward_limit
			NOR = { has_personality_submissive_trigger = yes }
			is_pregnant = no
			any_close_family_member = {
				OR = {
					is_child_of = root.primary_spouse
					is_grandchild_of = root.primary_spouse
				}
				is_courtier_of = root
				is_close_family_of = root.primary_spouse
				age >= childhood_education_start_age
				is_available_child = yes
				has_recoverable_disease_trigger = no
				save_temporary_scope_as = potential_spouse_ward
				OR = {
					spouse_will_be_good_guardian = yes
					any_relation = {
						type = guardian
						NOT = { this = root }
						spouse_is_better_guardian = yes
					}
				}
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = { num_of_relation_ward < 1 }
		}
		modifier = {
			factor = 2
			primary_spouse = { is_playable_character = yes }
		}
		modifier = {
			factor = 0.5
			has_relation_rival = root
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1170_event years = 10 }
		add_spouse_event_variables = yes
		save_scope_as = recipient

		#find child and their guardian
		primary_spouse = {
			save_scope_as = guardian
			save_scope_as = actor
			random_close_family_member = {
				limit = {
					OR = {
						is_child_of = root.primary_spouse
						is_grandchild_of = root.primary_spouse
					}
					is_courtier_of = root
					age >= childhood_education_start_age
					age < 15
					is_available_child = yes
					has_recoverable_disease_trigger = no
					save_temporary_scope_as = potential_spouse_ward
					OR = {
						spouse_will_be_good_guardian = yes
						any_relation = {
							type = guardian
							NOT = { this = root }
							spouse_is_better_guardian = yes
						}
					}
				}
				weight = {
					base = 1
					modifier = {
						num_of_relation_guardian = 0
						add = 2
					}
					modifier = {
						is_child_of = root.primary_spouse
						add = 2
					}
					modifier = {
						sex_same_as = root.primary_spouse
						add = 1
					}
					modifier = {
						any_relation = {
							type = guardian
							has_relation_rival = root.primary_spouse
						}
						add = 1
					}
				}
				save_scope_as = ward
				if = {
					limit = { num_of_relation_guardian > 0 }
					random_relation = {
						type = guardian
						limit = { spouse_is_better_guardian = yes }
						save_scope_as = spouse_ward_guardian
					}
				}
				root = { save_scope_as = ward_liege }
				if = {
					limit = { root.primary_spouse = { is_courtier_of = root } }
					root = { save_scope_as = guardian_liege }
				}
				else = {
					root.primary_spouse = { save_scope_as = guardian_liege }
				}
			}
		}
		
		#save the education scopes
		save_scope_value_as = { name = send_to_university value = no }
		if = {
			limit = {
				NOT = { primary_spouse.culture = scope:ward.culture }
				OR = {
					primary_spouse.culture = root.culture
					NOT = { scope:ward.culture = root.culture }
				}
			}
			save_scope_value_as = { name = convert_culture value = yes }
		}
		else = {
			save_scope_value_as = { name = convert_culture value = no }
		}
		if = {
			limit = {
				NOT = { primary_spouse.faith = scope:ward.faith }
				OR = {
					primary_spouse.faith = root.faith
					NOT = { scope:ward.faith = root.faith }
				}
			}
			save_scope_value_as = { name = convert_faith value = yes }
		}
		else = {
			save_scope_value_as = { name = convert_faith value = no }
		}
	}

	option = {
		name = lmf_spouse.1170.a #Very well, she can tutor them
		reverse_add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 20 }
		educate_child_interaction_effect = yes
		show_as_tooltip = {
			scope:ward = {
				if = {
					limit = { exists = var:ward_travelling_to_guardian }
					custom_tooltip = ward_departs_tt
				}
				else_if = {
					limit = { exists = scope:guardian.var:guardian_travelling_to_ward }
					scope:guardian = { custom_tooltip = guardian_departs_tt }
				}
				else = {
					set_relation_guardian = scope:guardian
				}
			}
		}
		show_as_tooltip = {
			scope:guardian  = { set_relation_ward = scope:ward }
		}
		ai_chance = {
			base = 75
		}
	}
	option = {
		name = lmf_spouse.1170.b #No, things will stay as they are
		reverse_add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -30 }
		ai_chance = {
			base = 25
		}
	}
}

# Spouse thinks daughter should stop learning swordsmanship
lmf_spouse.1175 = {
	type = character_event
	title = lmf_spouse.1175.t
	desc = {
		desc = lmf_spouse.1175.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						faith = { has_doctrine_parameter = combatant_must_be_male_if_no_roco }
						faith = root.faith
						ai_zeal >= 50
					}
				}
				desc = lmf_spouse.1175.desc.religion
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { has_trait = paranoid }
				}
				desc = lmf_spouse.1175.desc.paranoid
			}
			desc = lmf_spouse.1175.desc.dominant
		}
		desc = lmf_spouse.1175.desc.end
	}
	theme = family

	left_portrait = {
		character = scope:focus_child
		animation = aggressive_wooden_sword
	}
	right_portrait = {
		character = primary_spouse
		animation = disapproval
	}

	override_background = { reference = armory }

	trigger = {
		any_child = {
			is_child_of = root.primary_spouse
			OR = {
				is_courtier_of = root
				AND = {
					root.primary_spouse = { is_playable_character = yes }
					is_courtier_of = root.primary_spouse
				}
			}
			is_available_ai_child = yes
			is_female = yes
			has_character_flag = might_ignore_gender_army_rules
			NOT = { has_relation_friend = root.primary_spouse }
		}
		primary_spouse = {
			OR = {
				AND = {
					faith = { has_doctrine_parameter = combatant_must_be_male_if_no_roco }
					faith = root.faith
					ai_zeal >= 50
				}
				has_trait = paranoid
				has_personality_dominant_trigger = yes
			}
			NOR = {
				has_character_flag = had_lmf_spouse_1175_event
				has_character_flag = had_lmf_spouse_1180_event
				can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root.primary_spouse }
				has_education_martial_trigger = yes
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 2
			primary_spouse = {
				faith = { has_doctrine_parameter = combatant_must_be_male_if_no_roco }
				has_trait = zealous
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			has_relation_rival = primary_spouse
		}
	}

	immediate = {
		primary_spouse = { add_character_flag = had_lmf_spouse_1175_event }
		add_spouse_event_variables = yes

		#find child
		random_child = {
			limit = {
				is_child_of = root.primary_spouse
				OR = {
					is_courtier_of = root
					AND = {
						root.primary_spouse = { is_playable_character = yes }
						is_courtier_of = root.primary_spouse
					}
				}
				is_available_ai_child = yes
				is_female = yes
				has_character_flag = might_ignore_gender_army_rules
				NOT = { has_relation_friend = root.primary_spouse }
			}
			save_scope_as = focus_child
		}
	}

	option = {
		name = lmf_spouse.1175.a #Very well, you know what's best for her
		primary_spouse = {
			add_opinion = { target = root modifier = pleased_opinion opinion = 20 }
			worsen_relationship_effect = {
				TARGET = scope:focus_child
				REASON = stopped_my_swordsmanship_education
			}
		}
		scope:focus_child = {
			add_opinion = { target = root modifier = disappointed_opinion opinion = -20 }
			stress_impact = {
				base = medium_stress_impact_gain
			}
			remove_character_flag = might_ignore_gender_army_rules
		}
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_boldness = -0.5
			}
			opinion_modifier = {
				who = root
				opinion_target = root.primary_spouse
				multiplier = 0.50
			}
		}
	}
	option = {
		name = lmf_spouse.1175.b #No, she'll continue her training as is
		stress_impact = {
			base = medium_stress_impact_gain
		}
		reverse_add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -20 }
		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_boldness = 0.5
			}
			opinion_modifier = {
				who = root
				opinion_target = scope:focus_child
				multiplier = 0.50
			}
		}
	}
}

# Spouse thinks daughter should start learning swordsmanship
lmf_spouse.1180 = {
	type = character_event
	title = lmf_spouse.1180.t
	desc = {
		desc = lmf_spouse.1180.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						is_female = yes
						can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					}
				}
				desc = lmf_spouse.1180.desc.knight
			}
			triggered_desc = {
				trigger = {
					primary_spouse = {
						faith = { has_doctrine_parameter = combatant_must_be_male_if_no_roco }
						faith = root.faith
						has_trait = cynical
					}
				}
				desc = lmf_spouse.1180.desc.cynic
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { has_trait = just }
				}
				desc = lmf_spouse.1180.desc.just
			}
			desc = lmf_spouse.1180.desc.compassion
		}
		desc = lmf_spouse.1180.desc.end
	}
	theme = family

	left_portrait = {
		character = scope:focus_child
		animation = aggressive_wooden_sword
	}
	right_portrait = {
		character = primary_spouse
		animation = thinking
	}

	override_background = { reference = armory }

	trigger = {
		any_child = {
			is_child_of = root.primary_spouse
			age >= 8
			age <= 14
			is_female = yes
			has_focus = education_martial
			is_available_ai_child = yes
			prowess >= 4
			OR = {
				is_courtier_of = root
				AND = {
					root.primary_spouse = { is_playable_character = yes }
					is_courtier_of = root.primary_spouse
				}
			}
			OR = {
				has_trait = rowdy
				has_trait = bossy
				any_relation = {
					type = guardian
					is_female = yes
					has_character_modifier = ignores_gender_army_rules
				}
			}
			OR = {
				has_trait = brave
				has_trait = physique_good
				has_trait = shrewd
				has_trait = giant
				prowess >= 12
				AND = {
					religion = { exists = var:variable_ghw_unlocked }
					has_trait = zealous
				}
			}
			NOR = {
				has_trait = craven
				has_trait = physique_bad
				has_trait = weak
				has_trait = spindly
				has_trait = wheezing
				has_trait = bleeder
				has_trait = inbred
				has_trait = dwarf
				has_trait = hunchbacked
				has_trait = clubfooted
				has_trait = blind
			}
			NOR = {
				can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
				root.culture = { has_cultural_parameter = has_access_to_shieldmaidens }
				root.culture = { has_cultural_parameter = high_prowess_ignores_knight_restrictions }
				root = { has_character_flag = had_lmfmod_1500_event_daughter }
				has_character_flag = had_lmfmod_1500_event
				has_character_flag = had_lmfmod_1502_event
				has_character_flag = had_lmfmod_1504_event
				has_character_flag = might_ignore_gender_army_rules
			}
		}
		primary_spouse = {
			OR = {
				AND = {
					is_female = yes
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
				}
				AND = {
					faith = { has_doctrine_parameter = combatant_must_be_male_if_no_roco }
					faith = root.faith
					has_trait = cynical
				}
				has_trait = just
				ai_compassion >= 50
			}
			NOR = {
				has_character_flag = had_lmf_spouse_1175_event
				has_character_flag = had_lmf_spouse_1180_event
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 2
			primary_spouse = {
				is_female = yes
				can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			has_relation_rival = primary_spouse
		}
	}

	immediate = {
		primary_spouse = { add_character_flag = had_lmf_spouse_1180_event }
		add_spouse_event_variables = yes

		# find the child
		random_child = {
			limit = {
				is_child_of = root.primary_spouse
				age >= 8
				age <= 14
				is_female = yes
				has_focus = education_martial
				is_available_ai_child = yes
				prowess >= 4
				OR = {
					is_courtier_of = root
					AND = {
						root.primary_spouse = { is_playable_character = yes }
						is_courtier_of = root.primary_spouse
					}
				}
				OR = {
					has_trait = rowdy
					has_trait = bossy
					any_relation = {
						type = guardian
						is_female = yes
						has_character_modifier = ignores_gender_army_rules
					}
				}
				OR = {
					has_trait = brave
					has_trait = physique_good
					has_trait = shrewd
					has_trait = giant
					prowess >= 12
					AND = {
						religion = { exists = var:variable_ghw_unlocked }
						has_trait = zealous
					}
				}
				NOR = {
					has_trait = craven
					has_trait = physique_bad
					has_trait = weak
					has_trait = spindly
					has_trait = wheezing
					has_trait = bleeder
					has_trait = inbred
					has_trait = dwarf
					has_trait = hunchbacked
					has_trait = clubfooted
					has_trait = blind
				}
				NOR = {
					can_be_combatant_based_on_gender_trigger = { ARMY_OWNER = root }
					root.culture = { has_cultural_parameter = has_access_to_shieldmaidens }
					root.culture = { has_cultural_parameter = high_prowess_ignores_knight_restrictions }
					root = { has_character_flag = had_lmfmod_1500_event_daughter }
					has_character_flag = had_lmfmod_1500_event
					has_character_flag = had_lmfmod_1502_event
					has_character_flag = had_lmfmod_1504_event
					has_character_flag = might_ignore_gender_army_rules
				}
			}
			save_scope_as = focus_child
			add_character_flag = had_lmfmod_1504_event
		}
	}

	option = {
		name = lmf_spouse.1180.a #Very well, if you think it's best
		stress_impact = {
			base = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			zealous = minor_stress_impact_gain
		}
		custom_tooltip = bp2_yearly.1030.b.tt
		scope:focus_child = {
			add_martial_skill = 1
			add_prowess_skill = 2
			add_opinion = { target = root modifier = grateful_opinion opinion = 20 }
			add_opinion = { target = root.primary_spouse modifier = grateful_opinion opinion = 20 }
			hidden_effect = {
				education_point_acquisition_effect = yes
				add_character_flag = {
					flag = might_ignore_gender_army_rules
					years = 10
				}
			}
		}
		reverse_add_opinion = { target = primary_spouse modifier = pleased_opinion opinion = 10 }
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_zeal = -0.5
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1180.b #Absolutely not
		scope:focus_child = {
			add_opinion = { target = root modifier = disappointed_opinion opinion = -10 }
			add_opinion = { target = root.primary_spouse modifier = grateful_opinion opinion = 10 }
			stress_impact = {
				base = medium_stress_impact_gain
			}
		}
		reverse_add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -20 }
		ai_chance = {
			base = 75
		}
	}
}

# Spouse gets into argument with teenaged child
lmf_spouse.1185 = {
	type = character_event
	title = lmf_spouse.1185.t
	desc = {
		desc = lmf_spouse.1185.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { scope:fight_cause = flag:rowdy }
				desc = lmf_spouse.1185.desc.rowdy
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:bossy }
				desc = lmf_spouse.1185.desc.bossy
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:wrathful }
				desc = lmf_spouse.1185.desc.wrathful
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:arrogant }
				desc = lmf_spouse.1185.desc.arrogant
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:paranoia }
				desc = lmf_spouse.1185.desc.paranoia
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:stubborn }
				desc = lmf_spouse.1185.desc.stubborn
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:impatient }
				desc = lmf_spouse.1185.desc.impatient
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:callous }
				desc = lmf_spouse.1185.desc.callous
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:rival }
				desc = lmf_spouse.1185.desc.rival
			}
			desc = lmf_spouse.1185.desc.potential
		}
		desc = lmf_spouse.1185.desc.end
	}
	theme = family

	left_portrait = {
		character = scope:focus_child
		animation = dismissal
	}
	right_portrait = {
		character = primary_spouse
		animation = anger
	}

	override_background = { reference = sitting_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1185_event }
		any_child = {
			is_child_of = root.primary_spouse
			age > 12
			age < 20
			OR = {
				is_courtier_of = root
				is_vassal_of = root
			}
			is_available = yes
			has_recoverable_disease_trigger = no
			OR = {
				has_trait = rowdy
				has_trait = bossy
				has_trait = wrathful
				has_trait = arrogant
				has_trait = paranoid
				has_trait = stubborn
				has_trait = impatient
				has_trait = callous
				has_relation_rival = root.primary_spouse
				has_relation_potential_rival = root.primary_spouse
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = { has_personality_dominant_trigger = yes }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_annoying_trigger = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_benevolent_trigger = yes }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1185_event years = 10 }
		add_spouse_event_variables = yes

		# find child and cause of outburst
		random_child = {
			limit = {
				is_child_of = root.primary_spouse
				age > 12
				age < 20
				is_courtier_of = root
				is_available = yes
				has_recoverable_disease_trigger = no
				OR = {
					has_trait = rowdy
					has_trait = bossy
					has_trait = wrathful
					has_trait = arrogant
					has_trait = paranoid
					has_trait = stubborn
					has_trait = impatient
					has_trait = callous
					has_relation_rival = root.primary_spouse
					has_relation_potential_rival = root.primary_spouse
				}
			}
			save_scope_as = focus_child
			random_list = {
				10 = {
					trigger = { has_trait = rowdy }
					save_scope_value_as = { name = fight_cause value = flag:rowdy }
				}
				10 = {
					trigger = { has_trait = bossy }
					save_scope_value_as = { name = fight_cause value = flag:bossy }
				}
				10 = {
					trigger = { has_trait = wrathful }
					save_scope_value_as = { name = fight_cause value = flag:wrathful }
				}
				10 = {
					trigger = { has_trait = arrogant }
					save_scope_value_as = { name = fight_cause value = flag:arrogant }
				}
				10 = {
					trigger = { has_trait = paranoid }
					save_scope_value_as = { name = fight_cause value = flag:paranoid }
				}
				10 = {
					trigger = { has_trait = stubborn }
					save_scope_value_as = { name = fight_cause value = flag:stubborn }
				}
				10 = {
					trigger = { has_trait = impatient }
					save_scope_value_as = { name = fight_cause value = flag:impatient }
				}
				10 = {
					trigger = { has_trait = callous }
					save_scope_value_as = { name = fight_cause value = flag:callous }
				}
				20 = {
					trigger = { has_relation_potential_rival = root.primary_spouse }
					save_scope_value_as = { name = fight_cause value = flag:potential }
				}
				50 = {
					trigger = { has_relation_rival = root.primary_spouse }
					save_scope_value_as = { name = fight_cause value = flag:rival }
				}
			}
		}
	}

	option = {
		name = lmf_spouse.1185.a
		scope:focus_child = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
		}
		primary_spouse = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
			worsen_relationship_effect = {
				TARGET = scope:focus_child
				REASON = had_massive_argument
			}
		}
	}
}

# You get into argument with teenaged child, spouse counsels
lmf_spouse.1190 = {
	type = character_event
	title = lmf_spouse.1190.t
	desc = {
		desc = lmf_spouse.1190.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { scope:fight_cause = flag:rowdy }
				desc = lmf_spouse.1190.desc.rowdy
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:bossy }
				desc = lmf_spouse.1190.desc.bossy
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:wrathful }
				desc = lmf_spouse.1190.desc.wrathful
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:arrogant }
				desc = lmf_spouse.1190.desc.arrogant
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:paranoia }
				desc = lmf_spouse.1190.desc.paranoia
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:stubborn }
				desc = lmf_spouse.1190.desc.stubborn
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:impatient }
				desc = lmf_spouse.1190.desc.impatient
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:callous }
				desc = lmf_spouse.1190.desc.callous
			}
			triggered_desc = {
				trigger = { scope:fight_cause = flag:rival }
				desc = lmf_spouse.1190.desc.rival
			}
			desc = lmf_spouse.1190.desc.potential
		}
		desc = lmf_spouse.1190.desc.end
	}
	theme = family

	left_portrait = {
		character = scope:focus_child
		animation = dismissal
	}
	right_portrait = {
		character = root
		animation = anger
	}

	override_background = { reference = sitting_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1190_event }
		any_child = {
			age > 12
			age < 20
			OR = {
				is_courtier_of = root
				is_vassal_of = root
			}
			is_available = yes
			has_recoverable_disease_trigger = no
			OR = {
				has_trait = rowdy
				has_trait = bossy
				has_trait = wrathful
				has_trait = arrogant
				has_trait = paranoid
				has_trait = stubborn
				has_trait = impatient
				has_trait = callous
				has_relation_rival = root
				has_relation_potential_rival = root
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_personality_dominant_trigger = yes
		}
		modifier = {
			factor = 2
			has_personality_annoying_trigger = yes
		}
		modifier = {
			factor = 0.5
			has_personality_submissive_trigger = yes
		}
		modifier = {
			factor = 0.5
			has_personality_benevolent_trigger = yes
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1190_event years = 10 }
		add_spouse_event_variables = yes

		# find child and cause of outburst
		random_child = {
			limit = {
				age > 12
				age < 20
				OR = {
					is_courtier_of = root
					is_vassal_of = root
				}
				is_available = yes
				has_recoverable_disease_trigger = no
				OR = {
					has_trait = rowdy
					has_trait = bossy
					has_trait = wrathful
					has_trait = arrogant
					has_trait = paranoid
					has_trait = stubborn
					has_trait = impatient
					has_trait = callous
					has_relation_rival = root
					has_relation_potential_rival = root
				}
			}
			save_scope_as = focus_child
			random_list = {
				10 = {
					trigger = { has_trait = rowdy }
					save_scope_value_as = { name = fight_cause value = flag:rowdy }
				}
				10 = {
					trigger = { has_trait = bossy }
					save_scope_value_as = { name = fight_cause value = flag:bossy }
				}
				10 = {
					trigger = { has_trait = wrathful }
					save_scope_value_as = { name = fight_cause value = flag:wrathful }
				}
				10 = {
					trigger = { has_trait = arrogant }
					save_scope_value_as = { name = fight_cause value = flag:arrogant }
				}
				10 = {
					trigger = { has_trait = paranoid }
					save_scope_value_as = { name = fight_cause value = flag:paranoid }
				}
				10 = {
					trigger = { has_trait = stubborn }
					save_scope_value_as = { name = fight_cause value = flag:stubborn }
				}
				10 = {
					trigger = { has_trait = impatient }
					save_scope_value_as = { name = fight_cause value = flag:impatient }
				}
				10 = {
					trigger = { has_trait = callous }
					save_scope_value_as = { name = fight_cause value = flag:callous }
				}
				20 = {
					trigger = { has_relation_potential_rival = root }
					save_scope_value_as = { name = fight_cause value = flag:potential }
				}
				50 = {
					trigger = { has_relation_rival = root }
					save_scope_value_as = { name = fight_cause value = flag:rival }
				}
			}
		}
	}

	option = {
		name = lmf_spouse.1190.a
		scope:focus_child = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
		}
		stress_impact = {
			base = medium_stress_impact_gain
		}
		worsen_relationship_effect = {
			TARGET = scope:focus_child
			REASON = had_massive_argument
		}
	}
}

# Spouse passes on trait to favorite child
lmf_spouse.1195 = {
	type = character_event
	title = lmf_spouse.1195.t
	desc = lmf_spouse.1195.desc
	theme = family

	left_portrait = {
		character = scope:focus_child
		animation = laugh
	}
	right_portrait = {
		character = primary_spouse
		animation = happiness
	}

	override_background = { reference = sitting_room }

	trigger = {
		any_child = {
			is_child_of = root.primary_spouse
			age < 25
			OR = {
				is_courtier_of = root
				AND = {
					root.primary_spouse = { is_playable_character = yes }
					is_courtier_of = root.primary_spouse
				}
			}
			is_available = yes
			has_recoverable_disease_trigger = no
			save_temporary_scope_as = potential_child
			root.primary_spouse = {
				any_character_trait = {
					has_trait_category = personality
					OR = {
						any_opposite_trait = {
							scope:potential_child = { has_trait = prev }
						}
						scope:potential_child = {
							age > 12
							NOT = { has_trait = prev }
							number_of_personality_traits < 4
						}
						scope:potential_child = {
							age > 8
							NOT = { has_trait = prev }
							number_of_personality_traits < 3
						}
					}
				}
			}
			NOR = {
				has_relation_rival = root.primary_spouse
				has_relation_potential_rival = root.primary_spouse
			}
		}
		primary_spouse = {
			is_available = yes
			has_recoverable_disease_trigger = no
			trigger_if = {
				limit = { is_playable_character = yes }
				NOT = { is_at_war_with = root }
			}
			NOT = { has_character_flag = had_lmf_spouse_1195_event }
		}
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		primary_spouse = {
			add_character_flag = { flag = had_lmf_spouse_1195_event years = 10 }
		}
		add_spouse_event_variables = yes

		#find child and trait
		random_child = {
			limit = {
				is_child_of = root.primary_spouse
				age < 25
				OR = {
					is_courtier_of = root
					AND = {
						root.primary_spouse = { is_playable_character = yes }
						is_courtier_of = root.primary_spouse
					}
				}
				is_available = yes
				has_recoverable_disease_trigger = no
				save_temporary_scope_as = potential_child
				root.primary_spouse = {
					any_character_trait = {
						has_trait_category = personality
						OR = {
							any_opposite_trait = {
								scope:potential_child = { has_trait = prev }
							}
							scope:potential_child = {
								age > 12
								NOT = { has_trait = prev }
								number_of_personality_traits < 4
							}
							scope:potential_child = {
								age > 8
								NOT = { has_trait = prev }
								number_of_personality_traits < 3
							}
						}
					}
				}
				NOR = {
					has_relation_rival = root.primary_spouse
					has_relation_potential_rival = root.primary_spouse
				}
			}
			save_scope_as = focus_child
		}
		primary_spouse = {
			random_character_trait = {
				limit = {
					has_trait_category = personality
					OR = {
						any_opposite_trait = {
							scope:focus_child = { has_trait = prev }
						}
						scope:focus_child = {
							age > 12
							NOT = { has_trait = prev }
							number_of_personality_traits < 4
						}
						scope:focus_child = {
							age > 8
							NOT = { has_trait = prev }
							number_of_personality_traits < 3
						}
					}
				}
				save_scope_as = taught_trait
			}
			# and mark if root currently has an opposite to it
			if = {
				limit = {
					scope:taught_trait = {
						any_opposite_trait = {
							scope:focus_child = { has_trait = prev }
						}
					}
				}
				scope:taught_trait = {
					random_opposite_trait = {
						limit = {
							scope:focus_child = { has_trait = prev }
						}
						save_scope_as = taught_opposite_trait
					}
				}
			}
		}
	}

	option = {
		name = lmf_spouse.1195.a
		scope:focus_child = {
			if = {
				limit = { exists = scope:taught_opposite_trait }
				remove_trait_force_tooltip = scope:taught_opposite_trait
			}
			add_trait_force_tooltip = scope:taught_trait
			improve_relationship_effect = {
				TARGET = root.primary_spouse
				REASON = spent_quality_time_together
			}
		}
	}
}

# Spouse tries to secretly convert child
lmf_spouse.1200 = {
	type = character_event
	title = lmf_spouse.1200.t
	desc = lmf_spouse.1200.desc
	theme = family

	left_portrait = {
		character = primary_spouse
		animation = debating
	}
	right_portrait = {
		character = scope:focus_child
		animation = thinking
	}

	override_background = { reference = sitting_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1200_event }
		any_child = {
			is_child_of = root.primary_spouse
			is_available_ai_child = yes
			has_recoverable_disease_trigger = no
			age > 10
			is_courtier_of = root
			NOR = {
				faith = root.primary_spouse.faith
				has_relation_rival = root.primary_spouse
				has_relation_potential_rival = root.primary_spouse
			}
		}
		primary_spouse = {
			is_courtier_of = root
			learning >= 8
			NOR = {
				faith = root.faith
				has_trait = cynical
				any_secret = { type = secret_crypto_religionist }
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = { has_trait = zealous }
		}
		modifier = {
			factor = 2
			primary_spouse = { learning > 15 }
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_zeal < 0
		}
		modifier = {
			factor = 0.5
			primary_spouse = { learning < 12 }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1200_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1200.a #Allow it to continue
		add_piety = -50
		scope:focus_child = {
			set_character_faith = root.primary_spouse.faith
			add_opinion = { target = primary_spouse modifier = trust_opinion opinion = 20 }
		}
		reverse_add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 20 }
		ai_chance = {
			base = 25
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_zeal = -1.0
			}
			modifier = {
				add = 25
				has_trait = lazy
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1200.b #Intervene
		random_list = {
			50 = {
				modifier = {
					add = root.intrigue
					always = yes
				}
				desc = lmf_spouse.1200.b.success.tt
			}
			50 = {
				modifier = {
					add = root.primary_spouse.intrigue
					always = yes
				}
				desc = lmf_spouse.1200.b.secret.tt
				scope:focus_child = {
					make_character_crypto_religionist_effect = { CRYPTO_RELIGION = root.primary_spouse.faith }
					hidden_effect = {
						random_secret = {
							type = secret_crypto_religionist
							reveal_to_without_events_effect = { CHARACTER = root.primary_spouse }
						}
					}
				}
			}
		}
		reverse_add_opinion = { target = primary_spouse modifier = upset_opinion opinion = -20 }
		reverse_add_opinion = { target = scope:focus_child modifier = upset_opinion opinion = -20 }
		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_zeal = 1.0
			}
			modifier = {
				add = 25
				has_trait = diligent
			}
			modifier = {
				add = 75
				scope:focus_child = {
					any_heir_title = {}
				}
			}
			min = 1
		}
	}
}

# Rival spouse makes your life stressful
lmf_spouse.1205 = {
	type = character_event
	title = lmf_spouse.1205.t
	desc = {
		desc = lmf_spouse.1205.desc
		first_valid = {
			triggered_desc = {
				trigger = { primary_spouse = { is_playable_character = yes } }
				desc = lmf_spouse.1205.desc.ruler
			}
			desc = lmf_spouse.1205.desc.courtier
		}
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = personality_vengeful
	}

	override_background = {
		trigger = {
			is_travelling = yes
		}
		reference = terrain
	}
	override_background = {
		trigger = {
			is_travelling = no
			is_in_army = yes
		}
		reference = army_camp
	}
	override_background = {
		trigger = {
			is_travelling = no
			is_in_army = no
		}
		reference = courtyard
	}

	trigger = {
		has_relation_rival = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1205_event }
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_introverted_trigger = yes }
		}
		modifier = {
			factor = 2
			has_relation_nemesis = primary_spouse
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_malicious_trigger = yes }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_dominant_trigger = yes }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1205_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1205.a
		stress_impact = {
			base = medium_stress_impact_gain
		}
		add_character_modifier = {
			modifier = cold_shoulder_modifier
			years = 5
		}
	}
}

# Rival spouse sabotages things at the castle
lmf_spouse.1210 = {
	type = character_event
	title = lmf_spouse.1210.t
	desc = lmf_spouse.1210.desc
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = dismissal
	}
	right_portrait = {
		character = root
		animation = anger
	}

	override_background = { reference = throne_room }

	trigger = {
		has_relation_rival = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1210_event }
		primary_spouse = { is_courtier_of = root }
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_introverted_trigger = yes }
		}
		modifier = {
			factor = 2
			has_relation_nemesis = primary_spouse
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_malicious_trigger = yes }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_dominant_trigger = yes }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1210_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1210.a
		add_character_modifier = {
			modifier = spouse_sabotage_modifier
			years = 3
		}
	}
}

# Rival spouse sabotages relationship with vassal
lmf_spouse.1215 = {
	type = character_event
	title = lmf_spouse.1215.t
	desc = lmf_spouse.1215.desc
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = throne_room_bow_3
	}
	right_portrait = {
		character = root
		animation = disappointed
	}
	lower_right_portrait = scope:focus_vassal

	override_background = { reference = throne_room }

	trigger = {
		has_relation_rival = primary_spouse
		NOT = { has_character_flag = had_lmf_spouse_1215_event }
		primary_spouse = { is_courtier_of = root }
		any_vassal = {
			is_available_ai = yes
			has_recoverable_disease_trigger = no
			highest_held_title_tier > tier_barony
			NOR = {
				has_relation_nemesis = root
				has_relation_best_friend = root
				has_relation_friend = root.primary_spouse
				has_relation_lover = root.primary_spouse
				is_close_family_of = root.primary_spouse
				has_character_flag = affected_by_spouse_1215
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_introverted_trigger = yes }
		}
		modifier = {
			factor = 2
			has_relation_nemesis = primary_spouse
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_malicious_trigger = yes }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_dominant_trigger = yes }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1215_event years = 10 }
		add_spouse_event_variables = yes

		# find the vassal
		random_vassal = {
			limit = {
				is_available_ai = yes
				has_recoverable_disease_trigger = no
				highest_held_title_tier > tier_barony
				NOR = {
					has_relation_nemesis = root
					has_relation_best_friend = root
					has_relation_friend = root.primary_spouse
					has_relation_lover = root.primary_spouse
					is_close_family_of = root.primary_spouse
					has_character_flag = affected_by_spouse_1215
				}
			}
			weight = {
				base = 2
				modifier = {
					add = 3
					is_powerful_vassal_of = root
				}
				modifier = {
					add = -1
					has_relation_friend = root
				}
				modifier = {
					add = 1
					has_relation_rival = root
				}
				modifier = {
					add = 1
					NOT = { is_close_or_extended_family_of = root }
				}
			}
			save_scope_as = focus_vassal
		}
	}

	option = {
		name = lmf_spouse.1215.a
		add_prestige = medium_prestige_loss
		worsen_relationship_effect = {
			TARGET = scope:focus_vassal
			REASON = waylaid_message
		}
		scope:focus_vassal = { add_character_flag = affected_by_spouse_1215 }
	}
}

# Rival spouse refuses to take their place at the council
lmf_spouse.1220 = {
	type = character_event
	title = lmf_spouse.1220.t
	desc = lmf_spouse.1220.desc
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = dismissal
		camera = camera_event_center_pointing_left
	}
	right_portrait = {
		character = root
		animation = anger
	}

	override_background = { reference = corridor_day }

	trigger = {
		primary_spouse = {
			NOT = { has_character_flag = had_lmf_spouse_1220_event }
			has_relation_rival = root
			OR = {
				is_courtier_of = root
				is_councillor_of = root
			}
			NAND = {
				exists = var:block_hire_councillor
				var:block_hire_councillor = root
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_introverted_trigger = yes }
		}
		modifier = {
			factor = 2
			has_relation_nemesis = primary_spouse
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_malicious_trigger = yes }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_dominant_trigger = yes }
		}
	}

	immediate = {
		primary_spouse = {
			add_character_flag = { flag = had_lmf_spouse_1220_event years = 5 }
		}
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1220.a
		custom_tooltip = lmf_spouse.1120.tt
		hidden_effect = {
			fire_councillor = root.primary_spouse
			primary_spouse = {
				set_variable = {
					name = block_hire_councillor
					value = root
					years = 6
				}
			}
			trigger_event = { id = lmf_spouse.1221 days = 1850 }
		}
	}
}

lmf_spouse.1221 = {
	type = character_event
	hidden = yes

	trigger = {
		has_variable = block_hire_councillor
	}

	immediate = {
		save_scope_as = angry_spouse

		if = {
			limit = {
				var:block_hire_councillor = {
					OR = {
						is_alive = no
						is_playable_character = no
						NOT = { exists = primary_spouse }
						NOT = { primary_spouse = root }
					}
				}
			}
			remove_variable = block_hire_councillor
		}
		else_if = {
			limit = {
				var:block_hire_councillor.primary_spouse = root
				OR = {
					NOT = { has_relation_rival = root.var:block_hire_councillor }
					NOT = { has_character_flag = had_lmf_spouse_1220_event }
				}
			}
			var:block_hire_councillor = {
				send_interface_message = {
					type = event_generic_good_with_text
					title = lmf_spouse.1221.t
					desc = lmf_spouse.1221.desc
					left_icon = scope:angry_spouse
				}
			}
		}
	}
}

scripted_trigger gave_root_an_inheritable_child = {
	any_child = {
		age >= 3
		is_child_of = root.primary_spouse
		dynasty ?= root.dynasty
		has_inheritance_blocking_trait = no
		trigger_if = {
			limit = {
				root = {
					OR = {
						AND = {
							is_ruler = no
							faith = { has_doctrine_parameter = male_dominated_law }
						}
						AND = {
							is_ruler = yes
							has_realm_law = male_only_law
						}
						# we mark PREFER with 'yes' if we want to exclude girls in a male-preference situation
						AND = {
							$PREFER$ = yes
							is_ruler = yes
							has_realm_law = male_preference_law
						}
					}
				}
			}
			is_male = yes
		}
		trigger_else_if = {
			limit = {
				root = {
					OR = {
						AND = {
							is_ruler = no
							faith = { has_doctrine_parameter = female_dominated_law }
						}
						AND = {
							is_ruler = yes
							has_realm_law = female_only_law
						}
						# we mark PREFER with 'yes' if we want to exclude boys in a female-preference situation
						AND = {
							$PREFER$ = yes
							is_ruler = yes
							has_realm_law = female_preference_law
						}
					}
				}
			}
			is_female = yes
		}
		trigger_else = {
			always = yes
		}
	}
}

# Spouse doesn't want more children
lmf_spouse.1225 = {
	type = character_event
	title = lmf_spouse.1225.t
	desc = {
		desc = lmf_spouse.1225.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						NOT = {
							any_child = { even_if_dead = yes }
						}
					}
				}
				desc = lmf_spouse.1225.desc.hasnochildren
			}
			triggered_desc = {
				trigger = {
					primary_spouse = {
						any_child = {
							even_if_dead = yes
							is_child_of = root
						}
					}
				}
				desc = lmf_spouse.1225.desc.hasyourchildren
			}
			desc = lmf_spouse.1225.desc.haschildrennotyours
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						NOT = { is_attracted_to_gender_of = root }
					}
				}
				desc = lmf_spouse.1225.desc.notattracted
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { has_trait = chaste }
				}
				desc = lmf_spouse.1225.desc.chaste
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { has_trait = depressed }
				}
				desc = lmf_spouse.1225.desc.depressed
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { has_trait = lunatic }
				}
				desc = lmf_spouse.1225.desc.lunatic
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { has_trait = callous }
				}
				desc = lmf_spouse.1225.desc.callous
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { has_trait = paranoid }
				}
				desc = lmf_spouse.1225.desc.paranoid
			}
			desc = lmf_spouse.1225.desc.reclusive
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					has_inheritable_children = { TOTAL = 2 PREFER = yes }
				}
				desc = lmf_spouse.1225.desc.twoheirs
			}
			desc = lmf_spouse.1225.desc.heir
		}
		desc = lmf_spouse.1225.desc.end
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = beg
	}
	right_portrait = {
		character = root
		animation = sadness
	}

	override_background = { reference = bedchamber }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1225_event }
		fertility >= 0.20
		can_have_children_with = { CHARACTER = root.primary_spouse }
		primary_spouse = {
			is_female = yes
			age < marriage_female_fertility_cutoff_age_value
			is_pregnant = no
			fertility >= 0.20
			OR = {
				# husband already has two heirs
				root = {
					has_inheritable_children = { TOTAL = 2 PREFER = yes }
				}
				# I already gave him an heir
				gave_root_an_inheritable_child = { PREFER = yes }
			}
			# inclined to cut off more children
			OR = {
				NOT = { is_attracted_to_gender_of = root }
				has_trait = chaste
				has_trait = depressed
				has_trait = lunatic
				AND = {
					opinion = { target = root value < 30 }
					OR = {
						has_trait = callous
						has_trait = paranoid
						has_trait = reclusive
					}
				}
			}
			NOR = {
				has_character_flag = lmf_no_children
				has_relation_lover = root
				has_trait = lustful
				has_trait = family_first
				has_focus = diplomacy_family_focus
				has_focus = intrigue_temptation_focus
				has_relation_unfruitful_marriage = root
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 4
			primary_spouse = {
				NOT = { is_attracted_to_gender_of = root }
			}
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_dominant_trigger = yes }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_introverted_trigger = yes }
		}
		modifier = {
			factor = 2
			has_inheritable_children = { TOTAL = 3 PREFER = yes }
		}
		modifier = {
			factor = 2
			has_inheritable_children = { TOTAL = 4 PREFER = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 0.5
			NOT = {
				has_inheritable_children = { TOTAL = 2 PREFER = yes }
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1225_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1225.a #Very well. No more children.
		custom_tooltip = lmf_spouse.1225.a.tt
		hidden_effect = {
			set_relation_unfruitful_marriage = root.primary_spouse
		}
		primary_spouse = {
			stress_impact = {
				base = medium_stress_loss
			}
		}
		improve_relationship_effect = {
			TARGET = root.primary_spouse
			REASON = granted_request_no_more_children
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 1.0
				ai_honor = 0.5
			}
			modifier = {
				add = 100
				NOT = { is_attracted_to_gender_of = primary_spouse }
			}
			modifier = {
				add = 50
				has_trait = lazy
			}
		}
	}
	option = {
		name = lmf_spouse.1225.b #Absolutely not!
		primary_spouse = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
		}
		worsen_relationship_effect = {
			TARGET = root.primary_spouse
			REASON = refused_request_no_more_children
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = -1.0
				ai_honor = -0.5
			}
			modifier = {
				add = 50
				has_trait = diligent
			}
			modifier = {
				add = 50
				OR = {
					has_trait = lustful
					has_trait = family_first
					has_focus = diplomacy_family_focus
				}
			}
		}
	}
}

# Spouse wants more children
lmf_spouse.1230 = {
	type = character_event
	title = lmf_spouse.1230.t
	desc = {
		desc = lmf_spouse.1230.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					any_child = {
						even_if_dead = yes
						is_child_of = root.primary_spouse
						count > 0
					}
				}
				desc = lmf_spouse.1230.desc.another
			}
			desc = lmf_spouse.1230.desc.first
		}
		triggered_desc = {
			trigger = {
				primary_spouse = {
					is_playable_character = yes
					NOT = {
						has_inheritable_children = { TOTAL = 1 PREFER = yes }
					}
				}
			}
			desc = lmf_spouse.1230.desc.myheir
		}
		triggered_desc = {
			trigger = {
				NOT = {
					has_inheritable_children = { TOTAL = 1 PREFER = yes }
				}
			}
			desc = lmf_spouse.1230.desc.yourheir
		}
		triggered_desc = {
			trigger = { has_relation_unfruitful_marriage = primary_spouse }
			desc = lmf_spouse.1230.desc.unfruitful
		}
		desc = lmf_spouse.1230.desc.end
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = flirtation
		camera = camera_event_left_to_the_left
	}
	right_portrait = {
		character = root
		animation = happiness
		camera = camera_event_very_right
	}

	override_background = {
		trigger = {
			is_travelling = yes
		}
		reference = terrain
	}
	override_background = {
		trigger = {
			is_travelling = no
			is_in_army = yes
		}
		reference = ep3_relaxing_tent
	}
	override_background = {
		trigger = {
			is_travelling = no
			is_in_army = no
		}
		reference = bedchamber
	}

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1230_event }
		fertility >= 0.20
		can_have_children_with = { CHARACTER = root.primary_spouse }
		trigger_if = {
			limit = { is_female = yes }
			age < marriage_female_fertility_cutoff_age_value
			is_pregnant = no
		}
		primary_spouse = {
			fertility >= 0.20
			trigger_if = {
				limit = { is_female = yes }
				age < marriage_female_fertility_cutoff_age_value
				is_pregnant = no
			}
			OR = {
				# changed mind about cutting it off before
				AND = {
					has_relation_unfruitful_marriage = root
					OR = {
						has_relation_lover = root
						has_trait = lustful
						has_trait = family_first
						has_focus = diplomacy_family_focus
						has_focus = intrigue_temptation_focus
						NOR = {
							root = {
								has_inheritable_children = { TOTAL = 2 PREFER = yes }
							}
							gave_root_an_inheritable_child = { PREFER = yes }
						}
					}
				}
				# is a ruler and needs more heirs
				AND = {
					is_playable_character = yes
					NOT = {
						has_inheritable_children = { TOTAL = 1 PREFER = yes }
					}
				}
				# spouse is a ruler who needs more heirs
				root = {
					is_playable_character = yes
					NOT = {
						has_inheritable_children = { TOTAL = 1 PREFER = yes }
					}
				}
			}
			NOR = {
				has_character_flag = lmf_no_children
				has_relation_rival = root
				has_trait = depressed
				has_trait = lunatic
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = { has_personality_dominant_trigger = yes }
		}
		modifier = {
			factor = 2
			primary_spouse = { has_personality_submissive_trigger = yes }
		}
		modifier = {
			factor = 2
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_soulmate = primary_spouse
		}
		modifier = {
			factor = 0.5
			primary_spouse = { has_personality_introverted_trigger = yes }
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				NOT = { is_attracted_to_gender_of = root }
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1230_event years = 10 }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1230.a #Yes, let's get on that
		if = {
			limit = { has_relation_unfruitful_marriage = root.primary_spouse }
			hidden_effect = {
				remove_relation_unfruitful_marriage = root.primary_spouse
				remove_character_flag = had_lmf_spouse_1225_event
				primary_spouse = { remove_character_flag = had_lmf_spouse_1225_event }
			}
		}
		save_scope_as = actor
		primary_spouse = { save_scope_as = recipient }
		had_sex_with_effect = { CHARACTER = root.primary_spouse PREGNANCY_CHANCE = visit_pregnancy_chance }
	}
	option = {
		name = lmf_spouse.1230.b #No, I'd prefer not to
		trigger = { is_ai = no }
		reverse_add_opinion = { target = root.primary_spouse modifier = disappointed_opinion opinion = -10 }
	}
}

# Spouse kicks you out of the marriage bed
lmf_spouse.1235 = {
	type = character_event
	title = lmf_spouse.1235.t
	desc = {
		desc = lmf_spouse.1235.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { has_relation_rival = primary_spouse }
				desc = lmf_spouse.1235.desc.rival
			}
			triggered_desc = {
				trigger = {
					primary_spouse = {
						NOT = { is_attracted_to_gender_of = root }
					}
				}
				desc = lmf_spouse.1235.desc.attraction
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { has_personality_malicious_trigger = yes }
				}
				desc = lmf_spouse.1235.desc.malicious
			}
			desc = lmf_spouse.1235.desc.dominant
		}
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = dismissal
	}
	right_portrait = {
		character = root
		animation = beg
	}

	override_background = {
		trigger = {
			is_travelling = yes
		}
		reference = terrain
	}
	override_background = {
		trigger = {
			is_travelling = no
			is_in_army = yes
		}
		reference = ep3_relaxing_tent
	}
	override_background = {
		trigger = {
			is_travelling = no
			is_in_army = no
		}
		reference = bedchamber
	}

	trigger = {
		fertility >= 0.20
		can_have_children_with = { CHARACTER = root.primary_spouse }
		trigger_if = {
			limit = { is_female = yes }
			age < marriage_female_fertility_cutoff_age_value
			is_pregnant = no
		}
		primary_spouse = {
			fertility >= 0.20
			trigger_if = {
				limit = { is_female = yes }
				age < marriage_female_fertility_cutoff_age_value
				is_pregnant = no
			}
			OR = {
				has_relation_rival = root
				AND = {
					opinion = { target = root value < -20 }
					OR = {
						NOT = { is_attracted_to_gender_of = root }
						has_personality_malicious_trigger = yes
						has_personality_dominant_trigger = yes
					}
				}
			}
			NOR = {
				has_character_flag = lmf_no_children
				has_relation_lover = root
				has_relation_unfruitful_marriage = root
				has_personality_submissive_trigger = yes
				has_character_flag = had_lmf_spouse_1235_event
			}
		}
		extra_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = { has_personality_dominant_trigger = yes }
		}
		modifier = {
			factor = 2
			has_relation_rival = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_nemesis = primary_spouse
		}
	}

	immediate = {
		primary_spouse = { add_character_flag = had_lmf_spouse_1235_event }
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1235.a
		custom_tooltip = lmf_spouse.1225.a.tt
		hidden_effect = {
			set_relation_unfruitful_marriage = root.primary_spouse
			add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -20 }
			primary_spouse = {
				trigger_event = { id = lmf_spouse.1236 years = 3 }
			}
		}
	}
}

# Recheck martial bed acceptance
lmf_spouse.1236 = {
	type = character_event
	hidden = yes

	trigger = {
		has_character_flag = had_lmf_spouse_1235_event
	}

	immediate = {
		if = {
			limit = {
				OR = {
					is_married = no
					NOT = { has_relation_unfruitful_marriage = primary_spouse }
					age >= marriage_female_fertility_cutoff_age_value
				}
			}
			remove_character_flag = had_lmf_spouse_1235_event
			if = {
				limit = { has_relation_unfruitful_marriage = primary_spouse }
				hidden_effect = { remove_relation_unfruitful_marriage = root.primary_spouse }
			}
		}
		else_if = {
			limit = {
				OR = {
					has_relation_lover = primary_spouse
					has_personality_submissive_trigger = yes
					NOR = {
						has_relation_rival = primary_spouse
						AND = {
							opinion = { target = primary_spouse value <= 0 }
							OR = {
								NOT = { is_attracted_to_gender_of = primary_spouse }
								has_personality_malicious_trigger = yes
								has_personality_dominant_trigger = yes
							}
						}
					}
				}
			}
			save_scope_as = angry_spouse
			if = {
				limit = { is_ai = no }
				send_interface_message = {
					type = event_generic_good_with_text
					title = lmf_spouse.1236.t
					desc = lmf_spouse.1236.desc
					left_icon = scope:angry_spouse.primary_spouse
				}
			}
			primary_spouse = {
				send_interface_message = {
					type = event_generic_good_with_text
					title = lmf_spouse.1236.t
					desc = lmf_spouse.1236.desc
					left_icon = scope:angry_spouse
					hidden_effect = { remove_relation_unfruitful_marriage = scope:angry_spouse }
				}
			}
		}
		else = {
			trigger_event = { id = lmf_spouse.1236 years = 3 }
		}
	}
}

scripted_trigger is_appropriate_spouse_visit_character = {
	exists = location
	is_adult = yes
	is_available_ai = yes
	is_hostage = no
	opinion = { target = root.primary_spouse value >= 20 }
	reverse_opinion = { target = root.primary_spouse value >= 20 }
	NOT = { has_trait = reclusive }
	trigger_if = {
		limit = { has_relation_lover = root.primary_spouse }
		lover_is_secret_trigger = { CHARACTER = root.primary_spouse }
	}
	trigger_if = {
		limit = { is_playable_character = yes }
		is_landed_or_landless_administrative = yes
		exists = capital_province
		is_at_war = no
		NOR = {
			has_character_modifier = isolating_modifier
			capital_province.county = { has_county_modifier = isolate_capital_decision_modifier }
			capital_province.county = root.capital_province.county
		}
	}
	trigger_else = {
		is_courtier = yes
		NOT = { is_courtier_of = root }
		liege = {
			is_ai = yes
			is_landed_or_landless_administrative = yes
			exists = capital_province
			is_at_war = no
			NOR = {
				has_character_modifier = isolating_modifier
				capital_province.county = { has_county_modifier = isolate_capital_decision_modifier }
				capital_province.county = root.capital_province.county
				has_relation_rival = root
				has_relation_rival = root.primary_spouse
			}
		}
	}
	in_diplomatic_range = root.primary_spouse
}

# Spouse wants to visit distant friend/relative for a while - on their own
lmf_spouse.1240 = {
	type = character_event
	title = lmf_spouse.1240.t
	desc = {
		desc = lmf_spouse.1240.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { scope:spouse_visit_target.top_liege = root.top_liege }
				}
				desc = lmf_spouse.1240.desc.foreign
			}
			triggered_desc = {
				trigger = {
					scope:spouse_visit_target = { is_playable_character = yes }
				}
				desc = lmf_spouse.1240.desc.ruler
			}
			desc = lmf_spouse.1240.desc.courtier
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = { is_female = yes }
					scope:spouse_visit_target = {
						is_child_of = root.primary_spouse
						any_child = {
							age <= 1
							location ?= prev.location
							is_male = yes
						}
					}
				}
				desc = lmf_spouse.1240.desc.grandson
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { is_female = yes }
					scope:spouse_visit_target = {
						is_child_of = root.primary_spouse
						any_child = {
							age <= 1
							location ?= prev.location
						}
					}
				}
				desc = lmf_spouse.1240.desc.granddaughter
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { is_female = yes }
					scope:spouse_visit_target = {
						is_child_of = root.primary_spouse
						any_child = {
							count > 1
							age < 9
							location ?= prev.location
						}
					}
				}
				desc = lmf_spouse.1240.desc.grandchildren
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { is_female = yes }
					scope:spouse_visit_target = { has_trait = pregnant }
				}
				desc = lmf_spouse.1240.desc.pregnant
			}
			triggered_desc = {
				trigger = {
					primary_spouse = { is_female = yes }
					scope:spouse_visit_target = { has_recoverable_disease_trigger = yes }
				}
				desc = lmf_spouse.1240.desc.sick
			}
			triggered_desc = {
				trigger = {
					scope:spouse_visit_target = { has_relation_best_friend = root.primary_spouse }
				}
				desc = lmf_spouse.1240.desc.bestfriend
			}
			triggered_desc = {
				trigger = {
					scope:spouse_visit_target = { has_relation_friend = root.primary_spouse }
				}
				desc = lmf_spouse.1240.desc.friend
			}
			triggered_desc = {
				trigger = {
					scope:spouse_visit_target = { has_relation_lover = root.primary_spouse }
				}
				desc = lmf_spouse.1240.desc.lover
			}
			triggered_desc = {
				trigger = {
					scope:spouse_visit_target = { has_relation_potential_friend = root.primary_spouse }
				}
				desc = lmf_spouse.1240.desc.potfriend
			}
			desc = lmf_spouse.1240.desc.relation
		}
		desc = lmf_spouse.1240.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = throne_room_conversation_4
		camera = camera_event_very_left
	}
	right_portrait = {
		character = primary_spouse
		triggered_animation = {
			trigger = {
				primary_spouse = { has_personality_benevolent_trigger = yes }
			}
			animation = personality_compassionate
		}
		triggered_animation = {
			trigger = {
				primary_spouse = { has_personality_dominant_trigger = yes }
			}
			animation = personality_bold
		}
		triggered_animation = {
			trigger = {
				primary_spouse = { has_personality_malicious_trigger = yes }
			}
			animation = personality_callous
		}
		triggered_animation = {
			trigger = {
				primary_spouse = { has_personality_submissive_trigger = yes }
			}
			animation = personality_coward
		}
		animation = personality_content
		camera = camera_event_very_right
	}
	lower_right_portrait = scope:spouse_visit_target

	override_background = { reference = sitting_room }

	trigger = {
		primary_spouse = {
			is_courtier_of = root
			NOR = {
				has_character_flag = had_lmf_spouse_1240_event
				is_pregnant = yes
				has_trait = reclusive
				has_trait = depressed
				has_trait = wounded
				has_trait = infirm
				any_owned_story = { type = lmf_visit_invitation_story_cycle }
			}
			OR = {
				any_close_family_member = {
					is_close_family_of = root.primary_spouse
					is_appropriate_spouse_visit_character = yes
				}
				any_relation = {
					type = friend
					is_appropriate_spouse_visit_character = yes
				}
			}
		}
		NOR = {
			has_trait = pregnant
			is_at_war = yes
			has_character_modifier = isolating_modifier
			capital_county ?= { has_county_modifier = isolate_capital_decision_modifier }
			capital_county ?= { any_county_province = { any_province_epidemic = { count >= 1 } } }
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_relation_rival = primary_spouse
		}
		modifier = {
			factor = 2
			has_relation_nemesis = primary_spouse
		}
		modifier = {
			factor = 2
			primary_spouse.ai_sociability >= 20
		}
		modifier = {
			factor = 2
			primary_spouse.ai_sociability >= 100
		}
		modifier = {
			factor = 2
			primary_spouse.ai_energy >= 50
		}
		modifier = {
			factor = 2
			primary_spouse.ai_boldness >= 50
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_sociability <= -20
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_sociability <= -100
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_energy <= -50
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_boldness <= -50
		}
		modifier = {
			factor = 0.5
			has_trait = diligent
		}
		modifier = {
			factor = 0.5
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				any_child = {
					is_courtier_of = root
					OR = {
						age <= 3
						has_recoverable_disease_trigger = yes
					}
				}
			}
		}
	}

	immediate = {
		primary_spouse = {
			add_character_flag = { flag = had_lmf_spouse_1240_event years = 5 }
			save_scope_as = recipient
		}
		add_spouse_event_variables = yes

		# find visit target
		primary_spouse = {
			every_close_family_member = {
				limit = {
					is_close_family_of = root.primary_spouse
					is_appropriate_spouse_visit_character = yes
				}
				add_to_list = potential_spouse_visit_target
			}
			every_relation = {
				type = friend
				limit = { is_appropriate_spouse_visit_character = yes }
				add_to_list = potential_spouse_visit_target
			}
			every_relation = {
				type = potential_friend
				limit = { is_appropriate_spouse_visit_character = yes }
				add_to_list = potential_spouse_visit_target
			}
			every_relation = {
				type = lover
				limit = { is_appropriate_spouse_visit_character = yes }
				add_to_list = potential_spouse_visit_target
			}
		}
		random_in_list = {
			list = potential_spouse_visit_target
			weight = {
				base = 10
				modifier = {
					add = 10
					has_relation_lover = root.primary_spouse
				}
				modifier = {
					add = 2
					has_relation_friend = root.primary_spouse
				}
				modifier = {
					add = -5
					sex_opposite_of = root.primary_spouse
					NOT = { has_relation_lover = root.primary_spouse }
				}
				modifier = {
					add = -2
					NOT = { is_close_or_extended_family_of = root.primary_spouse }
				}
				modifier = {
					add = 5
					is_child_of = root.primary_spouse
				}
				modifier = {
					add = 5
					root.primary_spouse = { is_female = yes }
					is_child_of = root.primary_spouse
					any_child = {
						age <= 8
						location ?= prev.location
					}
				}
				modifier = {
					add = 5
					root.primary_spouse = { is_female = yes }
					is_child_of = root.primary_spouse
					any_child = {
						age <= 1
						location ?= prev.location
					}
				}
				modifier = {
					add = 5
					is_playable_character = yes
				}
				modifier = {
					add = 10
					has_trait = pregnant
					root.primary_spouse = { is_female = yes }
				}
				modifier = {
					add = 2
					reverse_opinion = { target = root.primary_spouse value >= 50 }
				}
				modifier = {
					add = 2
					reverse_opinion = { target = root.primary_spouse value >= 75 }
				}
			}
			save_scope_as = spouse_visit_target
			save_scope_as = actor
		}
	}

	option = {
		name = lmf_spouse.1240.a #Of course she may go
		stress_impact = {
			base = minor_stress_impact_gain
		}
		custom_tooltip = lmf_spouse.1240.a.tt
		if = {
			limit = {
				NOT = { scope:spouse_visit_target.top_liege = root.top_liege }
			}
			custom_tooltip = lmf_spouse.1240.a.nocouncil.tt
			hidden_effect = {
				fire_councillor = root.primary_spouse
				primary_spouse = {
					add_character_flag = temp_remove_from_council
					set_variable = { name = block_hire_councillor value = root years = 1 }
				}
			}
		}
		reverse_add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 20 }

		scope:spouse_visit_target = {
			hidden_effect = {
				set_variable = { name = visited_by_target value = root.primary_spouse }
				add_opinion = { target = root.primary_spouse modifier = agreed_to_visit_opinion }
			}
		}
		hidden_effect = {
			primary_spouse = {
				create_story = {
					type = lmf_visit_invitation_story_cycle
					save_scope_as = story
				}
				scope:story = {
					set_variable = { name = visit_target value = scope:actor }
					if = {
						limit = {
							scope:actor = { is_courtier = yes }
						}
						set_variable = { name = visit_province value = scope:actor.liege.capital_province }
						set_variable = { name = courtier_visit value = flag:yes }
					}
					else_if = {
						limit = {
							scope:actor = { exists = capital_province }
						}
						set_variable = { name = visit_province value = scope:actor.capital_province }
					}
					else = {
						set_variable = { name = visit_province value = scope:actor.location }
					}
					set_variable = { name = start_province value = scope:recipient.location }
					set_variable = { name = spouse_visiting_from value = root }
				}
				start_travel_plan = {
					destination = scope:story.var:visit_province
					on_travel_planner_cancel_event = lmf_interaction.1502
					on_arrival_event = lmf_interaction.1505
					on_arrival_destinations = all_but_last
				}
				# and give them a small safety boost
				current_travel_plan = {
					hidden_effect = {
						add_travel_plan_modifier = travel_guide_modifier
					}
				}
			}
		}

		ai_chance = {
			base = 75
		}
	}
	option = {
		name = lmf_spouse.1240.b #No, it's too dangerous. I'd prefer she stay here.
		primary_spouse = {
			stress_impact = {
				base = medium_stress_impact_gain
			}
		}
		reverse_add_opinion = { target = primary_spouse modifier = angry_opinion opinion = -20 }
		ai_chance = {
			base = 25
		}
	}
}

# Spouse visit takes place
lmf_spouse.1241 = {
	type = character_event
	hidden = yes

	immediate = {
		save_scope_as = recipient
		random_owned_story = {
			type = lmf_visit_invitation_story_cycle
			save_scope_as = story
			var:visit_target = { save_scope_as = actor }
			var:visit_province = { save_scope_as = destination }
			var:start_province = { save_scope_as = origin }
		}
		current_travel_plan ?= {
			hidden_effect = { pause_travel_plan = yes }
		}
		trigger_event = {
			id = lmf_spouse.1242
			days = { 130 200 }
		}
	}
}

# Spouse ends the visit and journeys home
lmf_spouse.1242 = {
	type = character_event
	hidden = yes

	immediate = {
		save_scope_as = visiting_spouse

		if = {
			limit = {
				exists = scope:story.var:spouse_visiting_from
				scope:story.var:spouse_visiting_from = {
					is_married = yes
					is_ai = no
					primary_spouse = root
				}
			}
			scope:story.var:spouse_visiting_from = {
				send_interface_message = {
					type = event_generic_good_with_text
					title = lmf_spouse.1242.title
					left_icon = scope:actor
					right_icon = scope:visiting_spouse
					desc = lmf_spouse.1242.desc
				}
			}
		}

		current_travel_plan ?= { resume_travel_plan = yes }
		scope:story = { end_story = yes }
		remove_character_flag = temp_remove_from_council
		remove_variable = block_hire_councillor
		improve_relationship_effect = {
			TARGET = scope:actor
			REASON = came_for_a_long_visit
		}
	}
}

# Spouse has negative stress trait
lmf_spouse.1250 = {
	type = character_event
	title = lmf_spouse.1250.t
	desc = {
		desc = lmf_spouse.1250.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						is_playable_character = yes
						exists = capital_province
					}
				}
				desc = lmf_spouse.1250.desc.ruler
			}
			desc = lmf_spouse.1250.desc.courtier
		}
		desc = lmf_spouse.1250.desc.mid
		first_valid = {
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:drunkard }
				desc = lmf_spouse.1250.desc.drunkard
			}
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:hashishiyah }
				desc = lmf_spouse.1250.desc.hashishiyah
			}
			triggered_desc = {
				trigger = {
					scope:spouse_stress = trait:rakish
					primary_spouse = {
						any_relation = {
							type = lover
							OR = {
								any_secret = {
									type = secret_lover
									is_known_by = root
									secret_target = root.primary_spouse
								}
								NOT = {
									any_secret = {
										type = secret_lover
										secret_target = root.primary_spouse
									}
								}
							}
						}
					}
				}
				desc = lmf_spouse.1250.desc.rakish.lover
			}
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:rakish }
				desc = lmf_spouse.1250.desc.rakish.nolover
			}
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:irritable }
				desc = lmf_spouse.1250.desc.irritable
			}
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:flagellant }
				desc = lmf_spouse.1250.desc.flagellant
			}
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:profligate }
				desc = lmf_spouse.1250.desc.profligate
			}
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:contrite }
				desc = lmf_spouse.1250.desc.contrite
			}
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:comfort_eater }
				desc = lmf_spouse.1250.desc.comfort_eater
			}
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:inappetetic }
				desc = lmf_spouse.1250.desc.inappetetic
			}
			desc = lmf_spouse.1250.desc.reclusive
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:same_stress }
				desc = lmf_spouse.1250.desc.same
			}
			desc = lmf_spouse.1250.desc.default
		}
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		triggered_animation = {
			trigger = { scope:spouse_stress = trait:drunkard }
			animation = wedding_drunk
		}
		triggered_animation = {
			trigger = { scope:spouse_stress = trait:hashishiyah }
			animation = delirium
		}
		triggered_animation = {
			trigger = { scope:spouse_stress = trait:rakish }
			animation = flirtation
		}
		triggered_animation = {
			trigger = { scope:spouse_stress = trait:irritable }
			animation = disgust
		}
		triggered_animation = {
			trigger = { scope:spouse_stress = trait:comfort_eater }
			animation = stress
		}
		triggered_animation = {
			trigger = { scope:spouse_stress = trait:reclusive }
			animation = throne_room_conversation_3
		}
		animation = shame
	}

	override_background = {
		trigger = {
			OR = {
				scope:spouse_stress = trait:drunkard
				scope:spouse_stress = trait:rakish
			}
		}
		reference = tavern
	}
	override_background = {
		trigger = {
			OR = {
				scope:spouse_stress = trait:flagellant
				scope:spouse_stress = trait:contrite
			}
		}
		reference = temple
	}
	override_background = {
		trigger = { scope:spouse_stress = trait:profligate }
		reference = market
	}
	override_background = {
		trigger = { scope:spouse_stress = trait:reclusive }
		reference = corridor_night
	}
	override_background = {
		trigger = {
			NOR = {
				scope:spouse_stress = trait:drunkard
				scope:spouse_stress = trait:rakish
				scope:spouse_stress = trait:flagellant
				scope:spouse_stress = trait:contrite
				scope:spouse_stress = trait:profligate
				scope:spouse_stress = trait:reclusive
			}
		}
		reference = sitting_room
	}

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1250_event }
		primary_spouse = {
			has_a_bad_stress_coping_trait_trigger = yes
			OR = {
				is_councillor_of = root
				is_playable_character = yes
			}
			stress >= lower_than_baseline_stress
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = { stress >= medium_stress }
		}
		modifier = {
			factor = 2
			primary_spouse = { stress >= high_stress }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { stress < higher_than_baseline_stress }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1250_event years = 10 }
		add_spouse_event_variables = yes

		# pick the stress trait
		primary_spouse = {
			random_character_trait = {
				limit = {
					OR = {
						this = trait:drunkard
						this = trait:hashishiyah
						this = trait:rakish
						this = trait:irritable
						this = trait:flagellant
						this = trait:profligate
						this = trait:contrite
						this = trait:comfort_eater
						this = trait:inappetetic
						this = trait:reclusive
					}
				}
				save_scope_as = spouse_stress
			}
		}
		if = {
			limit = { has_trait = scope:spouse_stress }
			save_scope_value_as = { name = same_stress value = flag:yes }
		}
	}

	option = {
		name = lmf_spouse.1250.a
		stress_impact = { base = minor_stress_gain }
		primary_spouse = {
			stress_impact = { base = massive_stress_loss }
		}
		if = {
			limit = { scope:spouse_stress = trait:flagellant }
			primary_spouse = {
				increase_wounds_no_death_effect = { REASON = flagellant }
			}
		}
		if = {
			limit = {
				scope:spouse_stress = trait:profligate
				primary_spouse = { is_playable_character = yes }
			}
			if = {
				limit = { primary_spouse = { is_playable_character = yes } }
				primary_spouse = { remove_short_term_gold = medium_gold_value }
			}
			else = {
				remove_short_term_gold = medium_gold_value
			}
		}
		if = {
			limit = { scope:spouse_stress = trait:comfort_eater }
			primary_spouse = { change_current_weight = 25 }
		}
		if = {
			limit = { scope:spouse_stress = trait:inappetetic }
			primary_spouse = { change_current_weight = -25 }
		}
		if = {
			limit = { exists = scope:same_stress }
			reverse_add_opinion = { target = primary_spouse modifier = friendliness_opinion opinion = 20 }
			hidden_effect = {
				add_opinion = { target = primary_spouse modifier = friendliness_opinion opinion = 20 }
			}
		}
		else = {
			reverse_add_opinion = { target = primary_spouse modifier = irritated_opinion opinion = -20 }
			hidden_effect = {
				add_opinion = { target = primary_spouse modifier = irritated_opinion opinion = -20 }
			}
		}
	}
}

# Spouse has positive stress trait
lmf_spouse.1260 = {
	type = character_event
	title = lmf_spouse.1260.t
	desc = {
		desc = lmf_spouse.1260.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					primary_spouse = {
						is_playable_character = yes
						exists = capital_province
					}
				}
				desc = lmf_spouse.1260.desc.ruler
			}
			desc = lmf_spouse.1260.desc.courtier
		}
		desc = lmf_spouse.1260.desc.mid
		first_valid = {
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:journaller }
				desc = lmf_spouse.1260.desc.journaller
			}
			triggered_desc = {
				trigger = { scope:spouse_stress = trait:confider }
				desc = lmf_spouse.1260.desc.confider
			}
			desc = lmf_spouse.1260.desc.athletic
		}
		first_valid = {
			triggered_desc = {
				trigger = { exists = scope:same_stress }
				desc = lmf_spouse.1260.desc.same
			}
			triggered_desc = {
				trigger = { exists = scope:can_learn_stress }
				desc = lmf_spouse.1260.desc.canlearn
			}
			desc = lmf_spouse.1260.desc.default
		}
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		triggered_animation = {
			trigger = { scope:spouse_stress = trait:journaller }
			animation = writing
		}
		animation = happiness
	}

	override_background = {
		trigger = { scope:spouse_stress = trait:journaller }
		reference = study
	}
	override_background = {
		trigger = { scope:spouse_stress = trait:athletic }
		reference = courtyard
	}
	override_background = {
		trigger = { scope:spouse_stress = trait:confider }
		reference = market
	}

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1250_event }
		primary_spouse = {
			OR = {
				is_councillor_of = root
				is_playable_character = yes
			}
			OR = {
				has_trait = journaller
				has_trait = confider
				has_trait = athletic
			}
			stress >= lower_than_baseline_stress
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = { stress >= medium_stress }
		}
		modifier = {
			factor = 2
			primary_spouse = { stress >= high_stress }
		}
		modifier = {
			factor = 0.5
			primary_spouse = { stress < higher_than_baseline_stress }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1250_event years = 10 }
		add_spouse_event_variables = yes

		# pick the stress trait
		primary_spouse = {
			random_character_trait = {
				limit = {
					OR = {
						this = trait:journaller
						this = trait:confider
						this = trait:athletic
					}
				}
				save_scope_as = spouse_stress
			}
		}
		if = {
			limit = { has_trait = scope:spouse_stress }
			save_scope_value_as = { name = same_stress value = flag:yes }
		}
		if = {
			limit = {
				NOT = { has_trait = scope:spouse_stress }
				has_two_stress_coping_traits_trigger = no
				OR = {
					AND = {
						scope:spouse_stress = trait:journaller
						learning >= high_skill_rating
					}
					AND = {
						scope:spouse_stress = trait:confider
						NOR = {
							has_trait = shy
							has_trait = arrogant
							has_trait = paranoid
						}
					}
					AND = {
						scope:spouse_stress = trait:athletic
						can_be_athletic = yes
					}
				}
			}
			save_scope_value_as = { name = can_learn_stress value = flag:yes }
		}
	}

	option = {
		name = lmf_spouse.1260.a # At least it's a healthy way to cope
		stress_impact = { base = minor_stress_loss }
		primary_spouse = {
			stress_impact = { base = massive_stress_loss }
		}
		if = {
			limit = { exists = scope:same_stress }
			reverse_add_opinion = { target = primary_spouse modifier = friendliness_opinion opinion = 20 }
			hidden_effect = {
				add_opinion = { target = primary_spouse modifier = friendliness_opinion opinion = 20 }
			}
		}
		ai_chance = {
			base = 25
		}
	}
	option = {
		name = lmf_spouse.1260.b # Maybe I could learn to be more like her?
		trigger = { exists = scope:can_learn_stress }
		primary_spouse = {
			stress_impact = { base = massive_stress_loss }
		}
		add_trait = scope:spouse_stress
		ai_chance = {
			base = 75
		}
	}
}

# Spouse is depressed
lmf_spouse.1270 = {
	type = character_event
	title = lmf_spouse.1270.t
	desc = lmf_spouse.1270.desc
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = sadness
		camera = camera_event_right
	}

	override_background = { reference = corridor_night }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1270_event }
		is_physically_able = yes
		primary_spouse = {
			has_trait = depressed
			is_available_ai = yes
			has_recoverable_disease_trigger = no
			trigger_if = {
				limit = { is_playable_character = yes }
				NOT = { is_at_war_with = root }
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse = { has_trait = depressed_genetic }
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1270_event years = 10 }
		add_spouse_event_variables = yes

		if = {
			limit = { exists = primary_spouse.capital_province }
			primary_spouse = {
				save_scope_as = home_ruler
				save_scope_as = bg_override_char
			}
		}
		else = {
			save_scope_as = home_ruler
		}
	}

	option = {
		name = lmf_spouse.1270.a # It is what it is
		if = {
			limit = { scope:home_ruler = root }
			stress_impact = { base = minor_stress_impact_gain }
		}
		primary_spouse = {
			stress_impact = { base = medium_stress_impact_gain }
		}
		ai_chance = {
			base = 75
		}
	}
	option = {
		name = lmf_spouse.1270.b # Try to gently shake her out of it
		trigger = {
			is_available = yes
			has_recoverable_disease_trigger = no
			primary_spouse = {
				has_trait = depressed_1
				OR = {
					has_relation_friend = root
					has_relation_lover = root
				}
			}
		}
		show_as_unavailable = {
			primary_spouse = {
				has_trait = depressed_1
			}
		}
		stress_impact = { base = medium_stress_impact_gain }
		primary_spouse = {
			stress_impact = { base = medium_stress_impact_gain }
		}
		random_list = {
			10 = {
				modifier = {
					trigger = { diplomacy > 7 }
					add = { value = diplomacy }
				}
				opinion_modifier = {
					who = root.primary_spouse
					opinion_target = root
					multiplier = 0.5
				}
				modifier = {
					add = 10
					has_relation_friend = primary_spouse
					has_relation_lover = primary_spouse
				}
				modifier = {
					add = 10
					has_relation_best_friend = primary_spouse
				}
				modifier = {
					add = 10
					has_relation_soulmate = primary_spouse
				}
				ai_value_modifier = {
					who = root
					ai_compassion = 0.25
				}
				custom_tooltip = lmf_spouse.1270.success.tt
				primary_spouse = {
					show_as_tooltip = {
						remove_trait_force_tooltip = depressed_1
						stress_impact = { base = minor_stress_impact_loss }
						add_opinion = { target = root modifier = grateful_opinion opinion = 20 }
					}
				}
				min = 5
				send_interface_message = {
					type = event_generic_bad_with_text
					title = lmf_army.1270.success.title
					desc = lmf_spouse.1270.success.tt
					right_icon = root.primary_spouse
					primary_spouse = {
						remove_trait_force_tooltip = depressed_1
						stress_impact = { base = minor_stress_impact_loss }
						add_opinion = { target = root modifier = grateful_opinion opinion = 20 }
					}
				}
			}
			90 = {
				custom_tooltip = lmf_spouse.1270.fail.tt
				ai_value_modifier = {
					who = root.primary_spouse
					ai_energy = -0.25
				}
				modifier = {
					trigger = { diplomacy < 7 }
					add = { value = diplomacy }
				}
				min = 50
				primary_spouse = {
					show_as_tooltip = {
						stress_impact = { base = minor_stress_impact_gain }
						add_opinion = { target = root modifier = irritated_opinion opinion = -20 }
					}
				}
				send_interface_message = {
					type = event_generic_bad_with_text
					title = lmf_army.1270.fail.title
					desc = lmf_spouse.1270.fail.tt
					right_icon = root.primary_spouse
					primary_spouse = {
						stress_impact = { base = minor_stress_impact_gain }
						add_opinion = { target = root modifier = irritated_opinion opinion = -20 }
					}
				}
			}
		}
		ai_chance = {
			base = 25
		}
	}
}

# Spouse has an aging trait
lmf_spouse.1280 = {
	type = character_event
	title = lmf_spouse.1280.t
	desc = {
		desc = lmf_spouse.1280.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { scope:aging = trait:infirm }
				desc = lmf_spouse.1280.desc.infirm
			}
			triggered_desc = {
				trigger = { scope:aging = trait:withering_mind }
				desc = lmf_spouse.1280.desc.withering_mind
			}
			triggered_desc = {
				trigger = { scope:aging = trait:clouded_eyes }
				desc = lmf_spouse.1280.desc.clouded_eyes
			}
			triggered_desc = {
				trigger = { scope:aging = trait:faltering_heart }
				desc = lmf_spouse.1280.desc.faltering_heart
			}
			triggered_desc = {
				trigger = { scope:aging = trait:fragile_bones }
				desc = lmf_spouse.1280.desc.fragile_bones
			}
			desc = lmf_spouse.1280.desc.infirm
		}
		first_valid = {
			triggered_desc = {
				trigger = { has_trait = scope:aging }
				desc = lmf_spouse.1280.desc.same
			}
			triggered_desc = {
				trigger = { has_any_aging_trait = yes }
				desc = lmf_spouse.1280.desc.other
			}
			triggered_desc = {
				trigger = { age >= 50 }
				desc = lmf_spouse.1280.desc.old
			}
			desc = lmf_spouse.1280.desc.default
		}
	}
	theme = marriage

	left_portrait = {
		character = root
		triggered_animation = {
			trigger = { scope:aging = trait:withering_mind }
			animation = stress
		}
		animation = sadness
	}
	right_portrait = {
		character = primary_spouse
		animation = worry
	}

	override_background = {
		trigger = { scope:aging = trait:withering_mind }
		reference = corridor_night
	}
	override_background = {
		trigger = { NOT = { scope:aging = trait:withering_mind } }
		reference = sitting_room
	}

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1280_event }
		primary_spouse = { has_any_aging_trait = yes }
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1280_event years = 10 }
		add_spouse_event_variables = yes

		#pick aging trait
		random_list = {
			10 = {
				trigger = { has_trait = infirm }
				save_scope_value_as = { name = aging value = trait:infirm }
			}
			30 = {
				trigger = { has_trait = withering_mind }
				save_scope_value_as = { name = aging value = trait:withering_mind }
			}
			20 = {
				trigger = {
					has_trait = clouded_eyes
					NOT = { has_trait = blind }
				}
				save_scope_value_as = { name = aging value = trait:clouded_eyes }
			}
			10 = {
				trigger = { has_trait = faltering_heart }
				save_scope_value_as = { name = aging value = trait:faltering_heart }
			}
			10 = {
				trigger = { has_trait = fragile_bones }
				save_scope_value_as = { name = aging value = trait:fragile_bones }
			}
		}
	}

	option = {
		name = {
			trigger = { NOT = { has_relation_rival = primary_spouse } }
			text = lmf_spouse.1280.a
		}
		name = {
			trigger = { has_relation_rival = primary_spouse }
			text = lmf_spouse.1280.a.rival
		}
		if = {
			limit = { has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root.primary_spouse } }
			stress_impact = {
				base = minor_stress_impact_gain
				compassionate = medium_stress_impact_gain
				family_first = minor_stress_impact_gain
				patient = minor_stress_impact_loss
			}
		}
		primary_spouse = {
			stress_impact = { base = medium_stress_impact_gain }
		}
	}
}

scripted_trigger spouse_has_reason_to_be_angry = {
	$CHARACTER$ = {
		OR = {
			has_relation_potential_rival = $TARGET$
			has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = $TARGET$ }
			opinion = { target = $TARGET$ value <= -10 }
		}
	}
}

# Made spouse mad - can it be fixed?
lmf_spouse.1290 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					spouse_has_reason_to_be_angry = { CHARACTER = root.primary_spouse TARGET = root }
				}
				desc = lmf_spouse.1290.t.reason
			}
			desc = lmf_spouse.1290.t.default
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					spouse_has_reason_to_be_angry = { CHARACTER = root.primary_spouse TARGET = root }
				}
				desc = lmf_spouse.1290.desc.reason
			}
			desc = {
				desc = lmf_spouse.1290.desc.default.start
				first_valid = {
					triggered_desc = {
						trigger = { has_relation_lover = primary_spouse }
						desc = lmf_spouse.1290.desc.lover
					}
					triggered_desc = {
						trigger = { has_relation_friend = primary_spouse }
						desc = lmf_spouse.1290.desc.friend
					}
					triggered_desc = {
						trigger = {
							reverse_opinion = { target = primary_spouse value >= 20 }
						}
						desc = lmf_spouse.1290.desc.warm
					}
					desc = lmf_spouse.1290.desc.cool
				}
				desc = lmf_spouse.1290.desc.default.end
			}
		}
		desc = lmf_spouse.1290.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = beg
	}
	right_portrait = {
		character = primary_spouse
		animation = dismissal
	}

	override_background = { reference = bedchamber }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1290_event }
		primary_spouse = {
			NOR = {
				has_relation_rival = root
				opinion = { target = root value <= -30 }
			}
		}
		trigger_if = {
			limit = {
				OR = {
					has_relation_best_friend = primary_spouse
					has_relation_soulmate = primary_spouse
				}
			}
			spouse_has_reason_to_be_angry = { CHARACTER = root.primary_spouse TARGET = root }
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse.ai_boldness >= 100
			NOT = {
				spouse_has_reason_to_be_angry = { CHARACTER = root.primary_spouse TARGET = root }
			}
		}
		modifier = {
			factor = 2
			primary_spouse.ai_vengefulness >= 100
		}
		modifier = {
			factor = 2
			primary_spouse.ai_boldness >= high_positive_ai_value
			NOT = {
				spouse_has_reason_to_be_angry = { CHARACTER = root.primary_spouse TARGET = root }
			}
		}
		modifier = {
			factor = 2
			primary_spouse.ai_vengefulness >= high_positive_ai_value
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_boldness < 0
			NOT = {
				spouse_has_reason_to_be_angry = { CHARACTER = root.primary_spouse TARGET = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_vengefulness < 0
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_boldness < high_negative_ai_value
			NOT = {
				spouse_has_reason_to_be_angry = { CHARACTER = root.primary_spouse TARGET = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_vengefulness < high_negative_ai_value
		}
		modifier = {
			factor = 0.5
			reverse_opinion = { target = primary_spouse value >= 20 }
		}
		modifier = {
			factor = 0.5
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_lover = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_soulmate = primary_spouse
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1290_event years = 20 }
		add_spouse_event_variables = yes
		primary_spouse = { save_scope_as = angry_spouse }
	}

	option = {
		name = lmf_spouse.1290.a # I can mend things
		stress_impact = {
			base = medium_stress_gain
			calm = minor_stress_impact_loss
			patient = minor_stress_impact_loss
			wrathful = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			stubborn = minor_stress_impact_gain
		}
		duel = {
			skill = diplomacy
			value = 12
			60 = {
				opinion_modifier = {
					who = scope:angry_spouse
					opinion_target = root
					multiplier = 0.5
					max = 20
					min = -20
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
				}
				min = 5
				desc = lmf_spouse.1290.a.success
				send_interface_toast = {
					title = lmf_spouse.1290.a.success
					left_icon = root
					right_icon = scope:angry_spouse
					if = {
						limit = {
							OR = {
								has_relation_best_friend = scope:angry_spouse
								has_relation_soulmate = scope:angry_spouse
							}
						}
						reverse_add_opinion = { modifier = apologized_opinion target = scope:angry_spouse opinion = 30 }
					}
					else = {
						improve_relationship_effect = {
							TARGET = scope:angry_spouse
							REASON = spouse_apologized_profusely
						}
					}
				}
			}
			40 = {
				modifier = {
					add = 20
					spouse_has_reason_to_be_angry = { CHARACTER = root.primary_spouse TARGET = root }
				}
				ai_value_modifier = {
					who = scope:angry_spouse
					ai_vengefulness = 1
					min = -20
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
				}
				min = 10
				desc = lmf_spouse.1290.a.failure
				send_interface_toast = {
					title = lmf_spouse.1290.a.failure
					left_icon = root
					right_icon = scope:angry_spouse
					reverse_add_opinion = { modifier = disgusted_opinion target = scope:angry_spouse opinion = -20 }
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				diplomacy >= 15
			}
			modifier = {
				add = 50
				diplomacy >= 18
			}
			ai_value_modifier = {
				ai_energy = 0.5
				ai_rationality = 0.5
			}
			min = 0
		}
	}
	option = {
		name = lmf_spouse.1290.b # Better to let sleeping dogs lie
		ai_chance = {
			base = 50
			modifier = {
				add = 50
				spouse_has_reason_to_be_angry = { CHARACTER = root.primary_spouse TARGET = root }
			}
			modifier = {
				add = 50
				stress > normal_baseline_stress
			}
			modifier = {
				add = 50
				stress >= high_medium_stress
			}
			modifier = {
				add = 50
				diplomacy <= 9
			}
			modifier = {
				add = 50
				diplomacy <= 6
			}
			ai_value_modifier = {
				ai_energy = -0.5
				ai_rationality = -0.5
			}
			min = 1
		}
	}
}

# Spouse tries to make amends
lmf_spouse.1300 = {
	type = character_event
	title = lmf_spouse.1300.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					spouse_has_reason_to_be_angry = { CHARACTER = root TARGET = root.primary_spouse }
				}
				desc = lmf_spouse.1300.desc.reason
			}
			desc = lmf_spouse.1300.desc.default
		}
		desc = lmf_spouse.1300.desc.mid
		first_valid = {
			triggered_desc = {
				trigger = {
					spouse_has_reason_to_be_angry = { CHARACTER = root TARGET = root.primary_spouse }
				}
				desc = lmf_spouse.1300.desc.reason2
			}
			desc = lmf_spouse.1300.desc.default2
		}
		desc = lmf_spouse.1300.desc.end
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = beg
	}
	right_portrait = {
		character = root
		animation = dismissal
	}

	override_background = { reference = bedchamber }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1290_event }
		primary_spouse = {
			NOR = {
				has_relation_rival = root
				has_relation_friend = root
				reverse_opinion = { target = root value <= -30 }
				opinion = { target = root value <= -30 }
				reverse_opinion = { target = root value >= 20 }
				opinion = { target = root value >= 20 }
				has_personality_malicious_trigger = yes
			}
		}
		trigger_if = {
			limit = { has_relation_lover = root }
			spouse_has_reason_to_be_angry = { CHARACTER = root TARGET = root.primary_spouse }
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse.ai_honor >= 100
		}
		modifier = {
			factor = 2
			primary_spouse.ai_honor >= 50
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_honor <= -100
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_honor <= -50
		}
		modifier = {
			factor = 0.5
			spouse_has_reason_to_be_angry = { CHARACTER = root TARGET = root.primary_spouse }
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1290_event years = 20 }
		add_spouse_event_variables = yes
		primary_spouse = { save_scope_as = angry_spouse }
	}

	option = {
		name = lmf_spouse.1300.a #Yes, I'd like things to be better
		improve_relationship_effect = {
			TARGET = scope:angry_spouse
			REASON = was_apologized_to_profusely
		}
		ai_chance = {
			base = 75
			ai_value_modifier = {
				ai_vengefulness = -1
				ai_compassion = 1
			}
			min = 1
		}
	}
	option = {
		name = lmf_spouse.1300.b #No, things are fine as they are
		reverse_add_opinion = { modifier = disappointed_opinion target = scope:angry_spouse opinion = -10 }
		ai_chance = {
			base = 25
		}
	}
}

# Spouse bonds with you over good child
lmf_spouse.1310 = {
	type = character_event
	title = lmf_spouse.1310.t
	desc = {
		desc = lmf_spouse.1310.desc.start
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:good_child = {
						is_courtier_of = root
						is_adult = no
					}
				}
				desc = lmf_spouse.1310.desc.courtier.child
			}
			triggered_desc = {
				trigger = {
					scope:good_child = {
						is_courtier_of = root
					}
				}
				desc = lmf_spouse.1310.desc.courtier.adult
			}
			desc = lmf_spouse.1310.desc.default
		}
		desc = lmf_spouse.1310.desc.mid
		first_valid = {
			triggered_desc = {
				trigger = { has_relation_rival = primary_spouse }
				desc = lmf_spouse.1310.desc.rival
			}
			triggered_desc = {
				trigger = { has_relation_lover = primary_spouse }
				desc = lmf_spouse.1310.desc.lover
			}
			triggered_desc = {
				trigger = { has_relation_friend = primary_spouse }
				desc = lmf_spouse.1310.desc.friend
			}
			triggered_desc = {
				trigger = { reverse_opinion = { target = primary_spouse value >= 20 } }
				desc = lmf_spouse.1310.desc.warm
			}
			desc = lmf_spouse.1310.desc.cool
		}
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = throne_room_conversation_3
	}
	right_portrait = {
		character = primary_spouse
		animation = happiness
	}
	lower_right_portrait = scope:good_child

	override_background = { reference = courtyard }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1310_event }
		any_child = {
			is_child_of = root.primary_spouse
			is_available_ai = yes
			has_recoverable_disease_trigger = no
			age <= 20
			OR = {
				is_courtier_of = root
				is_vassal_of = root
				liege ?= { is_vassal_of = root }
			}
			number_of_personality_traits > 2
			num_virtuous_traits = { value > 0 target = root.faith }
			num_sinful_traits = { value < 1 target = root.faith }
			is_malformed_trigger = no
			NOR = {
				has_relation_rival = root
				has_relation_rival = root.primary_spouse
				has_relation_potential_rival = root
				has_relation_potential_rival = root.primary_spouse
				has_trait = denounced
				has_trait = decadent
				has_trait = pregnant
				has_trait = depressed
				has_trait = lunatic
				has_trait = possessed
				has_trait = intellect_bad
				any_character_trait = { is_negative_ruler_trait = yes }
				has_any_shunned_or_criminal_trait_in_faith_trigger = { CHARACTER = this FAITH = root.faith }
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 0.5
			primary_spouse = {
				has_simplified_revenge_opinion_against_character_trigger = { CHARACTER = root }
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse = {
				OR = {
					has_opinion_modifier = { modifier = unfaithful_spouse_discovered_opinion target = root }
					has_opinion_modifier = { modifier = unfaithful_spouse_exposed_opinion target = root }
					has_opinion_modifier = { modifier = betrayed_our_promise target = root }
				}
			}
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1310_event years = 20 }
		add_spouse_event_variables = yes

		# find the good child
		random_child = {
			limit = {
				is_child_of = root.primary_spouse
				is_available_ai = yes
				has_recoverable_disease_trigger = no
				age <= 20
				OR = {
					is_courtier_of = root
					is_vassal_of = root
					liege ?= { is_vassal_of = root }
				}
				number_of_personality_traits > 2
				num_virtuous_traits = { value > 0 target = root.faith }
				num_sinful_traits = { value < 1 target = root.faith }
				is_malformed_trigger = no
				NOR = {
					has_relation_rival = root
					has_relation_rival = root.primary_spouse
					has_relation_potential_rival = root
					has_relation_potential_rival = root.primary_spouse
					has_trait = denounced
					has_trait = decadent
					has_trait = pregnant
					has_trait = depressed
					has_trait = lunatic
					has_trait = possessed
					has_trait = intellect_bad
					any_character_trait = { is_negative_ruler_trait = yes }
					has_any_shunned_or_criminal_trait_in_faith_trigger = { CHARACTER = this FAITH = root.faith }
				}
			}
			weight = {
				base = 5
				modifier = {
					add = 10
					num_virtuous_traits = { value > 1 target = root.faith }
				}
				modifier = {
					add = 5
					has_good_congenital_traits_trigger = yes
				}
				modifier = {
					add = -4
					has_trait = beauty_bad
				}
			}
			save_scope_as = good_child
		}
	}

	option = {
		name = lmf_spouse.1310.a
		reverse_add_opinion = { target = primary_spouse modifier = respect_opinion opinion = 20 }
		hidden_effect = {
			add_opinion = { target = primary_spouse modifier = respect_opinion opinion = 20 }
		}
	}
}

# All our children are grown now
lmf_spouse.1320 = {
	type = character_event
	title = lmf_spouse.1320.t
	desc = lmf_spouse.1320.desc
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = sadness
	}
	right_portrait = {
		character = root
		animation = love
	}

	override_background = { reference = study }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1320_event }
		# has at least four living adult children
		any_child = {
			count > 3
			is_child_of = root.primary_spouse
			is_adult = yes
			is_physically_able = yes
		}
		# none of whom are courtiers any longer
		NOT = {
			any_child = {
				is_child_of = root.primary_spouse
				is_courtier_of = root
			}
		}
		primary_spouse = {
			is_female = yes
			age > define:NChildbirth|MAX_FEMALE_REPRODUCTION_AGE
			is_pregnant = no
			is_courtier_of = root
			has_relation_lover = root
			NOT = { has_relation_rival = root }
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = had_lmf_spouse_1320_event
		add_spouse_event_variables = yes
	}

	option = {
		name = lmf_spouse.1320.a
		stress_impact = {
			base = medium_stress_loss
		}
		primary_spouse = {
			stress_impact = {
				base = medium_stress_loss
			}
		}
	}
}

# Spouse sad that a relative has died
lmf_spouse.1330 = {
	type = character_event
	title = lmf_spouse.1330.t
	desc = {
		desc = lmf_spouse.1330.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { scope:dead_relative = { days_since_death <= 30 } }
				desc = lmf_spouse.1330.desc.month
			}
			triggered_desc = {
				trigger = { scope:dead_relative = { days_since_death <= 180 } }
				desc = lmf_spouse.1330.desc.6month
			}
			desc = lmf_spouse.1330.desc.year
		}
		first_valid = {
			triggered_desc = {
				trigger = { has_relation_rival = primary_spouse }
				desc = lmf_spouse.1330.desc.rival
			}
			triggered_desc = {
				trigger = { has_relation_lover = primary_spouse }
				desc = lmf_spouse.1330.desc.lover
			}
			triggered_desc = {
				trigger = { has_relation_friend = primary_spouse }
				desc = lmf_spouse.1330.desc.friend
			}
			desc = lmf_spouse.1330.desc.default
		}
		desc = lmf_spouse.1330.desc.end
	}
	theme = marriage

	left_portrait = {
		character = primary_spouse
		animation = sadness
	}
	lower_right_portrait = scope:dead_relative

	override_background = { reference = temple }

	trigger = {
		primary_spouse = {
			NOT = { has_character_flag = had_lmf_spouse_1330_event }
			any_close_family_member = {
				even_if_dead = yes
				is_alive = no
				is_close_family_of = root.primary_spouse
				NOT = { is_close_family_of = root }
				days_since_death <= 365
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = root.primary_spouse }
		}
		modifier = {
			factor = 0.5
			has_relation_rival = primary_spouse
		}
	}

	immediate = {
		primary_spouse = {
			add_character_flag = { flag = had_lmf_spouse_1330_event years = 5 }
			save_scope_as = bg_override_char
		}
		add_spouse_event_variables = yes

		# find the relative
		primary_spouse = {
			random_close_family_member = {
				even_if_dead = yes
				limit = {
					is_alive = no
					is_close_family_of = root.primary_spouse
					NOT = { is_close_family_of = root }
					days_since_death <= 365
				}
				save_scope_as = dead_relative
			}
		}
	}

	option = {
		name = lmf_spouse.1330.a
		primary_spouse = {
			stress_impact = {
				base = medium_stress_loss
			}
			add_opinion = { target = root modifier = grateful_opinion opinion = 10 }
		}
	}
}

# Spouse wants bastard child sent away
lmf_spouse.1340 = {
	type = character_event
	title = lmf_spouse.1340.t
	desc = {
		desc = lmf_spouse.1340.desc.start
		first_valid = {
			triggered_desc = {
				trigger = { scope:bastard_child = { is_adult = no } }
				desc = lmf_spouse.1340.desc.child
			}
			desc = lmf_spouse.1340.desc.adult
		}
		desc = lmf_spouse.1340.desc.end
	}
	theme = marriage

	left_portrait = {
		character = root
		animation = stress
	}
	right_portrait = {
		character = primary_spouse
		animation = disapproval
	}
	lower_right_portrait = scope:bastard_child

	override_background = { reference = sitting_room }

	trigger = {
		NOT = { has_character_flag = had_lmf_spouse_1340_event }
		# has a bastard at court
		any_child = {
			has_trait = bastard
			is_courtier_of = root
			NOR = {
				is_child_of = root.primary_spouse
				is_consort_of = root
				reverse_opinion = { target = root.primary_spouse value >= 10 }
				has_any_good_relationship_with_character_trigger = { CHARACTER = root.primary_spouse }
			}
		}
		# spouse is likely to object
		primary_spouse = {
			is_illegitimate = no
			has_dynasty = yes
			NOR = {
				has_trait = forgiving
				has_trait = trusting
				has_trait = compassionate
				has_personality_submissive_trigger = yes
				any_child = {
					even_if_dead = yes
					is_illegitimate = no
				}
			}
		}
		standard_spouse_availability_trigger = yes
	}

	weight_multiplier = {
		base = 1
		modifier = {
			factor = 2
			primary_spouse.ai_vengefulness >= 100
		}
		modifier = {
			factor = 2
			primary_spouse.ai_compassion <= -100
		}
		modifier = {
			factor = 2
			primary_spouse.ai_boldness >= 50
		}
		modifier = {
			factor = 2
			primary_spouse = {
				is_playable_character = yes
				highest_held_title_tier >= root.highest_tier_minus_1
			}
		}
		modifier = {
			factor = 2
			primary_spouse = {
				has_dynasty = yes
				dynasty.dynasty_prestige_level >= 5
			}
		}
		modifier = {
			factor = 0.5
			primary_spouse.ai_boldness < 0
		}
		modifier = {
			factor = 0.5
			has_relation_friend = primary_spouse
		}
		modifier = {
			factor = 0.5
			has_relation_rival = primary_spouse
		}
	}

	immediate = {
		add_character_flag = { flag = had_lmf_spouse_1340_event years = 10 }
		add_spouse_event_variables = yes

		# find the bastard
		random_child = {
			limit = {
				has_trait = bastard
				is_courtier_of = root
				NOR = {
					is_child_of = root.primary_spouse
					is_consort_of = root
					reverse_opinion = { target = root.primary_spouse value >= 10 }
					has_any_good_relationship_with_character_trigger = { CHARACTER = root.primary_spouse }
				}
			}
			weight = {
				base = 1
				modifier = {
					add = {
						value = age
						multiply = 5
					}
				}
			}
			save_scope_as = bastard_child
		}

		# see if there's somewhere to send him
		random_vassal = {
			limit = {
				is_ai = yes
				OR = {
					has_relation_friend = root
					has_relation_friend = scope:bastard_child
					is_close_or_extended_family_of = scope:bastard_child
				}
				NOR = {
					has_any_bad_relationship_with_character_trigger = { CHARACTER = root }
					has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:bastard_child }
					is_close_family_of = root.primary_spouse
					is_at_war_with = root
					this = root.primary_spouse
				}
			}
			weight = {
				base = 5
				modifier = {
					add = 10
					has_any_good_relationship_with_character_trigger = { CHARACTER = scope:bastard_child }
				}
				modifier = {
					add = 5
					has_any_good_relationship_with_character_trigger = { CHARACTER = root }
				}
				modifier = {
					add = 5
					is_close_family_of = scope:bastard_child
				}
				modifier = {
					add = -4
					highest_held_title_tier < root.highest_tier_minus_1
				}
				modifier = {
					add = 3
					is_illegitimate = yes
				}
				modifier = {
					add = 5
					is_councillor_of = root
				}
			}
			save_scope_as = bastard_home
		}
	}

	option = {
		name = lmf_spouse.1340.a # Very well, I'll send him to a vassal
		trigger = { exists = scope:bastard_home }
		stress_impact = {
			just = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			diligent = medium_stress_impact_gain
			arbitrary = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
		}
		reverse_add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 10 }
		scope:bastard_child = {
			worsen_relationship_effect = {
				TARGET = root.primary_spouse
				REASON = had_me_sent_away_from_court
			}
			hidden_effect = {
				every_traveling_family_member = {
					limit = {
						NOT = { is_consort_of = root }
						trigger_if = {
							limit = { is_sibling_of = scope:bastard_child }
							NOR = {
								has_any_court_position = yes
								is_knight_of = root
								is_councillor_of = root
							}
						}
					}
					add_to_temporary_list = kicked_family
				}
			}
		}

		every_in_list = {
			list = kicked_family
			if = {
				limit = { has_character_flag = will_not_leave }
				remove_character_flag = will_not_leave
			}
			scope:bastard_home = { add_courtier = prev }
		}

		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 0.5
			}
			opinion_modifier = {
				who = root
				opinion_target = root.primary_spouse
				multiplier = 1
			}
		}
	}
	option = {
		name = lmf_spouse.1340.b # Fine. Out he goes. Are you happy?
		stress_impact = {
			just = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
			diligent = medium_stress_impact_gain
			arbitrary = minor_stress_impact_loss
			callous = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
		}
		if = {
			limit = { is_landless_adventurer = yes }
			add_prestige = minor_prestige_loss
		}
		else_if = {
			limit = {
				scope:bastard_child = { is_lowborn = yes }
			}
			add_prestige = minor_prestige_loss
		}
		else = {
			add_prestige = medium_prestige_loss
		}
		reverse_add_opinion = { target = primary_spouse modifier = grateful_opinion opinion = 10 }

		if = {
			limit = {
				scope:bastard_child = {
					can_set_relation_rival_trigger = { CHARACTER = root.primary_spouse }
				}
			}
			scope:bastard_child = {
				set_relation_rival = {
					target = root.primary_spouse
					reason = had_me_sent_away_from_court
				}
			}
		}

		kick_out_courtier_effect = { KICKED = scope:bastard_home KICKER = root }
		scope:bastard_child = {
			if = {
				limit = { has_character_flag = will_not_leave }
				remove_character_flag = will_not_leave
			}
		}
		
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = 1
				ai_compassion = 0.5
			}
			opinion_modifier = {
				who = root
				opinion_target = root.primary_spouse
				multiplier = 1
			}
			modifier = {
				factor = 0
				exists = scope:bastard_home
			}
		}
	}
	option = {
		name = lmf_spouse.1340.c # No. He's my son and my responsibility.
		worsen_relationship_effect = {
			TARGET = root.primary_spouse
			REASON = refused_to_kick_bastard_child
		}
		scope:bastard_child = {
			worsen_relationship_effect = {
				TARGET = root.primary_spouse
				REASON = demanded_I_be_ejected_from_court
			}
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_honor = -1
				ai_compassion = -0.5
			}
			opinion_modifier = {
				who = root
				opinion_target = scope:bastard_child
				multiplier = 1
			}
		}
	}
}

