#############################################
#
# Events for Family Members
#
# Event ID 37000-37999 is reserved
#
#############################################

###################################################
# Relative demands a title
###################################################

# Relative demands inheritance due to ambition
character_event = {
	id = 37000
	desc = EVTDESC37000

	picture = {
		picture = GFX_evt_daughter_asking_mother
		trigger = { is_female = yes }
	}
	picture = {
		picture = GFX_evt_son_asking_father
		trigger = { is_female = no }
	}

	is_triggered_only = yes # 00_ambitions.txt, obj_wants_landed_title, creation_effect; event 37004

	only_capable = yes
	prisoner = no
	lacks_dlc = "Conclave"

	trigger = {
		has_ambition = obj_wants_landed_title
		age >= 20

		trigger_if = {
			limit = { is_female = yes }

			OR = {
				has_law = enatic_succession
				has_law = enatic_cognatic_succession
				has_law = true_cognatic_succession
			}
		}
		trigger_else = {
			OR = {
				has_law = agnatic_succession
				has_law = cognatic_succession
				has_law = true_cognatic_succession
			}
		}

		liege = {
			is_close_relative = ROOT
			war = no

			any_demesne_title = {
				can_be_given_away = yes
				tier = COUNT
				is_feudal = yes

				location = {
					is_capital = no
				}
			}
		}

		NOR = {
			has_character_flag = flag_denied_title
			has_character_flag = flag_promised_title
		}
	}

	fail_trigger_effect = {
		if = {
			limit = { has_ambition = obj_wants_landed_title }

			repeat_event = {
				id = 37000
				months = 3
			}
		}
	}

	option = {
		name = EVTOPTA37000 # Ask liege for a title

		liege = {
			show_scope_change = no

			character_event = {
				id = 37001
				days = 3
				tooltip = EVTTOOLTIP37001
			}
		}
	}
}

# Liege responds to the request
character_event = {
	id = 37001
	desc = EVTDESC37001

	picture = {
		picture = GFX_evt_daughter_asking_mother
		trigger = { is_female = yes }
	}
	picture = {
		picture = GFX_evt_son_asking_father
		trigger = { is_female = no }
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTA37001 # Promise that you'll arrange it

		FROM = {
			show_scope_change = no

			character_event = {
				id = 37002
				tooltip = EVTTOOLTIP37002
			}
		}

		ai_chance = {
			factor = 10

			mult_modifier = {
				factor = 0.25
				demesne_efficiency >= 1.5
			}

			mult_modifier = {
				factor = 0.25
				demesne_efficiency >= 2.0
			}

			mult_modifier = {
				factor = 5
				demesne_efficiency < 1.1
			}

			mult_modifier = {
				factor = 0.1

				primary_title = {
					has_law = succ_gavelkind
				}
			}

			mult_modifier = {
				factor = 10
				FROM = { is_primary_heir = yes }
			}
		}
	}

	option = {
		name = EVTOPTB37001 # Say he's not ready yet

		trigger = { diplomacy < 8 }

		FROM = {
			show_scope_change = no

			character_event = {
				id = 37004
				tooltip = EVTTOOLTIP37004
			}
		}

		if = {
			limit = {
				ai = no
				independent = yes

				FROM = {
					has_character_flag = flag_later_title
					practical_age < 65

					NOR = {
						trait = content
						trait = patient
						trait = craven
					}
				}
			}

			custom_tooltip = { text = evt_relative_might_revolt }
		}
	}

	option = {
		name = {
			text = EVTOPTC37001 # Mention a Church career...
			trigger = { religion_group = christian }
		}
		name = {
			text = EVTOPTD37001 # Diplomatically refuse
			trigger = {
				NOT = { religion_group = christian }
			}
		}

		tooltip_info = diplomacy

		trigger = { diplomacy >= 8 }

		FROM = {
			show_scope_change = no

			character_event = {
				id = 37003
				tooltip = EVTTOOLTIP37003
			}
		}
	}
}

