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 = {
		OR = {
			has_trait = domina
			has_trait = paelex
		}
		any_consort = {
			has_trait = magister_trait_group
		}
	}

	immediate = {
		if = {
			limit = {
				has_trait = domina
				NOT = { root.primary_spouse.primary_spouse = root }
			}
			remove_trait = domina
			add_trait = paelex
		}
		if = {
			limit = {
				has_trait = paelex
				root.primary_spouse.primary_spouse = root
			}
			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 = { no_cloak no_hat no_pants no_clothes }
    	animation = personality_zealous
	}

	immediate = {
		scope:recipient = {
			add_character_flag = {
				flag = is_naked
				days = 180
			}
		}
		# hidden_effect = { # UPDATE - Not quite right.
		# 	scope:recipient = {
		# 		add_trait = blind
		# 	}
		# }
	}

	option = {
		name = regula_paelex_event.1000.b # Push power into her body. Increased beauty, reduction in apparent age.
		flavor = regula_paelex_event.1000.b.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_2
		}
	}
	option = {
		name = regula_paelex_event.1000.a # Drive the power into her mind. Increased traits, may bump up lifestyle trait.
		flavor = regula_paelex_event.1000.a.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_1
		}
	}
	option = {
		name = regula_paelex_event.1000.c # Mix power with your seed. Inheritable traits and pregnancy.
		flavor = regula_paelex_event.1000.c.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_3
		}
	}
	option = {
		name = regula_paelex_event.1000.d # Take power for yourself.
		add_piety = 100
	}
	after = {
		scope:recipient = {
			remove_character_flag = is_naked
		}
		# hidden_effect = {
		# 	scope:recipient = {
		# 		remove_trait = blind
		# 	}
		# }
	}
}

### 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 = { no_cloak no_hat no_pants no_clothes }
    	animation = personality_zealous
	}

	immediate = {
		scope:recipient = {
			add_character_flag = {
				flag = is_naked
				days = 180
			}
		}
		# hidden_effect = { # UPDATE - Not quite right.
		# 	scope:recipient = {
		# 		add_trait = blind
		# 	}
		# }
	}

	option = {
		name = regula_paelex_event.1000.b # Push power into her body. Increased beauty, reduction in apparent age.
		flavor = regula_paelex_event.1000.b.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_2
		}
	}
	option = {
		name = regula_paelex_event.1000.a # Drive the power into her mind. Increased traits, may bump up lifestyle trait.
		flavor = regula_paelex_event.1000.a.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_1
		}
	}
	option = {
		name = regula_paelex_event.1000.c # Mix power with your seed. Inheritable traits and pregnancy.
		flavor = regula_paelex_event.1000.c.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_3
		}
	}
	option = {
		name = regula_paelex_event.1000.d # Take power for yourself.
		add_piety = 100
	}
	after = {
		scope:recipient = {
			remove_character_flag = is_naked
		}
		# hidden_effect = {
		# 	scope:recipient = {
		# 		remove_trait = blind
		# 	}
		# }
	}
}

### 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 = { no_cloak no_hat no_pants no_clothes }
    	animation = personality_zealous
	}

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

	option = {
		name = regula_paelex_event.1000.b # Push power into her body. Increased beauty, reduction in apparent age.
		flavor = regula_paelex_event.1000.b.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_2
		}
	}
	option = {
		name = regula_paelex_event.1000.a # Drive the power into her mind. Increased traits, may bump up lifestyle trait.
		flavor = regula_paelex_event.1000.a.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_1
		}
	}
	option = {
		name = regula_paelex_event.1000.c # Mix power with your seed. Inheritable traits and pregnancy.
		flavor = regula_paelex_event.1000.c.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_3
		}
	}
	option = {
		name = regula_paelex_event.1000.d # Take power for yourself.
		add_piety = 100
	}
	after = {
		scope:recipient = {
			remove_character_flag = is_naked
		}
		# hidden_effect = {
		# 	scope:recipient = {
		# 		remove_trait = blind
		# 	}
		# }
	}
}

