﻿namespace = bride_show

########################
###Recruit Concubines###
########################

## For dukes ##
bride_show.2000 = {
	hidden = yes
	trigger = {
		is_alive = yes
		is_landed_or_landless_administrative = yes
		hp_accepts_concubinage = yes
		trigger_if = {
			limit = {
				has_variable = jarya_recruited
			}
			var:jarya_recruited < 4
		}
		trigger_if = {
			limit = {
				exists = capital_county
			}
			NOT = {
				capital_county = { has_county_modifier = isolate_capital_decision_modifier }
			}
		}
		NOR = {
			has_character_modifier = isolating_modifier
		}
	}

	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 = pool_candidates
					recruit_concubines_viable_candidate_trigger = {
						OVERLORD = scope:liege
					}
					count = 0
				}
			}
			calyver_create_candidate_effect = yes
			if = {
				limit = {
					exists = scope:bride
				}
				scope:bride = {
					add_to_list = pool_candidates
				}
				clear_saved_scope = bride
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = pool_candidates
					recruit_concubines_viable_candidate_trigger = {
						OVERLORD = scope:liege
					}
					count = 1
				}
			}
			random_in_list = {
				list = pool_candidates
				limit = {
					recruit_concubines_viable_candidate_trigger = {
						OVERLORD = scope:liege
					}
				}
				save_scope_as = jarya
			}
		}
		else = {
			random_in_list = {
				list = pool_candidates
				limit = {
					recruit_concubines_viable_candidate_trigger = {
						OVERLORD = scope:liege
					}
				}
				weight = {
					base = 50
					modifier = {
						exists = court_owner
						add = -25
					}
					modifier = {
						scope:liege.religion = religion:islam_religion
						location ?= {
							county.holder ?= {
								religion != religion:islam_religion
							}
						}
						add = 20
					}
					modifier = { # Christians were especially captured
						scope:liege.religion = religion:islam_religion
						religion = religion:christianity_religion
						add = 30
					}
					modifier = { # Foreigners were more exotic
						culture != scope:liege.culture
						scope:liege.religion = religion:islam_religion
						add = 5
					}
					modifier = { # Locals are preferred
						culture = scope:liege.culture
						scope:liege.religion != religion:islam_religion
						add = 5
					}
					modifier = {
						is_lowborn = no
						add = -25
					}
					# Virginity was prized
					modifier = {
						is_virgin_trigger = yes
						add = 25
					}
					# Skills
					modifier = {
						add = {
							value = stewardship
							add = diplomacy
							add = learning
						}
					}
					# Good genetics
					modifier = { #Trait considerations
						num_of_good_genetic_traits >= 1
						add = {
							value = num_of_good_genetic_traits
							multiply = 10
						}
					}
					# No bad genetic traits
					modifier = {
						num_of_bad_genetic_traits > 0
						add = {
							value = num_of_bad_genetic_traits
							multiply = -5
						}
					}
					# Docile captives would be easier to send
					modifier = {
						has_trait = temperate
						add = 10
					}
					modifier = {
						has_trait = craven
						add = 10
					}
					modifier = {
						has_trait = content
						add = 10
					}
					modifier = {
						has_trait = humble
						add = 10
					}
					modifier = {
						has_trait = lustful
						add = 10
					}
					modifier = {
						has_trait = chaste
						add = -10
					}
					modifier = {
						has_trait = zealous
						add = -20
					}
					modifier = {
						has_trait = strong
						add = 5
					}
					# Poets
					modifier = {
						has_trait = lifestyle_poet
						add = 5
					}
					# Skills
					modifier = { #Intrigue
						add = {
							value = intrigue
							divide = 2
						}
					}
					# Health
					modifier = {
						is_healthy = yes
						add = 25
					}
					modifier = {
						bride_show_beauty_important_parameters_trigger = yes
						add = 10
					}
				}
				save_scope_as = jarya
			}
		}
		if = {
			limit = {
				scope:jarya.court_owner ?= {
					NOT = { this = scope:liege }
					is_ai = no
				}
				scope:jarya = {
					has_any_court_position = yes
				}
			}
			if = {
				limit = {
					scope:liege.faith.religion = religion:islam_religion
				}
				scope:jarya.court_owner = {
					send_interface_toast = {
						type = event_generic_bad
						title = bride_show.2000.t.court_owner.abducted
						right_icon = scope:liege
						left_icon = scope:jarya
						custom_tooltip = bride_show.2000.desc.court_owner.abducted
					}
				}
			}
			else = {
				scope:jarya.court_owner = {
					send_interface_toast = {
						type = event_generic_neutral
						title = bride_show.2000.t.court_owner.recruited
						right_icon = scope:liege
						left_icon = scope:jarya
						show_as_tooltip = {
							scope:liege = {
								add_courtier = scope:jarya
							}
						}
					}
				}
			}
		}
		scope:jarya = {
			if = {
				limit = {
					is_betrothed = yes
					betrothed ?= { this != scope:liege }
				}
				scope:liege = {
					save_scope_as = actor
				}
				betrothed = { trigger_event = marriage_interaction.0041 }
				clear_saved_scope = actor
				break_betrothal = betrothed
			}
		}
		send_interface_toast = {
			type = event_generic_neutral
			title = bride_show.2000.t
			right_icon = scope:jarya
			add_courtier = scope:jarya
			scope:jarya = {
				if = {
					limit = {
						scope:liege.faith.religion = religion:islam_religion
					}
					add_opinion = {
						target = scope:liege
						modifier = upset_opinion
						opinion = -10
					}
					stress_impact = {
						base = minor_stress_impact_gain
					}
					if = {
						limit = {
							any_close_family_member = {
								NOT = { this = scope:liege }
								count >= 1
							}
						}
						every_close_family_member = {
							limit = {
								NOT = { this = scope:liege }
							}
							add_opinion = {
								target = scope:liege
								modifier = abducted_close_family_crime
							}
							if = {
								limit = {
									is_ai = no
								}
								send_interface_toast = {
									type = event_generic_bad
									title = bride_show.2000.t.close_family
									right_icon = scope:liege
									left_icon = scope:jarya
									custom_tooltip = bride_show.2000.desc.court_owner.abducted
								}
							}
						}
					}
				}
				add_character_flag = {
					flag = recently_abducted_concubine
					years = 2
				}
				#In case they received a marriage proposal already
				# add_character_flag = {
				# 	flag = has_been_offered_as_concubine
				# 	days = 1
				# }
				remove_from_list = pool_candidates
				add_character_flag = {
					flag = blocked_from_leaving
					years = 5
				}
				hidden_effect = {
					return_to_court = yes
					# Chance of conversion to liege's faith
					if = {
						limit = {
							NOR = {
								has_trait = zealous 
								faith = scope:liege.faith
							}
						}
						random = {
							chance = 30
							# Based on current faith
							modifier = {
								faith = {
									faith_hostility_level = {
										target = scope:liege.faith
										value = faith_fully_accepted_level
									}
								}
								add = 30
							}
							modifier = {
								faith = {
									faith_hostility_level = {
										target = scope:liege.faith
										value >= faith_astray_level
									}
								}
								add = -15
							}
							modifier = {
								faith = {
									faith_hostility_level = {
										target = scope:liege.faith
										value >= faith_hostile_level
									}
								}
								add = -15
							}
							modifier = {
								faith = {
									faith_hostility_level = {
										target = scope:liege.faith
										value >= faith_evil_level
									}
								}
								add = -15
							}
							modifier = {
								hp_accepts_harems = yes
								add = 10
							}
							# Based on traits
							modifier = {
								has_trait = cynical
								add = 20
							}
							modifier = {
								OR = {
									has_trait = ambitious
									has_trait = greedy
									has_trait = arrogant
								}
								add = 20
							}
							modifier = {
								has_trait = craven
								add = 20
							}
							# Younger characters are more likely to change faiths
							modifier = {
								age < 20
								add = 15
							}
							# Zealous rulers are more likely to recruit converted concubines
							modifier = {
								scope:liege = { has_trait = zealous }
								add = 15
							}
							# Cynical rulers don't care much about concubines' faith
							modifier = {
								scope:liege = { has_trait = cynical }
								add = -15
							}
							if = {
								limit = {
									scope:liege.religion = religion:islam_religion
									religion != religion:islam_religion
								}
								add_character_flag = {
									flag = abducted_non_believer
									years = 5
								}
							}
							set_character_faith = scope:liege.faith
						}
					}
					# They should be lowborn
					if = {
						limit = {
							house ?= {
								any_house_member = {
									count = 1
								}
							}
						}
						set_to_lowborn = yes
					}
				}
				# remove_character_flag = has_been_offered_as_concubine
			}
		}
		if = {
			limit = {
				NOT = {
					has_variable = jarya_recruited
				}
			}
			set_variable = {
				name = jarya_recruited
				value = 1
				months = 3
			}
			if = {
				limit = {
					OR = {
						highest_held_title_tier = tier_duchy
						AND = {
							highest_held_title_tier = tier_county
							is_ai = no
						}
					}
				}
				random = {
					chance = 50
					modifier = {
						has_trait = lustful
						add = 10
					}
					trigger_event = {
						id = bride_show.2000
						days = { 7 10 }
					}
				}
			}
			else_if = {
				limit = {
					highest_held_title_tier > tier_duchy
				}
				trigger_event = {
					id = bride_show.2000
					days = { 7 10 }
				}
			}
		}
		else = {
			change_variable = {
				name = jarya_recruited
				add = 1
			}
			# Should we repeat the event?
			# For dukes, the maximum is 3
			if = {
				limit = {
					highest_held_title_tier = tier_duchy
				}
				if = {
					limit = {
						var:jarya_recruited < 3
					}
					random = {
						chance = 25
						modifier = {
							has_trait = lustful
							add = 10
						}
						trigger_event = {
							id = bride_show.2000
							days = { 7 10 }
						}
					}
				}
				else = {
					remove_variable = jarya_recruited
				}
			}
			# For kings+, the maximum is 4
			if = {
				limit = {
					highest_held_title_tier > tier_duchy
				}
				if = {
					limit = {
						var:jarya_recruited < 3
					}
					random = {
						chance = 50
						modifier = {
							has_trait = lustful
							add = 10
						}
						trigger_event = {
							id = bride_show.2000
							days = { 7 10 }
						}
					}
				}
				else_if = {
					limit = {
						var:jarya_recruited = 3
					}
					random = {
						chance = 25
						modifier = {
							has_trait = lustful
							add = 10
						}
						modifier = {
							highest_held_title_tier > tier_kingdom
							add = 10
						}
						trigger_event = {
							id = bride_show.2000
							days = { 7 10 }
						}
					}
				}
				else_if = {
					limit = {
						var:jarya_recruited > 3	
					}
					remove_variable = jarya_recruited
				}
			}
		}
		# The AI is a bit slow and will sometimes convert them to Islam before taking them as concubines
		if = {
			limit = {
				is_ai = yes
				is_character_interaction_valid = {
					recipient = scope:jarya
					interaction = make_concubine_interaction
				}
				allowed_more_concubines = yes
			}
			random = {
				chance = 10
				modifier = {
					number_of_concubines < number_of_desired_concubines
					add = 60
				}
				modifier = {
					scope:jarya = {
						num_of_good_genetic_traits > 0
					}
					add = 25
				}
				modifier = {
					scope:jarya = {
						num_of_bad_genetic_traits > 0
					}
					add = -50
				}
				modifier = {
					scope:jarya = {
						can_have_children_with = { CHARACTER = scope:liege } # Only if you can have kids since this is about fertility and genetic traits
						fertility > 0.2
					}
					add = 10
				}
				modifier = {
					is_attracted_to_gender_of = scope:jarya
					add = 10
				}
				modifier = {
					NOT = { is_attracted_to_gender_of = scope:jarya }
					add = -25
				}
				modifier = {
					OR = { 
						has_relation_lover = scope:jarya
						has_relation_friend = scope:jarya
						has_relation_soulmate = scope:jarya
						has_relation_best_friend = scope:jarya
					}
					add = 60
				}
				run_interaction = {
					interaction = make_concubine_interaction
					actor = scope:liege
					secondary_actor = scope:liege
					recipient = scope:jarya
					secondary_recipient = scope:jarya
					execute_threshold = accept
				}
			}
		}
	}
}

