code:
namespace = regula_paelex_event

# 0001 - 0999: Maintenance events.
# 1000 - 1999: Paelex initiation events.
# 2000 - 2999: Domina initiation events.

# Keeps the domina/paelex traits up to date.
regula_paelex_event.0996 = {
	hidden = yes
	type = character_event

	trigger = {
		has_trait = magister_trait_group
		any_consort = {
			OR = {
				has_trait = paelex
				has_trait = domina
			}
		}
	}

	immediate = {
		every_consort = {
			if = {
				limit = {
					has_trait = domina
					NOT = { this = primary_spouse.primary_spouse }
				}
				remove_trait = domina
				add_trait = paelex
			}
			if= {
				limit = {
					has_trait = paelex
					this = primary_spouse.primary_spouse
				}
				remove_trait = paelex
				add_trait = domina
			}
		}
	}
}

# Fixes Head of Faith issues
regula_paelex_event.0997 = {
	hidden = yes
	type = character_event

	trigger = {
		root = faith.religious_head
		is_male = no
		has_realm_law = regula_magister_gender_law
		root.faith = { # This parameter is in a core tenet but should fire as true.
			has_doctrine_parameter = paelex_realm_benefits
		}
	}

	immediate = {
		add_realm_law_skip_effects = regula_vassal_succession_law
	}
}

# Adds landed concubine bonuses.
regula_paelex_event.0998 = {
	hidden = yes
	type = character_event

	trigger = {
	is_ai = no
	has_realm_law = regula_magister_gender_law
	}

	immediate = {
		remove_all_character_modifier_instances = paelex_realm_benefits
		if = {
			limit = {
				faith = {
					has_doctrine = tenet_regula_devoted
				}
			}
			set_while_counter_variable_effect = yes
			while = {
				limit = { var:while_counter < regula_num_landed_concubines }
				add_character_modifier = paelex_realm_benefits
				increase_while_counter_variable_effect = yes
			}
			remove_while_counter_variable_effect = yes
		}
		remove_all_character_modifier_instances = regula_unlanded_consort_penalty
		if = {
			limit = {
				faith = {
					has_doctrine = tenet_regula_devoted
				}
			}
			set_while_counter_variable_effect = yes
			while = {
				limit = { var:while_counter < regula_num_unlanded_consorts }
				add_character_modifier = regula_unlanded_consort_penalty
				increase_while_counter_variable_effect = yes
			}
			remove_while_counter_variable_effect = yes
		}

		# Leaving this in for savegame compatibility.
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits1
			}
			remove_character_modifier = paelex_realm_benefits1
		}
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits2
			}
			remove_character_modifier = paelex_realm_benefits2
		}
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits3
			}
			remove_character_modifier = paelex_realm_benefits3
		}
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits4
			}
			remove_character_modifier = paelex_realm_benefits4
		}
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits5
			}
			remove_character_modifier = paelex_realm_benefits5
		}
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits6
			}
			remove_character_modifier = paelex_realm_benefits6
		}
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits7
			}
			remove_character_modifier = paelex_realm_benefits7
				}
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits8
			}
			remove_character_modifier = paelex_realm_benefits8
		}
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits9
			}
			remove_character_modifier = paelex_realm_benefits9
		}
		if = {
			limit = {
				has_character_modifier = paelex_realm_benefits10
			}
			remove_character_modifier = paelex_realm_benefits10
		}
	}
}

# 0999. Vassal succession law maintenance.
regula_paelex_event.0999 = {
	hidden = yes
	type = character_event

	trigger = {
		# has_realm_law = regula_magister_gender_law
		faith = {
			has_doctrine = tenet_regula_devoted
		}
	}

	immediate = {
		if = {
			limit = {
				has_realm_law = regula_magister_gender_law
			}
			every_vassal_or_below = {
				limit = {
					highest_held_title_tier >= tier_barony
				}
				if = {
					limit = { NOT = { has_realm_law = regula_vassal_succession_law } }
					add_realm_law_skip_effects = regula_vassal_succession_law
				}
			}
		}
		else = {
			if = {
				limit = {
					is_ruler = yes
					is_ai = yes
				}
				if = {
					limit = { NOT = { has_realm_law = regula_vassal_succession_law } }
					add_realm_law_skip_effects = regula_vassal_succession_law
				}
			}
		}
	}
}

######################################################
# 1000-1010: - Initiation events
# 1010-1019: - Mind boosts
# 1020-1029: - Body boosts
# 1030-1039: - Sex boosts
# 1040-1049: - Misc Events
######################################################

### Make a landed vassal a paelex. Smooth with bliss.
regula_paelex_event.1000 = {
	type = character_event
	title = regula_paelex_event.1000.t
	desc = regula_paelex_event.1000.desc
	theme = regula_theme
	override_background = {
		event_background = godless_shrine  # Background: https://www.artstation.com/julesmartinvos
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { regula_blindfold }
    	animation = personality_zealous
	}

	immediate = {
		scope:recipient = {
			set_sexuality = bisexual
			add_character_flag = is_naked
		}
	}

	option = {
		name = regula_mutare_corpus_event.0001.b # Push power into her body. Increased stength and heals body.
		custom_description_no_bullet = { text = regula_mutare_corpus_physical_boost }
		regula_mutare_corpus_physical_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.a # Drive the power into her mind. Increased mental traits, may bump up lifestyle trait.
		custom_description_no_bullet = { text = regula_mutare_corpus_mental_boost }
		regula_mutare_corpus_mental_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.c # Mix power with your seed. Increase Beauty, Inheritable traits and pregnancy.
		custom_description_no_bullet = { text = regula_mutare_corpus_sexual_boost }
		regula_mutare_corpus_sexual_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.d_alt # Take power for yourself.
		add_piety = 300
	}

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

### Make a landed vassal a paelex. Shatter.
regula_paelex_event.1001 = {
	type = character_event
	title = regula_paelex_event.1001.t
	desc = regula_paelex_event.1001.desc
	theme = regula_theme
	override_background = {
		event_background = godless_shrine  # Background: https://www.artstation.com/julesmartinvos
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { regula_blindfold }
    	animation = personality_zealous
	}

	immediate = {
		scope:recipient = {
			set_sexuality = bisexual
			add_character_flag = is_naked
		}
	}

	option = {
		name = regula_mutare_corpus_event.0001.b # Push power into her body. Increased stength and heals body.
		custom_description_no_bullet = { text = regula_mutare_corpus_physical_boost }
		regula_mutare_corpus_physical_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.a # Drive the power into her mind. Increased mental traits, may bump up lifestyle trait.
		custom_description_no_bullet = { text = regula_mutare_corpus_mental_boost }
		regula_mutare_corpus_mental_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.c # Mix power with your seed. Increase Beauty, Inheritable traits and pregnancy.
		custom_description_no_bullet = { text = regula_mutare_corpus_sexual_boost }
		regula_mutare_corpus_sexual_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.d_alt # Take power for yourself.
		add_piety = 300
	}

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

### Make a landed vassal a paelex. Monument.
regula_paelex_event.1002 = {
	type = character_event
	title = regula_paelex_event.1002.t
	desc = regula_paelex_event.1002.desc
	theme = regula_theme
	override_background = {
		event_background = godless_shrine  # Background: https://www.artstation.com/julesmartinvos
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = {  regula_blindfold }
    	animation = personality_zealous
	}

	immediate = {
		scope:recipient = {
			set_sexuality = bisexual
			add_character_flag = is_naked
		}
	}

	option = {
		name = regula_mutare_corpus_event.0001.b # Push power into her body. Increased stength and heals body.
		custom_description_no_bullet = { text = regula_mutare_corpus_physical_boost }
		regula_mutare_corpus_physical_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.a # Drive the power into her mind. Increased mental traits, may bump up lifestyle trait.
		custom_description_no_bullet = { text = regula_mutare_corpus_mental_boost }
		regula_mutare_corpus_mental_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.c # Mix power with your seed. Increase Beauty, Inheritable traits and pregnancy.
		custom_description_no_bullet = { text = regula_mutare_corpus_sexual_boost }
		regula_mutare_corpus_sexual_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.d_alt # Take power for yourself.
		add_piety = 300
	}

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

### Make landed vassal a Paelex.  From Arglwydd
### I position [From.GetFirstName] like a dog and enter her firmly while whispering the Words of Taking. With each thrust my will is pumped into her body, dominating every corner of her mind. [From.GetFirstName] begins moaning "Yes, Mwyaf" with each thrust, each orgasm, each submission. I speak the last Word and release into her. [From.GetFirstName]'s body spasms in ecstasy so great she can only whimper. She is mine.

### Domination war end. Last discussion.
regula_paelex_event.1009 = {
	type = character_event
	title = regula_paelex_event.1009.t

	theme = regula_theme
	override_background = {
		event_background = regula_house_arrest  # Background: https://www.artstation.com/julesmartinvos
	}

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:defender = {
						has_trait = devoted_trait_group
					}
				}
				desc = regula_paelex_event.1009.devoted_intro
			}
			desc = regula_paelex_event.1009.regular_intro
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:defender = {
						tier_difference = {
							target = scope:attacker
							value = -1
						}
					}
				}
				desc = regula_paelex_event.1009.1
			}
			triggered_desc = {
				trigger = {
					scope:defender = {
						tier_difference = {
							target = scope:attacker
							value = -2
						}
					}
				}
				desc = regula_paelex_event.1009.2
			}
			triggered_desc = {
				trigger = {
					scope:defender = {
						tier_difference = {
							target = scope:attacker
							value = -3
						}
					}
				}
				desc = regula_paelex_event.1009.3
			}
			triggered_desc = {
				trigger = {
					scope:defender = {
						tier_difference = {
							target = scope:attacker
							value = -4
						}
					}
				}
				desc = regula_paelex_event.1009.4
			}
			desc = regula_paelex_event.1009.fallback
		}
	}

	right_portrait = {
		character = scope:defender
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
    	triggered_animation = {
			trigger = {
				has_trait = devoted_trait_group
			}
			animation = personality_greedy
		}
		triggered_animation = {
			trigger = {
				NOT = { has_trait = devoted_trait_group }
			}
			animation = disapproval
		}
	}

	immediate = {
		scope:attacker = {
			save_scope_as = actor
		}
		scope:defender = {
			save_scope_as = recipient
			if = {
				limit = { has_trait = devoted_trait_group }
				add_character_flag = {
					flag = is_naked
					days = 180
				}
			}
		}

	}

	option = {
		name = regula_paelex_event.1009.a # Take her to the godless shrine.
		scope:defender = {
			if = {
				limit = {
					has_trait = mulsa
				}
				remove_trait = mulsa
			}
			demand_conversion_interaction_effect = yes
			every_relation = {
				type = lover
				limit = {
					NOT = {
						has_trait = magister_trait_group
					}
				}
				lover_breakup_effect = {
					BREAKER = scope:defender
					LOVER = this
				}
			}
			if = {
				limit = {
					scope:attacker.primary_spouse = scope:defender
				}
				add_trait_force_tooltip = domina
			}
			if = {
				limit = {
					NOT = { scope:attacker.primary_spouse = scope:defender }
				}
				add_trait_force_tooltip = paelex
			}
			### War-specific benefits.
			if = {
				limit = {
					tier_difference = {
						target = scope:attacker
						value = -1
					}
				}
				if = {
					limit = { NOT = { has_trait = diligent } }
					add_trait = diligent
				}
				random_list = {
					20 = {
						trigger = { NOT = { has_trait = military_engineer } }
						add_trait = military_engineer
					}
					20 = {
						trigger = { NOT = { has_trait = unyielding_defender } }
						add_trait = unyielding_defender
					}
					20 = {
						trigger = { NOT = { has_trait = holy_warrior } }
						add_trait = holy_warrior
					}
					20 = {
						trigger = { NOT = { has_trait = organizer } }
						add_trait = organizer
					}
					20 = {
						trigger = { NOT = { has_trait = aggressive_attacker } }
						add_trait = aggressive_attacker
					}
				}
			}
			if = {
				limit = {
					tier_difference = {
						target = scope:attacker
						value = -2
					}
				}
				if = {
					limit = { NOT = { has_trait = diligent } }
					add_trait = diligent
				}
			}
			if = {
				limit = {
					tier_difference = {
						target = scope:attacker
						value = -3
					}
				}
				if = {
					limit = { NOT = { has_trait = content } }
					add_trait = content
				}
				if = {
					limit = { NOT = { has_trait = fecund } }
					add_trait = fecund
				}
			}
			if = {
				limit = {
					tier_difference = {
						target = scope:attacker
						value = -4
					}
				}
				if = {
					limit = { NOT = { has_trait = dull } }
					add_trait = dull
				}
				if = {
					limit = { NOT = { has_trait = content } }
					add_trait = content
				}
				if = {
					limit = { NOT = { has_trait = fecund } }
					add_trait = fecund
				}
			}
		}
		trigger_event = {
			id = regula_paelex_event.1010
		}
	}
}

