namespace = cfhdistricts

character_event = {
	id = cfhdistricts.0001 # population growth
	hide_window = yes
	is_triggered_only = yes
	
	only_playable = yes
	
	immediate = {
		any_demesne_province = {
			random_list = {
				10 = {
					set_variable = { which = cfh_population_temp_var value = 0 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 5 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 10 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 15 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 20 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 25 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 30 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 35 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 40 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 45 }
				}
				10 = {
					set_variable = { which = cfh_population_temp_var value = 50 }
				}
			}
			if = {
				limit = { has_province_modifier = depopulated_3 }
				multiply_variable = { which = cfh_population_temp_var value = 0.5 }
			}
			if = {
				limit = { has_province_modifier = depopulated_2 }
				multiply_variable = { which = cfh_population_temp_var value = 0.75 }
			}
			if = {
				limit = { has_province_modifier = depopulated_1 }
				multiply_variable = { which = cfh_population_temp_var value = 0.9 }
			}
			if = {
				limit = { has_province_modifier = prosperity_modifier_1 }
				multiply_variable = { which = cfh_population_temp_var value = 1.2 }
			}
			if = {
				limit = { has_province_modifier = prosperity_modifier_2 }
				multiply_variable = { which = cfh_population_temp_var value = 1.5 }
			}
			if = {
				limit = { has_province_modifier = prosperity_modifier_3 }
				multiply_variable = { which = cfh_population_temp_var value = 2 }
			}
			multiply_variable = { which = cfh_population_temp_var which = global_cfh_pop_growth_var }
			set_variable = { which = local_temp which = cfh_population_temp_var }
			modulo_variable = { which = local_temp value = 1 }
			subtract_variable = { which = cfh_population_temp_var which = local_temp }
			change_variable = { which = cfh_population_var which = cfh_population_temp_var }
			set_variable = { which = cfh_population_temp_var value = 0 }
			province_event = { id = cfhdistricts.0002 days = 2 }
		}
	}
}

province_event = {
	id = cfhdistricts.0002 # population flags set
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		always = yes
	}
	
	immediate = {
		clr_province_flag = cfh_districts_pop_expand_flag
		if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 15 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value > 20000 } }
				set_variable = { which = cfh_population_var value = 20000 }
			}
			set_variable = { which = cfh_population_target_var value = 10000 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 14 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 10000 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 15000 } }
					set_variable = { which = cfh_population_var value = 15000 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 8000 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 13 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 8000 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 12000 } }
					set_variable = { which = cfh_population_var value = 12000 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 6500 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 12 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 6500 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 9750 } }
					set_variable = { which = cfh_population_var value = 9750 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 5000 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 11 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 5000 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 7500 } }
					set_variable = { which = cfh_population_var value = 7500 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 4000 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 10 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 4000 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 6000 } }
					set_variable = { which = cfh_population_var value = 6000 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 3200 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 9 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 3200 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 4800 } }
					set_variable = { which = cfh_population_var value = 4800 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 2500 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 8 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 2500 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 3750 } }
					set_variable = { which = cfh_population_var value = 3750 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 2000 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 7 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 2000 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 3000 } }
					set_variable = { which = cfh_population_var value = 3000 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 1500 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 6 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 1500 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 2250 } }
					set_variable = { which = cfh_population_var value = 2250 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 1100 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 5 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 1100 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 1650 } }
					set_variable = { which = cfh_population_var value = 1650 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 850 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 4 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 850 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 1275 } }
					set_variable = { which = cfh_population_var value = 1275 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 600 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 3 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 600 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 900 } }
					set_variable = { which = cfh_population_var value = 900 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 400 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 2 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 400 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 600 } }
					set_variable = { which = cfh_population_var value = 600 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 250 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 1 } }
			if = {
				limit = { check_variable = { which = cfh_population_var value = 250 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 375 } }
					set_variable = { which = cfh_population_var value = 375 }
				}
			}
			set_variable = { which = cfh_population_target_var value = 100 }
		}
		else = {
			if = {
				limit = { check_variable = { which = cfh_population_var value = 100 } }
				set_province_flag = cfh_districts_pop_expand_flag
				if = {
					limit = { check_variable = { which = cfh_population_var value > 150 } }
					set_variable = { which = cfh_population_var value = 150 }
				}
			}
		}
		remove_province_modifier = cfh_districts_pop_modifier_30
		remove_province_modifier = cfh_districts_pop_modifier_29
		remove_province_modifier = cfh_districts_pop_modifier_28
		remove_province_modifier = cfh_districts_pop_modifier_27
		remove_province_modifier = cfh_districts_pop_modifier_26
		remove_province_modifier = cfh_districts_pop_modifier_25
		remove_province_modifier = cfh_districts_pop_modifier_24
		remove_province_modifier = cfh_districts_pop_modifier_23
		remove_province_modifier = cfh_districts_pop_modifier_22
		remove_province_modifier = cfh_districts_pop_modifier_21
		remove_province_modifier = cfh_districts_pop_modifier_20
		remove_province_modifier = cfh_districts_pop_modifier_19
		remove_province_modifier = cfh_districts_pop_modifier_18
		remove_province_modifier = cfh_districts_pop_modifier_17
		remove_province_modifier = cfh_districts_pop_modifier_16
		remove_province_modifier = cfh_districts_pop_modifier_15
		remove_province_modifier = cfh_districts_pop_modifier_14
		remove_province_modifier = cfh_districts_pop_modifier_13
		remove_province_modifier = cfh_districts_pop_modifier_12
		remove_province_modifier = cfh_districts_pop_modifier_11
		remove_province_modifier = cfh_districts_pop_modifier_10
		remove_province_modifier = cfh_districts_pop_modifier_9
		remove_province_modifier = cfh_districts_pop_modifier_8
		remove_province_modifier = cfh_districts_pop_modifier_7
		remove_province_modifier = cfh_districts_pop_modifier_6
		remove_province_modifier = cfh_districts_pop_modifier_5
		remove_province_modifier = cfh_districts_pop_modifier_4
		remove_province_modifier = cfh_districts_pop_modifier_3
		remove_province_modifier = cfh_districts_pop_modifier_2
		remove_province_modifier = cfh_districts_pop_modifier_1
		if = {
			limit = { check_variable = { which = cfh_population_var value = 15000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_30 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 14500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_29 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 14000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_28 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 13500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_27 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 13000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_26 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 12500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_25 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 12000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_24 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 11500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_23 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 11000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_22 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 10500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_21 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 10000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_20 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 9500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_19 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 9000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_18 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 8500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_17 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 8000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_16 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 7500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_15 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 7000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_14 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 6500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_13 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 6000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_12 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 5500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_11 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 5000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_10 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 4500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_9 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 4000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_8 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 3500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_7 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 3000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_6 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 2500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_5 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 2000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_4 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 1500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_3 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 1000 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_2 duration = -1 }
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_var value = 500 } }
			add_province_modifier = { name = cfh_districts_pop_modifier_1 duration = -1 }
		}
		if = {
			limit = { check_variable = { which = cfh_districts_pop_var value = 1 } }
			set_variable = { which = cfh_population_percent_var which = cfh_population_var }
			divide_variable = { which = cfh_population_percent_var which = cfh_population_target_var }
			province_event = { id = cfhdistricts.0003 days = 1 }
		}
	}
}

