﻿#############
# Scheme Scripted Modifiers
#############

##################################################
# Success Chance Modifiers

laamp_contract_scheme_basic_success_chance_modifier = {
	# Higher tier rulers are more demanding
	## Count
	modifier = {
		add = -20
		desc = laamp_contracts.tt.job_for_count
		scope:target.highest_held_title_tier = tier_county
	}
	## Duke
	modifier = {
		add = -30
		desc = laamp_contracts.tt.job_for_duke
		scope:target.highest_held_title_tier = tier_duchy
	}
	## King
	modifier = {
		add = -40
		desc = laamp_contracts.tt.job_for_king
		scope:target.highest_held_title_tier = tier_kingdom
	}
	## Emperor
	modifier = {
		add = -50
		desc = laamp_contracts.tt.job_for_emperor
		scope:target.highest_held_title_tier >= tier_empire
	}
}

# Used for standard low-ish skill contributions across most schemes; if you need a different value, you can just use a non-scripted modifier.
scheme_type_skill_success_chance_modifier = {
	modifier = {
		add = scope:owner.$SKILL$
		desc = SCHEME_YOUR_$SKILL$
	}
}

##################################################
# Countermeasure Modifiers

apply_calculated_scheme_success_chance_adjustments_modifier = {
	first_valid = {
		# Bonuses Against
		## Minor
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_minor_value
			desc = countermeasures_in_target_court.tt.effective
			# Make sure we hit the right scheme type.
			var:apply_countermeasures ?= flag:calculating
			# And then if a parameter applies.
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_calculated_schemes_bonus_minor
			}
		}
		## Medium
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_medium_value
			desc = countermeasures_in_target_court.tt.effective
			# Make sure we hit the right scheme type.
			var:apply_countermeasures ?= flag:calculating
			# And then if a parameter applies.
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_calculated_schemes_bonus_medium
			}
		}
		## Major
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_major_value
			desc = countermeasures_in_target_court.tt.effective
			# Make sure we hit the right scheme type.
			var:apply_countermeasures ?= flag:calculating
			# And then if a parameter applies.
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_calculated_schemes_bonus_major
			}
		}
		# Maluses Against
		## Minor
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_minor_value
			desc = countermeasures_in_target_court.tt.backfiring
			# Make sure we hit the right scheme type.
			var:apply_countermeasures ?= flag:calculating
			# And then if a parameter applies.
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_calculated_schemes_malus_minor
			}
		}
		## Medium
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_medium_value
			desc = countermeasures_in_target_court.tt.backfiring
			# Make sure we hit the right scheme type.
			var:apply_countermeasures ?= flag:calculating
			# And then if a parameter applies.
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_calculated_schemes_malus_medium
			}
		}
		## Major
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_major_value
			desc = countermeasures_in_target_court.tt.backfiring
			# Make sure we hit the right scheme type.
			var:apply_countermeasures ?= flag:calculating
			# And then if a parameter applies.
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_calculated_schemes_malus_major
			}
		}
	}
}

apply_opportunistic_scheme_success_chance_adjustments_modifier = {
	first_valid = {
		# Bonuses Against
		## Minor
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_minor_value
			desc = countermeasures_in_target_court.tt.effective
			var:apply_countermeasures ?= flag:opportunistic
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_opportunistic_schemes_bonus_minor
			}
		}
		## Medium
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_medium_value
			desc = countermeasures_in_target_court.tt.effective
			var:apply_countermeasures ?= flag:opportunistic
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_opportunistic_schemes_bonus_medium
			}
		}
		## Major
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_major_value
			desc = countermeasures_in_target_court.tt.effective
			var:apply_countermeasures ?= flag:opportunistic
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_opportunistic_schemes_bonus_major
			}
		}
		# Maluses Against
		## Minor
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_minor_value
			desc = countermeasures_in_target_court.tt.backfiring
			var:apply_countermeasures ?= flag:opportunistic
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_opportunistic_schemes_malus_minor
			}
		}
		## Medium
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_medium_value
			desc = countermeasures_in_target_court.tt.backfiring
			var:apply_countermeasures ?= flag:opportunistic
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_opportunistic_schemes_malus_medium
			}
		}
		## Major
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_major_value
			desc = countermeasures_in_target_court.tt.backfiring
			var:apply_countermeasures ?= flag:opportunistic
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_opportunistic_schemes_malus_major
			}
		}
	}
}

apply_indirect_scheme_success_chance_adjustments_modifier = {
	first_valid = {
		# Bonuses Against
		## Minor
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_minor_value
			desc = countermeasures_in_target_court.tt.effective
			var:apply_countermeasures ?= flag:indirect
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_indirect_schemes_bonus_minor
			}
		}
		## Medium
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_medium_value
			desc = countermeasures_in_target_court.tt.effective
			var:apply_countermeasures ?= flag:indirect
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_indirect_schemes_bonus_medium
			}
		}
		## Major
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_major_value
			desc = countermeasures_in_target_court.tt.effective
			var:apply_countermeasures ?= flag:indirect
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_indirect_schemes_bonus_major
			}
		}
		# Maluses Against
		## Minor
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_minor_value
			desc = countermeasures_in_target_court.tt.backfiring
			var:apply_countermeasures ?= flag:indirect
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_indirect_schemes_malus_minor
			}
		}
		## Medium
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_medium_value
			desc = countermeasures_in_target_court.tt.backfiring
			var:apply_countermeasures ?= flag:indirect
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_indirect_schemes_malus_medium
			}
		}
		## Major
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_major_value
			desc = countermeasures_in_target_court.tt.backfiring
			var:apply_countermeasures ?= flag:indirect
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_indirect_schemes_malus_major
			}
		}
	}
}

apply_political_scheme_success_chance_adjustments_modifier = {
	first_valid = {
		# Bonuses Against
		## Minor
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_minor_value
			desc = countermeasures_in_target_court.tt.effective
			var:apply_countermeasures ?= flag:political
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_political_schemes_bonus_minor
			}
		}
		## Medium
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_medium_value
			desc = countermeasures_in_target_court.tt.effective
			var:apply_countermeasures ?= flag:political
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_political_schemes_bonus_medium
			}
		}
		## Major
		modifier = {
			add = countermeasure_scheme_category_success_chance_bonus_against_major_value
			desc = countermeasures_in_target_court.tt.effective
			var:apply_countermeasures ?= flag:political
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_political_schemes_bonus_major
			}
		}
		# Maluses Against
		## Minor
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_minor_value
			desc = countermeasures_in_target_court.tt.backfiring
			var:apply_countermeasures ?= flag:political
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_political_schemes_malus_minor
			}
		}
		## Medium
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_medium_value
			desc = countermeasures_in_target_court.tt.backfiring
			var:apply_countermeasures ?= flag:political
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_political_schemes_malus_medium
			}
		}
		## Major
		modifier = {
			add = countermeasure_scheme_category_success_chance_malus_against_major_value
			desc = countermeasures_in_target_court.tt.backfiring
			var:apply_countermeasures ?= flag:political
			countermeasure_parameter_applies_against_char_trigger = {
				SCHEME_TARGET = scope:target
				SCHEME_OWNER = scope:owner
				PARAMETER = success_chance_vs_political_schemes_malus_major
			}
		}
	}
}

##################################################
# Acceptance Modifiers

