﻿revoke_leased_title_interaction = {
	category = interaction_category_uncategorized
	hidden = yes

	desc = revoke_leased_title_interaction_desc

	target_type = title
	target_filter = recipient_lessee_titles
	
	auto_accept = yes

	is_shown = {
		scope:actor = {
			any_sub_realm_barony = {
				barony_is_valid_for_holy_order_lease_cancellation_trigger = yes
				lessee ?= scope:recipient
			}
		}
	}

	#is_valid = {
	#	scope:actor = {
	#		piety >= holy_order_revoke_lease_piety_cost
	#	}
	#}
	
	has_valid_target_showing_failures_only = {
		NOT = { scope:actor = { is_at_war_with = scope:recipient } }
		#scope:target = {
		#	NOT = {
		#		recent_history = {
		#			type = leased_out
		#			years = 1
		#		}
		#	}
		#}
		scope:target = {
			has_revokable_lease = yes
			lessee = scope:recipient
			OR = {
				county.holder = { is_ai = yes }
				county.holder = scope:actor
			}
		}
		scope:recipient = { NOT = { has_strong_hook = scope:actor } }
	}

	on_accept = {
		revoke_holy_order_lease_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			BARONY = scope:target
		}
	}

	# AI
	ai_targets = {
		ai_recipients = vassals
	}
	ai_frequency = 12

	ai_potential = {
		is_playable_character = yes
		highest_held_title_tier > tier_barony
	}

	ai_will_do = {
		base = 0

		# revoke titles leased to holy orders of the wrong faith
		modifier = {
			add = 100
			scope:recipient = {
				government_has_flag = government_is_holy_order
				NOT = { faith = scope:actor.faith }
			}
		}
	}
}
