﻿convert_to_local_culture_decision = {
	picture = "gfx/interface/illustrations/decisions/decision_realm.dds"

	desc = convert_to_local_culture_decision_desc
	selection_tooltip = convert_to_local_culture_decision_tooltip

	is_shown = {
		is_landed = yes
		primary_title.tier > tier_barony
		NOT = { culture = capital_province.culture }
		NAND = {
			is_ai = yes
			OR = {
				has_character_flag = converted_culture_this_lifetime
				has_character_flag = converted_culture_this_lifetime_ai
			}
		}
	}

	is_valid_showing_failures_only = {
		is_available_adult = yes
		is_at_war = no
		custom_description = {
			text = can_only_change_culture_once
			NOT = { has_character_flag = converted_culture_this_lifetime }
		}
	}

	cost = {
		prestige = convert_to_local_culture_base_cost
	}

	effect = {
		convert_family_culture_and_notify_vassals_effect = {
			CONVERTER = root
			OLD_CULTURE = root.culture
			NEW_CULTURE = capital_province.culture
		}
	}
	
	ai_check_interval = 60

	ai_potential = {
		is_landed = yes
		NOT = { culture = capital_province.culture }
	}

	ai_will_do = {
		base = 3
		
		modifier = { # If your liege is the same culture as your capital, better get on with it! This should combat scattered wrong-culture Counts and such.
			add = 77
			capital_province.culture = liege.culture
		}
		
		modifier = { # Motivate vassals to assimilate if they are different culture from their liege. If they can't curry their liege's favor, better get the peasants on your side at least...
			add = 27
			NOR = {
				culture = capital_province.culture
				culture = liege.culture
			}
		}
		
		modifier = { # If you're the same culture as your liege, and your Capital is in a Duchy with your culture in it, never convert
			factor = 0
			exists = liege
			culture = liege.culture
			capital_province.duchy = {
				any_in_de_jure_hierarchy = {
					tier = tier_county
					any_county_province = {
						culture = root.culture
					}
				}
			}
		}
		
		modifier = { # If your capital borders a province with the correct culture, do not convert
			factor = 0
			exists = liege
			culture = liege.culture
			capital_province.county = {
				any_neighboring_county = {
					any_county_province = {
						culture = root.culture
					}
				}
			}
		}
		
		modifier = { # If your liege is your parent, do not convert
			factor = 0
			exists = liege
			culture = liege.culture
			OR = {
				liege = root.mother
				liege = root.father
			}
		}
		
		# Some cultures should not assimilate to certain others
		modifier = {
			factor = 0
			has_culture = culture:andalusian
			capital_province.culture_group = culture_group:iberian_group
		}
		modifier = {
			factor = 0
			has_culture_group = culture_group:iberian_group
			capital_province.culture = culture:andalusian
		}

		# Don't overwrite historically scripted developments
		modifier = {
			factor = 0
			OR = {
				has_culture = culture:norman
				has_culture = culture:english
			}
			capital_province.culture = culture:anglo_saxon
		}
		modifier = {
			factor = 0
			has_culture = culture:turkish
		}
		modifier = {
			factor = 0
			OR = {
				has_title = title:k_jerusalem
				has_title = title:e_outremer
				any_liege_or_above = {
					OR = {
						has_title = title:k_jerusalem
						has_title = title:e_outremer
					}
				}
			}
		}
		modifier = {
			factor = 0
			has_title = title:e_latin_empire
		}

		# Scots needs a bit of help to dominate as it did historically
		modifier = {
			factor = 0
			has_culture = culture:scottish
			capital_province.culture = culture:gaelic
		}

		# Pictish should usually disappear
		modifier = {
			factor = 0
			has_culture = culture:gaelic
			capital_province.culture = culture:pictish
		}
		
		# Don't go back on a previous conversion
		modifier = {
			factor = 0
			has_character_flag = converted_culture_this_lifetime
		}
		### Sane Warfare Changes
		
		#### Chance to convert affected by the culture of your vassals - if the realm has more vassals of the new culture than the old culture, the chances increase, if it has less, they are reduced. 
		#### Kings are weighted the same as 3 Dukes each, whereas Dukes are weighted the same as 2 Counts each.
		modifier = {
			factor = {
				value = 1
				## Kings
				every_vassal_or_below = {
					limit = {
						highest_held_title_tier = tier_kingdom
						culture = root.culture
					}
					add = -0.6
				}
				every_vassal_or_below = {
					limit = {
						highest_held_title_tier = tier_kingdom
						culture = capital_province.culture
					}
					add = 0.6
				}
				## Dukes
				every_vassal_or_below = {
					limit = {
						highest_held_title_tier = tier_duchy
						culture = root.culture
					}
					add = -0.2
				}
				every_vassal_or_below = {
					limit = {
						highest_held_title_tier = tier_duchy
						culture = capital_province.culture
					}
					add = 0.2
				}
				every_vassal_or_below = { ## Counts
					limit = {
						highest_held_title_tier = tier_county
						culture = root.culture
					}
					add = -0.1
				}
				every_vassal_or_below = { ## Counts
					limit = {
						highest_held_title_tier = tier_county
						culture = capital_province.culture
					}
					add = 0.1
				}
			}
				
		}
		### The Pope and other such characters should always convert to local culture - ensures consistency with MAA and buildings.
		modifier = {
			add = 1000
			AND ={
				root.faith = { has_doctrine = doctrine_temporal_head }
				root = root.faith.religious_head 
			}
		}
	}
}