# Basic modifiers that should always apply to virtually every scheme.
ai_agent_join_chance_basic_suite_modifier = {
	# Base Reluctance, including negative AI Energy
	modifier = {
		add = {
			value = -30
			# Energy can play a role.
			if = {
				limit = { ai_energy < 0 }
				add = {
					value = ai_energy
					multiply = 0.5
				}
			}
			# Courtiers fall in line.
			if = {
				limit = { host = scope:owner }
				add = 20
			}
			# Plus, make people less willing to scheme against higher tier targets.
			if = {
				limit = {
					scope:scheme = { is_scheme_target_type = character }
				}
				scope:target = {
					if = {
						limit = { highest_held_title_tier = tier_duchy }
						add = -5
					}
					else_if = {
						limit = { highest_held_title_tier = tier_kingdom }
						add = -15
					}
					else_if = {
						limit = { highest_held_title_tier >= tier_empire }
						add = -30
					}
				}
			}
		}
		desc = BASE_RELUCTANCE
	}

	# Nomad Yurt
	modifier = {
		add = {
			value = 0
			if = {
				limit = {
					scope:owner.domicile ?= {
						has_domicile_parameter = nomad_yurt_realm_agent_acceptance_lvl_3
					}
				}
				add = 30
			}
			else_if = {
				limit = {
					scope:owner.domicile ?= {
						has_domicile_parameter = nomad_yurt_realm_agent_acceptance_lvl_2
					}
				}
				add = 20
			}
			else_if = {
				limit = {
					scope:owner.domicile ?= {
						has_domicile_parameter = nomad_yurt_realm_agent_acceptance_lvl_1
					}
				}
				add = 10
			}
		}
		scope:owner = {
			government_has_flag = government_is_nomadic
			domicile ?= { has_domicile_building_or_higher = agent_dread_yurt_01 }
		}
		OR = {
			top_liege = scope:owner
			host ?= scope:owner
		}
		desc = agent_dread_yurt_01_domicile_building_with_value #Unop: Changed with a custom yml that display the value in the UI
	}

	# Don't scheme easily against people in other realms.
	modifier = {
		add = -25
		# Weird formatting to prevent errors.
		scope:scheme = { is_scheme_target_type = character }
		trigger_if = {
			limit = {
				scope:scheme = { is_scheme_target_type = character }
			}
			NOR = {
				top_liege = scope:target.host.top_liege
				host = scope:target.host.top_liege
			}
		}
		desc = sway_foreign_target
	}

	# add willingness based on agent contribution after TIT-53044 is done

	# diplomacy
	modifier = {
		scope:scheme = {
			scheme_skill = diplomacy
		}
		add = {
			value = scope:owner.diplomacy
			multiply = 0.5
		}
		desc = DIPLOMACY_SKILL_REASON
	}
	# martial
	modifier = {
		scope:scheme = {
			scheme_skill = martial
		}
		add = {
			value = scope:owner.martial
			multiply = 0.5
		}
		desc = MARTIAL_SKILL_REASON
	}
	# stewardship
	modifier = {
		scope:scheme = {
			scheme_skill = stewardship
		}
		add = {
			value = scope:owner.stewardship
			multiply = 0.5
		}
		desc = STEWARDSHIP_SKILL_REASON
	}
	# intrigue
	modifier = {
		scope:scheme = {
			scheme_skill = intrigue
		}
		add = scope:owner.intrigue
		desc = INTRIGUE_SKILL_REASON
	}
	# learning
	modifier = {
		scope:scheme = {
			scheme_skill = learning
		}
		add = {
			value = scope:owner.learning
			multiply = 0.5
		}
		desc = LEARNING_SKILL_REASON
	}
	# prowess
	modifier = {
		scope:scheme = {
			scheme_skill = prowess
		}
		add = {
			value = scope:owner.prowess
			multiply = 0.5
		}
		desc = PROWESS_SKILL_REASON
	}
	# intrigue boost to non-intrigue schemes
	modifier = {
		NOT = {
			scope:scheme = {
				scheme_skill = intrigue
			}
		}
		add = {
			value = scope:owner.intrigue
			multiply = 0.5
		}
		desc = INTRIGUE_SKILL_REASON
	}
	# Your spymaster skill
	modifier = {
		exists = scope:owner.cp:councillor_spymaster
		add = {
			value = scope:owner.cp:councillor_spymaster.intrigue
			multiply = 0.5
		}
		desc = SPYMASTER_INTRIGUE_SKILL_REASON
	}
	# Your second skill
	modifier = {
		exists = scope:owner.court_position:second_camp_officer
		add = {
			value = scope:owner.court_position:second_camp_officer.intrigue
			multiply = 0.5
		}
		desc = SECOND_INTRIGUE_SKILL_REASON
	}
	# Coercion.
	## Sent a gift.
	modifier = {
		add = {
			value = 10
			scope:recipient = {
				# A bit more for greedy chars.
				if = {
					limit = { has_trait = greedy }
					add = 10
				}
			}
		}
		scope:gift ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_GIFT
	}
	## Send a bigger gift.
	modifier = {
		add = {
			value = 20
			scope:recipient = {
				# A bit more for greedy chars.
				if = {
					limit = { has_trait = greedy }
					add = 10
				}
			}
		}
		scope:gift_significant ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_GIFT_SIGNIFICANT
	}
	## Sent a treasury gift.
	modifier = {
		add = {
			value = 10
			scope:recipient = {
				# A bit more for greedy chars.
				if = {
					limit = { has_trait = greedy }
					add = 10
				}
			}
		}
		scope:treasury ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_GIFT
	}
	## Send a bigger treasury gift.
	modifier = {
		add = {
			value = 20
			scope:recipient = {
				# A bit more for greedy chars.
				if = {
					limit = { has_trait = greedy }
					add = 10
				}
			}
		}
		scope:treasury_significant ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_GIFT_SIGNIFICANT
	}
	## Offer a hook on yourself.
	modifier = {
		add = 20
		scope:offer_hook ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_OFFER_HOOK
	}
	## Offer a strong hook on yourself.
	modifier = {
		add = 50
		scope:offer_hook_strong ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_OFFER_HOOK_STRONG
	}
	## Used a hook.
	modifier = {
		add = 100
		scope:hook ?= yes
		desc = SCHEME_WEAK_HOOK_USED
	}
	## Burnt opportunities.
	modifier = {
		add = 10
		scope:opportunities_t1 ?= yes
		desc = SCHEME_WITH_OPPORTUNITIES
	}
	modifier = {
		add = 30
		scope:opportunities_t2 ?= yes
		desc = SCHEME_WITH_OPPORTUNITIES
	}
	## Offer prestige.
	modifier = {
		add = {
			value = 20
			scope:recipient = {
				# A bit more for arrogant chars.
				if = {
					limit = { has_trait = arrogant }
					add = 10
				}
				# A bit less for humble ones.
				else_if = {
					limit = { has_trait = humble }
					add = -10
				}
			}
		}
		scope:prestige ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_PRESTIGE
	}
	## Offer influence.
	modifier = {
		add = {
			value = 20
			scope:recipient = {
				# A bit more for ambitious chars.
				if = {
					limit = { has_trait = ambitious }
					add = 10
				}
				# A bit less for content ones.
				else_if = {
					limit = { has_trait = content }
					add = -10
				}
			}
		}
		scope:influence ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_INFLUENCE
	}
	## Offer council rights guaranteed in their vassal contract.
	modifier = {
		add = {
			value = 30
			scope:recipient = {
				# A bit more for arrogant chars.
				if = {
					limit = { has_trait = arrogant }
					add = 10
				}
				# A bit less for humble ones.
				else_if = {
					limit = { has_trait = humble }
					add = -20
				}
			}
		}
		scope:council_rights ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_COUNCIL_RIGHTS
	}
	## Offer a county that's de jure theirs but which you control.
	modifier = {
		add = {
			value = 50
			# Higher tier characters are steadily less impressed.
			subtract = {
				value = scope:recipient.highest_held_title_tier
				add = -1
				multiply = 10
			}
		}
		scope:de_jure_title ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_DE_JURE_TITLE
	}
	## Offer a county they claim but which you control.
	modifier = {
		add = {
			value = 50
			# Higher tier characters are steadily less impressed.
			subtract = {
				value = scope:recipient.highest_held_title_tier
				add = -1
				multiply = 10
			}
		}
		scope:claimed_title ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_CLAIMED_TITLE
	}
	## Offer piety.
	modifier = {
		add = {
			value = 20
			scope:recipient = {
				# A bit more if they're zealous.
				if = {
					limit = { has_trait = zealous }
					add = 10
				}
			}
		}
		scope:piety ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_PIETY
	}
	## Offer Herd
	modifier = {
		add = {
			value = 20
			scope:recipient = {
				# A bit more for ambitious chars.
				if = {
					limit = { has_trait = ambitious }
					add = 10
				}
				# A bit less for content ones.
				if = {
					limit = { has_trait = content }
					add = -10
				}
			}
		}
		scope:herd ?= yes
		exists = scope:recipient
		desc = SCHEME_WITH_HERD
	}
	## Released them from prison in exchange for scheme support (ep3_emperor_yearly.2130)
	modifier = {
		has_character_flag = ep3_2130_ex_prisoner
		add = 1000
		desc = SCHEME_OWE_FREEDOM
	}
	# Relations
	## Rivals with scope:owner
	modifier = {
		add = -10
		has_relation_rival = scope:owner
		NOT = { has_relation_nemesis = scope:owner }
		desc = "SCHEME_AGAINST_RIVAL"
	}
	## Nemeses should be even more inclined
	modifier = {
		add = -1000
		has_relation_nemesis = scope:owner
		desc = SCHEME_AGAINST_NEMESIS
	}
	## Friends with scope:owner
	modifier = {
		add = 50
		has_relation_friend = scope:owner
		NOT = { has_relation_best_friend = scope:owner }
		desc = "SCHEME_FOR_FRIEND"
	}
	## Best friends should be even less inclined
	modifier = {
		add = 100
		has_relation_best_friend = scope:owner
		desc = SCHEME_FOR_BEST_FRIEND
	}
	modifier = {
		add = 25
		has_relation_lover = scope:owner
		NOT = { has_relation_soulmate = scope:owner }
		desc = SCHEME_FOR_LOVER
	}
	## As should soulmates
	modifier = {
		add = 100
		has_relation_soulmate = scope:owner
		desc = SCHEME_FOR_SOULMATE
	}
	## Nursed Child of scope:owner
	modifier = {
		add = 20
		exists = scope:owner
		has_relation_nursed_child = scope:owner
		desc = SCHEME_NURSED_CHILD
	}
	## Nursed Child of scope:recipient
	modifier = {
		add = -20
		exists = scope:recipient
		has_relation_nursed_child = scope:recipient
		desc = SCHEME_NURSED_CHILD
	}
	## Wet Nurse of scope:owner
	modifier = {
		add = 20
		exists = scope:owner
		has_relation_wet_nurse = scope:owner
		desc = SCHEME_AGAINST_WET_NURSE
	}
	## Wet Nurse of scope:recipient
	modifier = {
		add = -20
		exists = scope:recipient
		has_relation_wet_nurse = scope:recipient
		desc = SCHEME_AGAINST_WET_NURSE
	}
	## elder of scope:owner
	modifier = {
		add = -20
		exists = scope:owner
		has_relation_elder = scope:owner
		desc = SCHEME_AGAINST_ELDER
	}
	## disciple of scope:recipient
	modifier = {
		add = -20
		exists = scope:recipient
		has_relation_disciple = scope:recipient
		desc = SCHEME_AGAINST_DISCIPLE
	}
	## disciple of scope:owner
	modifier = {
		add = 20
		exists = scope:owner
		has_relation_disciple = scope:owner
		desc = SCHEME_FOR_ELDER
	}
	## elder of scope:recipient
	modifier = {
		add = 20
		exists = scope:recipient
		has_relation_elder = scope:recipient
		desc = SCHEME_FOR_DISCIPLE
	}

	## Loving (or at least non-hostile) spouse of scope:owner
	modifier = {
		add = 10
		is_consort_of = scope:owner
		opinion = {
			target = scope:owner
			value > 0
		}
		desc = "SCHEME_AGAINST_SPOUSE"
	}
	# same movement as owner
	modifier = {
		add = {
			value = 50
			if = {
				limit = {
					is_in_pro_hegemon_or_hegemon_movement = yes
				}
				multiply = 1.5
			}
		}
		is_in_same_movement_as = { TARGET = scope:owner }
		desc = OWNER_IS_MY_MOVEMENT_MEMBER
	}
	# Opinion
	## How much does the prospective agent like scope:owner?
	opinion_modifier = {
		trigger = {
			this != scope:owner
		}
		who = this
		opinion_target = scope:owner
		multiplier = 0.5
		step = 5
		desc = SCHEME_MY_OPINION_OF_YOU
	}
	# Event
	## Spinning Webs
	modifier = {
		add = 25
		exists = scope:recipient
		scope:scheme ?= {
			is_target_in_variable_list = {
				name = increased_agent_join_acceptance
				target = scope:recipient
			}
		}
		desc = SCHEME_CONVINCED_AT_FEAST
	}
	# TGP Bloc
	modifier = {
		add = determination_cohesion_reward_agent_join_value
		NAND = {
			exists = scope:scheme.scheme_target_character
			this = scope:target
		}
		scope:owner = {
			is_house_head = yes
			house.house_confederation ?= { has_cohesion_level_parameter = bloc_members_join_leaders_schemes }
		}
		house.house_confederation = scope:owner.house.house_confederation
		desc = DETERMINATION_BLOC_COHESION_REASON
	}
	# Edge Cases
	## Agent will never scheme against themselves
	modifier = {
		add = -1000
		exists = scope:scheme.scheme_target_character
		this = scope:target
		desc = COMPASSIONATE_REASON #SCHEME_NOT_AGAINST_SELF
	}
}

