namespace = intrigue_temptation

##################################################

#Intrigue Temptation Lifestyle events

	# 3100		- A courtier propositions you via a lewd image.
	# 3110		- While drinking with a courtier, you lead them towards deviancy.
	# 3120		- You enjoy a dinner with one of your guests, and try to tempt them into staying.
	# 3130		- You seduce the spouse of a potential rival to cement the foeship.
	# 3140		- Flirt openly with courtiers, pleasing some and irritating others.
	# 3150		- Caught chatting up a courtier, you back out, carry on, or double-down.
	# 3160		- Sleep with someone who dislikes you for fun or profit.

##################################################

##################################################
# An Unusual Proposition
# by Ewan Cowhig Croft
# 3100
##################################################

scripted_trigger intrigue_temptation_3100_potential_image_giver = {	#Pick a person who might actually think sending a lewd image is a good idea.
	is_available_ai_adult = yes
	is_attracted_to_gender_of = root
	mgr_can_seduce = yes
	OR = {
		has_trait = lustful
		has_trait = ambitious
		has_trait = arbitrary
	}
	accepts_incest_with_trigger = { CHARACTER = root } #No incest or 100% ok with incest
	NOR = {
		has_relation_lover = root
		is_consort_of = root
		has_trait = celibate
	}
}

scripted_trigger intrigue_temptation_3100_third_party_secret = {	#Grab a suitable rando for secret generation.
	is_ai = yes
	NOT = { this = scope:propositioning_courtier }
}

#	A courtier propositions you via a lewd image.
#		by Ewan Cowhig Croft
intrigue_temptation.3100 = {
	type = character_event
	title = {	#Title changes depending on the type of image given.
		first_valid = {
			triggered_desc = {
				trigger = { scope:letter_type = flag:cloth }
				desc = intrigue_temptation.3100.cloth_t
			}
			triggered_desc = {
				trigger = { scope:letter_type = flag:stone }
				desc = intrigue_temptation.3100.stone_t
			}
			triggered_desc = {
				trigger = { scope:letter_type = flag:wax }
				desc = intrigue_temptation.3100.wax_t
			}
			triggered_desc = {
				trigger = { scope:letter_type = flag:wood }
				desc = intrigue_temptation.3100.wood_t
			}
			triggered_desc = {
				trigger = { scope:letter_type = flag:vellum }
				desc = intrigue_temptation.3100.vellum_t
			}
		}
	}
	desc = {	#Desc changes depending on the type of image given.
		desc = intrigue_temptation.3100.start_desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:letter_type = flag:cloth }
				desc = intrigue_temptation.3100.cloth_desc
			}
			triggered_desc = {
				trigger = { scope:letter_type = flag:stone }
				desc = intrigue_temptation.3100.stone_desc
			}
			triggered_desc = {
				trigger = { scope:letter_type = flag:wax }
				desc = intrigue_temptation.3100.wax_desc
			}
			triggered_desc = {
				trigger = { scope:letter_type = flag:wood }
				desc = intrigue_temptation.3100.wood_desc
			}
			triggered_desc = {
				trigger = { scope:letter_type = flag:vellum }
				desc = intrigue_temptation.3100.vellum_desc
			}
		}
		desc = intrigue_temptation.3100.end_desc
	}
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:propositioning_courtier
		animation = flirtation
	}
	override_background = { event_background = feast }

	trigger = {
		is_adult = yes
		is_at_war = no
		eligible_for_affairs_trigger = yes
		NOT = { has_character_flag = had_event_intrigue_temptation_3100 }
		any_courtier_or_guest = { intrigue_temptation_3100_potential_image_giver = yes }
	}

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

	immediate = {
		add_character_flag = {
			flag = had_event_intrigue_temptation_3100
			days = 1825
		}
		save_scope_as = propositioned_character
		random_list = {	#Various different images can be given, each with a suitable depiction of the sender.
			1 = {	#Receive an embroidered cloth.
				save_scope_value_as = {
					name = letter_type
					value = flag:cloth
				}
			}
			1 = {	#Receive a poorly-etched stone slab.
				save_scope_value_as = {
					name = letter_type
					value = flag:stone
				}
			}
			1 = {	#Receive a crude wax pictogram.
				save_scope_value_as = {
					name = letter_type
					value = flag:wax
				}
			}
			1 = {	#Receive a carved wooden tablet.
				save_scope_value_as = {
					name = letter_type
					value = flag:wood
				}
			}
			1 = {	#Receive a blotchy vellum doodle.
				save_scope_value_as = {
					name = letter_type
					value = flag:vellum
				}
			}
		}
		random_courtier_or_guest = {	#Select a suitable non-entity for this.
			limit = { intrigue_temptation_3100_potential_image_giver = yes }
			weight = {
				base = 1
				modifier = {	#Characters who are attracted to you are more likely to try it on.
					add = 15
					attraction >= medium_positive_attraction
				}
				modifier = {	#Characters who are very attracted to you are even more likely to try it on.
					add = 15
					attraction >= high_positive_attraction
				}
				modifier = {	#Quite high intrigue characters fancy their chances a bit more.
					add = 10
					intrigue >= very_high_skill_rating
				}
				modifier = {	#Quite low intrigue characters also fancy their chances, but for different reasons.
					add = 10
					intrigue <= low_skill_rating
				}
				modifier = {	#Landless characters with a claim are interesting candidates.
					add = 20
					is_ruler = no
					is_claimant = yes
				}
				modifier = {	#Characters with high stats are interesting candidates.
					add = 5
					diplomacy >= high_skill_rating
				}
				modifier = {	#Characters with high stats are interesting candidates.
					add = 5
					martial >= high_skill_rating
				}
				modifier = {	#Characters with high stats are interesting candidates.
					add = 5
					stewardship >= high_skill_rating
				}
				modifier = {	#Characters with high stats are interesting candidates.
					add = 5
					learning >= high_skill_rating
				}
				modifier = {	#Characters with more than the minimum number of required traits are also better candidates.
					add = 10
					calc_true_if = {
						amount >= 2
						has_trait = lustful
						has_trait = ambitious
						has_trait = arbitrary
					}
				}
			}
			save_scope_as = propositioning_courtier
		}
	}

	option = {	#Turn down the sender.
		name = intrigue_temptation.3100.a
		if = {
			limit = {
				root.faith = { trait_is_sin = lustful }
			}
			add_piety = minor_piety_gain
		}
		else_if = {
			limit = {
				root.faith = { trait_is_virtue = lustful }
			}
			add_piety = medium_piety_loss
		}
		else = { add_prestige = miniscule_prestige_gain }
		scope:propositioning_courtier = {
			add_opinion = {
				modifier = insulted_opinion
				opinion = -10
				target = root
			}
		}
		custom_tooltip = intrigue_temptation.3100.a.tt
		hidden_effect = {	#Chaste characters in your court respect your dignity.
			every_courtier_or_guest = {
				limit = { has_trait = chaste }
				add_opinion = {
					modifier = respect_opinion
					opinion = 10
					target = root
				}
			}
		}
		stress_impact = { lustful = minor_stress_impact_gain }
		ai_chance = {
			base = 50
			modifier = {
				add = 20
				has_trait = chaste
			}
			modifier = {
				add = -20
				has_trait = lustful
			}
		}
	}
	option = {	#Give them a tumble to try for a secret.
		name = intrigue_temptation.3100.b
		trigger = {
			NOT = { has_relation_potential_lover = scope:propositioning_courtier }
		}
		if = {
			limit = {
				root.faith = { trait_is_sin = lustful }
			}
			add_piety = medium_piety_loss
		}
		else_if = {
			limit = {
				root.faith = { trait_is_virtue = lustful }
			}
			add_piety = minor_piety_gain
		}
		progress_towards_lover_effect = {
			CHARACTER = scope:propositioning_courtier
			OPINION = no
		}
		every_courtier = {		#Take every courtier, and whack 'em in a big list, excepting the seducer & any player-controlled characters.
			limit = { intrigue_temptation_3100_third_party_secret = yes }
			add_to_list = generate_secret_list
		}
		every_vassal = {		#Now add the vassals to that list.
			limit = { intrigue_temptation_3100_third_party_secret = yes }
			add_to_list = generate_secret_list
		}
		random_in_list = {
			list = generate_secret_list
			limit = {
				save_temporary_scope_as = temp_third_party_secret_holder
				any_secret = {
					is_blackmailable_secret_trigger = {
						PARTICIPANT = scope:temp_third_party_secret_holder
						BLACKMAILER = root
					}
					NOT = { is_known_by = root }
				}
			}
			alternative_limit = {
				any_secret = {
					NOT = { is_known_by = root }
				}
			}
			weight = {
				base = 1
				modifier = {	#Powerful vassals are good targets.
					add = 10
					is_powerful_vassal = yes
				}
				modifier = {	#Courtiers with claims are interesting targets.
					add = 10
					is_claimant = yes
					is_ruler = no
				}
				modifier = {	#Councillors are always good targets.
					add = 10
					OR = {
						has_council_position = councillor_chancellor
						has_council_position = councillor_marshal
						has_council_position = councillor_steward
						has_council_position = councillor_spymaster
						has_council_position = councillor_court_chaplain
					}
				}
				modifier = {	#Highly-skilled characters are acceptable targets.
					add = 5
					OR = {
						diplomacy >= high_skill_rating
						martial >= high_skill_rating
						stewardship >= high_skill_rating
						intrigue >= high_skill_rating
						learning >= high_skill_rating
					}
				}
				modifier = {	#Rivals are incredibly satisfying targets.
					add = 15
					has_relation_rival = root
				}
			}
			save_scope_as = third_party_secret_holder
		}
		had_sex_with_effect = {
			CHARACTER = scope:propositioning_courtier
			PREGNANCY_CHANCE = pregnancy_chance
		}
		custom_tooltip = intrigue_temptation.3100.b.tt
		hidden_effect = {
			if = {	#If there's a secret available, you are informed.
				limit = { exists = scope:third_party_secret_holder }
				send_interface_toast = {
					title = intrigue_temptation.3100.b.tt.secret_gained
					left_icon = scope:third_party_secret_holder
					scope:third_party_secret_holder = {
						random_secret = {
							limit = {
								is_blackmailable_secret_trigger = {
									PARTICIPANT = scope:third_party_secret_holder
									BLACKMAILER = root
								}
								NOT = { is_known_by = root }
							}
							alternative_limit = {
								NOT = { is_known_by = root }
							}
							reveal_to = root
						}
					}
				}
			}
			else = {	#If there is no secret available, you get some lifestyle XP.
				send_interface_toast = {
					title = intrigue_temptation.3100.b.tt.xp_gained
					left_icon = root
					add_intrigue_lifestyle_xp = medium_lifestyle_xp
				}
			 }
		}
		stress_impact = { chaste = minor_stress_impact_gain }
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				has_trait = lustful
			}
			modifier = {
				add = 20
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
			modifier = {
				add = -15
				has_trait = chaste
			}
		}
	}
	option = {	#Inexplicably, you find the image charming, and jump straight into a relationship. Apparently.
		name = {
			trigger = { scope:letter_type = flag:cloth }
			text = intrigue_temptation.3100.cloth_c
		}
		name = {
			trigger = { scope:letter_type = flag:stone }
			text = intrigue_temptation.3100.stone_c
		}
		name = {
			trigger = { scope:letter_type = flag:wax }
			text = intrigue_temptation.3100.wax_c
		}
		name = {
			trigger = { scope:letter_type = flag:wood }
			text = intrigue_temptation.3100.wood_c
		}
		name = {
			trigger = { scope:letter_type = flag:vellum }
			text = intrigue_temptation.3100.vellum_c
		}
		if = {
			limit = {
				root.faith = { trait_is_sin = lustful }
			}
			add_piety = medium_piety_loss
		}
		else_if = {
			limit = {
				root.faith = { trait_is_virtue = lustful }
			}
			add_piety = medium_piety_gain
		}
		had_sex_with_effect = {
			CHARACTER = scope:propositioning_courtier
			PREGNANCY_CHANCE = pregnancy_chance
		}
		set_relation_lover = scope:propositioning_courtier
		if = {
			limit = { intrigue <= 7 }
			add_intrigue_skill = 1
		}
		stress_impact = {
			chaste = medium_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 10
				has_trait = lustful
			}
			modifier = {
				add = -30
				has_trait = chaste
			}
		}
	}
	option = {	#Show the image around the party.
		name = intrigue_temptation.3100.d
		scope:propositioning_courtier = {
			add_opinion = {
				target = root
				modifier = humiliated_opinion
				opinion = -40
			}
		}
		add_character_modifier = {
			modifier = public_shamer_modifier
			days = 1095
		}
		if = {
			limit = {
				NOT = { has_trait = compassionate }
			}
			add_stress = major_stress_loss
		}
		stress_impact = { compassionate = medium_stress_impact_gain }
		ai_chance = {
			base = 50
			modifier = {
				add = 15
				has_trait = callous
			}
			modifier = {
				add = 40
				has_trait = sadistic
			}
		}
	}
}

