##############################
# 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 = 910
	title = "EVTNAME910"
	desc = "EVTDESC910"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_improve_relations
		NOT = { has_character_modifier = in_seclusion }
		location = {
			any_province_lord = {
				OR = {
					higher_tier_than = baron
					is_patrician = yes
					liege = { is_liege_of = ROOT }
				}
				is_theocracy = no
				NOT = { is_liege_of = ROOT }
				NOT = { character = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 120

		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 9 }
		}
		modifier = {
			factor = 1.05
			trait = slothful
		}
		modifier = {
			factor = 1.05
			trait = deceitful
		}
		modifier = {
			factor = 1.05
			trait = craven
		}
		modifier = {
			factor = 1.05
			trait = arbitrary
		}			
		modifier = {
			factor = 0.9
			diplomacy = 11
		}
		modifier = {
			factor = 0.9
			diplomacy = 12
		}
		modifier = {
			factor = 0.9
			diplomacy = 13
		}
		modifier = {
			factor = 0.9
			diplomacy = 14
		}
		modifier = {
			factor = 0.9
			diplomacy = 15
		}
		modifier = {
			factor = 0.9
			diplomacy = 16
		}
		modifier = {
			factor = 0.9
			diplomacy = 17
		}
		modifier = {
			factor = 0.9
			diplomacy = 18
		}
		modifier = {
			factor = 0.9
			diplomacy = 19
		}
		modifier = {
			factor = 0.9
			diplomacy = 20
		}
		modifier = {
			factor = 0.9
			diplomacy = 21
		}
		modifier = {
			factor = 0.9
			diplomacy = 22
		}
		modifier = {
			factor = 0.9
			diplomacy = 23
		}
		modifier = {
			factor = 0.9
			diplomacy = 24
		}
		modifier = {
			factor = 0.9
			diplomacy = 25
		}
		modifier = {
			factor = 0.9
			trait = grey_eminence
		}
		modifier = {
			factor = 0.9
			trait = honest
		}
		modifier = {
			factor = 0.9
			trait = socializer
		}	
		modifier = {
			factor = 0.9
			stewardship = 15
		}		
	}

	option = {
		name = "EVTOPTA910"
		hidden_tooltip = {
			location = {
				random_province_lord = {
					limit = {
						OR = {
							higher_tier_than = baron
							is_patrician = yes
							liege = { is_liege_of = ROOT }
						}
						is_theocracy = no
						NOT = { is_liege_of = ROOT }
						NOT = { character = ROOT }
					}
					character_event = { id = 20100 days = 7 }
				}
			}
		}
	}
}

# 20100: Inform the noble
character_event = {
	id = 20100
	desc = "EVTDESC20100"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20100"
		hidden_tooltip = {
			FROM = {
				liege = { letter_event = { id = 20101 } }
			}
		}
	}
}

