namespace = intrigue_temptation
namespace = intrigue_temptation_special

##################################################
#Intrigue Temptation Lifestyle events

	# 2201		- Learn secrets from your lover in another court, by Sean Hughes
	# 3000		- A visiting guest would like a tumble before leaving, by Alexander Oltner
	# 3010		- Wingman/woman, by Mathilda Bjarnehed
	# 3020		- Medieval tinder, by Mathilda Bjarnehed

# Special events
	# 1000		- Matchmaking chain, by Mathilda Bjarnehed
##################################################

##################################################
# Pillow Talk
# by Sean Hughes
# 2201-2203
##################################################

scripted_trigger valid_lover_in_another_court = {
	# Lover must be available for a liasion.
	is_available_healthy_ai_adult = yes

	# Lover must be located in a different court.
	exists = court_owner
	NOR = {
		court_owner = root
		court_owner = root.court_owner
		court_owner = this
	}

	# There must be a secret in the lover's court which you do not know(they do not necessarily need to know it!)
	save_temporary_scope_as = my_lover
	court_owner = {
		any_courtier = {
			any_secret = {
				NOR = {
					is_known_by = root # Won't reveal a secret to you which you already know.
					secret_owner = scope:my_lover # Lover won't spill their own secrets.
				}
			}
		}
	}
}

# Learn about secrets in another court via pillow talk with your lover there.
intrigue_temptation.2201 = {
	type = character_event
	title = intrigue_temptation.2201.t
	desc = intrigue_temptation.2201.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:my_lover
		animation = love
	}
	right_portrait = {
		character = scope:court_owner
		animation = worry
	}

	trigger = {
		NOT = { has_character_flag = had_event_intrigue_temptation_2201 }
		any_relation = {
			type = lover
			valid_lover_in_another_court = yes
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = intrigue_temptation_focus }
	}

	immediate = {
		add_character_flag = {
			flag = had_event_intrigue_temptation_2201
			years = 5
		}
		random_relation = {
			type = lover
			limit = {
				valid_lover_in_another_court = yes
			}
			save_scope_as = my_lover
		}

		scope:my_lover = {
			court_owner = {
				save_scope_as = court_owner

				# Reveals court_owner's secret first.
				if = {
					limit = {
						any_secret = {
							NOT = { is_known_by = root } #Won't reveal a secret you already know.
						}
					}
					random_secret = {
						limit = {
							NOT = { is_known_by = root }
						}
						weight = {
							base = 100

							modifier = {
								is_criminal_for = secret_owner
								add = 500
							}
							modifier = {
								AND = {
									exists = secret_target
									secret_target = {
										is_close_or_extended_family_of = root
									}
								}

								add = 150
							}
							modifier = {
								AND = {
									exists = secret_target
									secret_target = {
										is_close_or_extended_family_of = scope:court_owner
									}
								}
								add = 100
							}

						}
						save_scope_as = court_gossip
					}

				}
				else = { #Reveals a courtier's secret.
					every_courtier = {
						random_secret = {
							limit = {
								NOR = {
									is_known_by = root # Won't reveal a secret you already know.
									secret_owner = scope:my_lover # Lover won't spill their own secrets.
								}
							}

							weight = {
								base = 100
								modifier = {
									is_criminal_for = secret_owner
									add = 500
								}
								modifier = {
									AND = {
										exists = secret_target
										secret_target = {
											is_close_or_extended_family_of = root
										}
									}
									add = 150
								}
								modifier = {
									AND = {
										exists = secret_target
										secret_target = {
											is_close_or_extended_family_of = scope:court_owner
										}
									}
									add = 100
								}

							}
							save_scope_as = court_gossip
						}
					}
				}

			}
		}
	}

	# Attempt to learn about any secrets.
	option = {
		name = intrigue_temptation.2201.a
		duel = {
			skill = intrigue
			target = scope:my_lover

			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = intrigue_temptation.2201.a.success
				
				custom_tooltip = intrigue_temptation.2201.a.success.tt
				show_as_tooltip = { add_intrigue_lifestyle_xp = major_lifestyle_xp }

				hidden_effect = {
					send_interface_toast = {
						title = intrigue_temptation.2201.a.success
						
						scope:court_gossip = {
							reveal_to = root
						}
						add_intrigue_lifestyle_xp = major_lifestyle_xp
					}
				}
			}
			50 = {		
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = intrigue_temptation.2201.a.failure
				send_interface_toast = {
					title = intrigue_temptation.2201.a.failure
					add_intrigue_lifestyle_xp = miniscule_lifestyle_xp
					reverse_add_opinion = {
						modifier = disappointed_opinion
						target = scope:my_lover
						opinion = -10
					}
				}
			}
		}
		stress_impact = {
			honest = medium_stress_impact_gain
			impatient = medium_stress_impact_gain
			diligent = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_greed = 200
				ai_rationality = 50
				ai_boldness = 50
			}
		}
	}

	# Gain opinion increase instead
	option = {
		name = intrigue_temptation.2201.b
		reverse_add_opinion = {
			modifier = romance_opinion
			target = scope:my_lover
			opinion = 25
		}

		stress_impact = {
			paranoid = medium_stress_impact_gain
			arrogant = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
			greedy = minor_stress_impact_gain
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = 200
				ai_honor = 100
			}
		}
	}
	
	# Use your lover's vulnerability to force a secret out of them.
	option = {
		name = intrigue_temptation.2201.d.sadistic
		custom_tooltip = intrigue_temptation.2201.a.success.tt
		show_as_tooltip = { add_intrigue_lifestyle_xp = minor_lifestyle_xp }

		hidden_effect = {
			send_interface_toast = {
				title = intrigue_temptation.2201.a.success
				
				scope:court_gossip = {
					reveal_to = root
				}
				add_intrigue_lifestyle_xp = minor_lifestyle_xp
			}
		}
		set_nickname_effect = { NICKNAME = nick_the_heartbreaker }

		reverse_add_opinion = {
			modifier = angry_opinion
			target = scope:my_lover
			opinion = -50
		}
		remove_relation_lover = scope:my_lover
		stress_impact = {
			compassionate = major_stress_impact_gain
			generous = medium_stress_impact_gain
			trusting = medium_stress_impact_gain
			just = minor_stress_impact_gain
			lustful = minor_stress_impact_gain
			patient = minor_stress_impact_gain
			humble = minor_stress_impact_gain
		}
		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_compassion = -200
				ai_honor = -200
				ai_greed = 100
			}
		}
	}
}


#########################################
# A visiting guest would like a tumble before leaving, by Alexander Oltner
#############################################

scripted_trigger appropriate_guest_to_become_lover_trigger = {
	is_available_healthy_ai_adult = yes
	is_pool_guest = yes
	
	save_temporary_scope_as = guest_check
	
	
	can_set_relation_lover_trigger = { CHARACTER = root }
	
	NOR = {
		fertility <= low_fertility
		has_trait = chaste
		has_relation_lover = root
		has_relation_rival = root
		is_married = yes
	}
}

