#Scripted effects for estates

# Will apply effect if estate is present
# effect: Will apply effect to each estate present if defined
# <estate>_effect: Will apply effect to specific estate present if defined
each_estate_effect = {
	if = {
		limit = {
			has_estate = estate_brahmins
		}
		[[effect]
			$effect$
		]
		[[brahmins_effect]
			$brahmins_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_church
		}
		[[effect]
			$effect$
		]
		[[church_effect]
			$church_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_maratha
		}
		[[effect]
			$effect$
		]
		[[maratha_effect]
			$maratha_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_nobles
		}
		[[effect]
			$effect$
		]
		[[nobles_effect]
			$nobles_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_rajput
		}
		[[effect]
			$effect$
		]
		[[rajput_effect]
			$rajput_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_burghers
		}
		[[effect]
			$effect$
		]
		[[burghers_effect]
			$burghers_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_vaisyas
		}
		[[effect]
			$effect$
		]
		[[vaisyas_effect]
			$vaisyas_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_cossacks
		}
		[[effect]
			$effect$
		]
		[[cossacks_effect]
			$cossacks_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_nomadic_tribes
		}
		[[effect]
			$effect$
		]
		[[tribes_effect]
			$tribes_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_dhimmi
		}
		[[effect]
			$effect$
		]
		[[dhimmi_effect]
			$dhimmi_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_jains
		}
		[[effect]
			$effect$
		]
		[[jains_effect]
			$jains_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_janissaries
		}
		[[effect]
			$effect$
		]
		[[janissaries_effect]
			$janissaries_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_eunuchs
		}
		[[effect]
			$effect$
		]
		[[eunuchs_effect]
			$eunuchs_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_qizilbash
		}
		[[effect]
			$effect$
		]
		[[eunuchs_effect]
			$qizilbash_effect$
		]
	}
	if = {
		limit = {
			has_estate = estate_ghulams
		}
		[[effect]
			$effect$
		]
		[[eunuchs_effect]
			$ghulams_effect$
		]
	}
}

#Clergy
add_estate_church_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_church
		}
		add_estate_loyalty = {
			estate = estate_church
			loyalty = 10
		}
	}
	else_if = {
		limit = {
			religion = hinduism
			has_estate = estate_brahmins
		}
		add_estate_loyalty = {
			estate = estate_brahmins
			loyalty = 10
		}
	}
}
reduce_estate_church_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_church
		}
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -10
		}
	}
	else_if = {
		limit = {
			religion = hinduism
			has_estate = estate_brahmins
		}
		add_estate_loyalty = {
			estate = estate_brahmins
			loyalty = -10
		}
	}
}

#Dhimmi
add_estate_dhimmi_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_dhimmi
		}
		add_estate_loyalty = {
			estate = estate_dhimmi
			loyalty = 10
		}
	}
	else_if = {
		limit = {
			religion_group = muslim
			has_estate = estate_brahmins
		}
		add_estate_loyalty = {
			estate = estate_brahmins
			loyalty = 10
		}
	}
}
reduce_estate_dhimmi_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_dhimmi
		}
		add_estate_loyalty = {
			estate = estate_dhimmi
			loyalty = -10
		}
	}
	else_if = {
		limit = {
			religion_group = muslim
			has_estate = estate_brahmins
		}
		add_estate_loyalty = {
			estate = estate_brahmins
			loyalty = -10
		}
	}
}

#Nobles
add_estate_nobles_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_nobles
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = 10
		}
	}
	else_if = {
		limit = {
			has_estate = estate_rajput
		}
		add_estate_loyalty = {
			estate = estate_rajput
			loyalty = 10
		}
	}
	else_if = {
		limit = {
			has_estate = estate_maratha
		}
		add_estate_loyalty = {
			estate = estate_maratha
			loyalty = 10
		}
	}
}
reduce_estate_nobles_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_nobles
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -10
		}
	}
	else_if = {
		limit = {
			has_estate = estate_rajput
		}
		add_estate_loyalty = {
			estate = estate_rajput
			loyalty = -10
		}
	}
	else_if = {
		limit = {
			has_estate = estate_maratha
		}
		add_estate_loyalty = {
			estate = estate_maratha
			loyalty = -10
		}
	}
}

#Burghers
add_estate_burghers_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_burghers
		}
		add_estate_loyalty = {
			estate = estate_burghers
			loyalty = 10
		}
	}
	else_if = {
		limit = {
			has_estate = estate_vaisyas
		}
		add_estate_loyalty = {
			estate = estate_vaisyas
			loyalty = 10
		}
	}
	else_if = {
		limit = {
			has_estate = estate_jains
		}
		add_estate_loyalty = {
			estate = estate_jains
			loyalty = 10
		}
	}
}
reduce_estate_burghers_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_burghers
		}
		add_estate_loyalty = {
			estate = estate_burghers
			loyalty = -10
		}
	}
	else_if = {
		limit = {
			has_estate = estate_vaisyas
		}
		add_estate_loyalty = {
			estate = estate_vaisyas
			loyalty = -10
		}
	}
	else_if = {
		limit = {
			has_estate = estate_jains
		}
		add_estate_loyalty = {
			estate = estate_jains
			loyalty = -10
		}
	}
}

#Cossacks
add_estate_cossacks_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_cossacks
		}
		add_estate_loyalty = {
			estate = estate_cossacks
			loyalty = 10
		}
	}
}
reduce_estate_cossacks_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_cossacks
		}
		add_estate_loyalty = {
			estate = estate_cossacks
			loyalty = -10
		}
	}
}

#Jains
add_estate_jains_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_jains
		}
		add_estate_loyalty = {
			estate = estate_jains
			loyalty = 10
		}
	}
}
reduce_estate_jains_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_jains
		}
		add_estate_loyalty = {
			estate = estate_jains
			loyalty = -10
		}
	}
}

#Rajput
add_estate_rajput_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_rajput
		}
		add_estate_loyalty = {
			estate = estate_rajput
			loyalty = 10
		}
	}
}
reduce_estate_rajput_loyalty_effect = {
	if = {
		limit = {
			has_estate = estate_rajput
		}
		add_estate_loyalty = {
			estate = estate_rajput
			loyalty = -10
		}
	}
}


#Estate Privilege on_action effects

on_religion_change_estate_privileges_effect = {
	if = {
		limit = {
			OR = {
				AND = {
					NOT = { has_estate_privilege = estate_dhimmi_guaranteed_autonomy }
					NOT = { has_estate_privilege = estate_dhimmi_guarantee_of_traditions }
				}
				NOT = { religion_group = muslim }
			}
			any_owned_province = { has_province_modifier = estate_dhimmi_guaranteed_autonomy_mod }
		}
		every_owned_province = {
			limit = {
				has_province_modifier = estate_dhimmi_guaranteed_autonomy_mod
			}
			remove_province_modifier = estate_dhimmi_guaranteed_autonomy_mod
		}
	}
	if = {
		limit = {
			OR = {
				has_estate_privilege = estate_church_one_faith_one_culture
				has_estate_privilege = estate_brahmins_one_faith_one_culture
			}
		}
		every_owned_province = {
			limit = {
				has_province_modifier = estate_church_united_faith_and_culture
				NOT = { religion = ROOT }
			}
			remove_province_modifier = estate_church_united_faith_and_culture
		}
		every_owned_province = {
			limit = {				
				NOT = { has_province_modifier = estate_church_united_faith_and_culture }
				religion = ROOT
				OR = {
					culture_group = ROOT
					has_owner_accepted_culture = yes
				}
			}
			add_province_modifier = {
				name = estate_church_united_faith_and_culture
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_janissary_strict_devshirme_recruitment
			}
		}
		if = {
			limit = {
				owner = { NOT = { religion_group = ROOT } }
			}
			add_province_modifier = {
				name = estate_janissary_strict_devshirme_recruitment_mod
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_muslim_integration
			}
		}
		if = {
			limit = { religion_group = muslim }
			add_province_modifier = {
				name = estate_church_muslim_integration_mod
				duration = -1
			}
		}
		else = {
			remove_province_modifier = estate_church_muslim_integration_mod
		}
	}
}

on_secondary_religion_change_estate_privileges_effect = {
	#For whatever unholy reason, the trigger owner = { secondary_religion = PREV } for every owned province does not work in this scripted effect
	#Because of that this event workaround had to be made in order to update the religious cultures
	country_event = {
		id = passive_effects_events.10
	}
}

on_harmonized_religion_estate_privileges_effect = {
	if = {
		limit = {
			OR = {
				has_estate_privilege = estate_church_one_faith_one_culture
				has_estate_privilege = estate_brahmins_one_faith_one_culture
			}
		}
		every_owned_province = {
			limit = {
				has_province_modifier = estate_church_united_faith_and_culture
				NOT = { religion = ROOT }
				owner = { NOT = { has_harmonized_with = PREV } }
			}
			remove_province_modifier = estate_church_united_faith_and_culture
		}
		every_owned_province = {
			limit = {				
				NOT = { has_province_modifier = estate_church_united_faith_and_culture }
				owner = {
					OR = {
						religion = PREV
						has_harmonized_with = PREV
					}
				}
				OR = {
					culture_group = ROOT
					has_owner_accepted_culture = yes
				}
			}
			add_province_modifier = {
				name = estate_church_united_faith_and_culture
				duration = -1
			}
		}
	}
}

on_annexed_estate_privileges_effect = {
	if = {
		limit = {
			from = {
				NOT = { religion = root }
			}
		}
		add_country_modifier = {
			name = recently_annexed_other_religion_timer
			duration = 5475
			hidden = yes
		}
	}
}

on_province_religion_converted_estate_privileges_effect = {
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_dhimmi_lighter_dhimmi_taxes
			}
		}
		if = {
			limit = {
				NOT = { religion_group = muslim }
				NOT = { has_province_modifier = estate_dhimmi_lighter_dhimmi_taxes_privilege_mod }
			}
			add_province_modifier = {
				name = estate_dhimmi_lighter_dhimmi_taxes_privilege_mod
				duration = -1
			}
		}
		else_if = {
			limit = {
				religion_group = muslim
				has_province_modifier = estate_dhimmi_lighter_dhimmi_taxes_privilege_mod
			}
			remove_province_modifier = estate_dhimmi_lighter_dhimmi_taxes_privilege_mod
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_dhimmi_manpower
			}
		}
		if = {
			limit = {
				NOT = { religion_group = muslim }
				NOT = { has_province_modifier = estate_dhimmi_manpower_mod }
			}
			add_province_modifier = {
				name = estate_dhimmi_manpower_mod
				duration = -1
			}
		}
		else_if = {
			limit = {
				religion_group = muslim
				has_province_modifier = estate_dhimmi_manpower_mod
			}
			remove_province_modifier = estate_dhimmi_manpower_mod
		}
	}
	if = {
		limit = {
			owner = {
				has_country_flag = dhimmi_tolerates_wrong_religion
			}
		}
		if = {
			limit = {
				NOT = { religion_group = muslim }
				NOT = { has_province_modifier = estate_dhimmi_guaranteed_autonomy_mod }
			}
			add_province_modifier = {
				name = estate_dhimmi_guaranteed_autonomy_mod
				duration = -1
			}
		}
		else_if = {
			limit = {
				religion_group = muslim
				has_province_modifier = estate_dhimmi_guaranteed_autonomy_mod
			}
			remove_province_modifier = estate_dhimmi_guaranteed_autonomy_mod
		}
	}
	if = {
		limit = {
			owner = {
				has_country_flag = burghers_tolerates_orthodoxy
			}
		}
		if = {
			limit = {
				OR = {
					religion = orthodox
					religion = coptic
				}
				NOT = { has_province_modifier = estate_burghers_guaranteed_autonomy_mod }
			}
			add_province_modifier = {
				name = estate_burghers_guaranteed_autonomy_mod
				duration = -1
			}
		}
		else_if = {
			limit = {
				NOT = { religion = orthodox }
				NOT = { religion = coptic }
				has_province_modifier = estate_burghers_guaranteed_autonomy_mod
			}
			remove_province_modifier = estate_burghers_guaranteed_autonomy_mod
		}
	}
	if = {
		limit = {
			owner = {
				has_country_flag = gets_manpower_from_tax_buildings
			}
		}
		if = {
			limit = {
				has_owner_religion = yes
				has_building = cathedral
				NOT = { has_province_modifier = estate_nobles_religious_conscription_cathedral }
			}
			add_province_modifier = {
				name = estate_nobles_religious_conscription_cathedral
				duration = -1
			}
			remove_province_modifier = estate_nobles_religious_conscription_temple
		}
		else_if = {
			limit = {
				has_owner_religion = yes
				has_building = temple
				NOT = { has_province_modifier = estate_nobles_religious_conscription_temple }
			}
			add_province_modifier = {
				name = estate_nobles_religious_conscription_temple
				duration = -1
			}
			remove_province_modifier = estate_nobles_religious_conscription_cathedral
		}
		else_if = {
			limit = {
				OR = {
					has_province_modifier = estate_nobles_religious_conscription_temple
					has_province_modifier = estate_nobles_religious_conscription_cathedral
				}
			}
			remove_province_modifier = estate_nobles_religious_conscription_temple
			remove_province_modifier = estate_nobles_religious_conscription_cathedral
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_brahmins_guaranteed_autonomy
			}
		}
		if = {
			limit = {
				religion_group = dharmic
				NOT = { has_province_modifier = estate_brahmins_guaranteed_autonomy_mod }
			}
			add_province_modifier = {
				name = estate_brahmins_guaranteed_autonomy_mod
				duration = -1
			}
		}
		else_if = {
			limit = {
				NOT = { religion_group = dharmic }
				has_province_modifier = estate_brahmins_guaranteed_autonomy_mod
			}
			remove_province_modifier = estate_brahmins_guaranteed_autonomy_mod
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_brahmins_at_court
			}
		}
		if = {
			limit = {
				religion_group = dharmic
				NOT = { has_province_modifier = estate_brahmins_guaranteed_autonomy_mod }
			}
			add_province_modifier = {
				name = estate_brahmins_guaranteed_autonomy_mod
				duration = -1
			}
		}
		else_if = {
			limit = {
				NOT = { religion_group = dharmic }
				has_province_modifier = estate_brahmins_guaranteed_autonomy_mod
			}
			remove_province_modifier = estate_brahmins_guaranteed_autonomy_mod
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_lao_animism
			}
		}
		if = {
			limit = {
				religion = animism
				NOT = { has_province_modifier = estate_church_lao_animism_mod }
			}
		}
		else_if = {
			limit = {
				NOT = { religion = animism }
				has_province_modifier = estate_church_lao_animism_mod
			}
			remove_province_modifier = estate_church_lao_animism_mod
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_maratha_levies_for_muslims
			}
		}
		if = {
			limit = {
				religion = hinduism
			}
			add_province_modifier = {
				name = estate_maratha_levies_for_muslims_mod
				duration = -1
			}
		}
		else_if = {
			limit = {
				has_province_modifier = estate_maratha_levies_for_muslims_mod
			}
			remove_province_modifier = estate_maratha_levies_for_muslims_mod
		}
	}
	if = {
		limit = {
			owner = {
				OR = {
					has_estate_privilege = estate_church_one_faith_one_culture
					has_estate_privilege = estate_brahmins_one_faith_one_culture
				}
			}
		}
		if = {
			limit = {
				owner = {
					OR = {
						religion = ROOT
						has_harmonized_with = ROOT
						secondary_religion = ROOT
					}
					OR = {
						culture_group = ROOT
						accepted_culture = ROOT
					}
				}
			}
			add_province_modifier = {
				name = estate_church_united_faith_and_culture
				duration = -1
			}
		}
		if = {
			limit = {
				owner = {
					NOT = { culture_group = ROOT }
					NOT = { accepted_culture = ROOT }
				}
			}
			add_province_modifier = {
				name = estate_church_false_culture
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_dhimmi_millet_system
			}
		}
		if = {
			limit = {
				OR = {
					religion_group = christian
					religion_group = jewish_group
				}
			}
			add_province_modifier = {
				name = estate_dhimmi_millet_system_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_dhimmi_millet_system_mod }
				remove_province_modifier = estate_dhimmi_millet_system_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_development_of_temples
			}
		}
		if = {
			limit = {
				has_tax_building_trigger = yes
				OR = {
					has_owner_religion = yes
					has_owner_harmonized_religion = yes
					has_owner_secondary_religion = yes
				}
			}
			add_province_modifier = {
				name = estate_church_development_of_temples_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_church_development_of_temples_mod }
				remove_province_modifier = estate_church_development_of_temples_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_brahmins_development_of_temples
			}
		}
		if = {
			limit = {
				religion_group = dharmic
				has_tax_building_trigger = yes
			}
			add_province_modifier = {
				name = estate_brahmins_development_of_temples_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_brahmins_development_of_temples_mod }
				remove_province_modifier = estate_brahmins_development_of_temples_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_dhimmi_development_of_communities
			}
			has_tax_building_trigger = yes
		}
		if = {
			limit = {
				NOT = { religion_group = ROOT }
			}
			add_province_modifier = {
				name = estate_nomadic_tribes_freedom_of_the_steppes_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_nomadic_tribes_freedom_of_the_steppes_mod }
				remove_province_modifier = estate_nomadic_tribes_freedom_of_the_steppes_mod
			}
		}
	}
}

on_province_culture_converted_estate_privilges_effect = {
	if = {
		limit = { 
			owner = {
				has_estate_privilege = estate_nobles_reformatio_sigismundi
			}
			has_province_modifier = boh_cultural_integration 
			NOT = { culture_group = germanic }
		}
		remove_province_modifier = boh_cultural_integration
	}
	if = {
		limit = {
			owner = {
				OR = {
					has_estate_privilege = estate_church_one_faith_one_culture
					has_estate_privilege = estate_brahmins_one_faith_one_culture
				}
			}
		}
		if = {
			limit = {
				owner = {
					OR = {
						accepted_culture = ROOT
						culture_group = ROOT
					}
					OR = {
						religion = ROOT
						has_harmonized_with = ROOT
						secondary_religion = ROOT
					}
				}
			}
			if = {
				limit = {
					has_province_modifier = estate_church_false_culture
				}
				remove_province_modifier = estate_church_false_culture
			}
			add_province_modifier = {
				name = estate_church_united_faith_and_culture
				duration = -1
			}
		}
		if = {
			limit = {
				owner = {
					NOT = { culture_group = ROOT }
					NOT = { accepted_culture = ROOT }
				}
			}
			if = {
				limit = {
					has_province_modifier = estate_church_united_faith_and_culture
				}
				remove_province_modifier = estate_church_united_faith_and_culture
			}
			add_province_modifier = {
				name = estate_church_false_culture
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_maratha_development_of_marathi_lands
			}
		}
		if = {
			limit = {
				OR = {
					culture_group = western_aryan
					culture_group = dravidian
					culture = sinhala
				}
				NOT = { culture = rajput }
				NOT = { culture = malvi }
			}
			add_province_modifier = {
				name = estate_maratha_development_of_marathi_lands_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_maratha_development_of_marathi_lands_mod }
				remove_province_modifier = estate_maratha_development_of_marathi_lands_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_rajput_development_of_rajput_lands
			}
		}
		if = {
			limit = {
				OR = {
					culture = rajput
					culture = malvi
					AND = {
						culture_group = eastern_aryan
						NOT = { culture = sinhala }
					}
					culture_group = hindusthani
					culture_group = central_indic
				}
			}
			add_province_modifier = {
				name = estate_maratha_development_of_marathi_lands_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_rajput_development_of_rajput_lands_mod }
				remove_province_modifier = estate_rajput_development_of_rajput_lands_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_ghulams_ensure_caucasian_sovereignty
			}
		}
		if = {
			limit = { culture_group = caucasian }
			add_province_modifier = {
				name = estate_ghulams_ensure_caucasian_sovereignty_mod
				duration = -1
			}
		}
		else = {
			remove_province_modifier = estate_ghulams_ensure_caucasian_sovereignty_mod
		}
	}
}