# 20101: The liege is informed of the success
letter_event = {
	id = 20101
	desc = "EVTDESC20101"
	border = GFX_event_letter_frame_diplomacy
	show_from_from = yes

	is_triggered_only = yes

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


# 911: The Chancellor's attempts to improve relations with lord is sabotaged
character_event = {
	id = 911
	title = "EVTNAME911"
	desc = "EVTDESC911"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_improve_relations
		NOT = { has_character_modifier = in_seclusion }
		location = {
			any_province_lord = {
				OR = {
					higher_tier_than = baron
					is_patrician = yes
					liege = { is_liege_of = ROOT }
				}
				is_theocracy = no
				NOT = { is_liege_of = ROOT }
				NOT = { character = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 240

		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 0.9
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 1.05
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 0.95
			NOT = { diplomacy = 1 }
		}
		modifier = {
			factor = 0.95
			NOT = { diplomacy = 2 }
		}
		modifier = {
			factor = 0.95
			NOT = { diplomacy = 3 }
		}
		modifier = {
			factor = 0.95
			NOT = { diplomacy = 4 }
		}
		modifier = {
			factor = 0.95
			NOT = { diplomacy = 5 }
		}
		modifier = {
			factor = 0.95
			NOT = { diplomacy = 6 }
		}
		modifier = {
			factor = 0.95
			NOT = { diplomacy = 7 }
		}
		modifier = {
			factor = 0.95
			NOT = { diplomacy = 8 }
		}
		modifier = {
			factor = 0.95
			NOT = { diplomacy = 9 }
		}
		modifier = {
			factor = 0.95
			trait = slothful
		}
				modifier = {
			factor = 0.95
			trait = deceitful
		}
				modifier = {
			factor = 0.95
			trait = craven
		}
				modifier = {
			factor = 0.95
			trait = arbitrary
		}
		modifier = {
			factor = 1.05
			diplomacy = 11
		}
		modifier = {
			factor = 1.05
			diplomacy = 12
		}
		modifier = {
			factor = 1.05
			diplomacy = 13
		}
		modifier = {
			factor = 1.05
			diplomacy = 14
		}
		modifier = {
			factor = 1.05
			diplomacy = 15
		}
		modifier = {
			factor = 1.05
			diplomacy = 16
		}
		modifier = {
			factor = 1.05
			diplomacy = 17
		}
		modifier = {
			factor = 1.05
			diplomacy = 18
		}
		modifier = {
			factor = 1.05
			diplomacy = 19
		}
		modifier = {
			factor = 1.05
			diplomacy = 20
		}
		modifier = {
			factor = 1.05
			diplomacy = 21
		}
		modifier = {
			factor = 1.05
			diplomacy = 22
		}
		modifier = {
			factor = 1.05
			diplomacy = 23
		}
		modifier = {
			factor = 1.05
			diplomacy = 24
		}
		modifier = {
			factor = 1.05
			diplomacy = 25
		}
		modifier = {
			factor = 1.05
			trait = honest
		}
		modifier = {
			factor = 1.05
			trait = socializer
		}
		modifier = {
			factor = 1.05
			trait = grey_eminence
		}
	}

	option = {
		name = "EVTOPTA911"
		hidden_tooltip = {
			location = {
				random_province_lord = {
					limit = {
						OR = {
							higher_tier_than = baron
							is_patrician = yes
							liege = { is_liege_of = ROOT }
						}
						is_theocracy = no
						NOT = { is_liege_of = ROOT }
						NOT = { character = ROOT }
					}
					character_event = { id = 20110 days = 7 }
				}
			}
		}
	}
}

# 20110: Inform the noble
character_event = {
	id = 20110
	desc = {
		text = "EVTDESCA20110"
		trigger = { NOT = { same_liege = FROM }	}
	}
	desc = {
		text = "EVTDESCB20110"
		trigger = { same_liege = FROM }
	}
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20110"
		hidden_tooltip = {
			FROM = {
				liege = { letter_event = { id = 20111 } }
			}
		}
	}
}

# 20111: The liege is informed of the failure
letter_event = {
	id = 20111
	desc = "EVTDESC20111"
	border = GFX_event_letter_frame_diplomacy
	show_from_from = yes

	is_triggered_only = yes

	option = {
		name = "EVTOPTA20111"
		FROM = {
			opinion = {
				modifier = opinion_insulted
				who = ROOT
				years = 5
			}
		}
	}
}


# 912: The Chancellor arranges a meeting with a faction
character_event = {
	id = 912
	title = EVTNAME912
	desc = EVTDESC912
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy

	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_improve_relations
		NOT = { has_character_modifier = in_seclusion }
		location = {
			owner = {
				same_liege = ROOT
				independent = no
				in_command_trigger = no
				primary_title = { higher_tier_than = BARON }
				OR = {
					leads_faction = faction_court
					leads_faction = faction_prosperity
					leads_faction = faction_glory
					leads_faction = faction_tradition
				}
				OR = {
					NOT = { has_character_flag = faction_negotiate }
					had_character_flag = { flag = faction_negotiate days = 1825 }
				}
				NOR = {
					is_liege_of = ROOT
					character = ROOT
				}
				is_not_busy_trigger = yes
			}
		}
		liege = {
			NOR = {
				has_character_flag = faction_court_war
				has_character_flag = faction_prosperity_war
				has_character_flag = faction_glory_war
				has_character_flag = faction_tradition_war
				has_character_flag = faction_pretender_war
				has_character_flag = faction_separatist_war
				has_character_flag = faction_religious_war
				has_character_flag = faction_succession_war
			}
		}
	}
	
	immediate = {
		location = {
			owner = {
				save_event_target_as = faction_leader
			}
		}
	}
	
	mean_time_to_happen = {
		months = 100
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 8 }
		}
		modifier = {
			factor = 0.9
			diplomacy = 12
		}
		modifier = {
			factor = 0.9
			diplomacy = 14
		}
		modifier = {
			factor = 0.9
			diplomacy = 16
		}
		modifier = {
			factor = 0.9
			diplomacy = 18
		}
		modifier = {
			factor = 0.9
			diplomacy = 20
		}
		modifier = {
			factor = 0.9
			diplomacy = 22
		}
		modifier = {
			factor = 0.9
			diplomacy = 24
		}
	}
	
	option = {
		name = EVTOPTA912 #Inform the liege
		event_target:faction_member = { set_character_flag = faction_negotiate }
		liege = { letter_event = { id = PlusFaction.145 tooltip = NEGOTIATE_FACTION_INFORM } }
	}
}


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