## For kings and above ##

# Beauty #
bride_show.3000 = {
	type = character_event
	title = {
		desc = bride_show.3000.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 = diplomacy
	
	left_portrait = { 	
		character = root
		animation = personality_honorable
	}
	right_portrait = {
		trigger = {
			scope:attendant != root
		}
		character = scope:attendant
		animation = personality_content
	}
	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 = {
				OR = {
					NOT = { exists = scope:attendant }
					scope:attendant = {
						is_alive = no
					}
				}
			}
			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
				}
			}
			else = {
				save_scope_as = attendant
			}
		}
	}

	option = {
		name = bride_show.0002.a
		trigger = {
			gold >= minor_gold_value
		}
		show_as_unavailable = {
			NOT = { gold >= minor_gold_value }
		}
		remove_short_term_gold = minor_gold_value

		set_variable = {
			name = beauty_important
			value = yes
			days = 40
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				gold >= medium_gold_value
				add = 20
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
		}
	}
	
	option = {
		name = bride_show.0001.b
		ai_chance = {
			base = 10
		}
	}
	after = {
		trigger_event = {
			id = bride_show.3001
			days = { 5 10 }
		}
	}
}

# Virtue #
bride_show.3001 = {
	type = character_event
	title = {
		desc = bride_show.3000.t
		desc = bride_show.0003.t
	}
	desc = bride_show.3001.desc
	theme = diplomacy
	
	left_portrait = { 	
		character = root
		animation = thinking
	}
	right_portrait = {
		trigger = {
			scope:attendant != root
		}
		character = scope:attendant
		animation = personality_content
	}

	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 = {
				OR = {
					NOT = { exists = scope:attendant }
					scope:attendant = {
						is_alive = no
					}
				}
			}
			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
				}
			}
			else = {
				save_scope_as = attendant
			}
		}
	}

	option = {
		name = bride_show.0003.a
		trigger = {
			gold >= minor_gold_value
		}
		show_as_unavailable = {
			NOT = { gold >= minor_gold_value }
		}
		remove_short_term_gold = minor_gold_value

		set_variable = {
			name = personality_skills_important
			value = yes
			days = 40
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 1
			modifier = {
				gold >= medium_gold_value
				add = 20
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
		}
	}
	
	option = {
		name = bride_show.0001.b
		ai_chance = {
			base = 10
		}
	}
	after = {
		# Manage your subjects #
		trigger_event = {
			id = bride_show.3002
			days = { 4 9 }
		}
	}
}

