﻿appoint_holy_order_grandmaster_interaction = {
	category = interaction_category_friendly
	icon = holy_order

	desc = appoint_holy_order_grandmaster_interaction_desc

	auto_accept = yes

	is_shown = {
		scope:recipient != scope:actor
		scope:actor.faith = scope:recipient.faith
		scope:recipient = {
			is_adult = yes
			is_ruler = no
		}
		scope:actor.faith = {
			any_faith_holy_order = { count >= 1 }
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			is_available = yes
			custom_description = {
				text = "is_same_faith_tt"
				faith = scope:actor.faith
			}
		}
	}

	on_accept = {
		scope:actor = {
			trigger_event = holy_order_mod.0001
		}
	}

	ai_targets = {
		ai_recipients = none
	}
	ai_frequency = 0
	ai_will_do = {
		base = 0
	}
}

grant_barony_lease_to_holy_order_interaction = {
	category = interaction_category_friendly
	icon = holy_order

	desc = grant_barony_lease_to_holy_order_interaction_desc

	target_type = title
	target_filter = actor_realm_titles

	auto_accept = yes

	is_shown = {
		scope:recipient.primary_title ?= { is_holy_order = yes }
		scope:actor.faith = scope:recipient.faith
		scope:actor = {
			any_sub_realm_barony = {
				is_leased_out = no
			}
		}
	}

	can_be_picked_title = {
		scope:target = {
			tier = tier_barony
			is_leased_out = no
		}
	}

	has_valid_target_showing_failures_only = {
		scope:target = {
			tier = tier_barony
			is_leased_out = no
		}
	}

	on_accept = {
		if = {
			limit = { scope:target.holder != scope:actor }
			create_title_and_vassal_change = {
				type = leased_out
				save_scope_as = change
				add_claim_on_loss = no
			}
			scope:target = {
				change_title_holder_include_vassals = {
					holder = scope:actor
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
		}
		scope:target = {
			lease_out_to = scope:recipient.holy_order
		}
		scope:recipient = {
			add_opinion = {
				target = scope:actor
				modifier = pleased_opinion
				opinion = 30
			}
		}
		send_interface_toast = {
			type = holy_order_expanded_message
			title = grant_barony_lease_toast_title
			desc = grant_barony_lease_toast_desc
			left_icon = scope:actor
			right_icon = scope:recipient
		}
	}

	ai_targets = {
		ai_recipients = none
	}
	ai_frequency = 0
	ai_will_do = {
		base = 0
	}
}
