##############################
# LORD SPIRITUAL
#
# Job: action_inquisition
# 	900: County Religion Converted
# 	901: Subject Religion Converted
# 	902: Heathens Attack the Lord Spiritual
# 	903: Heretic Noble
#
# Job: action_improve_rel_relations
# 	906: The Lord Spiritual attempts to improve relations with a priest
# 	907: The Lord Spiritual attempts to sabotage the relations of a priest towards the official head of the religion
#
# Job: action_advance_cul_tech
# 	926: A Great Inventor offers his help: Random Culture Tech increases
# 	927: Lord Spiritual = heretic
#
##############################


##############################
# LORD SPIRITUAL
# JOB: action_inquisition
##############################

# 900: The Lord Spiritual converts a province!
character_event = {
	id = 900
	title = EVTNAME900
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	
	desc = {
		text = EVTDESC900
		trigger = {
			event_target:convert_province = {
				owner = { same_realm = ROOT }
			}
		}
	}
	desc = {
		text = EVTDESC900_hidden
		trigger = {
			event_target:convert_province = {
				owner = { NOT = { same_realm = ROOT } }
			}
		}
	}

	capable_only = yes
	prisoner = no
	min_age = 16

	trigger = {
		has_job_action = action_inquisition
		NOT = { has_character_modifier = in_seclusion }
		liege = {
			religion = ROOT
			OR = {
				ai = no
				NOT = { religion_group = muslim }
				ROOT = { location = { is_heresy_of = PREV } }
				ROOT = { location = { is_parent_religion = PREV } }
			}
			OR = {
				AND = {
					religion = ROOT
					ROOT = {
						location = {
							NOT = { religion = PREV }
							owner = { same_realm = PREVPREV }
						}
					}
				}
				AND = {
					higher_tier_than = COUNT
					OR = {
						independent = yes
						higher_tier_than = DUKE
					}
					OR = {
						is_pagan_religion = no
						is_reformed_pagan_religion = yes
					}
					OR = {
						NOT = { religion_group = indian_group }
						ai = no
					}
					ROOT = {
						location = {
							owner = {
								independent = yes
								controls_religion = no
								is_pagan_religion = yes
								is_reformed_pagan_religion = no
								capital_scope = { province = PREVPREV }
								NOR = {
									has_opinion_modifier = { who = PREVPREVPREV modifier = opinion_sent_preacher }
									rightful_religious_head_scope = { character = PREV }
									religion = ROOT
									is_heresy_of = ROOT
									is_parent_religion = ROOT
									same_realm = ROOT
								}
							}
						}
					}
				}
			}
		}
	}

	immediate = {
		location = {
			save_event_target_as = convert_province
		}
	}
	
	mean_time_to_happen = {
		months = 750
		modifier = {
			factor = 2.0
			liege = {
				tier = count
				ai = yes
			}
		}
		modifier = {
			factor = 1.33
			has_global_flag = hardcore_mode
			ai = no
		}
		modifier = {
			factor = 0.75
			liege = {
				religion_group = christian
				has_artifact = finger_of_st_john
			}
		}
		modifier = {
			factor = 0.75
			location = { is_capital = yes }
		}
		modifier = {
			factor = 0.9
			liege = {
				has_ambition = obj_convert_a_province
			}
		}
		modifier = {
			factor = 0.9
			location = {
				OR = {
					culture_group = ROOT
					any_neighbor_province = {
						has_owner = yes
						culture_group = PREV
						religion = ROOT
					}
				}
			}
		}
		modifier = {
			factor = 0.75
			location = {
				OR = {
					culture = ROOT
					any_neighbor_province = {
						has_owner = yes
						culture = PREV
						religion = ROOT
					}
				}
			}
		}
		modifier = {
			factor = 2.0
			OR = {
				location = { religion = sunni }
				location = { religion = shiite }
			}
			liege = {
				ai = no
				OR = {
					religion = sunni
					religion = shiite
				}
			}
		}
		modifier = {
			factor = 5.0
			OR = {
				location = { religion = sunni }
				location = { religion = shiite }
			}
			liege = {
				ai = yes
				OR = {
					religion = sunni
					religion = shiite
				}
			}
		}
		modifier = {
			factor = 0.9
			location = { religion_group = ROOT }
		}
		#non-pagan or reformed pagan converting non-reformed pagan
		modifier = {
			factor = 0.75
			OR = {
				is_pagan_religion = no
				is_reformed_pagan_religion = yes
			}
			location = {
				is_pagan_religion = yes
				is_reformed_pagan_religion = no
			}
		}
		modifier = {
			factor = 0.95
			location = { has_province_modifier = depopulated_1 }
		}
		modifier = {
			factor = 0.85
			location = { has_province_modifier = depopulated_2 }
		}
		modifier = {
			factor = 0.75
			location = { has_province_modifier = depopulated_3 }
		}
		modifier = {
			factor = 3.0
			location = { is_hard_to_convert = yes }
		}
		#non-reformed pagan converting non-pagan or reformed pagan
		modifier = {
			factor = 1.25
			is_pagan_religion = yes
			is_reformed_pagan_religion = no
			location = {
				OR = {
					is_pagan_religion = no
					is_reformed_pagan_religion = yes
				}
			}
		}
		#non-reformed tengri converting non-pagan or reformed pagan
		modifier = {
			factor = 100
			NOT = { any_liege = { ai = no } }
			religion = tengri_pagan
			is_reformed_pagan_religion = no
			location = {
				OR = {
					is_pagan_religion = no
					is_reformed_pagan_religion = yes
				}
			}
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.5
			NOT = { liege = { learning = 5 } }
		}
		modifier = {
			factor = 1.25
			liege = { learning = 5 }
			NOT = { liege = { learning = 10 } }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 10 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 14 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 18 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 20 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 22 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 24 }
		}
		modifier = {
			factor = 1.5
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.25
			learning = 5
			NOT = { learning = 10 }
		}
		modifier = {
			factor = 0.95
			learning = 10
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			religion_authority = 0.6
		}
		modifier = {
			factor = 0.95
			religion_authority = 0.7
		}
		modifier = {
			factor = 0.95
			religion_authority = 0.8
		}
		modifier = {
			factor = 0.75
			liege = {
				society_member_of = monastic_order_dominican
				society_rank >= 4
			}
		}
		modifier = {
			factor = 2.0
			religion_group = indian_group
			location = {
				religion_group = indian_group
			}
		}
		# Hindus and Buddhists have a hard time converting other Indian religions
		modifier = {
			factor = 3.0
			OR = {
				religion = hindu
				religion = buddhist
			}
			location = {
				religion_group = indian_group
				NOT = {
					religion = taoist
			}
		}
		}
		# Jains, Taoists and Bön have a hard time converting ALL non-pagans
		modifier = {
			factor = 3.0
			OR = {
				religion = jain
				religion = taoist
				religion = bon
			}
			location = {
				OR = {
					is_pagan_religion = no
					is_reformed_pagan_religion = yes
				}				
			}
		}

		modifier = {
			factor = 1.5
			NOT = { religion_authority = 0.5 }
		}
		modifier = {
			factor = 1.5
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor = 1.5
			NOT = { religion_authority = 0.3 }
		}
		modifier = {
			factor = 2
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 3.0
			NOT = { religion_authority = 0.1 }
		}
		modifier = {
			factor = 3.0
			location = { has_province_modifier = heretic_stronghold }
		}
		modifier = {
			factor = 0.75
			location = { has_province_modifier = force_converting }
		}
		modifier = {
			factor = 3.0
			location = { has_province_modifier = brm_revolt }
		}
		modifier = {
			factor = 1.5
			location = { religion_authority = 0.9 }
		}
		modifier = {
			factor = 1.5
			location = { religion_authority = 0.8 }
		}
		modifier = {
			factor = 1.5
			location = { religion_authority = 0.7 }
		}
		modifier = {
			factor = 0.9
			trait = zealous
		}
		modifier = {
			factor = 0.9
			liege = { trait = zealous }
		}
		modifier = {
			factor = 3
			has_game_rule = {
				name = religious_conversion
				value = slower
			}
		}
	}

	option = {
		name = EVTOPTA900 # My hard work has paid off!
		trigger = {
			event_target:convert_province = {
				owner = { same_realm = ROOT }
			}
		}
		piety = 10
		religion_authority = { modifier = converted_province_to }
		event_target:convert_province = {
			religion_authority = { modifier = converted_province_from }
			religion = ROOT
			hidden_tooltip = {
				if = {
					limit = { has_province_modifier = heretic_stronghold }
					remove_province_modifier = heretic_stronghold
				}
			}
		}
		liege = {
			add_character_modifier = { name = convert_province_timer duration = 3 hidden = yes }
			letter_event = { id = 20000 tooltip = EVTTOOLTIP20000 }
			hidden_tooltip = {
				if = {
					limit = {
						top_liege = {
							NOT = { character = PREV }
							religion = ROOT
						}
					}
					top_liege = { character_event = { id = 20001 } }
				}
			}
		}
	}
	option = {
		name = EVTOPTA900 # My hard work has paid off!
		trigger = {
			event_target:convert_province = {
				owner = { NOT = { same_realm = ROOT } }
			}
		}
		piety = 25
		religion_authority = { modifier = converted_province_to }
		event_target:convert_province = {
			religion_authority = { modifier = converted_province_from }
			religion = ROOT
			hidden_tooltip = {
				if = {
					limit = { has_province_modifier = heretic_stronghold }
					remove_province_modifier = heretic_stronghold
				}
				owner = { character_event = { id = 39620 } }
			}
		}		
	}
}

