﻿
#####################################################################
# EFFECT LIST
#####################################################################
# !!! Remember to add all new effects with a short description here !!!

#casual_sex_or_lover_event_effect - triggers an event about two characters after they've had sex to determine if it was just casual or if there's something more going on

#####################################################################
# EFFECTS
#####################################################################

love_letter_calculation_effect = {
	hidden_effect = {
		save_scope_as = letterAuthor
		duel = {
			skill = diplomacy
			value = 10
			25 = {
				compare_modifier = {
					value = scope:duel_value
				}
				set_variable = {
					name = love_letter_quality
					value = 4
				}
			}
			25 = {
				compare_modifier = {
					value = scope:duel_value
				}
				set_variable = {
					name = love_letter_quality
					value = 3
				}
			}
			25 = {
				set_variable = {
					name = love_letter_quality
					value = 2
				}
			}
			25 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -0.5
				}
				set_variable = {
					name = love_letter_quality
					value = 1
				}
			}
		}
	}
}

lover_activity_set_variable_effect = {
	hidden_effect = {
		random_list = {
			10 = { #No trigger, always available
				modifier = {
					OR = {
						has_trait = lifestyle_herbalist
						has_trait = shy
					}
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:garden_walk
					days = 1
				}
			}
			10 = { #No trigger, always available
				modifier = {
					OR = {
						has_trait = gregarious
						has_trait = gluttonous
					}
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:dinner
					days = 1
				}
			}
			10 = { #No trigger, always available
				modifier = {
					has_trait = greedy
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:buy_gift
					days = 1
				}
			}
			10 = {
				trigger = {
					NOR = {
						has_trait = shy
						has_trait = callous
						has_trait = sadistic
					}
					NOT = { PREV = { has_trait = shy } }
				}
				modifier = {
					OR = {
						has_trait = diplomat
						has_trait = gregarious
					}
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:social_events
					days = 1
				}
			}
			10 = {
				trigger = {
					PREV = { stewardship > 10 }
					NOT = { has_trait = greedy }
					NOT = { PREV = { has_trait = generous } }
				}
				set_variable = {
					name = lover_activity
					value = flag:play_games
					days = 1
				}
			}
			5 = {
				trigger = {
					NOR = {
						has_trait = shy
						has_trait = temperate
					}
					NOT = { PREV = { has_trait = temperate } }
				}
				modifier = {
					OR = {
						has_trait = lifestyle_reveler
						has_trait = drunkard
					}
					factor = 10
				}
				set_variable = {
					name = lover_activity
					value = flag:drink
					days = 1
				}
			}
			10 = {
				trigger = {
					NOR = {
						has_trait = craven
						has_trait = physique_bad_1
						has_trait = physique_bad_2
						has_trait = physique_bad_3
					}
					PREV = {
						NOR  ={
							has_trait = craven
							has_trait = physique_bad_1
							has_trait = physique_bad_2
							has_trait = physique_bad_3
						}
					}
				}
				modifier = {
					has_trait = lifestyle_hunter
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:go_hunting
					days = 1
				}
			}
			10 = {
				trigger = {
					NOR = {
						has_trait = cynical
						has_trait = impatient
					}
					PREV = {
						NOR = {
							has_trait = cynical
							has_trait = impatient
						}
					}
				}
				set_variable = {
					name = lover_activity
					value = flag:stargaze
					days = 1
				}
			}
			10 = {
				trigger = {
					NOT = { has_trait = humble }
				}
				modifier = {
					has_trait = arrogant
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:flatter
					days = 1
				}
			}
			10 = {
				trigger = {
					NOT = {
						has_trait = cynical
					}
					PREV = { NOT = { has_trait = cynical } }
					religion = PREV.religion
				}
				modifier = {
					has_trait = zealous
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:talk_about_god
					days = 1
				}
			}
			10 = {
				trigger = {
					NOR = {
						has_trait = craven
						has_trait = physique_bad_1
						has_trait = physique_bad_2
						has_trait = physique_bad_3
					}
					PREV = {
						NOR  ={
							has_trait = craven
							has_trait = physique_bad_1
							has_trait = physique_bad_2
							has_trait = physique_bad_3
						}
					}
				}
				modifier = {
					has_trait = brave
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:go_adventuring
					days = 1
				}
			}
			10 = {
				trigger = {
					NOT = { has_trait = cynical }
					PREV = { NOT = { has_trait = cynical } }
				}
				modifier = {
					OR = {
						has_trait = family_first
						has_trait = gregarious
						has_trait = ambitious
						has_trait = pregnant
					}
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:talk_about_future
					days = 1
				}
			}
			10 = {
				trigger = {
					NOT = {
						has_trait = calm
					}
					OR = {
						opinion = { target = PREV value < 15 }
						reverse_opinion = { target = PREV value < 15 }
						has_trait = wrathful
					}
					PREV = { NOT = { has_trait = calm } }
				}
				modifier = {
					OR = {
						opinion = { target = PREV value < 0 }
						reverse_opinion = { target = PREV value < 0 }
						has_trait = wrathful
					}
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:fight
					days = 1
				}
			}
			10 = {
				trigger = {
					OR = {
						learning = 12
						has_trait = scholar
					}
					PREV = { learning = 10 }
				}
				modifier = {
					has_trait = scholar
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:discuss_books
					days = 1
				}
			}
			10 = {
				trigger = {
					NOR = {
						has_trait = celibate
						has_trait = chaste
					}
					PREV = {
						NOR = {
							has_trait = celibate
							has_trait = chaste
						}
					}
				}
				modifier = {
					OR = {
						has_trait = seducer
						has_trait = lustful
						has_trait = deviant
					}
					factor = 5
				}
				set_variable = {
					name = lover_activity
					value = flag:lovemaking
					days = 1
				}
			}
		}
	}
}

