namespace = regula_initialize_event

regula_initialize_event.0001 = {
	type = character_event
	title = regula_initialize_event.0001.t
	desc = regula_initialize_event.0001.desc

	theme = regula_theme

	override_background = {
		event_background = regula_workshop_night
	}

	right_portrait = {
		character = root.primary_spouse
		animation = personality_zealous
	}

	immediate = {
		play_music_cue = "mx_cue_sacredrite"
		remove_character_flag = regula_decision_taken

		primary_spouse = {
			save_scope_as = domina
			add_character_flag = {
				flag = is_naked
				days = 7
			}
		}
	}

	# Become the magister
	option = {
		name = regula_initialize_event.0001.a
		show_as_tooltip = {
			add_realm_law_skip_effects = regula_magister_gender_law
		}
		set_character_faith = faith:regula_default
		add_trait = magister_2
		
		set_global_variable = {
			name = regula_initialized
			value = yes
		}
		trigger_event = {
			id = regula_initialize_event.0002
		}
	}	

	# Back out.
	option = {
		name = regula_initialize_event.0001.b	

		add_character_flag = {
			flag = regula_destroyed_character
		}

		random_secret = {
			limit = {
				secret_type = regula_covert_conversion
			}
			remove_secret = this
		}
	}

	after = {
		scope:domina = {
			remove_character_flag = is_naked
		}
	}
}

regula_initialize_event.0002 = {
	type = character_event
	title = regula_initialize_event.0002.t
	desc = regula_initialize_event.0002.desc

	theme = regula_theme

	override_background = {
		event_background = regula_kos_reborn
	}

	left_portrait = {
	}

	immediate = {
		play_music_cue = "regula_keeper_released"
		add_piety_level = -5  # Because set_piety_level doesn't exist.
		hidden_effect = { add_piety_level = 1 }

		remove_character_flag = regula_decision_taken

		set_global_variable = {
			name = regula_initialized
			value = yes
		}
		add_piety = 600
		add_prestige = 400
		hidden_effect = {
			regula_initialize_magister_effect = yes
			regula_secret_conversion_reveal_effect = yes
			scope:domina = {
				if = {
					limit = { is_landed = yes }
					remove_trait = mulsa
					add_trait = domina
					add_martial_skill = 2
					add_stewardship_skill = 2
					add_intrigue_skill = 2
					add_learning_skill = 2
					add_diplomacy_skill = 2
				}
			}
		}
	}

	option = {
		name = regula_initialize_event.0002.a
		flavor = regula_initialize_event.0002.a.tt

		custom_tooltip = regula_initialize_event.0002.a.tooltip
		hidden_effect = {
			faith:regula_default = {
				activate_holy_site = reg_jerusalem
				activate_holy_site = reg_brescia
				activate_holy_site = reg_alexandria
				activate_holy_site = reg_carthage
				activate_holy_site = reg_lesbos
		
				#Tenets
				add_doctrine = tenet_sacred_shadows
			}
		}
		add_realm_law_skip_effects = regula_magister_gender_law

		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			add_realm_law_skip_effects = regula_vassal_succession_law
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}

	option = {
		name = regula_initialize_event.0002.b
		flavor = regula_initialize_event.0002.b.tt
		custom_tooltip = regula_initialize_event.0002.b.tooltip

		hidden_effect = {
			faith:regula_default = {
			# Holy Sites
			activate_holy_site = reg_rome
			activate_holy_site = reg_toulouse
			activate_holy_site = reg_krakow
			activate_holy_site = reg_gotland
			activate_holy_site = reg_zeeland

			#Tenets
			add_doctrine = tenet_warmonger
			}
		}

		add_realm_law_skip_effects = regula_magister_gender_law

		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			add_realm_law_skip_effects = regula_vassal_succession_law
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}

	option = {
		name = regula_initialize_event.0002.c
		flavor = regula_initialize_event.0002.c.tt
		custom_tooltip = regula_initialize_event.0002.c.tooltip

		hidden_effect = {
			faith:regula_default = {
			# Holy Sites
			activate_holy_site = reg_baghdad
			activate_holy_site = reg_veria
			activate_holy_site = reg_tyre
			activate_holy_site = reg_yazd
			activate_holy_site = reg_lahur

			#Tenets
			add_doctrine = tenet_pursuit_of_power
			}
		}

		root.capital_province.county = {
			set_county_faith = faith:regula_default
		}
		add_realm_law_skip_effects = regula_magister_gender_law

		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			add_realm_law_skip_effects = regula_vassal_succession_law
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}

	option = {
		name = regula_initialize_event.0002.d
		flavor = regula_initialize_event.0002.d.tt
		custom_tooltip = regula_initialize_event.0002.d.tooltip

		hidden_effect = {
			faith:regula_default = {
			# Holy Sites
			activate_holy_site = reg_djenne
			activate_holy_site = reg_wenyon
			activate_holy_site = reg_daura
			activate_holy_site = reg_jara
			activate_holy_site = reg_oyo

			#Tenets
			add_doctrine = tenet_communal_identity
			}
		}


		add_realm_law_skip_effects = regula_magister_gender_law

		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			add_realm_law_skip_effects = regula_vassal_succession_law
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}
}


