﻿# enact_a_bull_decision
# pick_crusade_target_decision
# pam_declare_rite_heresy_bull_decision
# pam_permit_tenet_bull_decision
# pam_prohibit_tenet_bull_decision

enact_a_bull_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}
	decision_group_type = major

	desc = enact_a_bull_decision_desc
	selection_tooltip = enact_a_bull_decision_tooltip
	confirm_text = enact_a_bull_decision_confirm
	
	sort_order = 500
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 0
		hegemony = 0
	}
	
	is_shown = {
		is_ai = no
		any_held_title = { is_head_of_faith = yes }
		religion = religion:catholic_religion
		is_adult = yes
		has_pam_dlc_trigger = yes
	}
	
	is_valid = {
		OR = {
			has_realm_law = church_authority_1
			has_realm_law = church_authority_2
			has_realm_law = church_authority_3
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		piety >= pam_enact_a_bull_cost_value
	}

	widget = {
		gui = "decision_view_widget_option_list_generic"
		controller = decision_option_list_controller
		decision_to_second_step_button = "CHOOSE_BULL_NEXT_STEP_BUTTON"
		show_from_start = yes

		item = {
			value = bull_option_crusade
			is_shown = { is_ai = no }
			is_valid = {
				custom_tooltip = {
					text = enact_a_bull_crusade_cooldown_tt
					NOT = { exists = var:enact_a_bull_crusade_cooldown }
				}
				custom_tooltip = {
					text = enact_a_bull_decision_ghw_active_trigger_tt
					faith = {
						OR = {
							has_doctrine_parameter = great_holy_wars_active
							AND = {
								has_doctrine_parameter = great_holy_wars_active_if_reformed
								NOT = { has_doctrine_parameter = unreformed }
							}
							has_doctrine = divine_destiny_doctrine #SPECIAL: Has become the Chakravarti
						}
						has_doctrine = doctrine_spiritual_head
						root.rite = {
							NOR = {
								AND = {
									rite_has_tenet = tenet_dharmic_pacifism
									faith = { NOT = { has_doctrine = divine_destiny_doctrine } }
								}
								rite_has_tenet = tenet_pacifism
							}
						}
					}
				}
				faith = {
					custom_tooltip = {
						text = enact_a_bull_decision_existing_ghw_trigger_tt
						NOT = { exists = great_holy_war } # No active GHW
					}
				}
				custom_description = {
					text = great_holy_war_cooldown
					NOT = { faith = { exists = var:variable_ghw_cooldown } }
				}
				custom_tooltip = { # Valid target
					text = enact_a_bull_decision_valid_target_trigger_tt
					faith = {
						save_temporary_scope_as = faith
						save_temporary_scope_value_as = { # Used in valid_ghw_target_trigger
							name = faith_strength
							value = faith_military_strength
						}
						any_kingdom = {
							valid_ghw_target_trigger = { FAITH = scope:faith }
						}
					}
				}
				custom_tooltip = {
					text = enact_a_bull_decision_crusade_trigger_tt
					OR = {
						has_realm_law = church_authority_1
						has_realm_law = church_authority_2
						has_realm_law = church_authority_3
#						situation:the_christian_church ?= {
#							situation_current_phase = crusade_phase
					}
				}
			}
			current_description = enact_a_bull_decision_option_crusade_desc
			localization = enact_a_bull_decision_option_crusade
			icon = "gfx/interface/icons/traits/crusader_king.dds"
		}
		item = {
			value = bull_option_rite_heresy
			is_shown = { always = yes }
			is_valid = {
				custom_tooltip = {
					text = enact_a_bull_rite_heresy_cooldown_tt
					NOT = { exists = var:enact_a_bull_rite_heresy_cooldown }
				}
				custom_tooltip = {
					text = enact_a_bull_decision_heresy_trigger_tt
					faith = {
						any_faith_rite = {
							pam_rite_can_be_declared_heresy_trigger = yes
						}
					}
				}
			}
			current_description = enact_a_bull_decision_option_rite_heresy_desc
			localization = enact_a_bull_decision_option_rite_heresy
			icon = "gfx/interface/icons/message_feed/heresy.dds"
		}
		item = {
			value = bull_option_tenet_stance_permitted
			is_shown = { always = yes }
			is_valid = {
				custom_tooltip = {
					text = enact_a_bull_tenet_permitted_cooldown_tt
					NOT = { exists = var:enact_a_bull_tenet_permitted_cooldown }
				}
				any_character_tenet = {
					knowledge_filter = known
					pam_tenet_can_be_permitted_no_actor_trigger = yes
				}
				custom_tooltip = {
					text = ecumenical_council_already_ongoing_tt
					NOT = { faith = { has_variable = ecumenical_council_ongoing } }
				}
			}
			current_description = enact_a_bull_decision_option_tenet_stance_permitted_desc
			localization = enact_a_bull_decision_option_tenet_stance_permitted
			icon = "gfx/interface/icons/character_interactions/religious.dds"
			ai_chance = { value = 30 }
		}
		item = {
			value = bull_option_tenet_stance_forbidden
			is_shown = { always = yes }
			is_valid = {
				custom_tooltip = {
					text = enact_a_bull_tenet_forbidden_cooldown_tt
					NOT = { exists = var:enact_a_bull_tenet_forbidden_cooldown }
				}
				any_character_tenet = {
					knowledge_filter = known
					pam_tenet_can_be_prohibited_no_actor_trigger = yes
				}
				custom_tooltip = {
					text = ecumenical_council_already_ongoing_tt
					NOT = { faith = { has_variable = ecumenical_council_ongoing } }
				}
			}
			current_description = enact_a_bull_decision_option_tenet_stance_forbidden_desc
			localization = enact_a_bull_decision_option_tenet_stance_forbidden
			icon = "gfx/interface/icons/character_interactions/excommunication.dds"
		}
	}

	effect = {
		save_scope_as = bull_issuer
		switch = {
			trigger = yes
			scope:bull_option_crusade = {
				set_variable = {
					name = bull_option
					value = flag:crusade
					years = 1
				}
				faith = {
					save_temporary_scope_as = faith
					save_temporary_scope_value_as = { # Used in valid_ghw_target_trigger
						name = faith_strength
						value = faith_military_strength
					}
				}
				custom_tooltip = bull_option_crusade_tt
				open_view_data = {
					view = decision_detail
					data = decision:pick_crusade_target_decision
					player = root
				}
			}
			scope:bull_option_rite_heresy = {
				custom_tooltip = bull_option_rite_heresy_tt
				open_view_data = {
					view = decision_detail
					data = decision:pam_declare_rite_heresy_bull_decision
					player = root
				}
			}
			scope:bull_option_tenet_stance_permitted = {
				custom_tooltip = bull_option_tenet_stance_permitted_tt
				open_view_data = {
					view = decision_detail
					data = decision:pam_permit_tenet_bull_decision
					player = root
				}
			}
			scope:bull_option_tenet_stance_forbidden = {
				custom_tooltip = bull_option_tenet_stance_forbidden_tt
				open_view_data = {
					view = decision_detail
					data = decision:pam_prohibit_tenet_bull_decision
					player = root
				}
			}
		}
	}

	ai_potential = {
		always = no
	}
}

