﻿namespace = expwitch

#####################
# Confronting a Witch (fired from character interaction)
# by David Gaider
#####################

scripted_trigger challenge_has_reaction_reason_trigger = {
	OR = {
		AND = {
			scope:accused_witch = {
				NOT = { has_trait = witch }
			}
			any_known_secret = {
				secret_owner = scope:accused_witch
				secret_type = secret_witch
				can_be_exposed_by = scope:accuser
			}
		}
		AND = {
			scope:accused_witch = { is_imprisoned = no }
			OR = {
				has_imprisonment_reason = scope:accused_witch
				is_ai = no
			}
		}
	}
}

scripted_effect challenge_renounce_witchcraft_effect = {
	if = {
		limit = { has_trait = witch }
		remove_trait = witch
	}
	else = {
		random_secret = {
			type = secret_witch
			remove_secret = yes
		}
	}
	add_character_flag = block_convert_to_witchcraft
	hidden_effect = {
		remove_opinion = {
			modifier = challenged_witchcraft_opinion
			target = scope:accuser
		}
	}
	if = {
		limit = {
			any_known_secret = {
				secret_type = secret_witch
				NOT = { is_known_by = scope:accuser }
				secret_owner = { target_is_liege_or_above = scope:accuser }
			}
		}
		every_known_secret = {
			limit = {
				secret_type = secret_witch
				NOT = { is_known_by = scope:accuser }
				secret_owner = { target_is_liege_or_above = scope:accuser }
			}
			reveal_to = scope:accuser
		}
	}
}

scripted_effect challenge_recruit_witchcraft_success_effect = {
	add_secret = { type = secret_witch }
	random_secret = {
		type = secret_witch
		reveal_to = scope:accused_witch
	}
	progress_towards_friend_effect = {
		REASON = converted_me_to_witchcraft
		CHARACTER = scope:accused_witch
		OPINION = 20
	}
	random_list = {
		40 = {
			modifier = {
				factor = 2
				has_trait = zealous
			}
			modifier = {
				factor = 0
				NOT = { has_trait = zealous }
				number_of_personality_traits > 3
			}
			trigger = {
				OR = {
					has_trait = zealous
					NOR = {
						has_trait = zealous
						has_trait = cynical
					}
				}
			}
			if = {
				limit = { has_trait = zealous }
				remove_trait = zealous
			}
			else = {
				add_trait = cynical
			}
		}
		20 = {
			modifier = {
				factor = 2
				has_trait = content
			}
			modifier = {
				factor = 0
				NOT = { has_trait = content }
				number_of_personality_traits > 3
			}
			trigger = {
				OR = {
					has_trait = content
					NOR = {
						has_trait = zealous
						has_trait = content
					}
				}
			}
			if = {
				limit = { has_trait = content }
				remove_trait = content
			}
			else = {
				add_trait = ambitious
			}
		}
		10 = {
			modifier = {
				factor = 2
				has_trait = zealous
			}
			modifier = {
				factor = 0.5
				has_trait = cynical
			}
			trigger = {
				NOT = { has_trait = lunatic }
			}
			add_trait = lunatic_1
		}
		10 = {
			modifier = {
				factor = 2
				has_trait = zealous
			}
			modifier = {
				factor = 0.5
				has_trait = cynical
			}
			trigger = {
				NOT = { has_trait = possessed }
			}
			add_trait = possessed_1
		}
		40 = {}
	}
}

scripted_effect botched_witch_trial_effect = {
	scope:accused_witch = {
		add_character_flag = had_witch_trial
	}
	scope:court_chaplain = {
		add_character_flag = cannot_witch_trial
		add_piety_level = -1
		hidden_effect = {
			remove_opinion = {
				target = scope:accuser
				modifier = approves_piety_witch_opinion
			}
			random_secret = {
				type = secret_witch
				remove_secret = yes
			}
			reverse_add_opinion = {
				target = scope:actor
				modifier = witch_betrayed_me_opinion
			}
		}
		add_trait = witch
	}
	rightfully_imprison_character_effect = {
		TARGET = scope:court_chaplain
		IMPRISONER = scope:accuser
	}
	scope:accuser = {
		hidden_effect = {
			if = {
				limit = { has_relation_best_friend = scope:court_chaplain }
				remove_relation_best_friend = scope:court_chaplain
			}
			if = {
				limit = { has_relation_friend = scope:court_chaplain }
				remove_relation_friend = scope:court_chaplain
			}
		}
		if = {
			limit = {
				NOR = {
					has_relation_rival = scope:court_chaplain
					has_relation_nemesis = scope:court_chaplain
				}
			}
			set_relation_rival = {
				target = scope:court_chaplain
				reason = court_chaplain_betrayal
			}
		}
		if = {
			limit = {
				capital_county.faith = scope:accuser.faith
			}
			capital_county = {
				change_county_control = -20
				add_county_modifier = {
					modifier = upset_botched_witch_trial_modifier
					days = 1095 #3 years
				}
			}
		}
		if = {
			limit = {
				NOT = { has_global_variable = recent_witch_fervor_loss }
			}
			faith = {
				change_fervor = {
					value = -10
					desc = fervor_loss_witch_priest
				}
			}
			set_global_variable = {
				name = recent_witch_fervor_loss
				value = yes
				days = 1825 #5 years
			}
		}
	}
}


# First the accused receives an event prompting them to pick an initial reaction
expwitch.1000 = {
	type = character_event
	title = expwitch.1000.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = no
						is_imprisoned = yes
					}
				}
				desc = expwitch.1000.opening_prison_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = yes
						is_imprisoned = yes
					}
				}
				desc = expwitch.1000.opening_prison
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = no
					}
				}
				desc = expwitch.1000.opening_court_child
			}
			desc = expwitch.1000.opening_court
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = no
						rite = { rite_has_parameter = witchcraft_shunned }
					}
				}
				desc = expwitch.1000.mid_shunned_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = no
						rite = { rite_has_parameter = witchcraft_illegal }
					}
				}
				desc = expwitch.1000.mid_illegal_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						rite = { rite_has_parameter = witchcraft_shunned }
					}
				}
				desc = expwitch.1000.mid_shunned
			}
			desc = expwitch.1000.mid_illegal
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = no
					}
				}
				desc = expwitch.1000.end_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						rite = { rite_has_parameter = witchcraft_shunned }
					}
				}
				desc = expwitch.1000.end_shunned
			}
			desc = expwitch.1000.end_illegal
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		animation = disapproval
	}
	right_portrait = {
		character = scope:accused_witch
		animation = worry
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}

	trigger = {
		OR = {
			scope:accuser = {
				any_known_secret = {
					secret_owner = scope:accused_witch
					secret_type = secret_witch
				}
			}
			scope:accused_witch = { has_trait = witch }
		}
	}
	
	immediate = { challenge_cleanup_flags = yes } #to ensure no flags from previous events accidentally were left behind
	
	option = {
		name = expwitch.1000.a #Be defiant
		ai_chance = {
			base = 20
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 0.5
			}
			modifier = {
				add = 10
				has_trait = vengeful
			}
			modifier = {
				add = 10
				NOT = { faith = scope:accuser.faith }
			}
			opinion_modifier = {
				who = scope:accused_witch
				opinion_target = scope:accuser
				min = 0
				max = 20
				multiplier = -0.5
			}
			modifier = {
				add = -10
				has_dread_level_towards = {
					target = scope:accuser
					level = 1
				}
			}
			modifier = {
				add = -20
				has_dread_level_towards = {
					target = scope:accuser
					level > 1
				}
			}
			modifier = {
				add = 100
				OR = {
					has_relation_rival = scope:accuser
					has_relation_nemesis = scope:accuser
				}
			}
		}
		add_prestige = minor_prestige_gain
		reverse_add_opinion = {
			target = scope:accuser
			modifier = defied_witchcraft_challenge_opinion
		}
		stress_and_fulfillment_impact = {
			craven = medium_stress_impact_gain
			wrathful = minor_stress_impact_loss
		}
		add_character_flag = challenge_withcraft_defiant
		custom_tooltip = expwitch.1000.a.tt
		hidden_effect = {
			scope:accuser = { trigger_event = expwitch.1006 }
		}
	}
	option = {
		name = expwitch.1000.b #Wait and see what happens
		ai_chance = {
			base = 60
			ai_value_modifier = {
				ai_compassion = 1
			}
			modifier = {
				add = 20
				has_trait = calm
			}
			modifier = {
				add = 20
				has_trait = patient
			}
			modifier = {
				add = 10
				has_trait = trusting
			}
			modifier = {
				factor = 0.5
				OR = {
					has_trait = lunatic
					has_trait = possessed
				}
			}
			opinion_modifier = {
				who = scope:accused_witch
				opinion_target = scope:accuser
				min = 0
				max = 20
				multiplier = 0.5
			}
		}
		custom_tooltip = expwitch.1000.b.tt
		hidden_effect = {
			scope:accuser = { trigger_event = expwitch.1006 }
		}
	}
	option = {
		name = expwitch.1000.c #Confess everything and plead for mercy
		trigger = {
			scope:accuser = {
				rite = { rite_has_parameter = witchcraft_illegal }
			}
		}
		ai_chance = {
			base = 20
			modifier = {
				add = 20
				is_adult = no
				age >= 12
			}
			modifier = {
				add = 40
				is_adult = no
				age < 12
			}
			modifier = {
				add = 20
				is_imprisoned = yes
			}
			modifier = {
				add = 20
				has_dread_level_towards = {
					target = scope:accuser
					level >= 1
				}
			}
			ai_value_modifier = {
				ai_boldness = -1
			}
			modifier = {
				add = -10
				has_trait = vengeful
			}
			modifier = {
				add = -20
				has_trait = stubborn
			}
			modifier = {
				add = 20
				has_trait = honest
			}
			modifier = {
				factor = 0.5
				has_trait = deceitful
			}
			modifier = {
				factor = 0.5
				has_trait = paranoid
			}
			modifier = {
				factor = 0.5
				OR = {
					diplomacy >= decent_skill_rating
					intrigue >= decent_skill_rating
					learning >= decent_skill_rating
				}
				NOR = {
					diplomacy <= low_skill_rating
					intrigue <= low_skill_rating
					learning <= low_skill_rating
				}
			}
			modifier = {
				factor = 0.5
				OR = {
					diplomacy >= very_high_skill_rating
					intrigue >= very_high_skill_rating
					learning >= very_high_skill_rating
				}
				NOR = {
					diplomacy <= low_skill_rating
					intrigue <= low_skill_rating
					learning <= low_skill_rating
				}
			}
			modifier = {
				factor = 0.5
				is_ruler = yes
				is_powerful_vassal = no
				is_imprisoned = no
			}
			modifier = {
				factor = 0.1
				is_powerful_vassal = yes
				is_imprisoned = no
			}
			modifier = {
				factor = 0
				OR = {
					has_relation_rival = scope:accuser
					has_relation_nemesis = scope:accuser
				}
			}
		}
		custom_tooltip = expwitch.1000.c.tt
		add_prestige = medium_prestige_loss
		add_piety = medium_piety_loss
		reverse_add_opinion = {
			target = scope:accuser
			modifier = confessed_witchcraft_challenge_opinion
		}
		stress_and_fulfillment_impact = {
			honest = major_stress_impact_loss
			humble = minor_stress_impact_loss
			wrathful = minor_stress_impact_gain
			ambitious = medium_stress_impact_gain
			deceitful = major_stress_impact_gain
		}
		show_as_tooltip = {
			challenge_renounce_witchcraft_effect = yes
		}
		hidden_effect = {
			scope:accuser = { trigger_event = expwitch.1001 }
		}
	}
	
	on_trigger_fail = {
		scope:accused_witch = {
			remove_opinion = {
				modifier = challenged_witchcraft_opinion
				target = scope:accuser
			}
		}
	}
}