##################################################
# A Little Experimenting
# by Ewan Cowhig Croft
# 3110
##################################################

scripted_trigger intrigue_temptation_3110_potential_deviants = {	#Grab someone interesting to potentially introduce to the pleasures of deviancy.
	is_available_ai_adult = yes
	NOT = { has_trait = deviant }
	OR = {
		is_powerful_vassal = yes
		is_councillor_of = root
		AND = {
			is_ruler = no
			is_claimant = yes
		}
	}
	NOR = {
		has_relation_rival = root
		any_secret = { secret_type = secret_deviant }
		AND = {	#Zealous Muslims would never get to this point.
			has_religion = religion:islam_religion
			has_trait = zealous
		}
		has_trait = celibate
	}
	opinion = {
		target = root
		value >= 20
	}
}

#	While drinking with a courtier, you lead them towards deviancy.
#		by Ewan Cowhig Croft
intrigue_temptation.3110 = {
	type = character_event
	title = intrigue_temptation.3110.t
	desc = {
		desc = intrigue_temptation.3110.start_desc
		first_valid = {	#You have many obscene story types to tell.
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:0 }
				desc = intrigue_temptation.3110.0_desc
			}
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:1 }
				desc = intrigue_temptation.3110.1_desc
			}
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:2 }
				desc = intrigue_temptation.3110.2_desc
			}
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:3 }
				desc = intrigue_temptation.3110.3_desc
			}
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:4 }
				desc = intrigue_temptation.3110.4_desc
			}
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:5 }
				desc = intrigue_temptation.3110.5_desc
			}
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:6 }
				desc = intrigue_temptation.3110.6_desc
			}
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:7 }
				desc = intrigue_temptation.3110.7_desc
			}
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:8 }
				desc = intrigue_temptation.3110.8_desc
			}
			triggered_desc = {
				trigger = { scope:deviancy_type = flag:9 }
				desc = intrigue_temptation.3110.9_desc
			}
		}
		desc = intrigue_temptation.3110.end_desc
	}
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:potential_deviant
		animation = personality_irrational
	}

	trigger = {
		is_adult = yes
		is_at_war = no
		NOT = { has_character_flag = had_event_intrigue_temptation_3110 }
		NOR = {
			AND = {	#Zealous Muslims would never get to this point.
				has_religion = religion:islam_religion
				has_trait = zealous
			}
			has_trait = chaste
			has_trait = celibate
		}
		OR = {
			any_vassal = { intrigue_temptation_3110_potential_deviants = yes }	#Vassals are great candidates for this.
			any_courtier_or_guest = { intrigue_temptation_3110_potential_deviants = yes }	#Courtiers & guests are acceptable candidates.
		}
	}

	weight_multiplier = {
		base = 1
		upweight_for_focus_modifier = { FOCUS = intrigue_temptation_focus }
		modifier = {	#Shy characters are unlikely to go out with people.
			add = -0.5
			has_trait = shy
		}
	}

	immediate = {
		add_character_flag = {
			flag = had_event_intrigue_temptation_3110
			days = 1825
		}
		every_vassal = {
			limit = { intrigue_temptation_3110_potential_deviants = yes }
			add_to_list = potential_deviants_list
		}
		every_courtier_or_guest = {
			limit = { intrigue_temptation_3110_potential_deviants = yes }
			add_to_list = potential_deviants_list
		}
		random_in_list = {
			list = potential_deviants_list
			limit = {	#Take existing temptation-friends!
				lifestyle_friend_trigger = {
					CHARACTER = root
					FOCUS = intrigue_temptation_focus
				}
			}
			alternative_limit = {	#Otherwise, take good potential temptation friends!
				intrigue_temptation_focus_friend_points <= 60
			}
			alternative_limit = {	#Otherwise, take good potential temptation friends!
				intrigue_temptation_focus_friend_points <= 40
			}
			alternative_limit = {	#Otherwise, take good potential temptation friends!
				intrigue_temptation_focus_friend_points <= 20
			}
			alternative_limit = {	#Otherwise, take good potential temptation friends!
				intrigue_temptation_focus_friend_points <= 0
			}
			alternative_limit = { always = yes } #Or else just whoever.
			weight = {
				base = 30
				modifier = {	#Powerful vassals are good candidates.
					add = 10
					is_powerful_vassal = yes
				}
				modifier = {	#Councillors are good candidates.
					add = 10
					is_councillor_of = root
				}
				modifier = {	#Landless claimants are good candidates; slightly boosted to make up for powerful vassals typically being councillors.
					add = 15
					is_ruler = no
					is_claimant = yes
				}
				modifier = {	#Lustful characters are more likely to take the conversation this way.
					add = 10
					has_trait = lustful
				}
				modifier = {	#Chaste characters naturally avoid these conversions.
					add = -50
					has_trait = chaste
				}
				modifier = {	#Party animals are more likely to get this drunk.
					add = 10
					OR = {
						has_trait = drunkard
						has_trait = reveler_1
						has_trait = reveler_2
						has_trait = reveler_3
					}
				}
			}
			save_scope_as = potential_deviant
			random_list = {	#Pick a random deviancy story from the list.
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:0
					}
				}
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:1
					}
				}
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:2
					}
				}
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:3
					}
				}
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:4
					}
				}
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:5
					}
				}
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:6
					}
				}
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:7
					}
				}
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:8
					}
				}
				1 = {
					save_scope_value_as = {
						name = deviancy_type
						value = flag:9
					}
				}
			}
		}
	}

	option = {	#Encourage their deviancy.
		name = intrigue_temptation.3110.a
		duel = {
			skill = intrigue
			target = scope:potential_deviant
			50 = {	#The character acquires a fetish, and you retain knowledge of it.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = intrigue_temptation.3110.a.tt_success
				send_interface_toast = {
					title = intrigue_temptation.3110.a.tt_success
					left_icon = scope:potential_deviant
					scope:potential_deviant = {
						give_deviant_secret_or_trait_effect = yes
						every_secret = {
							limit = { secret_type = secret_deviant }
							reveal_to = root
						}
					}
					if = {
						limit = {
							NOT = {
								lifestyle_friend_trigger = {
									CHARACTER = root
									FOCUS = intrigue_temptation_focus
								}
							}
							potential_lifestyle_friend_availability_trigger = {
								FOCUS = intrigue_temptation_focus
								CHARACTER = root
							}
						}
						potential_lifestyle_friend_saving_effect = {
							FOCUS = intrigue_temptation_focus
							SCOPE_NAME = root_friend
						}
					}
				}
			}
			50 = {	#The character finds you to be intensely uncomfortable company.
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = intrigue_temptation.3110.a.tt_fail
				send_interface_toast = {	
					title = intrigue_temptation.3110.a.tt_fail
					left_icon = scope:potential_deviant
					scope:potential_deviant = {
						add_opinion = {
							modifier = disgusted_opinion
							opinion = -15
							target = root
						}
					}
				}
			}
		}
		stress_impact = {
			chaste = minor_stress_impact_gain
			honest = minor_stress_impact_gain
		}
		ai_chance = {
			base = 60
			ai_value_modifier = {
				ai_boldness = 0.5
				ai_honor = -0.5
			}
			modifier = {
				add = 15
				has_trait = deceitful
			}
		}
	}
	option = {	#Keep chatting about other things.
		name = intrigue_temptation.3110.b
		progress_towards_friend_effect = {
			CHARACTER = scope:potential_deviant
			OPINION = 10
		}
		stress_impact = {
			shy = minor_stress_impact_gain
			deceitful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 40
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.25
			}
			modifier = {
				add = -30
				has_trait = chaste
			}
		}
	}
}

