remove_guardian_interaction_visible_ward_trigger = {
	OR = {
		#If I am the child
		this = scope:actor
		#The ward has actor as its liege
		AND = {
			exists = employer
			employer = scope:actor
		}
		#The guardian is actor
		any_relation = {
			type = guardian
			this = scope:actor
		}
		#The guardian is actor's courtier
		any_relation = {
			type = guardian
			is_courtier_of = scope:actor
		}
	}
}

remove_guardian_interaction_available_ward_trigger = {
	is_busy_in_events_localised = yes
	#is_imprisoned = no
}

kick_from_court_validity_trigger = {
	is_busy_in_events_localised = yes
	NOR = {
		is_spouse_of = scope:actor
		is_concubine_of = scope:actor
		is_close_family_of = scope:actor
		has_council_position = councillor_court_chaplain
		is_diarch = yes
		# Marriage major partners of diarchs.
		## Female.
		AND = {
			is_married = yes
			is_female = yes
			matrilinear_marriage = yes
			any_consort = { is_diarch = yes }
		}
		## Male.
		AND = {
			is_married = yes
			is_male = yes
			patrilinear_marriage = yes
			any_consort = { is_diarch = yes }
		}
	}
}

ask_for_pardon_available_trigger = {
	$ACTOR$ = {
		is_independent_ruler = no
		any_liege_or_above = {
			OR = {
				has_imprisonment_reason = $ACTOR$
				has_banish_reason = $ACTOR$
				has_execute_reason = $ACTOR$
				has_revoke_title_reason = $ACTOR$
			}
		}
	}
}

title_revocation_standard_valid_showing_failures_only_trigger = {
	scope:actor = {
		NOR =  {
			is_at_war_with = scope:recipient
			has_truce = scope:recipient
		}
		custom_description = {
			text = "character_interactions_revoke_title_from_ally_without_reason"
			object = scope:recipient
			OR = {
				NOT = {
					is_allied_to = scope:recipient
				}
				has_revoke_title_reason = scope:recipient
			}
		}
	}
	scope:recipient = {
		is_busy_in_events_localised = yes
		NOT = { has_strong_hook = scope:actor }
	}
}

title_revocation_standard_can_pick_title_trigger = {
	is_contested = no
	custom_description = {
		text = "revoke_title_not_noble_family_title"
		is_noble_family_title = no
	}
	NOT = {
		recent_history = {
			type = granted
			years = 1
		}
	}
	custom_description = {
		text = "character_interactions_not_rel_head_title"
		is_head_of_faith = no
	}
}

diarch_revocation_has_claim_check_trigger = {
	custom_description = {
		text = diarch_has_claim_on_revokable_title
		object = scope:recipient
		scope:actor = {
			any_claim = {
				exists = holder
				holder = scope:recipient
			}
		}
	}
}

title_revocation_is_admin_governor_trigger = {
	has_government = administrative_government
	is_independent_ruler = yes
	save_temporary_scope_as = liege_temp
	$VASSAL$ = {
		is_landed_or_landless_administrative = yes
		target_is_liege_or_above = scope:liege_temp
	}
}

title_revocation_is_tyrannical_trigger = {
	NOR = {
		exists = scope:administrative_revocation
		has_revoke_title_reason = $VASSAL$
		trigger_if = {
			limit = { exists = scope:landed_title }
			has_claim_on = scope:landed_title
		}
		title_revocation_is_admin_governor_trigger = { VASSAL = $VASSAL$ }
		faith = {
			$VASSAL$ = {
				NOT = { vassal_contract_has_flag = religiously_protected}
			}
			OR = {
				AND = {
					has_doctrine_parameter = pluralism_righteous_revocation_tyranny_reduced
					faith_hostility_level = {
						target = $VASSAL$.faith
						value = faith_evil_level
					}
				}
				AND = {
					has_doctrine_parameter = pluralism_fundamentalist_revocation_tyranny_minimal
					faith_hostility_level = {
						target = $VASSAL$.faith
						value >= faith_hostile_level
					}
				}
			}
		}
	}
}

vassal_revocation_is_tyrannical_trigger = {
	NOR = {
		exists = scope:administrative_revocation
		AND = {
			has_government = administrative_government
			$VASSAL$ = {
			 	has_government = administrative_government
			}
		}
		has_revoke_title_reason = $VASSAL$
		faith = {
			OR = {
				AND = {
					has_doctrine_parameter = pluralism_righteous_revocation_tyranny_reduced
					faith_hostility_level = {
						target = $VASSAL$.faith
						value = faith_evil_level
					}
				}
				AND = {
					has_doctrine_parameter = pluralism_fundamentalist_revocation_tyranny_minimal
					faith_hostility_level = {
						target = $VASSAL$.faith
						value >= faith_hostile_level
					}
				}
			}
		}
	}
}

vassal_retraction_standard_valid_showing_failures_only_trigger = {
	NOT = {
		scope:actor = { is_at_war_with = scope:recipient }
	}
	scope:recipient = { is_busy_in_events_localised = yes }
	trigger_if = {
		limit = { exists = scope:secondary_recipient }
		scope:secondary_recipient = { is_busy_in_events_localised = yes }
	}
	scope:recipient = {
		NOT = { has_strong_hook = scope:actor }
	}
}