### 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:defender
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
    	animation = personality_zealous
	}

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

	option = {
		name = regula_paelex_event.1000.b # Push power into her body. Increased beauty, reduction in apparent age.
		flavor = regula_paelex_event.1000.b.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_2
		}
	}
	option = {
		name = regula_paelex_event.1000.a # Drive the power into her mind. Increased traits, may bump up lifestyle trait.
		flavor = regula_paelex_event.1000.a.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_1
		}
	}
	option = {
		name = regula_paelex_event.1000.c # Mix power with your seed. Inheritable traits and pregnancy.
		flavor = regula_paelex_event.1000.c.tt
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_3
		}
	}
	option = {
		name = regula_paelex_event.1000.d # Take power for yourself.
		add_piety = 100
	}
	after = {
		scope:defender = {
			remove_character_flag = is_naked
		}
		# hidden_effect = {
		# 	scope:defender = {
		# 		remove_trait = blind
		# 	}
		# }
	}
}



# Adds a small boost to mental traits.
regula_paelex_event.1011 = {
	hidden = yes
	type = character_event

	trigger = {
		NOR = {
			has_trait = education_stewardship_4
			has_trait = education_martial_4
			has_trait = education_intrigue_4
			has_trait = education_diplomacy_4
			has_trait = education_learning_4
		}
	}

	immediate = {
		scope:recipient = {
			if = {
				limit = { has_trait = education_stewardship_3 }
				remove_trait = education_stewardship_3
				add_trait = education_stewardship_4
			}
			if = {
				limit = { has_trait = education_stewardship_2 }
				remove_trait = education_stewardship_2
				add_trait = education_stewardship_3
			}
			if = {
				limit = { has_trait = education_stewardship_1 }
				remove_trait = education_stewardship_1
				add_trait = education_stewardship_2
			}
			if = {
				limit = { has_trait = education_martial_3 }
				remove_trait = education_martial_3
				add_trait = education_martial_4
			}
			if = {
				limit = { has_trait = education_martial_2 }
				remove_trait = education_martial_2
				add_trait = education_martial_3
			}
			if = {
				limit = { has_trait = education_martial_1 }
				remove_trait = education_martial_1
				add_trait = education_martial_2
			}
			if = {
				limit = { has_trait = education_learning_3 }
				remove_trait = education_learning_3
				add_trait = education_learning_4
			}
			if = {
				limit = { has_trait = education_learning_2 }
				remove_trait = education_learning_2
				add_trait = education_learning_3
			}
			if = {
				limit = { has_trait = education_learning_1 }
				remove_trait = education_learning_1
				add_trait = education_learning_2
			}
			if = {
				limit = { has_trait = education_intrigue_3 }
				remove_trait = education_intrigue_3
				add_trait = education_intrigue_4
			}
			if = {
				limit = { has_trait = education_intrigue_2 }
				remove_trait = education_intrigue_2
				add_trait = education_intrigue_3
			}
			if = {
				limit = { has_trait = education_intrigue_1 }
				remove_trait = education_intrigue_1
				add_trait = education_intrigue_2
			}
			if = {
				limit = { has_trait = education_diplomacy_3 }
				remove_trait = education_diplomacy_3
				add_trait = education_diplomacy_4
			}
			if = {
				limit = { has_trait = education_diplomacy_2 }
				remove_trait = education_diplomacy_2
				add_trait = education_diplomacy_3
			}
			if = {
				limit = { has_trait = education_diplomacy_1 }
				remove_trait = education_diplomacy_1
				add_trait = education_diplomacy_2
			}
		}
		trigger_event = {
			on_action = regula_vassal_paelex_mind_repair
			}
			
		scope:actor = {
			send_interface_message = {  # Tells the player the outcome.
				type = event_spouse_task_good
				title = regula_make_paelex_outcome_small_boost.t
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:actor.primary_spouse = scope:recipient
							}
							desc = regula_make_paelex_outcome_domina_small_boost.desc
						}
						triggered_desc = {
							trigger = {
								scope:recipient = {
									is_spouse_of = scope:actor
								}
							}
							desc = regula_make_paelex_outcome_small_boost.desc
						}
					}
				}
				right_icon = scope:recipient
			}
		}
	}
}


