code:
# This story cycle send the event a character should see when they discover a lover's/spouse's lover secret, or when a lover's/spouse's lover secret is exposed.

# It should be started by the secret_lover secret with these scripted effects:
# - start_infidelity_confrontation_story_discovery_effect
# - start_infidelity_confrontation_story_exposure_effect

# To get some special texts in the first event infidelity_confrontation.1000, you can save a variable on the secret before revealing/exposing it, and use the scripted effects to apply that variable to the story. Current special texts:
# - revealed_through_investigation_by_desc
# - revealed_through_confession_to_desc

story_cycle_infidelty_confronter = {

	on_setup = {
		set_variable = {
			name = ongoing_confrontation
			value = no
		}
	}

	on_end = {

	}

	on_owner_death = {
		end_story = yes
	}

	# Send the next confrontation chain
	effect_group = {
		days = { 2 3 }
		chance = 100

		triggered_effect = {
			trigger = {
				var:ongoing_confrontation = no
				has_variable_list = confronting_partners
			}
			effect = {
				#Save some scopes
				save_scope_as = story
				var:lover_1 = { save_scope_as = lover_1 }
				var:lover_2 = { save_scope_as = lover_2 }

				#Make sure there is no one in the list that shouldn't be there anymore
				every_in_list = {
					variable = confronting_partners
					limit = {
						OR = {
							NOR = {
								has_relation_soulmate = scope:lover_1
								has_relation_soulmate = scope:lover_2
								is_consort_of = scope:lover_1
								is_consort_of = scope:lover_2
								has_relation_lover = scope:lover_1
								has_relation_lover = scope:lover_2
							}
						}
					}
					save_temporary_scope_as = remove_from_list
					scope:story = {
						remove_list_variable = {
							name = confronting_partners
							target = scope:remove_from_list
						}
					}
				}

				#In order of importance, each partner of the two lovers will get to make their choice/demand
				random_in_list = {
					variable = confronting_partners
					limit = {
						is_ai = no
					}
					alternative_limit = {
						OR = {
							has_relation_soulmate = scope:lover_1
							has_relation_soulmate = scope:lover_2
						}
					}
					alternative_limit = {
						OR = {
							is_consort_of = scope:lover_1
							is_consort_of = scope:lover_2
						}
					}
					alternative_limit = {
						OR = {
							has_relation_lover = scope:lover_1
							has_relation_lover = scope:lover_2
						}
					}
					save_scope_as = confronting_partner
				}

				#Did we find someone? We might have removed the last character from the list above
				if = {
					limit = { exists = scope:confronting_partner }

					#Who is confronting_partner confronting? If involved with both, pick the "most important" one
					random_in_list = {
						variable = infidelity_lovers
						limit = { has_relation_soulmate = scope:confronting_partner }
						alternative_limit = { is_consort_of = scope:confronting_partner }
						alternative_limit = { has_relation_lover = scope:confronting_partner }
						save_scope_as = infidelity_partner
					}
					random_in_list = {
						variable = infidelity_lovers
						limit = {
							NOT = { this = scope:infidelity_partner }
						}
						save_scope_as = infidelity_partners_lover
					}

					#Did confronting_partner know? (exposed secrets only)
					if = {
						limit = {
							has_variable_list = knowing_confronting_partners
							is_target_in_variable_list = {
								name = knowing_confronting_partners
								target = scope:confronting_partner
							}
						}
						save_scope_value_as = {
							name = confronting_partner_knew
							value = yes
						}
					}
					else_if = {
						limit = {
							has_variable_list = knowing_confronting_partners
						}
						save_scope_value_as = {
							name = confronting_partner_knew
							value = no
						}
					}

					#Save exposer (if exposed)
					if = {
						limit = { exists = var:exposer }
						var:exposer = { save_scope_as = exposer }
					}

					#Save the secret (if discovery)
					scope:infidelity_partner = {
						random_secret = {
							limit = {
								secret_type = secret_lover
								secret_target = scope:infidelity_partners_lover
							}
							save_scope_as = secret
						}
					}

					#Remove current confronting_partner from list
					remove_list_variable = {
						name = confronting_partners
						target = scope:confronting_partner
					}

					#Block other choices while the current one is evaluating
					set_variable = {
						name = ongoing_confrontation
						value = yes
					}

					#Send event!
					scope:confronting_partner = {
						if = {
							limit = {
								has_trait = magister_trait_group
								scope:lover_1 = {
										has_trait = devoted_trait_group
								}
							}
							scope:lover_1 = {
								save_scope_as = lover_spouse
							}
							trigger_event = regula_adultery.0002
						}
						else_if = {
							limit = {
								has_trait = magister_trait_group
								scope:lover_2 = {
									has_trait = devoted_trait_group
								}
							}
							scope:lover_2 = {
								save_scope_as = lover_spouse
							}
							trigger_event = regula_adultery.0002
						}
						else = {
							trigger_event = infidelity_confrontation.1000
						}
					}
				}
			}
		}

		triggered_effect = {
			trigger = {
				NOT = { has_variable_list = confronting_partners }
				var:ongoing_confrontation = no #If it's yes, we still have an unresolved confrontation going on
			}

			effect = {
				end_story = yes
				#todo end the story with a happy summary if you're still together
			}
		}
	}

	#100 days self destruct
	effect_group = {
		days = 100
		chance = 100

		triggered_effect = {
			trigger = { always = yes }
			effect = {
				end_story = yes
			}
		}
	}
}


code:
story_regula_infecta_chain = {
    on_setup = {
        # Handled in the Fascinare Success effect.
    }

    on_end = {
        # In regula_virus_events
    }

	on_owner_death = {
		if = {
			limit = { exists = story_owner.player_heir }
			make_story_owner = story_owner.player_heir
		}
		else = {
			debug_log = "Regula infecta chain fizzled."
			end_story = yes
		}
	}

    	#If no one is sick anymore, send the outbreak end event which kills the story
	effect_group = {
		days = 30
		chance = 5

		triggered_effect = {
			trigger = {
                NOT = {
                    any_in_list = {
                        variable = new_converts
                        has_trait = regula_virus
                    }
                }
            }
			effect = {
				save_scope_as = infecta_story
				var:patient_zero = {
					save_scope_as = regula_patient_zero2
				}
				hidden_effect = {
					set_variable = {
						name = infection_tally
						value = 0
					}
				}
				every_in_list = {
					variable = new_converts
					prev = {
						change_variable = {
							name = infection_tally
							add = 1
						}
					}
				}
				global_var:magister_character = {
                    send_interface_message = {  # Tells the player the outcome.
                        type = event_spouse_task_good
                        title = regula_virus_outcome_invalid.t
                        desc = regula_virus_outcome_invalid.desc
                        right_icon = scope:regula_patient_zero
                    }
                }
				end_story = yes
			}
		}
		triggered_effect = {
			trigger = {
				any_in_list = {
					variable = new_converts
					has_trait = regula_virus
					is_imprisoned = yes
				}
            }
			effect = {
				save_scope_as = infecta_story
				hidden_effect = {
					set_variable = {
						name = infection_tally
						value = 0
					}
				}
				every_in_list = {
					variable = new_converts
					prev = {
						change_variable = {
							name = infection_tally
							add = 1
						}
					}
				}
				random_in_list = {
					variable = new_converts
					limit = {
						has_trait = regula_virus
						is_imprisoned = yes
					}
					save_scope_as = last_patient
					remove_trait = regula_virus
				}

				global_var:magister_character = {
                    send_interface_message = {  # Tells the player the outcome.
                        type = event_spouse_task_good
                        title = regula_virus_outcome_story_jail.t
                        desc = regula_virus_outcome_story_jail.desc
						left_icon = scope:regula_patient_zero
						right_icon = scope:last_patient
                    }
                }
				end_story = yes
			}
		}
	}
}

license: mit


code:
# The entry should be named in the same way that the elective succession law is named to define it's voter's logic.
# Root scope - Elector, the character voting in the election.
# scope:candidate scope - Candidate, Character considered for the title.
# scope:title scope - Title, The title the nomination is for.
# scope:holder scope - Ruler, The ruler currently holding the title.
# scope:holder_candidate scope - Favored Candidate, The title owner's candidate.
# The voter will vote for the top score candidate calculated from this script.

compeditae_elective = {
	elector_vote_strength = {
		base = 0
		modifier = { #Each voter is either the Magister or a Mulsa or above. The larger the domain and deeper their submission, the more voting power they have.
			desc = tooltip_scandinavian_elective_development
			is_landed = yes
			# or = {
			# 	has_trait = devoted_trait_group
			# 	has_trait = magister_trait_group
			# }
			domain_size >= 1
			any_held_title = {
				tier = tier_county
				development_level > 0
				# target_is_de_jure_liege_or_above = scope:title
			}
			add = { #Every county adds to the voting power.
				every_held_title = {
					limit = {
						tier = tier_county
						development_level > 0
						# target_is_de_jure_liege_or_above = scope:title
					}
					add = {
						value = this.development_level
						if = {
							limit = {
								NOT = { this.faith = root.faith }
							}
							divide = 2
						}
						if = {
							limit = {
								NOT = { this.culture = root.culture }
							}
							divide = 2
						}
						min = 1
					}
				}
			}
		}
		modifier = { #Trait boost Magister
			desc = tooltip_compeditae_power_magister
			has_trait = magister_trait_group
			factor = 5
		}
		modifier = { #Trait boost Mulsa
			desc = tooltip_compeditae_power_mulsa
			has_trait = mulsa
			factor = 1
		}
		modifier = { #Trait boost Paelex
			desc = tooltip_compeditae_power_paelex
			has_trait = paelex
			factor = 2
		}
		modifier = { #Trait boost Domina
			desc = tooltip_compeditae_power_domina
			has_trait = domina
			factor = 5
		}
		modifier = { #Trait boost Orba
			desc = tooltip_compeditae_power_orba
			has_trait = orba
			factor = 0.1
		}
		min = 1
	}

	electors = {
		max = 21 # Keep the number of electors sane, to limit drag on the system.
		add = holder
		add = {
			type = holder_direct_vassals
			limit = {
				target_is_liege_or_above = scope:holder #All direct vassals of the Magister.
				is_ruler = yes
				OR = {
					has_trait = devoted_trait_group
					has_trait = magister_trait_group
				}
				is_landed = yes
				exists = capital_county
				highest_held_title_tier > 1 #Barons excluded.
				domain_size >= 1
			}
		}
		add = {
			type = title_dejure_vassals
			limit = {
				target_is_liege_or_above = scope:holder #All de jure vassals, no matter the tier, sub-vassals included.
				is_ruler = yes
				OR = {
					has_trait = devoted_trait_group
					has_trait = magister_trait_group
				}
				is_landed = yes
				exists = capital_county
				highest_held_title_tier > 1 #Barons excluded.
				domain_size >= 1
				any_held_title = { #Elector title must be a de jure vassal of the title being voted on; multi-Dukes (or similar) might have two duchies in multiple electoral domains, which they should be able to vote on. This is only valid for the highest-tier title (so a Duke-Elector who also owns a County which is an electoral title for another title does not get a vote from that county).
					tier = root.highest_held_title_tier
					exists = de_jure_liege
					target_is_de_jure_liege_or_above = scope:title
				}
			}
		}
		add = {
			type = holder_spouses
			limit = {
				target_is_liege_or_above = scope:holder #All the Magister's spouses (in the realm).
				is_ruler = yes
				OR = {
					has_trait = devoted_trait_group
					has_trait = magister_trait_group
				}
				is_landed = yes
				exists = capital_county
				highest_held_title_tier > 1 #Barons excluded.
				domain_size >= 1
			}
		}
		priority = { # Magister then Domina, then Paelex-Queens, Paelex-Duchesses, Mulsa-Queens, Paelex-Countesses, Mulsa-Duchesses, Mulsa-Countesses.
			base = 1
			modifier = { # The Emperor is always picked.
				add = 202
				this = scope:holder
			}
			modifier = { # Queens first.
				add = 75
				highest_held_title_tier >= 4
			}
			modifier = { #Duchesses second
				add = 30
				highest_held_title_tier = 3
			}
			modifier = { #Domina will always be on the list
				add = 126
				has_trait = domina
			}
			modifier = { #Then Paelices
				add = 50
				has_trait = paelex
			}
		}
	}

	candidate_score = {
		base = 0
		######################	Elector self-voting pattern	##########################
		elector_self_voting_pattern_feudal_elective_modifier = yes

		##########################	Holder voting pattern	##########################
		holder_voting_pattern_feudal_elective_modifier = yes

		##########################	Elector voting patterns (circumstances)	##########################
		elector_voting_pattern_circumstances_feudal_elective_modifier = yes
		elector_voting_pattern_circumstances_scandinavian_elective_modifier = yes

		##########################	Elector voting patterns (prestige/piety)	##########################
		elector_voting_pattern_prestige_piety_feudal_elective_modifier = yes

		##########################	Elector voting patterns (traits)	##########################
		elector_voting_pattern_traits_compeditae_elective_modifier = yes

		##########################	Elector voting patterns (opinion)	##########################
		elector_voting_pattern_opinion_compeditae_elective_modifier = yes
	}

	#scope:candidate = Candidate, scope:title = Title, scope:holder_candidate = Candidate currently selected by ruler.
	candidates = {
		# add = {
		# 	type = title_claimants
		# 	limit = {
		# 		feudal_elective_potential_landless_claimant_candidate_trigger = yes
		# 	}
		# }
		add = {
			type = holder_close_or_extended_family
			limit = {
				feudal_elective_potential_landless_dynastic_candidate_trigger = yes
			}
		}
	}
}


