namespace = fervor

#########################
# Sinful Priest Scandal	#
# by Sean Hughes		#
# 1001-1002				#
#########################

# Trigger for checking if a character has the privliages + reponsibilities of a priest of their faith.
scripted_trigger is_capable_priest = {
	is_capable_adult_ai = yes
	is_imprisoned = no	
	NOT = {
		has_trait = excommunicated
	}
	faith.religious_head != this # Head of Faith gets checked separately.
	OR = {
		AND = { # All Faiths: Must be the Head of Faith, if one exists.
			exists = faith.religious_head
			this = faith.religious_head
		}
		AND = {# All Faiths: Must be a Theocracy.
			government_has_flag = government_is_theocracy
			is_landed = yes
		}
		trigger_if = { # Theocratic Faiths: Must be a Bishop
			limit = { faith = { has_doctrine_parameter = theocracy_temple_lease } }
			has_council_position = councillor_court_chaplain
		}
		trigger_if = { # Lay Clergy Faiths: Must personally hold a Temple.
			limit = { faith = { has_doctrine_parameter = theocracy_temple_ownership } }
			any_held_title = {
				title_tier = barony
				title_province ?= {
					has_holding_type = church_holding
				}
			}
		}
	}
}

# Used to find a sinful theocrat who could be the target of a scandal.
scripted_trigger valid_scandal_target = {
	faith = root
	num_sinful_traits >= 1
	is_capable_priest = yes
}

# Used to determine an appropriate scandal for the sinful theocrat to be caught doing.
scripted_trigger theocrat_has_sin = {
	scope:sinful_theocrat = {
		has_trait = $SIN$
		faith = { trait_is_sin = $SIN$ }
	}
}