# Core hostile modifiers that should be applied to most/all hostile schemes.
ai_agent_join_chance_hostile_general_suite_modifier = {
	# Difficulty
	## Easy
	modifier = {
		add = -10
		is_ai = yes
		has_game_rule = easy_difficulty
		scope:target = { is_ai = no }
		desc = "easy_difficulty"
	}
	## Very Easy
	modifier = {
		add = -20
		is_ai = yes
		has_game_rule = very_easy_difficulty
		scope:target = { is_ai = no }
		desc = "very_easy_difficulty"
	}
	## Hard, for AI
	modifier = {
		add = -25
		has_game_rule = hard_difficulty
		scope:owner = { is_ai = no }
		scope:target = { is_ai = yes }
		desc = "FACTION_REASON_DIFFICULTY_HARD"
	}
	## Very Hard, for AI
	modifier = {
		add = -50
		has_game_rule = very_hard_difficulty
		scope:owner = { is_ai = no }
		scope:target = { is_ai = yes }
		desc = "FACTION_REASON_DIFFICULTY_VERY_HARD"
	}
	## Hard, for Players
	modifier = {
		add = 25
		has_game_rule = hard_difficulty
		scope:owner = { is_ai = yes }
		scope:target = { is_ai = no }
		desc = "FACTION_REASON_DIFFICULTY_HARD"
	}
	## Very Hard, for Players
	modifier = {
		add = 50
		has_game_rule = very_hard_difficulty
		scope:owner = { is_ai = yes }
		scope:target = { is_ai = no }
		desc = "FACTION_REASON_DIFFICULTY_VERY_HARD"
	}
	## Conquerors
	modifier = {
		add = -20
		is_ai = yes
		scope:target = { ai_should_get_extreme_conqueror_bonuses = yes }
		desc = "ai_conqueror_modifier"
	}
	# Countermeasure Resistance
	## Honest
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_honest
		}
	}
	## Just
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_just
		}
	}
	## Deceitful
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_deceitful
		}
	}
	## Gregarious
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_gregarious
		}
	}
	## Arrogant
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_arrogant
		}
	}
	# Dread
	## For scope:target
	### Intimidated
	modifier = {
		trigger = {
			has_dread_level_towards = {
				target = scope:target
				level = 1
			}
		}
		add = -100
		desc = SCHEME_I_AM_INTIMIDATED
	}
	### Cowed
	modifier = {
		trigger = {
			has_dread_level_towards = {
				target = scope:target
				level = 2
			}
		}
		add = -1000
		desc = SCHEME_I_AM_COWED
	}
	## For scope:owner
	### Intimidated
	modifier = {
		add = intimidated_scheme_reason_value
		target_is_liege_or_above = scope:owner
		has_dread_level_towards = {
			target = scope:owner
			level = 1
		}
		desc = INTIMIDATED_REASON
	}
	modifier = {
		add = intimidated_scheme_external_reason_value
		NOT = { target_is_liege_or_above = scope:owner }
		has_dread_level_towards = {
			target = scope:owner
			level = 1
		}
		desc = INTIMIDATED_REASON
	}
	### Cowed
	modifier = {
		add = cowed_scheme_reason_value
		target_is_liege_or_above = scope:owner
		has_dread_level_towards = {
			target = scope:owner
			level = 2
		}
		desc = COWED_REASON
	}
	modifier = {
		add = cowed_scheme_external_reason_value
		NOT = { target_is_liege_or_above = scope:owner }
		has_dread_level_towards = {
			target = scope:owner
			level = 2
		}
		desc = COWED_REASON
	}
	# Relations
	## Rivals with scope:target
	modifier = {
		add = 10
		has_relation_rival = scope:target
		NOT = { has_relation_nemesis = scope:target }
		desc = "SCHEME_AGAINST_RIVAL"
	}
	## Nemeses should be even more inclined
	modifier = {
		add = 1000
		has_relation_nemesis = scope:target
		desc = SCHEME_AGAINST_NEMESIS
	}
	## Friends with scope:target
	modifier = {
		add = -20
		has_relation_friend = scope:target
		NOT = { has_relation_best_friend = scope:target }
		desc = "SCHEME_AGAINST_FRIEND"
	}
	## Best friends should be even less inclined
	modifier = {
		add = -1000
		has_relation_best_friend = scope:target
		desc = SCHEME_AGAINST_BEST_FRIEND
	}
	## As should soulmates
	modifier = {
		add = -1000
		has_relation_soulmate = scope:target
		desc = SCHEME_AGAINST_SOULMATE
	}
	## Loving (or at least non-hostile) spouse of scope:target
	modifier = {
		add = -10
		is_consort_of = scope:target
		opinion = {
			target = scope:target
			value > 0
		}
		desc = "SCHEME_AGAINST_SPOUSE"
	}
	# Faith
	## Sacred Lies tenet
	modifier = {
		add = 20
		faith = { has_doctrine_parameter = adherents_more_likely_to_join_schemes }
		desc = "SCHEME_IS_SACRED"
	}
	## Don't mess with your HoF.
	modifier = {
		trigger = {
			faith.religious_head ?= scope:target
		}
		add = {
			value = -25
			if = {
				limit = { has_trait = zealous }
				multiply = 2
			}
			else_if = {
				limit = { has_trait = arbitrary }
				multiply = 0
			}
		}
		desc = SCHEME_HEAD_OF_FAITH_REASON
	}
	# Culture
	## Esteemed Hospitality
	modifier = {
		add = -25
		scope:target = {
			culture = { has_cultural_parameter = courtiers_and_guests_less_likely_to_join_schemes }
		}
		OR = {
			is_courtier_of = scope:target
			is_pool_guest_of = scope:target
			is_foreign_court_guest_of = scope:target
		}
		desc = RESPECTED_HOST
	}
	## Varangians don't want to betray the Basileus
	modifier = {
		add = -50
		has_trait = varangian
		OR = {
			is_courtier_of = scope:target
			is_pool_guest_of = scope:target
			is_foreign_court_guest_of = scope:target
		}
		desc = VARANGIAN_LOYALTY
	}
	# Traits
	## Disloyal
	modifier = {
		add = 20
		has_trait = disloyal
		desc = "HAS_DISLOYAL_TRAIT"
	}
	## Loyal
	modifier = {
		add = -10
		has_trait = loyal
		desc = "HAS_LOYAL_TRAIT"
	}
	## Conniving Puppetmaster
	modifier = {
		add = 25
		scope:owner = { has_trait_with_flag = agent_acceptance_25 }
		desc = INTRIGUE_EDUCATION_5_BONUS
	}
	# Royal Courts
	## CGV
	### Intrigue above CGV level 7.
	modifier = {
		add = 20
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			has_court_type = court_intrigue
			court_grandeur_current_level >= 7
		}
		desc = INTRIGUE_COURT_AGENT_ACCEPTANCE_REASON
	}
	## Amenities
	### Lodgings
	modifier = {
		add = 5
		is_pool_guest_of = scope:owner
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner = {
				amenity_level = { target = court_lodging_standards value = medium_amenity_level }
			}
		}
		desc = BONUS_TO_AGENT_RECRUITMENT_FROM_AMENITIES
	}
	modifier = {
		add = 10
		is_pool_guest_of = scope:owner
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner = {
				amenity_level = { target = court_lodging_standards value = high_amenity_level }
			}
		}
		desc = BONUS_TO_AGENT_RECRUITMENT_FROM_AMENITIES
	}
	modifier = {
		add = 15
		is_pool_guest_of = scope:owner
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner = {
				amenity_level = { target = court_lodging_standards value = very_high_amenity_level }
			}
		}
		desc = BONUS_TO_AGENT_RECRUITMENT_FROM_AMENITIES
	}
	modifier = {
		add = 20
		is_pool_guest_of = scope:owner
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner = {
				amenity_level = { target = court_lodging_standards value = max_amenity_level }
			}
		}
		desc = BONUS_TO_AGENT_RECRUITMENT_FROM_AMENITIES
	}
	# Lifestyles
	## Skulduggery Focus
	modifier = {
		scope:owner = { has_focus = intrigue_skulduggery_focus }
		add = 10
		desc = SCHEME_SKULDUGGERY_FOCUS
	}
	## Duty Focus
	modifier = {
		scope:target = { has_focus = stewardship_duty_focus }
		add = -10
		desc = SCHEME_DUTY_FOCUS
	}
	# Dynasty Legacies
	## FP3 legacy track bonus
	modifier = {
		add = 10
		scope:target = {
			dynasty ?= root.dynasty
			dynasty = { has_dynasty_perk = fp3_khvarenah_legacy_2 }
		}
		desc = "KHVARENAH_LEGACY_DESC"
	}
	# Event Content
	## Generic bonus modifier.
	modifier = {
		add = 20
		scope:owner = { has_character_modifier = event_bonus_to_agent_invite }
		desc = BONUS_TO_AGENT_RECRUITMENT
	}
	## Family stressed duty to family.
	modifier = {
		add = 20
		OR = {
			is_close_family_of = scope:owner
			is_spouse_of = scope:owner
		}
		scope:owner = { has_character_modifier = united_family_modifier }
		desc = SCHEME_DUTIOUS_FAMILY
	}
	## Hostage learnt behaviour due to being rewarded for acting as an agent for their family.
	modifier = {
		add = 50
		# Sometimes characters will die before they reply, so we have to check for this.
		is_alive = yes
		# Then the variable.
		var:family_schemer ?= scope:owner
		desc = SCHEME_TAUGHT_TO_SCHEME
	}
	## court_events.3060
	modifier = {
		add = 25
		scope:owner = { has_character_modifier = spies_behind_every_corner_modifier }
		desc = scheme.owner.spies_behind_every_corner_modifier.value_desc
	}
	modifier = {
		add = 25
		scope:target = { has_character_modifier = spies_behind_every_corner_modifier }
		desc = scheme.target.spies_behind_every_corner_modifier.value_desc
	}
}

# Core personal modifiers that should be applied to most/all personal schemes.
ai_agent_join_chance_personal_general_suite_modifier = {
	# Difficulty
	## Easy
	modifier = {
		add = 10
		is_ai = yes
		scope:target = { is_ai = no }
		has_game_rule = easy_difficulty
		desc = "easy_difficulty"
	}
	## Very Easy
	modifier = {
		add = 20
		is_ai = yes
		scope:target = { is_ai = no }
		has_game_rule = very_easy_difficulty
		desc = "very_easy_difficulty"
	}
	# Relations
	## Rivals with scope:target
	modifier = {
		add = -20
		has_relation_rival = scope:target
		NOT = { has_relation_nemesis = scope:target }
		desc = "SCHEME_AGAINST_RIVAL"
	}
	## Nemeses should be even less inclined
	modifier = {
		add = -1000
		has_relation_nemesis = scope:target
		desc = SCHEME_AGAINST_NEMESIS
	}
	## Friends with scope:target
	modifier = {
		add = 10
		has_relation_friend = scope:target
		NOT = { has_relation_best_friend = scope:target }
		desc = "SCHEME_AGAINST_FRIEND"
	}
	## Best friends should be even more inclined
	modifier = {
		add = 1000
		has_relation_best_friend = scope:target
		desc = SCHEME_AGAINST_BEST_FRIEND
	}
	## As should soulmates
	modifier = {
		add = 1000
		has_relation_soulmate = scope:target
		desc = SCHEME_AGAINST_SOULMATE
	}
	## Loving (or at least non-hostile) spouse of scope:target
	modifier = {
		add = 10
		is_consort_of = scope:target
		opinion = {
			target = scope:target
			value > 0
		}
		desc = "SCHEME_AGAINST_SPOUSE"
	}
	# Traits
	## Disloyal
	modifier = {
		add = -20
		has_trait = disloyal
		desc = "HAS_DISLOYAL_TRAIT"
	}
	## Loyal
	modifier = {
		add = 20
		has_trait = loyal
		desc = "HAS_LOYAL_TRAIT"
	}
	## Compassionate
	modifier = {
		add = 20
		has_trait = compassionate
		desc = "HAS_COMPASSIONATE_TRAIT"
	}
	## Callous
	modifier = {
		add = -20
		has_trait = callous
		desc = "HAS_CALLOUS_TRAIT"
	}
	## Sadists may or may not be sociable, so we don't touch them.
	# Lifestyles
	## Foreign Affairs Focus
	modifier = {
		scope:owner = { has_focus = diplomacy_foreign_affairs_focus }
		scope:target = { is_ruler = yes }
		add = 10
		desc = SCHEME_FOREIGN_AFFAIRS_FOCUS
	}
	## Family Focus
	modifier = {
		scope:owner = { has_focus = diplomacy_family_focus }
		OR = {
			is_close_or_extended_family_of = scope:target
			is_consort_of = scope:target
		}
		add = 10
		desc = SCHEME_FAMILY_FOCUS
	}
	# Event Content
	## Generic bonus modifier.
	modifier = {
		add = 20
		scope:owner = { has_character_modifier = event_bonus_to_agent_invite }
		desc = BONUS_TO_AGENT_RECRUITMENT
	}
	## Family stressed duty to family.
	modifier = {
		add = 20
		OR = {
			is_close_family_of = scope:owner
			is_spouse_of = scope:owner
		}
		scope:owner = { has_character_modifier = united_family_modifier }
		desc = SCHEME_DUTIOUS_FAMILY
	}
}

