#Needs to be loaded after
# 	* medium_gold_value (01_dynamic_values)

#Religious war CB levels
faith_fully_accepted_level = 0
faith_astray_level = 1
faith_hostile_level = 2
faith_evil_level = 3

faith_hostility_prevents_marriage_level = faith_evil_level

religious_cb_enabled_hostility_level = faith_hostile_level
religious_cb_evil_hostility_level = faith_evil_level

religious_cb_ally_prestige_kingdom = 500
religious_cb_ally_prestige_duchy = 200
religious_cb_ally_prestige_county = 100

religious_cb_piety_gain_evil_foe = 200
religious_cb_piety_gain_empire = 200
religious_cb_piety_loss_empire = -200
religious_cb_piety_gain_kingdom = 150
religious_cb_piety_loss_kingdom = -150
religious_cb_piety_gain_duchy = 100
religious_cb_piety_loss_duchy = -100
religious_cb_piety_gain_county = 50
religious_cb_piety_loss_county = -50
religious_cb_piety_white_peace = -50

excommunication_cb_piety_change_multiplier = 4
excommunication_cb_piety_white_peace = -50

religious_cb_piety_discount_against_hof_humsac = 0.5
hof_humsacd_fervour_gain = major_fervor_value

faith_doctrine_cost_low = 200
faith_doctrine_cost_mid = 400
faith_doctrine_cost_high = 600
faith_doctrine_cost_massive = 1000

faith_tenet_cost_discount_scholar_official_tradition = 0
faith_tenet_cost_low = 500
faith_tenet_cost_mid = 1000
faith_tenet_cost_high = 1500
faith_tenet_cost_massive = 2000

faith_unchanged_doctrine_cost_mult = 0.5
faith_unchanged_tolerance_doctrine_cost_mult = 0.5
faith_changed_doctrine_cost_mult_two_step = 1.50
faith_changed_doctrine_cost_mult_three_step = 2.25
faith_changed_doctrine_cost_mult_four_step = 3.50

faith_tenet_discount_mountain_background_value = 0.75

hostility_multiplier_pluralism = 0.5
hostility_multiplier_righteous = 1
hostility_multiplier_fundamentalist = 2
hostility_multiplier_reduction_adaptive = -0.25

heretical_defector_fervor_gain = 15 # How much fervor Old Faith gains when a ruler splits off to a New Heresy

regional_heresy_factor = {
	if = {
		limit = { has_game_rule = default_regional_heresy }
		value = 5
	}
	else_if = {
		limit = { has_game_rule = strict_regional_heresy }
		value = 200
	}
	else = {
		value = 1
	}
}

meditation_duration = 185 # In days

local_shrine_duration = 14

faction_county_opinion_astray = {
	value = county_opinion
	multiply = -1.0
}
faction_county_opinion_hostile = {
	value = county_opinion
	multiply = -2.5
}
faction_county_opinion_evil = {
	value = county_opinion
	multiply = -5.0
}

head_of_faith_selection_weight = {
	value = 1

	# Strong weight for preferred gender
	if = {
		limit = {
			faith = { has_doctrine = doctrine_gender_male_dominated }
			is_male = yes
		}
		add = 50
	}
	else_if = {
		limit = {
			faith = { has_doctrine = doctrine_gender_female_dominated }
			is_female = yes
		}
		add = 50
	}

	# Bonus for holding land, especially if it is a holy site.
	if = {
		limit = {
			any_sub_realm_barony = {
				is_holy_site_of = root.faith
			}
		}
		add = 40
	}
	add = {
		value = highest_held_title_tier
		multiply = 20
	}

	# Bonus for piousness/learnedness
	add = {
		value = num_virtuous_traits
		multiply = 30
	}
	add = {
		value = num_sinful_traits
		multiply = -30
	}
	add = {
		value = piety_level
		multiply = 10
	}
	add = {
		value = learning
		multiply = 2
	}
	add = {
		value = diplomacy
		multiply = 1
	}	
}
################
# Demand Conversion chance calculation
################

#Calculated in scope:recipient
demand_conversion_learning_difference = {
	add = scope:actor.learning
	subtract = learning
	multiply = 5
}

demand_conversion_fervor_difference = {
	add = scope:actor.faith.fervor
	subtract = faith.fervor
}

demand_conversion_tenet_impact = {
	value = 0
	if = {
		limit = {
			faith = {
				has_doctrine_parameter = sanctioned_false_conversion
				NOT = { has_doctrine_parameter = unattractive_for_character_conversions }
			}
		}
		add = -20
	}
	if = {
		limit = {
			faith = { has_doctrine_parameter = tenet_adaptive_conversion_resistance }
		}
		add = -20
	}
	if = {
		limit = {
			faith = { has_doctrine_parameter = unattractive_for_character_conversions }
		}
		add = 20
	}
}

demand_conversion_likelihood_calculation = {
	#Five times actor's-recipient's learning
	add = demand_conversion_learning_difference

	#Calculate each faith's fervor
	add = demand_conversion_fervor_difference

	#Calculate various Doctrines and Tenets
	add = demand_conversion_tenet_impact

	if = {
		limit = {
			opinion = {
				target = scope:actor
				value < medium_negative_opinion
			}
		}
		add = -50
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:actor
				value < neutral_opinion
			}
		}
		add = -25
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:actor
				value >= medium_positive_opinion
			}
		}
		add = 50
	}
	else_if = {
		limit = {
			opinion = {
				target = scope:actor
				value > neutral_opinion
			}
		}
		add = 25
	}

	if = {
		limit = {
			scope:actor = { has_trait = savior }
		}
		add = 30
	}
	if = {
		limit = {
			scope:actor = { has_trait = divine_blood }
		}
		add = 15
	}
	
	if = {
		limit = {
			has_trait = zealous
		}
		add = -50
	}
	if = {
		limit = {
			has_trait = cynical
		}
		add = 30
	}

	if = {
		limit = {
			has_trait = heresiarch
		}
		add = -100
	}

	#Add value if refusing is a Crime
	if = {
		limit = {
			scope:actor = {
				refusing_conversion_is_crime_trigger = {
					CHARACTER = scope:recipient
				}
			}
		}
		add = 50
	}
	
	
		
	if = {
		limit = {
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 1
				}
			}
		}
		add = 10
	}
	if = {
		limit = {
			scope:recipient = {
				has_dread_level_towards = {
					target = scope:actor
					level = 2
				}
			}
		}
		add = 20
	}

	max = 100
}

demand_conversion_bribe_size = {
	value = medium_gold_value
}

demand_conversion_piety_cost = {
	value = medium_piety_value
}


#Religious Legal Pronouncement requirements
religious_legal_pronouncement_target_value = -20

religious_legal_pronouncement_sinful_value = {
	value = 0
	add = scope:recipient.num_sinful_traits
	multiply = 6
}

religious_legal_pronouncement_virtuous_value = {
	value = 0
	add = scope:recipient.num_virtuous_traits
	multiply = 5
}

religious_legal_pronouncement_requirements = {
	value = religious_legal_pronouncement_target_value
	add = religious_legal_pronouncement_sinful_value
	subtract = religious_legal_pronouncement_virtuous_value
	add = scope:actor.learning
}

religious_legal_pronouncement_learning_requirement = {
	value = 0
	subtract = religious_legal_pronouncement_sinful_value
	add = religious_legal_pronouncement_virtuous_value
	subtract = religious_legal_pronouncement_target_value
	min = 1
}

claim_piety_value = {
	value = {
		add = minor_piety_value
		multiply = 2
		if = {
			limit = {
				scope:target = {
					tier = tier_duchy
				}
			}
			multiply = 2
		}
		if = {
			limit = {
				scope:target = {
					tier = tier_kingdom
				}
			}
			multiply = 4
		}
		if = {
			limit = {
				scope:target = {
					tier = tier_empire
				}
			}
			multiply = 8
		}
		add = {
			value = scope:actor.sub_realm_size
			multiply = 10
		}
		# Landless adventurers can't get cheap access to legitimists without putting in some leg-work.
		if = {
			limit = {
				scope:actor = { has_government = landless_adventurer_government }
			}
			multiply = 10
		}
	}
}

#GHW Targeting Multipliers
#Up the base size of kingdoms with an existing same-faith ruler a bit:
ghw_target_existing_same_faith_ruler = 20
#Prioritise reclaiming lands that are core rather than just new large kingdoms:
ghw_target_heartlands = 150
ghw_target_frontier = 25
ghw_target_fringe = 15
ghw_target_stretch = 10
#Always buff any kingdom containing an uncontrolled holy site:
ghw_target_has_holy_site = 6
#Targets that should always be priorities if not controlled:
ghw_target_jerusalem = 200
ghw_target_key_religious_holding = 100
ghw_target_religious_vengeance = 150
#Distance modifiers stack:
ghw_target_distance_01_reduction = 0.8
ghw_target_distance_02_reduction = 0.1
ghw_target_distance_03_reduction = 0.01
ghw_target_distance_01_threshold = 722500
ghw_target_distance_02_threshold = 1445000
ghw_target_distance_03_threshold = 2167500