intrigue_temptation.3000 = {
	type = character_event
	title = intrigue_temptation.3000.t	
	desc = intrigue_temptation.3000.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:guest_lover
		animation = flirtation
	}
	
	trigger = {
		NOT = { has_character_flag = had_event_intrigue_temptation_3000 }
		has_focus = intrigue_temptation_focus
		is_capable_adult = yes
		
		OR = {
			num_of_relation_lover <= 3
			has_trait = seducer
		}
		
		any_courtier_or_guest = {
			appropriate_guest_to_become_lover_trigger = yes
		}
	}
	
	weight_multiplier = {
		base = 1
	}
	
	immediate = {
		add_character_flag = {
			flag = had_event_intrigue_temptation_3000
			days = 1825
		}
		
		hidden_effect = { # Find an appropriate guest, prefer someone lustful, or otherwise 'not good'
			random_courtier_or_guest = {
				limit = {
					appropriate_guest_to_become_lover_trigger = yes
					has_trait = lustful
				}
				alternative_limit = {
					appropriate_guest_to_become_lover_trigger = yes
					has_personality_malicious_trigger = yes
				}
				alternative_limit = {
					appropriate_guest_to_become_lover_trigger = yes
				}
				save_scope_as = guest_lover
			}
			
			if = { # Have the guest befriend a councillor, so they can speak well of us to them!
				limit = {
					any_councillor = {
						is_available_ai_adult = yes
						has_relation_friend = scope:guest_lover
					}
				}
				random_councillor = {
					limit = {
						is_available_ai_adult = yes
						has_relation_friend = scope:guest_lover
					}
					save_scope_as = guest_lovers_friend
				}
			}
			else_if = {
				limit = {
					any_councillor = {
						is_available_ai_adult = yes
						NOT = {
							has_relation_friend = scope:guest_lover
						}
					}
				}
				random_councillor = {
					limit = {
						is_available_ai_adult = yes
						can_set_relation_friend_trigger = { CHARACTER = scope:guest_lover }
					}
					set_relation_friend = scope:guest_lover
					save_scope_as = guest_lovers_friend
				}
			}
		}
	}
	
	option = { # Take them as a lover, then they leave (perfect agent in the future!)
		name = intrigue_temptation.3000.a
		
		had_sex_with_effect = {
			CHARACTER = scope:guest_lover
			PREGNANCY_CHANCE = pregnancy_chance
		}
		
		set_relation_lover = scope:guest_lover
		
		add_opinion = {
			target = scope:guest_lover
			modifier = love_opinion
			opinion = 50
		}
		
		scope:guest_lover = {
			select_and_move_to_pool_effect = yes
		}
		
		ai_chance = {
			base = 100
			modifier = {
				factor = 0.1
				has_trait = chaste
			}
		}
		
		stress_impact = {
			chaste = major_stress_impact_gain
		}
	}
	
	option = { # Try to learn a secret, then they leave
		name = intrigue_temptation.3000.b
		
		trigger = {
			any_vassal = { # There must be a Vassal which we don't know a secret of
				is_available_ai_adult = yes
				NOT = {
					any_secret = {
						is_known_by = root
					}
				}
			}
		}
		
		hidden_effect = {
			random_vassal = { # Save a known secret, or make a relevant one up!
				limit = {
					is_available_ai_adult = yes
					any_secret = {
						NOT = { is_known_by = root }
					}
				}
				alternative_limit = {
					is_available_ai_adult = yes
					NOT = {
						any_secret = {
							always = yes
						}
					}
				}
				if = {
					limit = {
						NOT = {
							any_secret = {
								always = yes
							}
						}
					}
					give_random_likely_secret_effect = yes
				}
				random_secret = {
					if = {
						limit = {
							NOT = { is_known_by = scope:guest_lover }
						}
						reveal_to = scope:guest_lover
						save_scope_as = juicy_secret
					}
				}
				save_scope_as = juicy_secret_owner
			}
		}
		
		had_sex_with_effect = {
			CHARACTER = scope:guest_lover
			PREGNANCY_CHANCE = pregnancy_chance
		}
		
		duel = {
			desc = intrigue_temptation.3000.b.tt
			skill = intrigue
			target = scope:guest_lover
			60 = {
				desc = yearly.3000.b.success.desc
				compare_modifier = {
					value = scope:duel_value
					multiplier = low_positive_duel_skill_multiplier
				}
				custom_tooltip = yearly.3000.b.success.tt
				hidden_effect = {
					send_interface_toast = {
						title = intrigue_temptation.3000.b.success
						left_icon = scope:guest_lover
						right_icon = scope:juicy_secret_owner
						
						if = {
							limit = {
								exists = scope:juicy_secret
							}
							scope:juicy_secret = {
								reveal_to = root
							}
						}
						
					}
				}
				add_intrigue_lifestyle_xp = medium_lifestyle_experience
			}
			40 = {
				desc = yearly.3000.b.failure.desc
				compare_modifier = {
					value = scope:duel_value
					multiplier = low_negative_duel_skill_multiplier
				}
				hidden_effect = {
					send_interface_toast = {
						title = intrigue_temptation.3000.b.failure
						left_icon = scope:guest_lover
						
					}
				}
			}
		}
		
		scope:guest_lover = {
			select_and_move_to_pool_effect = yes
		}
		
		ai_chance = {
			base = 100
			modifier = {
				factor = 0.1
				OR = {
					has_trait = chaste
					has_trait = honest
				}
			}
		}
		
		stress_impact = {
			honest = medium_stress_impact_gain
			chaste = major_stress_impact_gain
		}
	}
	
	option = { # Put a good word in with a councillor
		name = intrigue_temptation.3000.c
		
		trigger = {
			exists = scope:guest_lovers_friend
		}
		
		flavor = intrigue_temptation.3000.c.tt
		
		had_sex_with_effect = {
			CHARACTER = scope:guest_lover
			PREGNANCY_CHANCE = pregnancy_chance
		}
		
		progress_towards_friend_effect = {
			CHARACTER = scope:guest_lovers_friend
			OPINION = 35
		}
		
		scope:guest_lover = {
			select_and_move_to_pool_effect = yes
		}
		
		ai_chance = {
			base = 100
			modifier = {
				factor = 0.1
				has_trait = chaste
			}
		}
		
		stress_impact = {
			chaste = major_stress_impact_gain
		}
	}	
	
	option = { # Ignore them
		name = intrigue_temptation.3000.d
		
		add_piety = minor_piety_value
		
		scope:guest_lover = {
			add_opinion = {
				target = root
				modifier = rejected_opinion
				opinion = -10
			}
		}
		
		scope:guest_lover = {
			select_and_move_to_pool_effect = yes
		}
		
		ai_chance = {
			base = 100
			modifier = {
				factor = 0
				has_trait = lustful
			}
		}
		
		stress_impact = {
			lustful = major_stress_impact_gain
		}
	}
	
}


############################
# Wing(wo)man
# by Mathilda Bjarnehed
#############################

scripted_trigger supportive_of_same_sex_seduction_trigger = {
	faith = { save_temporary_scope_as = supportive_faith }
	OR = {
		has_sexuality = bisexual
		has_sexuality = homosexual
		#We check for both men and women. Even though there is no "female sodomite" doctrine atm, there is probably not a lot of lesbian acceptance in a society that dislikes gay men
		NOR = {
			trait_is_shunned_or_criminal_in_faith_trigger = {
				FAITH = scope:supportive_faith
				TRAIT = sodomite
				GENDER_CHARACTER = dummy_female
			}
			trait_is_shunned_or_criminal_in_faith_trigger = {
				FAITH = scope:supportive_faith
				TRAIT = sodomite
				GENDER_CHARACTER = dummy_male
			}
		}
	}
}

scripted_trigger romantic_partner_is_supportive_of_multiple_partners = {
	OR = {
		AND = {
			faith = { has_doctrine = doctrine_adultery_men_accepted }
			 sexually_liberal_trigger = yes 
			root = { is_male = yes }
		}
		AND = {
			faith = { has_doctrine = doctrine_adultery_women_accepted }
			 sexually_liberal_trigger = yes 
			root = { is_female = yes }
		}
		faith = { has_doctrine_parameter = no_unfaithfulness_penalty_active }	
	}
}

intrigue_temptation.3010 = { #by Mathilda Bjarnehed
	type = character_event
	title = intrigue_temptation.3010.t
	desc = {
		desc = intrigue_temptation.3010.start.desc
		desc = intrigue_temptation.3010.end.desc
	}
	
	theme = intrigue_temptation_focus
	override_background = {
		event_background = tavern
	}
	left_portrait = {
		character = scope:bar_servant
		animation = personality_bold
	}
	right_portrait = {
		character = scope:wingman
		animation = happiness
	}

	trigger = {
		NOT = { has_character_flag = had_event_intrigue_temptation_3010 }
		mgr_can_seduce = yes
		exists = capital_province
		is_landed = yes
	}
	
	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = intrigue_temptation_focus }

		modifier = { #Since it creates a GOOD character we don't want the ai to get it too often
			add = -0.9
			is_ai = yes
		}
	}
	
	immediate = {
		play_music_cue = "mx_cue_meadandwine"

		add_character_flag = {
			flag = had_event_intrigue_temptation_3010
			years = 15
		}

		hidden_effect = {
			#I already have a temptation friend, grab them
			if = {
				limit = {
					any_relation = {
						type = friend
						lifestyle_friend_trigger = { CHARACTER = root FOCUS = intrigue_temptation_focus }
						trigger_if = {
							limit = { is_spouse_or_romantic_partner_of_root = yes }
							romantic_partner_is_supportive_of_multiple_partners = yes
						}
					}
				}
				random_relation = {
					type = friend
					limit = { 
						lifestyle_friend_trigger = { CHARACTER = root FOCUS = intrigue_temptation_focus } 
						trigger_if = {
							limit = { is_spouse_or_romantic_partner_of_root = yes }
							romantic_partner_is_supportive_of_multiple_partners = yes
						}
					}
					save_scope_as = wingman
				}
			}
			#Else grab a new potential one
			else = {
				potential_lifestyle_friend_saving_effect = {
					FOCUS = intrigue_temptation_focus
					SCOPE_NAME = wingman
				}

				#Is my sexuality considered a sin? Wingman isn't accepting? Let's get someone else
				if = {
					limit = {
						OR = {
							has_sexuality = bisexual
							has_sexuality = homosexual
						}
						scope:wingman = {
							supportive_of_same_sex_seduction_trigger = no
						}
					}
					random_in_list = {
						list = lifestyle_friend_list #Saved through potential_lifestyle_friend_saving_effect
						limit = {
							supportive_of_same_sex_seduction_trigger = yes
							opinion = {
								target = root
								value >= 0
							}
							#If the wingman is my spouse, are they cool with this? If not, let's get someone else
							trigger_if = {
								limit = { is_spouse_or_romantic_partner_of_root = yes 	}
								romantic_partner_is_supportive_of_multiple_partners = yes
							}
							
						}
						weight = {
							base = 1
							modifier = {
								add = intrigue_temptation_focus_friend_points
							}
							modifier = {
								has_relation_potential_friend = scope:friend_checker
								add = 10
							}
							opinion_modifier = {
								opinion_target = scope:friend_checker
								multiplier = 0.2
							}
						}
						save_scope_as = wingman
					}	

					#We didn't find anyone new? Let's create someone and make them our guest
					if = {
						limit = {
							scope:wingman = {
								supportive_of_same_sex_seduction_trigger = no
							}
							#If the wingman is my spouse, are they cool with this? If not, let's get someone else
							scope:wingman = { 
								trigger_if = {
									limit = { 
										is_spouse_or_romantic_partner_of_root = yes 
									}
									romantic_partner_is_supportive_of_multiple_partners = yes
								}
							}
						}
						create_character = {
							location = root.capital_province
							template = intrigue_temptation_focus_friend_template
							save_scope_as = wingman
						}
						scope:wingman = {
							set_sexuality = bisexual
							visit_court_of = root
						}
					}
				}
			}

			#Save a seduction target
			random_pool_character = {
				province = root.capital_province
				limit = {
					save_temporary_scope_as = attractive_peasant
					root = { is_attracted_to_gender_of = scope:attractive_peasant }
					is_attracted_to_gender_of = root
					NOT = { exists = dynasty }
					is_adult = yes
					age <= 35
					attraction >= medium_positive_attraction
					can_set_relation_lover_trigger = { CHARACTER = root }
				}
				weight = {
					base = 20
					compatibility_modifier = {
						compatibility_target = root
						min = -15
						max = 100
						multiplier = 3
					}
				}
				save_scope_as = bar_servant
				if = {
					limit = { NOT = { has_trait = beauty_good } }
					add_trait = beauty_good_2
				}
			}

			if = {
				limit = {
					NOT = { exists = scope:bar_servant }
				}

				romance_target_gender_effect = { SCOPE_NAME = romance_target }

				create_character = {
					location = root.capital_province
					gender = scope:romance_target
					template = beautiful_peasant_character
					random_traits_list = {
						count = 1
						gregarious = {}
						lustful = {}
						compassionate = {}
						diligent = {}
						generous = {}
						ambitious = {}
					}
					save_scope_as = bar_servant
				}
				hidden_effect = {
					random_list = {
						25 = {
							trigger = {
								is_female = yes
								scope:bar_servant = { is_female = yes }
							}
							scope:bar_servant = { set_sexuality = homosexual }
						}
						100 = {
							trigger = {
								is_female = yes
								scope:bar_servant = { is_male = yes }
							}
							scope:bar_servant = { set_sexuality = heterosexual }
						}
						25 = {
							trigger = {
								is_male = yes
								scope:bar_servant = { is_male = yes }
							}
							scope:bar_servant = { set_sexuality = homosexual }
						}
						100 = {
							trigger = {
								is_male = yes
								scope:bar_servant = { is_female = yes }
							}
							scope:bar_servant = { set_sexuality = heterosexual }
						}
						50 = {
							scope:bar_servant = { set_sexuality = bisexual }
						}
					}
				}
			}
		}
	}

	# Accept help
	option = {
		name = intrigue_temptation.3010.a
			
		if = {
			limit = {
				has_relation_friend = scope:wingman
			}
			custom_tooltip = intrigue_temptation.3010.success.tt
			show_as_tooltip = { intrigue_temptation_3010_a_success_effect = yes }
			save_scope_value_as = {
				name = accept_help
				value = yes
			}
			trigger_event = intrigue_temptation.3011
		}
		else = {
			duel = {
				skill = intrigue
				value = average_skill_rating
				60 = {
					desc = intrigue_temptation.3010.a.success
					compare_modifier = {
						value = scope:duel_value
						multiplier = 3
					}
					modifier = {
						add = {
							value = scope:wingman.intrigue
							subtract = average_skill_rating
							multiply = 3
							min = 15 #Guaranteed help
						}
					}
					modifier = {
						add = {
							value = attraction
							divide = high_positive_attraction
							multiply = 40
						}
					}
					custom_tooltip = intrigue_temptation.3010.success.tt
					show_as_tooltip = { intrigue_temptation_3010_a_success_effect = yes }
					save_scope_value_as = {
						name = accept_help
						value = yes
					}
					trigger_event = intrigue_temptation.3011
				}
				40 = {	
					desc = intrigue_temptation.3010.a.failure
					compare_modifier = {
						value = scope:duel_value
						multiplier = -3
					}
					min = 5
					modifier = {
						add = {
							value = scope:wingman.intrigue
							subtract = average_skill_rating
							multiply = -3
							max = 0 #They shouldn't make this worse
						}
					}
					send_interface_toast = {
						title = intrigue_temptation.3010.a.failure
						left_icon = scope:bar_servant
					}
				}
			}
		}
	}

	# I do this myself
	option = {
		name = intrigue_temptation.3010.b

		duel = {
			skill = intrigue
			value = average_skill_rating
			60 = {
				desc = intrigue_temptation.3010.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3
				}
				modifier = {
					add = {
						value = attraction
						divide = high_positive_attraction
						multiply = 40
					}
				}
				custom_tooltip = intrigue_temptation.3010.success.tt
				show_as_tooltip = { intrigue_temptation_3010_b_success_effect = yes }
				save_scope_value_as = {
					name = accept_help
					value = no
				}
				trigger_event = intrigue_temptation.3011
			}
			40 = {
				desc = intrigue_temptation.3010.a.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3
				}
				min = 5
				send_interface_toast = {
					title = intrigue_temptation.3010.a.failure
					left_icon = scope:bar_servant
				}	
			}
		}
	}
	
	# I was just here for a drink
	option = {
		name = intrigue_temptation.3010.c
		
		stress_impact = {
			base = medium_stress_impact_loss
			lustful = minor_stress_impact_gain
			shy = minor_stress_impact_loss
			lazy = minor_stress_impact_loss
			drunkard = medium_stress_impact_loss
		}
	}
}			