# The relative is filled with anticipation
character_event = {
	id = 37002
	desc = EVTDESC37002

	picture = {
		picture = GFX_evt_daughter_asking_mother
		trigger = { is_female = yes }
	}

	picture = {
		picture = GFX_evt_son_asking_father
		trigger = { is_female = no }
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTA37002 # It had better not be hollow words...

		opinion = {
			name = opinion_promised_title
			who = FROM
			years = 3
		}

		set_character_flag = flag_promised_title

		add_character_modifier = {
			name = promised_a_title
			duration = -1
		}

		if = {
			limit = { trait = ambitious }

			character_event = {
				id = 37005
				years = 1
				random = 50
			}
		}
		else_if = {
			limit = {
				OR = {
					trait = slothful
					trait = content
				}
			}

			character_event = {
				id = 37005
				days = 865
				random = 200
			}
		}
		else = {
			character_event = {
				id = 37005
				days = 385
				random = 200
			}
		}
	}
}

# The relative is deeply offended
character_event = {
	id = 37003
	desc = EVTDESC37003
	picture = GFX_evt_bad_news

	is_triggered_only = yes

	option = {
		name = EVTOPTA37003 # This will not stand!

		opinion = {
			name = opinion_denied_title
			who = FROM
			years = 10
		}

		set_character_flag = flag_denied_title
		set_character_flag = obj_landed_title
		cancel_ambition = yes
	}
}

# The relative is disappointed
character_event = {
	id = 37004
	desc = EVTDESC37004
	picture = GFX_evt_bad_news

	is_triggered_only = yes

	option = {
		name = EVTOPTE37004 # I can accept this

		set_character_flag = obj_landed_title
		cancel_ambition = yes

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 5.0
				trait = content
			}

			mult_modifier = {
				factor = 5.0
				trait = humble
			}

			mult_modifier = {
				factor = 2.0
				trait = charitable
			}

			mult_modifier = {
				factor = 2.0
				trait = kind
			}
		}
	}

	option = {
		name = EVTOPTA37004 # I'll ask again later...

		trigger = {
			NOT = { has_character_flag = flag_later_title }
		}

		set_character_flag = flag_later_title

		if = {
			limit = {
				trait = slothful
				trait = content
			}

			character_event = {
				id = 37000
				years = 15
				random = 4563 # 12.5 years
			}
		}
		else_if = {
			limit = {
				OR = {
					trait = slothful
					trait = content
				}

				NOR = {
					trait = ambitious
					trait = diligent
				}
			}

			character_event = {
				id = 37000
				years = 9
				random = 180
			}
		}
		else = {
			character_event = {
				id = 37000
				years = 5
				random = 180
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 2.0
				trait = greedy
			}

			mult_modifier = {
				factor = 2.0
				trait = proud
			}

			mult_modifier = {
				factor = 5.0
				trait = ambitious
			}

			mult_modifier = {
				factor = 5.0
				trait = envious
			}
		}
	}

	option = {
		name = EVTOPTB37004 # Not again!

		trigger = { has_character_flag = flag_later_title }

		opinion = {
			name = opinion_denied_title
			who = FROM
			years = 10
		}

		set_character_flag = obj_landed_title
		cancel_ambition = yes

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 2.0
				trait = greedy
			}

			mult_modifier = {
				factor = 2.0
				trait = proud
			}

			mult_modifier = {
				factor = 5.0
				trait = ambitious
			}

			mult_modifier = {
				factor = 5.0
				trait = envious
			}
		}
	}

	option = {
		name = EVTOPTB37007 # I WILL have what is mine!

		trigger = {
			has_character_flag = flag_later_title
			practical_age < 65

			NOR = {
				trait = content
				trait = patient
				trait = craven
			}

			liege = {
				independent = yes
			}
		}

		opinion = {
			name = opinion_broken_title_promise
			who = FROM
			years = 10
		}

		clr_character_flag = flag_promised_title
		remove_character_modifier = promised_a_title
		set_character_flag = flag_denied_title

		character_event = {
			id = 37010
			days = 45
		}

		ai_chance = {
			factor = 100

			mult_modifier = {
				factor = 2.5
				trait = ambitious
			}

			mult_modifier = {
				factor = 5.0
				religion_group = muslim
			}

			mult_modifier = {
				factor = 0.25
				trait = slothful
			}
		}
	}
}