# 913: The Chancellor fabricates a claim for his liege on a landed noble's title
character_event = {
	id = 913
	title = EVTNAME913
	desc = EVTDESC913
	picture = GFX_evt_council
	border = GFX_event_normal_frame_diplomacy

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_fabricate_claims
		NOT = { has_character_modifier = in_seclusion }
		NOT = { has_character_modifier = bribed_by_noble_timer }
		liege = {
			prestige = 0
			ROOT = {
				location = {
					OR = {
						county = {
							NOT = { claimed_by = PREVPREVPREV }
							holder_scope = {
								NOT = { is_liege_of = ROOT }
								NOT = { character = ROOT }
								NOT = {
									AND = {
										religion = catholic
										ROOT = { liege = { religion_head = { character = PREVPREVPREV } } }
									}
								}
							}
						}
						AND = {
							duchy = {
								NOT = { claimed_by = PREVPREVPREV }
								holder_scope = {
									NOT = { is_liege_of = ROOT }
									NOT = { character = ROOT }
									NOT = {
										AND = {
											religion = catholic
											ROOT = { liege = { religion_head = { character = PREVPREVPREV } } }
										}
									}
								}
							}
							ROOT = { diplomacy = 15 }
						}
						AND = {
							ROOT = {
								liege = { 
									has_ambition = obj_become_king
									NOT = { has_character_flag = kingdom_claimed_with_ambition }
								}
							}
							kingdom = {
								NOT = { claimed_by = PREVPREVPREV }
								holder_scope = {
									NOT = { is_liege_of = ROOT }
									NOT = { character = ROOT }
									NOT = {
										AND = {
											religion = catholic
											ROOT = { liege = { religion_head = { character = PREVPREVPREV } } }
										}
									}
								}
							}
						}
					}
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 240
		modifier = {
			factor = 0.75
			NOT = { has_global_flag = hardcore_mode }
			liege = {
				ai = no
				NOT = { any_claim = { lower_tier_than = KING } }
				NOT = { demesne_size = 3 }
			}
		}
		modifier = {
			factor = 2.0
			liege = { ai = yes }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -100 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -75 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -50 } }
		}
		modifier = {
			factor = 1.1
			NOT = { opinion = { who = liege value = -25 } }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 25 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 50 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 75 }
		}
		modifier = {
			factor = 0.95
			opinion = { who = liege value = 100 }
		}
		modifier = {
			factor = 0.95
			trait = grey_eminence
		}
		modifier = {
			factor = 0.95
			trait = schemer
		}
		modifier = {
			factor = 1.05
			trait = deceitful
		}
		modifier = {
			factor = 1.05
			trait = arbitrary
		}
		modifier = {
			factor = 1.05
			trait = cruel
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 1 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 2 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 3 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 4 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 5 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 6 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 7 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 8 }
		}
		modifier = {
			factor = 1.05
			NOT = { diplomacy = 9 }
		}
		modifier = {
			factor = 0.95
			diplomacy = 11
		}
		modifier = {
			factor = 0.95
			diplomacy = 12
		}
		modifier = {
			factor = 0.95
			diplomacy = 13
		}
		modifier = {
			factor = 0.95
			diplomacy = 14
		}
		modifier = {
			factor = 0.95
			diplomacy = 15
		}
		modifier = {
			factor = 0.95
			diplomacy = 16
		}
		modifier = {
			factor = 0.95
			diplomacy = 17
		}
		modifier = {
			factor = 0.95
			diplomacy = 18
		}
		modifier = {
			factor = 0.95
			diplomacy = 19
		}
		modifier = {
			factor = 0.95
			diplomacy = 20
		}
		modifier = {
			factor = 0.95
			diplomacy = 21
		}
		modifier = {
			factor = 0.95
			diplomacy = 22
		}
		modifier = {
			factor = 0.95
			diplomacy = 23
		}
		modifier = {
			factor = 0.95
			diplomacy = 24
		}
		modifier = {
			factor = 0.95
			diplomacy = 25
		}
		modifier = {
			factor = 1.05
			trait = honest
		}
		modifier = {
			factor = 1.05
			trait = slothful
		}
		modifier = {
			factor = 1.05
			trait = just
		}
		modifier = {
			factor = 0.95
			learning = 15
		}
		modifier = {
			factor = 0.5
			has_game_rule = {
				name = fabricate_claim_rate
				value = double
			}
		}
		modifier = {
			factor = 0.33
			has_game_rule = {
				name = fabricate_claim_rate
				value = triple
			}
		}
		modifier = {
			factor = 0.25
			has_game_rule = {
				name = fabricate_claim_rate
				value = quadruple
			}
		}
		modifier = {
			factor = 2.0
			has_game_rule = {
				name = fabricate_claim_rate
				value = half
			}
		}
	}

	option = {
		name = "EVTOPTA913"
		hidden_tooltip = {
			# Try to claim Kingdom title - only available with Become King ambition
			if = {
				limit = {
					diplomacy = 22
					liege = {
						has_ambition = obj_become_king
						NOT = { has_character_flag = kingdom_claimed_with_ambition }
						ROOT = {
							location = {
								kingdom = {
									NOT = { claimed_by = PREVPREVPREV }
									holder_scope = {
										NOT = { character = ROOT }
										owns = PREVPREV
									}
								}
							}
						}
					}
				}
				random = {
					chance = 20
					location = {
						kingdom = {
							holder_scope = {
								set_character_flag = kingdom_claimed
								character_event = { id = 20130 days = 1 }
							}
						}
					}
					liege = { set_character_flag = kingdom_claimed_with_ambition }
					set_character_flag = claim_done
					break = yes
				}
			}
			if = {
				limit = {
					diplomacy = 18
					NOT = { diplomacy = 22 }
					liege = {
						has_ambition = obj_become_king
						NOT = { has_character_flag = kingdom_claimed_with_ambition }
						ROOT = {
							location = {
								kingdom = {
									NOT = { claimed_by = PREVPREVPREV }
									holder_scope = {
										NOT = { character = ROOT }
										owns = PREVPREV
									}
								}
							}
						}
					}
				}
				random = {
					chance = 10
					location = {
						kingdom = {
							holder_scope = {
								set_character_flag = kingdom_claimed
								character_event = { id = 20130 days = 1 }
							}
						}
					}
					liege = { set_character_flag = kingdom_claimed_with_ambition }
					set_character_flag = claim_done
					break = yes
				}
			}
			if = {
				limit = {
					diplomacy = 15
					NOT = { diplomacy = 18 }
					liege = {
						has_ambition = obj_become_king
						NOT = { has_character_flag = kingdom_claimed_with_ambition }
						ROOT = {
							location = {
								kingdom = {
									NOT = { claimed_by = PREVPREVPREV }
									holder_scope = {
										NOT = { character = ROOT }
										owns = PREVPREV
									}
								}
							}
						}
					}
				}
				random = {
					chance = 5
					location = {
						kingdom = {
							holder_scope = {
								set_character_flag = kingdom_claimed
								character_event = { id = 20130 days = 1 }
							}
						}
					}
					liege = { set_character_flag = kingdom_claimed_with_ambition }
					set_character_flag = claim_done
					break = yes
				}
			}
			if = {
				limit = {
					NOT = { diplomacy = 15 }
					liege = {
						has_ambition = obj_become_king
						NOT = { has_character_flag = kingdom_claimed_with_ambition }
						ROOT = {
							location = {
								kingdom = {
									NOT = { claimed_by = PREVPREVPREV }
									holder_scope = {
										NOT = { character = ROOT }
										owns = PREVPREV
									}
								}
							}
						}
					}
				}
				random = {
					chance = 2
					location = {
						kingdom = {
							holder_scope = {
								set_character_flag = kingdom_claimed
								character_event = { id = 20130 days = 1 }
							}
						}
					}
					set_character_flag = claim_done
					break = yes
				}
			}
			# Try to claim duchy title
			if = {
				limit = {
					NOT = { diplomacy = 15 }
					liege = {
						ROOT = {
							location = {
								duchy = {
									NOT = { claimed_by = PREVPREVPREV }
									holder_scope = {
										NOT = { is_liege_of = ROOT }
										NOT = { character = ROOT }
										owns = PREVPREV
									}
								}
							}
						}
					}
				}
				random = {
					chance = 15
					location = {
						duchy = {
							holder_scope = {
								set_character_flag = duchy_claimed
								character_event = { id = 20130 days = 1 }
							}
						}
					}
					set_character_flag = claim_done
				}
			}
			if = {
				limit = {
					diplomacy = 15
					NOT = { diplomacy = 20 }
					liege = {
						ROOT = {
							location = {
								duchy = {
									NOT = { claimed_by = PREVPREVPREV }
									holder_scope = {
										NOT = { is_liege_of = ROOT }
										NOT = { character = ROOT }
										owns = PREVPREV
									}
								}
							}
						}
					}
				}
				random = {
					chance = 20
					location = {
						duchy = {
							holder_scope = {
								set_character_flag = duchy_claimed
								character_event = { id = 20130 days = 1 }
							}
						}
					}
					set_character_flag = claim_done
				}
			}
			if = {
				limit = {
					diplomacy = 20
					liege = {
						ROOT = {
							location = {
								duchy = {
									NOT = { claimed_by = PREVPREVPREV }
									holder_scope = {
										NOT = { is_liege_of = ROOT }
										NOT = { character = ROOT }
										owns = PREVPREV
									}
								}
							}
						}
					}
				}
				random = {
					chance = 25
					location = {
						duchy = {
							holder_scope = {
								set_character_flag = duchy_claimed
								character_event = { id = 20130 days = 1 }
							}
						}
					}
					set_character_flag = claim_done
				}
			}
			# Try to claim county title
			if = {
				limit = {
					NOT = { has_character_flag = claim_done }
					liege = {
						ROOT = {
							location = {
								county = {
									NOT = { claimed_by = PREVPREVPREV }
									holder_scope = {
										NOT = { is_liege_of = ROOT }
										NOT = { character = ROOT }
										owns = PREVPREV
									}
								}
							}
						}
					}
				}
				location = {
					county = {
						holder_scope = {
							character_event = { id = 20130 days = 1 }
						}
					}
				}
			}
			clr_character_flag = claim_done
		}
	}
}

