###########################################
#
# Heresy Events - Sons of Abraham
#
# ID SoA 4000-4999 is reserved
#
###########################################
# Written by Henrik Fåhraeus
###########################################

namespace = SoA
namespace = PerformanceSoA

###################################################
# Heresy Appears in Province
###################################################

# Heresy Appears in Province
province_event = {
	id = SoA.4000
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	desc = {
		text = EVTDESC39000
		trigger = { is_heretic = yes }
	}
	desc = {
		text = EVTDESC39000_B
		trigger = { is_heretic = no }
	}
	
	trigger = {
		has_dlc = "Sons of Abraham"
		
		is_heretic = no
		
		has_heresies = yes
		
		# Heretic top lieges must spread the faith themselves
		owner = {
			top_liege = {
				NOT = { is_heresy_of = ROOT }
			}
		}
		
		num_of_settlements = 1
		any_province_holding = {
			NOT = { holding_type = nomad }
		}
		
		NOT = { religion_authority = 0.9 }
		
		e_placeholder = { had_title_flag = { flag = startup days = 1095 } }
	}
	
	mean_time_to_happen = {
		months = 9600 # 800 years
		modifier = {
			factor = 1.5
			religion = chalcedonian
			NOT = { year = 1000 }
		}
		modifier = {
			factor = 1.5
			NOT = { year = 900 }
		}
		modifier = {
			factor = 1.5
			NOT = { year = 800 }
		}
		modifier = {
			factor = 1.5
			religion_authority = 0.6
		}
		modifier = {
			factor = 1.5
			religion_authority = 0.7
		}
		modifier = {
			factor = 1.5
			religion_authority = 0.8
		}
		modifier = {
			factor = 2.0
			religion_authority = 0.9
		}
		modifier = {
			factor = 3.0
			OR = {
				province_id = 333 # Rome
				province_id = 497 # Thrace
				province_id = 719 # Mecca
			}
		}
		modifier = {
			factor = 0.5
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.3 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.5 }
		}
		
		modifier = {
			factor = 0.5
			any_neighbor_province = {
				is_land = yes
				is_heresy_of = ROOT
			}
		}
		modifier = {
			factor = 0.25
			any_neighbor_province = {
				is_land = yes
				is_heresy_of = ROOT
				has_province_modifier = heretic_stronghold
			}
		}
	}
	
	immediate = {
		heresy_province_effect = yes
		# Two years of much higher revolt risk
		add_province_modifier = {
			name = religious_unrest
			duration = 730
		}
		# One heretic province in the realm is the epicentre of the heresy
		if = {
			limit = {
				is_heretic = yes
				owner = {
					top_liege = {
						NOT = {
							any_realm_province = {
								religion = ROOT
								has_province_modifier = heretic_stronghold
							}
						}
					}
				}
			}
			add_province_modifier = {
				name = heretic_stronghold # Ten years of even higher revolt risk
				duration = 3650
			}
		}
		# Notify the lieges
		hidden_tooltip = {
			owner = {
				any_liege = {
					limit = { NOT = { character = PREV } }
					character_event = { id = 39400 }
				}
			}
			owner = {
				if = {
					limit = { ai = no }
					chronicle = {
						entry = CHRONICLE_HERESY_SPREAD
						picture = GFX_evt_heretic
					}
				}
			}
			owner = {
				any_liege = {
					if = {
						limit = { ai = no }
						chronicle = {
							entry = CHRONICLE_HERESY_SPREAD
							picture = GFX_evt_heretic
						}
					}
				}
			}
		}		
	}
	
	option = {
		name = {
			text = EVTOPTA39000 # The owner is of the parent religion
			trigger = { owner = { is_parent_religion = ROOT } }
		}
		ai_chance = {
			factor = 95
		}
	}
	option = {
		name = {
			text = EVTOPTB39000 # The owner is of the same heresy
			trigger = { owner = { religion = ROOT } }
		}
		ai_chance = {
			factor = 95
		}
	}
	option = {
		name = {
			text = EVTOPTC_SOA_4000 # The owner is of some other religion
			trigger = {
				owner = {
					NOT = { religion = ROOT }
					NOT = { is_parent_religion = ROOT }
				}
			}
		}
		ai_chance = {
			factor = 95
		}
	}
	option = {
		name = EVTOPTD_SOA_4000 #  The owner is of the parent religion and interested in the heresy
		trigger = {
			owner = { is_parent_religion = ROOT }
		}
		
		owner = {
			piety = -250
			set_secret_religion = { target_type = public target = ROOT }
			any_spouse = {
				limit = {
					ai = yes
					has_secret_religion = no
				}
				set_secret_religion = { target_type = public target = ROOT }
			}
			any_child = {
				limit = {
					ai = yes
					has_secret_religion = no
				}
				set_secret_religion = { target_type = public target = ROOT }
			}
		}
		
		ai_chance = {
        	factor = 5
        	modifier = {
        		factor = 0
				owner = {
					trait = zealous 
				}
        	}
        	modifier = {
        		factor = 2
				owner = {
					trait = cynical 
				}
        	}
        }
	}
}

###################################################
# Character picks up province religion
###################################################

# SoA.4020 - Character picks up province religion, if it's in the same religion group but not the top liege's religion
#	- Notify liege: SoA 4021

# Character converts to local religion
character_event = {
	id = SoA.4020
	desc = EVTDESC_SOA_4020
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		has_dlc = "Sons of Abraham"
		
		NOR = {
			trait = zealous
			is_inaccessible_trigger = yes
			trait = shiite_claimant
			father = { trait = shiite_claimant }
			any_sibling = { trait = shiite_claimant }
		}
	
		is_heretic = no # Heretics, already people of strong conviction, never change religion spontaneously
		
		OR = {
			is_ruler = no
			is_theocracy = no
		}
		
		can_change_religion = yes
		controls_religion = no
		NOT = { rightful_religious_head = ROOT }
		
		NOT = { religion_authority = 0.9 }
		
		location = {
			OR = {
				religion_group = ROOT
				religion = manichean
			}
			NOT = { religion = ROOT }
			is_pagan_religion = no
			OR = {
				is_heretic = yes
				religion_authority = ROOT # The local religion has at least the same authority as my religion
			}
		}
	}

	immediate = {
		location = { save_event_target_as = local_religion }
	}
	option = {
		name = EVTOPTA_SOA_4020
		ai_chance = { factor = 100 }
		
		hidden_tooltip = {
			if = {
				limit = {
					independent = no
					liege = {
						religion = ROOT
					}
				}
				liege = {
					character_event = { id = SoA.4021 days = 3 }
				}
			}
		}
		
		religion = event_target:local_religion
		hidden_tooltip = {
			if = {
				limit = { religion_group = indian_group }
				set_character_flag = india_converted
				character_event = { id = RoI.30120 } # Set religious branch randomly
			}
		}
	}
	option = {
		name = EVTOPTB_SOA_4020
		ai_chance = { factor = 0 }
	}
}