pick_crusade_target_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_story/pam_the_christian_church_crusade.dds"
	}
	decision_group_type = major
	is_invisible = yes
	should_create_alert = { always = no }
	ai_check_interval = 0

	cooldown = { years = 5 }

	desc = pick_crusade_target_decision_desc
	selection_tooltip = pick_crusade_target_decision_tooltip
	confirm_text = pick_crusade_target_decision_confirm

	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_imprisoned = no
		custom_tooltip = {
			text = enact_a_bull_crusade_cooldown_tt
			NOT = { exists = var:enact_a_bull_crusade_cooldown }
		}
		custom_description = {
			text = great_holy_war_cooldown
			NOT = { faith = { exists = var:variable_ghw_cooldown } }
		}
	}

	widget = {
		controller = select_kingdom_title
		title_valid = {
			scope:ruler.faith = {
				save_temporary_scope_as = faith
				save_temporary_scope_value_as = {
					name = faith_strength
					value = faith_military_strength
				}
			}
			valid_ghw_target_trigger = { FAITH = scope:faith }
		}
	}

	cost = {
		piety = pam_enact_a_crusade_bull_cost_value
	}

	effect = {
		save_scope_as = bull_issuer
		if = {
			limit = { exists = scope:title }
			set_variable = {
				name = pam_bull_ghw_target_kingdom
				value = scope:title
			}
		}
		show_as_tooltip = {
			custom_tooltip = pick_crusade_target_decision_effect_tt
		}
		set_variable = {
			name = enact_a_bull_crusade_cooldown
			years = 5
		}
		trigger_event = pam_bull_events.0001
	}
}

pam_declare_rite_heresy_bull_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_story/pam_the_christian_church_instability.dds"
	}
	decision_group_type = major
	is_invisible = yes
	should_create_alert = { always = no }
	
	cooldown = { years = 5 }
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 200
		duchy = 200
		kingdom = 200
		empire = 200
		hegemony = 200
	}

	desc = pam_declare_rite_heresy_bull_decision_desc
	selection_tooltip = pam_declare_rite_heresy_bull_decision_tooltip
	confirm_text = pam_declare_rite_heresy_bull_decision_confirm

	is_valid = {
		faith = {
			any_faith_rite = {
				pam_rite_can_be_declared_heresy_trigger = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		custom_tooltip = {
			text = enact_a_bull_rite_heresy_cooldown_tt
			NOT = { exists = var:enact_a_bull_rite_heresy_cooldown }
		}
		custom_tooltip = {
			text = pam_rite_heresy_select_tt
			exists = scope:selected_item
		}
	}

	cost = {
		piety = pam_enact_a_bull_cost_value
	}

	effect = {
		set_variable = {
			name = bull_option
			value = flag:heresy
			years = 1
		}
		save_scope_as = bull_issuer
		scope:selected_item = { save_scope_as = heresy_rite }
		show_as_tooltip = {
			pam_declare_rite_heresy_effect = yes
		}
		set_variable = {
			name = enact_a_bull_rite_heresy_cooldown
			years = 5
		}
		trigger_event = pam_bull_events.0003
	}

	widget = {
		gui = "decision_view_widget_select_rite"
		controller = select_scope_object
		show_from_start = yes
		decision_to_second_step_button = "SELECT"

		setup_items = {
			scope:actor = {
				faith = {
					every_faith_rite = {
						limit = {
							pam_rite_can_be_declared_heresy_trigger = yes
						}
						add_to_list = item_list
					}
				}
			}
		}

		default_item = {
			scope:actor = {
				faith = {
					random_faith_rite = {
						limit = {
							pam_rite_can_be_declared_heresy_trigger = yes
						}
						save_scope_as = selected_item
					}
				}
			}
		}

		is_item_valid = {
			pam_rite_can_be_declared_heresy_trigger = yes
		}

		ai_select_item = {
			scope:actor = {
				faith = {
					ordered_faith_rite = {
						limit = {
							pam_rite_can_be_declared_heresy_trigger = yes
							trigger_if = {
								limit = { exists = head_of_rite }
								scope:actor = {
									dislikes_character_trigger = { CHARACTER = prev.head_of_rite }
								}
							}
						}
						order_by = "divergence(faith.main_rite)"
						save_scope_as = selected_item
					}
				}
			}
		}
	}

	ai_potential = {
		has_pam_dlc_trigger = yes
		this = faith.religious_head
		religion = religion:catholic_religion
		faith = {
			any_faith_rite = {
				pam_rite_can_be_declared_heresy_trigger = yes
			}
		}
	}

	ai_will_do = {
		base = 100
		modifier = {
			add = -25
			has_trait_submissive_trigger = yes
		}
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 20
			has_trait = theologian
		}
		modifier = {
			add = -30
			has_trait = cynical
		}
	}
}

