﻿namespace = bride_show

scripted_effect bride_show_add_to_candidate_list_effect = {
	if = {
		limit = { 
			bride_show_viable_candidate_trigger = {
				OVERLORD = scope:liege
			} 
		}
		add_to_list = eligible_candidates_list
	}
}

scripted_trigger can_still_participate_in_bride_show_trigger = {
	has_any_illness = no
	is_alive = yes
	NOR = {
		has_trait = devoted
		has_trait = celibate
	}
	can_become_concubine_of_character_valid_trigger = { CHARACTER = root }
	trigger_if = {
		limit = {
			exists = court_owner
		}
		court_owner = {
			harem_politics_valid_bride_show_subject_trigger = {
				OVERLORD = root
			}
		}
	}
}
scripted_effect bride_show_next_candidate_effect = {
	if = {
		limit = { #I can still pick candidates
			OR = {
				NOT = {		
					exists = scope:candidate_3
				}
				AND = {	
					NOT = {		
						exists = scope:candidate_4
					}
					can_have_four_candidates_trigger = yes
				}
				AND = {
					NOT = { exists = scope:candidate_5 }
					can_have_five_candidates_trigger = yes
				}
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = eligible_candidates_list
					can_still_participate_in_bride_show_trigger = no
					count > 0
				}
			}
			every_in_list = {
				list = eligible_candidates_list
				limit = {
					can_still_participate_in_bride_show_trigger = no
				}
				remove_from_list = eligible_candidates_list
			}
		}
		#Characters will be created only if not at least 4 candidates
		if = {
			limit = { 
				OR = { 
					any_in_list = {
						list = eligible_candidates_list
						count = 0
					}
					any_in_list = { #Or in case all of them are teens
						list = eligible_candidates_list
						is_adult = yes
						count = 0
					}
					AND = { #Or if there aren't any candidates with good congenital traits
						NOT = { exists = scope:candidate_1 }
						scope:liege = { has_variable = beauty_important }
						any_in_list = {
							list = eligible_candidates_list
							OR = {	
								has_trait = beauty_good
								has_trait = physique_good
							}
							count = 0
						}
					}
				}
			}
			calyver_create_candidate_effect = yes
			scope:bride = {
				add_to_list = eligible_candidates_list
				add_to_list = created_candidates_list
				add_character_flag = created_bride_flag
			}
			clear_saved_scope = bride
		}
		if = {
			limit = {
				any_in_list = {
					list = eligible_candidates_list
					is_alive = yes
					count = 1
				}
			}
			random_in_list = {
				list = eligible_candidates_list
				limit = {
					is_alive = yes
				}
				save_scope_as = potential_candidate
			}
		}
		else = {
			ordered_in_list = {
				list = eligible_candidates_list
				limit = {
					is_alive = yes
				}
				order_by = {
					value = 10
					if = { #Non-rejected consorts are preferred
						limit = {
							is_demoted_consort_trigger = no
						}
						add = 10
					}
					if = { #Ready to be consorts are preferred
						limit = {
							is_adult = yes
						}
						add = 25
					}
					if = { #Powerful candidates are preferred
						limit = {
							is_lowborn = no
						}
						add = 10
					}
					if = { #More if it was set
						limit = {
							scope:liege = { has_variable = family_background_important }
							is_lowborn = no
						}
						add = 20
					}

					if = { #Children of vassals are preferred
						limit = {
							any_close_or_extended_family_member = {
								OR = {	
									is_vassal_or_below_of = scope:liege
									is_tributary_of = scope:liege
								}
							}
						}
						add = 5
					}
					if = { #More if it was set
						limit = {
							any_close_or_extended_family_member = {
								OR = {	
									is_vassal_or_below_of = scope:liege
									is_tributary_of = scope:liege
								}
							}
							scope:liege = { has_variable = family_background_important }
						}
						add = 25
					}
					if = { #Child of powerful vassals are preferred
						limit = {
							OR = {
								any_close_family_member = {
									OR = {
										is_powerful_vassal_of = scope:liege
										is_councillor_of = scope:liege
										is_parent_of = scope:liege
									}
								}
								trigger_if = {
									limit = { scope:liege = { government_allows = administrative } }
									house ?= {
										OR = {
											is_dominant_family = yes
											is_powerful_family = yes
										}
									}
								}
							}
						}
						add = 10
					}
					if = { #Child of tributaries are preferred
						limit = {
							any_close_family_member = {
								is_tributary_of = scope:liege
								tier_difference = {
									target = scope:liege
									value >= -1
								}
							}
						}
						add = 15
					}
					if = { #More if it was set
						limit = {
							OR = {
								any_close_family_member = {
									OR = {
										is_powerful_vassal_of = scope:liege
										is_councillor_of = scope:liege
										is_parent_of = scope:liege
										AND = {
											is_tributary_of = scope:liege
											is_lowborn = no
										}
									}
								}
								trigger_if = {
									limit = { scope:liege = { government_allows = administrative } }
									house ?= {
										OR = {
											is_dominant_family = yes
											is_powerful_family = yes
										}
									}
								}
							}
							scope:liege = { has_variable = family_background_important }
						}
						add = 50
					}

					if = { #More if it was set
						limit = {
							any_close_family_member = {
								government_has_flag = government_is_administrative
								top_liege ?= scope:liege
								house ?= {
									is_dominant_family = yes
								}
							}
							scope:liege = { 
								has_variable = family_background_important 
								government_has_flag = government_is_administrative
							}
						}
						add = 75
					}
					if = { #Noble rank
						limit = {
							any_close_family_member = {
								highest_held_title_tier >= tier_county
							}
						}
						add = 5
					}
					if = { #Noble rank - preference for powerful background
						limit = {
							any_close_family_member = {
								highest_held_title_tier >= tier_county
							}
							scope:liege = { has_variable = family_background_important }
						}
						add = 5
					}
					if = { #Ducal rank - preference for powerful background
						limit = {
							any_close_family_member = {
								highest_held_title_tier >= tier_duchy
							}
							scope:liege = { has_variable = family_background_important }
						}
						add = 5
					}
					if = { #Royal rank - preference for powerful background
						limit = {
							any_close_family_member = {
								highest_held_title_tier >= tier_kingdom
							}
							scope:liege = { has_variable = family_background_important }
						}
						add = 10
					}
					if = { #Imperial rank - preference for powerful background
						limit = {
							any_close_family_member = {
								highest_held_title_tier >= tier_empire
							}
							scope:liege = { has_variable = family_background_important }
						}
						add = 5
					}

					if = { #Nepotism wins if family background is important
						limit = {
							any_close_or_extended_family_member = {
								is_close_or_extended_family_of = scope:liege
							}
							scope:liege = { has_variable = family_background_important }
						}
						add = 15
					}
					if = { #Trait considerations
						limit = {
							num_of_good_genetic_traits >= 1
						}
						add = 5
					}
					if = { #Trait considerations - beauty is important
						limit = {
							has_trait = strong
							scope:liege = { has_variable = beauty_important }
						}
						add = 10
					}
					if = { #Trait considerations - beauty is important
						limit = {
							OR = {
								has_trait = beauty_good_1
								has_trait = physique_good_1
							}
							scope:liege = { has_variable = beauty_important }
						}
						add = 40
					}
					if = { #Trait considerations - beauty is important
						limit = {
							OR = {
								has_trait = beauty_good_1
								has_trait = physique_good_1
							}
							scope:liege = { 
								has_variable = beauty_important 
								NOT = {
									any_consort = {
										OR = {
											has_trait = beauty_good_1
											has_trait = physique_good_1
										}
									}
								}
							}
						}
						add = 40
					}

					if = { #Trait considerations - beauty is important
						limit = {
							OR = {
								has_trait = beauty_good_2
								has_trait = physique_good_2
							}
							scope:liege = { has_variable = beauty_important }
						}
						add = 50
					}
					if = { #Trait considerations - beauty is important
						limit = {
							OR = {
								has_trait = beauty_good_2
								has_trait = physique_good_2
							}
							scope:liege = { 
								has_variable = beauty_important 
								NOT = {
									any_consort = {
										OR = {
											has_trait = beauty_good_2
											has_trait = physique_good_2
										}
									}
								}
							}
						}
						add = 50
					}
					if = { #Trait considerations - beauty is important
						limit = {
							OR = {
								has_trait = beauty_good_3
								has_trait = physique_good_3
							}
							scope:liege = { has_variable = beauty_important }
						}
						add = 60
					}
					if = { #Trait considerations - beauty is important
						limit = {
							OR = {
								has_trait = beauty_good_3
								has_trait = physique_good_3
							}
							scope:liege = { 
								has_variable = beauty_important 
								NOT = {
									any_consort = {
										OR = {
											has_trait = beauty_good_3
											has_trait = physique_good_3
										}
									}
								}
							}
						}
						add = 60
					}

					if = { #Virtuous traits are encouraged - if they were chosen
						limit = {
							num_sinful_traits > 0
							scope:liege = { has_variable = personality_skills_important }
						}
						add = -10
					}
					if = { #Virtuous traits are encouraged - if they were chosen
						limit = {
							num_sinful_traits >= 2
							scope:liege = { has_variable = personality_skills_important }
						}
						add = -10
					}
					if = { #Virtuous traits are encouraged - if they were chosen
						limit = {
							num_sinful_traits >= 3
							scope:liege = { has_variable = personality_skills_important }
						}
						add = -10
					}
					if = { #Bonus for virtuous candidates - if virtuous traits matter
						limit = {
							AND = {
								num_sinful_traits = 0
								num_virtuous_traits >= 1
							}
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Virtuous traits are encouraged - if they were chosen
						limit = {
							num_virtuous_traits >= 1
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Virtuous traits are encouraged - if they were chosen
						limit = {
							num_virtuous_traits >= 2
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}

					if = { #Virtuous traits are encouraged - if they were chosen
						limit = {
							num_virtuous_traits >= 3
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Skill considerations - if they were chosen
						limit = {
							OR = {
								stewardship >= 9
								diplomacy >= 9
								learning >= 9
							}
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 5
					}
					if = { #Skill considerations - if they were chosen
						limit = {
							OR = {
								stewardship >= 13
								diplomacy >= 13
								learning >= 13
							}
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Skill considerations - if they were chosen
						limit = {
							OR = {
								stewardship >= 17
								diplomacy >= 17
								learning >= 17
							}
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 15
					}
					if = { #Bonus - skill considerations - if they were chosen
						limit = {
							AND = {
								stewardship >= 13
								diplomacy >= 13
								learning >= 13
							}
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 20
					}

					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = content
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = calm
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = gregarious
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = compassionate
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = forgiving
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = honest
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}

					if = { #Trait considerations - if they were chosen - bonus for non-scheming consorts
						limit = {
							harem_politics_evil_consort_trigger = no
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 10
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = intellect_good_1
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 15
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = intellect_good_1
							scope:liege = { 
								has_variable = personality_skills_important 
								NOT = {
									any_consort = {
										has_trait = intellect_good_1
									}
								}
							}
						}
						add = 15
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = intellect_good_2
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 25
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = intellect_good_2
							scope:liege = { 
								has_variable = personality_skills_important 
								NOT = {
									any_consort = {
										has_trait = intellect_good_2
									}
								}
							}
						}
						add = 25
					}
					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = intellect_good_3
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 35
					}

					if = { #Trait considerations - if they were chosen
						limit = {
							has_trait = intellect_good_3
							scope:liege = { 
								has_variable = personality_skills_important 
								NOT = {
									any_consort = {
										has_trait = intellect_good_3
									}
								}
							}
						}
						add = 35
					}
					# Poets
					if = {
						limit = {
							has_trait = lifestyle_poet
							scope:liege = { has_variable = personality_skills_important }
						}
						add = 15
					}
					# Skills
					if = { #Diplomacy
						limit = {
							always = yes
						}
						add = {
							value = diplomacy
							divide = 2
						}
					}
					if = { #Learning
						limit = {
							always = yes
						}
						add = {
							value = learning
							divide = 2
						}
					}
					if = { #Intrigue
						limit = {
							always = yes
						}
						add = {
							value = intrigue
							divide = 2
						}
					}
					if = { #Scheming consorts will try their best to be chosen... and they make the harem interesting
						limit = {
							harem_politics_evil_consort_trigger = yes
							NOT = { scope:liege = { has_variable = personality_skills_important } }
						}
						add = 15
					}

					if = { #Parents would not leave their children
						limit = {
							any_child = {
								even_if_dead = yes
								count = 0
							}
						}
						add = 15
					}
					if = { #Virginity is valuable
						limit = {
							is_virgin_trigger = yes
						}
						add = 20
					}
					if = { #Characters that believe in concubinage are more eligible
						limit = {
							hp_accepts_harems = yes
						}
						add = 10
					}
				}
				save_scope_as = potential_candidate
			}
		}
	}

	# Are we done? Yes
	if = {
		limit = {
			trigger_if = {
				limit = {
					can_have_four_candidates_trigger = no
				}
				exists = scope:candidate_3
			}
			trigger_else_if = {
				limit = {
					can_have_five_candidates_trigger = no
				}
				exists = scope:candidate_4
			}
			trigger_else = {
				exists = scope:candidate_5
			}
		}
		if = {
			limit = {
				is_ai = no
			}
			trigger_event = bride_show.0006
		}
		else = {
			bride_show_ending_effect = yes
		}
	}
	#No
	else = {
		trigger_event = bride_show.0005
	}
}

#######################
##Choosing parameters##
#######################

##Family background##
bride_show.0001 = { 
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					is_female = no
					government_has_flag = government_is_nomadic
				}
				desc = bride_show.0001_m_nomadic.t
			}
			triggered_desc = {
				trigger = {
					is_female = no
					government_has_flag = government_is_tribal
				}
				desc = bride_show.0001_m_tribal.t
			}
			triggered_desc = {
				trigger = {
					is_female = no
				}
				desc = bride_show.0001_m.t
			}
			triggered_desc = {
				trigger = {
					is_female = yes
					government_has_flag = government_is_nomadic
				}
				desc = bride_show.0001_f_nomadic.t
			}
			triggered_desc = {
				trigger = {
					is_female = yes
					government_has_flag = government_is_tribal
				}
				desc = bride_show.0001_f_tribal.t
			}
			desc = bride_show.0001_f.t
		}
		desc = bride_show.0001.t
	}
	desc = bride_show.0001.desc
	theme = realm
	
	left_portrait = { 	
		character = root
		animation = personality_honorable
	}
	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:liege }
			}
			save_scope_as = liege
		}
		if = {
			limit = {
				NOT = { exists = scope:harem_liege }
			}
			save_scope_as = harem_liege
		}
		if = {
			limit = {
				any_in_list = {
					list = bride_show_preliminary_list
					count >= 1
				}
			}
			every_in_list = {
				list = bride_show_preliminary_list
				remove_from_list = bride_show_preliminary_list
			}
		}
	}
	# Family background is important
	option = {
		name = bride_show.0001.a
		trigger = {
			gold >= tiny_gold_value
		}
		show_as_unavailable = {
			gold < tiny_gold_value
		}

		remove_short_term_gold = tiny_gold_value

		stress_impact = {
			humble = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}
		
		set_variable = {
			name = family_background_important
			value = yes
			days = 30
		}
		ai_chance = { #The AI will always choose this
			base = 20
			modifier = {
				has_trait = arrogant
				add = 25
			}
			modifier = {
				has_trait = humble
				add = -25
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				allowed_more_spouses = yes
				is_valid_for_legitimacy_change = yes
				NOT = { has_variable = lowborn_legitimacy_cooldown }
				add = 10
			}
			modifier = { #More likely if root doesn't have enough spouses
				add = 10
				is_valid_for_legitimacy_change = yes
				NOT = { has_variable = lowborn_legitimacy_cooldown }
				trigger_if = {
					limit = {
						primary_title.tier >= 5
					}
					any_spouse = {
						count < 4
					}
				}
				trigger_else_if = {
					limit = {
						primary_title.tier >= 4
					}
					any_spouse = {
						count < 3
					}
				}
				trigger_else_if = {
					limit = {
						primary_title.tier >= 3
					}
					any_spouse = {
						count < 2
					}
				}
				trigger_else = {
					any_spouse = {
						count < 1
					}
				}
			}
			modifier = {
				gold <= minor_gold_value
				factor = 0
			}
		}
	}

	#It's irrelevant
	option = {
		name = bride_show.0001.b
		stress_impact = {
			arrogant = minor_stress_impact_gain
		}
		ai_chance = {
			base = 5
			modifier = {
				has_trait = arrogant
				add = -10
			}
			modifier = {
				has_trait = humble
				add = 50
			}
			modifier = {
				has_trait = greedy
				add = 50
			}
		}
	}
	after = {
		trigger_event = {
			id = bride_show.0002
			days = { 5 10 }
		}
	}
}

