﻿# this = candidate in-law ruler, $PLAYER$ = the human ruler
nmt_valid_truce_pair_trigger = {
	is_alive = yes
	is_ruler = yes
	is_landless_ruler = no
	highest_held_title_tier >= tier_county
	NOT = { this = $PLAYER$ }
	NOT = { is_close_family_of = $PLAYER$ }
	NOT = { top_liege = $PLAYER$.top_liege }
	$PLAYER$ = {
		is_ai = no
		is_alive = yes
		is_ruler = yes
		highest_held_title_tier >= tier_county
	}
}

# this = the human ruler. True if the player or a close relative has another spouse or
# betrothed (not $TARGET$) linked to $RULER$, so one choice covers several couples.
nmt_other_tie_with_ruler_trigger = {
	OR = {
		nmt_other_partner_tied_trigger = { RULER = $RULER$ TARGET = $TARGET$ }
		any_close_family_member = {
			nmt_other_partner_tied_trigger = { RULER = $RULER$ TARGET = $TARGET$ }
		}
	}
}

# this = the player or a close relative
nmt_other_partner_tied_trigger = {
	OR = {
		any_spouse = {
			NOT = { this = $TARGET$ }
			nmt_partner_tied_to_trigger = { RULER = $RULER$ }
		}
		AND = {
			is_betrothed = yes
			betrothed = {
				NOT = { this = $TARGET$ }
				nmt_partner_tied_to_trigger = { RULER = $RULER$ }
			}
		}
	}
}

# this = a partner. Uses the ruler the mod linked them to; before they are linked,
# the ruler or the ruler's close family counts.
nmt_partner_tied_to_trigger = {
	OR = {
		this = $RULER$
		AND = {
			exists = var:nmt_tie_ruler
			var:nmt_tie_ruler = $RULER$
		}
		AND = {
			NOT = { exists = var:nmt_tie_ruler }
			is_close_family_of = $RULER$
		}
	}
}