# Accused witch confesses and renounces witchcraft
expwitch.1001 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = confront_witch_end_success }
				desc = expwitch.1001.t.success
			}
			desc = expwitch.1001.t
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = { is_adult = no }
					has_character_flag = confront_witch_end_success
					has_character_flag = confront_diplomacy_second
				}
				desc = expwitch.1001.success_diplomacy_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = { is_adult = no }
					has_character_flag = confront_witch_end_success
					has_character_flag = confront_learning_second
				}
				desc = expwitch.1001.success_learning_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = { is_adult = no }
					has_character_flag = confront_witch_end_success
					has_character_flag = confront_threaten_second
				}
				desc = expwitch.1001.success_threaten_child
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_witch_end_success
					has_character_flag = confront_diplomacy_second
				}
				desc = expwitch.1001.success_diplomacy
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_witch_end_success
					has_character_flag = confront_learning_second
				}
				desc = expwitch.1001.success_learning
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_witch_end_success
					has_character_flag = confront_threaten_second
				}
				desc = expwitch.1001.success_threaten
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_imprisoned = yes
						is_adult = no
					}
				}
				desc = expwitch.1001.imprisoned_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_imprisoned = no
						is_adult = no
					}
				}
				desc = expwitch.1001.court_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_imprisoned = yes
					}
				}
				desc = expwitch.1001.imprisoned
			}
			desc = expwitch.1001.court
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = { is_adult = no }
				}
				desc = expwitch.1001.end_child
			}
			desc = expwitch.1001.end
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		triggered_animation = {
			trigger = {
				has_character_flag = confront_witch_end_success
			}
			animation = personality_zealous
		}
		animation = disapproval
	}
	right_portrait = {
		character = scope:accused_witch
		animation = beg
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}
	
	option = {
		name = {
			trigger = {
				scope:accused_witch = { is_imprisoned = no }
			}
			text = expwitch.1001.a #That's all I wanted to hear.
		}
		name = {
			trigger = {
				scope:accused_witch = { is_imprisoned = yes }
			}
			text = expwitch.1001.b #That's all I wanted to hear. They are free to go.
		}
		add_prestige = minor_prestige_gain
		add_piety = medium_piety_gain
		stress_and_fulfillment_impact = {
			compassionate = minor_stress_impact_loss
			forgiving = medium_stress_impact_loss
			zealous = medium_stress_impact_loss
			cynical = minor_stress_impact_gain
			wrathful = minor_stress_impact_gain
		}
		scope:accused_witch = {
			if = {
				limit = { scope:accuser = { has_character_flag = confront_witch_end_success } }
				show_as_tooltip = { challenge_renounce_witchcraft_effect = yes }
			}
			else = { challenge_renounce_witchcraft_effect = yes }
			show_as_tooltip = {
				if = {
					limit = { is_imprisoned_by = scope:accuser }
					release_from_prison = yes
				}
				consume_all_criminal_reasons_effect = {
					LIEGE = scope:accuser
					CRIMINAL = scope:accused_witch
				}
				challenge_confession_effect = yes
			}
			hidden_effect = { trigger_event = expwitch.1004 }
		}
		ai_chance = {
			base = 70
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.2
			}
			opinion_modifier = {
				who = scope:accuser
				opinion_target = scope:accused_witch
				min = -20
				max = 20
				multiplier = -0.5
			}
			modifier = {
				add = -20
				has_trait = cynical
			}
			modifier = {
				add = 20
				has_trait = forgiving
			}
			modifier = {
				add = 20
				has_trait = zealous
			}
			modifier = {
				add = 20
				scope:accused_witch = { is_adult = no }
			}
			modifier = {
				factor = 0.2
				OR = {
					has_opinion_modifier = { target = scope:accused_witch modifier = murdered_close_family_crime }
					has_opinion_modifier = { target = scope:accused_witch modifier = attempted_murder_close_family_crime }
					has_opinion_modifier = { target = scope:accused_witch modifier = attempted_murder_me_crime }
					has_opinion_modifier = { target = scope:accused_witch modifier = abducted_close_family_crime }
					has_opinion_modifier = { target = scope:accused_witch modifier = executed_close_family_crime }
					has_opinion_modifier = { target = scope:accused_witch modifier = vassal_lost_faction_revolt_war }
					has_banish_reason = scope:accused_witch
					has_revoke_title_reason = scope:accused_witch
				}
			}
			modifier = {
				factor = 0.1
				OR = {
					has_relation_rival = scope:accused_witch
					has_relation_nemesis = scope:accused_witch
				}
			}
			modifier = {
				add = -20
				has_character_flag = confront_witch_end_success
			}
		}	
	}
	option = {
		trigger = {
			OR = {
				has_opinion_modifier = { target = scope:accused_witch modifier = murdered_close_family_crime }
				has_opinion_modifier = { target = scope:accused_witch modifier = attempted_murder_close_family_crime }
				has_opinion_modifier = { target = scope:accused_witch modifier = attempted_murder_me_crime }
				has_opinion_modifier = { target = scope:accused_witch modifier = abducted_close_family_crime }
				has_opinion_modifier = { target = scope:accused_witch modifier = executed_close_family_crime }
				has_opinion_modifier = { target = scope:accused_witch modifier = vassal_lost_faction_revolt_war }
				has_banish_reason = scope:accused_witch
				has_revoke_title_reason = scope:accused_witch
				scope:accuser = { is_ai = no }
			}
		}
		name = expwitch.1001.c #I accept their confession, but they have other crimes to answer for.
		stress_and_fulfillment_impact = {
			zealous = medium_stress_impact_loss
			cynical = minor_stress_impact_gain
		}
		add_piety = medium_piety_gain
		if = {
			limit = { scope:accused_witch = { is_imprisoned = yes } }
			custom_tooltip = expwitch.remain_in_prison.tt
		}
		else = {
			scope:accused_witch = { add_character_flag = liege_imprisoned_me }
			show_as_tooltip = {
				rightfully_imprison_character_effect = {
					TARGET = scope:accused_witch
					IMPRISONER = scope:accuser
				}
			}
		}
		scope:accused_witch = {
			if = {
				limit = { scope:accuser = { has_character_flag = confront_witch_end_success } }
				show_as_tooltip = { challenge_renounce_witchcraft_effect = yes }
			}
			else = { challenge_renounce_witchcraft_effect = yes }
			if = {
				limit = { scope:accused_witch = { is_imprisoned = no } }
				show_as_tooltip = { challenge_confession_betrayed_effect = yes }
			}
			else = {
				show_as_tooltip = { challenge_confession_effect = yes }
			}
			hidden_effect = { trigger_event = expwitch.1003 }
		}
		ai_chance = {
			base = 70
			ai_value_modifier = {
				ai_compassion = 0.5
			}
			opinion_modifier = {
				who = scope:accuser
				opinion_target = scope:accused_witch
				min = -20
				max = 20
				multiplier = -0.5
			}
			modifier = {
				add = -10
				has_trait = cynical
			}
			modifier = {
				factor = 0.5
				opinion = {
					target = scope:accused_witch
					value > 40
				}
			}
			modifier = {
				factor = 0.1
				OR = {
					has_relation_rival = scope:accused_witch
					has_relation_nemesis = scope:accused_witch
				}
			}
			modifier = {
				add = -20
				has_character_flag = confront_witch_end_success
			}
			modifier = {
				add = -20
				scope:accused_witch = { is_imprisoned = no }
			}
			modifier = {
				factor = 0.25
				is_close_or_extended_family_of = scope:accused_witch
			}
		}
	}
	option = {
		name = {
			trigger = {
				scope:accused_witch = {
					NOT = { has_trait = witch }
				}
			}
			text = expwitch.1001.d #They have only confirmed the awful truth.
		}
		name = {
			trigger = {
				scope:accused_witch = {
					has_trait = witch
				}
			}
			text = expwitch.1001.e #This changes nothing.
		}
		hidden_effect = {
			remove_opinion = {
				target = scope:accused_witch
				modifier = confessed_witchcraft_challenge_opinion
			}
		}
		add_dread = minor_dread_gain
		add_piety = medium_piety_gain
		stress_and_fulfillment_impact = {
			compassionate = minor_stress_impact_gain
			forgiving = medium_stress_impact_gain
			wrathful = minor_stress_impact_loss
		}
		add_opinion = {
			target = scope:accused_witch
			modifier = confessed_witchcraft_crime
		}
		if = {
			limit = { scope:accused_witch = { is_imprisoned = yes } }
			custom_tooltip = expwitch.remain_in_prison.tt
		}
		else = {
			scope:accused_witch = { add_character_flag = liege_imprisoned_me }
			show_as_tooltip = {
				rightfully_imprison_character_effect = {
					TARGET = scope:accused_witch
					IMPRISONER = scope:accuser
				}
			}
		}
		scope:accused_witch = {
			if = {
				limit = { scope:accuser = { has_character_flag = confront_witch_end_success } }
				show_as_tooltip = { challenge_renounce_witchcraft_effect = yes }
			}
			else = { challenge_renounce_witchcraft_effect = yes }
			show_as_tooltip = { challenge_confession_betrayed_effect = yes }
			hidden_effect = { trigger_event = expwitch.1002 }
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_compassion = -0.5
				ai_honor = -0.2
			}
			modifier = {
				add = 20
				has_trait = zealous
			}
			modifier = {
				add = -20
				has_trait = forgiving
			}
			modifier = {
				add = 20
				opinion = {
					target = scope:accused_witch
					value < -40
				}
			}
			modifier = {
				factor = 0.5
				opinion = {
					target = scope:accused_witch
					value > 40
				}
			}
			modifier = {
				factor = 0.5
				NOT = { is_close_family_of = scope:accused_witch }
				is_extended_family_of = scope:accused_witch
			}
			modifier = {
				factor = 0.5
				scope:accused_witch = {
					OR = {
						is_powerful_vassal = yes
						is_councillor_of = scope:accuser
						has_relation_friend = scope:accuser
						has_relation_best_friend = scope:accuser
						is_knight_of = scope:accuser
						has_relation_lover = scope:accuser
						has_relation_soulmate = scope:accuser
					}
				}
			}
			modifier = {
				factor = 0.2
				scope:accused_witch = { is_adult = no }
			}
			modifier = {
				factor = 0
				is_close_family_of = scope:accused_witch
			}
		}	
	}
}

# Accuser rejects the accused's confession
expwitch.1002 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_witch_end_success }
				}
				desc = expwitch.1002.t.success
			}
			desc = expwitch.1002.t
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accuser = {
						has_character_flag = confront_witch_end_success
						has_character_flag = confront_diplomacy_second
					}
				}
				desc = expwitch.1002.success_diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:accuser = {
						has_character_flag = confront_witch_end_success
						has_character_flag = confront_learning_second
					}
				}
				desc = expwitch.1002.success_learning
			}
			triggered_desc = {
				trigger = {
					scope:accuser = {
						has_character_flag = confront_witch_end_success
						has_character_flag = confront_threaten_second
					}
				}
				desc = expwitch.1002.success_threaten
			}
			desc = expwitch.1002.desc
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = { is_imprisoned = yes }
				}
				desc = expwitch.1002.end_prison
			}
			desc = expwitch.1002.end_court
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		animation = disapproval
	}
	right_portrait = {
		character = scope:accused_witch
		animation = beg
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}
	override_sound = {
		trigger = { has_character_flag = liege_imprisoned_me }
		reference = "event:/SFX/Events/Themes/sfx_event_theme_type_prison"
	}
	
	option = {
		name = expwitch.1002.a #Betrayal!
		if = {
			limit = { is_imprisoned = no }
			rightfully_imprison_character_effect = {
				TARGET = scope:accused_witch
				IMPRISONER = scope:accuser
			}
		}
		if = {
			limit = { scope:accuser = { has_character_flag = confront_witch_end_success } }
			challenge_renounce_witchcraft_effect = yes
		}
		challenge_confession_betrayed_effect = yes
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				has_trait = vengeful
			}
			modifier = {
				factor = 0.5
				has_trait = wrathful
			}
			modifier = {
				factor = 0.5
				has_trait = deceitful
			}
		}
	}
	option = {
		name = expwitch.1002.b #I secretly pray for forgiveness from witch god
		trigger = {
			OR = {
				has_trait = vengeful
				has_trait = wrathful
				has_trait = deceitful
			}
		}
		show_as_unavailable = {
			NOR = {
				has_trait = vengeful
				has_trait = wrathful
				has_trait = deceitful
			}
		}
		if = {
			limit = { is_imprisoned = no }
			rightfully_imprison_character_effect = {
				TARGET = scope:accused_witch
				IMPRISONER = scope:accuser
			}
		}
		if = {
			limit = { scope:accuser = { has_character_flag = confront_witch_end_success } }
			if = {
				limit = { has_trait = witch }
				remove_trait = witch
				add_secret = { type = secret_witch }
			}
			else = {
				#removing and then re-adding the effect to remove accuser as secret knower
				hidden_effect = {
					random_secret = {
						type = secret_witch
						every_secret_knower = {
							limit = {
								NOT = { this = scope:accuser }
							}
							add_to_list = witch_secret_knowers
						}
						remove_secret = yes
					}
					add_secret = { type = secret_witch }
					if = {
						limit = {
							any_in_list = {
								list = witch_secret_knowers
								count > 0
							}
						}
						every_in_list = {
							list = witch_secret_knowers
							save_temporary_scope_as = current_knower
							scope:accused_witch = {
								random_secret = {
									type = secret_witch
									reveal_to = scope:current_knower
								}
							}
						}
					}
				}
			}
			hidden_effect = {
				remove_opinion = {
					modifier = challenged_witchcraft_opinion
					target = scope:accuser
				}
			}
			if = {
				limit = {
					any_known_secret = {
						secret_type = secret_witch
						NOT = { is_known_by = scope:accuser }
						secret_owner = { target_is_liege_or_above = scope:accuser }
					}
				}
				every_known_secret = {
					limit = {
						secret_type = secret_witch
						NOT = { is_known_by = scope:accuser }
						secret_owner = { target_is_liege_or_above = scope:accuser }
					}
					reveal_to = scope:accuser
				}
			}
		}
		else = {
			remove_character_flag = block_convert_to_witchcraft
			add_secret = { type = secret_witch }
		}
		challenge_confession_betrayed_effect = yes
		ai_chance = {
			base = 50
			modifier = {
				factor = 2
				has_character_flag = challenge_withcraft_defiant
			}
			modifier = {
				factor = 2
				is_imprisoned = no
			}
			modifier = {
				factor = 0.1
				is_adult = no
			}
		}
	}
	
	after = { challenge_cleanup_flags = yes }
}