province_event = {
	id = cfhdistricts.0003 # province flags
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		always = yes
	}
	
	immediate = {
		clr_province_flag = cfh_districts_pop_100_flag # prov modifiers 100%
		clr_province_flag = cfh_districts_pop_90_flag # prov modifiers 80%
		clr_province_flag = cfh_districts_pop_80_flag # prov modifiers 60%
		clr_province_flag = cfh_districts_pop_70_flag # prov modifiers 40%
		clr_province_flag = cfh_districts_pop_60_flag # prov modifiers 20%
		clr_province_flag = cfh_districts_pop_50_flag # prov modifiers 0%
		if = {
			limit = { check_variable = { which = cfh_population_percent_var value = 1 } }
			set_province_flag = cfh_districts_pop_100_flag
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_percent_var value = 0.9 } }
			set_province_flag = cfh_districts_pop_90_flag
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_percent_var value = 0.8 } }
			set_province_flag = cfh_districts_pop_80_flag
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_percent_var value = 0.7 } }
			set_province_flag = cfh_districts_pop_70_flag
		}
		else_if = {
			limit = { check_variable = { which = cfh_population_percent_var value = 0.6 } }
			set_province_flag = cfh_districts_pop_60_flag
		}
		else = {
			set_province_flag = cfh_districts_pop_50_flag
		}
		province_event = { id = cfhdistricts.0004 }
	}
}

