﻿# Breaking an alliance also breaks any betrothal that was a reason for it (vanilla
# on_alliance_broken in common/on_action/alliance_on_actions.txt). So the mod must not
# cancel an alliance between two rulers while a betrothal links their families; it waits
# for the wedding instead (breaking a marriage alliance does not end the marriage).

# this = a ruler, $OTHER$ = another ruler.
# True if this ruler or a close relative is betrothed to $OTHER$, a close relative of
# $OTHER$, someone living at $OTHER$'s court, or a partner the mod remembers as tied to $OTHER$.
nmt_betrothal_links_trigger = {
	OR = {
		nmt_betrothed_to_family_of_trigger = { OTHER = $OTHER$ }
		any_close_family_member = {
			nmt_betrothed_to_family_of_trigger = { OTHER = $OTHER$ }
		}
	}
}

# this = a character
nmt_betrothed_to_family_of_trigger = {
	is_betrothed = yes
	betrothed = {
		OR = {
			this = $OTHER$
			is_close_family_of = $OTHER$
			# The game bases the alliance on the court the partner lives at, which can
			# differ from the ruler the mod linked them to (the ruler of the proposal).
			AND = {
				exists = court_owner
				court_owner = $OTHER$
			}
			AND = {
				exists = var:nmt_extra_ally
				var:nmt_extra_ally = $OTHER$
			}
			AND = {
				exists = var:nmt_tie_ruler
				var:nmt_tie_ruler = $OTHER$
			}
		}
	}
}
