# Plot tags need to start with 'plot_'

# Supported types:
# character, spouse, rivals, friends, liege_titles, vassal_titles, realm_titles, realm_characters, realm_characters_plus, independent_rulers
# Special: society_plot. When trigger fulfilled, anyone within the society can be invited. ROOT is the plotter. FROM is the target. FROMFROM is the society
# Note that "player_allow" has the target as ROOT, and the plotter (the player) as FROM!

###############
# PLOTS
###############

# Gain one of the liege's landed titles
plot_gain_title = {
	type = liege_titles
	military_plot = yes

	# Plotter scope
	# ROOT is plotter
	potential = {
		always = no # Disabled for being too similar to the factions

		is_landed = yes
		higher_real_tier_than = BARON
		independent = no
		is_adult = yes
		prisoner = no
		is_incapable = no
		NOT = { trait = imbecile }

		trigger_if = {
			limit = {
				NOT = { has_dlc = "Conclave" }

				crownlaw_title = {
					always = yes
				}
			}

			crownlaw_title = {
				NOR = {
					has_law = crown_authority_3
					has_law = crown_authority_4
				}
			}
		}
		trigger_else = {
			# Plot against top liege or king
			OR = {
				top_liege = {
					character = ROOT
				}
				liege = {
					character = ROOT
					real_tier = KING
				}
			}
		}
	}

	# Title scope
	# FROM is plotter
	allow = {
		holder_scope = {
			NOR = {
				is_married = FROM
				reverse_has_truce = FROM
			}
		}

		OR = {
			FROM = {
				OR = {
					is_feudal = yes
					is_tribal = yes
				}
			}

			AND = {
				FROM = { is_feudal = no }
				lower_real_tier_than = KING
			}
		}

		OR = {
			claimed_by = FROM

			AND = {
				is_primary_holder_title = yes
				FROM = { is_pretender = yes }
			}

			AND = {
				# Secondary title of highest held tier
				is_primary_holder_title = no
				is_primary_holder_title_tier = yes

				is_titular = no

				holder_scope = {
					is_liege_of = FROM
				}

				# Title is plotter's de jure kingdom title
				FROM = {
					primary_title = {
						kingdom = {
							title = PREVPREVPREV
						}
					}
				}
			}
		}
	}

	# Title scope
	# FROM is plotter
	success = {
		holder = FROM
	}

	effect = {
		FROM = {
			show_scope_change = no

			if = {
				limit = { intrigue < 10 }
				change_intrigue = 1
			}

			any_plot_backer = {
				show_scope_change = no

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

			clr_character_flag = event7040
		}
	}

	# Title scope
	# FROM is plotter
	abort = {
		OR = {
			holder_scope = {
				is_married = FROM
			}

			FROM = {
				OR = {
					is_ruler = no
					independent = yes
					is_incapable = yes
				}
			}
		}
	}

	abort_effect = {
		FROM = {
			clr_character_flag = event7040
		}
	}

	# Title scope
	# FROM is plotter
	chance = {
		factor = 50

		trigger = {
			trigger_if = {
				limit = { FROM = { ai = yes } } # Needed for some reason (maybe a bug)

				FROM = {
					war = no

					trigger_if = {
						limit = {
							OR = {
								trait = envious
								trait = deceitful
								trait = ambitious
							}
						}

						ROOT = {
							holder_scope = {
								reverse_opinion = {
									who = FROM
									value < 50
								}
							}
						}
					}
					trigger_else = {
						ROOT = {
							holder_scope = {
								reverse_opinion = {
									who = FROM
									value < 25
								}
							}
						}
					}
				}
			}
		}

		mult_modifier = {
			factor = 0.01
			FROM = { trait = content }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { is_dumb_trigger = yes }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { trait = kind }
		}

		mult_modifier = {
			factor = 0.2

			FROM = {
				opinion = {
					who = liege
					value >= 0
				}

				NOR = {
					trait = envious
					trait = deceitful
					trait = ambitious
				}
			}
		}

		mult_modifier = {
			factor = 0.2

			FROM = {
				opinion = {
					who = liege
					value >= 25
				}

				NOR = {
					trait = envious
					trait = deceitful
					trait = ambitious
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			FROM = {
				opinion = {
					who = liege
					value < -50
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			FROM = {
				opinion = {
					who = liege
					value < -75
				}
			}
		}

		mult_modifier = {
			factor = 1.5
			FROM = { is_smart_trigger = yes }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = envious }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = deceitful }
		}

		mult_modifier = {
			factor = 4.0
			FROM = { trait = ambitious }
		}

		mult_modifier = {
			# Subtle balance against nepotism
			factor = 2.0

			holder_scope = {
				NOT = { dynasty = FROM }

				top_liege = {
					higher_real_tier_than = COUNT
					dynasty = PREV
					dynasty_realm_power >= 0.25
				}
			}
		}

		mult_modifier = {
			# Subtle balance against nepotism
			factor = 2.0

			holder_scope = {
				NOT = { dynasty = FROM }

				top_liege = {
					higher_real_tier_than = COUNT
					dynasty = PREV
					dynasty_realm_power >= 0.40
				}
			}
		}

		mult_modifier = {
			factor = 4.0

			# Secondary title of highest held tier
			is_primary_holder_title = no
			is_primary_holder_title_tier = yes

			is_titular = no

			holder_scope = {
				is_liege_of = FROM
			}

			# Title is plotter's de jure kingdom title
			FROM = {
				primary_title = {
					kingdom = {
						title = PREVPREVPREV
					}
				}
			}
		}
	}
}

# Gain one of a vassal's landed titles
plot_gain_vassal_title = {
	type = vassal_titles
	vassal_rank_plot = yes

	# Plotter scope
	# ROOT is plotter
	potential = {
		always = no # Disabled in CK2Plus
		is_playable = yes
		is_adult = yes
		prisoner = no
		is_patrician = no
		is_incapable = no

		primary_title = {
			higher_real_tier_than = COUNT
			temporary = no
		}

		trigger_if = {
			limit = { ai = yes }
			war = no
		}

		NOT = { has_landed_title = e_china_west_governor }
	}

	# Title scope
	target_potential = {
		higher_tier_than = BARON
		is_primary_type_title = no
		is_landless_type_title = no
		controls_religion = no
		is_merchant_republic = no
		mercenary = no
	}

	# Title scope
	# FROM is plotter
	allow = {
		is_recent_grant = no

		FROM = { in_revolt = no }

		holder_scope = {
			custom_tooltip = { # liege_before_war lacks localisation, among other things
				text = TT_FROM_IS_LIEGE_BEFORE_WAR

				liege_before_war = { # Plot will not invalidate during vassal-liege war
					character = FROM
				}
			}

			NOR = {
				has_non_aggression_pact_with = FROM
				reverse_has_truce = FROM
			}
		}

		OR = {
			# Count titles in ruler's primary duchy
			custom_tooltip = {
				text = TT_PLOT_GAIN_VASSAL_TITLE_COUNTY_IN_CAPITAL_DUCHY

				real_tier = COUNT

				dejure_liege_title  = {
					holder_scope = {
						character = FROM

						capital_scope = {
							duchy = {
								title = PREVPREVPREV
							}
						}
					}
				}
			}

			# Count's secondary county
			custom_tooltip = {
				text = TT_PLOT_GAIN_VASSAL_TITLE_COUNT_SECONDARY_COUNTY

				real_tier = COUNT

				location = {
					is_capital = no
				}

				holder_scope = {
					lower_real_tier_than = DUKE
					num_of_count_titles >= 2
				}
			}

			# Count title outside a Duke's duchy
			custom_tooltip = {
				text = TT_PLOT_GAIN_VASSAL_TITLE_DUKE_COUNTY_OUTSIDE_DUCHY

				real_tier = COUNT

				holder_scope = {
					real_tier = DUKE

					ROOT = {
						NOT = { de_jure_liege = PREV }
					}
				}
			}

			# Duke with no count titles
			custom_tooltip = {
				text = TT_PLOT_GAIN_VASSAL_TITLE_DUCHY_ALL_DJ_COUNTIES_NOT_DEFACTO

				real_tier = DUKE

				holder_scope = {
					ROOT = {
						NOT = {
							any_direct_de_jure_vassal_title = {
								holder_scope = {
									OR = {
										character = PREVPREVPREV
										is_vassal_or_below_of = PREVPREVPREV
									}
								}
							}
						}
					}
				}
			}

			# Belongs to Tyrannical Bloodline
			custom_tooltip = {
				text = TT_PLOT_GAIN_VASSAL_TITLE_TYRANNICAL_BLOODLINE

				FROM = {
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_revocation_plot
						bloodline_is_active_for = PREV
					}
				}
			}
		}
	}

	success = {
		holder = FROM
	}

	effect = {
		FROM = {
			show_scope_change = no

			any_plot_backer = {
				show_scope_change = no

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

			clr_character_flag = event7040
		}
	}

	abort = {
		OR = {
			NOR = {
				# Count title outside a Duke's duchy
				AND = {
					real_tier = COUNT

					holder_scope = {
						real_tier = DUKE

						ROOT = {
							NOT = { de_jure_liege = PREV }
						}
					}
				}

				# Duke with no count titles
				AND = {
					real_tier = DUKE

					holder_scope = {
						NOT = {
							any_demesne_title = {
								real_tier = COUNT

								location = {
									duchy = {
										title = ROOT
									}
								}
							}
						}

						NOT = {
							any_vassal = {
								any_demesne_title = {
									real_tier = COUNT

									location = {
										duchy = {
											title = ROOT
										}
									}
								}
							}
						}
					}
				}

				# Count titles in ruler's primary duchy
				AND = {
					real_tier = COUNT

					dejure_liege_title  = {
						holder = FROM

						FROM = {
							capital_scope = {
								duchy = {
									title = PREVPREVPREV
								}
							}
						}
					}
				}

				# Count's secondary county
				AND = {
					real_tier = COUNT

					location = {
						is_capital = no
					}

					holder_scope = {
						lower_real_tier_than = DUKE
						num_of_count_titles >= 2
					}
				}

				FROM = {
					any_owned_bloodline = {
						has_bloodline_flag = bloodline_revocation_plot
						bloodline_is_active_for = PREV
					}
				}
			}

			FROM = {
				OR = {
					is_playable = no
					is_incapable = yes
					in_revolt = yes
				}
			}

			holder_scope = {
				liege_before_war = {
					NOT = { character = FROM }
				}
			}
		}
	}

	abort_effect = {
		FROM = {
			clr_character_flag = event7040
		}
	}

	chance = {
		factor = 1

		trigger = {
			trigger_if = {
				limit = { FROM = { ai = yes } } # Needed for some reason (maybe a bug)

				holder_scope = {
					FROM = {
						war = no

						trigger_if = {
							limit = { dynasty = PREV }

							opinion = {
								who = PREV
								value < 0
							}
						}

						trigger_if = {
							limit = {
								OR = {
									trait = envious
									trait = deceitful
									trait = ambitious
								}
							}

							opinion = {
								who = PREV
								value < 50
							}
						}
						trigger_else = {
							opinion = {
								who = PREV
								value < 25
							}
						}
					}
				}
			}
		}

		mult_modifier = {
			factor = 0.01
			FROM = { trait = content }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { is_dumb_trigger = yes }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { trait = kind }
		}

		mult_modifier = {
			factor = 0.25

			FROM = {
				opinion = {
					who = ROOT
					value >= 25
				}

				OR = {
					trait = envious
					trait = deceitful
					trait = ambitious
				}
			}
		}

		mult_modifier = {
			factor = 0.25

			FROM = {
				opinion = {
					who = ROOT
					value >= 0
				}

				NOR = {
					trait = envious
					trait = deceitful
					trait = ambitious
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			FROM = {
				opinion = {
					who = ROOT
					value < -50
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			FROM = {
				opinion = {
					who = ROOT
					value < -75
				}
			}
		}

		mult_modifier = {
			factor = 1.5
			FROM = { is_smart_trigger = yes }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = envious }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = deceitful }
		}

		mult_modifier = {
			factor = 4.0
			FROM = { trait = ambitious }
		}
	}
}

# Get a character killed
plot_kill_character = {
	type = realm_characters_plus # All characters in the same realm, plus rivals and relatives of self, parents, children and spouse, and quest target
	intrigue_plot = yes
	murder_plot = yes

	# ROOT is plotter
	# FROM is target
	# FROMFROM is society
	society_plot = {
		ROOT = {
			society_rank = {
				society = the_assassins
				rank >= 2
			}
		}

		OR = {
			FROM = {
				NOR = {
					religion = shiite
					secret_religion = shiite
				}
			}

			AND = {
				ROOT = {
					has_quest = quest_the_assassins_assassination
				}

				FROM = {
					is_quest_target_of = ROOT
				}
			}
		}
	}

	# Plotter scope
	# ROOT is plotter
	potential = {
		is_adult = yes
		prisoner = no
		is_incapable = no

	#	trigger_if = {
	#		limit = { ai = yes }
	#		has_character_flag = allow_plotting
	#	}
	}

	# FROM is plotter
	target_potential = {
		NOT = { is_married = FROM } # This case is covered by another plot
	}

	# Target allow trigger for when players target a specific character in the GUI
	# ROOT is target
	# FROM is plotter
	player_allow = {
		is_within_diplo_range = FROM

		NOT = {
			has_opinion_modifier = {
				name = opinion_recent_plot
				who = FROM
			}
		}
	}

	# Target character scope
	# ROOT is target
	# FROM is plotter
	allow = {
		is_within_diplo_range = FROM
		assassination_interaction_trigger = yes # Game rule

		NOR = {
			is_married = FROM # This case is covered by another plot
			is_child_of = FROM # Not my own children
			is_grandchild_of = FROM
			is_friend = FROM
			is_lover = FROM
			has_blood_oath_with = FROM

			# Don't kill my lovers, or their children
			FROM = {
				any_lover = {
					OR = {
						character = ROOT
						is_parent_of = ROOT
					}
				}
			}
		}

		trigger_if = { # Not against myself! (unself I am bonkers)
			limit = { character = FROM }
			trait = lunatic
		}

		# Not against children unless they're your liege or you're ambitious/cruel
		trigger_if = {
			limit = { is_adult = no }

			OR = {
				is_liege_or_above_of = FROM

				FROM = {
					OR = {
						trait = ambitious
						trait = cruel
					}
				}
			}
		}

		# Only against targets that one dislikes sufficiently
		FROM = {
			OR = {
				trigger_if = {
					limit = { is_close_relative = ROOT }

					trigger_if = {
						limit = {
							OR = {
								trait = deceitful
								trait = ambitious
								trait = cruel
							}
						}

						opinion = {
							who = ROOT
							value < 0
						}
					}
					trigger_else_if = {
						limit = {
							OR = {
								trait = arbitrary
								trait = cynical
								trait = proud
							}
						}

						opinion = {
							who = FROM
							value < -25
						}
					}
					trigger_else = {
						opinion = {
							who = FROM
							value < -50
						}
					}
				}
				trigger_else = {
					trigger_if = {
						limit = {
							OR = {
								trait = deceitful
								trait = ambitious
								trait = cruel
							}
						}

						opinion = {
							who = FROM
							value < 50
						}
					}
					trigger_else_if = {
						limit = {
							OR = {
								trait = arbitrary
								trait = cynical
								trait = proud
							}
						}

						opinion = {
							who = FROM
							value < 25
						}
					}
					trigger_else = {
						opinion = {
							who = FROM
							value < 0
						}
					}
				}

				trigger_if = {
					limit = {
						OR = {
							trait = lunatic
							trait = possessed
						}
					}

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

		FROM = {
			OR = {
				# An adventurer targeting me
				has_opinion_modifier = {
					name = opinion_claimant_adventure_target
					who = ROOT
				}

				# Get rid of the current heir if I'm a pretender
				any_pretender_title = {
					current_heir = { character = ROOT }
				}

				# Kill a ruler if I'm the heir
				any_heir_title = {
					holder = ROOT
				}

				# Gets rid of obstacles in the way of a child's succession
				AND = {
					NOT = { is_close_relative = ROOT }

					any_child = {
						OR = {
							any_pretender_title = {
								current_heir = { character = ROOT }
							}

							any_heir_title = {
								holder = ROOT
							}
						}
					}
				}

				# Gets rid of obstacles in the way of a spouse's succession
				AND = {
					NOT = { is_close_relative = ROOT }

					spouse = {
						OR = {
							any_pretender_title = {
								current_heir = { character = ROOT }
							}

							any_heir_title = {
								holder = ROOT
							}
						}
					}
				}

				# A lover of my spouse...
				AND = {
					NOT = { trait = homosexual }

					any_spouse = {
						any_lover = {
							character = ROOT

							OR = {
								reverse_has_opinion_modifier = {
									name = slut_seductress
									who = FROM
								}

								reverse_has_opinion_modifier = {
									name = opinion_cuckolded
									who = FROM
								}
							}
						}
					}
				}

				# Go nuts...
				AND = {
					same_liege = ROOT
					trait = lunatic
				}

				# Rivals
				is_rival = ROOT

				ROOT = { is_murder_quest_target_of_prev_trigger = yes }

				# Spymaster who dislikes liege
				AND = {
					job_spymaster = {
						character = ROOT
					}

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

	# ROOT is target
	# FROM is joiner
	# FROMFROM is plotter
	allow_join = {
		ROOT = {
			NOT = { is_child_of = FROM } # Not my own children
		}
	}

	success = {
		is_alive = no

		hidden_trigger = {
			killer = {
				character = FROM
				is_plot_active = yes
			}
		}
	}

	effect = {
		opinion = {
			name = opinion_recent_plot
			who = FROM
			years = 5
		}

		FROM = {
			show_scope_change = no

			any_plot_backer = {
				show_scope_change = no

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

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}

			hidden_effect = {
				clr_character_flag = event7040
				clr_character_flag = event1007003
				clr_character_flag = allow_plotting

				change_variable = {
					which = lifestyle_intrigue
					value = 1
				}
			}
		}
	}

	abort = {
		OR = {
			is_alive = no

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

				FROM = {
					NOR = {
						has_opinion_modifier = {
							name = opinion_claimant_adventure_target
							who = ROOT
						}

						any_pretender_title = {
							current_heir = { character = ROOT }
						}

						any_heir_title = {
							holder = ROOT
						}

						AND = {
							NOT = { is_close_relative = ROOT }

							any_child = {
								OR = {
									any_pretender_title = {
										current_heir = { character = ROOT }
									}

									any_heir_title = {
										holder = ROOT
									}
								}
							}
						}

						AND = {
							NOT = { is_close_relative = ROOT }

							spouse = {
								OR = {
									any_pretender_title = {
										current_heir = { character = ROOT }
									}

									any_heir_title = {
										holder = ROOT
									}
								}
							}
						}

						AND = {
							NOT = { trait = homosexual }

							spouse = {
								any_lover = {
									character = ROOT

									OR = {
										reverse_has_opinion_modifier = {
											name = slut_seductress
											who = FROM
										}

										reverse_has_opinion_modifier = {
											name = opinion_cuckolded
											who = FROM
										}
									}
								}
							}
						}

						AND = {
							same_liege = ROOT

							OR = {
								trait = lunatic
								trait = possessed
							}
						}

						is_rival = ROOT
						ROOT = { is_murder_quest_target_of_prev_trigger = yes }

						ROOT = {
							job_spymaster = {
								character = FROM

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

	abort_effect = {
		opinion = {
			name = opinion_recent_plot
			who = FROM
			years = 5
		}

		FROM = {
			clr_character_flag = event7040
			clr_character_flag = event1007003
			clr_character_flag = allow_plotting

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}
		}
	}

	chance = {
		factor = 2

		trigger = {
			trigger_if = {
				limit = { FROM = { ai = yes } } # Needed for some reason (maybe a bug)

				is_pilgrim = no

				FROM = {
					trigger_if = {
						limit = {
							OR = {
								trait = content
								trait = honest
								trait = kind
								trait = just
							}

							NOR = {
								trait = lunatic
								trait = possessed
							}
						}

						has_opinion_modifier = {
							name = opinion_claimant_adventure_target
							who = ROOT
						}
					}

					NOR = {
						trait = dishonorable6
						trait = dishonorable7
						trait = dishonorable8
						trait = dishonorable9
						trait = dishonorable10
					}
				}
			}
		}

		mult_modifier = {
			factor = 50

			FROM = { has_quest = quest_the_assassins_assassination }
			is_quest_target_of = FROM
		}

		mult_modifier = {
			factor = 0.2
			FROM = { pacifist = yes }
		}

		mult_modifier = {
			factor = 2.0

			FROM = {
				trait = envious

				OR = {
					any_pretender_title = {
						current_heir = { character = ROOT }
					}

					any_heir_title = {
						holder = ROOT
					}
				}
			}
		}

		mult_modifier = {
			factor = 1.5
			FROM = { trait = arbitrary }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = cruel }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = deceitful }
		}

		mult_modifier = {
			factor = 3.0
			FROM = { trait = ambitious }
		}

		mult_modifier = {
			factor = 1.5

			reverse_opinion = {
				who = FROM
				value < -25
			}
		}

		mult_modifier = {
			factor = 2.0

			reverse_opinion = {
				who = FROM
				value < -50
			}
		}

		mult_modifier = {
			factor = 2.0

			reverse_opinion = {
				who = FROM
				value < -75
			}
		}

		mult_modifier = {
			factor = 2.0

			# Subtle balance against nepotism: Kill off members of powerful dynasties
			top_liege = {
				higher_real_tier_than = COUNT
				dynasty = ROOT
				dynasty_realm_power >= 0.25
			}
		}

		mult_modifier = {
			factor = 2.0

			# Subtle balance against nepotism: Kill off members of powerful dynasties
			top_liege = {
				higher_real_tier_than = COUNT
				dynasty = ROOT
				dynasty_realm_power >= 0.40
			}
		}

		mult_modifier = {
			factor = 2.0

			# Subtle balance against nepotism: Kill off members of powerful dynasties
			top_liege = {
				higher_real_tier_than = COUNT
				dynasty = ROOT
				dynasty_realm_power >= 0.60
			}
		}

		mult_modifier = {
			factor = 4.0

			plot_target_char = {
				sibling = FROM
				ai = yes
				is_child_of = top_liege
			}

			FROM = {
				religion_group = muslim
				is_child_of = top_liege
			}
		}

		mult_modifier = {
			factor = 2.0

			plot_target_char = {
				sibling = FROM
				ai = yes
				is_child_of = top_liege
				is_landed = no
			}

			FROM = {
				religion_group = muslim
				is_child_of = top_liege
			}
		}

		mult_modifier = {
			factor = 2.0

			any_owned_bloodline = { # Backstabbing family
				has_bloodline_flag = bloodline_murderous
				bloodline_is_active_for = PREV
			}
		}

		# CK2Plus
		mult_modifier = {
			factor = 5

			has_opinion_modifier = {
				name = opinion_claimant_adventure_target
				who = ROOT
			}
		}

		mult_modifier = {
			factor = 5.0
			FROM = { trait = decadent }
		}

		mult_modifier = {
			factor = 10
			FROM = { trait = possessed }
		}

		mult_modifier = {
			factor = 0.5
			FROM = { trait = dishonorable1 }
		}

		mult_modifier = {
			factor = 0.4
			FROM = { trait = dishonorable2 }
		}

		mult_modifier = {
			factor = 0.3
			FROM = { trait = dishonorable3 }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { trait = dishonorable4 }
		}

		mult_modifier = {
			factor = 0.1
			FROM = { trait = dishonorable5 }
		}

		mult_modifier = {
			factor = 0.01

			FROM = {
				trait = charitable

				NOR = {
					trait = lunatic
					trait = possessed

					has_opinion_modifier = {
						name = opinion_claimant_adventure_target
						who = ROOT
					}
				}
			}
		}

		mult_modifier = {
			factor = 0.1

			their_opinion = {
				who = FROM
				value >= 25
			}

			FROM = {
				ROOT = {
					is_murder_quest_target_of_prev_trigger = no
				}
			}
		}

		mult_modifier = {
			factor = 0.5

			their_opinion = {
				who = FROM
				value >= 0
			}

			FROM = {
				NOR = {
					trait = envious
					trait = deceitful
					trait = ambitious
					trait = cruel
					trait = arbitrary
					trait = lunatic
					trait = possessed
				}

				ROOT = {
					is_murder_quest_target_of_prev_trigger = no
				}
			}
		}

		mult_modifier = {
			factor = 0.25
			FROM = { intrigue < 8 }
		}

		mult_modifier = {
			factor = 2
			FROM = { intrigue >= 15 }
		}

		mult_modifier = {
			factor = 2
			FROM = { intrigue >= 20 }
		}
	}
}

# Get a spouse killed
plot_kill_spouse = {
	type = spouse
	intrigue_plot = yes
	murder_plot = yes

	# ROOT is plotter
	# FROM is target
	# FROMFROM is society
	society_plot = {
		ROOT = {
			society_rank = {
				society = the_assassins
				rank >= 2
			}
		}

		OR = {
			FROM = {
				NOR = {
					religion = shiite
					secret_religion = shiite
				}
			}

			AND = {
				ROOT = {
					has_quest = quest_the_assassins_assassination
				}

				FROM = {
					is_quest_target_of = ROOT
				}
			}
		}
	}

	# Plotter scope
	potential = {
		is_adult = yes
		is_married = yes
		prisoner = no
		is_incapable = no

	#	trigger_if = {
	#		limit = { ai = yes }
	#		has_character_flag = allow_plotting
	#	}
	}

	# Target allow trigger for when players target a specific character in the GUI
	# FROM is plotter
	player_allow = {
		NOT = { is_lover = FROM }
		assassination_interaction_trigger = yes
	}

	# Target character scope
	# ROOT is target
	# FROM is plotter
	allow = {
		NOT = { is_lover = FROM }

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

			OR = {
				# Male plotter without heirs wanting to kill an old/barren wife
				AND = {
					practical_age >= 40

					FROM = {
						is_female = no

						OR = {
							is_ruler = yes
							any_heir_title = { always = yes }
							any_pretender_title = { always = yes }
						}

						# No sons
						NOT = {
							any_child = {
								is_alive = yes
								is_female = no
								NOT = { trait = bastard }
							}
						}

						# No female heirs
						NOT = {
							any_child = {
								is_female = yes
								is_alive = yes

								OR = {
									any_heir_title = { always = yes }
									any_pretender_title = { always = yes }
								}
							}
						}

						# Dislikes her enough to kill her
						trigger_if = {
							limit = {
								OR = {
									trait = ambitious
									trait = paranoid
									trait = cruel
								}
							}

							opinion = {
								who = ROOT
								value < 50
							}
						}
						trigger_else_if = {
							limit = {
								OR = {
									trait = arbitrary
									trait = cynical
									trait = deceitful
								}
							}

							opinion = {
								who = ROOT
								value < 25
							}
						}
						trigger_else = {
							opinion = {
								who = ROOT
								value < 0
							}
						}
					}
				}

				# Female plotter taking revenge on husband for usurping her
				FROM = {
					is_female = yes

					has_opinion_modifier = {
						name = husband_usurped_me
						who = ROOT
					}
				}

				# Female plotter disliking her husband but loving her child - the legal heir
				FROM = {
					is_female = yes
					num_of_children >= 1

					opinion = {
						who = ROOT
						value < 0
					}

					any_child = {
						is_alive = yes
						is_incapable = no

						any_heir_title = {
							holder = ROOT
						}

						reverse_opinion = {
							who = FROM
							value >= 75
						}
					}
				}

				# Disliked spouse has a lover...
				AND = {
					has_lover = yes

					any_lover = {
						NOT = { character = FROM }
					}

					FROM = {
						opinion = {
							who = ROOT
							value < 0
						}
					}
				}

				# Insane plotter...
				FROM = {
					trait = lunatic

					opinion = {
						who = ROOT
						value < 50
					}
				}

				# Really just don't like them
				FROM = {
					opinion = {
						who = ROOT
						value < -75
					}
				}
			}
		}
	}

	success = {
		is_alive = no

		hidden_trigger = {
			killer = {
				character = FROM
				is_plot_active = yes
			}
		}
	}

	effect = {
		opinion = {
			name = opinion_recent_plot
			who = FROM
			years = 5
		}

		FROM = {
			show_scope_change = no

			# Achievement
			if = {
				limit = {
					ai = no
					is_ironman = yes
				}

				set_character_flag = achievement_spouse_killer
			}

			any_plot_backer = {
				show_scope_change = no

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

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}

			# Clear flags
			hidden_effect = {
				clr_character_flag = event7040
				clr_character_flag = event1007003
				clr_character_flag = allow_plotting

				change_variable = {
					which = lifestyle_intrigue
					value = 1
				}
			}
		}
	}

	abort = {
		OR = {
			is_alive = no

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

				OR = {
					is_lover = FROM

					# Male plotter without heirs wanting to kill an old/barren wife
					AND = {
						practical_age >= 40

						FROM = {
							is_female = no

							OR = {
								is_ruler = yes
								any_heir_title = { always = yes }
								any_pretender_title = { always = yes }
							}

							# No sons
							NOT = {
								any_child = {
									is_alive = yes
									is_female = no
									NOT = { trait = bastard }
								}
							}

							# No female heirs
							NOT = {
								any_child = {
									is_female = yes
									is_alive = yes

									OR = {
										any_heir_title = { always = yes }
										any_pretender_title = { always = yes }
									}
								}
							}

							# Dislikes her enough to kill her
							trigger_if = {
								limit = {
									OR = {
										trait = ambitious
										trait = paranoid
										trait = cruel
									}
								}

								opinion = {
									who = ROOT
									value < 50
								}
							}
							trigger_else_if = {
								limit = {
									OR = {
										trait = arbitrary
										trait = cynical
										trait = deceitful
									}
								}

								opinion = {
									who = ROOT
									value < 25
								}
							}
							trigger_else = {
								opinion = {
									who = ROOT
									value < 0
								}
							}
						}
					}

					# Female plotter taking revenge on husband for usurping her
					FROM = {
						is_female = yes

						has_opinion_modifier = {
							name = husband_usurped_me
							who = ROOT
						}
					}

					# Female plotter disliking her husband but loving her child - the legal heir
					FROM = {
						is_female = yes
						num_of_children >= 1

						opinion = {
							who = ROOT
							value < 0
						}

						any_child = {
							is_alive = yes
							is_incapable = no

							any_heir_title = {
								holder = ROOT
							}

							reverse_opinion = {
								who = FROM
								value >= 75
							}
						}
					}

					# Disliked spouse has a lover...
					AND = {
						has_lover = yes

						any_lover = {
							NOT = { character = FROM }
						}

						FROM = {
							opinion = {
								who = ROOT
								value < 0
							}
						}
					}

					# Insane plotter...
					FROM = {
						trait = lunatic

						opinion = {
							who = ROOT
							value < 50
						}
					}

					# Really just don't like them
					FROM = {
						opinion = {
							who = ROOT
							value < -75
						}
					}
				}
			}
		}
	}

	abort_effect = {
		opinion = {
			name = opinion_recent_plot
			who = FROM
			years = 5
		}

		FROM = {
			clr_character_flag = event7040
			clr_character_flag = event1007003
			clr_character_flag = allow_plotting

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}
		}
	}

	chance = {
		factor = 10

		trigger = {
			trigger_if = {
				limit = { FROM = { ai = yes } } # Needed for some reason (maybe a bug)

				is_pilgrim = no

				FROM = {
					trigger_if = {
						limit = {
							OR = {
								trait = envious
								trait = deceitful
								trait = ambitious
							}
						}

						opinion = {
							who = ROOT
							value < 25
						}
					}
					trigger_else = {
						opinion = {
							who = ROOT
							value < 0
						}
					}

					NOR = {
						trait = dishonorable6
						trait = dishonorable7
						trait = dishonorable8
						trait = dishonorable9
						trait = dishonorable10
					}

					trigger_if = {
						limit = {
							OR = {
								trait = content
								trait = honest
								trait = kind
								trait = just
								trait = charitable
							}
						}

						NOR = {
							trait = lunatic
							trait = possessed
						}
					}
				}
			}
		}

		mult_modifier = {
			factor = 0.01
			FROM = { trait = content }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { pacifist = yes }
		}

		mult_modifier = {
			factor = 1.5

			reverse_opinion = {
				who = FROM
				value < -25
			}
		}

		mult_modifier = {
			factor = 1.5

			reverse_opinion = {
				who = FROM
				value < -50
			}
		}

		mult_modifier = {
			factor = 2.0

			reverse_opinion = {
				who = FROM
				value < -75
			}
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = deceitful }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { trait = paranoid }
		}

		mult_modifier = {
			factor = 1.25
			FROM = { trait = lunatic }
		}

		mult_modifier = {
			factor = 10
			FROM = { trait = possessed }
		}

		mult_modifier = {
			factor = 1.25
			FROM = { trait = intricate_webweaver }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { trait = elusive_shadow }
		}

		mult_modifier = {
			factor = 2.0

			practical_age >= 40

			OR = {
				is_married = FROM
				is_consort = FROM
			}

			FROM = {
				is_female = no

				NOT = {
					any_child = {
						is_female = no
						has_inheritance_blocker = no
					}
				}
			}
		}

		mult_modifier = {
			factor = 50

			FROM = { has_quest = quest_the_assassins_assassination }
			is_quest_target_of = FROM
		}

		# CK2Plus
		mult_modifier = {
			factor = 0.5
			FROM = { trait = dishonorable1 }
		}

		mult_modifier = {
			factor = 0.4
			FROM = { trait = dishonorable2 }
		}

		mult_modifier = {
			factor = 0.3
			FROM = { trait = dishonorable3 }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { trait = dishonorable4 }
		}

		mult_modifier = {
			factor = 0.1
			FROM = { trait = dishonorable5 }
		}

		mult_modifier = {
			factor = 0.1

			FROM = {
				opinion = {
					who = ROOT
					value >= 25
				}
			}
		}

		modifier = {
			factor = 0.5

			FROM = {
				opinion = {
					who = ROOT
					value >= 0
				}

				NOR = {
					trait = deceitful
					trait = cruel
					trait = paranoid
					trait = lunatic
					trait = possessed
				}
			}
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = cruel }
		}

		mult_modifier = {
			factor = 0.25
			FROM = { intrigue < 8 }
		}

		mult_modifier = {
			factor = 2
			FROM = { intrigue >= 15 }
		}

		mult_modifier = {
			factor = 2
			FROM = { intrigue >= 20 }
		}
	}
}

# Cut down a fellow vassal to size
plot_weaken_fellow_vassal = {
	type = realm_titles
	military_plot = yes

	# Plotter scope
	potential = {
		higher_real_tier_than = BARON
		is_landed = yes
		independent = no
		is_adult = yes
		prisoner = no
		is_patrician = no
		is_incapable = no
		NOT = { trait = imbecile }

		liege = {
			is_patrician = no
		}

		trigger_if = {
			# If affected by a Crown Law title not held by my liege
			limit = {
				crownlaw_title = {
					holder_scope = {
						NOT = { is_liege_of = ROOT }
					}
				}
			}

			will_liege_enforce_peace = no
			has_liege_enforced_peace = no
		}

	#	trigger_if = {
	#		limit = { ai = yes }
	#		has_character_flag = allow_plotting
	#	}
	}

	target_potential = {
		real_tier = DUKE
		is_primary_holder_title_tier = yes
		is_primary_holder_title = no
		is_vice_royalty = no

		holder_scope = {
			same_liege = FROM
			independent = no
			NOT = { character = FROM }
		}
	}

	# Title scope
	# ROOT is title
	# FROM is plotter
	allow = {
		holder_scope = {
			held_title_rating >= FROM

			any_vassal = {
				real_tier = COUNT

				any_demesne_title = {
					real_tier = COUNT
					de_jure_liege = ROOT
				}

				NOT = { is_heir = FROM }
			}

			NOR = {
				reverse_has_truce = FROM
				is_married = FROM
				is_allied_with = FROM
				has_non_aggression_pact_with = FROM

				has_opinion_modifier = {
					name = opinion_recent_plot
					who = FROM
				}

				# TODO: Add custom tooltip
				has_character_flag = weaken_vassal # Once per ruler only
			}
		}

		# Not the current heir to their titles
		current_heir = {
			NOT = { character = FROM }
		}
	}

	# Occurs when plot is activated
	# ROOT is title
	# FROM is plotter
	creation_effect = {
	}

	# Title scope
	# FROM is plotter
	success = {
		custom_tooltip = {
			text = PLOT_TOOLTIP_WEAKEN_VASSAL
			always = no # Handled by events
		}
	}

	# FROM is plotter
	effect = {
		FROM = {
			show_scope_change = no

			if = {
				limit = { intrigue < 10 }
				change_intrigue = 1
			}

			any_plot_backer = {
				show_scope_change = no

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

			clr_character_flag = allow_plotting

			hidden_effect = {
				change_variable = {
					which = lifestyle_intrigue
					value = 1
				}
			}

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}
		}

		holder_scope = {
			show_scope_change = no

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

	# Title scope
	# FROM is plotter
	abort = {
		holder_scope = {
			OR = {
				is_married = FROM
				has_liege_enforced_peace = yes
			}
		}
	}

	# FROM is plotter
	abort_effect = {
		FROM = {
			clr_character_flag = allow_plotting

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}
		}

		holder_scope = {
			opinion = {
				name = opinion_recent_plot
				who = FROM
				years = 5
			}
		}
	}

	# Title scope
	# ROOT is title
	# FROM is plotter
	chance = {
		factor = 1

		trigger = {
			trigger_if = {
				limit = { FROM = { ai = yes } } # Needed for some reason (maybe a bug)

				FROM = {
					war = no

					trigger_if = {
						limit = {
							OR = {
								trait = content
								trait = honest
								trait = kind
								trait = just
							}
						}

						NOR = {
							trait = lunatic
							trait = possessed
						}
					}

					trigger_if = {
						limit = {
							OR = {
								trait = envious
								trait = deceitful
								trait = ambitious
							}
						}

						ROOT = {
							holder_scope = {
								reverse_opinion = {
									who = FROM
									value < 50
								}
							}
						}
					}
					trigger_else = {
						ROOT = {
							holder_scope = {
								reverse_opinion = {
									who = FROM
									value < 25
								}
							}
						}
					}
				}
			}
		}

		mult_modifier = {
			factor = 0.01
			FROM = { trait = content }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { is_dumb_trigger = yes }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { trait = kind }
		}

		mult_modifier = {
			factor = 0.2

			trigger_if = {
				limit = {
					FROM = {
						OR = {
							trait = envious
							trait = deceitful
							trait = ambitious
						}
					}
				}

				holder_scope = {
					reverse_opinion = {
						who = FROM
						value >= 25
					}
				}
			}
			trigger_else = {
				holder_scope = {
					reverse_opinion = {
						who = FROM
						value >= 0
					}
				}
			}
		}

		mult_modifier = {
			factor = 1.25

			holder_scope = {
				reverse_opinion = {
					who = FROM
					value < 0
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			holder_scope = {
				reverse_opinion = {
					who = FROM
					value < -25
				}
			}
		}

		mult_modifier = {
			factor = 2.0

			# Subtle balance against nepotism
			holder_scope = {
				top_liege = {
					higher_real_tier_than = COUNT
					dynasty = PREV
					dynasty_realm_power >= 0.25
				}
			}
		}

		mult_modifier = {
			factor = 2.0

			# Subtle balance against nepotism
			holder_scope = {
				top_liege = {
					higher_real_tier_than = COUNT
					dynasty = PREV
					dynasty_realm_power >= 0.40
				}
			}
		}

		mult_modifier = {
			factor = 2.0

			# Subtle balance against nepotism
			holder_scope = {
				top_liege = {
					higher_real_tier_than = COUNT
					dynasty = PREV
					dynasty_realm_power >= 0.60
				}
			}
		}

		mult_modifier = {
			factor = 1.5
			FROM = { is_smart_trigger = yes }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = envious }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = deceitful }
		}

		mult_modifier = {
			factor = 4.0
			FROM = { trait = ambitious }
		}

		# CK2Plus
		mult_modifier = {
			factor = 0.2
			FROM = { pacifist = yes }
		}

		mult_modifier = {
			factor = 0.25
			FROM = { intrigue < 8 }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { intrigue >= 15 }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { intrigue >= 20 }
		}
	}
}

#################################
### Plots to Fabricate Claims ###
#################################

# Vassal ruler plots to gain claim on liege's title
plot_gain_liege_title = {
	type = liege_titles
	vassal_intrigue_plot = yes

	# Plotter scope
	# ROOT is plotter
	potential = {
		is_playable = yes
		is_landed = yes
		is_adult = yes
		prisoner = no
		independent = no
		is_incapable = no
		mercenary = no

		OR = {
			is_feudal = yes
			is_tribal = yes
		}

		NOR = {
			trait = imbecile
			is_parent_of = liege
			is_allied_with = liege
			has_truce = liege
			has_non_aggression_pact_with = liege

			reverse_has_opinion_modifier = {
				name = opinion_recent_plot
				who = liege
			}
		}

	#	trigger_if = {
	#		limit = { ai = yes }
	#		has_character_flag = allow_plotting
	#	}
	}

	# Title scope
	# FROM is plotter
	target_potential = {
		FROM = {
			OR = {
				de_jure_liege = ROOT

				primary_title = {
					de_jure_vassal_or_below = ROOT
				}
			}
		}
	}

	# Title scope
	# FROM is plotter
	allow = {
		is_vice_royalty = no
		NOT = { claimed_by = FROM }

		current_heir = {
			NOT = { character = FROM }
		}
	}

	# Title scope
	# FROM is plotter
	success = {
		claimed_by = FROM
	}

	# FROM is plotter
	effect = {
		FROM = {
			show_scope_change = no

			any_plot_backer = {
				show_scope_change = no

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

			clr_character_flag = allow_plotting

			hidden_effect = {
				change_variable = {
					which = lifestyle_intrigue
					value = 1
				}
			}

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}
		}

		holder_scope = {
			show_scope_change = no

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

	# Title scope
	# FROM is plotter
	abort = {
		OR = {
			holder = FROM
			has_holder = no
			is_vice_royalty = yes

			FROM = {
				is_playable = no
			}
		}
	}

	# FROM is plotter
	abort_effect = {
		FROM = {
			clr_character_flag = allow_plotting

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}
		}

		holder_scope = {
			opinion = {
				name = opinion_recent_plot
				who = FROM
				years = 5
			}
		}
	}

	# Title scope
	# FROM is plotter
	chance = {
		factor = 1 # Must always be an integer

		trigger = {
			FROM = {
				trigger_if = {
					limit = { ai = yes } # Needed for some reason (maybe a bug)

					war = no

					NOR = {
						trait = content
						trait = kind
					}

					trigger_if = {
						limit = {
							OR = {
								trait = envious
								trait = deceitful
								trait = ambitious
							}
						}

						opinion = {
							who = liege
							value < 50
						}
					}
					trigger_else = {
						opinion = {
							who = liege
							value < 25
						}
					}
				}
			}
		}

		mult_modifier = {
			factor = 0.2
			FROM = { is_dumb_trigger = yes }
		}

		mult_modifier = {
			factor = 0.2

			FROM = {
				trigger_if = {
					limit = {
						OR = {
							trait = envious
							trait = deceitful
							trait = ambitious
						}
					}

					opinion = {
						who = liege
						value >= 0
					}
				}
				trigger_else = {
					opinion = {
						who = liege
						value >= 25
					}
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			FROM = {
				opinion = {
					who = liege
					value < -50
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			FROM = {
				opinion = {
					who = liege
					value < -75
				}
			}
		}

		mult_modifier = {
			factor = 2.0

			# Subtle balance against nepotism
			holder_scope = {
				NOT = { dynasty = FROM }

				top_liege = {
					higher_real_tier_than = COUNT
					dynasty = PREV
					dynasty_realm_power >= 0.25
				}
			}
		}

		mult_modifier = {
			factor = 2.0

			# Subtle balance against nepotism
			holder_scope = {
				NOT = { dynasty = FROM }

				top_liege = {
					higher_real_tier_than = COUNT
					dynasty = PREV
					dynasty_realm_power >= 0.40
				}
			}
		}

		mult_modifier = {
			factor = 1.5
			FROM = { is_smart_trigger = yes }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = envious }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = deceitful }
		}

		mult_modifier = {
			factor = 4.0
			FROM = { trait = ambitious }
		}

		# CK2Plus
		mult_modifier = {
			factor = 5.0
			FROM = { trait = decadent }
		}

		mult_modifier = {
			factor = 0.1
			FROM = { relative_power_to_liege < 0.20 }
		}

		mult_modifier = {
			factor = 0.25
			FROM = { relative_power_to_liege < 0.30 }
		}

		mult_modifier = {
			factor = 0.5
			FROM = { relative_power_to_liege < 0.40 }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { relative_power_to_liege >= 0.5 }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { relative_power_to_liege >= 0.75 }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { relative_power_to_liege >= 1.0 }
		}

		mult_modifier = {
			factor = 0.25
			FROM = { intrigue < 8 }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { intrigue >= 15 }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { intrigue >= 20 }
		}

		mult_modifier = {
			factor = 1.5

			FROM = {
				opinion = {
					who = liege
					value < -25
				}
			}
		}
	}
}

# Vassal ruler plots to gain claim on a fellow vassal's title
plot_gain_fellow_vassal_title = {
	type = realm_titles
	vassal_intrigue_plot = yes

	# Plotter scope
	potential = {
		is_landed = yes
		independent = no
		is_adult = yes
		prisoner = no
		is_incapable = no

		OR = {
			is_feudal = yes
			is_tribal = yes
		}

		NOR = {
			trait = imbecile
		}

	#	trigger_if = {
	#		limit = { ai = yes }
	#		has_character_flag = allow_plotting
	#	}
	}

	# Title scope
	# ROOT is title
	# FROM is plotter
	target_potential = {
		FROM = {
			OR = {
				any_demesne_title = {
					de_jure_liege = ROOT
				}

				primary_title = {
					de_jure_vassal_or_below = ROOT
				}
			}
		}

		holder_scope = {
			OR = {
				is_feudal = yes
				is_tribal = yes
			}

			is_landed = yes
			higher_real_tier_than = BARON
			independent = no
			same_liege = FROM

			NOR = {
				is_liege_of = FROM
				character = FROM
				reverse_has_truce = FROM
				has_non_aggression_pact_with = FROM

				has_opinion_modifier = {
					name = opinion_recent_plot
					who = FROM
				}
			}
		}
	}

	# Title scope
	# FROM is plotter
	allow = {
		is_vice_royalty = no

		NOR = {
			claimed_by = FROM
			current_heir = { character = FROM }
		}
	}

	# Title scope
	# FROM is plotter
	success = {
		claimed_by = FROM
	}

	# FROM is plotter
	effect = {
		FROM = {
			show_scope_change = no

			if = {
				limit = { intrigue < 10 }
				change_intrigue = 1
			}

			any_plot_backer = {
				show_scope_change = no

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

			clr_character_flag = allow_plotting

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}

			hidden_effect = {
				change_variable = {
					which = lifestyle_intrigue
					value = 1
				}
			}
		}
	}

	# Title scope
	# FROM is plotter
	abort = {
		OR = {
			holder = FROM
			has_holder = no
			is_vice_royalty = yes
		}
	}

	abort_effect = {
		FROM = {
			clr_character_flag = allow_plotting

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}
		}

		holder_scope = {
			opinion = {
				name = opinion_recent_plot
				who = FROM
				years = 5
			}
		}
	}

	chance = {
		factor = 1 # Must be an integer

		trigger = {
			FROM = {
				trigger_if = {
					limit = { ai = yes } # Needed for some reason (maybe a bug)

					war = no

					NOR = {
						trait = content
						trait = kind
					}

					trigger_if = {
						limit = {
							OR = {
								trait = envious
								trait = deceitful
								trait = ambitious
							}
						}

						ROOT = {
							holder_scope = {
								reverse_opinion = {
									who = FROM
									value < 50
								}
							}
						}
					}
					trigger_else = {
						ROOT = {
							holder_scope = {
								reverse_opinion = {
									who = FROM
									value < 25
								}
							}
						}
					}
				}
			}
		}

		mult_modifier = {
			factor = 0.2
			FROM = { is_dumb_trigger = yes }
		}

		mult_modifier = {
			factor = 0.2

			trigger_if = {
				limit = {
					FROM = {
						OR = {
							trait = envious
							trait = deceitful
							trait = ambitious
						}
					}
				}

				holder_scope = {
					reverse_opinion = {
						who = FROM
						value >= 25
					}
				}
			}
			trigger_else = {
				holder_scope = {
					reverse_opinion = {
						who = FROM
						value >= 0
					}
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			holder_scope = {
				reverse_opinion = {
					who = FROM
					value < -50
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			holder_scope = {
				reverse_opinion = {
					who = FROM
					value < -75
				}
			}
		}

		mult_modifier = {
			factor = 1.5
			FROM = { is_smart_trigger = yes }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = envious }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = deceitful }
		}

		mult_modifier = {
			factor = 4.0
			FROM = { trait = ambitious }
		}

		# CK2Plus
		mult_modifier = {
			factor = 5.0
			FROM = { trait = decadent }
		}

		mult_modifier = {
			factor = 0.25
			FROM = { intrigue < 8 }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { intrigue >= 15 }
		}

		mult_modifier = {
			factor = 1.5
			FROM = { intrigue >= 20 }
		}
	}
}

# Seize Trade Post (Republics only)
plot_seize_trade_post = {
	type = rep_trade_posts
	intrigue_plot = yes

	# Plotter scope
	potential = {
		has_dlc = "The Republic"
		is_patrician = yes
		is_merchant_republic = no
		is_adult = yes
		prisoner = no
		is_incapable = no
		NOT = { trait = imbecile }

	#	trigger_if = {
	#		limit = { ai = yes }
	#		has_character_flag = allow_plotting
	#	}
	}

	# Target scope
	# FROM is plotter
	allow = {
		has_trade_post = yes

		any_neighbor_province = {
			has_trade_post = yes

			trade_post_owner = {
				character = FROM
			}
		}

		trade_post_owner = {
			num_of_trade_post_diff = {
				character = FROM
				value >= 1
			}

			OR = {
				same_liege = FROM
				is_liege_of = FROM
			}

			NOR = {
				character = FROM
				reverse_has_truce = FROM
				is_allied_with = FROM
				has_non_aggression_pact_with = FROM

				has_opinion_modifier = {
					name = opinion_seized_tp
					who = FROM
				}

				has_opinion_modifier = {
					name = opinion_recent_plot
					who = FROM
				}
			}

			# Only if there is no non-aggression-pact with the trade post owner
			NOT = { has_non_aggression_pact_with = FROM }
		}
	}

	# Title scope
	# FROM is plotter
	success = {
		trade_post_owner = {
			character = FROM
		}
	}

	# Title scope
	# FROM is plotter
	effect = {
		seize_trade_post = FROM

		FROM = {
			clr_character_flag = allow_plotting

			hidden_effect = {
				change_variable = {
					which = lifestyle_intrigue
					value = 1
				}
			}

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}
		}
	}

	abort = {
	}

	abort_effect = {
		FROM = {
			clr_character_flag = plot_seize_trade_post_decision_taken
			clr_character_flag = allow_plotting

			if = {
				limit = { has_character_modifier = plot_assisted_spying }
				remove_character_modifier = plot_assisted_spying
			}
		}
	}

	chance = {
		factor = 1 # Must be an integer

		trigger = {
			FROM = {
				trigger_if = {
					limit = { ai = yes } # Needed for some reason (maybe a bug)

					war = no

					NOR = {
						trait = content
						trait = kind
					}

					trigger_if = {
						limit = {
							OR = {
								trait = envious
								trait = deceitful
								trait = ambitious
							}
						}

						ROOT = {
							trade_post_owner = {
								reverse_opinion = {
									who = FROM
									value < 50
								}
							}
						}
					}
					trigger_else = {
						ROOT = {
							trade_post_owner = {
								reverse_opinion = {
									who = FROM
									value < 25
								}
							}
						}
					}
				}
			}
		}

		mult_modifier = {
			factor = 0.01
			FROM = { trait = content }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { is_dumb_trigger = yes }
		}

		mult_modifier = {
			factor = 0.2
			FROM = { trait = kind }
		}

		mult_modifier = {
			factor = 0.2

			trigger_if = {
				limit = {
					FROM = {
						OR = {
							trait = envious
							trait = deceitful
							trait = ambitious
						}
					}
				}

				trade_post_owner = {
					reverse_opinion = {
						who = FROM
						value >= 0
					}
				}
			}
			trigger_else = {
				trade_post_owner = {
					reverse_opinion = {
						who = FROM
						value >= 25
					}
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			trade_post_owner = {
				reverse_opinion = {
					who = FROM
					value < -50
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			trade_post_owner = {
				reverse_opinion = {
					who = FROM
					value < -75
				}
			}
		}

		mult_modifier = {
			factor = 1.5
			FROM = { is_smart_trigger = yes }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = envious }
		}

		mult_modifier = {
			factor = 2.0
			FROM = { trait = deceitful }
		}

		mult_modifier = {
			factor = 4.0
			FROM = { trait = ambitious }
		}

		mult_modifier = {
			factor = 4.0

			trade_post_owner = {
				num_of_trade_post_diff = {
					character = FROM
					value >= 10
				}
			}
		}

		# CK2Plus
		mult_modifier = {
			factor = 4.0

			trade_post_owner = {
				num_of_trade_post_diff = {
					character = FROM
					value >= 3
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			trade_post_owner = {
				reverse_opinion = {
					who = FROM
					value < 0
				}
			}
		}

		mult_modifier = {
			factor = 1.5

			trade_post_owner = {
				reverse_opinion = {
					who = FROM
					value < -25
				}
			}
		}
	}
}

###SOCIETIES PLOTS###

###Assassins###

plot_assassins_collect_debt = {
	type = realm_characters_plus # All characters in the same realm, plus rivals and relatives of self, parents, children and spouse, and quest target
	intrigue_plot = yes

	# Plotter scope
	potential = {
		society_member_of = the_assassins
		has_quest = quest_the_assassins_collect_debt
		prisoner = no
		is_adult = yes
		is_incapable = no
	}

	# Targe scope
	# FROM is plotter
	player_allow = {
		FROM = { has_quest = quest_the_assassins_collect_debt }
	}

	# Target scope
	# ROOT is target
	# FROM is plotter
	target_potential = {
		FROM = {
			has_quest = quest_the_assassins_collect_debt
			quest_target = { character = ROOT }
		}
	}

	# Target scope
	# ROOT is target
	# FROM is plotter
	allow = {
		custom_tooltip = {
			text = plot_assassins_collect_debt_allow_tt

			FROM = {
				has_quest = quest_the_assassins_collect_debt
				quest_target = { character = ROOT }
			}
		}
	}

	# FROM is plotter
	# ROOT is target
	success = {
		custom_tooltip = {
			text = plot_assassins_collect_debt_success
			FROM = { has_character_flag = collected_debt_success }
		}
	}

	# FROM is plotter
	# ROOT is target
	abort = {
		OR = {
			is_alive = no

			FROM = {
				OR = {
					is_alive = no
					has_character_flag = collected_debt_failure
				}
			}
		}
	}

	# FROM is plotter
	# ROOT is target
	abort_effect = {
		FROM = { clr_character_flag = collected_debt_failure }
	}

	# FROM is plotter
	# ROOT is target
	effect = {
		FROM = { clr_character_flag = collected_debt_success }
	}

	chance = {
		factor = 50
	}
}