﻿marriage_ai_accept_modifier = {
	#########
	# HOOKS #
	#########
	modifier = { #Weak hook
		scope:marriage_hook = yes
		add = 100
		scope:actor = { NOT = { has_strong_hook = scope:recipient } }
		desc = SCHEME_WEAK_HOOK_USED
	}
	modifier = { #Strong Hook (in some cases it's not auto accept)
		scope:marriage_hook = yes
		add = 200
		scope:actor = { has_strong_hook = scope:recipient }
		desc = SCHEME_STRONG_HOOK_USED
	}
	
	#########
	# PERKS #
	#########
	modifier = { # A lot of acceptance for yourself - you are likely already married, thus you need motivation to get rid of your spouse to marry someone better
		scope:actor = { has_perk = promising_prospects_perk }
		scope:actor = scope:secondary_actor
		add = promising_prospects_self_value
		desc = PROMISING_PROSPECTS_PERK_MODIFIER
	}
	modifier = { # A significant but lesser chunk of acceptance for your extended family, to increase the value of the perk!
		scope:actor = { has_perk = promising_prospects_perk }
		NOT = { scope:actor = scope:secondary_actor }
		scope:secondary_actor = {
			is_close_or_extended_family_of = scope:actor
		}
		add = promising_prospects_other_value
		desc = PROMISING_PROSPECTS_PERK_MODIFIER
	}
	modifier = { # Dynasty Glory Perk acceptance, checks the secondary recipients dynasty for the perk
		exists = scope:secondary_actor.dynasty
		scope:secondary_actor.dynasty = { has_dynasty_perk = glory_legacy_1 }
		add = glory_legacy_1_marriage_acceptance
		desc = DYNASTY_LEGACY_GLORY_MARRIAGE_ACCEPTANCE_PERK_MODIFIER
	}

	##########################
	# WHO IS GETTING MARRIED #
	##########################
	modifier = {
		add = -15 # Less likely if it's the recipient him/herself
		scope:recipient = scope:secondary_recipient
		desc = MY_OWN_MARRIAGE_REASON
	}
	#More likely if the secondary_actor is the actor's heir
	modifier = {
		add = 10
		scope:actor = {
			exists = player_heir
			player_heir_position = {
				value <= 4 #0, 1, 2, 3, 4 = 5 first player heirs
				target = scope:secondary_actor
			}
			NOT = {
				player_heir_position = {
					value = 0 #player heir
					target = scope:secondary_actor
				}
			}
		}
		scope:actor = {
			tier_difference = {
				target = scope:recipient
				value > 0
			}
		}
		desc = MARRYING_HEIR_REASON
	}

	modifier = {
		add = 20
		scope:actor = {
			exists = player_heir
			player_heir_position = {
				value = 0 #player heir
				target = scope:secondary_actor
			}
		}
		scope:actor = {
			tier_difference = {
				target = scope:recipient
				value > 0
			}
		}
		desc = MARRYING_HEIR_REASON
	}
	
	##############################################
	# ALLIANCE/HOSTILITY FACTORS ("REALPOLITIK") #
	##############################################
	modifier = {
		add = {
			value = 40
			if = {
				limit = {
					scope:actor = {
						tier_difference = {
							target = scope:recipient
							value = -1
						}
					}
				}
				subtract = 10
			}
			else_if = {
				limit = {
					scope:actor = {
						tier_difference = {
							target = scope:recipient
							value = -2
						}
					}
				}
				subtract = 30
			}
			if = {
				limit = {
					scope:actor = {
						any_ally = {
							NOR = {
    							target_is_liege_or_above = scope:actor
    							target_is_vassal_or_below = scope:actor
							}
							count >= 2
						}
					}
				}
				scope:actor = {
					every_ally = {
						limit = {
							NOR = {
    							target_is_liege_or_above = scope:actor
    							target_is_vassal_or_below = scope:actor
							}
						}
						multiply = 0.5
					}
				}
			}
		}
		scope:recipient = {
			NOR = {
				is_allied_to = scope:actor
				scope:actor = { # Emperors do not care for Counts at all
					tier_difference = {
						target = scope:recipient
						value <= -3
					}
				}
			}
			OR = {
				ai_diplomacy_stance = {
					target = scope:actor
					stance = neutral
				}
				ai_diplomacy_stance = {
					target = scope:actor
					stance = threat
				}
			}
			yields_alliance = {
				candidate = scope:secondary_recipient
				target = scope:actor
				target_candidate = scope:secondary_actor
			}
		}
		OR = {
			scope:actor = {
				is_independent_ruler = yes
			}
			scope:recipient = {
				is_independent_ruler = yes
			}
			scope:recipient.liege = scope:actor.liege
		}
		
		desc = DESIRES_ALLIANCE
	}
	modifier = {
		add = {
			value = 100
			if = {
				limit = {
					scope:actor = {
						any_ally = {
							NOR = {
    							target_is_liege_or_above = scope:actor
    							target_is_vassal_or_below = scope:actor
							}
							count >= 2
						}
					}
				}
				scope:actor = {
					every_ally = {
						limit = {
							NOR = {
    							target_is_liege_or_above = scope:actor
    							target_is_vassal_or_below = scope:actor
							}
						}
						multiply = 0.5
					}
				}
			}
		}
		scope:recipient = {
			NOT = { is_allied_to = scope:actor }
			ai_diplomacy_stance = {
				target = scope:actor
				stance = friend
			}
			yields_alliance = {
				candidate = scope:secondary_recipient
				target = scope:actor
				target_candidate = scope:secondary_actor
			}
		}
		desc = DESIRES_ALLIANCE
	}
	modifier = {
		add = -100
		scope:recipient = {
			NOT = { is_allied_to = scope:actor }
			ai_diplomacy_stance = {
				target = scope:actor
				stance = enemy
			}
			yields_alliance = {
				candidate = scope:secondary_recipient
				target = scope:actor
				target_candidate = scope:secondary_actor
			}
		}
		desc = DOES_NOT_WANT_ALLIANCE
	}
	modifier = {
		add = {
			scope:actor = {
				every_ally = {
					limit = {
						NOR = {
    						target_is_liege_or_above = scope:actor
    						target_is_vassal_or_below = scope:actor
						}
					}
					add = -15
				}
			}
		}
		scope:actor = {
			any_ally = {
				NOR = {
					target_is_vassal_or_below = scope:actor
					target_is_liege_or_above = scope:actor
				}
				count >= 2
			}
		}
		scope:recipient = {
			NOR = {
				is_allied_to = scope:actor
				target_is_vassal_or_below = scope:actor
				target_is_liege_or_above = scope:actor
			}
			yields_alliance = {
				candidate = scope:secondary_recipient
				target = scope:actor
				target_candidate = scope:secondary_actor
			}
		}
		desc = YOU_HAVE_TOO_MANY_ALLIANCES
	}
	# Clan contract: Marriage Favor
	modifier = {
		add = 100
		OR = {
			# Liege PoV
			scope:recipient = {
				is_vassal_of = scope:actor
				vassal_contract_has_flag = vassal_contract_marriage_favor
			}
			# Vassal PoV
			scope:actor = {
				is_vassal_of = scope:recipient
				vassal_contract_has_flag = vassal_contract_marriage_favor
			}
		}

		desc = VASSAL_CONTRACT_MARRIAGE_FAVOR_BONUS
	}

	####################
	# TIER DIFFERENCES #
	####################
	modifier = {
		scope:recipient = {
			OR = {
				AND = {
					is_lowborn = no
					dynasty = scope:secondary_recipient.dynasty
				}
				is_close_or_extended_family_of = scope:secondary_recipient
			}
		}
		scope:actor = {
			OR = {
				is_close_or_extended_family_of = scope:secondary_actor
				this = scope:secondary_actor
			}
			tier_difference = {
				target = scope:recipient
				value >= 1
			}
		}
		add = {
			value = scope:actor.highest_held_title_tier
			subtract = scope:recipient.highest_held_title_tier
			multiply = 30
		}
		desc = MARRYING_UP_REASON
	}
	
	modifier = {
		scope:recipient = {
			OR = {
				AND = {
					is_lowborn = no
					dynasty = scope:secondary_recipient.dynasty
				}
				is_close_or_extended_family_of = scope:secondary_recipient
			}
		}
		scope:actor = {
			OR = {
				is_close_or_extended_family_of = scope:secondary_actor
				this = scope:secondary_actor
			}
			tier_difference = {
				target = scope:recipient
				value <= -1
			}
		}
		add = {
			value = scope:actor.highest_held_title_tier
			subtract = scope:recipient.highest_held_title_tier
			if = {
				limit = { scope:actor.highest_held_title_tier = tier_kingdom }
				multiply = 30
			}
			else = {
				multiply = 40
			}
		}
		desc = MARRYING_DOWN_REASON
	}
	
	modifier = {
		scope:recipient = {
			OR = {
				AND = {
					is_lowborn = no
					dynasty = scope:secondary_recipient.dynasty
				}
				is_close_or_extended_family_of = scope:secondary_recipient
			}
		}
		scope:actor = {
			NOR = {
				is_close_or_extended_family_of = scope:secondary_actor
				this = scope:secondary_actor
			}
		}
		NOR = {
			scope:secondary_actor = {
				tier_difference = {
					target = scope:recipient
					value >= 0
				}
			}
			AND = {
				exists = scope:secondary_actor.father
				scope:secondary_actor.father = {
					tier_difference = {
						target = scope:recipient
						value >= 0
					}
				}
			}
			AND = {
				exists = scope:secondary_actor.mother
				scope:secondary_actor.mother = {
					tier_difference = {
						target = scope:recipient
						value >= 0
					}
				}
			}
		}
		add = {
			value = 0
			if = {
				limit = {
					scope:secondary_actor = {
						exists = father.primary_title
						trigger_if = {
							limit = {
								exists = mother.primary_title
							}
							father.primary_title.tier >= mother.primary_title.tier
						}
					}
				}
				add = scope:secondary_actor.father.highest_held_title_tier
				subtract = scope:recipient.highest_held_title_tier
				if = {
					limit = { scope:secondary_actor.father.highest_held_title_tier = tier_kingdom }
					multiply = 30
				}
				else = {
					multiply = 40
				}
			}
			else_if = {
				limit = {
					scope:secondary_actor = {
						exists = mother.primary_title
						trigger_if = {
							limit = {
								exists = father.primary_title
							}
							mother.primary_title.tier >= father.primary_title.tier
						}
					}
				}
				add = scope:secondary_actor.mother.highest_held_title_tier
				subtract = scope:recipient.highest_held_title_tier
				if = {
					limit = { scope:secondary_actor.mother.highest_held_title_tier = tier_kingdom }
					multiply = 30
				}
				else = {
					multiply = 40
				}
			}
			else = {
				add = scope:secondary_actor.highest_held_title_tier
				subtract = scope:recipient.highest_held_title_tier
				if = {
					limit = { scope:secondary_actor.highest_held_title_tier = tier_kingdom }
					multiply = 30
				}
				else = {
					multiply = 40
				}
			}
			
		}
		desc = MARRYING_DOWN_REASON
	}

	############
	# OPINIONS #
	############
	opinion_modifier = { # More likely to accept if Recipient likes the person the Actor offers for marriage
		trigger = {
			NOT = { scope:recipient = scope:secondary_actor }
		}
		who = scope:recipient
		opinion_target = scope:secondary_actor
		multiplier = 0.25
		desc = AI_OPINION_REASON
	}
	opinion_modifier = { # A lot more likely if Recipient likes Actor
		trigger = {
			NOT = { scope:actor = scope:recipient }
		}
		who = scope:recipient
		opinion_target = scope:actor
		multiplier = 0.75
		desc = AI_OPINION_REASON
	}
	modifier = { # Likely to want two candidates who like each other to marry if Recipient likes them both
		add = 15
		scope:secondary_recipient = { #Do they like each other a lot?
			opinion = {
				target = scope:secondary_actor
				value > 50
			}
			reverse_opinion = {
				target = scope:secondary_actor
				value > 50
			}
		}
		scope:recipient = { #The Recipient needs to want well for both candidates
			NOT = { has_trait = sadistic }
			NOT = { has_trait = callous }
			NOT = { has_trait = cynical }
			opinion = {
				target = scope:secondary_actor
				value > 0
			}
			opinion = {
				target = scope:secondary_recipient
				value > 0
			}
		}
		desc = wishes_well_for_lovers_tooltip
	}
	compare_modifier = { #If the Secondary_recipient has the Love opinion for the Secondary_actor, add the Recipients compassion value
		target = scope:recipient
		trigger = {
			scope:recipient = {
				ai_compassion > 0
				opinion = {
					target = scope:secondary_recipient
					value > 0
				}
			}
			scope:secondary_recipient = {
				has_opinion_modifier = {
					target = scope:secondary_actor
					modifier = love_opinion
				}
			}
		}
		value = ai_compassion
		multiplier = 0.25
	}
	modifier = { # Recipient wants to marry their lovers
		add = 25
		scope:secondary_recipient = scope:recipient
		scope:secondary_recipient = {
			has_relation_lover = scope:secondary_actor
			NOT = { has_relation_soulmate = scope:secondary_actor }
			# If it's a secret relation we know of it
			trigger_if = {
				limit = {
					any_secret = {
						secret_type = secret_lover
						secret_target = scope:secondary_actor
					}
				}
				any_secret = {
					secret_type = secret_lover
					secret_target = scope:secondary_actor
					any_secret_knower = {
						this = scope:actor
					}
				}
			}
		}
		desc = ARE_LOVERS_REASON
	}

	modifier = { # Recipient wants to marry their soulmates
		add = 100
		scope:secondary_recipient = scope:recipient
		scope:secondary_recipient = {
			has_relation_soulmate = scope:secondary_actor
			# If it's a secret relation we know of it
			trigger_if = {
				limit = {
					any_secret = {
						secret_type = secret_lover
						secret_target = scope:secondary_actor
					}
				}
				any_secret = {
					secret_type = secret_lover
					secret_target = scope:secondary_actor
					any_secret_knower = {
						this = scope:actor
					}
				}
			}
		}
		desc = ARE_SOULMATES_REASON
	}
	
	modifier = { # Same language
		add = 5
		desc = speaks_same_language_interaction_reason
		trigger = {
			scope:actor = {
				knows_language_of_culture = scope:recipient.culture
			}
		}
	}
	
	modifier = { # Shared Court Language (non-spoken)
		add = 5
		desc = foreign_realm_court_language_non_spoken_interaction_reason
		trigger = {
			scope:actor = {
				has_royal_court = yes
				NOT = { knows_court_language_of = this }
			}
			NOT = {
				scope:actor.top_liege = scope:recipient.top_liege
			}
			OR = {
				AND = {
					scope:recipient = {
						has_royal_court = yes
					}
					scope:actor = { # You share Court Language
						has_same_court_language = scope:recipient
					}
				}
				
				scope:recipient = { # The recipient doesn't have a royal court, but their liege does
					is_independent_ruler = no
					is_pool_character = no
					has_royal_court = no
					exists = liege 
					liege = {
						has_royal_court = yes
						has_same_court_language = scope:actor
					}
				}
				scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege does, while their liege doesn't have a royal court
					is_independent_ruler = no
					is_pool_character = no
					has_royal_court = no
					exists = liege.liege
					liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege = {
						has_royal_court = yes
						has_same_court_language = scope:actor
					}
				}
				scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege's liege does, while their liege doesn't have a royal court
					is_independent_ruler = no
					is_pool_character = no
					has_royal_court = no
					exists = liege.liege
					exists = liege.liege.liege
					liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege.liege = {
						has_royal_court = yes
						has_same_court_language = scope:actor
					}
				}
				scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege's liege's liege does, while their liege doesn't have a royal court
					is_independent_ruler = no
					is_pool_character = no
					has_royal_court = no
					exists = liege.liege
					exists = liege.liege.liege
					exists = liege.liege.liege.liege
					liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege.liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege.liege.liege = {
						has_royal_court = yes
						has_same_court_language = scope:actor
					}
				}
			}
		}
	}
	
	modifier = { # Shared Court Language (spoken)
		add = 15
		desc = foreign_realm_court_language_spoken_interaction_reason
		trigger = {
			scope:actor = {
				has_royal_court = yes
				knows_court_language_of = this
			}
			NOT = {
				scope:actor.top_liege = scope:recipient.top_liege
			}
			OR = {
				AND = {
					scope:recipient = {
						has_royal_court = yes
					}
					scope:actor = { # You share Court Language
						has_same_court_language = scope:recipient
					}
				}
				
				scope:recipient = { # The recipient doesn't have a royal court, but their liege does
					is_independent_ruler = no
					is_pool_character = no
					has_royal_court = no
					exists = liege 
					liege = {
						has_royal_court = yes
						has_same_court_language = scope:actor
					}
				}
				scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege does, while their liege doesn't have a royal court
					is_independent_ruler = no
					is_pool_character = no
					has_royal_court = no
					exists = liege.liege
					liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege = {
						has_royal_court = yes
						has_same_court_language = scope:actor
					}
				}
				scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege's liege does, while their liege doesn't have a royal court
					is_independent_ruler = no
					is_pool_character = no
					has_royal_court = no
					exists = liege.liege
					exists = liege.liege.liege
					liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege.liege = {
						has_royal_court = yes
						has_same_court_language = scope:actor
					}
				}
				scope:recipient = { # The recipient doesn't have a royal court, but their liege's liege's liege's liege does, while their liege doesn't have a royal court
					is_independent_ruler = no
					is_pool_character = no
					has_royal_court = no
					exists = liege.liege
					exists = liege.liege.liege
					exists = liege.liege.liege.liege
					liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege.liege = {
						is_independent_ruler = no
						has_royal_court = no
					}
					liege.liege.liege.liege = {
						has_royal_court = yes
						has_same_court_language = scope:actor
					}
				}
			}
		}
	}
	
	###########################
	# DYNASTY PRESTIGE LEVELS #
	###########################
	modifier = {
		scope:secondary_actor = { has_dynasty = no }
		add = {
			value = -20 # AI really doesn't like marrying lowborn courtiers.
			if = {
				limit = { # Especially not if they're not lowborn themselves
					scope:secondary_recipient = { has_dynasty = yes }
				}
				multiply = 6
			}
		}
		desc = AI_DYNASTY_PRESTIGE_REASON_LOWBORN
	}
	modifier = {
		scope:secondary_actor = { has_dynasty = yes }
		scope:recipient.dynasty = scope:secondary_recipient.dynasty
		NOT = { scope:secondary_actor.dynasty = { dynasty_prestige_level = 1 } } #Would equal a value of 0, so we hide it
		add = {
			value = scope:secondary_actor.dynasty.dynasty_prestige_level
			multiply = 5
			subtract = 5 #At 0 dynasty prestige level, there should be a penalty
		}
		desc = AI_DYNASTY_PRESTIGE_REASON_SECONDARY
	}	
	

	#####################################
	# PENALTIES FOR INCORRECT LINEALITY # (matrilineal for men, patrilineal for women)
	#####################################
	modifier = {
		scope:secondary_recipient = {
			exists = dynasty
			exists = scope:recipient.dynasty
			dynasty = scope:recipient.dynasty
			NAND = {
				dynasty = scope:actor.dynasty
				dynasty = scope:secondary_actor.dynasty
				scope:secondary_actor = { NOT = { has_trait = bastard } }
			}

			scope:recipient = { is_ruler = yes }
			scope:secondary_actor = { sex_opposite_of = scope:secondary_recipient }
			#Incorrect lineality
			#Modded with code from More Game Rules (MGR) by Neutrino for compatibility
			OR = {
				AND = {
					NOT = { always = scope:matrilineal }
					is_female = yes
					OR = {
						NOT = { exists = global_var:mgr_is_active }
						AND = {
							#Checks to see if More Game Rules (MGR) is active
							exists = global_var:mgr_is_active
							#From More Game Rules (MGR) \common\scripted_triggers\000_more_game_rules_triggers.tx
							#matri_marriage_allowed = yes
							OR = {
								has_game_rule = default_matri
								AND = {
									has_game_rule = restricted_matri
									faith = {
										OR = {
											has_doctrine = doctrine_gender_equal
											has_doctrine = doctrine_gender_female_dominated
										}
									}
								}
								AND = {
									has_game_rule = more_restricted_matri
									faith = { has_doctrine = doctrine_gender_female_dominated }
								}
							}
						}
					}
				}
				AND = {
					always = scope:matrilineal
					is_male = yes
				}
			}
		}
		#Only cares about the ruler, first 3 heirs, and the dominant gender dynasty members
		scope:recipient = {
			OR = {
				this = scope:secondary_recipient
				AND = {
					exists = player_heir
					player_heir_position = { #0, 1, 2 = the first three player heirs in succession line.
						value <= 2
						target = scope:secondary_recipient
					}
				}
				has_realm_law = equal_law
				AND = {
					scope:secondary_recipient = { is_female = yes }
					OR = {
						has_realm_law = female_only_law
						has_realm_law = female_preference_law
					}
				}
				AND = {
					scope:secondary_recipient = { is_male = yes }
					OR = {
						has_realm_law = male_only_law
						has_realm_law = male_preference_law
					}
				}
			}
		}

		add = {
			#For the ruler themselves and their first player heir
			if = {
				limit = {
					scope:recipient = {
						OR = {
							this = scope:secondary_recipient
							AND = {
								exists = player_heir
								player_heir_position = {
									value = 0 #First player heir
									target = scope:secondary_recipient
								}
							}
						}
					}
					OR = {
						AND = {
							scope:recipient.faith = {
								has_doctrine = doctrine_gender_male_dominated
							}
							scope:secondary_recipient = {
								is_male = yes
							}
						}
						AND = {
							scope:recipient.faith = {
								has_doctrine = doctrine_gender_female_dominated
							}
							scope:secondary_recipient = {
								is_female = yes
							}
						}
					}
				}
				subtract = 1000
			}
			else_if = {
				limit = {
					scope:recipient = {
						OR = {
							this = scope:secondary_recipient
							AND = {
								exists = player_heir
								player_heir_position = {
									value = 0 #First player heir
									target = scope:secondary_recipient
								}
							}
						}
					}
				}
				subtract = 100
			}
			#For the second heir
			else_if = {
				limit = {
					scope:recipient = {
						exists = player_heir
						player_heir_position = {
							value = 1 #Second player heir
							target = scope:secondary_recipient
						}
					}
				}
				subtract = 60 #A bit more than a strong hook
			}
			#For the third heir
			else_if = {
				limit = {
					scope:recipient = {
						exists = player_heir
						player_heir_position = {
							value = 2 #Third player heir
							target = scope:secondary_recipient
						}
					}
				}
				subtract = 30 #A bit more than a weak hook
			}
			else_if = {
				limit = {
					scope:recipient = { has_realm_law = equal_law }
				}
				subtract = 10 #If The realm law is equal, and the secondary_recipient is NOT ruler or their 1st/2nd/3rd heir, slash the penalty in half
			}
			else = {
				subtract = 20 #Base penalty for dynasty members who are NOT ruler or their 1st/2nd/3rd heir
			}
		}
		desc = MATRILINEAL_PATRILINEAL_REASON
	}
	##################################################
	# WRONG LINEALITY - MORE GAME RULES (MGR) MODDED #
	##################################################
	#Modded with code from More Game Rules (MGR) by Neutrino for compatibility 
	modifier = {
		exists = global_var:mgr_is_active
		add = {
			if = {
				limit = {
					OR = {
						has_game_rule = restricted_matri
						has_game_rule = more_restricted_matri
						has_game_rule = never_matri
					}
					OR = {
						scope:secondary_recipient = { always = scope:matrilineal }
						scope:actor = { always = scope:matrilineal }
					}
				}
				if = {
					limit = { 
						has_game_rule = restricted_matri
					}
					if = {
						limit = { 
							scope:secondary_recipient = { 
								faith = { has_doctrine = doctrine_gender_male_dominated }
								is_male = yes
							} 
							scope:actor = { is_female = yes }
						}
						subtract = 1000
					}
				}
				else_if = {
					limit = { has_game_rule = more_restricted_matri }
					if = {
						limit = {
							scope:secondary_recipient = { 
								NOT = { faith = { has_doctrine = doctrine_gender_female_dominated } }
								is_male = yes
							}
							scope:actor = { is_female = yes }
						}
						subtract = 1000
					} 
				}
				else = { #Never
					subtract = 10000
				}
			}
		}
		desc = GAME_RULE_MATRILINEAL_REASON
	}

	#########
	# FAITH #
	#########
	modifier = { # A recipient will be reluctant (to differing degrees) to agree to marriages sent from an actor of a different faith
		add = {
			value = -10
			if = {
				limit = {					
					NOR = {
						# Exempt certain struggle phases.
						is_struggle_parameter_active_interfaith_marriages_available_between_involved_characters_trigger = yes
						# Exempt Conciliation struggle resolution
						AND = {
							has_global_variable = fp2_struggle_conciliation_ending
							fp2_struggle_conciliation_special_cultural_rules_trigger = { C1 = scope:recipient C2 = scope:actor }
						}
					}
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value > faith_astray_level
							}
						}
					}
					subtract = 15
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostility_prevents_marriage_level
							}
						}
					}
					subtract = 975
				}
			}
		}

		scope:recipient.faith = {
			faith_hostility_level = {
				target = scope:actor.faith
				value > faith_fully_accepted_level
			}
		}
		desc = MARRY_DIFFERENT_FAITH_REASON
	}

	modifier = { # Polygamy not supported
		add = -1000
		desc = DIVORCE_POLYGAMY

		scope:secondary_actor = { 
			is_married = yes 
		}
		AND = {
			scope:secondary_recipient.culture = { NOT = { has_cultural_tradition = tradition_polygamous } }
			scope:secondary_recipient.faith = { NOT = { has_doctrine = doctrine_polygamy } }
		}
	}

	modifier = { # Same-sex marriage not supported in recipient's faith
		add = -1000
		desc = SAME_SEX_MARRIAGE_FAITH_REASON

		scope:secondary_recipient = {
			sex_same_as = scope:secondary_actor
			allowed_to_marry_same_sex_trigger = no
		}
	}

	modifier = { # A debuff for no fertility to same-sex marriage
		add = -200
		desc = SAME_SEX_MARRIAGE_FERTILITY_REASON

		scope:secondary_recipient = {
			allowed_to_marry_same_sex_trigger = yes
			sex_same_as = scope:secondary_actor
			OR = {
				is_ruler = yes
				AND = {
					exists = scope:recipient.primary_heir
					scope:recipient.primary_heir = { this = scope:secondary_recipient }
				}
			}
			NOT = {
				any_child = {
					count >= 2
				}
			}
		}
	}

	###############
	# PROCREATION #
	###############
	compare_modifier = { # Recipient is reluctant to marry old women (procreation is a key factor)
		trigger = {
			scope:secondary_actor = {
			
				is_female = yes
				NAND = {
					is_ruler = yes
					OR = {
						has_relation_lover = scope:secondary_recipient
						has_relation_soulmate = scope:secondary_recipient
						has_relation_friend = scope:secondary_recipient
						has_relation_best_friend = scope:secondary_recipient
					}
				}
				OR = {
					AND = {
						age > 29
						NOT = { is_ruler = yes }
					}
					AND = {
						is_ruler = yes
						age > 35
					}
				}
			}
			scope:secondary_recipient = {
				#is_adult = yes #Modded so it applies to betrothals too
				OR = { 
					AND = {
						exists = scope:secondary_recipient.dynasty
						scope:secondary_recipient.dynasty = {
							OR = {
								any_dynasty_member = {
									count >= 2
								}
								dynasty_prestige_level > 1
							}
						}
					}
					is_ruler = yes
				    is_close_or_extended_family_of = scope:recipient
					this = scope:recipient.player_heir
				}
				age < 40 # Modded #Will still suffer hard fertitly nerfs below	
			}
		}
		target = scope:secondary_actor
		value = age
		multiplier = -20.0 #Modded from -5
		step = 1
		offset = -29
		desc = MARRY_AGE
	}

	compare_modifier = { # MODDED ADDITION Actor is reluctant to marry old women (procreation is a key factor)
		trigger = {
			scope:secondary_recipient = {
				is_female = yes
				NAND = {
					is_ruler = yes
					OR = {
						has_relation_lover = scope:secondary_actor
						has_relation_soulmate = scope:secondary_actor
						has_relation_friend = scope:secondary_actor
						has_relation_best_friend = scope:secondary_actor
					}
				}
				OR = {
					AND = {
						age > 29
						NOT = { is_ruler = yes }
					}
					AND = {
						is_ruler = yes
						age > 35
					}
				}
			}
			scope:secondary_actor = {
				#is_adult = yes #Modded so it applies to betrothals too
				OR = { 
					AND = {
						exists = scope:secondary_actor.dynasty
						scope:secondary_actor.dynasty = {
							OR = {
								any_dynasty_member = {
									count >= 2
								}
								dynasty_prestige_level > 1
							}
						}
					}
					is_ruler = yes
				    is_close_or_extended_family_of = scope:actor
					this = scope:actor.player_heir
				}
				age < 40 #Modded Will still suffer hard fertility nerfs below
			}
			scope:actor = {
				is_ai = yes
			}
		}
		target = scope:secondary_recipient
		value = age
		multiplier = -20.0 #Modded from -5
		step = 1
		offset = -29
		desc = MARRY_AGE
	}	
	
	compare_modifier = { # MODDED ADDITION Young male recipient triply reluctant to marry old women (procreation is a key factor)
		trigger = {
			scope:secondary_actor = {
				is_female = yes
				NAND = {
					is_ruler = yes
					OR = {
						has_relation_lover = scope:secondary_recipient
						has_relation_soulmate = scope:secondary_recipient
						has_relation_friend = scope:secondary_recipient
						has_relation_best_friend = scope:secondary_recipient
					}
				}
				OR = {
					AND = {
						age > 29
						NOT = { is_ruler = yes }
					}
					AND = {
						is_ruler = yes
						age > 35
					}
				}
			}
			scope:secondary_recipient = {
				#is_adult = yes #Modded so it applies to betrothals too
				age < 34 #Modded, triple reluctance for men under 34
				#OR = {
				#	AND = {
				#		exists = scope:secondary_recipient.dynasty
				#		scope:secondary_recipient.dynasty = {
				#			OR = {
				#				any_dynasty_member = {
				#					count >= 2
				#				}
				#				dynasty_prestige_level > 1
				#			}
				#		}
				#	}
				#	is_ruler = yes
				#	is_close_or_extended_family_of = scope:recipient
				#	this = scope:recipient.player_heir
				#}
			}
		}
		target = scope:secondary_actor
		value = age
		multiplier = -40.0 #Modded from -5
		step = 1
		offset = -29
		desc = MARRY_AGE
	}	

	compare_modifier = { # MODDED ADDITION Young male actor triply reluctant to marry old women (procreation is a key factor)
		trigger = {
			scope:secondary_recipient = {
				is_female = yes
				NAND = {
					is_ruler = yes
					OR = {
						has_relation_lover = scope:secondary_actor
						has_relation_soulmate = scope:secondary_actor
						has_relation_friend = scope:secondary_actor
						has_relation_best_friend = scope:secondary_actor
					}
				}
				OR = {
					AND = {
						age > 29
						NOT = { is_ruler = yes }
					}
					AND = {
						is_ruler = yes
						age > 35
					}
				}
			}
			scope:secondary_actor = {
				#is_adult = yes #Modded so it applies to betrothals too
				age < 34 #Modded, triple reluctance for men under 34
				#OR = {
				#	AND = {
				#		exists = scope:secondary_recipient.dynasty
				#		scope:secondary_recipient.dynasty = {
				#			OR = {
				#				any_dynasty_member = {
				#					count >= 2
				#				}
				#				dynasty_prestige_level > 1
				#			}
				#		}
				#	}
				#	is_ruler = yes
				#	is_close_or_extended_family_of = scope:recipient
				#	this = scope:recipient.player_heir
				#}
			}
			scope:actor = {
				is_ai = yes
			}
		}
		target = scope:secondary_recipient
		value = age
		multiplier = -40.0 #Modded from -5
		step = 1
		offset = -29
		desc = MARRY_AGE
	}	
	
	compare_modifier = { # Recipient is VERY reluctant to betrothe old women to boys
		trigger = {
			scope:secondary_actor = {
				age > 20
				is_female = yes
			}
			scope:secondary_recipient = {
				is_adult = no
			}
		}
		target = scope:secondary_actor
		value = age
		multiplier = -10.0 #Modded from -5
		step = 1
		offset = -20
		desc = MARRY_AGE
	}
	
	compare_modifier = { # MODDED ADDITION Actor is VERY reluctant to betrothe old women to boys
		trigger = {
			scope:secondary_recipient = {
				age > 20
				is_female = yes
			}
			scope:secondary_actor = {
				is_adult = no
			}		
		}
		target = scope:secondary_recipient
		value = age
		multiplier = -10.0 #Modded from -5
		step = 1
		offset = -20
		desc = MARRY_AGE
	}	

	compare_modifier = { #MODDED ADDITION Recipient is EXTRA reluctant to betrothe older women to boys
		trigger = {
			scope:secondary_actor = {
				age > 25
				is_female = yes
			}
			scope:secondary_recipient = {
				is_adult = no
			}
		}
		target = scope:secondary_actor
		value = age
		multiplier = -20.0 #Modded from -5
		step = 1
		offset = -25
		desc = MARRY_AGE
	}
	
	compare_modifier = { # MODDED ADDITION Actor is EXTRA reluctant to betrothe older women to boys
		trigger = {
			scope:secondary_recipient = {
				age > 25
				is_female = yes
			}
			scope:secondary_actor = {
				is_adult = no
			}
		}
		target = scope:secondary_recipient
		value = age
		multiplier = -20.0 #Modded from -5
		step = 1
		offset = -25
		desc = MARRY_AGE
	}	
	modifier = { # A Recipient is VERY unlikely to agree to a marriage where the Secondary_recipient is a fertile woman and the Secondary_actor is an underage boy who won't become an adult before the woman is infertile
		add = -1001 #Modded from -200
		
		scope:secondary_recipient = {
			is_female = yes
			#is_adult = yes #Hashed out so it applies to child to child betrothals that fall under the age gap set below in marriage_fertile_age_value (29-16=13 year age gap allowed)
			#age < 45 #MODDED Hashed out so boys don't betrothe unfertile woman
			#OR = {	#MODDED Hashed out so it applies to everyone
			#	AND = {
			#		exists = scope:secondary_recipient.dynasty
			#		scope:secondary_recipient.dynasty = {
			#			OR = {
			#				any_dynasty_member = {
			#					count >= 2
			#				}
			#				dynasty_prestige_level > 1
			#			}
			#		}
			#	}
			#	is_ruler = yes
			#	is_close_or_extended_family_of = scope:recipient
			#	this = scope:recipient.player_heir
			#}
		}
		scope:secondary_actor = {
			is_adult = no
		}
		marriage_fertile_age_reverse_value >= 29 #MODDED FROM 43
		
		#Modded from MARRY_LOW_FERTILITY_REASON
		desc = MARRY_AGE
	}

	modifier = { # A Recipient is VERY unlikely to agree to a marriage where the Secondary_actor is a woman and the Secondary_recipient is an underage boy who won't become an adult before the woman is infertile
		add = -1002 #Modded from -200
		
		scope:secondary_actor = {
			is_female = yes
			#is_adult = yes #Hashed out so it applies to child to child betrothals that fall under the age gap set below in marriage_fertile_age_value (29-16=13 year age gap allowed)
		}
		scope:secondary_recipient = {
			is_adult = no
			#OR = { #Modded Hashed out so it applies to everyone
			#	AND = {
			#		exists = scope:secondary_recipient.dynasty
			#		scope:secondary_recipient.dynasty = {
			#			OR = {
			#				any_dynasty_member = {
			#					count >= 2
			#				}
			#				dynasty_prestige_level > 1
			#			}
			#		}
			#	}
			#	is_ruler = yes
			#	is_close_or_extended_family_of = scope:recipient
			#	this = scope:recipient.player_heir
			#}
		}
		marriage_fertile_age_value >= 29 #MODDED FROM 43
		
		#Modded from MARRY_LOW_FERTILITY_REASON
		desc = MARRY_AGE
	}
	
	modifier = { # A Recipient is unlikely to agree to a marriage where the Secondary_recipient is fertile and the Secondary_actor isn't even if Secondary_recipient has children
		add = -200 #Modded from -100
		
		scope:secondary_recipient = {
			NAND = {
				#is_female = yes #Men can marry their infertile friends and lovers after they've had two kids
				is_ruler = yes
				OR = {
					has_relation_lover = scope:secondary_actor
					has_relation_soulmate = scope:secondary_actor
					has_relation_friend = scope:secondary_actor
					has_relation_best_friend = scope:secondary_actor
				}
			}
			OR = {
				fertility > 0.1
				is_adult = no
			}
			#OR = { #MODDED Hashed out so it applies to everyone
			#	AND = {
			#		exists = scope:secondary_recipient.dynasty
			#		scope:secondary_recipient.dynasty = {
			#			OR = {
			#				any_dynasty_member = {
			#					count >= 2
			#				}
			#				dynasty_prestige_level > 1
			#			}
			#		}
			#	}
			#	is_ruler = yes
			#	is_close_or_extended_family_of = scope:recipient
			#	this = scope:recipient.player_heir
			#}
			OR = {
				is_female = no
				#Modded to add floating female age
				AND = {
					is_female = yes
					age <= marriage_female_fertility_cutoff_age_value
				}								  
			}
			any_child = {
				count >= 2 #Modded from one
			}
		}
		scope:secondary_actor = {
			NAND = {
				#is_female = yes #Men can marry their infertile friends and lovers after they've had two kids
				is_ruler = yes
				OR = {
					has_relation_lover = scope:secondary_recipient
					has_relation_soulmate = scope:secondary_recipient
					has_relation_friend = scope:secondary_recipient
					has_relation_best_friend = scope:secondary_recipient
				}
			}
			is_adult = yes
			OR = {
				fertility < 0.1
				AND = {
					is_female = yes
					age >= marriage_female_fertility_cutoff_age_value
				}
			}
		}
		desc = MARRY_LOW_FERTILITY_REASON
	}

	modifier = { # MODDED ADDITION An actor is unlikely to agree to a marriage where the Secondary_actor is fertile and the Secondary_actor isn't even if Secondary_recipient has children
		add = -200 #Modded from -100
		
		scope:secondary_actor = {
			NAND = {
				#is_female = yes #Men can marry their infertile friends and lovers after they've had two kids
				is_ruler = yes
				OR = {
					has_relation_lover = scope:secondary_recipient
					has_relation_soulmate = scope:secondary_recipient
					has_relation_friend = scope:secondary_recipient
					has_relation_best_friend = scope:secondary_recipient
				}
			}
			OR = {
				fertility > 0.1
				is_adult = no
			}
			#OR = { #MODDED Hashed out so it applies to everyone
			#	AND = {
			#		exists = scope:secondary_recipient.dynasty
			#		scope:secondary_recipient.dynasty = {
			#			OR = {
			#				any_dynasty_member = {
			#					count >= 2
			#				}
			#				dynasty_prestige_level > 1
			#			}
			#		}
			#	}
			#	is_ruler = yes
			#	is_close_or_extended_family_of = scope:recipient
			#	this = scope:recipient.player_heir
			#}
			OR = {
				is_female = no
				#Modded to add floating female age
				AND = {
					is_female = yes
					age <= marriage_female_fertility_cutoff_age_value
				}								  
			}
			any_child = {
				count >= 2 #Modded from one
			}
		}
		scope:secondary_recipient = {
			NAND = {
				#is_female = yes #Men can marry their infertile friends and lovers after they've had two kids
				is_ruler = yes
				OR = {
					has_relation_lover = scope:secondary_actor
					has_relation_soulmate = scope:secondary_actor
					has_relation_friend = scope:secondary_actor
					has_relation_best_friend = scope:secondary_actor
				}
			}
			is_adult = yes
			OR = {
				fertility < 0.1
				AND = {
					is_female = yes
					age >= marriage_female_fertility_cutoff_age_value
				}
			}
		}
		desc = MARRY_LOW_FERTILITY_REASON
	}

	modifier = { # A Recipient is VERY unlikely to agree to a marriage where the Secondary_recipient is fertile and the Secondary_actor isn't if Secondary_recipient doesn't have children
		add = -1003 #Modded from -200
		
		scope:secondary_recipient = {
			NAND = {
				is_female = yes
				is_ruler = yes
				OR = {
					has_relation_lover = scope:secondary_actor
					has_relation_soulmate = scope:secondary_actor
					has_relation_friend = scope:secondary_actor
					has_relation_best_friend = scope:secondary_actor
				}
			}
			OR = {
				fertility > 0.1
				is_adult = no
			}
			#OR = {
			#	AND = {
			#		exists = scope:secondary_recipient.dynasty
			#		scope:secondary_recipient.dynasty = {
			#			OR = {
			#				any_dynasty_member = {
			#					count >= 2
			#				}
			#				dynasty_prestige_level > 1
			#			}
			#		}
			#	}
			#	is_ruler = yes
			#	is_close_or_extended_family_of = scope:recipient
			#	this = scope:recipient.player_heir
			#}
			OR = {
				is_female = no
				#Modded to add floating age
				AND = {
					is_female = yes
					age <= marriage_female_fertility_cutoff_age_value
				}								  
			}
			any_child = {
				count < 2 #Modded from one
			}
		}
		scope:secondary_actor = {
			NAND = {
				is_female = yes
				is_ruler = yes
				OR = {
					has_relation_lover = scope:secondary_recipient
					has_relation_soulmate = scope:secondary_recipient
					has_relation_friend = scope:secondary_recipient
					has_relation_best_friend = scope:secondary_recipient
				}
			}
			is_adult = yes
			OR = {
				fertility < 0.1
				AND = {
					is_female = yes
					age >= marriage_female_fertility_cutoff_age_value
				}
			}
		}
										  
  
		desc = MARRY_LOW_FERTILITY_REASON
	}

	modifier = { #MODDED ADDITION A actor is VERY unlikely to agree to a marriage where the Secondary_actor	is fertile and the Secondary_recp isn't if Secondary_actor doesn't have children
		add = -1004 #Modded from -200
		
		scope:secondary_actor = {
			NAND = {
				is_female = yes
				is_ruler = yes
				OR = {
					has_relation_lover = scope:secondary_recipient
					has_relation_soulmate = scope:secondary_recipient
					has_relation_friend = scope:secondary_recipient
					has_relation_best_friend = scope:secondary_recipient
				}
			}
			OR = {
				fertility > 0.1
				is_adult = no
			}
			#OR = {
			#	AND = {
			#		exists = scope:secondary_recipient.dynasty
			#		scope:secondary_recipient.dynasty = {
			#			OR = {
			#				any_dynasty_member = {
			#					count >= 2
			#				}
			#				dynasty_prestige_level > 1
			#			}
			#		}
			#	}
			#	is_ruler = yes
			#	is_close_or_extended_family_of = scope:recipient
			#	this = scope:recipient.player_heir
			#}
			OR = {
				is_female = no
				#Modded to add floating age
				AND = {
					is_female = yes
					age <= marriage_female_fertility_cutoff_age_value	  
				}
			}
			any_child = {
				count < 2 #Modded from one
			}
		}
		scope:secondary_recipient = {
			NAND = {
				is_female = yes
				is_ruler = yes
				OR = {
					has_relation_lover = scope:secondary_actor
					has_relation_soulmate = scope:secondary_actor
					has_relation_friend = scope:secondary_actor
					has_relation_best_friend = scope:secondary_actor
				}
			}
			is_adult = yes
			OR = {
				fertility < 0.1
				AND = {
					is_female = yes
					age >= marriage_female_fertility_cutoff_age_value
				}											
			}
		} 
		desc = MARRY_LOW_FERTILITY_REASON
	}
	
	modifier = { # Unimportant courtier? Fair game, have them.
		add = 10

		scope:secondary_recipient = {
			is_adult = yes
			NOR = {
				dynasty = scope:recipient.dynasty
				is_close_or_extended_family_of = scope:recipient
				
				is_councillor_of = scope:recipient
				has_relation_lover = scope:recipient
				has_relation_soulmate = scope:recipient
				has_relation_friend = scope:recipient
				has_relation_best_friend = scope:recipient
				is_knight_of = scope:recipient
				exists = inspiration
			}
		}
		desc = MARRY_UNIMPORTANT_COURTIER_REASON
	}

	modifier = {
		add = -10
		scope:secondary_recipient = {
			is_adult = yes
			OR = {		
				is_councillor_of = scope:recipient
				has_relation_lover = scope:recipient
				has_relation_soulmate = scope:recipient
				has_relation_friend = scope:recipient
				has_relation_best_friend = scope:recipient
				is_knight_of = scope:recipient
				AND = {
					exists = inspiration
					inspiration = {
						exists = inspiration_sponsor
						inspiration_sponsor = scope:recipient
					}
				}
			}
		}
		desc = MARRY_CARES_ABOUT_COURTIER_REASON
	}

	modifier = {
		add = -25
		scope:secondary_recipient = {
			any_child = {
				is_child_of = scope:recipient
			}
			NOT = { this = scope:recipient }
		}
		desc = MARRY_PARENT_OF_CHILDREN_REASON
	}


	#########
	# LIEGE #
	#########
	modifier = { # A Recipient is more likely to agree to a marriage arranged by their liege.
		add = 40
		
		scope:recipient = {
			target_is_liege_or_above = scope:actor
			NOT = { target_is_liege_or_above = scope:secondary_actor }
			OR = {
				opinion = {
					target = scope:secondary_actor
					value > -40
				}
				NOT = { is_close_or_extended_family_of = scope:secondary_recipient }
			}
		}
		desc = LIEGE_REASON
	}

	modifier = { # A Recipient is more likely to agree to a marriage with their liege.
		add = 60
		
		scope:recipient = {
			target_is_liege_or_above = scope:secondary_actor
		}
		desc = LIEGE_REASON
	}

	#############
	# CLAIMANTS #
	#############
	modifier = { # Don't agree to marry off Claimants to inconsequential courtiers
		add = -50
		scope:secondary_recipient = {
			is_claimant = yes
			NOT = {
				any_claim = {
					holder = scope:recipient
				}
			}
			NOR = {
				this = scope:recipient
				is_close_or_extended_family_of = scope:recipient
			}
		}
		scope:secondary_actor = {
			is_landed = no
			NOT = { is_close_or_extended_family_of = scope:secondary_recipient }
		}
		desc = VALUABLE_CLAIMANT
	}
	
	modifier = { # Reluctance in marrying off Claimants to my own titles, if I am not related to the secondary_recipient. I'd rather keep the claimants under lock and key!
		add = -50
		scope:secondary_recipient = {
			any_claim = {
				holder = scope:recipient
			}
			NOT = { is_close_or_extended_family_of = scope:recipient }
		}
		desc = CLAIMANT_TO_MY_TITLES
	}

	#########
	# DREAD #
	#########
	#More likely to accept a preposition that doesn't include them if they fear you
	modifier = {
		add = intimidated_marriage_reason_value
		scope:recipient = {
			NOT = { this = scope:secondary_recipient }
			target_is_liege_or_above = scope:actor
			has_dread_level_towards = {
				target = scope:actor
				level = 1
			}
		}
		desc = INTIMIDATED_REASON
	}
	modifier = {
		add = cowed_marriage_reason_value
		scope:recipient = {
			NOT = { this = scope:secondary_recipient }
			target_is_liege_or_above = scope:actor
			has_dread_level_towards = {
				target = scope:actor
				level = 2
			}
		}
		desc = COWED_REASON
	}
	
	modifier = {
		add = intimidated_marriage_external_reason_value
		scope:recipient = {
			NOT = { this = scope:secondary_recipient }
			NOT = { target_is_liege_or_above = scope:actor }
			has_dread_level_towards = {
				target = scope:actor
				level = 1
			}
		}
		desc = INTIMIDATED_REASON
	}
	modifier = {
		add = cowed_marriage_external_reason_value
		scope:recipient = {
			NOT = { this = scope:secondary_recipient }
			NOT = { target_is_liege_or_above = scope:actor }
			has_dread_level_towards = {
				target = scope:actor
				level = 2
			}
		}
		desc = COWED_REASON
	}
	#Less likely to accept a marriage with someone they are scared off
	modifier = {
		add = -50
		scope:actor = scope:secondary_actor
		scope:recipient = {
			this = scope:secondary_recipient
			target_is_liege_or_above = scope:actor
			has_dread_level_towards = {
				target = scope:actor
				level = 1
			}
		}
		desc = INTIMIDATED_REASON
	}
	modifier = {
		add = -75
		scope:actor = scope:secondary_actor
		scope:recipient = {
			this = scope:secondary_recipient
			target_is_liege_or_above = scope:actor
			has_dread_level_towards = {
				target = scope:actor
				level = 2
			}
		}
		desc = COWED_REASON
	}
	
	modifier = {
		add = -75
		scope:actor = scope:secondary_actor
		scope:recipient = {
			this = scope:secondary_recipient
			NOT = { target_is_liege_or_above = scope:actor }
			has_dread_level_towards = {
				target = scope:actor
				level = 1
			}
		}
		desc = INTIMIDATED_REASON
	}
	modifier = {
		add = -150
		scope:actor = scope:secondary_actor
		scope:recipient = {
			this = scope:secondary_recipient
			NOT = { target_is_liege_or_above = scope:actor }
			has_dread_level_towards = {
				target = scope:actor
				level = 2
			}
		}
		desc = COWED_REASON
	}
	#More likely to accept a marriage proposal from someone they're scared of if they're not the secondary_actor
	modifier = {
		add = intimidated_marriage_not_secondary_reason_value
		NOT = { scope:actor = scope:secondary_actor }
		scope:recipient = {
			this = scope:secondary_recipient
			has_dread_level_towards = {
				target = scope:actor
				level = 1
			}
		}
		desc = INTIMIDATED_REASON
	}
	modifier = {
		add = cowed_marriage_not_secondary_reason_value
		NOT = { scope:actor = scope:secondary_actor }
		scope:recipient = {
			this = scope:secondary_recipient
			has_dread_level_towards = {
				target = scope:actor
				level = 2
			}
		}
		desc = COWED_REASON
	}

	opinion_modifier = { # Additional reluctance if recipient likes the close relative
		trigger = {
			NOT = { scope:recipient = scope:secondary_recipient }
			scope:recipient = {
				OR = {
					is_close_or_extended_family_of = scope:secondary_recipient
					has_relation_lover = scope:secondary_recipient
				}
				opinion = {
					target = scope:secondary_recipient
					value > 10
				}
			}
		}
	
		who = scope:recipient
		opinion_target = scope:secondary_recipient
		multiplier = -0.15
		desc = DEAR_TO_ME_REASON
	}

	### FAMILY CONSIDERATIONS
	modifier = {
		add = -1000
		scope:recipient.faith = {
			NOT = {
				faith_allows_marriage_consanguinity_trigger = { CHARACTER_1 = scope:secondary_recipient CHARACTER_2 = scope:secondary_actor }
			}
		}
		desc = MARRY_CONSANGUINITY_REASON
	}
	
	modifier = {
		trigger = {
			scope:secondary_recipient = {
				age > 20
				OR = {
					dynasty = scope:recipient.dynasty
					is_close_or_extended_family_of = scope:recipient
				}
			}
		}
		add = {
			value = scope:secondary_recipient.age
			subtract = 20
		}
		desc = MARRIAGE_DESPERATION
	}

	modifier = { #The actor's spouse has boosted the AI's willingness to marry the heir
		add = 75
		scope:actor = {
			exists = player_heir
			player_heir = scope:secondary_actor
		}
		scope:secondary_actor = {
			has_character_modifier = heir_easier_to_marry_off_modifier
		}
		desc = MARRIAGE_SPOUSE_COUNCILLOR_BOOST_HEIR
	}
	modifier = {
		add = 50
		scope:secondary_actor = {
			is_child_of = scope:actor
			has_character_modifier = child_easier_to_marry_off_modifier
		}
		desc = MARRIAGE_SPOUSE_COUNCILLOR_BOOST_CHILD
	}


	################
	# INSPIRATIONS #
	################

	modifier = { # Inspired people will be _very_ hesitant
		exists = scope:secondary_recipient.inspiration
		has_completed_inspiration = no
		add = -100
		desc = IS_FOCUSING_ON_INSPIRATION_MODIFIER
	}

	##################
	# COURT GRANDEUR #
	##################

	modifier = { # Court grandeur level above expected level gives a boost 
		add = ep1_court_grandeur_marriage_acceptance_value
		desc = COURT_GRANDEUR_LEVEL_MARRIAGE_ACCEPTANCE_BOOST_MODIFIER
		scope:actor = {
			has_royal_court = yes
			court_grandeur_current_level > court_grandeur_minimum_expected_level
		}
	}

	modifier = { # Court grandeur level below expected level gives a penalty 
		add = ep1_court_grandeur_marriage_acceptance_value_penalty
		desc = COURT_GRANDEUR_LEVEL_MARRIAGE_ACCEPTANCE_PENALTY_MODIFIER
		scope:actor = {
			has_royal_court = yes
			court_grandeur_current_level < court_grandeur_minimum_expected_level
		}
	}
	
	################
	#  TRADITIONS  #
	################
	modifier = { # Wedding Ceremonies
		scope:actor.culture = { has_cultural_parameter = marriage_acceptance_bonus }
		add = 10
		desc = TRADITION_BONUS_WEDDING_CEREMONIES
	}
	modifier = {
		add = -50
		scope:recipient = {
			culture = {
				has_cultural_parameter = dislikes_marrying_outside_of_culture
			}
		}
		NOT = {
			scope:recipient.culture = scope:actor.culture
		}
		desc = TRADITION_PENALTY_ISOLATIONIST
	}

	################
	#  STRUGGLES   #
	################
	modifier = {
		add = 25
		desc = STRUGGLE_MARRIAGE_ACCEPTANCE_BOTH_INVOLVED_BONUS
		scope:actor = {
			any_character_struggle = {
				involvement = involved
				is_struggle_parameter_active_secondary_character_involvement_involved_trigger = {
					PARAMETER = involved_form_alliances_with_each_other_easier
					CHAR = scope:recipient
				}
			}
		}
	}

	# We add some hidden reluctance for the AI selecting/accepting marriages from outside a struggle they're involved in unless a player is taking part.
	## Involved struggle characters will seek to avoid marrying anyone outside the struggle who isn't already quite powerful.
	modifier = {
		factor = {
			value = 0
			if = {
				limit = {
					scope:actor = {
						is_ai = yes
						any_character_struggle = {
							involvement = involved
							phase_has_catalyst = catalyst_forming_alliance_with_major_uninvolved_power
						}
					}
				}
				if = {
					limit = {
						scope:recipient = {
							is_ai = yes
							realm_size <= medium_realm_size
						}
					}
					add = 0.2
				}
				else_if = {
					limit = {
						scope:recipient = {
							is_ai = yes
							any_character_struggle = {
								involvement = involved
								phase_has_catalyst = catalyst_forming_alliance_with_major_uninvolved_power
							}
						}
						scope:actor = {
							is_ai = yes
							realm_size <= medium_realm_size
						}
					}
					add = 0.2
				}
			}
		}
		OR = {
			AND = {
				# The actor is involved and try to marry with someone outside of it
				scope:actor = {
					is_ai = yes
					any_character_struggle = {
						involvement = involved
						is_secondary_character_involvement_neither_trigger = { CHAR = scope:recipient }
					}
				}
				scope:recipient = {
					is_ai = yes
				}
			}
			AND = {
				# The actor is not involved and try to marry with someone inside of it
				scope:recipient = {
					is_ai = yes
					any_character_struggle = {
						involvement = involved
						is_secondary_character_involvement_neither_trigger = { CHAR = scope:actor }
					}
				}
				scope:actor = {
					is_ai = yes
				}
			}
		}
	}
	## And heavily weight down interlopers and powerful uninvolved because they're strange and foreign.
	modifier = {
		factor = 0.5
		OR = {
			AND = {
				scope:actor = {
					is_ai = yes
					any_character_struggle = {
						involvement = involved
						is_secondary_character_involvement_interloper_trigger = { CHAR = scope:recipient }
					}
				}
				scope:recipient = { is_ai = yes }
			}
			AND = {
				scope:recipient = {
					is_ai = yes
					any_character_struggle = {
						involvement = involved
							is_secondary_character_involvement_interloper_trigger = { CHAR = scope:actor }
					}
				}
				scope:actor = { is_ai = yes }
			}
		}
	}

	###########
	#  FEUD   #
	###########
	modifier = {
		add = -25
		scope:recipient = {
			exists = house
			house.house_head = {
				house_feud_target_house_trigger = { HOUSE = scope:actor.house }
			}
		}
		desc = MARRY_FAMILY_FEUD_REASON
	}

	#############
	#  HAROLD   #
	#############
	#Poor Harold :(
	modifier = {
		add = -5000
		years_from_game_start <= 5
		OR = {
			scope:actor = character:122
			scope:recipient = character:122
			scope:secondary_actor = character:122
			scope:secondary_recipient = character:122
		}
		scope:actor = {
			is_ai = yes
		}
		scope:recipient = {
			is_ai = yes
		}
		scope:secondary_actor = {
			is_ai = yes
		}
		scope:secondary_recipient = {
			is_ai = yes
		}
	}
}