
character_gender_can_rule_title_trigger = {
	trigger_if = {
		limit = {
			$GENDER$ = { is_male = yes }
			exists = $TITLE$
			$TITLE$ = {
				NOT = {
					has_title_law = female_only_law
				}
			}
		}
		always = yes
	}
	trigger_else_if = {
		limit = {
			$GENDER$ = { is_female = yes }
			exists = $TITLE$
			$TITLE$ = {
				NOT = {
					has_title_law = male_only_law
				}
			}
		}
		always = yes
	}
	trigger_else = {
		always = no
	}
}

character_gender_can_inherit_from_trigger = {
	save_temporary_scope_as = heir

	trigger_if = {
		limit = {
			$CHARACTER$ = { exists = primary_title }
		}
		$CHARACTER$ = {
			character_gender_can_rule_title_trigger = {
				GENDER = scope:heir
				TITLE = primary_title
			}
		}
	}
	trigger_else = {
		always = no
	}
}

has_partition_succession_realm_law_trigger = {
	OR = {
		has_realm_law = confederate_partition_succession_law
		has_realm_law = partition_succession_law
		has_realm_law = high_partition_succession_law
	}
}

realm_law_use_crown_authority = {
	NOT = { has_government = tribal_government }
}

can_have_confederate_partition_succession_law_trigger = {
	OR = {
		has_government = feudal_government
		has_government = tribal_government
		has_government = clan_government
		has_game_rule = allow_unplayables
	}
}

can_keep_partition_succession_law_trigger = {
	# The 'can_keep' triggers are dependent on actually having the law. If they aren't, the trigger breakdown for the player breaks and shows incomplete information.
	trigger_if = {
		limit = {
			has_realm_law = partition_succession_law
		}
		OR = {
			can_have_partition_succession_law_trigger = yes

			# Mongol Empires
			has_title = title:e_mongol_empire
			has_title = title:e_ilkhanate
			has_title = title:e_golden_horde
			has_title = title:e_chagatai
			has_title = title:e_black_horde
			has_title = title:e_white_horde
			has_title = title:e_aarlud_khanate
			has_title = title:e_togskol_khanate
			has_title = title:e_baruun_khanate
		}
	}
}

can_have_partition_succession_law_trigger = {
	culture = {
		has_innovation = innovation_hereditary_rule
	}
	custom_description = {
		text = succession_laws_must_have_organised_government_tooltip
		OR = {
			has_government = feudal_government
			has_government = clan_government
			AND = {
				has_game_rule = allow_unplayables
				NOT = { has_government = tribal_government }
			}
		}
	}
}

can_keep_high_partition_succession_law_trigger = {
	# The 'can_keep' triggers are dependent on actually having the law. If they aren't, the trigger breakdown for the player breaks and shows incomplete information.
	trigger_if = {
		limit = {
			has_realm_law = high_partition_succession_law
		}
		OR = {
			can_have_high_partition_succession_law_trigger = yes

			# Mongol Empires
			has_title = title:e_mongol_empire
			has_title = title:e_ilkhanate
			has_title = title:e_golden_horde
			has_title = title:e_chagatai
			has_title = title:e_black_horde
			has_title = title:e_white_horde
			has_title = title:e_aarlud_khanate
			has_title = title:e_togskol_khanate
			has_title = title:e_baruun_khanate
		}
	}
}

can_have_high_partition_succession_law_trigger = {
	trigger_if = {
		limit = {
			OR = {
				has_culture = culture:occitan
				has_culture = culture:basque
				has_culture = culture:aragonese
				has_culture = culture:catalan
			}
			culture = {
				NOT = { has_innovation = innovation_heraldry }
			}
		}
		culture = { has_innovation = innovation_visigothic_codes }
	}
	trigger_else = {
		culture = { has_innovation = innovation_heraldry }
	}
	custom_description = {
		text = succession_laws_must_have_organised_government_tooltip
		OR = {
			has_government = feudal_government
			has_government = clan_government
			AND = {
				has_game_rule = allow_unplayables
				NOT = { has_government = tribal_government }
			}
		}
	}
}