regula_initialize_event.0003 = { #Initialization of the Covert Chain
	type = character_event
	title = regula_initialize_event.0003.t
	desc = regula_initialize_event.0003.desc

	theme = realm

	override_icon = {
		reference = "gfx/interface/icons/event_types/regula_frame.dds"
	}

	override_background = {
		event_background = sitting_room
	}

	right_portrait = {
		character = root
		animation = personality_rational
	}

	immediate = {
		play_music_cue = "mx_cue_sacredrite"
		remove_character_flag = regula_decision_taken
	}

	option = {
		name = regula_initialize_event.0003.a

		regula_first_secret_conversion = yes

		set_global_variable = {
			name = regula_covert_initialized
			value = yes
		}
	}

		option = {
		name = regula_initialize_event.0003.b	# Back out.
	}
}

regula_initialize_event.0004 = { # Primary wife conversion.
	type = character_event
	title = regula_initialize_event.0004.t
	desc = regula_initialize_event.0004.desc

	theme = regula_theme

	override_background = {
		event_background = bedchamber
	}

	right_portrait = {
		character = scope:recipient
		animation = personality_forgiving
	}

	immediate = {
		play_music_cue = "regula_opening_book"
		scope:recipient = {
			regula_secret_conversion = yes
		}
	}

	option = {
		name = regula_initialize_event.0004.a
	}
}

regula_initialize_event.0005 = { # Character converted. Letter event.
	type = letter_event
	opening = {
		desc = regula_initialize_event.0005.opening
	}
	desc = regula_initialize_event.0005.desc
	sender = scope:recipient

	immediate = {
		scope:recipient = {
			regula_secret_conversion = yes
		}
	}
	
	option = {
		name = regula_initialize_event.0005.a
	}
}

regula_initialize_event.0006 = { # They ask for money.
	type = letter_event
	opening = {
		desc = regula_initialize_event.0006.opening
	}
	desc = regula_initialize_event.0006.desc
	sender = scope:recipient

	immediate = {
	}

	#Accept
	option = {
		name = regula_initialize_event.0006.a
		pay_short_term_gold = {
			target = scope:recipient
			gold = minor_gold_value
		}
		
		stress_impact = {
			greedy = minor_stress_impact_gain
		}

		scope:recipient = {
			regula_secret_conversion = yes
		}
	}

	#Refuse
	option = {
		name = regula_initialize_event.0006.b
	}

	#Use a Hook to force it through
	option = {
		name = regula_initialize_event.0006.c
		trigger = {
			has_strong_usable_hook = scope:recipient
		}
		use_hook = scope:recipient
		
		scope:recipient = {
			regula_secret_conversion = yes
		}
	}
}


regula_initialize_event.0007 = { # Character not converted. No major effect. Letter event.
	type = letter_event
	opening = {
		desc = regula_initialize_event.0007.opening
	}
	desc = regula_initialize_event.0007.desc
	sender = scope:recipient

	immediate = {
		scope:recipient = {
		}
	}
	
	option = {
		name = regula_initialize_event.0007.a
	}
}