# Relative reminds liege of promised title
character_event = {
	id = 37005
	desc = EVTDESC37005

	picture = {
		picture = GFX_evt_daughter_asking_mother
		trigger = { is_female = yes }
	}
	picture = {
		picture = GFX_evt_son_asking_father
		trigger = { is_female = no }
	}

	is_triggered_only = yes

	has_character_flag = flag_promised_title
	only_capable = yes
	prisoner = no

	trigger = {
		independent = no
		is_ruler = no
		has_ambition = obj_wants_landed_title

		liege = {
			war = no

			any_demesne_title = {
				can_be_given_away = yes
				tier = COUNT
				is_feudal = yes

				location = {
					is_capital = no
				}
			}
		}
	}

	option = {
		name = EVTOPTA37005 # Ask liege for a title

		liege = {
			show_scope_change = no

			character_event = {
				id = 37006
				tooltip = EVTTOOLTIP37006
			}
		}
	}
}

# Liege responds to the reminder
character_event = {
	id = 37006
	desc = EVTDESC37006

	picture = {
		picture = GFX_evt_daughter_asking_mother
		trigger = { is_female = yes }
	}
	picture = {
		picture = GFX_evt_son_asking_father
		trigger = { is_female = no }
	}

	is_triggered_only = yes

	trigger = {
		FROM = { is_alive = yes }
	}

	option = {
		name = EVTOPTA37006 # Oh, very well!

		random_demesne_title = {
			show_scope_change = no

			limit = {
				can_be_given_away = yes
				tier = COUNT
				is_feudal = yes

				location = {
					is_capital = no
				}
			}

			grant_title = FROM
		}
	}

	option = {
		name = EVTOPTB37006 # I've had it with his whining!

		FROM = {
			show_scope_change = no

			character_event = {
				id = 37007
				days = 2
				tooltip = EVTTOOLTIP37007
			}
		}

		if = {
			limit = {
				ai = no
				independent = yes

				FROM = {
					practical_age < 65

					NOR = {
						trait = content
						trait = patient
						trait = craven
					}
				}
			}

			custom_tooltip = { text = evt_relative_might_revolt }
		}
	}
}

# Liege breaks the promise
character_event = {
	id = 37007
	desc = EVTDESC37007
	picture = GFX_evt_bad_news

	is_triggered_only = yes

	option = {
		name = EVTOPTA37007 # This is an outrage!

		ai_chance = { factor = 500 }

		opinion = {
			name = opinion_broken_title_promise
			who = FROM
			years = 10
		}

		set_character_flag = obj_landed_title
		cancel_ambition = yes
		clr_character_flag = flag_promised_title
		remove_character_modifier = promised_a_title
		set_character_flag = flag_denied_title
	}

	option = {
		name = EVTOPTB37007 # I will not stand for this! REVOLT!

		trigger = {
			practical_age < 65

			NOR = {
				trait = content
				trait = patient
				trait = craven
			}

			liege = {
				independent = yes
			}
		}

		opinion = {
			name = opinion_broken_title_promise
			who = FROM
			years = 10
		}

		set_character_flag = obj_landed_title
		cancel_ambition = yes
		clr_character_flag = flag_promised_title
		remove_character_modifier = promised_a_title
		set_character_flag = flag_denied_title

		character_event = {
			id = 37010
			days = 45
		}

		ai_chance = {
			factor = 100

			mult_modifier = {
				factor = 2.5
				trait = ambitious
			}

			mult_modifier = {
				factor = 5.0
				religion_group = muslim
			}

			mult_modifier = {
				factor = 0.25
				trait = slothful
			}
		}
	}
}