diarch_retraction_is_de_jure_liege_trigger = {
	custom_description = {
		text = "diarch_is_de_jure_liege_of_retractable_vassal"
		object = scope:recipient
		scope:actor = {
			any_held_title = {
				any_direct_de_jure_vassal_title = { holder.liege = scope:recipient }
			}
		}
	}
}

is_de_jure_vassal_of_liege_trigger = {
	liege = {
		save_temporary_scope_as = my_liege
	}
	primary_title = {
		OR = {
			de_jure_liege = {
				exists = holder
				holder = scope:my_liege
			}
			trigger_if = {
				limit = {
					tier = tier_duchy
				}
				de_jure_liege = {
					de_jure_liege = {
						exists = holder
						holder = scope:my_liege
					}
				}
			}
		}
	}
}

send_poem_positive_poem_lock_trigger = {
	OR = {
		is_ai = no
		NOT = { has_relation_rival = scope:recipient }
		NOT = { has_relation_nemesis = scope:recipient }
	}
}

send_poem_negative_poem_lock_trigger = {
	OR = {
		is_ai = no
		has_relation_rival = scope:recipient
		has_relation_nemesis = scope:recipient
	}
}

can_any_traveling_family_members_travel_trigger = {
	NOR = {
		this = scope:recipient
		is_in_pool_at = scope:actor.capital_province
	}
	is_ruler = no
	trigger_if = {
		limit = {
			exists = scope:recipient.host
			is_child_of = scope:recipient.host
			is_adult = no
		}
		NOT = { dynasty = scope:recipient.host.dynasty }
	}
}

imprison_neutral_is_valid_showing_failures_only_triggers_trigger = {
	scope:recipient = { is_busy_in_events_localised = yes }
	scope:actor.liege = {
		trigger_if = {
			limit = { has_realm_law_flag = imprisonment_toggle_enable }
			# TIT-43801
			#has_realm_law_flag = imprisonment_toggle_on
			NOT = { has_realm_law = tribal_authority_0 }
		}
	}
	scope:actor = { is_imprisoned = no }
	custom_description = {
		text = cannot_imprison_almohad_leader
		subject = scope:recipient
		NOT = {
			scope:recipient = { has_character_modifier = almohad_leader_modifier }
		}
	}
}

grant_title_rivalry_trigger = {
	is_ai = yes
	is_playable_character = yes
	top_liege = scope:actor
	faith = scope:actor.faith
	reverse_opinion = {
		target = top_liege
		value > -50
	}
	opinion = {
		target = top_liege
		value > -50
	}
	trigger_if = {
		limit = {
			is_female = yes
			faith_dominant_gender_female_or_equal = no
		}
		scope:recipient = { is_female = yes }
	}
	trigger_if = {
		limit = {
			is_male = yes
			faith_dominant_gender_male_or_equal = no
		}
		scope:recipient = { is_male = yes }
	}
	has_dread_level_towards = {
		target = scope:actor
		level < 1
	}
	is_eunuch_trigger = no
	NOR = {
		this = scope:actor
		this = scope:recipient
		has_trait = content
		has_trait = humble
		has_trait = blind
		has_trait = devoted
		is_close_family_of = scope:recipient
		has_any_good_relationship_with_character_trigger = { CHARACTER = scope:actor }
		has_any_bad_relationship_with_character_trigger = { CHARACTER = scope:actor }
	}
}

should_prioritise_hostile_action_against_due_to_personal_relations_trigger = {
	$ACTOR$ = {
		OR = {
			has_any_bad_relationship_with_character_trigger = { CHARACTER = $RECIPIENT$ }
			opinion = {
				target = $RECIPIENT$
				value <= very_high_negative_opinion
			}
		}
	}
}

should_avoid_hostile_action_against_due_to_personal_relations_trigger = {
	$ACTOR$ = {
		OR = {
			has_any_good_relationship_with_character_trigger = { CHARACTER = $RECIPIENT$ }
			is_allied_to = $RECIPIENT$
			opinion = {
				target = $RECIPIENT$
				value >= very_high_positive_opinion
			}
			# Plus filter out heirs & other family, unless we hate 'em.
			AND = {
				OR = {
					is_close_or_extended_family_of = $RECIPIENT$
					any_spouse = { this = $RECIPIENT$ }
					is_heir_of = $RECIPIENT$
				}
				NOR = {
					has_any_bad_relationship_with_character_trigger = { CHARACTER = $RECIPIENT$ }
					exposed_cheating_on_spouse_trigger = { SPOUSE = $RECIPIENT$ }
					AND = {
						is_ai = yes
						opinion = {
							target = $RECIPIENT$
							value <= low_negative_opinion
						}
					}
				}
			}
		}
	}
}

should_avoid_hostile_action_against_due_to_liege_relations_trigger = {
	$ACTOR$ = {
		exists = liege
		liege = {
			OR = {
				has_any_good_relationship_with_character_trigger = { CHARACTER = $RECIPIENT$ }
				is_allied_to = $RECIPIENT$
				opinion = {
					target = $RECIPIENT$
					value >= very_high_positive_opinion
				}
			}
		}
	}
}

is_asking_for_gold_in_ransom_trigger = {
	OR = {
		scope:extortionate_gold ?= yes
		scope:extortionate_current_gold ?= yes
		scope:gold ?= yes
		scope:current_gold ?= yes
	}
}