##Beauty##
bride_show.0002 = { 
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					is_female = no
					government_has_flag = government_is_nomadic
				}
				desc = bride_show.0001_m_nomadic.t
			}
			triggered_desc = {
				trigger = {
					is_female = no
					government_has_flag = government_is_tribal
				}
				desc = bride_show.0001_m_tribal.t
			}
			triggered_desc = {
				trigger = {
					is_female = no
				}
				desc = bride_show.0001_m.t
			}
			triggered_desc = {
				trigger = {
					is_female = yes
					government_has_flag = government_is_nomadic
				}
				desc = bride_show.0001_f_nomadic.t
			}
			triggered_desc = {
				trigger = {
					is_female = yes
					government_has_flag = government_is_tribal
				}
				desc = bride_show.0001_f_tribal.t
			}
			desc = bride_show.0001_f.t
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					is_female = yes
				}
				desc = bride_show.0002.t.f
			}
			desc = bride_show.0002.t.m
		}
	}
	desc = bride_show.0002.desc
	theme = realm
	
	right_portrait = { 	
		character = root
		animation = personality_rational
	}
	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:liege }
			}
			save_scope_as = liege
		}
		if = {
			limit = {
				NOT = { exists = scope:harem_liege }
			}
			save_scope_as = harem_liege
		}
	}
	# Beauty is important
	option = {
		name = bride_show.0002.a
		trigger = {
			gold >= tiny_gold_value
		}
		show_as_unavailable = { NOT = { gold >= tiny_gold_value } }
		flavor = { #To get warning if you don't have enough money
			triggered_desc = {
				trigger = {
					NOT = { gold >= tiny_gold_value }
				}
				desc = holy_order.0202.a._not.tt
			}
		}
		remove_short_term_gold = tiny_gold_value
		set_variable = {
			name = beauty_important
			value = yes
			days = 30
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = { #The AI will always choose this
			base = 20
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				gold <= minor_gold_value
				factor = 0
			}
		}
	}

	#It's irrelevant
	option = {
		name = bride_show.0001.b
		ai_chance = {
			base = 1
			modifier = {
				has_trait = greedy
				add = 15
			}
		}
	}
	after = {
		trigger_event = {
			id = bride_show.0003
			days = { 5 10 }
		}
	}
}

##Personality and skills##
bride_show.0003 = { 
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					is_female = no
					government_has_flag = government_is_nomadic
				}
				desc = bride_show.0001_m_nomadic.t
			}
			triggered_desc = {
				trigger = {
					is_female = no
					government_has_flag = government_is_tribal
				}
				desc = bride_show.0001_m_tribal.t
			}
			triggered_desc = {
				trigger = {
					is_female = no
				}
				desc = bride_show.0001_m.t
			}
			triggered_desc = {
				trigger = {
					is_female = yes
					government_has_flag = government_is_nomadic
				}
				desc = bride_show.0001_f_nomadic.t
			}
			triggered_desc = {
				trigger = {
					is_female = yes
					government_has_flag = government_is_tribal
				}
				desc = bride_show.0001_f_tribal.t
			}
			desc = bride_show.0001_f.t
		}
		desc = bride_show.0003.t
	}
	desc = bride_show.0003.desc
	theme = realm
	
	left_portrait = { 	
		character = root
		animation = personality_compassionate
	}
	immediate = {
		if = {
			limit = {
				NOT = { exists = scope:liege }
			}
			save_scope_as = liege
		}
		if = {
			limit = {
				NOT = { exists = scope:harem_liege }
			}
			save_scope_as = harem_liege
		}
	}
	# Personality and skills are important
	option = {
		name = bride_show.0003.a
		trigger = {
			gold >= tiny_gold_value
		}
		show_as_unavailable = { NOT = { gold >= tiny_gold_value } }
		flavor = { #To get warning if you don't have enough money
			triggered_desc = {
				trigger = {
					NOT = { gold >= tiny_gold_value }
				}
				desc = holy_order.0202.a._not.tt
			}
		}
		remove_short_term_gold = tiny_gold_value
		set_variable = {
			name = personality_skills_important
			value = yes
			days = 30
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				gold <= minor_gold_value
				factor = 0
			}
		}
	}

	#It's irrelevant
	option = {
		name = bride_show.0001.b
		ai_chance = { #The AI will always choose this
			base = 15
			modifier = {
				has_trait = greedy
				add = 15
			}
		}
	}
	after = {
		trigger_event = {
			id = bride_show.1001
			days = { 10 15 }
		}
	}
}