province_event = {
	id = cfhdistricts.0004 # district modifiers
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		always = yes
	}
	
	immediate = {
		if = {
			limit = { has_province_flag = cfh_districts_pop_100_flag }
			if = {
				limit = { has_province_flag = cfh_districts_military_2_flag }
				cfh_districts_mil_mod_25_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_1_flag }
				cfh_districts_mil_mod_15_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_0_flag }
				cfh_districts_mil_mod_5_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_industry_2_flag }
				cfh_districts_ind_mod_25_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_1_flag }
				cfh_districts_ind_mod_15_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_0_flag }
				cfh_districts_ind_mod_5_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_religion_2_flag }
				cfh_districts_rel_mod_25_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_1_flag }
				cfh_districts_rel_mod_15_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_0_flag }
				cfh_districts_rel_mod_5_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_trade_2_flag }
				cfh_districts_tra_mod_25_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_1_flag }
				cfh_districts_tra_mod_15_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_0_flag }
				cfh_districts_tra_mod_5_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_monument_2_flag }
				cfh_districts_mon_mod_25_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_1_flag }
				cfh_districts_mon_mod_15_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_0_flag }
				cfh_districts_mon_mod_5_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_2_flag }
				cfh_districts_poor_mod_25_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_1_flag }
				cfh_districts_poor_mod_15_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_0_flag }
				cfh_districts_poor_mod_5_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_2_flag }
				cfh_districts_rich_mod_25_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_1_flag }
				cfh_districts_rich_mod_15_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_0_flag }
				cfh_districts_rich_mod_5_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_2_flag }
				cfh_districts_noble_mod_25_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_1_flag }
				cfh_districts_noble_mod_15_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_0_flag }
				cfh_districts_noble_mod_5_effect = yes
			}
		}
		else_if = {
			limit = { has_province_flag = cfh_districts_pop_90_flag }
			if = {
				limit = { has_province_flag = cfh_districts_military_2_flag }
				cfh_districts_mil_mod_24_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_1_flag }
				cfh_districts_mil_mod_14_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_0_flag }
				cfh_districts_mil_mod_4_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_industry_2_flag }
				cfh_districts_ind_mod_24_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_1_flag }
				cfh_districts_ind_mod_14_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_0_flag }
				cfh_districts_ind_mod_4_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_religion_2_flag }
				cfh_districts_rel_mod_24_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_1_flag }
				cfh_districts_rel_mod_14_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_0_flag }
				cfh_districts_rel_mod_4_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_trade_2_flag }
				cfh_districts_tra_mod_24_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_1_flag }
				cfh_districts_tra_mod_14_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_0_flag }
				cfh_districts_tra_mod_4_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_monument_2_flag }
				cfh_districts_mon_mod_24_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_1_flag }
				cfh_districts_mon_mod_14_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_0_flag }
				cfh_districts_mon_mod_4_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_2_flag }
				cfh_districts_poor_mod_24_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_1_flag }
				cfh_districts_poor_mod_14_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_0_flag }
				cfh_districts_poor_mod_4_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_2_flag }
				cfh_districts_rich_mod_24_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_1_flag }
				cfh_districts_rich_mod_14_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_0_flag }
				cfh_districts_rich_mod_4_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_2_flag }
				cfh_districts_noble_mod_24_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_1_flag }
				cfh_districts_noble_mod_14_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_0_flag }
				cfh_districts_noble_mod_4_effect = yes
			}
		}
		else_if = {
			limit = { has_province_flag = cfh_districts_pop_80_flag }
			if = {
				limit = { has_province_flag = cfh_districts_military_2_flag }
				cfh_districts_mil_mod_23_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_1_flag }
				cfh_districts_mil_mod_13_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_0_flag }
				cfh_districts_mil_mod_3_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_industry_2_flag }
				cfh_districts_ind_mod_23_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_1_flag }
				cfh_districts_ind_mod_13_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_0_flag }
				cfh_districts_ind_mod_3_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_religion_2_flag }
				cfh_districts_rel_mod_23_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_1_flag }
				cfh_districts_rel_mod_13_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_0_flag }
				cfh_districts_rel_mod_3_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_trade_2_flag }
				cfh_districts_tra_mod_23_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_1_flag }
				cfh_districts_tra_mod_13_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_0_flag }
				cfh_districts_tra_mod_3_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_monument_2_flag }
				cfh_districts_mon_mod_23_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_1_flag }
				cfh_districts_mon_mod_13_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_0_flag }
				cfh_districts_mon_mod_3_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_2_flag }
				cfh_districts_poor_mod_23_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_1_flag }
				cfh_districts_poor_mod_13_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_0_flag }
				cfh_districts_poor_mod_3_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_2_flag }
				cfh_districts_rich_mod_23_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_1_flag }
				cfh_districts_rich_mod_13_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_0_flag }
				cfh_districts_rich_mod_3_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_2_flag }
				cfh_districts_noble_mod_23_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_1_flag }
				cfh_districts_noble_mod_13_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_0_flag }
				cfh_districts_noble_mod_3_effect = yes
			}
		}
		else_if = {
			limit = { has_province_flag = cfh_districts_pop_70_flag }
			if = {
				limit = { has_province_flag = cfh_districts_military_2_flag }
				cfh_districts_mil_mod_22_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_1_flag }
				cfh_districts_mil_mod_12_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_0_flag }
				cfh_districts_mil_mod_2_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_industry_2_flag }
				cfh_districts_ind_mod_22_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_1_flag }
				cfh_districts_ind_mod_12_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_0_flag }
				cfh_districts_ind_mod_2_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_religion_2_flag }
				cfh_districts_rel_mod_22_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_1_flag }
				cfh_districts_rel_mod_12_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_0_flag }
				cfh_districts_rel_mod_2_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_trade_2_flag }
				cfh_districts_tra_mod_22_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_1_flag }
				cfh_districts_tra_mod_12_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_0_flag }
				cfh_districts_tra_mod_2_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_monument_2_flag }
				cfh_districts_mon_mod_22_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_1_flag }
				cfh_districts_mon_mod_12_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_0_flag }
				cfh_districts_mon_mod_2_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_2_flag }
				cfh_districts_poor_mod_22_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_1_flag }
				cfh_districts_poor_mod_12_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_0_flag }
				cfh_districts_poor_mod_2_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_2_flag }
				cfh_districts_rich_mod_22_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_1_flag }
				cfh_districts_rich_mod_12_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_0_flag }
				cfh_districts_rich_mod_2_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_2_flag }
				cfh_districts_noble_mod_22_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_1_flag }
				cfh_districts_noble_mod_12_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_0_flag }
				cfh_districts_noble_mod_2_effect = yes
			}
		}
		else_if = {
			limit = { has_province_flag = cfh_districts_pop_60_flag }
			if = {
				limit = { has_province_flag = cfh_districts_military_2_flag }
				cfh_districts_mil_mod_21_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_1_flag }
				cfh_districts_mil_mod_11_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_military_0_flag }
				cfh_districts_mil_mod_1_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_industry_2_flag }
				cfh_districts_ind_mod_21_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_1_flag }
				cfh_districts_ind_mod_11_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_industry_0_flag }
				cfh_districts_ind_mod_1_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_religion_2_flag }
				cfh_districts_rel_mod_21_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_1_flag }
				cfh_districts_rel_mod_11_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_religion_0_flag }
				cfh_districts_rel_mod_1_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_trade_2_flag }
				cfh_districts_tra_mod_21_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_1_flag }
				cfh_districts_tra_mod_11_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_trade_0_flag }
				cfh_districts_tra_mod_1_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_monument_2_flag }
				cfh_districts_mon_mod_21_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_1_flag }
				cfh_districts_mon_mod_11_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_monument_0_flag }
				cfh_districts_mon_mod_1_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_2_flag }
				cfh_districts_poor_mod_21_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_1_flag }
				cfh_districts_poor_mod_11_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_poor_0_flag }
				cfh_districts_poor_mod_1_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_2_flag }
				cfh_districts_rich_mod_21_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_1_flag }
				cfh_districts_rich_mod_11_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_rich_0_flag }
				cfh_districts_rich_mod_1_effect = yes
			}
			if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_2_flag }
				cfh_districts_noble_mod_21_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_1_flag }
				cfh_districts_noble_mod_11_effect = yes
			}
			else_if = {
				limit = { has_province_flag = cfh_districts_citizen_noble_0_flag }
				cfh_districts_noble_mod_1_effect = yes
			}
		}
		else = {
			cfh_districts_rich_mod_0_effect = yes
			cfh_districts_noble_mod_0_effect = yes
			cfh_districts_poor_mod_0_effect = yes
			cfh_districts_mil_mod_0_effect = yes
			cfh_districts_ind_mod_0_effect = yes
			cfh_districts_rel_mod_0_effect = yes
			cfh_districts_tra_mod_0_effect = yes
			cfh_districts_mon_mod_0_effect = yes
		}
	}
}

character_event = {
	id = cfhdistricts.0011 # siege population depletion
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		always = yes
	}
	
	immediate = {
		FROM = {
			location = {
				multiply_variable = { which = cfh_population_var value = 0.95 }
				set_variable = { which = local_temp which = cfh_population_var }
				modulo_variable = { which = local_temp value = 1 }
				subtract_variable = { which = cfh_population_var which = local_temp }
				province_event = { id = cfhdistricts.0002 days = 1  }
			}
		}
	}
}

character_event = {
	id = cfhdistricts.0012 # loot population depletion
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		always = yes
	}
	
	immediate = {
		FROM = {
			location = {
				multiply_variable = { which = cfh_population_var value = 0.98 }
				set_variable = { which = local_temp which = cfh_population_var }
				modulo_variable = { which = local_temp value = 1 }
				subtract_variable = { which = cfh_population_var which = local_temp }
				province_event = { id = cfhdistricts.0002 days = 1  }
			}
		}
	}
}