code:
###
# Indices notes for other modders
# Reserved 6500 - 6599 for this mod
# 6550-6559: Magister traits.
# 6560-6569: Concubine traits.
# 6570-6579: Random lifestyle traits.
# 6580-6589: Magister Bloodlines
# 6590-6599: Generic Bloodlines
###

magister_1 = {
	index = 6551

    inherit_chance = 0
	birth = 0
    random_creation = 0

    diplomacy = -3
	learning = -3
	stress_gain_mult = 0.25
	health = -0.5
	prowess = -2
	same_faith_opinion = 15

	flag = carn_no_consequences_for_extramarital_sex_with_others

	shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_magister_1_desc
			}
			desc = trait_magister_1_character_desc
		}
	}

	group = magister_trait_group
    level = 1

	#AI Values
    ai_honor = -15
	ai_zeal = -20

	compatibility = {
		seducer = @pos_compat_high
		zealous = @pos_compat_medium
		humble = @pos_compat_high
		lustful = @pos_compat_medium
		arrogant = @neg_compat_high
		calm = @neg_compat_medium
		ambitious = @neg_compat_medium
		chaste = @neg_compat_low
		greedy = @neg_compat_low
	}
}

magister_2 = {
	index = 6552

    inherit_chance = 0
	birth = 0
    random_creation = 0

    intrigue = 1
    diplomacy = 1
	fertility = 0.1
	attraction_opinion = 5
	stress_gain_mult = -0.25
	prowess = 4
	same_faith_opinion = 25
	monthly_piety = 1

	flag = carn_no_consequences_for_extramarital_sex_with_others

	shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_magister_2_desc
			}
			desc = trait_magister_2_character_desc
		}
	}

	group = magister_trait_group
    level = 2

	#AI Values
    ai_honor = -15
	ai_zeal = -20

	compatibility = {
		seducer = @pos_compat_high
		zealous = @pos_compat_medium
		humble = @pos_compat_high
		lustful = @pos_compat_medium
		arrogant = @neg_compat_high
		calm = @neg_compat_medium
		ambitious = @neg_compat_medium
		chaste = @neg_compat_low
		greedy = @neg_compat_low
	}
}

magister_3 = {
	index = 6553

    inherit_chance = 0
	birth = 0
    random_creation = 0

    intrigue = 3
    diplomacy = 3
	attraction_opinion = 10
	prowess = 6
	fertility = 0.15
	health = 0.25
	stress_gain_mult = -0.50
	same_faith_opinion = 25
	monthly_piety = 1

	flag = carn_no_consequences_for_extramarital_sex_with_others

	shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_magister_3_desc
			}
			desc = trait_magister_3_character_desc
		}
	}

	group = magister_trait_group
    level = 3

	#AI Values
    ai_honor = -15
	ai_zeal = -20

	compatibility = {
		seducer = @pos_compat_high
		zealous = @pos_compat_medium
		humble = @pos_compat_high
		lustful = @pos_compat_medium
		arrogant = @neg_compat_high
		calm = @neg_compat_medium
		ambitious = @neg_compat_medium
		chaste = @neg_compat_low
		greedy = @neg_compat_low
	}
}

magister_4 = {
	index = 6554

    inherit_chance = 0
	birth = 0
    random_creation = 0

    intrigue = 3
	diplomacy = 3
	martial = 3
	prowess = 8
	fertility = 0.2
	health = 0.40
	attraction_opinion = 20
	stress_gain_mult = -0.60
	dread_gain_mult = 0.25
	different_faith_opinion = 5
	same_faith_opinion = 25
	monthly_piety = 1

	flag = carn_no_consequences_for_extramarital_sex_with_others

	shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_magister_4_desc
			}
			desc = trait_magister_4_character_desc
		}
	}

	group = magister_trait_group
    level = 4

	#AI Values
    ai_honor = -15
	ai_zeal = -20

	compatibility = {
		seducer = @pos_compat_high
		zealous = @pos_compat_medium
		humble = @pos_compat_high
		lustful = @pos_compat_medium
		arrogant = @neg_compat_high
		calm = @neg_compat_medium
		ambitious = @neg_compat_medium
		chaste = @neg_compat_low
		greedy = @neg_compat_low
	}
}

magister_5 = {
	index = 6555

    inherit_chance = 0
	birth = 0
    random_creation = 0

    intrigue = 3
	diplomacy = 3
	martial = 3
	attraction_opinion = 25
	prowess = 10
	fertility = 0.25
	health = 0.50
	stress_gain_mult = -0.75
	dread_gain_mult = 0.50
	dread_decay_mult = -0.25
	same_faith_opinion = 25
	different_faith_opinion = 15
	monthly_piety = 1

	flag = carn_no_consequences_for_extramarital_sex_with_others

	#shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_magister_5_desc
			}
			desc = trait_magister_5_character_desc
		}
	}

	group = magister_trait_group
    level = 5

	#AI Values
    ai_honor = -15
	ai_zeal = -20

	compatibility = {
		seducer = @pos_compat_high
		zealous = @pos_compat_medium
		humble = @pos_compat_high
		lustful = @pos_compat_medium
		arrogant = @neg_compat_high
		calm = @neg_compat_medium
		ambitious = @neg_compat_medium
		chaste = @neg_compat_low
		greedy = @neg_compat_low
	}
}

magister_6 = {
	index = 6556

    inherit_chance = 0
	birth = 0
    random_creation = 0

    intrigue = 3
	diplomacy = 3
	martial = 3
	prowess = 12
	attraction_opinion = 25
	fertility = 0.25
	health = 0.50
	stress_gain_mult = -0.90
	dread_gain_mult = 0.50
	dread_decay_mult = -0.50
	same_faith_opinion = 25
	different_faith_opinion = 25
	monthly_piety = 1

	flag = carn_no_consequences_for_extramarital_sex_with_others

	#shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_magister_6_desc
			}
			desc = trait_magister_6_character_desc
		}
	}

	group = magister_trait_group
    level = 6

	#AI Values
    ai_honor = -15
	ai_zeal = -20

	compatibility = {
		seducer = @pos_compat_high
		zealous = @pos_compat_medium
		humble = @pos_compat_high
		lustful = @pos_compat_medium
		arrogant = @neg_compat_high
		calm = @neg_compat_medium
		ambitious = @neg_compat_medium
		chaste = @neg_compat_low
		greedy = @neg_compat_low
	}
}

mulsa = {
	index = 6561
	opposites = {
		magister_trait_group
	}

    inherit_chance = 0
	birth = 0
    random_creation = 0

    stewardship = 2
	learning = 2
	diplomacy = 2
	prowess = 2
	fertility = 0.15
	attraction_opinion = 10
	same_opinion = 15
	opposite_opinion = 25

	stress_gain_mult = -0.1
	group = devoted_trait_group
	level = 1

	genetic_constraint_all = beauty_3
	shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_mulsa_desc
			}
			desc = trait_mulsa_character_desc
		}
	}
}

paelex = {
	index = 6562
	opposites = {
		magister_trait_group
	}

	inherit_chance = 0
	birth = 0
	random_creation = 0

    stewardship = 3
	learning = 3
	diplomacy = 3
	prowess = 4

	fertility = 0.3
	health = 0.50
	attraction_opinion = 10
	same_opinion = 25
	opposite_opinion = 50
	stress_gain_mult = -0.2
	group = devoted_trait_group
	level = 2

	flag = can_not_marry

	genetic_constraint_all = beauty_3
	shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_paelex_desc
			}
			desc = trait_paelex_character_desc
		}
	}

	ai_honor = dominant_positive_ai_value  # Should shut down seduce schemes.

}

domina = {
	index = 6563
	opposites = {
		magister_trait_group
	}

	inherit_chance = 0
	birth = 0
	random_creation = 0

    stewardship = 5
	learning = 5
	diplomacy = 5
	intrigue = 3
	prowess = 6

	fertility = 0.5
	health = 1
	attraction_opinion = 10
	same_opinion = 50
	opposite_opinion = 50
	stress_gain_mult = -0.25
	group = devoted_trait_group
	level = 3

	flag = can_not_marry

	genetic_constraint_all = beauty_3
	shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_domina_desc
			}
			desc = trait_domina_character_desc
		}
	}

	ai_honor = dominant_positive_ai_value  # Should shut down seduce schemes.

}

orba = {
	index = 6564
	opposites = {
		magister_trait_group
	}

	inherit_chance = 0
	birth = 0
	random_creation = 0

	diplomacy = -5
	martial = -5
	stewardship = -5
	learning = -5
	intrigue = -5
	health = -8
	opposite_opinion = 50
	stress_gain_mult = 0.50
	group = devoted_trait_group
	level = 4

	flag = can_not_marry
	can_have_children = no
	shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_orba_desc
			}
			desc = trait_orba_character_desc
		}
	}
}

contubernalis = {
	index = 6565

	opposites = {
		devoted_trait_group
		magister_trait_group
	}

	diplomacy = 15
	intrigue = -10
	stewardship = -10
	martial = -10
	learning = -10
	prowess = 15
	fertility = 1
	immortal = yes

	inherit_chance = 0
	birth = 0
	random_creation = 0

	stress_gain_mult = -1 # Ignorance is bliss, as they say.
	stress_loss_mult = 1
	dread_baseline_add = -25
	dread_loss_mult = 1

	incapacitating = yes
	can_have_children = no
	disables_combat_leadership = yes

	blocks_from_claim_inheritance = yes
	flag = can_not_be_granted_titles
	flag = blocked_from_leaving	# Cannot leave player court
	# flag = carn_cannot_be_enslaved
	flag = can_not_marry
	flag = is_naked

	ai_honor = dominant_positive_ai_value
	shown_in_ruler_designer = no

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_contubernalis_desc
			}
			desc = trait_contubernalis_character_desc
		}
	}

	ai_energy = -100
}

regula_undying = {
	index = 6566

	opposites = {
		magister_trait_group
	}

    inherit_chance = 0
	birth = 0
    random_creation = 0

	opposite_opinion = 500
	immortal = yes
	shown_in_ruler_designer = no
	stress_gain_mult = -1
	stress_loss_mult = 1
	negate_health_penalty_add = 1
	can_have_children = no
	dread_baseline_add = 25

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_undying_desc
			}
			desc = trait_regula_undying_character_desc
		}
	}
}

