###################################
#
# Events for Religion
#
# Id 39000 - 39999 is reserved
#
###################################

# Written by Henrik F�hraeus, Johan Andersson & Niklas Strid

########################################
# HERESIES
########################################

# Heresy appears out of "nowhere"
province_event = {
	id = 39000
	desc = "EVTDESC39000"
	picture = "GFX_evt_stone_church"
	border = "GFX_event_normal_frame_religion"
	
	lacks_dlc = "Sons of Abraham"
	
	trigger = {
		is_heretic = no
		has_heresies = yes
		NOR = { 
			province_id = 333 # Rome
			province_id = 497 # Thrace
			province_id = 719 # Mecca
			province_id = 718 # Medina
		}
	}
	
	mean_time_to_happen = {
		months = 50000
		modifier = {
			factor = 1.25
			religion_authority = 0.7
		}
		modifier = {
			factor = 1.25
			religion_authority = 0.8
		}
		modifier = {
			factor = 2
			has_game_rule = {
				name = religious_conversion
				value = slower
			}
		}
		modifier = {
			factor = 1.25
			religion_authority = 0.9
		}
		modifier = {
			factor = 1.25
			religion_authority = 1.0
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.3 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.1 }
		}
	}
	
	immediate = {
		become_heretic = yes
		set_province_flag = heresy_in_province
		add_province_modifier = {
			name = heresy_in_province_timer
			duration = 730
			hidden = yes
		}
		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"
			trigger = { owner = { NOT = { religion = ROOT } } }
		}
		name = {
			text = "EVTOPTB39000"
			trigger = { owner = { religion = ROOT } }
		}
		if = {
			limit = { 
				ruler = { is_parent_religion = ROOT }
			}
			ruler = { piety = -10 }
		}
		if = {
			limit = {
				owner = {
					top_liege = {
						NOT = {
							any_realm_province = {
								religion = ROOT
								has_province_modifier = heretic_stronghold
							}
						}
					}
				}
			}
			add_province_modifier = {
				name = heretic_stronghold
				duration = 3650
			}
		}
		# News spread
		hidden_tooltip = {
			owner = {
				top_liege = {
					if = {
						limit = {
							NOT = { character = PREV }
						}
						character_event = { id = 39400 days = 2 }
					}
					any_vassal = {
						limit = {
							OR = {
								is_parent_religion = ROOT
								religion = ROOT
							}
						}
						character_event = { id = 39400 days = 2 }
					}
				}
			}
		}
	}
}

# News spread in realm
character_event = {
	id = 39400
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	desc = {
		text = EVTDESC39400
		trigger = { FROM = { is_heretic = yes } }
	}
	desc = {
		text = EVTDESC39400_B
		trigger = { FROM = { is_heretic = no } }
	}
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39400"
		trigger = {
			NOT = { religion = FROM }
			religion_group = FROM
		}
	}
	option = {
		name = "EXCELLENT"
		trigger = {
			religion = FROM
		}
	}
	option = {
		name = "EVTOPTB39400"
		trigger = {
			NOT = { religion_group = FROM }
		}
	}
}

# Pope urges to root out heresy in province
character_event = {
	id = 39403
	desc = "EVTDESC39403"
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	min_age = 16
	lacks_dlc = "Sons of Abraham"
	only_playable = yes
	ai = yes
	
	
	trigger = {
		OR = {
			controls_religion = yes
			rightful_religious_head = ROOT
		}
		is_heretic = no
		
		
		any_playable_ruler = {
			religion = ROOT
			NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = pope_disappointed_over_heretic_province } }
			any_demesne_province = {
				religion_group = ROOT
				is_heretic = yes
				owner = {
					NOT = {
						any_courtier = {
							location = {
								province_id = PREVPREVPREV
							}
							has_job_action = action_inquisition
						}
					}
				}
				NOT = { has_province_modifier = force_converting }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 12
	}
	
	option = {
		name = "EVTOPTA39403"
		random_playable_ruler = {
			limit = {
				religion = ROOT
				NOT = { reverse_has_opinion_modifier = { who = ROOT modifier = pope_disappointed_over_heretic_province } }
				any_demesne_province = {
					religion_group = ROOT
					is_heretic = yes
					owner = {
						NOT = {
							any_courtier = {
								location = { province_id = PREVPREVPREV }
								has_job_action = action_inquisition
							}
						}
					}
					NOT = { has_province_modifier = force_converting }
				}
			}
			random_demesne_province = {
				limit = {
					religion_group = ROOT
					is_heretic = yes
					owner = {
						NOT = {
							any_courtier = {
								location = { province_id = PREVPREVPREV }
								has_job_action = action_inquisition
							}
						}
					}
					NOT = { has_province_modifier = force_converting }
				}
				province_event = { id = 39404 days = 1 }
			}
		}
	}
}

# Message from the Pope
province_event = {
	id = 39404
	desc = "EVTDESC39404"
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39404"
		add_province_modifier = {
			name = force_converting
			duration = 3650
		}
		owner = { piety = 10 }
	}
	option = {
		name = "EVTOPTB39404"
		owner = {
			piety = -50
			reverse_opinion = {
				modifier = pope_disappointed_over_heretic_province
				who = FROM
				months = 60
			}
		}
	}
}

# Pope learns that a catholic ruler has a heretic advisor
character_event = {
	id = 39410
	desc = "EVTDESC39410"
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	min_age = 16
	only_playable = yes
	ai = yes
	lacks_dlc = "Sons of Abraham"
	
	trigger = {
		OR = {
			controls_religion = yes
			rightful_religious_head = ROOT
		}
		is_heretic = no
		
		
		any_playable_ruler = {
			religion = ROOT
			rightful_religious_head = ROOT
			any_courtier = {
				prisoner = no
				religion_group = ROOT
				is_heretic = yes
				is_councillor = yes
			}
		}
	}
	
	mean_time_to_happen = {
		months = 500
		modifier = {
			factor = 0.25
			trait = zealous
		}
	}

	option = {
		name = "EVTOPTA39410"
		random_playable_ruler = {
			limit = {
				religion = ROOT
				rightful_religious_head = ROOT
				any_courtier = {
					prisoner = no
					religion_group = ROOT
					is_heretic = yes
					is_councillor = yes
				}
			}
			letter_event = { id = 39441 days = 7 }
		}
	}
}

# Letter from the pope
letter_event = {
	id = 39441
	desc = "EVTDESC39441"
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		random_courtier = {
			limit = {
				prisoner = no
				religion_group = ROOT
				is_heretic = yes
				is_councillor = yes
			}
			set_character_flag = heretic_to_target
		}
	}

	option = {
		name = "EVTOPTA39441"	# Imprison
		ai_chance = {
			factor = 90
		}
		random_courtier = {
			limit = { has_character_flag = heretic_to_target }
			clr_character_flag = heretic_to_target
			opinion = {
				who = ROOT
				modifier = opinion_arrest_attempt
				months = 240
			}
			imprison = yes
		}
		reverse_remove_opinion = { who = FROM modifier = pope_heretic_removal_disapprove }
		if = {
			limit = {
				FROM = {
					NOT = {
						has_opinion_modifier = {
							modifier = pope_heretic_removal_approve
							who = ROOT
						}
					}
				}
			}
			FROM = {
				opinion = {
					modifier = pope_heretic_removal_approve
					who = ROOT
					months = 36
				}
			}
		}
	}
	option = {
		name = "EVTOPTB39441"	#Ignore Pope
		ai_chance = {
			factor = 10
			modifier = {
				factor =  0
				NOR = {
					trait = cynical
					trait = excommunicated
				}
			}
		}
		reverse_remove_opinion = { who = FROM modifier = pope_heretic_removal_approve }
		FROM = {
			opinion = {
				modifier = pope_heretic_removal_disapprove
				who = ROOT
				months = 36
			}
		}
		random_courtier = {
			limit = { has_character_flag = heretic_to_target }
			clr_character_flag = heretic_to_target
			opinion = {
				modifier = opinion_defended_me
				who = ROOT
				years = 5
			}
		}
		piety = -50
	}
}

# Vassal disappointed in liege having heretic advisor
character_event = {
	id = 39445
	desc = "EVTDESC39445"
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_religion

	min_age = 16
	only_capable = yes
	prisoner = no
	only_rulers = yes
	lacks_dlc = "Sons of Abraham"
	
	trigger = {
		independent = no
		is_heretic = no
		

		liege = {
			religion = ROOT
			
			any_courtier = {
				is_heretic = yes
				religion_group = ROOT
				prisoner = no
				is_councillor = yes
			}
			
			ROOT = {
				NOT = { has_opinion_modifier = { who = PREV modifier = opinion_disappointed } }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 600
		modifier = {
			factor = 0.25
			trait = zealous
		}
		modifier = {
			factor = 2.0
			trait = cynical
		}
	}
	
	option = {
		name = "EVTOPTA39445"
		hidden_tooltip = {
			liege = { letter_event = { id = 39446 } }
		}
	}
	option = {
		name = "EVTOPTB39445"
	}
}

# Vassal lets the liege know about his disappointment
letter_event = {
	id = 39446
	desc = "EVTDESC39446"
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39446"
		FROM = {
			opinion = {
				modifier = opinion_disappointed
				who = ROOT
				years = 5
			}
		}
	}
}

# Heresy spreads to a neighboring province
province_event = {
	id = 39001
	desc = "EVTDESC39001"
	picture = "GFX_evt_stone_church"
	border = "GFX_event_normal_frame_religion"
	
	lacks_dlc = "Sons of Abraham"
	
	trigger = {
		is_heretic = no
		has_heresies = yes
		owner = { is_heretic = no }
		NOR = { 
			province_id = 333 # Rome
			province_id = 497 # Thrace
			province_id = 719 # Mecca
			province_id = 718 # Medina
		}
		
		any_neighbor_province = {
			has_owner = yes
			is_heresy_of = ROOT
		}
	}
	
	mean_time_to_happen = {
		months = 1000
		modifier = {
			factor = 1.25
			religion_authority = 0.7
		}
		modifier = {
			factor = 1.25
			religion_authority = 0.8
		}
		modifier = {
			factor = 2
			has_game_rule = {
				name = religious_conversion
				value = slower
			}
		}
		modifier = {
			factor = 1.25
			religion_authority = 0.9
		}
		modifier = {
			factor = 1.25
			religion_authority = 1.0
		}
		
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.3 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.1 }
		}
		modifier = {
			factor = 0.75
			any_neighbor_province = {
				has_owner = yes
				is_heresy_of = ROOT
				ROOT = {
					any_neighbor_province = {
						has_owner = yes
						is_heresy_of = ROOT
						NOT = { province_id = PREVPREV }
					}
				}
			}
		}
		modifier = {
			factor = 0.5
			any_neighbor_province = {
				has_owner = yes
				is_heresy_of = ROOT
				owner = { is_heresy_of = ROOT }
			}
		}
		modifier = {
			factor = 0.5
			any_neighbor_province = {
				has_owner = yes
				is_heresy_of = ROOT
				has_province_modifier = heretic_stronghold
			}
		}
	}
	
	immediate = {
		random_neighbor_province = {
			limit = {
				is_heresy_of = ROOT
			}
			reverse_religion = ROOT
		}
	}
	
	option = {
		name = "EVTOPTA39001"
		if = {
			limit = { 
				ruler = { is_parent_religion = ROOT }
			}
			ruler = { piety = -10 }
		}
	}
}

# Character picks up the provincial heresy
character_event = {
	id = 39010
	desc = "EVTDESC39010"
	picture = GFX_evt_heretic
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	capable_only = yes
	prisoner = no
	lacks_dlc = "Sons of Abraham"
	
	trigger = {
		is_heretic = no
		OR = {
			is_ruler = no
			is_theocracy = no
		}
		location = {
			is_heresy_of = ROOT
		}
		
		can_change_religion = yes
		NOT = { is_inaccessible_trigger = yes }
	}
	
	mean_time_to_happen = {
		months = 360
		modifier = {
			factor = 0.25
			trait = cynical
		}
		modifier = {
			factor = 5.0
			trait = zealous
		}
		modifier = {
			factor = 2.0
			religion_authority = 0.6
		}
		modifier = {
			factor = 2.0
			religion_authority = 0.8
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.4 }
		}
	}
	
	option = {
		name = "EVTOPTA39010"
		ai_chance = { factor = 100 }
		location = {
			reverse_religion = ROOT
		}
	}
	option = {
		name = "EVTOPTB39010"
		ai_chance = { factor = 0 }
	}
}

# Heretic character attempts to spread the faith
character_event = {
	id = 39020
	desc = "EVTDESC39020"
	picture = GFX_evt_heretic
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	capable_only = yes
	prisoner = no
	lacks_dlc = "Sons of Abraham"
	
	trigger = {
		is_heretic = yes
		any_courtier = {
			is_adult = yes
			is_parent_religion = ROOT
			at_location = ROOT
			is_heretic = no
			prisoner = no
			NOT = { trait = incapable }
			reverse_opinion = { who = ROOT value = 25 }
		}
	}
	
	mean_time_to_happen = {
		months = 120
		modifier = {
			factor = 10.0
			trait = cynical
		}
		modifier = {
			factor = 0.25
			trait = zealous
		}
		modifier = {
			factor = 0.5
			trait = diligent
		}
		modifier = {
			factor = 3.0
			trait = slothful
		}
		modifier = {
			factor = 2.0
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 2.0
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor = 0.75
			religion_authority = 0.6
		}
		modifier = {
			factor = 0.75
			religion_authority = 0.8
		}
	}
	
	option = {
		name = "EVTOPTA39020"
		random_courtier = {
			limit = {
				is_adult = yes
				is_parent_religion = ROOT
				at_location = ROOT
				is_heretic = no
				prisoner = no
				NOT = { trait = incapable }
				reverse_opinion = { who = ROOT value = 25 }
			}
			character_event = { id = 39021 tooltip = EVTTOOLTIP39021 }
		}
	}
}

# A heretic character approaches me
character_event = {
	id = 39021
	desc = "EVTDESC39021"
	picture = GFX_evt_heretic
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39021" # Embrace the heresy
		ai_chance = {
			factor = 25
			modifier = {
				factor = 0.5
				independent = yes
			}
			modifier = {
				factor = 0.25
				tier = KING
			}
			modifier = {
				factor = 0.25
				tier = EMPEROR
			}
			modifier = {
				factor = 0.01
				trait = zealous
			}
		}
		hidden_tooltip = {
			FROM = { character_event = { id = 39022 days = 4 } }
		}
		religion = FROM
	}
	option = {
		name = "EVTOPTB39021" # Demand abandonment of heresy
		tooltip_info = diplomacy
		trigger = {
			is_liege_of = FROM
			diplomacy = 12
		}
		ai_chance = { factor = 25 }
		hidden_tooltip = {
			FROM = { character_event = { id = 39023 days = 3 } }
		}
	}
	option = {
		name = "EVTOPTC39021" # Have the heretic jailed!
		trigger = {
			is_liege_of = FROM
			OR = {
				trait = wroth
				trait = zealous
				trait = lunatic
			}
			OR = {
				NOT = { is_close_relative = FROM }
				trait = lunatic
			}
		}
		ai_chance = {
			factor = 25
			modifier = {
				factor = 10
				trait = zealous
			}
		}
		piety = 10
		hidden_tooltip = {
			FROM = { character_event = { id = 39024 days = 2 } }
		}
	}
	option = {
		name = "EVTOPTD39021" # Just say no
		ai_chance = { factor = 25 }
		hidden_tooltip = {
			FROM = { character_event = { id = 39025 days = 4 } }
		}
	}
}

# The heretic succeeded
character_event = {
	id = 39022
	desc = "EVTDESC39022"
	picture = GFX_evt_heretic
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39022" # Good news!
		piety = 10
		opinion = {
			modifier = opinion_successful_conversion
			who = FROM
			years = 5
		}
	}
}

# The heretic is asked to abandon the heresy
character_event = {
	id = 39023
	desc = "EVTDESC39023"
	picture = GFX_evt_heretic
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39023" # Never!
		hidden_tooltip = {
			FROM = { character_event = { id = 39025 days = 4 } }
		}
	}
	option = {
		name = "EVTOPTB39023" # Very well
		religion = FROM
		hidden_tooltip = {
			FROM = { character_event = { id = 39026 days = 4 } }
		}
	}
}

# Guards come to arrest the heretic
character_event = {
	id = 39024
	desc = "EVTDESC39024"
	picture = GFX_evt_heretic
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39024" # Accept judgement
		opinion = {
			modifier = opinion_arrest_attempt
			who = FROM
			years = 10
		}
		imprison = FROM
		set_character_flag = imprisoned_converter
	}
	option = {
		name = "EVTOPTB39024" # Attempt to escape
		tooltip_info = intrigue
		trigger = {
			intrigue = 6
		}
		opinion = {
			modifier = opinion_arrest_attempt
			who = FROM
			years = 10
		}
		random_list = {
			67 = {
				imprison = FROM
				set_character_flag = imprisoned_converter
			}
			33 = {
				if = {
					limit = { is_ruler = no }
					banish = yes
				}
			}
		}
	}
}

# One character failed to convert the other
character_event = {
	id = 39025
	desc = "EVTDESC39025"
	picture = GFX_evt_heretic
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39025"
		opinion = {
			modifier = opinion_failed_conversion
			who = FROM
			years = 5
		}
	}
}

# The heretic accepts reconversion
character_event = {
	id = 39026
	desc = "EVTDESC39026"
	picture = GFX_evt_heretic
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39026"
		piety = 10
		opinion = {
			modifier = opinion_successful_conversion
			who = FROM
			years = 5
		}
	}
}


########################################
# Formation of the Orders
########################################