# Character goes into exile to raise an army
character_event = {
	id = 37010

	hide_window = yes
	is_triggered_only = yes

	trigger = {
		independent = no
		is_ruler = no
		prisoner = no
		is_incapable = no

		FROMFROM = {
			is_alive = yes
			independent = yes
		}

		liege = {
			capital_scope = {
				any_independent_ruler = {
					religion_group = ROOT
					is_landed = yes
					NOT = { character = PREVPREV }

					capital_scope = {
						distance = {
							where = PREVPREV
							value < 400
						}
					}
				}
			}
		}
	}

	immediate = {
		liege = {
			capital_scope = {
				random_independent_ruler = {
					limit = {
						religion_group = ROOT
						is_landed = yes
						NOT = { character = PREVPREV }

						capital_scope = {
							distance = {
								where = PREVPREV
								value < 400
							}
						}
					}

					character_event = { id = 37011 } # Notify the new host

					ROOT = {
						move_character = PREV
					}
				}
			}
		}
	}
}

# The ruler who hosts the pretender is notified
character_event = {
	id = 37011
	desc = EVTDESC37011
	picture = GFX_evt_large_army

	is_triggered_only = yes

	option = {
		name = EVTOPTA37011 # Interesting

		FROMFROMFROM = {
			character_event = { id = 37012 } # Notify the old liege
		}
	}
}

# The old liege is notified
character_event = {
	id = 37012
	desc = EVTDESC37012
	picture = GFX_evt_large_army

	is_triggered_only = yes

	option = {
		name = EVTOPTA37012 # The traitorous git!

		opinion = {
			name = opinion_traitor
			who = FROMFROM
		}

		hidden_effect = {
			opinion = {
				name = opinion_targeted_by_adventurer
				who = FROMFROM
				years = 1
			}

			FROMFROM = {
				character_event = {
					id = 37015 # The event that actually fires the revolt
					years = 1
				}
			}
		}
	}
}