# 20000: The Lord Spiritual informs his liege of the conversion
letter_event = {
	id = 20000
	desc = "EVTDESC20000"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20000"
		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
				}
			}
		}
	}
}

# 20001: Informs top liege
character_event = {
	id = 20001
	desc = EVTDESC20001
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	is_triggered_only = yes
	
	notification = yes

	option = {
		name = "EXCELLENT"
	}
}

# 901: The Lord Spiritual converts a subject character
character_event = {
	id = 901
	title = "EVTNAME901"
	desc = "EVTDESC901"
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_inquisition
		NOT = { has_character_modifier = in_seclusion }
		liege = {
			religion = ROOT
			OR = {
				ai = no
				NOT = { religion_group = muslim }
				ROOT = {
					location = {
						ROOT = { is_heresy_of = PREV }
					}
				}
				ROOT = {
					location = {
						ROOT = { is_parent_religion = PREV }
					}
				}
			}
		}
		location = {
			any_province_character = {
				is_adult = yes
				NOT = { rightful_religious_head_scope = { character = PREV } }
				NOT = { character = ROOT }
				NOT = { is_liege_of = ROOT }
				NOT = { religion = ROOT }
				OR = {
					is_ruler = no
					primary_title = {
						controls_religion = no
						mercenary = no
						holy_order = no
					}
				}
				same_realm = ROOT
			}
		}
	}

	mean_time_to_happen = {
		months = 120
		modifier = {
			factor = 1000
			location = {
				owner = {
					NOT = { same_realm = ROOT }
				}
			}
		}
		modifier = {
			factor = 1.25
			is_pagan_religion = yes
		}
		modifier = {
			factor = 100
			NOT = { any_liege = { ai = no } }
			religion = tengri_pagan
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { liege = { learning = 1 } }
		}
		modifier = {
			factor = 1.05
			NOT = { liege = { learning = 2 } }
		}
		modifier = {
			factor = 1.05
			NOT = { liege = { learning = 3 } }
		}
		modifier = {
			factor = 1.05
			NOT = { liege = { learning = 4 } }
		}
		modifier = {
			factor = 1.05
			NOT = { liege = { learning = 5 } }
		}
		modifier = {
			factor = 1.05
			NOT = { liege = { learning = 6 } }
		}
		modifier = {
			factor = 1.05
			NOT = { liege = { learning = 7 } }
		}
		modifier = {
			factor = 1.05
			NOT = { liege = { learning = 8 } }
		}
		modifier = {
			factor = 1.05
			NOT = { liege = { learning = 9 } }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 11 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 12 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 13 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 14 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 15 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 16 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 17 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 18 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 19 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 20 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 21 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 22 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 23 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 24 }
		}
		modifier = {
			factor = 0.95
			liege = { learning = 25 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
		modifier = {
			factor = 2.0
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor = 2.0
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 0.75
			religion_authority = 0.6
		}
		modifier = {
			factor = 0.75
			religion_authority = 0.8
		}
		modifier = {
			factor = 3.0
			is_pagan_religion = yes
			is_reformed_pagan_religion = no
		}
		modifier = {
			factor = 2.0
			religion_group = indian_group
			location = {
				religion_group = indian_group
			}
		}
	}

	option = {
		name = "EVTOPTA901"
		piety = 5
		location = {
			random_province_character = {
				limit = {
					is_adult = yes
					NOT = { rightful_religious_head_scope = { character = PREV } }
					NOT = { character = ROOT }
					NOT = { is_liege_of = ROOT }
					NOT = { religion = ROOT }
					OR = {
						is_ruler = no
						primary_title = {
							controls_religion = no
							mercenary = no
							holy_order = no
						}
					}
					same_realm = ROOT
				}
				letter_event = { id = 20010 tooltip = "EVTTOOLTIP20010" }
			}
		}
	}
}

# 20010: Inform the target character about this
letter_event = {
	id = 20010
	desc = "EVTDESC20010"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20010"

		if = {
			limit = { higher_tier_than = BARON }
			religion_authority = {
				modifier = ruler_converted_from
			}
		}

		religion = FROM

		if = {
			limit = { higher_tier_than = BARON }
			religion_authority = {
				modifier = ruler_converted_to
			}
		}

		hidden_tooltip = {
			FROM = {
				liege = { letter_event = { id = 20011 } }
			}
			if = {
				limit = {
					liege = {
						job_spiritual = {
							NOT = { character = FROM }
						}
					}
				}
				liege = { letter_event = { id = 20012 } }
			}
		}
	}
}

# 20011: Inform Lord Spiritual's Liege about this
letter_event = {
	id = 20011
	desc = "EVTDESC20011"
	border = GFX_event_letter_frame_religion
	show_from_from = yes

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20011"
	}
}

# 20012: Inform character's Liege about this
letter_event = {
	id = 20012
	desc = "EVTDESC20012"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20012"
		trigger = { FROM = { religion = ROOT } }
	}
	option = {
		name = "EVTOPTB20012"
		trigger = { FROM = { NOT = { religion = ROOT } } }
	}
}


# 902: The Lord Spiritual is attacked by heathens (Gets away, Is wounded, Is killed)
character_event = {
	id = 902
	title = "EVTNAME902"
	desc = "EVTDESC902"
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_inquisition
		NOT = { has_character_modifier = in_seclusion }
		liege = {
			religion = ROOT
			OR = {
				ai = no
				NOT = { religion_group = muslim }
				ROOT = {
					location = {
						ROOT = { is_heresy_of = PREV }
					}
				}
				ROOT = {
					location = {
						ROOT = { is_parent_religion = PREV }
					}
				}
			}
		}
		location = {
			NOT = { religion = ROOT }
			OR = {
				owner = { same_realm = ROOT }
				ROOT = { has_character_flag = preacher_hidden }
			}
		}
	}

	mean_time_to_happen = {
		months = 120
		modifier = {
			factor = 1000
			location = {
				NOR = {
					owner = { same_realm = ROOT }
					ROOT = { has_character_flag = preacher_hidden }
				}
			}
		}
		modifier = {
			factor = 0.8
			has_character_flag = preacher_hidden
		}
		modifier = {
			factor = 2.0
			liege = {
				tier = count
				ai = yes
			}
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 1.05
			learning = 11
		}
		modifier = {
			factor = 1.05
			learning = 12
		}
		modifier = {
			factor = 1.05
			learning = 13
		}
		modifier = {
			factor = 1.05
			learning = 14
		}
		modifier = {
			factor = 1.05
			learning = 15
		}
		modifier = {
			factor = 1.05
			learning = 16
		}
		modifier = {
			factor = 1.05
			learning = 17
		}
		modifier = {
			factor = 1.05
			learning = 18
		}
		modifier = {
			factor = 1.05
			learning = 19
		}
		modifier = {
			factor = 1.05
			learning = 20
		}
		modifier = {
			factor = 1.05
			learning = 21
		}
		modifier = {
			factor = 1.05
			learning = 22
		}
		modifier = {
			factor = 1.05
			learning = 23
		}
		modifier = {
			factor = 1.05
			learning = 24
		}
		modifier = {
			factor = 1.05
			learning = 25
		}
		modifier = {
			factor = 1.1
			religion_authority = 0.6
		}
		modifier = {
			factor = 1.1
			religion_authority = 0.7
		}
		modifier = {
			factor = 1.1
			religion_authority = 0.8
		}
		modifier = {
			factor = 1.1
			religion_authority = 0.9
		}
		modifier = {
			factor = 1.1
			religion_authority = 1.0
		}
		modifier = {
			factor = 0.9
			NOT = { religion_authority = 0.5 }
		}
		modifier = {
			factor = 0.9
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor = 0.9
			NOT = { religion_authority = 0.3 }
		}
		modifier = {
			factor = 0.9
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 0.9
			NOT = { religion_authority = 0.1 }
		}
	}

	option = {
		name = "EVTOPTA902"
		random_list = {
			50 = { character_event = { id = 20020 tooltip = "EVTTOOLTIP20020" } }
			40 = { character_event = { id = 20021 tooltip = "EVTTOOLTIP20021" } }
			10 = {
				hidden_tooltip = {
					liege = { character_event = { id = 20023 } }
				}
				death = { death_reason = death_rabble }
			}
		}
	}
}