# Success! What do you want to do?
intrigue_temptation.3011 = { #by Mathilda Bjarnehed
	type = character_event
	title = intrigue_temptation.3010.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:accept_help = yes }
				desc = intrigue_temptation.3011.help.desc
			}
			desc = intrigue_temptation.3011.alone.desc
		}
	}
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:bar_servant
		animation = flirtation
	}
	right_portrait = {
		character = scope:portrait_wingman
		animation = personality_dishonorable
	}
	
	immediate = {
		reverse_add_opinion = {
			modifier = romance_opinion
			opinion = 20
			target = scope:bar_servant
		}
		if = {
			limit = { scope:accept_help = yes }
			intrigue_temptation_3010_a_success_effect = yes
			scope:wingman = { save_scope_as = portrait_wingman }
		}
		else = {
			intrigue_temptation_3010_b_success_effect = yes
		}
	}

	# Become lover
	option = {
		name = intrigue_temptation.3011.a

		set_relation_lover = scope:bar_servant
		had_sex_with_effect = {
				CHARACTER = scope:bar_servant
				PREGNANCY_CHANCE = pregnancy_chance
			}
	}

	# One night stand
	option = {
		name = intrigue_temptation.3011.b
		
			had_sex_with_effect = {
				CHARACTER = scope:bar_servant
				PREGNANCY_CHANCE = pregnancy_chance
			}
	}
	
	# Leave them wanting more
	option = {
		name = intrigue_temptation.3011.c
		
		add_character_modifier = {
			modifier = unattainable_modifier
			years = 10
		}

		hidden_effect = {
			progress_towards_lover_effect = {
				CHARACTER = scope:bar_servant
				OPINION = no
			}
		}
	}
}


##############################
# Medieval tinder
# by Mathilda Bjarnehed
##############################

scripted_trigger intrigue_temptation_3020_viable_date_trigger = {
	save_temporary_scope_as = potential_date_check
	is_adult = yes
	mgr_can_seduce = yes
	is_attracted_to_gender_of = root
	trigger_if = {
		limit = { root = { NOT = { has_sexuality = asexual } } }
		root = { is_attracted_to_gender_of = scope:potential_date_check }
	}
	trigger_else = {
		sex_opposite_of = root
	}
	age <= 45
	NOR = {
		has_character_flag = intrigue_temptation_3020_recent_player_target
		is_close_or_extended_family_of = root
		this = root
	}
	in_diplomatic_range = root
}

scripted_trigger intrigue_temptation_3020_this_or_family_viable_date_trigger = { #Should match selection in intrigue_temptation_3020_add_this_and_family_to_dates_list_effect
	OR = {
		intrigue_temptation_3020_viable_date_trigger = yes
		trigger_if = {
			limit = { exists = primary_spouse }
			primary_spouse = { intrigue_temptation_3020_viable_date_trigger = yes }
		}
	}
}

scripted_effect intrigue_temptation_3020_add_this_and_family_to_dates_list_effect = {
	if = {
		limit = { intrigue_temptation_3020_viable_date_trigger = yes }
		add_to_list = potential_dates_list
	}
	if = {
		limit = {
			exists = primary_spouse
			primary_spouse = { intrigue_temptation_3020_viable_date_trigger = yes }
		}
		primary_spouse = {
			add_to_list = potential_dates_list
		}
	}
	if = {
		limit = { root = { is_ai = no } } #Bonus for players
		every_child = {
			limit = {
				is_married = no
				is_courtier_of = prev
				intrigue_temptation_3020_viable_date_trigger = yes
			}
			add_to_list = potential_dates_list
		}
	}
}

scripted_effect intrigue_temptation_302x_next_portrait_effect = {
	if = {
		limit = {
			NOT = { exists = scope:date_3 } #I can still pick dates
		}
		if = {
			limit = { is_ai = no }
			random_in_list = {
				list = potential_dates_list
				limit = {
					NOR = {
						is_in_list = approved_dates
						is_in_list = declined_dates
					}
				}
				weight = {
					base = 5
					#Attraction and personality
					compatibility_modifier = {
						compatibility_target = root
						min = -15
						max = 100
						multiplier = 3
					}
					modifier = {
						add = {
							value = attraction
							divide = high_positive_attraction
							multiply = 40
						}
					}
					modifier = { #Because otherwise you will almost only get opposite sex matches
						root = { has_sexuality = bisexual }
						sex_same_as = root
						add = 50
					}
					#Player targets
					modifier = {
						OR = {
							is_ai = no
							any_spouse = {
								is_ai = no
							}
							any_parent = {
								is_ai = no
							}
						}
						add = 100
					}
					#Highest_held_title_tier
					modifier = {
						is_landed = yes
						add = {
							value = highest_held_title_tier
							multiply = 20
						}
					}
					modifier = {
						is_landed = no
						exists = primary_spouse
						primary_spouse = { is_landed = yes }
						add = {
							value = primary_spouse.highest_held_title_tier
							multiply = 15
						}
					}
					modifier = {
						is_landed = no
						exists = father
						father = { is_landed = yes }
						add = {
							value = father.highest_held_title_tier
							multiply = 15
						}
					}
					modifier = {
						is_landed = no
						exists = mother
						mother = { is_landed = yes }
						add = {
							value = mother.highest_held_title_tier
							multiply = 15
						}
					}
				}
				save_scope_as = potential_date
			}
		}
		else = {
			random_in_list = {
				limit = {
					NOT = {
						is_in_list = approved_dates #The AI does not decline dates
					}
				}
				list = potential_dates_list
				weight = {
					base = 5
					#Player targets
					modifier = {
						OR = {
							is_ai = no
							any_spouse = {
								is_ai = no
							}
							any_parent = {
								is_ai = no
							}
						}
						add = 10
					}
				}
				save_scope_as = potential_date
			}
		}
	}

	#Are we done? Yes
	if = {
		limit = {
			OR = {
				exists = scope:date_3
				scope:potential_date = { #We failed to pick a new date
					OR = {
						is_in_list = approved_dates
						is_in_list = declined_dates
					}
				}
			}
		}
		trigger_event = intrigue_temptation.3022
	}
	#No
	else = {
		trigger_event = intrigue_temptation.3021
	}
}