# The pretender launches the attack
character_event = {
	id = 37015

	hide_window = yes
	is_triggered_only = yes

	trigger = {
		independent = no
		is_ruler = no
		prisoner = no
		is_incapable = no

		FROM = {
			is_alive = yes
			independent = yes
		}

		liege = {
			character = FROMFROM
		}
	}

	immediate = {
		liege = {
			capital_scope = {
				ROOT = {
					set_defacto_liege = ROOT

					create_title = {
						tier = DUKE
						landless = yes
						temporary = yes
						culture = ROOT
						name = CLAIMANT_ADVENTURE
						holder = ROOT
						ruler = LORD
						ruler_female = LADY
					}
				}

				FROM = {
					ROOT = {
						set_character_flag = claimant_adventurer

						random_list = {
							34 = {
								while = {
									count = 6

									spawn_unit = {
										province = PREVPREV
										home = PREVPREV
										owner = THIS
										leader = THIS
										match_character = PREV
										match_mult = 0.125
										match_min = 300
										match_max = 5000
										attrition = 0.25
										earmark = claimant_adventure
										disband_on_peace = yes
									}
								}
							}

							33 = {
								while = {
									count = 6

									spawn_unit = {
										province = PREVPREV
										home = PREVPREV
										owner = THIS
										leader = THIS
										match_character = PREV
										match_mult = 0.1
										match_min = 300
										match_max = 5000
										attrition = 0.25
										earmark = claimant_adventure
										disband_on_peace = yes
									}
								}
							}

							33 = {
								while = {
									count = 6

									spawn_unit = {
										province = PREVPREV
										home = PREVPREV
										owner = THIS
										leader = THIS
										match_character = PREV
										match_mult = 0.075
										match_min = 300
										match_max = 5000
										attrition = 0.25
										earmark = claimant_adventure
										disband_on_peace = yes
									}
								}
							}
						}
					}
				}
			}
		}

		# Create some decent commander characters
		if = {
			limit = { has_religion_feature = religion_matriarchal }

			while = {
				count = 4

				create_random_soldier = {
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = yes
					age = 25
				}

				new_character = {
					random_list = {
						1 = { }
						1 = { add_age = 1 }
						1 = { add_age = 2 }
						1 = { add_age = 3 }
						1 = { add_age = 4 }
						1 = { add_age = 5 }
						1 = { add_age = 6 }
						1 = { add_age = 7 }
						1 = { add_age = 8 }
					}
				}
			}
		}
		else = {
			while = {
				count = 4

				create_random_soldier = {
					random_traits = yes
					dynasty = none
					religion = ROOT
					culture = ROOT
					female = no
					age = 25
				}

				new_character = {
					random_list = {
						1 = { }
						1 = { add_age = 1 }
						1 = { add_age = 2 }
						1 = { add_age = 3 }
						1 = { add_age = 4 }
						1 = { add_age = 5 }
						1 = { add_age = 6 }
						1 = { add_age = 7 }
						1 = { add_age = 8 }
					}
				}
			}
		}

		# Create a fleet, just to be sure
		spawn_fleet = {
			province = closest # closest sea zone
			owner = ROOT
			disband_on_peace = yes

			troops = {
				galleys = { 150 150 }
			}

			earmark = claimant_adventure
		}

		FROM = {
			# Prioritize going for secondary empires
			if = {
				limit = { num_of_emperor_titles > 1 }

				random_demesne_title = {
					limit = {
						real_tier = EMPEROR
						is_primary_holder_title = no
					}

					add_claim = ROOT

					holder_scope = {
						reverse_war = {
							target = ROOT
							casus_belli = claim
							thirdparty_title = PREV
						}
					}
				}
			}

			# Next, secondary kingdoms
			else_if = {
				limit = { num_of_king_titles > 1 }

				random_demesne_title = {
					limit = {
						real_tier = KING
						is_primary_holder_title = no
					}

					add_claim = ROOT

					holder_scope = {
						reverse_war = {
							target = ROOT
							casus_belli = claim
							thirdparty_title = PREV
						}
					}
				}
			}

			# Otherwise, just go for the primary title
			else = {
				primary_title = {
					add_claim = ROOT

					holder_scope = {
						reverse_war = {
							target = ROOT
							casus_belli = claim
							thirdparty_title = PREV
						}
					}
				}
			}
		}
	}
}

# IDs to 37048 reserved for more events concerning this ambition

##############################################################
# Close relative asks to get married due to obj_get_married
##############################################################

# Setup
character_event = {
	id = 37050

	is_triggered_only = yes # 00_ambitions.txt, obj_get_married, creation_effect
	hide_window = yes

	# lacks_dlc = "Conclave"

	immediate = {
		save_event_target_as = target_relative

		liege = {
			character_event = { id = 37051 }
		}
	}
}

# Liege responds to marriage request
character_event = {
	id = 37051
	desc = EVTDESC37051
	picture = GFX_evt_marriage

	is_triggered_only = yes

	ai = no
	only_capable = yes
	prisoner = no
	war = no

	trigger = {
		event_target:target_relative = {
			is_close_relative = ROOT
			vassal_of = ROOT
			has_ambition = obj_get_married
			religion = ROOT
			is_ruler = no
			is_marriage_adult = yes
			is_adult = yes
			practical_age < 40
			prisoner = no
			is_betrothed = no
			is_consort = no
			is_married = no
			is_incapable = no

			NOR = {
				trait = bastard
				has_minor_title = title_regent
				has_character_flag = flag_denied_marriage
				has_character_flag = flag_promised_marriage
			}
		}
	}

	fail_trigger_effect = {
		if = {
			limit = {
				ai = no
				religion_group = christian

				event_target:target_relative = {
					is_close_relative = ROOT
					vassal_of = ROOT
					has_ambition = obj_get_married
					religion = ROOT
					is_ruler = no
					is_marriage_adult = yes
					is_adult = yes
					practical_age < 40
					is_betrothed = no

					NOR = {
						trait = bastard
						has_character_flag = flag_denied_marriage
						has_character_flag = flag_promised_marriage
					}
				}
			}

			repeat_event = {
				id = 37051
				months = 2
			}
		}
	}

	option = {
		name = EVTOPTA37051 # Promise that you'll arrange it

		event_target:target_relative = {
			show_scope_change = no

			character_event = {
				id = 37052
				tooltip = EVTTOOLTIP37052
			}
		}
	}

	option = {
		name = EVTOPTB37051 # Mention a Church career...

		event_target:target_relative = {
			show_scope_change = no

			character_event = {
				id = 37053
				tooltip = EVTTOOLTIP37053
			}
		}
	}
}