# Accuser accepts confession, but imprisons them anyway (or leaves them there)
expwitch.1003 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					NOT = { has_character_flag = liege_imprisoned_me }
					scope:accuser = { has_character_flag = confront_witch_end_success }
				}
				desc = expwitch.1003.t.success
			}
			triggered_desc = {
				trigger = {
					has_character_flag = liege_imprisoned_me
					scope:accuser = { has_character_flag = confront_witch_end_success }
				}
				desc = expwitch.1003.t.success_imprison
			}
			desc = expwitch.1003.t
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accuser = {
						has_character_flag = confront_witch_end_success
						has_character_flag = confront_diplomacy_second
					}
				}
				desc = expwitch.1003.success_diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:accuser = {
						has_character_flag = confront_witch_end_success
						has_character_flag = confront_learning_second
					}
				}
				desc = expwitch.1003.success_learning
			}
			triggered_desc = {
				trigger = {
					scope:accuser = {
						has_character_flag = confront_witch_end_success
						has_character_flag = confront_threaten_second
					}
				}
				desc = expwitch.1003.success_threaten
			}
			desc = expwitch.1003.desc
		}
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = liege_imprisoned_me }
				desc = expwitch.1003.end_imprison
			}
			desc = expwitch.1003.end
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		animation = personality_compassionate
	}
	right_portrait = {
		character = scope:accused_witch
		animation = beg
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = {
				OR = {
					is_imprisoned = yes
					has_character_flag = liege_imprisoned_me
				}
			}
		}
		reference = dungeon
	}
	override_sound = {
		trigger = { has_character_flag = liege_imprisoned_me }
		reference = "event:/SFX/Events/Themes/sfx_event_theme_type_prison"
	}
	
	option = {
		name = {
			trigger = { has_character_flag = liege_imprisoned_me }
			text = expwitch.1003.a
		}
		name = {
			trigger = { NOT = { has_character_flag = liege_imprisoned_me } }
			text = expwitch.1003.b
		}
		if = {
			limit = { has_character_flag = liege_imprisoned_me }
			rightfully_imprison_character_effect = {
				TARGET = scope:accused_witch
				IMPRISONER = scope:accuser
			}
		}
		else = {
			custom_tooltip = expwitch.I_remain_in_prison.tt
		}
		if = {
			limit = { scope:accuser = { has_character_flag = confront_witch_end_success } }
			challenge_renounce_witchcraft_effect = yes
		}
		if = {
			limit = { has_character_flag = liege_imprisoned_me }
			challenge_confession_betrayed_effect = yes
		}
		else = { challenge_confession_effect = yes }
		ai_chance = {
			base = 50
			modifier = {
				factor = 0.5
				has_trait = vengeful
			}
			modifier = {
				factor = 0.5
				has_trait = wrathful
			}
			modifier = {
				factor = 0.5
				has_trait = deceitful
			}
		}
	}	
	option = {
		name = expwitch.1002.b #I secretly pray for forgiveness from witch god
		trigger = {
			has_character_flag = liege_imprisoned_me
			OR = {
				has_trait = vengeful
				has_trait = wrathful
				has_trait = deceitful
			}
		}
		show_as_unavailable = {
			NOR = {
				has_trait = vengeful
				has_trait = wrathful
				has_trait = deceitful
			}
		}
		rightfully_imprison_character_effect = {
			TARGET = scope:accused_witch
			IMPRISONER = scope:accuser
		}
		if = {
			limit = { scope:accuser = { has_character_flag = confront_witch_end_success } }
			if = {
				limit = { has_trait = witch }
				remove_trait = witch
				add_secret = { type = secret_witch }
			}
			else = {
				#removing and then re-adding the effect to remove all current secret knowers
				hidden_effect = {
					random_secret = {
						type = secret_witch
						every_secret_knower = {
							limit = {
								NOT = { this = scope:accuser }
							}
							add_to_list = witch_secret_knowers
						}
						remove_secret = yes
					}
					add_secret = { type = secret_witch }
					if = {
						limit = {
							any_in_list = {
								list = witch_secret_knowers
								count > 0
							}
						}
						every_in_list = {
							list = witch_secret_knowers
							save_temporary_scope_as = current_knower
							scope:accused_witch = {
								random_secret = {
									type = secret_witch
									reveal_to = scope:current_knower
								}
							}
						}
					}
				}
			}
			hidden_effect = {
				remove_opinion = {
					modifier = challenged_witchcraft_opinion
					target = scope:accuser
				}
			}
			if = {
				limit = {
					any_known_secret = {
						secret_type = secret_witch
						NOT = { is_known_by = scope:accuser }
						secret_owner = { target_is_liege_or_above = scope:accuser }
					}
				}
				every_known_secret = {
					limit = {
						secret_type = secret_witch
						NOT = { is_known_by = scope:accuser }
						secret_owner = { target_is_liege_or_above = scope:accuser }
					}
					reveal_to = scope:accuser
				}
			}
		}
		else = {
			remove_character_flag = block_convert_to_witchcraft
			add_secret = { type = secret_witch }
		}
		challenge_confession_betrayed_effect = yes
		ai_chance = {
			base = 100
			modifier = {
				factor = 2
				has_character_flag = challenge_withcraft_defiant
			}
			modifier = {
				factor = 0.1
				is_adult = no
			}
		}
	}
	
	after = { challenge_cleanup_flags = yes }
}

# Accuser accepts confession fully
expwitch.1004 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_witch_end_success }
				}
				desc = expwitch.1004.t.success
			}
			desc = expwitch.1004.t
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accuser = {
						has_character_flag = confront_witch_end_success
						has_character_flag = confront_diplomacy_second
					}
				}
				desc = expwitch.1004.success_diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:accuser = {
						has_character_flag = confront_witch_end_success
						has_character_flag = confront_learning_second
					}
				}
				desc = expwitch.1004.success_learning
			}
			triggered_desc = {
				trigger = {
					scope:accuser = {
						has_character_flag = confront_witch_end_success
						has_character_flag = confront_threaten_second
					}
				}
				desc = expwitch.1004.success_threaten
			}
			desc = expwitch.1004.desc
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		animation = personality_forgiving
	}
	right_portrait = {
		character = scope:accused_witch
		animation = beg
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}
	
	option = {
		name = expwitch.1003.a
		if = {
			limit = { is_imprisoned_by = scope:accuser }
			release_from_prison = yes
		}
		consume_all_criminal_reasons_effect = {
			LIEGE = scope:accuser
			CRIMINAL = scope:accused_witch
		}
		if = {
			limit = { scope:accuser = { has_character_flag = confront_witch_end_success } }
			challenge_renounce_witchcraft_effect = yes
		}
		challenge_confession_effect = yes
		challenge_cleanup_flags = yes
	}
}

# Summoned vassal refuses to attend the liege at court
expwitch.1005 = {
	type = character_event
	title = expwitch.1005.t
	desc = {
		desc = expwitch.1005.desc
		first_valid = {
			triggered_desc = {
				trigger = {
					any_known_secret = {
						secret_owner = scope:recipient
						secret_type = secret_witch
						can_be_exposed_by = root
					}
				}
				desc = expwitch.1005.secret
			}
			desc = expwitch.1005.witch
		}
	}
	theme = realm

	left_portrait = {
		character = scope:recipient
		animation = dismissal
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}

	immediate = {
		play_music_cue = mx_cue_murder
		save_scope_as = accuser
		scope:recipient = { save_scope_as = accused_witch }
	}

	after = {
		remove_variable = currently_blackmailing
		challenge_cleanup_flags = yes
	}

	option = {
		name = expwitch.1005.a
		trigger = {
			any_known_secret = {
				secret_owner = scope:recipient
				secret_type = secret_witch
				can_be_exposed_by = root
			}
			scope:recipient = {
				NOT = { has_trait = witch }
			}
		}
		random_known_secret = {
			limit = {
				secret_owner = scope:recipient
				secret_type = secret_witch
				can_be_exposed_by = root
			}
			expose_secret = root
		}
		stress_and_fulfillment_impact = {
			honest = medium_stress_impact_loss
			zealous = medium_stress_impact_loss
			cynical = minor_stress_impact_gain
			just = minor_stress_impact_loss
			shy = minor_stress_impact_gain
		}
	}
	option = {
		name = expwitch.1005.b
		trigger = {
			any_known_secret = {
				secret_owner = scope:recipient
				secret_type = secret_witch
				can_be_exposed_by = root
			}
			scope:recipient = {
				NOT = { has_trait = witch }
			}
		}
		random_known_secret = {
			limit = {
				secret_owner = scope:recipient
				secret_type = secret_witch
				can_be_exposed_by = root
			}
			disable_exposure_by = root
		}
		ai_chance = {
			factor = 0
		}
	}
	option = {
		name = expwitch.1005.c
		trigger = {
			OR = {
				NOT = {
					any_known_secret = {
						secret_owner = scope:recipient
						secret_type = secret_witch
						can_be_exposed_by = root
					}
				}
				scope:recipient = { has_trait = witch }
			}
		}
	}
}

