﻿marriage_interaction_can_be_picked_trigger = {
	can_marry_trigger = yes
	is_available_quick = {
		hostage = no
		imprisoned = no
	}
	
	#to prevent rulers from being able to arrange marriage during their own introductions
	NAND = {
		has_variable = intro_secondary_actor
		has_variable = intro_secondary_recipient
		has_variable = intro_actor
		has_variable = intro_recipient
		OR = {
			this = var:intro_actor
			this = var:intro_recipient
		}
		OR = {
			this = var:intro_secondary_actor
			this = var:intro_secondary_recipient
		}
	}
}

marriage_interaction_valid_target_trigger = {
	# Clergy cannot marry if their faith doesn't allow it
	trigger_if = {
		limit = {
			scope:secondary_actor = {
				is_clergy = yes
				NOT = {
					faith = {
						has_doctrine_parameter = clergy_can_marry
					}
				}
			}
		}
		custom_description = {
			text = character_is_clergy_and_cannot_marry
			subject = scope:secondary_actor
			object = scope:secondary_recipient
			scope:secondary_actor = {
				is_clergy = no
			}
		}
	}
	trigger_else_if = {
		limit = {
			scope:secondary_recipient = {
				is_clergy = yes
				NOT = {
					faith = {
						has_doctrine_parameter = clergy_can_marry
					}
				}
			}
		}
		custom_description = {
			text = character_is_clergy_and_cannot_marry
			subject = scope:secondary_recipient
			object = scope:secondary_actor
			scope:secondary_recipient = {
				is_clergy = no
			}
		}
	}
	#Marriage
	trigger_else_if = {
		limit = {
			scope:secondary_actor = { is_adult = yes }
			scope:secondary_recipient = { is_adult = yes }
		}
		scope:secondary_actor = {
			custom_description = {
				text = "can_marry_check_secondary_actor"
				subject = scope:secondary_actor
				object = scope:secondary_recipient
				can_marry_character_trigger = { CHARACTER = scope:secondary_recipient } #Checks marriage status, betrothed, gender, consanguinity, faith hostility etc.
				NOR = {
					has_opinion_modifier = { modifier = ended_engagement_opinion target = scope:secondary_recipient }
					reverse_has_opinion_modifier = { modifier = ended_engagement_opinion target = scope:secondary_recipient }
				}
			}
		}
	}
	#Betrothal
	trigger_else = {
		scope:secondary_actor = {
			custom_description = {
				text = "can_betroth_check_secondary_actor"
				subject = scope:secondary_actor
				object = scope:secondary_recipient
				can_marry_character_trigger = { CHARACTER = scope:secondary_recipient } #Checks marriage status, betrothed, gender, consanguinity, faith hostility etc.
				NOR = {
					has_opinion_modifier = { modifier = ended_engagement_opinion target = scope:secondary_recipient }
					reverse_has_opinion_modifier = { modifier = ended_engagement_opinion target = scope:secondary_recipient }
				}
			}
		}
	}

	# If the actor is ai they will not pick a character already considered for concubinage
	trigger_if = {
		limit = {
			scope:actor = { is_ai = yes }
		}
		NOR = {
			scope:secondary_actor = { has_character_flag = has_been_offered_as_concubine }
			scope:secondary_recipient = { has_character_flag = has_been_offered_as_concubine }
		}
	}
	
	# Prevents AI from ignoring marriage AI modifiers
	trigger_if = {
		limit = {
			scope:actor = { is_ai = yes }
			scope:recipient = { is_ai = yes }
		}
		ai_marriage_restrictions_trigger = yes
	}
}

# $CHARACTER$ has the right to break betrothal or receive interaction for breaking betrothal?
break_betrothal_valid_target_trigger = {
	is_betrothed = yes
	# yourself, your courtier, or your child vassal and you were the matchmaker
	trigger_if = {
		limit = {
			this != $CHARACTER$
		}
		is_ai = yes
		OR = {
			AND = {
				is_child_of = $CHARACTER$
				target_is_liege_or_above = $CHARACTER$
				NOT = {
					matchmaker = {
						is_parent_of = prev
						this != $CHARACTER$
					}
				}
			}
			AND = {
				is_playable_character = no
				liege = $CHARACTER$
			}
			is_non_courtier_marriage_candidate = { RULER = $CHARACTER$ }
		}
	}
}

