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
				}
			}
			#New BR estates
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_generals } }
						has_estate = estate_generals
						NOT = {
							estate_loyalty = {
								estate = estate_generals
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = pretender_rebels
					size = $size$
					estate = estate_generals
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_exarches } }
						has_estate = estate_exarches
						NOT = {
							estate_loyalty = {
								estate = estate_exarches
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = pretender_rebels
					size = $size$
					estate = estate_exarches
					as_if_faction = yes
				}
			}
			1 = {
				trigger = {
					owner = {
						NOT = { disabled_rebels_from_seized_land_for_estate = { estate = estate_knightly_orders } }
						has_estate = estate_knightly_orders
						NOT = {
							estate_loyalty = {
								estate = estate_knightly_orders
								loyalty = 30
							}
						}
					}
				}
				spawn_rebels = {
					type = pretender_rebels #Pending better rebels, I'm taking this for now.
					size = $size$
					estate = estate_knightly_orders
					as_if_faction = yes
				}
			}
		}
	}
}



re_add_loyalty_from_seized_land = {
	hidden_effect = {
		if = { #Vanilla bugfix - they forgot to not add less loyalty for NED
			limit = {
				has_country_flag = ned_lands_generality_flag
			}
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nobles } }				add_estate_loyalty = { estate = estate_nobles			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_brahmins } }			add_estate_loyalty = { estate = estate_brahmins			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_burghers } }			add_estate_loyalty = { estate = estate_burghers			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_church } }				add_estate_loyalty = { estate = estate_church			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_cossacks } }			add_estate_loyalty = { estate = estate_cossacks			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_dhimmi } }				add_estate_loyalty = { estate = estate_dhimmi			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_jains } }				add_estate_loyalty = { estate = estate_jains			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_maratha } }			add_estate_loyalty = { estate = estate_maratha			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_nomadic_tribes } }		add_estate_loyalty = { estate = estate_nomadic_tribes	 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_rajput } }				add_estate_loyalty = { estate = estate_rajput			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_vaisyas } }			add_estate_loyalty = { estate = estate_vaisyas			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_janissaries } }		add_estate_loyalty = { estate = estate_janissaries		 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_eunuchs } }			add_estate_loyalty = { estate = estate_eunuchs			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_qizilbash } }			add_estate_loyalty = { estate = estate_qizilbash		 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_ghulams } }			add_estate_loyalty = { estate = estate_ghulams			 loyalty = 10 } }
			#BTIP Estates
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_peasants } }			add_estate_loyalty = { estate = estate_peasants			 loyalty = 10 } }
			#BR Estates
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_generals } }			add_estate_loyalty = { estate = estate_generals			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_exarches } }			add_estate_loyalty = { estate = estate_exarches			 loyalty = 10 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_knightly_orders } }	add_estate_loyalty = { estate = estate_knightly_orders	 loyalty = 10 } }
		}
		else_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 } }
			#BTIP Estates
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_peasants } }			add_estate_loyalty = { estate = estate_peasants			 loyalty = 15 } }
			#BR Estates
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_generals } }			add_estate_loyalty = { estate = estate_generals			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_exarches } }			add_estate_loyalty = { estate = estate_exarches			 loyalty = 15 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_knightly_orders } }	add_estate_loyalty = { estate = estate_knightly_orders	 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 } }
			#BTIP Estates
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_peasants } }			add_estate_loyalty = { estate = estate_peasants			 loyalty = 20 } }
			#BR Estates
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_generals } }			add_estate_loyalty = { estate = estate_generals			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_exarches } }			add_estate_loyalty = { estate = estate_exarches			 loyalty = 20 } }
			if = { limit = { estate_has_exempt_from_seize_land_privilege = { estate = estate_knightly_orders } }	add_estate_loyalty = { estate = estate_knightly_orders	 loyalty = 20 } }
		}
	}
}