# Accused does not immediately confess - Initial Attempt
expwitch.1006 = {
	type = character_event
	title = expwitch.1006.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = no
						is_imprisoned = yes
						has_character_flag = challenge_withcraft_defiant
					}
				}
				desc = expwitch.1006.prison_child_defiant
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = no
						is_imprisoned = no
						has_character_flag = challenge_withcraft_defiant
					}
				}
				desc = expwitch.1006.court_child_defiant
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = no
						is_imprisoned = yes
					}
				}
				desc = expwitch.1006.prison_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_adult = no
						is_imprisoned = no
					}
				}
				desc = expwitch.1006.court_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_imprisoned = yes
						has_character_flag = challenge_withcraft_defiant
					}
				}
				desc = expwitch.1006.prison_defiant
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_imprisoned = no
						has_character_flag = challenge_withcraft_defiant
					}
				}
				desc = expwitch.1006.court_defiant
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						is_imprisoned = yes
					}
				}
				desc = expwitch.1006.prison
			}
			desc = expwitch.1006.court
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = { is_adult = no }
				}
				desc = expwitch.1006.ending_child
			}
			desc = expwitch.1006.ending
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		animation = disapproval
	}
	right_portrait = {
		character = scope:accused_witch
		triggered_animation = {
			trigger = {
				scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
			}
			animation = personality_callous
		}
		triggered_animation = {
			trigger = {
				scope:accused_witch = { has_trait_submissive_trigger = yes }
			}
			animation = personality_coward
		}
		triggered_animation = {
			trigger = {
				scope:accused_witch = { has_trait_dominant_trigger = yes }
			}
			animation = personality_bold
		}
		triggered_animation = {
			trigger = {
				scope:accused_witch = { has_trait_levelheaded_trigger = yes }
			}
			animation = idle
		}
		animation = worry
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}	

	option = {
		trigger = {
			scope:accused_witch = { is_adult = yes }
		}
		name = expwitch.1006.a #Diplomacy challenge vs. adult
		skill = diplomacy
		add_character_flag = confront_diplomacy_initial
		stress_and_fulfillment_impact = {
			shy = medium_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		duel = {
			skill = diplomacy
			target = scope:accused_witch
			40 = {
				modifier = {
					factor = 0.5
					scope:accused_witch = { has_trait = lunatic }
				}
				modifier = {
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
					factor = 0.75
				}
				ai_value_modifier = {
					who = scope:accused_witch
					ai_honor = 0.25
					ai_compassion = 0.25
					max = 20
					min = -20
				}
				modifier = {
					add = 10
					has_trait = diplomat
				}
				modifier = {
					add = 10
					has_trait = patient
				}
				modifier = {
					add = -10
					has_trait = impatient
				}
				modifier = {
					add = -10
					has_trait = shy
				}
				modifier = {
					add = -10
					NOT = { faith = scope:accused_witch.faith }
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 5
				}
				custom_tooltip = expwitch.1006.confession.progress.tt
				add_character_flag = confront_witch_progress
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = 5
				}
				custom_tooltip = expwitch.1006.confession.no_progress.tt
				add_character_flag = confront_witch_no_progress
			}
			20 = {
				modifier = {
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
					factor = 1.5
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = diplomat }
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = impatient }
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = irritable }
				}
				modifier = {
					add = -10
					scope:accused_witch = { has_trait = patient }
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 5
				}
				custom_tooltip = expwitch.1006.confession.failure.tt
				add_character_flag = confront_witch_fail
			}
		}
		ai_chance = {
			base = 30
			modifier = {
				add = {
					value = scope:accuser.diplomacy
					subtract = scope:accused_witch.diplomacy
					multiply = 5
					min = -30
				}
				always = yes
			}
			modifier = {
				factor = 0.5
				has_trait = cynical
			}
		}
	}
	option = {
		trigger = {
			scope:accused_witch = { is_adult = yes }
		}
		name = expwitch.1006.b #Learning challenge vs. adult
		skill = learning
		add_character_flag = confront_learning_initial
		stress_and_fulfillment_impact = {
			cynical = medium_stress_impact_gain
			lazy = minor_stress_impact_gain
		}
		duel = {
			skill = learning
			target = scope:accused_witch
			40 = {
				modifier = {
					factor = 0.5
					scope:accused_witch = { has_trait = lunatic }
				}
				modifier = {
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
					factor = 0.75
				}
				modifier = {
					factor = 1.5
					OR = {
						has_trait = erudite
						has_trait = theologian
					}
				}
				modifier = {
					factor = 1.5
					has_trait = zealous
				}
				modifier = {
					factor = 0.5
					has_trait = cynical
				}
				modifier = {
					add = 10
					has_trait = just
				}
				modifier = {
					add = -10
					has_trait = lazy
				}
				modifier = {
					add = -10
					NOT = { faith = scope:accused_witch.faith }
				}
				modifier = {
					add = 20
					scope:accused_witch = { has_trait = contrite }
				}
				ai_value_modifier = {
					who = scope:accused_witch
					ai_rationality = 0.25
					ai_zeal = -0.5
					max = 20
					min = -20
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 5
				}
				custom_tooltip = expwitch.1006.confession.progress.tt
				add_character_flag = confront_witch_progress
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = 5
				}
				custom_tooltip = expwitch.1006.confession.no_progress.tt
				add_character_flag = confront_witch_no_progress
			}
			20 = {
				modifier = {
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
					factor = 1.5
				}
				modifier = {
					factor = 2
					scope:accused_witch = {
						OR = {
							has_trait = erudite
							has_trait = theologian
						}
					}
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = arbitrary }
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 5
				}
				custom_tooltip = expwitch.1006.confession.failure.tt
				add_character_flag = confront_witch_fail
			}
		}
		ai_chance = {
			base = 30
			modifier = {
				factor = 2
				has_trait = zealous
			}
			modifier = {
				add = {
					value = scope:accuser.learning
					subtract = scope:accused_witch.learning
					multiply = 5
					min = -30
				}
				always = yes
			}
			modifier = {
				factor = 0.5
				has_trait = cynical
			}
		}
	}
	option = {
		trigger = {
			scope:accused_witch = { is_adult = yes }
		}
		name = expwitch.1006.c #Intrigue challenge vs. adult
		skill = intrigue
		add_character_flag = confront_intrigue_initial
		stress_and_fulfillment_impact = {
			honest = medium_stress_impact_gain
			compassionate = minor_stress_impact_gain
		}
		duel = {
			skill = intrigue
			target = scope:accused_witch
			40 = {
				modifier = {
					factor = 0.5
					scope:accused_witch = { has_trait = lunatic }
				}
				modifier = {
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
					factor = 0.75
				}
				ai_value_modifier = {
					who = scope:accused_witch
					ai_vengefulness = -0.25
					ai_honor = 0.25
					max = 20
					min = -20
				}
				modifier = {
					add = -10
					has_trait = honest
				}
				modifier = {
					add = 10
					has_trait = schemer
				}
				modifier = {
					add = 10
					has_trait = calm
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 5
				}
				custom_tooltip = expwitch.1006.confession.progress.tt
				add_character_flag = confront_witch_progress
			}
			40 = {
				compare_modifier = {
					value = scope:duel_value
					multiplier = -1
					min = 5
				}
				custom_tooltip = expwitch.1006.confession.no_progress.tt
				add_character_flag = confront_witch_no_progress
			}
			20 = {
				modifier = {
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
					factor = 1.5
				}
				modifier = {
					add = 20
					scope:accused_witch = { has_trait = schemer }
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = deceitful }
				}
				modifier = {
					add = -10
					scope:accused_witch = { has_trait = trusting }
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 5
				}
				custom_tooltip = expwitch.1006.confession.failure.tt
				add_character_flag = confront_witch_fail
			}
		}
		ai_chance = {
			base = 30
			modifier = {
				add = {
					value = scope:accuser.intrigue
					subtract = scope:accused_witch.intrigue
					multiply = 5
					min = -30
				}
				always = yes
			}
			modifier = {
				factor = 0.5
				has_trait = honest
			}
		}
	}
	option = {
		trigger = {
			scope:accused_witch = { is_adult = no }
		}
		name = expwitch.1006.d #Diplomacy vs. child
		skill = diplomacy
		add_character_flag = confront_diplomacy_second
		stress_and_fulfillment_impact = {
			shy = medium_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		random_list = {
			50 = {
				modifier = {
					add = {
						value = diplomacy
						multiply = 2
					}
				}
				modifier = {
					add = 10
					has_trait = diplomat
					NOR = {
						has_relation_friend = scope:accuser
						has_relation_lover = scope:accuser
						is_close_family_of = scope:accuser
					}
				}
				modifier = {
					add = 20
					OR = {
						has_relation_friend = scope:accuser
						has_relation_lover = scope:accuser
						is_close_family_of = scope:accuser
					}
				}
				opinion_modifier = {
					who = scope:accused_witch
					opinion_target = scope:accuser
					multiplier = 0.5
				}
				ai_value_modifier = {
					who = scope:accused_witch
					ai_honor = 0.50
				}
				ai_value_modifier = {
					who = scope:accuser
					ai_honor = 0.20
				}
				modifier = {
					add = -20
					scope:accused_witch = {
						OR = {
							has_trait = lunatic
							has_trait = possessed
						}
					}
				}
				modifier = {
					add = -10
					scope:accused_witch = { has_trait = zealous }
				}
				modifier = {
					factor = 0.5
					OR = {
						has_relation_rival = scope:accused_witch
						has_relation_nemesis = scope:accused_witch
					}
				}
				add_character_flag = confront_witch_end_success
				custom_tooltip = expwitch.1007.succeed_confront.tt
			}
			50 = {
				modifier = {
					add = 20
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				modifier = {
					add = {
						value = scope:accused_witch.intrigue
						multiply = 1
					}
				}
				modifier = {
					factor = 0.5
					scope:accused_witch = { has_trait = craven }
				}
				add_character_flag = confront_witch_end_fail
				custom_tooltip = expwitch.1007.failure_confront.tt
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = diplomacy
					multiply = 5
				}
			}
			modifier = {
				add = 20
				OR = {
					has_trait = diplomat
					has_relation_friend = scope:accuser
					has_relation_lover = scope:accuser
					is_close_family_of = scope:accuser
				}
			}
			modifier = {
				add = -20
				has_trait = shy
			}
			ai_value_modifier = {
				who = scope:accused_witch
				ai_honor = 0.20
			}
			opinion_modifier = {
				who = scope:accused_witch
				opinion_target = scope:accuser
				multiplier = 0.20
			}
			ai_value_modifier = {
				who = scope:accuser
				ai_honor = 0.50
			}
			modifier = {
				add = -20
				scope:accused_witch = {
					OR = {
						has_trait = lunatic
						has_trait = possessed
					}
				}
			}
			modifier = {
				add = -10
				scope:accused_witch = { has_trait = zealous }
			}
		}	
	}
	option = {
		trigger = {
			scope:accused_witch = { is_adult = no }
		}
		name = expwitch.1006.e #Patiently explain to child
		skill = learning
		add_character_flag = confront_learning_second
		stress_and_fulfillment_impact = {
			zealous = medium_stress_impact_loss
			lazy = minor_stress_impact_gain
		}
		random_list = {
			50 = {
				modifier = {
					add = {
						value = learning
						multiply = 2
					}
				}
				opinion_modifier = {
					who = scope:accused_witch
					opinion_target = scope:accuser
					multiplier = 0.2
				}
				ai_value_modifier = {
					who = scope:accused_witch
					ai_zeal = -0.50
				}
				ai_value_modifier = {
					who = scope:accuser
					ai_zeal = 0.20
				}
				modifier = {
					add = 10
					has_trait = erudite
				}
				modifier = {
					add = 20
					has_trait = theologian
				}
				modifier = {
					add = 20
					scope:accused_witch = {
						NOT = { has_trait = witch }
					}
				}
				modifier = {
					factor = 0.5
					OR = {
						has_relation_rival = scope:accused_witch
						has_relation_nemesis = scope:accused_witch
					}
				}
				add_character_flag = confront_witch_end_success
				custom_tooltip = expwitch.1007.succeed_confront.tt
			}
			50 = {
				modifier = {
					add = 20
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = stubborn }
				}
				modifier = {
					add = 20
					scope:accused_witch = {
						OR = {
							has_trait = lunatic
							has_trait = possessed
						}
					}
				}
				modifier = {
					add = 20
					scope:accused_witch = {
						OR = {
							has_trait = deviant
							has_trait = cannibal
							has_trait = sodomite
							has_trait = incestuous
							has_trait = excommunicated
						}
					}
				}
				modifier = {
					add = {
						value = scope:accused_witch.intrigue
						multiply = 1
					}
				}
				modifier = {
					factor = 0.5
					scope:accused_witch = { has_trait = craven }
				}
				add_character_flag = confront_witch_end_fail
				custom_tooltip = expwitch.1007.failure_confront.tt
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = learning
					multiply = 5
				}
			}
			ai_value_modifier = {
				who = scope:accused_witch
				ai_zeal = -0.20
			}
			ai_value_modifier = {
				who = scope:accuser
				ai_zeal = 0.50
			}
			modifier = {
				add = 10
				has_trait = erudite
			}
			modifier = {
				add = 20
				has_trait = theologian
			}
			modifier = {
				add = 20
				scope:accused_witch = {
					NOT = { has_trait = witch }
				}
			}
			modifier = {
				add = -20
				scope:accused_witch = {
					OR = {
						has_trait = lunatic
						has_trait = possessed
					}
				}
			}
			modifier = {
				add = -20
				scope:accused_witch = {
					OR = {
						has_trait = deviant
						has_trait = cannibal
						has_trait = sodomite
						has_trait = incestuous
						has_trait = excommunicated
					}
				}
			}
		}	
	}
	option = {
		trigger = {
			scope:accused_witch = { is_adult = no }
		}
		name = expwitch.1006.f #Threaten child
		add_character_flag = confront_threaten_second
		stress_and_fulfillment_impact = {
			base = minor_stress_impact_gain
			forgiving = medium_stress_impact_gain
			patient = minor_stress_impact_gain
			compassionate = minor_stress_impact_gain
			wrathful = minor_stress_impact_loss
		}
		if = {
			limit = {
				scope:accused_witch = { is_vassal_of = scope:accuser }
			}
			add_dread = medium_dread_gain
		}
		else = {
			add_dread = minor_dread_gain
		}
		random_list = {
			75 = {
				modifier = {
					add = 25
					scope:accused_witch = { is_ruler = no }
				}
				modifier = {
					add = 25
					scope:accused_witch = { is_imprisoned = yes }
				}
				ai_value_modifier = {
					who = scope:accused_witch
					ai_boldness = -0.50
				}
				ai_value_modifier = {
					who = scope:accuser
					ai_vengefulness = 0.20
				}
				opinion_modifier = {
					who = scope:accuser
					opinion_target = scope:accused_witch
					multiplier = -0.2
					min = -20
					max = 20
				}
				modifier = {
					add = 10
					has_trait = wrathful
				}
				modifier = {
					add = 10
					has_trait = sadistic
				}
				modifier = {
					add = 10
					scope:accused_witch = {
						NOT = { has_trait = witch }
					}
				}
				modifier = {
					add = 20
					scope:accused_witch = { has_trait = craven }
				}
				modifier = {
					add = 25
					scope:accused_witch = {
						has_dread_level_towards = {
							target = scope:accuser
							level = 1
						}
					}
				}
				modifier = {
					add = 50
					scope:accused_witch = {
						has_dread_level_towards = {
							target = scope:accuser
							level = 2
						}
					}
				}
				modifier = {
					factor = 0.5
					OR = {
						has_relation_rival = scope:accused_witch
						has_relation_nemesis = scope:accused_witch
					}
				}
				add_character_flag = confront_witch_end_success
				custom_tooltip = expwitch.1007.succeed_confront.tt
			}
			25 = {
				modifier = {
					add = 20
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				modifier = {
					add = 10
					has_trait = just
				}
				modifier = {
					add = 10
					has_trait = forgiving
				}
				modifier = {
					add = 20
					scope:accused_witch = {
						OR = {
							has_trait = lunatic
							has_trait = possessed
						}
					}
				}
				modifier = {
					add = 10
					NAND = {
						scope:accused_witch = { has_trait = witch }
						NOT = { has_imprisonment_reason = scope:accused_witch }
					}
				}
				add_character_flag = confront_witch_end_fail
				custom_tooltip = expwitch.1007.failure_confront.tt
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 25
				scope:accused_witch = { is_imprisoned = yes }
			}
			modifier = {
				add = 10
				has_trait = wrathful
			}
			modifier = {
				add = 20
				has_trait = sadistic
			}
			modifier = {
				add = -10
				has_trait = just
			}
			modifier = {
				add = -20
				has_trait = forgiving
			}
			modifier = {
				add = -20
				has_trait = compassionate
			}
			ai_value_modifier = {
				who = scope:accused_witch
				ai_boldness = -0.20
			}
			ai_value_modifier = {
				who = scope:accuser
				ai_vengefulness = 0.50
			}
			opinion_modifier = {
				who = scope:accuser
				opinion_target = scope:accused_witch
				multiplier = -0.5
				max = 20
			}
			modifier = {
				add = -25
				is_close_or_extended_family_of = scope:accused_witch
			}
			modifier = {
				factor = 0
				OR = {
					ai_compassion >= low_positive_compassion
					ai_vengefulness <= low_negative_vengefulness
				}
			}
		}	
	}
	option = {
		name = expwitch.1006.g #Give up
		challenge_cleanup_flags = yes
		add_piety = minor_piety_loss
		stress_and_fulfillment_impact = {
			zealous = medium_stress_impact_gain
			diligent = minor_stress_impact_gain
		}
		if = {
			limit = {
				scope:accused_witch = { is_imprisoned = yes }
			}
			custom_tooltip = expwitch.1006.g.inprison.tt
		}
		else_if = {
			limit = {
				scope:accused_witch = { has_trait = witch }
				NOT = { has_imprisonment_reason = scope:accused_witch }
			}
			custom_tooltip = expwitch.1006.g.noprison.tt
		}
		else = {
			custom_tooltip = expwitch.1006.g.tt
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 30
				scope:accused_witch = { is_adult = yes }
				diplomacy < scope:accused_witch.diplomacy
				learning < scope:accused_witch.learning
				intrigue < scope:accused_witch.intrigue
				NAND = {
					scope:accuser.diplomacy_plus_10 <= scope:accused_witch.diplomacy
					scope:accuser.learning_plus_10 <= scope:accused_witch.learning
					scope:accuser.intrigue_plus_10 <= scope:accused_witch.intrigue
				}
			}
			modifier = {
				add = 100
				scope:accused_witch = { is_adult = yes }
				scope:accuser.diplomacy_plus_10 <= scope:accused_witch.diplomacy
				scope:accuser.learning_plus_10 <= scope:accused_witch.learning
				scope:accuser.intrigue_plus_10 <= scope:accused_witch.intrigue
			}
			modifier = {
				factor = 0.1
				OR = {
					has_trait = zealous
					has_trait = diligent
				}
			}
		}
	}

	after = {
		if = {
			limit = {
				OR = {
					has_character_flag = confront_diplomacy_initial
					has_character_flag = confront_learning_initial
					has_character_flag = confront_intrigue_initial
				}
			}
			#proceed to the second phase for adult targets
			trigger_event = expwitch.1007
		}
		else_if = {
			limit = { has_character_flag = confront_witch_end_fail }
			#proceed to failure event for children
			trigger_event = expwitch.1009
		}
		else_if = {
			limit = { has_character_flag = confront_witch_end_success }
			#proceed to success event for children
			trigger_event = expwitch.1001
		}
		else_if = {
			limit = { challenge_has_reaction_reason_trigger = yes }
			#accuser who abandons effort can decide whether or not to imprison or reveal their secret
			trigger_event = expwitch.1009
		}
		else = {
			#accuser who abandons effort and has to let them go
			scope:accused_witch = { trigger_event = expwitch.1008 }
		}
	}
}