### Make a independent vassal a paelex. Defeated in Domination war.
regula_paelex_event.1010 = {
	type = character_event
	title = regula_paelex_event.1010.t
	desc = regula_paelex_event.1010.desc
	theme = regula_theme
	override_background = {
		event_background = godless_shrine  # Background: https://www.artstation.com/julesmartinvos
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = {  regula_blindfold }
    	animation = personality_zealous
	}

	immediate = {
		scope:recipient = {
			set_sexuality = bisexual
			add_character_flag = is_naked
		}
	}

	option = {
		name = regula_mutare_corpus_event.0001.b # Push power into her body. Increased stength and heals body.
		custom_description_no_bullet = { text = regula_mutare_corpus_physical_boost }
		regula_mutare_corpus_physical_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.a # Drive the power into her mind. Increased mental traits, may bump up lifestyle trait.
		custom_description_no_bullet = { text = regula_mutare_corpus_mental_boost }
		regula_mutare_corpus_mental_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.c # Mix power with your seed. Increase Beauty, Inheritable traits and pregnancy.
		custom_description_no_bullet = { text = regula_mutare_corpus_sexual_boost }
		regula_mutare_corpus_sexual_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.d_alt # Take power for yourself.
		add_piety = 300
	}

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

# Child of the Book Event Chain
# Add flag that next birth should give Child of the Book Trait
regula_paelex_event.1040 = {
	hidden = yes
	type = character_event

	immediate = {
		set_pregnancy_gender = female
		add_character_flag = {
			flag = regula_domitans_pregnant
			years = 1
		}
	}
}

regula_paelex_event.1041 = {
	hidden = yes
	type = character_event

	trigger = {
		has_character_flag = regula_domitans_pregnant
	}

	immediate = {
		remove_character_flag = regula_domitans_pregnant

		scope:child = {
			save_scope_as = domitans_child
		}
		global_var:magister_character = {
			trigger_event = {
				id = regula_paelex_event.1042
				days = 4
				# years = 4  #REVERT
			}
		}
	}
}

regula_paelex_event.1042 ={
	type = character_event
	title = regula_paelex_event.1042.t
	desc = regula_paelex_event.1042.desc
	theme = regula_theme
	override_background = {
		event_background = study
	}

	right_portrait = {
		character = scope:domitans_child
    	animation = personality_zealous
	}

	immediate = {
		scope:domitans_child = {
			add_trait = regula_child_of_the_book
		}
	}

	option = {
		name = regula_paelex_event.1042.a
	}
}

### Make a landed wife a domina.
regula_paelex_event.2000 ={
	type = character_event
	title = regula_paelex_event.2000.t
	desc = regula_paelex_event.2000.desc
	theme = regula_theme
	override_background = {
		event_background = godless_shrine  # Background: https://www.artstation.com/julesmartinvos
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = {  regula_blindfold }
    	animation = personality_zealous
	}

	immediate = {
		scope:recipient = {
			set_sexuality = bisexual
			add_character_flag = is_naked
		}
	}

	option = {
		name = regula_mutare_corpus_event.0001.b # Push power into her body. Increased stength and heals body.
		custom_description_no_bullet = { text = regula_mutare_corpus_physical_boost }
		regula_mutare_corpus_physical_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.a # Drive the power into her mind. Increased mental traits, may bump up lifestyle trait.
		custom_description_no_bullet = { text = regula_mutare_corpus_mental_boost }
		regula_mutare_corpus_mental_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.c # Mix power with your seed. Increase Beauty, Inheritable traits and pregnancy.
		custom_description_no_bullet = { text = regula_mutare_corpus_sexual_boost }
		regula_mutare_corpus_sexual_boost_effect = yes
	}
	option = {
		name = regula_mutare_corpus_event.0001.d_alt # Take power for yourself.
		add_piety = 300
	}

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


code:
namespace = regula_prisoner_event

regula_prisoner_event.1000 = {  ### UPDATE - Need to remove the bars
	type = character_event
	title = regula_prisoner_event.1000.t

	desc = {
		first_valid = {
			triggered_desc = {  # Add another for lovers?
				trigger = {
					scope:recipient = {
						has_trait = devoted_trait_group
					}
				}
				desc = regula_prisoner_event.1000.desc.devoted
			}
			desc = regula_prisoner_event.1000.desc.standard
		}
	}

	theme = regula_theme
	override_background = {  # Split between house arrest and dungeon?
		event_background = regula_cell
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
    	triggered_animation = {
			trigger = {
				has_trait = devoted_trait_group
			}
			animation = prisonhouse
		}
		triggered_animation = {
			trigger = {
				NOT = { has_trait = devoted_trait_group }
			}
			animation = prisondungeon
		}
	}

	immediate = {
		scope:recipient = {
			add_character_flag = {
				flag = is_naked
				days = 180
			}
		}
	}

	option = { # Charm at half piety cost.
		name = regula_prisoner_event.1000.a
		flavor = regula_prisoner_event.1000.a.tt
		trigger = {
			scope:recipient = {
				NOT = { has_trait = devoted_trait_group }
				NOT = { has_trait = contubernalis }
			}
			scope:actor = {
				custom_description = {
					text = magister_trait_2_required_trigger
					has_trait_rank = {
						trait = magister_trait_group
						rank >= 2
					}
				}
			}
		}

		show_as_tooltip = {
			scope:recipient = {
				fascinare_success_effect = { CHARACTER = root }
			}
			scope:actor = {
				add_piety = -50
			}
		}
		scope:actor = {
			trigger_event = regula_prisoner_event.1001
		}
	}

	option = { # Puppet at half piety cost.
		name = regula_prisoner_event.1000.b
		flavor = regula_prisoner_event.1000.b.tt
		trigger = {
			scope:recipient = {
				NOT = { has_trait = sigillum }
				has_trait = devoted_trait_group
			}
			scope:actor = {
				custom_description = {
					text = magister_trait_3_required_trigger
					has_trait_rank = {
						trait = magister_trait_group
						rank >= 3
					}
				}
			}
		}

		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_piety = -75
			}
		}

		scope:actor = {
			trigger_event = regula_prisoner_event.1002
		}
	}

	option = { # Sex interaction.  Overwhelming lust.
		name = regula_prisoner_event.1000.c
		flavor = regula_prisoner_event.1000.c.tt
		trigger = {
			scope:actor = {
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 2
				}
			}
		}
		show_as_tooltip = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = scope:actor
				CHARACTER_2 = scope:recipient
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = no
			}
		}
		scope:actor = {
			trigger_event = regula_prisoner_event.1003 # Masquerade
		}
	}

	option = { # Pretend to be lover? Become her lover. Also removes rival relationship.
		name = regula_prisoner_event.1000.d
		flavor = regula_prisoner_event.1000.d.tt
		trigger = {
			scope:actor = {
				custom_description = {
					text = magister_trait_4_required_trigger
					has_trait_rank = {
						trait = magister_trait_group
						rank >= 4
					}
				}

				NOT = { has_relation_lover = scope:recipient }
			}
			scope:recipient = {
				OR = {
					is_married = yes
					num_of_relation_lover >= 1
				}
				NOT = { is_spouse_of = scope:actor }
			}
		}

		show_as_tooltip = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = scope:actor
				CHARACTER_2 = scope:recipient
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = no
			}
			scope:recipient = {
				if = {
					limit = { num_of_relation_lover >=1 }
					scope:recipient = {
						random_relation = {
							type = lover
							lover_breakup_effect = {
								BREAKER = scope:recipient
								LOVER = this
							}
						}
					}
				}
			}
			scope:actor = {
				set_relation_lover = scope:recipient
			}
		}
		scope:actor = {
			trigger_event = regula_prisoner_event.1004
		}
		# scope:recipient = {  # Better as a cuckhold thing.
		# 	if = {
		# 		limit = {
		# 			OR = {
		# 				is_married = yes
		# 				num_of_relation_lover >= 1
		# 			}
		# 			NOT = { is_spouse_of = scope:actor }
		# 		}
		# 		scope:actor = {
		# 			trigger_event = regula_prisoner_event.1004 # Masquerade
		# 		}
		# 	}
		# 	else = {
		# 		scope:actor = {
		# 			trigger_event = regula_prisoner_event.1005 # Love spell
		# 		}
		# 	}
		# }
	}

	option = { # Contubernalis.  High piety cost (500?), and requires level 3 or 4.
		name = regula_prisoner_event.1000.e
		flavor = regula_prisoner_event.1000.e.tt

		trigger = {
			scope:actor = {
				custom_description = {
					text = magister_trait_4_required_trigger
					has_trait_rank = {
						trait = magister_trait_group
						rank >= 5
					}
				}
			}
			scope:recipient = {
				NOT = { has_trait = contubernalis }
			}
			scope:actor = {
				piety >= 500
			}
		}

		show_as_unavailable = {
			scope:actor = {
				custom_description = {
					text = magister_trait_4_required_trigger
					has_trait_rank = {
						trait = magister_trait_group
						rank >= 5
					}
				}
			}
			scope:recipient = {
				NOT = { has_trait = contubernalis }
			}
			scope:actor = {
				piety < 500
			}
		}

		show_as_tooltip = {  ### UPDATE - Add a note about their relations disliking this?
			scope:recipient = {
				regula_turn_into_contubernalis = yes
			}
			scope:actor = {
				add_piety = -500
				add_dread = medium_dread_gain
				add_tyranny = 10
			}
		}
		scope:actor = {
			trigger_event = regula_prisoner_event.1006
		}
	}

	option = { # Leave them.
		name = regula_prisoner_event.1000.f
		scope:recipient = {
			remove_character_flag = is_naked
		}
	}

	after = {
	}
}