##################################################
# Wandering Hearts
# by Ewan Cowhig Croft
# 3120
##################################################

scripted_trigger intrigue_temptation_3120_temptable_guests = {	#Nab guests who are both valid partners & interesting characters.
	is_available_ai_adult = yes
	is_attracted_to_gender_of = root
	save_temporary_scope_as = guest
	root = { is_attracted_to_gender_of = scope:guest }
	accepts_incest_with_trigger = { CHARACTER = root } #No incest or 100% ok with incest
	NOR = {
		has_relation_rival = root
		has_relation_lover = root
		is_consort_of = root
		has_trait = celibate
	}
	OR = {
		any_claim = {	#Claimants are usually great.
			useful_courtier_or_guest_claim_trigger = { RULER = root }
		}
		AND = {	#People from famous dynasties can be fun to collect.
			exists = dynasty
			dynasty = { dynasty_prestige_level >= 4 }
		}
		OR = {	#Otherwise, anyone with a respectable skill rating might make a fun companion.
			AND = {
				can_be_chancellor_trigger = { COURT_OWNER = root }
				diplomacy >= high_skill_rating
			}
			AND = {
				can_be_marshal_trigger = { COURT_OWNER = root }
				martial >= high_skill_rating
			}
			AND = {
				can_be_steward_trigger = { COURT_OWNER = root }
				stewardship >= high_skill_rating
			}
			AND = {
				can_be_spymaster_trigger = { COURT_OWNER = root }
				intrigue >= high_skill_rating
			}
			AND = {
				guest_physician_candidate_trigger = yes
				learning >= high_skill_rating
			}
			AND = {
				guest_knight_candidate_trigger = { HOST = root }
				prowess >= high_skill_rating
			}
		}
	}
}