pam_permit_tenet_bull_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_story/pam_the_christian_church_stability.dds"
	}
	decision_group_type = major
	is_invisible = yes
	should_create_alert = { always = no }
	
	cooldown = { years = 5 }
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 200
		duchy = 200
		kingdom = 200
		empire = 200
		hegemony = 200
	}

	desc = pam_permit_tenet_decision_desc
	selection_tooltip = pam_permit_tenet_decision_tooltip
	confirm_text = pam_permit_tenet_decision_confirm

	is_valid = {
		any_character_tenet = {
			knowledge_filter = known
			pam_tenet_can_be_permitted_no_actor_trigger = yes
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		custom_tooltip = {
			text = enact_a_bull_tenet_permitted_cooldown_tt
			NOT = { exists = var:enact_a_bull_tenet_permitted_cooldown }
		}
		custom_tooltip = {
			text = pam_tenet_stance_select_tt
			exists = scope:selected_item
		}
		custom_tooltip = {
			text = ecumenical_council_already_ongoing_tt
			NOT = { faith = { has_variable = ecumenical_council_ongoing } }
		}
	}

	cost = {
		piety = pam_enact_a_bull_cost_value
	}

	effect = {
		set_variable = {
			name = bull_option
			value = flag:tenet_permitted
			years = 1
		}
		save_scope_as = bull_issuer
		save_scope_as = pam_tenet_stance_issuer
		save_scope_as = pam_tenet_stance_permit
		scope:selected_item = { save_scope_as = pam_tenet_stance_tenet }
		show_as_tooltip = {
			faith = {
				set_tenet_status = {
					tenet = scope:selected_item
					status = permitted
				}
				change_fervor = {
					value = significant_fervor_loss
					desc = fervor_loss_pam_tenet_permitted
				}
				if = {
					limit = { has_tenet_popularity_trigger = yes }
					change_tenet_popularity = {
						target = scope:selected_item
						change = medium_tenet_popularity_gain
					}
				}
			}
		}
		set_variable = {
			name = enact_a_bull_tenet_permitted_cooldown
			years = 5
		}
		trigger_event = pam_bull_events.0002
	}

	widget = {
		gui = "decision_view_widget_select_tenet"
		controller = select_scope_object
		show_from_start = yes
		decision_to_second_step_button = "SELECT"

		# List is tenets the HoF personally knows + tenets the rite knows
		setup_items = {
			scope:actor = {
				ordered_character_tenet = {
					knowledge_filter = known
					order_by = {
						value = pam_raw_tenet_popularity_value
						multiply = -1
					}
					max = 200
					check_range_bounds = no
					add_to_list = item_list
				}
			}
		}

		default_item = {
			scope:actor = {
				random_character_tenet = {
					knowledge_filter = known
					limit = { pam_tenet_can_be_permitted_trigger = yes }
					save_scope_as = selected_item
				}
			}
		}

		is_item_valid = {
			pam_tenet_can_be_permitted_trigger = yes
		}

		ai_select_item = {
			scope:actor = {
				if = { # The Pope does not leave his own practice a crime, whatever the desired list says
					limit = {
						any_personal_tenet = {
							scope:actor.rite = {
								has_tenet_status = { tenet = prev status = prohibited }
							}
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
					}
					random_personal_tenet = {
						limit = {
							scope:actor.rite = {
								has_tenet_status = { tenet = prev status = prohibited }
							}
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
						save_scope_as = selected_item
					}
				}
				else_if = { # A tenet the faith adores gets sanctioned whether or not the Pope cares for it
					limit = {
						any_character_tenet = {
							knowledge_filter = known
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_is_overwhelmingly_popular_trigger = { CHARACTER = scope:actor }
						}
					}
					ordered_character_tenet = {
						knowledge_filter = known
						limit = {
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_is_overwhelmingly_popular_trigger = { CHARACTER = scope:actor }
						}
						order_by = pam_raw_tenet_popularity_value
						position = 0
						save_scope_as = selected_item
					}
				}
				else_if = {
					limit = {
						any_personal_tenet = {
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
					}
					random_personal_tenet = {
						limit = {
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
						weight = {
							base = 10
							modifier = {
								add = pam_tenet_popularity_impact_value
							}
							modifier = {
								factor = 0.25
								this = tenet:tenet_polyamory
							}
						}
						save_scope_as = selected_item
					}
				}
				else = {
					random_desired_tenet = {
						limit = {
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
						only_positive = yes
						threshold = 1
						selection_count = 97
						weight = {
							base = 10
							modifier = {
								add = pam_tenet_popularity_impact_value
							}
							modifier = {
								factor = 0.25
								this = tenet:tenet_polyamory
							}
						}
						save_scope_as = selected_item
					}
				}
			}
		}
	}

	ai_potential = {
		has_pam_dlc_trigger = yes
		this = faith.religious_head
		religion = religion:catholic_religion
		OR = {
			any_personal_tenet = {
				root.rite = {
					has_tenet_status = { tenet = prev status = prohibited }
				}
				pam_tenet_ai_may_permit_trigger = { CHARACTER = root }
			}
			any_desired_tenet = {
				only_positive = yes
				threshold = 1
				selection_count = 97
				root.rite = {
					NOR = {
						has_tenet_status = { tenet = prev status = permitted }
						has_tenet_status = { tenet = prev status = core }
					}
				}
				pam_tenet_ai_may_permit_trigger = { CHARACTER = root }
			}
			any_character_tenet = {
				knowledge_filter = known
				pam_tenet_can_be_permitted_no_actor_trigger = yes
				pam_tenet_is_overwhelmingly_popular_trigger = { CHARACTER = root }
			}
		}
	}

	ai_will_do = {
		base = 100
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 20
			has_trait = theologian
		}
		modifier = {
			add = -30
			has_trait = cynical
		}
	}
}

pam_prohibit_tenet_bull_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_story/pam_the_christian_church_instability.dds"
	}
	decision_group_type = major
	is_invisible = yes
	should_create_alert = { always = no }
	
	cooldown = { years = 5 }

	ai_check_interval_by_tier = {
		barony = 0
		county = 200
		duchy = 200
		kingdom = 200
		empire = 200
		hegemony = 200
	}

	desc = pam_prohibit_tenet_decision_desc
	selection_tooltip = pam_prohibit_tenet_decision_tooltip
	confirm_text = pam_prohibit_tenet_decision_confirm

	is_valid = {
		any_character_tenet = {
			knowledge_filter = known
			pam_tenet_can_be_prohibited_no_actor_trigger = yes
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		custom_tooltip = {
			text = enact_a_bull_tenet_forbidden_cooldown_tt
			NOT = { exists = var:enact_a_bull_tenet_forbidden_cooldown }
		}
		custom_tooltip = {
			text = pam_tenet_stance_select_tt
			exists = scope:selected_item
		}
		custom_tooltip = {
			text = ecumenical_council_already_ongoing_tt
			NOT = { faith = { has_variable = ecumenical_council_ongoing } }
		}
	}

	cost = {
		piety = pam_enact_a_bull_cost_value
	}

	effect = {
		set_variable = {
			name = bull_option
			value = flag:tenet_forbidden
			years = 1
		}
		save_scope_as = bull_issuer
		save_scope_as = pam_tenet_stance_issuer
		save_scope_as = pam_tenet_stance_prohibit
		scope:selected_item = { save_scope_as = pam_tenet_stance_tenet }
		show_as_tooltip = {
			faith = {
				set_tenet_status = {
					tenet = scope:selected_item
					status = prohibited
				}
				change_fervor = {
					value = notable_fervor_value
					desc = fervor_gain_pam_tenet_prohibited
				}
				if = {
					limit = { has_tenet_popularity_trigger = yes }
					change_tenet_popularity = {
						target = scope:selected_item
						change = major_tenet_popularity_loss
					}
				}
			}
		}
		set_variable = {
			name = enact_a_bull_tenet_forbidden_cooldown
			years = 5
		}
		trigger_event = pam_bull_events.0002
	}

	widget = {
		gui = "decision_view_widget_select_tenet"
		controller = select_scope_object
		show_from_start = yes
		decision_to_second_step_button = "SELECT"

		# List is tenets the HoF personally knows + tenets the rite knows
		setup_items = {
			scope:actor = {
				ordered_character_tenet = {
					knowledge_filter = known
					order_by = pam_raw_tenet_popularity_value
					max = 200
					check_range_bounds = no
					add_to_list = item_list
				}
			}
		}

		default_item = {
			scope:actor = {
				random_character_tenet = {
					knowledge_filter = known
					limit = { pam_tenet_can_be_prohibited_trigger = yes }
					save_scope_as = selected_item
				}
			}
		}

		is_item_valid = {
			pam_tenet_can_be_prohibited_trigger = yes
		}

		ai_select_item = {
			scope:actor = {
				if = { # Reform moves against the most entrenched vice whether or not the Pope minds it
					limit = {
						any_character_tenet = {
							knowledge_filter = known
							pam_tenet_can_be_prohibited_trigger = yes
							scope:actor = {
								NOT = { has_personal_tenet = scope:pam_tenet_candidate }
							}
							pam_tenet_ai_should_purge_trigger = { CHARACTER = scope:actor }
						}
					}
					ordered_character_tenet = {
						knowledge_filter = known
						limit = {
							pam_tenet_can_be_prohibited_trigger = yes
							scope:actor = {
								NOT = { has_personal_tenet = scope:pam_tenet_candidate }
							}
							pam_tenet_ai_should_purge_trigger = { CHARACTER = scope:actor }
						}
						order_by = pam_raw_tenet_popularity_value
						position = 0
						save_scope_as = selected_item
					}
				}
				else = {
					random_undesired_tenet = {
						limit = {
							pam_tenet_can_be_prohibited_trigger = yes
							scope:actor = {
								NOT = { has_personal_tenet = scope:pam_tenet_candidate }
							}
							pam_tenet_ai_may_prohibit_trigger = { CHARACTER = scope:actor }
						}
						known_tenets = yes
						only_negative = yes
						threshold = -1
						selection_count = 97
						weight = {
							base = 10
							modifier = {
								add = pam_tenet_unpopularity_impact_value
							}
						}
						save_scope_as = selected_item
					}
				}
			}
		}
	}

	ai_potential = {
		has_pam_dlc_trigger = yes
		is_ai = yes
		religion = religion:catholic_religion
		this = faith.religious_head
		OR = {
			any_character_tenet = {
				knowledge_filter = known
				pam_tenet_can_be_prohibited_no_actor_trigger = yes
				root = {
					NOT = { has_personal_tenet = scope:pam_tenet_candidate }
				}
				pam_tenet_ai_should_purge_trigger = { CHARACTER = root }
			}
			any_undesired_tenet = {
				known_tenets = yes
				only_negative = yes
				threshold = -1
				selection_count = 97
				root.rite = {
					NOR = {
						has_tenet_status = { tenet = prev status = prohibited }
						has_tenet_status = { tenet = prev status = core }
					}
				}
				pam_tenet_ai_may_prohibit_trigger = { CHARACTER = root }
			}
		}
	}

	ai_will_do = {
		base = 100
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 20
			has_trait = theologian
		}
		modifier = {
			add = -30
			has_trait = cynical
		}
	}
}

# Orthodox Encyclicals: parallel implementation of the working Papal Bull decision widgets.
# Orthodox requirements, option keys and outcome events differ; Papal Bulls above remain untouched.

neow_issue_encyclical_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/decision_major_religion.dds"
	}
	decision_group_type = major

	desc = neow_issue_encyclical_decision_desc
	selection_tooltip = neow_issue_encyclical_decision_tooltip
	confirm_text = neow_issue_encyclical_decision_confirm
	
	sort_order = 500
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 0
		duchy = 0
		kingdom = 0
		empire = 0
		hegemony = 0
	}
	
	is_shown = {
		is_ai = no
		any_held_title = { is_head_of_faith = yes }
		religion = religion:eastern_orthodox_religion
		is_adult = yes
		has_pam_dlc_trigger = yes
	}
	
	is_valid = {
		OR = {
			has_realm_law = church_authority_1
			has_realm_law = church_authority_2
			has_realm_law = church_authority_3
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		piety >= pam_enact_a_bull_cost_value
	}

	widget = {
		gui = "decision_view_widget_option_list_generic"
		controller = decision_option_list_controller
		decision_to_second_step_button = "CHOOSE_ENCYCLICAL_NEXT_STEP_BUTTON"
		show_from_start = yes

		item = {
			value = encyclical_option_crusade
			is_shown = { is_ai = no }
			is_valid = {
				custom_tooltip = {
					text = neow_encyclical_crusade_cooldown_tt
					NOT = { exists = var:neow_encyclical_crusade_cooldown }
				}
				custom_tooltip = {
					text = neow_issue_encyclical_decision_ghw_active_trigger_tt
					faith = {
						OR = {
							has_doctrine_parameter = great_holy_wars_active
							AND = {
								has_doctrine_parameter = great_holy_wars_active_if_reformed
								NOT = { has_doctrine_parameter = unreformed }
							}
							has_doctrine = divine_destiny_doctrine #SPECIAL: Has become the Chakravarti
						}
						has_doctrine = doctrine_spiritual_head
						root.rite = {
							NOR = {
								AND = {
									rite_has_tenet = tenet_dharmic_pacifism
									faith = { NOT = { has_doctrine = divine_destiny_doctrine } }
								}
								rite_has_tenet = tenet_pacifism
							}
						}
					}
				}
				faith = {
					custom_tooltip = {
						text = neow_issue_encyclical_decision_existing_ghw_trigger_tt
						NOT = { exists = great_holy_war } # No active GHW
					}
				}
				custom_description = {
					text = great_holy_war_cooldown
					NOT = { faith = { exists = var:variable_ghw_cooldown } }
				}
				custom_tooltip = { # Valid target
					text = neow_issue_encyclical_decision_valid_target_trigger_tt
					faith = {
						save_temporary_scope_as = faith
						save_temporary_scope_value_as = { # Used in valid_ghw_target_trigger
							name = faith_strength
							value = faith_military_strength
						}
						any_kingdom = {
							valid_ghw_target_trigger = { FAITH = scope:faith }
						}
					}
				}
				custom_tooltip = {
					text = neow_issue_encyclical_decision_crusade_trigger_tt
					this = faith.religious_head
					faith = { has_doctrine = doctrine_spiritual_head }
				}
				# Match the native Great Holy War event's unlocking conditions.
				custom_tooltip = {
					text = launch_undirected_great_holy_war_decision_age_of_crusades_tt
					religion = { exists = var:variable_ghw_unlocked }
				}
				custom_tooltip = {
					text = launch_undirected_great_holy_war_decision_ghw_doctrines_tt
					faith = { faith_has_undirected_ghw_doctrines_trigger = yes }
				}
			}
			current_description = neow_issue_encyclical_decision_option_crusade_desc
			localization = neow_issue_encyclical_decision_option_crusade
			icon = "gfx/interface/icons/traits/crusader_king.dds"
		}
		item = {
			value = encyclical_option_rite_heresy
			is_shown = { always = yes }
			is_valid = {
				custom_tooltip = {
					text = neow_encyclical_rite_heresy_cooldown_tt
					NOT = { exists = var:neow_encyclical_rite_heresy_cooldown }
				}
				custom_tooltip = {
					text = neow_issue_encyclical_decision_heresy_trigger_tt
					faith = {
						any_faith_rite = {
							pam_rite_can_be_declared_heresy_trigger = yes
						}
					}
				}
			}
			current_description = neow_issue_encyclical_decision_option_rite_heresy_desc
			localization = neow_issue_encyclical_decision_option_rite_heresy
			icon = "gfx/interface/icons/message_feed/heresy.dds"
		}
		item = {
			value = encyclical_option_tenet_stance_permitted
			is_shown = { always = yes }
			is_valid = {
				custom_tooltip = {
					text = neow_encyclical_tenet_permitted_cooldown_tt
					NOT = { exists = var:neow_encyclical_tenet_permitted_cooldown }
				}
				any_character_tenet = {
					knowledge_filter = known
					pam_tenet_can_be_permitted_no_actor_trigger = yes
				}
				custom_tooltip = {
					text = ecumenical_council_already_ongoing_tt
					NOT = { faith = { has_variable = ecumenical_council_ongoing } }
				}
			}
			current_description = neow_issue_encyclical_decision_option_tenet_stance_permitted_desc
			localization = neow_issue_encyclical_decision_option_tenet_stance_permitted
			icon = "gfx/interface/icons/character_interactions/religious.dds"
			ai_chance = { value = 30 }
		}
		item = {
			value = encyclical_option_tenet_stance_forbidden
			is_shown = { always = yes }
			is_valid = {
				custom_tooltip = {
					text = neow_encyclical_tenet_forbidden_cooldown_tt
					NOT = { exists = var:neow_encyclical_tenet_forbidden_cooldown }
				}
				any_character_tenet = {
					knowledge_filter = known
					pam_tenet_can_be_prohibited_no_actor_trigger = yes
				}
				custom_tooltip = {
					text = ecumenical_council_already_ongoing_tt
					NOT = { faith = { has_variable = ecumenical_council_ongoing } }
				}
			}
			current_description = neow_issue_encyclical_decision_option_tenet_stance_forbidden_desc
			localization = neow_issue_encyclical_decision_option_tenet_stance_forbidden
			icon = "gfx/interface/icons/character_interactions/excommunication.dds"
		}
	}

	effect = {
		save_scope_as = neow_encyclical_issuer
		switch = {
			trigger = yes
			scope:encyclical_option_crusade = {
				set_variable = {
					name = encyclical_option
					value = flag:crusade
					years = 1
				}
				faith = {
					save_temporary_scope_as = faith
					save_temporary_scope_value_as = { # Used in valid_ghw_target_trigger
						name = faith_strength
						value = faith_military_strength
					}
				}
				custom_tooltip = encyclical_option_crusade_tt
				open_view_data = {
					view = decision_detail
					data = decision:neow_pick_crusade_target_encyclical_decision
					player = root
				}
			}
			scope:encyclical_option_rite_heresy = {
				custom_tooltip = encyclical_option_rite_heresy_tt
				open_view_data = {
					view = decision_detail
					data = decision:neow_condemn_rite_encyclical_decision
					player = root
				}
			}
			scope:encyclical_option_tenet_stance_permitted = {
				custom_tooltip = encyclical_option_tenet_stance_permitted_tt
				open_view_data = {
					view = decision_detail
					data = decision:neow_permit_tenet_encyclical_decision
					player = root
				}
			}
			scope:encyclical_option_tenet_stance_forbidden = {
				custom_tooltip = encyclical_option_tenet_stance_forbidden_tt
				open_view_data = {
					view = decision_detail
					data = decision:neow_prohibit_tenet_encyclical_decision
					player = root
				}
			}
		}
	}

	ai_potential = {
		always = no
	}
}