# Formation of the Knights of St John
narrative_event = {
	id = 39100
	title = "EVTNAME39100"
	desc = "EVTDESC39100"
	picture = "GFX_evt_crusaders"
	border = "GFX_event_narrative_frame_religion"
	
	major = yes
	only_playable = yes
	only_men = yes
	religion_group = christian
	has_global_flag = christian_crusades_unlocked
	
	trigger = {
		OR = {
			religion = chalcedonian
			religion = catholic
			religion = cathar
			religion = fraticelli
			religion = waldensian
			religion = lollard
			religion = adoptionist
		}
		is_heretic = no
		
		NOT = { is_title_active = d_knights_hospitaler }
		
		
		OR = {
			year = 1113	# Historical
			221 = { # Provence
				NOT = { owner = { religion_group = christian } }
			}
			214 = { # Toulouse
				NOT = { owner = { religion_group = christian } }
			}
			112 = { # Paris
				NOT = { owner = { religion_group = christian } }
			}
			119 = { # Cologne
				NOT = { owner = { religion_group = christian } }
			}
			257 = { # Braunschweig
				NOT = { owner = { religion_group = christian } }
			}
			e_byzantium = {
				holder_scope = {
					NOT = { religion_group = christian }
				}
			}
			496 = { # Constantinople
				NOT = { owner = { religion_group = christian } }
			}
			753 = { # Ancyra
				NOT = { owner = { religion_group = christian } }
			}
			333 = { # Rome
				NOT = { owner = { religion_group = christian } }
			}
			AND = {
				482 = { # Athens
					NOT = { owner = { religion_group = christian } }
				}
				481 = { # Corinth
					NOT = { owner = { religion_group = christian } }
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 4
	}
	
	immediate = {
		activate_title = { title = d_knights_hospitaler status = yes }
		create_random_soldier = {
			dynasty = none
			random_traits = yes
			religion = ROOT
		}
		new_character = {
			d_knights_hospitaler = {
				religion = PREV
				grant_title = PREV
			}
			set_defacto_liege = THIS
			wealth = 500
		}
		religion_authority = {
			modifier = religious_order_formed
			years = 10
		}
	}
	option = {
		name = "EVTOPTA39100"
		trigger = {
			religion = ROOT
		}
	}
	option = {
		name = "EVTOPTB39100"
		trigger = {
			NOT = { religion_group = christian }
		}
	}
	option = {
		name = "EVTOPTC39100"
		trigger = {
			religion_group = christian
			NOT = { religion = ROOT }
		}
	}
}

# Formation of the Knights Templar
narrative_event = {
	id = 39101
	title = "EVTNAME39101"
	desc = "EVTDESC39101"
	picture = "GFX_evt_crusaders"
	border = "GFX_event_narrative_frame_religion"
	
	major = yes
	only_playable = yes
	only_men = yes
	religion_group = christian
	has_global_flag = christian_crusades_unlocked
	
	trigger = {
		OR = {
			religion = chalcedonian
			religion = catholic
			religion = cathar
			religion = fraticelli
			religion = waldensian
			religion = lollard
			religion = adoptionist
		}
		is_heretic = no
		
		NOT = { year = 1312 }
		NOT = { is_title_active = d_knights_templar }
	
		
		OR = {
			year = 1118	# Historical
			
			e_byzantium = {
				holder_scope = {
					NOT = { religion_group = christian }
				}
			}
			496 = { # Constantinople
				NOT = { owner = { religion_group = christian } }
			}
			753 = { # Ancyra
				NOT = { owner = { religion_group = christian } }
			}
			333 = { # Rome
				NOT = { owner = { religion_group = christian } }
			}
			AND = {
				482 = { # Athens
					NOT = { owner = { religion_group = christian } }
				}
				481 = { # Corinth
					NOT = { owner = { religion_group = christian } }
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 4
	}
	
	immediate = {
		activate_title = { title = d_knights_templar status = yes }
		create_random_soldier = {
			dynasty = none
			random_traits = yes
			religion = ROOT
		}
		new_character = {
			d_knights_templar = {
				religion = PREV
				grant_title = PREV
			}
			set_defacto_liege = THIS
			wealth = 600
		}
		religion_authority = {
			modifier = religious_order_formed
			years = 10
		}
	}
	option = {
		name = "EVTOPTA39101"
		trigger = {
			religion = ROOT
		}
	}
	option = {
		name = "EVTOPTB39101"
		trigger = {
			NOT = { religion_group = christian }
		}
	}
	option = {
		name = "EVTOPTC39100"
		trigger = {
			religion_group = christian
			NOT = { religion = ROOT }
		}
	}
}

# Formation of the Teutonic Order
narrative_event = {
	id = 39102
	title = "EVTNAME39102"
	desc = "EVTDESC39102"
	picture = "GFX_evt_crusaders"
	border = "GFX_event_narrative_frame_religion"
	
	major = yes
	only_playable = yes
	only_men = yes
	religion_group = christian
	has_global_flag = christian_crusades_unlocked
	
	trigger = {
		OR = {
			religion = chalcedonian
			religion = catholic
			religion = cathar
			religion = fraticelli
			religion = waldensian
			religion = lollard
			religion = adoptionist
		}
		is_heretic = no
		
		NOT = { is_title_active = d_teutonic_order }
		
		OR = {
			year = 1192	# Historical
			221 = { # Provence
				NOT = { owner = { religion_group = christian } }
			}
			214 = { # Toulouse
				NOT = { owner = { religion_group = christian } }
			}
			112 = { # Paris
				NOT = { owner = { religion_group = christian } }
			}
			119 = { # Cologne
				NOT = { owner = { religion_group = christian } }
			}
			257 = { # Braunschweig
				NOT = { owner = { religion_group = christian } }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 4
	}
	
	immediate = {
		activate_title = { title = d_teutonic_order status = yes }
		create_random_soldier = {
			dynasty = none
			random_traits = yes
			religion = ROOT
		}
		new_character = {
			d_teutonic_order = {
				religion = PREV
				grant_title = PREV
			}
			set_defacto_liege = THIS
			wealth = 500
		}
		
		religion_authority = {
			modifier = religious_order_formed
			years = 10
		}
	}
	option = {
		name = "EVTOPTA39102"
		trigger = {
			religion = ROOT
		}
	}
	option = {
		name = "EVTOPTB39102"
		trigger = {
			NOT = { religion_group = christian }
		}
	}
	option = {
		name = "EVTOPTC39100"
		trigger = {
			religion_group = christian
			NOT = { religion = ROOT }
		}
	}
}

########################################
# PAPAL EVENTS
########################################

# The Pope gives money to someone fighting the Infidel
character_event = {
	id = 39200
	desc = "EVTDESC39200"
	picture = "GFX_evt_battle"
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	only_playable = yes
	war = no
	
	trigger = {		
		OR = {
			controls_religion = yes
			rightful_religious_head = ROOT
		}
		NOT = { religion_group = muslim }
		ai = yes
		wealth = 250
		any_independent_ruler = {
			religion = ROOT
			rightful_religious_head = ROOT
			reverse_opinion = { who = ROOT value = 0 }
			any_current_enemy = { NOT = { religion_group = christian } }
			NOR = {
				wealth = 100
				excommunicated_for = ROOT
				any_current_enemy = { religion = ROOT }
				war_with = ROOT
			}
			OR = {
				NOT = { has_character_flag = money_from_the_pope }
				OR = {
					had_character_flag = { flag = money_from_the_pope days = 730 }
					AND = {
						ai = yes
						had_character_flag = { flag = money_from_the_pope days = 365 }
						any_war = {
							using_cb = holy_war
							OR = {
								attacker = {
									character = PREVPREV
									NOT = { war_score = -15 }
								}
								defender = {
									character = PREVPREV
									war_score = 15
								}
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 32
		modifier = {
			factor = 0.25
			any_war = { using_cb = crusade }
		}
		modifier = {
			factor = 0.5
			wealth = 500
		}
		modifier = {
			factor = 0.5
			wealth = 1000
		}
		modifier = {
			factor = 1.5
			trait = greedy
		}
		modifier = {
			factor = 1.5
			trait = slothful
		}
		modifier = {
			factor = 0.75
			trait = charitable
		}
		modifier = {
			factor = 0.75
			trait = diligent
		}
		modifier = {
			factor = 0.75
			trait = zealous
		}
	}
	
	option = {
		name = "EVTOPTA39200"
		ai_chance = { factor = 100 }

		# first look for a player in good standing with the Pope
		random_independent_ruler = {
			limit = {
				ROOT = { NOT = { has_character_flag = found_money_target } }
				religion = ROOT
				rightful_religious_head = ROOT
				reverse_opinion = { who = ROOT value = 0 }
				any_current_enemy = { NOT = { religion_group = ROOT } }
				NOT = {
					wealth = 100
					excommunicated_for = ROOT
					any_current_enemy = { religion = ROOT }
					war_with = ROOT
				}
				OR = {
					NOT = { has_character_flag = money_from_the_pope }
					OR = {
						had_character_flag = { flag = money_from_the_pope days = 730 }
						AND = {
							ai = yes
							had_character_flag = { flag = money_from_the_pope days = 365 }
							any_war = {
								using_cb = holy_war
								OR = {
									attacker = {
										character = PREVPREV
										NOT = { war_score = -15 }
									}
									defender = {
										character = PREVPREV
										war_score = 15
									}
								}
							}
						}
					}
				}
				ai = no
				OR = {
					any_war = { using_cb = crusade }
					reverse_opinion = { who = ROOT value = 50 }
				}
			}
			ROOT = { set_character_flag = found_money_target }
			letter_event = { id = 39201 tooltip = EVTTOOLTIP39201 }
		}		
		# then look for a King+ helping in a crusade
		random_independent_ruler = {
			limit = {
				ROOT = { NOT = { has_character_flag = found_money_target } }
				religion = ROOT
				rightful_religious_head = ROOT
				reverse_opinion = { who = ROOT value = 0 }
				any_current_enemy = { NOT = { religion_group = ROOT } }
				NOT = {
					wealth = 100
					excommunicated_for = ROOT
					any_current_enemy = { religion = ROOT }
					war_with = ROOT
				}
				OR = {
					NOT = { has_character_flag = money_from_the_pope }
					OR = {
						had_character_flag = { flag = money_from_the_pope days = 730 }
						AND = {
							ai = yes
							had_character_flag = { flag = money_from_the_pope days = 365 }
							any_war = {
								using_cb = holy_war
								OR = {
									attacker = {
										character = PREVPREV
										NOT = { war_score = -15 }
									}
									defender = {
										character = PREVPREV
										war_score = 15
									}
								}
							}
						}
					}
				}
				higher_tier_than = DUKE
				any_war = { using_cb = crusade }
			}
			ROOT = { set_character_flag = found_money_target }
			letter_event = { id = 39201 tooltip = EVTTOOLTIP39201 }
		}		
		# then look for a Duke - helping with a crusade
		random_independent_ruler = {
			limit = {
				ROOT = { NOT = { has_character_flag = found_money_target } }
				religion = ROOT
				rightful_religious_head = ROOT
				reverse_opinion = { who = ROOT value = 0 }
				any_current_enemy = { NOT = { religion_group = ROOT } }
				NOT = {
					wealth = 100
					excommunicated_for = ROOT
					any_current_enemy = { religion = ROOT }
					war_with = ROOT
				}
				OR = {
					NOT = { has_character_flag = money_from_the_pope }
					OR = {
						had_character_flag = { flag = money_from_the_pope days = 730 }
						AND = {
							ai = yes
							had_character_flag = { flag = money_from_the_pope days = 365 }
							any_war = {
								using_cb = holy_war
								OR = {
									attacker = {
										character = PREVPREV
										NOT = { war_score = -15 }
									}
									defender = {
										character = PREVPREV
										war_score = 15
									}
								}
							}
						}
					}
				}
				lower_tier_than = KING
				any_war = { using_cb = crusade }
			}
			ROOT = { set_character_flag = found_money_target }
			letter_event = { id = 39201 tooltip = EVTTOOLTIP39201 }
		}
		# then look for a King+ who the Pope likes
		random_independent_ruler = {
			limit = {
				ROOT = { NOT = { has_character_flag = found_money_target } }
				religion = ROOT
				rightful_religious_head = ROOT
				reverse_opinion = { who = ROOT value = 25 }
				any_current_enemy = { NOT = { religion_group = ROOT } }
				NOT = {
					wealth = 100
					excommunicated_for = ROOT
					any_current_enemy = { religion = ROOT }
					war_with = ROOT
				}
				OR = {
					NOT = { has_character_flag = money_from_the_pope }
					OR = {
						had_character_flag = { flag = money_from_the_pope days = 730 }
						AND = {
							ai = yes
							had_character_flag = { flag = money_from_the_pope days = 365 }
							any_war = {
								using_cb = holy_war
								OR = {
									attacker = {
										character = PREVPREV
										NOT = { war_score = -15 }
									}
									defender = {
										character = PREVPREV
										war_score = 15
									}
								}
							}
						}
					}
				}
				higher_tier_than = DUKE
			}
			ROOT = { set_character_flag = found_money_target }
			letter_event = { id = 39201 tooltip = EVTTOOLTIP39201 }
		}
		# then look for a Duke- who the Pope likes
		random_independent_ruler = {
			limit = {
				ROOT = { NOT = { has_character_flag = found_money_target } }
				religion = ROOT
				rightful_religious_head = ROOT
				reverse_opinion = { who = ROOT value = 25 }
				any_current_enemy = { NOT = { religion_group = ROOT } }
				NOT = {
					wealth = 100
					excommunicated_for = ROOT
					any_current_enemy = { religion = ROOT }
					war_with = ROOT
				}
				OR = {
					NOT = { has_character_flag = money_from_the_pope }
					OR = {
						had_character_flag = { flag = money_from_the_pope days = 730 }
						AND = {
							ai = yes
							had_character_flag = { flag = money_from_the_pope days = 365 }
							any_war = {
								using_cb = holy_war
								OR = {
									attacker = {
										character = PREVPREV
										NOT = { war_score = -15 }
									}
									defender = {
										character = PREVPREV
										war_score = 15
									}
								}
							}
						}
					}
				}
				lower_tier_than = KING
			}
			ROOT = { set_character_flag = found_money_target }
			letter_event = { id = 39201 tooltip = EVTTOOLTIP39201 }
		}
		# then anyone
		random_independent_ruler = {
			limit = {
				ROOT = { NOT = { has_character_flag = found_money_target } }
				religion = ROOT
				rightful_religious_head = ROOT
				reverse_opinion = { who = ROOT value = 0 }
				any_current_enemy = { NOT = { religion_group = ROOT } }
				NOT = {
					wealth = 100
					excommunicated_for = ROOT
					any_current_enemy = { religion = ROOT }
					war_with = ROOT
				}
				OR = {
					NOT = { has_character_flag = money_from_the_pope }
					OR = {
						had_character_flag = { flag = money_from_the_pope days = 730 }
						AND = {
							ai = yes
							had_character_flag = { flag = money_from_the_pope days = 365 }
							any_war = {
								using_cb = holy_war
								OR = {
									attacker = {
										character = PREVPREV
										NOT = { war_score = -15 }
									}
									defender = {
										character = PREVPREV
										war_score = 15
									}
								}
							}
						}
					}
				}
			}
			ROOT = { set_character_flag = found_money_target }
			letter_event = { id = 39201 tooltip = EVTTOOLTIP39201 }
		}
		clr_character_flag = found_money_target
	}
	
	option = {
		name = "EVTOPTB39200"
		ai_chance = { factor = 0 }
	}
}

letter_event = {
	id = 39201
	desc = "EVTDESC39201"
	border = "GFX_event_letter_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39201"
		wealth = 100
		hidden_tooltip = {
			FROM = { wealth = -100 }
			set_character_flag = money_from_the_pope
		}
	}
}

#Pope offers absolution for Kinslaying
character_event = {
	id = 39210
	desc = "EVTDESC39210"
	picture = GFX_evt_pope
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	only_capable = yes
	prisoner = no
	only_playable = yes
	ai = yes
	war = no
	
	trigger = {
		OR = {
			controls_religion = yes
			rightful_religious_head = ROOT
		}
		ai = yes
		is_heretic = no
		war = no
		
		any_independent_ruler = {
			NOT = { dynasty = ROOT }
			religion = ROOT
			rightful_religious_head = ROOT
			is_kinslayer_trigger = yes
			piety = 100
			wealth = 50
			reverse_opinion  = { who = ROOT value = 0 }
			NOT = { has_character_flag = kinslaying_offered }
		}
	}
	
	mean_time_to_happen = {
		months = 24
	}
	
	option = {
		name = "EVTOPTA39210"
		ai_chance = { factor = 100 }
		
		random_independent_ruler = {
			limit = {
				NOT = { dynasty = ROOT }
				religion = ROOT
				rightful_religious_head = ROOT
				is_kinslayer_trigger = yes
				piety = 100
				wealth = 50
				reverse_opinion  = { who = ROOT value = 0 }
				NOT = { has_character_flag = kinslaying_offered }
			}
			set_character_flag = kinslaying_offered
			character_event = { id = 39211 tooltip = EVTTOOLTIP39211 }
		}
	}
	
	option = {
		name = "EVTOPTB39210"	#incase someone plays the pope.. players will mod it in, so might as well give them a fun option here..
		ai_chance = { factor = 0 }
	}
}

character_event = {
	id = 39211
	desc = "EVTDESC39211"
	picture = GFX_evt_pope
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39211"
		ai_chance = { factor = 100 }
		piety = -100
		wealth = -50
		remove_trait = kinslayer
		remove_trait = familial_kinslayer 
		remove_trait = dynastic_kinslayer 
		FROM = { character_event = { id = 39212 days = 1 tooltip = EVTTOOLTIP39212 } }
	}
	
	option = {
		name = "EVTOPTB39211"
		ai_chance = { factor = 0 }
		add_trait = cynical
		FROM = { character_event = { id = 39213 days = 1  tooltip = EVTTOOLTIP39213 } }
	}
}

character_event = {
	id = 39212
	desc = "EVTDESC39212"
	picture = GFX_evt_knight_kneeling
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39212"
		wealth = 50
		prestige = 10
	}
}

character_event = {
	id = 39213
	desc = "EVTDESC39213"
	picture = GFX_evt_torture
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39213"
		prestige = -10
	}
}


########################################
#Bishops don't like being in prison events...
########################################

#CHAIN BEGIN
character_event = {
	id = 39220
	desc = "EVTDESC39220"	#Bishops in prison whine to pope..		
	picture = GFX_evt_into_the_dungeon
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	only_playable = yes
	religion_group = christian
	prisoner = yes
	
	trigger = {
		is_heretic = no
		is_theocracy = yes
		imprisoned_days = 14
		host = { religion = ROOT }
		NOT = { rightful_religious_head = ROOT }
		rightful_religious_head_scope = {
			reverse_opinion = { who = ROOT value = 0 }		#not grovel if we dont like the pope.
			opinion = { who = ROOT value = 0 }
		}
		NOT = {
			has_character_flag = nag_pope_to_help_me
		}
	}

	mean_time_to_happen = {
		days = 180
		modifier = {
			factor = 0.90
			trait = ambitious
		}
		modifier = {
			factor = 0.50
			trait = zealous
		}
		modifier = {
			factor = 0.75
			piety = 25
		}
		modifier = {
			factor = 0.75
			rightful_religious_head_scope = {
				reverse_opinion = { who = ROOT value = 50 }		
			}
		}
	}	

	immediate = {
		rightful_religious_head_scope = { save_event_target_as = rightful_rel_head }
		set_character_flag = nag_pope_to_help_me
	}

	option = {
		name = "EVTOPTA39220" # Write a letter to the pope.
		rightful_religious_head_scope = { character_event = { id = 39221 days = 5 random = 10 tooltip = EVTTOOLTIP39221 } }
		if = {
			limit = {
				host = { realm_intrigue = 15 }
			}
			random = {
				chance = 25
				host = { character_event = { id = 39222 days = 3 tooltip = EVTTOOLTIP39222 }  }
			}
		}
		
	}	
	option = {
		name = "EVTOPTB39220" # Pray for Divine Help
		piety = 10
		hidden_tooltip = {	
			host = { character_event = { id = 39223 days = 5 } 	}
		}
	}	
}	

#Pope gets letter.
character_event = {
	id = 39221
	desc = "EVTDESC39221"
	picture = GFX_evt_into_the_dungeon
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39221"	#try to help bishop
		FROM = {
			character_event = { id = 39224 days = 5 random = 10 tooltip = EVTTOOLTIP39224 }
		}
		prestige = 5
	}
	option = {
		name = "EVTOPTB39221"	#not my problem
		ai_chance = {
			factor = 0
		}
		FROM = {
			character_event = { id = 39225 days = 5 random = 10 tooltip = EVTTOOLTIP39225 }
		}
		religion_authority = {
			modifier = head_of_religion_neglect
			years = 10
		}
		prestige = -5
	}
}

#We discover bishop writing to pope
character_event = {
	id = 39222
	desc = "EVTDESC39222"
	picture = GFX_evt_recieve_letter
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39222" #kill
		trigger = {
			OR = {
				trait = cruel
				trait = impaler
				trait = wroth
			}
		}
		piety = -50
		FROM = {
			death = {
				death_reason = death_execution
				killer = ROOT
			}
		}
	}	
	option = {
		name = "EVTOPTB39222" #this is bad news
		trigger = {
			NOT = { trait = cruel }
			NOT = { trait = impaler }
			NOT = { trait = wroth }				
		}
		piety = -5
	}	
}

#Pious bishop praying for it..
character_event = {
	id = 39223
	desc = "EVTDESC39223"
	picture = GFX_evt_into_the_dungeon
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39223" #kind and release him
		trigger = {
			NOR = { 
				trait = cruel 
				trait = impaler
				trait = wroth
				trait = cynical
			}			
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 100
				trait = kind
			}
		}
		piety = 10
		FROM = { 
			prisoner = no 
			clr_character_flag = nag_pope_to_help_me
		}
	}	
	option = {
		name = "EVTOPTB39223" #nopes
		ai_chance = {
			factor = 10
		}
		piety = -5
	}	
}

#Bishop hears pope is helping him.
character_event = {
	id = 39224
	desc = "EVTDESC39224"
	picture = GFX_evt_pope
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	immediate = {
		host = { character_event = { id = 39226 days = 1 random = 2 tooltip = EVTTOOLTIP39226 } }
	}
	option = {
		name = "EVTOPTA39224"	#good news
		piety = 1
	}	
}

#bad news, pope tells you no
character_event = {
	id = 39225
	desc = "EVTDESC39225"
	picture = GFX_evt_knight_kneeling
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39225"	#bad news
		piety = -5
		opinion = {
			modifier = opinion_disappointed
			who = FROM
			years = 5
		}		
	}	
}

#deal with papal demands
character_event = {
	id = 39226
	desc = "EVTDESC39226"
	picture = GFX_evt_pope
	border = "GFX_event_normal_frame_religion"
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39226"	#let him go
		ai_chance = {
			factor = 1
			modifier = {
				factor = 100
				trait = kind
			}
		}
		FROM = { 
			prisoner = no 
			clr_character_flag = nag_pope_to_help_me
		}
		piety = 10
		religion_authority = {
			modifier = ruler_bowed_to_pope
			years = 10
		}
	}	
	option = {
		name = "EVTOPTB39226"	#no
		trigger = {
			NOT = {
				trait = zealous 
			}
		}
		ai_chance = {
			factor = 2
			modifier = {
				factor = 20
				NOT = {
					opinion = { who = FROM value = 20 }
				}
			}
		}
		piety = -50
		religion_authority = {
			modifier = ruler_defied_pope
			years = 10
		}
		religion_head = {
			opinion = {
				modifier = opinion_ignore_papal_demands
				who = ROOT
				years = 5
			}
		}
		
	}	
}


########################################################################
#Religious Head does not like it when you have heathens in your employ
########################################################################

character_event = {
	id = 39240
	desc = "EVTDESC39240"	#Pope asks a ruler that they should not have heathens employed.
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	min_age = 16
	only_capable = yes
	prisoner = no
	ai = yes
	only_playable = yes
	religion_group = christian
	war = no
	
	trigger = {
		OR = {
			controls_religion = yes
			rightful_religious_head = ROOT
		}
		is_heretic = no
		
		religion_authority = 0.20

		any_playable_ruler = {
			religion = ROOT
			rightful_religious_head = ROOT
			NOT = { has_character_flag = pope_dislikes_heathen_employed }
			any_courtier = {
				prisoner = no
				is_councillor = yes
				OR = {
					religion_group = muslim
					is_pagan_religion = yes
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 500
		modifier = {
			factor = 0.25
			trait = zealous
		}
	}

	option = {
		name = "EVTOPTA39240"	#ask them
		ai_chance = { factor = 100 }
		random_playable_ruler = {
			limit = {
				religion = ROOT
				rightful_religious_head = ROOT
				NOT = { has_character_flag = pope_dislikes_heathen_employed }

				any_courtier = {
					prisoner = no
					is_councillor = yes
					OR = {
						religion_group = muslim
						is_pagan_religion = yes
					}
				}
			}
			character_event = { id = 39241 days = 14 tooltip = EVTTOOLTIP392401 }
			set_character_flag = pope_dislikes_heathen_employed
		}
	}

	option = {
		name = "EVTOPTB39240"	#ignore it.
		ai_chance = { factor = 0 }
		religion_authority = {
			modifier = head_of_religion_neglect
			years = 10
		}
	}
}

#Demands is coming on us about
character_event = {
	id = 39241
	desc = "EVTDESC39241"	
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		random_courtier = {
			limit = {
				prisoner = no
				is_councillor = yes
				OR = {
					religion_group = muslim
					is_pagan_religion = yes
				}
			}
			set_character_flag = heathen_to_target
		}
	}
	
	option = {
		name = "EVTOPTB39241" #imprison
		random_courtier = {
			limit = { has_character_flag = heathen_to_target }
			clr_character_flag = heathen_to_target
			opinion = {
				who = ROOT
				modifier = opinion_arrest_attempt
				months = 240
			}
			imprison = yes
		}
		FROM = {
			opinion = {
				modifier = pope_heathen_removal_approve_2
				who = ROOT
				months = 36
			}
		}
		hidden_tooltip = {
			FROM = {  character_event = { id = 39243 days = 1  } }
		}	
		clr_character_flag = pope_dislikes_heathen_employed
	}
	option = {
		name = "EVTOPTC39241"	#Ignore Pope
		ai_chance = {
			factor = 1
			modifier = {
				factor =  0
				NOR = {
					trait = cynical
					trait = excommunicated
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_ignore_papal_demands
				who = ROOT
				months = 60
			}
		}
		random_courtier = {
			limit = { has_character_flag = heathen_to_target }
			clr_character_flag = heathen_to_target
			
			opinion = {
				modifier = opinion_defended_me
				who = ROOT
				years = 5
			}
		}
		piety = -50
		hidden_tooltip = {
			FROM = {  character_event = { id = 39244 days = 1 } }
		}
	}
}

#they imprisoned the heathen
character_event = {
	id = 39243
	desc = "EVTDESC39243"
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39243" 
		prestige = 5
	}
}

#they ignored us.
character_event = {
	id = 39244
	desc = "EVTDESC39244"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = "EVTOPTA39244" 
		prestige = -10
	}
}

#Character purchases lift of excommunication
character_event = {
	id = 39252
	desc = "EVTDESC39252"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA39252"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.5
				trait = greedy
			}
			modifier = {
				factor = 2
				opinion = {
					who = FROM
					value = -25
				}
			}
		}
		FROM = {
			character_event = { id = 39253 days = 3 random = 7 }
		}
	}
	option = {
		name = "EVTOPTB3206"
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.5
				trait = zealous
			}
			modifier = {
				factor = 2
				NOT = {
					opinion = {
						who = FROM
						value = -50
					}
				}
			}
		}
		FROM = {
			character_event = { id = 39254 days = 3 random = 7 }
		}
	}
}