# Attempting to get the accused witch to repent - Final Attempt
expwitch.1007 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = confront_witch_progress }
				desc = expwitch.1007.t.progress
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_witch_fail
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.t.mockery
			}
			triggered_desc = {
				trigger = { has_character_flag = confront_witch_fail }
				desc = expwitch.1007.t.fail
			}
			desc = expwitch.1007.t.noprogress
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = confront_diplomacy_initial
					has_character_flag = confront_witch_progress
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.diplomacy_progress_defiant
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_diplomacy_initial
					has_character_flag = confront_witch_progress
				}
				desc = expwitch.1007.diplomacy_progress
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_diplomacy_initial
					has_character_flag = confront_witch_no_progress
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.diplomacy_no_progress_defiant
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_diplomacy_initial
					has_character_flag = confront_witch_no_progress
				}
				desc = expwitch.1007.diplomacy_no_progress
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_diplomacy_initial
					has_character_flag = confront_witch_fail
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.diplomacy_fail_defiant
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_diplomacy_initial
					has_character_flag = confront_witch_fail
				}
				desc = expwitch.1007.diplomacy_fail
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_progress
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.learning_progress_defiant
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_progress
				}
				desc = expwitch.1007.learning_progress
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_no_progress
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.learning_no_progress_defiant
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_no_progress
				}
				desc = expwitch.1007.learning_no_progress
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_fail
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.learning_fail_defiant
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_fail
				}
				desc = expwitch.1007.learning_fail
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_intrigue_initial
					has_character_flag = confront_witch_progress
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.intrigue_progress_defiant
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_intrigue_initial
					has_character_flag = confront_witch_progress
				}
				desc = expwitch.1007.intrigue_progress
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_no_progress
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.intrigue_no_progress_defiant
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_no_progress
				}
				desc = expwitch.1007.intrigue_no_progress
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_fail
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1007.intrigue_fail_defiant
			}
			triggered_desc = {
				trigger = {
					has_character_flag = confront_learning_initial
					has_character_flag = confront_witch_fail
				}
				desc = expwitch.1007.intrigue_fail
			}
		}
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = confront_witch_progress }
				desc = expwitch.1007.end_progress
			}
			triggered_desc = {
				trigger = { has_character_flag = confront_witch_fail }
				desc = expwitch.1007.end_fail
			}
			desc = expwitch.1007.end_noprogress
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		triggered_animation = {
			trigger = {
				has_character_flag = confront_witch_fail
			}
			animation = shock
		}
		triggered_animation = {
			trigger = {
				has_character_flag = confront_witch_progress
			}
			animation = beg
		}
		animation = disapproval
	}
	right_portrait = {
		character = scope:accused_witch
		triggered_animation = {
			trigger = {
				scope:accuser = { has_character_flag = confront_witch_fail }
			}
			animation = disgust
		}
		triggered_animation = {
			trigger = {
				scope:accuser = { has_character_flag = confront_witch_progress }
			}
			animation = shame
		}
		animation = dismissal
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}

	option = {
		trigger = {
			NOR = {
				has_relation_rival = scope:accused_witch
				has_relation_nemesis = scope:accused_witch
				reverse_opinion = { target = scope:accused_witch value < -50 }
			}
		}
		show_as_unavailable = {
			OR = {
				has_relation_rival = scope:accused_witch
				has_relation_nemesis = scope:accused_witch
				reverse_opinion = { target = scope:accused_witch value < -40 }
			}
		}
		name = {
			trigger = {
				scope:accused_witch = {
					OR = {
						has_relation_friend = scope:accuser
						has_relation_lover = scope:accuser
						is_close_family_of = scope:accuser
					}
				}
			}
			text = expwitch.1007.a #Appeal based on relationship
		}
		name = {
			trigger = {
				scope:accused_witch = {
					NOR = {
						has_relation_friend = scope:accuser
						has_relation_lover = scope:accuser
						is_close_family_of = scope:accuser
					}
				}
			}
			text = expwitch.1007.b #Appeal to virtue and morality
		}
		skill = diplomacy
		add_character_flag = confront_diplomacy_second
		stress_and_fulfillment_impact = {
			shy = medium_stress_impact_gain
			impatient = minor_stress_impact_gain
		}
		random_list = {
			0 = {
				modifier = {
					add = {
						value = diplomacy
						multiply = 2
					}
				}
				modifier = {
					add = 50
					has_character_flag = confront_witch_progress
				}
				modifier = {
					add = 10
					has_trait = diplomat
					NOR = {
						has_relation_friend = scope:accuser
						has_relation_lover = scope:accuser
						is_close_family_of = scope:accuser
					}
				}
				modifier = {
					add = -10
					NOR = {
						faith = scope:accused_witch.faith
						has_relation_friend = scope:accuser
						has_relation_lover = scope:accuser
						is_close_family_of = scope:accuser
					}
				}
				modifier = {
					add = 20
					OR = {
						has_relation_friend = scope:accuser
						has_relation_lover = scope:accuser
						is_close_family_of = scope:accuser
					}
				}
				opinion_modifier = {
					trigger = {
						scope:accused_witch = {
							opinion = { target = scope:accuser value > 0 }
						}
					}
					who = scope:accused_witch
					opinion_target = scope:accuser
					multiplier = 0.5
				}
				ai_value_modifier = {
					trigger = {
						scope:accused_witch = { ai_honor > 0 }
					}
					who = scope:accused_witch
					ai_honor = 0.50
				}
				ai_value_modifier = {
					trigger = { ai_honor > 0 }
					who = scope:accuser
					ai_honor = 0.20
				}
				modifier = {
					factor = 0.5
					OR = {
						has_relation_rival = scope:accused_witch
						has_relation_nemesis = scope:accused_witch
					}
				}
				add_character_flag = confront_witch_end_success
				custom_tooltip = expwitch.1007.succeed_confront.tt
			}
			90 = {
				opinion_modifier = {
					trigger = {
						scope:accused_witch = {
							opinion = { target = scope:accuser value < 0 }
						}
					}
					who = scope:accused_witch
					opinion_target = scope:accuser
					multiplier = -0.5
				}
				ai_value_modifier = {
					trigger = {
						scope:accused_witch = { ai_honor < 0 }
					}
					who = scope:accused_witch
					ai_honor = -0.50
				}
				ai_value_modifier = {
					trigger = { ai_honor < 0 }
					who = scope:accuser
					ai_honor = -0.20
				}
				modifier = {
					add = 20
					has_character_flag = confront_witch_fail
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = zealous }
				}
				modifier = {
					add = 20
					scope:accused_witch = {
						OR = {
							has_trait = lunatic
							has_trait = possessed
						}
					}
				}
				add_character_flag = confront_witch_end_fail
				custom_tooltip = expwitch.1007.failure_confront.tt
			}
			10 = {
				modifier = {
					add = 10
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				modifier = {
					add = { value = scope:accused_witch.intrigue }
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = schemer }
				}
				modifier = {
					factor = 0.5
					scope:accused_witch = { has_trait = craven }
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = zealous }
				}
				add_character_flag = confront_witch_end_critfail
				custom_tooltip = expwitch.1007.critfail_confront.tt
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = diplomacy
					multiply = 5
				}
			}
			modifier = {
				add = 20
				OR = {
					has_trait = diplomat
					has_relation_friend = scope:accuser
					has_relation_lover = scope:accuser
					is_close_family_of = scope:accuser
				}
			}
			modifier = {
				add = -20
				has_trait = shy
			}
			ai_value_modifier = {
				who = scope:accused_witch
				ai_honor = 0.20
			}
			opinion_modifier = {
				who = scope:accused_witch
				opinion_target = scope:accuser
				multiplier = 0.20
			}
			ai_value_modifier = {
				who = scope:accuser
				ai_honor = 0.50
			}
			modifier = {
				add = -20
				scope:accused_witch = {
					OR = {
						has_trait = lunatic
						has_trait = possessed
					}
				}
			}
			modifier = {
				add = -10
				scope:accused_witch = { has_trait = zealous }
			}
		}
	}
	option = {
		trigger = {
			NOR = {
				has_trait = cynical
				has_trait = excommunicated
			}
		}
		show_as_unavailable = {
			OR = {
				has_trait = cynical
				has_trait = excommunicated
			}
		}
		name = expwitch.1007.c #Patiently convert them
		skill = learning
		add_character_flag = confront_learning_second
		stress_and_fulfillment_impact = {
			zealous = medium_stress_impact_loss
			lazy = minor_stress_impact_gain
		}
		random_list = {
			0 = {
				modifier = {
					add = {
						value = learning
						multiply = 2
					}
				}
				modifier = {
					add = 25
					has_character_flag = confront_witch_progress
				}
				opinion_modifier = {
					trigger = {
						scope:accused_witch = {
							opinion = { target = scope:accuser value > 0 }
						}
					}
					who = scope:accused_witch
					opinion_target = scope:accuser
					multiplier = 0.2
				}
				ai_value_modifier = {
					trigger = {
						scope:accused_witch = { ai_zeal < 0 }
					}
					who = scope:accused_witch
					ai_zeal = -0.50
				}
				ai_value_modifier = {
					trigger = { ai_zeal > 0 }
					who = scope:accuser
					ai_zeal = 0.20
				}
				modifier = {
					add = 10
					has_trait = erudite
				}
				modifier = {
					add = -10
					NOT = { faith = scope:accused_witch.faith }
				}
				modifier = {
					add = 20
					has_trait = theologian
				}
				modifier = {
					add = 20
					scope:accused_witch = {
						NOT = { has_trait = witch }
					}
				}
				modifier = {
					factor = 0.5
					OR = {
						has_relation_rival = scope:accused_witch
						has_relation_nemesis = scope:accused_witch
					}
				}
				add_character_flag = confront_witch_end_success
				custom_tooltip = expwitch.1007.succeed_confront.tt
			}
			90 = {
				opinion_modifier = {
					trigger = {
						scope:accused_witch = {
							opinion = { target = scope:accuser value < 0 }
						}
					}
					who = scope:accused_witch
					opinion_target = scope:accuser
					multiplier = -0.2
				}
				ai_value_modifier = {
					trigger = {
						scope:accused_witch = { ai_zeal > 0 }
					}
					who = scope:accused_witch
					ai_zeal = 0.50
				}
				ai_value_modifier = {
					trigger = { ai_zeal < 0 }
					who = scope:accuser
					ai_zeal = -0.20
				}
				modifier = {
					add = -25
					has_character_flag = confront_witch_progress
				}
				modifier = {
					add = 20
					has_character_flag = confront_witch_fail
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = stubborn }
				}
				modifier = {
					add = 20
					scope:accused_witch = {
						OR = {
							has_trait = lunatic
							has_trait = possessed
						}
					}
				}
				modifier = {
					add = 20
					scope:accused_witch = {
						OR = {
							has_trait = deviant
							has_trait = cannibal
							has_trait = sodomite
							has_trait = incestuous
							has_trait = excommunicated
						}
					}
				}
				add_character_flag = confront_witch_end_fail
				custom_tooltip = expwitch.1007.failure_confront.tt
			}
			10 = {
				ai_value_modifier = {
					who = scope:accused_witch
					ai_zeal = 0.20
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				modifier = {
					add = { value = scope:accused_witch.intrigue }
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = schemer }
				}
				modifier = {
					factor = 0.5
					scope:accused_witch = { has_trait = craven }
				}
				add_character_flag = confront_witch_end_critfail
				custom_tooltip = expwitch.1007.critfail_confront.tt
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = {
					value = learning
					multiply = 5
				}
			}
			ai_value_modifier = {
				who = scope:accused_witch
				ai_zeal = -0.20
			}
			ai_value_modifier = {
				who = scope:accuser
				ai_zeal = 0.50
			}
			modifier = {
				add = 10
				has_trait = erudite
			}
			modifier = {
				add = 20
				has_trait = theologian
			}
			modifier = {
				add = 20
				scope:accused_witch = {
					NOT = { has_trait = witch }
				}
			}
			modifier = {
				add = -20
				scope:accused_witch = {
					OR = {
						has_trait = lunatic
						has_trait = possessed
					}
				}
			}
			modifier = {
				add = -20
				scope:accused_witch = {
					OR = {
						has_trait = deviant
						has_trait = cannibal
						has_trait = sodomite
						has_trait = incestuous
						has_trait = excommunicated
					}
				}
			}
		}
	}
	option = {
		name = expwitch.1007.d #Threaten them
		add_character_flag = confront_threaten_second
		stress_and_fulfillment_impact = {
			forgiving = medium_stress_impact_gain
			patient = minor_stress_impact_gain
			wrathful = minor_stress_impact_loss
		}
		if = {
			limit = {
				scope:accused_witch = { is_vassal_of = scope:accuser }
			}
			add_dread = medium_dread_gain
		}
		else = {
			add_dread = minor_dread_gain
		}
		random_list = {
			50 = {
				modifier = {
					add = 25
					scope:accused_witch = { is_ruler = no }
				}
				modifier = {
					add = 25
					scope:accused_witch = { is_imprisoned = yes }
				}
				ai_value_modifier = {
					trigger = { ai_vengefulness > 0 }
					who = scope:accuser
					ai_vengefulness = 0.20
				}
				ai_value_modifier = {
					trigger = {
						scope:accused_witch = { ai_boldness < 0 }
					}
					who = scope:accused_witch
					ai_boldness = -0.50
				}
				opinion_modifier = {
					trigger = {
						opinion = { target = scope:accused_witch value < 0 }
					}
					who = scope:accuser
					opinion_target = scope:accused_witch
					multiplier = -0.2
				}
				modifier = {
					add = 10
					has_trait = wrathful
				}
				modifier = {
					add = 10
					has_trait = sadistic
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = craven }
				}
				modifier = {
					add = 10
					scope:accused_witch = {
						NOT = { has_trait = witch }
					}
				}
				modifier = {
					add = 50
					has_character_flag = confront_witch_progress
				}
				modifier = {
					add = 25
					scope:accused_witch = {
						has_dread_level_towards = {
							target = scope:accuser
							level = 1
						}
					}
				}
				modifier = {
					add = 50
					scope:accused_witch = {
						has_dread_level_towards = {
							target = scope:accuser
							level = 2
						}
					}
				}
				modifier = {
					factor = 0.5
					OR = {
						has_relation_rival = scope:accused_witch
						has_relation_nemesis = scope:accused_witch
					}
				}
				add_character_flag = confront_witch_end_success
				custom_tooltip = expwitch.1007.succeed_confront.tt
			}
			50 = {
				ai_value_modifier = {
					trigger = { ai_vengefulness < 0 }
					who = scope:accuser
					ai_vengefulness = -0.20
				}
				ai_value_modifier = {
					trigger = {
						scope:accused_witch = { ai_boldness > 0 }
					}
					who = scope:accused_witch
					ai_boldness = 0.50
				}
				opinion_modifier = {
					trigger = {
						opinion = { target = scope:accused_witch value > 0 }
					}
					who = scope:accuser
					opinion_target = scope:accused_witch
					multiplier = 0.2
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				modifier = {
					add = 50
					has_character_flag = confront_witch_fail
				}
				modifier = {
					add = 10
					has_trait = just
				}
				modifier = {
					add = 10
					has_trait = forgiving
				}
				modifier = {
					add = 10
					scope:accused_witch = { has_trait = witch }
					NOT = { has_imprisonment_reason = scope:accused_witch }
				}
				modifier = {
					add = 20
					scope:accused_witch = {
						OR = {
							has_trait = lunatic
							has_trait = possessed
						}
					}
				}
				modifier = {
					add = 25
					scope:accused_witch = {
						is_powerful_vassal = yes
						is_imprisoned = no
					}
				}
				add_character_flag = confront_witch_end_fail
				custom_tooltip = expwitch.1007.failure_confront.tt
			}
		}
		ai_chance = {
			base = 0
			modifier = {
				add = 25
				scope:accused_witch = { is_ruler = no }
			}
			modifier = {
				add = 25
				scope:accused_witch = { is_imprisoned = yes }
			}
			modifier = {
				add = -25
				scope:accused_witch = {
					is_powerful_vassal = yes
					is_imprisoned = no
				}
			}
			modifier = {
				add = 10
				has_trait = wrathful
			}
			modifier = {
				add = 10
				has_trait = sadistic
			}
			modifier = {
				add = -10
				has_trait = just
			}
			modifier = {
				add = -20
				has_trait = forgiving
			}
			ai_value_modifier = {
				who = scope:accused_witch
				ai_boldness = -0.20
			}
			ai_value_modifier = {
				who = scope:accuser
				ai_vengefulness = 0.50
			}
			opinion_modifier = {
				who = scope:accuser
				opinion_target = scope:accused_witch
				multiplier = -0.5
			}
			modifier = {
				add = 25
				scope:accused_witch = {
					has_dread_level_towards = {
						target = scope:accuser
						level = 1
					}
				}
			}
			modifier = {
				add = 50
				scope:accused_witch = {
					has_dread_level_towards = {
						target = scope:accuser
						level = 2
					}
				}
			}
		}	
	}
	option = {
		name = expwitch.1007.e #Abandon the effort
		challenge_cleanup_flags = yes
		add_piety = minor_piety_loss
		stress_and_fulfillment_impact = {
			zealous = medium_stress_impact_gain
			diligent = minor_stress_impact_gain
		}
		if = {
			limit = { challenge_has_reaction_reason_trigger = yes }
			custom_tooltip = expwitch.1006.g.tt
		}
		else_if = {
			limit = { scope:accused_witch = { is_imprisoned = yes } }
			custom_tooltip = expwitch.1006.g.inprison.tt
		}
		else = {
			custom_tooltip = expwitch.1006.g.noprison.tt
		}
		ai_chance = {
			base = 10
			#all three of the options are not a great idea
			modifier = {
				add = 20
				OR = {
					diplomacy < 8
					has_relation_rival = scope:accused_witch
					has_relation_nemesis = scope:accused_witch
					scope:accused_witch = { ai_honor <= high_negative_honor }
					reverse_opinion = { target = scope:accused_witch value < -50 }
				}
				OR = {
					learning < 8
					has_trait = cynical
					has_trait = excommunicated
					scope:accused_witch = { ai_zeal >= high_positive_zeal }
				}
				OR = {
					has_trait = forgiving
					scope:accused_witch = { ai_boldness >= high_positive_boldness }
					scope:accused_witch = {
						is_powerful_vassal = yes
						is_imprisoned = no
					}
				}
			}
			# rivals have a smaller chance of success overall
			modifier = {
				add = 50
				OR = {
					has_relation_rival = scope:accused_witch
					has_relation_nemesis = scope:accused_witch
				}
			}
			# failed the first duel
			modifier = {
				add = 40
				has_character_flag = confront_witch_fail
			}
			# lets gooooo
			modifier = {
				factor = 0.5
				has_character_flag = confront_witch_progress
			}
		}
	}
	
	after = {
		if = {
			limit = { has_character_flag = confront_witch_end_critfail }
			scope:accused_witch = { trigger_event = expwitch.1011 }
		}
		else_if = {
			limit = { has_character_flag = confront_witch_end_success }
			trigger_event = expwitch.1001
		}
		else_if = {
			limit = {
				OR = {
					challenge_has_reaction_reason_trigger = yes
					has_character_flag = confront_witch_end_fail
				}
			}
			trigger_event = expwitch.1009
		}
		else = {
			scope:accused_witch = { trigger_event = expwitch.1008 }
		}
	}
}