lover_activity_remove_flag_effect = {
	
}




had_sex_with_effect = {
	save_scope_as = had_sex_root_character
	$CHARACTER$ = { save_scope_as = had_sex_with_effect_partner }

	# Error logging
	## Children should never run this effect.
	if = {
		limit = {
			OR = {
				scope:had_sex_root_character = { is_adult = no }
				scope:had_sex_with_effect_partner = { is_adult = no }
			}
		}
		error_log = "Trying to run had_sex_with_effect but one or more partners is a child"
	}
	## Did you forget to run the check for whether adultery was valid?
	if = {
		limit = {
			# Rarely, we may also want to block this check (e.g., seduction schemes or monogamous threesomes).
			NOT = { exists = scope:ignore_cheating_error_check }
		}
		# Check whether the root char is cheating.
		if = {
			limit = {
				scope:had_sex_root_character = {
					NOR = {
						is_consort_of = scope:had_sex_with_effect_partner
						has_relation_lover = scope:had_sex_with_effect_partner
					}
					might_cheat_on_every_partner_trigger = no
				}
			}
			# The weird structure here is so that we can use prev scope in loc to grab both chars.
			scope:had_sex_with_effect_partner = {
				scope:had_sex_root_character = { error_log = had_sex_with_effect.log.root_cheated_inappropriately }
			}
		}
		# Check whether their partner is cheating.
		## Though this does lead to potential duplication in the error log, where you'll get an entry for X cheating with Y _and_ for Y cheating with X, it is necessary: it's perfectly possible for one char to be cheating but the other not.
		if = {
			limit = {
				scope:had_sex_with_effect_partner = {
					NOR = {
						is_consort_of = scope:had_sex_root_character
						has_relation_lover = scope:had_sex_root_character
					}
					might_cheat_on_every_partner_trigger = no
				}
			}
			# The weird structure here is so that we can use prev scope in loc to grab both chars.
			scope:had_sex_root_character = {
				scope:had_sex_with_effect_partner = { error_log = had_sex_with_effect.log.target_cheated_inappropriately }
			}
		}
	}
	### Plus, remove the blocking scope we might have.
	clear_saved_scope = ignore_cheating_error_check

	if = {
		limit = { this = root }
		custom_tooltip = had_sex_with_effect.first_person.tt
	}
	else_if = {
		limit = { root = scope:had_sex_with_effect_partner }
		custom_tooltip = had_sex_with_effect.other_person.tt
	}
	else = {
		custom_tooltip = had_sex_with_effect.third_person.tt
	}

	create_character_memory = {
		type = had_sex
		participants = {
			sex_partner = scope:had_sex_with_effect_partner
		}
	}

	#Stress
	if = {
		limit = { # For use with events that add/remove more stress than these values, to avoid ugly tooltips
			NOT = {
				has_character_flag = no_sex_stress_loss
			}
		}
		$CHARACTER$ = {
			if = {
				limit = { this = root }
				stress_impact = {
					lustful = minor_stress_impact_loss
					rakish = minor_stress_impact_loss
				}
			}
			else = {
				hidden_effect = {
					stress_impact = {
						lustful = minor_stress_impact_loss
						rakish = minor_stress_impact_loss
					}
				}
			}
		}
		if = {
			limit = { this = root }
			stress_impact = {
				lustful = minor_stress_impact_loss
				rakish = minor_stress_impact_loss
			}
		}
		else = {
			hidden_effect = {
				stress_impact = {
					lustful = minor_stress_impact_loss
					rakish = minor_stress_impact_loss
				}
			}
		}
	}

	#Pregnancy & story cycles
	hidden_effect = {
		if = {
			limit = {
				is_female = yes
				$CHARACTER$ = { is_male = yes }
				possible_pregnancy_after_sex_with_character_trigger = { CHARACTER = scope:had_sex_with_effect_partner }
			}
			add_to_variable_list = {
				name = potential_father_variable_list
				target = $CHARACTER$
			}
			random = {
				chance = $PREGNANCY_CHANCE$
				make_pregnant = {
					father = $CHARACTER$
				}
			}
			if = {
				limit = {
					is_ai = no
					NOT = { has_character_flag = had_story_cycle_peasant_affair }
					is_ruler = yes
					$CHARACTER$ = {
						is_lowborn = yes
						is_playable_character = no
						is_courtier = no
					}
					NOT = {
						any_scheme = {
							scheme_target_character = $CHARACTER$
						}
					}
				}
				set_variable = {
					name = story_peasant_affair_target
					value = $CHARACTER$
				}
				create_story = story_peasant_affair
			}
		}
		else_if = {
			limit = {
				is_male = yes
				$CHARACTER$ = { is_female = yes }
				possible_pregnancy_after_sex_with_character_trigger = { CHARACTER = scope:had_sex_with_effect_partner }
			}
			$CHARACTER$ = {
				add_to_variable_list = {
					name = potential_father_variable_list
					target = scope:had_sex_root_character
				}
			}
			if = {
				limit = {
					is_ai = no
					NOT = { has_character_flag = had_story_cycle_peasant_affair }
					is_ruler = yes
					$CHARACTER$ = {
						is_lowborn = yes
						is_playable_character = no
						is_courtier = no
					}
					NOT = {
						any_scheme = {
							scheme_target_character ?= $CHARACTER$
						}
					}
				}
				set_variable = {
					name = story_peasant_affair_target
					value = $CHARACTER$
				}
				$CHARACTER$ = {
					if = {
						limit = {
							is_pregnant = no
							fertility >= 0.1
							is_visibly_fertile = yes
						}
						random = {
							chance = $PREGNANCY_CHANCE$
							add_character_flag = {
								flag = peasant_is_pregnant
								days = 560
							}
						}
					}
				}
				create_story = story_peasant_affair
			}
			else = {
				$CHARACTER$ = {
					random = {
						chance = $PREGNANCY_CHANCE$
						make_pregnant = {
							father = scope:had_sex_root_character
						}
					}
				}
			}
		}
		
		#STD transmission
		risk_of_std_from_effect = { PARTNER = $CHARACTER$ }
		hidden_effect = {
			$CHARACTER$ = { risk_of_std_from_effect = { PARTNER = scope:had_sex_root_character } }
		}
	
		#Adultery suspicion
		hidden_effect = {
			if = {
				limit = {
					OR = {
						is_married = yes
						is_concubine = yes
					}
					NOR = {
						any_consort = { this = $CHARACTER$ }
						AND = {
							house.house_head ?= this
							house ?= { has_house_power_parameter = aspect_of_creation }
						}
					}
				}
				set_variable = {
					name = had_recent_sex_with
					value = $CHARACTER$
					days = 1000
				}
				random = {
					chance = 50 #This should be quite high as there is a chance that adultery.0001 "fails" i.e. spouse doesn't realize
					every_relation = {
						type = soulmate
						limit = {
							NOT = { this = $CHARACTER$ } #Soulmates should not grow suspicous of adulterous affairs after sleeping with their lover
						}
						add_to_temporary_list = partners_1
					}
					every_consort = {
						add_to_temporary_list = partners_1
					}
					random_in_list = {
						list = partners_1
						limit = { is_ai = no }
						alternative_limit = { always = yes }
						trigger_event = {
							id = adultery.0001
							days = { 14 365 }
						}
					}
				}
			}
			$CHARACTER$ = {
				if = {
					limit = {
						OR = {
							is_married = yes
							is_concubine = yes
						}
						NOR = {
							any_consort = { this = scope:had_sex_root_character }
							AND = {
								house.house_head ?= this
								house ?= { has_house_power_parameter = aspect_of_creation }
							}
						}
					}
					set_variable = {
						name = had_recent_sex_with
						value = scope:had_sex_root_character
						days = 1000
					}
					random = {
						chance = 50 #This should be quite high as there is a chance that adultery.0001 "fails" i.e. spouse doesn't realize
						every_relation = {
							type = soulmate
							limit = {
								this != scope:had_sex_root_character #Soulmates should not grow suspicous of adulterous affairs after sleeping with their lover
							}
							add_to_temporary_list = partners_2
						}
						every_consort = {
							add_to_temporary_list = partners_2
						}
						random_in_list = {
							list = partners_2
							limit = { is_ai = no }
							alternative_limit = { always = yes }
							trigger_event = {
								id = adultery.0001
								days = { 14 365 }
							}
						}
					}
				}
			}
		}

		#Incestuous Relations
		give_incest_secret_or_nothing_with_target_effect = { CHARACTER = $CHARACTER$ }
		hidden_effect = {
			$CHARACTER$ = { give_incest_secret_or_nothing_with_target_effect = { CHARACTER = scope:had_sex_root_character } }
		}

		#Homosexuality
		give_homosexual_secret_or_nothing_with_target_effect = { CHARACTER = $CHARACTER$ }
		hidden_effect = {
			$CHARACTER$ = { give_homosexual_secret_or_nothing_with_target_effect = { CHARACTER = scope:had_sex_root_character } }
		}
	}

	#Violet Poet trait
	if = {
		limit = {
			scope:had_sex_root_character = {
				has_trait = violet_poet
			}
		}
		scope:had_sex_root_character = {
			add_trait_xp = {
				trait = violet_poet
				value = {
					integer_range = {
						min = 5
						max = 10
					}
				}
			}
		}
	}
	if = {
		limit = {
			scope:had_sex_with_effect_partner = {
				has_trait = violet_poet
			}
		}
		scope:had_sex_with_effect_partner = {
			add_trait_xp = {
				trait = violet_poet
				value = {
					integer_range = {
						min = 5
						max = 10
					}
				}
			}
		}
	}

	# Achievements
	fp2_had_friend_with_benefits = yes # FP2 History's Best Friend
}

