﻿# Same trigger as above with the exception of the recent divorce trigger
can_take_as_concubine_character_trigger = {
	save_temporary_scope_as = can_marry_check
	can_marry_common_trigger = yes
	$CHARACTER$ = { can_marry_common_trigger = yes }
	#Opposite genders if you don't have accepted same-sex marriage game rule enabled and your faith supports it
	trigger_if = {
		limit = {
			is_ai = yes
			$CHARACTER$ = { allowed_to_marry_same_sex_trigger = no }
		}
		sex_opposite_of = $CHARACTER$
	}
	#Faith hostility & consanguinity
	# Player-only unrestricted: AI keeps vanilla faith/consanguinity checks
	trigger_if = {
		limit = {
			is_ai = yes
			NOT = { is_courtier_of = $CHARACTER$ } # If you're someone's courtier, your liege can take you anyway
		}
		faith = {
			faith_allows_marriage_consanguinity_trigger = {
				CHARACTER_1 = scope:can_marry_check
				CHARACTER_2 = $CHARACTER$
			}
			#faith_hostility_level = {
			#	target = $CHARACTER$.faith
			#	value < faith_hostility_prevents_marriage_level
			#}
		}
	}
	trigger_if = {
		limit = {
			is_ai = yes
			$CHARACTER$ = { NOT = { is_courtier_of = scope:can_marry_check } } # If you're someone's courtier, your liege can take you anyway
		}
		$CHARACTER$.faith = {
			faith_allows_marriage_consanguinity_trigger = {
				CHARACTER_1 = scope:can_marry_check
				CHARACTER_2 = $CHARACTER$
			}
			#faith_hostility_level = {
			#	target = scope:can_marry_check.faith
			#	value < faith_hostility_prevents_marriage_level
			#}
		}
	}

	# trigger_if = {
	# 	limit = { NOT = { is_courtier_of = $CHARACTER$ } } #If you're someone's courtier, your liege can marry you anyway
	# 	faith = {
	# 		faith_allows_marriage_consanguinity_trigger = {
	# 			CHARACTER_1 = scope:can_marry_check
	# 			CHARACTER_2 = $CHARACTER$
	# 		}
	# 		#faith_hostility_level = {
	# 		#	target = $CHARACTER$.faith
	# 		#	value < faith_hostility_prevents_marriage_level
	# 		#}
	# 	}
	# }
	# trigger_if = {
	# 	limit = { $CHARACTER$ = { NOT = { is_courtier_of = scope:can_marry_check } } } #If you're someone's courtier, your liege can marry you anyway
	# 	$CHARACTER$.faith = {
	# 		faith_allows_marriage_consanguinity_trigger = {
	# 			CHARACTER_1 = scope:can_marry_check
	# 			CHARACTER_2 = $CHARACTER$
	# 		}
	# 		#faith_hostility_level = {
	# 		#	target = scope:can_marry_check.faith
	# 		#	value < faith_hostility_prevents_marriage_level
	# 		#}
	# 	}
	# }
	NOT = {
		scope:can_marry_check = { is_spouse_of = $CHARACTER$ }
	}
}

#two characters could potentially marry (does NOT check that they're unmarried)
could_marry_character_trigger = {
	save_temporary_scope_as = can_marry_check
	can_marry_common_trigger = yes
	$CHARACTER$ = { can_marry_common_trigger = yes }

	# Opposite genders ONLY for AI if same-sex marriage is not allowed
	trigger_if = {
		limit = { # If you're someone's courtier, your liege can marry you anyway
			is_ai = yes
			NOT = { is_courtier_of = $CHARACTER$ }
			allowed_to_marry_same_sex_trigger = no
		}
		sex_opposite_of = $CHARACTER$
	}
	trigger_if = {
		limit = { # If you're someone's courtier, your liege can marry you anyway
			is_ai = yes
			$CHARACTER$ = { NOT = { is_courtier_of = scope:can_marry_check } }
			$CHARACTER$ = { allowed_to_marry_same_sex_trigger = no }
		}
		sex_opposite_of = $CHARACTER$
	}
	trigger_if = {
		limit = {
			is_ai = yes
			is_courtier_of = $CHARACTER$
			$CHARACTER$ = { allowed_to_marry_same_sex_trigger = no }
		}
		sex_opposite_of = $CHARACTER$
	}
	trigger_if = {
		limit = {
			is_ai = yes
			$CHARACTER$ = { is_courtier_of = scope:can_marry_check }
			allowed_to_marry_same_sex_trigger = no
		}
		sex_opposite_of = $CHARACTER$
	}

	# Have you recently divorced this character? (applies to everyone; not an incest restriction)
	NOT = {
		has_opinion_modifier = {
			modifier = divorced_me_opinion
			target = $CHARACTER$
		}
	}

	# Faith hostility & consanguinity ONLY for AI (player is unrestricted)
	trigger_if = {
		limit = {
			is_ai = yes
			NOT = { is_courtier_of = $CHARACTER$ } # If you're someone's courtier, your liege can marry you anyway
		}
		faith = {
			faith_allows_marriage_consanguinity_trigger = {
				CHARACTER_1 = scope:can_marry_check
				CHARACTER_2 = $CHARACTER$
			}
		}
	}
	trigger_if = {
		limit = {
			is_ai = yes
			$CHARACTER$ = { NOT = { is_courtier_of = scope:can_marry_check } } # If you're someone's courtier, your liege can marry you anyway
		}
		$CHARACTER$.faith = {
			faith_allows_marriage_consanguinity_trigger = {
				CHARACTER_1 = scope:can_marry_check
				CHARACTER_2 = $CHARACTER$
			}
		}
	}

	# Cannot marry self
	NOT = { scope:can_marry_check = $CHARACTER$ }

	# Cannot marry someone you're already married to
	NOT = { scope:can_marry_check = { is_spouse_of = $CHARACTER$ } }
}