# 20130: The noble is informed about the claim
character_event = {
	id = 20130
	desc = "EVTDESC20130"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20130"
		hidden_tooltip = {
			# Claim county
			if = {
				limit = {
					NOR = {
						has_character_flag = duchy_claimed
						has_character_flag = kingdom_claimed
					}
				}
				FROM = { liege = { letter_event = { id = 20131 days = 1 } } }
			}
			# Claim duchy
			if = {
				limit = { has_character_flag = duchy_claimed }
				FROM = { liege = { letter_event = { id = 20133 days = 1 } } }
				clr_character_flag = duchy_claimed
			}
			# Claim Kingdom
			if = {
				limit = { has_character_flag = kingdom_claimed }
				FROM = { liege = { letter_event = { id = 20134 days = 1 } } }
				clr_character_flag = kingdom_claimed
			}
		}
	}
}

# 20131: The liege is informed and has a choice to press the claim or not
letter_event = {
	id = 20131
	desc = "EVTDESC20131"
	border = GFX_event_letter_frame_diplomacy
	show_from_from = yes

	is_triggered_only = yes

	trigger = {
		FROM = {
			FROM = {
				has_job_action = action_fabricate_claims
				location = {
					OR = {
						county = {
							NOT = { claimed_by = ROOT }
						}
						duchy = {
							NOT = { claimed_by = ROOT }
						}
					}
				}
			}
		}
	}
	option = {	# Emperor or King
		name = "EVTOPTA20131" #Press the Claim
		trigger = { primary_title = { higher_tier_than = DUKE }	}
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 1.25 }
			}
			modifier = {
				factor = 0
				OR = {
					spouse = { character = FROM }
					current_heir = { character = FROM }
				}
			}
		}
		scaled_wealth = { value = -1.5 min = -150 }
		prestige = -150
		FROM = {
			FROM = {
				location = {
					county = {
						add_claim = ROOT
					}
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 10
			}
			hidden_tooltip = {
				character_event = { id = 20132 days = 7 }
			}
		}
	}
	option = {	# Duke
		name = "EVTOPTA20131" #Press the Claim
		trigger = { primary_title = { tier = DUKE } }
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 1.25 }
			}
			modifier = {
				factor = 0
				OR = {
					spouse = { character = FROM }
					current_heir = { character = FROM }
				}
			}
		}
		scaled_wealth = { value = -1.0 min = -100 }
		prestige = -100
		FROM = {
			FROM = {
				location = {
					county = {
						add_claim = ROOT
					}
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 10
			}
			hidden_tooltip = {
				character_event = { id = 20132 days = 7 }
			}
		}
	}
	option = {	# Count or Patrician
		name = "EVTOPTA20131" #Press the Claim
		trigger = {
			OR = {
				primary_title = { tier = COUNT }
				AND = {
					is_patrician = yes
					primary_title = { NOT = { higher_tier_than = COUNT } }
				}
			}
		}
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 1.25 }
			}
			modifier = {
				factor = 0
				OR = {
					spouse = { character = FROM }
					current_heir = { character = FROM }
				}
			}
		}
		scaled_wealth = { value = -0.75 min = -75 }
		prestige = -50
		FROM = {
			FROM = {
				location = {
					county = {
						add_claim = ROOT
					}
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 10
			}
			hidden_tooltip = {
				character_event = { id = 20132 days = 7 }
			}
		}
	}
	option = {
		name = "EVTOPTB20131" #Let it go
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				scaled_wealth = 1.25
				NOT = {
					OR = {
						spouse = { character = FROM }
						current_heir = { character = FROM }
					}
				}
			}
		}
		piety = 10
	}
}