# 20020: Lord Spiritual gets away
character_event = {
	id = 20020
	desc = "EVTDESC20020"
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20020"
		prestige = -10
	}
}

# 20021: Lord Spiritual gets wounded
character_event = {
	id = 20021
	desc = "EVTDESC20021"
	picture = GFX_evt_illness
	border = GFX_event_normal_frame_religion
	
	is_triggered_only = yes
	
	immediate = {
		location = {
			save_event_target_as = wounded_location
		}
	}

	option = {
		name = "EVTOPTA20021"
		trigger = {
			NOT = {
				AND = {
					trait = wroth
					NOT = { trait = humble }
				}
			}
		}
		add_trait = wounded
		liege = { character_event = { id = 20022 tooltip = "EVTTOOLTIP20022" } }
	}
	option = {
		name = "EVTOPTB20021"
		trigger = {
			trait = wroth
			NOT = { trait = humble }
		}
		add_trait = wounded
		add_trait = zealous
		liege = { character_event = { id = 20022 tooltip = "EVTTOOLTIP20022" } }
	}
}

# 20022: Inform the Liege about wounding
character_event = {
	id = 20022
	desc = EVTDESC20022
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_religion
	is_triggered_only = yes
	notification = yes

	immediate = {
		prestige = -10
	}
	
	option = {
		name = EVTOPTA20022
		tooltip = { prestige = -10 }
	}
}

# 20023: Inform the Liege about death
character_event = {
	id = 20023
	desc = "EVTDESC20023"
	picture = GFX_evt_death
	border = GFX_event_normal_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20023"
		prestige = -15
	}
}


# 903: The Lord Spiritual suspects a subject character of heresy
character_event = {
	id = 903
	title = "EVTNAME903"
	desc = "EVTDESC903"
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_inquisition
		NOT = { has_character_modifier = in_seclusion }
		religion_group = christian
		has_heresies = yes
		trait = zealous
		liege = {
			religion = ROOT
			OR = {
				ai = no
				NOT = { religion_group = muslim }
				ROOT = {
					location = {
						ROOT = {
							is_heresy_of = PREV
						}
					}
				}
				ROOT = {
					location = {
						ROOT = {
							is_parent_religion = PREV
						}
					}
				}
			}
		}
		location = {
			any_province_lord = {
				trait = cynical
				NOT = { is_liege_of = ROOT }
				NOT = { has_character_flag = no_heretic }
				NOT = { has_character_flag = branded_heretic }
				NOT = { character = ROOT }
				age = 20
				same_realm = ROOT
				religion = ROOT
				can_change_religion = yes
				NOT = { piety = 100 }
				OR = {
					is_ruler = no
					primary_title = { tier = BARON }
					AND = {
						primary_title = { tier = COUNT }
						ROOT = { liege = { primary_title = { higher_tier_than = COUNT } } }
					}
					AND = {
						primary_title = { tier = DUKE }
						ROOT = { liege = { primary_title = { higher_tier_than = DUKE } } }
					}
					AND = {
						primary_title = { tier = KING }
						ROOT = { liege = { primary_title = { higher_tier_than = KING } } }
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 480
		modifier = {
			factor = 5000
			location = {
				owner = {
					NOT = { same_realm = ROOT }
				}
			}
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
		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 = 0.9
			religion_authority = 1.0
		}
		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 = 1.1
			NOT = { religion_authority = 0.1 }
		}
	}

	immediate = {
		location = {
			random_province_lord = {
				limit = {
					trait = cynical
					NOT = { is_liege_of = ROOT }
					NOT = { has_character_flag = no_heretic }
					NOT = { has_character_flag = branded_heretic }
					NOT = { character = ROOT }
					age = 20
					same_realm = ROOT
					religion = ROOT
					can_change_religion = yes
					NOT = { piety = 100 }
					OR = {
						is_ruler = no
						primary_title = { tier = BARON }
						AND = {
							primary_title = { tier = COUNT }
							ROOT = { liege = { primary_title = { higher_tier_than = COUNT } } }
						}
						AND = {
							primary_title = { tier = DUKE }
							ROOT = { liege = { primary_title = { higher_tier_than = DUKE } } }
						}
						AND = {
							primary_title = { tier = KING }
							ROOT = { liege = { primary_title = { higher_tier_than = KING } } }
						}
					}
				}
				save_event_target_as = suspected_heretic
			}
		}
	}

	option = {
		name = "EVTOPTA903"
		ai_chance = { factor = 75 }
		event_target:suspected_heretic = {
			character_event = { id = 20030 days = 7 tooltip = "EVTTOOLTIP20030" }
		}
	}
}

# 20030: Noble reacts to the accusations
character_event = {
	id = 20030
	desc = "EVTDESC20030"
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20030"
		trigger = {
			NOT = {
				religion_group = muslim
			}
		}
		FROM = {
			liege = { letter_event = { id = 20032 tooltip = "EVTTOOLTIP20032" } }
		}
	}
	option = {
		name = "EVTOPTB20030"
		trigger = {
			religion_group = muslim
		}
		FROM = {
			liege = { letter_event = { id = 20032 tooltip = "EVTTOOLTIP20032" } }
		}
	}
}

# 20032: Liege: The noble complains
letter_event = {
	id = 20032
	desc = "EVTDESC20032"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20032" #Noble = no heretic
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2.0
				opinion = { who = FROM value = 50 }
			}
			modifier = {
				factor = 2.0
				opinion = { who = FROM value = 75 }
			}
		}
		FROM = {
			letter_event = { id = 20033 days = 7 tooltip = "EVTTOOLTIP20033" }
			opinion = {
				modifier = opinion_grateful
				who = ROOT
				years = 5
			}
			set_character_flag = no_heretic
		}
		job_spiritual = {
			letter_event = { id = 20034 days = 7 tooltip = "EVTTOOLTIP20034" }
			opinion = {
				modifier = opinion_chastised_by_liege
				who = ROOT
				years = 5
			}
		}
	}
	option = {
		name = "EVTOPTB20032" #Noble = heretic
		ai_chance = {
			factor = 50
			modifier = {
				factor = 2.0
				NOT = { opinion = { who = FROM value = -25 } }
			}
			modifier = {
				factor = 2.0
				NOT = { opinion = { who = FROM value = -50 } }
			}
		}
		FROM = {
			letter_event = { id = 20035 days = 7 tooltip = "EVTTOOLTIP20035" }
			opinion = {
				modifier = opinion_branded_heretic
				who = ROOT
				years = 10
			}
		}
		job_spiritual = {
			letter_event = { id = 20036 days = 7 tooltip = "EVTTOOLTIP20036" }
		}
	}
}

# 20033: Noble: Noble isn't heretic
letter_event = {
	id = 20033
	desc = "EVTDESC20033"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20033"
		trigger = {
			NOT = {
				religion_group = muslim
			}
		}
	}
	option = {
		name = "EVTOPTB20033"
		trigger = {
			religion_group = muslim
		}
	}
}