##Managing the eligible subjects##
scripted_trigger is_valid_candidate_for_recruitment_trigger = {
	royal_concubines_eligible_candidate_trigger = {
		OVERLORD = $OVERLORD$
	}
	trigger_if = {
		limit = {
			exists = court_owner
		}
		court_owner = {
			harem_politics_valid_bride_show_subject_trigger = {
				OVERLORD = $OVERLORD$
			}
		}
	}
}
scripted_trigger recruit_concubines_eligible_subject_trigger = {
	harem_politics_valid_bride_show_subject_trigger = {
		OVERLORD = scope:liege
	}
	OR = {
		trigger_if = {
			limit = {
				gold >= minor_gold_value
			}
			OR = {
				any_neighboring_and_across_water_top_liege_realm_owner = {
					any_realm_province = {
						recruit_royal_concubines_viable_county_trigger = {
							OVERLORD = scope:liege
						}
					}
				}
				any_realm_province = {
					recruit_royal_concubines_viable_county_trigger = {
						OVERLORD = scope:liege
					}
				}
			}
		}
		any_courtier = {
			royal_concubines_eligible_candidate_trigger = {
				OVERLORD = scope:liege
			}
			# Skills appear here because otherwise the option to recruit would show the option available because the vassal has high skills
			trigger_if = {
				limit = {
					scope:liege = { has_variable = personality_skills_important }
				}
				min_personality_and_skills_trigger = yes
			}
		}
	}
}
bride_show.3002 = { 
	hidden = yes
	immediate = {
		if = {
			limit = {
				any_vassal = {
					recruit_concubines_eligible_subject_trigger = yes
				}
			}
			every_vassal = {
				limit = {
					recruit_concubines_eligible_subject_trigger = yes
				}
				add_to_temporary_list = recruit_concubines_subjects_list
			}
		}
		if = {
			limit = {
				any_tributary = {
					recruit_concubines_eligible_subject_trigger = yes
					NOT = { is_in_list = recruit_concubines_subjects_list }
				}
			}
			every_tributary = {
				limit = {
					recruit_concubines_eligible_subject_trigger = yes
					NOT = { is_in_list = recruit_concubines_subjects_list }
				}
				add_to_temporary_list = recruit_concubines_subjects_list
			}
		}
		if = {
			limit = {
				any_in_list = {
					list = recruit_concubines_subjects_list
					count >= 1
				}
			}
			save_temporary_scope_value_as = {
				name = max_subject_value
				value = {
					value = 3
					if = {
						limit = {
							can_have_four_candidates_trigger = yes
						}
						add = 1
					}
					if = {
						limit = {
							can_have_five_candidates_trigger = yes
						}
						add = 1
					}
				}
			}
			ordered_in_list = {
				list = recruit_concubines_subjects_list
				order_by = {
					value = "opinion(root)"
					if = {
						limit = {
							is_powerful_vassal_of = scope:liege
						}
						add = 20
					}
				}
				max = scope:max_subject_value
				min = 0
				trigger_event = {
					id = bride_show.3003
					days = { 1 2 }
				}
			}
		}
		trigger_event = {
			id = bride_show.3004
			days = 11
		}
	}
}


