################################################
#
# Events for Muslim Honorary Titles Events
#
# ID 105000 - 105999 is reserved
#
# The basic events are triggered by on actions
#
#################################################
#
# Written by Sara Wendel-rtqvist

### CHIEF QADI ###

### Woman asks Chief Qadi for a divorce - Setup ###
character_event = {
	id = 104999

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim

	trigger = {
		has_assigned_minor_title = title_chief_qadi

		any_courtier_or_vassal = {
			is_female = yes
			is_incapable = no
			prisoner = no

			NOR = {
				has_character_modifier = qadi_divorce_timer
				has_character_flag = qadi_granted_divorce
			}

			spouse = {
				OR = {
					trait = wroth
					trait = cruel
					trait = arbitrary
					trait = greedy

					reverse_opinion = {
						who = ROOT
						value < 0
					}
				}

				NOT = { has_minor_title = title_chief_qadi }
			}
		}
	}

	immediate = {
		any_courtier_or_vassal = {
			limit = {
				is_female = yes
				is_incapable = no
				prisoner = no

				NOR = {
					has_character_modifier = qadi_divorce_timer
					has_character_flag = qadi_granted_divorce
				}

				spouse = {
					OR = {
						trait = wroth
						trait = cruel
						trait = arbitrary
						trait = greedy

						reverse_opinion = {
							who = ROOT
							value < 0
						}
					}

					NOT = { has_minor_title = title_chief_qadi }
				}
			}

			score_value = { # TODO: check that this works properly
				value = 100

				mult_modifier = {
					factor = 0.2
					trait = content
				}

				mult_modifier = {
					factor = 2
					trait = honest
				}

				mult_modifier = {
					factor = 0.5
					num_of_children >= 2
				}

				mult_modifier = {
					factor = 0.33
					num_of_children >= 4
				}

				mult_modifier = {
					factor = 0.25
					num_of_children >= 6
				}
			}

			character_event = { id = 105000 }
		}
	}
}

### Woman asks Chief Qadi for a divorce ###
character_event = {
	id = 105000
	desc = EVTDESC105000
	picture = GFX_evt_quarrel # Placeholder?
	border = GFX_event_normal_frame_religion
	portrait = spouse

	is_triggered_only = yes

	immediate = {
		add_character_modifier = {
			name = qadi_divorce_timer
			years = 3
			hidden = yes
		}
	}

	option = {
		name = EVTOPTA105000

		liege = {
			show_scope_change = no

			random_courtier_or_vassal = {
				show_scope_change = no

				limit = { has_minor_title = title_chief_qadi }

				character_event = {
					id = 105001
					days = 1
					random = 3
					tooltip = EVTTOOLTIP105001
				}
			}
		}

		ai_chance = { factor = 40 }
	}

	option = {
		name = EVTOPTB105000

		if = {
			limit = { trait = content }

			random = {
				chance = 20
				add_trait_depressed_effect = yes
			}
		}
		else = {
			remove_trait_silently_ambitious_effect = yes
			add_trait = content
		}

		ai_chance = { factor = 60 }
	}
}

# Court Qadi is asked by the woman to grant her a divorce
character_event = {
	id = 105001
	desc = EVTDESC105001
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105001 # Yes

		FROM = {
			show_scope_change = no

			character_event = {
				id = 105002
				days = 1
				random = 3
				tooltip = EVTTOOLTIP105002
			}

			spouse = {
				character_event = {
					id = 105005
					days = 1
					random = 3
				}
			}
		}

		ai_chance = {
			factor = 40

			mult_modifier = {
				factor = 4
				trait = just
			}
		}
	}

	option = {
		name = EVTOPTB105001 # No

		FROM = {
			show_scope_change = no

			character_event = {
				id = 105003
				days = 1
				random = 3
				tooltip = EVTTOOLTIP105003
			}
		}

		ai_chance = {
			factor = 60

			mult_modifier = {
				factor = 2
				trait = arbitrary
			}
		}
	}
}

# Woman is granted divorce
character_event = {
	id = 105002
	desc = EVTDESC105002
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA105002
			trigger = { is_pregnant = no }
		}
		name = {
			text = EVTOPTB105002 # Pregnant, must wait until child is born
			trigger = { is_pregnant = yes }
		}

		set_character_flag = qadi_granted_divorce

		add_character_modifier = {
			name = iddah_period
			duration = -1
		}

		hidden_effect = {
			remove_character_modifier = qadi_divorce_timer
		}

		if = {
			limit = { is_pregnant = no }

			character_event = {
				id = 105004
				days = 130 # 4 months and 10 days
			}
		}

		ai_chance = {
			factor = 20

			mult_modifier = {
				factor = 2
				trait = wroth
			}

			mult_modifier = {
				factor = 2
				trait = cruel
			}

			mult_modifier = {
				factor = 2
				trait = arbitrary
			}

			mult_modifier = {
				factor = 2
				trait = greedy
			}

			mult_modifier = {
				factor = 2

				opinion = {
					who = spouse
					value < 0
				}
			}
		}
	}

	option = {
		name = EVTOPTC105002 # I have changed my mind

		spouse = {
			show_scope_change = no

			set_character_flag = reconsidered_divorce

			opinion = {
				name = opinion_glad
				who = ROOT
				years = 5
			}

			character_event = {
				id = 105007
				days = 1
				random = 2
				tooltip = EVTTOOLTIPB105007
			}
		}

		ai_chance = { factor = 60 }
	}
}

# Woman won't get the Chief Qadi's approval
character_event = {
	id = 105003
	desc = EVTDESC105003
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105003

		opinion = {
			name = opinion_very_disappointed
			who = FROM
			years = 5
		}

		add_trait_silently_depressed_effect = yes
	}
}

# Woman gets divorced
character_event = {
	id = 105004
	desc = EVTDESC105004
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	has_character_flag = qadi_granted_divorce

	trigger = {
		is_pregnant = no
		has_character_modifier = iddah_period
	}

	option = {
		name = EVTOPTA105004

		remove_character_modifier = iddah_period
		clr_character_flag = qadi_granted_divorce
		remove_spouse = spouse
	}

	option = {
		name = EVTOPTB105004

		remove_character_modifier = iddah_period
		clr_character_flag = qadi_granted_divorce

		spouse = {
			show_scope_change = no

			set_character_flag = reconsidered_divorce

			opinion = {
				name = opinion_glad
				who = ROOT
				years = 5
			}

			character_event = {
				id = 105007
				days = 1
				random = 2
				tooltip = EVTTOOLTIPB105007
			}
		}
	}
}

# Spouse finds out about divorce
character_event = {
	id = 105005
	desc = EVTDESC105005
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105005 # if that's what she wants...

		prestige = -10
	}

	option = {
		name = EVTOPTB105005 # NO! I won't allow it!

		spouse = {
			show_scope_change = no

			character_event = {
				id = 105006
				days = 1
				random = 3
				tooltip = EVTTOOLTIP105006
			}
		}
	}
}

# Woman is asked by spouse to reconsider
character_event = {
	id = 105006
	desc = EVTDESC105006
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105006 # I want that divorce!

		FROM = {
			show_scope_change = no

			set_character_flag = wants_divorce

			character_event = {
				id = 105007
				days = 1
				random = 3
				tooltip = EVTTOOLTIPA105007
			}
		}
	}

	option = {
		name = EVTOPTB105006 # Okay

		remove_character_modifier = iddah_period
		clr_character_flag = qadi_granted_divorce

		FROM = {
			show_scope_change = no

			set_character_flag = reconsidered_divorce

			opinion = {
				name = opinion_glad
				who = ROOT
				years = 5
			}

			character_event = {
				id = 105007
				days = 1
				random = 3
				tooltip = EVTTOOLTIPB105007
			}
		}
	}
}

# Spouse: Woman's answer
character_event = {
	id = 105007
	desc = EVTDESC105007
	picture = GFX_evt_quarrel
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105007

		trigger = { has_character_flag = wants_divorce }

		clr_character_flag = wants_divorce

		opinion = {
			name = opinion_angry
			who = FROM
			years = 2
		}
	}

	option = {
		name = EVTOPTB105007

		trigger = { has_character_flag = reconsidered_divorce }

		clr_character_flag = reconsidered_divorce

		tooltip = {
			opinion = {
				name = opinion_glad
				who = FROM
				years = 5
			}
		}
	}
}

# Check for muslim mother's divorce on birth
character_event = {
	id = 105008

	is_triggered_only = yes # on_birth
	hide_window = yes

	trigger = {
		mother = { has_character_flag = qadi_granted_divorce }
	}

	immediate = {
		mother = {
			character_event = {
				id = 105004
				days = 2
			}
		}
	}
}

### Suggest a Chief Qadi - Setup ###
character_event = {
	id = 105009

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		can_grant_title = title_chief_qadi

		any_courtier_or_vassal = {
			can_hold_title = title_chief_qadi
			NOT = { is_rival = ROOT }
		}

		any_courtier_or_vassal = {
			OR = {
				is_voter = yes
				is_ruler = yes
			}

			religion_group = muslim
			block_general_event_trigger = no
			war = no
			in_command_trigger = no

			NOR = {
				has_character_flag = qadi_suggester
				has_character_flag = new_qadi_suggester
			}
		}
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = {
				OR = {
					is_voter = yes
					is_ruler = yes
				}

				religion_group = muslim
				block_general_event_trigger = no
				war = no
				in_command_trigger = no

				NOR = {
					has_character_flag = qadi_suggester
					has_character_flag = new_qadi_suggester
				}

				trigger_if = {
					limit = {
						NOT = { can_hold_title = title_chief_qadi }
					}

					ROOT = {
						any_courtier_or_vassal = {
							can_hold_title = title_chief_qadi
							NOT = { is_rival = PREVPREV }
						}
					}
				}
			}

			preferred_limit = {
				OR = {
					trait = diligent
					trait = ambitious
				}
			}

			preferred_limit = {
				NOR = {
					trait = slothful
					trait = content
				}
			}

			set_character_flag = qadi_suggester
			character_event = { id = 105010 }
		}
	}
}

### Suggest a Chief Qadi ###
character_event = {
	id = 105010
	desc = EVTDESC105010
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105010 # Suggest a courtier

		trigger = {
			liege = {
				any_courtier = {
					can_hold_title = title_chief_qadi
					is_ruler = no
					NOT = { is_rival = ROOT }
				}
			}
		}

		liege = {
			random_courtier = {
				limit = {
					can_hold_title = title_chief_qadi
					is_ruler = no
					NOT = { is_rival = ROOT }
				}

				save_event_target_as = target_suggested_qadi
			}

			set_character_flag = suggested_qadi_courtier

			character_event = {
				id = 105011
				days = 2
				random = 4
				tooltip = EVTTOOLTIP105011
			}
		}
	}

	option = {
		name = EVTOPTB105010 # Suggest yourself

		trigger = { can_hold_title = title_chief_qadi }

		save_event_target_as = target_suggested_qadi

		liege = {
			show_scope_change = no

			set_character_flag = suggested_qadi_from

			character_event = {
				id = 105011
				days = 2
				random = 4
				tooltip = EVTTOOLTIP105011
			}
		}
	}

	option = {
		name = EVTOPTC105010 # Suggest a vassal

		trigger = {
			liege = {
				any_vassal = {
					can_hold_title = title_chief_qadi
					NOT = { is_rival = ROOT }
				}
			}
		}

		liege = {
			random_vassal = {
				limit = {
					can_hold_title = title_chief_qadi
					NOT = { is_rival = ROOT }
				}

				save_event_target_as = target_suggested_qadi
			}

			set_character_flag = suggested_qadi_vassal

			character_event = {
				id = 105011
				days = 2
				random = 4
				tooltip = EVTTOOLTIP105011
			}
		}
	}

	option = {
		name = EVTOPTD105010 # Do nothing
	}
}