# 20133: The liege is informed and has a choice to press the claim or not
letter_event = {
	id = 20133
	desc = "EVTDESC20133"
	border = GFX_event_letter_frame_diplomacy
	show_from_from = yes

	is_triggered_only = yes

	trigger = {
		FROM = {
			FROM = {
				has_job_action = action_fabricate_claims
				location = {
					duchy = {
						NOT = { claimed_by = ROOT }
					}
				}
			}
		}
	}

	option = {	# Emperor or King
		name = "EVTOPTA20131" #Press the Claim
		trigger = { primary_title = { higher_tier_than = DUKE } }
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 2.25 }
			}
		}
		scaled_wealth = { value = -3.0 min = -300 }
		prestige = -300
		FROM = {
			FROM = {
				location = {
					duchy = {
						add_claim = ROOT
					}
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 20
			}
			hidden_tooltip = {
				character_event = { id = 20132 days = 7 }
			}
		}
	}
	option = {	# Duke
		name = "EVTOPTA20131" #Press the Claim
		trigger = { primary_title = { tier = DUKE } }
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 2.25 }
			}
		}
		scaled_wealth = { value = -2.0 min = -200 }
		prestige = -200
		FROM = {
			FROM = {
				location = {
					duchy = {
						add_claim = ROOT
					}
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 20
			}
			hidden_tooltip = {
				character_event = { id = 20132 days = 7 }
			}
		}
	}
	option = {	# Count
		name = "EVTOPTA20131" #Press the Claim
		trigger = { primary_title = { tier = COUNT } }
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 2.25 }
			}
		}
		scaled_wealth = { value = -1.0 min = -100 }
		prestige = -100
		FROM = {
			FROM = {
				location = {
					duchy = {
						add_claim = ROOT
					}
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 20
			}
			hidden_tooltip = {
				character_event = { id = 20132 days = 7 }
			}
		}
	}
	option = {
		name = "EVTOPTB20131" #Let it go
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				scaled_wealth = 2.25
			}
		}
		piety = 20
	}
}