# Your subjects are notified #
scripted_effect add_to_candidate_variable_list_effect = {
	$CANDIDATE$ = {
		if = {
			limit = {
				royal_concubines_eligible_candidate_trigger = {
					OVERLORD = scope:liege
				}
				# Skills appear here because otherwise the option to recruit would show the option available because the vassal has high skills
				trigger_if = {
					limit = {
						scope:liege = { has_variable = personality_skills_important }
					}
					min_personality_and_skills_trigger = yes
				}
			}
			add_character_flag = {
				flag = blocked_from_leaving
				days = 15
			}
			scope:liege = {
				add_to_variable_list = {
					name = eligible_candidates_list
					target = prev
					days = 20
				}
			}
			if = {
				limit = {
					exists = betrothed
				}
				if = {
					limit = {
						exists = court_owner
					}
					court_owner = {
						run_interaction = {
							interaction = break_betrothal_interaction
							actor = $CANDIDATE$.court_owner
							recipient = $CANDIDATE$
							execute_threshold = accept
						}
					}
				}
				else = {
					run_interaction = {
						interaction = break_betrothal_interaction
						actor = $CANDIDATE$
						recipient = $CANDIDATE$.betrothed
						execute_threshold = accept
					}
				}
			}
		}
	}
}
bride_show.3003 = {
	type = character_event
	title = bride_show.3003.t
	desc = {
		desc = bride_show.3003.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:jarya = {
						is_courtier_of = root
					}
					NOT = {
						exists = scope:potential_candidate
					}
				}
				desc = bride_show.3003.courtier.desc
			}
			triggered_desc = {
				trigger = {
					scope:jarya = {
						NOT = { is_courtier_of = root }
					}
					exists = scope:potential_candidate
				}
				desc = bride_show.3003.recruit.desc
			}
			triggered_desc = {
				trigger = {
					scope:jarya = {
						is_courtier_of = root
					}
					exists = scope:potential_candidate
				}
				desc = bride_show.3003.fallback.desc
			}
		}
	}
	theme = vassal
	
	right_portrait = { 	
		character = root
		animation = personality_rational
	}
	left_portrait = {
		character = scope:jarya
		animation = personality_content
	}
	lower_center_portrait = {
		trigger = {
			scope:potential_candidate ?= {
				this != scope:jarya
			}
		}
		character = scope:potential_candidate
	}

	trigger = {
		recruit_concubines_eligible_subject_trigger = yes
	}

	immediate = {
		# Find the concubines
		if = {
			limit = {
				any_courtier = {
					royal_concubines_eligible_candidate_trigger = {
						OVERLORD = scope:liege
					}
					# Skills appear here because otherwise the option to recruit would show the option available because the vassal has high skills
					trigger_if = {
						limit = {
							scope:liege = { has_variable = personality_skills_important }
						}
						min_personality_and_skills_trigger = yes
					}
				}
			}
			ordered_courtier = {
				limit = {
					royal_concubines_eligible_candidate_trigger = {
						OVERLORD = scope:liege
					}
					# Skills appear here because otherwise the option to recruit would show the option available because the vassal has high skills
					trigger_if = {
						limit = {
							scope:liege = { has_variable = personality_skills_important }
						}
						min_personality_and_skills_trigger = yes
					}
				}
				order_by = {
					value = 1
					add = recruit_royal_concubines_value
				}
				max = 1
				save_scope_as = jarya
			}
		}

		if = {
			limit = {
				gold >= minor_gold_value
			}
			if = {
				limit = {
					any_neighboring_and_across_water_top_liege_realm_owner = {
						any_realm_province = {
							recruit_royal_concubines_viable_county_trigger = {
								OVERLORD = scope:liege
							}
							NOT = { is_in_list = pool_provinces }
						}
					}
				}
				every_neighboring_and_across_water_top_liege_realm_owner = {
					ordered_realm_province = {
						limit = {
							recruit_royal_concubines_viable_county_trigger = {
								OVERLORD = scope:liege
							}
							NOT = { is_in_list = pool_provinces }
						}
						order_by = {
							value = recruit_muslim_concubines_county_value
							if = {
								limit = {
									any_pool_character = {
										province = this
										royal_concubines_eligible_candidate_trigger = {
											OVERLORD = scope:liege
										}
										# Skills appear here because otherwise the option to recruit would show the option available because the vassal has high skills
										trigger_if = {
											limit = {
												scope:liege = { has_variable = personality_skills_important }
											}
											min_personality_and_skills_trigger = yes
										}
										NOT = {
											has_character_flag = concubine_offer_in_progress
										}
									}
								}
								add = 10
							}
						}
						max = 2
						min = 0
						add_to_temporary_list = pool_provinces
					}
					if = {
						limit = {
							any_in_list = {
								list = pool_provinces
								any_pool_character = {
									province = this
									royal_concubines_eligible_candidate_trigger = {
										OVERLORD = scope:liege
									}
									# Skills appear here because otherwise the option to recruit would show the option available because the vassal has high skills
									trigger_if = {
										limit = {
											scope:liege = { has_variable = personality_skills_important }
										}
										min_personality_and_skills_trigger = yes
									}
									NOR = {
										has_character_flag = concubine_offer_in_progress
										is_in_list = pool_candidates
									}
								}
								count > 0
							}
						}
						every_in_list = {
							list = pool_provinces
							every_pool_character = {
								province = this
								limit = {
									royal_concubines_eligible_candidate_trigger = {
										OVERLORD = scope:liege
									}
									# Skills appear here because otherwise the option to recruit would show the option available because the vassal has high skills
									trigger_if = {
										limit = {
											scope:liege = { has_variable = personality_skills_important }
										}
										min_personality_and_skills_trigger = yes
									}
									NOR = {
										has_character_flag = concubine_offer_in_progress
										is_in_list = pool_candidates
									}
								}
								add_to_temporary_list = pool_candidates
							}
						}
					}
				}
			}
			if = {
				limit = {
					any_in_list = {
						list = pool_candidates
						NOT = { has_character_flag = concubine_offer_in_progress }
						count >= 1
					}
				}
				# Nothing
			}
			else = {
				scope:liege = {
					calyver_create_candidate_effect = yes
					if = {
						limit = {
							exists = scope:bride
						}
						scope:bride = {
							add_to_list = pool_candidates
						}
						clear_saved_scope = bride
					}
				}
			}
			if = {
				limit = {
					any_in_list = {
						list = pool_candidates
						NOT = {
							has_character_flag = concubine_offer_in_progress
						}
						count = 1
					}
				}
				random_in_list = {
					list = pool_candidates
					limit = {
						NOT = {
							has_character_flag = concubine_offer_in_progress
						}
					}
					if = {
						limit = {
							NOT = { exists = scope:jarya }
						}
						save_scope_as = jarya
					}
					save_scope_as = potential_candidate
					add_character_flag = {
						flag = concubine_offer_in_progress
						days = 15
					}
				}
			}
			else = {
				ordered_in_list = {
					list = pool_candidates
					limit = {
						NOT = {
							has_character_flag = concubine_offer_in_progress
						}
					}
					order_by = {
						value = 1
						add = recruit_royal_concubines_value
					}
					max = 1
					min = 0
					if = {
						limit = {
							NOT = { exists = scope:jarya }
						}
						save_scope_as = jarya
					}
					save_scope_as = potential_candidate  
					add_character_flag = {
						flag = concubine_offer_in_progress
						days = 15
					}
				}
			}
			if = {
				limit = {
					exists = scope:potential_candidate
				}
				scope:potential_candidate = {
					save_scope_value_as = {
						name = gold_to_pay
						value = recruit_concubines_payment_value
					}
				}
			}
		}
	}

	# Send the courtier
	option = {
		name = bride_show.3003.a
		trigger = {
			scope:jarya = {
				is_courtier_of = root
				is_valid_candidate_for_recruitment_trigger = {
					OVERLORD = scope:liege
				}
			}
		}

		add_to_candidate_variable_list_effect = {
			CANDIDATE = scope:jarya
		}

		ai_chance = { #The AI will always choose this
			base = 30
			ai_value_modifier = {
				ai_greed = -0.1
			}
			modifier = {
				OR = {	
					has_relation_lover = scope:jarya
					has_relation_friend = scope:jarya
				}
				add = -15
			}
			modifier = {
				OR = {	
					has_relation_soulmate = scope:jarya
					has_relation_best_friend = scope:jarya
				}
				add = -20
			}
			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = -15
			}
			modifier = {
				has_trait = ambitious
				add = 15
			}
			modifier = {
				scope:liege = {
					opinion = {
						target = root
						value <= -10
					}
				}
				add = {
					value = "scope:liege.opinion(root)"
					multiply = -0.25
				}
			}
			modifier = {
				scope:liege = {
					any_claim = {
						holder ?= root
					}
				}
				add = {
					value = scope:liege.highest_held_title_tier
					multiply = 5
				}
			}
			modifier = {
				has_relation_rival = scope:liege
				add = -15
			}
			modifier = {
				has_relation_nemesis = scope:liege
				add = -30
			}
			modifier = {
				scope:jarya = {
					num_of_bad_genetic_traits > 0
				}
				add = {
					value = scope:jarya.num_of_bad_genetic_traits
					multiply = -10
				}
			}
			opinion_modifier = {
				opinion_target = scope:liege
				multiplier = 0.2
			}
		}
	}
	
	# Send the other candidate
	option = {
		name = bride_show.3003.b
		custom_tooltip = bride_show.3003.b.tt
		trigger = {
			scope:potential_candidate ?= {
				NOT = { is_courtier_of = root }
				royal_concubines_eligible_candidate_trigger = {
					OVERLORD = scope:liege
				}
			}
			exists = scope:gold_to_pay
		}
		remove_short_term_gold = scope:gold_to_pay
		scope:potential_candidate = {
			save_temporary_scope_as = concubine
		}
		add_courtier = scope:concubine
		add_to_candidate_variable_list_effect = {
			CANDIDATE = scope:concubine
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_greed = -0.5
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				OR = {	
					has_relation_lover = scope:potential_candidate
					has_relation_friend = scope:potential_candidate
				}
				add = -15
			}
			modifier = {
				OR = {	
					has_relation_soulmate = scope:potential_candidate
					has_relation_best_friend = scope:potential_candidate
				}
				add = -20
			}
			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = -15
			}
			modifier = {
				has_trait = ambitious
				add = 15
			}
			modifier = {
				scope:liege = {
					opinion = {
						target = root
						value <= -10
					}
				}
				add = {
					value = "scope:liege.opinion(root)"
					multiply = -0.25
				}
			}
			modifier = {
				scope:liege = {
					any_claim = {
						holder ?= root
					}
				}
				add = {
					value = scope:liege.highest_held_title_tier
					multiply = 5
				}
			}
			modifier = {
				has_relation_rival = scope:liege
				add = -15
			}
			modifier = {
				has_relation_nemesis = scope:liege
				add = -30
			}
			modifier = {
				scope:potential_candidate = {
					num_of_bad_genetic_traits > 0
				}
				add = {
					value = scope:potential_candidate.num_of_bad_genetic_traits
					multiply = -10
				}
			}
			opinion_modifier = {
				opinion_target = scope:liege
				multiplier = 0.2
			}
			modifier = {
				gold <= scope:gold_to_pay
				factor = 0
			}
		}
	}

	# Make them my concubine
	option = {
		name = bride_show.3003.c
		trigger = {
			allowed_concubines = yes
			allowed_more_concubines = yes
			scope:potential_candidate ?= {
				NOT = { is_courtier_of = root }
				bride_show_viable_consort_trigger = { OVERLORD = root }
			}
			exists = scope:gold_to_pay
		}
		remove_short_term_gold = scope:gold_to_pay
		hidden_effect = {
			scope:potential_candidate = {
				save_temporary_scope_as = concubine
			}
			add_courtier = scope:concubine
			scope:concubine = {
				return_to_court = yes
			}
			if = {
				limit = {
					allowed_more_concubines = yes
				}
				if = {
					limit = {
						exists = scope:potential_candidate.betrothed
					}
					run_interaction = {
						interaction = break_betrothal_interaction
						actor = root
						recipient = scope:potential_candidate.betrothed
						execute_threshold = accept
					}
				}
				run_interaction = {
					interaction = make_concubine_interaction
					actor = root
					secondary_actor = root
					recipient = scope:concubine
					secondary_recipient = scope:concubine
					execute_threshold = accept
				}
			}
		}
		show_as_tooltip = {
			make_concubine = scope:concubine
		}
		stress_impact = {
			greedy = minor_stress_impact_gain
			chaste = minor_stress_impact_gain
		}
		ai_chance = { #The AI will never choose this
			base = 30
			ai_value_modifier = {
				ai_greed = -0.5
				ai_boldness = 0.1
				ai_honor = -0.2
			}
			modifier = {
				has_trait = greedy
				add = -25
			}
			modifier = {
				has_trait = chaste
				add = -25
			}
			modifier = {
				OR = {	
					has_relation_lover = scope:potential_candidate
					has_relation_friend = scope:potential_candidate
				}
				add = 15
			}
			modifier = {
				OR = {	
					has_relation_soulmate = scope:potential_candidate
					has_relation_best_friend = scope:potential_candidate
				}
				add = 20
			}
			modifier = {
				number_of_concubines < number_of_desired_concubines
				add = 15
			}
			modifier = {
				has_trait = ambitious
				add = 15
			}
			modifier = {
				scope:potential_candidate = {
					num_of_good_genetic_traits > 0
				}
				add = {
					value = scope:potential_candidate.num_of_good_genetic_traits
					multiply = 5
				}
			}
			modifier = {
				scope:potential_candidate = {
					num_of_bad_genetic_traits > 0
				}
				add = {
					value = scope:potential_candidate.num_of_bad_genetic_traits
					multiply = -20
				}
			}
			modifier = {
				NOT = { is_attracted_to_gender_of = scope:potential_candidate }
				add = -25
			}
			opinion_modifier = {
				opinion_target = scope:potential_candidate
				multiplier = 0.2
			}
			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 <= scope:gold_to_pay
				factor = 0
			}
		}
	}

	# Recruit to court
	option = { # Recruit to court and break betrothal
		name = bride_show.0005.c
		trigger = {
			exists = scope:gold_to_pay
			exists = scope:potential_candidate
		}

		# Reward
		remove_short_term_gold = scope:gold_to_pay
		
		hidden_effect = {
			scope:potential_candidate = {
				if = {
					limit = {
						is_hostage = yes
					}
					return_hostage = yes
				}
				root = {
					add_courtier = scope:potential_candidate
				}
				return_to_court = yes
				if = {
					limit = {
						exists = betrothed
					}
					run_interaction = {
						interaction = break_betrothal_interaction
						actor = root
						recipient = scope:potential_candidate.betrothed
						execute_threshold = accept
					}
				}
			}
		}
		show_as_tooltip = { 
			add_courtier = scope:potential_candidate
		}
		
		ai_chance = {
			base = 0
		}
	}

	# Do nothing
	option = {
		name = bride_show.3003.d
		stress_impact = {
			generous = minor_stress_impact_gain
		}
		ai_chance = { #The AI will always choose this
			base = 40
			ai_value_modifier = {
				ai_greed = 0.5
				ai_boldness = 0.1
				ai_honor = -0.1
			}
			modifier = {
				has_trait = greedy
				add = 25
			}
			modifier = {
				has_trait = generous
				add = 25
			}
			modifier = {
				scope:jarya = {
					num_of_bad_genetic_traits > 0
				}
				add = {
					value = scope:jarya.num_of_bad_genetic_traits
					multiply = 10
				}
			}
			modifier = {
				scope:potential_candidate ?= {
					num_of_bad_genetic_traits > 0
				}
				add = {
					value = scope:potential_candidate.num_of_bad_genetic_traits
					multiply = 10
				}
			}
			opinion_modifier = {
				opinion_target = scope:liege
				multiplier = -0.4
			}
		}
	}
}

