code:
## regula_astringere_interaction
## regula_astringere_activation_interaciton
## regula_astringere_removal_interaction
## regula_bestow_titles_interaction
## regula_titulum_novis_interaction
## regula_break_betrothal_courtier_interaction
## regula_covert_conversion_interaction
## regula_divorce_courtier_interaction
## regula_enact_abice_maritus_interaction
## regula_fascinare_scheme_interaction
## regula_forge_inheritance_law_interaction
## regula_form_alliance_interaction
## regula_join_servitude_war_interaction
## regula_make_paelex_interaction
## regula_mutare_corpus_interaction
## regula_promote_paelex_interaction (deprecated)
## regula_demote_domina_interaction (deprecated)
## regula_potestas_non_transfunde_interaction
## regula_prisoner_interaction
## regula_sanctifica_serva_interaction
## regula_take_orba_interaction
## debug interactions

regula_astringere_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	interface_priority = 90

	desc = regula_astringere_interaction_desc

	cost = {
		piety = 150
	}
	is_shown = {
		scope:recipient = {
			has_trait = devoted_trait_group
			NOT = { has_trait = sigillum }
			is_imprisoned = no # Alternate event for Magister's captives.
		}
		scope:actor = {
			has_trait = magister_trait_group
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_3_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 3
				}
			}
		}
	}

	auto_accept = yes

	on_accept = {
		show_as_tooltip = {
			scope:recipient = {
				add_trait = sigillum
				add_stress = medium_stress_gain
			}
			scope:actor = {
				add_hook = {
					target = scope:recipient
					type = regula_sigillum_hook
				}
				add_tyranny = 3
				add_dread = 5
			}
		}
		scope:actor = {
			trigger_event = {
				id = regula_astringere_outcome_event.1001
				days = { 7 14 }
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

regula_astringere_activation_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	interface_priority = 63

	desc = regula_astringere_activation_interaction_desc

	is_shown = {
		scope:recipient = {
			has_trait = devoted_trait_group
			has_trait = sigillum
			OR = {
				is_imprisoned = no
				is_imprisoned_by = scope:actor
			}
		}
		scope:actor = {
			has_trait = magister_trait_group
			NOT = { has_strong_hook = scope:recipient }
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_2_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 2
				}
			}
		}
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			add_hook_no_toast = {
				target = scope:recipient
				type = regula_sigillum_hook
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

regula_astringere_removal_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	interface_priority = 75

	desc = regula_astringere_removal_interaction_desc

	is_shown = {
		scope:recipient = {
			has_trait = devoted_trait_group
			has_trait = sigillum
			OR = {
				is_imprisoned = no # Alternate event for Magister's captives.
				is_imprisoned_by = scope:actor
			}
		}
		scope:actor = {
			has_trait = magister_trait_group
		}
	}

	auto_accept = yes

	on_accept = {
		scope:recipient = {
			remove_trait = sigillum
			add_stress = minor_stress_loss
		}
		scope:actor = {
			remove_hook = {
				target = scope:recipient
				type = regula_sigillum_hook
			}
			add_piety = 75
		}
	}

	ai_will_do = {
		base = 0
	}
}

regula_bestow_titles_interaction = {

	category = interaction_category_religion
	common_interaction = yes
	desc = regula_bestow_titles_interaction_desc

	auto_accept = yes

	target_type = title
	target_filter = actor_domain_titles

	is_shown = {
		scope:actor = {
			any_secret = {
				secret_type = regula_covert_conversion
			}
		}
		NOT = {
			scope:actor.faith = {
				has_dominant_ruling_gender = scope:recipient
			}
		}
		scope:recipient = {
			is_landed = no
			OR = {
				# is_vassal_or_below_of = scope:actor
				# primary_spouse = scope:actor
				liege = {
					OR = {
						is_vassal_or_below_of = scope:actor
						this = scope:actor
					}
				}
				AND = {
					is_in_the_same_court_as_or_guest = scope:actor
					is_imprisoned = no
				}
			}
		}
	}

	cost = {
		prestige = 50
		piety = 150
	}

	on_accept = {
		custom_tooltip = regula_bestow_titles_interaction_tooltip

		scope:recipient = {
			create_title_and_vassal_change = {
				type = conquest
				save_scope_as = change
				add_claim_on_loss = yes
			}
			scope:target = {
				change_title_holder_include_vassals = {
					holder = scope:recipient
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
			add_opinion = {
				target = scope:actor
				modifier = received_title_barony
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

# Revoke Title
regula_titulum_novis_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	notification_text = REVOKE_TITLE_PROPOSAL

	desc = regula_titulum_novis_interaction_desc

	special_interaction = revoke_title_interaction
	interface = revoke_title
	target_type = title
	target_filter = recipient_domain_titles
	can_send_despite_rejection = yes
	popup_on_receive = yes
	pause_on_receive = yes
	icon = revoke_title

	interface_priority = 60
	ai_min_reply_days = 4
	ai_max_reply_days = 9

	# actor character giving the titles
	# recipient character receiving the titles
	auto_accept = yes

	is_shown = {
		scope:actor = {
			has_trait = magister_trait_group
		}
		scope:recipient = {
			is_landed = yes
			# should be shown but be disabled for indirect vassals
			target_is_liege_or_above = scope:actor
			# is_vassal_of = scope:actor
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOR =  {
				is_at_war_with = scope:recipient
			}
		}
		scope:recipient = {
			has_trait = devoted_trait_group
			is_vassal_of = scope:actor
			is_busy_in_events_localised = yes
		}
		scope:actor = {
			custom_description = {
				text = magister_trait_4_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 4
				}
			}
		}
	}

	can_send = {
		scope:actor = {
			custom_description = {
				text = "character_interactions_hostile_actions_disabled_delay"
				NOT = { has_character_flag = flag_hostile_actions_disabled_delay }
			}
		}
	}

	# Highlighted in the interaction menu when right-clicking a character
	is_highlighted = {
		OR = {
			scope:actor = {
				has_revoke_title_reason = scope:recipient
			}
			scope:recipient = {
					any_held_title = {
					scope:actor = {
						has_claim_on = prev
					}
				}
				NOT = {
					any_ally = {
						this = scope:actor
					}
				}
			}
		}
	}

	can_be_picked_title = {
		scope:actor = {
			piety >= scope:target.regula_titulum_novis_cost
		}
		scope:target = {
			is_contested = no
		}
	}

	send_options_exclusive = no

	on_send = {
		scope:actor = {
			add_character_flag = {
				flag = flag_hostile_actions_disabled_delay
				days = 10
			}
		}
	}

	on_accept = {
		regula_titulum_novis_interaction_effect = yes

		save_scope_value_as = {
			name = revoke_title_interaction
			value = yes
		}

		scope:actor = {
			trigger_event = regula_interaction_event.0001
		}

		if = {
			limit = {
				scope:actor = { has_character_flag = flag_hostile_actions_disabled_delay }
			}
			scope:actor = { remove_character_flag = flag_hostile_actions_disabled_delay }
		}
	}

	ai_will_do = {
		base = 0
	}
}

# regula_bestow_titles_interaction = {

# 	category = interaction_category_religion
# 	common_interaction = yes
# 	desc = regula_bestow_titles_interaction_desc

# 	auto_accept = yes

# 	is_shown = {
# 		scope:actor = {
# 			any_secret = {
# 				secret_type = regula_covert_conversion
# 			}
# 		}
# 		NOT = {
# 			scope:actor.faith = {
# 				has_dominant_ruling_gender = scope:recipient
# 			}
# 		}
# 		scope:recipient = {
# 			is_landed = no
# 			OR = {
# 				# is_vassal_or_below_of = scope:actor
# 				# primary_spouse = scope:actor
# 				liege = {
# 					OR = {
# 						is_vassal_or_below_of = scope:actor
# 						this = scope:actor
# 					}
# 				}
# 				AND = {
# 					is_in_the_same_court_as_or_guest = scope:actor
# 					is_imprisoned = no
# 				}
# 			}
# 		}
# 	}

# 	is_valid_showing_failures_only = {
# 		scope:actor = {
# 			custom_description = {
# 				text = regula_bestow_barony_required_trigger
# 				any_held_title = {
# 					tier = tier_barony
# 					title_province = {
# 						OR = {
# 							has_holding_type = castle_holding
# 							has_holding_type = city_holding
# 						}
# 					}
# 					can_be_leased_out = yes
# 				}
# 			}
# 		}
# 	}

# 	cost = {
# 		prestige = 50
# 		piety = 150
# 	}

# 	on_accept = {
# 		custom_tooltip = regula_bestow_titles_interaction_tooltip

# 		scope:recipient = {
# 			create_title_and_vassal_change = {
# 				type = conquest
# 				save_scope_as = change
# 				add_claim_on_loss = yes
# 			}
# 			scope:actor = {
# 				random_held_title = {
# 					limit = {
# 						tier = tier_barony
# 						title_province = {
# 							OR = {
# 								has_holding_type = castle_holding
# 								has_holding_type = city_holding
# 							}
# 						}
# 						can_be_leased_out = yes
# 					}
# 					change_title_holder_include_vassals = {
# 						holder = scope:recipient
# 						change = scope:change
# 					}
# 				}
# 			}
# 			resolve_title_and_vassal_change = scope:change
# 			add_opinion = {
# 				target = scope:actor
# 				modifier = received_title_barony
# 			}
# 		}
# 	}

# 	ai_will_do = {
# 		base = 0
# 	}
# }

regula_break_betrothal_courtier_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	interface_priority = 98

	desc = regula_divorce_courtier_interaction_desc

	cost = {
		piety = 50
	}
	is_shown = {
		scope:recipient = {
			has_trait = devoted_trait_group
			is_imprisoned = no # Alternate event for Magister's captives.
			is_betrothed = yes
			is_ruler = no
		}
		scope:actor = {
			has_trait = magister_trait_group
		}
		NOT = {
			scope:recipient.betrothed = scope:actor
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_3_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 3
				}
			}
		}
	}

	auto_accept = yes

	on_accept = {
		custom_tooltip = regula_break_betrothal_courtier_interaction_tooltip
		scope:recipient = {
			break_betrothal = scope:recipient.betrothed
		}
	}

	ai_will_do = {
		base = 0
	}
}

regula_covert_conversion_interaction = {
	category = interaction_category_religion
	common_interaction = yes

	interface_priority = 20

	ai_maybe = yes
	ai_min_reply_days = 21
	ai_max_reply_days = 45
	can_send_despite_rejection = yes
	ai_accept_negotiation = yes
	popup_on_receive = yes

	desc = {
		desc = regula_covert_conversion_interaction_desc
		desc = line_break
		triggered_desc = {
			trigger = {
				NOT = { scope:recipient = { is_imprisoned_by = scope:actor } }
			}
			desc = might_ask_for_something_in_return_warning
		}
	}

	is_shown = {
		scope:actor = {
			is_ai = no
			any_secret = {
				secret_type = regula_covert_conversion
			}
		}

		scope:recipient = {
			is_male = no
			is_adult = yes
			OR = {
				# is_vassal_or_below_of = scope:actor
				# primary_spouse = scope:actor
				liege = {
					OR = {
						is_vassal_or_below_of = scope:actor
						this = scope:actor
					}
				}
				AND = {
					is_in_the_same_court_as_or_guest = scope:actor
					is_imprisoned = no
				}
			}
		}
	}

	is_valid = {
		NOT = { scope:recipient = scope:actor }
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			custom_description = {
				text = regula_already_spellbound_trigger
				NOT = {
					any_secret = {
						secret_type = regula_covert_conversion
					}
				}
			}
		}
	}

	cost = {
		prestige = 50
	}

	on_decline_summary = stop_attacker_vassal_war_decline_summary

	cooldown_against_recipient = { months = 6 }

	auto_accept = {
		custom_description = {
			text = "spending_hook"
			subject = scope:actor
			object = scope:recipient
			scope:hook = yes
			scope:actor = { has_strong_hook = scope:recipient }
		}
	}

	on_send = {
	}

	redirect = {
		scope:recipient = {
			save_scope_as = target
		}
	}

	on_accept = {
		custom_tooltip = regula_covert_conversion_interaction_tooltip
		scope:actor = {
			if = {
				limit = {
					primary_spouse = scope:recipient
				}
				trigger_event = {
					id = regula_initialize_event.0004
				}
			}
			else = {
				trigger_event = {
					id = regula_initialize_event.0005
				}
			}
		}
	}

	on_decline = {
		scope:recipient = {
			hidden_effect = {
				random_list = {
					80 = { # They ask for gold.
						ai_value_modifier = {
							ai_greed = 0.5
						}
						modifier = {
							add = 50 # More likely to ask for gold if they're poor
							scope:recipient.short_term_gold < medium_gold_value
						}
						modifier = {
							add = { # Much more likely to ask for gold involved in one of their own wars (they want to win).
								value = 50
								if = {
									# Especially true if they're in debt!
									limit = { gold < 0 }
									add = 150
								}
							}
							is_at_war = yes
							any_character_war = {
								is_war_leader = scope:recipient
							}
						}

						scope:actor = {
							if = {
								limit = {
									scope:recipient.primary_spouse = scope:actor
								}
								trigger_event = {
									id = regula_initialize_event.0004
								}
							}
							else = {
								trigger_event = {
									id = regula_initialize_event.0006
								}
							}
						}
					}
					20 = { # Full refuse
						modifier = {
							add = 10
							has_trait = impatient
						}
						modifier = {
							add = 20
							has_trait = shy
						}
						modifier = {
							add = 20
							has_trait = reclusive
						}
						modifier = {
							add = 10
							has_trait = lazy
						}
						scope:actor = {
							trigger_event = {
								id = regula_initialize_event.0007
							}
						}
					}
					5 = { # They sound the alarm
						modifier = {
							add = 10
							has_trait = deceitful
						}
						modifier = {
							add = 10
							has_trait = paranoid
						}
						modifier = {
							add = 10
							has_trait = celibate
						}
						modifier = {
							add = 25
							has_trait = crusader_king
						}
						scope:actor = {
							random_secret = {
								limit = {
									secret_owner = scope:actor
									secret_type = regula_covert_conversion
								}
								expose_secret = scope:recipient
							}
						}
					}
				}
			}
			custom_tooltip = regula_covert_conversion_interaction_failure
			show_as_tooltip = {
				#Negative opinions
				add_opinion = {
					target = scope:actor
					modifier = regula_covert_conversion_interaction_failure_opinion
				}
			}
		}
	}

	# Use hook
	send_option = {
		is_valid = {
			scope:actor = {
				has_usable_hook = scope:recipient
			}
			NOT = {
				scope:recipient = { is_imprisoned_by = scope:actor }
			}
		}
		flag = hook
		localization = SCHEME_HOOK
	}
	# should_use_extra_icon = {
	# 	scope:actor = { has_usable_hook = scope:recipient }
	# }
	extra_icon = "gfx/interface/icons/character_interactions/hook_icon.dds"

	send_options_exclusive = no

	ai_will_do = {
		base = 0
	}

	ai_accept = {
		base = 25

		#Diplomacy based
		compare_modifier = {
			desc = "sway_my_diplomacy"
			target = scope:actor
			value = diplomacy
			multiplier = 4
		}

		modifier = {
			desc = "SCHEME_SCHEMER_TRAIT"
			scope:actor = { has_trait = seducer }
			add = 25
		}

		#Beauty good
		modifier = {
			desc = "scheme_beauty_good_1"
			scope:actor = { has_trait = beauty_good_1 }
			add = 10
		}
		modifier = {
			desc = "scheme_beauty_good_2"
			scope:actor = { has_trait = beauty_good_2 }
			add = 15
		}
		modifier = {
			desc = "scheme_beauty_good_3"
			scope:actor = { has_trait = beauty_good_3 }
			add = 20
		}

		#Physique good
		modifier = {
			desc = "scheme_physique_good_1"
			scope:actor = { has_trait = physique_good_1 }
			add = 5
		}
		modifier = {
			desc = "scheme_physique_good_2"
			scope:actor = { has_trait = physique_good_2 }
			add = 10
		}
		modifier = {
			desc = "scheme_physique_good_3"
			scope:actor = { has_trait = physique_good_3 }
			add = 15
		}

		#Beauty bad
		modifier = {
			desc = "scheme_beauty_bad_1"
			scope:actor = { has_trait = beauty_bad_1 }
			add = -10
		}
		modifier = {
			desc = "scheme_beauty_bad_2"
			scope:actor = { has_trait = beauty_bad_2 }
			add = -15
		}
		modifier = {
			desc = "scheme_beauty_bad_3"
			scope:actor = { has_trait = beauty_bad_3 }
			add = -20
		}

		modifier = {
			desc = "SCHEME_BEFRIEND_MY_GREGARIOUSNESS"
			scope:actor = { has_trait = gregarious }
			add = 25
		}

		#Sexuality
		modifier = {
			desc = "SCHEME_SEDUCE_WRONG_GENDER"
			scope:actor = {
				NOR = {
					is_attracted_to_gender_of = scope:recipient
					has_perk = unshackled_lust_perk # Removed by the Unshackled Lust Perk
				}
			}
			add = -25
		}

		#TARGET#
		#Lustful/hedonist
		modifier = {
			desc = "SCHEME_REVELER"
			scope:recipient = { has_trait = lifestyle_reveler }
			add = 15
		}
		modifier = {
			desc = "SCHEME_LUSTFUL_TRAIT"
			scope:recipient = { has_trait = lustful }
			add = 30
		}
		modifier = {
			desc = "REGULA_SCHEME_SEDUCER_TRAIT"
			scope:recipient = { has_trait = seducer }
			add = 50
		}

		modifier = {
			desc = "SCHEME_BEFRIEND_THEIR_GREGARIOUSNESS"
			scope:actor = { has_trait = gregarious }
			add = 50
		}

		#Chaste/shy
		modifier = {
			desc = "SCHEME_CHASTE_TRAIT"
			scope:recipient = { has_trait = chaste }
			add = -10
		}
		modifier = {
			desc = "SCHEME_SHY_TRAIT"
			scope:recipient = { has_trait = shy }
			add = -20
		}
		modifier = {
			desc = "REGULA_SCHEME_RECLUSIVE_TRAIT"
			scope:recipient = { has_trait = reclusive }
			add = 50
		}

		#Opinion of actor
		opinion_modifier = {
			desc = regula_covert_conversion_interaction_their_opinion
			who = scope:recipient
			opinion_target = scope:actor
			min = -25
			max = 25
			multiplier = 0.75
		}

		#Target is actor's spouse
		modifier = { #
			trigger = { scope:actor = { is_consort_of = scope:recipient } }
			scope:recipient = {
				NOT = { has_relation_rival = scope:actor }
			}
			add = 25
			desc = "SCHEME_SEDUCE_SPOUSE_BONUS"
		}
		#Target is actor's lover.
		modifier = {
			add = 50
			has_relation_lover = scope:recipient
			desc = "HAS_RELATION_LOVER_WITH_TARGET"
		}
		#Target is actor's soulmate.
		modifier = {
			add = 75
			has_relation_soulmate = scope:recipient
			desc = "HAS_RELATION_SOULMATE_WITH_TARGET"
		}
		#Target is actor's friend.
		modifier = {
			add = 25
			has_relation_friend = scope:recipient
			desc = "HAS_RELATION_FRIEND_WITH_TARGET"
		}
		#Target is actor's best friend.
		modifier = {
			add = 50
			has_relation_best_friend = scope:recipient
			desc = "HAS_RELATION_BEST_FRIEND_WITH_TARGET"
		}
		#Target is actor's rival.
		modifier = {
			add = -25
			has_relation_rival = scope:recipient
			desc = "HAS_RELATION_RIVAL_WITH_TARGET"
		}
		#Target is actor's nemesis.
		modifier = {
			add = -50
			has_relation_nemesis = scope:recipient
			desc = "HAS_RELATION_NEMESIS_WITH_TARGET"
		}
		#Trait similarity to actor
		compatibility_modifier = {
			who = scope:recipient
			compatibility_target = scope:actor
			min = -15
			max = 30
			multiplier = 2
		}

		#Rank tier difference (landed target/target whose liege doesn't care)
		modifier = { #3 or more higher rank
			trigger = { scope:actor = { NOT = { is_consort_of = scope:recipient } } } # Your spouse doesn't care if you're a different rank than them.
			add = 40
			desc = "HIGHER_RANK_THAN_SCHEME_TARGET"
			scope:recipient = {
				personal_scheme_success_compare_target_liege_tier_trigger = no
				NOT = {
					is_theocratic_lessee = yes
				}
			}
			scope:actor = {
				tier_difference = {
					target = scope:recipient
					value >= 3
				}
			}
		}
		modifier = { #2 higher rank
			trigger = { scope:actor = { NOT = { is_consort_of = scope:recipient } } } # Your spouse doesn't care if you're a different rank than them.
			add = 20
			desc = "HIGHER_RANK_THAN_SCHEME_TARGET"
			scope:recipient = {
				personal_scheme_success_compare_target_liege_tier_trigger = no
				NOT = {
					is_theocratic_lessee = yes
				}
			}
			scope:actor = {
				tier_difference = {
					target = scope:recipient
					value = 2
				}
			}
		}
		modifier = { #1 higher rank
			trigger = { scope:actor = { NOT = { is_consort_of = scope:recipient } } } # Your spouse doesn't care if you're a different rank than them.
			add = 10
			desc = "HIGHER_RANK_THAN_SCHEME_TARGET"
			scope:recipient = {
				personal_scheme_success_compare_target_liege_tier_trigger = no
				NOT = {
					is_theocratic_lessee = yes
				}
			}
			scope:actor = {
				tier_difference = {
					target = scope:recipient
					value = 1
				}
			}
		}

		#Extra rank bonus/penalty if target is arrogant/ambitious
		modifier = {
			trigger = { scope:actor = { NOT = { is_consort_of = scope:recipient } } } # No 'social climbing' if you're already their spouse!
			desc = SCHEME_SOCIAL_CLIMBER_RANK_BONUS
			add = 20
			scope:recipient = {
				OR = {
					has_trait = arrogant
					has_trait = ambitious
					has_trait = greedy
				}
				NOT = {
					is_theocratic_lessee = yes
				}
			}
			OR = {
				AND = {
					scope:recipient = { personal_scheme_success_compare_target_liege_tier_trigger = yes }
					scope:actor.highest_held_title_tier > scope:recipient.liege.highest_held_title_tier
				}
				AND = {
					scope:recipient = { personal_scheme_success_compare_target_liege_tier_trigger = no }
					scope:actor.highest_held_title_tier > scope:recipient.highest_held_title_tier
				}
			}
		}
		modifier = {
			trigger = { scope:actor = { NOT = { is_consort_of = scope:recipient } } } # No 'social climbing' if you're already their spouse!
			desc = regula_covert_conversion_interaction_social_climber_rank_penalty
			add = -10
			scope:recipient = {
				OR = {
					has_trait = arrogant
					has_trait = ambitious
					has_trait = greedy
				}
			}
			OR = {
				AND = {
					scope:recipient = { personal_scheme_success_compare_target_liege_tier_trigger = yes }
					scope:actor.highest_held_title_tier < scope:recipient.liege.highest_held_title_tier
				}
				AND = {
					scope:recipient = { personal_scheme_success_compare_target_liege_tier_trigger = no }
					scope:actor.highest_held_title_tier < scope:recipient.highest_held_title_tier
				}
			}
		}

		# Dynasty Kin Personal Scheme Success Chance on Dynasty Perk
		modifier = {
			add = kin_legacy_4_success_chance
			desc = KIN_LEGACY_DESC
			exists = scope:actor.dynasty
			scope:actor.dynasty = {
				has_dynasty_perk = kin_legacy_4
			}
			scope:recipient.dynasty = scope:actor.dynasty
		}

		# Thicker Than Water Perk
		modifier = {
			add = thicker_than_water_bonus
			desc = BEFRIEND_THICKER_THAN_WATER_PERK_DESC
			scope:actor = {
				has_perk = thicker_than_water_perk
			}
			scope:recipient = {
				is_close_or_extended_family_of = scope:actor
			}
		}

		modifier = {
			desc = might_ask_for_something_in_return_warning_line_break
			add = 0
		}
	}
}

regula_divorce_courtier_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	interface_priority = 85

	desc = regula_divorce_courtier_interaction_desc

	cost = {
		piety = 100
	}
	is_shown = {
		scope:recipient = {
			has_trait = devoted_trait_group
			is_imprisoned = no # Alternate event for Magister's captives.
			is_married = yes
			is_ruler = no
			NOT = {
				scope:recipient.primary_spouse = scope:actor
			}
		}
		scope:actor = {
			has_trait = magister_trait_group
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_3_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 3
				}
			}
		}
		custom_description = {
			text = regula_courtier_spouse_ruler_trigger
			scope:recipient = {
				AND = {
					is_married = yes
					scope:recipient.primary_spouse = {
						is_ruler = no
					}
				}
			}
		}
	}

	auto_accept = yes

	on_accept = {
		custom_tooltip = regula_divorce_courtier_interaction_tooltip
		scope:recipient = {
			every_spouse = {
				scope:recipient = {
					divorce = prev
				}
				if = {
					limit = {
						has_relation_lover = scope:recipient
					}
					lover_breakup_effect = {
						BREAKER = scope:recipient
						LOVER = this
					}
					set_relation_rival = scope:recipient
				}
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

# Trigger title transfer to wife.
regula_enact_abice_maritus_interaction = {
	interface_priority = 100
	category = interaction_category_religion
	common_interaction = yes
	desc = regula_enact_abice_maritus_interaction_desc

	use_diplomatic_range = yes
	ignores_pending_interaction_block = yes

	is_shown = {
		NOT = { scope:recipient = scope:actor }
		scope:actor = {
			has_trait = magister_trait_group
		}
		scope:recipient = {
			faith = { religion_tag = regula_religion }
			is_ruler = no
			is_married = yes
			is_imprisoned = no
			is_male = no
			scope:recipient.primary_spouse = {
				is_ruler = yes
			}
			NOT = { is_consort_of = scope:actor }
			scope:recipient.primary_spouse = {
				NOT = { # Can't become head of a holy order. Mercenary company OK.
					any_held_title = {
						is_holy_order = yes
					}
				}
			}
		}
	}

	cost = {
		piety = regula_abice_maritus_cost
		desc = CB_SIZE_OF_TARGET_REALM_COST
	}

	is_valid_showing_failures_only = {
		global_var:magister_character = {
			piety >= regula_abice_maritus_cost
		}
	}

	auto_accept = yes

	on_accept = {
		scope:recipient.primary_spouse = {
			create_title_and_vassal_change = {
				type = conquest
				save_scope_as = change
				add_claim_on_loss = no
			}
			every_held_title = {
				change_title_holder_include_vassals = {
					holder = scope:recipient
					change = scope:change
				}
			}
			resolve_title_and_vassal_change = scope:change
			if = {
				limit = { gold > 0 }
				pay_short_term_gold = {
					target = scope:recipient
					gold = scope:recipient.primary_spouse.gold
				}
			}
		}

		scope:recipient.primary_spouse = {
			scope:recipient = {
				if = {
					limit = {
						scope:recipient.top_liege = { # This is going to be of limited utility for foreign Mulsa.
							any_vassal_or_below = {
								has_government = theocracy_government
								primary_title.tier > tier_barony
								faith = scope:actor.faith
							}
						}
					}
					scope:recipient.top_liege = {
						random_vassal_or_below = {
							limit = {
								has_government = theocracy_government
								primary_title.tier > tier_barony
								faith = scope:actor.faith
							}
							save_scope_as = theocratic_travel_target
						}
					}
					visit_court_of = scope:theocratic_travel_target
				}
				else_if = {
					limit = {
						exists = scope:recipient.capital_province
					}
					move_to_pool_at = scope:recipient.capital_province
				}
				kick_from_court_interaction_warning_tooltip_effect = yes
			}
			scope:recipient.primary_spouse = {
				add_opinion = {
					modifier = demanded_taking_vows
					target = scope:recipient
				}
				add_trait = devoted
				add_piety_level = 1
				if = {
					limit = { is_ruler = yes }
					depose = yes
				}
				if = {
					limit = {
						is_married = yes
					}
					every_spouse = {
						divorce = scope:recipient.primary_spouse
					}
				}
				if = {
					limit = {
						exists = betrothed
					}
					break_betrothal = betrothed
				}
				if = {
					limit = {
						is_concubine = yes
					}
					this.concubinist = {
						remove_concubine = scope:recipient.primary_spouse
					}
				}
				if = {
					limit = {
						number_of_concubines > 0
					}
					every_concubine = {
						scope:recipient = {
							remove_concubine = prev
						}
					}
				}
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

# Start fascinare scheme.
regula_fascinare_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	scheme = regula_fascinare
	interface_priority = 150

	cost = {
		piety = 100
	}

	send_name = START_FASCINARE
	common_interaction = yes
	ignores_pending_interaction_block = yes

	desc = regula_fascinare_interaction_desc

	ai_frequency = 24 # Every 2 years.

	is_shown = {
		scope:actor = {
			is_ai = no  # Turned off for AI.  See corresponding AI character interaction instead.
			OR = {
				has_trait = magister_trait_group
				AND = {
					OR = {
						has_trait = paelex
						has_trait = mulsa
						has_trait = domina
					}
					scope:actor.faith = {
						controls_holy_site_with_flag = holy_site_reg_mulsa_fascinare_flag
					}
				}
			}
		}
		scope:recipient = {
			is_adult = yes
			is_male = no
			NOR = {
				has_trait = paelex
				has_trait = mulsa
				has_trait = domina
				has_trait = contubernalis
				has_trait = orba
			}
			is_imprisoned = no
		}
	}

	is_valid = {
		NOT = { scope:recipient = scope:actor }
		scope:actor = {
			OR = {
				has_trait = magister_trait_group
				has_trait = devoted_trait_group
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_2_required_trigger
				NOT = { has_trait = magister_1 }
			}
		}
	}

	on_accept = {
		scope:actor = {
			hidden_effect = {
				send_interface_toast = {
					title = regula_fascinare_interaction_toast
					left_icon = scope:actor
					right_icon = scope:recipient

					start_scheme = {
						target = scope:recipient
						type = regula_fascinare
					}
				}
			}
		}
	}

	ai_potential = {
		NOR = {
			any_scheme = {
				OR = {
					scheme_type = seduce
					scheme_type = regula_fascinare
				}
			}
		}
	}

	ai_targets = {
		ai_recipients = realm_characters # limited by is_shown to members of their court.
		max = 10
	}
	ai_targets = {
		ai_recipients = guests
		ai_recipients = courtiers
	}

	ai_targets = {
		ai_recipients = dynasty
	}

	ai_target_quick_trigger = {
		adult = yes
		attracted_to_owner = yes
		owner_attracted = yes
	}

	auto_accept = yes

	ai_will_do = {
		base = 0
		# base = 50

		# modifier = {
		# 	factor = 0.5
		# 	scope:actor = {
		# 		opinion = {
		# 			target = scope:recipient
		# 			value < -50
		# 		}
		# 	}
		# }

		# modifier = {
		# 	factor = 2
		# 	scope:recipient = {
		# 		opinion = {
		# 			target = scope:actor
		# 			value > 50
		# 		}
		# 	}
		# }

		# modifier = {
		# 	add = 50
		# 	has_focus = diplomacy_family_focus
		# }

		# modifier = {
		# 	factor = 2
		# 	scope:recipient.liege = scope:actor
		# }

		# modifier = { # Focus should be away from the converted.
		# 	factor = 0.1
		# 	scope:recipient.faith = scope:actor.faith
		# }

		# modifier = {
		# 	factor = 0.25
		# 	scope:actor = {
		# 		is_ruler = yes
		# 		tier_difference = {
		# 			target = scope:recipient
		# 			value > 2
		# 		}
		# 	}
		# }
		# modifier = {
		# 	add = 25
		# 	scope:actor = {
		# 		has_trait = lustful
		# 	}
		# }

		# modifier = {
		# 	add = 15
		# 	scope:actor = {
		# 		is_attracted_to_women = yes
		# 	}
		# }

		# modifier = {
		# 	add = 20
		# 	scope:actor = {
		# 		OR = {
		# 			has_trait = gregarious
		# 			has_trait = diplomat
		# 			has_trait = family_first
		# 			has_trait = august
		# 		}
		# 	}
		# }

		# modifier = {
		# 	factor = 2
		# 	scope:actor = {
		# 		is_child_of = scope:recipient
		# 	}
		# }

		# modifier = { # Besties first.
		# 	factor = 25
		# 	scope:actor = {
		# 		OR = {
		# 			has_relation_friend = scope:recipient
		# 			has_relation_lover = scope:recipient
		# 			has_relation_soulmate = scope:recipient
		# 		}
		# 	}
		# }

		# modifier = {
		# 	factor = 2
		# 	scope:actor = { #Friends of friends
		# 		any_relation = {
		# 			type = friend
		# 			any_relation = {
		# 				type = friend
		# 				this = scope:recipient
		# 			}
		# 		}
		# 	}
		# }
		# modifier = {
		# 	factor = 4
		# 	scope:recipient = {
		# 		is_claimant = yes
		# 	}
		# }
		# modifier = {
		# 	factor = 10
		# 	scope:recipient = {
		# 		is_landed = yes
		# 	}
		# }
	}
}

regula_forge_inheritance_law_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	scheme = regula_forge_inheritance_law
	interface_priority = 100

	cost = {
		gold = 75
		prestige = 125
	}

	send_name = START_REGULA_FORGE_INHERITANCE_LAW
	common_interaction = yes
	ignores_pending_interaction_block = yes

	desc = regula_forge_inheritance_law_interaction_desc

	ai_frequency = 0 # Every 2 years.

	is_shown = {
		scope:actor = {
			is_ai = no
			any_secret = {
				secret_type = regula_covert_conversion
			}
		}

		scope:recipient = {
			is_ruler = yes
			OR = {
				liege = {
					OR = {
						is_vassal_or_below_of = scope:actor
						this = scope:actor
					}
				}
			}
			NOR = {
				has_realm_law = regula_covert_vassal_succession_law
			}
			NOT = { has_realm_law = bishop_theocratic_succession_law }
			NOT = {  # The law is applied by default when a character's primed.
				any_secret = {
					secret_type = regula_covert_conversion
				}
			}
		}
	}

	is_valid = {
		NOT = { scope:recipient = scope:actor }
	}

	is_valid_showing_failures_only = {
	}

	on_accept = {
		scope:actor = {
			hidden_effect = {
				send_interface_toast = {
					title = regula_forge_inheritance_law_interaction_toast
					left_icon = scope:actor
					right_icon = scope:recipient

					start_scheme = {
						target = scope:recipient
						type = regula_forge_inheritance_law
					}
				}
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 0
	}
}

# Ally to a foreign ruler.
regula_form_alliance_interaction = {
	category = interaction_category_diplomacy
	common_interaction = yes

	ai_min_reply_days = 4
	ai_max_reply_days = 9

	send_name = regula_form_alliance_interaction

	interface_priority = 180
	desc = regula_form_alliance_interaction_desc

	greeting = positive
	notification_text = NEGOTIATE_ALLIANCE_NOTIFICATION

	is_shown = {
		exists = scope:actor.faith.religious_head
		NOR = {
			scope:actor = scope:recipient
			scope:actor.faith.religious_head = scope:recipient
		}
		scope:actor.faith = {
			this = scope:recipient.faith
		}
		scope:actor.faith.religious_head = scope:actor
		scope:recipient = {
			NOT = { this = scope:actor }
			NOT = { is_allied_to = scope:actor }
			is_ruler = yes
			is_independent_ruler = yes
			is_male = no
			highest_held_title_tier >= 2
		}
		scope:actor = {
			is_ruler = yes
			faith = {
				religion_tag = regula_religion
			}
			OR = {
				is_ai = no
				highest_held_title_tier >= 2
			}
			tier_difference = {
					target = scope:recipient
					value >= 0
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			is_landed = yes
			is_imprisoned = no
		}
		scope:actor = {
			is_landed = yes
			is_imprisoned = no
			NOT = {
				is_at_war_with = scope:recipient
			}
			scope:actor = {
				custom_description = {
					text = magister_trait_4_required_trigger
					has_trait_rank = {
						trait = magister_trait_group
						rank >= 4					}
				}
			}
		}
		scope:recipient = { is_available = yes }
	}

	cost = {
		prestige = 250
	}

	on_auto_accept = {

	}

	on_accept = {
		save_scope_value_as = { #So that we can show the opinion gain in the response event
			name = perk_alliance_interaction
			value = yes
		}
		scope:recipient = {

		}

		#Set up alliance, because of Pontifex Carnalis interactions
		scope:actor = {
			custom_tooltip = negotiate_alliance_effect_recipient_tooltip
			trigger_event = regula_alliance_event.0001
			create_alliance = {
				target = scope:recipient
				allied_through_owner = scope:actor
				allied_through_target = scope:recipient
			}
		}
		scope:recipient = { # This opinion modifier controls the interaction, and is removed when breaking the alliance in any way (though on_actions)
			add_opinion = {
				modifier = perk_negotiated_alliance_opinion
				target = scope:actor
			}
		}
	}

	on_decline = {

	}

	auto_accept = yes

	ai_will_do = 0
}

# Join an ongoing servitude war.
regula_join_servitude_war_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	interface = interfere_in_war
	special_interaction = interfere_in_war_interaction
	popup_on_receive = yes
	desc = regula_join_servitude_war_interaction_desc

	greeting = positive
	notification_text = regula_join_servitude_war_interaction_notification

	is_shown = {
		scope:actor = {
			has_trait = magister_trait_group
			NOT = { is_at_war_with = scope:recipient }
		}

		scope:recipient = {
			is_leading_faction_type = regula_servitude_faction
			NOT = {
				any_ally = {
					has_trait = magister_trait_group
				}
			}
		}
		scope:recipient.liege = {
			any_targeting_faction = {
				faction_is_type = regula_servitude_faction
				faction_is_at_war = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			NOT = { has_truce = scope:recipient }
		}
	}

	can_be_picked = {
		exists = scope:target
		scope:target = {
			is_war_leader = scope:recipient
			is_defender = scope:recipient.liege
			primary_attacker = {
				is_leading_faction_type = regula_servitude_faction
			}
		}

		joiner_not_already_in_another_war_with_any_target_war_participants_trigger = {
			WARRIOR = scope:recipient
			JOINER = scope:actor
		}

		can_join_war_liege_vassal_check_trigger = { WARRIOR = scope:recipient JOINER = scope:actor }
	}

	on_accept = {
		scope:target = {
			if = {
				limit = {
					is_attacker = scope:recipient
				}
				add_attacker = scope:actor
			}
			else = {
				add_defender = scope:actor
			}
		}
		scope:actor = {
			stress_impact = {
				craven = medium_stress_impact_gain
				shy = minor_stress_impact_gain
			}
		}
	}

	on_decline = {
		scope:actor = {
			trigger_event = char_interaction.0236
		}
	}

	auto_accept = yes

	ai_accept = {
		base = 100 # everyone wants help
	}
}

### Make landed vassal a paelex.
regula_make_paelex_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	desc = regula_make_paelex_interaction_desc
	interface_priority = 20

	is_shown = {
		scope:actor = {
			has_trait = magister_trait_group
		}
		scope:recipient = {
			is_ai = yes
			has_trait = devoted_trait_group
			is_vassal_or_below_of = scope:actor
			NOT = { scope:recipient = scope:actor }
			NOR = {
				has_trait = paelex
				has_trait = domina
				has_trait = contubernalis
				has_trait = orba
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_2_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 2
				}
			}
		}
		scope:recipient = {
			highest_held_title_tier >= tier_county
			is_imprisoned = no #Will make alternate event for this.
		}
	}

	auto_accept = yes

	on_accept = {
		scope:recipient = {
			remove_trait = mulsa
			set_character_faith = global_var:magister_character.faith
			every_relation = {
				type = lover
				limit = { NOT = { has_trait = magister_trait_group } }
				lover_breakup_effect = {
					BREAKER = scope:recipient
					LOVER = this
				}
			}
		}
		if = { # Redirect towards spouse event(s).
			limit = {
				OR = {
					scope:actor.primary_spouse = scope:recipient
				}
			}
			scope:recipient = {
				add_trait_force_tooltip = domina
			}
			scope:actor = {
				hidden_effect = {
					every_spouse = {
						remove_opinion = {
							modifier = polygamous_marriage_opinion
							target = scope:actor
						}
					}
				}
				trigger_event = {
					id = regula_paelex_event.2000
				}
			}
		}
		else_if = { # Redirect towards spouse event(s).
			limit = {
				scope:actor = {
					is_married = no
				}
			}
			regula_make_paelex_interaction_effect = yes
			scope:recipient = {
				add_trait_force_tooltip = domina
			}
			scope:actor = {
				marry = scope:recipient
				hidden_effect = {
					every_spouse = {
						remove_opinion = {
							modifier = polygamous_marriage_opinion
							target = scope:actor
						}
					}
				}
				trigger_event = {
					id = regula_paelex_event.2000
				}
			}
		}
		else = { # Default events.
			regula_make_paelex_interaction_effect = yes
			scope:recipient = {
				add_trait_force_tooltip = paelex
			}
			scope:actor = {
				marry = scope:recipient
				trigger_event = {
					on_action = regula_paelex_event_on_action
				}
				hidden_effect = {
					every_spouse = {
						remove_opinion = {
							modifier = polygamous_marriage_opinion
							target = scope:actor
						}
					}
				}
			}
		}
	}
	ai_will_do = {
		base = 0
	}
}

# Spend piety to improve your devoted
regula_mutare_corpus_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	desc = regula_mutare_corpus_interaction_desc
	interface_priority = 21

	cooldown = { years = 3 }

	is_shown = {
		scope:actor = {
			has_trait = magister_trait_group
		}
		scope:recipient = {
			is_ai = yes
			has_trait = devoted_trait_group
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_2_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 2
				}
			}
		}
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			trigger_event = {
				id = regula_mutare_corpus_event.0001
			}
		}
		scope:recipient = {
			custom_tooltip = regula_mutare_corpus_interaction_tooltip
		}
	}

	cost = {
		piety = regula_mutare_corpus_interaction_piety_cost
	}

	ai_will_do = {
		base = 0
	}
}

# regula_promote_paelex_interaction = {  ### No longer required, as concubines aren't a thing anymore.
# 	category = interaction_category_religion
# 	desc = regula_promote_paelex_interaction_desc
# 	interface_priority = 60

# 	is_shown = {
# 		scope:actor = {
# 			has_trait = magister_trait_group
# 			age >= 16
# 		}
# 		scope:recipient = {
# 			is_ai = yes
# 			has_trait = paelex
# 			is_concubine_of = scope:actor
# 			NOT = { scope:recipient = scope:actor }
# 		}
# 	}

# 	cooldown = { months = 6 }

# 	is_valid_showing_failures_only = {
# 		scope:recipient = {
# 			is_available = yes
# 			is_imprisoned = no
# 		}
# 	}

# 	auto_accept = yes

# 	on_accept = {
# 		scope:actor = {
# 			if = {
# 				limit = {
# 					is_married = yes
# 				}
# 				regula_promote_paelex_divorce_effect = yes
# 			}
# 			marry = scope:recipient
# 		}
# 		scope:recipient = {
# 			remove_trait = paelex
# 			add_trait = domina
# 			hidden_effect = {
# 					remove_opinion = { # This modifier autoadds if the religion doesn't have the base concubines doctrine.
# 					modifier = spouse_does_not_believe_in_concubines_opinion
# 					target = scope:actor
# 				}
# 			}
# 		}
# 	}

# 	ai_will_do = {
# 		base = 0
# 	}
# }

# regula_demote_domina_interaction = {  ### No longer required.
# 	category = interaction_category_religion
# 	desc = regula_demote_domina_interaction_desc
# 	interface_priority = 60

# 	is_shown = {
# 		scope:actor = {
# 			has_trait = magister_trait_group
# 		}
# 		scope:recipient = {
# 			is_ai = yes
# 			has_trait = domina
# 			is_spouse_of = scope:actor
# 			is_concubine = no
# 			NOT = { scope:recipient = scope:actor }
# 		}
# 	}

# 	is_valid_showing_failures_only = {
# 		scope:recipient = { is_available = yes }
# 	}

# 	auto_accept = yes

# 	on_accept = {
# 		hidden_effect = {
# 			scope:actor = {
# 				divorce = scope:recipient
# 				make_concubine = scope:recipient
# 			}
# 		}
# 		scope:recipient = {
# 			remove_trait = domina
# 			add_trait = paelex
# 		}
# 		scope:actor = {
# 			reverse_add_opinion = {
# 				modifier = demoted_domina_opinion
# 				target = scope:recipient
# 			}
# 		}
# 	}
# 	ai_will_do = {
# 		base = 0
# 	}
# }

regula_potestas_non_transfunde_interaction = {
	category = interaction_category_religion ### vassalage?
	common_interaction = yes
	interface_priority = 60
	desc = regula_potestas_non_transfunde_interaction_desc

	is_shown = {
		exists = scope:actor.faith.religious_head
		NOR = {
			scope:actor = scope:recipient
			scope:actor.faith.religious_head = scope:recipient
		}
		scope:actor.faith = {
			this = scope:recipient.faith
		}
		scope:actor.faith.religious_head = scope:actor
		scope:actor.highest_held_title_tier > scope:recipient.highest_held_title_tier

		scope:recipient = {
			is_male = no  # Leaving the door open for futas, etc.
			is_independent_ruler = yes
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = { # Show this or not?
			prestige >= scope:recipient.regula_potestas_non_transfunde_cost
		}
		scope:recipient = { # Vassalization target
			age >= 16
		}
		scope:actor = {
			NOT = {
				is_at_war_with = scope:recipient
			}
		}
		scope:recipient = { ### UPDATE - This doesn't work, for some reason.
			character_is_realm_neighbor = scope:actor
		}
		scope:recipient = { is_available = yes }
		scope:recipient = { NOT = { has_strong_hook = scope:actor } }
	}

	cost = {
		prestige = scope:recipient.regula_potestas_non_transfunde_cost
	}

	auto_accept = yes

	on_accept = {
		custom_tooltip = regula_potestas_non_transfunde_interaction_tooltip
		create_title_and_vassal_change = {
			type = swear_fealty
			save_scope_as = change
		}
		scope:recipient = {
			change_liege = {
				liege = scope:actor
				change = scope:change
			}
		}
		resolve_title_and_vassal_change = scope:change
		if = {
			limit = {
				scope:recipient = {
					highest_held_title_tier = tier_kingdom
				}
			}
			change_global_variable = {
				name = regula_potestas_queen_tally
				add = 1
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

regula_prisoner_interaction = {
	category = interaction_category_prison
	common_interaction = yes
	interface_priority = 25

	desc = regula_prisoner_interaction_desc

	is_shown = {
		scope:recipient = {
			is_male = no
			is_imprisoned_by = scope:actor
			age >= 16
		}
		scope:actor = {
			has_trait = magister_trait_group
		}
	}

	auto_accept = yes

	on_accept = {
		scope:actor = {
			trigger_event = {
				id = regula_prisoner_event.1000
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

### Create Avatar
regula_sanctifica_serva_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	desc = regula_sanctifica_serva_interaction_desc
	interface_priority = 20

	is_shown = {
		scope:actor = {
			has_trait = magister_trait_group
			faith = {
				controls_holy_site_with_flag = holy_site_reg_sanctifica_serva_flag
			}
		}
		scope:recipient = {
			OR = {
				has_trait = paelex
				has_trait = domina
			}
			is_immortal = no
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_4_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 4
				}
			}
			custom_description = {
				text = sanctifica_serva_health_trigger
				health >=4
			}
			custom_description = {
				text = sanctifica_serva_in_progress_trigger
				NOT = { has_variable = regula_sanctifica_serva_in_progress }
			}
		}
	}

	auto_accept = yes

	on_accept = {
		custom_tooltip = regula_sanctifica_serva_interaction_tooltip
		scope:actor = {
			set_variable = regula_sanctifica_serva_in_progress
			trigger_event = {
				id = regula_holy_site_event.1001
				days = { 2 7 }
			}
		}
	}
	ai_will_do = {
		base = 0
	}
}

regula_summon_to_court_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	desc = regula_summon_to_court_interaction_desc
	interface_priority = 18
#	icon = "gfx/interface/icons/character_interactions/regula_character_interaction.dds"

	is_shown = {
		scope:recipient = {
			has_trait = devoted_trait_group
			NOR = {
				is_courtier_of = scope:actor
				is_foreign_court_guest = yes
				AND = {
					exists = host
					host = scope:actor
				}
				is_ruler = yes
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_3_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 3
				}
			}
		}
		scope:recipient = {
			# custom_description = {
			# 	text = regula_courtier_spouse_ruler_trigger
			# 	scope:recipient = {
			# 		OR = {
			# 			is_married = no
			# 			AND = {
			# 				is_married = yes
			# 				scope:recipient.primary_spouse = {
			# 					is_ruler = no
			# 				}
			# 			}
			# 		}
			# 	}
			# }
			NOR = {
				custom_description = {
					text = is_not_wandering_child
					subject = scope:recipient
					OR = {
						AND = {
							is_adult = no
							is_pool_character = no
						}
						AND = {
							is_adult = no
							NOT = { is_close_or_extended_family_of = scope:actor }
						}
					}
				}
				is_imprisoned = yes
				is_theocratic_lessee = yes
				trigger_if = {
					limit = { exists = host }
					is_consort_of = host
				}
				trigger_if = {
					limit = { exists = host }
					host = {
						pressing_claim_of_character_trigger = { CHARACTER = scope:recipient }
					}
				}
			}
		}
	}

	cost = {
		piety = {
			if = {
				limit = {
					scope:recipient = {
						OR = {
							has_opinion_modifier = {
								modifier = attempted_imprisonment_opinion
								target = scope:actor
							}
							has_opinion_modifier = {
								modifier = treasonous_imprison_refusal
								target = scope:actor
							}
							AND = {
								exists = var:escaped_imprisonment_from
								var:escaped_imprisonment_from = scope:actor
							}
						}
					}
				}
				value = 250
			}
			else = {
				value = 125
			}
		}
	}

	on_accept = {
		custom_tooltip = regula_summon_to_court_interaction_tooltip
		hidden_effect = {
			if = {
				limit = {
					exists = scope:recipient.liege
				}
				scope:recipient.liege = {
					send_interface_message = {
						type = event_generic_neutral
						title = msg_courtier_left_court_interaction_title

						right_icon = scope:recipient

						show_as_tooltip = {
							remove_courtier_or_guest = scope:recipient
						}
					}
				}
			}
		}

		scope:actor = {
			send_interface_message = {
				type = event_generic_neutral
				title = invite_to_court_interaction_notification
				right_icon = scope:recipient

				scope:recipient = {
					every_traveling_family_member = {
						scope:actor = { recruit_courtier = prev }
						hidden_effect = {
							return_to_court = yes
						}
					}
				}

				scope:actor = {
					stress_impact = {
						shy = minor_stress_impact_gain
						chaste = medium_stress_impact_gain
						paranoid = medium_stress_impact_gain
						lustful = minor_stress_impact_loss
						gregarious = minor_stress_impact_loss
					}
				}
			}
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 0
	}
}

regula_take_orba_interaction = {
	category = interaction_category_religion
	common_interaction = yes
	desc = regula_take_orba_interaction_desc
	interface_priority = 150

	is_shown = {
		scope:actor = {
			has_trait = magister_trait_group
		}
		scope:recipient = {
			is_ai = yes
			has_trait = orba
			NOT = { scope:recipient = scope:actor }
		}
	}

	is_valid_showing_failures_only = {
		scope:actor = {
			custom_description = {
				text = magister_trait_2_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 2
				}
			}
		}
		scope:recipient = {
			highest_held_title_tier >= tier_county
			is_imprisoned = no #Will make alternate event for this.
			OR = {
				is_concubine = no
				is_consort_of = scope:actor
			}
		}
	}

	auto_accept = yes

	on_accept = {
		regula_make_paelex_interaction_effect = yes
		scope:recipient = {
			remove_trait = orba
			add_trait_force_tooltip = paelex
			every_relation = {
				type = lover
				limit = { NOT = { this = scope:actor } }
				lover_breakup_effect = {
					BREAKER = scope:recipient
					LOVER = this
				}
			}
		}
		scope:actor = {
			marry = scope:recipient
			add_piety = 50
			hidden_effect = {
				every_spouse = {
					remove_opinion = {
						modifier = polygamous_marriage_opinion
						target = scope:actor
					}
				}
			}
		}
	}
	ai_will_do = {
		base = 0
	}
}

#### Debug Interactions ####

#Expose covert secret
regula_expose_covert_character_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	interface_priority = -1

	is_shown = {
		debug_only = yes
	}

	on_accept = {
		random_independent_ruler = {
			save_scope_as = rando
		}
		scope:recipient = {
			random_secret = {
				limit = {
					secret_type = regula_covert_conversion
				}
				expose_secret = scope:rando
			}
		}
	}
	auto_accept = yes
}

# Gene testing
regula_gene_mod = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes
	is_shown = {
		debug_only = yes
		NOT = { scope:recipient = scope:actor }
	}

	on_accept = {
		scope:recipient = {
			add_character_flag = {
				flag = dna_change_example_modifier
			}
		}
	}

	auto_accept = yes
}

# Start fascinare scheme.
regula_debug_fascinare_interaction = {
	category = interaction_debug_main
	use_diplomatic_range = no
	ignores_pending_interaction_block = yes

	is_shown = {
		debug_only = yes
		scope:actor = {
			OR = {
				has_trait = magister_trait_group
			}
		}
		scope:recipient = {
			is_adult = yes
			is_male = no
			NOR = {
				has_trait = paelex
				has_trait = mulsa
				has_trait = domina
				has_trait = contubernalis
				has_trait = orba
			}
			is_imprisoned = no
		}
	}

	is_valid = {
		NOT = { scope:recipient = scope:actor }
		scope:actor = {
			OR = {
				has_trait = magister_trait_group
				has_trait = devoted_trait_group
			}
		}
	}

	on_accept = {
		scope:recipient = {
			add_trait = mulsa
			set_character_faith = global_var:magister_character.faith
		}
		change_global_variable = {
			name = regula_fascinare_tally
			add = 1
		}
	}

	auto_accept = yes

	ai_will_do = {
		base = 0
	}
}


code:
template = {

	# Simple charge COA
	regula_womb_template = {
		pattern = "pattern_solid.dds"
		color1 = list "normal_colors"
		color2 = list "metal_colors"

		colored_emblem = {
			texture = list "cheri_womb_list"
			color1 = list "metal_colors"
			color2 = list "normal_colors"
			instance = { position = { 0.5 0.5 } scale = { 0.8 0.8 }  }
		}
	}

	# Simple charge COA
	regula_womb_template_inverted = {
		pattern = "pattern_solid.dds"
		color1 = list "metal_colors"
		color2 = list "normal_colors"

		colored_emblem = {
			texture = list "cheri_womb_list"
			color1 = list "normal_colors"
			color2 = list "metal_colors"
			instance = { position = { 0.5 0.5 } scale = { 0.8 0.8 }  }
		}
	}

	# Spiral Background with women silhouette
	regula_women_hypno_normal_template = {
		pattern = "pattern_solid.dds"
		color1 = list "normal_colors"

		colored_emblem = {
			texture = list "cheri_women_list"
			color1  = white
			instance = { position = { 0.5 0.5 } scale = { 0.85 0.85 }  }
		}

		colored_emblem = {
			texture = list "cheri_spiral_list"
			color1  = black
			instance = { position = { 0.5 0.5 } depth = 1  }
		}
	}

	# Spiral Background with women silhouette
	regula_women_hypno_metal_template = {
		pattern = "pattern_solid.dds"
		color1 = list "normal_colors"

		colored_emblem = {
			texture = list "cheri_women_list"
			color1  = white
			instance = { position = { 0.5 0.5 } scale = { 0.85 0.85 }  }
		}

		colored_emblem = {
			texture = list "cheri_spiral_list"
			color1  = black
			instance = { position = { 0.5 0.5 } depth = 1  }
		}
	}

	# Hypno eyes inside coloured line across center
	regula_eye_hypno_template = {
		pattern = "pattern_horizontal_stripes_01.dds"
		color1 = list "normal_colors"
		color2 = list "metal_colors"

		colored_emblem={
			color1=purple
			texture="cherilewd_ce_hypno_4.dds"
			instance={
				position={ 0.700000 0.500000 }
				scale={ -0.400000 0.400000 }
			}

			instance={
				position={ 0.300000 0.500000 }
				scale={ 0.400000 0.400000 }
				depth=1.010000
			}

		}
	}

}

license: mit


code:
coat_of_arms_template_lists = {
	# Root may be the set character, if in the ruler designer it will not exist yet but the saved scopes will so use them instead of checking the character
	# scope:faith is the faith of the character, always set
	# scope:culture is the culture of the character, always set
	# scope:title is the primary title of the character, may be unset
	# Regula

	all = {
		# Simple catch all

		3 = basic_charge_01
		3 = basic_charge_01b
		3 = basic_ordinary_01
		3 = basic_ordinary_01_inverted

		#500 = basic_charge_02
		#50000 = basic_charge_03
		#1 = basic_charge_04
		#50000 = basic_charge_05
		#3 = basic_charge_06

		# Turned off
		#1 = basic_charge_13
		#1 = basic_charge_13_b
		#1 = border_01
		#1 = border_01_metal
		#1 = basic_ordinary_02
		#1 = basic_ordinary_02_b
		#1 = dynasty_godwin
		#1 = dynasty_godwin_02

		#3 = basic_ordinary_division_01
		#1 = basic_ordinary_division_02
		#3 = basic_ordinary_chief_01
		#1 = basic_ordinary_chief_02

		# Regula
		special_selection = {
			trigger = {
				scope:culture = { has_coa_gfx = regula_coa_gfx }
			}
			2000 = regula_womb_template
			2000 = regula_womb_template_inverted
			2000 = regula_women_hypno_normal_template
			1000 = regula_women_hypno_metal_template
			3000 = regula_eye_hypno_template
		}

		# Crosses
		special_selection = {
			trigger = {
				coa_cross_trigger = yes
			}
			1 = basic_ordinary_cross_01
			3 = basic_ordinary_cross_02
			1 = basic_ordinary_cross_03
			3 = basic_ordinary_cross_04

			1 = basic_ordinary_saltire_01
			1 = basic_ordinary_saltire_02
			#1 = basic_ordinary_saltire_03
			#1 = basic_ordinary_saltire_04
		}

		# Pagan catch-all
		special_selection = {
			trigger = {
				scope:faith.religion = {
					save_temporary_scope_as = religion
				}

				scope:religion = { is_in_family = rf_pagan }
				NOR = {
					scope:religion = religion:slavic_religion
					scope:religion = religion:baltic_religion
					scope:religion = religion:finno_ugric_religion
					scope:religion = religion:magyar_religion
					scope:religion = religion:germanic_religion
					scope:religion = religion:zoroastrianism_religion
					scope:religion = religion:tengrism_religion
					scope:religion = religion:akom_religion
					scope:religion = religion:akom_religion
					scope:religion = religion:waaqism_religion
					scope:religion = religion:west_african_religion
					scope:religion = religion:west_african_bori_religion
					scope:religion = religion:west_african_roog_religion
					scope:religion = religion:west_african_orisha_religion
				}
			}
			5000 = basic_charge_01
			#50000 = basic_charge_02
		}
		# European Paganism - Single, Circle, Senester
		special_selection = {
			trigger = {
				scope:faith.religion = {
					save_temporary_scope_as = religion
				}
				OR = {
					scope:religion = religion:slavic_religion
					scope:religion = religion:baltic_religion
					scope:religion = religion:finno_ugric_religion
					scope:religion = religion:magyar_religion
				}
			}
			# Weights are temps
			16000 = basic_pagan_template
			16000 = basic_pagan_template_inverted
			8000 = basic_pagan_template_senester
			8000 = basic_pagan_template_senester_inverted
			3000 = geometrical_pagan_template
			4000 = geometrical_pagan_template_inverted
			3000 = geometrical_pagan_template_senester
			2000 = circled_pagan_template
			2000 = circled_pagan_template_inverted
			2000 = circled_pagan_template_offset
			2000 = circled_pagan_template_offset_inverted
		}

		# Germanic Paganism
		special_selection = {
			trigger = {
				scope:faith.religion = religion:germanic_religion
			}
			5000 = basic_pagan_template
			5000 = basic_pagan_template_inverted
			2500 = basic_pagan_template_senester
			2500 = basic_pagan_template_senester_inverted
			5000 = geometrical_pagan_template
			5000 = geometrical_pagan_template_inverted
			2500 = geometrical_pagan_template_senester
			7500 = circled_pagan_template
			7500 = circled_pagan_template_inverted

		}

		special_selection = {
			trigger = {
				coa_indian_trigger = yes
			}
			50 = basic_charge_01
			50 = basic_charge_01b
			50 = basic_ordinary_01
			50 = basic_ordinary_01_inverted
			100 = indian_geometrical_template
			100 = indian_geometrical_template_inverted
			50 = indian_single_border_template
			50 = indian_single_border_template_inverted
			150 = circled_indian_template
			150 = circled_indian_template_inverted
			60  = circled_indian_template_offset
			60  = circled_indian_template_offset_inverted
		}
		# India proper (to tone down those very cultural specific designs vs catch all)
		special_selection = {
			trigger = {
				exists = scope:title
				scope:title = {
					any_this_title_or_de_jure_above = {
						OR = {
							this = title:e_india
							this = title:e_deccan
							this = title:e_rajastan
							this = title:k_gondwana
							this = title:k_bihar
							this = title:k_orissa
						}
					}
				}
			}
			100 = indian_single_template
			100 = indian_single_template_inverted
			100 = indian_single_template_senester
			100 = indian_single_template_senester_inverted
			100 = circled_indian_single_symbol_template
			100 = circled_indian_single_symbol_template_inverted
		}

		# Tamgha users - Circle/Roundel
		special_selection = {
			trigger = {
				scope:faith.religion = {
					save_temporary_scope_as = religion
				}
				OR = {
					scope:faith = faith:nestorian
					scope:religion = religion:tengrism_religion
					scope:religion = religion:zoroastrianism_religion
					scope:religion = religion:magyar_religion
					AND = {
						scope:religion = religion:judaism_religion
						scope:culture = { has_coa_gfx = turkic_group_coa_gfx }
					}
				}
			}
			5000 = basic_tamgha_template
			5000 = basic_tamgha_template_inverted
			2500 = circled_tamgha_template
			2500 = circled_tamgha_template_inverted
			2500 = roundel_tamgha_template
			2500 = roundel_tamgha_template_inverted
		}
		# African Paganism - Single charge, geometrical patterns
		special_selection = {
			trigger = {
				coa_african_religion_trigger = yes
			}
			2000 = basic_african_template
			2000 = basic_african_template_inverted
			2000 = circled_african_template
			2000 = circled_african_template_inverted
			2500 = geometrical_african_template
			2500 = geometrical_african_template_inverted
		}
		# Feudal Europe
		special_selection = {
			trigger = {
				scope:faith.religion = religion:christianity_religion
				scope:culture = { has_coa_gfx = western_coa_gfx }
			}
			# A (main = charge)
			# Rougly 50% of all cases, 50% of it being from bestiary, 50% of said bestiary being lions.
			2500 = hr_single_charge_template
			2500 = hr_single_charge_template_inverted
			500 = hr_three_charges_template
			500 = hr_three_charges_template_inverted
			250 = hr_six_charges_template
			250 = hr_six_charges_template_inverted
			200 = hr_charge_under_chief_template
			200 = hr_charge_under_chief_template_inverted
			200 = hr_lion_semy_template
			200 = hr_lion_semy_template_inverted
			100 = hr_three_charges_in_pale_template
			100 = hr_three_charges_in_pale_template_inverted
			100 = hr_seven_charges_template
			100 = hr_seven_charges_template_inverted
			100 = hr_ten_charges_template
			100 = hr_ten_charges_template_inverted
			100 = hr_charge_and_canton_template
			100 = hr_charge_and_canton_template_inverted
			100 = hr_escutcheon_orle_template
			100 = hr_escutcheon_orle_template_inverted
			50 = hr_semy_template
			50 = hr_semy_template_inverted
			100 = hr_canton_template
			100 = hr_canton_template_inverted
			50 = hr_charge_canton_ermine_template
			50 = hr_charge_canton_ermine_template_inverted
			10 = hr_five_charges_template
			10 = hr_five_charges_template_inverted
			10 = hr_single_charge_on_mount_template
			10 = hr_single_charge_on_mount_template_inverted
			# Two charges in pale (ie Normandy)

			# B (main = ordinaries & partitions)
			# Roughly 50% of all cases : 50% divisions, 50% ordinaries (not counting any accompanying charge)
			2500 = hr_geometrical_template
			2500 = hr_geometrical_template_inverted
			100 = hr_geometrical_field_canton_template
			100 = hr_geometrical_field_canton_template_inverted
			200 = hr_three_charges_in_bend_template
			200 = hr_three_charges_in_bend_template_inverted
			200 = hr_three_charges_in_chief_template
			200 = hr_three_charges_in_chief_template_inverted
			200 = hr_three_charges_in_fess_template
			200 = hr_three_charges_in_fess_template_inverted
			200 = hr_cross_ch_five_template
			200 = hr_cross_ch_five_template_inverted
			200 = hr_cross_acc_four_template
			200 = hr_cross_acc_four_template_inverted
			100 = hr_chevron_acc_three_template
			100 = hr_chevron_acc_three_template_inverted
			100 = hr_fess_acc_three_template
			100 = hr_fess_acc_three_template_inverted
			100 = hr_fess_acc_six_charges_template
			100 = hr_fess_acc_six_charges_template_inverted
			100 = hr_bend_acc_six_charges_template
			100 = hr_bend_acc_six_charges_template_inverted
			100 = hr_charge_issant_chief_template
			100 = hr_charge_issant_chief_template_inverted
			50 = hr_canton_ermine_template
			50 = hr_canton_ermine_template_inverted

			# C (mixed)
			100 = hr_vair_template
			100 = hr_ermine_template
			100 = hr_charge_within_border_template
			100 = hr_charge_within_border_template_inverted

		}
		special_selection = {
			trigger = {
				scope:faith.religion = religion:christianity_religion
				scope:culture = { has_coa_gfx = iberian_group_coa_gfx }
			}
			1000 = hr_five_charges_template
			1000 = hr_five_charges_template_inverted
		}
		special_selection = {
			trigger = {
				scope:faith.religion = religion:christianity_religion
				scope:culture = { has_coa_gfx = german_group_coa_gfx }
			}
			500 = hr_single_charge_on_mount_template
			500 = hr_single_charge_on_mount_template_inverted
		}
		special_selection = {
			trigger = {
				scope:faith.religion = religion:christianity_religion
				coa_french_trigger = yes
			}
			200 = hr_semy_template
			200 = hr_semy_template_inverted
			200 = hr_seven_charges_template
			200 = hr_seven_charges_template_inverted
			200 = hr_ten_charges_template
			200 = hr_ten_charges_template_inverted
			100 = hr_vair_template
			100 = hr_ermine_template
			100 = hr_charge_issant_chief_template
			100 = hr_charge_issant_chief_template_inverted
			50 = hr_charge_canton_ermine_template
			50 = hr_charge_canton_ermine_template_inverted
			100 = hr_escutcheon_orle_template
			100 = hr_escutcheon_orle_template_inverted
		}

		special_selection = {
			trigger = {
				scope:faith.religion = religion:christianity_religion
				coa_scandinavian_trigger = yes
			}
			1500 = hr_dimidiated_charge_and_geometrical
			1500 = hr_dimidiated_charge_and_geometrical_inverted
			2500 = hr_single_charge_template
			2500 = hr_single_charge_template_inverted
			1000 = hr_three_charges_template
			1000 = hr_three_charges_template_inverted
			1500 = hr_three_charges_in_pall_template
			1500 = hr_three_charges_in_pall_template_inverted
			2500 = hr_geometrical_template
			2500 = hr_geometrical_template_inverted
			1000 = hr_three_charges_arranged_in_bend_template
			1000 = hr_three_charges_arranged_in_bend_template_inverted
			1000 = hr_three_charges_arranged_in_bend_template_senester
			1000 = hr_three_charges_arranged_in_bend_template_senester_inverted
			1500 = hr_single_charge_chevron_chief
			1500 = hr_single_charge_chevron_chief_inverted
			2500 = hr_single_charge_in_bend
		}

		special_selection = {
			trigger = {
				scope:faith.religion = religion:christianity_religion
				scope:culture = { has_coa_gfx = polish_coa_gfx }
			}
			2500 = hr_single_charge_template
			2500 = hr_single_charge_template_inverted
		}
		special_selection = {
			trigger = {
				scope:faith.religion = religion:christianity_religion
				scope:culture = {
					OR = {
						has_coa_gfx = west_slavic_group_coa_gfx
						has_coa_gfx = south_slavic_group_coa_gfx
						has_coa_gfx = east_slavic_group_coa_gfx
						has_coa_gfx = baltic_group_coa_gfx
						has_coa_gfx = balto_finnic_group_coa_gfx
					}
				}
			}
			5000 = hr_single_charge_template
			5000 = hr_single_charge_template_inverted
			2500 = hr_geometrical_template
			2500 = hr_geometrical_template_inverted
		}

		# Middle East
		# Islam - catch all - Persian, Turkic & others will use these only
		special_selection = {
			trigger = {
				scope:faith.religion = religion:islam_religion
			}
			2000 = circled_mena_template
			2000 = circled_mena_template_inverted
			2000 = roundel_mena_template
			2000 = roundel_mena_template_inverted
			4000 = mena_geometrical_template
			4000 = mena_geometrical_template_inverted
		}
		# MENA - Saracen/Mamluk heraldry - Additionnal layer centered on arabic & berber cultures
		special_selection = {
			trigger = {
				scope:faith.religion = religion:islam_religion
				scope:culture = {
					OR = {
						has_coa_gfx = arabic_group_coa_gfx
						has_coa_gfx = berber_group_coa_gfx
					}
				}
			}
			1000 = mena_fess_01
			1000 = mena_fess_01_barrulets
			1000 = mena_fess_02
			1000 = mena_fess_02_barrulets
			1000 = mena_fess_03
			1000 = mena_fess_03_barrulets
			1000 = mena_fess_04
			1000 = mena_fess_04_barrulets # 100000
			1000 = mena_fess_05
			1000 = mena_fess_05_barrulets
			1000 = mena_fess_06
			1000 = mena_fess_06_barrulets
			1000 = mena_chief_01
			1000 = mena_chief_01_b # 50000
			1000 = mena_chief_03
			1000 = mena_chief_04
			1000 = mena_bend_01
			1000 = mena_bend_02
			500 = mena_fess_chief
			500 = mena_lowered_fess
			500 = mena_fess_chief_inverted
			500 = mena_lowered_fess_inverted
			# larger bend for larger charge, those could be used for arabic calligraphy (ie Nasrid)
		}
	}

	religious_title = {
		100 = religious_icon_01
		100 = religious_icon_01_metal
	}

	factions = {
		100 = faction_01
	}
}


code:
colored_emblem_texture_lists = {
	cheri_womb_list = {
		100 = "carn_ce_womb_1.dds"
		100 = "carn_ce_womb_2.dds"
		100 = "carn_ce_womb_3.dds"
		100 = "carn_ce_womb_4.dds"
		100 = "carn_ce_womb_5.dds"
		100 = "carn_ce_womb_6.dds"
		100 = "carn_ce_womb_7.dds"
		100 = "carn_ce_womb_8.dds"
		100 = "carn_ce_womb_9.dds"
		100 = "carn_ce_womb_10.dds"
		100 = "carn_ce_womb_11.dds"
		100 = "carn_ce_womb_12.dds"
		100 = "carn_ce_womb_13.dds"
		100 = "carn_ce_womb_14.dds"
		100 = "carn_ce_womb_15.dds"
		100 = "carn_ce_womb_16.dds"
		100 = "carn_ce_womb_17.dds"
		100 = "carn_ce_womb_18.dds"
		100 = "carn_ce_womb_19.dds"
		100 = "carn_ce_womb_20.dds"
		100 = "carn_ce_womb_21.dds"
		100 = "carn_ce_womb_22.dds"
		100 = "carn_ce_womb_23.dds"
		100 = "carn_ce_womb_24.dds"
		100 = "carn_ce_womb_25.dds"
		100 = "carn_ce_womb_26.dds"
		100 = "carn_ce_womb_27.dds"
		100 = "carn_ce_womb_28.dds"
		100 = "carn_ce_womb_29.dds"
		100 = "carn_ce_womb_30.dds"
		100 = "carn_ce_womb_31.dds"
		100 = "carn_ce_womb_32.dds"
		100 = "carn_ce_womb_33.dds"
		100 = "carn_ce_womb_34.dds"
		100 = "carn_ce_womb_35.dds"
		100 = "carn_ce_womb_36.dds"
		100 = "carn_ce_womb_37.dds"
		100 = "carn_ce_womb_38.dds"
		100 = "carn_ce_womb_39.dds"
		100 = "carn_ce_womb_40.dds"
		100 = "carn_ce_womb_41.dds"
		100 = "carn_ce_womb_42.dds"
		100 = "carn_ce_womb_43.dds"
		100 = "carn_ce_womb_44.dds"
		100 = "carn_ce_womb_45.dds"
		100 = "carn_ce_womb_46.dds"
		100 = "carn_ce_womb_47.dds"
		100 = "carn_ce_womb_48.dds"
		100 = "carn_ce_womb_49.dds"
		100 = "carn_ce_womb_50.dds"
		100 = "carn_ce_womb_51.dds"
		100 = "carn_ce_womb_52.dds"
		100 = "carn_ce_womb_53.dds"
		100 = "carn_ce_womb_54.dds"
		100 = "carn_ce_womb_55.dds"
		100 = "carn_ce_womb_56.dds"
		100 = "carn_ce_womb_57.dds"
		100 = "carn_ce_womb_58.dds"
		100 = "carn_ce_womb_59.dds"
		100 = "carn_ce_womb_60.dds"
		100 = "carn_ce_womb_61.dds"
		100 = "carn_ce_womb_62.dds"
		100 = "carn_ce_womb_63.dds"
		100 = "carn_ce_womb_64.dds"
		100 = "carn_ce_womb_65.dds"
		100 = "carn_ce_womb_66.dds"
		100 = "carn_ce_womb_67.dds"
		100 = "carn_ce_womb_68.dds"
		100 = "carn_ce_womb_69.dds"
		100 = "carn_ce_womb_70.dds"
		100 = "carn_ce_womb_71.dds"
		100 = "carn_ce_womb_72.dds"
		100 = "carn_ce_womb_73.dds"
		100 = "carn_ce_womb_74.dds"
		100 = "carn_ce_womb_75.dds"
		100 = "carn_ce_womb_76.dds"
		100 = "carn_ce_womb_77.dds"
	}
	cheri_women_list = {
		100 = "cherilewd_ce_silhouette_1.dds"
		100 = "cherilewd_ce_silhouette_2.dds"
		100 = "cherilewd_ce_silhouette_3.dds"
		100 = "cherilewd_ce_silhouette_4.dds"
		100 = "cherilewd_ce_silhouette_5.dds"
		100 = "cherilewd_ce_silhouette_6.dds"
		100 = "cherilewd_ce_silhouette_7.dds"
		100 = "cherilewd_ce_silhouette_8.dds"
	}
	cheri_spiral_list = {
		100 = "cherilewd_ce_hypno_1.dds"
		100 = "cherilewd_ce_hypno_2.dds"
	}
	cher_hypno_list = {
		100 = "cherilewd_ce_hypno_3.dds"
		100 = "cherilewd_ce_hypno_4.dds"
	}
}


code:
magistri = {
	color = { 0.5 0.0 0.5 }
	created = 867.1.1
	parents = { english }

	ethos = ethos_communal
	heritage = heritage_west_germanic
	language = language_anglic
	martial_custom = martial_custom_regula

	traditions = {
		tradition_famuli_warriors
		tradition_magistri_submission
		tradition_strength_in_numbers
		tradition_zealous_people
		tradition_family_entrepreneurship
	}

	name_list = name_list_magistri_english

	coa_gfx = { regula_coa_gfx }
	building_gfx = { western_building_gfx }
	clothing_gfx = { western_clothing_gfx }
	unit_gfx = { western_unit_gfx }

	ethnicities = {
		25 = caucasian_blond
		15 = caucasian_ginger
		35 = caucasian_brown_hair
		25 = caucasian_dark_hair
	}

}


code:
name_list_magistri_english = {

	cadet_dynasty_names = {
		{ "dynnp_de" "dynn_Bohun" }
		{ "dynnp_de" "dynn_Vere" }
		{ "dynnp_de" "dynn_Gand" }
		"dynn_Myall"
		{ "dynnp_de" "dynn_Turberville" }
		{ "dynnp_de" "dynn_Holland" }
		"dynn_Butler"
		{ "dynnp_of" "dynn_Thornham" }
		{ "dynnp_de" "dynn_Camville" }
		"dynn_Breakspear"
		{ "dynnp_of" "dynn_Itchington" }
		{ "dynnp_of" "dynn_Northall" }
		{ "dynnp_de" "dynn_Montagu" }
		{ "dynnp_de" "dynn_Umfraville" }
		"dynn_FitzPeter"
		"dynn_Belles-mains"
		{ "dynnp_of" "dynn_Warwick" }
		"dynn_FitzAlan"
		{ "dynnp_de" "dynn_Beauchamp" }
		{ "dynnp_of" "dynn_Ilchester" }
		{ "dynnp_de" "dynn_Raleigh" }
		{ "dynnp_de" "dynn_Stratford" }
		"dynn_Becket"
		{ "dynnp_de" "dynn_la_Pole" }
	}

	dynasty_names = {
		{ "dynnp_de" "dynn_Bohun" }
		{ "dynnp_de" "dynn_Vere" }
		{ "dynnp_de" "dynn_Gand" }
		"dynn_Myall"
		{ "dynnp_de" "dynn_Turberville" }
		{ "dynnp_de" "dynn_Holland" }
		"dynn_Butler"
		{ "dynnp_of" "dynn_Thornham" }
		{ "dynnp_de" "dynn_Camville" }
		"dynn_Breakspear"
		{ "dynnp_of" "dynn_Itchington" }
		{ "dynnp_of" "dynn_Northall" }
		{ "dynnp_de" "dynn_Montagu" }
		{ "dynnp_de" "dynn_Umfraville" }
		"dynn_FitzPeter"
		"dynn_Belles-mains"
		{ "dynnp_of" "dynn_Warwick" }
		"dynn_FitzAlan"
		{ "dynnp_de" "dynn_Beauchamp" }
		{ "dynnp_of" "dynn_Ilchester" }
		{ "dynnp_de" "dynn_Raleigh" }
		{ "dynnp_de" "dynn_Stratford" }
		"dynn_Becket"
		{ "dynnp_de" "dynn_la_Pole" }
	}

	# Does not exist in 1066 - is the result of cultural amalgamation between Saxon and Norman through events
	male_names = {
		14 = { # most common
			William
		}
		8 = { # second most common
			John
		}
		48 = { # other common names
			Adam Geoffrey Henry Hugh Nicholas Peter Ralph Richard Robert Roger Simon Thomas Walter
		}
		30 = { # everything else
			Alan Albert Alexander Alfred Andrew Anselm Arnold Arthur Aubrey Baldrick Christopher David Edmund Edward Eric Eustace Fulk George Gerald Gilbert
			Godfrey Gregory Guy Harold Humphrey Jocelyn Jordan Laurence Lionel Mark Martin Matthew Maurice Michael Paul Philip
			Randolph Reginald Roderick Samuel Stephen Theobald Waleran
		}
		0 = { # translated versions of other culture names
			Blethin Duncan Douglas Fergus Findlay Griffith Kenneth Patrick Teague Howell Meredith Owen Tristan Cecil Sweeney Cedric Merlin Sebastian Zachary
		}

	}

	female_names = {
		Adela Adelaide Alice Amice Anne Aveline Beatrice Blanche Catherine Cecilia Constance Edith Ela Eleanor Elizabeth Emma Hawise Isabel
		Isabella Joan Joanna Juliana Mahaut Margaret Mary Matilda Maud Philippa Sybilla
	}

	dynasty_of_location_prefix = "dynnp_of"
	bastard_dynasty_prefix = "dynnp_fitz"

	patronym_suffix_male = "dynnpat_suf_s"
	patronym_suffix_female = "dynnpat_suf_s"

	# Chance of male children being named after their paternal or maternal grandfather, or their father. Sum must not exceed 100.
	pat_grf_name_chance = 30
	mat_grf_name_chance = 10
	father_name_chance = 25

	# Chance of female children being named after their paternal or maternal grandmother, or their mother. Sum must not exceed 100.
	pat_grm_name_chance = 20
	mat_grm_name_chance = 40
	mother_name_chance = 5

	mercenary_names = {
		{ name = mercenary_company_concubine_conquerers }
		{ name = mercenary_company_raiders_of_fair_maidens }
		{ name = mercenary_company_women_enslavers }
	}

	founder_named_dynasties = yes
}


code:
martial_custom_regula = {
	type = martial_custom

	parameters = {
		martial_custom_female_only_combatant = yes
	}

	character_modifier = {
		hostile_county_attrition = -0.15
		skirmishers_max_size_add = 1
		archers_max_size_add = 1
		light_cavalry_max_size_add = 1
	}

	can_pick = {
		custom_tooltip = {
			text = martial_customs_trigger_femaleonly

			scope:character = { has_trait = magister_trait_group }
		}
	}

	ai_will_do = {
		value = 0

	}
}


code:
##############################
# REGULA CULTURAL TRADITIONS #
##############################

tradition_famuli_warriors = {
	category = combat

	layers = {
		0 = martial
		1 = mena
		4 = famuli_warrior.dds
	}

	# Assumes player is a culture head, and has Regula religion
	# This is a fallback pick anyway, as you normally get this via the decision
	can_pick = {
		culture_head = {
			has_religion = religion:regula_religion
		}
		has_cultural_pillar = martial_custom_regula
	}

	parameters = {
		unlock_maa_famuli = yes
	}
	character_modifier = {
		advantage = 5
		movement_speed = 0.25
		retreat_losses = 0.30
		enemy_hard_casualty_modifier = 0.25
	}

	cost = {
		prestige = {
			add = {
				value = tradition_base_cost
				desc = BASE
				format = "BASE_VALUE_FORMAT"
			}

			# Tradition is free if we already have the Famuli Martial Custom
			if = {
				limit = {
					has_cultural_pillar = martial_custom_regula
				}
				add = {
					value = -1000
					desc = has_famuli_custom_desc
				}
			}

			multiply = tradition_replacement_cost_if_relevant
		}
	}

	# AI will never take this on their own
	ai_will_do = {
		value = 0
	}
}

tradition_magistri_submission = {
	category = societal

	layers = {
		0 = learning
		1 = mediterranean
		4 = magistri_submission.dds
	}

	# Assumes player is a culture head, and has Regula religion
	# This is a fallback pick anyway, as you normally get this via the decision
	can_pick = {
		culture_head = {
			has_religion = religion:regula_religion
		}
	}

	parameters = {
		content_trait_more_common = yes
		courtiers_less_likely_to_leave_same_culture_court = yes
		ai_doesnt_marry_outside_culture = yes
	}
	culture_modifier = {
		cultural_acceptance_gain_mult = -0.35
	}

	character_modifier = {
		stress_gain_mult = -0.15
		stress_loss_mult = 0.15

		# Less likely to start wars
		ai_war_chance = -0.75
		ai_war_cooldown = 10

		ai_boldness = -80
		ai_energy = -20
		ai_compassion = 30
		ai_sociability = 10
		ai_honor = 30
		ai_zeal = 50

		knight_effectiveness_mult = -0.2
		prowess = -2
		hostile_scheme_resistance_mult = -0.2
		personal_scheme_resistance_mult = -0.2
	}

	county_modifier = {
		monthly_county_control_change_add = 0.3
		development_growth_factor = 0.1
		county_opinion_add = 20
	}

	cost = {
		prestige = {
			add = {
				value = tradition_base_cost
				desc = BASE
				format = "BASE_VALUE_FORMAT"
			}

			# Tradition is free if we already have the Regula religion
			if = {
				limit = {
					culture_head = {
						has_religion = religion:regula_religion
					}
				}
				add = {
					value = -1000
					desc = has_regula_custom_desc
				}
			}

			multiply = tradition_replacement_cost_if_relevant
		}
	}

	# AI will never take this on their own
	ai_will_do = {
		value = 0
	}
}


code:
### Layout ###
# Biostatistics (Age, Health, Fertility)
# Opinion of Liege
# Scheme status - personal
# Scheme status - hostile
# Faction status
regula_status_scheme_personal = {  ### UPDATE - Hopefully these fire in order.  Need to verify.  first_valid might work.
    type = character

    text = {
        localization_key = REGULA_STATUS_SCHEME_PERSONAL_YES
        trigger = {
            any_scheme = {
				OR = {
					scheme_type = befriend
					scheme_type = sway
					scheme_type = seduce
					scheme_type = courting
					scheme_type = elope
				}
			}
        }
    }

    text = {
        localization_key = REGULA_STATUS_SCHEME_PERSONAL_YES_FALLBACK
        trigger = {
            has_owned_scheme = yes
            any_scheme = {
                NOR = {
					scheme_type = befriend
					scheme_type = sway
					scheme_type = seduce
					scheme_type = courting
					scheme_type = elope
                }
            }
        }
    }

    text = {
        localization_key = REGULA_STATUS_SCHEME_PERSONAL_NO
        trigger = {
            any_scheme = {
				NOR = {
					scheme_type = befriend
					scheme_type = sway
					scheme_type = seduce
					scheme_type = courting
					scheme_type = elope
				}
			}
        }
    }
}

regula_status_scheme_hostile = {
    type = character

    text = {
        localization_key = REGULA_STATUS_SCHEME_HOSTILE_YES
        trigger = {
            any_scheme = {
				OR = {
					scheme_type = murder
					scheme_type = abduct
					scheme_type = claim_throne
                    scheme_type = fabricate_hook
                    scheme_type = rapta_maritus
				}
			}
        }
    }

    text = {
        localization_key = REGULA_STATUS_SCHEME_HOSTILE_YES_FALLBACK
        trigger = {
            has_owned_scheme = yes
            any_scheme = {
                NOR = {
                    scheme_type = murder
					scheme_type = abduct
					scheme_type = claim_throne
                    scheme_type = fabricate_hook
                    scheme_type = rapta_maritus
                }
            }
        }
    }

    text = {
        localization_key = REGULA_STATUS_SCHEME_HOSTILE_NO
        trigger = {
            any_scheme = {
				NOR = {
					scheme_type = murder
					scheme_type = abduct
					scheme_type = claim_throne
                    scheme_type = fabricate_hook
                    scheme_type = rapta_maritus
				}
			}
        }
    }
}

regula_status_faction = {
    type = character
    text = {
        localization_key = REGULA_STATUS_FACTION_NO
        trigger = {
            AND = {
                is_a_faction_member = no
                is_a_faction_leader = no
            }
        }
    }
    text = {
        localization_key = REGULA_STATUS_FACTION_YES
        trigger = {
            OR = {
                is_a_faction_member = yes
                is_a_faction_leader = yes
            }
        }
    }
}


code:
regula_throw_orgy_decision = {
	ai_check_interval = 0

	cooldown = { years = 5 }
	picture = "gfx/interface/illustrations/decisions/regula_throw_orgy_decision.dds"
	desc = regula_throw_orgy_decision_desc
	selection_tooltip = regula_throw_orgy_decision_tooltip

	is_shown = {
		has_trait = magister_trait_group
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		custom_description = {
			text = regula_throw_orgy_concubine_minimum
			regula_num_landed_concubines >= 6
		}
		custom_description = {
			text = magister_trait_2_required_trigger
			NOT = { has_trait = magister_1 }
		}
	}

	effect = {
		capital_province = {
			spawn_activity = {
				type = activity_regula_orgy
				owner = root
			}
		}
		stress_impact = {
			base = major_stress_impact_loss
		}
	}

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0
	}
}


code:
regula_corrupt_holy_order_decision = {
   	picture = "gfx/interface/illustrations/decisions/regula_corrupt_holy_order_decision.dds"
    major = yes
	title = regula_corrupt_holy_order_decision.t
	desc = regula_corrupt_holy_order_decision_desc
	selection_tooltip = regula_corrupt_holy_order_decision_tooltip

	ai_check_interval = 0 #AI won't consider.

	is_shown = {
		is_ai = no
		is_ruler = yes
		has_trait = magister_trait_group
		age >= 16
		OR = {
			any_held_title = {
				is_under_holy_order_lease = yes
				barony_is_valid_for_holy_order_lease_cancellation_trigger = yes
				lessee_title.holder = {
					save_temporary_scope_as = infidel_grandmaster
					NOT = { faith = global_var:magister_character.faith }
					faith = {
						any_faith_holy_order = {
							leader = scope:infidel_grandmaster
							save_temporary_scope_as = infidel_holy_order
						}
					}
				}
			}
			any_vassal_or_below = {
				has_trait = devoted_trait_group
				any_held_title = {
					is_under_holy_order_lease = yes
					barony_is_valid_for_holy_order_lease_cancellation_trigger = yes
					lessee_title.holder = {
						save_temporary_scope_as = infidel_grandmaster
						NOT = { faith = global_var:magister_character.faith }
						faith = {
							any_faith_holy_order = {
								leader = scope:infidel_grandmaster
								save_temporary_scope_as = infidel_holy_order
							}
						}
					}
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		custom_description = {
			text = magister_trait_6_required_trigger
			has_trait_rank = {
				trait = magister_trait_group
				rank >= 6
			}
		}
	}

	cost = {
		piety = 2000
	}

	effect = {
		custom_tooltip = "regula_corrupt_holy_order_decision_tooltip_effect"
		trigger_event = {
			id = regula_corrupt_holy_order_event.0001
		}
	}

	confirm_text = regula_corrupt_holy_order_decision_confirm.a

	ai_will_do = {
		base = 0
	}

}


code:
regula_initialize_compeditae_succession_decision = {
	picture = "gfx/interface/illustrations/decisions/regula_initialize_compeditae_succession_decision.dds"
	major = yes
	title = regula_initialize_compeditae_succession_decision.t
	desc = regula_initialize_compeditae_succession_decision.desc
	selection_tooltip = regula_initialize_compeditae_succession_decision_tooltip

	ai_check_interval = 0 #AI won't consider.

	is_shown = {
		is_ruler = yes
		is_ai = no
		has_global_variable = regula_initialized
		primary_title = {
			NOT = {
				has_title_law = compeditae_elective_succession_law
			}
		}
	}

	is_valid = {
		is_independent_ruler = yes
		highest_held_title_tier = tier_empire
		custom_description = {
			text = magister_trait_5_required_decision_trigger
			has_trait_rank = {
				trait = magister_trait_group
				rank >= 5
			}
		}
		custom_description = {
			text = regula_compeditae_election_concubine_pass_minimum_decision_trigger
			regula_num_landed_concubines >= 10
		}
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	cost = {
		gold = 500
		prestige = 1500
		piety = 750
	}

	effect = {
		custom_tooltip = "regula_initialize_compeditae_succession_decision_tooltip_effect"
		trigger_event = {
			id = regula_initialize_event.1030
		}
		add_character_modifier = regula_compeditae_succession_modifier
	}

	confirm_text = regula_initialize_compeditae_succession_decision.a

	ai_will_do = {
		base = 0
	}
}


code:
# regula_initialize_decision = {
# 	picture = "gfx/interface/illustrations/decisions/regula_initialize_decision.dds"
# 	major = yes
# 	title = regula_initialize_decision.t
# 	desc = regula_initialize_decision_desc
# 	selection_tooltip = regula_initialize_decision_tooltip

# 	ai_check_interval = 0 #AI won't consider.

# 	is_shown = {
# 		is_ruler = yes
# 		is_male = yes
# 		is_ai = no
# 		age >= 16
# 		NOT = { has_global_variable = regula_initialized }
# 		NOT = { has_global_variable = regula_covert_initialized }
# 		NOT = { has_character_flag = regula_decision_taken }
# 	}

# 	is_valid = {
# 		# is_independent_ruler = yes
# 	}

# 	is_valid_showing_failures_only = {
# 		is_available = yes
# 		is_male = yes
# 		age >= 16
# 		custom_description = {
# 			text = regula_faith_head_trigger
# 			NOT = { root.faith.religious_head = root }
# 		}
# 	}

# 	cost = {
# 		gold = 300
# 		prestige = 1000
# 		piety = 400
# 	}

# 	effect = {
# 		custom_tooltip = "regula_initialize_decision_tooltip_effect"
# 		add_character_flag = regula_decision_taken
# 		trigger_event = {
# 			id = regula_initialize_event.0001
# 			days = { 15 45 }
# 		}
# 	}

# 	confirm_text = regula_initialize_decision_confirm.a

# 	ai_will_do = {
# 		base = 0
# 	}
# }

regula_initialize_decision_minor = {
	picture = "gfx/interface/illustrations/decisions/regula_initialize_decision.dds"
	major = no
	title = regula_initialize_decision_minor.t
	desc = regula_initialize_decision_minor_desc
	selection_tooltip = regula_initialize_decision_minor_tooltip

	ai_check_interval = 0 #AI won't consider.

	is_shown = {
		is_ruler = yes
		is_male = yes
		is_ai = no
		age >= 16
		OR = {
			AND = {
				has_global_variable = regula_initialized
				has_global_variable = regula_burned
			}
			AND = {
				has_global_variable = regula_covert_initialized
				NOT = { any_secret = { secret_type = regula_covert_conversion } }
			}
		}
		NOT = { has_character_flag = regula_decision_taken }
		NOT = {
			has_trait = magister_trait_group
			has_character_flag = regula_destroyed_character
		}
	}

	is_valid = {
		# is_independent_ruler = yes
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	effect = {
		custom_tooltip = "regula_initialize_decision_minor_tooltip_effect"
		add_character_flag = regula_decision_taken
		trigger_event = {
			id = regula_initialize_event.0011
			days = { 1 7 }
		}
	}

	confirm_text = regula_initialize_decision_minor_confirm.a

	ai_will_do = {
		base = 0
	}
}

regula_initialize_covert_decision = {
	picture = "gfx/interface/illustrations/decisions/regula_peddler.dds"
	major = yes
	title = regula_initialize_covert_decision.t
	desc = regula_initialize_covert_decision_desc
	selection_tooltip = regula_initialize_covert_decision_tooltip

	ai_check_interval = 0 #AI won't consider.

	is_shown = {
		is_ruler = yes
		is_ai = no
		NOT = { has_global_variable = regula_initialized }
		NOT = { has_global_variable = regula_covert_initialized }
		NOT = { has_character_flag = regula_decision_taken }
		NOT = { any_secret = { secret_type = regula_covert_conversion } }
	}

	is_valid = {
	}

	is_valid_showing_failures_only = {
		is_available = yes
		is_male = yes
		age >= 16

		custom_description = {
			text = regula_choir_conversion_trigger
			NOT = {
				faith = {
					religion_tag = regula_religion
				}
			}
		}
	}

	cost = {
		gold = medium_gold_value
	}

	effect = {
		custom_tooltip = "regula_initialize_covert_decision_tooltip_effect"
		add_character_flag = regula_decision_taken
		trigger_event = {
			id = regula_initialize_event.0003
			days = { 15 45 }
		}
	}

	confirm_text = regula_initialize_covert_decision_confirm.a

	ai_will_do = {
		base = 0
	}
}

regula_initialize_reveal_decision = { # Switch from covert to active.
	picture = "gfx/interface/illustrations/decisions/regula_initialize_decision.dds"
	major = yes
	title = regula_initialize_reveal_decision.t
	desc = regula_initialize_reveal_decision_desc
	selection_tooltip = regula_initialize_reveal_decision_tooltip

	ai_check_interval = 0 #AI won't consider.

	is_shown = {
		is_ruler = yes
		is_male = yes
		is_ai = no
		age >= 16
		any_secret = {
			secret_type = regula_covert_conversion
		}
		NOT = { has_global_variable = regula_initialized }
		NOT = { has_character_flag = regula_decision_taken }
		any_secret = { secret_type = regula_covert_conversion }

	}

	is_valid = {
		highest_held_title_tier >=3
		custom_description = {
			text = regula_spouse_entranced_trigger
			primary_spouse = {
				any_secret = {
					secret_type = regula_covert_conversion
				}
			}
		}
		custom_description = {
			text = regula_2_covert_powerful_vassals_trigger
			regula_num_covert_powerful_vassals >= 2
		}

	}

	is_valid_showing_failures_only = {
		is_available = yes
		is_male = yes
		is_married = yes
		age >= 16
		custom_description = {
			text = regula_faith_head_trigger
			NOT = { root.faith.religious_head = root }
		}
	}

	cost = {
	}

	effect = {
		custom_tooltip = "regula_initialize_reveal_decision_tooltip_effect"
		custom_tooltip = "regula_initialize_reveal_decision_tooltip_effect_religion"
		custom_tooltip = "regula_initialize_reveal_decision_tooltip_effect_domina"
		custom_tooltip = "regula_initialize_reveal_decision_tooltip_effect_mulsa"
		add_character_flag = regula_decision_taken
		trigger_event = {
			id = regula_initialize_event.0001
			days = { 5 15 }
		}
	}

	confirm_text = regula_initialize_reveal_decision_confirm.a

	ai_will_do = {
		base = 0
	}
}


code:
regula_stress_loss_sex_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_misc.dds"
	desc = stress_loss_profligate_decision_desc
	selection_tooltip = stress_loss_profligate_decision_tooltip

	ai_check_interval = 6

	cooldown = { days = 100 }

	is_shown = {
		is_male = no
		OR = {
            has_trait = paelex
            has_trait = domina
            AND = {
                has_trait = mulsa
                has_trait = lustful
            }
        }
		stress > 200
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	effect = {
		trigger_event = {
			on_action = regula_stress_loss_sex
		}
	}

	ai_potential = {
		is_adult = yes
		stress > 200
	}

	ai_will_do = {
		base = 100
		### UPDATE - If Paradox ever fixes the stress spiral, re-enable this and change the base to 0.
		# modifier = {
		# 	add = 25
		# 	stress > low_medium_stress
		# }

		# modifier = {
		# 	add = 50
		# 	stress > medium_stress
		# }

		# modifier = {
		# 	add = 75
		# 	stress > high_stress
		# }

        # modifier = {
        #     add = 15
        #     has_trait = lustful
        # }
        # modifier = {
        #     add = 10
        #     has_sexuality = bisexual
        # }
        # modifier = {
        #     add = 25
        #     has_sexuality = homosexual
        # }
	}
}


code:
regula_take_initiates_from_holy_order_decision = {
	picture = "gfx/interface/illustrations/decisions/regula_corrupt_holy_order_decision.dds"
    major = no
	title = regula_take_initiates_from_holy_order_decision.t
	desc = regula_take_initiates_from_holy_order_decision_desc
	selection_tooltip = regula_take_initiates_from_holy_order_decision_tooltip
	confirm_text = regula_take_initiates_from_holy_order_decision_confirm.a

	cooldown = { years = 5 }

	is_shown = {
		is_ai = no
		religion = religion:regula_religion
		faith = {
			any_faith_holy_order = { #Your faith must have a Holy Order
				always = yes
			}
		}
	}

	is_valid = {
		# Holy order has common inititates
		trigger_if = {
			OR = {
				custom_description = {
					text = regula_take_initiates_from_holy_order_common_trigger
				}
				custom_description = {
					text = regula_take_initiates_from_holy_order_noble_trigger
					regula_num_holy_order_counties >= 15
				}
				custom_description = {
					text = regula_take_initiates_from_holy_order_royal_trigger
					regula_num_holy_order_counties >= 30
				}
			}
		}
	}

	is_valid_showing_failures_only = {
		is_alive = yes
		is_imprisoned = no
	}

	effect = {
		custom_tooltip = "regula_take_initiates_from_holy_order_decision_tooltip_effect"
		# trigger_event = {
		# 	id = regula_take_initiates_from_holy_order.0002
		# }
		if = {
			limit = {
				faith = {
					controls_holy_site_with_flag = holy_site_reg_offspring_flag
				}
			}
			trigger_event = {
				id = regula_take_initiates_from_holy_order.0002
			}
		} else = {
			trigger_event = {
				id = regula_take_initiates_from_holy_order.0001
			}
		}
	}

	cost = {
		piety = 500
	}

	ai_check_interval = 0 # Change this value if you want the AI to consider this decision.
	ai_will_do = {
		base = 0
	}
}


code:
regula_adopt_martial_custom_decision = {
	ai_check_interval = 0
	major = yes

	title = regula_adopt_martial_custom_decision.t
	desc = regula_adopt_martial_custom_decision.desc
	picture = "gfx/interface/illustrations/decisions/regula_adopt_martial_custom_decision.dds"
	selection_tooltip = regula_adopt_martial_custom_decision_tooltip

	is_shown = {
		has_trait = magister_trait_group
		culture = {
			NOT = { has_cultural_pillar = martial_custom_regula }
		}
	}

	is_valid = {
		custom_description = {
			text = holy_site_reg_offspring_held_trigger
			faith = {
				controls_holy_site_with_flag = holy_site_reg_offspring_flag
			}
		}
		custom_description = {
			text = magister_trait_5_required_decision
			OR = {
				has_trait = magister_5
				has_trait = magister_6
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
	}

	cost = {
		piety = 1500
		prestige = 2000
	}

	effect = {
		custom_tooltip = "regula_adopt_martial_custom_decision_tooltip_effect"
		trigger_event = regula_tradition.1001
	}

	confirm_text = regula_adopt_martial_custom_decision.a

	ai_potential = {
		always = yes
	}

	ai_will_do = {
		base = 0
	}
}


code:
regula_settings_decision = {
	picture = "gfx/interface/illustrations/decisions/regula_initialize_decision.dds"
	major = no
	title = regula_settings_decision.t
	desc = regula_settings_decision_desc

	ai_check_interval = 0 #AI won't consider.

	is_shown = {
		is_ruler = yes
		is_ai = no
		has_global_variable = regula_initialized
	}

	is_valid = {
		# is_independent_ruler = yes
	}

	is_valid_showing_failures_only = {
		is_available = yes
	}

	cost = {
	}

	effect = {
		trigger_event = {
			id = regula_initialize_event.1000
		}
	}

	confirm_text = regula_settings_decision_confirm.a

	ai_will_do = {
		base = 0
	}
}


code:
regula_mutare_corpus_mental_boost = {
	first = regula_mutare_corpus_mental_boost_desc
	third = regula_mutare_corpus_mental_boost_desc
	global = regula_mutare_corpus_mental_boost_desc
}

regula_mutare_corpus_physical_boost = {
	first = regula_mutare_corpus_physical_boost_desc
	third = regula_mutare_corpus_physical_boost_desc
	global = regula_mutare_corpus_physical_boost_desc
}

regula_mutare_corpus_sexual_boost = {
	first = regula_mutare_corpus_sexual_boost_desc
	third = regula_mutare_corpus_sexual_boost_desc
	global = regula_mutare_corpus_sexual_boost_desc
}

regula_mutare_corpus_outcome_1 = {
	first = regula_mutare_corpus_outcome_1_desc
	third = regula_mutare_corpus_outcome_1_desc
	global = regula_mutare_corpus_outcome_1_desc
}

regula_mutare_corpus_outcome_2 = {
	first = regula_mutare_corpus_outcome_2_desc
	third = regula_mutare_corpus_outcome_2_desc
	global = regula_mutare_corpus_outcome_2_desc
}

regula_mutare_corpus_outcome_3 = {
	first = regula_mutare_corpus_outcome_3_desc
	third = regula_mutare_corpus_outcome_3_desc
	global = regula_mutare_corpus_outcome_3_desc
}

regula_mutare_corpus_outcome_4 = {
	first = regula_mutare_corpus_outcome_4_desc
	third = regula_mutare_corpus_outcome_4_desc
	global = regula_mutare_corpus_outcome_4_desc
}

regula_mutare_corpus_outcome_5 = {
	first = regula_mutare_corpus_outcome_5_desc
	third = regula_mutare_corpus_outcome_5_desc
	global = regula_mutare_corpus_outcome_5_desc
}