fervor.1001 = {
	hidden = yes
	scope = faith

	trigger = {
		num_county_followers > 0
		OR = {	# Must have a valid sinful theocrat.
			AND = { # Sinful Head of Faith
				religious_head ?= {
					is_capable_adult_ai = yes
					num_sinful_traits >= 1
				}
			}
			AND = { # Sinful Theocratic Ruler
				any_theocratic_ruler = {
					valid_scandal_target = yes
				}
			}
			trigger_if = { # Theocracy: Sinful Bishop
				limit = {
					has_doctrine_parameter = theocracy_temple_lease
				}
				any_faith_ruler = {
					cp:councillor_court_chaplain ?= { valid_scandal_target = yes }
				}
			}
			trigger_if = { # Lay Clergy: Sinful Temple Holder
				limit = {
					has_doctrine_parameter = theocracy_temple_ownership
				}
				any_faith_ruler = {
					valid_scandal_target = yes
					any_held_title = {
						title_tier = barony
						title_province ?= { has_holding_type = church_holding }
					}
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 2
			num_county_followers >= 300
		}
		modifier = {
			add = 1.67
			num_county_followers >= 200
		}
		modifier = {
			add = 1.33
			num_county_followers >= 100
		}
		modifier = {
			add = 1.00
			num_county_followers >= 50
		}
		modifier = {
			add = 0.67
			num_county_followers >= 25
		}
		modifier = {
			add = 0.33
			num_county_followers >= 10
		}
		modifier = {
			add = 1.5
			religious_head ?= {
				num_sinful_traits >= 2
			}
		}
		modifier = {
			add = 1.5
			religious_head ?= {
				num_sinful_traits >= 3
			}
		}
	}

	immediate = {
		# Pick a suitable theocrat to be the target of our scandal.
		random_list = {
			20 = { # Religious Head
				trigger = {
					religious_head ?= {
						num_sinful_traits >= 1
						valid_scandal_target = yes
					}
				}

				compare_modifier = {
					value = religious_head.num_sinful_traits
					multiplier = 20
				}
				compare_modifier = {
					value = religious_head.num_virtuous_traits
					multiplier = -20
				}

				modifier = {
					add = 10
					religious_head = {
						has_strong_religious_conviction_trigger = no
					}
				}

				religious_head = {
					save_scope_as = sinful_theocrat
				}
			}
			60 = { # Theocratic Ruler
				trigger = {
					any_theocratic_ruler = {
						valid_scandal_target = yes
					}
				}
				random_theocratic_ruler = {
					limit = {
						valid_scandal_target = yes
						highest_held_title_tier >= 3
					}
					alternative_limit = {
						valid_scandal_target = yes
						highest_held_title_tier >= 2
					}
					alternative_limit = {
						valid_scandal_target = yes
						highest_held_title_tier >= 1
					}

					weight = {
						base = 1

						compare_modifier = {
							value = num_sinful_traits
							multiplier = 50
						}
						compare_modifier = {
							value = num_virtuous_traits
							multiplier = -50
						}
						modifier = {
							add = 25
							has_strong_religious_conviction_trigger = no
						}
						modifier = {
							add = 50
							is_powerful_vassal = yes
						}
						modifier = {
							add = 75
							top_liege = this
						}
						modifier = {
							add = 25
							any_liege_or_above = {
								is_ai = no
							}
						}
						modifier = {
							add = 25
							any_player = {
								culture = prev.culture
							}
						}
					}
					save_scope_as = sinful_theocrat
				}
			}
			60 = {
				trigger = {	# Theocracy: Sinful Bishop
					has_doctrine_parameter = theocracy_temple_lease
					any_faith_ruler = {
						cp:councillor_court_chaplain ?= { valid_scandal_target = yes }
					}
				}
				random_faith_ruler = {
					limit = {
						cp:councillor_court_chaplain ?= { valid_scandal_target = yes }
						highest_held_title_tier >= tier_duchy
					}
					alternative_limit = {
						cp:councillor_court_chaplain ?= { valid_scandal_target = yes }
						highest_held_title_tier >= tier_county
					}
					alternative_limit = {
						cp:councillor_court_chaplain ?= { valid_scandal_target = yes }
						highest_held_title_tier >= tier_barony
					}

					weight = {
						base = 1

						compare_modifier = {
							value = cp:councillor_court_chaplain.num_sinful_traits
							multiplier = 50
						}
						compare_modifier = {
							value = cp:councillor_court_chaplain.num_virtuous_traits
							multiplier = -50
						}
						modifier = {
							add = 25
							cp:councillor_court_chaplain = {
								has_strong_religious_conviction_trigger = no
							}
						}
						modifier = {
							add = 50
							cp:councillor_court_chaplain = {
								is_powerful_vassal = yes
							}
						}
						modifier = {
							add = 25
							any_liege_or_above = {
								is_ai = no
							}
						}
						modifier = {
							add = 25
							any_player = {
								culture = prev.culture
							}
						}
					}
					cp:councillor_court_chaplain = {
						save_scope_as = sinful_theocrat
					}
				}
			}
			60 = { # Lay Clergy: Sinful Temple Holder
				trigger = {
					has_doctrine_parameter = theocracy_temple_ownership
					any_faith_ruler = {
						valid_scandal_target = yes
						any_held_title = {
							title_tier = barony
							title_province ?= { has_holding_type = church_holding }
						}
					}
				}
				random_faith_ruler = {
					limit = {
						valid_scandal_target = yes
						any_held_title = {
							title_tier = barony
							title_province ?= {
								has_holding_type = church_holding
							}
						}
						highest_held_title_tier >= tier_duchy
					}
					alternative_limit = {
						valid_scandal_target = yes
						any_held_title = {
							title_tier = barony
							title_province ?= {
								has_holding_type = church_holding
							}
						}
						highest_held_title_tier >= tier_county
					}
					alternative_limit = {
						valid_scandal_target = yes
						any_held_title = {
							title_tier = barony
							title_province ?= {
								has_holding_type = church_holding
							}
						}
						highest_held_title_tier >= tier_barony
					}

					weight = {
						base = 1

						compare_modifier = {
							value = num_sinful_traits
							multiplier = 50
						}
						compare_modifier = {
							value = num_virtuous_traits
							multiplier = -50
						}
						modifier = {
							add = 25
							has_strong_religious_conviction_trigger = no
						}
						modifier = {
							add = 50
							is_powerful_vassal = yes
						}
						modifier = {
							add = 75
							top_liege = this
						}
						modifier = {
							add = 25
							any_liege_or_above = {
								is_ai = no
							}
						}
						modifier = {
							add = 25
							any_player = {
								culture = prev.culture
							}
						}
					}
					save_scope_as = sinful_theocrat
				}
			}
		}

		# Pick an appropriate scandal for our sinful theocrat, based on their personality.
		if = {
			limit = {
				exists = scope:sinful_theocrat
			}
			hidden_effect = { # Just collapse this - it's very long and not very interesting!
				if = {
					limit = { theocrat_has_sin = { SIN = lustful } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_lustful }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = chaste } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_chaste }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = gluttonous } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_gluttonous }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = temperate } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_temperate }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = greedy } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_greedy }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = generous } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_generous }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = lazy } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_lazy }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = diligent } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_diligent }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = wrathful } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_wrathful }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = calm } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_calm }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = patient } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_patient }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = impatient } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_impatient }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = arrogant } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_arrogant }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = humble } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_humble }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = deceitful } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_deceitful }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = honest } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_honest }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = craven } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_craven }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = brave } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_brave }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = shy } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_shy }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = gregarious } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_gregarious }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = ambitious } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_ambitious }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = content } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_content }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = arbitrary } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_arbitrary }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = just } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_just }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = cynical } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_cynical }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = zealous } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_zealous }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = paranoid } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_paranoid }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = trusting } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_trusting }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = compassionate } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_compassionate }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = callous } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_callous }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = sadistic } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_sadistic }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = stubborn } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_stubborn }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = fickle } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_fickle }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = vengeful } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_vengeful }
				}
				else_if = {
					limit = { theocrat_has_sin = { SIN = forgiving } }
						save_scope_value_as = { name = scandal_type value = flag:fervor_1001_forgiving }
				}
			}

			# Scandal target always loses 1 piety level, regardless of who they are.
			scope:sinful_theocrat = {
				add_piety_level = -1

				# Dummies may be called in localization depending on the nature of the sin.
				random_dummy_gender_servant_effect = yes
				random_dummy_gender_clergy_effect = yes
			}

			# If the Head of Faith is the sinful theocrat, it will be more impactful than for a random theocrat.
			if = {
				limit = {
					exists = religious_head
					exists = scope:sinful_theocrat
					religious_head = scope:sinful_theocrat
				}
				change_fervor = {
					value = -20
					desc = fervor_loss_scandalous_hof
				}

				# Due to the importance of the scandal all players will get an event.
				every_player = {
					limit = {
						faith = root
						NOR = { 
							this = scope:sinful_theocrat
							top_overlord ?= {
								primary_title = title:h_china
								government_has_flag = government_has_merit
								faith = { has_doctrine_parameter = theocracy_temple_ownership }
							}
						}
					}
					trigger_event = fervor.1002
				}
			}
			# Otherwise, how we handle the scandal will depend on each player's relationship to the chosen theocrat.
			else_if = {
				limit = {
					exists = scope:sinful_theocrat
				}

				change_fervor = {
					value = -10
					desc = fervor_loss_scandalous_priest
				}

				every_player = {
					limit = {
						faith = root
						NOR = { 
							this = scope:sinful_theocrat
							top_overlord ?= {
								primary_title = title:h_china
								government_has_flag = government_has_merit
								faith = { has_doctrine_parameter = theocracy_temple_ownership }
							}
						}
					}
					if = { # If the sinful theocrat is somebody that a player will personally care about, send them a full event.
						limit = {
							OR = {
								any_vassal = {
									this = scope:sinful_theocrat
								}
								liege ?= scope:sinful_theocrat

								AND = {
									exists = cp:councillor_court_chaplain
									cp:councillor_court_chaplain = scope:sinful_theocrat
								}
								any_spouse = {
									this = scope:sinful_theocrat
								}
								any_relation = {
									type = friend
									this = scope:sinful_theocrat
								}
								any_relation = {
									type = lover
									this = scope:sinful_theocrat
								}
								any_relation = {
									type = rival
									this = scope:sinful_theocrat
								}
								any_close_family_member = {
									this = scope:sinful_theocrat
								}
							}
						}
						trigger_event = fervor.1002
					}
					# Otherwise, players will only only get to know about this through the fervor log entry.
				}
			}
			
			set_variable = {
				name = recent_fervor_event
				value = yes
				days = 1460 # 4 year cooldown (plus a 1 year MTTH ~= occurs once per 5 years)
			}
		} # Close 'exists = scope:sinful_theocrat'
	}
}