# Would an agent join a scheme to do something like seduce the target?
ai_agent_join_chance_hostile_taboo_modifier = {
	ai_agent_join_chance_hostile_general_suite_modifier = yes

	# Opinion
	## How much does the Agent like the Target? Modified by ai_honor
	### Positive honor multiplier: Ranges -1 to -5
	### Negative honor multiplier: Ranges -1 to -0.2
	### Then multiplied by 1.5
	opinion_modifier = {
		trigger = {
			this != scope:target
			opinion = {
				target = scope:target
				value >= low_positive_opinion
			}
		}
		who = this
		opinion_target = scope:target
		multiplier = {
			value = -1
			if = {
				limit = { this.ai_honor >= 0 }
				subtract = {
					value = this.ai_honor
					multiply = 0.025
				}
			}
			else = {
				subtract = {
					value = this.ai_honor
					multiply = 0.008
				}
			}
			multiply = 1.5
		}
		desc = SCHEME_MY_OPINION_OF_TARGET
	}
	# Faith
	## Stance on your adultery.
	### Shunned.
	modifier = {
		trigger = {
			NOR = {
				has_trait = cynical
				scope:owner = { is_spouse_of = scope:target }
				AND = {
					faith = { has_doctrine = doctrine_concubines }
					OR = {
						scope:owner = { is_concubine_of = scope:target }
						scope:target = { is_concubine_of = scope:owner }
					}
				}
				scope:scheme = { scheme_type = fabricate_hook } #Unop Adultery makes no sense for fabricate hook
			}
			trait_is_shunned_in_faith_trigger = { #Unop shunned, not criminal
				FAITH = faith
				TRAIT = trait:adulterer
				GENDER_CHARACTER = scope:owner
			}
		}
		add = -5
		desc = ai_opinion.reason.faith.adultery_shunned.owner
	}
	### Criminal.
	modifier = {
		trigger = {
			NOR = {
				has_trait = cynical
				scope:owner = { is_spouse_of = scope:target }
				AND = {
					faith = { has_doctrine = doctrine_concubines }
					OR = {
						scope:owner = { is_concubine_of = scope:target }
						scope:target = { is_concubine_of = scope:owner }
					}
				}
				scope:scheme = { scheme_type = fabricate_hook } #Unop Adultery makes no sense for fabricate hook
			}
			trait_is_criminal_in_faith_trigger = {
				FAITH = faith
				TRAIT = trait:adulterer
				GENDER_CHARACTER = scope:owner
			}
		}
		add = -15
		desc = ai_opinion.reason.faith.adultery_criminal.owner
	}
	## Stance on their adultery.
	### Shunned.
	modifier = {
		trigger = {
			NOR = {
				has_trait = cynical
				scope:owner = { is_spouse_of = scope:target }
				AND = {
					faith = { has_doctrine = doctrine_concubines }
					OR = {
						scope:owner = { is_concubine_of = scope:target }
						scope:target = { is_concubine_of = scope:owner }
					}
				}
				scope:scheme = { scheme_type = fabricate_hook } #Unop Adultery makes no sense for fabricate hook
			}
			trait_is_shunned_in_faith_trigger = { #Unop shunned, not criminal
				FAITH = faith
				TRAIT = trait:adulterer
				GENDER_CHARACTER = scope:owner
			}
		}
		add = -5
		desc = ai_opinion.reason.faith.adultery_shunned.target
	}
	### Criminal.
	modifier = {
		trigger = {
			NOR = {
				has_trait = cynical
				scope:owner = { is_spouse_of = scope:target }
				AND = {
					faith = { has_doctrine = doctrine_concubines }
					OR = {
						scope:owner = { is_concubine_of = scope:target }
						scope:target = { is_concubine_of = scope:owner }
					}
				}
				scope:scheme = { scheme_type = fabricate_hook } #Unop Adultery makes no sense for fabricate hook
			}
			trait_is_criminal_in_faith_trigger = {
				FAITH = faith
				TRAIT = trait:adulterer
				GENDER_CHARACTER = scope:owner
			}
		}
		add = -15
		desc = ai_opinion.reason.faith.adultery_criminal.target
	}
	## Lust is a sin.
	modifier = {
		trigger = {
			NOT = { scope:scheme = { scheme_type = fabricate_hook } } #Unop Lustful / chaste makes no sense for fabricate hook
			faith = { trait_is_sin = lustful }
		}
		add = -5
		desc = ai_opinion.reason.trait_is_sinful.lustful
	}
	## Lust is a virtue.
	modifier = {
		trigger = {
			NOT = { scope:scheme = { scheme_type = fabricate_hook } } #Unop Lustful / chaste makes no sense for fabricate hook
			faith = { trait_is_virtue = lustful }
		}
		add = 10
		desc = ai_opinion.reason.trait_is_virtuous.lustful
	}
	## Chaste is a sin.
	modifier = {
		trigger = {
			NOT = { scope:scheme = { scheme_type = fabricate_hook } } #Unop Lustful / chaste makes no sense for fabricate hook
			faith = { trait_is_sin = chaste }
		}
		add = 10
		desc = ai_opinion.reason.trait_is_sinful.chaste
	}
	## Chaste is a virtue.
	modifier = {
		trigger = {
			NOT = { scope:scheme = { scheme_type = fabricate_hook } } #Unop Lustful / chaste makes no sense for fabricate hook
			faith = { trait_is_virtue = chaste }
		}
		add = -5
		desc = ai_opinion.reason.trait_is_virtuous.chaste
	}
	# AI Personality
	## Compassion (general)
	modifier = {
		trigger = {
			ai_compassion > 0
			this != scope:target
		}
		add = {
			value = ai_compassion
			multiply = -1
			divide = 2.5
		}
		desc = COMPASSIONATE_REASON
	}
	## Compassion (sadism)
	modifier = {
		trigger = {
			ai_compassion < high_negative_ai_value
			this != scope:target
		}
		add = {
			value = ai_compassion
			multiply = -1
			divide = 10
		}
		desc = COMPASSIONATE_NEGATIVE_REASON
	}
	## Vengefulness (and the prospective agent has been wronged by scope:target)
	modifier = {
		trigger = {
			ai_vengefulness > 0
			this != scope:target
			opinion = {
				target = scope:target
				value <= 0
			}
			OR = {
				has_opinion_modifier = {
					modifier = murdered_close_family_crime
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = attempted_murder_close_family_crime
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = executed_close_family
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = slept_with_spouse_discovered_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = slept_with_spouse_exposed_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = unfaithful_spouse_discovered_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = unfaithful_spouse_exposed_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = refused_to_renounce_lover_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = betrayed_our_promise
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = botched_my_treatment_crime_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = botched_treatment_of_kin_crime_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = smeared_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = insulted_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = mocked_me_in_time_of_need
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = loved_one_dungeon_death
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = abandoned_me_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = reason_child_died
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = falsely_accused
					target = scope:target
				}
			}
		}
		add = {
			value = ai_vengefulness
			multiply = 2
		}
		desc = SCHEME_I_MUST_TAKE_VENGEANCE
	}
	## Cowardice
	modifier = {
		trigger = { ai_boldness < 0 }
		add = ai_boldness
		desc = SCHEME_I_AM_A_COWARD
	}
	modifier = {
		trigger = { ai_boldness > 0 }
		add = ai_boldness
		desc = SCHEME_I_AM_BOLD
	}
	# Realm Drama
	## Scope:target spouse has caused internal strife in the realm
	character_hates_scope_spouse_due_to_strife_plus_desc_modifier = { TARGET = scope:target }
	## Family Feud
	house_feud_hostile_scheme_agent_modifier = yes
	modifier = {
		trigger = {
			house_has_feud_relation_with_trigger = { TARGET = scope:target }
		}
		add = 50
		desc = SCHEME_TARGET_IS_FEUD_TARGET
	}
	# Other
	## Nothing to be gained for the prospective agent
	modifier = {
		trigger = {
			NAND = { # Greedy agents find that Gold is, indeed, something they stand to gain!
				OR = {
					AND = {
						exists = scope:gift
						always = scope:gift
					}
					AND = {
						exists = scope:gift_significant
						always = scope:gift_significant
					}
					AND = {
						exists = scope:treasury
						always = scope:treasury
					}
					AND = {
						exists = scope:treasury_significant
						always = scope:treasury_significant
					}
				}
				ai_greed > 0
			}
			NOR = {
				scope:target = {
					is_ruler = yes
					any_held_title = {
						place_in_line_of_succession = {
							target = root
							value <= 10
						}
					}
				}
				opinion = {
					target = scope:target
					value <= medium_negative_opinion
				}
			}
			NOT = {
				house_has_feud_relation_with_trigger = { TARGET = scope:target }
			}
		}
		add = {
			value = -10
			if = {
				limit = {
					ai_greed > 0
				}
				subtract = {
					value = ai_greed
					multiply = 0.25
				}
			}
		}
		desc = SCHEME_NOTHING_TO_GAIN
	}
}

# Would an agent join a scheme to do something like kidnap or murder the target?
ai_agent_join_chance_hostile_grievous_modifier = {
	ai_agent_join_chance_hostile_general_suite_modifier = yes

	# Opinion
	## How much does the Agent like the Target? Modified by ai_honor
	### Positive honor multiplier: Ranges -1 to -5
	### Negative honor multiplier: Ranges -1 to -0.2
	### Then multiplied by 1.5
	opinion_modifier = {
		trigger = {
			this != scope:target
			opinion = {
				target = scope:target
				value >= low_positive_opinion
			}
		}
		who = this
		opinion_target = scope:target
		multiplier = {
			value = -1
			if = {
				limit = { this.ai_honor >= 0 }
				subtract = {
					value = this.ai_honor
					multiply = 0.025
				}
			}
			else = {
				subtract = {
					value = this.ai_honor
					multiply = 0.008
				}
			}
			multiply = 1.5
		}
		desc = SCHEME_I_LIKE_TARGET
	}
	# Relations
	## Don't murder descendants
	modifier = {
		add = -100
		OR = {
			is_great_grandparent_of = scope:target
			is_grandparent_of = scope:target
			is_parent_of = scope:target
		}
		desc = SCHEME_NOT_AGAINST_DESCENDANTS
	}
	## Lovers (with Mortal Adoration lifestyle perk)
	modifier = {
		add = -25
		scope:target = { has_perk = mortal_adoration_perk }
		has_relation_lover = scope:target
		desc = MORTAL_ADORATION_REDUCED_HOSTILE_SCHEME_JOIN_CHANCE
	}
	## A spiteful spouse will want to murder you
	modifier = {
		add = 10
		trigger = {
			ai_compassion < 0
			is_consort_of = scope:target
		}
		opinion = {
			target = scope:target
			value < low_negative_opinion
		}
		desc = SCHEME_AGAINST_SPOUSE_POSITIVE
	}
	# AI Personality
	## Compassion (general)
	modifier = {
		trigger = {
			ai_compassion > 0
			this != scope:target
		}
		add = {
			value = ai_compassion
			multiply = -1
			divide = 2.5
		}
		desc = COMPASSIONATE_REASON
	}
	## Compassion (general towards children)
	modifier = {
		trigger = {
			ai_compassion > 0
			scope:target = { is_adult = no }
		}
		add = {
			value = ai_compassion
			multiply = -1
		}
		desc = SCHEME_COMPASSIONATE_NOT_MURDER_CHILDREN
	}
	## Compassion (sadism)
	modifier = {
		trigger = {
			ai_compassion < high_negative_ai_value
			this != scope:target
		}
		add = {
			value = ai_compassion
			multiply = -1
			divide = 10
		}
		desc = COMPASSIONATE_NEGATIVE_REASON
	}
	## Vengefulness (and the prospective agent has been wronged by scope:target)
	modifier = {
		trigger = {
			ai_vengefulness > 0
			this != scope:target
			opinion = {
				target = scope:target
				value <= 0
			}
			OR = {
				has_opinion_modifier = {
					modifier = murdered_close_family_crime
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = attempted_murder_close_family_crime
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = executed_close_family
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = slept_with_spouse_discovered_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = slept_with_spouse_exposed_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = unfaithful_spouse_discovered_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = unfaithful_spouse_exposed_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = refused_to_renounce_lover_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = betrayed_our_promise
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = botched_my_treatment_crime_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = botched_treatment_of_kin_crime_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = smeared_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = insulted_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = mocked_me_in_time_of_need
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = loved_one_dungeon_death
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = abandoned_me_opinion
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = reason_child_died
					target = scope:target
				}
				has_opinion_modifier = {
					modifier = falsely_accused
					target = scope:target
				}
			}
		}
		add = {
			value = ai_vengefulness
			multiply = 2
		}
		desc = SCHEME_I_MUST_TAKE_VENGEANCE
	}
	## Cowardice
	modifier = {
		trigger = { ai_boldness < 0 }
		add = ai_boldness
		desc = SCHEME_I_AM_A_COWARD
	}
	## Greed (and the prospective agent holds titles that scope:target claims)
	modifier = {
		trigger = {
			is_ruler = yes
			ai_greed > 0
			opinion = {
				target = scope:target
				value <= low_negative_opinion
			}
			any_held_title = {
				scope:target = { has_claim_on = prev }
			}
			NOR = {
				is_great_grandparent_of = scope:target
				is_grandparent_of = scope:target
				is_parent_of = scope:target
			}
		}
		add = {
			value = ai_greed
			divide = 2
		}
		desc = SCHEME_GET_RID_OF_UNRULY_CLAIMANT
	}
	## Greed (and the prospective agent MIGHT gain a title if scope:target bites the dust)
	modifier = {
		trigger = {
			ai_greed > 0
			scope:target = {
				any_held_title = {
					place_in_line_of_succession = {
						target = root
						value <= 3
					}
				}
			}
		}
		add = {
			value = ai_greed
			divide = 2
		}
		desc = SCHEME_MOVES_ME_UP_THE_SUCCESSION
	}
	## Zeal (and scope:target is a faith to be zealous against)
	modifier = {
		trigger = {
			ai_zeal > 10
			NOT = {
				faith = {
					faith_hostility_level = {
						target = scope:target.faith
						value = faith_fully_accepted_level
					}
				}
			}
		}
		add = {
			value = ai_zeal
			if = {
				limit = {
					faith = {
						faith_hostility_level = {
							target = scope:target.faith
							value = faith_astray_level
						}
					}
				}
				multiply = 0.25
			}
			else = {
				multiply = 0.5
			}
		}
		desc = SCHEME_ZEALOUS_AGAINST_HEATHEN
	}
	# Event Content
	## Murder Couples
	modifier = {
		add = 50
		has_opinion_modifier = {
			target = scope:owner
			modifier = murder_partner_opinion
		}
		desc = "SCHEME_MURDER_COUPLE"
	}
	modifier = {
		add = -1000
		# Sometimes characters will die before they reply, so we have to check for this.
		is_alive = yes
		# Then the variable.
		var:murder_scheme_disinterest ?= scope:target
		desc = "SCHEME_MURDER_DISINTERESTED"
	}
	# Realm Drama
	## Scope:target has caused internal strife in the realm
	character_hates_scope_due_to_strife_plus_desc_modifier = { TARGET = scope:target }
	## Family Feud
	house_feud_hostile_scheme_agent_modifier = yes
	modifier = {
		exists = house
		house_has_feud_relation_with_trigger = { TARGET = scope:target }
		add = 50
		desc = SCHEME_TARGET_IS_FEUD_TARGET
	}
	### Admin Eunuch
	modifier = {
		trigger = {
			top_liege ?= scope:target
			scope:target = { ep3_story_cycle_admin_eunuch_valid_story_trigger = yes }
			scope:eunuch_temp ?= this
			OR = {
				has_character_modifier = admin_eunuch_eunuch_1_modifier
				has_character_modifier = admin_eunuch_eunuch_2_modifier
				has_character_modifier = admin_eunuch_eunuch_3_modifier
			}
		}
		add = {
			value = 50
			if = {
				limit = { has_character_modifier = admin_eunuch_eunuch_2_modifier }
				add = 50
			}
			else_if = {
				limit = { has_character_modifier = admin_eunuch_eunuch_3_modifier }
				add = 100
			}
			if = {
				limit = { scope:story_temp.var:eunuch_score < 0 }
				multiply = {
					value = {
						value = scope:story_temp.var:eunuch_score
						add = 1
						abs = yes
						min = 1
					}
				}
			}
		}
		desc = SCHEME_TARGET_IS_ADMIN_EUNUCH_TARGET
	}
	modifier = {
		trigger = {
			top_liege ?= {
				ep3_story_cycle_admin_eunuch_valid_story_trigger = yes
				scope:eunuch_temp ?= scope:target
				scope:story_temp ?= {
					is_target_in_variable_list = {
						name = upset_courtiers
						target = root

					}
				}
			}
		}
		add = 100
		desc = SCHEME_TARGET_IS_ADMIN_EUNUCH_UPSET_COURTIER
	}
	# Other
	## Nothing to be gained for the prospective agent
	modifier = {
		trigger = {
			NAND = { # Greedy agents find that Gold is, indeed, something they stand to gain!
				OR = {
					AND = {
						exists = scope:gift
						always = scope:gift
					}
					AND = {
						exists = scope:gift_significant
						always = scope:gift_significant
					}
					AND = {
						exists = scope:treasury
						always = scope:treasury
					}
					AND = {
						exists = scope:treasury_significant
						always = scope:treasury_significant
					}
				}
				ai_greed > 0
			}
			NOR = {
				scope:target = {
					is_ruler = yes
					any_held_title = {
						place_in_line_of_succession = {
							target = root
							value <=10
						}
					}
				}
				opinion = {
					target = scope:target
					value <= medium_negative_opinion
				}
			}
			NOT = {
				house_has_feud_relation_with_trigger = { TARGET = scope:target }
			}
		}
		add = {
			value = -10
			if = {
				limit = {
					ai_greed > 0
				}
				subtract = {
					value = ai_greed
					multiply = 0.25
				}
			}
		}
		desc = SCHEME_NOTHING_TO_GAIN
	}
}