# The relative is delighted
character_event = {
	id = 37052
	desc = EVTDESC37052
	picture = GFX_evt_marriage

	is_triggered_only = yes

	option = {
		name = OK # Great news!

		set_character_flag = flag_promised_marriage

		add_character_modifier = {
			name = promised_a_marriage
			duration = -1
		}

		opinion = {
			name = opinion_promised_marriage
			who = FROM
			years = 10
		}

		if = {
			limit = {
				trait = content
				NOT = { trait = lustful }
			}

			character_event = {
				id = 37054
				years = 3
				random = 60
			}
		}
		else_if = {
			limit = {
				OR = {
					trait = lustful
					trait = ambitious
				}

				NOT = { trait = slothful }
			}

			character_event = {
				id = 37054
				years = 1
				random = 45
			}
		}
		else = {
			character_event = {
				id = 37054
				years = 1
				random = 120
			}
		}
	}
}

# The relative is disappointed
character_event = {
	id = 37053
	desc = EVTDESC37053
	picture = GFX_evt_bad_news

	is_triggered_only = yes

	option = {
		name = OK # Bleak news

		set_character_flag = flag_denied_marriage

		opinion = {
			name = opinion_denied_marriage
			who = FROM
			years = 10
		}

		if = {
			limit = {
				trait = lustful
				NOT = { trait = content }
			}

			character_event = {
				id = 37056
				years = 2
				random = 365
			}
		}
		else_if = {
			limit = {
				trait = ambitious
				NOT = { trait = slothful }
			}

			character_event = {
				id = 37056
				years = 4
				random = 730 # 2 years
			}
		}
		else_if = {
			limit = {
				trait = content
				NOT = { trait = lustful }
			}

			character_event = {
				id = 37056
				years = 20
				random = 14600 # 40 years
			}
		}
		else = {
			character_event = {
				id = 37056
				years = 5
				random = 3650 # 10 years
			}
		}
	}
}

# Relative reminds liege of promised marriage
character_event = {
	id = 37054
	desc = EVTDESC37054
	picture = GFX_evt_marriage

	is_triggered_only = yes

	has_character_flag = flag_promised_marriage
	only_capable = yes
	prisoner = no
	# lacks_dlc = "Conclave"
	is_married = no
	min_age = 20

	trigger = {
		has_ambition = obj_get_married
		is_close_relative = liege

		has_opinion_modifier = {
			name = opinion_promised_marriage
			who = liege
		}

		is_ruler = no
		is_betrothed = no
		NOT = { trait = bastard }
	}

	option = {
		name = EVTOPTA37054 # Ask dad

		liege = {
			show_scope_change = no

			character_event = {
				id = 37055
				days = 3
				tooltip = EVTTOOLTIP37055
			}
		}
	}
}