neow_pick_crusade_target_encyclical_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_story/pam_the_christian_church_crusade.dds"
	}
	decision_group_type = major
	is_invisible = yes
	should_create_alert = { always = no }
	ai_check_interval = 0

	cooldown = { years = 5 }

	desc = neow_pick_crusade_target_encyclical_decision_desc
	selection_tooltip = neow_pick_crusade_target_encyclical_decision_tooltip
	confirm_text = neow_pick_crusade_target_encyclical_decision_confirm

	is_shown = {
		religion = religion:eastern_orthodox_religion
		this = faith.religious_head
		has_pam_dlc_trigger = yes
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_imprisoned = no
		custom_tooltip = {
			text = neow_encyclical_crusade_cooldown_tt
			NOT = { exists = var:neow_encyclical_crusade_cooldown }
		}
		custom_description = {
			text = great_holy_war_cooldown
			NOT = { faith = { exists = var:variable_ghw_cooldown } }
		}
		custom_tooltip = {
			text = launch_undirected_great_holy_war_decision_age_of_crusades_tt
			religion = { exists = var:variable_ghw_unlocked }
		}
		custom_tooltip = {
			text = launch_undirected_great_holy_war_decision_ghw_doctrines_tt
			faith = { faith_has_undirected_ghw_doctrines_trigger = yes }
		}
		faith = { NOT = { exists = great_holy_war } }
	}

	widget = {
		controller = select_kingdom_title
		title_valid = {
			scope:ruler.faith = {
				save_temporary_scope_as = faith
				save_temporary_scope_value_as = {
					name = faith_strength
					value = faith_military_strength
				}
			}
			valid_ghw_target_trigger = { FAITH = scope:faith }
		}
	}

	cost = {
		piety = pam_enact_a_crusade_bull_cost_value
	}

	effect = {
		# The selected kingdom and all scopes are saved before the event opens.
		save_scope_as = neow_encyclical_issuer
		set_variable = { name = encyclical_option value = flag:crusade years = 1 }
		if = {
			limit = { exists = scope:title }
			scope:title = { save_scope_as = neow_encyclical_target }
			set_variable = {
				name = pam_bull_ghw_target_kingdom
				value = scope:title
			}
		}
		show_as_tooltip = {
			custom_tooltip = neow_pick_crusade_target_encyclical_decision_effect_tt
		}
		set_variable = { name = neow_encyclical_crusade_cooldown years = 5 }
		# Same direct trigger semantics as the Papal Bull decision: no one-tick wait.
		trigger_event = pam_decision_events.0410
	}
}

