settlement_decisions = {

#Détruire l'établissement
#Détruire Grand Ouvrage
#Inviter un local
#Esclave

########################################
####### Détruire l'établissement #######
########################################

	destroy_holding_1 = {
		filter = owned
		
		from_potential = {
			ai = no
		}
		
		potential = {
			OR = {
				holding_type = castle
				holding_type = city
				holding_type = temple
				holding_type = tribal
			}
			holder_scope = {
				character = FROM
			}
			OR = {
				AND = {
					is_capital = yes
					location = {
						num_of_settlements = 2
					}
				}
				NOT = {
					is_capital = yes
				}
			}
		}
		
		allow = {
			holder = FROM
			is_capital = no
			FROM = { wealth = 100 }
			holder_scope = {
				NOT = {
					trait = incapable
				}
			}
		}
		
		effect = {
			if = {
				limit = {
					holding_type = temple
					is_nomadic = no
				}
				if = {
					limit = {
						location = {
							religion = FROM
						}
					}
					religion_authority = {
						modifier = destroyed_temple 
						years = 10
					}
				}
				if = {
					limit = {
						location = {
							NOT = {
								religion = FROM
								has_province_modifier = destroyed_temple
							}
						}
					}
					if = {
						limit = {
							location = {
								religion_group = pagan_group
							}
						}
						location = {
							religion_authority = {
								modifier = destroyed_pagan_temple
								years = 10
							}
						}
					}
					if = {
						limit = {
							location = {
								NOT = {
									religion_group = pagan_group
								}
							}
						}
						location = {
							religion_authority = {
								modifier = destroyed_heathen_temple
								years = 10
							}
						}
					}
					FROM = {
						religion_authority = {
							modifier = destroyed_temple_positive
						}
					}
				}
				location = {
					add_province_modifier = {
						name = destroyed_temple
						years = 10
						stacking = yes
					}
				}
				FROM = {
				    piety = -200
					add_character_modifier = {
					    name = destroyed_temple_opinion
					    duration = 3650
					    stacking = yes
				    }
				}
			}
			if = {
				limit = {
					NOT = {
						holding_type = city
						holding_type = temple
					}
					is_nomadic = no
				}
				FROM = {
					add_character_modifier = {
					    name = destroyed_castle_opinion
					    duration = 3650
					    stacking = yes
				    }
				}
			}
			if = {
				limit = {
					NOT = {
						holding_type = castle
						holding_type = temple
					}
					is_nomadic = no
				}
				FROM = {
					add_character_modifier = {
					    name = destroyed_city_opinion
					    duration = 3650
					    stacking = yes
				    }
				}
			}
			if = {
				limit = {
					NOT = {
						holding_type = temple
					}
					is_nomadic = no
				}
				location = {
					add_province_modifier = {
						name = destroyed_holding
						years = 10
						stacking = yes
					}
				}
			}
			destroy_settlement = THIS
			if = {
			    limit = { is_nomadic = no }
			    FROM = {
			        wealth = -100
			    	prestige = -200
			    }
			}
			if = {
			    limit = { is_nomadic = yes }
			    FROM = {
			        wealth = -10
			    }
			}
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	convert_settlement_castle = {
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = no
			is_nomadic = no
			ai = no
		}
		
		potential = {
			OR = {
				holding_type = city
				holding_type = temple
			}
			holder_scope = {
				character = FROM
			}
		}
		
		allow = {
			holder = FROM
			FROM = {
				wealth = 750
			}
			OR = {
				AND = {
					holding_type = city
					location = {
						any_province_holding = {
							is_capital = no
							holding_type = city
						}
					}
				}
				AND = {
					holding_type = temple
					location = {
						any_province_holding = {
							is_capital = no
							holding_type = temple
						}
					}
				}
			}
		}
		
		effect = {
			if = {
				limit = {
					holding_type = temple
				}
				FROM = {
					if = {
						limit = {
							NOT = {
								religion_group = muslim
							}
						}
						hidden_tooltip = {
							any_vassal = {
								limit = {
									is_priest = yes
								}
								opinion = {
								modifier = opinion_angry
								who = FROM
								years = 10
								}
							}
						}
						custom_tooltip = { text = priest_vassal_angry }
					}
					if = {
						limit = {
							religion_group = muslim
						}
						hidden_tooltip = {
							any_vassal = {
								limit = {
									OR = {
										is_priest = yes
										is_feudal = yes
									}
								}
								opinion = {
									modifier = opinion_angry
									who = FROM
									years = 10
								}
							}
						}
						custom_tooltip = { text = iqta_vassal_angry }
					}
					religion_head = {
						opinion = {
							modifier = opinion_angry
							who = FROM
							years = 20
						}
					}
					religion_authority = {
						modifier = destroyed_temple
						years = 20
					}
				}
			}
			if = {
				limit = {
					holding_type = city
				}
				FROM = {
					hidden_tooltip = {
						any_vassal = {
							limit = {
								is_republic = yes
							}
							opinion = {
							modifier = opinion_angry
							who = FROM
							years = 10
							}
						}
					}
					custom_tooltip = { text = republic_vassal_angry }
				}
			}
			FROM = {
				wealth = -750
			}
			convert_to = CASTLE
		}
	}
	
	convert_settlement_city = {
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = no
			is_nomadic = no
			ai = no
		}
		
		potential = {
			OR = {
				holding_type = castle
				holding_type = temple
			}
			holder_scope = {
				character = FROM
			}
		}
		
		allow = {
			holder = FROM
			FROM = {
				wealth = 750
			}
			OR = {
				AND = {
					holding_type = castle
					location = {
						any_province_holding = {
							is_capital = no
							holding_type = castle
						}
					}
				}
				AND = {
					holding_type = temple
					location = {
						any_province_holding = {
							is_capital = no
							holding_type = temple
						}
					}
				}
			}
		}
		
		effect = {
			if = {
				limit = {
					holding_type = temple
				}
				FROM = {
					if = {
						limit = {
							NOT = {
								religion_group = muslim
							}
						}
						hidden_tooltip = {
							any_vassal = {
								limit = {
									is_priest = yes
								}
								opinion = {
								modifier = opinion_angry
								who = FROM
								years = 10
								}
							}
						}
						custom_tooltip = { text = priest_vassal_angry }
					}
					if = {
						limit = {
							religion_group = muslim
						}
						any_vassal = {
							limit = {
								OR = {
									is_priest = yes
									is_feudal = yes
								}
							}
							opinion = {
								modifier = opinion_angry
								who = FROM
								years = 10
							}
						}
					}
					religion_head = {
						opinion = {
							modifier = opinion_angry
							who = FROM
							years = 20
						}
					}
					religion_authority = {
						modifier = destroyed_temple
						years = 20
					}
				}
			}
			if = {
				limit = {
					holding_type = castle
				}
				FROM = {
					hidden_tooltip = {
						any_vassal = {
							limit = {
								is_feudal = yes
							}
							opinion = {
							modifier = opinion_angry
							who = FROM
							years = 10
							}
						}
					}
					custom_tooltip = { text = feudal_vassal_angry }
				}
			}
			FROM = {
				wealth = -750
			}
			convert_to = CITY
		}
	}

	convert_settlement_temple = {
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = no
			is_nomadic = no
			ai = no
		}
		
		potential = {
			OR = {
				holding_type = city
				holding_type = castle
			}
			holder_scope = {
				character = FROM
			}
		}
		
		allow = {
			holder = FROM
			FROM = {
				wealth = 750
			}
			OR = {
				AND = {
					holding_type = city
					location = {
						any_province_holding = {
							is_capital = no
							holding_type = city
						}
					}
				}
				AND = {
					holding_type = castle
					location = {
						any_province_holding = {
							is_capital = no
							holding_type = castle
						}
					}
				}
			}
		}
		
		effect = {
			if = {
				limit = {
					holding_type = city
				}
				FROM = {
					hidden_tooltip = {
						any_vassal = {
							limit = {
								is_republic = yes
							}
							opinion = {
							modifier = opinion_angry
							who = FROM
							years = 10
							}
						}
					}
					custom_tooltip = { text = republic_vassal_angry }
				}
			}
			if = {
				limit = {
					holding_type = castle
				}
				FROM = {
					hidden_tooltip = {
						any_vassal = {
							limit = {
								is_feudal = yes
							}
							opinion = {
							modifier = opinion_angry
							who = FROM
							years = 10
							}
						}
					}
					custom_tooltip = { text = feudal_vassal_angry }
				}
			}
			religion_authority = {
				modifier = temple_built
				years = 20
			}
			FROM = {
				religion_head = {
					opinion = {
						modifier = opinion_satisfied
						who = FROM
						years = 20
					}
				}
			}
			FROM = {
				wealth = -750
			}
			convert_to = TEMPLE
		}
	}
	