# Would an agent join a scheme to do something like sway the target?
ai_agent_join_chance_personal_inoffensive_modifier = {
	ai_agent_join_chance_personal_general_suite_modifier = yes

	# Opinion
	opinion_modifier = {
		trigger = {
			this != scope:target
		}
		who = this
		opinion_target = scope:target
		desc = SCHEME_MY_OPINION_OF_TARGET
	}
	# AI Personality
	## Energy
	modifier = {
		trigger = {
			this != scope:target
		}
		add = ai_energy
		desc = ai_opinion.reason.ai_values.energy.flavour
	}
}

# Would a camp follower join a contract scheme by their leader?
## Should be synced with the "is_scheme_category = contract" section of invite_agent_to_scheme_interaction's auto-accept, to prevent agents agents leaving the scheme immediately after joining.
ai_agent_join_chance_laamp_contract_modifier = {
	first_valid = {
		# Or nemesis.
		modifier = {
			trigger = { has_relation_nemesis = scope:owner }
			add = -1000
			desc = ai_opinion.reason.laamp_nemesis
		}
		# Like rival.
		modifier = {
			trigger = { has_relation_rival = scope:owner }
			add = -100
			desc = ai_opinion.reason.laamp_rival
		}
		# Or they're your stooge.
		modifier = {
			trigger = {
				has_court_position = stooge_camp_officer # Unop: This was scope to the owner but we want to check if the Target has the court position !
				is_court_position_employer = {
					court_position = stooge_camp_officer
					who = scope:owner
				}
			}
			add = -50
			desc = ai_opinion.reason.laamp_stooge
		}
		# Followers must earn their keep.
		modifier = {
			trigger = {
				is_courtier_of = scope:owner
				NOT = { scope:scheme = { is_scheme_category = contract } } #Unop: Added to make sure it doesn't conflict with the addition below
			}
			add = 100
			desc = ai_opinion.reason.courtier.followers_must_work
		}
		# Followers must earn their keep. Unop: With the modification from invite_agent_to_scheme_interaction/auto-accept
		modifier = {
			trigger = {
				NOR = {
					has_relation_nemesis = scope:owner
					has_relation_rival = scope:owner
					AND = {
						has_court_position = stooge_camp_officer
						is_court_position_employer = {
							court_position = stooge_camp_officer
							who = scope:owner
						}
					}
				}
				is_courtier_of = scope:owner
				scope:scheme = { is_scheme_category = contract }
			}
			add = 1500 # Unop: That seems a lot, but in fact we need a VERY BIG value to counteract EVERYTHNG to mimic the "auto accept"
			desc = ai_opinion.reason.courtier.followers_must_work
		}
	}
}

# Special ai acceptance behavior for political schemes
ai_agent_join_chance_political_suite_modifier = {
	modifier = {
		add = {
			value = -30
			if = {
				limit = { ai_honor < 0 }
				add = {
					value = ai_honor
					multiply = 0.5
				}
			}
		}
		desc = ai_agent_join_political_base
	}
	# Relative House Power Modifier
	modifier = {
		trigger = {
			exists = house
			exists = scope:owner.house
			NOR = {
				AND = {
					scope:owner.house = { is_dominant_family = yes }
					house = { is_dominant_family = yes }
				}
				AND = {
					scope:owner.house = { is_powerful_family = yes }
					house = { is_powerful_family = yes }
				}
				AND = {
					scope:owner.house = {
						is_dominant_family = no
						is_powerful_family = no
					}
					house = {
						is_dominant_family = no
						is_powerful_family = no
					}
				}
			}
		}
		add = {
			if = {
				limit = {
					scope:owner.house = {
						OR = {
							is_dominant_family = yes
							is_powerful_family = yes
						}
					}
					house = {
						is_dominant_family = no
						is_powerful_family = no
					}
				}
				add = 50
			}
			else_if = {
				limit = {
					scope:owner.house = { is_dominant_family = yes }
					house = { is_powerful_family = yes }
				}
				add = 25
			}
			else_if = {
				limit = {
					house = {
						OR = {
							is_dominant_family = yes
							is_powerful_family = yes
						}
					}
					scope:owner.house = {
						is_dominant_family = no
						is_powerful_family = no
					}
				}
				add = -50
			}
			else_if = {
				limit = {
					house = { is_dominant_family = yes }
					scope:owner.house = { is_powerful_family = yes }
				}
				add = -25
			}
		}
		desc = ai_agent_join_political_relative_house_power
	}
}

##################################################
# Scheme Preparation Modifiers

scheme_prep_ai_should_execute_scheme_modifier = {
	first_valid = {
		# Impatient characters should go as soon as they have a shot.
		modifier = {
			add = 100
			has_trait = impatient
		}
		# Otherwise, go once you've hit your max.
		## Since the AI can't fire off till they're 50% or over, and we give them success agents to start with for important schemes, this means they'll mostly be firing in the 60%+ range. Solid enough.
		modifier = {
			add = 100
			scope:scheme.scheme_success_chance >= scope:scheme.max_scheme_success_chance
		}
		# Patient characters should always wait till they hit max.
		modifier = {
			add = 100
			has_trait = patient
			scope:scheme.scheme_success_chance < scope:scheme.max_scheme_success_chance
		}
		# Otherwise, just roll against our general chance
		modifier = {
			add = scope:scheme.scheme_success_chance
			always = yes
		}
	}
}

##################################################
# Diarch Modifiers

diarch_scheming_within_realm_bonus_modifier = {
	modifier = {
		add = 20
		desc = "DIARCH_REALM_INFLUENCE"
		scope:owner = { is_diarch = yes }
		scope:target = {
			any_liege_or_above = { this = scope:owner.liege }
			# Exempting the liege themselves, against whom we get other bonuses.
			this != scope:target
		}
	}
}

diarch_scheming_title_within_realm_bonus_modifier = {
	modifier = {
		add = 20
		desc = "DIARCH_REALM_INFLUENCE"
		scope:owner = { is_diarch = yes }
		scope:target.holder = {
			any_liege_or_above = { this = scope:owner.liege }
			# Exempting the liege themselves, against whom we get other bonuses.
			this != scope:target.holder
		}
	}
}

##################################################
# Mandala Modifiers

# Your Aspect
owner_aspect_skill_modifier = {
	modifier = {
		scope:owner = {
			house = { has_house_aspiration_parameter = aspect_of_creation }
		}
		add = {
			value = scope:owner.stewardship
			if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_creation_05 }
					}
				}
				multiply = 2
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_creation_04 }
					}
				}
				multiply = 1.75
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_creation_03 }
					}
				}
				multiply = 1.5
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_creation_02 }
					}
				}
				multiply = 1.25
			}
		}
		desc = SCHEME_YOUR_ASPECT_SKILL_CREATION
	}
	modifier = {
		scope:owner = {
			house = { has_house_aspiration_parameter = aspect_of_serenity }
		}
		add = {
			value = scope:owner.diplomacy
			if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_serenity_05 }
					}
				}
				multiply = 2
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_serenity_04 }
					}
				}
				multiply = 1.75
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_serenity_03 }
					}
				}
				multiply = 1.5
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_serenity_02 }
					}
				}
				multiply = 1.25
			}
		}
		desc = SCHEME_YOUR_ASPECT_SKILL_SERENITY
	}
	modifier = {
		scope:owner = {
			house = { has_house_aspiration_parameter = aspect_of_destruction }
		}
		add = {
			value = scope:owner.martial
			if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_destruction_05 }
					}
				}
				multiply = 2
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_destruction_04 }
					}
				}
				multiply = 1.75
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_destruction_03 }
					}
				}
				multiply = 1.5
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_destruction_02 }
					}
				}
				multiply = 1.25
			}
		}
		desc = SCHEME_YOUR_ASPECT_SKILL_DESTRUCTION
	}
	modifier = {
		scope:owner = {
			house = { has_house_aspiration_parameter = aspect_of_trickery }
		}
		add = {
			value = scope:owner.intrigue
			if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_trickery_05 }
					}
				}
				multiply = 2
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_trickery_04 }
					}
				}
				multiply = 1.75
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_trickery_03 }
					}
				}
				multiply = 1.5
			}
			else_if = {
				limit = {
					scope:owner = {
						house = { has_house_aspiration_parameter = aspect_of_trickery_02 }
					}
				}
				multiply = 1.25
			}
		}
		desc = SCHEME_YOUR_ASPECT_SKILL_TRICKERY
	}
}

