﻿# Determines if a faith can be created, on top of the piety requirement, and the doctrine requirements
# Also handles reforming a faith, check for the unreformed doctrine to enable those additional checks
# Root is the faith creator
faith_creation = {
	trigger_if = {
		limit = {
			highest_held_title_tier = tier_county
			top_liege != this
		}
		custom_description = {
			text = "faith_creation_duchy_or_higher"
			highest_held_title_tier >= tier_duchy
		}
	}

	is_adult = yes
	is_at_war = no
	# Head of faith check disabled by mod
	#custom_description = {
	#	text = "character_is_not_real_head"
	#	faith.religious_head != root
	#}

	custom_description = {
		text = "character_can_only_create_one_faith"
		NOT = { exists = var:has_created_a_faith }
	}

	trigger_if = {
		limit = {
			faith = { has_doctrine_parameter = unreformed }
		}

		NOT = {
			custom_description = {
				text = faith_has_been_reformed
				object = faith
				exists = faith.var:has_been_reformed
			}
		}

		trigger_if = {
			limit = {
				NOT = {
					has_character_flag = ignore_3_holy_site_rule
				}
			}
			faith = {
				num_realm_holy_sites_faithful_holders = {
					CHARACTER = root
					COUNT = 3
				}
			}
		}

		custom_tooltip = {
			text = faith_reformation_via_decision
			faith = {
				NOT = { has_variable = block_reformation_var }
			}
		}
	}
}