# -*- ck2.laws -*-

# DO NOT ALTER THE NAME OR NUMBER OF THESE!

succession_laws = {

	succ_gavelkind = {
		oldest_child_opinion = -5
		child_opinion = 15
		dynasty_opinion = 5

		potential = {
			emf_laws_succ_basic_potential = yes
			emf_laws_potential_not_for_byzantium = yes
			holder_scope = {
				OR = {
					is_feudal = yes
					is_tribal = yes
				}
			}
			rebel = no
			NOT = { holder_scope = { government = confucian_bureaucracy } }
		}
		allow = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			holder_scope = {
				show_scope_change = no
				OR = {
					is_tribal = no
					emf_not_unreformed_pagan = yes
					culture = hungarian
				}
				in_revolt = no
			}
			emf_laws_allow_switch_away_from_hre_elective = yes
		}
		effect = {
			#tooltip = {
			#	succession = gavelkind
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = gavelkind
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_gavelkind: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = gavelkind
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_gavelkind_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = gavelkind
		}
	}

	succ_elective_gavelkind = {
		child_opinion = 15
		dynasty_opinion = 5
		vassal_opinion = 5

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			emf_laws_succ_basic_potential = yes
			emf_laws_potential_not_for_byzantium = yes
			holder_scope = {
				OR = {
					is_feudal = yes
					is_tribal = yes
				}
			}
			rebel = no
			NOT = { holder_scope = { government = confucian_bureaucracy } }
			NOT = { holder_scope = { government = chinese_imperial_government } }
		}
		allow = {
			holder_scope = {
				show_scope_change = no
				in_revolt = no
			}
			emf_laws_allow_switch_away_from_hre_elective = yes
		}
		effect = {
			#tooltip = {
			#	succession = { base_type = elective_gavelkind voting_rules = elective_gavelkind }
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = { base_type = elective_gavelkind voting_rules = elective_gavelkind }
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_elective_gavelkind: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = { base_type = elective_gavelkind voting_rules = elective_gavelkind }
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_elective_gavelkind_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = { base_type = elective_gavelkind voting_rules = elective_gavelkind }
		}
	}

	succ_eldership = {
		dynasty_opinion = 5
	
		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			emf_laws_succ_basic_potential = yes
			emf_laws_potential_not_for_byzantium = yes
			holder_scope = {
				OR = {
					is_feudal = yes
					is_tribal = yes
				}
				OR = {
					AND = {
						is_tribal = yes
						OR = { religion = baltic_pagan religion = west_african_pagan }
					}
					has_religion_feature = religion_beatification
					has_religion_feature = religion_feature_baltic
					has_religion_feature = religion_feature_west_african
				}
				NOR = {
					has_religion_feature = religion_matriarchal
					has_religion_feature = religion_patriarchal
					government = confucian_bureaucracy
					government = chinese_imperial_government
				}
			}
			rebel = no
		}
		allow = {
			holder_scope = {
				show_scope_change = no
				OR = {
					AND = {
						is_tribal = yes
						OR = { religion = baltic_pagan religion = west_african_pagan }
					}
					has_religion_feature = religion_beatification
					has_religion_feature = religion_feature_baltic
					has_religion_feature = religion_feature_west_african
				}
				in_revolt = no
			}
		}
		effect = {
			#tooltip = {
			#	succession = { base_type = tanistry voting_rules = eldership_rules }
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = { base_type = tanistry voting_rules = eldership_rules }
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_eldership: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = { base_type = tanistry voting_rules = eldership_rules }
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_eldership_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = { base_type = tanistry voting_rules = eldership_rules }
		}
	}

	succ_seniority = {
		vassal_opinion = -5
		oldest_child_opinion = -15
		child_opinion = -10
		dynasty_opinion = 5

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			emf_laws_succ_basic_potential = yes
			emf_laws_potential_not_for_byzantium = yes
			holder_scope = {
				OR = {
					is_merchant_republic = no
					primary_title = {
						NOT = { title = PREVPREV }
					}
				}
				OR = {
					NOR = {
						religion_group = muslim
						religion_group = indian_group
					}
					is_patrician = yes
				}
				OR = {
					NOT = { religion_group = pagan_group }
					is_reformed_religion = yes
					is_patrician = yes
				}
				OR = {
					is_republic = no
					is_patrician = yes
				}
			}
			OR = {
				AND = {
					tier = BARON
					is_feudal = yes
				}
				holder_scope = { is_feudal = yes }
				holder_scope = { is_patrician = yes }
			}
			OR = {
				NOT = { tier = BARON }
				holder_scope = { is_patrician = yes }
			}
			NOT = { holder_scope = { government = confucian_bureaucracy } }
		}
		allow = {
			emf_laws_allow_switch_away_from_hre_elective = yes
			OR = {
				emf_laws_no_crown_law_title = yes
				emf_laws_crownlaw_title_medium_ca_plus = yes
				emf_laws_holder_has_late_adminstration_plus = yes
				holder_scope = {
					is_patrician = yes
					OR = {
						is_merchant_republic = no
						PREV = {
							is_primary_holder_title = no
						}
						NOR = {
							in_revolt = yes
							succ_law_title = {
								title = PREVPREV
							}
						}
					}
				}
			}
		}
		effect = {
			#tooltip = {
			#	succession = seniority
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = seniority
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_seniority: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = seniority
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_seniority_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = seniority
		}
	}

	succ_primogeniture = {
		oldest_child_opinion = 10
		youngest_child_opinion = -15
		child_opinion = -10
		dynasty_opinion = -5

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			emf_laws_potential_not_for_byzantium = yes
			OR = {
				AND = {
					emf_laws_succ_basic_potential = yes
					OR = {
						AND = {
							tier = BARON
							is_feudal = yes
						}
						holder_scope = { is_feudal = yes }
					}
					holder_scope = {
						OR = {
							emf_unreformed_pagan = no
							religion = hellenic_pagan
						}
					}
				}
				has_title_flag = alternate_byz
			}
			holder_scope = {
				is_merchant_republic = no
				is_patrician = no
				NOT = { government = confucian_bureaucracy }
			}
		}
		allow = {
			OR = {
				emf_laws_crownlaw_title_high_ca_plus = yes
				emf_laws_holder_has_late_adminstration_plus = yes
			}
			emf_laws_allow_switch_away_from_hre_elective = yes
		}
		effect = {
			#tooltip = {
			#	succession = primogeniture
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = primogeniture
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_primogeniture: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = primogeniture
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_primogeniture_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = primogeniture
		}
	}

	succ_feudal_elective = {
		oldest_child_opinion = -15
		child_opinion = -5
		dynasty_opinion = -5
		vassal_opinion = 10

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			OR = {
				emf_is_hre = no
				has_title_flag = alternate_hre
			}
			emf_laws_potential_not_for_byzantium = yes
			NOT = { tier = BARON }
			holder_scope = {
				OR = {
					independent = yes
					NOT = { any_liege = { holy_order = yes } }
				}
				OR = {
					NOT = { religion_group = pagan_group }
					is_reformed_religion = yes
					religion = hellenic_pagan
					has_law = succ_feudal_elective
					has_law = succ_hre_elective
					PREV = { has_title_flag = alternate_hre }
				}
				OR = {
					is_feudal = yes
					has_law = succ_feudal_elective
					has_law = succ_hre_elective
					PREV = { has_title_flag = alternate_hre }
				}
			}
			OR = {
				is_landless_type_title = no
				temporary = yes
			}
			is_primary_type_title = no
			NOT = { holder_scope = { government = confucian_bureaucracy } }
			NOT = { holder_scope = { government = chinese_imperial_government } }
		}
		allow = {
			holder_scope = {
				custom_tooltip = {
					text = emf_laws_ctt_player_if_muslim_or_indian
					hidden_tooltip = {
						OR = {
							AND = {
								ai = no
								# Only after start, or Muslim players might start
								# w/ Feudal Elective instead of Open succession
								has_game_started = yes
							}
							NOR = {
								religion_group = muslim
								religion_group = indian_group
							}
							hidden_tooltip = {
								OR = {
									has_law = succ_feudal_elective
									has_law = succ_hre_elective
								}
							}
							hidden_tooltip = { PREV = { has_title_flag = alternate_hre } }
						}
					}
				}
			}
		}
		effect = {
			#tooltip = {
			#	succession = { base_type = feudal_elective voting_rules = feudal_elective }
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = { base_type = feudal_elective voting_rules = feudal_elective }
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_feudal_elective: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = { base_type = feudal_elective voting_rules = feudal_elective }
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_feudal_elective_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = { base_type = feudal_elective voting_rules = feudal_elective }
		}
	}

	succ_hre_elective = {
		oldest_child_opinion = -15
		child_opinion = -5
		dynasty_opinion = -5
		vassal_opinion = 15
		vassal_limit = 20

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			emf_is_hre = yes
			emf_laws_potential_not_for_byzantium = yes
			holder_scope = {
				is_merchant_republic = no
				is_patrician = no
				OR = {
					NOR = { 
						religion_group = muslim
						religion_group = indian_group
					}
					has_law = succ_feudal_elective # Keep it even if you revoke Full Council Authority
					has_law = succ_hre_elective
					ROOT = { has_title_flag = alternate_hre }
				}
				
				OR = {
					NOT = { religion_group = pagan_group }
					is_reformed_religion = yes
					religion = hellenic_pagan
					has_law = succ_feudal_elective # Keep it even if you revoke Full Council Authority
					has_law = succ_hre_elective
					ROOT = { has_title_flag = alternate_hre }
				}
			}
			OR = {
				is_landless_type_title = no
				is_tribal_type_title = yes
				temporary = yes
			}
			is_primary_type_title = no
			NOT = { tier = BARON }
			holder_scope = {
				OR = {
					is_feudal = yes
					has_law = succ_feudal_elective # Keep it even if you revoke Full Council Authority
					has_law = succ_hre_elective
					ROOT = { has_title_flag = alternate_hre }
				}
				NOR = {
					government = confucian_bureaucracy
					government = chinese_imperial_government
				}
			}
		}
		allow = {
		}
		effect = {
			#tooltip = {
			#	succession = { base_type = feudal_elective voting_rules = hre_feudal_elective }
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = { base_type = feudal_elective voting_rules = hre_feudal_elective }
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_hre_elective: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = { base_type = feudal_elective voting_rules = hre_feudal_elective }
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_hre_elective_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = { base_type = feudal_elective voting_rules = hre_feudal_elective }
		}
	}
	
	succ_byzantine_elective = {
		oldest_child_opinion = -5
		child_opinion = -5
		dynasty_opinion = -5
		feudal_opinion = -5

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			holder_scope = {
				primary_title = { emf_is_roman_empire = yes }
				NOT = { religion_group = muslim }
				is_nomadic = no
				is_merchant_republic = no
				is_patrician = no
				NOR = {
					government = confucian_bureaucracy
					government = chinese_imperial_government
				}
			}
		}
		allow = {
		}
		effect = {
			#tooltip = {
			#	succession = { base_type = feudal_elective voting_rules = byzantine_elective }
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = { base_type = feudal_elective voting_rules = byzantine_elective }
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_byzantine_elective: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = { base_type = feudal_elective voting_rules = byzantine_elective }
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_byzantine_elective_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = { base_type = feudal_elective voting_rules = byzantine_elective }
		}
	}

	succ_tanistry = {
		oldest_child_opinion = -20
		child_opinion = -10
		dynasty_opinion = 5
		vassal_opinion = 5

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			emf_laws_succ_basic_potential = yes
			emf_laws_potential_not_for_byzantium = yes
			holder_scope = {
				is_merchant_republic = no
				is_patrician = no
				OR = {
					culture_group = celtic
					is_feudal = yes
					any_owned_bloodline = { has_bloodline_flag = bloodline_tanistry }
				}
			}
			NOT = { tier = BARON }
			NOT = { holder_scope = { government = confucian_bureaucracy } }
			NOT = { holder_scope = { government = chinese_imperial_government } }
		}
		allow = {
			holder_scope = {
				OR = {
					is_feudal = yes
					is_tribal = yes
				}
			}
			emf_laws_allow_switch_away_from_hre_elective = yes
		}
		effect = {
			#tooltip = {
			#	succession = { base_type = tanistry voting_rules = tanistry }
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = { base_type = tanistry voting_rules = tanistry }
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_tanistry: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = { base_type = tanistry voting_rules = tanistry }
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_tanistry_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = { base_type = tanistry voting_rules = tanistry }
		}
	}

	succ_ultimogeniture = {
		youngest_child_opinion = 10
		oldest_child_opinion = -15
		child_opinion = -10
		dynasty_opinion = -5

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			emf_laws_potential_not_for_byzantium = yes
			holder_scope = {
				NOT = { religion_group = muslim }
				OR = {
					independent = yes
					NOT = { any_liege = { holy_order = yes } }
				}
				is_merchant_republic = no
				is_patrician = no
				OR = {
					culture = mongol
					emf_unreformed_pagan = no
				}
			}
			OR = {
				AND = {
					tier = BARON
					is_feudal = yes
				}
				holder_scope = { is_feudal = yes }
				AND = {
					is_nomadic = no
					OR = {
						title = e_mongol_empire
						title = e_golden_horde
						title = e_il-khanate
					}
				}
			}
			OR = {
				is_landless_type_title = no
				temporary = yes
				AND = {
					is_nomadic = no
					OR = {
						title = e_mongol_empire
						title = e_golden_horde
						title = e_il-khanate
					}
				}
			}
			is_primary_type_title = no
			NOT = { holder_scope = { government = confucian_bureaucracy } }
		}
		allow = {
			OR = {
				emf_laws_crownlaw_title_high_ca_plus = yes
				emf_laws_holder_has_late_adminstration_plus = yes
			}
			emf_laws_allow_switch_away_from_hre_elective = yes
		}
		effect = {
			#tooltip = {
			#	succession = ultimogeniture
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = ultimogeniture
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_ultimogeniture: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = ultimogeniture
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_ultimogeniture_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = ultimogeniture
		}
	}

	succ_turkish_succession = {
		oldest_child_opinion = -5
#		child_opinion = 30
#		dynasty_opinion = 10

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			emf_laws_potential_not_for_byzantium = yes
			holder_scope = {
				OR = {
					religion_group = muslim
					AND = {
						has_religion_feature = religion_patriarchal
						is_theocracy = no
					}
					AND = {
						has_religion_feature = religion_matriarchal
						is_theocracy = no
					}
				}
				is_republic = no
				is_merchant_republic = no
				is_nomadic = no
				OR = {
					independent = yes
					NOT = { any_liege = { holy_order = yes } }
				}
			}
			OR = {
				is_landless_type_title = no
				temporary = yes
			}
			is_primary_type_title = no
			NOT = { holder_scope = { government = confucian_bureaucracy } }
		}
		effect = {
			#tooltip = {
			#	succession = turkish_succession
			#	emf_laws_change_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		succession = turkish_succession
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: succ_turkish_succession: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		succession = turkish_succession
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_succ_turkish_succession_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_succ_law_effect = yes
			}
			succession = turkish_succession
		}
	}

	succ_papal_succession = {
		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			OR = {
				title = k_papal_state
				title = d_fraticelli
				title = d_cathar
				title = d_bogomilist
				title = d_manichean
			}
		}
		effect = {
			succession = papal_succession
		}
	}

	# Titles revert back to the liege on death
	succ_appointment = {
		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			holder_scope = {
				is_feudal = yes
				independent = no
				any_liege = {
					holy_order = yes
				}
				is_merchant_republic = no
				NOR = {
					government = confucian_bureaucracy
					government = chinese_imperial_government
				}
			}
		}
		effect = {
			succession = appointment
		}
	}

	succ_open_elective = {
		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_lowborn_g	
					government = rtp_noble_g	
					government = rtp_republic_g	
					government = rtp_baron_republic_g	
					government = rtp_theocracy_g	
					government = rtp_baron_theocracy_g	
					government = rtp_mercenary_g	
					government = rtp_baron_mercenary_g	
				}	
			}
			emf_laws_potential_not_for_byzantium = yes
			NOR = {
				title = k_papal_state
				title = d_fraticelli
				title = d_cathar
				title = d_bogomilist
				title = d_manichean
			}
			temporary = no
			OR = {
				is_primary_type_title = yes
				holy_order = yes
				AND = {
					tier = BARON
					OR = {
						is_republic = yes
						AND = {
							is_theocracy = yes
							NOT = { holder_scope = { religion_group = muslim } }
						}
					}
				}
				holder_scope = {
					OR = {
						is_republic = yes
						AND = {
							is_theocracy = yes
							NOT = { religion_group = muslim }
						}
					}
				}
			}
			OR = {
				is_landless_type_title = yes
				holder_scope = { is_theocracy = no }
				holder_scope = {
					NOR = {
						religion = catholic
						religion = cathar
						religion = bogomilist
						religion = manichean
						religion = fraticelli
					}
				}
			}
			holder_scope = {
				is_patrician = no
				is_merchant_republic = no
				OR = {
					independent = yes
					is_feudal = no
					NOT = {
						any_liege = {
							holy_order = yes
						}
					}
				}
			}
			NOT = { holder_scope = { government = confucian_bureaucracy } }
			NOT = { holder_scope = { government = chinese_imperial_government } }
		}

		effect = {
			succession = open_elective
		}
	}

	succ_catholic_bishopric = {
		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			is_landless_type_title = no
			OR = {
				AND = {
					tier = BARON
					is_theocracy = yes
				}
				holder_scope = { is_theocracy = yes }
			}

			holder_scope = {
				OR = {
					religion = catholic
					religion = cathar
					religion = bogomilist
					religion = manichean
					religion = fraticelli
				}
				is_merchant_republic = no
				OR = {
					independent = yes
					is_feudal = no
					NOT = {
						any_liege = {
							holy_order = yes
						}
					}
				}
			}
			is_primary_type_title = no
			NOT = { holder_scope = { government = confucian_bureaucracy } }
			NOT = { holder_scope = { government = chinese_imperial_government } }
		}
		effect = {
			succession = catholic_bishopric
		}
	}

	succ_patrician_elective = {
		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			OR = {
				is_primary_holder_title = yes
				holder_scope = {
					in_revolt = yes
					succ_law_title = {
						title = PREVPREV
					}
				}
			}
			holder_scope = {
				is_merchant_republic = yes
			}
			NOT = { holder_scope = { government = confucian_bureaucracy } }
			NOT = { holder_scope = { government = chinese_imperial_government } }
		}
		effect = {
			succession = patrician_elective
		}
	}

	succ_nomad_succession = {
		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			holder_scope = {
				is_nomadic = yes
			}
		}
		effect = {
			succession = nomad_succession
		}
	}
	
	succ_offmap_succession = {
		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_republic_g	
					government = rtp_theocracy_g	
					government = rtp_mercenary_g	
				}	
			}
			holder_scope = {
				top_liege = { is_offmap_governor = yes }
				government = confucian_bureaucracy # To use this with future offmap powers, use an OR clause here with the new government types
			}
		}
		effect = {
			succession = offmap_succession
			# This succession type generates a character of China's culture and religion
			# They have decent (4-10) stats, and good (7-11) stewardship, and will always have a Stewardship education
			# The offmap power defined in the top liege's government is used to determine the culture and religion. Will not function if this isn't defined
		}
	}
}

