﻿# Pilgrims and Preachers - character interactions

# A Pilgrims adventurer asks a landed cleric or theocrat of the same faith for a
# letter of safe-conduct. Player-only: the AI never sends it, but an AI recipient
# answers through ai_accept and a player recipient gets a normal accept/decline.
ppr_request_safe_conduct_interaction = {
	category = interaction_category_laamp
	icon = letter_of_indulgence
	common_interaction = no
	interface_priority = 30

	desc = ppr_request_safe_conduct_interaction_desc

	greeting = positive
	notification_text = ppr_request_safe_conduct_interaction_notification
	answer_accept_key = ppr_request_safe_conduct_interaction_accept
	answer_reject_key = ppr_request_safe_conduct_interaction_reject

	ai_min_reply_days = 1
	ai_max_reply_days = 3

	cooldown = { years = 3 }

	is_available = {
		is_ai = no
		government_has_flag = government_is_landless_adventurer
		has_realm_law = ppr_camp_purpose_pilgrims
	}

	is_shown = {
		has_ep3_dlc_trigger = yes
		scope:recipient != scope:actor
		scope:actor = {
			has_realm_law = ppr_camp_purpose_pilgrims
		}
		scope:recipient = {
			is_landed = yes
			faith = scope:actor.faith
			OR = {
				is_clergy = yes
				government_has_flag = government_is_theocracy
			}
		}
	}

	is_valid_showing_failures_only = {
		# Has to be used instead of diplo range checks in laamp to landed interactions
		ep3_laamp_diplo_range_trigger = {
			TARGET = scope:recipient
			LAAMP = scope:actor
		}
		scope:actor = {
			NOT = { is_at_war_with = scope:recipient }
			custom_tooltip = {
				text = ppr_request_safe_conduct_has_letter_tt
				NOT = { has_character_modifier = ppr_safe_conduct_modifier }
			}
			custom_tooltip = {
				text = ppr_request_safe_conduct_excommunicated_tt
				NOT = { has_trait = excommunicated }
			}
		}
		scope:recipient = {
			is_imprisoned = no
		}
	}

	cost = {
		piety = minor_piety_value
	}

	on_accept = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_good
				title = ppr_request_safe_conduct_accepted_toast
				left_icon = scope:actor
				right_icon = scope:recipient
				add_character_modifier = {
					modifier = ppr_safe_conduct_modifier
					years = 3
				}
			}
		}
	}

	on_decline = {
		scope:actor = {
			send_interface_toast = {
				type = event_toast_effect_bad
				title = ppr_request_safe_conduct_declined_toast
				left_icon = scope:actor
				right_icon = scope:recipient
				# The offering is returned
				add_piety = minor_piety_value
			}
		}
	}

	ai_accept = {
		base = 10

		opinion_modifier = {
			who = scope:recipient
			opinion_target = scope:actor
			multiplier = 1
			desc = AI_OPINION_REASON
		}
		modifier = {
			add = 10
			desc = ppr_safe_conduct_reason_pilgrim
			scope:actor = { has_trait = pilgrim }
		}
		modifier = {
			add = 15
			desc = ppr_safe_conduct_reason_piety
			scope:actor.piety_level >= 3
		}
		modifier = {
			add = 10
			desc = ppr_safe_conduct_reason_zealous
			scope:recipient = { has_trait = zealous }
		}
		modifier = {
			add = -20
			desc = ppr_safe_conduct_reason_cynical
			scope:recipient = { has_trait = cynical }
		}
		modifier = {
			add = -100
			desc = ppr_safe_conduct_reason_rival
			scope:recipient = { has_relation_rival = scope:actor }
		}
	}

	# Never sent by the AI (is_available also excludes it)
	ai_targets = {
		ai_recipients = domicile_location_top_ruler
	}
	ai_frequency = 0

	ai_will_do = {
		base = 0
	}
}