#	You enjoy a dinner with one of your guests, and try to tempt them into staying.
#		by Ewan Cowhig Croft
intrigue_temptation.3120 = {
	type = character_event
	title = intrigue_temptation.3120.t
	desc = intrigue_temptation.3120.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:tempted_guest
		animation = flirtation
	}

	trigger = {
		mgr_can_seduce = yes
		NOT = { has_character_flag = had_event_intrigue_temptation_3120 }
		NOT = { has_trait = celibate }
		any_pool_guest = { intrigue_temptation_3120_temptable_guests = yes }

	}

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

	immediate = {
		add_character_flag = {
			flag = had_event_intrigue_temptation_3120
			days = 1825
		}
		capital_province = { save_scope_as = capital }	#For loc.
		random_pool_guest = {
			limit = { intrigue_temptation_3120_temptable_guests = yes }
			weight = {
				base = 1
				modifier = {	#Attraction makes a guest more likely to dine with you.
					add = 5
					attraction >= medium_positive_attraction
				}
				modifier = {
					add = 5
					attraction >= high_positive_attraction
				}
				opinion_modifier = {	#Guests that like you, likewise.
					opinion_target = root
					multiplier = 0.25
					max = 15
				}
				modifier = {	#Claimants always get a bit of extra time in court.
					add = 40
					any_claim = {
						useful_courtier_or_guest_claim_trigger = { RULER = root }
					}
				}
				modifier = {	#Famous dynasties receive extra attention.
					exists = dynasty
					dynasty = { dynasty_prestige_level >=4 }
					add = {
						value = dynasty.dynasty_prestige_level
						multiply = 3
					}
				}
				modifier = {	#Skilled individuals are worth talking to.
					add = 5
					AND = {
						can_be_chancellor_trigger = { COURT_OWNER = root }
						diplomacy >= high_skill_rating
					}
				}
				modifier = {
					add = 5
					AND = {
						can_be_marshal_trigger = { COURT_OWNER = root }
						martial >= high_skill_rating
					}
				}
				modifier = {
					add = 5
					AND = {
						can_be_steward_trigger = { COURT_OWNER = root }
						stewardship >= high_skill_rating
					}
				}
				modifier = {
					add = 5
					AND = {
						can_be_spymaster_trigger = { COURT_OWNER = root }
						intrigue >= high_skill_rating
					}
				}
				modifier = {
					add = 5
					AND = {
						guest_physician_candidate_trigger = yes
						learning >= high_skill_rating
					}
				}
				modifier = {
					add = 5
					AND = {
						guest_knight_candidate_trigger = { HOST = root }
						prowess >= high_skill_rating
					}
				}
			}
			save_scope_as = tempted_guest
		}
	}

	option = {	#Attempt to seduce the guest into staying.
		name = intrigue_temptation.3120.a
		duel = {
			skill = intrigue
			target = scope:tempted_guest
			60 = {	#Your wiley wiles wile them into staying.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = intrigue_temptation.3120.a.tt_success
				send_interface_toast = {
					title = intrigue_temptation.3120.a.tt_success
					left_icon = scope:tempted_guest
					had_sex_with_effect = {
						CHARACTER = scope:tempted_guest
						PREGNANCY_CHANCE = pregnancy_chance
					}
					progress_towards_lover_effect = {
						CHARACTER = scope:tempted_guest
						OPINION = 15
					}
					add_courtier = scope:tempted_guest
				}
			}
			40 = {	#Your strange and uncomfortable come-on confuses and alarms them.
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = intrigue_temptation.3120.a.tt_fail
				send_interface_toast = {	
					title = intrigue_temptation.3120.a.tt_fail
					left_icon = scope:tempted_guest
					scope:tempted_guest = {
						add_opinion = {
							modifier = disgusted_opinion
							opinion = -25
							target = root
						}
					}
				}
			}
		}
		add_intrigue_lifestyle_xp = medium_lifestyle_xp
		stress_impact = { chaste = medium_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_boldness = 0.25 }
			modifier = {
				add = -25
				has_trait = chaste
			}
		}
	}
	option = {	#Promise them a hefty favour if they stay.
		name = intrigue_temptation.3120.b
		add_courtier = scope:tempted_guest
		scope:tempted_guest = {
			add_hook = {
				target = root
				type = favor_hook
			}
			add_opinion = {
				modifier = romance_opinion
				opinion = 20
				target = root
			}
		}
		stress_impact = {
			deceitful = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			paranoid = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.25
				ai_boldness = 0.25
			}
			modifier = {
				add = 20
				has_trait = deceitful
			}
			modifier = {
				add = -25
				has_trait = callous
			}
			modifier = {
				add = -1000
				has_trait = paranoid
			}
		}
	}
	option = {	#Just let them stay a guest.
		name = intrigue_temptation.3120.c
		scope:tempted_guest = {
			add_opinion = {
				modifier = friendliness_opinion
				opinion = 10
				target = root
			}
		}
		stress_impact = {
			base = medium_stress_impact_loss
			shy = minor_stress_impact_gain
			gregarious = minor_stress_impact_loss
			drunkard = minor_stress_impact_loss
		}
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_boldness = -0.25 }
			modifier = {
				add = -10
				has_trait = shy
			}
			modifier = {
				add = 20
				has_trait = gregarious
			}
			modifier = {
				add = 25
				has_trait = drunkard
			}
		}
	}
}

##################################################
# With Cold Heart
# by Ewan Cowhig Croft
# 3130
##################################################

scripted_trigger intrigue_temptation_3130_potential_rivals = {
	is_available_ai_adult = yes
	has_relation_potential_rival = root
}

scripted_trigger intrigue_temptation_3130_potential_rival_spouses = {
	is_available_ai_adult = yes
	is_attracted_to_gender_of = root
	mgr_can_seduce = yes
	accepts_incest_with_trigger = { CHARACTER = root } #No incest or 100% ok with incest
	NOR = {
		has_relation_lover = root
		is_spouse_of = root
		has_trait = celibate
	}
}