#######################################
# Players notified of scandal (event) #
#######################################

fervor.1002 = {
	type = character_event
	title = fervor.1002.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {	faith.religious_head = scope:sinful_theocrat }
				desc = fervor.1002.desc.start_hof
			}
			desc = fervor.1002.desc.start
		}
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_lustful }
						desc = fervor.1002.desc.lustful
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_chaste }
						desc = fervor.1002.desc.chaste
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_gluttonous }
						desc = fervor.1002.desc.gluttonous
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_temperate }
						desc = fervor.1002.desc.temperate
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_greedy }
						desc = fervor.1002.desc.greedy
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_generous }
						desc = fervor.1002.desc.generous
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_lazy }
						desc = fervor.1002.desc.lazy
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_diligent }
						desc = fervor.1002.desc.diligent
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_wrathful }
						desc = fervor.1002.desc.wrathful
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_calm }
						desc = fervor.1002.desc.calm
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_patient }
						desc = fervor.1002.desc.patient
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_impatient }
						desc = fervor.1002.desc.impatient
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_arrogant }
						desc = fervor.1002.desc.arrogant
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_humble }
						desc = fervor.1002.desc.humble
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_deceitful }
						desc = fervor.1002.desc.deceitful
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_honest }
						desc = fervor.1002.desc.honest
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_craven }
						desc = fervor.1002.desc.craven
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_brave }
						desc = fervor.1002.desc.brave
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_shy }
						desc = fervor.1002.desc.shy
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_gregarious }
						desc = fervor.1002.desc.gregarious
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_ambitious }
						desc = fervor.1002.desc.ambitious
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_content }
						desc = fervor.1002.desc.content
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_arbitrary }
						desc = fervor.1002.desc.arbitrary
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_just }
						desc = fervor.1002.desc.just
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_cynical }
						desc = fervor.1002.desc.cynical
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_zealous }
						desc = fervor.1002.desc.zealous
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_paranoid }
						desc = fervor.1002.desc.paranoid
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_trusting }
						desc = fervor.1002.desc.trusting
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_compassionate }
						desc = fervor.1002.desc.compassionate
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_callous }
						desc = fervor.1002.desc.callous
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_sadistic }
						desc = fervor.1002.desc.sadistic
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_stubborn }
						desc = fervor.1002.desc.stubborn
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_fickle }
						desc = fervor.1002.desc.fickle
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_vengeful }
						desc = fervor.1002.desc.vengeful
				}
				triggered_desc = {
					trigger = { scope:scandal_type = flag:fervor_1001_forgiving }
						desc = fervor.1002.desc.forgiving
				}
			}
				desc = fervor.1002.desc.fallback
		}
		first_valid = {
			triggered_desc = {
				trigger = {	faith.religious_head = scope:sinful_theocrat }
				desc = fervor.1002.desc.end_hof
			}
			desc = fervor.1002.desc.end
		}
		}
	theme = faith
	override_background = {
		trigger = {
			scope:scandal_type = flag:fervor_1001_sadistic
		}
		reference = dungeon
	}
	override_background = {
		trigger = {
			scope:scandal_type = flag:fervor_1001_gluttonous
		}
		reference = feast
	}
	override_background = {
		trigger = {
			scope:scandal_type = flag:fervor_1001_deceitful
		}
		reference = study
	}


	left_portrait = {
		character = scope:sinful_theocrat
		animation = shame
		triggered_animation = {
			trigger = {
				OR = {
					has_trait = arrogant
					ai_vengefulness >= medium_positive_ai_value
					ai_rationality <= high_negative_ai_value
				}
				NOR = {
					scope:scandal_type = flag:fervor_1001_sadistic
					scope:scandal_type = flag:fervor_1001_deceitful
				}
			}
			animation = anger
		}
		triggered_animation = {
			trigger = {
				scope:scandal_type = flag:fervor_1001_sadistic
			}
			animation = schadenfreude
		}
		triggered_animation = {
			trigger = {
				scope:scandal_type = flag:fervor_1001_deceitful
			}
			animation = scheme
		}
	}

	immediate = {

		# Save any necessary scopes we may need for localization.
		if = {
			limit = {
				scope:sinful_theocrat = {
					is_ruler = yes
				}
			}
			primary_title = { save_scope_as = scoped_primary_title }
		}
		if = {
			limit = {
				scope:sinful_theocrat = {
					is_ruler = no
				}
			}
			liege.primary_title = { save_scope_as = scoped_primary_title }
		}

		# These effects already happened in the previous event, but we also need to notify players about the impact.
		if = {
			limit = {
				exists = faith.religious_head
				faith.religious_head = scope:sinful_theocrat
			}
			show_as_tooltip = {
				faith = {
					change_fervor = {
						value = -20
						desc = fervor_loss_scandalous_hof
					}
				}
			}
		}
		else = {
			show_as_tooltip = {
				faith = {
					change_fervor = {
						value = -10
						desc = fervor_loss_scandalous_priest
					}
				}
			}
		}
		show_as_tooltip = {
			scope:sinful_theocrat = {
				add_piety_level = -1
			}
		}
	}

	# Option 1: Condemn the theocrat for their sins!
	option = {
		name = fervor.1002.b

		add_piety = medium_piety_gain
		reverse_add_opinion = {
			modifier = angry_opinion
			target = scope:sinful_theocrat
			opinion = -30
		}

		if = {
			# Condemning someone who is known to hold grudges might not be the wisest course of action...
			limit = {
				scope:scandal_type = flag:fervor_1001_vengeful
			}
			scope:sinful_theocrat = {
				set_relation_rival = {
					target = root
					reason = rival_called_out_sin
				}
			}
		}

		stress_impact = {
			cynical = minor_stress_impact_gain
			humble = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			forgiving = minor_stress_impact_gain
		}
	}

	# Option 2: Defend the theocrat publically, taking a prestige/piety hit for a substantial relations boost.
	option = {
		name = fervor.1002.c
		add_prestige = medium_prestige_loss
		add_piety = medium_piety_loss
		reverse_add_opinion = {
			modifier = grateful_opinion
			target = scope:sinful_theocrat
			opinion = 30
		}

		stress_impact = {
			zealous = medium_stress_impact_gain
			craven = medium_stress_impact_gain
			shy = medium_stress_impact_gain
			vengeful = minor_stress_impact_gain
			callous = minor_stress_impact_gain
			sadistic = minor_stress_impact_gain
		}
	}

	# Option 3: Take no action
	option = {
		name = fervor.1002.d

		stress_impact = {
			base = minor_stress_impact_gain
			just = medium_stress_impact_gain
			brave = minor_stress_impact_gain
			impatient = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
		}
	}	
}