gender_laws = {
	cognatic_succession = {
		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_lowborn_g	
					government = rtp_noble_g	
				}	
			}
			holder_scope = {
				NOT = { has_religion_feature = religion_matriarchal }
				NOT = { has_religion_feature = religion_equal }
				NOT = { has_religion_feature = religion_feature_bon }
				OR = {
					NOT = { tier = BARON }
					is_theocracy = yes
					is_republic = yes
				}
				NOT = {
					any_liege = {
						holy_order = yes
						OR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_equal
							has_religion_feature = religion_feature_bon
						}
					}
				}
				OR = {
					NOR = {
						religion_group = muslim
						has_horde_culture = yes
						is_tribal = yes
						is_nomadic = yes
						is_merchant_republic = yes
						is_patrician = yes
					}
					AND = {
						OR = {
							has_game_rule = { name = gender value = all }
							AND = {
								has_dlc = "Zeus"
								OR = {
									ROOT = { holder_scope = { primary_title = { has_law = status_of_women_3 } } }
									ROOT = { holder_scope = { primary_title = { has_law = status_of_women_4 } } }
								}
							}
						}
						OR = {
							is_patrician = no
							is_merchant_republic = yes
							liege = {
								primary_title = {
									OR = {
										has_law = true_cognatic_succession
										has_law = cognatic_succession
									}
								}
							}
						}
					}
				}
			}
			OR = {
				AND = {
					tier = BARON
					is_theocracy = no
					is_republic = no
				}
				holder_scope = {
					is_theocracy = no
					OR = {
						is_republic = no
						is_patrician = yes
					}
				}
			}
			is_landless_type_title = no
			is_primary_type_title = no
		}
		allow = {
			OR = {
				has_law = agnatic_succession
				has_law = true_cognatic_succession
			}
			emf_laws_change_succ_can_afford_prestige_cost = yes
		}
		effect = {
			#tooltip = {
			#	gender_succ = cognatic
			#	law_set_allow_matrilineal_marriage = yes
			#	emf_laws_change_gender_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		gender_succ = cognatic
			#		law_set_allow_matrilineal_marriage = yes
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: cognatic_succession: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		gender_succ = cognatic
			#		law_set_allow_matrilineal_marriage = yes
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_cognatic_succession_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_gender_law_effect = yes
			}
			gender_succ = cognatic
			law_set_allow_matrilineal_marriage = yes
			hidden_tooltip = {
				emf_do_gender_succ_family_palace_workaround = yes
			}
		}
		default = yes
		default_selection = {
			factor = 0
			modifier = {
				factor = 0
				has_game_rule = { name = gender value = all }
			}
			additive_modifier = {
				value = 10
				holder_scope = {
					is_female = yes
				}
			}
			additive_modifier = {
				value = 10
				OR = {
					title = e_byzantium
					AND = { # Z: this needs more research, but it's not exactly high-priority
						year = 1000
						holder_scope = {
							OR = {
								culture_group = iberian
								culture = occitan
							}
						}
					}
				}
			}
		}
	}
	agnatic_succession = {
		female_dynasty_opinion = -5

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_lowborn_g	
					government = rtp_noble_g	
				}	
			}
			holder_scope = { 
				NOT = { has_religion_feature = religion_matriarchal } 
				NOT = { has_religion_feature = religion_equal }
				NOT = { has_religion_feature = religion_feature_bon }
				NOT = {
					any_liege = {
						holy_order = yes
						OR = {
							has_religion_feature = religion_matriarchal
							has_religion_feature = religion_equal
							has_religion_feature = religion_feature_bon
						}
					}
				}
			}
		}
		allow = {
			has_law = cognatic_succession
			emf_laws_change_succ_can_afford_prestige_cost = yes
		}
		effect = {
			#tooltip = {
			#	gender_succ = agnatic
			#	emf_laws_change_gender_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		gender_succ = agnatic
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: agnatic_succession: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		gender_succ = agnatic
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_agnatic_succession_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_gender_law_effect = yes
			}
			gender_succ = agnatic
			hidden_tooltip = {
				emf_do_gender_succ_family_palace_workaround = yes
			}
		}
		default = yes
		default_selection = {
			factor = 1
			modifier = {
				factor = 0
				has_game_rule = { name = gender value = all }
			}
			modifier = {
				factor = 0
				holder_scope = {
					is_female = yes # If a female is holding this title, the title must not have had male-only succession for them to have gotten it in the first place
				}
			}
			modifier = {
				factor = 100
				holder_scope = {
					NOR = {
						religion_group = christian
						religion = west_african_pagan
						religion = west_african_pagan_reformed
						AND = {
							culture_group = tibetan_group
							NOT = { religion = taoist }
							NOT = { culture = tangut }
						}
					}
					primary_title = {
						NOT = { has_law = status_of_women_3 }
						NOT = { has_law = status_of_women_4 }
					}
				}
			}
		}
	}
	true_cognatic_succession = {
		male_dynasty_opinion = -5

		potential = {
			holder_scope = { NOT = { has_religion_feature = religion_matriarchal } }
			holder_scope = { NOT = { has_religion_feature = religion_patriarchal } }
			OR = {
				has_game_rule = { name = gender value = all }
				holder_scope = {
					NOT = {
						any_liege = {
							holy_order = yes
							NOR = {
								has_religion_feature = religion_equal
								has_religion_feature = religion_feature_bon
							}
						}
					}
					OR = {
						NOR = {
							religion_group = muslim
							has_horde_culture = yes
							is_tribal = yes
							is_nomadic = yes
							is_merchant_republic = yes
							is_patrician = yes
						}
						has_religion_feature = religion_equal
						has_religion_feature = religion_feature_bon
						AND = {
							has_dlc = "Zeus"
							ROOT = { holder_scope = { primary_title = { has_law = status_of_women_4 } } }
							OR = {
								is_patrician = no
								is_merchant_republic = yes
								liege = {
									primary_title = {
										OR = {
											has_law = true_cognatic_succession
											has_law = cognatic_succession
										}
									}
								}
							}
						}
					}
				}
			}
			OR = {
				AND = {
					tier = BARON
					is_theocracy = no
					is_republic = no
				}
				holder_scope = {
					is_theocracy = no
					OR = {
						is_republic = no
						is_patrician = yes
					}
				}
				holder_scope = {
					OR = {
						has_religion_feature = religion_equal
						has_religion_feature = religion_feature_bon
					}
				}
			}
			is_landless_type_title = no
			is_primary_type_title = no
		}
		allow = {
			OR = {
				has_law = cognatic_succession
				has_law = enatic_cognatic_succession
			}
			holder_scope = {
				OR = {
					has_game_rule = { name = gender value = all }
					primary_title = {
						show_scope_change = no
						has_law = status_of_women_4
					}
					culture = basque
					culture = zhangzhung
					culture = sumpa
					emf_feminist_religion = yes
				}
			}
			emf_laws_change_succ_can_afford_prestige_cost = yes
		}
		effect = {
			#tooltip = {
			#	gender_succ = true_cognatic
			#	law_set_allow_matrilineal_marriage = yes
			#	emf_laws_change_gender_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		gender_succ = true_cognatic
			#		law_set_allow_matrilineal_marriage = yes
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: true_cognatic_succession: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		gender_succ = true_cognatic
			#		law_set_allow_matrilineal_marriage = yes
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_true_cognatic_succession_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_gender_law_effect = yes
			}
			gender_succ = true_cognatic
			law_set_allow_matrilineal_marriage = yes
			hidden_tooltip = {
				emf_do_gender_succ_family_palace_workaround = yes
			}
		}
		default = yes
		default_selection = {
			factor = 1
			additive_modifier = {
				value = 100
				OR = {
					has_game_rule = { name = gender value = all }
					holder_scope = { has_religion_feature = religion_equal }
					holder_scope = { has_religion_feature = religion_feature_bon }
				}
			}
			modifier = {
				factor = 0
				NOR = {
					has_game_rule = { name = gender value = all }
					holder_scope = { has_religion_feature = religion_equal }
					holder_scope = { has_religion_feature = religion_feature_bon }
				}
			}
		}
	}

	enatic_succession = {
		male_dynasty_opinion = -10
		female_dynasty_opinion = 10

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_lowborn_g	
					government = rtp_noble_g	
				}	
			}
			holder_scope = {
				OR = {
					has_religion_feature = religion_matriarchal
					has_landed_title = e_hip
				}
				NOT = {
					any_liege = {
						holy_order = yes
						NOT = { has_religion_feature = religion_matriarchal }
					}
				}
			}
		}
		allow = {
			has_law = enatic_cognatic_succession
			emf_laws_change_succ_can_afford_prestige_cost = yes
		}
		effect = {
			#tooltip = {
			#	gender_succ = enatic
			#	emf_laws_change_gender_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		gender_succ = enatic
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: enatic_succession: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		gender_succ = enatic
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_enatic_succession_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_gender_law_effect = yes
			}
			gender_succ = enatic
			law_set_allow_matrilineal_marriage = yes
			hidden_tooltip = {
				emf_do_gender_succ_family_palace_workaround = yes
			}
		}
		default_selection = {
			factor = 1
			modifier = {
				factor = 0
				has_game_rule = { name = gender value = all }
			}
			modifier = {
				factor = 0
				NOT = {
					holder_scope = {
						OR = {
							has_religion_feature = religion_matriarchal
							has_landed_title = e_hip
						}
					}
				}
			}
		}
	}

	enatic_cognatic_succession = {
		male_dynasty_opinion = -10
		female_dynasty_opinion = 5

		potential = {
			holder_scope = {	
				NOR = {	
					government = rtp_lowborn_g	
					government = rtp_noble_g	
				}	
			}
			holder_scope = {
				OR = {
					has_religion_feature = religion_matriarchal
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_enatic_cognatic 
					}
					has_landed_title = e_hip
				}
				NOT = {
					any_liege = {
						holy_order = yes
						NOT = { has_religion_feature = religion_matriarchal }
					}
				}
			}
		}
		allow = {
			OR = {
				has_law = true_cognatic_succession
				has_law = enatic_succession
			}
			emf_laws_change_succ_can_afford_prestige_cost = yes
		}
		effect = {
			#tooltip = {
			#	gender_succ = enatic_cognatic
			#	emf_laws_change_gender_succ_basic = yes
			#}
			#hidden_tooltip = {
			#	if = {
			#		limit = { emf_laws_penalty = no }
			#		gender_succ = enatic_cognatic
			#	}
			#	else = {
			#		save_event_target_as = emf_succ_title
			#		holder_scope = { save_event_target_as = emf_succ_changer }
			#		log = "INFO: enatic_cognatic_succession: law enacted for [This.GetID] ([This.GetFullBaseName]) by [emf_succ_changer.GetTitledFirstName] (ID: [emf_succ_changer.GetID])"
			#		emf_laws_change_succ_basic = yes
			#		emf_laws_change_succ_save_contenders = yes
			#		gender_succ = enatic_cognatic
			#		holder_scope = { recalc_succession = yes }
			#		emf_laws_enatic_cognatic_succession_reactions = yes
			#	}
			#}
			if = {
				limit = { emf_laws_penalty = yes }
				pf_save_old_gender_law_effect = yes
			}
			gender_succ = enatic_cognatic
			law_set_allow_matrilineal_marriage = yes
			hidden_tooltip = {
				emf_do_gender_succ_family_palace_workaround = yes
			}
		}
		default_selection = {
			factor = 1
			modifier = {
				factor = 0
				has_game_rule = { name = gender value = all }
			}
			modifier = {
				factor = 0
				NOT = {
					holder_scope = {
						OR = {
							has_religion_feature = religion_matriarchal
							any_owned_bloodline = {
								has_bloodline_flag = bloodline_enatic_cognatic 
							}
							has_landed_title = e_hip
						}
					}
				}
			}
			modifier = {
				factor = 100
				holder_scope = {
					OR = {
						has_religion_feature = religion_matriarchal
						any_owned_bloodline = {
							has_bloodline_flag = bloodline_enatic_cognatic 
						}
						has_landed_title = e_hip
					}
				}
			}
		}
	}
}