sigillum = {
	index = 6567

	inherit_chance = 0
	birth = 0
    random_creation = 0
	shown_in_ruler_designer = no

	health = -0.25
	intrigue = -2
	fertility = -0.2

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_sigillum_desc
			}
			desc = trait_sigillum_character_desc
		}
	}
}

regula_virus = {
	index = 6568
	health_trait = yes

	inherit_chance = 0
	birth = 0
    random_creation = 0
	shown_in_ruler_designer = no

	diplomacy = -1
	intrigue = -1
	stewardship = -1
	martial = -1
	learning = -1

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_virus_desc
			}
			desc = trait_regula_virus_character_desc
		}
	}
}

regula_gossip = {
	index = 6570

	inherit_chance = 0
	birth = 0
	random_creation = 0

	diplomacy = 3
	intrigue = -1

	same_opinion = 10
	liege_opinion = -5

	ruler_designer_cost = 20

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_gossip_desc
			}
			desc = trait_regula_gossip_character_desc
		}
	}
}

regula_child_of_the_book = {
	index = 6571

	inherit_chance = 0
	birth = 0
	random_creation = 0

	diplomacy = 2
	martial = 2
	stewardship = 2
	intrigue = 2
	learning = 2

	# liege_opinion = 22
	opinion_of_liege = 20
	courtier_and_guest_opinion = 20
	monthly_stewardship_lifestyle_xp_gain_mult = 0.5
	monthly_piety = 2

	shown_in_ruler_designer = no

	ai_energy = 45

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_child_of_the_book_desc
			}
			desc = trait_regula_child_of_the_book_character_desc
		}
	}
}

################ Magister Bloodlines ###################

regula_fascinare_bloodline = {
	index = 6580

	inherit_chance = 100
	birth = 0

	random_creation = 0
	shown_in_ruler_designer = no

	diplomacy = 2
	fertility = 0.05

	valid_sex = female

	flag = regula_bloodline_magister

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_fascinare_bloodline_desc
			}
			desc = trait_regula_fascinare_bloodline_character_desc
		}
	}

	ai_sociability = 15
}

regula_domitans_bloodline = {
	index = 6581

	inherit_chance = 100
	birth = 0

	random_creation = 0
	shown_in_ruler_designer = no

	valid_sex = female

	inbreeding_chance = -0.25
	years_of_fertility = 5

	flag = regula_bloodline_magister

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_domitans_bloodline_desc
			}
			desc = trait_regula_domitans_bloodline_character_desc
		}
	}
}

regula_contubernalis_bloodline = {
	index = 6582

	inherit_chance = 100
	birth = 0

	random_creation = 0
	shown_in_ruler_designer = no

	attraction_opinion = -20
	monthly_dread = 1

	valid_sex = male

	flag = regula_bloodline_magister

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_contubernalis_bloodline_desc
			}
			desc = trait_regula_contubernalis_bloodline_character_desc
		}
	}

	compatibility = {
		craven = @pos_compat_medium
		just = @neg_compat_medium
		compassionate = @neg_compat_high
	}
}

regula_domination_war_bloodline = {
	index = 6583

	inherit_chance = 100
	birth = 0

	random_creation = 0
	shown_in_ruler_designer = no

	dread_baseline_add = 5
	knight_limit = 4
	knight_effectiveness_mult = 0.25

	valid_sex = male

	flag = regula_bloodline_magister

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_domination_war_bloodline_desc
			}
			desc = trait_regula_domination_war_bloodline_character_desc
		}
	}

	compatibility = {
		craven = @pos_compat_medium
		arrogant = @neg_compat_medium
		ambitious = @neg_compat_low
	}
}

regula_servitude_war_bloodline = {
	index = 6584

	inherit_chance = 100
	birth = 0
	valid_sex = male

	random_creation = 0
	shown_in_ruler_designer = no

	vassal_limit = 10
	personal_scheme_power_add = 15

	flag = regula_bloodline_magister

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_servitude_war_bloodline_desc
			}
			desc = trait_regula_servitude_war_bloodline_character_desc
		}
	}

	compatibility = {
		deceitful = @pos_compat_medium
		fickle = @pos_compat_medium
		ambitious = @pos_compat_low
		brave = @neg_compat_low
		just = @neg_compat_low
	}
}

regula_potestas_queen_bloodline = {
	index = 6585

	inherit_chance = 100
	birth = 0
	random_creation = 0

	valid_sex = male

	shown_in_ruler_designer = no

	monthly_prestige = 0.5
	monthly_tyranny = -0.2

	flag = regula_bloodline_magister

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_potestas_queen_bloodline_desc
			}
			desc = trait_regula_potestas_queen_bloodline_character_desc
		}
	}
}

regula_obedience_bloodline = {
	index = 6586

	inherit_chance = 100
	birth = 0

	random_creation = 0
	shown_in_ruler_designer = no

	valid_sex = female

	stress_loss_mult = 0.3
	opinion_of_same_faith = 20
	ai_boldness = -100
	ai_honor = 50

	flag = regula_bloodline_magister

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_obedience_bloodline_desc
			}
			desc = trait_regula_obedience_bloodline_character_desc
		}
	}
}

################ Generic Bloodlines ###################

regula_multitasker_bloodline = {
	index = 6590

	inherit_chance = 80
	birth = 0

	fame = yes
	good = yes

	random_creation = 0
	ruler_designer_cost = 200

	max_personal_schemes_add = 1

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_multitasker_bloodline_desc
			}
			desc = trait_regula_multitasker_bloodline_character_desc
		}
	}

	#AI Values
    ai_honor = -15
	ai_energy = 20
	ai_sociability = 20

	compatibility = {
		seducer = @pos_compat_high
		lustful = @pos_compat_medium
		trusting = @pos_compat_low
		chaste = @neg_compat_medium
		temperate = @neg_compat_low
	}
}

regula_bun_bloodline = {
	index = 6591

	inherit_chance = 80
	birth = 0
	valid_sex = female

	fame = yes
	good = yes

	fertility = 0.1

	random_creation = 0
	ruler_designer_cost = 80

	flag = regula_twin_boost

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { exists = this }
				}
				desc = trait_regula_bun_bloodline_desc
			}
			desc = trait_regula_bun_bloodline_character_desc
		}
	}

	compatibility = {
		gregarious = @pos_compat_high
		impatient = @neg_compat_medium
		ambitious = @pos_compat_low
		greedy = @pos_compat_medium
	}
}


code:
regula_courtier_spouse_ruler_trigger = {
	first_not = regula_courtier_spouse_ruler
}

fascinare_cooldown = {
	first_not = I_HAVE_FASCINARE_COOLDOWN_ON_THIS_CHARACTER
}

magister_trait_5_required_decision_trigger = {
	first = magister_trait_5_achieved_decision
	first_not = magister_trait_5_required_decision
}

magister_trait_2_required_trigger = {
	first = magister_trait_2_achieved
	first_not = magister_trait_2_required
}

magister_trait_3_required_trigger = {
	first = magister_trait_3_achieved
	first_not = magister_trait_3_required
}

magister_trait_4_required_trigger = {
	first = magister_trait_4_achieved
	first_not = magister_trait_4_required
}

magister_trait_5_required_trigger = {
	first = magister_trait_5_achieved
	first_not = magister_trait_5_required
}

magister_trait_6_required_trigger = {
	first = magister_trait_6_achieved
	first_not = magister_trait_6_required
}

rapta_maritus_in_progress_trigger = {
	first = rapta_maritus_in_progress
	first_not = rapta_maritus_in_progress
}

sanctifica_serva_health_trigger = {
	first_not = sanctifica_serva_health
}

sanctifica_serva_in_progress_trigger = {
	first_not = sanctifica_serva_in_progress
}

regula_already_spellbound_trigger = {
	first_not = regula_already_spellbound
}

regula_bestow_barony_required_trigger = {
	first_not = regula_bestow_barony_required
}

regula_instiga_discordia_in_progress_trigger = {
	first_not = regula_instiga_discordia_in_progress
}


code:
doctrine_concubine_regula_can_pick_trigger = {
	first = doctrine_concubine_regula_can_pick
	first_not = doctrine_concubine_regula_cannot_pick
}

must_be_at_the_top_trigger = {
	global = MUST_BE_INDEPENDENT
}

must_serve_magister_trigger = {
	global = MUST_SERVE_MAGISTER
}

does_not_serve_magister_trigger = {
	global = DOES_NOT_SERVE_MAGISTER
}

holy_site_reg_offspring_held_trigger = {
	first = holy_site_reg_offspring_held
}

regula_throw_orgy_concubine_minimum = {
	first_not = I_HAVE_FEWER_THAN_6_CONCUBINES
}

regula_choir_conversion_trigger = {
	first_not = regula_choir_conversion
}

regula_compeditae_election_concubine_pass_minimum_decision_trigger = {
	first = regula_compeditae_election_concubine_pass_minimum_decision
}

regula_compeditae_election_concubine_pass_minimum_trigger = {
	first = REGULA_COMPEDITAE_ELECTION_CONCUBINE_MINIMUM
}

regula_faith_head_trigger = {
	first_not = regula_faith_head
}

regula_2_covert_powerful_vassals_trigger = {
	first = regula_2_covert_powerful_vassals_required
	first_not = regula_2_covert_powerful_vassals_achieved
}

regula_spouse_entranced_trigger = {
	first = regula_spouse_covert_required
	first_not = regula_spouse_covert_achieved
}


code:
version="0.101"
picture = "thumbnail.png"
tags={
	"Gameplay"
	"Character Interactions"
	"Decisions"
	"Religion"
	"Schemes"
}
name="Regula Magistri"
supported_version="1.8.*"


code:
namespace = regula_orgy

# Invitation event for concubines.
regula_orgy.1000 = {
	type = letter_event
	opening = regula_orgy.1000.t
	desc = regula_orgy.1000.desc
	sender = scope:host

	immediate = {
		scope:activity.activity_owner = { save_scope_as = host }
		debug_log = invitation_received
	}

  	# Concubines never decline the invitation.
	option = {
		name = regula_orgy.1000.a

		play_music_cue = "mx_cue_sacredrite"
		scope:activity = {
			accept_invitation_for_character = prev
		}
		reverse_add_opinion = {
			target = scope:host
			modifier = pleased_opinion
			opinion = 20
		}
		ai_chance = {
			base = 100
		}
	}
}

# Invitation event for non-concubines.
regula_orgy.1001 = {
	type = letter_event
	opening = regula_orgy.1001.t
	desc = regula_orgy.1001.desc
	sender = scope:host

	immediate = {
		scope:activity.activity_owner = { save_scope_as = host }
		debug_log = invitation_received
	}

  	#Yes!
	option = {
		name = regula_orgy.1001.a

		play_music_cue = "mx_cue_sacredrite"
		scope:activity = {
			accept_invitation_for_character = prev
		}
		reverse_add_opinion = {
			target = scope:host
			modifier = pleased_opinion
			opinion = 10
		}
		ai_chance = {
			base = 100
			opinion_modifier = {
				opinion_target = scope:host
			}
		}
	}

	#No...
	option = {
		name = regula_orgy.1001.b

		scope:activity = {
			decline_invitation_for_character = prev
		}
		reverse_add_opinion = {
			target = scope:host
			modifier = disappointed_opinion
			opinion = -10
		}
		ai_chance = {
			base = 10
			modifier = {
				add = 15
				target_is_liege_or_above = scope:host
			}
			ai_value_modifier = {
				ai_boldness = 0.2
			}
		}
	}
}

#No guests came
regula_orgy.1002 = {
	type = character_event
	title = regula_orgy.1002.t
	desc = regula_orgy.1002.desc
	theme = regula_theme
	override_background = {
		event_background = regula_orgy
	}
	left_portrait = {
		character = scope:target
		animation = sadness
	}

	option = {
		name = regula_orgy.1002.a

		scope:activity = {
			complete_activity = yes
		}
	}
}

