decisions = {

	plot_usurp_wife_decision = {
		is_high_prio = yes
		ai_check_interval = 12

		potential = {
			has_plot = plot_usurp_wife
			NOT = { has_character_flag = plot_usurp_wife_decision_taken }
		}

		allow = {
			OR = {
				AND = {
					plot_power >= 1.0
					num_of_plot_backers >= 1
					plot_target_char = { prisoner = no }
				}

				plot_target_char = {
					prisoner = yes
					host = { character = ROOT }
				}

				AND = {
					plot_target_char = { is_incapable = yes }
					plot_power >= 0.5
				}
			}

			war = no

			custom_tooltip = {
				text = IS_NOT_BUSY
				in_command_trigger = no
			}

			is_inaccessible_trigger = no

			plot_target_char = {
				war = no

				custom_tooltip = {
					text = IS_NOT_BUSY
					in_command_trigger = no
				}

				is_inaccessible_trigger = no
			}
		}

		effect = {
			plot_target_char = {
				show_scope_change = no

				character_event = {
					id = FemRule.360
					tooltip = ATTEMPT_TO_USURP_WIFE
				}
			}

			hidden_effect = {
				set_character_flag = plot_usurp_wife_decision_taken
				activate_plot = yes

				add_character_modifier = {
					name = do_not_disturb
					days = 7
					hidden = yes
				}
			}
		}

		ai_will_do = {
			factor = 1

			trigger = {
				NOT = { trait = content }

				trigger_if = {
					limit = { plot_target_char = { is_incapable = yes } }
					plot_power >= 0.75
				}
				trigger_else_if = {
					limit = { plot_target_char = { prisoner = no } }
					plot_power >= 1.25
				}
			}
		}
	}

}

targeted_decisions = {

	reveal_plot = {
		ai_target_filter = realm
		ai_check_interval = 5

		only_rulers = yes

		from_potential = {
			job_spymaster = { always = yes }
			NOT = { has_character_flag = attempted_blackmail }
		}

		potential = {
			has_plot = yes
			plot_is_known_by = FROM

			FROM = {
				NOT = { is_plot_target_of = ROOT }
			}
		}

		allow = {
			FROM = {
				has_regent = no

				NOT = {
					has_opinion_modifier = {
						name = opinion_blackmailed
						who = ROOT
					}
				}
			}

			plot_target_char = {
				is_adult = yes

				custom_tooltip = {
					text = NOT_AWARE_PLOT
					ROOT = { NOT = { plot_is_known_by = PREV } }
				}
			}
		}

		effect = {
			tooltip = {
				ROOT = { reveal_plot = yes }
			}

			if = {
				limit = { any_plot_backer = { character = FROM } }

				FROM = {
					show_scope_change = no

					leave_plot = ROOT
				}
			}

			plot_target_char = {
				save_event_target_as = revealed_target
				letter_event = { id = Plus.285 }
			}

			character_event = {
				id = Plus.288
				days = 7
			}
		}

		ai_will_do = {
			factor = 0.5

			trigger = {
				NOT = {
					any_plot_backer = { character = FROM }
				}

				plot_target_char = {
					reverse_opinion = {
						who = FROM
						value >= 0
					}

					NOR = {
						FROM = {
							likes_better_than = {
								who = ROOT
								than = PREV
							}
						}

						has_opinion_modifier = {
							name = opinion_recent_plot
							who = FROM
						}

						has_truce = FROM
						has_non_aggression_pact_with = FROM
						war_with = FROM
					}
				}
			}

			mult_modifier = {
				factor = 10

				plot_target_char = {
					OR = {
						is_close_relative = FROM
						any_liege = { character = FROM }
					}
				}
			}
		}
	}

	blackmail_plotter = {
		ai_target_filter = realm
		ai_check_interval = 5

		only_rulers = yes

		from_potential = {
			has_regent = no
			job_spymaster = {always = yes }
			NOT = { has_character_flag = attempted_blackmail }
		}

		potential = {
			has_plot = yes
			plot_is_known_by = FROM
			plot_target_char = { NOT = { character = FROM } }

			NOR = {
				has_plot = plot_seduce
				is_vassal_or_below_of = FROM
				is_liege_or_above_of = FROM
				reverse_has_opinion_modifier = { who = FROM name = opinion_blackmailed }
				reverse_has_opinion_modifier = { who = FROM name = opinion_failed_blackmail }
			}
		}

		allow = {
			ROOT = { wealth >= 100 }

			plot_target_char = {
				custom_tooltip = {
					text = NOT_AWARE_PLOT
					ROOT = { NOT = { plot_is_known_by = PREV } }
				}
			}
		}

		effect = {
			FROM = {
				set_character_flag = attempted_blackmail
				character_event = { id = 7259 }

				if = {
					limit = { trait = just }

					random = {
						chance = 25
						remove_trait = just
					}
				}

				random = {
					chance = 50

					add_trait_deceitful_effect = yes
					remove_trait_honest_effect = yes
				}
			}
		}

		ai_will_do = {
			factor = 0.5

			trigger = {
				FROM = {
					OR = {
						trait = deceitful
						trait = greedy
						trait = envious
					}

					NOR = {
						trait = just
						trait = diligent
						any_plot_backer = { character = FROM }
					}

					opinion = {
						who = ROOT
						value < 0
					}
				}

				plot_target_char = {
					reverse_opinion = {
						who = FROM
						value >= 0
					}

					NOR = {
						FROM = {
							likes_better_than = {
								who = ROOT
								than = PREV
							}
						}

						has_opinion_modifier = { who = FROM name = opinion_recent_plot }
						has_truce = FROM
						has_non_aggression_pact_with = FROM
						war_with = FROM
						is_close_relative = FROM
					}
				}
			}
		}
	}
}