decisions = {
	
	convert_to_liege_religion = {
		only_playable = yes
		potential = {
			ai = no
			is_playable = yes
			liege = {
				NOT = { character = ROOT }
				NOT = { religion = ROOT }
				religion_group = ROOT
			}
			controls_religion = no
			NOT = { rightful_religious_head = ROOT }
			NOT = { has_character_flag = converted_religion }
		}
		allow = {
			NOT = { trait = zealous }
		}
		effect = {
			set_character_flag = converted_religion
			piety = -100
			if = {
				limit = { higher_tier_than = BARON }
				religion_authority = {
					modifier = ruler_converted_from
				}
			}
			liege = {
				reverse_religion = ROOT
			}
			add_character_modifier = { name = recently_converted duration = 730}
			if = {
				limit = { higher_tier_than = BARON }
				hidden_tooltip = {
					religion_authority = {
						modifier = ruler_converted_to
					}
				}
			}
			if = {
				limit = { liege = { trait = shaivist_hindu } }
				add_trait = shaivist_hindu
			}
			if = {
				limit = { liege = { trait = vaishnavist_hindu } }
				add_trait = vaishnavist_hindu
			}
			if = {
				limit = { liege = { trait = shaktist_hindu } }
				add_trait = shaktist_hindu
			}
			if = {
				limit = { liege = { trait = smartist_hindu } }
				add_trait = smartist_hindu
			}
			if = {
				limit = { liege = { trait = mahayana_buddhist } }
				add_trait = mahayana_buddhist
			}
			if = {
				limit = { liege = { trait = vajrayana_buddhist } }
				add_trait = vajrayana_buddhist
			}
			if = {
				limit = { liege = { trait = theravada_buddhist } }
				add_trait = theravada_buddhist
			}
			if = {
				limit = { liege = { trait = digambara_jain } }
				add_trait = digambara_jain
			}
			if = {
				limit = { liege = { trait = svetambara_jain } }
				add_trait = svetambara_jain
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	convert_to_liege_culture = {
		only_playable = yes
		potential = {
			is_playable = yes
			is_nomadic = no
			mercenary = no
			liege = {
				NOT = { character = ROOT }
				NOT = { culture = ROOT }
			}
			NOT = { has_character_flag = converted_culture }
		}
		allow = {
			prestige = 100
		}
		effect = {
			liege = {
				save_event_target_as = liege_culture
			}
			prestige = -100
			culture = event_target:liege_culture
			any_courtier = {
				limit = {
					is_ruler = no
					dynasty = ROOT
				}
				culture = event_target:liege_culture
			}
			set_character_flag = converted_culture
			clear_event_target = liege_culture
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	convert_to_parent_religion = {
		only_playable = yes
		potential = {
			is_playable = yes
			is_heretic = yes
			controls_religion = no
			NOT = { rightful_religious_head = ROOT }
			NOT = {
				AND = {
					has_dlc = "Charlemagne"
					has_landed_title = e_byzantium  # May instead renounce iconoclasm
					has_landed_title = c_byzantion
					religion = iconoclast
					is_heresy_of = orthodox
				}
			}
		}
		allow = {
			NOT = { trait = zealous }
			independent = yes
		}
		effect = {
			piety = -100
			if = {
				limit = { higher_tier_than = BARON }
				religion_authority = {
					modifier = ruler_converted_from
				}
			}
			
			abandon_heresy = yes
			add_character_modifier = { name = recently_converted duration = 730}
			set_character_flag = converted_religion
			
			if = {
				limit = { higher_tier_than = BARON }
				hidden_tooltip = {
					religion_authority = {
						modifier = ruler_converted_to
					}
				}
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
	
	# Weak or unreformed religions are allowed to convert to the attacker's religion when under Holy War
	convert_to_attacker_religion = {
		is_high_prio = yes
		only_playable = yes
		ai_check_interval = 6
		
		potential = {
			is_playable = yes
			OR = {
				AND = {
					is_pagan_religion = yes
					is_reformed_pagan_religion = no
					NOT = { religion_authority = 0.4 }
				}
				NOT = { religion_authority = 0.3 }
				religion_group = zoroastrian_group
				religion_group = mesoamerican_group
			}
			controls_religion = no
			NOT = { rightful_religious_head = ROOT }
			war = yes
			any_war = {
				defender = { character = ROOT }
				attacker = {
					NOT = { religion = ROOT }
					religion_authority = 0.5
					OR = {
						is_pagan_religion = no
						is_reformed_pagan_religion = yes
					}
				}
				OR = {
					using_cb = crusade
					using_cb = holy_war
				}
			}
		}
		
		allow = {
			NOT = { trait = zealous }
		}
		
		effect = {
			prestige = -500
			religion_authority = {
				modifier = ruler_converted_from
			}
			
			hidden_tooltip = {
				any_war = {
					limit = {
						defender = { character = ROOT }
						attacker = {
							NOT = { religion = ROOT }
							religion_authority = 0.5
							OR = {
								is_pagan_religion = no
								is_reformed_pagan_religion = yes
							}
						}
						OR = {
							using_cb = crusade
							using_cb = holy_war
						}
					}
					attacker = {
						save_event_target_as = enemy_attacker
					}
				}
			}
			
			if = {
				limit = { event_target:enemy_attacker = { NOT = { religion_group = ROOT } } }
				if = {
					limit = { is_pagan_religion = yes }
					add_trait = sympathy_pagans
				}
				
				if = {
					limit = { religion_group = zoroastrian_group }
					add_trait = sympathy_zoroastrianism
				}
				
				if = {
					limit = { religion_group = christian }
					add_trait = sympathy_christendom
				}
				
				if = {
					limit = { religion_group = muslim }
					add_trait = sympathy_islam
				}
				
				if = {
					limit = { religion_group = jewish_group }
					add_trait = sympathy_judaism
				}
				
				if = {
					limit = { religion_group = indian_group }
					add_trait = sympathy_indian
				}
			}
			
			event_target:enemy_attacker = {
				hidden_tooltip = {
					letter_event = { id = 62800 }
					ROOT = {
						any_courtier = {
							limit = {
								religion = ROOT
								employer = { character = ROOT }
							}
							religion = PREVPREV
						}
						any_vassal = {
							limit = {
								is_playable = no
								religion = ROOT
							}
							religion = PREVPREV
						}
						capital_scope = {
							if = {
								limit = { religion = ROOT }
								religion = PREVPREV
							}
						}
					}
				}
				reverse_religion = ROOT
				add_character_modifier = { name = recently_converted duration = 730}
			}
			
			hidden_tooltip = {
				religion_authority = {
					modifier = ruler_converted_to
				}
			}
			
			piety = 100
		}
		
		
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1
			}
			modifier = {
				factor = 100
				any_war = {
					attacker = {
						any_war = {
							OR = {
								using_cb = crusade
								using_cb = holy_war
							}
						}
						ROOT = { has_prevs_secret_religion_truly_trigger = yes }
					}
				}
			}
			modifier = {
				factor = 0.05
				is_hard_to_convert = yes
			}
			modifier = {
				factor = 0
				NOT = {
					any_war = {
						defender = { character = ROOT }
						attacker = {
							NOT = { religion = ROOT }
							religion_authority = 0.45
							OR = {
								is_pagan_religion = no
								is_reformed_pagan_religion = yes
							}
						}
						OR = {
							using_cb = crusade
							using_cb = holy_war
						}
						war_score = 50
						thirdparty_title_scope = {
							ROOT = {
								primary_title = {
									title = PREVPREV
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 2
				any_war = {
					defender = { character = ROOT }
					attacker = {
						NOT = { religion = ROOT }
						religion_authority = 0.45
						OR = {
							is_pagan_religion = no
							is_reformed_pagan_religion = yes
						}
					}
					OR = {
						using_cb = crusade
						using_cb = holy_war
					}
					war_score = 75
					thirdparty_title_scope = {
						ROOT = {
							primary_title = {
								title = PREVPREV
							}
						}
					}
				}
			}
		}
	}
	
	convert_to_swedish = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			culture = norse
			capital_scope = {
				region = custom_sweden
			}
			any_realm_province = {
				culture = swedish
			}
		}
		allow = {
			culture = norse
		}
		effect = {
			culture = swedish
			any_courtier = {
				limit = {
					culture = norse
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = swedish
			}
		}
		ai_will_do = {
			factor = 1
			
			modifier = { # Do not flip if we're in a huge Norse empire
				factor = 0
				top_liege = { culture = norse }
				OR = {
					top_liege = {
						tier = emperor
					}
					AND = {
						290 = { # Uppland
							owner = {
								same_realm = ROOT
							}
						}
						272 = { # Akershus
							owner = {
								same_realm = ROOT
							}
						}
						266 = { # Sjaelland
							owner = {
								same_realm = ROOT
							}
						}
					}
				}
			}
			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = swedish }
				}
			}
			modifier = {
				factor = 0.1
				capital_scope = {
					NOT = { region = custom_sweden }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = swedish }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = swedish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = swedish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = swedish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = swedish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = swedish
				}
			}
		}
	}

	convert_to_norwegian = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			culture = norse
			capital_scope = {
				region = custom_norway
			}
			any_realm_province = {
				culture = norwegian
			}
		}
		allow = {
			culture = norse
		}
		effect = {
			culture = norwegian
			any_courtier = {
				limit = {
					culture = norse
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = norwegian
			}
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 0.1
				capital_scope = {
					NOT = { region = custom_norway }
				}
			}			
			modifier = { # Do not flip if we're in a huge Norse empire
				factor = 0
				top_liege = { culture = norse }
				290 = { # Uppland
					owner = {
						same_realm = ROOT
					}
				}
				272 = { # Akershus
					owner = {
						same_realm = ROOT
					}
				}
				266 = { # Sjaelland
					owner = {
						same_realm = ROOT
					}
				}
			}
			
			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = norwegian }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = norwegian }
			}
			
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = norwegian
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = norwegian
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = norwegian
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = norwegian
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = norwegian
				}
			}
		}
	}

	convert_to_danish = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			culture = norse
			capital_scope = {
				region = custom_denmark
			}
			any_realm_province = {
				culture = danish
			}
		}
		allow = {
			culture = norse
		}
		effect = {
			culture = danish
			any_courtier = {
				limit = {
					culture = norse
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = danish
			}
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.1
				capital_scope = {
					NOT = { region = custom_denmark }
				}
			}			
			modifier = { # Do not flip if we're in a huge Norse empire
				factor = 0
				top_liege = { culture = norse }
				290 = { # Uppland
					owner = {
						same_realm = ROOT
					}
				}
				272 = { # Akershus
					owner = {
						same_realm = ROOT
					}
				}
				266 = { # Sjaelland
					owner = {
						same_realm = ROOT
					}
				}
			}
			
			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = danish }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = danish }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = danish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = danish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = danish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = danish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = danish
				}
			}
		}
	}

	convert_to_norman = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			culture = norse
			any_realm_province = {
				culture = norman
			}
		}
		allow = {
			culture = norse
		}
		effect = {
			culture = norman
			any_courtier = {
				limit = {
					culture = norse
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = norman
			}
		}
		ai_will_do = {
			factor = 1

			modifier = { # Do not flip if we're in a huge Norse empire
				factor = 0
				top_liege = { culture = norse }
				OR = {
					top_liege = {
						tier = emperor
					}
					AND = {
						290 = { # Uppland
							owner = {
								same_realm = ROOT
							}
						}
						272 = { # Akershus
							owner = {
								same_realm = ROOT
							}
						}
						266 = { # Sjaelland
							owner = {
								same_realm = ROOT
							}
						}
					}
				}
			}
			
			modifier = {
				factor = 1.2
				liege = { culture = norman }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = norman
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = norman
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = norman
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = norman
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = norman
				}
			}
		}
	}
	
	convert_to_reformed = {
		only_playable = yes
		ai_check_interval = 40
		potential = {
			is_playable = yes
			is_heretic = yes
			OR = {
				religion = norse_pagan
				religion = finnish_pagan
				religion = baltic_pagan
				religion = tengri_pagan
				religion = slavic_pagan
				religion = celtic_pagan
				religion = west_african_pagan
			}
		}
		allow = {
			NOT = { trait = zealous }
			piety = 50
		}
		effect = {
			piety = -50
			if = {
				limit = { religion = norse_pagan }
				religion = norse_pagan_reformed
			}
			if = {
				limit = { religion = finnish_pagan }
				religion = finnish_pagan_reformed
			}
			if = {
				limit = { religion = baltic_pagan }
				religion = baltic_pagan_reformed
			}
			if = {
				limit = { religion = tengri_pagan }
				religion = tengri_pagan_reformed
			}
			if = {
				limit = { religion = slavic_pagan }
				religion = slavic_pagan_reformed
			}
			if = {
				limit = { religion = west_african_pagan }
				religion = west_african_pagan_reformed
			}
			if = {
				limit = { religion = celtic_pagan }
				religion = celtic_pagan_reformed
			}
			add_character_modifier = { name = recently_converted duration = 730}
			hidden_tooltip = {
				any_courtier = {
					limit = {
						is_heresy_of = ROOT
						employer = { character = ROOT }
					}
					religion = ROOT
				}
				any_vassal = {
					limit = {
						is_playable = no
						is_heresy_of = ROOT
					}
					religion = ROOT
				}
				capital_scope = {
					if = {
						limit = { is_heresy_of = ROOT }
						religion = ROOT
					}
				}
			}
		}
		ai_will_do = {
			factor = 1 # On average ca 1 year before taken
			modifier = {
				factor = 0.5
				OR = {
					trait = slow
					trait = dull
				}
			}
			modifier = {
				factor = 0.1
				trait = imbecile
			}
			modifier = {
				factor = 0.5
				trait = content
			}
			modifier = {
				factor = 1.5
				OR = {
					trait = quick				
					trait = shrewd
				}
			}
			modifier = {
				factor = 2.0
				trait = quick
			}
			modifier = {
				factor = 4.0
				trait = genius
			}
			modifier = {
				factor = 5.0
				trait = cynical # It's the future..
			}
			modifier = {
				factor = 2.0
				trait = ambitious
			}
			modifier = {
				factor = 0
				independent = no
				any_liege = {
					religion = ROOT
				}
			}
		}
	}
	
	# Carolingian renaissance - Old Frankish conversion to French
	convert_to_french = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			culture = old_frankish
			capital_scope = {
				region = custom_france
				NOR = {
					region = custom_frisia
					region = custom_swabian
					region = custom_austrian
					region = custom_bavarian
					region = custom_colognian
					region = custom_old_saxon
					region = custom_swiss
					region = custom_thuringian
					region = custom_prussian
				}
			}
			any_realm_province = {
				culture = frankish
			}
		}
		allow = {
			culture = old_frankish
		}
		effect = {
			culture = frankish
			any_courtier = {
				limit = {
					culture = old_frankish
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = frankish
			}
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0
				NOT = { year = 800 }
			}
			modifier = {
				factor = 2
				year = 850
			}
			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = frankish }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = frankish }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = frankish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = frankish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = frankish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = frankish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = frankish
				}
			}
		}
	}
	
	# Pictish character may convert to Scottish
	convert_to_scottish = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			culture = pictish
			capital_scope = {
				region = custom_scotland
			}
			any_realm_province = {
				culture = scottish
			}
		}
		allow = {
			culture = pictish
		}
		effect = {
			culture = scottish
			any_courtier = {
				limit = {
					culture = pictish
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = scottish
			}
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = scottish }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = scottish }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = scottish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = scottish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = scottish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = scottish
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = scottish
				}
			}
		}
	}
	
	# Arabic or Visigothic character may convert to Andalusian
	convert_to_andalusian = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			OR = {
				culture = visigothic
				culture_group = arabic
			}
			OR = {
				religion_group = muslim
				top_liege = { religion_group = muslim }
			}
			capital_scope = {
				region = custom_andalusian
			}
			any_realm_province = {
				culture = andalusian_arabic
			}
			NOT = {
				culture = andalusian_arabic
			}
		}
		allow = {
		}
		effect = {
			any_courtier = {
				limit = {
					culture = ROOT
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = andalusian_arabic
			}
			culture = andalusian_arabic
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = andalusian_arabic }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = andalusian_arabic }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = andalusian_arabic
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = andalusian_arabic
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = andalusian_arabic
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = andalusian_arabic
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = andalusian_arabic
				}
			}
		}
	}

	# Visigothic character may convert to Castillan
	convert_to_castillan = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			culture = visigothic
			religion_group = christian
			capital_scope = {
				region = custom_castillian
			}
			any_realm_province = {
				culture = castillan
			}
		}
		allow = {
			culture = visigothic
		}
		effect = {
			any_courtier = {
				limit = {
					culture = ROOT
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = castillan
			}
			culture = castillan
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = castillan }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = castillan }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = castillan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = castillan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = castillan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = castillan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = castillan
				}
			}
		}
	}	

	# Visigothic character may convert to catalan
	convert_to_catalan = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			culture = visigothic
			religion_group = christian
			capital_scope = {
				region = custom_catalan
			}
			any_realm_province = {
				culture = catalan
			}
		}
		allow = {
			culture = visigothic
		}
		effect = {
			any_courtier = {
				limit = {
					culture = ROOT
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = catalan
			}
			culture = catalan
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = catalan }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = catalan }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = catalan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = catalan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = catalan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = catalan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = catalan
				}
			}
		}
	}	

	# Suebi or Visigothic character may convert to Portuguese
	convert_to_portuguese = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			OR = {
				culture = suebi
				culture = visigothic
			}
			religion_group = christian
			capital_scope = {
				region = custom_portuguese
			}
			any_realm_province = {
				culture = portuguese
			}
		}
		allow = {
			OR = {
				culture = suebi
				culture = visigothic
			}
		}
		effect = {
			any_courtier = {
				limit = {
					culture = ROOT
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = portuguese
			}
			culture = portuguese
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = portuguese }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = portuguese }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = portuguese
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = portuguese
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = portuguese
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = portuguese
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = portuguese
				}
			}
		}
	}
	
	# Old Frankish or Old Saxon character may convert to dutch
	convert_to_dutch = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			OR = {
				culture = old_frankish
				culture = old_saxon
				culture = frisian
			}
			capital_scope = {
				region = custom_frisia
			}
			any_realm_province = {
				culture = dutch
			}
		}
		allow = {
			culture = ROOT
		}
		effect = {
			any_courtier = {
				limit = {
					culture = ROOT
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = dutch
			}
			culture = dutch
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = dutch }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = dutch }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = dutch
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = dutch
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = dutch
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = dutch
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = dutch
				}
			}
		}
	}
	
	# longobard character may convert to italian
	convert_to_italian = {
		only_playable = yes
		ai_check_interval = 12
		potential = {
			is_playable = yes
			culture = longobard
			capital_scope = {
				region = world_europe_south_italy
			}
			any_realm_province = {
				culture = italian
			}
			OR = {
				year = 786
				top_liege = {
					NOT = { culture = longobard }
				}
			}
		}
		allow = {
			culture = longobard
			any_realm_province = {
				is_italian_trigger = yes
				OR = {
					region = custom_emilian_cultural_area
					region = custom_veneto_cultural_area
					region = custom_ligurian_cultural_area
					region = custom_lombard_cultural_area
					region = custom_umbrian_cultural_area
					region = custom_neapolitan_cultural_area
					region = custom_tuscan_cultural_area
				}
			}
		}
		effect = {
			if = {
				limit = { location = { region = custom_emilian_cultural_area } }
				culture = emilian
			}
			if = {
				limit = { location = { region = custom_veneto_cultural_area } }
				culture = veneto
			}
			if = {
				limit = { location = { region = custom_ligurian_cultural_area } }
				culture = ligurian
			}
			if = {
				limit = { location = { region = custom_lombard_cultural_area } }
				culture = lombard
			}
			if = {
				limit = { location = { region = custom_umbrian_cultural_area } }
				culture = umbrian
			}
			if = {
				limit = { location = { region = custom_neapolitan_cultural_area } }
				culture = neapolitan
			}
			if = {
				limit = { location = { region = custom_tuscan_cultural_area } }
				culture = tuscan
			}
			any_courtier = {
				limit = {
					culture = longobard
					employer = { character = ROOT }
					dynasty = ROOT
				}
				if = {
					limit = { location = { region = custom_emilian_cultural_area } }
					culture = emilian
				}
				if = {
					limit = { location = { region = custom_veneto_cultural_area } }
					culture = veneto
				}
				if = {
					limit = { location = { region = custom_ligurian_cultural_area } }
					culture = ligurian
				}
				if = {
					limit = { location = { region = custom_lombard_cultural_area } }
					culture = lombard
				}
				if = {
					limit = { location = { region = custom_umbrian_cultural_area } }
					culture = umbrian
				}
				if = {
					limit = { location = { region = custom_neapolitan_cultural_area } }
					culture = neapolitan
				}
				if = {
					limit = { location = { region = custom_tuscan_cultural_area } }
					culture = tuscan
				}
			}
		}
		ai_will_do = {
			factor = 1
			
			modifier = {
				factor = 0
				OR = {
					independent = yes
					top_liege = { culture = longobard }
				}
			}

			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = italian }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = italian }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = italian
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = italian
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = italian
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = italian
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = italian
				}
			}
		}
	}
	
	# Visigothic character may convert to occitan
	convert_to_occitan = {
		only_playable = yes
		ai_check_interval = 6
		potential = {
			is_playable = yes
			culture = visigothic
			religion_group = christian
			capital_scope = {
				OR = {
					region = custom_aquitaine
					region = custom_burgundy
				}
			}
			any_realm_province = {
				culture = occitan
			}
		}
		allow = {
			culture = ROOT
		}
		effect = {
			any_courtier = {
				limit = {
					culture = ROOT
					employer = { character = ROOT }
					dynasty = ROOT
				}
				culture = occitan
			}
			culture = occitan
		}
		ai_will_do = {
			factor = 1

			modifier = {
				factor = 0.01
				capital_scope = {
					NOT = { culture = occitan }
				}
			}
			modifier = {
				factor = 2.0
				liege = { culture = occitan }
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 2
					culture = occitan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 4
					culture = occitan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 6
					culture = occitan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 8
					culture = occitan
				}
			}
			modifier = {
				factor = 1.1
				num_culture_realm_provs = {
					value = 10
					culture = occitan
				}
			}
		}
	}

	# Byzantine Emperor may renounce Iconoclasm
	renounce_iconoclasm = {
		only_playable = yes
		ai_check_interval = 12
		icon_religion = orthodox
		
		potential = {
			is_playable = yes
			religion = iconoclast
			has_landed_title = e_byzantium
			any_vassal = { has_landed_title = d_iconoclast }
			NOT = { has_character_flag = renounced_iconoclasm }
			NOT = { k_papal_state = { has_title_flag = schism_happened } }
			NOT = { year = 900 }
		}
		allow = {
			has_landed_title = e_byzantium
			has_landed_title = c_byzantion
			any_realm_province = { religion = chalcedonian }
			NOT = { trait = zealous }
			war = no
		}
		effect = {
			set_character_flag = renounced_iconoclasm
			religion_authority = {
				modifier = ruler_converted_from
			}
			religion = chalcedonian
			hidden_tooltip = {
				religion_authority = {
					modifier = ruler_converted_to
				}
			}
			if = {
				limit = { capital_scope = { NOT = { religion = chalcedonian } } }
				capital_scope = { religion = chalcedonian }
			}
			custom_tooltip = {
				text = renounce_iconoclasm_muslim_opinion_tooltip
				hidden_tooltip = {
					any_independent_ruler = {
						any_realm_lord = {
							limit = { religion_group = muslim }
							opinion = {
								who = ROOT
								modifier = opinion_idolater
								months = 120
							}
						}
					}
				}
			}
			custom_tooltip = {
				text = renounce_iconoclasm_province_tooltip
				hidden_tooltip = {
					any_realm_province = {
						if = {
							limit = { religion = chalcedonian }
							add_province_modifier = {
								name = appeased_religious
								months = 60
							}
						}
					}
				}
			}
			k_papal_chalcedon = {
				holder_scope = {
					opinion = {
						who = ROOT
						modifier = opinion_renounced_iconoclasm
						months = 120
					}
				}
			}
			hidden_tooltip = {
				any_realm_character = {
					limit = {
						religion = iconoclast
						NOT = { character = ROOT }
						can_change_religion = yes
					}
					character_event = { id = CM.4200 }
				}
			}
			d_iconoclast = {
				holder_scope = {
					unsafe_religion = chalcedonian  # Use this effect with care
					set_defacto_liege = ROOT
					pf_liege_change_effect = yes
				}
				hidden_tooltip = { unsafe_destroy_landed_title = THIS }
			}
			activate_title = { title = d_iconoclast status = no }
		}
		ai_will_do = {
			factor = 1
			modifier = {
				factor = 3
				trait = cynical
			}
		}
	}
	
	convert_indian_branch = {
		potential = {
			ai = no
			is_playable = yes
			is_adult = yes
			is_theocracy = no
			religion_group = indian_group
		}
		allow = {
			NOT = { trait = zealous }
			prestige = 50
			custom_tooltip = {
				text = indian_has_not_converted
				NOT = { has_character_flag = india_branch_converted }
			}
		}
		effect = {
			set_character_flag = india_branch_converted
			prestige = -50
			piety = 25
			if = {
				limit = { religion = hindu }
				character_event = { id = RoI.115 } # Choose branch
			}
			if = {
				limit = { religion = buddhist }
				character_event = { id = RoI.116 } # Choose branch
			}
			if = {
				limit = { religion = jain }
				character_event = { id = RoI.117 } # Confirm conversion
			}
		}
		ai_will_do = {
			factor = 0
		}
	}
}