# Liege listens to suggestions
character_event = {
	id = 105011
	desc = EVTDESC105011
	picture = GFX_evt_emissary # Placeholder?
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTE105011 # OK

		event_target:target_suggested_qadi = {
			show_scope_change = no

			give_minor_title = title_chief_qadi

			if = {
				limit = { character = FROM }

				opinion = {
					name = opinion_grateful
					who = ROOT
					years = 5
				}

				character_event = {
					id = 105014
					days = 3
					random = 3
					tooltip = EVTTOOLTIPA105014
				}
			}
			else = {
				character_event = {
					id = 105012
					days = 3
					random = 3
					tooltip = EVTTOOLTIP105012
				}
			}
		}

		ai_chance = { factor = 40 }
	}

	option = {
		name = EVTOPTF105011 # No

		FROM = {
			if = {
				limit = { character = event_target:target_suggested_qadi }

				opinion = {
					name = opinion_disappointed
					who = ROOT
					years = 5
				}

				character_event = {
					id = 105014
					days = 3
					random = 3
					tooltip = EVTTOOLTIPB105014
				}
			}
			else = {
				character_event = {
					id = 105013
					days = 3
					random = 3
					tooltip = EVTTOOLTIPA105013
				}
			}
		}

		ai_chance = { factor = 60 }
	}
}

# Vassal/Courtier gets title thanks to ROOT
character_event = {
	id = 105012
	desc = EVTDESC105012
	picture = GFX_evt_emissary # Placeholder?
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	show_from_from = yes

	option = {
		name = EVTOPTA105012

		tooltip = {
			give_minor_title = title_chief_qadi
		}

		opinion = {
			name = opinion_grateful
			who = FROMFROM
			years = 5
		}

		FROMFROM = {
			show_scope_change = no

			character_event = {
				id = 105013
				days = 3
				random = 3
				tooltip = EVTTOOLTIPB105013
			}
		}
	}
}

# ROOT is thanked/dismissed
character_event = {
	id = 105013
	desc = EVTDESC105013
	picture = GFX_evt_emissary # Placeholder?
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	show_from_from = yes

	option = {
		name = EVTOPTA105013

		trigger = {
			event_target:target_suggested_qadi = {
				has_minor_title = title_chief_qadi
			}
		}

		prestige = 15

		tooltip = {
			reverse_opinion = {
				name = opinion_grateful
				who = event_target:target_suggested_qadi
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105013

		trigger = {
			event_target:target_suggested_qadi = {
				NOT = { has_minor_title = title_chief_qadi }
			}
		}

		prestige = -5
	}
}

# ROOT gains title/is dismissed
character_event = {
	id = 105014
	desc = EVTDESC105014
	picture = GFX_evt_emissary # Placeholder?
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105014

		trigger = { has_minor_title = title_chief_qadi }

		tooltip = {
			give_minor_title = title_chief_qadi
		}

		prestige = 20

		tooltip = {
			opinion = {
				name = opinion_grateful
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105014

		trigger = {
			NOT = { has_minor_title = title_chief_qadi }
		}

		prestige = -5

		tooltip = {
			opinion = {
				name = opinion_disappointed
				who = FROM
				years = 5
			}
		}
	}
}

### Suggest a new Chief Qadi - Setup ###
character_event = {
	id = 105019

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		any_vassal = {
			has_minor_title = title_chief_qadi
			learning < 15

			trigger_if = {
				limit = { trait = just }

				OR = {
					trait = slothful
					trait = content
				}
			}
		}

		any_courtier_or_vassal = {
			can_hold_title = title_chief_qadi
			learning >= 15
			trait = just

			NOR = {
				trait = slothful
				trait = content
			}
		}

		NOT = { has_law = council_privileges_1 }
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = { has_minor_title = title_chief_qadi }
			save_event_target_as = old_qadi
		}

		random_courtier_or_vassal = {
			limit = {
				religion_group = muslim
				block_general_event_trigger = no
				war = no
				in_command_trigger = no
				NOT = { has_minor_title = title_chief_qadi }

				trigger_if = {
					limit = {
						NOT = { can_hold_title = title_chief_qadi }
					}

					ROOT = {
						any_courtier_or_vassal = {
							can_hold_title = title_chief_qadi
							learning >= 15
							trait = just

							NOR = {
								trait = slothful
								trait = content
								is_rival = PREVPREV
							}
						}
					}
				}
			}

			preferred_limit = {
				OR = {
					trait = diligent
					trait = ambitious
				}
			}

			preferred_limit = {
				NOR = {
					trait = content
					trait = slothful
				}
			}

			set_character_flag = new_qadi_suggester
			character_event = { id = 105020 }
		}
	}
}

### Suggest a new Chief Qadi ###
character_event = {
	id = 105020
	desc = EVTDESC105020
	picture = GFX_evt_emissary # Placeholder!
	border = GFX_event_normal_frame_religion
	portrait = event_target:old_qadi

	is_triggered_only = yes

	option = {
		name = EVTOPTA105020 # Suggest a courtier

		trigger = {
			liege = {
				any_courtier = {
					can_hold_title = title_chief_qadi
					learning >= 15
					trait = just
					is_ruler = no

					NOR = {
						trait = slothful
						trait = content
						is_rival = ROOT
					}
				}
			}
		}

		liege = {
			show_scope_change = no

			random_courtier = {
				limit = {
					can_hold_title = title_chief_qadi
					learning >= 15
					trait = just
					is_ruler = no

					NOR = {
						trait = slothful
						trait = content
						is_rival = ROOT
					}
				}

				save_event_target_as = target_suggested_qadi
			}

			character_event = {
				id = 105021
				days = 2
				random = 4
				tooltip = EVTTOOLTIP105021
			}
		}
	}

	option = {
		name = EVTOPTB105020 # Suggest yourself

		trigger = { can_hold_title = title_chief_qadi }

		save_event_target_as = target_suggested_qadi

		liege = {
			show_scope_change = no

			character_event = {
				id = 105021
				days = 2
				random = 4
				tooltip = EVTTOOLTIP105021
			}
		}
	}

	option = {
		name = EVTOPTC105020 # Suggest a vassal

		trigger = {
			liege = {
				any_vassal = {
					can_hold_title = title_chief_qadi
					learning >= 15
					trait = just

					NOR = {
						trait = slothful
						trait = content
						is_rival = ROOT
					}
				}
			}
		}

		liege = {
			show_scope_change = no

			random_vassal = {
				limit = {
					can_hold_title = title_chief_qadi
					learning >= 15
					trait = just

					NOR = {
						trait = slothful
						trait = content
						is_rival = ROOT
					}
				}

				save_event_target_as = target_suggested_qadi
			}

			character_event = {
				id = 105021
				days = 2
				random = 4
				tooltip = EVTTOOLTIP105021
			}
		}
	}

	option = {
		name = EVTOPTD105020 # Do nothing
	}
}

# Liege listens to suggestions
character_event = {
	id = 105021
	desc = EVTDESC105021
	picture = GFX_evt_emissary # Placeholder?
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTC105021 # OK

		event_target:old_qadi = {
			show_scope_change = no

			remove_title = title_chief_qadi

			if = {
				limit = {
					has_opinion_modifier = {
						name = opinion_chief_qadi
						who = ROOT
					}
				}

				remove_opinion = {
					name = opinion_chief_qadi
					who = ROOT
				}
			}

			character_event = {
				id = 105025
				days = 1
				tooltip = EVTTOOLTIP105025
			}
		}

		event_target:target_suggested_qadi = {
			show_scope_change = no

			give_minor_title = title_chief_qadi

			if = {
				limit = { character = FROM }

				opinion = {
					name = opinion_grateful
					who = ROOT
					years = 5
				}

				character_event = {
					id = 105024
					days = 3
					random = 3
					tooltip = EVTTOOLTIPA105014
				}
			}
			else = {
				character_event = {
					id = 105022
					days = 3
					random = 3
					tooltip = EVTTOOLTIP105022
				}
			}
		}

		ai_chance = { factor = 40 }
	}

	option = {
		name = EVTOPTB105021 # No

		FROM = {
			if = {
				limit = { character = event_target:target_suggested_qadi }

				opinion = {
					name = opinion_disappointed
					who = ROOT
					years = 5
				}

				character_event = {
					id = 105024
					days = 3
					random = 3
					tooltip = EVTTOOLTIPB105014
				}
			}
			else = {
				character_event = {
					id = 105023
					days = 3
					random = 3
					tooltip = EVTTOOLTIPA105013
				}
			}
		}

		ai_chance = { factor = 60 }
	}
}

# Vassal/Courtier gets title thanks to ROOT
character_event = {
	id = 105022
	desc = EVTDESC105012
	picture = GFX_evt_emissary # Placeholder?
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	show_from_from = yes

	option = {
		name = EVTOPTA105012

		tooltip = {
			give_minor_title = title_chief_qadi
		}

		FROMFROM = {
			show_scope_change = no

			reverse_opinion = {
				name = opinion_grateful
				who = ROOT
				years = 5
			}

			character_event = {
				id = 105023
				days = 3
				random = 3
				tooltip = EVTTOOLTIPB105013
			}
		}
	}
}