##The show starts##
bride_show.0004 = {
	type = character_event
	title = bride_show.0004.t
	desc = bride_show.0004.desc
	theme = realm
	
	right_portrait = { 	
		character = root
		animation = personality_rational
	}
	left_portrait = {
		trigger = {
			exists = scope:attendant
		}
		character = scope:attendant
		animation = personality_content
	}

	immediate = {
		if = {
			limit = {
				OR = {
					employs_court_position = chief_eunuch_court_position
					employs_court_position = lady_in_waiting_court_position
					employs_court_position = keeper_of_the_harem_court_position
				}
			}
			random_courtier = {
				limit = {
					OR = {
						has_court_position = chief_eunuch_court_position
						has_court_position = lady_in_waiting_court_position
						has_court_position = keeper_of_the_harem_court_position
					}
				}
				weight = {
					base = 1
					modifier = {
						add = 10
						sex_same_as = scope:liege
					}
				}
				save_scope_as = attendant
			}
		}
	}
	
	# Let's go!
	option = {
		name = bride_show.0004.a
		custom_tooltip = bride_show.0004.a.tt

		if = {
			limit = {
				NOT = {
					exists = scope:liege
				}
			}
			save_scope_as = liege
		}
		if = {
			limit = {
				NOT = { exists = scope:harem_liege }
			}
			save_scope_as = harem_liege
		}
		stress_impact = {
			shy = minor_stress_impact_gain
		}
		hidden_effect = {
			#Set up lists
			# Subjects
			if = {
				limit = {
					any_in_list = {
						variable = bride_show_subject_list
						harem_politics_is_valid_bride_show_subject_trigger = {
							OVERLORD = scope:liege
						}
						any_courtier = {
							bride_show_viable_candidate_trigger = {
								OVERLORD = scope:liege
							} 
						}
						count >= 1
					}
				}
				every_in_list = {
					variable = bride_show_subject_list
					limit = {
						harem_politics_is_valid_bride_show_subject_trigger = {
							OVERLORD = scope:liege
						}
						any_courtier = {
							bride_show_viable_candidate_trigger = {
								OVERLORD = scope:liege
							} 
						}
					}
					every_courtier = {
						bride_show_add_to_candidate_list_effect = yes
					}
					if = {
						limit = {
							is_ai = no
						}
						trigger_event = bride_show.1002
					}
				}
			}
			if = {
				limit = {
					has_variable_list = bride_show_subject_list
				}
				clear_variable_list = bride_show_subject_list
			}
			#Let's go!
			bride_show_next_candidate_effect = yes 
		}
		ai_chance = {
			base = 1
		}
	}
}

scripted_effect bride_show_break_betrothal_candidate_effect = {
	if = {
		limit = { exists = betrothed }
		root = { save_scope_as = actor }
		save_scope_as = rejecting_betrothed
		betrothed = {
			save_scope_as = recipient
			scope:recipient = { save_scope_as = rejected_betrothed }
			trigger_event = marriage_interaction.0020
			add_opinion = {
				target = root
				modifier = broke_betrothal_opinion
			}
			every_close_or_extended_family_member = {
				limit = {
					NOR = {
						this = root 
						is_close_or_extended_family_of = root
					}
				}
				custom = all_family_members
				add_opinion = {
					target = root
					modifier = broke_betrothal_opinion
				}
			}
			clear_saved_scope = recipient
		}
		break_betrothal = betrothed
		if = { #Ambitious candidates see this as an opportunity to climb up
			limit = {
				AND = {
					agrees_with_bride_show = yes
					OR = {
						has_trait = greedy
						has_trait = arrogant
						has_trait = ambitious
					}
				}
			}
		}
		else = {
			add_opinion = {
				target = root
				modifier = broke_betrothal_opinion
			}
		}
		every_close_or_extended_family_member = {
			limit = {
				NOR = {
					this = root 
					is_close_or_extended_family_of = root
					AND	= {
						agrees_with_bride_show = yes
						is_vassal_or_below_of = root
						OR = {
							has_vassal_stance = courtly
							has_trait = ambitious
							has_trait = greedy
							has_trait = arrogant
						}
					}
				}
			}
			custom = all_family_members
			add_opinion = {
				target = root
				modifier = broke_betrothal_opinion
			}
		}
	}
}

