namespace = chancellor

##############################
# CHANCELLOR
#
# Job: action_improve_relations
# 	910: The Chancellor attempts to improve relations with a local noble
# 	911: The Chancellor attempts to sabotage the relations of a subject noble towards the official head of the religion
#	912: The Chancellor arranges a meeting with the faction leader
#
# Job: action_fabricate_claims
# 	913: The Chancellor fabricates a claim for his liege on a local landed noble
# 	914: A Noble finds out what the Chancellor is up to (trying to fabricate claims)
#
# Job: action_sow_dissent
# 	916: The Chancellor sows dissent between a noble and his liege
# 	917: Chancellor Discovered
#
##############################


##############################
# CHANCELLOR
# JOB: action_improve_relations
##############################

# 910: The Chancellor attempts to improve relations with lord
character_event = {
	id = chancellor.001
	title = evt_chancellor_001_title
	desc = evt_chancellor_001_desc_a
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	has_job_title = yes

	trigger = {
		has_job_action = action_improve_relations
		in_seclusion = no
		NOT = { has_character_modifier = bedridden_illness }

		location = {
			any_province_lord = {
				# No reason to improve relations with irrelevant barons
				trigger_if = {
					limit = { real_tier = BARON }

					OR = {
						same_liege = ROOT
						is_patrician = yes
					}
				}

				is_theocracy = no

				NOR = {
					is_liege_of = ROOT
					character = ROOT
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 120

		job_event_mtth_modifier_diplomacy_score = yes
		plus_councillor_job_events_opinion_score = yes

		mult_modifier = {
			factor = 1.05
			trait = slothful
		}
		mult_modifier = {
			factor = 1.05
			trait = deceitful
		}
		mult_modifier = {
			factor = 1.05
			trait = craven
		}
		mult_modifier = {
			factor = 1.05
			trait = arbitrary
		}
		mult_modifier = {
			factor = 0.9
			trait = grey_eminence
		}
		mult_modifier = {
			factor = 0.9
			trait = honest
		}
		mult_modifier = {
			factor = 0.9
			trait = socializer
		}
	}

	option = {
		name = evt_chancellor_001_option_a # I have succeeded

		hidden_effect = {
			location = {
				random_province_lord = {
					limit = {
						trigger_if = {
							limit = { real_tier = BARON }

							OR = {
								same_liege = ROOT
								is_patrician = yes
							}
						}

						is_theocracy = no

						NOR = {
							is_liege_of = ROOT
							character = ROOT
						}
					}

					character_event = {
						id = chancellor.002 # Inform the noble
						days = 7
					}
				}
			}
		}
	}
}

# 20100: Inform the noble
character_event = {
	id = chancellor.002
	desc = evt_chancellor_002_desc_a
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_002_option_a # I feel a new appreciation

		FROM = {
			liege = {
				letter_event = { id = chancellor.003 } # Inform liege
			}
		}
	}
}

# 20101: The liege is informed of the success
letter_event = {
	id = chancellor.003
	desc = evt_chancellor_003_desc_a
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes
	show_from_from = yes

	option = {
		name = PERFECT

		reverse_opinion = {
			name = opinion_improved_relations
			who = FROM
			years = 4
		}
	}
}

# 911: The Chancellor's attempts to improve relations with lord is sabotaged
character_event = {
	id = chancellor.101
	title = evt_chancellor_101_title
	desc = evt_chancellor_101_desc_a
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	has_job_title = yes

	trigger = {
		has_job_action = action_improve_relations
		in_seclusion = no
		NOT = { has_character_modifier = bedridden_illness }

		location = {
			any_province_lord = {
				trigger_if = {
					limit = { real_tier = BARON }

					OR = {
						same_liege = ROOT
						is_patrician = yes
					}
				}

				is_theocracy = no

				NOR = {
					is_liege_of = ROOT
					character = ROOT
				}
			}
		}
	}

	mean_time_to_happen = {
		years = 20

		job_event_mtth_modifier_inverted_diplomacy_score = yes
		plus_councillor_job_events_opinion_inverted_score = yes

		mult_modifier = {
			factor = 0.95
			trait = slothful
		}
		mult_modifier = {
			factor = 0.95
			trait = deceitful
		}
		mult_modifier = {
			factor = 0.95
			trait = craven
		}
		mult_modifier = {
			factor = 0.95
			trait = arbitrary
		}
		mult_modifier = {
			factor = 1.05
			trait = honest
		}
		mult_modifier = {
			factor = 1.05
			trait = socializer
		}
		mult_modifier = {
			factor = 1.05
			trait = grey_eminence
		}
	}

	option = {
		name = evt_chancellor_101_option_a # I have failed miserably

		hidden_effect = {
			location = {
				random_province_lord = {
					limit = {
						trigger_if = {
							limit = { real_tier = BARON }

							OR = {
								same_liege = ROOT
								is_patrician = yes
							}
						}

						is_theocracy = no

						NOR = {
							is_liege_of = ROOT
							character = ROOT
						}
					}

					character_event = {
						id = chancellor.102
						days = 7
					}
				}
			}
		}
	}
}

# 20110: Inform the noble
character_event = {
	id = chancellor.102
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	desc = {
		text = evt_chancellor_102_desc_a
		trigger = { NOT = { same_liege = FROM }	}
	}
	desc = {
		text = evt_chancellor_102_desc_b
		trigger = { same_liege = FROM }
	}

	is_triggered_only = yes

	option = {
		name = evt_chancellor_102_option_a

		FROM = {
			liege = {
				letter_event = { id = chancellor.103 }
			}
		}
	}
}

# 20111: The liege is informed of the failure
letter_event = {
	id = chancellor.103
	desc = evt_chancellor_103_desc_a
	border = GFX_event_letter_frame_diplomacy

	show_from_from = yes
	is_triggered_only = yes

	option = {
		name = evt_chancellor_103_option_a

		reverse_opinion = {
			name = opinion_insulted
			who = FROM
			years = 2
		}
	}
}

##############################
# CHANCELLOR
# JOB: action_fabricate_claims
##############################

# 913: The Chancellor fabricates a claim for his liege on a landed noble's title
character_event = {
	id = chancellor.201
	title = evt_chancellor_201_title
	desc = evt_chancellor_201_desc_a
	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	has_job_title = yes

	trigger = {
		has_job_action = action_fabricate_claims
		in_seclusion = no

		NOR = {
			has_character_modifier = bedridden_illness
			has_character_modifier = bribed_by_noble_timer
		}

		liege = {
			ROOT = {
				location = {
					OR = {
						county = {
							NOT = { claimed_by = PREVPREVPREV } # liege

							holder_scope = {
								NOR = {
									is_liege_of = ROOT
									character = ROOT

									# Not the Pope
									trigger_if = {
										limit = { controls_religion = yes }
										religion = catholic
									}
								}
							}
						}

						AND = {
							ROOT = {
								diplomacy >= 15
							}

							duchy = {
								NOT = { claimed_by = PREVPREVPREV } # liege

								holder_scope = {
									NOR = {
										is_liege_of = ROOT
										character = ROOT

										# Not the Pope
										trigger_if = {
											limit = { controls_religion = yes }
											religion = catholic
										}
									}
								}
							}
						}

						AND = {
							ROOT = {
								liege = {
									has_ambition = obj_become_king
									NOT = { has_character_flag = kingdom_claimed_with_ambition }
								}
							}

							kingdom = {
								NOT = { claimed_by = PREVPREVPREV } # liege

								holder_scope = {
									owns = PREVPREV

									NOR = {
										is_liege_of = ROOT
										character = ROOT

										# Not the Pope
										trigger_if = {
											limit = { controls_religion = yes }
											religion = catholic
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		years = 20

		job_event_mtth_modifier_diplomacy_score = yes
		plus_councillor_job_events_opinion_score = yes

		mult_modifier = {
			factor = 0.75

			liege = {
				any_owned_bloodline = {
					has_bloodline_flag = bloodline_faster_claims
					bloodline_is_active_for = PREV
				}
			}
		}

		mult_modifier = {
			factor = 0.75

			# If chancellor is also your relative
			any_owned_bloodline = {
				has_bloodline_flag = bloodline_faster_claims
				bloodline_is_active_for = PREV
			}
		}

		# CK2Plus
		mult_modifier = {
			factor = 0.75

			liege = {
				ai = no
				demesne_size < 3

				NOT = {
					any_claim = {
						lower_real_tier_than = KING
					}
				}
			}

			NOT = { has_global_flag = hardcore_mode }
		}

		mult_modifier = {
			factor = 2.0
			liege = { ai = yes }
		}

		mult_modifier = {
			factor = 0.95
			trait = grey_eminence
		}

		mult_modifier = {
			factor = 0.95
			trait = master_schemer
		}

		mult_modifier = {
			factor = 1.05
			trait = deceitful
		}

		mult_modifier = {
			factor = 1.05
			trait = arbitrary
		}

		mult_modifier = {
			factor = 1.05
			trait = cruel
		}

		mult_modifier = {
			factor = 1.05
			trait = honest
		}

		mult_modifier = {
			factor = 1.05
			trait = slothful
		}

		mult_modifier = {
			factor = 1.05
			trait = just
		}

		mult_modifier = {
			factor = 0.5

			has_game_rule = {
				name = fabricate_claim_rate
				value = double
			}
		}

		mult_modifier = {
			factor = 0.33

			has_game_rule = {
				name = fabricate_claim_rate
				value = triple
			}
		}

		mult_modifier = {
			factor = 0.25

			has_game_rule = {
				name = fabricate_claim_rate
				value = quadruple
			}
		}

		mult_modifier = {
			factor = 2.0

			has_game_rule = {
				name = fabricate_claim_rate
				value = half
			}
		}
	}

	option = {
		name = evt_chancellor_201_option_a

		hidden_effect = {
			# Try to claim Kingdom title - only available with Become King ambition
			if = {
				limit = {
					liege = {
						has_ambition = obj_become_king
						NOT = { has_character_flag = kingdom_claimed_with_ambition }

						ROOT = {
							location = {
								kingdom = {
									NOT = { claimed_by = PREVPREVPREV } # liege

									holder_scope = {
										owns = PREVPREV
										NOT = { character = ROOT }
									}
								}
							}
						}
					}
				}

				random = {
					chance = 2

					mult_modifier = {
						factor = 2.5 # 5% chance
						diplomacy >= 15
					}

					mult_modifier = {
						factor = 2 # 10% chance
						diplomacy >= 18
					}

					mult_modifier = {
						factor = 2 # 20% chance
						diplomacy >= 22
					}

					location = {
						kingdom = {
							save_event_target_as = target_title

							holder_scope = {
								character_event = {
									id = chancellor.202
									days = 1
								}
							}
						}
					}

					liege = {
						set_character_flag = kingdom_claimed_with_ambition
					}

					set_character_flag = claim_done
				}
			}

			# Try to fabricate a duchy claim
			else_if = {
				limit = {
					liege = {
						ROOT = {
							location = {
								duchy = {
									NOT = { claimed_by = PREVPREVPREV } # liege

									holder_scope = {
										owns = PREVPREV

										NOR = {
											is_liege_of = ROOT
											character = ROOT
										}
									}
								}
							}
						}
					}
				}

				random = {
					chance = 15

					mult_modifier = {
						factor = 1.333 # 20% chance
						diplomacy >= 15
					}

					mult_modifier = {
						factor = 1.25 # 25% chance
						diplomacy >= 20
					}

					location = {
						duchy = {
							save_event_target_as = target_title

							holder_scope = {
								character_event = {
									id = chancellor.202
									days = 1
								}
							}
						}
					}

					set_character_flag = claim_done
				}
			}

			# If the kingdom/duchy attempts failed, always fabricate  county claim
			if = {
				limit = {
					NOT = { has_character_flag = claim_done }

					liege = {
						ROOT = {
							location = {
								county = {
									NOT = { claimed_by = PREVPREVPREV } # liege

									holder_scope = {
										owns = PREVPREV

										NOR = {
											is_liege_of = ROOT
											character = ROOT
										}
									}
								}
							}
						}
					}
				}

				location = {
					county = {
						save_event_target_as = target_title

						holder_scope = {
							character_event = {
								id = chancellor.202
								days = 1
							}
						}
					}
				}
			}

			clr_character_flag = claim_done
		}
	}
}

# 20130: The noble is informed about the claim
character_event = {
	id = chancellor.202
	desc = evt_chancellor_202_desc_a
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_202_option_a

		FROM = {
			liege = {
				letter_event = {
					id = chancellor.203
					days = 1
				}
			}
		}
	}
}

# 20131: The liege is informed and has a choice to press the claim or not
# County claim
letter_event = {
	id = chancellor.203
	border = GFX_event_letter_frame_diplomacy

	desc = {
		text = evt_chancellor_203_desc_a # I have a forged a county claim
		trigger = { event_target:target_title = { real_tier = COUNT } }
	}
	desc = {
		text = evt_chancellor_203_desc_b # I have a forged a duchy claim
		trigger = { event_target:target_title = { real_tier = DUKE } }
	}
	desc = {
		text = evt_chancellor_203_desc_c # I have a forged a kingdom claim
		trigger = { event_target:target_title = { real_tier = KING } }
	}

	is_triggered_only = yes
	show_from_from = yes

	trigger = {
		FROMFROM = {
			has_job_action = action_fabricate_claims

			event_target:target_title = {
				NOT = { claimed_by = ROOT }
			}
		}
	}

	option = { # Emperor or King
		name = evt_chancellor_203_option_a # Press the Claim

		if = {
			limit = {
				event_target:target_title = {
					real_tier = COUNT
				}
			}

			if = {
				limit = { higher_real_tier_than = DUKE }

				scaled_wealth = {
					value = -1.0
					min = -150
				}

				prestige = -150
			}
			else_if = {
				limit = { real_tier = DUKE }

				scaled_wealth = {
					value = -1.0
					min = -100
				}

				prestige = -100
			}
			else = {
				scaled_wealth = {
					value = -0.75
					min = -75
				}

				prestige = -50
			}
		}
		else_if = { # Duchy claim
			limit = {
				event_target:target_title = {
					tier = DUKE
				}
			}

			if = {
				limit = { higher_real_tier_than = DUKE }

				scaled_wealth = {
					value = -3.0
					min = -300
				}

				prestige = -300
			}
			else_if = {
				limit = { real_tier = DUKE }

				scaled_wealth = {
					value = -2.0
					min = -200
				}

				prestige = -200
			}
			else = {
				scaled_wealth = {
					value = -1.0
					min = -100
				}

				prestige = -100
			}
		}
		else = { # Kingdom claim
			if = {
				limit = { higher_real_tier_than = DUKE }

				scaled_wealth = {
					value = -3.0
					min = -300
				}

				prestige = -300
			}
			else_if = {
				limit = { real_tier = DUKE }

				scaled_wealth = {
					value = -3.0
					min = -300
				}

				prestige = -200
			}
			else = {
				scaled_wealth = {
					value = -1.5
					min = -150
				}

				prestige = -100
			}
		}

		add_claim = event_target:target_title

		FROM = {
			show_scope_change = no

			if = {
				limit = {
					event_target:target_title = {
						real_tier = COUNT
					}
				}

				opinion = {
					name = opinion_furious
					who = ROOT
					years = 10
				}
			}
			else = {
				opinion = {
					name = opinion_furious
					who = ROOT
					years = 20
				}
			}

			character_event = {
				id = chancellor.204
				days = 7
			}
		}

		if = {
			limit = { has_global_flag = ck2_tutorial_2 }
			long_character_event = { id = 107300 }
		}

		ai_chance = {
			factor = 90

			trigger = {
				trigger_if = {
					limit = {
						event_target:target_title = {
							real_tier = COUNT
						}
					}

					scaled_wealth = 1.25

					NOR = {
						is_married = FROM
						is_primary_heir = FROM
					}
				}
				trigger_else = {
					scaled_wealth = 2.25
				}
			}
		}
	}

	option = {
		name = evt_chancellor_203_option_b # Let it go

		if = {
			limit = {
				event_target:target_title = {
					real_tier = COUNT
				}
			}

			piety = 10
		}
		else = {
			piety = 20
		}

		ai_chance = {
			factor = 10

			trigger = {
				trigger_if = {
					limit = {
						event_target:target_title = {
							real_tier = COUNT
						}
					}

					OR = {
						NOT = { scaled_wealth = 1.25 }

						is_married = FROM
						is_primary_heir = FROM
					}
				}
				trigger_else = {
					NOT = { scaled_wealth = 2.25 }
				}
			}
		}
	}
}

# 20132: The noble is informed if the claim is pressed, and is insulted
character_event = {
	id = chancellor.204
	desc = evt_chancellor_204_desc_a
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_204_option_a

		hidden_effect = {
			remove_opinion = {
				name = opinion_furious
				who = FROM
			}
		}

		opinion = {
			name = opinion_furious
			who = FROM
			years = 10
		}
	}
}

# 914: A Noble finds out that the Chancellor is trying to fabricate claims
character_event = {
	id = chancellor.301
	title = evt_chancellor_301_title
	desc = evt_chancellor_301_desc_a
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	has_job_title = yes

	trigger = {
		has_job_action = action_fabricate_claims
		in_seclusion = no

		NOR = {
			has_character_modifier = bedridden_illness
			has_character_modifier = bribed_by_noble_timer
		}

		location = {
			owner = {
				NOR = {
					is_liege_of = ROOT
					character = ROOT
				}
			}
		}
	}

	mean_time_to_happen = {
		years = 10

		job_event_mtth_modifier_inverted_diplomacy_score = yes
		plus_councillor_job_events_opinion_inverted_score = yes

		mult_modifier = {
			factor = 1.25

			liege = {
				any_owned_bloodline = {
					has_bloodline_flag = bloodline_faster_claims
					bloodline_is_active_for = PREV
				}
			}
		}

		mult_modifier = {
			factor = 1.25

			# If chancellor is also your relative
			any_owned_bloodline = {
				has_bloodline_flag = bloodline_faster_claims
				bloodline_is_active_for = PREV
			}
		}
	}

	option = {
		name = evt_chancellor_301_option_a

		location = {
			show_scope_change = no

			owner = {
				show_scope_change = no

				character_event = {
					id = chancellor.302
					days = 7
					tooltip = evt_chancellor_301_option_a_tooltip
				}
			}
		}
	}
}

# 20140 - The noble knows about the fabricated claims
character_event = {
	id = chancellor.302
	desc = evt_chancellor_302_desc_a
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_302_option_a # Make him disappear...

		piety = -10

		random_list = {
			50 = {
				FROM = {
					show_scope_change = no

					character_event = {
						id = chancellor.303 # Assassination succeeds
						days = 7
						tooltip = evt_chancellor_302_option_a_tooltip_1
					}
				}
			}

			50 = {
				character_event = {
					id = chancellor.306 # Assassination failed
					days = 7
					tooltip = evt_chancellor_302_option_a_tooltip_2
				}
			}
		}

		ai_chance = { factor = 40 }
	}

	option = {
		name = evt_chancellor_302_option_b # Try to bribe him

		trigger = { wealth >= 50 }

		wealth = -50

		FROM = {
			show_scope_change = no

			letter_event = {
				id = chancellor.307
				days = 7
				tooltip = evt_chancellor_302_option_b_tooltip
			}
		}

		ai_chance = { factor = 30 }
	}

	option = {
		name = evt_chancellor_302_option_c # I better let it be for now

		ai_chance = { factor = 30 }
	}
}

# 20141 - Chancellor is assassinated...
character_event = {
	id = chancellor.303
	desc = evt_chancellor_303_desc_a
	picture = GFX_evt_death
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_303_option_a

		FROM = {
			character_event = { id = chancellor.304 }
		}
	}
}

# 20142 - Noble is informed that the assassination attempt succeeded
character_event = {
	id = chancellor.304
	desc = evt_chancellor_304_desc_a
	picture = GFX_evt_death
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = EXCELLENT

		FROM = {
			liege = {
				character_event = { id = chancellor.305 }
			}
		}
	}
}

# 20147 - The liege is informed about the Chancellor's death
character_event = {
	id = chancellor.305
	desc = evt_chancellor_305_desc_a
	picture = GFX_evt_death
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes
	show_from_from = yes

	option = {
		name = evt_chancellor_305_option_a

		FROMFROM = {
			show_scope_change = no

			death = {
				death_reason = death_murder_unknown
				killer = FROM
			}
		}
	}
}

# 20143 - Noble is informed that the assassination attempt failed
character_event = {
	id = chancellor.306
	desc = evt_chancellor_306_desc_a
	picture = GFX_evt_death
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	ai = no

	option = {
		name = evt_chancellor_306_option_a
	}
}

# 20144 - Noble tries to bribe Chancellor
letter_event = {
	id = chancellor.307
	desc = evt_chancellor_307_desc_a
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_307_option_a

		wealth = 50

		FROM = {
			show_scope_change = no

			letter_event = {
				id = chancellor.308
				tooltip = evt_chancellor_307_option_a_tooltip
			}
		}

		add_character_modifier = {
			name = bribed_by_noble_timer
			years = 1
			hidden = yes
		}
	}

	option = {
		name = evt_chancellor_307_option_b

		prestige = 5

		FROM = {
			show_scope_change = no

			letter_event = {
				id = chancellor.309
				tooltip = evt_chancellor_307_option_b_tooltip
			}
		}
	}
}

# 20145 - Noble is informed that the Chancellor accepted the bribe
letter_event = {
	id = chancellor.308
	desc = evt_chancellor_308_desc_a
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes

	ai = no

	option = {
		name = EXCELLENT
	}
}

# 20146 - Noble is informed that the Chancellor didn't accept the bribe
letter_event = {
	id = chancellor.309
	desc = evt_chancellor_309_desc_a
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_309_option_a

		wealth = 50
	}
}

##############################
# CHANCELLOR
# JOB: action_sow_dissent
##############################

# 916: The Chancellor sows dissent between a liege and his vassals
character_event = {
	id = chancellor.401
	title = evt_chancellor_401_title
	desc = evt_chancellor_401_desc_a
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy

	has_job_title = yes

	trigger = {
		has_job_action = action_sow_dissent
		in_seclusion = no
		NOT = { has_character_modifier = bedridden_illness }

		location = {
			owner = {
				religion = ROOT

				ROOT = {
					liege = {
						religion = PREVPREV
					}
				}

				any_vassal = {
					is_playable = yes

					NOR = {
						is_liege_of = ROOT
						character = ROOT
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		years = 20

		job_event_mtth_modifier_diplomacy_score = yes
		plus_councillor_job_events_opinion_score = yes

		mult_modifier = {
			factor = 0.75

			liege = {
				any_owned_bloodline = {
					has_bloodline_flag = bloodline_faster_dissent
					bloodline_is_active_for = PREV
				}
			}
		}

		mult_modifier = {
			factor = 0.75

			# If chancellor is also your relative
			any_owned_bloodline = {
				has_bloodline_flag = bloodline_faster_dissent
				bloodline_is_active_for = PREV
			}
		}

		# Ck2Plus
		mult_modifier = {
			factor = 0.95
			trait = grey_eminence
		}

		mult_modifier = {
			factor = 0.95
			trait = master_schemer
		}

		mult_modifier = {
			factor = 0.95
			trait = deceitful
		}

		mult_modifier = {
			factor = 0.95
			trait = arbitrary
		}

		mult_modifier = {
			factor = 0.95
			intrigue >= 15
		}
	}

	option = {
		name = evt_chancellor_401_option_a

		hidden_effect = {
			location = {
				owner = {
					any_vassal = {
						limit = {
							is_playable = yes

							NOR = {
								is_liege_of = ROOT
								character = ROOT
							}
						}

						character_event = {
							id = chancellor.402
							days = 7
						}
					}

					character_event = {
						id = chancellor.403
						days = 7
						tooltip = evt_chancellor_402_option_a_tooltip
					}
				}
			}
		}
	}
}

# 20160: The local noble start disliking his liege
character_event = {
	id = chancellor.402
	desc = evt_chancellor_402_desc_a
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_402_option_a

		opinion = {
			name = dissent_sowed
			who = liege
			years = 5
		}

		FROM = {
			liege = {
				letter_event = { id = chancellor.404 } # Inform liege
			}
		}
	}
}

# 20161: The province owner is informed
character_event = {
	id = chancellor.403
	desc = evt_chancellor_403_desc_a
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_403_option_a

		tooltip = {
			any_vassal = {
				limit = {
					is_playable = yes

					NOR = {
						is_liege_of = FROM
						character = FROM
					}
				}

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

		FROM = {
			liege = {
				letter_event = {
					id = chancellor.404
					days = 7
				}
			}
		}
	}
}

# 20162: The liege of the Chancellor is informed
letter_event = {
	id = chancellor.404
	desc = evt_chancellor_404_desc_a
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes
	show_from_from = yes

	ai = no

	option = {
		name = EXCELLENT
	}
}

# 917: Chancellor Discovered
character_event = {
	id = chancellor.501
	title = evt_chancellor_501_title
	desc = evt_chancellor_501_desc_a
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy

	has_job_title = yes

	trigger = {
		has_job_action = action_sow_dissent
		in_seclusion = no
		NOT = { has_character_modifier = bedridden_illness }

		location = {
			owner = {
				any_vassal = {
					is_playable = yes

					NOR = {
						is_liege_of = ROOT
						character = ROOT
					}
				}

				NOR = {
					is_liege_of = ROOT
					character = ROOT
				}
			}
		}
	}

	mean_time_to_happen = {
		years = 10

		job_event_mtth_modifier_inverted_diplomacy_score = yes
		plus_councillor_job_events_opinion_inverted_score = yes

		mult_modifier = {
			factor = 1.25

			liege = {
				any_owned_bloodline = {
					has_bloodline_flag = bloodline_faster_dissent
					bloodline_is_active_for = PREV
				}
			}
		}

		mult_modifier = {
			factor = 1.25

			# If chancellor is also your relative
			any_owned_bloodline = {
				has_bloodline_flag = bloodline_faster_dissent
				bloodline_is_active_for = PREV
			}
		}
	}

	option = {
		name = evt_chancellor_501_option_a

		location = {
			random_province_lord = {
				limit = {
					is_playable = yes

					NOR = {
						is_liege_of = ROOT
						character = ROOT
					}
				}

				character_event = {
					id = chancellor.502
					tooltip = evt_chancellor_501_option_a_tooltip
				}
			}
		}
	}
}

# 20170: The local noble is informed
character_event = {
	id = chancellor.502
	desc = evt_chancellor_502_desc_a
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_502_option_a

		FROM = {
			show_scope_change = no

			opinion = {
				name = opinion_arrest_attempt
				who = ROOT
				years = 20
			}

			imprison = ROOT
		}

		FROM = {
			character_event = { id = chancellor.503 }

			liege = {
				letter_event = { id = chancellor.504 }
			}
		}

		# liege = {
		# 	letter_event = { id = chancellor.505 }
		# }
	}

	option = {
		name = evt_chancellor_502_option_b

		FROM = {
			show_scope_change = no

			liege = {
				show_scope_change = no

				reverse_opinion = {
					name = opinion_furious
					who = ROOT
					years = 2
				}
			}
		}

		FROM = {
			liege = {
				letter_event = { id = chancellor.506 }
			}
		}

		liege = {
			letter_event = { id = chancellor.507 }
		}

		ai_chance = { factor = 0 }
	}
}

# 20171: The Chancellor is imprisoned
character_event = {
	id = chancellor.503
	desc = evt_chancellor_503_desc_a
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_503_option_a

		prestige = -10
	}
}

# 20172: The Chancellor's liege is informed about imprisonment
letter_event = {
	id = chancellor.504
	desc = evt_chancellor_504_desc_a
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_504_option_a

		prestige = -10
	}
}

# 20173: The local noble informs his liege about imprisonment
# letter_event = {
# 	id = chancellor.505
# 	desc = evt_chancellor_505_desc_a
# 	border = GFX_event_letter_frame_diplomacy
#
# 	is_triggered_only = yes
#
# 	option = {
# 		name = evt_chancellor_505_option_a
#
# 		FROMFROM = {
# 			show_scope_change = no
#
# 			liege = {
# 				show_scope_change = no
#
# 				reverse_opinion = {
# 					name = opinion_furious
# 					who = ROOT
# 					years = 2
# 				}
#
# 				letter_event = { id = chancellor.506 }
# 			}
# 		}
# 	}
# }

# 20175: The Chancellor's liege is informed about the reaction of the noble
letter_event = {
	id = chancellor.506
	desc = evt_chancellor_506_desc_a
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_506_option_a

		prestige = -5

		tooltip = {
			reverse_opinion = {
				name = opinion_furious
				who = FROM
				years = 2
			}
		}
	}
}

# 20174: The local noble informs his liege about the Chancellor's doing
letter_event = {
	id = chancellor.507
	desc = evt_chancellor_507_desc_a
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_507_option_a

		FROMFROM = {
			show_scope_change = no

			liege = {
				show_scope_change = no

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

				letter_event = { id = chancellor.508 }
			}
		}
	}
}

# 20176: The Chancellor's liege is informed about the reaction of the noble's liege
letter_event = {
	id = chancellor.508
	desc = evt_chancellor_508_desc_a
	border = GFX_event_letter_frame_diplomacy

	is_triggered_only = yes

	option = {
		name = evt_chancellor_508_option_a

		prestige = -10

		tooltip = {
			reverse_opinion = {
				name = opinion_furious
				who = FROM
				years = 2
			}
		}
	}
}

# 20235: The Chancellor successfully increases the sentiment of the local clan
character_event = {
	id = chancellor.601
	title = evt_chancellor_601_title
	desc = evt_chancellor_601_desc_a
	picture = GFX_evt_market
	border = GFX_event_normal_frame_diplomacy

	has_job_title = yes

	trigger = {
		has_job_action = action_clan_sentiment
		in_seclusion = no
		NOT = { has_character_modifier = bedridden_illness }

		location = {
			owner = {
				is_nomadic = yes

				ROOT = {
					liege = {
						OR = {
							is_liege_of = PREVPREV
							vassal_of = PREVPREV
							same_liege = PREVPREV
						}

						NOT = { character = PREVPREV }
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		years = 5

		mult_modifier = {
			factor = 10

			clan_title = {
				clan = yes # Is the head of a Clan
			}

			owns = location # This is my own clan

			opinion = {
				who = liege
				value < 0
			}
		}

		job_event_mtth_modifier_diplomacy_score = yes
	}

	immediate = {
		liege = {
			clan_title = {
				save_event_target_as = liege_clan
			}
		}

		location = {
			owner = {
				save_event_target_as = target_chief
			}
		}
	}

	option = {
		name = evt_chancellor_601_option_a # Increase the sentiments vs the Khan's Clan

		event_target:target_chief = {
			show_scope_change = no

			clan_title = {
				show_scope_change = no

				clan_opinion = {
					name = clan_propaganda_effort
					who = event_target:liege_clan
					years = 5
				}
			}
		}

		liege = {
			character_event = { id = chancellor.602 }
		}
	}

	option = {
		name = evt_chancellor_601_option_b # Do nothing

		ai_chance = { factor = 0 }
	}
}

# 20236: The liege is informed of the success
character_event = {
	id = chancellor.602
	title = evt_chancellor_601_title
	desc = evt_chancellor_602_desc_a
	picture = GFX_evt_market
	border = GFX_event_normal_frame_diplomacy

	is_triggered_only = yes

	ai = no

	option = {
		name = EXCELLENT

		tooltip = {
			event_target:target_chief = {
				show_scope_change = no

				clan_title = {
					show_scope_change = no

					clan_opinion = {
						name = clan_propaganda_effort
						who = event_target:liege_clan
						years = 5
					}
				}
			}
		}
	}
}