#For having sex with "someone" (not a character)
had_sex_with_unknown_effect = {
	save_temporary_scope_value_as = {
		name = gender
		value = flag:$GENDER$
	}

	#Error logging
	if = {
		limit = {
			is_adult = no
		}
		error_log = "Trying to run had_sex_with_unknown_effect on a child"
	}

	#Stress release
	if = {
		limit = {
			OR = {
				has_trait = lustful
				has_trait = lifestyle_reveler
			}
		}
		add_stress = minor_stress_loss
	}

	#Sodomy
	if = {
		limit = { scope:gender = flag:male }
		give_homosexual_secret_or_nothing_with_target_effect = { CHARACTER = dummy_male }
	}

	hidden_effect = {
		#Adultery suspicion
		set_variable = {
			name = had_recent_sex
			value = flag:$GENDER$
		}
		random = {
			chance = 5
			random_spouse = {
				limit = { is_ai = no }
				alternative_limit = { always = yes }
				trigger_event = adultery.0001
			}
		}

		#STD transmission
		random_list = {
			95 = {
				#Nothing
			}
			4 = {
				contract_disease_notify_effect = { DISEASE = lovers_pox }
			}
			1 = {
				contract_disease_notify_effect = { DISEASE = great_pox }
			}
		}
	}
}