on_province_owner_change_estate_privileges_effect = {
	if = {
		limit = { has_terrain = steppe }
		if = {
			limit = { owner = { has_estate_privilege = estate_cossacks_prime_herding_rights } }
			add_province_modifier = {
				name = estate_cossacks_prime_herding_rights_mod
				duration = -1
			}
			if = {
				limit = { owner = { has_country_flag = feo_upgrade_prime_herding_rights_flag } }
				add_province_modifier = {
					name = feo_upgrade_prime_herding_rights_mod
					duration = -1
				}
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_cossacks_prime_herding_rights_mod }
				remove_province_modifier = estate_cossacks_prime_herding_rights_mod
			}
			if = {
				limit = { has_province_modifier = feo_upgrade_prime_herding_rights_mod }
				remove_province_modifier = feo_upgrade_prime_herding_rights_mod
			}
		}
		if = {
			limit = { owner = { has_estate_privilege = estate_cossacks_exploration_expedition } }
			add_province_modifier = {
				name = estate_cossacks_exploration_expedition_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_cossacks_exploration_expedition_mod }
				remove_province_modifier = estate_cossacks_exploration_expedition_mod
			}
		}
		if = {
			limit = { owner = { has_estate_privilege = estate_cossacks_exempt_from_bureaucracy has_country_flag = feo_cossack_self_governance_buff_flag } }
			add_province_modifier = {
				name = feo_cossack_self_governance_buff_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = feo_cossack_self_governance_buff_mod }
				remove_province_modifier = feo_cossack_self_governance_buff_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_dhimmi_lighter_dhimmi_taxes
			}
			NOT = { religion_group = muslim }
		}
		add_province_modifier = {
			name = estate_dhimmi_lighter_dhimmi_taxes_privilege_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_dhimmi_manpower
			}
			NOT = { religion_group = muslim }
		}
		add_province_modifier = {
			name = estate_dhimmi_manpower_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_country_flag = dhimmi_tolerates_wrong_religion
			}
			NOT = { religion_group = muslim }
		}
		add_province_modifier = {
			name = estate_dhimmi_guaranteed_autonomy_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_country_flag = burghers_tolerates_orthodoxy
			}
			OR = {
				religion = orthodox
				religion = coptic
			}
		}
		add_province_modifier = {
			name = estate_burghers_guaranteed_autonomy_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_country_flag = gets_manpower_from_tax_buildings
			}
		}
		if = {
			limit = {
				has_owner_religion = yes
				has_building = cathedral
				NOT = { has_province_modifier = estate_nobles_religious_conscription_cathedral }
			}
			add_province_modifier = {
				name = estate_nobles_religious_conscription_cathedral
				duration = -1
			}
			remove_province_modifier = estate_nobles_religious_conscription_temple
		}
		else_if = {
			limit = {
				has_owner_religion = yes
				has_building = temple
				NOT = { has_province_modifier = estate_nobles_religious_conscription_temple }
			}
			add_province_modifier = {
				name = estate_nobles_religious_conscription_temple
				duration = -1
			}
			remove_province_modifier = estate_nobles_religious_conscription_cathedral
		}
		else_if = {
			limit = {
				OR = {
					has_province_modifier = estate_nobles_religious_conscription_temple
					has_province_modifier = estate_nobles_religious_conscription_cathedral
				}
			}
			remove_province_modifier = estate_nobles_religious_conscription_temple
			remove_province_modifier = estate_nobles_religious_conscription_cathedral
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_brahmins_guaranteed_autonomy
			}
			religion_group = dharmic
		}
		add_province_modifier = {
			name = estate_brahmins_guaranteed_autonomy_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_brahmins_at_court
			}
			religion_group = dharmic
		}
		add_province_modifier = {
			name = estate_brahmins_guaranteed_autonomy_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_the_great_privilege
			}
			region = low_countries_region
		}
		add_province_modifier = {
			name = estate_burghers_the_great_privilege_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_monopoly_of_textiles
			}
			OR = {
				trade_goods = cloth
				trade_goods = silk
			}
		}
		add_province_modifier = {
			name = estate_burghers_monopoly_of_textiles_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_vaisyas_monopoly_of_textiles
			}
			OR = {
				trade_goods = cloth
				trade_goods = silk
			}
		}
		add_province_modifier = {
			name = estate_vaisyas_monopoly_of_textiles_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_jains_monopoly_of_textiles
			}
			OR = {
				trade_goods = cloth
				trade_goods = silk
			}
		}
		add_province_modifier = {
			name = estate_jains_monopoly_of_textiles_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_monopoly_of_dyes
			}
			trade_goods = dyes
		}
		add_province_modifier = {
			name = estate_burghers_monopoly_of_dyes_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_vaisyas_monopoly_of_dyes
			}
			trade_goods = dyes
		}
		add_province_modifier = {
			name = estate_vaisyas_monopoly_of_dyes_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_jains_monopoly_of_dyes
			}
			trade_goods = dyes
		}
		add_province_modifier = {
			name = estate_jains_monopoly_of_dyes_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_monopoly_of_glass
			}
			trade_goods = glass
		}
		add_province_modifier = {
			name = estate_burghers_monopoly_of_glass_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_vaisyas_monopoly_of_glass
			}
			trade_goods = glass
		}
		add_province_modifier = {
			name = estate_vaisyas_monopoly_of_glass_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_jains_monopoly_of_glass
			}
			trade_goods = glass
		}
		add_province_modifier = {
			name = estate_jains_monopoly_of_glass_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_monopoly_of_paper
			}
			trade_goods = paper
		}
		add_province_modifier = {
			name = estate_burghers_monopoly_of_paper_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_vaisyas_monopoly_of_paper
			}
			trade_goods = paper
		}
		add_province_modifier = {
			name = estate_vaisyas_monopoly_of_paper_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_jains_monopoly_of_paper
			}
			trade_goods = paper
		}
		add_province_modifier = {
			name = estate_jains_monopoly_of_paper_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_monopoly_of_incense
			}
			trade_goods = incense
		}
		add_province_modifier = {
			name = estate_church_monopoly_of_incense_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_brahmins_monopoly_of_incense
			}
			trade_goods = incense
		}
		add_province_modifier = {
			name = estate_brahmins_monopoly_of_incense_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_monopoly_of_wool
			}
			trade_goods = wool
		}
		add_province_modifier = {
			name = estate_church_monopoly_of_wool_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_brahmins_monopoly_of_wool
			}
			trade_goods = wool
		}
		add_province_modifier = {
			name = estate_brahmins_monopoly_of_wool_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_monopoly_of_wine
			}
			trade_goods = wine
		}
		add_province_modifier = {
			name = estate_church_monopoly_of_wine_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_monopoly_of_slaves
			}
			trade_goods = slaves
		}
		add_province_modifier = {
			name = estate_church_monopoly_of_slaves_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_nobles_monopoly_of_metals
			}
			OR = {
				trade_goods = iron
				trade_goods = copper
			}
		}
		add_province_modifier = {
			name = estate_nobles_monopoly_of_metals_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_rajput_monopoly_of_metals
			}
			OR = {
				trade_goods = iron
				trade_goods = copper
			}
		}
		add_province_modifier = {
			name = estate_rajput_monopoly_of_metals_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_maratha_monopoly_of_metals
			}
			OR = {
				trade_goods = iron
				trade_goods = copper
			}
		}
		add_province_modifier = {
			name = estate_maratha_monopoly_of_metals_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_nobles_monopoly_of_livestock
			}
			trade_goods = livestock
		}
		add_province_modifier = {
			name = estate_nobles_monopoly_of_livestock_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_rajput_monopoly_of_livestock
			}
			trade_goods = livestock
		}
		add_province_modifier = {
			name = estate_rajput_monopoly_of_livestock_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_maratha_monopoly_of_livestock
			}
			trade_goods = livestock
		}
		add_province_modifier = {
			name = estate_maratha_monopoly_of_livestock_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_nobles_monopoly_of_gems
			}
			trade_goods = gems
		}
		add_province_modifier = {
			name = estate_nobles_monopoly_of_gems_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_rajput_monopoly_of_gems
			}
			trade_goods = gems
		}
		add_province_modifier = {
			name = estate_rajput_monopoly_of_gems_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_maratha_monopoly_of_gems
			}
			trade_goods = gems
		}
		add_province_modifier = {
			name = estate_maratha_monopoly_of_gems_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_YEM_coffee_monopoly
			}
			trade_goods = coffee
		}
		add_province_modifier = {
			name = estate_burghers_YEM_coffee_monopoly_mod
			duration = -1
		}
	}
	if = {
		limit = {
			trade_goods = grain
			owner = {
				OR = {
					has_estate_privilege = estate_burghers_khmer_irrigation
					has_estate_privilege = estate_vaisyas_khmer_irrigation
				}
			}
		}
		add_province_modifier = {
			name = estate_burghers_khmer_irrigation_mod
			duration = -1
		}
	}
	if = {
		limit = {
			has_climate = tropical
			owner = {
				has_estate_privilege = estate_burghers_tropical_nation
			}
		}
		add_province_modifier = {
			name = estate_burghers_tropical_mod
			duration = -1
		}
	}
	if = {
		limit = {
			has_climate = arid
			owner = {
				has_estate_privilege = estate_burghers_ARB_oasis_development
			}
		}
		add_province_modifier = {
			name = ARB_estate_burghers_arid_climate_development
			duration = -1
		}
	}
	if = {
		limit = {
			OR = {
				has_terrain = desert
				has_terrain = coastal_desert
			}
			owner = {
				has_estate_privilege = estate_burghers_ARB_oasis_development
			}
		}
		add_province_modifier = {
			name = ARB_estate_burghers_desert
			duration = -1
		}
	}
	if = {
		limit = {
			religion = animism
			owner = {
				has_estate_privilege = estate_church_lao_animism
			}
		}
		add_province_modifier = {
			name = estate_church_lao_animism_mod
			duration = -1
		}
	}
	if = {
		limit = {
			religion = hinduism
			owner = {
				has_estate_privilege = estate_maratha_levies_for_muslims
			}
		}
		add_province_modifier = {
			name = estate_maratha_levies_for_muslims_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				OR = {
					has_estate_privilege = estate_church_one_faith_one_culture
					has_estate_privilege = estate_brahmins_one_faith_one_culture
				}
			}
		}
		if = {
			limit = {
				owner = {
					OR = {
						religion = ROOT
						has_harmonized_with = ROOT
						secondary_religion = ROOT
					}
					OR = {
						culture_group = ROOT
						accepted_culture = ROOT
					}
				}
			}
			add_province_modifier = {
				name = estate_church_united_faith_and_culture
				duration = -1
			}
		}
		if = {
			limit = {
				owner = {
					NOT = { culture_group = ROOT }
					NOT = { accepted_culture = ROOT }
				}
			}
			add_province_modifier = {
				name = estate_church_false_culture
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_hydraulic_rights
			}
		}
		if = {
			limit = {
				has_terrain = desert
			}
			add_province_modifier = {
				name = estate_burghers_hydraulic_rights_desert
				duration = -1
			}
		}
		if = {
			limit = {
				has_terrain = coastal_desert
			}
			add_province_modifier = {
				name = estate_burghers_hydraulic_rights_coastal_desert
				duration = -1
			}
		}
		if = {
			limit = {
				has_terrain = steppe
			}
			add_province_modifier = {
				name = estate_burghers_hydraulic_rights_steppes
				duration = -1
			}
		}
		if = {
			limit = {
				has_terrain = savannah
			}
			add_province_modifier = {
				name = estate_burghers_hydraulic_rights_savanna
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_forest_expansion
			}
		}
		if = {
			limit = {
				has_terrain = forest
			}
			add_province_modifier = {
				name = estate_burghers_forest_expansion_forest
				duration = -1
			}
		}
		if = {
			limit = {
				has_terrain = woods
			}
			add_province_modifier = {
				name = estate_burghers_forest_expansion_woods
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_mountain_expansion
			}
		}
		if = {
			limit = {
				has_terrain = mountain
			}
			add_province_modifier = {
				name = estate_burghers_mountain_expansion_mountains
				duration = -1
			}
		}
		if = {
			limit = {
				has_terrain = highlands
			}
			add_province_modifier = {
				name = estate_burghers_mountain_expansion_highlands
				duration = -1
			}
		}
		if = {
			limit = {
				has_terrain = hills
			}
			add_province_modifier = {
				name = estate_burghers_mountain_expansion_hills
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_janissary_strict_devshirme_recruitment
			}
		}
		if = {
			limit = {
				owner = { NOT = { religion_group = ROOT } }
			}
			add_province_modifier = {
				name = estate_janissary_strict_devshirme_recruitment_mod
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_MAY_tropical_adaptation
			}
			has_terrain = jungle
		}
		if = {
			limit = {
				owner = { has_country_flag = MAY_upgraded_privilege }
			}
			add_province_modifier = {
				name = MAY_jungle_reduction_upgrade
				duration = -1
			}
		}
		else = {
			add_province_modifier = {
				name = MAY_jungle_reduction
				duration = -1
			}
		}
	}
	if = {
		limit = {
			owner = { has_estate_privilege = estate_burghers_INC_mountain_development }
		}
        if = {
            limit = { owner = { has_country_flag = INC_upgrade_mountain_development_privilege_flag } }
            if = {
                limit = { has_terrain = mountain }
                add_province_modifier = { name = estate_burghers_mountain_expansion_upgrade_mountains duration = -1 }
            }
            else_if = {
                limit = { has_terrain = highlands }
                add_province_modifier = { name = estate_burghers_mountain_expansion_upgrade_highlands duration = -1 }
            }
            else_if = {
                limit = { has_terrain = hills }
                add_province_modifier = { name = estate_burghers_mountain_expansion_upgrade_hills duration = -1 }
            }
            else = { 
                add_province_modifier = { name = estate_burghers_mountain_expansion_penalty duration = -1 }
            }
        }
        else = {
            if = {
                limit = { has_terrain = mountain }
                add_province_modifier = { name = estate_burghers_mountain_expansion_mountains duration = -1 }
            }
            else_if = {
                limit = { has_terrain = highlands }
                add_province_modifier = { name = estate_burghers_mountain_expansion_highlands duration = -1 }
            }
            else_if = {
                limit = { has_terrain = hills }
                add_province_modifier = { name = estate_burghers_mountain_expansion_hills duration = -1 }
            }
            else = { 
                add_province_modifier = { name = estate_burghers_mountain_expansion_penalty duration = -1 }
            }
        }
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_dhimmi_millet_system
			}
		}
		if = {
			limit = {
				OR = {
					religion_group = christian
					religion_group = jewish_group
				}
			}
			add_province_modifier = {
				name = estate_dhimmi_millet_system_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_dhimmi_millet_system_mod }
				remove_province_modifier = estate_dhimmi_millet_system_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_church_development_of_temples
			}
		}
		if = {
			limit = {
				has_tax_building_trigger = yes
				OR = {
					has_owner_religion = yes
					has_owner_harmonized_religion = yes
					has_owner_secondary_religion = yes
				}
			}
			add_province_modifier = {
				name = estate_church_development_of_temples_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_church_development_of_temples_mod }
				remove_province_modifier = estate_church_development_of_temples_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_brahmins_development_of_temples
			}
		}
		if = {
			limit = {
				religion_group = dharmic
				has_tax_building_trigger = yes
			}
			add_province_modifier = {
				name = estate_brahmins_development_of_temples_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_brahmins_development_of_temples_mod }
				remove_province_modifier = estate_brahmins_development_of_temples_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_development_of_cities
			}
		}
		if = {
			limit = {
				OR = {
					province_has_center_of_trade_of_level = 1
					has_river_estuary_trigger = yes
				}
			}
			add_province_modifier = {
				name = estate_burghers_development_of_cities_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_burghers_development_of_cities_mod }
				remove_province_modifier = estate_burghers_development_of_cities_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_cossacks_freedom_of_the_steppes
			}
		}
		if = {
			limit = {
				has_terrain = steppe
			}
			add_province_modifier = {
				name = estate_cossacks_freedom_of_the_steppes_mod
				duration = -1
			}
			if = {
				limit = { owner = { has_country_flag = feo_buffed_freedom_of_steppes_flag } }
				add_province_modifier = {
					name = feo_buffed_freedom_of_steppes_mod
					duration = -1
				}
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_cossacks_freedom_of_the_steppes_mod }
				remove_province_modifier = estate_cossacks_freedom_of_the_steppes_mod
			}
			if = {
				limit = { has_province_modifier = feo_buffed_freedom_of_steppes_mod }
				remove_province_modifier = feo_buffed_freedom_of_steppes_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_nomadic_tribes_freedom_of_the_steppes
			}
		}
		if = {
			limit = {
				has_terrain = steppe
			}
			add_province_modifier = {
				name = estate_nomadic_tribes_freedom_of_the_steppes_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_nomadic_tribes_freedom_of_the_steppes_mod }
				remove_province_modifier = estate_nomadic_tribes_freedom_of_the_steppes_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_dhimmi_development_of_communities
			}
			has_tax_building_trigger = yes
		}
		if = {
			limit = {
				NOT = { religion_group = ROOT }
			}
			add_province_modifier = {
				name = estate_nomadic_tribes_freedom_of_the_steppes_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_nomadic_tribes_freedom_of_the_steppes_mod }
				remove_province_modifier = estate_nomadic_tribes_freedom_of_the_steppes_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_vaisyas_development_of_cities
			}
		}
		if = {
			limit = {
				OR = {
					province_has_center_of_trade_of_level = 1
					has_river_estuary_trigger = yes
				}
			}
			add_province_modifier = {
				name = estate_vaisyas_development_of_cities_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_vaisyas_development_of_cities_mod }
				remove_province_modifier = estate_vaisyas_development_of_cities_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_jains_development_of_cities
			}
		}
		if = {
			limit = {
				OR = {
					province_has_center_of_trade_of_level = 1
					has_river_estuary_trigger = yes
				}
			}
			add_province_modifier = {
				name = estate_jains_development_of_cities_mod
				duration = -1
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = estate_jains_development_of_cities_mod }
				remove_province_modifier = estate_jains_development_of_cities_mod
			}
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_burghers_great_works_of_iran
			}
		}
		if = {
			limit = {
				OR = {
					region = persia_region
					region = khorasan_region
				}
			}
			if = {
				limit = { has_terrain = mountain }
				add_province_modifier = { name = turkoman_privilege_mountains duration = -1 }
			}
			if = {
				limit = { has_terrain = highlands }
				add_province_modifier = { name = turkoman_privilege_highlands duration = -1 }
			}
			if = {
				limit = { has_terrain = desert }
				add_province_modifier = { name = turkoman_privilege_desert duration = -1 }
			}
			if = {
				limit = { has_terrain = drylands }
				add_province_modifier = { name = turkoman_privilege_drylands duration = -1 }
			}
		}
		else = {
			if = {
				limit = { has_province_modifier = turkoman_privilege_mountains }
				remove_province_modifier = turkoman_privilege_mountains
			}
			if = {
				limit = { has_province_modifier = turkoman_privilege_highlands }
				remove_province_modifier = turkoman_privilege_highlands
			}
			if = {
				limit = { has_province_modifier = turkoman_privilege_desert }
				remove_province_modifier = turkoman_privilege_desert
			}
			if = {
				limit = { has_province_modifier = turkoman_privilege_drylands }
				remove_province_modifier = turkoman_privilege_drylands
			}
		}
	}
	if = {
		limit = {
			owner = {
				OR = {
					has_estate_privilege = estate_nobles_mamlukian_administration
					has_estate_privilege = estate_ghulams_mamlukian_administration
					has_estate_privilege = estate_qizilbash_mamlukian_administration
				}
			}
			region = egypt_region
		}
		add_province_modifier = {
			name = mamlukian_administration_modifier
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_ghulams_ensure_caucasian_sovereignty
			}
		}
		if = {
			limit = { culture_group = caucasian }
			add_province_modifier = {
				name = estate_ghulams_ensure_caucasian_sovereignty_mod
				duration = -1
			}
		}
		else = {
			remove_province_modifier = estate_ghulams_ensure_caucasian_sovereignty_mod
		}
	}
}

