﻿#4962A048A9B1946FCB40FB55637FB5912D9498FE

seek_indulgences_interaction = {
	icon = religious
	category = interaction_category_religion

	desc = seek_indulgences_interaction_desc

	notification_text = RELIGIOUS_HEAD_SEEK_INDULGENCES

	is_shown = {
		scope:recipient != scope:actor
		scope:actor.faith = {
			religious_head = scope:recipient
			has_doctrine = tenet_communion
		}
	}

	cooldown = { years = 5 }

	is_valid_showing_failures_only = {
		scope:actor = {
			trigger_if = {
				limit = {
					has_trait = kinslayer_3
					trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = kinslayer_3 GENDER_CHARACTER = scope:actor }
				}
				gold >= seek_indulgences_major_criminal_trait_value
			}
			trigger_else_if = {
				limit = {
					OR = {
						AND = {
							has_trait = kinslayer_2
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = kinslayer_2 GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = witch
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = witch GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = deviant
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = deviant GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = sodomite
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = sodomite GENDER_CHARACTER = scope:actor }
						}
					}
				}
				gold >= seek_indulgences_medium_criminal_trait_value
			}
			trigger_else_if = {
				limit = {
					OR = {
						AND = {
							has_trait = kinslayer_1
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = kinslayer_1 GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = fornicator
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = fornicator GENDER_CHARACTER = scope:actor }
						}
						AND = {
							has_trait = adulterer
							trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = adulterer GENDER_CHARACTER = scope:actor }
						}
					}
				}
				gold >= seek_indulgences_minor_criminal_trait_value
			}
			trigger_else = {
				gold >= seek_indulgences_buy_piety_value
			}
			custom_description = {
				text = "seek_indulgences_excommunicated"
				NOT = { has_trait = excommunicated }
			}
		}
		scope:actor = {
			custom_description = {
				text = "hof_interaction_unreformed_faith"
				NOT = {
					faith = { has_doctrine_parameter = unreformed }
				}
			}
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
	}

	ai_accept = {
		base = 50

		opinion_modifier = {
			opinion_target = scope:actor
			who = scope:recipient
			multiplier = 1
		}

		modifier = { # Same language
			add = 5
			desc = speaks_same_language_interaction_reason
			trigger = {
				scope:actor = {
					knows_language_of_culture = scope:recipient.culture
				}
			}
		}

		evaluate_action_increasing_house_unity = {
			VALUE = 50
		}

		evaluate_action_decreasing_house_unity = {
			VALUE = -100
		}
	}
	auto_accept = yes
	
	ai_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		scope:recipient = {
			send_interface_message = {
				type = send_interface_message_good
				title = seek_indulgences_interaction
				right_icon = scope:actor
				seek_indulgences_interaction_effect = yes				
			}
		}
		scope:actor = {
			trigger_event = religious_interaction.1010
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = medium_unity_gain
			DESC = clan_unity_indulgences_accepted.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = religious_interaction.1011
		}

		# If we're a clan this interaction affects unity
		add_clan_unity_interaction_effect = {
			CHARACTER = scope:actor
			TARGET = scope:recipient
			VALUE = minor_unity_loss
			DESC = clan_unity_indulgences_declined.desc
			REVERSE_NON_HOUSE_TARGET = no
		}
	}

	# AI will do

	ai_potential = {
		short_term_gold >= head_of_faith_gold_value
		NOT = {
			has_trait = cynical
		}
	}

	ai_targets = {
		ai_recipients = head_of_faith
	}

	ai_frequency_by_tier = {
		barony = 0
		county = 36
		duchy = 36
		kingdom = 36
		empire = 36
		hegemony = 36
	}

	ai_will_do = {
		base = -25

		ai_value_modifier = { # +50 to -50
			who = scope:actor
			ai_zeal = 0.5
		}

		modifier = {
			add = 50
			scope:actor = {
				piety < 0
			}
		}

		modifier = {
			add = 75
			scope:actor = {
				piety_level < 0
			}
		}

		modifier = {
			add = 50
			scope:actor = {
				piety < major_piety_value
				short_term_gold >= head_of_faith_gold_value
				short_term_gold >= monumental_gold_value
			}
		}

		modifier = {
			add = -25
			scope:actor = {
				piety > major_piety_value
				piety_level > 0
			}
		}

		evaluate_action_increasing_house_unity = {
			VALUE = 50
		}
	}
}