# Adds a medium boost to mental traits.
regula_paelex_event.1012 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:recipient = {
			if = {
				limit = { has_trait = dull }
				remove_trait = dull
			}
			if = {
				limit = { has_trait = intellect_bad_1 }
				remove_trait = intellect_bad_1
			}
			if = {
				limit = { has_trait = intellect_bad_2 }
				remove_trait = intellect_bad_2
				add_trait = intellect_bad_1
			}
			if = {
				limit = { has_trait = intellect_bad_3 }
				remove_trait = intellect_bad_3
				add_trait = intellect_bad_2
			}
			if = {
				limit = { has_trait = intellect_good_2 }
				remove_trait = intellect_good_2
				add_trait = intellect_good_3
			}
			if = {
				limit = { has_trait = intellect_good_1 }
				remove_trait = intellect_good_1
				add_trait = intellect_good_2
			}
			if = {
				limit = {
					NOR = {
						has_trait = intellect_bad_1
						has_trait = intellect_bad_2
						has_trait = intellect_bad_3
						has_trait = intellect_good_1
						has_trait = intellect_good_2
						has_trait = intellect_good_3
					}
				}
				scope:recipient = {
					add_trait = intellect_good_1
				}
			}
		}
		trigger_event = {
			on_action = regula_vassal_paelex_mind_repair
			}
		scope:actor = {
			send_interface_message = {  # Tell the player the outcome.
				type = event_spouse_task_good
				title = regula_make_paelex_outcome_medium_boost.t
				
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:actor.primary_spouse = scope:recipient
							}
							desc = regula_make_paelex_outcome_domina_medium_boost.desc
						}
						triggered_desc = {
							trigger = {
								scope:recipient = {
									is_spouse_of = scope:actor
								}
							}
							desc = regula_make_paelex_outcome_medium_boost.desc
						}
					}
				}
				right_icon = scope:recipient
			}
		}
	}
}


