﻿### Convert to Local Culture ###
convert_to_local_culture_decision = {
	picture = {
		reference = "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_playable_character = yes
		primary_title.tier > tier_barony
		culture != capital_province.culture
		NAND = {
			is_ai = yes
			OR = {
				has_character_flag = converted_culture_this_lifetime
				has_character_flag = converted_culture_this_lifetime_ai
			}
		}
		NOT = { government_has_flag = government_is_landless_minority }
	}

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

	cost = {
		prestige = {
			value = convert_to_local_culture_base_cost
			if = { # Cheaper to convert to a hybrid culture made from your culture
				limit = {
					capital_province.culture = {
						any_parent_culture = {
							this = root.culture
						}
					}
				}
				multiply = 0.5
			}
			
			# Similarities in culture
			if = {
				limit = {
					capital_province.culture = {
						has_same_culture_ethos = root.culture
					}
				}
				multiply = 0.75
			}
			if = {
				limit = {
					capital_province.culture = {
						has_same_culture_heritage = root.culture
					}
				}
				multiply = 0.75
			}
			if = {
				limit = {
					capital_province.culture = {
						has_same_culture_language = root.culture
					}
				}
				multiply = 0.5
			}
			if = {
				limit = {
					NOT = {
						capital_province.culture = {
							has_same_culture_martial_tradition = root.culture
						}
					}
				}
				multiply = 1.25
			}
			if = {
				limit = {
					culture = {
						has_cultural_parameter = expensive_convert_to_local_culture
					}
				}
				multiply = 3
			}
			if = {
				limit = {
					culture = {
						has_cultural_parameter = cheaper_convert_to_local_culture
					}
				}
				multiply = 0.25
			}
			else_if = {
				limit = {
					NOT = {
						government_has_flag = government_is_nomadic
					}
					has_trait = nomadic_philosophy
				}
				multiply = 0.25
			}
			# Account for struggle phase.
			if = {
				limit = { is_struggle_parameter_active_cheaper_to_convert_to_struggle_culture_trigger = yes }
				multiply = 0.25
			}

			# Make sure it's never dumb numbers.
			min = 25
		}
	}

	effect = {
		if = {
			limit = {
				culture = {
					has_cultural_parameter = less_likely_to_culture_convert
				}
				OR = {
					has_trait = compassionate
					has_trait = gregarious
					has_trait = diligent
					has_trait = fickle
					has_trait = humble
					has_trait = trusting
				}
			}
			add_stress = medium_stress_gain
		}
		else_if = {
			limit = {
				culture = {
					has_cultural_parameter = less_likely_to_culture_convert
				}
			}
			add_stress = major_stress_gain
		}
		# Struggle Catalysts
		if = {
			limit = {
				any_character_struggle = {
					involvement = involved
					phase_has_catalyst = catalyst_convert_local_culture_faith
					is_culture_involved_in_struggle = root.capital_province.culture
				}
			}
			every_character_struggle = {
				involvement = involved
				activate_struggle_catalyst = {
					catalyst = catalyst_convert_local_culture_faith
					character = root
				}
			}
		}

		convert_family_culture_and_notify_vassals_effect = {
			CONVERTER = root
			OLD_CULTURE = root.culture
			NEW_CULTURE = capital_province.culture
		}
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	ai_potential = {
		is_playable_character = yes
		culture != capital_province.culture
		is_landless_adventurer = no
	}

	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
			}
		}

		# Reduced chance for every vassal who has your old culture
		modifier = {
			factor = {
				value = 1
				every_vassal = {
					limit = {
						OR = {
							highest_held_title_tier = tier_kingdom
							highest_held_title_tier = tier_duchy
							AND = {
								root = {
									highest_held_title_tier = tier_duchy
								}
								primary_title.tier = tier_county
							}
						}
						culture = root.culture
					}
					add = -0.3
				}
			}
		}
		
		modifier = { # This factor 0 is not misplaced; Loyal Subjects should not culture convert unless it's to a hybrid!
			factor = 0
			top_liege != this
			exists = liege
			culture != liege.culture
			culture = {
				has_cultural_tradition = tradition_loyal_soldiers
			}
		}
		
		modifier = { # You're an independent count that has become landed somewhere, as you can't increase acceptance, it's best to assimilate.
			add = 200
			top_liege = this
			primary_title.tier = tier_county
			domain_size <= 3
			culture = {
				NOR = {
					has_cultural_parameter = easier_to_hybridize # Not for hybrid-loving cultures
					has_cultural_parameter = expensive_convert_to_local_culture # Nor staunch traditionalists
				}
				cultural_acceptance = { target = root.capital_province.culture value < 50 }
			}
		}
		
		modifier = { # Do convert to hybrids of your own culture
			add = 200
			capital_province.culture = {
				is_hybrid_culture = yes
				any_parent_culture = {
					this = root.culture
				}
			}
		}
		
		modifier = { # Farewell, norse culture (unless the player is running a norse empire)
			add = 200
			OR = {
				top_liege = this
				AND = {
					top_liege != this
					NOT = {
						any_liege_or_above = {
							culture = culture:norse
						}
					}
				}
			}
			culture = culture:norse
			capital_province.culture = {
				OR = {
					this = culture:swedish
					this = culture:norwegian
					this = culture:danish
				}
			}
		}

		modifier = { # Iberian Struggle modifiers
			any_character_struggle = {
				involvement = involved
			}
			add = {
				value = 0
				if = {
					limit = {
						any_character_struggle = {
							phase_has_catalyst = catalyst_convert_local_culture_faith
						}
						has_character_flag = agenda_towards_escalation
					}
					add = -300
				}
				else_if = { # Slight boost, so players can't exploit landing lots of characters to bump catalyst progress
					limit = {
						any_character_struggle = {
							phase_has_catalyst = catalyst_convert_local_culture_faith
						}
					}
					add = 20
				}
			}
		}
		
		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
			top_liege != this
			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
			top_liege != this
			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
			top_liege != this
			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 = { has_cultural_pillar = heritage_iberian }
			}
			NOT = {
				capital_province = {
					culture = {
						is_hybrid_culture = yes
						any_parent_culture_or_above = {
							this = root.culture
						}
					}
				}
			}
		}
		modifier = {
			factor = 0
			culture = { has_cultural_pillar = heritage_iberian }
			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
			capital_province = {
				culture = {
					OR = {
						has_cultural_pillar = heritage_byzantine
						has_cultural_pillar = heritage_caucasian
					}
				}
			}
			NOT = {
				capital_province = {
					culture = {
						is_hybrid_culture = yes
						any_parent_culture_or_above = {
							this = root.culture
						}
					}
				}
			}
		}
		modifier = {
			factor = 0
			has_culture = culture:turkish
			primary_title.tier >= tier_empire
		}
		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
					}
				}
			}
			NOR = {
				capital_province = { # Convert to Hybrids of your culture in the Holy Land
					culture = {
						is_hybrid_culture = yes
						any_parent_culture_or_above = {
							this = root.culture
						}
					}
				}
				AND = {
					top_liege != this
					exists = liege
					capital_province.culture = liege.culture
				}
			}
		}
		modifier = {
			factor = 0
			has_title = title:e_latin_empire
			NOT = {
				capital_province = {
					culture = {
						is_hybrid_culture = yes
						any_parent_culture_or_above = {
							this = root.culture
						}
					}
				}
			}
		}

		# 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
		}
		#Some traditions reeeallly don't like doing this
		modifier = {
			factor = 0.1
			culture = {
				OR = {
					has_cultural_parameter = less_likely_to_culture_convert
					has_cultural_parameter = expensive_convert_to_local_culture
				}
			}
		}
	}
}