on_province_tax_building_built_estate_privileges_effect = {
	if = {
		limit = {
			FROM = {
				OR = {
					religion = buddhism
					religion = mahayana
					religion = vajrayana
				}
				has_estate_privilege = estate_church_karma_temples
			}
		}
		FROM = {
			if = {
				limit = {
					has_government_attribute = buffed_monastic_temples
				}
				add_karma = 5
			}
			else = {
				add_karma = 3
			}
		}
	}
	if = {
		limit = {
			FROM = {
				religion = catholic
				has_estate_privilege = estate_church_influence_temples
			}
		}
		FROM = {
			add_papal_influence = 3
		}
	}
	if = {
		limit = {
			owner = {
				has_country_flag = gets_manpower_from_tax_buildings
			}
		}
		if = {
			limit = {
				has_owner_religion = yes
				has_building = cathedral
				NOT = { has_province_modifier = estate_nobles_religious_conscription_cathedral }
			}
			add_province_modifier = {
				name = estate_nobles_religious_conscription_cathedral
				duration = -1
			}
			remove_province_modifier = estate_nobles_religious_conscription_temple
		}
		else_if = {
			limit = {
				has_owner_religion = yes
				has_building = temple
				NOT = { has_province_modifier = estate_nobles_religious_conscription_temple }
			}
			add_province_modifier = {
				name = estate_nobles_religious_conscription_temple
				duration = -1
			}
			remove_province_modifier = estate_nobles_religious_conscription_cathedral
		}
		else_if = {
			limit = {
				OR = {
					has_province_modifier = estate_nobles_religious_conscription_temple
					has_province_modifier = estate_nobles_religious_conscription_cathedral
				}
			}
			remove_province_modifier = estate_nobles_religious_conscription_temple
			remove_province_modifier = estate_nobles_religious_conscription_cathedral
		}
	}
	if = {
		limit = {
			owner = { has_estate_privilege = estate_church_development_of_temples }
			OR = {
				has_owner_religion = yes
				has_owner_harmonized_religion = yes
				has_owner_secondary_religion = yes
			}
		}
		add_province_modifier = {
			name = estate_church_development_of_temples_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = { has_estate_privilege = estate_brahmins_development_of_temples }
			religion_group = dharmic
			has_tax_building_trigger = yes
		}
		add_province_modifier = {
			name = estate_brahmins_development_of_temples_mod
			duration = -1
		}
	}
	if = {
		limit = {
			owner = {
				has_estate_privilege = estate_dhimmi_development_of_communities
				NOT = { religion_group = PREV }
			}
		}
		add_province_modifier = {
			name = estate_dhimmi_development_of_communities_mod
			duration = -1
		}
	}

}

on_province_tax_building_destroyed_estate_privileges_effect = {
	if = {
		limit = {
			FROM = {
				OR = {
					religion = buddhism
					religion = mahayana
					religion = vajrayana
				}
				has_estate_privilege = estate_church_karma_temples
			}
		}
		FROM = {
			if = {
				limit = {
					has_government_attribute = buffed_monastic_temples
				}
				add_karma = -5
			}
			else = {
				add_karma = -3
			}
		}
	}
	if = {
		limit = {
			FROM = {
				religion = catholic
				has_estate_privilege = estate_church_influence_temples
			}
		}
		FROM = {
			add_papal_influence = -3
		}
	}
	if = {
		limit = {
			owner = {
				has_country_flag = gets_manpower_from_tax_buildings
			}
		}
		if = {
			limit = {
				has_owner_religion = yes
				has_building = cathedral
				NOT = { has_province_modifier = estate_nobles_religious_conscription_cathedral }
			}
			add_province_modifier = {
				name = estate_nobles_religious_conscription_cathedral
				duration = -1
			}
			remove_province_modifier = estate_nobles_religious_conscription_temple
		}
		else_if = {
			limit = {
				has_owner_religion = yes
				has_building = temple
				NOT = { has_province_modifier = estate_nobles_religious_conscription_temple }
			}
			add_province_modifier = {
				name = estate_nobles_religious_conscription_temple
				duration = -1
			}
			remove_province_modifier = estate_nobles_religious_conscription_cathedral
		}
		else_if = {
			limit = {
				OR = {
					has_province_modifier = estate_nobles_religious_conscription_temple
					has_province_modifier = estate_nobles_religious_conscription_cathedral
				}
			}
			remove_province_modifier = estate_nobles_religious_conscription_temple
			remove_province_modifier = estate_nobles_religious_conscription_cathedral
		}
	}
	if = {
		limit = {
			has_province_modifier = estate_church_development_of_temples_mod
		}
		remove_province_modifier = estate_church_development_of_temples_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_brahmins_development_of_temples_mod
		}
		remove_province_modifier = estate_brahmins_development_of_temples_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_dhimmi_development_of_communities_mod
		}
		remove_province_modifier = estate_dhimmi_development_of_communities_mod
	}
}

on_trade_good_changed_estate_privileges_effect = {
	if = {
		limit = {
			has_province_modifier = estate_burghers_persian_rugs_modifier
			NOT = { trade_goods = silk }
			NOT = { trade_goods = cloth }
			NOT = { trade_goods = dyes }
		}
		remove_province_modifier = estate_burghers_persian_rugs_modifier
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_burghers_persian_rugs }
			NOT = { has_province_modifier = estate_burghers_persian_rugs_modifier }
			OR = {
				trade_goods = silk
				trade_goods = cloth
				trade_goods = dyes
			}
		}
		add_province_modifier = {
			name = estate_burghers_persian_rugs_modifier
			duration = -1
		}
	}
	###MONOPOLIES###
	if = {
		limit = {
			has_province_modifier = estate_burghers_monopoly_of_textiles_mod
			NOT = { trade_goods = silk }
			NOT = { trade_goods = cloth }
		}
		remove_province_modifier = estate_burghers_monopoly_of_textiles_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_burghers_monopoly_of_textiles }
			NOT = { has_province_modifier = estate_burghers_monopoly_of_textiles_mod }
			OR = {
				trade_goods = silk
				trade_goods = cloth
			}
		}
		remove_province_modifier = estate_burghers_monopoly_of_textiles_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_vaisyas_monopoly_of_textiles_mod
			NOT = { trade_goods = silk }
			NOT = { trade_goods = cloth }
		}
		remove_province_modifier = estate_vaisyas_monopoly_of_textiles_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_vaisyas_monopoly_of_textiles }
			NOT = { has_province_modifier = estate_vaisyas_monopoly_of_textiles_mod }
			OR = {
				trade_goods = silk
				trade_goods = cloth
			}
		}
		remove_province_modifier = estate_vaisyas_monopoly_of_textiles_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_jains_monopoly_of_textiles_mod
			NOT = { trade_goods = silk }
			NOT = { trade_goods = cloth }
		}
		remove_province_modifier = estate_jains_monopoly_of_textiles_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_jains_monopoly_of_textiles }
			NOT = { has_province_modifier = estate_jains_monopoly_of_textiles_mod }
			OR = {
				trade_goods = silk
				trade_goods = cloth
			}
		}
		remove_province_modifier = estate_jains_monopoly_of_textiles_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_burghers_monopoly_of_dyes_mod
			NOT = { trade_goods = dyes }
		}
		remove_province_modifier = estate_burghers_monopoly_of_dyes_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_burghers_monopoly_of_dyes }
			NOT = { has_province_modifier = estate_burghers_monopoly_of_dyes_mod }
			trade_goods = dyes
		}
		remove_province_modifier = estate_burghers_monopoly_of_dyes_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_vaisyas_monopoly_of_dyes_mod
			NOT = { trade_goods = dyes }
		}
		remove_province_modifier = estate_vaisyas_monopoly_of_dyes_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_vaisyas_monopoly_of_dyes }
			NOT = { has_province_modifier = estate_vaisyas_monopoly_of_dyes_mod }
			trade_goods = dyes
		}
		remove_province_modifier = estate_vaisyas_monopoly_of_dyes_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_jains_monopoly_of_dyes_mod
			NOT = { trade_goods = dyes }
		}
		remove_province_modifier = estate_jains_monopoly_of_dyes_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_jains_monopoly_of_dyes }
			NOT = { has_province_modifier = estate_jains_monopoly_of_dyes_mod }
			trade_goods = dyes
		}
		remove_province_modifier = estate_jains_monopoly_of_dyes_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_burghers_monopoly_of_glass_mod
			NOT = { trade_goods = glass }
		}
		remove_province_modifier = estate_burghers_monopoly_of_glass_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_burghers_monopoly_of_glass }
			NOT = { has_province_modifier = estate_burghers_monopoly_of_glass_mod }
			trade_goods = glass
		}
		remove_province_modifier = estate_burghers_monopoly_of_glass_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_vaisyas_monopoly_of_glass_mod
			NOT = { trade_goods = glass }
		}
		remove_province_modifier = estate_vaisyas_monopoly_of_glass_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_vaisyas_monopoly_of_glass }
			NOT = { has_province_modifier = estate_vaisyas_monopoly_of_glass_mod }
			trade_goods = glass
		}
		remove_province_modifier = estate_vaisyas_monopoly_of_glass_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_jains_monopoly_of_glass_mod
			NOT = { trade_goods = glass }
		}
		remove_province_modifier = estate_jains_monopoly_of_glass_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_jains_monopoly_of_glass }
			NOT = { has_province_modifier = estate_jains_monopoly_of_glass_mod }
			trade_goods = glass
		}
		remove_province_modifier = estate_jains_monopoly_of_glass_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_burghers_monopoly_of_paper_mod
			NOT = { trade_goods = paper }
		}
		remove_province_modifier = estate_burghers_monopoly_of_paper_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_burghers_monopoly_of_paper }
			NOT = { has_province_modifier = estate_burghers_monopoly_of_paper_mod }
			trade_goods = paper
		}
		remove_province_modifier = estate_burghers_monopoly_of_paper_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_vaisyas_monopoly_of_paper_mod
			NOT = { trade_goods = paper }
		}
		remove_province_modifier = estate_vaisyas_monopoly_of_paper_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_vaisyas_monopoly_of_paper }
			NOT = { has_province_modifier = estate_vaisyas_monopoly_of_paper_mod }
			trade_goods = paper
		}
		remove_province_modifier = estate_vaisyas_monopoly_of_paper_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_jains_monopoly_of_paper_mod
			NOT = { trade_goods = paper }
		}
		remove_province_modifier = estate_jains_monopoly_of_paper_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_jains_monopoly_of_paper }
			NOT = { has_province_modifier = estate_jains_monopoly_of_paper_mod }
			trade_goods = paper
		}
		remove_province_modifier = estate_jains_monopoly_of_paper_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_church_monopoly_of_incense_mod
			NOT = { trade_goods = incense }
		}
		remove_province_modifier = estate_church_monopoly_of_incense_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_church_monopoly_of_incense }
			NOT = { has_province_modifier = estate_church_monopoly_of_incense_mod }
			trade_goods = incense
		}
		remove_province_modifier = estate_church_monopoly_of_incense_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_brahmins_monopoly_of_incense_mod
			NOT = { trade_goods = incense }
		}
		remove_province_modifier = estate_brahmins_monopoly_of_incense_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_brahmins_monopoly_of_incense }
			NOT = { has_province_modifier = estate_brahmins_monopoly_of_incense_mod }
			trade_goods = incense
		}
		remove_province_modifier = estate_brahmins_monopoly_of_incense_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_church_monopoly_of_wool_mod
			NOT = { trade_goods = wool }
		}
		remove_province_modifier = estate_church_monopoly_of_wool_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_church_monopoly_of_wool }
			NOT = { has_province_modifier = estate_church_monopoly_of_wool_mod }
			trade_goods = wool
		}
		remove_province_modifier = estate_church_monopoly_of_wool_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_brahmins_monopoly_of_wool_mod
			NOT = { trade_goods = wool }
		}
		remove_province_modifier = estate_brahmins_monopoly_of_wool_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_brahmins_monopoly_of_wool }
			NOT = { has_province_modifier = estate_brahmins_monopoly_of_wool_mod }
			trade_goods = wool
		}
		remove_province_modifier = estate_brahmins_monopoly_of_wool_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_church_monopoly_of_wine_mod
			NOT = { trade_goods = wine }
		}
		remove_province_modifier = estate_church_monopoly_of_wine_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_church_monopoly_of_wine }
			NOT = { has_province_modifier = estate_church_monopoly_of_wine_mod }
			trade_goods = wine
		}
		remove_province_modifier = estate_church_monopoly_of_wine_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_church_monopoly_of_slaves_mod
			NOT = { trade_goods = slaves }
		}
		remove_province_modifier = estate_church_monopoly_of_slaves_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_church_monopoly_of_slaves }
			NOT = { has_province_modifier = estate_church_monopoly_of_slaves_mod }
			trade_goods = slaves
		}
		remove_province_modifier = estate_church_monopoly_of_slaves_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_nobles_monopoly_of_metals_mod
			NOT = { trade_goods = copper }
			NOT = { trade_goods = iron }
		}
		remove_province_modifier = estate_nobles_monopoly_of_metals_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_nobles_monopoly_of_metals }
			NOT = { has_province_modifier = estate_nobles_monopoly_of_metals_mod }
			OR = {
				trade_goods = copper
				trade_goods = iron
			}
		}
		remove_province_modifier = estate_nobles_monopoly_of_metals_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_rajput_monopoly_of_metals_mod
			NOT = { trade_goods = copper }
			NOT = { trade_goods = iron }
		}
		remove_province_modifier = estate_rajput_monopoly_of_metals_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_rajput_monopoly_of_metals }
			NOT = { has_province_modifier = estate_rajput_monopoly_of_metals_mod }
			OR = {
				trade_goods = copper
				trade_goods = iron
			}
		}
		remove_province_modifier = estate_rajput_monopoly_of_metals_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_maratha_monopoly_of_metals_mod
			NOT = { trade_goods = copper }
			NOT = { trade_goods = iron }
		}
		remove_province_modifier = estate_maratha_monopoly_of_metals_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_maratha_monopoly_of_metals }
			NOT = { has_province_modifier = estate_maratha_monopoly_of_metals_mod }
			OR = {
				trade_goods = copper
				trade_goods = iron
			}
		}
		remove_province_modifier = estate_maratha_monopoly_of_metals_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_nobles_monopoly_of_livestock_mod
			NOT = { trade_goods = livestock }
		}
		remove_province_modifier = estate_nobles_monopoly_of_livestock_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_nobles_monopoly_of_livestock }
			NOT = { has_province_modifier = estate_nobles_monopoly_of_livestock_mod }
			trade_goods = livestock
		}
		remove_province_modifier = estate_nobles_monopoly_of_livestock_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_rajput_monopoly_of_livestock_mod
			NOT = { trade_goods = livestock }
		}
		remove_province_modifier = estate_rajput_monopoly_of_livestock_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_rajput_monopoly_of_livestock }
			NOT = { has_province_modifier = estate_rajput_monopoly_of_livestock_mod }
			trade_goods = livestock
		}
		remove_province_modifier = estate_rajput_monopoly_of_livestock_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_maratha_monopoly_of_livestock_mod
			NOT = { trade_goods = livestock }
		}
		remove_province_modifier = estate_maratha_monopoly_of_livestock_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_maratha_monopoly_of_livestock }
			NOT = { has_province_modifier = estate_maratha_monopoly_of_livestock_mod }
			trade_goods = livestock
		}
		remove_province_modifier = estate_maratha_monopoly_of_livestock_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_nobles_monopoly_of_gems_mod
			NOT = { trade_goods = gems }
		}
		remove_province_modifier = estate_nobles_monopoly_of_gems_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_nobles_monopoly_of_gems }
			NOT = { has_province_modifier = estate_nobles_monopoly_of_gems_mod }
			trade_goods = gems
		}
		remove_province_modifier = estate_nobles_monopoly_of_gems_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_rajput_monopoly_of_gems_mod
			NOT = { trade_goods = gems }
		}
		remove_province_modifier = estate_rajput_monopoly_of_gems_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_rajput_monopoly_of_gems }
			NOT = { has_province_modifier = estate_rajput_monopoly_of_gems_mod }
			trade_goods = gems
		}
		remove_province_modifier = estate_rajput_monopoly_of_gems_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_maratha_monopoly_of_gems_mod
			NOT = { trade_goods = gems }
		}
		remove_province_modifier = estate_maratha_monopoly_of_gems_mod
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_maratha_monopoly_of_gems }
			NOT = { has_province_modifier = estate_maratha_monopoly_of_gems_mod }
			trade_goods = gems
		}
		remove_province_modifier = estate_maratha_monopoly_of_gems_mod
	}
	if = {
		limit = {
			has_province_modifier = estate_burghers_control_over_gold_mine
			NOT = { trade_goods = gold }
		}
		remove_province_modifier = estate_burghers_control_over_gold_mine
	}
	else_if = {
		limit = {
			from = { has_estate_privilege = estate_burghers_control_over_the_mint }
			NOT = { has_province_modifier = estate_burghers_control_over_gold_mine }
			trade_goods = gold
		}
		add_province_modifier = {
			name = estate_burghers_control_over_gold_mine
			duration = -1
		}
	}
}