# ROOT is thanked/dismissed
character_event = {
	id = 105023
	desc = EVTDESC105023
	picture = GFX_evt_emissary # Placeholder?
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	show_from_from = yes

	option = {
		name = EVTOPTA105023

		trigger = {
			event_target:target_suggested_qadi = {
				has_minor_title = title_chief_qadi
			}
		}

		prestige = 15

		tooltip = {
			reverse_opinion = {
				name = opinion_grateful
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105023

		trigger = {
			event_target:target_suggested_qadi = {
				NOT = { has_minor_title = title_chief_qadi }
			}
		}

		prestige = -5
	}
}

# ROOT gains title/is dismissed
character_event = {
	id = 105024
	desc = EVTDESC105024
	picture = GFX_evt_emissary # Placeholder?
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105014

		trigger = {
			has_minor_title = title_chief_qadi
		}

		tooltip = {
			give_minor_title = title_chief_qadi
		}

		prestige = 20

		tooltip = {
			opinion = {
				name = opinion_grateful
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105014

		trigger = {
			NOT = { has_minor_title = title_chief_qadi }
		}

		prestige = -5

		tooltip = {
			opinion = {
				name = opinion_disappointed
				who = FROM
				years = 5
			}
		}
	}
}

# Former Chief Qadi is fired
character_event = {
	id = 105025
	desc = EVTDESC105025
	picture = GFX_evt_emissary # Placeholder?
	border = GFX_event_normal_frame_religion

	show_from_from = yes
	is_triggered_only = yes

	option = {
		name = EVTOPTA105025

		tooltip = {
			remove_title = title_chief_qadi
		}

		prestige = -10

		opinion = {
			name = opinion_angry
			who = FROMFROM
			years = 5
		}
	}
}

### Chief Qadi and the drunkard - Setup ###
character_event = {
	id = 105029

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim

	trigger = {
		any_courtier_or_vassal = {
			has_minor_title = title_chief_qadi
			block_general_event_trigger = no
			war = no
			in_command_trigger = no

			ROOT = {
				any_realm_character = {
					trait = drunkard
					religion_group = muslim
					block_general_event_trigger = no
					war = no
					in_command_trigger = no
					NOT = { character = PREVPREV }
				}
			}
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 0.2

			any_courtier_or_vassal = {
				has_minor_title = title_chief_qadi
				trait = drunkard
			}
		}

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_chief_qadi
				trait = zealous
			}
		}
	}

	immediate = {

		random_courtier_or_vassal = {
			limit = { has_minor_title = title_chief_qadi }

			ROOT = {
				random_realm_character = {
					limit = {
						trait = drunkard
						religion_group = muslim
						block_general_event_trigger = no
						war = no
						in_command_trigger = no
						NOT = { character = PREVPREV }
					}

					save_event_target_as = target_drunkard
				}
			}

			character_event = { id = 105030 }
		}
	}
}

### Chief Qadi and the drunkard ###
character_event = {
	id = 105030
	desc = EVTDESC105030
	picture = GFX_evt_drunk
	border = GFX_event_normal_frame_religion
	portrait = event_target:target_drunkard

	is_triggered_only = yes

	option = {
		name = EVTOPTA105030

		event_target:target_drunkard = {
			show_scope_change = no

			random = {
				chance = 5
				remove_trait = drunkard
			}

			random = {
				chance = 30
				add_trait_wounded_effect = yes
			}

			character_event = {
				id = 105031
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105031
			}
		}

		ai_chance = {
			factor = 25

			mult_modifier = {
				factor = 0.5
				trait = kind
			}

			mult_modifier = {
				factor = 0.5
				trait = arbitrary
			}

			mult_modifier = {
				factor = 2
				trait = wroth
			}

			mult_modifier = {
				factor = 2
				trait = cruel
			}

			mult_modifier = {
				factor = 2
				trait = impaler
			}

			mult_modifier = {
				factor = 1.2
				trait = just
			}
		}
	}

	option = {
		name = EVTOPTB105030

		event_target:target_drunkard = {
			show_scope_change = no

			opinion = {
				name = opinion_merciful_qadi
				who = ROOT
				years = 5
			}

			random = {
				chance = 25
				remove_trait = drunkard
			}

			character_event = {
				id = 105032
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105032
			}
		}

		liege = {
			show_scope_change = no

			any_realm_character = {
				limit = {
					trait = zealous
					religion_group = muslim
					piety >= 100
					NOT = { trait = drunkard }
				}

				opinion = {
					name = opinion_arbitrary_qadi
					who = ROOT
					years = 2
				}
			}
		}

		ai_chance = {
			factor = 25

			mult_modifier = {
				factor = 2
				trait = kind
			}

			mult_modifier = {
				factor = 2
				trait = arbitrary
			}

			mult_modifier = {
				factor = 0.5
				trait = wroth
			}

			mult_modifier = {
				factor = 0.5
				trait = cruel
			}

			mult_modifier = {
				factor = 0.5
				trait = impaler
			}
		}
	}

	option = {
		name = EVTOPTC105030

		piety = -10

		ai_chance = { factor = 50 }
	}
}

# Drunkard is flogged eighty lashes
character_event = {
	id = 105031
	desc = EVTDESC105031
	picture = GFX_evt_torture
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105031

		trigger = {
			trait = wounded
			trait = drunkard
		}

		prestige = -5

		tooltip = {
			add_trait = wounded
		}
	}

	option = {
		name = EVTOPTB105031

		trigger = {
			trait = wounded
			NOT = { trait = drunkard }
		}

		prestige = -5

		tooltip = {
			add_trait = wounded
			remove_trait = drunkard
		}
	}

	option = {
		name = EVTOPTC105031

		trigger = {
			NOT = { trait = wounded }
			trait = drunkard
		}

		prestige = -5
	}

	option = {
		name = EVTOPTD105031

		trigger = {
			NOR = {
				trait = wounded
				trait = drunkard
			}
		}

		prestige = -5

		tooltip = {
			remove_trait = drunkard
		}
	}
}

# Drunkard is pardoned
character_event = {
	id = 105032
	desc = EVTDESC105032
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105032

		trigger = { trait = drunkard }

		scaled_wealth = -0.025

		tooltip = {
			opinion = {
				name = opinion_merciful_qadi
				who = ROOT
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105032

		trigger = {
			NOT = { trait = drunkard }
		}

		scaled_wealth = -0.025

		tooltip = {
			remove_trait = drunkard

			opinion = {
				name = opinion_merciful_qadi
				who = ROOT
				years = 5
			}
		}
	}
}

### Chief Qadi and Zina - Setup ###
character_event = {
	id = 105034

	is_triggered_only = yes # on_yearly_pulse
	hide_window = yes

	only_rulers = yes
	religion_group = muslim
	only_men = yes
	is_married = yes
	min_age = 16
	only_capable = yes
	prisoner = no

	trigger = {
		has_lover = yes
		is_inaccessible_trigger = no

		any_lover = {
			NOT = { is_married = ROOT }
		}

		spouse = {
			religion_group = muslim
		}

		trigger_if = {
			limit = { trait = zealous }

			OR = {
				trait = lustful
				trait = deceitful
			}
		}

		NOR = {
			has_minor_title = title_chief_qadi
			trait = homosexual
		}

		liege = {
			any_courtier_or_vassal = {
				has_minor_title = title_chief_qadi
				block_general_event_trigger = no
			}
		}
	}

	immediate = {
		save_event_target_as = unfaithful_vassal

		liege = {
			random_courtier_or_vassal = {
				limit = { has_minor_title = title_chief_qadi }
				save_event_target_as = chief_qadi
			}

			random_courtier_or_vassal = { # On the off chance that this fails to find anyone, oh well
				limit = {
					religion_group = muslim
					has_lover = no
					block_general_event_trigger = no

					NOR = {
						has_character_modifier = ignored_muslim_sins
						has_minor_title = title_chief_qadi
					}
				}

				preferred_limit = {
					OR = {
						trait = just
						trait = zealous
					}
				}

				preferred_limit = {
					NOT = { trait = deceitful }
				}

				character_event = { id = 105035 }
			}
		}
	}
}

### Chief Qadi and Zina ###
character_event = {
	id = 105035
	desc = EVTDESC105035
	picture = GFX_evt_lovers
	border = GFX_event_normal_frame_religion
	portrait = event_target:unfaithful_vassal

	is_triggered_only = yes

	option = {
		name = EVTOPTA105035

		show_portrait = event_target:unfaithful_vassal

		event_target:chief_qadi = {
			show_scope_change = no

			character_event = {
				id = 105036
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105036
			}
		}
	}

	option = {
		name = EVTOPTB105035

		event_target:unfaithful_vassal = {
			show_scope_change = no

			character_event = {
				id = 105037
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105037
			}
		}
	}

	option = {
		name = EVTOPTC105035

		add_character_modifier = {
			name = ignored_muslim_sins
			years = 1
		}
	}
}

# ROOT told Chief Qadi
character_event = {
	id = 105036
	desc = EVTDESC105036
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105036 # Confront

		event_target:unfaithful_vassal = {
			show_scope_change = no

			character_event = {
				id = 105038
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105038
			}
		}

		hidden_effect = {
			FROM = {
				set_character_flag = qadi_confront

				character_event = {
					id = 105039
					days = 2
					random = 2
				}
			}
		}
	}

	option = {
		name = EVTOPTB105036 # Ask ROOT to take care of it himself

		trigger = {
			NOT = { has_character_flag = asked_qadi_zina }
		}

		FROM = {
			show_scope_change = no

			set_character_flag = permission_zina

			opinion = {
				name = opinion_disappointed
				who = ROOT
				years = 2
			}

			character_event = {
				id = 105039
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105039
			}
		}
	}

	option = {
		name = EVTOPTC105036 # Ignore the subject

		FROM = {
			show_scope_change = no

			set_character_flag = qadi_ignored

			opinion = {
				name = opinion_very_disappointed
				who = ROOT
				years = 2
			}

			character_event = {
				id = 105039
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105039
			}
		}
	}
}

# ROOT told suspect
character_event = {
	id = 105037
	desc = EVTDESC105037
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105037 # Try to bribe ROOT to keep quiet

		tooltip = {
			transfer_scaled_wealth = {
				to = FROM
				value = 0.25
			}
		}

		FROM = {
			show_scope_change = no

			set_character_flag = money_silenced

			character_event = {
				id = 105040
				days = 2
				random = 2
				tooltip = EVTTOOLTIPA105040
			}
		}

		ai_chance = {
			factor = 10

			mult_modifier = {
				factor = 0.01
				NOT = { scaled_wealth = 0.5 }
			}

			mult_modifier = {
				factor = 5
				scaled_wealth = 2
			}
		}
	}

	option = {
		name = EVTOPTB105037 # Promise to break it up with lover

		hidden_effect = {
			random_lover = {
				limit = {
					NOT = { is_married = ROOT }
				}

				save_event_target_as = target_lover
			}
		}

		if = {
			limit = { has_dlc = "Way of Life" }

			character_event = {
				id = WoL.1102
				tooltip = EVTTOOLTIP64045
			}
		}
		else = {
			character_event = {
				id = 64045
				tooltip = EVTTOOLTIP64045
			}
		}

		FROM = {
			show_scope_change = no

			set_character_flag = lover_silenced

			character_event = {
				id = 105040
				days = 2
				random = 2
				tooltip = EVTTOOLTIPB105040
			}
		}

		ai_chance = {
			factor = 10

			mult_modifier = {
				factor = 0.01
				NOT = { scaled_wealth = 0.5 }
			}

			mult_modifier = {
				factor = 5
				scaled_wealth = 2
			}

			mult_modifier = {
				factor = 5
				trait = zealous
			}

			mult_modifier = {
				factor = 0.5
				trait = lustful
			}
		}
	}

	option = {
		name = EVTOPTC105037 # Refuse to do anything about it

		FROM = {
			show_scope_change = no

			set_character_flag = ignored_threat

			character_event = {
				id = 105040
				days = 2
				random = 2
				tooltip = EVTTOOLTIPC105040
			}
		}
	}
}