#	You seduce the spouse of a potential rival to cement the foeship.
#		by Ewan Cowhig Croft
intrigue_temptation.3130 = {
	type = character_event
	title = intrigue_temptation.3130.t
	desc = intrigue_temptation.3130.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:rival_main
		animation = rage
	}
	right_portrait = {
		character = scope:rival_spouse
		animation = admiration
	}
	override_background = { event_background = corridor_night }

	trigger = {
		is_at_war = no
		mgr_can_seduce = yes
		NOT = { has_character_flag = had_event_intrigue_temptation_3130 }
		NOT = { has_trait = celibate }
		any_relation = {
			type = potential_rival
			intrigue_temptation_3130_potential_rivals = yes
			any_spouse = { intrigue_temptation_3130_potential_rival_spouses = yes }
		}
	}

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

	immediate = {
		add_character_flag = {
			flag = had_event_intrigue_temptation_3130
			days = 1825
		}
		every_relation = {
			type = potential_rival
			limit = {
				intrigue_temptation_3130_potential_rivals = yes
				any_spouse = { intrigue_temptation_3130_potential_rival_spouses = yes }
			}
			add_to_list = potential_rivals_list
		}
		random_in_list = {
			list = potential_rivals_list
			weight = {
				base = 1
				modifier = {	#Powerful rulers make fun rivals.
					add = 500
					highest_held_title_tier = tier_empire
				}
				modifier = {
					add = 250
					highest_held_title_tier = tier_kingdom
				}
				modifier = {
					add = 100
					highest_held_title_tier = tier_duchy
				}
				modifier = {
					add = 50
					highest_held_title_tier = tier_county
				}
				modifier = {	#Potential powerful rulers are less fun, but still worthwhile.
					add = 100
					is_ruler = no
					any_claim = { tier = tier_empire }
				}
				modifier = {
					add = 75
					is_ruler = no
					any_claim = { tier = tier_kingdom }
				}
				modifier = {
					add = 50
					is_ruler = no
					any_claim = { tier = tier_duchy }
				}
				modifier = {
					add = 25
					is_ruler = no
					any_claim = { tier = tier_county }
				}
				modifier = {	#Skullduggerous characters are great rivals.
					add = 50
					intrigue >= extremely_high_skill_rating
				}
				modifier = {
					add = 50
					intrigue >= high_skill_rating
				}
				modifier = {	#Alternatively, anyone who can beat the snot out of you is pretty swell too.
					add = 50
					prowess >= extremely_high_skill_rating
				}
				modifier = {
					add = 50
					prowess >= high_skill_rating
				}
				modifier = {	#Characters who are fun at parties, and so can rally some support better, are also somewhat acceptable.
					add = 25
					diplomacy >= extremely_high_skill_rating
				}
				modifier = {
					add = 25
					diplomacy >= high_skill_rating
				}
			}
			save_scope_as = rival_main
			random_spouse = {
				limit = { intrigue_temptation_3130_potential_rival_spouses = yes }
				save_scope_as = rival_spouse
			}
			save_scope_value_as = {
				name = rival_scale
				value = {
					value = 0
					if = {
						limit = {
							scope:rival_main = { highest_held_title_tier = tier_empire }
						}
						add = 50
					}
					if = {
						limit = {
							scope:rival_main = { highest_held_title_tier = tier_kingdom }
						}
						add = 25
					}
					if = {
						limit = {
							scope:rival_main = { highest_held_title_tier = tier_duchy }
						}
						add = 10
					}
					if = {
						limit = {
							scope:rival_main = { highest_held_title_tier = tier_county }
						}
						add = 5
					}
					if = {
						limit = {
							scope:rival_main = {
								is_ruler = no
								any_claim = { tier = tier_empire }
							}
						}
						add = 5
					}
					if = {
						limit = {
							scope:rival_main = {
								is_ruler = no
								any_claim = { tier = tier_kingdom }
							}
						}
						add = 5
					}
					if = {
						limit = {
							scope:rival_main = {
								is_ruler = no
								any_claim = { tier = tier_duchy }
							}
						}
						add = 2
					}
					if = {
						limit = {
							scope:rival_main = {
								is_ruler = no
								any_claim = { tier = tier_county }
							}
						}
						add = 2
					}
					if = {
						limit = {
							scope:rival_main = { intrigue >= extremely_high_skill_rating }
						}
						add = 5
					}
					if = {
						limit = {
							scope:rival_main = { intrigue >= high_skill_rating }
						}
						add = 5
					}
					if = {
						limit = {
							scope:rival_main = { prowess >= extremely_high_skill_rating }
						}
						add = 5
					}
					if = {
						limit = {
							scope:rival_main = { prowess >= high_skill_rating }
						}
						add = 5
					}
					if = {
						limit = {
							scope:rival_main = { diplomacy >= extremely_high_skill_rating }
						}
						add = 2
					}
					if = {
						limit = {
							scope:rival_main = { diplomacy >= high_skill_rating }
						}
						add = 2
					}
				}
			}
		}
	}

	option = {	#Attempt to sleep with your potential-foe's wife.
		name = intrigue_temptation.3130.a
		duel = {
			skill = intrigue
			target = scope:rival_spouse
			50 = {
				#NOTE: it is deliberate that there is no chance to be discovered beyond the had_sex_with_effect mechanics.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = intrigue_temptation.3130.a.tt_success
				send_interface_toast = {
					title = intrigue_temptation.3130.a.tt_success
					left_icon = scope:rival_main
					had_sex_with_effect = {
						CHARACTER = scope:rival_spouse
						PREGNANCY_CHANCE = pregnancy_chance
					}
					set_relation_rival = scope:rival_main
					if = {
						limit = { scope:rival_scale <= 9 }
						add_prestige = miniscule_prestige_gain
					}
					if = {
						limit = {
							scope:rival_scale >= 10
							scope:rival_scale <= 24
						}
						add_prestige = minor_prestige_gain
						add_character_modifier = {
							modifier = saucy_reputation_01_modifier
							days = 1825
						}
					}
					if = {
						limit = {
							scope:rival_scale >= 25
							scope:rival_scale <= 49
						}
						add_prestige = medium_prestige_gain
						add_character_modifier = {
							modifier = saucy_reputation_02_modifier
							days = 1825
						}
					}
					if = {
						limit = { scope:rival_scale >= 50 }
						add_prestige = major_prestige_gain
						add_character_modifier = {
							modifier = saucy_reputation_03_modifier
							days = 1825
						}
					}
				}
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = intrigue_temptation.3130.a.tt_fail
				send_interface_toast = {	
					title = intrigue_temptation.3130.a.tt_fail
					left_icon = scope:rival_main
					scope:rival_main = {
						add_opinion = {
							modifier = angry_opinion
							opinion = -25
							target = root
						}
					}
					scope:rival_spouse = {
						add_opinion = {
							modifier = disgusted_opinion
							opinion = -25
							target = root
						}
					}
				}
			}
		}
		stress_impact = {
			chaste = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = -0.50
				ai_vengefulness = 1
			}
			modifier = {
				add = 10
				has_trait = lustful
			}
			modifier = {
				add = 30
				has_trait = seducer
			}
			modifier = {
				add = -20
				has_trait = chaste
			}
		}
	}
	option = {	#I can't do it.
		name = intrigue_temptation.3130.b
		remove_relation_potential_rival = scope:rival_main
		add_prestige = minor_prestige_gain
		stress_impact = {
			callous = minor_stress_impact_gain
			sadistic = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_vengefulness = -0.5
			}
			modifier = {
				add = 20
				has_trait = forgiving
			}
		}
	}
}

##################################################
# Showing Off
# by Ewan Cowhig Croft
# 3140
##################################################

#	Flirt openly with courtiers, pleasing some and irritating others.
#		by Ewan Cowhig Croft
intrigue_temptation.3140 = {
	type = character_event
	title = intrigue_temptation.3140.t
	desc = intrigue_temptation.3140.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = root
		animation = flirtation
	}
	override_background = { event_background = feast }

	trigger = {
		is_at_war = no
		NOT = { has_character_flag = had_event_intrigue_temptation_3140 }
		NOT = { has_trait = celibate }
		any_courtier = {
			count >= 5
			is_adult = yes
		}
	}

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

	immediate = {
		add_character_flag = {
			flag = had_event_intrigue_temptation_3140
			days = 1825
		}
		romance_target_gender_effect = { SCOPE_NAME = romance_target }
	}

	option = {	#Flirt a little.
		name = intrigue_temptation.3140.a
		if = {	#If flirting ability is bad, set the minimum modifier lower.
			limit = { intrigue <= medium_skill_rating }
			add_character_modifier = {
				modifier = licentious_01_modifier
				days = 1825
			}
		}
		if = {	#If flirting ability is tolerable, set the minimum modifier to an acceptable level.
			limit = {
				intrigue > medium_skill_rating
				intrigue < high_skill_rating
			}
			add_character_modifier = {
				modifier = licentious_02_modifier
				days = 1825
			}
		}
		if = {	#If flirting ability is high, set the minimum modifier ludicrously high.
			limit = { intrigue >= high_skill_rating }
			add_character_modifier = {
				modifier = licentious_03_modifier
				days = 1825
			}
		}
		stress_impact = { shy = minor_stress_impact_gain }
		ai_chance = {
			base = 50
			modifier = {
				add = -35
				has_trait = shy
			}
		}
	}
	option = {	#Flirt more than is appropriate.
		name = intrigue_temptation.3140.b
		if = {	#If flirting ability is bad, set the intermediate modifier lower.
			limit = { intrigue <= medium_skill_rating }
			add_character_modifier = {
				modifier = licentious_02_modifier
				days = 1825
			}
		}
		if = {	#If flirting ability is tolerable, set the intermediate modifier to an acceptable level.
			limit = {
				intrigue > medium_skill_rating
				intrigue < high_skill_rating
			}
			add_character_modifier = {
				modifier = licentious_03_modifier
				days = 1825
			}
		}
		if = {	#If flirting ability is high, set the intermediate modifier ludicrously high.
			limit = { intrigue >= high_skill_rating }
			add_character_modifier = {
				modifier = licentious_04_modifier
				days = 1825
			}
		}
		stress_impact = {
			shy = medium_stress_impact_gain
			chaste = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			modifier = {
				add = -50
				has_trait = shy
			}
			modifier = {
				add = -40
				has_trait = chaste
			}
		}
	}
	option = {	#Flirt shamelessly.
		name = intrigue_temptation.3140.c
		if = {	#If flirting ability is bad, set the maximum modifier lower.
			limit = { intrigue <= medium_skill_rating }
			add_character_modifier = {
				modifier = licentious_03_modifier
				days = 1825
			}
		}
		if = {	#If flirting ability is tolerable, set the maximum modifier to an acceptable level.
			limit = {
				intrigue > medium_skill_rating
				intrigue < high_skill_rating
			}
			add_character_modifier = {
				modifier = licentious_04_modifier
				days = 1825
			}
		}
		if = {	#If flirting ability is high, set the maximum modifier ludicrously high.
			limit = { intrigue >= high_skill_rating }
			add_character_modifier = {
				modifier = licentious_05_modifier
				days = 1825
			}
		}
		stress_impact = {
			shy = major_stress_impact_gain
			chaste = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_energy = 0.25
			}
			modifier = {
				add = 20
				has_trait = gregarious
			}
			modifier = {
				add = -55
				has_trait = shy
			}
			modifier = {
				add = -40
				has_trait = chaste
			}
		}
	}
	option = {	#Turn your nose up at all these pesky flirters.
		name = intrigue_temptation.3140.d
		add_prestige = miniscule_prestige_gain
		stress_impact = { lustful = minor_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_boldness = -0.1
				ai_energy = -0.25
			}
			modifier = {
				add = -30
				has_trait = gregarious
			}
		}
	}
}