#Target Aspect (if any)
target_share_aspect_skill_modifier = {
	modifier = {
		scope:owner = {
			house = { has_house_aspiration_parameter = aspect_of_creation }
		}
		scope:target = {
			government_has_flag = government_is_mandala
			house = { has_house_aspiration_parameter = aspect_of_creation }
		}
		add = {
			value = scope:owner.stewardship
			multiply = 0.5
		}
		desc = SCHEME_TARGET_ASPECT_SKILL_CREATION
	}
	modifier = {
		scope:owner = {
			house = { has_house_aspiration_parameter = aspect_of_serenity }
		}
		scope:target = {
			government_has_flag = government_is_mandala
			house = { has_house_aspiration_parameter = aspect_of_serenity }
		}
		add = {
			value = scope:owner.diplomacy
			multiply = 0.5
		}
		desc = SCHEME_TARGET_ASPECT_SKILL_SERENITY
	}
	modifier = {
		scope:owner = {
			house = { has_house_aspiration_parameter = aspect_of_destruction }
		}
		scope:target = {
			government_has_flag = government_is_mandala
			house = { has_house_aspiration_parameter = aspect_of_destruction }
		}
		add = {
			value = scope:owner.martial
			multiply = 0.5
		}
		desc = SCHEME_TARGET_ASPECT_SKILL_DESTRUCTION
	}
	modifier = {
		scope:owner = {
			house = { has_house_aspiration_parameter = aspect_of_trickery }
		}
		scope:target = {
			government_has_flag = government_is_mandala
			house = { has_house_aspiration_parameter = aspect_of_trickery }
		}
		add = {
			value = scope:owner.intrigue
			multiply = 0.5
		}
		desc = SCHEME_TARGET_ASPECT_SKILL_TRICKERY
	}
}

#You do NOT share Aspect
not_share_aspect_modifier = {
	modifier = {
		NOT = { 
			same_mandala_aspect_trigger = { FIRST_CHAR = scope:owner SECOND_CHAR = scope:target }
		}
		add = -15
		desc = SCHEME_TARGET_NOT_SAME_ASPECT
	}
}

#Target's Suzerain's Aspect (if any)
target_suzerain_share_aspect_skill_modifier = {
	modifier = {
		scope:target = {
			is_tributary = yes
			house = { has_house_aspiration_parameter = aspect_of_creation }
		}
		scope:target.suzerain = {
			house = { has_house_aspiration_parameter = aspect_of_creation }
		}
		add = {
			value = scope:target.suzerain.stewardship
			multiply = -1
		}
		desc = SCHEME_SUZERAIN_ASPECT_SKILL_CREATION
	}
	modifier = {
		scope:target = {
			is_tributary = yes
			house = { has_house_aspiration_parameter = aspect_of_serenity }
		}
		scope:target.suzerain = {
			house = { has_house_aspiration_parameter = aspect_of_serenity }
		}
		add = {
			value = scope:target.suzerain.diplomacy
			multiply = -1
		}
		desc = SCHEME_SUZERAIN_ASPECT_SKILL_SERENITY
	}
	modifier = {
		scope:target = {
			is_tributary = yes
			house = { has_house_aspiration_parameter = aspect_of_destruction }
		}
		scope:target.suzerain = {
			house = { has_house_aspiration_parameter = aspect_of_destruction }
		}
		add = {
			value = scope:target.suzerain.martial
			multiply = -1
		}
		desc = SCHEME_SUZERAIN_ASPECT_SKILL_DESTRUCTION
	}
	modifier = {
		scope:target = {
			is_tributary = yes
			house = { has_house_aspiration_parameter = aspect_of_trickery }
		}
		scope:target.suzerain = {
			house = { has_house_aspiration_parameter = aspect_of_trickery }
		}
		add = {
			value = scope:target.suzerain.intrigue
			multiply = -1
		}
		desc = SCHEME_SUZERAIN_ASPECT_SKILL_TRICKERY
	}
}

##################################################
# Old Modifiers
## Old as in "before the scheme rework".

hostile_scheme_base_chance_modifier = {
	first_valid = {
		modifier = {
			add = -30
			exists = scope:target.primary_title
			scope:target.primary_title.tier = tier_empire
			desc = "SCHEME_TARGET_IS_AN_EMPEROR"
		}
		modifier = {
			add = -20
			exists = scope:target.primary_title
			scope:target.primary_title.tier = tier_kingdom
			desc = "SCHEME_TARGET_IS_A_KING"
		}
	}

	# Scheme restarted
	modifier = {
		add = scope:scheme.var:scheme_reset_to_zero_value
		scope:scheme ?= { has_variable = scheme_reset_to_zero_value }
		desc = "SCHEME_RESTARTED"
	}

	modifier = { # Minor Lifestyle Perk protection for Courtiers
		add = {
			value = 0
			subtract = prepared_for_anything_perk_secondary_percentage
		}
		scope:target = {
			is_alive = yes
			is_ruler = no
			court_owner ?= {
				has_perk = prepared_for_anything_perk
			}
			court_owner != scope:owner
			NOT = { has_perk = prepared_for_anything_perk }
		}
		desc = "SCHEME_PREPARED_FOR_ANYTHING_LIEGE_PERK_MODIFIER"
	}

	modifier = { # Bonus for murdering Pool characters, as you can't have agents against them
		add = 25
		scope:target = {
			is_pool_character = yes
			NOT = { intrigue >= very_high_skill_rating }
		}
		desc = "SCHEME_TARGET_TRAVELLING_UNSAFE_ROADS"
	}

	modifier = { # ...unless they're sneaky as all heck
		add = -10
		scope:target = {
			is_pool_character = yes
			intrigue >= very_high_skill_rating
		}
		desc = "SCHEME_TARGET_TRAVELLING_INCOGNITO"
	}

	modifier = { # FP3 legacy track bonus for murdering dynasty members
		add = 10
		scope:target = {
			exists = dynasty
			exists = scope:owner.dynasty
			dynasty = scope:owner.dynasty
			dynasty = { has_dynasty_perk = fp3_khvarenah_legacy_2 }
		}
		desc = "KHVARENAH_LEGACY_DESC"
	}

	first_valid = { # Essentially the Base
		modifier = {
			add = 75
			scope:owner = {
				exists = scope:target.cp:councillor_spymaster
				scope:target.cp:councillor_spymaster = this
			}
			desc = "SCHEME_I_AM_SPYMASTER"
		}
		modifier = {
			add = 75
			scope:target = {
				is_landed_or_landless_administrative = no
			}
			scope:owner = {
				exists = scope:target.liege.cp:councillor_spymaster
				scope:target.liege.cp:councillor_spymaster = this
			}
			desc = "SCHEME_I_AM_SPYMASTER_OF_LIEGE"
		}
		modifier = {
			add = 75
			scope:target = {
				is_landed_or_landless_administrative = no
			}
			scope:owner = {
				exists = scope:target.host.cp:councillor_spymaster
				scope:target.host.cp:councillor_spymaster = this
			}
			desc = "SCHEME_I_AM_SPYMASTER_OF_HOST"
		}
		modifier = {
			add = 75
			scope:owner = {
				has_relation_guardian = scope:target
			}
			desc = "SCHEME_I_AM_GUARDIAN"
		}
		modifier = {
			add = 50
			scope:owner = { is_diarch_of_target = scope:target }
			desc = "SCHEME_I_AM_DIARCH"
		}
		modifier = {
			add = 25
			scope:target = {
				is_ruler = no
			}
			exists = scope:target.liege
			scope:target.liege = scope:owner
			desc = "SCHEME_TARGET_IN_MY_COURT"
		}
		modifier = {
			add = 15
			scope:owner = {
				is_councillor_of = scope:target
			}
			desc = "SCHEME_I_AM_COUNCILLOR"
		}
		modifier = {
			add = 15
			scope:owner = {
				has_relation_lover = scope:target
			}
			desc = "SCHEME_TARGET_IS_LOVER"
		}
		modifier = {
			add = 10
			scope:owner = {
				is_spouse_of = scope:target
			}
			desc = "SCHEME_TARGET_IS_SPOUSE"
		}
		modifier = {
			add = 5
			scope:owner = {
				is_consort_of = scope:target
			}
			desc = "SCHEME_TARGET_IS_CONCUBINE"
		}
		modifier = {
			add = 5
			scope:owner = {
				is_close_family_of = scope:target
			}
			desc = "SCHEME_TARGET_IS_CLOSE_FAMILY"
		}
	}

	#Characters who has the disloyal trait are predisposed to scheme
	modifier = {
		add = 10
		scope:owner = {
			has_trait = disloyal
		}
		desc = "HAS_DISLOYAL_TRAIT"
	}
	modifier = {
		add = -10
		scope:owner = {
			has_trait = loyal
		}
		desc = "HAS_LOYAL_TRAIT"
	}

	modifier = { # Vengeful Bonus
		add = vengeful_scheme_success_chance_modifier
		scope:owner = {
			has_trait = vengeful
			OR = {
				has_relation_rival = scope:target
				has_relation_nemesis = scope:target
			}
		}
		desc = "SCHEME_VENGEFUL_RIVAL"
	}

	modifier = { # Culture Bonus
		add = 15
		scope:owner = {
			culture = {
				has_cultural_parameter = hostile_action_vs_rival_bonuses
			}
			OR = {
				has_relation_rival = scope:target
				has_relation_nemesis = scope:target
			}
		}
		desc = "SCHEME_EYE_FOR_AN_EYE"
	}

	modifier = { # Culture Bonus
		add = -50
		scope:owner = {
			culture = {
				has_cultural_parameter = hostile_scheme_success_chance_vs_spouse_penalty
			}
			is_spouse_of = scope:target
		}
		desc = "SCHEME_WEDDING_CEREMONIES"
	}

	modifier = {
		add = -35
		always = scope:exposed
		desc = "SCHEME_IS_EXPOSED"
	}

	# Difficulty
	modifier = {
		add = -25
		has_game_rule = easy_difficulty
		scope:owner = {
			is_ai = yes
		}
		scope:target = {
			is_ai = no
		}
		desc = "SCHEME_SUCCESS_DIFFICULTY_EASY"
	}

	modifier = {
		add = -75
		has_game_rule = very_easy_difficulty
		scope:owner = {
			is_ai = yes
		}
		scope:target = {
			is_ai = no
		}
		desc = "SCHEME_SUCCESS_DIFFICULTY_VERY_EASY"
	}

	# Struggle
	modifier = {
		add = -25
		scope:owner = {
			any_character_struggle = {
				involvement = involved
				has_struggle_phase_parameter = struggle_agents_less_likely_to_join_schemes
				is_secondary_character_involvement_involved_trigger = {
					CHAR = scope:target
				}
			}
		}
	}
	## court_events.3060
	modifier = {
		add = 25
		scope:owner = { has_character_modifier = spies_behind_every_corner_modifier }
		desc = scheme.owner.spies_behind_every_corner_modifier.value_desc
	}
	modifier = {
		add = 25
		scope:target = { has_character_modifier = spies_behind_every_corner_modifier }
		desc = scheme.target.spies_behind_every_corner_modifier.value_desc
	}
	## tgp_japan_yearly_events.1071
	modifier = {
		add = 10 
		scope:owner = { 
			has_variable = tgp_1071_bonus
			var:tgp_1071_bonus = scope:target
		}
		desc = scheme.target.japan_1071.value_desc
	}

	# house_head_request_interaction
	modifier = {
		add = hostile_scheme_variable_list_value
		scope:owner = {
			has_variable_list = supporting_hostile_schemes
		}
		desc = HOUSE_HEAD_SCHEME_SUPPORT_DESC
	}
	modifier = {
		add = -10
		scope:owner = { has_character_modifier = hostile_schemes_distracted_modifier }
		desc = hostile_schemes_distracted_modifier
	}

	# House Relations
	modifier = {
		add = house_relation_hostile_scheme_bonus_value
		scope:owner.house ?= {
			NOT = { scope:target.house ?= this }
			any_house_relation = {
				has_house_relation_parameter = hostile_scheme_bonus
				any_relation_house = {
					scope:target.house ?= this
				}
			}
		}
		desc = house_relation_hostile_scheme_bonus_desc
	}
	modifier = {
		add = 15
		scope:owner = {
			has_variable = spouse_hostile_scheme_bonus
			var:spouse_hostile_scheme_bonus = {
				this = scope:target
			}
		}
		desc = coronation_spouse_despised_modifier
	}
}