#Uninvited guest
scripted_trigger regula_orgy_1003_potential_guest_trigger = {
	NOR = {
		has_RelationToMe_relation = { CHARACTER = root }
		has_trait = devoted_trait_group
	}
	is_close_family_of = scope:inviter
	is_female = yes
	age >= 18
	age <= 35
}

regula_orgy.1003 = {
	type = character_event
	title = regula_orgy.1003.t
	desc = regula_orgy.1003.desc
	theme = regula_theme
	override_background = {
		event_background = corridor_night
	}
	left_portrait = scope:inviter
	right_portrait = scope:new_guest

	immediate = {
		hidden_effect = {
			capital_province = { save_scope_as = capital }

			#Find inviter
			scope:activity = {
				random_participant = {
					limit = {
						is_ai = yes
						# NOT = { is_courtier_of = root }
						any_close_family_member = {
							is_female = yes
							age >= 16
							age <= 35
							NOT = { has_trait = devoted_trait_group }
						}
					}
					alternative_limit = {
					 	is_ai = yes
					}
					alternative_limit = {
						always = yes
					}
					save_scope_as = inviter
				}
			}

			#50% chance of pool character guest, 50% chance of new guest
			random = {
				chance = 50
				random_pool_character = {
					province = capital_province
					limit = {
						regula_orgy_1003_potential_guest_trigger = yes
						save_temporary_scope_as = potential_guest
					}
					alternative_limit = {
						OR = {
							AND = {
								OR = {
									has_trait = beauty_good
									has_trait = intellect_good
									has_trait = lustful
								}
								matching_gender_and_sexuality_trigger = { CHARACTER_1 = scope:potential_guest CHARACTER_2 = root }
							}
							has_trait = deviant
						}
						NOT = { has_trait = devoted_trait_group }
						is_male = no
						age >= 18
						age <= 35
					}
					save_scope_as = new_guest
				}
			}

			if = {
				limit = { NOT = { exists = scope:new_guest } }
				regula_create_orgy_guest_effect = { WHO = root }
				scope:created_orgy_guest = { save_scope_as = new_guest }
			}
		}
	}

	#You are very welcome!
	option = {
		name = regula_orgy.1003.a

		scope:activity = {
			hidden_effect = { invite_character_to_activity = scope:new_guest }
			accept_invitation_for_character = scope:new_guest
		}
		# Entrance the guest
		scope:new_guest = {
			add_trait = mulsa
			set_character_faith = global_var:magister_character.faith
			hidden_effect = { # No take-backs.
				add_character_flag = {
					flag = converted_by_forced_conversion_interaction
					years = 10
				}
			}
			add_character_flag = {
				flag = regula_orgy_new_guest
				days = 30
			}
		}
		reverse_add_opinion = {
			target = scope:new_guest
			modifier = grateful_opinion
			opinion = 30
		}
		reverse_add_opinion = {
			target = scope:inviter
			modifier = grateful_opinion
			opinion = 20
		}
	}

	#Invite only, sorry
	option = {
		name = regula_orgy.1003.b

		reverse_add_opinion = {
			target = scope:new_guest
			modifier = disappointed_opinion
			opinion = -15
		}
		# reverse_add_opinion = { # They're not sad, the potential guest was a gift.
		# 	target = scope:inviter
		# 	modifier = disappointed_opinion
		# 	opinion = 0
		# }
	}
}

regula_orgy.1010 = { # Launch the orgy.
	type = character_event
	title = regula_orgy.1010.t
	desc = regula_orgy.1010.desc
	theme = seduce_scheme
	override_background = {
		event_background = regula_orgy
	}
	left_portrait = root

	immediate = {
		save_scope_as = host
		capital_province = { save_scope_as = background_wilderness_scope }
	}

	#Launch option
	option = {
		name = regula_orgy.1010.a
		scope:activity = {
			random_participant = {
				limit = {
					has_trait = devoted_trait_group
					NOT = { has_character_flag = regula_orgy_new_guest }
				}
				save_scope_as = first_orgy_partner
			}
			every_participant = {
				regula_mutare_corpus_cure_disease_single_effect = yes
			}
		}
		carn_had_sex_with_effect = {
			CHARACTER_1 = scope:host
			CHARACTER_2 = scope:first_orgy_partner
			C1_PREGNANCY_CHANCE = pregnancy_chance
			C2_PREGNANCY_CHANCE = pregnancy_chance
			STRESS_EFFECTS = yes
			DRAMA = no
		}
	}

	after = {
		# trigger_event = {
		# 	on_action = regula_orgy_petitions
		# 	days = 3
		# }
		scope:activity = {
			every_participant = { # Strips clothes, removes STIs.
				add_character_flag = {
					flag = is_naked
					days = 7
				}
				if = { # One event for the magister.
					limit = { root = scope:host }
					trigger_event = {
						id = regula_orgy.1014
					}
				}
				else = { # Another for the slaves.
					trigger_event = {
						id = regula_orgy.1020
					}
				}
			}
		}
	}
}

scripted_trigger regula_orgy_1014_can_have_sex_trigger = {
	is_adult = yes
	NOR = {
		has_sexuality = asexual
		has_trait = celibate
	}
}

scripted_trigger regula_orgy_1014_sex_partner_trigger = {
	regula_orgy_1014_can_have_sex_trigger = yes
	NOT = { this = root }
	is_ai = yes
	NOT = { this = scope:deviant }
	save_temporary_scope_as = seduction_target
	# It's an orgy, anything goes.
	# matching_gender_and_sexuality_trigger = { CHARACTER_1 = scope:seduction_target CHARACTER_2 = root }
}

regula_orgy.1014 = {
	type = character_event
	title = regula_orgy.1014.t
	desc = regula_orgy.1014.desc

	theme = seduce_scheme
	override_background = {
		event_background = regula_orgy
	}
	# left_portrait = scope:left_portrait

	right_portrait = {
		character = scope:first_orgy_partner
		animation = personality_content
	}
	lower_left_portrait = scope:lower_left_portrait
	lower_center_portrait = scope:lower_center_portrait
	lower_right_portrait = scope:lower_right_portrait

	trigger = {

	}

	immediate = {

		###What is available to do?###
		scope:activity = {
			#Talk to new guest
			if = {
				limit = { root = scope:host }
				scope:activity = {
					random_participant = {
						limit = { has_character_flag = regula_orgy_new_guest }
						save_scope_as = new_guest
					}
				}
			}

			#Deviant
			random_participant = {
				limit = {
					has_trait = deviant
					NOR = {
						trigger_if = {
							limit = { exists = scope:new_guest }
							this = scope:new_guest
						}
						this = root
					}
				}
				save_scope_as = deviant
			}

			#Random sex partner
			random_participant = {
				limit = {
					regula_orgy_1014_sex_partner_trigger = yes
					save_temporary_scope_as = sex_partner_check #Saved for weight modifier
					NOT = { has_character_flag = regula_orgy_new_guest }
				}
				weight = {
					base = 10
					modifier = {
						has_trait = seducer
						add = 10
					}
					modifier = {
						has_trait = lustful
						add = 10
					}
					modifier = {
						has_trait = beauty_good
						add = 10
					}
					modifier = {
						has_relation_potential_lover = root
						add = 10
					}
					incest_acceptance_modifier = {
						TARGET = scope:sex_partner_check
						SEDUCER = root
					}
				}
				save_scope_as = sex_partner
			}

			#Set portraits
			if = {
				limit = {
					exists = scope:deviant
					exists = scope:sex_partner
					exists = scope:new_guest
				}
				scope:deviant = { save_scope_as = lower_left_portrait }
				scope:sex_partner = { save_scope_as = lower_center_portrait }
				scope:new_guest = { save_scope_as = lower_right_portrait }
			}
			else_if = {
				limit = {
					exists = scope:deviant
					exists = scope:sex_partner
				}
				scope:deviant = { save_scope_as = lower_left_portrait }
				scope:sex_partner = { save_scope_as = lower_right_portrait }
			}
			else_if = {
				limit = {
					exists = scope:deviant
					exists = scope:new_guest
				}
				scope:deviant = { save_scope_as = lower_left_portrait }
				scope:new_guest = { save_scope_as = lower_right_portrait }
			}
			else_if = {
				limit = {
					exists = scope:sex_partner
					exists = scope:new_guest
				}
				scope:sex_partner = { save_scope_as = lower_left_portrait }
				scope:new_guest = { save_scope_as = lower_right_portrait }
			}
			else_if = {
				limit = { exists = scope:deviant }
				scope:deviant = { save_scope_as = lower_center_portrait }
			}
			else_if = {
				limit = { exists = scope:sex_partner }
				scope:sex_partner = { save_scope_as = lower_center_portrait }
			}
			else_if = {
				limit = { exists = scope:new_guest }
				scope:new_guest = { save_scope_as = lower_center_portrait }
			}
			else = {
				save_scope_as = lower_center_portrait
			}
		}
	}

	###WHAT DO I WANT TO DO?###

	#Sex with random participant
	option = {
		trigger = {
			exists = scope:sex_partner
		}
		name = regula_orgy.1014.a
		custom_tooltip = regula_orgy.1014.a.tt

		show_as_tooltip = {
			scope:sex_partner = {
				if = {
					limit = {
						NOT = { has_trait = lustful }
					}
					add_trait = lustful
				}
			}
		}

		trigger_event = {
			id = regula_orgy.1015
			days = 1
		}

		hidden_effect = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = scope:host
				CHARACTER_2 = scope:sex_partner
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = no
			}
		}

		stress_impact = {
			chaste = medium_stress_impact_gain
			shy = minor_stress_impact_gain
			rakish = minor_stress_impact_loss
		}
	}

	#Learn from a deviant
	option = {
		trigger = {
			exists = scope:deviant
		}
		name = regula_orgy.1014.b
		highlight_portrait = scope:deviant

		if = {
			limit = { NOT = { has_trait = deviant } }
			random_list = {
				40 = {
					desc = regula_orgy.1014.b.knowledge
					send_interface_toast = {
						title = regula_orgy.1014.b.knowledge
						left_icon = scope:deviant
						add_trait = deviant
						add_piety = 100
					}
				}
				60 = {
					desc = regula_orgy.1014.b.inspiration
					send_interface_toast = {
						title = regula_orgy.1014.b.inspiration
						left_icon = scope:deviant
						add_character_modifier = {
							modifier = seeker_of_knowledge
							years = 5
						}
						add_piety = 100
					}
				}
			}
		}
		else = {
			add_character_modifier = {
				modifier = seeker_of_knowledge
				years = 5
			}
			add_piety = 100
		}

		hidden_effect = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = scope:deviant
				CHARACTER_2 = scope:sex_partner
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = no
			}
		}
		trigger_event = {
			id = regula_orgy.1016
			days = 1
		}

		stress_impact = {
			lazy = minor_stress_impact_gain
		}
	}

	#Fuck the new guest
	option = {
		trigger = {
			exists = scope:new_guest
		}
		name = regula_orgy.1014.c
		highlight_portrait = scope:new_guest

		random_list = {
			50 = { #Bring them directly into the harem, with minimal bonuses.
				desc = regula_orgy.1014.c.minor
				compatibility_modifier = {
					who = root
					compatibility_target = scope:new_guest
					multiplier = 3
					max = 50
					min = -30
				}
				send_interface_toast = {
					title = regula_orgy.1014.c.minor
					left_icon = scope:new_guest
					had_sex_with_effect = { CHARACTER = scope:new_guest PREGNANCY_CHANCE = 50 }
					scope:new_guest = {
						if= {
							limit = { NOT = { has_trait = lustful } }
							add_trait = lustful
						}
					}
					recruit_courtier = scope:new_guest
				}
			}
			35 = { #Bring them into the harem, with larger bonuses.
				desc = regula_orgy.1014.c.major
				compatibility_modifier = {
					who = root
					compatibility_target = scope:new_guest
					multiplier = 2
					max = 35
					min = -35
				}
				send_interface_toast = {
					title = regula_orgy.1014.c.major
					left_icon = scope:new_guest
					set_relation_lover = scope:new_guest
					carn_had_sex_with_effect = {
						CHARACTER_1 = scope:host
						CHARACTER_2 = scope:new_guest
						C1_PREGNANCY_CHANCE = pregnancy_chance
						C2_PREGNANCY_CHANCE = pregnancy_chance
						STRESS_EFFECTS = yes
						DRAMA = no
					}
					recruit_courtier = scope:new_guest
					scope:new_guest = {
						if= {
							limit = { NOT = { has_trait = lustful } }
							add_trait = lustful
						}
						if= {
							limit = { NOT = { has_trait = fecund }  }
							add_trait = fecund
						}
					}
				}
			}
		}
		hidden_effect = {
			carn_had_sex_with_effect = {
				CHARACTER_1 = scope:host
				CHARACTER_2 = scope:new_guest
				C1_PREGNANCY_CHANCE = pregnancy_chance
				C2_PREGNANCY_CHANCE = pregnancy_chance
				STRESS_EFFECTS = yes
				DRAMA = no
			}
		}
		trigger_event = {
			id = regula_orgy.1017
			days = 1
		}

	}

	#Relax and just watch
	option = {
		name = regula_orgy.1014.f
		trigger = {
			calc_true_if = {  # Will add extra options later.
				amount <= 3
				exists = scope:deviant
				exists = scope:sex_partner
				exists = scope:new_guest
			}
		}
		stress_impact = {
			base = medium_stress_loss
			gregarious = minor_stress_impact_loss
			lustful = medium_stress_impact_loss
			deviant = medium_stress_impact_loss
		}
		# add_piety = 250  # If specific benefits are added to the other options this can be re-enabled.
	}
}