intrigue_temptation.3020 = { #by Mathilda Bjarnehed
	type = character_event
	title = intrigue_temptation.3020.t
	desc = {
		desc = intrigue_temptation.3020.start.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					is_attracted_to_men = yes
					is_attracted_to_women = yes
				}
				desc = intrigue_temptation.3020.nobles.desc
			}
			triggered_desc = {
				trigger = {
					OR = {
						is_attracted_to_men = yes
						AND = {
							is_female = yes
							has_sexuality = asexual
						}
					}
				}
				desc = intrigue_temptation.3020.noblemen.desc
			}
			triggered_desc = {
				trigger = {
					OR = {
						is_attracted_to_women = yes
						AND = {
							is_male = yes
							has_sexuality = asexual
						}
					}
				}
				desc = intrigue_temptation.3020.noblewomen.desc
			}
		}
		desc = intrigue_temptation.3020.end.desc
	}
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = root
		animation = personality_greedy
	}
	
	trigger = {
		is_ai = no
		NOT = { has_character_flag = had_event_intrigue_temptation_3020 }
		trigger_if = {
			limit = { is_ai = yes } #Players throw a much wider net
			top_liege = {
				any_vassal = {
					intrigue_temptation_3020_this_or_family_viable_date_trigger = yes
				}
			}
		}
	}
	
	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = intrigue_temptation_focus }
	}

	immediate = {
		play_music_cue_once = { TRACK = mx_cue_marriage }
		add_character_flag = {
			flag = had_event_intrigue_temptation_3020
		}
	}
	
	# Let's go!
	option = {
		name = intrigue_temptation.3020.a
		custom_tooltip = intrigue_temptation.3020.a.tt
		
		hidden_effect = {
			#Set up lists
			if = {
				limit = { is_ai = no }
				every_ruler = {
					limit = { NOT = { this = root } }
					intrigue_temptation_3020_add_this_and_family_to_dates_list_effect = yes
				}
			}
			else = {
				top_liege = {
					every_vassal = {
						intrigue_temptation_3020_add_this_and_family_to_dates_list_effect = yes
					}
				}
				every_player = {
					intrigue_temptation_3020_add_this_and_family_to_dates_list_effect = yes
				}
			}
			#Let's go!
			intrigue_temptation_302x_next_portrait_effect = yes #picks someone from the list and sends 3021
		}
	}

	# Nah...
	option = {
		name = intrigue_temptation.3020.b
		add_character_modifier = {
			modifier = intrigue_picky_about_partners
			years = 5
		}
	}
}

scripted_effect intrigue_temptation_3021_save_approved_date_effect = {
	add_to_list = approved_dates
	if = {
		limit = { NOT = { exists = scope:date_1 } }
		save_scope_as = date_1
	}
	else_if = {
		limit = { NOT = { exists = scope:date_2 } }
		save_scope_as = date_2
	}
	else = {
		save_scope_as = date_3
	}
}

#Pick your portraits
intrigue_temptation.3021 = { #by Mathilda Bjarnehed
	type = character_event
	title = intrigue_temptation.3020.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { 	
					scope:potential_date = {
						has_character_flag = naked_intrigue_temptation_3021
					}
				}
				desc = intrigue_temptation.3021.lewd.desc
			}
			triggered_desc = {
				trigger = { scope:potential_date = { has_trait = beauty_good } }
				desc = intrigue_temptation.3021.beauty.desc
			}
			triggered_desc = {
				trigger = { scope:potential_date = { has_trait = beauty_bad } }
				desc = intrigue_temptation.3021.ugly.desc
			}
			triggered_desc = {
				trigger = {
					scope:potential_date = {
						is_female = yes
						has_trait = arrogant
					}
				}
				desc = intrigue_temptation.3021.arrogant.desc
			}
			triggered_desc = {
				trigger = {
					age >= 22
					scope:potential_date = {
						is_female = yes
						has_trait = impatient
						age >= 22
					}
				}
				desc = intrigue_temptation.3021.impatient.desc
			}
			random_valid = {
				desc = intrigue_temptation.3021.generic1.desc
				desc = intrigue_temptation.3021.generic2.desc
				desc = intrigue_temptation.3021.generic3.desc
				desc = intrigue_temptation.3021.generic4.desc
				triggered_desc = {
					trigger = {
						scope:potential_date = {
							is_male = yes
							NOT = { has_trait = humble }
						}
					}
					desc = intrigue_temptation.3021.arrogant.desc
				}
				triggered_desc = {
					trigger = {
						age >= 22
						scope:potential_date = {
							is_male = yes
							NOT = { has_trait = patient }
							age >= 22
						}
					}
					desc = intrigue_temptation.3021.impatient.desc
				}
				triggered_desc = {
					trigger = {
						scope:potential_date = {
							is_male = yes
							NOT = { has_trait = dwarf }
						}
					}
					desc = intrigue_temptation.3021.tall.desc
				}
				triggered_desc = {
					trigger = { scope:potential_date = { ai_boldness >= medium_positive_ai_value } }
					desc = intrigue_temptation.3021.adventurous.desc
				}
				triggered_desc = {
					trigger = { scope:potential_date = { is_male = yes } }
					desc = intrigue_temptation.3021.fish.desc
				}
				triggered_desc = {
					trigger = {
						scope:potential_date = {
							OR = {
								ai_honor <= 0
								ai_compassion >= 0
							}
						}
					}
					desc = intrigue_temptation.3021.dog.desc
				}
				triggered_desc = {
					trigger = {
						scope:potential_date = {
							is_male = yes
							is_married = no
						}
					}
					desc = intrigue_temptation.3021.do_not_believe.desc
				}
				triggered_desc = {
					trigger = {
						is_male = yes
						scope:potential_date = { is_female = yes }
					}
					desc = intrigue_temptation.3021.must_be_tall.desc
				}
			}
		}
	}
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:potential_date
		animation = flirtation
		triggered_outfit = {
			trigger = { scope:potential_date = { has_character_flag = naked_intrigue_temptation_3021 } }
			outfit_tags = { no_clothes }
		}
	}
	
	trigger = {
		exists = scope:potential_date
	}	

	immediate = {
		scope:potential_date = {
			if = {
				limit = {
					NOT = { has_trait = chaste }
					OR = {
						has_trait = lustful
						AND = {
							is_male = yes
							ai_boldness >= medium_positive_boldness
						}
					}
				}
				random = {
					chance = 20
					add_character_flag = naked_intrigue_temptation_3021
				}
			}
		}
	}

	#Put in top pile (fav)
	option = {
		name = intrigue_temptation.3021.a
		custom_tooltip = intrigue_temptation.3021.a.tt

		#Tooltip
		if = {
			limit = { exists = scope:favorite }
			custom_tooltip = intrigue_temptation.3021.a.favorite_exists.tt
		}

		scope:potential_date = {
			save_scope_as = favorite
			intrigue_temptation_3021_save_approved_date_effect = yes
		}

	}

	#Put in right pile (yes)
	option = {
		name = intrigue_temptation.3021.b
		#Tooltip
		custom_tooltip = intrigue_temptation.3021.b.tt
		if = {
			limit = { exists = scope:date_2 }
			custom_tooltip = intrigue_temptation.3021.b.2_dates.tt
		}
		else_if = {
			limit = { exists = scope:date_1 }
			custom_tooltip = intrigue_temptation.3021.b.1_date.tt
		}

		scope:potential_date = {
			intrigue_temptation_3021_save_approved_date_effect = yes
		}

	}

	#Put in left pile (no)
	option = {
		trigger = {
			is_ai = no
		}
		name = intrigue_temptation.3021.c
		custom_tooltip = intrigue_temptation.3021.c.tt
		scope:potential_date = {
			add_to_list = declined_dates
		}
	}

	#Opt out
	option = {
		name = intrigue_temptation.3021.d
		trigger = {
			is_ai = no
		}
		custom_tooltip = intrigue_temptation.3021.d.tt

		add_character_modifier = {
			modifier = intrigue_picky_about_partners
			years = 5
		}

		save_scope_value_as = {
			name = ending_chain
			value = yes
		}
	}

	after = {
		hidden_effect = {
			if = {
				limit = {
					NOT = { exists = scope:ending_chain }
				}
				scope:potential_date = { remove_character_flag = naked_intrigue_temptation_3021 }
				intrigue_temptation_302x_next_portrait_effect = yes
			}
		}
	}
}

#Decide what to do with portraits
scripted_effect intrigue_temptation_3022_great_outcome_effect = {
	progress_towards_lover_effect = {
		CHARACTER = root
		OPINION = 20
	}	
}

scripted_effect intrigue_temptation_3022_b_failure_outcome_effect = {
	add_opinion = {
		target = root
		modifier = seduce_permanent_blocker_opinion
	}
}