##################################################
# Caught in the Act
# by Ewan Cowhig Croft
# 3150
##################################################

scripted_trigger intrigue_temptation_3150_threesome_courtiers = {	#Filter available characters.
	is_available_ai_adult = yes
	is_attracted_to_gender_of = root
	root = { is_attracted_to_gender_of = prev }
	mgr_can_seduce = yes
	accepts_incest_with_trigger = { CHARACTER = root } #No incest or 100% ok with incest
	NOR = {
		has_relation_rival = root
		has_relation_lover = root
		is_consort_of = root
		has_trait = celibate
	}
	might_cheat_on_every_partner_trigger = yes
}

#	Caught chatting up a courtier, you back out, carry on, or double-down.
#		by Ewan Cowhig Croft
intrigue_temptation.3150 = {
	type = character_event
	title = intrigue_temptation.3150.t
	desc = intrigue_temptation.3150.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:primary_seducee
		animation = flirtation
	}
	right_portrait = {
		character = scope:secondary_seducee
		animation = shock
	}
	override_background = { event_background = corridor_night }

	trigger = {
		is_at_war = no
		mgr_can_seduce = yes
		NOT = { has_character_flag = had_event_intrigue_temptation_3150 }
		NOT = { has_trait = celibate }
		any_courtier_or_guest = {	#Technically should count councillors too, but it's better to assume some might be eligible but always have a couple of low-tier fallbacks.
			count >= 2
			intrigue_temptation_3150_threesome_courtiers = yes
		}
		has_focus = intrigue_temptation_focus
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		add_character_flag = {
			flag = had_event_intrigue_temptation_3150
			days = 1825
		}
		every_courtier_or_guest = {	#Grab suitable candidates hanging about the court.
			limit = { intrigue_temptation_3150_threesome_courtiers = yes }
			add_to_list = threesome_candidates_list
		}
		every_councillor = {	#See if any councillors are valid partners here, for spice.
			limit = { intrigue_temptation_3150_threesome_courtiers = yes }
			add_to_list = threesome_candidates_list
		}
		random_in_list = {
			list = threesome_candidates_list
			limit = { has_relation_potential_lover = root }	#Always prefer potential lovers if we can.
			alternative_limit = { always = yes }
			weight = {
				base = 1
				modifier = {	#Prefer landless characters for the main seducee.
					add = 100
					is_ruler = no
				}
				modifier = {	#Useful claims are nice reasons to pick someone.
					add = 30
					any_claim = {
						useful_courtier_or_guest_claim_trigger = { RULER = root }
					}
				}
				modifier = {	#Highly skilled characters make useful lovers.
					add = 10
					AND = {
						can_be_chancellor_trigger = { COURT_OWNER = root }
						diplomacy >= high_skill_rating
					}
				}
				modifier = {
					add = 10
					AND = {
						can_be_marshal_trigger = { COURT_OWNER = root }
						martial >= high_skill_rating
					}
				}
				modifier = {
					add = 10
					AND = {
						can_be_steward_trigger = { COURT_OWNER = root }
						stewardship >= high_skill_rating
					}
				}
				modifier = {
					add = 10
					AND = {
						can_be_spymaster_trigger = { COURT_OWNER = root }
					}
				}
				modifier = {
					add = 10
					AND = {
						guest_physician_candidate_trigger = yes
						learning >= high_skill_rating
					}
				}
				modifier = {
					add = 10
					AND = {
						guest_knight_candidate_trigger = { HOST = root }
						prowess >= high_skill_rating
					}
				}
			}
			save_scope_as = primary_seducee
		}
		random_in_list = {
			list = threesome_candidates_list
			limit = {
				has_relation_potential_lover = root	#Always prefer potential lovers if we can.
				NOT = { this = scope:primary_seducee }
			}
			alternative_limit = {
				NOT = { this = scope:primary_seducee }
			}
			weight = {
				base = 1
				modifier = {	#Prefer landed characters for the secondary seducee. It's funnier if your chancellor walks in on you and a guest.
					add = 100
					is_councillor = yes
				}
				modifier = {	#Useful claims are nice reasons to pick someone.
					add = 30
					any_claim = {
						useful_courtier_or_guest_claim_trigger = { RULER = root }
					}
				}
				modifier = {	#Highly skilled characters make useful lovers.
					add = 10
					AND = {
						can_be_chancellor_trigger = { COURT_OWNER = root }
						diplomacy >= high_skill_rating
					}
				}
				modifier = {
					add = 10
					AND = {
						can_be_marshal_trigger = { COURT_OWNER = root }
						martial >= high_skill_rating
					}
				}
				modifier = {
					add = 10
					AND = {
						can_be_steward_trigger = { COURT_OWNER = root }
						stewardship >= high_skill_rating
					}
				}
				modifier = {
					add = 10
					AND = {
						can_be_spymaster_trigger = { COURT_OWNER = root }
					}
				}
				modifier = {
					add = 10
					AND = {
						guest_physician_candidate_trigger = yes
						learning >= high_skill_rating
					}
				}
				modifier = {
					add = 10
					AND = {
						guest_knight_candidate_trigger = { HOST = root }
						prowess >= high_skill_rating
					}
				}
			}
			save_scope_as = secondary_seducee
			scope:primary_seducee = { add_to_list = threesome_chosen_list }
			scope:secondary_seducee = { add_to_list = threesome_chosen_list }
		}
		if = {	#Check to see if the primary seducee has higher intrigue.
			limit = { scope:primary_seducee.intrigue > scope:secondary_seducee.intrigue }
			scope:primary_seducee = { save_scope_as = highest_intrigue_seducee }
		}
		else = {	#Otherwise, assume that the secondary seducee has higher intrigue.
			scope:secondary_seducee = { save_scope_as = highest_intrigue_seducee }
		}
	}

	option = {	#Badly fake out of the situation. Usually, this would be the last option, as it's an opt-out, but it's funnier in first-place.
		name = intrigue_temptation.3150.a
		scope:primary_seducee = {	#The primary seducee is not happy about this slight.
			add_opinion = {
				modifier = romance_opinion
				opinion = -15
				target = root
			}
		}
		scope:secondary_seducee = {	#The secondary seducee only cares if their faith is bothered about your adultery, and if you are actually married.
			if = {
				limit = {
					NOT = {
						faith = { has_doctrine = doctrine_adultery_men_accepted }
					}
					root = {
						is_married = yes
						is_male = yes
					}
				}
				add_opinion = {
					modifier = reputation_opinion
					opinion = -10
					target = root
				}
			}
			if = {
				limit = {
					NOT = {
						faith = { has_doctrine = doctrine_adultery_women_accepted }
					}
					root = {
						is_married = yes
						is_male = no
					}
				}
				add_opinion = {
					modifier = reputation_opinion
					opinion = -10
					target = root
				}
			}
		}
		add_character_modifier = {	#Clearly you are a master of deception.
			modifier = quick_thinker_modifier
			days = 1825
		}
		stress_impact = {
			lustful = minor_stress_impact_gain
			honest = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_boldness = -0.25 }
			modifier = {
				add = 25
				has_trait = chaste
			}
			modifier = {
				add = -25
				has_trait = lustful
			}
		}
	}
	option = {	#Continue your frisky activities elsewhere.
		name = intrigue_temptation.3150.b
		random_list = {
			60 = {
				desc = intrigue_temptation.3150.b.tt_success
				send_interface_toast = {
					title = intrigue_temptation.3150.b.tt_success
					left_icon = scope:primary_seducee
					if = {
						limit = {
							NOT = { has_trait = chaste }
						}
						add_stress = medium_stress_loss
					}
					had_sex_with_effect = {
						CHARACTER = scope:primary_seducee
						PREGNANCY_CHANCE = pregnancy_chance
					}
					progress_towards_lover_effect = {
						CHARACTER = scope:primary_seducee
						OPINION = no
					}
				}
				modifier = {
					add = 10
					scope:primary_seducee = { has_trait = lustful }
				}
				modifier = {
					add = 20
					has_trait = seducer
				}
				modifier = {
					add = -40
					scope:primary_seducee = { has_trait = chaste }
				}
			}
			40 = {
				desc = intrigue_temptation.3150.b.tt_failure
				send_interface_toast = {
					title = intrigue_temptation.3150.b.tt_failure
					left_icon = scope:primary_seducee
					scope:primary_seducee = {
						if = {
							limit = { has_relation_potential_lover = root }
							remove_relation_potential_lover = root
						}
						add_opinion = {
							modifier = romance_opinion
							opinion = -20
							target = root
						}
					}
				}
				modifier = {
					add = 40
					scope:primary_seducee = { has_trait = chaste }
				}
				modifier = {
					add = -10
					scope:primary_seducee = { has_trait = lustful }
				}
				modifier = {
					add = -20
					has_trait = seducer
				}
			}
		}
		scope:secondary_seducee = {	#The secondary seducee only cares if their faith is bothered about your adultery, and if you are actually married.
			if = {
				limit = {
					NOT = {
						faith = { has_doctrine = doctrine_adultery_men_accepted }
					}
					root = {
						is_married = yes
						is_male = yes
					}
				}
				add_opinion = {
					modifier = reputation_opinion
					opinion = -10
					target = root
				}
			}
			if = {
				limit = {
					NOT = {
						faith = { has_doctrine = doctrine_adultery_women_accepted }
					}
					root = {
						is_married = yes
						is_male = no
					}
				}
				add_opinion = {
					modifier = reputation_opinion
					opinion = -10
					target = root
				}
			}
		}
		stress_impact = { chaste = minor_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_boldness = 0.5 }
			modifier = {
				add = 25
				has_trait = lustful
			}
			modifier = {
				add = -25
				has_trait = chaste
			}
		}
	}
	option = {	#Shoot for a threesome.
		name = intrigue_temptation.3150.c
		duel = {
			skill = intrigue
			target = scope:highest_intrigue_seducee	#Use whoever had the highest intrigue as the duel target.
			40 = {	#That worked. Somehow.
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -39
				}
				desc = intrigue_temptation.3150.c.tt_success
				send_interface_toast = {
					title = intrigue_temptation.3150.c.tt_success
					left_icon = scope:primary_seducee
					right_icon = scope:secondary_seducee
					custom_tooltip = intrigue_temptation.3150.c.tt_success.lovers
					hidden_effect = {
						every_in_list = {	#Organise the threesome's effects.
							list = threesome_chosen_list
							had_sex_with_effect = {
								CHARACTER = root
								PREGNANCY_CHANCE = pregnancy_chance
							}
							if = {
								limit = {
									can_set_relation_lover_trigger = { CHARACTER = root }
								}
								set_relation_lover = root
							}
						}
						if = {	#Determine if the primary & secondary seducees also slept together, or if they just slept with you.
							limit = {
								matching_gender_and_sexuality_trigger = {
									CHARACTER_1 = scope:primary_seducee
									CHARACTER_2 = scope:secondary_seducee
								}
							}
							scope:primary_seducee = {
								progress_towards_lover_effect = {	#Partners bond over the experience.
									CHARACTER = scope:secondary_seducee
									OPINION = 20
								}
								had_sex_with_effect = {
									CHARACTER = scope:secondary_seducee
									PREGNANCY_CHANCE = pregnancy_chance
								}
							}
						}
					}
					add_character_modifier = {	#Naturally, you're rather cocky about all of this.
						modifier = silver_tongued_modifier
						days = 1825
					}
				}
			}
			60 = {	#Unsurprisingly, neither party is interested in you now.
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -59
				}
				desc = intrigue_temptation.3150.c.tt_failure
				send_interface_toast = {
					title = intrigue_temptation.3150.c.tt_failure
					left_icon = scope:primary_seducee
					right_icon = scope:secondary_seducee
					scope:primary_seducee = {
						if = {
							limit = { has_relation_potential_lover = root }
							remove_relation_potential_lover = root
						}
						add_opinion = {
							modifier = insult_opinion
							opinion = -15
							target = root
						}
					}
					scope:secondary_seducee = {
						if = {
							limit = { has_relation_potential_lover = root }
							remove_relation_potential_lover = root
						}
						add_opinion = {
							modifier = insult_opinion
							opinion = -15
							target = root
						}
					}
				}
			}
		}
		add_intrigue_lifestyle_xp = major_lifestyle_xp	#Either way, it was a learning experience.
		stress_impact = {
			shy = medium_stress_impact_gain
			chaste = medium_stress_impact_gain
		}
		ai_chance = {
			base = 30
			ai_value_modifier = { ai_boldness = 0.25 }
			modifier = {
				add = 40
				has_trait = seducer
			}
			modifier = {
				add = 25
				has_trait = lustful
			}
			modifier = {
				add = -25
				has_trait = chaste
			}
			modifier = {
				add = -20
				has_trait = shy
			}
		}
	}
}