regula_initialize_event.0008 = { # Covert secret revealed.
	type = character_event
	title = regula_initialize_event.0008.t
	desc = regula_initialize_event.0008.desc

	theme = regula_theme

	override_background = {
		event_background = corridor_night
	}

	right_portrait = {
		character = root
		animation = poison
	}

	immediate = {
		root = {
			add_piety_level = -5  # Because set_piety_level doesn't exist.
			hidden_effect = { add_piety_level = 1 }
			set_character_faith = faith:regula_default
			add_trait = magister_2
			add_trait = wounded_2
			remove_character_flag = regula_decision_taken
			capital_province.county = {
				set_county_faith = faith:regula_default
			}
		}
		regula_initialize_magister_effect = yes
		set_global_variable = {
			name = regula_initialized
			value = yes
		}
	
	}

	option = {
		name = regula_initialize_event.0002.a
		flavor = regula_initialize_event.0002.a.tt

		custom_tooltip = regula_initialize_event.0002.a.tooltip
		hidden_effect = {
			faith:regula_default = {
				activate_holy_site = reg_jerusalem
				activate_holy_site = reg_brescia
				activate_holy_site = reg_alexandria
				activate_holy_site = reg_carthage
				activate_holy_site = reg_lesbos
		
				#Tenets
				add_doctrine = tenet_sacred_shadows
			}
		}
		add_realm_law_skip_effects = regula_magister_gender_law

		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			add_realm_law_skip_effects = regula_vassal_succession_law
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}

	option = {
		name = regula_initialize_event.0002.b
		flavor = regula_initialize_event.0002.b.tt
		custom_tooltip = regula_initialize_event.0002.b.tooltip

		hidden_effect = {
			faith:regula_default = {
			# Holy Sites
			activate_holy_site = reg_rome
			activate_holy_site = reg_toulouse
			activate_holy_site = reg_krakow
			activate_holy_site = reg_gotland
			activate_holy_site = reg_zeeland

			#Tenets
			add_doctrine = tenet_warmonger
			}
		}

		add_realm_law_skip_effects = regula_magister_gender_law

		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			add_realm_law_skip_effects = regula_vassal_succession_law
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}

	option = {
		name = regula_initialize_event.0002.c
		flavor = regula_initialize_event.0002.c.tt
		custom_tooltip = regula_initialize_event.0002.c.tooltip

		hidden_effect = {
			faith:regula_default = {
			# Holy Sites
			activate_holy_site = reg_baghdad
			activate_holy_site = reg_veria
			activate_holy_site = reg_tyre
			activate_holy_site = reg_yazd
			activate_holy_site = reg_lahur

			#Tenets
			add_doctrine = tenet_pursuit_of_power
			}
		}

		root.capital_province.county = {
			set_county_faith = faith:regula_default
		}
		add_realm_law_skip_effects = regula_magister_gender_law

		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			add_realm_law_skip_effects = regula_vassal_succession_law
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}

	option = {
		name = regula_initialize_event.0002.d
		flavor = regula_initialize_event.0002.d.tt
		custom_tooltip = regula_initialize_event.0002.d.tooltip

		hidden_effect = {
			faith:regula_default = {
			# Holy Sites
			activate_holy_site = reg_djenne
			activate_holy_site = reg_wenyon
			activate_holy_site = reg_daura
			activate_holy_site = reg_jara
			activate_holy_site = reg_oyo

			#Tenets
			add_doctrine = tenet_communal_identity
			}
		}


		add_realm_law_skip_effects = regula_magister_gender_law

		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			add_realm_law_skip_effects = regula_vassal_succession_law
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}
}

regula_initialize_event.0009 = { # Maintain covert gender succession law.
	hidden = yes
	type = character_event

	trigger = {
		any_secret = {
			secret_type = regula_covert_conversion
		}
		NOT = { 
			religion = {
				is_in_family = rf_regula
			}
		}
		NOT = { has_trait = devoted_trait_group }
	}

	immediate = {
		if = {
			limit = {
				is_male = no
			}
				add_realm_law_skip_effects = regula_covert_vassal_succession_law
		}
	}
}


