interaction = {
    key = sale_of_titles
    random_seed = crown_land_share
	cooldown_months = 60

    trigger = {
        crown_land_share = 10
        NOT = { num_of_rebel_armies = 1 }
		NOT = { num_of_rebel_controlled_provinces = 1 }
		hidden_trigger = { has_any_estates = yes }
    }
    effect = {
		if = {
			limit = {
				religion = inti
				check_variable = {
					which = inca_amount_of_mummies
					value = 1
				}
			}
			INC_sell_crownland_modified_by_mummies = yes
		}
		else_if = {
			limit = { 
				NOT = { has_government_attribute = no_crownland_money_loss_to_age } 
				NOT = { has_country_flag = enable_full_ducat_gain_from_selling_crownland_flag }
			}
			if = {
				limit = { current_age = age_of_discovery }
				add_years_of_estate_land_income = 2.5
			}
			else_if = {
				limit = { current_age = age_of_reformation }
				add_years_of_estate_land_income = 2.0
			}
			else_if = {
				limit = { current_age = age_of_absolutism }
				add_years_of_estate_land_income = 1.5
			}
			else_if = {
				limit = { current_age = age_of_revolutions }
				add_years_of_estate_land_income = 1.0
			}
		}
		else = {
			add_years_of_estate_land_income = 2.5
		}
		if = {
			limit = {
				NOT = { has_government_attribute = can_sell_crownland_to_single_estates }
				NOT = { has_country_flag = can_sell_crownland_to_estates_targeted_flag }
			}
			custom_tooltip = ESTATES_SALE_OF_TITLES_DESC
			give_estate_land_share_gigantic = { estate = all }
			add_estate_loyalty = {
				estate = all
				loyalty = 10
				short = yes
			}
			if = {
				limit = {
					has_government_attribute = selling_titles_increases_pa
				}
				add_patriarch_authority = 0.05
			}
		}
		else = {
			country_event = {
				id = estate_privileges_and_agendas_events.6
			}
		}
		if = {
			limit = {
				has_country_flag = recent_land_distribution
			}
			clr_country_flag = recent_land_distribution
		}
		set_country_flag = recent_land_distribution
		on_sale_of_titles_effect = yes
    }
	ai_will_do = {
		factor = 25
		modifier = {
			factor = 0
			OR = {
				NOT = { crown_land_share = 25 }
				AND = {
					is_absolutism_active = yes
					NOT = { crown_land_share = 40 }
				}
			}
		}
		modifier = {
			factor = 0.8
			OR = {
				NOT = { crown_land_share = 35 }
				AND = {
					is_absolutism_active = yes
					NOT = { crown_land_share = 50 }
				}
			}
		}
		modifier = {
			factor = 0
			NOT = { num_of_loans = 1 }
		}
		modifier = {
			factor = 0.5
			is_in_deficit = no
		}
		modifier = {
			factor = 1.25
			has_any_disaster = yes
		}
		modifier = {
			factor = 1.5
			num_of_loans = 2
			is_in_deficit = yes
		}
		modifier = {
			factor = 1.5
			num_of_loans = 5
		}
		modifier = {
			factor = 1.5
			num_of_loans = 10
		}
		modifier = {
			factor = 1.5
			num_of_loans = 15
		}
		modifier = {
			factor = 1.5
			num_of_loans = 20
		}
		modifier = {
			factor = 1.2
			NOT = {
				estate_loyalty = {
					estate = all
					loyalty = 25
				}
			}
		}
		modifier = {
			factor = 1.1
			crown_land_share = 80
		}
		modifier = {
			factor = 0.75
			num_of_powerful_estates = 1
		}
		modifier = {
			factor = 0.8
			has_country_flag = recent_land_distribution
			NOT = {
				had_country_flag = {
					flag = recent_land_distribution
					days = 5475
				}
			}
		}
		modifier = {
			factor = 1.2
			had_country_flag = {
				flag = recent_land_distribution
				days = 10950
			}
		}
		modifier = {
			factor = 0.5
			has_country_flag = recent_land_seizure
			NOT = {
				had_country_flag = {
					flag = recent_land_seizure
					days = 5475
				}
			}
		}
	}
}