# Charm
regula_prisoner_event.1001 = {
	type = character_event
	title = regula_prisoner_event.1001.t
	desc = regula_prisoner_event.1001.desc

	theme = dungeon
	override_background = {
		event_background = regula_cell
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_greedy
	}

	immediate = {
		scope:recipient = {
			fascinare_success_effect = { CHARACTER = root }
			# if = {
			# 	limit = {
			# 		NOT = { has_trait = deviant }
			# 	}
			# 	add_trait = deviant ### UPDAGE - Not really appropriate.  Need to make a bondage-specific trait.
			# }
		}
		scope:actor = {
			add_piety = -50
		}
	}

	option = { # Back to cell
		name = regula_prisoner_event.1001.a

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

	option = { # Leave them.
		name = regula_prisoner_event.1000.f
		scope:recipient = {
			remove_character_flag = is_naked
		}
	}
}

# Puppet
regula_prisoner_event.1002 = {
	type = character_event
	title = regula_prisoner_event.1002.t
	desc = regula_prisoner_event.1002.desc

	theme = dungeon
	override_background = {
		event_background = regula_cell
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = sick

	}

	immediate = {
		scope:recipient = {
			add_trait = sigillum
			add_stress = medium_stress_gain
		}
		scope:actor = {
			add_hook = {
				target = scope:recipient
				type = regula_sigillum_hook
			}
		}
	}

	option = { # Back to cell
		name = regula_prisoner_event.1002.a

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

	option = { # Leave them.
		name = regula_prisoner_event.1000.f
		scope:recipient = {
			remove_character_flag = is_naked
		}
	}
}

# Sex
regula_prisoner_event.1003 = {
	type = character_event
	title = regula_prisoner_event.1003.t
	desc = regula_prisoner_event.1003.desc

	theme = dungeon
	override_background = {
		event_background = regula_cell
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = happiness
	}

	immediate = {
		carn_had_sex_with_effect = {
			CHARACTER_1 = scope:actor
			CHARACTER_2 = scope:recipient
			C1_PREGNANCY_CHANCE = pregnancy_chance
			C2_PREGNANCY_CHANCE = pregnancy_chance
			STRESS_EFFECTS = yes
			DRAMA = no
		}
	}

	option = { # Back to cell
		name = regula_prisoner_event.1003.a

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

	option = { # Leave them.
		name = regula_prisoner_event.1003.b
		scope:recipient = {
			remove_character_flag = is_naked
		}
	}
}

# Love spell - lover
regula_prisoner_event.1004 = {
	type = character_event
	title = regula_prisoner_event.1004.t
	desc = regula_prisoner_event.1004.desc

	theme = dungeon
	override_background = {
		event_background = regula_cell
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = shock ### Update
	}

	immediate = {
		if = {
			limit = {
				num_of_relation_lover = 0
			}
			scope:recipient.primary_spouse = {
				save_scope_as = old_lover
			}
		}
		else = {
			scope:relation = {
				random_relation = {
					type = lover
					save_scope_as = old_lover
				}
			}
		}
		carn_had_sex_with_effect = {
			CHARACTER_1 = scope:actor
			CHARACTER_2 = scope:recipient
			C1_PREGNANCY_CHANCE = pregnancy_chance
			C2_PREGNANCY_CHANCE = pregnancy_chance
			STRESS_EFFECTS = yes
			DRAMA = no
		}
		scope:recipient = {
			every_relation = {
				type = lover
				lover_breakup_effect = {
					BREAKER = scope:recipient
					LOVER = this
				}
			}
		}
		scope:recipient = {
			remove_relation_nemesis = scope:actor
			remove_relation_rival = scope:actor
		}
		scope:actor = {
			set_relation_lover = scope:recipient
		}
	}

	option = { # Back to cell
		name = regula_prisoner_event.1004.a

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

	option = { # Leave them.
		name = regula_prisoner_event.1004.b

		scope:recipient = {
			remove_character_flag = is_naked
		}
	}
}

# Love spell - basic
regula_prisoner_event.1005 = {
	type = character_event
	title = regula_prisoner_event.1005.t
	desc = regula_prisoner_event.1005.desc

	theme = dungeon
	override_background = {
		event_background = regula_cell
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = prison_dungeon
	}

	immediate = {
		carn_had_sex_with_effect = {
			CHARACTER_1 = scope:actor
			CHARACTER_2 = scope:recipient
			C1_PREGNANCY_CHANCE = pregnancy_chance
			C2_PREGNANCY_CHANCE = pregnancy_chance
			STRESS_EFFECTS = yes
			DRAMA = no
		}
		scope:recipient = {
			remove_relation_nemesis = scope:actor
			remove_relation_rival = scope:actor
		}
		scope:actor = { # Remove rival flag?
			set_relation_lover = scope:recipient
		}
	}

	option = { # Back to cell
		name = regula_prisoner_event.1001.a

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

	option = { # Leave them.
		name = regula_prisoner_event.1000.f
		scope:recipient = {
			remove_character_flag = is_naked
		}
	}
}

# Contubernalis
regula_prisoner_event.1006 = {
	type = character_event
	title = regula_prisoner_event.1006.t
	desc = regula_prisoner_event.1006.desc

	theme = dungeon
	override_background = {
		event_background = regula_cell
	}

	right_portrait = {
		character = scope:recipient
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = fear
	}

	immediate = { ## Warp appearance? (beauty trait or otherwise).
		scope:recipient = {
			regula_turn_into_contubernalis = yes
		}
		scope:actor = {
			add_piety = -500
			add_dread = medium_dread_gain
			add_tyranny = 10
		}
		# Iterate the Contubernalis counter
		change_global_variable = {
			name = regula_contubernalis_tally
			add = 1
		}
	}

	option = { # Back to cell
		name = regula_prisoner_event.1006.a

		scope:actor = {
			recruit_courtier = scope:recipient
		}
		scope:recipient = {
			release_from_prison = yes
		}
	}

	option = { # Leave them.
		name = regula_prisoner_event.1000.f

		scope:actor = {
			recruit_courtier = scope:recipient
		}
		scope:recipient = {
			release_from_prison = yes
		}

		scope:recipient = {
			remove_character_flag = is_naked
		}
	}
}

license: mit


code:
# The outcome of a fascinare scheme.  Largely based on the seduction scheme.

namespace = fascinare_outcome

# NOTE: To set up a new scheme outcome, make sure that you make an event for the owner and one for the target, and add them to their relevant on_actions.

# 0000-0999: Maintenance events
# 1000-1999: Setup events
# 2000-2999: Success events for scheme owner
# 4000-4999: Failure events for scheme owner

######################################################
# MAINTENANCE EVENTS
# 0000-0999
######################################################

#I am a player and there is a discovery chance. Do I want to take the risk?
fascinare_outcome.0001 = {
	type = character_event
	title = fascinare_outcome.0001.t
	desc = {
		desc = fascinare_outcome.0001.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:scheme.scheme_success_chance >= 60 }
				desc = fascinare_outcome.0001.positive.desc
			}
			desc = fascinare_outcome.0001.negative.desc
		}
	}
	theme = regula_theme
	override_background = {
		event_background = corridor_day
	}
	left_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
	}

	option = {
		name = fascinare_outcome.0001.a
		custom_tooltip = fascinare_outcome.0001.a.tt
		trigger_event = fascinare_outcome.0002 #Do the rolls!

		stress_impact = {
			craven = minor_stress_impact_gain
		}
	}

	option = {
		name = fascinare_outcome.0001.b
		stress_impact = {
			ambitious = minor_stress_impact_gain
		}
		scope:scheme = {
			end_scheme = yes
		}
	}
}

#Rolls success and discovery, and triggers on_actions (or sends "player's choice" event)
fascinare_outcome.0002 = {
	type = character_event

	hidden = yes

	immediate = {
		#SUCCESS ROLL
		random = {
			chance = scope:scheme.scheme_success_chance

			save_scope_value_as = {
				name = scheme_successful
				value = yes
			}
		}

		#DISCOVERY ROLL
		save_scope_value_as = {
			name = discovery_chance
			value = {
				value = 100
				subtract = scope:scheme.scheme_secrecy
			}
		}

		random = {
			chance = scope:discovery_chance
			save_scope_value_as = {
				name = scheme_discovered
				value = yes
			}
		}

		#AI always succeeds.
		if = {
			limit = {
				scope:owner = {
					is_ai = yes
				}
			}
			trigger_event = {
				on_action = fascinare_success
			}
		}
		else_if = {
			limit = {
				exists = scope:scheme_successful
			}
			trigger_event = {
				on_action = fascinare_success
			}
		}
		else = {
			trigger_event = {
				on_action = fascinare_failure
			}
		}
		# #FOR PLAYER CHARACTER, SEND CHOICE EVENT
		# else = {
		# 	scope:target = {
		# 		trigger_event = {
		# 			id = fascinare_outcome.0003
		# 		}
		# 	}
		# }
	}
}

# Target acquires the mulsa trait through other means.
fascinare_outcome.0004 = {
	type = character_event
	title = fascinare_outcome.0004.t
	desc = fascinare_outcome.0004.desc

	theme = regula_theme
	override_background = {
		event_background = throne_room
	}
	left_portrait = scope:target
	#No scheme, no widget

	option = {
		name = fascinare_outcome.0004.a
		add_piety = 100
	}
}

#Target died
fascinare_outcome.0005 = {
	type = character_event
	title = fascinare_outcome.0005.t
	desc = fascinare_outcome.0005.desc

	theme = regula_theme
	override_background = {
		event_background = throne_room
	}
	left_portrait = scope:target
	#No scheme, no widget

	option = {
		name = fascinare_outcome.0005.a
		add_piety = 100
	}
}

######################################################
# SUCCESS EVENTS FOR OWNER
# 2000-2999
######################################################

# Default charm script.
# fascinare_outcome.2301 = {
# 	type = character_event
# 	title = fascinare_outcome.2301.t
# 	desc = fascinare_outcome.2301.desc

# 	theme = seduce_scheme
# 	left_portrait = {
# 		character = scope:target
# 		animation = shock
# 	}
# 	widget = {
# 		gui = "event_window_widget_scheme"
# 		container = "custom_widgets_container"
# 	}

################# This section changes the likelihood of the scene appearing.
# 	weight_multiplier = {
# 		base = 0.5
# 		modifier = { #More likely if you're in the same court
# 			add = 0.7
# 			seduction_target_is_close_trigger = yes
# 		}
# 		modifier = { #Less likely if you're the target's spouse
# 			add = -0.2
# 			scope:target = { is_spouse_of = root }
# 		}
# 	}
	# weight_multiplier = {
	# 	base = 0.5
	# 	modifier = { #Much more likely if target is a hunter
	# 		add = 2
	# 		scope:target = { has_trait = lifestyle_hunter }
	# 	}
	# 	modifier = { #More likely if you're also a hunter!
	# 		add = 1
	# 		has_trait = lifestyle_hunter
	# 	}
	# 	modifier = {
	# 		add = 0.5
	# 		seduction_target_is_close_trigger = no
	# 	}
	# }

#################

# 	immediate = {
# 		scope:target = {
# 			if = {
# 				limit = { root = { is_ai = no }	}
# 				assign_quirk_effect = yes
# 			}
# 		}
# 		scope:target = { #Adds trait, converts religion. Possibly scope:recipient.
# 			add_trait = mulsa
# 			set_character_faith = global_var:magister_character.faith
#			hidden_effect = { # No take-backs.
#				add_character_flag = converted_by_forced_conversion_interaction
#				years = 10
#			}
# 		}
#		play_music_cue = "mx_cue_seduction"
# 	}

# 	option = { #Finialize the action
# 		name = fascinare_outcome.2301.a
# 		flavor = fascinare_outcome.2301.a.tt
# 		ai_chance = {
# 			base = 100
# 		}
# 	}

# 	after = {
# 		scope:target = {
# 			trigger_event = seduce_outcome.3301
# 		}
# 		show_as_tooltip = {
# 			scope:scheme = {
# 				end_scheme = yes
# 			}
# 		}
# 	}
# }

#Go to the target's chambers
fascinare_outcome.2301 = {
	type = character_event
	title = fascinare_outcome.2301.t
	desc = fascinare_outcome.2301.desc

	theme = regula_theme
	override_background = {
		event_background = bedchamber
	}

	left_portrait = {
		character = scope:target
		animation = shock
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if you're in the same court
			add = 0.7
			seduction_target_is_close_trigger = yes
		}
		modifier = { #Less likely if you're the target's spouse
			add = -0.2
			scope:target = { is_spouse_of = root }
		}
	}
	immediate = {
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion.
			fascinare_success_effect = { CHARACTER = root }
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2301.a
		flavor = fascinare_outcome.2301.a.tt
		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

# Charm foreigner/outsider.
fascinare_outcome.2302 = {
	type = character_event
	title = fascinare_outcome.2302.t
	desc = fascinare_outcome.2302.desc

	theme = seduce_scheme
	override_background = {
		event_background = sitting_room
	}
	left_portrait = {
		character = scope:target
		animation = shock
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if you're not in the same court
			add = 0.7
			seduction_target_is_close_trigger = no
		}
		modifier = { #Much more likely if target talkative
			add = 1
			scope:target = { has_trait = gregarious }
		}
		modifier = { #More likely if you're also a hunter!
			add = 0.5
			has_trait = gregarious
		}
	}

	immediate = {
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion. Possibly scope:recipient.
			fascinare_success_effect = { CHARACTER = root }
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2302.a
		flavor = fascinare_outcome.2301.a.tt
		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

# Charm by candelight
fascinare_outcome.2303 = {
	type = character_event
	title = fascinare_outcome.2303.t
	desc = fascinare_outcome.2303.desc

	theme = seduce_scheme
	override_background = {
		event_background = physicians_study
	}
	left_portrait = {
		character = scope:target
		animation = shock
	}

	trigger = { # Must be a ruler.
		scope:target = {
			is_landed = yes
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #Much more likely if target works hard
			add = 2
			scope:target = { has_trait = diligent }
		}
		modifier = {
			add = 1
			scope:target = { has_trait = ambitious }
		}
	}

	immediate = {
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion. Possibly scope:recipient.
			fascinare_success_effect = { CHARACTER = root }
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2303.a
		flavor = fascinare_outcome.2301.a.tt
		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

# Insane
fascinare_outcome.2304 = {
	type = character_event
	title = fascinare_outcome.2304.t
	desc = fascinare_outcome.2304.desc

	theme = seduce_scheme
	override_background = {
		event_background = garden
	}
	left_portrait = {
		character = scope:target
		animation = paranoia
	}

	trigger = { # Must be insane
		scope:target = {
			OR = {
				has_trait = lunatic_1
				has_trait = lunatic_genetic
			}
		}
	}

	weight_multiplier = {
		base = 0.5
	}

	immediate = {
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion. Possibly scope:recipient.
			fascinare_success_effect = { CHARACTER = root }
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2304.a
		flavor = fascinare_outcome.2301.a.tt
		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

#Charm a courtier
fascinare_outcome.2305 = {
	type = character_event
	title = fascinare_outcome.2305.t
	desc = fascinare_outcome.2305.desc
	override_background = {
		event_background = regula_bedchamber
	}
	theme = regula_theme
	left_portrait = {
		character = scope:event_paelex
		animation = flirtation
	}
	right_portrait = {
		character = scope:target
		animation = shock
	}

	trigger = {
		any_consort = {
			OR = {
				has_trait = paelex
				has_trait = domina
			}
		}
		NOT = {	root.primary_spouse = scope:target }
		scope:target = {
			is_courtier_of = root
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #More likely if you're not in the same court
			add = 1
			seduction_target_is_close_trigger = yes
		}
		modifier = { # More likely if rumors are swirling.
			add = 1
			regula_num_landed_concubines >=4
		}
	}

	immediate = {
		random_consort = {
			limit = {
				OR = {
					has_trait = paelex
					has_trait = domina
				}
			}
			save_scope_as = event_paelex
		}
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion. Possibly scope:recipient.
			fascinare_success_effect = { CHARACTER = root }
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2305.a
		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

#Charm your spouse
fascinare_outcome.2306 = {
	type = character_event
	title = fascinare_outcome.2306.t
	desc = fascinare_outcome.2306.desc

	theme = regula_theme
	override_background = {
		event_background = bedchamber
	}
	left_portrait = {
		character = scope:target
		animation = shock
	}

	trigger = {
		root.primary_spouse = scope:target
	}

	weight_multiplier = {
		base = 10
	}

	immediate = {
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion. Possibly scope:recipient.
			fascinare_success_effect = { CHARACTER = root }
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2306.a
		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

#Charming rival
fascinare_outcome.2307 = {
	type = character_event
	title = fascinare_outcome.2307.t
	desc = fascinare_outcome.2307.desc

	theme = regula_theme
	override_background = {
		event_background = sitting_room
	}
	left_portrait = {
		character = scope:target
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = beg
	}

	trigger = {
		OR = {
			has_relation_rival = scope:target
			opinion = {
				target = scope:target
				value < high_negative_opinion
			}
			reverse_opinion = {
				target = scope:target
				value < high_negative_opinion
			}
		}
	}

	weight_multiplier = {
		base = 4
	}

	immediate = {
		if = {
			limit = {
				has_relation_rival = scope:target
			}
			remove_relation_rival = scope:target
		}
		if = {
			limit = {
				has_relation_nemesis = scope:target
			}
			remove_relation_nemesis = scope:target
		}
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion.
			add_trait = humble
			fascinare_success_effect = { CHARACTER = root }
			add_character_flag = {
				flag = is_naked
				days = 180
			}
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2307.a

		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3307
			remove_character_flag = is_naked
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

#Charming close family member
fascinare_outcome.2308 = {
	type = character_event
	title = fascinare_outcome.2308.t
	desc = fascinare_outcome.2308_desc

	theme = regula_theme
	override_background = {
		event_background = sitting_room
	}
	left_portrait = {
		character = scope:target
		animation = shock
	}

	trigger = {
		is_close_family_of = scope:target
	}

	immediate = {
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion. Possibly scope:recipient.
			fascinare_success_effect = { CHARACTER = root }
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2308.a

		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3308
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

# Zealous compedita
fascinare_outcome.2309 = {
	type = character_event
	title = fascinare_outcome.2309.t
	desc = fascinare_outcome.2309.desc

	theme = seduce_scheme
	override_background = {
		event_background = throne_room
	}
	left_portrait = {
		character = scope:target
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = happiness ### Update - Find something appropriate.
	}

	trigger = { # Must be a compedita.
		scope:target.faith = {
			religion_tag = regula_religion
		}
	}

	weight_multiplier = {
		base = 0.5
		modifier = { #Much more likely if target is zealous
			add = 2
			scope:target = { has_trait = zealous }
		}
		modifier = {
			add = -0.5
			scope:target = { has_trait = cynical }
		}
	}

	immediate = {

		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion. Possibly scope:recipient.
			fascinare_success_effect = { CHARACTER = root }
			add_character_flag = {
				flag = is_naked
				days = 1
			}
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2309.a
		flavor = fascinare_outcome.2301.a.tt
		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

#Charm a secondary spouse through dance.
fascinare_outcome.2310 = {
	type = character_event
	title = fascinare_outcome.2310.t
	desc = fascinare_outcome.2310.desc
	override_background = {
		event_background = regula_orgy
	}
	theme = regula_theme
	left_portrait = {
		character = scope:paelex
		animation = flirtation
	}
	right_portrait = {
		character = scope:target
		animation = shock
	}

	trigger = {
		any_consort = {
			OR = {
				has_trait = paelex
				has_trait = domina
			}
		}
		scope:target = {
			is_spouse_of = root
		}
		NOT = {	root.primary_spouse = scope:target }
	}

	weight_multiplier = {
		base = 4
	}

	immediate = {
		random_spouse = {
			limit = {
				OR = {
					has_trait = paelex
					has_trait = domina
				}
			}
			save_scope_as = paelex
		}
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
		scope:target = { #Adds trait, converts religion. Possibly scope:recipient.
			fascinare_success_effect = { CHARACTER = root }
			if = {
				limit = {
					has_trait = shy
				}
				remove_trait = shy
			}
		}
		play_music_cue = "mx_cue_seduction"
	}

	option = { #Finialize the action
		name = fascinare_outcome.2310.a
		ai_chance = {
			base = 100
		}
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

# Charming automatically
fascinare_outcome.2311 = {
	type = character_event
	hidden = yes

	trigger = {
		global_var:fascinare_events_enabled = no
	}

	immediate = {
		send_interface_message = {
			type = event_generic_good
			title = target_fascinare_success_effect.desc
			left_icon = scope:target
			scope:target = {
				if = {
					limit = { root = { is_ai = no }	}
					assign_quirk_effect = yes
				}
				fascinare_success_effect = { CHARACTER = root } #Adds trait, converts religion.
				trigger_event = seduce_outcome.3301
			}
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

# Ward Charming

# Child comes of age
fascinare_outcome.2500 = {
	hidden = yes
	trigger = {
		NOT = { has_trait = devoted_trait_group }
		is_male = no # leaving an opening for futa, etc.
		OR = {
			any_relation = {
				type = guardian
				OR = {
					has_trait = devoted_trait_group
					has_trait = magister_trait_group
				}
			}
			has_trait = regula_obedience_bloodline
		}
	}
	immediate = {
		save_scope_as = teen	# save our current scope as the teen ward
		if = { # If events are disabled, use a notification instead
			limit = {
				global_var:ward_enslavement_events_enabled = no
			}
			global_var:magister_character = {
				trigger_event = fascinare_outcome.2505
			}
		}
		else = { # If events are enabled, run the event
			if ={ # If the guardian is the player. Guaranteed success
				limit = {
					any_relation = {
						type = guardian
						has_trait = magister_trait_group
					}
				}
				random_relation = {
					type = guardian
					save_scope_as = guardian
					global_var:magister_character = {
						trigger_event = fascinare_outcome.2501
					}
				}
			}
			else_if = { # If the guardian is the the players direct vassal paelex or domina. Guaranteed success
				limit = {
					any_relation = {
						type = guardian
						OR = {
							has_trait = paelex
							has_trait = domina
						}
						liege = { # Only direct vassals, to keep the events low.
							has_trait = magister_trait_group
						}
					}
				}
				random_relation = {
					type = guardian
					save_scope_as = guardian
				}
				global_var:magister_character = {
					trigger_event = fascinare_outcome.2503
				}
			}
			else_if = {   # If the guardian is a vassal mulsa. Not guaranteed success
				limit = {
					any_relation = {
						type = guardian
						has_trait = mulsa
						liege = global_var:magister_character
					}
				}
				save_scope_as = teen
				random_relation = {
					type = guardian
					save_scope_as = guardian
				}
				global_var:magister_character = {
					trigger_event = fascinare_outcome.2502
				}
			}
			else_if = {   # If the teen has the obdience trait. Guaranteed success
				limit = {
					has_trait = regula_obedience_bloodline
				}
				save_scope_as = teen
				global_var:magister_character = {
					trigger_event = fascinare_outcome.2504
				}
			}
			else = { # For non-realm mulsa just add the trait.  Fallback.
				save_scope_as = teen
				random_relation = {
					type = guardian
					save_scope_as = guardian
				}
				scope:guardian = {
					trigger_event = fascinare_outcome.2502
				}
			}
		}
	}
}

# Entrance your ward, guaranteed to happen
fascinare_outcome.2501 = {
	type = character_event
	title = fascinare_outcome.2501.t
	desc = fascinare_outcome.2501.desc
	theme = regula_theme
	override_background = {
		event_background = study
	}
	right_portrait = {
		character = scope:teen
		animation = idle
	}

	immediate = {
	}
	# Charm.
	option = {
		name = fascinare_outcome.2501.a
		scope:teen = {
			fascinare_success_effect = { CHARACTER = root }
			ward_enslavement_success_effect = yes
		}

		ai_chance = {
			base = 100
		}
	}
	# Leave them be.
	option = {
		name = fascinare_outcome.2501.b

	}
}

# Entrance the ward of a Mulsa, not guaranteed to happen, has a sucess chance based on ward/guardian traits
fascinare_outcome.2502 = {
	type = character_event
	title = fascinare_outcome.2502.t
	desc = fascinare_outcome.2502.desc
	theme = regula_theme
	override_background = {
		event_background = study
	}
	left_portrait = {
		character = scope:guardian
		animation = disbelief
	}
	right_portrait = {
		character = scope:teen
		animation = shock
	}

	immediate = {

	}
	# Attempt to charm.
	option = {
		name = fascinare_outcome.2502.a
		random_list = {
			# Charm successful
			50 = {
				desc = teen_fascinare_success_effect.desc

				modifier = {
					scope:guardian = {
						has_trait = lustful
					}
					add = 20
				}
				modifier = {
					scope:guardian = {
						has_trait = deviant
					}
					add = 20
				}
				modifier = {
					scope:teen = { has_trait = ambitious }
					add = 20
				}
				modifier = {
					scope:teen = { has_trait = lustful }
					add = 20
				}
				modifier = {
					scope:teen = { has_trait = deviant }
					add = 40
				}
				opinion_modifier = {
					who = scope:teen
					opinion_target = global_var:magister_character
					multiplier = 0.25
					step = 5
				}
				send_interface_toast = {
					title = teen_fascinare_success_effect.desc
					left_icon = scope:teen
					scope:teen = {
						fascinare_success_effect = { CHARACTER = root }
						ward_enslavement_success_effect = yes
					}
				}
			}
			35 = {
				desc = teen_fascinare_failure_effect.desc
				opinion_modifier = {
					who = scope:teen
					opinion_target = global_var:magister_character
					multiplier = -0.25
					step = 5
				}
				modifier = {
					scope:teen = { has_sexuality = homosexual }
					add = 40
				}
				modifier = {
					scope:teen = { has_trait = chaste }
					add = 40
				}
				modifier = {
					scope:guardian = { has_trait = chaste }
					add = 20
				}
				modifier = {
					scope:guardian = { has_trait = celibate }
					add = 40
				}
				modifier = {
					scope:guardian = { has_trait = stubborn }
					add = 20
				}
				modifier = {
					scope:teen = { has_trait = stubborn }
					add = 40
				}

				send_interface_toast = {
					title = teen_fascinare_failure_effect.desc
					left_icon = scope:teen
				}
			}
			15 = {
				desc = teen_fascinare_critical_failure_effect.desc

				opinion_modifier = {
					who = scope:teen
					opinion_target = global_var:magister_character
					multiplier = -0.25
					step = 5
				}
				modifier = {
					scope:teen = { has_trait = celibate }
					add = 150
				}
				modifier = {
					scope:teen = { has_sexuality = asexual }
					add = 150
				}

				send_interface_toast = {
					title = teen_fascinare_critical_failure_effect.desc
					left_icon = scope:teen
					scope:teen = {
						add_opinion = {
							target = global_var:magister_character
							modifier = hate_opinion
							opinion = -30
						}
					}
				}
			}
		}
	}
	# Leave them be.
	option = {
		name = fascinare_outcome.2502.b
	}
}

# Entrance the ward of a Domina, Paelex, guaranteed to happen
fascinare_outcome.2503 = {
	type = character_event
	title = fascinare_outcome.2503.t
	desc = fascinare_outcome.2503.desc
	theme = regula_theme
	override_background = {
		event_background = study
	}
	left_portrait = {
		character = scope:guardian
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = chaplain  ### Update - Nothing really works.  Need custom poses.
	}
	right_portrait = {
		character = scope:teen
		animation = shock
	}

	immediate = {
		scope:guardian = {
			if = {
				limit = {
					OR = {
						has_trait = paelex
						has_trait = domina
						has_trait = orba
					}
					NOT = {
						has_character_flag = is_naked
					}
				}
				add_character_flag = {
					flag = is_naked
					days = 1
				}
			}
		}
	}
	# Charm.
	option = {
		name = fascinare_outcome.2503.a
		scope:teen = {
			fascinare_success_effect = { CHARACTER = root }
			ward_enslavement_success_effect = yes
		}
	}
	# Leave them be.
	option = {
		name = fascinare_outcome.2503.b
	}
}

# Entrance the obedient character
# Entrance your ward, Guaranteed to happen
fascinare_outcome.2504 = {
	type = character_event
	title = fascinare_outcome.2504.t
	desc = fascinare_outcome.2504.desc
	theme = regula_theme
	override_background = {
		event_background = study
	}
	left_portrait = {
		character = global_var:magister_character
		animation = happiness
	}
	right_portrait = {
		character = scope:teen
		animation = admiration
	}

	immediate = {
	}

	# Charm.
	option = {
		name = fascinare_outcome.2504.a
		scope:teen = {
			fascinare_success_effect = { CHARACTER = root }
			ward_enslavement_success_effect = yes
		}

		ai_chance = {
			base = 100
		}
	}

	# Leave them be.
	option = {
		name = fascinare_outcome.2504.b
	}
}

# Entrance your ward automatically
fascinare_outcome.2505 = {
	type = character_event
	hidden = yes

	immediate = {
		send_interface_message = {
			type = event_generic_good
			title = teen_fascinare_success_effect.desc
			left_icon = scope:teen
			scope:teen = {
				fascinare_success_effect = { CHARACTER = root }
				ward_enslavement_success_effect = yes
			}
		}
	}
}

##### This code is probably irrelevant, but may be useful in the future.
# #Outcome using the sex scene generator.
# #by Linnéa Thimrén
# seduce_outcome.2309 = {
# 	type = character_event
# 	title = seduce_outcome.2309.t
# 	desc = {
# 		desc = seduce_outcome.2309.desc_opening
# 		desc = seduce_outcome.2309.desc_ending
# 	}

# 	theme = seduce_scheme
# 	left_portrait = {
# 		character = scope:target
# 		animation = flirtation_left
# 	}
# 	widget = {
# 		gui = "event_window_widget_scheme"
# 		container = "custom_widgets_container"
# 	}

# 	trigger = {
# 		NOR = {
# 			has_trait = chaste
# 			scope:target = { has_trait = chaste }
# 		}
# 	}

# 	weight_multiplier = {
# 		base = 0.5
# 		modifier = {
# 			add = 1
# 			scope:target = { has_trait = lustful }
# 		}
# 		modifier = {
# 			add = 1
# 			has_trait = lustful
# 		}
# 		modifier = {
# 			add = -2
# 			OR = {
# 				has_sexuality = asexual
# 				scope:target = { has_sexuality = asexual }
# 			}
# 		}
# 	}

# 	immediate = {
# 		hidden_effect = {
# 			random = {
# 				chance = 30
# 				set_random_sex_scene_location_effect = yes
# 				transfer_sex_scene_location_to_character_effect = { CHARACTER = scope:target }
# 			}
# 		}
# 		#Either runs had_sex_with_effect or shows a tooltip of it (effect is always just run once per success):
# 		owner_seduce_outcome_sex_effect = yes
# 	}

# 	option = { #Go for both consummation and relationship
# 		name = seduce_outcome.2309.a
# 		trigger = { seduce_outcome_become_lovers_trigger = yes } #Enabled if a player target said "lovers please" or target is AI

# 		owner_seduce_outcome_become_lovers_option_effects = yes

# 		ai_chance = {
# 			base = 100
# 		}
# 	}

# 	option = { #I'm just here for the fun time!
# 		name = seduce_outcome.2301.b
# 		trigger = { seduce_outcome_just_sex_trigger = yes } #Blocks this option for AI owners if the target is a player who said "lovers please"

# 		owner_seduce_outcome_just_sex_effects = yes

# 		ai_chance = {
# 			base = 0
# 			ai_value_modifier = {
# 				ai_greed = 0.25
# 				ai_vengefulness = 0.25
# 			}
# 		}
# 	}

# 	after = {
# 		scope:target = {
# 			trigger_event = seduce_outcome.3309
# 		}
# 		show_as_tooltip = {
# 			scope:scheme = {
# 				end_scheme = yes
# 			}
# 		}
# 	}
# }

######################################################
# SUCCESS EVENTS FOR TARGET (mirror of owner's)
# 3000-3999
######################################################

# Regula just uses the vanila versions of these.  The AI can't use the fascinare action.

######################################################
# FAILURE EVENTS FOR OWNER
# 4000-4999
######################################################

# Failure without consequence
fascinare_outcome.4001 = {
	type = character_event
	title = fascinare_outcome.4001.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { scope:target = { relation_with_character_is_incestuous_in_my_faith_trigger = { CHARACTER = root } } }
				desc = fascinare_outcome.4001.incest.desc
			}
			desc = fascinare_outcome.4001.regular.desc
		}
	}

	theme = regula_theme
	override_background = {
		event_background = sitting_room
	}
	left_portrait = {
		character = scope:target
		animation = paranoia
	}

	trigger = {
	}

	weight_multiplier = {
		base = 0.75
		modifier = {
			reverse_opinion = {
				target = scope:target
				value >= high_positive_opinion
			}
			factor = 1.3
		}
		modifier = {
			OR = {
				has_relation_friend = scope:target
				is_spouse_of = scope:target
			}
			factor = 1.3
		}
		modifier = { #Very unlikely if they don't dislike you
			NOR = {
				reverse_opinion = {
					target = scope:target
					value >= low_positive_opinion
				}
				AND = {
					scope:target = { ai_compassion >= medium_positive_ai_value }
					reverse_opinion = {
						target = scope:target
						value >= low_negative_opinion
					}
				}
			}
			factor = 0.1
		}
	}

	immediate = {
		scope:target = {
			if = {
				limit = { root = { is_ai = no }	}
				assign_quirk_effect = yes
			}
		}
	}

	option = {
		name = fascinare_outcome.4001.a

		scope:target = { fascinare_cooldown_for_character_effect = { CHARACTER = scope:owner } }
		add_piety = 50
		scope:scheme = {
			end_scheme = yes
		}
	}
}

# Critical failure. Outplayed.
# fascinare_outcome.4003 = {
# 	type = character_event
# 	title = fascinare_outcome.4003.t
# 	desc = {
# 		random_valid = {
# 			triggered_desc = { #They have a mean plot
# 				trigger = {
# 					scope:target = {
# 						OR = {
# 							opinion = {
# 								target = root
# 								value < 0
# 							}
# 							ai_honor <= low_negative_ai_value
# 							ai_compassion <= low_negative_ai_value
# 							ai_vengefulness >= low_positive_ai_value
# 							has_trait = sadistic
# 							has_trait = vengeful
# 							has_trait = deceitful
# 						}
# 					}
# 					NOR = {
# 						has_trait = compassionate
# 						has_trait = chaste
# 						has_trait = zealous
# 					}
# 				}
# 				desc = fascinare_outcome.4003.plot.desc
# 			}
# 			desc = fascinare_outcome.4003.regular.desc
# 		}
# 	}
# 	theme = seduce_scheme
# 	left_portrait = {
# 		character = scope:target
# 		animation = anger
# 	}

# 	widget = {
# 		gui = "event_window_widget_scheme"
# 		container = "custom_widgets_container"
# 	}

# 	trigger = {
# 		OR = {
# 			#Regular conditions
# 			reverse_opinion = { #Dislikes you
# 				target = scope:target
# 				value < 0
# 			}
# 			AND = { #Thinks that you're ugly
# 				scope:target = { ai_compassion < medium_positive_ai_value }
# 				attraction < 0
# 			}
# 			ai_values_divergence = { #Very different
# 				target = scope:target
# 				value >= high_ai_values_divergence
# 			}
# 			scope:target = { has_trait = chaste } #Chaste
# 			scope:target = { #This is not honorable
# 				trait_is_shunned_or_criminal_in_my_or_lieges_faith_trigger = { TRAIT = adulterer GENDER_CHARACTER = scope:target }
# 				OR = {
# 					ai_honor >= low_positive_ai_value
# 					has_trait = zealous
# 					has_trait = honest
# 				}
# 			}
# 			#Was triggered by player choice
# 			exists = scope:target_chose_mean_reject
# 		}
# 		NOT = { is_consort_of = scope:target }

# 		#Disabled by Graceful Recovery Perk
# 		NOT = { has_perk = graceful_recovery_perk }
# 	}

# 	weight_multiplier = {
# 		base = 0.5
# 		modifier = {
# 			scope:target = { ai_vengefulness >= medium_positive_ai_value }
# 			add = 1
# 		}
# 		modifier = {
# 			scope:target = { ai_compassion < medium_positive_ai_value }
# 			add = 1
# 		}
# 		modifier = {
# 			has_relation_rival = scope:target
# 			add = 2
# 		}
# 		modifier = {
# 			has_trait = zealous
# 			add = 1
# 		}
# 		modifier = {
# 			#A fellow homo-/bisexual character will hesitate to call you out in public
# 			scope:target = { relation_with_character_is_sodomy_in_my_or_lieges_faith_trigger = { CHARACTER = root } }
# 			add = -0.5
# 		}
# 	}

# 	immediate = { play_music_cue = "mx_cue_negative" }

# 	option = {
# 		name = {
# 			text = fascinare_outcome.4003.a.plot
# 			trigger = {
# 				scope:target = {
# 					OR = {
# 						opinion = {
# 							target = root
# 							value < 0
# 						}
# 						ai_honor <= low_negative_ai_value
# 						ai_compassion <= low_negative_ai_value
# 						ai_vengefulness >= low_positive_ai_value
# 						has_trait = sadistic
# 						has_trait = vengeful
# 						has_trait = deceitful
# 					}
# 				}
# 				NOR = {
# 					has_trait = compassionate
# 					has_trait = chaste
# 					has_trait = zealous
# 				}
# 			}
# 		}
# 		name = fascinare_outcome.4003.a.regular
# 		if = {
# 			limit = {
# 				OR = {
# 					scope:target = { is_landed = yes }
# 					AND = {
# 						exists = host
# 						host = root
# 					}
# 				}
# 			}
# 			fascinare_outcome_publicised_attempted_crimes_or_nothing_effect = {
# 				TARGET = scope:target
# 				OWNER = scope:owner
# 			}
# 		}
# 		else_if = {
# 			limit = {
# 				scope:target = {
# 					exists = liege
# 					NOT = { liege = scope:owner }
# 				}
# 			}
# 			show_as_tooltip = {
# 				fascinare_outcome_publicised_attempted_crimes_or_nothing_effect = {
# 					TARGET = scope:target
# 					OWNER = scope:owner
# 				}
# 			}
# 			scope:target = { liege = { trigger_event = seduce_outcome.4900 } }
# 		}

# 		scope:target = { seduction_block_character_effect = { CHARACTER = scope:owner } }

# 		scope:scheme = {
# 			end_scheme = yes
# 		}
# 	}
# }

# Failure with reveal. Discovered.
fascinare_outcome.4005 = {
	type = character_event
	title = fascinare_outcome.4005.t
	desc = fascinare_outcome.4005.desc

	theme = regula_theme
	override_background = {
		event_background = bedchamber
	}

	left_portrait = {
		character = scope:target
		animation = war_attacker
	}

	trigger = {
		exists = scope:scheme_discovered
		scope:target = {
			is_landed = no
			exists = liege
		}
	}

	immediate = {
		scope:target = { liege = { save_scope_as = target_liege } }
	}

	option = {
		name = fascinare_outcome.4005.a

		show_as_tooltip = {
			fascinare_outcome_publicised_attempted_crimes_or_nothing_effect = {
				TARGET = scope:target
				OWNER = scope:owner
			}
		} #Is actually applied in 4900

		scope:target = { fascinare_cooldown_for_character_effect = { CHARACTER = scope:owner } }
		add_opinion = {
			target = scope:owner
			modifier = fascinare_discovered_cooldown_opinion
		}
		scope:scheme = {
			end_scheme = yes
		}
		#Send "failed seduction attempt discovered" event to target's liege
		scope:target_liege = { trigger_event = seduce_outcome.4900 }
	}
}

# Automatic failure
fascinare_outcome.4006 = {
	type = character_event
	hidden = yes

	trigger = {
		global_var:ward_enslavement_events_enabled = no
	}

	immediate = {
		send_interface_message = {
			type = event_generic_bad
			title = target_fascinare_failure_effect.desc
			left_icon = scope:target

			scope:target = {
				if = {
					limit = { root = { is_ai = no }	}
					assign_quirk_effect = yes
				}
				fascinare_cooldown_for_character_effect = { CHARACTER = scope:owner }
			}
			add_piety = 50
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}


code:
#Events handling rapta_maritus outcomes

# System by Petter Vilberg

namespace = rapta_maritus_outcome

##################################
# MAINTENANCE EVENTS 0000 - 0099
##################################

rapta_maritus_outcome.0001 = {

	hidden = yes

	immediate = {
		add_character_flag = { #Only resolve one abduction in the same day
			flag = is_in_event_rapta_maritus_outcome_0001
			days = 1
		}
		trigger_event = {
			on_action = rapta_maritus_setup
		}
	}
}

#################
# METHOD SELECTION EVENTS
# 1000-1999
#################

######################
# Seize Roadside
######################
rapta_maritus_outcome.1001 = {
	type = character_event
	title = rapta_maritus_outcome.1001.t
	desc = {
		desc = rapta_maritus_outcome.1001.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:arrival
				}
				desc = rapta_maritus_outcome.1001.arrival
			}
			desc = rapta_maritus_outcome.1001.no_arrival
		}
		desc = rapta_maritus_outcome.1001.ending
	}
	theme = intrigue
	left_portrait = {
		character = scope:target
		animation = personality_coward
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	weight_multiplier = {
		base = 1
	}

	immediate = {
		save_scope_value_as = {
			name = rapta_maritus_method
			value = flag:seized_roadside
		}
		if = {
			limit = {
				exists = scope:target.location.county.holder.capital_county
			}
			scope:target.location.county.holder.capital_county = {
				save_scope_as = departure
			}
			scope:target.location.county.holder.top_liege = {
				random_sub_realm_county = {
					limit = {
						NOR = {
							this = scope:departure
							holder = scope:owner
						}
						scope:departure = {
							squared_distance = {
								target = prev
								value < 100000
							}
						}
					}
					save_scope_as = arrival
				}
			}
		}
		else = {
			scope:owner.capital_county = {
				save_scope_as = departure
			}
			scope:owner.top_liege = {
				random_sub_realm_county = {
					limit = {
						NOR = {
							this = scope:departure
							holder = scope:owner
						}
						scope:departure = {
							squared_distance = {
								target = prev
								value < 100000
							}
						}
					}
					save_scope_as = arrival
				}
			}
		}
		rapta_maritus_outcome_roll_setup_effect = yes
	}

	option = {
		name = rapta_maritus_outcome.1001.a
		remove_short_term_gold = minor_gold_value
		rapta_maritus_outcome_roll_effect = yes
		ai_chance = {
			base = 100
		}
	}

	option = {
		name = rapta_maritus_outcome.1001.b
		custom_tooltip = do_not_execute_rapta_maritus_tooltip

		scope:scheme = {
			add_scheme_progress = -10 # Reset scheme progress
		}

		ai_chance = {
			base = 0
		}
		stress_impact = {
			impatient = medium_stress_impact_gain
			stubborn = medium_stress_impact_gain
		}
	}
}

#####################################
# SUCCESS OUTCOMES 2001 - 2999
#####################################

#######################
# Seized Roadside
#######################
rapta_maritus_outcome.2001 = {
	type = character_event
	title = rapta_maritus_outcome.1001.t
	desc = rapta_maritus_outcome.2001.desc
	theme = intrigue
	left_portrait = {
		character = scope:target
		animation = fear
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		scope:rapta_maritus_method = flag:seized_roadside
	}

	immediate = {
		if = {
			limit = {
				exists = capital_county
			}
			capital_county = {
				save_scope_as = prison_location
			}
		}
		else_if = {
			limit = {
				exists = location.county
			}
			location.county = {
				save_scope_as = prison_location
			}
		}
		rapta_maritus_success_effect = yes
	}

	option = {
		name = rapta_maritus_outcome.2001.a
		play_music_cue = "mx_cue_prison"
		successful_rapta_maritus_outcome_event_option_effect = yes
	}
}

#################################
# FAILURE OUTCOMES 4000 - 4999
#################################
rapta_maritus_outcome.4001 = {
	type = character_event
	title = rapta_maritus_outcome.1001.t
	desc = {
		desc = rapta_maritus_outcome.4001.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:scheme_discovered
				}
				desc = rapta_maritus_outcome.4001.owner_discovered
			}
			desc = rapta_maritus_outcome.4001.owner_secret
		}
	}
	theme = intrigue
	left_portrait = {
		character = scope:target
		animation = rage
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		scope:rapta_maritus_method = flag:seized_roadside
	}

	immediate = {
		rapta_maritus_failure_effect = yes
	}

	option = { # Abandon scheme
		name = rapta_maritus_outcome.4001.a
		scope:scheme = {
			end_scheme = yes
		}
		stress_impact = {
			stubborn = medium_stress_impact_gain
		}
		ai_chance = { #They're charmed.  No way they back out.
			base = 100
		}
	}
}

########################################
# TARGET SUCCESS NOTIFICATIONS
########################################

#I have been abducted!
rapta_maritus_outcome.5001 = {
	type = character_event
	title = rapta_maritus_outcome.5001.t
	desc = {
		desc = rapta_maritus_outcome.5001.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:rapta_maritus_method = flag:seized_roadside
				}
				desc = rapta_maritus_outcome.5001.seized_roadside
			}
			triggered_desc = {
				trigger = {
					scope:rapta_maritus_method = flag:on_the_way
				}
				desc = rapta_maritus_outcome.5001.on_the_way
			}
			triggered_desc = {
				trigger = {
					scope:rapta_maritus_method = flag:unwelcome_guests
				}
				desc = rapta_maritus_outcome.5001.unwelcome_guests
			}
		}
	}
	theme = prison
	left_portrait = {
		character = scope:owner
		animation = scheme
	}

	immediate = {
		show_as_tooltip = {
			hard_imprison_character_effect = {
				TARGET = scope:target
				IMPRISONER = scope:owner
			}
		}
	}

	option = {
		name = rapta_maritus_outcome.5001.a
		play_music_cue = "mx_cue_stress"
		add_opinion = {
			target = scope:owner
			modifier = unfaithful_spouse_exposed_opinion
		}
		add_opinion = {
			target = global_var:magister_character
			modifier = abducted_me_opinion
		}
	}
}

###################################
# TARGET FAILURE NOTIFICATIONS
###################################

rapta_maritus_outcome.5002 = {
	type = character_event
	title = rapta_maritus_outcome.5002.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:rapta_maritus_method = flag:seized_roadside
				}
				desc = rapta_maritus_outcome.5002.seized_roadside
			}
			triggered_desc = {
				trigger = {
					scope:rapta_maritus_method = flag:on_the_way
				}
				desc = rapta_maritus_outcome.5002.on_the_way
			}
			triggered_desc = {
				trigger = {
					scope:rapta_maritus_method = flag:unwelcome_guests
				}
				desc = rapta_maritus_outcome.5002.unwelcome_guests
			}
			desc = rapta_maritus_outcome.5002.fallback
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:scheme_discovered
				}
				desc = rapta_maritus_outcome.5002.owner_known
			}
			desc = rapta_maritus_outcome.5002.owner_not_known
		}
	}
	theme = intrigue
	left_portrait = {
		character = scope:revealed_owner
		animation = disbelief
	}

	immediate = {
		if = {
			limit = {
				exists = scope:scheme_discovered
			}
			scope:owner = {
				save_scope_as = revealed_owner
			}
		}
	}

	option = {
		name = rapta_maritus_outcome.5002.a
		trigger = {
			exists = scope:scheme_discovered
		}
		add_opinion = {
			target = scope:owner
			modifier = unfaithful_spouse_exposed_opinion
		}
		add_character_modifier = {
			modifier = watchful_modifier
			days = watchful_modifier_duration
		}
	}

	option = {
		name = rapta_maritus_outcome.5002.b
		trigger = {
			NOT = { exists = scope:scheme_discovered }
		}
		add_character_modifier = {
			modifier = watchful_modifier
			days = watchful_modifier_duration
		}
	}
}

###################################
# MAGISTER SUCCESS NOTIFICATIONS
###################################

rapta_maritus_outcome.7001 = {
	type = letter_event

	opening = {
		desc = rapta_maritus_outcome.7001.opening
	}
	desc = rapta_maritus_outcome.7001.desc
	sender = {
		character = scope:owner
		animation = worry ### UPDATE - Put something relevant here.
	}

	# immediate ={
	# 	show_as_tooltip = { ransom_interaction_effect = yes }
	# }

	option = {
		name = rapta_maritus_outcome.7001.a
	}
}

###################################
# MAGISTER FAILURE NOTIFICATIONS
###################################

rapta_maritus_outcome.7002 = {
	type = letter_event
	opening = {
		desc = rapta_maritus_outcome.7002.opening
	}
	desc = rapta_maritus_outcome.7002.desc

	sender = scope:owner

	# immediate ={
	# 	show_as_tooltip = { ransom_interaction_effect = yes }
	# }

	option = {
		name = rapta_maritus_outcome.7002.a
	}
}


code:
namespace = regula_astringere_outcome_event

# Add the Sigillum trait.
regula_astringere_outcome_event.1001 = {
	type = character_event
	title = regula_astringere_outcome_event.1001.t
	desc = regula_astringere_outcome_event.1001.desc

	theme = regula_theme
	override_background = {
		event_background = sitting_room
	}
	right_portrait = {
		character = scope:recipient
		animation = personality_content
	}

	option = { # Add the trait and hook.
		name = regula_astringere_outcome_event.1001.a
		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
		}
	}
}


code:
namespace = regula_forge_inheritance_outcome

##################################
# MAINTENANCE EVENTS 0000 - 0099
##################################

# Go or no go?
regula_forge_inheritance_outcome.0001 = {
	type = character_event
	title = regula_forge_inheritance_outcome.0001.t
	desc = {
		desc = regula_forge_inheritance_outcome.0001.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:scheme.scheme_success_chance >= 60 }
				desc = regula_forge_inheritance_outcome.0001.positive.desc
			}
			desc = regula_forge_inheritance_outcome.0001.negative.desc
		}
	}
	theme = regula_theme
	override_background = {
		event_background = courtyard
	}
	# left_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		save_scope_value_as = {
			name = forgery_type
			value = flag:xena
		}
	}

	option = {
		name = regula_forge_inheritance_outcome.0001.a
		custom_tooltip = regula_forge_inheritance_outcome.0001.a.tt
		trigger_event = regula_forge_inheritance_outcome.0005 #Do the rolls!

		stress_impact = {
			craven = minor_stress_impact_gain
		}
	}

	option = {
		name = regula_forge_inheritance_outcome.0001.b
		stress_impact = {
			ambitious = minor_stress_impact_gain
		}
		scope:scheme = {
			end_scheme = yes
		}
	}
}

regula_forge_inheritance_outcome.0002 = {
	type = character_event
	title = regula_forge_inheritance_outcome.0002.t
	desc = {
		desc = regula_forge_inheritance_outcome.0002.desc
		first_valid = {
			triggered_desc = {
				trigger = { scope:scheme.scheme_success_chance >= 60 }
				desc = regula_forge_inheritance_outcome.0002.positive.desc
			}
			desc = regula_forge_inheritance_outcome.0002.negative.desc
		}
	}
	theme = regula_theme
	override_background = {
		event_background = courtyard
	}
	# left_portrait = scope:target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	immediate = {
		save_scope_value_as = {
			name = forgery_type
			value = flag:calf
		}
	}

	option = {
		name = regula_forge_inheritance_outcome.0002.a
		custom_tooltip = regula_forge_inheritance_outcome.0002.a.tt
		trigger_event = regula_forge_inheritance_outcome.0005 #Do the rolls!

		stress_impact = {
			craven = minor_stress_impact_gain
		}
	}

	option = {
		name = regula_forge_inheritance_outcome.0002.b
		stress_impact = {
			ambitious = minor_stress_impact_gain
		}
		scope:scheme = {
			end_scheme = yes
		}
	}
}