# Chief Qadi confronts zina
character_event = {
	id = 105038
	desc = EVTDESC105038
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105038 # Deny

		FROM = {
			show_scope_change = no

			random_list = {
				50 = {
					set_character_flag = convinced_innocence

					character_event = {
						id = 105041
						days = 2
						random = 2
						tooltip = EVTTOOLTIPA105041
					}
				}

				50 = {
					set_character_flag = not_convinced_innocence

					character_event = {
						id = 105041
						days = 2
						random = 2
						tooltip = EVTTOOLTIPB105041
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTB105038 # Promise to break it up with lover

		random = {
			chance = 20

			set_character_flag = no_lover_no_cry

			hidden_effect = {
				random_lover = {
					limit = {
						NOT = { is_married = PREV }
					}

					save_event_target_as = target_lover
				}
			}

			if = {
				limit = { has_dlc = "Way of Life" }

				character_event = {
					id = WoL.1102
					tooltip = EVTTOOLTIP64045
				}
			}
			else = {
				character_event = {
					id = 64045
					tooltip = EVTTOOLTIP64045
				}
			}
		}

		FROM = {
			show_scope_change = no

			character_event = {
				id = 105042
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105042
			}
		}
	}

	option = {
		name = EVTOPTC105038 # Don't deny it

		FROM = {
			show_scope_change = no

			character_event = {
				id = 105043
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105043
			}
		}
	}
}

# ROOT: Chief Qadi confront/ignores/other
character_event = {
	id = 105039
	desc = EVTDESC105039
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105039

		trigger = { has_character_flag = qadi_ignored }

		clr_character_flag = qadi_ignored

		tooltip = {
			opinion = {
				name = opinion_very_disappointed
				who = FROM
				years = 2
			}
		}
	}

	option = {
		name = EVTOPTB105039

		trigger = { has_character_flag = permission_zina }

		clr_character_flag = permission_zina

		tooltip = {
			opinion = {
				name = opinion_disappointed
				who = FROM
				years = 2
			}
		}

		event_target:unfaithful_vassal = {
			show_scope_change = no

			character_event = {
				id = 105037
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105037
			}
		}
	}

	option = {
		name = EVTOPTC105039

		trigger = { has_character_flag = qadi_confront }

		clr_character_flag = qadi_confront
		piety = 10

		reverse_opinion = {
			name = opinion_good_work
			who = FROM
			years = 5
		}
	}
}

# ROOT: accused offered money/promised to break up with lover/refused to do anything
character_event = {
	id = 105040
	desc = EVTDESC105040
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOTPA105040

		trigger = { has_character_flag = money_silenced }

		clr_character_flag = money_silenced

		transfer_scaled_wealth = {
			from = FROM
			value = 0.25
		}
	}

	option = {
		name = EVTOTPB105040 # Tell Chief Qadi

		trigger = { has_character_flag = ignored_threat }

		clr_character_flag = ignored_threat

		event_target:chief_qadi = {
			show_scope_change = no

			set_character_flag = asked_qadi_zina

			character_event = {
				id = 105036
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105036
			}
		}
	}

	option = {
		name = EVTOTPC105040 # Tell Chief Qadi

		trigger = { has_character_flag = ignored_threat }

		clr_character_flag = ignored_threat

		event_target:chief_qadi = {
			show_scope_change = no

			set_character_flag = asked_qadi_zina

			character_event = {
				id = 105036
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105036
			}
		}
	}

	option = {
		name = EVTOTPD105040 # Stop caring

		trigger = { has_character_flag = ignored_threat }

		clr_character_flag = ignored_threat
		piety = -5
	}

	option = {
		name = EVTOTPE105040 # Tell Chief Qadi

		trigger = { has_character_flag = lover_silenced }

		clr_character_flag = lover_silenced

		event_target:chief_qadi = {
			show_scope_change = no

			character_event = {
				id = 105036
				days = 2
				random = 2
				tooltip = EVTTOOLTIP105036
			}
		}
	}

	option = {
		name = EVTOTPF105040 # Stop caring

		trigger = { has_character_flag = lover_silenced }

		clr_character_flag = lover_silenced
		piety = -5
	}
}

# Chief Qadi: suspect declared innocence
character_event = {
	id = 105041
	desc = EVTDESC105041
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes
	show_from_from = yes

	option = {
		name = EVTOPTA105041

		trigger = { has_character_flag = convinced_innocence }

		clr_character_flag = convinced_innocence

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_merciful_qadi
				who = ROOT
				years = 5
			}

			set_character_flag = qadi_merciful

			character_event = {
				id = 105044
				days = 1
				tooltip = EVTTOOLTIPA105044
			}
		}
	}

	option = {
		name = EVTOPTB105041

		trigger = { has_character_flag = not_convinced_innocence }

		clr_character_flag = not_convinced_innocence

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_merciful_qadi
				who = ROOT
				years = 5
			}

			set_character_flag = qadi_merciful

			character_event = {
				id = 105044
				days = 1
				tooltip = EVTTOOLTIPB105044
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.05
				trait = wroth
			}

			mult_modifier = {
				factor = 0.05
				trait = cruel
			}

			mult_modifier = {
				factor = 0.05
				trait = arbitrary
			}

			mult_modifier = {
				factor = 2
				trait = just
			}

			mult_modifier = {
				factor = 2
				trait = kind
			}

			mult_modifier = {
				factor = 2
				trait = trusting
			}
		}
	}

	option = {
		name = EVTOPTC105041

		trigger = { has_character_flag = not_convinced_innocence }

		clr_character_flag = not_convinced_innocence

		FROM = {
			show_scope_change = no

			random = {
				chance = 30
				add_trait_wounded_effect = yes
			}

			character_event = {
				id = 105044
				days = 1
				tooltip = EVTTOOLTIPC105044
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 2
				trait = wroth
			}

			mult_modifier = {
				factor = 2
				trait = cruel
			}

			mult_modifier = {
				factor = 2
				trait = arbitrary
			}

			mult_modifier = {
				factor = 0.05
				trait = just
			}

			mult_modifier = {
				factor = 0.05
				trait = kind
			}

			mult_modifier = {
				factor = 0.05
				trait = trusting
			}
		}
	}
}

# Chief Qadi: accused promised to break it up with lover
character_event = {
	id = 105042
	desc = EVTDESC105042
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105042

		trigger = {
			FROM = {
				NOT = { has_character_flag = no_lover_no_cry }
			}
		}

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_merciful_qadi
				who = ROOT
				years = 5
			}

			set_character_flag = qadi_merciful

			character_event = {
				id = 105044
				days = 1
				tooltip = EVTTOOLTIPB105044
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.05
				trait = wroth
			}

			mult_modifier = {
				factor = 0.05
				trait = cruel
			}

			mult_modifier = {
				factor = 0.05
				trait = arbitrary
			}

			mult_modifier = {
				factor = 2
				trait = just
			}

			mult_modifier = {
				factor = 2
				trait = kind
			}

			mult_modifier = {
				factor = 2
				trait = trusting
			}
		}
	}

	option = {
		name = EVTOPTB105042

		trigger = {
			FROM = {
				NOT = { has_character_flag = no_lover_no_cry }
			}
		}

		FROM = {
			show_scope_change = no

			random = {
				chance = 30
				add_trait_wounded_effect = yes
			}

			set_character_flag = zina_suspected
			save_event_target_as = target_lover

			character_event = {
				id = 105044
				days = 1
				tooltip = EVTTOOLTIPC105044
			}

			random_lover = {
				show_scope_change = no

				limit = {
					NOT = { is_married = PREV }
				}

				random = {
					chance = 30
					add_trait_wounded_effect = yes
				}

				if = {
					limit = { has_dlc = "Way of Life" }

					character_event = {
						id = WoL.1102
						days = 1
						tooltip = EVTTOOLTIP64045
					}
				}
				else = {
					character_event = {
						id = 64045
						days = 1
						tooltip = EVTTOOLTIP64045
					}
				}
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.05
				trait = wroth
			}

			mult_modifier = {
				factor = 0.05
				trait = cruel
			}

			mult_modifier = {
				factor = 0.05
				trait = arbitrary
			}

			mult_modifier = {
				factor = 2
				trait = just
			}

			mult_modifier = {
				factor = 2
				trait = kind
			}

			mult_modifier = {
				factor = 2
				trait = trusting
			}
		}
	}

	option = {
		name = EVTOPTC105042

		trigger = {
			FROM = { has_character_flag = no_lover_no_cry }
		}

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_merciful_qadi
				who = ROOT
				years = 5
			}

			set_character_flag = qadi_believe_merciful
			clr_character_flag = no_lover_no_cry

			character_event = {
				id = 105044
				days = 1
				tooltip = EVTTOOLTIPA105044
			}
		}
	}
}

# Chief Qadi: accused did not deny it
character_event = {
	id = 105043
	desc = EVTDESC105043
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105043

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_merciful_qadi
				who = ROOT
				years = 5
			}

			set_character_flag = qadi_merciful

			character_event = {
				id = 105044
				days = 1
				tooltip = EVTTOOLTIPE105044
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.05
				trait = wroth
			}

			mult_modifier = {
				factor = 0.05
				trait = cruel
			}

			mult_modifier = {
				factor = 0.05
				trait = arbitrary
			}

			mult_modifier = {
				factor = 2
				trait = just
			}

			mult_modifier = {
				factor = 2
				trait = kind
			}

			mult_modifier = {
				factor = 2
				trait = trusting
			}
		}
	}

	option = {
		name = EVTOPTB105043

		FROM = {
			show_scope_change = no

			random = {
				chance = 30
				add_trait_wounded_effect = yes
			}

			character_event = {
				id = 105044
				days = 1
				tooltip = EVTTOOLTIPC105044
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 2
				trait = wroth
			}

			mult_modifier = {
				factor = 2
				trait = cruel
			}

			mult_modifier = {
				factor = 2
				trait = arbitrary
			}

			mult_modifier = {
				factor = 0.05
				trait = just
			}

			mult_modifier = {
				factor = 0.05
				trait = kind
			}

			mult_modifier = {
				factor = 0.05
				trait = trusting
			}
		}
	}
}