#Run in the scope of the character breaking things off
lose_lover_effect = {
	if = {
		limit = {
			has_relation_lover = $LOVER$
		}
		remove_relation_lover = $LOVER$
	}
	#To clear flags
	if = {
		limit = {
			has_character_flag = can_be_confronted_about_lover_exclusivity
		}
		remove_character_flag = can_be_confronted_about_lover_exclusivity
	}
	if = {
		limit = {
			$LOVER$ = {
				has_character_flag = can_be_confronted_about_lover_exclusivity
			}
		}
		$LOVER$ = {
			remove_character_flag = can_be_confronted_about_lover_exclusivity
		}
	}

	#To remove the object of importance if it exists
	if = {
		limit = {
			has_variable_list = lover_object_of_importance
			is_target_in_variable_list = {
				name = lover_object_of_importance
				target = $LOVER$
			}
		}
		clear_variable_list = lover_object_of_importance
	}
	else_if = {
		limit = {
			has_variable_list = lover_object_of_importance_2
			is_target_in_variable_list = {
				name = lover_object_of_importance_2
				target = $LOVER$
			}
		}
		clear_variable_list = lover_object_of_importance_2
	}
	else_if = {
		limit = {
			$LOVER$ = {
				has_variable_list = lover_object_of_importance
				is_target_in_variable_list = {
					name = lover_object_of_importance
					target = prev
				}
			}
		}
		$LOVER$ = { clear_variable_list = lover_object_of_importance }
	}
	else_if = {
		limit = {
			$LOVER$ = {
				has_variable_list = lover_object_of_importance_2
				is_target_in_variable_list = {
					name = lover_object_of_importance_2
					target = prev
				}
			}
		}
		$LOVER$ = { clear_variable_list = lover_object_of_importance_2 }
	}
}