intrigue_temptation.3022 = { #by Mathilda Bjarnehed
	type = character_event
	title = intrigue_temptation.3020.t
	desc = intrigue_temptation.3022.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:favorite
		animation = admiration
	}
	right_portrait = {
		character = scope:right_portrait
		animation = flirtation
	}
	lower_left_portrait = scope:lower_left_portrait
	lower_right_portrait = scope:lower_right_portrait

	immediate = {
		### Portrait scopes

		#Left portrait is favorite or, if there is no favorite, a random one
		if = {
			limit = { NOT = { exists = scope:favorite } }
			random_in_list = {
				list = approved_dates
				save_scope_as = favorite
			}
		}

		#Lower portraits are the others
		random_in_list = {
			list = approved_dates
			limit = { NOT = { this = scope:favorite } }
			save_scope_as = lower_left_portrait
		}
		random_in_list = {
			list = approved_dates
			limit = {
				NOR = {
					this = scope:favorite
					this = scope:lower_left_portrait
				}
			}
			save_scope_as = lower_right_portrait
		}

		save_scope_as = letter_writer
	}
	
	#Send only one good letter
	option = {
		name = intrigue_temptation.3022.a
		add_intrigue_lifestyle_xp = minor_lifestyle_xp

		set_variable = {
			name = love_letter_quality
			value = 4
			days = 30
		}
		scope:favorite = {
			intrigue_temptation_3022_great_outcome_effect = yes
			trigger_event = intrigue_temptation.3023

			if = {
				limit = {
					is_ai = no
				}
				add_character_flag = { # Players can only be the target of one of these events once every 10 years (it gets spammy otherwise).
					flag = intrigue_temptation_3020_recent_player_target
					years = 10
				}
			}
		}
	}

	#Send to all three, hoping it goes well
	option = {
		trigger = {
			exists = scope:date_2
		}
		name = intrigue_temptation.3022.b

		add_intrigue_lifestyle_xp = minor_lifestyle_xp

		duel = {
			skill = intrigue
			desc = outcome_in_a_few_days
			value = {
				add = scope:date_1.intrigue
				if = {
					limit = { exists = scope:date_3 }
					add = scope:date_2.intrigue
					add = scope:date_3.intrigue
					divide = 3
				}
			}
			70 = {
				desc = intrigue_temptation.3022.b.success
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3
				}
				set_variable = {
					name = love_letter_quality
					value = 4
					days = 30
				}
				save_scope_value_as = {
					name = multiple_letters
					value = yes
				}
				every_in_list = {
					custom = every_approved_date
					list = approved_dates
					show_as_tooltip = { intrigue_temptation_3022_great_outcome_effect = yes }
					trigger_event = intrigue_temptation.3023

					if = {
							limit = {
								is_ai = no
							}
							add_character_flag = { # Players can only be the target of one of these events once every 10 years (it gets spammy otherwise).
								flag = intrigue_temptation_3020_recent_player_target
								years = 10
							}
						}
				}
			}
			30 = {
				desc = intrigue_temptation.3022.b.failure
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3
					min = -20
				}
				every_in_list = {
					custom = every_approved_date
					list = approved_dates
					show_as_tooltip = { intrigue_temptation_3022_b_failure_outcome_effect = yes }
				}
				trigger_event = {
					id = intrigue_temptation.3025
					days = { 14 20 }
				}
			}
		}
	}
	
	#Actually opt out
	option = {
		name = intrigue_temptation.3022.c

		add_character_modifier = {
			modifier = intrigue_picky_about_partners
			years = 5
		}

		ai_chance = {
			base = 0
		}
	}
}

#The date receives their love letter (good outcome)
intrigue_temptation.3023 = { #by Mathilda Bjarnehed
	type = letter_event
	opening = intrigue_temptation.3023.t
	desc = intrigue_temptation.3023.desc
	sender = scope:letter_writer

	immediate = {
		save_scope_as = answering_date
	}


	# Send a letter back
	option = {
		name = intrigue_temptation.3023.a

		love_letter_calculation_effect = yes

		reverse_add_opinion = {
			target = scope:letter_writer
			modifier = romance_opinion
			opinion = 20
		}

		scope:letter_writer = {
			trigger_event = {
				id = intrigue_temptation.3024
				days = { 7 14 }
			}
		}
	}

	# Send it to spouse instead, with some minor edits
	option = {
		trigger = {
			exists = primary_spouse
		}
		name = intrigue_temptation.3023.b
			
		reverse_add_opinion = {
			target = primary_spouse
			modifier = romance_opinion
			opinion = 15
		}

		ai_chance = {
			base = 0
		}
	}

	# Ignore
	option = {
		trigger = { is_ai = no }
		name = intrigue_temptation.3023.c

		ai_chance = {
			base = 0
		}
	}
}

#It went well!
intrigue_temptation.3024 = { #by Mathilda Bjarnehed
	type = letter_event
	opening = intrigue_temptation.3023.t
	desc = intrigue_temptation.3024.desc
	sender = scope:answering_date
	
	trigger = {
		scope:answering_date = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		scope:answering_date = {
			intrigue_temptation_3022_great_outcome_effect = yes
		}
	}

	option = {
		name = intrigue_temptation.3024.a
		
			hidden_effect = {
				scope:answering_date = {
					remove_variable = love_letter_quality
				}
				#Can't remove my own variable because I don't know if I'm done yet! But it has a duration
			}
	}
}

#It went poorly...
intrigue_temptation.3025 = { #by Mathilda Bjarnehed
	type = letter_event
	opening = intrigue_temptation.3025.t
	desc = intrigue_temptation.3025.desc
	sender = scope:favorite
	
	trigger = {
		scope:favorite = {
			is_alive = yes
			is_imprisoned = no
		}
	}

	immediate = {
		every_in_list = {
			custom = every_approved_date
			list = approved_dates
			intrigue_temptation_3022_b_failure_outcome_effect = yes
		}
	}

	option = {
		name = intrigue_temptation.3025.a
		
		remove_variable = love_letter_quality
	}
}



#############################################
####### SPECIAL EVENTS ######################
#############################################

##################################################
# Matchmaking
# By Mathilda Bjarnehed
##################################################

scripted_trigger intrigue_temptation_special_1001_wants_love = {
	is_available_healthy_ai_adult = yes
	mgr_can_seduce = yes
	save_temporary_scope_as = wants_love_test
	NOR = {
		is_consort_of = root
		has_relation_lover = root
	}
	reverse_opinion = {
		value >= 10
		target = root
	}
	OR = {
		# Not happily married
		is_married = no
		any_spouse = {
			reverse_opinion = {
				value <= low_positive_opinion
				target = scope:wants_love_test
			}
		}
		has_trait_extroverted_trigger = yes
	}
	NOR = {
		has_trait = celibate
		has_sexuality = asexual
		any_spouse = {
			reverse_opinion = {
				value >= high_positive_opinion
				target = scope:wants_love_test
			}
		}
		any_relation = { type = soulmate always = yes }
	}
}

scripted_trigger intrigue_temptation_special_1001_available_match = {
	is_available_healthy_ai_adult = yes
	save_temporary_scope_as = available_match_option
	NOR = {
		is_spouse_of = root
		has_relation_lover = root
		has_relation_lover = scope:wants_love
		is_spouse_of = scope:wants_love
		has_relation_rival = scope:wants_love
		is_close_or_extended_family_of = scope:wants_love
		this = scope:wants_love
	}
}

scripted_trigger intrigue_temptation_special_1001_good_match = {
	save_temporary_scope_as = evaluate_gender
	scope:wants_love = { is_attracted_to_gender_of = scope:evaluate_gender }
	is_attracted_to_gender_of = scope:wants_love
	trigger_if = {
		limit = { scope:wants_love = { scope:preference_flag = flag:sex_appeal } }
		attraction >= 10
	}
	trigger_if = {
		limit = { scope:wants_love = { scope:preference_flag = flag:power } }
		OR = {
			is_landed = yes
			AND = {
				exists = root.player_heir
				this = root.player_heir
			}
			is_knight = yes
			is_councillor_of = root
			AND = {
				ai_greed = high_positive_greed
				is_lowborn = no
			}
		}
	}
	trigger_if = {
		limit = { scope:wants_love = { scope:preference_flag = flag:personality } }
		OR = {
			number_of_traits_in_common = {
				target = scope:wants_love
				value >= 1
			}
			ai_values_divergence = {
				target = scope:wants_love
				value <= low_ai_values_divergence
			}
		}
		number_of_opposing_traits = {
			target = scope:wants_love
			value = 0
		}
	}
}

scripted_trigger intrigue_temptation_special_1001_great_match = {
	save_temporary_scope_as = evaluate_gender
	scope:wants_love = { is_attracted_to_gender_of = scope:evaluate_gender }
	is_attracted_to_gender_of = scope:wants_love
	trigger_if = {
		limit = { scope:wants_love = { scope:preference_flag = flag:sex_appeal } }
		attraction >= 20
	}
	trigger_if = {
		limit = { scope:wants_love = { scope:preference_flag = flag:power } }
		OR = {
			highest_held_title_tier >= scope:wants_love.highest_held_title_tier
			AND = {
				is_landed = yes
				ai_greed = high_positive_greed
			}
		}
	}
	trigger_if = {
		limit = { scope:wants_love = { scope:preference_flag = flag:personality } }
		OR = {
			number_of_traits_in_common = {
				target = scope:wants_love
				value >= 2
			}
			ai_values_divergence = {
				target = scope:wants_love
				value <= very_low_ai_values_divergence
			}
		}
		number_of_opposing_traits = {
			target = scope:wants_love
			value = 0
		}
	}	
}

scripted_trigger intrigue_temptation_special_1001_bad_match = {
	save_temporary_scope_as = evaluate_gender
	intrigue_temptation_special_1001_good_match = no
}