targeted_decisions = {

	convert_to_spouse_religion= {
		filter = home_court
		ai_target_filter = home_court
		only_playable = yes
	
		from_potential = {
			ai = no
			is_playable = yes
			is_pagan_religion = yes
			controls_religion = no
		}
		
		potential = {
			OR = {
				spouse = {
					character = FROM
				}
				consort = {
					character = FROM
				}
			}
			OR = {
				religion_group = christian
				religion_group = muslim
				religion_group = zoroastrian_group
				religion_group = jewish_group
				religion_group = indian_group
			}
			is_alive = yes
		}
		
		allow = {
			FROM = { NOT = { trait = zealous } }
		}
		
		effect = {
			FROM = {
				prestige = -500
				religion_authority = {
					modifier = ruler_converted_from
				}
			
				if = {
					limit = {
						trait = cynical
					}
					random = {
						chance = 60
						add_trait = sympathy_pagans
					}
				}
				if = {
					limit = {
						NOT = { trait = cynical }
					}
					random = {
						chance = 50
						add_trait = sympathy_pagans
					}
				}		
			
				religion = ROOT
				add_character_modifier = { name = recently_converted duration = 730}
				
				#When spouse is Hindu
				if = {
					limit = {
						ROOT = {
							trait = shaivist_hindu
						}
					}
					add_trait = shaivist_hindu
				}
				if = {
					limit = {
						ROOT = {
							trait = vaishnavist_hindu
						}
					}
					add_trait = vaishnavist_hindu
				}
				if = {
					limit = {
						ROOT = {
							trait = shaktist_hindu
						}
					}
					add_trait = shaktist_hindu
				}
				if = {
					limit = {
						ROOT = {
							trait = smartist_hindu
						}
					}
					add_trait = smartist_hindu
				}
				
				#When spouse is Buddhist
				if = {
					limit = {
						ROOT = {
							trait = mahayana_buddhist
						}
					}
					add_trait = mahayana_buddhist
				}
				if = {
					limit = {
						ROOT = {
							trait = vajrayana_buddhist
						}
					}
					add_trait = vajrayana_buddhist
				}
				if = {
					limit = {
						ROOT = {
							trait = theravada_buddhist
						}
					}
					add_trait = theravada_buddhist
				}
				
				#When spouse is Jain
				if = {
					limit = {
						ROOT = {
							trait = digambara_jain
						}
					}
					add_trait = digambara_jain
				}
				if = {
					limit = {
						ROOT = {
							trait = svetambara_jain
						}
					}
					add_trait = svetambara_jain
				}
				
				hidden_tooltip = {
					religion_authority = {
						modifier = ruler_converted_to
					}
				}
				piety = 200
			}
		}
		
		
		ai_will_do = {
			factor = 0
		}
	}
}