province_event = {
	id = cfhdistricts.0013 # disease population depletion
	hide_window = yes
	is_triggered_only = yes
	
	trigger = {
		always = yes
	}
	
	immediate = {
		if = {
			limit = { disease = bubonic_plague } # 4
			multiply_variable = { which = cfh_population_var value = 0.5 }
		}
		else_if = {
			limit = { # 3
				OR = {
					disease = typhoid_fever
					disease = typhus
					disease = small_pox
					disease = syphilis
				}
			}
			multiply_variable = { which = cfh_population_var value = 0.6 }
		}
		else_if = {
			limit = { # 2
				OR = {
					disease = tuberculosis
					disease = measles
				}
			}
			multiply_variable = { which = cfh_population_var value = 0.7 }
		}
		else = {
	#		limit = { disease = dancing_plague } # 1
			multiply_variable = { which = cfh_population_var value = 0.8 }
		}
		set_variable = { which = local_temp which = cfh_population_var }
		modulo_variable = { which = local_temp value = 1 }
		subtract_variable = { which = cfh_population_var which = local_temp }
		province_event = { id = cfhdistricts.0002 days = 1  }
	}
}

character_event = {
	id = cfhdistricts.0021 # district building modifiers
	hide_window = yes
	is_triggered_only = yes
	
	only_playable = yes
	
	trigger = {
		NOT = { 
			has_game_rule = {
				name = cfh_rule_districts
				value = off
			}
		}
	}
	
	immediate = {
		any_demesne_title = {
			limit = {
				OR = {
					holding_type = castle
					holding_type = city
					holding_type = temple
					holding_type = tribal
				}
				is_capital = yes
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_engineers_guild_2
						has_building = cfh_districts_ct_building_engineers_guild_2
						has_building = cfh_districts_tp_building_engineers_guild_2
						has_building = cfh_districts_tb_building_engineers_guild_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_engineers_guild_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_engineers_guild_mod_2
					remove_province_modifier = cfh_districts_building_engineers_guild_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_engineers_guild_1
						has_building = cfh_districts_ct_building_engineers_guild_1
						has_building = cfh_districts_tp_building_engineers_guild_1
						has_building = cfh_districts_tb_building_engineers_guild_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_engineers_guild_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_engineers_guild_mod_3
					remove_province_modifier = cfh_districts_building_engineers_guild_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_engineers_guild_0
						has_building = cfh_districts_ct_building_engineers_guild_0
						has_building = cfh_districts_tp_building_engineers_guild_0
						has_building = cfh_districts_tb_building_engineers_guild_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_engineers_guild_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_engineers_guild_mod_3
					remove_province_modifier = cfh_districts_building_engineers_guild_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_engineers_guild_mod_1
					remove_province_modifier = cfh_districts_building_engineers_guild_mod_3
					remove_province_modifier = cfh_districts_building_engineers_guild_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_architech_guild_2
						has_building = cfh_districts_ct_building_architech_guild_2
						has_building = cfh_districts_tp_building_architech_guild_2
						has_building = cfh_districts_tb_building_architech_guild_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_architech_guild_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_architech_guild_mod_2
					remove_province_modifier = cfh_districts_building_architech_guild_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_architech_guild_1
						has_building = cfh_districts_ct_building_architech_guild_1
						has_building = cfh_districts_tp_building_architech_guild_1
						has_building = cfh_districts_tb_building_architech_guild_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_architech_guild_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_architech_guild_mod_3
					remove_province_modifier = cfh_districts_building_architech_guild_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_architech_guild_0
						has_building = cfh_districts_ct_building_architech_guild_0
						has_building = cfh_districts_tp_building_architech_guild_0
						has_building = cfh_districts_tb_building_architech_guild_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_architech_guild_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_architech_guild_mod_3
					remove_province_modifier = cfh_districts_building_architech_guild_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_architech_guild_mod_1
					remove_province_modifier = cfh_districts_building_architech_guild_mod_3
					remove_province_modifier = cfh_districts_building_architech_guild_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_guard_camp_2
						has_building = cfh_districts_ct_building_guard_camp_2
						has_building = cfh_districts_tp_building_guard_camp_2
						has_building = cfh_districts_tb_building_guard_camp_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_guard_camp_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_guard_camp_mod_2
					remove_province_modifier = cfh_districts_building_guard_camp_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_guard_camp_1
						has_building = cfh_districts_ct_building_guard_camp_1
						has_building = cfh_districts_tp_building_guard_camp_1
						has_building = cfh_districts_tb_building_guard_camp_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_guard_camp_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_guard_camp_mod_3
					remove_province_modifier = cfh_districts_building_guard_camp_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_guard_camp_0
						has_building = cfh_districts_ct_building_guard_camp_0
						has_building = cfh_districts_tp_building_guard_camp_0
						has_building = cfh_districts_tb_building_guard_camp_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_guard_camp_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_guard_camp_mod_3
					remove_province_modifier = cfh_districts_building_guard_camp_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_guard_camp_mod_1
					remove_province_modifier = cfh_districts_building_guard_camp_mod_3
					remove_province_modifier = cfh_districts_building_guard_camp_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_fortress_2
						has_building = cfh_districts_ct_building_fortress_2
						has_building = cfh_districts_tp_building_fortress_2
						has_building = cfh_districts_tb_building_fortress_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_fortress_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_fortress_mod_2
					remove_province_modifier = cfh_districts_building_fortress_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_fortress_1
						has_building = cfh_districts_ct_building_fortress_1
						has_building = cfh_districts_tp_building_fortress_1
						has_building = cfh_districts_tb_building_fortress_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_fortress_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_fortress_mod_3
					remove_province_modifier = cfh_districts_building_fortress_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_fortress_0
						has_building = cfh_districts_ct_building_fortress_0
						has_building = cfh_districts_tp_building_fortress_0
						has_building = cfh_districts_tb_building_fortress_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_fortress_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_fortress_mod_3
					remove_province_modifier = cfh_districts_building_fortress_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_fortress_mod_1
					remove_province_modifier = cfh_districts_building_fortress_mod_3
					remove_province_modifier = cfh_districts_building_fortress_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_donation_house_2
						has_building = cfh_districts_ct_building_donation_house_2
						has_building = cfh_districts_tp_building_donation_house_2
						has_building = cfh_districts_tb_building_donation_house_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_donation_house_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_donation_house_mod_2
					remove_province_modifier = cfh_districts_building_donation_house_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_donation_house_1
						has_building = cfh_districts_ct_building_donation_house_1
						has_building = cfh_districts_tp_building_donation_house_1
						has_building = cfh_districts_tb_building_donation_house_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_donation_house_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_donation_house_mod_3
					remove_province_modifier = cfh_districts_building_donation_house_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_donation_house_0
						has_building = cfh_districts_ct_building_donation_house_0
						has_building = cfh_districts_tp_building_donation_house_0
						has_building = cfh_districts_tb_building_donation_house_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_donation_house_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_donation_house_mod_3
					remove_province_modifier = cfh_districts_building_donation_house_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_donation_house_mod_1
					remove_province_modifier = cfh_districts_building_donation_house_mod_3
					remove_province_modifier = cfh_districts_building_donation_house_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_indoctrination_centre_2
						has_building = cfh_districts_ct_building_indoctrination_centre_2
						has_building = cfh_districts_tp_building_indoctrination_centre_2
						has_building = cfh_districts_tb_building_indoctrination_centre_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_indoctrination_centre_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_indoctrination_centre_mod_2
					remove_province_modifier = cfh_districts_building_indoctrination_centre_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_indoctrination_centre_1
						has_building = cfh_districts_ct_building_indoctrination_centre_1
						has_building = cfh_districts_tp_building_indoctrination_centre_1
						has_building = cfh_districts_tb_building_indoctrination_centre_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_indoctrination_centre_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_indoctrination_centre_mod_3
					remove_province_modifier = cfh_districts_building_indoctrination_centre_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_indoctrination_centre_0
						has_building = cfh_districts_ct_building_indoctrination_centre_0
						has_building = cfh_districts_tp_building_indoctrination_centre_0
						has_building = cfh_districts_tb_building_indoctrination_centre_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_indoctrination_centre_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_indoctrination_centre_mod_3
					remove_province_modifier = cfh_districts_building_indoctrination_centre_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_indoctrination_centre_mod_1
					remove_province_modifier = cfh_districts_building_indoctrination_centre_mod_3
					remove_province_modifier = cfh_districts_building_indoctrination_centre_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_road_forts_2
						has_building = cfh_districts_ct_building_road_forts_2
						has_building = cfh_districts_tp_building_road_forts_2
						has_building = cfh_districts_tb_building_road_forts_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_road_forts_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_road_forts_mod_2
					remove_province_modifier = cfh_districts_building_road_forts_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_road_forts_1
						has_building = cfh_districts_ct_building_road_forts_1
						has_building = cfh_districts_tp_building_road_forts_1
						has_building = cfh_districts_tb_building_road_forts_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_road_forts_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_road_forts_mod_3
					remove_province_modifier = cfh_districts_building_road_forts_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_road_forts_0
						has_building = cfh_districts_ct_building_road_forts_0
						has_building = cfh_districts_tp_building_road_forts_0
						has_building = cfh_districts_tb_building_road_forts_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_road_forts_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_road_forts_mod_3
					remove_province_modifier = cfh_districts_building_road_forts_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_road_forts_mod_1
					remove_province_modifier = cfh_districts_building_road_forts_mod_3
					remove_province_modifier = cfh_districts_building_road_forts_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_auction_2
						has_building = cfh_districts_ct_building_auction_2
						has_building = cfh_districts_tp_building_auction_2
						has_building = cfh_districts_tb_building_auction_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_auction_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_auction_mod_2
					remove_province_modifier = cfh_districts_building_auction_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_auction_1
						has_building = cfh_districts_ct_building_auction_1
						has_building = cfh_districts_tp_building_auction_1
						has_building = cfh_districts_tb_building_auction_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_auction_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_auction_mod_3
					remove_province_modifier = cfh_districts_building_auction_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_auction_0
						has_building = cfh_districts_ct_building_auction_0
						has_building = cfh_districts_tp_building_auction_0
						has_building = cfh_districts_tb_building_auction_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_auction_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_auction_mod_3
					remove_province_modifier = cfh_districts_building_auction_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_auction_mod_1
					remove_province_modifier = cfh_districts_building_auction_mod_3
					remove_province_modifier = cfh_districts_building_auction_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_tavern_2
						has_building = cfh_districts_ct_building_tavern_2
						has_building = cfh_districts_tp_building_tavern_2
						has_building = cfh_districts_tb_building_tavern_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_tavern_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_tavern_mod_2
					remove_province_modifier = cfh_districts_building_tavern_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_tavern_1
						has_building = cfh_districts_ct_building_tavern_1
						has_building = cfh_districts_tp_building_tavern_1
						has_building = cfh_districts_tb_building_tavern_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_tavern_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_tavern_mod_3
					remove_province_modifier = cfh_districts_building_tavern_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_tavern_0
						has_building = cfh_districts_ct_building_tavern_0
						has_building = cfh_districts_tp_building_tavern_0
						has_building = cfh_districts_tb_building_tavern_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_tavern_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_tavern_mod_3
					remove_province_modifier = cfh_districts_building_tavern_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_tavern_mod_1
					remove_province_modifier = cfh_districts_building_tavern_mod_3
					remove_province_modifier = cfh_districts_building_tavern_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_gambling_2
						has_building = cfh_districts_ct_building_gambling_2
						has_building = cfh_districts_tp_building_gambling_2
						has_building = cfh_districts_tb_building_gambling_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_gambling_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_gambling_mod_2
					remove_province_modifier = cfh_districts_building_gambling_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_gambling_1
						has_building = cfh_districts_ct_building_gambling_1
						has_building = cfh_districts_tp_building_gambling_1
						has_building = cfh_districts_tb_building_gambling_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_gambling_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_gambling_mod_3
					remove_province_modifier = cfh_districts_building_gambling_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_gambling_0
						has_building = cfh_districts_ct_building_gambling_0
						has_building = cfh_districts_tp_building_gambling_0
						has_building = cfh_districts_tb_building_gambling_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_gambling_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_gambling_mod_3
					remove_province_modifier = cfh_districts_building_gambling_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_gambling_mod_1
					remove_province_modifier = cfh_districts_building_gambling_mod_3
					remove_province_modifier = cfh_districts_building_gambling_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_road_2
						has_building = cfh_districts_ct_building_road_2
						has_building = cfh_districts_tp_building_road_2
						has_building = cfh_districts_tb_building_road_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_road_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_road_mod_2
					remove_province_modifier = cfh_districts_building_road_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_road_1
						has_building = cfh_districts_ct_building_road_1
						has_building = cfh_districts_tp_building_road_1
						has_building = cfh_districts_tb_building_road_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_road_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_road_mod_3
					remove_province_modifier = cfh_districts_building_road_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_road_0
						has_building = cfh_districts_ct_building_road_0
						has_building = cfh_districts_tp_building_road_0
						has_building = cfh_districts_tb_building_road_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_road_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_road_mod_3
					remove_province_modifier = cfh_districts_building_road_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_road_mod_1
					remove_province_modifier = cfh_districts_building_road_mod_3
					remove_province_modifier = cfh_districts_building_road_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_trade_dock_2
						has_building = cfh_districts_ct_building_trade_dock_2
						has_building = cfh_districts_tp_building_trade_dock_2
						has_building = cfh_districts_tb_building_trade_dock_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_trade_dock_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_trade_dock_mod_2
					remove_province_modifier = cfh_districts_building_trade_dock_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_trade_dock_1
						has_building = cfh_districts_ct_building_trade_dock_1
						has_building = cfh_districts_tp_building_trade_dock_1
						has_building = cfh_districts_tb_building_trade_dock_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_trade_dock_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_trade_dock_mod_3
					remove_province_modifier = cfh_districts_building_trade_dock_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_trade_dock_0
						has_building = cfh_districts_ct_building_trade_dock_0
						has_building = cfh_districts_tp_building_trade_dock_0
						has_building = cfh_districts_tb_building_trade_dock_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_trade_dock_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_trade_dock_mod_3
					remove_province_modifier = cfh_districts_building_trade_dock_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_trade_dock_mod_1
					remove_province_modifier = cfh_districts_building_trade_dock_mod_3
					remove_province_modifier = cfh_districts_building_trade_dock_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_household_guards_2
						has_building = cfh_districts_ct_building_household_guards_2
						has_building = cfh_districts_tp_building_household_guards_2
						has_building = cfh_districts_tb_building_household_guards_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_household_guards_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_household_guards_mod_2
					remove_province_modifier = cfh_districts_building_household_guards_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_household_guards_1
						has_building = cfh_districts_ct_building_household_guards_1
						has_building = cfh_districts_tp_building_household_guards_1
						has_building = cfh_districts_tb_building_household_guards_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_household_guards_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_household_guards_mod_3
					remove_province_modifier = cfh_districts_building_household_guards_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_household_guards_0
						has_building = cfh_districts_ct_building_household_guards_0
						has_building = cfh_districts_tp_building_household_guards_0
						has_building = cfh_districts_tb_building_household_guards_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_household_guards_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_household_guards_mod_3
					remove_province_modifier = cfh_districts_building_household_guards_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_household_guards_mod_1
					remove_province_modifier = cfh_districts_building_household_guards_mod_3
					remove_province_modifier = cfh_districts_building_household_guards_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_county_estates_2
						has_building = cfh_districts_ct_building_county_estates_2
						has_building = cfh_districts_tp_building_county_estates_2
						has_building = cfh_districts_tb_building_county_estates_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_county_estates_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_county_estates_mod_2
					remove_province_modifier = cfh_districts_building_county_estates_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_county_estates_1
						has_building = cfh_districts_ct_building_county_estates_1
						has_building = cfh_districts_tp_building_county_estates_1
						has_building = cfh_districts_tb_building_county_estates_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_county_estates_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_county_estates_mod_3
					remove_province_modifier = cfh_districts_building_county_estates_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_county_estates_0
						has_building = cfh_districts_ct_building_county_estates_0
						has_building = cfh_districts_tp_building_county_estates_0
						has_building = cfh_districts_tb_building_county_estates_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_county_estates_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_county_estates_mod_3
					remove_province_modifier = cfh_districts_building_county_estates_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_county_estates_mod_1
					remove_province_modifier = cfh_districts_building_county_estates_mod_3
					remove_province_modifier = cfh_districts_building_county_estates_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_public_gardens_2
						has_building = cfh_districts_ct_building_public_gardens_2
						has_building = cfh_districts_tp_building_public_gardens_2
						has_building = cfh_districts_tb_building_public_gardens_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_public_gardens_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_public_gardens_mod_2
					remove_province_modifier = cfh_districts_building_public_gardens_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_public_gardens_1
						has_building = cfh_districts_ct_building_public_gardens_1
						has_building = cfh_districts_tp_building_public_gardens_1
						has_building = cfh_districts_tb_building_public_gardens_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_public_gardens_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_public_gardens_mod_3
					remove_province_modifier = cfh_districts_building_public_gardens_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_public_gardens_0
						has_building = cfh_districts_ct_building_public_gardens_0
						has_building = cfh_districts_tp_building_public_gardens_0
						has_building = cfh_districts_tb_building_public_gardens_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_public_gardens_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_public_gardens_mod_3
					remove_province_modifier = cfh_districts_building_public_gardens_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_public_gardens_mod_1
					remove_province_modifier = cfh_districts_building_public_gardens_mod_3
					remove_province_modifier = cfh_districts_building_public_gardens_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_public_baths_2
						has_building = cfh_districts_ct_building_public_baths_2
						has_building = cfh_districts_tp_building_public_baths_2
						has_building = cfh_districts_tb_building_public_baths_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_public_baths_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_public_baths_mod_2
					remove_province_modifier = cfh_districts_building_public_baths_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_public_baths_1
						has_building = cfh_districts_ct_building_public_baths_1
						has_building = cfh_districts_tp_building_public_baths_1
						has_building = cfh_districts_tb_building_public_baths_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_public_baths_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_public_baths_mod_3
					remove_province_modifier = cfh_districts_building_public_baths_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_public_baths_0
						has_building = cfh_districts_ct_building_public_baths_0
						has_building = cfh_districts_tp_building_public_baths_0
						has_building = cfh_districts_tb_building_public_baths_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_public_baths_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_public_baths_mod_3
					remove_province_modifier = cfh_districts_building_public_baths_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_public_baths_mod_1
					remove_province_modifier = cfh_districts_building_public_baths_mod_3
					remove_province_modifier = cfh_districts_building_public_baths_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_poor_house_2
						has_building = cfh_districts_ct_building_poor_house_2
						has_building = cfh_districts_tp_building_poor_house_2
						has_building = cfh_districts_tb_building_poor_house_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_poor_house_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_poor_house_mod_2
					remove_province_modifier = cfh_districts_building_poor_house_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_poor_house_1
						has_building = cfh_districts_ct_building_poor_house_1
						has_building = cfh_districts_tp_building_poor_house_1
						has_building = cfh_districts_tb_building_poor_house_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_poor_house_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_poor_house_mod_3
					remove_province_modifier = cfh_districts_building_poor_house_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_poor_house_0
						has_building = cfh_districts_ct_building_poor_house_0
						has_building = cfh_districts_tp_building_poor_house_0
						has_building = cfh_districts_tb_building_poor_house_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_poor_house_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_poor_house_mod_3
					remove_province_modifier = cfh_districts_building_poor_house_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_poor_house_mod_1
					remove_province_modifier = cfh_districts_building_poor_house_mod_3
					remove_province_modifier = cfh_districts_building_poor_house_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_inn_2
						has_building = cfh_districts_ct_building_inn_2
						has_building = cfh_districts_tp_building_inn_2
						has_building = cfh_districts_tb_building_inn_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_inn_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_inn_mod_2
					remove_province_modifier = cfh_districts_building_inn_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_inn_1
						has_building = cfh_districts_ct_building_inn_1
						has_building = cfh_districts_tp_building_inn_1
						has_building = cfh_districts_tb_building_inn_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_inn_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_inn_mod_3
					remove_province_modifier = cfh_districts_building_inn_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_inn_0
						has_building = cfh_districts_ct_building_inn_0
						has_building = cfh_districts_tp_building_inn_0
						has_building = cfh_districts_tb_building_inn_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_inn_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_inn_mod_3
					remove_province_modifier = cfh_districts_building_inn_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_inn_mod_1
					remove_province_modifier = cfh_districts_building_inn_mod_3
					remove_province_modifier = cfh_districts_building_inn_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_guild_hall_2
						has_building = cfh_districts_ct_building_guild_hall_2
						has_building = cfh_districts_tp_building_guild_hall_2
						has_building = cfh_districts_tb_building_guild_hall_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_guild_hall_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_guild_hall_mod_2
					remove_province_modifier = cfh_districts_building_guild_hall_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_guild_hall_1
						has_building = cfh_districts_ct_building_guild_hall_1
						has_building = cfh_districts_tp_building_guild_hall_1
						has_building = cfh_districts_tb_building_guild_hall_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_guild_hall_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_guild_hall_mod_3
					remove_province_modifier = cfh_districts_building_guild_hall_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_guild_hall_0
						has_building = cfh_districts_ct_building_guild_hall_0
						has_building = cfh_districts_tp_building_guild_hall_0
						has_building = cfh_districts_tb_building_guild_hall_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_guild_hall_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_guild_hall_mod_3
					remove_province_modifier = cfh_districts_building_guild_hall_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_guild_hall_mod_1
					remove_province_modifier = cfh_districts_building_guild_hall_mod_3
					remove_province_modifier = cfh_districts_building_guild_hall_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_jail_2
						has_building = cfh_districts_ct_building_jail_2
						has_building = cfh_districts_tp_building_jail_2
						has_building = cfh_districts_tb_building_jail_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_jail_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_jail_mod_2
					remove_province_modifier = cfh_districts_building_jail_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_jail_1
						has_building = cfh_districts_ct_building_jail_1
						has_building = cfh_districts_tp_building_jail_1
						has_building = cfh_districts_tb_building_jail_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_jail_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_jail_mod_3
					remove_province_modifier = cfh_districts_building_jail_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_jail_0
						has_building = cfh_districts_ct_building_jail_0
						has_building = cfh_districts_tp_building_jail_0
						has_building = cfh_districts_tb_building_jail_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_jail_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_jail_mod_3
					remove_province_modifier = cfh_districts_building_jail_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_jail_mod_1
					remove_province_modifier = cfh_districts_building_jail_mod_3
					remove_province_modifier = cfh_districts_building_jail_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_apothecary_2
						has_building = cfh_districts_ct_building_apothecary_2
						has_building = cfh_districts_tp_building_apothecary_2
						has_building = cfh_districts_tb_building_apothecary_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_apothecary_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_apothecary_mod_2
					remove_province_modifier = cfh_districts_building_apothecary_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_apothecary_1
						has_building = cfh_districts_ct_building_apothecary_1
						has_building = cfh_districts_tp_building_apothecary_1
						has_building = cfh_districts_tb_building_apothecary_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_apothecary_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_apothecary_mod_3
					remove_province_modifier = cfh_districts_building_apothecary_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_apothecary_0
						has_building = cfh_districts_ct_building_apothecary_0
						has_building = cfh_districts_tp_building_apothecary_0
						has_building = cfh_districts_tb_building_apothecary_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_apothecary_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_apothecary_mod_3
					remove_province_modifier = cfh_districts_building_apothecary_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_apothecary_mod_1
					remove_province_modifier = cfh_districts_building_apothecary_mod_3
					remove_province_modifier = cfh_districts_building_apothecary_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_village_green_2
						has_building = cfh_districts_ct_building_village_green_2
						has_building = cfh_districts_tp_building_village_green_2
						has_building = cfh_districts_tb_building_village_green_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_village_green_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_village_green_mod_2
					remove_province_modifier = cfh_districts_building_village_green_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_village_green_1
						has_building = cfh_districts_ct_building_village_green_1
						has_building = cfh_districts_tp_building_village_green_1
						has_building = cfh_districts_tb_building_village_green_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_village_green_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_village_green_mod_3
					remove_province_modifier = cfh_districts_building_village_green_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_village_green_0
						has_building = cfh_districts_ct_building_village_green_0
						has_building = cfh_districts_tp_building_village_green_0
						has_building = cfh_districts_tb_building_village_green_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_village_green_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_village_green_mod_3
					remove_province_modifier = cfh_districts_building_village_green_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_village_green_mod_1
					remove_province_modifier = cfh_districts_building_village_green_mod_3
					remove_province_modifier = cfh_districts_building_village_green_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_brewery_2
						has_building = cfh_districts_ct_building_brewery_2
						has_building = cfh_districts_tp_building_brewery_2
						has_building = cfh_districts_tb_building_brewery_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_brewery_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_brewery_mod_2
					remove_province_modifier = cfh_districts_building_brewery_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_brewery_1
						has_building = cfh_districts_ct_building_brewery_1
						has_building = cfh_districts_tp_building_brewery_1
						has_building = cfh_districts_tb_building_brewery_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_brewery_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_brewery_mod_3
					remove_province_modifier = cfh_districts_building_brewery_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_brewery_0
						has_building = cfh_districts_ct_building_brewery_0
						has_building = cfh_districts_tp_building_brewery_0
						has_building = cfh_districts_tb_building_brewery_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_brewery_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_brewery_mod_3
					remove_province_modifier = cfh_districts_building_brewery_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_brewery_mod_1
					remove_province_modifier = cfh_districts_building_brewery_mod_3
					remove_province_modifier = cfh_districts_building_brewery_mod_2
				}
			}
			if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_weaver_2
						has_building = cfh_districts_ct_building_weaver_2
						has_building = cfh_districts_tp_building_weaver_2
						has_building = cfh_districts_tb_building_weaver_2
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_weaver_mod_3 duration = -1 }
					remove_province_modifier = cfh_districts_building_weaver_mod_2
					remove_province_modifier = cfh_districts_building_weaver_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_weaver_1
						has_building = cfh_districts_ct_building_weaver_1
						has_building = cfh_districts_tp_building_weaver_1
						has_building = cfh_districts_tb_building_weaver_1
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_weaver_mod_2 duration = -1 }
					remove_province_modifier = cfh_districts_building_weaver_mod_3
					remove_province_modifier = cfh_districts_building_weaver_mod_1
				}
			}
			else_if = {
				limit = { 
					OR = {
						has_building = cfh_districts_ca_building_weaver_0
						has_building = cfh_districts_ct_building_weaver_0
						has_building = cfh_districts_tp_building_weaver_0
						has_building = cfh_districts_tb_building_weaver_0
					}
				}
				location = {
					add_province_modifier = { name = cfh_districts_building_weaver_mod_1 duration = -1 }
					remove_province_modifier = cfh_districts_building_weaver_mod_3
					remove_province_modifier = cfh_districts_building_weaver_mod_2
				}
			}
			else = {
				location = {
					remove_province_modifier = cfh_districts_building_weaver_mod_1
					remove_province_modifier = cfh_districts_building_weaver_mod_3
					remove_province_modifier = cfh_districts_building_weaver_mod_2
				}
			}
		}
	}
}

