# DO NOT ALTER THE NAME OR NUMBER OF THESE!

gender_laws = {
	agnatic_succession = {
		female_dynasty_opinion = -5

		potential = {
			holder_scope = {
				# Theocracies have to allow Male temple holders
				trigger_if = {
					limit = { is_theocracy = yes }

					religion_allows_male_temple_holders = yes
					religion_allows_female_temple_holders = no
				}
				# Matriarchal and Equal religions don't allow male-centric succession
				trigger_else = {
					NOR = {
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_equal
						### ACR ###
						has_religion_feature = religion_feature_bon
						has_religion_feature = religion_feature_egyptian
						has_religion_feature = religion_feature_celtic
						religion = britannic_pagan
					}
				}
			}
		}

		pass_effect = {
			# log = "agnatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			# log = "agnatic_succession ([This.GetFullBaseName])"
			gender_succ = agnatic
			law_set_allow_matrilineal_marriage = no
		}

		default_selection = {
			factor = 1

			mult_modifier = {
				factor = 100

				holder_scope = {
					NOR = {
						# Christian
						religion = cathar
						religion = bogomilist
						religion = messalian

						# Indian
						religion = buddhist

						# Pagan
						religion_openly_west_african_or_reformed_trigger = yes

						# Zoroastrian
						religion = mazdaki

						trigger_if = {
							limit = { culture_group = tibetan_group }

							NOR = {
								religion = taoist
								culture = tangut
							}
						}
					}

					NOR = {
						has_law = status_of_women_3
						has_law = status_of_women_4
					}
				}
			}
		}
	}

	cognatic_succession = { # agnatic-cognatic
		potential = {
		#	is_landless_type_title = no
		#	is_primary_type_title = no

			holder_scope = {
				is_theocracy = no

				trigger_if = {
					limit = { is_republic = yes }

					has_dlc = "Conclave"
					is_patrician = yes

					trigger_if = {
						limit = { independent = no }

						defacto_liege_title = {
							OR = {
								has_law = true_cognatic_succession
								has_law = cognatic_succession
							}
						}
					}
				}
				trigger_else_if = {
					limit = {
						OR = {
							religion_group = muslim
							has_horde_culture = yes
							is_nomadic = yes
							religion = aztec_pagan
						}
					}

					has_dlc = "Conclave"
				}
				trigger_else_if = {
					limit = { government = order_government }
					independent = yes
				}

				# No exceptions
				NOR = {
					has_religion_feature = religion_matriarchal
					has_religion_feature = religion_equal
					### ACR ###
					has_religion_feature = religion_feature_bon
					has_religion_feature = religion_feature_egyptian
					has_religion_feature = religion_feature_celtic
					religion = britannic_pagan
				}
			}
		}

		allow = {
			holder_scope = {
				show_scope_change = no

				trigger_if = {
					limit = {
						OR = {
							religion_group = muslim
							has_horde_culture = yes
							is_nomadic = yes
							religion = aztec_pagan
						}

						NOT = {
							has_game_rule = {
								name = gender
								value = all
							}
						}
					}

					OR = {
						has_law = status_of_women_3
						has_law = status_of_women_4
					}
				}
			}
		}

		pass_effect = {
			# log = "cognatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			# log = "cognatic_succession ([This.GetFullBaseName])"
			gender_succ = cognatic
			law_set_allow_matrilineal_marriage = yes
		}

		default_selection = {
			factor = 10
		}
	}

	true_cognatic_succession = { # absolute cognatic
		male_dynasty_opinion = -5

		potential = {
		#	is_landless_type_title = no
		#	is_primary_type_title = no

			holder_scope = {
				trigger_if = {
					limit = { is_theocracy = yes }

					religion_allows_male_temple_holders = yes
					religion_allows_female_temple_holders = yes
				}

				# Equality gets a free pass
				trigger_else_if = {
					limit = {
						NOR = {
							has_religion_feature = religion_equal
							has_religion_feature = religion_feature_bon

							trigger_if = {
								limit = { has_dlc = "Conclave" }

								has_game_rule = {
									name = gender
									value = all
								}
							}
							
							### ACR ###
							has_religion_feature = religion_feature_egyptian
							has_religion_feature = religion_feature_celtic
						}
					}

					# No Exceptions
					NOR = {
						has_religion_feature = religion_matriarchal
						has_religion_feature = religion_patriarchal
						### ACR ###
						religion = britannic_pagan
					}

					trigger_if = {
						limit = { is_republic = yes }

						has_dlc = "Conclave"
						is_patrician = yes

						trigger_if = {
							limit = { independent = no }

							defacto_liege_title = {
								OR = {
									has_law = true_cognatic_succession
									has_law = cognatic_succession
									has_law = enatic_cognatic_succession
								}
							}
						}
					}
					trigger_else_if = {
						limit = {
							OR = {
								religion_group = muslim
								has_horde_culture = yes
								is_nomadic = yes
								religion = aztec_pagan
							}
						}

						has_dlc = "Conclave"
					}
				}
			}
		}

		allow = {
			holder_scope = {
				show_scope_change = no

				trigger_if = {
					limit = {
						NOT = {
							has_game_rule = {
								name = gender
								value = all
							}
						}
					}

					OR = {
						culture = basque
						culture = zhangzhung
						culture = sumpa

						has_religion_feature = religion_equal
						has_religion_feature = religion_feature_bon

						religion = cathar
						religion = messalian
						religion = mazdaki

						trigger_if = {
							limit = { has_dlc = "Conclave"}
							has_law = status_of_women_4
						}
						
						### ACR ###
						has_religion_feature = religion_feature_egyptian
						has_religion_feature = religion_feature_celtic
					}
				}
			}
		}

		pass_effect = {
			# log = "true_cognatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			# log = "true_cognatic_succession ([This.GetFullBaseName])"
			gender_succ = true_cognatic
			law_set_allow_matrilineal_marriage = yes
		}

		default_selection = {
			factor = 1

			additive_modifier = {
				value = 10000

				has_game_rule = {
					name = gender
					value = all
				}
			}

			mult_modifier = {
				factor = 100

				holder_scope = {
					OR = {
						has_religion_feature = religion_equal
						### ACR ###
						has_religion_feature = religion_feature_bon
						has_religion_feature = religion_feature_egyptian
						has_religion_feature = religion_feature_celtic
					}
				}
			}
		}
	}

	enatic_cognatic_succession = {
		male_dynasty_opinion = -10
		female_dynasty_opinion = 5

		potential = {
		#	is_landless_type_title = no
		#	is_primary_type_title = no

			holder_scope = {
				is_theocracy = no

				trigger_if = {
					limit = { is_republic = yes }

					has_dlc = "Conclave"
					is_patrician = yes

					trigger_if = {
						limit = { independent = no }

						defacto_liege_title = {
							OR = {
								has_law = true_cognatic_succession
								has_law = enatic_cognatic_succession
							}
						}
					}
				}

				OR = {
					has_religion_feature = religion_matriarchal

					any_owned_bloodline = {
						has_bloodline_flag = bloodline_enatic_cognatic
						bloodline_is_active_for = PREV
					}

					trigger_if = {
						limit = { has_game_started = no }
						character = c_251187 # Magajiva Daura, necesesary because her historical bloodline doesn't evaluate correctly on game start-up
					}
					
					### ACR ###
					religion = britannic_pagan
				}
			}

			# Override laws set by title history, should default to Absolute Cognatic
			trigger_if = {
				limit = { has_game_started = no }

				NOT = {
					has_game_rule = {
						name = gender
						value = all
					}
				}
			}
		}

		pass_effect = {
			# log = "enatic_cognatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			# log = "enatic_cognatic_succession ([This.GetFullBaseName])"
			gender_succ = enatic_cognatic
		}

		default_selection = {
			factor = 100
		}
	}

	enatic_succession = {
		male_dynasty_opinion = -10
		female_dynasty_opinion = 10

		potential = {
		#	is_landless_type_title = no

			holder_scope = {
				trigger_if = {
					limit = { is_theocracy = yes }

					religion_allows_male_temple_holders = no
					religion_allows_female_temple_holders = yes
				}
				trigger_else = {
					OR = {
						has_religion_feature = religion_matriarchal
						### ACR ###
						religion = britannic_pagan
					}
				}
			}

			# Override laws set by title history, should default to Absolute Cognatic
			trigger_if = {
				limit = { has_game_started = no }

				NOT = {
					has_game_rule = {
						name = gender
						value = all
					}
				}
			}
		}

		pass_effect = {
			# log = "enatic_succession pass ([This.GetFullBaseName])"
		}

		effect = {
			# log = "enatic_succession ([This.GetFullBaseName])"
			gender_succ = enatic
		}

		default_selection = {
			factor = 1
		}
	}
}