###########################################
#
# Society decisions for secret religious societies
#
###########################################

decisions = {
	
	secret_religions_openly_adopt_faith = {
		is_high_prio = yes
		only_rulers = yes
		ai_check_interval = 6
		potential = {
			capital_scope = { has_owners_secret_community = yes }
			has_secret_religion = yes
			has_game_rule = { name = secret_cults value = default }
		}
	
		allow = {
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			war = no
			OR = {
				AND = {
					tier = count
					piety = 250
				}
				AND = {
					tier = duke
					piety = 500
				}
				AND = {
					tier = king
					piety = 1000
				}
				AND = {
					tier = emperor
					piety = 2000
				}
			}
		}
		
		effect = {
			custom_tooltip = {
				text = openly_adopt_faith_effect_tooltip
				if = { # Caliphates and Fylkirates are forfeit
					limit = {
						OR = {
							religion_group = muslim
							religion = norse_pagan_reformed
							#TODO: this needs to be updated
						}
						any_demesne_title = {
							controls_religion = yes
						}
					}
					any_demesne_title = {
						limit = {
							controls_religion = yes
						}
						destroy_landed_title = THIS
					}
				}
				if = { # Papacies are given to a random new character
					limit = {
						NOR = {
							religion_group = muslim
							religion = norse_pagan_reformed
						}
						any_demesne_title = {
							controls_religion = yes
						}
					}
					hidden_tooltip = {
						liege = {
							save_event_target_as = liege_target
						}
						create_character = {
							age = 38
							dynasty = random
							religion = ROOT
							culture = ROOT
							random_traits = yes
						}
						new_character = {
							save_event_target_as = new_holder
						}
					}
					any_demesne_title = {
						limit = {
							controls_religion = yes
						}
						grant_title = event_target:new_holder
						holder_scope = {
							any_vassal = {
								set_defacto_liege = event_target:liege_target
							}
						}
					}
					hidden_tooltip = {
						set_defacto_liege = event_target:liege_target
					}
				}
				if = { # Holy Orders/Static Mercs are given to a random new character
					limit = {
						any_demesne_title = {
							OR = {
								holy_order = yes
								mercenary = yes
							}
						}
					}
					hidden_tooltip = {
						liege = {
							save_event_target_as = liege_target
						}
						create_character = {
							age = 38
							dynasty = random
							religion = ROOT
							culture = ROOT
							random_traits = yes
						}
						new_character = {
							save_event_target_as = new_holder
						}
					}
					any_demesne_title = {
						limit = {
							OR = {
								holy_order = yes
								mercenary = yes
							}
						}
						grant_title = event_target:new_holder
						holder_scope = {
							any_vassal = {
								set_defacto_liege = event_target:liege_target
							}
						}
					}
					hidden_tooltip = {
						set_defacto_liege = event_target:liege_target
					}
				}
				hidden_effect = {
					character_event = { id = MNM.3811 }
					top_liege = {
						any_realm_character = {
							if = {
								limit = {
									secret_religion = { target_type = secret target = ROOT }
								}
								character_event = { id = MNM.3800 } # Convert cultists
							}
							
							if = {
								limit = {
									OR = {
										has_prevs_secret_religion_truly_trigger = yes
										has_sympathy_for_true_religion_of_prev_trigger = yes
									}
								}
								character_event = { id = MNM.3810 } # Allow sympathisers the chance to flip
							}
							
							if = {
								limit = {
									is_ruler = yes
									any_demesne_province = {
										has_roots_secret_community = yes
									}
								}
								if = {
									limit = {
										NOT = { has_character_flag = currently_part_of_secret_religion_uncovering }
										liege = { character = ROOT }
									}
									character_event = { id = MNM.3820 } # Flip provinces with local cult modifier
								}
								if = {
									limit = { has_character_flag = currently_part_of_secret_religion_uncovering }
									ROOT = {
										trigger_switch = {
											on_trigger = secret_religion
											chalcedonian = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_chalcedonian_community
														}
														religion = chalcedonian
														remove_province_modifier = secret_chalcedonian_community
													}
												}
											}
											catholic = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_catholic_community
														}
														religion = catholic
														remove_province_modifier = secret_catholic_community
													}
												}
											}
											cathar = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_cathar_community
														}
														religion = cathar
														remove_province_modifier = secret_cathar_community
													}
												}
											}
											fraticelli = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_fraticelli_community
														}
														religion = fraticelli
														remove_province_modifier = secret_fraticelli_community
													}
												}
											}
											waldensian = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_waldensian_community
														}
														religion = waldensian
														remove_province_modifier = secret_waldensian_community
													}
												}
											}
											lollard = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_lollard_community
														}
														religion = lollard
														remove_province_modifier = secret_lollard_community
													}
												}
											}
											adoptionist = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_adoptionist_community
														}
														religion = adoptionist
														remove_province_modifier = secret_adoptionist_community
													}
												}
											}
											orthodox = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_orthodox_community
														}
														religion = orthodox
														remove_province_modifier = secret_orthodox_community
													}
												}
											}
											miaphysite = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_miaphysite_community
														}
														religion = miaphysite
														remove_province_modifier = secret_miaphysite_community
													}
												}
											}
											monophysite = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_monophysite_community
														}
														religion = monophysite
														remove_province_modifier = secret_monophysite_community
													}
												}
											}
											bogomilist = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_bogomilist_community
														}
														religion = bogomilist
														remove_province_modifier = secret_bogomilist_community
													}
												}
											}
											monothelite = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_monothelite_community
														}
														religion = monothelite
														remove_province_modifier = secret_monothelite_community
													}
												}
											}
											iconoclast = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_iconoclast_community
														}
														religion = iconoclast
														remove_province_modifier = secret_iconoclast_community
													}
												}
											}
											apostolic = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_apostolic_community
														}
														religion = apostolic
														remove_province_modifier = secret_apostolic_community
													}
												}
											}
											paulician = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_paulician_community
														}
														religion = paulician
														remove_province_modifier = secret_paulician_community
													}
												}
											}
											tondrakian = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_tondrakian_community
														}
														religion = tondrakian
														remove_province_modifier = secret_tondrakian_community
													}
												}
											}
											nestorian = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_nestorian_community
														}
														religion = nestorian
														remove_province_modifier = secret_nestorian_community
													}
												}
											}
											messalian = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_messalian_community
														}
														religion = messalian
														remove_province_modifier = secret_messalian_community
													}
												}
											}
											sunni = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_sunni_community
														}
														religion = sunni
														remove_province_modifier = secret_sunni_community
													}
												}
											}
											zikri = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_zikri_community
														}
														religion = zikri
														remove_province_modifier = secret_zikri_community
													}
												}
											}
											quranist = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_quranist_community
														}
														religion = quranist
														remove_province_modifier = secret_quranist_community
													}
												}
											}
											yazidi = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_yazidi_community
														}
														religion = yazidi
														remove_province_modifier = secret_yazidi_community
													}
												}
											}
											ibadi = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_ibadi_community
														}
														religion = ibadi
														remove_province_modifier = secret_ibadi_community
													}
												}
											}
											kharijite = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_kharijite_community
														}
														religion = kharijite
														remove_province_modifier = secret_kharijite_community
													}
												}
											}
											shiite = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_shiite_community
														}
														religion = shiite
														remove_province_modifier = secret_shiite_community
													}
												}
											}
											bektashi = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_bektashi_community
														}
														religion = bektashi
														remove_province_modifier = secret_bektashi_community
													}
												}
											}
											druze = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_druze_community
														}
														religion = druze
														remove_province_modifier = secret_druze_community
													}
												}
											}
											hurufi = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_hurufi_community
														}
														religion = hurufi
														remove_province_modifier = secret_hurufi_community
													}
												}
											}
											qarmatian = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_qarmatian_community
														}
														religion = qarmatian
														remove_province_modifier = secret_qarmatian_community
													}
												}
											}
											aztec = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_aztec_community
														}
														religion = aztec
														remove_province_modifier = secret_aztec_community
													}
												}
											}
											jewish = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_jewish_community
														}
														religion = jewish
														remove_province_modifier = secret_jewish_community
													}
												}
											}
											samaritan = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_samaritan_community
														}
														religion = samaritan
														remove_province_modifier = secret_samaritan_community
													}
												}
											}
											karaite = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_karaite_community
														}
														religion = karaite
														remove_province_modifier = secret_karaite_community
													}
												}
											}
											zoroastrian = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_zoroastrian_community
														}
														religion = zoroastrian
														remove_province_modifier = secret_zoroastrian_community
													}
												}
											}
											zurvanist = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_zurvanist_community
														}
														religion = zurvanist
														remove_province_modifier = secret_zurvanist_community
													}
												}
											}
											mazdaki = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_mazdaki_community
														}
														religion = mazdaki
														remove_province_modifier = secret_mazdaki_community
													}
												}
											}
											manichean = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_manichean_community
														}
														religion = manichean
														remove_province_modifier = secret_manichean_community
													}
												}
											}
											mandaean = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_mandaean_community
														}
														religion = mandaean
														remove_province_modifier = secret_mandaean_community
													}
												}
											}
											hindu = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_hindu_community
														}
														religion = hindu
														remove_province_modifier = secret_hindu_community
													}
												}
											}
											buddhist = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_buddhist_community
														}
														religion = buddhist
														remove_province_modifier = secret_buddhist_community
													}
												}
											}
											jain = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_jain_community
														}
														religion = jain
														remove_province_modifier = secret_jain_community
													}
												}
											}
											khurmazta = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_khurmazta_community
														}
														religion = khurmazta
														remove_province_modifier = secret_khurmazta_community
													}
												}
											}
											taoist = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_taoist_community
														}
														religion = taoist
														remove_province_modifier = secret_taoist_community
													}
												}
											}
											bon = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_bon_community
														}
														religion = bon
														remove_province_modifier = secret_bon_community
													}
												}
											}
											tibetan_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_tibetan_pagan_community
														}
														religion = tibetan_pagan
														remove_province_modifier = secret_tibetan_pagan_community
													}
												}
											}
											norse_pagan_reformed = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_norse_pagan_reformed_community
														}
														religion = norse_pagan_reformed
														remove_province_modifier = secret_norse_pagan_reformed_community
													}
												}
											}
											norse_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_norse_pagan_community
														}
														religion = norse_pagan
														remove_province_modifier = secret_norse_pagan_community
													}
												}
											}
											german_pagan_reformed = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_german_pagan_reformed_community
														}
														religion = german_pagan_reformed
														remove_province_modifier = secret_german_pagan_reformed_community
													}
												}
											}
											german_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_german_pagan_community
														}
														religion = german_pagan
														remove_province_modifier = secret_german_pagan_community
													}
												}
											}
											celtic_pagan_reformed = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_celtic_pagan_reformed_community
														}
														religion = celtic_pagan_reformed
														remove_province_modifier = secret_celtic_pagan_reformed_community
													}
												}
											}
											celtic_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_celtic_pagan_community
														}
														religion = celtic_pagan
														remove_province_modifier = secret_celtic_pagan_community
													}
												}
											}
											slavic_pagan_reformed = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_slavic_pagan_reformed_community
														}
														religion = slavic_pagan_reformed
														remove_province_modifier = secret_slavic_pagan_reformed_community
													}
												}
											}
											slavic_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_slavic_pagan_community
														}
														religion = slavic_pagan
														remove_province_modifier = secret_slavic_pagan_community
													}
												}
											}
											tengri_pagan_reformed = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_tengri_pagan_reformed_community
														}
														religion = tengri_pagan_reformed
														remove_province_modifier = secret_tengri_pagan_reformed_community
													}
												}
											}
											tengri_pagan = {
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_tengri_pagan_community
														}
														religion = tengri_pagan
														remove_province_modifier = secret_tengri_pagan_community
													}
												}
											}
											baltic_pagan_reformed = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_baltic_pagan_reformed_community
														}
														religion = baltic_pagan_reformed
														remove_province_modifier = secret_baltic_pagan_reformed_community
													}
												}
											}
											baltic_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_baltic_pagan_community
														}
														religion = baltic_pagan
														remove_province_modifier = secret_baltic_pagan_community
													}
												}
											}
											finnish_pagan_reformed = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_finnish_pagan_reformed_community
														}
														religion = finnish_pagan_reformed
														remove_province_modifier = secret_finnish_pagan_reformed_community
													}
												}
											}
											finnish_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_finnish_pagan_community
														}
														religion = finnish_pagan
														remove_province_modifier = secret_finnish_pagan_community
													}
												}
											}
											west_african_pagan_reformed = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_west_african_pagan_reformed_community
														}
														religion = west_african_pagan_reformed
														remove_province_modifier = secret_west_african_pagan_reformed_community
													}
												}
											}
											west_african_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_west_african_pagan_community
														}
														religion = west_african_pagan
														remove_province_modifier = secret_west_african_pagan_community
													}
												}
											}
											zun_pagan_reformed = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_zun_pagan_reformed_community
														}
														religion = zun_pagan_reformed 
														remove_province_modifier = secret_zun_pagan_reformed_community
													}
												}
											} 
											zun_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_zun_pagan_community
														}
														religion = zun_pagan 
														remove_province_modifier = secret_zun_pagan_community
													}
												}
											}
											roman_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_roman_pagan_community
														}
														religion = roman_pagan 
														remove_province_modifier = secret_roman_pagan_community
													}
												}
											}
											egyptian_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_egyptian_pagan_community
														}
														religion = egyptian_pagan
														remove_province_modifier = secret_egyptian_pagan_community
													}
												}
											}
											promethean_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_promethean_pagan_community
														}
														religion = promethean_pagan 
														remove_province_modifier = secret_promethean_pagan_community
													}
												}
											}
											aten_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_aten_pagan_community
														}
														religion = aten_pagan 
														remove_province_modifier = secret_aten_pagan_community
													}
												}
											}
											arab_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_arab_pagan_community
														}
														religion = arab_pagan
														remove_province_modifier = secret_arab_pagan_community
													}
												}
											}
											berber_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_berber_pagan_community
														}
														religion = berber_pagan 
														remove_province_modifier = secret_berber_pagan_community
													}
												}
											}
											jewish_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_jewish_pagan_community
														}
														religion = jewish_pagan 
														remove_province_modifier = secret_jewish_pagan_community
													}
												}
											}
											hellenic_pagan = { 
												PREV = {
													any_demesne_province = {
														limit = {
															has_province_modifier = secret_hellenic_pagan_community
														}
														religion = hellenic_pagan 
														remove_province_modifier = secret_hellenic_pagan_community
													}
												}
											}
										}
									}
								}
							}
						}
					}
					flip_secret_religious_community_provinces = yes
					flip_to_secret_religion_effect = yes
					
					trigger_switch = {
						on_trigger = tier
						count = { piety = -250 }
						duke = { piety = -500 }
						king = { piety = -1000 }
						emperor = { piety = -2000 }
					}
					
					top_liege = {
						any_realm_lord = {
							character_event = { id = MNM.3830 } # Inform lieges unless they're part of the cult flipping, save a flag on previous events.
						}
						
						any_realm_character = {
							limit = {
								NOT = {
									character = ROOT
								}
								has_character_flag = currently_part_of_secret_religion_uncovering
							}
							clr_character_flag = currently_part_of_secret_religion_uncovering
						}
					}
				}
			}
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.6 # Slow down
			}
			modifier = {
				factor = 0.1
				is_landed = no
			}
			modifier = {
				factor = 0
				prisoner = yes
			}
			modifier = {
				factor = 0
				top_liege = {
					war = yes
				}
			}
			modifier = { #Don't do it unless you are confident in support
				factor = 0
				NOR = {
					AND = { # The Top Liege is in the Secret Cult, and at least 3 of the Liege's direct vassals are also members
						top_liege = {
							is_openly_of_roots_secret_religion_trigger = yes
						}
						top_liege = {
							any_vassal = {
								count = 3
								higher_tier_than = BARON
								prisoner = no
								is_openly_of_roots_secret_religion_trigger = yes
							}
						}
					}
					top_liege = { # At least 5 direct vassals of the Top Liege is in the Secret Cult
						any_vassal = {
							count = 5
							higher_tier_than = BARON
							prisoner = no
							is_openly_of_roots_secret_religion_trigger = yes
						}
					}
					top_liege = { # All direct vassals of the Top Liege are in the Secret Cult
						NOT = {
							any_vassal = {
								higher_tier_than = BARON
								is_openly_of_roots_secret_religion_trigger = yes
							}
						}
					}
					top_liege = {
						realm_character_percent = {
							target = 0.30
							is_openly_of_prevs_secret_religion_trigger = yes
						}
					}
					AND = {
						top_liege = {
							realm_character_percent = {
								target = 0.25
								is_openly_of_prevs_secret_religion_trigger = yes
							}
						}
						liege = {
							is_openly_of_prevs_secret_religion_trigger = yes
						}
					}
					AND = {
						top_liege = {
							realm_character_percent = {
								target = 0.20
								is_openly_of_prevs_secret_religion_trigger = yes
							}
						}
						top_liege = {
							is_openly_of_prevs_secret_religion_trigger = yes
						}
						liege = {
							is_openly_of_prevs_secret_religion_trigger = yes
						}
					}
					AND = {
						top_liege = {
							realm_character_percent = {
								target = 0.15
								is_openly_of_prevs_secret_religion_trigger = yes
							}
						}
						any_vassal = {
							is_openly_of_prevs_secret_religion_trigger = yes
						}
						top_liege = {
							is_openly_of_prevs_secret_religion_trigger = yes
						}
						liege = {
							is_openly_of_prevs_secret_religion_trigger = yes
						}
					}
				}
			}
			modifier = {
				factor = 1.5
				trait = ambitious
			}
			modifier = {
				factor = 1.5
				realm_character_percent = {
					target = 0.15
					is_openly_of_prevs_secret_religion_trigger = yes
				}				
			}
			modifier = {
				factor = 1.5
				realm_character_percent = {
					target = 0.25
					is_openly_of_prevs_secret_religion_trigger = yes
				}				
			}
			modifier = {
				factor = 1.5
				realm_character_percent = {
					target = 0.35
					is_openly_of_prevs_secret_religion_trigger = yes
				}				
			}
			modifier = {
				factor = 1.5
				realm_character_percent = {
					target = 0.5
					is_openly_of_prevs_secret_religion_trigger = yes
				}				
			}
			modifier = {
				factor = 1.5
				realm_character_percent = {
					target = 0.65
					is_openly_of_prevs_secret_religion_trigger = yes
				}				
			}
		}
	}
}

