settlement_decisions = {

	######################
	# balanced decisions #
	######################
	
	destroy_settlement_mod = {				# Destroy built holding (only for tribals)
		filter = owned
		ai_target_filter = owned
		is_high_prio = yes
		
		from_potential = {
			is_tribal = yes
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = balanced
			}
			OR = {
				holding_type = castle
				holding_type = city
				holding_type = temple
				AND = {
					holding_type = tribal
					is_capital = no
					location = {
						holding_type = tribal
						is_capital = yes
					}
				}
			}
			holder_scope = {
				character = FROM
			}
			location = {
				has_tribal = yes
			}
		}
		
		allow = {
			holder = FROM
			holder_scope = {
				NOT = {
					trait = incapable
				}
			}
		}
		
		effect = {
			if = {
				limit = {
					holding_type = temple
				}
				if = {
					limit = {
						location = {
							religion = FROM
						}
					}
					religion_authority = {
						modifier = destroyed_temple 
						years = 20
					}
				}
				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 = 20
							}
						}
					}
					if = {
						limit = {
							location = {
								NOT = {
									religion_group = pagan_group
								}
							}
						}
						location = {
							religion_authority = {
								modifier = destroyed_heathen_temple
								years = 20
							}
						}
					}
					FROM = {
						religion_authority = {
							modifier = destroyed_temple_positive
						}
					}
				}
				location = {
					add_province_modifier = {
						name = destroyed_temple
						years = 20
						stacking = yes
					}
				}
			}
			if = {
				limit = {
					NOR = {
						holding_type = temple
						holding_type = tribal
					}
				}
				location = {
					add_province_modifier = {
						name = destroyed_holding
						years = 20
						stacking = yes
					}
					province_event = { id = DaCS.3 days = 7300 }
				}
			}
			if = {
				limit = {
					holding_type = tribal
				}
				location = {
					add_province_modifier = {
						name = merged_tribes
						years = 20
					}
				}
			}
			if = {
				limit = {
					NOT = {
						holding_type = tribal
					}
				}
				location = {
					add_province_modifier = {
						name = salvaged_materials
						years = 5
					}
				}
			}

			destroy_settlement = THIS
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					location = {
						OR = {
							has_province_modifier = destroyed_holding
							has_province_modifier = destroyed_temple
						}
					}
					AND = {
						holding_type = temple
						location = {
							religion = FROM
						}
					}
					trait = temperate
					trait = kind
					trait = patient
					trait = craven
					trait = content
					trait = humble
				}
			}
		}
	}
	
	convert_settlement_tribe = { 			# Convert Capital Settlement to Tribe
		filter = owned
		ai_target_filter = owned
		is_high_prio = yes
		
		from_potential = {
			is_tribal = yes
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = balanced
			}
			is_capital = yes
			location = {
				NOT = {
					any_province_holding = {
						holding_type = tribal
					}
				}
			}
		}
		
		allow = {
			holder = FROM
		}
		
		effect = {
			location = {
				if = {
					limit = {
						NOT = {
							has_province_modifier = settled_tribe
						}
					}
					add_province_modifier = {
						name = settled_tribe
						years = 20
					}
				}
				if = {
					limit = {
						NOT = {
							has_province_modifier = population_relocated
						}
					}
					add_province_modifier = {
						name = population_relocated
						years = 10
					}
				}
			}
			convert_to = TRIBAL
		}
	}

	convert_settlement_castle = { 			# Convert holding to CASTLE
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = no
			is_nomadic = no
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = balanced
			}
			OR = {
				holding_type = city
				holding_type = temple
			}
			holder_scope = {
				character = FROM
				ai = no
			}
			is_capital = yes
		}
		
		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 = {				# Convert holding to CITY
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = no
			is_nomadic = no
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = balanced
			}
			OR = {
				holding_type = castle
				holding_type = temple
			}
			holder_scope = {
				character = FROM
				ai = no
			}
			is_capital = yes
		}
		
		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 = {			# Convert holding to TEMPLE
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = no
			is_nomadic = no
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = balanced
			}
			OR = {
				holding_type = city
				holding_type = castle
			}
			holder_scope = {
				character = FROM
				ai = no
			}
			is_capital = yes
		}
		
		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
		}
	}
	
	##################
	# free decisions #
	##################
	
	destroy_settlement_mod_free = {			# Destroy built holding (only for tribals)
		filter = owned
		ai_target_filter = owned
		is_high_prio = yes
		
		from_potential = {	
			is_tribal = yes
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = free
			}
			OR = {
				holding_type = castle
				holding_type = city
				holding_type = temple
				AND = {
					holding_type = tribal
					is_capital = no
					location = {
						holding_type = tribal
						is_capital = yes
					}
				}
			}
			holder_scope = {
				character = FROM
			}
			location = {
				has_tribal = yes
			}
		}
		
		allow = {
			holder = FROM
			holder_scope = {
				NOT = {
					trait = incapable
				}
			}
		}
		
		effect = {
			destroy_settlement = THIS
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0
				OR = {
					location = {
						OR = {
							has_province_modifier = destroyed_holding
							has_province_modifier = destroyed_temple
						}
					}
					AND = {
						holding_type = temple
						location = {
							religion = FROM
						}
					}
					trait = temperate
					trait = kind
					trait = patient
					trait = craven
					trait = content
					trait = humble
				}
			}
		}
	}
	
	convert_settlement_tribe_free = {		# Convert Capital Settlement to Tribe
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = yes
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = free
			}
			is_capital = yes
			location = {
				NOT = {
					any_province_holding = {
						holding_type = tribal
					}
				}
			}
		}
		
		allow = {
			holder = FROM
		}
		
		effect = {
			convert_to = TRIBAL
		}
	}

	convert_settlement_castle_free = {			# Convert holding to CASTLE
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = no
			is_nomadic = no
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = free
			}
			OR = {
				holding_type = city
				holding_type = temple
			}
			holder_scope = {
				character = FROM
				ai = no
			}
			is_capital = yes
		}
		
		allow = {
			holder = FROM
			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 = {
			convert_to = CASTLE
		}
	}
	
	convert_settlement_city_free = {		# Convert holding to CITY
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = no
			is_nomadic = no
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = free
			}
			OR = {
				holding_type = castle
				holding_type = temple
			}
			holder_scope = {
				character = FROM
				ai = no
			}
			is_capital = yes
		}
		
		allow = {
			holder = FROM
			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 = {
			convert_to = CITY
		}
	}

	convert_settlement_temple_free = {		# Convert holding to TEMPLE
		filter = owned
		ai_target_filter = owned
		
		from_potential = {
			is_tribal = no
			is_nomadic = no
		}
		
		potential = {
			has_game_rule =  {
				name = dacs
				value = free
			}
			OR = {
				holding_type = city
				holding_type = castle
			}
			holder_scope = {
				character = FROM
				ai = no
			}
			is_capital = yes
		}
		
		allow = {
			holder = FROM
			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 = {
			convert_to = TEMPLE
		}
	}
}