﻿#Character interactions relating to schemes

seduce_interaction = {
	icon = icon_scheme_seduce
	category = interaction_category_friendly
	interface_priority = 45
	scheme = seduce
	common_interaction = no

	send_name = START_SCHEME
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = family
		max = 2
	}
	ai_targets = {
		ai_recipients = guests
		ai_recipients = courtiers
		max = 10
	}
	ai_targets = {
		ai_recipients = neighboring_rulers
		max = 5
	}
	ai_targets = {
		ai_recipients = vassals
		max = 5
	}
	ai_targets = {
		ai_recipients = peer_vassals
		max = 5
	}

	# We don't want this to grow ludicrously large in big realms
	ai_targets = {
		ai_recipients = realm_characters
		max = 10
	}

	ai_target_quick_trigger = {
		adult = yes
		attracted_to_owner = yes
		owner_attracted = yes
	}
	
	ai_frequency_by_tier = {
		barony = 0
		county = 72
		duchy = 36
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		scope:actor != scope:recipient
		scope:recipient = { is_adult = yes }
		scope:actor = { is_adult = yes }

		# Avoid seducing lowborn nobodies in foreign courts
		trigger_if = {
			limit = {
				scope:actor = { is_ai = yes }
			}
			NOT = {
				scope:recipient = {
					is_lowborn = yes
					is_playable_character = no
					NOR = {
						is_courtier_of = scope:actor
						is_foreign_court_or_pool_guest_of = scope:actor
					}
				}
			}
		}
		scope:actor = { # Some early filtering for the AI to focus it towards fruitful seductions
			trigger_if = {
				limit = { is_ai = yes }
				trigger_if = { # Deviants will seduce anyone
					limit = { is_deviant_trigger = yes }
					always = yes
				}
				trigger_else_if = { # It's always fine to seduce your spouse
					limit = {
						scope:recipient = { is_consort_of = scope:actor }
					}
					always = yes
				}
				trigger_else_if = { # If the target is a close family member, only certain AI's will seduce much older members
					limit = {
						ai_rationality <= -50
						is_close_family_of = scope:recipient
						OR = {
							has_trait = lustful
							has_trait = rakish
							is_incestuous_trigger = yes
							has_opinion_modifier = {
								modifier = childhood_crush
								target = scope:recipient
							}
						}
					}
					scope:recipient.age <= scope:actor.age_plus_25
				}
				trigger_else_if = { # Lustful/seduction-focused characters have a wider range
					limit = {
						OR = {
							has_trait = lustful
							has_trait = rakish
							has_focus = intrigue_temptation_focus
						}
					}
					OR = {
						scope:recipient.age <= scope:actor.age_plus_10
						AND = { # Seducing your vassals/liege/realm priest is good realm management, AND drama!
							has_focus = intrigue_temptation_focus
							OR = {
								scope:recipient = { is_vassal_of = scope:actor }
								liege ?= scope:recipient
								scope:recipient = {
									is_theocratic_lessee = yes
									is_courtier_of = scope:actor
								}
							}
						}
					}
					trigger_if = { # The AI should focus on bastard-producing seductions, it's more dramatic
						limit = {
							is_male = yes
							scope:recipient = { is_female = yes }
						}
						scope:recipient.age <= scope:recipient.marriage_female_fertility_cutoff_age_value
					}
				}
				trigger_else_if = { # Male characters with no children that are seducing women want to produce bastards
					limit = {
						is_male = yes
						scope:recipient = { is_female = yes }
						NOT = {
							has_inheritable_children = { TOTAL = 1 PREFER = yes }
						}
					}
					scope:recipient.age <= scope:actor.age_plus_5
					scope:recipient.age <= scope:recipient.marriage_female_fertility_cutoff_age_value
				}
				trigger_else = { # Otherwise, try to not seduce with *too* large an age gap
					scope:recipient.age <= scope:actor.age_plus_5
					scope:recipient.age >= scope:actor.age_minus_10
				}
			}
			trigger_if = {
				limit = { is_ai = yes }
				might_cheat_on_every_partner_trigger = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOT = { is_at_war_with = scope:recipient }
			can_start_scheme = {
				type = seduce
				target_character = scope:recipient
			}
		}
		trigger_if = {
			limit = {
				scope:recipient = { exists = primary_spouse }
			}
			scope:recipient = { primary_spouse = { NOT = { has_strong_hook = scope:actor } } }
		}
		#limit range for landless adventurers
		trigger_if = {
			limit = {
				scope:actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:actor
			}
		}
	}

	desc = scheme_interaction_tt_seduce_approved

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = seduce_interaction_notification

				left_icon = scope:actor
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = seduce
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}

				seduce_interaction_stress_effect = yes
			}
		}
		scope:actor = {
			if = {
				limit = {
					NOT = { is_attracted_to_gender_of = scope:recipient }
				}
				custom_tooltip = scheme_interaction_tt_wrong_gender_no_lover
			}
		}
	}

	ai_potential = {
		is_adult = yes
		# seduction is for the young, excepting only deviants, the lustful, and the ambitious
		OR = {
			is_old_age_or_not_have_children = no
			is_deviant_trigger = yes
			has_trait = lustful
			has_trait = ambitious
		}
		NOR = {
			has_trait = celibate
			has_trait = chaste
			has_trait = infirm
			has_trait = incapable
			is_malformed_trigger = yes
			scheme_generic_ai_blocker_trigger = yes
			primary_title ?= {
				is_mercenary_company = yes
			}
			AND = { # No one cares about City barons
				is_lowborn = yes
				primary_title.tier <= tier_barony
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 5

		modifier = {
			add = -50
			scope:actor = {
				primary_spouse ?= { has_strong_hook = scope:actor }
			}
		}

		modifier = {
			add = 50
			scope:actor = {
				has_focus = intrigue_temptation_focus
			}
		}

		modifier = {
			add = 50
			scope:actor = {
				has_opinion_modifier = {
					modifier = childhood_crush
					target = scope:recipient
				}
			}
		}

		modifier = {
			add = 25
			exists = scope:actor.dynasty
			scope:actor.dynasty = {
				has_dynasty_perk = fp1_adventure_legacy_2
			}
		}

		modifier = { # Focus on befriending if that's the path you've chosen
			add = -50
			scope:actor = {
				has_perk = befriend_perk
			}
		}

		modifier = { # Non-lustful clergy tend to not seduce
			add = -25
			scope:actor = {
				OR = {
					is_clergy = yes
					has_council_position = councillor_court_chaplain
				}
				faith = {
					NOT = { has_doctrine_parameter = clergy_can_marry }
				}
				NOR = {
					has_trait = lustful
					has_focus = intrigue_temptation_focus
				}
			}
		}

		modifier = { # Seducing your unmarried courtiers is good for producing bastards, which the AI will want to do if they have few heirs
			add = 10
			scope:actor = {
				any_child = {
					count <= 1
				}
			}
			scope:recipient = {
				is_married = no
				is_betrothed = no
				fertility > low_fertility
				OR = {
					is_courtier_of = scope:actor
					is_pool_guest_of = scope:actor
				}
				OR = {
					age < 30
					fertility >= high_fertility
					is_attractive_trigger = yes
				}
				NOT = { is_unattractive_trigger = yes }
			}
		}

		modifier = { # Lustful
			add = 30
			scope:actor = {
				has_trait = lustful
			}
		}

		modifier = { # ( ͡° ͜ʖ ͡°)
			add = 50
			scope:actor = {
				is_close_or_extended_family_of = scope:recipient
				is_deviant_trigger = yes
			}
			scope:recipient = {
				OR = {
					is_deviant_trigger = yes
					has_trait = lustful
				}
			}
		}

		modifier = {
			add = 25
			scope:actor = {
				is_close_or_extended_family_of = scope:recipient
				is_deviant_trigger = yes
			}
			scope:recipient = {
				NOR = {
					is_deviant_trigger = yes
					has_trait = lustful
				}
			}
		}

		modifier = { # Close/Extended family in faith with divine marriage
			add = 50
			scope:actor = {
				is_close_or_extended_family_of = scope:recipient
				faith = { has_doctrine = tenet_divine_marriage }
			}
		}

		modifier = { # Seducing the spouse of your rival is good drama...
			add = 25
			scope:recipient = {
				primary_spouse ?= {
					OR = {
						has_relation_rival = scope:actor
						has_relation_nemesis = scope:actor
					}
				}
			}
		}

		modifier = { # Close family
			add = -20
			scope:actor = {
				NOR = {
					has_trait = lustful
					has_trait = arbitrary
					is_deviant_trigger = yes
					faith = { has_doctrine = tenet_divine_marriage }
					has_perk = subtle_desire_perk
				}
			}
			scope:recipient = {
				is_close_family_of = scope:actor
			}
		}

		modifier = { # Seducing someone's spouse is not a clever prospect for most characters, so lowering the attractiveness a bit
			add = -20
			scope:recipient = {
				is_married = yes
				NOT = {
					primary_spouse = scope:actor
				}
			}
			scope:actor = {
				NOR = {
					has_trait = lustful
					has_focus = intrigue_temptation_focus
				}
			}
		}

		modifier = { # Try to avoid aggressive seduction unless you're geared for it
			add = -10
			scope:actor = {
				NOR = {
					has_trait = lustful
					has_focus = intrigue_temptation_focus
				}
			}
			scope:recipient = {
				is_lowborn = no
				NOT = { is_pool_guest_of = scope:actor }
			}
		}

		modifier = { # Struggle
			scope:recipient = {
				any_character_struggle = {
					involvement = involved
					is_struggle_type = iberian_struggle
					phase_has_catalyst = catalyst_became_friend_lover_with_character
				}
			}
			scope:actor = {
				any_character_struggle = {
					involvement = involved
					is_struggle_type = iberian_struggle
					phase_has_catalyst = catalyst_became_friend_lover_with_character
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						scope:actor = {
							has_character_flag = agenda_towards_deescalation
							trait_compatibility = {
								target = scope:recipient
								value >= low_positive_trait_compatibility
							}
						}
						scope:recipient = {
							has_character_flag = agenda_towards_deescalation
						}
					}
					add = 50
				}
				else_if = {
					limit = {
						scope:actor = {
							has_character_flag = agenda_towards_escalation
						}
					}
					add = -200
				}
				else = {
					add = 5
				}
			}
		}

		modifier = { # Personality traits in common
			factor = 1.1
			scope:recipient = {
				number_of_personality_traits_in_common = {
					target = scope:actor
					value >= 1
				}
			}
		}

		modifier = {
			factor = 1.25
			scope:recipient = {
				number_of_personality_traits_in_common = {
					target = scope:actor
					value >= 2
				}
			}
		}

		modifier = {
			factor = 1.5
			scope:recipient = {
				number_of_personality_traits_in_common = {
					target = scope:actor
					value >= 3
				}
			}
		}

		modifier = { # Recipient is landed
			factor = 1.5
			scope:recipient = {
				is_playable_character = yes
			}
		}

		modifier = { # Target the player less aggressively
			factor = 0.5
			scope:recipient = {
				OR = {
					is_ai = no
					any_consort = {
						is_ai = no
					}
				}
			}
		}

		modifier = {
			factor = 1.25
			scope:recipient = {
				has_trait = lustful
			}
		}

		modifier = { # Men avoid targeting women who are older unless they're physically attractive
			factor = 0.5
			scope:actor = { is_female = no }
			scope:recipient = {
				is_female = yes
				NOT = { has_trait = beauty_good }
				OR = {
					age >= 30
					age >= scope:actor.age
				}
			}
		}

		modifier = { # Men really avoid targeting women who are more than 10 years older
			factor = 0.1
			scope:actor = { is_female = no }
			scope:recipient = {
				is_female = yes
				age >= scope:actor.age_plus_10
			}
		}

		modifier = { # Older women don't tend to seduce unless they're lustful or deviants
			factor = 0.1
			scope:actor = {
				is_female = yes
				age > define:NChildbirth|MAX_FEMALE_REPRODUCTION_AGE
				NOR = {
					has_trait = lustful
					is_deviant_trigger = yes
					faith = { has_doctrine = tenet_carnal_exaltation }
				}
			}
		}

		modifier = { # Women don't tend to seduce much younger men unless they're deviants
			factor = 0.1
			scope:actor = {
				is_female = yes
				NOT = { is_deviant_trigger = yes }
			}
			scope:recipient = {
				age <= scope:actor.age_minus_25
			}
		}

		modifier = { # Only deviants and those with low zeal will target nuns and clergy members
			factor = 0.1
			scope:actor = {
				NOR = {
					is_deviant_trigger = yes
					ai_zeal <= low_negative_ai_value
					faith = { has_doctrine = tenet_carnal_exaltation }
					faith = { has_doctrine = doctrine_clerical_marriage_allowed }
				}
			}
			scope:recipient = {
				OR = {
					is_clergy = yes
					has_council_position = councillor_court_chaplain
				}
			}
		}
		
		modifier = { # Only the bold try to seduce the wives or children of those who can jail them
			factor = 0.1
			scope:actor = {
				ai_boldness < 20
			}
			scope:recipient = {
				OR = {
					AND = {
						exists = primary_spouse
						primary_spouse = { is_liege_or_above_of = scope:actor }
					}
					any_parent = {
						is_alive = yes
						is_liege_or_above_of = scope:actor
					}
				}
			}
		}
		
		modifier = { # Recipient doesn't like the actor
			factor = {
				value = 0.5
				if = {
					limit = {
						scope:recipient = {
							opinion = {
								target = scope:actor
								value < -15
							}
						}
					}
					value = 0
				}
				if = {
					limit = {
						scope:recipient = {
							opinion = {
								target = scope:actor
								value < -5
							}
						}
					}
					value = 0.1
				}
			}
			scope:recipient = {
				opinion = {
					target = scope:actor
					value < 5
				}
			}
		}
		
		modifier = { # Actor doesn't like the recipient
			factor = {
				value = 0.5
				if = {
					limit = {
						scope:actor = {
							opinion = {
								target = scope:recipient
								value < -15
							}
						}
					}
					value = 0
				}
				if = {
					limit = {
						scope:actor = {
							opinion = {
								target = scope:recipient
								value < -5
							}
						}
					}
					value = 0.1
				}
			}
			scope:actor = {
				opinion = {
					target = scope:recipient
					value < 5
				}
			}
		}

		modifier = { # Multiple opposing traits
			factor = 0.1
			scope:recipient = {
				number_of_opposing_personality_traits = {
					target = scope:actor
					value >= 1
				}
			}
		}

		modifier = { # Recipient is lowborn
			factor = 0.75
			scope:recipient = {
				is_lowborn = yes
			}
		}
		
		modifier = { # Barons tend to not seduce anyone landed above them
			factor = 0.1
			scope:actor = {
				is_playable_character = yes
				primary_title = {
					tier = tier_barony
				}
			}
			scope:recipient = {
				OR = {
					AND = {
						is_playable_character = yes
						primary_title = {
							tier > tier_barony
						}
					}
					any_spouse = {
						is_playable_character = yes
						primary_title = {
							tier > tier_barony
						}
					}
				}
			}
		}
		
		modifier = { # Recipient is already being seduced
			factor = 0.2
			scope:recipient = {
				is_ai = yes
				any_targeting_scheme = {
					scheme_type = seduce
				}
			}
		}
		
		modifier = { # Recipient is chaste
			factor = 0.1
			scope:recipient = {
				has_trait = chaste
			}
		}
		
		modifier = { # Recipient is unattractive but landed
			factor = 0.5
			scope:recipient = {
				is_landed = yes
				is_unattractive_trigger = yes
			}
		}
		
		modifier = { # Recipient is unattractive and unlanded
			factor = 0.1
			scope:recipient = {
				is_landed = no
				is_unattractive_trigger = yes
			}
		}
		
		modifier = { # Positive beauty traits
			factor = 1.25
			scope:recipient = {
				has_trait = beauty_good_1
			}
		}
		modifier = {
			factor = 1.5
			scope:recipient = {
				has_trait = beauty_good_2
			}
		}
		modifier = {
			factor = 2
			scope:recipient = {
				has_trait = beauty_good_3
			}
		}
		
		modifier = { # Positive physique traits
			factor = 1.1
			scope:recipient = {
				has_trait = physique_good_1
			}
		}
		modifier = {
			factor = 1.25
			scope:recipient = {
				has_trait = physique_good_2
			}
		}
		modifier = {
			factor = 1.5
			scope:recipient = {
				has_trait = physique_good_3
			}
		}

		modifier = { # Recipient has a soulmate
			factor = 0
			scope:recipient = {
				num_of_relation_soulmate > 0
			}
		}

		modifier = { # Actor is unattractive
			factor = 0.5
			scope:actor = {
				is_unattractive_trigger = yes
			}
		}

		modifier = { # Recipient is malformed
			factor = 0
			scope:recipient = {
				is_malformed_trigger = yes
			}
		}

		modifier = { # Family Feud
			add = 50
			scope:actor = {
				house_has_feud_relation_with_trigger = { TARGET = scope:recipient }
			}
		}

		modifier = { # Recipient is married and unreceptive
			factor = {
				value = 0.5
				# prevent AI without high Intrigue from even attempting seductions on those who will not cheat
				if = {
					limit = {
						scope:actor = {
							is_ai = yes
							intrigue < 20
						}
					}
					value = 0
				}
			}
			scope:recipient = {
				OR = {
					is_married = yes
					is_betrothed = yes
				}
				NOT = { is_consort_of = scope:actor }
				might_cheat_on_every_partner_trigger = no
			}
		}

		modifier = {
			factor = 0
			scope:actor = {
				NOT = {
					willing_to_take_character_as_lover = { LOVER = scope:recipient }
				}
			}
		}
		
		cc_seduce_ai_modifier = yes

		ttd_major_distance_ai_modifier = yes
	}
}