# The liege is reminded of the promise
character_event = {
	id = 37055
	desc = EVTDESC37055
	picture = GFX_evt_marriage

	is_triggered_only = yes

	option = {
		name = EVTOPTA37055 # Alright, alright!

		trigger = {
			FROM = { is_married = no }

			any_courtier = {
				is_opposite_sex = FROM
				practical_age < 40
				can_marry = FROM
			}
		}

		remove_character_modifier = promised_a_marriage
		clr_character_flag = flag_promised_marriage

		random_courtier = {
			show_scope_change = no

			limit = {
				is_opposite_sex = FROM
				practical_age < 40
				can_marry = FROM
			}

			add_spouse = FROM
		}
	}

	option = {
		name = EVTOPTB37055 # You're off to the monastery!

		trigger = {
			religion_group = christian

			FROM = {
				religion_group = christian
				is_married = no
			}

			any_realm_lord = {
				is_theocracy = yes
			}
		}

		random_realm_lord = {
			show_scope_change = no
			limit = { is_theocracy = yes }
			reverse_banish = FROM
		}

		FROM = {
			show_scope_change = no

			cancel_ambition = yes
			remove_character_modifier = promised_a_marriage
			clr_character_flag = flag_promised_marriage

			opinion = {
				name = opinion_sent_to_church
				who = ROOT
				years = 10
			}
		}
	}

	option = {
		name = EVTOPTC37055 # I haven't found anyone for you...

		trigger = {
			FROM = { is_married = no }
		}

		FROM = {
			show_scope_change = no

			set_character_flag = flag_denied_marriage
			clr_character_flag = flag_promised_marriage
			remove_character_modifier = promised_a_marriage

			if = {
				limit = {
					trait = lustful
					NOT = { trait = content }
				}

				character_event = {
					id = 37056
					years = 2
					random = 365
				}
			}
			else_if = {
				limit = {
					trait = ambitious
					NOT = { trait = slothful }
				}

				character_event = {
					id = 37056
					years = 4
					random = 730 # 2 years
				}
			}
			else_if = {
				limit = {
					trait = content
					NOT = { trait = lustful }
				}

				character_event = {
					id = 37056
					years = 20
					random = 14600 # 40 years
				}
			}
			else = {
				character_event = {
					id = 37056
					years = 5
					random = 3650 # 10 years
				}
			}
		}
	}

	option = {
		name = EVTOPTD37055

		trigger = {
			FROM = {
				is_married = yes

				spouse = {
					is_alive = yes
				}
			}
		}
	}
}

# Relative who was denied decides to marry in secret
character_event = {
	id = 37056
	picture = GFX_evt_marriage

	desc = {
		text = EVTDESC37056
		trigger = { is_female = no }
	}
	desc = {
		text = EVTDESC37056_B
		trigger = { is_female = yes }
	}

	is_triggered_only = yes

	has_character_flag = flag_denied_marriage
	# lacks_dlc = "Conclave"
	is_married = no
	only_capable = yes
	prisoner = no

	trigger = {
		has_ambition = obj_get_married
		is_ruler = no
		is_betrothed = no

		any_courtier = {
			is_opposite_sex = ROOT
			practical_age < 40
			can_marry = ROOT
		}
	}

	option = {
		name = EVTOPTA37056 # I'm getting married right now

		random_courtier = {
			show_scope_change = no

			limit = {
				is_opposite_sex = ROOT
				practical_age < 40
				can_marry = ROOT
			}

			if = {
				limit = { is_female = yes }
				add_spouse = ROOT
			}
			else = {
				add_spouse_matrilineal = ROOT
			}
		}

		liege = {
			show_scope_change = no

			character_event = {
				id = 37057
				tooltip = EVTTOOLTIP37057
			}
		}
	}
}

# The liege is informed of the secret marriage
character_event = {
	id = 37057
	picture = GFX_evt_marriage

	desc = {
		text = EVTDESC37057
		trigger = { FROM = { is_female = no } }
	}
	desc = {
		text = EVTDESC37057_B
		trigger = { FROM = { is_female = yes } }
	}

	is_triggered_only = yes

	option = {
		name = EVTOPTA37057 # Ah well
		tooltip_info = kind

		trigger = { trait = kind }
	}

	option = {
		name = EVTOPTB37057 # The insolence!

		trigger = {
			NOT = { trait = kind }
		}

		opinion = {
			name = opinion_secret_marriage
			who = FROM
			years = 10
		}
	}

	option = {
		name = EVTOPTC37057 # They will both pay for this!

		trigger = {
			OR = {
				trait = wroth
				trait = envious
			}
		}

		FROM = {
			show_scope_change = no

			imprison = ROOT

			opinion = {
				name = opinion_arrest_attempt
				who = ROOT
				years = 20
			}

			spouse = {
				show_scope_change = no

				imprison = ROOT

				opinion = {
					name = opinion_arrest_attempt
					who = ROOT
					years = 20
				}
			}
		}
	}
}