##Pick your candidates##
bride_show.0005 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					is_female = no
					government_has_flag = government_is_nomadic
				}
				desc = bride_show.0005_m_nomadic.t
			}
			triggered_desc = {
				trigger = {
					is_female = no
					government_has_flag = government_is_tribal
				}
				desc = bride_show.0005_m_tribal.t
			}
			triggered_desc = {
				trigger = {
					is_female = no
				}
				desc = bride_show.0005_m.t
			}
			triggered_desc = {
				trigger = {
					is_female = yes
					government_has_flag = government_is_nomadic
				}
				desc = bride_show.0005_f_nomadic.t
			}
			triggered_desc = {
				trigger = {
					is_female = yes
					government_has_flag = government_is_tribal
				}
				desc = bride_show.0005_f_tribal.t
			}
			desc = bride_show.0005_f.t
		}
	}
	desc = {
		first_valid = { #Intro
			triggered_desc = {
				trigger = {
					trigger_if = {
						limit = {
							can_have_four_candidates_trigger = no
						}
						exists = scope:candidate_2
					}
					trigger_else_if = {
						limit = {
							can_have_five_candidates_trigger = no
						}
						exists = scope:candidate_3
					}
					trigger_else = {
						exists = scope:candidate_4
					}
				}
				desc = bride_show.0005.start_3.desc
			}
			triggered_desc = {
				trigger = {
					exists = scope:candidate_1
					trigger_if = {
						limit = {
							can_have_five_candidates_trigger = yes
						}
						NOT = { exists = scope:candidate_4 }
					}
					trigger_else_if = {
						limit = { can_have_four_candidates_trigger = yes }
						NOT = { exists = scope:candidate_3 }
					}
					trigger_else = {
						always = yes
					}
				}
				desc = bride_show.0005.start_2.desc
			}
			triggered_desc = {
				# First candidate (fallback - no candidates exist yet)
				desc = bride_show.0005.start.desc
			}
		}
		first_valid = { #Traits
			triggered_desc = {
				trigger = { #2 #4
					OR = {
						AND = {	
							exists = scope:candidate_1
							NOT = {
								exists = scope:candidate_2
							}
						}
						AND = {
							exists = scope:candidate_3
							NOT = {
								exists = scope:candidate_4
							}
						}
					}
					scope:potential_candidate = {
						AND = {
							OR = {
								has_trait = shy
								has_trait = paranoid
								has_trait = craven
							}
							NOR = {
								has_trait = ambitious
								has_trait = brave
								has_trait = arrogant
							}
						}
					}
				}
				desc = bride_show.0005.shy_2.desc
			}
			triggered_desc = {
				trigger = { #1 #3 #5
					scope:potential_candidate = {
						AND = {
							OR = {
								has_trait = shy
								has_trait = paranoid
								has_trait = craven
							}
							NOR = {
								has_trait = ambitious
								has_trait = brave
								has_trait = arrogant
							}
						}
					}
				}
				desc = bride_show.0005.shy.desc
			}
			triggered_desc = {
				trigger = { #2 #4
					OR = {
						AND = {	
							exists = scope:candidate_1
							NOT = {
								exists = scope:candidate_2
							}
						}
						AND = {
							exists = scope:candidate_3
							NOT = {
								exists = scope:candidate_4
							}
						}
					}
					scope:potential_candidate = {
						AND = {
							OR = {
								has_trait = brave
								has_trait = ambitious
							}
							NOR = {
								has_trait = craven
								has_trait = paranoid
								has_trait = shy
								has_trait = arrogant
							}
						}
					}
				}
				desc = bride_show.0005.brave_2.desc
			}
			triggered_desc = {
				trigger = {  #1 #3 #5
					scope:potential_candidate = {
						AND = {
							OR = {
								has_trait = brave
								has_trait = ambitious
							}
							NOR = {
								has_trait = craven
								has_trait = paranoid
								has_trait = shy
								has_trait = arrogant
							}
						}
					}
				}
				desc = bride_show.0005.brave.desc
			}
			triggered_desc = {
				trigger = { #2 #4
					OR = {
						AND = {	
							exists = scope:candidate_1
							NOT = {
								exists = scope:candidate_2
							}
						}
						AND = {
							exists = scope:candidate_3
							NOT = {
								exists = scope:candidate_4
							}
						}
					}
					scope:potential_candidate = {
						AND = {
							OR = {
								has_trait = arrogant
							}
							NOR = {
								has_trait = craven
								has_trait = paranoid
								has_trait = shy
								has_trait = brave
								has_trait = ambitious
							}
						}
					}
				}
				desc = bride_show.0005.arrogant_2.desc
			}
			triggered_desc = {
				trigger = {  #1 #3 #5
					scope:potential_candidate = {
						AND = {
							OR = {
								has_trait = arrogant
							}
							NOR = {
								has_trait = craven
								has_trait = paranoid
								has_trait = shy
								has_trait = brave
								has_trait = ambitious
							}
						}
					}
				}
				desc = bride_show.0005.arrogant.desc
			}
			triggered_desc = {
				trigger = { #2 #4
					OR = {
						AND = {	
							exists = scope:candidate_1
							NOT = {
								exists = scope:candidate_2
							}
						}
						AND = {
							exists = scope:candidate_3
							NOT = {
								exists = scope:candidate_4
							}
						}
					}
				}
				desc = bride_show.0005.generic_1_2.desc
			}
			triggered_desc = {  #1 #3 #5
				desc = bride_show.0005.generic_1.desc
			}
		}
		first_valid = { #Beauty
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						has_trait = beauty_good_3
					}
				}
				desc = bride_show.0005.beautiful.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						has_trait = beauty_good_2
					}
				}
				desc = bride_show.0005.handsome.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						has_trait = beauty_good_1
					}
				}
				desc = bride_show.0005.comely.desc
			}
			triggered_desc = {
				desc = bride_show.0005.generic_2.desc
			}
		}
		first_valid = { #Intellect
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						has_trait = intellect_good_3
					}
				}
				desc = bride_show.0005.genius.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						has_trait = intellect_good_2
					}
				}
				desc = bride_show.0005.intelligent.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						has_trait = intellect_good_1
					}
				}
				desc = bride_show.0005.quick.desc
			}
			triggered_desc = {
				desc = bride_show.0005.generic_3.desc
			}
		}
		first_valid = { #Skills
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						AND = {
							diplomacy <= 11
							learning <= 11
							stewardship >= 12
						}
					}
				}
				desc = bride_show.0005.stewardship.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						AND = {
							diplomacy <= 11
							learning >= 12
							stewardship <= 11
						}
					}
				}
				desc = bride_show.0005.learning.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						AND = {
							diplomacy >= 12
							learning <= 11
							stewardship <= 11
						}
					}
				}
				desc = bride_show.0005.diplomacy.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_candidate = {
						OR = {
							AND = {
								stewardship >= 12
								learning >= 12
							}
							AND = {
								stewardship >= 12
								diplomacy >= 12
							}
							AND = {
								learning >= 12
								diplomacy >= 12
							}
						}
					}
				}
				desc = bride_show.0005.multiple.desc
			}
			triggered_desc = {
				desc = bride_show.0005.generic_4.desc
			}
		}
		desc = bride_show.0005.end.desc
	}
	theme = realm
	
	left_portrait = {
		character = scope:potential_candidate
		triggered_animation = {
			trigger = { 
				scope:potential_candidate = {
					is_adult = yes
				}
			}
  			animation = flirtation
  		}
		animation = personality_honorable
	}
	lower_center_portrait = {
		trigger = {
			scope:pc_court_owner ?= scope:potential_candidate.court_owner
		}
		character = scope:pc_court_owner
	}

	immediate = {
		if = {
			limit = {
				NOT = {
					exists = scope:liege
				}
			}
			save_scope_as = liege
		}
		if = {
			limit = {
				NOT = { exists = scope:harem_liege }
			}
			save_scope_as = harem_liege
		}
		scope:potential_candidate.court_owner ?= {
			save_scope_as = pc_court_owner
		}
	}
	
	# Marry them
	option = {
		name = bride_show.0005.a
		trigger = {
			allowed_more_spouses = yes
			scope:potential_candidate = {
				any_consort = {
					count = 0
				}
				is_adult = yes
				could_marry_character_trigger = { CHARACTER = scope:liege }
			}
			is_adult = yes
			gold >= bride_compensation_payment_value
		}
		show_as_unavailable = { 
			NOT = { gold >= bride_compensation_payment_value }
			allowed_more_spouses = yes
			scope:potential_candidate = {
				is_adult = yes
				could_marry_character_trigger = { CHARACTER = scope:liege }
			}
			is_adult = yes
		}
		flavor = { #To get warning if you don't have enough money
			triggered_desc = {
				trigger = {
					NOT = { gold >= bride_compensation_payment_value }
				}
				desc = holy_order.0202.a._not.tt
			}
		}

		save_scope_value_as = {
			name = gold_to_pay
			value = bride_compensation_payment_value
		}
		#Reward
		if = {
			limit = {
				exists = scope:potential_candidate.court_owner
			}
			pay_short_term_gold = {
				target = scope:potential_candidate.court_owner
				gold = bride_compensation_payment_value
			}
			scope:potential_candidate = {
				save_scope_as = candidate_marriage
				court_owner = {
					if = {
						limit = {
							any_close_family_member = {
								this = scope:candidate_marriage
							}
							is_ai = no
						}
						trigger_event = bride_show.0008
					}
					else = {
						hidden_effect = {
							send_interface_toast = {
								type = event_generic_neutral
								title = chosen_consort_t
								right_icon = scope:liege
								left_icon = scope:potential_candidate
								

								scope:liege = { 
									show_as_tooltip = {
										if = {
											limit = {
												is_male = yes
											}
											marry = scope:potential_candidate
										}
										else = {
											marry_matrilineal = scope:potential_candidate
										}
										pay_short_term_gold = {
											target = scope:potential_candidate.court_owner
											gold = bride_compensation_payment_value
										}
									}
									if = {
										limit  ={
											any_close_family_member = {
												this = scope:candidate_marriage
											}
										}
										#Prestige
										if = {
											limit = {
												highest_held_title_tier = tier_duchy
											}
											scope:potential_candidate.court_owner = {
												add_prestige = miniscule_prestige_gain
											}
										}
										else_if = {
											limit = {
												highest_held_title_tier = tier_kingdom
											}
											scope:potential_candidate.court_owner = {
												add_prestige = minor_prestige_gain
											}
										}
										else_if = {
											limit = {
												highest_held_title_tier >= tier_empire
											}
											scope:potential_candidate.court_owner = {
												add_prestige = medium_prestige_gain
											}
										}
									}
								}

								gain_influence_harem_politics_effect = {
									ACTOR = scope:potential_candidate.court_owner
									RECIPIENT = scope:liege
									CONCUBINE = scope:potential_candidate
								}
							}
						}
					}
				}
			}
			
			#Courtly vassals get a positive opinion
			if = {
				limit = {
					scope:potential_candidate.court_owner = {
						is_vassal_or_below_of = root
						OR = {
							has_vassal_stance = courtly
							has_trait = ambitious
							has_trait = greedy
							has_trait = arrogant
						}
						any_close_family_member = {
							this = scope:potential_candidate
						}
						agrees_with_bride_show = yes
					}
				}
				scope:potential_candidate.court_owner = {
					add_opinion = {
						target = root
						modifier = courtly_vassal_marriage_opinion
					}
				}
			}
		}
		else = {
			pay_short_term_gold = {
				target = scope:potential_candidate
				gold = bride_compensation_payment_value
			}
			if = {
				limit = {
					highest_held_title_tier = tier_duchy
				}
				scope:potential_candidate = {
					add_prestige = miniscule_prestige_gain
				}
			}
			else_if = {
				limit = {
					highest_held_title_tier = tier_kingdom
				}
				scope:potential_candidate = {
					add_prestige = minor_prestige_gain
				}
			}
			else_if = {
				limit = {
					highest_held_title_tier >= tier_empire
				}
				scope:potential_candidate = {
					add_prestige = medium_prestige_gain
				}
			}
		}
		
		stress_impact = {
			paranoid = miniscule_stress_impact_gain
		}
		
		scope:potential_candidate = {
			bride_show_break_betrothal_candidate_effect = yes
			hidden_effect = {
				if = {
					limit = {
						is_hostage = yes
					}
					return_hostage = yes
				}
			}
			save_scope_as = secondary_recipient
		}
		if = {
			limit = {
				is_female = yes
			}
			marry_matrilineal = scope:potential_candidate
		}
		else = {
			marry = scope:potential_candidate
		}
		
		#Marriage effects
		save_scope_as = actor
		save_scope_as = recipient
		save_scope_as = secondary_actor
		marriage_interaction_on_accept_effect = yes
		
		ai_chance = {
			base = 10
			modifier = { #Weigh down for stress
				add = -25
				has_trait = paranoid
			}
			modifier = { #Weigh down for stress
				add = -15
				has_trait = craven
			}
			modifier = { #Weigh down for stress
				add = -25
				has_trait = shy
			}
			modifier = { #More likely if root is lustful
				add = 15
				has_trait = lustful
			}
			modifier = { #More likely if concubinage isn't accepted
				add = 20
				allowed_concubines = no
			}
			modifier = { #Less likely if the candidate is a commoner
				add = -30
				has_settled_harem_trigger = yes
				scope:potential_candidate = {
					is_lowborn = yes
				}
			}
			modifier = { #More likely if root doesn't have enough spouses
				add = 50
				scope:liege = {
					trigger_if = {
						limit = {
							primary_title.tier >= 5
						}
						any_spouse = {
							count < 4
						}
					}
					trigger_else_if = {
						limit = {
							primary_title.tier >= 4
						}
						any_spouse = {
							count < 3
						}
					}
					trigger_else_if = {
						limit = {
							primary_title.tier >= 3
						}
						any_spouse = {
							count < 2
						}
					}
					trigger_else = {
						any_spouse = {
							count < 1
						}
					}
				}
			}
			modifier = { #Less likely if the candidate is lowborn and low legitimacy
				add = -60
				is_valid_for_legitimacy_change = yes
				NOT = { has_variable = lowborn_legitimacy_cooldown }
				OR = {
					AND = {
						highest_held_title_tier >= tier_hegemony
						legitimacy_level < dynastic_cycle_legitimacy_expectation
					}
					AND = {
						highest_held_title_tier = tier_empire
						legitimacy_level <= 3
					}
					AND = {
						highest_held_title_tier = tier_kingdom
						legitimacy_level <= 2
					}
					AND = {
						highest_held_title_tier = tier_duchy
						legitimacy_level <= 1
					}
				}
				scope:potential_candidate = {
					is_lowborn = yes
				}
			}
			modifier = { #More likely if the shares same faith
				scope:potential_candidate.faith = root.faith
				add = 10
			}
			modifier = { #More likely if the shares same culture
				scope:potential_candidate.culture = root.culture
				add = 10
			}
			modifier = { #More likely if the candidate is the child of a vassal
				add = 35
				scope:potential_candidate = {
					any_close_family_member = { is_vassal_or_below_of = root }
				}
			}
			modifier = { #More likely if the candidate is the child of a powerful vassal
				add = 40
				scope:potential_candidate = {
					OR = {
						any_close_family_member = { 
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
								is_parent_of = root
							}
						}
						trigger_if = {
							limit = { root = { government_allows = administrative } }
							house ?= {
								is_powerful_family = yes
							}
						}
					}
				}
			}
			modifier = {
				government_has_flag = government_is_administrative
				scope:potential_candidate = {
					any_close_family_member = {
						government_has_flag = government_is_administrative
						top_liege ?= scope:liege
						house ?= {
							is_dominant_family = yes
						}
					}
				}
				add = 50
			}
			modifier = {
				scope:potential_candidate = {
					any_close_family_member = {
						tier_difference = {
							target = scope:liege
							value >= -1
						}
					}
				}
				add = 15
			}
			modifier = { #More likely if the candidate doesn't have the trait child of a concubine
				add = 10
				scope:potential_candidate = {
					NOR = {
						has_trait = child_of_concubine_female
						has_trait = child_of_concubine_male
						has_trait = wild_oat
						has_trait = bastard
					}
				}
			}
			modifier = { #More likely if the candidate has nice traits
				add = 10
				scope:potential_candidate = {
					OR = {
						has_trait = beauty_good_1
						has_trait = physique_good_1
						has_trait = intellect_good_1
					}
				}
			}
			modifier = { #More likely if the candidate has good traits
				add = 20
				scope:potential_candidate = {
					OR = {
						has_trait = beauty_good_2
						has_trait = physique_good_2
						has_trait = intellect_good_2
					}
				}
			}
			modifier = { #More likely if the candidate has excellent traits
				add = 30
				scope:potential_candidate = {
					OR = {
						has_trait = beauty_good_3
						has_trait = physique_good_3
						has_trait = intellect_good_3
					}
				}
			}
			modifier = { #More likely if the candidate has excellent traits
				add = 15
				scope:potential_candidate = {
					has_trait = pure_blooded
				}
			}
			modifier = { #More likely if the candidate has excellent traits
				add = 40
				scope:potential_candidate = {
					has_trait = golden_lineage
				}
			}
			modifier = { #More likely if the candidate has excellent traits
				add = 40
				faith.religion = religion:islam_religion
				scope:potential_candidate = {
					has_trait = sayyid
				}
			}
			modifier = { #More likely if the candidate has excellent traits
				add = 40
				faith.religion = religion:zoroastrianism_religion
				scope:potential_candidate = {
					has_trait = saoshyant
				}
			}
			modifier = { #More likely if the candidate is virtuous
				add = 10
				scope:potential_candidate = {
					num_sinful_traits = 0
				}
			}
			modifier = { #More likely if the candidate is virtuous
				add = {
					value = 10
					if = {
						limit = {
							num_virtuous_traits >= 2
						}
						add = 10
					}
				}
				scope:potential_candidate = {
					num_virtuous_traits >= 1
				}
			}
			modifier = { #More likely if the candidate isn't a criminal
				add = 10
				NOT = { has_imprisonment_reason = scope:potential_candidate }
			}
			modifier = { #More likely if root doesn't have kids
				add = 15
				is_virgin_trigger = yes
			}
			modifier = { #More likely if candidate has good skills
				add = 10
				scope:potential_candidate = {
					OR = { 
						stewardship >= 9
						learning >= 9
					}
				}
			}
			modifier = { #More likely if candidate has good skills
				add = 5
				scope:potential_candidate = {
					OR = { 
						stewardship >= 13
						learning >= 13
					}
				}
			}
			modifier = { #More likely if candidate has good skills
				add = 5
				scope:potential_candidate = {
					OR = { 
						stewardship >= 17
						learning >= 17
					}
				}
			}
			compatibility_modifier = { #Trait compatibility
				who = root
				compatibility_target = scope:potential_candidate
				min = -25
				max = 25
				multiplier = 1
			}
			modifier = {
				scope:liege = {
					trigger_if = {
						limit = {
							primary_title.tier >= 5
						}
						any_spouse = {
							count >= 4
						}
					}
					trigger_else_if = {
						limit = {
							primary_title.tier >= 4
						}
						any_spouse = {
							count >= 3
						}
					}
					trigger_else_if = {
						limit = {
							primary_title.tier >= 3
						}
						any_spouse = {
							count >= 2
						}
					}
					trigger_else = {
						any_spouse = {
							count >= 1
						}
					}
				}
				factor = 0.5
			}
			modifier = {
				scope:liege = {
					trigger_if = {
						limit = {
							primary_title.tier >= 5
						}
						any_spouse = {
							count > 4
						}
					}
					trigger_else_if = {
						limit = {
							primary_title.tier >= 4
						}
						any_spouse = {
							count > 3
						}
					}
					trigger_else_if = {
						limit = {
							primary_title.tier > 3
						}
						any_spouse = {
							count > 2
						}
					}
					trigger_else = {
						any_spouse = {
							count > 1
						}
					}
				}
				factor = 0.5
			}
			modifier = {
				gold <= bride_compensation_payment_value
				factor = 0
			}
		}
	}

	#Make them my concubine
	option = {
		name = bride_show.0005.b
		trigger = {
			allowed_concubines = yes
			allowed_more_concubines = yes
			scope:potential_candidate = {
				any_consort = {
					count = 0
				}
				is_adult = yes
				could_marry_character_trigger = { CHARACTER = scope:liege }
			}
			is_adult = yes
			gold >= bride_compensation_payment_value
		}
		show_as_unavailable = {
			NOT = { gold >= bride_compensation_payment_value }
			allowed_concubines = yes
			allowed_more_concubines = yes
			scope:potential_candidate = {
				is_adult = yes
				could_marry_character_trigger = { CHARACTER = scope:liege }
			}
			is_adult = yes
		}
		flavor = { #To get warning if you don't have enough money
			triggered_desc = {
				trigger = {
					NOT = { gold >= bride_compensation_payment_value }
				}
				desc = holy_order.0202.a._not.tt
			}
		}
		
		save_scope_value_as = {
			name = gold_to_pay
			value = bride_compensation_payment_value
		}
		#Reward
		if = {
			limit = {
				exists = scope:potential_candidate.court_owner
			}
			pay_short_term_gold = {
				target = scope:potential_candidate.court_owner
				gold = bride_compensation_payment_value
			}
			scope:potential_candidate = {
				save_scope_as = candidate_concubinage
				court_owner = {
					if = {
						limit = {
							any_close_family_member = {
								this = scope:candidate_concubinage
							}
							is_ai = no
						}
						trigger_event = bride_show.0008
					}
					else = {
						hidden_effect = {
							send_interface_toast = {
								type = event_generic_neutral
								title = chosen_consort_t
								right_icon = scope:liege
								left_icon = scope:potential_candidate								

								scope:liege = { 
									show_as_tooltip = {
										make_concubine = scope:potential_candidate
										pay_short_term_gold = {
											target = scope:potential_candidate.court_owner
											gold = bride_compensation_payment_value
										}
									}
									if = {
										limit  ={
											any_close_family_member = {
												this = scope:candidate_concubinage
											}
										}
										#Prestige
										if = {
											limit = {
												highest_held_title_tier = tier_kingdom
											}
											scope:potential_candidate.court_owner = {
												add_prestige = miniscule_prestige_gain
											}
										}
										else_if = {
											limit = {
												highest_held_title_tier >= tier_empire
											}
											scope:potential_candidate.court_owner = {
												add_prestige = minor_prestige_gain
											}
										}
									}
								}

								gain_influence_harem_politics_effect = {
									ACTOR = scope:potential_candidate.court_owner
									RECIPIENT = scope:liege
									CONCUBINE = scope:potential_candidate
								}
							}
						}
					}
				}
			}
			
			#Courtly vassals get a positive opinion
			if = {
				limit = {
					scope:potential_candidate.court_owner = {
						is_vassal_or_below_of = root
						OR = {
							has_vassal_stance = courtly
							has_trait = ambitious
							has_trait = greedy
							has_trait = arrogant
						}
						any_close_family_member = {
							this = scope:potential_candidate
						}
						agrees_with_bride_show = yes
					}
				}
				scope:potential_candidate.court_owner = {
					add_opinion = {
						target = root
						modifier = courtly_vassal_marriage_opinion
					}
				}
			}
		}
		else = {
			pay_short_term_gold = {
				target = scope:potential_candidate
				gold = bride_compensation_payment_value
			}
			if = {
				limit = {
					highest_held_title_tier = tier_kingdom
				}
				scope:potential_candidate = {
					add_prestige = miniscule_prestige_gain
				}
			}
			else_if = {
				limit = {
					highest_held_title_tier >= tier_empire
				}
				scope:potential_candidate = {
					add_prestige = minor_prestige_gain
				}
			}
		}
		
		stress_impact = {
			paranoid = miniscule_stress_impact_gain
		}
		
		scope:potential_candidate = {
			bride_show_break_betrothal_candidate_effect = yes
			hidden_effect = {
				if = {
					limit = {
						is_hostage = yes
					}
					return_hostage = yes
				}
			}
			save_scope_as = recipient
			save_scope_as = secondary_recipient
		}
		save_scope_as = actor
		save_scope_as = secondary_actor
		
		#Concubinage effects
		concubine_on_accept_effect = yes
		make_concubine = scope:recipient
		
		ai_chance = {
			base = 45
			modifier = { #Weigh down for stress
				add = -25
				has_trait = paranoid
			}
			modifier = { #Weigh down for stress
				add = -15
				has_trait = craven
			}
			modifier = { #Weigh down for stress
				add = -25
				has_trait = shy
			}
			modifier = { #More likely if root is lustful
				add = 20
				has_trait = lustful
			}

			modifier = { #More likely if the shares same faith
				scope:potential_candidate.faith = root.faith
				add = 10
			}
			modifier = { #More likely if the shares same culture
				scope:potential_candidate.culture = root.culture
				add = 10
			}
			modifier = {
				scope:potential_candidate = {
					is_lowborn = yes
				}
				add = 15
			}

			modifier = { #More likely if the candidate is the child of a vassal
				add = 5
				scope:potential_candidate = {
					any_close_family_member = { is_vassal_or_below_of = root }
				}
			}
			modifier = { #More likely if the candidate is the child of a powerful vassal
				add = 10
				scope:potential_candidate = {
					OR = {
						any_close_family_member = { 
							OR = {
								is_powerful_vassal_of = root
								is_councillor_of = root
								is_parent_of = root
							}
						}
						trigger_if = {
							limit = { root = { government_allows = administrative } }
							house ?= {
								is_powerful_family = yes
							}
						}
					}
				}
			}
			modifier = {
				government_has_flag = government_is_administrative
				scope:potential_candidate = {
					any_close_family_member = {
						government_has_flag = government_is_administrative
						top_liege ?= scope:liege
						house ?= {
							is_dominant_family = yes
						}
					}
				}
				add = 15
			}
			modifier = {
				scope:potential_candidate = {
					any_close_family_member = {
						tier_difference = {
							target = scope:liege
							value >= -1
						}
					}
				}
				add = 5
			}

			modifier = { # Beauty
				add = 10
				scope:potential_candidate = {
					has_trait = beauty_good_1
				}
			}
			modifier = { # Beauty
				add = 15
				scope:potential_candidate = {
					has_trait = beauty_good_2
				}
			}
			modifier = { # Beauty
				add = 20
				scope:potential_candidate = {
					has_trait = beauty_good_3
				}
			}

			modifier = { # Physique
				add = 5
				scope:potential_candidate = {
					has_trait = physique_good_1
				}
			}
			modifier = { # Physique
				add = 10
				scope:potential_candidate = {
					has_trait = physique_good_2
				}
			}
			modifier = { # Physique
				add = 15
				scope:potential_candidate = {
					has_trait = physique_good_3
				}
			}

			modifier = { # Intellect
				add = 5
				scope:potential_candidate = {
					has_trait = intellect_good_1
				}
			}
			modifier = { # Intellect
				add = 10
				scope:potential_candidate = {
					OR = {
						has_trait = intellect_good_2
						has_trait = intellect_good_3
					}
				}
			}

			modifier = { #More likely if the candidate has excellent traits
				add = 15
				scope:potential_candidate = {
					has_trait = pure_blooded
				}
			}
			modifier = { #More likely if the candidate has excellent traits
				add = 40
				scope:potential_candidate = {
					has_trait = golden_lineage
				}
			}
			modifier = { #More likely if the candidate is virtuous
				add = 10
				scope:potential_candidate = {
					num_sinful_traits = 0
				}
			}
			modifier = { #More likely if the candidate is virtuous
				add = {
					value = 10
					if = {
						limit = {
							num_virtuous_traits >= 2
						}
						add = 10
					}
				}
				scope:potential_candidate = {
					num_virtuous_traits >= 1
				}
			}
			modifier = { #More likely if the candidate isn't a criminal
				add = 5
				NOT = { has_imprisonment_reason = scope:potential_candidate }
			}
			modifier = { #More likely if root doesn't have kids
				add = 20
				is_virgin_trigger = yes
			}
			modifier = { #More likely if candidate has good skills
				add = 15
				scope:potential_candidate = {
					OR = {
						learning >= 9
						diplomacy >= 9
					}
				}
			}
			modifier = { #More likely if candidate has good skills
				add = 5
				scope:potential_candidate = {
					OR = {
						learning >= 13
						diplomacy >= 13
					}
				}
			}
			modifier = { #More likely if candidate has good skills
				add = 5
				scope:potential_candidate = {
					OR = {
						learning >= 17
						diplomacy >= 17
					}
				}
			}
			compatibility_modifier = { #Trait compatibility
				who = root
				compatibility_target = scope:potential_candidate
				min = -50
				max = 50
				multiplier = 2
			}
			modifier = { #Less likely if they could inherit a title
				add = -20
				scope:potential_candidate = {
					any_heir_title = {
						place_in_line_of_succession = {
							target = prev
							value <= 2
						}
					}
				}
			}
			modifier = { # More likely if root doesn't have enough concubines
				add = 20
				number_of_concubines < number_of_desired_concubines
			}
			modifier = {
				number_of_concubines >= number_of_desired_concubines
				any_consort = {
					can_have_children_with = { CHARACTER = root }
					can_have_children = yes
				}
				factor = 0.5
			}
			modifier = {
				number_of_concubines > number_of_desired_concubines
				factor = 0.5
			}
			modifier = {
				gold <= bride_compensation_payment_value
				factor = 0
			}
		}
	}

	#Recruit to court
	option = { # Recruit to court and break betrothal
		name = bride_show.0005.c
		if = {
			limit = {
				scope:potential_candidate = {
					exists = betrothed
				}
			}
			custom_tooltip = bride_show.0005.c.tt
		}
		trigger = {
			scope:potential_candidate = {
				is_adult = yes
			}
			gold >= bride_compensation_payment_value
		}
		show_as_unavailable = { 
			scope:potential_candidate = {
				is_adult = yes
			}
			NOT = { gold >= bride_compensation_payment_value } 
		}
		flavor = { #To get warning if you don't have enough money
			triggered_desc = {
				trigger = {
					NOT = { gold >= bride_compensation_payment_value }
				}
				desc = holy_order.0202.a._not.tt
			}
		}
		
		save_scope_value_as = {
			name = gold_to_pay
			value = bride_compensation_payment_value
		}
		#Reward
		if = {
			limit = {
				exists = scope:potential_candidate.court_owner
			}
			pay_short_term_gold = {
				target = scope:potential_candidate.court_owner
				gold = bride_compensation_payment_value
			}
			scope:potential_candidate = {
				save_scope_as = candidate_courtier
				court_owner = {
					if = {
						limit = {
							any_close_family_member = {
								this = scope:candidate_courtier
							}
							is_ai = no
						}
						trigger_event = bride_show.0008
					}
					else = {
						hidden_effect = {
							send_interface_toast = {
								type = event_generic_neutral
								title = chosen_candidate_t
								right_icon = scope:liege
								left_icon = scope:potential_candidate
								
								show_as_tooltip = {
									scope:liege = {
										add_courtier = scope:potential_candidate
										pay_short_term_gold = {
											target = scope:potential_candidate.court_owner
											gold = bride_compensation_payment_value
										}
									}
								}
								#Prestige
								if = {
									limit = {
										any_close_family_member = {
											this = scope:potential_candidate
										}
									}
									add_prestige = miniscule_prestige_gain
								}
								gain_influence_harem_politics_effect = {
									ACTOR = scope:potential_candidate.court_owner
									RECIPIENT = scope:liege
									CONCUBINE = scope:potential_candidate
								}
							}
						}
					}
				}
			}
		}
		else = {
			pay_short_term_gold = {
				target = scope:potential_candidate
				gold = bride_compensation_payment_value
			}
			scope:potential_candidate = {
				add_prestige = miniscule_prestige_gain
			}
		}
		
		stress_impact = {
			paranoid = miniscule_stress_impact_gain
		}
		
		scope:potential_candidate = {
			bride_show_break_betrothal_candidate_effect = yes
		}
		hidden_effect = {
			if = {
				limit = {
					scope:potential_candidate = {
						is_hostage = yes
					}
				}
				scope:potential_candidate = {
					return_hostage = yes
				}
			}
		}
		add_courtier = scope:potential_candidate
		scope:potential_candidate = {
			hidden_effect = {
				return_to_court = yes
			}
		}
		
		ai_chance = {
			base = 0
		}
	}

	#Break betrothal for kids
	option = { # I've got plans for you
		name = bride_show.0005.d
		trigger = {
			scope:potential_candidate = {
				is_betrothed = yes
				is_adult = no
			}
			gold >= bride_compensation_payment_value
		}
		show_as_unavailable = {
			scope:potential_candidate = {
				is_adult = no
			}
			NOT = { gold >= bride_compensation_payment_value } 
		}
		flavor = { #To get warning if you don't have enough money
			triggered_desc = {
				trigger = {
					NOT = { gold >= bride_compensation_payment_value }
				}
				desc = holy_order.0202.a._not.tt
			}
		}
		
		save_scope_value_as = {
			name = gold_to_pay
			value = bride_compensation_payment_value
		}
		#Reward
		if = {
			limit = {
				exists = scope:potential_candidate.court_owner
			}
			pay_short_term_gold = {
				target = scope:potential_candidate.court_owner
				gold = bride_compensation_payment_value
			}
			scope:potential_candidate.court_owner = {
				if = {
					limit = {
						any_close_family_member = {
							this = scope:potential_candidate
						}
						is_ai = no
					}
					trigger_event = bride_show.0008
				}
				else = {
					hidden_effect = {
						send_interface_toast = {
							type = event_generic_neutral
							title = chosen_candidate_t
							right_icon = scope:liege
							left_icon = scope:potential_candidate
							custom_tooltip = broken_betrothal_d
							if = {
								limit = {
									is_vassal_or_below_of = root
									OR = {
										has_vassal_stance = courtly
										has_trait = ambitious
										has_trait = greedy
										has_trait = arrogant
									}
									any_close_family_member = {
										this = scope:potential_candidate
									}
									agrees_with_bride_show = yes
								}
								add_prestige = miniscule_prestige_gain
							}
							show_as_tooltip = {
								scope:liege = { 
									pay_short_term_gold = {
										target = scope:potential_candidate.court_owner
										gold = bride_compensation_payment_value
									}
								}
							}
						}
					}
				}
			}
		}
		else = {
			pay_short_term_gold = {
				target = scope:potential_candidate
				gold = bride_compensation_payment_value
			}
			scope:potential_candidate = {
				add_prestige = miniscule_prestige_gain
			}
		}
		
		scope:potential_candidate = {
			bride_show_break_betrothal_candidate_effect = yes
		}
		
		ai_chance = {
			base = 0
		}
	}

	# Pass
	option = {
		name = bride_show.0005.e
		if = {
			limit = { 
				trigger_if = {
					limit = {
						can_have_four_candidates_trigger = no
					}
					exists = scope:candidate_2
				}
				trigger_else_if = {
					limit = {
						can_have_five_candidates_trigger = no
					}
					exists = scope:candidate_3
				}
				trigger_else = {
					exists = scope:candidate_4
				}
			}
			custom_tooltip = bride_show.0005.e_last.tt
		}
		else  = {
			custom_tooltip = bride_show.0005.e.tt
		}
		
		if = {
			limit = {
				scope:potential_candidate.court_owner ?= {
					is_vassal_or_below_of = root
					OR = {
						has_vassal_stance = courtly
						has_trait = ambitious
						has_trait = greedy
						has_trait = arrogant
					}
					is_close_family_of = scope:potential_candidate
					agrees_with_bride_show = yes
				}
			}
			scope:potential_candidate.court_owner = {
				add_opinion = {
					target = root
					modifier = courtly_vassal_rejected_opinion
				}
			}
		}
		
		scope:potential_candidate = {
			add_character_flag = {
				flag = rejected_candidate_flag
				days = 5
			}
			if = {
				limit = {
					NOR = {
						has_trait = paranoid
						has_trait = craven
						has_trait = shy
						has_trait = chaste
						has_trait = celibate
					}
					is_betrothed = no
					agrees_with_bride_show = yes
				}
				add_opinion = {
					target = root
					modifier = rejected_me_opinion
				}
			}
			else_if = {
				limit = {
					AND = {
						OR = {
							has_trait = arrogant
							has_trait = greedy
							has_trait = ambitious
						}
						agrees_with_bride_show = yes
					}
				}
				add_opinion = {
					target = root
					modifier = rejected_me_opinion
				}
			}
		}
		ai_chance = {
			base = 15
			modifier = { #Paranoid
				add = 20
				has_trait = paranoid
			}
			modifier = { #Shy
				add = 20
				has_trait = shy
			}
			modifier = { #Craven
				add = 10
				has_trait = craven
			}
			modifier = { #More likely if the candidate is not the child of a vassal
				add = 30
				scope:potential_candidate = {
					NOT = {
						any_close_family_member = { 
							OR = {
								is_vassal_or_below_of = root 
								is_tributary_of = root
							}
						}
					}
				}
			}
			modifier = { #More likely if the candidate doesn't have any good traits
				add = 15
				scope:potential_candidate = {
					NOR = {
						has_trait = beauty_good
						has_trait = intellect_good
						has_trait = physique_good
						has_trait = fecund
					}
				}
			}
			modifier = { #More likely if candidate has bad skills
				add = 15
				scope:potential_candidate = {
					learning < medium_skill_rating
					diplomacy < medium_skill_rating
					stewardship < medium_skill_rating
					trigger_if = {
						limit = {
							can_be_knight_trigger = { ARMY_OWNER = root }
						}
						martial < medium_skill_rating
						prowess < medium_skill_rating
					}
				}
			}
			modifier = {
				scope:potential_candidate = {
					num_of_bad_genetic_traits >= 1
				}
				add = {
					value = 25
					if = {
						limit = {
							num_of_bad_genetic_traits >= 2
						}
						add = 10
					}
				}
			}
		}
	}
	
	after = {
		scope:potential_candidate = {
			bride_show_saved_candidate_effect = {
				LIST = eligible_candidates_list
			}
		}
		if = {
			limit = {
				exists = scope:pc_court_owner
			}
			clear_saved_scope = pc_court_owner
		}
		hidden_effect = {
			bride_show_next_candidate_effect = yes
		}
	}

}