# Base modifier against titles
#  - scope:target is expected to refer to a title (but could refer to other things whe used elsewhere)
#  - scope:target_title refers to the same title (or nothing at all if used with a scheme targeting something else)
hostile_scheme_title_base_chance_modifier = {
	modifier = {
		add = -20
		scope:target ?= {
			tier = tier_kingdom
		}
		desc = "SCHEME_TARGET_IS_A_KINGDOM"
	}
	modifier = {
		add = -30
		scope:target ?= {
			tier = tier_empire
		}
		desc = "SCHEME_TARGET_IS_AN_EMPIRE"
	}
	modifier = {
		add = -40
		scope:target ?= {
			tier = tier_hegemony
		}
		desc = "SCHEME_TARGET_IS_A_HEGEMONY"
	}
	modifier = { # Minor Lifestyle Perk protection for Courtiers
		add = {
			value = 0
			subtract = prepared_for_anything_perk_secondary_percentage
		}
		scope:target.holder ?= {
			is_alive = yes
			is_ruler = no
			court_owner ?= {
				has_perk = prepared_for_anything_perk
			}
			court_owner != scope:owner
			NOT = { has_perk = prepared_for_anything_perk }
		}
		desc = "SCHEME_PREPARED_FOR_ANYTHING_LIEGE_PERK_MODIFIER"
	}

	modifier = { # FP3 legacy track bonus for murdering dynasty members
		add = 10
		scope:target.holder ?= {
			exists = dynasty
			exists = scope:owner.dynasty
			dynasty = scope:owner.dynasty
			dynasty = { has_dynasty_perk = fp3_khvarenah_legacy_2 }
		}
		desc = "KHVARENAH_LEGACY_DESC"
	}

	first_valid = { # Essentially the Base
		modifier = {
			add = 75
			exists = scope:target.holder.cp:councillor_spymaster
			scope:owner = {
				scope:target.holder.cp:councillor_spymaster = this
			}
			desc = "SCHEME_I_AM_SPYMASTER_OF_HOLDER"
		}
		modifier = {
			add = 75
			scope:target.holder ?= {
				is_landed_or_landless_administrative = no
			}
			scope:owner = {
				exists = scope:target.holder.liege.cp:councillor_spymaster #Unop ck3-tiger
				scope:target.holder.liege.cp:councillor_spymaster = this
			}
			desc = "SCHEME_I_AM_SPYMASTER_OF_LIEGE_OF_HOLDER"
		}
		modifier = {
			add = 50
			exists = scope:target.holder
			scope:owner = { is_diarch_of_target = scope:target.holder }
			desc = "SCHEME_I_AM_DIARCH_OF_HOLDER"
		}
		modifier = {
			add = 15
			exists = scope:target.holder
			scope:owner = {
				is_councillor_of = scope:target.holder
			}
			desc = "SCHEME_I_AM_COUNCILLOR_OF_HOLDER"
		}
		modifier = {
			add = 15
			exists = scope:target.holder
			scope:owner = {
				has_relation_lover = scope:target.holder
			}
			desc = "SCHEME_TARGET_IS_LOVER_OF_HOLDER"
		}
		modifier = {
			add = 10
			exists = scope:target.holder
			scope:owner = {
				is_spouse_of = scope:target.holder
			}
			desc = "SCHEME_TARGET_IS_SPOUSE_OF_HOLDER"
		}
		modifier = {
			add = 5
			exists = scope:target.holder
			scope:owner = {
				is_close_family_of = scope:target.holder
				this != scope:target.holder
			}
			desc = "SCHEME_TARGET_IS_CLOSE_FAMILY_OF_HOLDER"
		}
	}

	#Characters who has the disloyal trait are predisposed to scheme
	modifier = {
		add = 10
		scope:owner = {
			has_trait = disloyal
		}
		desc = "HAS_DISLOYAL_TRAIT"
	}
	modifier = {
		add = -10
		scope:owner = {
			has_trait = loyal
		}
		desc = "HAS_LOYAL_TRAIT"
	}

	modifier = { # Vengeful Bonus
		add = vengeful_scheme_success_chance_modifier
		exists = scope:target.holder
		scope:owner = {
			has_trait = vengeful
			OR = {
				has_relation_rival = scope:target.holder
				has_relation_nemesis = scope:target.holder
			}
		}
		desc = "SCHEME_VENGEFUL_RIVAL_OF_HOLDER"
	}

	modifier = { # Culture Bonus
		add = 15
		exists = scope:target.holder
		scope:owner = {
			culture = {
				has_cultural_parameter = hostile_action_vs_rival_bonuses
			}
			OR = {
				has_relation_rival = scope:target.holder
				has_relation_nemesis = scope:target.holder
			}
		}
		desc = "SCHEME_EYE_FOR_AN_EYE_HOLDER"
	}

	modifier = { # Culture Bonus
		add = -50
		exists = scope:target.holder
		scope:owner = {
			culture = {
				has_cultural_parameter = hostile_scheme_success_chance_vs_spouse_penalty
			}
			is_spouse_of = scope:target.holder
		}
		desc = "SCHEME_WEDDING_CEREMONIES_HOLDER"
	}

	modifier = {
		add = -35
		always = scope:exposed
		desc = "SCHEME_IS_EXPOSED"
	}

	# Difficulty
	modifier = {
		add = -25
		has_game_rule = easy_difficulty
		scope:owner = {
			is_ai = yes
		}
		scope:target.holder ?= {
			is_ai = no
		}
		desc = "SCHEME_SUCCESS_DIFFICULTY_EASY"
	}

	modifier = {
		add = -75
		has_game_rule = very_easy_difficulty
		scope:owner = {
			is_ai = yes
		}
		scope:target.holder ?= {
			is_ai = no
		}
		desc = "SCHEME_SUCCESS_DIFFICULTY_VERY_EASY"
	}

	# Struggle
	modifier = {
		add = -25
		scope:owner = {
			any_character_struggle = {
				involvement = involved
				has_struggle_phase_parameter = struggle_agents_less_likely_to_join_schemes
				is_secondary_character_involvement_involved_trigger = {
					CHAR = scope:target.holder
				}
			}
		}
	}

	## court_events.3060
	modifier = {
		add = 25
		scope:owner = { has_character_modifier = spies_behind_every_corner_modifier }
		desc = scheme.owner.spies_behind_every_corner_modifier.value_desc
	}
	modifier = {
		add = 25
		scope:target.holder ?= { has_character_modifier = spies_behind_every_corner_modifier }
		desc = scheme.target.holder.spies_behind_every_corner_modifier.value_desc
	}
}

#ai agents join chance against titles
ai_agent_join_chance_hostile_title_modifier = {
	# Difficulty
	## Easy
	modifier = {
		add = -10
		is_ai = yes
		scope:target.holder = { is_ai = no }
		has_game_rule = easy_difficulty
		desc = "easy_difficulty"
	}
	## Very Easy
	modifier = {
		add = -20
		is_ai = yes
		scope:target.holder = { is_ai = no }
		has_game_rule = very_easy_difficulty
		desc = "very_easy_difficulty"
	}
	# Countermeasure Resistance
	## Honest
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target.holder
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_honest
		}
	}
	## Just
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target.holder
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_just
		}
	}
	## Deceitful
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target.holder
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_deceitful
		}
	}
	## Gregarious
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target.holder
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_gregarious
		}
	}
	## Arrogant
	modifier = {
		add = countermeasure_disliked_by_trait_agenthood_acceptance_value
		countermeasure_parameter_applies_against_char_trigger = {
			SCHEME_TARGET = scope:target.holder
			SCHEME_OWNER = scope:owner
			PARAMETER = characters_more_likely_to_accept_agenthood_against_if_arrogant
		}
	}
	# Dread
	## For scope:target
	### Intimidated
	modifier = {
		trigger = {
			has_dread_level_towards = {
				target = scope:target.holder
				level = 1
			}
		}
		add = -100
		desc = SCHEME_I_AM_INTIMIDATED
	}
	### Cowed
	modifier = {
		trigger = {
			has_dread_level_towards = {
				target = scope:target.holder
				level = 2
			}
		}
		add = -1000
		desc = SCHEME_I_AM_COWED
	}
	## For scope:owner
	### Intimidated
	modifier = {
		add = intimidated_scheme_reason_value
		target_is_liege_or_above = scope:owner
		has_dread_level_towards = {
			target = scope:owner
			level = 1
		}
		desc = INTIMIDATED_REASON
	}
	modifier = {
		add = intimidated_scheme_external_reason_value
		NOT = { target_is_liege_or_above = scope:owner }
		has_dread_level_towards = {
			target = scope:owner
			level = 1
		}
		desc = INTIMIDATED_REASON
	}
	### Cowed
	modifier = {
		add = cowed_scheme_reason_value
		target_is_liege_or_above = scope:owner
		has_dread_level_towards = {
			target = scope:owner
			level = 2
		}
		desc = COWED_REASON
	}
	modifier = {
		add = cowed_scheme_external_reason_value
		NOT = { target_is_liege_or_above = scope:owner }
		has_dread_level_towards = {
			target = scope:owner
			level = 2
		}
		desc = COWED_REASON
	}
	# Relations
	## Rivals with scope:target
	modifier = {
		add = 10
		has_relation_rival = scope:target.holder
		NOT = { has_relation_nemesis = scope:target.holder }
		desc = "SCHEME_AGAINST_RIVAL"
	}
	## Nemeses should be even more inclined
	modifier = {
		add = 1000
		has_relation_nemesis = scope:target.holder
		desc = SCHEME_AGAINST_NEMESIS
	}
	## Friends with scope:target
	modifier = {
		add = -20
		has_relation_friend = scope:target.holder
		NOT = { has_relation_best_friend = scope:target.holder }
		desc = "SCHEME_AGAINST_FRIEND"
	}
	## Best friends should be even less inclined
	modifier = {
		add = -1000
		has_relation_best_friend = scope:target.holder
		desc = SCHEME_AGAINST_BEST_FRIEND
	}
	## As should soulmates
	modifier = {
		add = -1000
		has_relation_soulmate = scope:target.holder
		desc = SCHEME_AGAINST_SOULMATE
	}
	## Loving (or at least non-hostile) spouse of scope:target
	modifier = {
		add = -10
		is_consort_of = scope:target.holder
		opinion = {
			target = scope:target.holder
			value > 0
		}
		desc = "SCHEME_AGAINST_SPOUSE"
	}
	# Faith
	## Sacred Lies tenet
	modifier = {
		add = 20
		faith = { has_doctrine_parameter = adherents_more_likely_to_join_schemes }
		desc = "SCHEME_IS_SACRED"
	}
	## Don't mess with your HoF.
	modifier = {
		trigger = {
			exists = faith.religious_head
			scope:target.holder = faith.religious_head
		}
		add = {
			value = -25
			if = {
				limit = { has_trait = zealous }
				multiply = 2
			}
			else_if = {
				limit = { has_trait = arbitrary }
				multiply = 0
			}
		}
		desc = SCHEME_HEAD_OF_FAITH_REASON
	}
	# Culture
	## Esteemed Hospitality
	modifier = {
		add = -25
		scope:target.holder = {
			culture = { has_cultural_parameter = courtiers_and_guests_less_likely_to_join_schemes }
		}
		OR = {
			is_courtier_of = scope:target.holder
			is_pool_guest_of = scope:target.holder
			is_foreign_court_guest_of = scope:target.holder
		}
		desc = RESPECTED_HOST
	}
	# Traits
	## Disloyal
	modifier = {
		add = 20
		has_trait = disloyal
		desc = "HAS_DISLOYAL_TRAIT"
	}
	## Loyal
	modifier = {
		add = -10
		has_trait = loyal
		desc = "HAS_LOYAL_TRAIT"
	}
	## Conniving Puppetmaster
	modifier = {
		add = 25
		scope:owner = { has_trait_with_flag = agent_acceptance_25 }
		desc = INTRIGUE_EDUCATION_5_BONUS
	}
	# Royal Courts
	## CGV
	### Intrigue above CGV level 7.
	modifier = {
		add = 20
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			has_court_type = court_intrigue
			court_grandeur_current_level >= 7
		}
		desc = INTRIGUE_COURT_AGENT_ACCEPTANCE_REASON
	}
	## Amenities
	### Lodgings
	modifier = {
		add = 5
		is_pool_guest_of = scope:owner
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner = {
				amenity_level = { target = court_lodging_standards value = medium_amenity_level }
			}
		}
		desc = BONUS_TO_AGENT_RECRUITMENT_FROM_AMENITIES
	}
	modifier = {
		add = 10
		is_pool_guest_of = scope:owner
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner = {
				amenity_level = { target = court_lodging_standards value = high_amenity_level }
			}
		}
		desc = BONUS_TO_AGENT_RECRUITMENT_FROM_AMENITIES
	}
	modifier = {
		add = 15
		is_pool_guest_of = scope:owner
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner = {
				amenity_level = { target = court_lodging_standards value = very_high_amenity_level }
			}
		}
		desc = BONUS_TO_AGENT_RECRUITMENT_FROM_AMENITIES
	}
	modifier = {
		add = 20
		is_pool_guest_of = scope:owner
		scope:owner = {
			has_royal_court = yes
			has_dlc_feature = royal_court
			court_owner = {
				amenity_level = { target = court_lodging_standards value = max_amenity_level }
			}
		}
		desc = BONUS_TO_AGENT_RECRUITMENT_FROM_AMENITIES
	}
	# Lifestyles
	## Skulduggery Focus
	modifier = {
		scope:owner = { has_focus = intrigue_skulduggery_focus }
		add = 10
		desc = SCHEME_SKULDUGGERY_FOCUS
	}
	## Duty Focus
	modifier = {
		scope:target.holder = { has_focus = stewardship_duty_focus }
		add = -10
		desc = SCHEME_DUTY_FOCUS
	}
	# Dynasty Legacies
	## FP3 legacy track bonus
	modifier = {
		add = 10
		scope:target.holder = {
			is_lowborn = no
			dynasty = root.dynasty
			dynasty = { has_dynasty_perk = fp3_khvarenah_legacy_2 }
		}
		desc = "KHVARENAH_LEGACY_DESC"
	}
	# Event Content
	## Generic bonus modifier.
	modifier = {
		add = 20
		scope:owner = { has_character_modifier = event_bonus_to_agent_invite }
		desc = BONUS_TO_AGENT_RECRUITMENT
	}
	## Family stressed duty to family.
	modifier = {
		add = 20
		OR = {
			is_close_family_of = scope:owner
			is_spouse_of = scope:owner
		}
		scope:owner = { has_character_modifier = united_family_modifier }
		desc = SCHEME_DUTIOUS_FAMILY
	}
	## Hostage learnt behaviour due to being rewarded for acting as an agent for their family.
	modifier = {
		add = 50
		# Sometimes characters will die before they reply, so we have to check for this.
		is_alive = yes
		# Then the variable.
		var:family_schemer ?= scope:owner
		desc = SCHEME_TAUGHT_TO_SCHEME
	}
	## court_events.3060
	modifier = {
		add = 25
		scope:owner = { has_character_modifier = spies_behind_every_corner_modifier }
		desc = scheme.owner.spies_behind_every_corner_modifier.value_desc
	}
	modifier = {
		add = 25
		scope:target.holder = { has_character_modifier = spies_behind_every_corner_modifier }
		desc = scheme.target.holder.spies_behind_every_corner_modifier.value_desc
	}
}
#Feud modifier against titles
house_feud_hostile_scheme_title_success_modifier = {
	modifier = {
		add = 5
		exists = scope:owner.house
		exists = scope:target.holder.house
		scope:owner = {
			house_has_feud_relation_with_trigger = { TARGET = scope:target.holder }
			has_opinion_modifier = {
				modifier = house_feud_opinion
				target = scope:target.holder.house.house_head
			}
		}
		desc = HOSTILE_FAMILY_FEUD_SCHEMER_TITLE_BONUS
	}
}