regula_initialize_event.0010 = { # Once more into the breach.
	type = character_event
	title = regula_initialize_event.0010.t
	desc = regula_initialize_event.0010.desc

	theme = realm

	right_portrait = {
		character = root
		animation = stress
	}

	trigger = {
		is_ai = no
		is_male = yes
		age >= 16
		has_global_variable = regula_initialized
		NOT = { has_global_variable = regula_burned }
		NOT = { 
			has_trait = magister_trait_group 
			has_character_flag = regula_destroyed_character
		}
	}

	immediate = {
		play_music_cue = "mx_cue_sacredrite"
		remove_character_flag = regula_decision_taken
	}

	option = {
		name = regula_initialize_event.0010.a
		add_piety_level = -5  # Because set_piety_level doesn't exist.
		hidden_effect = { 
			add_piety_level = 1 
			
		}
		add_trait = magister_2
		set_character_faith = global_var:magister_character.faith

		hidden_effect = {
			regula_initialize_magister_effect = yes
		}
		if = { 
			limit = { NOT = { has_realm_law = regula_magister_gender_law } }
			add_realm_law_skip_effects = regula_magister_gender_law
		}
		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			if = {
				limit = { NOT = { has_realm_law = regula_vassal_succession_law } }
				add_realm_law_skip_effects = regula_vassal_succession_law
			}
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}

	option = {
		name = regula_initialize_event.0010.b	# Disable the Magister traits.
		custom_tooltip = regula_initialize_event.0010.b.tt
		hidden_effect = {

			add_character_flag = {
				flag = regula_destroyed_character
			}
			set_global_variable = {  # Sets up a magister scope.
				name = regula_burned
				value = yes
			}
			while = {
				limit = { 
					list_size = { 
						name = regula_undying_character_list 
						value > 0 
					} 
				}
				every_in_list = {
					list = regula_undying_character_list
					remove_from_list = regula_undying_character_list
					death = {
						death_reason = death_vanished
					}
				}
			}
		}
	}
}

# Re-initializes the mod, for those that previously destroyed the book and for those on the covert chain.
regula_initialize_event.0011 = {
	type = character_event
	title = regula_initialize_event.0011.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_global_variable = regula_initialized
				}
				desc = regula_initialize_event.0011.burned_desc
			}
			desc = regula_initialize_event.0011.covert_desc
		}
	}
	theme = realm

	override_background = {
		event_background = study
	}

	right_portrait = {
		character = root
		animation = personality_rational
	}

	immediate = {
		remove_character_flag = regula_decision_taken
	}

	option = { # Become a Magister.
		trigger = { has_global_variable = regula_initialized }
		name = regula_initialize_event.0011.a
		add_piety_level = -5  # Because set_piety_level doesn't exist.
		hidden_effect = { 
			add_piety_level = 1 
		}
	
		add_trait = magister_2 
		set_character_faith = global_var:magister_character.faith

		hidden_effect = {
			regula_initialize_magister_effect = yes
		}

		remove_global_variable = regula_burned
		if = { 
			limit = { NOT = { has_realm_law = regula_magister_gender_law } }
			add_realm_law_skip_effects = regula_magister_gender_law
		}
		every_vassal = {
			limit = {
				highest_held_title_tier >= tier_county
			}
			if = {
				limit = { NOT = { has_realm_law = regula_vassal_succession_law } }
				add_realm_law_skip_effects = regula_vassal_succession_law
			}
		}
		trigger_event = {
			on_action = regula_initialize_complete_response
		}
	}

	option = { # Burn it.
		name = regula_initialize_event.0011.b	
		custom_tooltip = regula_initialize_event.0011.b.tt
		trigger = { has_global_variable = regula_initialized }
		hidden_effect = {
			add_character_flag = {
				flag = regula_destroyed_character
			}
			every_in_global_list = {
				list = regula_undying_character_list
				death = {
					death_reason = death_vanished
				}
			}
		}
	}


	option = { # Gain the Conversion Secret
		trigger = { NOT = { has_global_variable = regula_initialized } }
		name = regula_initialize_event.0011.c	

		regula_secret_reboot = yes

	}

	option = { # Set it aside.
		trigger = { NOT = { has_global_variable = regula_initialized } }
		name = regula_initialize_event.0011.d	

		hidden_effect = {
			add_character_flag = {
				flag = regula_destroyed_character
			}
			every_in_global_list = {
				list = regula_undying_character_list
				death = {
					death_reason = death_vanished
				}
			}
		}
	}
}

