﻿@minority_law_cooldown_years = 5

# flag = religious_minorities_may_grow
# flag = religious_minorities_may_migrate
# flag = cultural_minorities_may_grow
# flag = cultural_minorities_may_migrate
# flag = may_convert_faith
# flag = may_convert_culture
# flag = unlock_expel_religious_minorities
# flag = unlock_expel_cultural_minorities

religious_minority_status_law = {
	default = religious_minority_status_2
	flag = religion_culture_law
	flag = religion_law

	# Laws only apply to astray and lower faiths

	religious_minority_status_1 = {

		modifier = {
			different_faith_opinion = 10
			clergy_opinion = -10
			minority_opinion = 5
			zealot_opinion = -10
		}

		flag = religious_minorities_may_grow
		flag = religious_minorities_may_migrate

		can_have = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}
		can_keep = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}

		can_pass = {
			has_realm_law = religious_minority_status_2
			custom_description = {
				subject = root
				text = "has_minority_law_cooldown"
				NOT = { has_variable = minority_law_cooldown }
			}
		}

		pass_cost = {
			prestige = medium_prestige_value
		}

		on_pass = {
			set_variable = {
				name = minority_law_cooldown
				years = @minority_law_cooldown_years
			}
		}

		ai_will_do = {
			value = 0
			# Factor for personality
			add = ai_honor
			add = ai_compassion

			add = {
				value = ai_zeal
				multiply = -1
			}
			add = {
				value = ai_vengefulness
				multiply = -1
			}
			if = {
				limit = {
					faith = {
						has_doctrine = doctrine_pluralism_pluralistic
					}
				}
				add = 25
			}
			if = {
				limit = {
					OR = {
						has_trait = holy_warrior
						has_trait = crusader_king
					}
				}
				add = -100
			}
			if = {
				limit = {
					# Check to make sure that the HRE, ERE, theocrats and heads of faith are not going to be all uwu huggy wuggy with other faiths
					OR = {
						has_title = title:e_hre
						has_title = title:e_byzantium
						has_title = faith.religious_head_title
						has_government = theocracy_government
					}
				}
				add = -1000
			}
		}
	}

	religious_minority_status_2 = {

		modifier = {
			#different_faith_opinion = -10
			#clergy_opinion = 10
			zealot_opinion = -5
		}

		flag = may_convert_faith
		flag = religious_minorities_may_migrate

		can_have = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}
		can_keep = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}

		should_start_with = { always = yes }

		can_pass = {
			OR = {
				has_realm_law = religious_minority_status_1
				has_realm_law = religious_minority_status_3
			}
			custom_description = {
				subject = root
				text = "has_minority_law_cooldown"
				NOT = { has_variable = minority_law_cooldown }
			}
		}

		pass_cost = {
			prestige = medium_prestige_value
		}

		on_pass = {
			set_variable = {
				name = minority_law_cooldown
				years = @minority_law_cooldown_years
			}
		}

		ai_will_do = {
			value = 0

			if = {
				# Chance to be intolerant
				limit = { has_realm_law = religious_minority_status_1 }
				add = -50

				# Factor for personality
				add = ai_zeal
				add = ai_vengefulness

				add = {
					value = ai_honor
					multiply = -1
				}
				add = {
					value = ai_compassion
					multiply = -1
				}
				if = {
					limit = {
						OR = {
							has_trait = holy_warrior
							has_trait = crusader_king
						}
					}
					add = 100
				}
				if = {
					limit = {
						# Check to make sure that the HRE, ERE, theocrats and heads of faith are not going to be all uwu huggy wuggy with other faiths
						OR = {
							has_title = title:e_hre
							has_title = title:e_byzantium
							has_title = faith.religious_head_title
							has_government = theocracy_government
						}
					}
					add = 1000
				}
			}
			else_if = {
				# Chance to be tolerant
				limit = { has_realm_law = religious_minority_status_3 }
				add = 50

				# Factor for personality
				add = ai_honor
				add = ai_compassion

				add = {
					value = ai_zeal
					multiply = -1
				}
				add = {
					value = ai_vengefulness
					multiply = -1
				}
				if = {
					limit = {
						OR = {
							has_trait = holy_warrior
							has_trait = crusader_king
						}
					}
					add = -100
				}
				if = {
					limit = {
						faith = {
							has_doctrine = doctrine_pluralism_pluralistic
						}
					}
					add = 25
				}
			}
			if = {
				limit = {
					faith = {
						has_doctrine = doctrine_pluralism_righteous
					}
				}
				add = 50
			}
			if = {
				limit = {
					# Check to make sure that the HRE, ERE, theocrats and heads of faith are not going to be all uwu huggy wuggy with other faiths
					OR = {
						has_title = title:e_hre
						has_title = title:e_byzantium
						has_title = faith.religious_head_title
						has_government = theocracy_government
					}
				}
				add = -1000
			}
		}
	}

	religious_minority_status_3 = {

		modifier = {
			different_faith_opinion = -10
			clergy_opinion = 10
			minority_opinion = -5
			zealot_opinion = 5
		}

		flag = may_convert_faith
		flag = unlock_expel_religious_minorities

		can_have = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}
		can_keep = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}

		can_pass = {
			has_realm_law = religious_minority_status_2
			custom_description = {
				subject = root
				text = "has_minority_law_cooldown"
				NOT = { has_variable = minority_law_cooldown }
			}
		}

		pass_cost = {
			prestige = medium_prestige_value
		}

		on_pass = {
			set_variable = {
				name = minority_law_cooldown
				years = @minority_law_cooldown_years
			}
		}

		ai_will_do = {
			value = -50

			# Factor for personality
			add = ai_zeal
			add = ai_vengefulness

			add = {
				value = ai_honor
				multiply = -1
			}
			add = {
				value = ai_compassion
				multiply = -1
			}
			if = {
				limit = {
					OR = {
						has_trait = holy_warrior
						has_trait = crusader_king
					}
				}
				add = 100
			}
			if = {
				limit = {
					faith = {
						has_doctrine = doctrine_pluralism_fundamentalist
					}
				}
				add = 25
			}
			if = {
				limit = {
					# Check to make sure that the HRE, ERE, theocrats and heads of faith are not going to be all uwu huggy wuggy with other faiths
					OR = {
						has_title = title:e_hre
						has_title = title:e_byzantium
						has_title = faith.religious_head_title
						has_government = theocracy_government
					}
				}
				add = 1000
			}
		}
	}
}