character_event = {
	id = cfhdistricts.0031 # migration
	hide_window = yes
	is_triggered_only = yes
	
	only_playable = yes
	
	immediate = {
		any_realm_province = {
			limit = {
				any_province_holding = {
					OR = {
						holding_type = city
						holding_type = temple
						holding_type = castle
						holding_type = tribal
					}
				}
				owner = { character = ROOT }
				check_variable = { which = cfh_population_var value = 200 }
			}
			province_event = {
				id = cfhdistricts.0032 # migration
			}
		}
	}
}

province_event = {
	id = cfhdistricts.0032 # migration
	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		set_variable = { which = local_migration_var which = prosperity_value }
		set_variable = { which = local_population_var which = cfh_population_var }
		any_neighbor_province = {
			limit = {
				any_province_holding = {
					OR = {
						holding_type = city
						holding_type = temple
						holding_type = castle
						holding_type = tribal
					}
				}
			}
			set_variable = { which = local_migration_neighbor_var which = prosperity_value }
			subtract_variable = { which = local_migration_neighbor_var which = local_migration_var }
			if = {
				limit = {
					check_variable = { which = local_migration_neighbor_var value = 50 }
					check_variable = { which = cfh_population_var value < 15000 }
					check_variable = { which = local_population_var value = 100 }
					NOT = { has_province_flag = cfh_buildings_pop_expand_flag }
				}
				if = {
					limit = { check_variable = { which = local_migration_neighbor_var which = local_population_var } }
					set_variable = { which = local_migration_neighbor_var which = local_population_var }
				}
				multiply_variable = { which = local_migration_neighbor_var value = 0.2 }
				set_variable = { which = local_temp which = local_migration_neighbor_var }
				modulo_variable = { which = local_temp value = 1 }
				subtract_variable = { which = local_migration_neighbor_var which = local_temp }
				change_variable = { which = cfh_population_var which = local_migration_neighbor_var }
				ROOT = {
					subtract_variable = { which = cfh_population_var which = local_migration_neighbor_var }
					set_variable = { which = local_population_var which = cfh_population_var }
				}
			}
		}
	}
}