# Remove magister traits from characters that no longer follow the religion.
regula_initialize_event.0012 = {
	type = character_event
	hidden = yes

	trigger = {
		has_trait = magister_trait_group
		faith = {
			NOT = { has_doctrine_parameter = magister_tenet_traits }
		}		
	}

	immediate = {
		if = {
			limit = {
				has_trait = magister_2
			}
			remove_trait = magister_2
			add_trait = magister_1
		}
		if = {
			limit = {
				has_trait = magister_3
			}
			remove_trait = magister_3
			add_trait = magister_1
		}
		if = {
			limit = {
				has_trait = magister_4
			}
			remove_trait = magister_4
			add_trait = magister_1
		}
		if = {
			limit = {
				has_trait = magister_5
			}
			remove_trait = magister_5
			add_trait = magister_1
		}
		if = {
			limit = {
				has_trait = magister_6
			}
			remove_trait = magister_6
			add_trait = magister_1
		}
	}
}

# Keep the Compeditae Election humming
regula_initialize_event.0013 = {
	type = character_event
	hidden = yes

	trigger = {
		is_ai = no
		any_held_title = {
			has_title_law = compeditae_elective_succession_law
		}
	}

	immediate = {
		every_held_title = {
			limit = {
				NOT = { this = root.primary_title }
				is_titular = no
				NOR = { 
					has_title_law = compeditae_lower_title_succession_law
					has_title_law = compeditae_elective_succession_law
				}
			}
			add_title_law = compeditae_lower_title_succession_law
		}
		if = {
			limit = {
				NOT = { has_character_modifier = regula_compeditae_succession_modifier }
			}
			add_character_modifier = regula_compeditae_succession_modifier
		}
	}
}

# Settings Menu
regula_initialize_event.1000 = {
	type = character_event
	title = regula_initialize_event.1000.t
	desc = regula_initialize_event.1000.desc

    theme = regula_theme

    override_background = {
		event_background = throne_room
	}

	# option = { # Tweak Suggestions Tab
	# 	name = regula_initialize_event.1000.a

	# 	trigger_event = {
	# 		id = regula_initialize_event.1001
	# 	}
	# }
	
	option = { # Religion
		name = regula_initialize_event.1000.b

		trigger = {
			religion = {
				is_in_family = rf_regula
			}
		}

		trigger_event = {
			id = regula_initialize_event.1010
		}
	}

	# option = { # Birth Control
	# 	name = regula_initialize_event.1000.c

	# 	trigger_event = {
	# 		id = regula_childhood_event.0020
	# 	}
	# }


	option = { # Wards 
		name = regula_initialize_event.1000.d

		trigger_event = {
			id = regula_childhood_event.0010
		}
	}

	option = { # Stats
		name = regula_initialize_event.1000.e

		trigger_event = {
			id = regula_initialize_event.1003
		}
	}

	option = { # Exit
		name = regula_initialize_event.1000.exit
	}
}


# Tweak Suggestions Tab
regula_initialize_event.1001 = {
	type = character_event
	title = regula_initialize_event.1001.t
	desc = regula_initialize_event.1001.desc
    theme = regula_theme

    override_background = {
		event_background = throne_room
	}

	option = {
		name = regula_initialize_event.1001.a

	
		trigger_event = {
			id = regula_initialize_event.1002
		}
	}

	
	option = {
		name = regula_initialize_event.1001.menu
		trigger_event = {
			id = regula_initialize_event.1000
		}
	}

	option = {
		name = regula_initialize_event.1001.exit
	}
}

# Suggestions Tab - Dominate Mulsa Suggestion
regula_initialize_event.1002 = {
	type = character_event
	title = regula_initialize_event.1002.t
	desc = regula_initialize_event.1002.desc
    theme = regula_theme

    override_background = {
		event_background = throne_room
	}

	immediate = {
	}

	# Dominate all
	option = {
		name = regula_initialize_event.1002.a
		flavor = regula_initialize_event.1002.a.tt

		set_global_variable = {
			name = action_regula_make_paelex_value
            value = flag:all
		}
	}

	# Direct Vassals
	option = {
		name = regula_initialize_event.1002.b

		set_global_variable = {
			name = action_regula_make_paelex_value
            value = flag:direct
		}
	}

	# Hide the suggestion	
	option = {
		name = regula_initialize_event.1002.c

		set_global_variable = {
			name = action_regula_make_paelex_value
            value = flag:none
		}
	}	

	option = {
		name = regula_initialize_event.1001.menu
		trigger_event = {
			id = regula_initialize_event.1000
		}
	}

	option = {
		name = regula_initialize_event.1001.exit
	}
}