scripted_trigger can_still_participate_in_concubine_recruitment_trigger = {
	has_any_illness = no
	is_alive = yes
	is_virgin_trigger = yes
	can_be_taken_as_muslim_concubine_trigger = {
		CHARACTER = scope:liege
		RECEIVER = scope:liege
	}
	NOR = {
		has_trait = devoted
		has_trait = celibate
	}
	can_become_concubine_of_character_valid_trigger = { CHARACTER = scope:liege }
	trigger_if = {
		limit = {
			exists = court_owner
		}
		court_owner = {
			harem_politics_valid_bride_show_subject_trigger = {
				OVERLORD = scope:liege
			}
		}
	}
}

scripted_effect recruit_royal_concubines_next_candidate_effect = {
	hidden_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 = potential_candidates_list
						can_still_participate_in_concubine_recruitment_trigger = no
						count > 0
					}
				}
				every_in_list = {
					list = potential_candidates_list
					limit = {
						can_still_participate_in_concubine_recruitment_trigger = no
					}
					remove_from_list = potential_candidates_list
				}
			}
			# Characters will be created
			if = {
				limit = { 
					OR = { 
						any_in_list = {
							list = potential_candidates_list
							count = 0
						}
						AND = { # Or if there aren't any candidates with good congenital traits
							scope:liege = { has_variable = beauty_important }
							any_in_list = {
								list = potential_candidates_list
								num_of_good_genetic_traits >= 1
								count = 0
							}
						}
						AND = { # Or if there aren't any candidates with good skills
							scope:liege = { has_variable = personality_skills_important }
							any_in_list = {
								list = potential_candidates_list
								min_personality_and_skills_trigger = yes
								count = 0
							}
						}
					}
				}
				calyver_create_candidate_effect = yes
				scope:bride = {
					add_to_list = potential_candidates_list
					add_to_list = created_candidates_list
					add_character_flag = created_bride_flag
				}
				clear_saved_scope = bride
			}
			if = {
				limit = {
					any_in_list = {
						list = potential_candidates_list
						count = 1
					}
				}
				random_in_list = {
					list = potential_candidates_list
					save_scope_as = potential_candidate
				}
			}
			else = {
				ordered_in_list = {
					list = potential_candidates_list
					order_by = {
						value = 1
						add = recruit_royal_concubines_value
					}
					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.3006
			}
			else = {
				bride_show_ending_effect = yes
			}
		}
		# No
		else = {
			trigger_event = bride_show.3005
		}
	}
}