#########################
# Exalted Priest 		#
# by Flavio				#
# 2001-2002				#
#########################

#A theocrat has been very virtuous: Hidden ping on the Faith itself.

scripted_trigger suitable_theocrat_fervor_2001_trigger = {
	faith = root
	num_virtuous_traits >= 1
	is_capable_priest = yes
}

# Used to determine an appropriate exaltation for the virtuous theocrat to exemplify.
scripted_trigger theocrat_has_virtue = {
	scope:virtuous_theocrat = {
		has_trait = $VIRTUE$
		faith = { trait_is_virtue = $VIRTUE$ }
	}
}

fervor.2001 = {
	hidden = yes
	scope = faith

	trigger = {
		num_county_followers > 0 # Must be on the map.
		OR = {
			religious_head ?= {
					is_capable_adult_ai = yes
					num_virtuous_traits >= 1
				}
			any_theocratic_ruler = {
					faith = root
					suitable_theocrat_fervor_2001_trigger = yes
				}
			trigger_if = { # Theocracy: Sinful Bishop
				limit = {
					has_doctrine_parameter = theocracy_temple_lease
				}
				any_faith_ruler = {
					cp:councillor_court_chaplain ?= { suitable_theocrat_fervor_2001_trigger = yes }
				}
			}
			trigger_if = { # Lay Clergy: Sinful Temple Holder
				limit = {
					has_doctrine_parameter = theocracy_temple_ownership
				}
				any_faith_ruler = {
					suitable_theocrat_fervor_2001_trigger = yes
					any_held_title = {
						title_tier = barony
						title_province ?= { has_holding_type = church_holding }
					}
				}
			}
		}
	}

	weight_multiplier = {
		base = 1
		modifier = {
			add = 0.33
			num_county_followers < 300
		}
		modifier = {
			add = 0.67
			num_county_followers < 200
		}
		modifier = {
			add = 1.00
			num_county_followers < 100
		}
		modifier = {
			add = 1.33
			num_county_followers < 50
		}
		modifier = {
			add = 1.67
			num_county_followers < 25
		}
		modifier = {
			add = 2.00
			num_county_followers < 10
		}
		modifier = {
			add = 1.5
			religious_head ?= {
				num_virtuous_traits >= 2
				piety_level >= medium_piety_level
			}
		}
		modifier = {
			add = 1.5
			religious_head ?= {
				num_virtuous_traits >= 3
				piety_level >= high_piety_level
			}
		}
	}

	immediate = {
		random_list = { #Pick either Religious Head (if any), powerful theocrat (if not lay clergy), or powerful ruler (if lay clergy)
			10 = { # Virtuous Head of Faith
				trigger = {
					religious_head ?= {
						num_virtuous_traits >= 1
					}
				}
				modifier = {
					add = -15
					religious_head = {
						OR = {
							has_trait = excommunicated
							has_trait = cynical
						}
						}
				}
				modifier = {
					add = 15
					religious_head = {
						num_virtuous_traits >= 2
						piety_level >= medium_piety_level
						}
				}
				modifier = {
					add = 15
					religious_head = {
						num_virtuous_traits >= 3
						piety_level >= high_piety_level
						}
				}
				modifier = {
					add = 15
					religious_head = {
						has_strong_religious_conviction_trigger = yes
						}
				}
				modifier = {
					add = -15
					religious_head = {
						num_sinful_traits >= 1
						piety_level >= high_piety_level
						}
				}
				modifier = {
					add = -15
					religious_head = {
						num_sinful_traits >= 2
						piety_level >= high_piety_level
						}
				}
				religious_head = {
					save_scope_as = virtuous_theocrat
					add_piety = major_piety_gain
				}
			}
			40 = { # Virtuous Theocracy-Government Ruler
				trigger = {
					any_theocratic_ruler = {
						faith = root
						suitable_theocrat_fervor_2001_trigger = yes
						faith.religious_head != this
					}
				}
				random_theocratic_ruler = {
					limit = {
						highest_held_title_tier >= 2
						suitable_theocrat_fervor_2001_trigger = yes
						NOT = { has_trait = cynical }
					}
					alternative_limit = {
						suitable_theocrat_fervor_2001_trigger = yes
						NOT = { has_trait = cynical }
					}
					alternative_limit = {
						suitable_theocrat_fervor_2001_trigger = yes
					}
					weight = {
						base = 100

						modifier = {
							add = -20
							num_sinful_traits >= 1
						}
						modifier = {
							add = -20
							num_sinful_traits >= 2
						}
						modifier = {
							add = 15
							has_strong_religious_conviction_trigger = yes
						}
						modifier = {
							add = 10
							highest_held_title_tier >= 3
						}
						modifier = {
							add = 10
							highest_held_title_tier >= 4
						}
						modifier = {
							add = 20
							num_virtuous_traits >= 2
						}
						modifier = {
							add = 20
							num_virtuous_traits >= 3
						}
						modifier = {
							add = 20
							num_virtuous_traits >= 4
						}
						modifier = {
							add = 25
							piety_level >= high_piety_level
						}
						modifier = {
							add = 50
							is_powerful_vassal = yes
						}
						modifier = {
							add = 75
							top_liege = this
						}
						modifier = {
							add = 25
							any_liege_or_above = {
								is_ai = no
							}
						}
						modifier = {
							add = 25
							any_player = {
								culture = prev.culture
							}
						}
					}
					save_scope_as = virtuous_theocrat
					add_piety = major_piety_gain
				}
			}
			40 = { # Theocracy: Virtuous Bishop
				trigger = {	
					has_doctrine_parameter = theocracy_temple_lease
					any_faith_ruler = {
						exists = cp:councillor_court_chaplain
						cp:councillor_court_chaplain = {
							suitable_theocrat_fervor_2001_trigger = yes
						}
					}
				}
				random_faith_ruler = {
					limit = {
						exists = cp:councillor_court_chaplain
						cp:councillor_court_chaplain = {
							suitable_theocrat_fervor_2001_trigger = yes
						}
						highest_held_title_tier >= tier_duchy
					}
					alternative_limit = {
						exists = cp:councillor_court_chaplain
						cp:councillor_court_chaplain = {
							suitable_theocrat_fervor_2001_trigger = yes
						}
						highest_held_title_tier >= tier_county
					}
					alternative_limit = {
						exists = cp:councillor_court_chaplain
						cp:councillor_court_chaplain = {
							suitable_theocrat_fervor_2001_trigger = yes
						}
						highest_held_title_tier >= tier_barony
					}

					weight = {
						base = 1

						compare_modifier = {
							value = cp:councillor_court_chaplain.num_virtuous_traits
							multiplier = 50
						}
						compare_modifier = {
							value = cp:councillor_court_chaplain.num_sinful_traits
							multiplier = -50
						}
						
						modifier = {
							add = 25
							cp:councillor_court_chaplain = {
								has_strong_religious_conviction_trigger = no
							}
						}
						modifier = {
							add = 50
							cp:councillor_court_chaplain = {
								is_powerful_vassal = yes
							}
						}
						modifier = {
							add = 25
							any_liege_or_above = {
								is_ai = no
							}
						}
						modifier = {
							add = 25
							any_player = {
								culture = prev.culture
							}
						}
					}

					cp:councillor_court_chaplain = {
						save_scope_as = virtuous_theocrat
					}
				}
			}
			40 = { # Lay Clergy: Any Virtuous Ruler with a Temple Holding
				trigger = {
					has_doctrine_parameter = theocracy_temple_ownership
					any_faith_ruler = {
						suitable_theocrat_fervor_2001_trigger = yes
						any_held_title = {
							title_tier = barony
							title_province ?= {
								has_holding_type = church_holding
							}
						}
					}
				}
				random_faith_ruler = {
					limit = {
						suitable_theocrat_fervor_2001_trigger = yes
						highest_held_title_tier >= 2
						NOT = { has_trait = cynical }
					}
					alternative_limit = {
						suitable_theocrat_fervor_2001_trigger = yes
						NOT = { has_trait = cynical }
					}
					alternative_limit = {
						suitable_theocrat_fervor_2001_trigger = yes
					}
					weight = {
						base = 100

						modifier = {
							add = -20
							num_sinful_traits >= 1
						}
						modifier = {
							add = -20
							num_sinful_traits >= 2
						}
						modifier = {
							add = 15
							has_strong_religious_conviction_trigger = yes
						}
						modifier = {
							add = 10
							highest_held_title_tier >= tier_duchy
						}
						modifier = {
							add = 10
							highest_held_title_tier >= tier_kingdom
						}
						modifier = {
							add = 20
							num_virtuous_traits >= 2
						}
						modifier = {
							add = 20
							num_virtuous_traits >= 3
						}
						modifier = {
							add = 20
							num_virtuous_traits >= 4
						}
						modifier = {
							add = 25
							piety_level >= high_piety_level
						}
						modifier = {
							add = 50
							is_powerful_vassal = yes
						}
						modifier = {
							add = 75
							top_liege = this
						}
						modifier = {
							add = 25
							any_liege_or_above = {
								is_ai = no
							}
						}
						modifier = {
							add = 25
							any_player = {
								culture = prev.culture
							}
						}
					}
					save_scope_as = virtuous_theocrat
				}
			}
		}
		if = {
			limit = {
				exists = scope:virtuous_theocrat
			}
			# Pick an appropriate exaltation for our virtuous theocrat, based on their personality.
			hidden_effect = { # Just collapse this - it's very long and not very interesting!
				if = {
					limit = { theocrat_has_virtue = { VIRTUE = lustful } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_lustful }
				}
				else_if = {
					limit = {
						OR = {
							theocrat_has_virtue = { VIRTUE = chaste }
							theocrat_has_virtue = { VIRTUE = celibate }
						}
					}
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_chaste }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = gluttonous } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_gluttonous }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = temperate } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_temperate }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = greedy } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_greedy }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = generous } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_generous }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = lazy } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_lazy }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = diligent } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_diligent }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = wrathful } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_wrathful }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = calm } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_calm }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = patient } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_patient }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = impatient } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_impatient }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = arrogant } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_arrogant }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = humble } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_humble }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = deceitful } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_deceitful }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = honest } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_honest }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = craven } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_craven }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = brave } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_brave }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = shy } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_shy }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = gregarious } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_gregarious }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = ambitious } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_ambitious }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = content } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_content }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = arbitrary } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_arbitrary }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = just } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_just }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = cynical } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_cynical }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = zealous } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_zealous }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = paranoid } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_paranoid }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = trusting } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_trusting }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = compassionate } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_compassionate }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = callous } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_callous }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = sadistic } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_sadistic }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = stubborn } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_stubborn }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = fickle } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_fickle }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = vengeful } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_vengeful }
				}
				else_if = {
					limit = { theocrat_has_virtue = { VIRTUE = forgiving } }
						save_scope_value_as = { name = exaltation_type value = flag:fervor_2001_forgiving }
				}
			}

			change_fervor = {
				value = 10
				desc = fervor_gain_virtous_priest
			}

			every_player = {
				limit = {
					faith = root
				}
				if = {
					limit = {
						this != scope:virtuous_theocrat
						OR = {
							any_vassal = {
								this = scope:virtuous_theocrat
							}
							liege ?= scope:virtuous_theocrat

							AND = {
								exists = cp:councillor_court_chaplain
								cp:councillor_court_chaplain = scope:virtuous_theocrat
							}
							any_spouse = {
								this = scope:virtuous_theocrat
							}
							any_relation = {
								type = friend
								this = scope:virtuous_theocrat
							}
							any_relation = {
								type = lover
								this = scope:virtuous_theocrat
							}
							any_relation = {
								type = rival
								this = scope:virtuous_theocrat
							}
							any_close_family_member = {
								this = scope:virtuous_theocrat
							}
						}
					}
					trigger_event = fervor.2002
				}
				#Otherwise only noted in the fervor log
			}
		}
		set_variable = {
			name = recent_fervor_event
			value = yes
			days = 1460 # 4 year cooldown (plus a 1 year MTTH ~= occurs once per 5 years)
		}
	}
}