can_keep_single_heir_succession_law_trigger = {
	# The 'can_keep' triggers are dependent on actually having the law. If they aren't, the trigger breakdown for the player breaks and shows incomplete information.
	trigger_if = {
		limit = {
			has_realm_law = single_heir_succession_law
		}
		OR = {
			can_have_single_heir_succession_law_trigger = yes
			# Byzantine Empire
			historical_succession_access_single_heir_succession_law_trigger = yes
		}
	}
}

can_have_single_heir_succession_law_trigger = {
	culture = {
		has_innovation = innovation_primogeniture
	}
	# Non-tribals only
	custom_description = {
		text = succession_laws_must_have_organised_government_tooltip
		OR = {
			has_government = feudal_government
			has_government = clan_government
			AND = {
				has_game_rule = allow_unplayables
				NOT = { has_government = tribal_government }
			}
		}
	}
}

can_keep_single_heir_youngest_succession_law_trigger = {
	# The 'can_keep' triggers are dependent on actually having the law. If they aren't, the trigger breakdown for the player breaks and shows incomplete information.
	trigger_if = {
		limit = {
			has_realm_law = single_heir_succession_law_youngest
		}
		OR = {
			can_have_single_heir_youngest_succession_law_trigger = yes
			historical_succession_access_single_heir_succession_law_youngest_trigger = yes
		}
	}
}

can_have_single_heir_youngest_succession_law_trigger = {
	culture = {
		has_innovation = innovation_primogeniture
	}
	# Non-tribals only
	custom_description = {
		text = succession_laws_must_have_organised_government_tooltip
		OR = {
			has_government = feudal_government
			has_government = clan_government
			AND = {
				has_game_rule = allow_unplayables
				NOT = { has_government = tribal_government }
			}

		}
	}
}

can_keep_single_heir_dynasty_house_trigger = {
	# The 'can_keep' triggers are dependent on actually having the law. If they aren't, the trigger breakdown for the player breaks and shows incomplete information.
	trigger_if = {
		limit = {
			has_realm_law = single_heir_dynasty_house
		}
		OR = {
			can_have_single_heir_dynasty_house_trigger = yes
			historical_succession_access_single_heir_dynasty_house_trigger = yes
		}
	}
}

can_have_single_heir_dynasty_house_trigger = {
	exists = house
	trigger_if = {
		limit = {
			OR = {
				has_culture = culture:czech
				has_culture = culture:slovien
			}
			culture = {
				NOT = {
					has_innovation = innovation_heraldry
				}
			}
		}
		culture = {
			has_innovation = innovation_table_of_princes
		}
	}
	trigger_else = {
		culture = {
			has_innovation = innovation_heraldry
		}
	}
	custom_description = {
		text = succession_laws_must_have_organised_government_tooltip
		OR = {
			has_government = feudal_government
			has_government = clan_government
			AND = {
				has_game_rule = allow_unplayables
				NOT = { has_government = tribal_government }
			}

		}
	}
}

can_have_bishop_theocratic_succession_law_trigger = {
	OR = {
		is_theocratic_lessee = yes
		has_government = theocracy_government
	}
}

is_temporal_head_of_faith_trigger = {
	is_head_of_faith = yes
	holder.faith = { has_doctrine = doctrine_temporal_head }
}

can_title_have_law_general_trigger = {
	tier >= tier_duchy
	is_temporal_head_of_faith_trigger = no
}

can_have_holy_order_succession_law_trigger = {
	has_government = holy_order_government
}

can_have_mercenary_succession_law_trigger = {
	has_government = mercenary_government
}

can_have_city_succession_law_trigger = {
	has_government = republic_government
}

title_can_reduce_partition_law_trigger = {
	OR = {
		AND = {
			has_title_law = single_heir_succession_law
			holder = {
				can_have_high_partition_succession_law_trigger = yes
			}
		}
		AND = {
			has_title_law = high_partition_succession_law
			holder = {
				can_have_high_partition_succession_law_trigger = yes
			}
		}
		AND = {
			has_title_law = partition_succession_law
			holder = {
				can_have_confederate_partition_succession_law_trigger = yes
			}
		}
	}
}