targetted_decisions = {
	kcb_import_elephants_to_capital = {
		only_playable = yes
		filter = self
		ai_target_filter = self
		diplomacy_icon = GFX_trait_war_elephant_leader
	
		potential = {
			has_game_rule = {
				name = kcult_import_elephants
				value = kimp_elephants_yes
			}
			has_dlc = "Legacy of Rome"
			has_dlc = "Rajas of India"
			real_tier = EMPEROR
			is_nomadic = no
			is_tribal = no
			capital_scope = {
				NOT = { terrain = arctic }
				NOT = { has_province_modifier = kcb_local_elephant_herd }
			}
		}
		
		allow = {
			age > 11
			prestige = 3000
			custom_tooltip = {
				text = kcb_import_elephants_tooltip_01
				OR = {
					any_demesne_province = {
						trigger_if = {
							limit = {
								OR = {
									has_game_rule = {
										name = kcult_fantasy_elephants
										value = k_atlas_elephants
									}
									has_game_rule = {
										name = kcult_fantasy_elephants
										value = k_all_fanstasy_elephants
									}
								}
							}
							OR = {
								region = world_india
								region = world_africa_north
							}
						}
						trigger_else = { region = world_india }
						NOT = { has_province_modifier = kcb_exporting_elephants }
					}
					any_vassal = {
						higher_real_tier_than = BARON
						capital_scope = {
							trigger_if = {
								limit = {
									OR = {
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_atlas_elephants
										}
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_all_fanstasy_elephants
										}
									}
								}
								OR = {
									region = world_india
									region = world_africa_north
								}
							}
							trigger_else = { region = world_india }
							NOT = { has_province_modifier = kcb_exporting_elephants }
						}
					}
					AND = {
						NOT = { has_character_modifier = kcb_ally_refused_elephants }
						any_neighbor_independent_ruler = {
							is_allied_with = FROM
							is_feudal = yes
							higher_real_tier_than = DUKE
							capital_scope = {
								trigger_if = {
									limit = {
										OR = {
											has_game_rule = {
												name = kcult_fantasy_elephants
												value = k_atlas_elephants
											}
											has_game_rule = {
												name = kcult_fantasy_elephants
												value = k_all_fanstasy_elephants
											}
										}
									}
									OR = {
										region = world_india
										region = world_africa_north
									}
								}
								trigger_else = { region = world_india }
								NOT = { has_province_modifier = kcb_exporting_elephants }
							}
						}
					}
				}
			}
			custom_tooltip = {
				text = kcb_import_elephants_tooltip_02
				NOT = { has_character_flag = kcb_asked_buddy_for_pachyderms }
				NOT = { has_character_modifier = kcb_lost_pachyderms }
				NOR = {
					any_demesne_province = { has_province_modifier = kcb_local_elephant_herd }
					any_demesne_province = { has_province_modifier = kcb_importing_elephants }
				}
			}
			custom_tooltip = {
				text = kcb_import_elephants_tooltip_03
				capital_scope = {
					OR = {
						trigger_if = {
							limit = {
								NOR = {
									has_game_rule = {
										name = kcult_fantasy_elephants
										value = k_atlas_elephants
									}
									has_game_rule = {
										name = kcult_fantasy_elephants
										value = k_all_fanstasy_elephants
									}
								}
							}
							region = world_africa_north
						}
						region = world_asia_minor
						region = world_persia
						region = world_middle_east
						province_id = 496
					}
					OR = {
						NOT = { terrain = mountain }
						trade_route = silk_road
						port = yes
						borders_lake = yes
						borders_major_river = yes
					}
					OR = {
						NOT = { terrain = desert }
						borders_lake = yes
						borders_major_river = yes
					}
				}
			}
			trigger_if = {
				limit = {
					OR = {
						any_demesne_province = {
							trigger_if = {
								limit = {
									OR = {
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_atlas_elephants
										}
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_all_fanstasy_elephants
										}
									}
								}
								OR = {
									region = world_india
									region = world_africa_north
								}
							}
							trigger_else = { region = world_india }
							NOT = { has_province_modifier = kcb_exporting_elephants }
						}
						any_vassal = {
							higher_real_tier_than = BARON
							capital_scope = {
								trigger_if = {
									limit = {
										OR = {
											has_game_rule = {
												name = kcult_fantasy_elephants
												value = k_atlas_elephants
											}
											has_game_rule = {
												name = kcult_fantasy_elephants
												value = k_all_fanstasy_elephants
											}
										}
									}
									OR = {
										region = world_india
										region = world_africa_north
									}
								}
								trigger_else = { region = world_india }
								NOT = { has_province_modifier = kcb_exporting_elephants }
							}
						}
					}
				}
				scaled_wealth = {
					value = 1.5
					min = 500
					max = 3000
				}
			}
			trigger_else = {
				scaled_wealth = {
					value = 3
					min = 1000
					max = 7500
				}
			}
			capital_scope = {
				NOT = { has_province_modifier = kcb_importing_elephants }	
			}
		}
		
		effect = {
			if = {
				limit = {
					any_demesne_province = {
						trigger_if = {
							limit = {
								OR = {
									has_game_rule = {
										name = kcult_fantasy_elephants
										value = k_atlas_elephants
									}
									has_game_rule = {
										name = kcult_fantasy_elephants
										value = k_all_fanstasy_elephants
									}
								}
							}
							OR = {
								region = world_india
								region = world_africa_north
							}
						}
						trigger_else = { region = world_india }
						NOT = { has_province_modifier = kcb_exporting_elephants }
					}
				}
				scaled_wealth = {
					value = -1.5
					min = -500
					max = -3000
				}
				if = {
					limit = {
						capital_scope = { terrain = desert }
					}
					capital_scope = {
						show_scope_change = no
						add_province_modifier = {
							name = kcb_importing_elephants
							years = 30
						}
						province_event = {
							id = kcb_elephants.1
							years = 30
						}
					}
					random_demesne_province = {
						show_scope_change = no
						limit = {
							trigger_if = {
								limit = {
									OR = {
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_atlas_elephants
										}
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_all_fanstasy_elephants
										}
									}
								}
								OR = {
									region = world_india
									region = world_africa_north
								}
							}
							trigger_else = { region = world_india }
							NOT = { has_province_modifier = kcb_exporting_elephants }
						}
						add_province_modifier = {
							name = kcb_exporting_elephants
							years = 30
						}
					}
				}
				else_if = {
					limit = {
						capital_scope = { terrain = mountain }
					}
					capital_scope = {
						show_scope_change = no
						add_province_modifier = {
							name = kcb_importing_elephants
							years = 25
						}
						province_event = {
							id = kcb_elephants.1
							years = 25
						}
					}
					random_demesne_province = {
						show_scope_change = no
						limit = {
							trigger_if = {
								limit = {
									OR = {
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_atlas_elephants
										}
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_all_fanstasy_elephants
										}
									}
								}
								OR = {
									region = world_india
									region = world_africa_north
								}
							}
							trigger_else = { region = world_india }
							NOT = { has_province_modifier = kcb_exporting_elephants }
						}
						add_province_modifier = {
							name = kcb_exporting_elephants
							years = 25
						}
					}
				}
				else_if = {
					limit = {
						capital_scope = {
							OR = {
								terrain = steppe
								terrain = hills
							}
						}
					}
					capital_scope = {
						show_scope_change = no
						add_province_modifier = {
							name = kcb_importing_elephants
							years = 20
						}
						province_event = {
							id = kcb_elephants.1
							years = 20
						}
					}
					random_demesne_province = {
						show_scope_change = no
						limit = {
							trigger_if = {
								limit = {
									OR = {
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_atlas_elephants
										}
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_all_fanstasy_elephants
										}
									}
								}
								OR = {
									region = world_india
									region = world_africa_north
								}
							}
							trigger_else = { region = world_india }
							NOT = { has_province_modifier = kcb_exporting_elephants }
						}
						add_province_modifier = {
							name = kcb_exporting_elephants
							years = 20
						}
					}
				}
				else = {
					capital_scope = {
						show_scope_change = no
						add_province_modifier = {
							name = kcb_importing_elephants
							years = 15
						}
						province_event = {
							id = kcb_elephants.1
							years = 15
						}
					}
					random_demesne_province = {
						show_scope_change = no
						limit = {
							trigger_if = {
								limit = {
									OR = {
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_atlas_elephants
										}
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_all_fanstasy_elephants
										}
									}
								}
								OR = {
									region = world_india
									region = world_africa_north
								}
							}
							trigger_else = { region = world_india }
							NOT = { has_province_modifier = kcb_exporting_elephants }
						}
						add_province_modifier = {
							name = kcb_exporting_elephants
							years = 15
						}
					}
				}
			}
			else_if = {
				limit = {
					any_vassal = {
						higher_real_tier_than = BARON
						capital_scope = {
							trigger_if = {
								limit = {
									OR = {
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_atlas_elephants
										}
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_all_fanstasy_elephants
										}
									}
								}
								OR = {
									region = world_india
									region = world_africa_north
								}
							}
							trigger_else = { region = world_india }
							NOT = { has_province_modifier = kcb_exporting_elephants }
						}
					}
				}
				scaled_wealth = {
					value = -0.375
					min = -125
					max = -750
				}
				random_vassal = {
					limit = {
						higher_real_tier_than = BARON
						capital_scope = {
							trigger_if = {
								limit = {
									OR = {
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_atlas_elephants
										}
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_all_fanstasy_elephants
										}
									}
								}
								OR = {
									region = world_india
									region = world_africa_north
								}
							}
							trigger_else = { region = world_india }
							NOT = { has_province_modifier = kcb_exporting_elephants }
						}
					}
					preferred_limit = {
						real_tier = KING
						kcb_is_potential_elephant_giver = yes
					}
					preferred_limit = {
						real_tier = KING
					}
					preferred_limit = {
						real_tier = DUKE
						num_of_duke_titles >= 2
						kcb_is_potential_elephant_giver = yes
					}
					preferred_limit = {
						real_tier = DUKE
						kcb_is_potential_elephant_giver = yes
					}
					preferred_limit = {
						kcb_is_potential_elephant_giver = yes
					}
					preferred_limit = {
						real_tier = DUKE
					}
					transfer_scaled_wealth = {
						from = ROOT
						value = 1.25
						min = 375
						max = 2250
					}
					if = {
						limit = {
							ROOT = { capital_scope = { terrain = desert } }
						}
						ROOT = {
							show_scope_change = no
							capital_scope = {
								show_scope_change = no
								add_province_modifier = {
									name = kcb_importing_elephants
									years = 30
								}
								province_event = {
									id = kcb_elephants.1
									years = 30
								}
							}
						}
						capital_scope = {
							show_scope_change = no
							add_province_modifier = {
								name = kcb_exporting_elephants
								years = 30
							}
						}
					}
					else_if = {
						limit = {
							ROOT = { capital_scope = { terrain = mountain } }
						}
						ROOT = {
							show_scope_change = no
							capital_scope = {
								show_scope_change = no
								add_province_modifier = {
									name = kcb_importing_elephants
									years = 25
								}
								province_event = {
									id = kcb_elephants.1
									years = 25
								}
							}
						}
						capital_scope = {
							show_scope_change = no
							add_province_modifier = {
								name = kcb_exporting_elephants
								years = 25
							}
						}
					}
					else_if = {
						limit = {
							ROOT = {
								capital_scope = {
									OR = {
										terrain = steppe
										terrain = hills
									}
								}
							}
						}
						ROOT = {
							show_scope_change = no
							capital_scope = {
								show_scope_change = no
								add_province_modifier = {
									name = kcb_importing_elephants
									years = 20
								}
								province_event = {
									id = kcb_elephants.1
									years = 20
								}
							}
						}
						capital_scope = {
							show_scope_change = no
							add_province_modifier = {
								name = kcb_exporting_elephants
								years = 20
							}
						}
					}
					else = {
						ROOT = {
							show_scope_change = no
							capital_scope = {
								show_scope_change = no
								add_province_modifier = {
									name = kcb_importing_elephants
									years = 15
								}
								province_event = {
									id = kcb_elephants.1
									years = 15
								}
							}
						}
						capital_scope = {
							show_scope_change = no
							add_province_modifier = {
								name = kcb_exporting_elephants
								years = 15
							}
						}
					}
				}
			}
			else = {
				set_character_flag = kcb_asked_buddy_for_pachyderms
				character_event = {
					id = kcb_elephants.7
					days = 20
				}
				hidden_effect = {
					save_event_target_as = target_kcb_wants_elephants
					capital_scope = { save_event_target_as = target_kcb_elephant_capital }
				}
				random_neighbor_independent_ruler = {
					limit = {
						is_allied_with = FROM
						higher_real_tier_than = DUKE
						capital_scope = {
							trigger_if = {
								limit = {
									OR = {
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_atlas_elephants
										}
										has_game_rule = {
											name = kcult_fantasy_elephants
											value = k_all_fanstasy_elephants
										}
									}
								}
								OR = {
									region = world_india
									region = world_africa_north
								}
							}
							trigger_else = { region = world_india }
							NOT = { has_province_modifier = kcb_exporting_elephants }
						}
					}
					preferred_limit = {
						kcb_is_potential_elephant_giver = yes
					}
					letter_event = {
						id = kcb_elephants.2
						days = 3
						tooltip = kcb_ask_for_elephants_tooltip
					}
				}
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0.33 # Less likely to do it
			}
			modifier = {
				factor = 2
				trait = ambitious
			}
			modifier = {
				factor = 2
				trait = proud
			}
			modifier = {
				factor = 2
				has_lifestyle_martial_trigger = yes
			}
			modifier = {
				factor = 1.5
				has_crusade_trait_trigger = yes
			}
			modifier = {
				factor = 1.5
				trait = haughty
			}
			modifier = {
				factor = 1.5
				trait = willful
			}
			modifier = {
				factor = 0
				trait = content
			}
			modifier = {
				factor = 0.33
				trait = humble
			}
			modifier = {
				factor = 0.33
				trait = timid
			}
		}
	}
}