neow_condemn_rite_encyclical_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_story/pam_the_christian_church_instability.dds"
	}
	decision_group_type = major
	is_invisible = yes
	should_create_alert = { always = no }
	
	cooldown = { years = 5 }
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 200
		duchy = 200
		kingdom = 200
		empire = 200
		hegemony = 200
	}

	desc = neow_condemn_rite_encyclical_decision_desc
	selection_tooltip = neow_condemn_rite_encyclical_decision_tooltip
	confirm_text = neow_condemn_rite_encyclical_decision_confirm

	is_valid = {
		faith = {
			any_faith_rite = {
				pam_rite_can_be_declared_heresy_trigger = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		custom_tooltip = {
			text = neow_encyclical_rite_heresy_cooldown_tt
			NOT = { exists = var:neow_encyclical_rite_heresy_cooldown }
		}
		custom_tooltip = {
			text = pam_rite_heresy_select_tt
			exists = scope:selected_item
		}
	}

	cost = {
		piety = pam_enact_a_bull_cost_value
	}

	effect = {
		set_variable = { name = encyclical_option value = flag:heresy years = 1 }
		save_scope_as = neow_encyclical_issuer
		save_scope_as = bull_issuer # Existing PAM heresy effect references this scope.
		scope:selected_item = { save_scope_as = heresy_rite }
		show_as_tooltip = { pam_declare_rite_heresy_effect = yes }
		set_variable = { name = neow_encyclical_rite_heresy_cooldown years = 5 }
		trigger_event = pam_decision_events.0411
	}

	widget = {
		gui = "decision_view_widget_select_rite"
		controller = select_scope_object
		show_from_start = yes
		decision_to_second_step_button = "SELECT"

		setup_items = {
			scope:actor = {
				faith = {
					every_faith_rite = {
						limit = {
							pam_rite_can_be_declared_heresy_trigger = yes
						}
						add_to_list = item_list
					}
				}
			}
		}

		default_item = {
			scope:actor = {
				faith = {
					random_faith_rite = {
						limit = {
							pam_rite_can_be_declared_heresy_trigger = yes
						}
						save_scope_as = selected_item
					}
				}
			}
		}

		is_item_valid = {
			pam_rite_can_be_declared_heresy_trigger = yes
		}

		ai_select_item = {
			scope:actor = {
				faith = {
					ordered_faith_rite = {
						limit = {
							pam_rite_can_be_declared_heresy_trigger = yes
							trigger_if = {
								limit = { exists = head_of_rite }
								scope:actor = {
									dislikes_character_trigger = { CHARACTER = prev.head_of_rite }
								}
							}
						}
						order_by = "divergence(faith.main_rite)"
						save_scope_as = selected_item
					}
				}
			}
		}
	}

	ai_potential = {
		has_pam_dlc_trigger = yes
		this = faith.religious_head
		religion = religion:eastern_orthodox_religion
		faith = {
			any_faith_rite = {
				pam_rite_can_be_declared_heresy_trigger = yes
			}
		}
	}

	ai_will_do = {
		base = 100
		modifier = {
			add = -25
			has_trait_submissive_trigger = yes
		}
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 20
			has_trait = theologian
		}
		modifier = {
			add = -30
			has_trait = cynical
		}
	}
}