#Players notified of event.
fervor.2002 = {
	type = character_event
	title = fervor.2002.t
	desc = {
		first_valid = {
			random_valid = {
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_lustful
					}
						desc = fervor.2002.desc.lustful
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_chaste
					}
						desc = fervor.2002.desc.chaste
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_gluttonous
					}
						desc = fervor.2002.desc.gluttonous
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_temperate
					}
						desc = fervor.2002.desc.temperate
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_greedy
					}
						desc = fervor.2002.desc.greedy
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_generous
						scope:virtuous_theocrat != faith.religious_head
					}
						desc = fervor.2002.desc.generous
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_generous
						scope:virtuous_theocrat = faith.religious_head
					}
						desc = fervor.2002.desc.generous.pope
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_lazy
					}
						desc = fervor.2002.desc.lazy
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_diligent
					}
						desc = fervor.2002.desc.diligent
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat != faith.religious_head
						OR = {
							scope:exaltation_type = flag:fervor_2001_wrathful
							scope:exaltation_type = flag:fervor_2001_vengeful
						}
					}
						desc = fervor.2002.desc.wrathful
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat = faith.religious_head
						OR = {
							scope:exaltation_type = flag:fervor_2001_wrathful
							scope:exaltation_type = flag:fervor_2001_vengeful
						}
					}
						desc = fervor.2002.desc.wrathful.pope
				}
				triggered_desc = {
					trigger = {
						OR = {
							scope:exaltation_type = flag:fervor_2001_calm
							scope:exaltation_type = flag:fervor_2001_patient
						}
					}
						desc = fervor.2002.desc.calm
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat != faith.religious_head
						scope:exaltation_type = flag:fervor_2001_impatient
					}
						desc = fervor.2002.desc.impatient
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat = faith.religious_head
						scope:exaltation_type = flag:fervor_2001_impatient
					}
						desc = fervor.2002.desc.impatient.pope
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_arrogant
					}
						desc = fervor.2002.desc.arrogant
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_humble
					}
						desc = fervor.2002.desc.humble
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_deceitful
					}
						desc = fervor.2002.desc.deceitful
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat != faith.religious_head
						scope:exaltation_type = flag:fervor_2001_honest
					}
						desc = fervor.2002.desc.honest
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat = faith.religious_head
						scope:exaltation_type = flag:fervor_2001_honest
					}
						desc = fervor.2002.desc.honest.pope
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_craven
					}
						desc = fervor.2002.desc.craven
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_brave
					}
						desc = fervor.2002.desc.brave
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_shy
					}
						desc = fervor.2002.desc.shy
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat != faith.religious_head
						scope:exaltation_type = flag:fervor_2001_gregarious
					}
						desc = fervor.2002.desc.gregarious
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat = faith.religious_head
						scope:exaltation_type = flag:fervor_2001_gregarious
					}
						desc = fervor.2002.desc.gregarious.pope
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_ambitious
					}
						desc = fervor.2002.desc.ambitious
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_content
					}
						desc = fervor.2002.desc.content
				}
				triggered_desc = {
					trigger = {
						OR = {
							scope:exaltation_type = flag:fervor_2001_arbitrary
							scope:exaltation_type = flag:fervor_2001_fickle
						}
					}
						desc = fervor.2002.desc.arbitrary
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_just
					}
						desc = fervor.2002.desc.just
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_cynical
					}
						desc = fervor.2002.desc.cynical
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat != faith.religious_head
						OR = {
							scope:exaltation_type = flag:fervor_2001_zealous
							scope:exaltation_type = flag:fervor_2001_stubborn
						}
					}
						desc = fervor.2002.desc.zealous
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat = faith.religious_head
						OR = {
							scope:exaltation_type = flag:fervor_2001_zealous
							scope:exaltation_type = flag:fervor_2001_stubborn
						}
					}
						desc = fervor.2002.desc.zealous.pope
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_paranoid
					}
						desc = fervor.2002.desc.paranoid
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_trusting
					}
						desc = fervor.2002.desc.trusting
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_compassionate
					}
						desc = fervor.2002.desc.compassionate
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_callous
					}
						desc = fervor.2002.desc.callous
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat != faith.religious_head
						scope:exaltation_type = flag:fervor_2001_sadistic
					}
						desc = fervor.2002.desc.sadistic
				}
				triggered_desc = {
					trigger = {
						scope:virtuous_theocrat = faith.religious_head
						scope:exaltation_type = flag:fervor_2001_sadistic
					}
						desc = fervor.2002.desc.sadistic.pope
				}
				triggered_desc = {
					trigger = {
						scope:exaltation_type = flag:fervor_2001_forgiving
					}
						desc = fervor.2002.desc.forgiving
				}
			}
				desc = fervor.2002.desc.fallback
		}
		}
	theme = faith
	override_background = {
		trigger = {
			scope:exaltation_type = flag:fervor_2001_sadistic
		}
		reference = dungeon
	}
	override_background = {
		trigger = {
			scope:exaltation_type = flag:fervor_2001_gluttonous
		}
		reference = feast
	}
	override_background = {
		trigger = {
			scope:exaltation_type = flag:fervor_2001_deceitful
		}
		reference = study
	}

	left_portrait = {
		character = scope:virtuous_theocrat
		triggered_animation = {
			trigger = {
				scope:exaltation_type = flag:fervor_1001_sadistic
			}
			animation = schadenfreude
		}
		triggered_animation = {
			trigger = {
				scope:exaltation_type = flag:fervor_1001_deceitful
			}
			animation = scheme
		}
	}

	immediate = {
		if = {
			limit = {
				scope:virtuous_theocrat = {
					is_ruler = yes
				}
			}
			primary_title = { save_scope_as = scoped_primary_title }
		}
		if = {
			limit = {
				scope:virtuous_theocrat = {
					is_ruler = no
				}
			}
			liege.primary_title = { save_scope_as = scoped_primary_title }
		}
		show_as_tooltip = {
			faith = {
				change_fervor = {
					value = 10
					desc = fervor_gain_virtous_priest
				}
			}
		}
	}
	option = { #
		name = {
			trigger = { has_strong_religious_conviction_trigger = yes }
			text = fervor.2001.a.a
		}
		name = {
			trigger = {
				has_strong_religious_conviction_trigger = no
				NOT = { has_trait = cynical }
			}
			text = fervor.2001.a.b
		}
		name = {
			trigger = {
				has_strong_religious_conviction_trigger = no
				has_trait = cynical
			}
			text = fervor.2001.a.c
		}
	}
}