title_decisions = {

	kcb_settle_minorities_depopulation = {
		only_playable = yes
		filter = owned
		ai_target_filter = owned
		is_high_prio = yes
		ai_check_interval = 12
		
		from_potential = {
			has_dlc = "Reapers"
			block_general_event_trigger = no
			is_incapable = no
		}
		
		potential = {
			tier = COUNT
			location = {
				num_of_settlements = 1
				NOT = { has_province_modifier = nomad_agitation }
				OR = {
					has_province_modifier = depopulated_1
					has_province_modifier = depopulated_2
					has_province_modifier = depopulated_3
				}
			}
		}
		allow = {
			location = {
				show_scope_change = no
				has_disease = no
				custom_tooltip = {
					text = kcb_settle_minorities_depopulation_tooltip_03
					NOT = { any_neighbor_province = { has_disease = yes } }
				}
				custom_tooltip = {
					text = kcb_settle_minorities_depopulation_tooltip_01
					any_province = {
						kcb_is_potential_source = yes
						NAND = {
							culture = ROOT
							religion = ROOT
						}
						OR = {
							owned_by = ROOT_FROM
							AND = {
								NOT = { owned_by = ROOT_FROM }
								owner = { 
									same_realm = ROOT_FROM
									block_general_event_trigger = no
									is_incapable = no
								}
							}
							AND = {
								NOT = { owned_by = ROOT_FROM }
								owner = { 
									NOT = { same_realm = ROOT_FROM }
									is_within_diplo_range = ROOT_FROM
									block_general_event_trigger = no
									is_incapable = no
								}
							}
						}
					}
				}
			}
			FROM = {
				show_scope_change = no
				custom_tooltip = {
					text = kcb_settle_minorities_depopulation_tooltip_04
					OR = {
						NOT = { has_character_flag = kcb_minority_settlement_end }
						had_character_flag = {
							flag = kcb_minority_settlement_end
							months = 30
						}
					}
				}
				scaled_wealth = {
					value = 0.5
					max = 1000
				}
			}
		}
		effect = {
			custom_tooltip = {
				text = kcb_settle_minorities_depopulation_tooltip_02
				location = {
					set_province_flag = kcb_looking_for_settlers
					kcb_clear_minority_flags = yes
				}
				FROM = {
					if = {
						limit = { has_character_flag = kcb_minority_settlement_end }
						clr_character_flag = kcb_minority_settlement_end
					}
					character_event = { id = kcb_cultures.03 }
				}
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.66 # Less likely to do it
			}
			modifier = {
				factor = 0
				FROM = {
					NOT = {
						scaled_wealth = {
							value = 0.5
							max = 1000
						}
					}
				}
			}
		}
	}
	
	kcb_settle_minorities_nomad = {
		only_playable = yes
		filter = owned
		ai_target_filter = owned
		is_high_prio = yes
		ai_check_interval = 12
		
		from_potential = {
			has_dlc = "Reapers"
			primary_title = { higher_tier_than = COUNT }
			block_general_event_trigger = no
			is_incapable = no
		}
		
		potential = {
			tier = COUNT
			is_capital = no
			location = {
				num_of_settlements = 1
				has_province_modifier = nomad_agitation
				region = world_steppe
				OR = {
					has_province_modifier = depopulated_1
					has_province_modifier = depopulated_2
					has_province_modifier = depopulated_3
				}
			}
		}
		allow = {
			location = {
				show_scope_change = no
				has_disease = no
				custom_tooltip = {
					text = kcb_settle_minorities_depopulation_tooltip_03
					NOT = { any_neighbor_province = { has_disease = yes } }
				}
				custom_tooltip = {
					text = kcb_settle_minorities_nomad_tooltip_01
					any_neighbor_province = {
						region = world_steppe
						kcb_is_potential_source = yes
						NAND = {
							culture = ROOT
							religion = ROOT
						}
						owned_by = ROOT_FROM
						#OR = {
						#	owned_by = ROOT_FROM
						#	AND = {
						#		NOT = { owned_by = ROOT_FROM }
						#		owner = { 
						#			same_realm = ROOT_FROM
						#			block_general_event_trigger = no
						#			is_incapable = no
						#		}
						#	}
						#}
					}
				}
			}
			FROM = {
				show_scope_change = no
				custom_tooltip = {
					text = kcb_settle_minorities_nomad_tooltip_04
					OR = {
						NOT = { has_character_flag = kcb_nomad_settlement_end }
						had_character_flag = {
							flag = kcb_nomad_settlement_end
							months = 90
						}
					}
				}
				scaled_wealth = {
					value = 0.33
					max = 500
				}
			}
		}
		effect = {
			custom_tooltip = {
				text = kcb_settle_minorities_depopulation_tooltip_02
				location = {
					set_province_flag = kcb_looking_for_settlers
					any_neighbor_province = {
						limit = {
							region = world_steppe
							kcb_is_potential_source = yes
							NAND = {
								culture = ROOT
								religion = ROOT
							}
							owned_by = ROOT_FROM
						}
						set_province_flag = kcb_can_be_nomad_source
					}
					kcb_clear_minority_flags = yes
				}
				FROM = {
					if = {
						limit = { has_character_flag = kcb_nomad_settlement_end }
						clr_character_flag = kcb_nomad_settlement_end
					}
					character_event = { id = kcb_cultures.13 }
				}
			}
		}
		
		revoke_allowed = {
			always = no
		}
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.33 # Less likely to do it
			}
			modifier = {
				factor = 0
				FROM = {
					NOT = {
						scaled_wealth = {
							value = 0.33
							max = 500
						}
					}
				}
			}
		}
	}
}