######################################
####### Détruire Grand Ouvrage #######
######################################

    destroy_great_work = {
		filter = realm_owned

		from_potential = {
			ai = no
			is_playable = yes
		}
		
		potential = {
			holder_scope = {
				character = FROM
				has_wonder = yes
			}
		}

		allow = {
			location = {
				controlled_by = FROM
				has_wonder = yes
			}
		}

		effect = {
			ROOT = {
				location = {
					destroy_wonder = yes
				} 
			}
		}

		ai_will_do = {
			factor = 0
		}
	}
	
################################
####### Inviter un local #######
################################

	invite_a_local = {
		only_playable = yes
		filter = owned
		ai_target_filter = owned
	
		from_potential = {
			ai = no
			is_playable = yes
			higher_tier_than = BARON
		}
		
		potential = {
			NOT = {
				holding_type = nomad
			}
			holder_scope = {
				character = FROM
			}
		}
		
		allow = {
			FROM = {
				scaled_wealth = 0.10
				NOT = {
					has_character_modifier = in_seclusion
				}
			}
			location = {
				NAND = {
					culture = FROM
					religion = FROM
				}	
			}
		}
		
		effect = {
			FROM = {
				scaled_wealth = -0.10
				create_character = {
					random_traits = yes
					dynasty = none
					female = no
					culture = ROOT
					religion = ROOT
				}
				new_character = {
					hidden_tooltip = {
						if = {
							limit = {
								has_dharmic_religion_trigger = yes
							}
							add_trait = kshatriya
							character_event = { id = RoI.30121 }
						}
						if = {
							limit = {
								OR = {
									religion = hellenic_pagan
									religion = hellenic_pagan_reformed
									has_religion_feature = religion_astrology
								}
							}
							hidden_tooltip = { add_western_zodiac_trait_effect = yes }
						}
						if = {
							limit = {
								has_religion_feature = religion_no_leader
								religion_group = pagan_group
							}
							random_list = {  
								5 = {
									add_trait = pagan_branch_1
								}
								25 = {
									add_trait = pagan_branch_2
								}
								25 = {
									add_trait = pagan_branch_3
								}
								25 = {
									add_trait = pagan_branch_4
								}
							}
						}
					}
					
					save_event_target_as = invited_character
				}
				character_event = { id = NE.1 }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	
	invite_a_local_woman = {
		only_playable = yes
		filter = owned
		ai_target_filter = owned
	
		from_potential = {
			ai = no
			is_playable = yes
			higher_tier_than = BARON
		}
		
		potential = {
			NOT = {
				holding_type = nomad
			}
			holder_scope = {
				character = FROM
			}
		}
		
		allow = {
			FROM = {
				scaled_wealth = 0.10
				NOT = {
					has_character_modifier = in_seclusion
				}
			}
			location = {
				NAND = {
					culture = FROM
					religion = FROM
				}	
			}
		}
		
		effect = {
			FROM = {
				scaled_wealth = -0.10
				create_character = {
					random_traits = yes
					dynasty = none
					female = yes
					culture = ROOT
					religion = ROOT
				}
				new_character = {
					hidden_tooltip = {
						if = {
							limit = {
								has_dharmic_religion_trigger = yes
							}
							add_trait = kshatriya
							character_event = { id = RoI.30121 }
						}
						if = {
							limit = {
								OR = {
									religion = hellenic_pagan
									religion = hellenic_pagan_reformed
									has_religion_feature = religion_astrology
								}
							}
							hidden_tooltip = { add_western_zodiac_trait_effect = yes }
						}
						if = {
							limit = {
								has_religion_feature = religion_no_leader
								religion_group = pagan_group
							}
							random_list = {  
								5 = {
									add_trait = pagan_branch_1
								}
								25 = {
									add_trait = pagan_branch_2
								}
								25 = {
									add_trait = pagan_branch_3
								}
								25 = {
									add_trait = pagan_branch_4
								}
							}
						}
					}
					
					save_event_target_as = invited_character
				}
				character_event = { id = NE.1 }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	invite_a_local_adventurer = {
		only_playable = yes
		filter = owned
		ai_target_filter = owned
	
		from_potential = {
			ai = no
			is_landed = no
		}
		
		potential = {
		}
		
		allow = {
			FROM = {
				scaled_wealth = 0.10
				NOT = {
					has_character_modifier = in_seclusion
				}
			}
			location = {
				NAND = {
					culture = FROM
					religion = FROM
				}	
			}
		}
		
		effect = {
			FROM = {
				scaled_wealth = -0.10
				create_character = {
					random_traits = yes
					dynasty = none
					female = no
					culture = ROOT
					religion = ROOT
				}
				new_character = {
					hidden_tooltip = {
						if = {
							limit = {
								has_dharmic_religion_trigger = yes
							}
							add_trait = kshatriya
							character_event = { id = RoI.30121 }
						}
						if = {
							limit = {
								OR = {
									religion = hellenic_pagan
									religion = hellenic_pagan_reformed
									has_religion_feature = religion_astrology
								}
							}
							hidden_tooltip = { add_western_zodiac_trait_effect = yes }
						}
						if = {
							limit = {
								has_religion_feature = religion_no_leader
								religion_group = pagan_group
							}
							random_list = {  
								5 = {
									add_trait = pagan_branch_1
								}
								25 = {
									add_trait = pagan_branch_2
								}
								25 = {
									add_trait = pagan_branch_3
								}
								25 = {
									add_trait = pagan_branch_4
								}
							}
						}
					}
					
					save_event_target_as = invited_character
				}
				character_event = { id = NE.1 }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
	invite_a_local_woman_adventurer = {
		only_playable = yes
		filter = owned
		ai_target_filter = owned
	
		from_potential = {
			ai = no
			is_landed = no
		}
		
		potential = {
		}
		
		allow = {
			FROM = {
				wealth = 35
				NOT = {
					has_character_modifier = in_seclusion
				}
			}
			location = {
				NAND = {
					culture = FROM
					religion = FROM
				}
			}
		}
		
		effect = {
			FROM = {
				scaled_wealth = -0.10
				create_character = {
					random_traits = yes
					dynasty = none
					female = yes
					culture = ROOT
					religion = ROOT
				}
				new_character = {
					hidden_tooltip = {
						if = {
							limit = {
								has_dharmic_religion_trigger = yes
							}
							add_trait = kshatriya
							character_event = { id = RoI.30121 }
						}
						if = {
							limit = {
								OR = {
									religion = hellenic_pagan
									religion = hellenic_pagan_reformed
									has_religion_feature = religion_astrology
								}
							}
							hidden_tooltip = { add_western_zodiac_trait_effect = yes }
						}
						if = {
							limit = {
								has_religion_feature = religion_no_leader
								religion_group = pagan_group
							}
							random_list = {  
								5 = {
									add_trait = pagan_branch_1
								}
								25 = {
									add_trait = pagan_branch_2
								}
								25 = {
									add_trait = pagan_branch_3
								}
								25 = {
									add_trait = pagan_branch_4
								}
							}
						}
					}
					
					save_event_target_as = invited_character
				}
				character_event = { id = NE.1 }
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 0
		}
	}
	
#######################
####### Esclave #######
#######################

	forced_slave_labor = {
		filter = owned
		ai_target_filter = owned
		ai_check_interval = 80
		diplomacy_icon = GFX_slavery_decision
		
		is_high_prio = yes
		
		from_potential = {
			is_playable = yes
			is_nomadic = no
			is_adult = yes
			higher_tier_than = BARON
			has_dlc = "Holy Fury"
			any_host_courtier = {
				count = 1
				is_enslaved = yes
				prisoner = no
				is_ruler = no
				is_councillor = no
				NOT = {
					has_minor_title = title_regent
					has_minor_title = title_appointed_regent
					has_minor_title = title_commander
					has_minor_title = title_court_physician
				}
				NOT = { has_character_flag = slave_not_work }
			}
		}
		
		potential = {
			holder_scope = {
				character = FROM
			}
			OR = { 
				AND = { 
					holding_type = tribal
					NAND = { 
						OR = { 
							has_building = tb_hillfort_4
							is_building = tb_hillfort_4
						}
						OR = { 
							has_building = tb_defensive_fortifications_4
							is_building = tb_defensive_fortifications_4
						}
					}
				}
				AND = { 
					holding_type = castle
					NAND = { 
						OR = { 
							has_building = ca_wall_5
							has_building = ca_con_wall_6
							is_building = ca_wall_5
						}
						OR = { 
							has_building = ca_wall_q_5
							is_building = ca_wall_q_5
						}
					}
				}
			}
		}
		allow = {
			custom_tooltip = {
				text = custom_has_slave_labor
				FROM = {
					any_host_courtier = {
						count = 10
						is_enslaved = yes
						prisoner = no
						is_ruler = no
						is_councillor = no
						NOT = {
							has_minor_title = title_regent
							has_minor_title = title_appointed_regent
							has_minor_title = title_commander
							has_minor_title = title_court_physician
						}
						age = 14
					}
				}
			}
			show_only_failed_conditions = yes
			OR = { 
				conditional_tooltip = {
					trigger = { 
						holding_type = tribal
						NOT = { has_building = tb_hillfort_4 } 
					}
					AND = { 
						holding_type = tribal
						hidden_tooltip = { NOT = { has_building = tb_hillfort_4 } } 
						OR = { 
							AND = { 
								custom_tooltip = { 
									text = tooltip_can_build_tb_hillfort_1
									hidden_tooltip = { 
										NOR = { 
											is_building = tb_hillfort_1 
											has_building = tb_hillfort_1 
										}
										location = { TECH_CASTLE_CONSTRUCTION = 0 }
									}
								}
							}
							AND = { 
								custom_tooltip = { 
									text = tooltip_can_build_tb_hillfort_2
									hidden_tooltip = { 
										has_building = tb_hillfort_1
										NOR = { 
											is_building = tb_hillfort_2 
											has_building = tb_hillfort_2 
										}
										location = { TECH_CASTLE_CONSTRUCTION = 0 }
									}
								}
							}
							AND = { 
								custom_tooltip = { 
									text = tooltip_can_build_tb_hillfort_3
									hidden_tooltip = { 
										has_building = tb_hillfort_2
										NOR = { 
											is_building = tb_hillfort_3 
											has_building = tb_hillfort_3 
										}
										location = { TECH_CASTLE_CONSTRUCTION = 1 }
									}
								}
							}
							AND = { 
								custom_tooltip = { 
									text = tooltip_can_build_tb_hillfort_4
									hidden_tooltip = { 
										has_building = tb_hillfort_3
										NOR = { 
												is_building = tb_hillfort_4 
												has_building = tb_hillfort_4 
											}
										location = { TECH_CASTLE_CONSTRUCTION = 1 }
									}
								}
							}
						}
					}
				}
				conditional_tooltip = {
					trigger = { 
						holding_type = tribal
						OR = { 
							is_building = tb_hillfort_4
							has_building = tb_hillfort_4
							can_build_hillfort_trigger = no
						}
					}
					AND = { 
						holding_type = tribal
						hidden_tooltip = { 
							OR = { 
								is_building = tb_hillfort_4
								has_building = tb_hillfort_4
								can_build_hillfort_trigger = no
							}
							NOR = { 
								is_building = tb_defensive_fortifications_4
								has_building = tb_defensive_fortifications_4
							}
						}
						OR = { 
							AND = { 
								custom_tooltip = { 
									text = tooltip_can_build_tb_defensive_fortifications_1
									hidden_tooltip = { 
										NOR = { 
											is_building = tb_defensive_fortifications_1 
											has_building = tb_defensive_fortifications_1
										}
										location = { TECH_CASTLE_CONSTRUCTION = 0 }
									}
								}
							}
							AND = { 
								custom_tooltip = { 
									text = tooltip_can_build_tb_defensive_fortifications_2 
									hidden_tooltip = { 
										has_building = tb_defensive_fortifications_1
										NOR = { 
											is_building = tb_defensive_fortifications_2 
											has_building = tb_defensive_fortifications_2 
										}
										location = { TECH_CASTLE_CONSTRUCTION = 0 }
									}
								}
							}
							AND = { 
								custom_tooltip = { 
									text = tooltip_can_build_tb_defensive_fortifications_3
									hidden_tooltip = { 
										has_building = tb_defensive_fortifications_2
										NOR = { 
											is_building = tb_defensive_fortifications_3 
											has_building = tb_defensive_fortifications_3 
										}
										location = { TECH_CASTLE_CONSTRUCTION = 1 }
									}
								}
							}
							AND = { 
								custom_tooltip = { 
									text = tooltip_can_build_tb_defensive_fortifications_4
									hidden_tooltip = { 
										has_building = tb_defensive_fortifications_3
										NOR = { 
											is_building = tb_defensive_fortifications_4 
											has_building = tb_defensive_fortifications_4 
										}
										location = { TECH_CASTLE_CONSTRUCTION = 1 }
									}
								}
							}
						}
					}
				}
				conditional_tooltip = {
					trigger = { 
						holding_type = castle
						NOT = { has_building = ca_wall_5 }
					}
					AND = { 
						holding_type = castle
						hidden_tooltip = { NOT = { has_building = ca_wall_5 } }
						custom_tooltip = { 
							text = tooltip_can_build_ca_wall_1
							hidden_tooltip = { 
								OR = { 
									AND = { 
										NOR = { 
											is_building = ca_wall_1 
											has_building = ca_wall_1
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 0 }
									}
									AND = { 
										has_building = ca_wall_1
										NOR = { 
											is_building = ca_wall_2 
											has_building = ca_wall_2
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 2 }
									}
									AND = { 
										has_building = ca_wall_2
										NOR = { 
											is_building = ca_wall_3 
											has_building = ca_wall_3
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 4 }
									}
									AND = { 
										has_building = ca_wall_3
										NOR = { 
											is_building = ca_wall_4 
											has_building = ca_wall_4
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 6 }
									}
									AND = { 
										has_building = ca_wall_4
										NOR = { 
											is_building = ca_wall_5 
											has_building = ca_wall_5
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 8 }
									}
								}
							}
						}
					}
				}
				conditional_tooltip = {
					trigger = { 
						holding_type = castle
						OR = { 
							is_building = ca_wall_5 
							has_building = ca_wall_5 
							can_build_walls_trigger = no
						}
					}
					AND = { 
						holding_type = castle
						hidden_tooltip = { 
							OR = { 
								is_building = ca_wall_5
								has_building = ca_wall_5 
								can_build_walls_trigger = no
							}
							NOR = { 
								is_building = ca_wall_q_5
								has_building = ca_wall_q_5
							}
						}
						custom_tooltip = { 
							text = tooltip_can_build_ca_wall_q_1
							hidden_tooltip = { 
								OR = { 
									AND = { 
										NOR = { 
											is_building = ca_wall_q_1
											has_building = ca_wall_q_1
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 0 }
									}
									AND = { 
										has_building = ca_wall_q_1
										NOR = { 
											is_building = ca_wall_q_2 
											has_building = ca_wall_q_2
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 1 }
									}
									AND = { 
										has_building = ca_wall_q_2
										NOR = { 
											is_building = ca_wall_q_3 
											has_building = ca_wall_q_3
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 3 }
									}
									AND = { 
										has_building = ca_wall_q_3
										NOR = { 
											is_building = ca_wall_q_4 
											has_building = ca_wall_q_4 
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 5 }
									}
									AND = { 
										has_building = ca_wall_q_4
										NOR = { 
											is_building = ca_wall_q_5 
											has_building = ca_wall_q_5
										}
										location = { TECH_FORTIFICATIONS_CONSTRUCTION = 7 }
									}
								}
							}
						}
					}
				}
			}
		}
		effect = {
			custom_tooltip = {
				text = custom_has_slave_labor_10
				FROM = {
					any_host_courtier = {
						count = 10
						limit = {
							is_enslaved = yes
							prisoner = no
							is_ruler = no
							is_councillor = no
							NOT = {
								has_minor_title = title_regent
								has_minor_title = title_appointed_regent
								has_minor_title = title_commander
								has_minor_title = title_court_physician
							}
							age = 14
							NOT = { has_character_flag = slave_not_work }
						}
						death = {
							death_reason = DEATH_SLAVERY
							killer = ROOT
						}
					}
				}
			}
			FROM = {
				hidden_tooltip = { 
					random_list = { 
						33 = { sound_effect = baltic_holds_01 } 
						33 = { sound_effect = baltic_holds_02 } 
						33 = { sound_effect = baltic_holds_03 } 
					}
				}
			}
			
			if = {
				limit = {
					holding_type = castle
					can_build_walls_trigger = yes
					NOR = { 
						has_building = ca_wall_5
						is_building = ca_wall_5 
					}
				}
				if = { 
				limit = { 
					has_building = ca_wall_4
					NOR = { 
						is_building = ca_wall_5 
					}
					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 8 }
					}
					add_building = ca_wall_5
					hidden_tooltip = { FROM = { character_event = { id = HF.25068 } } }
				}
				else_if = { 
				limit = { 
					has_building = ca_wall_3
					NOR = { 
						is_building = ca_wall_4 
					}
					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 6 }
					}
					add_building = ca_wall_4
					hidden_tooltip = { FROM = { character_event = { id = HF.25068 } } }
				}
				else_if = { 
				limit = { 
					has_building = ca_wall_2
					NOR = { 
						is_building = ca_wall_3 
					}
					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 4 }
					}
					add_building = ca_wall_3
					hidden_tooltip = { FROM = { character_event = { id = HF.25068 } } }
				}
				else_if = { 
					limit = { 
						has_building = ca_wall_1
						NOR = { 
							is_building = ca_wall_2 
						}
						location = { TECH_FORTIFICATIONS_CONSTRUCTION = 2 }
					}
					add_building = ca_wall_2
					hidden_tooltip = { FROM = { character_event = { id = HF.25068 } } }
				}
				else_if = { 
					limit = { 
						NOR = { 
							is_building = ca_wall_1 
							has_building = ca_wall_1 
						}
						location = { TECH_FORTIFICATIONS_CONSTRUCTION = 0 }
					}
					add_building = ca_wall_1
					hidden_tooltip = { FROM = { character_event = { id = HF.25068 } } }
				}
				break = yes
			}
			if = {
				limit = {
					holding_type = castle
					NOR = { 
						has_building = ca_wall_q_5
						is_building = ca_wall_q_5 
					}
					OR = { 
						is_building = ca_wall_5 
						has_building = ca_wall_5 
						can_build_walls_trigger = no
					}
				}
				if = { 
				limit = { 
					has_building = ca_wall_q_4
					NOR = { 
						is_building = ca_wall_q_5 
					}
					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 7 }
					}
					add_building = ca_wall_q_5
					hidden_tooltip = { FROM = { character_event = { id = HF.25069 } } }
				}
				else_if = { 
				limit = { 
					has_building = ca_wall_q_3
					NOR = { 
						is_building = ca_wall_q_4 
					}
					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 5 }
					}
					add_building = ca_wall_q_4
					hidden_tooltip = { FROM = { character_event = { id = HF.25069 } } }
				}
				else_if = { 
				limit = { 
					has_building = ca_wall_q_2
					NOR = { 
						is_building = ca_wall_q_3 
					}
					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 3 }
					}
					add_building = ca_wall_q_3
					hidden_tooltip = { FROM = { character_event = { id = HF.25069 } } }
				}
				else_if = { 
				limit = { 
					has_building = ca_wall_q_1
					NOR = { 
						is_building = ca_wall_q_2 
					}
					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 1 }
					}
					add_building = ca_wall_q_2
					hidden_tooltip = { FROM = { character_event = { id = HF.25069 } } }
				}
				else_if = { 
				limit = { 
					NOR = { 
						is_building = ca_wall_q_1
						has_building = ca_wall_q_1
					}
					location = { TECH_FORTIFICATIONS_CONSTRUCTION = 0 }
					}
					add_building = ca_wall_q_1
					hidden_tooltip = { FROM = { character_event = { id = HF.25069 } } }
				}
			}
			if = {
				limit = {
					holding_type = tribal
					can_build_hillfort_trigger = yes
					NOR = { 
						has_building = tb_hillfort_4
						is_building = tb_hillfort_4 
					}
				}
				if = { 
				limit = { 
					has_building = tb_hillfort_3
					NOR = { 
						is_building = tb_hillfort_4 
					}
					location = { TECH_CASTLE_CONSTRUCTION = 1 }
					}
					add_building = tb_hillfort_4
					hidden_tooltip = { FROM = { character_event = { id = HF.25067 } } }
				}
				else_if = { 
				limit = { 
					has_building = tb_hillfort_2
					NOR = { 
						is_building = tb_hillfort_3 
					}
					location = { TECH_CASTLE_CONSTRUCTION = 0 }
					}
					add_building = tb_hillfort_3
					hidden_tooltip = { FROM = { character_event = { id = HF.25066 } } }
				}
				else_if = { 
				limit = { 
					has_building = tb_hillfort_1
					NOR = { 
						is_building = tb_hillfort_2 
					}
					location = { TECH_CASTLE_CONSTRUCTION = 0 }
					}
					add_building = tb_hillfort_2
					hidden_tooltip = { FROM = { character_event = { id = HF.25065 } } }
				}
				else_if = { 
				limit = { 
					NOR = { 
						is_building = tb_hillfort_1
						has_building = tb_hillfort_1
					}
					location = { TECH_CASTLE_CONSTRUCTION = 0 }
					}
					add_building = tb_hillfort_1
					hidden_tooltip = { FROM = { character_event = { id = HF.25064 } } }
				}
				break = yes
			}
			if = {
				limit = {
					holding_type = tribal
					NOR = { 
						has_building = tb_defensive_fortifications_4  
						is_building = tb_defensive_fortifications_4  
					}
					OR = { 
						is_building = tb_hillfort_4 
						has_building = tb_hillfort_4 
						can_build_hillfort_trigger = no
					}
				}
				if = { 
				limit = { 
					has_building = tb_defensive_fortifications_3
					NOR = { 
						is_building = tb_defensive_fortifications_4 
					}
					location = { TECH_CASTLE_CONSTRUCTION = 1 }
					}
					add_building = tb_defensive_fortifications_4
					hidden_tooltip = { FROM = { character_event = { id = HF.25063 } } }
				}
				else_if = { 
				limit = { 
					has_building = tb_defensive_fortifications_2
					NOR = { 
						is_building = tb_defensive_fortifications_3 
					}
					location = { TECH_CASTLE_CONSTRUCTION = 0 }
					}
					add_building = tb_defensive_fortifications_3
					hidden_tooltip = { FROM = { character_event = { id = HF.25062 } } }
				}
				else_if = { 
				limit = { 
					has_building = tb_defensive_fortifications_1
					NOR = { 
						is_building = tb_defensive_fortifications_2 
					}
					location = { TECH_CASTLE_CONSTRUCTION = 0 }
					}
					add_building = tb_defensive_fortifications_2
					hidden_tooltip = { FROM = { character_event = { id = HF.25061 } } }
				}
				else_if = { 
				limit = { 
					NOR = { 
						is_building = tb_defensive_fortifications_1 
						has_building = tb_defensive_fortifications_1
					}
					location = { TECH_CASTLE_CONSTRUCTION = 0 }
					}
					add_building = tb_defensive_fortifications_1
					hidden_tooltip = { FROM = { character_event = { id = HF.25060 } } }
				}
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
		}
	}
	
	work_slave_decision = {
	    filter = owned
		ai_target_filter = owned
		ai_check_interval = 80
		diplomacy_icon = GFX_slavery_decision
		
		from_potential = {
			is_playable = yes
			is_nomadic = no
			is_adult = yes
			higher_tier_than = BARON
			has_dlc = "Holy Fury"
			any_host_courtier = {
				count = 1
				is_enslaved = yes
				prisoner = no
				is_ruler = no
				is_councillor = no
				NOT = {
					has_minor_title = title_regent
					has_minor_title = title_appointed_regent
					has_minor_title = title_commander
					has_minor_title = title_court_physician
				}
				NOT = { has_character_flag = slave_not_work }
			}
		}
		
		potential = {
			holder_scope = {
				character = FROM
			}
		}
		
		allow = {
			custom_tooltip = {
				text = custom_has_slave_work
				FROM = {
					any_host_courtier = {
						count = 5
						is_enslaved = yes
						prisoner = no
						is_ruler = no
						is_councillor = no
						NOT = {
							has_minor_title = title_regent
							has_minor_title = title_appointed_regent
							has_minor_title = title_commander
							has_minor_title = title_court_physician
						}
						age = 14
					}
				}
			}
			location = {
				NOT = { has_province_modifier = slave_work_modifier }
			}
		}
		
		effect = {
			custom_tooltip = {
				text = custom_has_slave_work_5
				FROM = {
					any_host_courtier = {
						count = 5
						limit = {
							is_enslaved = yes
							prisoner = no
							is_ruler = no
							is_councillor = no
							NOT = {
								has_minor_title = title_regent
								has_minor_title = title_appointed_regent
								has_minor_title = title_commander
								has_minor_title = title_court_physician
							}
							age = 14
							NOT = { has_character_flag = slave_not_work }
						}
						custom_tooltip = {
							text = custom_slave_work
							death = {
								death_reason = DEATH_SLAVERY
								killer = ROOT
							}
						}
					}
				}
			}
			location = {
				add_province_modifier = {
					name = slave_work_modifier
					duration = 1825
				}
				change_variable = { which = prosperity_value value = 5 }
			}
		}
		
		ai_will_do = {
			factor = 0
		}
	}

}