# 20134: The liege is informed and has a choice to press the claim or not
letter_event = {
	id = 20134
	desc = "EVTDESC20134"
	border = GFX_event_letter_frame_diplomacy
	
	show_from_from = yes
	
	is_triggered_only = yes
	
	trigger = {
		FROM = {
			FROM = {
				has_job_action = action_fabricate_claims
				location = {
					kingdom = {
						NOT = { claimed_by = ROOT }
					}
				}
			}
		}
	}

	option = {	# Duke
		name = "EVTOPTA20131" #Press the Claim
		trigger = { primary_title = { tier = DUKE } }
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 2.25 }
			}
		}
		scaled_wealth = { value = -3.0 min = -300 }
		prestige = -200
		FROM = {
			FROM = {
				location = {
					kingdom = {
						add_claim = ROOT
					}
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 20
			}
			hidden_tooltip = {
				character_event = { id = 20132 days = 7 }
			}
		}
	}
	option = {	# Count
		name = "EVTOPTA20131" #Press the Claim
		trigger = { primary_title = { tier = COUNT } }
		ai_chance = {
			factor = 90
			modifier = {
				factor = 0
				NOT = { scaled_wealth = 2.25 }
			}
		}
		scaled_wealth = { value = -1.5 min = -150 }
		prestige = -100
		FROM = {
			FROM = {
				location = {
					kingdom = {
						add_claim = ROOT
					}
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 20
			}
			hidden_tooltip = {
				character_event = { id = 20132 days = 7 }
			}
		}
	}
	option = {
		name = "EVTOPTB20131" #Let it go
		ai_chance = {
			factor = 10
			modifier = {
				factor = 0
				scaled_wealth = 2.25
			}
		}
		piety = 20
	}
}

# 20132: The noble is informed if the claim is pressed, and is insulted
character_event = {
	id = 20132
	desc = "EVTDESC20132"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20132"
		hidden_tooltip = {
			FROM = {
				reverse_remove_opinion = {
					modifier = opinion_furious
					who = ROOT
				}
			}
		}
		opinion = {
			modifier = opinion_furious
			who = FROM
			years = 10
		}
	}
}


# 914: A Noble finds out that the Chancellor is trying to fabricate claims
character_event = {
	id = 914
	title = "EVTNAME914"
	desc = "EVTDESC914"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy
	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_fabricate_claims
		NOT = { has_character_modifier = in_seclusion }
		NOT = { has_character_modifier = bribed_by_noble_timer }
		liege = { prestige = 0 }
		location = {
			owner = {
				NOT = { is_liege_of = ROOT }
				NOT = { character = ROOT }
			}
		}
	}

	mean_time_to_happen = {
		months = 120

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

	option = {
		name = "EVTOPTA914"
		location = {
			county = {
				holder_scope = {
					character_event = { id = 20140 days = 7 tooltip = "EVTTOOLTIP20140" }
				}
			}
		}
	}
}

# 20140 - The noble knows about the fabricated claims
character_event = {
	id = 20140
	desc = "EVTDESC20140"
	picture = GFX_evt_emissary
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20140" #Make him disappear...
		ai_chance = { factor = 40 }
		piety = -10
		hidden_tooltip = {
			random_list = {
				50 = { set_character_flag = assassinate_chancellor_succeed }
				50 = { set_character_flag = assassinate_chancellor_fails }
			}
		}
		if = {
			limit = { has_character_flag = assassinate_chancellor_succeed }
			FROM = {
				character_event = { id = 20141 days = 7 tooltip = "EVTTOOLTIP20141" }
			}
			clr_character_flag = assassinate_chancellor_succeed
		}
		if = {
			limit = { has_character_flag = assassinate_chancellor_fails }
			FROM = {
				character_event = { id = 20143 days = 7 tooltip = "EVTTOOLTIP20143" }
			}
			clr_character_flag = assassinate_chancellor_fails
		}
	}
	option = {
		name = "EVTOPTB20140" #Send him an offer
		trigger = {
			treasury = 50
		}
		ai_chance = { factor = 30 }
		treasury = -50
		FROM = {
			letter_event = { id = 20144 days = 7 tooltip = "EVTTOOLTIP20144" }
		}
	}
	option = {
		name = "EVTOPTC20140" #I better let it be for now
		ai_chance = {
			factor = 30
			modifier = {
				factor = 2
				NOT = { treasury = 50 }
			}
		}
	}
}

# 20141 - Chancellor is assassinated...
character_event = {
	id = 20141
	desc = "EVTDESC20141"
	picture = GFX_evt_death
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20141"
		hidden_tooltip = {
			FROM = { character_event = { id = 20142 } }
		}
	}
}

# 20142 - Noble is informed that the assassination attempt succeeded
character_event = {
	id = 20142
	desc = "EVTDESC20142"
	picture = GFX_evt_death
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20142"
		hidden_tooltip = {
			FROM = { liege = { character_event = { id = 20147 } } }
		}
	}
}

# 20143 - Noble is informed that the assassination attempt failed
character_event = {
	id = 20143
	desc = "EVTDESC20143"
	picture = GFX_evt_death
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20143"
	}
}