court_interaction = {
	icon = icon_scheme_romance
	category = interaction_category_friendly

	send_name = START_SCHEME

	interface_priority = 40
	scheme = courting
	ignores_pending_interaction_block = yes

	ai_targets = {
		ai_recipients = spouses
		ai_recipients = neighboring_rulers
	}

	ai_targets = {
		ai_recipients = vassals
		max = 5
	}

	ai_targets = {
		ai_recipients = peer_vassals
		max = 5
	}

	ai_targets = {
		ai_recipients = family
		max = 5
	}

	ai_targets = {
		ai_recipients = realm_characters
		max = 30
	}

	ai_target_quick_trigger = {
		adult = yes
		attracted_to_owner = yes
		owner_attracted = yes
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 72
		duchy = 36
		kingdom = 12
		empire = 12
		hegemony = 12
	}

	is_shown = {
		scope:actor != scope:recipient
		scope:recipient = { is_adult = yes }
		scope:actor = { is_adult = yes }
		scope:actor = { is_attracted_to_gender_of = scope:recipient }
		scope:recipient = { is_attracted_to_gender_of = scope:actor }

		scope:actor = { # Some early filtering for the AI to focus it towards fruitful romance
			trigger_if = {
				limit = {
					is_ai = yes
				}
				trigger_if = { # It's always fine to romance your spouse
					limit = {
						scope:recipient = { is_consort_of = scope:actor }
					}
				}
				trigger_else_if = { # If the target is a close family member, only certain AI's will romance much older members
					limit = {
						ai_rationality <= -50
						is_close_family_of = scope:recipient
						OR = {
							is_incestuous_trigger = yes
							has_opinion_modifier = {
								modifier = childhood_crush
								target = scope:recipient
							}
						}
					}
					scope:recipient.age <= scope:actor.age_plus_25
				}
				trigger_else_if = { # Lustful/seduction-focused characters have a wider range
					limit = {
						OR = {
							has_trait = lustful
							has_trait = rakish
							has_focus = intrigue_temptation_focus
						}
					}
					OR = {
						scope:recipient.age <= scope:actor.age_plus_10
						AND = { # Romancing your vassals/liege/realm priest is good realm management, AND drama!
							has_focus = intrigue_temptation_focus
							OR = {
								scope:recipient = {
									is_vassal_of = scope:actor
								}
								liege ?= scope:recipient
								scope:recipient = {
									is_theocratic_lessee = yes
									is_courtier_of = scope:actor
								}
							}
						}
					}
					trigger_if = { # The AI should focus on bastard-producing romances, it's more dramatic
						limit = {
							is_male = yes
							scope:recipient = {
								is_female = yes
							}
						}
						scope:recipient.age <= scope:recipient.marriage_female_fertility_cutoff_age_value
					}
				}
				trigger_else_if = { # Male characters with no children that are romancing women want to produce children
					limit = {
						is_male = yes
						scope:recipient = { is_female = yes }
						any_child = {
							count <= 1
						}
					}
					scope:recipient.age <= scope:actor.age_plus_5
					scope:recipient.age <= scope:recipient.marriage_female_fertility_cutoff_age_value
				}
				trigger_else = { # Otherwise, try to not seduce with *too* large an age gap
					scope:recipient.age <= scope:actor.age_plus_5
					scope:recipient.age >= scope:actor.age_minus_10
				}
			}
			trigger_if = {
				limit = { is_ai = yes }
				might_cheat_on_every_partner_trigger = yes
			}
		}	
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOT = { is_at_war_with = scope:recipient }
			can_start_scheme = {
				type = courting
				target_character = scope:recipient
			}
		}
		#limit range for landless adventurers
		trigger_if = {
			limit = {
				scope:actor = {
					has_government = landless_adventurer_government
				}
			}
			#Has to be used instead of diplo range checks in laamp to landed interactions
			ep3_laamp_diplo_range_trigger = {
				TARGET = scope:recipient
				LAAMP = scope:actor
			}
		}
	}

	desc = scheme_interaction_tt_courtship_approved

	on_accept = {
		scope:actor = {
			# If you already have a soulmate, they get very mad
			every_relation = {
				type = soulmate
				limit = { soulmate_relation_is_exclusive_trigger = yes }

				add_opinion = {
					modifier = betrayed_our_promise
					target = scope:actor
				}
			}
		}
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = court_interaction_notification

				left_icon = scope:actor
				right_icon = scope:recipient

				begin_scheme_basic_effect = {
					SCHEME_TYPE = courting
					TARGET_TYPE = target_character
					TARGET_SCOPE = scope:recipient
				}

				show_as_tooltip = {
					# If you already have a soulmate, they get very mad
					every_relation = {
						type = soulmate
						limit = { soulmate_relation_is_exclusive_trigger = yes }

						add_opinion = {
							modifier = betrayed_our_promise
							target = scope:actor
						}
					}
				}
			}
		}
		scope:recipient = {
			if = {
				limit = {
					is_ai = no
				}
				add_character_flag = {
					flag = courting_cooldown
					years = 5
				}
			}
		}
	}

	ai_potential = {
		is_adult = yes
		# romance is for the young, excepting only those pursuing chivalry
		OR = {
			is_old_age_or_not_have_children = no
			has_focus = martial_chivalry_focus
		}
		trigger_if = {
			limit = {
				NOR = {
					culture = { has_cultural_parameter = ai_romance_scheme_increase }
					AND = {
						has_character_flag = agenda_towards_deescalation
						any_character_struggle = {
							involvement = involved
							is_struggle_type = iberian_struggle
							phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
						}
					}
				}
			}
			ai_honor > 0
			ai_compassion > 0
		}
		NOR = {
			has_trait = celibate
			has_trait = chaste
			has_trait = incapable
			has_trait = infirm
			is_malformed_trigger = yes
			num_of_relation_soulmate > 0
			scheme_generic_ai_blocker_trigger = yes
			AND = { # No one cared about City barons
				is_lowborn = yes
				primary_title.tier <= tier_barony
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 0

		modifier = { # Increase chance of romancing one's spouse
			add = {
				value = 3
				if = {
					limit = {
						scope:actor = { age < 25 }
						scope:recipient = { age < 25 }
					}
					add = 2
				}
				if = {
					limit = {
						scope:recipient = { is_female = no }
						scope:actor = {
							is_female = yes
							age < marriage_female_fertility_cutoff_age_value
							NOT = { any_child = { is_alive = yes } }
						}
					}
					add = 2
				}
				if = {
					limit = {
						scope:recipient = { is_female = no }
						scope:actor = {
							is_female = yes
							age >= marriage_female_fertility_cutoff_age_value
						}
					}
					add = -2
				}
				if = {
					limit = {
						scope:actor = {
							is_female = no
							NOT = { any_child = { is_alive = yes } }
						}
						scope:recipient = {
							is_female = yes
							age < marriage_female_fertility_cutoff_age_value
						}
					}
					add = 2
				}
				if = {
					limit = {
						scope:actor = { is_female = no }
						scope:recipient = {
							is_female = yes
							age >= marriage_female_fertility_cutoff_age_value
						}
					}
					add = -2
				}
			}
			scope:recipient = {
				exists = primary_spouse
				primary_spouse = scope:actor
				NOR = {
					has_trait = pregnant
					has_any_illness = yes
					has_trait = adulterer
					has_trait = fornicator
				}
			}
			scope:actor = {
				opinion = {
					target = scope:recipient
					value >= 20
				}
				NOR = {
					has_trait = pregnant
					has_any_illness = yes
					has_trait = adulterer
					has_trait = fornicator
				}
			}
		}

		modifier = { # Struggle
			scope:actor = {
				any_character_struggle = {
					involvement = involved
					is_struggle_type = iberian_struggle
					phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
				}
			}
			scope:recipient = {
				any_character_struggle = {
					involvement = involved
					is_struggle_type = iberian_struggle
					phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
				}
			}
			add = {
				value = 0
				if = {
					limit = {
						scope:actor = {
							has_character_flag = agenda_towards_deescalation
						}
						scope:recipient = {
							has_character_flag = agenda_towards_deescalation
						}
					}
					add = 25
				}
				else_if = {
					limit = {
						scope:actor = {
							has_character_flag = agenda_towards_escalation
						}
					}
					add = -200
				}
				else = {
					add = 5
				}
			}
		}
		
		modifier = { # Motivate AI's to use it on catalyst providers exclusively
			add = -50
			scope:actor = {
				any_character_struggle = {
					involvement = involved
					is_struggle_type = iberian_struggle
					phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
				}
			}
			scope:recipient = {
				NOT = {
					any_character_struggle = {
						involvement = involved
						is_struggle_type = iberian_struggle
						phase_has_catalyst = catalyst_became_best_friend_soulmate_with_very_important_character
					}
				}
			}
		}

		opinion_modifier = {
			opinion_target = scope:recipient
			multiplier = 0.4
		}

		compatibility_modifier = {
			compatibility_target = scope:recipient
			multiplier = 1
			max = court_scheme_max_compatability_value
		}

		modifier = { # Chivalric culture
			factor = 25
			culture = { has_cultural_parameter = ai_romance_scheme_increase }
		}

		modifier = { # Martial chivalry focus
			factor = 25
			has_focus = martial_chivalry_focus
		}
		
		modifier = { # They are already our lover
			add = 20
			has_relation_lover = scope:recipient
		}
		
		modifier = { # Recipient is childhood crush
			add = 50
			scope:actor = {
				has_opinion_modifier = {
					modifier = childhood_crush
					target = scope:recipient
				}
			}
		}
		
		modifier = { # Clergy tend to not romance
			add = -25
			scope:actor = {
				OR = {
					is_clergy = yes
					has_council_position = councillor_court_chaplain
				}
				faith = {
					NOT = { has_doctrine_parameter = clergy_can_marry }
				}
			}
		}
		
		modifier = { # Recipient is close family
			add = -50
			scope:actor = {
				is_close_family_of = scope:recipient
				NOR = {
					is_deviant_trigger = yes
					has_trait = lustful
				}
			}
		}

		modifier = { # Recipient is landed or a landed noble's spouse
			factor = 3
			scope:recipient = {
				OR = {
					is_playable_character = yes
					any_spouse = { is_playable_character = yes }
				}
			}
		}

		modifier = { # Positive beauty traits
			factor = 1.25
			scope:recipient = {
				has_trait = beauty_good_1
			}
		}
		modifier = {
			factor = 1.5
			scope:recipient = {
				has_trait = beauty_good_2
			}
		}
		modifier = {
			factor = 2
			scope:recipient = {
				has_trait = beauty_good_3
			}
		}

		modifier = { # Positive Physique traits
			factor = 1.1
			scope:recipient = {
				has_trait = physique_good_1
			}
		}
		modifier = {
			factor = 1.25
			scope:recipient = {
				has_trait = physique_good_2
			}
		}
		modifier = {
			factor = 1.5
			scope:recipient = {
				has_trait = physique_good_3
			}
		}

		modifier = { # Men avoid targeting women who are older unless they're physically attractive
			factor = 0.5
			scope:actor = { is_female = no }
			scope:recipient = {
				is_female = yes
				NOT = { has_trait = beauty_good }
				OR = {
					age >= 30
					age >= scope:actor.age
				}
			}
		}

		modifier = { # Men really avoid targeting women who are more than 10 years older
			factor = 0.1
			scope:actor = { is_female = no }
			scope:recipient = {
				is_female = yes
				age >= scope:actor.age_plus_10
			}
		}

		modifier = { # Older women don't tend to romance unless they're lustful or deviants
			factor = 0.1
			scope:actor = {
				is_female = yes
				age > define:NChildbirth|MAX_FEMALE_REPRODUCTION_AGE
				NOR = {
					has_trait = lustful
					is_deviant_trigger = yes
					faith = { has_doctrine = tenet_carnal_exaltation }
				}
			}
		}

		modifier = { # Women don't tend to romance much younger men unless they're deviants
			factor = 0.1
			scope:actor = {
				is_female = yes
				NOT = { is_deviant_trigger = yes }
			}
			scope:recipient = {
				age <= scope:actor.age_minus_25
			}
		}

		modifier = { # Only deviants and those with low zeal will target nuns and clergy members
			factor = 0.1
			scope:actor = {
				NOR = {
					is_deviant_trigger = yes
					ai_zeal <= low_negative_ai_value
					faith = { has_doctrine = tenet_carnal_exaltation }
					faith = { has_doctrine = doctrine_clerical_marriage_allowed }
				}
			}
			scope:recipient = {
				OR = {
					is_clergy = yes
					has_council_position = councillor_court_chaplain
				}
			}
		}

		modifier = { # Recipient doesn't like the actor
			factor = {
				value = 0.5
				if = {
					limit = {
						scope:recipient = {
							opinion = {
								target = scope:actor
								value < -20
							}
						}
					}
					value = 0
				}
				else_if = {
					limit = {
						scope:recipient = {
							opinion = {
								target = scope:actor
								value < 0
							}
						}
					}
					value = 0.1
				}
			}
			scope:recipient = {
				opinion = {
					target = scope:actor
					value < 20
				}
			}
		}

		modifier = { # Recipient is married and unreceptive
			factor = 0.5
			scope:recipient = {
				OR = {
					is_married = yes
					is_betrothed = yes
				}
				NOT = { is_consort_of = scope:actor }
				might_cheat_on_every_partner_trigger = no
			}
		}

		modifier = { # Recipient is currently being courted
			factor = 0.2
			scope:recipient = {
				is_ai = yes
				any_targeting_scheme = {
					scheme_type = courting
				}
			}
		}
		
		modifier = { # Recipient already has a soulmate
			factor = 0.1
			scope:recipient = { any_relation = { type = soulmate } }
		}

		modifier = { # Lowborn recipient
			factor = 0.1
			scope:recipient = {
				is_lowborn = yes
				NOT = { is_consort_of = scope:actor }
			}
		}
		
		modifier = { # Recipient is unattractive
			factor = 0.1
			scope:recipient = {
				is_unattractive_trigger = yes
			}
		}
			
		modifier = { # Actor is unattractive
			factor = 0.5
			scope:actor = {
				is_unattractive_trigger = yes
			}
		}
		
		modifier = { # Recipient is malformed
			factor = 0
			scope:recipient = {
				is_malformed_trigger = yes
			}
		}
		
		cc_court_ai_modifier = yes
		
		ttd_major_distance_ai_modifier = yes
	}
}

