﻿
has_county_block_culture_conversion_trigger = {
	OR = {
		has_county_modifier = governance_1073_conversion_resistance_modifier
		has_county_modifier = county_shuubiyya_modifier
		has_county_modifier = enthusiastic_nomad_settlement_saharan_modifier
		has_county_modifier = nomad_settlement_saharan_modifier		
	}
}

potential_county_culture_conversion = {
	is_landless_type_title = no
	culture != scope:councillor_liege.culture
	trigger_if = {
		limit = {
			scope:councillor_liege = { has_variable = hold_court_8130_culture_block }
		}
		custom_tooltip = {
			text = hold_court_8130_conversion_tt
			culture != scope:councillor_liege.var:hold_court_8130_culture_block
		}
	}
	trigger_if = {
		limit = {
			scope:councillor_liege = {
				is_ai = yes
				NAND = { # AI Directives override this
					has_character_flag = vassal_directive_convert_culture
					vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
				}
			}
		}
		NAND = { # Princes in the HRE tend to not convert each other's cultures
			exists = title:e_hre.holder
			scope:councillor_liege.top_liege = title:e_hre.holder
			OR = {
				scope:councillor_liege.culture = culture:czech
				scope:councillor_liege.culture = { has_cultural_pillar = heritage_central_germanic }
			}
			OR = {
				scope:county.culture = culture:czech
				scope:county.culture = { has_cultural_pillar = heritage_central_germanic }
			}
		}
		NOT = { # Do not eliminate the Basques
			scope:county.culture = {
				this = culture:basque
				any_culture_county = {
					count <= 5
				}
			}
		}
		scope:councillor_liege = {
			OR = {
				NOT = {
					scope:county.culture = {
						cultural_acceptance = { target = scope:councillor_liege.culture value >= 50 }
					}
				}
				scope:county = {
					this = title:c_maragha
					culture = culture:turkish
				}
				culture = { # All AI's are motivated to spread new Hybrid/Divergent cultures
					OR = {
						is_hybrid_culture = yes
						is_divergent_culture = yes
					}
					NOT = { # Leave the Welsh alone!
						this = culture:anglo_saxon
					}
					any_parent_culture = {
						this = scope:county.culture
					}
				}
				culture = { # Small cultures want to grow a bit
					any_culture_county = {
						count < 10
					}
				}
				scope:county.culture = { # 'dead' small cultures can go away
					OR = {
						is_hybrid_culture = yes
						is_divergent_culture = yes
					}
					any_culture_county = {
						count < 10
					}
					OR = {
						NOT = { exists = culture_head }
						any_culture_county = {
							count < 5
						}
					}
				}
				AND = {
					# Scottish rulers should convert counties of 'old' cultures to the new one.
					culture = culture:scottish
					OR = {
						scope:county.culture = culture:anglo_saxon
						scope:county.culture = culture:gaelic
						scope:county.culture = culture:cumbrian
						scope:county.culture = culture:pictish
					}
				}
				AND = {
					# English rulers should convert counties of 'old' cultures to the new one.
					culture = culture:english
					OR = {
						scope:county.culture = culture:anglo_saxon
						scope:county.culture = culture:norman
					}
				}
				AND = {
					# German rulers want to convert the polabians
					culture = { has_cultural_pillar = heritage_central_germanic }
					scope:county.culture = culture:polabian
					NOT = { scope:councillor_liege.primary_title = title:e_hre }
				}

				AND = {
					# Japanese rulers should convert Emishi counties
					culture = culture:japanese
					scope:county.culture = culture:emishi
				}
			}
			OR = {
				is_independent_ruler = yes
				primary_title.tier > tier_county
				culture = { # All AI's are motivated to spread new Hybrid/Divergent cultures
					OR = {
						is_hybrid_culture = yes
						is_divergent_culture = yes
					}
					any_parent_culture = {
						this = scope:county.culture
					}
				}
				culture = { # Small cultures want to grow a bit
					any_culture_county = {
						count < 10
					}
				}
				scope:county.culture = { # 'dead' small cultures can go away
					OR = {
						is_hybrid_culture = yes
						is_divergent_culture = yes
					}
					any_culture_county = {
						count < 10
					}
					OR = {
						NOT = { exists = culture_head }
						any_culture_county = {
							count < 5
						}
					}
				}
				culture = { # Imperious cultures want to grow to a certain size
					culture_head ?= {
						is_independent_ruler = yes
						highest_held_title_tier >= tier_kingdom
						sub_realm_size >= 30
					}
					any_culture_county = {
						count < 35
					}
				}
				AND = {
					# Scottish rulers should convert counties of 'old' cultures to the new one.
					culture = culture:scottish
					OR = {
						scope:county.culture = culture:anglo_saxon
						scope:county.culture = culture:gaelic
						scope:county.culture = culture:cumbrian
						scope:county.culture = culture:pictish
					}
				}
				AND = {
					# English rulers should convert counties of 'old' cultures to the new one.
					culture = culture:english
					OR = {
						scope:county.culture = culture:anglo_saxon
						scope:county.culture = culture:norman
					}
				}
				AND = {
					# German rulers want to convert the polabians
					culture = { has_cultural_pillar = heritage_central_germanic }
					scope:county.culture = culture:polabian
					NOT = { scope:councillor_liege.primary_title = title:e_hre }
				}
				AND = {
					# Japanese rulers should convert Emishi counties
					culture = culture:japanese
					scope:county.culture = culture:emishi
				}
			}
		}
		OR = {
			scope:county = {
				any_neighboring_county = {
					culture = scope:councillor_liege.culture # The AI only wants to convert counties bordering their own culture
				}
			}
			AND = { # The English want to convert the Anglo Saxons and Cumbrians
				scope:councillor_liege.culture = culture:english
				OR = {
					scope:county.culture = culture:anglo_saxon
					scope:county.culture = culture:cumbrian
				}
			}
			AND = { # The Scots want to convert the Anglo Saxons, Cumbrians and Gaelic
				scope:councillor_liege.culture = culture:scottish
				OR = {
					scope:county.culture = culture:anglo_saxon
					scope:county.culture = culture:gaelic
					scope:county.culture = culture:cumbrian
					scope:county.culture = culture:pictish
				}
			}
			AND = { # The Gaels want to convert the Picts and Cumbrians
				scope:councillor_liege.culture = culture:gaelic
				OR = {
					scope:county.culture = culture:cumbrian
					scope:county.culture = culture:pictish
				}
			}
			AND = { # The modern scandinavians want to convert the Norse
				OR = {
					scope:councillor_liege.culture = culture:swedish
					scope:councillor_liege.culture = culture:danish
					scope:councillor_liege.culture = culture:norwegian
				}
				scope:county.culture = culture:norse
			}
			AND = { # The Portuguese should want to convert Suebi
				scope:councillor_liege.culture = culture:portuguese
				scope:county.culture = culture:suebi
			}
			AND = { # The Iberians want to convert Visigothic
				scope:councillor_liege.culture = { has_cultural_pillar = heritage_iberian }
				NOT = { scope:councillor_liege.culture = culture:portuguese }
				scope:county.culture = culture:visigothic
			}
			AND = {
				# German rulers want to convert the polabians
				scope:councillor_liege.culture = { has_cultural_pillar = heritage_central_germanic }
				scope:county.culture = culture:polabian
				NOT = { scope:councillor_liege.primary_title = title:e_hre }
			}
			AND = {
				# Japanese rulers should convert Emishi counties
				scope:councillor_liege.culture = culture:japanese
				scope:county.culture = culture:emishi
			}
		}
	}
	trigger_else_if = { # But AI Directives should still try to look pretty
		limit = {
			scope:councillor_liege = {
				is_ai = yes
				has_character_flag = vassal_directive_convert_culture
				vassal_is_valid_and_follows_directive_trigger = { VASSAL = this LIEGE = liege }
			}
		}
		trigger_if = {
			limit = {
				scope:county = {
					any_neighboring_county = {
						culture = scope:councillor_liege.culture
					}
				}
			}
			scope:county = {
				any_neighboring_county = {
					culture = scope:councillor_liege.culture # The AI only wants to convert counties bordering their own culture
				}
			}
		}
		trigger_else = {
			always = yes
		}
	}
	trigger_else = {
	}
}