# 20034: Lord Spiritual: Noble isn't heretic
letter_event = {
	id = 20034
	desc = "EVTDESC20034"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20034"
		liege = {
			reverse_opinion = {
				modifier = opinion_disappointed
				who = ROOT
				years = 5
			}
		}
	}
}

# 20035: Noble: Noble is heretic
letter_event = {
	id = 20035
	desc = "EVTDESC20035"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20035"
		if = {
			limit = { ai = no }
			become_heretic = yes
		}
		if = {
			limit = { ai = yes }
			heresy_character_effect = yes
		}
	}
}

# 20036: Lord Spiritual: Noble is heretic
letter_event = {
	id = 20036
	desc = "EVTDESC20036"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20036"
		piety = 10
	}
}

# 20037: Increased revolt risk
character_event = {
	id = 20037
	desc = "EVTDESC20037"
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_inquisition
		NOT = { has_character_modifier = in_seclusion }
		liege = {
			OR = {
				ai = no
				NOT = { religion_group = muslim }
				ROOT = {
					location = {
						ROOT = {
							is_heresy_of = PREV
						}
					}
				}
				ROOT = {
					location = {
						ROOT = {
							is_parent_religion = PREV
						}
					}
				}
			}
		}
		location = {
			NOT = { religion = ROOT }
			NOT = { has_province_modifier = religious_tension }
		}
	}

	mean_time_to_happen = {
		months = 240

		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 1.05
			learning = 11
		}
		modifier = {
			factor = 1.05
			learning = 12
		}
		modifier = {
			factor = 1.05
			learning = 13
		}
		modifier = {
			factor = 1.05
			learning = 14
		}
		modifier = {
			factor = 1.05
			learning = 15
		}
		modifier = {
			factor = 1.05
			learning = 16
		}
		modifier = {
			factor = 1.05
			learning = 17
		}
		modifier = {
			factor = 1.05
			learning = 18
		}
		modifier = {
			factor = 1.05
			learning = 19
		}
		modifier = {
			factor = 1.05
			learning = 20
		}
		modifier = {
			factor = 1.05
			learning = 21
		}
		modifier = {
			factor = 1.05
			learning = 22
		}
		modifier = {
			factor = 1.05
			learning = 23
		}
		modifier = {
			factor = 1.05
			learning = 24
		}
		modifier = {
			factor = 1.05
			learning = 25
		}
		modifier = {
			factor = 0.75
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor =0.75
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 2.0
			religion_authority = 0.6
		}
		modifier = {
			factor = 2.0
			religion_authority = 0.8
		}
	}

	option = {
		name = "EVTOPTA20037"
		hidden_tooltip = {
			location = {
				# Inform barons about the rebels
				owner = {
					if = {
						limit = {
							is_liege_of = ROOT
						}
						set_character_flag = liege_informed
					}
				}
				any_province_lord = {
					limit = {
						NOT = { has_character_flag = liege_informed }
						ai = no
					}
					character_event = { id = 20038 days = 1 }
				}
				# Inform liege
				ROOT = {
					liege = { letter_event = { id = 20039 } }
					clr_character_flag = liege_informed
				}
			}
		}
	}
}

# 20038: Inform province lords
character_event = {
	id = 20038
	desc = "EVTDESC20038"
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20038"
	}
}

# 20039: Inform liege
letter_event = {
	id = 20039
	desc = "EVTDESC20039"
	border = GFX_event_letter_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20039"
		FROM = {
			location = {
				# Increase revolt risk
				add_province_modifier = {
					name = religious_tension
					duration = 365
				}
				# Province barons
				any_province_lord = {
					limit = {
						NOT = { character = ROOT }
						NOT = { character = FROM }
					}
					opinion = {
						who = ROOT
						modifier = opinion_irritated
						years = 5
					}
				}
			}
		}
	}
}