# The candidates are here
bride_show.3004 = {
	type = character_event
	title = recruit_concubines_decision_title
	desc = bride_show.3004.desc
	theme = diplomacy
	
	right_portrait = { 	
		character = root
		animation = personality_rational
	}
	left_portrait = {
		trigger = {
			scope:attendant != root
		}
		character = scope:attendant
		animation = personality_content
	}

	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 = {
				OR = {
					NOT = { exists = scope:attendant }
					scope:attendant = {
						is_alive = no
					}
				}
			}
			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
				}
			}
			else = {
				save_scope_as = attendant
			}
		}
	}
	
	# Let's go!
	option = {
		name = bride_show.3004.a
		custom_tooltip = bride_show.3004.a.tt
		hidden_effect = {
			if = {
				limit = {
					has_variable_list = eligible_candidates_list
				}
				every_in_list = {
					variable = eligible_candidates_list
					limit = {
						can_still_participate_in_concubine_recruitment_trigger = yes
					}
					add_to_list = potential_candidates_list
				}
				clear_variable_list = eligible_candidates_list
				if = {
					limit = {
						any_in_list = {
							list = potential_candidates_list
							court_owner ?= {
								is_ai = no
								harem_politics_valid_bride_show_subject_trigger = {
									OVERLORD = scope:liege
								}
							}
							count > 0
						}
					}
					every_in_list = {
						list = potential_candidates_list
						limit = {
							court_owner ?= {
								is_ai = no
								harem_politics_valid_bride_show_subject_trigger = {
									OVERLORD = scope:liege
								}
							}
						}
						court_owner = {
							trigger_event = bride_show.3007
						}
					}
				}
			}
			recruit_royal_concubines_next_candidate_effect = yes
		}
		ai_chance = {
			base = 1
		}
	}
}