province_event = {
	id = cfhdistricts.0100 # province population details
	desc = EVTDESCcfhdistricts.0100
	picture = GFX_evt_council_speaker
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes
	
	option = {
		name = CFHDISTRICTSEVTOPTA0100 # population number
	}
	
	option = {
		name = CFHDISTRICTSEVTOPTB0100 # population percentage of target
	}
	
	option = {
		name = CFHDISTRICTSEVTOPTC0100 # population target
	}
}

character_event = {
	id = cfhdistricts.9999 # set globals
	hide_window = yes
	is_triggered_only = yes
	
	only_playable = yes
	
	trigger = {
		NOT = { 
			has_global_flag = cfh_pop_global_flag
		}
	}
	
	immediate = {
		if = {
			limit = {
				OR = {
					has_game_rule = {
						name = cfh_rule_districts
						value = off
					}
					has_game_rule = {
						name = cfh_rule_districts
						value = normal
					}
				}
			}
			set_variable = { which = global_cfh_pop_growth_var value = 1 }
		}
		if = {
			limit = {
				has_game_rule = {
					name = cfh_rule_districts
					value = half
				}
			}
			set_variable = { which = global_cfh_pop_growth_var value = 0.5 }
		}
		if = {
			limit = {
				has_game_rule = {
					name = cfh_rule_districts
					value = double
				}
			}
			set_variable = { which = global_cfh_pop_growth_var value = 2 }
		}
	}
}