#Rolls success and discovery, and triggers on_actions (or sends "player's choice" event)
regula_forge_inheritance_outcome.0005 = {
	type = character_event

	hidden = yes

	immediate = {
		#SUCCESS ROLL
		random = {
			chance = scope:scheme.scheme_success_chance

			save_scope_value_as = {
				name = scheme_successful
				value = yes
			}
		}

		#DISCOVERY ROLL
		save_scope_value_as = {
			name = discovery_chance
			value = {
				value = 100
				subtract = scope:scheme.scheme_secrecy
			}
		}

		random = {
			chance = scope:discovery_chance
			save_scope_value_as = {
				name = scheme_discovered
				value = yes
			}
		}

		if = {
			limit = {
				exists = scope:scheme_successful
			}
			trigger_event = {
				on_action = regula_forge_inheritance_law_success
			}
		}
		else = {
			trigger_event = {
				on_action = regula_forge_inheritance_law_fail
			}
		}
	}
}

#################
# SUCCESS EVENTS
# 1000-1999
#################

#Success - Warrior Princesses
regula_forge_inheritance_outcome.1000 = {
	type = character_event
	title = regula_forge_inheritance_outcome.1000.t
	desc = regula_forge_inheritance_outcome.1000.desc

	theme = regula_theme
	override_background = {
		event_background = council_chamber
	}
	right_portrait = {
		character = scope:target
		animation = disbelief
	}

	trigger = {
		scope:forgery_type = flag:xena
	}

	immediate = {
		scope:target = {
			regula_forge_inheritance_law_success_effect = yes
		}
	}

	option = {
		name = regula_forge_inheritance_outcome.1000.a
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

#Success - Dark future
regula_forge_inheritance_outcome.1001 = {
	type = character_event
	title = regula_forge_inheritance_outcome.1001.t
	desc = regula_forge_inheritance_outcome.1001.desc

	theme = regula_theme
	override_background = {
		event_background = council_chamber
	}
	right_portrait = {
		character = scope:target
		animation = disbelief
	}

	trigger = {
		scope:forgery_type = flag:calf
	}

	immediate = {
		scope:target = {
			regula_forge_inheritance_law_success_effect = yes
		}
	}

	option = {
		name = regula_forge_inheritance_outcome.1001.a
	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

#####################################
# FAILURE EVENTS 2001 - 2999
#####################################

#Warrior Princesses
regula_forge_inheritance_outcome.2000 = {
	type = character_event
	title = regula_forge_inheritance_outcome.2000.t
	desc = regula_forge_inheritance_outcome.2000.desc
	theme = regula_theme

	override_background = {
		event_background = council_chamber
	}
	left_portrait = {
		character = scope:target
		animation = anger
	}

	trigger = {
		scope:forgery_type = flag:xena
	}

	immediate = {
		add_prestige = -250
	}

	option = {
		name = regula_forge_inheritance_outcome.2000.a

	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}

#Dark Future
regula_forge_inheritance_outcome.2001 = {
	type = character_event
	title = regula_forge_inheritance_outcome.2001.t
	desc = regula_forge_inheritance_outcome.2001.desc
	theme = regula_theme

	override_background = {
		event_background = council_chamber
	}
	left_portrait = {
		character = scope:target
		animation = anger
	}

	trigger = {
		scope:forgery_type = flag:calf
	}

	immediate = {
		add_prestige = -250
	}

	option = {
		name = regula_forge_inheritance_outcome.2001.a

	}

	after = {
		scope:target = {
			trigger_event = seduce_outcome.3301
		}
		show_as_tooltip = {
			scope:scheme = {
				end_scheme = yes
			}
		}
	}
}


code:
#Events handling regula_instiga_discordia outcomes

namespace = regula_instiga_discordia_outcome

##################################
# MAINTENANCE EVENTS 0000 - 0099
##################################

regula_instiga_discordia_outcome.0001 = {

	hidden = yes

	immediate = {
		add_character_flag = { #Only resolve one abduction in the same day
			flag = is_in_event_regula_instiga_discordia_outcome_0001
			days = 1
		}

		# Find someone to make the target's rival
		scope:target = {
			every_vassal = {
				limit = {
					is_powerful_vassal = yes
					NOT = { has_relation_rival = scope:target }
				}
				add_to_temporary_list = potential_new_rival
			}
			if = {
				limit = {
					is_independent_ruler = no
				}
				scope:target.liege = {
					add_to_temporary_list = potential_new_rival
				}
			}
		}
		random_in_list = {
			list = potential_new_rival
			save_scope_as = new_rival
		}

		### Roll to see if the plan succeeds.
		#SUCCESS ROLL
		random = {
			chance = scope:scheme.scheme_success_chance

			save_scope_value_as = {
				name = scheme_successful
				value = yes
			}
		}

		#DISCOVERY ROLL
		save_scope_value_as = {
			name = discovery_chance
			value = {
				value = 100
				subtract = scope:scheme.scheme_secrecy
			}
		}

		random = {
			chance = scope:discovery_chance
			save_scope_value_as = {
				name = scheme_discovered
				value = yes
			}
		}
		global_var:magister_character = {
			if = {
				limit = {
					exists = scope:scheme_successful
				}
				trigger_event = {
					on_action = regula_instiga_discordia_success
				}
			}
			else = {
				trigger_event = {
					on_action = regula_instiga_discordia_failure
				}
			}
		}
	}
}

#################
# SUCCESS EVENTS
# 1000-1999
#################

regula_instiga_discordia_outcome.1001 = {
	type = character_event
	title = regula_instiga_discordia_outcome.1001.t
	desc = {
		desc = regula_instiga_discordia_outcome.1001.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:scheme_discovered
				}
				desc = regula_instiga_discordia_outcome.1001.owner_discovered
			}
			desc = regula_instiga_discordia_outcome.1001.owner_secret
		}
	}
	theme = diplomacy
	left_portrait = {
		character = scope:target
		animation = personality_dishonorable  ### UPDATE
	}
	right_portrait = {
		character = scope:new_rival
		animation = rage
	}

	immediate = {
		if = {
			limit = {
				exists = scope:scheme_discovered
			}
			regula_instiga_discordia_discovered_success_effect = yes
		}
		scope:new_rival = {
			add_character_flag = {  ### Find a way to make them bottomless only?
				flag = is_naked
				days = 180
			}
		}
	}

	option = { # Abandon scheme
		name = regula_instiga_discordia_outcome.1001.a

		scope:target = {
			hidden_effect = {
				if = {
					limit = {
						has_relation_potential_rival = scope:new_rival
					}
					remove_relation_potential_rival = scope:new_rival
				}
			}
			set_relation_rival = scope:new_rival
		}
		scope:scheme = {
			end_scheme = yes
		}
	}
	after = {
		scope:new_rival = {
			remove_character_flag = is_naked
		}
	}
}

#################################
# FAILURE OUTCOMES 2000 - 2999
#################################
regula_instiga_discordia_outcome.2001 = {
	type = character_event
	title = regula_instiga_discordia_outcome.2001.t
	desc = {
		desc = regula_instiga_discordia_outcome.2001.opening
		first_valid = {
			triggered_desc = {
				trigger = {
					exists = scope:scheme_discovered
				}
				desc = regula_instiga_discordia_outcome.2001.owner_discovered
			}
			desc = regula_instiga_discordia_outcome.2001.owner_secret
		}
	}
	theme = diplomacy
	left_portrait = {
		character = scope:target
		triggered_animation = {
			trigger = {
				exists = scope:scheme_discovered
			}
			animation = stress  # Upset
		}
		animation = disapproval  # Wondering what on earth happened.
	}

	immediate = {
		if = {
			limit = {
				exists = scope:scheme_discovered
			}
			regula_instiga_discordia_discovered_failure_effect = yes
		}
	}

	option = { # Abandon scheme
		name = regula_instiga_discordia_outcome.2001.a
		scope:scheme = {
			end_scheme = yes
		}
	}
}

###################################
# MAGISTER SUCCESS NOTIFICATIONS
###################################

### Not being run.  The success/failure events fire for the magister instead.

# regula_instiga_discordia_outcome.7001 = {
# 	type = letter_event

# 	opening = {
# 		desc = regula_instiga_discordia_outcome.7001.opening
# 	}
# 	desc = regula_instiga_discordia_outcome.7001.desc
# 	sender = {
# 		character = scope:owner
# 		animation = worry ### UPDATE - Put something relevant here.
# 	}

# 	# immediate ={
# 	# 	show_as_tooltip = { ransom_interaction_effect = yes }
# 	# }

# 	option = {
# 		name = regula_instiga_discordia_outcome.7001.a
# 	}
# }

# ###################################
# # MAGISTER FAILURE NOTIFICATIONS
# ###################################

# regula_instiga_discordia_outcome.7002 = {
# 	type = letter_event
# 	opening = {
# 		desc = regula_instiga_discordia_outcome.7002.opening
# 	}
# 	desc = regula_instiga_discordia_outcome.7002.desc

# 	sender = scope:owner

# 	# immediate ={
# 	# 	show_as_tooltip = { ransom_interaction_effect = yes }
# 	# }

# 	option = {
# 		name = regula_instiga_discordia_outcome.7002.a
# 	}
# }


code:
namespace = revela_secretum

# 0001 - Character knows secret.
# 0002 - Character doesn't know secret, and can't fabricate one.
# 0003 -

# Mulsa knows something.
revela_secretum.0001 = {
	type = letter_event
	opening = revela_secretum.0001.opening
	desc = revela_secretum.0001.desc
	sender = {
		character = scope:revela_recipient
		animation = flirtation ### UPDATE - Put something relevant here.
	}

	trigger = {
		scope:revela_recipient = {
			any_secret = {
				NOT = { is_known_by = global_var:magister_character }
			}
		}
	}

	immediate = {
		scope:revela_recipient = {
			random_secret = {
				limit = { NOT = { is_known_by = global_var:magister_character } }
				save_scope_as = secret_to_reveal
			}
		}
	}

	option = { # Know something that would be of use.
		name = revela_secretum.0001.a # UPDATE - generic congratulations
		scope:secret_to_reveal = {
			reveal_to_without_events_effect = {
				CHARACTER = global_var:magister_character
			}
		}
	}
}

# Mulsa doesn't know how to fabricate a secret.
revela_secretum.0002 = {
	type = character_event
	title = revela_secretum.0002.t
	desc = revela_secretum.0002.desc
	theme = fabricate_hook_scheme
	right_portrait = {
		character = scope:revela_recipient
		animation = grief
	}
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	option = { # Knows nothing.
		name = revela_secretum.0002.a
	}

	option = {
		name = revela_secretum.0002.b
		custom_tooltip = revela_secretum.0002.b.tt

		trigger = {
			custom_description = { ### UPDATE - A custom description shouldn't be required here.  Make sure it doesn't mess anything up.
				text = magister_trait_3_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank >= 3
				}
			}
		}

		show_as_unavailable = {
			custom_description = {
				text = magister_trait_3_required_trigger
				has_trait_rank = {
					trait = magister_trait_group
					rank <= 2
				}
			}
		}

		scope:revela_recipient = {
			if = {
				limit = {
					has_trait = honest
				}
				remove_trait = honest
			}
			if = {
				limit = {
					has_trait = trusting
				}
				remove_trait = trusting
			}
			if = {
				limit = {
					NOT = { has_trait = paranoid }
				}
				add_trait = paranoid
			}
			if = {
				limit = {
					NOT = { has_trait = deceitful }
				}
				add_trait = deceitful
			}
			add_perk = truth_is_relative_perk
		}
		scope:actor = {
			add_piety = -150
		}
		trigger_event = {
			on_action = revela_secretum_fabricate_effect # Fabricate hook.  fabricate_hook_outcome.1001 as a guide.
			days = { 10 30 }
		}
	}
}

#Fabrication events

revela_secretum.1001 = { # Honeypot
	type = character_event
	title = revela_secretum.1001.t
	desc = revela_secretum.1001.desc
	theme = fabricate_hook_scheme
	override_background = {
		event_background = throne_room
	}
	right_portrait = {
		character = scope:revela_recipient
		animation = content
	}
	lower_right_portrait = scope:revela_target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		scope:revela_target = {
			AND = {
				is_ruler = yes
				OR = {
					is_married = yes # Doesn't work if they've little to lose.
					is_betrothed = yes
				}
			}
		NOT = { is_consort_of = scope:revela_target } # Can't honeypot your own spouse.
		NOT = { is_spouse_of = scope:revela_target } # Can't honeypot your own spouse.
		}
	}

	# More likely with attractive/lustful Mulsa, or a lustful target.
	weight_multiplier = {
		base = 0.5
		modifier = {
			add = 2
			scope:revela_target = { has_trait = lustful }
		}
		modifier = {
			add = 1
			scope:revela_recipient = { has_trait = lustful }
		}
		modifier = {
			add = 1
			scope:revela_recipient = { has_trait = beauty_good }
		}
		modifier = {
			add = -2
			scope:revela_recipient = { has_trait = beauty_bad }
		}
	}

	immediate = {
		scope:revela_target.court_owner = { # For use in loc
			save_scope_as = court_owner
		}
	}

	option = {
		name = revela_secretum.1001.a
		revela_secretum_success_effect = {
			TYPE = life_threat_hook
		}
	}

	option = {
		name = revela_secretum.1001.b
	}
}