# Regular sex
regula_orgy.1015 = {
	type = character_event
	title = regula_orgy.1015.t
	desc = regula_orgy.1015.desc
	theme = seduce_scheme
	left_portrait = {
		character = scope:sex_partner
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_content
	}

	option = {
		name = regula_orgy.1015.a
		scope:sex_partner = {
			if = {
				limit = {
					NOT = { has_trait = lustful }
				}
				add_trait = lustful
			}
		}
	}
}

# Deviant event
regula_orgy.1016 = {
	type = character_event
	title = regula_orgy.1016.t
	desc = regula_orgy.1016.desc
	theme = seduce_scheme
	override_background = {
		event_background = regula_cell
	}

	left_portrait = {
		character = scope:deviant
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = scheme
	}
	right_portrait = {
		character = scope:sex_partner
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = shame
	}

	option = {
		name = regula_orgy.1016.a
		scope:sex_partner = {
			if = {
				limit = { NOT = { has_trait = lustful } }
				add_trait = lustful
			}
		}
		regula_bdsm_session_effect = {
			SUBMISSIVE = scope:sex_partner
			DOMINANT = root
		}
	}
}

# New guest induction
regula_orgy.1017 = {
	type = character_event
	title = regula_orgy.1017.t
	desc = {
		desc = regula_orgy.1017.start.desc
	}

	theme = seduce_scheme

	left_portrait = {
		character = scope:new_guest
		outfit_tags = { no_cloak no_hat no_pants no_clothes }
		animation = personality_content
	}

	option = {
		name = regula_orgy.1017.a

	}
}

# Event for the participants. Filler for the moment.
regula_orgy.1020 = {
	type = character_event
	title = regula_orgy.1020.t
	desc = regula_orgy.1020.desc
	theme = regula_theme

	option = {
		name = regula_orgy.1020.a

	}
	# option = {
	# 	name = regula_orgy.1020.b
	# }
	# option = {
	# 	name = regula_orgy.1020.c
	# }
}

#End for host
regula_orgy.1098 = {
	type = character_event
	title = regula_orgy.1098.t
	desc = {
		desc = regula_orgy.1098.start.desc
		desc = regula_orgy.1098.end.desc
	}
	theme = regula_theme
	override_background = {
		event_background = regula_orgy
	}
	left_portrait = root

	trigger = { exists = scope:activity }

	immediate = {
		capital_province = { save_scope_as = background_wilderness_scope }
	}

	option = { #Increase health
		name = regula_orgy.1098.a
		add_character_modifier = {
			modifier = regula_orgy_health
			months = 30
		}
		hidden_effect = {
			scope:activity = {
				every_participant = {
					limit = { NOT = { this = root } }
					add_character_modifier = {
						modifier = regula_orgy_health_vassal
						months = 30
					}
				}
			}
		}
	}

	option = { # Lifestyle boost for all
		name = regula_orgy.1098.b
		add_character_modifier = {
			modifier = regula_orgy_lifestyle
			months = 30
		}
		if = {
			limit = { highest_skill = diplomacy }
			add_diplomacy_lifestyle_xp = 250
		}
		else_if = {
			limit = { highest_skill = martial }
			add_martial_lifestyle_xp = 250
		}
		else_if = {
			limit = { highest_skill = stewardship }
			add_stewardship_lifestyle_xp = 250
		}
		else_if = {
			limit = { highest_skill = intrigue }
			add_intrigue_lifestyle_xp = 250
		}
		else_if = {
			limit = { highest_skill = learning }
			add_learning_lifestyle_xp = 250
		}
		hidden_effect = {
			scope:activity = {
				every_participant = {
					limit = { NOT = { this = root } }
					add_character_modifier = {
						modifier = regula_orgy_lifestyle_vassal
						months = 30
					}
					add_stewardship_lifestyle_perk_points = 1
					add_martial_lifestyle_perk_points = 1
				}
			}
		}
	}

	option = { #Passive piety gain (deepen the connection to the book)
		name = regula_orgy.1098.c

		add_character_modifier = {
			modifier = regula_orgy_piety
			months = 30
		}
		hidden_effect = {
			scope:activity = {
				every_participant = {
					limit = { NOT = { this = root } }
					add_character_modifier = {
						modifier = regula_orgy_piety_vassal
						months = 30
					}
				}
			}
		}
	}

	after = {
		scope:activity = {
			every_participant = {
				limit = { NOT = { this = root } }
				trigger_event = regula_orgy.1099
			}
			complete_activity = yes
		}
	}
}

#End for guest
regula_orgy.1099 = {
	type = character_event
	title = regula_orgy.1098.t
	desc = {
		desc = regula_orgy.1099.start.desc
		desc = regula_orgy.1098.end.desc
	}
	theme = regula_theme
	override_background = {
		event_background = regula_orgy
	}
	left_portrait = root

	option = {
		name = regula_orgy.1098.a
		custom_tooltip = regula_orgy.1099.tt
	}
}


code:
namespace = regula_faction_demand

# Servitude Faction Demand
regula_faction_demand.0001 = {
	type = letter_event
	sender = scope:faction_leader
	opening = {
		desc = "REGULA_FACTION_DEMAND_SERVITUDE"
	}
	desc = "REGULA_FACTION_DEMAND_SERVITUDE_DESC"

	trigger = {
		exists = scope:faction # May have ceased to exist by the time this triggers
	}

	option = {
		name = "FACTION_DEMAND_ACCEPT"

		root = {
			save_scope_as = faction_target
			add_dread = medium_dread_loss
		}

		create_title_and_vassal_change = {
			type = swear_fealty
			save_scope_as = change
			add_claim_on_loss = no
		}
		scope:faction = {
			every_faction_member = {
				change_liege = {
					liege = global_var:magister_character
					CHANGE = scope:change
				}
				trigger_event = faction_demand.0002

			}
		}
		resolve_title_and_vassal_change = scope:change
		# Iterate the servitude war counter
		change_global_variable = {
			name = regula_servitude_war_tally
			add = 1
		}
		global_var:magister_character = {
			send_interface_message = {  # Let the MC know the war is won.
			type = event_war_good
			title = regula_servitude_faction_victory_notification.t
			desc = regula_servitude_faction_victory_notification_desc
			right_icon = scope:attacker
			left_icon = scope:defender
			}
			add_prestige = major_prestige_value
		}

		add_prestige = {
			value = medium_prestige_value
			multiply = -1
		}

		ai_chance = {
			base = 1
			modifier = {
				add = 99
				scope:faction = { faction_power >= 100 }
			}
			modifier = {
				add = 50
				scope:faction = { faction_power >= 125 }
			}
			modifier = {
				add = 50
				scope:faction = { faction_power >= 150 }
			}
			modifier = {
				add = 50
				scope:faction = { faction_power >= 200 }
			}
			modifier = {
				factor = 0.1
				any_ally = {
					NOR = {
						target_is_liege_or_above = root
						target_is_vassal_or_below = root
					}
					max_military_strength > root.max_military_strength
				}
			}
			compare_modifier = {
				value = debt_level
				multiplier = 25
			}
		}
	}

	option = {
		name = "FACTION_DEMAND_REFUSE"

		show_as_tooltip = {
			scope:faction = {
				faction_start_war = {}
			}
		}

		root = {
			save_scope_as = faction_target
		}

		scope:faction_leader = {
			trigger_event = regula_faction_demand.0003
		}

		ai_chance = {
			base = 100
			ai_value_modifier = {
				ai_boldness = 4.0
			}
			modifier = {
				add = 50
				scope:faction = { faction_power < 80 }
			}
			modifier = {
				add = 100
				scope:faction = { faction_power < 60 }
			}
			modifier = {
				add = 1000
				scope:faction = { faction_power < 40 }
			}
			compare_modifier = {
				value = debt_level
				multiplier = -25
			}
		}
	}
}

# Independence Faction Demand Accepted
regula_faction_demand.0002 = {
	type = letter_event
	sender = scope:faction_target
	opening = {
		desc = "FACTION_DEMAND_INDEPENDENCE_ACCEPTED"
	}
	desc = "FACTION_DEMAND_INDEPENDENCE_ACCEPTED_DESC"

	option = {
		name = "FACTION_DEMAND_ACCEPTED_OPT"
		custom_tooltip = faction_demand.0002.tt
	}
}

# Independence Faction Demand Refused
regula_faction_demand.0003 = {
	type = letter_event
	sender = scope:faction_target
	opening = {
		desc = "FACTION_DEMAND_INDEPENDENCE_REFUSED"
	}
	desc = "FACTION_DEMAND_INDEPENDENCE_REFUSED_DESC"

	option = {
		name = "FACTION_DEMAND_REFUSED_OPT"
		scope:faction = {
			faction_start_war = {}

			every_faction_member = {
				limit = { NOT = { this = scope:faction.faction_leader } }
				trigger_event = regula_faction_demand.0004
			}
		}
	}
}

# Independence Faction Demand Refused Member Notice
regula_faction_demand.0004 = {
	type = letter_event
	sender = scope:faction_target
	opening = {
		desc = "FACTION_DEMAND_INDEPENDENCE_REFUSED"
	}
	desc = "FACTION_DEMAND_INDEPENDENCE_REFUSED_DESC"

	option = {
		name = "FACTION_DEMAND_REFUSED_OPT"
	}
}

# Independence Faction Demand Send Notice
regula_faction_demand.0005 = {
	type = letter_event
	sender = scope:faction_leader
	opening = {
		desc = "FACTION_DEMAND_INDEPENDENCE_SEND_DEMAND_NOTIFICATION"
	}
	desc = "FACTION_DEMAND_INDEPENDENCE_SEND_DEMAND_NOTIFICATION_DESC"

	option = {
		name = "FACTION_DEMAND_SEND_DEMAND_NOTIFICATION_OPT"
	}
}

