﻿lay_with_man_interaction = {
	category = interaction_category_friendly
	use_diplomatic_range = yes

	ai_maybe = yes
	ai_min_reply_days = 1
	ai_max_reply_days = 2
	popup_on_receive = yes
	pause_on_receive = yes

	desc = lay_with_man_interaction_desc

	on_decline_summary = laid_with_decline_summary

	is_shown = {
		NAND = {
			scope:actor = {	is_female = no }
			scope:recipient = { is_female = no }
		}
		scope:actor = {
		    is_adult = yes
			is_imprisoned = no
			is_attracted_to_gender_of = scope:recipient
			is_commanding_army = no
		}
		scope:recipient = {
			is_female = no
			NOT = {
				this = scope:actor
			}
			AND = {
				is_at_same_location = scope:actor
				OR = {
					exists = liege
					is_pool_guest_of = scope:actor
					is_pool_guest_of = scope:actor.location.county.holder
				}
			}
			OR = {
				is_adult = yes
				AND = {
					is_adult = no
					is_consort_of = scope:actor
				}
			}
			is_imprisoned = no
			is_commanding_army = no
		}
		#Fertility/Pregnancy
		scope:actor = {
			can_have_children = yes
			NOT = { has_trait = pregnant }
			fertility > 0
		}

		scope:recipient = {
			can_have_children = yes
			fertility > 0
		}
	}

	is_valid_showing_failures_only = {
		trigger_if = {
			limit = {
				has_game_rule = LWYR_trait_limits_on
			}
			custom_description = {
				text = "unwilling_to_ask"
				scope:actor = {
					is_willing_to_ask_trigger = {
						ACTOR = scope:actor
						TARGET = scope:recipient
					}
				}
			}
		}

		#AGE CUTOFFS
		trigger_if = {
			limit = {
				NOT = {
					has_game_rule = LWYR_trait_limits_off
				}
			}
			custom_description = {
				text = does_not_want_them_desc
				OR = {
					scope:recipient.age <= define:NCharacter|MALE_ATTRACTION_CUTOFF_AGE
					scope:recipient.age <= scope:actor.age_plus_20	
					scope:recipient = { attraction >= 30 }
					scope:actor = {
						OR = {
							has_trait = lustful
							AND = {
								has_trait = eccentric
								diplomacy >= decent_skill_rating
							}
							has_trait = curious
						}
					}
				}
			}
		}


		scope:actor = {
			custom_description = {
				text = has_attempted_sex_desc
				NOT = {
					has_character_flag = has_attempted_sex
				}
			}
		}

		scope:recipient = {
			custom_description = {
				text = does_not_want_you_desc
				NOT = { has_sexuality = none }
				# OR = {
				# 	is_attracted_to_gender_of = scope:actor
				# 	is_consort_of = scope:actor
				# }
				NOR = {
					has_opinion_modifier = {
						target = scope:actor
						modifier = laid_with_led_on
					}
					has_opinion_modifier = {
						target = scope:actor
						modifier = laid_with_success_opinion
					}
					has_opinion_modifier = {
						target = scope:actor
						modifier = laid_with_midsuccess_opinion
					}
					has_opinion_modifier = {
						target = scope:actor
						modifier = laid_with_unsuccess_opinion
					}
					has_opinion_modifier = {
						target = scope:actor
						modifier = laid_with_OD_opinion
					}
				}
			}
		}
	
		#Other
		trigger_if = {
			limit = {
				NOT = {
					has_game_rule = LWYR_restrictions_off
				}
				scope:actor = {
					is_female = yes
				}
			}
			scope:actor = {
				custom_description = {
					text = too_soon_after_child_desc
					NOR = {
						has_character_flag = LWYR_restricted_sex
						any_child = {
							is_alive = yes
							age < 1
						}
					}
				}
			}
		}
	}

	#Use hook
	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
		}
	}

	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
		}
		flag = hook
		localization = SCHEME_HOOK
	}

	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_options_exclusive = no


	ai_accept = {
		base = 0 #added 75 for maybe
		modifier = { #The Ways of Our Culture
			desc = lay_with_partner_aibehavior_norms_tt
			trigger = {
				scope:recipient = { NOT = { is_consort_of = scope:actor } }
				OR = {
					NOT = { is_close_family_of = scope:actor }
					has_trait = incestuous
					NOT = { trait_is_criminal_in_faith_trigger = { TRAIT = incestuous FAITH = scope:actor.faith GENDER_CHARACTER = scope:recipient } }
				}
			}
			add = {
				value = 0
				#Lax Cultures
				if = {
					limit = {
						scope:actor = {
							classical_relations_culture_trigger = yes							
						}
					}
					add = 8
				}
				if = {
					limit = {
						scope:recipient = {
							classical_relations_culture_trigger = yes							
						}
					}
					add = 21
				}
				#Concubine Cultures
				if = {
					limit = {
						scope:actor = {
							classical_relations_culture_trigger = no							
							OR = {
								culture = { has_cultural_tradition = tradition_concubines }
								faith = { has_doctrine = doctrine_concubines }
							}
						}
					}
					add = 5
				}
				if = {
					limit = {
						scope:recipient = {
							classical_relations_culture_trigger = no							
							OR = {
								culture = { has_cultural_tradition = tradition_concubines }
								faith = { has_doctrine = doctrine_concubines }
							}
						}
					}
					add = 10
				}
				#Polygamous Cultures
				if = {
					limit = {
						scope:actor = {
							classical_relations_culture_trigger = no							
							OR = {
								culture = { has_cultural_tradition = tradition_polygamous }
								faith = { has_doctrine = doctrine_polygamy }
							}
						}
					}
					add = 3
				}
				if = {
					limit = {
						scope:recipient = {
							classical_relations_culture_trigger = no							
							OR = {
								culture = { has_cultural_tradition = tradition_polygamous }
								faith = { has_doctrine = doctrine_polygamy }
							}
						}
					}
					add = 6
				}
				# Government Views
				if = {
					limit = {
						scope:actor = {
							government_has_flag = government_is_tribal
						}
					}
					add = 2
				}
				if = {
					limit = {
						scope:recipient = {
							government_has_flag = government_is_tribal
						}
					}
					add = 4
				}
				if = {
					limit = {
						scope:actor = {
							government_has_flag = government_is_landless_adventurer
						}
					}
					add = 1
				}
				if = {
					limit = {
						scope:recipient = {
							government_has_flag = government_is_landless_adventurer
						}
					}
					add = 2
				}
				# Cultural Eras
				if = {
					limit = {
						OR = {
							scope:actor = {	culture = { has_cultural_era_or_later = culture_era_early_medieval } }
							scope:recipient = {	culture = { has_cultural_era_or_later = culture_era_early_medieval } }
						}
					}
					add = -5
				}
				if = {
					limit = {
						OR = {
							scope:actor = {	culture = { has_cultural_era_or_later = culture_era_high_medieval } }
							scope:recipient = {	culture = { has_cultural_era_or_later = culture_era_high_medieval } }
						}
					}
					add = -5
				}
				if = {
					limit = {
						OR = {
							scope:actor = {	culture = { has_cultural_era_or_later = culture_era_late_medieval } }
							scope:recipient = {	culture = { has_cultural_era_or_later = culture_era_late_medieval } }
						}
					}
					add = -5
				}
			}
		}

		modifier = {
			trigger = {
				scope:recipient = {
					NOR = {
						is_consort_of = scope:actor
						is_close_family_of = scope:actor
						previous_partner_trigger = {
							ACTOR = scope:actor
							TARGET = scope:recipient
						}
					}
				}
			}
			add = {
				add = {
					value = scope:actor.diplomacy
					subtract = medium_skill_rating
					multiply = 2
					min = 0
				}
				add = {
					value = scope:actor.learning
				 	subtract = medium_skill_rating
	 				multiply = 0.5
					min = 0
				}
				add = {
					value = scope:actor.attraction
					multiply = 0.75
				}
				min = 0
				max = 30
			}
			desc = lay_with_partner_aibehavior_conversation_tt
		}

		# HOOK
		modifier = { #Weak hook
			scope:hook = yes
			add = 25
			scope:actor = { NOT = { has_strong_hook = scope:recipient } }
			desc = SCHEME_WEAK_HOOK_USED
		}

		opinion_modifier = { #Compare Opinion modifier.
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 0.55
		}

		# OPINION INFLUENCE
		modifier = {
			add = intimidated_external_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
			desc = INTIMIDATED_REASON
		}
		modifier = {
			add = cowed_external_reason_value
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
			desc = COWED_REASON
		}

		modifier = { # They are Married
			desc = lay_with_partner_aibehavior_marriedthey_tt
			trigger = {
				scope:recipient = {
					AND = {
						OR = {
							is_married = yes
							is_concubine = yes
						}
						NOT = {
							is_consort_of = scope:actor
						}
					}
				}
			}	
			add = {
				value = -30
				if = {
					limit = {
						scope:recipient = {
							OR = {
								classical_relations_culture_trigger = yes							
								culture = { has_cultural_tradition = tradition_concubines }
								faith = { has_doctrine = doctrine_concubines }
								culture = { has_cultural_tradition = tradition_polygamous }
								faith = { has_doctrine = doctrine_polygamy }
							}
						}
					}
					multiply = 0.75
				}
				if = {
					limit = {
						scope:recipient = {
							OR = {
								culture = { has_cultural_tradition = tradition_polygamous }
								faith = { has_doctrine = doctrine_polygamy }
							}
						}
					}
					multiply = 0.67
				}
			}
		}

		modifier = { # I am Married
			desc = lay_with_partner_aibehavior_marriedme_tt
			trigger = {
				scope:actor = {
					AND = {
						OR = {
							is_married = yes
							is_concubine = yes
						}
						NOT = {
							is_consort_of = scope:recipient
						}
					}
				}
			}	
			add = {
				value = -25
				if = {
					limit = {
						scope:actor = {
							OR = {
								classical_relations_culture_trigger = yes							
								culture = { has_cultural_tradition = tradition_concubines }
								faith = { has_doctrine = doctrine_concubines }
								culture = { has_cultural_tradition = tradition_polygamous }
								faith = { has_doctrine = doctrine_polygamy }
							}
						}
					}
					multiply = 0.75
				}
				if = {
					limit = {
						scope:actor = {
							OR = {
								culture = { has_cultural_tradition = tradition_polygamous }
								faith = { has_doctrine = doctrine_polygamy }
							}
						}
					}
					multiply = 0.67
				}
			}
		}

		modifier = { # Your are both young and single
			desc = lay_with_partner_aibehavior_single_tt
			AND = {
				scope:actor = {
					AND = {
						age <= 25
						is_married = no
						is_betrothed = no
						is_concubine = no
					}
				}
				scope:recipient = {
					AND = {
						age <= 25
						is_married = no
						is_betrothed = no
						is_concubine = no
					}
				}
			}
			add = 20
		}

		opinion_modifier = { #Compare Opinion of Spouse
			trigger = {
				scope:recipient = {
					is_married = yes
					NOT = {
						is_consort_of = scope:actor
					}
				}
			}
			who = scope:recipient
			opinion_target = scope:recipient.primary_spouse
			multiplier = -0.75
			desc = lay_with_partner_aibehavior_theyrespouse_tt
		}

		modifier = { # They not into you
			desc = lay_with_partner_aibehavior_gender_tt
			scope:recipient = {
				NOT = {
					is_attracted_to_gender_of = scope:actor
				}
				NOT = {
					has_sexuality = asexual
				}
			}	
			add = -50
		}

		modifier = { # They not into anybody
			desc = lay_with_partner_aibehavior_asexual_tt
			scope:recipient = {
				has_sexuality = asexual
			}	
			add = -35
		}

		modifier = { # They are young
			desc = lay_with_partner_aibehavior_youngthey_tt
			scope:recipient = {
				AND = {
					age <= 20
					age >= 18
				}
			}	
			add = 15
		}

		modifier = { # They are naive
			desc = lay_with_partner_aibehavior_naivethey_tt
			scope:recipient = {
					age <= 17
				}
			add = 10
		}

		modifier = { # Virgin
			desc = lay_with_partner_aibehavior_virgin_tt
			scope:recipient = {
				AND = {
					is_likely_virgin = yes
					NOT = {
						has_character_flag = not_virgin
					}
				}	
			}
			add = -20
		}

		modifier = { # They are bonded with you
			desc = lay_with_partner_aibehavior_spousethey_tt
			scope:recipient = {
				is_consort_of = scope:actor
			}
			add = 50
		}
		
		modifier = { # They are a secondary spouse
			desc = lay_with_partner_aibehavior_secspousethey_tt
			scope:recipient = {
				is_concubine_of = scope:actor
			}
			add = 15
		}

		modifier = { # No Heirs
			desc = lay_with_partner_aibehavior_heirs_tt
			NOT = { is_close_family_of = scope:actor }
			OR = {
				AND = {
					scope:recipient = { is_consort_of = scope:actor }
					scope:actor = {
						NOT = {
							any_child = {
								is_heir_of = scope:actor
							}
						}
					}
				}		
				scope:actor = {
					AND = {
						age > 30
						scope:actor = {
							NOT = {
								any_child = {
									is_heir_of = scope:actor
								}
							}
						}
					}	
				}	
			}
			add = 25
		}

		#Ranks and Tiers
		modifier = { # I am a higher rank
			desc = lay_with_partner_aibehavior_ranked_tt
			trigger = {
				OR = {
					scope:actor = { is_landed = yes }
					scope:actor = { is_landless_adventurer = yes }
				}
				scope:actor = {	NOT = { is_close_or_extended_family_of = scope:recipient } }
				scope:actor.highest_held_title_tier > scope:recipient.highest_held_title_tier
			}
			add = {
				value = 5
				if = {
					limit = { scope:recipient = { has_trait = ambitious } }
					add = 15
				}
				if = {
					limit = { scope:recipient = { has_trait = content } }
					add = -10
				}
				if = {
					limit = { scope:actor = { highest_held_title_tier = tier_duchy } }
					add = 5
				}
				if = {
					limit = { scope:actor = { highest_held_title_tier = tier_kingdom } }
					add = 15
				}
				if = {
					limit = { scope:actor = { highest_held_title_tier = tier_empire } }
					add = 25
				}
			}
		}

		modifier = { # They are Courtier
			desc = lay_with_partner_aibehavior_courtierthey_tt
			scope:recipient = {
				is_courtier_of = scope:actor
				NOR = {
					is_consort_of = scope:actor
					has_relation_lover = scope:actor
					has_relation_soulmate = scope:actor
				}
			}
			add = 15
		}	
		
		modifier = { # They are Guest
			desc = lay_with_partner_aibehavior_guestthey_tt
			scope:recipient = {
				NOT = { is_close_family_of = scope:actor }
				is_pool_guest_of = scope:actor
				NOR = {
					is_consort_of = scope:actor
					has_relation_lover = scope:actor
					has_relation_soulmate = scope:actor
				}
			}
			add = -10
		}
		
		
		modifier = { # They are Betrothed
			desc = lay_with_partner_aibehavior_betrothedthey_tt
			scope:recipient = {
				is_betrothed = yes
				NOT = {
					this = scope:actor.betrothed
				}
			}
			add = -15
		}	
	
		
		modifier = { # I am Betrothed
			desc = lay_with_partner_aibehavior_betrothedme_tt
			scope:actor = {
				is_betrothed = yes
				NOT = {
					this = scope:recipient.betrothed
				}
			}
			scope:recipient = {
				NOT = {
					is_consort_of = scope:actor
				}
			}
			add = -15
		}	

		modifier = { # I am Celibate
			desc = lay_with_partner_aibehavior_celibateme_tt
			scope:actor = {
				has_trait = celibate
			}
			add = -100
		}

		modifier = { # They are Celibate
			desc = lay_with_partner_aibehavior_celibatethey_tt
			scope:recipient = {
				has_trait = celibate
			}
			add = -100
		}

		modifier = { # Lustful
			desc = lay_with_partner_aibehavior_lustful_tt
			trigger = {
				scope:recipient = {
					OR = {
						has_trait = lustful
						has_trait = seducer
					}
				}
			}
			add = {
				value = 0
				if = {
					limit = { scope:recipient = { has_trait = lustful } }
					add = 30
				}
				if = {
					limit = { scope:recipient = { has_trait = seducer } }
					add = 30
				}
			}
		}

		modifier = { # Chaste
			desc = lay_with_partner_aibehavior_chaste_tt
			scope:recipient = {
				has_trait = chaste
			}
			add = -30
		}

		modifier = { # Innocent
			desc = lay_with_partner_aibehavior_innocent_tt
			scope:recipient = {
				has_trait = innocent
			}
			add = -15
		}

		modifier = { # Shy
			desc = lay_with_partner_aibehavior_shy_tt
			scope:recipient = {
				has_trait = shy
			}
			add = -10
		}

		modifier = { # Trusting
			desc = lay_with_partner_aibehavior_trusting_tt
			scope:recipient = {
				has_trait = trusting
			}
			add = 15
		}

		modifier = { # I have Lover's Pox
			desc = lay_with_partner_aibehavior_loverspoxme_tt
			scope:actor = {
				has_trait = lovers_pox
			}
			add = -30
		}

		modifier = { # They have Lover's Pox
			desc = lay_with_partner_aibehavior_loverspoxthey_tt
			scope:recipient = {
				has_trait = lovers_pox
			}
			add = -15
		}

		modifier = { # I have Great Pox
			desc = lay_with_partner_aibehavior_greatpoxme_tt
			scope:actor = {
				has_trait = great_pox
			}
			add = -40
		}

		modifier = { # They have Great Pox
			desc = lay_with_partner_aibehavior_greatpoxthey_tt
			scope:recipient = {
				has_trait = great_pox
			}
			add = -20
		}

		modifier = { # I am Impotent
			desc = lay_with_partner_aibehavior_impotentme_tt
			scope:actor = {
				has_trait = impotent
			}
			add = -10
		}

		modifier = { # They are Impotent
			desc = lay_with_partner_aibehavior_impotentthey_tt
			scope:recipient = {
				has_trait = impotent
			}
			add = -15
		}

		modifier = { # I have Gout
			desc = lay_with_partner_aibehavior_goutme_tt
			scope:actor = {
				has_trait = gout_ridden 
			}
			add = -20
		}

		modifier = { # They have Gout
			desc = lay_with_partner_aibehavior_goutthey_tt
			scope:recipient = {
				has_trait = gout_ridden
			}
			add = -10
		}

		modifier = { # I am Ill
			desc = lay_with_partner_aibehavior_illme_tt
			scope:actor = {
				has_trait = ill
			}
			add = -25
		}

		modifier = { # They are Ill
			desc = lay_with_partner_aibehavior_illthey_tt
			scope:recipient = {
				has_trait = ill
			}
			add = -20
		}

		modifier = { # I have Pneumonia
			desc = lay_with_partner_aibehavior_pneumonicme_tt
			scope:actor = {
				has_trait = pneumonic
			}
			add = -40
		}

		modifier = { # They have Pneumonia
			desc = lay_with_partner_aibehavior_pneumonicthey_tt
			scope:recipient = {
				has_trait = pneumonic
			}
			add = -30
		}

		modifier = { # I have Consumption
			desc = lay_with_partner_aibehavior_consumptionme_tt
			scope:actor = {
				has_trait = consumption
			}
			add = -30
		}

		modifier = { # They have Consumption
			desc = lay_with_partner_aibehavior_consumptionthey_tt
			scope:recipient = {
				has_trait = consumption
			}
			add = -25
		}

		modifier = { # I have Smallpox
			desc = lay_with_partner_aibehavior_smallpoxme_tt
			scope:actor = {
				has_trait = smallpox
			}
			add = -60
		}

		modifier = { # They have Smallpox
			desc = lay_with_partner_aibehavior_smallpoxthey_tt
			scope:recipient = {
				has_trait = smallpox
			}
			add = -50
		}

		modifier = { # I have Typhus
			desc = lay_with_partner_aibehavior_typhusme_tt
			scope:actor = {
				has_trait = typhus
			}
			add = -65
		}

		modifier = { # They have Typhus
			desc = lay_with_partner_aibehavior_typhusthey_tt
			scope:recipient = {
				has_trait = typhus
			}
			add = -55
		}

		modifier = { # I have Plague
			desc = lay_with_partner_aibehavior_plagueme_tt
			scope:actor = {
				has_trait = bubonic_plague
			}
			add = -80
		}

		modifier = { # They have Plague
			desc = lay_with_partner_aibehavior_plaguethey_tt
			scope:recipient = {
				has_trait = bubonic_plague
			}
			add = -75
		}

		modifier = { # I have Leprosy
			desc = lay_with_partner_aibehavior_leperme_tt
			scope:actor = {
				has_trait = leper
			}
			add = -95
		}

		modifier = { # They have Leprosy
			desc = lay_with_partner_aibehavior_leperthey_tt
			scope:recipient = {
				has_trait = leper
			}
			add = -90
		}


		modifier = { #Friend modifier.
			desc = offer_vassalization_interaction_aibehavior_friend_tt
			trigger = {
				scope:recipient = {
					has_relation_friend = scope:actor
					NOT = { has_relation_best_friend = scope:actor }
				}
			}
			add = 20
		}
		
		modifier = { #Best Friend modifier.
			desc = offer_vassalization_interaction_aibehavior_best_friend_tt
			trigger = {
				scope:recipient = {
					has_relation_best_friend = scope:actor
				}
			}
			add = 30
		}

		modifier = { #Lover Modifier
			desc = lay_with_partner_aibehavior_lover_tt
			trigger = {
				scope:recipient = {
					has_relation_lover = scope:actor
				}
			}
			add = 40
		}

		modifier = { #Soulmate Modifier
			desc = lay_with_partner_aibehavior_soulmate_tt
			trigger = {
				scope:recipient = {
					has_relation_soulmate = scope:actor
				}
			}
			add = 55
		}

		modifier = { #Rivalry modifier.
			desc = offer_vassalization_interaction_aibehavior_rival_tt
			trigger = {
				scope:recipient = {
					has_relation_rival = scope:actor
					NOT = { has_relation_nemesis = scope:actor }
				}
			}
			add = -25
		}
		
		modifier = { #Nemesis modifier.
			desc = offer_vassalization_interaction_aibehavior_nemesis_tt
			trigger = {
				scope:recipient = {
					has_relation_nemesis = scope:actor
				}
			}
			add = -75
		}
		
		#Cultures and Languages Modifiers
		modifier = {
			desc = lay_with_partner_aibehavior_culture_tt
			trigger = {
				scope:actor = {
					NOT = { has_same_culture_as = scope:recipient }
					NOR = {
						has_relation_lover = scope:recipient
						has_relation_soulmate = scope:recipient
					}
				}
			}
			add = {
				value = -10
				if = {
					limit = {
						scope:actor = {
							culture = {
								NOT = { has_same_culture_heritage = scope:recipient.culture }
							}
						}
					}
					add = -15
				}
				if = {
					limit = {
						scope:recipient = {
							NOT = { is_close_or_extended_family_of = scope:actor }
							scope:actor = {
								knows_language_of_culture = scope:recipient.culture
							}
						}
					}
					add = 10
				}
				if = {
					limit = {
						scope:recipient = {
							classical_relations_culture_trigger = yes							
						}
					}
					multiply = 0.25
				}
				if = {
					limit = {
						scope:recipient = {
							OR = {
								is_consort_of = scope:actor
								is_concubine_of = scope:actor
							}
						}
					}
					multiply = 0.25
				}
			}
		}

		modifier = { #Faith modifiers.
			desc = offer_vassalization_interaction_aibehavior_differentfaith_tt
			trigger = {
				scope:actor = {
					NOT = { scope:actor.faith = scope:recipient.faith }
					NOR = {
						has_relation_lover = scope:recipient
						has_relation_soulmate = scope:recipient
					}
				}
			}
			add = {
				value = -25
				if = {
					limit = {
						scope:actor.faith.religion = scope:recipient.faith.religion						
					}
					add = 15
				}
				if = {
					limit = {
						scope:recipient = {	has_trait = zealous	}
					}
					multiply = 3
				}
				if = {
					limit = {
						scope:recipient = {	has_trait = cynical	}
					}
					multiply = 0.5
				}
				if = {
					limit = {
						scope:recipient = {
							classical_relations_culture_trigger = yes							
						}
					}
					multiply = 0.5
				}
				if = {
					limit = {
						scope:recipient = {
							OR = {
								is_consort_of = scope:actor
								is_concubine_of = scope:actor
							}
						}
					}
					multiply = 0.25
				}
			}
		}

		modifier = { #Foreigner modifiers.
			desc = lay_with_partner_aibehavior_foreign_tt
			add = -20
			scope:recipient = {
				NOR = {
					#NOT PART OF COURT
					is_consort_of = scope:actor
					is_courtier_of = scope:actor
					is_close_or_extended_family_of = scope:actor
					#NOT VISITOR TO COURT
					# exists = liege
					is_pool_guest_of = scope:actor
					#NOT A VASSAL OR LIEGE
					is_vassal_of = scope:actor
					liege = scope:actor
					top_liege = scope:actor
					#NOT FAMILY
					AND = {
						exists = liege
						is_close_or_extended_family_of = liege
					}
				}
			}
		}

		modifier = { #Things in common 1
			desc = lay_with_partner_aibehavior_trait2_tt
			add = 10
			scope:actor = {
				number_of_personality_traits_in_common = {
					target = scope:recipient
					value >=1
				}
				number_of_traits_in_common = {
					target = scope:recipient
					value = 2
				}
			}
		}

		modifier = { #Things in common 2
			desc = lay_with_partner_aibehavior_trait3_tt
			add = 20
			scope:actor = {
				number_of_personality_traits_in_common = {
					target = scope:recipient
					value >=1
				}
				number_of_traits_in_common = {
					target = scope:recipient
					value = 3
				}
			}
		}

		modifier = { #Things in common 3
			desc = lay_with_partner_aibehavior_trait4_tt
			add = 30
			scope:actor = {
				number_of_personality_traits_in_common = {
					target = scope:recipient
					value >= 2
				}
				number_of_traits_in_common = {
					target = scope:recipient
					value >= 4
				}
			}
		}

		modifier = { #Close Family modifier.
			desc = lay_with_partner_aibehavior_clfamily_tt
			add = -70
			scope:actor = {
				AND = {
					is_close_family_of = scope:recipient
					NOR = {
						is_consort_of = scope:recipient
						has_relation_lover = scope:recipient
						has_relation_soulmate = scope:recipient
					}
				}
			}
			NAND = {
				scope:actor = {
					OR = {
						has_trait = incestuous
						any_secret = {
							type = secret_incest
						}
					}
				}	
				scope:recipient = { 
					OR = {
						has_trait = incestuous
						any_secret = {
							type = secret_incest
						}
					}
				}
			}
		}
		
		modifier = { #Extended Family modifier.
			desc = lay_with_partner_aibehavior_exfamily_tt
			add = -30
			scope:actor = {
				AND = {
					is_extended_family_of = scope:recipient
					NOR = {
						is_consort_of = scope:recipient
						has_relation_lover = scope:recipient
						has_relation_soulmate = scope:recipient
					}
				}
			}
		}

		modifier = { #Share Incestuous Proclivities
			desc = lay_with_partner_aibehavior_incest_tt
			add = 20
			scope:actor = {
				is_close_or_extended_family_of = scope:recipient
				OR = {
					has_trait = incestuous
					any_secret = {
						type = secret_incest
						is_known_by = scope:recipient
					}
				}
			}
			scope:recipient = {
				OR = {
					has_trait = incestuous
					any_secret = {
						type = secret_incest
						is_known_by = scope:actor
					}
				}
			}
		}
	
		modifier = { #Witches
			desc = lay_with_partner_aibehavior_witches_tt
			add = 20
			scope:actor = {
				OR = {
					has_trait = witch
					any_secret = {
						type = secret_witch
						is_known_by = scope:recipient
					}
				}
			}
			scope:recipient = {
				OR = {
					has_trait = witch
					any_secret = {
						type = secret_witch
						is_known_by = scope:actor
					}
				}
			}
		}

		modifier = { #Prior Partners
			desc = lay_with_partner_aibehavior_partner_tt
			add = 25
			previous_partner_trigger = {
				ACTOR = scope:actor
				TARGET = scope:recipient
			}
		}

		modifier = { #Removes Pregnancy Chance from Calculation
			desc = lay_with_partner_pregnancy_chance_no_tt
			add = {
				value = 0
				if = {
					limit = {
						has_game_rule = fertility_pregnancy_view
					}
				}
				add = scope:actor.fertility
				add = scope:recipient.fertility
				multiply = -25
				# add = 10
			}
		}
		modifier = { #Shows Pregnancy Chance
			desc = lay_with_partner_pregnancy_chance_tt
			add = {
				value = 0
				if = {
					limit = {
						has_game_rule = fertility_pregnancy_view
					}
				}
				add = scope:actor.fertility
				add = scope:recipient.fertility
				multiply = 25
				# add = -10
			}
		}
	}

	ai_will_do = {
		base = 0 #The AI should never do this!
	}

	on_accept = {
		scope:actor = {
			if = {
				limit = {
					has_usable_hook = scope:recipient
					scope:recipient = {
						OR = {
							is_adult = yes
							NOT = {
								has_trait = lustful
							}
						}
					}
				}
				use_hook = scope:recipient
			}
			if = {
				limit = {
					has_character_modifier = faithfulness_modifier
					OR = {
						is_married = yes
						is_concubine = yes
					}
					scope:recipient = {
						NOT = {
							is_consort_of = scope:actor
						}
					}
				}
				remove_character_modifier = faithfulness_modifier
				add_character_modifier = {
					modifier = unfaithfulness_modifier
				}
			}
			else_if = {
				limit = {
					has_character_modifier = faithfulness_modifier
					scope:recipient = {
						NOR = {
							is_consort_of = scope:actor
							has_relation_lover = scope:actor
							has_relation_soulmate = scope:actor
						}
					}
				}
				remove_character_modifier = faithfulness_modifier
			}
		}

		scope:actor = {
			trigger_event = lay_with_man.20
			add_character_flag = {
				flag = has_attempted_sex
				days = 30 #was 14 - Decreased to prevent baby spamming in Polygamous Cultures
			}
		}

		scope:actor = {
			if = {
				limit = {
					scope:recipient = {
						NOR = {
							is_consort_of = scope:actor
							has_relation_lover = scope:actor
							has_relation_soulmate = scope:actor
							is_close_or_extended_family_of = scope:actor
						}
					}
				}
			add_prestige = 15 #miniscule_prestige_gain
			}
		}

		scope:recipient = {
			add_opinion = {
				target = scope:actor
				modifier = laid_with_opinion
			}
		}

		scope:recipient = { 
			if = {
				limit = {
					AND = {
						NOT = {
							is_consort_of = scope:actor
						}	
						age <= 17
					}
				}	
				add_opinion = {
					target = scope:actor
					modifier = laid_with_smitten
				}	
			}
		}

		scope:recipient = { 
			if = {
				limit = {
					AND = {
						age <= 20
						age >= 18
						NOT = {
							is_consort_of = scope:actor
						}
					}
				}	
				add_opinion = {
					target = scope:actor
					modifier = laid_with_enamored
				}	
			}
		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = failed_to_lay.01
			stress_impact = {
				base = minor_stress_impact_gain
				chaste = medium_stress_impact_gain
				lustful = miniscule_stress_impact_gain
				shy = medium_stress_impact_gain
			}
			add_character_flag = {
				flag = has_attempted_sex
				days = 30 #was 14 - Decreased to prevent baby spamming in Polygamous Cultures
			}
		}

		scope:recipient = {
			add_opinion = {
				target = scope:actor
				modifier = laid_with_OD_opinion
			}	
		}

		scope:recipient = { 
			if = {
				limit = {
					AND = {
						NOT = {
							is_consort_of = scope:actor
						}	
						age <= 17 
					}
				}	
				add_opinion = {
					target = scope:actor
					modifier = laid_with_OD_smitten
				}	
			}
		}

		scope:recipient = { 
			if = {
				limit = {
					AND = {
						age <= 20
						age >= 18
						NOT = {
							is_consort_of = scope:actor
						}
					}
				}	
				add_opinion = {
					target = scope:actor
					modifier = laid_with_OD_enamored
				}	
			}
		}
	}
}