﻿### 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
	notification_text = ASK_FOR_INFLUENCE_TEXT

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

	redirect = {
		scope:actor = {
			spiritual_hof_or_realm_priest_superior_recipient_redirect_effect = yes
		}
	}

	cooldown_against_recipient = { years = 10 }

	is_available = {
		government_has_mechanic = administrative
		trigger_if = {
			limit = {
				is_ai = yes
			}
			piety >= massive_piety_value
			exists = faith.religious_head
			exists = house
			NOT = { has_trait = excommunicated }
		}
		is_playable_character = yes
		faith ?= {
			OR = {
				has_doctrine = doctrine_spiritual_head
				has_doctrine_parameter = has_clerical_regions
			}
		}
		is_lowborn = no
	}

	is_shown = {
		scope:recipient != scope:puppet_or_actor
		scope:puppet_or_actor ?= {
			broader_clergy_show_hof_or_superior_interactions_trigger = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			spiritual_hof_or_realm_priest_superior_recipient_trigger = yes
			piety >= massive_piety_value
			custom_description = {
				text = hof_ask_for_gold_excommunicated
				NOT = { has_trait = excommunicated }
			}
			NOT = { is_at_war_with = scope:recipient }
			custom_tooltip = {
				text = HOF_INTERACTION_UNREFORMED_FAITH
				NOT = {
					faith = { has_doctrine_parameter = unreformed }
				}
			}
			custom_tooltip = {
				text = HOF_INTERACTION_STATE_FAITH
				top_liege = {
					government_allows = state_faith
					exists = primary_title.state_rite
				}
				rite = {
					this = scope:actor.top_liege.primary_title.state_rite
				}
			}
			custom_tooltip = {
				text = HOF_INTERACTION_HAS_HOUSE_MODIFIER
				house ?= {
					NOR = {
						has_house_modifier = ep3_requested_faith_support_modifier
						has_house_modifier = ep3_requested_faith_support_modifier_small
					}
				}
			}
			custom_tooltip = {
				text = HOF_INTERACTION_IS_HOUSE_HEAD
				house ?= {
					house_head = scope:actor
				}
			}
		}
		custom_tooltip = {
			text = recipient_supports_3_houses_tt
			NOT = {
				scope:recipient = {
					has_variable_list = cleric_houses_support
					variable_list_size = {
						name = cleric_houses_support
						value >= 3
					}
				}
			}
		}
	}

	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 = {
		show_as_tooltip = {
			scope:actor = { clerical_interaction_refusal_major_effect = yes }
		}
		scope:actor = {
			trigger_event = ep3_interactions_events.0621
		}
	}

	ai_accept = {
		base = -50

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

		modifier = {
			scope:recipient = {
				OR = {
					ai_greed > 0
					ai_greed < 0
				}
			}
			add = {
				value = scope:recipient.ai_greed
				multiply = 0.5
			}
			desc = AI_GREED_REASON
		}
		modifier = {
			scope:recipient = {
				OR = {
					ai_honor > 0
					ai_honor < 0
				}
			}
			add = {
				value = scope:recipient.ai_honor
				multiply = -0.5
			}
			desc = AI_HONOR_REASON
		}

		#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 = { # 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_rite_trigger = { RITE = rite TRAIT = trait:fornicator GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = adulterer
						trait_is_shunned_or_criminal_in_rite_trigger = { RITE = rite TRAIT = 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 = { rite = { rite_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_rite_trigger = { RITE = rite TRAIT = trait:kinslayer_1 GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = kinslayer_2
						trait_is_shunned_or_criminal_in_rite_trigger = { RITE = rite TRAIT = trait:kinslayer_2 GENDER_CHARACTER = scope:actor }
					}
					AND = {
						has_trait = kinslayer_3
						trait_is_shunned_or_criminal_in_rite_trigger = { RITE = rite TRAIT = 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_aspiration_parameter = increased_clerical_influence_acceptance_3 }
					}
					add = increased_clerical_influence_acceptance_3_value
				}
				else_if = {
					limit = {
						scope:actor.house ?= { has_house_aspiration_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_aspiration_parameter = increased_clerical_influence_acceptance_1
					has_house_aspiration_parameter = increased_clerical_influence_acceptance_2
					has_house_aspiration_parameter = increased_clerical_influence_acceptance_3
				}
			}
			desc = you_have_faithful_nobles_attribute_with_value_desc
		}
		secular_to_ecclesiastical_pam_factors_acceptance_modifier = yes

		modifier = {
			add = -30
			scope:recipient = {
				has_variable_list = cleric_houses_support
				variable_list_size = {
					name = cleric_houses_support
					value < 2
				}
			}
			desc = supports_other_house_reason
		}
		modifier = {
			add = -75
			scope:recipient = {
				has_variable_list = cleric_houses_support
				variable_list_size = {
					name = cleric_houses_support
					value >= 2
				}
			}
			desc = supports_other_houses_reason
		}
		modifier = {
			scope:actor.house ?= {
				is_powerful_family = yes
			}
			add = 25
			desc = YOUR_FAMILY_IS_POWERFUL
		}
		modifier = {
			scope:actor.house ?= {
				is_dominant_family = yes
			}
			add = 50
			desc = YOUR_FAMILY_IS_DOMINANT
		}
	}

	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
			}
		}
		modifier = {
			add = -25
			scope:recipient = {
				has_variable_list = cleric_houses_support
				variable_list_size = {
					name = cleric_houses_support
					value < 2
				}
			}
		}
		modifier = {
			add = -75
			scope:recipient = {
				has_variable_list = cleric_houses_support
				variable_list_size = {
					name = cleric_houses_support
					value >= 2
				}
			}
		}
	}
}