# Adds a large boost to mental traits.
regula_paelex_event.1013 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:recipient = {
			if = {
				limit = { has_trait = dull }
				remove_trait = dull
			}
			if = {
				limit = { has_trait = education_stewardship_3 }
				remove_trait = education_stewardship_3
				add_trait = education_stewardship_4
			}
			if = {
				limit = { has_trait = education_stewardship_2 }
				remove_trait = education_stewardship_2
				add_trait = education_stewardship_3
			}
			if = {
				limit = { has_trait = education_stewardship_1 }
				remove_trait = education_stewardship_1
				add_trait = education_stewardship_2
			}
			if = {
				limit = { has_trait = education_martial_3 }
				remove_trait = education_martial_3
				add_trait = education_martial_4
			}
			if = {
				limit = { has_trait = education_martial_2 }
				remove_trait = education_martial_2
				add_trait = education_martial_3
			}
			if = {
				limit = { has_trait = education_martial_1 }
				remove_trait = education_martial_1
				add_trait = education_martial_2
			}
			if = {
				limit = { has_trait = education_learning_3 }
				remove_trait = education_learning_3
				add_trait = education_learning_4
			}
			if = {
				limit = { has_trait = education_learning_2 }
				remove_trait = education_learning_2
				add_trait = education_learning_3
			}
			if = {
				limit = { has_trait = education_learning_1 }
				remove_trait = education_learning_1
				add_trait = education_learning_2
			}
			if = {
				limit = { has_trait = education_intrigue_3 }
				remove_trait = education_intrigue_3
				add_trait = education_intrigue_4
			}
			if = {
				limit = { has_trait = education_intrigue_2 }
				remove_trait = education_intrigue_2
				add_trait = education_intrigue_3
			}
			if = {
				limit = { has_trait = education_intrigue_1 }
				remove_trait = education_intrigue_1
				add_trait = education_intrigue_2
			}
			if = {
				limit = { has_trait = education_diplomacy_3 }
				remove_trait = education_diplomacy_3
				add_trait = education_diplomacy_4
			}
			if = {
				limit = { has_trait = education_diplomacy_2 }
				remove_trait = education_diplomacy_2
				add_trait = education_diplomacy_3
			}
			if = {
				limit = { has_trait = education_diplomacy_1 }
				remove_trait = education_diplomacy_1
				add_trait = education_diplomacy_2
			}
			if = {
				limit = { has_trait = intellect_bad_1 }
				remove_trait = intellect_bad_1
			}
			if = {
				limit = { has_trait = intellect_bad_2 }
				remove_trait = intellect_bad_2
				add_trait = intellect_bad_1
			}
			if = {
				limit = { has_trait = intellect_bad_3 }
				remove_trait = intellect_bad_3
				add_trait = intellect_bad_2
			}
			if = {
				limit = { has_trait = intellect_good_2 }
				remove_trait = intellect_good_2
				add_trait = intellect_good_3
			}
			if = {
				limit = { has_trait = intellect_good_1 }
				remove_trait = intellect_good_1
				add_trait = intellect_good_2
			}
			if = {
				limit = {
					NOR = {
						has_trait = intellect_bad_1
						has_trait = intellect_bad_2
						has_trait = intellect_bad_3
						has_trait = intellect_good_1
						has_trait = intellect_good_2
						has_trait = intellect_good_3
					}
				}
				scope:recipient = {
					add_trait = intellect_good_1
				}
			}
		}
		trigger_event = {
			on_action = regula_vassal_paelex_mind_repair
			}
		scope:actor = {
			send_interface_message = {  # Tells the player the outcome.
				type = event_spouse_task_good
				title = regula_make_paelex_outcome_large_boost.t
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:actor.primary_spouse = scope:recipient
							}
							desc = regula_make_paelex_outcome_domina_large_boost.desc
						}
						triggered_desc = {
							trigger = {
								scope:recipient = {
									is_spouse_of = scope:actor
								}
							}
							desc = regula_make_paelex_outcome_large_boost.desc
						}
					}
				}
				right_icon = scope:recipient
			}
		}
	}
}

regula_paelex_event.1021 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:recipient = {
			if = {
				limit = { has_trait = early_great_pox }
				remove_trait = early_great_pox
			}
			if = {
				limit = { has_trait = lovers_pox }
				remove_trait = lovers_pox
			}
			if = {
				limit = { has_trait = ill }
				remove_trait = ill
			}
			if = {
				limit = { has_trait = pneumonic }
				remove_trait = pneumonic
			}		
			if = {
				limit = { has_trait = wounded_1 }
				remove_trait = wounded_1
			}
			if = {
				limit = { has_trait = wounded_2 }
				remove_trait = wounded_2
			}
			if = {
				limit = { has_trait = wounded_3 }
				remove_trait = wounded_3
				add_trait = wounded_1
			}
			if = {
				limit = { has_trait = maimed }
				remove_trait = maimed
			}
			if = {
				limit = { has_trait = disfigured }
				remove_trait = disfigured
			}
			if = {
				limit = { has_trait = gout_ridden }
				remove_trait = gout_ridden
			}
			if = {
				limit = { has_trait = consumption }
				remove_trait = consumption
			}
			if = {
				limit = { has_trait = cancer }
				remove_trait = cancer
			}
			if = {
				limit = { has_trait = blind }
				remove_trait = blind
			}
			if = {
				limit = { has_trait = weak }
				remove_trait = weak
			}
			add_trait = athletic
			add_trait = lifestyle_herbalist
		}
		scope:actor = {
			send_interface_message = {  # Tells the player the outcome.
				type = event_spouse_task_good
				title = regula_make_paelex_outcome_medium_boost.t
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:actor.primary_spouse = scope:recipient
							}
							desc = regula_make_paelex_outcome_domina_medium_boost.desc
						}
						triggered_desc = {
							trigger = {
								scope:recipient = {
									is_spouse_of = scope:actor
								}
							}
							desc = regula_make_paelex_outcome_medium_boost.desc
						}
					}
				}
				right_icon = scope:recipient
			}
		}
	}
}