# 20144 - Noble tries to bribe Chancellor
letter_event = {
	id = 20144
	desc = "EVTDESC20144"
	border = GFX_event_letter_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20144"
		wealth = 50
		FROM = {
			letter_event = { id = 20145 tooltip = "EVTTOOLTIP20145" }
		}
		hidden_tooltip = {
			add_character_modifier = {
				name = bribed_by_noble_timer
				duration = 365
				hidden = yes
			}
		}
	}
	option = {
		name = "EVTOPTB20144"
		prestige = 5
		FROM = { letter_event = { id = 20146 tooltip = "EVTTOOLTIP20146" } }
	}
}

# 20145 - Noble is informed that the Chancellor accepted the bribe
letter_event = {
	id = 20145
	desc = "EVTDESC20145"
	border = GFX_event_letter_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20145"
	}
}

# 20146 - Noble is informed that the Chancellor didn't accept the bribe
letter_event = {
	id = 20146
	desc = "EVTDESC20146"
	border = GFX_event_letter_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20146"
		wealth = 50
	}
}

# 20147 - The liege is informed about the Chancellor's death
character_event = {
	id = 20147
	desc = "EVTDESC20147"
	picture = GFX_evt_death
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20147"
		job_chancellor = {
			death = {
				death_reason = death_murder_unknown
				killer = FROM
			}
		}
	}
}


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