# Accused gets his/her punishment?
character_event = {
	id = 105044
	desc = EVTDESC105044
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105044

		trigger = {
			trait = wounded
			has_character_flag = zina_suspected
		}

		clr_character_flag = zina_suspected

		tooltip = {
			add_trait = wounded
		}

		prestige = -15

		random = {
			chance = 20

			random_lover = {
				limit = {
					NOT = { is_married = ROOT }
				}

				remove_lover = ROOT
			}
		}

		any_vassal = {
			show_scope_change = no

			limit = {
				trait = zealous
				religion_group = muslim
				has_lover = no
			}

			opinion = {
				name = opinion_committed_zina
				who = ROOT
				years = 2
			}
		}
	}

	option = {
		name = EVTOPTB105044

		trigger = { has_character_flag = qadi_merciful }

		clr_character_flag = qadi_merciful

		tooltip = {
			opinion = {
				name = opinion_merciful_qadi
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTC105044

		trigger = { has_character_flag = qadi_believe_merciful }

		clr_character_flag = qadi_believe_merciful

		tooltip = {
			opinion = {
				name = opinion_merciful_qadi
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTD105044

		trigger = {
			NOR = {
				trait = wounded
				has_character_flag = zina_suspected
			}
		}

		clr_character_flag = zina_suspected
		prestige = -15

		random = {
			chance = 20

			random_lover = {
				limit = {
					NOT = { is_married = ROOT }
				}

				remove_lover = ROOT
			}
		}

		any_vassal = {
			show_scope_change = no

			limit = {
				trait = zealous
				religion_group = muslim
				has_lover = no
			}

			opinion = {
				name = opinion_committed_zina
				who = ROOT
				years = 2
			}
		}
	}
}

### COURT CALLIGRAPHER ###

# Court Calligrapher is asked to decorate the mosque - Setup
character_event = {
	id = 105049

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		any_courtier_or_vassal = {
			has_minor_title = title_court_calligrapher
			religion_group = muslim
			block_general_event_trigger = no
			in_command_trigger = no
			NOT = { has_character_modifier = mosque_calligrapher_timer }
		}

		any_vassal = {
			religion_group = muslim
			block_general_event_trigger = no
			war = no
			in_command_trigger = no
			NOT = { has_minor_title = title_court_calligrapher }

			any_demesne_title = {
				real_tier = BARON
				holding_type = temple
			}
		}
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = { has_minor_title = title_court_calligrapher }

			save_event_target_as = court_calligrapher

			add_character_modifier = {
				name = mosque_calligrapher_timer
				years = 5
				hidden = yes
			}
		}

		random_vassal = {
			limit = {
				religion_group = muslim
				block_general_event_trigger = no
				war = no
				in_command_trigger = no

				any_demesne_title = {
					real_tier = BARON
					holding_type = temple
				}

				NOR = {
					character = event_target:court_calligrapher

					has_opinion_modifier = {
						name = opinion_disappointed_calligrapher
						who = event_target:court_calligrapher
					}
				}
			}

			preferred_limit = {
				OR = {
					trait = zealous
					trait = ambitious
				}

				NOT = { has_minor_title = title_chief_architect }
			}

			preferred_limit = {
				NOR = {
					trait = cynical
					trait = paranoid
					has_minor_title = title_chief_architect
				}
			}

			preferred_limit = {
				NOT = { has_minor_title = title_chief_architect }
			}

			character_event = { id = 105050 }
		}
	}
}

# Court Calligrapher is asked to decorate the mosque
character_event = {
	id = 105050
	desc = EVTDESC105050
	picture = GFX_evt_courtiers_talking # Placeholder?
	border = GFX_event_normal_frame_religion
	portrait = event_target:court_calligrapher

	is_triggered_only = yes

	option = {
		name = EVTOPTA105050

		event_target:court_calligrapher = {
			show_scope_change = no

			character_event = {
				id = 105051
				days = 3
				random = 2
				tooltip = EVTTOOLTIP105051
			}
		}
	}

	option = {
		name = EVTOPTB105050
	}
}

# CC is asked
character_event = {
	id = 105051
	desc = EVTDESC105051
	picture = GFX_evt_courtiers_talking # Placeholder?
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105051 # Yes

		if = {
			limit = {
				OR = {
					learning >= 15
					trait = scholar
					trait = poet
				}
			}

			FROM = {
				show_scope_change = no

				random_list = {
					70 = {
						set_character_flag = good_work_calligrapher

						character_event = {
							id = 105052
							days = 7
							random = 7
							tooltip = EVTTOOLTIPA105052 # Good work
						}
					}

					30 = {
						set_character_flag = bad_work_calligrapher

						character_event = {
							id = 105052
							days = 7
							random = 7
							tooltip = EVTTOOLTIPB105052 # Bad work
						}
					}
				}
			}
		}
		else = {
			FROM = {
				show_scope_change = no

				random_list = {
					50 = {
						set_character_flag = good_work_calligrapher

						character_event = {
							id = 105052
							days = 7
							random = 7
							tooltip = EVTTOOLTIPA105052 # Good work
						}
					}

					50 = {
						set_character_flag = bad_work_calligrapher

						character_event = {
							id = 105052
							days = 7
							random = 7
							tooltip = EVTTOOLTIPB105052 # Bad work
						}
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTB105051 # No

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_disappointed_calligrapher
				who = ROOT
				years = 5
			}

			character_event = {
				id = 105053
				days = 7
				random = 7
				tooltip = EVTTOOLTIPB105053 # Disappointed
			}
		}
	}
}

# ROOT: Court Calligrapher did a good/bad work
character_event = {
	id = 105052
	desc = EVTDESC105052
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105052 # Good work!

		trigger = { has_character_flag = good_work_calligrapher }

		clr_character_flag = good_work_calligrapher

		opinion = {
			name = opinion_grateful_calligrapher
			who = FROM
			years = 5
		}

		FROM = {
			show_scope_change = no

			tooltip = {
				prestige = 20
				piety = 10
			}

			set_character_flag = perfect_work_calligrapher

			character_event = {
				id = 105054
				days = 2
				random = 2
				tooltip = EVTTOOLTIPA105054
			}

			liege = {
				show_scope_change = no

				set_character_flag = perfect_work_calligrapher

				character_event = {
					id = 105055
					days = 2
					random = 2
					tooltip = EVTTOOLTIPA105055
				}
			}
		}
	}

	option = {
		name = EVTOPTB105052 # Horrible!

		trigger = { has_character_flag = bad_work_calligrapher }

		clr_character_flag = bad_work_calligrapher

		opinion = {
			name = opinion_disappointed_calligrapher
			who = FROM
			years = 5
		}

		FROM = {
			tooltip = {
				prestige = -10
				piety = -5
			}

			set_character_flag = dissatisfied_calligrapher

			character_event = {
				id = 105054
				days = 2
				random = 2
				tooltip = EVTTOOLTIPB105054
			}

			liege = {
				show_scope_change = no

				set_character_flag = dissatisfied_calligrapher

				character_event = {
					id = 105055
					days = 2
					random = 2
					tooltip = EVTTOOLTIPB105055
				}
			}
		}
	}

	option = {
		name = EVTOPTC105052 # Pretend it's bad

		trigger = { has_character_flag = good_work_calligrapher }

		clr_character_flag = good_work_calligrapher

		opinion = {
			name = opinion_dissatisfied_calligrapher
			who = FROM
			years = 5
		}

		FROM = {
			show_scope_change = no

			tooltip = {
				prestige = -5
			}

			set_character_flag = no_good_calligrapher

			character_event = {
				id = 105054
				days = 2
				random = 2
				tooltip = EVTTOOLTIPB105054
			}

			liege = {
				show_scope_change = no

				set_character_flag = no_good_calligrapher

				character_event = {
					id = 105055
					days = 2
					random = 2
					tooltip = EVTTOOLTIPB105055
				}
			}
		}
	}

	option = {
		name = EVTOPTD105052 # Pretend it's good

		trigger = { has_character_flag = bad_work_calligrapher }

		clr_character_flag = bad_work_calligrapher

		opinion = {
			name = opinion_satisfied
			who = FROM
			years = 5
		}

		FROM = {
			show_scope_change = no

			tooltip = {
				prestige = 10
			}

			set_character_flag = satisfied_work_calligrapher

			character_event = {
				id = 105054
				days = 2
				random = 2
				tooltip = EVTTOOLTIPA105054
			}

			liege = {
				show_scope_change = no

				set_character_flag = satisfied_work_calligrapher

				character_event = {
					id = 105055
					days = 2
					random = 2
					tooltip = EVTTOOLTIPA105055
				}
			}
		}
	}
}

# ROOT: Calligrapher said no
character_event = {
	id = 105053
	desc = EVTDESC105053
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	ai = no

	option = {
		name = EVTOPTA105053

		tooltip = {
			opinion = {
				name = opinion_disappointed_calligrapher
				who = FROM
				years = 5
			}
		}
	}
}

# Court Calligrapher: Gets answer from ROOT
character_event = {
	id = 105054
	desc = EVTDESC105054
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105054

		trigger = { has_character_flag = satisfied_work_calligrapher }

		clr_character_flag = satisfied_work_calligrapher

		add_character_modifier = {
			name = mod_satisfied_work_calligrapher
			days = 912 # 2.5 years
		}

		tooltip = {
			opinion = {
				name = opinion_satisfied
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105054

		trigger = { has_character_flag = no_good_calligrapher }

		clr_character_flag = no_good_calligrapher

		add_character_modifier = {
			name = mod_bad_work_calligrapher
			years = 1
		}

		tooltip = {
			opinion = {
				name = opinion_dissatisfied_calligrapher
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTC105054

		trigger = { has_character_flag = dissatisfied_calligrapher }

		clr_character_flag = dissatisfied_calligrapher

		add_character_modifier = {
			name = mod_dissatisfied_calligrapher
			years = 1
		}

		tooltip = {
			opinion = {
				name = opinion_disappointed_calligrapher
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTD105054

		trigger = { has_character_flag = perfect_work_calligrapher }

		clr_character_flag = perfect_work_calligrapher

		add_character_modifier = {
			name = mod_perfect_work_calligrapher
			years = 5
		}

		prestige = 20
		piety = 10

		tooltip = {
			reverse_opinion = {
				name = opinion_grateful_calligrapher
				who = FROM
				years = 5
			}
		}
	}
}

# Liege: is satisfied/irritated
character_event = {
	id = 105055
	desc = EVTDESC105055
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	show_from_from = yes
	is_triggered_only = yes

	option = {
		name = EVTOPTA105055

		trigger = { has_character_flag = satisfied_work_calligrapher }

		clr_character_flag = satisfied_work_calligrapher
		prestige = 5
	}

	option = {
		name = EVTOPTB105055

		trigger = { has_character_flag = no_good_calligrapher }

		clr_character_flag = no_good_calligrapher
		prestige = -5
	}

	option = {
		name = EVTOPTC105055

		trigger = { has_character_flag = dissatisfied_calligrapher }

		clr_character_flag = dissatisfied_calligrapher
		prestige = -10
	}

	option = {
		name = EVTOPTD105055

		trigger = { has_character_flag = perfect_work_calligrapher }

		clr_character_flag = perfect_work_calligrapher
		prestige = 20
	}
}

### Court Calligrapher created fine Hilya - Setup ###
character_event = {
	id = 105059

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		piety >= 100
		in_command_trigger = no

		any_courtier_or_vassal = {
			has_minor_title = title_court_calligrapher
			religion_group = muslim
			block_general_event_trigger = no
			in_command_trigger = no
			NOT = { has_character_modifier = beautiful_hilya }

			OR = {
				learning >= 20
				trait = scholar
				trait = poet
			}
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_court_calligrapher
				trait = zealous
			}
		}

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_court_calligrapher
				trait = ambitious
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_court_calligrapher
				trait = cynical
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_court_calligrapher
				trait = slothful
			}
		}
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = { has_minor_title = title_court_calligrapher }
			character_event = { id = 105060 }
		}
	}
}

### Court Calligrapher created fine Hilya ###
character_event = {
	id = 105060
	desc = EVTDESC105060
	picture = GFX_evt_courtiers_talking
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105060

		trigger = {
			rightful_religious_head_scope = {
				NOR = {
					character = ROOT
					is_liege_of = ROOT
				}
			}
		}

		add_character_modifier = {
			name = beautiful_hilya
			years = 2
		}

		piety = 20

		rightful_religious_head_scope = {
			show_scope_change = no

			opinion = {
				name = opinion_good_work
				who = ROOT
				years = 5
			}

			character_event = {
				id = 105061
				days = 7
				random = 7
				tooltip = EVTTOOLTIPA105061
			}
		}
	}

	option = {
		name = EVTOPTB105060

		add_character_modifier = {
			name = beautiful_hilya
			years = 2
		}

		prestige = 20

		liege = {
			show_scope_change = no

			opinion = {
				name = opinion_good_work
				who = ROOT
				years = 5
			}

			character_event = {
				id = 105061
				days = 7
				random = 7
				tooltip = EVTTOOLTIPB105061
			}
		}
	}

	option = {
		name = EVTOPTC105060

		add_character_modifier = {
			name = beautiful_hilya
			months = 1
		}

		scaled_wealth = 0.5
	}
}

# Caliph/Liege gets Hilya from ROOT
character_event = {
	id = 105061
	desc = EVTDESC105061
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105061

		tooltip = {
			opinion = {
				name = opinion_good_work
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105061

		tooltip = {
			opinion = {
				name = opinion_good_work
				who = FROM
				years = 5
			}
		}

		FROM = {
			show_scope_change = no

			transfer_scaled_wealth = {
				from = ROOT
				value = 0.25
			}

			piety = 10
		}
	}

	option = {
		name = EVTOPTC105061

		remove_opinion = {
			name = opinion_good_work
			who = FROM
		}

		ai_chance = { factor = 0 }
	}
}

### Court Calligrapher: Golden Qu'ran - Setup ###
character_event = {
	id = 105064

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		scaled_wealth = 2
		in_command_trigger = no

		any_courtier_or_vassal = {
			has_minor_title = title_court_calligrapher
			religion_group = muslim
			age >= 30
			is_inaccessible_or_incapable_trigger = no
			in_command_trigger = no
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_court_calligrapher
				trait = greedy
			}
		}

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_court_calligrapher
				trait = deceitful
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_court_calligrapher
				trait = honest
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_court_calligrapher
				trait = charitable
			}
		}
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = { has_minor_title = title_court_calligrapher }
			character_event = { id = 105065 }
		}
	}
}