on_loan_repaid_estate_privileges_effect = {
	if = {
		limit = {
			has_estate_privilege = estate_burghers_indebted_to_burghers
			has_estate_loan = no
		}
		remove_estate_privilege = estate_burghers_indebted_to_burghers
	}
	if = {
		limit = {
			has_estate_privilege = estate_jains_indebted_to_jains
			has_estate_loan = no
		}
		remove_estate_privilege = estate_jains_indebted_to_jains
	}
}


on_bi_yearly_pulse_estate_privileges_effect = {
	if = {
		limit = {
			OR = {
				has_estate_privilege = estate_nobles_supremacy_over_crown
				has_estate_privilege = estate_brahmins_supremacy_over_crown
			}
			NOT = { has_any_active_estate_agenda = yes }
		}
		country_event = { id = estate_privileges_and_agendas_events.3 }
	}
}

on_culture_promoted_estate_privileges_effect = {
	if = {
		limit = {
			OR = {
				has_estate_privilege = estate_church_one_faith_one_culture
				has_estate_privilege = estate_brahmins_one_faith_one_culture
			}
		}
		every_owned_province = {
			limit = {
				has_province_modifier = estate_church_false_culture
				OR = {
					culture_group = ROOT
					has_owner_accepted_culture = yes
				}
			}
			remove_province_modifier = estate_church_false_culture
			if = {
				limit = {
					owner = {
						OR = {
							religion = PREV
							has_harmonized_with = PREV
							secondary_religion = PREV
						}
					}
				}
				add_province_modifier = {
					name = estate_church_united_faith_and_culture
					duration = -1
				}
			}
		}
	}
}

on_culture_demoted_estate_privileges_effect = {
	if = {
		limit = {
			OR = {
				has_estate_privilege = estate_church_one_faith_one_culture
				has_estate_privilege = estate_brahmins_one_faith_one_culture
			}
		}
		every_owned_province = {
			limit = {
				OR = {
					NOT = { has_province_modifier = estate_church_false_culture }
					has_province_modifier = estate_church_united_faith_and_culture
				}
				has_owner_accepted_culture = no
				NOT = { culture_group = ROOT }
			}
			add_province_modifier = {
				name = estate_church_false_culture
				duration = -1
			}
			remove_province_modifier = estate_church_united_faith_and_culture
		}
	}
}

on_primary_culture_changed_privileges_effect = {
	if = {
		limit = {
			OR = {
				has_estate_privilege = estate_church_one_faith_one_culture
				has_estate_privilege = estate_brahmins_one_faith_one_culture
			}
		}
		every_owned_province = {
			remove_province_modifier = estate_church_false_culture
			remove_province_modifier = estate_church_united_faith_and_culture
			if = {
				limit = {
					owner = {
						OR = {
							religion = PREV
							has_harmonized_with = PREV
							secondary_religion = PREV
						}
					}
					OR = {
						has_owner_accepted_culture = yes
						culture_group = ROOT
					}
				}
				add_province_modifier = {
					name = estate_church_united_faith_and_culture
					duration = -1
				}
			}
			else_if = {
				limit = {
					has_province_modifier = estate_church_united_faith_and_culture
				}
				remove_province_modifier = estate_church_united_faith_and_culture
			}
			if = {
				limit = {
					NOT = { culture_group = ROOT }
					has_owner_accepted_culture = no
				}
				add_province_modifier = {
					name = estate_church_false_culture
					duration = -1
				}
			}
			else_if = {
				limit = {
					has_province_modifier = estate_church_false_culture
				}
				remove_province_modifier = estate_church_false_culture
			}
		}
	}
}

reapply_estate_privilege = {
	# privilege: The privilege we want to reapply
	if = {
		limit = { 
			can_revoke_estate_privilege = $privilege$
		}
		hidden_effect = {
			remove_estate_privilege = $privilege$
		}
		set_estate_privilege = $privilege$
	}
}
scaled_estate_church_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_church }
}

scaled_estate_church_negative_land_share_effect = {
	scaled_estate_land_share_reduce_effect = { estate = estate_church }
}

scaled_estate_nobles_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_nobles }
}

scaled_estate_nobles_negative_land_share_effect = {
	scaled_estate_land_share_reduce_effect = { estate = estate_nobles }
}

scaled_estate_burghers_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_burghers }
}

scaled_estate_burghers_negative_land_share_effect = {
	scaled_estate_land_share_reduce_effect = { estate = estate_burghers }
}

scaled_estate_rajput_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_rajput }
}

scaled_estate_rajput_negative_land_share_effect = {
	scaled_estate_land_share_reduce_effect = { estate = estate_rajput }
}

scaled_estate_maratha_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_maratha }
}

scaled_estate_maratha_negative_land_share_effect = {
	scaled_estate_land_share_reduce_effect = { estate = estate_maratha }
}

scaled_estate_brahmins_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_brahmins }
}

scaled_estate_brahmins_negative_land_share_effect = {
	scaled_estate_land_share_reduce_effect = { estate = estate_brahmins }
}

scaled_estate_vaisyas_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_vaisyas }
}

scaled_estate_vaisyas_negative_land_share_effect = {
	scaled_estate_land_share_reduce_effect = { estate = estate_vaisyas }
}

scaled_estate_dhimmi_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_dhimmi }
}

scaled_estate_dhimmi_negative_land_share_effect = {
	scaled_estate_land_share_reduce_effect = { estate = estate_dhimmi }
}

scaled_estate_cossacks_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_cossacks }
}

scaled_estate_cossacks = {
	scaled_estate_land_share_reduce_effect = { estate = estate_cossacks }
}

scaled_estate_jains_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_jains }
}

scaled_estate_jains = {
	scaled_estate_land_share_reduce_effect = { estate = estate_jains }
}

scaled_estate_nomadic_tribes_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_nomadic_tribes }
}

scaled_estate_nomadic_tribes = {
	scaled_estate_land_share_reduce_effect = { estate = estate_nomadic_tribes }
}

scaled_estate_janissaries_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_janissaries }
}

scaled_estate_janissaries = {
	scaled_estate_land_share_reduce_effect = { estate = estate_janissaries }
}

scaled_estate_eunuchs_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_eunuchs }
}

scaled_estate_eunuchs = {
	scaled_estate_land_share_reduce_effect = { estate = estate_eunuchs }
}

scaled_estate_qizilbash_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_qizilbash }
}

scaled_estate_qizilbash = {
	scaled_estate_land_share_reduce_effect = { estate = estate_qizilbash }
}

scaled_estate_ghulams_land_share_effect = {
	scaled_estate_land_share_add_effect = { estate = estate_ghulams }
}

scaled_estate_ghulams = {
	scaled_estate_land_share_reduce_effect = { estate = estate_ghulams }
}

#Based on those above, but you can choose which estate you use
#example of usage: scaled_estate_land_share_add_effect = { estate = estate_nobles }
scaled_estate_land_share_add_effect = {
	if = {
		limit = {
			NOT = { total_development = 50 }
		}
		give_estate_land_share_large = { estate = $estate$ }
	}
	else_if = {
		limit = {
			total_development = 50
			NOT = { total_development = 100 }
		}
		give_estate_land_share_medium = { estate = $estate$ }
	}
	else_if = {
		limit = {
			total_development = 100
		}
		give_estate_land_share_small = { estate = $estate$ }
	}
}

#example of usage: scaled_estate_land_share_reduce_effect = { estate = estate_nobles }
scaled_estate_land_share_reduce_effect = {
	if = {
		limit = {
			NOT = { total_development = 50 }
		}
		take_estate_land_share_large = { estate = $estate$ }
	}
	else_if = {
		limit = {
			total_development = 50
			NOT = { total_development = 100 }
		}
		give_estate_land_share_medium = { estate = $estate$ }
	}
	else_if = {
		limit = {
			total_development = 100
		}
		give_estate_land_share_small = { estate = $estate$ }
	}
}

# Expects country scope
seize_land_effect = {
	hidden_effect = {
		set_variable = {
			which = seize_land_effect_variable
			value = $scale$
		}
		while = {
			limit = {
				check_variable = {
					which = seize_land_effect_variable
					value = 1
				}
			}
			change_variable = {
				which = seize_land_effect_variable
				value = -1
			}
			if = {
				limit = {
					any_owned_province = {
						OR = {
							is_in_capital_area = yes
							is_state_core = root
						}
						is_capital = no
						NOT = {
							area_for_scope_province = {
								owned_by = root
								has_province_flag = seize_land_spawn_unrest_and_rebels
							}
						}
						area_for_scope_province = {
							any_neighbor_province = {
								owned_by = root
								has_province_flag = seize_land_spawn_unrest_and_rebels
							}
						}
					}
				}
				random_owned_province = {
					limit = {
						OR = {
							is_in_capital_area = yes
							is_state_core = root
						}
						is_capital = no
						NOT = {
							area_for_scope_province = {
								owned_by = root
								has_province_flag = seize_land_spawn_unrest_and_rebels
							}
						}
						area_for_scope_province = {
							any_neighbor_province = {
								owned_by = root
								has_province_flag = seize_land_spawn_unrest_and_rebels
							}
						}
						highest_supply_limit_in_area = yes
					}
					spawn_rebels_from_unhappy_estate = { size = 2 }
					area = {
						limit = {
							owned_by = ROOT
						}
						set_province_flag = seize_land_spawn_unrest_and_rebels
						if = {
							limit = {
								NOT = { has_province_flag = has_estate_unrest_flag }
							}
							add_named_unrest = { name = estate_land_seized value = 10 }
							set_province_flag = has_estate_unrest_flag
						}
					}
				}
			}
			else = {
				random_owned_province = {
					limit = {
						OR = {
							is_in_capital_area = yes
							is_state_core = root
						}
						NOT = {
							area_for_scope_province = {
								owned_by = root
								has_province_flag = seize_land_spawn_unrest_and_rebels
							}
						}
						highest_supply_limit_in_area = yes
					}
					spawn_rebels_from_unhappy_estate = { size = 2 }
					area = {
						limit = {
							owned_by = ROOT
						}
						set_province_flag = seize_land_spawn_unrest_and_rebels
						if = {
							limit = {
								NOT = { has_province_flag = has_estate_unrest_flag }
							}
							add_named_unrest = { name = estate_land_seized value = 10 }
							set_province_flag = has_estate_unrest_flag
						}
					}
				}
			}
		}
		every_owned_province = {
			limit = { has_province_flag = seize_land_spawn_unrest_and_rebels }
			clr_province_flag = seize_land_spawn_unrest_and_rebels
		}
	}
}

spawn_rebels_from_unhappy_estate = {
	if = {
		limit = {
			owner = { 
				NOT = { disabled_rebels_from_seized_land_for_estate = { estate = all } } 
				NOT = { has_government_attribute = seizing_land_no_rebels }
			}
		}
		random_list = {
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_nobles } }
						has_estate = estate_nobles
						NOT = {
							estate_loyalty = {
								estate = estate_nobles
								loyalty = 30
							}
						}
					}
				}
				if = {
					limit = {
						owner = {
							OR = {
								primary_culture = polish
								primary_culture = polish_new
							}
						}
					}
					spawn_rebels = {
						type = polish_noble_rebels
						size = $size$
						estate = estate_nobles
						as_if_faction = yes
					}
				}
				else = {
					spawn_rebels = {
						type = noble_rebels
						size = $size$
						estate = estate_nobles
						as_if_faction = yes
					}
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_church } }
						has_estate = estate_church
						NOT = {
							estate_loyalty = {
								estate = estate_church
								loyalty = 30
							}
						}
					}
				}
				owner = {
					trigger_switch = {
						on_trigger = religion
						anglican =      { PREV = { spawn_rebels = { type = anglican_rebels size = $size$ as_if_faction = yes } } }
						hussite =      { PREV = { spawn_rebels = { type = hussite_rebels size = $size$ as_if_faction = yes } } }
						animism =       { PREV = { spawn_rebels = { type = animism_rebels size = $size$ as_if_faction = yes } } }
						buddhism =      { PREV = { spawn_rebels = { type = buddhism_rebels size = $size$ as_if_faction = yes } } }
						catholic =      { PREV = { spawn_rebels = { type = catholic_rebels size = $size$ as_if_faction = yes } } }
						confucianism =  { PREV = { spawn_rebels = { type = confucianism_rebels size = $size$ as_if_faction = yes } } }
						coptic =        { PREV = { spawn_rebels = { type = coptic_rebels size = $size$ as_if_faction = yes } } }
						hinduism =      { PREV = { spawn_rebels = { type = hinduism_rebels size = $size$ as_if_faction = yes } } }
						ibadi =         { PREV = { spawn_rebels = { type = ibadi_rebels size = $size$ as_if_faction = yes } } }
						inti =          { PREV = { spawn_rebels = { type = inti_rebels size = $size$ as_if_faction = yes } } }
						jewish =        { PREV = { spawn_rebels = { type = jewish_rebels size = $size$ as_if_faction = yes } } }
						mahayana =      { PREV = { spawn_rebels = { type = mahayana_rebels size = $size$ as_if_faction = yes } } }
						mesoamerican_religion = { PREV = { spawn_rebels = { type = maya_rebels size = $size$ as_if_faction = yes } } }
						nahuatl =       { PREV = { spawn_rebels = { type = nahuatl_rebels size = $size$ as_if_faction = yes } } }
						norse_pagan_reformed = { PREV = { spawn_rebels = { type = norse_pagan_reformed_rebels size = $size$ as_if_faction = yes } } }
						orthodox =      { PREV = { spawn_rebels = { type = orthodox_rebels size = $size$ as_if_faction = yes } } }
						protestant =    { PREV = { spawn_rebels = { type = protestant_rebels size = $size$ as_if_faction = yes } } }
						reformed =      { PREV = { spawn_rebels = { type = reformed_rebels size = $size$ as_if_faction = yes } } }
						shamanism =     { PREV = { spawn_rebels = { type = shamanism_rebels size = $size$ as_if_faction = yes } } }
						shiite =        { PREV = { spawn_rebels = { type = shiite_rebels size = $size$ as_if_faction = yes } } }
						shinto =        { PREV = { spawn_rebels = { type = shinto_rebels size = $size$ as_if_faction = yes } } }
						sikhism =       { PREV = { spawn_rebels = { type = sikhism_rebels size = $size$ as_if_faction = yes } } }
						sunni =         { PREV = { spawn_rebels = { type = sunni_rebels size = $size$ as_if_faction = yes } } }
						tengri_pagan_reformed = { PREV = { spawn_rebels = { type = tengri_pagan_reformed_rebels size = $size$ as_if_faction = yes } } }
						totemism =      { PREV = { spawn_rebels = { type = totemism_rebels size = $size$ as_if_faction = yes } } }
						vajrayana =     { PREV = { spawn_rebels = { type = vajrayana_rebels size = $size$ as_if_faction = yes } } }
						zoroastrian =   { PREV = { spawn_rebels = { type = zoroastrian_rebels size = $size$ as_if_faction = yes } } }
						dreamtime =      { PREV = { spawn_rebels = { type = dreamtime_rebels size = $size$ as_if_faction = yes } } }
					}
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_rajput } }
						has_estate = estate_rajput
						NOT = {
							estate_loyalty = {
								estate = estate_rajput
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = noble_rebels
					size = $size$
					estate = estate_rajput
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_maratha } }
						has_estate = estate_maratha
						NOT = {
							estate_loyalty = {
								estate = estate_maratha
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = noble_rebels
					size = $size$
					estate = estate_maratha
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_burghers } }
						has_estate = estate_burghers
						NOT = {
							estate_loyalty = {
								estate = estate_burghers
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = particularist_rebels
					size = $size$
					estate = estate_burghers
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_jains } }
						has_estate = estate_jains
						NOT = {
							estate_loyalty = {
								estate = estate_jains
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = particularist_rebels
					size = $size$
					estate = estate_jains
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_vaisyas } }
						has_estate = estate_vaisyas
						NOT = {
							estate_loyalty = {
								estate = estate_vaisyas
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = particularist_rebels
					size = $size$
					estate = estate_vaisyas
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_dhimmi } }
						has_estate = estate_dhimmi
						NOT = {
							estate_loyalty = {
								estate = estate_dhimmi
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = particularist_rebels
					size = $size$
					estate = estate_dhimmi
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_brahmins } }
						has_estate = estate_brahmins
						NOT = {
							estate_loyalty = {
								estate = estate_brahmins
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = hinduism_rebels
					size = $size$
					estate = estate_brahmins
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_cossacks } }
						has_estate = estate_cossacks
						NOT = {
							estate_loyalty = {
								estate = estate_cossacks
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = cossack_rebels
					size = $size$
					estate = estate_cossacks
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_nomadic_tribes } }
						has_estate = estate_nomadic_tribes
						NOT = {
							estate_loyalty = {
								estate = estate_nomadic_tribes
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = tribal_rebels
					size = $size$
					estate = estate_nomadic_tribes
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_janissaries } }
						has_estate = estate_janissaries
						NOT = {
							estate_loyalty = {
								estate = estate_janissaries
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = janissary_rebels
					size = $size$
					estate = estate_janissaries
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_eunuchs } }
						has_estate = estate_eunuchs
						NOT = {
							estate_loyalty = {
								estate = estate_eunuchs
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = eunuch_rebels
					size = $size$
					estate = estate_eunuchs
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_qizilbash } }
						has_estate = estate_qizilbash
						NOT = {
							estate_loyalty = {
								estate = estate_qizilbash
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = qizilbash_rebels
					size = $size$
					estate = estate_qizilbash
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_ghulams } }
						has_estate = estate_ghulams
						NOT = {
							estate_loyalty = {
								estate = estate_ghulams
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = ghulams_rebels
					size = $size$
					estate = estate_ghulams
					as_if_faction = yes
				}
			}
		}
	}
}