# Hidden setup event
intrigue_temptation_special.1000 = {
	hidden = yes

	trigger = {
		has_focus = intrigue_temptation_focus
		NOT = { exists = scope:checked_intrigue_1000_recently }
		NOT = { has_character_flag = had_intrigue_temptation_special_1000_this_lifetime }
		is_in_civil_war = no
		OR = { # Expensive, so we restrict the AI use of this
			is_ai = no
			highest_held_title_tier > tier_county
		}
		OR = {
			any_relation = { type = friend intrigue_temptation_special_1001_wants_love = yes }
			any_sibling = { intrigue_temptation_special_1001_wants_love = yes }
			any_parent = { intrigue_temptation_special_1001_wants_love = yes }
			AND = {
				is_independent_ruler = no
				exists = liege
				liege = { intrigue_temptation_special_1001_wants_love = yes }
			}
			any_vassal = {
				is_powerful_vassal = yes
				intrigue_temptation_special_1001_wants_love = yes
			}
			any_child = { intrigue_temptation_special_1001_wants_love = yes }
		}
	}

	immediate = {
		add_character_flag = {
			flag = is_in_intrigue_special_event
			days = 100
		}
		# Create list
		every_relation = {
			type = friend
			limit = { intrigue_temptation_special_1001_wants_love = yes }
			add_to_temporary_list = potential_wants_love
		}
		every_sibling = {
			limit = { intrigue_temptation_special_1001_wants_love = yes }
			add_to_temporary_list = potential_wants_love
		}
		every_parent = {
			limit = { intrigue_temptation_special_1001_wants_love = yes }
			add_to_temporary_list = potential_wants_love
		}
		if = {
			limit = {
				is_independent_ruler = no
				exists = liege
				liege = { intrigue_temptation_special_1001_wants_love = yes }
			}
			liege = { add_to_temporary_list = potential_wants_love }
		}
		every_vassal = {
			limit = {
				is_powerful_vassal = yes
				intrigue_temptation_special_1001_wants_love = yes
			}
			add_to_temporary_list = potential_wants_love
		}
		every_child = {
			limit = { intrigue_temptation_special_1001_wants_love = yes }
			add_to_temporary_list = potential_wants_love
		}

		# Picks someone who wants love:
		random_in_list = {
			list = potential_wants_love
			weight = {
				base = 1
				modifier = {
					OR = {
						has_trait_extroverted_trigger = yes
						is_married = no
					}
					factor = 10
				}
			}
			save_scope_as = wants_love
		}

		# Do they prefer personality, power or good looks?
		scope:wants_love = {
			random_list = {
				1 = {
					modifier = {
						OR = {
							has_trait = arrogant
							has_trait = lustful
						}
						factor = 10
					}
					modifier = {
						attraction >= 10
						factor = 5
					}
					save_scope_value_as = {
						name = preference_flag
						value = flag:sex_appeal
					}
				}
				2 = {
					compare_modifier = {
						factor = ai_greed
						multiplier = 0.2
						max = 10
						min = 0.8
					}
					save_scope_value_as = {
						name = preference_flag
						value = flag:power
					}
				}
				3 = {
					compare_modifier = {
						factor = ai_compassion
						multiplier = 0.2
						max = 10
						min = 0.5
					}
					save_scope_value_as = {
						name = preference_flag
						value = flag:personality
					}
				}
			}
		}

		# Make a list of all available matches
		every_vassal_or_below = {
			limit = { intrigue_temptation_special_1001_available_match = yes }
			add_to_list = available_matches
		}
		every_courtier = {
			limit = { intrigue_temptation_special_1001_available_match = yes }
			add_to_list = available_matches
		}
		if = {
			limit = {
				exists = dynasty
				dynasty = {
					any_dynasty_member = {
						intrigue_temptation_special_1001_available_match = yes
					}
				}
			}
			dynasty = {
				every_dynasty_member = {
					limit = { intrigue_temptation_special_1001_available_match = yes }
					add_to_list = available_matches
				}
			}
		}
		# Pick a good match from the list
		random_in_list = {
			list = available_matches
			limit = {
				is_married = no
				intrigue_temptation_special_1001_great_match = yes
			}
			alternative_limit = {
				is_married = yes
				intrigue_temptation_special_1001_great_match = yes
			}
			alternative_limit = {
				is_married = no
				intrigue_temptation_special_1001_good_match = yes
			}
			alternative_limit = {
				is_married = yes
				intrigue_temptation_special_1001_good_match = yes
			}
			add_to_list = potential_matches
		}

		# Pick a bad match from the list (if we found a good one)
		if = {
			limit = {
				any_in_list = {
					list = potential_matches
					count = 1
				}
			}
			random_in_list = {
				list = available_matches
				limit = {
					is_married = no
					intrigue_temptation_special_1001_bad_match = yes
				}
				alternative_limit = {
					is_married = yes
					intrigue_temptation_special_1001_bad_match = yes
				}
				weight = {
					base = 1
					modifier = {
						scope:wants_love = { is_attracted_to_gender_of = prev }
						add = 10
					}
				}
				add_to_list = potential_matches
			}
		}
		# If we have a good and a bad potential match, start the event
		if = {
			limit = {
				any_in_list = {
					list = potential_matches
					count = 2
				}
			}
			trigger_event = intrigue_temptation_special.1001
		}

		# If the event won't work, trigger the on_action for another regular event
		else = {
			remove_character_flag = is_in_intrigue_special_event
			save_scope_value_as = {
				name = checked_intrigue_1000_recently
				value = yes
			}
			trigger_event = {
				on_action = intrigue_lifestyle_common_events
			}
		}
	}
}

#You notice someone lonely
intrigue_temptation_special.1001 = {
	type = character_event
	title = intrigue_temptation_special.1001.t
	desc = intrigue_temptation_special.1001.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:wants_love
		animation = sadness
	}

	immediate = {
		hidden_effect = {
			add_character_flag = had_intrigue_temptation_special_1000_this_lifetime
		}
	}

	#Find them a match
	option = {
		name = intrigue_temptation_special.1001.a
		custom_tooltip = intrigue_lifestyle_perk_indication
		custom_tooltip = intrigue_temptation_special.1001.a.tt
		play_music_cue = "mx_cue_marriage"

		hidden_effect = { trigger_event = intrigue_temptation_special.1002 }
	}

	#Focus on your own love (ends chain)
	option = {
		trigger = { is_married = yes }
		name = intrigue_temptation_special.1001.b
		add_intrigue_lifestyle_xp = miniscule_lifestyle_xp
		random_spouse = {
			reverse_add_opinion = {
				target = root
				modifier = renewed_attention
			}
			hidden_effect = {
				add_opinion = {
					target = root
					modifier = renewed_attention
				}
			}
		}

		hidden_effect = {
			remove_character_flag = is_in_intrigue_special_event
		}

		ai_chance = {
			base = 0
		}
	}

	#Get yourself some love! (ends chain)
	option = {
		trigger = { is_married = no }
		name = intrigue_temptation_special.1001.c
		add_intrigue_lifestyle_xp = miniscule_lifestyle_xp
		add_character_modifier = {
			modifier = intrigue_flirtatious_modifier
			years = 10
		}

		hidden_effect = {
			remove_character_flag = is_in_intrigue_special_event
		}

		ai_chance = {
			base = 0
		}
	}
}

#Observe for preference
intrigue_temptation_special.1002 = {
	type = character_event
	title = intrigue_temptation_special.1001.t
	desc = intrigue_temptation_special.1002.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:wants_love
		animation = worry
	}
	
	#Prefers personality?
	option = {
		name = intrigue_temptation_special.1002.a
		flavor = intrigue_temptation_special.1002.a.tt

		hidden_effect = {
			save_scope_value_as = {
				name = preference_check_flag
				value = flag:personality
			}
		}
	}

	#Prefers looks?
	option = {
		name = intrigue_temptation_special.1002.b
		flavor = intrigue_temptation_special.1002.b.tt

		hidden_effect = {
			save_scope_value_as = {
				name = preference_check_flag
				value = flag:sex_appeal
			}
		}
	}
	
	#Prefers power?
	option = {
		name = intrigue_temptation_special.1002.c
		flavor = intrigue_temptation_special.1002.c.tt

		hidden_effect = {
			save_scope_value_as = {
				name = preference_check_flag
				value = flag:power
			}
		}
	}

	after = {
		hidden_effect = {
			#Set outcome flag for investigating preference
			if = {
				limit = {
					exists = scope:preference_check_flag
					scope:preference_check_flag = scope:preference_flag
				}
				save_scope_value_as = {
					name = preference_check_outcome_flag
					value = flag:success
				}
			}
			else = {
				save_scope_value_as = {
					name = preference_check_outcome_flag
					value = flag:failure
				}
			}
		
			trigger_event = {
				id = intrigue_temptation_special.1003
				days = { 21 35 }
			}
		}
	}
}

#Outcome of investigation + matches
intrigue_temptation_special.1003 = {
	type = character_event
	title = intrigue_temptation_special.1001.t
	desc = {
		desc = intrigue_temptation_special.1003.start.desc
		first_valid = { #Preference investigation outcome
			triggered_desc = {
				trigger = {
					scope:preference_check_flag = flag:personality
					scope:preference_check_outcome_flag = flag:success
				}
				desc = intrigue_temptation_special.1003.personality_success.desc
			}
			triggered_desc = {
				trigger = {
					scope:preference_check_flag = flag:personality
					scope:preference_check_outcome_flag = flag:failure
				}
				desc = intrigue_temptation_special.1003.personality_failure.desc
			}
			triggered_desc = {
				trigger = {
					scope:preference_check_flag = flag:sex_appeal
					scope:preference_check_outcome_flag = flag:success
				}
				desc = intrigue_temptation_special.1003.sex_appeal_success.desc
			}
			triggered_desc = {
				trigger = {
					scope:preference_check_flag = flag:sex_appeal
					scope:preference_check_outcome_flag = flag:failure
				}
				desc = intrigue_temptation_special.1003.sex_appeal_failure.desc
			}
			triggered_desc = {
				trigger = {
					scope:preference_check_flag = flag:power
					scope:preference_check_outcome_flag = flag:success
				}
				desc = intrigue_temptation_special.1003.power_success.desc
			}
			triggered_desc = {
				trigger = {
					scope:preference_check_flag = flag:power
					scope:preference_check_outcome_flag = flag:failure
				}
				desc = intrigue_temptation_special.1003.power_failure.desc
			}
		}	
		desc = intrigue_temptation_special.1003.end.desc
	}
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:wants_love
		animation = worry
	}
	right_portrait = {
		character = scope:target_list_member_a
		animation = flirtation
	}
	lower_left_portrait = scope:target_list_member_b
	lower_right_portrait = scope:target_list_member_c
	
	immediate = {
		hidden_effect = {
			#Find one more characters (if possible) for the list
			random_in_list = {
				list = available_matches
				limit = {
					is_alive = yes #In case someone in the list died
					is_married = no
					intrigue_temptation_special_1001_good_match = yes
				}
				alternative_limit = {
					is_alive = yes #In case someone in the list died
					is_married = yes
					intrigue_temptation_special_1001_good_match = yes
				}
				add_to_list = potential_matches
			}
			#Assign each potential match an option
			save_target_list_as_separate_scopes_effect = { TARGET_LIST = potential_matches }
		}
	}

	#Pick the match
	option = {
		name = intrigue_temptation_special.1003.a
		flavor = intrigue_temptation_special.1003.tt
		custom_tooltip = intrigue_temptation_special.1003.a.tt
		scope:target_list_member_a = { save_scope_as = chosen_match }
	}

	option = {
		name = intrigue_temptation_special.1003.b
		flavor = intrigue_temptation_special.1003.tt
		custom_tooltip = intrigue_temptation_special.1003.b.tt
		scope:target_list_member_b = { save_scope_as = chosen_match }
	}
	
	option = {
		trigger = { exists = scope:target_list_member_c }
		name = intrigue_temptation_special.1003.c
		flavor = intrigue_temptation_special.1003.tt
		custom_tooltip = intrigue_temptation_special.1003.c.tt
		scope:target_list_member_c = { save_scope_as = chosen_match }
	}

	after = {
		hidden_effect = {
			if = {
				limit = { exists = scope:chosen_match } #To prevent errors before option is chosen

				#Evaluate the match
				random_list = {
					#Great
					1 = {
						modifier = {
							scope:chosen_match = { intrigue_temptation_special_1001_great_match = yes }
							factor = 100
						}
						save_scope_value_as = {
							name = match_status_flag
							value = flag:great
						}
					}
					#Good
					1 = {
						modifier = {
							scope:chosen_match = { intrigue_temptation_special_1001_good_match = yes }
							factor = 20
						}
						save_scope_value_as = {
							name = match_status_flag
							value = flag:good
						}
					}
					#Bad (if the match doesn't fulfill good trigger, 67% chance of bad)
					2 = {
						save_scope_value_as = {
							name = match_status_flag
							value = flag:bad
						}
					}
				}

				#If chosen_match's gender doesn't interest wants_love or vise versa, match always turn bad
				if = {
					limit = {
						OR = {
							NOT = { scope:chosen_match = { is_attracted_to_gender_of = scope:wants_love } }
							NOT = { scope:wants_love = { is_attracted_to_gender_of = scope:chosen_match } }
						}
					}
					trigger_event = {
						id = intrigue_temptation_special.1006
						days = { 5 10 }
					}
				}

				#But if it does, let's continue!
				else = {
					trigger_event = {
						id = intrigue_temptation_special.1004
						days = { 5 10 }
					}
				}
			}
		}
	}
}