# Accuser abandoned the attempt and either leaves them in prison or was forced to let them go
expwitch.1008 = {
	type = character_event
	title = expwitch.1008.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_witch_end_fail }
				}
				desc = expwitch.1008.failed_second
			}
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_diplomacy_initial }
				}
				desc = expwitch.1008.tried_diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_learning_initial }
				}
				desc = expwitch.1008.tried_learning
			}
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_intrigue_initial }
				}
				desc = expwitch.1008.tried_intrigue
			}
			desc = expwitch.1008.tried_nothing
		}
		first_valid = {
			triggered_desc = {
				trigger = { is_imprisoned = yes }
				desc = expwitch.1008.end_imprisoned
			}
			desc = expwitch.1008.end_court
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		animation = sadness
	}
	right_portrait = {
		character = scope:accused_witch
		animation = dismissal
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}	

	option = {
		name = expwitch.1008.a
		add_prestige = medium_prestige_gain
		challenge_cleanup_flags = yes
	}
}

# Accuser abandons or fails the attempt and might still imprison them
expwitch.1009 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = confront_witch_end_fail }
				desc = expwitch.1009.t.fail
			}
			desc = expwitch.1009.t.abandon
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = { is_adult = no }
					has_character_flag = confront_diplomacy_second
				}
				desc = expwitch.1009.diplomacy_fail_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = { is_adult = no }
					has_character_flag = confront_learning_second
				}
				desc = expwitch.1009.learning_fail_child
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = { is_adult = no }
					has_character_flag = confront_threaten_second
				}
				desc = expwitch.1009.threaten_fail_child
			}
			triggered_desc = {
				trigger = { has_character_flag = confront_diplomacy_second }
				desc = expwitch.1009.diplomacy_fail
			}
			triggered_desc = {
				trigger = { has_character_flag = confront_learning_second }
				desc = expwitch.1009.learning_fail
			}
			triggered_desc = {
				trigger = { has_character_flag = confront_threaten_second }
				desc = expwitch.1009.threaten_fail
			}
			triggered_desc = {
				trigger = {
					OR = {
						has_character_flag = confront_diplomacy_initial
						has_character_flag = confront_learning_initial
						has_character_flag = confront_intrigue_initial
					}
				}
				desc = expwitch.1009.abandon_second
			}
			desc = expwitch.1009.abandon
		}
		desc = expwitch.1009.end
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		animation = sadness
	}
	right_portrait = {
		character = scope:accused_witch
		animation = dismissal
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}	

	option = {
		name = {
			trigger = {
				scope:accused_witch = { is_imprisoned = no }
			}
			text = expwitch.1009.a #Let them go
		}
		name = {
			trigger = {
				scope:accused_witch = { is_imprisoned = yes }
			}
			text = expwitch.1009.b #They'll stay where they are
		}
		add_piety = medium_piety_loss
		if = {
			limit = { scope:accused_witch = { is_imprisoned = no } }
			custom_tooltip = expwitch.free_to_go.tt
		}
		else = {
			custom_tooltip = expwitch.remain_in_prison.tt
		}
		ai_chance = {
			base = 50
			ai_value_modifier = {
				who = scope:accuser
				ai_compassion = 0.50
				ai_vengefulness = -0.50
				ai_zeal = -0.50
			}
			opinion_modifier = {
				who = scope:accuser
				opinion_target = scope:accused_witch
				multiplier = 0.5
			}
			modifier = {
				add = 100
				is_close_family_of = scope:accused_witch
			}
			modifier = {
				add = 50
				NOT = { is_close_family_of = scope:accused_witch }
				is_extended_family_of = scope:accused_witch
			}
			modifier = {
				add = 25
				dynasty = scope:accused_witch.dynasty
				NOT = { is_close_or_extended_family_of = scope:accused_witch }
			}
			modifier = {
				factor = 0.5
				scope:accused_witch = { has_trait = witch }
				has_imprisonment_reason = scope:accused_witch
				NOR = {
					has_trait = just
					has_trait = zealous
				}
			}
			modifier = {
				factor = 2
				scope:accused_witch = { is_adult = no }
			}
		}
	}
	option = {
		trigger = { challenge_has_reaction_reason_trigger = yes }
		name = {
			trigger = {
				scope:accused_witch = { is_imprisoned = no }
			}
			text = expwitch.1009.c #Imprison them!
		}
		name = {
			trigger = {
				scope:accused_witch = { is_imprisoned = yes }
			}
			text = expwitch.1009.d #Everyone should know what they are
		}
		add_piety = minor_piety_gain
		stress_and_fulfillment_impact = {
			forgiving = minor_stress_impact_gain
			zealous = medium_stress_impact_loss
		}
		if = {
			limit = {
				scope:accused_witch = {
					NOT = { has_trait = witch }
				}
				any_known_secret = {
					secret_owner = scope:accused_witch
					secret_type = secret_witch
					can_be_exposed_by = scope:accuser
				}
			}
			scope:accused_witch = { add_character_flag = liege_revealed_witch_secret }
			random_known_secret = {
				limit = {
					secret_owner = scope:accused_witch
					secret_type = secret_witch
					can_be_exposed_by = scope:accuser
				}
				show_as_tooltip = {
					expose_secret = scope:accuser
				}
			}
			if = {
				limit = {
					scope:accused_witch = { is_imprisoned = no }
				}
				scope:accused_witch = { add_character_flag = liege_imprisoned_me }
				show_as_tooltip = {
					rightfully_imprison_character_effect = {
						TARGET = scope:accused_witch
						IMPRISONER = scope:accuser
					}
				}
			}
		}
		else = {
			scope:accused_witch = { add_character_flag = liege_imprisoned_me }
			show_as_tooltip = {
				imprison_character_effect = {
					TARGET = scope:accused_witch
					IMPRISONER = scope:accuser
				}
			}
		}
		ai_chance = {
			base = 50
			modifier = {
				add = 100
				has_character_flag = confront_threaten_second
			}
			modifier = {
				add = 50
				NOT = { is_close_or_extended_family_of = scope:accused_witch }
				OR = {
					has_banish_reason = scope:accused_witch
					has_revoke_title_reason = scope:accused_witch
				}
			}
			modifier = {
				add = 50
				OR = {
					has_relation_rival = scope:accused_witch
					has_relation_nemesis = scope:accused_witch
				}
			}
			modifier = {
				factor = 0.5
				scope:accused_witch = { is_adult = no }
			}
		}
	}
	
	after = {
		if = {
			limit = {
				scope:accused_witch = {
					OR = {
						has_character_flag = liege_revealed_witch_secret
						has_character_flag = liege_imprisoned_me
					}
				}
			}
			scope:accused_witch = { trigger_event = expwitch.1010 }
		}
		else = {
			scope:accused_witch = { trigger_event = expwitch.1008 }
		}
	}
}

# Accuser elected to imprison the accused or reveal their secret after failing/abandoning the attempt
expwitch.1010 = {
	type = character_event
	title = expwitch.1010.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_witch_end_fail }
				}
				desc = expwitch.1008.failed_second
			}
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_diplomacy_initial }
				}
				desc = expwitch.1008.tried_diplomacy
			}
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_learning_initial }
				}
				desc = expwitch.1008.tried_learning
			}
			triggered_desc = {
				trigger = {
					scope:accuser = { has_character_flag = confront_intrigue_initial }
				}
				desc = expwitch.1008.tried_intrigue
			}
			desc = expwitch.1008.tried_nothing
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = liege_revealed_witch_secret
					is_imprisoned = no
					NOT = { has_character_flag = liege_imprisoned_me }
				}
				desc = expwitch.1010.reveal_noprison
			}
			triggered_desc = {
				trigger = {
					has_character_flag = liege_revealed_witch_secret
					is_imprisoned = yes
					NOT = { has_character_flag = liege_imprisoned_me }
				}
				desc = expwitch.1010.reveal_stillprison
			}
			triggered_desc = {
				trigger = {
					has_character_flag = liege_revealed_witch_secret
					has_character_flag = liege_imprisoned_me
				}
				desc = expwitch.1010.reveal_sentprison
			}
			desc = expwitch.1010.noreveal_sentprison

		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		animation = sadness
	}
	right_portrait = {
		character = scope:accused_witch
		animation = dismissal
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			OR = {
				is_imprisoned = yes
				has_character_flag = liege_imprisoned_me
			}
		}
		reference = dungeon
	}
	override_sound = {
		trigger = { has_character_flag = liege_imprisoned_me }
		reference = "event:/SFX/Events/Themes/sfx_event_theme_type_prison"
	}

	option = {
		name = expwitch.1010.a
		if = {
			limit = { has_character_flag = liege_revealed_witch_secret }
			random_secret = {
				type = secret_witch
				limit = {
					secret_owner = scope:accused_witch
					can_be_exposed_by = scope:accuser
				}
				expose_secret = scope:accuser
			}
			if = {
				limit = {
					is_imprisoned = no
					has_character_flag = liege_imprisoned_me
				}
				rightfully_imprison_character_effect = {
					TARGET = scope:accused_witch
					IMPRISONER = scope:accuser
				}
			}
		}
		else_if = {
			limit = { has_character_flag = liege_imprisoned_me }
			imprison_character_effect = {
				TARGET = scope:accused_witch
				IMPRISONER = scope:accuser
			}
		}
		challenge_cleanup_flags = yes
	}
}