cultural_minority_status_law = {
	default = cultural_minority_status_2
	flag = religion_culture_law
	flag = culture_law

	# Laws only apply to other heritage cultures

	cultural_minority_status_1 = {

		modifier = {
			different_culture_opinion = 10
			same_culture_opinion = -5
			minority_opinion = 5
			courtly_opinion = -10
		}

		flag = cultural_minorities_may_grow
		flag = cultural_minorities_may_migrate

		can_have = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}
		can_keep = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}

		can_pass = {
			has_realm_law = cultural_minority_status_2
			custom_description = {
				subject = root
				text = "has_minority_law_cooldown"
				NOT = { has_variable = minority_law_cooldown }
			}
		}

		pass_cost = {
			prestige = medium_prestige_value
		}

		on_pass = {
			set_variable = {
				name = minority_law_cooldown
				years = @minority_law_cooldown_years
			}
		}

		ai_will_do = {
			value = 0
			# Factor for personality
			add = ai_honor
			add = ai_compassion

			add = {
				value = ai_zeal
				multiply = -1
			}
			add = {
				value = ai_vengefulness
				multiply = -1
			}
			if = {
				limit = {
					culture = {
						OR = {
							has_cultural_tradition = tradition_xenophilic
							has_cultural_parameter = cheaper_to_hybridize
						}
					}
				}
				add = 50
			}
		}
	}

	cultural_minority_status_2 = {

		modifier = {
			#different_culture_opinion = -10
			#same_culture_opinion = 5
			courtly_opinion = -5
		}

		flag = may_convert_culture
		flag = cultural_minorities_may_migrate

		should_start_with = { always = yes }

		can_have = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}
		can_keep = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}

		can_pass = {
			OR = {
				has_realm_law = cultural_minority_status_1
				has_realm_law = cultural_minority_status_3
			}
			custom_description = {
				subject = root
				text = "has_minority_law_cooldown"
				NOT = { has_variable = minority_law_cooldown }
			}
		}

		pass_cost = {
			prestige = medium_prestige_value
		}

		on_pass = {
			set_variable = {
				name = minority_law_cooldown
				years = @minority_law_cooldown_years
			}
		}

		ai_will_do = {
			value = 0

			if = {
				# Chance to be intolerant
				limit = { has_realm_law = cultural_minority_status_1 }
				add = -50

				# Factor for personality
				add = ai_zeal
				add = ai_vengefulness

				add = {
					value = ai_honor
					multiply = -1
				}
				add = {
					value = ai_compassion
					multiply = -1
				}
				if = {
					limit = {
						culture = {
							OR = {
								has_cultural_tradition = tradition_xenophilic
								has_cultural_parameter = cheaper_to_hybridize
							}
						}
					}
					add = 50
				}
			}
			else_if = {
				# Chance to be tolerant
				limit = { has_realm_law = cultural_minority_status_3 }
				add = 50

				# Factor for personality
				add = ai_honor
				add = ai_compassion

				add = {
					value = ai_zeal
					multiply = -1
				}
				add = {
					value = ai_vengefulness
					multiply = -1
				}
				if = {
					limit = {
						culture = {
							OR = {
								has_cultural_tradition = tradition_xenophilic
								has_cultural_parameter = cheaper_to_hybridize
							}
						}
					}
					add = 50
				}
			}
		}
	}

	cultural_minority_status_3 = {

		modifier = {
			different_culture_opinion = -10
			same_culture_opinion = 5
			minority_opinion = -5
			courtly_opinion = 5
		}

		flag = may_convert_culture
		flag = unlock_expel_cultural_minorities

		can_have = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}
		can_keep = {
			NOT = {	has_government = anarchist_government }
			is_landed = yes
		}

		can_pass = {
			has_realm_law = cultural_minority_status_2
			custom_description = {
				subject = root
				text = "has_minority_law_cooldown"
				NOT = { has_variable = minority_law_cooldown }
			}
		}

		pass_cost = {
			prestige = medium_prestige_value
		}

		on_pass = {
			set_variable = {
				name = minority_law_cooldown
				years = @minority_law_cooldown_years
			}
		}

		ai_will_do = {
			value = -50
			# Factor for personality
			add = ai_zeal
			add = ai_vengefulness

			add = {
				value = ai_honor
				multiply = -1
			}
			add = {
				value = ai_compassion
				multiply = -1
			}
			if = {
				limit = {
					culture = {
						OR = {
							has_cultural_tradition = tradition_xenophilic
							has_cultural_parameter = cheaper_to_hybridize
						}
					}
				}
				add = 50
			}
		}
	}
}