### Have the Realm Embrace Local Traditions ###
assimilate_local_traditions_decision = {
	picture = {
		reference = "gfx/interface/illustrations/decisions/fp1_decision_raise_runestone.dds"
	}
	sort_order = 75

	desc = assimilate_local_traditions_decision_desc
	selection_tooltip = assimilate_local_traditions_decision_tooltip

	is_shown = {
		culture = culture:norse
		is_landed = yes
		primary_title.tier > tier_barony
		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 = {
		top_liege = this
		is_physically_able_adult = yes
		is_at_war = no
		custom_description = {
			text = can_only_change_culture_once
			NOT = { has_character_flag = converted_culture_this_lifetime }
		}
		capital_province = {
			NOT = {
				geographical_region = world_europe_north
			}
		}
	}

	cost = {
		prestige = {
			value = 300
			if = {
				limit = {
					is_ai = yes
					capital_province = {
						geographical_region = world_europe_east
					}
				}
				multiply = 0
			}
			# Account for struggle phase.
			if = {
				limit = { is_struggle_parameter_active_cheaper_to_convert_to_struggle_culture_trigger = yes }
				multiply = 0.25
			}

			# Make sure it's never dumb numbers.
			min = 25
		}
	}

	effect = {
		norse_assimilate_local_traditions_effect = {
			CONVERTER = root
			OLD_CULTURE = root.culture
			OLD_FAITH = root.faith
			NEW_CULTURE = capital_province.culture
			NEW_FAITH = capital_province.faith
		}
	}
	
	ai_check_interval_by_tier = {
		barony = 0
		county = 60
		duchy = 60
		kingdom = 60
		empire = 60
		hegemony = 60
	}

	ai_potential = {
		culture = culture:norse
		is_playable_character = yes
		culture != capital_province.culture
	}

	ai_will_do = {
		base = 100
		
		# Don't do it too early
		modifier = {
			factor = 0
			NOT = {
				primary_title.title_held_years > 30
			}
		}
		
		# Don't do it if you're zealous
		modifier = {
			factor = 0
			has_trait = zealous
			capital_province.faith != root.faith
		}
		
		# Historical Exceptions
		modifier = {
			add = 100
			capital_province = {
				geographical_region = world_europe_east
			}
		}
	}
}
