targetted_decisions = {
	acr_cl_make_antipope = {
		only_playable = yes
		ai_check_interval = 3
		filter = vassals
		ai_target_filter = vassals
		
		from_potential = {
			has_global_flag = acr_pagan_antipopes
			has_law = investiture_law_1
			religion_scope = {
				persistent_event_target:religion_title = { has_title_flag = acr_uses_antipopes }
			}
			is_inaccessible_or_incapable_trigger = no
			independent = yes
			higher_real_tier_than = DUKE
			#NOR = {
			#	any_realm_lord = {
			#		is_theocracy = yes
			#		religion = FROM
			#		is_antipope = yes
			#	}
			#	any_realm_lord = {
			#		is_theocracy = yes
			#		religion = FROM
			#		controls_religion = yes
			#	}
			#}
			rightful_religious_head_scope = {
				NOR = {
					same_realm = FROM
					same_realm = ROOT
				}
			}
			trigger_if = {
				limit = { has_character_flag = acr_appointed_antipope }
				had_character_flag = {
					flag = acr_appointed_antipope
					years >= 30
				}
			}
		}

		potential = {
			religion = FROM
			is_inaccessible_or_incapable_trigger = no
			higher_real_tier_than = BARON
			is_theocracy = yes
		}

		allow = {
			FROM = { prestige >= 500 }
			religion_head = {
				show_scope_change = no
				ROOT = {
					show_scope_change = no
					likes_better_than = {
						who = FROM
						than = PREV
					}
				}
			}
			crownlaw_title = { has_law = investiture_law_1 }
			trigger_if = {
				limit = { religion_head = { primary_title = { has_title_flag = k_acr_git_gud_antipope } } }
				custom_tooltip = {
					text = k_acr_recent_antipope_tip
					religion_head = {
						primary_title = {
							had_title_flag = {
								flag = k_acr_git_gud_antipope
								years >= 50
							}
						}
					}
				}
			}
			trigger_if = {
				limit = {
					FROM = {
						ai = yes
						is_pious_trigger = yes
					}
				}
				is_impious_trigger = no
			}
			trigger_if = {
				limit = {
					FROM = {
						ai = yes
						is_benevolent_trigger = yes
					}
				}
				is_evil_trigger = no
			}
			trigger_if = {
				limit = {
					FROM = {
						ai = yes
						is_evil_trigger = yes
					}
				}
				is_benevolent_trigger = no
			}
			trigger_if = {
				limit = {
					FROM = {
						ai = yes
						NOT = { trait = cynical }
					}
				}
				piety >= 0
				has_bad_priest_trait_trigger = no
			}
		}

		effect = {
			FROM = {
				prestige = -500
				if = {
					limit = { has_character_flag = acr_appointed_antipope }
					clr_character_flag = acr_appointed_antipope
				}
				set_character_flag = acr_appointed_antipope
			}
			if = {
				limit = { religion = celtic_pagan_reformed }
				add_claim = d_celtic_pagan_reformed
			}
			else_if = {
				limit = { religion = hellenic_pagan_reformed }
				add_claim = k_hellenic_pagan_reformed
			}
			else_if = {
				limit = { religion = egyptian_pagan_reformed }
				add_claim = d_egyptian_pagan_reformed
			}
			else_if = {
				limit = { religion = baltic_pagan_reformed }
				add_claim = d_baltic_pagan_reformed
			}
			else_if = {
				limit = { religion = tengri_pagan_reformed }
				add_claim = d_tengri_pagan_reformed
			}
			else_if = {
				limit = { religion = finnish_pagan_reformed }
				add_claim = d_finnish_pagan_reformed
			}
			else_if = {
				limit = { religion = aztec_pagan_reformed }
				add_claim = d_aztec_pagan_reformed
			}
			else_if = {
				limit = { religion = slavic_pagan_reformed }
				add_claim = d_slavic_pagan_reformed
			}
			else_if = {
				limit = { religion = west_african_pagan_reformed }
				add_claim = d_west_african_pagan_reformed
			}
			else_if = {
				limit = { religion = zun_pagan_reformed }
				add_claim = d_zun_pagan_reformed
			}
			else_if = {
				limit = { religion = bon_pagan_reformed }
				add_claim = d_bon_pagan_reformed
			}
			else_if = {
				limit = { religion = norse_pagan_reformed }
				add_claim = d_norse_pagan_reformed
			}
			else_if = {
				limit = { religion = britannic_pagan }
				add_claim = k_britannic_pagan
			}
			else_if = {
				limit = { religion = promethean_pagan }
				add_claim = d_promethean_pagan
			}
			else_if = {
				limit = { religion = jewish }
				add_claim = d_jewish
			}
			else_if = {
				limit = { religion = zoroastrian }
				add_claim = d_zoroastrian
			}
			else_if = {
				limit = { religion = manichaean }
				add_claim = d_manichaean
			}
			if = {
				limit = { religion_head = { primary_title = { has_title_flag = k_acr_git_gud_antipope } } }
				hidden_effect = { religion_head = { primary_title = { clr_title_flag = k_acr_git_gud_antipope } } }
			}
		}

		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				religion_head = {
					OR = {
						dynasty = FROM
						is_friend = FROM
						is_lover = FROM
						is_close_relative = FROM
					}
					NOR = {
						is_foe = FROM
						is_former_lover = FROM
					}
				}
			}
			modifier = {
				factor = 2
				religion_head = {
					OR = {
						is_foe = FROM
						is_former_lover = FROM
					}
				}
			}
			modifier = {
				factor = 2
				FROM = { is_pious_trigger = yes }
				religion_head = { is_impious_trigger = yes }
			}
			modifier = {
				factor = 1.5
				FROM = { is_benevolent_trigger = yes }
				religion_head = { is_evil_trigger = yes }
			}
			modifier = {
				factor = 2
				FROM = { is_evil_trigger = yes }
				religion_head = { is_benevolent_trigger = yes }
			}
			modifier = {
				factor = 1.5
				FROM = { trait = ambitious }
			}
			modifier = {
				factor = 1.5
				FROM = { NOT = { trait = cynical } }
				religion_head = { piety <= 200 }
			}
			modifier = {
				factor = 1.25
				FROM = { NOT = { trait = cynical } }
				religion_head = { piety <= 100 }
			}
			modifier = {
				factor = 2
				FROM = { NOT = { trait = cynical } }
				religion_head = { piety <= 50 }
			}
			modifier = {
				factor = 10
				FROM = { NOT = { trait = cynical } }
				religion_head = { piety <= 0 }
			}
			modifier = {
				factor = 0
				trigger_if = {
					limit = { religion_head = { independent = yes } }
					religion_head = {
						FROM = {
							relative_power = {
								who = PREV
								power <= 0.25
							}
							NOR = {
								trait = lunatic
								trait = possessed
								is_dumb_trigger = yes
							}
						}
					}
				}
				trigger_else = {
					religion_head = {
						top_liege = {
							FROM = {
								relative_power = {
									who = PREV
									power <= 0.25
								}
								NOR = {
									trait = lunatic
									trait = possessed
									is_dumb_trigger = yes
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 0.33
				trigger_if = {
					limit = { religion_head = { independent = yes } }
					religion_head = {
						FROM = {
							relative_power = {
								who = PREV
								power <= 0.5
							}
							NOR = {
								trait = lunatic
								trait = possessed
								is_dumb_trigger = yes
							}
						}
					}
				}
				trigger_else = {
					religion_head = {
						top_liege = {
							FROM = {
								relative_power = {
									who = PREV
									power <= 0.5
								}
								NOR = {
									trait = lunatic
									trait = possessed
									is_dumb_trigger = yes
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 0.66
				trigger_if = {
					limit = { religion_head = { independent = yes } }
					religion_head = {
						FROM = {
							relative_power = {
								who = PREV
								power <= 0.75
							}
							NOR = {
								trait = lunatic
								trait = possessed
								is_dumb_trigger = yes
							}
						}
					}
				}
				trigger_else = {
					religion_head = {
						top_liege = {
							FROM = {
								relative_power = {
									who = PREV
									power <= 0.75
								}
								NOR = {
									trait = lunatic
									trait = possessed
									is_dumb_trigger = yes
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.33
				trigger_if = {
					limit = { religion_head = { independent = yes } }
					religion_head = {
						FROM = {
							relative_power = {
								who = PREV
								power >= 1.5
							}
							NOR = {
								trait = craven
								is_weak_trigger = yes
							}
						}
					}
				}
				trigger_else = {
					religion_head = {
						top_liege = {
							FROM = {
								relative_power = {
									who = PREV
									power >= 1.5
								}
								NOR = {
									trait = craven
									is_weak_trigger = yes
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.66
				trigger_if = {
					limit = { religion_head = { independent = yes } }
					religion_head = {
						FROM = {
							relative_power = {
								who = PREV
								power >= 2
							}
							NOR = {
								trait = craven
								is_weak_trigger = yes
							}
						}
					}
				}
				trigger_else = {
					religion_head = {
						top_liege = {
							FROM = {
								relative_power = {
									who = PREV
									power >= 2
								}
								NOR = {
									trait = craven
									is_weak_trigger = yes
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				religion_head = { has_bad_priest_trait_trigger = yes }
			}
			modifier = {
				factor = 0.8
				religion_head = {
					primary_title = {
						had_title_flag = {
							flag = k_acr_git_gud_antipope
							years <= 75
						}
					}
				}
			}
			modifier = {
				factor = 0.1 # Slow it down
			}
		}
	}
	
	acr_cl_invest_priest = {
		only_playable = yes
		ai_check_interval = 3
		filter = vassals
		ai_target_filter = vassals
		third_party_filter = realm
		ai_third_party_filter = sub_realm
		third_party = FROM
		
		from_potential = {
			OR = {
				has_global_flag = acr_pagan_papal
				has_global_flag = acr_pagan_antipopes
			}
			trigger_if = {
				limit = { cl_kinich_uses_autocephaly = yes }
				always = yes
			}
			trigger_else_if = {
				limit = { higher_real_tier_than = DUKE }
				has_law = investiture_law_1
			}
			trigger_else = {
				crownlaw_title = { has_law = investiture_law_1 }
			}
			trigger_if = {
				limit = { cl_kinich_uses_autocephaly = yes }
				always = yes
			}
			trigger_else = {
				religion_scope = {
					persistent_event_target:religion_title = { has_title_flag = acr_uses_investiture }
				}
			}
			#trigger_if = {
			#	limit = {
			#		has_dlc = "Holy Fury"
			#		religion_group = pagan_group
			#		OR = {
			#			has_religion_feature = religion_theocratic_head
			#			has_religion_feature = religion_autocephaly
			#		}
			#		NOR = {
			#			religion = britannic_pagan
			#			religion = promethean_pagan
			#		}
			#	}
			#	OR = {
			#		religion = celtic_pagan_reformed
			#		religion = hellenic_pagan_reformed
			#		religion = egyptian_pagan_reformed
			#		religion = baltic_pagan_reformed
			#		religion = tengri_pagan_reformed
			#		religion = finnish_pagan_reformed
			#		religion = aztec_pagan_reformed
			#		religion = slavic_pagan_reformed
			#		religion = west_african_pagan_reformed
			#		religion = zun_pagan_reformed
			#		religion = norse_pagan_reformed
			#		religion = bon_pagan_reformed
			#	}
			#}
			#trigger_else_if = {
			#	limit = {
			#		NOT = { has_dlc = "Holy Fury" }
			#		religion_group = pagan_group
			#		is_not_unreformed_pagan_trigger = yes
			#		NOR = {
			#			religion = britannic_pagan
			#			religion = promethean_pagan
			#		}
			#	}
			#	OR = {
			#		religion = celtic_pagan_reformed
			#		religion = hellenic_pagan_reformed
			#		religion = egyptian_pagan_reformed
			#		religion = baltic_pagan_reformed
			#		religion = tengri_pagan_reformed
			#		religion = finnish_pagan_reformed
			#		religion = aztec_pagan_reformed
			#		religion = slavic_pagan_reformed
			#		religion = west_african_pagan_reformed
			#		religion = zun_pagan_reformed
			#		religion = bon_pagan_reformed
			#	}
			#}
			#trigger_else_if = {
			#	limit = { cl_kinich_uses_autocephaly = yes }
			#	NOT = { religion_group = pagan_group }
			#}
			#trigger_else_if = {
			#	limit = { religion = zoroastrian }
			#	d_zoroastrian = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = manichaean }
			#	d_army_light = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = jewish }
			#	d_jewish = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = promethean_pagan }
			#	d_promethean_pagan = { has_holder = yes }
			#}
			#trigger_else = {
			#	religion = britannic_pagan
			#	k_britannic_pagan = { has_holder = yes }
			#}
			is_inaccessible_or_incapable_trigger = no
			higher_real_tier_than = BARON
		}
	
		potential = {
			religion = FROM
			vassal_of = FROM
			is_theocracy = yes
			trigger_if = {
				limit = { cl_kinich_uses_autocephaly = yes }
				always = yes
			}
			trigger_else = {
				controls_religion = no
			}
			trigger_if = {
				limit = {
					FROM = { ai = yes }
					has_character_flag = acr_invested_priest
				}
				had_character_flag = {
					flag = acr_invested_priest
					years >= 10
				}
			}
		}
		
		third_party_potential = {
			FROMFROM = {
				NOT = { has_character_flag = acr_invested_successor }
				is_adult = yes
				is_inaccessible_or_incapable_trigger = no
				trigger_if = {
					limit = { is_female = no }
					religion_allows_male_temple_holders = yes
				}
				trigger_else = {
					religion_allows_female_temple_holders = yes
				}
				trigger_if = {
					limit = {
						OR = {
							religion_group = christian
							religion_group = zoroastrian_group
							religion_openly_bon_or_reformed_trigger = yes
							religion = jain
							religion = buddhist
							religion = taoist
							persistent_event_target:religion_title = { has_title_flag = kcc_is_monastic_religion }
						}
					}
					is_betrothed = no
					is_married = no
				}
				trigger_if = {
					limit = {
						cl_kinich_uses_autocephaly = yes
						#ROOT = { controls_religion = yes }
						ROOT = { rightful_religious_head = ROOT }
					}
					is_landed = yes
					is_theocracy = yes
					controls_religion = no
				}
				trigger_else_if = {
					limit = { cl_kinich_uses_autocephaly = yes }
					is_ruler = no
					controls_religion = no
				}
				trigger_else = {
					is_ruler = no
				}
				religion = ROOT
			}
		}
		
		allow = {
			ROOT = {
				show_scope_change = no
				trigger_if = {
					limit = { cl_kinich_uses_autocephaly = yes }
					trigger_if = {
						limit = {
							#controls_religion = yes
							rightful_religious_head = ROOT
							tier = KING
						}
						FROM = { show_scope_change = no piety = 200 }
					}
					trigger_else_if = {
						limit = {
							#controls_religion = yes
							rightful_religious_head = ROOT
							tier = DUKE
						}
						FROM = { show_scope_change = no piety = 150 }
					}
					trigger_else_if = {
						limit = {
							OR = {
								tier = KING
								AND = {
									#controls_religion = yes
									rightful_religious_head = ROOT
									tier = COUNT
								}
							}
						}
						FROM = { show_scope_change = no piety = 100 }
					}
					trigger_else_if = {
						limit = { tier = DUKE }
						FROM = { show_scope_change = no piety = 150 }
					}
					trigger_else_if = {
						limit = { tier = COUNT }
						FROM = { show_scope_change = no piety = 50 }
					}
					trigger_else = {
						FROM = { show_scope_change = no piety = 25 }
					}
				}
				trigger_else = {
					crownlaw_title = { has_law = investiture_law_1 }
				}
			}
		}
		
		third_party_allow = {
			FROMFROM = {
				show_scope_change = no
				is_heir = no
			}
		}
		
		third_party_score = {
			factor = 100

			acr_pagan_investiture_score = yes
		}
		
		effect = {
			hidden_effect = {
				ROOT = {
					if = {
						limit = { has_character_flag = acr_invested_priest }
						clr_character_flag = acr_invested_priest
					}
					set_character_flag = acr_invested_priest
					if = {
						limit = {
							persistent_event_target:pagan_papal_priest_successor = { is_alive = yes }
						}
						persistent_event_target:pagan_papal_priest_successor = {
							clr_character_flag = acr_invested_successor
							clear_persistent_event_target = pagan_papal_invested_priest
						}
						clear_persistent_event_target = pagan_papal_priest_successor
					}
					save_persistent_event_target = {
						name = pagan_papal_priest_successor
						scope = FROMFROM
					}
				}
				FROMFROM = {
					save_persistent_event_target = {
						name = pagan_papal_invested_priest
						scope = ROOT_FROM
					}
					set_character_flag = acr_invested_successor
				}
			}
			if = {
				limit = { cl_kinich_uses_autocephaly = yes }
				ROOT = {
					show_scope_change = no
					if = {
						limit = {
							#controls_religion = yes
							rightful_religious_head = ROOT
						}
						trigger_switch = {
							on_trigger = tier

							BARON	= { FROM = { show_scope_change = no piety = -50 } }
							COUNT	= { FROM = { show_scope_change = no piety = -100 } }
							DUKE	= { FROM = { show_scope_change = no piety = -150 } }
							KING	= { FROM = { show_scope_change = no piety = -200 } }
						}
						opinion = {
							modifier = opinion_angry
							who = FROM
							years = 10
						}
					}
					else = {
						trigger_switch = {
							on_trigger = tier

							BARON	= { FROM = { show_scope_change = no piety = -25 } }
							COUNT	= { FROM = { show_scope_change = no piety = -50 } }
							DUKE	= { FROM = { show_scope_change = no piety = -75 } }
							KING	= { FROM = { show_scope_change = no piety = -100 } }
						}
						rightful_religious_head_scope = {
							show_scope_change = no
							opinion = {
								modifier = opinion_upset
								who = FROM
								years = 10
							}
						}
					}
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	acr_cl_check_invested_priest = {
		only_playable = yes
		ai_check_interval = 3
		filter = vassals
		ai_target_filter = vassals
		third_party_filter = realm
		ai_third_party_filter = realm
		
		from_potential = {
			OR = {
				has_global_flag = acr_pagan_papal
				has_global_flag = acr_pagan_antipopes
			}
			trigger_if = {
				limit = { cl_kinich_uses_autocephaly = yes }
				always = yes
			}
			trigger_else_if = {
				limit = { higher_real_tier_than = DUKE }
				has_law = investiture_law_1
			}
			trigger_else = {
				crownlaw_title = { has_law = investiture_law_1 }
			}
			trigger_if = {
				limit = { cl_kinich_uses_autocephaly = yes }
				always = yes
			}
			trigger_else = {
				religion_scope = {
					persistent_event_target:religion_title = { has_title_flag = acr_uses_investiture }
				}
			}
			#trigger_if = {
			#	limit = {
			#		has_dlc = "Holy Fury"
			#		religion_group = pagan_group
			#		has_religion_feature = religion_theocratic_head
			#		NOR = {
			#			religion = britannic_pagan
			#			religion = promethean_pagan
			#		}
			#	}
			#	OR = {
			#		religion = celtic_pagan_reformed
			#		religion = hellenic_pagan_reformed
			#		religion = egyptian_pagan_reformed
			#		religion = baltic_pagan_reformed
			#		religion = tengri_pagan_reformed
			#		religion = finnish_pagan_reformed
			#		religion = aztec_pagan_reformed
			#		religion = slavic_pagan_reformed
			#		religion = west_african_pagan_reformed
			#		religion = zun_pagan_reformed
			#		religion = norse_pagan_reformed
			#		religion = bon_pagan_reformed
			#	}
			#}
			#trigger_else_if = {
			#	limit = {
			#		NOT = { has_dlc = "Holy Fury" }
			#		religion_group = pagan_group
			#		is_not_unreformed_pagan_trigger = yes
			#		NOR = {
			#			religion = britannic_pagan
			#			religion = promethean_pagan
			#		}
			#	}
			#	OR = {
			#		religion = celtic_pagan_reformed
			#		religion = hellenic_pagan_reformed
			#		religion = egyptian_pagan_reformed
			#		religion = baltic_pagan_reformed
			#		religion = tengri_pagan_reformed
			#		religion = finnish_pagan_reformed
			#		religion = aztec_pagan_reformed
			#		religion = slavic_pagan_reformed
			#		religion = west_african_pagan_reformed
			#		religion = zun_pagan_reformed
			#		religion = bon_pagan_reformed
			#	}
			#}
			#trigger_else_if = {
			#	limit = { cl_kinich_uses_autocephaly = yes }
			#	NOT = { religion_group = pagan_group }
			#}
			#trigger_else_if = {
			#	limit = { religion = zoroastrian }
			#	d_zoroastrian = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = manichaean }
			#	d_army_light = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = jewish }
			#	d_jewish = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = promethean_pagan }
			#	d_promethean_pagan = { has_holder = yes }
			#}
			#trigger_else = {
			#	religion = britannic_pagan
			#	k_britannic_pagan = { has_holder = yes }
			#}
			is_inaccessible_or_incapable_trigger = no
			higher_real_tier_than = BARON
		}
	
		potential = {
			religion = FROM
			vassal_of = FROM
			is_theocracy = yes
			has_character_flag = acr_invested_priest
			persistent_event_target:pagan_papal_priest_successor = {
				is_alive = yes
			}
		}
		
		third_party_potential = {
			FROMFROM = {
				has_character_flag = acr_invested_successor
				persistent_event_target:pagan_papal_invested_priest = {
					character = ROOT
				}
			}
		}
		
		allow = {
			ROOT = {
				show_scope_change = no
				trigger_if = {
					limit = { cl_kinich_uses_autocephaly = yes }
					always = yes
				}
				trigger_else = {
					crownlaw_title = { has_law = investiture_law_1 }
				}
				hidden_trigger = {
					persistent_event_target:pagan_papal_priest_successor = {
						is_alive = yes
					}
				}
			}
		}
		
		third_party_allow = {
			FROMFROM = {
				show_scope_change = no
				always = yes
			}
		}
		
		effect = {
			hidden_effect = {
				ROOT = {
					clr_character_flag = acr_invested_priest
					clear_persistent_event_target = pagan_papal_priest_successor
				}
				FROMFROM = {
					clr_character_flag = acr_invested_successor
					clear_persistent_event_target = pagan_papal_invested_priest
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	acr_cl_nominate_priest = {
		only_playable = yes
		ai_check_interval = 3
		filter = religious_head
		third_party_filter = realm
		ai_third_party_filter = sub_realm
		third_party = FROM
		
		from_potential = {
			cl_kinich_uses_autocephaly = no
			OR = {
				has_global_flag = acr_pagan_papal
				has_global_flag = acr_pagan_antipopes
			}
			trigger_if = {
				limit = { higher_real_tier_than = DUKE }
				has_law = investiture_law_0
			}
			trigger_else = {
				crownlaw_title = { has_law = investiture_law_0 }
			}
			religion_scope = {
				persistent_event_target:religion_title = { has_title_flag = acr_uses_investiture }
			}
			#trigger_if = {
			#	limit = {
			#		has_dlc = "Holy Fury"
			#		religion_group = pagan_group
			#		OR = {
			#			has_religion_feature = religion_theocratic_head
			#			has_religion_feature = religion_autocephaly
			#		}
			#		NOR = {
			#			religion = britannic_pagan
			#			religion = promethean_pagan
			#		}
			#	}
			#	OR = {
			#		religion = celtic_pagan_reformed
			#		religion = hellenic_pagan_reformed
			#		religion = egyptian_pagan_reformed
			#		religion = baltic_pagan_reformed
			#		religion = tengri_pagan_reformed
			#		religion = finnish_pagan_reformed
			#		religion = aztec_pagan_reformed
			#		religion = slavic_pagan_reformed
			#		religion = west_african_pagan_reformed
			#		religion = zun_pagan_reformed
			#		religion = norse_pagan_reformed
			#		religion = bon_pagan_reformed
			#	}
			#}
			#trigger_else_if = {
			#	limit = {
			#		NOT = { has_dlc = "Holy Fury" }
			#		religion_group = pagan_group
			#		is_not_unreformed_pagan_trigger = yes
			#		NOR = {
			#			religion = britannic_pagan
			#			religion = promethean_pagan
			#		}
			#	}
			#	OR = {
			#		religion = celtic_pagan_reformed
			#		religion = hellenic_pagan_reformed
			#		religion = egyptian_pagan_reformed
			#		religion = baltic_pagan_reformed
			#		religion = tengri_pagan_reformed
			#		religion = finnish_pagan_reformed
			#		religion = aztec_pagan_reformed
			#		religion = slavic_pagan_reformed
			#		religion = west_african_pagan_reformed
			#		religion = zun_pagan_reformed
			#		religion = bon_pagan_reformed
			#	}
			#}
			#trigger_else_if = {
			#	limit = { religion = zoroastrian }
			#	d_zoroastrian = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = manichaean }
			#	d_army_light = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = jewish }
			#	d_jewish = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = promethean_pagan }
			#	d_promethean_pagan = { has_holder = yes }
			#}
			#trigger_else = {
			#	religion = britannic_pagan
			#	k_britannic_pagan = { has_holder = yes }
			#}
			is_inaccessible_or_incapable_trigger = no
			higher_real_tier_than = BARON
			trigger_if = {
				limit = {
					ai = yes
					has_character_flag = acr_nominated_priest
				}
				had_character_flag = {
					flag = acr_nominated_priest
					years >= 3
				}
			}
			NOT = { has_character_flag = acr_is_nominating_priest }
		}
	
		potential = {
			religion = FROM
			is_theocracy = yes
			controls_religion = yes
		}
		
		third_party_potential = {
			FROMFROM = {
				NOR = {
					has_character_flag = acr_invested_successor
					has_character_flag = acr_nominated_successor
				}
				is_adult = yes
				is_inaccessible_or_incapable_trigger = no
				trigger_if = {
					limit = { is_female = no }
					religion_allows_male_temple_holders = yes
				}
				trigger_else = {
					religion_allows_female_temple_holders = yes
				}
				trigger_if = {
					limit = {
						OR = {
							religion_group = christian
							religion_group = zoroastrian_group
							religion_openly_bon_or_reformed_trigger = yes
							religion = jain
							religion = buddhist
							religion = taoist
							persistent_event_target:religion_title = { has_title_flag = kcc_is_monastic_religion }
						}
					}
					is_betrothed = no
					is_married = no
				}
				is_ruler = no
				religion = ROOT
			}
		}
		
		allow = {
			FROM = {
				show_scope_change = no
				wealth = 50
				piety = 30
			}
		}
		
		third_party_allow = {
			FROMFROM = {
				show_scope_change = no
				is_heir = no
				trigger_if = {
					limit = { has_character_flag = acr_rejected_nominee }
					custom_tooltip = {
						text = acr_is_not_rejected_nominee
						had_character_flag = {
							flag = acr_rejected_nominee
							years >= 10
						}
					}
				}
			}
		}
		
		third_party_score = {
			factor = 100

			acr_pagan_investiture_score = yes
		}
		
		effect = {
			custom_tooltip = {
				text = acr_ask_pagan_pope_to_invest_priest
				FROMFROM = {
					if = {
						limit = { has_character_flag = acr_rejected_nominee }
						clr_character_flag = acr_rejected_nominee
					}
					save_persistent_event_target = {
						name = pagan_papal_priest_nominator
						scope = ROOT_FROM
					}
					set_character_flag = acr_nominated_successor
				}
				FROM = {
					if = {
						limit = { has_character_flag = acr_nominated_priest }
						clr_character_flag = acr_nominated_priest
					}
					set_character_flag = acr_nominated_priest
					if = {
						limit = {
							persistent_event_target:pagan_papal_priest_nominee = { is_alive = yes }
						}
						save_persistent_event_target = {
							name = pagan_papal_priest_backup_nominee
							scope = persistent_event_target:pagan_papal_priest_nominee
						}
						clear_persistent_event_target = pagan_papal_priest_nominee
					}
					save_persistent_event_target = {
						name = pagan_papal_priest_nominee
						scope = ROOT_FROMFROM
					}
					set_character_flag = acr_is_nominating_priest
					persistent_event_target:pagan_papal_priest_nominee = { character_event = { id = ke_ancrel_m.10 } }
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}
		
		#ai_acceptance = {
		#	factor = 0
		#	yes_threshold = 0
		#	nominate_bishop_chance = yes
		#}
	}
	
	acr_cl_check_nominated_priest = {
		only_playable = yes
		ai_check_interval = 3
		filter = religious_head
		third_party_filter = realm
		ai_third_party_filter = realm
		
		from_potential = {
			cl_kinich_uses_autocephaly = no
			OR = {
				has_global_flag = acr_pagan_papal
				has_global_flag = acr_pagan_antipopes
			}
			trigger_if = {
				limit = { higher_real_tier_than = DUKE }
				has_law = investiture_law_0
			}
			trigger_else = {
				crownlaw_title = { has_law = investiture_law_0 }
			}
			religion_scope = {
				persistent_event_target:religion_title = { has_title_flag = acr_uses_investiture }
			}
			#trigger_if = {
			#	limit = {
			#		has_dlc = "Holy Fury"
			#		religion_group = pagan_group
			#		has_religion_feature = religion_theocratic_head
			#		NOR = {
			#			religion = britannic_pagan
			#			religion = promethean_pagan
			#		}
			#	}
			#	OR = {
			#		religion = celtic_pagan_reformed
			#		religion = hellenic_pagan_reformed
			#		religion = egyptian_pagan_reformed
			#		religion = baltic_pagan_reformed
			#		religion = tengri_pagan_reformed
			#		religion = finnish_pagan_reformed
			#		religion = aztec_pagan_reformed
			#		religion = slavic_pagan_reformed
			#		religion = west_african_pagan_reformed
			#		religion = zun_pagan_reformed
			#		religion = norse_pagan_reformed
			#		religion = bon_pagan_reformed
			#	}
			#}
			#trigger_else_if = {
			#	limit = {
			#		NOT = { has_dlc = "Holy Fury" }
			#		religion_group = pagan_group
			#		is_not_unreformed_pagan_trigger = yes
			#		NOR = {
			#			religion = britannic_pagan
			#			religion = promethean_pagan
			#		}
			#	}
			#	OR = {
			#		religion = celtic_pagan_reformed
			#		religion = hellenic_pagan_reformed
			#		religion = egyptian_pagan_reformed
			#		religion = baltic_pagan_reformed
			#		religion = tengri_pagan_reformed
			#		religion = finnish_pagan_reformed
			#		religion = aztec_pagan_reformed
			#		religion = slavic_pagan_reformed
			#		religion = west_african_pagan_reformed
			#		religion = zun_pagan_reformed
			#		religion = bon_pagan_reformed
			#	}
			#}
			#trigger_else_if = {
			#	limit = { religion = zoroastrian }
			#	d_zoroastrian = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = manichaean }
			#	d_army_light = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = jewish }
			#	d_jewish = { has_holder = yes }
			#}
			#trigger_else_if = {
			#	limit = { religion = promethean_pagan }
			#	d_promethean_pagan = { has_holder = yes }
			#}
			#trigger_else = {
			#	religion = britannic_pagan
			#	k_britannic_pagan = { has_holder = yes }
			#}
			is_inaccessible_or_incapable_trigger = no
			higher_real_tier_than = BARON
			has_character_flag = acr_nominated_priest
			persistent_event_target:pagan_papal_priest_nominee = {
				is_alive = yes
			}
		}
	
		potential = {
			religion = FROM
			is_theocracy = yes
			controls_religion = yes
		}
		
		third_party_potential = {
			FROMFROM = {
				has_character_flag = acr_nominated_successor
				persistent_event_target:pagan_papal_priest_nominator = {
					character = FROM
				}
			}
		}
		
		allow = {
			FROM = {
				show_scope_change = no
				persistent_event_target:pagan_papal_priest_nominee = {
					is_alive = yes
				}
			}
		}
		
		third_party_allow = {
			FROMFROM = {
				show_scope_change = no
				always = yes
			}
		}
		
		effect = {
			hidden_effect = {
				FROM = {
					clr_character_flag = acr_nominated_priest
					clear_persistent_event_target = pagan_papal_priest_nominee
				}
				FROMFROM = {
					clr_character_flag = acr_nominated_successor
					clear_persistent_event_target = pagan_papal_priest_nominator
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	acr_cl_revive_egyptian_coptic = {
		ai_check_interval = 12
		filter = self
		ai_target_filter = self

		potential = {
			has_global_flag = greater_egypt_restored
			NOR = {
				has_global_flag = egyptian_coptic_revived
				culture = egyptian_coptic
			}
			block_general_event_trigger = no
			has_landed_title = e_greater_egypt
			religion_openly_in_egyptian_subgroup_trigger = yes
		}
		allow = {
			OR = {
				culture = egyptian_arabic
				culture = coptic
			}
			prestige >= 10000
			learning >= 15
		}
		effect = {
			set_global_flag = egyptian_coptic_revived
			culture = egyptian_coptic

			capital_scope = {
				show_scope_change = no
				if = {
					limit = {
						OR = {
							culture = egyptian_arabic
							culture = coptic
						}
						religion_openly_in_egyptian_subgroup_trigger = yes
					}

					culture = egyptian_coptic
				}
			}
			
			custom_tooltip = {
				text = egyptian_coptic_courtier_conversion
				any_courtier = {
					limit = {
						OR = {
							culture = egyptian_arabic
							culture = coptic
						}
						religion_openly_in_egyptian_subgroup_trigger = yes
						is_ruler = no
					}
					culture = egyptian_coptic
				}
			}
			
			hidden_effect = {
				any_playable_ruler = {
					limit = {
						capital_scope = {
							OR = {
								region = world_africa
								region = world_middle_east
								region = world_europe_south
							}
						}
					}
					narrative_event = { id = ancrel_cleanslate.1 }
				}
				narrative_event = { id = ancrel_cleanslate.1 }
			}
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	acr_cl_embrace_egyptian_coptic = {
		ai_check_interval = 12
		filter = self
		ai_target_filter = self

		potential = {
			has_global_flag = egyptian_coptic_revived
			NOT = { culture = egyptian_coptic }
			block_general_event_trigger = no
			capital_scope = { is_in_egyptian_regions_of_interest_trigger = yes }
			OR = {
				any_realm_province = { culture = egyptian_coptic }
				any_liege = { culture = egyptian_coptic }
			}
			religion_openly_in_egyptian_subgroup_trigger = yes
		}
		allow = {
			OR = {
				culture = egyptian_arabic
				culture = coptic
			}
		}
		effect = {
			culture = egyptian_coptic

			capital_scope = {
				show_scope_change = no
				if = {
					limit = {
						OR = {
							culture = egyptian_arabic
							culture = coptic
						}
						religion_openly_in_egyptian_subgroup_trigger = yes
					}

					culture = egyptian_coptic
				}
			}
			
			custom_tooltip = {
				text = egyptian_coptic_courtier_conversion
				any_courtier = {
					limit = {
						OR = {
							culture = egyptian_arabic
							culture = coptic
						}
						religion_openly_in_egyptian_subgroup_trigger = yes
						is_ruler = no
					}
					culture = egyptian_coptic
				}
			}
		}
		ai_will_do = {
			factor = 1

			mult_modifier = {
				factor = 0.25 #Decrease chance AI will do this
				always = yes
			}
			
			mult_modifier = {
				factor = 30

				top_liege = {
					culture = egyptian_coptic
					has_landed_title = e_greater_egypt
				}
			}

			mult_modifier = {
				factor = 1.5

				capital_scope = { region = world_africa_north_nile }
			}

			mult_modifier = {
				factor = 2.0
				liege = { culture = egyptian_coptic }
			}

			mult_modifier = {
				factor = 1.1

				num_culture_realm_provs = {
					culture = egyptian_coptic
					value >= 2
				}
			}

			mult_modifier = {
				factor = 1.1

				num_culture_realm_provs = {
					culture = egyptian_coptic
					value >= 4
				}
			}

			mult_modifier = {
				factor = 1.1

				num_culture_realm_provs = {
					culture = egyptian_coptic
					value >= 6
				}
			}

			mult_modifier = {
				factor = 1.25

				num_culture_realm_provs = {
					culture = egyptian_coptic
					value >= 8
				}
			}

			mult_modifier = {
				factor = 1.5

				num_culture_realm_provs = {
					culture = egyptian_coptic
					value >= 10
				}
			}
		}
	}
	
	acr_cl_revive_gaulish = {
		ai_check_interval = 12
		filter = self
		ai_target_filter = self

		potential = {
			capital_scope = { region = world_europe_west_gaul }
			NOR = {
				has_global_flag = gaulish_revived
				culture = gaulish
			}
			block_general_event_trigger = no
			has_landed_title = e_francia
			NOT = { has_landed_title = e_britannia }
			religion = celtic_pagan_reformed
		}
		allow = {
			OR = {
				culture = breton
				culture = frankish
				culture_group = iberian
				culture = french
				culture = norman
				culture = occitan
				culture = frisian
				culture = dutch
			}
			prestige >= 10000
			learning >= 12
		}
		effect = {
			set_global_flag = gaulish_revived
			if = {
				limit = { can_apply_cool_nickname_trigger = yes }
				give_nickname = nick_the_gaul
			}
			culture = gaulish

			capital_scope = {
				show_scope_change = no
				if = {
					limit = {
						OR = {
							culture = breton
							culture = frankish
							culture_group = iberian
							culture = french
							culture = norman
							culture = occitan
							culture = frisian
							culture = dutch
						}
						religion_openly_celtic_or_reformed_trigger = yes
					}

					culture = gaulish
				}
			}
			
			custom_tooltip = {
				text = gaulish_courtier_conversion
				any_courtier = {
					limit = {
						OR = {
							culture = breton
							culture = frankish
							culture_group = iberian
							culture = french
							culture = norman
							culture = occitan
							culture = frisian
							culture = dutch
						}
						religion_openly_in_celtic_subgroup_trigger = yes
						is_ruler = no
					}
					culture = gaulish
				}
			}
			
			hidden_effect = {
				any_playable_ruler = {
					limit = {
						capital_scope = {
							OR = {
								region = world_europe
								region = world_middle_east_asia_minor
								region = world_africa_north
							}
						}
					}
					narrative_event = { id = ancrel_cleanslate.2 }
				}
				narrative_event = { id = ancrel_cleanslate.2 }
			}
		}
		ai_will_do = {
			factor = 1

			mult_modifier = {
				factor = 0.2
				culture = breton
			}
			
		}
	}
	
	acr_cl_embrace_gaulish = {
		ai_check_interval = 12
		filter = self
		ai_target_filter = self

		potential = {
			has_global_flag = gaulish_revived
			NOT = { culture = gaulish }
			block_general_event_trigger = no
			capital_scope = {
				NOT = { region = world_europe_west_british_isles }
				is_in_celtic_regions_of_interest_trigger = yes
			}
			OR = {
				any_realm_province = { culture = gaulish }
				any_liege = { culture = gaulish }
			}
			religion_openly_celtic_or_reformed_trigger = yes
		}
		allow = {
			OR = {
				culture = breton
				culture = frankish
				culture_group = iberian
				culture = french
				culture = norman
				culture = occitan
				culture = frisian
				culture = dutch
			}
		}
		effect = {
			culture = gaulish

			capital_scope = {
				show_scope_change = no
				if = {
					limit = {
						OR = {
							culture = breton
							culture = frankish
							culture_group = iberian
							culture = french
							culture = norman
							culture = occitan
							culture = frisian
							culture = dutch
						}
						religion_openly_celtic_or_reformed_trigger = yes
					}

					culture = gaulish
				}
			}
			
			custom_tooltip = {
				text = gaulish_courtier_conversion
				any_courtier = {
					limit = {
						OR = {
							culture = breton
							culture = frankish
							culture_group = iberian
							culture = french
							culture = norman
							culture = occitan
							culture = frisian
							culture = dutch
						}
						religion_openly_in_celtic_subgroup_trigger = yes
						is_ruler = no
					}
					culture = gaulish
				}
			}
		}
		ai_will_do = {
			factor = 1

			mult_modifier = {
				factor = 0.25 #Decrease chance AI will do this
				always = yes
			}
			
			mult_modifier = {
				factor = 0.2
				culture = breton
			}
			
			mult_modifier = {
				factor = 30

				top_liege = {
					culture = gaulish
					has_landed_title = e_francia
					NOT = { has_landed_title = e_britannia }
				}
			}

			mult_modifier = {
				factor = 1.5

				capital_scope = { region = world_europe_west_gaul }
			}

			mult_modifier = {
				factor = 2.0
				liege = { culture = gaulish }
			}

			mult_modifier = {
				factor = 1.1

				num_culture_realm_provs = {
					culture = gaulish
					value >= 2
				}
			}

			mult_modifier = {
				factor = 1.1

				num_culture_realm_provs = {
					culture = gaulish
					value >= 4
				}
			}

			mult_modifier = {
				factor = 1.1

				num_culture_realm_provs = {
					culture = gaulish
					value >= 6
				}
			}

			mult_modifier = {
				factor = 1.25

				num_culture_realm_provs = {
					culture = gaulish
					value >= 8
				}
			}

			mult_modifier = {
				factor = 1.5

				num_culture_realm_provs = {
					culture = gaulish
					value >= 10
				}
			}
		}
	}
	
	acr_cl_reforge_achilles_shield = {
		ai_check_interval = 12
		filter = self
		ai_target_filter = self

		potential = {
			religion_openly_in_hellenic_subgroup_trigger = yes
			has_artifact = achilles_shield_piece
			NOT = { has_global_flag = achilles_shield_reforged }
			block_general_event_trigger = no
		}
		allow = {
			higher_real_tier_than = KING
			trigger_if = {
				limit = {
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_artisan_craftsmen
						bloodline_is_active_for = PREV
					}
				}
				scaled_wealth = {
					value = 0.5
					min = 100
					max = 1500
				}
			}
			trigger_else = {
				scaled_wealth = {
					value = 1
					min = 200
					max = 3000
				}
			}
			custom_tooltip = {
				text = reforge_achilles_shield_tooltip_01
				any_artifact = {
					limit = { has_artifact_flag = achilles_shield_piece }
					count >= 4
				}
			}
			custom_tooltip = {
				text = reforge_achilles_shield_tooltip_02
				any_realm_wonder = {
					### COW ###
					trigger_if = {
						limit = { has_global_flag = is_cl_cow_save }
						OR = {
							has_wonder_upgrade = upgrade_armory
							has_wonder_upgrade = upgrade_cow_armory
						}
					}
					trigger_else = { has_wonder_upgrade = upgrade_armory }
					is_active = yes
				}
			}
		}
		effect = {
			sound_effect = baltic_holds_02
			set_global_flag = achilles_shield_reforged
			
			if = {
				limit = {
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_artisan_craftsmen
						bloodline_is_active_for = PREV
					}
				}
				scaled_wealth = {
					value = -0.5
					min = -100
					max = -1500
				}
			}
			else = {
				scaled_wealth = {
					value = -1
					min = -200
					max = -3000
				}
			}
			any_artifact = {
				limit = { has_artifact_flag = achilles_shield_piece }
				destroy_artifact = yes
			}
			add_artifact = achilles_shield_complete
			prestige = 500
		}
		ai_will_do = {
			factor = 1
		}
	}
	
	acr_cl_check_venerated_ancestors_01 = {
		ai = no
		filter = religious_head

		from_potential = {
			OR = {
				has_religion_feature = religion_feature_baltic
				has_religion_feature = religion_feature_egyptian
				religion = britannic_pagan
			}
		}
		potential = {
			religion = FROM
			controls_religion = yes
		}
		allow = {
			custom_tooltip = {
				text = acr_ancestor_worship_bloodline_exists
				any_bloodline = {
					founder = { religion = ROOT }
					has_bloodline_flag = ancestor_worship_bloodline
				}
			}
		}
		effect = {
			hidden_effect = {
				FROM = { letter_event = { id = ke_ancrel_m.14 } }
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	acr_cl_check_venerated_ancestors_02 = {
		ai = no
		filter = self

		potential = {
			OR = {
				has_religion_feature = religion_feature_baltic
				has_religion_feature = religion_feature_egyptian
			}
			controls_religion = yes
		}
		allow = {
			custom_tooltip = {
				text = acr_ancestor_worship_bloodline_exists
				any_bloodline = {
					founder = { religion = ROOT }
					has_bloodline_flag = ancestor_worship_bloodline
				}
			}
		}
		effect = {
			hidden_effect = {
				ROOT = { letter_event = { id = ke_ancrel_m.14 } }
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
}