regula_paelex_event.1022 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:recipient = {
			if = {
				limit = { has_trait = infertile }
				remove_trait = infertile
			}
			if = {
				limit = { has_trait = early_great_pox }
				remove_trait = early_great_pox
			}
			if = {
				limit = { has_trait = lovers_pox }
				remove_trait = lovers_pox
			}
			if = {
				limit = { has_trait = ill }
				remove_trait = ill
			}
			if = {
				limit = { has_trait = pneumonic }
				remove_trait = pneumonic
			}
			if = {
				limit = { has_trait = leper }
				remove_trait = leper
			}		
			if = {
				limit = { has_trait = wounded_1 }
				remove_trait = wounded_1
			}
			if = {
				limit = { has_trait = wounded_2 }
				remove_trait = wounded_2
			}
			if = {
				limit = { has_trait = wounded_3 }
				remove_trait = wounded_3
			}
			if = {
				limit = { has_trait = maimed }
				remove_trait = maimed
			}
			if = {
				limit = { has_trait = disfigured }
				remove_trait = disfigured
			}
			if = {
				limit = { has_trait = one_legged }
				remove_trait = one_legged
			}
			if = {
				limit = { has_trait = disfigured }
				remove_trait = disfigured
			}
			if = {
				limit = { has_trait = infirm }
				remove_trait = infirm
			}
			if = {
				limit = { has_trait = incapable }
				remove_trait = incapable
			}
			if = {
				limit = { has_trait = gout_ridden }
				remove_trait = gout_ridden
			}
			if = {
				limit = { has_trait = consumption }
				remove_trait = consumption
			}
			if = {
				limit = { has_trait = cancer }
				remove_trait = cancer
			}
			if = {
				limit = { has_trait = typhus }
				remove_trait = typhus
			}
			if = {
				limit = { has_trait = bubonic_plague }
				remove_trait = bubonic_plague
			}
			if = {
				limit = { has_trait = smallpox }
				remove_trait = smallpox
			}
			if = {
				limit = { has_trait = blind }
				remove_trait = blind
			}
			if = {
				limit = { has_trait = weak }
				remove_trait = weak
			}
			if = {
				limit = { has_trait = spindly }
				remove_trait = spindly
			}
			if = {
				limit = { has_trait = physique_bad_1 }
				remove_trait = physique_bad_1
			}
			if = {
				limit = { has_trait = physique_bad_2 }
				remove_trait = physique_bad_2
				add_trait = physique_bad_1
			}
			if = {
				limit = { has_trait = physique_bad_3 }
				remove_trait = physique_bad_3
				add_trait = physique_bad_2
			}
			if = {
				limit = { has_trait = physique_good_2 }
				remove_trait = physique_good_2
				add_trait = physique_good_3
			}
			if = {
				limit = { has_trait = physique_good_1 }
				remove_trait = physique_good_1
				add_trait = physique_good_2
			}
			if = {
				limit = {
					NOR = {
						has_trait = physique_bad_1
						has_trait = physique_bad_2
						has_trait = physique_bad_3
						has_trait = physique_good_1
						has_trait = physique_good_2
						has_trait = physique_good_3
					}
				}
				scope:recipient = {
					add_trait = physique_good_1
				}
			}
			if = {
				limit = { has_trait = lisping }
				remove_trait = lisping
			}
			if = {
				limit = { has_trait = stuttering }
				remove_trait = stuttering
			}
			if = {
				limit = { has_trait = scaly }
				remove_trait = scaly
			}
		}
		scope:actor = {
			send_interface_message = {  # Tells the player the outcome.
				type = event_spouse_task_good
				title = regula_make_paelex_outcome_large_boost.t
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:actor.primary_spouse = scope:recipient
							}
							desc = regula_make_paelex_outcome_domina_large_boost.desc
						}
						triggered_desc = {
							trigger = {
								scope:recipient = {
									is_spouse_of = scope:actor
								}
							}
							desc = regula_make_paelex_outcome_large_boost.desc
						}
					}
				}
				right_icon = scope:recipient
			}
		}
	}
}