# Accused witch turns the tables on the accuser
expwitch.1011 = {
	type = character_event
	title = expwitch.1011.t
	desc = expwitch.1011.desc
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		animation = stress
	}
	right_portrait = {
		character = scope:accused_witch
		animation = disgust
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}
	
	option = {
		name = expwitch.1011.a #Gain a favor
		trigger = {
			is_imprisoned = no
			can_add_hook = {
				target = scope:accuser
				type = manipulation_hook
			}
		}
		add_character_flag = confront_critfail_favor
		if = {
			limit = {
				scope:accuser = { has_hook = scope:accused_witch }
			}
			show_as_tooltip = {
				scope:accuser = {
					remove_hook = { target = scope:accused_witch }
				}
			}
		}
		if = {
			limit = {
				can_add_hook = {
					target = scope:accuser
					type = manipulation_hook
				}
			}
			show_as_tooltip = {
				add_hook = {
					target = scope:accuser
					type = manipulation_hook
				}
			}
		}
		ai_chance = {
			factor = 100
		}
	}
	option = {
		name = expwitch.1011.b #Release from prison
		trigger = { is_imprisoned = yes }
		add_character_flag = confront_critfail_release
		show_as_tooltip = {
			release_from_prison = yes
			consume_all_criminal_reasons_effect = {
				LIEGE = scope:accuser
				CRIMINAL = scope:accused_witch
			}
			every_secret = {
				limit = {
					is_known_by = scope:accuser
					secret_owner = scope:accused_witch
					can_be_exposed_by = scope:accuser
				}
				disable_exposure_by = scope:accuser
			}
		}
		ai_chance = {
			factor = 100
		}
	}
	option = {
		name = expwitch.1011.c #Attempt to convert
		trigger = {
			intrigue >= 8
			scope:accuser = { NOT = { has_trait = zealous } }
		}
		show_as_unavailable = {
			OR = {
				intrigue < 8
				scope:accuser = { has_trait = zealous }
			}
		}
		skill = intrigue
		if = {
			limit = { is_imprisoned = yes }
			custom_tooltip = expwitch.1011.still_prison.tt
		}
		else = {
			custom_tooltip = expwitch.1011.can_leave.tt
		}
		duel = {
			skill = intrigue
			value = high_skill_rating
			20 = {
				ai_value_modifier = {
					who = scope:accuser
					ai_zeal = -0.50
					max = 20
					min = -20
				}
				opinion_modifier = {
					who = scope:accuser
					opinion_target = scope:accused_witch
					multiplier = 0.5
					max = 20
					min = -20
				}
				modifier = {
					add = 10
					scope:accuser = { has_trait = fickle }
				}
				modifier = {
					add = 20
					scope:accuser = { has_trait = trusting }
				}
				modifier = {
					add = 20
					scope:accuser = { has_trait = intellect_bad }
				}
				modifier = {
					add = 30
					scope:accuser = { has_trait = lunatic }
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = 3.5
					min = 5
				}
				add_character_flag = confront_critfail_convert
				custom_tooltip = expwitch.1011.c.success.tt
			}
			80 = {
				modifier = {
					add = 20
					scope:accuser = { has_trait = paranoid }
				}
				modifier = {
					add = 20
					scope:accuser = { has_trait = intellect_good }
				}
				modifier = {
					add = 10
					scope:accuser = { has_trait = stubborn }
				}
				compare_modifier = {
					value = scope:duel_value
					multiplier = -3.5
					min = 5
				}
				add_character_flag = confront_critfail_convert_fail
				custom_tooltip = expwitch.1011.c.fail.tt
			}
		}
		ai_chance = {
			factor = 20
			compare_modifier = {
				target = scope:accused_witch
				value = intrigue
				multiplier = 5.0
				offset = 8
			}
			compare_modifier = {
				target = scope:accuser
				value = intrigue
				multiplier = -5.0
				offset = scope:accused_witch.intrigue
			}
			modifier = {
				add = 10
				scope:accuser = { has_trait = trusting }
			}
			modifier = {
				add = 10
				scope:accuser = { has_trait = intellect_bad }
			}
			modifier = {
				add = 20
				scope:accuser = { has_trait = lunatic }
			}
			ai_value_modifier = {
				who = scope:accuser
				ai_zeal = -0.50
				max = 20
				min = -20
			}
			opinion_modifier = {
				who = scope:accuser
				opinion_target = scope:accused_witch
				multiplier = 0.5
				max = 20
				min = -20
			}
			modifier = {
				factor = 0
				intrigue < scope:accuser.intrigue
			}
		}
	}
	option = {
		name = expwitch.1011.d #Just leave
		trigger = { is_imprisoned = no }
		add_character_flag = confront_critfail_leave
		ai_chance = {
			factor = 1
		}
	}
	
	after = {
		if = {
			limit = {
				OR = {
					has_character_flag = confront_critfail_convert
					has_character_flag = confront_critfail_convert_fail
				}
			}
			trigger_event = expwitch.1012
		}
		else = {
			scope:accuser = { trigger_event = expwitch.1013 }
		}
	}
}

# Accused witch informed of results of attempting to convert accuser
expwitch.1012 = {
	type = character_event
	title = {
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = confront_critfail_convert_fail }
				desc = expwitch.1012.t.fail
			}
			desc = expwitch.1012.t.success
		}
	}
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					has_character_flag = confront_critfail_convert_fail
					is_imprisoned = yes
				}
				desc = expwitch.1012.fail_prison
			}
			triggered_desc = {
				trigger = { has_character_flag = confront_critfail_convert_fail }
				desc = expwitch.1012.fail
			}
			desc = expwitch.1012.success
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		triggered_animation = {
			trigger = {
				scope:accused_witch = { has_character_flag = confront_critfail_convert_fail }
			}
			animation = anger
		}
		animation = thinking
	}
	right_portrait = {
		character = scope:accused_witch
		animation = personality_zealous
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}

	option = {
		name = expwitch.1012.a #success
		trigger = { has_character_flag = confront_critfail_convert }
		add_prestige = medium_prestige_gain
		stress_and_fulfillment_impact = {
			base = medium_stress_impact_loss
			arrogant = minor_stress_impact_loss
			shy = minor_stress_impact_gain
		}
		show_as_tooltip = {
			if = {
				limit = { is_imprisoned_by = scope:accuser }
				release_from_prison = yes
			}
			consume_all_criminal_reasons_effect = {
				LIEGE = scope:accuser
				CRIMINAL = scope:accused_witch
			}		
			scope:accuser = {
				challenge_recruit_witchcraft_success_effect = yes
			}
		}
	}
	option = {
		name = expwitch.1012.b #failure
		trigger = { has_character_flag = confront_critfail_convert_fail }
		add_piety = medium_piety_loss
		stress_and_fulfillment_impact = {
			base = medium_stress_impact_gain
			arrogant = minor_stress_impact_gain
			ambitious = minor_stress_impact_gain
		}
		show_as_tooltip = {
			scope:accuser = {
				progress_towards_rival_effect = {
					CHARACTER = scope:accused_witch
					REASON = attempt_convert_me_to_witchcraft
					OPINION = -50
				}
			}
		}
	}
	
	after = {
		scope:accuser = { trigger_event = expwitch.1013 }
	}
}

# Accuser informed of results of botched confrontation
expwitch.1013 = {
	type = character_event
	title = expwitch.1013.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = { has_character_flag = confront_diplomacy_second }
				desc = expwitch.1013.diplomacy
			}
			desc = expwitch.1013.learning
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = { has_character_flag = confront_critfail_convert }
				}
				desc = expwitch.1013.converted
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = { has_character_flag = confront_critfail_convert_fail }
				}
				desc = expwitch.1013.convert.fail
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = { has_character_flag = confront_critfail_release }
				}
				desc = expwitch.1013.release
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = { has_character_flag = confront_critfail_favor }
				}
				desc = expwitch.1013.favor
			}
			desc = expwitch.1013.leave
		}
	}
	theme = realm
	
	left_portrait = {
		character = scope:accuser
		triggered_animation = {
			trigger = {
				scope:accused_witch = { has_character_flag = confront_critfail_convert_fail }
			}
			animation = anger
		}
		triggered_animation = {
			trigger = {
				scope:accused_witch = { has_character_flag = confront_critfail_convert }
			}
			animation = thinking
		}
		animation = stress
	}
	right_portrait = {
		character = scope:accused_witch
		animation = personality_zealous
	}
	override_icon = {
		reference = "gfx/interface/icons/event_types/type_faith.dds"
	}
	override_background = {
		trigger = {
			scope:accused_witch = { is_imprisoned = yes }
		}
		reference = dungeon
	}	

	option = {
		name = expwitch.1013.a
		trigger = {
			scope:accused_witch = { has_character_flag = confront_critfail_convert }
		}
		add_piety = major_piety_loss
		stress_and_fulfillment_impact = {
			base = major_stress_impact_gain
			honest = medium_stress_impact_gain
			zealous = major_stress_impact_gain
			ambitious = minor_stress_impact_loss
		}
		if = {
			limit = { is_imprisoned_by = scope:accuser }
			release_from_prison = yes
		}
		consume_all_criminal_reasons_effect = {
			LIEGE = scope:accuser
			CRIMINAL = scope:accused_witch
		}		
		challenge_recruit_witchcraft_success_effect = yes
	}
	option = {
		name = expwitch.1013.b
		trigger = {
			scope:accused_witch = { has_character_flag = confront_critfail_convert_fail }
		}
		add_piety = medium_piety_loss
		stress_and_fulfillment_impact = {
			base = medium_stress_impact_gain
			vengeful = minor_stress_impact_gain
		}
		progress_towards_rival_effect = {
			CHARACTER = scope:accused_witch
			REASON = attempt_convert_me_to_witchcraft
			OPINION = -50
		}
	}
	option = {
		name = expwitch.1013.c
		trigger = {
			scope:accused_witch = { has_character_flag = confront_critfail_release }
		}
		add_piety = medium_piety_loss
		add_prestige = major_prestige_loss
		stress_and_fulfillment_impact = {
			base = medium_stress_impact_gain
			just = medium_stress_impact_gain
			forgiving = minor_stress_impact_loss
		}
		consume_all_criminal_reasons_effect = {
			LIEGE = scope:accuser
			CRIMINAL = scope:accused_witch
		}
		scope:accused_witch = {
			release_from_prison = yes
			every_secret = {
				limit = {
					is_known_by = scope:accuser
					secret_owner = scope:accused_witch
					can_be_exposed_by = scope:accuser
				}
				disable_exposure_by = scope:accuser
			}
		}
	}
	option = {
		name = expwitch.1013.d
		trigger = {
			scope:accused_witch = { has_character_flag = confront_critfail_favor }
		}
		add_piety = medium_piety_loss
		add_prestige = medium_prestige_loss
		stress_and_fulfillment_impact = {
			base = medium_stress_impact_gain
			greedy = minor_stress_impact_gain
			diligent = minor_stress_impact_gain
			generous = minor_stress_impact_loss
		}
		if = {
			limit = { has_hook = scope:accused_witch }
			remove_hook = { target = scope:accused_witch }
		}
		if = {
			limit = {
				scope:accused_witch = {
					can_add_hook = {
						target = scope:accuser
						type = manipulation_hook
					}
				}
			}
			scope:accused_witch = {
				add_hook = {
					target = scope:accuser
					type = manipulation_hook
				}
			}
		}
	}
	option = {
		name = expwitch.1013.e
		trigger = {
			scope:accused_witch = { has_character_flag = confront_critfail_leave }
		}
		add_piety = medium_piety_loss
		stress_and_fulfillment_impact = {
			base = medium_stress_impact_gain
			just = minor_stress_impact_gain
		}
	}
	
	after = { challenge_cleanup_flags = yes }
}


#####################
# Witch Trial (fired from character interaction)
# by David Gaider
#####################