# Independence Faction Demand Send Notice to Magister
regula_faction_demand.0006 = {
	type = letter_event
	sender = {
		character = scope:faction_leader
		animation = happiness
	}
	opening = {
		desc = "REGULA_FACTION_DEMAND_SERVITUDE_INFORM_MAGISTER_NOTIFICATION"
	}
	desc = "REGULA_FACTION_DEMAND_SERVITUDE_INFORM_MAGISTER_DESC"

	option = {
		name = "REGULA_FACTION_DEMAND_SERVITUDE_INFORM_MAGISTER_OPT"
	}
}


code:
namespace = regula_interaction_event

#############################
# Regula Interaction Events #
######################################################
# 0001: Titulum Novis
######################################################

# Title Revocation Accepted (Titulum Novis)
regula_interaction_event.0001 = {
	type = letter_event
	opening = {
		desc = char_interaction.0001.opening
	}
	desc = regula_interaction_event.0001.desc

	sender = scope:recipient

	immediate = {
		show_as_tooltip = { regula_titulum_novis_interaction_effect = yes }
	}

	option = {
		name = regula_interaction_event.0001.a
	}
}


code:
namespace = regula_mutare_corpus_event

#############################
# Regula Interaction Events #
######################################################
# 0001: Mutare Corpus
	# 0011-0005: Mental boosts
	# 0021-0015: Body boosts
	# 0031-0025: Sex boosts
######################################################

# Change Body (Mutare Corpus)
regula_mutare_corpus_event.0001 = {
	type = character_event
	title = regula_mutare_corpus_event.0001.t

	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 0 }}
				desc = regula_mutare_corpus_event.0001.desc_0
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 1 }}
				desc = regula_mutare_corpus_event.0001.desc_1
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 2 }}
				desc = regula_mutare_corpus_event.0001.desc_2
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 3 }}
				desc = regula_mutare_corpus_event.0001.desc_3
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 4 }}
				desc = regula_mutare_corpus_event.0001.desc_4
			}
			triggered_desc = {
				trigger = { global_var:magister_character = { piety_level = 5 }}
				desc = regula_mutare_corpus_event.0001.desc_5
			}
		}
	}

	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 = {
			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 # Take power for yourself. This is a refund so no experience gain!
		add_piety_no_experience = 300
		hidden_effect = {
			remove_interaction_cooldown = regula_mutare_corpus_interaction
		}
	}

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

# Mutare Corpus Mental boosts ############################################################################################################
# In order of
# Backfire		- Gives lunatic trait, and wound
# Bad			- Causes minor wound, repairs a single bad mental trait
# Good			- Fixes 1 mental flaws, increases education and intelligence trait, can give other good learning trait
# Great			- Fixes 2 mental flaws, increases education trait and congenital mental trait (can double increase), can give other good learning trait
# Fantastic		- Fixes 3 mental flaws, increases education and congential mental traits (can double/triple increase), gives at least one other good learning trait

# Mental - Backfire
regula_mutare_corpus_event.0011 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_bad
				title = regula_mutare_corpus_outcome_1.t
				desc = regula_mutare_corpus_mental_backfire.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Add random bad mental trait
					random_list = {
						1 = {
							trigger = { NOT = {has_trait = possessed_1} }
							add_trait = possessed_1
						}
						1 = {
							trigger = { NOT = {has_trait = depressed_1} }
							add_trait = depressed_1
						}
						1 = {
							trigger = { NOT = {has_trait = lunatic_1} }
							add_trait = lunatic_1
						}
					}
					# Add wound
					increase_wounds_effect = { REASON = treatment }
				}
			}
		}
	}
}

# Mental - Bad
regula_mutare_corpus_event.0012 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_bad
				title = regula_mutare_corpus_outcome_2.t
				desc = regula_mutare_corpus_mental_bad.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove bad mental trait
					regula_mutare_corpus_repair_mind_single_effect = yes
					# Add wound
					increase_wounds_no_death_effect = { REASON = treatment }
				}
			}
		}
	}
}

# Mental - Good
regula_mutare_corpus_event.0013 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_good
				title = regula_mutare_corpus_outcome_3.t
				desc = regula_mutare_corpus_mental_good.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove bad mental trait
					regula_mutare_corpus_repair_mind_single_effect = yes
					# Increase education
					rank_up_education_effect = yes
					# Make more intelligent
					regula_rank_up_intelligence_trait_effect = yes
					# 50% chance to get random other good mental triat
					random = {
						chance = 50
						regula_mutare_corpus_give_good_mental_trait_effect = yes
					}
				}
			}
		}
	}
}

# Mental - Great
regula_mutare_corpus_event.0014 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_good
				title = regula_mutare_corpus_outcome_4.t
				desc = regula_mutare_corpus_mental_great.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove 2 bad mental trait
					hidden_effect = {
						regula_mutare_corpus_repair_mind_single_effect = yes
					}
					regula_mutare_corpus_repair_mind_single_effect = yes

					# Increase education, 50% chance to increase by single, or double
					random_list = {
						50 = {
							rank_up_education_effect = yes
						}
						50 = {
							hidden_effect = {
								rank_up_education_effect = yes
							}
							rank_up_education_effect = yes
						}
					}

					# Same for congential intelligence
					random_list = {
						50 = {
							regula_rank_up_intelligence_trait_effect = yes
						}
						50 = {
							hidden_effect = {
								regula_rank_up_intelligence_trait_effect = yes
							}
							regula_rank_up_intelligence_trait_effect = yes
						}
					}

					# Give a random good mental trait
					regula_mutare_corpus_give_good_mental_trait_effect = yes
				}
			}
		}
	}
}

# Mental - Fantastic
regula_mutare_corpus_event.0015 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_good
				title = regula_mutare_corpus_outcome_5.t
				desc = regula_mutare_corpus_mental_fantastic.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove 3 bad mental trait
					hidden_effect = {
						regula_mutare_corpus_repair_mind_single_effect = yes
						regula_mutare_corpus_repair_mind_single_effect = yes
					}
					regula_mutare_corpus_repair_mind_single_effect = yes

					# Increase education, 20% chance to increase by single, 60% by double and 20% by triple
					random_list = {
						20 = {
							rank_up_education_effect = yes
						}
						60 = {
							hidden_effect = {
								rank_up_education_effect = yes
							}
							rank_up_education_effect = yes
						}
						20 = {
							hidden_effect = {
								rank_up_education_effect = yes
								rank_up_education_effect = yes
							}
							rank_up_education_effect = yes
						}
					}

					# Same for congential intelligence
					random_list = {
						20 = {
							regula_rank_up_intelligence_trait_effect = yes
						}
						60 = {
							hidden_effect = {
								regula_rank_up_intelligence_trait_effect = yes
							}
							regula_rank_up_intelligence_trait_effect = yes
						}
						20 = {
							hidden_effect = {
								regula_rank_up_intelligence_trait_effect = yes
								regula_rank_up_intelligence_trait_effect = yes
							}
							regula_rank_up_intelligence_trait_effect = yes
						}
					}

					# Give a random good mental trait
					regula_mutare_corpus_give_good_mental_trait_effect = yes
				}
			}
		}
	}
}

############################################################################################################################################
# Mutare Corpus Physical boosts ############################################################################################################
# In order of
# Backfire		- Gives physical defect trait, and normal wound
# Bad			- Causes minor wound, fixes minor physical defects
# Good			- Fixes physical defects, increases congenital physical trait, may give bonus physical trait, small health boost
# Great			- Fixes physical defects, increases congenital physical trait, gives bonus physical trait, medium health boost
# Fantastic		- Fixes physical defects, increases congenital physical trait, gives bonus physical trait, large health boost

# Physical - Backfire
regula_mutare_corpus_event.0021 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_bad
				title = regula_mutare_corpus_outcome_1.t
				desc = regula_mutare_corpus_physical_backfire.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Add random bad physcal trait
					# Add chances here so that we weight towards the less bad physical traits
					random_list = {
						100 = {
							trigger = { NOT = {has_trait = scarred} }
							add_trait = scarred
						}
						50 = {
							trigger = { NOT = {has_trait = one_eyed} }
							add_trait = one_eyed
						}
						50 = {
							trigger = { NOT = {has_trait = one_legged} }
							add_trait = one_legged
						}
						30 = {
							trigger = { NOT = {has_trait = spindly} }
							add_trait = spindly
						}
						30 = {
							trigger = { NOT = {has_trait = wheezing} }
							add_trait = wheezing
						}
						20 = {
							trigger = { NOT = {has_trait = blind} }
							add_trait = blind
						}
						20 = {
							trigger = { NOT = {has_trait = hunchbacked} }
							add_trait = hunchbacked
						}
						10 = {
							trigger = { NOT = {has_trait = disfigured} }
							add_trait = disfigured
						}
						1 = {
							trigger = { NOT = {has_trait = maimed} }
							add_trait = maimed # This will most likely kill, ouch!
						}
					}

					# Add wound
					increase_wounds_effect = { REASON = treatment }
				}
			}
		}
	}
}

# Physical - Bad
regula_mutare_corpus_event.0022 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_bad
				title = regula_mutare_corpus_outcome_2.t
				desc = regula_mutare_corpus_physical_bad.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove bad physical traits
					regula_mutare_corpus_repair_physical_single_effect = yes
					# Add wound
					increase_wounds_no_death_effect = { REASON = treatment }
				}
			}
		}
	}
}

# Physical - Good
regula_mutare_corpus_event.0023 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_good
				title = regula_mutare_corpus_outcome_3.t
				desc = regula_mutare_corpus_physical_good.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove bad physical trait
					regula_mutare_corpus_repair_physical_single_effect = yes
					# Make stronger
					regula_rank_up_physical_trait_effect = yes
					# Health boost
					add_character_modifier = {
						modifier = regula_mutare_corpus_small_boost
						years = 3
					}
					# 50% chance to get random other good physical triat
					random = {
						chance = 50
						regula_mutare_corpus_give_good_physical_trait_effect = yes
					}
				}
			}
		}
	}
}

# Physical - Great
regula_mutare_corpus_event.0024 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_good
				title = regula_mutare_corpus_outcome_4.t
				desc = regula_mutare_corpus_physical_great.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove 2 bad physical trait
					hidden_effect = {
						regula_mutare_corpus_repair_physical_single_effect = yes
					}
					regula_mutare_corpus_repair_physical_single_effect = yes
					# Increase physique once or twice
					random_list = {
						50 = {
							regula_rank_up_physical_trait_effect = yes
						}
						50 = {
							hidden_effect = {
								regula_rank_up_physical_trait_effect = yes
							}
							regula_rank_up_physical_trait_effect = yes
						}
					}
					# Health boost
					add_character_modifier = {
						modifier = regula_mutare_corpus_medium_boost
						years = 3
					}
					# Give a random good physical trait
					regula_mutare_corpus_give_good_physical_trait_effect = yes
				}
			}
		}
	}
}

# Physical - Fantastic
regula_mutare_corpus_event.0025 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_good
				title = regula_mutare_corpus_outcome_5.t
				desc = regula_mutare_corpus_physical_fantastic.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove 3 bad physical trait
					hidden_effect = {
						regula_mutare_corpus_repair_physical_single_effect = yes
						regula_mutare_corpus_repair_physical_single_effect = yes
					}
					regula_mutare_corpus_repair_physical_single_effect = yes
					# Increase Physqiue, 20% chance to increase by single, 60% by double and 20% by triple
					random_list = {
						20 = {
							regula_rank_up_physical_trait_effect = yes
						}
						60 = {
							hidden_effect = {
								regula_rank_up_physical_trait_effect = yes
							}
							regula_rank_up_physical_trait_effect = yes
						}
						20 = {
							hidden_effect = {
								regula_rank_up_physical_trait_effect = yes
								regula_rank_up_physical_trait_effect = yes
							}
							regula_rank_up_physical_trait_effect = yes
						}
					}
					# Health boost
					add_character_modifier = {
						modifier = regula_mutare_corpus_large_boost
						years = 3
					}
					# Give a random good physical trait
					regula_mutare_corpus_give_good_physical_trait_effect = yes
				}
			}
		}
	}
}