# Referenced by code when building list of ghw targets
# Logic reworked by Ewan Cowhig Croft
great_holy_war_target_kingdom_weight = {
	# WEIGHTING PROCESS
	# 1. Check how many individual counties within a de jure kingdom have a top-liege with an eligible faith for GHWing. Boost the count a little for kingdoms with existing same-faith monarchs.
	# 2. Modify the count by region location & relative importance to the Faith (is this kingdom in the heartlands of the faith, or one of an increasing gradiant of frontier regions?).
	# 3. Modify the count by region distance from the HoF's capital, or a fallback holy site.
	# 4. Weight up kingdoms containing holy sites directly.
	# 5. Weight up special priority targets (e.g., Jerusalem, Mecca) directly.

	### 1 ###
	# Is the target kingdom a viable GHW target?
	every_in_de_jure_hierarchy = {
		# Check individual counties within the potential target de jure kingdom.
		continue = { tier > tier_county }
		# For every county with a GHWable liege...
		limit = {
			tier = tier_county
			scope:the_faith = {
				is_hostile_enough_for_holy_war_trigger = { FAITH = prev.holder.top_liege.faith }
			}
		}
		# ... Add 1 to the weighting.
		add = 1
	}
	# Weight up the kingdom if it either has an existing same-faith holder, or at least a same-faith claimant.
	if = {
		limit = {
			OR = {
				AND = {
					exists = holder
					holder.faith = scope:the_faith
				}
				any_claimant = {
					exists = this
					faith = scope:the_faith
					is_available_adult = yes
				}
			}
		}
		add = ghw_target_existing_same_faith_ruler
	}
	
	### 2 ###
	### Abrahamics & Zoroastrians
	# Documentation = {
		# Avoid adding lots of reckless GHW stretch goals, as it'll mess up the targeting if every religion has a dozen apiece.

		# Below is an organised, prioritised list of the different target regions for each religion. Update it as you make changes.
		# Christianity
		# ghw_region_northern_italy					# heartlands
		# ghw_region_thessalonika					# heartlands
		# ghw_region_ethiopia						# heartlands
		# ghw_region_france							# heartlands
		# ghw_region_germany						# heartlands
		# ghw_region_greece							# heartlands
		# ghw_region_england						# heartlands
		# ghw_region_caucasus						# heartlands
		# ghw_region_anatolia						# frontier
		# ghw_region_near_east						# frontier
		# ghw_region_mediterranean					# frontier
		# ghw_region_balkans						# frontier
		# ghw_region_holy_land						# frontier
		# ghw_region_iberia							# frontier
		# ghw_region_celtic							# fringe
		# ghw_region_germanic						# fringe
		# ghw_region_central_european				# fringe
		# ghw_region_baltic							# stretch
		
		# Islam
		# ghw_region_holy_land						# heartlands
		# ghw_region_arabia							# heartlands
		# ghw_region_near_east						# heartlands
		# ghw_region_egypt							# heartlands
		# ghw_region_persia							# heartlands
		# ghw_region_north_africa					# heartlands
		# ghw_region_sicily							# frontier
		# ghw_region_iberia							# frontier
		# ghw_region_anatolia						# frontier
		# ghw_region_afghanistan					# frontier
		# ghw_region_the_sahel						# fringe
		# ghw_region_mediterranean					# fringe
		# ghw_region_western_india					# fringe
		# ghw_region_southern_france				# fringe

		# Yazidism
		# ghw_region_kurdistan						# heartlands
		# ghw_region_southern_middle_east			# frontier
		# ghw_region_eastern_middle_east			# frontier
		# ghw_region_caucasus						# frontier
		# ghw_region_caspian_steppe					# fringe
		# ghw_region_arabia							# fringe
		# ghw_region_holy_land						# fringe

		# Judaism
		# ghw_region_holy_land						# heartlands
		# ghw_region_arabia							# frontier
		# ghw_region_near_east						# frontier
		# ghw_region_egypt							# frontier
		# ghw_region_anatolia						# fringe
		# ghw_region_persia							# fringe
		# ghw_region_ethiopia						# fringe

		# Zoroastrianism/Dualism
		# ghw_region_persia							# heartlands
		# ghw_region_afghanistan					# frontier
		# ghw_region_near_east						# frontier
		# ghw_region_arabia							# fringe
		# ghw_region_holy_land						# fringe
		# ghw_region_anatolia						# fringe
		# ghw_region_mongolia						# fringe
		# ghw_region_western_india					# fringe

		# Norse Paganism
		# ghw_region_scandinavia					# heartlands
		# ghw_region_britannia						# frontier
		# ghw_region_saxony							# frontier
		# ghw_region_russia							# frontier
		# ghw_region_baltic							# fringe
		# ghw_region_poland							# fringe
		# ghw_region_thessalonika					# stretch

		# Baltic Paganism
		# ghw_region_baltic							# heartlands
		# ghw_region_poland							# frontier
		# ghw_region_russia							# frontier
		# ghw_region_scandinavia					# fringe
		# ghw_region_steppe							# fringe
		# ghw_region_hungary						# fringe

		# Slavic Paganism
		# ghw_region_wendish_lands					# heartlands
		# ghw_region_balkans						# heartlands
		# ghw_region_russia							# heartlands
		# ghw_region_hungary						# frontier
		# ghw_region_steppe							# frontier
		# ghw_region_mainland_greece				# fringe
		# ghw_region_germany						# fringe
		# ghw_region_italy							# stretch

		# Finnish Paganism
		# ghw_region_finland_&_estonia				# heartlands
		# ghw_region_northern_russia				# heartlands
		# ghw_region_steppe							# heartlands
		# ghw_region_scandinavia					# frontier
		# ghw_region_baltic							# frontier
		# ghw_region_southern_russia				# frontier
		# ghw_region_siberia						# frontier
		# ghw_region_transoxiana					# fringe
		# ghw_region_mongolia						# fringe

		# Tengri Paganism
		# ghw_region_mongolia						# heartlands
		# ghw_region_siberia						# heartlands
		# ghw_region_steppe							# heartlands
		# ghw_region_russia							# frontier
		# ghw_region_transoxiana					# frontier
		# ghw_region_hungary						# frontier
		# ghw_region_tibet							# fringe
		# ghw_region_wendish_lands					# fringe

		# Magyar Paganism
		# ghw_region_hungary						# heartlands
		# ghw_region_balkans						# frontier
		# ghw_region_crimea							# frontier
		# ghw_region_poland_bohemia_bavaria			# frontier
		# ghw_region_southern_russia				# frontier
		# ghw_region_mainland_greece				# fringe
		# ghw_region_baltic							# fringe

		# Bon Paganism, Qiangicism, Donyipoloism, & Mundhumism
		# ghw_region_tibet							# heartlands
		# ghw_region_northern_india					# frontier
		# ghw_region_khotan							# frontier
		# ghw_region_mongolia						# fringe
		# ghw_region_transoxiana					# fringe
		# ghw_region_southern_india					# stretch

		# Mande Paganism & Senegambian Paganism
		# ghw_region_the_sahel						# heartlands
		# ghw_region_subsahelian_africa				# frontier
		# ghw_region_north_african_interior			# frontier
		# ghw_region_western_sahara					# frontier
		# ghw_region_north_africa					# fringe

		# Hausan Paganism
		# ghw_region_north_african_interior			# heartlands
		# ghw_region_the_sahel						# frontier
		# ghw_region_subsahelian_africa				# frontier
		# ghw_region_ethiopia						# frontier
		# ghw_region_eastern_sahara					# frontier
		# ghw_region_horn_of_africa					# fringe
		# ghw_region_egypt_et_al					# fringe
		# ghw_region_north_africa					# fringe

		# Akan Paganism & Yoruba Paganism
		# ghw_region_subsahelian_africa				# heartlands
		# ghw_region_the_sahel						# frontier
		# ghw_region_north_african_interior			# frontier
		# ghw_region_western_sahara					# frontier
		# ghw_region_north_africa					# fringe

		# Kushite Paganism
		# ghw_region_egypt_et_al					# heartlands
		# ghw_region_north_african_interior			# frontier
		# ghw_region_ethiopia						# frontier
		# ghw_region_horn_of_africa					# frontier
		# ghw_region_the_sahel						# fringe
		# ghw_region_subsahelian_africa				# fringe
		# ghw_region_eastern_sahara					# fringe
		# ghw_region_north_africa					# fringe
		# ghw_region_holy_land						# stretch
		# ghw_region_arabia							# stretch

		# Waaqi Paganism
		# ghw_region_horn_of_africa					# heartlands
		# ghw_region_ethiopia						# frontier
		# ghw_region_egypt_et_al					# frontier
		# ghw_region_arabia							# frontier
		# ghw_region_north_african_interior			# fringe
		# ghw_region_holy_land						# fringe

		# Zunist Paganism
		# ghw_region_afghanistan					# heartlands
		# ghw_region_western_india					# frontier
		# ghw_region_persia							# frontier
		# ghw_region_transoxiana					# frontier
		# ghw_region_caucasus						# fringe
		# ghw_region_holy_land						# fringe
		# ghw_region_near_east						# fringe
		# ghw_region_southwestern_india				# fringe
		# ghw_region_egypt							# stretch

		# Hellenic Paganism
		# ghw_region_mainland_greece				# heartlands
		# ghw_region_italy							# heartlands
		# ghw_region_anatolia						# frontier
		# ghw_region_balkans						# frontier
		# ghw_region_near_east						# frontier
		# ghw_region_holy_land						# fringe
		# ghw_region_egypt							# fringe
		# ghw_region_north_africa					# fringe
		# ghw_region_southern_france				# fringe

		# Hinduism
		# Hinduism prioritises the Sacred River above the rest of the sub-continent.
		# ghw_region_the_ganges						# heartlands
		# ghw_region_non_ganges_india				# frontier
		# ghw_region_tibet							# fringe
		# ghw_region_afghanistan					# fringe
		# ghw_region_persia							# fringe

		# Jainism
		# How did you even *manage* to get a game that needs this?
		# ghw_region_gujarat_&_rajputana			# heartlands
		# ghw_region_non_gujarat_or_rajputana_india	# frontier
		# ghw_region_tibet							# fringe
		# ghw_region_afghanistan					# fringe
		# ghw_region_persia							# fringe

		# Buddhism Theravada
		# ghw_region_lanka_&_bengal					# heartlands
		# ghw_region_middle_india					# frontier
		# ghw_region_western_india					# fringe

		# Buddhism Mahayana & Vajrayana
		# ghw_region_tibet							# heartlands
		# ghw_region_mongolia						# heartlands
		# ghw_region_khotan							# frontier
		# ghw_region_siberia						# frontier
		# ghw_region_transoxiana					# fringe
		# ghw_region_afghanistan					# fringe

		# Taoism
		# ghw_region_mongolia						# heartlands
		# ghw_region_siberia						# frontier
		# ghw_region_tibet							# frontier
		# ghw_region_north_eastern_india			# fringe
	# }

	# Christian heartlands
	if = {
		limit = {
			OR = {
				scope:the_faith.religion = religion:eastern_orthodox_religion
				scope:the_faith.religion = religion:catholic_religion
				scope:the_faith.religion = religion:protestant_religion 
			}
			OR = {
				AND = {
					# Catholic sphere.
					scope:the_faith = { not_non_catholic_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_northern_italy
							geographical_region = ghw_region_france
							geographical_region = ghw_region_germany
							#geographical_region = ghw_region_england
						}
					}
				}
				AND = {
					# Orthodox sphere.
					scope:the_faith = { not_non_orthodox_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_thessalonika
							geographical_region = ghw_region_greece
						}
					}
				}
				AND = {
					# Coptic sphere.
					scope:the_faith = { not_non_coptic_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = { geographical_region = ghw_region_ethiopia }
				}
				AND = {
					# Armenian sphere.
					scope:the_faith = { not_non_armenian_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = { geographical_region = ghw_region_caucasus }
				}
			}
		}
		add = ghw_target_heartlands
	}
	# Christian frontier
	else_if = {
		limit = {
			OR = {
				scope:the_faith.religion = religion:eastern_orthodox_religion
				scope:the_faith.religion = religion:catholic_religion
				scope:the_faith.religion = religion:protestant_religion 
			}
			OR = {
				AND = {
					# Shared Orthodox/Armenian sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_orthodox_standard_christian_faith_trigger = yes
							not_non_armenian_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = { geographical_region = ghw_region_anatolia }
				}
				AND = {
					# Shared Catholic/Orthodox/Armenian sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_catholic_standard_christian_faith_trigger = yes
							not_non_orthodox_standard_christian_faith_trigger = yes
							not_non_armenian_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_near_east
							geographical_region = ghw_region_egypt
						}
					}
				}
				AND = {
					# Shared Catholic/Orthodox sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_catholic_standard_christian_faith_trigger = yes
							not_non_orthodox_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_mediterranean
							geographical_region = ghw_region_balkans
						}
					}
				}
				AND = {
					# Shared Catholic/Orthodox/Armenian sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_catholic_standard_christian_faith_trigger = yes
							not_non_orthodox_standard_christian_faith_trigger = yes
							not_non_armenian_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = { geographical_region = ghw_region_holy_land }
				}
				AND = {
					scope:the_faith = { not_non_catholic_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = { geographical_region = ghw_region_iberia }
				}
			}
		}
		add = ghw_target_frontier
	}
	# Christian fringe
	else_if = {
		limit = {
			OR = {
				scope:the_faith.religion = religion:eastern_orthodox_religion
				scope:the_faith.religion = religion:catholic_religion
				scope:the_faith.religion = religion:protestant_religion 
			}
			OR = {
				AND = {
					scope:the_faith = { not_non_catholic_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_celtic
							geographical_region = ghw_region_germanic
							geographical_region = ghw_region_finland_&_estonia
						}
					}
				}
				AND = {
					# Shared Catholic/Orthodox sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_catholic_standard_christian_faith_trigger = yes
							not_non_orthodox_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = { geographical_region = ghw_region_central_european }
				}
			}
		}
		add = ghw_target_fringe
	}
	# Christian stretch goal
	else_if = {
		limit = {
			AND = {
				scope:the_faith = {
					OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion }
					not_non_catholic_standard_christian_faith_trigger = yes
				}
				title_capital_county.title_province = { geographical_region = ghw_region_baltic }
			}
		}
		add = ghw_target_stretch
	}
	# Muslim heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:islam_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_holy_land
					geographical_region = ghw_region_arabia
					geographical_region = ghw_region_near_east
					geographical_region = ghw_region_egypt
					geographical_region = ghw_region_persia
					geographical_region = ghw_region_north_africa
				}
			}
		}
		add = ghw_target_heartlands
	}
	# Muslim frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:islam_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_sicily
					geographical_region = ghw_region_iberia
					geographical_region = ghw_region_anatolia
					geographical_region = ghw_region_afghanistan
				}
			}
		}
		add = ghw_target_frontier
	}
	# Muslim fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:islam_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_the_sahel
					geographical_region = ghw_region_mediterranean
					geographical_region = ghw_region_western_india
					geographical_region = ghw_region_southern_france
				}
			}
		}
		add = ghw_target_fringe
	}
	# Yazidi heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:yazidi_religion
			title_capital_county.title_province = { geographical_region = ghw_region_kurdistan }
		}
		add = ghw_target_heartlands
	}
	# Yazidi frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:yazidi_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_southern_middle_east
					geographical_region = ghw_region_eastern_middle_east
					geographical_region = ghw_region_caucasus
				}
			}
		}
		add = ghw_target_frontier
	}
	# Yazidi fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:yazidi_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_caspian_steppe
					geographical_region = ghw_region_arabia
					geographical_region = ghw_region_holy_land
				}
			}
		}
		add = ghw_target_fringe
	}
	# Jewish heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:judaism_religion
			title_capital_county.title_province = { geographical_region = ghw_region_holy_land }
		}
		add = ghw_target_heartlands
	}
	# Jewish frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:judaism_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_arabia
					geographical_region = ghw_region_near_east
					geographical_region = ghw_region_egypt
				}
			}
		}
		add = ghw_target_frontier
	}
	# Jewish fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:judaism_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_anatolia
					geographical_region = ghw_region_persia
					geographical_region = ghw_region_ethiopia
				}
			}
		}
		add = ghw_target_fringe
	}
	# Zoroastrian/Dualist heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = {
				OR = {
					this = religion:zoroastrianism_religion
#					this = religion:dualism_religion
				}
			}
			title_capital_county.title_province = { geographical_region = ghw_region_persia }
		}
		add = ghw_target_heartlands
	}
	# Zoroastrian/Dualist frontier
	else_if = {
		limit = {
			scope:the_faith.religion = {
				OR = {
					this = religion:zoroastrianism_religion
#					this = religion:dualism_religion
				}
			}
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_afghanistan
					geographical_region = ghw_region_near_east
				}
			}
		}
		add = ghw_target_frontier
	}
	# Zoroastrian/Dualist fringe
	else_if = {
		limit = {
			scope:the_faith.religion = {
				OR = {
					this = religion:zoroastrianism_religion
#					this = religion:dualism_religion
				}
			}
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_arabia
					geographical_region = ghw_region_holy_land
					geographical_region = ghw_region_anatolia
					geographical_region = ghw_region_mongolia
					geographical_region = ghw_region_western_india
				}
			}
		}
		add = ghw_target_fringe
	}
	
	### Pagans
	# Norse heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:folkgerman_religion
			title_capital_county.title_province = { geographical_region = ghw_region_scandinavia }
		}
		add = ghw_target_heartlands
	}
	# Norse frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:folkgerman_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_britannia
					geographical_region = ghw_region_saxony
					geographical_region = ghw_region_russia
				}
			}
		}
		add = ghw_target_frontier
	}
	# Norse fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:folkgerman_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_baltic
					geographical_region = ghw_region_poland
				}
			}
		}
		add = ghw_target_fringe
	}
	# Norse stretch goal
	else_if = {
		limit = {
			scope:the_faith.religion = religion:folkgerman_religion
			title_capital_county.title_province = { geographical_region = ghw_region_thessalonika }
		}
		add = ghw_target_stretch
	}
	# Baltic heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:baltic_religion
			title_capital_county.title_province = { geographical_region = ghw_region_baltic }
		}
		add = ghw_target_heartlands
	}
	# Baltic frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:baltic_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_poland
					geographical_region = ghw_region_russia
				}
			}
		}
		add = ghw_target_frontier
	}
	# Baltic fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:baltic_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_scandinavia
					geographical_region = ghw_region_steppe
					geographical_region = ghw_region_hungary
				}
			}
		}
		add = ghw_target_fringe
	}
	# Slavic heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:slavic_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_wendish_lands
					geographical_region = ghw_region_balkans
					geographical_region = ghw_region_russia
				}
			}
		}
		add = ghw_target_heartlands
	}
	# Slavic frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:slavic_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_hungary
					geographical_region = ghw_region_steppe
				}
			}
		}
		add = ghw_target_frontier
	}
	# Slavic fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:slavic_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_mainland_greece
					geographical_region = ghw_region_germany
				}
			}
		}
		add = ghw_target_fringe
	}
	# Slavic stretch goal
	else_if = {
		limit = {
			scope:the_faith.religion = religion:slavic_religion
			title_capital_county.title_province = { geographical_region = ghw_region_italy }
		}
		add = ghw_target_stretch
	}
	# Finnish & Siberian heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = {
				OR = {
					this = religion:finnic_religion
					this = religion:siberian_religion
				}
			}
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_finland_&_estonia
					geographical_region = ghw_region_northern_russia
					geographical_region = ghw_region_steppe
				}
			}
		}
		add = ghw_target_heartlands
	}
	# Finnish & Siberian frontier
	else_if = {
		limit = {
			scope:the_faith.religion = {
				OR = {
					this = religion:finnic_religion
					this = religion:siberian_religion
				}
			}
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_scandinavia
					geographical_region = ghw_region_baltic
					geographical_region = ghw_region_southern_russia
					geographical_region = ghw_region_siberia
				}
			}
		}
		add = ghw_target_frontier
	}
	# Finnish & Siberian fringe
	else_if = {
		limit = {
			scope:the_faith.religion = {
				OR = {
					this = religion:finnic_religion
					this = religion:siberian_religion
				}
			}
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_transoxiana
					geographical_region = ghw_region_mongolia
				}
			}
		}
		add = ghw_target_fringe
	}
	# Tengri heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:tengrism_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_mongolia
					geographical_region = ghw_region_siberia
					geographical_region = ghw_region_steppe
				}
			}
		}
		add = ghw_target_heartlands
	}
	# Tengri frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:tengrism_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_russia
					geographical_region = ghw_region_transoxiana
					geographical_region = ghw_region_hungary
				}
			}
		}
		add = ghw_target_frontier
	}
	# Tengri fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:tengrism_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_tibet
					geographical_region = ghw_region_wendish_lands
				}
			}
		}
		add = ghw_target_fringe
	}
	# Magyar heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:hungaric_religion
			title_capital_county.title_province = { geographical_region = ghw_region_hungary }
		}
		add = ghw_target_heartlands
	}
	# Magyar frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:hungaric_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_balkans
					geographical_region = ghw_region_crimea
					geographical_region = ghw_region_poland_bohemia_bavaria
					geographical_region = ghw_region_southern_russia
				}
			}
		}
		add = ghw_target_frontier
	}
	# Magyar fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:hungaric_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_mainland_greece
					geographical_region = ghw_region_baltic
				}
			}
		}
		add = ghw_target_fringe
	}