pick_random_estate_if_present = {
	random_list = {
		1 = { 
			trigger = {
				has_estate = estate_brahmins
				NOT = { has_country_flag = estate_brahmins_$flag$ }
			}
			set_country_flag = estate_brahmins_$flag$
			[[estate_action]
			$estate_action$ = estate_brahmins
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_church
				NOT = { has_country_flag = estate_church_$flag$ }
			}
			set_country_flag = estate_church_$flag$
			[[estate_action]
			$estate_action$ = estate_church
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_maratha
				NOT = { has_country_flag = estate_maratha_$flag$ }
			}
			set_country_flag = estate_maratha_$flag$ 
			[[estate_action]
			$estate_action$ = estate_maratha
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_nobles
				NOT = { has_country_flag = estate_nobles_$flag$ }
			}
			set_country_flag = estate_nobles_$flag$
			[[estate_action]
			$estate_action$ = estate_nobles
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_burghers
				NOT = { has_country_flag = estate_burghers_$flag$ }
			}
			set_country_flag = estate_burghers_$flag$
			[[estate_action]
			$estate_action$ = estate_burghers
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_vaisyas
				NOT = { has_country_flag = estate_vaisyas_$flag$ }
			}
			set_country_flag = estate_vaisyas_$flag$
			[[estate_action]
			$estate_action$ = estate_vaisyas
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_cossacks
				NOT = { has_country_flag = estate_cossacks_$flag$ }
			}
			set_country_flag = estate_cossacks_$flag$
			[[estate_action]
			$estate_action$ = estate_cossacks
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_nomadic_tribes
				NOT = { has_country_flag = estate_nomadic_tribes_$flag$ }
			}
			set_country_flag = estate_nomadic_tribes_$flag$
			[[estate_action]
			$estate_action$ = estate_nomadic_tribes
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_dhimmi
				NOT = { has_country_flag = estate_dhimmi_$flag$ }
			}
			set_country_flag = estate_dhimmi_$flag$
			[[estate_action]
			$estate_action$ = estate_dhimmi
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_jains
				NOT = { has_country_flag = estate_jains_$flag$ }
			}
			set_country_flag = estate_jains_$flag$
			[[estate_action]
			$estate_action$ = estate_jains
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_rajput
				NOT = { has_country_flag = estate_rajput_$flag$ }
			}
			set_country_flag = estate_rajput_$flag$
			[[estate_action]
			$estate_action$ = estate_rajput
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_janissaries
				NOT = { has_country_flag = estate_janissaries_$flag$ }
			}
			set_country_flag = estate_janissaries_$flag$
			[[estate_action]
			$estate_action$ = estate_janissaries
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_eunuchs
				NOT = { has_country_flag = estate_eunuchs_$flag$ }
			}
			set_country_flag = estate_eunuchs_$flag$
			[[estate_action]
			$estate_action$ = estate_eunuchs
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_qizilbash
				NOT = { has_country_flag = estate_qizilbash_$flag$ }
			}
			set_country_flag = estate_qizilbash_$flag$
			[[estate_action]
			$estate_action$ = estate_qizilbash
			]
		}
		1 = { 
			trigger = {
				has_estate = estate_ghulams
				NOT = { has_country_flag = estate_ghulams_$flag$ }
			}
			set_country_flag = estate_ghulams_$flag$
			[[estate_action]
			$estate_action$ = estate_ghulams
			]
		}
		
		#New added MMETR
		1 = {
			trigger = {
				has_estate = estate_scholars
				NOT = { has_country_flag = estate_scholars_$flag$ }
			}
			set_country_flag = estate_scholars_$flag$
			[[estate_action]
			$estate_action$ = estate_scholars
			]
		}
	}
}

seize_land_estate_effect = {
	take_estate_land_share_massive = { estate = $estate$ }
	if = {
		limit = {
			has_country_flag = ned_lands_generality_flag
		}
		add_estate_loyalty = {
			estate = $estate$
			loyalty = -10
			short = yes
		}
	}
	else_if = {
		limit = {
			has_government_attribute = seizing_land_loyalty
		}
		add_estate_loyalty = {
			estate = $estate$
			loyalty = -15
			short = yes
		}
	}
	else = {
		add_estate_loyalty = {
			estate = $estate$
			loyalty = -20
			short = yes
		}
	} 
	if = {
		limit = { NOT = { has_government_attribute = seizing_land_no_rebels } }
		custom_tooltip = seize_land_rebels_tt
	}
	if = {
		limit = {
			NOT = {
				estate_loyalty = {
					estate = $estate$
					loyalty = 50
				}
			}
			estate_loyalty = {
				estate = $estate$
				loyalty = 30
			}
		}
	}
	else_if = { 
		limit = {
			NOT = {
				estate_loyalty = {
					estate = $estate$
					loyalty = 30
				}
			}
			estate_influence = {
				estate = $estate$
				influence = 1
			}				
		}
		spawn_rebels_seize_land_switch = yes
	}
}

# estate = what estate
# Will give the estate 1% land
give_estate_land_share_small = {
	change_estate_land_share = {
		estate = $estate$
		share = 1
	}
}

# estate = what estate
# Will give the estate 2% land
give_estate_land_share_medium = {
	change_estate_land_share = {
		estate = $estate$
		share = 2
	}
}

# estate = what estate
# Will give the estate 3% land
give_estate_land_share_large = {
	change_estate_land_share = {
		estate = $estate$
		share = 3
	}
}

# estate = what estate
# Will give the estate 5% land
give_estate_land_share_massive = {
	change_estate_land_share = {
		estate = $estate$
		share = 5
	}
}

# estate = what estate
# Will give the estate 10% land
give_estate_land_share_gigantic = {
	change_estate_land_share = {
		estate = $estate$
		share = 10
	}
}

give_estate_land_share_init = {
	change_estate_land_share = {
		estate = $estate$
		share = 20
	}
}

# estate = what estate
# Will take the 1% land from estate
take_estate_land_share_small = {
	change_estate_land_share = {
		estate = $estate$
		share = -1
	}
}

# estate = what estate
# Will take away 2% land from estate
take_estate_land_share_medium = {
	change_estate_land_share = {
		estate = $estate$
		share = -2
	}
}

# estate = what estate
# Will take the 3% land from estate
take_estate_land_share_large = {
	change_estate_land_share = {
		estate = $estate$
		share = -3
	}
}

# estate = what estate
# Will take the 5% land from estate
take_estate_land_share_massive = {
	change_estate_land_share = {
		estate = $estate$
		share = -5
	}
}

# estate = what estate
# Will take the 10% land from estate
take_estate_land_share_gigantic = {
	change_estate_land_share = {
		estate = $estate$
		share = -10
	}
}

# Used to apply estate monopoly modifier based on the estate privilege name
# privilege = name of privilege
apply_estate_monopoly_modifier = {
	if = {
		limit = { owner = { has_estate_privilege = $privilege$ } }
		add_province_modifier = { 
			name = $privilege$_mod 
			duration = -1
		}
	}
}

remove_estate_monopoly_modifier = {
	remove_province_modifier = $privilege$_mod
}

re_add_loyalty_from_seized_land = {
	hidden_effect = {
		if = {
			limit = {
				has_government_attribute = seizing_land_loyalty
			}
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nobles } }			add_estate_loyalty = { estate = estate_nobles			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_brahmins } }		add_estate_loyalty = { estate = estate_brahmins			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_burghers } }		add_estate_loyalty = { estate = estate_burghers			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_church } }			add_estate_loyalty = { estate = estate_church			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_cossacks } }		add_estate_loyalty = { estate = estate_cossacks			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_dhimmi } }			add_estate_loyalty = { estate = estate_dhimmi			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_jains } }			add_estate_loyalty = { estate = estate_jains			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_maratha } }		add_estate_loyalty = { estate = estate_maratha			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nomadic_tribes } }	add_estate_loyalty = { estate = estate_nomadic_tribes	 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_rajput } }			add_estate_loyalty = { estate = estate_rajput			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_vaisyas } }		add_estate_loyalty = { estate = estate_vaisyas			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_janissaries } }	add_estate_loyalty = { estate = estate_janissaries		 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_eunuchs } }		add_estate_loyalty = { estate = estate_eunuchs			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_qizilbash } }		add_estate_loyalty = { estate = estate_qizilbash		 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_ghulams } }		add_estate_loyalty = { estate = estate_ghulams			 loyalty = 15 } }
		}
		else = {
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nobles } }			add_estate_loyalty = { estate = estate_nobles			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_brahmins } }		add_estate_loyalty = { estate = estate_brahmins			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_burghers } }		add_estate_loyalty = { estate = estate_burghers			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_church } }			add_estate_loyalty = { estate = estate_church			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_cossacks } }		add_estate_loyalty = { estate = estate_cossacks			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_dhimmi } }			add_estate_loyalty = { estate = estate_dhimmi			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_jains } }			add_estate_loyalty = { estate = estate_jains			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_maratha } }		add_estate_loyalty = { estate = estate_maratha			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nomadic_tribes } }	add_estate_loyalty = { estate = estate_nomadic_tribes	 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_rajput } }			add_estate_loyalty = { estate = estate_rajput			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_vaisyas } }		add_estate_loyalty = { estate = estate_vaisyas			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_janissaries } }	add_estate_loyalty = { estate = estate_janissaries		 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_eunuchs } }		add_estate_loyalty = { estate = estate_eunuchs			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_qizilbash } }		add_estate_loyalty = { estate = estate_qizilbash		 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_ghulams } }		add_estate_loyalty = { estate = estate_ghulams			 loyalty = 20 } }
		}
	}
}

spawn_rebels_seize_land_switch = {
	trigger_switch = {
		on_trigger = num_of_owned_areas
		1000 = { custom_tooltip = estate_seize_land_interaction_tooltip_1000 seize_land_effect = { scale = 101 } }
		990 = { custom_tooltip = estate_seize_land_interaction_tooltip_990 seize_land_effect = { scale = 100 } }
		980 = { custom_tooltip = estate_seize_land_interaction_tooltip_980 seize_land_effect = { scale = 99 } }
		970 = { custom_tooltip = estate_seize_land_interaction_tooltip_970 seize_land_effect = { scale = 98 } }
		960 = { custom_tooltip = estate_seize_land_interaction_tooltip_960 seize_land_effect = { scale = 97 } }
		950 = { custom_tooltip = estate_seize_land_interaction_tooltip_950 seize_land_effect = { scale = 96 } }
		940 = { custom_tooltip = estate_seize_land_interaction_tooltip_940 seize_land_effect = { scale = 95 } }
		930 = { custom_tooltip = estate_seize_land_interaction_tooltip_930 seize_land_effect = { scale = 94 } }
		920 = { custom_tooltip = estate_seize_land_interaction_tooltip_920 seize_land_effect = { scale = 93 } }
		910 = { custom_tooltip = estate_seize_land_interaction_tooltip_910 seize_land_effect = { scale = 92 } }
		900 = { custom_tooltip = estate_seize_land_interaction_tooltip_900 seize_land_effect = { scale = 91 } }
		890 = { custom_tooltip = estate_seize_land_interaction_tooltip_890 seize_land_effect = { scale = 90 } }
		880 = { custom_tooltip = estate_seize_land_interaction_tooltip_880 seize_land_effect = { scale = 89 } }
		870 = { custom_tooltip = estate_seize_land_interaction_tooltip_870 seize_land_effect = { scale = 88 } }
		860 = { custom_tooltip = estate_seize_land_interaction_tooltip_860 seize_land_effect = { scale = 87 } }
		850 = { custom_tooltip = estate_seize_land_interaction_tooltip_850 seize_land_effect = { scale = 86 } }
		840 = { custom_tooltip = estate_seize_land_interaction_tooltip_840 seize_land_effect = { scale = 85 } }
		830 = { custom_tooltip = estate_seize_land_interaction_tooltip_830 seize_land_effect = { scale = 84 } }
		820 = { custom_tooltip = estate_seize_land_interaction_tooltip_820 seize_land_effect = { scale = 83 } }
		810 = { custom_tooltip = estate_seize_land_interaction_tooltip_810 seize_land_effect = { scale = 82 } }
		800 = { custom_tooltip = estate_seize_land_interaction_tooltip_800 seize_land_effect = { scale = 81 } }
		790 = { custom_tooltip = estate_seize_land_interaction_tooltip_790 seize_land_effect = { scale = 80 } }
		780 = { custom_tooltip = estate_seize_land_interaction_tooltip_780 seize_land_effect = { scale = 79 } }
		770 = { custom_tooltip = estate_seize_land_interaction_tooltip_770 seize_land_effect = { scale = 78 } }
		760 = { custom_tooltip = estate_seize_land_interaction_tooltip_760 seize_land_effect = { scale = 77 } }
		750 = { custom_tooltip = estate_seize_land_interaction_tooltip_750 seize_land_effect = { scale = 76 } }
		740 = { custom_tooltip = estate_seize_land_interaction_tooltip_740 seize_land_effect = { scale = 75 } }
		730 = { custom_tooltip = estate_seize_land_interaction_tooltip_730 seize_land_effect = { scale = 74 } }
		720 = { custom_tooltip = estate_seize_land_interaction_tooltip_720 seize_land_effect = { scale = 73 } }
		710 = { custom_tooltip = estate_seize_land_interaction_tooltip_710 seize_land_effect = { scale = 72 } }
		700 = { custom_tooltip = estate_seize_land_interaction_tooltip_700 seize_land_effect = { scale = 71 } }
		690 = { custom_tooltip = estate_seize_land_interaction_tooltip_690 seize_land_effect = { scale = 70 } }
		680 = { custom_tooltip = estate_seize_land_interaction_tooltip_680 seize_land_effect = { scale = 69 } }
		670 = { custom_tooltip = estate_seize_land_interaction_tooltip_670 seize_land_effect = { scale = 68 } }
		660 = { custom_tooltip = estate_seize_land_interaction_tooltip_660 seize_land_effect = { scale = 67 } }
		650 = { custom_tooltip = estate_seize_land_interaction_tooltip_650 seize_land_effect = { scale = 66 } }
		640 = { custom_tooltip = estate_seize_land_interaction_tooltip_640 seize_land_effect = { scale = 65 } }
		630 = { custom_tooltip = estate_seize_land_interaction_tooltip_630 seize_land_effect = { scale = 64 } }
		620 = { custom_tooltip = estate_seize_land_interaction_tooltip_620 seize_land_effect = { scale = 63 } }
		610 = { custom_tooltip = estate_seize_land_interaction_tooltip_610 seize_land_effect = { scale = 62 } }
		600 = { custom_tooltip = estate_seize_land_interaction_tooltip_600 seize_land_effect = { scale = 61 } }
		590 = { custom_tooltip = estate_seize_land_interaction_tooltip_590 seize_land_effect = { scale = 60 } }
		580 = { custom_tooltip = estate_seize_land_interaction_tooltip_580 seize_land_effect = { scale = 59 } }
		570 = { custom_tooltip = estate_seize_land_interaction_tooltip_570 seize_land_effect = { scale = 58 } }
		560 = { custom_tooltip = estate_seize_land_interaction_tooltip_560 seize_land_effect = { scale = 57 } }
		550 = { custom_tooltip = estate_seize_land_interaction_tooltip_550 seize_land_effect = { scale = 56 } }
		540 = { custom_tooltip = estate_seize_land_interaction_tooltip_540 seize_land_effect = { scale = 55 } }
		530 = { custom_tooltip = estate_seize_land_interaction_tooltip_530 seize_land_effect = { scale = 54 } }
		520 = { custom_tooltip = estate_seize_land_interaction_tooltip_520 seize_land_effect = { scale = 53 } }
		510 = { custom_tooltip = estate_seize_land_interaction_tooltip_510 seize_land_effect = { scale = 52 } }
		500 = { custom_tooltip = estate_seize_land_interaction_tooltip_500 seize_land_effect = { scale = 51 } }
		490 = { custom_tooltip = estate_seize_land_interaction_tooltip_490 seize_land_effect = { scale = 50 } }
		480 = { custom_tooltip = estate_seize_land_interaction_tooltip_480 seize_land_effect = { scale = 49 } }
		470 = { custom_tooltip = estate_seize_land_interaction_tooltip_470 seize_land_effect = { scale = 48 } }
		460 = { custom_tooltip = estate_seize_land_interaction_tooltip_460 seize_land_effect = { scale = 47 } }
		450 = { custom_tooltip = estate_seize_land_interaction_tooltip_450 seize_land_effect = { scale = 46 } }
		440 = { custom_tooltip = estate_seize_land_interaction_tooltip_440 seize_land_effect = { scale = 45 } }
		430 = { custom_tooltip = estate_seize_land_interaction_tooltip_430 seize_land_effect = { scale = 44 } }
		420 = { custom_tooltip = estate_seize_land_interaction_tooltip_420 seize_land_effect = { scale = 43 } }
		410 = { custom_tooltip = estate_seize_land_interaction_tooltip_410 seize_land_effect = { scale = 42 } }
		400 = { custom_tooltip = estate_seize_land_interaction_tooltip_400 seize_land_effect = { scale = 41 } }
		390 = { custom_tooltip = estate_seize_land_interaction_tooltip_390 seize_land_effect = { scale = 40 } }
		380 = { custom_tooltip = estate_seize_land_interaction_tooltip_380 seize_land_effect = { scale = 39 } }
		370 = { custom_tooltip = estate_seize_land_interaction_tooltip_370 seize_land_effect = { scale = 38 } }
		360 = { custom_tooltip = estate_seize_land_interaction_tooltip_360 seize_land_effect = { scale = 37 } }
		350 = { custom_tooltip = estate_seize_land_interaction_tooltip_350 seize_land_effect = { scale = 36 } }
		340 = { custom_tooltip = estate_seize_land_interaction_tooltip_340 seize_land_effect = { scale = 35 } }
		330 = { custom_tooltip = estate_seize_land_interaction_tooltip_330 seize_land_effect = { scale = 34 } }
		320 = { custom_tooltip = estate_seize_land_interaction_tooltip_320 seize_land_effect = { scale = 33 } }
		310 = { custom_tooltip = estate_seize_land_interaction_tooltip_310 seize_land_effect = { scale = 32 } }
		300 = { custom_tooltip = estate_seize_land_interaction_tooltip_300 seize_land_effect = { scale = 31 } }
		290 = { custom_tooltip = estate_seize_land_interaction_tooltip_290 seize_land_effect = { scale = 30 } }
		280 = { custom_tooltip = estate_seize_land_interaction_tooltip_280 seize_land_effect = { scale = 29 } }
		270 = { custom_tooltip = estate_seize_land_interaction_tooltip_270 seize_land_effect = { scale = 28 } }
		260 = { custom_tooltip = estate_seize_land_interaction_tooltip_260 seize_land_effect = { scale = 27 } }
		250 = { custom_tooltip = estate_seize_land_interaction_tooltip_250 seize_land_effect = { scale = 26 } }
		240 = { custom_tooltip = estate_seize_land_interaction_tooltip_240 seize_land_effect = { scale = 25 } }
		230 = { custom_tooltip = estate_seize_land_interaction_tooltip_230 seize_land_effect = { scale = 24 } }
		220 = { custom_tooltip = estate_seize_land_interaction_tooltip_220 seize_land_effect = { scale = 23 } }
		210 = { custom_tooltip = estate_seize_land_interaction_tooltip_210 seize_land_effect = { scale = 22 } }
		200 = { custom_tooltip = estate_seize_land_interaction_tooltip_200 seize_land_effect = { scale = 21 } }
		190 = { custom_tooltip = estate_seize_land_interaction_tooltip_190 seize_land_effect = { scale = 20 } }
		180 = { custom_tooltip = estate_seize_land_interaction_tooltip_180 seize_land_effect = { scale = 19 } }
		170 = { custom_tooltip = estate_seize_land_interaction_tooltip_170 seize_land_effect = { scale = 18 } }
		160 = { custom_tooltip = estate_seize_land_interaction_tooltip_160 seize_land_effect = { scale = 17 } }
		150 = { custom_tooltip = estate_seize_land_interaction_tooltip_150 seize_land_effect = { scale = 16 } }
		140 = { custom_tooltip = estate_seize_land_interaction_tooltip_140 seize_land_effect = { scale = 15 } }
		130 = { custom_tooltip = estate_seize_land_interaction_tooltip_130 seize_land_effect = { scale = 14 } }
		120 = { custom_tooltip = estate_seize_land_interaction_tooltip_120 seize_land_effect = { scale = 13 } }
		110 = { custom_tooltip = estate_seize_land_interaction_tooltip_110 seize_land_effect = { scale = 12 } }
		100 = { custom_tooltip = estate_seize_land_interaction_tooltip_100 seize_land_effect = { scale = 11 } }
		90 = { custom_tooltip = estate_seize_land_interaction_tooltip_90 seize_land_effect = { scale = 10 } }
		80 = { custom_tooltip = estate_seize_land_interaction_tooltip_80 seize_land_effect = { scale = 9 } }
		70 = { custom_tooltip = estate_seize_land_interaction_tooltip_70 seize_land_effect = { scale = 8 } }
		60 = { custom_tooltip = estate_seize_land_interaction_tooltip_60 seize_land_effect = { scale = 7 } }
		50 = { custom_tooltip = estate_seize_land_interaction_tooltip_50 seize_land_effect = { scale = 6 } }
		40 = { custom_tooltip = estate_seize_land_interaction_tooltip_40 seize_land_effect = { scale = 5 } }
		30 = { custom_tooltip = estate_seize_land_interaction_tooltip_30 seize_land_effect = { scale = 4 } }
		20 = { custom_tooltip = estate_seize_land_interaction_tooltip_20 seize_land_effect = { scale = 3 } }
		10 = { custom_tooltip = estate_seize_land_interaction_tooltip_10 seize_land_effect = { scale = 2 } }
		1 = { custom_tooltip = estate_seize_land_interaction_tooltip_1 seize_land_effect = { scale = 1 } }
	}
}