# SoA.4021 - Liege response
character_event = {
	id = SoA.4021
	desc = EVTDESC_SOA_4021
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = { # Convince him to convert
		name = EVTOPTD_SOA_4021
		trigger = { piety = 0 }
		ai_chance = {
			factor = 100
			modifier = {
				factor = 1.5
				trait = kind
			}
			modifier = {
				factor = 1.5
				trait = patient
			}
			modifier = {
				factor = 1.5
				trait = gregarious
			}
			modifier = {
				factor = 1.25
				trait = charitable
			}
			modifier = {
				factor = 0.75
				trait = shy
			}
			modifier = {
				factor = 0.75
				trait = slothful
			}
			modifier = {
				factor = 0.5
				NOT = { diplomacy = 8 }
			}
			modifier = {
				factor = 2.0
				OR = {
					diplomacy = 15
					trait = socializer
					trait = poet
				}
			}
		}
		if = {
			limit = { FROM = { is_ruler = no } }
			piety = -10
		}
		if = {
			limit = { FROM = { is_ruler = yes } }
			piety = -50
		}
		FROM = {
			character_event = { id = GoPagan.131 days = 7 tooltip = CONVINCE_CONVERSION }
			custom_tooltip = { text = CONVERSION_START }
			custom_tooltip = { text = CONVERSION_BASE_DIPLOMACY }
			if = {
				limit = {
					OR = {
						AND = {
							trait = sympathy_christendom
							ROOT = { religion_group = christian }
						}
						AND = {
							trait = sympathy_islam
							ROOT = { religion_group = muslim }
						}
						AND = {
							trait = sympathy_pagans
							ROOT = { is_pagan_religion = yes }
						}
						AND = {
							trait = sympathy_zoroastrianism
							ROOT = { religion_group = zoroastrian_group }
						}
						AND = {
							trait = sympathy_judaism
							ROOT = { religion_group = jewish_group }
						}
						AND = {
							trait = sympathy_indian
							ROOT = { religion_group = indian_group }
						}
					}
				}
				custom_tooltip = { text = CONVERSION_SYMPATHY }
			}
			if = {
				limit = {
					culture_group = east_slavic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = orthodox
							religion = bogomilist
							religion = monothelite
							religion = iconoclast
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_3 }
			}
			if = {
				limit = {
					culture_group = north_germanic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = catholic
							religion = cathar
							religion = fraticelli
							religion = waldensian
							religion = lollard
							religion = adoptionist
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_3 }
			}
			if = {
				limit = {
					culture_group = baltic
					is_pagan_religion = yes
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_4 }
			}
			if = {
				limit = {
					OR = {
						culture_group = north_germanic
						culture_group = east_slavic
					}
					is_pagan_religion = yes
					ROOT = { religion_group = muslim }
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_4 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					is_reformed_pagan_religion = no
					ROOT = { is_pagan_religion = no }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_2 }
			}
			if = {
				limit = {
					religion_group = jewish_group
					ROOT = { NOT = { religion_group = jewish_group } }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_4 }
			}
			if = {
				limit = {
					OR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_4 }
			}
			if = {
				limit = {
					religion_group = muslim
					ROOT = { religion_group = muslim }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_3 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					ROOT = { is_pagan_religion = yes }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_3 }
			}
			if = {
				limit = {
					religion_group = ROOT
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
						is_pagan_religion = yes
						religion_group = muslim
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_1 }
			}
			if = {
				limit = {
					NOT = { opinion = { who = ROOT value = 0 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_4 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 0 }
					NOT = { opinion = { who = ROOT value = 25 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_3 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 25 }
					NOT = { opinion = { who = ROOT value = 50 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_1 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 50 }
					NOT = { opinion = { who = ROOT value = 75 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_2 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 75 }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_3 }
			}
			if = {
				limit = {
					OR = {
						AND = {
							is_ruler = no
							OR = {
								is_married = ROOT
								any_spouse = { is_father = ROOT }
								any_spouse = { is_mother = ROOT }
								any_spouse = { is_child_of = ROOT }
							}
						}
						OR = {
							is_close_relative = ROOT
							is_lover = ROOT
						}
					}
					OR = {
						NOT = {
							AND = {
								is_ruler = no
								OR = {
									is_married = ROOT
									any_spouse = { is_father = ROOT }
									any_spouse = { is_mother = ROOT }
									any_spouse = { is_child_of = ROOT }
								}
							}
						}
						NOR = {
							is_close_relative = ROOT
							is_lover = ROOT
						}
					}
				}
				custom_tooltip = { text = CONVERSION_RELATION_GOOD_2 }
			}
			if = {
				limit = {
					is_ruler = no
					OR = {
						is_married = ROOT
						any_spouse = { is_father = ROOT }
						any_spouse = { is_mother = ROOT }
						any_spouse = { is_child_of = ROOT }
					}
					OR = {
						is_close_relative = ROOT
						is_lover = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELATION_GOOD_3 }
			}
			if = {
				limit = { trait = cynical }
				custom_tooltip = { text = CONVERSION_CYNICAL_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					NOT = { religion_authority = 0.1 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.1
					NOT = { religion_authority = 0.25 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.25
					NOT = { religion_authority = 0.4 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.6
					NOT = { religion_authority = 0.75 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.75
					NOT = { religion_authority = 0.9 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.9
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_3 }
			}
			if = {
				limit = {
					ROOT = { diplomacy = 12 }
					ROOT = { NOT = { diplomacy = 16 } }
				}
				custom_tooltip = { text = CONVERSION_DIPLOMACY_GOOD_1 }
			}
			if = {
				limit = {
					ROOT = { diplomacy = 16 }
				}
				custom_tooltip = { text = CONVERSION_DIPLOMACY_GOOD_2 }
			}
		}
	}
	option = { # Debate for reconversion
		name = EVTOPTC_SOA_4021
		tooltip_info = learning
		trigger = {
			learning = 8
			piety = 0
		}
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2
				is_priest = yes
			}
			modifier = {
				factor = 1.2
				learning = 10
			}
			modifier = {
				factor = 1.2
				learning = 12
			}
			modifier = {
				factor = 1.2
				learning = 14
			}
			modifier = {
				factor = 1.2
				learning = 16
			}
			modifier = {
				factor = 1.2
				learning = 18
			}
			modifier = {
				factor = 1.2
				learning = 20
			}
			modifier = {
				factor = 1.5
				trait = zealous
			}
			modifier = {
				factor = 0.75
				trait = slothful
			}
			modifier = {
				factor = 2.0
				OR = {
					trait = scholar
					trait = theologian
					trait = faqih
				}
			}
		}
		if = {
			limit = { FROM = { is_ruler = no } }
			piety = -10
		}
		if = {
			limit = { FROM = { is_ruler = yes } }
			piety = -50
		}
		FROM = {
			character_event = { id = GoPagan.135 tooltip = DEBATE_CONVERSION }
			custom_tooltip = { text = CONVERSION_START }
			custom_tooltip = { text = CONVERSION_BASE_DEBATE }
			if = {
				limit = {
					OR = {
						AND = {
							trait = sympathy_christendom
							ROOT = { religion_group = christian }
						}
						AND = {
							trait = sympathy_islam
							ROOT = { religion_group = muslim }
						}
						AND = {
							trait = sympathy_pagans
							ROOT = { is_pagan_religion = yes }
						}
						AND = {
							trait = sympathy_zoroastrianism
							ROOT = { religion_group = zoroastrian_group }
						}
						AND = {
							trait = sympathy_judaism
							ROOT = { religion_group = jewish_group }
						}
						AND = {
							trait = sympathy_indian
							ROOT = { religion_group = indian_group }
						}
					}
				}
				custom_tooltip = { text = CONVERSION_SYMPATHY }
			}
			if = {
				limit = {
					culture_group = east_slavic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = orthodox
							religion = bogomilist
							religion = monothelite
							religion = iconoclast
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_2 }
			}
			if = {
				limit = {
					culture_group = north_germanic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = catholic
							religion = cathar
							religion = fraticelli
							religion = waldensian
							religion = lollard
							religion = adoptionist
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_2 }
			}
			if = {
				limit = {
					culture_group = baltic
					is_pagan_religion = yes
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_3 }
			}
			if = {
				limit = {
					OR = {
						culture_group = north_germanic
						culture_group = east_slavic
					}
					is_pagan_religion = yes
					ROOT = { religion_group = muslim }
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_3 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					is_reformed_pagan_religion = no
					ROOT = { is_pagan_religion = no }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_1 }
			}
			if = {
				limit = {
					religion_group = jewish_group
					ROOT = { NOT = { religion_group = jewish_group } }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_3 }
			}
			if = {
				limit = {
					OR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					religion_group = muslim
					ROOT = { religion_group = muslim }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					ROOT = { is_pagan_religion = yes }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					religion_group = ROOT
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
						is_pagan_religion = yes
						religion_group = muslim
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_2 }
			}
			if = {
				limit = {
					NOT = { opinion = { who = ROOT value = -25 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_4 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = -25 }
					NOT = { opinion = { who = ROOT value = 0 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_3 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 25 }
					NOT = { opinion = { who = ROOT value = 50 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_1 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 50 }
					NOT = { opinion = { who = ROOT value = 75 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_2 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 75 }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_3 }
			}
			if = {
				limit = { trait = cynical }
				custom_tooltip = { text = CONVERSION_CYNICAL_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					NOT = { religion_authority = 0.1 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.1
					NOT = { religion_authority = 0.25 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.25
					NOT = { religion_authority = 0.4 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.6
					NOT = { religion_authority = 0.75 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.75
					NOT = { religion_authority = 0.9 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.9
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_3 }
			}
			if = {
				limit = {
					ROOT = { attribute_diff = { character = FROM attribute = learning value = 1 } }
					NOT = { ROOT = { attribute_diff = { character = FROM attribute = learning value = 5 } } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_GOOD_1 }
			}
			if = {
				limit = {
					ROOT = { attribute_diff = { character = FROM attribute = learning value = 5 } }
					NOT = { ROOT = { attribute_diff = { character = FROM attribute = learning value = 9 } } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_GOOD_2 }
			}
			if = {
				limit = {
					ROOT = { attribute_diff = { character = FROM attribute = learning value = 9 } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_GOOD_3 }
			}
			if = {
				limit = {
					attribute_diff = { character = ROOT attribute = learning value = 1 }
					NOT = { attribute_diff = { character = ROOT attribute = learning value = 5 } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_BAD_1 }
			}
			if = {
				limit = {
					attribute_diff = { character = ROOT attribute = learning value = 5 }
					NOT = { attribute_diff = { character = ROOT attribute = learning value = 9 } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_BAD_2 }
			}
			if = {
				limit = {
					attribute_diff = { character = ROOT attribute = learning value = 9 }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_BAD_3 }
			}
			if = {
				limit = {
					ROOT = { NOT = { trait = zealous } }
					reverse_opinion = { who = ROOT value = 0 }
					attribute_diff = { character = ROOT attribute = learning value = 1 }
					NOR = {
						religion_group = ROOT
						AND = {
							ROOT = { trait = sympathy_christendom }
							religion_group = christian
						}
						AND = {
							ROOT = { trait = sympathy_islam }
							religion_group = muslim
						}
						AND = {
							ROOT = { trait = sympathy_pagans }
							is_pagan_religion = yes
						}
						AND = {
							ROOT = { trait = sympathy_zoroastrianism }
							religion_group = zoroastrian_group
						}
						AND = {
							ROOT = { trait = sympathy_judaism }
							religion_group = jewish_group
						}
						AND = {
							ROOT = { trait = sympathy_indian }
							religion_group = indian_group
						}
					}
				}
				custom_tooltip = { text = CONVERSION_CHANCE_SYMP }
			}
		}
	}
	option = { # Threaten unless he converts
		name = EVTOPTA_SOA_4021
		trigger = {
			OR = {
				AND = {
					is_tribal = no
					crownlaw_title = {
						OR = {
							has_law = crown_authority_2
							has_law = crown_authority_3
							has_law = crown_authority_4
						}
					}
				}
				AND = {
					is_tribal = yes
					primary_title = {
						OR = {
							has_law = tribal_organization_2
							has_law = tribal_organization_3
							has_law = tribal_organization_4
						}
					}
				}
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				OR = {
					is_friend = FROM
					AND = {
						trait = sympathy_christendom
						FROM = { religion_group = christian }
					}
					AND = {
						trait = sympathy_islam
						FROM = { religion_group = muslim }
					}
					AND = {
						trait = sympathy_pagans
						FROM = { is_pagan_religion = yes }
					}
					AND = {
						trait = sympathy_zoroastrianism
						FROM = { religion_group = zoroastrian_group }
					}
					AND = {
						trait = sympathy_judaism
						FROM = { religion_group = jewish_group }
					}
					AND = {
						trait = sympathy_indian
						FROM = { religion_group = indian_group }
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					trait = kind
					trait = just
					trait = humble
				}
			}
			modifier = {
				factor = 0
				NOR = {
					trait = wroth
					trait = proud
					trait = cruel
					trait = arbitrary
					trait = zealous
					trait = impaler
				}
			}
			modifier = {
				factor = 0.5
				is_close_relative = FROM
			}
			modifier = {
				factor = 2
				trait = wroth
			}
			modifier = {
				factor = 2
				trait = cruel
			}
			modifier = {
				factor = 2
				trait = impaler
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.5
				trait = arbitrary
			}
			modifier = {
				factor = 1.5
				trait = paranoid
			}
			modifier = {
				factor = 0.5
				trait = patient
			}
			modifier = {
				factor = 0.5
				trait = charitable
			}
			modifier = {
				factor = 0.5
				reverse_opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 0.5
				reverse_opinion = { who = FROM value = 75 }
			}
			modifier = {
				factor = 1.5
				NOT = { reverse_opinion = { who = FROM value = 25 } }
			}
			modifier = {
				factor = 1.5
				NOT = { reverse_opinion = { who = FROM value = 0 } }
			}
			modifier = {
				factor = 0.8
				OR = {
					trait = tyrant1
					trait = tyrant2
					trait = tyrant3
				}
			}
			modifier = {
				factor = 0.8
				OR = {
					trait = tyrant4
					trait = tyrant5
					trait = tyrant6
				}
			}
			modifier = {
				factor = 0.8
				OR = {
					trait = tyrant7
					trait = tyrant8
					trait = tyrant9
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					trait = tyrant10
					trait = tyrant11
					trait = tyrant12
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					trait = tyrant13
					trait = tyrant14
					trait = tyrant15
				}
			}
			modifier = {
				factor = 0
				OR = {
					trait = tyrant16
					trait = tyrant17
					trait = tyrant18
					trait = tyrant19
				}
			}
		}
		tyrant_plus_1_effect = yes
		if = {
			limit = { FROM = { is_ruler = no } }
			piety = -10
		}
		if = {
			limit = { FROM = { is_ruler = yes } }
			piety = -50
		}
		FROM = {
			character_event = { id = GoPagan.143 days = 7 tooltip = THREATEN_CONVERSION }
			custom_tooltip = { text = CONVERSION_START }
			custom_tooltip = { text = CONVERSION_BASE_THREAT }
			if = {
				limit = {
					OR = {
						AND = {
							trait = sympathy_christendom
							ROOT = { religion_group = christian }
						}
						AND = {
							trait = sympathy_islam
							ROOT = { religion_group = muslim }
						}
						AND = {
							trait = sympathy_pagans
							ROOT = { is_pagan_religion = yes }
						}
						AND = {
							trait = sympathy_zoroastrianism
							ROOT = { religion_group = zoroastrian_group }
						}
						AND = {
							trait = sympathy_judaism
							ROOT = { religion_group = jewish_group }
						}
						AND = {
							trait = sympathy_indian
							ROOT = { religion_group = indian_group }
						}
					}
				}
				custom_tooltip = { text = CONVERSION_SYMPATHY }
			}
			if = {
				limit = {
					religion_group = jewish_group
					ROOT = { NOT = { religion_group = jewish_group } }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_4 }
			}
			if = {
				limit = {
					OR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					is_ruler = yes
				}
				custom_tooltip = { text = CONVERSION_RULER_BAD_2 }
			}
			if = {
				limit = {
					is_priest = yes
				}
				custom_tooltip = { text = CONVERSION_PRIEST_BAD_2 }
			}
			if = {
				limit = { trait = cynical }
				custom_tooltip = { text = CONVERSION_CYNICAL_GOOD_3 }
			}
			if = {
				limit = { trait = craven }
				custom_tooltip = { text = CONVERSION_CRAVEN_GOOD_3 }
			}
			if = {
				limit = { trait = brave }
				custom_tooltip = { text = CONVERSION_BRAVE_BAD_3 }
			}
			if = {
				limit = { trait = humble }
				custom_tooltip = { text = CONVERSION_HUMBLE_GOOD_1 }
			}
			if = {
				limit = { trait = content }
				custom_tooltip = { text = CONVERSION_CONTENT_GOOD_1 }
			}
			if = {
				limit = { trait = proud }
				custom_tooltip = { text = CONVERSION_PROUD_BAD_1 }
			}
			if = {
				limit = { trait = wroth }
				custom_tooltip = { text = CONVERSION_WROTH_BAD_1 }
			}
			if = {
				limit = {
					NOT = { opinion = { who = ROOT value = -75 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_4 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = -75 }
					NOT = { opinion = { who = ROOT value = -50 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_3 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = -50 }
					NOT = { opinion = { who = ROOT value = -25 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_2 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = -25 }
					NOT = { opinion = { who = ROOT value = 0 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_1 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 0 }
					NOT = { opinion = { who = ROOT value = 25 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_1 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 25 }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_2 }
			}
			if = {
				limit = {
					ROOT = {
						OR = {
							AND = {
								is_tribal = no
								crownlaw_title = { has_law = crown_authority_3 }
							}
							AND = {
								is_tribal = yes
								primary_title = { has_law = tribal_organization_3 }
							}
						}
					}
				}
				custom_tooltip = { text = CONVERSION_AUTHORITY_GOOD_1 }
			}
			if = {
				limit = {
					ROOT = {
						OR = {
							AND = {
								is_tribal = no
								crownlaw_title = { has_law = crown_authority_4 }
							}
							AND = {
								is_tribal = yes
								primary_title = { has_law = tribal_organization_4 }
							}
						}
					}
				}
				custom_tooltip = { text = CONVERSION_AUTHORITY_GOOD_2 }
			}
			custom_tooltip = { text = IMPRISON_IF_REFUSE }
		}
	}
	option = { # Let it slide
		name = EVTOPTB_SOA_4021
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2
				trait = patient
			}
			modifier = {
				factor = 2
				trait = just
			}
			modifier = {
				factor = 0.5
				trait = cruel
			}
			modifier = {
				factor = 0.5
				trait = arbitrary
			}
			modifier = {
				factor = 10
				OR = {
					trait = kind
					is_friend = FROM
					AND = {
						trait = sympathy_christendom
						FROM = { religion_group = christian }
					}
					AND = {
						trait = sympathy_islam
						FROM = { religion_group = muslim }
					}
					AND = {
						trait = sympathy_pagans
						FROM = { is_pagan_religion = yes }
					}
					AND = {
						trait = sympathy_zoroastrianism
						FROM = { religion_group = zoroastrian_group }
					}
					AND = {
						trait = sympathy_judaism
						FROM = { religion_group = jewish_group }
					}
					AND = {
						trait = sympathy_indian
						FROM = { religion_group = indian_group }
					}
				}
			}
		}
	}
}

#######################################################################
# Courtier attempts to convert another character at court
#######################################################################

# SoA.4030 - Courtier attempts to convert another character at court (bounce event)
character_event = {
	id = SoA.4030

	hide_window = yes
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			character_event = { id = SoA.4031 }
		}
	}
}

# SoA.4031 - Character is approached about conversion
character_event = {
	id = SoA.4031
	desc = EVTDESC_SOA_4031
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		add_character_modifier = {
			name = conversion_attempt_timer
			duration = 1825
			hidden = yes
		}
	}
	
	option = { # Accept
		name = EVTOPTA_SOA_4031
		trigger = {
			OR = {
				religion_group = FROM
				AND = {
					trait = sympathy_christendom
					FROM = { religion_group = christian }
				}
				AND = {
					trait = sympathy_islam
					FROM = { religion_group = muslim }
				}
				AND = {
					trait = sympathy_pagans
					FROM = { is_pagan_religion = yes }
				}
				AND = {
					trait = sympathy_zoroastrianism
					FROM = { religion_group = zoroastrian_group }
				}
				AND = {
					trait = sympathy_judaism
					FROM = { religion_group = jewish_group }
				}
				AND = {
					trait = sympathy_indian
					FROM = { religion_group = indian_group }
				}
			}
		}
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0.5
				is_ruler = yes
				OR = {
					independent = yes
					liege = { NOT = { religion = FROM } }
				}
			}
			modifier = {
				factor = 0
				#My secret religion doesn't match requesters religion
				has_secret_religion_trait_trigger = yes
				FROM = {
					is_openly_of_prevs_secret_religion_trigger = no
				}
			}
			modifier = {
				factor = 0
				is_ruler = yes
				NOT = { religion_group = muslim }
				is_pagan_religion = no
				FROM = {
					NOR = {
						religion_group = ROOT
						religion = jewish
					}
				}
				location = {
					NOT = { religion = FROM }
				}
			}
			modifier = {
				factor = 0
				is_ruler = yes
				religion_group = muslim
				FROM = {
					NOR = {
						religion_group = ROOT
						religion = jewish
						religion = zoroastrian
					}
				}
				location = {
					NOT = { religion = FROM }
				}
			}
			modifier = {
				factor = 3
				culture_group = east_slavic
				is_pagan_religion = yes
				FROM = {
					OR = {
						religion = chalcedonian
						religion = orthodox
						religion = bogomilist
						religion = monothelite
						religion = iconoclast
					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 3
				culture_group = north_germanic
				is_pagan_religion = yes
				FROM = {
					OR = {
						religion = chalcedonian
 						religion = catholic
						religion = cathar
						religion = fraticelli
						religion = waldensian
						religion = lollard
						religion = adoptionist
 					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 0.1
				is_heretic = yes
			}
			modifier = {
				factor = 0.1
				culture_group = baltic
				is_pagan_religion = yes
			}
			modifier = {
				factor = 0.1
				OR = {
					culture_group = north_germanic
					culture_group = east_slavic
				}
				is_pagan_religion = yes
				FROM = { religion_group = muslim }
			}
			modifier = {
				factor = 2
				is_pagan_religion = yes
				is_reformed_pagan_religion = no
				FROM = {
					OR = {
						is_pagan_religion = no
						is_reformed_pagan_religion = yes
					}
				}
			}
			modifier = {
				factor = 0.5
				is_ruler = no
				liege = { NOT = { religion = FROM } }
			}
			modifier = {
				factor = 1.5
				is_ruler = no
				liege = { religion = FROM }
			}
			modifier = {
				factor = 1.25
				location = { religion = FROM }
			}
			modifier = {
				factor = 0.5
				OR = {
					NOT = { religion_group = FROM }
					AND = {
						religion_group = muslim
						FROM = { religion_group = muslim }
						FROM = { is_heretic = no }
					}
					AND = {
						is_pagan_religion = yes
						FROM = { is_pagan_religion = yes }
						FROM = { is_heretic = no }
					}
				}
			}
			modifier = {
				factor = 0.1
				religion_group = jewish_group
				FROM = { NOT = { religion_group = jewish_group } }
			}
			modifier = {
				factor = 0.1
				NOT = { personal_opinion = { who = FROM value = 0 } }
			}
			modifier = {
				factor = 1.5
				personal_opinion = { who = FROM value = 25 }
			}
			modifier = {
				factor = 1.5
				personal_opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 1.5
				personal_opinion = { who = FROM value = 75 }
			}
			modifier = {
				factor = 2.0
				trait = cynical
			}
			modifier = {
				factor = 2.0
				trait = excommunicated
			}
			modifier = {
				factor = 1.25
				NOT = { religion_authority = 0.4 }
			}
			modifier = {
				factor = 1.25
				NOT = { religion_authority = 0.3 }
			}
			modifier = {
				factor = 1.25
				NOT = { religion_authority = 0.2 }
			}
			modifier = {
				factor = 1.25
				NOT = { religion_authority = 0.1 }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 16 }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 18 }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 20 }
			}
			modifier = {
				factor = 10
				FROM = {
					is_openly_of_prevs_secret_religion_trigger = yes
				}
			}
		}
		if = {
			limit = {
				trait = sympathy_christendom
				FROM = { religion_group = christian }
			}
			remove_trait = sympathy_christendom
		}
		if = {
			limit = {
				trait = sympathy_islam
				FROM = { religion_group = muslim }
			}
			remove_trait = sympathy_islam
		}
		if = {
			limit = {
				trait = sympathy_pagans
				FROM = { is_pagan_religion = yes }
			}
			remove_trait = sympathy_pagans
		}
		if = {
			limit = {
				trait = sympathy_zoroastrianism
				FROM = { religion_group = zoroastrian_group }
			}
			remove_trait = sympathy_zoroastrianism
		}
		if = {
			limit = {
				trait = sympathy_judaism
				FROM = { religion_group = jewish_group }
			}
			remove_trait = sympathy_judaism
		}
		if = {
			limit = {
				trait = sympathy_indian
				FROM = { religion_group = indian_group }
			}
			remove_trait = sympathy_indian
		}
		if = {
			limit = {
				religion_group = christian
				FROM = { NOT = { religion_group = christian } }
			}
			random = {
				chance = 50
				add_trait = sympathy_christendom
			}
		}
		if = {
			limit = {
				religion_group = muslim
				FROM = { NOT = { religion_group = muslim } }
			}
			random = {
				chance = 50
				add_trait = sympathy_islam
			}
		}
		if = {
			limit = {
				is_pagan_religion = yes
				FROM = { is_pagan_religion = no }
			}
			random = {
				chance = 50
				add_trait = sympathy_pagans
			}
		}
		if = {
			limit = {
				religion_group = zoroastrian_group
				FROM = { NOT = { religion_group = zoroastrian_group } }
			}
			random = {
				chance = 50
				add_trait = sympathy_zoroastrianism
			}
		}
		if = {
			limit = {
				religion_group = jewish_group
				FROM = { NOT = { religion_group = jewish_group } }
			}
			random = {
				chance = 50
				add_trait = sympathy_judaism
			}
		}
		if = {
			limit = {
				religion_group = indian_group
				FROM = { NOT = { religion_group = indian_group } }
			}
			random = {
				chance = 50
				add_trait = sympathy_indian
			}
		}
		
		hidden_tooltip = {
			if = {
				limit = { religion_group = FROM }
				if = {
					limit = {
						is_ruler = yes
						lower_tier_than = DUKE
					}
					FROM = { piety = 25 }
				}
				if = {
					limit = {
						is_ruler = yes
						tier = DUKE
					}
					FROM = { piety = 50 }
				}
				if = {
					limit = {
						is_ruler = yes
						higher_tier_than = DUKE
					}
					FROM = { piety = 100 }
				}
			}
			if = {
				limit = { NOT = { religion_group = FROM } }
				if = {
					limit = {
						is_ruler = yes
						lower_tier_than = DUKE
					}
					FROM = { piety = 50 }
				}
				if = {
					limit = {
						is_ruler = yes
						tier = DUKE
					}
					FROM = {
						piety = 100
						if = {
							limit = { has_nickname = no }
							random_list = {
								30 = {}
								20 = { give_nickname = nick_the_preacher }
								10 = { give_nickname = nick_the_proselytizer }
								10 = { give_nickname = nick_the_pious }
							}
						}
					}
				}
				if = {
					limit = {
						is_ruler = yes
						higher_tier_than = DUKE
					}
					set_character_flag = king_converted
					FROM = {
						if = {
							limit = { has_nickname = no }
							random_list = {
								10 = {}
								20 = { give_nickname = nick_the_preacher }
								20 = { give_nickname = nick_the_proselytizer }
								10 = { give_nickname = nick_the_pious }
								5 = { give_nickname = nick_the_illuminator }
							}
						}
						piety = 200
						set_character_flag = converted_king
					}
				}
			}
		}
		if = {
			limit = {
				has_secret_religion_trait_trigger = yes
				FROM = {
					is_openly_of_prevs_secret_religion_trigger = yes
				}
			}
			remove_secret_religion_trait_effect = yes
		}
		religion = FROM
		if = {
			limit = {
				NOR = {
					trait = cynical
					trait = sympathy_christendom
					trait = sympathy_islam
					trait = sympathy_pagans
					trait = sympathy_zoroastrianism
					trait = sympathy_judaism
					trait = sympathy_indian
				}
			}
			random = {
				chance = 25
				add_trait = zealous
				hidden_tooltip = { character_event = { id = 38269 } } #notification
			}
		}	
		if = {
			limit = { trait = cynical }
			remove_trait = cynical
		}
		opinion = { who = FROM modifier = converted_me years = 20 }
		reverse_opinion = { who = FROM modifier = agreed_to_convert years = 20 }
		hidden_tooltip = { 
			if = {
				limit = { religion_group = indian_group }
				set_character_flag = india_converted
				character_event = { id = RoI.30122 }
			}
		}
	}
	option = { # Sympathy
		name = EVTOPTF_SOA_4031
		trigger = {
			NOR = {
				religion_group = FROM
				AND = {
					trait = sympathy_christendom
					FROM = { religion_group = christian }
				}
				AND = {
					trait = sympathy_islam
					FROM = { religion_group = muslim }
				}
				AND = {
					trait = sympathy_pagans
					FROM = { is_pagan_religion = yes }
				}
				AND = {
					trait = sympathy_zoroastrianism
					FROM = { religion_group = zoroastrian_group }
				}
				AND = {
					trait = sympathy_judaism
					FROM = { religion_group = jewish_group }
				}
				AND = {
					trait = sympathy_indian
					FROM = { religion_group = indian_group }
				}
			}
		}
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0.25
				OR = {
					AND = {
						trait = sympathy_christendom
						NOT = { FROM = { religion_group = christian } }
					}
					AND = {
						trait = sympathy_islam
						NOT = { FROM = { religion_group = muslim } }
					}
					AND = {
						trait = sympathy_pagans
						NOT = { FROM = { is_pagan_religion = yes } }
					}
					AND = {
						trait = sympathy_zoroastrianism
						NOT = { FROM = { religion_group = zoroastrian_group } }
					}
					AND = {
						trait = sympathy_judaism
						NOT = { FROM = { religion_group = jewish_group } }
					}
					AND = {
						trait = sympathy_indian
						NOT = { FROM = { religion_group = indian_group } }
					}
				}
			}
			modifier = {
				factor = 0.5
				is_ruler = yes
				OR = {
					independent = yes
					liege = { NOT = { religion = FROM } }
				}
			}
			modifier = {
				factor = 0.5
				is_ruler = no
				liege = { NOT = { religion = FROM } }
			}
			modifier = {
				factor = 1.5
				is_ruler = no
				liege = { religion = FROM }
			}
			modifier = {
				factor = 1.5
				location = { religion = FROM }
			}
			modifier = {
				factor = 0.5
				NOT = { religion_group = FROM }
			}
			modifier = {
				factor = 3
				culture_group = east_slavic
				is_pagan_religion = yes
				FROM = {
					OR = {
						religion = chalcedonian
						religion = orthodox
						religion = bogomilist
						religion = monothelite
						religion = iconoclast
					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 3
				culture_group = north_germanic
				is_pagan_religion = yes
				FROM = {
					OR = {
						religion = chalcedonian
 						religion = catholic
						religion = cathar
						religion = fraticelli
						religion = waldensian
						religion = lollard
						religion = adoptionist
 					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 0.1
				is_heretic = yes
			}
			modifier = {
				factor = 0.1
				culture_group = baltic
				is_pagan_religion = yes
			}
			modifier = {
				factor = 0.1
				OR = {
					culture_group = north_germanic
					culture_group = east_slavic
				}
				is_pagan_religion = yes
				FROM = { religion_group = muslim }
			}
			modifier = {
				factor = 2
				is_pagan_religion = yes
				is_reformed_pagan_religion = no
				FROM = {
					OR = {
						is_pagan_religion = no
						is_reformed_pagan_religion = yes
					}
				}
			}
			modifier = {
				factor = 0.1
				religion_group = jewish_group
				FROM = { NOT = { religion_group = jewish_group } }
			}
			modifier = {
				factor = 0.1
				NOT = { personal_opinion = { who = FROM value = 0 } }
			}
			modifier = {
				factor = 1.5
				personal_opinion = { who = FROM value = 25 }
			}
			modifier = {
				factor = 1.5
				personal_opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 1.5
				personal_opinion = { who = FROM value = 75 }
			}
			modifier = {
				factor = 2.0
				trait = cynical
			}
			modifier = {
				factor = 2.0
				trait = excommunicated
			}
			modifier = {
				factor = 1.25
				NOT = { religion_authority = 0.4 }
			}
			modifier = {
				factor = 1.25
				NOT = { religion_authority = 0.3 }
			}
			modifier = {
				factor = 1.25
				NOT = { religion_authority = 0.2 }
			}
			modifier = {
				factor = 1.25
				NOT = { religion_authority = 0.1 }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 16 }
			}
			modifier = {
				factor = 1.1
				FROM = { diplomacy = 18 }
			}
			modifier = {
				factor = 1.2
				FROM = { diplomacy = 20 }
			}
		}
		if = {
			limit = { FROM = { religion_group = christian } }
			add_trait = sympathy_christendom
		}
		if = {
			limit = { FROM = { religion_group = muslim } }
			add_trait = sympathy_islam
		}
		if = {
			limit = { FROM = { is_pagan_religion = yes } }
			add_trait = sympathy_pagans
		}
		if = {
			limit = { FROM = { religion_group = zoroastrian_group } }
			add_trait = sympathy_zoroastrianism
		}
		if = {
			limit = { FROM = { religion_group = jewish_group } }
			add_trait = sympathy_judaism
		}
		if = {
			limit = { FROM = { religion_group = indian_group } }
			add_trait = sympathy_indian
		}
		if = {
			limit = { NOT = { trait = cynical } }
			random = {
				chance = 50
				add_trait = cynical
				hidden_tooltip = { character_event = { id = 38258 } } #notify
			}
		}
		opinion = { who = FROM modifier = opinion_mutual_respect multiplier = 2 years = 20 }
		reverse_opinion = { who = FROM modifier = opinion_mutual_respect multiplier = 2 years = 20 }
	}
	option = { # Refuse
		name = EVTOPTB_SOA_4031
		trigger = {
			OR = {
				NOT = { learning = 8 }
				NOT = { is_liege_of = FROM }
			}
		}
		ai_chance = {
			factor = 300
			modifier = {
				factor = 0.5
				OR = {
					AND = {
						independent = no
						liege = { religion = FROM }
					}
					location = { religion = FROM }
					AND = {
						trait = sympathy_christendom
						FROM = { religion_group = christian }
					}
					AND = {
						trait = sympathy_islam
						FROM = { religion_group = muslim }
					}
					AND = {
						trait = sympathy_pagans
						FROM = { is_pagan_religion = yes }
					}
					AND = {
						trait = sympathy_zoroastrianism
						FROM = { religion_group = zoroastrian_group }
					}
					AND = {
						trait = sympathy_judaism
						FROM = { religion_group = jewish_group }
					}
					AND = {
						trait = sympathy_indian
						FROM = { religion_group = indian_group }
					}
				}
			}
			modifier = {
				factor = 1.25
				religion_authority = 0.6
			}
			modifier = {
				factor = 1.5
				religion_authority = 0.7
			}
			modifier = {
				factor = 1.5
				religion_authority = 0.8
			}
			modifier = {
				factor = 0
				FROM = {
					is_openly_of_prevs_secret_religion_trigger = yes
				}
			}
		}
		opinion = { who = FROM modifier = tried_to_convert_me years = 20 }
	}	
	option = { # Debate for reconversion
		name = EVTOPTC_SOA_4031
		trigger = {
			learning = 8
			is_liege_of = FROM
			piety = 0
		}
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0
				FROM = {
					is_openly_of_prevs_secret_religion_trigger = yes
				}
			}
		}
		tooltip_info = learning
		if = {
			limit = { FROM = { is_ruler = no } }
			piety = -10
		}
		if = {
			limit = { FROM = { is_ruler = yes } }
			piety = -50
		}
		FROM = {
			character_event = { id = GoPagan.135 tooltip = DEBATE_CONVERSION }
			custom_tooltip = { text = CONVERSION_START }
			custom_tooltip = { text = CONVERSION_BASE_DEBATE }
			if = {
				limit = {
					OR = {
						AND = {
							trait = sympathy_christendom
							ROOT = { religion_group = christian }
						}
						AND = {
							trait = sympathy_islam
							ROOT = { religion_group = muslim }
						}
						AND = {
							trait = sympathy_pagans
							ROOT = { is_pagan_religion = yes }
						}
						AND = {
							trait = sympathy_zoroastrianism
							ROOT = { religion_group = zoroastrian_group }
						}
						AND = {
							trait = sympathy_judaism
							ROOT = { religion_group = jewish_group }
						}
						AND = {
							trait = sympathy_indian
							ROOT = { religion_group = indian_group }
						}
					}
				}
				custom_tooltip = { text = CONVERSION_SYMPATHY }
			}
			if = {
				limit = {
					culture_group = east_slavic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = orthodox
							religion = bogomilist
							religion = monothelite
							religion = iconoclast
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_2 }
			}
			if = {
				limit = {
					culture_group = north_germanic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = catholic
							religion = cathar
							religion = fraticelli
							religion = waldensian
							religion = lollard
							religion = adoptionist
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_2 }
			}
			if = {
				limit = {
					culture_group = baltic
					is_pagan_religion = yes
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_3 }
			}
			if = {
				limit = {
					OR = {
						culture_group = north_germanic
						culture_group = east_slavic
					}
					is_pagan_religion = yes
					ROOT = { religion_group = muslim }
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_3 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					is_reformed_pagan_religion = no
					ROOT = { is_pagan_religion = no }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_1 }
			}
			if = {
				limit = {
					religion_group = jewish_group
					ROOT = { NOT = { religion_group = jewish_group } }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_3 }
			}
			if = {
				limit = {
					OR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					religion_group = muslim
					ROOT = { religion_group = muslim }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					ROOT = { is_pagan_religion = yes }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					religion_group = ROOT
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
						is_pagan_religion = yes
						religion_group = muslim
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_2 }
			}
			if = {
				limit = {
					NOT = { opinion = { who = ROOT value = -25 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_4 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = -25 }
					NOT = { opinion = { who = ROOT value = 0 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_3 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 25 }
					NOT = { opinion = { who = ROOT value = 50 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_1 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 50 }
					NOT = { opinion = { who = ROOT value = 75 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_2 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 75 }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_3 }
			}
			if = {
				limit = { trait = cynical }
				custom_tooltip = { text = CONVERSION_CYNICAL_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					NOT = { religion_authority = 0.1 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.1
					NOT = { religion_authority = 0.25 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.25
					NOT = { religion_authority = 0.4 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.6
					NOT = { religion_authority = 0.75 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.75
					NOT = { religion_authority = 0.9 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.9
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_3 }
			}
			if = {
				limit = {
					ROOT = { attribute_diff = { character = FROM attribute = learning value = 1 } }
					NOT = { ROOT = { attribute_diff = { character = FROM attribute = learning value = 5 } } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_GOOD_1 }
			}
			if = {
				limit = {
					ROOT = { attribute_diff = { character = FROM attribute = learning value = 5 } }
					NOT = { ROOT = { attribute_diff = { character = FROM attribute = learning value = 9 } } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_GOOD_2 }
			}
			if = {
				limit = {
					ROOT = { attribute_diff = { character = FROM attribute = learning value = 9 } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_GOOD_3 }
			}
			if = {
				limit = {
					attribute_diff = { character = ROOT attribute = learning value = 1 }
					NOT = { attribute_diff = { character = ROOT attribute = learning value = 5 } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_BAD_1 }
			}
			if = {
				limit = {
					attribute_diff = { character = ROOT attribute = learning value = 5 }
					NOT = { attribute_diff = { character = ROOT attribute = learning value = 9 } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_BAD_2 }
			}
			if = {
				limit = {
					attribute_diff = { character = ROOT attribute = learning value = 9 }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_BAD_3 }
			}
			if = {
				limit = {
					ROOT = { NOT = { trait = zealous } }
					reverse_opinion = { who = ROOT value = 0 }
					attribute_diff = { character = ROOT attribute = learning value = 1 }
					NOR = {
						religion_group = ROOT
						AND = {
							ROOT = { trait = sympathy_christendom }
							religion_group = christian
						}
						AND = {
							ROOT = { trait = sympathy_islam }
							religion_group = muslim
						}
						AND = {
							ROOT = { trait = sympathy_pagans }
							is_pagan_religion = yes
						}
						AND = {
							ROOT = { trait = sympathy_zoroastrianism }
							religion_group = zoroastrian_group
						}
						AND = {
							ROOT = { trait = sympathy_judaism }
							religion_group = jewish_group
						}
						AND = {
							ROOT = { trait = sympathy_indian }
							religion_group = indian_group
						}
					}
				}
				custom_tooltip = { text = CONVERSION_CHANCE_SYMP }
			}
		}
	}
	option = { # Imprison (if liege)
		name = EVTOPTD_SOA_4031
		trigger = {
			is_liege_of = FROM
		}
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0
				FROM = {
					is_openly_of_prevs_secret_religion_trigger = yes
				}
			}
			modifier = {
				factor = 0
				OR = {
					trait = kind
					is_friend = FROM
					AND = {
						trait = sympathy_christendom
						FROM = { religion_group = christian }
					}
					AND = {
						trait = sympathy_islam
						FROM = { religion_group = muslim }
					}
					AND = {
						trait = sympathy_pagans
						FROM = { is_pagan_religion = yes }
					}
					AND = {
						trait = sympathy_zoroastrianism
						FROM = { religion_group = zoroastrian_group }
					}
					AND = {
						trait = sympathy_judaism
						FROM = { religion_group = jewish_group }
					}
					AND = {
						trait = sympathy_indian
						FROM = { religion_group = indian_group }
					}
				}
			}
			modifier = {
				factor = 0.75
				trait = charitable
			}
			modifier = {
				factor = 0.75
				trait = patient
			}
			modifier = {
				factor = 0.75
				trait = trusting
			}
			modifier = {
				factor = 0.5
				trait = just
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				OR = {
					trait = cruel
					trait = impaler
				}
			}
			modifier = {
				factor = 1.5
				trait = wroth
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.25
				trait = arbitrary
			}
			modifier = {
				factor = 0
				personal_opinion = { who = FROM value = 0 }
			}
			modifier = {
				factor = 3.0
				NOT = { personal_opinion = { who = FROM value = -25 } }
			}
			modifier = {
				factor = 0.9
				FROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 0.9
				FROM = { diplomacy = 16 }
			}
			modifier = {
				factor = 0.9
				FROM = { diplomacy = 18 }
			}
			modifier = {
				factor = 0.8
				FROM = { diplomacy = 20 }
			}
		}
		opinion = { who = FROM modifier = tried_to_convert_me multiplier = 2 years = 20 }
		FROM = { character_event = { id = 39024 tooltip = ATTEMPT_IMPRISON } }
	}
	option = { # Refuse and blab to liege (if not liege)
		name = EVTOPTE_SOA_4031
		trigger = {
			liege = { religion = ROOT }
			NOT = { is_liege_of = FROM }
			intrigue = 8
			attribute_diff = { character = FROM attribute = intrigue value = 1 }
		}
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0
				FROM = {
					is_openly_of_prevs_secret_religion_trigger = yes
				}
			}
			modifier = {
				factor = 0
				OR = {
					trait = kind
					is_friend = FROM
					AND = {
						trait = sympathy_christendom
						FROM = { religion_group = christian }
					}
					AND = {
						trait = sympathy_islam
						FROM = { religion_group = muslim }
					}
					AND = {
						trait = sympathy_pagans
						FROM = { is_pagan_religion = yes }
					}
					AND = {
						trait = sympathy_zoroastrianism
						FROM = { religion_group = zoroastrian_group }
					}
					AND = {
						trait = sympathy_judaism
						FROM = { religion_group = jewish_group }
					}
					AND = {
						trait = sympathy_indian
						FROM = { religion_group = indian_group }
					}
				}
			}
			modifier = {
				factor = 0.75
				trait = charitable
			}
			modifier = {
				factor = 0.75
				trait = patient
			}
			modifier = {
				factor = 0.75
				trait = trusting
			}
			modifier = {
				factor = 0.5
				trait = just
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				OR = {
					trait = cruel
					trait = impaler
				}
			}
			modifier = {
				factor = 1.5
				trait = wroth
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.25
				trait = arbitrary
			}
			modifier = {
				factor = 0
				personal_opinion = { who = FROM value = 0 }
			}
			modifier = {
				factor = 3.0
				NOT = {
					personal_opinion = { who = FROM value = -25 }
				}
			}
			modifier = {
				factor = 0.9
				FROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 0.9
				FROM = { diplomacy = 16 }
			}
			modifier = {
				factor = 0.9
				FROM = { diplomacy = 18 }
			}
			modifier = {
				factor = 0.8
				FROM = { diplomacy = 20 }
			}
		}
		tooltip_info = intrigue
		opinion = { who = FROM modifier = tried_to_convert_me multiplier = 2 years = 20 }
		liege = { 
			letter_event = { id = SoA.4032 days = 7 }
		}
	}
}

# SoA.4032 - Liege learns of conversion attempt
letter_event = {
	id = SoA.4032
	desc = EVTDESC_SOA_4032
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = { # Convince him to convert
		name = EVTOPTD_SOA_4032
		trigger = { piety = 0 }
		ai_chance = {
			factor = 100
			modifier = {
				factor = 1.5
				trait = kind
			}
			modifier = {
				factor = 1.5
				trait = patient
			}
			modifier = {
				factor = 1.5
				trait = gregarious
			}
			modifier = {
				factor = 1.25
				trait = charitable
			}
			modifier = {
				factor = 0.75
				trait = shy
			}
			modifier = {
				factor = 0.75
				trait = slothful
			}
			modifier = {
				factor = 0.5
				NOT = { diplomacy = 8 }
			}
			modifier = {
				factor = 2.0
				OR = {
					diplomacy = 15
					trait = socializer
					trait = poet
				}
			}
		}
		if = {
			limit = { FROMFROM = { is_ruler = no } }
			piety = -10
		}
		if = {
			limit = { FROMFROM = { is_ruler = yes } }
			piety = -50
		}
		FROMFROM = {
			character_event = { id = GoPagan.131 days = 7 tooltip = CONVINCE_CONVERSION }
			custom_tooltip = { text = CONVERSION_START }
			custom_tooltip = { text = CONVERSION_BASE_DIPLOMACY }
			if = {
				limit = {
					OR = {
						AND = {
							trait = sympathy_christendom
							ROOT = { religion_group = christian }
						}
						AND = {
							trait = sympathy_islam
							ROOT = { religion_group = muslim }
						}
						AND = {
							trait = sympathy_pagans
							ROOT = { is_pagan_religion = yes }
						}
						AND = {
							trait = sympathy_zoroastrianism
							ROOT = { religion_group = zoroastrian_group }
						}
						AND = {
							trait = sympathy_judaism
							ROOT = { religion_group = jewish_group }
						}
						AND = {
							trait = sympathy_indian
							ROOT = { religion_group = indian_group }
						}
					}
				}
				custom_tooltip = { text = CONVERSION_SYMPATHY }
			}
			if = {
				limit = {
					culture_group = east_slavic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = orthodox
							religion = bogomilist
							religion = monothelite
							religion = iconoclast
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_3 }
			}
			if = {
				limit = {
					culture_group = north_germanic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = catholic
							religion = cathar
							religion = fraticelli
							religion = waldensian
							religion = lollard
							religion = adoptionist
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_3 }
			}
			if = {
				limit = {
					culture_group = baltic
					is_pagan_religion = yes
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_4 }
			}
			if = {
				limit = {
					OR = {
						culture_group = north_germanic
						culture_group = east_slavic
					}
					is_pagan_religion = yes
					ROOT = { religion_group = muslim }
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_4 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					is_reformed_pagan_religion = no
					ROOT = { is_pagan_religion = no }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_2 }
			}
			if = {
				limit = {
					religion_group = jewish_group
					ROOT = { NOT = { religion_group = jewish_group } }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_4 }
			}
			if = {
				limit = {
					OR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_4 }
			}
			if = {
				limit = {
					religion_group = muslim
					ROOT = { religion_group = muslim }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_3 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					ROOT = { is_pagan_religion = yes }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_3 }
			}
			if = {
				limit = {
					religion_group = ROOT
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
						is_pagan_religion = yes
						religion_group = muslim
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_1 }
			}
			if = {
				limit = {
					NOT = { opinion = { who = ROOT value = 0 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_4 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 0 }
					NOT = { opinion = { who = ROOT value = 25 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_3 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 25 }
					NOT = { opinion = { who = ROOT value = 50 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_1 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 50 }
					NOT = { opinion = { who = ROOT value = 75 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_2 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 75 }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_3 }
			}
			if = {
				limit = {
					OR = {
						AND = {
							is_ruler = no
							OR = {
								is_married = ROOT
								any_spouse = { is_father = ROOT }
								any_spouse = { is_mother = ROOT }
								any_spouse = { is_child_of = ROOT }
							}
						}
						OR = {
							is_close_relative = ROOT
							is_lover = ROOT
						}
					}
					OR = {
						NOT = {
							AND = {
								is_ruler = no
								OR = {
									is_married = ROOT
									any_spouse = { is_father = ROOT }
									any_spouse = { is_mother = ROOT }
									any_spouse = { is_child_of = ROOT }
								}
							}
						}
						NOR = {
							is_close_relative = ROOT
							is_lover = ROOT
						}
					}
				}
				custom_tooltip = { text = CONVERSION_RELATION_GOOD_2 }
			}
			if = {
				limit = {
					is_ruler = no
					OR = {
						is_married = ROOT
						any_spouse = { is_father = ROOT }
						any_spouse = { is_mother = ROOT }
						any_spouse = { is_child_of = ROOT }
					}
					OR = {
						is_close_relative = ROOT
						is_lover = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELATION_GOOD_3 }
			}
			if = {
				limit = { trait = cynical }
				custom_tooltip = { text = CONVERSION_CYNICAL_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					NOT = { religion_authority = 0.1 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.1
					NOT = { religion_authority = 0.25 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.25
					NOT = { religion_authority = 0.4 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.6
					NOT = { religion_authority = 0.75 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.75
					NOT = { religion_authority = 0.9 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.9
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_3 }
			}
			if = {
				limit = {
					ROOT = { diplomacy = 12 }
					ROOT = { NOT = { diplomacy = 16 } }
				}
				custom_tooltip = { text = CONVERSION_DIPLOMACY_GOOD_1 }
			}
			if = {
				limit = {
					ROOT = { diplomacy = 16 }
				}
				custom_tooltip = { text = CONVERSION_DIPLOMACY_GOOD_2 }
			}
		}
	}
	option = { # Debate for reconversion
		name = EVTOPTC_SOA_4032
		tooltip_info = learning
		trigger = {
			learning = 8
			piety = 0
		}
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2
				is_priest = yes
			}
			modifier = {
				factor = 1.2
				learning = 10
			}
			modifier = {
				factor = 1.2
				learning = 12
			}
			modifier = {
				factor = 1.2
				learning = 14
			}
			modifier = {
				factor = 1.2
				learning = 16
			}
			modifier = {
				factor = 1.2
				learning = 18
			}
			modifier = {
				factor = 1.2
				learning = 20
			}
			modifier = {
				factor = 1.5
				trait = zealous
			}
			modifier = {
				factor = 0.75
				trait = slothful
			}
			modifier = {
				factor = 2.0
				OR = {
					trait = scholar
					trait = theologian
					trait = faqih
				}
			}
		}
		if = {
			limit = { FROMFROM = { is_ruler = no } }
			piety = -10
		}
		if = {
			limit = { FROMFROM = { is_ruler = yes } }
			piety = -50
		}
		FROMFROM = {
			character_event = { id = GoPagan.135 tooltip = DEBATE_CONVERSION }
			custom_tooltip = { text = CONVERSION_START }
			custom_tooltip = { text = CONVERSION_BASE_DEBATE }
			if = {
				limit = {
					OR = {
						AND = {
							trait = sympathy_christendom
							ROOT = { religion_group = christian }
						}
						AND = {
							trait = sympathy_islam
							ROOT = { religion_group = muslim }
						}
						AND = {
							trait = sympathy_pagans
							ROOT = { is_pagan_religion = yes }
						}
						AND = {
							trait = sympathy_zoroastrianism
							ROOT = { religion_group = zoroastrian_group }
						}
						AND = {
							trait = sympathy_judaism
							ROOT = { religion_group = jewish_group }
						}
						AND = {
							trait = sympathy_indian
							ROOT = { religion_group = indian_group }
						}
					}
				}
				custom_tooltip = { text = CONVERSION_SYMPATHY }
			}
			if = {
				limit = {
					culture_group = east_slavic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = orthodox
							religion = bogomilist
							religion = monothelite
							religion = iconoclast
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_2 }
			}
			if = {
				limit = {
					culture_group = north_germanic
					is_pagan_religion = yes
					ROOT = {
						OR = {
							religion = chalcedonian
							religion = catholic
							religion = cathar
							religion = fraticelli
							religion = waldensian
							religion = lollard
							religion = adoptionist
						}
						is_heretic = no
					}
				}
				custom_tooltip = { text = CONVERSION_CULTURE_GOOD_2 }
			}
			if = {
				limit = {
					culture_group = baltic
					is_pagan_religion = yes
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_3 }
			}
			if = {
				limit = {
					OR = {
						culture_group = north_germanic
						culture_group = east_slavic
					}
					is_pagan_religion = yes
					ROOT = { religion_group = muslim }
				}
				custom_tooltip = { text = CONVERSION_CULTURE_BAD_3 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					is_reformed_pagan_religion = no
					ROOT = { is_pagan_religion = no }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_1 }
			}
			if = {
				limit = {
					religion_group = jewish_group
					ROOT = { NOT = { religion_group = jewish_group } }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_3 }
			}
			if = {
				limit = {
					OR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					religion_group = muslim
					ROOT = { religion_group = muslim }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					is_pagan_religion = yes
					ROOT = { is_pagan_religion = yes }
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					religion_group = ROOT
					NOR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
						is_pagan_religion = yes
						religion_group = muslim
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_GOOD_2 }
			}
			if = {
				limit = {
					NOT = { opinion = { who = ROOT value = -25 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_4 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = -25 }
					NOT = { opinion = { who = ROOT value = 0 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_3 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 25 }
					NOT = { opinion = { who = ROOT value = 50 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_1 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 50 }
					NOT = { opinion = { who = ROOT value = 75 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_2 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 75 }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_3 }
			}
			if = {
				limit = { trait = cynical }
				custom_tooltip = { text = CONVERSION_CYNICAL_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					NOT = { religion_authority = 0.1 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_3 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.1
					NOT = { religion_authority = 0.25 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.25
					NOT = { religion_authority = 0.4 }
				}
				custom_tooltip = { text = CONVERSION_RA_GOOD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.6
					NOT = { religion_authority = 0.75 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_1 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.75
					NOT = { religion_authority = 0.9 }
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_2 }
			}
			if = {
				limit = {
					is_heretic = no
					religion_authority = 0.9
				}
				custom_tooltip = { text = CONVERSION_RA_BAD_3 }
			}
			if = {
				limit = {
					ROOT = { attribute_diff = { character = FROM attribute = learning value = 1 } }
					NOT = { ROOT = { attribute_diff = { character = FROM attribute = learning value = 5 } } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_GOOD_1 }
			}
			if = {
				limit = {
					ROOT = { attribute_diff = { character = FROM attribute = learning value = 5 } }
					NOT = { ROOT = { attribute_diff = { character = FROM attribute = learning value = 9 } } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_GOOD_2 }
			}
			if = {
				limit = {
					ROOT = { attribute_diff = { character = FROM attribute = learning value = 9 } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_GOOD_3 }
			}
			if = {
				limit = {
					attribute_diff = { character = ROOT attribute = learning value = 1 }
					NOT = { attribute_diff = { character = ROOT attribute = learning value = 5 } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_BAD_1 }
			}
			if = {
				limit = {
					attribute_diff = { character = ROOT attribute = learning value = 5 }
					NOT = { attribute_diff = { character = ROOT attribute = learning value = 9 } }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_BAD_2 }
			}
			if = {
				limit = {
					attribute_diff = { character = ROOT attribute = learning value = 9 }
				}
				custom_tooltip = { text = CONVERSION_LEARNING_BAD_3 }
			}
			if = {
				limit = {
					ROOT = { NOT = { trait = zealous } }
					reverse_opinion = { who = ROOT value = 0 }
					attribute_diff = { character = ROOT attribute = learning value = 1 }
					NOR = {
						religion_group = ROOT
						AND = {
							ROOT = { trait = sympathy_christendom }
							religion_group = christian
						}
						AND = {
							ROOT = { trait = sympathy_islam }
							religion_group = muslim
						}
						AND = {
							ROOT = { trait = sympathy_pagans }
							is_pagan_religion = yes
						}
						AND = {
							ROOT = { trait = sympathy_zoroastrianism }
							religion_group = zoroastrian_group
						}
						AND = {
							ROOT = { trait = sympathy_judaism }
							religion_group = jewish_group
						}
						AND = {
							ROOT = { trait = sympathy_indian }
							religion_group = indian_group
						}
					}
				}
				custom_tooltip = { text = CONVERSION_CHANCE_SYMP }
			}
		}
	}
	option = { # Threaten unless he converts
		name = EVTOPTA_SOA_4021
		trigger = {
			piety = 0
			OR = {
				AND = {
					is_tribal = no
					crownlaw_title = {
						OR = {
							has_law = crown_authority_2
							has_law = crown_authority_3
							has_law = crown_authority_4
						}
					}
				}
				AND = {
					is_tribal = yes
					primary_title = {
						OR = {
							has_law = tribal_organization_2
							has_law = tribal_organization_3
							has_law = tribal_organization_4
						}
					}
				}
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 0
				OR = {
					is_friend = FROMFROM
					AND = {
						trait = sympathy_christendom
						FROMFROM = { religion_group = christian }
					}
					AND = {
						trait = sympathy_islam
						FROMFROM = { religion_group = muslim }
					}
					AND = {
						trait = sympathy_pagans
						FROMFROM = { is_pagan_religion = yes }
					}
					AND = {
						trait = sympathy_zoroastrianism
						FROMFROM = { religion_group = zoroastrian_group }
					}
					AND = {
						trait = sympathy_judaism
						FROMFROM = { religion_group = jewish_group }
					}
					AND = {
						trait = sympathy_indian
						FROMFROM = { religion_group = indian_group }
					}
				}
			}
			modifier = {
				factor = 0
				OR = {
					trait = kind
					trait = just
					trait = humble
				}
			}
			modifier = {
				factor = 0
				NOR = {
					trait = wroth
					trait = proud
					trait = cruel
					trait = arbitrary
					trait = zealous
					trait = impaler
				}
			}
			modifier = {
				factor = 0.5
				is_close_relative = FROMFROM
			}
			modifier = {
				factor = 2
				trait = wroth
			}
			modifier = {
				factor = 2
				trait = cruel
			}
			modifier = {
				factor = 2
				trait = impaler
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.5
				trait = arbitrary
			}
			modifier = {
				factor = 1.5
				trait = paranoid
			}
			modifier = {
				factor = 0.5
				trait = patient
			}
			modifier = {
				factor = 0.5
				trait = charitable
			}
			modifier = {
				factor = 0.5
				reverse_opinion = { who = FROMFROM value = 50 }
			}
			modifier = {
				factor = 0.5
				reverse_opinion = { who = FROMFROM value = 75 }
			}
			modifier = {
				factor = 1.5
				NOT = { reverse_opinion = { who = FROMFROM value = 25 } }
			}
			modifier = {
				factor = 1.5
				NOT = { reverse_opinion = { who = FROMFROM value = 0 } }
			}
			modifier = {
				factor = 0.8
				OR = {
					trait = tyrant1
					trait = tyrant2
					trait = tyrant3
				}
			}
			modifier = {
				factor = 0.8
				OR = {
					trait = tyrant4
					trait = tyrant5
					trait = tyrant6
				}
			}
			modifier = {
				factor = 0.8
				OR = {
					trait = tyrant7
					trait = tyrant8
					trait = tyrant9
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					trait = tyrant10
					trait = tyrant11
					trait = tyrant12
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					trait = tyrant13
					trait = tyrant14
					trait = tyrant15
				}
			}
			modifier = {
				factor = 0
				OR = {
					trait = tyrant16
					trait = tyrant17
					trait = tyrant18
					trait = tyrant19
				}
			}
		}
		if = {
			limit = { FROMFROM = { is_ruler = no } }
			piety = -10
		}
		if = {
			limit = { FROMFROM = { is_ruler = yes } }
			piety = -50
		}
		tyrant_plus_1_effect = yes
		FROMFROM = {
			character_event = { id = GoPagan.143 days = 7 tooltip = THREATEN_CONVERSION }
			custom_tooltip = { text = CONVERSION_START }
			custom_tooltip = { text = CONVERSION_BASE_THREAT }
			if = {
				limit = {
					OR = {
						AND = {
							trait = sympathy_christendom
							ROOT = { religion_group = christian }
						}
						AND = {
							trait = sympathy_islam
							ROOT = { religion_group = muslim }
						}
						AND = {
							trait = sympathy_pagans
							ROOT = { is_pagan_religion = yes }
						}
						AND = {
							trait = sympathy_zoroastrianism
							ROOT = { religion_group = zoroastrian_group }
						}
						AND = {
							trait = sympathy_judaism
							ROOT = { religion_group = jewish_group }
						}
						AND = {
							trait = sympathy_indian
							ROOT = { religion_group = indian_group }
						}
					}
				}
				custom_tooltip = { text = CONVERSION_SYMPATHY }
			}
			if = {
				limit = {
					religion_group = jewish_group
					ROOT = { NOT = { religion_group = jewish_group } }
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_4 }
			}
			if = {
				limit = {
					OR = {
						is_heresy_of = ROOT
						is_parent_religion = ROOT
					}
				}
				custom_tooltip = { text = CONVERSION_RELIGION_BAD_2 }
			}
			if = {
				limit = {
					is_ruler = yes
				}
				custom_tooltip = { text = CONVERSION_RULER_BAD_2 }
			}
			if = {
				limit = {
					is_priest = yes
				}
				custom_tooltip = { text = CONVERSION_PRIEST_BAD_2 }
			}
			if = {
				limit = { trait = cynical }
				custom_tooltip = { text = CONVERSION_CYNICAL_GOOD_3 }
			}
			if = {
				limit = { trait = craven }
				custom_tooltip = { text = CONVERSION_CRAVEN_GOOD_3 }
			}
			if = {
				limit = { trait = brave }
				custom_tooltip = { text = CONVERSION_BRAVE_BAD_3 }
			}
			if = {
				limit = { trait = humble }
				custom_tooltip = { text = CONVERSION_HUMBLE_GOOD_1 }
			}
			if = {
				limit = { trait = content }
				custom_tooltip = { text = CONVERSION_CONTENT_GOOD_1 }
			}
			if = {
				limit = { trait = proud }
				custom_tooltip = { text = CONVERSION_PROUD_BAD_1 }
			}
			if = {
				limit = { trait = wroth }
				custom_tooltip = { text = CONVERSION_WROTH_BAD_1 }
			}
			if = {
				limit = {
					NOT = { opinion = { who = ROOT value = -75 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_4 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = -75 }
					NOT = { opinion = { who = ROOT value = -50 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_3 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = -50 }
					NOT = { opinion = { who = ROOT value = -25 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_2 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = -25 }
					NOT = { opinion = { who = ROOT value = 0 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_BAD_1 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 0 }
					NOT = { opinion = { who = ROOT value = 25 } }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_1 }
			}
			if = {
				limit = {
					opinion = { who = ROOT value = 25 }
				}
				custom_tooltip = { text = CONVERSION_OPINION_GOOD_2 }
			}
			if = {
				limit = {
					ROOT = {
						OR = {
							AND = {
								is_tribal = no
								crownlaw_title = { has_law = crown_authority_3 }
							}
							AND = {
								is_tribal = yes
								primary_title = { has_law = tribal_organization_3 }
							}
						}
					}
				}
				custom_tooltip = { text = CONVERSION_AUTHORITY_GOOD_1 }
			}
			if = {
				limit = {
					ROOT = {
						OR = {
							AND = {
								is_tribal = no
								crownlaw_title = { has_law = crown_authority_4 }
							}
							AND = {
								is_tribal = yes
								primary_title = { has_law = tribal_organization_4 }
							}
						}
					}
				}
				custom_tooltip = { text = CONVERSION_AUTHORITY_GOOD_2 }
			}
			custom_tooltip = { text = IMPRISON_IF_REFUSE }
		}
	}
	option = { # Imprison
		name = EVTOPTD_SOA_4031
		trigger = {
			NOT = { piety = 0 }
			OR = {
				AND = {
					is_tribal = no
					crownlaw_title = {
						OR = {
							has_law = crown_authority_2
							has_law = crown_authority_3
							has_law = crown_authority_4
						}
					}
				}
				AND = {
					is_tribal = yes
					primary_title = {
						OR = {
							has_law = tribal_organization_2
							has_law = tribal_organization_3
							has_law = tribal_organization_4
						}
					}
				}
			}
		}
		ai_chance = {
			factor = 100 
			modifier = {
				factor = 0
				OR = {
					trait = kind
					is_friend = FROMFROM
					AND = {
						trait = sympathy_christendom
						FROMFROM = { religion_group = christian }
					}
					AND = {
						trait = sympathy_islam
						FROMFROM = { religion_group = muslim }
					}
					AND = {
						trait = sympathy_pagans
						FROMFROM = { is_pagan_religion = yes }
					}
					AND = {
						trait = sympathy_zoroastrianism
						FROMFROM = { religion_group = zoroastrian_group }
					}
					AND = {
						trait = sympathy_judaism
						FROMFROM = { religion_group = jewish_group }
					}
					AND = {
						trait = sympathy_indian
						FROMFROM = { religion_group = indian_group }
					}
				}
			}
			modifier = {
				factor = 0.75
				trait = charitable
			}
			modifier = {
				factor = 0.75
				trait = patient
			}
			modifier = {
				factor = 0.75
				trait = trusting
			}
			modifier = {
				factor = 0.5
				trait = just
			}
			modifier = {
				factor = 0.5
				trait = cynical
			}
			modifier = {
				factor = 2
				OR = {
					trait = cruel
					trait = impaler
				}
			}
			modifier = {
				factor = 1.5
				trait = wroth
			}
			modifier = {
				factor = 1.5
				trait = proud
			}
			modifier = {
				factor = 1.25
				trait = arbitrary
			}
			modifier = {
				factor = 0
				personal_opinion = { who = FROMFROM value = 0 }
			}
			modifier = {
				factor = 3.0
				NOT = { personal_opinion = { who = FROMFROM value = -25 } }
			}
			modifier = {
				factor = 0.9
				FROMFROM = { diplomacy = 14 }
			}
			modifier = {
				factor = 0.9
				FROMFROM = { diplomacy = 16 }
			}
			modifier = {
				factor = 0.9
				FROMFROM = { diplomacy = 18 }
			}
			modifier = {
				factor = 0.8
				FROMFROM = { diplomacy = 20 }
			}
		}
		tyrant_plus_1_effect = yes
		FROMFROM = { character_event = { id = 39024 tooltip = ATTEMPT_IMPRISON } }
	}
	option = { # Let it slide
		name = EVTOPTB_SOA_4021
		ai_chance = {
			factor = 100
			modifier = {
				factor = 2
				trait = patient
			}
			modifier = {
				factor = 2
				trait = just
			}
			modifier = {
				factor = 0.5
				trait = cruel
			}
			modifier = {
				factor = 0.5
				trait = arbitrary
			}
			modifier = {
				factor = 10
				OR = {
					trait = kind
					is_friend = FROMFROM
					AND = {
						trait = sympathy_christendom
						FROMFROM = { religion_group = christian }
					}
					AND = {
						trait = sympathy_islam
						FROMFROM = { religion_group = muslim }
					}
					AND = {
						trait = sympathy_pagans
						FROMFROM = { is_pagan_religion = yes }
					}
					AND = {
						trait = sympathy_zoroastrianism
						FROMFROM = { religion_group = zoroastrian_group }
					}
					AND = {
						trait = sympathy_judaism
						FROMFROM = { religion_group = jewish_group }
					}
					AND = {
						trait = sympathy_indian
						FROMFROM = { religion_group = indian_group }
					}
				}
			}
		}
	}	

}

######################################################################################################
# Heretic province worries parent religion Head
######################################################################################################

# SoA.4100 - Heretic province worries parent religion Head (hidden province event)
#	Immediate: SoA 4101 (head)

province_event = {
	id = SoA.4100
	
	hide_window = yes
	
	trigger = {
		has_dlc = "Sons of Abraham"
		
		is_heretic = yes
		
		owner = {
			top_liege = {
				is_parent_religion = ROOT
				controls_religion = no
				rightful_religious_head_scope = {
					NOT = { character = PREV }
					war = no
					is_alive = yes
					wealth = 100
				}
			}
		}
		
		NOT = { has_province_modifier = theological_dialogue }
		NOT = { has_province_modifier = active_inquisition }
	}
	
	mean_time_to_happen = {
		months = 1200
		modifier = {
			factor = 3.0 # Do not spam human players with this
			owner = {
				top_liege = {
					rightful_religious_head_scope = {
						ai = no
					}
				}
			}
		}
	}
	
	immediate = {
		owner = {
			top_liege = {
				rightful_religious_head_scope = {
					character_event = { id = SoA.4101 }
				}
			}
		}
	}
}

# SoA.4101 - Heretic province worries parent religion Head
#	- A: Send in the Inquisition! Costs 100 gold. SoA 4110.
#	- B: Dispatch Legate to Ruler: (top liege) SoA 4120.
#	- C: Open Dialogue. (High learning) Costs 50 gold. SoA 4130.
#	- D: Do nothing

character_event = {
	id = SoA.4101
	desc = EVTDESC_SOA_4101
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = { # Send in the Inquisition!
		name = EVTOPTA_SOA_4101
		ai_chance = {
			factor = 200
			modifier = {
				factor = 10
				trait = cruel
			}
			modifier = {
				factor = 3
				trait = zealous
			}
		}
		
		wealth = -100
		
		FROM = {
			province_event = { id = SoA.4110 tooltip = EVTTOOLTIP_SOA_4110 }
		}
	}
	
	option = { # Dispatch Legate to Ruler
		name = EVTOPTB_SOA_4101
		trigger = {
			NOT = {
				FROM = {
					owner = {
						top_liege = { character = ROOT }
					}
				}
			}
		}
		ai_chance = {
			factor = 100
		}
		
		FROM = {
			owner = {
				top_liege = {
					character_event = { id = SoA.4120 days = 2 tooltip = EVTTOOLTIP_SOA_4120 }
				}
			}
		}
	}
	
	option = { # Open Dialogue
		name = EVTOPTC_SOA_4101
		tooltip_info = learning
		trigger = {
			learning = 7
		}
		
		ai_chance = {
			factor = 1000
		}
		
		wealth = -50
		
		FROM = {
			province_event = { id = SoA.4130 tooltip = EVTTOOLTIP_SOA_4130 }
		}
	}
	
	option = { # Do nothing
		name = EVTOPTD_SOA_4101
		ai_chance = {
			factor = 1
		}
	}
}

# SoA.4110 - Inquisition arrives in province.
province_event = {
	id = SoA.4110
	desc = EVTDESC_SOA_4110
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		add_province_modifier = {
			name = active_inquisition
			days = 730
		}
		random_list = {
			50 = {
				province_event = {
					id = SoA.4111 days = 730
				}
			}
			50 = {
				province_event = {
					id = SoA.4113 days = 730
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_SOA_4110
	}
}

# SoA.4111 - Inquisition fails! Fire SoA.4112 to the head of religion.
province_event = {
	id = SoA.4111
	desc = EVTDESC_SOA_4111
	picture = GFX_evt_burning_house
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	trigger = {
		is_heretic = yes
	}
	
	immediate = {
		remove_province_modifier = active_inquisition
		FROMFROM = {
			character_event = {
				id = SoA.4112
			}
		}
		add_province_modifier = {
			name = religious_unrest
			days = 365
		}
	}
	
	option = {
		name = EVTOPTA_SOA_4111
	}
}

# SoA.4112 - Notification: Inquisition fails! Loss of authority. 
character_event = {
	id = SoA.4112
	desc = EVTDESC_SOA_4112
	picture = GFX_evt_burning_house
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_SOA_4112
		religion_authority = {
			modifier = failed_inquisition
		}
	}
}

# SoA.4113 - Inquisition succeeds. Fire SoA.4114 to the head of religion.
province_event = {
	id = SoA.4113
	desc = EVTDESC_SOA_4113
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	trigger = {
		is_heretic = yes
	}
	
	immediate = {
		religion = FROMFROM
		remove_province_modifier = active_inquisition
		remove_province_modifier = religious_unrest
		remove_province_modifier = heretic_stronghold
	
		FROMFROM = {
			character_event = {
				id = SoA.4114
			}
		}
	}
	
	option = {
		name = EVTOPTA_SOA_4113
	}
}

# SoA.4114 - Notification: Inquisition succeeds!
character_event = {
	id = SoA.4114
	desc = EVTDESC_SOA_4114
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
			
	option = {
		name = EVTOPTA_SOA_4114
		religion_authority = {
			modifier = successful_inquisition
		}
	}
}

# SoA.4120 - Legate berates ruler about heretic province
character_event = {
	id = SoA.4120
	desc = EVTDESC_SOA_4120
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		add_character_modifier = {
			name = promised_to_clear_out_heresy
#			hidden = yes
			duration = 3650
		}
		FROMFROM = {
			add_province_modifier = {
				name = promised_to_clear_out_heresy
#				hidden = yes
				duration = 3650
			}
		}
	}
			
	option = {
		name = EVTOPTA_SOA_4120
	}
}

# SoA.4121 - The heresy is eradicated in the county. On-action.
province_event = {
	id = SoA.4121
	
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		has_dlc = "Sons of Abraham"
		has_province_modifier = promised_to_clear_out_heresy
		owner = {
			top_liege = {
				religion = ROOT
				has_character_modifier = promised_to_clear_out_heresy
			}
		}
	}
	
	immediate = {
		remove_province_modifier = promised_to_clear_out_heresy
		owner = {
			top_liege = {
				rightful_religious_head_scope = {
					character_event = {
						id = SoA.4122
					}
				}
			}
		}
	}
}

# SoA.4122 - The heresy has been eradicated in the county.
character_event = {
	id = SoA.4122
	desc = EVTDESC_SOA_4122
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		FROM = {
			owner = {
				top_liege = {
					reverse_opinion = {
						who = ROOT
						modifier = opinion_grateful
						months = 120
					}
				}
			}
		}
	}
			
	option = { # Reward the ruler with money
		name = EVTOPTA_SOA_4122
		trigger = {
			wealth = 100
		}
		ai_chance = { factor = 10 }
		
		wealth = -100
		
		FROM = {
			owner = {
				top_liege = {
					character_event = {
						id = SoA.4123 tooltip = EVTTOOLTIP_SOA_4123
					}
				}
			}
		}
	}
	
	option = { # Reward the ruler with piety
		name = EVTOPTB_SOA_4122
		ai_chance = { factor = 10 }
		FROM = {
			owner = {
				top_liege = {
					character_event = {
						id = SoA.4124 tooltip = EVTTOOLTIP_SOA_4124
					}
				}
			}
		}
	}
	
	option = { # Lift the excommunication
		name = EVTOPTC_SOA_4122
		trigger = {
			FROM = {
				owner = {
					top_liege = {
						excommunicated_for = ROOT
					}
				}
			}
		}
		ai_chance = { factor = 1000 }
		FROM = {
			owner = {
				top_liege = {
					character_event = {
						id = SoA.4125 tooltip = EVTTOOLTIP_SOA_4125
					}
				}
			}
		}
	}
}

# SoA.4123 - Reward the ruler with money
character_event = {
	id = SoA.4123
	desc = EVTDESC_SOA_4123
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_SOA_4123
		wealth = 100
		opinion = {
			who = FROM
			modifier = opinion_grateful
			months = 120
		}
	}
}

# SoA.4124 - Reward the ruler with piety
character_event = {
	id = SoA.4124
	desc = EVTDESC_SOA_4124
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_SOA_4123
		piety = 200
		opinion = {
			who = FROM
			modifier = opinion_grateful
			months = 120
		}
	}
}

# SoA.4125 - Excommunication is lifted
character_event = {
	id = SoA.4125
	desc = EVTDESC_SOA_4125
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_SOA_4123
		
		excommunicate = no
		
		opinion = {
			who = FROM
			modifier = opinion_grateful
			months = 120
		}
	}
}

# SoA.4130 - Theologians arrive in the province.
province_event = {
	id = SoA.4130
	desc = EVTDESC_SOA_4130
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		add_province_modifier = {
			name = theological_dialogue
			days = 730
		}
		random_list = {
			50 = {
				province_event = {
					id = SoA.4131 days = 730
				}
			}
			50 = {
				province_event = {
					id = SoA.4133 days = 730
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA_SOA_4130
	}
}

# SoA.4131 - Dialogue fails! Fire SoA.4132 to the head of religion.
province_event = {
	id = SoA.4131
	desc = EVTDESC_SOA_4131
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	trigger = {
		is_heretic = yes
	}
	
	immediate = {
		remove_province_modifier = theological_dialogue
		FROMFROM = {
			character_event = {
				id = SoA.4132
			}
		}
	}
	
	option = {
		name = EVTOPTA_SOA_4131
	}
}

# SoA.4132 - Notification: Dialogue fails! Loss of authority. 
character_event = {
	id = SoA.4132
	desc = EVTDESC_SOA_4132
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
			
	option = {
		name = EVTOPTA_SOA_4132
		religion_authority = {
			modifier = failed_heretic_dialogue
		}
	}
}

# SoA.4133 - Dialogue succeeds. Fire SoA.4134 to the head of religion.
province_event = {
	id = SoA.4133
	desc = EVTDESC_SOA_4133
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	trigger = {
		is_heretic = yes
	}
	
	immediate = {
		religion = FROMFROM
		remove_province_modifier = theological_dialogue
		remove_province_modifier = religious_unrest
		remove_province_modifier = heretic_stronghold
	
		FROMFROM = {
			character_event = {
				id = SoA.4134
			}
		}
	}
	
	option = {
		name = EVTOPTA_SOA_4133
	}
}

# SoA.4134 - Notification: Dialogue succeeds!
character_event = {
	id = SoA.4134
	desc = EVTDESC_SOA_4134
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
			
	option = {
		name = EVTOPTA_SOA_4134
		religion_authority = {
			modifier = successful_heretic_dialogue
		}
	}
}

# SoA.4200 - A heresy has become the new orthodoxy. On-action. There are temporary characters in FROM and FROMFROM with the correct religions set.
narrative_event = {
	id = SoA.4200
	title = EVTTITLE_SOA_4200
	desc = EVTDESC_SOA_4200
	picture = GFX_evt_bishop
	border = GFX_event_narrative_frame_religion
	hide_from = yes
	
	major = yes
	
	is_triggered_only = yes
			
	option = {
		name = EVTOPTA_SOA_4200
		trigger = {
			religion = FROM
		}
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_HERESY_TAKEOVER_PLAYER_IS_NEW
				portrait = [Root.GetID]
			}
		}
	}
	option = {
		name = EVTOPTB_SOA_4200
		trigger = {
			religion = FROMFROM
		}
		if = {
			limit = { ai = no }
			chronicle = {
				entry = CHRONICLE_HERESY_TAKEOVER_PLAYER_IS_OLD
				portrait = [Root.GetID]
			}
		}
	}
	option = {
		name = EVTOPTC_SOA_4200
		trigger = {
			NOT = { religion = FROM }
			NOT = { religion = FROMFROM }
		}
	}
}