bride_show.0006 = {
	type = character_event
	title = bride_show.0006.t
	desc = bride_show.0006.desc

	theme = realm
	
	right_portrait = { 	
		character = scope:right_portrait_character
		animation = personality_content
	}
	left_portrait = { 	
		character = scope:candidate_1
		animation = personality_compassionate
	}
	lower_left_portrait = { 	
		character = scope:candidate_2
	}
	lower_center_portrait = { 	
		trigger = {
			exists = scope:candidate_4
		}
		character = scope:candidate_4
	}
	lower_right_portrait = { 	
		character = scope:candidate_3
	}

	immediate = {
		if = {
			limit = {
				exists = scope:candidate_5
			}
			scope:candidate_5 = {
				save_scope_as = right_portrait_character
			}
		}
		else = {
			save_scope_as = right_portrait_character
		}
	}
	
	option = {
		name = bride_show.0006.a
		if = {
			limit = {
				is_valid_for_legitimacy_change = yes
			}
			add_legitimacy = miniscule_legitimacy_gain
		}
		bride_show_ending_effect = yes
		ai_chance = {
			base = 15
		}
	}
}

#############################
##Announcing the Bride Show##
#############################
bride_show.0007 = {
	type = letter_event
	opening = { desc = bride_show.opening.desc	}

	desc = {
		first_valid = {
			triggered_desc = { #Vassals
				trigger = {
					is_vassal_or_below_of = scope:liege
				}
				desc = bride_show.0007.start_vassal.desc
			}
			#Tributaries
			desc = bride_show.0007.start_tributary.desc
		}
		desc = bride_show.0007.desc.request
		first_valid = {
			triggered_desc = { #Vassal
				trigger = {
					is_vassal_or_below_of = scope:liege
				}
				desc = bride_show.0007.end_vassal.desc
			}
			#Tributary
			desc = bride_show.0007.end_tributary.desc
		}
	}
	sender = scope:liege

	trigger = {
		harem_politics_is_valid_bride_show_subject_trigger = {
			OVERLORD = scope:liege
		}
		any_courtier = {
			bride_show_viable_candidate_trigger = {
				OVERLORD = scope:liege
			} 
		}
	}

	immediate = {
		save_scope_as = subject_scope
		if = {
			limit = {
				is_vassal_or_below_of = scope:liege
			}
			if = {
				limit = {
					OR = { 
						culture = { has_cultural_tradition = tradition_ep3_palace_politics }
						culture = { has_cultural_tradition = tradition_legalistic }
						hp_accepts_harems = yes
					}
				}
				if = {
					limit = {
						OR = {
							has_vassal_stance = courtly
							has_trait = ambitious
							has_trait = greedy
							has_trait = arrogant
						}
					}
					add_opinion = {
						target = scope:liege
						modifier = bride_show_vassal_opinion
						opinion = 5
					}
				}
				else = {
					add_opinion = {
						target = scope:liege
						modifier = bride_show_vassal_opinion
						opinion = -10
					}
				}
			}
			else = {
				add_opinion = {
					target = scope:liege
					modifier = bride_show_vassal_opinion
					opinion = -20
				}
			}
		}
		else = {
			if = {
				limit = {
					OR = { 
						culture = { has_cultural_tradition = tradition_ep3_palace_politics }
						culture = { has_cultural_tradition = tradition_legalistic }
						hp_accepts_harems = yes
					}
				}
				add_opinion = {
					target = scope:liege
					modifier = bride_show_vassal_opinion
					opinion = -20
				}
			}
			else = {
				add_opinion = {
					target = scope:liege
					modifier = bride_show_vassal_opinion
					opinion = -30
				}
			}
		}
	}

	#There's nothing I can do
	option = {
		name = bride_show.0007.a
		trigger = {
			is_vassal_or_below_of = scope:liege
		}
		scope:liege = {
			add_to_variable_list = {
				name = bride_show_subject_list
				target = root
				days = 15
			}
		}
		ai_chance = {
			base = 1
		}
	}
	#I shall accept it
	option = {
		name = bride_show.0007.b
		trigger = {
			NOT = {
				is_vassal_or_below_of = scope:liege
			}
		}
		# Accepting it is akin to being treated as a vassal
		add_prestige = medium_prestige_loss
		scope:liege = {
			hidden_effect = {
				if = {
					limit = {
						is_ai = no
					}
					send_interface_toast = {
						type = event_generic_good
						title = bride_show.0007.b.t
						right_icon = root
						custom_tooltip = bride_show.0007.b.desc
						if = {
							limit = {
								root.highest_held_title_tier >= tier_empire
							}
							add_prestige = medium_prestige_gain
						}
						else_if = {
							limit = {
								root.highest_held_title_tier = tier_kingdom
							}
							add_prestige = minor_prestige_gain
						}
					}
				}
				else = {
					if = {
						limit = {
							root.highest_held_title_tier >= tier_empire
						}
						add_prestige = medium_prestige_gain
					}
					else_if = {
						limit = {
							root.highest_held_title_tier = tier_kingdom
						}
						add_prestige = minor_prestige_gain
					}
				}
				add_to_variable_list = {
					name = bride_show_subject_list
					target = root
					days = 15
				}
			}
		}
		stress_impact = {
			arrogant = minor_stress_impact_gain
			brave = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = -0.2
				ai_greed = -0.2
			}
			opinion_modifier = {
				opinion_target = scope:liege
				multiplier = 1
				max = 30
			}
			modifier = {
				is_obedient_to = scope:liege
				scope:liege = {
					government_has_flag = government_is_nomadic
				}
				add = 500
			}
			modifier = { #A scared tributary won't decline
				add = 115
				NOT = { 
					scope:liege = {
						government_has_flag = government_is_nomadic
					}
				}
				trigger_if = {
					limit = {
						highest_held_title_tier > scope:liege.highest_held_title_tier
					}
					has_dread_level_towards = {
						target = scope:liege
						level >= 2
					}
				}
				trigger_else_if = {
					limit = {
						highest_held_title_tier = scope:liege.highest_held_title_tier
					}
					has_dread_level_towards = {
						target = scope:liege
						level >= 1
					}
				}
				trigger_else = {
					always = no
				}
			}

			modifier = {
				has_trait = arrogant
				add = -25
			}
			modifier = {
				has_trait = brave
				add = -25
			}
			modifier = {
				has_trait = disloyal
				add = -15
			}
			modifier = {
				has_trait = loyal
				add = 15
			}
			modifier = {
				has_trait = craven
				add = 25
			}

			modifier = { #Kings are less likely to send their relatives
				highest_held_title_tier >= tier_kingdom
				add = -10
			}
			modifier = {
				hp_accepts_harems = no
				scope:liege = {
					hp_accepts_harems = yes
				}
				add = -25
			}
		}
	}
	#I shall refuse!
	option = {
		name = bride_show.0007.c
		trigger = {
			NOT = {
				is_vassal_or_below_of = scope:liege
			}
		}
		if = {
			limit = {
				scope:liege.highest_held_title_tier >= tier_empire
			}
			add_prestige = medium_prestige_gain
		}
		else_if = {
			limit = {
				scope:liege.highest_held_title_tier >= tier_kingdom
			}
			add_prestige = minor_prestige_gain
		}
		else = {
			add_prestige = miniscule_prestige_gain
		}
		scope:liege = {
			hidden_effect = {
				if = {
					limit = {
						is_ai = no
					}
					send_interface_toast = {
						type = event_generic_bad
						title = bride_show.0007.c.t
						right_icon = root
						custom_tooltip = bride_show.0007.c.desc
					}
				}
			}
			add_opinion = {
				target = root
				modifier = upset_opinion
				opinion = -15
			}
		}
		stress_impact = {
			craven = minor_stress_impact_gain
		}
		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.2
				ai_greed = 0.2
			}
			opinion_modifier = {
				opinion_target = scope:liege
				multiplier = -1
				max = 30
			}
			modifier = {
				NOT = { is_obedient_to = scope:liege }
				scope:liege = {
					government_has_flag = government_is_nomadic
				}
				add = 400
			}
			modifier = { #A scared tributary won't decline
				add = 100
				NOT = { 
					scope:liege = {
						government_has_flag = government_is_nomadic
					}
				}
				has_dread_level_towards = {
					target = scope:liege
					level = 0
				}
			}
			modifier = { #A scared tributary won't decline
				add = 100
				NOT = { 
					scope:liege = {
						government_has_flag = government_is_nomadic
					}
				}
				trigger_if = {
					limit = {
						highest_held_title_tier > scope:liege.highest_held_title_tier
					}
					has_dread_level_towards = {
						target = scope:liege
						level <= 1
					}
				}
				trigger_else_if = {
					limit = {
						highest_held_title_tier = scope:liege.highest_held_title_tier
					}
					has_dread_level_towards = {
						target = scope:liege
						level < 1
					}
				}
				trigger_else = {
					always = no
				}
			}

			modifier = {
				has_trait = arrogant
				add = 25
			}
			modifier = {
				has_trait = brave
				add = 25
			}
			modifier = {
				has_trait = disloyal
				add = 15
			}
			modifier = {
				has_trait = loyal
				add = -15
			}
			modifier = {
				has_trait = craven
				add = -25
			}

			modifier = { #Kings are less likely to send their relatives
				highest_held_title_tier >= tier_kingdom
				add = 15
			}
			modifier = {
				hp_accepts_harems = no
				scope:liege = {
					hp_accepts_harems = yes
				}
				add = 25
			}
		}
	}
}