# Accused witch decides how they'll face the trial
expwitch.1020 = {
	type = character_event
	title = expwitch.1020.t
	desc = {
		desc = expwitch.1020.start
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						knows_about_character_being_witch_trigger = { CHARACTER = scope:court_chaplain }
					}
				}
				desc = expwitch.1020.knows.witch
			}
			triggered_desc = {
				trigger = {
					scope:court_chaplain = { is_witch_trigger = yes }
				}
				desc = expwitch.1020.secret.witch
			}
			desc = expwitch.1020.end
		}
	}
	theme = faith
	
	left_portrait = {
		character = scope:court_chaplain
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = no } }
			outfit_tags = { priest_outfit }
		}
		triggered_animation = {
			trigger = {
				scope:court_chaplain = { is_witch_trigger = yes }
			}
			animation = scheme
		}
		animation = anger
	}
	right_portrait = {
		character = scope:accused_witch
		triggered_animation = {
			trigger = {
				scope:accused_witch = {
					knows_about_character_being_witch_trigger = { CHARACTER = scope:court_chaplain }
				}
			}
			animation = happiness
		}
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = no } }
			outfit_tags = { beggar_rags }
		}
		animation = scheme
		override_imprisonment_visuals = yes
	}
	
	option = {
		name = expwitch.1020.a #Defiance!
		trigger = {
			scope:court_chaplain = { is_witch_trigger = no }
		}
		add_character_flag = challenge_withcraft_defiant
		custom_tooltip = expwitch.1020.a.tt
		ai_chance = {
			factor = 20
			ai_value_modifier = {
				ai_boldness = 1
				ai_vengefulness = 0.5
			}
			modifier = {
				add = 10
				has_trait = vengeful
			}
			modifier = {
				add = 10
				NOT = { faith = scope:court_chaplain.faith }
			}
		}
	}
	option = {
		name = expwitch.1020.b #We shall see how this plays out.
		trigger = {
			scope:court_chaplain = { is_witch_trigger = no }
		}
		custom_tooltip = expwitch.1020.b.tt
		ai_chance = {
			factor = 60
			ai_value_modifier = {
				ai_compassion = 1
				ai_rationality = 0.5
			}
			modifier = {
				add = 20
				has_trait = calm
			}
			modifier = {
				add = 20
				has_trait = patient
			}
			modifier = {
				add = 10
				has_trait = trusting
			}
			modifier = {
				factor = 0.5
				OR = {
					has_trait = lunatic
					has_trait = possessed
				}
			}
		}
	}
	option = {
		name = expwitch.1020.c #I will admit everything and anything to survive!
		trigger = {
			scope:court_chaplain = { is_witch_trigger = no }
		}
		add_character_flag = challenge_withcraft_surrender
		custom_tooltip = expwitch.1020.c.tt
		ai_chance = {
			factor = 20
			ai_value_modifier = {
				ai_boldness = -1
			}
			modifier = {
				add = -10
				has_trait = vengeful
			}
			modifier = {
				add = -20
				has_trait = stubborn
			}
			modifier = {
				add = 20
				has_trait = honest
			}
			modifier = {
				factor = 0.5
				has_trait = deceitful
			}
			modifier = {
				factor = 0.5
				has_trait = paranoid
			}
			modifier = {
				factor = 0.5
				is_ruler = yes
				is_powerful_vassal = no
			}
			modifier = {
				factor = 0.1
				is_ruler = yes
				is_powerful_vassal = yes
			}
		}
	}
	option = {
		name = expwitch.1020.d #This should be good...
		trigger = {
			scope:court_chaplain = { is_witch_trigger = yes }
		}
		custom_tooltip = expwitch.I_remain_in_prison.tt
		show_as_tooltip = { botched_witch_trial_effect = yes }
	}
	
	after = {
		if = {
			limit = {
				scope:court_chaplain = { is_witch_trigger = yes }
			}
			scope:accuser = { trigger_event = expwitch.1021 }
		}
		else = {
			scope:accuser = { trigger_event = expwitch.1022 }
		}
	}
}

# Witch trial is a farce because the Court Chaplain is a witch
expwitch.1021 = {
	type = character_event
	title = expwitch.1021.t
	desc = expwitch.1021.desc
	theme = faith
	
	left_portrait = {
		character = scope:court_chaplain
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = no } }
			outfit_tags = { priest_outfit }
		}
		animation = personality_zealous
	}
	right_portrait = {
		character = scope:accused_witch
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = no } }
			outfit_tags = { beggar_rags }
		}
		animation = laugh
		override_imprisonment_visuals = yes
	}	

	immediate = {
		hidden_effect = {
			capital_county = {
				if = {
					limit = { has_county_modifier = had_witch_trial_modifier }
					change_county_control = -10
					remove_county_modifier = had_witch_trial_modifier
				}
			}
		}
	}

	option = {
		name = expwitch.1021.a
		add_piety = massive_piety_loss
		stress_and_fulfillment_impact = {
			base = major_stress_impact_gain
			just = minor_stress_impact_gain
			theologian = medium_stress_impact_gain
			zealous = major_stress_impact_gain
			cynical = medium_stress_impact_loss
			arbitrary = minor_stress_impact_loss
		}
		botched_witch_trial_effect = yes
	}
}

# Regular witch trial occurs
expwitch.1022 = {
	type = character_event
	title = expwitch.1022.t
	desc = {
		desc = expwitch.1022.start
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
				}
				desc = expwitch.1022.defiant
			}
			triggered_desc = {
				trigger = {
					scope:accused_witch = { has_character_flag = challenge_withcraft_surrender }
				}
				desc = expwitch.1022.surrender
			}
			desc = expwitch.1022.normal
		}
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = { has_character_flag = challenge_withcraft_surrender }
				}
				desc = expwitch.1022.surrender.end
			}
			desc = expwitch.1022.end
		}
	}
	theme = faith
	
	left_portrait = {
		character = scope:court_chaplain
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = no } }
			outfit_tags = { priest_outfit }
		}
		animation = anger
	}
	right_portrait = {
		character = scope:accused_witch
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = no } }
			outfit_tags = { beggar_rags }
		}
		triggered_animation = {
			trigger = {
				scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
			}
			animation = personality_callous
		}
		triggered_animation = {
			trigger = {
				scope:accused_witch = { has_character_flag = challenge_withcraft_surrender }
			}
			animation = beg
		}
		animation = scheme
		override_imprisonment_visuals = yes
	}

	option = {
		trigger = {
			scope:accused_witch = {
				NOT = { has_character_flag = challenge_withcraft_surrender }
			}
		}
		name = {
			trigger = {
				scope:accused_witch = { has_character_flag = challenge_withcraft_defiant }
			}
			text = expwitch.1022.a #This should be quick
		}
		name = {
			trigger = {
				scope:accused_witch = {
					NOT = { has_character_flag = challenge_withcraft_defiant }
				}
			}
			text = expwitch.1022.b #It's all on the Patriarch, now
		}
		scope:court_chaplain = {
			witch_trial_effect = yes
		}
	}
	option = {
		trigger = {
			scope:accused_witch = { has_character_flag = challenge_withcraft_surrender }
		}
		name = expwitch.1022.c #That was quick
		witch_trial_confession_effect = yes
	}
}

# Unimportant witch confesses to known witches in the liege's realm
expwitch.1023 = {
	type = character_event
	title = expwitch.1023.t
	desc = expwitch.1023.desc
	theme = faith
	
	left_portrait = {
		character = scope:court_chaplain
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = no } }
			outfit_tags = { priest_outfit }
		}
		animation = personality_zealous
	}
	right_portrait = {
		character = scope:accused_witch
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = no } }
			outfit_tags = { beggar_rags }
		}
		animation = shame
		override_imprisonment_visuals = yes
	}
	
	option = {
		name = expwitch.1023.a
		scope:accused_witch = {
			every_known_secret = {
				limit = {
					secret_type = secret_witch
					NOT = { is_known_by = root }
					secret_owner = { target_is_liege_or_above = root }
				}
				reveal_to = root
			}
		}
	}
	
	after = {
		challenge_cleanup_flags = yes
	}
}

# Accused witch has renounced witchcraft - liege now decides what becomes of them
expwitch.1024 = {
	type = character_event
	title = expwitch.1024.t
	desc = {
		first_valid = {
			triggered_desc = {
				trigger = {
					scope:accused_witch = {
						any_known_secret = {
							secret_type = secret_witch
							NOT = { is_known_by = scope:accuser }
							secret_owner = { target_is_liege_or_above = scope:accuser }
						}
					}
				}
				desc = expwitch.1024.secrets
			}
			desc = expwitch.1024.nosecrets
		}
		desc = expwitch.1024.desc
	}
	theme = faith

	left_portrait = {
		character = scope:court_chaplain
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:court_chaplain = { should_be_naked_trigger = no } }
			outfit_tags = { priest_outfit }
		}
		animation = personality_zealous
	}
	right_portrait = {
		character = scope:accused_witch
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = yes } }
			outfit_tags = { no_clothes }
		}
		triggered_outfit = {
			trigger = { scope:accused_witch = { should_be_naked_trigger = no } }
			outfit_tags = { beggar_rags }
		}
		animation = shame
		override_imprisonment_visuals = yes
	}
	
	option = {
		name = expwitch.1024.a #They are free to go
		stress_and_fulfillment_impact = {
			sadistic = minor_stress_impact_gain
			compassionate = minor_stress_impact_loss
			forgiving = medium_stress_impact_loss
			paranoid = minor_stress_impact_gain
			just = miniscule_stress_impact_loss
		}
		add_piety = medium_piety_gain
		scope:accused_witch = {
			if = {
				limit = {
					any_known_secret = {
						secret_type = secret_witch
						NOT = { is_known_by = scope:accuser }
						secret_owner = { target_is_liege_or_above = scope:accuser }
					}
				}
				every_known_secret = {
					limit = {
						secret_type = secret_witch
						NOT = { is_known_by = scope:accuser }
						secret_owner = { target_is_liege_or_above = scope:accuser }
					}
					reveal_to = scope:accuser
				}
			}
			release_from_prison = yes
			consume_all_criminal_reasons_effect = {
				LIEGE = scope:accuser
				CRIMINAL = scope:accused_witch
			}
			challenge_confession_effect = yes
			add_character_flag = had_witch_trial
			#chance of false confession
			hidden_effect = {
				random = {
					chance = 0
					modifier = {
						add = 20
						has_trait = vengeful
					}
					modifier = {
						add = 20
						has_trait = wrathful
					}
					modifier = {
						add = 20
						has_trait = deceitful
					}
					remove_character_flag = block_convert_to_witchcraft
					add_secret = { type = secret_witch }
				}
			}
		}
		ai_chance = {
			base = 70
			ai_value_modifier = {
				ai_compassion = 0.5
				ai_honor = 0.5
				min = -50
			}
			opinion_modifier = {
				who = scope:accuser
				opinion_target = scope:accused_witch
				multiplier = 0.5
				min = -20
			}
			modifier = {
				add = 20
				has_trait = forgiving
			}
			modifier = {
				factor = 0.1
				OR = {
					has_relation_rival = scope:accused_witch
					has_relation_nemesis = scope:accused_witch
				}
			}
			modifier = {
				factor = 0.1
				OR = {
					has_execute_reason = scope:accused_witch
					has_banish_reason = scope:accused_witch
					has_revoke_title_reason = scope:accused_witch
				}
			}
		}
	}
	option = {
		name = expwitch.1024.b #Back to prison!
		stress_and_fulfillment_impact = {
			sadistic = minor_stress_impact_loss
			compassionate = minor_stress_impact_gain
			forgiving = medium_stress_impact_gain
			paranoid = minor_stress_impact_loss
		}
		custom_tooltip = expwitch.remain_in_prison.tt
		scope:accused_witch = {
			if = {
				limit = {
					any_known_secret = {
						secret_type = secret_witch
						NOT = { is_known_by = scope:accuser }
						secret_owner = { target_is_liege_or_above = scope:accuser }
					}
				}
				every_known_secret = {
					limit = {
						secret_type = secret_witch
						NOT = { is_known_by = scope:accuser }
						secret_owner = { target_is_liege_or_above = scope:accuser }
					}
					reveal_to = scope:accuser
				}
			}
			challenge_confession_betrayed_effect = yes
			add_character_flag = had_witch_trial
			#chance of false confession
			hidden_effect = {
				random = {
					chance = 20
					modifier = {
						add = 20
						has_character_flag = challenge_withcraft_defiant
					}
					modifier = {
						add = -20
						has_character_flag = challenge_withcraft_surrender
					}
					modifier = {
						add = 20
						has_trait = vengeful
					}
					modifier = {
						add = 20
						has_trait = wrathful
					}
					modifier = {
						add = 20
						has_trait = deceitful
					}
					remove_character_flag = block_convert_to_witchcraft
					add_secret = { type = secret_witch }
				}
			}
		}
		ai_chance = {
			base = 30
			ai_value_modifier = {
				ai_vengefulness = 0.5
				min = -30
			}
			ai_value_modifier = {
				trigger = {
					scope:accused_witch = { gold >= 100 }
				}
				ai_greed = 0.5
				min = 0
			}
			modifier = {
				add = 20
				has_trait = zealous
			}
			modifier = {
				factor = 0.5
				scope:accused_witch = {
					exists = dynasty
					dynasty = scope:accuser.dynasty
				}
				NOR = {
					is_close_or_extended_family_of = scope:accused_witch
					has_relation_rival = scope:accused_witch
					has_relation_nemesis = scope:accused_witch
					has_execute_reason = scope:accused_witch
					has_banish_reason = scope:accused_witch
					has_revoke_title_reason = scope:accused_witch
				}
			}
			modifier = {
				factor = 0
				is_close_or_extended_family_of = scope:accused_witch
				NOR = {
					has_relation_rival = scope:accused_witch
					has_relation_nemesis = scope:accused_witch
				}
			}
			modifier = {
				factor = 0
				NOR = {
					has_relation_rival = scope:accused_witch
					has_relation_nemesis = scope:accused_witch
					has_execute_reason = scope:accused_witch
					has_banish_reason = scope:accused_witch
					has_revoke_title_reason = scope:accused_witch
					scope:accused_witch = {
						OR = {
							is_of_major_or_minor_interest_trigger = { CHARACTER = scope:accuser }
							gold >= 100
						}
					}
				}
			}
		}
	}
	
	after = {
		challenge_cleanup_flags = yes
	}
}
	
# Hidden event to add opinions to other witches in response to an execution (separated for performance)
expwitch.1025 = {
	hidden = yes
	immediate = {
		every_living_character = {
			limit = {
				OR = {
					target_is_liege_or_above = scope:accuser
					has_any_relation_trigger = { CHARACTER = scope:accused_witch }
				}
				NOT = { this = scope:accused_witch }
				has_trait = witch
			}
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:accuser }
				}
				set_relation_potential_rival = scope:accuser
			}
			add_opinion = {
				target = scope:accuser
				modifier = executed_fellow_witch
			}
			if = {
				limit = {
					can_set_relation_potential_rival_trigger = { CHARACTER = scope:court_chaplain }
				}
				set_relation_potential_rival = scope:court_chaplain
			}
			add_opinion = {
				target = scope:court_chaplain
				modifier = executed_fellow_witch
			}
		}
	}
}

