### Interactions from vanilla that are modified by NEOW

# Request Clergy Support / request_clergy_support
ep3_hof_ask_for_influence_interaction = {
	icon = icon_influence_01
	category = interaction_category_religion

	desc = ep3_hof_ask_for_influence_interaction_desc

	ai_targets = {
		ai_recipients = head_of_faith
	}
	ai_target_quick_trigger = {
		adult = yes
	}
	ai_frequency_by_tier = {
		barony = 0
		county = 144
		duchy = 24
		kingdom = 24
		empire = 24
		hegemony = 24
	}

	cooldown_against_recipient = { years = 10 }

	is_shown = {
		scope:recipient != scope:actor
		scope:actor.faith = {
			religious_head = scope:recipient
			has_doctrine = doctrine_spiritual_head
		}
		scope:actor = {
			is_playable_character = yes
			government_allows = administrative
			is_lowborn = no
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			piety >= massive_piety_value
			custom_description = {
				text = "hof_ask_for_gold_excommunicated"
				NOT = { has_trait = excommunicated }
			}
			NOT = { is_at_war_with = scope:recipient }
			custom_description = {
				text = "hof_interaction_unreformed_faith"
				NOT = {
					faith = { has_doctrine_parameter = unreformed }
				}
			}
			custom_description = {
				text = "hof_interaction_has_house_modifier"
				house ?= {
					NOT = {
						has_house_modifier = ep3_requested_faith_support_modifier
					}
				}
			}
			custom_description = {
				text = "hof_interaction_is_house_head"
				house ?= {
					house_head = scope:actor
				}
			}
		}

	}

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
		}
	}

	send_option = {
		is_shown = {
			scope:actor != scope:recipient
		}
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
		}
		flag = hook
		localization = GENERIC_SPEND_A_HOOK
	}
	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_min_reply_days = 1
	ai_max_reply_days = 5

	on_accept = {
		ep3_hof_ask_for_influence_interaction_effect = yes

		scope:actor = {
			trigger_event = ep3_interactions_events.0620
		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = ep3_interactions_events.0621
		}
	}

	ai_potential = {
		is_playable_character = yes
		piety >= massive_piety_value
		NOT = { has_trait = excommunicated }
		exists = faith.religious_head
		exists = house
	}

	ai_accept = {
		base = -50

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

		#Doesn't like the emperor... if you're not the emperor
		modifier = {
			add = 5
			scope:actor.top_liege = {
				NOR = {
					this = scope:actor
					this = scope:recipient
				}
				reverse_opinion = {
					target = scope:recipient
					value < 0
				}
				reverse_opinion = {
					target = scope:recipient
					value > -40
				}
			}
			desc = HOF_OPINION_OF_EMPEROR
		}
		modifier = {
			add = 10
			scope:actor.top_liege = {
				NOR = {
					this = scope:actor
					this = scope:recipient
				}
				reverse_opinion = {
					target = scope:recipient
					value <= -40
				}
				reverse_opinion = {
					target = scope:recipient
					value > -80
				}
			}
			desc = HOF_OPINION_OF_EMPEROR
		}
		modifier = {
			add = 20
			scope:actor.top_liege = {
				NOR = {
					this = scope:actor
					this = scope:recipient
				}
				reverse_opinion = {
					target = scope:recipient
					value <= -80
				}
			}
			desc = HOF_OPINION_OF_EMPEROR
		}
		#Likes emperor... and you're not emperor
		modifier = {
			add = -5
			scope:actor.top_liege = {
				NOR = {
					this = scope:actor
					this = scope:recipient
				}
				reverse_opinion = {
					target = scope:recipient
					value >= 40
				}
				reverse_opinion = {
					target = scope:recipient
					value < 80
				}
			}
			desc = HOF_OPINION_OF_EMPEROR
		}
		modifier = {
			add = -10
			scope:actor.top_liege = {
				NOR = {
					this = scope:actor
					this = scope:recipient
				}
				reverse_opinion = {
					target = scope:recipient
					value >= 80
				}
			}
			desc = HOF_OPINION_OF_EMPEROR
		}

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

		modifier = { # Attacking a co-religionist
			add = -50
			desc = I_AM_ATTACKING_A_CORELIGIONIST
			scope:actor = {
				is_at_war = yes
				any_character_war = {
					primary_attacker = scope:actor
					primary_defender.faith = scope:actor.faith
					primary_defender = {
						NOT = {
							has_trait = excommunicated
						}
					}
				}
			}
		}

		modifier = { # Offensive holy war/excommunication war
			add = 30
			desc = I_AM_WAGING_AN_OFFENSIVE_HOLY_OR_EXCOMMUNICATION_WAR
			scope:actor = {
				is_at_war = yes
				any_character_war = {
					is_attacker = scope:actor
					OR = {
						using_non_ghw_holy_war_cb_trigger = yes
						using_cb = excommunication_war
					}
				}
			}
		}

		modifier = { # Defensive Holy War
			add = 50
			desc = I_AM_DEFENDING_AGAINST_A_HOLY_WAR
			scope:actor = {
				is_at_war = yes
				any_character_war = {
					is_defender = scope:actor
					using_non_ghw_holy_war_cb_trigger = yes
				}
			}
		}

		modifier = { # HoF wants the influence for themselves!
			add = -10
			desc = THEY_ARE_GREEDY
			scope:recipient = {
				ai_greed >= high_positive_greed
			}
		}

		modifier = { # I am influential already
			add = -10
			desc = I_AM_INFLUENTIAL
			scope:actor = {
				influence_level >= 4
				NOT = {
					influence_level >= 6
				}
			}
		}

		modifier = { # I am very influential already
			add = -20
			desc = I_AM_INFLUENTIAL
			scope:actor = {
				influence_level >= 6
			}
		}

		modifier = { # I am Adulterer/Fornicator
			add = -25
			desc = I_AM_ADULTERER
			scope:actor = {
				OR = {
					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 }
					}
				}
			}
		}

		modifier = { # I am a Murderer
			add = -50
			desc = I_AM_MURDERER
			scope:actor = {
				has_trait = murderer
			}
		}

		modifier = { # I am Incestous
			add = -50
			desc = I_AM_INCESTOUS
			scope:actor = {
				NOT = { scope:recipient = { faith = { has_doctrine = doctrine_consanguinity_unrestricted } } }
				has_trait = incestuous
			}
		}

		modifier = { # I am a Kinslayer
			add = -50
			desc = I_AM_A_KINSLAYER
			scope:actor = {
				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 = kinslayer_2
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = kinslayer_2 GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = kinslayer_3
						trait_is_shunned_or_criminal_in_faith_trigger = { FAITH = faith TRAIT = kinslayer_3 GENDER_CHARACTER = scope:actor }
					}
				}
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_SAVIOR
			add = 15
			scope:actor = {
				has_trait = savior
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_DIVINE_BLOOD
			add = 5
			scope:actor = {
				has_trait = divine_blood
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_PARAGON
			add = 15
			scope:actor = {
				has_trait = paragon
			}
		}
		modifier = {
			desc = RELIGIOUS_HEAD_INTERACTION_CONSECRATED_BLOOD
			add = 5
			scope:actor = {
				has_trait = consecrated_blood
			}
		}

		modifier = { # You are of the same dynasty as the Head of Faith
			add = 5
			desc = YOU_ARE_MY_DYNASTY_MEMBER
			scope:recipient = {
				is_lowborn = no
				dynasty = scope:actor.dynasty
				NOR = {
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
					is_child_of = scope:actor
					scope:recipient.dynasty = scope:secondary_recipient.dynasty
				}
			}
		}

		modifier = { # You are of the same house as the Head of Faith
			add = 10
			desc = YOU_ARE_MY_HOUSE_MEMBER
			scope:recipient = {
				is_lowborn = no
				house = scope:actor.house
				NOR = {
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
					is_child_of = scope:actor
					scope:recipient.house = scope:secondary_recipient.house
				}
			}
		}

		modifier = { # Related to the Head of Faith
			add = 10
			desc = YOU_ARE_MY_RELATIVE
			scope:recipient = {
				OR = {
					is_close_or_extended_family_of = scope:actor
					is_cousin_of = scope:actor
				}
				NOT = { is_child_of = scope:actor }
			}
		}

		modifier = { # Parent of the Head of Faith
			add = 25
			desc = YOU_ARE_MY_PARENT
			scope:recipient = {
				is_child_of = scope:actor
			}
		}

		modifier = { # Friend of the Head of Faith
			add = 25
			desc = WE_ARE_FRIENDS
			scope:recipient = {
				has_relation_friend = scope:actor
			}
		}

		modifier = { # Best Friend of the Head of Faith
			add = 50
			desc = WE_ARE_BEST_FRIENDS
			scope:recipient = {
				has_relation_best_friend = scope:actor
			}
		}

		modifier = { # Lover of the Head of Faith
			add = 10
			desc = WE_ARE_LOVERS
			scope:recipient = {
				has_relation_lover = scope:actor
			}
		}

		modifier = { # Rival of the Head of Faith
			add = -100
			desc = WE_ARE_RIVALS
			scope:recipient = {
				has_relation_rival = scope:actor
			}
		}

		modifier = { # Nemesis of the Head of Faith
			add = -500
			desc = WE_ARE_NEMESES
			scope:recipient = {
				has_relation_nemesis = scope:actor
			}
		}

		modifier = {
			add = {
				add = 10
				multiply = scope:actor.num_virtuous_traits
			}
			scope:actor.num_virtuous_traits > 0
			desc = I_AM_VIRTUOUS
		}

		modifier = {
			add = {
				add = 5
				multiply = scope:actor.piety_level
			}
			scope:actor.piety_level > 1
			desc = I_AM_PIOUS
		}

		modifier = {
			add = {
				add = -10
				multiply = scope:actor.num_sinful_traits
			}
			scope:actor.num_sinful_traits > 0
			desc = I_AM_SINFUL
		}
		
		# Admin family attribute bonus
		modifier = {
			add = {
				value = 0
				if = {
					limit = {
						scope:actor.house ?= { has_house_power_parameter = increased_clerical_influence_acceptance_3 }
					}
					add = increased_clerical_influence_acceptance_3_value
				}
				else_if = {
					limit = {
						scope:actor.house ?= { has_house_power_parameter = increased_clerical_influence_acceptance_2 }
					}
					add = increased_clerical_influence_acceptance_2_value
				}
				else = {
					add = increased_clerical_influence_acceptance_1_value
				}
			}
			scope:actor.house ?= {
				OR = {
					has_house_power_parameter = increased_clerical_influence_acceptance_1
					has_house_power_parameter = increased_clerical_influence_acceptance_2
					has_house_power_parameter = increased_clerical_influence_acceptance_3
				}
			}
			desc = you_have_faithful_nobles_attribute_with_value_desc
		}
	}

	ai_will_do = {
		base = 0

		modifier = { # The AI will only use a Hook if they couldn't otherwise do this
			scope:hook = yes
			add = -1
		}

		modifier = { # I am low on influence
			add = 300
			scope:actor = {
				influence <= minor_influence_value
			}
		}

		modifier = { # Piety to burn, and no reason to keep it.
			add = 100
			scope:actor = {
				piety > massive_piety_value
				NOR = {
					has_character_modifier = vow_of_poverty_modifier
					has_trait = content
					has_trait = humble
				}
			}
		}
		modifier = { # Or when greedy
			add = {
				value = scope:actor.ai_greed
				multiply = 0.5
			}
			scope:actor = {
				ai_greed > 0
			}
		}
		modifier = { # Or when energy
			add = {
				value = scope:actor.ai_energy
				multiply = 0.5
			}
			scope:actor = {
				ai_energy > 0
			}
		}

		modifier = { # I am an up and comer who really needs help
			add = 100
			scope:actor = {
				influence_level <= 1
			}
		}

		modifier = {
			add = 100
			scope:actor = {
				ai_has_warlike_personality = yes
			}
		}

		modifier = {
			add = 50
			scope:actor = {
				ai_has_cautious_personality = no
			}
		}
	}
}