interaction = {
    key = summon_the_diet
    random_seed = random
	cooldown_months = 60

    trigger = {
        NOT = { has_any_active_estate_agenda = yes }
		hidden_trigger = { has_any_estates = yes }
		NOT = { has_government_attribute = blocked_call_diet }
    }

    effect = {
        custom_tooltip = ESTATES_SUMMON_THE_DIET_DESC
        hidden_effect = {
	        country_event = { id = estate_privileges_and_agendas_events.3 }
			if = {
				limit = {
					ai = yes
				}
				random_list = {
					1 = {}
					9 = { set_country_flag = auto_complete_estate_agenda_all }
				}
			}
        }
        custom_tooltip = SEPERATOR_TOOLTIP
        
		if = {
			limit = {
				has_country_flag = recent_estate_agenda
			}
			clr_country_flag = recent_estate_agenda
		}
		set_country_flag = recent_estate_agenda

		if = {
			limit = { NOT = { has_government_attribute = diet_increases_not_influence } }
			add_estate_influence_modifier = {
				estate = all
				desc = EST_VAL_DIET_SUMMONED
				duration = 7300
				influence = 5
				short = yes
			}
		}
        add_estate_loyalty = {
            estate = all
            loyalty = 5
            short = yes
        }
		if = {
			limit = {
				has_government_attribute = republican_tradition_from_diets
			}
			add_scaled_republican_tradition = 2
		}
		on_summon_the_diet_effect = yes
    }
	ai_will_do = {
		# Only use if it will bring loyalty above 50 for all estates
		# AI will most likely fail to complete the task
		factor = 10
		modifier = {
			factor = 10
			can_use_crown_land_interaction = seize_land
			
			estate_loyalty = {
				estate = all
				loyalty = 45.5
			}
			NOT = {
				estate_loyalty = {
					estate = all
					loyalty = 50
				}
			}
		}
		modifier = {
			factor = 0
			NOT = {
				estate_influence = {
					estate = all
					less_than = yes
					influence = 90
				}
			}
		}
	}
}