revela_secretum.1002 = { # Forged brothel documents.
	type = character_event
	title = revela_secretum.1002.t
	desc = revela_secretum.1002.desc
	theme = fabricate_hook_scheme
	override_background = {
		event_background = bedchamber
	}
	right_portrait = {
		character = scope:revela_recipient
		animation = personality_dishonorable
	}
	lower_right_portrait = scope:revela_target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
		scope:revela_target = { is_ruler = yes }
	}

	# An easier sell if the target is secretive. Not a big deal if they usually frequent brothels anyway.
	weight_multiplier = {
		base = 0.5
		modifier = {
			scope:revela_target = { has_trait = deceitful }
			add = 2
		}
		modifier = {
			scope:revela_target = { has_trait = rakish }
			add = -2
		}
		modifier = {
			scope:revela_recipient = { has_trait = diligent }
			add = 1
		}
		modifier = {
			scope:revela_recipient = {
				stewardship >= 20
			}
			add = 2
		}
	}

	immediate = {
		scope:revela_target.court_owner = { # For use in loc
			save_scope_as = court_owner
		}
	}

	option = {
		name = revela_secretum.1002.a
		scope:revela_target = {
			add_character_modifier = {
				modifier = fabricate_hook_interfering_with_servants_modifier
				years = 5
			}
		}
		revela_secretum_success_effect = {
			TYPE = fabrication_hook
		}
	}

	option = {
		name = revela_secretum.1002.b
	}
}