#	# Bon/Qiangicism/Donyipoloism/Mundhumism heartlands
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:bon_religion
#					this = religion:tani_religion
#					this = religion:mundhum_religion
#					this = religion:qiangic_religion
#				}
#			}
#			title_capital_county.title_province = { geographical_region = ghw_region_tibet }
#		}
#		add = ghw_target_heartlands
#	}
	# Bon/Qiangicism/Donyipoloism/Mundhumism frontier
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:bon_religion
#					this = religion:tani_religion
#					this = religion:mundhum_religion
#					this = religion:qiangic_religion
#				}
#			}
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_northern_india
#					geographical_region = ghw_region_khotan
#				}
#			}
#		}
#		add = ghw_target_frontier
#	}
	# Bon/Qiangicism/Donyipoloism/Mundhumism fringe
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:bon_religion
#					this = religion:tani_religion
#					this = religion:mundhum_religion
#					this = religion:qiangic_religion
#				}
#			}
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_mongolia
#					geographical_region = ghw_region_transoxiana
#				}
#			}
#		}
#		add = ghw_target_fringe
#	}
	# Bon/Qiangicism/Donyipoloism/Mundhumism stretch goal
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:bon_religion
#					this = religion:tani_religion
#					this = religion:mundhum_religion
#					this = religion:qiangic_religion
#				}
#			}
#			title_capital_county.title_province = { geographical_region = ghw_region_southern_india }
#		}
#		add = ghw_target_stretch
#	}
#	# Mande Paganism & Senegambian Paganism heartlands
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:west_african_roog_religion
#					this = religion:west_african_religion
#				}
#			}
#			title_capital_county.title_province = { geographical_region = ghw_region_the_sahel }
#		}
#		add = ghw_target_heartlands
#	}
#	# Mande Paganism & Senegambian Paganism frontier
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:west_african_roog_religion
#					this = religion:west_african_religion
#				}
#			}
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_subsahelian_africa
#					geographical_region = ghw_region_north_african_interior
#					geographical_region = ghw_region_western_sahara
#				}
#			}
#		}
#		add = ghw_target_frontier
#	}
#	# Mande Paganism & Senegambian Paganism fringe
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:west_african_roog_religion
#					this = religion:west_african_religion
#				}
#			}
#			title_capital_county.title_province = { geographical_region = ghw_region_north_africa }
#		}
#		add = ghw_target_fringe
#	}
#	# Hausan Paganism heartlands
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:west_african_bori_religion
#			title_capital_county.title_province = { geographical_region = ghw_region_north_african_interior }
#		}
#		add = ghw_target_heartlands
#	}
#	# Hausan Paganism frontier
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:west_african_bori_religion
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_the_sahel
#					geographical_region = ghw_region_subsahelian_africa
#					geographical_region = ghw_region_ethiopia
#					geographical_region = ghw_region_eastern_sahara
#				}
#			}
#		}
#		add = ghw_target_frontier
#	}
#	# Hausan Paganism fringe
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:west_african_bori_religion
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_horn_of_africa
#					geographical_region = ghw_region_egypt_et_al
#					geographical_region = ghw_region_north_africa
#				}
#			}
#		}
#		add = ghw_target_fringe
#	}
#	# Akan Paganism & Yoruba Paganism heartlands
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:akom_religion
#					this = religion:west_african_orisha_religion
#				}
#			}
#			title_capital_county.title_province = { geographical_region = ghw_region_subsahelian_africa }
#		}
#		add = ghw_target_heartlands
#	}
#	# Akan Paganism & Yoruba Paganism frontier
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:akom_religion
#					this = religion:west_african_orisha_religion
#				}
#			}
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_the_sahel
#					geographical_region = ghw_region_north_african_interior
#					geographical_region = ghw_region_western_sahara
#				}
#			}
#		}
#		add = ghw_target_frontier
#	}
#	# Akan Paganism & Yoruba Paganism fringe
#	else_if = {
#		limit = {
#			scope:the_faith.religion = {
#				OR = {
#					this = religion:akom_religion
#					this = religion:west_african_orisha_religion
#				}
#			}
#			title_capital_county.title_province = { geographical_region = ghw_region_north_africa }
#		}
#		add = ghw_target_fringe
#	}
#	# Kushite Paganism heartlands
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:kushitism_religion
#			title_capital_county.title_province = { geographical_region = ghw_region_egypt_et_al }
#		}
#		add = ghw_target_heartlands
#	}
#	# Kushite Paganism frontier
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:kushitism_religion
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_north_african_interior
#					geographical_region = ghw_region_ethiopia
#					geographical_region = ghw_region_ethiopia
#					geographical_region = ghw_region_horn_of_africa
#				}
#			}
#		}
#		add = ghw_target_frontier
#	}
#	# Kushite Paganism fringe
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:kushitism_religion
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_the_sahel
#					geographical_region = ghw_region_subsahelian_africa
#					geographical_region = ghw_region_north_africa
#					geographical_region = ghw_region_north_africa
#				}
#			}
#		}
#		add = ghw_target_fringe
#	}
#	# Kushite Paganism stretch goals
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:kushitism_religion
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_holy_land
#					geographical_region = ghw_region_arabia
#				}
#			}
#		}
#		add = ghw_target_stretch
#	}
#	# Waaqi Paganism heartlands
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:waaqism_religion
#			title_capital_county.title_province = { geographical_region = ghw_region_horn_of_africa }
#		}
#		add = ghw_target_heartlands
#	}
#	# Waaqi Paganism frontier
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:waaqism_religion
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_ethiopia
#					geographical_region = ghw_region_egypt_et_al
#					geographical_region = ghw_region_arabia
#				}
#			}
#		}
#		add = ghw_target_frontier
#	}
#	# Waaqi Paganism fringe
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:waaqism_religion
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_north_african_interior
#					geographical_region = ghw_region_holy_land
#				}
#			}
#		}
#		add = ghw_target_fringe
#	}
#	# Zunist heartlands
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:zunism_religion
#			title_capital_county.title_province = { geographical_region = ghw_region_afghanistan }
#		}
#		add = ghw_target_heartlands
#	}
#	# Zunist frontier
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:zunism_religion
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_western_india
#					geographical_region = ghw_region_persia
#					geographical_region = ghw_region_transoxiana
#				}
#			}
#		}
#		add = ghw_target_frontier
#	}
#	# Zunist fringe
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:zunism_religion
#			title_capital_county.title_province = {
#				OR = {
#					geographical_region = ghw_region_caucasus
#					geographical_region = ghw_region_holy_land
#					geographical_region = ghw_region_near_east
#					geographical_region = ghw_region_southwestern_india
#				}
#			}
#		}
#		add = ghw_target_fringe
#	}
#	# Zunist stretch goal
#	else_if = {
#		limit = {
#			scope:the_faith.religion = religion:zunism_religion
#			title_capital_county.title_province = { geographical_region = ghw_region_egypt }
#		}
#		add = ghw_target_stretch
#	}
	# Hellenic heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:theomach_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_mainland_greece
					geographical_region = ghw_region_italy
				}
			}
		}
		add = ghw_target_heartlands
	}
	# Hellenic frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:theomach_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_anatolia
					geographical_region = ghw_region_balkans
					geographical_region = ghw_region_near_east
				}
			}
		}
		add = ghw_target_frontier
	}
	# Hellenic fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:theomach_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_holy_land
					geographical_region = ghw_region_egypt
					geographical_region = ghw_region_north_africa
					geographical_region = ghw_region_southern_france
				}
			}
		}
		add = ghw_target_fringe
	}
	
	### Eastern
	# Hindu heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:hinduism_religion
			title_capital_county.title_province = { geographical_region = ghw_region_the_ganges }
		}
		add = ghw_target_heartlands
	}
	# Hindu frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:hinduism_religion
			title_capital_county.title_province = { geographical_region = ghw_region_non_ganges_india }
		}
		add = ghw_target_frontier
	}
	# Hindu fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:hinduism_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_tibet
					geographical_region = ghw_region_afghanistan
					geographical_region = ghw_region_persia
				}
			}
		}
		add = ghw_target_fringe
	}
	# Jain heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:jainism_religion
			title_capital_county.title_province = { geographical_region = ghw_region_gujarat_&_rajputana }
		}
		add = ghw_target_heartlands
	}
	# Jain frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:jainism_religion
			title_capital_county.title_province = { geographical_region = ghw_region_non_gujarat_or_rajputana_india }
		}
		add = ghw_target_frontier
	}
	# Jain fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:jainism_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_tibet
					geographical_region = ghw_region_afghanistan
					geographical_region = ghw_region_persia
				}
			}
		}
		add = ghw_target_fringe
	}
	# Theravada Buddhist heartlands
	else_if = {
		limit = {
			scope:the_faith = {
				religion = religion:buddhism_religion
				NOR = {
					this = faith:mahayana
					this = faith:vajrayana
				}
			}
			title_capital_county.title_province = { geographical_region = ghw_region_lanka_&_bengal }
		}
		add = ghw_target_heartlands
	}
	# Theravada Buddhist frontier
	else_if = {
		limit = {
			scope:the_faith = {
				religion = religion:buddhism_religion
				NOR = {
					this = faith:mahayana
					this = faith:vajrayana
				}
			}
			title_capital_county.title_province = { geographical_region = ghw_region_middle_india }
		}
		add = ghw_target_frontier
	}
	# Theravada Buddhist fringe
	else_if = {
		limit = {
			scope:the_faith = {
				religion = religion:buddhism_religion
				NOR = {
					this = faith:mahayana
					this = faith:vajrayana
				}
			}
			title_capital_county.title_province = { geographical_region = ghw_region_western_india }
		}
		add = ghw_target_fringe
	}
	# Mahayana & Vajrayana Buddhist heartlands
	else_if = {
		limit = {
			scope:the_faith = {
				religion = religion:buddhism_religion
				NOT = { this = faith:theravada }
			}
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_tibet
					geographical_region = ghw_region_mongolia
				}
			}
		}
		add = ghw_target_heartlands
	}
	# Mahayana & Vajrayana Buddhist frontier
	else_if = {
		limit = {
			scope:the_faith = {
				religion = religion:buddhism_religion
				NOT = { this = faith:theravada }
			}
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_khotan
					geographical_region = ghw_region_siberia
				}
			}
		}
		add = ghw_target_frontier
	}
	# Mahayana & Vajrayana Buddhist fringe
	else_if = {
		limit = {
			scope:the_faith = {
				religion = religion:buddhism_religion
				NOT = { this = faith:theravada }
			}
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_transoxiana
					geographical_region = ghw_region_afghanistan
				}
			}
		}
		add = ghw_target_fringe
	}
	# Taoist heartlands
	else_if = {
		limit = {
			scope:the_faith.religion = religion:taoism_religion
			title_capital_county.title_province = { geographical_region = ghw_region_mongolia }
		}
		add = ghw_target_heartlands
	}
	# Taoist frontier
	else_if = {
		limit = {
			scope:the_faith.religion = religion:taoism_religion
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_siberia
					geographical_region = ghw_region_tibet
				}
			}
		}
		add = ghw_target_frontier
	}
	# Taoist fringe
	else_if = {
		limit = {
			scope:the_faith.religion = religion:taoism_religion
			title_capital_county.title_province = { geographical_region = ghw_region_north_eastern_india }
		}
		add = ghw_target_fringe
	}

	### 3 ###
	# Factor in the potential target's distance from the faith.
	# Distance: Rome to Jerusalem-ish
	# If the HoF is landed, use them.
	if = {
		limit = {
			exists = scope:the_faith.religious_head.capital_county
		}
		if = {
			limit = {
				title_capital_county = {
					squared_distance = {
						target = scope:the_faith.religious_head.capital_county
						value >= ghw_target_distance_01_threshold
					}
				}
			}
			multiply = ghw_target_distance_01_reduction
		}
	}
	# Otherwise, use a preset fallback holy site.
	else = {
		# Christianity
		if = {
			limit = { 
				OR = {
					scope:the_faith.religion = religion:eastern_orthodox_religion
					scope:the_faith.religion = religion:catholic_religion
					scope:the_faith.religion = religion:protestant_religion 
				} 
			}
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_roma
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Islam
		else_if = {
			limit = { scope:the_faith.religion = religion:islam_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_mecca
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Judaism
		else_if = {
			limit = { scope:the_faith.religion = religion:judaism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_jerusalem
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Zoroastrianism & Dualism
		else_if = {
			limit = {
				scope:the_faith.religion = {
					OR = {
						this = religion:zoroastrianism_religion
#						this = religion:dualism_religion
					}
				}
			}
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_baduspan
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Asatru Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:folkgerman_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_upland
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Vidilist Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:baltic_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_braslau
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Slovianskan Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:slavic_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_kiev
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Ukonusko & Turumic Paganism
		else_if = {
			limit = {
				scope:the_faith.religion = {
					OR = {
						this = religion:finnic_religion
						this = religion:siberian_religion
					}
				}
			}
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_kakisalmi
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Tengri Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:tengrism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_qayaliq
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Taltosist Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:hungaric_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_visegrad
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Bon/Qiangicism/Donyipoloism/Mundhumism
#		else_if = {
#			limit = {
#				scope:the_faith.religion = {
#					OR = {
#						this = religion:bon_religion
#						this = religion:tani_religion
#						this = religion:mundhum_religion
#						this = religion:qiangic_religion
#					}
#				}
#			}
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_khotan
#							value >= ghw_target_distance_01_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_01_reduction
#			}
#		}
#		# Mande Paganism 
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_awkar
#							value >= ghw_target_distance_01_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_01_reduction
#			}
#		}
#		# Senegambian Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_roog_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_kasa
#							value >= ghw_target_distance_01_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_01_reduction
#			}
#		}
#		# Hausan Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_bori_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_daura
#							value >= ghw_target_distance_01_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_01_reduction
#			}
#		}
#		# Akan Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:akom_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_kumasi
#							value >= ghw_target_distance_01_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_01_reduction
#			}
#		}
#		# Yoruba Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_orisha_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_owu
#							value >= ghw_target_distance_01_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_01_reduction
#			}
#		}
#		# Kushite Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:kushitism_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_aswan
#							value >= ghw_target_distance_01_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_01_reduction
#			}
#		}
#		# Waaqi Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:waaqism_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_mogadishu
#							value >= ghw_target_distance_01_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_01_reduction
#			}
#		}
#		# Zunist Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:zunism_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_kabul
#							value >= ghw_target_distance_01_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_01_reduction
#			}
#		}
		# Hellenic Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:theomach_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_roma
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Hinduism
		else_if = {
			limit = { scope:the_faith.religion = religion:hinduism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_mathura
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Jainism
		else_if = {
			limit = { scope:the_faith.religion = religion:jainism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_somnath
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Buddhism
		else_if = {
			limit = { scope:the_faith.religion = religion:buddhism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_gaya
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
		# Taoism
		else_if = {
			limit = { scope:the_faith.religion = religion:taoism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_langshan
							value >= ghw_target_distance_01_threshold
						}
					}
				}
				multiply = ghw_target_distance_01_reduction
			}
		}
	}
	# Distance: Rome to Afghanistan-ish
	# If the HoF is landed, use them.
	if = {
		limit = {
			scope:the_faith.religious_head = { is_playable_character = yes }
		}
		if = {
			limit = {
				title_capital_county = {
					squared_distance = {
						target = scope:the_faith.religious_head.capital_county
						value >= ghw_target_distance_02_threshold
					}
				}
			}
			multiply = ghw_target_distance_02_reduction
		}
	}
	# Otherwise, use a preset fallback holy site.
	else = {
		# Christianity
		if = {
			limit = { 
				OR = {
					scope:the_faith.religion = religion:eastern_orthodox_religion
					scope:the_faith.religion = religion:catholic_religion
					scope:the_faith.religion = religion:protestant_religion 
				} 
			}
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_roma
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Islam
		else_if = {
			limit = { scope:the_faith.religion = religion:islam_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_mecca
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Judaism
		else_if = {
			limit = { scope:the_faith.religion = religion:judaism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_jerusalem
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Zoroastrianism & Dualism
		else_if = {
			limit = {
				scope:the_faith.religion = {
					OR = {
						this = religion:zoroastrianism_religion
#						this = religion:dualism_religion
					}
				}
			}
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_baduspan
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Asatru Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:folkgerman_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_upland
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Vidilist Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:baltic_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_braslau
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Slovianskan Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:slavic_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_kiev
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Ukonusko & Turumic Paganism
		else_if = {
			limit = {
				scope:the_faith.religion = {
					OR = {
						this = religion:finnic_religion
						this = religion:siberian_religion
					}
				}
			}
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_kakisalmi
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Tengri Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:tengrism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_qayaliq
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Taltosist Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:hungaric_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_visegrad
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Bon/Qiangicism/Donyipoloism/Mundhumism
#		else_if = {
#			limit = {
#				scope:the_faith.religion = {
#					OR = {
#						this = religion:bon_religion
#						this = religion:tani_religion
#						this = religion:mundhum_religion
#						this = religion:qiangic_religion
#					}
#				}
#			}
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_khotan
#							value >= ghw_target_distance_02_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_02_reduction
#			}
#		}
#		# Mande Paganism 
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_awkar
#							value >= ghw_target_distance_02_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_02_reduction
#			}
#		}
#		# Senegambian Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_roog_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_kasa
#							value >= ghw_target_distance_02_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_02_reduction
#			}
#		}
#		# Hausan Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_bori_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_daura
#							value >= ghw_target_distance_02_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_02_reduction
#			}
#		}
#		# Akan Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:akom_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_kumasi
#							value >= ghw_target_distance_02_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_02_reduction
#			}
#		}
#		# Yoruba Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_orisha_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_owu
#							value >= ghw_target_distance_02_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_02_reduction
#			}
#		}
#		# Kushite Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:kushitism_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_aswan
#							value >= ghw_target_distance_02_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_02_reduction
#			}
#		}
#		# Waaqi Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:waaqism_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_mogadishu
#							value >= ghw_target_distance_02_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_02_reduction
#			}
#		}
#		# Zunist Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:zunism_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_kabul
#							value >= ghw_target_distance_02_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_02_reduction
#			}
#		}
		# Hellenic Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:theomach_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_roma
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Hinduism
		else_if = {
			limit = { scope:the_faith.religion = religion:hinduism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_mathura
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Jainism
		else_if = {
			limit = { scope:the_faith.religion = religion:jainism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_somnath
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Buddhism
		else_if = {
			limit = { scope:the_faith.religion = religion:buddhism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_gaya
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
		# Taoism
		else_if = {
			limit = { scope:the_faith.religion = religion:taoism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_langshan
							value >= ghw_target_distance_02_threshold
						}
					}
				}
				multiply = ghw_target_distance_02_reduction
			}
		}
	}
	# Distance: Rome to Bengal-ish
	# If the HoF is landed, use them.
	if = {
		limit = {
			scope:the_faith.religious_head = { is_playable_character = yes }
		}
		if = {
			limit = {
				title_capital_county = {
					squared_distance = {
						target = scope:the_faith.religious_head.capital_county
						value >= ghw_target_distance_03_threshold
					}
				}
			}
			multiply = ghw_target_distance_03_reduction
		}
	}
	# Otherwise, use a preset fallback holy site.
	else = {
		# Christianity
		if = {
			limit = { 
				OR = {
					scope:the_faith.religion = religion:eastern_orthodox_religion
					scope:the_faith.religion = religion:catholic_religion
					scope:the_faith.religion = religion:protestant_religion 
				} 
			}
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_roma
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Islam
		else_if = {
			limit = { scope:the_faith.religion = religion:islam_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_mecca
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Judaism
		else_if = {
			limit = { scope:the_faith.religion = religion:judaism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_jerusalem
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Zoroastrianism & Dualism
		else_if = {
			limit = {
				scope:the_faith.religion = {
					OR = {
						this = religion:zoroastrianism_religion
#						this = religion:dualism_religion
					}
				}
			}
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_baduspan
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Asatru Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:folkgerman_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_upland
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Vidilist Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:baltic_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_braslau
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Slovianskan Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:slavic_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_kiev
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Ukonusko & Turumic Paganism
		else_if = {
			limit = {
				scope:the_faith.religion = {
					OR = {
						this = religion:finnic_religion
						this = religion:siberian_religion
					}
				}
			}
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_kakisalmi
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Tengri Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:tengrism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_qayaliq
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Taltosist Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:hungaric_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_visegrad
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Bon/Qiangicism/Donyipoloism/Mundhumism
#		else_if = {
#			limit = {
#				scope:the_faith.religion = {
#					OR = {
#						this = religion:bon_religion
#						this = religion:tani_religion
#						this = religion:mundhum_religion
#						this = religion:qiangic_religion
#					}
#				}
#			}
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_khotan
#							value >= ghw_target_distance_03_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_03_reduction
#			}
#		}
#		# Mande Paganism 
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_awkar
#							value >= ghw_target_distance_03_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_03_reduction
#			}
#		}
#		# Senegambian Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_roog_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_kasa
#							value >= ghw_target_distance_03_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_03_reduction
#			}
#		}
#		# Hausan Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_bori_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_daura
#							value >= ghw_target_distance_03_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_03_reduction
#			}
#		}
#		# Akan Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:akom_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_kumasi
#							value >= ghw_target_distance_03_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_03_reduction
#			}
#		}
#		# Yoruba Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:west_african_orisha_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_owu
#							value >= ghw_target_distance_03_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_03_reduction
#			}
#		}
#		# Kushite Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:kushitism_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_aswan
#							value >= ghw_target_distance_03_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_03_reduction
#			}
#		}
#		# Waaqi Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:waaqism_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_mogadishu
#							value >= ghw_target_distance_03_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_03_reduction
#			}
#		}
#		# Zunist Paganism
#		else_if = {
#			limit = { scope:the_faith.religion = religion:zunism_religion }
#			if = {
#				limit = {
#					title_capital_county = {
#						squared_distance = {
#							target = title:c_kabul
#							value >= ghw_target_distance_03_threshold
#						}
#					}
#				}
#				multiply = ghw_target_distance_03_reduction
#			}
#		}
		# Hellenic Paganism
		else_if = {
			limit = { scope:the_faith.religion = religion:theomach_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_roma
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Hinduism
		else_if = {
			limit = { scope:the_faith.religion = religion:hinduism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_mathura
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Jainism
		else_if = {
			limit = { scope:the_faith.religion = religion:jainism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_somnath
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Buddhism
		else_if = {
			limit = { scope:the_faith.religion = religion:buddhism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_gaya
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
		# Taoism
		else_if = {
			limit = { scope:the_faith.religion = religion:taoism_religion }
			if = {
				limit = {
					title_capital_county = {
						squared_distance = {
							target = title:c_langshan
							value >= ghw_target_distance_03_threshold
						}
					}
				}
				multiply = ghw_target_distance_03_reduction
			}
		}
	}
	
	# Weigh down certain areas slightly 
	if = {
		limit = {
			OR = {
				scope:the_faith.religion = religion:eastern_orthodox_religion
				scope:the_faith.religion = religion:catholic_religion
				scope:the_faith.religion = religion:protestant_religion 
			}
			# Shared Catholic/Orthodox sphere.
			scope:the_faith = {
				OR = {
					# Bit cack-handed to check it like this, but keeps things hygienic.
					not_non_catholic_standard_christian_faith_trigger = yes
					not_non_orthodox_standard_christian_faith_trigger = yes
				}
			}
			title_capital_county.title_province = {
				geographical_region = ghw_region_north_africa
			}
		}
		multiply = 0.7
	}
	else_if = {
		limit = {
			OR = {
				scope:the_faith.religion = religion:eastern_orthodox_religion
				scope:the_faith.religion = religion:catholic_religion
				scope:the_faith.religion = religion:protestant_religion 
			}
			# Shared Catholic/Orthodox sphere.
			scope:the_faith = {
				OR = {
					# Bit cack-handed to check it like this, but keeps things hygienic.
					not_non_catholic_standard_christian_faith_trigger = yes
					not_non_orthodox_standard_christian_faith_trigger = yes
				}
			}
			title_capital_county.title_province = {
				OR = {
					geographical_region = ghw_region_western_sahara
					geographical_region = ghw_region_eastern_sahara
					geographical_region = ghw_region_the_sahel
					geographical_region = ghw_region_north_african_interior
					geographical_region = ghw_region_subsahelian_africa
					geographical_region = world_steppe
					geographical_region = world_asia_north_east
				}
			}
		}
		multiply = 0.001
	}

	### 4 ###
	# Always weight-up kingdoms containing holy sites.
	if = {
		limit = {
			any_in_de_jure_hierarchy = {
				tier = tier_barony
				continue = { tier > tier_barony }
				is_holy_site_of = scope:the_faith
			}
		}
		multiply = ghw_target_has_holy_site
	}

	### 5 ###
	# Christian & Jewish preference for Jerusalem
	if = {
		limit = {
			# Belongs to a Christian or Jewish religion.
			OR = {
				OR = {
					scope:the_faith.religion = religion:eastern_orthodox_religion
					scope:the_faith.religion = religion:catholic_religion
					scope:the_faith.religion = religion:protestant_religion 
				}
				scope:the_faith.religion = religion:judaism_religion
			}
			# Not a non-Catholic standard Christian faith.
			scope:the_faith = { not_non_catholic_standard_christian_faith_trigger = yes }
			# Definitely actually considers Jerusalem holy.
			title:c_jerusalem = {
				any_in_de_jure_hierarchy = {
					tier = tier_barony
					continue = { tier > tier_barony }
					is_holy_site_of = scope:the_faith
				}
			}
			# There's a GHWable kingdom in the area.
			title_capital_county.title_province = { geographical_region = ghw_region_jerusalem }
		}
		add = ghw_target_jerusalem
	}
	# Muslim preference for Mecca & Medina
	if = {
		limit = {
			# Belongs to an Islamic religion.
			scope:the_faith.religion = religion:islam_religion
			# Not the Qarmatians. Since they weren't exactly fans of the Holy Cities.
			NOT = { scope:the_faith = faith:qarmatian }
			# Definitely actually considers at least Mecca or Medina holy.
			OR = {
				title:c_mecca = {
					any_in_de_jure_hierarchy = {
						tier = tier_barony
						continue = { tier > tier_barony }
						is_holy_site_of = scope:the_faith
					}
				}
				title:c_medina = {
					any_in_de_jure_hierarchy = {
						tier = tier_barony
						continue = { tier > tier_barony }
						is_holy_site_of = scope:the_faith
					}
				}
			}
			# There's a GHWable kingdom in the area.
			title_capital_county.title_province = { geographical_region = ghw_region_arabia }
		}
		add = ghw_target_key_religious_holding
	}
	# A defender in the region HumSac'd your HoF
	if = {
		limit = {
			any_in_de_jure_hierarchy = {
				continue = { tier > tier_county }
				tier = tier_county
				holder = {
					AND = {
						has_variable_list = humsacd_hofs
						is_target_in_variable_list = {
							name = humsacd_hofs
							target = scope:the_faith
						}
					}
					scope:the_faith = {
						is_hostile_enough_for_holy_war_trigger = { FAITH = top_liege.faith }
					}
				}
			}
		}
		multiply = ghw_target_religious_vengeance
	}
}

great_holy_war_pledge_amount = {
	value = root.yearly_character_income
	min = 10
}

# Referenced in code; don't delete this. When determining GHW participation score, the character's score from the war is multiplied by this. ROOT is the character
ghw_score_mult = {
	value = 1
	if = {
		limit = {
			this = faith.religious_head
			faith = { has_doctrine = doctrine_spiritual_head } # Temporal heads get credit
		}
		value = 0
	}
}

# Referenced in code; don't delete this. When determining GHW participation score, the character's score percentage is capped at this. ROOT is the character
ghw_max_score_percentage = {
	value = 20
}

# Referenced in code; don't delete this. Used by the GHW screen to show the player how much of the pot they'll get when the war starts. Should be used where you hand it out: divide_war_chest = { fraction = ghw_war_start_handout_percentage }
ghw_war_start_handout_percentage = {
	value = 0.2
}

# Referenced in code; don't delete this
# When a holy war is declared, everyone of the defender's faith that passes can_defensively_join_holy_war will be scored using this
# Scores above 0 will join
# Scope is the potential joiner
# scope:attacker is the attacker
# scope:defender is the defender
holy_war_defensive_join_value = {
	add = {
		desc = "BASE_VALUE"
		value = -50
		format = "BASE_VALUE_FORMAT"
	}
	add = {
		desc = "zealous_personality"
		value = ai_zeal
	}
	
	add = {
		desc = "bold_personality"
		value = ai_boldness
		divide = 2
	}
	
	add = { # More fervent faiths are likelier to defend themselves en masse
		desc = "high_fervor"
		value = faith.fervor
		divide = 5 # Max 20
		if = {
			limit = {
				ai_zeal < 0
			}
			divide = 2 # Max 10 if not zealous
		}
	}
	
	if = {
		limit = {
			has_relation_rival = scope:attacker
		}
		add = {
			desc = "you_are_rivals"
			value = 200
		}
	}
	
	if = {
		limit = {
			OR = {
				has_relation_friend = scope:defender
				has_relation_lover = scope:defender
			}
		}
		add = {
			desc = "friends_with_defender"
			value = 200
		}
	}
	
	# Less Likely if you dislike the target
	if = {
		limit = {
			opinion = { target = scope:defender value <= -15 }
			ai_zeal < 50
		}
		add = {
			desc = "dislikes_defender"
			value = -25
		}
	}
	
	# Much Less Likely if you really dislike the target
	if = {
		limit = {
			opinion = { target = scope:defender value <= -50 }
			ai_zeal < 50
		}
		add = {
			desc = "strongly_dislikes_defender"
			value = -50
		}
	}
}

# Root = faith
faith_conversion_fervor_mult = {
	value = define:NFaith|MAX_FERVOR
	subtract = fervor
	multiply = define:NFaith|FAITH_CREATION_FERVOR_DISCOUNT_PER_MISSING_FERVOR
	max = define:NFaith|FAITH_CREATION_FERVOR_DISCOUNT_MAX
	divide = define:NFaith|MAX_FERVOR
}

# Modify (multiply) the doctrine cost when creating a faith.
# The returned value is interpreted as a multiplicative modifier (e.g. 0.5 means +50% cost).
# scope:character = the creation character
# scope:old_faith = the faith the character is converting from
faith_creation_cost_mult = {
	subtract = {
		value = scope:old_faith.faith_conversion_fervor_mult
		desc = "faith_creation_cost_fervor_impact"
		format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
	}
}

# Modify (multiply) the doctrine cost when converting to a faith.
# The returned value is interpreted as a multiplicative modifier (e.g. 0.5 means +50% cost).
# scope:character = the converting character
# scope:new_faith = the faith the character is converting to
# There should be no subtract equal or higher than 1
faith_conversion_cost_mult = {
	
	#Adding 1 to apply properly the following multipliers
	add = {
		value = 1
	}

	# Try to always be cheaper than creating a new faith
	if = {
		limit = {
			scope:character.learning > 0
		}
		multiply = {
			value = 1
			subtract = {
				desc = "learning_modifier"
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = scope:character.learning
				divide = 100
			}
		}
	}
	if = {
		limit = {
			always = yes
		}
		multiply = {
			value = 1
			add = {
				value = scope:new_faith.faith_conversion_fervor_mult
				subtract = scope:character.faith.faith_conversion_fervor_mult
				desc = "faith_conversion_cost_fervor_difference"
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
			}
		}	
	}
	# Try to always be cheaper than creating a new faith
	if = {
		limit = {
			scope:new_faith.religion = scope:character.faith.religion
		}
		multiply = {
			value = 1
			subtract = {
				desc = "faith_conversion_cost_existing_faith"
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.5
			}
		}
	}
	# Try to always be cheaper than creating a new faith
	else = {
		multiply = {
			value = 1
			subtract = {
				desc = "faith_conversion_cost_existing_faith"
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.35
			}
		}
	}
	# Pluralistic faiths have it easier converting to each other
	if = {
		limit = {
			scope:new_faith = { has_doctrine = doctrine_pluralism_pluralistic }
			scope:character.faith = { has_doctrine = doctrine_pluralism_pluralistic }
		}
		multiply = {
			value = 1
			subtract = {
				desc = "faith_conversion_cost_pluralists"
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.25
			}
		}
	}
	# Pluralistic faiths have it easier converting
	else_if = {
		limit = {
			scope:character.faith = { has_doctrine = doctrine_pluralism_pluralistic }
		}
		multiply = {
			value = 1
			subtract = {
				desc = "faith_conversion_cost_pluralist"
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.15
			}
		}
	}

	###############################################################
	# Converting TO an unreformed faith often has steep penalties #
	###############################################################
	if = {
		limit = {
			scope:new_faith = {
				has_doctrine_parameter = unreformed
			}
		}

		# Massive penalty if your current faith is reformed.
		if = {
			limit = {
				scope:character = {
					faith = {
						NOT = { has_doctrine_parameter = unreformed }
					}
				}
			}
			multiply = {
				value = 1
				add = {
					desc = "faith_conversion_cost_reformed_converting_to_unreformed"
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 5
				}
			}
			
		}

		# Minor stacking penalties depending on (non-tribal) government form.
		if = {
			limit = {
				scope:character = {
					government_has_flag = government_is_clan
				}
			}
			multiply = {
				value = 1
				add = {
					desc = "faith_conversion_cost_clan_converting_to_unreformed"
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.25
				}
			}
		}
		else_if = {
			limit = {
				scope:character = {
					government_has_flag = government_is_feudal
				}
			}
			multiply = {
				value = 1
				add = {
					desc = "faith_conversion_cost_feudal_converting_to_unreformed"
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.5
				}
			}
		}
		else_if = {
			limit = {
				scope:character = {
					government_has_flag = government_is_republic
				}
			}
			multiply = {
				value = 1
				add = {
					desc = "faith_conversion_cost_republic_converting_to_unreformed"
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.75
				}
			}
		}
	}

	##################################
	# Dead Religion/Faith penalty(s) #
	##################################
	#More expensive to convert to a dead religion
	if = {
		limit = {
			scope:new_faith = {
				religion = {
					any_faith = {
						count = all
						has_followers_trigger = no
					}
				}
			}
		}
		multiply = {
			value = 1
			add = {
				desc = faith_conversion_cost_dead_religion
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 5
			}
		}
	}

	#######################################
	# Switching religion/family penalties #
	#######################################
	# More expensive if you convert to a faith outside of your religion's family
	if = {
		limit = {
			scope:new_faith = { has_doctrine = special_doctrine_immaterial_harmony }
			scope:character.faith = { has_doctrine = special_doctrine_immaterial_harmony }
		}
		multiply = {
			value = 1
			add = {
				desc = faith_conversion_cost_immaterial_harmony
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = -0.5
			}
		}
	}
	else_if = {
		limit = {
			OR = {
				AND = {
					scope:new_faith.religion = { is_in_family = rf_abrahamic }
					NOT = {
						scope:character.faith.religion = { is_in_family = rf_abrahamic }
					}
				}
				AND = {
					scope:new_faith.religion = { is_in_family = rf_eastern }
					NOT = {
						scope:character.faith.religion = { is_in_family = rf_eastern }
					}
				}
				AND = {
					scope:new_faith.religion = { is_in_family = rf_pagan }
					NOT = {
						scope:character.faith.religion = { is_in_family = rf_pagan }
					}
				}
			}
		}
		multiply = {
			value = 1
			add = {
				desc = faith_conversion_cost_other_religion_family
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 2
			}
		}
	}
	
	# Unreformed Faiths have an easier way converting to Organized faiths
	if = {
		limit = {
			scope:new_faith = {
				NOT = { has_doctrine_parameter = unreformed }
			}
			scope:character.faith = { has_doctrine_parameter = unreformed }
		}
		multiply = {
			value = 1
			subtract = {
				desc = faith_conversion_cost_unreformed_to_organized
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.9
			}
		}
	}

	if = {
		limit = {
			scope:character = {
				any_courtier = {
					has_character_flag = suzerains_missionary
					faith = scope:new_faith
				}
			}
		}
		multiply = {
			value = 1
			subtract = {
				desc = faith_conversion_cost_suzerains_missionary
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.1
			}
		}
	}
	
	# More expensive to convert to something inside your religion family that's not the same religion
	if = {
		limit = {
			scope:new_faith.religion = { is_in_family = rf_abrahamic }
			scope:character.faith.religion = {
				is_in_family = rf_abrahamic
				this != scope:new_faith.religion
			}
		}
		multiply = {
			value = 1
			add = {
				desc = faith_conversion_cost_inside_religion_family
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 1
			}
		}
	}
	else_if = {
		limit = {
			scope:new_faith.religion = { is_in_family = rf_eastern }
			scope:character.faith.religion = {
				is_in_family = rf_eastern
				this != scope:new_faith.religion
			}
		}
		multiply = {
			value = 1
			add = {
				desc = faith_conversion_cost_inside_religion_family
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 1
			}
		}
	}
	if = {
		limit = {
			scope:new_faith.religion = { is_in_family = rf_pagan }
			scope:character.faith.religion = {
				is_in_family = rf_pagan
				this != scope:new_faith.religion
			}
		}
		multiply = {
			value = 1
			add = {
				desc = faith_conversion_cost_inside_religion_family
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 1
			}
		}
	}

	#######################################
	# Misc penalties #
	#######################################
	# More expensive to convert to a faith who's HoF you HumSac'D/to a faith on good terms with one who's HoF you HumSac'd, unless they're chill with HumSac.
	if = {
		limit = {
			scope:character = {
				has_variable_list = humsacd_hofs
				any_in_list = {
					variable = humsacd_hofs
					faith_hostility_level = {
						target = scope:new_faith
						value <= faith_astray_level
					}
				}
			}
			# Exemptions for people who already practice HumSac: they're likely not happy, but it's not the ultimate taboo for them.
			scope:new_faith = {
				NOT = { has_doctrine_parameter = human_sacrifice_active }
			}
		}
		multiply = {
			value = 1
			add = {
				desc = faith_conversion_cost_sacrificed_hof
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 5
			}
		}
	}

	########################
	# Conversion Discounts #
	########################
	# Cheaper if you are targeted by the new Faith in a defensive Holy War
	if = {
		limit = {
			scope:character = {
				any_character_war = {
					using_holy_war_cb_trigger = yes
					is_defender = scope:character
				}
			}
		}
		if = { # Even cheaper if unreformed
			limit = {
				scope:new_faith = {
					NOT = { has_doctrine_parameter = unreformed }
				}
				scope:character = {
					faith = {
						has_doctrine_parameter = unreformed
					}
				}
			}
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_unreformed_holy_war
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.9
				}
			}
		}
		else = { # But still a sizable discount otherwise.
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_holy_war
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.5
				}
			}
		}
	}
	# Cheaper if your spouse is of the faith
	if = {
		limit = {
			scope:character = {
				any_spouse = {
					faith = scope:new_faith
				}
			}
		}
		if = { # Even cheaper if unreformed
			limit = {
				scope:new_faith = {
					NOT = { has_doctrine_parameter = unreformed }
				}
				scope:character = {
					faith = {
						has_doctrine_parameter = unreformed
					}
				}
			}
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_unreformed_spouse
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.9
				}
			}
		}
		else = { # But still a sizable discount otherwise.		
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_spouse
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.5
				}
			}
		}
	}
	# Does a concubine have the right religion?
	else_if = {
		limit = {
			scope:character = {
				any_concubine = {
					faith = scope:new_faith
				}
			}
		}
		if = { # Even cheaper if unreformed
			limit = {
				scope:new_faith = {
					NOT = { has_doctrine_parameter = unreformed }
				}
				scope:character = {
					faith = {
						has_doctrine_parameter = unreformed
					}
				}
			}
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_unreformed_concubine
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.9
				}
			}
		}
		else = { # But still a sizable discount otherwise.
			
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_concubine
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.25
				}
			}
		}
	}
	# Cheaper if the religion is present near/in your borders
	if = {
		limit = {
			scope:new_faith = {
				religion = { is_in_family = rf_abrahamic }
			}
			scope:character = {
				faith = {
					religion = {
						NOT = { is_in_family = rf_abrahamic }
					}
				}
				OR = {
					any_neighboring_top_liege_realm_owner = {
						faith = scope:new_faith
					}
					any_vassal = {
						faith = scope:new_faith
					}
					any_realm_province = {
						faith = scope:new_faith
					}
					liege ?= {
						faith = scope:new_faith
					}

					liege ?= {	
						any_vassal = {
							faith = scope:new_faith
						}
					}
				}
			}
		}
		multiply = {
			value = 1 
			subtract = {
				desc = faith_conversion_cost_present
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.9
			}
		}
	}
	# Cheaper if the religion is present near/in your borders
	else_if = {
		limit = {
			scope:new_faith = {
				religion = { is_in_family = rf_eastern }
			}
			scope:character = {
				faith = {
					religion = {
						NOT = { is_in_family = rf_eastern }
					}
				}
				OR = {
					any_neighboring_top_liege_realm_owner = {
						faith = scope:new_faith
					}
					any_vassal = {
						faith = scope:new_faith
					}
					any_realm_province = {
						faith = scope:new_faith
					}
					liege ?= {
						faith = scope:new_faith
					}

					liege ?= {	
						any_vassal = {
							faith = scope:new_faith
						}
					}
				}
			}
		}
		multiply = {
			value = 1 
			subtract = {
				desc = faith_conversion_cost_present
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.9
			}
		}
	}
	# Cheaper if the religion is present near/in your borders
	else_if = {
		limit = {
			scope:new_faith = {
				religion = { is_in_family = rf_pagan }
			}
			scope:character = {
				faith = {
					religion = {
						NOT = { is_in_family = rf_pagan }
					}
				}
				OR = {
					any_neighboring_top_liege_realm_owner = {
						faith = scope:new_faith
					}
					any_vassal = {
						faith = scope:new_faith
					}
					any_realm_province = {
						faith = scope:new_faith
					}
					liege ?= {
						faith = scope:new_faith
					}

					liege ?= {	
						any_vassal = {
							faith = scope:new_faith
						}
					}
				}
			}
		}
		multiply = {
			value = 1 
			subtract = {
				desc = faith_conversion_cost_present
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.9
			}
		}
	}
	# Cheaper if the religion is present near/in your borders
	else_if = {
		limit = {
			scope:new_faith = {
				religion = { is_in_family = rf_abrahamic }
			}
			scope:character = {
				faith = {
					religion = {
						is_in_family = rf_abrahamic
						this != scope:new_faith.religion
					}
				}
				OR = {
					any_neighboring_top_liege_realm_owner = {
						faith = scope:new_faith
					}
					any_vassal = {
						faith = scope:new_faith
					}
					any_realm_province = {
						faith = scope:new_faith
					}
					liege ?= {
						faith = scope:new_faith
					}

					liege ?= {	
						any_vassal = {
							faith = scope:new_faith
						}
					}
				}
			}
		}
		multiply = {
			value = 1 
			subtract = {
				desc = faith_conversion_cost_present
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.8
			}
		}
	}
	# Cheaper if the religion is present near/in your borders
	else_if = {
		limit = {
			scope:new_faith = {
				religion = { is_in_family = rf_eastern }
			}
			scope:character = {
				faith = {
					religion = {
						is_in_family = rf_eastern
						this != scope:new_faith.religion
					}
				}
				OR = {
					any_neighboring_top_liege_realm_owner = {
						faith = scope:new_faith
					}
					any_vassal = {
						faith = scope:new_faith
					}
					any_realm_province = {
						faith = scope:new_faith
					}
					liege ?= {
						faith = scope:new_faith
					}

					liege ?= {	
						any_vassal = {
							faith = scope:new_faith
						}
					}
				}
			}
		}
		multiply = {
			value = 1 
			subtract = {
				desc = faith_conversion_cost_present
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.8
			}
		}
	}
	# Cheaper if the religion is present near/in your borders
	else_if = {
		limit = {
			scope:new_faith = {
				religion = { is_in_family = rf_pagan }
			}
			scope:character = {
				faith = {
					religion = {
						is_in_family = rf_pagan
						this != scope:new_faith.religion
					}
				}
				OR = {
					any_neighboring_top_liege_realm_owner = {
						faith = scope:new_faith
					}
					any_vassal = {
						faith = scope:new_faith
					}
					any_realm_province = {
						faith = scope:new_faith
					}
					liege ?= {
						faith = scope:new_faith
					}

					liege ?= {	
						any_vassal = {
							faith = scope:new_faith
						}
					}
				}
			}
		}
		multiply = {
			value = 1 
			subtract = {
				desc = faith_conversion_cost_present
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.8
			}
		}
	}
	else_if = {
		limit = {
			scope:character = {
				OR = {
					any_neighboring_top_liege_realm_owner = {
						faith = scope:new_faith
					}
					any_vassal = {
						faith = scope:new_faith
					}
					any_realm_province = {
						faith = scope:new_faith
					}
					liege ?= {
						faith = scope:new_faith
					}

					liege ?= {	
						any_vassal = {
							faith = scope:new_faith
						}
					}
				}
			}
		}
		multiply = {
			value = 1 
			subtract = {
				desc = faith_conversion_cost_present
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.5
			}
		}
	}
	# Cheaper if you're an interloper in a struggle converting to an involved faith.
#	if = {
#		limit = {
#			scope:character = {
#				any_character_struggle = {
#					involvement = interloper
#					has_struggle_phase_parameter = cheaper_to_convert_to_struggle_faith
#					is_faith_involved_in_struggle = scope:new_faith
#				}
#			}
#		}
#		multiply = {
#			value = 1 
#			subtract = {
#				desc = struggle_parameter_cheaper_to_convert_to_struggle_faith
#				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
#				value = 0.5
#			}
#		}
#	}

	################################################
	# Conversion Discount from Confucian Education
	################################################

	if = {
		limit = {
			scope:new_faith.religion = religion:confucianism_religion
			scope:character = {
				has_trait = confucian_education
				has_trait_xp = {
					trait = confucian_education
					value >= 20 #Confused Confucian
				}
			}
		}
		if = {
			limit = {
				scope:character = {
					has_trait_xp = {
						trait = confucian_education
						value >= 80 #Moral Paragon
					}
				}
			}
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_confucian_education
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.7
				}
			}
		}
		else_if = {
			limit = {
				scope:character = {
					has_trait_xp = {
						trait = confucian_education
						value >= 60 #Virtuous Ethicist
					}
				}
			}
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_confucian_education
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.5
				}
			}
		}
		else_if = {
			limit = {
				scope:character = {
					has_trait_xp = {
						trait = confucian_education
						value >= 40 #Studious Classicist
					}
				}
			}
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_confucian_education
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.25
				}
			}
		}
		else = {
			multiply = {
				value = 1 
				subtract = {
					desc = faith_conversion_cost_confucian_education
					format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
					value = 0.1
				}
			}
		}
	}

	########################################
	# Conversion Discounts from Traditions #
	########################################
	# scope:new_faith.religion = scope:character.faith.religion

	# Pacifism Tenet
	if = {
		limit = {
			AND = {
				scope:character= {
					culture = {
						has_cultural_parameter = reduced_cost_for_conversion_to_pacifist_faith
					}
				}
				scope:new_faith = {
					has_doctrine = tenet_pacifism 
				}
			}
		}
		multiply = {
			value = 1 
			subtract = {
				desc = faith_conversion_cost_tradition
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.25
			}
		}
	}

	####################################
	# Conversion Discounts from Events #
	####################################
	if = {
		limit = {
			scope:character = {
				exists = var:discounted_faith_to_convert_to_var
			}
			scope:character.var:discounted_faith_to_convert_to_var = scope:new_faith
		}
		multiply = {
			value = 1
			subtract = {
				desc = faith_conversion_cost_event
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.5
			}
		}
	}
	if = {
		limit = {
			scope:character = {
				has_character_modifier = mpo_islam_conversion_modifier
			}
			scope:new_faith = { religion = religion:islam_religion }
		}
		multiply = {
			value = 1
			subtract = {
				desc = faith_conversion_cost_mpo_islam_event
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.25
			}
		}
	}
	if = {
		limit = {
			scope:character = {
				has_variable = japan_1010_discount
			}
			scope:new_faith = var:japan_1010_discount
		}
		multiply = {
			value = 1
			subtract = {
				desc = faith_conversion_cost_tgp_japan_1010_event
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.5
			}
		}
	}
	if = {
		limit = {
			scope:character = {
				has_character_flag = tgp_japan_1040_discount
			}
			scope:new_faith.religion = religion:shintoism_religion
		}
		multiply = {
			value = 1
			subtract = {
				desc = faith_conversion_cost_tgp_japan_1040_event
				format = "BREAKDOWN_FORMAT_PIETY_PERCENTAGE_POSITIVE_IS_BAD"
				value = 0.5
			}
		}
	}

	# Removing 1 to offset the value and present it as expected by the code
	subtract = {
		value = 1
	}

}

reincarnation_chance = 4

holy_sites_to_create_temporal_head_of_faith = 1
holy_sites_to_create_spiritual_head_of_faith = 1 

faith_military_strength = {
	every_ruler = {
		limit = {
			faith = prev
			is_at_war = no
		}
		add = max_military_strength
	}
}

syncretic_mutual_opinion_bonus_value = 30

ask_to_take_vows_piety_cost = {
	value = {
		add = medium_piety_value
		if = {
			limit = { exists = scope:actor }
			if = {
				limit = {
					OR = {
						is_child_of = scope:actor
						"scope:actor.primary_title.place_in_line_of_succession(scope:recipient)" <= 3
					}
				}
				add = major_piety_value
			}
		}
		else_if = {
			limit = { is_close_family_of = scope:actor }
			add = medium_piety_value
		}
	}
}

# Simplified target kingdom weight for crusade specifically used to send help to Byzantium (ask_western_help_decision)

great_holy_war_target_kingdom_weight_simplified = {
	# Is the target kingdom a viable GHW target?
	every_in_de_jure_hierarchy = {
		# Check individual counties within the potential target de jure kingdom.
		continue = { tier > tier_county }
		# For every county with a GHWable liege...
		limit = {
			tier = tier_county
			scope:the_faith = {
				is_hostile_enough_for_holy_war_trigger = { FAITH = prev.holder.top_liege.faith }
			}
		}
		add = 0.5
	}
	# Weight up the kingdom if it either has an existing same-faith holder, or at least a same-faith claimant.
	if = {
		limit = {
			OR = {
				AND = {
					exists = holder
					holder.faith = scope:the_faith
				}
				any_claimant = {
					exists = this
					faith = scope:the_faith
					is_available_adult = yes
				}
			}
		}
		add = ghw_target_existing_same_faith_ruler
	}
	# Christian heartlands
	if = {
		limit = {
			OR = {
				AND = {
					# Catholic sphere.
					scope:the_faith = { not_non_catholic_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_northern_italy
							geographical_region = ghw_region_france
							geographical_region = ghw_region_germany
							geographical_region = ghw_region_england
						}
					}
				}
				AND = {
					# Orthodox sphere.
					scope:the_faith = { not_non_orthodox_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_thessalonika
							geographical_region = ghw_region_greece
						}
					}
				}
				AND = {
					# Coptic sphere.
					scope:the_faith = { not_non_coptic_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = { geographical_region = ghw_region_ethiopia }
				}
				AND = {
					# Armenian sphere.
					scope:the_faith = { not_non_armenian_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = { geographical_region = ghw_region_caucasus }
				}
			}
		}
		add = ghw_target_heartlands
	}
	# Christian frontier
	else_if = {
		limit = {
			OR = {
				AND = {
					# Shared Orthodox/Armenian sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_orthodox_standard_christian_faith_trigger = yes
							not_non_armenian_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = { geographical_region = ghw_region_anatolia }
				}
				AND = {
					# Shared Catholic/Orthodox/Armenian sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_catholic_standard_christian_faith_trigger = yes
							not_non_orthodox_standard_christian_faith_trigger = yes
							not_non_armenian_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_near_east
							geographical_region = ghw_region_egypt
						}
					}
				}
				AND = {
					# Shared Catholic/Orthodox sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_catholic_standard_christian_faith_trigger = yes
							not_non_orthodox_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_mediterranean
							geographical_region = ghw_region_balkans
						}
					}
				}
				AND = {
					# Shared Catholic/Orthodox/Armenian sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_catholic_standard_christian_faith_trigger = yes
							not_non_orthodox_standard_christian_faith_trigger = yes
							not_non_armenian_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = { geographical_region = ghw_region_holy_land }
				}
				AND = {
					scope:the_faith = { not_non_catholic_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = { geographical_region = ghw_region_iberia }
				}
			}
		}
		add = ghw_target_frontier
	}
	# Christian fringe
	else_if = {
		limit = {
			OR = {
				AND = {
					scope:the_faith = { not_non_catholic_standard_christian_faith_trigger = yes }
					title_capital_county.title_province = {
						OR = {
							geographical_region = ghw_region_celtic
							geographical_region = ghw_region_germanic
							geographical_region = ghw_region_finland_&_estonia
						}
					}
				}
				AND = {
					# Shared Catholic/Orthodox sphere.
					scope:the_faith = {
						OR = {
							# Bit cack-handed to check it like this, but keeps things hygienic.
							not_non_catholic_standard_christian_faith_trigger = yes
							not_non_orthodox_standard_christian_faith_trigger = yes
						}
					}
					title_capital_county.title_province = { geographical_region = ghw_region_central_european }
				}
			}
		}
		add = ghw_target_fringe
	}
	# Christian stretch goal
	else_if = {
		limit = {
			AND = {
				scope:the_faith = {
					OR = { religion = religion:eastern_orthodox_religion religion = religion:catholic_religion religion = religion:protestant_religion }
					not_non_catholic_standard_christian_faith_trigger = yes
				}
				title_capital_county.title_province = { geographical_region = ghw_region_baltic }
			}
		}
		add = ghw_target_stretch
	}
	# Prio to kingdoms that border Byzantium
#	if = {
#		limit = {
#			title_capital_county = {
#				squared_distance = {
#					target = title:c_byzantion
#					value <= ghw_target_distance_01_threshold
#				}
#			}
#		}
#		multiply = 1.3
#	}
#	if = {
#		limit = {
#			any_title_to_title_neighboring_and_across_water_empire = {
#				this = title:e_byzantium
#			}
#		}
#		multiply = 2
#	}
	#Weight down farthest kingdoms
	if = {
		limit = {
			title_capital_county = {
				squared_distance = {
					target = title:c_byzantion
					value >= ghw_target_distance_02_threshold
				}
			}
		}
		multiply = ghw_target_distance_02_reduction
	}
	# Always weight-up kingdoms containing holy sites.
	if = {
		limit = {
			any_in_de_jure_hierarchy = {
				tier = tier_barony
				continue = { tier > tier_barony }
				is_holy_site_of = scope:the_faith
			}
		}
		multiply = ghw_target_has_holy_site
	}
	# Christian preference for Jerusalem
	if = {
		limit = {
			# Not a non-Catholic standard Christian faith.
			scope:the_faith = { not_non_catholic_standard_christian_faith_trigger = yes }
			# Definitely actually considers Jerusalem holy.
			title:c_jerusalem = {
				any_in_de_jure_hierarchy = {
					tier = tier_barony
					continue = { tier > tier_barony }
					is_holy_site_of = scope:the_faith
				}
			}
			# There's a GHWable kingdom in the area.
			title_capital_county.title_province = { geographical_region = ghw_region_jerusalem }
		}
		add = ghw_target_jerusalem
	}
	# A defender in the region HumSac'd your HoF
	if = {
		limit = {
			any_in_de_jure_hierarchy = {
				continue = { tier > tier_county }
				tier = tier_county
				holder = {
					AND = {
						has_variable_list = humsacd_hofs
						is_target_in_variable_list = {
							name = humsacd_hofs
							target = scope:the_faith
						}
					}
					scope:the_faith = {
						is_hostile_enough_for_holy_war_trigger = { FAITH = top_liege.faith }
					}
				}
			}
		}
		multiply = ghw_target_religious_vengeance
	}
}

holy_site_reform_tracker_value = {
	value = 0
	faith = {
		every_holy_site = {
			limit = {
				county = {
					save_temporary_scope_as = current_holy_site
					OR = {
						is_holy_site_controlled_by = root
						root.confederation ?= {
							is_house_based = no # any_confederation_member is not performant for house blocs
							any_confederation_member = {
								scope:current_holy_site = {
									is_holy_site_controlled_by = prev
								}
							}
						}
					}
					holder.faith = root.faith
				}
			}
			add = 1
		}
	}
}