interaction = {
    key = seize_land
    random_seed = random
	cooldown_months = 60

    trigger = {
		hidden_trigger = { has_any_estates = yes }
        NOT = { crown_land_share = 100 }
        NOT = { num_of_rebel_armies = 1 }
		NOT = { num_of_rebel_controlled_provinces = 1 }
		#The following if/else_if-statements match those in estate_privileges_and_agendas_events.2.a. If those change, these should too.
		if = {
			limit = {
				OR = {
					has_estate_privilege = estate_brahmins_statutory_rights
					AND = {
						religion = hinduism
						has_estate = estate_brahmins
					}
				}
				has_estate = estate_brahmins
			}
			NOT = { has_estate_privilege = estate_brahmins_statutory_rights }
		}
		else_if = {
			limit = {
				OR = {
					has_estate_privilege = estate_nobles_statutory_rights
					AND = {
						has_estate = estate_nobles
						government = monarchy
					}
				}
			}
			NOT = { has_estate_privilege = estate_nobles_statutory_rights }
		}
		else_if = {
			limit = {
				OR = {
					has_estate_privilege = estate_burghers_statutory_rights
					AND = {
						has_estate = estate_burghers
						government = republic
					}
				}
			}
			NOT = { has_estate_privilege = estate_burghers_statutory_rights }
		}
		else_if = {
			limit = {
				OR = {
					has_estate_privilege = estate_church_statutory_rights
					AND = {
						has_estate = estate_church
						government = theocracy
					}
				}
			}
			NOT = { has_estate_privilege = estate_church_statutory_rights }
		}
        is_at_war = no
		if = {
			limit = { has_government_attribute = can_not_seize_land }
			NOT = { has_government_attribute_short_desc = can_not_seize_land }
		}
    }
    effect = {
		
		if = {
			limit = {
				has_country_flag = recent_land_seizure
			}
			clr_country_flag = recent_land_seizure
		}
		set_country_flag = recent_land_seizure
		if = {
			limit = {
				religion = inti
				check_variable = {
					which = inca_amount_of_mummies
					value = 1
				}
			}
			INC_seize_crownland_modified_by_mummies = yes
		}
		else_if = {
			limit = {
				NOT = { has_government_attribute = can_seize_crownland_of_single_estates }
				NOT = { has_country_flag = can_seize_crownland_to_estates_targeted_flag }
			}
			custom_tooltip = ESTATES_SEIZE_LAND_DESC
			take_estate_land_share_massive = { estate = all }
			custom_tooltip = SEPERATOR_TOOLTIP
			if = {
				limit = {
					has_country_flag = ned_lands_generality_flag
				}
				add_estate_loyalty = {
					estate = all
					loyalty = -10
					short = yes
				}
				add_country_modifier = {
					name = "btip_recently_seized_land_10_loyalty"
					duration = 1825
		        }
			}
			else_if = {
				limit = {
					has_government_attribute = seizing_land_loyalty
				}
				add_estate_loyalty = {
					estate = all
					loyalty = -15
					short = yes
				}
				add_country_modifier = {
					name = "btip_recently_seized_land_15_loyalty"
					duration = 1825
		        }
			}
			else = {
				add_estate_loyalty = {
					estate = all
					loyalty = -20
					short = yes
				}
				add_country_modifier = {
					name = "btip_recently_seized_land"
					duration = 1825
		        }
			}
			custom_tooltip = ESTATES_SEIZE_LAND_EXCEPTION_DESC
			custom_tooltip = btip_exempt_from_seize_land_tt #TODO: Merge into one
			re_add_loyalty_from_seized_land = yes
			hidden_effect = { #Added here because for some bizarre reason, don't tell me why, add_estate_loyalty_modifier does not work when put in scripted effects. Sorry. Any mod authors who wish to add new estates will have to overwrite this file.
				if = {
					limit = {
						has_government_attribute = ned_lands_generality_flag
					}
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nobles } }				add_estate_loyalty_modifier = { estate = estate_nobles 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_brahmins } }			add_estate_loyalty_modifier = { estate = estate_brahmins 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_burghers } }			add_estate_loyalty_modifier = { estate = estate_burghers 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_church } }				add_estate_loyalty_modifier = { estate = estate_church 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_cossacks } }			add_estate_loyalty_modifier = { estate = estate_cossacks 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_dhimmi } }				add_estate_loyalty_modifier = { estate = estate_dhimmi 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_jains } }				add_estate_loyalty_modifier = { estate = estate_jains 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_maratha } }			add_estate_loyalty_modifier = { estate = estate_maratha 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nomadic_tribes } }		add_estate_loyalty_modifier = { estate = estate_nomadic_tribes 	desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_rajput } }				add_estate_loyalty_modifier = { estate = estate_rajput 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_vaisyas } }			add_estate_loyalty_modifier = { estate = estate_vaisyas 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_janissaries } }		add_estate_loyalty_modifier = { estate = estate_janissaries 	desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_eunuchs } }			add_estate_loyalty_modifier = { estate = estate_eunuchs 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_qizilbash } }			add_estate_loyalty_modifier = { estate = estate_qizilbash 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_ghulams } }			add_estate_loyalty_modifier = { estate = estate_ghulams 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					#BTIP Estates
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_peasants } }			add_estate_loyalty_modifier = { estate = estate_peasants 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					#BR Estates
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_generals } }			add_estate_loyalty_modifier = { estate = estate_generals 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_exarches } }			add_estate_loyalty_modifier = { estate = estate_exarches 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_knightly_orders } }	add_estate_loyalty_modifier = { estate = estate_knightly_orders desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 10 duration = 1875 } }
				}
				else_if = {
					limit = {
						has_government_attribute = seizing_land_loyalty
					}
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nobles } }				add_estate_loyalty_modifier = { estate = estate_nobles 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_brahmins } }			add_estate_loyalty_modifier = { estate = estate_brahmins 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_burghers } }			add_estate_loyalty_modifier = { estate = estate_burghers 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_church } }				add_estate_loyalty_modifier = { estate = estate_church 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_cossacks } }			add_estate_loyalty_modifier = { estate = estate_cossacks 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_dhimmi } }				add_estate_loyalty_modifier = { estate = estate_dhimmi 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_jains } }				add_estate_loyalty_modifier = { estate = estate_jains 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_maratha } }			add_estate_loyalty_modifier = { estate = estate_maratha 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nomadic_tribes } }		add_estate_loyalty_modifier = { estate = estate_nomadic_tribes 	desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_rajput } }				add_estate_loyalty_modifier = { estate = estate_rajput 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_vaisyas } }			add_estate_loyalty_modifier = { estate = estate_vaisyas 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_janissaries } }		add_estate_loyalty_modifier = { estate = estate_janissaries 	desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_eunuchs } }			add_estate_loyalty_modifier = { estate = estate_eunuchs 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_qizilbash } }			add_estate_loyalty_modifier = { estate = estate_qizilbash 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_ghulams } }			add_estate_loyalty_modifier = { estate = estate_ghulams 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					#BTIP Estates
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_peasants } }			add_estate_loyalty_modifier = { estate = estate_peasants 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					#BR Estates
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_generals } }			add_estate_loyalty_modifier = { estate = estate_generals 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_exarches } }			add_estate_loyalty_modifier = { estate = estate_exarches 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_knightly_orders } }	add_estate_loyalty_modifier = { estate = estate_knightly_orders desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 15 duration = 1875 } }
				}
				else = {					
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nobles } }				add_estate_loyalty_modifier = { estate = estate_nobles 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_brahmins } }			add_estate_loyalty_modifier = { estate = estate_brahmins 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_burghers } }			add_estate_loyalty_modifier = { estate = estate_burghers 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_church } }				add_estate_loyalty_modifier = { estate = estate_church 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_cossacks } }			add_estate_loyalty_modifier = { estate = estate_cossacks 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_dhimmi } }				add_estate_loyalty_modifier = { estate = estate_dhimmi 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_jains } }				add_estate_loyalty_modifier = { estate = estate_jains 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_maratha } }			add_estate_loyalty_modifier = { estate = estate_maratha 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nomadic_tribes } }		add_estate_loyalty_modifier = { estate = estate_nomadic_tribes 	desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_rajput } }				add_estate_loyalty_modifier = { estate = estate_rajput 			desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_vaisyas } }			add_estate_loyalty_modifier = { estate = estate_vaisyas 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_janissaries } }		add_estate_loyalty_modifier = { estate = estate_janissaries 	desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_eunuchs } }			add_estate_loyalty_modifier = { estate = estate_eunuchs 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_qizilbash } }			add_estate_loyalty_modifier = { estate = estate_qizilbash 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_ghulams } }			add_estate_loyalty_modifier = { estate = estate_ghulams 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					#BTIP Estates
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_peasants } }			add_estate_loyalty_modifier = { estate = estate_peasants 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					#BR Estates
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_generals } }			add_estate_loyalty_modifier = { estate = estate_generals 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_exarches } }			add_estate_loyalty_modifier = { estate = estate_exarches 		desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
					if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_knightly_orders } }	add_estate_loyalty_modifier = { estate = estate_knightly_orders desc = EST_EXEMPT_FROM_SEIZE_LAND loyalty = 20 duration = 1875 } }
				}
			}
			if = {
				limit = { NOT = { has_government_attribute = seizing_land_no_rebels } }
				custom_tooltip = seize_land_rebels_tt
			}
			if = {
				limit = {
					NOT = {
						estate_loyalty = {
							estate = all
							loyalty = 50
						}
					}
					estate_loyalty = {
						estate = all
						loyalty = 30
					}
				}
			}
			else_if = { 
				limit = {
					NOT = {
						estate_loyalty = {
							estate = all
							loyalty = 30
						}
					}
					estate_influence = {
						estate = all
						influence = 1
					}				
				}
				spawn_rebels_seize_land_switch = yes
			}
		}
		else = {
			country_event = {
				id = estate_privileges_and_agendas_events.7
			}
		}
		if = {
			limit = {
				has_government_attribute = seizing_land_takes_karma
			}
			add_karma = -10
		}
		if = {
			limit = { has_government_attribute = theocratic_monarchy_mechanic }
			change_statists_vs_orangists = 0.05
		}
		on_seize_land_effect = yes
	}
	ai_will_do = {
		factor = 50
		modifier = {
			factor = 0
			# This check is needed to prevent collision with day-1 event theocracy.1
			uses_devotion = yes
			has_heir = no
		}
		modifier = {
			factor = 0
			# This is a hack for countries with enclaves that can be hard to get to, to kill the rebels
			# OR = { #BT Modified: The AI really should not seize land when it causes disloyalty. It's *very* bad for the AI economy, I think. Technically this makes the modifiers below rather redundant, but eh. //Dub
				# tag = TEU
				# tag = KOL
				# # Add more as necessary
			# }
			NOT = {
				estate_loyalty = {
					estate = all
					loyalty = 50
				}
			}
		}
		modifier = {
			factor = 0.2
			NOT = {
				estate_loyalty = {
					estate = all
					loyalty = 50
				}
			}
			NOT = {
				army_size = 6
			}
		}
		modifier = {
			factor = 0.2

			# This custom event target is set by code. If ai_will_do is higher when this is set (and >50) than when it isn't,
			# the AI will raise maintenance and wait until the event target doesn't increase the ai_will_do score
			NOT = { has_saved_event_target = ai_suppose_full_maintenance }

			NOT = {
				estate_loyalty = {
					estate = all
					loyalty = 50
				}
			}

			OR = {
				NOT = { land_maintenance = 0.9 }
				num_mothballed_forts = 1
				NOT = { all_regiments_morale_percent = 90 }
				any_owned_province = {
					fort_level = 1
					NOT = { garrison = 400 }
				}
			}
		}
		modifier = {
			factor = 0
			crown_land_share = 30
			has_any_disaster = yes
			NOT = { #sorry, scripted triggers glitched out
				OR = {
					has_disaster = estate_brahmins_disaster
					has_disaster = estate_burghers_disaster
					has_disaster = estate_church_disaster
					has_disaster = estate_cossacks_disaster
					has_disaster = estate_dhimmi_disaster
					has_disaster = estate_jains_disaster
					has_disaster = estate_maratha_disaster
					has_disaster = estate_nobility_disaster
					has_disaster = estate_nomadic_tribes_disaster
					has_disaster = estate_rajput_disaster
					has_disaster = estate_vaisyas_disaster
				}
			}
		}
		modifier = {
			factor = 0.5
			crown_land_share = 30
			NOT = {
				estate_loyalty = {
					estate = all
					loyalty = 50
				}
			}
			if = {
				limit = { num_of_cities = 50 }
				NOT = { army_size_percentage = 0.2 }
			}
			else_if = {
				limit = { num_of_cities = 25 }
				NOT = { army_size_percentage = 0.3 }
			}
			else = {
				NOT = { army_size_percentage = 0.5 }
			}
			if = {
				limit = { is_emperor = yes }
				NOT = { army_size = 50 }
			}
			NOT = { army_size = 100 }
			NOT = { #sorry, scripted triggers glitched out
				OR = {
					has_disaster = estate_brahmins_disaster
					has_disaster = estate_burghers_disaster
					has_disaster = estate_church_disaster
					has_disaster = estate_cossacks_disaster
					has_disaster = estate_dhimmi_disaster
					has_disaster = estate_jains_disaster
					has_disaster = estate_maratha_disaster
					has_disaster = estate_nobility_disaster
					has_disaster = estate_nomadic_tribes_disaster
					has_disaster = estate_rajput_disaster
					has_disaster = estate_vaisyas_disaster
					has_disaster_progress = {
						disaster = estate_brahmins_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_burghers_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_church_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_cossacks_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_dhimmi_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_jains_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_maratha_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_nobility_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_nomadic_tribes_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_rajput_disaster
						value = 5
					}
					has_disaster_progress = {
						disaster = estate_vaisyas_disaster
						value = 5
					}
				}
			}
		}
		modifier = {
			factor = 1.5
			is_absolutism_active = yes
			NOT = { num_of_rebel_armies = 1 }
		}
		modifier = {
			factor = 1.5
			is_absolutism_active = yes
			NOT = { average_unrest = 1 }
			NOT = { num_of_rebel_armies = 1 }
		}
		modifier = {
			factor = 2
			NOT = { crown_land_share = 20 }
		}
		modifier = {
			factor = 1.5
			NOT = { crown_land_share = 30 }
		}
		modifier = {
			factor = 1.2
			NOT = { crown_land_share = 35 }
		}
		modifier = {
			factor = 1.2
			NOT = { crown_land_share = 50 }
		}
		modifier = {
			factor = 1.1
			stability = 2
		}
		modifier = {
			factor = 1.1
			stability = 3
		}
		modifier = {
			factor = 0.5
			average_unrest = 3
		}
		modifier = {
			factor = 1.2
			estate_loyalty = {
				estate = all
				loyalty = 50
			}
		}
		modifier = {
			factor = 10
			OR = {
				has_disaster = estate_brahmins_disaster
				has_disaster = estate_burghers_disaster
				has_disaster = estate_church_disaster
				has_disaster = estate_cossacks_disaster
				has_disaster = estate_dhimmi_disaster
				has_disaster = estate_jains_disaster
				has_disaster = estate_maratha_disaster
				has_disaster = estate_nobility_disaster
				has_disaster = estate_nomadic_tribes_disaster
				has_disaster = estate_rajput_disaster
				has_disaster = estate_vaisyas_disaster
				has_disaster_progress = {
					disaster = estate_brahmins_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_burghers_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_church_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_cossacks_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_dhimmi_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_jains_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_maratha_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_nobility_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_nomadic_tribes_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_rajput_disaster
					value = 5
				}
				has_disaster_progress = {
					disaster = estate_vaisyas_disaster
					value = 5
				}
			}
		}
	}
}
