targeted_decisions = {
	dismantle_spy_network = {
		ai_target_filter = realm
		ai_check_interval = 12

		only_playable = yes

		from_potential = {
			has_character_flag = has_personal_spy_network
			job_spymaster = { always = yes }
		}

		potential = {
			has_character_flag = has_personal_spy_network

			check_variable = {
				which = personal_spy_network
				value >= 10
			}

			FROM = {
				trigger_if = {
					limit = { ai = yes }

					has_plot = yes
					plot_target_char = { character = ROOT }
				}
			}
		}

		allow = {
			FROM = {
				custom_tooltip = {
					text = SPYNETWORK_10_PLUS

					check_variable = {
						which = personal_spy_network
						value >= 10
					}
				}
			}

			ROOT = {
				is_within_diplo_range = FROM

				custom_tooltip = {
					text = NOT_SPIES_RECENTLY_ASSAULTED

					trigger_if = {
						limit = { has_character_flag = spy_network_assaulted }

						had_character_flag = {
							flag = spy_network_assaulted
							months >= 6
						}
					}
				}
			}
		}

		effect = {
			ROOT = {
				set_character_flag = spy_network_assaulted
				job_spymaster = { save_event_target_as = my_spymaster }
			}

			FROM = {
				custom_tooltip = {
					text = SPYNETWORK_DECREASE_10_LIEGE

					change_variable = {
						which = personal_spy_network
						value = -10
					}
				}
			}

			random_list = {
				20 = {
					mult_modifier = {
						factor = 0.5

						OR = {
							is_ruler = no
							NOT = { job_spymaster = { always = yes } }
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -1
							}
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -3
							}
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -5
							}
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -7
							}
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -9
							}
						}
					}

					mult_modifier = {
						factor = 1.5

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 1
							}
						}
					}

					mult_modifier = {
						factor = 1.5

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 3
							}
						}
					}

					mult_modifier = {
						factor = 1.5

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 5
							}
						}
					}

					mult_modifier = {
						factor = 1.5

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 7
							}
						}
					}

					mult_modifier = {
						factor = 2.0

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 9
							}
						}
					}

					custom_tooltip = { text = DISMANTLE_ATTEMPT_FAILS }
				}

				10 = {
					custom_tooltip = {
						text = SPYNETWORK_DECREASE_5

						set_character_flag = small_network_decrease

						change_variable = {
							which = personal_spy_network
							value = -5
						}
					}
				}

				50 = {
					custom_tooltip = {
						text = SPYNETWORK_DECREASE_10

						set_character_flag = med_network_decrease

						change_variable = {
							which = personal_spy_network
							value = -10
						}
					}
				}

				20 = {
					trigger = {
						check_variable = {
							which = personal_spy_network
							value >= 20
						}
					}

					custom_tooltip = {
						text = SPYNETWORK_DECREASE_20

						set_character_flag = large_network_decrease

						change_variable = {
							which = personal_spy_network
							value = -20
						}
					}
				}
			}

			random_list = {
				50 = {
					mult_modifier = {
						factor = 0.2

						OR = {
							is_ruler = no
							NOT = { job_spymaster = { always = yes } }
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -1
							}
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -3
							}
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -5
							}
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -7
							}
						}
					}

					mult_modifier = {
						factor = 0.8

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value <= -9
							}
						}
					}

					mult_modifier = {
						factor = 1.5

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 1
							}
						}
					}

					mult_modifier = {
						factor = 1.5

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 3
							}
						}
					}

					mult_modifier = {
						factor = 1.5

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 5
							}
						}
					}

					mult_modifier = {
						factor = 1.5

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 7
							}
						}
					}

					mult_modifier = {
						factor = 2.0

						job_spymaster = {
							attribute_diff = {
								attribute = learning
								character = event_target:my_spymaster
								value >= 9
							}
						}
					}

					custom_tooltip = {
						text = DISMANTLE_ATTEMPT_DISCOVERED

						FROM = { character_event = { id = 20356 } }
						ROOT = { character_event = { id = 20357 days = 1 } }
					}
				}

				50 = {
					custom_tooltip = {
						text = DISMANTLE_ATTEMPT_NOT_DISCOVERED

						FROM = { character_event = { id = 20358 } }
						ROOT = { character_event = { id = 20359 days = 1 } }
					}
				}
			}
		}

		ai_will_do = {
			factor = 0.5

			mult_modifier = {
				factor = 10

				check_variable = {
					which = personal_spy_network
					value >= 29
				}
			}
		}
	}
}