# Deprecated; left it in in case there's any mods desperately reliant on this.
hostile_scheme_agent_success_chance_modifier = {
	first_valid = {
		modifier = {
			add = 75
			scope:target = {
				is_ruler = yes
			}
			has_council_position = councillor_spymaster
			scope:target.cp:councillor_spymaster = this
			desc = "SCHEME_AGENT_IS_SPYMASTER_IN_MY_COURT"
		}
		modifier = {
			add = 75
			scope:target = {
				is_ruler = no
			}
			has_council_position = councillor_spymaster
			exists = scope:target.liege.cp:councillor_spymaster
			scope:target.liege.cp:councillor_spymaster = this
			desc = "SCHEME_AGENT_IS_SPYMASTER"
		}
		modifier = {
			add = 50
			is_spouse_of = scope:target
			desc = "SCHEME_AGENT_IS_SPOUSE"
		}
		modifier = {
			add = 50
			has_relation_best_friend = scope:target
			desc = "SCHEME_AGENT_IS_BEST_FRIEND"
		}
		modifier = {
			add = 50
			has_relation_ward = scope:target
			desc = "SCHEME_AGENT_IS_GUARDIAN"
		}
		modifier = {
			add = 50
			is_diarch_of_target = scope:target
			desc = "SCHEME_AGENT_IS_DIARCH"
		}
		modifier = {
			add = 30
			has_relation_friend = scope:target
			desc = "SCHEME_AGENT_IS_FRIEND"
		}
		modifier = {
			add = 30
			is_concubine_of = scope:target
			desc = "SCHEME_AGENT_IS_CONCUBINE"
		}
		modifier = {
			add = 30
			has_relation_lover = scope:target
			desc = "SCHEME_AGENT_IS_LOVER"
		}
		modifier = {
			add = 30
			has_court_position = court_physician_court_position
			is_court_position_employer = {
		        court_position = court_physician_court_position
				who = scope:target
		    }
			desc = "SCHEME_AGENT_IS_COURT_PHYSICIAN"
		}
		modifier = {
			add = 30
			has_court_position = food_taster_court_position
			is_court_position_employer = {
		        court_position = food_taster_court_position
				who = scope:target
		    }
			desc = "SCHEME_AGENT_IS_FOOD_TASTER"
		}
		modifier = {
			add = 30
			has_court_position = cupbearer_court_position
			is_court_position_employer = {
		        court_position = cupbearer_court_position
				who = scope:target
		    }
			desc = "SCHEME_AGENT_IS_CUP_BEARER"
		}
		modifier = {
			add = 30
			has_court_position = chief_eunuch_court_position
			is_court_position_employer = {
		        court_position = chief_eunuch_court_position
				who = scope:target
		    }
			desc = "SCHEME_AGENT_IS_CHIEF_EUNUCH"
		}
		modifier = {
			add = 30
			has_court_position = bodyguard_court_position
			is_court_position_employer = {
		        court_position = bodyguard_court_position
				who = scope:target
		    }
			desc = "SCHEME_AGENT_IS_BODYGUARD"
		}
		modifier = {
			add = 15
			has_court_position = lady_in_waiting_court_position
			is_court_position_employer = {
		        court_position = lady_in_waiting_court_position
				who = scope:target
		    }
			desc = "SCHEME_AGENT_IS_LADY_IN_WAITING"
		}
		modifier = {
			add = 25
			is_councillor_of = scope:target
			NOT = { has_council_position = councillor_spymaster }
			desc = "SCHEME_AGENT_IS_COUNCILLOR"
		}
		modifier = {
			add = 20
			is_close_family_of = scope:target
			desc = "SCHEME_AGENT_IS_CLOSE_KIN"
		}
		modifier = {
			add = 15
			is_powerful_vassal_of = scope:target
			desc = "SCHEME_AGENT_IS_POWERFUL_VASSAL"
		}
		modifier = {
			add = 15
			is_extended_family_of = scope:target
			desc = "SCHEME_AGENT_IS_EXTENDED_FAMILY"
		}
		modifier = {
			add = 10
			scope:target = {
				is_ruler = yes
			}
			is_ruler = yes
			desc = "SCHEME_AGENT_IS_VASSAL"
		}
		modifier = {
			add = 10
			scope:target = {
				is_ruler = no
			}
			is_ruler = yes
			desc = "SCHEME_AGENT_IS_VASSAL_OF_LIEGE"
		}
		modifier = {
			add = 10
			exists = liege
			exists = scope:target.liege
			scope:target.liege = scope:owner
			liege = scope:owner
			desc = "SCHEME_AGENT_IS_COURTIER_MY_COURT"
		}
		modifier = {
			add = 10
			is_courtier_of = scope:target
			desc = "SCHEME_AGENT_IS_COURTIER"
		}
		modifier = {
			add = 10
			is_foreign_court_or_pool_guest_of = scope:target
			desc =  "SCHEME_AGENT_IS_GUEST"
		}

		modifier = {
			add = 5 #FALLBACK
			desc = "SCHEME_AGENT_IS_FELLOW_COURTIER"
		}
	}
	first_valid = {
		modifier = {
			add = 15
			has_relation_nemesis = scope:target
			desc = "SCHEME_AGENT_IS_NEMESIS"
		}
		modifier = {
			add = 10
			has_relation_rival = scope:target
			desc = "SCHEME_AGENT_IS_RIVAL"
		}
	}
	modifier = {
		add = intrigue
		desc =  "SCHEME_AGENT_INTRIGUE"
	}
}

start_hostile_scheme_ai_base_modifiers = {
	modifier = { # An Intimidated character is very unlikely to raise their hand
		add = -40
		scope:actor = {
			has_dread_level_towards = {
				target = scope:recipient
				level = 1
			}
		}
	}

	modifier = { # A Cowed character will never start a hostile scheme
		factor = 0
		scope:actor = {
			has_dread_level_towards = {
				target = scope:recipient
				level = 2
			}
		}
	}
}

personal_scheme_base_success_chance_modifiers = {
	# Thicker Than Water Perk
	modifier = {
		add = thicker_than_water_bonus
		desc = BEFRIEND_THICKER_THAN_WATER_PERK_DESC
		scope:owner = { has_perk = thicker_than_water_perk }
		scope:target = { is_close_or_extended_family_of = scope:owner }
	}
	# house_head_request_interaction
	modifier = {
		add = personal_scheme_variable_list_value
		scope:owner = { has_variable_list = supporting_personal_schemes }
		desc = HOUSE_HEAD_SCHEME_SUPPORT_DESC
	}
	modifier = {
		add = -10
		scope:owner = { has_character_modifier = personal_schemes_distracted_modifier }
		desc = personal_schemes_distracted_modifier
	}
	# Estate
	modifier = {
		scope:owner.domicile ?= { has_domicile_parameter = increased_success_personal_schemes_1 }
		add = estate_increased_personal_scheme_success_1_value
	}
	modifier = {
		scope:owner.domicile ?= { has_domicile_parameter = increased_success_personal_schemes_2 }
		add = estate_increased_personal_scheme_success_2_value
	}
	modifier = {
		scope:owner.domicile ?= { has_domicile_parameter = increased_success_personal_schemes_3 }
		add = estate_increased_personal_scheme_success_3_value
	}
	# House Relation
	modifier = {
		add = house_relation_personal_scheme_bonus_value
		scope:owner.house ?= {
			NOT = { scope:target.house ?= this }
			any_house_relation = {
				has_house_relation_parameter = personal_scheme_bonus
				any_relation_house = {
					scope:target.house ?= this
				}
			}
		}
		desc = house_relation_personal_scheme_bonus_desc
	}
}
