## regula_astringere_interaction
## regula_astringere_activation_interaciton
## regula_astringere_removal_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_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
	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
	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
	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
	}
}

# 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
	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

	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
					}
				}
			}
		}
	}

	
	cooldown = { months = 6 }

	cost = {
		prestige = 50
	}

	on_decline_summary = stop_attacker_vassal_war_decline_summary

	cooldown_against_recipient = { years = 2 }

	auto_accept = {
		OR = {
			scope:recipient = { is_imprisoned_by = scope:actor }
			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
	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
	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 = {
			if = {
				limit = {
					global_var:magister_character.faith = {
						controls_holy_site_with_flag = 	regula_abice_maritus_active
					}
				}
				value = 100
			}
			else = {
				value = 250
			}
		}
	}

	is_valid_showing_failures_only = {
		scope:recipient = {
			piety >= 250
		}
	}

	auto_accept = yes

	on_accept = {
		scope:recipient = {
			add_piety = -250
		}
		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
	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
	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

	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_diplomatically_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
	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
	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 = {
				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
	}
}

# 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_diplomatically_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_diplomatically_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?
	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_diplomatically_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
				}
			}
			global_var:magister_character = {
				change_variable = {
					name = regula_potestas_queen_tally
					add = 1
				}
			}
		}
	}

	ai_will_do = {
		base = 0
	}
}

regula_prisoner_interaction = {
	category = interaction_category_prison
	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
	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
	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
	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
		}
		global_var:magister_character = {
			change_variable = {
				name = regula_fascinare_tally
				add = 1
			}
		}
	}


	auto_accept = yes

	ai_will_do = {
		base = 0
	}
}
