estate_church =
{
	icon = 1
	
	color = { 200 150 0 }
	
	# Is estate kept in control of province on conquest?
	keep_on_conquest = no
	
	# Estate will always be removed when conquered by a different religion than previous owner
	always_remove_on_religious_conquest = yes
	
	# They want to control at least this % of the country's non-overseas development, if # of home provinecs is above set amount
	min_territory = 10 
	min_provinces_to_want_territory = 10
	wanted_territory_modifier = {
		desc = EST_VAL_HINDU_CLERGY
		trigger = {
			religion = hinduism
		}	
		value = -5
	}
	wanted_territory_modifier = {
		desc = EST_VAL_PAPAL_LANDS
		trigger = {
			tag = PAP
		}	
		value = -10
	}
	wanted_territory_modifier = {
		desc = EST_VAL_CATHOLIC
		trigger = {
			religion = catholic
			NOT = { tag = PAP }
		}	
		value = 5
	}
	wanted_territory_modifier = {
		desc = EST_VAL_THEOCRACY
		trigger = {
			government = theocracy
			NOT = { tag = PAP }
		}	
		value = 5
	}	

	# If true, country will get estate
	trigger = {
		NOT = { government = merchant_republic }
		NOT = { government = trading_city }
		NOT = { government = siberian_native_council }
		NOT = { government = native_council }
		NOT = { government = revolutionary_republic }
		OR = {
			NOT = { government = celestial_empire }
			has_dlc = "Mandate of Heaven"
		}
		#OR = {
		#	NOT = { tag = USA }
		#	government = theocracy
		#}
		is_nomad = no
		is_colonial_nation = no
	}
	
	# If true, province can be granted to estate
	province_trigger = {
		always = yes
	}
	
	# Min autonomy in estate provinces
	min_autonomy = 25
	
	# Estate cancels out the following multiplicative local autonomy effects:
	autonomy_does_not_affect = local_tax_modifier

	# These scale with loyalty & power
	country_modifier_happy = {
		global_tax_modifier = 0.2
		papal_influence = 1
		devotion = 0.5
		church_power_modifier = 0.1
		monthly_fervor_increase = 1
		stability_cost_modifier = -0.1
	}
	country_modifier_neutral = {
		global_tax_modifier = 0.2
	}	
	country_modifier_angry = {
		global_tax_modifier = -0.1
		papal_influence = -1
		devotion = -0.5
		church_power_modifier = -0.25
		monthly_fervor_increase = -1
		stability_cost_modifier = 0.1
	}	
	
	# These do not scale, but only applied in provinces owned by the estate
	province_modifier_happy = {
		local_missionary_strength = 0.02
		local_tax_modifier = 0.1
		local_unrest = -2
	}
	province_modifier_neutral = {
		local_unrest = -2
	}	
	province_modifier_angry = {
		local_unrest = 5
	}	
	
	# Influence modifiers
	base_influence = 20
	influence_modifier = {
		desc = EST_VAL_THEOCRACY
		trigger = {
			government = theocracy
			NOT = { tag = PAP }
		}	
		influence = 10
	}
	influence_modifier = {
		desc = EST_VAL_PAPACY
		trigger = {
			tag = PAP
		}
		influence = 30
	}
	influence_modifier = {
		desc = EST_VAL_SHARIFS
		trigger = {
			tag = HED
			owns = 385 #Mecca
		}	
		influence = 20
	}
	influence_modifier = {
		desc = EST_VAL_STATE_RELIGIOUS_MINORITY
		trigger = {
			NOT = { dominant_religion = ROOT }
		}	
		influence = -15
	}
	influence_modifier = {
		desc = EST_VAL_VERY_HIGH_PATRIARCH_AUTHORITY
		trigger = {
			religion = orthodox
			patriarch_authority = 0.75
		}	
		influence = 10
	}
	influence_modifier = {
		desc = EST_VAL_HIGH_PATRIARCH_AUTHORITY
		trigger = {
			religion = orthodox
			patriarch_authority = 0.5
			NOT = { patriarch_authority = 0.75 }
		}	
		influence = 5
	}
	influence_modifier = {
		desc = EST_VAL_VERY_HIGH_INTI_AUTHORITY
		trigger = {
			has_dlc = "El Dorado"
			religion = inti
			authority = 75
		}	
		influence = 15
	}
	influence_modifier = {
		desc = EST_VAL_HIGH_INTI_AUTHORITY
		trigger = {
			has_dlc = "El Dorado"
			religion = inti
			authority = 50
			NOT = { authority = 75 }
		}	
		influence = 10
	}
	influence_modifier = {
		desc = EST_VAL_OTHER_ESTATE_IN_POWER
		trigger = {
			OR = {
				has_disaster = estate_nobility_disaster
				has_disaster = estate_burghers_disaster
			}
		}
		influence = -40
	}
	influence_modifier = {
		desc = EST_VAL_CELESTIAL_EMPIRE
		trigger = {
			government = celestial_empire
		}		
		influence = -10
	}
	
	# Loyalty modifiers
	loyalty_modifier = {
		desc = EST_VAL_PIOUS
		trigger = {
			religion_group = muslim
			piety = 0.5
			NOT = { piety = 0.75 }
		}
		loyalty = 5
	}
	loyalty_modifier = {
		desc = EST_VAL_VERY_PIOUS
		trigger = {
			religion_group = muslim
			piety = 0.75
		}
		loyalty = 10
	}
	loyalty_modifier = {
		desc = EST_VAL_NOT_PIOUS
		trigger = {
			religion_group = muslim
			NOT = { piety = -0.5 }
			piety = -0.75
		}
		loyalty = -5
	}
	loyalty_modifier = {
		desc = EST_VAL_VERY_UNPIOUS
		trigger = {
			religion_group = muslim
			NOT = { piety = -0.75 }
		}
		loyalty = -10
	}
	loyalty_modifier = {
		desc = EST_VAL_PROTESTANT
		trigger = {
			religion = protestant
		}
		loyalty = 10
	}
	loyalty_modifier = {
		desc = EST_VAL_PAPAL_CONTROLLER
		trigger = {
			is_papal_controller = yes
		}
		loyalty = 10
	}
	loyalty_modifier = {
		desc = EST_VAL_STATUTE_IN_RESTRAINTS
		trigger = {
			has_country_modifier = the_statue_in_restraint_of_appeals
		}
		loyalty = 5
	}
	loyalty_modifier = {
		desc = EST_VAL_SHEIKH_UL_ISLAM
		trigger = {
			has_country_modifier = the_sheikh_ul_islam
		}
		loyalty = 5
	}
	loyalty_modifier = {
		desc = EST_VAL_OTHER_ESTATE_IN_POWER_LOY
		trigger = {
			OR = {
				has_disaster = estate_nobility_disaster
				has_disaster = estate_burghers_disaster
			}
		}
		loyalty = -20
	}
	loyalty_modifier = {
		desc = EST_VAL_FULL_RELIGIOUS
		trigger = {
			full_idea_group = religious_ideas
		}
		loyalty = 10
	}
	
	custom_name = {
		desc = estate_monasteries
		trigger = {
			OR = {
				religion = buddhism #Theravada
				religion = mahayana
				religion = vajrayana
			}
		}
	}
	custom_name = {
		desc = estate_brahmins
		trigger = {
			religion = hinduism
		}
	}
	custom_name = {
		desc = estate_gentry
		trigger = {
			OR = {
				government = celestial_empire
				culture_group = east_asian
				culture_group = californian
			}
		}
	}
	custom_name = {
		desc = estate_ulema
		trigger = {
			religion_group = muslim
		}
	}
	custom_name = {
		desc = estate_tlamacazqueh
		trigger = {
			religion = mictlantec
		}
	}
	custom_name = {
		desc = estate_judiciary
		trigger = {
			religion = americanist
		}
	}
	custom_name = {
		desc = estate_tech_priests #Could also be railroads based on individual titles
		trigger = {
			religion = rust_cultist
		}
	}
	
	# For province assignment
	ai_grant_province = {
		factor = 1
		modifier = {
			factor = 10
			has_owner_religion = no
			NOT = { tolerance_to_this = 1 }
		}
		modifier = {
			factor = 0.1
			has_estate = estate_cossacks
			has_terrain = steppe
		}
		modifier = {
			factor = 0.75
			has_owner_culture = yes
		}
		modifier = {
			factor = 0.75
			province_trade_power = 5
		}			
		modifier = {
			factor = 0.75
			province_trade_power = 10
		}			
	}
	
	# Does the AI want to give any extra territory beyond the minimum?
	ai_territory_modifier = {
		trigger = {
			has_idea_group = religious_ideas
			num_of_cities = 10
		}	
		value = 10		
	}		
	
	# Special interactions
	interaction = {
		name = "DEMAND_SUPPORT_CHURCH"
		icon = 2
		
		years_between_use = 20
		
		potential = {
			NOT = { has_disaster = estate_nobility_disaster }
			NOT = { has_disaster = estate_burghers_disaster }
		}
		
		trigger = {		
			estate_loyalty = {
				estate = estate_church
				loyalty = 30
			}	
			estate_influence = {
				estate = estate_church
				influence = 25
			}			
		}
		
		effect = {
			if = {
				limit = {
					NOT = {
						estate_influence = {
							estate = estate_church
							influence = 50
						}	
					}
				}
				add_adm_power = 50
			}
			if = {
				limit = {
					estate_influence = {
						estate = estate_church
						influence = 50
					}
					NOT = {
						estate_influence = {
							estate = estate_church
							influence = 75
						}	
					}
				}
				add_adm_power = 100
			}
			if = {
				limit = {
					estate_influence = {
						estate = estate_church
						influence = 75
					}
					NOT = {
						estate_influence = {
							estate = estate_church
							influence = 100
						}	
					}
				}
				add_adm_power = 150
			}
			if = {
				limit = {
					estate_influence = {
						estate = estate_church
						influence = 100
					}
				}
				add_adm_power = 200
			}				
			add_estate_loyalty = {
				estate = estate_church
				loyalty = -20
			}
		}
		
		ai_will_do = {
			factor = 0		
		}
	}
	interaction = {
		name = "MAKE_GENEROUS_DONATION"
		icon = 7
		
		years_between_use = 10
		
		potential = {
			NOT = { has_disaster = estate_nobility_disaster }
			NOT = { has_disaster = estate_burghers_disaster }
		}
		
		trigger = {
			always = yes
		}
		
		effect = {
			add_years_of_income = -0.25
			add_estate_loyalty = {
				estate = estate_church
				loyalty = 15
			}
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				NOT = { years_of_income = 0.5 }				
			}
			modifier = {
				factor = 0
				estate_loyalty = {
					estate = estate_church
					loyalty = 40
				}
			}			
		}		
	}
	interaction = {
		name = "SEEK_SUPPORT_OF_CLERGY"
		icon = 17
		
		years_between_use = 20
		
		trigger = {
			always = yes
		}
		
		effect = {
			add_prestige = -5
			add_legitimacy = -5
			add_republican_tradition = -3
			add_devotion = -3
			add_piety = 0.05
			if = {
				limit = { religion = protestant }
				add_church_power = 10
			}
			add_patriarch_authority = 0.05
			if = {
				limit = { religion = reformed }
				add_fervor = 10
			}
			add_estate_influence_modifier = {
				estate = estate_church
				desc = EST_VAL_SOUGHT_SUPPORT
				influence = 10
				duration = 7300
			}
			add_estate_loyalty = {
				estate = estate_church
				loyalty = 15
			}
		}
	
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				estate_loyalty = {
					estate = estate_church
					loyalty = 30
				}						
			}
			modifier = {
				factor = 0
				estate_influence = {
					estate = estate_church
					influence = 60
				}						
			}			
		}
	}
	interaction = {
		name = "RECRUIT_MINISTER"
		icon = 10
		
		potential = {
			NOT = { has_disaster = estate_nobility_disaster }
			NOT = { has_disaster = estate_burghers_disaster }
		}
		
		years_between_use = 30
		
		trigger = {
			estate_influence = {
				estate = estate_church
				influence = 40
			}
		}
		
		effect = {
			if = {
				limit = {
					monthly_income = 25
				}
				define_advisor = {
					type = theologian
					skill = 3
					discount = yes
				}
			}
			if = {
				limit = { NOT = { monthly_income = 25 } }
				define_advisor = {
					type = theologian
					skill = 2
					discount = yes
				}
			}
			add_estate_influence_modifier = {
				estate = estate_church
				desc = EST_VAL_CLERGY_MINISTER
				influence = 15
				duration = 10950
			}
		}
		
		ai_will_do = {
			factor = 0			
		}
	}
	interaction = {
		name = "RECRUIT_INQUISITOR"
		icon = 11
		
		potential = {
			NOT = { has_disaster = estate_nobility_disaster }
			NOT = { has_disaster = estate_burghers_disaster }
		}
		
		years_between_use = 30
		
		trigger = {
			estate_influence = {
				estate = estate_church
				influence = 40
			}
		}
		
		effect = {
			if = {
				limit = {
					monthly_income = 25
				}
				define_advisor = {
					type = inquisitor
					skill = 3
					discount = yes
				}
			}
			if = {
				limit = { NOT = { monthly_income = 25 } }
				define_advisor = {
					type = inquisitor
					skill = 2
					discount = yes
				}
			}
			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
				}
			}
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	interaction = {
		name = "NEW_WORLD_MISSION"
		icon = 15
		
		years_between_use = 20
		
		potential = {
			has_idea_group = exploration_ideas
			NOT = { has_disaster = estate_nobility_disaster }
			NOT = { has_disaster = estate_burghers_disaster }
		}
		
		trigger = {
			estate_influence = {
				estate = estate_church
				influence = 40
			}
		}
		
		effect = {
			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
			}
		}
		
		ai_will_do = {
			factor = 0			
		}
	}
	interaction = {
		name = "SEND_EMISSARY_TO_POPE"
		icon = 14
		
		years_between_use = 20
		
		potential = {
			religion = catholic
			NOT = { tag = PAP }
			NOT = { has_disaster = estate_nobility_disaster }
			NOT = { has_disaster = estate_burghers_disaster }
		}
		
		trigger = {
			estate_influence = {
				estate = estate_church
				influence = 40
			}
		}
		
		effect = {
			add_papal_influence = 10
			add_estate_influence_modifier = {
				estate = estate_church
				desc = EST_VAL_EMISSARY_TO_POPE
				influence = 10
				duration = 7300
			}
		}
	
		ai_will_do = {
			factor = 0			
		}	
	}
}