# Chaplain arrives at Pagan capital
character_event = {
	id = 39650
	desc = EVTDESC39650
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes	
	prisoner = no

	trigger = {
		has_job_action = action_inquisition
		NOT = { has_character_modifier = in_seclusion }
		NOT = { has_character_flag = preacher_arrives }
		NOT = { has_character_flag = preacher_hidden }
		NOT = { has_character_flag = arrived_at_pagan_capital }
		liege = {
			higher_tier_than = COUNT
			OR = {
				independent = yes
				higher_tier_than = DUKE
			}
			OR = {
				is_pagan_religion = no
				is_reformed_pagan_religion = yes
			}
			OR = {
				NOT = { religion_group = indian_group }
				ai = no
			}
			ROOT = {
				location = {
					owner = {
						independent = yes
						controls_religion = no
						is_pagan_religion = yes
						is_reformed_pagan_religion = no
						capital_scope = { province = PREVPREV }
						NOR = {
							has_opinion_modifier = { who = PREVPREVPREV modifier = opinion_sent_preacher }
							rightful_religious_head_scope = { character = PREV }
							religion = ROOT
							is_heresy_of = ROOT
							is_parent_religion = ROOT
							same_realm = ROOT
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}	

	option = {
		name = EVTOPTA39650
		set_character_flag = arrived_at_pagan_capital
		location = {
			owner = {
				character_event = { id = 39600 days = 4 tooltip = EVTTOOLTIP39600 }
			}
		}
	}
}

# Chaplain has a chance of converting the Pagan lord
character_event = {
	id = 39651
	title = EVTNAME39651
	desc = EVTDESC39651
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = preacher_arrives

	trigger = {
		has_job_action = action_inquisition
		NOT = { has_character_modifier = in_seclusion }
		liege = {
			higher_tier_than = COUNT
			OR = {
				independent = yes
				higher_tier_than = DUKE
			}
			OR = {
				is_pagan_religion = no
				is_reformed_pagan_religion = yes
			}
			OR = {
				NOT = { religion_group = indian_group }
				ai = no
			}
			ROOT = {
				location = {
					owner = {
						independent = yes
						controls_religion = no
						is_pagan_religion = yes
						is_reformed_pagan_religion = no
						capital_scope = { province = PREVPREV }
						NOR = {
							has_opinion_modifier = { who = PREVPREVPREV modifier = opinion_sent_preacher }
							rightful_religious_head_scope = { character = PREV }
							religion = ROOT
							is_heresy_of = ROOT
							is_parent_religion = ROOT
							same_realm = ROOT
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 500
		modifier = {
			factor = 1000
			NOT = { has_character_flag = preacher_arrives }
		}
		modifier = {
			factor = 0.75
			location = { religion = ROOT }
		}
		modifier = {
			factor = 1.5
			NOT = { year = 900 }
		}
		modifier = {
			factor = 0.75
			OR = {
				religion = chalcedonian
				religion = orthodox
				religion = bogomilist
				religion = monothelite
				religion = iconoclast
			}
			is_heretic = no
			location = {
				owner = { culture_group = east_slavic }
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			location = {
				owner = { culture_group = north_germanic }
			}
		}
		modifier = {
			factor = 1.3
			location = {
				NOT = {
					OR = {
						owner = { culture = ROOT }
						owner = { culture_group = ROOT }
					}
				}
			}
		}
		modifier = {
			factor = 0.8
			location = {
				owner = { culture_group = ROOT }
			}
		}
		modifier = {
			factor = 0.7
			location = {
				owner = { culture = ROOT }
			}
		}
		
		modifier = {
			factor = 1.25
			NOT = { realm_learning = 15 }
		}
		modifier = {
			factor = 1.25
			NOT = { realm_learning = 16 }
		}
		modifier = {
			factor = 1.25
			NOT = { realm_learning = 17 }
		}
		modifier = {
			factor = 1.25
			NOT = { realm_learning = 18 }
		}
		modifier = {
			factor = 1.20
			NOT = { realm_learning = 19 }
		}
		modifier = {
			factor = 1.20
			NOT = { realm_learning = 20 }
		}
		modifier = {
			factor = 1.20
			NOT = { realm_learning = 21 }
		}
		modifier = {
			factor = 1.15
			NOT = { realm_learning = 22 }
		}
		modifier = {
			factor = 1.10
			NOT = { realm_learning = 23 }
		}
		modifier = {
			factor = 0.95
			realm_learning = 24
		}
		modifier = {
			factor = 0.95
			realm_learning = 25
		}
		modifier = {
			factor = 0.95
			realm_learning = 26
		}
		modifier = {
			factor = 0.90
			realm_learning = 27
		}
		modifier = {
			factor = 0.90
			realm_learning = 28
		}
		modifier = {
			factor = 0.85
			realm_learning = 29
		}
		modifier = {
			factor = 0.85
			realm_learning = 30
		}
		modifier = {
			factor = 0.80
			realm_learning = 31
		}
		modifier = {
			factor = 0.80
			realm_learning = 32
		}
		modifier = {
			factor = 0.75
			realm_learning = 33
		}
		modifier = {
			factor = 0.75
			realm_learning = 34
		}
		modifier = {
			factor = 0.75
			realm_learning = 35
		}
		modifier = {
			factor = 0.75
			realm_learning = 36
		}
		modifier = {
			factor = 0.75
			realm_learning = 37
		}
		modifier = {
			factor = 0.75
			realm_learning = 38
		}
		modifier = {
			factor = 1.2
			NOT = { religion_authority = 0.6 }
		}
		modifier = {
			factor = 1.1
			NOT = { religion_authority = 0.7 }
		}
		modifier = {
			factor = 0.9
			religion_authority = 0.8
		}
		modifier = {
			factor = 0.8
			religion_authority = 0.9
		}
		modifier = {
			factor = 0.7
			religion_authority = 1.0
		}
		modifier = {
			factor = 100
			NOT = { religion_authority = 0.5 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.90
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.85
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.80
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 0
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 2
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.5
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.25
			NOT = { opinion = { who = liege value = -25 } }
		}
	}

	option = {
		name = EVTOPTA39651
		hidden_tooltip = {
			location = {
				owner = {
					character_event = { id = 39601 days = 1 }
				}
			}
		}
	}
}

# Chaplain converts Pagan courtier
character_event = {
	id = 39652
	title = EVTNAME39652
	desc = EVTDESC39652
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = preacher_arrives

	trigger = {
		has_job_action = action_inquisition
		NOT = { has_character_modifier = in_seclusion }
		liege = {
			higher_tier_than = COUNT
			OR = {
				independent = yes
				higher_tier_than = DUKE
			}
			OR = {
				is_pagan_religion = no
				is_reformed_pagan_religion = yes
			}
			OR = {
				NOT = { religion_group = indian_group }
				ai = no
			}
			ROOT = {
				location = {
					owner = {
						independent = yes
						controls_religion = no
						is_pagan_religion = yes
						is_reformed_pagan_religion = no
						capital_scope = { province = PREVPREV }
						NOR = {
							has_opinion_modifier = { who = PREVPREVPREV modifier = opinion_sent_preacher }
							rightful_religious_head_scope = { character = PREV }
							religion = ROOT
							is_heresy_of = ROOT
							is_parent_religion = ROOT
							same_realm = ROOT
						}
						any_courtier = {
							age = 14
							prisoner = no
							at_location = ROOT
							NOT = { trait = incapable }
							ai = yes
							is_pagan_religion = yes
							is_reformed_pagan_religion = no
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 100
		modifier = {
			factor = 1000
			NOT = { has_character_flag = preacher_arrives }
		}
		modifier = {
			factor = 0.75
			location = { religion = ROOT }
		}
		modifier = {
			factor = 1.5
			NOT = { year = 900 }
		}
		modifier = {
			factor = 0.75
			OR = {
				religion = chalcedonian
				religion = orthodox
				religion = bogomilist
				religion = monothelite
				religion = iconoclast
			}
			is_heretic = no
			location = {
				owner = { culture_group = east_slavic }
			}
		}
		modifier = {
			factor = 0.75
			OR = {
				religion = chalcedonian
				religion = catholic
				religion = cathar
				religion = fraticelli
				religion = waldensian
				religion = lollard
				religion = adoptionist
			}
			is_heretic = no
			location = {
				owner = { culture_group = north_germanic }
			}
		}
		modifier = {
			factor = 0.9
			location = {
				owner = { culture_group = ROOT }
			}
		}
		modifier = {
			factor = 0.9
			location = {
				owner = { culture = ROOT }
			}
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
		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 = 0.9
			religion_authority = 1.0
		}
		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 = 1.1
			NOT = { religion_authority = 0.1 }
		}
	}

	option = {
		name = EVTOPTA39652
		hidden_tooltip = {
			location = {
				owner = {
					random_courtier = {
						limit = {
							age = 14
							prisoner = no
							at_location = ROOT
							NOT = { trait = incapable }
							ai = yes
							is_pagan_religion = yes
							is_reformed_pagan_religion = no
						}
						character_event = { id = 39610 days = 1 }
					}
				}
			}
		}
	}
}

# Chaplain squabbles with other chaplain
character_event = {
	id = 39653
	title = EVTNAME39653
	desc = EVTDESC39653
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = preacher_arrives

	trigger = {
		has_job_action = action_inquisition
		NOT = { has_character_modifier = in_seclusion }
		liege = {
			higher_tier_than = COUNT
			OR = {
				independent = yes
				higher_tier_than = DUKE
			}
			OR = {
				is_pagan_religion = no
				is_reformed_pagan_religion = yes
			}
			OR = {
				NOT = { religion_group = indian_group }
				ai = no
			}
			ROOT = {
				location = {
					owner = {
						independent = yes
						controls_religion = no
						is_pagan_religion = yes
						is_reformed_pagan_religion = no
						capital_scope = { province = PREVPREV }
						NOR = {
							has_opinion_modifier = { who = PREVPREVPREV modifier = opinion_sent_preacher }
							rightful_religious_head_scope = { character = PREV }
							religion = ROOT
							is_heresy_of = ROOT
							is_parent_religion = ROOT
							same_realm = ROOT
						}
					}
				}
			}
		}
		any_playable_ruler = {
			any_courtier = {
				has_job_action = action_inquisition
				has_character_flag = preacher_arrives
				at_location = ROOT
				NOT = { character = ROOT }
				NOT = { same_liege = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 120
		modifier = {
			factor = 1000
			NOT = { has_character_flag = preacher_arrives }
		}
		modifier = {
			factor = 0.75
			location = { religion = ROOT }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
	}

	option = {
		name = EVTOPTA39653
		hidden_tooltip = {
			random_playable_ruler = {
				limit = {
					any_courtier = {
						has_job_action = action_inquisition
						has_character_flag = preacher_arrives
						at_location = ROOT
						NOT = { character = ROOT }
						NOT = { same_liege = ROOT }
					}
				}
				random_courtier = {
					limit = {
						has_job_action = action_inquisition
						has_character_flag = preacher_arrives
						at_location = ROOT
						NOT = { character = ROOT }
						NOT = { same_liege = ROOT }
					}
					character_event = { id = 39611 days = 1 }
				}
			}
		}
	}
}

# Clear preacher_arrives flag
character_event = {
	id = 39654
	hide_window = yes
	
	min_age = 16
	capable_only = yes
	prisoner = no
	has_character_flag = preacher_arrives
	
	trigger = {
		OR = {
			NOT = { has_job_action = action_inquisition }
			NOT = {
				liege = {
					religion = ROOT
					OR = {
						ai = no
						NOT = { religion_group = muslim }
						ROOT = { location = { is_heresy_of = PREV } }
						ROOT = { location = { is_parent_religion = PREV } }
					}
					higher_tier_than = COUNT
					OR = {
						independent = yes
						higher_tier_than = DUKE
					}
					OR = {
						is_pagan_religion = no
						is_reformed_pagan_religion = yes
					}
					OR = {
						NOT = { religion_group = indian_group }
						ai = no
					}
					ROOT = {
						location = {
							owner = {
								independent = yes
								controls_religion = no
								is_pagan_religion = yes
								is_reformed_pagan_religion = no
								capital_scope = { province = PREVPREV }
								NOR = {
									has_opinion_modifier = { who = PREVPREVPREV modifier = opinion_sent_preacher }
									rightful_religious_head_scope = { character = PREV }
									religion = ROOT
									is_heresy_of = ROOT
									is_parent_religion = ROOT
									same_realm = ROOT
								}
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		clr_character_flag = preacher_arrives
		clr_character_flag = arrived_at_pagan_capital
	}
}

# Clear preacher_hidden flag
character_event = {
	id = 39655
	hide_window = yes
	
	min_age = 16
	has_character_flag = preacher_hidden
	
	trigger = {
		OR = {
			NOT = { has_job_action = action_inquisition }
			NOT = {
				liege = {
					religion = ROOT
					OR = {
						ai = no
						NOT = { religion_group = muslim }
						ROOT = { location = { is_heresy_of = PREV } }
						ROOT = { location = { is_parent_religion = PREV } }
					}
					higher_tier_than = COUNT
					OR = {
						independent = yes
						higher_tier_than = DUKE
					}
					OR = {
						is_pagan_religion = no
						is_reformed_pagan_religion = yes
					}
					OR = {
						NOT = { religion_group = indian_group }
						ai = no
					}
					ROOT = {
						location = {
							owner = {
								independent = yes
								controls_religion = no
								is_pagan_religion = yes
								is_reformed_pagan_religion = no
								capital_scope = { province = PREVPREV }
								NOR = {
									has_opinion_modifier = { who = PREVPREVPREV modifier = opinion_sent_preacher }
									rightful_religious_head_scope = { character = PREV }
									religion = ROOT
									is_heresy_of = ROOT
									is_parent_religion = ROOT
									same_realm = ROOT
								}
							}
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		days = 1
	}
	
	immediate = {
		clr_character_flag = preacher_hidden
	}
}

# 39656: Ruler finds out that the Chaplain did not return home
character_event = {
	id = 39656
	title = EVTNAME39656
	desc = EVTDESC39656
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	
	capable_only = yes
	prisoner = no
	has_character_flag = preacher_hidden

	trigger = {
		has_job_action = action_inquisition
		liege = {
			religion = ROOT
			OR = {
				ai = no
				NOT = { religion_group = muslim }
				ROOT = { location = { is_heresy_of = PREV } }
				ROOT = { location = { is_parent_religion = PREV } }
			}
			higher_tier_than = COUNT
			OR = {
				independent = yes
				higher_tier_than = DUKE
			}
			OR = {
				is_pagan_religion = no
				is_reformed_pagan_religion = yes
			}
			OR = {
				NOT = { religion_group = indian_group }
				ai = no
			}
			ROOT = {
				location = {
					owner = {
						independent = yes
						controls_religion = no
						is_pagan_religion = yes
						is_reformed_pagan_religion = no
						capital_scope = { province = PREVPREV }
						NOR = {
							has_opinion_modifier = { who = PREVPREVPREV modifier = opinion_sent_preacher }
							rightful_religious_head_scope = { character = PREV }
							religion = ROOT
							is_heresy_of = ROOT
							is_parent_religion = ROOT
							same_realm = ROOT
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 120
		modifier = {
			factor = 1000
			NOT = { has_character_flag = preacher_hidden }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 1.05
			learning = 11
		}
		modifier = {
			factor = 1.05
			learning = 12
		}
		modifier = {
			factor = 1.05
			learning = 13
		}
		modifier = {
			factor = 1.05
			learning = 14
		}
		modifier = {
			factor = 1.05
			learning = 15
		}
		modifier = {
			factor = 1.05
			learning = 16
		}
		modifier = {
			factor = 1.05
			learning = 17
		}
		modifier = {
			factor = 1.05
			learning = 18
		}
		modifier = {
			factor = 1.05
			learning = 19
		}
		modifier = {
			factor = 1.05
			learning = 20
		}
		modifier = {
			factor = 1.05
			learning = 21
		}
		modifier = {
			factor = 1.05
			learning = 22
		}
		modifier = {
			factor = 1.05
			learning = 23
		}
		modifier = {
			factor = 1.05
			learning = 24
		}
		modifier = {
			factor = 1.05
			learning = 25
		}
	}

	immediate = {
		location = {
			save_event_target_as = convert_province
		}
	}
	
	option = {
		name = CURSES
		event_target:convert_province = {
			owner = {
				tooltip = {
					ROOT = { imprison = PREV }
				}
				hidden_tooltip = {
					character_event = { id = 39624 } # Notify
				}
			}
		}
		hidden_tooltip = {
			liege = {
				character_event = { id = 39625 } # Notify
			}
		}
	}
}

##############################
# LORD SPIRITUAL
# JOB: action_improve_rel_relations
##############################

# 906: The Lord Spiritual improves relations between the liege and a bishop
character_event = {
	id = 906
	title = "EVTNAME906"
	desc = "EVTDESC906"
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_improve_rel_relations
		NOT = { has_character_modifier = in_seclusion }
		location = {
			any_province_lord = {
				NOT = { character = ROOT }
				is_theocracy = yes
				religion = ROOT
				NOT = { is_liege_of = ROOT }
				NOT = { character = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 120

		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
		modifier = {
			factor = 2.0
			NOT = { religion_authority = 0.4 }
		}
		modifier = {
			factor = 2.0
			NOT = { religion_authority = 0.2 }
		}
		modifier = {
			factor = 0.75
			religion_authority = 0.6
		}
		modifier = {
			factor = 0.75
			religion_authority = 0.8
		}
	}

	option = {
		name = "EVTOPTA906"
		hidden_tooltip = {
			location = {
				random_province_lord = {
					limit = {
						NOT = { character = ROOT }
						is_theocracy = yes
						religion = ROOT
						NOT = { is_liege_of = ROOT }
					}
					character_event = { id = 20060 days = 7 }
				}
			}
		}
	}
}

# 20060: Inform the bishop
character_event = {
	id = 20060
	desc = "EVTDESC20060"
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20060"
		hidden_tooltip = {
			FROM = {
				liege = { letter_event = { id = 20061 } }
			}
		}
	}
}

# 20061: The liege is informed of the success
letter_event = {
	id = 20061
	desc = "EVTDESC20061"
	border = GFX_event_letter_frame_religion
	show_from_from = yes

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20061"
		FROM = {
			opinion = {
				modifier = opinion_improved_relations
				who = ROOT
				years = 5
			}
		}
	}
}


# 907: The Lord Spiritual attempts to sabotage the relations of a subject priest towards the official head of the religion
character_event = {
	id = 907
	title = "EVTNAME907"
	desc = "EVTDESC907"
	picture = GFX_evt_pope_feast
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_improve_rel_relations
		NOT = { has_character_modifier = in_seclusion }
		religion_head = {
			NOT = { character = liege }
		}
		location = {
			any_province_lord = {
				is_theocracy = yes
				NOT = { is_liege_of = ROOT }
				same_realm = ROOT
				religion = ROOT
				NOT = { character = ROOT }
				religion_head = {
					is_alive = yes
					NOT = { character = PREV }
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 240

		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
	}

	option = {
		name = "EVTOPTA907"
		hidden_tooltip = {
			location = {
				random_province_lord = {
					limit = {
						is_theocracy = yes
						NOT = { is_liege_of = ROOT }
						same_realm = ROOT
						religion = ROOT
						religion_head = {
							NOT = { character = PREV }
						}
					}
					character_event = { id = 20070 days = 7 }
				}
			}
		}
	}
}

# 20070: Inform the bishop
character_event = {
	id = 20070
	desc = "EVTDESC20070"
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20070"
		hidden_tooltip = {
			FROM = {
				liege = { letter_event = { id = 20071 } }
			}
		}
	}
}

# 20071: The liege is informed of the success
letter_event = {
	id = 20071
	desc = "EVTDESC20071"
	border = GFX_event_letter_frame_religion
	show_from_from = yes

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20071"
		FROM = {
			religion_head = {
				reverse_opinion = {
					modifier = opinion_head_of_religion_negative
					who = PREV
					years = 5
				}
			}
		}
	}
}


##############################
# LORD SPIRITUAL
# JOB: action_advance_cul_tech
##############################

# 926: A Great Inventor offers his help: Random Culture Tech increases
character_event = {
	id = 926
	title = "EVTNAME926"
	desc = "EVTDESC926"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion
	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_advance_cul_tech
		NOT = { has_character_modifier = in_seclusion }
	}

	mean_time_to_happen = {
		months = 1000

		modifier = {
			factor = 0.5
			OR = {
				has_focus = focus_scholarship
				liege = { has_focus = focus_scholarship }
			}
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
	}

	option = {
		name = "EVTOPTA926"
		liege = { letter_event = { id = 20260 tooltip = "EVTTOOLTIP20260" } }
	}
}

# 20260: The liege is informed of the success
letter_event = {
	id = 20260
	desc = "EVTDESC20260"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20260"
		scaled_wealth = -0.5
		culture_techpoints = 50
		if = {
			limit = {
				has_dlc = "Reapers"
			}
			custom_tooltip = {
				text = increase_prosperity_custom_tooltip
				hidden_tooltip = {
					FROM = {
						location = {
							change_variable = { which = prosperity_value value = 6 }
						}
					}
				}
			}
		}
	}
	option = {
		name = "EVTOPTB20260"
	}
}


# 927: Lord Spiritual = heretic
character_event = {
	id = 927
	title = "EVTNAME927"
	desc = "EVTDESC927"
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion
	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		NOT = { has_character_modifier = in_seclusion }
		has_secret_religion = no
		is_heretic = no
		liege = { religion = ROOT }
		has_heresies = yes
		has_job_action = action_advance_cul_tech
		NOT = { trait = zealous }
		controls_religion = no
		NOT = { rightful_religious_head = ROOT }
	}

	mean_time_to_happen = {
		months = 1000

		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
	}

	option = {
		name = "EVTOPTA927"
		ai_chance = { factor = 80 }
		if = {
			limit = { ai = no }
			become_heretic = yes
			hidden_tooltip = {
				liege = { letter_event = { id = 20270 } }
			}
		}
		if = {
			limit = { ai = yes }
			character_event = { id = 20271 } #become heretic
		}
	}
	option = {
		name = "EVTOPTB927"
		ai_chance = { factor = 20 }
	}
}

# 20270: Liege get a letter
letter_event = {
	id = 20270
	desc = "EVTDESC20270"
	border = GFX_event_letter_frame_religion
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20270"
		trigger = {
			OR = {
				FROM = { is_heretic = yes }
				religion_group = muslim
				trait = zealous
				trait = lunatic
				trait = possessed
			}
		}
		ai_chance = { factor = 99 }
		FROM = { imprison = yes }
		hidden_tooltip = {
			opinion = {
				who = FROM
				modifier = mad_heretic
				years = 10
			}
		}
		reverse_opinion = {
			modifier = opinion_hate
			who = FROM
			years = 10
		}
	}
	option = {
		name = "EVTOPTC20270"
		trigger = {
			NOR = {
				FROM = { is_heretic = yes }
				religion_group = muslim
			}
		}
		ai_chance = { factor = 99 }
		hidden_tooltip = {
			opinion = {
				who = FROM
				modifier = opinion_very_disappointed
				years = 10
			}
		}
		reverse_opinion = {
			modifier = opinion_very_disappointed
			who = FROM
			years = 10
		}
	}
	option = {
		name = "EVTOPTC20270"
		trigger = {
			NOR = {
				religion = FROM
				has_secret_religion = yes
			}
		}
		ai_chance = { factor = 0 }
		set_secret_religion = { target_type = public target = FROM }
		FROM = { letter_event = { id = 20272 } }
	}
	option = {
		name = "EVTOPTB20270"
		ai_chance = {
			factor = 1
			modifier = {
				factor = 0
				trait = zealous
			}
		}
		religion = FROM
		if = {
			limit = { higher_tier_than = BARON }
			hidden_tooltip = {
				religion_authority = {
					modifier = ruler_converted_to
				}
			}
		}
		hidden_tooltip = {
			any_courtier = {
				limit = {
					is_adult = no
					is_ruler = no
					dynasty = ROOT
				}
				religion = ROOT
			}
		}
		set_character_flag = converted_religion
		reverse_opinion = {
			modifier = opinion_happy
			who = FROM
			years = 10
		}
	}
}

# Bounce event for becoming heretic
character_event = {
	id = 20271
	desc = "EVTDESC927"
	picture = GFX_evt_heretic
	border = GFX_event_normal_frame_religion	
	
	is_triggered_only = yes
	
	immediate = {
		heresy_character_effect = yes
	}
	
	option = {
		name = OK
		liege = { letter_event = { id = 20270 days = 2 } }
	}
}

letter_event = {
	id = 20272 #vanilla 20271
	desc = EVTDESC20271
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA20271
		religion = FROM
		set_secret_religion = { target_type = true target = FROM }
		hidden_tooltip = {
			liege = { letter_event = { id = 20272 } }
		}
		ai_chance = { factor = 10 }
	}
	option = {
		name = EVTOPTB20271
		hidden_tooltip = {
			liege = { letter_event = { id = 20273 } }
		}
		ai_chance = { factor = 5 }
	}
}

letter_event = {
	id = 20273
	desc = EVTDESC20273
	border = GFX_event_letter_frame_religion
	
	is_triggered_only = yes
	
	option = {
		name = EVTOPTA20273
	}
}

##############################
# MUSLIM LORD SPIRITUAL (Mufti)
# JOB: action_charity
##############################

# 20040: The Mufti improves relations between the liege and a vassal
character_event = {
	id = 20040
	desc = "EVTDESC20040"
	title = "EVTNAME20040"
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_charity
		NOT = { has_character_modifier = in_seclusion }
		location = {
			any_province_lord = {
				religion = ROOT
				NOT = { is_liege_of = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 240

		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
	}

	option = {
		name = "EVTOPTA20040"
		hidden_tooltip = {
			location = {
				random_province_lord = {
					limit = {
						religion = ROOT
						NOT = { is_liege_of = ROOT }
					}
					character_event = { id = 20041 days = 7 }
				}
			}
		}
	}
}

# 20041: Inform the vassal
character_event = {
	id = 20041
	desc = "EVTDESC20041"
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20041"
		hidden_tooltip = {
			FROM = {
				liege = { character_event = { id = 20042 days = 7 } }
			}
		}
	}
}

# 20042: The liege is informed of the success
character_event = {
	id = 20042
	desc = "EVTDESC20042"
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	show_from_from = yes

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20042"
		FROM = {
			opinion = {
				modifier = opinion_improved_relations
				who = ROOT
				years = 2
			}
		}
	}
}

# 20043: The Mufti is trampled by a peasant mob (Gets away, Is wounded, Is killed)
character_event = {
	id = 20043
	desc = "EVTDESC20043"
	title = "EVTNAME20043"
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_charity
		NOT = { has_character_modifier = in_seclusion }
		location = {
			religion = ROOT
			owner = { same_realm = ROOT }
		}
	}

	mean_time_to_happen = {
		months = 480

		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 1.05
			learning = 11
		}
		modifier = {
			factor = 1.05
			learning = 12
		}
		modifier = {
			factor = 1.05
			learning = 13
		}
		modifier = {
			factor = 1.05
			learning = 14
		}
		modifier = {
			factor = 1.05
			learning = 15
		}
		modifier = {
			factor = 1.05
			learning = 16
		}
		modifier = {
			factor = 1.05
			learning = 17
		}
		modifier = {
			factor = 1.05
			learning = 18
		}
		modifier = {
			factor = 1.05
			learning = 19
		}
		modifier = {
			factor = 1.05
			learning = 20
		}
		modifier = {
			factor = 1.05
			learning = 21
		}
		modifier = {
			factor = 1.05
			learning = 22
		}
		modifier = {
			factor = 1.05
			learning = 23
		}
		modifier = {
			factor = 1.05
			learning = 24
		}
		modifier = {
			factor = 1.05
			learning = 25
		}
	}

	option = {
		name = "EVTOPTA20043"
		random_list = {
			50 = { character_event = { id = 20044 tooltip = "EVTTOOLTIP20020" } }
			40 = { character_event = { id = 20045 tooltip = "EVTTOOLTIP20021" } }
			10 = {
				hidden_tooltip = {
					liege = { character_event = { id = 20047 } }
				}
				death = {
					death_reason = death_rabble
				}
			}
		}
	}
}

# 20044: Mufti gets away
character_event = {
	id = 20044
	desc = "EVTDESC20044"
	picture = GFX_evt_peasants
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20044"
		prestige = -30
	}
}

# 20045: Mufti gets wounded
character_event = {
	id = 20045
	desc = "EVTDESC20045"
	picture = GFX_evt_bloody_man
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20045"
		add_trait = wounded
		hidden_tooltip = {
			liege = { character_event = { id = 20046 days = 7 } }
		}
	}
}

# 20046: Inform the Liege about wounding
character_event = {
	id = 20046
	desc = "EVTDESC20046"
	picture = GFX_evt_bloody_man
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20046"
		prestige = -10
	}
}

# 20047: Inform the Liege about death
character_event = {
	id = 20047
	desc = "EVTDESC20047"
	picture = GFX_evt_death
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20047"
		prestige = -15
	}
}

# 20048: The Mufti pockets money meant for the pooor
character_event = {
	id = 20048
	desc = "EVTDESC20048"
	title = "EVTNAME20048"
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_charity
		NOT = { has_character_modifier = in_seclusion }
		NOT = { trait = charitable }
	}

	mean_time_to_happen = {
		months = 480

		modifier = {
			factor = 2.0
			trait = just
		}
		modifier = {
			factor = 0.5
			trait = arbitrary
		}
		modifier = {
			factor = 0.5
			trait = greedy
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 0.95
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 1.1
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 0.95
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 1.05
			learning = 11
		}
		modifier = {
			factor = 1.05
			learning = 12
		}
		modifier = {
			factor = 1.05
			learning = 13
		}
		modifier = {
			factor = 1.05
			learning = 14
		}
		modifier = {
			factor = 1.05
			learning = 15
		}
		modifier = {
			factor = 1.05
			learning = 16
		}
		modifier = {
			factor = 1.05
			learning = 17
		}
		modifier = {
			factor = 1.05
			learning = 18
		}
		modifier = {
			factor = 1.05
			learning = 19
		}
		modifier = {
			factor = 1.05
			learning = 20
		}
		modifier = {
			factor = 1.05
			learning = 21
		}
		modifier = {
			factor = 1.05
			learning = 22
		}
		modifier = {
			factor = 1.05
			learning = 23
		}
		modifier = {
			factor = 1.05
			learning = 24
		}
		modifier = {
			factor = 1.05
			learning = 25
		}
	}

	option = {
		name = "EVTOPTA20048"
		ai_chance = { factor = 80 }
		wealth = 35
		hidden_tooltip = {
			liege = { character_event = { id = 20049 days = 2 } }
		}
	}
	option = {
		name = "EVTOPTB20048"
		ai_chance = { factor = 20 }
		piety = 30
	}
}

# 20049: Liege informed about Mufti's theft
character_event = {
	id = 20049
	desc = "EVTDESC20049"
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20049"
		wealth = 35
		if = {
			limit = {
				dynasty_head = { character = ROOT }
			}
			piety = -50
		}
	}
	option = {
		name = "EVTOPTB20049"
		FROM = { imprison = yes }
		piety = 20
	}
}

# 20050: Mullah gains piety for the liege
character_event = {
	id = 20050
	desc = "EVTDESC20050"
	title = "EVTNAME20050"
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_charity
		NOT = { has_character_modifier = in_seclusion }
	}

	mean_time_to_happen = {
		months = 240

		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { learning = 9 }
		}
		modifier = {
			factor = 0.95
			learning = 11
		}
		modifier = {
			factor = 0.95
			learning = 12
		}
		modifier = {
			factor = 0.95
			learning = 13
		}
		modifier = {
			factor = 0.95
			learning = 14
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.95
			learning = 16
		}
		modifier = {
			factor = 0.95
			learning = 17
		}
		modifier = {
			factor = 0.95
			learning = 18
		}
		modifier = {
			factor = 0.95
			learning = 19
		}
		modifier = {
			factor = 0.95
			learning = 20
		}
		modifier = {
			factor = 0.95
			learning = 21
		}
		modifier = {
			factor = 0.95
			learning = 22
		}
		modifier = {
			factor = 0.95
			learning = 23
		}
		modifier = {
			factor = 0.95
			learning = 24
		}
		modifier = {
			factor = 0.95
			learning = 25
		}
	}

	option = {
		name = "EVTOPTA20050"
		liege = { character_event = { id = 20051 days = 2 tooltip = "EVTTOOLTIP20051" } }
	}
}

# 20051: Liege gains piety
character_event = {
	id = 20051
	desc = "EVTDESC20051"
	picture = GFX_evt_bishop
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20051"
		piety = 15
	}
}

##############################
# COURT CHAPLAIN
# JOB: action_build_zeal
##############################

# 20218: The Court Priest has managed to raise an eager force of holy warriors
character_event = {
	id = 20218
	title = EVTNAME20218
	desc = EVTDESC20218
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war

	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		has_job_action = action_build_zeal
		NOT = { has_character_modifier = in_seclusion }
		liege = {
			is_adult = yes
			prisoner = no
			piety = 10
			NOT = { trait = incapable }
			OR = {
				NOT = { has_character_flag = tribal_build_zeal_troops }
				had_character_flag = { flag = tribal_build_zeal_troops days = 1825 }
			}
			OR = {
				war = no
				any_war = {
					OR = {
						using_cb = crusade
						using_cb = holy_war
						using_cb = religious_revolt
						using_cb = manifest_destiny_invasion
					}
				}
			}
		}
		location = {
			county = {
				is_occupied = no
			}
			ROOT = {
				liege = {
					is_capital = PREVPREV
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 120
		
		modifier = {
			factor = 3.0
			liege = {
				tier = count
			}
		}
		
		modifier = {
			factor = 1.25
			NOT = { learning = 2 }
		}
		modifier = {
			factor = 1.25
			NOT = { learning = 3 }
		}
		modifier = {
			factor = 1.25
			NOT = { learning = 4 }
		}
		modifier = {
			factor = 1.25
			NOT = { learning = 5 }
		}
		modifier = {
			factor = 0.75
			learning = 9
		}
		modifier = {
			factor = 0.75
			learning = 10
		}
		modifier = {
			factor = 0.75
			learning = 11
		}
		modifier = {
			factor = 0.75
			learning = 12
		}
		modifier = {
			factor = 0.75
			learning = 13
		}
	}
	
	option = {
		name = EVTOPTA20218
		
		piety = 25
		hidden_tooltip  = {
			liege = { character_event = { id = 20219 } }
		}
	}
}

# 20219: The liege is informed
character_event = {
	id = 20219
	desc = EVTDESC20219
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	immediate = {
		capital_scope = {
			ROOT = {
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					match_character = THIS
					match_mult = 0.075
					match_min = 100
					match_max = 3000
					attrition = 1.0
					earmark = tribal_build_zeal
					disband_on_peace = yes
					can_toggle_looting = no
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					match_character = THIS
					match_mult = 0.075
					match_min = 100
					match_max = 3000
					attrition = 1.0
					earmark = tribal_build_zeal
					disband_on_peace = yes
					can_toggle_looting = no
				}
				spawn_unit = {
					province = PREV
					home = PREV
					owner = THIS
					match_character = THIS
					match_mult = 0.075
					match_min = 100
					match_max = 3000
					attrition = 1.0
					earmark = tribal_build_zeal
					disband_on_peace = yes
					can_toggle_looting = no
				}
			}
		}
		
		clr_character_flag = tribal_build_zeal_troops
		set_character_flag = tribal_build_zeal_troops
		
		character_event = { id = 20220 days = 365 random = 90 }
	}
	
	option = {
		name = EVTOPTA20219
		opinion = {
			who = FROM
			modifier = opinion_grateful
			months = 60
		}
	}
}

# 20220: The men are displeased and disband
character_event = {
	id = 20220
	desc = EVTDESC20220
	picture = GFX_evt_battle
	border = GFX_event_normal_frame_war
	
	is_triggered_only = yes
	
	trigger = {
		has_earmarked_regiments = tribal_build_zeal
		NOT = {
			any_war = {
				OR = {
					AND = {
						any_attacker = { character = ROOT }
						defender = {
							OR = {
								NOT = { religion_group = ROOT }
								is_heresy_of = ROOT
								is_parent_religion = ROOT
							}
						}
					}
					AND = {
						any_defender = { character = ROOT }
						attacker = {
							OR = {
								NOT = { religion_group = ROOT }
								is_heresy_of = ROOT
								is_parent_religion = ROOT
							}
						}
					}
				}
			}
		}
	}
	
	option = {
		name = EVTOPTA20220
		piety = -25
		clr_character_flag = tribal_build_zeal_troops
		disband_event_forces = tribal_build_zeal
	}
}