################
##Notification##
################
bride_show.0008 = {
	type = letter_event
	opening = { desc = bride_show.opening.desc	}
	
	desc = {
		first_valid = {
			triggered_desc = { #Chosen as a spouse
				trigger = {
					scope:candidate_marriage ?= scope:potential_candidate
				}
				desc = bride_show.married.desc
			}
			triggered_desc = { #Chosen as a consort
				trigger = {
					scope:candidate_concubinage ?= scope:potential_candidate
				}
				desc = bride_show.concubine.desc
			}
			triggered_desc = { #Recruited to court
				trigger = {
					scope:candidate_courtier ?= scope:potential_candidate
				}
				desc = bride_show.recruit.desc
			}
			#Fallback
			desc = bride_show.fallback.desc
		}
	}
	sender = scope:liege
	
	immediate = {
		scope:liege = {
			show_as_tooltip = {
				pay_short_term_gold = {
					target = root
					gold = scope:gold_to_pay
				}
			}
			#Prestige
			if = {
				limit = {
					root = {
						any_close_family_member = {
							this = scope:potential_candidate
						}
					}
				}
				if = {
					limit = {
						scope:candidate_marriage ?= scope:potential_candidate
					}
					if = {
						limit = {
							highest_held_title_tier = tier_duchy
						}
						root = {
							add_prestige = miniscule_prestige_gain
						}
					}
					else_if = {
						limit = {
							highest_held_title_tier = tier_kingdom
						}
						root = {
							add_prestige = minor_prestige_gain
						}
					}
					else_if = {
						limit = {
							highest_held_title_tier >= tier_empire
						}
						root = {
							add_prestige = medium_prestige_gain
						}
					}
				}
				else_if = {
					limit = {
						scope:candidate_concubinage ?= scope:potential_candidate
					}
					#Prestige
					if = {
						limit = {
							highest_held_title_tier = tier_kingdom
						}
						root = {
							add_prestige = miniscule_prestige_gain
						}
					}
					else_if = {
						limit = {
							highest_held_title_tier >= tier_empire
						}
						root = {
							add_prestige = minor_prestige_gain
						}
					}
				}
				else_if  ={
					limit = {
						scope:candidate_courtier ?= scope:potential_candidate
					}
					root = {
						add_prestige = miniscule_prestige_gain
					}
				}
			}
		}
		if = {
			limit = {
				scope:potential_candidate = {
					is_adult = yes
				}
			}
			gain_influence_harem_politics_effect = {
				ACTOR = root
				RECIPIENT = scope:liege
				CONCUBINE = scope:potential_candidate
			}
		}
	}

	option = {
		name = bride_show.0007.a
		ai_chance = {
			base = 1
		}
	}
}