# IDs to 37149 reserved for more events concerning this ambition

# Common interest with spouse
character_event = {
	id = 37250
	desc = EVTDESC_37252
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes # on_yearly_pulse, random_events

	is_married = yes
	min_age = 16
	only_capable = yes

	trigger = {
		any_spouse = {
			has_prev_education_trigger = yes

			opinion = {
				who = ROOT
				value >= 20
			}

			is_inaccessible_or_incapable_trigger = no
		}

		NOR = {
			trait = blinded
			has_character_flag = spouse_offered_help
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 2
			has_focus = focus_family
		}

		mult_modifier = {
			factor = 1.5
			has_pleasant_personality_trigger = yes
		}

		mult_modifier = {
			factor = 0.75
			has_unpleasant_personality_trigger = yes
		}

		mult_modifier = {
			factor = 0.5
			has_lover = yes
		}
	}

	immediate = {
		set_character_flag = spouse_offered_help

		random_spouse = {
			limit = {
				has_prev_education_trigger = yes

				opinion = {
					who = ROOT
					value >= 20
				}

				is_inaccessible_or_incapable_trigger = no
			}

			save_event_target_as = target_spouse
		}
	}

	option = {
		name = EVTOPTA_37252 # Yes

		custom_tooltip = {
			text = EVTOPTA_37252_TOOLTIP

			repeat_event = {
				id = 37253
				days = 7
			}
		}
	}

	option = {
		name = EVTOPTB_37252 # No

		custom_tooltip = { text = EVTOPTB_37252_TOOLTIP }

		random = {
			chance = 30
			add_trait_fully_proud_effect = yes
		}

		reverse_opinion = {
			name = opinion_ungrateful
			who = event_target:target_spouse
			years = 5
		}
	}
}

character_event = {
	id = 37253
	desc = EVTDESC_37253
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	# Bonding over common interests and getting work done
	option = {
		name = EVTOPTA_37253

		custom_tooltip = { text = EVTOPTA_37253_TOOLTIP }

		opinion = {
			name = common_interests_opinion
			who = event_target:target_spouse
			years = 10
		}

		reverse_opinion = {
			name = common_interests_opinion
			who = event_target:target_spouse
			years = 10
		}

		if = {
			limit = { has_education_martial_trigger = yes }
			military_techpoints = 50
		}
		else_if = {
			limit = { has_education_stewardship_trigger = yes }
			economy_techpoints = 50
		}
		else_if = {
			limit = {
				OR = {
					has_education_diplomacy_trigger = yes
					has_education_learning_trigger = yes
				}
			}

			culture_techpoints = 50
		}
		else_if = {
			limit = { has_education_intrigue_trigger = yes }

			military_techpoints = 15
			culture_techpoints = 15
			economy_techpoints = 15
		}
	}

	# Let's go to bed
	option = {
		name = EVTOPTB_37253

		trigger = {
			NOT = { is_lover = event_target:target_spouse }
		}

		custom_tooltip = { text = EVTOPTB_37253_TOOLTIP }

		add_lover = event_target:target_spouse
	}
}

# Get married ambition success is a ruler
character_event = {
	id = 37255

	hide_window = yes
	is_triggered_only = yes # OFFER_SUCCESSION_MARRIGE_INTERACTION_ACCEPT_EVENT

	only_rulers = yes

	trigger = {
		FROM = { has_ambition = obj_get_married }
	}

	immediate = {
		FROM = {
			opinion = {
				name = opinion_fulfilled_marriage_wish
				who = ROOT_FROMFROM
				years = 5
			}
		}
	}
}