﻿
suitable_theocrat_sponsor_trigger = {
	faith = scope:the_faith
	is_capable_adult_ai = yes
	is_imprisoned = no
}

suitable_faith_for_undirected_ghw_trigger = {
	OR = {
		has_doctrine_parameter = great_holy_wars_active
		AND = {
			has_doctrine_parameter = great_holy_wars_active_if_reformed
			NOT = { has_doctrine_parameter = unreformed }
		}
		has_doctrine = divine_destiny_doctrine #SPECIAL: Has become the Chakravarti
	}
	has_doctrine = doctrine_spiritual_head
	NOR = {
		has_doctrine_parameter = unreformed
		AND = {
			has_doctrine = tenet_dharmic_pacifism
			NOT = { has_doctrine = divine_destiny_doctrine }
		}
		has_doctrine = tenet_pacifism
	}
	fervor >= 75
	save_temporary_scope_value_as = {
		name = faith_strength
		value = faith_military_strength
	}
	save_temporary_scope_as = faith
	any_kingdom = {
		valid_ghw_target_trigger = { FAITH = scope:faith }
	}
}

suitable_faith_for_directed_ghw_trigger = {
	OR = {
		has_doctrine = tenet_armed_pilgrimages #Catholics
		has_doctrine = tenet_struggle_submission #Islam (though, the default Faiths have Temporal Heads, so still do not qualify)
		has_doctrine = tenet_warmonger #Germanic (though, starting as Unreformed, it still doesn't qualify by default)
		has_doctrine = divine_destiny_doctrine #SPECIAL: Has become the Chakravarti
	}	
	has_doctrine = doctrine_temporal_head
	NOR = {
		has_doctrine_parameter = unreformed
		AND = {
			has_doctrine = tenet_dharmic_pacifism
			NOT = { has_doctrine = divine_destiny_doctrine }
		}
		has_doctrine = tenet_pacifism
	}
	fervor >= 75
}

suitable_faith_for_any_ghw_trigger = {
	OR = {
		has_doctrine = tenet_armed_pilgrimages #Catholics
		has_doctrine = tenet_struggle_submission #Islam (though, the default Faiths have Temporal Heads, so still do not qualify)
		has_doctrine = tenet_warmonger #Germanic (though, starting as Unreformed, it still doesn't qualify by default)
		has_doctrine = divine_destiny_doctrine #SPECIAL: Has become the Chakravarti
	}
	OR = {
		has_doctrine = doctrine_temporal_head
		has_doctrine = doctrine_spiritual_head
	}
	NOR = {
		has_doctrine_parameter = unreformed
		AND = {
			has_doctrine = tenet_dharmic_pacifism
			NOT = { has_doctrine = divine_destiny_doctrine }
		}
		has_doctrine = tenet_pacifism
	}
	fervor >= 65
}

valid_ghw_target_trigger = {
	exists = capital_vassal.capital_vassal
	any_in_de_jure_hierarchy = {
		continue = { tier > tier_county }
		tier = tier_county
		count >= 5
		$FAITH$ = {
			is_hostile_enough_for_holy_war_trigger = { FAITH = prev.holder.top_liege.faith }
		}
	}
	NOT = {
		any_in_de_jure_hierarchy = {
			continue = { tier > tier_county }
			tier = tier_county
			$FAITH$ = {
				is_hostile_enough_for_holy_war_trigger = { FAITH = prev.holder.top_liege.faith }
				prev.holder.top_liege.current_military_strength > { value = scope:faith_strength }
			}
		}
	}
}

#The Pope is getting annoyed that player hasn't joined or contributed to the Crusade yet.
ghw_pope_annoyed_at_lack_of_participation_trigger = {
	faith = scope:the_faith
	NOR = {
		this = scope:the_faith.great_holy_war.ghw_war_declarer
		has_character_flag = ghw_unpledging_cooldown
		#Has not already unpledged and been castigated for it once.
		has_character_flag = ghw_unpledged_once
		#Has not already pledged troops or money.
		has_character_flag = ghw_pledged_gold
		scope:the_faith.great_holy_war = { has_pledged_attacker = prev }
		#Do not pledge against your own liege, or when your top liege belongs to the faith being targeted.
		any_liege_or_above = {
			this = scope:the_faith.great_holy_war.ghw_target_character
		}
	}
	OR = { #Either be independent, or all lieges above you MUST be of the same Faith declaring the war to avoid messy situations of vassals and lieges fighting against each other.
		is_independent_ruler = yes
		NOT = {
			any_liege_or_above = {
				NOT = { faith = scope:the_faith }
			}
		}
	}
}
ghw_pope_annoyed_at_lack_of_participation_tier_trigger = { #Either King/Emperor, or Independent Dukes.
	OR = {
		highest_held_title_tier > 3
		AND = {
			is_independent_ruler = yes
			highest_held_title_tier >= tier_duchy
			is_landless_adventurer = no
		}
	}
}