### Court Calligrapher: Golden Qu'ran ###
character_event = {
	id = 105065
	desc = EVTDESC105065
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105065 # Finance the whole book

		liege = {
			show_scope_change = no

			set_character_flag = finance_golden_quran

			character_event = {
				id = 105066
				days = 2
				random = 2
				tooltip = EVTTOOLTIPA105066
			}
		}

		ai_chance = {
			factor = 30

			mult_modifier = {
				factor = 3
				trait = greedy
			}

			mult_modifier = {
				factor = 0.05
				trait = charitable
			}
		}
	}

	option = {
		name = EVTOPTB105065 # Finance part of it

		liege = {
			show_scope_change = no

			set_character_flag = finance_quran

			character_event = {
				id = 105066
				days = 2
				random = 2
				tooltip = EVTTOOLTIPB105066
			}
		}

		ai_chance = {
			factor = 30

			mult_modifier = {
				factor = 3
				trait = deceitful
			}

			mult_modifier = {
				factor = 0.05
				trait = honest
			}
		}
	}

	option = {
		name = EVTOPTC105065 # Don't do it

		piety = 10
		remove_trait_silently_greedy_effect = yes

		ai_chance = {
			factor = 30

			mult_modifier = {
				factor = 3
				trait = charitable
			}

			mult_modifier = {
				factor = 3
				trait = honest
			}
		}
	}
}

# Liege: Finance Golden Qu'ran?
character_event = {
	id = 105066
	desc = EVTDESC105066
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105066 # Yes

		trigger = { has_character_flag = finance_golden_quran }

		clr_character_flag = finance_golden_quran

		transfer_scaled_wealth = {
			to = FROM
			value = 1
		}

		FROM = {
			show_scope_change = no

			set_character_flag = liege_finance_golden_quran

			character_event = {
				id = 105067
				days = 2
				random = 2
				tooltip = EVTTOOLTIPA105067
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.05
				NOT = { scaled_wealth = 3 }
			}
		}
	}

	option = {
		name = EVTOPTB105066 # Yes

		trigger = { has_character_flag = finance_quran }

		clr_character_flag = finance_quran

		transfer_scaled_wealth = {
			to = FROM
			value = 0.5
		}

		FROM = {
			show_scope_change = no

			set_character_flag = liege_finance_quran

			character_event = {
				id = 105067
				days = 2
				random = 2
				tooltip = EVTTOOLTIPA105067
			}
		}

		ai_chance = {
			factor = 50

			mult_modifier = {
				factor = 0.05
				NOT = { scaled_wealth = 2 }
			}
		}
	}

	option = {
		name = EVTOPTC105066 # No

		clr_character_flag = finance_quran
		clr_character_flag = finance_golden_quran

		FROM = {
			show_scope_change = no

			set_character_flag = liege_refused_finance

			character_event = {
				id = 105067
				days = 2
				random = 2
				tooltip = EVTTOOLTIPB105067
			}
		}
	}
}

# Court Calligrapher: Got the money or not?
character_event = {
	id = 105067
	desc = EVTDESC105067
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105067

		trigger = { has_character_flag = liege_finance_golden_quran }

		tooltip = {
			transfer_scaled_wealth = {
				from = FROM
				value = 1
			}
		}

		FROM = {
			if = {
				limit = {
					OR = {
						intrigue >= 20

						job_spymaster = {
							intrigue >= 20
						}
					}
				}
			}

			random = {
				chance = 50

				character_event = {
					id = 105068
					months = 6
					random = 2
				}
			}
		}
	}

	option = {
		name = EVTOPTB105067

		trigger = { has_character_flag = liege_finance_quran }

		tooltip = {
			transfer_scaled_wealth = {
				from = FROM
				value = 0.5
			}
		}

		FROM = {
			if = {
				limit = {
					OR = {
						intrigue >= 20

						job_spymaster = {
							intrigue >= 20
						}
					}
				}
			}

			random = {
				chance = 50

				character_event = {
					id = 105068
					months = 6
					random = 2
				}
			}
		}
	}

	option = {
		name = EVTOPTC105067

		trigger = { has_character_flag = liege_refused_finance }

		prestige = -5
	}
}

# Liege: No sign of Golden Qu'ran
character_event = {
	id = 105068
	desc = EVTDESC105068
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	trigger = {
		FROM = {
			is_alive = yes
		}
	}

	option = {
		name = EVTOPTA105068 # Imprison CC

		FROM = {
			show_scope_change = no

			imprison = ROOT
			remove_title = title_court_calligrapher
			set_character_flag = imprisoned_calligrapher
			character_event = { id = 105069 }
		}
	}

	option = {
		name = EVTOPTB105068 # Banish CC

		FROM = {
			show_scope_change = no

			banish = yes
			remove_title = title_court_calligrapher
			set_character_flag = banished_calligrapher
			character_event = { id = 105069 }
		}
	}

	option = {
		name = EVTOPTC105068 # Make him pay

		FROM = {
			show_scope_change = no

			clear_wealth = yes
			remove_title = title_court_calligrapher
			set_character_flag = poor_calligrapher
			character_event = { id = 105069 }
		}
	}

	option = {
		name = EVTOPTD105068

		trigger = {
			NOT = { trait = paranoid }
		}

		prestige = -5
	}
}

# CC is imprisoned/banished/robbed of all wealth
character_event = {
	id = 105069
	desc = EVTDESC105069
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_religion

	is_triggered_only = yes

	option = {
		name = EVTOPTA105069

		trigger = { has_character_flag = imprisoned_calligrapher }

		clr_character_flag = imprisoned_calligrapher

		tooltip = {
			remove_title = title_court_calligrapher
			imprison = FROM
		}
	}

	option = {
		name = EVTOPTB105069

		trigger = { has_character_flag = banished_calligrapher }

		clr_character_flag = banished_calligrapher

		tooltip = {
			remove_title = title_court_calligrapher
			banish = yes
		}
	}

	option = {
		name = EVTOPTC105069

		trigger = { has_character_flag = poor_calligrapher }

		clr_character_flag = poor_calligrapher

		tooltip = {
			remove_title = title_court_calligrapher
			clear_wealth = yes
		}
	}
}

### COURT MUSICIAN ###

### Court Musician presents a song for the liege/liege's spouse - Setup ###
character_event = {
	id = 105074

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		higher_real_tier_than = DUKE
		in_command_trigger = no

		any_courtier_or_vassal = {
			has_minor_title = title_court_musician
			religion_group = muslim
			block_general_event_trigger = no
			in_command_trigger = no

			OR = {
				diplomacy >= 15
				trait = poet
			}
		}
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = { has_minor_title = title_court_musician }

			save_event_target_as = court_musician

			character_event = { id = 105075 }
		}
	}
}

### Court Musician presents a song for the liege/liege's spouse ###
character_event = {
	id = 105075
	desc = EVTDESC105075
	picture = GFX_evt_spymaster

	is_triggered_only = yes

	option = {
		name = EVTOPTA105075

		trigger = {
			prefers_men_trigger = no

			liege = {
				spouse = {
					is_female = yes
					age >= 20
					practical_age < 30
					has_ugly_trait_trigger = no
				}
			}
		}

		liege = {
			show_scope_change = no

			spouse = {
				show_scope_change = no

				character_event = {
					id = 105076
					days = 3
					random = 3
					tooltip = EVTTOOLTIP105076
				}
			}
		}
	}

	option = {
		name = EVTOPTB105075

		liege = {
			show_scope_change = no

			set_character_flag = musician_song

			character_event = {
				id = 105077
				days = 3
				random = 3
				tooltip = EVTTOOLTIPA105077
			}
		}
	}

	option = {
		name = EVTOPTC105075

		add_character_modifier = {
			name = diligent_musician
			years = 1
		}
	}
}

# Liege's spouse: CM gave me song
character_event = {
	id = 105076
	desc = EVTDESC105076
	picture = GFX_evt_courtiers_talking

	is_triggered_only = yes

	option = {
		name = EVTOPTA105076

		opinion = {
			name = opinion_beautiful_song
			who = FROM
			years = 5
		}

		FROM = {
			show_scope_change = no

			set_character_flag = wonderful_song

			character_event = {
				id = 105078
				days = 3
				random = 3
				tooltip = EVTTOOLTIP105078
			}
		}
	}

	option = {
		name = EVTOPTB105076

		spouse = {
			show_scope_change = no

			set_character_flag = musician_song_spouse

			character_event = {
				id = 105077
				days = 3
				random = 3
				tooltip = EVTTOOLTIP105077
			}
		}
	}
}

# Liege/spouse: gets the song/spouse got the song
character_event = {
	id = 105077
	desc = EVTDESC105077
	picture = GFX_evt_emissary

	is_triggered_only = yes
	show_from_from = yes

	option = {
		name = EVTOPTA105077

		trigger = { has_character_flag = musician_song_spouse}

		clr_character_flag = musician_song_spouse

		tooltip = {
			transfer_scaled_wealth = {
				to = FROM
				value = 0.05
			}
		}

		reverse_opinion = {
			name = opinion_beautiful_song
			who = spouse
			years = 2
		}

		FROM = {
			show_scope_change = no

			set_character_flag = song_spouse_fine

			character_event = {
				id = 105078
				days = 3
				random = 3
				tooltip = EVTTOOLTIPB105078
			}
		}
	}

	option = {
		name = EVTOPTB105077

		trigger = { has_character_flag = musician_song_spouse }

		clr_character_flag = musician_song_spouse

		opinion = {
			name = opinion_seduce_spouse
			who = FROM
			years = 5
		}

		FROM = {
			show_scope_change = no

			imprison = ROOT
			set_character_flag = imprison_musician

			character_event = {
				id = 105078
				days = 3
				random = 3
				tooltip = EVTTOOLTIPC105078
			}
		}
	}

	option = {
		name = EVTOPTC105077

		trigger = { has_character_flag = musician_song }

		clr_character_flag = musician_song

		opinion = {
			name = opinion_beautiful_song
			who = FROM
			years = 5
		}

		FROM = {
			show_scope_change = no

			set_character_flag = wonderful_song

			character_event = {
				id = 105078
				days = 3
				random = 3
				tooltip = EVTTOOLTIP105078
			}
		}
	}
}