##########################################################################################################################################
# Mutare Corpus Sexual boosts ############################################################################################################
# In order of
# Backfire		- Gives random disease, and wound
# Bad			- Causes minor wound, cures a disease
# Good			- Cures a random disease, increases beauty congential trait, can give random sexual trait / make lustful, and impregnates with child
# Great			- Cures 2 diseases, increases beauty congential trait, can give random sexual trait / make lustful, and impregnates with twins
# Fantastic		- Cures 3 diseases, increases beauty congential trait, can give random sexual trait / make lustful, and impregnates with triplets

# Sexual - Backfire
regula_mutare_corpus_event.0031 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_bad
				title = regula_mutare_corpus_outcome_5.t
				desc = regula_mutare_corpus_sexual_backfire.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Add random bad disease
					# Weight these as well, so that the much worse ones arent as common
					random_list = {
						100 = {
							trigger = { NOT = {has_trait = lovers_pox} }
							add_trait = lovers_pox
						}
						100 = {
							trigger = { NOT = {has_trait = ill} }
							add_trait = ill
						}

						50 = {
							trigger = { NOT = {has_trait = gout_ridden} }
							add_trait = gout_ridden
						}
						50 = {
							trigger = { NOT = {has_trait = consumption} }
							add_trait = consumption
						}
						30 = {
							trigger = { NOT = {has_trait = typhus} }
							add_trait = typhus
						}
						5 = {
							trigger = { NOT = {has_trait = early_great_pox} }
							add_trait = early_great_pox
						}
						5 = {
							trigger = { NOT = {has_trait = cancer} }
							add_trait = cancer
						}
						5 = {
							trigger = { NOT = {has_trait = bubonic_plague} }
							add_trait = bubonic_plague
						}

					}
					# Add wound
					increase_wounds_effect = { REASON = treatment }
				}
			}
		}
	}
}

# Sexual - Bad
regula_mutare_corpus_event.0032 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_bad
				title = regula_mutare_corpus_outcome_2.t
				desc = regula_mutare_corpus_sexual_bad.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove a bad disease
					regula_mutare_corpus_cure_disease_single_effect = yes
					# Add wound
					increase_wounds_no_death_effect = { REASON = treatment }
				}
			}
		}
	}
}

# Sexual - Good
regula_mutare_corpus_event.0033 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_good
				title = regula_mutare_corpus_outcome_3.t
				desc = regula_mutare_corpus_sexual_good.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove a bad disease
					regula_mutare_corpus_cure_disease_single_effect = yes
					# Increase beauty trait
					regula_rank_up_beauty_trait_effect = yes
					# Chance to give random sexual trait
					random_list = {
						100 = {
							trigger = { NOT = { has_trait = lustful } }
							if = {
								limit = {has_trait = chaste }
								remove_trait = chaste
							}
							add_trait = lustful
						}
						50 = {
							trigger = { NOT = { has_trait = fecund } }
							add_trait = fecund
						}
						30 = {
							trigger = { NOT = { has_trait = deviant } }
							add_trait = deviant
						}
						10 = {
							trigger = { NOT = { has_trait = pure_blooded } }
							add_trait = pure_blooded
						}
					}

					# If already pregant, make child "child of the book" (25% chance here)
					# Otherwise make pregant
					if = {
						limit = {
							is_pregnant = yes
						}
						random = {
							chance = 25
							scope:recipient = {
								trigger_event = regula_paelex_event.1040
							}
						}
					}
					else = {
						# Impregnate with single kid
						make_pregnant = {
							father = global_var:magister_character
							number_of_children = 1
						}
					}

				}
			}
		}
	}
}

# Sexual - Great
regula_mutare_corpus_event.0034 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_good
				title = regula_mutare_corpus_outcome_4.t
				desc = regula_mutare_corpus_sexual_great.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove 2 bad diseases
					hidden_effect = {
						regula_mutare_corpus_cure_disease_single_effect = yes
					}
					regula_mutare_corpus_cure_disease_single_effect = yes
					# Increase physique once or twice
					random_list = {
						50 = {
							regula_rank_up_beauty_trait_effect = yes
						}
						50 = {
							hidden_effect = {
								regula_rank_up_beauty_trait_effect = yes
							}
							regula_rank_up_beauty_trait_effect = yes
						}
					}
					# Give random sexual trait
					random_list = {
						100 = {
							trigger = { NOT = { has_trait = lustful } }
							if = {
								limit = {has_trait = chaste }
								remove_trait = chaste
							}
							add_trait = lustful
						}
						50 = {
							trigger = { NOT = { has_trait = fecund } }
							add_trait = fecund
						}
						30 = {
							trigger = { NOT = { has_trait = deviant } }
							add_trait = deviant
						}
						10 = {
							trigger = { NOT = { has_trait = pure_blooded } }
							add_trait = pure_blooded
						}
					}
					# If already pregant, make child "child of the book" (50% chance here)
					# Otherwise make pregant
					if = {
						limit = {
							is_pregnant = yes
						}
						random = {
							chance = 50
							scope:recipient = {
								trigger_event = regula_paelex_event.1040
							}
						}
					}
					else = {
						# Impregnate with twins
						make_pregnant = {
							father = global_var:magister_character
							number_of_children = 2
						}
					}
				}
			}
		}
	}
}

# Sexual - Fantastic
regula_mutare_corpus_event.0035 = {
	hidden = yes
	type = character_event

	immediate = {
		scope:actor = {
			send_interface_message = {
				type = event_spouse_task_good
				title = regula_mutare_corpus_outcome_5.t
				desc = regula_mutare_corpus_sexual_fantastic.desc
				right_icon = scope:recipient

				# Do stuff here
				scope:recipient = {
					# Remove 3 diseases
					hidden_effect = {
						regula_mutare_corpus_cure_disease_single_effect = yes
						regula_mutare_corpus_cure_disease_single_effect = yes
					}
					regula_mutare_corpus_cure_disease_single_effect = yes
					# Increase Beauty, 20% chance to increase by single, 60% by double and 20% by triple
					random_list = {
						20 = {
							regula_rank_up_beauty_trait_effect = yes
						}
						60 = {
							hidden_effect = {
								regula_rank_up_beauty_trait_effect = yes
							}
							regula_rank_up_beauty_trait_effect = yes
						}
						20 = {
							hidden_effect = {
								regula_rank_up_beauty_trait_effect = yes
								regula_rank_up_beauty_trait_effect = yes
							}
							regula_rank_up_beauty_trait_effect = yes
						}
					}
					# Give random sexual trait
					random_list = {
						100 = {
							trigger = { NOT = { has_trait = lustful } }
							if = {
								limit = {has_trait = chaste }
								remove_trait = chaste
							}
							add_trait = lustful
						}
						50 = {
							trigger = { NOT = { has_trait = fecund } }
							add_trait = fecund
						}
						30 = {
							trigger = { NOT = { has_trait = deviant } }
							add_trait = deviant
						}
						10 = {
							trigger = { NOT = { has_trait = pure_blooded } }
							add_trait = pure_blooded
						}
					}
					# If already pregant, make child "child of the book" (100% chance here)
					# Otherwise make pregant
					if = {
						limit = {
							is_pregnant = yes
						}
						scope:recipient = {
							trigger_event = regula_paelex_event.1040
						}
					}
					else = {
						# Impregnate with triplets
						make_pregnant = {
							father = global_var:magister_character
							number_of_children = 3
						}
					}
				}
			}
		}
	}
}


code:
namespace = regula_bloodline

# 0000-0999: Eligibility events
# 1000-1999: Magister events
# 2000-2999: Generic events

######################################################
# ELIGIBILITY EVENTS
# 0000-0999
######################################################

regula_bloodline.0001 = { # Potestas non Transfunde Queen record.
	type = character_event
	hidden = yes

	trigger = {
		NOT = { global_var:regula_potestas_queen_bloodline_active = yes }
		# Using either single life goal or cumulative goal
		OR = {
			AND = {
				has_game_rule = regula_bloodline_tally_goals_single_life
				global_var:regula_potestas_queen_tally >= regula_potestas_queen_tally_goal
			}
			AND = {
				has_game_rule = regula_bloodline_tally_goals_cumulative
				global_var:regula_potestas_queen_tally >= regula_potestas_queen_tally_goal_cumulative
			}
		}
	}

	immediate = {
		set_global_variable = {
			name = last_magister_character
			value = global_var:magister_character
		}
		global_var:magister_character.primary_heir = {
			trigger_event = {
				id = regula_bloodline.1001
				days = 35
			}
		}
	}
}

regula_bloodline.0002 = { # Servitude War record.
	type = character_event
	hidden = yes

	trigger = {
		NOT = { global_var:regula_servitude_war_bloodline_active = yes }
		# Using either single life goal or cumulative goal
		OR = {
			AND = {
				has_game_rule = regula_bloodline_tally_goals_single_life
				global_var:regula_servitude_war_tally >= regula_servitude_war_tally_goal
			}
			AND = {
				has_game_rule = regula_bloodline_tally_goals_cumulative
				global_var:regula_servitude_war_tally >= regula_servitude_war_tally_goal_cumulative
			}
		}
	}

	immediate = {
		set_global_variable = {
			name = last_magister_character
			value = global_var:magister_character
		}
		global_var:magister_character.primary_heir = {
			trigger_event = {
				id = regula_bloodline.1002
				days = 36
			}
		}
	}
}

regula_bloodline.0003 = { # Domination War record.
	type = character_event
	hidden = yes

	trigger = {
		NOT = { global_var:regula_domination_war_bloodline_active = yes }
		# Using either single life goal or cumulative goal
		OR = {
			AND = {
				has_game_rule = regula_bloodline_tally_goals_single_life
				global_var:regula_domination_war_tally >= regula_domination_war_tally_goal
			}
			AND = {
				has_game_rule = regula_bloodline_tally_goals_cumulative
				global_var:regula_domination_war_tally >= regula_domination_war_tally_goal_cumulative
			}
		}
	}

	immediate = {
		set_global_variable = {
			name = last_magister_character
			value = global_var:magister_character
		}
		global_var:magister_character.primary_heir = {
			trigger_event = {
				id = regula_bloodline.1003
				days = 37
			}
		}
	}
}

regula_bloodline.0004 = { # Contubernalis record.
	type = character_event
	hidden = yes

	trigger = {
		NOT = { global_var:regula_contubernalis_bloodline_active = yes }
		# Using either single life goal or cumulative goal
		OR = {
			AND = {
				has_game_rule = regula_bloodline_tally_goals_single_life
				global_var:regula_contubernalis_tally >= regula_contubernalis_tally_goal
			}
			AND = {
				has_game_rule = regula_bloodline_tally_goals_cumulative
				global_var:regula_contubernalis_tally >= regula_contubernalis_tally_goal_cumulative
			}
		}
	}

	immediate = {
		set_global_variable = {
			name = last_magister_character
			value = global_var:magister_character
		}
		global_var:magister_character.primary_heir = {
			trigger_event = {
				id = regula_bloodline.1004
				days = 38
			}
		}
	}
}

regula_bloodline.0005 = { # Domitans Tribunal record.
	type = character_event
	hidden = yes

	trigger = {
		NOT = { global_var:regula_domitans_bloodline_active = yes }
		# Using either single life goal or cumulative goal
		OR = {
			AND = {
				has_game_rule = regula_bloodline_tally_goals_single_life
				global_var:regula_domitans_tally >= regula_domitans_tally_goal
			}
			AND = {
				has_game_rule = regula_bloodline_tally_goals_cumulative
				global_var:regula_domitans_tally >= regula_domitans_tally_goal_cumulative
			}
		}
	}

	immediate = {
		set_global_variable = {
			name = last_magister_character
			value = global_var:magister_character
		}
		global_var:magister_character.primary_heir = {
			trigger_event = {
				id = regula_bloodline.1005
				days = 39
			}
		}
	}
}