# 916: The Chancellor sows dissent between a liege and his vassals
character_event = {
	id = 916
	title = "EVTNAME916"
	desc = "EVTDESC916"
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_sow_dissent
		NOT = { has_character_modifier = in_seclusion }
		location = {
			owner = {
				religion = ROOT
				ROOT = {
					liege = {
						religion = PREVPREV
					}
				}
				NOT = { is_liege_of = ROOT }
				NOT = { character = ROOT }
				any_vassal = {
					NOT = { is_liege_of = ROOT }
					NOT = { character = ROOT }
					OR = { higher_tier_than = baron is_patrician = yes }
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 240

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

	option = {
		name = "EVTOPTA916"
		hidden_tooltip = {
			location = {
				owner = {
					any_vassal = {
						limit = {
							NOT = { is_liege_of = ROOT }
							NOT = { character = ROOT }
							OR = { higher_tier_than = baron is_patrician = yes }
						}
						character_event = { id = 20160 days = 7 }
					}
					character_event = { id = 20161 days = 7 tooltip = "EVTTOOLTIP20161" }
				}
			}
		}
	}
}

# 20160: The vassals start disliking their liege
character_event = {
	id = 20160
	desc = "EVTDESC20160"
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20160"
		liege = {
			reverse_opinion = {
				modifier = dissent_sowed
				who = ROOT
				years = 5
			}
		}
	}
}

# 20161: The province owner is informed
character_event = {
	id = 20161
	desc = "EVTDESC20161"
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy

	hide_from = yes
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20161"
		tooltip = {
			any_vassal = {
				limit = {
					NOT = { is_liege_of = FROM }
					NOT = { character = FROM }
					OR = { higher_tier_than = baron is_patrician = yes }
				}
				opinion = {
					modifier = dissent_sowed
					who = ROOT
					years = 5
				}
			}
		}
		hidden_tooltip = {
			FROM = {
				liege = {
					letter_event = { id = 20162 days = 7 }
				}
			}
		}
	}
}

# 20162: The liege of the Chancellor is informed
letter_event = {
	id = 20162
	desc = "EVTDESC20162"
	border = GFX_event_letter_frame_diplomacy

	show_from_from = yes

	is_triggered_only = yes

	option = {
		name = "EXCELLENT"
	}
}


# 917: Chancellor Discovered
character_event = {
	id = 917
	title = "EVTNAME917"
	desc = "EVTDESC917"
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy

	min_age = 16
	capable_only = yes
	prisoner = no

	trigger = {
		has_job_action = action_sow_dissent
		NOT = { has_character_modifier = in_seclusion }
		location = {
			owner = {
				NOT = { is_liege_of = ROOT }
				NOT = { character = ROOT }
				any_vassal = {
					NOT = { is_liege_of = ROOT }
					NOT = { character = ROOT }
					OR = { higher_tier_than = baron is_patrician = yes }
				}
			}
		}
	}

	mean_time_to_happen = {
		months = 90

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

	option = {
		name = "EVTOPTA917"
		location = {
			random_province_lord = {
				limit = {
					NOT = { is_liege_of = ROOT }
					NOT = { same_realm = ROOT }
					OR = { higher_tier_than = baron is_patrician = yes }
					independent = no
				}
				character_event = { id = 20170 tooltip = "EVTTOOLTIP20170" }
			}
		}
	}
}

# 20170: The local noble is informed
character_event = {
	id = 20170
	desc = "EVTDESC20170"
	picture = GFX_evt_spymaster
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20170"
		ai_chance = { factor = 100 }
		FROM = {
			opinion = {
				who = ROOT
				modifier = opinion_arrest_attempt
				months = 240
			}
			imprison = ROOT
		}
		hidden_tooltip = {
			FROM = {
				character_event = { id = 20171 }
				liege = { letter_event = { id = 20172 } }
			}
		}
	}
	option = {
		ai_chance = { factor = 0 }
		name = "EVTOPTB20170"
		FROM = {
			liege = {
				reverse_opinion = {
					modifier = opinion_furious
					who = ROOT
					years = 2
				}
			}
		}
		hidden_tooltip = {
			FROM = {
				liege = { letter_event = { id = 20175 } }
			}
			liege = { letter_event = { id = 20174 } }
		}
	}
}

# 20171: The Chancellor is imprisoned
character_event = {
	id = 20171
	desc = "EVTDESC20171"
	picture = GFX_evt_into_the_dungeon
	border = GFX_event_normal_frame_diplomacy
	is_triggered_only = yes

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

# 20172: The Chancellor's liege is informed about imprisonment
letter_event = {
	id = 20172
	desc = "EVTDESC20172"
	border = GFX_event_letter_frame_diplomacy
	is_triggered_only = yes

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

# 20174: The local noble informs his liege about the Chancellor's doing
letter_event = {
	id = 20174
	desc = "EVTDESC20174"
	border = GFX_event_letter_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = "EVTOPTA20174"
		FROM = {
			FROM = {
				liege = {
					reverse_opinion = {
						modifier = opinion_furious
						who = ROOT
						years = 5
					}
					hidden_tooltip = {
						letter_event = { id = 20176  }
					}
				}
			}
		}
	}
}

# 20175: The Chancellor's liege is informed about the reaction of the noble
letter_event = {
	id = 20175
	desc = EVTDESC20175
	border = GFX_event_letter_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = EVTOPTA20175
		prestige = -5
		hidden_tooltip = {
			FROM = {
				remove_opinion = {
					modifier = opinion_furious
					who = ROOT
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 5
			}
		}
	}
}

# 20176: The Chancellor's liege is informed about the reaction of the noble's liege
letter_event = {
	id = 20176
	desc = EVTDESC20176
	border = GFX_event_letter_frame_diplomacy
	is_triggered_only = yes

	option = {
		name = EVTOPTA20176
		prestige = -10
		hidden_tooltip = {
			FROM = {
				remove_opinion = {
					modifier = opinion_furious
					who = ROOT
				}
			}
		}
		FROM = {
			opinion = {
				modifier = opinion_furious
				who = ROOT
				years = 5
			}
		}
	}
}

# 20235: The Chancellor successfully increases the sentiment of the local clan
character_event = {
	id = 20235
	title = EVTNAME20235
	desc = EVTDESC20235
	picture = GFX_evt_market
	border = GFX_event_normal_frame_diplomacy

	min_age = 16
	capable_only = yes
	prisoner = no
	
	trigger = {
		has_job_action = action_clan_sentiment
		NOT = { has_character_modifier = in_seclusion }
		location = {
			owner = {
				is_nomadic = yes
				ROOT = {
					liege = {
						NOT = { character = PREVPREV }
						OR = {
							overlord_of = PREVPREV
							vassal_of = PREVPREV
							same_liege = PREVPREV
						}
					}
				}
			}
		}
	}
	
	mean_time_to_happen = {
		months = 60
		
		modifier = {
			factor = 10
			clan_title = { 
				clan = yes # Is the head of a Clan
			}
			location = {
				owner = {
					character = ROOT # This is my own clan
				}
			}
			NOT = {
				opinion = {
					who = liege
					value = 0
				}
			}
		}
		
		modifier = {
			factor = 1.25
			NOT = { diplomacy = 2 }
		}
		modifier = {
			factor = 1.25
			NOT = { diplomacy = 3 }
		}
		modifier = {
			factor = 1.25
			NOT = { diplomacy = 4 }
		}
		modifier = {
			factor = 1.25
			NOT = { diplomacy = 5 }
		}
		modifier = {
			factor = 0.75
			diplomacy = 9
		}
		modifier = {
			factor = 0.75
			diplomacy = 10
		}
		modifier = {
			factor = 0.75
			diplomacy = 11
		}
		modifier = {
			factor = 0.75
			diplomacy = 12
		}
		modifier = {
			factor = 0.75
			diplomacy = 13
		}
	}
	
	immediate = {
		liege = {
			clan_title = {
				save_event_target_as = liege_clan
			}
		}
		location = {
			owner = {
				save_event_target_as = target_chief
			}
		}
	}
	
	option = {
		name = EVTOPTA20235 # Increase the sentiments vs the Khan's Clan
		ai_chance = { factor = 100 }
		
		event_target:target_chief = {
			clan_title = {
				clan_opinion = {
					who = event_target:liege_clan
					modifier = clan_propaganda_effort
					years = 5
				}
			}
		}
		
		hidden_tooltip = {
			liege = { character_event = { id = 20236 } }
		}
	}
	
	option = {
		name = EVTOPTB20235 # Do nothing
		ai_chance = { factor = 0 }
	}
}

character_event = {
	id = 20236
	title = EVTNAME20235
	desc = EVTDESC20236
	picture = GFX_evt_market
	border = GFX_event_normal_frame_diplomacy
	
	is_triggered_only = yes
	
	option = {
		name = EXCELLENT
		
		tooltip = {
			event_target:target_chief = {
				clan_title = {
					clan_opinion = {
						who = event_target:liege_clan
						modifier = clan_propaganda_effort
						years = 5
					}
				}
			}
		}
	}
}

