﻿# Converts a character to the regula faith, always secretly.
#
# FAITH = the regula faith which the character is converting to
# scope = the character to convert
convert_to_regula_secretly_effect = {
	# Remove all vanilla crypto religionist secrets.
	every_secret = {
		limit = {
			secret_type = secret_crypto_religionist
		}
		remove_secret = yes
	}

	set_character_secret_faith = $FAITH$

	# - Add regula crypto religion secret
	if = {
		limit = {
			NOT = {
				any_secret = {
					secret_type = regula_crypto_religionist_secret
				}
			}
		}

		add_secret = {
			type = regula_crypto_religionist_secret
		}
	}
}

# Converts a character to the regula faith, either openly if they have no
# reason to hide the conversion, or secretly if they do.
#
# TODO: This should maybe be probabalistic if they do have a reason to
# hide, based on ai zeal or something?
#
# FAITH = the regula faith which the character is converting to
# scope = the character to convert
convert_to_regula_openly_or_secretly_effect = {
	if = {
		limit = {
			has_reason_to_hide_regula_faith_trigger = yes
		}

		convert_to_regula_secretly_effect = {
			FAITH = $FAITH$
		}
		regula_forge_inheritance_law_success_effect = yes
	}
	else = {
		set_character_faith = $FAITH$

		# Clear non-regula secret faiths if the charcter is charmed.
		if = {
			limit = {
				exists = secret_faith
				is_crypto_regula_trigger = no
				is_regula_devoted_trigger = yes
			}
			remove_character_secret_faith = yes
		}
	}
}

# If the currently scoped character is crypto regula, openly convert the
# character to their secret faith, forcibly.
#
# scope = the character to convert
regula_force_convert_to_secret_faith_effect = {
	if = {
		limit = {
			is_crypto_regula_trigger = yes
		}

		set_character_faith = secret_faith
		remove_character_secret_faith = yes
	}
}

# If the currently scoped character is crypto regula, openly convert the
# character to their secret faith if they no longer believe they need to hide
# it.
#
# TODO: This should maybe be probabalistic if they do still have a reason to
# hide, based on ai zeal or something? e.g. High zeal may reveal even if there
# is a reason to stay hidden.
#
# scope = the character to convert
regula_maybe_convert_to_secret_faith_effect = {
	if = {
		limit = {
			is_crypto_regula_trigger = yes
			has_reason_to_hide_regula_faith_trigger = no
		}

		set_character_faith = secret_faith
		remove_character_secret_faith = yes
	}
}