regula_bloodline.0006 = { # Fascinare record.
	type = character_event
	hidden = yes

	trigger = {
		NOT = { global_var:regula_fascinare_bloodline_active = yes }
		# Using either single life goal or cumulative goal
		OR = {
			AND = {
				has_game_rule = regula_bloodline_tally_goals_single_life
				global_var:regula_fascinare_tally >= regula_fascinare_tally_goal
			}
			AND = {
				has_game_rule = regula_bloodline_tally_goals_cumulative
				global_var:regula_fascinare_tally >= regula_fascinare_tally_goal_cumulative
			}
		}
	}

	immediate = {
		set_global_variable = {
			name = last_magister_character
			value = global_var:magister_character
		}
		global_var:magister_character.primary_heir = {
			trigger_event = {
				id = regula_bloodline.1006
				days = 40
			}
		}
	}
}

regula_bloodline.0007 = { # Obedience record.
	type = character_event
	hidden = yes

	trigger = {
		NOT = { global_var:regula_obedience_bloodline_active = yes }
		# Using either single life goal or cumulative goal
		OR = {
			AND = {
				has_game_rule = regula_bloodline_tally_goals_single_life
				global_var:regula_obedience_tally >= regula_obedience_tally_goal
			}
			AND = {
				has_game_rule = regula_bloodline_tally_goals_cumulative
				global_var:regula_obedience_tally >= regula_obedience_tally_goal_cumulative
			}
		}
	}

	immediate = {
		set_global_variable = {
			name = last_magister_character
			value = global_var:magister_character
		}
		global_var:magister_character.primary_heir = {
			trigger_event = {
				id = regula_bloodline.1007
				days = 41
			}
		}
	}
}

regula_bloodline.0021 = { # Pregnant lovers/spouses record. Called on pregnancy.
	type = character_event
	hidden = yes

	trigger = {
		is_married = yes
		OR = {
			root.primary_spouse = {
				NOT = { has_trait = regula_multitasker_bloodline }
				regula_num_pregnant_consorts_and_lovers >=3
			}
		}
	}

	immediate = {
		root.primary_spouse = {
			trigger_event = {
				id = regula_bloodline.2021
				days = 35
			}
		}
	}
}

regula_bloodline.0022 = { # Number of children record. Called on pregnancy.
	type = character_event
	hidden = yes

	trigger = {
		regula_num_children >= 6
	}

	immediate = {
		trigger_event = {
			id = regula_bloodline.2022
			days = 35
		}
	}
}

regula_bloodline.0023 = { # Twins adjustment for those with Bun in the Oven. Called on pregnancy.
	type = character_event
	hidden = yes

	trigger = {
		has_trait = regula_bun_bloodline
	}

	immediate = {
		random = {
			chance = 20
			set_num_pregnancy_children = 2
		}
		random = {
			chance = 10
			set_num_pregnancy_children = 3
		}
		random = {
			chance = 5
			set_num_pregnancy_children = 4
		}
	}
}

######################################################
# MAGISTER EVENTS
# 1000-1999
######################################################

regula_bloodline.1000 = { #Inheritance from grandparents
	type = character_event
	hidden = yes

	trigger = {
		any_close_family_member = {
			even_if_dead = yes
			has_trait_with_flag = regula_bloodline_magister
		}
	}

	immediate = {
		if = {
			limit = {
				NOT = { has_trait = regula_potestas_queen_bloodline }
				any_close_family_member = {
					has_trait = regula_potestas_queen_bloodline
				}
			}
			add_trait = regula_potestas_queen_bloodline
		}
		if = {
			limit = {
				NOT = { has_trait = regula_servitude_war_bloodline }
				any_close_family_member = {
					has_trait = regula_servitude_war_bloodline
				}
			}
			add_trait = regula_servitude_war_bloodline
		}
		if = {
			limit = {
				NOT = { has_trait = regula_domination_war_bloodline }
				any_close_family_member = {
					has_trait = regula_domination_war_bloodline
				}
			}
			add_trait = regula_domination_war_bloodline
		}
		if = {
			limit = {
				NOT = { has_trait = regula_contubernalis_bloodline }
				any_close_family_member = {
					has_trait = regula_contubernalis_bloodline
				}
			}
			add_trait = regula_contubernalis_bloodline
		}
		if = {
			limit = {
				NOT = { has_trait = regula_domitans_bloodline }
				any_close_family_member = {
					has_trait = regula_domitans_bloodline
				}
			}
			add_trait = regula_domitans_bloodline
		}
		if = {
			limit = {
				NOT = { has_trait = regula_fascinare_bloodline }
				any_close_family_member = {
					has_trait = regula_fascinare_bloodline
				}
			}
			add_trait = regula_fascinare_bloodline
		}
		if = {
			limit = {
				NOT = { has_trait = regula_obedience_bloodline }
				any_close_family_member = {
					has_trait = regula_obedience_bloodline
				}
			}
			add_trait = regula_obedience_bloodline
		}
	}
}

regula_bloodline.1001 = { # Potestas of Queens
	type = character_event
	title = regula_bloodline.1001.t
	desc = regula_bloodline.1001.desc

	theme = regula_theme
	override_background = {
		event_background = godless_shrine
	}
	right_portrait = {
		character = global_var:magister_character
		animation = personality_bold
	}
	lower_right_portrait = {
			character = global_var:last_magister_character
	}

	immediate = {
		global_var:last_magister_character = {
			regula_bloodline_dynasty_addition_effect = { BLOODLINE = regula_potestas_queen_bloodline }
			set_global_variable = {
				name = potestas_queen_bloodline_magister
				value = global_var:last_magister_character
			}
		}
	}

	option = { # Great!
		name = regula_bloodline.1001.a

		set_global_variable = {
			name = regula_potestas_queen_bloodline_active
			value = yes
		}
	}

	after = {
	}
}

regula_bloodline.1002 = { # Servitude War
	type = character_event
	title = regula_bloodline.1002.t
	desc = regula_bloodline.1002.desc

	theme = regula_theme
	override_background = {
		event_background = throne_room  # Town?
	}
	right_portrait = {
		character = global_var:magister_character
		animation = flirtation
	}
	lower_right_portrait = {
			character = global_var:last_magister_character
	}

	immediate = {
		global_var:last_magister_character = {
			regula_bloodline_dynasty_addition_effect = { BLOODLINE = regula_servitude_war_bloodline }
			set_global_variable = {
				name = servitude_war_bloodline_magister
				value = global_var:last_magister_character
			}
		}
	}

	option = { # Great!
		name = regula_bloodline.1002.a

		set_global_variable = {
			name = regula_servitude_war_bloodline_active
			value = yes
		}
	}

	after = {
	}
}

regula_bloodline.1003 = { # Domination War
	type = character_event
	title = regula_bloodline.1003.t
	desc = regula_bloodline.1003.desc

	theme = regula_theme
	override_background = {
		event_background = regula_bedchamber
	}
	right_portrait = {
		character = global_var:magister_character
		animation = personality_bold
	}
	lower_right_portrait = {
			character = global_var:last_magister_character
	}

	immediate = {
		global_var:last_magister_character = {
			regula_bloodline_dynasty_addition_effect = { BLOODLINE = regula_domination_war_bloodline }
			set_global_variable = {
				name = domination_war_bloodline_magister
				value = global_var:last_magister_character
			}
		}
	}

	option = { # Great!
		name = regula_bloodline.1003.a

		set_global_variable = {
			name = regula_domination_war_bloodline_active
			value = yes
		}
	}

	after = {
	}
}

regula_bloodline.1004 = { # Contubernalis
	type = character_event
	title = regula_bloodline.1004.t
	desc = regula_bloodline.1004.desc

	theme = regula_theme
	override_background = {
		event_background = physicians_study
	}
	right_portrait = {
		character = global_var:magister_character
		animation = disapproval
	}
	lower_right_portrait = {
			character = global_var:last_magister_character
	}

	immediate = {
		global_var:last_magister_character = {
			regula_bloodline_dynasty_addition_effect = { BLOODLINE = regula_contubernalis_bloodline }
			set_global_variable = {
				name = contubernalis_bloodline_magister
				value = global_var:last_magister_character
			}
		}
	}

	option = { # Great!
		name = regula_bloodline.1004.a

		set_global_variable = {
			name = regula_contubernalis_bloodline_active
			value = yes
		}
	}

	after = {
	}
}

regula_bloodline.1005 = { # Domitans Tribunal
	type = character_event
	title = regula_bloodline.1005.t
	desc = regula_bloodline.1005.desc

	theme = regula_theme
	override_background = {
		event_background = godless_shrine
	}
	right_portrait = {
		character = global_var:magister_character
		animation = personality_compassionate
	}
	lower_right_portrait = {
			character = global_var:last_magister_character
	}

	immediate = {
		global_var:last_magister_character = {
			regula_bloodline_dynasty_addition_effect = { BLOODLINE = regula_domitans_bloodline }
			set_global_variable = {
				name = domitans_bloodline_magister
				value = global_var:last_magister_character
			}
		}
	}

	option = { # Great!
		name = regula_bloodline.1005.a

		set_global_variable = {
			name = regula_domitans_bloodline_active
			value = yes
		}
	}

	after = {
	}
}

regula_bloodline.1006 = { # Fascinare
	type = character_event
	title = regula_bloodline.1006.t
	desc = regula_bloodline.1006.desc

	theme = regula_theme
	override_background = {
		event_background = sitting_room  # Town?
	}
	right_portrait = {
		character = global_var:magister_character
		animation = personality_compassionate
	}
	lower_right_portrait = {
			character = global_var:last_magister_character
	}

	immediate = {
		global_var:last_magister_character = {
			regula_bloodline_dynasty_addition_effect = { BLOODLINE = regula_fascinare_bloodline }
			set_global_variable = {
				name = fascinare_bloodline_magister
				value = global_var:last_magister_character
			}
		}
	}

	option = { # Great!
		name = regula_bloodline.1006.a

		set_global_variable = {
			name = regula_fascinare_bloodline_active
			value = yes
		}

	}

	after = {
	}
}

regula_bloodline.1007 = { # Obedience
	type = character_event
	title = regula_bloodline.1007.t
	desc = regula_bloodline.1007.desc

	theme = regula_theme
	override_background = {
		event_background = sitting_room  # Town?
	}
	right_portrait = {
		character = global_var:magister_character
		animation = personality_compassionate
	}
	lower_right_portrait = {
			character = global_var:last_magister_character
	}

	immediate = {
		global_var:last_magister_character = {
			regula_bloodline_dynasty_addition_effect = { BLOODLINE = regula_obedience_bloodline }
			set_global_variable = {
				name = obedience_bloodline_magister
				value = global_var:last_magister_character
			}
		}
	}

	option = { # Great!
		name = regula_bloodline.1007.a

		set_global_variable = {
			name = regula_obedience_bloodline_active
			value = yes
		}

	}
}

######################################################
# GENERIC EVENTS
# 2000-2999
######################################################

regula_bloodline.2021 = { # Multitasker
	type = character_event
	hidden = yes

	immediate = {
		regula_bloodline_addition_effect = { BLOODLINE = regula_multitasker_bloodline }

		send_interface_toast = { # Tell the character
			title = regula_bloodline.2021.title
			desc = regula_bloodline.2021.personal_desc
			add_trait = regula_multitasker_bloodline
		}
	}

	after = {
	}
}

regula_bloodline.2022 = { # Bun in the Oven
	type = character_event
	hidden = yes

	immediate = {
		regula_bloodline_addition_effect = { BLOODLINE = regula_bun_bloodline }

		send_interface_toast = { # Tell the character
			title = regula_bloodline.2022.personal_desc
			add_trait = regula_bun_bloodline

		}

		every_spouse = { #Inform relevant parties.
			send_interface_message = {
				type = good_omen
				title = regula_bloodline.2022.t
				right_icon = root
				desc = regula_bloodline.2022.desc
			}
		}
	}

	after = {
	}
}