# Court Musician: Liege's Spouse's reaction
character_event = {
	id = 105078
	desc = EVTDESC105078
	picture = GFX_evt_courtiers_talking

	is_triggered_only = yes

	option = {
		name = EVTOPTA105078

		trigger = { has_character_flag = wonderful_song }

		clr_character_flag = wonderful_song

		tooltip = {
			reverse_opinion = {
				name = opinion_beautiful_song
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105078

		trigger = { has_character_flag = song_spouse_fine }

		clr_character_flag = song_spouse_fine

		FROM = {
			show_scope_change = no

			transfer_scaled_wealth = {
				to = ROOT
				value = 0.05
			}

			tooltip = {
				spouse = {
					show_scope_change = no

					opinion = {
						name = opinion_beautiful_song
						who = ROOT
						years = 2
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTC105078

		trigger = { has_character_flag = imprison_musician }

		clr_character_flag = imprison_musician

		tooltip = {
			imprison = FROM

			reverse_opinion = {
				name = opinion_seduce_spouse
				who = FROM
				years = 5
			}
		}
	}
}

### COURT POET ###

### Court Poet writes poem - Setup ###
character_event = {
	id = 105099

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		higher_real_tier_than = DUKE
		in_command_trigger = no

		any_courtier_or_vassal = {
			has_minor_title = title_court_poet
			religion_group = muslim
			block_general_event_trigger = no
			in_command_trigger = no

			OR = {
				diplomacy >= 15
				trait = poet
			}
		}
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = { has_minor_title = title_court_poet }
			character_event = { id = 105100 }
		}
	}
}

### Court Poet writes poem ###
character_event = {
	id = 105100
	desc = EVTDESC105100
	picture = GFX_evt_garden

	is_triggered_only = yes

	option = {
		name = EVTOPTA105100

		trigger = {
			prefers_men_trigger = no

			liege = {
				spouse = {
					is_female = yes
					age >= 20
					practical_age < 30
					has_ugly_trait_trigger = no
				}
			}
		}

		liege = {
			show_scope_change = no

			spouse = {
				show_scope_change = no

				character_event = {
					id = 105101
					days = 3
					random = 3
					tooltip = EVTTOOLTIP105101
				}
			}
		}
	}

	option = {
		name = EVTOPTB105100

		liege = {
			show_scope_change = no

			set_character_flag = poet_poetry

			character_event = {
				id = 105102
				days = 3
				random = 3
				tooltip = EVTTOOLTIPA105102
			}
		}
	}

	option = {
		name = EVTOPTC105100

		add_character_modifier = {
			name = diligent_poet
			years = 1
		}
	}
}

# Liege's spouse: Court Poet gave me a poem
character_event = {
	id = 105101
	desc = EVTDESC105101
	picture = GFX_evt_garden

	is_triggered_only = yes

	option = {
		name = EVTOPTA105101

		tooltip = {
			opinion = {
				name = opinion_beautiful_poem
				who = FROM
				years = 5
			}
		}

		FROM = {
			show_scope_change = no

			set_character_flag = wonderful_poem

			character_event = {
				id = 105103
				days = 3
				random = 3
				tooltip = EVTTOOLTIP105103
			}
		}
	}

	option = {
		name = EVTOPTB105101

		spouse = {
			show_scope_change = no

			set_character_flag = poet_poetry_spouse

			character_event = {
				id = 105102
				days = 3
				random = 3
				tooltip = EVTTOOLTIPB105102
			}
		}
	}
}

# Liege/spouse: gets the poem/spouse got the poem
character_event = {
	id = 105102
	desc = EVTDESC105102
	picture = GFX_evt_garden

	is_triggered_only = yes

	option = {
		name = EVTOPTA105102

		trigger = { has_character_flag = poet_poetry_spouse }

		clr_character_flag = poet_poetry_spouse

		tooltip = {
			transfer_scaled_wealth = {
				to = FROM
				value = 0.05
			}
		}

		tooltip = {
			spouse = {
				show_scope_change = no

				opinion = {
					name = opinion_beautiful_poem
					who = FROM
					years = 2
				}
			}
		}

		FROM = {
			show_scope_change = no

			set_character_flag = poem_spouse_fine

			character_event = {
				id = 105103
				days = 3
				random = 3
				tooltip = EVTTOOLTIPB105103
			}
		}
	}

	option = {
		name = EVTOPTB105102

		trigger = { has_character_flag = poet_poetry_spouse}

		clr_character_flag = poet_poetry_spouse

		tooltip = {
			opinion = {
				name = opinion_seduce_spouse
				who = FROM
				years = 5
			}
		}

		FROM = {
			show_scope_change = no

			imprison = ROOT
			set_character_flag = imprison_poet

			character_event = {
				id = 105103
				days = 3
				random = 3
				tooltip = EVTTOOLTIPC105103
			}
		}
	}

	option = {
		name = EVTOPTC105102

		trigger = { has_character_flag = poet_poetry }

		clr_character_flag = poet_poetry

		tooltip = {
			opinion = {
				name = opinion_beautiful_poem
				who = FROM
				years = 5
			}
		}

		FROM = {
			show_scope_change = no

			set_character_flag = liege_wonderful_poem

			character_event = {
				id = 105103
				days = 3
				random = 3
				tooltip = EVTTOOLTIPB105103
			}
		}
	}
}

# Court Musician: Liege and liege's Spouse's reaction
character_event = {
	id = 105103
	desc = EVTDESC105103
	picture = GFX_evt_garden

	is_triggered_only = yes

	option = {
		name = EVTOPTA105103

		trigger = { has_character_flag = wonderful_poem }

		clr_character_flag = wonderful_poem

		tooltip = {
			reverse_opinion = {
				name = opinion_beautiful_poem
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105103

		trigger = { has_character_flag = poem_spouse_fine }

		clr_character_flag = poem_spouse_fine

		FROM = {
			show_scope_change = no

			transfer_scaled_wealth = {
				to = ROOT
				value = 0.05
			}

			spouse = {
				show_scope_change = no

				opinion = {
					name = opinion_beautiful_poem
					who = ROOT
					years = 2
				}
			}
		}
	}

	option = {
		name = EVTOPTC105103

		trigger = { has_character_flag = imprison_poet }

		clr_character_flag = imprison_poet

		tooltip = {
			imprison = FROM
		}

		reverse_opinion = {
			name = opinion_seduce_spouse
			who = FROM
			years = 5
		}
	}

	option = {
		name = EVTOPTD105103

		trigger = { has_character_flag = liege_wonderful_poem }

		clr_character_flag = liege_wonderful_poem

		opinion = {
			name = opinion_beautiful_poem
			who = FROM
			years = 5
		}
	}
}

### CUPBEARER ###

### Cupbearer: Poison Host - Setup###
character_event = {
	id = 105149

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		in_command_trigger = no

		any_courtier_or_vassal = {
			has_minor_title = title_cupbearer
			block_general_event_trigger = no
			war = no
			in_command_trigger = no
			NOT = { has_character_modifier = cupbearer_poison_timer }

			OR = {
				intrigue >= 15
				diplomacy >= 15
				trait = deceitful
				trait = envious
			}

			opinion = {
				who = ROOT
				value < 0
			}

			host = {
				character = ROOT
				at_location = PREV
			}
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_cupbearer
				trait = envious
			}
		}

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_cupbearer
				trait = deceitful
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_cupbearer
				trait = honest
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_cupbearer
				trait = charitable
			}
		}
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = { has_minor_title = title_cupbearer }

			add_character_modifier = {
				name = cupbearer_poison_timer
				years = 5
				hidden = yes
			}

			character_event = { id = 105150 }
		}
	}
}

### Cupbearer: Poison Host ###
character_event = {
	id = 105150
	desc = EVTDESC105150
	picture = GFX_evt_courtiers_talking

	is_triggered_only = yes

	option = {
		name = EVTOPTA105150

		host = {
			show_scope_change = no

			if = {
				limit = { trait = paranoid }

				random_list = {
					50 = {
						mult_modifier = {
							factor = 1.4 # 70%
							trait = paranoid
						}

						set_character_flag = failed_poison

						character_event = {
							id = 105151
							tooltip = EVTTOOLTIP105151
						}
					}

					25 = {
						mult_modifier = {
							factor = 0.6 # 15%
							trait = paranoid
						}

						if = {
							limit = { has_dlc = "Reapers" }

							set_character_flag = disease_not_serious
							add_trait = vomiting

							character_event = {
								id = RIP.11005
								days = 10
								random = 30
							}
						}
						else = {
							add_trait_ill_effect = yes
						}

						if = {
							limit = {
								OR = {
									intrigue >= 15

									job_spymaster = {
										intrigue >= 15
									}
								}
							}

							set_character_flag = poison_ill

							character_event = {
								id = 105151
								days = 3
								random = 3
							}
						}
					}

					20 = {
						mult_modifier = {
							factor = 0.5 # 10%
							trait = paranoid
						}

						add_trait_lunatic_effect = yes

						if = {
							limit = {
								OR = {
									intrigue >= 15

									job_spymaster = {
										intrigue >= 15
									}
								}
							}

							set_character_flag = poison_lunatic

							character_event = {
								id = 105151
								days = 3
								random = 3
							}
						}
					}

					5 = {
						death = {
							death_reason = death_murder_unknown_poison
							killer = ROOT
						}
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTB105150

		remove_trait_silently_deceitful_effect = yes
		remove_trait_silently_envious_effect = yes
	}
}

# Host finds out/is poisoned
character_event = {
	id = 105151
	desc = EVTDESC105151
	picture = GFX_evt_spymaster

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA105151
			trigger = { has_character_flag = poison_lunatic }
		}
		name = {
			text = EVTOPTB105151
			trigger = { has_character_flag = failed_poison }
		}
		name = {
			text = EVTOPTC105151
			trigger = { has_character_flag = poison_ill }
		}

		FROM = {
			show_scope_change = no

			imprison = ROOT

			tooltip = {
				remove_title = title_cupbearer

				reverse_opinion = {
					name = opinion_poisoner
					who = ROOT
					years = 5
				}
			}

			character_event = { id = 105152 }
		}

		trigger_switch = {
			on_trigger = has_character_flag

			poison_lunatic = {
				FROM = {
					show_scope_change = no

					custom_tooltip = { text = EVTTOOLTIPA105152 }
					set_character_flag = lunatic_imprison
				}
			}

			failed_poison = {
				FROM = {
					show_scope_change = no

					custom_tooltip = { text = EVTTOOLTIPB105152 }
					set_character_flag = failed_imprison
				}
			}

			ill_poison = {
				FROM = {
					show_scope_change = no

					custom_tooltip = { text = EVTTOOLTIPC105152 }
					set_character_flag = ill_imprison
				}
			}
		}
	}

	option = {
		name = {
			text = EVTOPTD105151
			trigger = { has_character_flag = poison_lunatic }
		}
		name = {
			text = EVTOPTE105151
			trigger = { has_character_flag = failed_poison }
		}
		name = {
			text = EVTOPTF105151
			trigger = { has_character_flag = poison_ill }
		}

		FROM = {
			show_scope_change = no
			death = { death_reason = death_execution }
		}
	}

	after = {
		clr_character_flag = poison_lunatic
		clr_character_flag = failed_poison
		clr_character_flag = poison_ill
	}
}

# Cupbearer is imprisoned
character_event = {
	id = 105152
	desc = EVTDESC105152
	picture = GFX_evt_into_the_dungeon

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA105152
			trigger = { has_character_flag = ill_imprison }
		}
		name = {
			text = EVTOPTB105152
			trigger = { has_character_flag = failed_imprison }
		}
		name = {
			text = EVTOPTC105152
			trigger = { has_character_flag = lunatic_imprison }
		}

		clr_character_flag = ill_imprison
		clr_character_flag = failed_imprison
		clr_character_flag = lunatic_imprison

		tooltip = {
			imprison = FROM
		}

		remove_title = title_cupbearer

		reverse_opinion = {
			name = opinion_poisoner
			who = FROM
			years = 5
		}
	}
}

### CHIEF ARCHITECT ###

### Chief Architect: Suggest improvements to castle - Setup ###
character_event = {
	id = 105199

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		scaled_wealth = 2
		in_command_trigger = no

		any_courtier_or_vassal = {
			has_minor_title = title_chief_architect
			religion_group = muslim
			block_general_event_trigger = no
			in_command_trigger = no
			at_location = ROOT

			NOR = {
				has_character_modifier = architect_improvement_timer
				has_character_modifier = diligent_architect
			}
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_chief_architect
				trait = envious
			}
		}

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_chief_architect
				trait = deceitful
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_chief_architect
				trait = honest
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_chief_architect
				trait = charitable
			}
		}
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = { has_minor_title = title_chief_architect }
			character_event = { id = 105200 }
		}
	}
}