#Character gets approval
character_event = {
	id = 39253
	desc = "EVTDESC39253"
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA39253"
		scaled_wealth = -2.0
		excommunicate = no
		FROM = {
			opinion = {
				who = ROOT
				modifier = opinion_repented_sins
				years = 10
			}
		}
		clr_character_flag  = ask_for_repentance
	}
	option = {
		name = "EVTOPTB39253"
		ai_chance = { factor = 0 }
		FROM = {
			opinion = {
				who = FROM
				modifier = refused_making_repentance
				years = 5
			}
		}
		clr_character_flag  = ask_for_repentance
	}
}

#Character does not get approval
character_event = {
	id = 39254
	desc = "EVTDESC39254"
	picture = GFX_evt_pope
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA39254"
	}
}

###############################################################
#Orthodox flavour: Icons!
###############################################################
character_event = {
	id = 39300
	desc = "EVTDESC39300"	# Icon of Mary, Mother of God  
	picture = "GFX_evt_icon"
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	only_capable = yes
	only_playable = yes
	prisoner = no
	religion_group = christian

	trigger = {
		OR = {
			religion = orthodox
			AND = {
				religion = chalcedonian
				rightful_religious_head_scope = { trait = greek_rites }
			}
		}
		is_heretic = no
		NOT = { has_character_flag = commisioned_icon }
		NOT = { trait = cynical }
	}
	
	mean_time_to_happen = {
		months = 600	
		modifier = {
			factor = 0.8
			trait = zealous
		}
		modifier = {
			factor = 0.8
			piety = 100
		}
		modifier = {
			factor = 0.8
			trait = kind
		}
	}
	option = {
		name = "EVTOPTA39300"	#Yes Please
		scaled_wealth = -0.25
		change_intrigue = 1
		set_character_flag = commisioned_icon
	} 
	option = {
		name = "EVTOPTB39300"	#No.
		piety = -25
		if = {
			limit = { trait = zealous }
			remove_trait = zealous
		}
	} 
}

#Icon of Christ Pantocrator
character_event = {
	id = 39301
	desc = "EVTDESC39301"	
	picture = "GFX_evt_icon"
	border = "GFX_event_normal_frame_religion"

	min_age = 16
	only_playable = yes
	only_capable = yes
	prisoner = no
	religion_group = christian

	trigger = {
		OR = {
			religion = orthodox
			AND = {
				religion = chalcedonian
				rightful_religious_head_scope = { trait = greek_rites }
			}
		}
		is_heretic = no
		NOT = {
			has_character_flag = commisioned_icon
		}
		NOT = { trait = cynical }
	}
	
	mean_time_to_happen = {
		months = 600	
		modifier = {
			factor = 0.8
			trait = zealous
		}
		modifier = {
			factor = 0.8
			piety = 100
		}
		modifier = {
			factor = 0.8
			trait = gregarious
		}
		
	}
	option = {
		name = "EVTOPTA39301"	#Yes Please
		scaled_wealth = -0.25
		change_diplomacy = 1
		set_character_flag = commisioned_icon
	} 
	option = {
		name = "EVTOPTB39301"	#No.
		piety = -25
		if = {
			limit = { trait = zealous }
			remove_trait = zealous
		}
	} 
}

#Icon of St.Peter
character_event = {
	id = 39302
	desc = "EVTDESC39302"	
	picture = "GFX_evt_icon"
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	only_playable = yes
	only_capable = yes
	prisoner = no
	religion_group = christian

	trigger = {
		OR = {
			religion = orthodox
			AND = {
				religion = chalcedonian
				rightful_religious_head_scope = { trait = greek_rites }
			}
		}
		is_heretic = no
		NOT = {
			has_character_flag = commisioned_icon
		}
		NOT = { trait = cynical }
	}
	
	mean_time_to_happen = {
		months = 600	
		modifier = {
			factor = 0.8
			trait = zealous
		}
		modifier = {
			factor = 0.8
			piety = 100
		}
		modifier = {
			factor = 0.8
			trait = just
		}
		
	}
	option = {
		name = "EVTOPTA39302"	#Yes Please
		scaled_wealth = -0.25
		change_stewardship = 1
		set_character_flag = commisioned_icon
	} 
	option = {
		name = "EVTOPTB39302"	#No.
		piety = -25
		if = {
			limit = { trait = zealous }
			remove_trait = zealous
		}
	} 
}

#Icon of John the Baptist
character_event = {
	id = 39303
	desc = "EVTDESC39303"	
	picture = "GFX_evt_icon"
	border = "GFX_event_normal_frame_religion"

	min_age = 16
	only_playable = yes
	only_capable = yes
	prisoner = no
	religion_group = christian

	trigger = {
		OR = {
			religion = orthodox
			AND = {
				religion = chalcedonian
				rightful_religious_head_scope = { trait = greek_rites }
			}
		}
		is_heretic = no
		NOT = {
			has_character_flag = commisioned_icon
		}
		NOT = { trait = cynical }
	}
	
	mean_time_to_happen = {
		months = 600	
		modifier = {
			factor = 0.8
			trait = zealous
		}
		modifier = {
			factor = 0.8
			piety = 100
		}
		modifier = {
			factor = 0.8
			trait = patient
		}
		
	}
	option = {
		name = "EVTOPTA39303"	#Yes Please
		scaled_wealth = -0.25
		change_learning = 1
		set_character_flag = commisioned_icon
	} 
	option = {
		name = "EVTOPTB39303"	#No.
		piety = -25
		if = {
			limit = { trait = zealous }
			remove_trait = zealous
		}
	} 
}

#Icon of Saint George
character_event = {
	id = 39304
	desc = "EVTDESC39304"
	picture = "GFX_evt_icon"
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	only_playable = yes
	only_capable = yes
	prisoner = no
	religion_group = christian

	trigger = {
		OR = {
			religion = orthodox
			AND = {
				religion = chalcedonian
				rightful_religious_head_scope = { trait = greek_rites }
			}
		}
		is_heretic = no
		NOT = {
			has_character_flag = commisioned_icon
		}
		NOT = { trait = cynical }
	}
	
	mean_time_to_happen = {
		months = 600	
		modifier = {
			factor = 0.8
			trait = zealous
		}
		modifier = {
			factor = 0.8
			piety = 100
		}
	}
	option = {
		name = "EVTOPTA39304"	#Yes Please
		scaled_wealth = -0.25
		change_martial = 1
		set_character_flag = commisioned_icon
	} 
	option = {
		name = "EVTOPTB39304"	#No.
		piety = -25
		if = {
			limit = { trait = zealous }
			remove_trait = zealous
		}
	} 
}


########################################
# A True Knight of christendom.
########################################

#True Knight
character_event = {
	id = 39310
	desc = "EVTDESC39310"
	picture = GFX_evt_melee
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	only_capable = yes
	only_men = yes
	religion_group = christian

	trigger = {
		is_heretic = no
		NOR = {	
			has_character_modifier = true_christian_knight	
			trait = cynical
			trait = lustful
			trait = gluttonous
			trait = greedy
			trait = slothful
			trait = envious
			trait = wroth
			trait = proud
			trait = cruel
		}
		martial = 8
		trait = humble
		trait = diligent
		trait = brave
		
		piety = 25
		
	}
	
	mean_time_to_happen = {
		months = 36
		modifier = {
			factor = 0.75
			trait = zealous
		}
		modifier = {
			factor = 0.75
			trait = crusader
		}
		modifier = {
			factor = 0.75
			piety = 100
		}
	}
	option = {
		name = "EVTOPTA39310"	#
		add_character_modifier = { name = true_christian_knight duration = -1 }
		set_character_flag = true_knight
		prestige = 50
	} 

}

#Losing status
character_event = {
	id = 39311
	desc = "EVTDESC39311"
	picture = GFX_evt_knight_kneeling
	border = "GFX_event_normal_frame_religion"
	
	min_age = 16
	only_men = yes
	has_character_flag = true_knight

	trigger = {
		has_character_modifier = true_christian_knight
		OR = {
			NOT = { religion_group = christian }
			is_heretic = yes 
			trait = cynical
			trait = lustful
			trait = gluttonous
			trait = greedy
			trait = slothful
			trait = envious
			trait = wroth
			trait = proud
			trait = cruel
			trait = craven
		}
		
	}
	
	mean_time_to_happen = {
		days = 5
	}
	option = {
		name = "EVTOPTA39311"	#
		remove_character_modifier =  true_christian_knight
		clr_character_flag = true_knight
		prestige = -50
	}
}

# County population converts to Islam
province_event = {
	id = 39500
	desc = "EVTDESC39500"
	picture = "GFX_evt_bishop"
	border = "GFX_event_normal_frame_religion"
	
	trigger = {
		NOT = { religion_group = muslim }
		owner = {
			religion_group = muslim
			top_liege = { religion_group = muslim } 
		}
	}
	
	mean_time_to_happen = {
		months = 1200
		modifier = {
			factor = 0.5
			owner = { trait = zealous }
		}
		modifier = {
			factor = 1.05
			NOT = { owner = { learning = 1 } }
		}
		modifier = {
			factor = 1.05
			NOT = { owner = { learning = 2 } }
		}
		modifier = {
			factor = 1.05
			NOT = { owner = { learning = 3 } }
		}
		modifier = {
			factor = 1.05
			NOT = { owner = { learning = 4 } }
		}
		modifier = {
			factor = 1.05
			NOT = { owner = { learning = 5 } }
		}
		modifier = {
			factor = 1.05
			NOT = { owner = { learning = 6 } }
		}
		modifier = {
			factor = 1.05
			NOT = { owner = { learning = 7 } }
		}
		modifier = {
			factor = 1.05
			NOT = { owner = { learning = 8 } }
		}
		modifier = {
			factor = 1.05
			NOT = { owner = { learning = 9 } }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 11 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 12 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 13 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 14 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 15 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 16 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 17 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 18 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 19 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 20 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 21 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 22 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 23 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 24 }
		}
		modifier = {
			factor = 0.95
			owner = { learning = 25 }
		}
		modifier = {
			factor = 0.9
			owner = { demesne_size = 2 }
		}
		modifier = {
			factor = 0.9
			owner = { demesne_size = 3 }
		}
		modifier = {
			factor = 0.9
			owner = { demesne_size = 4 }
		}
		modifier = {
			factor = 0.9
			owner = { demesne_size = 5 }
		}
		modifier = {
			factor = 0.9
			owner = { demesne_size = 6 }
		}
		modifier = {
			factor = 0.9
			owner = { demesne_size = 7 }
		}
		modifier = {
			factor = 0.9
			owner = { demesne_size = 8 }
		}
		modifier = {
			factor = 0.9
			religion_authority = 0.6
		}
		modifier = {
			factor = 0.9
			religion_authority = 0.7
		}
		modifier = {
			factor = 0.9
			religion_authority = 0.8
		}
		modifier = {
			factor = 0.9
			religion_authority = 0.9
		}
		modifier = {
			factor = 1.1
			NOT = { religion_authority = 0.5 }
		}
		modifier = {
			factor = 1.1
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor = 1.1
			NOT = { religion_authority = 0.3 }
		}
		modifier = {
			factor = 1.1
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 2.0
			owner = { trait = cynical }
		}
		modifier = {
			factor = 2.0
			NOT = {
				any_neighbor_province = {
					has_owner = yes
					religion = ROOT
				}
			}
		}
		modifier = {
			factor = 3
			has_game_rule = {
				name = religious_conversion
				value = slower
			}
		}
	}
	option = {
		name = "EVTOPTA39500"
		owner = {
			piety = 25
			add_character_modifier = { name = "convert_province_timer" duration = 3 hidden = yes }
		}

		if = {
			limit = {
				owner = {
					is_heretic = no
					ROOT = {
						NOT = { is_heresy_of = PREV }
					}
				}
			}
			owner = {
				religion_authority = {
					modifier = converted_province_to
				}
			}
			religion_authority = {
				modifier = converted_province_from
			}
		}

		owner = {
			ROOT = {
				religion = PREV
			}
		}
		
		hidden_tooltip = {
			owner = {
				top_liege = {
					if = {
						limit = {
							NOT = { character = PREV }
						}
						character_event = { id = 39501 days = 1 }
					}
					any_vassal = {
						limit = {
							NOT = { character = PREVPREV }
							higher_tier_than = baron
						}
						character_event = { id = 39501 days = 1 }
					}
				}
			}
		}
	}
}

# News of the conversion spreads in realm
character_event = {
	id = 39501
	desc = EVTDESC39501
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	notification = yes
	
	option = {
		name = "EVTOPTA39501"
		trigger = {
			NOT = { religion = FROM }
		}
	}
	option = {
		name = "EVTOPTA39500"
		trigger = {
			religion = FROM
		}
	}
}

##########################
### Proselytize Events ###
##########################