estate_action_monarch_power = {
	if = {
		limit = {
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 50
				}	
			}
		}
		add_$type$_power = 50
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 50
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 75
				}	
			}
		}
		add_$type$_power = 100
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 75
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 100
				}	
			}
		}
		add_$type$_power = 150
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 100
			}
		}
		add_$type$_power = 200
	}
}

estate_action_years_of_income = {
	if = {
		limit = {
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 50
				}	
			}
		}
		add_years_of_income = 0.25
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 50
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 75
				}	
			}
		}
		add_years_of_income = 0.5
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 75
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 100
				}	
			}
		}
		add_years_of_income = 0.75
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 100
			}
		}
		add_years_of_income = 1
	}
}

estate_action_yearly_manpower = {
	if = {
		limit = {
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 50
				}	
			}
		}
		add_yearly_manpower = 1
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 50
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 75
				}	
			}
		}
		add_yearly_manpower = 1.5
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 75
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 100
				}	
			}
		}
		add_yearly_manpower = 2
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 100
			}
		}
		add_yearly_manpower = 2.5
	}
}

estate_action_scaling_modifier = {
	if = {
		limit = {
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 50
				}	
			}
		}
		add_country_modifier = {
			name = $name$_level_1
			duration = $duration$
		}
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 50
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 75
				}	
			}
		}
		add_country_modifier = {
			name = $name$_level_2
			duration = $duration$
		}
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 75
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 100
				}	
			}
		}
		add_country_modifier = {
			name = $name$_level_3
			duration = $duration$
		}
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 100
			}
		}
		add_country_modifier = {
			name = $name$_level_4
			duration = $duration$
		}
	}
}

estate_action_scaling_province_modifier = {
	if = {
		limit = {
			$country$ = {
				NOT = {
					estate_influence = {
						estate = $estate$
						influence = 50
					}	
				}
			}
		}
		add_province_modifier = {
			name = $name$_level_1
			duration = $duration$
		}
	}
	if = {
		limit = {
			$country$ = {
				estate_influence = {
					estate = $estate$
					influence = 50
				}
				NOT = {
					estate_influence = {
						estate = $estate$
						influence = 75
					}	
				}
			}
		}
		add_province_modifier = {
			name = $name$_level_2
			duration = $duration$
		}
	}
	if = {
		limit = {
			$country$ = {
				estate_influence = {
					estate = $estate$
					influence = 75
				}
				NOT = {
					estate_influence = {
						estate = $estate$
						influence = 100
					}	
				}
			}
		}
		add_province_modifier = {
			name = $name$_level_3
			duration = $duration$
		}
	}
	if = {
		limit = {
			$country$ = {
				estate_influence = {
					estate = $estate$
					influence = 100
				}
			}
		}
		add_province_modifier = {
			name = $name$_level_4
			duration = $duration$
		}
	}
}

estate_action_tradition = {
	if = {
		limit = {
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 50
				}	
			}
		}
		add_$type$_tradition = 10
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 50
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 75
				}	
			}
		}
		add_$type$_tradition = 15
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 75
			}
			NOT = {
				estate_influence = {
					estate = $estate$
					influence = 100
				}	
			}
		}
		add_$type$_tradition = 20
	}
	if = {
		limit = {
			estate_influence = {
				estate = $estate$
				influence = 100
			}
		}
		add_$type$_tradition = 25
	}
}

# Supports the following parameters
###########################################
# estate_nobles
# estate_brahmins
# estate_burghers
# estate_church
# estate_cossacks
# estate_dhimmi
# estate_jains
# estate_maratha
# estate_nomadic_tribes
# estate_rajput
# estate_vaisyas
# estate_janissaries
# estate_eunuchs
# estate_qizilbash
# estate_ghulams
# all	- disables ALL rebels from seized land
disable_rebels_from_seize_land_for_estate = {
	custom_tooltip = disable_rebels_from_seize_land_for_$estate$
	hidden_effect = {
		set_country_flag = disabled_rebels_from_seized_land_for_$estate$
	}
}

# Supports the following parameters
###########################################
# estate_nobles
# estate_brahmins
# estate_burghers
# estate_church
# estate_cossacks
# estate_dhimmi
# estate_jains
# estate_maratha
# estate_nomadic_tribes
# estate_rajput
# estate_vaisyas
# estate_janissaries
# estate_eunuchs
# estate_qizilbash
# estate_ghulams
# all	- auto completes for every estate agenda
auto_complete_estate_agenda = {
	custom_tooltip = auto_complete_estate_agenda_$estate$_tt
	hidden_effect = {
		set_country_flag = auto_complete_estate_agenda_$estate$
	}
}

clr_auto_complete_flag = {
	hidden_effect = {
		clr_country_flag = auto_complete_estate_agenda_estate_nobles
		clr_country_flag = auto_complete_estate_agenda_estate_brahmins
		clr_country_flag = auto_complete_estate_agenda_estate_burghers
		clr_country_flag = auto_complete_estate_agenda_estate_church
		clr_country_flag = auto_complete_estate_agenda_estate_cossacks
		clr_country_flag = auto_complete_estate_agenda_estate_dhimmi
		clr_country_flag = auto_complete_estate_agenda_estate_jains
		clr_country_flag = auto_complete_estate_agenda_estate_maratha
		clr_country_flag = auto_complete_estate_agenda_estate_nomadic_tribes
		clr_country_flag = auto_complete_estate_agenda_estate_rajput
		clr_country_flag = auto_complete_estate_agenda_estate_vaisyas
		clr_country_flag = auto_complete_estate_agenda_estate_janissaries
		clr_country_flag = auto_complete_estate_agenda_estate_eunuchs
		clr_country_flag = auto_complete_estate_agenda_estate_qizilbash
		clr_country_flag = auto_complete_estate_agenda_estate_ghulams
		clr_country_flag = auto_complete_estate_agenda_all
	}
}

on_completed_agenda_effect_estate_nobles = {
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = 0.05
	}
}
on_completed_agenda_effect_estate_brahmins = {
	if = {
		limit = { has_government_attribute = clergy_estate_agendas_gives_karma }
		add_karma = 10
	}
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = -0.05
	}
}
on_completed_agenda_effect_estate_burghers = {
	if = {
		limit = {
			has_country_flag = ITA_upgrade_city_expansion_privileges_flag
			has_estate_privilege = estate_burghers_development_of_cities
		}
		custom_tooltip = ITA_3_random_dev_distribution
		hidden_effect = {
			for = {
				amount = 3
				effect = "
					random_owned_province = {
						add_random_development = 1
					}
				"
			}
		}
	}
}
on_completed_agenda_effect_estate_church = {
	if = {
		limit = { has_government_attribute = clergy_estate_agendas_gives_karma }
		add_karma = 10
	}
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = -0.05
	}
}
on_completed_agenda_effect_estate_cossacks = {
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = 0.05
	}
}
on_completed_agenda_effect_estate_dhimmi = {}
on_completed_agenda_effect_estate_jains = {}
on_completed_agenda_effect_estate_maratha = {
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = 0.05
	}
}
on_completed_agenda_effect_estate_nomadic_tribes = {
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = 0.05
	}
}
on_completed_agenda_effect_estate_rajput = {
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = 0.05
	}
}
on_completed_agenda_effect_estate_vaisyas = {}
on_completed_agenda_effect_estate_janissaries = {
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = 0.05
	}
}
on_completed_agenda_effect_estate_eunuchs = {}
on_completed_agenda_effect_estate_qizilbash = {
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = 0.05
	}
}
on_completed_agenda_effect_estate_ghulams = {
	if = {
		limit = { has_government_attribute = theocratic_monarchy_mechanic }
		change_statists_vs_orangists = 0.05
	}
}

on_completed_agenda_effect = {
	on_completed_agenda_effect_$estate$ = yes
	if = {
		limit = {
			has_government_mechanic = ottoman_decadence_mechanic
		}
		add_government_power = { 
			mechanic_type = ottoman_decadence_mechanic 
			power_type = ottoman_decadence
			value = -0.5
		}
	}
	clr_auto_complete_flag = yes
}

on_failed_agenda_effect = {
	if = {
		limit = {
			has_government_mechanic = ottoman_decadence_mechanic
		}
		add_government_power = { 
			mechanic_type = ottoman_decadence_mechanic 
			power_type = ottoman_decadence
			value = 1
		}
	}
}

#Estates are here ordered in "mana classes" - ADM for Clergy, DIP for Burghers, etc
add_estate_loyalty_by_class_adm = {
	if = {
		limit = { has_estate = estate_church }
		add_estate_loyalty = {
			estate = estate_church
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_dhimmi }
		add_estate_loyalty = {
			estate = estate_dhimmi
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_brahmins }
		add_estate_loyalty = {
			estate = estate_brahmins
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_eunuchs }
		add_estate_loyalty = {
			estate = estate_eunuchs
			loyalty = $loyalty$
		}
	}
}
add_estate_loyalty_by_class_dip = {
	if = {
		limit = { has_estate = estate_burghers }
		add_estate_loyalty = {
			estate = estate_burghers
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_jains }
		add_estate_loyalty = {
			estate = estate_jains
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_vaisyas }
		add_estate_loyalty = {
			estate = estate_vaisyas
			loyalty = $loyalty$
		}
	}
}
add_estate_loyalty_by_class_mil = {
	if = {
		limit = { has_estate = estate_nobles }
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_cossacks }
		add_estate_loyalty = {
			estate = estate_cossacks
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_nomadic_tribes }
		add_estate_loyalty = {
			estate = estate_nomadic_tribes
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_maratha }
		add_estate_loyalty = {
			estate = estate_maratha
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_rajput }
		add_estate_loyalty = {
			estate = estate_rajput
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_janissaries }
		add_estate_loyalty = {
			estate = estate_janissaries
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_qizilbash }
		add_estate_loyalty = {
			estate = estate_qizilbash
			loyalty = $loyalty$
		}
	}
	if = {
		limit = { has_estate = estate_ghulams }
		add_estate_loyalty = {
			estate = estate_ghulams
			loyalty = $loyalty$
		}
	}
}