### Chief Architect: Suggest improvements to castle ###
character_event = {
	id = 105200
	desc = EVTDESC105200
	picture = GFX_evt_castle_construction

	is_triggered_only = yes

	option = {
		name = EVTOPTA105200

		add_character_modifier = {
			name = architect_improvement_timer
			years = 5
			hidden = yes
		}

		liege = {
			show_scope_change = no

			character_event = {
				id = 105201
				days = 3
				random = 3
				tooltip = EVTTOOLTIP105201
			}
		}
	}

	option = {
		name = EVTOPTB105200

		add_character_modifier = {
			name = diligent_architect
			years = 1
		}
	}
}

# Liege: CA asks if improvements is OK
character_event = {
	id = 105201
	desc = EVTDESC105201
	picture = GFX_evt_castle_construction

	is_triggered_only = yes

	option = {
		name = EVTOPTA105201 # Yes

		FROM = {
			show_scope_change = no

			transfer_scaled_wealth = {
				from = ROOT
				value = 0.25
			}

			opinion = {
				name = opinion_glad
				who = ROOT
				years = 5
			}

			set_character_flag = all_improvements

			character_event = {
				id = 105202
				days = 3
				random = 3
				tooltip = EVTTOOLTIPA105202
			}
		}
	}

	option = {
		name = EVTOPTB105201 # No

		FROM = {
			show_scope_change = no

			set_character_flag = no_improvement

			opinion = {
				name = opinion_disappointed
				who = ROOT
				years = 5
			}

			character_event = {
				id = 105202
				days = 3
				random = 3
				tooltip = EVTTOOLTIPB105202
			}
		}
	}
}

# Chief Architect: Keep the money or not?/no money
character_event = {
	id = 105202
	desc = EVTDESC105202
	picture = GFX_evt_castle_construction

	is_triggered_only = yes

	option = {
		name = EVTOPTA105202

		trigger = { has_character_flag = no_improvement }

		clr_character_flag = no_improvement

		tooltip = {
			opinion = {
				name = opinion_disappointed
				who = FROM
				years = 5
			}
		}
	}

	option = {
		name = EVTOPTB105202 # Keep it!

		trigger = { has_character_flag = all_improvements }

		clr_character_flag = all_improvements

		transfer_scaled_wealth = {
			from = FROM
			value = 0.25
		}

		FROM = {
			if = {
				limit = {
					OR = {
						intrigue >= 20

						job_spymaster = {
							intrigue >= 20
						}
					}
				}
			}

			random = {
				chance = 50

				character_event = {
					id = 105203
					months = 6
					random = 2
				}
			}
		}
	}

	option = {
		name = EVTOPTC105202 # Do something useful with it

		trigger = { has_character_flag = all_improvements }

		liege = {
			show_scope_change = no

			random_realm_province = {
				show_scope_change = no

				limit = { held_under_PREV = yes }

				add_province_modifier = {
					name = architect_improvements
					years = 2
				}
			}
		}
	}
}

# Liege: No sign of improvements
character_event = {
	id = 105203
	desc = EVTDESC105203
	picture = GFX_evt_spymaster

	is_triggered_only = yes

	trigger = {
		FROM = {
			is_alive = yes
		}
	}

	option = {
		name = EVTOPTA105203 # Imprison CA

		FROM = {
			show_scope_change = no

			imprison = ROOT
			remove_title = title_chief_architect

			set_character_flag = imprisoned_architect
			character_event = { id = 105204 }
		}
	}

	option = {
		name = EVTOPTB105203 # Banish CA

		FROM = {
			show_scope_change = no

			banish = yes
			remove_title = title_chief_architect
			set_character_flag = banished_architect
			character_event = { id = 105204 }
		}
	}

	option = {
		name = EVTOPTC105203 # Make him pay

		FROM = {
			show_scope_change = no

			clear_wealth = yes
			remove_title = title_chief_architect
			set_character_flag = poor_architect
			character_event = { id = 105204 }
		}
	}

	option = {
		name = EVTOPTD105203

		random_realm_province = {
			show_scope_change = no

			limit = { held_under_PREV = yes }

			add_province_modifier = {
				name = architect_improvements
				years = 1
			}
		}
	}
}

# Chief Architect is imprisoned/banished/robbed of all wealth
character_event = {
	id = 105204
	desc = EVTDESC105204
	picture = GFX_evt_spymaster

	is_triggered_only = yes

	option = {
		name = EVTOPTA105204

		trigger = { has_character_flag = imprisoned_architect }

		clr_character_flag = imprisoned_architect

		tooltip = {
			imprison = FROM
		}
	}

	option = {
		name = EVTOPTB105204

		trigger = { has_character_flag = banished_architect }

		clr_character_flag = banished_architect

		tooltip = {
			banish = yes
		}
	}

	option = {
		name = EVTOPTC105204

		trigger = { has_character_flag = poor_architect }

		clr_character_flag = poor_architect

		tooltip = {
			clear_wealth = yes
		}
	}
}

### FOOD TASTER ###

### Food Taster: Poison host - Setup ###
character_event = {
	id = 105249

	is_triggered_only = yes # on_bi_yearly_pulse, random_events, muslim_sultan_honorary_titles
	hide_window = yes

	only_playable = yes
	religion_group = muslim
	prisoner = no

	trigger = {
		in_command_trigger = no

		any_courtier_or_vassal = {
			has_minor_title = title_food_taster
			block_general_event_trigger = no
			war = no
			in_command_trigger = no
			NOT = { has_character_modifier = food_taster_poison_timer }

			OR = {
				intrigue >= 15
				diplomacy >= 15
				trait = deceitful
				trait = envious
			}

			opinion = {
				who = ROOT
				value < 0
			}

			host = {
				character = ROOT
				at_location = PREV
			}
		}
	}

	weight_multiplier = {
		factor = 1

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_food_taster
				trait = envious
			}
		}

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_food_taster
				trait = deceitful
			}
		}

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_food_taster
				trait = paranoid
			}
		}

		mult_modifier = {
			factor = 2

			any_courtier_or_vassal = {
				has_minor_title = title_food_taster
				trait = cynical
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_food_taster
				trait = honest
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_food_taster
				trait = charitable
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_food_taster
				trait = trusting
			}
		}

		mult_modifier = {
			factor = 0.5

			any_courtier_or_vassal = {
				has_minor_title = title_food_taster
				trait = zealous
			}
		}
	}

	immediate = {
		random_courtier_or_vassal = {
			limit = { has_minor_title = title_food_taster }

			add_character_modifier = {
				name = food_taster_poison_timer
				years = 5
				hidden = yes
			}

			character_event = { id = 105250 }
		}
	}
}

### Food Taster: Poison host ###
character_event = {
	id = 105250
	desc = EVTDESC105250
	picture = GFX_evt_courtiers_talking

	is_triggered_only = yes

	option = {
		name = EVTOPTA105250

		host = {
			show_scope_change = no

			random_list = {
				50 = {
					mult_modifier = {
						factor = 1.4 # 70%
						trait = paranoid
					}

					set_character_flag = poison_failed

					character_event = {
						id = 105251
						tooltip = EVTTOOLTIP105251
					}
				}

				25 = {
					mult_modifier = {
						factor = 0.6 # 15%
						trait = paranoid
					}

					if = {
						limit = { has_dlc = "Reapers" }

						set_character_flag = disease_not_serious
						add_trait = vomiting

						character_event = {
							id = RIP.11005
							days = 10
							random = 30
						}
					}
					else = {
						add_trait_ill_effect = yes
					}

					if = {
						limit = {
							OR = {
								intrigue >= 15

								job_spymaster = {
									intrigue >= 15
								}
							}
						}

						set_character_flag = ill_poison

						character_event = {
							id = 105251
							days = 3
							random = 3
						}
					}
				}

				20 = {
					mult_modifier = {
						factor = 0.5 # 10%
						trait = paranoid
					}

					add_trait_lunatic_effect = yes

					if = {
						limit = {
							OR = {
								intrigue >= 15

								job_spymaster = {
									intrigue >= 15
								}
							}
						}

						set_character_flag = lunatic_poison

						character_event = {
							id = 105251
							days = 3
							random = 3
						}
					}
				}

				5 = {
					death = {
						death_reason = death_murder_unknown_poison
						killer = ROOT
					}
				}
			}
		}
	}

	option = {
		name = EVTOPTB105250

		remove_trait_silently_deceitful_effect = yes
		remove_trait_silently_envious_effect = yes
	}
}

# Host finds out/is poisoned
character_event = {
	id = 105251
	desc = EVTDESC105251
	picture = GFX_evt_spymaster

	is_triggered_only = yes

	option = {
		name = EVTOPTA105151

		trigger = { has_character_flag = lunatic_poison }

		clr_character_flag = lunatic_poison

		FROM = {
			show_scope_change = no

			imprison = ROOT
			set_character_flag = imprison_lunatic

			tooltip = {
				remove_title = title_food_taster

				reverse_opinion = {
					name = opinion_poisoner
					who = ROOT
					years = 5
				}
			}

			character_event = {
				id = 105253
				tooltip = EVTTOOLTIPA105253
			}
		}
	}

	option = {
		name = EVTOPTB105151

		trigger = { has_character_flag = poison_failed }

		clr_character_flag = poison_failed

		FROM = {
			show_scope_change = no

			imprison = ROOT
			set_character_flag = imprison_failed_poison

			tooltip = {
				remove_title = title_food_taster

				reverse_opinion = {
					name = opinion_poisoner
					who = ROOT
					years = 5
				}
			}

			character_event = {
				id = 105253
				tooltip = EVTTOOLTIPB105253
			}
		}
	}

	option = {
		name = EVTOPTC105151

		trigger = { has_character_flag = ill_poison }

		clr_character_flag = ill_poison

		FROM = {
			show_scope_change = no

			imprison = ROOT
			set_character_flag = imprison_ill

			tooltip = {
				remove_title = title_food_taster

				reverse_opinion = {
					name = opinion_poisoner
					who = ROOT
					years = 5
				}
			}

			character_event = {
				id = 105253
				tooltip = EVTTOOLTIPC105253
			}
		}
	}

	option = {
		name = {
			text = EVTOPTD105251
			trigger = { has_character_flag = lunatic_poison }
		}
		name = {
			text = EVTOPTE105151
			trigger = { has_character_flag = poison_failed }
		}
		name = {
			text = EVTOPTF105151
			trigger = { has_character_flag = ill_poison }
		}

		clr_character_flag = lunatic_poison
		clr_character_flag = poison_failed
		clr_character_flag = ill_poison

		FROM = {
			show_scope_change = no
			death = { death_reason = death_execution }
		}
	}
}

# Cupbearer is imprisoned
character_event = {
	id = 105253
	desc = EVTDESC105253
	picture = GFX_evt_into_the_dungeon

	is_triggered_only = yes

	option = {
		name = {
			text = EVTOPTA105253
			trigger = { has_character_flag = imprison_ill }
		}
		name = {
			text = EVTOPTB105253
			trigger = { has_character_flag = imprison_failed_poison }
		}
		name = {
			text = EVTOPTC105253
			trigger = { has_character_flag = imprison_lunatic }
		}

		clr_character_flag = imprison_ill
		clr_character_flag = imprison_failed_poison
		clr_character_flag = imprison_lunatic

		tooltip = {
			imprison = FROM
		}

		remove_title = title_food_taster

		reverse_opinion = {
			name = opinion_poisoner
			who = FROM
			years = 5
		}
	}
}