# Preacher Arrives
character_event = {
	id = 39600
	desc = EVTDESC39600
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	option = {
		name = EVTOPTB39600 #Allow them to preach
		ai_chance = {
			factor = 1
			
			# Year
			modifier = {
				factor = 0.5
				NOT = { year = 850 }
				NOT = { culture = hungarian }
			}
			modifier = {
				factor = 1.2
				year = 1000
			}
			modifier = {
				factor = 1.2
				year = 1050
			}
			modifier = {
				factor = 1.2
				year = 1100
			}
			
			# Traits
			modifier = {
				factor = 0.3
				trait = zealous
			}
			modifier = {
				factor = 3
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = {
				factor = 2
				trait = kind
			}
			
			# Culture of Preacher
			modifier = {
				factor = 1.5
				FROM = {
					culture_group = ROOT
					NOT = { culture = ROOT }
				}
			}
			modifier = {
				factor = 2
				FROM = { culture = ROOT }
			}
			
			# Personal
			modifier = {
				factor = 0.3
				FROM = {
					OR = {
						is_rival = ROOT
						any_liege = { is_rival = ROOT }
					}
				}
			}
			modifier = {
				factor = 3
				FROM = {
					liege = {
						OR = {
							is_allied_with = ROOT
							has_non_aggression_pact_with = ROOT
						}
					}
				}
			}
			modifier = {
				factor = 0.75
				FROM = {
					liege = {
						NOT = { reverse_opinion = { who = ROOT value = -50 } }
					}
				}
			}
			modifier = {
				factor = 0.5
				FROM = {
					liege = {
						NOT = { reverse_opinion = { who = ROOT value = -75 } }
					}
				}
			}
			modifier = {
				factor = 1.5
				FROM = {
					liege = { reverse_opinion = { who = ROOT value = 25 } }
				}
			}
			modifier = {
				factor = 1.5
				FROM = {
					liege = { reverse_opinion = { who = ROOT value = 50 } }
				}
			}
			modifier = {
				factor = 1.5
				FROM = {
					liege = { reverse_opinion = { who = ROOT value = 75 } }
				}
			}
			modifier = {
				factor = 1.5
				OR = {
					any_spouse = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_consort = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_lover = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_child = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
				}
			}
			
			# Political
			modifier = {
				factor = 0.2
				OR = {
					controls_religion = yes
					any_vassal = {
						religion = ROOT
						controls_religion = yes
					}
				}
			}
			modifier = {
				factor = 0.1
				any_war = {
					using_cb = holy_war
					attacker = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 0.1
				any_war = {
					using_cb = viking_invasion
					attacker = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 4
				any_war = {
					using_cb = holy_war
					defender = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 4
				any_war = {
					using_cb = crusade
					defender = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 2
				any_realm_province = {
					religion = FROM
				}
			}
			
			# Historical
			modifier = {
				factor = 0.3
				culture_group = altaic
				NOT = { year = 1200 }
			}
			modifier = {
				factor = 2
				culture_group = east_slavic # Historical outcome
				FROM = {
					OR = {
						religion = chalcedonian
						religion = orthodox
						religion = bogomilist
						religion = monothelite
						religion = iconoclast
					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 2
				culture_group = north_germanic # Historical outcome
				FROM = {
					OR = {
						religion = chalcedonian
 						religion = catholic
						religion = cathar
						religion = fraticelli
						religion = waldensian
						religion = lollard
						religion = adoptionist
 					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 2
				NOT = { government = nomadic_government }  # We're already adopting civilized ways...
				NOT = { government = tribal_government }
			}
			modifier = {
				factor = 0.2
				OR = {
					culture = old_saxon
					culture_group = baltic
					culture_group = finno_ugric  # The most stubborn pagans
				}
				
			}
			modifier = {
				factor = 0.2
				culture_group = east_slavic # Like alcohol
				FROM = {
					religion_group = muslim
				}
			}
			modifier = {
				factor = 0.2
				culture_group = north_germanic # Vikings do like their alcohol
				FROM = {
					religion_group = muslim
				}
			}
			
			# Pragmatism
			modifier = {
				factor = 3  # Powerful rulers want a modern religion
				tier = KING
				realm_size = 12
			}
			modifier = {
				factor = 0.2
				is_reformed_pagan_religion = no
				OR = {
					AND = {
						any_realm_title = {
							count = 3 
							is_holy_site = ROOT  # Close to reforming own religion instead
						}
						religion_authority = 0.4
					}
					religion_authority = 0.65 # Just very high authority, doing well
				}
			}
			modifier = {
				factor = 2
				any_realm_province = {
					any_neighbor_province = {
						owner = {
							top_liege = {
								religion = FROM
								relative_power = { who = ROOT power = 2.0 } # Powerful neighbor of that religion
							}
						}
					}
				}
			}
			modifier = {
				factor = 0.2
				NOR = {
					religion = tengri_pagan
					religion = aztec
					any_realm_province = {
						any_neighbor_province = {
							owner = {
								top_liege = {
									NAND = {
										is_pagan_religion = yes
										is_reformed_pagan_religion = no
									}
									any_realm_province = { TECH_RECRUITMENT = 4 } # More cocky when pagan homeland attrition effect is active against neighbors
								}
							}
						}
					}
				}
			}

			# Religious Authority
			modifier = {
				factor = 1.2
				NOT = { religion_authority = 0.5 }
			}
			modifier = {
				factor = 1.2
				NOT = { religion_authority = 0.4 }
			}
			modifier = {
				factor = 1.2
				NOT = { religion_authority = 0.3 }
			}
			modifier = {
				factor = 1.2
				NOT = { religion_authority = 0.2 }
			}
		}
		custom_tooltip = { text = preacher_allowed }
		FROM = {
			set_character_flag = preacher_arrives
			liege = { opinion = { who = ROOT modifier = opinion_allowed_missionary months = 60 } }
			hidden_tooltip = {
				character_event = { id = 39612 days = 1 }
			}
		}
	}
	option = {
		name = EVTOPTC39600 # Send them back home
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0.5
				trait = zealous
			}
			# Always allow them if you already like that religion
			modifier = {
				factor = 0
				FROM = { religion_group = christian }
				trait = sympathy_christendom
			}
			modifier = {
				factor = 0
				FROM = { religion_group = muslim }
				trait = sympathy_islam
			}
			modifier = {
				factor = 0
				FROM = { religion_group = jewish_group }
				trait = sympathy_judaism
			}
			modifier = {
				factor = 0
				FROM = { religion_group = zoroastrian_group }
				trait = sympathy_zoroastrianism
			}
			modifier = {
				factor = 0
				FROM = { religion_group = indian_group }
				trait = sympathy_indian
			}
		}
		custom_tooltip = { text = preacher_banished }
		FROM = {
			hidden_tooltip = {
				character_event = { id = 39618 days = 1 }
			}
		}
	}
	option = {
		name = EVTOPTA39600 # Throw the preacher in jail
		ai_chance = {
			factor = 1
			# Not unless certain conditions apply
			modifier = {
				factor = 0
				FROM = { liege = { relative_power = { who = ROOT power = 1.5 } } }
				NOR = {
					trait = lunatic
					trait = possessed
					trait = brave
				}
			}
			modifier = {
				factor = 0
				NOR = {
					trait = zealous
					trait = wroth
					trait = lunatic
					trait = possessed
				}
			}
			modifier = {
				factor = 0
				trait = cynical
			}	
			modifier = {
				factor = 2
				trait = zealous
			}
			# Always allow them if you already like that religion
			modifier = {
				factor = 0
				FROM = { religion_group = christian }
				trait = sympathy_christendom
			}
			modifier = {
				factor = 0
				FROM = { religion_group = muslim }
				trait = sympathy_islam
			}
			modifier = {
				factor = 0
				FROM = { religion_group = jewish_group }
				trait = sympathy_judaism
			}
			modifier = {
				factor = 0
				FROM = { religion_group = zoroastrian_group }
				trait = sympathy_zoroastrianism
			}
			modifier = {
				factor = 0
				FROM = { religion_group = indian_group }
				trait = sympathy_indian
			}
		}
		prestige = 50
		FROM = {
			set_character_flag = imprisoned_converter
			imprison = ROOT
			liege = {
				if = {
					limit = {
						any_realm_title = {
							tier = COUNT
							location = {
								any_neighbor_province = {
									owner = {
										OR = {
											character = ROOT
											is_liege_or_above = ROOT
										}
									}
								}
							}
						}
					}
					custom_tooltip = { text = will_get_claim }
				}
				set_character_flag = ai_failed_mission # AI flag - used in the code
				opinion = { who = ROOT modifier = opinion_imprisoned_missionary months = 60 }
				hidden_tooltip = {
					reverse_opinion = { modifier = opinion_sent_preacher who = ROOT }
					character_event = { id = 39605 days = 1 }
				}
			}
		}
	}
}

# Chaplain is allowed to stay in foreign realm (bounce event)
character_event = {
	id = 39612
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		liege = {
			letter_event = { id = 39604 }
		}
	}
}

# Liege informed that chaplain is allowed to stay in foreign realm
letter_event = {
	id = 39604
	desc = EVTDESC39604
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39604
		piety = 20
	}
}

# Chaplain sent back home (bounce event}
character_event = {
	id = 39618
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		liege = {
			letter_event = { id = 39619 }
		}
	}
}

# Liege informed that chaplain is being sent back home
letter_event = {
	id = 39619
	border = GFX_event_letter_frame_religion
	
	desc = {
		text = EVTDESC39619
		trigger = {
			FROM = {
				NOR = {
					trait = craven
					trait = cynical
					trait = paranoid
					NOT = { opinion = { who = ROOT value = -25 } }
				}
			}
		}
	}
	desc = {
		text = EVTDESC39619_coward
		trigger = {
			FROM = {
				OR = {
					trait = craven
					trait = cynical
					trait = paranoid
					NOT = { opinion = { who = ROOT value = -25 } }
				}
			}
		}
	}
	
	is_triggered_only = yes

	option = {
		name = EVTOPTA39619 # Stay and preach in hiding
		trigger = {
			FROM = {
				NOR = {
					trait = craven
					trait = cynical
					trait = paranoid
					NOT = { opinion = { who = ROOT value = -25 } }
				}
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.5
				trait = diligent
			}
			modifier = {
				factor = 0
				OR = {
					is_close_relative = FROM
					trait = cynical
					trait = patient
					trait = paranoid
				}
			}
		}
		custom_tooltip = { text = preacher_stays }
		FROM = { set_character_flag = preacher_hidden }
	}
	option = {
		name = {
			text = EVTOPTB39619 # They should come home
			trigger = {
				FROM = {
					NOR = {
						trait = craven
						trait = cynical
						trait = paranoid
						NOT = { opinion = { who = ROOT value = -25 } }
					}
				}
			}
		}
		name = {
			text = I_SEE
			trigger = {
				FROM = {
					OR = {
						trait = craven
						trait = cynical
						trait = paranoid
						NOT = { opinion = { who = ROOT value = -25 } }
					}
				}
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 0.1
				OR = {
					trait = zealous
					trait = proud
					trait = wroth
				}
			}
		}
		set_character_flag = ai_failed_mission # AI flag - used in the code
		hidden_tooltip = {
			reverse_opinion = { modifier = opinion_sent_preacher who = FROMFROM }
		}
		FROM = {
			cancel_job_action = action_inquisition
		}
	}
}

# Liege informed Chaplain imprisoned on arrival
character_event = {
	id = 39605
	desc = EVTDESC39605
	picture = GFX_evt_torture
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39605
		FROM = {
			random_realm_title = {
				limit = {
					tier = COUNT
					NOT = { claimed_by = ROOT }
					holder_scope = {
						OR = {
							character = PREVPREV
							is_liege_or_above = PREVPREV
						}
					}
					location = {
						any_neighbor_province = {
							owner = {
								OR = {
									character = ROOT
									is_liege_or_above = ROOT
								}
							}
						}
					}
				}
				add_claim = ROOT
			}
			reverse_opinion = { who = ROOT modifier = holy_war_sanction months = 6 }
		}
	}
}

# Ruler is approached by Chaplain -- convert or not?
character_event = {
	id = 39601
	desc = EVTDESC39601
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
 	trigger = {
		FROMs_religion_is_playable = yes
	}
	
	is_triggered_only = yes
	
	trigger = {
		can_change_religion = yes
	}
	
	option = {
		name = EVTOPTA39601 #Convert
		if = {
			limit = { FROMs_religion_is_playable = no }
			custom_tooltip = { text = you_will_game_over_tt }
		}
		ai_chance = {
			factor = 1
			# Year
			modifier = {
				factor = 0.5
				NOT = { year = 850 }
				NOT = { culture = hungarian }
			}
			modifier = {
				factor = 1.2
				year = 1000
			}
			modifier = {
				factor = 1.2
				year = 1050
			}
			modifier = {
				factor = 1.2
				year = 1100
			}

			# Traits
			modifier = {
				factor = 0.3
				trait = zealous
			}
			modifier = {
				factor = 3
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = {
				factor = 3
				FROM = { religion_group = christian }
				trait = sympathy_christendom
			}
			modifier = {
				factor = 3
				FROM = { religion_group = muslim }
				trait = sympathy_islam
			}
			modifier = {
				factor = 3
				FROM = { religion_group = jewish_group }
				trait = sympathy_judaism
			}
			modifier = {
				factor = 3
				FROM = { religion_group = zoroastrian_group }
				trait = sympathy_zoroastrianism
			}
			modifier = {
				factor = 3
				FROM = { religion_group = indian_group }
				trait = sympathy_indian
			}
			
			# Personal
			modifier = {
				factor = 0.3
				FROM = {
					OR = {
						is_rival = ROOT
						liege = { is_rival = ROOT }
					}
				}
			}
			modifier = {
				factor = 1.5
				OR = {
					any_spouse = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_consort = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_lover = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_child = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
				}
			}

			# Culture of Preacher
			modifier = {
				factor = 1.25
				FROM = {
					culture_group = ROOT
					NOT = { culture = ROOT }
				}
			}
			modifier = {
				factor = 1.5
				FROM = { culture = ROOT }
			}

			# Political
			modifier = {
				factor = 0.2
				any_vassal = {
					religion = ROOT
					controls_religion = yes
				}
			}
			modifier = {
				factor = 0.1
				any_war = {
					using_cb = holy_war
					attacker = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 0.1
				any_war = {
					using_cb = viking_invasion
					attacker = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 4
				any_war = {
					using_cb = holy_war
					defender = {
						character = ROOT
					}
					NOT = { war_score = 50 }
				}
			}
			modifier = {
				factor = 4
				any_war = {
					using_cb = crusade
					defender = {
						character = ROOT
					}
					NOT = { war_score = 50 }
				}
			}
			
			# Historical			
			modifier = {
				factor = 2
				NOT = { government = nomadic_government }  # We're already adopting civilized ways...
				NOT = { government = tribal_government }
			}
			modifier = {
				factor = 0.2
				OR = {
					culture = old_saxon
					culture_group = baltic
					culture_group = finno_ugric  # The most stubborn pagans
				}
				
			}
			modifier = {
				factor = 0.2
				culture_group = east_slavic # Like alcohol
				FROM = {
					religion_group = muslim
				}
			}
			modifier = {
				factor = 0.2
				culture_group = north_germanic # Vikings do like their alcohol
				FROM = {
					religion_group = muslim
				}
			}
			modifier = {
				factor = 0.2
				religion = bon
			}
			modifier = {
				factor = 2
				culture_group = east_slavic # Historical outcome
				FROM = {
					OR = {
						religion = chalcedonian
						religion = orthodox
						religion = bogomilist
						religion = monothelite
						religion = iconoclast
					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 2
				culture_group = north_germanic # Historical outcome
				FROM = {
					OR = {
						religion = chalcedonian
 						religion = catholic
						religion = cathar
						religion = fraticelli
						religion = waldensian
						religion = lollard
						religion = adoptionist
 					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 0.3
				culture_group = altaic
				NOT = { year = 1200 }
			}
			
			# Pragmatism
			modifier = {
				factor = 3  # Powerful rulers want a modern religion
				tier = KING
				realm_size = 12
			}
			modifier = {
				factor = 0
				is_reformed_pagan_religion = yes
			}
			modifier = {
				factor = 0.3
				is_reformed_pagan_religion = no
				OR = {
					AND = {
						any_realm_title = {
							count = 3 
							is_holy_site = ROOT  # Close to reforming own religion instead
						}
						religion_authority = 0.4
					}
					religion_authority = 0.65 # Just very high authority, doing well
				}
			}
			modifier = {
				factor = 2
				any_realm_province = {
					any_neighbor_province = {
						owner = {
							top_liege = {
								religion = FROM
								relative_power = { who = ROOT power = 2.0 } # Powerful neighbor of that religion
							}
						}
					}
				}
			}
			modifier = {
				factor = 0.2
				NOR = {
					religion = tengri_pagan
					religion = aztec
					any_realm_province = {
						any_neighbor_province = {
							owner = {
								top_liege = {
									NAND = {
										is_pagan_religion = yes
										is_reformed_pagan_religion = no
									}
									any_realm_province = { TECH_RECRUITMENT = 4 } # More cocky when pagan homeland attrition effect is active against neighbors
								}
							}
						}
					}
				}
			}

			# Realm stability
			modifier = {
				factor = 10
				num_of_vassals = 3
				NOT = {
					any_vassal = {
						NOT = { religion = FROM }
					}
				}
			}
			modifier = {
				factor = 10
				NOT = {
					any_realm_province = {
						NOT = { religion = FROM }
					}
				}
			}
			modifier = {
				factor = 0.5
				NOT = {
					any_realm_province = {
						religion = FROM
					}
				}
			}
			modifier = {
				factor = 0.3
				any_vassal = {
					count = 3
					OR = {
						AND = {
							ROOT = { higher_tier_than = DUKE }
							tier = DUKE
						}
						AND = {
							ROOT = { tier = DUKE }
							tier = COUNT
						}
					}
					NOT = { opinion = { who = ROOT value = 0 } }
					NOT = { religion = FROM }
				}
			}
			modifier = {
				factor = 0.3
				any_war = {
					NOT  = {
						using_cb = holy_war
						defender = {
							character = ROOT
						}
					}
					NOT  = {
						using_cb = crusade
						defender = {
							character = ROOT
						}
					}
					NOT = { war_score = 50 }
				}
			}
			modifier = {
				factor = 0.3
				any_war = {
					NOT  = {
						using_cb = holy_war
						defender = {
							character = ROOT
						}
					}
					NOT  = {
						using_cb = crusade
						defender = {
							character = ROOT
						}
					}
					NOT = { war_score = 10 }
				}
			}
		}
		custom_tooltip = { text = preacher_convert }
		if = {
			limit = {
				trait = cynical
				NOT = { trait = zealous }
				age = 12
			}
			random = {
				chance = 75
				add_trait = sympathy_pagans
			}
		}
		if = {
			limit = {
				NOR = { 
					trait = cynical
					trait = zealous
				}
				age = 12
			}
			random = {
				chance = 50
				add_trait = sympathy_pagans
			}
		}		
		prestige = -500
		if = {
			limit = { higher_tier_than = BARON }
			religion_authority = {
				modifier = ruler_converted_from
			}
		}
		hidden_tooltip = {
			if = {
				limit = { NOT = { religion_group = FROM } }
				FROM = { set_character_flag = religion_group_convert }
				if = {
					limit = { higher_tier_than = DUKE }
					set_character_flag = king_converted
				}
			}
		}
		religion = FROM
		if = {
			limit = { higher_tier_than = BARON }
			hidden_tooltip = {
				religion_authority = {
					modifier = ruler_converted_to
				}
			}
		}
		piety = 250
		if = {
			limit = { ai = yes }
			capital_scope = { religion = FROM }
		}
		hidden_tooltip = {
			any_courtier = {
				limit = {
					is_ruler = no
					dynasty = ROOT
				}
				religion = ROOT
			}
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = ROOT
			religion = FROM
			female = no
			age = 32
			attributes = {
				learning = 20
				diplomacy = 10
			}
		}
		new_character = {
			hidden_tooltip = {
				if = {
					limit = {
						religion_group = christian
						NOR = {
							religion = cathar
							religion = bogomilist
							religion = miaphysite
							religion = monophysite
						}
					}
					if = {
						limit = { is_female = no }
						change_learning = 1
						add_trait = monk
						set_character_flag = title_monk
						set_special_character_title = MONK_BROTHER
					}
					if = {
						limit = { is_female = yes }
						change_learning = 1
						add_trait = nun
						set_character_flag = title_nun
						set_special_character_title = NUN_SISTER
					}
				}
				if = {
					limit = {
						OR = {
							religion = miaphysite
							religion = monophysite
						}
					}
					if = {
						limit = { is_female = yes }
						add_trait = desert_mother
						set_character_flag = title_desert_mother
						set_special_character_title = DESERT_MOTHER_TITLE
					}
					if = {
						limit = { is_female = no }
						add_trait = desert_father
						set_character_flag = title_desert_father
						set_special_character_title = DESERT_FATHER_TITLE
					}
				}
				if = {
					limit = {
						OR = {
							religion = cathar
							religion = bogomilist
						}
					}
					remove_trait = incapable
					remove_trait = cynical
					remove_trait = lustful
					remove_trait = hedonist
					remove_trait = seducer
					remove_trait = seductress
					add_trait = zealous
					add_trait = perfecti
					set_character_flag = consolamentum_taken
					if = {
						limit = { is_female = no }
						set_character_flag = title_monk
						set_special_character_title = MONK_BROTHER
					}
					if = {
						limit = { is_female = yes }
						set_character_flag = title_nun
						set_special_character_title = NUN_SISTER
					}
				}
				if = {
					limit = { religion_group = jewish_group }
					random = {
						chance = 70
						add_trait = yehudi
					}
				}
				set_character_flag = yehudi_check
				if = { 
					limit = {
						OR = {
							religion = celtic_pagan
							religion = celtic_pagan_reformed
						}
					}
					add_trait = druid
				}
				if = {
					limit = {
						religion_group = indian_group
						NOT = { religion = taoist }
						NOT = { religion = bon }
					}
					add_trait = brahmin
					character_event = { id = RoI.30121 }
				}
			}
			give_job_title = job_spiritual
			save_event_target_as = convert_lord_spiritual
		}
		hidden_tooltip = {
			any_vassal = {
				limit = {
					NOT = { religion = ROOT }
					ROOT = { ai = yes } # Only for AI!
				}
				letter_event = { id = 39617 } # Send out letter to vassals
			}
			FROM = {
				character_event = { id = 39614 days = 1 } # Notify chaplain
			}
		}
	}
	option = {
		name = EVTOPTB39601 #Banish the preacher
		ai_chance = {
			factor = 1
		}
		custom_tooltip = { text = preacher_banished }
		FROM = {
			clr_character_flag = preacher_arrives
			liege = {
				opinion = { who = ROOT modifier = opinion_banished_missionary months = 60 }
			}
			hidden_tooltip = {
				character_event = { id = 39613 days = 1 }
			}
		}
	}
}

# Ruler has been converted -- notify vassals
letter_event = {
	id = 39617
	desc = EVTDESC_39617
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_39617 # Convert
		ai_chance = {
			factor = 1
			
			# Traits
			modifier = {
				factor = 0.3
				trait = zealous
			}
			modifier = {
				factor = 3
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = {
				factor = 0
				relative_power = { who = FROM power = 1.0 } # Very powerful vassal who is also zealous NEVER accepts
				trait = zealous
			}
			
			# Personal
			modifier = {
				factor = 0.3
				FROM = {
					is_rival = ROOT
				}
			}
			modifier = {
				factor = 1.5
				OR = {
					any_spouse = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_consort = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_lover = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_child = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
				}
			}
			
			# Historical			
			modifier = {
				factor = 2
				NOT = { government = nomadic_government }  # We're already adopting civilized ways...
				NOT = { government = tribal_government }
			}
			modifier = {
				factor = 0.2
				OR = {
					culture_group = baltic
					culture_group = finno_ugric  # The most stubborn pagans
				}
			}
			modifier = {
				factor = 0.2
				culture_group = east_slavic # Like alcohol
				FROM = {
					religion_group = muslim
				}
			}
			modifier = {
				factor = 0.2
				culture_group = north_germanic # Vikings do like their alcohol
				FROM = {
					religion_group = muslim
				}
			}
			modifier = {
				factor = 3
				culture_group = east_slavic # Historical outcome
				FROM = {
					OR = {
						religion = chalcedonian
						religion = orthodox
						religion = bogomilist
						religion = monothelite
						religion = iconoclast
					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 3
				culture_group = north_germanic # Historical outcome
				FROM = {
					OR = {
						religion = chalcedonian
 						religion = catholic
						religion = cathar
						religion = fraticelli
						religion = waldensian
						religion = lollard
						religion = adoptionist
 					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 0.3
				culture_group = altaic
				NOT = { year = 1200 }
			}
		}
		prestige = -250
		if = {
			limit = { higher_tier_than = COUNT }
			religion_authority = {
				modifier = ruler_converted_from
			}
		}
		religion = FROM
		if = {
			limit = { higher_tier_than = COUNT }
			religion_authority = {
				modifier = ruler_converted_to
			}
		}
		hidden_tooltip = {
			any_courtier = {
				limit = {
					is_adult = no
					is_ruler = no
					dynasty = ROOT
				}
				religion = ROOT
			}
			any_spouse = {
				limit = { is_consort = no }
				religion = FROM
			}
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = ROOT
			religion = FROM
			female = no
			attributes = {
				learning = 20
				diplomacy = 10
			}
		}
		new_character = {
			give_job_title = job_spiritual
		}
	}
	option = {
		name = EVTOPTB_39617 # Don't convert
		ai_chance = {
			factor = 1
		}
		piety = 100
	}
	option = {
		name = EVTOPTC_39617 # Respond with anger
		ai_chance = {
			factor = 0
		}
		prestige = 100
		piety = 100
		reverse_opinion = {
			modifier = opinion_angry
			who = ROOT
			years = 5
		}
	}
}

# Ruler has been converted -- notify chaplain (bounce event)
character_event = {
	id = 39614
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = { NOT = { has_character_flag = religion_group_convert } }
			if = {
				limit = {
					FROM = {
						is_ruler = yes
						lower_tier_than = DUKE
					}
				}
				piety = 25
			}
			if = {
				limit = {
					FROM = {
						is_ruler = yes
						tier = DUKE
					}
				}
				piety = 50
			}
			if = {
				limit = {
					FROM = {
						is_ruler = yes
						higher_tier_than = DUKE
					}
				}
				piety = 100
			}
		}
		if = {
			limit = { has_character_flag = religion_group_convert }
			clr_character_flag = religion_group_convert
			if = {
				limit = {
					FROM = {
						is_ruler = yes
						lower_tier_than = DUKE
					}
				}
				piety = 50
			}
			if = {
				limit = {
					FROM = {
						is_ruler = yes
						tier = DUKE
					}
				}
				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 = {
					FROM = {
						is_ruler = yes
						higher_tier_than = DUKE
					}
				}
				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
			}
		}
		liege = {
			letter_event = { id = 39606 }
		}
	}
}

# Ruler has been converted -- notify chaplain's liege
letter_event = {
	id = 39606
	desc = EVTDESC39606
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39606
		tooltip = {
			FROMFROM = {
				religion = FROM
			}
		}
		FROM = { cancel_job_action = action_inquisition }
		piety = 200
	}
}

# Chaplain has been banished after failing to convert ruler (bounce event) 
character_event = {
	id = 39613
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		liege = {
			letter_event = { id = 39607 }
		}
	}
}

# Liege informed of Chaplain's failure
letter_event = {
	id = 39607
	border = GFX_event_letter_frame_religion
	
	desc = {
		text = EVTDESC39607_can_stay
		trigger = {
			FROM = {
				NOR = {
					trait = craven
					trait = cynical
					trait = paranoid
					NOT = { opinion = { who = ROOT value = -25 } }
				}
			}
		}
	}
	desc = {
		text = EVTDESC39607
		trigger = {
			FROM = {
				OR = {
					trait = craven
					trait = cynical
					trait = paranoid
					NOT = { opinion = { who = ROOT value = -25 } }
				}
			}
		}
	}
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39619 # Stay and preach in hiding
		trigger = {
			FROM = {
				NOR = {
					trait = craven
					trait = cynical
					trait = paranoid
					NOT = { opinion = { who = ROOT value = -25 } }
				}
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.5
				trait = diligent
			}
			modifier = {
				factor = 0
				OR = {
					is_close_relative = FROM
					trait = cynical
					trait = patient
					trait = paranoid
				}
			}
		}
		custom_tooltip = { text = preacher_stays }
		FROM = { set_character_flag = preacher_hidden }
	}
	option = {
		name = {
			text = EVTOPTB39619 # They should come home
			trigger = {
				FROM = {
					NOR = {
						trait = craven
						trait = cynical
						trait = paranoid
						NOT = { opinion = { who = ROOT value = -25 } }
					}
				}
			}
		}
		name = {
			text = I_SEE
			trigger = {
				FROM = {
					OR = {
						trait = craven
						trait = cynical
						trait = paranoid
						NOT = { opinion = { who = ROOT value = -25 } }
					}
				}
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 0.1
				OR = {
					trait = zealous
					trait = proud
					trait = wroth
				}
			}
		}
		set_character_flag = ai_failed_mission # AI flag - used in the code
		hidden_tooltip = {
			reverse_opinion = { modifier = opinion_sent_preacher who = FROMFROM }
		}
		FROM = { cancel_job_action = action_inquisition }
	}
}

# Chaplain converts courtier
character_event = {
	id = 39610
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		if = {
			limit = {
				NOT = { 
					trait = cynical 
					trait = zealous 
				}
				age = 12
			}
			random = {
				chance = 50
				add_trait = sympathy_pagans
			}
		}
		religion = FROM
		if = {
			limit = {
				OR = {
					liege = { is_close_relative = ROOT }
					liege = { dynasty = ROOT }
					is_voter = yes
					is_ruler = yes
				}
			}
			liege = {
				character_event = { id = 39602 }
			}
		}
	}
}

# Ruler notified that chaplain converted courtier
character_event = {
	id = 39602
	desc = EVTDESC39602
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39602 #Banish the preacher
		ai_chance = {
			factor = 2
			modifier = {
				factor = 0.75
				FROMFROM = {
					liege = {
						culture_group = ROOT
						NOT = { culture = ROOT }
					}
				}
			}
			modifier = {
				factor = 0.5
				FROMFROM = { liege = { culture = ROOT } }
			}
			modifier = {
				factor = 0.5
				FROMFROM = { liege = { is_allied_with = ROOT } }
			}
			modifier = {
				factor = 0.5
				FROMFROM = {
					liege = {
						relative_power = { who = ROOT power = 2.0 }
						any_realm_province = {
							any_neighbor_province = {
								owner = {
									OR = {
										same_realm = ROOT
										character = ROOT
									}
								}
							}
						}
					}
				}
			}
			modifier = {
				factor = 3
				trait = zealous
			}
			modifier = {
				factor = 5
				any_vassal = { controls_religion = yes }
			}
			modifier = {
				factor = 1.5
				FROMFROM = {
					liege = {
						NOT = { reverse_opinion = { who = ROOT value = -25 } }
					}
				}
			}
			modifier = {
				factor = 2
				FROMFROM = {
					liege = {
						NOT = { reverse_opinion = { who = ROOT value = -50 } }
					}
				}
			}
			modifier = {
				factor = 2.5
				FROMFROM = {
					liege = {
						NOT = { reverse_opinion = { who = ROOT value = -75 } }
					}
				}
			}
			modifier = {
				factor = 5
				NOT = { year = 850 }
				NOT = { culture_group = magyar }
			}
			modifier = {
				factor = 5
				culture_group = baltic # The most stubborn pagans
			}
			modifier = {
				factor = 4
				culture_group = altaic
				NOT = { year = 1100 }
			}
			modifier = {
				factor = 3
				culture_group = east_slavic # Angry at Muslim Tatars, also like alcohol
				FROMFROM = {
					religion_group = muslim
				}
			}
			modifier = {
				factor = 5
				culture_group = north_germanic # Vikings do like their alcohol
				FROMFROM = {
					religion_group = muslim
				}
			}
			modifier = {
				factor = 10
				any_war = {
					using_cb = holy_war
					attacker = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 10
				any_war = {
					using_cb = viking_invasion
					attacker = {
						character = ROOT
					}
				}
			}
		}
		custom_tooltip = { text = preacher_banished }
		FROMFROM = {
			clr_character_flag = preacher_arrives
			liege = {
				opinion = { who = ROOT modifier = opinion_banished_missionary months = 60 }
			}
			hidden_tooltip = {
				character_event = { id = 39615 days = 1 }
			}
		}
	}
	option = {
		name = EVTOPTB39602 #Let it go
		ai_chance = {
			factor = 4
			modifier = {
				factor = 4
				culture_group = north_germanic # Historical outcome
				FROMFROM = {
					OR = {
						religion = chalcedonian
 						religion = catholic
						religion = cathar
						religion = fraticelli
						religion = waldensian
						religion = lollard
						religion = adoptionist
 					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 1.5
				FROMFROM = {
					liege = { reverse_opinion = { who = ROOT value = 25 } }
				}
			}
			modifier = {
				factor = 1.5
				FROMFROM = {
					liege = { reverse_opinion = { who = ROOT value = 50 } }
				}
			}
			modifier = {
				factor = 1.5
				FROMFROM = {
					liege = { reverse_opinion = { who = ROOT value = 75 } }
				}
			}
			modifier = {
				factor = 3
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = { #Tweaked by Battle bunny
				factor = 2
				trait = kind
			}
			modifier = {
				factor = 3
				NOT = { piety = 0 }
			}
			modifier = {
				factor = 1.2
				NOT = { religion_authority = 0.5 }
			}
			modifier = {
				factor = 1.2
				NOT = { religion_authority = 0.4 }
			}
			modifier = {
				factor = 1.2
				NOT = { religion_authority = 0.3 }
			}
			modifier = {
				factor = 1.2
				NOT = { religion_authority = 0.2 }
			}
			modifier = {
				factor = 4
				culture_group = east_slavic # Historical outcome
				FROMFROM = {
					OR = {
						religion = orthodox
						religion = bogomilist
						religion = paulician
						religion = monothelite
						religion = iconoclast
					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 4
				any_war = {
					using_cb = holy_war
					defender = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 4
				any_war = {
					using_cb = crusade
					defender = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 0.75
				NOT = { year = 850 }
			}
			modifier = {
				factor = 1.1
				year = 1000
			}
			modifier = {
				factor = 1.1
				year = 1025
			}
			modifier = {
				factor = 1.1
				year = 1050
			}
			modifier = {
				factor = 1.1
				year = 1075
			}
			modifier = {
				factor = 1.1
				year = 1100
			}
		}
		custom_tooltip = { text = preacher_allowed }
	}
}

# Chaplain banished after converting courtier (bounce event)
character_event = {
	id = 39615
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		liege = {
			letter_event = { id = 39608 }
		}
	}
}

# Liege informed Chaplain banished after converting courtier
letter_event = {
	id = 39608
	border = GFX_event_letter_frame_religion
	
	desc = {
		text = EVTDESC39608
		trigger = {
			FROM = {
				NOR = {
					trait = craven
					trait = cynical
					trait = paranoid
					NOT = { opinion = { who = ROOT value = -25 } }
				}
			}
		}
	}
	desc = {
		text = EVTDESC39608_coward
		trigger = {
			FROM = {
				OR = {
					trait = craven
					trait = cynical
					trait = paranoid
					NOT = { opinion = { who = ROOT value = -25 } }
				}
			}
		}
	}
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39619 # Stay and preach in hiding
		trigger = {
			FROM = {
				NOR = {
					trait = craven
					trait = cynical
					trait = paranoid
					NOT = { opinion = { who = ROOT value = -25 } }
				}
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.5
				trait = diligent
			}
			modifier = {
				factor = 0
				OR = {
					is_close_relative = FROM
					trait = cynical
					trait = patient
					trait = paranoid
				}
			}
		}
		custom_tooltip = { text = preacher_stays }
		FROM = { set_character_flag = preacher_hidden }
	}
	option = {
		name = {
			text = EVTOPTB39619 # They should come home
			trigger = {
				FROM = {
					NOR = {
						trait = craven
						trait = cynical
						trait = paranoid
						NOT = { opinion = { who = ROOT value = -25 } }
					}
				}
			}
		}
		name = {
			text = I_SEE
			trigger = {
				FROM = {
					OR = {
						trait = craven
						trait = cynical
						trait = paranoid
						NOT = { opinion = { who = ROOT value = -25 } }
					}
				}
			}
		}
		ai_chance = {
			factor = 50
			modifier = {
				factor = 1.5
				trait = slothful
			}
			modifier = {
				factor = 0.1
				OR = {
					trait = zealous
					trait = proud
					trait = wroth
				}
			}
		}
		set_character_flag = ai_failed_mission # AI flag - used in the code
		hidden_tooltip = {
			reverse_opinion = { modifier = opinion_sent_preacher who = FROMFROM }
		}
		FROM = { cancel_job_action = action_inquisition }
	}
}

# Chaplain fights with other Chaplain
character_event = {
	id = 39611
	desc = EVTDESC39653
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39653
		hidden_tooltip = {
			location = {
				owner = {
					character_event = { id = 39603 days = 1 }
				}
			}
		}
	}
}

# Ruler informed of preachers Squabbling
character_event = {
	id = 39603
	desc = EVTDESC39603
	picture = GFX_evt_child_sword
	border = GFX_event_normal_frame_religion
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39603
		hidden_tooltip = {
			FROMFROM = {
				character_event = { id = 39616 days = 1 }
			}
		}
		FROMFROM = {
			clr_character_flag = preacher_arrives
			liege = {
				opinion = { who = ROOT modifier = opinion_banished_missionary months = 60 }
				hidden_tooltip = {
					reverse_opinion = { modifier = opinion_sent_preacher who = ROOT }
				}
			}
		}
		FROM = {
			liege = {
				opinion = { modifier = opinion_supported_preacher who = ROOT }
			}
		}
	}
	option = {
		name = EVTOPTB39603
		hidden_tooltip = {
			FROM = {
				character_event = { id = 39616 days = 1 }
			}
		}
		FROM = {
			clr_character_flag = preacher_arrives
			liege = {
				opinion = { who = ROOT modifier = opinion_banished_missionary months = 60 }
				hidden_tooltip = {
					reverse_opinion = { modifier = opinion_sent_preacher who = ROOT }
				}
			}
		}
		FROMFROM = {
			liege = {
				opinion = { modifier = opinion_supported_preacher who = ROOT }
			}
		}
	}
	option = {
		name = EVTOPTC39603
		FROM = {
			liege = {
				opinion = {
					modifier = opinion_did_not_support_preacher
					who = ROOT
				}
			}
		}
		FROMFROM = {
			liege = {
				opinion = {
					modifier = opinion_did_not_support_preacher
					who = ROOT
				}
			}
		}
	}
}

# Chaplain banished after squabble (bounce event)
character_event = {
	id = 39616
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		liege = {
			letter_event = { id = 39609 }
		}
	}
}

# Liege informed Chaplain banished after squabble
letter_event = {
	id = 39609
	desc = EVTDESC39609
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39609
		FROM = { cancel_job_action = action_inquisition }
	}
}

# Ruler informed that Chaplain converted province
character_event = {
	id = 39620
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	desc = {
		text = EVTDESC39620
		trigger = {
			FROM = { NOT = { has_character_flag = preacher_hidden } }
		}
	}
	desc = {
		text = EVTDESC39620_hidden
		trigger = {
			FROM = { has_character_flag = preacher_hidden }
		}
	}
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39620 # Convert
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0.5
				FROM = { has_character_flag = preacher_hidden }
			}
			# Year
			modifier = {
				factor = 0.5
				NOT = { year = 850 }
				NOT = { culture = hungarian }
			}
			modifier = {
				factor = 1.2
				year = 1000
			}
			modifier = {
				factor = 1.2
				year = 1050
			}
			modifier = {
				factor = 1.2
				year = 1100
			}

			# Traits
			modifier = {
				factor = 0.3
				trait = zealous
			}
			modifier = {
				factor = 3
				trait = cynical
			}
			modifier = {
				factor = 2
				trait = arbitrary
			}
			modifier = {
				factor = 3
				FROM = { religion_group = christian }
				trait = sympathy_christendom
			}
			modifier = {
				factor = 3
				FROM = { religion_group = muslim }
				trait = sympathy_islam
			}
			modifier = {
				factor = 3
				FROM = { religion_group = jewish_group }
				trait = sympathy_judaism
			}
			modifier = {
				factor = 3
				FROM = { religion_group = zoroastrian_group }
				trait = sympathy_zoroastrianism
			}
			modifier = {
				factor = 3
				FROM = { religion_group = indian_group }
				trait = sympathy_indian
			}
			
			# Personal
			modifier = {
				factor = 0.3
				FROM = {
					OR = {
						is_rival = ROOT
						liege = { is_rival = ROOT }
					}
				}
			}
			modifier = {
				factor = 1.5
				OR = {
					any_spouse = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_consort = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_lover = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
					any_child = {
						religion = FROM
						reverse_opinion = { who = ROOT value = 50 }
					}
				}
			}

			# Culture of Preacher
			modifier = {
				factor = 1.25
				FROM = {
					culture_group = ROOT
					NOT = { culture = ROOT }
				}
			}
			modifier = {
				factor = 1.5
				FROM = { culture = ROOT }
			}

			# Political
			modifier = {
				factor = 0.2
				any_vassal = {
					religion = ROOT
					controls_religion = yes
				}
			}
			modifier = {
				factor = 0.1
				any_war = {
					using_cb = holy_war
					attacker = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 0.1
				any_war = {
					using_cb = viking_invasion
					attacker = {
						character = ROOT
					}
				}
			}
			modifier = {
				factor = 4
				any_war = {
					using_cb = holy_war
					defender = {
						character = ROOT
					}
					NOT = { war_score = 50 }
				}
			}
			modifier = {
				factor = 4
				any_war = {
					using_cb = crusade
					defender = {
						character = ROOT
					}
					NOT = { war_score = 50 }
				}
			}
			
			# Historical			
			modifier = {
				factor = 2
				NOT = { government = nomadic_government }  # We're already adopting civilized ways...
				NOT = { government = tribal_government }
			}
			modifier = {
				factor = 0.2
				OR = {
					culture = old_saxon
					culture_group = baltic
					culture_group = finno_ugric  # The most stubborn pagans
				}
				
			}
			modifier = {
				factor = 0.2
				culture_group = east_slavic # Like alcohol
				FROM = {
					religion_group = muslim
				}
			}
			modifier = {
				factor = 0.2
				culture_group = north_germanic # Vikings do like their alcohol
				FROM = {
					religion_group = muslim
				}
			}
			modifier = {
				factor = 2
				culture_group = east_slavic # Historical outcome
				FROM = {
					OR = {
						religion = chalcedonian
						religion = orthodox
						religion = bogomilist
						religion = monothelite
						religion = iconoclast
					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 2
				culture_group = north_germanic # Historical outcome
				FROM = {
					OR = {
						religion = chalcedonian
 						religion = catholic
						religion = cathar
						religion = fraticelli
						religion = waldensian
						religion = lollard
						religion = adoptionist
 					}
					is_heretic = no
				}
			}
			modifier = {
				factor = 0.3
				culture_group = altaic
				NOT = { year = 1200 }
			}
			
			# Pragmatism
			modifier = {
				factor = 3  # Powerful rulers want a modern religion
				tier = KING
				realm_size = 12
			}
			modifier = {
				factor = 0
				is_reformed_pagan_religion = yes
			}
			modifier = {
				factor = 0.3
				is_reformed_pagan_religion = no
				OR = {
					AND = {
						any_realm_title = {
							count = 3 
							is_holy_site = ROOT  # Close to reforming own religion instead
						}
						religion_authority = 0.4
					}
					religion_authority = 0.65 # Just very high authority, doing well
				}
			}
			modifier = {
				factor = 2
				any_realm_province = {
					any_neighbor_province = {
						owner = {
							top_liege = {
								religion = FROM
								relative_power = { who = ROOT power = 2.0 } # Powerful neighbor of that religion
							}
						}
					}
				}
			}
			modifier = {
				factor = 0.2
				NOR = {
					religion = tengri_pagan
					religion = aztec
					any_realm_province = {
						any_neighbor_province = {
							owner = {
								top_liege = {
									NAND = {
										is_pagan_religion = yes
										is_reformed_pagan_religion = no
									}
									any_realm_province = { TECH_RECRUITMENT = 4 } # More cocky when pagan homeland attrition effect is active against neighbors
								}
							}
						}
					}
				}
			}

			# Realm stability
			modifier = {
				factor = 10
				num_of_vassals = 3
				NOT = {
					any_vassal = {
						NOT = { religion = FROM }
					}
				}
			}
			modifier = {
				factor = 10
				NOT = {
					any_realm_province = {
						NOT = { religion = FROM }
					}
				}
			}
			modifier = {
				factor = 0.5
				NOT = {
					any_realm_province = {
						religion = FROM
					}
				}
			}
			modifier = {
				factor = 0.3
				any_vassal = {
					count = 3
					OR = {
						AND = {
							ROOT = { higher_tier_than = DUKE }
							tier = DUKE
						}
						AND = {
							ROOT = { tier = DUKE }
							tier = COUNT
						}
					}
					NOT = { opinion = { who = ROOT value = 0 } }
					NOT = { religion = FROM }
				}
			}
			modifier = {
				factor = 0.3
				any_war = {
					NOT  = {
						using_cb = holy_war
						defender = {
							character = ROOT
						}
					}
					NOT  = {
						using_cb = crusade
						defender = {
							character = ROOT
						}
					}
					NOT = { war_score = 50 }
				}
			}
			modifier = {
				factor = 0.3
				any_war = {
					NOT  = {
						using_cb = holy_war
						defender = {
							character = ROOT
						}
					}
					NOT  = {
						using_cb = crusade
						defender = {
							character = ROOT
						}
					}
					NOT = { war_score = 10 }
				}
			}
		}
		custom_tooltip = { text = preacher_convert }
		if = {
			limit = {
				trait = cynical
				NOT = { trait = zealous }
				age = 12
			}
			random = {
				chance = 75
				add_trait = sympathy_pagans
			}
		}
		if = {
			limit = {
				NOR = { 
					trait = cynical
					trait = zealous
				}
				age = 12
			}
			random = {
				chance = 50
				add_trait = sympathy_pagans
			}
		}		
		prestige = -500
		if = {
			limit = { higher_tier_than = BARON }
			religion_authority = {
				modifier = ruler_converted_from
			}
		}
		hidden_tooltip = {
			if = {
				limit = { NOT = { religion_group = FROM } }
				FROM = { set_character_flag = religion_group_convert }
				if = {
					limit = { higher_tier_than = DUKE }
					set_character_flag = king_converted
				}
			}
		}
		religion = FROM
		if = {
			limit = { higher_tier_than = BARON }
			hidden_tooltip = {
				religion_authority = {
					modifier = ruler_converted_to
				}
			}
		}
		piety = 250
		if = {
			limit = { ai = yes }
			capital_scope = { religion = FROM }
		}
		hidden_tooltip = {
			any_courtier = {
				limit = {
					is_ruler = no
					dynasty = ROOT
				}
				religion = ROOT
			}
		}
		create_random_priest = {
			random_traits = yes
			dynasty = random
			culture = ROOT
			religion = FROM
			female = no
			age = 32
			attributes = {
				learning = 20
				diplomacy = 10
			}
		}
		new_character = {
			hidden_tooltip = {
				if = {
					limit = {
						religion_group = christian
						NOR = {
							religion = cathar
							religion = bogomilist
							religion = miaphysite
							religion = monophysite
						}
					}
					if = {
						limit = { is_female = no }
						change_learning = 1
						add_trait = monk
						set_character_flag = title_monk
						set_special_character_title = MONK_BROTHER
					}
					if = {
						limit = { is_female = yes }
						change_learning = 1
						add_trait = nun
						set_character_flag = title_nun
						set_special_character_title = NUN_SISTER
					}
				}
				if = {
					limit = {
						OR = {
							religion = miaphysite
							religion = monophysite
						}
					}
					if = {
						limit = { is_female = yes }
						add_trait = desert_mother
						set_character_flag = title_desert_mother
						set_special_character_title = DESERT_MOTHER_TITLE
					}
					if = {
						limit = { is_female = no }
						add_trait = desert_father
						set_character_flag = title_desert_father
						set_special_character_title = DESERT_FATHER_TITLE
					}
				}
				if = {
					limit = {
						OR = {
							religion = cathar
							religion = bogomilist
						}
					}
					remove_trait = incapable
					remove_trait = cynical
					remove_trait = lustful
					remove_trait = hedonist
					remove_trait = seducer
					remove_trait = seductress
					add_trait = zealous
					add_trait = perfecti
					set_character_flag = consolamentum_taken
					if = {
						limit = { is_female = no }
						set_character_flag = title_monk
						set_special_character_title = MONK_BROTHER
					}
					if = {
						limit = { is_female = yes }
						set_character_flag = title_nun
						set_special_character_title = NUN_SISTER
					}
				}
				if = {
					limit = { religion_group = jewish_group }
					random = {
						chance = 70
						add_trait = yehudi
					}
				}
				set_character_flag = yehudi_check
				if = { 
					limit = {
						OR = {
							religion = celtic_pagan
							religion = celtic_pagan_reformed
						}
					}
					add_trait = druid
				}
				if = {
					limit = {
						religion_group = indian_group
						NOT = { religion = taoist }
						NOT = { religion = bon }
					}
					add_trait = brahmin
					character_event = { id = RoI.30121 }
				}
			}
			give_job_title = job_spiritual
			save_event_target_as = convert_lord_spiritual
		}
		hidden_tooltip = {
			any_vassal = {
				limit = {
					NOT = { religion = ROOT }
					ROOT = { ai = yes } # Only for AI!
				}
				letter_event = { id = 39617 } # Send out letter to vassals
			}
			FROM = {
				set_character_flag = preacher_arrives
				clr_character_flag = preacher_hidden
				character_event = { id = 39614 days = 1 } # Notify chaplain
			}
		}
	}
	option = {
		name = EVTOPTB39620 # Do Nothing
		trigger = {
			FROM = { NOT = { has_character_flag = preacher_hidden } }
		}
		ai_chance = {
			factor = 1
		}
		hidden_tooltip = {
			FROM = { character_event = { id = 39621 } } # notify
		}
	}
	option = {
		name = {
			text = EVTOPTC39620 # Imprison
			trigger = {
				FROM = { NOT = { has_character_flag = preacher_hidden } }
			}
		}
		name = {
			text = EVTOPTC39620_hidden
			trigger = {
				FROM = { has_character_flag = preacher_hidden }
			}
		}
		ai_chance = {
			factor = 1
			modifier = {
				factor = 2.0
				FROM = { has_character_flag = preacher_hidden }
			}
			modifier = {
				factor = 2.0
				trait = zealous
			}
			modifier = {
				factor = 1.5
				trait = paranoid
			}
			modifier = {
				factor = 1.5
				trait = wroth
				FROM = { has_character_flag = preacher_hidden }
			}
			modifier = {
				factor = 1.5
				trait = arbitrary
				FROM = { NOT = { has_character_flag = preacher_hidden } }
			}
			modifier = {
				factor = 0.5
				trait = just
				FROM = { NOT = { has_character_flag = preacher_hidden } }
			}
			modifier = {
				factor = 0.1
				OR = {
					trait = cynical
					trait = kind
				}
			}
		}
		FROM = {
			clr_character_flag = preacher_arrives
			set_character_flag = imprisoned_converter
			if = {
				limit = { has_character_flag = preacher_hidden }
				clr_character_flag = preacher_hidden
				reverse_opinion = { who = ROOT modifier = devious_plotter months = 60 }
			}
			imprison = ROOT
			liege = {
				set_character_flag = ai_failed_mission # AI flag - used in the code
				opinion = { who = ROOT modifier = opinion_imprisoned_missionary months = 60 }
				hidden_tooltip = {
					reverse_opinion = { modifier = opinion_sent_preacher who = ROOT }
					character_event = { id = 39623 days = 1 }
				}
			}
		}
	}
}

# Ruler did nothing after province converted -- notify chaplain (bounce event)
character_event = {
	id = 39621
	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		liege = {
			letter_event = { id = 39622 }
		}
	}
}

# Ruler did nothing after province converted -- notify chaplain's liege
letter_event = {
	id = 39622
	desc = EVTDESC39622
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		tooltip = {
			event_target:convert_province = {
				religion = FROM
			}
		}
		piety = 25
		if = {
			limit = { any_vassal = { leads_faction = faction_tradition } }
			custom_tooltip = { text = TRADITIONFACTIONMOODPLUS }
			hidden_tooltip = {
				random_vassal = { limit = { leads_faction = faction_tradition } set_variable = { which = "faction_mood_increase" value = 1 } }
				character_event = { id = PlusFaction.200 days = 1 } #recalculate faction moods
			}
		}
		if = {
			limit = {
				is_heretic = no
				rightful_religious_head_scope = {
					ROOT = {
						NOT = { excommunicated_for = PREV }
					}
				}
			}
			rightful_religious_head_scope = {
				opinion = {
					modifier = opinion_converted_province
					who = ROOT
					years = 5
				}
			}
		}
	}
}

# Liege informed Chaplain imprisoned after converting province
character_event = {
	id = 39623
	desc = EVTDESC39623
	picture = GFX_evt_torture
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39605
		FROM = {
			reverse_opinion = { who = ROOT modifier = holy_war_sanction months = 6 }
		}
	}
}

# Ruler informed Chaplain found
character_event = {
	id = 39624
	desc = EVTDESC39624
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39624
		FROM = {
			set_character_flag = imprisoned_converter
			reverse_opinion = { who = ROOT modifier = devious_plotter months = 60 }
			imprison = ROOT
			liege = {
				set_character_flag = ai_failed_mission # AI flag - used in the code
				opinion = { who = ROOT modifier = opinion_imprisoned_missionary months = 60 }
				hidden_tooltip = {
					reverse_opinion = { modifier = opinion_sent_preacher who = ROOT }
				}
			}
		}
	}
}

# Liege informed Chaplain found and imprisoned
character_event = {
	id = 39625
	desc = EVTDESC39625
	picture = GFX_evt_torture
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39605
	}
}

# RISE OF THE SHI'A CALIPHATE
character_event = {
	id = 39640

	hide_window = yes
	
	only_independent = yes
	only_playable = yes
	religion_group = muslim
	
	trigger = {
		NOT  = { has_global_flag = ancient_religions_start }
		ai = yes
		year = 870
		d_shiite = { has_holder = no }
		is_landed = yes
		higher_tier_than = DUKE		
		capital_scope = {
			OR = {
				region = custom_persia
				region = custom_syria
				region = custom_egypt
				region = custom_africa
				region = custom_algiers
			}
		}
		OR = {
			trait = dynasty_decadence_low
			trait = dynasty_decadence_med
			trait = dynasty_decadence_high
		}
		NOR = {
			shiite_claimant = { is_alive = yes }
			religion = shiite
			has_global_flag = shia_caliphate_revolt_ongoing
			has_global_flag = shia_caliphate_revolt
		}
		any_realm_province = {
			OR = {
				region = custom_persia
				region = custom_syria
				region = custom_egypt
				region = custom_africa
				region = custom_algiers
			}
			kingdom = {
				OR = {
					has_holder = no
					holder_scope = { character = ROOT }
				}
				num_title_realm_provs = {
					who = ROOT
					value = 6
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 1000
		modifier = {
			factor = 0.25
			c_tunis = {
				holder_scope = { same_realm = ROOT }
			}
		}
		modifier = {
			factor = 0.5
			c_cairo = {
				holder_scope = { same_realm = ROOT }
			}
		}
		modifier = {
			factor = 0.5
			trait = dynasty_decadence_high
		}
		modifier = {
			factor = 0.75
			trait = dynasty_decadence_med
		}
		modifier = {
			factor = 0.75
			year = 900
		}
		modifier = {
			factor = 0.75
			year = 950
		}
		modifier = {
			factor = 0.5
			year = 1000
		}
		modifier = {
			factor = 0.25
			year = 1050
		}
		modifier = {
			factor = 0.25
			year = 1100
		}
	}
	
	immediate = {
		set_global_flag = shia_caliphate_revolt
		save_event_target_as = shiite_revolt_target
		
		#prioritize africa
		random_realm_province = {
			limit = {
				region = custom_africa
				kingdom = {
					OR = {
						has_holder = no
						holder_scope = { character = ROOT }
					}
					num_title_realm_provs = {
						who = ROOT
						value = 5
					}
				}
			}
			kingdom = { save_event_target_as = shiite_revolt_target_title }
		}
		
		#then prioritize egypt
		random_realm_province = {
			limit = {
				NOT = { event_target:shiite_revolt_target_title = { always = yes } }
				region = custom_egypt
				kingdom = {
					OR = {
						has_holder = no
						holder_scope = { character = ROOT }
					}
					num_title_realm_provs = {
						who = ROOT
						value = 5
					}
				}
			}
			kingdom = { save_event_target_as = shiite_revolt_target_title }
		}
		
		#then any title will do
		random_realm_province = {
			limit = {
				NOT = { event_target:shiite_revolt_target_title = { always = yes } }
				OR = {
					region = custom_persia
					region = custom_syria
					region = custom_egypt
					region = custom_africa
					region = custom_algiers
				}
				kingdom = {
					OR = {
						has_holder = no
						holder_scope = { character = ROOT }
					}
					num_title_realm_provs = {
						who = ROOT
						value = 5
					}
				}
			}
			kingdom = { save_event_target_as = shiite_revolt_target_title }
		}
		
		#create the new claimant
		create_random_diplomat = {
			random_traits = yes
			dynasty = 589 #Fatimid
			religion = shiite
			culture = bedouin_arabic
			female = no
			age = 16
			health = 6.5
			fertility = 0.6
			trait = sayyid
			trait = shiite_claimant
			trait = quick
			trait = fair
			attributes = {
				learning = 5
				diplomacy = 5
				martial = 8
			}
		}
		new_character = {
			log = "[This.GetTitledName] is a new Imamah starting the Shiite Caliphate Uprising in ]shiite_revolt_target_title.GetName]"
			set_character_flag = found_claimant
			set_character_flag = shia_caliphate_pretender
			save_event_target_as = shiite_revolter
			if = {
				limit = {
					OR = {
						trait = naive_appeaser
						trait = underhanded_rogue
						trait = charismatic_negotiator
					}
				}
				remove_trait = naive_appeaser
				remove_trait = underhanded_rogue
				remove_trait = charismatic_negotiator
				add_trait = grey_eminence
			}
			narrative_event = { id = Plus.1962 }
		}
	}
}

# THE START OF THE CHRISTIAN CRUSADES - 1090 AND JERUSALEM NOT CHRISTIAN
narrative_event = {
	id = 39660
	title = EVTNAME39660
	desc = EVTDESC39660
	picture = GFX_evt_jerusalem
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	min_age = 16
	only_men = yes
	religion_group = christian
	
	trigger = {
		NOT = { has_global_flag = ancient_religions_start }
		controls_religion = yes
		OR = {
			religion = catholic
			religion = chalcedonian
		}
		year = 1090
		
		774 = { # Jerusalem
			NOT = { owner = { religion_group = christian } }
		}
		
		NOT = { has_global_flag = christian_crusades_unlocked }
	}
	
	mean_time_to_happen = {
		months = 120
	}
	
	immediate = {
		set_global_flag = christian_crusades_unlocked
	}
	
	option = {
		name = EVTOPTA39660
		trigger = {
			religion_group = christian
		}
	}
	
	option = {
		name = EVTOPTB39660
		trigger = {
			NOT = { religion_group = christian }
		}
	}
}

# THE START OF THE CHRISTIAN CRUSADES - BYZANTIUM FAILING
narrative_event = {
	id = 39661
	title = EVTNAME39660
	desc = EVTDESC39661
	picture = GFX_evt_hagia_sofia
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	religion_group = christian
	min_age = 16
	only_men = yes
	
	trigger = {
		NOT = { has_global_flag = ancient_religions_start }
		controls_religion = yes
		OR = {
			religion = catholic
			religion = chalcedonian
		}
		year = 850
		NOT = { has_global_flag = christian_crusades_unlocked }
		
		OR = {
			e_byzantium = {
				holder_scope = {
					NOT = { religion_group = christian }
				}
			}
			496 = { # Constantinople
				NOT = { owner = { religion_group = christian } }
			}
			753 = { # Ancyra
				NOT = { owner = { religion_group = christian } }
			}
			AND = {
				482 = { # Athens
					NOT = { owner = { religion_group = christian } }
				}
				481 = { # Corinth
					NOT = { owner = { religion_group = christian } }
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 3
	}
	
	immediate = {
		set_global_flag = christian_crusades_unlocked
	}
	
	option = {
		name = EVTOPTA39660
		trigger = {
			religion_group = christian
		}
	}
	
	option = {
		name = EVTOPTB39660
		trigger = {
			NOT = { religion_group = christian }
		}
	}
}

# THE START OF THE CHRISTIAN CRUSADES - ROME HAS FALLEN
narrative_event = {
	id = 39662
	title = EVTNAME39660
	desc = EVTDESC39662
	picture = GFX_evt_pope
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	min_age = 16
	only_men = yes
	religion_group = christian
	
	trigger = {
		NOT = { has_global_flag = ancient_religions_start }
		controls_religion = yes
		year = 850
		OR = {
			religion = catholic
			religion = chalcedonian
		}
		NOT = { has_global_flag = christian_crusades_unlocked }
		
		333 = { # Rome
			owner = {
				OR = {
					NOT = { religion_group = christian }
					is_heretic = yes
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 3
	}
	
	immediate = {
		set_global_flag = christian_crusades_unlocked
	}
	
	option = {
		name = EVTOPTA39660
		trigger = {
			religion_group = christian
		}
	}
	
	option = {
		name = EVTOPTB39660
		trigger = {
			NOT = { religion_group = christian }
		}
	}
}

# THE START OF THE CHRISTIAN CRUSADES - EUROPE
narrative_event = {
	id = 39663
	title = EVTNAME39660
	desc = EVTDESC39663
	picture = GFX_evt_crusaders
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	min_age = 16
	only_men = yes
	religion_group = christian
	
	trigger = {
		NOT = { has_global_flag = ancient_religions_start }
		controls_religion = yes
		OR = {
			religion = catholic
			religion = chalcedonian
		}
		year = 850
		NOT = { has_global_flag = christian_crusades_unlocked }
		
		OR = {
			221 = { # Provence
				NOT = { owner = { religion_group = christian } }
			}
			214 = { # Toulouse
				NOT = { owner = { religion_group = christian } }
			}
			112 = { # Paris
				NOT = { owner = { religion_group = christian } }
			}
			119 = { # Cologne
				religion_group = christian
				NOT = { owner = { religion_group = christian } }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 3
	}
	
	immediate = {
		set_global_flag = christian_crusades_unlocked
	}
	
	option = {
		name = EVTOPTA39660
		trigger = {
			religion_group = christian
		}
	}
	
	option = {
		name = EVTOPTB39660
		trigger = {
			NOT = { religion_group = christian }
		}
	}
}

# THE START OF MUSLIM JIHADS - 1187 IF THERE IS STILL A CALIPH
narrative_event = {
	id = 39670
	title = EVTNAME39670
	desc = EVTDESC39670
	picture = GFX_evt_bishop_muslim
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	min_age = 16
	only_men = yes
	religion_group = muslim
	
	trigger = {
		controls_religion = yes
		year = 1187
		
		NOT = { has_global_flag = muslim_jihads_unlocked }
	}
	
	mean_time_to_happen = {
		months = 120
	}
	
	immediate = {
		set_global_flag = muslim_jihads_unlocked
	}
	
	option = {
		name = EVTOPTA39670
		trigger = {
			religion_group = muslim
		}
	}
	
	option = {
		name = EVTOPTB39670
		trigger = {
			NOT = { religion_group = muslim }
		}
	}
}

# THE START OF MUSLIM JIHADS - JERUSALEM HAS FALLEN
narrative_event = {
	id = 39671
	title = EVTNAME39670
	desc = EVTDESC39671
	picture = GFX_evt_jerusalem_captured_muslims
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	min_age = 16
	only_men = yes
	religion_group = muslim
	
	trigger = {
		year = 850
		controls_religion = yes
		NOT = { has_global_flag = muslim_jihads_unlocked }
		774 = { # Jerusalem
			NOT = { owner = { religion_group = muslim } }
		}
	}
	
	mean_time_to_happen = {
		months = 3
	}
	
	immediate = {
		set_global_flag = muslim_jihads_unlocked
	}
	
	option = {
		name = EVTOPTA39670
		trigger = {
			religion_group = muslim
		}
	}
	
	option = {
		name = EVTOPTB39670
		trigger = {
			NOT = { religion_group = muslim }
		}
	}
}

# THE START OF MUSLIM JIHADS - MECCA HAS FALLEN
narrative_event = {
	id = 39672
	title = EVTNAME39670
	desc = EVTDESC39672
	picture = GFX_evt_mecca_falls_soa
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	min_age = 16
	only_men = yes
	religion_group = muslim
	
	trigger = {
		year = 850
		controls_religion = yes
		NOT = { has_global_flag = muslim_jihads_unlocked }
		719 = { # Mecca
			NOT = { owner = { religion_group = muslim } }
		}
	}
	
	mean_time_to_happen = {
		months = 3
	}
	
	immediate = {
		set_global_flag = muslim_jihads_unlocked
	}
	
	option = {
		name = EVTOPTA39670
		trigger = {
			religion_group = muslim
		}
	}
	
	option = {
		name = EVTOPTB39670
		trigger = {
			NOT = { religion_group = muslim }
		}
	}
}

# THE START OF MUSLIM JIHADS - THE CENTER CANNOT HOLD
narrative_event = {
	id = 39673
	title = EVTNAME39670
	desc = EVTDESC39673
	picture = GFX_evt_moors
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	min_age = 16
	only_men = yes
	religion_group = muslim
	
	trigger = {
		year = 850
		controls_religion = yes
		NOT = { has_global_flag = muslim_jihads_unlocked }
		OR = {
			693 = { # Baghdad
				NOT = { owner = { religion_group = muslim } }
			}
			728 = { # Damascus
				NOT = { owner = { religion_group = muslim } }
			}
			796 = { # Cairo
				NOT = { owner = { religion_group = muslim } }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 3
	}
	
	immediate = {
		set_global_flag = muslim_jihads_unlocked
	}
	
	option = {
		name = EVTOPTA39670
		trigger = {
			religion_group = muslim
		}
	}
	
	option = {
		name = EVTOPTB39670
		trigger = {
			NOT = { religion_group = muslim }
		}
	}
}

# THE START OF MUSLIM JIHADS - AFRICA UNDER THREAT
narrative_event = {
	id = 39674
	title = EVTNAME39670
	desc = EVTDESC39674
	picture = GFX_evt_desert
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	min_age = 16
	only_men = yes
	religion_group = muslim
	
	trigger = {
		year = 1000
		controls_religion = yes
		NOT = { has_global_flag = muslim_jihads_unlocked }
		OR = {
			843 = { # Marrakesh
				NOT = { owner = { religion_group = muslim } }
			}
			817 = { # Tunis
				NOT = { owner = { religion_group = muslim } }
			}
			831 = { # Al Djazair
				NOT = { owner = { religion_group = muslim } }
			}
		}
	}
	
	mean_time_to_happen = {
		months = 3
	}
	
	immediate = {
		set_global_flag = muslim_jihads_unlocked
	}
	
	option = {
		name = EVTOPTA39670
		trigger = {
			religion_group = muslim
		}
	}
	
	option = {
		name = EVTOPTB39670
		trigger = {
			NOT = { religion_group = muslim }
		}
	}
}

# THE START OF PAGAN GREAT HOLY WARS - AFTER THE ABRAHAMICS
narrative_event = {
	id = 39680
	title = EVTNAME39680
	desc = EVTDESC39680
	picture = GFX_evt_midwinter_blot_oldgods
	border = GFX_event_narrative_frame_religion
	
	major = yes
	
	show_ROOT = yes
	hide_new = yes
	
	only_rulers = yes
	min_age = 16
	
	trigger = {
		is_pagan_religion = yes
		controls_religion = yes
		
		NOT = { has_global_flag = pagan_ghws_unlocked }
		
		OR = {
			has_global_flag = ancient_religions_start
			has_global_flag = muslim_jihads_unlocked
			has_global_flag = christian_crusades_unlocked
		}
	}
	
	mean_time_to_happen = {
		months = 120
	}
	
	immediate = {
		set_global_flag = pagan_ghws_unlocked
	}
	
	option = {
		name = EVTOPTA39680
		trigger = {
			religion = ROOT
		}
	}
	
	option = {
		name = EVTOPTB39680
		trigger = {
			is_pagan_religion = yes
			NOT = { religion = ROOT }
		}
	}
	
	option = {
		name = EVTOPTC39680
		trigger = {
			is_pagan_religion = no
		}
	}
}

# Vassal accepts religious conversion demand. 
# Fired from 'on_vassal_accepts_religious_conversion'
# FROMFROM is the demander. FROM is the target vassal. ROOT is the current character. Fires for the target and each of his/her courtiers and direct vassals (but not for characters below the target's vassals).
character_event = {
	id = 39700
	
	hide_window = yes
	
	is_triggered_only = yes
	
	trigger = {
		NOT = { religion = FROMFROM }
		OR = {
			character = FROM
			AND = {
				is_ruler = no
				NOT = { trait = zealous }
				religion = FROM # Will not change religion if already different from the vassal's
			}
		}
	}
	
	immediate = {
		if = {
			limit = {
				character = FROM
			}
			opinion = {
				who = FROMFROM
				modifier = opinion_demanded_conversion
			}
			if = {
				limit = {
					prisoner = yes
					host = {
						character = FROMFROM
					}
				}
				imprison = no
			}
		}
	}
	
	option = { # No sympathy for the old religion
		ai_chance = {
			factor = 100
		}
		clr_religion_char_flag_effect = yes #Must clear all old flags to avoid double traits
		add_religion_char_flag_effect = yes
		religion = FROMFROM
		if = {
			limit = {
				religion_group = indian_group
			}
			character_event = { id = RoI.120 } # Assign Indian religion branch
		}
		if = {
			limit = {
				character = FROM
			}
			character_event = { id = MNM.3949 days = 3 random = 10 }
		}
	}
	
	option = { # Sympathy for the old religion
		ai_chance = {
			factor = 100
			modifier = {
				factor = 0
				OR = {
					trait = zealous
					NOT = { age = 12 }
				}
			}
			modifier = {
				factor = 10
				trait = cynical
				age = 12
			}
		}
		if = {
			limit = {
				religion_group = christian
			}
			add_trait = sympathy_christendom
		}
		if = {
			limit = {
				religion_group = muslim
			}
			add_trait = sympathy_islam
		}
		if = {
			limit = {
				is_pagan_religion = yes
			}
			add_trait = sympathy_pagans
		}
		if = {
			limit = {
				religion_group = zoroastrian_group
			}
			add_trait = sympathy_zoroastrianism
		}
		if = {
			limit = {
				religion_group = jewish_group
			}
			add_trait = sympathy_judaism
		}
		if = {
			limit = {
				religion_group = indian_group
			}
			add_trait = sympathy_indian
		}

		clr_religion_char_flag_effect = yes #Must clear all old flags to avoid double traits
		add_religion_char_flag_effect = yes
		religion = FROMFROM
		if = {
			limit = {
				religion_group = indian_group
			}
			character_event = { id = RoI.120 } # Assign Indian religion branch
		}
		if = {
			limit = {
				character = FROM
			}
			character_event = { id = MNM.3949 days = 3 random = 10 }
		}
	}
}

# Catholic antipope immediately loses claim if he or liege is no longer catholic, if he is a child, or if he is in the same realm as the Pope
character_event = {
	id = 39701

	hide_window = yes

	only_playable = yes
	religion_group = christian
	
	trigger = {
		has_landed_title = k_papal_state
		k_papal_state = {
			any_claimant = {
				OR = {
					NOT = { religion = catholic }
					any_liege = { NOT = { religion = catholic } }
					is_adult = no
					same_realm = ROOT
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		k_papal_state = {
			any_claimant = {
				limit = {
					OR ={
						NOT = { religion = catholic }
						any_liege = { NOT = { religion = catholic } }
						is_adult = no
						same_realm = ROOT
					}
				}
				remove_claim = k_papal_state
			}
		}
	}
}

# Fraticelli antipope immediately loses claim if he or liege is no longer Fraticelli, if he is a child, or if he is in the same realm as the Pope
character_event = {
	id = 39702

	hide_window = yes

	only_rulers = yes
	religion_group = christian
	
	trigger = {
		has_landed_title = d_fraticelli
		d_fraticelli = {
			any_claimant = {
				OR = {
					NOT = { religion = fraticelli }
					any_liege = { NOT = { religion = fraticelli } }
					is_adult = no
					same_realm = ROOT
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		d_fraticelli = {
			any_claimant = {
				limit = {
					OR = {
						NOT = { religion = fraticelli }
						any_liege = { NOT = { religion = fraticelli } }
					}
				}
				remove_claim = d_fraticelli
			}
		}
	}
}

# Establishing the Fraticelli Papacy
character_event = {
	id = 39703
	desc = {
		text = EVTDESC39703A
		trigger = {
			character = FROM
		}
	}
	desc = {
		text = EVTDESC39703B
		trigger = {
			NOT = { character = FROM }
		}
	}
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	major = yes

	is_triggered_only = yes
	major_trigger = {
		religion_group = christian
	}
	
	only_playable = yes
	
	option = {
		name = EVTOPTA_SOA_4200
		trigger = {
			religion = fraticelli
		}
	}
	option = {
		name = EVTOPTB_SOA_4200
		trigger = {
			religion = catholic
		}
	}
	option = {
		name = EVTOPTC_SOA_4200
		trigger = {
			NOR = {
				religion = fraticelli
				religion = catholic
			}
		}
	}
}

# Establishing the Iconoclast Patriarchy
long_character_event = {
	id = 39704
	desc = {
		text = EVTDESC39704A
		trigger = {
			character = FROM
		}
	}
	desc = {
		text = EVTDESC39704B
		trigger = {
			NOT = { character = FROM }
		}
	}
	picture = GFX_evt_bishop
	border = GFX_event_long_frame_religion
	
	major = yes
	
	is_triggered_only = yes
	major_trigger = {
		religion_group = christian
	}
	
	only_playable = yes
	
	option = {
		name = EVTOPTA_SOA_4200
		trigger = {
			religion = iconoclast
		}
	}
	option = {
		name = EVTOPTB_SOA_4200
		trigger = {
			religion = orthodox
		}
	}
	option = {
		name = EVTOPTC_SOA_4200
		trigger = {
			NOR = {
				religion = iconoclast
				religion = orthodox
			}
		}
	}
}

# Restore the Pope in Rome
character_event = {
	id = 39705
	desc = {
		text = EVTDESC39705A
		trigger = {
			event_target:restored_pope = { religion = fraticelli }
			character = FROM
		}
	}
	desc = {
		text = EVTDESC39705B
		trigger = {
			event_target:restored_pope = { religion = fraticelli }
			NOT = { character = FROM }
		}
	}
	desc = {
		text = EVTDESC39705C
		trigger = {
			event_target:restored_pope = { religion = catholic }
			character = FROM
		}
	}
	desc = {
		text = EVTDESC39705D
		trigger = {
			event_target:restored_pope = { religion = catholic }
			NOT = { character = FROM }
		}
	}
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	#major = yes
	
	is_triggered_only = yes
	#major_trigger = {
	#	religion_group = christian
	#}
	
	only_playable = yes
	
	option = {
		name = EVTOPTA_SOA_4200
		trigger = {
			religion = fraticelli
		}
	}
	option = {
		name = EVTOPTB_SOA_4200
		trigger = {
			religion = catholic
		}
	}
	option = {
		name = EVTOPTC_SOA_4200
		trigger = {
			NOR = {
				religion = fraticelli
				religion = catholic
			}
		}
	}
}

# Restore the Ecumenical Patriarchy
long_character_event = {
	id = 39706
	desc = {
		text = EVTDESC39706A
		trigger = {
			character = FROM
		}
	}
	desc = {
		text = EVTDESC39706B
		trigger = {
			NOT = { character = FROM }
		}
	}
	picture = GFX_evt_bishop
	border = GFX_event_long_frame_religion
	
	major = yes
	
	is_triggered_only = yes
	major_trigger = {
		religion_group = christian
	}
	
	only_playable = yes
	
	option = {
		name = EVTOPTA_SOA_4200
		trigger = {
			religion = orthodox
		}
	}
	option = {
		name = EVTOPTB_SOA_4200
		trigger = {
			religion = iconoclast
		}
	}
	option = {
		name = EVTOPTC_SOA_4200
		trigger = {
			NOR = {
				religion = iconoclast
				religion = orthodox
			}
		}
	}
}

################################
# Jade Dragon religious events
################################

#KHURMAZTA
# Fired from Decision 'patrons_khu'
character_event = {
	id = 39800
	desc = EVTDESC39800
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_39800
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_desi
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTB_39800
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_parn
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTC_39800
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_nanaiya
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTD_39800
		hidden_tooltip = { character_event = { id = 39801 } }
	}
}

character_event = {
	id = 39801
	desc = EVTDESC39801
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_39801
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_weshparkar
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTB_39801
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_wishaghn
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTC_39801
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_zurvan
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTD_39801
		hidden_tooltip = { character_event = { id = 39800 } }
	}
}

#BON
# Fired from Decision 'patrons_bon'
character_event = {
	id = 39802
	desc = EVTDESC39802
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_39802
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_damchen
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTB_39802
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_shenla_okar
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTC_39802
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_shinje
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTD_39802
		hidden_tooltip = { character_event = { id = 39803 } }
	}
}

character_event = {
	id = 39803
	desc = EVTDESC39803
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = EVTOPTA_39803
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_kula_kari
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTB_39803
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_lamlha
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTC_39803
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = patron_sangpo_bumtri
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = EVTOPTD_39803
		hidden_tooltip = { character_event = { id = 39802 } }
	}
}

#Taoist school
# Fired from Decision 'school_tao'
character_event = {
	id = 39807
	desc = school_tao_1_desc
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	
	option = {
		name = school_tao_1_a
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = school_zhengyi
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = school_tao_1_b
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = school_quanzhen
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
	option = {
		name = school_tao_1_c
		set_character_flag = patron_chosen
		add_character_modifier = {
			name = school_shangqing
			duration = -1
		}
		clr_character_flag = selecting_patron_deity
	}
}

#Remove main deity in case of religious conversion
character_event = {
	id = 39804

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOT = {
			religion = bon
		}
	}

	immediate = {
		remove_character_modifier = patron_damchen
		remove_character_modifier = patron_shenla_okar
		remove_character_modifier = patron_shinje
		remove_character_modifier = patron_kula_kari
		remove_character_modifier = patron_lamlha 
		remove_character_modifier = patron_sangpo_bumtri
	}
}

character_event = {
	id = 39805

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOT = {
			religion = khurmazta
		}
	}

	immediate = {
		remove_character_modifier = patron_desi
		remove_character_modifier = patron_parn
		remove_character_modifier = patron_nanaiya
		remove_character_modifier = patron_weshparkar
		remove_character_modifier = patron_wishaghn
		remove_character_modifier = patron_zurvan
	}
}

character_event = {
	id = 39806

	is_triggered_only = yes
	hide_window = yes

	trigger = {
		NOT = {
			religion = taoist
		}
	}

	immediate = {
		remove_character_modifier = school_quanzhen
		remove_character_modifier = school_shangqing
		remove_character_modifier = school_zhengyi
	}
}


# The birth of the Order of St Anthony (Alternate)
narrative_event = {
	id = 39810
	desc = EVTDESC39810
	title = EVTTITLE39810
	major = yes
	
	picture = GFX_evt_knight_kneeling
	
	is_triggered_only = yes
	
	immediate = {
		activate_title = { title = d_saint_anthony status = yes }
		create_character = {
			random_traits = no
			dynasty = random
			religion = ROOT
			culture = ROOT
			female = no
			age = 31
			trait = brilliant_strategist
			trait = zealous
			trait = humble
			trait = ambitious
			trait = strategist
			trait = holy_warrior
		}
		new_character = {
			wealth = 500
			d_saint_anthony = {
				grant_title = PREV
			}
			set_government_type = feudal_government
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = no
				age = 16
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ethiopian
				female = no
				age = 18
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ethiopian
				female = no
				age = 18
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = no
				age = 20
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = greek
				female = no
				age = 25
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = armenian
				female = no
				age = 26
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = no
				age = 28
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = yes
				age = 16
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = ROOT
				female = yes
				age = 17
			}
		}
	}
	
	option = {
		name = EVTOPTA_SOA_2809
		trigger = {
			religion = ROOT
		}
	}
	option = {
		name = EVTOPTB_SOA_2809
		trigger = {
			NOT = { religion = ROOT	}
		}
	}
}

# The birth of the Order of St Addai (Alternate)
narrative_event = {
	id = 39811
	desc = EVTDESC39811
	title = EVTTITLE39811
	major = yes
	
	picture = GFX_evt_knight_kneeling
	
	is_triggered_only = yes
	
	immediate = {
		activate_title = { title = d_saint_addai status = yes }
		create_character = {
			random_traits = no
			dynasty = random
			religion = ROOT
			culture = assyrian
			female = no
			age = 31
			trait = brilliant_strategist
			trait = zealous
			trait = humble
			trait = ambitious
			trait = strategist
			trait = holy_warrior
		}
		new_character = {
			wealth = 500
			d_saint_addai = {
				grant_title = PREV
			}
			set_government_type = feudal_government
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = persian
				female = no
				age = 16
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = assyrian
				female = no
				age = 18
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = assyrian
				female = no
				age = 18
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = assyrian
				female = no
				age = 20
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = assyrian
				female = no
				age = 25
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = assyrian
				female = no
				age = 26
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = assyrian
				female = no
				age = 28
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = assyrian
				female = yes
				age = 16
			}
			create_character = {
				random_traits = yes
				dynasty = random
				religion = ROOT
				culture = assyrian
				female = yes
				age = 17
			}
		}
	}
	
	option = {
		name = EVTOPTA_SOA_2809
		trigger = {
			religion = ROOT
		}
	}
	option = {
		name = EVTOPTB_SOA_2809
		trigger = {
			NOT = { religion = ROOT	}
		}
	}
}


### Bema festival

# Invitation Sent
character_event = {
	id = 39812
	desc = EVTDESC39812
	
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39812
		any_vassal = {
			limit = {
				religion = manichean
				age = 16
				prisoner = no
				war = no
				NOT = { trait = incapable }
			}
			character_event = { id = 39813 days = 2 tooltip = EVTTOOLTIP_39813 }
		}
		custom_tooltip = { text = bema_invitations_sent }
		hidden_tooltip = { character_event = { id = 39815 days = 10 } }
		hidden_tooltip = { character_event = { id = 39816 days = 12 } }
	}
}

# Invitation Received
character_event = {
	id = 39813
	desc = EVTDESC39813
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes

	trigger = { NOT = { is_inaccessible_trigger = yes } }
	
	option = {
		name = EVTOPTA39813
		ai_chance = {
			factor = 80
			modifier = {
				factor = 0
				NOT = {	opinion = { who = ROOT value = -20 } }
			}
		}
		custom_tooltip = { text = bema_accepted }
		set_character_flag = attending_bema
		set_character_flag = do_not_disturb
		hidden_tooltip = { character_event = { id = 39815 days = 8 } }
		hidden_tooltip = { character_event = { id = 39818 days = 20 } } # Safety catch flag clearing
	}
	option = {
		name = EVTOPTB39813
		ai_chance = {
			factor = 20
		}
		FROM = {
			opinion = {
				modifier = opinion_refused_bema
				who = ROOT
			}
		}
		custom_tooltip = { text = bema_declined }
		hidden_tooltip = {
			FROM = { character_event = { id = 39814 } }
		}
	}
}

# Invitation Refused
character_event = {
	id = 39814
	desc = EVTDESC39814
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39814
		opinion = {
			modifier = opinion_refused_bema
			who = FROM
		}
	}
}

# Bema Begins
character_event = {
	id = 39815
	desc = EVTDESC39815
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39815
	}
}

# Bema Ends (Host)
character_event = {
	id = 39816
	desc = EVTDESC39816
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	hide_from = yes
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39816
		any_vassal = {
			limit = { has_character_flag = attending_bema }
			opinion = {
				modifier = opinion_held_bema
				who = ROOT
			}
		}
		hidden_tooltip = {
			any_vassal = {
				limit = { has_character_flag = attending_bema }
				character_event = { id = 39817 }
			}
		}
		add_character_modifier = {
			name = held_bema_timer
			duration = 1825
			hidden = yes
		}
		prestige = 100
		piety = 100
		clr_character_flag = holding_bema
		remove_do_not_disturb_effect = yes
	}
}

# Bema Ends (Guest)
character_event = {
	id = 39817
	desc = EVTDESC39817
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39816
		clr_character_flag = attending_bema
		remove_do_not_disturb_effect = yes
	}
}

# Safety catch - clears character flags and modifiers
character_event = {
	id = 39818

	hide_window = yes
	
	is_triggered_only = yes
	
	immediate = {
		remove_do_not_disturb_effect = yes
		clr_character_flag = holding_bema
		clr_character_flag = attending_bema
	}
}

### Zoroastrian Jashan-e Sadah

# Invitations Sent (Liege)
character_event = {
	id = 39820
	desc = EVTDESC39820
	picture = GFX_evt_marriage_zoroastrian_group
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	hide_from = yes
	
	option = {
		name = EVTOPTA39820
		any_vassal = {
			limit = {
				age = 16
				prisoner = no
				war = no
				NOT = { trait = incapable }
			}
			character_event = { id = 39821 tooltip = EVTTOOLTIP_39821 }
		}
		hidden_tooltip = { character_event = { id = 39823 days = 10 } }
	}
}

# Invitations Received (Vassals)
character_event = {
	id = 39821
	desc = EVTDESC39821
	picture = GFX_evt_feast
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39821
		trigger = {
			OR = {
				religion_group = zoroastrian_group
				not = { religion = manichean }
				not = { religion = mazdaki }
			}
		}
		set_character_flag = attending_sadah
		set_character_flag = do_not_disturb
		if = {
			limit = { trait = in_hiding	}
			remove_trait = in_hiding
			add_character_modifier = {
				name = went_out_of_hiding_timer
				duration = 180
				hidden = yes
			}
			hidden_tooltip = { character_event = { id = CM.6400 } } # Notify plotters and family
		}
	}
	option = {
		name = EVTOPTB39821
		trigger = {
			NOT = { religion_group = zoroastrian_group }
				not = { religion = manichean }
				not = { religion = mazdaki }
		}
		FROM = {
			character_event = { id = 39822 days = 5 tooltip = DIPLOWINDOW_REJECT }
			opinion = {
				modifier = opinion_refused_sadah
				who = ROOT
			}
		}
	}
}

# Invitation Refused (Liege)
character_event = {
	id = 39822
	desc = EVTDESC39822
	picture = GFX_evt_rival_rulers
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39822
		tooltip = {
			opinion = {
				modifier = opinion_refused_sadah
				who = FROM
			}
		}
	}
}

# Celebration Begins (Liege)
character_event = {
	id = 39823
	desc = EVTDESC39823
	picture = GFX_evt_prospering_province
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	hide_from = yes
	
	option = {
		name = EVTOPTA39823
		custom_tooltip = {
			text = sadah_begins1
			hidden_tooltip = {
				any_vassal = {
					limit = { has_character_flag = attending_sadah }
					character_event = { id = 39824 }
				}
				character_event = { id = 39830 days = 2 }
			}
		}
	}
}

# Celebration Begins (Vassals)
character_event = {
	id = 39824
	desc = EVTDESC39824
	picture = GFX_evt_jewish_market
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39824
		custom_tooltip = {
			text = sadah_begins1
			hidden_tooltip = {
				character_event = { id = 39831 days = 2 }
			}
		}
	}
}

# Feast Begins (Liege)
character_event = {
	id = 39825
	desc = EVTDESC39825
	picture = GFX_evt_feast
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	hide_from = yes
	
	option = {
		name = EVTOPTA39825
		
			hidden_tooltip = {
				character_event = { id = 39827 days = 25 }
			}
		}
	}

# Feast Begins (Vassals)
character_event = {
	id = 39826
	desc = EVTDESC39826
	picture = GFX_evt_feast
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39825
		set_character_flag = sadah_feast_vassal
	}
}

# Feast Ends (Liege)
character_event = {
	id = 39827
	desc = EVTDESC39827
	picture = GFX_evt_powerful_ruler
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	hide_from = yes
	
	option = {
		name = EVTOPTA39827
		any_vassal = {
			limit = { has_character_flag = attending_sadah }
			opinion = {
				modifier = opinion_held_sadah
				who = ROOT
			}
		}
		hidden_tooltip = {
			any_vassal = {
				limit = { has_character_flag = attending_sadah }
				character_event = { id = 39828 }
			}
		}
		add_character_modifier = {
			name = jd_held_sadah_timer
			duration = 1825
		}
		prestige = 200
		piety = 100
		clr_character_flag = holding_sadah
		clr_character_flag = feast_drunkard
		clr_character_flag = feast_gluttonous
		clr_character_flag = feast_lunatic
		clr_character_flag = feast_lustful
		clr_character_flag = feast_homosexual
		remove_do_not_disturb_effect = yes
	}
}

# Feast Ends (Vassals)
character_event = {
	id = 39828
	desc = EVTDESC39828
	picture = GFX_evt_feast
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA39827
		clr_character_flag = attending_sadah
		clr_character_flag = sadah_feast_vassal
		clr_character_flag = feast_drunkard
		clr_character_flag = feast_gluttonous
		clr_character_flag = feast_lunatic
		clr_character_flag = feast_lustful
		clr_character_flag = feast_friendship
		clr_character_flag = feast_homosexual
		remove_do_not_disturb_effect = yes
	}
}

# Fire prayer (Liege)
character_event = {
	id = 39830
	desc = EVTDESC39830
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	hide_from = yes
	
	option = {
		name = EVTOPTA39823
		trigger = {
		    NOT = { trait = zealous }
			NOT = { trait = cynical }
			NOT = { trait = charitable }
			NOT = { trait = theologian }
			NOT = { trait = slothful }
			NOT = { trait = administrator }
			NOT = { trait = stressed }
			NOT = { trait = proud }
			NOT = { trait = lunatic }
			NOT = { trait = lustful }
			NOT = { trait = poet }
			NOT = { trait = tough_soldier }
			NOT = { trait = skilled_tactician }
			NOT = { trait = brilliant_strategist }
			NOT = { trait = detached_priest }
			NOT = { trait = martial_cleric }
			NOT = { trait = possessed }
			NOT = { trait = arbitrary }
			NOT = { trait = seducer }
			NOT = { trait = seductress }
			NOT = { trait = depressed }
			NOT = { trait = humble }
			NOT = { trait = content }
			NOT = { trait = gardener }
			NOT = { trait = gregarious }
			NOT = { trait = fair }
			NOT = { trait = charismatic_negotiator }
			NOT = { trait = midas_touched }
			NOT = { trait = grey_eminence }
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_SCHOLAR
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_SCHOLAR_TT }
		trigger = {
			OR = {
				trait = scholarly_theologian
				trait = mastermind_theologian
			}
		}
		add_character_modifier = {
			name = green_fingers
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_SOLDIER
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_SOLDIER_TT }
		trigger = {
			OR = {
				trait = tough_soldier
				trait = skilled_tactician
				trait = brilliant_strategist
			}
		}
		add_character_modifier = {
			name = diligent_liege_morale
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_HUMBLE
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_HUMBLE_TT }
		trigger = {
			OR = {
				trait = humble
				trait = content
				trait = gardener
			}
		}
		add_character_modifier = {
			name = green_fingers
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_GREG
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_GREG_TT }
		trigger = {
			OR = {
				trait = gregarious
				trait = fair
				trait = charismatic_negotiator
				trait = midas_touched
				trait = grey_eminence
			}
		}
		add_character_modifier = {
			name = popular_ruler
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_GLUTTON
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_GLUTTON_TT }
		trigger = {
			OR = {
				trait = gluttonous
				trait = drunkard
				trait = hedonist
			}
		}
		add_character_modifier = {
			name = the_reveller
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_POET
		tooltip_info = poet
		trigger = {
			trait = poet
		}
		add_character_modifier = {
			name = aspiring_poet
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_LUNATIC
		tooltip_info = lunatic
		trigger = {
			trait = lunatic
		}
		add_character_modifier = {
			name = foolish_behavior
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_LUST
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_LUST_TT }
		trigger = {
			OR = {
				trait = lustful
				trait = seducer
				trait = seductress
			}
		}
		add_character_modifier = {
			name = seizing_the_day
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_PROUD
		tooltip_info = proud
		trigger = {
			trait = proud
		}
		add_character_modifier = {
			name = the_pompous
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_STRESSED
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_STRESSED_TT }
		trigger = {
			OR = {
				trait = stressed
				trait = depressed
			}
		}
		add_character_modifier = {
			name = blessing_of_health
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_ADMIN
		tooltip_info = administrator
		trigger = {
			trait = administrator
		}
		add_character_modifier = {
			name = inspired_peasantry
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_THEO
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_THEO_TT }
		trigger = {
			OR = {
				trait = theologian
				trait = detached_priest
				trait = martial_cleric
			}
		}
		add_character_modifier = {
			name = renewed_faith
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_POSS
		tooltip_info = possessed
		trigger = {
			trait = possessed
		}
		add_character_modifier = {
			name = peasant_crisis
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_CHAR
		tooltip_info = charitable
		trigger = {
			trait = charitable
		}
		add_character_modifier = {
			name = recently_donated_to_charity
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_ZEAL
		tooltip_info = zealous
		trigger = {
			trait = zealous
		}
		add_character_modifier = {
			name = inspired_warriors
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_CYNIC
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_CYNIC_TT }
		trigger = {
			OR = {
				trait = cynical
				trait = slothful
				trait = arbitrary
			}
		}
		add_character_modifier = {
			name = annoyed_religious
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39825 days = 10 }
			}
		}
	}
}

# Fire prayer (vassal)
character_event = {
	id = 39831
	desc = EVTDESC39831
	picture = GFX_evt_religious_exultation
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	hide_from = yes
	
	option = {
		name = EVTOPTA39823
		trigger = {
			NOR = {
				trait = cynical
				trait = theologian
				trait = slothful
				trait = stressed
				trait = lustful
				trait = detached_priest
				trait = martial_cleric
				trait = arbitrary
				trait = seducer
				trait = seductress
				trait = depressed
				trait = gregarious
				trait = underhanded_rogue
				trait = charismatic_negotiator
			}
		}
		custom_tooltip = {
			text = sadah_begins1
			hidden_tooltip = {
				character_event = { id = 39826 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39831_HEDONIST
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39831_HEDONIST_TT }
		trigger = {
			OR = {
				trait = hedonist
				trait = drunkard
				trait = gluttonous
				trait = lustful
				trait = seducer
				trait = seductress
			}
		}
		add_character_modifier = {
			name = invigorated
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39826 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39831_CYNIC
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39831_CYNIC_TT }
		trigger = {
			OR = {
				trait = cynical
				trait = arbitrary
			}
		}
		add_character_modifier = {
			name = church_unfunny
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39826 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39830_SCHOLAR
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_SCHOLAR_TT }
		trigger = {
			OR = {
				trait = theologian
				trait = detached_priest
				trait = martial_cleric
				trait = scholarly_theologian
				trait = mastermind_theologian
			}
		}
		add_character_modifier = {
			name = discussed_scripture
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39826 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39831_GREG
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39831_GREG_TT }
		trigger = {
			OR = {
				trait = gregarious
				trait = charismatic_negotiator
				trait = underhanded_rogue
			}
		}
		add_character_modifier = {
			name = took_stroll_small_talk
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39826 days = 10 }
			}
		}
	}
	option = {
		name = EVTOPT39831_STRESSED
		tooltip_info = yes
		custom_tooltip = { text = EVTOPT39830_STRESSED_TT }
		trigger = {
			OR = {
				trait = stressed
				trait = depressed
			}
		}
		add_character_modifier = {
			name = blessing_of_health
			duration = 1825
		}
		custom_tooltip = {
			text = sadah_begins
			hidden_tooltip = {
				character_event = { id = 39826 days = 10 }
			}
		}
	}
}