targeted_decisions = {
	secret_religions_induct_child = {
		ai_target_filter = home_court
		ai_check_interval = 3
		from_potential = {
			has_secret_religion = yes
			OR = {
				NOT = { has_character_flag = induct_child_flag }
				had_character_flag = { flag = induct_child_flag days = 365 }
			}
		}

		potential = {
			NOT = {
				character = FROM
			}
			OR = {
				mother = { character = FROM }
				father = { character = FROM }
				educator = { character = FROM }
				guardian = { character = FROM }
			}
			has_secret_religion_trait_trigger = no
			FROM = { ROOT = { is_openly_of_prevs_secret_religion_trigger = no } }
			is_adult = no
			has_game_rule = { name = secret_cults value = default }
		}

		allow = {
			NOT = {
				has_character_modifier = accused_apostate
			}
			FROM = {
				prisoner = no
				is_inaccessible_trigger = no
				NOT = { trait = incapable }
				piety = 50
			}
			age = 8
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			custom_tooltip = {
				text = secret_religions_induct_child_allow_tt
				FROM = { shares_prevs_secret_religion_trigger = no }
			}
			custom_tooltip = {
				text = secret_religions_induct_character_cd_tt
				NOT = { has_character_modifier = secret_religions_induct_child_timer }
			}
		}

		effect = {
			custom_tooltip = {
				text = secret_religions_induct_child_effect

				FROM = { character_event = { id = MNM.3438 } }

				hidden_effect = {
					add_character_modifier = {
						name = secret_religions_induct_child_timer
						years = 10
						hidden = yes
					}
				}
			}
			FROM = { 
				increase_visibility_effect = yes
				piety = -50
				set_character_flag = induct_child_flag
			}
		}

		
		ai_will_do = {
			factor = 1
			modifier = {
				OR = {
					mother = { character = FROM }
					father = { character = FROM }
				}
				factor = 10
			}
			modifier = {
				FROM = { current_heir = { character = ROOT } }
				factor = 10
			}
			modifier = {
				is_friend = FROM
				factor = 10
			}
			modifier = {
				trait = trusting
				factor = 5
			}
			modifier = {
				ai = no
				factor = 5
			}
			modifier = {
				OR = {
					mother = { ai = no }
					father = { ai = no }
				}
				factor = 0.1
			}
			modifier = {
				factor = 0.1
				NOT = {
					any_realm_character = {
						ai = no
					}
				}
			}
		}
	}
	
	secret_religions_induct_character = {
		
		filter = realm
		ai_target_filter = realm
		ai_check_interval = 3
		from_potential = {
			has_secret_religion = yes
			capital_scope = { has_owners_secret_community = yes }
			OR = {
				NOT = { has_character_flag = induct_character_flag }
				had_character_flag = { flag = induct_character_flag days = 365 }
			}
		}
		
		potential = {
			NOT = {
				character = FROM
			}
			is_adult = yes
			FROM = { 
				ROOT = { 
					NOT = {
						secret_religion = PREV
					}
					is_openly_of_prevs_secret_religion_trigger = no
				} 
			}
			FROM = { 
				ROOT = { 
					OR = {
						has_sympathy_for_true_religion_of_prev_trigger = yes
						is_openly_of_prevs_true_religion_group = yes 
					}
				}
			}
			OR = {
				real_tier = FROM
				is_liege_of = FROM
				AND = {
					vassal_of = FROM
					lower_real_tier_than = FROM
				}
			}
			has_game_rule = { name = secret_cults value = default }
		}

		allow = {
			NOT = {
				has_character_modifier = accused_apostate
			}
			FROM = {
				prisoner = no
				is_inaccessible_trigger = no
				NOT = { trait = incapable }
				piety = 50
			}
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			custom_tooltip = {
				text = secret_religions_induct_character_cd_tt
				OR = {
					NOT = { has_character_modifier = secret_religion_induction_timer }
					has_quest = quest_secret_religious_soceities_induct_ruler
				}
			}
		}

		effect = {
			hidden_effect = {
				add_character_modifier = {
					name = secret_religion_induction_timer
					years = 10
					hidden = yes
				}
			}

			custom_tooltip = {
				text = secret_religions_induct_character_effect_tt
				FROM = { character_event = { id = MNM.3408 days = 10 } }
			}
			FROM = { 
				increase_visibility_effect = yes
				piety = -50
				set_character_flag = induct_character_flag
			}
		}

		
		ai_will_do = {
			factor = 1
			modifier = {
				ai = no
				factor = 5
			}
			modifier = {
				is_ruler = yes
				factor = 10
			}
			modifier = {
				is_close_relative = FROM
				factor = 10
			}
			modifier = {
				is_lover = FROM
				factor = 10
			}
			modifier = {
				is_friend = FROM
				factor = 10
			}
			modifier = {
				trait = trusting
				factor = 5
			}
			modifier = {
				ai = no
				factor = 5
			}
			modifier = {
				NOT = {
					any_realm_character = {
						ai = no
					}
				}
    			factor = 0.01
			}
		}
	}
	
	secret_religions_evoke_sympathy = {
		only_rulers = yes #this is intentionally limited to rulers only
		filter = realm 
		ai_target_filter = realm
		ai_check_interval = 3
		from_potential = {
			has_secret_religion = yes
			OR = {
				NOT = { has_character_flag = sympathy_character_flag }
				had_character_flag = { flag = sympathy_character_flag days = 365 }
			}
		}

		potential = {
			same_realm = FROM
			is_adult = yes
			NOT = { secret_religion = ROOT }
			FROM = { 
				ROOT = { 
					has_sympathy_for_true_religion_of_prev_trigger = no
					is_openly_of_prevs_true_religion_group = no
					shares_prevs_secret_religion_trigger = no
				}
			}
			NOT = { 
				character = FROM
			}
			OR = {
				real_tier = FROM
				is_liege_of = FROM
				AND = {
					vassal_of = FROM
					lower_real_tier_than = FROM
				}
			}
			has_game_rule = { name = secret_cults value = default }
		}

		allow = {
			NOT = {
				has_character_modifier = accused_apostate
			}
			FROM = {
				prisoner = no
				is_inaccessible_trigger = no
				NOT = { trait = incapable }
				piety = 25
			}
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
			custom_tooltip = {
				text = secret_religions_evoke_sympathy_cd_tt
				NOT = { has_character_modifier = secret_religion_sympathy_timer }
			}
		}

		effect = {
			hidden_effect = {
				add_character_modifier = {
					name = secret_religion_sympathy_timer
					years = 10
					hidden = yes
				}
			}

			custom_tooltip = {
				text = secret_religions_evoke_sympathy_tt
				FROM = { character_event = { id = MNM.3404 days = 7 } }
			}
			FROM = {
				increase_visibility_minor_effect = yes
				set_character_flag = sympathy_character_flag
				piety = -25
			}
		}

		
		ai_will_do = {
			factor = 1
			modifier = {
				NOT = {
					capital_scope = { has_owners_secret_community = yes }
				}
				factor = 0.1
			}
			modifier = {
				is_ruler = yes
				factor = 3
			}
			modifier = {
				trait = zealous
				factor = 0.0001
			}
			modifier = {
				is_close_relative = FROM
				factor = 10
			}
			modifier = {
				is_lover = FROM
				factor = 10
			}
			modifier = {
				is_friend = FROM
				factor = 10
			}
			modifier = {
				trait = kind
				factor = 5
			}
			modifier = {
				trait = trusting
				factor = 5
			}
			modifier = {
				ai = no
				factor = 5
			}
		}
	}
	
	secret_religions_renounce_secret_religion = {
		only_playable = yes
		
		filter = self
		ai_target_filter = self
		
		potential = {
			character = FROM
			has_secret_religion = yes
		}
		
		allow = {
			NOT = { trait = incapable }
		}
		
		effect = {
			clear_secret_religion = yes
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secret_religions_personally_adopt_secret_religion = {
		only_playable = yes
		
		filter = self
		ai_target_filter = self
		
		potential = {
			character = FROM
			has_secret_religion = yes
		}
		
		allow = {
			NOT = { trait = incapable }
			OR = {
				AND = {
					tier = count
					piety = 100
				}
				AND = {
					tier = duke
					piety = 200
				}
				AND = {
					tier = king
					piety = 500
				}
				AND = {
					tier = emperor
					piety = 1000
				}
			}
		}
		
		effect = {
			flip_to_secret_religion_effect = yes
			trigger_switch = {
				on_trigger = tier
				count = { piety = -100 }
				duke = { piety = -200 }
				king = { piety = -500 }
				emperor = { piety = -1000 }
			}
			trigger_switch = {
				on_trigger = religion
				catholic = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_catholic_community } religion = catholic
					}
				}
				chalcedonian = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_chalcedonian_community } religion = chalcedonian
					}
				}
				cathar = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_cathar_community } religion = cathar
					}
				}
				fraticelli = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_fraticelli_community } religion = fraticelli
					}
				}
				waldensian = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_waldensian_community } religion = waldensian
					}
				}
				lollard = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_lollard_community } religion = lollard
					}
				}
				adoptionist = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_adoptionist_community } religion = adoptionist
					}
				}
				orthodox = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_orthodox_community } religion = orthodox
					}
				}
				miaphysite = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_miaphysite_community } religion = miaphysite
					}
				}
				monophysite = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_monophysite_community } religion = monophysite
					}
				}
				bogomilist = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_bogomilist_community } religion = bogomilist
					}
				}
				monothelite = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_monothelite_community } religion = monothelite
					}
				}
				iconoclast = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_iconoclast_community } religion = iconoclast
					}
				}
				paulician = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_paulician_community } religion = paulician
					}
				}
				apostolic = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_apostolic_community } religion = apostolic
					}
				}
				tondrakian = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_tondrakian_community } religion = tondrakian
					}
				}
				nestorian = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_nestorian_community } religion = nestorian
					}
				}
				messalian = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_messalian_community } religion = messalian
					}
				}
				sunni = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_sunni_community } religion = sunni
					}
				}
				zikri = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_zikri_community } religion = zikri
					}
				}
				quranist = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_quranist_community } religion = quranist
					}
				}
				bektashi = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_bektashi_community } religion = bektashi
					}
				}
				yazidi = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_yazidi_community } religion = yazidi
					}
				}
				ibadi = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_ibadi_community } religion = ibadi
					}
				}
				kharijite = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_kharijite_community } religion = kharijite
					}
				}
				shiite = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_shiite_community } religion = shiite
					}
				}
				druze = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_druze_community } religion = druze
					}
				}
				hurufi = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_hurufi_community } religion = hurufi
					}
				}
				qarmatian = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_qarmatian_community } religion = qarmatian
					}
				}
				aztec = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_aztec_community } religion = aztec
					}
				}
				jewish = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_jewish_community } religion = jewish
					}
				}
				samaritan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_samaritan_community } religion = samaritan
					}
				}
				karaite = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_karaite_community } religion = karaite
					}
				}
				zoroastrian = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_zoroastrian_community } religion = zoroastrian
					}
				}
				zurvanist = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_zurvanist_community } religion = zurvanist
					}
				}
				mazdaki = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_mazdaki_community } religion = mazdaki
					}
				}
				manichean = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_manichean_community } religion = manichean
					}
				}
				mandaean = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_mandaean_community } religion = mandaean
					}
				}
				khurmazta = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_khurmazta_community } religion = khurmazta
					}
				}
				taoist = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_taoist_community } religion = taoist
					}
				}
				bon = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_bon_community } religion = bon
					}
				}
				tibetan_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_tibetan_pagan_community } religion = tibetan_pagan
					}
				}
				hindu = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_hindu_community } religion = hindu
					}
				}
				buddhist = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_buddhist_community } religion = buddhist
					}
				}
				jain = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_jain_community } religion = jain
					}
				}
				norse_pagan_reformed = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_norse_pagan_reformed_community } 
						religion = norse_pagan_reformed
					}
				}
				norse_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_norse_pagan_community } 
						religion = norse_pagan
					}
				}
				german_pagan_reformed = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_german_pagan_reformed_community } 
						religion = german_pagan_reformed
					}
				}
				german_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_german_pagan_community } 
						religion = german_pagan
					}
				}
				celtic_pagan_reformed = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_celtic_pagan_reformed_community } 
						religion = celtic_pagan_reformed
					}
				}
				celtic_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_celtic_pagan_community } 
						religion = celtic_pagan
					}
				}
				baltic_pagan_reformed = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_baltic_pagan_reformed_community } 
						religion = baltic_pagan_reformed
					}
				}
				baltic_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_baltic_pagan_community } 
						religion = baltic_pagan
					}
				}
				finnish_pagan_reformed = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_finnish_pagan_reformed_community } 
						religion = finnish_pagan_reformed
					}
				}
				finnish_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_finnish_pagan_community } 
						religion = finnish_pagan
					}
				}
				slavic_pagan_reformed = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_slavic_pagan_reformed_community } 
						religion = slavic_pagan_reformed
					}
				}
				slavic_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_slavic_pagan_community } 
						religion = slavic_pagan
					}
				}
				tengri_pagan_reformed = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_tengri_pagan_reformed_community } 
						religion = tengri_pagan_reformed
					}
				}
				tengri_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_tengri_pagan_community } 
						religion = tengri_pagan
					}
				}
				west_african_pagan_reformed = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_west_african_pagan_reformed_community } 
						religion = west_african_pagan_reformed
					}
				}
				west_african_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_west_african_pagan_community } 
						religion = west_african_pagan
					}
				}
				zun_pagan_reformed = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_zun_pagan_reformed_community } 
						religion = zun_pagan_reformed
					}
				}
				zun_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_zun_pagan_community } 
						religion = zun_pagan
					}
				}
				roman_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_roman_pagan_community } 
						religion = roman_pagan
					}
				}
				egyptian_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_egyptian_pagan_community } 
						religion = egyptian_pagan
					}
				}
				promethean_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_promethean_pagan_community } 
						religion = promethean_pagan
					}
				}
				aten_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_aten_pagan_community } 
						religion = aten_pagan
					}
				}
				arab_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_arab_pagan_community } 
						religion = arab_pagan
					}
				}
				berber_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_berber_pagan_community } 
						religion = berber_pagan
					}
				}
				jewish_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_jewish_pagan_community } 
						religion = jewish_pagan
					}
				}
				hellenic_pagan = {
					any_demesne_province = {
						limit = { has_province_modifier = secret_hellenic_pagan_community } 
						religion = hellenic_pagan
					}
				}
			}
			if = {
				limit = {
					liege = {
						NOT = {
							character = ROOT
						}
					}
				}
				liege = {
					character_event = { id = MNM.3840 }
				}
			}
			hidden_tooltip = {
				set_variable = { which = visibility_value value = 0 }
				remove_character_modifier = highly_suspect
				remove_character_modifier = under_suspicion
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
}