scripted_effect selected_candidate_opinion_effect = {
	hidden_effect = {
		if = { #Scale opinion gain a bit depending on how cool the concubine is
			limit = {
				scope:potential_candidate = {
					OR = {
						has_trait = beauty_good_2
						has_trait = beauty_good_3
						num_of_good_genetic_traits > 1
						has_relation_lover = scope:liege
						has_relation_soulmate = scope:liege
					}
					trigger_if = {
						limit = {
							is_female = yes
						}
						age < define:NChildbirth|MAX_FEMALE_REPRODUCTION_AGE
					}
				}
			}
			add_opinion = {
				target = scope:potential_candidate.court_owner
				modifier = grateful_opinion
				opinion = 10
			}
		}
		else_if = {
			limit = {
				scope:potential_candidate = {
					OR = {
						is_lowborn = no
						has_trait = beauty_good_1
						num_of_good_genetic_traits > 0
						has_relation_friend = scope:liege
						has_relation_best_friend = scope:liege
					}
					trigger_if = {
						limit = {
							is_female = yes
						}
						age < define:NChildbirth|MAX_FEMALE_REPRODUCTION_AGE
					}
				}
			}
			add_opinion = {
				target = scope:potential_candidate.court_owner
				modifier = grateful_opinion
				opinion = 5
			}
		}
	}
}
##Pick your candidates##
bride_show.3005 = {
	type = character_event
	title = bride_show.3005.t
	desc = {
		first_valid = { # Introduction
			triggered_desc = { # The last candidate
				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.3005.candidate_3.desc
			}
			triggered_desc = { # Middle candidates (2nd, 3rd if can have 4+, 4th if can have 5)
				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.3005.candidate_2.desc
			}
			triggered_desc = { # First candidate (fallback - no candidates exist yet)
				desc = bride_show.3005.candidate_1.desc
			}
		}
		first_valid = { # Physical traits
			triggered_desc = { # Fecund - the harem head exists
				trigger = {
					exists = scope:harem_head
					scope:potential_candidate = {
						has_trait = fecund
					}
				}
				desc = bride_show.3005.fecund.hh.desc
			}
			triggered_desc = { # Fecund - no harem head
				trigger = {
					scope:potential_candidate = {
						has_trait = fecund
					}
				}
				desc = bride_show.3005.fecund.desc
			}
			triggered_desc = { # Beautiful - the harem head exists
				trigger = {
					exists = scope:harem_head
					scope:potential_candidate = {
						has_trait = beauty_good_3
					}
				}
				desc = bride_show.3005.beauty_good_3.hh.desc
			}
			triggered_desc = { # Beautiful - no harem head
				trigger = {
					scope:potential_candidate = {
						has_trait = beauty_good_3
					}
				}
				desc = bride_show.3005.beauty_good_3.desc
			}
			triggered_desc = { # Handsome - the harem head exists
				trigger = {
					exists = scope:harem_head
					scope:potential_candidate = {
						has_trait = beauty_good_2
					}
				}
				desc = bride_show.3005.beauty_good_2.hh.desc
			}
			triggered_desc = { # Handsome - no harem head
				trigger = {
					scope:potential_candidate = {
						has_trait = beauty_good_2
					}
				}
				desc = bride_show.3005.beauty_good_2.desc
			}
			triggered_desc = { # Comely - the harem head exists
				trigger = {
					exists = scope:harem_head
					scope:potential_candidate = {
						has_trait = beauty_good
					}
				}
				desc = bride_show.3005.beauty_good.hh.desc
			}
			triggered_desc = { # Comely - no harem head
				trigger = {
					scope:potential_candidate = {
						has_trait = beauty_good
					}
				}
				desc = bride_show.3005.beauty_good.desc
			}
			triggered_desc = { # Amazonian - harem head
				trigger = {
					exists = scope:harem_head
					scope:potential_candidate = {
						has_trait = physique_good_3
					}
				}
				desc = bride_show.3005.physique_good_3.hh.desc
			}
			triggered_desc = { # Amazonian - no harem head
				trigger = {
					scope:potential_candidate = {
						has_trait = physique_good_3
					}
				}
				desc = bride_show.3005.physique_good_3.desc
			}
			triggered_desc = { # Robust - harem head
				trigger = {
					exists = scope:harem_head
					scope:potential_candidate = {
						has_trait = physique_good_2
					}
				}
				desc = bride_show.3005.physique_good_2.hh.desc
			}
			triggered_desc = { # Robust - no harem head
				trigger = {
					scope:potential_candidate = {
						has_trait = physique_good_2
					}
				}
				desc = bride_show.3005.physique_good_2.desc
			}
			triggered_desc = { # Hale - harem head
				trigger = {
					exists = scope:harem_head
					scope:potential_candidate = {
						has_trait = physique_good
					}
				}
				desc = bride_show.3005.physique_good.hh.desc
			}
			triggered_desc = { # Hale - no harem head
				trigger = {
					scope:potential_candidate = {
						has_trait = physique_good
					}
				}
				desc = bride_show.3005.physique_good.desc
			}
			triggered_desc = { # Fallback - the harem head exists
				trigger = {
					exists = scope:harem_head
				}
				desc = bride_show.3005.fallback.hh.desc
			}
			desc = bride_show.3005.fallback.desc
		}
		first_valid = { # Skills
			triggered_desc = { # Poet
				trigger = {
					scope:potential_candidate = {
						has_trait = lifestyle_poet
					}
				}
				desc = bride_show.3005.lifestyle_poet.desc
			}
			triggered_desc = { # 3 skills
				trigger = {
					scope:potential_candidate = {
						diplomacy >= average_skill_level
						learning >= average_skill_level
						trigger_if = {
							limit = {
								can_be_knight_trigger = { ARMY_OWNER = root }
							}
							prowess >= average_skill_level
						}
					}
				}
				desc = bride_show.3005.skilled.desc
			}
			triggered_desc = { #Diplomacy
				trigger = {
					scope:potential_candidate = {
						diplomacy >= average_skill_level
					}
				}
				desc = bride_show.3005.diplomacy.desc
			}
			triggered_desc = { #Learning
				trigger = {
					scope:potential_candidate = {
						learning >= average_skill_level
					}
				}
				desc = bride_show.3005.learning.desc
			}
			triggered_desc = { #Prowess
				trigger = {
					scope:potential_candidate = {
						can_be_knight_trigger = { ARMY_OWNER = root }
						prowess >= average_skill_level
					}
				}
				desc = bride_show.3005.prowess.desc
			}
			desc = bride_show.3005.skill_fallback.desc
		}
		random_valid = { # Skills
			triggered_desc = { # Nervous
				trigger = {
					scope:potential_candidate = {
						OR = {
							has_trait = shy
							has_trait = craven
							has_trait = chaste
						}
					}
				}
				desc = bride_show.3005.nervous.desc
			}
			triggered_desc = { # Bold
				trigger = {
					scope:potential_candidate = {
						OR = {
							has_trait = brave
							has_trait = ambitious
							has_trait = greedy
							has_trait = arrogant
						}
					}
				}
				desc = bride_show.3005.bold.desc
			}
			desc = bride_show.3005.trait_fallback.desc
		}
	}
	theme = diplomacy
	
	left_portrait = {
		character = scope:potential_candidate
		animation = flirtation
	}
	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
		}
		if = {
			limit = {
				NOT = { exists = scope:harem_head }
				any_courtier = {
					is_head_of_the_harem_trigger = {
						LIEGE = scope:liege
					}
					NOT = {
						is_consort_of = scope:liege
					}
				}
			}
			ordered_courtier = {
				limit = {
					is_head_of_the_harem_trigger = {
						LIEGE = scope:liege
					}
					NOT = {
						is_consort_of = scope:liege
					}
				}
				order_by = {
					add = 1
					# Mother
					if = {
						limit = {
							is_parent_of = scope:harem_liege
						}
						add = 200
					}
					# Grandmother
					else_if = {
						limit = {
							is_grandparent_of = scope:harem_liege
						}
						add = 100
					}
					# Aunts
					else_if = {
						limit = {
							is_uncle_or_aunt_of = scope:harem_liege
						}
						add = 50
					}
					# Siblings
					else_if = {
						limit = {
							is_sibling_of = scope:harem_liege
						}
						add = 25
					}
		
					add = age
				}
				max = 1
				min = 0
				save_scope_as = harem_head
			}
		}
		hidden_effect = {
			scope:potential_candidate = {
				if = {
					limit = {
						exists = court_owner
						court_owner != scope:liege
					}
					court_owner = {
						save_scope_as = pc_court_owner
						if = {
							limit = {
								scope:potential_candidate = {
									is_betrothed = yes
								}
							}
							run_interaction = {
								interaction = break_betrothal_interaction
								actor = scope:potential_candidate.court_owner
								recipient = scope:potential_candidate
								execute_threshold = accept
							}
						}
					}
				}
				else_if = {
					limit = {
						is_betrothed = yes
					}
					run_interaction = {
						interaction = break_betrothal_interaction
						actor = scope:potential_candidate
						recipient = scope:potential_candidate.betrothed
						execute_threshold = accept
					}
				}
				save_scope_value_as = {
					name = gold_to_pay
					value = recruit_concubines_payment_value
				}
			}
		}
	}

	# Make them my concubine
	option = {
		name = bride_show.0005.b
		trigger = {
			allowed_concubines = yes
			allowed_more_concubines = yes
			scope:potential_candidate = {
				is_valid_candidate_for_recruitment_trigger = { OVERLORD = scope:liege }
			}
		}

		# Reward
		if = {
			limit = {
				exists = scope:potential_candidate.court_owner
			}
			pay_short_term_gold = {
				target = scope:potential_candidate.court_owner
				gold = scope:gold_to_pay
			}
			
			# Courtly vassals get a positive opinion
			scope:potential_candidate.court_owner = {
				if = {
					limit = {
						is_vassal_of = scope:liege
						has_vassal_stance = courtly
						agrees_with_bride_show = yes
					}
					add_opinion = {
						target = scope:liege
						modifier = pleased_opinion
						opinion = 10
					}
				}
				hidden_effect = {
					if = {
						limit = {
							is_ai = no
						}
						send_interface_toast = {
							type = event_generic_good
							title = chosen_consort_t
							right_icon = scope:liege
							left_icon = scope:potential_candidate
							show_as_tooltip = {
								scope:liege = {
									make_concubine = scope:potential_candidate
									pay_short_term_gold = {
										target = scope:potential_candidate.court_owner
										gold = scope:gold_to_pay
									}
									selected_candidate_opinion_effect = yes
								}
							}
						}
					}
				}
			}
			hidden_effect = {
				selected_candidate_opinion_effect = yes
			}
			stress_impact = {
				paranoid = miniscule_stress_impact_gain
			}
		}
		else = {
			remove_short_term_gold = scope:gold_to_pay
		}
		
		# Concubinage effects
		hidden_effect = {
			scope:potential_candidate = {
				if = {
					limit = {
						is_hostage = yes
					}
					return_hostage = yes
				}
				scope:harem_liege = {
					add_courtier = scope:potential_candidate
				}
				return_to_court = yes
			}
			if = {
				limit = {
					allowed_more_concubines = yes
				}
				run_interaction = {
					interaction = make_concubine_interaction
					actor = scope:liege
					secondary_actor = scope:liege
					recipient = scope:potential_candidate
					secondary_recipient = scope:potential_candidate
					execute_threshold = accept
				}
			}
		}
		show_as_tooltip = {
			make_concubine = scope:potential_candidate
		}
		
		ai_chance = {
			base = 45
			# Compatibility
			compatibility_modifier = { #Trait compatibility
				who = root
				compatibility_target = scope:potential_candidate
				min = -20
				max = 20
				multiplier = 0.2
			}
			opinion_modifier = {
				who = scope:liege
				opinion_target = scope:potential_candidate
				multiplier = 0.2
			}
			# # Traits
			modifier = { #Weigh down for stress
				add = -35
				has_trait = paranoid
				exists = scope:potential_candidate.court_owner
			}
			modifier = { #Weigh down for stress
				add = -15
				has_trait = shy
			}
			modifier = { #More likely if root is lustful
				add = 20
				has_trait = lustful
			}

			# Number of concubines
			modifier = { #More likely if root doesn't have enough spouses
				add = 30
				number_of_concubines < number_of_desired_concubines
			}

			# Sender
			modifier = { #More likely if the candidate was sent by a vassal
				add = 5
				scope:potential_candidate.court_owner ?= {
					OR = {
						is_tributary_of = root
						is_vassal_of = root
					}
				}
			}
			modifier = { #More likely if the candidate was sent by a powerful vassal
				add = 10
				scope:potential_candidate.court_owner ?= {
					OR = {
						is_powerful_vassal_of = root
						is_councillor_of = root
					}
				}
			}
			modifier = {
				government_has_flag = government_is_administrative
				scope:potential_candidate.court_owner ?= {
					government_has_flag = government_is_administrative
					top_liege ?= scope:liege
					house ?= {
						is_dominant_family = yes
					}
				}
				add = 15
			}
			modifier = {
				exists = scope:potential_candidate.court_owner
				add = {
					value = scope:potential_candidate.court_owner.highest_held_title_tier
					multiply = 2
				}
			}

			# Genetic traits
			modifier = { # Beauty
				add = 10
				scope:potential_candidate = {
					has_trait = beauty_good
				}
			}
			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 = {
				scope:potential_candidate = {
					num_of_good_genetic_traits >= 1
				}
				add = {
					value = scope:potential_candidate.num_of_good_genetic_traits
					multiply = 10
				}
			}
			modifier = {
				scope:potential_candidate = {
					num_of_bad_genetic_traits > 0
				}
				add = {
					value = scope:potential_candidate.num_of_bad_genetic_traits
					multiply = -20
				}
			}
			modifier = { #More likely if the candidate has excellent traits
				add = 40
				scope:potential_candidate = {
					has_trait = golden_lineage
				}
			}

			# Skills
			modifier = { #More likely if candidate has good skills
				add = scope:potential_candidate.learning
			}
			modifier = { #More likely if candidate has good skills
				add = scope:potential_candidate.diplomacy
			}
			modifier = {
				has_trait = lifestyle_poet
				add = 15
			}
			modifier = { #More likely if the candidate isn't a criminal
				add = 5
				NOT = { has_imprisonment_reason = scope:potential_candidate }
			}
			modifier = {
				NOT = {
					is_attracted_to_gender_of = scope:potential_candidate
				}
				add = -10
			}
			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 <= scope:gold_to_pay
				factor = 0
			}
		}
	}

	# Recruit to court
	option = { # Recruit to court and break betrothal
		name = bride_show.0005.c
		trigger = {
			trigger_if = {
				limit = {
					exists = scope:potential_candidate.court_owner
				}
				scope:potential_candidate.court_owner = {
					harem_politics_valid_bride_show_subject_trigger = {
						OVERLORD = scope:liege
					}
				}
			}
		}

		# Reward
		if = {
			limit = {
				exists = scope:potential_candidate.court_owner
			}
			pay_short_term_gold = {
				target = scope:potential_candidate.court_owner
				gold = scope:gold_to_pay
			}
			
			# Courtly vassals get a positive opinion
			scope:potential_candidate.court_owner = {
				if = {
					limit = {
						is_vassal_of = scope:liege
						has_vassal_stance = courtly
						agrees_with_bride_show = yes
					}
					add_opinion = {
						target = scope:liege
						modifier = pleased_opinion
						opinion = 5
					}
				}
				hidden_effect = {
					if = {
						limit = {
							is_ai = no
						}
						send_interface_toast = {
							type = event_generic_good
							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 = scope:gold_to_pay
									}
									selected_candidate_opinion_effect = yes
								}
							}
						}
					}
				}
			}
			hidden_effect = {
				selected_candidate_opinion_effect = yes
			}
			stress_impact = {
				paranoid = miniscule_stress_impact_gain
			}
		}
		else = {
			remove_short_term_gold = scope:gold_to_pay
		}
		
		hidden_effect = {
			scope:potential_candidate = {
				if = {
					limit = {
						is_hostage = yes
					}
					return_hostage = yes
				}
				scope:harem_liege = {
					add_courtier = scope:potential_candidate
				}
				return_to_court = yes
			}
		}
		show_as_tooltip = { 
			add_courtier = scope:potential_candidate
		}
		
		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
		}
		
		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
					}
					agrees_with_bride_show = yes
				}
				add_opinion = {
					target = root
					modifier = rejected_me_opinion
				}
			}
		}
		ai_chance = {
			base = 35
			compatibility_modifier = { #Trait compatibility
				who = root
				compatibility_target = scope:potential_candidate
				min = -20
				max = 20
				multiplier = -0.2
			}
			opinion_modifier = {
				who = scope:liege
				opinion_target = scope:potential_candidate
				multiplier = -0.2
			}
			# Traits
			modifier = { #Weigh down for stress
				add = 35
				has_trait = paranoid
				exists = scope:potential_candidate.court_owner
			}
			modifier = { #Weigh down for stress
				add = 10
				has_trait = shy
			}
			modifier = { #More likely if root is lustful
				add = -35
				has_trait = lustful
			}

			# Number of concubines
			modifier = {
				add = 15
				number_of_concubines >= number_of_desired_concubines
			}

			# Sender
			modifier = { #Less likely if the candidate was sent by a vassal
				add = -5
				scope:potential_candidate.court_owner ?= {
					OR = {
						is_tributary_of = root
						is_vassal_of = root
					}
				}
			}
			modifier = { #Less likely if the candidate was sent by a powerful vassal
				add = -10
				scope:potential_candidate.court_owner ?= {
					OR = {
						is_powerful_vassal_of = root
						is_councillor_of = root
					}
				}
			}
			modifier = { # Less likely if the candidate was sent by a member of a dominant family
				government_has_flag = government_is_administrative
				scope:potential_candidate.court_owner ?= {
					government_has_flag = government_is_administrative
					top_liege ?= scope:liege
					house ?= {
						is_dominant_family = yes
					}
				}
				add = -15
			}
			modifier = { # Less likely depending on the title tier of the sender
				exists = scope:potential_candidate.court_owner
				add = {
					value = scope:potential_candidate.court_owner.highest_held_title_tier
					multiply = -2
				}
			}

			modifier = { # More likely if the candidate has bad genetic traits
				scope:potential_candidate = {
					num_of_bad_genetic_traits >= 1
				}
				add = {
					value = scope:potential_candidate.num_of_bad_genetic_traits
					multiply = 20
				}
			}
			modifier = { #More likely if the candidate isn't a criminal
				add = 10
				has_imprisonment_reason = scope:potential_candidate
			}
			modifier = {
				NOT = {
					is_attracted_to_gender_of = scope:potential_candidate
				}
				add = 10
			}
			modifier = {
				exists = scope:potential_candidate.court_owner
				add = {
					value = "opinion(scope:potential_candidate.court_owner)"
					multiply = -0.3
				}
			}
		}
	}
	
	after = {
		hidden_effect = {
			scope:potential_candidate = {
				bride_show_saved_candidate_effect = {
					LIST = potential_candidates_list
				}
				if = {
					limit = {
						is_courtier_of = scope:liege
					}
					if = {
						limit = {
							faith != scope:harem_liege.faith
						}
						random = {
							chance = 60
							modifier = {
								scope:harem_liege = {
									has_trait = zealous
								}
								add = 15
							}
							if = {
								limit = {
									scope:harem_liege.religion = religion:islam_religion
									religion != religion:islam_religion
								}
								add_character_flag = {
									flag = abducted_non_believer
									years = 5
								}
							}
							set_character_faith = scope:harem_liege.faith
						}
					}
				}
			}
			if = {
				limit = {
					exists = scope:pc_court_owner
				}
				clear_saved_scope = pc_court_owner
			}
			recruit_royal_concubines_next_candidate_effect = yes
		}
	}
}

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

	theme = diplomacy
	
	right_portrait = { 	
		character = scope:right_portrait_character
		animation = personality_honorable
	}
	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
	}

	trigger = {
		is_ai = no
	}

	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
		
		bride_show_ending_effect = yes
		ai_chance = {
			base = 1
		}
	}
}

# Notification for subjects #
bride_show.3007 = {
	hidden = yes
	trigger = {
		is_ai = no
		any_in_list = {
			list = potential_candidates_list
			is_courtier_of = root
			count >= 1
		}
	}
	immediate = {
		save_scope_as = subject
		if = {
			limit = {
				any_in_list = {
					list = potential_candidates_list
					is_courtier_of = root
					count > 1
				}
			}
			set_variable = {
				name = num_courtiers_summoned
				value = -1
			}
			every_in_list = {
				list = potential_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 = potential_candidates_list
				limit = {
					is_courtier_of = root
				}
				save_scope_as = drafted_candidate
			}
		}

		send_interface_toast = {
			type = event_generic_neutral
			title = bride_show.3005.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
			}
		}
	}
}