on_death = {
	on_actions = {
		on_death_magister ### Deals with paelex, sets up heir.
		on_death_magister_bloodlines
	}
}
on_death_magister = {
	trigger = {
		is_ai = no
		has_trait = magister_trait_group
	}
	effect = {
		every_spouse = {
			if = {
				limit = {
					has_trait = paelex
				}
				remove_trait = paelex
				add_trait = orba
			}
		}
		every_spouse = { 
			if = {
				limit = {
					has_trait = domina
				}
				remove_trait = domina
				add_trait = orba
			}
		}
		every_concubine = {
			if = {
				limit = {
					has_trait = paelex
				}
				remove_trait = paelex
				add_trait = orba
			}
		}
		every_concubine = { 
			if = {
				limit = {
					has_trait = domina
				}
				remove_trait = domina
				add_trait = orba
			}
		}
		root.primary_heir = {
			trigger_event = {
				id = regula_initialize_event.0010
				days = { 7 28 }
			}
		}
	}
}

on_death_magister_bloodlines = {
	trigger = {
		is_ai = no
		has_trait = magister_trait_group
	}
	
	first_valid = {
		regula_bloodline.0001
		regula_bloodline.0002
		regula_bloodline.0003
		regula_bloodline.0004
		regula_bloodline.0005
		regula_bloodline.0006
	}
}