#Dinner observance & picking the next activity
scripted_trigger intrigue_temptation_special_1004_great_outcome = {
	scope:activity_skill_flag = flag:$SKILL$
	scope:wants_love = { $SKILL$ >= decent_skill_rating }
	scope:chosen_match = { $SKILL$ >= decent_skill_rating }
}

scripted_trigger intrigue_temptation_special_1004_good_outcome = {
	scope:activity_skill_flag = flag:$SKILL$
	scope:wants_love = {
		OR = {
			$SKILL$ >= mediocre_skill_rating
			highest_skill = $SKILL$
		}
	}
	scope:chosen_match = {
		OR = {
			$SKILL$ >= mediocre_skill_rating
			highest_skill = $SKILL$
		}
	}
}

intrigue_temptation_special.1004 = {
	type = character_event
	title = intrigue_temptation_special.1001.t
	desc = {
		desc = intrigue_temptation_special.1004.start.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:match_status_flag = flag:great }
				desc = intrigue_temptation_special.1004.great.desc
			}
			triggered_desc = {
				trigger = { scope:match_status_flag = flag:good }
				desc = intrigue_temptation_special.1004.good.desc
			}
			triggered_desc = {
				trigger = { scope:match_status_flag = flag:bad }
				desc = intrigue_temptation_special.1004.bad.desc
			}
		}
		desc = intrigue_temptation_special.1004.end.desc
	}
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:wants_love
		animation = worry
	}
	right_portrait = {
		character = scope:chosen_match
		animation = personality_honorable
	}
	

	immediate = {
		hidden_effect = {
			#Making sure only 4 options show up, which one to exclude?
			random_list = {
				100 = {
					modifier = {
						OR = {
							scope:wants_love = { highest_skill = diplomacy }
							scope:chosen_match = { highest_skill = diplomacy }
						}
						factor = 0.01
					}
					modifier = {
						OR = {
							scope:wants_love = { diplomacy < mediocre_skill_rating }
							scope:chosen_match = { diplomacy < mediocre_skill_rating }
						}
						factor = 10
					}
					save_scope_value_as = {
						name = exclude_option_flag
						value = flag:diplomacy
					}
				}
				100 = {
					modifier = {
						OR = {
							scope:wants_love = { highest_skill = martial }
							scope:chosen_match = { highest_skill = martial }
						}
						factor = 0.01
					}
					modifier = {
						OR = {
							scope:wants_love = { martial < mediocre_skill_rating }
							scope:chosen_match = { martial < mediocre_skill_rating }
						}
						factor = 10
					}
					save_scope_value_as = {
						name = exclude_option_flag
						value = flag:martial
					}
				}
				100 = {
					modifier = {
						OR = {
							scope:wants_love = { highest_skill = stewardship }
							scope:chosen_match = { highest_skill = stewardship }
						}
						factor = 0.01
					}
					modifier = {
						OR = {
							scope:wants_love = { stewardship < mediocre_skill_rating }
							scope:chosen_match = { stewardship < mediocre_skill_rating }
						}
						factor = 10
					}
					save_scope_value_as = {
						name = exclude_option_flag
						value = flag:stewardship
					}
				}
				100 = {
					modifier = {
						OR = {
							scope:wants_love = { highest_skill = intrigue }
							scope:chosen_match = { highest_skill = intrigue }
						}
						factor = 0.01
					}
					modifier = {
						OR = {
							scope:wants_love = { intrigue < mediocre_skill_rating }
							scope:chosen_match = { intrigue < mediocre_skill_rating }
						}
						factor = 10
					}
					save_scope_value_as = {
						name = exclude_option_flag
						value = flag:intrigue
					}
				}
				100 = {
					modifier = {
						OR = {
							scope:wants_love = { highest_skill = learning }
							scope:chosen_match = { highest_skill = learning }
						}
						factor = 0.01
					}
					modifier = {
						OR = {
							scope:wants_love = { learning < mediocre_skill_rating }
							scope:chosen_match = { learning < mediocre_skill_rating }
						}
						factor = 10
					}
					save_scope_value_as = {
						name = exclude_option_flag
						value = flag:learning
					}
				}
			}
		}
	}

	#Pick an activity

	#Dance
	option = {
		trigger = { NOT = { scope:exclude_option_flag = flag:diplomacy } }
		name = intrigue_temptation_special.1004.a
		flavor = intrigue_temptation_special.1004.tt
		save_scope_value_as = {
			name = activity_skill_flag
			value = flag:diplomacy
		}
	}

	#Hunt
	option = {
		trigger = { NOT = { scope:exclude_option_flag = flag:martial } }
		name = intrigue_temptation_special.1004.b
		flavor = intrigue_temptation_special.1004.tt
		save_scope_value_as = {
			name = activity_skill_flag
			value = flag:martial
		}
	}
	
	#Ride and inspect lands
	option = {
		trigger = { NOT = { scope:exclude_option_flag = flag:stewardship } }
		name = intrigue_temptation_special.1004.c
		flavor = intrigue_temptation_special.1004.tt
		save_scope_value_as = {
			name = activity_skill_flag
			value = flag:stewardship
		}
	}

	#Private gathering, share secrets
	option = {
		trigger = { NOT = { scope:exclude_option_flag = flag:intrigue } }
		name = intrigue_temptation_special.1004.d
		flavor = intrigue_temptation_special.1004.tt
		save_scope_value_as = {
			name = activity_skill_flag
			value = flag:intrigue
		}
	}

	#Poetry reading
	option = {
		trigger = { NOT = { scope:exclude_option_flag = flag:learning } }
		name = intrigue_temptation_special.1004.e
		flavor = intrigue_temptation_special.1004.tt
		save_scope_value_as = {
			name = activity_skill_flag
			value = flag:learning
		}
	}

	after = {
		if = {
			limit = { exists = scope:activity_skill_flag }

			#Evaluate outcome of activity
			hidden_effect = {
				#It went great!
				if = {
					limit = {
						OR = {
							intrigue_temptation_special_1004_great_outcome = { SKILL = diplomacy }
							intrigue_temptation_special_1004_great_outcome = { SKILL = martial }
							intrigue_temptation_special_1004_great_outcome = { SKILL = stewardship }
							intrigue_temptation_special_1004_great_outcome = { SKILL = intrigue }
							intrigue_temptation_special_1004_great_outcome = { SKILL = learning }
						}
					}

					save_scope_value_as = {
						name = activity_outcome_flag
						value = flag:great
					}

					if = { #A good match becomes great
						limit = { scope:match_status_flag = flag:good }
						save_scope_value_as = {
							name = match_status_flag
							value = flag:great
						}
					}
					if = { #A bad match becomes good
						limit = { scope:match_status_flag = flag:bad }
						save_scope_value_as = {
							name = match_status_flag
							value = flag:good
						}
					}
				}
				#It went good!
				else_if = {
					limit = {
						OR = {
							intrigue_temptation_special_1004_good_outcome = { SKILL = diplomacy }
							intrigue_temptation_special_1004_good_outcome = { SKILL = martial }
							intrigue_temptation_special_1004_good_outcome = { SKILL = stewardship }
							intrigue_temptation_special_1004_good_outcome = { SKILL = intrigue }
							intrigue_temptation_special_1004_good_outcome = { SKILL = learning }
						}
					}

					save_scope_value_as = {
						name = activity_outcome_flag
						value = flag:good
					}

					if = { #A bad match becomes good
						limit = { scope:match_status_flag = flag:bad }
						save_scope_value_as = {
							name = match_status_flag
							value = flag:good
						}
					}
				}
				#It went bad...
				else = {
					save_scope_value_as = {
						name = activity_outcome_flag
						value = flag:bad
					}

					if = { #A great match becomes good
						limit = { scope:match_status_flag = flag:great }
						save_scope_value_as = {
							name = match_status_flag
							value = flag:good
						}
					}
					else = { #Otherwise, it's bad
						save_scope_value_as = {
						name = match_status_flag
						value = flag:bad
						}
					}
				}

				trigger_event = {
					id = intrigue_temptation_special.1005
					days = { 10 20 }
				}
			}
		}
	}
}