estate_action_MAKE_GENEROUS_DONATION_BRAHMINS = {
	add_years_of_income = -0.25
	add_estate_loyalty = {
		estate = estate_brahmins
		loyalty = 10
	}
}
estate_action_SEEK_SUPPORT_OF_BRAHMINS = {
	add_prestige = -5
	add_legitimacy = -5
	add_republican_tradition = -3
	add_estate_influence_modifier = {
		estate = estate_brahmins
		desc = EST_VAL_SOUGHT_SUPPORT
		influence = 10
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_brahmins
		loyalty = 15
	}
}
estate_action_RECRUIT_MINISTER_BRAHMINS = {
	generate_estate_advisor = {
		estate = estate_brahmins
		type = theologian
	}
	add_estate_loyalty = {
		estate = estate_brahmins
		loyalty = -10
	}
	#add_estate_influence_modifier = {
	#	estate = estate_brahmins
	#	desc = EST_VAL_BRAHMIN_MINISTER
	#	influence = 15
	#	duration = 10950
	#}
}
estate_action_RECRUIT_INQUISITOR_BRAHMINS = {
	generate_estate_advisor = {
		estate = estate_brahmins
		type = inquisitor
	}
	add_estate_loyalty = {
		estate = estate_brahmins
		loyalty = -10
	}
	#add_estate_influence_modifier = {
	#	estate = estate_brahmins
	#	desc = EST_VAL_CLERGY_INQUISITOR
	#	influence = 10
	#	duration = 10950
	#}
	if = {
		limit = { has_estate = estate_dhimmi }
		add_estate_loyalty = {
			estate = estate_dhimmi
			loyalty = -15
		}
	}
}
estate_action_DEMAND_SUPPORT_BRAHMINS = {
	estate_action_monarch_power = {
		estate = estate_brahmins
		type = adm
	}
	add_estate_loyalty = {
		estate = estate_brahmins
		loyalty = -20
	}
}
estate_action_SEEK_BRAHMIN_LEGITIMACY_BRAHMINS = {
	add_country_modifier = {
		name = muslim_brahmin_legitimacy
		duration = 7300
	}
	add_estate_influence_modifier = {
		estate = estate_brahmins
		desc = EST_VAL_BRAHMIN_LEGITIMACY
		influence = 15
		duration = 7300
	}
	auto_complete_estate_agenda = {
		estate = estate_brahmins
	}
}
estate_action_ASK_FOR_CONTRIBUTION_BURGHERS = {
	#estate_action_years_of_income = {
	#	estate = estate_burghers
	#}
	estate_action_scaling_modifier = {
		estate = estate_burghers
		name = ASK_FOR_CONTRIBUTION_BURGHERS
		duration = 3650
	}
	add_estate_loyalty = {
		estate = estate_burghers
		loyalty = -10
	}
}
estate_action_DEMAND_SUPPORT_BURGHERS = {
	estate_action_monarch_power = {
		estate = estate_burghers
		type = dip
	}
	add_estate_loyalty = {
		estate = estate_burghers
		loyalty = -20
	}

}
estate_action_GRANT_MONOPOLY_CHARTER_BURGHERS = {
	add_prestige = -5
	add_estate_influence_modifier = {
		estate = estate_burghers
		desc = EST_VAL_GRANTED_MONOPOLIES
		influence = 10
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_burghers
		loyalty = 15
	}
	auto_complete_estate_agenda = {
		estate = estate_burghers
	}
}
estate_action_RECRUIT_MINISTER_BURGHERS = {
	generate_estate_advisor = {
		estate = estate_burghers
		type = master_of_mint
	}
	#add_estate_influence_modifier = {
	#	estate = estate_burghers
	#	desc = EST_VAL_BURGHER_MINISTER
	#	influence = 15
	#	duration = 10950
	#}
	add_estate_loyalty = {
		estate = estate_burghers
		loyalty = -10
	}
}
estate_action_GRANT_ADMIRALSHIP_BURGHERS = {
	create_leader_scaling_with_tradition = {
		leader = admiral
		type = navy
	}
	#add_estate_influence_modifier = {
	#	estate = estate_burghers
	#	desc = EST_VAL_GRANTED_ADMIRALSHIP
	#	influence = 20
	#	duration = 3650
	#}
	add_estate_loyalty = {
		estate = estate_burghers
		loyalty = -10
	}
}
estate_action_GRANT_NEW_WORLD_CHARTER_BURGHERS = {
	add_country_modifier = {
		name = "new_world_company"
		duration = 3650
	}
	#add_estate_influence_modifier = {
	#	estate = estate_burghers
	#	desc = EST_VAL_NEW_WORLD_CHARTER
	#	influence = 15
	#	duration = 3650
	#}
	create_leader_scaling_with_tradition = {
		leader = explorer
		type = navy
	}
}
estate_action_COMISSION_MERCHANT_SHIPS_FOR_WAR_BURGHERS = {
	#add_estate_loyalty = {
	#	estate = estate_burghers
	#	loyalty = -15
	#}
	if = {
		limit = {
			has_country_flag = SUN_draft_ships_for_war_flag
		}
		add_ship_construction_scaled_to_ports_MAY = yes
	}
	else = {
		add_ship_construction_scaled_to_ports = {
			type = heavy_ship
		}
	}
}
estate_action_MAKE_GENEROUS_DONATION_CHURCH = {
	add_years_of_income = -0.25
	add_estate_loyalty = {
		estate = estate_church
		loyalty = 10
	}
}
estate_action_RECRUIT_MINISTER_CHURCH = {
	generate_estate_advisor = {
		estate = estate_church
		type = theologian
	}
	#add_estate_influence_modifier = {
	#	estate = estate_church
	#	desc = EST_VAL_CLERGY_MINISTER
	#	influence = 15
	#	duration = 10950
	#}
	add_estate_loyalty = {
		estate = estate_church
		loyalty = -10
	}
}
estate_action_RECRUIT_INQUISITOR_CHURCH = {
	generate_estate_advisor = {
		estate = estate_church
		type = inquisitor
	}
	#add_estate_influence_modifier = {
	#	estate = estate_church
	#	desc = EST_VAL_CLERGY_INQUISITOR
	#	influence = 10
	#	duration = 10950
	#}
	if = {
		limit = { has_estate = estate_dhimmi }
		add_estate_loyalty = {
			estate = estate_dhimmi
			loyalty = -15
		}
	}
	add_estate_loyalty = {
		estate = estate_church
		loyalty = -10
	}
}
estate_action_RELIGIOUS_DELEGATION_CHURCH = {
	if = {
		limit = {
			religion = catholic
		}
		reverse_add_opinion = {
			who = PAP
			modifier = religious_delegation
		}
	}
	add_estate_loyalty = {
		estate = estate_church
		loyalty = 10
	}
	auto_complete_estate_agenda = {
		estate = estate_church
	}
}
estate_action_DEMAND_SUPPORT_CHURCH = {
	estate_action_monarch_power = {
		estate = estate_church
		type = adm
	}
	add_estate_loyalty = {
		estate = estate_church
		loyalty = -20
	}
}
estate_action_SEEK_SUPPORT_OF_CLERGY_CHURCH = {
	if = {
		limit = {
			NOT = { has_country_flag = MAY_upgrade_institutionalized_clergy_privilege_flag }
		}
		add_prestige = -5
		add_legitimacy = -5
		add_republican_tradition = -3
		add_devotion = -5
		add_horde_unity = -5
		add_meritocracy = -2
	}
	change_piety_effect = {
		amount = 0.05
	}
	if = {
		limit = {
			uses_church_aspects = yes
		}
		add_church_power = 10
	}
	if = {
		limit = {
			uses_patriarch_authority = yes
		}
		add_patriarch_authority = 0.05
	}
	if = {
		limit = {
			uses_fervor = yes
		}
		add_fervor = 10
	}
	if = {
		limit = {
			religion = confucianism
		}
		add_harmony = 5
	}
	if = {
		limit = {
			harmonization_progress = 1
		}
		add_harmonization_progress = 1
	}
	change_karma_effect = {
		amount = 10
		second_amount = 5
	}
	add_papal_influence = 15
	add_estate_influence_modifier = {
		estate = estate_church
		desc = EST_VAL_SOUGHT_SUPPORT
		influence = 10
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_church
		loyalty = 15
	}
}
estate_action_NEW_WORLD_MISSION_CHURCH = {
	add_country_modifier = {
		name = "new_world_missions"
		duration = 7300
	}
	add_estate_influence_modifier = {
		estate = estate_church
		desc = EST_VAL_NEW_WORLD_MISSION
		influence = 15
		duration = 7300
	}
}
estate_action_EXPAND_COSSACK_REGISTRY_COSSACKS = {
	add_prestige = -5
	add_estate_loyalty = {
		estate = estate_cossacks
		loyalty = 10
	}
	add_estate_influence_modifier = {
		estate = estate_cossacks
		desc = EST_VAL_COSSACK_REGISTER_EXPANDED
		influence = 10
		duration = 7300
	}
}
estate_action_RAISE_COSSACK_HOST_COSSACKS = {
	custom_tooltip = RAISE_COSSACK_HOST_COSSACKS_effect_tt
	hidden_effect = {
		if = {
			limit = {
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
		if = {
			limit = {
				num_of_owned_provinces_with = {
					value = 2
					has_terrain = steppe
				}
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
		if = {
			limit = {
				num_of_owned_provinces_with = {
					value = 3
					has_terrain = steppe
				}
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
		if = {
			limit = {
				num_of_owned_provinces_with = {
					value = 4
					has_terrain = steppe
				}
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
		if = {
			limit = {
				num_of_owned_provinces_with = {
					value = 5
					has_terrain = steppe
				}
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
		if = {
			limit = {
				num_of_owned_provinces_with = {
					value = 6
					has_terrain = steppe
				}
				estate_influence = {
					estate = estate_cossacks
					influence = 60
				}
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
		if = {
			limit = {
				num_of_owned_provinces_with = {
					value = 7
					has_terrain = steppe
				}
				estate_influence = {
					estate = estate_cossacks
					influence = 60
				}
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
		if = {
			limit = {
				num_of_owned_provinces_with = {
					value = 8
					has_terrain = steppe
				}
				estate_influence = {
					estate = estate_cossacks
					influence = 60
				}
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
		if = {
			limit = {
				num_of_owned_provinces_with = {
					value = 9
					has_terrain = steppe
				}
				estate_influence = {
					estate = estate_cossacks
					influence = 60
				}
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
		if = {
			limit = {
				num_of_owned_provinces_with = {
					value = 10
					has_terrain = steppe
				}
				estate_influence = {
					estate = estate_cossacks
					influence = 60
				}
				NOT = { army_size_percentage = 1 }
			}
			random_owned_province = {
				limit = { has_terrain = steppe }
				cossack_cavalry = ROOT
			}
			add_manpower = -1
		}
	}
	add_estate_loyalty = {
		estate = estate_cossacks
		loyalty = -15
	}
	add_estate_influence_modifier = {
		estate = estate_cossacks
		desc = EST_VAL_RAISED_COSSACK_HOST
		influence = 10
		duration = 1825
	}
}
estate_action_COSSACK_CONQUISTADOR_COSSACKS = {
	create_leader_scaling_with_tradition = {
		leader = conquistador
		type = army
	}
	#add_estate_influence_modifier = {
	#	estate = estate_cossacks
	#	desc = EST_VAL_COSSACK_CONQUISTADOR
	#	influence = 20
	#	duration = 10950
	#}
	add_estate_loyalty = {
		estate = estate_cossacks
		loyalty = -10
	}
}
estate_action_RECRUIT_MINISTER_COSSACKS = {
	generate_estate_advisor = {
		estate = estate_cossacks
		type = army_reformer
	}
	add_estate_loyalty = {
		estate = estate_cossacks
		loyalty = -10
	}
	#add_estate_influence_modifier = {
	#	estate = estate_cossacks
	#	desc = EST_VAL_COSSACKS_MINISTER
	#	influence = 20
	#	duration = 10950
	#}
	if = {
		limit = {
			has_estate = estate_nobles
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -15 #Taking offense to a cossack being used in government
		}
	}
}
estate_action_CONSCRIPT_COSSACK_ELITE_COSSACKS = {
	estate_action_tradition = {
		type = army
		estate = estate_cossacks
	}
	add_estate_loyalty = {
		estate = estate_cossacks
		loyalty = -15
	}
}
estate_action_SUPPLY_ARMS_COSSACKS = {
	add_mil_power = -15
	add_country_modifier = {
		name = "armed_cossacks"
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_cossacks
		loyalty = 5
	}
	add_estate_influence_modifier = {
		estate = estate_cossacks
		desc = EST_VAL_SUPPLY_ARMS
		influence = 15
		duration = 7300
	}
}
estate_action_PERMIT_SELF_GOVERNANCE_COSSACKS = {
	add_estate_loyalty = {
		estate = estate_cossacks
		loyalty = 5
	}
	add_estate_influence_modifier = {
		estate = estate_cossacks
		desc = EST_VAL_SELF_GOVERNANCE
		influence = 15
		duration = 7300
	}
	auto_complete_estate_agenda = {
		estate = estate_cossacks
	}
}
estate_action_RECRUIT_MINISTER_DHIMMI = {
	generate_estate_advisor = {
		estate = estate_dhimmi
		type = trader
	}
	add_estate_loyalty = {
		estate = estate_dhimmi
		loyalty = -10
	}
	#add_estate_influence_modifier = {
	#	estate = estate_dhimmi
	#	desc = EST_VAL_DHIMMI_MINISTER
	#	influence = 15
	#	duration = 10950
	#}
	if = {
		limit = { has_estate = estate_church }
		add_estate_loyalty = {
			estate = estate_church
			loyalty = -15
		}
	}
}
estate_action_LIGHTEN_DHIMMI_TAX_BURDEN_DHIMMI = {
	add_estate_loyalty = {
		estate = estate_dhimmi
		loyalty = 25
	}
	add_estate_influence_modifier = {
		estate = estate_dhimmi
		desc = EST_VAL_LIGHTEN_DHIMMI_TAX_BURDEN
		influence = 10
		duration = 3650
	}
}
estate_action_PROMOTE_DHIMMI_NOBLES_DHIMMI = {
	add_estate_loyalty = {
		estate = estate_dhimmi
		loyalty = 20
	}
	#add_country_modifier = {
	#	name = "dhimmi_nobles"
	#	duration = 10950
	#}
	add_estate_loyalty = {
		estate = estate_church
		loyalty = -15
	}
	add_estate_loyalty = {
		estate = estate_nobles
		loyalty = -15
	}
	add_estate_influence_modifier = {
		estate = estate_dhimmi
		desc = EST_VAL_DHIMMI_NOBLES
		influence = 15
		duration = 10950
	}
	auto_complete_estate_agenda = {
		estate = estate_dhimmi
	}
}
estate_action_RECRUIT_FROM_THE_DHIMMI_DHIMMI = {
	estate_action_yearly_manpower = {
		estate = estate_dhimmi
	}
	add_estate_loyalty = {
		estate = estate_dhimmi
		loyalty = -15
	}
	add_estate_influence_modifier = {
		estate = estate_dhimmi
		desc = EST_VAL_RECRUITED_DHIMMI
		influence = 10
		duration = 3650
	}
}
estate_action_DEMAND_CONTRIBUTION_DHIMMI = {
	estate_action_years_of_income = {
		estate = estate_dhimmi
	}
	add_estate_loyalty = {
		estate = estate_dhimmi
		loyalty = -15 #Take more offense than the Burghers do due to their supposedly protected status.
	}
	custom_tooltip = DEMAND_CONTRIBUTION_DHIMMI_effect_tt
	tooltip = {
		estate_action_scaling_province_modifier = {
			country = ROOT
			estate = estate_dhimmi
			name = DEMAND_CONTRIBUTION_DHIMMI
			duration = 3650
		}
	}
	hidden_effect = {
		every_owned_province = {
			limit = {
				NOT = { religion_group = ROOT }
			}
			estate_action_scaling_province_modifier = {
				country = ROOT
				estate = estate_dhimmi
				name = DEMAND_CONTRIBUTION_DHIMMI
				duration = 3650
			}
		}
	}
}
estate_action_PROCURE_LOANS_JAINS = {
	if = {
		limit = {
			NOT = {
				estate_influence = {
					estate = estate_jains
					influence = 50
				}
			}
		}
		add_loan = {
			interest_modifier = -0.5
			duration = 60
		}
	}
	if = {
		limit = {
			estate_influence = {
				estate = estate_jains
				influence = 50
			}
		}
		add_loan = {
			interest_modifier = -1
			duration = 60
		}
	}
	add_estate_influence_modifier = {
		estate = estate_jains
		desc = EST_VAL_JAIN_LOANS
		influence = 10
		duration = 3650
	}
}
estate_action_INVESTIGATE_CORRUPTION_JAINS = {
	add_corruption = -2
	add_estate_influence_modifier = {
		estate = estate_jains
		desc = EST_VAL_JAIN_CORRUPTION
		influence = 10
		duration = 3650
	}
}
estate_action_PATRONIZE_JAIN_FAMILIES_JAINS = {
	add_prestige = -5
	add_estate_loyalty = {
		estate = estate_jains
		loyalty = 15
	}
	add_estate_influence_modifier = {
		estate = estate_jains
		desc = EST_VAL_JAINS_PATRONIZED
		influence = 10
		duration = 7300
	}
	auto_complete_estate_agenda = {
		estate = estate_jains
	}
}
estate_action_COMMISSION_JAIN_SCRIPTURES_JAINS = {
	add_years_of_income = -0.25
	add_estate_loyalty = {
		estate = estate_jains
		loyalty = 10
	}
}
estate_action_DEMAND_SUPPORT_JAINS = {
	estate_action_monarch_power = {
		estate = estate_jains
		type = dip
	}
	add_estate_loyalty = {
		estate = estate_jains
		loyalty = -20
	}
}
estate_action_PROMOTE_MARATHA_NOBILITY_MARATHA = {
	add_prestige = -5
	add_estate_influence_modifier = {
		estate = estate_maratha
		desc = EST_VAL_PROMOTED_MARATHAS
		influence = 10
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_maratha
		loyalty = 15
	}
	auto_complete_estate_agenda = {
		estate = estate_maratha
	}
	if = {
		limit = {
			has_estate = estate_nobles
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -15
		}
	}
}
estate_action_RECRUIT_MINISTER_MARATHA = {
	if = {
		limit = {
			has_reform = permanent_marathas_council_reform
		}
		custom_tooltip = maratha_general.tooltip
		hidden_effect = {
			create_general = {
				tradition = 40
				add_shock = 1
				culture = marathi
			}
		}
	}
	generate_estate_advisor = {
		estate = estate_maratha
		type = commandant
	}
}
estate_action_RECRUIT_MARATHI_TROOPS_MARATHA = {
	#estate_action_yearly_manpower = {
	#	estate = estate_maratha
	#}
	estate_action_scaling_modifier = {
		estate = estate_maratha
		name = DEMAND_MORE_TROOPS_NOBLES
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_maratha
		loyalty = -15
	}
}
estate_action_DEMAND_SUPPORT_MARATHA = {
	estate_action_monarch_power = {
		estate = estate_maratha
		type = mil
	}
	add_estate_loyalty = {
		estate = estate_maratha
		loyalty = -20
	}
}
estate_action_CALL_DIET_NOBLES = {
	add_prestige = -5
	add_estate_loyalty = {
		estate = estate_nobles
		loyalty = 15
	}
	add_estate_influence_modifier = {
		estate = estate_nobles
		desc = EST_VAL_DIET_HELD
		influence = 10
		duration = 7300
	}
	auto_complete_estate_agenda = {
		estate = estate_nobles
	}
	if = {
		limit = {
			has_estate = estate_rajput
		}
		add_estate_loyalty = {
			estate = estate_rajput
			loyalty = -15
		}
	}
	else_if = {
		limit = {
			has_estate = estate_maratha
		}
		add_estate_loyalty = {
			estate = estate_maratha
			loyalty = -15
		}
	}
	if = {
		limit = {
			has_estate = estate_ghulams
		}
		add_estate_loyalty = {
			estate = estate_ghulams
			loyalty = -15
		}
	}
	if = {
		limit = {
			has_estate = estate_qizilbash
		}
		add_estate_loyalty = {
			estate = estate_qizilbash
			loyalty = -15
		}
	}
}
estate_action_GRANT_GENERALSHIP_NOBLES = {
	if = {
		limit = {
			has_country_flag = INC_upgrade_general_privilege_for_the_nobles_flag
		}
		create_general_scaling_with_tradition_and_pips = {
			add_shock = 1
			add_manuever = 1
		}
	}
	else = {
		create_leader_scaling_with_tradition = {
			leader = general
			type = army
		}
	}
	#add_estate_influence_modifier = {
	#	estate = estate_nobles
	#	desc = EST_VAL_GRANTED_GENERALSHIP
	#	influence = 20
	#	duration = 3650
	#}
	add_estate_loyalty = {
		estate = estate_nobles
		loyalty = -10
	}
	if = {
		limit = {
			has_estate = estate_rajput
		}
		add_estate_loyalty = {
			estate = estate_rajput
			loyalty = -5
		}
	}
	else_if = {
		limit = {
			has_estate = estate_maratha
		}
		add_estate_loyalty = {
			estate = estate_maratha
			loyalty = -5
		}
	}
	if = {
		limit = {
			has_estate = estate_qizilbash
		}
		add_estate_loyalty = {
			estate = estate_qizilbash
			loyalty = -5
		}
	}
	if = {
		limit = {
			has_estate = estate_ghulams
		}
		add_estate_loyalty = {
			estate = estate_ghulams
			loyalty = -5
		}
	}
}
estate_action_RECRUIT_CONQUISTADOR_ESTATES_NOBLES = {
	create_leader_scaling_with_tradition = {
		leader = conquistador
		type = army
	}
	#add_estate_influence_modifier = {
	#	estate = estate_nobles
	#	desc = EST_VAL_RECRUITED_CONQUISTADOR
	#	influence = 15
	#	duration = 5475
	#}
	add_estate_loyalty = {
		estate = estate_nobles
		loyalty = -15
	}
}
estate_action_DEMAND_SUPPORT_NOBLES = {
	estate_action_monarch_power = {
		estate = estate_nobles
		type = mil
	}
	add_estate_loyalty = {
		estate = estate_nobles
		loyalty = -20
	}
}
estate_action_RECRUIT_MINISTER_NOBLES = {
	generate_estate_advisor = {
		estate = estate_nobles
		type = diplomat
	}
	if = {
		limit = {
			has_country_flag = GER_upgrade_the_statesman_privilege_flag
		}
		generate_estate_advisor = {
			estate = estate_nobles
			type = statesman
		}
	}
	#add_estate_influence_modifier = {
	#	estate = estate_nobles
	#	desc = EST_VAL_NOBLES_MINISTER
	#	influence = 15
	#	duration = 10950
	#}
	add_estate_loyalty = {
		estate = estate_nobles
		loyalty = -10
	}
	if = {
		limit = {
			has_estate = estate_rajput
		}
		add_estate_loyalty = {
			estate = estate_rajput
			loyalty = -5
		}
	}
	else_if = {
		limit = {
			has_estate = estate_maratha
		}
		add_estate_loyalty = {
			estate = estate_maratha
			loyalty = -5
		}
	}
	if = {
		limit = {
			has_estate = estate_qizilbash
		}
		add_estate_loyalty = {
			estate = estate_qizilbash
			loyalty = -5
		}
	}
	if = {
		limit = {
			has_estate = estate_ghulams
		}
		add_estate_loyalty = {
			estate = estate_ghulams
			loyalty = -5
		}
	}
}
estate_action_DEMAND_MORE_TROOPS_NOBLES = {
	#estate_action_yearly_manpower = {
	#	estate = estate_nobles
	#}
	estate_action_scaling_modifier = {
		estate = estate_nobles
		name = DEMAND_MORE_TROOPS_NOBLES
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_nobles
		loyalty = -15
	}
}
estate_action_SUPPORT_TRIBES_NOMADIC_TRIBES = {
	add_years_of_income = -0.25
	add_estate_loyalty = {
		estate = estate_nomadic_tribes
		loyalty = 10
	}
}
estate_action_CONTRIBUTE_WARRIORS_NOMADIC_TRIBES = {
	#add_yearly_manpower = 2.5
	estate_action_scaling_modifier = {
		estate = estate_nomadic_tribes
		name = CONTRIBUTE_WARRIORS_NOMADIC_TRIBES
		duration = 3650
	}
	add_estate_loyalty = {
		estate = estate_nomadic_tribes
		loyalty = -15
	}
}
estate_action_RAISE_HOST_NOMADIC_TRIBES = {
	capital_scope = {
		add_unit_construction = {
			type = cavalry
			amount = 5
			speed = 0.25
			cost = 0
		}
	}
	create_leader_scaling_with_tradition = {
		type = army
		leader = general
	}
	add_estate_influence_modifier = {
		estate = estate_nomadic_tribes
		desc = EST_VAL_RAISED_HOST
		influence = 15
		duration = 3650
	}
}
estate_action_REDISTRIBUTE_HORDE_AUTHORITY_TRIBES = {
	add_horde_unity = -5
	add_estate_loyalty = {
		estate = estate_nomadic_tribes
		loyalty = 15
	}
	auto_complete_estate_agenda = {
		estate = estate_nomadic_tribes
	}
}
estate_action_STRENGTHEN_TRIBAL_AUTONOMY = {
	estate_action_monarch_power = {
		estate = estate_nomadic_tribes
		type = mil
	}
	estate_action_tradition = {
		estate = estate_nomadic_tribes
		type = army
	}
	add_estate_influence_modifier = {
		estate = estate_nomadic_tribes
		desc = EST_VAL_STRENGTHENED_TRIBAL_AUTONOMY
		influence = 10
		duration = 3650
	}
}
estate_action_RECRUIT_MINISTER_NOMADIC_TRIBES = {
	generate_estate_advisor = {
		estate = estate_nomadic_tribes
		type = recruitmaster
	}			
	#add_estate_influence_modifier = {
	#	estate = estate_nomadic_tribes
	#	desc = EST_VAL_NOMAD_MINISTER
	#	influence = 15
	#	duration = 10950
	#}
	add_estate_loyalty = {
		estate = estate_nomadic_tribes
		loyalty = -10
	}
}
estate_action_RECRUIT_RAJPUT_GENERAL_RAJPUT = {
	custom_tooltip = rajput_general.tooltip
	hidden_effect = {
		create_general = {
			tradition = 40
			add_fire = 1
			culture = rajput
		}
	}
	add_estate_influence_modifier = {
		estate = estate_rajput
		desc = EST_VAL_GRANTED_GENERALSHIP
		influence = 20
		duration = 3650
	}
	if = {
		limit = {
			has_estate = estate_nobles
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -5
		}
	}
}
estate_action_LOOK_UP_PURBIAS_RAJPUT = {
	if = {
		limit = {
			has_reform = governmental_purbias_register_reform
		}
		add_country_modifier = {
			name = "look_up_purbias_upgraded"
			duration = 3650
		}
	}
	else = {
		add_country_modifier = {
			name = "look_up_purbias"
			duration = 3650
		}
	}
	add_years_of_income = -0.25
}
estate_action_DEMAND_SUPPORT_RAJPUT = {
	estate_action_monarch_power = {
		estate = estate_rajput
		type = mil
	}
	add_estate_loyalty = {
		estate = estate_rajput
		loyalty = -20
	}
}
estate_action_EXEMPT_FROM_JIZYA_RAJPUT = {
	add_years_of_income = -0.5
	add_estate_loyalty = {
		estate = estate_rajput
		loyalty = 15
	}
	if = {
		limit = {
			has_estate = estate_nobles
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -15
		}
	}
}
estate_action_PROMOTE_RAJPUT_NOBILITY_RAJPUT = {
	add_prestige = -5
	add_estate_influence_modifier = {
		estate = estate_rajput
		desc = EST_VAL_PROMOTED_RAJPUTS
		influence = 10
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_rajput
		loyalty = 15
	}
	auto_complete_estate_agenda = {
		estate = estate_rajput
	}
	if = {
		limit = {
			has_estate = estate_nobles
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -15
		}
	}
}
estate_action_RECRUIT_RAJPUT_TROOPS_RAJPUT = {
	#estate_action_yearly_manpower = {
	#	estate = estate_rajput
	#}
	estate_action_scaling_modifier = {
		estate = estate_rajput
		name = DEMAND_MORE_TROOPS_NOBLES
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_rajput
		loyalty = -15
	}
}
estate_action_ASK_FOR_CONTRIBUTION_VAISYAS = {
	#estate_action_years_of_income = {
	#	estate = estate_vaisyas
	#}
	estate_action_scaling_modifier = {
		estate = estate_vaisyas
		name = ASK_FOR_CONTRIBUTION_VAISYAS
		duration = 3650
	}
	add_estate_loyalty = {
		estate = estate_vaisyas
		loyalty = -10
	}
}
estate_action_DEMAND_SUPPORT_VAISYAS = {
	estate_action_monarch_power = {
		estate = estate_vaisyas
		type = dip
	}
	add_estate_loyalty = {
		estate = estate_vaisyas
		loyalty = -20
	}
}
estate_action_SEEK_GUILD_SUPPORT_VAISYAS = {
	add_prestige = -5
	add_estate_influence_modifier = {
		estate = estate_vaisyas
		desc = EST_VAL_GUILD_SUPPORT
		influence = 10
		duration = 7300
	}
	add_estate_loyalty = {
		estate = estate_vaisyas
		loyalty = 15
	}
	auto_complete_estate_agenda = {
		estate = estate_vaisyas
	}
}
estate_action_RECRUIT_MINISTER_VAISYAS = {
	generate_estate_advisor = {
		estate = estate_vaisyas
		type = master_of_mint
	}
	#add_estate_influence_modifier = {
	#	estate = estate_vaisyas
	#	desc = EST_VAL_BURGHER_MINISTER
	#	influence = 15
	#	duration = 10950
	#}
	add_estate_loyalty = {
		estate = estate_vaisyas
		loyalty = -10
	}
}
estate_action_COMISSION_MERCHANT_SHIPS_FOR_WAR_VAISYAS = {
	#add_estate_loyalty = {
	#	estate = estate_vaisyas
	#	loyalty = -15
	#}
	add_ship_construction_scaled_to_ports = {
		type = heavy_ship
	}
}
estate_action_GRANT_QIZILBASH_HORSES = {
	capital_scope = {
		create_units_of_type_in_province = {
			custom_tooltip = 4_QIZILBASH_CAVALRY_FOR_ROOT
			amount = 4
			unit_type = qizilbash_cavalry
			who = root
		}
	}
	add_estate_influence_modifier = {
		estate = estate_qizilbash
		desc = EST_GRANT_QIZILBASH_HORSES
		influence = 10
		duration = 7300
	}
	auto_complete_estate_agenda = {
		estate = estate_qizilbash
	}
	if = {
		limit = {
			has_estate = estate_ghulams
		}
		add_estate_loyalty = {
			estate = estate_ghulams
			loyalty = -15
		}
	}
	if = {
		limit = {
			has_estate = estate_nobles
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -15
		}
	}
}
estate_action_PROMOTE_CAUCASIAN_TROOPS = {
	add_yearly_manpower = 0.5
	add_estate_influence_modifier = {
		estate = estate_ghulams
		desc = EST_PROMOTE_CAUCASIAN_TROOPS
		influence = 10
		duration = 7300
	}
	auto_complete_estate_agenda = {
		estate = estate_ghulams
	}
	if = {
		limit = {
			has_estate = estate_nobles
		}
		add_estate_loyalty = {
			estate = estate_nobles
			loyalty = -15
		}
	}
	if = {
		limit = {
			has_estate = estate_qizilbash
		}
		add_estate_loyalty = {
			estate = estate_qizilbash
			loyalty = -15
		}
	}
}

# Supports the following paramters
###########################################
# MAKE_GENEROUS_DONATION_BRAHMINS
# SEEK_SUPPORT_OF_BRAHMINS
# RECRUIT_MINISTER_BRAHMINS
# RECRUIT_INQUISITOR_BRAHMINS
# DEMAND_SUPPORT_BRAHMINS
# SEEK_BRAHMIN_LEGITIMACY_BRAHMINS
# ASK_FOR_CONTRIBUTION_BURGHERS
# DEMAND_SUPPORT_BURGHERS
# GRANT_MONOPOLY_CHARTER_BURGHERS
# RECRUIT_MINISTER_BURGHERS
# GRANT_ADMIRALSHIP_BURGHERS
# GRANT_NEW_WORLD_CHARTER_BURGHERS
# COMISSION_MERCHANT_SHIPS_FOR_WAR_BURGHERS
# MAKE_GENEROUS_DONATION_CHURCH
# RECRUIT_MINISTER_CHURCH
# RECRUIT_INQUISITOR_CHURCH
# RELIGIOUS_DELEGATION_CHURCH
# DEMAND_SUPPORT_CHURCH
# SEEK_SUPPORT_OF_CLERGY_CHURCH
# NEW_WORLD_MISSION_CHURCH
# EXPAND_COSSACK_REGISTRY_COSSACKS
# RAISE_COSSACK_HOST_COSSACKS
# COSSACK_CONQUISTADOR_COSSACKS
# RECRUIT_MINISTER_COSSACKS
# CONSCRIPT_COSSACK_ELITE_COSSACKS
# SUPPLY_ARMS_COSSACKS
# PERMIT_SELF_GOVERNANCE_COSSACKS
# RECRUIT_MINISTER_DHIMMI
# LIGHTEN_DHIMMI_TAX_BURDEN_DHIMMI
# PROMOTE_DHIMMI_NOBLES_DHIMMI
# RECRUIT_FROM_THE_DHIMMI_DHIMMI
# DEMAND_CONTRIBUTION_DHIMMI
# PROCURE_LOANS_JAINS
# INVESTIGATE_CORRUPTION_JAINS
# PATRONIZE_JAIN_FAMILIES_JAINS
# COMMISSION_JAIN_SCRIPTURES_JAINS
# DEMAND_SUPPORT_JAINS
# PROMOTE_MARATHA_NOBILITY_MARATHA
# RECRUIT_MINISTER_MARATHA
# RECRUIT_MARATHI_TROOPS_MARATHA
# DEMAND_SUPPORT_MARATHA
# CALL_DIET_NOBLES
# GRANT_GENERALSHIP_NOBLES
# RECRUIT_CONQUISTADOR_ESTATES_NOBLES
# DEMAND_SUPPORT_NOBLES
# RECRUIT_MINISTER_NOBLES
# DEMAND_MORE_TROOPS_NOBLES
# SUPPORT_TRIBES_NOMADIC_TRIBES
# CONTRIBUTE_WARRIORS_NOMADIC_TRIBES
# RAISE_HOST_NOMADIC_TRIBES
# RECRUIT_MINISTER_NOMADIC_TRIBES
# RECRUIT_RAJPUT_GENERAL_RAJPUT
# LOOK_UP_PURBIAS_RAJPUT
# DEMAND_SUPPORT_RAJPUT
# EXEMPT_FROM_JIZYA_RAJPUT
# PROMOTE_RAJPUT_NOBILITY_RAJPUT
# ASK_FOR_CONTRIBUTION_VAISYAS
# DEMAND_SUPPORT_VAISYAS
# SEEK_GUILD_SUPPORT_VAISYAS
# RECRUIT_MINISTER_VAISYAS
# COMISSION_MERCHANT_SHIPS_FOR_WAR_VAISYAS
# GRANT_QIZILBASH_HORSES
# PROMOTE_CAUCASIAN_TROOPS
estate_action = {
	estate_action_$estate_action$ = yes
}

enable_estate_action = {
	custom_tooltip = enable_estate_action_$estate_action$_tt
	custom_tooltip = estate_action_potential_effect
	tooltip = {
		estate_action_$estate_action$ = yes
	}
	hidden_effect = {
		set_country_flag = enable_estate_action_$estate_action$
	}
}

disable_estate_action = {
	custom_tooltip = disable_estate_action_$estate_action$_tt
	hidden_effect = {
		clr_country_flag = enable_estate_action_$estate_action$
	}
}

set_estate_action_cooldown = {
	hidden_effect = {
		clr_country_flag = $estate_action$_flag
		set_country_flag = $estate_action$_flag
	}
}

increase_estate_action_counter = {
	hidden_effect = {
		change_variable = {
			which = general_estate_action_counter
			value = 1
		}
		change_variable = {
			which = $estate$_action_counter
			value = 1
		}
	}
}

scaling_with_influence_privilege_tooltip = {
	custom_tooltip = scaling_with_estate_influence_tt
	custom_tooltip = when_loyal_tt
	tooltip = {
		add_country_modifier = {
			name = $estate_privilege$_loyal
			duration = -1
			desc = UNTIL_REVOKED
		}
	}
	custom_tooltip = when_neutral_tt
	tooltip = {
		add_country_modifier = {
			name = $estate_privilege$_neutral
			duration = -1
			desc = UNTIL_REVOKED
		}
	}
	custom_tooltip = when_disloyal_tt
	tooltip = {
		add_country_modifier = {
			name = $estate_privilege$_disloyal
			duration = -1
			desc = UNTIL_REVOKED
		}
	}
}

scaling_with_loyalty_privilege_tooltip = {
	custom_tooltip = scaling_with_estate_loyalty_tt
	tooltip = {
		add_country_modifier = {
			name = $estate_privilege$_scaling
			duration = -1
			desc = UNTIL_REVOKED
		}
	}
}

block_estate_removing_reforms = {
	custom_tooltip = block_estate_removing_reforms_tt
	hidden_effect = {
		set_country_flag = block_$estate$_removing_reform
	}
}

unblock_estate_removing_reforms = {
	custom_tooltip = unblock_estate_removing_reforms_tt
	hidden_effect = {
		clr_country_flag = block_$estate$_removing_reform
	}
}

#Just write here a custom tooltip
transfer_crownland_share = {
	if = {
		limit = {
			has_estate = $from_estate$
			has_estate = $target_estate$
		}
		[[custom_tooltip]custom_tooltip = $custom_tooltip$]
		hidden_effect = {
			set_variable = {
				which = amount_to_transfer
				value = $amount$
			}
			while = {
				limit = { check_variable = { which = amount_to_transfer value = 1 } }
				change_estate_land_share = { estate = $from_estate$ share = -1 }
				change_estate_land_share = { estate = $target_estate$ share = 1 }
				change_variable = { which = amount_to_transfer value = -1 }
			}
		}
	}
}

transfer_percentage_crownland_share = {
	if = {
		limit = {
			has_estate = $from_estate$
			has_estate = $target_estate$
		}
		[[custom_tooltip]custom_tooltip = $custom_tooltip$]
		hidden_effect = {
			set_variable = {
				which = crownland_to_transfer
				value = 0
			}
			set_variable = {
				which = transferable_crownland
				value = 0
			}
			set_variable = {
				which = percentage_multiplier
				value = $amount$
			}
			#Calc how much in total Crownland there is to transfer
			while = {
				limit = { estate_territory = { estate = $from_estate$ territory = 1 } }
				change_estate_land_share = { estate = $from_estate$ share = -1 }
				change_variable = { which = transferable_crownland value = 1 }
				change_variable = { which = crownland_to_transfer value = 1 }
			}
			#Restore the stolen crownland
			while = {
				limit = { check_variable = { which = transferable_crownland value = 1 } }
				change_estate_land_share = { estate = $from_estate$ share = 1 }
				change_variable = { which = transferable_crownland value = -1 }
			}
			#Use the multiplier and then transfer the actual percentage of crownland
			multiply_variable = {
				which = crownland_to_transfer
				which = percentage_multiplier
			}
			while = {
				limit = { check_variable = { which = crownland_to_transfer value = 1 } }
				change_estate_land_share = { estate = $target_estate$ share = 1 }
				change_estate_land_share = { estate = $from_estate$ share = -1 }
				change_variable = { which = crownland_to_transfer value = -1 }
			}
		}
	}
}

# Supports the following parameters
###########################################
# estate_nobles
# estate_brahmins
# estate_burghers
# estate_church
# estate_cossacks
# estate_dhimmi
# estate_jains
# estate_maratha
# estate_nomadic_tribes
# estate_rajput
# estate_vaisyas
# estate_janissaries
# estate_eunuchs
# estate_qizilbash
# estate_ghulams
# all	- have ALL of them available
select_grand_vizier_from_estate = {
	custom_tooltip = select_grand_vizier_from_estate_$estate$_tt
	add_estate_loyalty = {
		estate = $estate$
		loyalty = 10
	}
	add_estate_influence_modifier = {
		desc = GRAND_VIZIER_FROM_ESTATE
		estate = $estate$
		influence = 5
		duration = 3650
		short = yes
	}
	hidden_effect = {
		set_country_flag = selected_$type$_advisor
		set_country_flag = selected_grand_vizier_from_$estate$
		country_event = {
			id = estate_privileges_and_agendas_events.9
		}
	}
}
clr_grand_vizier_flags = {
	clr_country_flag = selected_grand_vizier_from_estate_nobles
	clr_country_flag = selected_grand_vizier_from_estate_brahmins
	clr_country_flag = selected_grand_vizier_from_estate_burghers
	clr_country_flag = selected_grand_vizier_from_estate_church
	clr_country_flag = selected_grand_vizier_from_estate_cossacks
	clr_country_flag = selected_grand_vizier_from_estate_dhimmi
	clr_country_flag = selected_grand_vizier_from_estate_jains
	clr_country_flag = selected_grand_vizier_from_estate_maratha
	clr_country_flag = selected_grand_vizier_from_estate_nomadic_tribes
	clr_country_flag = selected_grand_vizier_from_estate_rajput
	clr_country_flag = selected_grand_vizier_from_estate_vaisyas
	clr_country_flag = selected_grand_vizier_from_estate_janissaries
	clr_country_flag = selected_grand_vizier_from_estate_eunuchs
	clr_country_flag = selected_grand_vizier_from_estate_qizilbash
	clr_country_flag = selected_grand_vizier_from_estate_ghulams
	clr_country_flag = selected_grand_vizier_from_all
}