##################################################
# A Confused Sort of Magnetism
# by Ewan Cowhig Croft
# 3160
##################################################

scripted_trigger intrigue_temptation_3160_sometime_rivals = {	#Filter available characters.
	is_available_ai_adult = yes
	is_attracted_to_gender_of = root
	accepts_incest_with_trigger = { CHARACTER = root } #No incest or 100% ok with incest
	NOR = {
		has_relation_rival = root
		has_relation_lover = root
		is_consort_of = root
		has_trait = celibate
		has_trait = calm
		is_in_list = sometime_rivals_list
	}
	OR = {
		has_relation_potential_rival = root	#Always nab appropriate rivals.
 		opinion = {	#Otherwise just random haters are fine.
 			target = root
 			value < medium_negative_opinion
 		}
	}
	OR = {
		AND = {	#Vassals who aren't ludicrously far below your notice are suitable candidates.
			is_vassal_of = root
			tier_difference = {
				target = root
				value >= -2
			}
		}
		is_councillor_of = root	#Councillors are always interesting.
		any_claim = {
			OR = {
				holder = root	#Claimants against you are likely to have tension.
				any_title_heir = { this = root }	#Those whose death you'd profit by, likewise.
			}
		}

	}
}

#	Sleep with someone who dislikes you for fun or profit.
#		by Ewan Cowhig Croft
intrigue_temptation.3160 = {
	type = character_event
	title = intrigue_temptation.3160.t
	desc = intrigue_temptation.3160.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:sometime_rival
		animation = rage
	}

	trigger = {
		mgr_can_seduce = yes
		is_at_war = no
		NOT = { has_character_flag = had_event_intrigue_temptation_3160 }
		NOT = { has_trait = celibate }
		attraction >= medium_positive_attraction
		OR = {
			any_courtier_or_guest = { intrigue_temptation_3160_sometime_rivals = yes }
			any_vassal = { intrigue_temptation_3160_sometime_rivals = yes }
			any_councillor = { intrigue_temptation_3160_sometime_rivals = yes }
		}
	}

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

	immediate = {
		add_character_flag = {
			flag = had_event_intrigue_temptation_3160
			days = 7300
		}
		every_courtier_or_guest = {
			limit = { intrigue_temptation_3160_sometime_rivals = yes }
			add_to_list = sometime_rivals_list
		}
		every_vassal = {
			limit = { intrigue_temptation_3160_sometime_rivals = yes }
			add_to_list = sometime_rivals_list
		}
		every_councillor = {
			limit = { intrigue_temptation_3160_sometime_rivals = yes }
			add_to_list = sometime_rivals_list
		}
		random_in_list = {
			list = sometime_rivals_list
			limit = { has_relation_potential_rival = root }
			alternative_limit = { always = yes }
			weight = {
				base = 1
				opinion_modifier = {
					opinion_target = root
					multiplier = -0.25
				}
				modifier = {	#It's always fun to sleep with your bishop.
					add = 50
					is_theocratic_lessee = yes
				}
				modifier = {	#Councillors make interesting rivals.
					add = 30
					is_councillor_of = root
					is_theocratic_lessee = no	#No double-dipping for bishops.
				}
				modifier = {	#Kings make lovely rivals!
					add = 30
					highest_held_title_tier = tier_kingdom
				}
				modifier = {	#Dukes make acceptable rivals.
					add = 20
					highest_held_title_tier = tier_duchy
				}
				modifier = {	#Counts are tolerable rivals.
					add = 10
					highest_held_title_tier = tier_county
				}
				modifier = {	#Lustful characters are a bit easier to persuade.
					add = 10
					has_trait = lustful
				}
				modifier = {	#Chaste characters are in the pool, but less likely to fall victim to their passions.
					add = -20
					has_trait = chaste
				}
			}
			save_scope_as = sometime_rival
		}
	}

	option = {
		name = intrigue_temptation.3160.a
		duel = {
			skill = intrigue
			target = scope:sometime_rival
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = -49
				}
				desc = intrigue_temptation.3160.a.tt_success
				had_sex_with_effect = {
					CHARACTER = scope:sometime_rival
					PREGNANCY_CHANCE = pregnancy_chance
				}
				custom_tooltip = intrigue_temptation.3160.a.tt_success.tt
				trigger_event = { id = intrigue_temptation.3161 }
			}
			50 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = -49
				}
				desc = intrigue_temptation.3160.a.tt_fail
				send_interface_toast = {	
					title = intrigue_temptation.3160.a.tt_fail
					left_icon = scope:sometime_rival
					add_prestige = medium_prestige_loss
					scope:sometime_rival = {
						add_opinion = {
							modifier = disgusted_opinion
							opinion = -40
							target = root
						}
					}
				}
			}
		}
		stress_impact = { chaste = medium_stress_impact_gain }
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_boldness = 0.2 }
			modifier = {
				add = 20
				has_trait = lustful
			}
			modifier = {
				add = 30
				has_trait = seducer
			}
			modifier = {
				add = -30
				has_trait = chaste
			}
		}
	}
	option = {
		name = intrigue_temptation.3160.b
		add_prestige = medium_prestige_gain
		scope:sometime_rival = {
			add_opinion = {
				modifier = angry_opinion
				opinion = -35
				target = root
			}
		}
		progress_towards_rival_effect = {
			CHARACTER = scope:sometime_rival
			OPINION = no
		}
		stress_impact = {
			lustful = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = { ai_boldness = -0.2 }
			modifier = {
				add = -20
				has_trait = lustful
			}
			modifier = {
				add = -20
				has_trait = wrathful
			}
		}
	}
}