bride_show.1000 = { 
	type = character_event
	title = bride_show.1000.t
	desc = bride_show.1000.desc
	theme = realm
	
	left_portrait = { 	
		character = root
		animation = personality_greedy
	}
	right_portrait = {
		character = scope:tributary_scope
		animation = disapproval
	}

	trigger = {
		any_in_list = {
			list = bride_show_preliminary_list
			harem_politics_is_valid_bride_show_subject_trigger = {
				OVERLORD = scope:liege
			}
			NOT = {
				is_vassal_or_below_of = scope:liege
			}
			count >= 1
		}
	}
	immediate = {
		ordered_in_list = {
			list = bride_show_preliminary_list
			limit = {
				NOT = {
					is_vassal_or_below_of = scope:liege
				}
			}
			order_by = {
				value = primary_title.tier
				add = dominance_value
			}
			save_scope_as = tributary_scope
		}
	}

	#Invite tributaries' courtiers
	option = {
		name = bride_show.1000.a
		custom_tooltip = bride_show_tributary_invite_effect_tooltip
		custom_tooltip = bride_show_tributary_opinion_effect_tooltip
		add_prestige = minor_prestige_loss
		set_local_variable = {
			name = bride_show_tributary_participation
			value = yes
		}
		stress_impact = {
			craven = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}

		ai_chance = {
			base = 10
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_greed = 1
			}
			modifier = { #Stress
				has_trait = craven
				add = -25
			}
			modifier = {
				has_trait = paranoid
				add = -25
			}
			modifier = {
				has_trait = shy
				add = -15
			}
			modifier = {
				has_trait = content
				add = -15
			}
			modifier = {
				has_trait = humble
				add = -15
			}


			modifier = {
				trigger_if = {
					limit = {
						government_has_flag = government_is_nomadic
					}
					any_in_list = {
						list = bride_show_preliminary_list
						count = 4
					}
				}
				trigger_else = {
					any_in_list = {
						list = bride_show_preliminary_list
						count = 3
					}
				}
				add = 20
			}

			modifier = {
				any_tributary = {
					harem_politics_is_valid_bride_show_subject_trigger = {
						OVERLORD = scope:liege
					}
					count >= 2
				}
				add = 10
			}
			modifier = {
				any_tributary = {
					harem_politics_is_valid_bride_show_subject_trigger = {
						OVERLORD = scope:liege
					}
					count >= 3
				}
				add = 10
			}
			modifier = {
				any_in_list = {
					list = bride_show_preliminary_list
					is_vassal_or_below_of = scope:liege
					count >= 5
				}
				add = -15
			}
			modifier = {
				prestige <= minor_prestige_value
				add = -50
			}
		}
	}

	#Do not invite them
	option = {
		name = bride_show.1000.c

		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_boldness = -0.5
				ai_greed = -1
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = { #Stress
				has_trait = craven
				add = 15
			}
			modifier = {
				has_trait = paranoid
				add = 15
			}
			modifier = {
				has_trait = shy
				add = 15
			}
			modifier = {
				has_trait = content
				add = 15
			}
			modifier = {
				has_trait = humble
				add = 15
			}

			modifier = {
				prestige <= minor_prestige_gain
				add = 100
			}
			modifier = {
				any_in_list = {
					list = bride_show_preliminary_list
					is_vassal_or_below_of = scope:liege
					count >= 5
				}
				add = 25
			}
		}
	}

	after = {
		trigger_event = {
			id = bride_show.0001
			days = { 10 14 }
		}
		clear_saved_scope = tributary_scope
	}
}

