﻿make_clerical_puppet_interaction = {
	category = interaction_category_diplomacy
	icon = {
		trigger = {
			scope:actor.rite = {
				rite_has_doctrine = special_doctrine_is_western_christian_faith
			}
		}
		reference = theological_agent_puppet_catholic
	}
	icon = {
		trigger = {
			scope:actor.rite = {
				NOT = { rite_has_doctrine = special_doctrine_is_western_christian_faith }
			}
		}
		reference = theological_agent_puppet
	}

	common_interaction = yes
	interface_priority = 50
	ai_instant_response = yes

	desc = make_clerical_puppet_interaction_desc

	is_available = {
		can_have_realm_priest_puppet_trigger = yes
        is_incapable = no
        trigger_if = {
            limit = {
                is_ai = yes
            }
            NOT = {
                exists = puppet:theological_agent_puppet
            }
		}
	}

	cooldown_against_recipient = { years = 10 } # Spam prevention

	is_shown = {
		scope:actor.cp:councillor_court_chaplain ?= scope:recipient
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_tooltip = {
				text = pam_already_have_clerical_puppet_tt
				NOT = {
					exists = puppet:theological_agent_puppet
				}
			}
		}
		scope:recipient = {
			is_ai = yes
			NOR = {
				is_adult = no
				has_trait = incapable
			}
            custom_tooltip = {
                text = pam_recipient_already_puppet_tt
                NOT = { exists = puppeteer }
            }
		}
	}

	can_send = {
		scope:actor = {
			custom_tooltip = {
				text = piety_level_dread_or_hook_tt
				OR = {
					piety_level >= 2
					has_hook = scope:recipient
					scope:recipient = {
						has_dread_level_towards = {
							target = scope:actor
							level >= 2
						}
					}
				}
			}
		}
	}

	ai_targets = {
        ai_recipients = councillors
    }
    ai_frequency_by_tier = {
        barony = 0
        county = 72
        duchy = 36
        kingdom = 12
        empire = 12
        hegemony = 12
    }
    ai_will_do = {
        base = 100
    }

	cost = {
		piety = {
			value = {
				value = medium_piety_value
				if = {
					limit = {
						scope:recipient = {
							is_ruler = yes
						}
					}
					multiply = {
						value = scope:recipient.highest_held_title_tier
						subtract = 1
					}
				}
			}
		}
	}

	on_accept = {
		scope:actor = {
			hidden_effect = {
				send_interface_toast = {
					type = event_toast_effect_good
					title = make_clerical_puppet_interaction_notification
					left_icon = scope:actor
					right_icon = scope:recipient
					set_puppet = {
						target = scope:recipient
						type = theological_agent_puppet
					}
					pam_generic_set_puppet_interaction_side_effects = yes
				}
			}
			show_as_tooltip = {
				pam_generic_set_puppet_interaction_side_effects = yes
			}
		}
		scope:recipient = {
			custom_tooltip = set_clerical_puppet_tt
		}
	}

	send_option = {
		is_valid = {
			scope:actor = { has_usable_hook = scope:recipient }
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	#My skills could be useful to you...?
	send_option = {
		is_valid = {
			scope:actor = {
				skill_support_trigger = yes
			}
		}
		flag = skill_support
		localization = SKILL_SUPPORT_INTERACTION_OPTION
	}
	#I will lead you into the light by my piety
	send_option = {
		is_valid = {
			scope:actor = {
				piety_support_trigger = yes
				custom_tooltip = {
					text = pious_puppet_sf_req_tt
					has_fulfillment_parameter = pious_puppet_option
				}
			}
		}
		flag = piety_support
		localization = PIETY_SUPPORT_INTERACTION_OPTION
	}
	#Become an instrument of my dreadful will, not a target of my will
	send_option = {
		is_valid = {
			scope:actor = {
				dread_support_trigger = yes
				custom_tooltip = {
					text = dread_puppet_sf_req_tt
					has_fulfillment_parameter = dread_puppet_option
				}
			}
		}
		flag = dread_support
		localization = DREAD_SUPPORT_INTERACTION_OPTION
	}
	#You can trust in me, relation
	send_option = {
		is_valid = {
			scope:actor = {
				friendly_support_trigger = yes
				custom_tooltip = {
					text = friendly_puppet_sf_req_tt
					has_fulfillment_parameter = positive_relation_puppet_option
				}
			}
		}
		flag = friendly_support
		localization = FRIENDLY_SUPPORT_INTERACTION_OPTION
	}
	#Your mind, your will, is no more
	send_option = {
		is_valid = {
			scope:actor = {
				lunacy_support_trigger = yes
			}
		}
		flag = lunacy_support
		localization = LUNACY_SUPPORT_INTERACTION_OPTION
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"
	send_options_exclusive = no

	ai_accept = {
		base = -25

		celestial_hierarchy_acceptance_modifier = {
			ACTOR = scope:actor
			RECIPIENT = scope:recipient
		}

		theocratic_related_puppet_acceptance_factors_modifier = yes
	}
}

make_external_clerical_puppet_interaction = {
	category = interaction_category_diplomacy
	icon = {
		trigger = {
			scope:actor.rite = {
				rite_has_doctrine = special_doctrine_is_western_christian_faith
			}
		}
		reference = external_theological_agent_puppet_catholic
	}
	icon = {
		trigger = {
			scope:actor.rite = {
				NOT = { rite_has_doctrine = special_doctrine_is_western_christian_faith }
			}
		}
		reference = external_theological_agent_puppet
	}
	common_interaction = yes
	interface_priority = 50
	ai_instant_response = yes
	# Clergy sit across the faith
	use_diplomatic_range = no

	desc = make_external_clerical_puppet_interaction_desc

	is_available = {
		is_adult = yes
        can_have_theological_agent_puppet_trigger = yes
		NOT = { has_trait = incapable }
        trigger_if = {
            limit = {
                is_ai = yes
            }
            NOT = {
                exists = puppet:external_theological_agent_puppet
            }
        }
		has_pam_dlc_trigger = yes
	}

	cooldown_against_recipient = { years = 10 } # Spam prevention

	is_shown = {
		scope:actor != scope:recipient
		scope:actor.faith ?= scope:recipient.faith
		scope:recipient = {
			is_clergy = yes
			is_ruler = yes # Hide against unlanded non-ruler clergy; landless clerical title-holders remain valid
			NOR = {
				scope:actor.puppet:theological_agent_puppet ?= scope:recipient
				scope:actor.cp:councillor_court_chaplain ?= scope:recipient
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOR = {
				is_at_war_with = scope:recipient
				puppet:external_theological_agent_puppet ?= scope:recipient
			}
			custom_tooltip = {
				text = pam_already_have_external_clerical_puppet_tt
				NOT = {
					exists = puppet:external_theological_agent_puppet
				}
			}
			custom_tooltip = {
				text = actor_is_antipope_sponsor_tt
				pam_sponsors_other_antipope_trigger = no
			}
		}
		scope:recipient = {
			is_ai = yes
			NOR = {
				is_adult = no
				has_trait = incapable
			}
            custom_tooltip = {
                text = pam_recipient_already_puppet_tt
                NOT = { exists = puppeteer }
            }
		}
	}

	can_send = {
		scope:actor = {
			custom_tooltip = {
				text = external_theocratic_puppet_reqs_tt
				OR = {
					trigger_if = {
						limit = {
							scope:recipient = {
								highest_held_title_tier >= tier_kingdom
							}
						}
						has_strong_hook = scope:recipient
					}
					trigger_else = {
						has_hook = scope:recipient
					}
					AND = {
						is_liege_or_above_of = scope:recipient
						scope:recipient = {
							has_dread_level_towards = {
								target = scope:actor
								level >= 2
							}
						}
					}
					AND = {
						exists = scope:recipient.house
						scope:recipient.house.house_head = scope:actor
					}
					has_any_moderate_good_relationship_with_character_trigger = { CHARACTER = scope:recipient }
					scope:recipient = {
						is_imprisoned_by = scope:actor
					}
					any_subordinate = {
						this = scope:recipient
					}
					scope:recipient = {
						has_variable_list = puppeteers
						any_in_list = {
							variable = puppeteers
							this = scope:actor
						}
					}
				}
			}
		}
	}
	ai_targets = {
		ai_recipients = head_of_faith
		ai_recipients = head_of_rite
		ai_recipients = superior
		ai_recipients = top_superior
		ai_recipients = realm_priest_superior
		ai_recipients = realm_priest_top_superior
		ai_recipients = liege
		ai_recipients = top_liege
		ai_recipients = papabile
		ai_recipients = prisoners
	}
	ai_targets = {
		ai_recipients = clerical_region_rulers_in_realm
		ai_recipients = faith_holy_order_leaders
		ai_recipients = subordinates
		ai_recipients = vassals
		ai_recipients = hooked_characters
		ai_recipients = scripted_relations
		ai_recipients = dynasty
		max = 10
	}
	ai_targets = {
		ai_recipients = neighboring_rulers
		ai_recipients = peer_vassals
		max = 10
	}
    ai_target_quick_trigger = {
        adult = yes
    }
    ai_frequency_by_tier = {
        barony = 0
        county = 160
        duchy = 48
        kingdom = 24
        empire = 24
        hegemony = 24
    }
    ai_will_do = {
        base = 100

		modifier = {
			scope:recipient = {
				highest_held_title_tier <= tier_county
			}
			factor = 0.25
		}
		modifier = {
			scope:recipient = {
				highest_held_title_tier <= tier_county
			}
			scope:actor.highest_held_title_tier >= tier_duchy
			factor = 0
		}
    }

	cost = {
		piety = {
			value = {
				value = medium_piety_value
				multiply = {
					value = scope:recipient.highest_held_title_tier
					subtract = 1
				}
			}
		}
	}

	on_accept = {
		scope:actor = {
			trigger_event = pam_interactions_events.0120
			pam_generic_set_puppet_interaction_side_effects = yes
		}
		scope:recipient = {
			custom_tooltip = set_external_clerical_puppet_tt
		}
	}

	send_option = {
		is_valid = {
			scope:actor = { has_usable_hook = scope:recipient }
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	#My skills could be useful to you...?
	send_option = {
		is_valid = {
			scope:actor = {
				skill_support_trigger = yes
			}
		}
		flag = skill_support
		localization = SKILL_SUPPORT_INTERACTION_OPTION
	}
	#I will lead you into the light by my piety
	send_option = {
		is_valid = {
			scope:actor = {
				piety_support_trigger = yes
				custom_tooltip = {
					text = pious_puppet_sf_req_tt
					has_fulfillment_parameter = pious_puppet_option
				}
			}
		}
		flag = piety_support
		localization = PIETY_SUPPORT_INTERACTION_OPTION
	}
	#Become an instrument of my dreadful will, not a target of my will
	send_option = {
		is_valid = {
			scope:actor = {
				dread_support_trigger = yes
				custom_tooltip = {
					text = dread_puppet_sf_req_tt
					has_fulfillment_parameter = dread_puppet_option
				}
			}
		}
		flag = dread_support
		localization = DREAD_SUPPORT_INTERACTION_OPTION
	}
	#You can trust in me, relation
	send_option = {
		is_valid = {
			scope:actor = {
				friendly_support_trigger = yes
				custom_tooltip = {
					text = friendly_puppet_sf_req_tt
					has_fulfillment_parameter = positive_relation_puppet_option
				}
			}
		}
		flag = friendly_support
		localization = FRIENDLY_SUPPORT_INTERACTION_OPTION
	}
	#Your mind, your will, is no more
	send_option = {
		is_valid = {
			scope:actor = {
				lunacy_support_trigger = yes
			}
		}
		flag = lunacy_support
		localization = LUNACY_SUPPORT_INTERACTION_OPTION
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"
	send_options_exclusive = no

	ai_accept = {
		base = -75

		celestial_hierarchy_acceptance_modifier = {
			ACTOR = scope:actor
			RECIPIENT = scope:recipient
		}

		# Head of Faith will not be anyone's puppet
		modifier = {
			add = -30
			scope:recipient.faith.religious_head = scope:recipient
			desc = HEAD_OF_FAITH_REASON
		}

		# recipient is militarily weaker than the actor
		modifier = {
			add = 15
			scope:recipient = {
				is_landed = yes
			}
			scope:recipient.current_military_strength < scope:actor.current_military_strength
			desc = PUPPET_RECIPIENT_WEAKER_REASON
		}

		# recipient is far weaker (less than half) than the actor
		modifier = {
			add = 30
			scope:recipient = {
				is_landed = yes
			}
			scope:recipient.current_military_strength < scope:actor.half_current_military_strength
			desc = PUPPET_RECIPIENT_MUCH_WEAKER_REASON
		}

		# actor is militarily weaker than the recipient
		modifier = {
			add = -15
			scope:actor.current_military_strength < scope:recipient.current_military_strength
			desc = PUPPET_ACTOR_WEAKER_REASON
		}

		# actor is far weaker (less than half) than the recipient
		modifier = {
			add = -30
			scope:actor.current_military_strength < scope:recipient.half_current_military_strength
			desc = PUPPET_ACTOR_MUCH_WEAKER_REASON
		}
		modifier = {
			add = -75
			NOR = {
				scope:actor = {
					government_has_flag = government_is_theocracy
				}
				exists = scope:actor.puppet:theological_agent_puppet
			}
			desc = YOU_HAVE_NO_THEOLOGICAL_PUPPET
		}
		modifier = {
			add = 40
			scope:recipient.holy_order.holy_order_patron ?= scope:actor
			desc = YOU_ARE_PATRON
		}
		modifier = {
			scope:recipient.holy_order ?= {
				any_leased_title = {
					holder ?= {
						target_is_same_character_or_above = scope:actor
					}
				}
			}
			add = {
				value = 0
				scope:recipient.holy_order ?= {
					every_leased_title = {
						limit = {
							holder ?= scope:actor
						}
						add = 15
					}
				}
				scope:recipient.holy_order ?= {
					every_leased_title = {
						limit = {
							holder ?= {
								is_vassal_or_below_of = scope:actor
							}
						}
						add = 5
					}
				}
			}
			desc = YOU_ARE_LEASE_HOLDER
		}
		modifier = {
			add = 25
			scope:recipient = {
				has_variable_list = recent_leasers
				any_in_list = {
					variable = recent_leasers
					this = scope:actor	
				}
			}
			desc = RECENTLY_LEASED_TO_ORDER
		}
		modifier = {
			add = 25
			scope:recipient = {
				has_variable_list = recent_donators
				any_in_list = {
					variable = recent_donators
					this = scope:actor	
				}
			}
			desc = RECENTLY_DONATED_TO_ORDER
		}
		modifier = {
			desc = ORDER_SIZE_REASON
			scope:recipient.holy_order ?= {
				any_leased_title = {
					count >= 4
					NOT = {
						holder ?= {
							target_is_same_character_or_above = scope:actor
						}
					}
				}
			}
			add = {
				#So first 3 don't count
				value = 15
				scope:recipient.holy_order ?= {
					every_leased_title = {
						limit = {
							NOT = {
								holder ?= {
									target_is_same_character_or_above = scope:actor
								}
							}
						}
						add = -5
					}
				}
			}
		}

		theocratic_related_puppet_acceptance_factors_modifier = yes
	}
}

make_external_ruler_puppet_interaction = {
	category = interaction_category_diplomacy
	icon = external_ruler_puppet
	common_interaction = yes
	interface_priority = 50
	ai_instant_response = yes

	desc = make_external_ruler_puppet_interaction_desc

	is_available = {
		is_ai = no
		trigger_if = {
			limit = {
				is_ai = yes
			}
			NOT = {
				exists = puppet:external_ruler_puppet
			}
		}
		NOT = { has_trait = incapable }
		is_adult = yes
		has_pam_dlc_trigger = yes
	}

	cooldown_against_recipient = { years = 10 } 

	is_shown = {
		scope:actor != scope:recipient
		scope:recipient = {
			is_landed = yes
			is_ruler = yes
			NOR = {
				has_trait = incapable
				is_clergy = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			age >= 6
			is_ai = yes
			custom_tooltip = {
				text = pam_recipient_already_puppet_tt
				NOT = { exists = puppeteer }
			}
		}
		scope:actor = {
			NOR = {
				is_at_war_with = scope:recipient
				puppet:external_ruler_puppet ?= scope:recipient
			}
			custom_tooltip = {
				text = pam_already_have_external_ruler_puppet_tt
				NOT = {
					exists = puppet:external_ruler_puppet
				}
			}
			custom_tooltip = {
				text = actor_is_antipope_sponsor_tt
				pam_sponsors_other_antipope_trigger = no
			}
		}
	}

	can_send = {
		custom_tooltip = {
			text = make_external_ruler_puppet_tt
			OR = {
				scope:actor = {
					is_clergy = yes
					is_vassal_of = scope:recipient
				}
				AND = {
					scope:actor = {
						has_trait = seducer
					}
					trigger_if = {
						limit = {
							scope:recipient = {
								highest_held_title_tier >= tier_kingdom
							}
						}
						scope:recipient = {
							has_relation_soulmate = scope:actor
						}
					}
					trigger_else = {
						scope:recipient = {
							has_relation_lover = scope:actor
						}
					}
				}
				AND = {
					scope:actor = {
						has_trait = torturer
					}
					scope:recipient = {
						is_imprisoned_by = scope:actor
						is_in_prison_type = dungeon
					}
				}
				AND = {
					scope:actor = {
						has_trait = family_first
					}
					scope:recipient = {
						is_close_family_of = scope:actor
					}
				}
				scope:actor = {
					has_trait = schemer
					trigger_if = {
						limit = {
							scope:recipient = {
								highest_held_title_tier >= tier_kingdom
							}
						}
						has_strong_hook = scope:recipient
					}
					trigger_else = {
						has_hook = scope:recipient
					}
				}
				scope:actor = {
					has_trait = diplomat
					is_allied_to = scope:recipient
				}
				AND = {
					scope:actor = {
						has_trait = gallant
					}
					scope:recipient = {
						is_spouse_of = scope:actor
					}
				}
				AND = {
					scope:actor = {
						is_diarch_of_target = scope:recipient
					}
					scope:recipient = {
						has_diarchy_parameter = diarchy_type_is_entrenched_regency
					}
				}
				AND = {
					exists = scope:recipient.religious_head_or_challenger
					scope:recipient.religious_head_or_challenger = scope:actor
				}
				AND = {
					exists = scope:recipient.rite.head_of_rite
					scope:recipient.rite.head_of_rite = scope:actor
				}
			}
		}
		scope:actor = {
			trigger_if = {
				limit = {
					scope:recipient = {
						highest_held_title_tier >= tier_empire
					}
				}
				custom_tooltip = {
					text = pam_empire_dread_or_strong_hook_tt
					OR = {
						has_strong_hook = scope:recipient
						scope:recipient = {
							has_dread_level_towards = {
								target = scope:actor
								level >= 2
							}
						}
						scope:recipient.religious_head_or_challenger ?= scope:actor
					}
				}
			}
			trigger_else_if = {
				limit = {
					scope:recipient = {
						highest_held_title_tier >= tier_kingdom
					}
				}
				custom_tooltip = {
					text = piety_level_4_dread_or_strong_hook_tt
					OR = {
						piety_level >= 4
						has_strong_hook = scope:recipient
						scope:recipient = {
							has_dread_level_towards = {
								target = scope:actor
								level >= 2
							}
						}
						scope:recipient.religious_head_or_challenger ?= scope:actor
					}
				}
			}
			trigger_else = {
				custom_tooltip = {
					text = piety_level_3_dread_or_hook_tt
					OR = {
						piety_level >= 3
						has_hook = scope:recipient
						scope:recipient = {
							has_dread_level_towards = {
								target = scope:actor
								level >= 2
							}
						}
						scope:recipient.religious_head_or_challenger ?= scope:actor
					}
				}
			}
		}
	}

	ai_targets = {
		ai_recipients = neighboring_rulers
		max = 10
	}
	ai_targets = {
		ai_recipients = peer_vassals
		max = 10
	}
	ai_targets = {
		ai_recipients = rulers_in_clerical_region
		max = 10
	}
	ai_targets = {
		ai_recipients = family
		max = 5
	}
	ai_targets = {
		ai_recipients = liege
		ai_recipients = top_liege
		ai_recipients = spouses
		ai_recipients = prisoners
		ai_recipients = scripted_relations
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 160
		duchy = 36
		kingdom = 24
		empire = 24
		hegemony = 24
	}

	ai_will_do = {
		base = 100
		modifier = {
			scope:recipient = {
				highest_held_title_tier < scope:actor.highest_held_title_tier
			}
			factor = 0.25
		}
		modifier = {
			scope:recipient = {
				highest_held_title_tier < scope:actor.highest_held_title_tier_minus_one
			}
			factor = 0
		}
	}
	
	cost = {
		prestige = {
			value = {
				value = minor_prestige_value
				multiply = {
					value = scope:recipient.highest_held_title_tier
					subtract = 1
				}
			}
		}
	}

	on_accept = {
		scope:actor = {
			trigger_event = pam_interactions_events.0121
			pam_generic_set_puppet_interaction_side_effects = yes
		}
		scope:recipient = {
			custom_tooltip = set_external_ruler_puppet_tt
		}
	}

	send_option = {
		is_valid = {
			scope:actor = { has_usable_hook = scope:recipient }
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	#My skills could be useful to you...?
	send_option = {
		is_valid = {
			scope:actor = {
				skill_support_trigger = yes
			}
		}
		flag = skill_support
		localization = SKILL_SUPPORT_INTERACTION_OPTION
	}
	#I will lead you into the light by my piety
	send_option = {
		is_shown = {
			scope:actor = {
				pam_is_clergy_ruler_trigger = yes
			}
		}
		is_valid = {
			scope:actor = {
				piety_support_trigger = yes
			}
		}
		flag = piety_support
		localization = PIETY_SUPPORT_INTERACTION_OPTION
	}
	#Become an instrument of my dreadful will, not a target of my will
	send_option = {
		is_valid = {
			scope:actor = {
				trigger_if = {
					limit = { pam_is_clergy_ruler_trigger = yes }
					dread_support_trigger = yes
				}
				trigger_else = {
					dread_support_secular_trigger = yes
				}
			}
		}
		flag = dread_support
		localization = DREAD_SUPPORT_INTERACTION_OPTION
	}
	#You can trust in me, relation
	send_option = {
		is_valid = {
			scope:actor = {
				trigger_if = {
					limit = { pam_is_clergy_ruler_trigger = yes }
					friendly_support_trigger = yes
				}
				trigger_else = {
					friendly_support_secular_trigger = yes
				}
			}
		}
		flag = friendly_support
		localization = FRIENDLY_SUPPORT_INTERACTION_OPTION
	}
	#Your mind, your will, is no more
	send_option = {
		is_valid = {
			scope:actor = {
				lunacy_support_trigger = yes
			}
		}
		flag = lunacy_support
		localization = LUNACY_SUPPORT_INTERACTION_OPTION
	}
	should_use_extra_icon = {
		scope:actor = { has_usable_hook = scope:recipient }
	}
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"
	send_options_exclusive = no

	ai_accept = {
		base = -50

		celestial_hierarchy_acceptance_modifier = {
			ACTOR = scope:actor
			RECIPIENT = scope:recipient
		}
		celestial_hierarchy_external_ruler_puppet_acceptance_modifier = {
			ACTOR = scope:actor
			RECIPIENT = scope:recipient
		}

		# Rank gap: an actor outranked by the recipient has little leverage
		modifier = {
			scope:actor = {
				tier_difference = {
					target = scope:recipient
					value <= -1
				}
			}
			add = {
				value = -60
				if = {
					limit = {
						scope:actor = {
							tier_difference = {
								target = scope:recipient
								value = -2
							}
						}
					}
					add = -60
				}
				if = {
					limit = {
						scope:actor = {
							tier_difference = {
								target = scope:recipient
								value = -3
							}
						}
					}
					add = -120
				}
				if = {
					limit = {
						scope:actor = {
							tier_difference = {
								target = scope:recipient
								value <= -4
							}
						}
					}
					add = -180
				}
			}
			desc = RANK_DIFFERENCE_REASON
		}

		# Head of Faith will not be anyone's puppet
		modifier = {
			add = -30
			scope:recipient.faith.religious_head = scope:recipient
			desc = HEAD_OF_FAITH_REASON
		}

		# Different faith
		modifier = {
			add = {
				value = -50
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_hostile_level
							}
						}
					}
					add = -50
				}
				if = {
					limit = {
						scope:recipient.faith = {
							faith_hostility_level = {
								target = scope:actor.faith
								value >= faith_evil_level
							}
						}
					}
					add = -50
				}
			}
			scope:recipient = {
				NOT = { faith = scope:actor.faith }
			}
			desc = PUPPET_DIFFERENT_FAITH_REASON
		}

		# recipient is militarily weaker than the actor
		modifier = {
			add = 15
			scope:recipient = {
				is_landed = yes
			}
			scope:recipient.current_military_strength < scope:actor.current_military_strength
			desc = PUPPET_RECIPIENT_WEAKER_REASON
		}

		# recipient is far weaker (less than half) than the actor
		modifier = {
			add = 30
			scope:recipient = {
				is_landed = yes
			}
			scope:recipient.current_military_strength < scope:actor.half_current_military_strength
			desc = PUPPET_RECIPIENT_MUCH_WEAKER_REASON
		}

		# actor is militarily weaker than the recipient
		modifier = {
			add = -15
			scope:actor.current_military_strength < scope:recipient.current_military_strength
			desc = PUPPET_ACTOR_WEAKER_REASON
		}

		# actor is far weaker (less than half) than the recipient
		modifier = {
			add = -30
			scope:actor.current_military_strength < scope:recipient.half_current_military_strength
			desc = PUPPET_ACTOR_MUCH_WEAKER_REASON
		}

		modifier = {
			add = 50
			scope:actor = {
				is_clergy = yes
			}
			has_trait = zealous
			desc = ASK_FOR_CONVERSION_RECIPIENT_IS_ZEALOUS
		}
		
		theocratic_related_puppet_acceptance_factors_modifier = yes
	}
}


fire_puppet_interaction = {
	category = interaction_category_diplomacy
	icon = fire_puppet_interaction
	interface_priority = 51

	desc = fire_puppet_interaction_desc

	is_available = {
		is_ai = no
		is_adult = yes
	}

	is_shown = {
		scope:actor != scope:recipient
		scope:recipient.puppeteer ?= scope:actor
	}
	
	is_valid_showing_failures_only = {
		scope:actor = { is_incapable = no }
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_neutral
				title = fire_puppet_interaction_notification
				left_icon = scope:actor
				right_icon = scope:recipient
				custom_tooltip = fire_puppet_interaction_effect_tt
				hidden_effect = {
					scope:recipient = {
						clear_puppet_status = yes
						remove_puppet_modifiers_effect = yes
					}
				}
				scope:recipient = {
					add_opinion = {
						target = scope:actor
						modifier = set_me_aside_opinion
						opinion = -10
					}
				}
			}
		}
	}

	ai_targets = {
		ai_recipients = puppets
	}
	ai_frequency = 0
}