decisions = {
	hire_assassin_nonruler = {
		ai_check_interval = 3

		potential = {
			has_character_flag = has_personal_spy_network

			OR = {
				has_plot = plot_kill_character
				has_plot = plot_kill_spouse
				has_plot = plot_take_revenge
			}

			plot_target_char = {
				is_ruler = no

				NOR = {
					character = ROOT
					father = { higher_real_tier_than = BARON }
					mother = { higher_real_tier_than = BARON }
				}
			}
		}

		allow = {
			wealth >= 50

			custom_tooltip = {
				text = SPYNETWORK_10_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 10
				}
			}

			custom_tooltip = {
				text = NOT_HIRED_ASSASSIN_LAST_YEAR

				trigger_if = {
					limit = { has_character_flag = hired_recent_assassin }

					had_character_flag = {
						flag = hired_recent_assassin
						years >= 1
					}
				}
			}
		}

		effect = {
			set_character_flag = hired_recent_assassin

			custom_tooltip = {
				text = SPYNETWORK_DECREASE_10

				change_variable = {
					which = personal_spy_network
					value = -10
				}
			}

			wealth = -50

			custom_tooltip = {
				text = SEND_SPY_ASSASSIN

				plot_target_char = {
					ROOT = { send_assassin = PREV }
				}
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					trait = decadent
					trait = cruel
					trait = wroth
					trait = deceitful
				}

				NOR = {
					trait = kind
					trait = patient
					trait = honest
					trait = just
					has_character_modifier = ai_austerity
					has_character_modifier = planning_claimant_adventure
					has_character_flag = claimant_adventurer
				}
			}
		}
	}

	hire_assassin_count = {
		ai_check_interval = 3

		potential = {
			has_character_flag = has_personal_spy_network

			OR = {
				has_plot = plot_kill_character
				has_plot = plot_kill_spouse
				has_plot = plot_take_revenge
			}

			plot_target_char = {
				OR = {
					real_tier = COUNT
					father = { real_tier = COUNT }
					mother = { real_tier = COUNT }
				}

				NOR = {
					character = ROOT
					father = { higher_real_tier_than = COUNT }
					mother = { higher_real_tier_than = COUNT }
				}
			}
		}

		allow = {
			wealth >= 150

			custom_tooltip = {
				text = SPYNETWORK_10_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 10
				}
			}

			custom_tooltip = {
				text = NOT_HIRED_ASSASSIN_LAST_YEAR

				trigger_if = {
					limit = { has_character_flag = hired_recent_assassin }

					had_character_flag = {
						flag = hired_recent_assassin
						years >= 1
					}
				}
			}
		}

		effect = {
			set_character_flag = hired_recent_assassin

			custom_tooltip = {
				text = SPYNETWORK_DECREASE_10

				change_variable = {
					which = personal_spy_network
					value = -10
				}
			}

			wealth = -150

			custom_tooltip = {
				text = SEND_SPY_ASSASSIN

				plot_target_char = {
					ROOT = { send_assassin = PREV }
				}
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					trait = decadent
					trait = cruel
					trait = wroth
					trait = deceitful
				}

				NOR = {
					trait = kind
					trait = patient
					trait = honest
					trait = just
					has_character_modifier = ai_austerity
					has_character_modifier = planning_claimant_adventure
					has_character_flag = claimant_adventurer
				}
			}
		}
	}

	hire_assassin_duke = {
		ai_check_interval = 3

		potential = {
			has_character_flag = has_personal_spy_network

			OR = {
				has_plot = plot_kill_character
				has_plot = plot_kill_spouse
				has_plot = plot_take_revenge
			}

			plot_target_char = {
				OR = {
					real_tier = DUKE
					father = { real_tier = DUKE }
					mother = { real_tier = DUKE }
				}

				NOR = {
					character = ROOT
					father = { higher_real_tier_than = DUKE }
					mother = { higher_real_tier_than = DUKE }
				}
			}
		}

		allow = {
			wealth >= 250

			custom_tooltip = {
				text = SPYNETWORK_20_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 20
				}
			}

			custom_tooltip = {
				text = NOT_HIRED_ASSASSIN_LAST_YEAR

				trigger_if = {
					limit = { has_character_flag = hired_recent_assassin }

					had_character_flag = {
						flag = hired_recent_assassin
						years >= 1
					}
				}
			}
		}

		effect = {
			set_character_flag = hired_recent_assassin

			custom_tooltip = {
				text = SPYNETWORK_DECREASE_20

				change_variable = {
					which = personal_spy_network
					value = -20
				}
			}

			wealth = -250

			custom_tooltip = {
				text = SEND_SPY_ASSASSIN

				plot_target_char = {
					ROOT = { send_assassin = PREV }
				}
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					trait = decadent
					trait = cruel
					trait = wroth
					trait = deceitful
				}

				NOR = {
					trait = kind
					trait = patient
					trait = honest
					trait = just
					has_character_modifier = ai_austerity
					has_character_modifier = planning_claimant_adventure
					has_character_flag = claimant_adventurer
				}
			}
		}
	}

	hire_assassin_king = {
		ai_check_interval = 3

		potential = {
			has_character_flag = has_personal_spy_network

			OR = {
				has_plot = plot_kill_character
				has_plot = plot_kill_spouse
				has_plot = plot_take_revenge
			}

			plot_target_char = {
				OR = {
					real_tier = KING
					father = { real_tier = KING }
					mother = { real_tier = KING }
				}

				NOR = {
					character = ROOT
					father = { real_tier = EMPEROR }
					mother = { real_tier = EMPEROR }
				}
			}
		}

		allow = {
			wealth >= 350
			custom_tooltip = {
				text = SPYNETWORK_20_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 20
				}
			}

			custom_tooltip = {
				text = NOT_HIRED_ASSASSIN_LAST_YEAR

				trigger_if = {
					limit = { has_character_flag = hired_recent_assassin }

					had_character_flag = {
						flag = hired_recent_assassin
						years >= 1
					}
				}
			}
		}

		effect = {
			set_character_flag = hired_recent_assassin

			custom_tooltip = {
				text = SPYNETWORK_DECREASE_20

				change_variable = {
					which = personal_spy_network
					value = -20
				}
			}

			wealth = -350

			custom_tooltip = {
				text = SEND_SPY_ASSASSIN

				plot_target_char = {
					ROOT = { send_assassin = PREV }
				}
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					trait = decadent
					trait = cruel
					trait = wroth
					trait = deceitful
				}

				NOR = {
					trait = kind
					trait = patient
					trait = honest
					trait = just
					has_character_modifier = ai_austerity
					has_character_modifier = planning_claimant_adventure
					has_character_flag = claimant_adventurer
				}
			}
		}
	}

	hire_assassin_emperor = {
		ai_check_interval = 3

		potential = {
			has_character_flag = has_personal_spy_network

			OR = {
				has_plot = plot_kill_character
				has_plot = plot_kill_spouse
				has_plot = plot_take_revenge
			}

			plot_target_char = {
				NOT = { character = ROOT }

				OR = {
					real_tier = EMPEROR
					father = { real_tier = EMPEROR }
					mother = { real_tier = EMPEROR }
				}
			}
		}

		allow = {
			wealth >= 450

			custom_tooltip = {
				text = SPYNETWORK_30_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 30
				}
			}

			custom_tooltip = {
				text = NOT_HIRED_ASSASSIN_LAST_YEAR

				trigger_if = {
					limit = { has_character_flag = hired_recent_assassin }

					had_character_flag = {
						flag = hired_recent_assassin
						years >= 1
					}
				}
			}
		}

		effect = {
			set_character_flag = hired_recent_assassin

			custom_tooltip = {
				text = SPYNETWORK_DECREASE_30

				change_variable = {
					which = personal_spy_network
					value = -30
				}
			}

			wealth = -450

			custom_tooltip = {
				text = SEND_SPY_ASSASSIN

				plot_target_char = {
					ROOT = { send_assassin = PREV }
				}
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					trait = decadent
					trait = cruel
					trait = wroth
					trait = deceitful
				}

				NOR = {
					trait = kind
					trait = patient
					trait = honest
					trait = just
					has_character_modifier = ai_austerity
					has_character_modifier = planning_claimant_adventure
					has_character_flag = claimant_adventurer
				}
			}
		}
	}

	use_spy_network_1 = {
		ai_check_interval = 12

		potential = {
			has_character_flag = has_personal_spy_network

			NOR = {
				has_character_modifier = plot_assisted_spying
				has_character_modifier = plot_assisted_spying2
				has_character_modifier = plot_assisted_spying3
				has_character_modifier = plot_assisted_spying4
				has_character_modifier = plot_assisted_spying5
			}
		}

		allow = {
			custom_tooltip = {
				text = SPYNETWORK_10_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 10
				}
			}

			is_not_in_regency_trigger = yes
			is_inaccessible_trigger = no
			NOT = { has_character_modifier = away_from_court }
		}

		effect = {
			custom_tooltip = {
				text = SPYNETWORK_DECREASE_10

				change_variable = {
					which = personal_spy_network
					value = -10
				}
			}

			add_character_modifier = {
				name = plot_assisted_spying
				years = 1
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					has_plot = yes
					has_any_opinion_modifier = opinion_spying_on
				}
			}
		}
	}

	use_spy_network_2 = {
		ai_check_interval = 12

		potential = {
			has_character_flag = has_personal_spy_network
			has_character_modifier = plot_assisted_spying
		}

		allow = {
			custom_tooltip = {
				text = SPYNETWORK_20_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 20
				}
			}

			is_not_in_regency_trigger = yes
			is_inaccessible_trigger = no
			NOT = { has_character_modifier = away_from_court }
		}

		effect = {
			custom_tooltip = {
				text = SPYNETWORK_DECREASE_20

				change_variable = {
					which = personal_spy_network
					value = -20
				}
			}

			add_character_modifier = {
				name = plot_assisted_spying2
				years = 1
			}

			hidden_effect = {
				remove_character_modifier = plot_assisted_spying
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					has_plot = plot_kill_character
					has_plot = plot_kill_spouse
					has_plot = plot_take_revenge
					has_plot = plot_stir_rebellion
					has_plot = plot_become_republic
					has_plot = plot_seize_trade_post
					has_plot = plot_discredit_councillor
					has_plot = plot_embezzle_from_liege
					has_plot = plot_fabricate_treason
					has_plot = plot_fabricate_treason_liege
					has_plot = plot_fabricate_heresy
					has_plot = plot_gain_liege_title
					has_plot = plot_gain_fellow_vassal_title
					has_plot = plot_weaken_fellow_vassal
					has_plot = plot_kidnap_liege
					has_plot = plot_usurp_wife
					has_plot = plot_replace_regent
					has_plot = plot_incapable_usurp
				}
			}
		}
	}

	use_spy_network_3 = {
		ai_check_interval = 12

		potential = {
			has_character_flag = has_personal_spy_network
			has_character_modifier = plot_assisted_spying2
		}

		allow = {
			custom_tooltip = {
				text = SPYNETWORK_30_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 30
				}
			}

			is_not_in_regency_trigger = yes
			is_inaccessible_trigger = no
			NOT = { has_character_modifier = away_from_court }
		}

		effect = {
			custom_tooltip = {
				text = SPYNETWORK_DECREASE_30

				change_variable = {
					which = personal_spy_network
					value = -30
				}
			}

			add_character_modifier = {
				name = plot_assisted_spying3
				years = 10
			}

			hidden_effect = {
				remove_character_modifier = plot_assisted_spying2
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					has_plot = plot_kill_character
					has_plot = plot_kill_spouse
					has_plot = plot_take_revenge
					has_plot = plot_stir_rebellion
					has_plot = plot_become_republic
					has_plot = plot_fabricate_treason
					has_plot = plot_fabricate_treason_liege
					has_plot = plot_fabricate_heresy
					has_plot = plot_gain_liege_title
					has_plot = plot_gain_fellow_vassal_title
					has_plot = plot_weaken_fellow_vassal
					has_plot = plot_kidnap_liege
					has_plot = plot_usurp_wife
					has_plot = plot_replace_regent
					has_plot = plot_incapable_usurp
				}
			}
		}
	}

	use_spy_network_4 = {
		ai_check_interval = 12

		potential = {
			has_character_flag = has_personal_spy_network
			has_character_modifier = plot_assisted_spying3
		}

		allow = {
			custom_tooltip = {
				text = SPYNETWORK_40_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 40
				}
			}

			is_not_in_regency_trigger = yes
			is_inaccessible_trigger = no
			NOT = { has_character_modifier = away_from_court }
		}

		effect = {
			custom_tooltip = {
				text = SPYNETWORK_DECREASE_40

				change_variable = {
					which = personal_spy_network
					value = -40
				}
			}

			add_character_modifier = {
				name = plot_assisted_spying4
				years = 1
			}

			hidden_effect = {
				remove_character_modifier = plot_assisted_spying3
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					has_plot = plot_kill_character
					has_plot = plot_kill_spouse
					has_plot = plot_take_revenge
					has_plot = plot_stir_rebellion
					has_plot = plot_become_republic
					has_plot = plot_kidnap_liege
					has_plot = plot_replace_regent
					has_plot = plot_incapable_usurp
				}
			}
		}
	}

	use_spy_network_5 = {
		ai_check_interval = 12

		potential = {
			has_character_flag = has_personal_spy_network
			has_character_modifier = plot_assisted_spying4
		}

		allow = {
			custom_tooltip = {
				text = SPYNETWORK_50_PLUS

				check_variable = {
					which = personal_spy_network
					value >= 50
				}
			}

			is_not_in_regency_trigger = yes
			is_inaccessible_trigger = no
			NOT = { has_character_modifier = away_from_court }
		}

		effect = {
			custom_tooltip = {
				text = SPYNETWORK_DECREASE_50

				change_variable = {
					which = personal_spy_network
					value = -50
				}
			}

			add_character_modifier = {
				name = plot_assisted_spying5
				years = 1
			}

			hidden_effect = {
				remove_character_modifier = plot_assisted_spying4
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				OR = {
					has_plot = plot_kill_character
					has_plot = plot_kill_spouse
					has_plot = plot_take_revenge
					has_plot = plot_kidnap_liege
					has_plot = plot_incapable_usurp
				}
			}
		}
	}
}