#	Seduction follow-up.
intrigue_temptation.3161 = {
	type = character_event
	title = intrigue_temptation.3160.t
	desc = intrigue_temptation.3161.desc
	
	theme = intrigue_temptation_focus
	left_portrait = {
		character = scope:sometime_rival
		animation = flirtation
	}

	trigger = {
		exists = scope:sometime_rival
	}

	weight_multiplier = {
		base = 1
	}

	option = {
		name = intrigue_temptation.3161.a
		scope:sometime_rival = {
			if = {
				limit = { has_relation_potential_rival = root }
				remove_relation_potential_rival = root
			}
		}
		progress_towards_lover_effect = {
			CHARACTER = scope:sometime_rival
			OPINION = 40
		}
		stress_impact = {
			callous = minor_stress_impact_gain
			sadistic = medium_stress_impact_gain
			vengeful = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = 0.1
				ai_vengefulness = -0.1
			}
			modifier = {
				add = 20
				has_trait = forgiving
			}
			modifier = {
				add = 20
				has_trait = calm
			}
			modifier = {
				add = 10
				has_trait = lustful
			}
			modifier = {
				add = -20
				has_trait = callous
			}
			modifier = {
				add = -40
				has_trait = sadistic
			}
			modifier = {
				add = -50
				has_trait = vengeful
			}
		}
	}
	option = {
		name = intrigue_temptation.3161.b
		flavor = intrigue_temptation.3161.b_flavour
		scope:sometime_rival = {
			set_relation_rival = root
			add_opinion = {
				modifier = hate_opinion
				opinion = -20
				target = root
			}
			add_stress = major_stress_gain
		}
		stress_impact = {
			forgiving = medium_stress_impact_gain
			compassionate = medium_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = -0.1
				ai_vengefulness = 0.1
			}
			modifier = {
				add = 10
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
			modifier = {
				add = 20
				has_trait = vengeful
			}
			modifier = {
				add = -20
				has_trait = forgiving
			}
			modifier = {
				add = -20
				has_trait = calm
			}
		}
	}
	option = {
		name = intrigue_temptation.3161.c
		scope:sometime_rival = {
			death = {
				death_reason = death_accident
				killer = root
			}
		}
		add_secret = {
			type = secret_murder
			target = scope:sometime_rival
		}
		add_character_modifier = {
			modifier = malignant_hearsay_modifier
			days = 3650
		}
		stress_impact = {
			forgiving = major_stress_impact_gain
			compassionate = major_stress_impact_gain
			just = major_stress_impact_gain
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				ai_compassion = -0.2
				ai_vengefulness = 0.2
			}
			modifier = {
				add = 20
				OR = {
					has_trait = callous
					has_trait = sadistic
				}
			}
			modifier = {
				add = 30
				has_trait = wrathful
			}
			modifier = {
				add = 40
				has_trait = vengeful
			}
			modifier = {
				add = -20
				has_trait = forgiving
			}
			modifier = {
				add = -20
				has_trait = calm
			}
			modifier = {
				add = -40
				has_trait = compassionate
			}
		}
	}
}