# Stats
regula_initialize_event.1003 = {
	type = character_event
	title = regula_initialize_event.1003.t
	desc = regula_initialize_event.1003.desc

	right_portrait = {
		character = root
		animation = personality_rational
	}

	theme = regula_theme
	override_background = {
		event_background = throne_room
	}
	
	immediate = {
		global_var:regula_secret_keeper = {
			save_scope_as = dead_baby
			random_targeting_secret = {
				limit = {
					secret_type = regula_covert_conversion
					secret_owner = {
						is_male = yes
					}
				}
				save_scope_as = regula_secret
				scope:regula_secret.secret_owner = {
					save_scope_as = proto_magister
				}
			}
			every_targeting_secret = {
				reveal_to = scope:proto_magister
			}
		}
	}


	option = {
		name = regula_initialize_event.1001.menu
		trigger_event = {
			id = regula_initialize_event.1000
		}
	}

	option = {
		name = regula_initialize_event.1001.exit
	}
}


# Swap religion types.
regula_initialize_event.1010 = {
	type = character_event
	title = regula_initialize_event.1010.t
	desc = regula_initialize_event.1010.desc
    theme = regula_theme

    override_background = {
		event_background = throne_room
	}

	option = {
		name = regula_initialize_event.1010.a

		# faith = {
		# 	save_scope_as = old_faith
		# }
		# set_character_faith = faith:regula_default
		# # First, make sure everyone is the default faith (for backwards compatibility).
		# if = {
		# 	limit = {
		# 		NOT = {
		# 			scope:old_faith = faith:regula_default
		# 		}
		# 	}
		# 	if = {
		# 		limit = {
		# 			exists = faith.religious_head
		# 			root = faith.religious_head
		# 		}
		# 		faith = {
		# 			remove_religious_head_title = yes
		# 		}
		# 		set_character_faith = faith:regula_default
		# 		hidden_effect = {
		# 			regula_faith_swap = yes
					
		# 		}
		# 	}
		# 	else = {
		# 		hidden_effect = {
		# 			regula_faith_swap = yes
		# 		}
		# 	}
	
		# }
		# Now swap holy sites.
		faith = {
			hidden_effect = {
				regula_holy_site_deactivation = yes
				if = {
					limit = { has_doctrine = tenet_warmonger }
					remove_doctrine = tenet_warmonger
				}
				if = {
					limit = { has_doctrine = tenet_communal_identity }
					remove_doctrine = tenet_communal_identity
				}
				if = {
					limit = { has_doctrine = tenet_pursuit_of_power }
					remove_doctrine = tenet_pursuit_of_power
				}
				if = {
					limit = { NOT = { has_doctrine = tenet_sacred_shadows } }
					add_doctrine = tenet_sacred_shadows
				}
			}
			# Holy Sites
			activate_holy_site = reg_jerusalem
			activate_holy_site = reg_brescia
			activate_holy_site = reg_alexandria
			activate_holy_site = reg_carthage
			activate_holy_site = reg_lesbos
		}
		trigger_event = {
			id = regula_initialize_event.1000
		}
	}

	option = {
		name = regula_initialize_event.1010.b

		# faith = {
		# 	save_scope_as = old_faith
		# }
		# set_character_faith = faith:regula_default
		# # First, make sure everyone is the default faith (for backwards compatibility).
		# if = {
		# 	limit = {
		# 		NOT = {
		# 			scope:old_faith = faith:regula_default
		# 		}
		# 	}
		# 	if = {
		# 		limit = {
		# 			exists = faith.religious_head
		# 			root = faith.religious_head
		# 		}
		# 		faith = {
		# 			remove_religious_head_title = yes
		# 		}
		# 		set_character_faith = faith:regula_default
		# 		hidden_effect = {
		# 			regula_faith_swap = yes
					
		# 		}
		# 	}
		# 	else = {
		# 		hidden_effect = {
		# 			regula_faith_swap = yes
		# 		}
		# 	}
	
		# }
		# Now swap holy sites.
		faith = {
			hidden_effect = {
				regula_holy_site_deactivation = yes
				if = {
					limit = { has_doctrine = tenet_sacred_shadows }
					remove_doctrine = tenet_sacred_shadows
				}
				if = {
					limit = { has_doctrine = tenet_pursuit_of_power }
					remove_doctrine = tenet_pursuit_of_power
				}
				if = {
					limit = { has_doctrine = tenet_communal_identity }
					remove_doctrine = tenet_communal_identity
				}
				if = {
					limit = { NOT = { has_doctrine = tenet_warmonger } }
					add_doctrine = tenet_warmonger
				}
			}
			# Holy Sites
			activate_holy_site = reg_rome
			activate_holy_site = reg_toulouse
			activate_holy_site = reg_krakow
			activate_holy_site = reg_gotland
			activate_holy_site = reg_zeeland

		}
		trigger_event = {
			id = regula_initialize_event.1000
		}
	}

	option = {
		name = regula_initialize_event.1010.c

		faith = {
			hidden_effect = {
				regula_holy_site_deactivation = yes
				if = {
					limit = { has_doctrine = tenet_sacred_shadows }
					remove_doctrine = tenet_sacred_shadows
				}
				if = {
					limit = { has_doctrine = tenet_warmonger }
					remove_doctrine = tenet_warmonger
				}
				if = {
					limit = { has_doctrine = tenet_communal_identity }
					remove_doctrine = tenet_communal_identity
				}
				if = {
					limit = { NOT = { has_doctrine = tenet_pursuit_of_power } }
					add_doctrine = tenet_pursuit_of_power
				}
			}
			# Holy Sites
			activate_holy_site = reg_baghdad
			activate_holy_site = reg_veria
			activate_holy_site = reg_tyre
			activate_holy_site = reg_yazd
			activate_holy_site = reg_lahur
		}
		trigger_event = {
			id = regula_initialize_event.1000
		}
	}


	option = {
		name = regula_initialize_event.1010.d

		faith = {
			hidden_effect = {
				regula_holy_site_deactivation = yes
				if = {
					limit = { has_doctrine = tenet_sacred_shadows }
					remove_doctrine = tenet_sacred_shadows
				}
				if = {
					limit = { has_doctrine = tenet_warmonger }
					remove_doctrine = tenet_warmonger
				}
				if = {
					limit = { has_doctrine = tenet_pursuit_of_power }
					remove_doctrine = tenet_pursuit_of_power
				}
				if = {
					limit = { NOT = { has_doctrine = tenet_communal_identity } }
					add_doctrine = tenet_communal_identity
				}
			}
			# Holy Sites
			activate_holy_site = reg_djenne
			activate_holy_site = reg_wenyon
			activate_holy_site = reg_daura
			activate_holy_site = reg_jara
			activate_holy_site = reg_oyo
		}
		trigger_event = {
			id = regula_initialize_event.1000
		}
	}

	option = {
		name = regula_initialize_event.1010.menu
		trigger_event = {
			id = regula_initialize_event.1000
		}
	}

	option = {
		name = regula_initialize_event.1010.exit
	}
}

regula_initialize_event.1030 = {
	type = character_event

	title = regula_initialize_event.1030.t
	desc = regula_initialize_event.1030.desc

	theme = regula_theme
	override_background = {
		event_background = throne_room
	}

	left_portrait = {
		character = root
		animation = personality_bold
	}

	trigger = {
	}

	immediate = {
		play_music_cue = "mx_cue_epic_sacral_moment"
	}

	option = {
		name = regula_initialize_event.1030.a
		
		primary_title = {
			add_title_law = compeditae_elective_succession_law
		}
		if = {
			limit = {
				NOT = { has_character_modifier = regula_compeditae_succession_modifier }
			}
			add_character_modifier = regula_compeditae_succession_modifier
		}
		hidden_effect = {
			every_held_title = {
				limit = {
					NOT = { this = root.primary_title }
					is_titular = no
				}
				add_title_law = compeditae_lower_title_succession_law
			}
		}
	}
}