#########################################################################################################
################ Secret society title decisions
#########################################################################################################
title_decisions = {
	secret_religions_prepare_grounds = {
		only_playable = yes
		ai_check_interval = 12
		ai_target_filter = realm_owned
		filter = realm_owned
		
		from_potential = {
			has_secret_religion = yes
			has_game_rule = { name = secret_cults value = default }
		}
		
		potential = {
			tier = COUNT
			holder_scope = {
				same_realm = FROM
			}
			OR = {
				AND = {
					FROM = {
						secret_religion = catholic
					}
					NOT = { location = { religion = catholic } }
					NOT = { location = { has_province_modifier = secret_catholic_community } }
				}
				AND = {
					FROM = {
						secret_religion = chalcedonian
					}
					NOT = { location = { religion = chalcedonian } }
					NOT = { location = { has_province_modifier = secret_chalcedonian_community } }
				}
				AND = {
					FROM = {
						secret_religion = cathar
					}
					NOT = { location = { religion = cathar } }
					NOT = { location = { has_province_modifier = secret_cathar_community } }
				}
				AND = {
					FROM = {
						secret_religion = fraticelli
					}
					NOT = { location = { religion = fraticelli } }
					NOT = { location = { has_province_modifier = secret_fraticelli_community } }
				}
				AND = {
					FROM = {
						secret_religion = waldensian
					}
					NOT = { location = { religion = waldensian } }
					NOT = { location = { has_province_modifier = secret_waldensian_community } }
				}
				AND = {
					FROM = {
						secret_religion = lollard
					}
					NOT = { location = { religion = lollard } }
					NOT = { location = { has_province_modifier = secret_lollard_community } }
				}
				AND = {
					FROM = {
						secret_religion = adoptionist
					}
					NOT = { location = { religion = adoptionist } }
					NOT = { location = { has_province_modifier = secret_adoptionist_community } }
				}
				AND = {
					FROM = {
						secret_religion = orthodox
					}
					NOT = { location = { religion = orthodox } }
					NOT = { location = { has_province_modifier = secret_orthodox_community } }
				}
				AND = {
					FROM = {
						secret_religion = miaphysite
					}
					NOT = { location = { religion = miaphysite } }
					NOT = { location = { has_province_modifier = secret_miaphysite_community } }
				}
				AND = {
					FROM = {
						secret_religion = monophysite
					}
					NOT = { location = { religion = monophysite } }
					NOT = { location = { has_province_modifier = secret_monophysite_community } }
				}
				AND = {
					FROM = {
						secret_religion = bogomilist
					}
					NOT = { location = { religion = bogomilist } }
					NOT = { location = { has_province_modifier = secret_bogomilist_community } }
				}
				AND = {
					FROM = {
						secret_religion = monothelite
					}
					NOT = { location = { religion = monothelite } }
					NOT = { location = { has_province_modifier = secret_monothelite_community } }
				}
				AND = {
					FROM = {
						secret_religion = iconoclast
					}
					NOT = { location = { religion = iconoclast } }
					NOT = { location = { has_province_modifier = secret_iconoclast_community } }
				}
				AND = {
					FROM = {
						secret_religion = paulician
					}
					NOT = { location = { religion = paulician } }
					NOT = { location = { has_province_modifier = secret_paulician_community } }
				}
				AND = {
					FROM = {
						secret_religion = apostolic
					}
					NOT = { location = { religion = apostolic } }
					NOT = { location = { has_province_modifier = secret_apostolic_community } }
				}
				AND = {
					FROM = {
						secret_religion = tondrakian
					}
					NOT = { location = { religion = tondrakian } }
					NOT = { location = { has_province_modifier = secret_tondrakian_community } }
				}
				AND = {
					FROM = {
						secret_religion = nestorian
					}
					NOT = { location = { religion = nestorian } }
					NOT = { location = { has_province_modifier = secret_nestorian_community } }
				}
				AND = {
 					FROM = {
						secret_religion = messalian
					}
					NOT = { location = { religion = messalian } }
					NOT = { location = { has_province_modifier = secret_messalian_community } }
				}
				AND = {
					FROM = {
						secret_religion = sunni
					}
					NOT = { location = { religion = sunni } }
					NOT = { location = { has_province_modifier = secret_sunni_community } }
				}
				AND = {
					FROM = {
						secret_religion = zikri
					}
					NOT = { location = { religion = zikri } }
					NOT = { location = { has_province_modifier = secret_zikri_community } }
				}
				AND = {
					FROM = {
						secret_religion = quranist
					}
					NOT = { location = { religion = quranist } }
					NOT = { location = { has_province_modifier = secret_quranist_community } }
				}
				AND = {
					FROM = {
						secret_religion = yazidi
					}
					NOT = { location = { religion = yazidi } }
					NOT = { location = { has_province_modifier = secret_yazidi_community } }
				}
				AND = {
					FROM = {
						secret_religion = ibadi
					}
					NOT = { location = { religion = ibadi } }
					NOT = { location = { has_province_modifier = secret_ibadi_community } }
				}
				AND = {
					FROM = {
						secret_religion = kharijite
					}
					NOT = { location = { religion = kharijite } }
					NOT = { location = { has_province_modifier = secret_kharijite_community } }
				}
				AND = {
					FROM = {
						secret_religion = shiite
					}
					NOT = { location = { religion = shiite } }
					NOT = { location = { has_province_modifier = secret_shiite_community } }
				}
				AND = {
					FROM = {
						secret_religion = bektashi
					}
					NOT = { location = { religion = bektashi } }
					NOT = { location = { has_province_modifier = secret_bektashi_community } }
				}
				AND = {
					FROM = {
						secret_religion = druze
					}
					NOT = { location = { religion = druze } }
					NOT = { location = { has_province_modifier = secret_druze_community } }
				}
				AND = {
					FROM = {
						secret_religion = hurufi
					}
					NOT = { location = { religion = hurufi } }
					NOT = { location = { has_province_modifier = secret_hurufi_community } }
				}
				AND = {
					FROM = {
						secret_religion = qarmatian
					}
					NOT = { location = { religion = qarmatian } }
					NOT = { location = { has_province_modifier = secret_qarmatian_community } }
				}
				AND = {
					FROM = {
						secret_religion = aztec
					}
					NOT = { location = { religion = aztec } }
					NOT = { location = { has_province_modifier = secret_aztec_community } }
				}
				AND = {
					FROM = {
						secret_religion = jewish
					}
					NOT = { location = { religion = jewish } }
					NOT = { location = { has_province_modifier = secret_jewish_community } }
				}
				AND = {
					FROM = {
						secret_religion = samaritan
					}
					NOT = { location = { religion = samaritan } }
					NOT = { location = { has_province_modifier = secret_samaritan_community } }
				}
				AND = {
					FROM = {
						secret_religion = karaite
					}
					NOT = { location = { religion = karaite } }
					NOT = { location = { has_province_modifier = secret_karaite_community } }
				}
				AND = {
					FROM = {
						secret_religion = zoroastrian
					}
					NOT = { location = { religion = zoroastrian } }
					NOT = { location = { has_province_modifier = secret_zoroastrian_community } }
				}
				AND = {
					FROM = {
						secret_religion = zurvanist
					}
					NOT = { location = { religion = zurvanist } }
					NOT = { location = { has_province_modifier = secret_zurvanist_community } }
				}
				AND = {
					FROM = {
						secret_religion = mazdaki
					}
					NOT = { location = { religion = mazdaki } }
					NOT = { location = { has_province_modifier = secret_mazdaki_community } }
				}
				AND = {
					FROM = {
						secret_religion = manichean
					}
					NOT = { location = { religion = manichean } }
					NOT = { location = { has_province_modifier = secret_manichean_community } }
				}
				AND = {
					FROM = {
						secret_religion = mandaean
					}
					NOT = { location = { religion = mandaean } }
					NOT = { location = { has_province_modifier = secret_mandaean_community } }
				}
				AND = {
					FROM = {
						secret_religion = khurmazta
					}
					NOT = { location = { religion = khurmazta } }
					NOT = { location = { has_province_modifier = secret_khurmazta_community } }
				}
				AND = {
					FROM = {
						secret_religion = bon
					}
					NOT = { location = { religion = bon } }
					NOT = { location = { has_province_modifier = secret_bon_community } }
				}
				AND = {
					FROM = {
						secret_religion = taoist
					}
					NOT = { location = { religion = taoist } }
					NOT = { location = { has_province_modifier = secret_taoist_community } }
				}
				AND = {
					FROM = {
						secret_religion = tibetan_pagan
					}
					NOT = { location = { religion = tibetan_pagan } }
					NOT = { location = { has_province_modifier = secret_tibetan_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = hindu
					}
					NOT = { location = { religion = hindu } }
					NOT = { location = { has_province_modifier = secret_hindu_community } }
				}
				AND = {
					FROM = {
						secret_religion = buddhist
					}
					NOT = { location = { religion = buddhist } }
					NOT = { location = { has_province_modifier = secret_buddhist_community } }
				}
				AND = {
					FROM = {
						secret_religion = jain
					}
					NOT = { location = { religion = jain } }
					NOT = { location = { has_province_modifier = secret_jain_community } }
				}
				AND = {
					FROM = {
						secret_religion = norse_pagan_reformed
					}
					NOT = { location = { religion = norse_pagan_reformed } }
					NOT = { location = { has_province_modifier = secret_norse_pagan_reformed_community } }
				}
				AND = {
					FROM = {
						secret_religion = norse_pagan
					}
					NOT = { location = { religion = norse_pagan } }
					NOT = { location = { has_province_modifier = secret_norse_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = german_pagan
					}
					NOT = { location = { religion = german_pagan } }
					NOT = { location = { has_province_modifier = secret_german_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = german_pagan_reformed
					}
					NOT = { location = { religion = german_pagan_reformed } }
					NOT = { location = { has_province_modifier = secret_german_pagan_reformed_community } }
				}
				AND = {
					FROM = {
						secret_religion = celtic_pagan
					}
					NOT = { location = { religion = celtic_pagan } }
					NOT = { location = { has_province_modifier = secret_celtic_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = celtic_pagan_reformed
					}
					NOT = { location = { religion = celtic_pagan_reformed } }
					NOT = { location = { has_province_modifier = secret_celtic_pagan_reformed_community } }
				}
				AND = {
					FROM = {
						secret_religion = slavic_pagan_reformed
					}
					NOT = { location = { religion = slavic_pagan_reformed } }
					NOT = { location = { has_province_modifier = secret_slavic_pagan_reformed_community } }
				}
				AND = {
					FROM = {
						secret_religion = slavic_pagan
					}
					NOT = { location = { religion = slavic_pagan } }
					NOT = { location = { has_province_modifier = secret_slavic_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = tengri_pagan_reformed
					}
					NOT = { location = { religion = tengri_pagan_reformed } }
					NOT = { location = { has_province_modifier = secret_tengri_pagan_reformed_community } }
				}
				AND = {
					FROM = {
						secret_religion = tengri_pagan
					}
					NOT = { location = { religion = tengri_pagan } }
					NOT = { location = { has_province_modifier = secret_tengri_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = baltic_pagan_reformed
					}
					NOT = { location = { religion = baltic_pagan_reformed } }
					NOT = { location = { has_province_modifier = secret_baltic_pagan_reformed_community } }
				}
				AND = {
					FROM = {
						secret_religion = baltic_pagan
					}
					NOT = { location = { religion = baltic_pagan } }
					NOT = { location = { has_province_modifier = secret_baltic_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = finnish_pagan_reformed
					}
					NOT = { location = { religion = finnish_pagan_reformed } }
					NOT = { location = { has_province_modifier = secret_finnish_pagan_reformed_community } }
				}
				AND = {
					FROM = {
						secret_religion = finnish_pagan
					}
					NOT = { location = { religion = finnish_pagan } }
					NOT = { location = { has_province_modifier = secret_finnish_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = west_african_pagan_reformed
					}
					NOT = { location = { religion = west_african_pagan_reformed } }
					NOT = { location = { has_province_modifier = secret_west_african_pagan_reformed_community } }
				}
				AND = {
					FROM = {
						secret_religion = west_african_pagan
					}
					NOT = { location = { religion = west_african_pagan } }
					NOT = { location = { has_province_modifier = secret_west_african_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = zun_pagan_reformed
					}
					NOT = { location = { religion = zun_pagan_reformed } }
					NOT = { location = { has_province_modifier = secret_zun_pagan_reformed_community } }
				}
				AND = {
					FROM = {
						secret_religion = zun_pagan
					}
					NOT = { location = { religion = zun_pagan } }
					NOT = { location = { has_province_modifier = secret_zun_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = roman_pagan
					}
					NOT = { location = { religion = roman_pagan } }
					NOT = { location = { has_province_modifier = secret_roman_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = egyptian_pagan
					}
					NOT = { location = { religion = egyptian_pagan } }
					NOT = { location = { has_province_modifier = secret_egyptian_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = promethean_pagan
					}
					NOT = { location = { religion = promethean_pagan } }
					NOT = { location = { has_province_modifier = secret_promethean_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = aten_pagan
					}
					NOT = { location = { religion = aten_pagan } }
					NOT = { location = { has_province_modifier = secret_aten_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = arab_pagan
					}
					NOT = { location = { religion = arab_pagan } }
					NOT = { location = { has_province_modifier = secret_arab_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = berber_pagan
					}
					NOT = { location = { religion = berber_pagan } }
					NOT = { location = { has_province_modifier = secret_berber_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = jewish_pagan
					}
					NOT = { location = { religion = jewish_pagan } }
					NOT = { location = { has_province_modifier = secret_jewish_pagan_community } }
				}
				AND = {
					FROM = {
						secret_religion = hellenic_pagan
					}
					NOT = { location = { religion = hellenic_pagan } }
					NOT = { location = { has_province_modifier = secret_hellenic_pagan_community } }
				}
			}
			location = {
				OR = {
					is_capital = yes
					OR = {
						AND = {
							FROM = { secret_religion = catholic }
							ROOT = { is_holy_site = catholic }
						}
						AND = {
							FROM = { secret_religion = chalcedonian }
							ROOT = { is_holy_site = chalcedonian }
						}
						AND = {
							FROM = { secret_religion = cathar }
							ROOT = { is_holy_site = cathar }
						}
						AND = {
							FROM = { secret_religion = catholic }
							ROOT = { is_holy_site = catholic }
						}
						AND = {
							FROM = { secret_religion = fraticelli }
							ROOT = { is_holy_site = fraticelli }
						}
						AND = {
							FROM = { secret_religion = waldensian }
							ROOT = { is_holy_site = waldensian }
						}
						AND = {
							FROM = { secret_religion = lollard }
							ROOT = { is_holy_site = lollard }
						}
						AND = {
							FROM = { secret_religion = adoptionist }
							ROOT = { is_holy_site = adoptionist }
						}
						AND = {
							FROM = { secret_religion = orthodox }
							ROOT = { is_holy_site = orthodox }
						}
						AND = {
							FROM = { secret_religion = miaphysite }
							ROOT = { is_holy_site = miaphysite }
						}
						AND = {
							FROM = { secret_religion = monophysite }
							ROOT = { is_holy_site = monophysite }
						}
						AND = {
							FROM = { secret_religion = bogomilist }
							ROOT = { is_holy_site = bogomilist }
						}
						AND = {
							FROM = { secret_religion = monothelite }
							ROOT = { is_holy_site = monothelite }
						}
						AND = {
							FROM = { secret_religion = iconoclast }
							ROOT = { is_holy_site = iconoclast }
						}
						AND = {
							FROM = { secret_religion = paulician }
							ROOT = { is_holy_site = paulician }
						}
						AND = {
							FROM = { secret_religion = apostolic }
							ROOT = { is_holy_site = apostolic }
						}
						AND = {
							FROM = { secret_religion = tondrakian }
							ROOT = { is_holy_site = tondrakian }
						}
						AND = {
							FROM = { secret_religion = nestorian }
							ROOT = { is_holy_site = nestorian }
						}
						AND = {
							FROM = { secret_religion = messalian }
							ROOT = { is_holy_site = messalian }
						}
						AND = {
							FROM = { secret_religion = sunni }
							ROOT = { is_holy_site = sunni }
						}
						AND = {
							FROM = { secret_religion = zikri }
							ROOT = { is_holy_site = zikri }
						}
						AND = {
							FROM = { secret_religion = quranist }
							ROOT = { is_holy_site = quranist }
						}
						AND = {
							FROM = { secret_religion = yazidi }
							ROOT = { is_holy_site = yazidi }
						}
						AND = {
							FROM = { secret_religion = ibadi }
							ROOT = { is_holy_site = ibadi }
						}
						AND = {
							FROM = { secret_religion = kharijite }
							ROOT = { is_holy_site = kharijite }
						}
						AND = {
							FROM = { secret_religion = shiite }
							ROOT = { is_holy_site = shiite }
						}
						AND = {
							FROM = { secret_religion = bektashi }
							ROOT = { is_holy_site = bektashi }
						}
						AND = {
							FROM = { secret_religion = druze }
							ROOT = { is_holy_site = druze }
						}
						AND = {
							FROM = { secret_religion = hurufi }
							ROOT = { is_holy_site = hurufi }
						}
						AND = {
							FROM = { secret_religion = qarmatian }
							ROOT = { is_holy_site = qarmatian }
						}
						AND = {
							FROM = { secret_religion = jewish }
							ROOT = { is_holy_site = jewish }
						}
						AND = {
							FROM = { secret_religion = samaritan }
							ROOT = { is_holy_site = samaritan }
						}
						AND = {
							FROM = { secret_religion = karaite }
							ROOT = { is_holy_site = karaite }
						}
						AND = {
							FROM = { secret_religion = zoroastrian }
							ROOT = { is_holy_site = zoroastrian }
						}
						AND = {
							FROM = { secret_religion = zurvanist }
							ROOT = { is_holy_site = zurvanist }
						}
						AND = {
							FROM = { secret_religion = mazdaki }
							ROOT = { is_holy_site = mazdaki }
						}
						AND = {
							FROM = { secret_religion = manichean }
							ROOT = { is_holy_site = manichean }
						}
						AND = {
							FROM = { secret_religion = mandaean }
							ROOT = { is_holy_site = mandaean }
						}
						AND = {
							FROM = { secret_religion = hindu }
							ROOT = { is_holy_site = hindu }
						}
						AND = {
							FROM = { secret_religion = buddhist }
							ROOT = { is_holy_site = buddhist }
						}
						AND = {
							FROM = { secret_religion = jain }
							ROOT = { is_holy_site = jain }
						}
						AND = {
							FROM = { secret_religion = taoist }
							ROOT = { is_holy_site = taoist }
						}
						AND = {
							FROM = { secret_religion = khurmazta }
							ROOT = { is_holy_site = khurmazta }
						}
						AND = {
							FROM = { secret_religion = bon }
							ROOT = { is_holy_site = bon }
						}
						AND = {
							FROM = { secret_religion = tibetan_pagan }
							ROOT = { is_holy_site = tibetan_pagan }
						}
						AND = {
							FROM = { secret_religion = norse_pagan_reformed }
							ROOT = { is_holy_site = norse_pagan_reformed }
						}
						AND = {
							FROM = { secret_religion = norse_pagan }
							ROOT = { is_holy_site = norse_pagan }
						}
						AND = {
							FROM = { secret_religion = german_pagan_reformed }
							ROOT = { is_holy_site = german_pagan_reformed }
						}
						AND = {
							FROM = { secret_religion = german_pagan }
							ROOT = { is_holy_site = german_pagan }
						}
						AND = {
							FROM = { secret_religion = baltic_pagan_reformed }
							ROOT = { is_holy_site = baltic_pagan_reformed }
						}
						AND = {
							FROM = { secret_religion = baltic_pagan }
							ROOT = { is_holy_site = baltic_pagan }
						}
						AND = {
							FROM = { secret_religion = celtic_pagan_reformed }
							ROOT = { is_holy_site = celtic_pagan_reformed }
						}
						AND = {
							FROM = { secret_religion = celtic_pagan }
							ROOT = { is_holy_site = celtic_pagan }
						}
						AND = {
							FROM = { secret_religion = slavic_pagan_reformed }
							ROOT = { is_holy_site = slavic_pagan_reformed }
						}
						AND = {
							FROM = { secret_religion = slavic_pagan }
							ROOT = { is_holy_site = slavic_pagan }
						}
						AND = {
							FROM = { secret_religion = tengri_pagan_reformed }
							ROOT = { is_holy_site = tengri_pagan_reformed }
						}
						AND = {
							FROM = { secret_religion = tengri_pagan }
							ROOT = { is_holy_site = tengri_pagan }
						}
						AND = {
							FROM = { secret_religion = finnish_pagan_reformed }
							ROOT = { is_holy_site = finnish_pagan_reformed }
						}
						AND = {
							FROM = { secret_religion = finnish_pagan }
							ROOT = { is_holy_site = finnish_pagan }
						}
						AND = {
							FROM = { secret_religion = west_african_pagan_reformed }
							ROOT = { is_holy_site = west_african_pagan_reformed }
						}
						AND = {
							FROM = { secret_religion = west_african_pagan }
							ROOT = { is_holy_site = west_african_pagan }
						}
						AND = {
							FROM = { secret_religion = zun_pagan_reformed }
							ROOT = { is_holy_site = zun_pagan_reformed }
						}
						AND = {
							FROM = { secret_religion = zun_pagan }
							ROOT = { is_holy_site = zun_pagan }
						}
						AND = {
							FROM = { secret_religion = roman_pagan }
							ROOT = { is_holy_site = roman_pagan }
						}
						AND = {
							FROM = { secret_religion = promethean_pagan }
							ROOT = { is_holy_site = promethean_pagan }
						}
						AND = {
							FROM = { secret_religion = egyptian_pagan }
							ROOT = { is_holy_site = egyptian_pagan }
						}
						AND = {
							FROM = { secret_religion = aten_pagan }
							ROOT = { is_holy_site = aten_pagan }
						}
						AND = {
							FROM = { secret_religion = arab_pagan }
							ROOT = { is_holy_site = arab_pagan }
						}
						AND = {
							FROM = { secret_religion = berber_pagan }
							ROOT = { is_holy_site = berber_pagan }
						}
						AND = {
							FROM = { secret_religion = jewish_pagan }
							ROOT = { is_holy_site = jewish_pagan }
						}
						AND = {
							FROM = { secret_religion = aztec }
							ROOT = { is_holy_site = aztec }
						}
						AND = {
							FROM = { secret_religion = hellenic_pagan }
							ROOT = { is_holy_site = hellenic_pagan }
						}
					}
					any_neighbor_province = {
						OR = {
							AND = {
								FROM = {
									secret_religion = catholic
								}
								OR = {
									religion = catholic
									has_province_modifier = secret_catholic_community
								}
							}
							AND = {
								FROM = {
									secret_religion = chalcedonian
								}
								OR = {
									religion = chalcedonian
									has_province_modifier = secret_chalcedonian_community
								}
							}
							AND = {
								FROM = {
									secret_religion = cathar
								}
								OR = {
									religion = cathar
									has_province_modifier = secret_cathar_community
								}
							}
							AND = {
								FROM = {
									secret_religion = fraticelli
								}
								OR = {
									religion = fraticelli
									has_province_modifier = secret_fraticelli_community
								}
							}
							AND = {
								FROM = {
									secret_religion = waldensian
								}
								OR = {
									religion = waldensian
									has_province_modifier = secret_waldensian_community
								}
							}
							AND = {
								FROM = {
									secret_religion = lollard
								}
								OR = {
									religion = lollard
									has_province_modifier = secret_lollard_community
								}
							}
							AND = {
								FROM = {
									secret_religion = adoptionist
								}
								OR = {
									religion = adoptionist
									has_province_modifier = secret_adoptionist_community
								}
							}
							AND = {
								FROM = {
									secret_religion = orthodox
								}
								OR = {
									religion = orthodox
									has_province_modifier = secret_orthodox_community
								}
							}
							AND = {
								FROM = {
									secret_religion = miaphysite
								}
								OR = {
									religion = miaphysite
									has_province_modifier = secret_miaphysite_community
								}
							}
							AND = {
								FROM = {
									secret_religion = monophysite
								}
								OR = {
									religion = monophysite
									has_province_modifier = secret_monophysite_community
								}
							}
							AND = {
								FROM = {
									secret_religion = bogomilist
								}
								OR = {
									religion = bogomilist
									has_province_modifier = secret_bogomilist_community
								}
							}
							AND = {
								FROM = {
									secret_religion = monothelite
								}
								OR = {
									religion = monothelite
									has_province_modifier = secret_monothelite_community
								}
							}
							AND = {
								FROM = {
									secret_religion = iconoclast
								}
								OR = {
									religion = iconoclast
									has_province_modifier = secret_iconoclast_community
								}
							}
							AND = {
								FROM = {
									secret_religion = paulician
								}
								OR = {
									religion = paulician
									has_province_modifier = secret_paulician_community
								}
							}
							AND = {
								FROM = {
									secret_religion = apostolic
								}
								OR = {
									religion = apostolic
									has_province_modifier = secret_apostolic_community
								}
							}
							AND = {
								FROM = {
									secret_religion = tondrakian
								}
								OR = {
									religion = tondrakian
									has_province_modifier = secret_tondrakian_community
								}
							}
							AND = {
								FROM = {
									secret_religion = nestorian
								}
								OR = {
									religion = nestorian
									has_province_modifier = secret_nestorian_community
								}
							}
							AND = {
								FROM = {
									secret_religion = messalian
								}
								OR = {
									religion = messalian
									has_province_modifier = secret_messalian_community
								}
							}
							AND = {
								FROM = {
									secret_religion = sunni
								}
								OR = {
									religion = sunni
									has_province_modifier = secret_sunni_community
								}
							}
							AND = {
								FROM = {
									secret_religion = zikri
								}
								OR = {
									religion = zikri
									has_province_modifier = secret_zikri_community
								}
							}
							AND = {
								FROM = {
									secret_religion = quranist
								}
								OR = {
									religion = quranist
									has_province_modifier = secret_quranist_community
								}
							}
							AND = {
								FROM = {
									secret_religion = yazidi
								}
								OR = {
									religion = yazidi
									has_province_modifier = secret_yazidi_community
								}
							}
							AND = {
								FROM = {
									secret_religion = ibadi
								}
								OR = {
									religion = ibadi
									has_province_modifier = secret_ibadi_community
								}
							}
							AND = {
								FROM = {
									secret_religion = kharijite
								}
								OR = {
									religion = kharijite
									has_province_modifier = secret_kharijite_community
								}
							}
							AND = {
								FROM = {
									secret_religion = shiite
								}
								OR = {
									religion = shiite
									has_province_modifier = secret_shiite_community
								}
							}
							AND = {
								FROM = {
									secret_religion = bektashi
								}
								OR = {
									religion = bektashi
									has_province_modifier = secret_bektashi_community
								}
							}
							AND = {
								FROM = {
									secret_religion = druze
								}
								OR = {
									religion = druze
									has_province_modifier = secret_druze_community
								}
							}
							AND = {
								FROM = {
									secret_religion = hurufi
								}
								OR = {
									religion = hurufi
									has_province_modifier = secret_hurufi_community
								}
							}
							AND = {
								FROM = {
									secret_religion = qarmatian
								}
								OR = {
									religion = qarmatian
									has_province_modifier = secret_qarmatian_community
								}
							}
							AND = {
								FROM = {
									secret_religion = aztec
								}
								OR = {
									religion = aztec
									has_province_modifier = secret_aztec_community
								}
							}
							AND = {
								FROM = {
									secret_religion = jewish
								}
								OR = {
									religion = jewish
									has_province_modifier = secret_jewish_community
								}
							}
							AND = {
								FROM = {
									secret_religion = samaritan
								}
								OR = {
									religion = samaritan
									has_province_modifier = secret_samaritan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = karaite
								}
								OR = {
									religion = karaite
									has_province_modifier = secret_karaite_community
								}
							}
							AND = {
								FROM = {
									secret_religion = zoroastrian
								}
								OR = {
									religion = zoroastrian
									has_province_modifier = secret_zoroastrian_community
								}
							}
							AND = {
								FROM = {
									secret_religion = zurvanist
								}
								OR = {
									religion = zurvanist
									has_province_modifier = secret_zurvanist_community
								}
							}
							AND = {
								FROM = {
									secret_religion = mazdaki
								}
								OR = {
									religion = mazdaki
									has_province_modifier = secret_mazdaki_community
								}
							}
							AND = {
								FROM = {
									secret_religion = manichean
								}
								OR = {
									religion = manichean
									has_province_modifier = secret_manichean_community
								}
							}
							AND = {
								FROM = {
									secret_religion = mandaean
								}
								OR = {
									religion = mandaean
									has_province_modifier = secret_mandaean_community
								}
							}
							AND = {
								FROM = {
									secret_religion = hindu
								}
								OR = {
									religion = hindu
									has_province_modifier = secret_hindu_community
								}
							}
							AND = {
								FROM = {
									secret_religion = buddhist
								}
								OR = {
									religion = buddhist
									has_province_modifier = secret_buddhist_community
								}
							}
							AND = {
								FROM = {
									secret_religion = jain
								}
								OR = {
									religion = jain
									has_province_modifier = secret_jain_community
								}
							}
							AND = {
								FROM = {
									secret_religion = taoist
								}
								OR = {
									religion = taoist
									has_province_modifier = secret_taoist_community
								}
							}
							AND = {
								FROM = {
									secret_religion = kharijite
								}
								OR = {
									religion = kharijite
									has_province_modifier = secret_kharijite_community
								}
							}
							AND = {
								FROM = {
									secret_religion = bon
								}
								OR = {
									religion = bon
									has_province_modifier = secret_bon_community
								}
							}
							AND = {
								FROM = {
									secret_religion = tibetan_pagan
								}
								OR = {
									religion = tibetan_pagan
									has_province_modifier = secret_tibetan_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = norse_pagan_reformed
								}
								OR = {
									religion = norse_pagan_reformed
									has_province_modifier = secret_norse_pagan_reformed_community
								}
							}
							AND = {
								FROM = {
									secret_religion = norse_pagan
								}
								OR = {
									religion = norse_pagan
									has_province_modifier = secret_norse_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = german_pagan
								}
								OR = {
									religion = german_pagan
									has_province_modifier = secret_german_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = german_pagan_reformed
								}
								OR = {
									religion = german_pagan_reformed
									has_province_modifier = secret_german_pagan_reformed_community
								}
							}
							AND = {
								FROM = {
									secret_religion = celtic_pagan
								}
								OR = {
									religion = celtic_pagan
									has_province_modifier = secret_celtic_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = celtic_pagan_reformed
								}
								OR = {
									religion = celtic_pagan_reformed
									has_province_modifier = secret_celtic_pagan_reformed_community
								}
							}
							AND = {
								FROM = {
									secret_religion = slavic_pagan_reformed
								}
								OR = {
									religion = slavic_pagan_reformed
									has_province_modifier = secret_slavic_pagan_reformed_community
								}
							}
							AND = {
								FROM = {
									secret_religion = slavic_pagan
								}
								OR = {
									religion = slavic_pagan
									has_province_modifier = secret_slavic_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = tengri_pagan_reformed
								}
								OR = {
									religion = tengri_pagan_reformed
									has_province_modifier = secret_tengri_pagan_reformed_community
								}
							}
							AND = {
								FROM = {
									secret_religion = tengri_pagan
								}
								OR = {
									religion = tengri_pagan
									has_province_modifier = secret_tengri_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = baltic_pagan_reformed
								}
								OR = {
									religion = baltic_pagan_reformed
									has_province_modifier = secret_baltic_pagan_reformed_community
								}
							}
							AND = {
								FROM = {
									secret_religion = baltic_pagan
								}
								OR = {
									religion = baltic_pagan
									has_province_modifier = secret_baltic_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = finnish_pagan_reformed
								}
								OR = {
									religion = finnish_pagan_reformed
									has_province_modifier = secret_finnish_pagan_reformed_community
								}
							}
							AND = {
								FROM = {
									secret_religion = finnish_pagan
								}
								OR = {
									religion = finnish_pagan
									has_province_modifier = secret_finnish_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = west_african_pagan_reformed
								}
								OR = {
									religion = west_african_pagan_reformed
									has_province_modifier = secret_west_african_pagan_reformed_community
								}
							}
							AND = {
								FROM = {
									secret_religion = west_african_pagan
								}
								OR = {
									religion = west_african_pagan
									has_province_modifier = secret_west_african_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = zun_pagan_reformed
								}
								OR = {
									religion = zun_pagan_reformed
									has_province_modifier = secret_zun_pagan_reformed_community
								}
							}
							AND = {
								FROM = {
									secret_religion = zun_pagan
								}
								OR = {
									religion = zun_pagan
									has_province_modifier = secret_zun_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = roman_pagan
								}
								OR = {
									religion = roman_pagan
									has_province_modifier = secret_roman_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = egyptian_pagan
								}
								OR = {
									religion = egyptian_pagan
									has_province_modifier = secret_egyptian_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = promethean_pagan
								}
								OR = {
									religion = promethean_pagan
									has_province_modifier = secret_promethean_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = aten_pagan
								}
								OR = {
									religion = aten_pagan
									has_province_modifier = secret_aten_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = arab_pagan
								}
								OR = {
									religion = arab_pagan
									has_province_modifier = secret_arab_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = berber_pagan
								}
								OR = {
									religion = berber_pagan
									has_province_modifier = secret_berber_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = jewish_pagan
								}
								OR = {
									religion = jewish_pagan
									has_province_modifier = secret_jewish_pagan_community
								}
							}
							AND = {
								FROM = {
									secret_religion = hellenic_pagan
								}
								OR = {
									religion = hellenic_pagan
									has_province_modifier = secret_hellenic_pagan_community
								}
							}
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
				piety = 200
			}
			custom_tooltip = {
				text = prepare_grounds_allow_tooltip
				hidden_trigger = {
					FROM = { NOT = { has_character_flag = preparing_grounds_in_province } }
				}
			}
		}
		
		effect = {
			location = {
				save_event_target_as = target_province
			}
			FROM = {
				custom_tooltip = {
					text = secret_religions_prepare_grounds_effect_tooltip
					character_event = { id = MNM.3850 days = 2 }
				}
				piety = -200
				increase_visibility_effect = yes
				set_character_flag = preparing_grounds_in_province
				character_event = { id = MNM.3849 days = 1200 }
			}
		}
		
		ai_will_do = {
			factor = 1
		}
	}
}

#########################################################################################################
################ Secret society normal decisions
#########################################################################################################
decisions = {
	secret_religions_falsely_confess_faith = {
	
		is_high_prio = yes
	
		only_playable = yes
		
		potential = {
			OR = {
				liege = {
					NOT = {
						religion = ROOT
					}
				}
				top_liege = {
					NOT = {
						religion = ROOT
					}
				}
			}
			NOT = { controls_religion = yes }
		}
		allow = {
			piety = 100
			prisoner = no
			NOT = { trait = incapable }
			NOT = { is_inaccessible_trigger = yes }
		}
		effect = {
			character_event = { id = MNM.3951 days = 1 }
			piety = -100
			religion_scope = { save_event_target_as = actual_religion }
			tooltip = {
				set_secret_religion = event_target:actual_religion # This has to actually happen after the religion is set
			}
			custom_tooltip = {
				text = confess_faith_decision_tooltip
				hidden_effect = {
					if = {
						limit = {
							liege = {
								NOT = {
									religion = ROOT
								}
							}
						}
						liege = {
							ROOT = {
								religion = PREV
								set_secret_religion = event_target:actual_religion
								break = yes
							}
						}
					}
					if = {
						limit = {
							top_liege = {
								NOT = {
									religion = ROOT
								}
							}
						}
						top_liege = {
							ROOT = {
								religion = PREV
								set_secret_religion = event_target:actual_religion
								break = yes
							}
						}
					}
				}
			}
			
		}
		
		ai_will_do = {
			factor = 0
		}
	}
}

title_decisions = {
	secretly_convert_to_province_religion = {
		filter = owned
		ai_target_filter = self
		
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = { location = { religion = FROM } }
			NOT = { location = { religion = { target_type = secret target = FROM } } }
			owner = { character = FROM }
		}
		
		allow = {
			FROM = { 
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			location = { save_event_target_as = location }
			FROM = {
				set_secret_religion = event_target:location
				piety = -250
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_catholic_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = catholic }
			NOT = { religion = catholic }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			k_papal_state =  { has_holder = yes }
			tier = COUNT
			NOT = {
				location = { religion = catholic }
			}
			OR = {
				is_holy_site = catholic
				any_de_jure_vassal_title = {
					is_holy_site = catholic
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = catholic
			}
		}
	
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_chalcedonian_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = chalcedonian }
			NOT = { religion = chalcedonian }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			k_papal_state = { has_holder = no }
			tier = COUNT
			NOT = {
				location = { religion = chalcedonian }
			}
			OR = {
				is_holy_site = chalcedonian
				any_de_jure_vassal_title = {
					is_holy_site = chalcedonian
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = chalcedonian
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_orthodox_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = orthodox }
			NOT = { religion = orthodox }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			k_papal_state =  { has_holder = yes }
			tier = COUNT
			NOT = {
				location = { religion = orthodox }
			}
			OR = {
				is_holy_site = orthodox
				any_de_jure_vassal_title = {
					is_holy_site = orthodox
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = orthodox
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_miaphysite_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = miaphysite }
			NOT = { religion = miaphysite }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = miaphysite }
			}
			OR = {
				is_holy_site = miaphysite
				any_de_jure_vassal_title = {
					is_holy_site = miaphysite
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = miaphysite
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_nestorian_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = nestorian }
			NOT = { religion = nestorian }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = nestorian }
			}
			OR = {
				is_holy_site = nestorian
				any_de_jure_vassal_title = {
					is_holy_site = nestorian
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = nestorian
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_sunni_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = sunni }
			NOT = { religion = sunni }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = sunni }
			}
			OR = {
				is_holy_site = sunni
				any_de_jure_vassal_title = {
					is_holy_site = sunni
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = sunni
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_shiite_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = shiite }
			NOT = { religion = shiite }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = shiite }
			}
			OR = {
				is_holy_site = shiite
				any_de_jure_vassal_title = {
					is_holy_site = shiite
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = shiite
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_ibadi_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = ibadi }
			NOT = { religion = ibadi }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = ibadi }
			}
			OR = {
				is_holy_site = ibadi
				any_de_jure_vassal_title = {
					is_holy_site = ibadi
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = ibadi
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_jewish_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = jewish }
			NOT = { religion = jewish }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = jewish }
			}
			OR = {
				is_holy_site = jewish
				any_de_jure_vassal_title = {
					is_holy_site = jewish
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = jewish
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_zoroastrian_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = zoroastrian }
			NOT = { religion = zoroastrian }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = zoroastrian }
			}
			OR = {
				is_holy_site = zoroastrian
				any_de_jure_vassal_title = {
					is_holy_site = zoroastrian
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = zoroastrian
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_hindu_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = hindu }
			NOT = { religion = hindu }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = hindu }
			}
			OR = {
				is_holy_site = hindu
				any_de_jure_vassal_title = {
					is_holy_site = hindu
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = hindu
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_buddhist_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = buddhist }
			NOT = { religion = buddhist }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = buddhist }
			}
			OR = {
				is_holy_site = buddhist
				any_de_jure_vassal_title = {
					is_holy_site = buddhist
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = buddhist
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_jain_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = jain }
			NOT = { religion = jain }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = jain }
			}
			OR = {
				is_holy_site = jain
				any_de_jure_vassal_title = {
					is_holy_site = jain
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = jain
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_norse_pagan_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = norse_pagan }
			NOT = { has_global_flag = norse_reformation }
			NOT = { religion = norse_pagan }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = norse_pagan }
			}
			OR = {
				is_holy_site = norse_pagan
				any_de_jure_vassal_title = {
					is_holy_site = norse_pagan
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = norse_pagan
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_norse_pagan_reformed_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = norse_pagan_reformed }
			has_global_flag = norse_reformation
			NOT = { religion = norse_pagan_reformed }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = norse_pagan_reformed }
			}
			OR = {
				is_holy_site = norse_pagan_reformed
				any_de_jure_vassal_title = {
					is_holy_site = norse_pagan_reformed
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = norse_pagan_reformed
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_slavic_pagan_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = slavic_pagan }
			NOT = { has_global_flag = slavic_reformation }
			NOT = { religion = slavic_pagan }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = slavic_pagan }
			}
			OR = {
				is_holy_site = slavic_pagan
				any_de_jure_vassal_title = {
					is_holy_site = slavic_pagan
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = slavic_pagan
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_slavic_pagan_reformed_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = slavic_pagan_reformed }
			has_global_flag = slavic_reformation
			NOT = { religion = slavic_pagan_reformed }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = slavic_pagan_reformed }
			}
			OR = {
				is_holy_site = slavic_pagan_reformed
				any_de_jure_vassal_title = {
					is_holy_site = slavic_pagan_reformed
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = slavic_pagan_reformed
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_tengri_pagan_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = tengri_pagan }
			NOT = { has_global_flag = tengri_reformation }
			NOT = { religion = tengri_pagan }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = tengri_pagan }
			}
			OR = {
				is_holy_site = tengri_pagan
				any_de_jure_vassal_title = {
					is_holy_site = tengri_pagan
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = tengri_pagan
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_tengri_pagan_reformed_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = tengri_pagan_reformed }
			has_global_flag = tengri_reformation
			NOT = { religion = tengri_pagan_reformed }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = tengri_pagan_reformed }
			}
			OR = {
				is_holy_site = tengri_pagan_reformed
				any_de_jure_vassal_title = {
					is_holy_site = tengri_pagan_reformed
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = tengri_pagan_reformed
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_baltic_pagan_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = baltic_pagan }
			NOT = { has_global_flag = baltic_reformation }
			NOT = { religion = baltic_pagan }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = baltic_pagan }
			}
			OR = {
				is_holy_site = baltic_pagan
				any_de_jure_vassal_title = {
					is_holy_site = baltic_pagan
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = baltic_pagan
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_baltic_pagan_reformed_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = baltic_pagan_reformed }
			has_global_flag = baltic_reformation
			NOT = { religion = baltic_pagan_reformed }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = baltic_pagan_reformed }
			}
			OR = {
				is_holy_site = baltic_pagan_reformed
				any_de_jure_vassal_title = {
					is_holy_site = baltic_pagan_reformed
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = baltic_pagan_reformed
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_finnish_pagan_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = finnish_pagan }
			NOT = { has_global_flag = finnish_reformation }
			NOT = { religion = finnish_pagan }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = finnish_pagan }
			}
			OR = {
				is_holy_site = finnish_pagan
				any_de_jure_vassal_title = {
					is_holy_site = finnish_pagan
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = finnish_pagan
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_finnish_pagan_reformed_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = finnish_pagan_reformed }
			has_global_flag = finnish_reformation
			NOT = { religion = finnish_pagan_reformed }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = finnish_pagan_reformed }
			}
			OR = {
				is_holy_site = finnish_pagan_reformed
				any_de_jure_vassal_title = {
					is_holy_site = finnish_pagan_reformed
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = finnish_pagan_reformed
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_west_african_pagan_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = west_african_pagan }
			NOT = { has_global_flag = west_african_reformation }
			NOT = { religion = west_african_pagan }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = west_african_pagan }
			}
			OR = {
				is_holy_site = west_african_pagan
				any_de_jure_vassal_title = {
					is_holy_site = west_african_pagan
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = west_african_pagan
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_west_african_pagan_reformed_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = west_african_pagan_reformed }
			has_global_flag = west_african_reformation
			NOT = { religion = west_african_pagan_reformed }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = west_african_pagan_reformed }
			}
			OR = {
				is_holy_site = west_african_pagan_reformed
				any_de_jure_vassal_title = {
					is_holy_site = west_african_pagan_reformed
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = west_african_pagan_reformed
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_aztec_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = aztec }
			has_global_flag = aztec_arrival
			NOT = { has_global_flag = aztec_reformation }
			NOT = { religion = aztec }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = aztec }
			}
			OR = {
				is_holy_site = aztec
				any_de_jure_vassal_title = {
					is_holy_site = aztec
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = aztec
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
		
	secretly_convert_to_zun_pagan_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = zun_pagan }
			NOT = { has_global_flag = zun_reformation }
			NOT = { religion = zun_pagan }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = zun_pagan }
			}
			OR = {
				is_holy_site = zun_pagan
				any_de_jure_vassal_title = {
					is_holy_site = zun_pagan
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = zun_pagan
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
	
	secretly_convert_to_zun_pagan_reformed_holy_site = {
		filter = owned
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { secret_religion = zun_pagan_reformed }
			has_global_flag = zun_reformation
			NOT = { religion = zun_pagan_reformed }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			tier = COUNT
			NOT = {
				location = { religion = zun_pagan_reformed }
			}
			OR = {
				is_holy_site = zun_pagan_reformed
				any_de_jure_vassal_title = {
					is_holy_site = zun_pagan_reformed
				}
			}
			OR = {
				holder_scope = {
					character = FROM
				}
				AND = {
					tier = BARON
					holder_scope = {
						liege = {
							character = FROM
						}
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = {
				piety = -250
				set_secret_religion = zun_pagan_reformed
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
}

targeted_decisions = {
	secretly_convert_to_close_relations_religion = {
		#filter
		ai_target_filter = self
	
		only_playable = yes
		
		from_potential = {
			ai = no
			NOT = { trait = incapable }
			NOT = { controls_religion = yes }
		}
		
		potential = {
			OR = {
				AND = {
					spouse = {
						character = FROM
					}
					NOR = { 
						religion = FROM
						religion = { target_type = secret target = FROM }
					}
				}
				AND = {
					consort = {
						character = FROM
					}
					NOR = { 
						religion = FROM
						religion = { target_type = secret target = FROM }
					}
				}
				AND = {
					is_friend = FROM
					NOR = { 
						religion = FROM
						religion = { target_type = secret target = FROM }
					}
				}
			}
		}
		
		allow = {
			FROM = {
				piety = 250
				prisoner = no
				NOT = { trait = incapable }
				NOT = { is_inaccessible_trigger = yes }
			}
		}
		
		effect = {
			FROM = { set_secret_religion = { target_type = public target = PREV } }
			FROM = { piety = -250 }
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
}