neow_permit_tenet_encyclical_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_story/pam_the_christian_church_stability.dds"
	}
	decision_group_type = major
	is_invisible = yes
	should_create_alert = { always = no }
	
	cooldown = { years = 5 }
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 200
		duchy = 200
		kingdom = 200
		empire = 200
		hegemony = 200
	}

	desc = neow_permit_tenet_encyclical_decision_desc
	selection_tooltip = neow_permit_tenet_encyclical_decision_tooltip
	confirm_text = neow_permit_tenet_encyclical_decision_confirm

	is_valid = {
		any_character_tenet = {
			knowledge_filter = known
			pam_tenet_can_be_permitted_no_actor_trigger = yes
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		custom_tooltip = {
			text = neow_encyclical_tenet_permitted_cooldown_tt
			NOT = { exists = var:neow_encyclical_tenet_permitted_cooldown }
		}
		custom_tooltip = {
			text = pam_tenet_stance_select_tt
			exists = scope:selected_item
		}
		custom_tooltip = {
			text = ecumenical_council_already_ongoing_tt
			NOT = { faith = { has_variable = ecumenical_council_ongoing } }
		}
	}

	cost = {
		piety = pam_enact_a_bull_cost_value
	}

	effect = {
		set_variable = { name = encyclical_option value = flag:tenet_permitted years = 1 }
		save_scope_as = neow_encyclical_issuer
		save_scope_as = pam_tenet_stance_issuer
		save_scope_as = pam_tenet_stance_permit
		scope:selected_item = { save_scope_as = pam_tenet_stance_tenet }
		show_as_tooltip = {
			faith = {
				set_tenet_status = { tenet = scope:selected_item status = permitted }
				change_fervor = { value = significant_fervor_loss desc = fervor_loss_pam_tenet_permitted }
				if = {
					limit = { has_tenet_popularity_trigger = yes }
					change_tenet_popularity = { target = scope:selected_item change = medium_tenet_popularity_gain }
				}
			}
		}
		set_variable = { name = neow_encyclical_tenet_permitted_cooldown years = 5 }
		trigger_event = pam_decision_events.0412
	}

	widget = {
		gui = "decision_view_widget_select_tenet"
		controller = select_scope_object
		show_from_start = yes
		decision_to_second_step_button = "SELECT"

		# List is tenets the HoF personally knows + tenets the rite knows
		setup_items = {
			scope:actor = {
				ordered_character_tenet = {
					knowledge_filter = known
					order_by = {
						value = pam_raw_tenet_popularity_value
						multiply = -1
					}
					max = 200
					check_range_bounds = no
					add_to_list = item_list
				}
			}
		}

		default_item = {
			scope:actor = {
				random_character_tenet = {
					knowledge_filter = known
					limit = { pam_tenet_can_be_permitted_trigger = yes }
					save_scope_as = selected_item
				}
			}
		}

		is_item_valid = {
			pam_tenet_can_be_permitted_trigger = yes
		}

		ai_select_item = {
			scope:actor = {
				if = { # The Pope does not leave his own practice a crime, whatever the desired list says
					limit = {
						any_personal_tenet = {
							scope:actor.rite = {
								has_tenet_status = { tenet = prev status = prohibited }
							}
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
					}
					random_personal_tenet = {
						limit = {
							scope:actor.rite = {
								has_tenet_status = { tenet = prev status = prohibited }
							}
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
						save_scope_as = selected_item
					}
				}
				else_if = { # A tenet the faith adores gets sanctioned whether or not the Pope cares for it
					limit = {
						any_character_tenet = {
							knowledge_filter = known
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_is_overwhelmingly_popular_trigger = { CHARACTER = scope:actor }
						}
					}
					ordered_character_tenet = {
						knowledge_filter = known
						limit = {
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_is_overwhelmingly_popular_trigger = { CHARACTER = scope:actor }
						}
						order_by = pam_raw_tenet_popularity_value
						position = 0
						save_scope_as = selected_item
					}
				}
				else_if = {
					limit = {
						any_personal_tenet = {
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
					}
					random_personal_tenet = {
						limit = {
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
						weight = {
							base = 10
							modifier = {
								add = pam_tenet_popularity_impact_value
							}
							modifier = {
								factor = 0.25
								this = tenet:tenet_polyamory
							}
						}
						save_scope_as = selected_item
					}
				}
				else = {
					random_desired_tenet = {
						limit = {
							pam_tenet_can_be_permitted_trigger = yes
							pam_tenet_ai_may_permit_trigger = { CHARACTER = scope:actor }
						}
						only_positive = yes
						threshold = 1
						selection_count = 97
						weight = {
							base = 10
							modifier = {
								add = pam_tenet_popularity_impact_value
							}
							modifier = {
								factor = 0.25
								this = tenet:tenet_polyamory
							}
						}
						save_scope_as = selected_item
					}
				}
			}
		}
	}

	ai_potential = {
		has_pam_dlc_trigger = yes
		this = faith.religious_head
		religion = religion:eastern_orthodox_religion
		OR = {
			any_personal_tenet = {
				root.rite = {
					has_tenet_status = { tenet = prev status = prohibited }
				}
				pam_tenet_ai_may_permit_trigger = { CHARACTER = root }
			}
			any_desired_tenet = {
				only_positive = yes
				threshold = 1
				selection_count = 97
				root.rite = {
					NOR = {
						has_tenet_status = { tenet = prev status = permitted }
						has_tenet_status = { tenet = prev status = core }
					}
				}
				pam_tenet_ai_may_permit_trigger = { CHARACTER = root }
			}
			any_character_tenet = {
				knowledge_filter = known
				pam_tenet_can_be_permitted_no_actor_trigger = yes
				pam_tenet_is_overwhelmingly_popular_trigger = { CHARACTER = root }
			}
		}
	}

	ai_will_do = {
		base = 100
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 20
			has_trait = theologian
		}
		modifier = {
			add = -30
			has_trait = cynical
		}
	}
}

neow_prohibit_tenet_encyclical_decision = {
	picture = {
		reference = "gfx/interface/illustrations/event_story/pam_the_christian_church_instability.dds"
	}
	decision_group_type = major
	is_invisible = yes
	should_create_alert = { always = no }
	
	cooldown = { years = 5 }

	ai_check_interval_by_tier = {
		barony = 0
		county = 200
		duchy = 200
		kingdom = 200
		empire = 200
		hegemony = 200
	}

	desc = neow_prohibit_tenet_encyclical_decision_desc
	selection_tooltip = neow_prohibit_tenet_encyclical_decision_tooltip
	confirm_text = neow_prohibit_tenet_encyclical_decision_confirm

	is_valid = {
		any_character_tenet = {
			knowledge_filter = known
			pam_tenet_can_be_prohibited_no_actor_trigger = yes
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		custom_tooltip = {
			text = neow_encyclical_tenet_forbidden_cooldown_tt
			NOT = { exists = var:neow_encyclical_tenet_forbidden_cooldown }
		}
		custom_tooltip = {
			text = pam_tenet_stance_select_tt
			exists = scope:selected_item
		}
		custom_tooltip = {
			text = ecumenical_council_already_ongoing_tt
			NOT = { faith = { has_variable = ecumenical_council_ongoing } }
		}
	}

	cost = {
		piety = pam_enact_a_bull_cost_value
	}

	effect = {
		set_variable = { name = encyclical_option value = flag:tenet_forbidden years = 1 }
		save_scope_as = neow_encyclical_issuer
		save_scope_as = pam_tenet_stance_issuer
		save_scope_as = pam_tenet_stance_prohibit
		scope:selected_item = { save_scope_as = pam_tenet_stance_tenet }
		show_as_tooltip = {
			faith = {
				set_tenet_status = { tenet = scope:selected_item status = prohibited }
				change_fervor = { value = notable_fervor_value desc = fervor_gain_pam_tenet_prohibited }
				if = {
					limit = { has_tenet_popularity_trigger = yes }
					change_tenet_popularity = { target = scope:selected_item change = major_tenet_popularity_loss }
				}
			}
		}
		set_variable = { name = neow_encyclical_tenet_forbidden_cooldown years = 5 }
		trigger_event = pam_decision_events.0413
	}

	widget = {
		gui = "decision_view_widget_select_tenet"
		controller = select_scope_object
		show_from_start = yes
		decision_to_second_step_button = "SELECT"

		# List is tenets the HoF personally knows + tenets the rite knows
		setup_items = {
			scope:actor = {
				ordered_character_tenet = {
					knowledge_filter = known
					order_by = pam_raw_tenet_popularity_value
					max = 200
					check_range_bounds = no
					add_to_list = item_list
				}
			}
		}

		default_item = {
			scope:actor = {
				random_character_tenet = {
					knowledge_filter = known
					limit = { pam_tenet_can_be_prohibited_trigger = yes }
					save_scope_as = selected_item
				}
			}
		}

		is_item_valid = {
			pam_tenet_can_be_prohibited_trigger = yes
		}

		ai_select_item = {
			scope:actor = {
				if = { # Reform moves against the most entrenched vice whether or not the Pope minds it
					limit = {
						any_character_tenet = {
							knowledge_filter = known
							pam_tenet_can_be_prohibited_trigger = yes
							scope:actor = {
								NOT = { has_personal_tenet = scope:pam_tenet_candidate }
							}
							pam_tenet_ai_should_purge_trigger = { CHARACTER = scope:actor }
						}
					}
					ordered_character_tenet = {
						knowledge_filter = known
						limit = {
							pam_tenet_can_be_prohibited_trigger = yes
							scope:actor = {
								NOT = { has_personal_tenet = scope:pam_tenet_candidate }
							}
							pam_tenet_ai_should_purge_trigger = { CHARACTER = scope:actor }
						}
						order_by = pam_raw_tenet_popularity_value
						position = 0
						save_scope_as = selected_item
					}
				}
				else = {
					random_undesired_tenet = {
						limit = {
							pam_tenet_can_be_prohibited_trigger = yes
							scope:actor = {
								NOT = { has_personal_tenet = scope:pam_tenet_candidate }
							}
							pam_tenet_ai_may_prohibit_trigger = { CHARACTER = scope:actor }
						}
						known_tenets = yes
						only_negative = yes
						threshold = -1
						selection_count = 97
						weight = {
							base = 10
							modifier = {
								add = pam_tenet_unpopularity_impact_value
							}
						}
						save_scope_as = selected_item
					}
				}
			}
		}
	}

	ai_potential = {
		has_pam_dlc_trigger = yes
		is_ai = yes
		religion = religion:eastern_orthodox_religion
		this = faith.religious_head
		OR = {
			any_character_tenet = {
				knowledge_filter = known
				pam_tenet_can_be_prohibited_no_actor_trigger = yes
				root = {
					NOT = { has_personal_tenet = scope:pam_tenet_candidate }
				}
				pam_tenet_ai_should_purge_trigger = { CHARACTER = root }
			}
			any_undesired_tenet = {
				known_tenets = yes
				only_negative = yes
				threshold = -1
				selection_count = 97
				root.rite = {
					NOR = {
						has_tenet_status = { tenet = prev status = prohibited }
						has_tenet_status = { tenet = prev status = core }
					}
				}
				pam_tenet_ai_may_prohibit_trigger = { CHARACTER = root }
			}
		}
	}

	ai_will_do = {
		base = 100
		modifier = {
			add = 25
			has_trait = zealous
		}
		modifier = {
			add = 20
			has_trait = theologian
		}
		modifier = {
			add = -30
			has_trait = cynical
		}
	}
}