#Which one of the two characters do I love the most?
whom_do_i_love_the_most_effect = {
	if = {
		limit = {
			has_opinion_modifier = {
				target = $CHARACTER1$
				modifier = love_opinion
				value >= 0
			}
			has_opinion_modifier = {
				target = $CHARACTER2$
				modifier = love_opinion
				value >= 0
			}
		}
		if = {
			limit = {
				has_opinion_modifier = {
					target = $CHARACTER1$
					modifier = love_opinion
					value >= 10
				}
				has_opinion_modifier = {
					target = $CHARACTER2$
					modifier = love_opinion
					value >= 10
				}
			}
			if = {
				limit = {
					has_opinion_modifier = {
						target = $CHARACTER1$
						modifier = love_opinion
						value >= 20
					}
					has_opinion_modifier = {
						target = $CHARACTER2$
						modifier = love_opinion
						value >= 20
					}
				}
				if = {
					limit = {
						has_opinion_modifier = {
							target = $CHARACTER1$
							modifier = love_opinion
							value >= 30
						}
						has_opinion_modifier = {
							target = $CHARACTER2$
							modifier = love_opinion
							value >= 30
						}
					}
					if = {
						limit = {
							has_opinion_modifier = {
								target = $CHARACTER1$
								modifier = love_opinion
								value >= 40
							}
							has_opinion_modifier = {
								target = $CHARACTER2$
								modifier = love_opinion
								value >= 40
							}
						}
						if = {
							limit = {
								has_opinion_modifier = {
									target = $CHARACTER1$
									modifier = love_opinion
									value >= 50
								}
								has_opinion_modifier = {
									target = $CHARACTER2$
									modifier = love_opinion
									value >= 50
								}
							}
							if = {
								limit = {
									has_opinion_modifier = {
										target = $CHARACTER1$
										modifier = love_opinion
										value >= 60
									}
									has_opinion_modifier = {
										target = $CHARACTER2$
										modifier = love_opinion
										value >= 60
									}
								}
								if = {
									limit = {
										has_opinion_modifier = {
											target = $CHARACTER1$
											modifier = love_opinion
											value >= 70
										}
										has_opinion_modifier = {
											target = $CHARACTER2$
											modifier = love_opinion
											value >= 70
										}
									}
									if = {
										limit = {
											has_opinion_modifier = {
												target = $CHARACTER1$
												modifier = love_opinion
												value >= 80
											}
											has_opinion_modifier = {
												target = $CHARACTER2$
												modifier = love_opinion
												value >= 80
											}
										}
										random_list = {
											50 = {
												$CHARACTER1$ = { save_scope_as = most_beloved }
											}
											50 = {
												$CHARACTER2$ = { save_scope_as = most_beloved }
											}
										}
									}
									else_if = {
										limit = {
											has_opinion_modifier = {
												target = $CHARACTER1$
												modifier = love_opinion
												value >= 80
											}
										}
										$CHARACTER1$ = { save_scope_as = most_beloved }
									}
									else_if = {
										limit = {
											has_opinion_modifier = {
												target = $CHARACTER2$
												modifier = love_opinion
												value >= 80
											}
										}
										$CHARACTER2$ = { save_scope_as = most_beloved }
									}
								}
								else_if = {
									limit = {
										has_opinion_modifier = {
											target = $CHARACTER1$
											modifier = love_opinion
											value >= 70
										}
									}
									$CHARACTER1$ = { save_scope_as = most_beloved }
								}
								else_if = {
									limit = {
										has_opinion_modifier = {
											target = $CHARACTER2$
											modifier = love_opinion
											value >= 70
										}
									}
									$CHARACTER2$ = { save_scope_as = most_beloved }
								}
							}
							else_if = {
								limit = {
									has_opinion_modifier = {
										target = $CHARACTER1$
										modifier = love_opinion
										value >= 60
									}
								}
								$CHARACTER1$ = { save_scope_as = most_beloved }
							}
							else_if = {
								limit = {
									has_opinion_modifier = {
										target = $CHARACTER2$
										modifier = love_opinion
										value >= 60
									}
								}
								$CHARACTER2$ = { save_scope_as = most_beloved }
							}
						}
						else_if = {
							limit = {
								has_opinion_modifier = {
									target = $CHARACTER1$
									modifier = love_opinion
									value >= 50
								}
							}
							$CHARACTER1$ = { save_scope_as = most_beloved }
						}
						else_if = {
							limit = {
								has_opinion_modifier = {
									target = $CHARACTER2$
									modifier = love_opinion
									value >= 50
								}
							}
							$CHARACTER2$ = { save_scope_as = most_beloved }
						}
					}
					else_if = {
						limit = {
							has_opinion_modifier = {
								target = $CHARACTER1$
								modifier = love_opinion
								value >= 40
							}
						}
						$CHARACTER1$ = { save_scope_as = most_beloved }
					}
					else_if = {
						limit = {
							has_opinion_modifier = {
								target = $CHARACTER2$
								modifier = love_opinion
								value >= 40
							}
						}
						$CHARACTER2$ = { save_scope_as = most_beloved }
					}
				}
				else_if = {
					limit = {
						has_opinion_modifier = {
							target = $CHARACTER1$
							modifier = love_opinion
							value >= 30
						}
					}
					$CHARACTER1$ = { save_scope_as = most_beloved }
				}
				else_if = {
					limit = {
						has_opinion_modifier = {
							target = $CHARACTER2$
							modifier = love_opinion
							value >= 30
						}
					}
					$CHARACTER2$ = { save_scope_as = most_beloved }
				}
			}
			else_if = {
				limit = {
					has_opinion_modifier = {
						target = $CHARACTER1$
						modifier = love_opinion
						value >= 20
					}
				}
				$CHARACTER1$ = { save_scope_as = most_beloved }
			}
			else_if = {
				limit = {
					has_opinion_modifier = {
						target = $CHARACTER2$
						modifier = love_opinion
						value >= 20
					}
				}
				$CHARACTER2$ = { save_scope_as = most_beloved }
			}
		}
		else_if = {
			limit = {
				has_opinion_modifier = {
					target = $CHARACTER1$
					modifier = love_opinion
					value >= 10
				}
			}
			$CHARACTER1$ = { save_scope_as = most_beloved }
		}
		else_if = {
			limit = {
				has_opinion_modifier = {
					target = $CHARACTER2$
					modifier = love_opinion
					value >= 10
				}
			}
			$CHARACTER2$ = { save_scope_as = most_beloved }
		}
	}
	else_if = {
		limit = {
			has_opinion_modifier = {
				target = $CHARACTER1$
				modifier = love_opinion
				value >= 0
			}
		}
		$CHARACTER1$ = { save_scope_as = most_beloved }
	}
	else_if = {
		limit = {
			has_opinion_modifier = {
				target = $CHARACTER2$
				modifier = love_opinion
				value >= 0
			}
		}
		$CHARACTER2$ = { save_scope_as = most_beloved }
	}
	else = {
		random_list = {
			50 = {
				$CHARACTER1$ = { save_scope_as = most_beloved }
			}
			50 = {
				$CHARACTER2$ = { save_scope_as = most_beloved }
			}
		}
	}
}

casual_sex_or_lover_event_effect = {
	$CHARACTER_2$ = { save_scope_as = married_seducer }
	$CHARACTER_1$ = {
		trigger_event = {
			id = yearly.1002
			days = $DAYS$
		}
	}
}