#The outcome of the activity & your final result
intrigue_temptation_special.1005 = {
	type = character_event
	title = intrigue_temptation_special.1001.t
	desc = {
		#How did the activity go?
		first_valid = {
			#Great outcomes
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:diplomacy
					scope:activity_outcome_flag = flag:great
				}
				desc = intrigue_temptation_special.1005.great_diplomacy.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:martial
					scope:activity_outcome_flag = flag:great
				}
				desc = intrigue_temptation_special.1005.great_martial.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:stewardship
					scope:activity_outcome_flag = flag:great
				}
				desc = intrigue_temptation_special.1005.great_stewardship.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:intrigue
					scope:activity_outcome_flag = flag:great
				}
				desc = intrigue_temptation_special.1005.great_intrigue.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:learning
					scope:activity_outcome_flag = flag:great
				}
				desc = intrigue_temptation_special.1005.great_learning.desc
			}
			#Good outcome
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:diplomacy
					scope:activity_outcome_flag = flag:good
				}
				desc = intrigue_temptation_special.1005.good_diplomacy.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:martial
					scope:activity_outcome_flag = flag:good
				}
				desc = intrigue_temptation_special.1005.good_martial.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:stewardship
					scope:activity_outcome_flag = flag:good
				}
				desc = intrigue_temptation_special.1005.good_stewardship.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:intrigue
					scope:activity_outcome_flag = flag:good
				}
				desc = intrigue_temptation_special.1005.good_intrigue.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:learning
					scope:activity_outcome_flag = flag:good
				}
				desc = intrigue_temptation_special.1005.good_learning.desc
			}
			#Bad outcome...
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:diplomacy
					scope:activity_outcome_flag = flag:bad
				}
				desc = intrigue_temptation_special.1005.bad_diplomacy.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:martial
					scope:activity_outcome_flag = flag:bad
				}
				desc = intrigue_temptation_special.1005.bad_martial.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:stewardship
					scope:activity_outcome_flag = flag:bad
				}
				desc = intrigue_temptation_special.1005.bad_stewardship.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:intrigue
					scope:activity_outcome_flag = flag:bad
				}
				desc = intrigue_temptation_special.1005.bad_intrigue.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_skill_flag = flag:learning
					scope:activity_outcome_flag = flag:bad
				}
				desc = intrigue_temptation_special.1005.bad_learning.desc
			}
		}
		#If bad, who struggled?
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:activity_outcome_flag = flag:bad
					OR = {
						AND = {
							scope:activity_skill_flag = flag:diplomacy
							scope:wants_love = { diplomacy < mediocre_skill_rating }
						}
						AND = {
							scope:activity_skill_flag = flag:martial
							scope:wants_love = { martial < mediocre_skill_rating }
						}
						AND = {
							scope:activity_skill_flag = flag:stewardship
							scope:wants_love = { stewardship < mediocre_skill_rating }
						}
						AND = {
							scope:activity_skill_flag = flag:intrigue
							scope:wants_love = { intrigue < mediocre_skill_rating }
						}
						AND = {
							scope:activity_skill_flag = flag:learning
							scope:wants_love = { learning < mediocre_skill_rating }
						}
					}
				}
				desc = intrigue_temptation_special.1005.wants_love_struggled.desc
			}
			triggered_desc = {
				trigger = {
					scope:activity_outcome_flag = flag:bad
					OR = {
						AND = {
							scope:activity_skill_flag = flag:diplomacy
							scope:chosen_match = { diplomacy < mediocre_skill_rating }
						}
						AND = {
							scope:activity_skill_flag = flag:martial
							scope:chosen_match = { martial < mediocre_skill_rating }
						}
						AND = {
							scope:activity_skill_flag = flag:stewardship
							scope:chosen_match = { stewardship < mediocre_skill_rating }
						}
						AND = {
							scope:activity_skill_flag = flag:intrigue
							scope:chosen_match = { intrigue < mediocre_skill_rating }
						}
						AND = {
							scope:activity_skill_flag = flag:learning
							scope:chosen_match = { learning < mediocre_skill_rating }
						}
					}
				}
				desc = intrigue_temptation_special.1005.chosen_match_struggled.desc
			}
		}
		#How are they getting along now?
		first_valid = {
			triggered_desc = {
				trigger = { scope:match_status_flag = flag:great }
				desc = intrigue_temptation_special.1005.great_status.desc
			}
			triggered_desc = {
				trigger = {
					scope:match_status_flag = flag:good
					scope:activity_outcome_flag = flag:bad
				}
				desc = intrigue_temptation_special.1005.good_status_despite_bad_activity.desc
			}
			triggered_desc = {
				trigger = { scope:match_status_flag = flag:good }
				desc = intrigue_temptation_special.1005.good_status.desc
			}
			triggered_desc = {
				trigger = { scope:match_status_flag = flag:bad }
				desc = intrigue_temptation_special.1005.bad_status.desc
			}
		}
	}
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:wants_love
		animation = personality_honorable
	}
	right_portrait = {
		character = scope:chosen_match
		animation = personality_compassionate
	}

	trigger = {
		scope:wants_love = { is_alive = yes }
		scope:chosen_match = { is_alive = yes }
	}

	on_trigger_fail = {
		remove_character_flag = is_in_intrigue_special_event
	}

	#great outcome!
	option = {
		trigger = { scope:match_status_flag = flag:great }
		name = intrigue_temptation_special.1005.a
		add_character_modifier = {
			modifier = intrigue_understands_desires_modifier
			years = 10
		}

		reverse_add_opinion = {
			target = scope:wants_love
			modifier = grateful_opinion
			opinion = 20
		}
		reverse_add_opinion = {
			target = scope:chosen_match
			modifier = grateful_opinion
			opinion = 20
		}
		add_intrigue_lifestyle_perk_points = 1

		#Opinions & follow-up
		hidden_effect = {
			scope:wants_love = {
				progress_towards_lover_effect = {
					CHARACTER = scope:chosen_match
					OPINION = 50
				}
			}

			#If triggers are passed, they become lovers
			trigger_event = {
				id = intrigue_temptation_special.1007
				days = { 365 1825 }
			}
		}
	}

	#good outcome
	option = {
		trigger = { scope:match_status_flag = flag:good }
		name = intrigue_temptation_special.1005.b
		add_intrigue_lifestyle_perk_points = 1

		add_character_modifier = {
			modifier = intrigue_understands_people_modifier
			years = 10
		}

		reverse_add_opinion = {
			target = scope:chosen_match
			modifier = grateful_opinion
			opinion = 10
		}

		add_intrigue_lifestyle_xp = major_lifestyle_xp
		hidden_effect = {
			scope:wants_love = {
				progress_towards_lover_effect = {
					CHARACTER = scope:chosen_match
					OPINION = 25
				}
			}

			#If triggers are passed, they become lovers
			trigger_event = {
				id = intrigue_temptation_special.1007
				days = { 365 1825 }
			}
		}
	}
	
	#bad outcome...
	option = {
		trigger = { scope:match_status_flag = flag:bad }
		name = intrigue_temptation_special.1005.c
		add_intrigue_lifestyle_xp = minor_lifestyle_xp
		add_character_modifier = {
			modifier = intrigue_studying_people_modifier
			years = 10
		}
	}

	after = {
		hidden_effect = {
			remove_character_flag = is_in_intrigue_special_event
		}
	}
}


#You picked someone of a gender not interesting to wants_love, fail
intrigue_temptation_special.1006 = {
	type = character_event
	title = intrigue_temptation_special.1001.t
	desc = intrigue_temptation_special.1006.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:wants_love
		animation = disapproval
	}
	right_portrait = {
		character = scope:chosen_match
		animation = sadness
	}

	immediate = {
		#For desc
		if = { #Wants love is not interested
			limit = { scope:wants_love = { NOT = { is_attracted_to_gender_of = scope:chosen_match } } }

			scope:wants_love = {
				save_scope_as = not_interested
				if = {
					limit = { is_attracted_to_women = yes }
					dummy_female = { save_scope_as = interesting_ladylord }
				}
				else = {
					dummy_male = { save_scope_as = interesting_ladylord }
				}
			}
		}
		else = {
			scope:chosen_match = {
				save_scope_as = not_interested
				if = {
					limit = { is_attracted_to_women = yes }
					dummy_female = { save_scope_as = interesting_ladylord }
				}
				else = {
					dummy_male = { save_scope_as = interesting_ladylord }
				}
			}
		}
	}

	option = {
		name = intrigue_temptation_special.1006.a
		add_character_modifier = {
			modifier = intrigue_studying_people_modifier
			years = 5
		}
	}
}

#Follow-up later
intrigue_temptation_special.1007 = {
	type = character_event
	title = intrigue_temptation_special.1001.t
	desc = intrigue_temptation_special.1007.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:wants_love
		animation = love
	}
	right_portrait = {
		character = scope:chosen_match
		animation = flirtation
	}
	
	trigger = {
		scope:wants_love = {
			opinion = {
				target = scope:chosen_match
				value >= 40
			}
			is_ai = yes
		}
		scope:chosen_match = {
			opinion = {
				target = scope:wants_love
				value >= 40
			}
			is_ai = yes
		}
	}

	immediate = {
		scope:wants_love = {
			if = {
				limit = {
					can_set_relation_lover_trigger = { CHARACTER = scope:chosen_match }
				}
			}
			set_relation_lover = scope:chosen_match
		}
	}

	option = {
		name = intrigue_temptation_special.1007.a
		add_intrigue_lifestyle_xp = massive_lifestyle_xp
		scope:wants_love = {
			if = {
				limit = {
					any_secret = {
						exists = secret_target
						secret_target = scope:chosen_match
						secret_type = secret_lover		
					}
				}
				random_secret = {
					limit = {
						exists = secret_target
						secret_target = scope:chosen_match
						secret_type = secret_lover
					}
					reveal_to = root
				}
			}
		}

		add_character_modifier = {
			modifier = intrigue_flirtatious_modifier
			years = 5
		}

		hidden_effect = {
			remove_character_flag = is_in_intrigue_special_event
		}
	}
}