regula_paelex_event.1031 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:recipient = {
			if = {
				limit = { has_trait = infertile }
				remove_trait = infertile
			}
			if = {
				limit = { has_trait = early_great_pox }
				remove_trait = early_great_pox
			}
			if = {
				limit = { has_trait = lovers_pox }
				remove_trait = lovers_pox
			}
			if = {
				limit = { has_trait = chaste }
				remove_trait = chaste
				add_trait = lustful
			}
			if = {
				limit = { NOT = { has_trait = lustful } }
				add_trait = lustful
			}
			make_pregnant = {
				father = global_var:magister_character
			}
			set_sexuality = bisexual
		}
		scope:actor = {
			send_interface_message = {  # Tells the player the outcome.
				type = event_spouse_task_good
				title = regula_make_paelex_outcome_small_boost.t
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:actor.primary_spouse = scope:recipient	
							}
							desc = regula_make_paelex_outcome_domina_small_boost.desc
						}
						triggered_desc = {
							trigger = {
								scope:recipient = {
									is_spouse_of = scope:actor
								}
							}
							desc = regula_make_paelex_outcome_small_boost.desc
						}
					}
				}
				right_icon = scope:recipient
			}
		}
	}
}

regula_paelex_event.1032 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:recipient = {
			if = {
				limit = { has_trait = infertile }
				remove_trait = infertile
			}
			if = {
				limit = { has_trait = early_great_pox }
				remove_trait = early_great_pox
			}
			if = {
				limit = { has_trait = lovers_pox }
				remove_trait = lovers_pox
			}
			if = {
				limit = { has_trait = chaste }
				remove_trait = chaste
				add_trait = lustful
			}
			if = {
				limit = { has_trait = infertile }
				remove_trait = infertile
				add_trait = fecund
			}
			if = {
				limit = { NOT = { has_trait = fecund } }
				add_trait = fecund
			}
			if = {
				limit = { NOT = { has_trait = lustful } }
				add_trait = lustful
			}
			if = {
				limit = { has_trait = beauty_good_1 }
				remove_trait = beauty_good_1
				add_trait = beauty_good_3
			}
			if = {
				limit = { has_trait = beauty_good_2 }
				remove_trait = beauty_good_2
				add_trait = beauty_good_3
			}
			if = {
				limit = { has_trait = beauty_bad_1 }
				remove_trait = beauty_bad_1
				add_trait = beauty_good_1
			}
			if = {
				limit = { has_trait = beauty_bad_3 }
				remove_trait = beauty_bad_3
				add_trait = beauty_bad_1
			}
			if = {
				limit = { has_trait = beauty_bad_2 }
				remove_trait = beauty_bad_2
			}
			if = {
				limit = {
					NOR = {
						has_trait = beauty_bad_1
						has_trait = beauty_bad_2
						has_trait = beauty_bad_3
						has_trait = beauty_good_1
						has_trait = beauty_good_2
						has_trait = beauty_good_3
					}
				}
				scope:recipient = {
					add_trait = beauty_good_1
				}
			}
			make_pregnant = {
				father = global_var:magister_character
				number_of_children = 2
			}
			set_sexuality = bisexual
		}
		scope:actor = {
			send_interface_message = {  # Tells the player the outcome.
				type = event_spouse_task_good
				title = regula_make_paelex_outcome_medium_boost.t
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:actor.primary_spouse = scope:recipient
							}
							desc = regula_make_paelex_outcome_domina_medium_boost.desc
						}
						triggered_desc = {
							trigger = {
								scope:recipient = {
									is_spouse_of = scope:actor
								}
							}
							desc = regula_make_paelex_outcome_medium_boost.desc
						}
					}
				}
				right_icon = scope:recipient
			}
		}
	}
}