revela_secretum.1003 = { # Just hit them with arousal until they make a fool of themselves.
	type = character_event
	title = revela_secretum.1003.t
	theme = fabricate_hook_scheme
	override_background = {
		event_background = throne_room
	}
	right_portrait = {
		character = scope:revela_recipient
		animation = content
	}
	lower_right_portrait = scope:revela_target
	widget = {
		gui = "event_window_widget_scheme"
		container = "custom_widgets_container"
	}

	trigger = {
	}

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:revela_target = {
						is_male = yes
					}
				}
				desc = revela_secretum.1003.desc.male
			}
			triggered_desc = {
				trigger = {
					scope:revela_target = {
						is_female = yes
					}
				}
				desc = revela_secretum.1003.desc.female
			}
			desc = revela_secretum.1003.desc.fallback
		}
	}

	# More likely with attractive/lustful Mulsa, or a lustful target.
	weight_multiplier = {
		base = 0.5
	}

	immediate = {
		scope:revela_target.court_owner = { # For use in loc
			save_scope_as = court_owner
		}
	}

	option = {
		name = revela_secretum.1003.a
		revela_secretum_success_effect = {
			TYPE = loyalty_hook
		}
	}

	option = {
		name = revela_secretum.1003.b
	}
}


code:
entity = {
	name = "regula_female_eyes_pink_entity"
	pdxmesh = "female_eyes_mesh"

	game_data = {
		portrait_entity_user_data = {
			color_mask_remap_interval = {
				interval = {0.0 1.0}
			}
		}
	}

	meshsettings = {
		name = "female_eyesShape"
		index = 0
		texture_diffuse = "regula_female_eyes_pink_diffuse.dds"
	}
}

entity = {
	name = "regula_female_eyes_violet_entity"
	pdxmesh = "female_eyes_mesh"

	game_data = {
		portrait_entity_user_data = {
			color_mask_remap_interval = {
				interval = {0.0 1.0}
			}
		}
	}

	meshsettings = {
		name = "female_eyesShape"
		index = 0
		texture_diffuse = "regula_female_eyes_violet_diffuse.dds"
	}
}

entity = {
	name = "regula_female_sclera_pink_entity"
	pdxmesh = "female_eyes_mesh"

	game_data = {
		portrait_entity_user_data = {
			color_mask_remap_interval = {
				interval = {0.0 1.0}
			}
		}
	}

	meshsettings = {
		name = "female_eyesShape"
		index = 0
		texture_diffuse = "regula_sclera_pink_diffuse.dds"
	}
}


code:
regula_female_eyes_pink = {
	entity = { entity = "regula_female_eyes_pink_entity" 	shared_pose_entity = head }
}

regula_female_eyes_violet = {
	entity = { entity = "regula_female_eyes_violet_entity" 	shared_pose_entity = head }
}

regula_female_sclera_pink = {
	entity = { entity = "regula_female_sclera_pink_entity" 	shared_pose_entity = head }
}