##Managing the eligible subjects##
bride_show.1001 = {
	hidden = yes
	immediate = {
		if = {
			limit = {
				any_vassal_or_below = {
					harem_politics_is_valid_bride_show_subject_trigger = {
						OVERLORD = scope:liege
					}
					any_courtier = {
						bride_show_viable_candidate_trigger = {
							OVERLORD = scope:liege
						} 
					}
					count >= 1
				}
			}
			every_vassal_or_below = {
				limit = {
					harem_politics_is_valid_bride_show_subject_trigger = {
						OVERLORD = scope:liege
					}
					any_courtier = {
						bride_show_viable_candidate_trigger = {
							OVERLORD = scope:liege
						} 
					}
				}
				trigger_event = bride_show.0007
			}
		}
		if = {
			limit = {
				any_tributary = {
					harem_politics_is_valid_bride_show_subject_trigger = {
						OVERLORD = scope:liege
					}
					any_courtier = {
						bride_show_viable_candidate_trigger = {
							OVERLORD = scope:liege
						} 
					}
					count >= 1
				}
				exists = local_var:bride_show_tributary_participation
			}
			every_tributary = {
				limit = {
					harem_politics_is_valid_bride_show_subject_trigger = {
						OVERLORD = scope:liege
					}
					any_courtier = {
						bride_show_viable_candidate_trigger = {
							OVERLORD = scope:liege
						} 
					}
				}
				trigger_event = bride_show.0007
			}
		}
		trigger_event = {
			id = bride_show.0004
			days = 10
		}
	}
}

bride_show.1002 = {
	hidden = yes
	trigger = {
		is_ai = no
		any_in_list = {
			list = eligible_candidates_list
			is_courtier_of = root
			count >= 1
		}
	}
	immediate = {
		save_scope_as = subject
		if = {
			limit = {
				any_in_list = {
					list = eligible_candidates_list
					is_courtier_of = root
					count > 1
				}
			}
			set_variable = {
				name = num_courtiers_summoned
				value = -1
			}
			every_in_list = {
				list = eligible_candidates_list
				limit = {
					is_courtier_of = root
				}
				root = {
					change_variable = {
						name = num_courtiers_summoned
						add = 1
					}
				}
				add_to_list = summoned_courtiers_list
			}
			ordered_in_list = {
				list = summoned_courtiers_list

				order_by = {
					value = bride_show_candidate_weights_for_root_value
				}
				if = {
					limit = {
						NOT = {
							exists = scope:drafted_candidate
						}
					}
					save_scope_as = drafted_candidate
				}
				remove_from_list = summoned_courtiers_list
			}
		}
		else = {
			random_in_list = {
				list = eligible_candidates_list
				limit = {
					is_courtier_of = root
				}
				save_scope_as = drafted_candidate
			}
		}

		send_interface_toast = {
			type = event_generic_neutral
			title = {
				first_valid = {
					triggered_desc = {
						trigger = {
							scope:liege = {
								is_female = yes
							}
						}
						desc = bride_show.0005_f.t
					}
					desc = bride_show.0005_m.t
				}
			}
			right_icon = scope:liege
			left_icon = scope:drafted_candidate
			if = {
				limit = {
					NOT = {
						has_variable = num_courtiers_summoned
					}
				}
				custom_tooltip = bride_show_1_courtiers_desc
			}
			else = {
				custom_tooltip = bride_show_more_courtiers_desc
				remove_variable = num_courtiers_summoned
			}
		}
	}
}