regula_paelex_event.1033 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:recipient = {
			if = {
				limit = { has_trait = infertile }
				remove_trait = infertile
			}
			if = {
				limit = { has_trait = early_great_pox }
				remove_trait = early_great_pox
			}
			if = {
				limit = { has_trait = lovers_pox }
				remove_trait = lovers_pox
			}
			if = {
				limit = { has_trait = chaste }
				remove_trait = chaste
				add_trait = lustful
			}
			if = {
				limit = { has_trait = infertile }
				remove_trait = infertile
				add_trait = fecund
			}
			if = {
				limit = { NOT = { has_trait = fecund } }
				add_trait = fecund
			}
			if = {
				limit = { NOT = { has_trait = lustful } }
				add_trait = lustful
			}			if = {
				limit = { has_trait = beauty_good_1 }
				remove_trait = beauty_good_1
				add_trait = beauty_good_3
			}
			if = {
				limit = { has_trait = beauty_good_2 }
				remove_trait = beauty_good_2
				add_trait = beauty_good_3
			}
			if = {
				limit = { has_trait = beauty_bad_1 }
				remove_trait = beauty_bad_1
				add_trait = beauty_good_1
			}
			if = {
				limit = { has_trait = beauty_bad_3 }
				remove_trait = beauty_bad_3
				add_trait = beauty_bad_1
			}
			if = {
				limit = { has_trait = beauty_bad_2 }
				remove_trait = beauty_bad_2
			}
			if = {
				limit = {
					NOR = {
						has_trait = beauty_bad_1
						has_trait = beauty_bad_2
						has_trait = beauty_bad_3
						has_trait = beauty_good_1
						has_trait = beauty_good_2
						has_trait = beauty_good_3
					}
				}
				scope:recipient = {
					add_trait = beauty_good_1
				}
			}
			make_pregnant = {
				father = global_var:magister_character
				number_of_children = 3
			}
			set_sexuality = bisexual
			add_trait = pure_blooded
		}
		scope:actor = {
			send_interface_message = {  # Tells the player the outcome.
				type = event_spouse_task_good
				title = regula_make_paelex_outcome_large_boost.t
				desc = {
					first_valid = {
						triggered_desc = {
							trigger = {
								scope:actor.primary_spouse = scope:recipient
							}
							desc = regula_make_paelex_outcome_domina_large_boost.desc
						}
						triggered_desc = {
							trigger = {
								scope:recipient = {
									is_spouse_of = scope:actor
								}
							}
							desc = regula_make_paelex_outcome_large_boost.desc
						}
					}
				}
				right_icon = scope:recipient
			}
		}
	}
}

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 = { no_cloak no_hat no_pants no_clothes }
    	animation = personality_zealous
	}

	immediate = {
		# scope:actor = {
		# 	marry = scope:recipient 
		# }
		scope:recipient = {
			set_sexuality = bisexual
			add_character_flag = {
				flag = is_naked
				days = 180
			}
		}
	}

	option = {
		name = regula_paelex_event.1000.b # Push power into her body. Increased beauty, reduction in apparent age.
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_2
		}
	}
	option = {
		name = regula_paelex_event.1000.a # Drive the power into her mind. Increased mental traits, may bump up lifestyle trait.
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_1
		}
	}
	option = {
		name = regula_paelex_event.1000.c # Mix power with your seed. Inheritable traits and pregnancy.
		trigger_event = {
			on_action = regula_vassal_paelex_initiation_3
		}
	}
	option = {
		name = regula_paelex_event.1000.d # Take power for yourself.
		add_piety = 100
	}
	after = {
		scope:recipient = {
			remove_character_flag = is_naked
		}
	}
}